code-playpad 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/JAVA-COMPATIBILITY.md +12 -12
  2. package/README.md +104 -14
  3. package/dist/COMPILER-LICENSE-AUDIT.md +104 -0
  4. package/dist/COMPILER-NOTICES.txt +16973 -0
  5. package/dist/THIRD-PARTY-NOTICES.txt +102 -0
  6. package/dist/cdn.js +2 -2
  7. package/dist/compiler-license-manifest.json +198 -0
  8. package/dist/{config-D9w0xYhX.js → config-cwuPIQ48.js} +1 -1
  9. package/dist/cpp-D2TrExLz.js +1 -0
  10. package/dist/cpp-DakNa4ys.js +6 -0
  11. package/dist/dist--J_vhCIU.js +14 -0
  12. package/dist/{dist-B5vq9x6M.js → dist-BIgiGgKu.js} +1 -1
  13. package/dist/dist-BNvM_BAY.js +6 -0
  14. package/dist/{dist-XlpaG2JF.js → dist-BkpKCrXQ.js} +1 -1
  15. package/dist/{dist-BKRQwpg6.js → dist-CJxiVI4a.js} +1 -1
  16. package/dist/dist-CNOK8CHE.js +6 -0
  17. package/dist/dist-D25hs99E.js +10 -0
  18. package/dist/dist-D2igTc4m.js +6 -0
  19. package/dist/{dist-CqpVTRAq.js → dist-D7jBL3Ib.js} +9 -9
  20. package/dist/dist-DXjodKfp.js +6 -0
  21. package/dist/dist-DfFrsBkU.js +8 -0
  22. package/dist/dist-Vr-fb58P.js +12 -0
  23. package/dist/{element-DaStU7U7.js → element-BQWrbSEp.js} +7 -7
  24. package/dist/element.js +1 -1
  25. package/dist/{hints-v5iHTd1l.js → hints-CCMgezw9.js} +1 -1
  26. package/dist/index.d.ts +1 -1
  27. package/dist/index.js +1 -1
  28. package/dist/java-DeBiVPXO.js +6 -0
  29. package/dist/java-Xf1xYcVv.js +1 -0
  30. package/dist/{java-library-bitset.generated-Duwl7F-b.js → java-library-bitset.generated-C3m-nf8F.js} +1 -1
  31. package/dist/{java-library-math.generated-DmUvund7.js → java-library-math.generated-BQwpn8sQ.js} +1 -1
  32. package/dist/{java-library-regex.generated-a8crcad3.js → java-library-regex.generated-ItYSF2aV.js} +1 -1
  33. package/dist/java-library-time.generated-Dl0XA7nZ.js +6 -0
  34. package/dist/java-library.generated-B7ib0gOX.js +6 -0
  35. package/dist/{javascript-CSfl5gbA.js → javascript-CTY3U1Mc.js} +4 -2
  36. package/dist/{javascript-CX-lsX2u.js → javascript-DkarEcEB.js} +4 -2
  37. package/dist/{pyodide-Crdd9em4.js → pyodide-B1U3JD9Z.js} +2 -2
  38. package/dist/{pyodide-CdDlM0du.js → pyodide-BGBI232i.js} +1 -1
  39. package/dist/react.js +1 -1
  40. package/dist/runtime/compiler-assets.d.ts +5 -0
  41. package/dist/runtime/compiler-cache.d.ts +9 -0
  42. package/dist/runtime/config.d.ts +11 -0
  43. package/dist/runtime/cpp/assets.d.ts +6 -0
  44. package/dist/runtime/cpp/project.d.ts +9 -0
  45. package/dist/runtime/cpp/worker.d.ts +1 -0
  46. package/dist/runtime/cpp-worker.generated.d.ts +1 -0
  47. package/dist/runtime/cpp.d.ts +3 -0
  48. package/dist/runtime/java-library-bitset.generated.d.ts +2 -2
  49. package/dist/runtime/java-library-math.generated.d.ts +2 -2
  50. package/dist/runtime/java-library-regex.generated.d.ts +2 -2
  51. package/dist/runtime/java-library-time.generated.d.ts +3 -3
  52. package/dist/runtime/java-library.generated.d.ts +3 -3
  53. package/dist/runtime/java-worker.generated.d.ts +3 -3
  54. package/dist/runtime/worker-runtime.d.ts +1 -0
  55. package/dist/standalone.js +9 -9
  56. package/dist/types.d.ts +13 -1
  57. package/dist/worker-runtime-DfYet3xy.js +9 -0
  58. package/dist/worker-runtime-Dq71SbjR.js +4 -0
  59. package/package.json +18 -6
  60. package/dist/dist-BThnYaQ5.js +0 -12
  61. package/dist/dist-CnC1nMtN.js +0 -6
  62. package/dist/dist-D0FPZcUi.js +0 -8
  63. package/dist/dist-DOsLUKSb.js +0 -10
  64. package/dist/dist-D_qJovVA.js +0 -14
  65. package/dist/dist-DlIO0dzi.js +0 -6
  66. package/dist/dist-DmrP6yta.js +0 -6
  67. package/dist/java-DIL6bxPF.js +0 -1
  68. package/dist/java-DxQWnfHu.js +0 -6
  69. package/dist/java-library-time.generated-mFyqZ0pg.js +0 -6
  70. package/dist/java-library.generated-1yFV284B.js +0 -6
  71. package/dist/worker-runtime-C8pmmgW9.js +0 -4
  72. package/dist/worker-runtime-CNPpMRo1.js +0 -9
