Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Add JSON support for Metafields with a nice UI/editor (#13159)
Damian Legawiecdafa22bd0f6c
diff --git a/.claude/settings.local.json b/.claude/settings.local.jsonindex 79b0688bf4..478a680bbf 100644--- a/.claude/settings.local.json+++ b/.claude/settings.local.json@@ -10,7 +10,8 @@"Bash(mv:*)","Bash(bundle exec rails:*)","Bash(curl:*)",- "Bash(bundle exec rake:*)"+ "Bash(bundle exec rake:*)",+ "Bash(bin/importmap:*)"],"deny": []}diff --git a/admin/app/javascript/spree/admin/application.js b/admin/app/javascript/spree/admin/application.jsindex e7b13f9157..fde45572fa 100644--- a/admin/app/javascript/spree/admin/application.js+++ b/admin/app/javascript/spree/admin/application.js@@ -54,6 +54,7 @@ import BulkOperationController from 'spree/admin/controllers/bulk_operation_contimport CalculatorFieldsController from 'spree/admin/controllers/calculator_fields_controller'import CalendarRangeController from 'spree/admin/controllers/calendar_range_controller'import Clipboard from 'spree/admin/controllers/clipboard_controller'+import CodeMirrorController from 'spree/admin/controllers/codemirror_controller'import ColorPaletteController from 'spree/admin/controllers/color_palette_controller'import ColorPickerController from 'spree/admin/controllers/color_picker_controller'import DrawerController from 'spree/admin/controllers/drawer_controller'@@ -104,6 +105,7 @@ application.register('calculator-fields', CalculatorFieldsController)application.register('calendar-range', CalendarRangeController)application.register('checkbox-select-all', CheckboxSelectAll)application.register('clipboard', Clipboard)+application.register('codemirror', CodeMirrorController)application.register('color-palette', ColorPaletteController)application.register('color-picker', ColorPickerController)application.register('dialog', Dialog)diff --git a/admin/app/javascript/spree/admin/controllers/codemirror_controller.js b/admin/app/javascript/spree/admin/controllers/codemirror_controller.jsnew file mode 100644index 0000000000..af6504fc39--- /dev/null+++ b/admin/app/javascript/spree/admin/controllers/codemirror_controller.js@@ -0,0 +1,45 @@+import { Controller } from '@hotwired/stimulus'+import { EditorView, basicSetup } from 'codemirror'+import { json } from '@codemirror/lang-json'+import { EditorState } from '@codemirror/state'++export default class extends Controller {+ static targets = ['editor', 'input']+ static values = {+ language: { type: String, default: 'json' }+ }++ connect() {+ const initialValue = this.inputTarget.value || ''++ const extensions = [+ basicSetup,+ EditorView.lineWrapping,+ EditorView.updateListener.of((update) => {+ if (update.docChanged) {+ this.inputTarget.value = update.state.doc.toString()+ }+ })+ ]++ // Add language support based on value+ if (this.languageValue === 'json') {+ extensions.push(json())+ }++ this.editorView = new EditorView({+ doc: initialValue,+ extensions: extensions,+ parent: this.editorTarget+ })++ // Hide the original textarea+ this.inputTarget.style.display = 'none'+ }++ disconnect() {+ if (this.editorView) {+ this.editorView.destroy()+ }+ }+}diff --git a/admin/app/views/spree/admin/metafields/types/_json.html.erb b/admin/app/views/spree/admin/metafields/types/_json.html.erbindex 9dcc23a7d1..0be02eaa3f 100644--- a/admin/app/views/spree/admin/metafields/types/_json.html.erb+++ b/admin/app/views/spree/admin/metafields/types/_json.html.erb@@ -1 +1,4 @@-<%= f.text_area :value, class: 'form-control', data: { controller: 'textarea-autogrow' } %>\ No newline at end of file+<div data-controller="codemirror" data-codemirror-language-value="json" class="form-control h-auto overflow-hidden p-0">+ <div data-codemirror-target="editor"></div>+ <%= f.text_area :value, data: { codemirror_target: 'input' }, class: 'invisible' %>+</div>\ No newline at end of filediff --git a/admin/config/importmap.rb b/admin/config/importmap.rbindex de05e4f63f..a72974df9a 100644--- a/admin/config/importmap.rb+++ b/admin/config/importmap.rb@@ -143,6 +143,25 @@ pin "@floating-ui/core", to: "@floating-ui--core.js", preload: ['application-sprpin "@floating-ui/utils", to: "@floating-ui--utils.js", preload: ['application-spree-admin'] # @0.2.10pin "@floating-ui/utils/dom", to: "@floating-ui--utils--dom.js", preload: ['application-spree-admin'] # @0.2.10+# CodeMirror+pin "@codemirror/commands", to: "@codemirror--commands.js" # @6.9.0+pin "@codemirror/lang-json", to: "@codemirror--lang-json.js" # @6.0.2+pin "@codemirror/language", to: "@codemirror--language.js" # @6.11.3+pin "@codemirror/state", to: "@codemirror--state.js" # @6.5.2+pin "@codemirror/view", to: "@codemirror--view.js" # @6.38.4+pin "codemirror" # @6.0.2+pin "@codemirror/autocomplete", to: "@codemirror--autocomplete.js" # @6.19.0+pin "@codemirror/lint", to: "@codemirror--lint.js" # @6.9.0+pin "@codemirror/search", to: "@codemirror--search.js" # @6.5.11+pin "@lezer/common", to: "@lezer--common.js" # @1.2.3+pin "@lezer/highlight", to: "@lezer--highlight.js" # @1.2.1+pin "@lezer/json", to: "@lezer--json.js" # @1.0.3+pin "@lezer/lr", to: "@lezer--lr.js" # @1.4.2+pin "@marijn/find-cluster-break", to: "@marijn--find-cluster-break.js" # @1.0.2+pin "crelt" # @1.0.6+pin "style-mod" # @4.1.2+pin "w3c-keyname" # @2.2.8+pin_all_from Spree::Admin::Engine.root.join('app/javascript/spree/admin/controllers'),under: 'spree/admin/controllers',to: 'spree/admin/controllers',diff --git a/admin/vendor/javascript/@codemirror--autocomplete.js b/admin/vendor/javascript/@codemirror--autocomplete.jsnew file mode 100644index 0000000000..de5fa85bc2--- /dev/null+++ b/admin/vendor/javascript/@codemirror--autocomplete.js@@ -0,0 +1,4 @@+// @codemirror/[email protected] downloaded from https://ga.jspm.io/npm:@codemirror/[email protected]/dist/index.js++import{Annotation as e,EditorSelection as t,StateEffect as n,codePointAt as i,codePointSize as o,fromCodePoint as s,Facet as l,combineConfig as r,StateField as a,Prec as c,MapMode as f,Transaction as u,Text as h,RangeValue as p,RangeSet as d,CharCategory as m}from"@codemirror/state";import{Direction as g,logException as v,showTooltip as b,EditorView as w,getTooltip as y,ViewPlugin as x,Decoration as C,WidgetType as S,keymap as A}from"@codemirror/view";import{syntaxTree as I,indentUnit as k}from"@codemirror/language";class CompletionContext{constructor(e,t,n,i){this.state=e;this.pos=t;this.explicit=n;this.view=i;this.abortListeners=[];this.abortOnDocChange=false}tokenBefore(e){let t=I(this.state).resolveInner(this.pos,-1);while(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);let n=Math.max(t.from,this.pos-250);let i=t.text.slice(n-t.from,this.pos-t.from);let o=i.search(M(e,false));return o<0?null:{from:n+o,to:this.pos,text:i.slice(o)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){if(e=="abort"&&this.abortListeners){this.abortListeners.push(t);n&&n.onDocChange&&(this.abortOnDocChange=true)}}}function D(e){let t=Object.keys(e).join("");let n=/\w/.test(t);n&&(t=t.replace(/\w/g,""));return`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function O(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=true;for(let e=1;e<i.length;e++)n[i[e]]=true}let i=D(t)+D(n)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function R(e){let t=e.map((e=>typeof e=="string"?{label:e}:e));let[n,i]=t.every((e=>/^\w+$/.test(e.label)))?[/\w*$/,/\w+$/]:O(t);return e=>{let o=e.matchBefore(i);return o||e.explicit?{from:o?o.from:e.pos,options:t,validFor:n}:null}}function T(e,t){return n=>{for(let i=I(n.state).resolveInner(n.pos,-1);i;i=i.parent){if(e.indexOf(i.name)>-1)return t(n);if(i.type.isTop)break}return null}}function E(e,t){return n=>{for(let t=I(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}class Option{constructor(e,t,n,i){this.completion=e;this.source=t;this.match=n;this.score=i}}function L(e){return e.selection.main.from}function M(e,t){var n;let{source:i}=e;let o=t&&i[0]!="^",s=i[i.length-1]!="$";return o||s?new RegExp(`${o?"^":""}(?:${i})${s?"$":""}`,(n=e.flags)!==null&&n!==void 0?n:e.ignoreCase?"i":""):e}const P=e.define();function F(e,n,i,o){let{main:s}=e.selection,l=i-s.from,r=o-s.from;return{...e.changeByRange((a=>{if(a!=s&&i!=o&&e.sliceDoc(a.from+l,a.from+r)!=e.sliceDoc(i,o))return{range:a};let c=e.toText(n);return{changes:{from:a.from+l,to:o==s.from?a.to:a.from+r,insert:c},range:t.cursor(a.from+l+c.length)}})),scrollIntoView:true,userEvent:"input.complete"}}const B=new WeakMap;function $(e){if(!Array.isArray(e))return e;let t=B.get(e);t||B.set(e,t=R(e));return t}const N=n.define();const U=n.define();class FuzzyMatcher{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<e.length;){let n=i(e,t),s=o(n);this.chars.push(n);let l=e.slice(t,t+s),r=l.toUpperCase();this.folded.push(i(r==l?l.toLowerCase():r,0));t+=s}this.astral=e.length!=this.chars.length}ret(e,t){this.score=e;this.matched=t;return this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:l,precise:r,byWord:a}=this;if(t.length==1){let s=i(e,0),l=o(s);let r=l==e.length?0:-100;if(s==t[0]);else{if(s!=n[0])return null;r+=-200}return this.ret(r,[0,l])}let c=e.indexOf(this.pattern);if(c==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let f=t.length,u=0;if(c<0){for(let s=0,r=Math.min(e.length,200);s<r&&u<f;){let r=i(e,s);r!=t[u]&&r!=n[u]||(l[u++]=s);s+=o(r)}if(u<f)return null}let h=0;let p=0,d=false;let m=0,g=-1,v=-1;let b=/[a-z]/.test(e),w=true;for(let l=0,u=Math.min(e.length,200),y=0;l<u&&p<f;){let u=i(e,l);if(c<0){h<f&&u==t[h]&&(r[h++]=l);if(m<f)if(u==t[m]||u==n[m]){m==0&&(g=l);v=l+1;m++}else m=0}let x,C=u<255?u>=48&&u<=57||u>=97&&u<=122?2:u>=65&&u<=90?1:0:(x=s(u))!=x.toLowerCase()?1:x!=x.toUpperCase()?2:0;(!l||C==1&&b||y==0&&C!=0)&&(t[p]==u||n[p]==u&&(d=true)?a[p++]=l:a.length&&(w=false));y=C;l+=o(u)}return p==f&&a[0]==0&&w?this.result((d?-200:0)-100,a,e):m==f&&g==0?this.ret(-200-e.length+(v==e.length?0:-100),[0,v]):c>-1?this.ret(-700-e.length,[c,c+this.pattern.length]):m==f?this.ret(-900-e.length,[g,v]):p==f?this.result((d?-200:0)-100-700+(w?0:-1100),a,e):t.length==2?null:this.result((l[0]?-700:0)-200-1100,l,e)}result(e,t,n){let s=[],l=0;for(let e of t){let t=e+(this.astral?o(i(n,e)):1);if(l&&s[l-1]==e)s[l-1]=t;else{s[l++]=e;s[l++]=t}}return this.ret(e-n.length,s)}}class StrictMatcher{constructor(e){this.pattern=e;this.matched=[];this.score=0;this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length);let n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;if(n==null)return null;this.matched=[0,t.length];this.score=n+(e.length==this.pattern.length?0:-100);return this}}const W=l.define({combine(e){return r(e,{activateOnTyping:true,activateOnCompletion:()=>false,activateOnTypingDelay:100,selectOnOpen:true,override:null,closeOnBlur:true,maxRenderedOptions:100,defaultKeymap:true,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:false,icons:true,addToOptions:[],positionInfo:j,filterStrict:false,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=>q(e(n),t(n)),optionClass:(e,t)=>n=>q(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function q(e,t){return e?t?e+" "+t:e:t}function j(e,t,n,i,o,s){let l=e.textDirection==g.RTL,r=l,a=false;let c,f,u="top";let h=t.left-o.left,p=o.right-t.right;let d=i.right-i.left,m=i.bottom-i.top;r&&h<Math.min(d,p)?r=false:!r&&p<Math.min(d,h)&&(r=true);if(d<=(r?h:p)){c=Math.max(o.top,Math.min(n.top,o.bottom-m))-t.top;f=Math.min(400,r?h:p)}else{a=true;f=Math.min(400,(l?t.right:o.right-t.left)-30);let e=o.bottom-t.bottom;if(e>=m||e>t.top)c=n.bottom-t.top;else{u="bottom";c=t.bottom-n.top}}let v=(t.bottom-t.top)/s.offsetHeight;let b=(t.right-t.left)/s.offsetWidth;return{style:`${u}: ${c/v}px; max-width: ${f/b}px`,class:"cm-completionInfo-"+(a?l?"left-narrow":"right-narrow":r?"left":"right")}}function z(e){let t=e.addToOptions.slice();e.icons&&t.push({render(e){let t=document.createElement("div");t.classList.add("cm-completionIcon");e.type&&t.classList.add(...e.type.split(/\s+/g).map((e=>"cm-completionIcon-"+e)));t.setAttribute("aria-hidden","true");return t},position:20});t.push({render(e,t,n,i){let o=document.createElement("span");o.className="cm-completionLabel";let s=e.displayLabel||e.label,l=0;for(let e=0;e<i.length;){let t=i[e++],n=i[e++];t>l&&o.appendChild(document.createTextNode(s.slice(l,t)));let r=o.appendChild(document.createElement("span"));r.appendChild(document.createTextNode(s.slice(t,n)));r.className="cm-completionMatchedText";l=n}l<s.length&&o.appendChild(document.createTextNode(s.slice(l)));return o},position:50},{render(e){if(!e.detail)return null;let t=document.createElement("span");t.className="cm-completionDetail";t.textContent=e.detail;return t},position:80});return t.sort(((e,t)=>e.position-t.position)).map((e=>e.render))}function H(e,t,n){if(e<=n)return{from:0,to:e};t<0&&(t=0);if(t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let i=Math.floor((e-t)/n);return{from:e-(i+1)*n,to:e-i*n}}class CompletionTooltip{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:e=>this.placeInfo(e),key:this};this.space=null;this.currentClass="";let i=e.state.field(t);let{options:o,selected:s}=i.open;let l=e.state.facet(W);this.optionContent=z(l);this.optionClass=l.optionClass;this.tooltipClass=l.tooltipClass;this.range=H(o.length,s,l.maxRenderedOptions);this.dom=document.createElement("div");this.dom.className="cm-tooltip-autocomplete";this.updateTooltipClass(e.state);this.dom.addEventListener("mousedown",(n=>{let{options:i}=e.state.field(t).open;for(let t,o=n.target;o&&o!=this.dom;o=o.parentNode)if(o.nodeName=="LI"&&(t=/-(\d+)$/.exec(o.id))&&+t[1]<i.length){this.applyCompletion(e,i[+t[1]]);n.preventDefault();return}}));this.dom.addEventListener("focusout",(t=>{let n=e.state.field(this.stateField,false);n&&n.tooltip&&e.state.facet(W).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:U.of(null)})}));this.showOptions(o,i.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);let i=e.startState.field(this.stateField);this.updateTooltipClass(e.state);if(n!=i){let{options:o,selected:s,disabled:l}=n.open;if(!i.open||i.open.options!=o){this.range=H(o.length,s,e.state.facet(W).maxRenderedOptions);this.showOptions(o,n.id)}this.updateSel();l!=((t=i.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(" "))e&&this.dom.classList.remove(e);for(let e of t.split(" "))e&&this.dom.classList.add(e);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.from||t.selected>=this.range.to){this.range=H(t.options.length,t.selected,this.view.state.facet(W).maxRenderedOptions);this.showOptions(t.options,e.id)}if(this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:n}=t.options[t.selected];let{info:i}=n;if(!i)return;let o=typeof i==="string"?document.createTextNode(i):i(n);if(!o)return;"then"in o?o.then((t=>{t&&this.view.state.field(this.stateField,false)==e&&this.addInfoPane(t,n)})).catch((e=>v(this.view.state,e,"completion info"))):this.addInfoPane(o,n)}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");n.className="cm-tooltip cm-completionInfo";if(e.nodeType!=null){n.appendChild(e);this.infoDestroy=null}else{let{dom:t,destroy:i}=e;n.appendChild(t);this.infoDestroy=i||null}this.dom.appendChild(n);this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,i=this.range.from;n;n=n.nextSibling,i++)if(n.nodeName=="LI"&&n.id)if(i==e){if(!n.hasAttribute("aria-selected")){n.setAttribute("aria-selected","true");t=n}}else n.hasAttribute("aria-selected")&&n.removeAttribute("aria-selected");else i--;t&&K(this.list,t);return t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect();let n=this.info.getBoundingClientRect();let i=e.getBoundingClientRect();let o=this.space;if(!o){let e=this.dom.ownerDocument.documentElement;o={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return i.top>Math.min(o.bottom,t.bottom)-10||i.bottom<Math.max(o.top,t.top)+10?null:this.view.state.facet(W).positionInfo(this.view,t,i,n,o,this.dom)}placeInfo(e){if(this.info)if(e){e.style&&(this.info.style.cssText=e.style);this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")}else this.info.style.cssText="top: -1e6px"}createListBox(e,t,n){const i=document.createElement("ul");i.id=t;i.setAttribute("role","listbox");i.setAttribute("aria-expanded","true");i.setAttribute("aria-label",this.view.state.phrase("Completions"));i.addEventListener("mousedown",(e=>{e.target==i&&e.preventDefault()}));let o=null;for(let s=n.from;s<n.to;s++){let{completion:l,match:r}=e[s],{section:a}=l;if(a){let e=typeof a=="string"?a:a.name;if(e!=o&&(s>n.from||n.from==0)){o=e;if(typeof a!="string"&&a.header)i.appendChild(a.header(a));else{let t=i.appendChild(document.createElement("completion-section"));t.textContent=e}}}const c=i.appendChild(document.createElement("li"));c.id=t+"-"+s;c.setAttribute("role","option");let f=this.optionClass(l);f&&(c.className=f);for(let e of this.optionContent){let t=e(l,this.view.state,this.view,r);t&&c.appendChild(t)}}n.from&&i.classList.add("cm-completionListIncompleteTop");n.to<e.length&&i.classList.add("cm-completionListIncompleteBottom");return i}destroyInfo(){if(this.info){this.infoDestroy&&this.infoDestroy();this.info.remove();this.info=null}}destroy(){this.destroyInfo()}}function V(e,t){return n=>new CompletionTooltip(n,e,t)}function K(e,t){let n=e.getBoundingClientRect();let i=t.getBoundingClientRect();let o=n.height/e.offsetHeight;i.top<n.top?e.scrollTop-=(n.top-i.top)/o:i.bottom>n.bottom&&(e.scrollTop+=(i.bottom-n.bottom)/o)}function Q(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function X(e,t){let n=[];let i=null,o=null;let s=e=>{n.push(e);let{section:t}=e.completion;if(t){i||(i=[]);let e=typeof t=="string"?t:t.name;i.some((t=>t.name==e))||i.push(typeof t=="string"?{name:e}:t)}};let l=t.facet(W);for(let i of e)if(i.hasResult()){let e=i.result.getMatch;if(i.result.filter===false)for(let t of i.result.options)s(new Option(t,i.source,e?e(t):[],1e9-n.length));else{let n,r=t.sliceDoc(i.from,i.to);let a=l.filterStrict?new StrictMatcher(r):new FuzzyMatcher(r);for(let t of i.result.options)if(n=a.match(t.label)){let l=t.displayLabel?e?e(t,n.matched):[]:n.matched;let r=n.score+(t.boost||0);s(new Option(t,i.source,l,r));if(typeof t.section=="object"&&t.section.rank==="dynamic"){let{name:e}=t.section;o||(o=Object.create(null));o[e]=Math.max(r,o[e]||-1e9)}}}}if(i){let e=Object.create(null),t=0;let s=(e,t)=>(e.rank==="dynamic"&&t.rank==="dynamic"?o[t.name]-o[e.name]:0)||(typeof e.rank=="number"?e.rank:1e9)-(typeof t.rank=="number"?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of i.sort(s)){t-=1e5;e[n.name]=t}for(let t of n){let{section:n}=t.completion;n&&(t.score+=e[typeof n=="string"?n:n.name])}}let r=[],a=null;let c=l.compareCompletions;for(let e of n.sort(((e,t)=>t.score-e.score||c(e.completion,t.completion)))){let t=e.completion;!a||a.label!=t.label||a.detail!=t.detail||a.type!=null&&t.type!=null&&a.type!=t.type||a.apply!=t.apply||a.boost!=t.boost?r.push(e):Q(e.completion)>Q(a)&&(r[r.length-1]=e);a=e.completion}return r}class CompletionDialog{constructor(e,t,n,i,o,s){this.options=e;this.attrs=t;this.tooltip=n;this.timestamp=i;this.selected=o;this.disabled=s}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new CompletionDialog(this.options,J(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,i,o,s){if(i&&!s&&e.some((e=>e.isPending)))return i.setDisabled();let l=X(e,t);if(!l.length)return i&&e.some((e=>e.isPending))?i.setDisabled():null;let r=t.facet(W).selectOnOpen?0:-1;if(i&&i.selected!=r&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<l.length;t++)if(l[t].completion==e){r=t;break}}return new CompletionDialog(l,J(n,r),{pos:e.reduce(((e,t)=>t.hasResult()?Math.min(e,t.from):e),1e8),create:le,above:o.aboveCursor},i?i.timestamp:Date.now(),r,false)}map(e){return new CompletionDialog(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new CompletionDialog(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,true)}}class CompletionState{constructor(e,t,n){this.active=e;this.id=t;this.open=n}static start(){return new CompletionState(Z,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,n=t.facet(W);let i=n.override||t.languageDataAt("autocomplete",L(t)).map($);let o=i.map((t=>{let i=this.active.find((e=>e.source==t))||new ActiveSource(t,this.active.some((e=>e.state!=0))?1:0);return i.update(e,n)}));o.length==this.active.length&&o.every(((e,t)=>e==this.active[t]))&&(o=this.active);let s=this.open,l=e.effects.some((e=>e.is(ne)));s&&e.docChanged&&(s=s.map(e.changes));e.selection||o.some((t=>t.hasResult()&&e.changes.touchesRange(t.from,t.to)))||!_(o,this.active)||l?s=CompletionDialog.build(o,t,this.id,s,n,l):s&&s.disabled&&!o.some((e=>e.isPending))&&(s=null);!s&&o.every((e=>!e.isPending))&&o.some((e=>e.hasResult()))&&(o=o.map((e=>e.hasResult()?new ActiveSource(e.source,0):e)));for(let t of e.effects)t.is(ie)&&(s=s&&s.setSelected(t.value,this.id));return o==this.active&&s==this.open?this:new CompletionState(o,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Y:G}}function _(e,t){if(e==t)return true;for(let n=0,i=0;;){while(n<e.length&&!e[n].hasResult())n++;while(i<t.length&&!t[i].hasResult())i++;let o=n==e.length,s=i==t.length;if(o||s)return o==s;if(e[n++].result!=t[i++].result)return false}}const Y={"aria-autocomplete":"list"};const G={};function J(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};t>-1&&(n["aria-activedescendant"]=e+"-"+t);return n}const Z=[];function ee(e,t){if(e.isUserEvent("input.complete")){let n=e.annotation(P);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class ActiveSource{constructor(e,t,n=false){this.source=e;this.state=t;this.explicit=n}hasResult(){return false}get isPending(){return this.state==1}update(e,t){let n=ee(e,t),i=this;(n&8||n&16&&this.touches(e))&&(i=new ActiveSource(i.source,0));n&4&&i.state==0&&(i=new ActiveSource(this.source,1));i=i.updateFor(e,n);for(let t of e.effects)if(t.is(N))i=new ActiveSource(i.source,1,t.value);else if(t.is(U))i=new ActiveSource(i.source,0);else if(t.is(ne))for(let e of t.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(L(e.state))}}class ActiveResult extends ActiveSource{constructor(e,t,n,i,o,s){super(e,3,t);this.limit=n;this.result=i;this.from=o;this.to=s}hasResult(){return true}updateFor(e,t){var n;if(!(t&3))return this.map(e.changes);let i=this.result;i.map&&!e.changes.empty&&(i=i.map(i,e.changes));let o=e.changes.mapPos(this.from),s=e.changes.mapPos(this.to,1);let l=L(e.state);if(l>s||!i||t&2&&(L(e.startState)==this.from||l<this.limit))return new ActiveSource(this.source,t&4?1:0);let r=e.changes.mapPos(this.limit);return te(i.validFor,e.state,o,s)?new ActiveResult(this.source,this.explicit,r,i,o,s):i.update&&(i=i.update(i,o,s,new CompletionContext(e.state,l,false)))?new ActiveResult(this.source,this.explicit,r,i,i.from,(n=i.to)!==null&&n!==void 0?n:L(e.state)):new ActiveSource(this.source,1,this.explicit)}map(e){if(e.empty)return this;let t=this.result.map?this.result.map(this.result,e):this.result;return t?new ActiveResult(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new ActiveSource(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function te(e,t,n,i){if(!e)return false;let o=t.sliceDoc(n,i);return typeof e=="function"?e(o,n,i,t):M(e,true).test(o)}const ne=n.define({map(e,t){return e.map((e=>e.map(t)))}});const ie=n.define();const oe=a.define({create(){return CompletionState.start()},update(e,t){return e.update(t)},provide:e=>[b.from(e,(e=>e.tooltip)),w.contentAttributes.from(e,(e=>e.attrs))]});function se(e,t){const n=t.completion.apply||t.completion.label;let i=e.state.field(oe).active.find((e=>e.source==t.source));if(!(i instanceof ActiveResult))return false;typeof n=="string"?e.dispatch({...F(e.state,n,i.from,i.to),annotations:P.of(t.completion)}):n(e,t.completion,i.from,i.to);return true}const le=V(oe,se);function re(e,t="option"){return n=>{let i=n.state.field(oe,false);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<n.state.facet(W).interactionDelay)return false;let o,s=1;t=="page"&&(o=y(n,i.open.tooltip))&&(s=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector("li").offsetHeight)-1));let{length:l}=i.open.options;let r=i.open.selected>-1?i.open.selected+s*(e?1:-1):e?0:l-1;r<0?r=t=="page"?0:l-1:r>=l&&(r=t=="page"?l-1:0);n.dispatch({effects:ie.of(r)});return true}}const ae=e=>{let t=e.state.field(oe,false);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(W).interactionDelay)&&se(e,t.open.options[t.open.selected])};const ce=e=>{let t=e.state.field(oe,false);if(!t)return false;e.dispatch({effects:N.of(true)});return true};const fe=e=>{let t=e.state.field(oe,false);if(!t||!t.active.some((e=>e.state!=0)))return false;e.dispatch({effects:U.of(null)});return true};class RunningQuery{constructor(e,t){this.active=e;this.context=t;this.time=Date.now();this.updates=[];this.done=void 0}}const ue=50,he=1e3;const pe=x.fromClass(class{constructor(e){this.view=e;this.debounceUpdate=-1;this.running=[];this.debounceAccept=-1;this.pendingStart=false;this.composing=0;for(let t of e.state.field(oe).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(oe);let n=e.state.facet(W);if(!e.selectionSet&&!e.docChanged&&e.startState.field(oe)==t)return;let i=e.transactions.some((e=>{let t=ee(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)}));for(let t=0;t<this.running.length;t++){let n=this.running[t];if(i||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>ue&&Date.now()-n.time>he){for(let e of n.context.abortListeners)try{e()}catch(e){v(this.view.state,e)}n.context.abortListeners=null;this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate);e.transactions.some((e=>e.effects.some((e=>e.is(N)))))&&(this.pendingStart=true);let o=this.pendingStart?50:n.activateOnTypingDelay;this.debounceUpdate=t.active.some((e=>e.isPending&&!this.running.some((t=>t.active.source==e.source))))?setTimeout((()=>this.startUpdate()),o):-1;if(this.composing!=0)for(let t of e.transactions)t.isUserEvent("input.type")?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1;this.pendingStart=false;let{state:e}=this.view,t=e.field(oe);for(let e of t.active)e.isPending&&!this.running.some((t=>t.active.source==e.source))&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(W).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=L(t);let i=new CompletionContext(t,n,e.explicit,this.view);let o=new RunningQuery(e,i);this.running.push(o);Promise.resolve(e.source(i)).then((e=>{if(!o.context.aborted){o.done=e||null;this.scheduleAccept()}}),(e=>{this.view.dispatch({effects:U.of(null)});v(this.view.state,e)}))}scheduleAccept(){this.running.every((e=>e.done!==void 0))?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(W).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept);this.debounceAccept=-1;let t=[];let n=this.view.state.facet(W),i=this.view.state.field(oe);for(let o=0;o<this.running.length;o++){let s=this.running[o];if(s.done===void 0)continue;this.running.splice(o--,1);if(s.done){let i=L(s.updates.length?s.updates[0].startState:this.view.state);let o=Math.min(i,s.done.from+(s.active.explicit?0:1));let l=new ActiveResult(s.active.source,s.active.explicit,o,s.done,s.done.from,(e=s.done.to)!==null&&e!==void 0?e:i);for(let e of s.updates)l=l.update(e,n);if(l.hasResult()){t.push(l);continue}}let l=i.active.find((e=>e.source==s.active.source));if(l&&l.isPending)if(s.done==null){let e=new ActiveSource(s.active.source,0);for(let t of s.updates)e=e.update(t,n);e.isPending||t.push(e)}else this.startQuery(l)}(t.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:ne.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(oe,false);if(t&&t.tooltip&&this.view.state.facet(W).closeOnBlur){let n=t.open&&y(this.view,t.open.tooltip);n&&n.dom.contains(e.relatedTarget)||setTimeout((()=>this.view.dispatch({effects:U.of(null)})),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout((()=>this.view.dispatch({effects:N.of(false)})),20);this.composing=0}}});const de=typeof navigator=="object"&&/Win/.test(navigator.platform);const me=c.highest(w.domEventHandlers({keydown(e,t){let n=t.state.field(oe,false);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(de&&e.altKey)||e.metaKey)return false;let i=n.open.options[n.open.selected];let o=n.active.find((e=>e.source==i.source));let s=i.completion.commitCharacters||o.result.commitCharacters;s&&s.indexOf(e.key)>-1&&se(t,i);return false}}));const ge=w.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:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".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:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class FieldPos{constructor(e,t,n,i){this.field=e;this.line=t;this.from=n;this.to=i}}class FieldRange{constructor(e,t,n){this.field=e;this.from=t;this.to=n}map(e){let t=e.mapPos(this.from,-1,f.TrackDel);let n=e.mapPos(this.to,1,f.TrackDel);return t==null||n==null?null:new FieldRange(this.field,t,n)}}class Snippet{constructor(e,t){this.lines=e;this.fieldPositions=t}instantiate(e,t){let n=[],i=[t];let o=e.doc.lineAt(t),s=/^\s*/.exec(o.text)[0];for(let o of this.lines){if(n.length){let n=s,l=/^\t*/.exec(o)[0].length;for(let t=0;t<l;t++)n+=e.facet(k);i.push(t+n.length-l);o=n+o.slice(l)}n.push(o);t+=o.length+1}let l=this.fieldPositions.map((e=>new FieldRange(e.field,i[e.line]+e.from,i[e.line]+e.to)));return{text:n,ranges:l}}static parse(e){let t=[];let n,i=[],o=[];for(let s of e.split(/\r\n?|\n/)){while(n=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(s)){let e=n[1]?+n[1]:null,l=n[2]||n[3]||"",r=-1;let a=l.replace(/\\[{}]/g,(e=>e[1]));for(let n=0;n<t.length;n++)(e!=null?t[n].seq!=e:!a||t[n].name!=a)||(r=n);if(r<0){let n=0;while(n<t.length&&(e==null||t[n].seq!=null&&t[n].seq<e))n++;t.splice(n,0,{seq:e,name:a});r=n;for(let e of o)e.field>=r&&e.field++}for(let e of o)if(e.line==i.length&&e.from>n.index){let t=n[2]?3+(n[1]||"").length:2;e.from-=t;e.to-=t}o.push(new FieldPos(r,i.length,n.index,n.index+a.length));s=s.slice(0,n.index)+l+s.slice(n.index+n[0].length)}s=s.replace(/\\([{}])/g,((e,t,n)=>{for(let e of o)if(e.line==i.length&&e.from>n){e.from--;e.to--}return t}));i.push(s)}return new Snippet(i,o)}}let ve=C.widget({widget:new class extends S{toDOM(){let e=document.createElement("span");e.className="cm-snippetFieldPosition";return e}ignoreEvent(){return false}}});let be=C.mark({class:"cm-snippetField"});class ActiveSnippet{constructor(e,t){this.ranges=e;this.active=t;this.deco=C.set(e.map((e=>(e.from==e.to?ve:be).range(e.from,e.to))),true)}map(e){let t=[];for(let n of this.ranges){let i=n.map(e);if(!i)return null;t.push(i)}return new ActiveSnippet(t,this.active)}selectionInsideField(e){return e.ranges.every((e=>this.ranges.some((t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))))}}const we=n.define({map(e,t){return e&&e.map(t)}});const ye=n.define();const xe=a.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(we))return n.value;if(n.is(ye)&&e)return new ActiveSnippet(e.ranges,n.value)}e&&t.docChanged&&(e=e.map(t.changes));e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null);return e},provide:e=>w.decorations.from(e,(e=>e?e.deco:C.none))});function Ce(e,n){return t.create(e.filter((e=>e.field==n)).map((e=>t.range(e.from,e.to))))}function Se(e){let t=Snippet.parse(e);return(e,i,o,s)=>{let{text:l,ranges:r}=t.instantiate(e.state,o);let{main:a}=e.state.selection;let c={changes:{from:o,to:s==a.from?a.to:s,insert:h.of(l)},scrollIntoView:true,annotations:i?[P.of(i),u.userEvent.of("input.complete")]:void 0};r.length&&(c.selection=Ce(r,0));if(r.some((e=>e.field>0))){let t=new ActiveSnippet(r,0);let i=c.effects=[we.of(t)];e.state.field(xe,false)===void 0&&i.push(n.appendConfig.of([xe,Le,Pe,ge]))}e.dispatch(e.state.update(c))}}function Ae(e){return({state:t,dispatch:n})=>{let i=t.field(xe,false);if(!i||e<0&&i.active==0)return false;let o=i.active+e,s=e>0&&!i.ranges.some((t=>t.field==o+e));n(t.update({selection:Ce(i.ranges,o),effects:we.of(s?null:new ActiveSnippet(i.ranges,o)),scrollIntoView:true}));return true}}const Ie=({state:e,dispatch:t})=>{let n=e.field(xe,false);if(!n)return false;t(e.update({effects:we.of(null)}));return true};const ke=Ae(1);const De=Ae(-1);function Oe(e){let t=e.field(xe,false);return!!(t&&t.ranges.some((e=>e.field==t.active+1)))}function Re(e){let t=e.field(xe,false);return!!(t&&t.active>0)}const Te=[{key:"Tab",run:ke,shift:De},{key:"Escape",run:Ie}];const Ee=l.define({combine(e){return e.length?e[0]:Te}});const Le=c.highest(A.compute([Ee],(e=>e.facet(Ee))));function Me(e,t){return{...t,apply:Se(e)}}const Pe=w.domEventHandlers({mousedown(e,t){let n,i=t.state.field(xe,false);if(!i||(n=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return false;let o=i.ranges.find((e=>e.from<=n&&e.to>=n));if(!o||o.field==i.active)return false;t.dispatch({selection:Ce(i.ranges,o.field),effects:we.of(i.ranges.some((e=>e.field>o.field))?new ActiveSnippet(i.ranges,o.field):null),scrollIntoView:true});return true}});function Fe(e){let t=e.replace(/[\]\-\\]/g,"\\$&");try{return new RegExp(`[\\p{Alphabetic}\\p{Number}_${t}]+`,"ug")}catch(e){return new RegExp(`[w${t}]`,"g")}}function Be(e,t){return new RegExp(t(e.source),e.unicode?"u":"")}const $e=Object.create(null);function Ne(e){return $e[e]||($e[e]=new WeakMap)}function Ue(e,t,n,i,o){for(let s=e.iterLines(),l=0;!s.next().done;){let e,{value:r}=s;t.lastIndex=0;while(e=t.exec(r))if(!i[e[0]]&&l+e.index!=o){n.push({type:"text",label:e[0]});i[e[0]]=true;if(n.length>=2e3)return}l+=r.length+1}}function We(e,t,n,i,o){let s=e.length>=1e3;let l=s&&t.get(e);if(l)return l;let r=[],a=Object.create(null);if(e.children){let s=0;for(let l of e.children){if(l.length>=1e3){for(let e of We(l,t,n,i-s,o-s))if(!a[e.label]){a[e.label]=true;r.push(e)}}else Ue(l,n,r,a,o-s);s+=l.length+1}}else Ue(e,n,r,a,o);s&&r.length<2e3&&t.set(e,r);return r}const qe=e=>{let t=e.state.languageDataAt("wordChars",e.pos).join("");let n=Fe(t);let i=e.matchBefore(Be(n,(e=>e+"$")));if(!i&&!e.explicit)return null;let o=i?i.from:e.pos;let s=We(e.state.doc,Ne(t),n,5e4,o);return{from:o,options:s,validFor:Be(n,(e=>"^"+e))}};const je={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]};const ze=n.define({map(e,t){let n=t.mapPos(e,-1,f.TrackAfter);return n==null?void 0:n}});const He=new class extends p{};He.startSide=1;He.endSide=-1;const Ve=a.define({create(){return d.empty},update(e,t){e=e.map(t.changes);if(t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(ze)&&(e=e.update({add:[He.range(n.value,n.value+1)]}));return e}});function Ke(){return[Ge,Ve]}const Qe="()[]{}<>«»»«[]{}";function Xe(e){for(let t=0;t<Qe.length;t+=2)if(Qe.charCodeAt(t)==e)return Qe.charAt(t+1);return s(e<128?e:e+1)}function _e(e,t){return e.languageDataAt("closeBrackets",t)[0]||je}const Ye=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent);const Ge=w.inputHandler.of(((e,t,n,s)=>{if((Ye?e.composing:e.compositionStarted)||e.state.readOnly)return false;let l=e.state.selection.main;if(s.length>2||s.length==2&&o(i(s,0))==1||t!=l.from||n!=l.to)return false;let r=et(e.state,s);if(!r)return false;e.dispatch(r);return true}));const Je=({state:e,dispatch:n})=>{if(e.readOnly)return false;let o=_e(e,e.selection.main.head);let s=o.brackets||je.brackets;let l=null,r=e.changeByRange((n=>{if(n.empty){let o=it(e.doc,n.head);for(let l of s)if(l==o&&nt(e.doc,n.head)==Xe(i(l,0)))return{changes:{from:n.head-l.length,to:n.head+l.length},range:t.cursor(n.head-l.length)}}return{range:l=n}}));l||n(e.update(r,{scrollIntoView:true,userEvent:"delete.backward"}));return!l};const Ze=[{key:"Backspace",run:Je}];function et(e,t){let n=_e(e,e.selection.main.head);let o=n.brackets||je.brackets;for(let s of o){let l=Xe(i(s,0));if(t==s)return l==s?lt(e,s,o.indexOf(s+s+s)>-1,n):ot(e,s,l,n.before||je.before);if(t==l&&tt(e,e.selection.main.from))return st(e,s,l)}return null}function tt(e,t){let n=false;e.field(Ve).between(0,e.doc.length,(e=>{e==t&&(n=true)}));return n}function nt(e,t){let n=e.sliceString(t,t+2);return n.slice(0,o(i(n,0)))}function it(e,t){let n=e.sliceString(t-2,t);return o(i(n,0))==n.length?n:n.slice(1)}function ot(e,n,i,o){let s=null,l=e.changeByRange((l=>{if(!l.empty)return{changes:[{insert:n,from:l.from},{insert:i,from:l.to}],effects:ze.of(l.to+n.length),range:t.range(l.anchor+n.length,l.head+n.length)};let r=nt(e.doc,l.head);return!r||/\s/.test(r)||o.indexOf(r)>-1?{changes:{insert:n+i,from:l.head},effects:ze.of(l.head+n.length),range:t.cursor(l.head+n.length)}:{range:s=l}}));return s?null:e.update(l,{scrollIntoView:true,userEvent:"input.type"})}function st(e,n,i){let o=null,s=e.changeByRange((n=>n.empty&&nt(e.doc,n.head)==i?{changes:{from:n.head,to:n.head+i.length,insert:i},range:t.cursor(n.head+i.length)}:o={range:n}));return o?null:e.update(s,{scrollIntoView:true,userEvent:"input.type"})}function lt(e,n,i,o){let s=o.stringPrefixes||je.stringPrefixes;let l=null,r=e.changeByRange((o=>{if(!o.empty)return{changes:[{insert:n,from:o.from},{insert:n,from:o.to}],effects:ze.of(o.to+n.length),range:t.range(o.anchor+n.length,o.head+n.length)};let r,a=o.head,c=nt(e.doc,a);if(c==n){if(rt(e,a))return{changes:{insert:n+n,from:a},effects:ze.of(a+n.length),range:t.cursor(a+n.length)};if(tt(e,a)){let o=i&&e.sliceDoc(a,a+n.length*3)==n+n+n;let s=o?n+n+n:n;return{changes:{from:a,to:a+s.length,insert:s},range:t.cursor(a+s.length)}}}else{if(i&&e.sliceDoc(a-2*n.length,a)==n+n&&(r=ct(e,a-2*n.length,s))>-1&&rt(e,r))return{changes:{insert:n+n+n+n,from:a},effects:ze.of(a+n.length),range:t.cursor(a+n.length)};if(e.charCategorizer(a)(c)!=m.Word&&ct(e,a,s)>-1&&!at(e,a,n,s))return{changes:{insert:n+n,from:a},effects:ze.of(a+n.length),range:t.cursor(a+n.length)}}return{range:l=o}}));return l?null:e.update(r,{scrollIntoView:true,userEvent:"input.type"})}function rt(e,t){let n=I(e).resolveInner(t+1);return n.parent&&n.from==t}function at(e,t,n,i){let o=I(e).resolveInner(t,-1);let s=i.reduce(((e,t)=>Math.max(e,t.length)),0);for(let l=0;l<5;l++){let l=e.sliceDoc(o.from,Math.min(o.to,o.from+n.length+s));let r=l.indexOf(n);if(!r||r>-1&&i.indexOf(l.slice(0,r))>-1){let t=o.firstChild;while(t&&t.from==o.from&&t.to-t.from>n.length+r){if(e.sliceDoc(t.to-n.length,t.to)==n)return false;t=t.firstChild}return true}let a=o.to==t&&o.parent;if(!a)break;o=a}return false}function ct(e,t,n){let i=e.charCategorizer(t);if(i(e.sliceDoc(t-1,t))!=m.Word)return t;for(let o of n){let n=t-o.length;if(e.sliceDoc(n,t)==o&&i(e.sliceDoc(n-1,n))!=m.Word)return n}return-1}function ft(e={}){return[me,oe,W.of(e),pe,ht,ge]}const ut=[{key:"Ctrl-Space",run:ce},{mac:"Alt-`",run:ce},{mac:"Alt-i",run:ce},{key:"Escape",run:fe},{key:"ArrowDown",run:re(true)},{key:"ArrowUp",run:re(false)},{key:"PageDown",run:re(true,"page")},{key:"PageUp",run:re(false,"page")},{key:"Enter",run:ae}];const ht=c.highest(A.computeN([W],(e=>e.facet(W).defaultKeymap?[ut]:[])));function pt(e){let t=e.field(oe,false);return t&&t.active.some((e=>e.isPending))?"pending":t&&t.active.some((e=>e.state!=0))?"active":null}const dt=new WeakMap;function mt(e){var t;let n=(t=e.field(oe,false))===null||t===void 0?void 0:t.open;if(!n||n.disabled)return[];let i=dt.get(n.options);i||dt.set(n.options,i=n.options.map((e=>e.completion)));return i}function gt(e){var t;let n=(t=e.field(oe,false))===null||t===void 0?void 0:t.open;return n&&!n.disabled&&n.selected>=0?n.options[n.selected].completion:null}function vt(e){var t;let n=(t=e.field(oe,false))===null||t===void 0?void 0:t.open;return n&&!n.disabled&&n.selected>=0?n.selected:null}function bt(e){return ie.of(e)}export{CompletionContext,ae as acceptCompletion,ft as autocompletion,Ie as clearSnippet,Ke as closeBrackets,Ze as closeBracketsKeymap,fe as closeCompletion,qe as completeAnyWord,R as completeFromList,ut as completionKeymap,pt as completionStatus,mt as currentCompletions,Je as deleteBracketPair,Oe as hasNextSnippetField,Re as hasPrevSnippetField,T as ifIn,E as ifNotIn,et as insertBracket,F as insertCompletionText,re as moveCompletionSelection,ke as nextSnippetField,P as pickedCompletion,De as prevSnippetField,gt as selectedCompletion,vt as selectedCompletionIndex,bt as setSelectedCompletion,Se as snippet,Me as snippetCompletion,Ee as snippetKeymap,ce as startCompletion};+diff --git a/admin/vendor/javascript/@codemirror--commands.js b/admin/vendor/javascript/@codemirror--commands.jsnew file mode 100644index 0000000000..5292993516--- /dev/null+++ b/admin/vendor/javascript/@codemirror--commands.js@@ -0,0 +1,4 @@+// @codemirror/[email protected] downloaded from https://ga.jspm.io/npm:@codemirror/[email protected]/dist/index.js++import{Annotation as e,Facet as t,combineConfig as n,StateField as r,Transaction as o,ChangeSet as s,ChangeDesc as l,EditorSelection as a,StateEffect as i,findClusterBreak as c,CharCategory as u,countColumn as f,Text as h}from"@codemirror/state";import{EditorView as m,Direction as d}from"@codemirror/view";import{syntaxTree as p,matchBrackets as g,getIndentUnit as y,IndentContext as v,getIndentation as A,indentString as k,indentUnit as w}from"@codemirror/language";import{NodeProp as S}from"@lezer/common";const D=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=T(e.state,n.from);return r.line?M(e):!!r.block&&H(e)};function x(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return false;let o=e(t,n);if(!o)return false;r(n.update(o));return true}}const M=x(J,0);const E=x(J,1);const B=x(J,2);const C=x(L,0);const b=x(L,1);const O=x(L,2);const H=x(((e,t)=>L(e,t,R(t))),0);function T(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}const I=50;function V(e,{open:t,close:n},r,o){let s=e.sliceDoc(r-I,r);let l=e.sliceDoc(o,o+I);let a=/\s*$/.exec(s)[0].length,i=/^\s*/.exec(l)[0].length;let c=s.length-a;if(s.slice(c-t.length,c)==t&&l.slice(i,i+n.length)==n)return{open:{pos:r-a,margin:a&&1},close:{pos:o+i,margin:i&&1}};let u,f;if(o-r<=2*I)u=f=e.sliceDoc(r,o);else{u=e.sliceDoc(r,r+I);f=e.sliceDoc(o-I,o)}let h=/^\s*/.exec(u)[0].length,m=/\s*$/.exec(f)[0].length;let d=f.length-m-n.length;return u.slice(h,h+t.length)==t&&f.slice(d,d+n.length)==n?{open:{pos:r+h+t.length,margin:/\s/.test(u.charAt(h+t.length))?1:0},close:{pos:o-m-n.length,margin:/\s/.test(f.charAt(d-1))?1:0}}:null}function R(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from);let o=n.to<=r.to?r:e.doc.lineAt(n.to);o.from>r.from&&o.from==n.to&&(o=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let s=t.length-1;s>=0&&t[s].to>r.from?t[s].to=o.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:o.to})}return t}function L(e,t,n=t.selection.ranges){let r=n.map((e=>T(t,e.from).block));if(!r.every((e=>e)))return null;let o=n.map(((e,n)=>V(t,r[n],e.from,e.to)));if(e!=2&&!o.every((e=>e)))return{changes:t.changes(n.map(((e,t)=>o[t]?[]:[{from:e.from,insert:r[t].open+" "},{from:e.to,insert:" "+r[t].close}])))};if(e!=1&&o.some((e=>e))){let e=[];for(let t,n=0;n<o.length;n++)if(t=o[n]){let o=r[n],{open:s,close:l}=t;e.push({from:s.pos-o.open.length,to:s.pos+s.margin},{from:l.pos-l.margin,to:l.pos+o.close.length})}return{changes:e}}return null}function J(e,t,n=t.selection.ranges){let r=[];let o=-1;for(let{from:e,to:s}of n){let n=r.length,l=1e9;let a=T(t,e).line;if(a){for(let n=e;n<=s;){let i=t.doc.lineAt(n);if(i.from>o&&(e==s||s>i.from)){o=i.from;let e=/^\s*/.exec(i.text)[0].length;let t=e==i.length;let n=i.text.slice(e,e+a.length)==a?e:-1;e<i.text.length&&e<l&&(l=e);r.push({line:i,comment:n,token:a,indent:e,empty:t,single:false})}n=i.to+1}if(l<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=l);r.length==n+1&&(r[n].single=true)}}if(e!=2&&r.some((e=>e.comment<0&&(!e.empty||e.single)))){let e=[];for(let{line:t,token:n,indent:o,empty:s,single:l}of r)!l&&s||e.push({from:t.from+o,insert:n+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some((e=>e.comment>=0))){let e=[];for(let{line:t,comment:n,token:o}of r)if(n>=0){let r=t.from+n,s=r+o.length;t.text[s-t.from]==" "&&s++;e.push({from:r,to:s})}return{changes:e}}return null}const N=e.define();const U=e.define();const z=t.define();const G=t.define({combine(e){return n(e,{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)})}});const P=r.define({create(){return HistoryState.empty},update(e,t){let n=t.state.facet(G);let r=t.annotation(N);if(r){let o=HistEvent.fromTransaction(t,r.selection),s=r.side;let l=s==0?e.undone:e.done;l=o?Z(l,l.length,n.minDepth,o):se(l,t.startState.selection);return new HistoryState(s==0?r.rest:l,s==0?l:r.rest)}let s=t.annotation(U);s!="full"&&s!="before"||(e=e.isolate());if(t.annotation(o.addToHistory)===false)return t.changes.empty?e:e.addMapping(t.changes.desc);let l=HistEvent.fromTransaction(t);let a=t.annotation(o.time),i=t.annotation(o.userEvent);l?e=e.addChanges(l,a,i,n,t):t.selection&&(e=e.addSelection(t.startState.selection,a,i,n.newGroupDelay));s!="full"&&s!="after"||(e=e.isolate());return e},toJSON(e){return{done:e.done.map((e=>e.toJSON())),undone:e.undone.map((e=>e.toJSON()))}},fromJSON(e){return new HistoryState(e.done.map(HistEvent.fromJSON),e.undone.map(HistEvent.fromJSON))}});function W(e={}){return[P,G.of(e),m.domEventHandlers({beforeinput(e,t){let n=e.inputType=="historyUndo"?j:e.inputType=="historyRedo"?F:null;if(!n)return false;e.preventDefault();return n(t)}})]}const q=P;function $(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return false;let o=n.field(P,false);if(!o)return false;let s=o.pop(e,n,t);if(!s)return false;r(s);return true}}const j=$(0,false);const F=$(1,false);const _=$(0,true);const K=$(1,true);function Q(e){return function(t){let n=t.field(P,false);if(!n)return 0;let r=e==0?n.done:n.undone;return r.length-(r.length&&!r[0].changes?1:0)}}const X=Q(0);const Y=Q(1);class HistEvent{constructor(e,t,n,r,o){this.changes=e;this.effects=t;this.mapped=n;this.startSelection=r;this.selectionsAfter=o}setSelAfter(e){return new HistEvent(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((e=>e.toJSON()))}}static fromJSON(e){return new HistEvent(e.changes&&s.fromJSON(e.changes),[],e.mapped&&l.fromJSON(e.mapped),e.startSelection&&a.fromJSON(e.startSelection),e.selectionsAfter.map(a.fromJSON))}static fromTransaction(e,t){let n=re;for(let t of e.startState.facet(z)){let r=t(e);r.length&&(n=n.concat(r))}return!n.length&&e.changes.empty?null:new HistEvent(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,re)}static selection(e){return new HistEvent(void 0,re,void 0,void 0,e)}}function Z(e,t,n,r){let o=t+1>n+20?t-n-1:0;let s=e.slice(o,t);s.push(r);return s}function ee(e,t){let n=[],r=false;e.iterChangedRanges(((e,t)=>n.push(e,t)));t.iterChangedRanges(((e,t,o,s)=>{for(let e=0;e<n.length;){let t=n[e++],l=n[e++];s>=t&&o<=l&&(r=true)}}));return r}function te(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter(((e,n)=>e.empty!=t.ranges[n].empty)).length===0}function ne(e,t){return e.length?t.length?e.concat(t):e:t}const re=[];const oe=200;function se(e,t){if(e.length){let n=e[e.length-1];let r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-oe));if(r.length&&r[r.length-1].eq(t))return e;r.push(t);return Z(e,e.length-1,1e9,n.setSelAfter(r))}return[HistEvent.selection([t])]}function le(e){let t=e[e.length-1];let n=e.slice();n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1));return n}function ae(e,t){if(!e.length)return e;let n=e.length,r=re;while(n){let o=ie(e[n-1],t,r);if(o.changes&&!o.changes.empty||o.effects.length){let t=e.slice(0,n);t[n-1]=o;return t}t=o.mapped;n--;r=o.selectionsAfter}return r.length?[HistEvent.selection(r)]:re}function ie(e,t,n){let r=ne(e.selectionsAfter.length?e.selectionsAfter.map((e=>e.map(t))):re,n);if(!e.changes)return HistEvent.selection(r);let o=e.changes.map(t),s=t.mapDesc(e.changes,true);let l=e.mapped?e.mapped.composeDesc(s):s;return new HistEvent(o,i.mapEffects(e.effects,t),l,e.startSelection.map(s),r)}const ce=/^(input\.type|delete)($|\.)/;class HistoryState{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 HistoryState(this.done,this.undone):this}addChanges(e,t,n,r,o){let s=this.done,l=s[s.length-1];s=l&&l.changes&&!l.changes.empty&&e.changes&&(!n||ce.test(n))&&(!l.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(o,ee(l.changes,e.changes))||n=="input.type.compose")?Z(s,s.length-1,r.minDepth,new HistEvent(e.changes.compose(l.changes),ne(i.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,re)):Z(s,s.length,r.minDepth,e);return new HistoryState(s,re,t,n)}addSelection(e,t,n,r){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:re;return o.length>0&&t-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&te(o[o.length-1],e)?this:new HistoryState(se(this.done,e),this.undone,t,n)}addMapping(e){return new HistoryState(ae(this.done,e),ae(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let o=r[r.length-1],s=o.selectionsAfter[0]||t.selection;if(n&&o.selectionsAfter.length)return t.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:N.of({side:e,rest:le(r),selection:s}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:true});if(o.changes){let n=r.length==1?re:r.slice(0,r.length-1);o.mapped&&(n=ae(n,o.mapped));return t.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:N.of({side:e,rest:n,selection:s}),filter:false,userEvent:e==0?"undo":"redo",scrollIntoView:true})}return null}}HistoryState.empty=new HistoryState(re,re);const ue=[{key:"Mod-z",run:j,preventDefault:true},{key:"Mod-y",mac:"Mod-Shift-z",run:F,preventDefault:true},{linux:"Ctrl-Shift-z",run:F,preventDefault:true},{key:"Mod-u",run:_,preventDefault:true},{key:"Alt-u",mac:"Mod-Shift-u",run:K,preventDefault:true}];function fe(e,t){return a.create(e.ranges.map(t),e.mainIndex)}function he(e,t){return e.update({selection:t,scrollIntoView:true,userEvent:"select"})}function me({state:e,dispatch:t},n){let r=fe(e.selection,n);if(r.eq(e.selection,true))return false;t(he(e,r));return true}function de(e,t){return a.cursor(t?e.to:e.from)}function pe(e,t){return me(e,(n=>n.empty?e.moveByChar(n,t):de(n,t)))}function ge(e){return e.textDirectionAt(e.state.selection.main.head)==d.LTR}const ye=e=>pe(e,!ge(e));const ve=e=>pe(e,ge(e));const Ae=e=>pe(e,true);const ke=e=>pe(e,false);function we(e,t,n){let r=t.head,o=e.doc.lineAt(r);r=r==(n?o.to:o.from)?n?Math.min(e.doc.length,o.to+1):Math.max(0,o.from-1):o.from+c(o.text,r-o.from,n);return a.cursor(r,n?-1:1)}function Se(e,t){return me(e,(n=>n.empty?we(e.state,n,t):de(n,t)))}const De=e=>Se(e,true);const xe=e=>Se(e,false);function Me(e,t){return me(e,(n=>n.empty?e.moveByGroup(n,t):de(n,t)))}const Ee=e=>Me(e,!ge(e));const Be=e=>Me(e,ge(e));const Ce=e=>Me(e,true);const be=e=>Me(e,false);function Oe(e,t,n){let r=e.state.charCategorizer(t);let o=r(n),s=o!=u.Space;return e=>{let t=r(e);if(t!=u.Space)return s&&t==o;s=false;return true}}const He=e=>me(e,(t=>t.empty?e.moveByChar(t,true,(n=>Oe(e,t.head,n))):de(t,true)));const Te=typeof Intl!="undefined"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function Ie(e,t,n){let r=e.state.charCategorizer(t.from);let o=u.Space,s=t.from,l=0;let i=false,c=false,f=false;let h=t=>{if(i)return false;s+=n?t.length:-t.length;let a,h=r(t);h==u.Word&&t.charCodeAt(0)<128&&/[\W_]/.test(t)&&(h=-1);o==u.Space&&(o=h);if(o!=h)return false;if(o==u.Word)if(t.toLowerCase()==t){if(!n&&c)return false;f=true}else if(f){if(n)return false;i=true}else{if(c&&n&&r(a=e.state.sliceDoc(s,s+1))==u.Word&&a.toLowerCase()==a)return false;c=true}l++;return true};let m=e.moveByChar(t,n,(e=>{h(e);return h}));if(Te&&o==u.Word&&m.from==t.from+l*(n?1:-1)){let r=Math.min(t.head,m.head),o=Math.max(t.head,m.head);let s=e.state.sliceDoc(r,o);if(s.length>1&&/[\u4E00-\uffff]/.test(s)){let e=Array.from(Te.segment(s));if(e.length>1)return n?a.cursor(t.head+e[1].index,-1):a.cursor(m.head+e[e.length-1].index,1)}}return m}function Ve(e,t){return me(e,(n=>n.empty?Ie(e,n,t):de(n,t)))}const Re=e=>Ve(e,true);const Le=e=>Ve(e,false);function Je(e,t,n){if(t.type.prop(n))return true;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Ne(e,t,n){let r=p(e).resolveInner(t.head);let o=n?S.closedBy:S.openedBy;for(let s=t.head;;){let t=n?r.childAfter(s):r.childBefore(s);if(!t)break;Je(e,t,o)?r=t:s=n?t.to:t.from}let s,l,i=r.type.prop(o);l=i&&(s=n?g(e,r.from,1):g(e,r.to,-1))&&s.matched?n?s.end.to:s.end.from:n?r.to:r.from;return a.cursor(l,n?-1:1)}const Ue=e=>me(e,(t=>Ne(e.state,t,!ge(e))));const ze=e=>me(e,(t=>Ne(e.state,t,ge(e))));function Ge(e,t){return me(e,(n=>{if(!n.empty)return de(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)}))}const Pe=e=>Ge(e,false);const We=e=>Ge(e,true);function qe(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2;let n,r=0,o=0;if(t){for(let t of e.state.facet(m.scrollMargins)){let n=t(e);(n===null||n===void 0?void 0:n.top)&&(r=Math.max(n===null||n===void 0?void 0:n.top,r));(n===null||n===void 0?void 0:n.bottom)&&(o=Math.max(n===null||n===void 0?void 0:n.bottom,o))}n=e.scrollDOM.clientHeight-r-o}else n=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:o,selfScroll:t,height:Math.max(e.defaultLineHeight,n-5)}}function $e(e,t){let n=qe(e);let{state:r}=e,o=fe(r.selection,(r=>r.empty?e.moveVertically(r,t,n.height):de(r,t)));if(o.eq(r.selection))return false;let s;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head);let l=e.scrollDOM.getBoundingClientRect();let a=l.top+n.marginTop,i=l.bottom-n.marginBottom;t&&t.top>a&&t.bottom<i&&(s=m.scrollIntoView(o.main.head,{y:"start",yMargin:t.top-a}))}e.dispatch(he(r,o),{effects:s});return true}const je=e=>$e(e,false);const Fe=e=>$e(e,true);function _e(e,t,n){let r=e.lineBlockAt(t.head),o=e.moveToLineBoundary(t,n);o.head==t.head&&o.head!=(n?r.to:r.from)&&(o=e.moveToLineBoundary(t,n,false));if(!n&&o.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(o=a.cursor(r.from+n))}return o}const Ke=e=>me(e,(t=>_e(e,t,true)));const Qe=e=>me(e,(t=>_e(e,t,false)));const Xe=e=>me(e,(t=>_e(e,t,!ge(e))));const Ye=e=>me(e,(t=>_e(e,t,ge(e))));const Ze=e=>me(e,(t=>a.cursor(e.lineBlockAt(t.head).from,1)));const et=e=>me(e,(t=>a.cursor(e.lineBlockAt(t.head).to,-1)));function tt(e,t,n){let r=false,o=fe(e.selection,(t=>{let o=g(e,t.head,-1)||g(e,t.head,1)||t.head>0&&g(e,t.head-1,1)||t.head<e.doc.length&&g(e,t.head+1,-1);if(!o||!o.end)return t;r=true;let s=o.start.from==t.head?o.end.to:o.end.from;return n?a.range(t.anchor,s):a.cursor(s)}));if(!r)return false;t(he(e,o));return true}const nt=({state:e,dispatch:t})=>tt(e,t,false);const rt=({state:e,dispatch:t})=>tt(e,t,true);function ot(e,t){let n=fe(e.state.selection,(e=>{let n=t(e);return a.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)}));if(n.eq(e.state.selection))return false;e.dispatch(he(e.state,n));return true}function st(e,t){return ot(e,(n=>e.moveByChar(n,t)))}const lt=e=>st(e,!ge(e));const at=e=>st(e,ge(e));const it=e=>st(e,true);const ct=e=>st(e,false);const ut=e=>ot(e,(t=>we(e.state,t,true)));const ft=e=>ot(e,(t=>we(e.state,t,false)));function ht(e,t){return ot(e,(n=>e.moveByGroup(n,t)))}const mt=e=>ht(e,!ge(e));const dt=e=>ht(e,ge(e));const pt=e=>ht(e,true);const gt=e=>ht(e,false);const yt=e=>ot(e,(t=>e.moveByChar(t,true,(n=>Oe(e,t.head,n)))));function vt(e,t){return ot(e,(n=>Ie(e,n,t)))}const At=e=>vt(e,true);const kt=e=>vt(e,false);const wt=e=>ot(e,(t=>Ne(e.state,t,!ge(e))));const St=e=>ot(e,(t=>Ne(e.state,t,ge(e))));function Dt(e,t){return ot(e,(n=>e.moveVertically(n,t)))}const xt=e=>Dt(e,false);const Mt=e=>Dt(e,true);function Et(e,t){return ot(e,(n=>e.moveVertically(n,t,qe(e).height)))}const Bt=e=>Et(e,false);const Ct=e=>Et(e,true);const bt=e=>ot(e,(t=>_e(e,t,true)));const Ot=e=>ot(e,(t=>_e(e,t,false)));const Ht=e=>ot(e,(t=>_e(e,t,!ge(e))));const Tt=e=>ot(e,(t=>_e(e,t,ge(e))));const It=e=>ot(e,(t=>a.cursor(e.lineBlockAt(t.head).from)));const Vt=e=>ot(e,(t=>a.cursor(e.lineBlockAt(t.head).to)));const Rt=({state:e,dispatch:t})=>{t(he(e,{anchor:0}));return true};const Lt=({state:e,dispatch:t})=>{t(he(e,{anchor:e.doc.length}));return true};const Jt=({state:e,dispatch:t})=>{t(he(e,{anchor:e.selection.main.anchor,head:0}));return true};const Nt=({state:e,dispatch:t})=>{t(he(e,{anchor:e.selection.main.anchor,head:e.doc.length}));return true};const Ut=({state:e,dispatch:t})=>{t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"}));return true};const zt=({state:e,dispatch:t})=>{let n=cn(e).map((({from:t,to:n})=>a.range(t,Math.min(n+1,e.doc.length))));t(e.update({selection:a.create(n),userEvent:"select"}));return true};const Gt=({state:e,dispatch:t})=>{let n=fe(e.selection,(t=>{let n=p(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return a.range(n.to,n.from)}return t}));if(n.eq(e.selection))return false;t(he(e,n));return true};function Pt(e,t){let{state:n}=e,r=n.selection,o=n.selection.ranges.slice();for(let r of n.selection.ranges){let s=n.doc.lineAt(r.head);if(t?s.to<e.state.doc.length:s.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<s.from||r.head>s.to){o.some((e=>e.head==r.head))||o.push(r);break}if(r.head==n.head)break;n=r}}if(o.length==r.ranges.length)return false;e.dispatch(he(n,a.create(o,o.length-1)));return true}const Wt=e=>Pt(e,false);const qt=e=>Pt(e,true);const $t=({state:e,dispatch:t})=>{let n=e.selection,r=null;n.ranges.length>1?r=a.create([n.main]):n.main.empty||(r=a.create([a.cursor(n.main.head)]));if(!r)return false;t(he(e,r));return true};function jt(e,t){if(e.state.readOnly)return false;let n="delete.selection",{state:r}=e;let o=r.changeByRange((r=>{let{from:o,to:s}=r;if(o==s){let l=t(r);if(l<o){n="delete.backward";l=Ft(e,l,false)}else if(l>o){n="delete.forward";l=Ft(e,l,true)}o=Math.min(o,l);s=Math.max(s,l)}else{o=Ft(e,o,false);s=Ft(e,s,true)}return o==s?{range:r}:{changes:{from:o,to:s},range:a.cursor(o,o<r.head?-1:1)}}));if(o.changes.empty)return false;e.dispatch(r.update(o,{scrollIntoView:true,userEvent:n,effects:n=="delete.selection"?m.announce.of(r.phrase("Selection deleted")):void 0}));return true}function Ft(e,t,n){if(e instanceof m)for(let r of e.state.facet(m.atomicRanges).map((t=>t(e))))r.between(t,t,((e,r)=>{e<t&&r>t&&(t=n?r:e)}));return t}const _t=(e,t,n)=>jt(e,(r=>{let o,s,l=r.from,{state:a}=e,i=a.doc.lineAt(l);if(n&&!t&&l>i.from&&l<i.from+200&&!/[^ \t]/.test(o=i.text.slice(0,l-i.from))){if(o[o.length-1]=="\t")return l-1;let e=f(o,a.tabSize),t=e%y(a)||y(a);for(let e=0;e<t&&o[o.length-1-e]==" ";e++)l--;s=l}else{s=c(i.text,l-i.from,t,t)+i.from;s==l&&i.number!=(t?a.doc.lines:1)?s+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(i.text.slice(s-i.from,l-i.from))&&(s=c(i.text,s-i.from,false,false)+i.from)}return s}));const Kt=e=>_t(e,false,true);const Qt=e=>_t(e,false,false);const Xt=e=>_t(e,true,false);const Yt=(e,t)=>jt(e,(n=>{let r=n.head,{state:o}=e,s=o.doc.lineAt(r);let l=o.charCategorizer(r);for(let e=null;;){if(r==(t?s.to:s.from)){r==n.head&&s.number!=(t?o.doc.lines:1)&&(r+=t?1:-1);break}let a=c(s.text,r-s.from,t)+s.from;let i=s.text.slice(Math.min(r,a)-s.from,Math.max(r,a)-s.from);let u=l(i);if(e!=null&&u!=e)break;i==" "&&r==n.head||(e=u);r=a}return r}));const Zt=e=>Yt(e,false);const en=e=>Yt(e,true);const tn=e=>jt(e,(t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}));const nn=e=>jt(e,(t=>{let n=e.lineBlockAt(t.head).from;return t.head>n?n:Math.max(0,t.head-1)}));const rn=e=>jt(e,(t=>{let n=e.moveToLineBoundary(t,false).head;return t.head>n?n:Math.max(0,t.head-1)}));const on=e=>jt(e,(t=>{let n=e.moveToLineBoundary(t,true).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}));const sn=({state:e,dispatch:t})=>{if(e.readOnly)return false;let n=[];for(let t=0,r="",o=e.doc.iter();;){o.next();if(o.lineBreak||o.done){let e=r.search(/\s+$/);e>-1&&n.push({from:t-(r.length-e),to:t});if(o.done)break;r=""}else r=o.value;t+=o.value.length}if(!n.length)return false;t(e.update({changes:n,userEvent:"delete"}));return true};const ln=({state:e,dispatch:t})=>{if(e.readOnly)return false;let n=e.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:h.of(["",""])},range:a.cursor(e.from)})));t(e.update(n,{scrollIntoView:true,userEvent:"input"}));return true};const an=({state:e,dispatch:t})=>{if(e.readOnly)return false;let n=e.changeByRange((t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n);let o=n==r.from?n-1:c(r.text,n-r.from,false)+r.from;let s=n==r.to?n+1:c(r.text,n-r.from,true)+r.from;return{changes:{from:o,to:s,insert:e.doc.slice(n,s).append(e.doc.slice(o,n))},range:a.cursor(s)}}));if(n.changes.empty)return false;t(e.update(n,{scrollIntoView:true,userEvent:"move.character"}));return true};function cn(e){let t=[],n=-1;for(let r of e.selection.ranges){let o=e.doc.lineAt(r.from),s=e.doc.lineAt(r.to);r.empty||r.to!=s.from||(s=e.doc.lineAt(r.to-1));if(n>=o.number){let e=t[t.length-1];e.to=s.to;e.ranges.push(r)}else t.push({from:o.from,to:s.to,ranges:[r]});n=s.number+1}return t}function un(e,t,n){if(e.readOnly)return false;let r=[],o=[];for(let t of cn(e)){if(n?t.to==e.doc.length:t.from==0)continue;let s=e.doc.lineAt(n?t.to+1:t.from-1);let l=s.length+1;if(n){r.push({from:t.to,to:s.to},{from:t.from,insert:s.text+e.lineBreak});for(let n of t.ranges)o.push(a.range(Math.min(e.doc.length,n.anchor+l),Math.min(e.doc.length,n.head+l)))}else{r.push({from:s.from,to:t.from},{from:t.to,insert:e.lineBreak+s.text});for(let e of t.ranges)o.push(a.range(e.anchor-l,e.head-l))}}if(!r.length)return false;t(e.update({changes:r,scrollIntoView:true,selection:a.create(o,e.selection.mainIndex),userEvent:"move.line"}));return true}const fn=({state:e,dispatch:t})=>un(e,t,false);const hn=({state:e,dispatch:t})=>un(e,t,true);function mn(e,t,n){if(e.readOnly)return false;let r=[];for(let t of cn(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});t(e.update({changes:r,scrollIntoView:true,userEvent:"input.copyline"}));return true}const dn=({state:e,dispatch:t})=>mn(e,t,false);const pn=({state:e,dispatch:t})=>mn(e,t,true);const gn=e=>{if(e.state.readOnly)return false;let{state:t}=e,n=t.changes(cn(t).map((({from:e,to:n})=>{e>0?e--:n<t.doc.length&&n++;return{from:e,to:n}})));let r=fe(t.selection,(t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),o=e.coordsAtPos(t.head,t.assoc||1);o&&(n=r.bottom+e.documentTop-o.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,true,n)})).map(n);e.dispatch({changes:n,selection:r,scrollIntoView:true,userEvent:"delete.line"});return true};const yn=({state:e,dispatch:t})=>{t(e.update(e.replaceSelection(e.lineBreak),{scrollIntoView:true,userEvent:"input"}));return true};const vn=({state:e,dispatch:t})=>{t(e.update(e.changeByRange((t=>{let n=/^\s*/.exec(e.doc.lineAt(t.from).text)[0];return{changes:{from:t.from,to:t.to,insert:e.lineBreak+n},range:a.cursor(t.from+n.length+1)}})),{scrollIntoView:true,userEvent:"input"}));return true};function An(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=p(e).resolveInner(t);let r,o=n.childBefore(t),s=n.childAfter(t);return o&&s&&o.to<=t&&s.from>=t&&(r=o.type.prop(S.closedBy))&&r.indexOf(s.name)>-1&&e.doc.lineAt(o.to).from==e.doc.lineAt(s.from).from&&!/\S/.test(e.sliceDoc(o.to,s.from))?{from:o.to,to:s.from}:null}const kn=Sn(false);const wn=Sn(true);function Sn(e){return({state:t,dispatch:n})=>{if(t.readOnly)return false;let r=t.changeByRange((n=>{let{from:r,to:o}=n,s=t.doc.lineAt(r);let l=!e&&r==o&&An(t,r);e&&(r=o=(o<=s.to?s:t.doc.lineAt(o)).to);let i=new v(t,{simulateBreak:r,simulateDoubleBreak:!!l});let c=A(i,r);c==null&&(c=f(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize));while(o<s.to&&/\s/.test(s.text[o-s.from]))o++;l?({from:r,to:o}=l):r>s.from&&r<s.from+100&&!/\S/.test(s.text.slice(0,r))&&(r=s.from);let u=["",k(t,c)];l&&u.push(k(t,i.lineIndent(s.from,-1)));return{changes:{from:r,to:o,insert:h.of(u)},range:a.cursor(r+1+u[1].length)}}));n(t.update(r,{scrollIntoView:true,userEvent:"input"}));return true}}function Dn(e,t){let n=-1;return e.changeByRange((r=>{let o=[];for(let s=r.from;s<=r.to;){let l=e.doc.lineAt(s);if(l.number>n&&(r.empty||r.to>l.from)){t(l,o,r);n=l.number}s=l.to+1}let s=e.changes(o);return{changes:o,range:a.range(s.mapPos(r.anchor,1),s.mapPos(r.head,1))}}))}const xn=({state:e,dispatch:t})=>{if(e.readOnly)return false;let n=Object.create(null);let r=new v(e,{overrideIndentation:e=>{let t=n[e];return t==null?-1:t}});let o=Dn(e,((t,o,s)=>{let l=A(r,t.from);if(l==null)return;/\S/.test(t.text)||(l=0);let a=/^\s*/.exec(t.text)[0];let i=k(e,l);if(a!=i||s.from<t.from+a.length){n[t.from]=l;o.push({from:t.from,to:t.from+a.length,insert:i})}}));o.changes.empty||t(e.update(o,{userEvent:"indent"}));return true};const Mn=({state:e,dispatch:t})=>{if(e.readOnly)return false;t(e.update(Dn(e,((t,n)=>{n.push({from:t.from,insert:e.facet(w)})})),{userEvent:"input.indent"}));return true};const En=({state:e,dispatch:t})=>{if(e.readOnly)return false;t(e.update(Dn(e,((t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let o=f(r,e.tabSize),s=0;let l=k(e,Math.max(0,o-y(e)));while(s<r.length&&s<l.length&&r.charCodeAt(s)==l.charCodeAt(s))s++;n.push({from:t.from+s,to:t.from+r.length,insert:l.slice(s)})})),{userEvent:"delete.dedent"}));return true};const Bn=e=>{e.setTabFocusMode();return true};const Cn=e=>{e.setTabFocusMode(2e3);return true};const bn=({state:e,dispatch:t})=>{if(e.selection.ranges.some((e=>!e.empty)))return Mn({state:e,dispatch:t});t(e.update(e.replaceSelection("\t"),{scrollIntoView:true,userEvent:"input"}));return true};const On=[{key:"Ctrl-b",run:ye,shift:lt,preventDefault:true},{key:"Ctrl-f",run:ve,shift:at},{key:"Ctrl-p",run:Pe,shift:xt},{key:"Ctrl-n",run:We,shift:Mt},{key:"Ctrl-a",run:Ze,shift:It},{key:"Ctrl-e",run:et,shift:Vt},{key:"Ctrl-d",run:Xt},{key:"Ctrl-h",run:Kt},{key:"Ctrl-k",run:tn},{key:"Ctrl-Alt-h",run:Zt},{key:"Ctrl-o",run:ln},{key:"Ctrl-t",run:an},{key:"Ctrl-v",run:Fe}];const Hn=[{key:"ArrowLeft",run:ye,shift:lt,preventDefault:true},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Ee,shift:mt,preventDefault:true},{mac:"Cmd-ArrowLeft",run:Xe,shift:Ht,preventDefault:true},{key:"ArrowRight",run:ve,shift:at,preventDefault:true},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Be,shift:dt,preventDefault:true},{mac:"Cmd-ArrowRight",run:Ye,shift:Tt,preventDefault:true},{key:"ArrowUp",run:Pe,shift:xt,preventDefault:true},{mac:"Cmd-ArrowUp",run:Rt,shift:Jt},{mac:"Ctrl-ArrowUp",run:je,shift:Bt},{key:"ArrowDown",run:We,shift:Mt,preventDefault:true},{mac:"Cmd-ArrowDown",run:Lt,shift:Nt},{mac:"Ctrl-ArrowDown",run:Fe,shift:Ct},{key:"PageUp",run:je,shift:Bt},{key:"PageDown",run:Fe,shift:Ct},{key:"Home",run:Qe,shift:Ot,preventDefault:true},{key:"Mod-Home",run:Rt,shift:Jt},{key:"End",run:Ke,shift:bt,preventDefault:true},{key:"Mod-End",run:Lt,shift:Nt},{key:"Enter",run:kn,shift:kn},{key:"Mod-a",run:Ut},{key:"Backspace",run:Kt,shift:Kt,preventDefault:true},{key:"Delete",run:Xt,preventDefault:true},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Zt,preventDefault:true},{key:"Mod-Delete",mac:"Alt-Delete",run:en,preventDefault:true},{mac:"Mod-Backspace",run:rn,preventDefault:true},{mac:"Mod-Delete",run:on,preventDefault:true}].concat(On.map((e=>({mac:e.key,run:e.run,shift:e.shift}))));const Tn=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Ue,shift:wt},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:ze,shift:St},{key:"Alt-ArrowUp",run:fn},{key:"Shift-Alt-ArrowUp",run:dn},{key:"Alt-ArrowDown",run:hn},{key:"Shift-Alt-ArrowDown",run:pn},{key:"Mod-Alt-ArrowUp",run:Wt},{key:"Mod-Alt-ArrowDown",run:qt},{key:"Escape",run:$t},{key:"Mod-Enter",run:wn},{key:"Alt-l",mac:"Ctrl-l",run:zt},{key:"Mod-i",run:Gt,preventDefault:true},{key:"Mod-[",run:En},{key:"Mod-]",run:Mn},{key:"Mod-Alt-\\",run:xn},{key:"Shift-Mod-k",run:gn},{key:"Shift-Mod-\\",run:nt},{key:"Mod-/",run:D},{key:"Alt-A",run:C},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Bn}].concat(Hn);const In={key:"Tab",run:Mn,shift:En};export{Wt as addCursorAbove,qt as addCursorBelow,b as blockComment,O as blockUncomment,pn as copyLineDown,dn as copyLineUp,ke as cursorCharBackward,xe as cursorCharBackwardLogical,Ae as cursorCharForward,De as cursorCharForwardLogical,ye as cursorCharLeft,ve as cursorCharRight,Lt as cursorDocEnd,Rt as cursorDocStart,be as cursorGroupBackward,Ce as cursorGroupForward,He as cursorGroupForwardWin,Ee as cursorGroupLeft,Be as cursorGroupRight,Qe as cursorLineBoundaryBackward,Ke as cursorLineBoundaryForward,Xe as cursorLineBoundaryLeft,Ye as cursorLineBoundaryRight,We as cursorLineDown,et as cursorLineEnd,Ze as cursorLineStart,Pe as cursorLineUp,nt as cursorMatchingBracket,Fe as cursorPageDown,je as cursorPageUp,Le as cursorSubwordBackward,Re as cursorSubwordForward,Ue as cursorSyntaxLeft,ze as cursorSyntaxRight,Tn as defaultKeymap,Kt as deleteCharBackward,Qt as deleteCharBackwardStrict,Xt as deleteCharForward,Zt as deleteGroupBackward,en as deleteGroupForward,gn as deleteLine,rn as deleteLineBoundaryBackward,on as deleteLineBoundaryForward,tn as deleteToLineEnd,nn as deleteToLineStart,sn as deleteTrailingWhitespace,On as emacsStyleKeymap,W as history,q as historyField,ue as historyKeymap,En as indentLess,Mn as indentMore,xn as indentSelection,In as indentWithTab,wn as insertBlankLine,yn as insertNewline,kn as insertNewlineAndIndent,vn as insertNewlineKeepIndent,bn as insertTab,z as invertedEffects,U as isolateHistory,E as lineComment,B as lineUncomment,hn as moveLineDown,fn as moveLineUp,F as redo,Y as redoDepth,K as redoSelection,Ut as selectAll,ct as selectCharBackward,ft as selectCharBackwardLogical,it as selectCharForward,ut as selectCharForwardLogical,lt as selectCharLeft,at as selectCharRight,Nt as selectDocEnd,Jt as selectDocStart,gt as selectGroupBackward,pt as selectGroupForward,yt as selectGroupForwardWin,mt as selectGroupLeft,dt as selectGroupRight,zt as selectLine,Ot as selectLineBoundaryBackward,bt as selectLineBoundaryForward,Ht as selectLineBoundaryLeft,Tt as selectLineBoundaryRight,Mt as selectLineDown,Vt as selectLineEnd,It as selectLineStart,xt as selectLineUp,rt as selectMatchingBracket,Ct as selectPageDown,Bt as selectPageUp,Gt as selectParentSyntax,kt as selectSubwordBackward,At as selectSubwordForward,wt as selectSyntaxLeft,St as selectSyntaxRight,$t as simplifySelection,ln as splitLine,Hn as standardKeymap,Cn as temporarilySetTabFocusMode,C as toggleBlockComment,H as toggleBlockCommentByLine,D as toggleComment,M as toggleLineComment,Bn as toggleTabFocusMode,an as transposeChars,j as undo,X as undoDepth,_ as undoSelection};+diff --git a/admin/vendor/javascript/@codemirror--lang-json.js b/admin/vendor/javascript/@codemirror--lang-json.jsnew file mode 100644index 0000000000..7af9a3ced1--- /dev/null+++ b/admin/vendor/javascript/@codemirror--lang-json.js@@ -0,0 +1,4 @@+// @codemirror/[email protected] downloaded from https://ga.jspm.io/npm:@codemirror/[email protected]/dist/index.js++import{parser as e}from"@lezer/json";import{LRLanguage as t,indentNodeProp as r,foldNodeProp as n,continuedIndent as a,foldInside as o,LanguageSupport as s}from"@codemirror/language";const c=()=>e=>{try{JSON.parse(e.state.doc.toString())}catch(t){if(!(t instanceof SyntaxError))throw t;const r=i(t,e.state.doc);return[{from:r,message:t.message,severity:"error",to:r}]}return[]};function i(e,t){let r;return(r=e.message.match(/at position (\d+)/))?Math.min(+r[1],t.length):(r=e.message.match(/at line (\d+) column (\d+)/))?Math.min(t.line(+r[1]).from+ +r[2]-1,t.length):0}const m=t.define({name:"json",parser:e.configure({props:[r.add({Object:a({except:/^\s*\}/}),Array:a({except:/^\s*\]/})}),n.add({"Object Array":o})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function d(){return new s(m)}export{d as json,m as jsonLanguage,c as jsonParseLinter};+diff --git a/admin/vendor/javascript/@codemirror--language.js b/admin/vendor/javascript/@codemirror--language.jsnew file mode 100644index 0000000000..b4d68d0240--- /dev/null+++ b/admin/vendor/javascript/@codemirror--language.js@@ -0,0 +1,4 @@+// @codemirror/[email protected] downloaded from https://ga.jspm.io/npm:@codemirror/[email protected]/dist/index.js++import{NodeProp as t,Tree as e,IterMode as n,TreeFragment as r,Parser as s,NodeType as i,NodeSet as o}from"@lezer/common";import{Facet as a,EditorState as l,StateEffect as h,StateField as u,countColumn as f,RangeSet as c,combineConfig as d,RangeSetBuilder as p,Prec as g}from"@codemirror/state";import{ViewPlugin as m,logException as k,EditorView as v,Decoration as w,WidgetType as x,GutterMarker as b,gutter as y,Direction as S}from"@codemirror/view";import{tagHighlighter as C,highlightTree as P,tags as T,styleTags as A}from"@lezer/highlight";import{StyleModule as L}from"style-mod";var I;const D=new t;function O(t){return a.define({combine:t?e=>e.concat(t):void 0})}const B=new t;class Language{constructor(t,e,n=[],r=""){this.data=t;this.name=r;l.prototype.hasOwnProperty("tree")||Object.defineProperty(l.prototype,"tree",{get(){return N(this)}});this.parser=e;this.extension=[$.of(this),l.languageData.of(((t,e,n)=>{let r=M(t,e,n),s=r.type.prop(D);if(!s)return[];let i=t.facet(s),o=r.type.prop(B);if(o){let s=r.resolve(e-r.from,n);for(let e of o)if(e.test(s,t)){let n=t.facet(e.facet);return e.type=="replace"?n:n.concat(i)}}return i}))].concat(n)}isActiveAt(t,e,n=-1){return M(t,e,n).type.prop(D)==this.data}findRegions(n){let r=n.facet($);if((r===null||r===void 0?void 0:r.data)==this.data)return[{from:0,to:n.doc.length}];if(!r||!r.allowsNesting)return[];let s=[];let i=(n,r)=>{if(n.prop(D)==this.data){s.push({from:r,to:r+n.length});return}let o=n.prop(t.mounted);if(o){if(o.tree.prop(D)==this.data){if(o.overlay)for(let t of o.overlay)s.push({from:t.from+r,to:t.to+r});else s.push({from:r,to:r+n.length});return}if(o.overlay){let t=s.length;i(o.tree,o.overlay[0].from+r);if(s.length>t)return}}for(let t=0;t<n.children.length;t++){let s=n.children[t];s instanceof e&&i(s,n.positions[t]+r)}};i(N(n),0);return s}get allowsNesting(){return true}}Language.setState=h.define();function M(t,e,r){let s=t.facet($),i=N(t).topNode;if(!s||s.allowsNesting)for(let t=i;t;t=t.enter(e,r,n.ExcludeBuffers))t.type.isTop&&(i=t);return i}class LRLanguage extends Language{constructor(t,e,n){super(t,e,[],n);this.parser=e}static define(t){let e=O(t.languageData);return new LRLanguage(e,t.parser.configure({props:[D.add((t=>t.isTop?e:void 0))]}),t.name)}configure(t,e){return new LRLanguage(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function N(t){let n=t.field(Language.state,false);return n?n.tree:e.empty}function R(t,e,n=50){var r;let s=(r=t.field(Language.state,false))===null||r===void 0?void 0:r.context;if(!s)return null;let i=s.viewport;s.updateViewport({from:0,to:e});let o=s.isDone(e)||s.work(n,e)?s.tree:null;s.updateViewport(i);return o}function E(t,e=t.doc.length){var n;return((n=t.field(Language.state,false))===null||n===void 0?void 0:n.context.isDone(e))||false}function F(t,e=t.viewport.to,n=100){let r=R(t.state,e,n);r!=N(t.state)&&t.dispatch({});return!!r}function W(t){var e;return((e=t.plugin(V))===null||e===void 0?void 0:e.isWorking())||false}class DocInput{constructor(t){this.doc=t;this.cursorPos=0;this.string="";this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){this.string=this.cursor.next(t-this.cursorPos).value;this.cursorPos=t+this.string.length;return this.cursorPos-this.string.length}chunk(t){this.syncTo(t);return this.string}get lineChunks(){return true}read(t,e){let n=this.cursorPos-this.string.length;return t<n||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-n,e-n)}}let U=null;class ParseContext{constructor(t,e,n=[],r,s,i,o,a){this.parser=t;this.state=e;this.fragments=n;this.tree=r;this.treeLen=s;this.viewport=i;this.skipped=o;this.scheduleOn=a;this.parse=null;this.tempSkipped=[]}static create(t,n,r){return new ParseContext(t,n,[],e.empty,0,r,[],null)}startParse(){return this.parser.startParse(new DocInput(this.state.doc),this.fragments)}work(t,n){n!=null&&n>=this.state.doc.length&&(n=void 0);if(this.tree!=e.empty&&this.isDone(n!==null&&n!==void 0?n:this.state.doc.length)){this.takeTree();return true}return this.withContext((()=>{var e;if(typeof t=="number"){let e=Date.now()+t;t=()=>Date.now()>e}this.parse||(this.parse=this.startParse());n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n<this.state.doc.length&&this.parse.stopAt(n);for(;;){let s=this.parse.advance();if(s){this.fragments=this.withoutTempSkipped(r.addTree(s,this.fragments,this.parse.stoppedAt!=null));this.treeLen=(e=this.parse.stoppedAt)!==null&&e!==void 0?e:this.state.doc.length;this.tree=s;this.parse=null;if(!(this.treeLen<(n!==null&&n!==void 0?n:this.state.doc.length)))return true;this.parse=this.startParse()}if(t())return false}}))}takeTree(){let t,e;if(this.parse&&(t=this.parse.parsedPos)>=this.treeLen){(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t);this.withContext((()=>{while(!(e=this.parse.advance()));}));this.treeLen=t;this.tree=e;this.fragments=this.withoutTempSkipped(r.addTree(this.tree,this.fragments,true));this.parse=null}}withContext(t){let e=U;U=this;try{return t()}finally{U=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=j(t,e.from,e.to);return t}changes(t,n){let{fragments:s,tree:i,treeLen:o,viewport:a,skipped:l}=this;this.takeTree();if(!t.empty){let n=[];t.iterChangedRanges(((t,e,r,s)=>n.push({fromA:t,toA:e,fromB:r,toB:s})));s=r.applyChanges(s,n);i=e.empty;o=0;a={from:t.mapPos(a.from,-1),to:t.mapPos(a.to,1)};if(this.skipped.length){l=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);n<r&&l.push({from:n,to:r})}}}return new ParseContext(this.parser,n,s,i,o,a,l,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return false;this.viewport=t;let e=this.skipped.length;for(let e=0;e<this.skipped.length;e++){let{from:n,to:r}=this.skipped[e];if(n<t.to&&r>t.from){this.fragments=j(this.fragments,n,r);this.skipped.splice(e--,1)}}if(this.skipped.length>=e)return false;this.reset();return true}reset(){if(this.parse){this.takeTree();this.parse=null}}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends s{createParse(n,r,s){let o=s[0].from,a=s[s.length-1].to;let l={parsedPos:o,advance(){let n=U;if(n){for(let t of s)n.tempSkipped.push(t);t&&(n.scheduleOn=n.scheduleOn?Promise.all([n.scheduleOn,t]):t)}this.parsedPos=a;return new e(i.none,[],[],a-o)},stoppedAt:null,stopAt(){}};return l}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&e[0].from==0&&e[0].to>=t}static get(){return U}}function j(t,e,n){return r.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class LanguageState{constructor(t){this.context=t;this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state);let n=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);e.work(20,n)||e.takeTree();return new LanguageState(e)}static init(t){let e=Math.min(3e3,t.doc.length);let n=ParseContext.create(t.facet($).parser,t,{from:0,to:e});n.work(20,e)||n.takeTree();return new LanguageState(n)}}Language.state=u.define({create:LanguageState.init,update(t,e){for(let t of e.effects)if(t.is(Language.setState))return t.value;return e.startState.facet($)!=e.state.facet($)?LanguageState.init(e.state):t.apply(e)}});let z=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};typeof requestIdleCallback!="undefined"&&(z=t=>{let e=-1,n=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const H=typeof navigator!="undefined"&&((I=navigator.scheduling)===null||I===void 0?void 0:I.isInputPending)?()=>navigator.scheduling.isInputPending():null;const V=m.fromClass(class ParseWorker{constructor(t){this.view=t;this.working=null;this.workScheduled=0;this.chunkEnd=-1;this.chunkBudget=-1;this.work=this.work.bind(this);this.scheduleWork()}update(t){let e=this.view.state.field(Language.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork();if(t.docChanged||t.selectionSet){this.view.hasFocus&&(this.chunkBudget+=50);this.scheduleWork()}this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(Language.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=z(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)){this.chunkEnd=e+3e4;this.chunkBudget=3e3}if(this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,s=n.field(Language.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let i=Date.now()+Math.min(this.chunkBudget,100,t&&!H?Math.max(25,t.timeRemaining()-5):1e9);let o=s.context.treeLen<r&&n.doc.length>r+1e3;let a=s.context.work((()=>H&&H()||Date.now()>i),r+(o?0:1e5));this.chunkBudget-=Date.now()-e;if(a||this.chunkBudget<=0){s.context.takeTree();this.view.dispatch({effects:Language.setState.of(new LanguageState(s.context))})}this.chunkBudget>0&&!(a&&!o)&&this.scheduleWork();this.checkAsyncSchedule(s.context)}checkAsyncSchedule(t){if(t.scheduleOn){this.workScheduled++;t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>k(this.view.state,t))).then((()=>this.workScheduled--));t.scheduleOn=null}}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}});const $=a.define({combine(t){return t.length?t[0]:null},enables:t=>[Language.state,V,v.contentAttributes.compute([t],(e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}}))]});class LanguageSupport{constructor(t,e=[]){this.language=t;this.support=e;this.extension=[t,e]}}class LanguageDescription{constructor(t,e,n,r,s,i=void 0){this.name=t;this.alias=e;this.extensions=n;this.filename=r;this.loadFunc=s;this.support=i;this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then((t=>this.support=t),(t=>{this.loading=null;throw t})))}static of(t){let{load:e,support:n}=t;if(!e){if(!n)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");e=()=>Promise.resolve(n)}return new LanguageDescription(t.name,(t.alias||[]).concat(t.name).map((t=>t.toLowerCase())),t.extensions||[],t.filename,e,n)}static matchFilename(t,e){for(let n of t)if(n.filename&&n.filename.test(e))return n;let n=/\.([^.]+)$/.exec(e);if(n)for(let e of t)if(e.extensions.indexOf(n[1])>-1)return e;return null}static matchLanguageName(t,e,n=true){e=e.toLowerCase();for(let n of t)if(n.alias.some((t=>t==e)))return n;if(n)for(let n of t)for(let t of n.alias){let r=e.indexOf(t);if(r>-1&&(t.length>2||!/\w/.test(e[r-1])&&!/\w/.test(e[r+t.length])))return n}return null}}const q=a.define();const G=a.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some((t=>t!=e[0])))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function J(t){let e=t.facet(G);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function _(t,e){let n="",r=t.tabSize,s=t.facet(G)[0];if(s=="\t"){while(e>=r){n+="\t";e-=r}s=" "}for(let t=0;t<e;t++)n+=s;return n}function K(t,e){t instanceof l&&(t=new IndentContext(t));for(let n of t.state.facet(q)){let r=n(t,e);if(r!==void 0)return r}let n=N(t.state);return n.length>=e?Y(t,n,e):null}function Q(t,e,n){let r=Object.create(null);let s=new IndentContext(t,{overrideIndentation:t=>{var e;return(e=r[t])!==null&&e!==void 0?e:-1}});let i=[];for(let o=e;o<=n;){let e=t.doc.lineAt(o);o=e.to+1;let n=K(s,e.from);if(n==null)continue;/\S/.test(e.text)||(n=0);let a=/^\s*/.exec(e.text)[0];let l=_(t,n);if(a!=l){r[e.from]=n;i.push({from:e.from,to:e.from+a.length,insert:l})}}return t.changes(i)}class IndentContext{constructor(t,e={}){this.state=t;this.options=e;this.unit=J(t)}lineAt(t,e=1){let n=this.state.doc.lineAt(t);let{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=n.from&&r<=n.to?s&&r==t?{text:"",from:t}:(e<0?r<t:r<=t)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:n,from:r}=this.lineAt(t,e);return n.slice(t-r,Math.min(n.length,t+100-r))}column(t,e=1){let{text:n,from:r}=this.lineAt(t,e);let s=this.countColumn(n,t-r);let i=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;i>-1&&(s+=i-this.countColumn(n,n.search(/\S|$/)));return s}countColumn(t,e=t.length){return f(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:n,from:r}=this.lineAt(t,e);let s=this.options.overrideIndentation;if(s){let t=s(r);if(t>-1)return t}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const X=new t;function Y(t,e,n){let r=e.resolveStack(n);let s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let t=[];for(let e=s;e&&!(e.from<r.node.from||e.to>r.node.to||e.from==r.node.from&&e.type==r.node.type);e=e.parent)t.push(e);for(let e=t.length-1;e>=0;e--)r={node:t[e],next:r}}return Z(r,t,n)}function Z(t,e,n){for(let r=t;r;r=r.next){let t=et(r.node);if(t)return t(TreeIndentContext.create(e,n,r))}return 0}function tt(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function et(e){let n=e.type.prop(X);if(n)return n;let r,s=e.firstChild;if(s&&(r=s.type.prop(t.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>ot(e,true,1,void 0,n&&!tt(e)?t.from:void 0)}return e.parent==null?nt:null}function nt(){return 0}class TreeIndentContext extends IndentContext{constructor(t,e,n){super(t.state,t.options);this.base=t;this.pos=e;this.context=n}get node(){return this.context.node}static create(t,e,n){return new TreeIndentContext(t,e,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let n=t.resolve(e.from);while(n.parent&&n.parent.from==n.from)n=n.parent;if(rt(n,t))break;e=this.state.doc.lineAt(n.from)}return this.lineIndent(e.from)}continue(){return Z(this.context.next,this.base,this.pos)}}function rt(t,e){for(let n=e;n;n=n.parent)if(t==n)return true;return false}function st(t){let e=t.node;let n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak;let i=t.state.doc.lineAt(n.from);let o=s==null||s<=i.from?i.to:Math.min(i.to,s);for(let t=n.to;;){let s=e.childAfter(t);if(!s||s==r)return null;if(!s.type.isSkipped){if(s.from>=o)return null;let t=/^ */.exec(i.text.slice(n.to-i.from))[0].length;return{from:n.from,to:n.to+t}}t=s.to}}function it({closing:t,align:e=true,units:n=1}){return r=>ot(r,e,n,t)}function ot(t,e,n,r,s){let i=t.textAfter,o=i.match(/^\s*/)[0].length;let a=r&&i.slice(o,o+r.length)==r||s==t.pos+o;let l=e?st(t):null;return l?a?t.column(l.from):t.column(l.to):t.baseIndent+(a?0:t.unit*n)}const at=t=>t.baseIndent;function lt({except:t,units:e=1}={}){return n=>{let r=t&&t.test(n.textAfter);return n.baseIndent+(r?0:e*n.unit)}}const ht=200;function ut(){return l.transactionFilter.of((t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let n=t.newDoc,{head:r}=t.newSelection.main,s=n.lineAt(r);if(r>s.from+ht)return t;let i=n.sliceString(s.from,r);if(!e.some((t=>t.test(i))))return t;let{state:o}=t,a=-1,l=[];for(let{head:t}of o.selection.ranges){let e=o.doc.lineAt(t);if(e.from==a)continue;a=e.from;let n=K(o,e.from);if(n==null)continue;let r=/^\s*/.exec(e.text)[0];let s=_(o,n);r!=s&&l.push({from:e.from,to:e.from+r.length,insert:s})}return l.length?[t,{changes:l,sequential:true}]:t}))}const ft=a.define();const ct=new t;function dt(t){let e=t.firstChild,n=t.lastChild;return e&&e.to<n.from?{from:e.to,to:n.type.isError?t.to:n.from}:null}function pt(t,e,n){let r=N(t);if(r.length<n)return null;let s=r.resolveStack(n,1);let i=null;for(let o=s;o;o=o.next){let s=o.node;if(s.to<=n||s.from>n)continue;if(i&&s.from<e)break;let a=s.type.prop(ct);if(a&&(s.to<r.length-50||r.length==t.doc.length||!gt(s))){let r=a(s,t);r&&r.from<=n&&r.from>=e&&r.to>n&&(i=r)}}return i}function gt(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function mt(t,e,n){for(let r of t.facet(ft)){let s=r(t,e,n);if(s)return s}return pt(t,e,n)}function kt(t,e){let n=e.mapPos(t.from,1),r=e.mapPos(t.to,-1);return n>=r?void 0:{from:n,to:r}}const vt=h.define({map:kt});const wt=h.define({map:kt});function xt(t){let e=[];for(let{head:n}of t.state.selection.ranges)e.some((t=>t.from<=n&&t.to>=n))||e.push(t.lineBlockAt(n));return e}const bt=u.define({create(){return w.none},update(t,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges(((e,n)=>t=yt(t,e,n)));t=t.map(e.changes);for(let n of e.effects)if(n.is(vt)&&!Pt(t,n.value.from,n.value.to)){let{preparePlaceholder:r}=e.state.facet(Et);let s=r?w.replace({widget:new PreparedFoldWidget(r(e.state,n.value))}):Ut;t=t.update({add:[s.range(n.value.from,n.value.to)]})}else n.is(wt)&&(t=t.update({filter:(t,e)=>n.value.from!=t||n.value.to!=e,filterFrom:n.value.from,filterTo:n.value.to}));e.selection&&(t=yt(t,e.selection.main.head));return t},provide:t=>v.decorations.from(t),toJSON(t,e){let n=[];t.between(0,e.doc.length,((t,e)=>{n.push(t,e)}));return n},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let n=0;n<t.length;){let r=t[n++],s=t[n++];if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid JSON for fold state");e.push(Ut.range(r,s))}return w.set(e,true)}});function yt(t,e,n=e){let r=false;t.between(e,n,((t,s)=>{t<n&&s>e&&(r=true)}));return r?t.update({filterFrom:e,filterTo:n,filter:(t,r)=>t>=n||r<=e}):t}function St(t){return t.field(bt,false)||c.empty}function Ct(t,e,n){var r;let s=null;(r=t.field(bt,false))===null||r===void 0?void 0:r.between(e,n,((t,e)=>{(!s||s.from>t)&&(s={from:t,to:e})}));return s}function Pt(t,e,n){let r=false;t.between(e,e,((t,s)=>{t==e&&s==n&&(r=true)}));return r}function Tt(t,e){return t.field(bt,false)?e:e.concat(h.appendConfig.of(Ft()))}const At=t=>{for(let e of xt(t)){let n=mt(t.state,e.from,e.to);if(n){t.dispatch({effects:Tt(t.state,[vt.of(n),It(t,n)])});return true}}return false};const Lt=t=>{if(!t.state.field(bt,false))return false;let e=[];for(let n of xt(t)){let r=Ct(t.state,n.from,n.to);r&&e.push(wt.of(r),It(t,r,false))}e.length&&t.dispatch({effects:e});return e.length>0};function It(t,e,n=true){let r=t.state.doc.lineAt(e.from).number,s=t.state.doc.lineAt(e.to).number;return v.announce.of(`${t.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${t.state.phrase("to")} ${s}.`)}const Dt=t=>{let{state:e}=t,n=[];for(let r=0;r<e.doc.length;){let s=t.lineBlockAt(r),i=mt(e,s.from,s.to);i&&n.push(vt.of(i));r=(i?t.lineBlockAt(i.to):s).to+1}n.length&&t.dispatch({effects:Tt(t.state,n)});return!!n.length};const Ot=t=>{let e=t.state.field(bt,false);if(!e||!e.size)return false;let n=[];e.between(0,t.state.doc.length,((t,e)=>{n.push(wt.of({from:t,to:e}))}));t.dispatch({effects:n});return true};function Bt(t,e){for(let n=e;;){let r=mt(t.state,n.from,n.to);if(r&&r.to>e.from)return r;if(!n.from)return null;n=t.lineBlockAt(n.from-1)}}const Mt=t=>{let e=[];for(let n of xt(t)){let r=Ct(t.state,n.from,n.to);if(r)e.push(wt.of(r),It(t,r,false));else{let r=Bt(t,n);r&&e.push(vt.of(r),It(t,r))}}e.length>0&&t.dispatch({effects:Tt(t.state,e)});return!!e.length};const Nt=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:At},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Lt},{key:"Ctrl-Alt-[",run:Dt},{key:"Ctrl-Alt-]",run:Ot}];const Rt={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"};const Et=a.define({combine(t){return d(t,Rt)}});function Ft(t){let e=[bt,Ht];t&&e.push(Et.of(t));return e}function Wt(t,e){let{state:n}=t,r=n.facet(Et);let s=e=>{let n=t.lineBlockAt(t.posAtDOM(e.target));let r=Ct(t.state,n.from,n.to);r&&t.dispatch({effects:wt.of(r)});e.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(t,s,e);let i=document.createElement("span");i.textContent=r.placeholderText;i.setAttribute("aria-label",n.phrase("folded code"));i.title=n.phrase("unfold");i.className="cm-foldPlaceholder";i.onclick=s;return i}const Ut=w.replace({widget:new class extends x{toDOM(t){return Wt(t,null)}}});class PreparedFoldWidget extends x{constructor(t){super();this.value=t}eq(t){return this.value==t.value}toDOM(t){return Wt(t,this.value)}}const jt={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>false};class FoldMarker extends b{constructor(t,e){super();this.config=t;this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");e.textContent=this.open?this.config.openText:this.config.closedText;e.title=t.state.phrase(this.open?"Fold line":"Unfold line");return e}}function zt(t={}){let e={...jt,...t};let n=new FoldMarker(e,true),r=new FoldMarker(e,false);let s=m.fromClass(class{constructor(t){this.from=t.viewport.from;this.markers=this.buildMarkers(t)}update(t){(t.docChanged||t.viewportChanged||t.startState.facet($)!=t.state.facet($)||t.startState.field(bt,false)!=t.state.field(bt,false)||N(t.startState)!=N(t.state)||e.foldingChanged(t))&&(this.markers=this.buildMarkers(t.view))}buildMarkers(t){let e=new p;for(let s of t.viewportLineBlocks){let i=Ct(t.state,s.from,s.to)?r:mt(t.state,s.from,s.to)?n:null;i&&e.add(s.from,s.from,i)}return e.finish()}});let{domEventHandlers:i}=e;return[s,y({class:"cm-foldGutter",markers(t){var e;return((e=t.plugin(s))===null||e===void 0?void 0:e.markers)||c.empty},initialSpacer(){return new FoldMarker(e,false)},domEventHandlers:{...i,click:(t,e,n)=>{if(i.click&&i.click(t,e,n))return true;let r=Ct(t.state,e.from,e.to);if(r){t.dispatch({effects:wt.of(r)});return true}let s=mt(t.state,e.from,e.to);if(s){t.dispatch({effects:vt.of(s)});return true}return false}}}),Ft()]}const Ht=v.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"}});class HighlightStyle{constructor(t,e){this.specs=t;let n;function r(t){let e=L.newName();(n||(n=Object.create(null)))["."+e]=t;return e}const s=typeof e.all=="string"?e.all:e.all?r(e.all):void 0;const i=e.scope;this.scope=i instanceof Language?t=>t.prop(D)==i.data:i?t=>t==i:void 0;this.style=C(t.map((t=>({tag:t.tag,class:t.class||r(Object.assign({},t,{tag:null}))}))),{all:s}).style;this.module=n?new L(n):null;this.themeType=e.themeType}static define(t,e){return new HighlightStyle(t,e||{})}}const Vt=a.define();const $t=a.define({combine(t){return t.length?[t[0]]:null}});function qt(t){let e=t.facet(Vt);return e.length?e:t.facet($t)}function Gt(t,e){let n,r=[_t];if(t instanceof HighlightStyle){t.module&&r.push(v.styleModule.of(t.module));n=t.themeType}(e===null||e===void 0?void 0:e.fallback)?r.push($t.of(t)):n?r.push(Vt.computeN([v.darkTheme],(e=>e.facet(v.darkTheme)==(n=="dark")?[t]:[]))):r.push(Vt.of(t));return r}function Jt(t,e,n){let r=qt(t);let s=null;if(r)for(let t of r)if(!t.scope||n&&t.scope(n)){let n=t.style(e);n&&(s=s?s+" "+n:n)}return s}class TreeHighlighter{constructor(t){this.markCache=Object.create(null);this.tree=N(t.state);this.decorations=this.buildDeco(t,qt(t.state));this.decoratedTo=t.viewport.to}update(t){let e=N(t.state),n=qt(t.state);let r=n!=qt(t.startState);let{viewport:s}=t.view,i=t.changes.mapPos(this.decoratedTo,1);if(e.length<s.to&&!r&&e.type==this.tree.type&&i>=s.to){this.decorations=this.decorations.map(t.changes);this.decoratedTo=i}else if(e!=this.tree||t.viewportChanged||r){this.tree=e;this.decorations=this.buildDeco(t.view,n);this.decoratedTo=s.to}}buildDeco(t,e){if(!e||!this.tree.length)return w.none;let n=new p;for(let{from:r,to:s}of t.visibleRanges)P(this.tree,e,((t,e,r)=>{n.add(t,e,this.markCache[r]||(this.markCache[r]=w.mark({class:r})))}),r,s);return n.finish()}}const _t=g.high(m.fromClass(TreeHighlighter,{decorations:t=>t.decorations}));const Kt=HighlightStyle.define([{tag:T.meta,color:"#404740"},{tag:T.link,textDecoration:"underline"},{tag:T.heading,textDecoration:"underline",fontWeight:"bold"},{tag:T.emphasis,fontStyle:"italic"},{tag:T.strong,fontWeight:"bold"},{tag:T.strikethrough,textDecoration:"line-through"},{tag:T.keyword,color:"#708"},{tag:[T.atom,T.bool,T.url,T.contentSeparator,T.labelName],color:"#219"},{tag:[T.literal,T.inserted],color:"#164"},{tag:[T.string,T.deleted],color:"#a11"},{tag:[T.regexp,T.escape,T.special(T.string)],color:"#e40"},{tag:T.definition(T.variableName),color:"#00f"},{tag:T.local(T.variableName),color:"#30a"},{tag:[T.typeName,T.namespace],color:"#085"},{tag:T.className,color:"#167"},{tag:[T.special(T.variableName),T.macroName],color:"#256"},{tag:T.definition(T.propertyName),color:"#00c"},{tag:T.comment,color:"#940"},{tag:T.invalid,color:"#f00"}]);const Qt=v.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}});const Xt=1e4,Yt="()[]{}";const Zt=a.define({combine(t){return d(t,{afterCursor:true,brackets:Yt,maxScanDistance:Xt,renderMatch:ne})}});const te=w.mark({class:"cm-matchingBracket"}),ee=w.mark({class:"cm-nonmatchingBracket"});function ne(t){let e=[];let n=t.matched?te:ee;e.push(n.range(t.start.from,t.start.to));t.end&&e.push(n.range(t.end.from,t.end.to));return e}const re=u.define({create(){return w.none},update(t,e){if(!e.docChanged&&!e.selection)return t;let n=[];let r=e.state.facet(Zt);for(let t of e.state.selection.ranges){if(!t.empty)continue;let s=he(e.state,t.head,-1,r)||t.head>0&&he(e.state,t.head-1,1,r)||r.afterCursor&&(he(e.state,t.head,1,r)||t.head<e.state.doc.length&&he(e.state,t.head+1,-1,r));s&&(n=n.concat(r.renderMatch(s,e.state)))}return w.set(n,true)},provide:t=>v.decorations.from(t)});const se=[re,Qt];function ie(t={}){return[Zt.of(t),se]}const oe=new t;function ae(e,n,r){let s=e.prop(n<0?t.openedBy:t.closedBy);if(s)return s;if(e.name.length==1){let t=r.indexOf(e.name);if(t>-1&&t%2==(n<0?1:0))return[r[t+n]]}return null}function le(t){let e=t.type.prop(oe);return e?e(t.node):t}function he(t,e,n,r={}){let s=r.maxScanDistance||Xt,i=r.brackets||Yt;let o=N(t),a=o.resolveInner(e,n);for(let r=a;r;r=r.parent){let s=ae(r.type,n,i);if(s&&r.from<r.to){let o=le(r);if(o&&(n>0?e>=o.from&&e<o.to:e>o.from&&e<=o.to))return ue(t,e,n,r,o,s,i)}}return fe(t,e,n,o,a.type,s,i)}function ue(t,e,n,r,s,i,o){let a=r.parent,l={from:s.from,to:s.to};let h=0,u=a===null||a===void 0?void 0:a.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do{if(n<0?u.to<=r.from:u.from>=r.to){if(h==0&&i.indexOf(u.type.name)>-1&&u.from<u.to){let t=le(u);return{start:l,end:t?{from:t.from,to:t.to}:void 0,matched:true}}if(ae(u.type,n,o))h++;else if(ae(u.type,-n,o)){if(h==0){let t=le(u);return{start:l,end:t&&t.from<t.to?{from:t.from,to:t.to}:void 0,matched:false}}h--}}}while(n<0?u.prevSibling():u.nextSibling());return{start:l,matched:false}}function fe(t,e,n,r,s,i,o){let a=n<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1);let l=o.indexOf(a);if(l<0||l%2==0!=n>0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e};let u=t.doc.iterRange(e,n>0?t.doc.length:0),f=0;for(let t=0;!u.next().done&&t<=i;){let i=u.value;n<0&&(t+=i.length);let a=e+t*n;for(let t=n>0?0:i.length-1,e=n>0?i.length:-1;t!=e;t+=n){let e=o.indexOf(i[t]);if(!(e<0||r.resolveInner(a+t,1).type!=s))if(e%2==0==n>0)f++;else{if(f==1)return{start:h,end:{from:a+t,to:a+t+1},matched:e>>1==l>>1};f--}}n>0&&(t+=i.length)}return u.done?{start:h,matched:false}:null}function ce(t,e,n,r=0,s=0){if(e==null){e=t.search(/[^\s\u00a0]/);e==-1&&(e=t.length)}let i=s;for(let s=r;s<e;s++)t.charCodeAt(s)==9?i+=n-i%n:i++;return i}class StringStream{constructor(t,e,n,r){this.string=t;this.tabSize=e;this.indentUnit=n;this.overrideIndent=r;this.pos=0;this.start=0;this.lastColumnPos=0;this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(t){let e=this.string.charAt(this.pos);let n;n=typeof t=="string"?e==t:e&&(t instanceof RegExp?t.test(e):t(e));if(n){++this.pos;return e}}eatWhile(t){let e=this.pos;while(this.eat(t));return this.pos>e}eatSpace(){let t=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos)))++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let e=this.string.indexOf(t,this.pos);if(e>-1){this.pos=e;return true}}backUp(t){this.pos-=t}column(){if(this.lastColumnPos<this.start){this.lastColumnValue=ce(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue);this.lastColumnPos=this.start}return this.lastColumnValue}indentation(){var t;return(t=this.overrideIndent)!==null&&t!==void 0?t:ce(this.string,null,this.tabSize)}match(t,e,n){if(typeof t=="string"){let r=t=>n?t.toLowerCase():t;let s=this.string.substr(this.pos,t.length);if(r(s)==r(t)){e!==false&&(this.pos+=t.length);return true}return null}{let n=this.string.slice(this.pos).match(t);if(n&&n.index>0)return null;n&&e!==false&&(this.pos+=n[0].length);return n}}current(){return this.string.slice(this.start,this.pos)}}function de(t){return{name:t.name||"",token:t.token,blankLine:t.blankLine||(()=>{}),startState:t.startState||(()=>true),copyState:t.copyState||pe,indent:t.indent||(()=>null),languageData:t.languageData||{},tokenTable:t.tokenTable||xe,mergeTokens:t.mergeTokens!==false}}function pe(t){if(typeof t!="object")return t;let e={};for(let n in t){let r=t[n];e[n]=r instanceof Array?r.slice():r}return e}const ge=new WeakMap;class StreamLanguage extends Language{constructor(e){let n=O(e.languageData);let r,i=de(e);let o=new class extends s{createParse(t,e,n){return new Parse(r,t,e,n)}};super(n,o,[],e.name);this.topNode=Ie(n,this);r=this;this.streamParser=i;this.stateAfter=new t({perNode:true});this.tokenTable=e.tokenTable?new TokenTable(i.tokenTable):Te}static define(t){return new StreamLanguage(t)}getIndent(t){let e;let{overrideIndentation:n}=t.options;if(n){e=ge.get(t.state);e!=null&&e<t.pos-1e4&&(e=void 0)}let r,s,i=me(this,t.node.tree,t.node.from,t.node.from,e!==null&&e!==void 0?e:t.pos);if(i){s=i.state;r=i.pos+1}else{s=this.streamParser.startState(t.unit);r=t.node.from}if(t.pos-r>1e4)return null;while(r<t.pos){let e=t.state.doc.lineAt(r),i=Math.min(t.pos,e.to);if(e.length){let r=n?n(e.from):-1;let o=new StringStream(e.text,t.state.tabSize,t.unit,r<0?void 0:r);while(o.pos<i-e.from)we(this.streamParser.token,o,s)}else this.streamParser.blankLine(s,t.unit);if(i==t.pos)break;r=e.to+1}let o=t.lineAt(t.pos);n&&e==null&&ge.set(t.state,o.from);return this.streamParser.indent(s,/^\s*(.*)/.exec(o.text)[1],t)}get allowsNesting(){return false}}function me(t,n,r,s,i){let o=r>=s&&r+n.length<=i&&n.prop(t.stateAfter);if(o)return{state:t.streamParser.copyState(o),pos:r+n.length};for(let o=n.children.length-1;o>=0;o--){let a=n.children[o],l=r+n.positions[o];let h=a instanceof e&&l<i&&me(t,a,l,s,i);if(h)return h}return null}function ke(t,n,r,s,i){if(i&&r<=0&&s>=n.length)return n;i||r!=0||n.type!=t.topNode||(i=true);for(let o=n.children.length-1;o>=0;o--){let a,l=n.positions[o],h=n.children[o];if(l<s&&h instanceof e){if(!(a=ke(t,h,r-l,s-l,i)))break;return i?new e(n.type,n.children.slice(0,o).concat(a),n.positions.slice(0,o+1),l+a.length):a}}return null}function ve(t,n,r,s,i){for(let e of n){let n=e.from+(e.openStart?25:0),i=e.to-(e.openEnd?25:0);let o,a=n<=r&&i>r&&me(t,e.tree,0-e.offset,r,i);if(a&&a.pos<=s&&(o=ke(t,e.tree,r+e.offset,a.pos+e.offset,false)))return{state:a.state,tree:o}}return{state:t.streamParser.startState(i?J(i):4),tree:e.empty}}class Parse{constructor(t,e,n,r){this.lang=t;this.input=e;this.fragments=n;this.ranges=r;this.stoppedAt=null;this.chunks=[];this.chunkPos=[];this.chunk=[];this.chunkReused=void 0;this.rangeIndex=0;this.to=r[r.length-1].to;let s=ParseContext.get(),i=r[0].from;let{state:o,tree:a}=ve(t,n,i,this.to,s===null||s===void 0?void 0:s.state);this.state=o;this.parsedPos=this.chunkStart=i+a.length;for(let t=0;t<a.children.length;t++){this.chunks.push(a.children[t]);this.chunkPos.push(a.positions[t])}if(s&&this.parsedPos<s.viewport.from-1e5&&r.some((t=>t.from<=s.viewport.from&&t.to>=s.viewport.from))){this.state=this.lang.streamParser.startState(J(s.state));s.skipUntilInView(this.parsedPos,s.viewport.from);this.parsedPos=s.viewport.from}this.moveRangeIndex()}advance(){let t=ParseContext.get();let e=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt);let n=Math.min(e,this.chunkStart+512);t&&(n=Math.min(n,t.viewport.to));while(this.parsedPos<n)this.parseLine(t);this.chunkStart<this.parsedPos&&this.finishChunk();if(this.parsedPos>=e)return this.finish();if(t&&this.parsedPos>=t.viewport.to){t.skipUntilInView(this.parsedPos,e);return this.finish()}return null}stopAt(t){this.stoppedAt=t}lineAfter(t){let e=this.input.chunk(t);if(this.input.lineChunks)e=="\n"&&(e="");else{let t=e.indexOf("\n");t>-1&&(e=e.slice(0,t))}return t+e.length<=this.to?e:e.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,e=this.lineAfter(t),n=t+e.length;for(let t=this.rangeIndex;;){let r=this.ranges[t].to;if(r>=n)break;e=e.slice(0,r-(n-e.length));t++;if(t==this.ranges.length)break;let s=this.ranges[t].from;let i=this.lineAfter(s);e+=i;n=s+i.length}return{line:e,end:n}}skipGapsTo(t,e,n){for(;;){let r=this.ranges[this.rangeIndex].to,s=t+e;if(n>0?r>s:r>=s)break;let i=this.ranges[++this.rangeIndex].from;e+=i-r}return e}moveRangeIndex(){while(this.ranges[this.rangeIndex].to<this.parsedPos)this.rangeIndex++}emitToken(t,e,n,r){let s=4;if(this.ranges.length>1){r=this.skipGapsTo(e,r,1);e+=r;let t=this.chunk.length;r=this.skipGapsTo(n,r,-1);n+=r;s+=this.chunk.length-t}let i=this.chunk.length-4;this.lang.streamParser.mergeTokens&&s==4&&i>=0&&this.chunk[i]==t&&this.chunk[i+2]==e?this.chunk[i+2]=n:this.chunk.push(t,e,n,s);return r}parseLine(t){let{line:e,end:n}=this.nextLine(),r=0,{streamParser:s}=this.lang;let i=new StringStream(e,t?t.state.tabSize:4,t?J(t.state):2);if(i.eol())s.blankLine(this.state,i.indentUnit);else while(!i.eol()){let t=we(s.token,i,this.state);t&&(r=this.emitToken(this.lang.tokenTable.resolve(t),this.parsedPos+i.start,this.parsedPos+i.pos,r));if(i.start>1e4)break}this.parsedPos=n;this.moveRangeIndex();this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=e.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:ye,topID:0,maxBufferLength:512,reused:this.chunkReused});t=new e(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]);this.chunks.push(t);this.chunkPos.push(this.chunkStart-this.ranges[0].from);this.chunk=[];this.chunkReused=void 0;this.chunkStart=this.parsedPos}finish(){return new e(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function we(t,e,n){e.start=e.pos;for(let r=0;r<10;r++){let r=t(e,n);if(e.pos>e.start)return r}throw new Error("Stream parser failed to advance stream.")}const xe=Object.create(null);const be=[i.none];const ye=new o(be);const Se=[];const Ce=Object.create(null);const Pe=Object.create(null);for(let[t,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"]])Pe[t]=Le(xe,e);class TokenTable{constructor(t){this.extra=t;this.table=Object.assign(Object.create(null),Pe)}resolve(t){return t?this.table[t]||(this.table[t]=Le(this.extra,t)):0}}const Te=new TokenTable(xe);function Ae(t,e){if(!(Se.indexOf(t)>-1)){Se.push(t);console.warn(e)}}function Le(t,e){let n=[];for(let r of e.split(" ")){let e=[];for(let n of r.split(".")){let r=t[n]||T[n];r?typeof r=="function"?e.length?e=e.map(r):Ae(n,`Modifier ${n} used at start of tag`):e.length?Ae(n,`Tag ${n} used as modifier`):e=Array.isArray(r)?r:[r]:Ae(n,`Unknown highlighting tag ${n}`)}for(let t of e)n.push(t)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map((t=>t.id));let o=Ce[s];if(o)return o.id;let a=Ce[s]=i.define({id:be.length,name:r,props:[A({[r]:n})]});be.push(a);return a.id}function Ie(t,e){let n=i.define({id:be.length,name:"Document",props:[D.add((()=>t)),X.add((()=>t=>e.getIndent(t)))],top:true});be.push(n);return n}function De(t){return t.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(t)}function Oe(t){for(let e=t.iter();!e.next().done;)if(De(e.value))return true;return false}function Be(t){let e=false;t.iterChanges(((t,n,r,s,i)=>{!e&&Oe(i)&&(e=true)}));return e}const Me=a.define({combine:t=>t.some((t=>t))});function Ne(t={}){let e=[Re];t.alwaysIsolate&&e.push(Me.of(true));return e}const Re=m.fromClass(class{constructor(t){this.always=t.state.facet(Me)||t.textDirection!=S.LTR||t.state.facet(v.perLineTextDirection);this.hasRTL=!this.always&&Oe(t.state.doc);this.tree=N(t.state);this.decorations=this.always||this.hasRTL?Ee(t,this.tree,this.always):w.none}update(t){let e=t.state.facet(Me)||t.view.textDirection!=S.LTR||t.state.facet(v.perLineTextDirection);e||this.hasRTL||!Be(t.changes)||(this.hasRTL=true);if(!e&&!this.hasRTL)return;let n=N(t.state);if(e!=this.always||n!=this.tree||t.docChanged||t.viewportChanged){this.tree=n;this.always=e;this.decorations=Ee(t.view,n,e)}}},{provide:t=>{function e(e){var n,r;return(r=(n=e.plugin(t))===null||n===void 0?void 0:n.decorations)!==null&&r!==void 0?r:w.none}return[v.outerDecorations.of(e),g.lowest(v.bidiIsolatedRanges.of(e))]}});function Ee(e,n,r){let s=new p;let i=e.visibleRanges;r||(i=Fe(i,e.state.doc));for(let{from:e,to:r}of i)n.iterate({enter:e=>{let n=e.type.prop(t.isolate);n&&s.add(e.from,e.to,We[n])},from:e,to:r});return s.finish()}function Fe(t,e){let n=e.iter(),r=0,s=[],i=null;for(let{from:e,to:o}of t){if(i&&i.to>e){e=i.to;if(e>=o)continue}if(r+n.value.length<e){n.next(e-(r+n.value.length));r=e}for(;;){let t=r,e=r+n.value.length;!n.lineBreak&&De(n.value)&&(i&&i.to>t-10?i.to=Math.min(o,e):s.push(i={from:t,to:Math.min(o,e)}));if(e>=o)break;r=e;n.next()}}return s}const We={rtl:w.mark({class:"cm-iso",inclusive:true,attributes:{dir:"rtl"},bidiIsolate:S.RTL}),ltr:w.mark({class:"cm-iso",inclusive:true,attributes:{dir:"ltr"},bidiIsolate:S.LTR}),auto:w.mark({class:"cm-iso",inclusive:true,attributes:{dir:"auto"},bidiIsolate:null})};export{DocInput,HighlightStyle,IndentContext,LRLanguage,Language,LanguageDescription,LanguageSupport,ParseContext,StreamLanguage,StringStream,TreeIndentContext,Ne as bidiIsolates,ie as bracketMatching,oe as bracketMatchingHandle,Ft as codeFolding,lt as continuedIndent,Kt as defaultHighlightStyle,O as defineLanguageFacet,it as delimitedIndent,R as ensureSyntaxTree,at as flatIndent,Dt as foldAll,At as foldCode,vt as foldEffect,zt as foldGutter,dt as foldInside,Nt as foldKeymap,ct as foldNodeProp,ft as foldService,bt as foldState,mt as foldable,St as foldedRanges,F as forceParsing,J as getIndentUnit,K as getIndentation,Jt as highlightingFor,X as indentNodeProp,ut as indentOnInput,Q as indentRange,q as indentService,_ as indentString,G as indentUnit,$ as language,D as languageDataProp,he as matchBrackets,B as sublanguageProp,Gt as syntaxHighlighting,W as syntaxParserRunning,N as syntaxTree,E as syntaxTreeAvailable,Mt as toggleFold,Ot as unfoldAll,Lt as unfoldCode,wt as unfoldEffect};+diff --git a/admin/vendor/javascript/@codemirror--lint.js b/admin/vendor/javascript/@codemirror--lint.jsnew file mode 100644index 0000000000..b33a0ee259--- /dev/null+++ b/admin/vendor/javascript/@codemirror--lint.js@@ -0,0 +1,4 @@+// @codemirror/[email protected] downloaded from https://ga.jspm.io/npm:@codemirror/[email protected]/dist/index.js++import{Decoration as e,EditorView as t,hoverTooltip as i,showPanel as n,getPanel as o,ViewPlugin as s,logException as l,WidgetType as r,GutterMarker as a,gutter as c,showTooltip as d}from"@codemirror/view";import{Facet as f,RangeSetBuilder as u,StateEffect as m,StateField as h,combineConfig as g,RangeSet as p}from"@codemirror/state";import v from"crelt";class SelectedDiagnostic{constructor(e,t,i){this.from=e;this.to=t;this.diagnostic=i}}class LintState{constructor(e,t,i){this.diagnostics=e;this.panel=t;this.selected=i}static init(t,i,n){let o=n.facet($).markerFilter;o&&(t=o(t,n));let s=t.slice().sort(((e,t)=>e.from-t.from||e.to-t.to));let l=new u,r=[],a=0;for(let t=0;;){let i=t==s.length?null:s[t];if(!i&&!r.length)break;let o,c;if(r.length){o=a;c=r.reduce(((e,t)=>Math.min(e,t.to)),i&&i.from>o?i.from:1e8)}else{o=i.from;c=i.to;r.push(i);t++}while(t<s.length){let e=s[t];if(e.from!=o||!(e.to>e.from||e.to==o)){c=Math.min(e.from,c);break}r.push(e);t++;c=Math.min(e.to,c)}let d=_(r);if(r.some((e=>e.from==e.to||e.from==e.to-1&&n.doc.lineAt(e.from).to==e.from)))l.add(o,o,e.widget({widget:new DiagnosticWidget(d),diagnostics:r.slice()}));else{let t=r.reduce(((e,t)=>t.markClass?e+" "+t.markClass:e),"");l.add(o,c,e.mark({class:"cm-lintRange cm-lintRange-"+d+t,diagnostics:r.slice(),inclusiveEnd:r.some((e=>e.to>c))}))}a=c;for(let e=0;e<r.length;e++)r[e].to<=a&&r.splice(e--,1)}let c=l.finish();return new LintState(c,i,w(c))}}function w(e,t=null,i=0){let n=null;e.between(i,1e9,((e,i,{spec:o})=>{if(!(t&&o.diagnostics.indexOf(t)<0))if(n){if(o.diagnostics.indexOf(n.diagnostic)<0)return false;n=new SelectedDiagnostic(n.from,i,n.diagnostic)}else n=new SelectedDiagnostic(e,i,t||o.diagnostics[0])}));return n}function b(e,t){let i=t.pos,n=t.end||i;let o=e.state.facet($).hideOn(e,i,n);if(o!=null)return o;let s=e.startState.doc.lineAt(t.pos);return!!(e.effects.some((e=>e.is(y)))||e.changes.touchesRange(s.from,Math.max(s.to,n)))}function k(e,t){return e.field(S,false)?t:t.concat(m.appendConfig.of(ie))}function x(e,t){return{effects:k(e,[y.of(t)])}}const y=m.define();const C=m.define();const L=m.define();const S=h.define({create(){return new LintState(e.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let i=e.diagnostics.map(t.changes),n=null,o=e.panel;if(e.selected){let o=t.changes.mapPos(e.selected.from,1);n=w(i,e.selected.diagnostic,o)||w(i,null,o)}!i.size&&o&&t.state.facet($).autoPanel&&(o=null);e=new LintState(i,o,n)}for(let i of t.effects)if(i.is(y)){let n=t.state.facet($).autoPanel?i.value.length?LintPanel.open:null:e.panel;e=LintState.init(i.value,n,t.state)}else i.is(C)?e=new LintState(e.diagnostics,i.value?LintPanel.open:null,e.selected):i.is(L)&&(e=new LintState(e.diagnostics,e.panel,i.value));return e},provide:e=>[n.from(e,(e=>e.panel)),t.decorations.from(e,(e=>e.diagnostics))]});function T(e){let t=e.field(S,false);return t?t.diagnostics.size:0}const R=e.mark({class:"cm-lintRange cm-lintRange-active"});function P(e,t,i){let{diagnostics:n}=e.state.field(S);let o,s=-1,l=-1;n.between(t-(i<0?1:0),t+(i>0?1:0),((e,n,{spec:r})=>{if(t>=e&&t<=n&&(e==n||(t>e||i>0)&&(t<n||i<0))){o=r.diagnostics;s=e;l=n;return false}}));let r=e.state.facet($).tooltipFilter;o&&r&&(o=r(o,e.state));return o?{pos:s,end:l,above:e.state.doc.lineAt(s).to<l,create(){return{dom:I(e,o)}}}:null}function I(e,t){return v("ul",{class:"cm-tooltip-lint"},t.map((t=>q(e,t,false))))}const M=e=>{let t=e.state.field(S,false);t&&t.panel||e.dispatch({effects:k(e.state,[C.of(true)])});let i=o(e,LintPanel.open);i&&i.dom.querySelector(".cm-panel-lint ul").focus();return true};const A=e=>{let t=e.state.field(S,false);if(!t||!t.panel)return false;e.dispatch({effects:C.of(false)});return true};const D=e=>{let t=e.state.field(S,false);if(!t)return false;let i=e.state.selection.main,n=t.diagnostics.iter(i.to+1);if(!n.value){n=t.diagnostics.iter(0);if(!n.value||n.from==i.from&&n.to==i.to)return false}e.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:true});return true};const B=e=>{let{state:t}=e,i=t.field(S,false);if(!i)return false;let n=t.selection.main;let o,s,l,r;i.diagnostics.between(0,t.doc.length,((e,t)=>{if(t<n.to&&(o==null||o<e)){o=e;s=t}if(l==null||e>l){l=e;r=t}}));if(l==null||o==null&&l==n.from)return false;e.dispatch({selection:{anchor:o!==null&&o!==void 0?o:l,head:s!==null&&s!==void 0?s:r},scrollIntoView:true});return true};const O=[{key:"Mod-Shift-m",run:M,preventDefault:true},{key:"F8",run:D}];const F=s.fromClass(class{constructor(e){this.view=e;this.timeout=-1;this.set=true;let{delay:t}=e.state.facet($);this.lintTime=Date.now()+t;this.run=this.run.bind(this);this.timeout=setTimeout(this.run,t)}run(){clearTimeout(this.timeout);let e=Date.now();if(e<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-e);else{this.set=false;let{state:e}=this.view,{sources:t}=e.facet($);t.length&&z(t.map((e=>Promise.resolve(e(this.view)))),(t=>{this.view.state.doc==e.doc&&this.view.dispatch(x(this.view.state,t.reduce(((e,t)=>e.concat(t)))))}),(e=>{l(this.view.state,e)}))}}update(e){let t=e.state.facet($);if(e.docChanged||t!=e.startState.facet($)||t.needsRefresh&&t.needsRefresh(e)){this.lintTime=Date.now()+t.delay;if(!this.set){this.set=true;this.timeout=setTimeout(this.run,t.delay)}}}force(){if(this.set){this.lintTime=Date.now();this.run()}}destroy(){clearTimeout(this.timeout)}});function z(e,t,i){let n=[],o=-1;for(let s of e)s.then((i=>{n.push(i);clearTimeout(o);n.length==e.length?t(n):o=setTimeout((()=>t(n)),200)}),i)}const $=f.define({combine(e){return{sources:e.map((e=>e.source)).filter((e=>e!=null)),...g(e.map((e=>e.config)),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:E,tooltipFilter:E,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,n,o)=>e(i,n,o)||t(i,n,o):e:t,autoPanel:(e,t)=>e||t})}}});function E(e,t){return e?t?(i,n)=>t(e(i,n),n):e:t}function H(e,t={}){return[$.of({source:e,config:t}),F,ie]}function N(e){let t=e.plugin(F);t&&t.force()}function j(e){let t=[];if(e)e:for(let{name:i}of e){for(let e=0;e<i.length;e++){let n=i[e];if(/[a-zA-Z]/.test(n)&&!t.some((e=>e.toLowerCase()==n.toLowerCase()))){t.push(n);continue e}}t.push("")}return t}function q(e,t,i){var n;let o=i?j(t.actions):[];return v("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},v("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),(n=t.actions)===null||n===void 0?void 0:n.map(((i,n)=>{let s=false,l=n=>{n.preventDefault();if(s)return;s=true;let o=w(e.state.field(S).diagnostics,t);o&&i.apply(e,o.from,o.to)};let{name:r}=i,a=o[n]?r.indexOf(o[n]):-1;let c=a<0?r:[r.slice(0,a),v("u",r.slice(a,a+1)),r.slice(a+1)];let d=i.markClass?" "+i.markClass:"";return v("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:l,onmousedown:l,"aria-label":` Action: ${r}${a<0?"":` (access key "${o[n]})"`}.`},c)})),t.source&&v("div",{class:"cm-diagnosticSource"},t.source))}class DiagnosticWidget extends r{constructor(e){super();this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return v("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class PanelItem{constructor(e,t){this.diagnostic=t;this.id="item_"+Math.floor(Math.random()*4294967295).toString(16);this.dom=q(e,t,true);this.dom.id=this.id;this.dom.setAttribute("role","option")}}class LintPanel{constructor(e){this.view=e;this.items=[];let t=t=>{if(t.keyCode==27){A(this.view);this.view.focus()}else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else{if(!(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:i}=this.items[this.selectedIndex],n=j(i.actions);for(let o=0;o<n.length;o++)if(n[o].toUpperCase().charCodeAt(0)==t.keyCode){let t=w(this.view.state.field(S).diagnostics,i);t&&i.actions[o].apply(e,t.from,t.to)}}}t.preventDefault()};let i=e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)};this.list=v("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i});this.dom=v("div",{class:"cm-panel-lint"},this.list,v("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>A(this.view)},"×"));this.update()}get selectedIndex(){let e=this.view.state.field(S).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(S);let i=0,n=false,o=null;let s=new Set;e.between(0,this.view.state.doc.length,((e,l,{spec:r})=>{for(let e of r.diagnostics){if(s.has(e))continue;s.add(e);let l,r=-1;for(let t=i;t<this.items.length;t++)if(this.items[t].diagnostic==e){r=t;break}if(r<0){l=new PanelItem(this.view,e);this.items.splice(i,0,l);n=true}else{l=this.items[r];if(r>i){this.items.splice(i,r-i);n=true}}if(t&&l.diagnostic==t.diagnostic){if(!l.dom.hasAttribute("aria-selected")){l.dom.setAttribute("aria-selected","true");o=l}}else l.dom.hasAttribute("aria-selected")&&l.dom.removeAttribute("aria-selected");i++}}));while(i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0)){n=true;this.items.pop()}if(this.items.length==0){this.items.push(new PanelItem(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")}));n=true}if(o){this.list.setAttribute("aria-activedescendant",o.id);this.view.requestMeasure({key:this,read:()=>({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let i=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/i:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/i)}})}else this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant");n&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling;t.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){while(e!=i.dom)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);while(e)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(S);let i=w(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:true,effects:L.of(i)})}static open(e){return new LintPanel(e)}}function G(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function V(e){return G(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Y=t.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:V("#d11")},".cm-lintRange-warning":{backgroundImage:V("orange")},".cm-lintRange-info":{backgroundImage:V("#999")},".cm-lintRange-hint":{backgroundImage:V("#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}}});function Z(e){return e=="error"?4:e=="warning"?3:e=="info"?2:1}function _(e){let t="hint",i=1;for(let n of e){let e=Z(n.severity);if(e>i){i=e;t=n.severity}}return t}class LintGutterMarker extends a{constructor(e){super();this.diagnostics=e;this.severity=_(e)}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics;let n=e.state.facet(ne).tooltipFilter;n&&(i=n(i,e.state));i.length&&(t.onmouseover=()=>W(e,t,i));return t}}function U(e,t){let i=n=>{let o=t.getBoundingClientRect();if(!(n.clientX>o.left-10&&n.clientX<o.right+10&&n.clientY>o.top-10&&n.clientY<o.bottom+10)){for(let e=n.target;e;e=e.parentNode)if(e.nodeType==1&&e.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",i);e.state.field(ee)&&e.dispatch({effects:Q.of(null)})}};window.addEventListener("mousemove",i)}function W(e,t,i){function n(){let n=e.elementAtHeight(t.getBoundingClientRect().top+5-e.documentTop);const o=e.coordsAtPos(n.from);o&&e.dispatch({effects:Q.of({pos:n.from,above:false,clip:false,create(){return{dom:I(e,i),getCoords:()=>t.getBoundingClientRect()}}})});t.onmouseout=t.onmousemove=null;U(e,t)}let{hoverTime:o}=e.state.facet(ne);let s=setTimeout(n,o);t.onmouseout=()=>{clearTimeout(s);t.onmouseout=t.onmousemove=null};t.onmousemove=()=>{clearTimeout(s);s=setTimeout(n,o)}}function X(e,t){let i=Object.create(null);for(let n of t){let t=e.lineAt(n.from);(i[t.from]||(i[t.from]=[])).push(n)}let n=[];for(let e in i)n.push(new LintGutterMarker(i[e]).range(+e));return p.of(n,true)}const J=c({class:"cm-gutter-lint",markers:e=>e.state.field(K),widgetMarker:(e,t,i)=>{let n=[];e.state.field(K).between(i.from,i.to,((e,t,o)=>{e>i.from&&e<i.to&&n.push(...o.diagnostics)}));return n.length?new LintGutterMarker(n):null}});const K=h.define({create(){return p.empty},update(e,t){e=e.map(t.changes);let i=t.state.facet(ne).markerFilter;for(let n of t.effects)if(n.is(y)){let o=n.value;i&&(o=i(o||[],t.state));e=X(t.state.doc,o.slice(0))}return e}});const Q=m.define();const ee=h.define({create(){return null},update(e,t){e&&t.docChanged&&(e=b(t,e)?null:{...e,pos:t.changes.mapPos(e.pos)});return t.effects.reduce(((e,t)=>t.is(Q)?t.value:e),e)},provide:e=>d.from(e)});const te=t.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:G('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:G('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:G('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}});const ie=[S,t.decorations.compute([S],(t=>{let{selected:i,panel:n}=t.field(S);return i&&n&&i.from!=i.to?e.set([R.range(i.from,i.to)]):e.none})),i(P,{hideOn:b}),Y];const ne=f.define({combine(e){return g(e,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function oe(e={}){return[ne.of(e),K,J,te,ee]}function se(e,t){let i=e.field(S,false);if(i&&i.diagnostics.size){let e=[],n=[],o=-1;for(let s=p.iter([i.diagnostics]);;s.next()){for(let i=0;i<e.length;i++)if(!s.value||s.value.spec.diagnostics.indexOf(e[i])<0){t(e[i],n[i],o);e.splice(i,1);n.splice(i--,1)}if(!s.value)break;for(let t of s.value.spec.diagnostics)if(e.indexOf(t)<0){e.push(t);n.push(s.from)}o=s.to}}}export{A as closeLintPanel,T as diagnosticCount,se as forEachDiagnostic,N as forceLinting,oe as lintGutter,O as lintKeymap,H as linter,D as nextDiagnostic,M as openLintPanel,B as previousDiagnostic,x as setDiagnostics,y as setDiagnosticsEffect};+diff --git a/admin/vendor/javascript/@codemirror--search.js b/admin/vendor/javascript/@codemirror--search.jsnew file mode 100644index 0000000000..f7ffae4779--- /dev/null+++ b/admin/vendor/javascript/@codemirror--search.js@@ -0,0 +1,4 @@+// @codemirror/[email protected] downloaded from https://ga.jspm.io/npm:@codemirror/[email protected]/dist/index.js++import{EditorView as e,showPanel as t,getPanel as r,ViewPlugin as i,Decoration as n,runScopeHandlers as s}from"@codemirror/view";import{codePointAt as o,fromCodePoint as l,codePointSize as a,StateEffect as c,EditorSelection as h,StateField as u,Facet as f,combineConfig as d,CharCategory as m,Prec as p,EditorState as g,findClusterBreak as v,RangeSetBuilder as x}from"@codemirror/state";import y from"crelt";const b=typeof String.prototype.normalize=="function"?e=>e.normalize("NFKD"):e=>e;class SearchCursor{constructor(e,t,r=0,i=e.length,n,s){this.test=s;this.value={from:0,to:0};this.done=false;this.matches=[];this.buffer="";this.bufferPos=0;this.iter=e.iterRange(r,i);this.bufferStart=r;this.normalize=n?e=>n(b(e)):b;this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){this.bufferStart+=this.buffer.length;this.iter.next();if(this.iter.done)return-1;this.bufferPos=0;this.buffer=this.iter.value}return o(this.buffer,this.bufferPos)}next(){while(this.matches.length)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0){this.done=true;return this}let t=l(e),r=this.bufferStart+this.bufferPos;this.bufferPos+=a(e);let i=this.normalize(t);if(i.length)for(let e=0,n=r;;e++){let s=i.charCodeAt(e);let o=this.match(s,n,this.bufferPos+this.bufferStart);if(e==i.length-1){if(o){this.value=o;return this}break}n==r&&e<t.length&&t.charCodeAt(e)==s&&n++}}}match(e,t,r){let i=null;for(let t=0;t<this.matches.length;t+=2){let n=this.matches[t],s=false;if(this.query.charCodeAt(n)==e)if(n==this.query.length-1)i={from:this.matches[t+1],to:r};else{this.matches[t]++;s=true}if(!s){this.matches.splice(t,2);t-=2}}this.query.charCodeAt(0)==e&&(this.query.length==1?i={from:t,to:r}:this.matches.push(1,t));i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null);return i}}typeof Symbol!="undefined"&&(SearchCursor.prototype[Symbol.iterator]=function(){return this});const w={from:-1,to:-1,match:/.*/.exec("")};const S="gm"+(/x/.unicode==null?"":"u");class RegExpCursor{constructor(e,t,r,i=0,n=e.length){this.text=e;this.to=n;this.curLine="";this.done=false;this.value=w;if(/\\[sWDnr]|\n|\r|\[\^/.test(t))return new MultilineRegExpCursor(e,t,r,i,n);this.re=new RegExp(t,S+((r===null||r===void 0?void 0:r.ignoreCase)?"i":""));this.test=r===null||r===void 0?void 0:r.test;this.iter=e.iter();let s=e.lineAt(i);this.curLineStart=s.from;this.matchPos=C(e,i);this.getLine(this.curLineStart)}getLine(e){this.iter.next(e);if(this.iter.lineBreak)this.curLine="";else{this.curLine=this.iter.value;this.curLineStart+this.curLine.length>this.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 r=this.curLineStart+t.index,i=r+t[0].length;this.matchPos=C(this.text,i+(r==i?1:0));r==this.curLineStart+this.curLine.length&&this.nextLine();if((r<i||r>this.value.to)&&(!this.test||this.test(r,i,t))){this.value={from:r,to:i,match:t};return this}e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to)){this.done=true;return this}this.nextLine();e=0}}}}const M=new WeakMap;class FlattenedDoc{constructor(e,t){this.from=e;this.text=t}get to(){return this.from+this.text.length}static get(e,t,r){let i=M.get(e);if(!i||i.from>=r||i.to<=t){let i=new FlattenedDoc(t,e.sliceString(t,r));M.set(e,i);return i}if(i.from==t&&i.to==r)return i;let{text:n,from:s}=i;if(s>t){n=e.sliceString(t,s)+n;s=t}i.to<r&&(n+=e.sliceString(i.to,r));M.set(e,new FlattenedDoc(s,n));return new FlattenedDoc(t,n.slice(t-s,r-s))}}class MultilineRegExpCursor{constructor(e,t,r,i,n){this.text=e;this.to=n;this.done=false;this.value=w;this.matchPos=C(e,i);this.re=new RegExp(t,S+((r===null||r===void 0?void 0:r.ignoreCase)?"i":""));this.test=r===null||r===void 0?void 0:r.test;this.flat=FlattenedDoc.get(e,i,this.chunkEnd(i+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from;let 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)}if(t){let e=this.flat.from+t.index,r=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,r,t))){this.value={from:e,to:r,match:t};this.matchPos=C(this.text,r+(e==r?1:0));return this}}if(this.flat.to==this.to){this.done=true;return this}this.flat=FlattenedDoc.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol!="undefined"&&(RegExpCursor.prototype[Symbol.iterator]=MultilineRegExpCursor.prototype[Symbol.iterator]=function(){return this});function k(e){try{new RegExp(e,S);return true}catch(e){return false}}function C(e,t){if(t>=e.length)return t;let r,i=e.lineAt(t);while(t<i.to&&(r=i.text.charCodeAt(t-i.from))>=56320&&r<57344)t++;return t}function q(t){let r=String(t.state.doc.lineAt(t.state.selection.main.head).number);let i=y("input",{class:"cm-textfield",name:"line",value:r});let n=y("form",{class:"cm-gotoLine",onkeydown:e=>{if(e.keyCode==27){e.preventDefault();t.dispatch({effects:L.of(false)});t.focus()}else if(e.keyCode==13){e.preventDefault();s()}},onsubmit:e=>{e.preventDefault();s()}},y("label",t.state.phrase("Go to line"),": ",i)," ",y("button",{class:"cm-button",type:"submit"},t.state.phrase("go")),y("button",{name:"close",onclick:()=>{t.dispatch({effects:L.of(false)});t.focus()},"aria-label":t.state.phrase("close"),type:"button"},["×"]));function s(){let r=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(i.value);if(!r)return;let{state:n}=t,s=n.doc.lineAt(n.selection.main.head);let[,o,l,a,c]=r;let u=a?+a.slice(1):0;let f=l?+l:s.number;if(l&&c){let e=f/100;o&&(e=e*(o=="-"?-1:1)+s.number/n.doc.lines);f=Math.round(n.doc.lines*e)}else l&&o&&(f=f*(o=="-"?-1:1)+s.number);let d=n.doc.line(Math.max(1,Math.min(n.doc.lines,f)));let m=h.cursor(d.from+Math.max(0,Math.min(u,d.length)));t.dispatch({effects:[L.of(false),e.scrollIntoView(m.from,{y:"center"})],selection:m});t.focus()}return{dom:n}}const L=c.define();const F=u.define({create(){return true},update(e,t){for(let r of t.effects)r.is(L)&&(e=r.value);return e},provide:e=>t.from(e,(e=>e?q:null))});const D=e=>{let t=r(e,q);if(!t){let i=[L.of(true)];e.state.field(F,false)==null&&i.push(c.appendConfig.of([F,W]));e.dispatch({effects:i});t=r(e,q)}t&&t.dom.querySelector("input").select();return true};const W=e.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}});const R={highlightWordAroundCursor:false,minSelectionLength:1,maxMatches:100,wholeWords:false};const A=f.define({combine(e){return d(e,R,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function E(e){let t=[$,T];e&&t.push(A.of(e));return t}const P=n.mark({class:"cm-selectionMatch"});const I=n.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Q(e,t,r,i){return(r==0||e(t.sliceDoc(r-1,r))!=m.Word)&&(i==t.doc.length||e(t.sliceDoc(i,i+1))!=m.Word)}function z(e,t,r,i){return e(t.sliceDoc(r,r+1))==m.Word&&e(t.sliceDoc(i-1,i))==m.Word}const T=i.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(A);let{state:r}=e,i=r.selection;if(i.ranges.length>1)return n.none;let s,o=i.main,l=null;if(o.empty){if(!t.highlightWordAroundCursor)return n.none;let e=r.wordAt(o.head);if(!e)return n.none;l=r.charCategorizer(o.head);s=r.sliceDoc(e.from,e.to)}else{let e=o.to-o.from;if(e<t.minSelectionLength||e>200)return n.none;if(t.wholeWords){s=r.sliceDoc(o.from,o.to);l=r.charCategorizer(o.head);if(!(Q(l,r,o.from,o.to)&&z(l,r,o.from,o.to)))return n.none}else{s=r.sliceDoc(o.from,o.to);if(!s)return n.none}}let a=[];for(let i of e.visibleRanges){let e=new SearchCursor(r.doc,s,i.from,i.to);while(!e.next().done){let{from:i,to:s}=e.value;if(!l||Q(l,r,i,s)){o.empty&&i<=o.from&&s>=o.to?a.push(I.range(i,s)):(i>=o.to||s<=o.from)&&a.push(P.range(i,s));if(a.length>t.maxMatches)return n.none}}}return n.set(a)}},{decorations:e=>e.decorations});const $=e.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const O=({state:e,dispatch:t})=>{let{selection:r}=e;let i=h.create(r.ranges.map((t=>e.wordAt(t.head)||h.cursor(t.head))),r.mainIndex);if(i.eq(r))return false;t(e.update({selection:i}));return true};function V(e,t){let{main:r,ranges:i}=e.selection;let n=e.wordAt(r.head),s=n&&n.from==r.from&&n.to==r.to;for(let r=false,n=new SearchCursor(e.doc,t,i[i.length-1].to);;){n.next();if(!n.done){if(r&&i.some((e=>e.from==n.value.from)))continue;if(s){let t=e.wordAt(n.value.from);if(!t||t.from!=n.value.from||t.to!=n.value.to)continue}return n.value}if(r)return null;n=new SearchCursor(e.doc,t,0,Math.max(0,i[i.length-1].from-1));r=true}}const K=({state:t,dispatch:r})=>{let{ranges:i}=t.selection;if(i.some((e=>e.from===e.to)))return O({state:t,dispatch:r});let n=t.sliceDoc(i[0].from,i[0].to);if(t.selection.ranges.some((e=>t.sliceDoc(e.from,e.to)!=n)))return false;let s=V(t,n);if(!s)return false;r(t.update({selection:t.selection.addRange(h.range(s.from,s.to),false),effects:e.scrollIntoView(s.to)}));return true};const B=f.define({combine(t){return d(t,{top:false,caseSensitive:false,literal:false,regexp:false,wholeWord:false,createPanel:e=>new SearchPanel(e),scrollToMatch:t=>e.scrollIntoView(t)})}});function G(e){return e?[B.of(e),ke]:ke}class SearchQuery{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||k(this.search));this.unquoted=this.unquote(this.search);this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,((e,t)=>t=="n"?"\n":t=="r"?"\r":t=="t"?"\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 RegExpQuery(this):new StringQuery(this)}getCursor(e,t=0,r){let i=e.doc?e:g.create({doc:e});r==null&&(r=i.doc.length);return this.regexp?H(this,i,t,r):N(this,i,t,r)}}class QueryType{constructor(e){this.spec=e}}function N(e,t,r,i){return new SearchCursor(t.doc,e.unquoted,r,i,e.caseSensitive?void 0:e=>e.toLowerCase(),e.wholeWord?j(t.doc,t.charCategorizer(t.selection.main.head)):void 0)}function j(e,t){return(r,i,n,s)=>{if(s>r||s+n.length<i){s=Math.max(0,r-2);n=e.sliceString(s,Math.min(e.length,i+2))}return(t(J(n,r-s))!=m.Word||t(U(n,r-s))!=m.Word)&&(t(U(n,i-s))!=m.Word||t(J(n,i-s))!=m.Word)}}class StringQuery extends QueryType{constructor(e){super(e)}nextMatch(e,t,r){let i=N(this.spec,e,r,e.doc.length).nextOverlapping();if(i.done){let r=Math.min(e.doc.length,t+this.spec.unquoted.length);i=N(this.spec,e,0,r).nextOverlapping()}return i.done||i.value.from==t&&i.value.to==r?null:i.value}prevMatchInRange(e,t,r){for(let i=r;;){let r=Math.max(t,i-1e4-this.spec.unquoted.length);let n=N(this.spec,e,r,i),s=null;while(!n.nextOverlapping().done)s=n.value;if(s)return s;if(r==t)return null;i-=1e4}}prevMatch(e,t,r){let i=this.prevMatchInRange(e,0,t);i||(i=this.prevMatchInRange(e,Math.max(0,r-this.spec.unquoted.length),e.doc.length));return!i||i.from==t&&i.to==r?null:i}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let r=N(this.spec,e,0,e.doc.length),i=[];while(!r.next().done){if(i.length>=t)return null;i.push(r.value)}return i}highlight(e,t,r,i){let n=N(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,e.doc.length));while(!n.next().done)i(n.value.from,n.value.to)}}function H(e,t,r,i){return new RegExpCursor(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:e.wholeWord?X(t.charCategorizer(t.selection.main.head)):void 0},r,i)}function J(e,t){return e.slice(v(e,t,false),t)}function U(e,t){return e.slice(t,v(e,t))}function X(e){return(t,r,i)=>!i[0].length||(e(J(i.input,i.index))!=m.Word||e(U(i.input,i.index))!=m.Word)&&(e(U(i.input,i.index+i[0].length))!=m.Word||e(J(i.input,i.index+i[0].length))!=m.Word)}class RegExpQuery extends QueryType{nextMatch(e,t,r){let i=H(this.spec,e,r,e.doc.length).next();i.done&&(i=H(this.spec,e,0,t).next());return i.done?null:i.value}prevMatchInRange(e,t,r){for(let i=1;;i++){let n=Math.max(t,r-i*1e4);let s=H(this.spec,e,n,r),o=null;while(!s.next().done)o=s.value;if(o&&(n==t||o.from>n+10))return o;if(n==t)return null}}prevMatch(e,t,r){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,r,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,((t,r)=>{if(r=="&")return e.match[0];if(r=="$")return"$";for(let t=r.length;t>0;t--){let i=+r.slice(0,t);if(i>0&&i<e.match.length)return e.match[i]+r.slice(t)}return t}))}matchAll(e,t){let r=H(this.spec,e,0,e.doc.length),i=[];while(!r.next().done){if(i.length>=t)return null;i.push(r.value)}return i}highlight(e,t,r,i){let n=H(this.spec,e,Math.max(0,t-250),Math.min(r+250,e.doc.length));while(!n.next().done)i(n.value.from,n.value.to)}}const Y=c.define();const Z=c.define();const _=u.define({create(e){return new SearchState(de(e).create(),null)},update(e,t){for(let r of t.effects)r.is(Y)?e=new SearchState(r.value.create(),e.panel):r.is(Z)&&(e=new SearchState(e.query,r.value?fe:null));return e},provide:e=>t.from(e,(e=>e.panel))});function ee(e){let t=e.field(_,false);return t?t.query.spec:de(e)}function te(e){var t;return((t=e.field(_,false))===null||t===void 0?void 0:t.panel)!=null}class SearchState{constructor(e,t){this.query=e;this.panel=t}}const re=n.mark({class:"cm-searchMatch"}),ie=n.mark({class:"cm-searchMatch cm-searchMatch-selected"});const ne=i.fromClass(class{constructor(e){this.view=e;this.decorations=this.highlight(e.state.field(_))}update(e){let t=e.state.field(_);(t!=e.startState.field(_)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return n.none;let{view:r}=this;let i=new x;for(let t=0,n=r.visibleRanges,s=n.length;t<s;t++){let{from:o,to:l}=n[t];while(t<s-1&&l>n[t+1].from-500)l=n[++t].to;e.highlight(r.state,o,l,((e,t)=>{let n=r.state.selection.ranges.some((r=>r.from==e&&r.to==t));i.add(e,t,n?ie:re)}))}return i.finish()}},{decorations:e=>e.decorations});function se(e){return t=>{let r=t.state.field(_,false);return r&&r.query.spec.valid?e(t,r):ge(t)}}const oe=se(((e,{query:t})=>{let{to:r}=e.state.selection.main;let i=t.nextMatch(e.state,r,r);if(!i)return false;let n=h.single(i.from,i.to);let s=e.state.facet(B);e.dispatch({selection:n,effects:[Se(e,i),s.scrollToMatch(n.main,e)],userEvent:"select.search"});pe(e);return true}));const le=se(((e,{query:t})=>{let{state:r}=e,{from:i}=r.selection.main;let n=t.prevMatch(r,i,i);if(!n)return false;let s=h.single(n.from,n.to);let o=e.state.facet(B);e.dispatch({selection:s,effects:[Se(e,n),o.scrollToMatch(s.main,e)],userEvent:"select.search"});pe(e);return true}));const ae=se(((e,{query:t})=>{let r=t.matchAll(e.state,1e3);if(!r||!r.length)return false;e.dispatch({selection:h.create(r.map((e=>h.range(e.from,e.to)))),userEvent:"select.search.matches"});return true}));const ce=({state:e,dispatch:t})=>{let r=e.selection;if(r.ranges.length>1||r.main.empty)return false;let{from:i,to:n}=r.main;let s=[],o=0;for(let t=new SearchCursor(e.doc,e.sliceDoc(i,n));!t.next().done;){if(s.length>1e3)return false;t.value.from==i&&(o=s.length);s.push(h.range(t.value.from,t.value.to))}t(e.update({selection:h.create(s,o),userEvent:"select.search.matches"}));return true};const he=se(((t,{query:r})=>{let{state:i}=t,{from:n,to:s}=i.selection.main;if(i.readOnly)return false;let o=r.nextMatch(i,n,n);if(!o)return false;let l=o;let a,c,u=[];let f=[];if(l.from==n&&l.to==s){c=i.toText(r.getReplacement(l));u.push({from:l.from,to:l.to,insert:c});l=r.nextMatch(i,l.from,l.to);f.push(e.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(n).number)+"."))}let d=t.state.changes(u);if(l){a=h.single(l.from,l.to).map(d);f.push(Se(t,l));f.push(i.facet(B).scrollToMatch(a.main,t))}t.dispatch({changes:d,selection:a,effects:f,userEvent:"input.replace"});return true}));const ue=se(((t,{query:r})=>{if(t.state.readOnly)return false;let i=r.matchAll(t.state,1e9).map((e=>{let{from:t,to:i}=e;return{from:t,to:i,insert:r.getReplacement(e)}}));if(!i.length)return false;let n=t.state.phrase("replaced $ matches",i.length)+".";t.dispatch({changes:i,effects:e.announce.of(n),userEvent:"input.replace.all"});return true}));function fe(e){return e.state.facet(B).createPanel(e)}function de(e,t){var r,i,n,s,o;let l=e.selection.main;let a=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!a)return t;let c=e.facet(B);return new SearchQuery({search:((r=t===null||t===void 0?void 0:t.literal)!==null&&r!==void 0?r:c.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=t===null||t===void 0?void 0:t.caseSensitive)!==null&&i!==void 0?i:c.caseSensitive,literal:(n=t===null||t===void 0?void 0:t.literal)!==null&&n!==void 0?n:c.literal,regexp:(s=t===null||t===void 0?void 0:t.regexp)!==null&&s!==void 0?s:c.regexp,wholeWord:(o=t===null||t===void 0?void 0:t.wholeWord)!==null&&o!==void 0?o:c.wholeWord})}function me(e){let t=r(e,fe);return t&&t.dom.querySelector("[main-field]")}function pe(e){let t=me(e);t&&t==e.root.activeElement&&t.select()}const ge=e=>{let t=e.state.field(_,false);if(t&&t.panel){let r=me(e);if(r&&r!=e.root.activeElement){let i=de(e.state,t.query.spec);i.valid&&e.dispatch({effects:Y.of(i)});r.focus();r.select()}}else e.dispatch({effects:[Z.of(true),t?Y.of(de(e.state,t.query.spec)):c.appendConfig.of(ke)]});return true};const ve=e=>{let t=e.state.field(_,false);if(!t||!t.panel)return false;let i=r(e,fe);i&&i.dom.contains(e.root.activeElement)&&e.focus();e.dispatch({effects:Z.of(false)});return true};const xe=[{key:"Mod-f",run:ge,scope:"editor search-panel"},{key:"F3",run:oe,shift:le,scope:"editor search-panel",preventDefault:true},{key:"Mod-g",run:oe,shift:le,scope:"editor search-panel",preventDefault:true},{key:"Escape",run:ve,scope:"editor search-panel"},{key:"Mod-Shift-l",run:ce},{key:"Mod-Alt-g",run:D},{key:"Mod-d",run:K,preventDefault:true}];class SearchPanel{constructor(e){this.view=e;let t=this.query=e.state.field(_).query.spec;this.commit=this.commit.bind(this);this.searchField=y("input",{value:t.search,placeholder:ye(e,"Find"),"aria-label":ye(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit});this.replaceField=y("input",{value:t.replace,placeholder:ye(e,"Replace"),"aria-label":ye(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit});this.caseField=y("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit});this.reField=y("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit});this.wordField=y("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function r(e,t,r){return y("button",{class:"cm-button",name:e,onclick:t,type:"button"},r)}this.dom=y("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,r("next",(()=>oe(e)),[ye(e,"next")]),r("prev",(()=>le(e)),[ye(e,"previous")]),r("select",(()=>ae(e)),[ye(e,"all")]),y("label",null,[this.caseField,ye(e,"match case")]),y("label",null,[this.reField,ye(e,"regexp")]),y("label",null,[this.wordField,ye(e,"by word")]),...e.state.readOnly?[]:[y("br"),this.replaceField,r("replace",(()=>he(e)),[ye(e,"replace")]),r("replaceAll",(()=>ue(e)),[ye(e,"replace all")])],y("button",{name:"close",onclick:()=>ve(e),"aria-label":ye(e,"close"),type:"button"},["×"])])}commit(){let e=new SearchQuery({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});if(!e.eq(this.query)){this.query=e;this.view.dispatch({effects:Y.of(e)})}}keydown(e){if(s(this.view,e,"search-panel"))e.preventDefault();else if(e.keyCode==13&&e.target==this.searchField){e.preventDefault();(e.shiftKey?le:oe)(this.view)}else if(e.keyCode==13&&e.target==this.replaceField){e.preventDefault();he(this.view)}}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(Y)&&!e.value.eq(this.query)&&this.setQuery(e.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(B).top}}function ye(e,t){return e.state.phrase(t)}const be=30;const we=/[\s\.,:;?!]/;function Se(t,{from:r,to:i}){let n=t.state.doc.lineAt(r),s=t.state.doc.lineAt(i).to;let o=Math.max(n.from,r-be),l=Math.min(s,i+be);let a=t.state.sliceDoc(o,l);if(o!=n.from)for(let e=0;e<be;e++)if(!we.test(a[e+1])&&we.test(a[e])){a=a.slice(e);break}if(l!=s)for(let e=a.length-1;e>a.length-be;e--)if(!we.test(a[e-1])&&we.test(a[e])){a=a.slice(0,e);break}return e.announce.of(`${t.state.phrase("current match")}. ${a} ${t.state.phrase("on line")} ${n.number}.`)}const Me=e.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"}});const ke=[_,p.low(ne),Me];export{RegExpCursor,SearchCursor,SearchQuery,ve as closeSearchPanel,oe as findNext,le as findPrevious,ee as getSearchQuery,D as gotoLine,E as highlightSelectionMatches,ge as openSearchPanel,ue as replaceAll,he as replaceNext,G as search,xe as searchKeymap,te as searchPanelOpen,ae as selectMatches,K as selectNextOccurrence,ce as selectSelectionMatches,Y as setSearchQuery};+diff --git a/admin/vendor/javascript/@codemirror--state.js b/admin/vendor/javascript/@codemirror--state.jsnew file mode 100644index 0000000000..35730160fc--- /dev/null+++ b/admin/vendor/javascript/@codemirror--state.js@@ -0,0 +1,4 @@+// @codemirror/[email protected] downloaded from https://ga.jspm.io/npm:@codemirror/[email protected]/dist/index.js++import{findClusterBreak as e}from"@marijn/find-cluster-break";class Text{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,false,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,true,1,0)}replace(e,t,n){[e,t]=clip(this,e,t);let i=[];this.decompose(0,e,i,2);n.length&&n.decompose(0,n.length,i,3);this.decompose(t,this.length,i,1);return TextNode.from(i,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=clip(this,e,t);let n=[];this.decompose(e,t,n,0);return TextNode.from(n,t-e)}eq(e){if(e==this)return true;if(e.length!=this.length||e.lines!=this.lines)return false;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1);let i=new RawTextCursor(this),s=new RawTextCursor(e);for(let e=t,r=t;;){i.next(e);s.next(e);e=0;if(i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return false;r+=i.value.length;if(i.done||r>=n)return true}}iter(e=1){return new RawTextCursor(this,e)}iterRange(e,t=this.length){return new PartialTextCursor(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let i=this.line(e).from;n=this.iterRange(i,Math.max(i,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new LineCursor(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];this.flatten(e);return 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]?e.length<=32?new TextLeaf(e):TextNode.from(TextLeaf.split(e,[])):Text.empty}}class TextLeaf extends Text{constructor(e,t=textLength(e)){super();this.text=e;this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,i){for(let s=0;;s++){let r=this.text[s],a=i+r.length;if((t?n:a)>=e)return new Line(i,a,n,r);i=a+1;n++}}decompose(e,t,n,i){let s=e<=0&&t>=this.length?this:new TextLeaf(sliceText(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(i&1){let e=n.pop();let t=appendText(s.text,e.text.slice(),0,s.length);if(t.length<=32)n.push(new TextLeaf(t,e.length+s.length));else{let e=t.length>>1;n.push(new TextLeaf(t.slice(0,e)),new TextLeaf(t.slice(e)))}}else n.push(s)}replace(e,t,n){if(!(n instanceof TextLeaf))return super.replace(e,t,n);[e,t]=clip(this,e,t);let i=appendText(this.text,appendText(n.text,sliceText(this.text,0,e)),t);let s=this.length+n.length-(t-e);return i.length<=32?new TextLeaf(i,s):TextNode.from(TextLeaf.split(i,[]),s)}sliceString(e,t=this.length,n="\n"){[e,t]=clip(this,e,t);let i="";for(let s=0,r=0;s<=t&&r<this.text.length;r++){let a=this.text[r],o=s+a.length;s>e&&r&&(i+=n);e<o&&t>s&&(i+=a.slice(Math.max(0,e-s),t-s));s=o+1}return i}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],i=-1;for(let s of e){n.push(s);i+=s.length+1;if(n.length==32){t.push(new TextLeaf(n,i));n=[];i=-1}}i>-1&&t.push(new TextLeaf(n,i));return t}}class TextNode extends Text{constructor(e,t){super();this.children=e;this.length=t;this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,i){for(let s=0;;s++){let r=this.children[s],a=i+r.length,o=n+r.lines-1;if((t?o:a)>=e)return r.lineInner(e,t,n,i);i=a+1;n=o+1}}decompose(e,t,n,i){for(let s=0,r=0;r<=t&&s<this.children.length;s++){let a=this.children[s],o=r+a.length;if(e<=o&&t>=r){let s=i&((r<=e?1:0)|(o>=t?2:0));r>=e&&o<=t&&!s?n.push(a):a.decompose(e-r,t-r,n,s)}r=o+1}}replace(e,t,n){[e,t]=clip(this,e,t);if(n.lines<this.lines)for(let i=0,s=0;i<this.children.length;i++){let r=this.children[i],a=s+r.length;if(e>=s&&t<=a){let o=r.replace(e-s,t-s,n);let l=this.lines-r.lines+o.lines;if(o.lines<l>>4&&o.lines>l>>6){let s=this.children.slice();s[i]=o;return new TextNode(s,this.length-(t-e)+n.length)}return super.replace(s,a,o)}s=a+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n="\n"){[e,t]=clip(this,e,t);let i="";for(let s=0,r=0;s<this.children.length&&r<=t;s++){let a=this.children[s],o=r+a.length;r>e&&s&&(i+=n);e<o&&t>r&&(i+=a.sliceString(e-r,t-r,n));r=o+1}return i}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof TextNode))return 0;let n=0;let[i,s,r,a]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=t,s+=t){if(i==r||s==a)return n;let o=this.children[i],l=e.children[s];if(o!=l)return n+o.scanIdentical(l,t);n+=o.length+1}}static from(e,t=e.reduce(((e,t)=>e+t.length+1),-1)){let n=0;for(let t of e)n+=t.lines;if(n<32){let n=[];for(let t of e)t.flatten(n);return new TextLeaf(n,t)}let i=Math.max(32,n>>5),s=i<<1,r=i>>1;let a=[],o=0,l=-1,h=[];function add(e){let t;if(e.lines>s&&e instanceof TextNode)for(let t of e.children)add(t);else if(e.lines>r&&(o>r||!o)){flush();a.push(e)}else if(e instanceof TextLeaf&&o&&(t=h[h.length-1])instanceof TextLeaf&&e.lines+t.lines<=32){o+=e.lines;l+=e.length+1;h[h.length-1]=new TextLeaf(t.text.concat(e.text),t.length+1+e.length)}else{o+e.lines>i&&flush();o+=e.lines;l+=e.length+1;h.push(e)}}function flush(){if(o!=0){a.push(h.length==1?h[0]:TextNode.from(h,l));l=-1;o=h.length=0}}for(let t of e)add(t);flush();return a.length==1?a[0]:new TextNode(a,t)}}Text.empty=new TextLeaf([""],0);function textLength(e){let t=-1;for(let n of e)t+=n.length+1;return t}function appendText(e,t,n=0,i=1e9){for(let s=0,r=0,a=true;r<e.length&&s<=i;r++){let o=e[r],l=s+o.length;if(l>=n){l>i&&(o=o.slice(0,i-s));s<n&&(o=o.slice(n-s));if(a){t[t.length-1]+=o;a=false}else t.push(o)}s=l+1}return t}function sliceText(e,t,n){return appendText(e,[""],t,n)}class RawTextCursor{constructor(e,t=1){this.dir=t;this.done=false;this.lineBreak=false;this.value="";this.nodes=[e];this.offsets=[t>0?1:(e instanceof TextLeaf?e.text.length:e.children.length)<<1]}nextInner(e,t){this.done=this.lineBreak=false;for(;;){let n=this.nodes.length-1;let i=this.nodes[n],s=this.offsets[n],r=s>>1;let a=i instanceof TextLeaf?i.text.length:i.children.length;if(r==(t>0?a:0)){if(n==0){this.done=true;this.value="";return this}t>0&&this.offsets[n-1]++;this.nodes.pop();this.offsets.pop()}else if((s&1)==(t>0?0:1)){this.offsets[n]+=t;if(e==0){this.lineBreak=true;this.value="\n";return this}e--}else if(i instanceof TextLeaf){let s=i.text[r+(t<0?-1:0)];this.offsets[n]+=t;if(s.length>Math.max(0,e)){this.value=e==0?s:t>0?s.slice(e):s.slice(0,s.length-e);return this}e-=s.length}else{let s=i.children[r+(t<0?-1:0)];if(e>s.length){e-=s.length;this.offsets[n]+=t}else{t<0&&this.offsets[n]--;this.nodes.push(s);this.offsets.push(t>0?1:(s instanceof TextLeaf?s.text.length:s.children.length)<<1)}}}}next(e=0){if(e<0){this.nextInner(-e,-this.dir);e=this.value.length}return this.nextInner(e,this.dir)}}class PartialTextCursor{constructor(e,t,n){this.value="";this.done=false;this.cursor=new RawTextCursor(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){this.value="";this.done=true;return 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:i}=this.cursor.next(e);this.pos+=(i.length+e)*t;this.value=i.length<=n?i:t<0?i.slice(i.length-n):i.slice(0,n);this.done=!this.value;return this}next(e=0){e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos));return this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class LineCursor{constructor(e){this.inner=e;this.afterBreak=true;this.value="";this.done=false}next(e=0){let{done:t,lineBreak:n,value:i}=this.inner.next(e);if(t&&this.afterBreak){this.value="";this.afterBreak=false}else if(t){this.done=true;this.value=""}else if(n)if(this.afterBreak)this.value="";else{this.afterBreak=true;this.next()}else{this.value=i;this.afterBreak=false}return this}get lineBreak(){return false}}if(typeof Symbol!="undefined"){Text.prototype[Symbol.iterator]=function(){return this.iter()};RawTextCursor.prototype[Symbol.iterator]=PartialTextCursor.prototype[Symbol.iterator]=LineCursor.prototype[Symbol.iterator]=function(){return this}}class Line{constructor(e,t,n,i){this.from=e;this.to=t;this.number=n;this.text=i}get length(){return this.to-this.from}}function clip(e,t,n){t=Math.max(0,Math.min(e.length,t));return[t,Math.max(t,Math.min(e.length,n))]}function findClusterBreak(t,n,i=true,s=true){return e(t,n,i,s)}function surrogateLow(e){return e>=56320&&e<57344}function surrogateHigh(e){return e>=55296&&e<56320}function codePointAt(e,t){let n=e.charCodeAt(t);if(!surrogateHigh(n)||t+1==e.length)return n;let i=e.charCodeAt(t+1);return surrogateLow(i)?i-56320+(n-55296<<10)+65536:n}function fromCodePoint(e){if(e<=65535)return String.fromCharCode(e);e-=65536;return String.fromCharCode(55296+(e>>10),56320+(e&1023))}function codePointSize(e){return e<65536?1:2}const t=/\r\n?|\n/;var n=function(e){e[e.Simple=0]="Simple";e[e.TrackDel=1]="TrackDel";e[e.TrackBefore=2]="TrackBefore";e[e.TrackAfter=3]="TrackAfter";return e}(n||(n={}));class ChangeDesc{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,i=0;t<this.sections.length;){let s=this.sections[t++],r=this.sections[t++];if(r<0){e(n,i,s);i+=s}else i+=r;n+=s}}iterChangedRanges(e,t=false){iterChanges(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],i=this.sections[t++];i<0?e.push(n,i):e.push(i,n)}return new ChangeDesc(e)}composeDesc(e){return this.empty?e:e.empty?this:composeSets(this,e)}mapDesc(e,t=false){return e.empty?this:mapSet(this,e,t)}mapPos(e,t=-1,i=n.Simple){let s=0,r=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],l=this.sections[a++],h=s+o;if(l<0){if(h>e)return r+(e-s);r+=o}else{if(i!=n.Simple&&h>=e&&(i==n.TrackDel&&s<e&&h>e||i==n.TrackBefore&&s<e||i==n.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!o)return e==s||t<0?r:r+l;r+=l}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return r}touchesRange(e,t=e){for(let n=0,i=0;n<this.sections.length&&i<=t;){let s=this.sections[n++],r=this.sections[n++],a=i+s;if(r>=0&&i<=t&&a>=e)return!(i<e&&a>t)||"cover";i=a}return false}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],i=this.sections[t++];e+=(e?" ":"")+n+(i>=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some((e=>typeof e!="number")))throw new RangeError("Invalid JSON representation of ChangeDesc");return new ChangeDesc(e)}static create(e){return new ChangeDesc(e)}}class ChangeSet extends ChangeDesc{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");iterChanges(this,((t,n,i,s,r)=>e=e.replace(i,i+(n-t),r)),false);return e}mapDesc(e,t=false){return mapSet(this,e,t,true)}invert(e){let t=this.sections.slice(),n=[];for(let i=0,s=0;i<t.length;i+=2){let r=t[i],a=t[i+1];if(a>=0){t[i]=a;t[i+1]=r;let o=i>>1;while(n.length<o)n.push(Text.empty);n.push(r?e.slice(s,s+r):Text.empty)}s+=r}return new ChangeSet(t,n)}compose(e){return this.empty?e:e.empty?this:composeSets(this,e,true)}map(e,t=false){return e.empty?this:mapSet(this,e,t,true)}iterChanges(e,t=false){iterChanges(this,e,t)}get desc(){return ChangeDesc.create(this.sections)}filter(e){let t=[],n=[],i=[];let s=new SectionIter(this);e:for(let r=0,a=0;;){let o=r==e.length?1e9:e[r++];while(a<o||a==o&&s.len==0){if(s.done)break e;let e=Math.min(s.len,o-a);addSection(i,e,-1);let r=s.ins==-1?-1:s.off==0?s.ins:0;addSection(t,e,r);r>0&&addInsert(n,t,s.text);s.forward(e);a+=e}let l=e[r++];while(a<l){if(s.done)break e;let e=Math.min(s.len,l-a);addSection(t,e,-1);addSection(i,e,s.ins==-1?-1:s.off==0?s.ins:0);s.forward(e);a+=e}}return{changes:new ChangeSet(t,n),filtered:ChangeDesc.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],i=this.sections[t+1];i<0?e.push(n):i==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,n,i){let s=[],r=[],a=0;let o=null;function flush(e=false){if(!e&&!s.length)return;a<n&&addSection(s,n-a,-1);let t=new ChangeSet(s,r);o=o?o.compose(t.map(o)):t;s=[];r=[];a=0}function process(e){if(Array.isArray(e))for(let t of e)process(t);else if(e instanceof ChangeSet){if(e.length!=n)throw new RangeError(`Mismatched change set length (got ${e.length}, expected ${n})`);flush();o=o?o.compose(e.map(o)):e}else{let{from:o,to:l=o,insert:h}=e;if(o>l||o<0||l>n)throw new RangeError(`Invalid change range ${o} to ${l} (in doc of length ${n})`);let c=h?typeof h=="string"?Text.of(h.split(i||t)):h:Text.empty;let f=c.length;if(o==l&&f==0)return;o<a&&flush();o>a&&addSection(s,o-a,-1);addSection(s,l-o,f);addInsert(r,s,c);a=l}}process(e);flush(!o);return o}static empty(e){return new ChangeSet(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let i=0;i<e.length;i++){let s=e[i];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some(((e,t)=>t&&typeof e!="string")))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{while(n.length<i)n.push(Text.empty);n[i]=Text.of(s.slice(1));t.push(s[0],n[i].length)}}}return new ChangeSet(t,n)}static createSet(e,t){return new ChangeSet(e,t)}}function addSection(e,t,n,i=false){if(t==0&&n<=0)return;let s=e.length-2;if(s>=0&&n<=0&&n==e[s+1])e[s]+=t;else if(s>=0&&t==0&&e[s]==0)e[s+1]+=n;else if(i){e[s]+=t;e[s+1]+=n}else e.push(t,n)}function addInsert(e,t,n){if(n.length==0)return;let i=t.length-2>>1;if(i<e.length)e[e.length-1]=e[e.length-1].append(n);else{while(e.length<i)e.push(Text.empty);e.push(n)}}function iterChanges(e,t,n){let i=e.inserted;for(let s=0,r=0,a=0;a<e.sections.length;){let o=e.sections[a++],l=e.sections[a++];if(l<0){s+=o;r+=o}else{let h=s,c=r,f=Text.empty;for(;;){h+=o;c+=l;l&&i&&(f=f.append(i[a-2>>1]));if(n||a==e.sections.length||e.sections[a+1]<0)break;o=e.sections[a++];l=e.sections[a++]}t(s,h,r,c,f);s=h;r=c}}}function mapSet(e,t,n,i=false){let s=[],r=i?[]:null;let a=new SectionIter(e),o=new SectionIter(t);for(let e=-1;;){if(a.done&&o.len||o.done&&a.len)throw new Error("Mismatched change set lengths");if(a.ins==-1&&o.ins==-1){let e=Math.min(a.len,o.len);addSection(s,e,-1);a.forward(e);o.forward(e)}else if(o.ins>=0&&(a.ins<0||e==a.i||a.off==0&&(o.len<a.len||o.len==a.len&&!n))){let t=o.len;addSection(s,o.ins,-1);while(t){let n=Math.min(a.len,t);if(a.ins>=0&&e<a.i&&a.len<=n){addSection(s,0,a.ins);r&&addInsert(r,s,a.text);e=a.i}a.forward(n);t-=n}o.next()}else{if(!(a.ins>=0)){if(a.done&&o.done)return r?ChangeSet.createSet(s,r):ChangeDesc.create(s);throw new Error("Mismatched change set lengths")}{let t=0,n=a.len;while(n)if(o.ins==-1){let e=Math.min(n,o.len);t+=e;n-=e;o.forward(e)}else{if(!(o.ins==0&&o.len<n))break;n-=o.len;o.next()}addSection(s,t,e<a.i?a.ins:0);r&&e<a.i&&addInsert(r,s,a.text);e=a.i;a.forward(a.len-n)}}}}function composeSets(e,t,n=false){let i=[];let s=n?[]:null;let r=new SectionIter(e),a=new SectionIter(t);for(let e=false;;){if(r.done&&a.done)return s?ChangeSet.createSet(i,s):ChangeDesc.create(i);if(r.ins==0){addSection(i,r.len,0,e);r.next()}else if(a.len!=0||a.done){if(r.done||a.done)throw new Error("Mismatched change set lengths");{let t=Math.min(r.len2,a.len),n=i.length;if(r.ins==-1){let n=a.ins==-1?-1:a.off?0:a.ins;addSection(i,t,n,e);s&&n&&addInsert(s,i,a.text)}else if(a.ins==-1){addSection(i,r.off?0:r.len,t,e);s&&addInsert(s,i,r.textBit(t))}else{addSection(i,r.off?0:r.len,a.off?0:a.ins,e);s&&!a.off&&addInsert(s,i,a.text)}e=(r.ins>t||a.ins>=0&&a.len>t)&&(e||i.length>n);r.forward2(t);a.forward(t)}}else{addSection(i,0,a.ins,e);s&&addInsert(s,i,a.text);a.next()}}}class SectionIter{constructor(e){this.set=e;this.i=0;this.next()}next(){let{sections:e}=this.set;if(this.i<e.length){this.len=e[this.i++];this.ins=e[this.i++]}else{this.len=0;this.ins=-2}this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?Text.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?Text.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){if(e==this.len)this.next();else{this.len-=e;this.off+=e}}forward2(e){if(this.ins==-1)this.forward(e);else if(e==this.ins)this.next();else{this.ins-=e;this.off+=e}}}class SelectionRange{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,i;if(this.empty)n=i=e.mapPos(this.from,t);else{n=e.mapPos(this.from,1);i=e.mapPos(this.to,-1)}return n==this.from&&i==this.to?this:new SelectionRange(n,i,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return EditorSelection.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return EditorSelection.range(this.anchor,n)}eq(e,t=false){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 EditorSelection.range(e.anchor,e.head)}static create(e,t,n){return new SelectionRange(e,t,n)}}class EditorSelection{constructor(e,t){this.ranges=e;this.mainIndex=t}map(e,t=-1){return e.empty?this:EditorSelection.create(this.ranges.map((n=>n.map(e,t))),this.mainIndex)}eq(e,t=false){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return false;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return false;return true}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new EditorSelection([this.main],0)}addRange(e,t=true){return EditorSelection.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();n[t]=e;return EditorSelection.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map((e=>e.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 EditorSelection(e.ranges.map((e=>SelectionRange.fromJSON(e))),e.main)}static single(e,t=e){return new EditorSelection([EditorSelection.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,i=0;i<e.length;i++){let s=e[i];if(s.empty?s.from<=n:s.from<n)return EditorSelection.normalized(e.slice(),t);n=s.to}return new EditorSelection(e,t)}static cursor(e,t=0,n,i){return SelectionRange.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(i!==null&&i!==void 0?i:16777215)<<6)}static range(e,t,n,i){let s=(n!==null&&n!==void 0?n:16777215)<<6|(i==null?7:Math.min(6,i));return t<e?SelectionRange.create(t,e,48|s):SelectionRange.create(e,t,(t>e?8:0)|s)}static normalized(e,t=0){let n=e[t];e.sort(((e,t)=>e.from-t.from));t=e.indexOf(n);for(let n=1;n<e.length;n++){let i=e[n],s=e[n-1];if(i.empty?i.from<=s.to:i.from<s.to){let r=s.from,a=Math.max(i.to,s.to);n<=t&&t--;e.splice(--n,2,i.anchor>i.head?EditorSelection.range(a,r):EditorSelection.range(r,a))}}return new EditorSelection(e,t)}}function checkSelection(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let i=0;class Facet{constructor(e,t,n,s,r){this.combine=e;this.compareInput=t;this.compare=n;this.isStatic=s;this.id=i++;this.default=e([]);this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new Facet(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:sameArray),!!e.static,e.enables)}of(e){return new FacetProvider([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new FacetProvider(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new FacetProvider(e,this,2,t)}from(e,t){t||(t=e=>e);return this.compute([e],(n=>t(n.field(e))))}}function sameArray(e,t){return e==t||e.length==t.length&&e.every(((e,n)=>e===t[n]))}class FacetProvider{constructor(e,t,n,s){this.dependencies=e;this.facet=t;this.type=n;this.value=s;this.id=i++}dynamicSlot(e){var t;let n=this.value;let i=this.facet.compareInput;let s=this.id,r=e[s]>>1,a=this.type==2;let o=false,l=false,h=[];for(let n of this.dependencies)n=="doc"?o=true:n=="selection"?l=true:(((t=e[n.id])!==null&&t!==void 0?t:1)&1)==0&&h.push(e[n.id]);return{create(e){e.values[r]=n(e);return 1},update(e,t){if(o&&t.docChanged||l&&(t.docChanged||t.selection)||ensureAll(e,h)){let t=n(e);if(a?!compareArray(t,e.values[r],i):!i(t,e.values[r])){e.values[r]=t;return 1}}return 0},reconfigure:(e,t)=>{let o,l=t.config.address[s];if(l!=null){let s=getAddr(t,l);if(this.dependencies.every((n=>n instanceof Facet?t.facet(n)===e.facet(n):!(n instanceof StateField)||t.field(n,false)==e.field(n,false)))||(a?compareArray(o=n(e),s,i):i(o=n(e),s))){e.values[r]=s;return 0}}else o=n(e);e.values[r]=o;return 1}}}}function compareArray(e,t,n){if(e.length!=t.length)return false;for(let i=0;i<e.length;i++)if(!n(e[i],t[i]))return false;return true}function ensureAll(e,t){let n=false;for(let i of t)ensureAddr(e,i)&1&&(n=true);return n}function dynamicFacetSlot(e,t,n){let i=n.map((t=>e[t.id]));let s=n.map((e=>e.type));let r=i.filter((e=>!(e&1)));let a=e[t.id]>>1;function get(e){let n=[];for(let t=0;t<i.length;t++){let r=getAddr(e,i[t]);if(s[t]==2)for(let e of r)n.push(e);else n.push(r)}return t.combine(n)}return{create(e){for(let t of i)ensureAddr(e,t);e.values[a]=get(e);return 1},update(e,n){if(!ensureAll(e,r))return 0;let i=get(e);if(t.compare(i,e.values[a]))return 0;e.values[a]=i;return 1},reconfigure(e,s){let r=ensureAll(e,i);let o=s.config.facets[t.id],l=s.facet(t);if(o&&!r&&sameArray(n,o)){e.values[a]=l;return 0}let h=get(e);if(t.compare(h,l)){e.values[a]=l;return 0}e.values[a]=h;return 1}}}const s=Facet.define({static:true});class StateField{constructor(e,t,n,i,s){this.id=e;this.createF=t;this.updateF=n;this.compareF=i;this.spec=s;this.provides=void 0}static define(e){let t=new StateField(i++,e.create,e.update,e.compare||((e,t)=>e===t),e);e.provide&&(t.provides=e.provide(t));return t}create(e){let t=e.facet(s).find((e=>e.field==this));return((t===null||t===void 0?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>{e.values[t]=this.create(e);return 1},update:(e,n)=>{let i=e.values[t];let s=this.updateF(i,n);if(this.compareF(i,s))return 0;e.values[t]=s;return 1},reconfigure:(e,n)=>{let i,r=e.facet(s),a=n.facet(s);if((i=r.find((e=>e.field==this)))&&i!=a.find((e=>e.field==this))){e.values[t]=i.create(e);return 1}if(n.config.address[this.id]!=null){e.values[t]=n.field(this);return 0}e.values[t]=this.create(e);return 1}}}init(e){return[this,s.of({field:this,create:e})]}get extension(){return this}}const r={lowest:4,low:3,default:2,high:1,highest:0};function prec(e){return t=>new PrecExtension(t,e)}const a={highest:prec(r.highest),high:prec(r.high),default:prec(r.default),low:prec(r.low),lowest:prec(r.lowest)};class PrecExtension{constructor(e,t){this.inner=e;this.prec=t}}class Compartment{of(e){return new CompartmentInstance(this,e)}reconfigure(e){return Compartment.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class CompartmentInstance{constructor(e,t){this.compartment=e;this.inner=t}}class Configuration{constructor(e,t,n,i,s,r){this.base=e;this.compartments=t;this.dynamicSlots=n;this.address=i;this.staticValues=s;this.facets=r;this.statusTemplate=[];while(this.statusTemplate.length<n.length)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let i=[];let s=Object.create(null);let r=new Map;for(let n of flatten(e,t,r))n instanceof StateField?i.push(n):(s[n.facet.id]||(s[n.facet.id]=[])).push(n);let a=Object.create(null);let o=[];let l=[];for(let e of i){a[e.id]=l.length<<1;l.push((t=>e.slot(t)))}let h=n===null||n===void 0?void 0:n.config.facets;for(let e in s){let t=s[e],i=t[0].facet;let r=h&&h[e]||[];if(t.every((e=>e.type==0))){a[i.id]=o.length<<1|1;if(sameArray(r,t))o.push(n.facet(i));else{let e=i.combine(t.map((e=>e.value)));o.push(n&&i.compare(e,n.facet(i))?n.facet(i):e)}}else{for(let e of t)if(e.type==0){a[e.id]=o.length<<1|1;o.push(e.value)}else{a[e.id]=l.length<<1;l.push((t=>e.dynamicSlot(t)))}a[i.id]=l.length<<1;l.push((e=>dynamicFacetSlot(e,i,t)))}}let c=l.map((e=>e(a)));return new Configuration(e,r,c,a,o,s)}}function flatten(e,t,n){let i=[[],[],[],[],[]];let s=new Map;function inner(e,a){let o=s.get(e);if(o!=null){if(o<=a)return;let t=i[o].indexOf(e);t>-1&&i[o].splice(t,1);e instanceof CompartmentInstance&&n.delete(e.compartment)}s.set(e,a);if(Array.isArray(e))for(let t of e)inner(t,a);else if(e instanceof CompartmentInstance){if(n.has(e.compartment))throw new RangeError("Duplicate use of compartment in extensions");let i=t.get(e.compartment)||e.inner;n.set(e.compartment,i);inner(i,a)}else if(e instanceof PrecExtension)inner(e.inner,e.prec);else if(e instanceof StateField){i[a].push(e);e.provides&&inner(e.provides,a)}else if(e instanceof FacetProvider){i[a].push(e);e.facet.extensions&&inner(e.facet.extensions,r.default)}else{let t=e.extension;if(!t)throw new Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);inner(t,a)}}inner(e,r.default);return i.reduce(((e,t)=>e.concat(t)))}function ensureAddr(e,t){if(t&1)return 2;let n=t>>1;let i=e.status[n];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;e.status[n]=4;let s=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|s}function getAddr(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}const o=Facet.define();const l=Facet.define({combine:e=>e.some((e=>e)),static:true});const h=Facet.define({combine:e=>e.length?e[0]:void 0,static:true});const c=Facet.define();const f=Facet.define();const u=Facet.define();const d=Facet.define({combine:e=>!!e.length&&e[0]});class Annotation{constructor(e,t){this.type=e;this.value=t}static define(){return new AnnotationType}}class AnnotationType{of(e){return new Annotation(this,e)}}class StateEffectType{constructor(e){this.map=e}of(e){return new StateEffect(this,e)}}class StateEffect{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 StateEffect(this.type,t)}is(e){return this.type==e}static define(e={}){return new StateEffectType(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let i of e){let e=i.map(t);e&&n.push(e)}return n}}StateEffect.reconfigure=StateEffect.define();StateEffect.appendConfig=StateEffect.define();class Transaction{constructor(e,t,n,i,s,r){this.startState=e;this.changes=t;this.selection=n;this.effects=i;this.annotations=s;this.scrollIntoView=r;this._doc=null;this._state=null;n&&checkSelection(n,t.newLength);s.some((e=>e.type==Transaction.time))||(this.annotations=s.concat(Transaction.time.of(Date.now())))}static create(e,t,n,i,s,r){return new Transaction(e,t,n,i,s,r)}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(){this._state||this.startState.applyTransaction(this);return 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(Transaction.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}Transaction.time=Annotation.define();Transaction.userEvent=Annotation.define();Transaction.addToHistory=Annotation.define();Transaction.remote=Annotation.define();function joinRanges(e,t){let n=[];for(let i=0,s=0;;){let r,a;if(i<e.length&&(s==t.length||t[s]>=e[i])){r=e[i++];a=e[i++]}else{if(!(s<t.length))return n;r=t[s++];a=t[s++]}!n.length||n[n.length-1]<r?n.push(r,a):n[n.length-1]<a&&(n[n.length-1]=a)}}function mergeTransaction(e,t,n){var i;let s,r,a;if(n){s=t.changes;r=ChangeSet.empty(t.changes.length);a=e.changes.compose(t.changes)}else{s=t.changes.map(e.changes);r=e.changes.mapDesc(t.changes,true);a=e.changes.compose(s)}return{changes:a,selection:t.selection?t.selection.map(r):(i=e.selection)===null||i===void 0?void 0:i.map(s),effects:StateEffect.mapEffects(e.effects,s).concat(StateEffect.mapEffects(t.effects,r)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function resolveTransactionInner(e,t,n){let i=t.selection,s=asArray(t.annotations);t.userEvent&&(s=s.concat(Transaction.userEvent.of(t.userEvent)));return{changes:t.changes instanceof ChangeSet?t.changes:ChangeSet.of(t.changes||[],n,e.facet(h)),selection:i&&(i instanceof EditorSelection?i:EditorSelection.single(i.anchor,i.head)),effects:asArray(t.effects),annotations:s,scrollIntoView:!!t.scrollIntoView}}function resolveTransaction(e,t,n){let i=resolveTransactionInner(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===false&&(n=false);for(let s=1;s<t.length;s++){t[s].filter===false&&(n=false);let r=!!t[s].sequential;i=mergeTransaction(i,resolveTransactionInner(e,t[s],r?i.changes.newLength:e.doc.length),r)}let s=Transaction.create(e,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return extendTransaction(n?filterTransaction(s):s)}function filterTransaction(e){let t=e.startState;let n=true;for(let i of t.facet(c)){let t=i(e);if(t===false){n=false;break}Array.isArray(t)&&(n=n===true?t:joinRanges(n,t))}if(n!==true){let i,s;if(n===false){s=e.changes.invertedDesc;i=ChangeSet.empty(t.doc.length)}else{let t=e.changes.filter(n);i=t.changes;s=t.filtered.mapDesc(t.changes).invertedDesc}e=Transaction.create(t,i,e.selection&&e.selection.map(s),StateEffect.mapEffects(e.effects,s),e.annotations,e.scrollIntoView)}let i=t.facet(f);for(let n=i.length-1;n>=0;n--){let s=i[n](e);e=s instanceof Transaction?s:Array.isArray(s)&&s.length==1&&s[0]instanceof Transaction?s[0]:resolveTransaction(t,asArray(s),false)}return e}function extendTransaction(e){let t=e.startState,n=t.facet(u),i=e;for(let s=n.length-1;s>=0;s--){let r=n[s](e);r&&Object.keys(r).length&&(i=mergeTransaction(i,resolveTransactionInner(t,r,e.changes.newLength),true))}return i==e?e:Transaction.create(t,e.changes,e.selection,i.effects,i.annotations,i.scrollIntoView)}const g=[];function asArray(e){return e==null?g:Array.isArray(e)?e:[e]}var p=function(e){e[e.Word=0]="Word";e[e.Space=1]="Space";e[e.Other=2]="Other";return e}(p||(p={}));const m=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let S;try{S=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}function hasWordChar(e){if(S)return S.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||m.test(n)))return true}return false}function makeCategorizer(e){return t=>{if(!/\S/.test(t))return p.Space;if(hasWordChar(t))return p.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return p.Word;return p.Other}}class EditorState{constructor(e,t,n,i,s,r){this.config=e;this.doc=t;this.selection=n;this.values=i;this.status=e.statusTemplate.slice();this.computeSlot=s;r&&(r._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)ensureAddr(this,e<<1);this.computeSlot=null}field(e,t=true){let n=this.config.address[e.id];if(n!=null){ensureAddr(this,n);return getAddr(this,n)}if(t)throw new RangeError("Field is not present in this state")}update(...e){return resolveTransaction(this,e,true)}applyTransaction(e){let t=this.config,{base:n,compartments:i}=t;for(let s of e.effects)if(s.is(Compartment.reconfigure)){if(t){i=new Map;t.compartments.forEach(((e,t)=>i.set(t,e)));t=null}i.set(s.value.compartment,s.value.extension)}else if(s.is(StateEffect.reconfigure)){t=null;n=s.value}else if(s.is(StateEffect.appendConfig)){t=null;n=asArray(n).concat(s.value)}let s;if(t)s=e.startState.values.slice();else{t=Configuration.resolve(n,i,this);let e=new EditorState(t,this.doc,this.selection,t.dynamicSlots.map((()=>null)),((e,t)=>t.reconfigure(e,this)),null);s=e.values}let r=e.startState.facet(l)?e.newSelection:e.newSelection.asSingle();new EditorState(t,e.newDoc,r,s,((t,n)=>n.update(t,e)),e)}replaceSelection(e){typeof e=="string"&&(e=this.toText(e));return this.changeByRange((t=>({changes:{from:t.from,to:t.to,insert:e},range:EditorSelection.cursor(t.from+e.length)})))}changeByRange(e){let t=this.selection;let n=e(t.ranges[0]);let i=this.changes(n.changes),s=[n.range];let r=asArray(n.effects);for(let n=1;n<t.ranges.length;n++){let a=e(t.ranges[n]);let o=this.changes(a.changes),l=o.map(i);for(let e=0;e<n;e++)s[e]=s[e].map(l);let h=i.mapDesc(o,true);s.push(a.range.map(h));i=i.compose(l);r=StateEffect.mapEffects(r,l).concat(StateEffect.mapEffects(asArray(a.effects),h))}return{changes:i,selection:EditorSelection.create(s,t.mainIndex),effects:r}}changes(e=[]){return e instanceof ChangeSet?e:ChangeSet.of(e,this.doc.length,this.facet(EditorState.lineSeparator))}toText(e){return Text.of(e.split(this.facet(EditorState.lineSeparator)||t))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];if(t==null)return e.default;ensureAddr(this,t);return getAddr(this,t)}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let i=e[n];i instanceof StateField&&this.config.address[i.id]!=null&&(t[n]=i.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(n)for(let t in n)if(Object.prototype.hasOwnProperty.call(e,t)){let s=n[t],r=e[t];i.push(s.init((e=>s.spec.fromJSON(r,e))))}return EditorState.create({doc:e.doc,selection:EditorSelection.fromJSON(e.selection),extensions:t.extensions?i.concat([t.extensions]):i})}static create(e={}){let n=Configuration.resolve(e.extensions||[],new Map);let i=e.doc instanceof Text?e.doc:Text.of((e.doc||"").split(n.staticFacet(EditorState.lineSeparator)||t));let s=e.selection?e.selection instanceof EditorSelection?e.selection:EditorSelection.single(e.selection.anchor,e.selection.head):EditorSelection.single(0);checkSelection(s,i.length);n.staticFacet(l)||(s=s.asSingle());return new EditorState(n,i,s,n.dynamicSlots.map((()=>null)),((e,t)=>t.create(e)),null)}get tabSize(){return this.facet(EditorState.tabSize)}get lineBreak(){return this.facet(EditorState.lineSeparator)||"\n"}get readOnly(){return this.facet(d)}phrase(e,...t){for(let t of this.facet(EditorState.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}t.length&&(e=e.replace(/\$(\$|\d*)/g,((e,n)=>{if(n=="$")return"$";let i=+(n||1);return!i||i>t.length?e:t[i-1]})));return e}languageDataAt(e,t,n=-1){let i=[];for(let s of this.facet(o))for(let r of s(this,t,n))Object.prototype.hasOwnProperty.call(r,e)&&i.push(r[e]);return i}charCategorizer(e){return makeCategorizer(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:n,length:i}=this.doc.lineAt(e);let s=this.charCategorizer(e);let r=e-n,a=e-n;while(r>0){let e=findClusterBreak(t,r,false);if(s(t.slice(e,r))!=p.Word)break;r=e}while(a<i){let e=findClusterBreak(t,a);if(s(t.slice(a,e))!=p.Word)break;a=e}return r==a?null:EditorSelection.range(r+n,a+n)}}EditorState.allowMultipleSelections=l;EditorState.tabSize=Facet.define({combine:e=>e.length?e[0]:4});EditorState.lineSeparator=h;EditorState.readOnly=d;EditorState.phrases=Facet.define({compare(e,t){let n=Object.keys(e),i=Object.keys(t);return n.length==i.length&&n.every((n=>e[n]==t[n]))}});EditorState.languageData=o;EditorState.changeFilter=c;EditorState.transactionFilter=f;EditorState.transactionExtender=u;Compartment.reconfigure=StateEffect.define();function combineConfig(e,t,n={}){let i={};for(let t of e)for(let e of Object.keys(t)){let s=t[e],r=i[e];if(r===void 0)i[e]=s;else if(r===s||s===void 0);else{if(!Object.hasOwnProperty.call(n,e))throw new Error("Config merge conflict for field "+e);i[e]=n[e](r,s)}}for(let e in t)i[e]===void 0&&(i[e]=t[e]);return i}class RangeValue{eq(e){return this==e}range(e,t=e){return Range.create(e,t,this)}}RangeValue.prototype.startSide=RangeValue.prototype.endSide=0;RangeValue.prototype.point=false;RangeValue.prototype.mapMode=n.TrackDel;class Range{constructor(e,t,n){this.from=e;this.to=t;this.value=n}static create(e,t,n){return new Range(e,t,n)}}function cmpRange(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class Chunk{constructor(e,t,n,i){this.from=e;this.to=t;this.value=n;this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,i=0){let s=n?this.to:this.from;for(let r=i,a=s.length;;){if(r==a)return r;let i=r+a>>1;let o=s[i]-e||(n?this.value[i].endSide:this.value[i].startSide)-t;if(i==r)return o>=0?r:a;o>=0?a=i:r=i+1}}between(e,t,n,i){for(let s=this.findIndex(t,-1e9,true),r=this.findIndex(n,1e9,false,s);s<r;s++)if(i(this.from[s]+e,this.to[s]+e,this.value[s])===false)return false}map(e,t){let n=[],i=[],s=[],r=-1,a=-1;for(let o=0;o<this.value.length;o++){let l,h,c=this.value[o],f=this.from[o]+e,u=this.to[o]+e;if(f==u){let e=t.mapPos(f,c.startSide,c.mapMode);if(e==null)continue;l=h=e;if(c.startSide!=c.endSide){h=t.mapPos(f,c.endSide);if(h<l)continue}}else{l=t.mapPos(f,c.startSide);h=t.mapPos(u,c.endSide);if(l>h||l==h&&c.startSide>0&&c.endSide<=0)continue}if(!((h-l||c.endSide-c.startSide)<0)){r<0&&(r=l);c.point&&(a=Math.max(a,h-l));n.push(c);i.push(l-r);s.push(h-r)}}return{mapped:n.length?new Chunk(i,s,n,a):null,pos:r}}}class RangeSet{constructor(e,t,n,i){this.chunkPos=e;this.chunk=t;this.nextLayer=n;this.maxPoint=i}static create(e,t,n,i){return new RangeSet(e,t,n,i)}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=false,filterFrom:i=0,filterTo:s=this.length}=e;let r=e.filter;if(t.length==0&&!r)return this;n&&(t=t.slice().sort(cmpRange));if(this.isEmpty)return t.length?RangeSet.of(t):this;let a=new LayerCursor(this,null,-1).goto(0),o=0,l=[];let h=new RangeSetBuilder;while(a.value||o<t.length)if(o<t.length&&(a.from-t[o].from||a.startSide-t[o].value.startSide)>=0){let e=t[o++];h.addInner(e.from,e.to,e.value)||l.push(e)}else if(a.rangeIndex==1&&a.chunkIndex<this.chunk.length&&(o==t.length||this.chunkEnd(a.chunkIndex)<t[o].from)&&(!r||i>this.chunkEnd(a.chunkIndex)||s<this.chunkPos[a.chunkIndex])&&h.addChunk(this.chunkPos[a.chunkIndex],this.chunk[a.chunkIndex]))a.nextChunk();else{(!r||i>a.to||s<a.from||r(a.from,a.to,a.value))&&(h.addInner(a.from,a.to,a.value)||l.push(Range.create(a.from,a.to,a.value)));a.next()}return h.finishInner(this.nextLayer.isEmpty&&!l.length?RangeSet.empty:this.nextLayer.update({add:l,filter:r,filterFrom:i,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],i=-1;for(let s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],a=this.chunk[s];let o=e.touchesRange(r,r+a.length);if(o===false){i=Math.max(i,a.maxPoint);t.push(a);n.push(e.mapPos(r))}else if(o===true){let{mapped:s,pos:o}=a.map(r,e);if(s){i=Math.max(i,s.maxPoint);t.push(s);n.push(o)}}}let s=this.nextLayer.map(e);return t.length==0?s:new RangeSet(n,t,s||RangeSet.empty,i)}between(e,t,n){if(!this.isEmpty){for(let i=0;i<this.chunk.length;i++){let s=this.chunkPos[i],r=this.chunk[i];if(t>=s&&e<=s+r.length&&r.between(s,e-s,t-s,n)===false)return}this.nextLayer.between(e,t,n)}}iter(e=0){return HeapCursor.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return HeapCursor.from(e).goto(t)}static compare(e,t,n,i,s=-1){let r=e.filter((e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=s));let a=t.filter((e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=s));let o=findSharedChunks(r,a,n);let l=new SpanCursor(r,o,s);let h=new SpanCursor(a,o,s);n.iterGaps(((e,t,n)=>compare(l,e,h,t,n,i)));n.empty&&n.length==0&&compare(l,0,h,0,0,i)}static eq(e,t,n=0,i){i==null&&(i=999999999);let s=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0));let r=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0));if(s.length!=r.length)return false;if(!s.length)return true;let a=findSharedChunks(s,r);let o=new SpanCursor(s,a,0).goto(n),l=new SpanCursor(r,a,0).goto(n);for(;;){if(o.to!=l.to||!sameValues(o.active,l.active)||o.point&&(!l.point||!o.point.eq(l.point)))return false;if(o.to>i)return true;o.next();l.next()}}static spans(e,t,n,i,s=-1){let r=new SpanCursor(e,null,s).goto(t),a=t;let o=r.openStart;for(;;){let e=Math.min(r.to,n);if(r.point){let n=r.activeForPoint(r.to);let s=r.pointFrom<t?n.length+1:r.point.startSide<0?n.length:Math.min(n.length,o);i.point(a,e,r.point,n,s,r.pointRank);o=Math.min(r.openEnd(e),n.length)}else if(e>a){i.span(a,e,r.active,o);o=r.openEnd(e)}if(r.to>n)return o+(r.point&&r.to>n?1:0);a=r.to;r.next()}}static of(e,t=false){let n=new RangeSetBuilder;for(let i of e instanceof Range?[e]:t?lazySort(e):e)n.add(i.from,i.to,i.value);return n.finish()}static join(e){if(!e.length)return RangeSet.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let i=e[n];i!=RangeSet.empty;i=i.nextLayer)t=new RangeSet(i.chunkPos,i.chunk,t,Math.max(i.maxPoint,t.maxPoint));return t}}RangeSet.empty=new RangeSet([],[],null,-1);function lazySort(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let i=e[n];if(cmpRange(t,i)>0)return e.slice().sort(cmpRange);t=i}return e}RangeSet.empty.nextLayer=RangeSet.empty;class RangeSetBuilder{finishChunk(e){this.chunks.push(new Chunk(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;if(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 RangeSetBuilder)).add(e,t,n)}addInner(e,t,n){let i=e-this.lastTo||n.startSide-this.last.endSide;if(i<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");if(i<0)return false;this.from.length==250&&this.finishChunk(true);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));return true}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return false;this.from.length&&this.finishChunk(true);this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint);this.chunks.push(t);this.chunkPos.push(e);let n=t.value.length-1;this.last=t.value[n];this.lastFrom=t.from[n]+e;this.lastTo=t.to[n]+e;return true}finish(){return this.finishInner(RangeSet.empty)}finishInner(e){this.from.length&&this.finishChunk(false);if(this.chunks.length==0)return e;let t=RangeSet.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);this.from=null;return t}}function findSharedChunks(e,t,n){let i=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&i.set(t.chunk[e],t.chunkPos[e]);let s=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let r=i.get(e.chunk[t]);r==null||(n?n.mapPos(r):r)!=e.chunkPos[t]||(n===null||n===void 0?void 0:n.touchesRange(r,r+e.chunk[t].length))||s.add(e.chunk[t])}return s}class LayerCursor{constructor(e,t,n,i=0){this.layer=e;this.skip=t;this.minPoint=n;this.rank=i}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){this.chunkIndex=this.rangeIndex=0;this.gotoInner(e,t,false);return this}gotoInner(e,t,n){while(this.chunkIndex<this.layer.chunk.length){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++;n=false}if(this.chunkIndex<this.layer.chunk.length){let i=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,true);(!n||this.rangeIndex<i)&&this.setRangeIndex(i)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,true)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9;this.value=null;break}{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex];let n=e+t.from[this.rangeIndex];this.from=n;this.to=e+t.to[this.rangeIndex];this.value=t.value[this.rangeIndex];this.setRangeIndex(this.rangeIndex+1);if(this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){this.chunkIndex++;if(this.skip)while(this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]))this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++;this.rangeIndex=0;this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class HeapCursor{constructor(e){this.heap=e}static from(e,t=null,n=-1){let i=[];for(let s=0;s<e.length;s++)for(let r=e[s];!r.isEmpty;r=r.nextLayer)r.maxPoint>=n&&i.push(new LayerCursor(r,t,n,s));return i.length==1?i[0]:new HeapCursor(i)}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 e=this.heap.length>>1;e>=0;e--)heapBubble(this.heap,e);this.next();return this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)heapBubble(this.heap,e);(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();heapBubble(this.heap,0)}}}function heapBubble(e,t){for(let n=e[t];;){let i=1+(t<<1);if(i>=e.length)break;let s=e[i];if(i+1<e.length&&s.compare(e[i+1])>=0){s=e[i+1];i++}if(n.compare(s)<0)break;e[i]=n;e[t]=s;t=i}}class SpanCursor{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=HeapCursor.from(e,t,n)}goto(e,t=-1e9){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();return this}forward(e,t){while(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){remove(this.active,e);remove(this.activeTo,e);remove(this.activeRank,e);this.minActive=findMinIndex(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:i,rank:s}=this.cursor;while(t<this.activeRank.length&&(s-this.activeRank[t]||i-this.activeTo[t])>0)t++;insert(this.active,t,n);insert(this.activeTo,t,i);insert(this.activeRank,t,s);e&&insert(e,t,this.cursor.from);this.minActive=findMinIndex(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)<0){if(this.activeTo[i]>e){this.to=this.activeTo[i];this.endSide=this.active[i].endSide;break}this.removeActive(i);n&&remove(n,i)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from;this.endSide=this.cursor.startSide;break}{let e=this.cursor.value;if(e.point){if(!(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=e;this.pointFrom=this.cursor.from;this.pointRank=this.cursor.rank;this.to=this.cursor.to;this.endSide=e.endSide;this.cursor.next();this.forward(this.to,this.endSide);break}this.cursor.next()}else{this.addActive(n);this.cursor.next()}}}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0;n--){if(this.activeRank[n]<this.pointRank)break;(this.activeTo[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 compare(e,t,n,i,s,r){e.goto(t);n.goto(i);let a=i+s;let o=i,l=i-t;for(;;){let t=e.to+l-n.to,i=t||e.endSide-n.endSide;let s=i<0?e.to+l:n.to,h=Math.min(s,a);e.point||n.point?e.point&&n.point&&(e.point==n.point||e.point.eq(n.point))&&sameValues(e.activeForPoint(e.to),n.activeForPoint(n.to))||r.comparePoint(o,h,e.point,n.point):h>o&&!sameValues(e.active,n.active)&&r.compareRange(o,h,e.active,n.active);if(s>a)break;(t||e.openEnd!=n.openEnd)&&r.boundChange&&r.boundChange(s);o=s;i<=0&&e.next();i>=0&&n.next()}}function sameValues(e,t){if(e.length!=t.length)return false;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!e[n].eq(t[n]))return false;return true}function remove(e,t){for(let n=t,i=e.length-1;n<i;n++)e[n]=e[n+1];e.pop()}function insert(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function findMinIndex(e,t){let n=-1,i=1e9;for(let s=0;s<t.length;s++)if((t[s]-i||e[s].endSide-e[n].endSide)<0){n=s;i=t[s]}return n}function countColumn(e,t,n=e.length){let i=0;for(let s=0;s<n&&s<e.length;)if(e.charCodeAt(s)==9){i+=t-i%t;s++}else{i++;s=findClusterBreak(e,s)}return i}function findColumn(e,t,n,i){for(let i=0,s=0;;){if(s>=t)return i;if(i==e.length)break;s+=e.charCodeAt(i)==9?n-s%n:1;i=findClusterBreak(e,i)}return i===true?-1:e.length}export{Annotation,AnnotationType,ChangeDesc,ChangeSet,p as CharCategory,Compartment,EditorSelection,EditorState,Facet,Line,n as MapMode,a as Prec,Range,RangeSet,RangeSetBuilder,RangeValue,SelectionRange,StateEffect,StateEffectType,StateField,Text,Transaction,codePointAt,codePointSize,combineConfig,countColumn,findClusterBreak,findColumn,fromCodePoint};+diff --git a/admin/vendor/javascript/@codemirror--view.js b/admin/vendor/javascript/@codemirror--view.jsnew file mode 100644index 0000000000..b329a21992--- /dev/null+++ b/admin/vendor/javascript/@codemirror--view.js@@ -0,0 +1,4 @@+// @codemirror/[email protected] downloaded from https://ga.jspm.io/npm:@codemirror/[email protected]/dist/index.js++import{Text as t,RangeValue as e,RangeSet as i,MapMode as s,findClusterBreak as o,EditorSelection as n,Facet as r,StateEffect as l,ChangeSet as a,findColumn as h,CharCategory as c,EditorState as d,Annotation as f,Transaction as u,Prec as p,codePointAt as g,codePointSize as m,combineConfig as w,StateField as v,RangeSetBuilder as b,countColumn as y}from"@codemirror/state";import{StyleModule as M}from"style-mod";import{keyName as x,base as S,shift as C}from"w3c-keyname";import k from"crelt";function D(t){let e;e=t.nodeType==11?t.getSelection?t:t.ownerDocument:t;return e.getSelection()}function A(t,e){return!!e&&(t==e||t.contains(e.nodeType!=1?e.parentNode:e))}function O(t,e){if(!e.anchorNode)return false;try{return A(t,e.anchorNode)}catch(t){return false}}function T(t){return t.nodeType==3?G(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function V(t,e,i,s){return!!i&&(R(t,e,i,s,-1)||R(t,e,i,s,1))}function E(t){for(var e=0;;e++){t=t.previousSibling;if(!t)return e}}function B(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function R(t,e,i,s,o){for(;;){if(t==i&&e==s)return true;if(e==(o<0?0:L(t))){if(t.nodeName=="DIV")return false;let i=t.parentNode;if(!i||i.nodeType!=1)return false;e=E(t)+(o<0?0:1);t=i}else{if(t.nodeType!=1)return false;t=t.childNodes[e+(o<0?-1:0)];if(t.nodeType==1&&t.contentEditable=="false")return false;e=o<0?L(t):0}}}function L(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function P(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function H(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function N(t,e){let i=e.width/t.offsetWidth;let s=e.height/t.offsetHeight;(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1);(s>.995&&s<1.005||!isFinite(s)||Math.abs(e.height-t.offsetHeight)<1)&&(s=1);return{scaleX:i,scaleY:s}}function W(t,e,i,s,o,n,r,l){let a=t.ownerDocument,h=a.defaultView||window;for(let c=t,d=false;c&&!d;)if(c.nodeType==1){let t,f=c==a.body;let u=1,p=1;if(f)t=H(h);else{/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(d=true);if(c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();({scaleX:u,scaleY:p}=N(c,e));t={left:e.left,right:e.left+c.clientWidth*u,top:e.top,bottom:e.top+c.clientHeight*p}}let g=0,m=0;if(o=="nearest"){if(e.top<t.top){m=e.top-(t.top+r);i>0&&e.bottom>t.bottom+m&&(m=e.bottom-t.bottom+r)}else if(e.bottom>t.bottom){m=e.bottom-t.bottom+r;i<0&&e.top-m<t.top&&(m=e.top-(t.top+r))}}else{let s=e.bottom-e.top,n=t.bottom-t.top;let l=o=="center"&&s<=n?e.top+s/2-n/2:o=="start"||o=="center"&&i<0?e.top-r:e.bottom-n+r;m=l-t.top}if(s=="nearest"){if(e.left<t.left){g=e.left-(t.left+n);i>0&&e.right>t.right+g&&(g=e.right-t.right+n)}else if(e.right>t.right){g=e.right-t.right+n;i<0&&e.left<t.left+g&&(g=e.left-(t.left+n))}}else{let i=s=="center"?e.left+(e.right-e.left)/2-(t.right-t.left)/2:s=="start"==l?e.left-n:e.right-(t.right-t.left)+n;g=i-t.left}if(g||m)if(f)h.scrollBy(g,m);else{let t=0,i=0;if(m){let t=c.scrollTop;c.scrollTop+=m/p;i=(c.scrollTop-t)*p}if(g){let e=c.scrollLeft;c.scrollLeft+=g/u;t=(c.scrollLeft-e)*u}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i};t&&Math.abs(t-g)<1&&(s="nearest");i&&Math.abs(i-m)<1&&(o="nearest")}if(f)break;(e.top<t.top||e.bottom>t.bottom||e.left<t.left||e.right>t.right)&&(e={left:Math.max(e.left,t.left),right:Math.min(e.right,t.right),top:Math.max(e.top,t.top),bottom:Math.min(e.bottom,t.bottom)});c=c.assignedSlot||c.parentNode}else{if(c.nodeType!=11)break;c=c.host}}function F(t){let e,i,s=t.ownerDocument;for(let o=t.parentNode;o;){if(o==s.body||e&&i)break;if(o.nodeType==1){!i&&o.scrollHeight>o.clientHeight&&(i=o);!e&&o.scrollWidth>o.clientWidth&&(e=o);o=o.assignedSlot||o.parentNode}else{if(o.nodeType!=11)break;o=o.host}}return{x:e,y:i}}class DOMSelectionState{constructor(){this.anchorNode=null;this.anchorOffset=0;this.focusNode=null;this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?L(e):0),i,Math.min(t.focusOffset,i?L(i):0))}set(t,e,i,s){this.anchorNode=t;this.anchorOffset=e;this.focusNode=i;this.focusOffset=s}}let z=null;function I(t){if(t.setActive)return t.setActive();if(z)return t.focus(z);let e=[];for(let i=t;i;i=i.parentNode){e.push(i,i.scrollTop,i.scrollLeft);if(i==i.ownerDocument)break}t.focus(z==null?{get preventScroll(){z={preventScroll:true};return true}}:void 0);if(!z){z=false;for(let t=0;t<e.length;){let i=e[t++],s=e[t++],o=e[t++];i.scrollTop!=s&&(i.scrollTop=s);i.scrollLeft!=o&&(i.scrollLeft=o)}}}let q;function G(t,e,i=e){let s=q||(q=document.createRange());s.setEnd(t,i);s.setStart(t,e);return s}function K(t,e,i,s){let o={key:e,code:e,keyCode:i,which:i,cancelable:true};s&&({altKey:o.altKey,ctrlKey:o.ctrlKey,shiftKey:o.shiftKey,metaKey:o.metaKey}=s);let n=new KeyboardEvent("keydown",o);n.synthetic=true;t.dispatchEvent(n);let r=new KeyboardEvent("keyup",o);r.synthetic=true;t.dispatchEvent(r);return n.defaultPrevented||r.defaultPrevented}function Y(t){while(t){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function X(t){while(t.attributes.length)t.removeAttributeNode(t.attributes[0])}function _(t,e){let i=e.focusNode,s=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=s)return false;s=Math.min(s,L(i));for(;;)if(s){if(i.nodeType!=1)return false;let t=i.childNodes[s-1];if(t.contentEditable=="false")s--;else{i=t;s=L(i)}}else{if(i==t)return true;s=E(i);i=i.parentNode}}function j(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function U(t,e){for(let i=t,s=e;;){if(i.nodeType==3&&s>0)return{node:i,offset:s};if(i.nodeType==1&&s>0){if(i.contentEditable=="false")return null;i=i.childNodes[s-1];s=L(i)}else{if(!i.parentNode||B(i))return null;s=E(i);i=i.parentNode}}}function $(t,e){for(let i=t,s=e;;){if(i.nodeType==3&&s<i.nodeValue.length)return{node:i,offset:s};if(i.nodeType==1&&s<i.childNodes.length){if(i.contentEditable=="false")return null;i=i.childNodes[s];s=0}else{if(!i.parentNode||B(i))return null;s=E(i)+1;i=i.parentNode}}}class DOMPos{constructor(t,e,i=true){this.node=t;this.offset=e;this.precise=i}static before(t,e){return new DOMPos(t.parentNode,E(t),e)}static after(t,e){return new DOMPos(t.parentNode,E(t)+1,e)}}const Q=[];class ContentView{constructor(){this.parent=null;this.dom=null;this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t){let e=this.posAtStart;for(let i of this.children){if(i==t)return e;e+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}sync(t,e){if(this.flags&2){let i=this.dom;let s,o=null;for(let n of this.children){if(n.flags&7){if(!n.dom&&(s=o?o.nextSibling:i.firstChild)){let t=ContentView.get(s);(!t||!t.parent&&t.canReuseDOM(n))&&n.reuseDOM(s)}n.sync(t,e);n.flags&=-8}s=o?o.nextSibling:i.firstChild;e&&!e.written&&e.node==i&&s!=n.dom&&(e.written=true);if(n.dom.parentNode==i)while(s&&s!=n.dom)s=J(s);else i.insertBefore(n.dom,s);o=n.dom}s=o?o.nextSibling:i.firstChild;s&&e&&e.node==i&&(e.written=true);while(s)s=J(s)}else if(this.flags&1)for(let i of this.children)if(i.flags&7){i.sync(t,e);i.flags&=-8}}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let s=L(t)==0?0:e==0?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;s==0&&e.firstChild!=e.lastChild&&(s=t==e.firstChild?-1:1);t=e}i=s<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;while(i&&!ContentView.get(i))i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let s=this.children[t];if(s.dom==i)return e;e+=s.length+s.breakAfter}}domBoundsAround(t,e,i=0){let s=-1,o=-1,n=-1,r=-1;for(let l=0,a=i,h=i;l<this.children.length;l++){let i=this.children[l],c=a+i.length;if(a<t&&c>e)return i.domBoundsAround(t,e,a);if(c>=t&&s==-1){s=l;o=a}if(a>e&&i.dom.parentNode==this.dom){n=l;r=h;break}h=c;a=c+i.breakAfter}return{from:o,to:r<0?i+this.length:r,startDOM:(s?this.children[s-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:n<this.children.length&&n>=0?this.children[n].dom:null}}markDirty(t=false){this.flags|=2;this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){t&&(e.flags|=2);if(e.flags&1)return;e.flags|=1;t=false}}setParent(t){if(this.parent!=t){this.parent=t;this.flags&7&&this.markParentsDirty(true)}}setDOM(t){if(this.dom!=t){this.dom&&(this.dom.cmView=null);this.dom=t;t.cmView=this}}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,i=Q){this.markDirty();for(let s=t;s<e;s++){let t=this.children[s];t.parent==this&&i.indexOf(t)<0&&t.destroy()}i.length<250?this.children.splice(t,e-t,...i):this.children=[].concat(this.children.slice(0,t),i,this.children.slice(e));for(let t=0;t<i.length;t++)i[t].setParent(this)}ignoreMutation(t){return false}ignoreEvent(t){return false}childCursor(t=this.length){return new ChildCursor(this.children,t,this.children.length)}childPos(t,e=1){return this.childCursor().findPos(t,e)}toString(){let t=this.constructor.name.replace("View","");return t+(this.children.length?"("+this.children.join()+")":this.length?"["+(t=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(t){return t.cmView}get isEditable(){return true}get isWidget(){return false}get isHidden(){return false}merge(t,e,i,s,o,n){return false}become(t){return false}canReuseDOM(t){return t.constructor==this.constructor&&!(8&(this.flags|t.flags))}getSide(){return 0}destroy(){for(let t of this.children)t.parent==this&&t.destroy();this.parent=null}}ContentView.prototype.breakAfter=0;function J(t){let e=t.nextSibling;t.parentNode.removeChild(t);return e}class ChildCursor{constructor(t,e,i){this.children=t;this.pos=e;this.i=i;this.off=0}findPos(t,e=1){for(;;){if(t>this.pos||t==this.pos&&(e>0||this.i==0||this.children[this.i-1].breakAfter)){this.off=t-this.pos;return this}let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function Z(t,e,i,s,o,n,r,l,a){let{children:h}=t;let c=h.length?h[e]:null;let d=n.length?n[n.length-1]:null;let f=d?d.breakAfter:r;if(!(e==s&&c&&!r&&!f&&n.length<2&&c.merge(i,o,n.length?d:null,i==0,l,a))){if(s<h.length){let t=h[s];if(t&&(o<t.length||t.breakAfter&&(d===null||d===void 0?void 0:d.breakAfter))){if(e==s){t=t.split(o);o=0}if(!f&&d&&t.merge(0,o,d,true,0,a))n[n.length-1]=t;else{(o||t.children.length&&!t.children[0].length)&&t.merge(0,o,null,false,0,a);n.push(t)}}else(t===null||t===void 0?void 0:t.breakAfter)&&(d?d.breakAfter=1:r=1);s++}if(c){c.breakAfter=r;if(i>0){!r&&n.length&&c.merge(i,c.length,n[0],false,l,0)?c.breakAfter=n.shift().breakAfter:(i<c.length||c.children.length&&c.children[c.children.length-1].length==0)&&c.merge(i,c.length,null,false,l,0);e++}}while(e<s&&n.length)if(h[s-1].become(n[n.length-1])){s--;n.pop();a=n.length?0:l}else{if(!h[e].become(n[0]))break;e++;n.shift();l=n.length?0:a}!n.length&&e&&s<h.length&&!h[e-1].breakAfter&&h[s].merge(0,0,h[e-1],false,l,a)&&e--;(e<s||n.length)&&t.replaceChildren(e,s,n)}}function tt(t,e,i,s,o,n){let r=t.childCursor();let{i:l,off:a}=r.findPos(i,1);let{i:h,off:c}=r.findPos(e,-1);let d=e-i;for(let t of s)d+=t.length;t.length+=d;Z(t,h,c,l,a,s,0,o,n)}let et=typeof navigator!="undefined"?navigator:{userAgent:"",vendor:"",platform:""};let it=typeof document!="undefined"?document:{documentElement:{style:{}}};const st=/Edge\/(\d+)/.exec(et.userAgent);const ot=/MSIE \d/.test(et.userAgent);const nt=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(et.userAgent);const rt=!!(ot||nt||st);const lt=!rt&&/gecko\/(\d+)/i.test(et.userAgent);const at=!rt&&/Chrome\/(\d+)/.exec(et.userAgent);const ht="webkitFontSmoothing"in it.documentElement.style;const ct=!rt&&/Apple Computer/.test(et.vendor);const dt=ct&&(/Mobile\/\w+/.test(et.userAgent)||et.maxTouchPoints>2);var ft={mac:dt||/Mac/.test(et.platform),windows:/Win/.test(et.platform),linux:/Linux|X11/.test(et.platform),ie:rt,ie_version:ot?it.documentMode||6:nt?+nt[1]:st?+st[1]:0,gecko:lt,gecko_version:lt?+(/Firefox\/(\d+)/.exec(et.userAgent)||[0,0])[1]:0,chrome:!!at,chrome_version:at?+at[1]:0,ios:dt,android:/Android\b/.test(et.userAgent),webkit:ht,safari:ct,webkit_version:ht?+(/\bAppleWebKit\/(\d+)/.exec(et.userAgent)||[0,0])[1]:0,tabSize:it.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const ut=256;class TextView extends ContentView{constructor(t){super();this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM();if(this.dom.nodeValue!=this.text){e&&e.node==this.dom&&(e.written=true);this.dom.nodeValue=this.text}}reuseDOM(t){t.nodeType==3&&this.createDOM(t)}merge(t,e,i){if(this.flags&8||i&&(!(i instanceof TextView)||this.length-(e-t)+i.length>ut||i.flags&8))return false;this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e);this.markDirty();return true}split(t){let e=new TextView(this.text.slice(t));this.text=this.text.slice(0,t);this.markDirty();e.flags|=this.flags&8;return e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new DOMPos(this.dom,t)}domBoundsAround(t,e,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return pt(this.dom,t,e)}}class MarkView extends ContentView{constructor(t,e=[],i=0){super();this.mark=t;this.children=e;this.length=i;for(let t of e)t.setParent(this)}setAttrs(t){X(t);this.mark.class&&(t.className=this.mark.class);if(this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}canReuseDOM(t){return super.canReuseDOM(t)&&!(8&(this.flags|t.flags))}reuseDOM(t){if(t.nodeName==this.mark.tagName.toUpperCase()){this.setDOM(t);this.flags|=6}}sync(t,e){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));super.sync(t,e)}merge(t,e,i,s,o,n){if(i&&(!(i instanceof MarkView&&i.mark.eq(this.mark))||t&&o<=0||e<this.length&&n<=0))return false;tt(this,t,e,i?i.children.slice():[],o-1,n-1);this.markDirty();return true}split(t){let e=[],i=0,s=-1,o=0;for(let n of this.children){let r=i+n.length;r>t&&e.push(i<t?n.split(t-i):n);s<0&&i>=t&&(s=o);i=r;o++}let n=this.length-t;this.length=t;if(s>-1){this.children.length=s;this.markDirty()}return new MarkView(this.mark,e,n)}domAtPos(t){return gt(this,t)}coordsAt(t,e){return wt(this,t,e)}}function pt(t,e,i){let s=t.nodeValue.length;e>s&&(e=s);let o=e,n=e,r=0;if(e==0&&i<0||e==s&&i>=0){if(!(ft.chrome||ft.gecko))if(e){o--;r=1}else if(n<s){n++;r=-1}}else i<0?o--:n<s&&n++;let l=G(t,o,n).getClientRects();if(!l.length)return null;let a=l[(r?r<0:i>=0)?0:l.length-1];ft.safari&&!r&&a.width==0&&(a=Array.prototype.find.call(l,(t=>t.width))||a);return r?P(a,r<0):a||null}class WidgetView extends ContentView{static create(t,e,i){return new WidgetView(t,e,i)}constructor(t,e,i){super();this.widget=t;this.length=e;this.side=i;this.prevWidget=null}split(t){let e=WidgetView.create(this.widget,this.length-t,this.side);this.length-=t;return e}sync(t){if(!this.dom||!this.widget.updateDOM(this.dom,t)){this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom);this.prevWidget=null;this.setDOM(this.widget.toDOM(t));this.widget.editable||(this.dom.contentEditable="false")}}getSide(){return this.side}merge(t,e,i,s,o,n){if(i&&(!(i instanceof WidgetView)||!this.widget.compare(i.widget)||t>0&&o<=0||e<this.length&&n<=0))return false;this.length=t+(i?i.length:0)+(this.length-e);return true}become(t){if(t instanceof WidgetView&&t.side==this.side&&this.widget.constructor==t.widget.constructor){this.widget.compare(t.widget)||this.markDirty(true);this.dom&&!this.prevWidget&&(this.prevWidget=this.widget);this.widget=t.widget;this.length=t.length;return true}return false}ignoreMutation(){return true}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(this.length==0)return t.empty;let e=this;while(e.parent)e=e.parent;let{view:i}=e,s=i&&i.state.doc,o=this.posAtStart;return s?s.slice(o,o+this.length):t.empty}domAtPos(t){return(this.length?t==0:this.side>0)?DOMPos.before(this.dom):DOMPos.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let n=this.side?this.side<0:t>0;for(let e=n?s.length-1:0;;e+=n?-1:1){o=s[e];if(t>0?e==0:e==s.length-1||o.top<o.bottom)break}return P(o,!n)}get isEditable(){return false}get isWidget(){return true}get isHidden(){return this.widget.isHidden}destroy(){super.destroy();this.dom&&this.widget.destroy(this.dom)}}class WidgetBufferView extends ContentView{constructor(t){super();this.side=t}get length(){return 0}merge(){return false}become(t){return t instanceof WidgetBufferView&&t.side==this.side}split(){return new WidgetBufferView(this.side)}sync(){if(!this.dom){let t=document.createElement("img");t.className="cm-widgetBuffer";t.setAttribute("aria-hidden","true");this.setDOM(t)}}getSide(){return this.side}domAtPos(t){return this.side>0?DOMPos.before(this.dom):DOMPos.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return t.empty}get isHidden(){return true}}TextView.prototype.children=WidgetView.prototype.children=WidgetBufferView.prototype.children=Q;function gt(t,e){let i=t.dom,{children:s}=t,o=0;for(let t=0;o<s.length;o++){let n=s[o],r=t+n.length;if(!(r==t&&n.getSide()<=0)){if(e>t&&e<r&&n.dom.parentNode==i)return n.domAtPos(e-t);if(e<=t)break;t=r}}for(let t=o;t>0;t--){let e=s[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=o;t<s.length;t++){let e=s[t];if(e.dom.parentNode==i)return e.domAtPos(0)}return new DOMPos(i,0)}function mt(t,e,i){let s,{children:o}=t;if(i>0&&e instanceof MarkView&&o.length&&(s=o[o.length-1])instanceof MarkView&&s.mark.eq(e.mark))mt(s,e.children[0],i-1);else{o.push(e);e.setParent(t)}t.length+=e.length}function wt(t,e,i){let s=null,o=-1,n=null,r=-1;function l(t,e){for(let a=0,h=0;a<t.children.length&&h<=e;a++){let c=t.children[a],d=h+c.length;if(d>=e)if(c.children.length)l(c,e-h);else if((!n||n.isHidden&&(i>0||bt(n,c)))&&(d>e||h==d&&c.getSide()>0)){n=c;r=e-h}else if(h<e||h==d&&c.getSide()<0&&!c.isHidden){s=c;o=e-h}h=d}}l(t,e);let a=(i<0?s:n)||s||n;return a?a.coordsAt(Math.max(0,a==s?o:r),i):vt(t)}function vt(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=T(e);return i[i.length-1]||null}function bt(t,e){let i=t.coordsAt(0,1),s=e.coordsAt(0,1);return i&&s&&s.top<i.bottom}function yt(t,e){for(let i in t)i=="class"&&e.class?e.class+=" "+t.class:i=="style"&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}const Mt=Object.create(null);function xt(t,e,i){if(t==e)return true;t||(t=Mt);e||(e=Mt);let s=Object.keys(t),o=Object.keys(e);if(s.length-(i&&s.indexOf(i)>-1?1:0)!=o.length-(i&&o.indexOf(i)>-1?1:0))return false;for(let n of s)if(n!=i&&(o.indexOf(n)==-1||t[n]!==e[n]))return false;return true}function St(t,e,i){let s=false;if(e)for(let o in e)if(!(i&&o in i)){s=true;o=="style"?t.style.cssText="":t.removeAttribute(o)}if(i)for(let o in i)if(!(e&&e[o]==i[o])){s=true;o=="style"?t.style.cssText=i[o]:t.setAttribute(o,i[o])}return s}function Ct(t){let e=Object.create(null);for(let i=0;i<t.attributes.length;i++){let s=t.attributes[i];e[s.name]=s.value}return e}class WidgetType{eq(t){return false}updateDOM(t,e){return false}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return true}coordsAt(t,e,i){return null}get isHidden(){return false}get editable(){return false}destroy(t){}}var kt=function(t){t[t.Text=0]="Text";t[t.WidgetBefore=1]="WidgetBefore";t[t.WidgetAfter=2]="WidgetAfter";t[t.WidgetRange=3]="WidgetRange";return t}(kt||(kt={}));class Decoration extends e{constructor(t,e,i,s){super();this.startSide=t;this.endSide=e;this.widget=i;this.spec=s}get heightRelevant(){return false}static mark(t){return new MarkDecoration(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8;return new PointDecoration(t,e,e,i,t.widget||null,false)}static replace(t){let e,i,s=!!t.block;if(t.isBlockGap){e=-5e8;i=4e8}else{let{start:o,end:n}=Dt(t,s);e=(o?s?-3e8:-1:5e8)-1;i=1+(n?s?2e8:1:-6e8)}return new PointDecoration(t,e,i,s,t.widget||null,true)}static line(t){return new LineDecoration(t)}static set(t,e=false){return i.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}Decoration.none=i.empty;class MarkDecoration extends Decoration{constructor(t){let{start:e,end:i}=Dt(t);super(e?-1:5e8,i?1:-6e8,null,t);this.tagName=t.tagName||"span";this.class=t.class||"";this.attrs=t.attributes||null}eq(t){var e,i;return this==t||t instanceof MarkDecoration&&this.tagName==t.tagName&&(this.class||((e=this.attrs)===null||e===void 0?void 0:e.class))==(t.class||((i=t.attrs)===null||i===void 0?void 0:i.class))&&xt(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}MarkDecoration.prototype.point=false;class LineDecoration extends Decoration{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof LineDecoration&&this.spec.class==t.spec.class&&xt(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}LineDecoration.prototype.mapMode=s.TrackBefore;LineDecoration.prototype.point=true;class PointDecoration extends Decoration{constructor(t,e,i,o,n,r){super(e,i,n,t);this.block=o;this.isReplace=r;this.mapMode=o?e<=0?s.TrackBefore:s.TrackAfter:s.TrackDel}get type(){return this.startSide!=this.endSide?kt.WidgetRange:this.startSide<=0?kt.WidgetBefore:kt.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof PointDecoration&&At(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}PointDecoration.prototype.point=true;function Dt(t,e=false){let{inclusiveStart:i,inclusiveEnd:s}=t;i==null&&(i=t.inclusive);s==null&&(s=t.inclusive);return{start:i!==null&&i!==void 0?i:e,end:s!==null&&s!==void 0?s:e}}function At(t,e){return t==e||!!(t&&e&&t.compare(e))}function Ot(t,e,i,s=0){let o=i.length-1;o>=0&&i[o]+s>=t?i[o]=Math.max(i[o],e):i.push(t,e)}class LineView extends ContentView{constructor(){super(...arguments);this.children=[];this.length=0;this.prevAttrs=void 0;this.attrs=null;this.breakAfter=0}merge(t,e,i,s,o,n){if(i){if(!(i instanceof LineView))return false;this.dom||i.transferDOM(this)}s&&this.setDeco(i?i.attrs:null);tt(this,t,e,i?i.children.slice():[],o,n);return true}split(t){let e=new LineView;e.breakAfter=this.breakAfter;if(this.length==0)return e;let{i:i,off:s}=this.childPos(t);if(s){e.append(this.children[i].split(s),0);this.children[i].merge(s,this.children[i].length,null,false,0,0);i++}for(let t=i;t<this.children.length;t++)e.append(this.children[t],0);while(i>0&&this.children[i-1].length==0)this.children[--i].destroy();this.children.length=i;this.markDirty();this.length=t;return e}transferDOM(t){if(this.dom){this.markDirty();t.setDOM(this.dom);t.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs;this.prevAttrs=void 0;this.dom=null}}setDeco(t){if(!xt(this.attrs,t)){if(this.dom){this.prevAttrs=this.attrs;this.markDirty()}this.attrs=t}}append(t,e){mt(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=yt(e,this.attrs||{}));i&&(this.attrs=yt({class:i},this.attrs||{}))}domAtPos(t){return gt(this,t)}reuseDOM(t){if(t.nodeName=="DIV"){this.setDOM(t);this.flags|=6}}sync(t,e){var i;if(this.dom){if(this.flags&4){X(this.dom);this.dom.className="cm-line";this.prevAttrs=this.attrs?null:void 0}}else{this.setDOM(document.createElement("div"));this.dom.className="cm-line";this.prevAttrs=this.attrs?null:void 0}if(this.prevAttrs!==void 0){St(this.dom,this.prevAttrs,this.attrs);this.dom.classList.add("cm-line");this.prevAttrs=void 0}super.sync(t,e);let s=this.dom.lastChild;while(s&&ContentView.get(s)instanceof MarkView)s=s.lastChild;if(!s||!this.length||s.nodeName!="BR"&&((i=ContentView.get(s))===null||i===void 0?void 0:i.isEditable)==false&&(!ft.ios||!this.children.some((t=>t instanceof TextView)))){let t=document.createElement("BR");t.cmIgnore=true;this.dom.appendChild(t)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let t,e=0;for(let i of this.children){if(!(i instanceof TextView)||/[^ -~]/.test(i.text))return null;let s=T(i.dom);if(s.length!=1)return null;e+=s[0].width;t=s[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=wt(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let s=(e-t.textHeight)/2;return{top:i.top+s,bottom:i.bottom-s,left:i.left,right:i.left}}}return i}become(t){return t instanceof LineView&&this.children.length==0&&t.children.length==0&&xt(this.attrs,t.attrs)&&this.breakAfter==t.breakAfter}covers(){return true}static find(t,e){for(let i=0,s=0;i<t.children.length;i++){let o=t.children[i],n=s+o.length;if(n>=e){if(o instanceof LineView)return o;if(n>e)break}s=n+o.breakAfter}return null}}class BlockWidgetView extends ContentView{constructor(t,e,i){super();this.widget=t;this.length=e;this.deco=i;this.breakAfter=0;this.prevWidget=null}merge(t,e,i,s,o,n){if(i&&(!(i instanceof BlockWidgetView)||!this.widget.compare(i.widget)||t>0&&o<=0||e<this.length&&n<=0))return false;this.length=t+(i?i.length:0)+(this.length-e);return true}domAtPos(t){return t==0?DOMPos.before(this.dom):DOMPos.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new BlockWidgetView(this.widget,e,this.deco);i.breakAfter=this.breakAfter;return i}get children(){return Q}sync(t){if(!this.dom||!this.widget.updateDOM(this.dom,t)){this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom);this.prevWidget=null;this.setDOM(this.widget.toDOM(t));this.widget.editable||(this.dom.contentEditable="false")}}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):t.empty}domBoundsAround(){return null}become(t){if(t instanceof BlockWidgetView&&t.widget.constructor==this.widget.constructor){t.widget.compare(this.widget)||this.markDirty(true);this.dom&&!this.prevWidget&&(this.prevWidget=this.widget);this.widget=t.widget;this.length=t.length;this.deco=t.deco;this.breakAfter=t.breakAfter;return true}return false}ignoreMutation(){return true}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return false}get isWidget(){return true}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);return i||(this.widget instanceof BlockGapWidget?null:P(this.dom.getBoundingClientRect(),this.length?t==0:e<=0))}destroy(){super.destroy();this.dom&&this.widget.destroy(this.dom)}covers(t){let{startSide:e,endSide:i}=this.deco;return e!=i&&(t<0?e<0:i>0)}}class BlockGapWidget extends WidgetType{constructor(t){super();this.height=t}toDOM(){let t=document.createElement("div");t.className="cm-gap";this.updateDOM(t);return t}eq(t){return t.height==this.height}updateDOM(t){t.style.height=this.height+"px";return true}get editable(){return true}get estimatedHeight(){return this.height}ignoreEvent(){return false}}class ContentBuilder{constructor(t,e,i,s){this.doc=t;this.pos=e;this.end=i;this.disallowBlockEffectsFor=s;this.content=[];this.curLine=null;this.breakAtStart=0;this.pendingBuffer=0;this.bufferMarks=[];this.atCursorPos=true;this.openStart=-1;this.openEnd=-1;this.text="";this.textOff=0;this.cursor=t.iter();this.skip=e}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!(t.breakAfter||t instanceof BlockWidgetView&&t.deco.endSide<0)}getLine(){if(!this.curLine){this.content.push(this.curLine=new LineView);this.atCursorPos=true}return this.curLine}flushBuffer(t=this.bufferMarks){if(this.pendingBuffer){this.curLine.append(Tt(new WidgetBufferView(-1),t),t.length);this.pendingBuffer=0}}addBlockWidget(t){this.flushBuffer();this.curLine=null;this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0;this.posCovered()||t&&this.content.length&&this.content[this.content.length-1]instanceof BlockWidgetView||this.getLine()}buildText(t,e,i){while(t>0){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:s}=this.cursor.next(this.skip);this.skip=0;if(s)throw new Error("Ran out of text content when drawing inline views");if(i){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=true;t--;continue}this.text=e;this.textOff=0}let s=Math.min(this.text.length-this.textOff,t);let o=Math.min(s,512);this.flushBuffer(e.slice(e.length-i));this.getLine().append(Tt(new TextView(this.text.slice(this.textOff,this.textOff+o)),e),i);this.atCursorPos=true;this.textOff+=o;t-=o;i=s<=o?0:e.length}}span(t,e,i,s){this.buildText(e-t,i,s);this.pos=e;this.openStart<0&&(this.openStart=s)}point(t,e,i,s,o,n){if(this.disallowBlockEffectsFor[n]&&i instanceof PointDecoration){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(e>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let r=e-t;if(i instanceof PointDecoration)if(i.block){i.startSide>0&&!this.posCovered()&&this.getLine();this.addBlockWidget(new BlockWidgetView(i.widget||NullWidget.block,r,i))}else{let n=WidgetView.create(i.widget||NullWidget.inline,r,r?0:i.startSide);let l=this.atCursorPos&&!n.isEditable&&o<=s.length&&(t<e||i.startSide>0);let a=!n.isEditable&&(t<e||o>s.length||i.startSide<=0);let h=this.getLine();this.pendingBuffer!=2||l||n.isEditable||(this.pendingBuffer=0);this.flushBuffer(s);if(l){h.append(Tt(new WidgetBufferView(1),s),o);o=s.length+Math.max(0,o-s.length)}h.append(Tt(n,s),o);this.atCursorPos=a;this.pendingBuffer=a?t<e||o>s.length?1:2:0;this.pendingBuffer&&(this.bufferMarks=s.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);if(r){if(this.textOff+r<=this.text.length)this.textOff+=r;else{this.skip+=r-(this.text.length-this.textOff);this.text="";this.textOff=0}this.pos=e}this.openStart<0&&(this.openStart=o)}static build(t,e,s,o,n){let r=new ContentBuilder(t,e,s,n);r.openEnd=i.spans(o,e,s,r);r.openStart<0&&(r.openStart=r.openEnd);r.finish(r.openEnd);return r}}function Tt(t,e){for(let i of e)t=new MarkView(i,[t],t.length);return t}class NullWidget extends WidgetType{constructor(t){super();this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return true}}NullWidget.inline=new NullWidget("span");NullWidget.block=new NullWidget("div");var Vt=function(t){t[t.LTR=0]="LTR";t[t.RTL=1]="RTL";return t}(Vt||(Vt={}));const Et=Vt.LTR,Bt=Vt.RTL;function Rt(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const Lt=Rt("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008");const Pt=Rt("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333");const Ht=Object.create(null),Nt=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);Ht[e]=i;Ht[i]=-e}function Wt(t){return t<=247?Lt[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?Pt[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const Ft=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class BidiSpan{get dir(){return this.level%2?Bt:Et}constructor(t,e,i){this.from=t;this.to=e;this.level=i}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,i,s){let o=-1;for(let n=0;n<t.length;n++){let r=t[n];if(r.from<=e&&r.to>=e){if(r.level==i)return n;(o<0||(s!=0?s<0?r.from<e:r.to>e:t[o].level>r.level))&&(o=n)}}if(o<0)throw new RangeError("Index out of range");return o}}function zt(t,e){if(t.length!=e.length)return false;for(let i=0;i<t.length;i++){let s=t[i],o=e[i];if(s.from!=o.from||s.to!=o.to||s.direction!=o.direction||!zt(s.inner,o.inner))return false}return true}const It=[];function qt(t,e,i,s,o){for(let n=0;n<=s.length;n++){let r=n?s[n-1].to:e,l=n<s.length?s[n].from:i;let a=n?256:o;for(let e=r,i=a,s=a;e<l;e++){let o=Wt(t.charCodeAt(e));o==512?o=i:o==8&&s==4&&(o=16);It[e]=o==4?2:o;o&7&&(s=o);i=o}for(let t=r,e=a,s=a;t<l;t++){let o=It[t];if(o==128)t<l-1&&e==It[t+1]&&e&24?o=It[t]=e:It[t]=256;else if(o==64){let o=t+1;while(o<l&&It[o]==64)o++;let n=t&&e==8||o<i&&It[o]==8?s==1?1:8:256;for(let e=t;e<o;e++)It[e]=n;t=o-1}else o==8&&s==1&&(It[t]=1);e=o;o&7&&(s=o)}}}function Gt(t,e,i,s,o){let n=o==1?2:1;for(let r=0,l=0,a=0;r<=s.length;r++){let h=r?s[r-1].to:e,c=r<s.length?s[r].from:i;for(let e,i,s,r=h;r<c;r++)if(i=Ht[e=t.charCodeAt(r)])if(i<0){for(let t=l-3;t>=0;t-=3)if(Nt[t+1]==-i){let e=Nt[t+2];let i=e&2?o:e&4?e&1?n:o:0;i&&(It[r]=It[Nt[t]]=i);l=t;break}}else{if(Nt.length==189)break;Nt[l++]=r;Nt[l++]=e;Nt[l++]=a}else if((s=It[r])==2||s==1){let t=s==o;a=t?0:1;for(let e=l-3;e>=0;e-=3){let i=Nt[e+2];if(i&2)break;if(t)Nt[e+2]|=2;else{if(i&4)break;Nt[e+2]|=4}}}}}function Kt(t,e,i,s){for(let o=0,n=s;o<=i.length;o++){let r=o?i[o-1].to:t,l=o<i.length?i[o].from:e;for(let a=r;a<l;){let r=It[a];if(r==256){let r=a+1;for(;;)if(r==l){if(o==i.length)break;r=i[o++].to;l=o<i.length?i[o].from:e}else{if(It[r]!=256)break;r++}let h=n==1;let c=(r<e?It[r]:s)==1;let d=h==c?h?1:2:s;for(let e=r,s=o,n=s?i[s-1].to:t;e>a;){if(e==n){e=i[--s].from;n=s?i[s-1].to:t}It[--e]=d}a=r}else{n=r;a++}}}}function Yt(t,e,i,s,o,n,r){let l=s%2?2:1;if(s%2==o%2)for(let a=e,h=0;a<i;){let e=true,c=false;if(h==n.length||a<n[h].from){let t=It[a];if(t!=l){e=false;c=t==16}}let d=e||l!=1?null:[];let f=e?s:s+1;let u=a;t:for(;;)if(h<n.length&&u==n[h].from){if(c)break t;let p=n[h];if(!e)for(let t=p.to,e=h+1;;){if(t==i)break t;if(!(e<n.length&&n[e].from==t)){if(It[t]==l)break t;break}t=n[e++].to}h++;if(d)d.push(p);else{p.from>a&&r.push(new BidiSpan(a,p.from,f));let e=p.direction==Et!=!(f%2);Xt(t,e?s+1:s,o,p.inner,p.from,p.to,r);a=p.to}u=p.to}else{if(u==i||(e?It[u]!=l:It[u]==l))break;u++}d?Yt(t,a,u,s+1,o,d,r):a<u&&r.push(new BidiSpan(a,u,f));a=u}else for(let a=i,h=n.length;a>e;){let i=true,c=false;if(!h||a>n[h-1].to){let t=It[a-1];if(t!=l){i=false;c=t==16}}let d=i||l!=1?null:[];let f=i?s:s+1;let u=a;t:for(;;)if(h&&u==n[h-1].to){if(c)break t;let p=n[--h];if(!i)for(let t=p.from,i=h;;){if(t==e)break t;if(!i||n[i-1].to!=t){if(It[t-1]==l)break t;break}t=n[--i].from}if(d)d.push(p);else{p.to<a&&r.push(new BidiSpan(p.to,a,f));let e=p.direction==Et!=!(f%2);Xt(t,e?s+1:s,o,p.inner,p.from,p.to,r);a=p.from}u=p.from}else{if(u==e||(i?It[u-1]!=l:It[u-1]==l))break;u--}d?Yt(t,u,a,s+1,o,d,r):u<a&&r.push(new BidiSpan(u,a,f));a=u}}function Xt(t,e,i,s,o,n,r){let l=e%2?2:1;qt(t,o,n,s,l);Gt(t,o,n,s,l);Kt(o,n,s,l);Yt(t,o,n,e,i,s,r)}function _t(t,e,i){if(!t)return[new BidiSpan(0,0,e==Bt?1:0)];if(e==Et&&!i.length&&!Ft.test(t))return jt(t.length);if(i.length)while(t.length>It.length)It[It.length]=256;let s=[],o=e==Et?0:1;Xt(t,o,o,i,0,t.length,s);return s}function jt(t){return[new BidiSpan(0,t,0)]}let Ut="";function $t(t,e,i,s,r){var l;let a=s.head-t.from;let h=BidiSpan.find(e,a,(l=s.bidiLevel)!==null&&l!==void 0?l:-1,s.assoc);let c=e[h],d=c.side(r,i);if(a==d){let t=h+=r?1:-1;if(t<0||t>=e.length)return null;c=e[h=t];a=c.side(!r,i);d=c.side(r,i)}let f=o(t.text,a,c.forward(r,i));(f<c.from||f>c.to)&&(f=d);Ut=t.text.slice(Math.min(a,f),Math.max(a,f));let u=h==(r?e.length-1:0)?null:e[h+(r?1:-1)];return u&&f==d&&u.level+(r?0:1)<c.level?n.cursor(u.side(!r,i)+t.from,u.forward(r,i)?1:-1,u.level):n.cursor(f+t.from,c.forward(r,i)?-1:1,c.level)}function Qt(t,e,i){for(let s=e;s<i;s++){let e=Wt(t.charCodeAt(s));if(e==1)return Et;if(e==2||e==4)return Bt}return Et}const Jt=r.define();const Zt=r.define();const te=r.define();const ee=r.define();const ie=r.define();const se=r.define();const oe=r.define();const ne=r.define();const re=r.define();const le=r.define({combine:t=>t.some((t=>t))});const ae=r.define({combine:t=>t.some((t=>t))});const he=r.define();class ScrollTarget{constructor(t,e="nearest",i="nearest",s=5,o=5,n=false){this.range=t;this.y=e;this.x=i;this.yMargin=s;this.xMargin=o;this.isSnapshot=n}map(t){return t.empty?this:new ScrollTarget(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new ScrollTarget(n.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const ce=l.define({map:(t,e)=>t.map(e)});const de=l.define();function fe(t,e,i){let s=t.facet(ee);s.length?s[0](e):window.onerror&&window.onerror(String(e),i,void 0,void 0,e)||(i?console.error(i+":",e):console.error(e))}const ue=r.define({combine:t=>!t.length||t[0]});let pe=0;const ge=r.define({combine(t){return t.filter(((e,i)=>{for(let s=0;s<i;s++)if(t[s].plugin==e.plugin)return false;return true}))}});class ViewPlugin{constructor(t,e,i,s,o){this.id=t;this.create=e;this.domEventHandlers=i;this.domEventObservers=s;this.baseExtensions=o(this);this.extension=this.baseExtensions.concat(ge.of({plugin:this,arg:void 0}))}of(t){return this.baseExtensions.concat(ge.of({plugin:this,arg:t}))}static define(t,e){const{eventHandlers:i,eventObservers:s,provide:o,decorations:n}=e||{};return new ViewPlugin(pe++,t,i,s,(t=>{let e=[];n&&e.push(ve.of((e=>{let i=e.plugin(t);return i?n(i):Decoration.none})));o&&e.push(o(t));return e}))}static fromClass(t,e){return ViewPlugin.define(((e,i)=>new t(e,i)),e)}}class PluginInstance{constructor(t){this.spec=t;this.mustUpdate=null;this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;this.mustUpdate=null;if(this.value.update)try{this.value.update(t)}catch(e){fe(t.state,e,"CodeMirror plugin crashed");if(this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(t,this.spec.arg)}catch(e){fe(t.state,e,"CodeMirror plugin crashed");this.deactivate()}return this}destroy(t){var e;if((e=this.value)===null||e===void 0?void 0:e.destroy)try{this.value.destroy()}catch(e){fe(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const me=r.define();const we=r.define();const ve=r.define();const be=r.define();const ye=r.define();const Me=r.define();function xe(t,e){let s=t.state.facet(Me);if(!s.length)return s;let o=s.map((e=>e instanceof Function?e(t):e));let n=[];i.spans(o,e.from,e.to,{point(){},span(t,i,s,o){let r=t-e.from,l=i-e.from;let a=n;for(let t=s.length-1;t>=0;t--,o--){let i,n=s[t].spec.bidiIsolate;n==null&&(n=Qt(e.text,r,l));if(o>0&&a.length&&(i=a[a.length-1]).to==r&&i.direction==n){i.to=l;a=i.inner}else{let t={from:r,to:l,direction:n,inner:[]};a.push(t);a=t.inner}}}});return n}const Se=r.define();function Ce(t){let e=0,i=0,s=0,o=0;for(let n of t.state.facet(Se)){let r=n(t);if(r){r.left!=null&&(e=Math.max(e,r.left));r.right!=null&&(i=Math.max(i,r.right));r.top!=null&&(s=Math.max(s,r.top));r.bottom!=null&&(o=Math.max(o,r.bottom))}}return{left:e,right:i,top:s,bottom:o}}const ke=r.define();class ChangedRange{constructor(t,e,i,s){this.fromA=t;this.toA=e;this.fromB=i;this.toB=s}join(t){return new ChangedRange(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let s=t[e-1];if(!(s.fromA>i.toA)){if(s.toA<i.fromA)break;i=i.join(s);t.splice(e-1,1)}}t.splice(e,0,i);return t}static extendWithRanges(t,e){if(e.length==0)return t;let i=[];for(let s=0,o=0,n=0,r=0;;s++){let l=s==t.length?null:t[s],a=n-r;let h=l?l.fromB:1e9;while(o<e.length&&e[o]<h){let t=e[o],s=e[o+1];let n=Math.max(r,t),l=Math.min(h,s);n<=l&&new ChangedRange(n+a,l+a,n,l).addToSet(i);if(s>h)break;o+=2}if(!l)return i;new ChangedRange(l.fromA,l.toA,l.fromB,l.toB).addToSet(i);n=l.toA;r=l.toB}}}class ViewUpdate{constructor(t,e,i){this.view=t;this.state=e;this.transactions=i;this.flags=0;this.startState=t.state;this.changes=a.empty(this.startState.doc.length);for(let t of i)this.changes=this.changes.compose(t.changes);let s=[];this.changes.iterChangedRanges(((t,e,i,o)=>s.push(new ChangedRange(t,e,i,o))));this.changedRanges=s}static create(t,e,i){return new ViewUpdate(t,e,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((t=>t.selection))}get empty(){return this.flags==0&&this.transactions.length==0}}class DocView extends ContentView{get length(){return this.view.state.doc.length}constructor(t){super();this.view=t;this.decorations=[];this.dynamicDecorationMap=[false];this.domChanged=null;this.hasComposition=null;this.markedForComposition=new Set;this.editContextFormatting=Decoration.none;this.lastCompositionAfterCursor=false;this.minWidth=0;this.minWidthFrom=0;this.minWidthTo=0;this.impreciseAnchor=null;this.impreciseHead=null;this.forceSelection=false;this.lastUpdate=Date.now();this.setDOM(t.contentDOM);this.children=[new LineView];this.children[0].setParent(this);this.updateDeco();this.updateInner([new ChangedRange(0,0,0,t.state.doc.length)],0,null)}update(t){var e;let i=t.changedRanges;if(this.minWidth>0&&i.length)if(i.every((({fromA:t,toA:e})=>e<this.minWidthFrom||t>this.minWidthTo))){this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1);this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)}else this.minWidth=this.minWidthFrom=this.minWidthTo=0;this.updateEditContextFormatting(t);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(((e=this.domChanged)===null||e===void 0?void 0:e.newSel)?s=this.domChanged.newSel.head:Re(t.changes,this.hasComposition)||t.selectionSet||(s=t.state.selection.main.head));let o=s>-1?Oe(this.view,t.changes,s):null;this.domChanged=null;if(this.hasComposition){this.markedForComposition.clear();let{from:e,to:s}=this.hasComposition;i=new ChangedRange(e,s,t.changes.mapPos(e,-1),t.changes.mapPos(s,1)).addToSet(i.slice())}this.hasComposition=o?{from:o.range.fromB,to:o.range.toB}:null;(ft.ie||ft.chrome)&&!o&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=true);let n=this.decorations,r=this.updateDeco();let l=Ee(n,r,t.changes);i=ChangedRange.extendWithRanges(i,l);if(this.flags&7||i.length!=0){this.updateInner(i,t.startState.doc.length,o);t.transactions.length&&(this.lastUpdate=Date.now());return true}return false}updateInner(t,e,i){this.view.viewState.mustMeasureContent=true;this.updateChildren(t,e,i);let{observer:s}=this.view;s.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px";this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=ft.chrome||ft.ios?{node:s.selectionRange.focusNode,written:false}:void 0;this.sync(this.view,t);this.flags&=-8;t&&(t.written||s.selectionRange.focusNode!=t.node)&&(this.forceSelection=true);this.dom.style.height=""}));this.markedForComposition.forEach((t=>t.flags&=-9));let o=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.children)t instanceof BlockWidgetView&&t.widget instanceof BlockGapWidget&&o.push(t.dom);s.updateGaps(o)}updateChildren(t,e,i){let s=i?i.range.addToSet(t.slice()):t;let o=this.childCursor(e);for(let t=s.length-1;;t--){let e=t>=0?s[t]:null;if(!e)break;let n,r,l,a,{fromA:h,toA:c,fromB:d,toB:f}=e;if(i&&i.range.fromB<f&&i.range.toB>d){let t=ContentBuilder.build(this.view.state.doc,d,i.range.fromB,this.decorations,this.dynamicDecorationMap);let e=ContentBuilder.build(this.view.state.doc,i.range.toB,f,this.decorations,this.dynamicDecorationMap);r=t.breakAtStart;l=t.openStart;a=e.openEnd;let s=this.compositionView(i);if(e.breakAtStart)s.breakAfter=1;else if(e.content.length&&s.merge(s.length,s.length,e.content[0],false,e.openStart,0)){s.breakAfter=e.content[0].breakAfter;e.content.shift()}t.content.length&&s.merge(0,0,t.content[t.content.length-1],true,0,t.openEnd)&&t.content.pop();n=t.content.concat(s).concat(e.content)}else({content:n,breakAtStart:r,openStart:l,openEnd:a}=ContentBuilder.build(this.view.state.doc,d,f,this.decorations,this.dynamicDecorationMap));let{i:u,off:p}=o.findPos(c,1);let{i:g,off:m}=o.findPos(h,-1);Z(this,g,m,u,p,n,r,l,a)}i&&this.fixCompositionDOM(i)}updateEditContextFormatting(t){this.editContextFormatting=this.editContextFormatting.map(t.changes);for(let e of t.transactions)for(let t of e.effects)t.is(de)&&(this.editContextFormatting=t.value)}compositionView(t){let e=new TextView(t.text.nodeValue);e.flags|=8;for(let{deco:i}of t.marks)e=new MarkView(i,[e],e.length);let i=new LineView;i.append(e,0);return i}fixCompositionDOM(t){let e=(t,e)=>{e.flags|=8|(e.children.some((t=>t.flags&7))?1:0);this.markedForComposition.add(e);let i=ContentView.get(t);i&&i!=e&&(i.dom=null);e.setDOM(t)};let i=this.childPos(t.range.fromB,1);let s=this.children[i.i];e(t.line,s);for(let o=t.marks.length-1;o>=-1;o--){i=s.childPos(i.off,1);s=s.children[i.i];e(o>=0?t.marks[o].node:t.text,s)}}updateSelection(t=false,e=false){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,s=i==this.dom;let o=!s&&!(this.view.state.facet(ue)||this.dom.tabIndex>-1)&&O(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(s||e||o))return;let n=this.forceSelection;this.forceSelection=false;let r=this.view.state.selection.main;let l=this.moveToLine(this.domAtPos(r.anchor));let a=r.empty?l:this.moveToLine(this.domAtPos(r.head));if(ft.gecko&&r.empty&&!this.hasComposition&&De(l)){let t=document.createTextNode("");this.view.observer.ignore((()=>l.node.insertBefore(t,l.node.childNodes[l.offset]||null)));l=a=new DOMPos(t,0);n=true}let h=this.view.observer.selectionRange;if(n||!h.focusNode||(!V(l.node,l.offset,h.anchorNode,h.anchorOffset)||!V(a.node,a.offset,h.focusNode,h.focusOffset))&&!this.suppressWidgetCursorChange(h,r)){this.view.observer.ignore((()=>{if(ft.android&&ft.chrome&&this.dom.contains(h.focusNode)&&Be(h.focusNode,this.dom)){this.dom.blur();this.dom.focus({preventScroll:true})}let t=D(this.view.root);if(t)if(r.empty){if(ft.gecko){let t=Te(l.node,l.offset);if(t&&t!=3){let e=(t==1?U:$)(l.node,l.offset);e&&(l=new DOMPos(e.node,e.offset))}}t.collapse(l.node,l.offset);r.bidiLevel!=null&&t.caretBidiLevel!==void 0&&(t.caretBidiLevel=r.bidiLevel)}else if(t.extend){t.collapse(l.node,l.offset);try{t.extend(a.node,a.offset)}catch(t){}}else{let e=document.createRange();r.anchor>r.head&&([l,a]=[a,l]);e.setEnd(a.node,a.offset);e.setStart(l.node,l.offset);t.removeAllRanges();t.addRange(e)}else;if(o&&this.view.root.activeElement==this.dom){this.dom.blur();i&&i.focus()}}));this.view.observer.setSelectionRange(l,a)}this.impreciseAnchor=l.precise?null:new DOMPos(h.anchorNode,h.anchorOffset);this.impreciseHead=a.precise?null:new DOMPos(h.focusNode,h.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&V(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main;let i=D(t.root);let{anchorNode:s,anchorOffset:o}=t.observer.selectionRange;if(!i||!e.empty||!e.assoc||!i.modify)return;let n=LineView.find(this,e.head);if(!n)return;let r=n.posAtStart;if(e.head==r||e.head==r+n.length)return;let l=this.coordsAt(e.head,-1),a=this.coordsAt(e.head,1);if(!l||!a||l.bottom>a.top)return;let h=this.domAtPos(e.head+e.assoc);i.collapse(h.node,h.offset);i.modify("move",e.assoc<0?"forward":"backward","lineboundary");t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(s,o)}moveToLine(t){let e,i=this.dom;if(t.node!=i)return t;for(let s=t.offset;!e&&s<i.childNodes.length;s++){let t=ContentView.get(i.childNodes[s]);t instanceof LineView&&(e=t.domAtPos(0))}for(let s=t.offset-1;!e&&s>=0;s--){let t=ContentView.get(i.childNodes[s]);t instanceof LineView&&(e=t.domAtPos(t.length))}return e?new DOMPos(e.node,e.offset,true):t}nearest(t){for(let e=t;e;){let t=ContentView.get(e);if(t&&t.rootView==this)return t;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e<this.children.length-1;){let t=this.children[e];if(i<t.length||t instanceof LineView)break;e++;i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){let i=null,s=0;for(let o=this.length,n=this.children.length-1;n>=0;n--){let r=this.children[n],l=o-r.breakAfter,a=l-r.length;if(l<t)break;if(a<=t&&(a<t||r.covers(-1))&&(l>t||r.covers(1))&&(!i||r instanceof LineView&&!(i instanceof LineView&&e>=0))){i=r;s=a}else if(i&&a==t&&l==t&&r instanceof BlockWidgetView&&Math.abs(e)<2){if(r.deco.startSide<0)break;n&&(i=null)}o=a}return i?i.coordsAt(t-s,e):null}coordsForChar(t){let{i:e,off:i}=this.childPos(t,1),s=this.children[e];if(!(s instanceof LineView))return null;while(s.children.length){let{i:t,off:e}=s.childPos(i,1);for(;;t++){if(t==s.children.length)return null;if((s=s.children[t]).length)break}i=e}if(!(s instanceof TextView))return null;let n=o(s.text,i);if(n==i)return null;let r=G(s.dom,i,n).getClientRects();for(let t=0;t<r.length;t++){let e=r[t];if(t==r.length-1||e.top<e.bottom&&e.left<e.right)return e}return null}measureVisibleLineHeights(t){let e=[],{from:i,to:s}=t;let o=this.view.contentDOM.clientWidth;let n=o>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1;let r=-1,l=this.view.textDirection==Vt.LTR;for(let t=0,a=0;a<this.children.length;a++){let h=this.children[a],c=t+h.length;if(c>s)break;if(t>=i){let i=h.dom.getBoundingClientRect();e.push(i.height);if(n){let e=h.dom.lastChild;let s=e?T(e):[];if(s.length){let e=s[s.length-1];let n=l?e.right-i.left:i.right-e.left;if(n>r){r=n;this.minWidth=o;this.minWidthFrom=t;this.minWidthTo=c}}}}t=c+h.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return getComputedStyle(this.children[e].dom).direction=="rtl"?Vt.RTL:Vt.LTR}measureTextSize(){for(let t of this.children)if(t instanceof LineView){let e=t.measureTextSize();if(e)return e}let t,e,i,s=document.createElement("div");s.className="cm-line";s.style.width="99999px";s.style.position="absolute";s.textContent="abc def ghi jkl mno pqr stu";this.view.observer.ignore((()=>{this.dom.appendChild(s);let o=T(s.firstChild)[0];t=s.getBoundingClientRect().height;e=o?o.width/27:7;i=o?o.height:t;s.remove()}));return{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;e&&(t-=this.children[--e].length);return new ChildCursor(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,s=0;;s++){let o=s==e.viewports.length?null:e.viewports[s];let n=o?o.from-1:this.length;if(n>i){let s=(e.lineBlockAt(n).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(Decoration.replace({widget:new BlockGapWidget(s),block:true,inclusive:true,isBlockGap:true}).range(i,n))}if(!o)break;i=o.to+1}return Decoration.set(t)}updateDeco(){let t=1;let e=this.view.state.facet(ve).map((e=>{let i=this.dynamicDecorationMap[t++]=typeof e=="function";return i?e(this.view):e}));let s=false,o=this.view.state.facet(be).map(((t,e)=>{let i=typeof t=="function";i&&(s=true);return i?t(this.view):t}));if(o.length){this.dynamicDecorationMap[t++]=s;e.push(i.join(o))}this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];while(t<this.decorations.length)this.dynamicDecorationMap[t++]=false;return this.decorations}scrollIntoView(t){if(t.isSnapshot){let e=this.view.viewState.lineBlockAt(t.range.head);this.view.scrollDOM.scrollTop=e.top-t.yMargin;this.view.scrollDOM.scrollLeft=t.xMargin;return}for(let e of this.view.state.facet(he))try{if(e(this.view,t.range,t))return true}catch(t){fe(this.view.state,t,"scroll handler")}let{range:e}=t;let i,s=this.coordsAt(e.head,e.empty?e.assoc:e.head>e.anchor?-1:1);if(!s)return;!e.empty&&(i=this.coordsAt(e.anchor,e.anchor>e.head?-1:1))&&(s={left:Math.min(s.left,i.left),top:Math.min(s.top,i.top),right:Math.max(s.right,i.right),bottom:Math.max(s.bottom,i.bottom)});let o=Ce(this.view);let n={left:s.left-o.left,top:s.top-o.top,right:s.right+o.right,bottom:s.bottom+o.bottom};let{offsetWidth:r,offsetHeight:l}=this.view.scrollDOM;W(this.view.scrollDOM,n,e.head<e.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,r),-r),Math.max(Math.min(t.yMargin,l),-l),this.view.textDirection==Vt.LTR)}}function De(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function Ae(t,e){let i=t.observer.selectionRange;if(!i.focusNode)return null;let s=U(i.focusNode,i.focusOffset);let o=$(i.focusNode,i.focusOffset);let n=s||o;if(o&&s&&o.node!=s.node){let e=ContentView.get(o.node);if(!e||e instanceof TextView&&e.text!=o.node.nodeValue)n=o;else if(t.docView.lastCompositionAfterCursor){let t=ContentView.get(s.node);!t||t instanceof TextView&&t.text!=s.node.nodeValue||(n=o)}}t.docView.lastCompositionAfterCursor=n!=s;if(!n)return null;let r=e-n.offset;return{from:r,to:r+n.node.nodeValue.length,node:n.node}}function Oe(t,e,i){let s=Ae(t,i);if(!s)return null;let{node:o,from:n,to:r}=s,l=o.nodeValue;if(/[\n\r]/.test(l))return null;if(t.state.doc.sliceString(s.from,s.to)!=l)return null;let a=e.invertedDesc;let h=new ChangedRange(a.mapPos(n),a.mapPos(r),n,r);let c=[];for(let e=o.parentNode;;e=e.parentNode){let i=ContentView.get(e);if(i instanceof MarkView)c.push({node:e,deco:i.mark});else{if(i instanceof LineView||e.nodeName=="DIV"&&e.parentNode==t.contentDOM)return{range:h,text:o,marks:c,line:e};if(e==t.contentDOM)return null;c.push({node:e,deco:new MarkDecoration({inclusive:true,attributes:Ct(e),tagName:e.tagName.toLowerCase()})})}}}function Te(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e<t.childNodes.length&&t.childNodes[e].contentEditable=="false"?2:0)}let Ve=class DecorationComparator{constructor(){this.changes=[]}compareRange(t,e){Ot(t,e,this.changes)}comparePoint(t,e){Ot(t,e,this.changes)}boundChange(t){Ot(t,t,this.changes)}};function Ee(t,e,s){let o=new Ve;i.compare(t,e,s,o);return o.changes}function Be(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(i.nodeType==1&&i.contentEditable=="false")return true;return false}function Re(t,e){let i=false;e&&t.iterChangedRanges(((t,s)=>{t<e.to&&s>e.from&&(i=true)}));return i}function Le(t,e,i=1){let s=t.charCategorizer(e);let r=t.doc.lineAt(e),l=e-r.from;if(r.length==0)return n.cursor(e);l==0?i=1:l==r.length&&(i=-1);let a=l,h=l;i<0?a=o(r.text,l,false):h=o(r.text,l);let c=s(r.text.slice(a,h));while(a>0){let t=o(r.text,a,false);if(s(r.text.slice(t,a))!=c)break;a=t}while(h<r.length){let t=o(r.text,h);if(s(r.text.slice(h,t))!=c)break;h=t}return n.range(a+r.from,h+r.from)}function Pe(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function He(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function Ne(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function We(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function Fe(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function ze(t,e,i){let s,o,n,r,l=false;let a,h,c,d;for(let f=t.firstChild;f;f=f.nextSibling){let t=T(f);for(let u=0;u<t.length;u++){let p=t[u];o&&Ne(o,p)&&(p=We(Fe(p,o.bottom),o.top));let g=Pe(e,p),m=He(i,p);if(g==0&&m==0)return f.nodeType==3?Ie(f,e,i):ze(f,e,i);if(!s||r>m||r==m&&n>g){s=f;o=p;n=g;r=m;l=!g||(e<p.left?u>0:u<t.length-1)}if(g==0){if(i>p.bottom&&(!c||c.bottom<p.bottom)){a=f;c=p}else if(i<p.top&&(!d||d.top>p.top)){h=f;d=p}}else c&&Ne(c,p)?c=Fe(c,p.bottom):d&&Ne(d,p)&&(d=We(d,p.top))}}if(c&&c.bottom>=i){s=a;o=c}else if(d&&d.top<=i){s=h;o=d}if(!s)return{node:t,offset:0};let f=Math.max(o.left,Math.min(o.right,e));if(s.nodeType==3)return Ie(s,f,i);if(l&&s.contentEditable!="false")return ze(s,f,i);let u=Array.prototype.indexOf.call(t.childNodes,s)+(e>=(o.left+o.right)/2?1:0);return{node:t,offset:u}}function Ie(t,e,i){let s=t.nodeValue.length;let o=-1,n=1e9,r=0;for(let l=0;l<s;l++){let s=G(t,l,l+1).getClientRects();for(let a=0;a<s.length;a++){let h=s[a];if(h.top==h.bottom)continue;r||(r=e-h.left);let c=(h.top>i?h.top-i:i-h.bottom)-1;if(h.left-1<=e&&h.right+1>=e&&c<n){let i=e>=(h.left+h.right)/2,s=i;if(ft.chrome||ft.gecko){let e=G(t,l).getBoundingClientRect();e.left==h.right&&(s=!i)}if(c<=0)return{node:t,offset:l+(s?1:0)};o=l+(s?1:0);n=c}}}return{node:t,offset:o>-1?o:r>0?t.nodeValue.length:0}}function qe(t,e,i,s=-1){var o,n;let r=t.contentDOM.getBoundingClientRect(),l=r.top+t.viewState.paddingTop;let a,{docHeight:h}=t.viewState;let{x:c,y:d}=e,f=d-l;if(f<0)return 0;if(f>h)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,o=false;;){a=t.elementAtHeight(f);if(a.type==kt.Text)break;for(;;){f=s>0?a.bottom+e:a.top-e;if(f>=0&&f<=h)break;if(o)return i?null:0;o=true;s=-s}}d=l+f;let u=a.from;if(u<t.viewport.from)return t.viewport.from==0?0:i?null:Ge(t,r,a,c,d);if(u>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:Ge(t,r,a,c,d);let p=t.dom.ownerDocument;let g=t.root.elementFromPoint?t.root:p;let m=g.elementFromPoint(c,d);m&&!t.contentDOM.contains(m)&&(m=null);if(!m){c=Math.max(r.left+1,Math.min(r.right-1,c));m=g.elementFromPoint(c,d);m&&!t.contentDOM.contains(m)&&(m=null)}let w,v=-1;if(m&&((o=t.docView.nearest(m))===null||o===void 0?void 0:o.isEditable)!=false){if(p.caretPositionFromPoint){let t=p.caretPositionFromPoint(c,d);t&&({offsetNode:w,offset:v}=t)}else if(p.caretRangeFromPoint){let t=p.caretRangeFromPoint(c,d);t&&({startContainer:w,startOffset:v}=t)}w&&(!t.contentDOM.contains(w)||ft.safari&&Ye(w,v,c)||ft.chrome&&Xe(w,v,c))&&(w=void 0);w&&(v=Math.min(L(w),v))}if(!w||!t.docView.dom.contains(w)){let e=LineView.find(t.docView,u);if(!e)return f>a.top+a.height/2?a.to:a.from;({node:w,offset:v}=ze(e.dom,c,d))}let b=t.docView.nearest(w);if(!b)return null;if(b.isWidget&&((n=b.dom)===null||n===void 0?void 0:n.nodeType)==1){let t=b.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?b.posAtStart:b.posAtEnd}return b.localPosFromDOM(w,v)+b.posAtStart}function Ge(t,e,i,s,o){let n=Math.round((s-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>t.defaultLineHeight*1.5){let e=t.viewState.heightOracle.textHeight;let s=Math.floor((o-i.top-.5*(t.defaultLineHeight-e))/e);n+=s*t.viewState.heightOracle.lineLength}let r=t.state.sliceDoc(i.from,i.to);return i.from+h(r,n,t.state.tabSize)}function Ke(t,e,i){let s,o=t;if(t.nodeType!=3||e!=(s=t.nodeValue.length))return false;for(;;){let t=o.nextSibling;if(t){if(t.nodeName=="BR")break;return false}{let t=o.parentNode;if(!t||t.nodeName=="DIV")break;o=t}}return G(t,s-1,s).getBoundingClientRect().right>i}function Ye(t,e,i){return Ke(t,e,i)}function Xe(t,e,i){if(e!=0)return Ke(t,e,i);for(let e=t;;){let t=e.parentNode;if(!t||t.nodeType!=1||t.firstChild!=e)return false;if(t.classList.contains("cm-line"))break;e=t}let s=t.nodeType==1?t.getBoundingClientRect():G(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect();return i-s.left>5}function _e(t,e,i){let s=t.lineBlockAt(e);if(Array.isArray(s.type)){let t;for(let o of s.type){if(o.from>e)break;if(!(o.to<e)){if(o.from<e&&o.to>e)return o;t&&(o.type!=kt.Text||t.type==o.type&&!(i<0?o.from<e:o.to>e))||(t=o)}}return t||s}return s}function je(t,e,i,s){let o=_e(t,e.head,e.assoc||-1);let r=s&&o.type==kt.Text&&(t.lineWrapping||o.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>o.from?e.head-1:e.head):null;if(r){let e=t.dom.getBoundingClientRect();let s=t.textDirectionAt(o.from);let l=t.posAtCoords({x:i==(s==Vt.LTR)?e.right-1:e.left+1,y:(r.top+r.bottom)/2});if(l!=null)return n.cursor(l,i?-1:1)}return n.cursor(i?o.to:o.from,i?-1:1)}function Ue(t,e,i,s){let o=t.state.doc.lineAt(e.head),n=t.bidiSpans(o);let r=t.textDirectionAt(o.from);for(let l=e,a=null;;){let e=$t(o,n,r,l,i),h=Ut;if(!e){if(o.number==(i?t.state.doc.lines:1))return l;h="\n";o=t.state.doc.line(o.number+(i?1:-1));n=t.bidiSpans(o);e=t.visualLineSide(o,!i)}if(a){if(!a(h))return l}else{if(!s)return e;a=s(h)}l=e}}function $e(t,e,i){let s=t.state.charCategorizer(e);let o=s(i);return t=>{let e=s(t);o==c.Space&&(o=e);return o==e}}function Qe(t,e,i,s){let o=e.head,r=i?1:-1;if(o==(i?t.state.doc.length:0))return n.cursor(o,e.assoc);let l,a=e.goalColumn;let h=t.contentDOM.getBoundingClientRect();let c=t.coordsAtPos(o,e.assoc||-1),d=t.documentTop;if(c){a==null&&(a=c.left-h.left);l=r<0?c.top:c.bottom}else{let e=t.viewState.lineBlockAt(o);a==null&&(a=Math.min(h.right-h.left,t.defaultCharacterWidth*(o-e.from)));l=(r<0?e.top:e.bottom)+d}let f=h.left+a;let u=s!==null&&s!==void 0?s:t.viewState.heightOracle.textHeight>>1;for(let e=0;;e+=10){let i=l+(u+e)*r;let s=qe(t,{x:f,y:i},false,r);if(i<h.top||i>h.bottom||(r<0?s<o:s>o)){let e=t.docView.coordsForChar(s);let o=!e||i<e.top?-1:1;return n.cursor(s,o,void 0,a)}}}function Je(t,e,i){for(;;){let s=0;for(let o of t)o.between(e-1,e+1,((t,o,n)=>{if(e>t&&e<o){let n=s||i||(e-t<o-e?-1:1);e=n<0?t:o;s=n}}));if(!s)return e}}function Ze(t,e){let i=null;for(let s=0;s<e.ranges.length;s++){let o=e.ranges[s],r=null;if(o.empty){let e=Je(t,o.from,0);e!=o.from&&(r=n.cursor(e,-1))}else{let e=Je(t,o.from,-1);let i=Je(t,o.to,1);e==o.from&&i==o.to||(r=n.range(o.from==o.anchor?e:i,o.from==o.head?e:i))}if(r){i||(i=e.ranges.slice());i[s]=r}}return i?n.create(i,e.mainIndex):e}function ti(t,e,i){let s=Je(t.state.facet(ye).map((e=>e(t))),i.from,e.head>i.from?-1:1);return s==i.from?i:n.cursor(s,s<i.from?1:-1)}const ei="";class DOMReader{constructor(t,e){this.points=t;this.text="";this.lineSeparator=e.facet(d.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=ei}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let s=t;;){this.findPointBefore(i,s);let t=this.text.length;this.readNode(s);let o=s.nextSibling;if(o==e)break;let n=ContentView.get(s),r=ContentView.get(o);(n&&r?n.breakAfter:(n?n.breakAfter:B(s))||B(o)&&(s.nodeName!="BR"||s.cmIgnore)&&this.text.length>t)&&this.lineBreak();s=o}this.findPointBefore(i,e);return this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let o,n=-1,r=1;if(this.lineSeparator){n=e.indexOf(this.lineSeparator,i);r=this.lineSeparator.length}else if(o=s.exec(e)){n=o.index;r=o[0].length}this.append(e.slice(i,n<0?e.length:n));if(n<0)break;this.lineBreak();if(r>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=r-1);i=n+r}}readNode(t){if(t.cmIgnore)return;let e=ContentView.get(t);let i=e&&e.overrideDOMText;if(i!=null){this.findPointInside(t,i.length);for(let t=i.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else t.nodeType==3?this.readTextNode(t):t.nodeName=="BR"?t.nextSibling&&this.lineBreak():t.nodeType==1&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(t.nodeType==3?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(ii(t,i.node,i.offset)?e:0))}}function ii(t,e,i){for(;;){if(!e||i<L(e))return false;if(e==t)return true;i=E(e)+1;e=e.parentNode}}class DOMPoint{constructor(t,e){this.node=t;this.offset=e;this.pos=-1}}class DOMChange{constructor(t,e,i,s){this.typeOver=s;this.bounds=null;this.text="";this.domChanged=e>-1;let{impreciseHead:o,impreciseAnchor:r}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=o||r?[]:li(t);let i=new DOMReader(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM);this.text=i.text;this.newSel=ai(e,this.bounds.from)}else{let e=t.observer.selectionRange;let i=o&&o.node==e.focusNode&&o.offset==e.focusOffset||!A(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset);let s=r&&r.node==e.anchorNode&&r.offset==e.anchorOffset||!A(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset);let l=t.viewport;if((ft.ios||ft.chrome)&&t.state.selection.main.empty&&i!=s&&(l.from>0||l.to<t.state.doc.length)){let e=Math.min(i,s),o=Math.max(i,s);let n=l.from-e,r=l.to-o;if((n==0||n==1||e==0)&&(r==0||r==-1||o==t.state.doc.length)){i=0;s=t.state.doc.length}}this.newSel=n.single(s,i)}}}function si(e,i){let s;let{newSel:o}=i,r=e.state.selection.main;let l=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(i.bounds){let{from:o,to:n}=i.bounds;let a=r.from,h=null;if(l===8||ft.android&&i.text.length<n-o){a=r.to;h="end"}let c=ri(e.state.doc.sliceString(o,n,ei),i.text,a-o,h);if(c){ft.chrome&&l==13&&c.toB==c.from+2&&i.text.slice(c.from,c.toB)==ei+ei&&c.toB--;s={from:o+c.from,to:o+c.toA,insert:t.of(i.text.slice(c.from,c.toB).split(ei))}}}else o&&(!e.hasFocus&&e.state.facet(ue)||o.main.eq(r))&&(o=null);if(!s&&!o)return false;if(!s&&i.typeOver&&!r.empty&&o&&o.main.empty)s={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,r.to)};else if((ft.mac||ft.android)&&s&&s.from==s.to&&s.from==r.head-1&&/^\. ?$/.test(s.insert.toString())&&e.contentDOM.getAttribute("autocorrect")=="off"){o&&s.insert.length==2&&(o=n.single(o.main.anchor-1,o.main.head-1));s={from:s.from,to:s.to,insert:t.of([s.insert.toString().replace("."," ")])}}else if(s&&s.from>=r.from&&s.to<=r.to&&(s.from!=r.from||s.to!=r.to)&&r.to-r.from-(s.to-s.from)<=4)s={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,s.from).append(s.insert).append(e.state.doc.slice(s.to,r.to))};else if(ft.chrome&&s&&s.from==s.to&&s.from==r.head&&s.insert.toString()=="\n "&&e.lineWrapping){o&&(o=n.single(o.main.anchor-1,o.main.head-1));s={from:r.from,to:r.to,insert:t.of([" "])}}if(s)return oi(e,s,o,l);if(o&&!o.main.eq(r)){let t=false,i="select";if(e.inputState.lastSelectionTime>Date.now()-50){e.inputState.lastSelectionOrigin=="select"&&(t=true);i=e.inputState.lastSelectionOrigin;i=="select.pointer"&&(o=Ze(e.state.facet(ye).map((t=>t(e))),o))}e.dispatch({selection:o,scrollIntoView:t,userEvent:i});return true}return false}function oi(t,e,i,s=-1){if(ft.ios&&t.inputState.flushIOSKey(e))return true;let o=t.state.selection.main;if(ft.android&&(e.to==o.to&&(e.from==o.from||e.from==o.from-1&&t.state.sliceDoc(e.from,o.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&K(t.contentDOM,"Enter",13)||(e.from==o.from-1&&e.to==o.to&&e.insert.length==0||s==8&&e.insert.length<e.to-e.from&&e.to>o.head)&&K(t.contentDOM,"Backspace",8)||e.from==o.from&&e.to==o.to+1&&e.insert.length==0&&K(t.contentDOM,"Delete",46)))return true;let n=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let r;let l=()=>r||(r=ni(t,e,i));t.state.facet(se).some((i=>i(t,e.from,e.to,n,l)))||t.dispatch(l());return true}function ni(t,e,i){let s,o=t.state,r=o.selection.main,l=-1;if(e.from==e.to&&e.from<r.from||e.from>r.to){let i=e.from<r.from?-1:1,s=i<0?r.from:r.to;let n=Je(o.facet(ye).map((e=>e(t))),s,i);e.from==n&&(l=n)}if(l>-1)s={changes:e,selection:n.cursor(e.from+e.insert.length,-1)};else if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let i=r.from<e.from?o.sliceDoc(r.from,e.from):"";let n=r.to>e.to?o.sliceDoc(e.to,r.to):"";s=o.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+n))}else{let l=o.changes(e);let a=i&&i.main.to<=l.newLength?i.main:void 0;if(o.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=r.to&&e.to>=r.to-10){let h=t.state.sliceDoc(e.from,e.to);let c,d=i&&Ae(t,i.main.head);if(d){let t=e.insert.length-(e.to-e.from);c={from:d.from,to:d.to-t}}else c=t.state.doc.lineAt(r.head);let f=r.to-e.to,u=r.to-r.from;s=o.changeByRange((i=>{if(i.from==r.from&&i.to==r.to)return{changes:l,range:a||i.map(l)};let s=i.to-f,d=s-h.length;if(i.to-i.from!=u||t.state.sliceDoc(d,s)!=h||i.to>=c.from&&i.from<=c.to)return{range:i};let p=o.changes({from:d,to:s,insert:e.insert}),g=i.to-r.to;return{changes:p,range:a?n.range(Math.max(0,a.anchor+g),Math.max(0,a.head+g)):i.map(p)}}))}else s={changes:l,selection:a&&o.selection.replaceRange(a)}}let a="input.type";if(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50){t.inputState.compositionPendingChange=false;a+=".compose";if(t.inputState.compositionFirstChange){a+=".start";t.inputState.compositionFirstChange=false}}return o.update(s,{userEvent:a,scrollIntoView:true})}function ri(t,e,i,s){let o=Math.min(t.length,e.length);let n=0;while(n<o&&t.charCodeAt(n)==e.charCodeAt(n))n++;if(n==o&&t.length==e.length)return null;let r=t.length,l=e.length;while(r>0&&l>0&&t.charCodeAt(r-1)==e.charCodeAt(l-1)){r--;l--}if(s=="end"){let t=Math.max(0,n-Math.min(r,l));i-=r+t-n}if(r<n&&t.length<e.length){let t=i<=n&&i>=r?n-i:0;n-=t;l=n+(l-r);r=n}else if(l<n){let t=i<=n&&i>=l?n-i:0;n-=t;r=n+(r-l);l=n}return{from:n,toA:r,toB:l}}function li(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:s,focusNode:o,focusOffset:n}=t.observer.selectionRange;if(i){e.push(new DOMPoint(i,s));o==i&&n==s||e.push(new DOMPoint(o,n))}return e}function ai(t,e){if(t.length==0)return null;let i=t[0].pos,s=t.length==2?t[1].pos:i;return i>-1&&s>-1?n.single(i+e,s+e):null}class InputState{setSelectionOrigin(t){this.lastSelectionOrigin=t;this.lastSelectionTime=Date.now()}constructor(t){this.view=t;this.lastKeyCode=0;this.lastKeyTime=0;this.lastTouchTime=0;this.lastFocusTime=0;this.lastScrollTop=0;this.lastScrollLeft=0;this.pendingIOSKey=void 0;this.tabFocusMode=-1;this.lastSelectionOrigin=null;this.lastSelectionTime=0;this.lastContextMenu=0;this.scrollHandlers=[];this.handlers=Object.create(null);this.composing=-1;this.compositionFirstChange=null;this.compositionEndedAt=0;this.compositionPendingKey=false;this.compositionPendingChange=false;this.mouseSelection=null;this.draggedContent=null;this.handleEvent=this.handleEvent.bind(this);this.notifiedFocused=t.hasFocus;ft.safari&&t.contentDOM.addEventListener("input",(()=>null));ft.gecko&&Xi(t.contentDOM.ownerDocument)}handleEvent(t){yi(this.view,t)&&!this.ignoreDuringComposition(t)&&(t.type=="keydown"&&this.keydown(t)||(this.view.updateState!=0?Promise.resolve().then((()=>this.runHandlers(t.type,t))):this.runHandlers(t.type,t)))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let t of i.observers)t(this.view,e);for(let t of i.handlers){if(e.defaultPrevented)break;if(t(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=ci(t),i=this.handlers,s=this.view.contentDOM;for(let t in e)if(t!="scroll"){let o=!e[t].handlers.length;let n=i[t];if(n&&o!=!n.handlers.length){s.removeEventListener(t,this.handleEvent);n=null}n||s.addEventListener(t,this.handleEvent,{passive:o})}for(let t in i)t=="scroll"||e[t]||s.removeEventListener(t,this.handleEvent);this.handlers=e}keydown(t){this.lastKeyCode=t.keyCode;this.lastKeyTime=Date.now();if(t.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return true;this.tabFocusMode>0&&t.keyCode!=27&&ui.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1);if(ft.android&&ft.chrome&&!t.synthetic&&(t.keyCode==13||t.keyCode==8)){this.view.observer.delayAndroidKey(t.key,t.keyCode);return true}let e;if(ft.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&((e=di.find((e=>e.keyCode==t.keyCode)))&&!t.ctrlKey||fi.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)){this.pendingIOSKey=e||t;setTimeout((()=>this.flushIOSKey()),250);return true}t.keyCode!=229&&this.view.observer.forceFlush();return false}flushIOSKey(t){let e=this.pendingIOSKey;if(!e)return false;if(e.key=="Enter"&&t&&t.from<t.to&&/^\S+$/.test(t.insert.toString()))return false;this.pendingIOSKey=void 0;return K(this.view.contentDOM,e.key,e.keyCode,e instanceof KeyboardEvent?e:void 0)}ignoreDuringComposition(t){if(!/^key/.test(t.type))return false;if(this.composing>0)return true;if(ft.safari&&!ft.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100){this.compositionPendingKey=false;return true}return false}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy();this.mouseSelection=t}update(t){this.view.observer.update(t);this.mouseSelection&&this.mouseSelection.update(t);this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes));t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function hi(t,e){return(i,s)=>{try{return e.call(t,s,i)}catch(t){fe(i.state,t)}}}function ci(t){let e=Object.create(null);function i(t){return e[t]||(e[t]={observers:[],handlers:[]})}for(let e of t){let t=e.spec,s=t&&t.plugin.domEventHandlers,o=t&&t.plugin.domEventObservers;if(s)for(let t in s){let o=s[t];o&&i(t).handlers.push(hi(e.value,o))}if(o)for(let t in o){let s=o[t];s&&i(t).observers.push(hi(e.value,s))}}for(let t in Mi)i(t).handlers.push(Mi[t]);for(let t in xi)i(t).observers.push(xi[t]);return e}const di=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}];const fi="dthko";const ui=[16,17,18,20,91,92,224,225];const pi=6;function gi(t){return Math.max(0,t)*.7+8}function mi(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class MouseSelection{constructor(t,e,i,s){this.view=t;this.startEvent=e;this.style=i;this.mustSelect=s;this.scrollSpeed={x:0,y:0};this.scrolling=-1;this.lastEvent=e;this.scrollParents=F(t.contentDOM);this.atoms=t.state.facet(ye).map((e=>e(t)));let o=t.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this));o.addEventListener("mouseup",this.up=this.up.bind(this));this.extend=e.shiftKey;this.multiple=t.state.facet(d.allowMultipleSelections)&&wi(t,e);this.dragging=!(!bi(t,e)||Pi(e)!=1)&&null}start(t){this.dragging===false&&this.select(t)}move(t){if(t.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&mi(this.startEvent,t)<10)return;this.select(this.lastEvent=t);let e=0,i=0;let s=0,o=0,n=this.view.win.innerWidth,r=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:n}=this.scrollParents.x.getBoundingClientRect());this.scrollParents.y&&({top:o,bottom:r}=this.scrollParents.y.getBoundingClientRect());let l=Ce(this.view);t.clientX-l.left<=s+pi?e=-gi(s-t.clientX):t.clientX+l.right>=n-pi&&(e=gi(t.clientX-n));t.clientY-l.top<=o+pi?i=-gi(o-t.clientY):t.clientY+l.bottom>=r-pi&&(i=gi(t.clientY-r));this.setScrollSpeed(e,i)}up(t){this.dragging==null&&this.select(this.lastEvent);this.dragging||t.preventDefault();this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move);t.removeEventListener("mouseup",this.up);this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e};if(t||e)this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50));else if(this.scrolling>-1){clearInterval(this.scrolling);this.scrolling=-1}}scroll(){let{x:t,y:e}=this.scrollSpeed;if(t&&this.scrollParents.x){this.scrollParents.x.scrollLeft+=t;t=0}if(e&&this.scrollParents.y){this.scrollParents.y.scrollTop+=e;e=0}(t||e)&&this.view.win.scrollBy(t,e);this.dragging===false&&this.select(this.lastEvent)}select(t){let{view:e}=this,i=Ze(this.atoms,this.style.get(t,this.extend,this.multiple));!this.mustSelect&&i.eq(e.state.selection,this.dragging===false)||this.view.dispatch({selection:i,userEvent:"select.pointer"});this.mustSelect=false}update(t){t.transactions.some((t=>t.isUserEvent("input.type")))?this.destroy():this.style.update(t)&&setTimeout((()=>this.select(this.lastEvent)),20)}}function wi(t,e){let i=t.state.facet(Jt);return i.length?i[0](e):ft.mac?e.metaKey:e.ctrlKey}function vi(t,e){let i=t.state.facet(Zt);return i.length?i[0](e):ft.mac?!e.altKey:!e.ctrlKey}function bi(t,e){let{main:i}=t.state.selection;if(i.empty)return false;let s=D(t.root);if(!s||s.rangeCount==0)return true;let o=s.getRangeAt(0).getClientRects();for(let t=0;t<o.length;t++){let i=o[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return true}return false}function yi(t,e){if(!e.bubbles)return true;if(e.defaultPrevented)return false;for(let i,s=e.target;s!=t.contentDOM;s=s.parentNode)if(!s||s.nodeType==11||(i=ContentView.get(s))&&i.ignoreEvent(e))return false;return true}const Mi=Object.create(null);const xi=Object.create(null);const Si=ft.ie&&ft.ie_version<15||ft.ios&&ft.webkit_version<604;function Ci(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px";i.focus();setTimeout((()=>{t.focus();i.remove();Di(t,i.value)}),50)}function ki(t,e,i){for(let s of t.facet(e))i=s(i,t);return i}function Di(t,e){e=ki(t.state,ne,e);let i,{state:s}=t,o=1,r=s.toText(e);let l=r.lines==s.selection.ranges.length;let a=Ii!=null&&s.selection.ranges.every((t=>t.empty))&&Ii==r.toString();if(a){let t=-1;i=s.changeByRange((i=>{let a=s.doc.lineAt(i.from);if(a.from==t)return{range:i};t=a.from;let h=s.toText((l?r.line(o++).text:e)+s.lineBreak);return{changes:{from:a.from,insert:h},range:n.cursor(i.from+h.length)}}))}else i=l?s.changeByRange((t=>{let e=r.line(o++);return{changes:{from:t.from,to:t.to,insert:e.text},range:n.cursor(t.from+e.length)}})):s.replaceSelection(r);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:true})}xi.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop;t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft};Mi.keydown=(t,e)=>{t.inputState.setSelectionOrigin("select");e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3);return false};xi.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now();t.inputState.setSelectionOrigin("select.pointer")};xi.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};Mi.mousedown=(t,e)=>{t.observer.flush();if(t.inputState.lastTouchTime>Date.now()-2e3)return false;let i=null;for(let s of t.state.facet(te)){i=s(t,e);if(i)break}i||e.button!=0||(i=Hi(t,e));if(i){let s=!t.hasFocus;t.inputState.startMouseSelection(new MouseSelection(t,e,i,s));s&&t.observer.ignore((()=>{I(t.contentDOM);let e=t.root.activeElement;e&&!e.contains(t.contentDOM)&&e.blur()}));let o=t.inputState.mouseSelection;if(o){o.start(e);return o.dragging===false}}else t.inputState.setSelectionOrigin("select.pointer");return false};function Ai(t,e,i,s){if(s==1)return n.cursor(e,i);if(s==2)return Le(t.state,e,i);{let i=LineView.find(t.docView,e),s=t.state.doc.lineAt(i?i.posAtEnd:e);let o=i?i.posAtStart:s.from,r=i?i.posAtEnd:s.to;r<t.state.doc.length&&r==s.to&&r++;return n.range(o,r)}}let Oi=(t,e,i)=>e>=i.top&&e<=i.bottom&&t>=i.left&&t<=i.right;function Ti(t,e,i,s){let o=LineView.find(t.docView,e);if(!o)return 1;let n=e-o.posAtStart;if(n==0)return 1;if(n==o.length)return-1;let r=o.coordsAt(n,-1);if(r&&Oi(i,s,r))return-1;let l=o.coordsAt(n,1);return l&&Oi(i,s,l)?1:r&&r.bottom>=s?-1:1}function Vi(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},false);return{pos:i,bias:Ti(t,i,e.clientX,e.clientY)}}const Ei=ft.ie&&ft.ie_version<=11;let Bi=null,Ri=0,Li=0;function Pi(t){if(!Ei)return t.detail;let e=Bi,i=Li;Bi=t;Li=Date.now();return Ri=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Ri+1)%3:1}function Hi(t,e){let i=Vi(t,e),s=Pi(e);let o=t.state.selection;return{update(t){if(t.docChanged){i.pos=t.changes.mapPos(i.pos);o=o.map(t.changes)}},get(e,r,l){let a,h=Vi(t,e);let c=Ai(t,h.pos,h.bias,s);if(i.pos!=h.pos&&!r){let e=Ai(t,i.pos,i.bias,s);let o=Math.min(e.from,c.from),r=Math.max(e.to,c.to);c=o<c.from?n.range(o,r):n.range(r,o)}return r?o.replaceRange(o.main.extend(c.from,c.to)):l&&s==1&&o.ranges.length>1&&(a=Ni(o,h.pos))?a:l?o.addRange(c):n.create([c])}}}function Ni(t,e){for(let i=0;i<t.ranges.length;i++){let{from:s,to:o}=t.ranges[i];if(s<=e&&o>=e)return n.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let s=t.docView.nearest(e.target);if(s&&s.isWidget){let t=s.posAtStart,e=t+s.length;(t>=i.to||e<=i.from)&&(i=n.range(t,e))}}let{inputState:s}=t;s.mouseSelection&&(s.mouseSelection.dragging=true);s.draggedContent=i;if(e.dataTransfer){e.dataTransfer.setData("Text",ki(t.state,re,t.state.sliceDoc(i.from,i.to)));e.dataTransfer.effectAllowed="copyMove"}return false};Mi.dragend=t=>{t.inputState.draggedContent=null;return false};function Wi(t,e,i,s){i=ki(t.state,ne,i);if(!i)return;let o=t.posAtCoords({x:e.clientX,y:e.clientY},false);let{draggedContent:n}=t.inputState;let r=s&&n&&vi(t,e)?{from:n.from,to:n.to}:null;let l={from:o,insert:i};let a=t.state.changes(r?[r,l]:l);t.focus();t.dispatch({changes:a,selection:{anchor:a.mapPos(o,-1),head:a.mapPos(o,1)},userEvent:r?"move.drop":"input.drop"});t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return false;if(t.state.readOnly)return true;let i=e.dataTransfer.files;if(i&&i.length){let s=Array(i.length),o=0;let n=()=>{++o==i.length&&Wi(t,e,s.filter((t=>t!=null)).join(t.state.lineBreak),false)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=n;e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(s[t]=e.result);n()};e.readAsText(i[t])}return true}{let i=e.dataTransfer.getData("Text");if(i){Wi(t,e,i,true);return true}}return false};Mi.paste=(t,e)=>{if(t.state.readOnly)return true;t.observer.flush();let i=Si?null:e.clipboardData;if(i){Di(t,i.getData("text/plain")||i.getData("text/uri-list"));return true}Ci(t);return false};function Fi(t,e){let i=t.dom.parentNode;if(!i)return;let s=i.appendChild(document.createElement("textarea"));s.style.cssText="position: fixed; left: -10000px; top: 10px";s.value=e;s.focus();s.selectionEnd=e.length;s.selectionStart=0;setTimeout((()=>{s.remove();t.focus()}),50)}function zi(t){let e=[],i=[],s=false;for(let s of t.selection.ranges)if(!s.empty){e.push(t.sliceDoc(s.from,s.to));i.push(s)}if(!e.length){let o=-1;for(let{from:s}of t.selection.ranges){let n=t.doc.lineAt(s);if(n.number>o){e.push(n.text);i.push({from:n.from,to:Math.min(t.doc.length,n.to+1)})}o=n.number}s=true}return{text:ki(t,re,e.join(t.lineBreak)),ranges:i,linewise:s}}let Ii=null;Mi.copy=Mi.cut=(t,e)=>{let{text:i,ranges:s,linewise:o}=zi(t.state);if(!i&&!o)return false;Ii=o?i:null;e.type!="cut"||t.state.readOnly||t.dispatch({changes:s,scrollIntoView:true,userEvent:"delete.cut"});let n=Si?null:e.clipboardData;if(n){n.clearData();n.setData("text/plain",i);return true}Fi(t,i);return false};const qi=f.define();function Gi(t,e){let i=[];for(let s of t.facet(oe)){let o=s(t,e);o&&i.push(o)}return i.length?t.update({effects:i,annotations:qi.of(true)}):null}function Ki(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=Gi(t.state,e);i?t.dispatch(i):t.update([])}}),10)}xi.focus=t=>{t.inputState.lastFocusTime=Date.now();if(!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)){t.scrollDOM.scrollTop=t.inputState.lastScrollTop;t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft}Ki(t)};xi.blur=t=>{t.observer.clearSelectionRange();Ki(t)};xi.compositionstart=xi.compositionupdate=t=>{if(!t.observer.editContext){t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=true);t.inputState.composing<0&&(t.inputState.composing=0)}};xi.compositionend=t=>{if(!t.observer.editContext){t.inputState.composing=-1;t.inputState.compositionEndedAt=Date.now();t.inputState.compositionPendingKey=true;t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0;t.inputState.compositionFirstChange=null;ft.chrome&&ft.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then((()=>t.observer.flush())):setTimeout((()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])}),50)}};xi.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};Mi.beforeinput=(t,e)=>{var i,s;if(e.inputType=="insertReplacementText"&&t.observer.editContext){let s=(i=e.dataTransfer)===null||i===void 0?void 0:i.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let e=o[0];let i=t.posAtDOM(e.startContainer,e.startOffset),n=t.posAtDOM(e.endContainer,e.endOffset);oi(t,{from:i,to:n,insert:t.state.toText(s)},null);return true}}let o;if(ft.chrome&&ft.android&&(o=di.find((t=>t.inputType==e.inputType)))){t.observer.delayAndroidKey(o.key,o.keyCode);if(o.key=="Backspace"||o.key=="Delete"){let e=((s=window.visualViewport)===null||s===void 0?void 0:s.height)||0;setTimeout((()=>{var i;if((((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0)>e+10&&t.hasFocus){t.contentDOM.blur();t.focus()}}),100)}}ft.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon();ft.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout((()=>xi.compositionend(t,e)),20);return false};const Yi=new Set;function Xi(t){if(!Yi.has(t)){Yi.add(t);t.addEventListener("copy",(()=>{}));t.addEventListener("cut",(()=>{}))}}const _i=["pre-wrap","normal","pre-line","break-spaces"];let ji=false;function Ui(){ji=false}class HeightOracle{constructor(e){this.lineWrapping=e;this.doc=t.empty;this.heightSamples={};this.lineHeight=14;this.charWidth=7;this.textHeight=14;this.lineLength=30}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength)));return this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;let e=1+Math.max(0,Math.ceil((t-this.lineLength)/Math.max(1,this.lineLength-5)));return e*this.lineHeight}setDoc(t){this.doc=t;return this}mustRefreshForWrapping(t){return _i.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=false;for(let i=0;i<t.length;i++){let s=t[i];if(s<0)i++;else if(!this.heightSamples[Math.floor(s*10)]){e=true;this.heightSamples[Math.floor(s*10)]=true}}return e}refresh(t,e,i,s,o,n){let r=_i.indexOf(t)>-1;let l=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=r;this.lineWrapping=r;this.lineHeight=e;this.charWidth=i;this.textHeight=s;this.lineLength=o;if(l){this.heightSamples={};for(let t=0;t<n.length;t++){let e=n[t];e<0?t++:this.heightSamples[Math.floor(e*10)]=true}}return l}}class MeasuredHeights{constructor(t,e){this.from=t;this.heights=e;this.index=0}get more(){return this.index<this.heights.length}}class BlockInfo{constructor(t,e,i,s,o){this.from=t;this.length=e;this.top=i;this.height=s;this._content=o}get type(){return typeof this._content=="number"?kt.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof PointDecoration?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new BlockInfo(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var $i=function(t){t[t.ByPos=0]="ByPos";t[t.ByHeight=1]="ByHeight";t[t.ByPosNoHeight=2]="ByPosNoHeight";return t}($i||($i={}));const Qi=.001;class HeightMap{constructor(t,e,i=2){this.length=t;this.height=e;this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(t){this.flags=(t?2:0)|this.flags&-3}setHeight(t){if(this.height!=t){Math.abs(this.height-t)>Qi&&(ji=true);this.height=t}}replace(t,e,i){return HeightMap.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,s){let o=this,n=i.doc;for(let r=s.length-1;r>=0;r--){let{fromA:l,toA:a,fromB:h,toB:c}=s[r];let d=o.lineAt(l,$i.ByPosNoHeight,i.setDoc(e),0,0);let f=d.to>=a?d:o.lineAt(a,$i.ByPosNoHeight,i,0,0);c+=f.to-a;a=f.to;while(r>0&&d.from<=s[r-1].toA){l=s[r-1].fromA;h=s[r-1].fromB;r--;l<d.from&&(d=o.lineAt(l,$i.ByPosNoHeight,i,0,0))}h+=d.from-l;l=d.from;let u=NodeBuilder.build(i.setDoc(n),t,h,c);o=Ji(o,o.replace(l,a,u))}return o.updateHeight(i,0)}static empty(){return new HeightMapText(0,0)}static of(t){if(t.length==1)return t[0];let e=0,i=t.length,s=0,o=0;for(;;)if(e==i)if(s>o*2){let o=t[e-1];o.break?t.splice(--e,1,o.left,null,o.right):t.splice(--e,1,o.left,o.right);i+=1+o.break;s-=o.size}else{if(!(o>s*2))break;{let e=t[i];e.break?t.splice(i,1,e.left,null,e.right):t.splice(i,1,e.left,e.right);i+=2+e.break;o-=e.size}}else if(s<o){let i=t[e++];i&&(s+=i.size)}else{let e=t[--i];e&&(o+=e.size)}let n=0;if(t[e-1]==null){n=1;e--}else if(t[e]==null){n=1;i++}return new HeightMapBranch(HeightMap.of(t.slice(0,e)),n,HeightMap.of(t.slice(i)))}}function Ji(t,e){if(t==e)return t;t.constructor!=e.constructor&&(ji=true);return e}HeightMap.prototype.size=1;class HeightMapBlock extends HeightMap{constructor(t,e,i){super(t,e);this.deco=i}blockAt(t,e,i,s){return new BlockInfo(s,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,s,o){return this.blockAt(0,i,s,o)}forEachLine(t,e,i,s,o,n){t<=o+this.length&&e>=o&&n(this.blockAt(0,i,s,o))}updateHeight(t,e=0,i=false,s){s&&s.from<=e&&s.more&&this.setHeight(s.heights[s.index++]);this.outdated=false;return this}toString(){return`block(${this.length})`}}class HeightMapText extends HeightMapBlock{constructor(t,e){super(t,e,null);this.collapsed=0;this.widgetHeight=0;this.breaks=0}blockAt(t,e,i,s){return new BlockInfo(s,this.length,i,this.height,this.breaks)}replace(t,e,i){let s=i[0];if(i.length==1&&(s instanceof HeightMapText||s instanceof HeightMapGap&&s.flags&4)&&Math.abs(this.length-s.length)<10){s instanceof HeightMapGap?s=new HeightMapText(s.length,this.height):s.height=this.height;this.outdated||(s.outdated=false);return s}return HeightMap.of(i)}updateHeight(t,e=0,i=false,s){s&&s.from<=e&&s.more?this.setHeight(s.heights[s.index++]):(i||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight);this.outdated=false;return this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class HeightMapGap extends HeightMap{constructor(t){super(t,0)}heightMetrics(t,e){let i=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number;let o=s-i+1;let n,r=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*o);n=e/o;this.length>o+1&&(r=(this.height-e)/(this.length-o-1))}else n=this.height/o;return{firstLine:i,lastLine:s,perLine:n,perChar:r}}blockAt(t,e,i,s){let{firstLine:o,lastLine:n,perLine:r,perChar:l}=this.heightMetrics(e,s);if(e.lineWrapping){let o=s+(t<e.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length));let n=e.doc.lineAt(o),a=r+n.length*l;let h=Math.max(i,t-a/2);return new BlockInfo(n.from,n.length,h,a,0)}{let s=Math.max(0,Math.min(n-o,Math.floor((t-i)/r)));let{from:l,length:a}=e.doc.line(o+s);return new BlockInfo(l,a,i+r*s,r,0)}}lineAt(t,e,i,s,o){if(e==$i.ByHeight)return this.blockAt(t,i,s,o);if(e==$i.ByPosNoHeight){let{from:e,to:s}=i.doc.lineAt(t);return new BlockInfo(e,s-e,0,0,0)}let{firstLine:n,perLine:r,perChar:l}=this.heightMetrics(i,o);let a=i.doc.lineAt(t),h=r+a.length*l;let c=a.number-n;let d=s+r*c+l*(a.from-o-c);return new BlockInfo(a.from,a.length,Math.max(s,Math.min(d,s+this.height-h)),h,0)}forEachLine(t,e,i,s,o,n){t=Math.max(t,o);e=Math.min(e,o+this.length);let{firstLine:r,perLine:l,perChar:a}=this.heightMetrics(i,o);for(let h=t,c=s;h<=e;){let e=i.doc.lineAt(h);if(h==t){let i=e.number-r;c+=l*i+a*(t-o-i)}let s=l+a*e.length;n(new BlockInfo(e.from,e.length,c,s,0));c+=s;h=e.to+1}}replace(t,e,i){let s=this.length-e;if(s>0){let t=i[i.length-1];t instanceof HeightMapGap?i[i.length-1]=new HeightMapGap(t.length+s):i.push(null,new HeightMapGap(s-1))}if(t>0){let e=i[0];e instanceof HeightMapGap?i[0]=new HeightMapGap(t+e.length):i.unshift(new HeightMapGap(t-1),null)}return HeightMap.of(i)}decomposeLeft(t,e){e.push(new HeightMapGap(t-1),null)}decomposeRight(t,e){e.push(null,new HeightMapGap(this.length-t-1))}updateHeight(t,e=0,i=false,s){let o=e+this.length;if(s&&s.from<=e+this.length&&s.more){let i=[],n=Math.max(e,s.from),r=-1;s.from>e&&i.push(new HeightMapGap(s.from-e-1).updateHeight(t,e));while(n<=o&&s.more){let e=t.doc.lineAt(n).length;i.length&&i.push(null);let o=s.heights[s.index++];r==-1?r=o:Math.abs(o-r)>=Qi&&(r=-2);let l=new HeightMapText(e,o);l.outdated=false;i.push(l);n+=e+1}n<=o&&i.push(null,new HeightMapGap(o-n).updateHeight(t,n));let l=HeightMap.of(i);(r<0||Math.abs(l.height-this.height)>=Qi||Math.abs(r-this.heightMetrics(t,e).perLine)>=Qi)&&(ji=true);return Ji(this,l)}if(i||this.outdated){this.setHeight(t.heightForGap(e,e+this.length));this.outdated=false}return this}toString(){return`gap(${this.length})`}}class HeightMapBranch extends HeightMap{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0));this.left=t;this.right=i;this.size=t.size+i.size}get break(){return this.flags&1}blockAt(t,e,i,s){let o=i+this.left.height;return t<o?this.left.blockAt(t,e,i,s):this.right.blockAt(t,e,o,s+this.left.length+this.break)}lineAt(t,e,i,s,o){let n=s+this.left.height,r=o+this.left.length+this.break;let l=e==$i.ByHeight?t<n:t<r;let a=l?this.left.lineAt(t,e,i,s,o):this.right.lineAt(t,e,i,n,r);if(this.break||(l?a.to<r:a.from>r))return a;let h=e==$i.ByPosNoHeight?$i.ByPosNoHeight:$i.ByPos;return l?a.join(this.right.lineAt(r,h,i,n,r)):this.left.lineAt(r,h,i,s,o).join(a)}forEachLine(t,e,i,s,o,n){let r=s+this.left.height,l=o+this.left.length+this.break;if(this.break){t<l&&this.left.forEachLine(t,e,i,s,o,n);e>=l&&this.right.forEachLine(t,e,i,r,l,n)}else{let a=this.lineAt(l,$i.ByPos,i,s,o);t<a.from&&this.left.forEachLine(t,a.from-1,i,s,o,n);a.to>=t&&a.from<=e&&n(a);e>a.to&&this.right.forEachLine(a.to+1,e,i,r,l,n)}}replace(t,e,i){let s=this.left.length+this.break;if(e<s)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-s,e-s,i));let o=[];t>0&&this.decomposeLeft(t,o);let n=o.length;for(let t of i)o.push(t);t>0&&Zi(o,n-1);if(e<this.length){let t=o.length;this.decomposeRight(e,o);Zi(o,t)}return HeightMap.of(o)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left);if(this.break){i++;t>=i&&e.push(null)}t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,s=i+this.break;if(t>=s)return this.right.decomposeRight(t-s,e);t<i&&this.left.decomposeRight(t,e);this.break&&t<s&&e.push(null);e.push(this.right)}balanced(t,e){if(t.size>2*e.size||e.size>2*t.size)return HeightMap.of(this.break?[t,null,e]:[t,e]);this.left=Ji(this.left,t);this.right=Ji(this.right,e);this.setHeight(t.height+e.height);this.outdated=t.outdated||e.outdated;this.size=t.size+e.size;this.length=t.length+this.break+e.length;return this}updateHeight(t,e=0,i=false,s){let{left:o,right:n}=this,r=e+o.length+this.break,l=null;s&&s.from<=e+o.length&&s.more?l=o=o.updateHeight(t,e,i,s):o.updateHeight(t,e,i);s&&s.from<=r+n.length&&s.more?l=n=n.updateHeight(t,r,i,s):n.updateHeight(t,r,i);if(l)return this.balanced(o,n);this.height=this.left.height+this.right.height;this.outdated=false;return this}toString(){return this.left+(this.break?" ":"-")+this.right}}function Zi(t,e){let i,s;t[e]==null&&(i=t[e-1])instanceof HeightMapGap&&(s=t[e+1])instanceof HeightMapGap&&t.splice(e-1,3,new HeightMapGap(i.length+1+s.length))}const ts=5;class NodeBuilder{constructor(t,e){this.pos=t;this.oracle=e;this.nodes=[];this.lineStart=-1;this.lineEnd=-1;this.covering=null;this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof HeightMapText?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new HeightMapText(t-this.pos,-1));this.writtenTo=t;if(e>t){this.nodes.push(null);this.writtenTo++;this.lineStart=-1}}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let s=i.widget?i.widget.estimatedHeight:0;let o=i.widget?i.widget.lineBreaks:0;s<0&&(s=this.oracle.lineHeight);let n=e-t;i.block?this.addBlock(new HeightMapBlock(n,s,i)):(n||o||s>=ts)&&this.addLineDeco(s,o,n)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t;this.lineEnd=e;if(this.writtenTo<t){(this.writtenTo<t-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,t-1));this.nodes.push(null)}this.pos>t&&this.nodes.push(new HeightMapText(this.pos-t,-1));this.writtenTo=this.pos}blankContent(t,e){let i=new HeightMapGap(e-t);this.oracle.doc.lineAt(t).to==e&&(i.flags|=4);return i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof HeightMapText)return t;let e=new HeightMapText(0,-1);this.nodes.push(e);return e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine();this.nodes.push(t);this.writtenTo=this.pos=this.pos+t.length;e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let s=this.ensureLine();s.length+=i;s.collapsed+=i;s.widgetHeight=Math.max(s.widgetHeight,t);s.breaks+=e;this.writtenTo=this.pos=this.pos+i}finish(t){let e=this.nodes.length==0?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof HeightMapText||this.isCovered?(this.writtenTo<this.pos||e==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new HeightMapText(0,-1));let i=t;for(let t of this.nodes){t instanceof HeightMapText&&t.updateHeight(this.oracle,i);i+=t?t.length:1}return this.nodes}static build(t,e,s,o){let n=new NodeBuilder(s,t);i.spans(e,s,o,n,0);return n.finish(s)}}function es(t,e,s){let o=new DecorationComparator;i.compare(t,e,s,o,0);return o.changes}class DecorationComparator{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,s){(t<e||i&&i.heightRelevant||s&&s.heightRelevant)&&Ot(t,e,this.changes,5)}}function is(t,e){let i=t.getBoundingClientRect();let s=t.ownerDocument,o=s.defaultView||window;let n=Math.max(0,i.left),r=Math.min(o.innerWidth,i.right);let l=Math.max(0,i.top),a=Math.min(o.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=s.body;)if(e.nodeType==1){let i=e;let s=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&s.overflow!="visible"){let s=i.getBoundingClientRect();n=Math.max(n,s.left);r=Math.min(r,s.right);l=Math.max(l,s.top);a=Math.min(e==t.parentNode?o.innerHeight:a,s.bottom)}e=s.position=="absolute"||s.position=="fixed"?i.offsetParent:i.parentNode}else{if(e.nodeType!=11)break;e=e.host}return{left:n-i.left,right:Math.max(n,r)-i.left,top:l-(i.top+e),bottom:Math.max(l,a)-(i.top+e)}}function ss(t){let e=t.getBoundingClientRect(),i=t.ownerDocument.defaultView||window;return e.left<i.innerWidth&&e.right>0&&e.top<i.innerHeight&&e.bottom>0}function os(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class LineGap{constructor(t,e,i,s){this.from=t;this.to=e;this.size=i;this.displaySize=s}static same(t,e){if(t.length!=e.length)return false;for(let i=0;i<t.length;i++){let s=t[i],o=e[i];if(s.from!=o.from||s.to!=o.to||s.size!=o.size)return false}return true}draw(t,e){return Decoration.replace({widget:new LineGapWidget(this.displaySize*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class LineGapWidget extends WidgetType{constructor(t,e){super();this.size=t;this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");if(this.vertical)t.style.height=this.size+"px";else{t.style.width=this.size+"px";t.style.height="2px";t.style.display="inline-block"}return t}get estimatedHeight(){return this.vertical?this.size:-1}}class ViewState{constructor(e){this.state=e;this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0};this.inView=true;this.paddingTop=0;this.paddingBottom=0;this.contentDOMWidth=0;this.contentDOMHeight=0;this.editorHeight=0;this.editorWidth=0;this.scrollTop=0;this.scrolledToBottom=false;this.scaleX=1;this.scaleY=1;this.scrollAnchorPos=0;this.scrollAnchorHeight=-1;this.scaler=hs;this.scrollTarget=null;this.printing=false;this.mustMeasureContent=true;this.defaultTextDirection=Vt.LTR;this.visibleRanges=[];this.mustEnforceCursorAssoc=false;let i=e.facet(we).some((t=>typeof t!="function"&&t.class=="cm-lineWrapping"));this.heightOracle=new HeightOracle(i);this.stateDeco=e.facet(ve).filter((t=>typeof t!="function"));this.heightMap=HeightMap.empty().applyChanges(this.stateDeco,t.empty,this.heightOracle.setDoc(e.doc),[new ChangedRange(0,0,0,e.doc.length)]);for(let t=0;t<2;t++){this.viewport=this.getViewport(0,null);if(!this.updateForViewport())break}this.updateViewportLines();this.lineGaps=this.ensureLineGaps([]);this.lineGapDeco=Decoration.set(this.lineGaps.map((t=>t.draw(this,false))));this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let s=i?e.head:e.anchor;if(!t.some((({from:t,to:e})=>s>=t&&s<=e))){let{from:e,to:i}=this.lineBlockAt(s);t.push(new Viewport(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from));return this.updateScaler()}updateScaler(){let t=this.scaler;this.scaler=this.heightMap.height<=7e6?hs:new BigScaler(this.heightOracle,this.heightMap,this.viewports);return t.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[];this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(t=>{this.viewportLines.push(cs(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(ve).filter((t=>typeof t!="function"));let s=t.changedRanges;let o=ChangedRange.extendWithRanges(s,es(i,this.stateDeco,t?t.changes:a.empty(this.state.doc.length)));let n=this.heightMap.height;let r=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);Ui();this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),o);(this.heightMap.height!=n||ji)&&(t.flags|=2);if(r){this.scrollAnchorPos=t.changes.mapPos(r.from,-1);this.scrollAnchorHeight=r.top}else{this.scrollAnchorPos=-1;this.scrollAnchorHeight=n}let l=o.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<l.from||e.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,e));let h=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l;t.flags|=this.updateForViewport();(h||!t.changes.empty||t.flags&2)&&this.updateViewportLines();(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes)));t.flags|=this.computeVisibleRanges(t.changes);e&&(this.scrollTarget=e);!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(ae)&&(this.mustEnforceCursorAssoc=true)}measure(e){let i=e.contentDOM,s=window.getComputedStyle(i);let o=this.heightOracle;let n=s.whiteSpace;this.defaultTextDirection=s.direction=="rtl"?Vt.RTL:Vt.LTR;let r=this.heightOracle.mustRefreshForWrapping(n);let l=i.getBoundingClientRect();let a=r||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height;this.mustMeasureContent=false;let h=0,c=0;if(l.width&&l.height){let{scaleX:t,scaleY:e}=N(i,l);if(t>.005&&Math.abs(this.scaleX-t)>.005||e>.005&&Math.abs(this.scaleY-e)>.005){this.scaleX=t;this.scaleY=e;h|=16;r=a=true}}let d=(parseInt(s.paddingTop)||0)*this.scaleY;let f=(parseInt(s.paddingBottom)||0)*this.scaleY;if(this.paddingTop!=d||this.paddingBottom!=f){this.paddingTop=d;this.paddingBottom=f;h|=18}if(this.editorWidth!=e.scrollDOM.clientWidth){o.lineWrapping&&(a=true);this.editorWidth=e.scrollDOM.clientWidth;h|=16}let u=e.scrollDOM.scrollTop*this.scaleY;if(this.scrollTop!=u){this.scrollAnchorHeight=-1;this.scrollTop=u}this.scrolledToBottom=j(e.scrollDOM);let p=(this.printing?os:is)(i,this.paddingTop);let g=p.top-this.pixelViewport.top,m=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let w=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(w!=this.inView){this.inView=w;w&&(a=true)}if(!this.inView&&!this.scrollTarget&&!ss(e.dom))return 0;let v=l.width;if(this.contentDOMWidth!=v||this.editorHeight!=e.scrollDOM.clientHeight){this.contentDOMWidth=l.width;this.editorHeight=e.scrollDOM.clientHeight;h|=16}if(a){let i=e.docView.measureVisibleLineHeights(this.viewport);o.mustRefreshForHeights(i)&&(r=true);if(r||o.lineWrapping&&Math.abs(v-this.contentDOMWidth)>o.charWidth){let{lineHeight:t,charWidth:s,textHeight:l}=e.docView.measureTextSize();r=t>0&&o.refresh(n,t,s,l,Math.max(5,v/s),i);if(r){e.docView.minWidth=0;h|=16}}g>0&&m>0?c=Math.max(g,m):g<0&&m<0&&(c=Math.min(g,m));Ui();for(let s of this.viewports){let n=s.from==this.viewport.from?i:e.docView.measureVisibleLineHeights(s);this.heightMap=(r?HeightMap.empty().applyChanges(this.stateDeco,t.empty,this.heightOracle,[new ChangedRange(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(o,0,r,new MeasuredHeights(s.from,n))}ji&&(h|=2)}let b=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);if(b){h&2&&(h|=this.updateScaler());this.viewport=this.getViewport(c,this.scrollTarget);h|=this.updateForViewport()}(h&2||b)&&this.updateViewportLines();(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(r?[]:this.lineGaps,e));h|=this.computeVisibleRanges();if(this.mustEnforceCursorAssoc){this.mustEnforceCursorAssoc=false;e.docView.enforceCursorAssoc()}return h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2));let s=this.heightMap,o=this.heightOracle;let{visibleTop:n,visibleBottom:r}=this;let l=new Viewport(s.lineAt(n-i*1e3,$i.ByHeight,o,0,0).from,s.lineAt(r+1e3*(1-i),$i.ByHeight,o,0,0).to);if(e){let{head:t}=e.range;if(t<l.from||t>l.to){let i=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top);let n,r=s.lineAt(t,$i.ByPos,o,0,0);n=e.y=="center"?(r.top+r.bottom)/2-i/2:e.y=="start"||e.y=="nearest"&&t<l.from?r.top:r.bottom-i;l=new Viewport(s.lineAt(n-500,$i.ByHeight,o,0,0).from,s.lineAt(n+i+500,$i.ByHeight,o,0,0).to)}}return l}mapViewport(t,e){let i=e.mapPos(t.from,-1),s=e.mapPos(t.to,1);return new Viewport(this.heightMap.lineAt(i,$i.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(s,$i.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return true;let{top:s}=this.heightMap.lineAt(t,$i.ByPos,this.heightOracle,0,0);let{bottom:o}=this.heightMap.lineAt(e,$i.ByPos,this.heightOracle,0,0);let{visibleTop:n,visibleBottom:r}=this;return(t==0||s<=n-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||o>=r+Math.max(10,Math.min(i,250)))&&s>n-2e3&&o<r+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let s of t)e.touchesRange(s.from,s.to)||i.push(new LineGap(e.mapPos(s.from),e.mapPos(s.to),s.size,s.displaySize));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping;let s=i?1e4:2e3,o=s>>1,r=s<<1;if(this.defaultTextDirection!=Vt.LTR&&!i)return[];let l=[];let a=(s,r,h,c)=>{if(r-s<o)return;let d=this.state.selection.main,f=[d.from];d.empty||f.push(d.to);for(let t of f)if(t>s&&t<r){a(s,t-10,h,c);a(t+10,r,h,c);return}let u=as(t,(t=>t.from>=h.from&&t.to<=h.to&&Math.abs(t.from-s)<o&&Math.abs(t.to-r)<o&&!f.some((e=>t.from<e&&t.to>e))));if(!u){if(r<h.to&&e&&i&&e.visibleRanges.some((t=>t.from<=r&&t.to>=r))){let t=e.moveToLineBoundary(n.cursor(r),false,true).head;t>s&&(r=t)}let t=this.gapSize(h,s,r,c);let o=i||t<2e6?t:2e6;u=new LineGap(s,r,t,o)}l.push(u)};let h=e=>{if(e.length<r||e.type!=kt.Text)return;let o=ns(e.from,e.to,this.stateDeco);if(o.total<r)return;let n=this.scrollTarget?this.scrollTarget.range.head:null;let l,h;if(i){let t=s/this.heightOracle.lineLength*this.heightOracle.lineHeight;let i,r;if(n!=null){let s=ls(o,n);let l=((this.visibleBottom-this.visibleTop)/2+t)/e.height;i=s-l;r=s+l}else{i=(this.visibleTop-e.top-t)/e.height;r=(this.visibleBottom-e.top+t)/e.height}l=rs(o,i);h=rs(o,r)}else{let i=o.total*this.heightOracle.charWidth;let r=s*this.heightOracle.charWidth;let a=0;if(i>2e6)for(let i of t)i.from>=e.from&&i.from<e.to&&i.size!=i.displaySize&&i.from*this.heightOracle.charWidth+a<this.pixelViewport.left&&(a=i.size-i.displaySize);let c=this.pixelViewport.left+a,d=this.pixelViewport.right+a;let f,u;if(n!=null){let t=ls(o,n);let e=((d-c)/2+r)/i;f=t-e;u=t+e}else{f=(c-r)/i;u=(d+r)/i}l=rs(o,f);h=rs(o,u)}l>e.from&&a(e.from,l,e,o);h<e.to&&a(h,e.to,e,o)};for(let t of this.viewportLines)Array.isArray(t.type)?t.type.forEach(h):h(t);return l}gapSize(t,e,i,s){let o=ls(s,i)-ls(s,e);return this.heightOracle.lineWrapping?t.height*o:s.total*this.heightOracle.charWidth*o}updateLineGaps(t){if(!LineGap.same(t,this.lineGaps)){this.lineGaps=t;this.lineGapDeco=Decoration.set(t.map((t=>t.draw(this,this.heightOracle.lineWrapping))))}}computeVisibleRanges(t){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let s=[];i.spans(e,this.viewport.from,this.viewport.to,{span(t,e){s.push({from:t,to:e})},point(){}},20);let o=0;if(s.length!=this.visibleRanges.length)o=12;else for(let e=0;e<s.length&&!(o&8);e++){let i=this.visibleRanges[e],n=s[e];if(i.from!=n.from||i.to!=n.to){o|=4;t&&t.mapPos(i.from,-1)==n.from&&t.mapPos(i.to,1)==n.to||(o|=8)}}this.visibleRanges=s;return o}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find((e=>e.from<=t&&e.to>=t))||cs(this.heightMap.lineAt(t,$i.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find((e=>e.top<=t&&e.bottom>=t))||cs(this.heightMap.lineAt(this.scaler.fromDOM(t),$i.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return cs(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Viewport{constructor(t,e){this.from=t;this.to=e}}function ns(t,e,s){let o=[],n=t,r=0;i.spans(s,t,e,{span(){},point(t,e){if(t>n){o.push({from:n,to:t});r+=t-n}n=e}},20);if(n<e){o.push({from:n,to:e});r+=e-n}return{total:r,ranges:o}}function rs({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let s=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:o}=e[t],n=o-i;if(s<=n)return i+s;s-=n}}function ls(t,e){let i=0;for(let{from:s,to:o}of t.ranges){if(e<=o){i+=e-s;break}i+=o-s}return i/t.total}function as(t,e){for(let i of t)if(e(i))return i}const hs={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};class BigScaler{constructor(t,e,i){let s=0,o=0,n=0;this.viewports=i.map((({from:i,to:o})=>{let n=e.lineAt(i,$i.ByPos,t,0,0).top;let r=e.lineAt(o,$i.ByPos,t,0,0).bottom;s+=r-n;return{from:i,to:o,top:n,bottom:r,domTop:0,domBottom:0}}));this.scale=(7e6-s)/(e.height-s);for(let t of this.viewports){t.domTop=n+(t.top-o)*this.scale;n=t.domBottom=t.domTop+(t.bottom-t.top);o=t.bottom}}toDOM(t){for(let e=0,i=0,s=0;;e++){let o=e<this.viewports.length?this.viewports[e]:null;if(!o||t<o.top)return s+(t-i)*this.scale;if(t<=o.bottom)return o.domTop+(t-o.top);i=o.bottom;s=o.domBottom}}fromDOM(t){for(let e=0,i=0,s=0;;e++){let o=e<this.viewports.length?this.viewports[e]:null;if(!o||t<o.domTop)return i+(t-s)/this.scale;if(t<=o.domBottom)return o.top+(t-o.domTop);i=o.bottom;s=o.domBottom}}eq(t){return t instanceof BigScaler&&(this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every(((e,i)=>e.from==t.viewports[i].from&&e.to==t.viewports[i].to)))}}function cs(t,e){if(e.scale==1)return t;let i=e.toDOM(t.top),s=e.toDOM(t.bottom);return new BlockInfo(t.from,t.length,i,s-i,Array.isArray(t._content)?t._content.map((t=>cs(t,e))):t._content)}const ds=r.define({combine:t=>t.join(" ")});const fs=r.define({combine:t=>t.indexOf(true)>-1});const us=M.newName(),ps=M.newName(),gs=M.newName();const ms={"&light":"."+ps,"&dark":"."+gs};function ws(t,e,i){return new M(e,{finish(e){return/&/.test(e)?e.replace(/&\w*/,(e=>{if(e=="&")return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]})):t+" "+e}})}const vs=ws("."+us,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".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",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".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",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',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"}},ms);const bs={childList:true,characterData:true,subtree:true,attributes:true,characterDataOldValue:true};const ys=ft.ie&&ft.ie_version<=11;class DOMObserver{constructor(t){this.view=t;this.active=false;this.editContext=null;this.selectionRange=new DOMSelectionState;this.selectionChanged=false;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=false;this.gapIntersection=null;this.gaps=[];this.printQuery=null;this.parentCheck=-1;this.dom=t.contentDOM;this.observer=new MutationObserver((e=>{for(let t of e)this.queue.push(t);(ft.ie&&ft.ie_version<=11||ft.ios&&t.composing)&&e.some((t=>t.type=="childList"&&t.removedNodes.length||t.type=="characterData"&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()}));if(window.EditContext&&ft.android&&t.constructor.EDIT_CONTEXT!==false&&!(ft.chrome&&ft.chrome_version<126)){this.editContext=new EditContextManager(t);t.state.facet(ue)&&(t.contentDOM.editContext=this.editContext.editContext)}ys&&(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"));if(typeof ResizeObserver=="function"){this.resizeScroll=new ResizeObserver((()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}));this.resizeScroll.observe(t.scrollDOM)}this.addWindowListeners(this.win=t.win);this.start();if(typeof IntersectionObserver=="function"){this.intersection=new IntersectionObserver((t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3));if(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(t){this.view.inputState.runHandlers("scroll",t);this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(false);this.editContext&&this.view.requestMeasure(this.editContext.measureReq);this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1;this.view.requestMeasure()}),50))}onPrint(t){if(t.type!="change"&&t.type||t.matches){this.view.viewState.printing=true;this.view.measure();setTimeout((()=>{this.view.viewState.printing=false;this.view.requestMeasure()}),500)}}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some(((e,i)=>e!=t[i])))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,s=this.selectionRange;if(i.state.facet(ue)?i.root.activeElement!=this.dom:!O(this.dom,s))return;let o=s.anchorNode&&i.docView.nearest(s.anchorNode);o&&o.ignoreEvent(t)?e||(this.selectionChanged=false):(ft.ie&&ft.ie_version<=11||ft.android&&ft.chrome)&&!i.state.selection.main.empty&&s.focusNode&&V(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(false)}readSelectionRange(){let{view:t}=this;let e=D(t.root);if(!e)return false;let i=ft.safari&&t.root.nodeType==11&&t.root.activeElement==this.dom&&Ss(this.view,e)||e;if(!i||this.selectionRange.eq(i))return false;let s=O(this.dom,i);if(s&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&_(this.dom,i)){this.view.inputState.lastFocusTime=0;t.docView.updateSelection();return false}this.selectionRange.setRange(i);s&&(this.selectionChanged=true);return true}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset);this.selectionChanged=false}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(i.nodeType==1){!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t));e&&e.push(i);i=i.assignedSlot||i.parentNode}else{if(i.nodeType!=11)break;i=i.host}t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t));if(e){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=e)t.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{this.stop();return t()}finally{this.start();this.clear()}}start(){if(!this.active){this.observer.observe(this.dom,bs);ys&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData);this.active=true}}stop(){if(this.active){this.active=false;this.observer.disconnect();ys&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData)}}clear(){this.processRecords();this.queue.length=0;this.selectionChanged=false}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey();this.view.inputState.lastKeyCode=t.keyCode;this.view.inputState.lastKeyTime=Date.now();let e=this.flush();!e&&t.force&&K(this.dom,t.key,t.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&t!="Enter"||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!((i=this.delayedAndroidKey)===null||i===void 0?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey);this.delayedAndroidKey=null;this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1;this.flush()})))}forceFlush(){if(this.delayedFlush>=0){this.view.win.cancelAnimationFrame(this.delayedFlush);this.delayedFlush=-1}this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,s=false;for(let o of t){let t=this.readMutation(o);if(t){t.typeOver&&(s=true);if(e==-1)({from:e,to:i}=t);else{e=Math.min(t.from,e);i=Math.max(t.to,i)}}}return{from:e,to:i,typeOver:s}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords();let s=this.selectionChanged&&O(this.dom,this.selectionRange);if(t<0&&!s)return null;t>-1&&(this.lastChange=Date.now());this.view.inputState.lastFocusTime=0;this.selectionChanged=false;let o=new DOMChange(this.view,t,e,i);this.view.docView.domChanged={newSel:o.newSel?o.newSel.main:null};return o}flush(t=true){if(this.delayedFlush>=0||this.delayedAndroidKey)return false;t&&this.readSelectionRange();let e=this.readChange();if(!e){this.view.requestMeasure();return false}let i=this.view.state;let s=si(this.view,e);this.view.state==i&&(e.domChanged||e.newSel&&!e.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]);return s}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;e.markDirty(t.type=="attributes");t.type=="attributes"&&(e.flags|=4);if(t.type=="childList"){let i=Ms(e,t.previousSibling||t.target.previousSibling,-1);let s=Ms(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:s?e.posBefore(s):e.posAtEnd,typeOver:false}}return t.type=="characterData"?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){if(t!=this.win){this.removeWindowListeners(this.win);this.win=t;this.addWindowListeners(this.win)}}addWindowListeners(t){t.addEventListener("resize",this.onResize);this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint);t.addEventListener("scroll",this.onScroll);t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll);t.removeEventListener("resize",this.onResize);this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint);t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){if(this.editContext){this.editContext.update(t);t.startState.facet(ue)!=t.state.facet(ue)&&(t.view.contentDOM.editContext=t.state.facet(ue)?this.editContext.editContext:null)}}destroy(){var t,e,i;this.stop();(t=this.intersection)===null||t===void 0?void 0:t.disconnect();(e=this.gapIntersection)===null||e===void 0?void 0:e.disconnect();(i=this.resizeScroll)===null||i===void 0?void 0:i.disconnect();for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win);clearTimeout(this.parentCheck);clearTimeout(this.resizeTimeout);this.win.cancelAnimationFrame(this.delayedFlush);this.win.cancelAnimationFrame(this.flushingAndroidKey);if(this.editContext){this.view.contentDOM.editContext=null;this.editContext.destroy()}}}function Ms(t,e,i){while(e){let s=ContentView.get(e);if(s&&s.parent==t)return s;let o=e.parentNode;e=o!=t.dom?o:i>0?e.nextSibling:e.previousSibling}return null}function xs(t,e){let i=e.startContainer,s=e.startOffset;let o=e.endContainer,n=e.endOffset;let r=t.docView.domAtPos(t.state.selection.main.anchor);V(r.node,r.offset,o,n)&&([i,s,o,n]=[o,n,i,s]);return{anchorNode:i,anchorOffset:s,focusNode:o,focusOffset:n}}function Ss(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return xs(t,i)}let i=null;function s(t){t.preventDefault();t.stopImmediatePropagation();i=t.getTargetRanges()[0]}t.contentDOM.addEventListener("beforeinput",s,true);t.dom.ownerDocument.execCommand("indent");t.contentDOM.removeEventListener("beforeinput",s,true);return i?xs(t,i):null}class EditContextManager{constructor(e){this.from=0;this.to=0;this.pendingContextChange=null;this.handlers=Object.create(null);this.composing=null;this.resetRange(e.state);let i=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=s=>{let o=e.state.selection.main,{anchor:r,head:l}=o;let a=this.toEditorPos(s.updateRangeStart),h=this.toEditorPos(s.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:s.updateRangeStart,editorBase:a,drifted:false});let c={from:a,to:h,insert:t.of(s.text.split("\n"))};c.from==this.from&&r<this.from?c.from=r:c.to==this.to&&r>this.to&&(c.to=r);if(c.from!=c.to||c.insert.length){(ft.mac||ft.android)&&c.from==l-1&&/^\. ?$/.test(s.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:a,to:h,insert:t.of([s.text.replace("."," ")])});this.pendingContextChange=c;if(!e.state.readOnly){let t=this.to-this.from+(c.to-c.from+c.insert.length);oi(e,c,n.single(this.toEditorPos(s.selectionStart,t),this.toEditorPos(s.selectionEnd,t)))}if(this.pendingContextChange){this.revertPending(e.state);this.setSelection(e.state)}c.from<c.to&&!c.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(i.text.slice(Math.max(0,s.updateRangeStart-1),Math.min(i.text.length,s.updateRangeStart+1)))&&this.handlers.compositionend(s)}else{let t=n.single(this.toEditorPos(s.selectionStart),this.toEditorPos(s.selectionEnd));t.main.eq(o)||e.dispatch({selection:t,userEvent:"select"})}};this.handlers.characterboundsupdate=t=>{let s=[],o=null;for(let i=this.toEditorPos(t.rangeStart),n=this.toEditorPos(t.rangeEnd);i<n;i++){let t=e.coordsForChar(i);o=t&&new DOMRect(t.left,t.top,t.right-t.left,t.bottom-t.top)||o||new DOMRect;s.push(o)}i.updateCharacterBounds(t.rangeStart,s)};this.handlers.textformatupdate=t=>{let i=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,s=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(s)){let o=this.toEditorPos(e.rangeStart),n=this.toEditorPos(e.rangeEnd);if(o<n){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+" ":t=="Dashed"?"dashed ":t=="Squiggle"?"wavy ":""}${/thin/i.test(s)?1:2}px`;i.push(Decoration.mark({attributes:{style:e}}).range(o,n))}}}e.dispatch({effects:de.of(Decoration.set(i))})};this.handlers.compositionstart=()=>{if(e.inputState.composing<0){e.inputState.composing=0;e.inputState.compositionFirstChange=true}};this.handlers.compositionend=()=>{e.inputState.composing=-1;e.inputState.compositionFirstChange=null;if(this.composing){let{drifted:t}=this.composing;this.composing=null;t&&this.reset(e.state)}};for(let t in this.handlers)i.addEventListener(t,this.handlers[t]);this.measureReq={read:t=>{this.editContext.updateControlBounds(t.contentDOM.getBoundingClientRect());let e=D(t.root);e&&e.rangeCount&&this.editContext.updateSelectionBounds(e.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=false,s=this.pendingContextChange;t.changes.iterChanges(((o,n,r,l,a)=>{if(i)return;let h=a.length-(n-o);if(s&&n>=s.to){if(s.from==o&&s.to==n&&s.insert.eq(a)){s=this.pendingContextChange=null;e+=h;this.to+=h;return}s=null;this.revertPending(t.state)}o+=e;n+=e;if(n<=this.from){this.from+=h;this.to+=h}else if(o<this.to){if(o<this.from||n>this.to||this.to-this.from+a.length>3e4){i=true;return}this.editContext.updateText(this.toContextPos(o),this.toContextPos(n),a.toString());this.to+=h}e+=h}));s&&!i&&this.revertPending(t.state);return!i}update(t){let e=this.pendingContextChange,i=t.startState.selection.main;if(this.composing&&(this.composing.drifted||!t.changes.touchesRange(i.from,i.to)&&t.transactions.some((t=>!t.isUserEvent("input.type")&&t.changes.touchesRange(this.from,this.to))))){this.composing.drifted=true;this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)}else if(this.applyEdits(t)&&this.rangeIsValid(t.state))(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state);else{this.pendingContextChange=null;this.reset(t.state)}(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4);this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t);this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to));this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null;this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection;let i=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor)));let s=this.toContextPos(e.head);this.editContext.selectionStart==i&&this.editContext.selectionEnd==s||this.editContext.updateSelection(i,s)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>3e4)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let i=this.composing;return i&&i.drifted?i.editorBase+(t-i.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class EditorView{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var e;this.plugins=[];this.pluginMap=new Map;this.editorAttrs={};this.contentAttrs={};this.bidiCache=[];this.destroyed=false;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);t.parent&&t.parent.appendChild(this.dom);let{dispatch:i}=t;this.dispatchTransactions=t.dispatchTransactions||i&&(t=>t.forEach((t=>i(t,this))))||(t=>this.update(t));this.dispatch=this.dispatch.bind(this);this._root=t.root||Y(t.parent)||document;this.viewState=new ViewState(t.state||d.create(t));t.scrollTo&&t.scrollTo.is(ce)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state));this.plugins=this.state.facet(ge).map((t=>new PluginInstance(t)));for(let t of this.plugins)t.update(this);this.observer=new DOMObserver(this);this.inputState=new InputState(this);this.inputState.ensureHandlers(this.plugins);this.docView=new DocView(this);this.mountStyles();this.updateAttrs();this.updateState=0;this.requestMeasure();((e=document.fonts)===null||e===void 0?void 0:e.ready)&&document.fonts.ready.then((()=>this.requestMeasure()))}dispatch(...t){let e=t.length==1&&t[0]instanceof u?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e,i=false,s=false;let o=this.state;for(let e of t){if(e.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=e.state}if(this.destroyed){this.viewState.state=o;return}let r=this.hasFocus,l=0,a=null;if(t.some((t=>t.annotation(qi)))){this.inputState.notifiedFocused=r;l=1}else if(r!=this.inputState.notifiedFocused){this.inputState.notifiedFocused=r;a=Gi(o,r);a||(l=1)}let h=this.observer.delayedAndroidKey,c=null;if(h){this.observer.clearDelayedAndroidKey();c=this.observer.readChange();(c&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(c=null)}else this.observer.clear();if(o.facet(d.phrases)!=this.state.facet(d.phrases))return this.setState(o);e=ViewUpdate.create(this,o,t);e.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){f&&(f=f.map(e.changes));if(e.scrollIntoView){let{main:t}=e.state.selection;f=new ScrollTarget(t.empty?t:n.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(ce)&&(f=t.value.clip(this.state))}this.viewState.update(e,f);this.bidiCache=CachedOrder.update(this.bidiCache,e.changes);if(!e.empty){this.updatePlugins(e);this.inputState.update(e)}i=this.docView.update(e);this.state.facet(ke)!=this.styleModules&&this.mountStyles();s=this.updateAttrs();this.showAnnouncements(t);this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}e.startState.facet(ds)!=e.state.facet(ds)&&(this.viewState.mustMeasureContent=true);(i||s||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure();i&&this.docViewUpdate();if(!e.empty)for(let t of this.state.facet(ie))try{t(e)}catch(t){fe(this.state,t,"update listener")}(a||c)&&Promise.resolve().then((()=>{a&&this.state==a.startState&&this.dispatch(a);c&&!si(this,c)&&h.force&&K(this.contentDOM,h.key,h.keyCode)}))}setState(t){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=t;return}this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);this.viewState=new ViewState(t);this.plugins=t.facet(ge).map((t=>new PluginInstance(t)));this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView.destroy();this.docView=new DocView(this);this.inputState.ensureHandlers(this.plugins);this.mountStyles();this.updateAttrs();this.bidiCache=[]}finally{this.updateState=0}e&&this.focus();this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(ge),i=t.state.facet(ge);if(e!=i){let s=[];for(let o of i){let i=e.indexOf(o);if(i<0)s.push(new PluginInstance(o));else{let e=this.plugins[i];e.mustUpdate=t;s.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=s;this.pluginMap.clear()}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let e=t.value;if(e&&e.docViewUpdate)try{e.docViewUpdate(this)}catch(t){fe(this.state,t,"doc view update listener")}}}measure(t=true){if(this.destroyed)return;this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled);if(this.observer.delayedAndroidKey){this.measureScheduled=-1;this.requestMeasure();return}this.measureScheduled=0;t&&this.observer.forceFlush();let e=null;let i=this.scrollDOM,s=i.scrollTop*this.scaleY;let{scrollAnchorPos:o,scrollAnchorHeight:n}=this.viewState;Math.abs(s-this.viewState.scrollTop)>1&&(n=-1);this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(n<0)if(j(i)){o=-1;n=this.viewState.heightMap.height}else{let t=this.viewState.scrollAnchorAt(s);o=t.from;n=t.top}this.updateState=1;let r=this.viewState.measure(this);if(!r&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let l=[];r&4||([this.measureRequests,l]=[l,this.measureRequests]);let a=l.map((t=>{try{return t.read(this)}catch(t){fe(this.state,t);return ks}}));let h=ViewUpdate.create(this,this.state,[]),c=false;h.flags|=r;e?e.flags|=r:e=h;this.updateState=2;if(!h.empty){this.updatePlugins(h);this.inputState.update(h);this.updateAttrs();c=this.docView.update(h);c&&this.docViewUpdate()}for(let t=0;t<l.length;t++)if(a[t]!=ks)try{let e=l[t];e.write&&e.write(a[t],this)}catch(t){fe(this.state,t)}c&&this.docView.updateSelection(true);if(!h.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget);this.viewState.scrollTarget=null;n=-1;continue}{let t=o<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(o).top;let e=t-n;if(e>1||e<-1){s+=e;i.scrollTop=s/this.scaleY;n=-1;continue}}}break}}}finally{this.updateState=0;this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(ie))t(e)}get themeClasses(){return us+" "+(this.state.facet(fs)?gs:ps)+" "+this.state.facet(ds)}updateAttrs(){let t=Ds(this,me,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses});let e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(ue)?"true":"false",class:"cm-content",style:`${ft.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true");Ds(this,we,e);let i=this.observer.ignore((()=>{let i=St(this.contentDOM,this.contentAttrs,e);let s=St(this.dom,this.editorAttrs,t);return i||s}));this.editorAttrs=t;this.contentAttrs=e;return i}showAnnouncements(t){let e=true;for(let i of t)for(let t of i.effects)if(t.is(EditorView.announce)){e&&(this.announceDOM.textContent="");e=false;let i=this.announceDOM.appendChild(document.createElement("div"));i.textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(ke);let t=this.state.facet(EditorView.cspNonce);M.mount(this.root,this.styleModules.concat(vs).reverse(),t?{nonce:t}: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(false)}requestMeasure(t){this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame((()=>this.measure())));if(t){if(this.measureRequests.indexOf(t)>-1)return;if(t.key!=null)for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key){this.measureRequests[e]=t;return}this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);(e===void 0||e&&e.plugin!=t)&&this.pluginMap.set(t,e=this.plugins.find((e=>e.plugin==t))||null);return e&&e.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(t){this.readMeasured();return this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){this.readMeasured();return this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return ti(this,t,Ue(this,t,e,i))}moveByGroup(t,e){return ti(this,t,Ue(this,t,e,(e=>$e(this,t.head,e))))}visualLineSide(t,e){let i=this.bidiSpans(t),s=this.textDirectionAt(t.from);let o=i[e?i.length-1:0];return n.cursor(o.side(e,s)+t.from,o.forward(!e,s)?1:-1)}moveToLineBoundary(t,e,i=true){return je(this,t,e,i)}moveVertically(t,e,i){return ti(this,t,Qe(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=true){this.readMeasured();return qe(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let s=this.state.doc.lineAt(t),o=this.bidiSpans(s);let n=o[BidiSpan.find(o,t-s.from,-1,e)];return P(i,n.dir==Vt.LTR==e>0)}coordsForChar(t){this.readMeasured();return this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){let e=this.state.facet(le);if(!e||t<this.viewport.from||t>this.viewport.to)return this.textDirection;this.readMeasured();return this.docView.textDirectionAt(t)}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>Cs)return jt(t.length);let e,i=this.textDirectionAt(t.from);for(let s of this.bidiCache)if(s.from==t.from&&s.dir==i&&(s.fresh||zt(s.isolates,e=xe(this,t))))return s.order;e||(e=xe(this,t));let s=_t(t.text,i,e);this.bidiCache.push(new CachedOrder(t.from,t.to,i,e,true,s));return s}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||ft.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{I(this.contentDOM);this.docView.updateSelection()}))}setRoot(t){if(this._root!=t){this._root=t;this.observer.setWindow((t.nodeType==9?t:t.ownerDocument).defaultView||window);this.mountStyles()}}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.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=true}static scrollIntoView(t,e={}){return ce.of(new ScrollTarget(typeof t=="number"?n.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM;let i=this.viewState.scrollAnchorAt(t);return ce.of(new ScrollTarget(n.cursor(i.from),"start","start",i.top-t,e,true))}setTabFocusMode(t){t==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof t=="boolean"?this.inputState.tabFocusMode=t?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return ViewPlugin.define((()=>({})),{eventHandlers:t})}static domEventObservers(t){return ViewPlugin.define((()=>({})),{eventObservers:t})}static theme(t,e){let i=M.newName();let s=[ds.of(i),ke.of(ws(`.${i}`,t))];e&&e.dark&&s.push(fs.of(true));return s}static baseTheme(t){return p.lowest(ke.of(ws("."+us,t,ms)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content");let s=i&&ContentView.get(i)||ContentView.get(t);return((e=s===null||s===void 0?void 0:s.rootView)===null||e===void 0?void 0:e.view)||null}}EditorView.styleModule=ke;EditorView.inputHandler=se;EditorView.clipboardInputFilter=ne;EditorView.clipboardOutputFilter=re;EditorView.scrollHandler=he;EditorView.focusChangeEffect=oe;EditorView.perLineTextDirection=le;EditorView.exceptionSink=ee;EditorView.updateListener=ie;EditorView.editable=ue;EditorView.mouseSelectionStyle=te;EditorView.dragMovesSelection=Zt;EditorView.clickAddsSelectionRange=Jt;EditorView.decorations=ve;EditorView.outerDecorations=be;EditorView.atomicRanges=ye;EditorView.bidiIsolatedRanges=Me;EditorView.scrollMargins=Se;EditorView.darkTheme=fs;EditorView.cspNonce=r.define({combine:t=>t.length?t[0]:""});EditorView.contentAttributes=we;EditorView.editorAttributes=me;EditorView.lineWrapping=EditorView.contentAttributes.of({class:"cm-lineWrapping"});EditorView.announce=l.define();const Cs=4096;const ks={};class CachedOrder{constructor(t,e,i,s,o,n){this.from=t;this.to=e;this.dir=i;this.isolates=s;this.fresh=o;this.order=n}static update(t,e){if(e.empty&&!t.some((t=>t.fresh)))return t;let i=[],s=t.length?t[t.length-1].dir:Vt.LTR;for(let o=Math.max(0,t.length-10);o<t.length;o++){let n=t[o];n.dir!=s||e.touchesRange(n.from,n.to)||i.push(new CachedOrder(e.mapPos(n.from,1),e.mapPos(n.to,-1),n.dir,n.isolates,false,n.order))}return i}}function Ds(t,e,i){for(let s=t.state.facet(e),o=s.length-1;o>=0;o--){let e=s[o],n=typeof e=="function"?e(t):e;n&&yt(n,i)}return i}const As=ft.mac?"mac":ft.windows?"win":ft.linux?"linux":"key";function Os(t,e){const i=t.split(/-(?!$)/);let s=i[i.length-1];s=="Space"&&(s=" ");let o,n,r,l;for(let t=0;t<i.length-1;++t){const s=i[t];if(/^(cmd|meta|m)$/i.test(s))l=true;else if(/^a(lt)?$/i.test(s))o=true;else if(/^(c|ctrl|control)$/i.test(s))n=true;else if(/^s(hift)?$/i.test(s))r=true;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);e=="mac"?l=true:n=true}}o&&(s="Alt-"+s);n&&(s="Ctrl-"+s);l&&(s="Meta-"+s);r&&(s="Shift-"+s);return s}function Ts(t,e,i){e.altKey&&(t="Alt-"+t);e.ctrlKey&&(t="Ctrl-"+t);e.metaKey&&(t="Meta-"+t);i!==false&&e.shiftKey&&(t="Shift-"+t);return t}const Vs=p.default(EditorView.domEventHandlers({keydown(t,e){return Fs(Rs(e.state),t,e,"editor")}}));const Es=r.define({enables:Vs});const Bs=new WeakMap;function Rs(t){let e=t.facet(Es);let i=Bs.get(e);i||Bs.set(e,i=Ns(e.reduce(((t,e)=>t.concat(e)),[])));return i}function Ls(t,e,i){return Fs(Rs(t.state),e,t,i)}let Ps=null;const Hs=4e3;function Ns(t,e=As){let i=Object.create(null);let s=Object.create(null);let o=(t,e)=>{let i=s[t];if(i==null)s[t]=e;else if(i!=e)throw new Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")};let n=(t,s,n,r,l)=>{var a,h;let c=i[t]||(i[t]=Object.create(null));let d=s.split(/ (?!$)/).map((t=>Os(t,e)));for(let e=1;e<d.length;e++){let i=d.slice(0,e).join(" ");o(i,true);c[i]||(c[i]={preventDefault:true,stopPropagation:false,run:[e=>{let s=Ps={view:e,prefix:i,scope:t};setTimeout((()=>{Ps==s&&(Ps=null)}),Hs);return true}]})}let f=d.join(" ");o(f,false);let u=c[f]||(c[f]={preventDefault:false,stopPropagation:false,run:((h=(a=c._any)===null||a===void 0?void 0:a.run)===null||h===void 0?void 0:h.slice())||[]});n&&u.run.push(n);r&&(u.preventDefault=true);l&&(u.stopPropagation=true)};for(let s of t){let t=s.scope?s.scope.split(" "):["editor"];if(s.any)for(let e of t){let t=i[e]||(i[e]=Object.create(null));t._any||(t._any={preventDefault:false,stopPropagation:false,run:[]});let{any:o}=s;for(let e in t)t[e].run.push((t=>o(t,Ws)))}let o=s[e]||s.key;if(o)for(let e of t){n(e,o,s.run,s.preventDefault,s.stopPropagation);s.shift&&n(e,"Shift-"+o,s.shift,s.preventDefault,s.stopPropagation)}}return i}let Ws=null;function Fs(t,e,i,s){Ws=e;let o=x(e);let n=g(o,0),r=m(n)==o.length&&o!=" ";let l="",a=false,h=false,c=false;if(Ps&&Ps.view==i&&Ps.scope==s){l=Ps.prefix+" ";if(ui.indexOf(e.keyCode)<0){h=true;Ps=null}}let d=new Set;let f=t=>{if(t){for(let e of t.run)if(!d.has(e)){d.add(e);if(e(i)){t.stopPropagation&&(c=true);return true}}if(t.preventDefault){t.stopPropagation&&(c=true);h=true}}return false};let u,p,w=t[s];if(w){f(w[l+Ts(o,e,!r)])?a=true:!r||!(e.altKey||e.metaKey||e.ctrlKey)||ft.windows&&e.ctrlKey&&e.altKey||ft.mac&&e.altKey&&!(e.ctrlKey||e.metaKey)||!(u=S[e.keyCode])||u==o?r&&e.shiftKey&&f(w[l+Ts(o,e,true)])&&(a=true):(f(w[l+Ts(u,e,true)])||e.shiftKey&&(p=C[e.keyCode])!=o&&p!=u&&f(w[l+Ts(p,e,false)]))&&(a=true);!a&&f(w._any)&&(a=true)}h&&(a=true);a&&c&&e.stopPropagation();Ws=null;return a}class RectangleMarker{constructor(t,e,i,s,o){this.className=t;this.left=e;this.top=i;this.width=s;this.height=o}draw(){let t=document.createElement("div");t.className=this.className;this.adjust(t);return t}update(t,e){if(e.className!=this.className)return false;this.adjust(t);return true}adjust(t){t.style.left=this.left+"px";t.style.top=this.top+"px";this.width!=null&&(t.style.width=this.width+"px");t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,e,i){if(i.empty){let s=t.coordsAtPos(i.head,i.assoc||1);if(!s)return[];let o=zs(t);return[new RectangleMarker(e,s.left-o.left,s.top-o.top,null,s.bottom-s.top)]}return qs(t,e,i)}}function zs(t){let e=t.scrollDOM.getBoundingClientRect();let i=t.textDirection==Vt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX;return{left:i-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Is(t,e,i,s){let o=t.coordsAtPos(e,i*2);if(!o)return s;let n=t.dom.getBoundingClientRect();let r=(o.top+o.bottom)/2;let l=t.posAtCoords({x:n.left+1,y:r});let a=t.posAtCoords({x:n.right-1,y:r});return l==null||a==null?s:{from:Math.max(s.from,Math.min(l,a)),to:Math.min(s.to,Math.max(l,a))}}function qs(t,e,i){if(i.to<=t.viewport.from||i.from>=t.viewport.to)return[];let s=Math.max(i.from,t.viewport.from),o=Math.min(i.to,t.viewport.to);let n=t.textDirection==Vt.LTR;let r=t.contentDOM,l=r.getBoundingClientRect(),a=zs(t);let h=r.querySelector(".cm-line"),c=h&&window.getComputedStyle(h);let d=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0);let f=l.right-(c?parseInt(c.paddingRight):0);let u=_e(t,s,1),p=_e(t,o,-1);let g=u.type==kt.Text?u:null;let m=p.type==kt.Text?p:null;g&&(t.lineWrapping||u.widgetLineBreaks)&&(g=Is(t,s,1,g));m&&(t.lineWrapping||p.widgetLineBreaks)&&(m=Is(t,o,-1,m));if(g&&m&&g.from==m.from&&g.to==m.to)return v(b(i.from,i.to,g));{let e=g?b(i.from,null,g):y(u,false);let s=m?b(null,i.to,m):y(p,true);let o=[];(g||u).to<(m||p).from-(g&&m?1:0)||u.widgetLineBreaks>1&&e.bottom+t.defaultLineHeight/2<s.top?o.push(w(d,e.bottom,f,s.top)):e.bottom<s.top&&t.elementAtHeight((e.bottom+s.top)/2).type==kt.Text&&(e.bottom=s.top=(e.bottom+s.top)/2);return v(e).concat(o).concat(v(s))}function w(t,i,s,o){return new RectangleMarker(e,t-a.left,i-a.top,s-t,o-i)}function v({top:t,bottom:e,horizontal:i}){let s=[];for(let o=0;o<i.length;o+=2)s.push(w(i[o],t,i[o+1],e));return s}function b(e,i,s){let o=1e9,r=-1e9,l=[];function a(e,i,a,h,c){let u=t.coordsAtPos(e,e==s.to?-2:2);let p=t.coordsAtPos(a,a==s.from?2:-2);if(u&&p){o=Math.min(u.top,p.top,o);r=Math.max(u.bottom,p.bottom,r);c==Vt.LTR?l.push(n&&i?d:u.left,n&&h?f:p.right):l.push(!n&&h?d:p.left,!n&&i?f:u.right)}}let h=e!==null&&e!==void 0?e:s.from,c=i!==null&&i!==void 0?i:s.to;for(let s of t.visibleRanges)if(s.to>h&&s.from<c)for(let o=Math.max(s.from,h),n=Math.min(s.to,c);;){let s=t.state.doc.lineAt(o);for(let r of t.bidiSpans(s)){let t=r.from+s.from,l=r.to+s.from;if(t>=n)break;l>o&&a(Math.max(t,o),e==null&&t<=h,Math.min(l,n),i==null&&l>=c,r.dir)}o=s.to+1;if(o>=n)break}l.length==0&&a(h,e==null,c,i==null,t.textDirection);return{top:o,bottom:r,horizontal:l}}function y(t,e){let i=l.top+(e?t.top:t.bottom);return{top:i,bottom:i,horizontal:[]}}}function Gs(t,e){return t.constructor==e.constructor&&t.eq(e)}class LayerView{constructor(t,e){this.view=t;this.layer=e;this.drawn=[];this.scaleX=1;this.scaleY=1;this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)};this.dom=t.scrollDOM.appendChild(document.createElement("div"));this.dom.classList.add("cm-layer");e.above&&this.dom.classList.add("cm-layer-above");e.class&&this.dom.classList.add(e.class);this.scale();this.dom.setAttribute("aria-hidden","true");this.setOrder(t.state);t.requestMeasure(this.measureReq);e.mount&&e.mount(this.dom,t)}update(t){t.startState.facet(Ks)!=t.state.facet(Ks)&&this.setOrder(t.state);if(this.layer.update(t,this.dom)||t.geometryChanged){this.scale();t.view.requestMeasure(this.measureReq)}}docViewUpdate(t){this.layer.updateOnDocViewUpdate!==false&&t.requestMeasure(this.measureReq)}setOrder(t){let e=0,i=t.facet(Ks);while(e<i.length&&i[e]!=this.layer)e++;this.dom.style.zIndex=String((this.layer.above?150:-1)-e)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:t,scaleY:e}=this.view;if(t!=this.scaleX||e!=this.scaleY){this.scaleX=t;this.scaleY=e;this.dom.style.transform=`scale(${1/t}, ${1/e})`}}draw(t){if(t.length!=this.drawn.length||t.some(((t,e)=>!Gs(t,this.drawn[e])))){let e=this.dom.firstChild,i=0;for(let s of t)if(s.update&&e&&s.constructor&&this.drawn[i].constructor&&s.update(e,this.drawn[i])){e=e.nextSibling;i++}else this.dom.insertBefore(s.draw(),e);while(e){let t=e.nextSibling;e.remove();e=t}this.drawn=t;ft.ios&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view);this.dom.remove()}}const Ks=r.define();function Ys(t){return[ViewPlugin.define((e=>new LayerView(e,t))),Ks.of(t)]}const Xs=r.define({combine(t){return w(t,{cursorBlinkRate:1200,drawRangeCursor:true},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})}});function _s(t={}){return[Xs.of(t),$s,Js,Zs,ae.of(true)]}function js(t){return t.facet(Xs)}function Us(t){return t.startState.facet(Xs)!=t.state.facet(Xs)}const $s=Ys({above:true,markers(t){let{state:e}=t,i=e.facet(Xs);let s=[];for(let o of e.selection.ranges){let r=o==e.selection.main;if(o.empty||i.drawRangeCursor){let e=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary";let i=o.empty?o:n.cursor(o.head,o.head>o.anchor?-1:1);for(let o of RectangleMarker.forRange(t,e,i))s.push(o)}}return s},update(t,e){t.transactions.some((t=>t.selection))&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let i=Us(t);i&&Qs(t.state,e);return t.docChanged||t.selectionSet||i},mount(t,e){Qs(e.state,t)},class:"cm-cursorLayer"});function Qs(t,e){e.style.animationDuration=t.facet(Xs).cursorBlinkRate+"ms"}const Js=Ys({above:false,markers(t){return t.state.selection.ranges.map((e=>e.empty?[]:RectangleMarker.forRange(t,"cm-selectionBackground",e))).reduce(((t,e)=>t.concat(e)))},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Us(t)},class:"cm-selectionLayer"});const Zs=p.highest(EditorView.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));const to=l.define({map(t,e){return t==null?null:e.mapPos(t)}});const eo=v.define({create(){return null},update(t,e){t!=null&&(t=e.changes.mapPos(t));return e.effects.reduce(((t,e)=>e.is(to)?e.value:t),t)}});const io=ViewPlugin.fromClass(class{constructor(t){this.view=t;this.cursor=null;this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(t){var e;let i=t.state.field(eo);if(i==null){if(this.cursor!=null){(e=this.cursor)===null||e===void 0?void 0:e.remove();this.cursor=null}}else{if(!this.cursor){this.cursor=this.view.scrollDOM.appendChild(document.createElement("div"));this.cursor.className="cm-dropCursor"}(t.startState.field(eo)!=i||t.docChanged||t.geometryChanged)&&this.view.requestMeasure(this.measureReq)}}readPos(){let{view:t}=this;let e=t.state.field(eo);let i=e!=null&&t.coordsAtPos(e);if(!i)return null;let s=t.scrollDOM.getBoundingClientRect();return{left:i.left-s.left+t.scrollDOM.scrollLeft*t.scaleX,top:i.top-s.top+t.scrollDOM.scrollTop*t.scaleY,height:i.bottom-i.top}}drawCursor(t){if(this.cursor){let{scaleX:e,scaleY:i}=this.view;if(t){this.cursor.style.left=t.left/e+"px";this.cursor.style.top=t.top/i+"px";this.cursor.style.height=t.height/i+"px"}else this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(t){this.view.state.field(eo)!=t&&this.view.dispatch({effects:to.of(t)})}},{eventObservers:{dragover(t){this.setDropPos(this.view.posAtCoords({x:t.clientX,y:t.clientY}))},dragleave(t){t.target!=this.view.contentDOM&&this.view.contentDOM.contains(t.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function so(){return[eo,io]}function oo(t,e,i,s,o){e.lastIndex=0;for(let n,r=t.iterRange(i,s),l=i;!r.next().done;l+=r.value.length)if(!r.lineBreak)while(n=e.exec(r.value))o(l+n.index,n)}function no(t,e){let i=t.visibleRanges;if(i.length==1&&i[0].from==t.viewport.from&&i[0].to==t.viewport.to)return i;let s=[];for(let{from:o,to:n}of i){o=Math.max(t.state.doc.lineAt(o).from,o-e);n=Math.min(t.state.doc.lineAt(n).to,n+e);s.length&&s[s.length-1].to>=o?s[s.length-1].to=n:s.push({from:o,to:n})}return s}class MatchDecorator{constructor(t){const{regexp:e,decoration:i,decorate:s,boundary:o,maxLength:n=1e3}=t;if(!e.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");this.regexp=e;if(s)this.addMatch=(t,e,i,o)=>s(o,i,i+t[0].length,t,e);else if(typeof i=="function")this.addMatch=(t,e,s,o)=>{let n=i(t,e,s);n&&o(s,s+t[0].length,n)};else{if(!i)throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.addMatch=(t,e,s,o)=>o(s,s+t[0].length,i)}this.boundary=o;this.maxLength=n}createDeco(t){let e=new b,i=e.add.bind(e);for(let{from:e,to:s}of no(t,this.maxLength))oo(t.state.doc,this.regexp,e,s,((e,s)=>this.addMatch(s,t,e,i)));return e.finish()}updateDeco(t,e){let i=1e9,s=-1;t.docChanged&&t.changes.iterChanges(((e,o,n,r)=>{if(r>=t.view.viewport.from&&n<=t.view.viewport.to){i=Math.min(n,i);s=Math.max(r,s)}}));return t.viewportMoved||s-i>1e3?this.createDeco(t.view):s>-1?this.updateRange(t.view,e.map(t.changes),i,s):e}updateRange(t,e,i,s){for(let o of t.visibleRanges){let n=Math.max(o.from,i),r=Math.min(o.to,s);if(r>=n){let i=t.state.doc.lineAt(n),s=i.to<r?t.state.doc.lineAt(r):i;let l=Math.max(o.from,i.from),a=Math.min(o.to,s.to);if(this.boundary){for(;n>i.from;n--)if(this.boundary.test(i.text[n-1-i.from])){l=n;break}for(;r<s.to;r++)if(this.boundary.test(s.text[r-s.from])){a=r;break}}let h,c=[];let d=(t,e,i)=>c.push(i.range(t,e));if(i==s){this.regexp.lastIndex=l-i.from;while((h=this.regexp.exec(i.text))&&h.index<a-i.from)this.addMatch(h,t,h.index+i.from,d)}else oo(t.state.doc,this.regexp,l,a,((e,i)=>this.addMatch(i,t,e,d)));e=e.update({filterFrom:l,filterTo:a,filter:(t,e)=>t<l||e>a,add:c})}}return e}}const ro=/x/.unicode!=null?"gu":"g";const lo=new RegExp("[\0-\b\n--\u2028\u2029\ufeff-]",ro);const ao={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let ho=null;function co(){var t;if(ho==null&&typeof document!="undefined"&&document.body){let e=document.body.style;ho=((t=e.tabSize)!==null&&t!==void 0?t:e.MozTabSize)!=null}return ho||false}const fo=r.define({combine(t){let e=w(t,{render:null,specialChars:lo,addSpecialChars:null});(e.replaceTabs=!co())&&(e.specialChars=new RegExp("\t|"+e.specialChars.source,ro));e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,ro));return e}});function uo(t={}){return[fo.of(t),go()]}let po=null;function go(){return po||(po=ViewPlugin.fromClass(class{constructor(t){this.view=t;this.decorations=Decoration.none;this.decorationCache=Object.create(null);this.decorator=this.makeDecorator(t.state.facet(fo));this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new MatchDecorator({regexp:t.specialChars,decoration:(e,i,s)=>{let{doc:o}=i.state;let n=g(e[0],0);if(n==9){let t=o.lineAt(s);let e=i.state.tabSize,n=y(t.text,e,s-t.from);return Decoration.replace({widget:new TabWidget((e-n%e)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[n]||(this.decorationCache[n]=Decoration.replace({widget:new SpecialCharWidget(t,n)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(fo);if(t.startState.facet(fo)!=e){this.decorator=this.makeDecorator(e);this.decorations=this.decorator.createDeco(t.view)}else this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))}const mo="•";function wo(t){return t>=32?mo:t==10?"":String.fromCharCode(9216+t)}class SpecialCharWidget extends WidgetType{constructor(t,e){super();this.options=t;this.code=e}eq(t){return t.code==this.code}toDOM(t){let e=wo(this.code);let i=t.state.phrase("Control character")+" "+(ao[this.code]||"0x"+this.code.toString(16));let s=this.options.render&&this.options.render(this.code,i,e);if(s)return s;let o=document.createElement("span");o.textContent=e;o.title=i;o.setAttribute("aria-label",i);o.className="cm-specialChar";return o}ignoreEvent(){return false}}class TabWidget extends WidgetType{constructor(t){super();this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");t.textContent="\t";t.className="cm-tab";t.style.width=this.width+"px";return t}ignoreEvent(){return false}}const vo=ViewPlugin.fromClass(class{constructor(){this.height=1e3;this.attrs={style:"padding-bottom: 1000px"}}update(t){let{view:e}=t;let i=e.viewState.editorHeight-e.defaultLineHeight-e.documentPadding.top-.5;if(i>=0&&i!=this.height){this.height=i;this.attrs={style:`padding-bottom: ${i}px`}}}});function bo(){return[vo,we.of((t=>{var e;return((e=t.plugin(vo))===null||e===void 0?void 0:e.attrs)||null}))]}function yo(){return xo}const Mo=Decoration.line({class:"cm-activeLine"});const xo=ViewPlugin.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,i=[];for(let s of t.state.selection.ranges){let o=t.lineBlockAt(s.head);if(o.from>e){i.push(Mo.range(o.from));e=o.from}}return Decoration.set(i)}},{decorations:t=>t.decorations});class Placeholder extends WidgetType{constructor(t){super();this.content=t}toDOM(t){let e=document.createElement("span");e.className="cm-placeholder";e.style.pointerEvents="none";e.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(t):this.content.cloneNode(true));e.setAttribute("aria-hidden","true");return e}coordsAt(t){let e=t.firstChild?T(t.firstChild):[];if(!e.length)return null;let i=window.getComputedStyle(t.parentNode);let s=P(e[0],i.direction!="rtl");let o=parseInt(i.lineHeight);return s.bottom-s.top>o*1.5?{left:s.left,right:s.right,top:s.top,bottom:s.top+o}:s}ignoreEvent(){return false}}function So(t){let e=ViewPlugin.fromClass(class{constructor(e){this.view=e;this.placeholder=t?Decoration.set([Decoration.widget({widget:new Placeholder(t),side:1}).range(0)]):Decoration.none}get decorations(){return this.view.state.doc.length?Decoration.none:this.placeholder}},{decorations:t=>t.decorations});return typeof t=="string"?[e,EditorView.contentAttributes.of({"aria-placeholder":t})]:e}const Co=2e3;function ko(t,e,i){let s=Math.min(e.line,i.line),o=Math.max(e.line,i.line);let r=[];if(e.off>Co||i.off>Co||e.col<0||i.col<0){let l=Math.min(e.off,i.off),a=Math.max(e.off,i.off);for(let e=s;e<=o;e++){let i=t.doc.line(e);i.length<=a&&r.push(n.range(i.from+l,i.to+a))}}else{let l=Math.min(e.col,i.col),a=Math.max(e.col,i.col);for(let e=s;e<=o;e++){let i=t.doc.line(e);let s=h(i.text,l,t.tabSize,true);if(s<0)r.push(n.cursor(i.to));else{let e=h(i.text,a,t.tabSize);r.push(n.range(i.from+s,i.from+e))}}}return r}function Do(t,e){let i=t.coordsAtPos(t.viewport.from);return i?Math.round(Math.abs((i.left-e)/t.defaultCharacterWidth)):-1}function Ao(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},false);let s=t.state.doc.lineAt(i),o=i-s.from;let n=o>Co?-1:o==s.length?Do(t,e.clientX):y(s.text,t.state.tabSize,i-s.from);return{line:s.number,col:n,off:o}}function Oo(t,e){let i=Ao(t,e),s=t.state.selection;return i?{update(t){if(t.docChanged){let e=t.changes.mapPos(t.startState.doc.line(i.line).from);let o=t.state.doc.lineAt(e);i={line:o.number,col:i.col,off:Math.min(i.off,o.length)};s=s.map(t.changes)}},get(e,o,r){let l=Ao(t,e);if(!l)return s;let a=ko(t.state,i,l);return a.length?r?n.create(a.concat(s.ranges)):n.create(a):s}}:null}function To(t){let e=(t===null||t===void 0?void 0:t.eventFilter)||(t=>t.altKey&&t.button==0);return EditorView.mouseSelectionStyle.of(((t,i)=>e(i)?Oo(t,i):null))}const Vo={Alt:[18,t=>!!t.altKey],Control:[17,t=>!!t.ctrlKey],Shift:[16,t=>!!t.shiftKey],Meta:[91,t=>!!t.metaKey]};const Eo={style:"cursor: crosshair"};function Bo(t={}){let[e,i]=Vo[t.key||"Alt"];let s=ViewPlugin.fromClass(class{constructor(t){this.view=t;this.isDown=false}set(t){if(this.isDown!=t){this.isDown=t;this.view.update([])}}},{eventObservers:{keydown(t){this.set(t.keyCode==e||i(t))},keyup(t){t.keyCode!=e&&i(t)||this.set(false)},mousemove(t){this.set(i(t))}}});return[s,EditorView.contentAttributes.of((t=>{var e;return((e=t.plugin(s))===null||e===void 0?void 0:e.isDown)?Eo:null}))]}const Ro="-10000px";class TooltipViewManager{constructor(t,e,i,s){this.facet=e;this.createTooltipView=i;this.removeTooltipView=s;this.input=t.state.facet(e);this.tooltips=this.input.filter((t=>t));let o=null;this.tooltipViews=this.tooltips.map((t=>o=i(t,o)))}update(t,e){var i;let s=t.state.facet(this.facet);let o=s.filter((t=>t));if(s===this.input){for(let e of this.tooltipViews)e.update&&e.update(t);return false}let n=[],r=e?[]:null;for(let i=0;i<o.length;i++){let s=o[i],l=-1;if(s){for(let t=0;t<this.tooltips.length;t++){let e=this.tooltips[t];e&&e.create==s.create&&(l=t)}if(l<0){n[i]=this.createTooltipView(s,i?n[i-1]:null);r&&(r[i]=!!s.above)}else{let s=n[i]=this.tooltipViews[l];r&&(r[i]=e[l]);s.update&&s.update(t)}}}for(let t of this.tooltipViews)if(n.indexOf(t)<0){this.removeTooltipView(t);(i=t.destroy)===null||i===void 0?void 0:i.call(t)}if(e){r.forEach(((t,i)=>e[i]=t));e.length=r.length}this.input=s;this.tooltips=o;this.tooltipViews=n;return true}}function Lo(t={}){return Ho.of(t)}function Po(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const Ho=r.define({combine:t=>{var e,i,s;return{position:ft.ios?"absolute":((e=t.find((t=>t.position)))===null||e===void 0?void 0:e.position)||"fixed",parent:((i=t.find((t=>t.parent)))===null||i===void 0?void 0:i.parent)||null,tooltipSpace:((s=t.find((t=>t.tooltipSpace)))===null||s===void 0?void 0:s.tooltipSpace)||Po}}});const No=new WeakMap;const Wo=ViewPlugin.fromClass(class{constructor(t){this.view=t;this.above=[];this.inView=true;this.madeAbsolute=false;this.lastTransaction=0;this.measureTimeout=-1;let e=t.state.facet(Ho);this.position=e.position;this.parent=e.parent;this.classes=t.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 TooltipViewManager(t,qo,((t,e)=>this.createTooltip(t,e)),(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();t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this));this.maybeMeasure()}createContainer(){if(this.parent){this.container=document.createElement("div");this.container.style.position="relative";this.container.className=this.view.themeClasses;this.parent.appendChild(this.container)}else this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout((()=>{this.measureTimeout=-1;this.maybeMeasure()}),50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let i=e||t.geometryChanged;let s=t.state.facet(Ho);if(s.position!=this.position&&!this.madeAbsolute){this.position=s.position;for(let t of this.manager.tooltipViews)t.dom.style.position=this.position;i=true}if(s.parent!=this.parent){this.parent&&this.container.remove();this.parent=s.parent;this.createContainer();for(let t of this.manager.tooltipViews)this.container.appendChild(t.dom);i=true}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);i&&this.maybeMeasure()}createTooltip(t,e){let i=t.create(this.view);let s=e?e.dom:null;i.dom.classList.add("cm-tooltip");if(t.arrow&&!i.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow";i.dom.appendChild(t)}i.dom.style.position=this.position;i.dom.style.top=Ro;i.dom.style.left="0px";this.container.insertBefore(i.dom,s);i.mount&&i.mount(this.view);this.resizeObserver&&this.resizeObserver.observe(i.dom);return i}destroy(){var t,e,i;this.view.win.removeEventListener("resize",this.measureSoon);for(let e of this.manager.tooltipViews){e.dom.remove();(t=e.destroy)===null||t===void 0?void 0:t.call(e)}this.parent&&this.container.remove();(e=this.resizeObserver)===null||e===void 0?void 0:e.disconnect();(i=this.intersectionObserver)===null||i===void 0?void 0:i.disconnect();clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,i=false;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:t}=this.manager.tooltipViews[0];if(ft.gecko)i=t.offsetParent!=this.container.ownerDocument.body;else if(t.style.top==Ro&&t.style.left=="0px"){let e=t.getBoundingClientRect();i=Math.abs(e.top+1e4)>1||Math.abs(e.left)>1}}if(i||this.position=="absolute")if(this.parent){let i=this.parent.getBoundingClientRect();if(i.width&&i.height){t=i.width/this.parent.offsetWidth;e=i.height/this.parent.offsetHeight}}else({scaleX:t,scaleY:e}=this.view.viewState);let s=this.view.scrollDOM.getBoundingClientRect(),o=Ce(this.view);return{visible:{left:s.left+o.left,top:s.top+o.top,right:s.right-o.right,bottom:s.bottom-o.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map(((t,e)=>{let i=this.manager.tooltipViews[e];return i.getCoords?i.getCoords(t.pos):this.view.coordsAtPos(t.pos)})),size:this.manager.tooltipViews.map((({dom:t})=>t.getBoundingClientRect())),space:this.view.state.facet(Ho).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:i}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=true;this.position="absolute";for(let t of this.manager.tooltipViews)t.dom.style.position="absolute"}let{visible:i,space:s,scaleX:o,scaleY:n}=t;let r=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:c}=h;let d=t.pos[l],f=t.size[l];if(!d||a.clip!==false&&(d.bottom<=Math.max(i.top,s.top)||d.top>=Math.min(i.bottom,s.bottom)||d.right<Math.max(i.left,s.left)-.1||d.left>Math.min(i.right,s.right)+.1)){c.style.top=Ro;continue}let u=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null;let p=u?7:0;let g=f.right-f.left,m=(e=No.get(h))!==null&&e!==void 0?e:f.bottom-f.top;let w=h.offset||Io,v=this.view.textDirection==Vt.LTR;let b=f.width>s.right-s.left?v?s.left:s.right-f.width:v?Math.max(s.left,Math.min(d.left-(u?14:0)+w.x,s.right-g)):Math.min(Math.max(s.left,d.left-g+(u?14:0)-w.x),s.right-g);let y=this.above[l];!a.strictSide&&(y?d.top-m-p-w.y<s.top:d.bottom+m+p+w.y>s.bottom)&&y==s.bottom-d.bottom>d.top-s.top&&(y=this.above[l]=!y);let M=(y?d.top-s.top:s.bottom-d.bottom)-p;if(M<m&&h.resize!==false){if(M<this.view.defaultLineHeight){c.style.top=Ro;continue}No.set(h,m);c.style.height=(m=M)/n+"px"}else c.style.height&&(c.style.height="");let x=y?d.top-m-p-w.y:d.bottom+p+w.y;let S=b+g;if(h.overlap!==true)for(let t of r)t.left<S&&t.right>b&&t.top<x+m&&t.bottom>x&&(x=y?t.top-m-2-p:t.bottom+p+2);if(this.position=="absolute"){c.style.top=(x-t.parent.top)/n+"px";Fo(c,(b-t.parent.left)/o)}else{c.style.top=x/n+"px";Fo(c,b/o)}if(u){let t=d.left+(v?w.x:-w.x)-(b+14-7);u.style.left=t/o+"px"}h.overlap!==true&&r.push({left:b,top:x,right:S,bottom:x+m});c.classList.toggle("cm-tooltip-above",y);c.classList.toggle("cm-tooltip-below",!y);h.positioned&&h.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length){this.view.inView&&this.view.requestMeasure(this.measureReq);if(this.inView!=this.view.inView){this.inView=this.view.inView;if(!this.inView)for(let t of this.manager.tooltipViews)t.dom.style.top=Ro}}}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Fo(t,e){let i=parseInt(t.style.left,10);(isNaN(i)||Math.abs(e-i)>1)&&(t.style.left=e+"px")}const zo=EditorView.baseTheme({".cm-tooltip":{zIndex:500,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:"14px",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"}}});const Io={x:0,y:0};const qo=r.define({enables:[Wo,zo]});const Go=r.define({combine:t=>t.reduce(((t,e)=>t.concat(e)),[])});class HoverTooltipHost{static create(t){return new HoverTooltipHost(t)}constructor(t){this.view=t;this.mounted=false;this.dom=document.createElement("div");this.dom.classList.add("cm-tooltip-hover");this.manager=new TooltipViewManager(t,Go,((t,e)=>this.createHostedView(t,e)),(t=>t.dom.remove()))}createHostedView(t,e){let i=t.create(this.view);i.dom.classList.add("cm-tooltip-section");this.dom.insertBefore(i.dom,e?e.dom.nextSibling:this.dom.firstChild);this.mounted&&i.mount&&i.mount(this.view);return i}mount(t){for(let e of this.manager.tooltipViews)e.mount&&e.mount(t);this.mounted=true}positioned(t){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let e of this.manager.tooltipViews)(t=e.destroy)===null||t===void 0?void 0:t.call(e)}passProp(t){let e;for(let i of this.manager.tooltipViews){let s=i[t];if(s!==void 0)if(e===void 0)e=s;else if(e!==s)return}return e}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const Ko=qo.compute([Go],(t=>{let e=t.facet(Go);return e.length===0?null:{pos:Math.min(...e.map((t=>t.pos))),end:Math.max(...e.map((t=>{var e;return(e=t.end)!==null&&e!==void 0?e:t.pos}))),create:HoverTooltipHost.create,above:e[0].above,arrow:e.some((t=>t.arrow))}}));class HoverPlugin{constructor(t,e,i,s,o){this.view=t;this.source=e;this.field=i;this.setHover=s;this.hoverTime=o;this.hoverTimeout=-1;this.restartTimeout=-1;this.pending=null;this.lastMove={x:0,y:0,target:t.dom,time:0};this.checkHover=this.checkHover.bind(this);t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this));t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){if(this.pending){this.pending=null;clearTimeout(this.restartTimeout);this.restartTimeout=setTimeout((()=>this.startHover()),20)}}get active(){return this.view.state.field(this.field)}checkHover(){this.hoverTimeout=-1;if(this.active.length)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:e}=this;let i=t.docView.nearest(e.target);if(!i)return;let s,o=1;if(i instanceof WidgetView)s=i.posAtStart;else{s=t.posAtCoords(e);if(s==null)return;let i=t.coordsAtPos(s);if(!i||e.y<i.top||e.y>i.bottom||e.x<i.left-t.defaultCharacterWidth||e.x>i.right+t.defaultCharacterWidth)return;let n=t.bidiSpans(t.state.doc.lineAt(s)).find((t=>t.from<=s&&t.to>=s));let r=n&&n.dir==Vt.RTL?-1:1;o=e.x<i.left?-r:r}let n=this.source(t,s,o);if(n===null||n===void 0?void 0:n.then){let e=this.pending={pos:s};n.then((i=>{if(this.pending==e){this.pending=null;!i||Array.isArray(i)&&!i.length||t.dispatch({effects:this.setHover.of(Array.isArray(i)?i:[i])})}}),(e=>fe(t.state,e,"hover tooltip")))}else!n||Array.isArray(n)&&!n.length||t.dispatch({effects:this.setHover.of(Array.isArray(n)?n:[n])})}get tooltip(){let t=this.view.plugin(Wo);let e=t?t.manager.tooltips.findIndex((t=>t.create==HoverTooltipHost.create)):-1;return e>-1?t.manager.tooltipViews[e]:null}mousemove(t){var e,i;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()};this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:s,tooltip:o}=this;if(s.length&&o&&!Xo(o.dom,t)||this.pending){let{pos:o}=s[0]||this.pending,n=(i=(e=s[0])===null||e===void 0?void 0:e.end)!==null&&i!==void 0?i:o;if(o==n?this.view.posAtCoords(this.lastMove)!=o:!_o(this.view,o,n,t.clientX,t.clientY)){this.view.dispatch({effects:this.setHover.of([])});this.pending=null}}}mouseleave(t){clearTimeout(this.hoverTimeout);this.hoverTimeout=-1;let{active:e}=this;if(e.length){let{tooltip:e}=this;let i=e&&e.dom.contains(t.relatedTarget);i?this.watchTooltipLeave(e.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let e=i=>{t.removeEventListener("mouseleave",e);this.active.length&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",e)}destroy(){clearTimeout(this.hoverTimeout);this.view.dom.removeEventListener("mouseleave",this.mouseleave);this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Yo=4;function Xo(t,e){let i,{left:s,right:o,top:n,bottom:r}=t.getBoundingClientRect();if(i=t.querySelector(".cm-tooltip-arrow")){let t=i.getBoundingClientRect();n=Math.min(t.top,n);r=Math.max(t.bottom,r)}return e.clientX>=s-Yo&&e.clientX<=o+Yo&&e.clientY>=n-Yo&&e.clientY<=r+Yo}function _o(t,e,i,s,o,n){let r=t.scrollDOM.getBoundingClientRect();let l=t.documentTop+t.documentPadding.top+t.contentHeight;if(r.left>s||r.right<s||r.top>o||Math.min(r.bottom,l)<o)return false;let a=t.posAtCoords({x:s,y:o},false);return a>=e&&a<=i}function jo(t,e={}){let i=l.define();let o=v.define({create(){return[]},update(t,o){if(t.length){e.hideOnChange&&(o.docChanged||o.selection)?t=[]:e.hideOn&&(t=t.filter((t=>!e.hideOn(o,t))));if(o.docChanged){let e=[];for(let i of t){let t=o.changes.mapPos(i.pos,-1,s.TrackDel);if(t!=null){let s=Object.assign(Object.create(null),i);s.pos=t;s.end!=null&&(s.end=o.changes.mapPos(s.end));e.push(s)}}t=e}}for(let e of o.effects){e.is(i)&&(t=e.value);e.is(Qo)&&(t=[])}return t},provide:t=>Go.from(t)});return{active:o,extension:[o,ViewPlugin.define((s=>new HoverPlugin(s,t,o,i,e.hoverTime||300))),Ko]}}function Uo(t,e){let i=t.plugin(Wo);if(!i)return null;let s=i.manager.tooltips.indexOf(e);return s<0?null:i.manager.tooltipViews[s]}function $o(t){return t.facet(Go).some((t=>t))}const Qo=l.define();const Jo=Qo.of(null);function Zo(t){let e=t.plugin(Wo);e&&e.maybeMeasure()}const tn=r.define({combine(t){let e,i;for(let s of t){e=e||s.topContainer;i=i||s.bottomContainer}return{topContainer:e,bottomContainer:i}}});function en(t){return t?[tn.of(t)]:[]}function sn(t,e){let i=t.plugin(on);let s=i?i.specs.indexOf(e):-1;return s>-1?i.panels[s]:null}const on=ViewPlugin.fromClass(class{constructor(t){this.input=t.state.facet(rn);this.specs=this.input.filter((t=>t));this.panels=this.specs.map((e=>e(t)));let e=t.state.facet(tn);this.top=new PanelGroup(t,true,e.topContainer);this.bottom=new PanelGroup(t,false,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(t){let e=t.state.facet(tn);if(this.top.container!=e.topContainer){this.top.sync([]);this.top=new PanelGroup(t.view,true,e.topContainer)}if(this.bottom.container!=e.bottomContainer){this.bottom.sync([]);this.bottom=new PanelGroup(t.view,false,e.bottomContainer)}this.top.syncClasses();this.bottom.syncClasses();let i=t.state.facet(rn);if(i!=this.input){let e=i.filter((t=>t));let s=[],o=[],n=[],r=[];for(let i of e){let e,l=this.specs.indexOf(i);if(l<0){e=i(t.view);r.push(e)}else{e=this.panels[l];e.update&&e.update(t)}s.push(e);(e.top?o:n).push(e)}this.specs=e;this.panels=s;this.top.sync(o);this.bottom.sync(n);for(let t of r){t.dom.classList.add("cm-panel");t.mount&&t.mount()}}else for(let e of this.panels)e.update&&e.update(t)}destroy(){this.top.sync([]);this.bottom.sync([])}},{provide:t=>EditorView.scrollMargins.of((e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}}))});class PanelGroup{constructor(t,e,i){this.view=t;this.top=e;this.container=i;this.dom=void 0;this.classes="";this.panels=[];this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&t.indexOf(e)<0&&e.destroy();this.panels=t;this.syncDOM()}syncDOM(){if(this.panels.length==0){if(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 t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){while(t!=e.dom)t=nn(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);while(t)t=nn(t)}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 t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function nn(t){let e=t.nextSibling;t.remove();return e}const rn=r.define({enables:on});function ln(t,e){let i;let s=new Promise((t=>i=t));let o=t=>fn(t,e,i);t.state.field(hn,false)?t.dispatch({effects:cn.of(o)}):t.dispatch({effects:l.appendConfig.of(hn.init((()=>[o])))});let n=dn.of(o);return{close:n,result:s.then((e=>{let i=t.win.queueMicrotask||(e=>t.win.setTimeout(e,10));i((()=>{t.state.field(hn).indexOf(o)>-1&&t.dispatch({effects:n})}));return e}))}}function an(t,e){let i=t.state.field(hn,false)||[];for(let s of i){let i=sn(t,s);if(i&&i.dom.classList.contains(e))return i}return null}const hn=v.define({create(){return[]},update(t,e){for(let i of e.effects)i.is(cn)?t=[i.value].concat(t):i.is(dn)&&(t=t.filter((t=>t!=i.value)));return t},provide:t=>rn.computeN([t],(e=>e.field(t)))});const cn=l.define();const dn=l.define();function fn(t,e,i){let s=e.content?e.content(t,(()=>r(null))):null;if(!s){s=k("form");if(e.input){let t=k("input",e.input);/^(text|password|number|email|tel|url)$/.test(t.type)&&t.classList.add("cm-textfield");t.name||(t.name="input");s.appendChild(k("label",(e.label||"")+": ",t))}else s.appendChild(document.createTextNode(e.label||""));s.appendChild(document.createTextNode(" "));s.appendChild(k("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let o=s.nodeName=="FORM"?[s]:s.querySelectorAll("form");for(let t=0;t<o.length;t++){let e=o[t];e.addEventListener("keydown",(t=>{if(t.keyCode==27){t.preventDefault();r(null)}else if(t.keyCode==13){t.preventDefault();r(e)}}));e.addEventListener("submit",(t=>{t.preventDefault();r(e)}))}let n=k("div",s,k("button",{onclick:()=>r(null),"aria-label":t.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(n.className=e.class);n.classList.add("cm-dialog");function r(e){n.contains(n.ownerDocument.activeElement)&&t.focus();i(e)}return{dom:n,top:e.top,mount:()=>{if(e.focus){let t;t=typeof e.focus=="string"?s.querySelector(e.focus):s.querySelector("input")||s.querySelector("button");t&&"select"in t?t.select():t&&"focus"in t&&t.focus()}}}}class GutterMarker extends e{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return false}destroy(t){}}GutterMarker.prototype.elementClass="";GutterMarker.prototype.toDOM=void 0;GutterMarker.prototype.mapMode=s.TrackBefore;GutterMarker.prototype.startSide=GutterMarker.prototype.endSide=-1;GutterMarker.prototype.point=true;const un=r.define();const pn=r.define();const gn={class:"",renderEmptyElements:false,elementStyle:"",markers:()=>i.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"};const mn=r.define();function wn(t){return[bn(),mn.of({...gn,...t})]}const vn=r.define({combine:t=>t.some((t=>t))});function bn(t){let e=[yn];t&&t.fixed===false&&e.push(vn.of(true));return e}const yn=ViewPlugin.fromClass(class{constructor(t){this.view=t;this.domAfter=null;this.prevViewport=t.viewport;this.dom=document.createElement("div");this.dom.className="cm-gutters cm-gutters-before";this.dom.setAttribute("aria-hidden","true");this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px";this.gutters=t.state.facet(mn).map((e=>new SingleGutterView(t,e)));this.fixed=!t.state.facet(vn);for(let t of this.gutters)t.config.side=="after"?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky");this.syncGutters(false);t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){if(!this.domAfter){this.domAfter=document.createElement("div");this.domAfter.className="cm-gutters cm-gutters-after";this.domAfter.setAttribute("aria-hidden","true");this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px";this.domAfter.style.position=this.fixed?"sticky":"";this.view.scrollDOM.appendChild(this.domAfter)}return this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,i=t.view.viewport;let s=Math.min(e.to,i.to)-Math.max(e.from,i.from);this.syncGutters(s<.8*(i.to-i.from))}if(t.geometryChanged){let t=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=t;this.domAfter&&(this.domAfter.style.minHeight=t)}if(this.view.state.facet(vn)!=!this.fixed){this.fixed=!this.fixed;this.dom.style.position=this.fixed?"sticky":"";this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")}this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;if(t){this.dom.remove();this.domAfter&&this.domAfter.remove()}let s=i.iter(this.view.state.facet(un),this.view.viewport.from);let o=[];let n=this.gutters.map((t=>new UpdateContext(t,this.view.viewport,-this.view.documentPadding.top)));for(let t of this.view.viewportLineBlocks){o.length&&(o=[]);if(Array.isArray(t.type)){let e=true;for(let i of t.type)if(i.type==kt.Text&&e){xn(s,o,i.from);for(let t of n)t.line(this.view,i,o);e=false}else if(i.widget)for(let t of n)t.widget(this.view,i)}else if(t.type==kt.Text){xn(s,o,t.from);for(let e of n)e.line(this.view,t,o)}else if(t.widget)for(let e of n)e.widget(this.view,t)}for(let t of n)t.finish();if(t){this.view.scrollDOM.insertBefore(this.dom,e);this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter)}}updateGutters(t){let e=t.startState.facet(mn),s=t.state.facet(mn);let o=t.docChanged||t.heightChanged||t.viewportChanged||!i.eq(t.startState.facet(un),t.state.facet(un),t.view.viewport.from,t.view.viewport.to);if(e==s)for(let e of this.gutters)e.update(t)&&(o=true);else{o=true;let i=[];for(let o of s){let s=e.indexOf(o);if(s<0)i.push(new SingleGutterView(this.view,o));else{this.gutters[s].update(t);i.push(this.gutters[s])}}for(let t of this.gutters){t.dom.remove();i.indexOf(t)<0&&t.destroy()}for(let t of i)t.config.side=="after"?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.gutters=i}return o}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove();this.domAfter&&this.domAfter.remove()}},{provide:t=>EditorView.scrollMargins.of((e=>{let i=e.plugin(t);if(!i||i.gutters.length==0||!i.fixed)return null;let s=i.dom.offsetWidth*e.scaleX,o=i.domAfter?i.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Vt.LTR?{left:s,right:o}:{right:s,left:o}}))});function Mn(t){return Array.isArray(t)?t:[t]}function xn(t,e,i){while(t.value&&t.from<=i){t.from==i&&e.push(t.value);t.next()}}class UpdateContext{constructor(t,e,s){this.gutter=t;this.height=s;this.i=0;this.cursor=i.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:s}=this,o=(e.top-this.height)/t.scaleY,n=e.height/t.scaleY;if(this.i==s.elements.length){let e=new GutterElement(t,n,o,i);s.elements.push(e);s.dom.appendChild(e.dom)}else s.elements[this.i].update(t,n,o,i);this.height=e.bottom;this.i++}line(t,e,i){let s=[];xn(this.cursor,s,e.from);i.length&&(s=s.concat(i));let o=this.gutter.config.lineMarker(t,e,s);o&&s.unshift(o);let n=this.gutter;(s.length!=0||n.config.renderEmptyElements)&&this.addElement(t,e,s)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e),s=i?[i]:null;for(let i of t.state.facet(pn)){let o=i(t,e.widget,e);o&&(s||(s=[])).push(o)}s&&this.addElement(t,e,s)}finish(){let t=this.gutter;while(t.elements.length>this.i){let e=t.elements.pop();t.dom.removeChild(e.dom);e.destroy()}}}class SingleGutterView{constructor(t,e){this.view=t;this.config=e;this.elements=[];this.spacer=null;this.dom=document.createElement("div");this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in e.domEventHandlers)this.dom.addEventListener(i,(s=>{let o,n=s.target;if(n!=this.dom&&this.dom.contains(n)){while(n.parentNode!=this.dom)n=n.parentNode;let t=n.getBoundingClientRect();o=(t.top+t.bottom)/2}else o=s.clientY;let r=t.lineBlockAtHeight(o-t.documentTop);e.domEventHandlers[i](t,r,s)&&s.preventDefault()}));this.markers=Mn(e.markers(t));if(e.initialSpacer){this.spacer=new GutterElement(t,0,0,[e.initialSpacer(t)]);this.dom.appendChild(this.spacer.dom);this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none"}}update(t){let e=this.markers;this.markers=Mn(this.config.markers(t.view));if(this.spacer&&this.config.updateSpacer){let e=this.config.updateSpacer(this.spacer.markers[0],t);e!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[e])}let s=t.view.viewport;return!i.eq(this.markers,e,s.from,s.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(t)}destroy(){for(let t of this.elements)t.destroy()}}class GutterElement{constructor(t,e,i,s){this.height=-1;this.above=0;this.markers=[];this.dom=document.createElement("div");this.dom.className="cm-gutterElement";this.update(t,e,i,s)}update(t,e,i,s){if(this.height!=e){this.height=e;this.dom.style.height=e+"px"}this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":"");Sn(this.markers,s)||this.setMarkers(t,s)}setMarkers(t,e){let i="cm-gutterElement",s=this.dom.firstChild;for(let o=0,n=0;;){let r=n,l=o<e.length?e[o++]:null,a=false;if(l){let t=l.elementClass;t&&(i+=" "+t);for(let t=n;t<this.markers.length;t++)if(this.markers[t].compare(l)){r=t;a=true;break}}else r=this.markers.length;while(n<r){let t=this.markers[n++];if(t.toDOM){t.destroy(s);let e=s.nextSibling;s.remove();s=e}}if(!l)break;l.toDOM&&(a?s=s.nextSibling:this.dom.insertBefore(l.toDOM(t),s));a&&n++}this.dom.className=i;this.markers=e}destroy(){this.setMarkers(null,[])}}function Sn(t,e){if(t.length!=e.length)return false;for(let i=0;i<t.length;i++)if(!t[i].compare(e[i]))return false;return true}const Cn=r.define();const kn=r.define();const Dn=r.define({combine(t){return w(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let t in e){let s=i[t],o=e[t];i[t]=s?(t,e,i)=>s(t,e,i)||o(t,e,i):o}return i}})}});class NumberMarker extends GutterMarker{constructor(t){super();this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function An(t,e){return t.state.facet(Dn).formatNumber(e,t.state)}const On=mn.compute([Dn],(t=>({class:"cm-lineNumbers",renderEmptyElements:false,markers(t){return t.state.facet(Cn)},lineMarker(t,e,i){return i.some((t=>t.toDOM))?null:new NumberMarker(An(t,t.state.doc.lineAt(e.from).number))},widgetMarker:(t,e,i)=>{for(let s of t.state.facet(kn)){let o=s(t,e,i);if(o)return o}return null},lineMarkerChange:t=>t.startState.facet(Dn)!=t.state.facet(Dn),initialSpacer(t){return new NumberMarker(An(t,Vn(t.state.doc.lines)))},updateSpacer(t,e){let i=An(e.view,Vn(e.view.state.doc.lines));return i==t.number?t:new NumberMarker(i)},domEventHandlers:t.facet(Dn).domEventHandlers,side:"before"})));function Tn(t={}){return[Dn.of(t),bn(),On]}function Vn(t){let e=9;while(e<t)e=e*10+9;return e}const En=new class extends GutterMarker{constructor(){super(...arguments);this.elementClass="cm-activeLineGutter"}};const Bn=un.compute(["selection"],(t=>{let e=[],s=-1;for(let i of t.selection.ranges){let o=t.doc.lineAt(i.head).from;if(o>s){s=o;e.push(En.range(o))}}return i.of(e)}));function Rn(){return Bn}function Ln(t){return ViewPlugin.define((e=>({decorations:t.createDeco(e),update(e){this.decorations=t.updateDeco(e,this.decorations)}})),{decorations:t=>t.decorations})}const Pn=Decoration.mark({class:"cm-highlightTab"});const Hn=Decoration.mark({class:"cm-highlightSpace"});const Nn=Ln(new MatchDecorator({regexp:/\t| /g,decoration:t=>t[0]=="\t"?Pn:Hn,boundary:/\S/}));function Wn(){return Nn}const Fn=Ln(new MatchDecorator({regexp:/\s+$/g,decoration:Decoration.mark({class:"cm-trailingSpace"})}));function zn(){return Fn}const In={HeightMap:HeightMap,HeightOracle:HeightOracle,MeasuredHeights:MeasuredHeights,QueryType:$i,ChangedRange:ChangedRange,computeOrder:_t,moveVisually:$t,clearHeightChangeFlag:Ui,getHeightChangeFlag:()=>ji};export{BidiSpan,BlockInfo,kt as BlockType,Decoration,Vt as Direction,EditorView,GutterMarker,MatchDecorator,RectangleMarker,ViewPlugin,ViewUpdate,WidgetType,In as __test,Jo as closeHoverTooltips,Bo as crosshairCursor,_s as drawSelection,so as dropCursor,an as getDialog,js as getDrawSelectionConfig,sn as getPanel,Uo as getTooltip,wn as gutter,un as gutterLineClass,pn as gutterWidgetClass,bn as gutters,$o as hasHoverTooltips,yo as highlightActiveLine,Rn as highlightActiveLineGutter,uo as highlightSpecialChars,zn as highlightTrailingWhitespace,Wn as highlightWhitespace,jo as hoverTooltip,Es as keymap,Ys as layer,Cn as lineNumberMarkers,kn as lineNumberWidgetMarker,Tn as lineNumbers,fe as logException,en as panels,So as placeholder,To as rectangularSelection,Zo as repositionTooltips,Ls as runScopeHandlers,bo as scrollPastEnd,ln as showDialog,rn as showPanel,qo as showTooltip,Lo as tooltips};+diff --git a/admin/vendor/javascript/@lezer--common.js b/admin/vendor/javascript/@lezer--common.jsnew file mode 100644index 0000000000..a1e5a08bf7--- /dev/null+++ b/admin/vendor/javascript/@lezer--common.js@@ -0,0 +1,4 @@+// @lezer/[email protected] downloaded from https://ga.jspm.io/npm:@lezer/[email protected]/dist/index.js++const e=1024;let t=0;class Range{constructor(e,t){this.from=e;this.to=t}}class NodeProp{constructor(e={}){this.id=t++;this.perNode=!!e.perNode;this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");typeof e!="function"&&(e=NodeType.match(e));return t=>{let r=e(t);return r===void 0?null:[this,r]}}}NodeProp.closedBy=new NodeProp({deserialize:e=>e.split(" ")});NodeProp.openedBy=new NodeProp({deserialize:e=>e.split(" ")});NodeProp.group=new NodeProp({deserialize:e=>e.split(" ")});NodeProp.isolate=new NodeProp({deserialize:e=>{if(e&&e!="rtl"&&e!="ltr"&&e!="auto")throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}});NodeProp.contextHash=new NodeProp({perNode:true});NodeProp.lookAhead=new NodeProp({perNode:true});NodeProp.mounted=new NodeProp({perNode:true});class MountedTree{constructor(e,t,r){this.tree=e;this.overlay=t;this.parser=r}static get(e){return e&&e.props&&e.props[NodeProp.mounted.id]}}const r=Object.create(null);class NodeType{constructor(e,t,r,n=0){this.name=e;this.props=t;this.id=r;this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):r;let n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0);let i=new NodeType(e.name||"",t,e.id,n);if(e.props)for(let r of e.props){Array.isArray(r)||(r=r(i));if(r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}}return i}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 true;let t=this.prop(NodeProp.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let r in e)for(let n of r.split(" "))t[n]=e[r];return e=>{for(let r=e.prop(NodeProp.group),n=-1;n<(r?r.length:0);n++){let i=t[n<0?e.name:r[n]];if(i)return i}}}}NodeType.none=new NodeType("",Object.create(null),0,8);class NodeSet{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let r of this.types){let n=null;for(let t of e){let e=t(r);if(e){n||(n=Object.assign({},r.props));n[e[0].id]=e[1]}}t.push(n?new NodeType(r.name,n,r.id,r.flags):r)}return new NodeSet(t)}}const n=new WeakMap,i=new WeakMap;var s;(function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers";e[e.IncludeAnonymous=2]="IncludeAnonymous";e[e.IgnoreMounts=4]="IgnoreMounts";e[e.IgnoreOverlays=8]="IgnoreOverlays"})(s||(s={}));class Tree{constructor(e,t,r,n,i){this.type=e;this.children=t;this.positions=r;this.length=n;this.props=null;if(i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props[typeof e=="number"?e:e.id]=t}}toString(){let e=MountedTree.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let r=e.toString();if(r){t&&(t+=",");t+=r}}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new TreeCursor(this.topNode,e)}cursorAt(e,t=0,r=0){let i=n.get(this)||this.topNode;let s=new TreeCursor(i);s.moveTo(e,t);n.set(this,s._tree);return s}get topNode(){return new TreeNode(this,0,0,null)}resolve(e,t=0){let r=resolveNode(n.get(this)||this.topNode,e,t,false);n.set(this,r);return r}resolveInner(e,t=0){let r=resolveNode(i.get(this)||this.topNode,e,t,true);i.set(this,r);return r}resolveStack(e,t=0){return stackIterator(this,e,t)}iterate(e){let{enter:t,leave:r,from:n=0,to:i=this.length}=e;let o=e.mode||0,l=(o&s.IncludeAnonymous)>0;for(let e=this.cursor(o|s.IncludeAnonymous);;){let s=false;if(e.from<=i&&e.to>=n&&(!l&&e.type.isAnonymous||t(e)!==false)){if(e.firstChild())continue;s=true}for(;;){s&&r&&(l||!e.type.isAnonymous)&&r(e);if(e.nextSibling())break;if(!e.parent())return;s=true}}}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:balanceRange(NodeType.none,this.children,this.positions,0,this.children.length,0,this.length,((e,t,r)=>new Tree(this.type,e,t,r,this.propValues)),e.makeTree||((e,t,r)=>new Tree(NodeType.none,e,t,r)))}static build(e){return buildTree(e)}}Tree.empty=new Tree(NodeType.none,[],[],0);class FlatBufferCursor{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 FlatBufferCursor(this.buffer,this.index)}}class TreeBuffer{constructor(e,t,r){this.buffer=e;this.length=t;this.set=r}get type(){return NodeType.none}toString(){let e=[];for(let t=0;t<this.buffer.length;){e.push(this.childString(t));t=this.buffer[t+3]}return e.join(",")}childString(e){let t=this.buffer[e],r=this.buffer[e+3];let n=this.set.types[t],i=n.name;/\W/.test(i)&&!n.isError&&(i=JSON.stringify(i));e+=4;if(r==e)return i;let s=[];while(e<r){s.push(this.childString(e));e=this.buffer[e+3]}return i+"("+s.join(",")+")"}findChild(e,t,r,n,i){let{buffer:s}=this,o=-1;for(let l=e;l!=t;l=s[l+3])if(checkSide(i,n,s[l+1],s[l+2])){o=l;if(r>0)break}return o}slice(e,t,r){let n=this.buffer;let i=new Uint16Array(t-e),s=0;for(let o=e,l=0;o<t;){i[l++]=n[o++];i[l++]=n[o++]-r;let t=i[l++]=n[o++]-r;i[l++]=n[o++]-e;s=Math.max(s,t)}return new TreeBuffer(i,s,this.set)}}function checkSide(e,t,r,n){switch(e){case-2:return r<t;case-1:return n>=t&&r<t;case 0:return r<t&&n>t;case 1:return r<=t&&n>t;case 2:return n>t;case 4:return true}}function resolveNode(e,t,r,n){var i;while(e.from==e.to||(r<1?e.from>=t:e.from>t)||(r>-1?e.to<=t:e.to<t)){let t=!n&&e instanceof TreeNode&&e.index<0?null:e.parent;if(!t)return e;e=t}let o=n?0:s.IgnoreOverlays;if(n)for(let n=e,s=n.parent;s;n=s,s=n.parent)n instanceof TreeNode&&n.index<0&&((i=s.enter(t,r,o))===null||i===void 0?void 0:i.from)!=n.from&&(e=s);for(;;){let n=e.enter(t,r,o);if(!n)return e;e=n}}class BaseNode{cursor(e=0){return new TreeCursor(this,e)}getChild(e,t=null,r=null){let n=getChildren(this,e,t,r);return n.length?n[0]:null}getChildren(e,t=null,r=null){return getChildren(this,e,t,r)}resolve(e,t=0){return resolveNode(this,e,t,false)}resolveInner(e,t=0){return resolveNode(this,e,t,true)}matchContext(e){return matchNodeContext(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),r=this;while(t){let e=t.lastChild;if(!e||e.to!=t.to)break;if(e.type.isError&&e.from==e.to){r=t;t=e.prevSibling}else t=e}return r}get node(){return this}get next(){return this.parent}}class TreeNode extends BaseNode{constructor(e,t,r,n){super();this._tree=e;this.from=t;this.index=r;this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,r,n,i=0){for(let o=this;;){for(let{children:l,positions:f}=o._tree,h=t>0?l.length:-1;e!=h;e+=t){let h=l[e],u=f[e]+o.from;if(checkSide(n,r,u,u+h.length))if(h instanceof TreeBuffer){if(i&s.ExcludeBuffers)continue;let l=h.findChild(0,h.buffer.length,t,r-u,n);if(l>-1)return new BufferNode(new BufferContext(o,h,e,u),null,l)}else if(i&s.IncludeAnonymous||!h.type.isAnonymous||hasChild(h)){let l;if(!(i&s.IgnoreMounts)&&(l=MountedTree.get(h))&&!l.overlay)return new TreeNode(l.tree,u,e,o);let f=new TreeNode(h,u,e,o);return i&s.IncludeAnonymous||!f.type.isAnonymous?f:f.nextChild(t<0?h.children.length-1:0,t,r,n)}}if(i&s.IncludeAnonymous||!o.type.isAnonymous)return null;e=o.index>=0?o.index+t:t<0?-1:o._parent._tree.children.length;o=o._parent;if(!o)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,r=0){let n;if(!(r&s.IgnoreOverlays)&&(n=MountedTree.get(this._tree))&&n.overlay){let r=e-this.from;for(let{from:e,to:i}of n.overlay)if((t>0?e<=r:e<r)&&(t<0?i>=r:i>r))return new TreeNode(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,r)}nextSignificantParent(){let e=this;while(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 getChildren(e,t,r,n){let i=e.cursor(),s=[];if(!i.firstChild())return s;if(r!=null)for(let e=false;!e;){e=i.type.is(r);if(!i.nextSibling())return s}for(;;){if(n!=null&&i.type.is(n))return s;i.type.is(t)&&s.push(i.node);if(!i.nextSibling())return n==null?s:[]}}function matchNodeContext(e,t,r=t.length-1){for(let n=e;r>=0;n=n.parent){if(!n)return false;if(!n.type.isAnonymous){if(t[r]&&t[r]!=n.name)return false;r--}}return true}class BufferContext{constructor(e,t,r,n){this.parent=e;this.buffer=t;this.index=r;this.start=n}}class BufferNode extends BaseNode{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,r){super();this.context=e;this._parent=t;this.index=r;this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,t,r){let{buffer:n}=this.context;let i=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,r);return i<0?null:new BufferNode(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,r=0){if(r&s.ExcludeBuffers)return null;let{buffer:n}=this.context;let i=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return i<0?null:new BufferNode(this.context,this,i)}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;let t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new BufferNode(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context;let t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new BufferNode(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[];let{buffer:r}=this.context;let n=this.index+4,i=r.buffer[this.index+3];if(i>n){let s=r.buffer[this.index+1];e.push(r.slice(n,i,s));t.push(0)}return new Tree(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function iterStack(e){if(!e.length)return null;let t=0,r=e[0];for(let n=1;n<e.length;n++){let i=e[n];if(i.from>r.from||i.to<r.to){r=i;t=n}}let n=r instanceof TreeNode&&r.index<0?null:r.parent;let i=e.slice();n?i[t]=n:i.splice(t,1);return new StackIterator(i,r)}class StackIterator{constructor(e,t){this.heads=e;this.node=t}get next(){return iterStack(this.heads)}}function stackIterator(e,t,r){let n=e.resolveInner(t,r),i=null;for(let e=n instanceof TreeNode?n:n.context.parent;e;e=e.parent)if(e.index<0){let s=e.parent;(i||(i=[n])).push(s.resolve(t,r));e=s}else{let s=MountedTree.get(e.tree);if(s&&s.overlay&&s.overlay[0].from<=t&&s.overlay[s.overlay.length-1].to>=t){let o=new TreeNode(s.tree,s.overlay[0].from+e.from,-1,e);(i||(i=[n])).push(resolveNode(o,t,r,false))}}return i?iterStack(i):n}class TreeCursor{get name(){return this.type.name}constructor(e,t=0){this.mode=t;this.buffer=null;this.stack=[];this.index=0;this.bufferNode=null;if(e instanceof TreeNode)this.yieldNode(e);else{this._tree=e.context.parent;this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e;this.yieldBuf(e.index)}}yieldNode(e){if(!e)return false;this._tree=e;this.type=e.type;this.from=e.from;this.to=e.to;return true}yieldBuf(e,t){this.index=e;let{start:r,buffer:n}=this.buffer;this.type=t||n.set.types[n.buffer[e]];this.from=r+n.buffer[e+1];this.to=r+n.buffer[e+2];return true}yield(e){if(!e)return false;if(e instanceof TreeNode){this.buffer=null;return this.yieldNode(e)}this.buffer=e.context;return this.yieldBuf(e.index,e.type)}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,r,this.mode));let{buffer:n}=this.buffer;let i=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.buffer.start,r);if(i<0)return false;this.stack.push(this.index);return this.yieldBuf(i)}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,r=this.mode){return this.buffer?!(r&s.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&s.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&s.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();this.buffer=null;return 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));let{buffer:t}=this.buffer,r=this.stack.length-1;if(e<0){let e=r<0?0:this.stack[r]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(r<0?t.buffer.length:t.buffer[this.stack[r]+3]))return this.yieldBuf(e)}return r<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,r,{buffer:n}=this;if(n){if(e>0){if(this.index<n.buffer.buffer.length)return false}else for(let e=0;e<this.index;e++)if(n.buffer.buffer[e+3]<this.index)return false;({index:t,parent:r}=n)}else({index:t,_parent:r}=this._tree);for(;r;({index:t,_parent:r}=r))if(t>-1)for(let n=t+e,i=e<0?-1:r._tree.children.length;n!=i;n+=e){let e=r._tree.children[n];if(this.mode&s.IncludeAnonymous||e instanceof TreeBuffer||!e.type.isAnonymous||hasChild(e))return false}return true}move(e,t){if(t&&this.enterChild(e,0,4))return true;for(;;){if(this.sibling(e))return true;if(this.atLastNode(e)||!this.parent())return false}}next(e=true){return this.move(1,e)}prev(e=true){return this.move(-1,e)}moveTo(e,t=0){while(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))if(!this.parent())break;while(this.enterChild(1,e,t));return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,r=0;if(e&&e.context==this.buffer)e:for(let n=this.index,i=this.stack.length;i>=0;){for(let s=e;s;s=s._parent)if(s.index==n){if(n==this.index)return s;t=s;r=i+1;break e}n=this.stack[--i]}for(let e=r;e<this.stack.length;e++)t=new BufferNode(this.buffer,t,this.stack[e]);return this.bufferNode=new BufferNode(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let r=0;;){let n=false;if(this.type.isAnonymous||e(this)!==false){if(this.firstChild()){r++;continue}this.type.isAnonymous||(n=true)}for(;;){n&&t&&t(this);n=this.type.isAnonymous;if(!r)return;if(this.nextSibling())break;this.parent();r--;n=true}}}matchContext(e){if(!this.buffer)return matchNodeContext(this.node.parent,e);let{buffer:t}=this.buffer,{types:r}=t.set;for(let n=e.length-1,i=this.stack.length-1;n>=0;i--){if(i<0)return matchNodeContext(this._tree,e,n);let s=r[t.buffer[this.stack[i]]];if(!s.isAnonymous){if(e[n]&&e[n]!=s.name)return false;n--}}return true}}function hasChild(e){return e.children.some((e=>e instanceof TreeBuffer||!e.type.isAnonymous||hasChild(e)))}function buildTree(t){var r;let{buffer:n,nodeSet:i,maxBufferLength:s=e,reused:o=[],minRepeatType:l=i.types.length}=t;let f=Array.isArray(n)?new FlatBufferCursor(n,n.length):n;let h=i.types;let u=0,a=0;function takeNode(e,t,r,n,d,p){let{id:c,start:g,end:m,size:x}=f;let y=a,b=u;while(x<0){f.next();if(x==-1){let t=o[c];r.push(t);n.push(g-e);return}if(x==-3){u=c;return}if(x==-4){a=c;return}throw new RangeError(`Unrecognized record size: ${x}`)}let N,w,v=h[c];let T=g-e;if(m-g<=s&&(w=findBufferSize(f.pos-t,d))){let t=new Uint16Array(w.size-w.skip);let r=f.pos-w.size,n=t.length;while(f.pos>r)n=copyToBuffer(w.start,t,n);N=new TreeBuffer(t,m-w.start,i);T=w.start-e}else{let e=f.pos-x;f.next();let t=[],r=[];let n=c>=l?c:-1;let i=0,o=m;while(f.pos>e)if(n>=0&&f.id==n&&f.size>=0){if(f.end<=o-s){makeRepeatLeaf(t,r,g,i,f.end,o,n,y,b);i=t.length;o=f.end}f.next()}else p>2500?takeFlatNode(g,e,t,r):takeNode(g,e,t,r,n,p+1);n>=0&&i>0&&i<t.length&&makeRepeatLeaf(t,r,g,i,g,o,n,y,b);t.reverse();r.reverse();if(n>-1&&i>0){let e=makeBalanced(v,b);N=balanceRange(v,t,r,0,t.length,0,m-g,e,e)}else N=makeTree(v,t,r,m-g,y-m,b)}r.push(N);n.push(T)}function takeFlatNode(e,t,r,n){let o=[];let l=0,h=-1;while(f.pos>t){let{id:e,start:t,end:r,size:n}=f;if(n>4)f.next();else{if(h>-1&&t<h)break;h<0&&(h=r-s);o.push(e,t,r);l++;f.next()}}if(l){let t=new Uint16Array(l*4);let s=o[o.length-2];for(let e=o.length-3,r=0;e>=0;e-=3){t[r++]=o[e];t[r++]=o[e+1]-s;t[r++]=o[e+2]-s;t[r++]=r}r.push(new TreeBuffer(t,o[2]-s,i));n.push(s-e)}}function makeBalanced(e,t){return(r,n,i)=>{let s,o,l=0,f=r.length-1;if(f>=0&&(s=r[f])instanceof Tree){if(!f&&s.type==e&&s.length==i)return s;(o=s.prop(NodeProp.lookAhead))&&(l=n[f]+s.length+o)}return makeTree(e,r,n,i,l,t)}}function makeRepeatLeaf(e,t,r,n,s,o,l,f,h){let u=[],a=[];while(e.length>n){u.push(e.pop());a.push(t.pop()+r-s)}e.push(makeTree(i.types[l],u,a,o-s,f-o,h));t.push(s-r)}function makeTree(e,t,r,n,i,s,o){if(s){let e=[NodeProp.contextHash,s];o=o?[e].concat(o):[e]}if(i>25){let e=[NodeProp.lookAhead,i];o=o?[e].concat(o):[e]}return new Tree(e,t,r,n,o)}function findBufferSize(e,t){let r=f.fork();let n=0,i=0,o=0,h=r.end-s;let u={size:0,start:0,skip:0};e:for(let s=r.pos-e;r.pos>s;){let e=r.size;if(r.id==t&&e>=0){u.size=n;u.start=i;u.skip=o;o+=4;n+=4;r.next();continue}let f=r.pos-e;if(e<0||f<s||r.start<h)break;let a=r.id>=l?4:0;let d=r.start;r.next();while(r.pos>f){if(r.size<0){if(r.size!=-3)break e;a+=4}else r.id>=l&&(a+=4);r.next()}i=d;n+=e;o+=a}if(t<0||n==e){u.size=n;u.start=i;u.skip=o}return u.size>4?u:void 0}function copyToBuffer(e,t,r){let{id:n,start:i,end:s,size:o}=f;f.next();if(o>=0&&n<l){let l=r;if(o>4){let n=f.pos-(o-4);while(f.pos>n)r=copyToBuffer(e,t,r)}t[--r]=l;t[--r]=s-e;t[--r]=i-e;t[--r]=n}else o==-3?u=n:o==-4&&(a=n);return r}let d=[],p=[];while(f.pos>0)takeNode(t.start||0,t.bufferStart||0,d,p,-1,0);let c=(r=t.length)!==null&&r!==void 0?r:d.length?p[0]+d[0].length:0;return new Tree(h[t.topID],d.reverse(),p.reverse(),c)}const o=new WeakMap;function nodeSize(e,t){if(!e.isAnonymous||t instanceof TreeBuffer||t.type!=e)return 1;let r=o.get(t);if(r==null){r=1;for(let n of t.children){if(n.type!=e||!(n instanceof Tree)){r=1;break}r+=nodeSize(e,n)}o.set(t,r)}return r}function balanceRange(e,t,r,n,i,s,o,l,f){let h=0;for(let r=n;r<i;r++)h+=nodeSize(e,t[r]);let u=Math.ceil(h*1.5/8);let a=[],d=[];function divide(t,r,n,i,o){for(let l=n;l<i;){let n=l,h=r[l],p=nodeSize(e,t[l]);l++;for(;l<i;l++){let r=nodeSize(e,t[l]);if(p+r>=u)break;p+=r}if(l==n+1){if(p>u){let e=t[n];divide(e.children,e.positions,0,e.children.length,r[n]+o);continue}a.push(t[n])}else{let i=r[l-1]+t[l-1].length-h;a.push(balanceRange(e,t,r,n,l,h,i,null,f))}d.push(h+o-s)}}divide(t,r,n,i,0);return(l||f)(a,d,o)}class NodeWeakMap{constructor(){this.map=new WeakMap}setBuffer(e,t,r){let n=this.map.get(e);n||this.map.set(e,n=new Map);n.set(t,r)}getBuffer(e,t){let r=this.map.get(e);return r&&r.get(t)}set(e,t){e instanceof BufferNode?this.setBuffer(e.context.buffer,e.index,t):e instanceof TreeNode&&this.map.set(e.tree,t)}get(e){return e instanceof BufferNode?this.getBuffer(e.context.buffer,e.index):e instanceof TreeNode?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class TreeFragment{constructor(e,t,r,n,i=false,s=false){this.from=e;this.to=t;this.tree=r;this.offset=n;this.open=(i?1:0)|(s?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],r=false){let n=[new TreeFragment(0,e.length,e,0,false,r)];for(let r of t)r.to>e.length&&n.push(r);return n}static applyChanges(e,t,r=128){if(!t.length)return e;let n=[];let i=1,s=e.length?e[0]:null;for(let o=0,l=0,f=0;;o++){let h=o<t.length?t[o]:null;let u=h?h.fromA:1e9;if(u-l>=r)while(s&&s.from<u){let t=s;if(l>=t.from||u<=t.to||f){let e=Math.max(t.from,l)-f,r=Math.min(t.to,u)-f;t=e>=r?null:new TreeFragment(e,r,t.tree,t.offset+f,o>0,!!h)}t&&n.push(t);if(s.to>u)break;s=i<e.length?e[i++]:null}if(!h)break;l=h.toA;f=h.toA-h.toB}return n}}class Parser{startParse(e,t,r){typeof e=="string"&&(e=new StringInput(e));r=r?r.length?r.map((e=>new Range(e.from,e.to))):[new Range(0,0)]:[new Range(0,e.length)];return this.createParse(e,t||[],r)}parse(e,t,r){let n=this.startParse(e,t,r);for(;;){let e=n.advance();if(e)return e}}}class StringInput{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return false}read(e,t){return this.string.slice(e,t)}}function parseMixed(e){return(t,r,n,i)=>new MixedParse(t,e,r,n,i)}class InnerParse{constructor(e,t,r,n,i){this.parser=e;this.parse=t;this.overlay=r;this.target=n;this.from=i}}function checkRanges(e){if(!e.length||e.some((e=>e.from>=e.to)))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(e))}class ActiveOverlay{constructor(e,t,r,n,i,s,o){this.parser=e;this.predicate=t;this.mounts=r;this.index=n;this.start=i;this.target=s;this.prev=o;this.depth=0;this.ranges=[]}}const l=new NodeProp({perNode:true});class MixedParse{constructor(e,t,r,n,i){this.nest=t;this.input=r;this.fragments=n;this.ranges=i;this.inner=[];this.innerDone=0;this.baseTree=null;this.stoppedAt=null;this.baseParse=e}advance(){if(this.baseParse){let e=this.baseParse.advance();if(!e)return null;this.baseParse=null;this.baseTree=e;this.startInner();if(this.stoppedAt!=null)for(let e of this.inner)e.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let e=this.baseTree;this.stoppedAt!=null&&(e=new Tree(e.type,e.children,e.positions,e.length,e.propValues.concat([[l,this.stoppedAt]])));return e}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let r=Object.assign(Object.create(null),e.target.props);r[NodeProp.mounted.id]=new MountedTree(t,e.overlay,e.parser);e.target.props=r}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){this.stoppedAt=e;if(this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new FragmentCursor(this.fragments);let t=null;let r=null;let n=new TreeCursor(new TreeNode(this.baseTree,this.ranges[0].from,0,null),s.IncludeAnonymous|s.IgnoreMounts);e:for(let i,s;;){let o,l=true;if(this.stoppedAt!=null&&n.from>=this.stoppedAt)l=false;else if(e.hasNode(n)){if(t){let e=t.mounts.find((e=>e.frag.from<=n.from&&e.frag.to>=n.to&&e.mount.overlay));if(e)for(let r of e.mount.overlay){let i=r.from+e.pos,s=r.to+e.pos;i>=n.from&&s<=n.to&&!t.ranges.some((e=>e.from<s&&e.to>i))&&t.ranges.push({from:i,to:s})}}l=false}else if(r&&(s=checkCover(r.ranges,n.from,n.to)))l=s!=2;else if(!n.type.isAnonymous&&(i=this.nest(n,this.input))&&(n.from<n.to||!i.overlay)){n.tree||materialize(n);let s=e.findMounts(n.from,i.parser);if(typeof i.overlay=="function")t=new ActiveOverlay(i.parser,i.overlay,s,this.inner.length,n.from,n.tree,t);else{let e=punchRanges(this.ranges,i.overlay||(n.from<n.to?[new Range(n.from,n.to)]:[]));e.length&&checkRanges(e);!e.length&&i.overlay||this.inner.push(new InnerParse(i.parser,e.length?i.parser.startParse(this.input,enterFragments(s,e),e):i.parser.startParse(""),i.overlay?i.overlay.map((e=>new Range(e.from-n.from,e.to-n.from))):null,n.tree,e.length?e[0].from:n.from));i.overlay?e.length&&(r={ranges:e,depth:0,prev:r}):l=false}}else if(t&&(o=t.predicate(n))){o===true&&(o=new Range(n.from,n.to));if(o.from<o.to){let e=t.ranges.length-1;e>=0&&t.ranges[e].to==o.from?t.ranges[e]={from:t.ranges[e].from,to:o.to}:t.ranges.push(o)}}if(l&&n.firstChild()){t&&t.depth++;r&&r.depth++}else for(;;){if(n.nextSibling())break;if(!n.parent())break e;if(t&&! --t.depth){let e=punchRanges(this.ranges,t.ranges);if(e.length){checkRanges(e);this.inner.splice(t.index,0,new InnerParse(t.parser,t.parser.startParse(this.input,enterFragments(t.mounts,e),e),t.ranges.map((e=>new Range(e.from-t.start,e.to-t.start))),t.target,e[0].from))}t=t.prev}r&&! --r.depth&&(r=r.prev)}}}}function checkCover(e,t,r){for(let n of e){if(n.from>=r)break;if(n.to>t)return n.from<=t&&n.to>=r?2:1}return 0}function sliceBuf(e,t,r,n,i,s){if(t<r){let o=e.buffer[t+1];n.push(e.slice(t,r,o));i.push(o-s)}}function materialize(e){let{node:t}=e,r=[];let n=t.context.buffer;do{r.push(e.index);e.parent()}while(!e.tree);let i=e.tree,s=i.children.indexOf(n);let o=i.children[s],l=o.buffer,f=[s];function split(e,n,i,s,h,u){let a=r[u];let d=[],p=[];sliceBuf(o,e,a,d,p,s);let c=l[a+1],g=l[a+2];f.push(d.length);let m=u?split(a+4,l[a+3],o.set.types[l[a]],c,g-c,u-1):t.toTree();d.push(m);p.push(c-s);sliceBuf(o,l[a+3],n,d,p,s);return new Tree(i,d,p,h)}i.children[s]=split(0,l.length,NodeType.none,0,o.length,r.length-1);for(let t of f){let r=e.tree.children[t],n=e.tree.positions[t];e.yield(new TreeNode(r,n+e.from,t,e._tree))}}class StructureCursor{constructor(e,t){this.offset=t;this.done=false;this.cursor=e.cursor(s.IncludeAnonymous|s.IgnoreMounts)}moveTo(e){let{cursor:t}=this,r=e-this.offset;while(!this.done&&t.from<r)t.to>=e&&t.enter(r,1,s.IgnoreOverlays|s.ExcludeBuffers)||t.next(false)||(this.done=true)}hasNode(e){this.moveTo(e.from);if(!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return true;if(!(t.children.length&&t.positions[0]==0&&t.children[0]instanceof Tree))break;t=t.children[0]}return false}}class FragmentCursor{constructor(e){var t;this.fragments=e;this.curTo=0;this.fragI=0;if(e.length){let r=this.curFrag=e[0];this.curTo=(t=r.tree.prop(l))!==null&&t!==void 0?t:r.to;this.inner=new StructureCursor(r.tree,-r.offset)}else this.curFrag=this.inner=null}hasNode(e){while(this.curFrag&&e.from>=this.curTo)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;this.fragI++;if(this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=(e=t.tree.prop(l))!==null&&e!==void 0?e:t.to;this.inner=new StructureCursor(t.tree,-t.offset)}}findMounts(e,t){var r;let n=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let e=this.inner.cursor.node;e;e=e.parent){let i=(r=e.tree)===null||r===void 0?void 0:r.prop(NodeProp.mounted);if(i&&i.parser==t)for(let t=this.fragI;t<this.fragments.length;t++){let r=this.fragments[t];if(r.from>=e.to)break;r.tree==this.curFrag.tree&&n.push({frag:r,pos:e.from-r.offset,mount:i})}}}return n}}function punchRanges(e,t){let r=null,n=t;for(let i=1,s=0;i<e.length;i++){let o=e[i-1].to,l=e[i].from;for(;s<n.length;s++){let e=n[s];if(e.from>=l)break;if(!(e.to<=o)){r||(n=r=t.slice());if(e.from<o){r[s]=new Range(e.from,o);e.to>l&&r.splice(s+1,0,new Range(l,e.to))}else e.to>l?r[s--]=new Range(l,e.to):r.splice(s--,1)}}}return n}function findCoverChanges(e,t,r,n){let i=0,s=0,o=false,l=false,f=-1e9;let h=[];for(;;){let u=i==e.length?1e9:o?e[i].to:e[i].from;let a=s==t.length?1e9:l?t[s].to:t[s].from;if(o!=l){let e=Math.max(f,r),t=Math.min(u,a,n);e<t&&h.push(new Range(e,t))}f=Math.min(u,a);if(f==1e9)break;if(u==f)if(o){o=false;i++}else o=true;if(a==f)if(l){l=false;s++}else l=true}return h}function enterFragments(e,t){let r=[];for(let{pos:n,mount:i,frag:s}of e){let e=n+(i.overlay?i.overlay[0].from:0),o=e+i.tree.length;let l=Math.max(s.from,e),f=Math.min(s.to,o);if(i.overlay){let o=i.overlay.map((e=>new Range(e.from+n,e.to+n)));let h=findCoverChanges(t,o,l,f);for(let t=0,n=l;;t++){let o=t==h.length,l=o?f:h[t].from;l>n&&r.push(new TreeFragment(n,l,i.tree,-e,s.from>=n||s.openStart,s.to<=l||s.openEnd));if(o)break;n=h[t].to}}else r.push(new TreeFragment(l,f,i.tree,-e,s.from>=e||s.openStart,s.to<=o||s.openEnd))}return r}export{e as DefaultBufferLength,s as IterMode,MountedTree,NodeProp,NodeSet,NodeType,NodeWeakMap,Parser,Tree,TreeBuffer,TreeCursor,TreeFragment,parseMixed};+diff --git a/admin/vendor/javascript/@lezer--highlight.js b/admin/vendor/javascript/@lezer--highlight.jsnew file mode 100644index 0000000000..82f67061fb--- /dev/null+++ b/admin/vendor/javascript/@lezer--highlight.js@@ -0,0 +1,4 @@+// @lezer/[email protected] downloaded from https://ga.jspm.io/npm:@lezer/[email protected]/dist/index.js++import{NodeProp as t}from"@lezer/common";let e=0;class Tag{constructor(t,a,i,r){this.name=t;this.set=a;this.base=i;this.modified=r;this.id=e++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let a=typeof t=="string"?t:"?";t instanceof Tag&&(e=t);if(e===null||e===void 0?void 0:e.base)throw new Error("Can not derive from a modified tag");let i=new Tag(a,[],null,[]);i.set.push(i);if(e)for(let t of e.set)i.set.push(t);return i}static defineModifier(t){let e=new Modifier(t);return t=>t.modified.indexOf(e)>-1?t:Modifier.get(t.base||t,t.modified.concat(e).sort(((t,e)=>t.id-e.id)))}}let a=0;class Modifier{constructor(t){this.name=t;this.instances=[];this.id=a++}static get(t,e){if(!e.length)return t;let a=e[0].instances.find((a=>a.base==t&&sameArray(e,a.modified)));if(a)return a;let i=[],r=new Tag(t.name,i,t,e);for(let t of e)t.instances.push(r);let o=powerSet(e);for(let e of t.set)if(!e.modified.length)for(let t of o)i.push(Modifier.get(e,t));return r}}function sameArray(t,e){return t.length==e.length&&t.every(((t,a)=>t==e[a]))}function powerSet(t){let e=[[]];for(let a=0;a<t.length;a++)for(let i=0,r=e.length;i<r;i++)e.push(e[i].concat(t[a]));return e.sort(((t,e)=>e.length-t.length))}function styleTags(t){let e=Object.create(null);for(let a in t){let i=t[a];Array.isArray(i)||(i=[i]);for(let t of a.split(" "))if(t){let a=[],r=2,o=t;for(let e=0;;){if(o=="..."&&e>0&&e+3==t.length){r=1;break}let i=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!i)throw new RangeError("Invalid path: "+t);a.push(i[0]=="*"?"":i[0][0]=='"'?JSON.parse(i[0]):i[0]);e+=i[0].length;if(e==t.length)break;let l=t[e++];if(e==t.length&&l=="!"){r=0;break}if(l!="/")throw new RangeError("Invalid path: "+t);o=t.slice(e)}let l=a.length-1,s=a[l];if(!s)throw new RangeError("Invalid path: "+t);let n=new Rule(i,r,l>0?a.slice(0,l):null);e[s]=n.sort(e[s])}}return i.add(e)}const i=new t;class Rule{constructor(t,e,a,i){this.tags=t;this.mode=e;this.context=a;this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){if(!t||t.depth<this.depth){this.next=t;return this}t.next=this.sort(t.next);return t}get depth(){return this.context?this.context.length:0}}Rule.empty=new Rule([],2,null);function tagHighlighter(t,e){let a=Object.create(null);for(let e of t)if(Array.isArray(e.tag))for(let t of e.tag)a[t.id]=e.class;else a[e.tag.id]=e.class;let{scope:i,all:r=null}=e||{};return{style:t=>{let e=r;for(let i of t)for(let t of i.set){let i=a[t.id];if(i){e=e?e+" "+i:i;break}}return e},scope:i}}function highlightTags(t,e){let a=null;for(let i of t){let t=i.style(e);t&&(a=a?a+" "+t:t)}return a}function highlightTree(t,e,a,i=0,r=t.length){let o=new HighlightBuilder(i,Array.isArray(e)?e:[e],a);o.highlightRange(t.cursor(),i,r,"",o.highlighters);o.flush(r)}function highlightCode(t,e,a,i,r,o=0,l=t.length){let s=o;function writeTo(e,a){if(!(e<=s)){for(let o=t.slice(s,e),l=0;;){let t=o.indexOf("\n",l);let e=t<0?o.length:t;e>l&&i(o.slice(l,e),a);if(t<0)break;r();l=t+1}s=e}}highlightTree(e,a,((t,e,a)=>{writeTo(t,"");writeTo(e,a)}),o,l);writeTo(l,"")}class HighlightBuilder{constructor(t,e,a){this.at=t;this.highlighters=e;this.span=a;this.class=""}startSpan(t,e){if(e!=this.class){this.flush(t);t>this.at&&(this.at=t);this.class=e}}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(e,a,i,r,o){let{type:l,from:s,to:n}=e;if(s>=i||n<=a)return;l.isTop&&(o=this.highlighters.filter((t=>!t.scope||t.scope(l))));let h=r;let g=getStyleTags(e)||Rule.empty;let c=highlightTags(o,g.tags);if(c){h&&(h+=" ");h+=c;g.mode==1&&(r+=(r?" ":"")+c)}this.startSpan(Math.max(a,s),h);if(g.opaque)return;let f=e.tree&&e.tree.prop(t.mounted);if(f&&f.overlay){let t=e.node.enter(f.overlay[0].from+s,1);let l=this.highlighters.filter((t=>!t.scope||t.scope(f.tree.type)));let g=e.firstChild();for(let c=0,d=s;;c++){let m=c<f.overlay.length?f.overlay[c]:null;let p=m?m.from+s:n;let u=Math.max(a,d),k=Math.min(i,p);if(u<k&&g)while(e.from<k){this.highlightRange(e,u,k,r,o);this.startSpan(Math.min(k,e.to),h);if(e.to>=p||!e.nextSibling())break}if(!m||p>i)break;d=m.to+s;if(d>a){this.highlightRange(t.cursor(),Math.max(a,m.from+s),Math.min(i,d),"",l);this.startSpan(Math.min(i,d),h)}}g&&e.parent()}else if(e.firstChild()){f&&(r="");do{if(!(e.to<=a)){if(e.from>=i)break;this.highlightRange(e,a,i,r,o);this.startSpan(Math.min(i,e.to),h)}}while(e.nextSibling());e.parent()}}}function getStyleTags(t){let e=t.type.prop(i);while(e&&e.context&&!t.matchContext(e.context))e=e.next;return e||null}const r=Tag.define;const o=r(),l=r(),s=r(l),n=r(l),h=r(),g=r(h),c=r(h),f=r(),d=r(f),m=r(),p=r(),u=r(),k=r(u),y=r();const b={comment:o,lineComment:r(o),blockComment:r(o),docComment:r(o),name:l,variableName:r(l),typeName:s,tagName:r(s),propertyName:n,attributeName:r(n),className:r(l),labelName:r(l),namespace:r(l),macroName:r(l),literal:h,string:g,docString:r(g),character:r(g),attributeValue:r(g),number:c,integer:r(c),float:r(c),bool:r(h),regexp:r(h),escape:r(h),color:r(h),url:r(h),keyword:m,self:r(m),null:r(m),atom:r(m),unit:r(m),modifier:r(m),operatorKeyword:r(m),controlKeyword:r(m),definitionKeyword:r(m),moduleKeyword:r(m),operator:p,derefOperator:r(p),arithmeticOperator:r(p),logicOperator:r(p),bitwiseOperator:r(p),compareOperator:r(p),updateOperator:r(p),definitionOperator:r(p),typeOperator:r(p),controlOperator:r(p),punctuation:u,separator:r(u),bracket:k,angleBracket:r(k),squareBracket:r(k),paren:r(k),brace:r(k),content:f,heading:d,heading1:r(d),heading2:r(d),heading3:r(d),heading4:r(d),heading5:r(d),heading6:r(d),contentSeparator:r(f),list:r(f),quote:r(f),emphasis:r(f),strong:r(f),link:r(f),monospace:r(f),strikethrough:r(f),inserted:r(),deleted:r(),changed:r(),invalid:r(),meta:y,documentMeta:r(y),annotation:r(y),processingInstruction:r(y),definition:Tag.defineModifier("definition"),constant:Tag.defineModifier("constant"),function:Tag.defineModifier("function"),standard:Tag.defineModifier("standard"),local:Tag.defineModifier("local"),special:Tag.defineModifier("special")};for(let t in b){let e=b[t];e instanceof Tag&&(e.name=t)}const w=tagHighlighter([{tag:b.link,class:"tok-link"},{tag:b.heading,class:"tok-heading"},{tag:b.emphasis,class:"tok-emphasis"},{tag:b.strong,class:"tok-strong"},{tag:b.keyword,class:"tok-keyword"},{tag:b.atom,class:"tok-atom"},{tag:b.bool,class:"tok-bool"},{tag:b.url,class:"tok-url"},{tag:b.labelName,class:"tok-labelName"},{tag:b.inserted,class:"tok-inserted"},{tag:b.deleted,class:"tok-deleted"},{tag:b.literal,class:"tok-literal"},{tag:b.string,class:"tok-string"},{tag:b.number,class:"tok-number"},{tag:[b.regexp,b.escape,b.special(b.string)],class:"tok-string2"},{tag:b.variableName,class:"tok-variableName"},{tag:b.local(b.variableName),class:"tok-variableName tok-local"},{tag:b.definition(b.variableName),class:"tok-variableName tok-definition"},{tag:b.special(b.variableName),class:"tok-variableName2"},{tag:b.definition(b.propertyName),class:"tok-propertyName tok-definition"},{tag:b.typeName,class:"tok-typeName"},{tag:b.namespace,class:"tok-namespace"},{tag:b.className,class:"tok-className"},{tag:b.macroName,class:"tok-macroName"},{tag:b.propertyName,class:"tok-propertyName"},{tag:b.operator,class:"tok-operator"},{tag:b.comment,class:"tok-comment"},{tag:b.meta,class:"tok-meta"},{tag:b.invalid,class:"tok-invalid"},{tag:b.punctuation,class:"tok-punctuation"}]);export{Tag,w as classHighlighter,getStyleTags,highlightCode,highlightTree,styleTags,tagHighlighter,b as tags};+diff --git a/admin/vendor/javascript/@lezer--json.js b/admin/vendor/javascript/@lezer--json.jsnew file mode 100644index 0000000000..301e7de4a0--- /dev/null+++ b/admin/vendor/javascript/@lezer--json.js@@ -0,0 +1,4 @@+// @lezer/[email protected] downloaded from https://ga.jspm.io/npm:@lezer/[email protected]/dist/index.js++import{LRParser as O}from"@lezer/lr";import{styleTags as P,tags as e}from"@lezer/highlight";const Q=P({String:e.string,Number:e.number,"True False":e.bool,PropertyName:e.propertyName,Null:e.null,", :":e.separator,"[ ]":e.squareBracket,"{ }":e.brace});const r=O.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[Q],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0});export{r as parser};+diff --git a/admin/vendor/javascript/@lezer--lr.js b/admin/vendor/javascript/@lezer--lr.jsnew file mode 100644index 0000000000..722715dab4--- /dev/null+++ b/admin/vendor/javascript/@lezer--lr.js@@ -0,0 +1,4 @@+// @lezer/[email protected] downloaded from https://ga.jspm.io/npm:@lezer/[email protected]/dist/index.js++import{IterMode as t,Tree as e,NodeProp as s,Parser as i,NodeSet as r,NodeType as h,DefaultBufferLength as n}from"@lezer/common";class Stack{constructor(t,e,s,i,r,h,n,o,a,l=0,c){this.p=t;this.stack=e;this.state=s;this.reducePos=i;this.pos=r;this.score=h;this.buffer=n;this.bufferBase=o;this.curContext=a;this.lookAhead=l;this.parent=c}toString(){return`[${this.stack.filter(((t,e)=>e%3==0)).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,e,s=0){let i=t.parser.context;return new Stack(t,[],e,s,s,0,[],0,i?new StackContext(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,e){this.stack.push(this.state,e,this.bufferBase+this.buffer.length);this.state=t}reduce(t){var e;let s=t>>19,i=t&65535;let{parser:r}=this.p;let h=this.reducePos<this.pos-25;h&&this.setLookAhead(this.pos);let n=r.dynamicPrecedence(i);n&&(this.score+=n);if(s==0){this.pushState(r.getGoto(this.state,i,true),this.reducePos);i<r.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,h?8:4,true);this.reduceContext(i,this.reducePos);return}let o=this.stack.length-3*(s-1)-(t&262144?6:0);let a=o?this.stack[o-2]:this.p.ranges[0].from,l=this.reducePos-a;if(l>=2e3&&!((e=this.p.parser.nodeSet.types[i])===null||e===void 0?void 0:e.isAnonymous))if(a==this.p.lastBigReductionStart){this.p.bigReductionCount++;this.p.lastBigReductionSize=l}else if(this.p.lastBigReductionSize<l){this.p.bigReductionCount=1;this.p.lastBigReductionStart=a;this.p.lastBigReductionSize=l}let c=o?this.stack[o-1]:0,u=this.bufferBase+this.buffer.length-c;if(i<r.minRepeatTerm||t&131072){let t=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,a,t,u+4,true)}if(t&262144)this.state=this.stack[o];else{let t=this.stack[o-3];this.state=r.getGoto(t,i,true)}while(this.stack.length>o)this.stack.pop();this.reduceContext(i,a)}storeNode(t,e,s,i=4,r=false){if(t==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let t=this,i=this.buffer.length;if(i==0&&t.parent){i=t.bufferBase-t.parent.bufferBase;t=t.parent}if(i>0&&t.buffer[i-4]==0&&t.buffer[i-1]>-1){if(e==s)return;if(t.buffer[i-2]>=e){t.buffer[i-2]=s;return}}}if(r&&this.pos!=s){let r=this.buffer.length;if(r>0&&this.buffer[r-4]!=0){let t=false;for(let e=r;e>0&&this.buffer[e-2]>s;e-=4)if(this.buffer[e-1]>=0){t=true;break}if(t)while(r>0&&this.buffer[r-2]>s){this.buffer[r]=this.buffer[r-4];this.buffer[r+1]=this.buffer[r-3];this.buffer[r+2]=this.buffer[r-2];this.buffer[r+3]=this.buffer[r-1];r-=4;i>4&&(i-=4)}}this.buffer[r]=t;this.buffer[r+1]=e;this.buffer[r+2]=s;this.buffer[r+3]=i}else this.buffer.push(t,e,s,i)}shift(t,e,s,i){if(t&131072)this.pushState(t&65535,this.pos);else if((t&262144)==0){let r=t,{parser:h}=this.p;if(i>this.pos||e<=h.maxNode){this.pos=i;h.stateFlag(r,1)||(this.reducePos=i)}this.pushState(r,s);this.shiftContext(e,s);e<=h.maxNode&&this.buffer.push(e,s,i,4)}else{this.pos=i;this.shiftContext(e,s);e<=this.p.parser.maxNode&&this.buffer.push(e,s,i,4)}}apply(t,e,s,i){t&65536?this.reduce(t):this.shift(t,e,s,i)}useNode(t,e){let s=this.p.reused.length-1;if(s<0||this.p.reused[s]!=t){this.p.reused.push(t);s++}let i=this.pos;this.reducePos=this.pos=i+t.length;this.pushState(e,i);this.buffer.push(s,i,this.reducePos,-1);this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this;let e=t.buffer.length;while(e>0&&t.buffer[e-2]>t.reducePos)e-=4;let s=t.buffer.slice(e),i=t.bufferBase+e;while(t&&i==t.bufferBase)t=t.parent;return new Stack(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,s,i,this.curContext,this.lookAhead,t)}recoverByDelete(t,e){let s=t<=this.p.parser.maxNode;s&&this.storeNode(t,this.pos,e,4);this.storeNode(0,this.pos,e,s?8:4);this.pos=this.reducePos=e;this.score-=190}canShift(t){for(let e=new SimulatedStack(this);;){let s=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,t);if(s==0)return false;if((s&65536)==0)return true;e.reduce(s)}}recoverByInsert(t){if(this.stack.length>=300)return[];let e=this.p.parser.nextStates(this.state);if(e.length>8||this.stack.length>=120){let s=[];for(let i,r=0;r<e.length;r+=2)(i=e[r+1])!=this.state&&this.p.parser.hasAction(i,t)&&s.push(e[r],i);if(this.stack.length<120)for(let t=0;s.length<8&&t<e.length;t+=2){let i=e[t+1];s.some(((t,e)=>e&1&&t==i))||s.push(e[t],i)}e=s}let s=[];for(let t=0;t<e.length&&s.length<4;t+=2){let i=e[t+1];if(i==this.state)continue;let r=this.split();r.pushState(i,this.pos);r.storeNode(0,r.pos,r.pos,4,true);r.shiftContext(e[t],this.pos);r.reducePos=this.pos;r.score-=200;s.push(r)}return s}forceReduce(){let{parser:t}=this.p;let e=t.stateSlot(this.state,5);if((e&65536)==0)return false;if(!t.validAction(this.state,e)){let s=e>>19,i=e&65535;let r=this.stack.length-s*3;if(r<0||t.getGoto(this.stack[r],i,false)<0){let t=this.findForcedReduction();if(t==null)return false;e=t}this.storeNode(0,this.pos,this.pos,4,true);this.score-=100}this.reducePos=this.pos;this.reduce(e);return true}findForcedReduction(){let{parser:t}=this.p,e=[];let explore=(s,i)=>{if(!e.includes(s)){e.push(s);return t.allActions(s,(e=>{if(e&393216);else if(e&65536){let s=(e>>19)-i;if(s>1){let i=e&65535,r=this.stack.length-s*3;if(r>=0&&t.getGoto(this.stack[r],i,false)>=0)return s<<19|65536|i}}else{let t=explore(e,i+1);if(t!=null)return t}}))}};return explore(this.state,0)}forceAll(){while(!this.p.parser.stateFlag(this.state,2))if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,true);break}return this}get deadEnd(){if(this.stack.length!=3)return false;let{parser:t}=this.p;return t.data[t.stateSlot(this.state,1)]==65535&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,true);this.state=this.stack[0];this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return false;for(let e=0;e<this.stack.length;e+=3)if(this.stack[e]!=t.stack[e])return false;return true}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(e)))}reduceContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(e)))}emitContext(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let e=new StackContext(this.curContext.tracker,t);e.hash!=this.curContext.hash&&this.emitContext();this.curContext=e}}setLookAhead(t){if(t>this.lookAhead){this.emitLookAhead();this.lookAhead=t}}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext();this.lookAhead>0&&this.emitLookAhead()}}class StackContext{constructor(t,e){this.tracker=t;this.context=e;this.hash=t.strict?t.hash(e):0}}class SimulatedStack{constructor(t){this.start=t;this.state=t.state;this.stack=t.stack;this.base=this.stack.length}reduce(t){let e=t&65535,s=t>>19;if(s==0){this.stack==this.start.stack&&(this.stack=this.stack.slice());this.stack.push(this.state,0,0);this.base+=3}else this.base-=3*(s-1);let i=this.start.p.parser.getGoto(this.stack[this.base-3],e,true);this.state=i}}class StackBufferCursor{constructor(t,e,s){this.stack=t;this.pos=e;this.index=s;this.buffer=t.buffer;this.index==0&&this.maybeNext()}static create(t,e=t.bufferBase+t.buffer.length){return new StackBufferCursor(t,e,e-t.bufferBase)}maybeNext(){let t=this.stack.parent;if(t!=null){this.index=this.stack.bufferBase-t.bufferBase;this.stack=t;this.buffer=t.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 StackBufferCursor(this.stack,this.pos,this.index)}}function decodeArray(t,e=Uint16Array){if(typeof t!="string")return t;let s=null;for(let i=0,r=0;i<t.length;){let h=0;for(;;){let e=t.charCodeAt(i++),s=false;if(e==126){h=65535;break}e>=92&&e--;e>=34&&e--;let r=e-32;if(r>=46){r-=46;s=true}h+=r;if(s)break;h*=46}s?s[r++]=h:s=new e(h)}return s}class CachedToken{constructor(){this.start=-1;this.value=-1;this.end=-1;this.extended=-1;this.lookAhead=0;this.mask=0;this.context=0}}const o=new CachedToken;class InputStream{constructor(t,e){this.input=t;this.ranges=e;this.chunk="";this.chunkOff=0;this.chunk2="";this.chunk2Pos=0;this.next=-1;this.token=o;this.rangeIndex=0;this.pos=this.chunkPos=e[0].from;this.range=e[0];this.end=e[e.length-1].to;this.readNext()}resolveOffset(t,e){let s=this.range,i=this.rangeIndex;let r=this.pos+t;while(r<s.from){if(!i)return null;let t=this.ranges[--i];r-=s.from-t.to;s=t}while(e<0?r>s.to:r>=s.to){if(i==this.ranges.length-1)return null;let t=this.ranges[++i];r+=t.from-s.to;s=t}return r}clipPos(t){if(t>=this.range.from&&t<this.range.to)return t;for(let e of this.ranges)if(e.to>t)return Math.max(t,e.from);return this.end}peek(t){let e,s,i=this.chunkOff+t;if(i>=0&&i<this.chunk.length){e=this.pos+t;s=this.chunk.charCodeAt(i)}else{let i=this.resolveOffset(t,1);if(i==null)return-1;e=i;if(e>=this.chunk2Pos&&e<this.chunk2Pos+this.chunk2.length)s=this.chunk2.charCodeAt(e-this.chunk2Pos);else{let t=this.rangeIndex,i=this.range;while(i.to<=e)i=this.ranges[++t];this.chunk2=this.input.chunk(this.chunk2Pos=e);e+this.chunk2.length>i.to&&(this.chunk2=this.chunk2.slice(0,i.to-e));s=this.chunk2.charCodeAt(0)}}e>=this.token.lookAhead&&(this.token.lookAhead=e+1);return s}acceptToken(t,e=0){let s=e?this.resolveOffset(e,-1):this.pos;if(s==null||s<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=t;this.token.end=s}acceptTokenTo(t,e){this.token.value=t;this.token.end=e}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:t,chunkPos:e}=this;this.chunk=this.chunk2;this.chunkPos=this.chunk2Pos;this.chunk2=t;this.chunk2Pos=e;this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk;this.chunk2Pos=this.chunkPos;let t=this.input.chunk(this.pos);let e=this.pos+t.length;this.chunk=e>this.range.to?t.slice(0,this.range.to-this.pos):t;this.chunkPos=this.pos;this.chunkOff=0}}readNext(){if(this.chunkOff>=this.chunk.length){this.getChunk();if(this.chunkOff==this.chunk.length)return this.next=-1}return this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){this.chunkOff+=t;while(this.pos+t>=this.range.to){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos;this.range=this.ranges[++this.rangeIndex];this.pos=this.range.from}this.pos+=t;this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1);return this.readNext()}setDone(){this.pos=this.chunkPos=this.end;this.range=this.ranges[this.rangeIndex=this.ranges.length-1];this.chunk="";return this.next=-1}reset(t,e){if(e){this.token=e;e.start=t;e.lookAhead=t+1;e.value=e.extended=-1}else this.token=o;if(this.pos!=t){this.pos=t;if(t==this.end){this.setDone();return this}while(t<this.range.from)this.range=this.ranges[--this.rangeIndex];while(t>=this.range.to)this.range=this.ranges[++this.rangeIndex];if(t>=this.chunkPos&&t<this.chunkPos+this.chunk.length)this.chunkOff=t-this.chunkPos;else{this.chunk="";this.chunkOff=0}this.readNext()}return this}read(t,e){if(t>=this.chunkPos&&e<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,e-this.chunkPos);if(t>=this.chunk2Pos&&e<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,e-this.chunk2Pos);if(t>=this.range.from&&e<=this.range.to)return this.input.read(t,e);let s="";for(let i of this.ranges){if(i.from>=e)break;i.to>t&&(s+=this.input.read(Math.max(i.from,t),Math.min(i.to,e)))}return s}}class TokenGroup{constructor(t,e){this.data=t;this.id=e}token(t,e){let{parser:s}=e.p;readToken(this.data,t,e,this.id,s.data,s.tokenPrecTable)}}TokenGroup.prototype.contextual=TokenGroup.prototype.fallback=TokenGroup.prototype.extend=false;class LocalTokenGroup{constructor(t,e,s){this.precTable=e;this.elseToken=s;this.data=typeof t=="string"?decodeArray(t):t}token(t,e){let s=t.pos,i=0;for(;;){let s=t.next<0,r=t.resolveOffset(1,1);readToken(this.data,t,e,0,this.data,this.precTable);if(t.token.value>-1)break;if(this.elseToken==null)return;s||i++;if(r==null)break;t.reset(r,t.token)}if(i){t.reset(s,t.token);t.acceptToken(this.elseToken,i)}}}LocalTokenGroup.prototype.contextual=TokenGroup.prototype.fallback=TokenGroup.prototype.extend=false;class ExternalTokenizer{constructor(t,e={}){this.token=t;this.contextual=!!e.contextual;this.fallback=!!e.fallback;this.extend=!!e.extend}}function readToken(t,e,s,i,r,h){let n=0,o=1<<i,{dialect:a}=s.p.parser;t:for(;;){if((o&t[n])==0)break;let s=t[n+1];for(let i=n+3;i<s;i+=2)if((t[i+1]&o)>0){let s=t[i];if(a.allows(s)&&(e.token.value==-1||e.token.value==s||overrides(s,e.token.value,r,h))){e.acceptToken(s);break}}let i=e.next,l=0,c=t[n+2];if(!(e.next<0&&c>l&&t[s+c*3-3]==65535)){for(;l<c;){let r=l+c>>1;let h=s+r+(r<<1);let o=t[h],a=t[h+1]||65536;if(i<o)c=r;else{if(!(i>=a)){n=t[h+2];e.advance();continue t}l=r+1}}break}n=t[s+c*3-1]}}function findOffset(t,e,s){for(let i,r=e;(i=t[r])!=65535;r++)if(i==s)return r-e;return-1}function overrides(t,e,s,i){let r=findOffset(s,i,e);return r<0||findOffset(s,i,t)<r}const a=typeof process!="undefined"&&process.env&&/\bparse\b/.test(process.env.LOG);let l=null;function cutAt(e,s,i){let r=e.cursor(t.IncludeAnonymous);r.moveTo(s);for(;;)if(!(i<0?r.childBefore(s):r.childAfter(s)))for(;;){if((i<0?r.to<s:r.from>s)&&!r.type.isError)return i<0?Math.max(0,Math.min(r.to-1,s-25)):Math.min(e.length,Math.max(r.from+1,s+25));if(i<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return i<0?0:e.length}}class FragmentCursor{constructor(t,e){this.fragments=t;this.nodeSet=e;this.i=0;this.fragment=null;this.safeFrom=-1;this.safeTo=-1;this.trees=[];this.start=[];this.index=[];this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){this.safeFrom=t.openStart?cutAt(t.tree,t.from+t.offset,1)-t.offset:t.from;this.safeTo=t.openEnd?cutAt(t.tree,t.to+t.offset,-1)-t.offset:t.to;while(this.trees.length){this.trees.pop();this.start.pop();this.index.pop()}this.trees.push(t.tree);this.start.push(-t.offset);this.index.push(0);this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;while(this.fragment&&this.safeTo<=t)this.nextFragment();if(!this.fragment)return null;for(;;){let i=this.trees.length-1;if(i<0){this.nextFragment();return null}let r=this.trees[i],h=this.index[i];if(h==r.children.length){this.trees.pop();this.start.pop();this.index.pop();continue}let n=r.children[h];let o=this.start[i]+r.positions[h];if(o>t){this.nextStart=o;return null}if(n instanceof e){if(o==t){if(o<this.safeFrom)return null;let t=o+n.length;if(t<=this.safeTo){let e=n.prop(s.lookAhead);if(!e||t+e<this.fragment.to)return n}}this.index[i]++;if(o+n.length>=Math.max(this.safeFrom,t)){this.trees.push(n);this.start.push(o);this.index.push(0)}}else{this.index[i]++;this.nextStart=o+n.length}}}}class TokenCache{constructor(t,e){this.stream=e;this.tokens=[];this.mainToken=null;this.actions=[];this.tokens=t.tokenizers.map((t=>new CachedToken))}getActions(t){let e=0;let s=null;let{parser:i}=t.p,{tokenizers:r}=i;let h=i.stateSlot(t.state,3);let n=t.curContext?t.curContext.hash:0;let o=0;for(let i=0;i<r.length;i++){if((1<<i&h)==0)continue;let a=r[i],l=this.tokens[i];if(!s||a.fallback){if(a.contextual||l.start!=t.pos||l.mask!=h||l.context!=n){this.updateCachedToken(l,a,t);l.mask=h;l.context=n}l.lookAhead>l.end+25&&(o=Math.max(l.lookAhead,o));if(l.value!=0){let i=e;l.extended>-1&&(e=this.addActions(t,l.extended,l.end,e));e=this.addActions(t,l.value,l.end,e);if(!a.extend){s=l;if(e>i)break}}}}while(this.actions.length>e)this.actions.pop();o&&t.setLookAhead(o);if(!s&&t.pos==this.stream.end){s=new CachedToken;s.value=t.p.parser.eofTerm;s.start=s.end=t.pos;e=this.addActions(t,s.value,s.end,e)}this.mainToken=s;return this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let e=new CachedToken,{pos:s,p:i}=t;e.start=s;e.end=Math.min(s+1,i.stream.end);e.value=s==i.stream.end?i.parser.eofTerm:0;return e}updateCachedToken(t,e,s){let i=this.stream.clipPos(s.pos);e.token(this.stream.reset(i,t),s);if(t.value>-1){let{parser:e}=s.p;for(let i=0;i<e.specialized.length;i++)if(e.specialized[i]==t.value){let r=e.specializers[i](this.stream.read(t.start,t.end),s);if(r>=0&&s.p.parser.dialect.allows(r>>1)){(r&1)==0?t.value=r>>1:t.extended=r>>1;break}}}else{t.value=0;t.end=this.stream.clipPos(i+1)}}putAction(t,e,s,i){for(let e=0;e<i;e+=3)if(this.actions[e]==t)return i;this.actions[i++]=t;this.actions[i++]=e;this.actions[i++]=s;return i}addActions(t,e,s,i){let{state:r}=t,{parser:h}=t.p,{data:n}=h;for(let t=0;t<2;t++)for(let o=h.stateSlot(r,t?2:1);;o+=3){if(n[o]==65535){if(n[o+1]!=1){i==0&&n[o+1]==2&&(i=this.putAction(pair(n,o+2),e,s,i));break}o=pair(n,o+2)}n[o]==e&&(i=this.putAction(pair(n,o+1),e,s,i))}return i}}class Parse{constructor(t,e,s,i){this.parser=t;this.input=e;this.ranges=i;this.recovering=0;this.nextStackID=9812;this.minStackPos=0;this.reused=[];this.stoppedAt=null;this.lastBigReductionStart=-1;this.lastBigReductionSize=0;this.bigReductionCount=0;this.stream=new InputStream(e,i);this.tokens=new TokenCache(t,this.stream);this.topTerm=t.top[1];let{from:r}=i[0];this.stacks=[Stack.start(this,t.top[0],r)];this.fragments=s.length&&this.stream.end-r>t.bufferLength*4?new FragmentCursor(s,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t=this.stacks,e=this.minStackPos;let s=this.stacks=[];let i,r;if(this.bigReductionCount>300&&t.length==1){let[e]=t;while(e.forceReduce()&&e.stack.length&&e.stack[e.stack.length-2]>=this.lastBigReductionStart);this.bigReductionCount=this.lastBigReductionSize=0}for(let h=0;h<t.length;h++){let n=t[h];for(;;){this.tokens.mainToken=null;if(n.pos>e)s.push(n);else{if(this.advanceStack(n,s,t))continue;{if(!i){i=[];r=[]}i.push(n);let t=this.tokens.getMainToken(n);r.push(t.value,t.end)}}break}}if(!s.length){let t=i&&findFinished(i);if(t){a&&console.log("Finish with "+this.stackID(t));return this.stackToTree(t)}if(this.parser.strict){a&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none"));throw new SyntaxError("No parse at "+e)}this.recovering||(this.recovering=5)}if(this.recovering&&i){let t=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,r,s);if(t){a&&console.log("Force-finish "+this.stackID(t));return this.stackToTree(t.forceAll())}}if(this.recovering){let t=this.recovering==1?1:this.recovering*3;if(s.length>t){s.sort(((t,e)=>e.score-t.score));while(s.length>t)s.pop()}s.some((t=>t.reducePos>e))&&this.recovering--}else if(s.length>1){t:for(let t=0;t<s.length-1;t++){let e=s[t];for(let i=t+1;i<s.length;i++){let r=s[i];if(e.sameState(r)||e.buffer.length>500&&r.buffer.length>500){if(!((e.score-r.score||e.buffer.length-r.buffer.length)>0)){s.splice(t--,1);continue t}s.splice(i--,1)}}}s.length>12&&s.splice(12,s.length-12)}this.minStackPos=s[0].pos;for(let t=1;t<s.length;t++)s[t].pos<this.minStackPos&&(this.minStackPos=s[t].pos);return null}stopAt(t){if(this.stoppedAt!=null&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}advanceStack(t,i,r){let h=t.pos,{parser:n}=this;let o=a?this.stackID(t)+" -> ":"";if(this.stoppedAt!=null&&h>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let i=t.curContext&&t.curContext.tracker.strict,r=i?t.curContext.hash:0;for(let l=this.fragments.nodeAt(h);l;){let h=this.parser.nodeSet.types[l.type.id]==l.type?n.getGoto(t.state,l.type.id):-1;if(h>-1&&l.length&&(!i||(l.prop(s.contextHash)||0)==r)){t.useNode(l,h);a&&console.log(o+this.stackID(t)+` (via reuse of ${n.getName(l.type.id)})`);return true}if(!(l instanceof e)||l.children.length==0||l.positions[0]>0)break;let c=l.children[0];if(!(c instanceof e&&l.positions[0]==0))break;l=c}}let l=n.stateSlot(t.state,4);if(l>0){t.reduce(l);a&&console.log(o+this.stackID(t)+` (via always-reduce ${n.getName(l&65535)})`);return true}if(t.stack.length>=8400)while(t.stack.length>6e3&&t.forceReduce());let c=this.tokens.getActions(t);for(let e=0;e<c.length;){let s=c[e++],l=c[e++],u=c[e++];let f=e==c.length||!r;let p=f?t:t.split();let d=this.tokens.mainToken;p.apply(s,l,d?d.start:p.pos,u);a&&console.log(o+this.stackID(p)+` (via ${(s&65536)==0?"shift":`reduce of ${n.getName(s&65535)}`} for ${n.getName(l)} @ ${h}${p==t?"":", split"})`);if(f)return true;p.pos>h?i.push(p):r.push(p)}return false}advanceFully(t,e){let s=t.pos;for(;;){if(!this.advanceStack(t,null,null))return false;if(t.pos>s){pushStackDedup(t,e);return true}}}runRecovery(t,e,s){let i=null,r=false;for(let h=0;h<t.length;h++){let n=t[h],o=e[h<<1],l=e[1+(h<<1)];let c=a?this.stackID(n)+" -> ":"";if(n.deadEnd){if(r)continue;r=true;n.restart();a&&console.log(c+this.stackID(n)+" (restarted)");let t=this.advanceFully(n,s);if(t)continue}let u=n.split(),f=c;for(let t=0;u.forceReduce()&&t<10;t++){a&&console.log(f+this.stackID(u)+" (via force-reduce)");let t=this.advanceFully(u,s);if(t)break;a&&(f=this.stackID(u)+" -> ")}for(let t of n.recoverByInsert(o)){a&&console.log(c+this.stackID(t)+" (via recover-insert)");this.advanceFully(t,s)}if(this.stream.end>n.pos){if(l==n.pos){l++;o=0}n.recoverByDelete(o,l);a&&console.log(c+this.stackID(n)+` (via recover-delete ${this.parser.getName(o)})`);pushStackDedup(n,s)}else(!i||i.score<n.score)&&(i=n)}return i}stackToTree(t){t.close();return e.build({buffer:StackBufferCursor.create(t),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:t.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(t){let e=(l||(l=new WeakMap)).get(t);e||l.set(t,e=String.fromCodePoint(this.nextStackID++));return e+t}}function pushStackDedup(t,e){for(let s=0;s<e.length;s++){let i=e[s];if(i.pos==t.pos&&i.sameState(t)){e[s].score<t.score&&(e[s]=t);return}}e.push(t)}class Dialect{constructor(t,e,s){this.source=t;this.flags=e;this.disabled=s}allows(t){return!this.disabled||this.disabled[t]==0}}const id=t=>t;class ContextTracker{constructor(t){this.start=t.start;this.shift=t.shift||id;this.reduce=t.reduce||id;this.reuse=t.reuse||id;this.hash=t.hash||(()=>0);this.strict=t.strict!==false}}class LRParser extends i{constructor(t){super();this.wrappers=[];if(t.version!=14)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let e=t.nodeNames.split(" ");this.minRepeatTerm=e.length;for(let s=0;s<t.repeatNodeCount;s++)e.push("");let i=Object.keys(t.topRules).map((e=>t.topRules[e][1]));let o=[];for(let t=0;t<e.length;t++)o.push([]);function setProp(t,e,s){o[t].push([e,e.deserialize(String(s))])}if(t.nodeProps)for(let e of t.nodeProps){let t=e[0];typeof t=="string"&&(t=s[t]);for(let s=1;s<e.length;){let i=e[s++];if(i>=0)setProp(i,t,e[s++]);else{let r=e[s+-i];for(let h=-i;h>0;h--)setProp(e[s++],t,r);s++}}}this.nodeSet=new r(e.map(((e,s)=>h.define({name:s>=this.minRepeatTerm?void 0:e,id:s,props:o[s],top:i.indexOf(s)>-1,error:s==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(s)>-1}))));t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources));this.strict=false;this.bufferLength=n;let a=decodeArray(t.tokenData);this.context=t.context;this.specializerSpecs=t.specialized||[];this.specialized=new Uint16Array(this.specializerSpecs.length);for(let t=0;t<this.specializerSpecs.length;t++)this.specialized[t]=this.specializerSpecs[t].term;this.specializers=this.specializerSpecs.map(getSpecializer);this.states=decodeArray(t.states,Uint32Array);this.data=decodeArray(t.stateData);this.goto=decodeArray(t.goto);this.maxTerm=t.maxTerm;this.tokenizers=t.tokenizers.map((t=>typeof t=="number"?new TokenGroup(a,t):t));this.topRules=t.topRules;this.dialects=t.dialects||{};this.dynamicPrecedences=t.dynamicPrecedences||null;this.tokenPrecTable=t.tokenPrec;this.termNames=t.termNames||null;this.maxNode=this.nodeSet.types.length-1;this.dialect=this.parseDialect();this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,e,s){let i=new Parse(this,t,e,s);for(let r of this.wrappers)i=r(i,t,e,s);return i}getGoto(t,e,s=false){let i=this.goto;if(e>=i[0])return-1;for(let r=i[e+1];;){let e=i[r++],h=e&1;let n=i[r++];if(h&&s)return n;for(let s=r+(e>>1);r<s;r++)if(i[r]==t)return n;if(h)return-1}}hasAction(t,e){let s=this.data;for(let i=0;i<2;i++)for(let r,h=this.stateSlot(t,i?2:1);;h+=3){if((r=s[h])==65535){if(s[h+1]!=1){if(s[h+1]==2)return pair(s,h+2);break}r=s[h=pair(s,h+2)]}if(r==e||r==0)return pair(s,h+1)}return 0}stateSlot(t,e){return this.states[t*6+e]}stateFlag(t,e){return(this.stateSlot(t,0)&e)>0}validAction(t,e){return!!this.allActions(t,(t=>t==e||null))}allActions(t,e){let s=this.stateSlot(t,4);let i=s?e(s):void 0;for(let s=this.stateSlot(t,1);i==null;s+=3){if(this.data[s]==65535){if(this.data[s+1]!=1)break;s=pair(this.data,s+2)}i=e(pair(this.data,s+1))}return i}nextStates(t){let e=[];for(let s=this.stateSlot(t,1);;s+=3){if(this.data[s]==65535){if(this.data[s+1]!=1)break;s=pair(this.data,s+2)}if((this.data[s+2]&1)==0){let t=this.data[s+1];e.some(((e,s)=>s&1&&e==t))||e.push(this.data[s],t)}}return e}configure(t){let e=Object.assign(Object.create(LRParser.prototype),this);t.props&&(e.nodeSet=this.nodeSet.extend(...t.props));if(t.top){let s=this.topRules[t.top];if(!s)throw new RangeError(`Invalid top rule name ${t.top}`);e.top=s}t.tokenizers&&(e.tokenizers=this.tokenizers.map((e=>{let s=t.tokenizers.find((t=>t.from==e));return s?s.to:e})));if(t.specializers){e.specializers=this.specializers.slice();e.specializerSpecs=this.specializerSpecs.map(((s,i)=>{let r=t.specializers.find((t=>t.from==s.external));if(!r)return s;let h=Object.assign(Object.assign({},s),{external:r.to});e.specializers[i]=getSpecializer(h);return h}))}t.contextTracker&&(e.context=t.contextTracker);t.dialect&&(e.dialect=this.parseDialect(t.dialect));t.strict!=null&&(e.strict=t.strict);t.wrap&&(e.wrappers=e.wrappers.concat(t.wrap));t.bufferLength!=null&&(e.bufferLength=t.bufferLength);return e}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let e=this.dynamicPrecedences;return e==null?0:e[t]||0}parseDialect(t){let e=Object.keys(this.dialects),s=e.map((()=>false));if(t)for(let i of t.split(" ")){let t=e.indexOf(i);t>=0&&(s[t]=true)}let i=null;for(let t=0;t<e.length;t++)if(!s[t])for(let s,r=this.dialects[e[t]];(s=this.data[r++])!=65535;)(i||(i=new Uint8Array(this.maxTerm+1)))[s]=1;return new Dialect(t,s,i)}static deserialize(t){return new LRParser(t)}}function pair(t,e){return t[e]|t[e+1]<<16}function findFinished(t){let e=null;for(let s of t){let t=s.p.stoppedAt;(s.pos==s.p.stream.end||t!=null&&s.pos>t)&&s.p.parser.stateFlag(s.state,2)&&(!e||e.score<s.score)&&(e=s)}return e}function getSpecializer(t){if(t.external){let e=t.extend?1:0;return(s,i)=>t.external(s,i)<<1|e}return t.get}export{ContextTracker,ExternalTokenizer,InputStream,LRParser,LocalTokenGroup,Stack};+diff --git a/admin/vendor/javascript/@marijn--find-cluster-break.js b/admin/vendor/javascript/@marijn--find-cluster-break.jsnew file mode 100644index 0000000000..8cb0b71652--- /dev/null+++ b/admin/vendor/javascript/@marijn--find-cluster-break.js@@ -0,0 +1,4 @@+// @marijn/[email protected] downloaded from https://ga.jspm.io/npm:@marijn/[email protected]/src/index.js++let e=[],t=[];(()=>{let r="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((e=>e?parseInt(e,36):1));for(let n=0,i=0;n<r.length;n++)(n%2?t:e).push(i+=r[n])})();function isExtendingChar(r){if(r<768)return false;for(let n=0,i=e.length;;){let a=n+i>>1;if(r<e[a])i=a;else{if(!(r>=t[a]))return true;n=a+1}if(n==i)return false}}function isRegionalIndicator(e){return e>=127462&&e<=127487}const r=8205;function findClusterBreak(e,t,r=true,n=true){return(r?nextClusterBreak:prevClusterBreak)(e,t,n)}function nextClusterBreak(e,t,n){if(t==e.length)return t;t&&surrogateLow(e.charCodeAt(t))&&surrogateHigh(e.charCodeAt(t-1))&&t--;let i=codePointAt(e,t);t+=codePointSize(i);while(t<e.length){let a=codePointAt(e,t);if(i==r||a==r||n&&isExtendingChar(a)){t+=codePointSize(a);i=a}else{if(!isRegionalIndicator(a))break;{let r=0,n=t-2;while(n>=0&&isRegionalIndicator(codePointAt(e,n))){r++;n-=2}if(r%2==0)break;t+=2}}}return t}function prevClusterBreak(e,t,r){while(t>0){let n=nextClusterBreak(e,t-2,r);if(n<t)return n;t--}return 0}function codePointAt(e,t){let r=e.charCodeAt(t);if(!surrogateHigh(r)||t+1==e.length)return r;let n=e.charCodeAt(t+1);return surrogateLow(n)?n-56320+(r-55296<<10)+65536:r}function surrogateLow(e){return e>=56320&&e<57344}function surrogateHigh(e){return e>=55296&&e<56320}function codePointSize(e){return e<65536?1:2}export{findClusterBreak,isExtendingChar};+diff --git a/admin/vendor/javascript/codemirror.js b/admin/vendor/javascript/codemirror.jsnew file mode 100644index 0000000000..16783e16c7--- /dev/null+++ b/admin/vendor/javascript/codemirror.js@@ -0,0 +1,4 @@+// [email protected] downloaded from https://ga.jspm.io/npm:[email protected]/dist/index.js++import{lineNumbers as r,highlightActiveLineGutter as o,highlightSpecialChars as m,drawSelection as e,dropCursor as i,rectangularSelection as t,crosshairCursor as c,highlightActiveLine as f,keymap as l}from"@codemirror/view";export{EditorView}from"@codemirror/view";import{EditorState as a}from"@codemirror/state";import{foldGutter as p,indentOnInput as d,syntaxHighlighting as n,bracketMatching as s,defaultHighlightStyle as u,foldKeymap as w}from"@codemirror/language";import{history as b,defaultKeymap as g,historyKeymap as k}from"@codemirror/commands";import{highlightSelectionMatches as v,searchKeymap as x}from"@codemirror/search";import{closeBrackets as h,autocompletion as E,closeBracketsKeymap as M,completionKeymap as S}from"@codemirror/autocomplete";import{lintKeymap as V}from"@codemirror/lint";const j=(()=>[r(),o(),m(),b(),p(),e(),i(),a.allowMultipleSelections.of(true),d(),n(u,{fallback:true}),s(),h(),E(),t(),c(),f(),v(),l.of([...M,...g,...x,...k,...w,...S,...V])])();const q=(()=>[m(),b(),e(),n(u,{fallback:true}),l.of([...g,...k])])();export{j as basicSetup,q as minimalSetup};+diff --git a/admin/vendor/javascript/crelt.js b/admin/vendor/javascript/crelt.jsnew file mode 100644index 0000000000..22807977a6--- /dev/null+++ b/admin/vendor/javascript/crelt.js@@ -0,0 +1,4 @@+// [email protected] downloaded from https://ga.jspm.io/npm:[email protected]/index.js++function crelt(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var r=1,t=arguments[1];if(t&&"object"==typeof t&&null==t.nodeType&&!Array.isArray(t)){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){var o=t[n];"string"==typeof o?e.setAttribute(n,o):null!=o&&(e[n]=o)}r++}for(;r<arguments.length;r++)add(e,arguments[r]);return e}function add(e,r){if("string"==typeof r)e.appendChild(document.createTextNode(r));else if(null==r);else if(null!=r.nodeType)e.appendChild(r);else{if(!Array.isArray(r))throw new RangeError("Unsupported child node: "+r);for(var t=0;t<r.length;t++)add(e,r[t])}}export{crelt as default};+diff --git a/admin/vendor/javascript/style-mod.js b/admin/vendor/javascript/style-mod.jsnew file mode 100644index 0000000000..c965cb5828--- /dev/null+++ b/admin/vendor/javascript/style-mod.js@@ -0,0 +1,4 @@+// [email protected] downloaded from https://ga.jspm.io/npm:[email protected]/src/style-mod.js++const e="ͼ";const t=typeof Symbol=="undefined"?"__"+e:Symbol.for(e);const s=typeof Symbol=="undefined"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet");const l=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{};class StyleModule{constructor(e,t){this.rules=[];let{finish:s}=t||{};function splitSelector(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function render(e,t,l,n){let i=[],o=/^@(\w+)\b/.exec(e[0]),r=o&&o[1]=="keyframes";if(o&&t==null)return l.push(e[0]+";");for(let s in t){let n=t[s];if(/&/.test(s))render(s.split(/,\s*/).map((t=>e.map((e=>t.replace(/&/,e))))).reduce(((e,t)=>e.concat(t))),n,l);else if(n&&typeof n=="object"){if(!o)throw new RangeError("The value of a property ("+s+") should be a primitive value.");render(splitSelector(s),n,i,r)}else n!=null&&i.push(s.replace(/_.*/,"").replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))+": "+n+";")}(i.length||r)&&l.push((!s||o||n?e:e.map(s)).join(", ")+" {"+i.join(" ")+"}")}for(let t in e)render(splitSelector(t),e[t],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let s=l[t]||1;l[t]=s+1;return e+s.toString(36)}static mount(e,t,l){let n=e[s],i=l&&l.nonce;n?i&&n.setNonce(i):n=new StyleSet(e,i);n.mount(Array.isArray(t)?t:[t],e)}}let n=new Map;class StyleSet{constructor(e,t){let l=e.ownerDocument||e,i=l.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let t=n.get(l);if(t)return e[s]=t;this.sheet=new i.CSSStyleSheet;n.set(l,this)}else{this.styleTag=l.createElement("style");t&&this.styleTag.setAttribute("nonce",t)}this.modules=[];e[s]=this}mount(e,t){let s=this.sheet;let l=0,n=0;for(let t=0;t<e.length;t++){let i=e[t],o=this.modules.indexOf(i);if(o<n&&o>-1){this.modules.splice(o,1);n--;o=-1}if(o==-1){this.modules.splice(n++,0,i);if(s)for(let e=0;e<i.rules.length;e++)s.insertRule(i.rules[e],l++)}else{while(n<o)l+=this.modules[n++].rules.length;l+=i.rules.length;n++}}if(s)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e;let s=t.head||t;this.styleTag.parentNode!=s&&s.insertBefore(this.styleTag,s.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}export{StyleModule};+diff --git a/admin/vendor/javascript/w3c-keyname.js b/admin/vendor/javascript/w3c-keyname.jsnew file mode 100644index 0000000000..81a88b2e93--- /dev/null+++ b/admin/vendor/javascript/w3c-keyname.js@@ -0,0 +1,4 @@+// [email protected] downloaded from https://ga.jspm.io/npm:[email protected]/index.js++var e={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"};var r={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'};var t="undefined"!=typeof navigator&&/Mac/.test(navigator.platform);var o="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var n=0;n<10;n++)e[48+n]=e[96+n]=String(n);for(n=1;n<=24;n++)e[n+111]="F"+n;for(n=65;n<=90;n++){e[n]=String.fromCharCode(n+32);r[n]=String.fromCharCode(n)}for(var a in e)r.hasOwnProperty(a)||(r[a]=e[a]);function keyName(n){var a=t&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||o&&n.shiftKey&&n.key&&1==n.key.length||"Unidentified"==n.key;var i=!a&&n.key||(n.shiftKey?r:e)[n.keyCode]||n.key||"Unidentified";"Esc"==i&&(i="Escape");"Del"==i&&(i="Delete");"Left"==i&&(i="ArrowLeft");"Up"==i&&(i="ArrowUp");"Right"==i&&(i="ArrowRight");"Down"==i&&(i="ArrowDown");return i}export{e as base,keyName,r as shift};+diff --git a/api/spec/serializers/spree/api/v2/platform/metafield_serializer_spec.rb b/api/spec/serializers/spree/api/v2/platform/metafield_serializer_spec.rbnew file mode 100644index 0000000000..d6f1668e61--- /dev/null+++ b/api/spec/serializers/spree/api/v2/platform/metafield_serializer_spec.rb@@ -0,0 +1,64 @@+require 'spec_helper'++describe Spree::Api::V2::Platform::MetafieldSerializer do+ let(:product) { create(:product) }++ subject { described_class.new(Spree::Metafield.find(metafield.id)) }++ context 'with ShortText type' do+ let(:metafield_definition) { create(:metafield_definition, namespace: 'custom', key: 'test_field', metafield_type: 'Spree::Metafields::ShortText') }+ let(:metafield) { create(:metafield, metafield_definition: metafield_definition, value: 'Test Value', resource: product) }++ it { expect(subject.serializable_hash).to be_kind_of(Hash) }++ it do+ expect(subject.serializable_hash).to eq(+ {+ data: {+ id: metafield.id.to_s,+ type: :metafield,+ attributes: {+ name: metafield.name,+ type: metafield.type,+ display_on: metafield.display_on,+ key: 'custom.test_field',+ value: 'Test Value'+ }+ }+ }+ )+ end+ end++ context 'with Number type' do+ let(:metafield_definition) { create(:metafield_definition, namespace: 'custom', key: 'test_field', metafield_type: 'Spree::Metafields::Number') }+ let(:metafield) { create(:metafield, metafield_definition: metafield_definition, value: '123.45', resource: product, type: 'Spree::Metafields::Number') }++ it do+ expect(subject.serializable_hash[:data][:attributes][:value]).to be_kind_of(BigDecimal)+ expect(subject.serializable_hash[:data][:attributes][:value]).to eq(BigDecimal('123.45'))+ end+ end++ context 'with Json type' do+ let(:metafield_definition) { create(:metafield_definition, namespace: 'custom', key: 'test_field', metafield_type: 'Spree::Metafields::Json') }+ let(:metafield) { create(:metafield, metafield_definition: metafield_definition, value: '{"key": "value", "number": 42, "nested": {"foo": "bar"}}', resource: product, type: 'Spree::Metafields::Json') }+ subject { described_class.new(Spree::Metafield.find(metafield.id)) }++ it do+ expect(subject.serializable_hash[:data][:attributes][:value]).to be_kind_of(Hash)+ expect(subject.serializable_hash[:data][:attributes][:value]).to eq({ 'key' => 'value', 'number' => 42, 'nested' => { 'foo' => 'bar' } })+ end+ end++ context 'with Json array type' do+ let(:metafield_definition) { create(:metafield_definition, namespace: 'custom', key: 'test_field', metafield_type: 'Spree::Metafields::Json') }+ let(:metafield) { create(:metafield, metafield_definition: metafield_definition, value: '[1, 2, 3, "test"]', resource: product, type: 'Spree::Metafields::Json') }+ subject { described_class.new(Spree::Metafield.find(metafield.id)) }++ it do+ expect(subject.serializable_hash[:data][:attributes][:value]).to be_kind_of(Array)+ expect(subject.serializable_hash[:data][:attributes][:value]).to eq([1, 2, 3, 'test'])+ end+ end+enddiff --git a/core/app/models/spree/metafields/json.rb b/core/app/models/spree/metafields/json.rbnew file mode 100644index 0000000000..c32b8c65a5--- /dev/null+++ b/core/app/models/spree/metafields/json.rb@@ -0,0 +1,23 @@+module Spree+ module Metafields+ class Json < Spree::Metafield+ validate :value_must_be_valid_json++ def serialize_value+ JSON.parse(value)+ rescue JSON::ParserError+ value+ end++ private++ def value_must_be_valid_json+ return if value.blank?++ JSON.parse(value)+ rescue JSON::ParserError => e+ errors.add(:value, "must be valid JSON: #{e.message}")+ end+ end+ end+enddiff --git a/core/lib/spree/core/engine.rb b/core/lib/spree/core/engine.rbindex 6ace43b1e3..effc87e8a0 100644--- a/core/lib/spree/core/engine.rb+++ b/core/lib/spree/core/engine.rb@@ -260,7 +260,8 @@ module SpreeSpree::Metafields::LongText,Spree::Metafields::RichText,Spree::Metafields::Number,- Spree::Metafields::Boolean+ Spree::Metafields::Boolean,+ Spree::Metafields::Json]Rails.application.config.spree.metafield_enabled_resources = [diff --git a/core/lib/spree/testing_support/factories/metafield_definition_factory.rb b/core/lib/spree/testing_support/factories/metafield_definition_factory.rbindex a654cb9cf5..178ce23f60 100644--- a/core/lib/spree/testing_support/factories/metafield_definition_factory.rb+++ b/core/lib/spree/testing_support/factories/metafield_definition_factory.rb@@ -45,6 +45,12 @@ FactoryBot.define doname { 'Featured' }end+ trait :json_field do+ metafield_type { 'Spree::Metafields::Json' }+ key { 'metadata' }+ name { 'Metadata' }+ end+trait :for_variant doresource_type { 'Spree::Variant' }key { 'variant_custom' }diff --git a/core/spec/models/spree/metafields/json_spec.rb b/core/spec/models/spree/metafields/json_spec.rbnew file mode 100644index 0000000000..1368fccad1--- /dev/null+++ b/core/spec/models/spree/metafields/json_spec.rb@@ -0,0 +1,62 @@+require 'spec_helper'++describe Spree::Metafields::Json, type: :model do+ let(:product) { create(:product) }+ let(:metafield_definition) { create(:metafield_definition, metafield_type: 'Spree::Metafields::Json') }+ let(:metafield) { described_class.new(metafield_definition: metafield_definition, value: '{"key": "value"}', resource: product) }++ describe 'Validations' do+ it 'returns false if the value is not valid JSON' do+ metafield.value = 'not valid json'+ expect(metafield.valid?).to be false+ expect(metafield.errors[:value]).to include(/must be valid JSON/)+ end++ it 'returns true for valid JSON object' do+ metafield.value = '{"key": "value", "nested": {"foo": "bar"}}'+ expect(metafield.valid?).to be true+ end++ it 'returns true for valid JSON array' do+ metafield.value = '[1, 2, 3, "test"]'+ expect(metafield.valid?).to be true+ end++ it 'returns true for valid JSON string' do+ metafield.value = '"simple string"'+ expect(metafield.valid?).to be true+ end++ it 'returns true for valid JSON number' do+ metafield.value = '123'+ expect(metafield.valid?).to be true+ end++ it 'returns true for valid JSON boolean' do+ metafield.value = 'true'+ expect(metafield.valid?).to be true+ end++ it 'returns true for valid JSON null' do+ metafield.value = 'null'+ expect(metafield.valid?).to be true+ end+ end++ describe '#serialize_value' do+ it 'returns parsed JSON object' do+ metafield.value = '{"key": "value", "number": 42}'+ expect(metafield.serialize_value).to eq({ 'key' => 'value', 'number' => 42 })+ end++ it 'returns parsed JSON array' do+ metafield.value = '[1, 2, 3]'+ expect(metafield.serialize_value).to eq([1, 2, 3])+ end++ it 'returns original value if parsing fails' do+ allow(JSON).to receive(:parse).and_raise(JSON::ParserError)+ expect(metafield.serialize_value).to eq('{"key": "value"}')+ end+ end+end