/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../state/dist/index.js"),e=require("../../view/dist/index.js"),o=require("../../language/dist/index.js");class i{constructor(t,e,o,i){this.state=t,this.pos=e,this.explicit=o,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=o.syntaxTree(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),o=Math.max(e.from,this.pos-250),i=e.text.slice(o-e.from,this.pos-e.from),n=i.search(a(t,!1));return n<0?null:{from:o+n,to:this.pos,text:i.slice(n)}}get aborted(){return null==this.abortListeners}addEventListener(t,e,o){"abort"==t&&this.abortListeners&&(this.abortListeners.push(e),o&&o.onDocChange&&(this.abortOnDocChange=!0))}}function n(t){let e=Object.keys(t).join(""),o=/\w/.test(e);return o&&(e=e.replace(/\w/g,"")),`[${o?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function s(t){let e=t.map(t=>"string"==typeof t?{label:t}:t),[o,i]=e.every(t=>/^\w+$/.test(t.label))?[/\w*$/,/\w+$/]:function(t){let e=Object.create(null),o=Object.create(null);for(let{label:n}of t){e[n[0]]=!0;for(let t=1;t<n.length;t++)o[n[t]]=!0}let i=n(e)+n(o)+"*$";return[new RegExp("^"+i),new RegExp(i)]}(e);return t=>{let n=t.matchBefore(i);return n||t.explicit?{from:n?n.from:t.pos,options:e,validFor:o}:null}}class r{constructor(t,e,o,i){this.completion=t,this.source=e,this.match=o,this.score=i}}function l(t){return t.selection.main.from}function a(t,e){var o;let{source:i}=t,n=e&&"^"!=i[0],s="$"!=i[i.length-1];return n||s?new RegExp(`${n?"^":""}(?:${i})${s?"$":""}`,null!==(o=t.flags)&&void 0!==o?o:t.ignoreCase?"i":""):t}const c=t.Annotation.define();function h(e,o,i,n){let{main:s}=e.selection,r=i-s.from,l=n-s.from;return{...e.changeByRange(a=>{if(a!=s&&i!=n&&e.sliceDoc(a.from+r,a.from+l)!=e.sliceDoc(i,n))return{range:a};let c=e.toText(o);return{changes:{from:a.from+r,to:n==s.from?a.to:a.from+l,insert:c},range:t.EditorSelection.cursor(a.from+r+c.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const p=new WeakMap;function d(t){if(!Array.isArray(t))return t;let e=p.get(t);return e||p.set(t,e=s(t)),e}const f=t.StateEffect.define(),u=t.StateEffect.define();class m{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let o=0;o<e.length;){let i=t.codePointAt(e,o),n=t.codePointSize(i);this.chars.push(i);let s=e.slice(o,o+n),r=s.toUpperCase();this.folded.push(t.codePointAt(r==s?s.toLowerCase():r,0)),o+=n}this.astral=e.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,this}match(e){if(0==this.pattern.length)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:o,folded:i,any:n,precise:s,byWord:r}=this;if(1==o.length){let n=t.codePointAt(e,0),s=t.codePointSize(n),r=s==e.length?0:-100;if(n==o[0]);else{if(n!=i[0])return null;r+=-200}return this.ret(r,[0,s])}let l=e.indexOf(this.pattern);if(0==l)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=o.length,c=0;if(l<0){for(let s=0,r=Math.min(e.length,200);s<r&&c<a;){let r=t.codePointAt(e,s);r!=o[c]&&r!=i[c]||(n[c++]=s),s+=t.codePointSize(r)}if(c<a)return null}let h=0,p=0,d=!1,f=0,u=-1,m=-1,g=/[a-z]/.test(e),v=!0;for(let b=0,y=Math.min(e.length,200),x=0;b<y&&p<a;){let n=t.codePointAt(e,b);l<0&&(h<a&&n==o[h]&&(s[h++]=b),f<a&&(n==o[f]||n==i[f]?(0==f&&(u=b),m=b+1,f++):f=0));let c,y=n<255?n>=48&&n<=57||n>=97&&n<=122?2:n>=65&&n<=90?1:0:(c=t.fromCodePoint(n))!=c.toLowerCase()?1:c!=c.toUpperCase()?2:0;(!b||1==y&&g||0==x&&0!=y)&&(o[p]==n||i[p]==n&&(d=!0)?r[p++]=b:r.length&&(v=!1)),x=y,b+=t.codePointSize(n)}return p==a&&0==r[0]&&v?this.result((d?-200:0)-100,r,e):f==a&&0==u?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):f==a?this.ret(-900-e.length,[u,m]):p==a?this.result((d?-200:0)-100-700+(v?0:-1100),r,e):2==o.length?null:this.result((n[0]?-700:0)-200-1100,n,e)}result(e,o,i){let n=[],s=0;for(let r of o){let e=r+(this.astral?t.codePointSize(t.codePointAt(i,r)):1);s&&n[s-1]==r?n[s-1]=e:(n[s++]=r,n[s++]=e)}return this.ret(e-i.length,n)}}class g{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let e=t.slice(0,this.pattern.length),o=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return null==o?null:(this.matched=[0,e.length],this.score=o+(t.length==this.pattern.length?0:-100),this)}}const v=t.Facet.define({combine:e=>t.combineConfig(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:y,filterStrict:!1,compareCompletions:(t,e)=>(t.sortText||t.label).localeCompare(e.sortText||e.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>o=>b(t(o),e(o)),optionClass:(t,e)=>o=>b(t(o),e(o)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})});function b(t,e){return t?e?t+" "+e:t:e}function y(t,o,i,n,s,r){let l,a,c=t.textDirection==e.Direction.RTL,h=c,p=!1,d="top",f=o.left-s.left,u=s.right-o.right,m=n.right-n.left,g=n.bottom-n.top;if(h&&f<Math.min(m,u)?h=!1:!h&&u<Math.min(m,f)&&(h=!0),m<=(h?f:u))l=Math.max(s.top,Math.min(i.top,s.bottom-g))-o.top,a=Math.min(400,h?f:u);else{p=!0,a=Math.min(400,(c?o.right:s.right-o.left)-30);let t=s.bottom-o.bottom;t>=g||t>o.top?l=i.bottom-o.top:(d="bottom",l=o.bottom-i.top)}return{style:`${d}: ${l/((o.bottom-o.top)/r.offsetHeight)}px; max-width: ${a/((o.right-o.left)/r.offsetWidth)}px`,class:"cm-completionInfo-"+(p?c?"left-narrow":"right-narrow":h?"left":"right")}}function x(t,e,o){if(t<=o)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let t=Math.floor(e/o);return{from:t*o,to:(t+1)*o}}let i=Math.floor((t-e)/o);return{from:t-(i+1)*o,to:t-i*o}}class w{constructor(t,e,o){this.view=t,this.stateField=e,this.applyCompletion=o,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:t=>this.placeInfo(t),key:this},this.space=null,this.currentClass="";let i=t.state.field(e),{options:n,selected:s}=i.open,r=t.state.facet(v);this.optionContent=function(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(t){let e=document.createElement("div");return e.classList.add("cm-completionIcon"),t.type&&e.classList.add(...t.type.split(/\s+/g).map(t=>"cm-completionIcon-"+t)),e.setAttribute("aria-hidden","true"),e},position:20}),e.push({render(t,e,o,i){let n=document.createElement("span");n.className="cm-completionLabel";let s=t.displayLabel||t.label,r=0;for(let l=0;l<i.length;){let t=i[l++],e=i[l++];t>r&&n.appendChild(document.createTextNode(s.slice(r,t)));let o=n.appendChild(document.createElement("span"));o.appendChild(document.createTextNode(s.slice(t,e))),o.className="cm-completionMatchedText",r=e}return r<s.length&&n.appendChild(document.createTextNode(s.slice(r))),n},position:50},{render(t){if(!t.detail)return null;let e=document.createElement("span");return e.className="cm-completionDetail",e.textContent=t.detail,e},position:80}),e.sort((t,e)=>t.position-e.position).map(t=>t.render)}(r),this.optionClass=r.optionClass,this.tooltipClass=r.tooltipClass,this.range=x(n.length,s,r.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",o=>{let{options:i}=t.state.field(e).open;for(let e,n=o.target;n&&n!=this.dom;n=n.parentNode)if("LI"==n.nodeName&&(e=/-(\d+)$/.exec(n.id))&&+e[1]<i.length)return this.applyCompletion(t,i[+e[1]]),void o.preventDefault()}),this.dom.addEventListener("focusout",e=>{let o=t.state.field(this.stateField,!1);o&&o.tooltip&&t.state.facet(v).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:u.of(null)})}),this.showOptions(n,i.id)}mount(){this.updateSel()}showOptions(t,e){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,e,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(t){var e;let o=t.state.field(this.stateField),i=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),o!=i){let{options:n,selected:s,disabled:r}=o.open;i.open&&i.open.options==n||(this.range=x(n.length,s,t.state.facet(v).maxRenderedOptions),this.showOptions(n,o.id)),this.updateSel(),r!=(null===(e=i.open)||void 0===e?void 0:e.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!r)}}updateTooltipClass(t){let e=this.tooltipClass(t);if(e!=this.currentClass){for(let t of this.currentClass.split(" "))t&&this.dom.classList.remove(t);for(let t of e.split(" "))t&&this.dom.classList.add(t);this.currentClass=e}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),o=t.open;(o.selected>-1&&o.selected<this.range.from||o.selected>=this.range.to)&&(this.range=x(o.options.length,o.selected,this.view.state.facet(v).maxRenderedOptions),this.showOptions(o.options,t.id));let i=this.updateSelectedOption(o.selected);if(i){this.destroyInfo();let{completion:n}=o.options[o.selected],{info:s}=n;if(!s)return;let r="string"==typeof s?document.createTextNode(s):s(n);if(!r)return;"then"in r?r.then(e=>{e&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(e,n)}).catch(t=>e.logException(this.view.state,t,"completion info")):(this.addInfoPane(r,n),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(t,e){this.destroyInfo();let o=this.info=document.createElement("div");if(o.className="cm-tooltip cm-completionInfo",o.id="cm-completionInfo-"+Math.floor(65535*Math.random()).toString(16),null!=t.nodeType)o.appendChild(t),this.infoDestroy=null;else{let{dom:e,destroy:i}=t;o.appendChild(e),this.infoDestroy=i||null}this.dom.appendChild(o),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let e=null;for(let o=this.list.firstChild,i=this.range.from;o;o=o.nextSibling,i++)"LI"==o.nodeName&&o.id?i==t?o.hasAttribute("aria-selected")||(o.setAttribute("aria-selected","true"),e=o):o.hasAttribute("aria-selected")&&(o.removeAttribute("aria-selected"),o.removeAttribute("aria-describedby")):i--;return e&&function(t,e){let o=t.getBoundingClientRect(),i=e.getBoundingClientRect(),n=o.height/t.offsetHeight;i.top<o.top?t.scrollTop-=(o.top-i.top)/n:i.bottom>o.bottom&&(t.scrollTop+=(i.bottom-o.bottom)/n)}(this.list,e),e}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),o=this.info.getBoundingClientRect(),i=t.getBoundingClientRect(),n=this.space;if(!n){let t=this.dom.ownerDocument.documentElement;n={left:0,top:0,right:t.clientWidth,bottom:t.clientHeight}}return i.top>Math.min(n.bottom,e.bottom)-10||i.bottom<Math.max(n.top,e.top)+10?null:this.view.state.facet(v).positionInfo(this.view,e,i,o,n,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,e,o){const i=document.createElement("ul");i.id=e,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",t=>{t.target==i&&t.preventDefault()});let n=null;for(let s=o.from;s<o.to;s++){let{completion:r,match:l}=t[s],{section:a}=r;if(a){let t="string"==typeof a?a:a.name;if(t!=n&&(s>o.from||0==o.from))if(n=t,"string"!=typeof a&&a.header)i.appendChild(a.header(a));else{i.appendChild(document.createElement("completion-section")).textContent=t}}const c=i.appendChild(document.createElement("li"));c.id=e+"-"+s,c.setAttribute("role","option");let h=this.optionClass(r);h&&(c.className=h);for(let t of this.optionContent){let e=t(r,this.view.state,this.view,l);e&&c.appendChild(e)}}return o.from&&i.classList.add("cm-completionListIncompleteTop"),o.to<t.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function C(t,e){return o=>new w(o,t,e)}function S(t){return 100*(t.boost||0)+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}class I{constructor(t,e,o,i,n,s){this.options=t,this.attrs=e,this.tooltip=o,this.timestamp=i,this.selected=n,this.disabled=s}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new I(this.options,T(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,o,i,n,s){if(i&&!s&&t.some(t=>t.isPending))return i.setDisabled();let l=function(t,e){let o=[],i=null,n=null,s=t=>{o.push(t);let{section:e}=t.completion;if(e){i||(i=[]);let t="string"==typeof e?e:e.name;i.some(e=>e.name==t)||i.push("string"==typeof e?{name:t}:e)}},l=e.facet(v);for(let p of t)if(p.hasResult()){let t=p.result.getMatch;if(!1===p.result.filter)for(let e of p.result.options)s(new r(e,p.source,t?t(e):[],1e9-o.length));else{let o,i=e.sliceDoc(p.from,p.to),a=l.filterStrict?new g(i):new m(i);for(let e of p.result.options)if(o=a.match(e.label)){let i=e.displayLabel?t?t(e,o.matched):[]:o.matched,l=o.score+(e.boost||0);if(s(new r(e,p.source,i,l)),"object"==typeof e.section&&"dynamic"===e.section.rank){let{name:t}=e.section;n||(n=Object.create(null)),n[t]=Math.max(l,n[t]||-1e9)}}}}if(i){let t=Object.create(null),e=0,s=(t,e)=>("dynamic"===t.rank&&"dynamic"===e.rank?n[e.name]-n[t.name]:0)||("number"==typeof t.rank?t.rank:1e9)-("number"==typeof e.rank?e.rank:1e9)||(t.name<e.name?-1:1);for(let o of i.sort(s))e-=1e5,t[o.name]=e;for(let i of o){let{section:e}=i.completion;e&&(i.score+=t["string"==typeof e?e:e.name])}}let a=[],c=null,h=l.compareCompletions;for(let r of o.sort((t,e)=>e.score-t.score||h(t.completion,e.completion))){let t=r.completion;!c||c.label!=t.label||c.detail!=t.detail||null!=c.type&&null!=t.type&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?a.push(r):S(r.completion)>S(c)&&(a[a.length-1]=r),c=r.completion}return a}(t,e);if(!l.length)return i&&t.some(t=>t.isPending)?i.setDisabled():null;let a=e.facet(v).selectOnOpen?0:-1;if(i&&i.selected!=a&&-1!=i.selected){let t=i.options[i.selected].completion;for(let e=0;e<l.length;e++)if(l[e].completion==t){a=e;break}}return new I(l,T(o,a),{pos:t.reduce((t,e)=>e.hasResult()?Math.min(t,e.from):t,1e8),create:N,above:n.aboveCursor},i?i.timestamp:Date.now(),a,!1)}map(t){return new I(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new I(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class E{constructor(t,e,o){this.active=t,this.id=e,this.open=o}static start(){return new E(A,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(t){let{state:e}=t,o=e.facet(v),i=(o.override||e.languageDataAt("autocomplete",l(e)).map(d)).map(e=>(this.active.find(t=>t.source==e)||new O(e,this.active.some(t=>0!=t.state)?1:0)).update(t,o));i.length==this.active.length&&i.every((t,e)=>t==this.active[e])&&(i=this.active);let n=this.open,s=t.effects.some(t=>t.is(L));n&&t.docChanged&&(n=n.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!function(t,e){if(t==e)return!0;for(let o=0,i=0;;){for(;o<t.length&&!t[o].hasResult();)o++;for(;i<e.length&&!e[i].hasResult();)i++;let n=o==t.length,s=i==e.length;if(n||s)return n==s;if(t[o++].result!=e[i++].result)return!1}}(i,this.active)||s?n=I.build(i,e,this.id,n,o,s):n&&n.disabled&&!i.some(t=>t.isPending)&&(n=null),!n&&i.every(t=>!t.isPending)&&i.some(t=>t.hasResult())&&(i=i.map(t=>t.hasResult()?new O(t.source,0):t));for(let r of t.effects)r.is(R)&&(n=n&&n.setSelected(r.value,this.id));return i==this.active&&n==this.open?this:new E(i,this.id,n)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?k:P}}const k={"aria-autocomplete":"list"},P={};function T(t,e){let o={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(o["aria-activedescendant"]=t+"-"+e),o}const A=[];function D(t,e){if(t.isUserEvent("input.complete")){let o=t.annotation(c);if(o&&e.activateOnCompletion(o))return 12}let o=t.isUserEvent("input.type");return o&&e.activateOnTyping?5:o?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class O{constructor(t,e,o=!1){this.source=t,this.state=e,this.explicit=o}hasResult(){return!1}get isPending(){return 1==this.state}update(t,e){let o=D(t,e),i=this;(8&o||16&o&&this.touches(t))&&(i=new O(i.source,0)),4&o&&0==i.state&&(i=new O(this.source,1)),i=i.updateFor(t,o);for(let n of t.effects)if(n.is(f))i=new O(i.source,1,n.value);else if(n.is(u))i=new O(i.source,0);else if(n.is(L))for(let t of n.value)t.source==i.source&&(i=t);return i}updateFor(t,e){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(l(t.state))}}class M extends O{constructor(t,e,o,i,n,s){super(t,3,e),this.limit=o,this.result=i,this.from=n,this.to=s}hasResult(){return!0}updateFor(t,e){var o;if(!(3&e))return this.map(t.changes);let n=this.result;n.map&&!t.changes.empty&&(n=n.map(n,t.changes));let s=t.changes.mapPos(this.from),r=t.changes.mapPos(this.to,1),c=l(t.state);if(c>r||!n||2&e&&(l(t.startState)==this.from||c<this.limit))return new O(this.source,4&e?1:0);let h=t.changes.mapPos(this.limit);return function(t,e,o,i){if(!t)return!1;let n=e.sliceDoc(o,i);return"function"==typeof t?t(n,o,i,e):a(t,!0).test(n)}(n.validFor,t.state,s,r)?new M(this.source,this.explicit,h,n,s,r):n.update&&(n=n.update(n,s,r,new i(t.state,c,!1)))?new M(this.source,this.explicit,h,n,n.from,null!==(o=n.to)&&void 0!==o?o:l(t.state)):new O(this.source,1,this.explicit)}map(t){if(t.empty)return this;return(this.result.map?this.result.map(this.result,t):this.result)?new M(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new O(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}const L=t.StateEffect.define({map:(t,e)=>t.map(t=>t.map(e))}),R=t.StateEffect.define(),B=t.StateField.define({create:()=>E.start(),update:(t,e)=>t.update(e),provide:t=>[e.showTooltip.from(t,t=>t.tooltip),e.EditorView.contentAttributes.from(t,t=>t.attrs)]});function F(t,e){const o=e.completion.apply||e.completion.label;let i=t.state.field(B).active.find(t=>t.source==e.source);return i instanceof M&&("string"==typeof o?t.dispatch({...h(t.state,o,i.from,i.to),annotations:c.of(e.completion)}):o(t,e.completion,i.from,i.to),!0)}const N=C(B,F);function $(t,o="option"){return i=>{let n=i.state.field(B,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<i.state.facet(v).interactionDelay)return!1;let s,r=1;"page"==o&&(s=e.getTooltip(i,n.open.tooltip))&&(r=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:l}=n.open.options,a=n.open.selected>-1?n.open.selected+r*(t?1:-1):t?0:l-1;return a<0?a="page"==o?0:l-1:a>=l&&(a="page"==o?l-1:0),i.dispatch({effects:R.of(a)}),!0}}const q=t=>{let e=t.state.field(B,!1);return!(t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(v).interactionDelay)&&F(t,e.open.options[e.open.selected])},U=t=>!!t.state.field(B,!1)&&(t.dispatch({effects:f.of(!0)}),!0),V=t=>{let e=t.state.field(B,!1);return!(!e||!e.active.some(t=>0!=t.state))&&(t.dispatch({effects:u.of(null)}),!0)};class z{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}const W=e.ViewPlugin.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(B).active)e.isPending&&this.startQuery(e)}update(t){let o=t.state.field(B),i=t.state.facet(v);if(!t.selectionSet&&!t.docChanged&&t.startState.field(B)==o)return;let n=t.transactions.some(t=>{let e=D(t,i);return 8&e||(t.selection||t.docChanged)&&!(3&e)});for(let l=0;l<this.running.length;l++){let o=this.running[l];if(n||o.context.abortOnDocChange&&t.docChanged||o.updates.length+t.transactions.length>50&&Date.now()-o.time>1e3){for(let t of o.context.abortListeners)try{t()}catch(r){e.logException(this.view.state,r)}o.context.abortListeners=null,this.running.splice(l--,1)}else o.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(t=>t.effects.some(t=>t.is(f)))&&(this.pendingStart=!0);let s=this.pendingStart?50:i.activateOnTypingDelay;if(this.debounceUpdate=o.active.some(t=>t.isPending&&!this.running.some(e=>e.active.source==t.source))?setTimeout(()=>this.startUpdate(),s):-1,0!=this.composing)for(let e of t.transactions)e.isUserEvent("input.type")?this.composing=2:2==this.composing&&e.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(B);for(let o of e.active)o.isPending&&!this.running.some(t=>t.active.source==o.source)&&this.startQuery(o);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(v).updateSyncTime))}startQuery(t){let{state:o}=this.view,n=l(o),s=new i(o,n,t.explicit,this.view),r=new z(t,s);this.running.push(r),Promise.resolve(t.source(s)).then(t=>{r.context.aborted||(r.done=t||null,this.scheduleAccept())},t=>{this.view.dispatch({effects:u.of(null)}),e.logException(this.view.state,t)})}scheduleAccept(){this.running.every(t=>void 0!==t.done)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(v).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],o=this.view.state.facet(v),i=this.view.state.field(B);for(let n=0;n<this.running.length;n++){let s=this.running[n];if(void 0===s.done)continue;if(this.running.splice(n--,1),s.done){let i=l(s.updates.length?s.updates[0].startState:this.view.state),n=Math.min(i,s.done.from+(s.active.explicit?0:1)),r=new M(s.active.source,s.active.explicit,n,s.done,s.done.from,null!==(t=s.done.to)&&void 0!==t?t:i);for(let t of s.updates)r=r.update(t,o);if(r.hasResult()){e.push(r);continue}}let r=i.active.find(t=>t.source==s.active.source);if(r&&r.isPending)if(null==s.done){let t=new O(s.active.source,0);for(let e of s.updates)t=t.update(e,o);t.isPending||e.push(t)}else this.startQuery(r)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:L.of(e)})}},{eventHandlers:{blur(t){let o=this.view.state.field(B,!1);if(o&&o.tooltip&&this.view.state.facet(v).closeOnBlur){let i=o.open&&e.getTooltip(this.view,o.open.tooltip);i&&i.dom.contains(t.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:u.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout(()=>this.view.dispatch({effects:f.of(!1)}),20),this.composing=0}}}),j="object"==typeof navigator&&/Win/.test(navigator.platform),H=t.Prec.highest(e.EditorView.domEventHandlers({keydown(t,e){let o=e.state.field(B,!1);if(!o||!o.open||o.open.disabled||o.open.selected<0||t.key.length>1||t.ctrlKey&&(!j||!t.altKey)||t.metaKey)return!1;let i=o.open.options[o.open.selected],n=o.active.find(t=>t.source==i.source),s=i.completion.commitCharacters||n.result.commitCharacters;return s&&s.indexOf(t.key)>-1&&F(e,i),!1}})),K=e.EditorView.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 Q{constructor(t,e,o,i){this.field=t,this.line=e,this.from=o,this.to=i}}class X{constructor(t,e,o){this.field=t,this.from=e,this.to=o}map(e){let o=e.mapPos(this.from,-1,t.MapMode.TrackDel),i=e.mapPos(this.to,1,t.MapMode.TrackDel);return null==o||null==i?null:new X(this.field,o,i)}}class Y{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let i=[],n=[e],s=t.doc.lineAt(e),r=/^\s*/.exec(s.text)[0];for(let l of this.lines){if(i.length){let i=r,s=/^\t*/.exec(l)[0].length;for(let e=0;e<s;e++)i+=t.facet(o.indentUnit);n.push(e+i.length-s),l=i+l.slice(s)}i.push(l),e+=l.length+1}return{text:i,ranges:this.fieldPositions.map(t=>new X(t.field,n[t.line]+t.from,n[t.line]+t.to))}}static parse(t){let e,o=[],i=[],n=[];for(let s of t.split(/\r\n?|\n/)){for(;e=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(s);){let t=e[1]?+e[1]:null,r=e[2]||e[3]||"",l=-1,a=r.replace(/\\[{}]/g,t=>t[1]);for(let e=0;e<o.length;e++)(null!=t?o[e].seq==t:a&&o[e].name==a)&&(l=e);if(l<0){let e=0;for(;e<o.length&&(null==t||null!=o[e].seq&&o[e].seq<t);)e++;o.splice(e,0,{seq:t,name:a}),l=e;for(let t of n)t.field>=l&&t.field++}for(let o of n)if(o.line==i.length&&o.from>e.index){let t=e[2]?3+(e[1]||"").length:2;o.from-=t,o.to-=t}n.push(new Q(l,i.length,e.index,e.index+a.length)),s=s.slice(0,e.index)+r+s.slice(e.index+e[0].length)}s=s.replace(/\\([{}])/g,(t,e,o)=>{for(let s of n)s.line==i.length&&s.from>o&&(s.from--,s.to--);return e}),i.push(s)}return new Y(i,n)}}let _=e.Decoration.widget({widget:new class extends e.WidgetType{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),G=e.Decoration.mark({class:"cm-snippetField"});class J{constructor(t,o){this.ranges=t,this.active=o,this.deco=e.Decoration.set(t.map(t=>(t.from==t.to?_:G).range(t.from,t.to)),!0)}map(t){let e=[];for(let o of this.ranges){let i=o.map(t);if(!i)return null;e.push(i)}return new J(e,this.active)}selectionInsideField(t){return t.ranges.every(t=>this.ranges.some(e=>e.field==this.active&&e.from<=t.from&&e.to>=t.to))}}const Z=t.StateEffect.define({map:(t,e)=>t&&t.map(e)}),tt=t.StateEffect.define(),et=t.StateField.define({create:()=>null,update(t,e){for(let o of e.effects){if(o.is(Z))return o.value;if(o.is(tt)&&t)return new J(t.ranges,o.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>e.EditorView.decorations.from(t,t=>t?t.deco:e.Decoration.none)});function ot(e,o){return t.EditorSelection.create(e.filter(t=>t.field==o).map(e=>t.EditorSelection.range(e.from,e.to)))}function it(e){let o=Y.parse(e);return(e,i,n,s)=>{let{text:r,ranges:l}=o.instantiate(e.state,n),{main:a}=e.state.selection,h={changes:{from:n,to:s==a.from?a.to:s,insert:t.Text.of(r)},scrollIntoView:!0,annotations:i?[c.of(i),t.Transaction.userEvent.of("input.complete")]:void 0};if(l.length&&(h.selection=ot(l,0)),l.some(t=>t.field>0)){let o=new J(l,0),i=h.effects=[Z.of(o)];void 0===e.state.field(et,!1)&&i.push(t.StateEffect.appendConfig.of([et,ht,pt,K]))}e.dispatch(e.state.update(h))}}function nt(t){return({state:e,dispatch:o})=>{let i=e.field(et,!1);if(!i||t<0&&0==i.active)return!1;let n=i.active+t,s=t>0&&!i.ranges.some(e=>e.field==n+t);return o(e.update({selection:ot(i.ranges,n),effects:Z.of(s?null:new J(i.ranges,n)),scrollIntoView:!0})),!0}}const st=({state:t,dispatch:e})=>!!t.field(et,!1)&&(e(t.update({effects:Z.of(null)})),!0),rt=nt(1),lt=nt(-1),at=[{key:"Tab",run:rt,shift:lt},{key:"Escape",run:st}],ct=t.Facet.define({combine:t=>t.length?t[0]:at}),ht=t.Prec.highest(e.keymap.compute([ct],t=>t.facet(ct)));const pt=e.EditorView.domEventHandlers({mousedown(t,e){let o,i=e.state.field(et,!1);if(!i||null==(o=e.posAtCoords({x:t.clientX,y:t.clientY})))return!1;let n=i.ranges.find(t=>t.from<=o&&t.to>=o);return!(!n||n.field==i.active)&&(e.dispatch({selection:ot(i.ranges,n.field),effects:Z.of(i.ranges.some(t=>t.field>n.field)?new J(i.ranges,n.field):null),scrollIntoView:!0}),!0)}}),dt={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},ft=t.StateEffect.define({map(e,o){let i=o.mapPos(e,-1,t.MapMode.TrackAfter);return null==i?void 0:i}}),ut=new class extends t.RangeValue{};ut.startSide=1,ut.endSide=-1;const mt=t.StateField.define({create:()=>t.RangeSet.empty,update(t,e){if(t=t.map(e.changes),e.selection){let o=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:t=>t>=o.from&&t<=o.to})}for(let o of e.effects)o.is(ft)&&(t=t.update({add:[ut.range(o.value,o.value+1)]}));return t}});const gt="()[]{}<>«»»«［］｛｝";function vt(e){for(let t=0;t<16;t+=2)if(gt.charCodeAt(t)==e)return gt.charAt(t+1);return t.fromCodePoint(e<128?e:e+1)}function bt(t,e){return t.languageDataAt("closeBrackets",e)[0]||dt}const yt="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),xt=e.EditorView.inputHandler.of((e,o,i,n)=>{if((yt?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let s=e.state.selection.main;if(n.length>2||2==n.length&&1==t.codePointSize(t.codePointAt(n,0))||o!=s.from||i!=s.to)return!1;let r=St(e.state,n);return!!r&&(e.dispatch(r),!0)}),wt=({state:e,dispatch:o})=>{if(e.readOnly)return!1;let i=bt(e,e.selection.main.head).brackets||dt.brackets,n=null,s=e.changeByRange(o=>{if(o.empty){let n=function(e,o){let i=e.sliceString(o-2,o);return t.codePointSize(t.codePointAt(i,0))==i.length?i:i.slice(1)}(e.doc,o.head);for(let s of i)if(s==n&&Et(e.doc,o.head)==vt(t.codePointAt(s,0)))return{changes:{from:o.head-s.length,to:o.head+s.length},range:t.EditorSelection.cursor(o.head-s.length)}}return{range:n=o}});return n||o(e.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!n},Ct=[{key:"Backspace",run:wt}];function St(e,o){let i=bt(e,e.selection.main.head),n=i.brackets||dt.brackets;for(let s of n){let r=vt(t.codePointAt(s,0));if(o==s)return r==s?Tt(e,s,n.indexOf(s+s+s)>-1,i):kt(e,s,r,i.before||dt.before);if(o==r&&It(e,e.selection.main.from))return Pt(e,s,r)}return null}function It(t,e){let o=!1;return t.field(mt).between(0,t.doc.length,t=>{t==e&&(o=!0)}),o}function Et(e,o){let i=e.sliceString(o,o+2);return i.slice(0,t.codePointSize(t.codePointAt(i,0)))}function kt(e,o,i,n){let s=null,r=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:o,from:r.from},{insert:i,from:r.to}],effects:ft.of(r.to+o.length),range:t.EditorSelection.range(r.anchor+o.length,r.head+o.length)};let l=Et(e.doc,r.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:o+i,from:r.head},effects:ft.of(r.head+o.length),range:t.EditorSelection.cursor(r.head+o.length)}:{range:s=r}});return s?null:e.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Pt(e,o,i){let n=null,s=e.changeByRange(o=>o.empty&&Et(e.doc,o.head)==i?{changes:{from:o.head,to:o.head+i.length,insert:i},range:t.EditorSelection.cursor(o.head+i.length)}:n={range:o});return n?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function Tt(e,i,n,s){let r=s.stringPrefixes||dt.stringPrefixes,l=null,a=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:i,from:s.from},{insert:i,from:s.to}],effects:ft.of(s.to+i.length),range:t.EditorSelection.range(s.anchor+i.length,s.head+i.length)};let a,c=s.head,h=Et(e.doc,c);if(h==i){if(At(e,c))return{changes:{insert:i+i,from:c},effects:ft.of(c+i.length),range:t.EditorSelection.cursor(c+i.length)};if(It(e,c)){let o=n&&e.sliceDoc(c,c+3*i.length)==i+i+i?i+i+i:i;return{changes:{from:c,to:c+o.length,insert:o},range:t.EditorSelection.cursor(c+o.length)}}}else{if(n&&e.sliceDoc(c-2*i.length,c)==i+i&&(a=Dt(e,c-2*i.length,r))>-1&&At(e,a))return{changes:{insert:i+i+i+i,from:c},effects:ft.of(c+i.length),range:t.EditorSelection.cursor(c+i.length)};if(e.charCategorizer(c)(h)!=t.CharCategory.Word&&Dt(e,c,r)>-1&&!function(t,e,i,n){let s=o.syntaxTree(t).resolveInner(e,-1),r=n.reduce((t,e)=>Math.max(t,e.length),0);for(let o=0;o<5;o++){let o=t.sliceDoc(s.from,Math.min(s.to,s.from+i.length+r)),l=o.indexOf(i);if(!l||l>-1&&n.indexOf(o.slice(0,l))>-1){let e=s.firstChild;for(;e&&e.from==s.from&&e.to-e.from>i.length+l;){if(t.sliceDoc(e.to-i.length,e.to)==i)return!1;e=e.firstChild}return!0}let a=s.to==e&&s.parent;if(!a)break;s=a}return!1}(e,c,i,r))return{changes:{insert:i+i,from:c},effects:ft.of(c+i.length),range:t.EditorSelection.cursor(c+i.length)}}return{range:l=s}});return l?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function At(t,e){let i=o.syntaxTree(t).resolveInner(e+1);return i.parent&&i.from==e}function Dt(e,o,i){let n=e.charCategorizer(o);if(n(e.sliceDoc(o-1,o))!=t.CharCategory.Word)return o;for(let s of i){let i=o-s.length;if(e.sliceDoc(i,o)==s&&n(e.sliceDoc(i-1,i))!=t.CharCategory.Word)return i}return-1}const Ot=[{key:"Ctrl-Space",run:U},{mac:"Alt-`",run:U},{mac:"Alt-i",run:U},{key:"Escape",run:V},{key:"ArrowDown",run:$(!0)},{key:"ArrowUp",run:$(!1)},{key:"PageDown",run:$(!0,"page")},{key:"PageUp",run:$(!1,"page")},{key:"Enter",run:q}],Mt=t.Prec.highest(e.keymap.computeN([v],t=>t.facet(v).defaultKeymap?[Ot]:[]));exports.CompletionContext=i,exports.acceptCompletion=q,exports.autocompletion=function(t={}){return[H,B,v.of(t),W,Mt,K]},exports.clearSnippet=st,exports.closeBrackets=function(){return[xt,mt]},exports.closeBracketsKeymap=Ct,exports.closeCompletion=V,exports.completeFromList=s,exports.completionKeymap=Ot,exports.deleteBracketPair=wt,exports.ifNotIn=function(t,e){return i=>{for(let e=o.syntaxTree(i.state).resolveInner(i.pos,-1);e;e=e.parent){if(t.indexOf(e.name)>-1)return null;if(e.type.isTop)break}return e(i)}},exports.insertBracket=St,exports.insertCompletionText=h,exports.moveCompletionSelection=$,exports.nextSnippetField=rt,exports.pickedCompletion=c,exports.prevSnippetField=lt,exports.snippet=it,exports.snippetCompletion=function(t,e){return{...e,apply:it(t)}},exports.snippetKeymap=ct,exports.startCompletion=U;