@@ -1,6 +0,0 @@
1
- /*!
2
- * code-playpad — MIT © 2026 Seung Hun Lee
3
- * Bundles CodeMirror 6 and Lezer (MIT) © Marijn Haverbeke and others.
4
- * Full third-party licences: THIRD-PARTY-NOTICES.txt in this package.
5
- */
6
- import{_ as e,a as t,c as n,f as r,g as i,h as a,i as o,l as s,m as c,p as l,s as u,t as d,u as f,v as p,w as m,y as h}from"./dist-DOsLUKSb.js";import{a as g,c as _,d as v,f as y,n as b,o as x,r as S,t as C,u as ee}from"./dist-BThnYaQ5.js";import{indentUnit as te,syntaxTree as w}from"./dist-D0FPZcUi.js";var T=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=w(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(O(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function E(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function ne(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=E(t)+E(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function re(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:ne(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function ie(e,t){return n=>{for(let r=w(n.state).resolveInner(n.pos,-1);r;r=r.parent){if(e.indexOf(r.name)>-1)return t(n);if(r.type.isTop)break}return null}}function ae(e,t){return n=>{for(let t=w(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)}}var oe=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function D(e){return e.selection.main.from}function O(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var k=d.define();function se(e,n,r,i){let{main:a}=e.selection,o=r-a.from,s=i-a.from;return{...e.changeByRange(c=>{if(c!=a&&r!=i&&e.sliceDoc(c.from+o,c.from+s)!=e.sliceDoc(r,i))return{range:c};let l=e.toText(n);return{changes:{from:c.from+o,to:i==a.from?c.to:c.from+s,insert:l},range:t.cursor(c.from+o+l.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var ce=new WeakMap;function le(e){if(!Array.isArray(e))return e;let t=ce.get(e);return t||ce.set(e,t=re(e)),t}var A=l.define(),j=l.define(),ue=class{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<t.length;){let r=e(t,n),i=p(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(e(o==a?a.toLowerCase():o,0)),n+=i}this.astral=t.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(t){if(this.pattern.length==0)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:n,folded:r,any:i,precise:a,byWord:o}=this;if(n.length==1){let i=e(t,0),a=p(i),o=a==t.length?0:-100;if(i!=n[0]){if(i==r[0])o+=-200;else return null}return this.ret(o,[0,a])}let s=t.indexOf(this.pattern);if(s==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let c=n.length,l=0;if(s<0){for(let a=0,o=Math.min(t.length,200);a<o&&l<c;){let o=e(t,a);(o==n[l]||o==r[l])&&(i[l++]=a),a+=p(o)}if(l<c)return null}let u=0,d=0,f=!1,h=0,g=-1,_=-1,v=/[a-z]/.test(t),y=!0;for(let i=0,l=Math.min(t.length,200),b=0;i<l&&d<c;){let l=e(t,i);s<0&&(u<c&&l==n[u]&&(a[u++]=i),h<c&&(l==n[h]||l==r[h]?(h==0&&(g=i),_=i+1,h++):h=0));let x,S=l<255?l>=48&&l<=57||l>=97&&l<=122?2:+(l>=65&&l<=90):(x=m(l))==x.toLowerCase()?x==x.toUpperCase()?0:2:1;(!i||S==1&&v||b==0&&S!=0)&&(n[d]==l||r[d]==l&&(f=!0)?o[d++]=i:o.length&&(y=!1)),b=S,i+=p(l)}return d==c&&o[0]==0&&y?this.result(-100+(f?-200:0),o,t):h==c&&g==0?this.ret(-200-t.length+(_==t.length?0:-100),[0,_]):s>-1?this.ret(-700-t.length,[s,s+this.pattern.length]):h==c?this.ret(-900-t.length,[g,_]):d==c?this.result(-100+(f?-200:0)+-700+(y?0:-1100),o,t):n.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,t)}result(t,n,r){let i=[],a=0;for(let t of n){let n=t+(this.astral?p(e(r,t)):1);a&&i[a-1]==t?i[a-1]=n:(i[a++]=t,i[a++]=n)}return this.ret(t-r.length,i)}},de=class{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),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},M=u.define({combine(e){return h(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:fe,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||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=>N(e(n),t(n)),optionClass:(e,t)=>n=>N(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function N(e,t){return e?t?e+` `+t:e:t}function fe(e,t,n,r,i,a){let o=e.textDirection==b.RTL,s=o,c=!1,l=`top`,u,d,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,h=r.bottom-r.top;if(s&&f<Math.min(m,p)?s=!1:!s&&p<Math.min(m,f)&&(s=!0),m<=(s?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-h))-t.top,d=Math.min(400,s?f:p);else{c=!0,d=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=h||e>t.top?u=n.bottom-t.top:(l=`bottom`,u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,_=(t.right-t.left)/a.offsetWidth;return{style:`${l}: ${u/g}px; max-width: ${d/_}px`,class:`cm-completionInfo-`+(c?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var P=l.define();function pe(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return 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`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>o&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return o<a.length&&i.appendChild(document.createTextNode(a.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement(`span`);return t.className=`cm-completionDetail`,t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}function F(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.ceil((e-t)/n);return{from:e-r*n,to:e-(r-1)*n}}var me=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(M);this.optionContent=pe(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=F(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<r.length){this.applyCompletion(e,r[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains(`cm-completionListIncompleteTop`)&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains(`cm-completionListIncompleteBottom`)&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:P.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(M).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:j.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=F(r.length,i,e.state.facet(M).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}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;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=F(t.options.length,t.selected,this.view.state.facet(M).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>v(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&ge(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(M).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className=`cm-tooltip cm-completionInfo `+(e.class||``)):this.info.style.cssText=`top: -1e6px`)}createListBox(e,t,n){let r=document.createElement(`ul`);r.id=t,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-expanded`,`true`),r.setAttribute(`aria-label`,this.view.state.phrase(`Completions`)),r.addEventListener(`mousedown`,e=>{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;a<n.to;a++){let{completion:o,match:s}=e[a],{section:c}=o;if(c){let e=typeof c==`string`?c:c.name;if(e!=i&&(a>n.from||n.from==0)){if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.to<e.length&&r.classList.add(`cm-completionListIncompleteBottom`),r}destroyInfo(){this.info&&=(this.infoDestroy&&this.infoDestroy(),this.info.remove(),null)}destroy(){this.destroyInfo()}};function he(e,t){return n=>new me(n,e,t)}function ge(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function _e(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function ve(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(M);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new oe(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new de(n):new ue(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new oe(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[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 r.sort(a))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 s=[],c=null,l=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):_e(e.completion)>_e(c)&&(s[s.length-1]=e),c=e.completion}return s}var ye=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,we(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=ve(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(M).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){c=t;break}}return new e(s,we(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:ke,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},be=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(Te,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(M),i=(r.override||n.languageDataAt(`autocomplete`,D(n)).map(le)).map(e=>(this.active.find(t=>t.source==e)||new I(e,+!!this.active.some(e=>e.state!=0))).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(L));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!xe(i,this.active)||o?a=ye.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new I(e.source,0):e));for(let e of t.effects)e.is(P)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Se:Ce}};function xe(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}var Se={"aria-autocomplete":`list`},Ce={};function we(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var Te=[];function Ee(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(k);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}var I=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=Ee(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(A))i=new e(i.source,1,n.value);else if(n.is(j))i=new e(i.source,0);else if(n.is(L))for(let e of n.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(D(e.state))}},De=class e extends I{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=D(t.state);if(o>a||!r||n&2&&(D(t.startState)==this.from||o<this.limit))return new I(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return Oe(r.validFor,t.state,i,a)?new e(this.source,this.explicit,s,r,i,a):r.update&&(r=r.update(r,i,a,new T(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??D(t.state)):new I(this.source,1,this.explicit)}map(t){if(t.empty)return this;let n=this.result.map?this.result.map(this.result,t):this.result;return n?new e(this.source,this.explicit,t.mapPos(this.limit),n,t.mapPos(this.from),t.mapPos(this.to,1)):new I(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function Oe(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):O(e,!0).test(i)}var L=l.define({map(e,t){return e.map(e=>e.map(t))}}),R=c.define({create(){return be.start()},update(e,t){return e.update(t)},provide:e=>[y.from(e,e=>e.tooltip),S.contentAttributes.from(e,e=>e.attrs)]});function z(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(R).active.find(e=>e.source==t.source);return r instanceof De&&(typeof n==`string`?e.dispatch({...se(e.state,n,r.from,r.to),annotations:k.of(t.completion)}):n(e,t.completion,r.from,r.to),!0)}var ke=he(R,z);function B(e,t=`option`){return n=>{let r=n.state.field(R,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(M).interactionDelay)return!1;let i=1,a;t==`page`&&(a=_(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector(`li`).offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t==`page`?0:o-1:s>=o&&(s=t==`page`?o-1:0),n.dispatch({effects:P.of(s)}),!0}}var Ae=e=>{let t=e.state.field(R,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(M).interactionDelay?!1:z(e,t.open.options[t.open.selected])},V=e=>e.state.field(R,!1)?(e.dispatch({effects:A.of(!0)}),!0):!1,H=e=>{let t=e.state.field(R,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:j.of(null)}),!0)},je=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},Me=50,Ne=1e3,Pe=g.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(R).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(R),n=e.state.facet(M);if(!e.selectionSet&&!e.docChanged&&e.startState.field(R)==t)return;let r=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(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>Me&&Date.now()-n.time>Ne){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(A)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,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=!1;let{state:e}=this.view,t=e.field(R);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(M).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new T(t,D(t),e.explicit,this.view),r=new je(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:j.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(M).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(M),n=this.view.state.field(R);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let n=D(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new De(i.active.source,i.active.explicit,r,i.done,i.done.from,i.done.to??n);for(let e of i.updates)a=a.update(e,t);if(a.hasResult()){e.push(a);continue}}let a=n.active.find(e=>e.source==i.active.source);if(a&&a.isPending){if(i.done==null){let n=new I(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:L.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(R,!1);if(t&&t.tooltip&&this.view.state.facet(M).closeOnBlur){let n=t.open&&_(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:j.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:A.of(!1)}),20),this.composing=0}}}),Fe=typeof navigator==`object`&&/Win/.test(navigator.platform),Ie=s.highest(S.domEventHandlers({keydown(e,t){let n=t.state.field(R,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(Fe&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&z(t,r),!1}})),U=S.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`,cursor:`pointer`},".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`}}}),Le=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},Re=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let r=t.mapPos(this.from,-1,n.TrackDel),i=t.mapPos(this.to,1,n.TrackDel);return r==null||i==null?null:new e(this.field,r,i)}},ze=class e{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],r=[t],i=e.doc.lineAt(t),a=/^\s*/.exec(i.text)[0];for(let i of this.lines){if(n.length){let n=a,o=/^\t*/.exec(i)[0].length;for(let t=0;t<o;t++)n+=e.facet(te);r.push(t+n.length-o),i=n+i.slice(o)}n.push(i),t+=i.length+1}return{text:n,ranges:this.fieldPositions.map(e=>new Re(e.field,r[e.line]+e.from,r[e.line]+e.to))}}static parse(t){let n=[],r=[],i=[],a;for(let e of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(e);){let t=a[1]?+a[1]:null,o=a[2]||a[3]||``,s=-1;t===0&&(t=1e9);let c=o.replace(/\\[{}]/g,e=>e[1]);for(let e=0;e<n.length;e++)(t==null?c&&n[e].name==c:n[e].seq==t)&&(s=e);if(s<0){let e=0;for(;e<n.length&&(t==null||n[e].seq!=null&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:c}),s=e;for(let e of i)e.field>=s&&e.field++}for(let e of i)if(e.line==r.length&&e.from>a.index){let t=a[2]?3+(a[1]||``).length:2;e.from-=t,e.to-=t}i.push(new Le(s,r.length,a.index,a.index+c.length)),e=e.slice(0,a.index)+o+e.slice(a.index+a[0].length)}e=e.replace(/\\([{}])/g,(e,t,n)=>{for(let e of i)e.line==r.length&&e.from>n&&(e.from--,e.to--);return t}),r.push(e)}return new e(r,i)}},Be=C.widget({widget:new class extends x{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),Ve=C.mark({class:`cm-snippetField`}),W=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=C.set(e.map(e=>(e.from==e.to?Be:Ve).range(e.from,e.to)),!0)}map(t){let n=[];for(let e of this.ranges){let r=e.map(t);if(!r)return null;n.push(r)}return new e(n,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))}},G=l.define({map(e,t){return e&&e.map(t)}}),He=l.define(),K=c.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(G))return n.value;if(n.is(He)&&e)return new W(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>S.decorations.from(e,e=>e?e.deco:C.none)});function q(e,n){return t.create(e.filter(e=>e.field==n).map(e=>t.range(e.from,e.to)))}function Ue(e){let t=ze.parse(e);return(e,n,r,o)=>{let{text:s,ranges:c}=t.instantiate(e.state,r),{main:u}=e.state.selection,d={changes:{from:r,to:o==u.from?u.to:o,insert:a.of(s)},scrollIntoView:!0,annotations:n?[k.of(n),i.userEvent.of(`input.complete`)]:void 0};if(c.length&&(d.selection=q(c,0)),c.some(e=>e.field>0)){let t=new W(c,0),n=d.effects=[G.of(t)];e.state.field(K,!1)===void 0&&n.push(l.appendConfig.of([K,Ze,$e,U]))}e.dispatch(e.state.update(d))}}function We(e){return({state:t,dispatch:n})=>{let r=t.field(K,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(t=>t.field==i+e);return n(t.update({selection:q(r.ranges,i),effects:G.of(a?null:new W(r.ranges,i)),scrollIntoView:!0})),!0}}var Ge=({state:e,dispatch:t})=>e.field(K,!1)?(t(e.update({effects:G.of(null)})),!0):!1,Ke=We(1),qe=We(-1);function Je(e){let t=e.field(K,!1);return!!(t&&t.ranges.some(e=>e.field==t.active+1))}function Ye(e){let t=e.field(K,!1);return!!(t&&t.active>0)}var Xe=[{key:`Tab`,run:Ke,shift:qe},{key:`Escape`,run:Ge}],J=u.define({combine(e){return e.length?e[0]:Xe}}),Ze=s.highest(ee.compute([J],e=>e.facet(J)));function Qe(e,t){return{...t,apply:Ue(e)}}var $e=S.domEventHandlers({mousedown(e,t){let n=t.state.field(K,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(e=>e.from<=r&&e.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:q(n.ranges,i.field),effects:G.of(n.ranges.some(e=>e.field>i.field)?new W(n.ranges,i.field):null),scrollIntoView:!0}),!0)}});function et(e){let t=e.replace(/[\]\-\\]/g,`\\$&`);try{return RegExp(`[\\p{Alphabetic}\\p{Number}_${t}]+`,`ug`)}catch{return RegExp(`[\w${t}]`,`g`)}}function tt(e,t){return new RegExp(t(e.source),e.unicode?`u`:``)}var nt=Object.create(null);function rt(e){return nt[e]||(nt[e]=new WeakMap)}function it(e,t,n,r,i){for(let a=e.iterLines(),o=0;!a.next().done;){let{value:e}=a,s;for(t.lastIndex=0;s=t.exec(e);)if(!r[s[0]]&&o+s.index!=i&&(n.push({type:`text`,label:s[0]}),r[s[0]]=!0,n.length>=2e3))return;o+=e.length+1}}function at(e,t,n,r,i){let a=e.length>=1e3,o=a&&t.get(e);if(o)return o;let s=[],c=Object.create(null);if(e.children){let a=0;for(let o of e.children){if(o.length>=1e3)for(let e of at(o,t,n,r-a,i-a))c[e.label]||(c[e.label]=!0,s.push(e));else it(o,n,s,c,i-a);a+=o.length+1}}else it(e,n,s,c,i);return a&&s.length<2e3&&t.set(e,s),s}var ot=e=>{let t=e.state.languageDataAt(`wordChars`,e.pos)[0]??``,n=et(t),r=e.matchBefore(tt(n,e=>e+`$`));if(!r&&!e.explicit)return null;let i=r?r.from:e.pos;return{from:i,options:at(e.state.doc,rt(t),n,5e4,i),validFor:tt(n,e=>`^`+e)}},Y={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},X=l.define({map(e,t){return t.mapPos(e,-1,n.TrackAfter)??void 0}}),Z=new class extends r{};Z.startSide=1,Z.endSide=-1;var st=c.define({create(){return f.empty},update(e,t){if(e=e.map(t.changes),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(X)&&(e=e.update({add:[Z.range(n.value,n.value+1)]}));return e}});function ct(){return[pt,st]}var lt=`()[]{}<>«»»«[]{}`;function ut(e){for(let t=0;t<16;t+=2)if(lt.charCodeAt(t)==e)return lt.charAt(t+1);return m(e<128?e:e+1)}function dt(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||Y}var ft=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),pt=S.inputHandler.of((t,n,r,i)=>{if((ft?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let a=t.state.selection.main;if(i.length>2||i.length==2&&p(e(i,0))==1||n!=a.from||r!=a.to)return!1;let o=ht(t.state,i);return o?(t.dispatch(o),!0):!1}),Q=({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=dt(n,n.selection.main.head).brackets||Y.brackets,a=null,o=n.changeByRange(r=>{if(r.empty){let a=_t(n.doc,r.head);for(let o of i)if(o==a&&$(n.doc,r.head)==ut(e(o,0)))return{changes:{from:r.head-o.length,to:r.head+o.length},range:t.cursor(r.head-o.length)}}return{range:a=r}});return a||r(n.update(o,{scrollIntoView:!0,userEvent:`delete.backward`})),!a},mt=[{key:`Backspace`,run:Q}];function ht(t,n){let r=dt(t,t.selection.main.head),i=r.brackets||Y.brackets;for(let a of i){let o=ut(e(a,0));if(n==a)return o==a?bt(t,a,i.indexOf(a+a+a)>-1,r):vt(t,a,o,r.before||Y.before);if(n==o&&gt(t,t.selection.main.from))return yt(t,a,o)}return null}function gt(e,t){let n=!1;return e.field(st).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function $(t,n){let r=t.sliceString(n,n+2);return r.slice(0,p(e(r,0)))}function _t(t,n){let r=t.sliceString(n-2,n);return p(e(r,0))==r.length?r:r.slice(1)}function vt(e,n,r,i){let a=null,o=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:n,from:o.from},{insert:r,from:o.to}],effects:X.of(o.to+n.length),range:t.range(o.anchor+n.length,o.head+n.length)};let s=$(e.doc,o.head);return!s||/\s/.test(s)||i.indexOf(s)>-1?{changes:{insert:n+r,from:o.head},effects:X.of(o.head+n.length),range:t.cursor(o.head+n.length)}:{range:a=o}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function yt(e,n,r){let i=null,a=e.changeByRange(n=>n.empty&&$(e.doc,n.head)==r?{changes:{from:n.head,to:n.head+r.length,insert:r},range:t.cursor(n.head+r.length)}:i={range:n});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function bt(e,n,r,i){let a=i.stringPrefixes||Y.stringPrefixes,s=null,c=e.changeByRange(i=>{if(!i.empty)return{changes:[{insert:n,from:i.from},{insert:n,from:i.to}],effects:X.of(i.to+n.length),range:t.range(i.anchor+n.length,i.head+n.length)};let c=i.head,l=$(e.doc,c),u;if(l==n){if(xt(e,c))return{changes:{insert:n+n,from:c},effects:X.of(c+n.length),range:t.cursor(c+n.length)};if(gt(e,c)){let i=r&&e.sliceDoc(c,c+n.length*3)==n+n+n?n+n+n:n;return{changes:{from:c,to:c+i.length,insert:i},range:t.cursor(c+i.length)}}}else if(r&&e.sliceDoc(c-2*n.length,c)==n+n&&(u=Ct(e,c-2*n.length,a))>-1&&xt(e,u))return{changes:{insert:n+n+n+n,from:c},effects:X.of(c+n.length),range:t.cursor(c+n.length)};else if(e.charCategorizer(c)(l)!=o.Word&&Ct(e,c,a)>-1&&!St(e,c,n,a))return{changes:{insert:n+n,from:c},effects:X.of(c+n.length),range:t.cursor(c+n.length)};return{range:s=i}});return s?null:e.update(c,{scrollIntoView:!0,userEvent:`input.type`})}function xt(e,t){let n=w(e).resolveInner(t+1);return n.parent&&n.from==t}function St(e,t,n,r){let i=w(e).resolveInner(t,-1),a=r.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),s=o.indexOf(n);if(!s||s>-1&&r.indexOf(o.slice(0,s))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+s;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function Ct(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=o.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=o.Word)return n}return-1}function wt(e={}){return[Ie,R,M.of(e),Pe,Et,U]}var Tt=[{key:`Ctrl-Space`,run:V},{mac:"Alt-`",run:V},{mac:`Alt-i`,run:V},{key:`Escape`,run:H},{key:`ArrowDown`,run:B(!0)},{key:`ArrowUp`,run:B(!1)},{key:`PageDown`,run:B(!0,`page`)},{key:`PageUp`,run:B(!1,`page`)},{key:`Enter`,run:Ae}],Et=s.highest(ee.computeN([M],e=>e.facet(M).defaultKeymap?[Tt]:[]));function Dt(e){let t=e.field(R,!1);return t&&t.active.some(e=>e.isPending)?`pending`:t&&t.active.some(e=>e.state!=0)?`active`:null}var Ot=new WeakMap;function kt(e){let t=e.field(R,!1)?.open;if(!t||t.disabled)return[];let n=Ot.get(t.options);return n||Ot.set(t.options,n=t.options.map(e=>e.completion)),n}function At(e){let t=e.field(R,!1)?.open;return t&&!t.disabled&&t.selected>=0?t.options[t.selected].completion:null}function jt(e){let t=e.field(R,!1)?.open;return t&&!t.disabled&&t.selected>=0?t.selected:null}function Mt(e){return P.of(e)}export{T as CompletionContext,Ae as acceptCompletion,wt as autocompletion,Ge as clearSnippet,ct as closeBrackets,mt as closeBracketsKeymap,H as closeCompletion,ot as completeAnyWord,re as completeFromList,Tt as completionKeymap,Dt as completionStatus,kt as currentCompletions,Q as deleteBracketPair,Je as hasNextSnippetField,Ye as hasPrevSnippetField,ie as ifIn,ae as ifNotIn,ht as insertBracket,se as insertCompletionText,B as moveCompletionSelection,Ke as nextSnippetField,k as pickedCompletion,qe as prevSnippetField,At as selectedCompletion,jt as selectedCompletionIndex,Mt as setSelectedCompletion,Ue as snippet,Qe as snippetCompletion,J as snippetKeymap,V as startCompletion};