@nocobase/plugin-field-code 2.1.0-alpha.7 → 2.1.0-alpha.9

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.
@@ -1,10 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- "use strict";(self.webpackChunk_nocobase_plugin_field_code=self.webpackChunk_nocobase_plugin_field_code||[]).push([["685"],{858:function(t,e,r){r.d(e,{Dv:function(){return U},Gn:function(){return B},K0:function(){return P},KC:function(){return h},Qf:function(){return th},R_:function(){return tk},SS:function(){return D},Um:function(){return tD},c:function(){return O},e7:function(){return tt},kU:function(){return c},mi:function(){return tu},n$:function(){return tC},nF:function(){return tm},nY:function(){return _},qp:function(){return p},qz:function(){return m},ri:function(){return C},tC:function(){return W},uj:function(){return N},vw:function(){return E},x0:function(){return F},y1:function(){return T},ze:function(){return R}});var n,o=r(419),i=r(263),s=r(990),l=r(930),a=r(502);let u=new o.md;function c(t){return i.r$.define({combine:t?e=>e.concat(t):void 0})}let h=new o.md;class f{constructor(t,e,r=[],n=""){this.data=t,this.name=n,i.yy.prototype.hasOwnProperty("tree")||Object.defineProperty(i.yy.prototype,"tree",{get(){return m(this)}}),this.parser=e,this.extension=[A.of(this),i.yy.languageData.of((t,e,r)=>{let n=d(t,e,r),o=n.type.prop(u);if(!o)return[];let i=t.facet(o),s=n.type.prop(h);if(s){let o=n.resolve(e-n.from,r);for(let e of s)if(e.test(o,t)){let r=t.facet(e.facet);return"replace"==e.type?r:r.concat(i)}}return i})].concat(r)}isActiveAt(t,e,r=-1){return d(t,e,r).type.prop(u)==this.data}findRegions(t){let e=t.facet(A);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let r=[],n=(t,e)=>{if(t.prop(u)==this.data)return void r.push({from:e,to:e+t.length});let i=t.prop(o.md.mounted);if(i){if(i.tree.prop(u)==this.data){if(i.overlay)for(let t of i.overlay)r.push({from:t.from+e,to:t.to+e});else r.push({from:e,to:e+t.length});return}else if(i.overlay){let t=r.length;if(n(i.tree,i.overlay[0].from+e),r.length>t)return}}for(let r=0;r<t.children.length;r++){let i=t.children[r];i instanceof o.mp&&n(i,t.positions[r]+e)}};return n(m(t),0),r}get allowsNesting(){return!0}}function d(t,e,r){let n=t.facet(A),i=m(t).topNode;if(!n||n.allowsNesting)for(let t=i;t;t=t.enter(e,r,o.vj.ExcludeBuffers))t.type.isTop&&(i=t);return i}f.setState=i.Py.define();class p extends f{constructor(t,e,r){super(t,e,[],r),this.parser=e}static define(t){let e=c(t.languageData);return new p(e,t.parser.configure({props:[u.add(t=>t.isTop?e:void 0)]}),t.name)}configure(t,e){return new p(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function m(t){let e=t.field(f.state,!1);return e?e.tree:o.mp.empty}class g{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let r=this.cursorPos-this.string.length;return t<r||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-r,e-r)}}let k=null;class v{constructor(t,e,r=[],n,o,i,s,l){this.parser=t,this.state=e,this.fragments=r,this.tree=n,this.treeLen=o,this.viewport=i,this.skipped=s,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,e,r){return new v(t,e,[],o.mp.empty,0,r,[],null)}startParse(){return this.parser.startParse(new g(this.state.doc),this.fragments)}work(t,e){return(null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=o.mp.empty&&this.isDone(null!=e?e:this.state.doc.length))?(this.takeTree(),!0):this.withContext(()=>{var r;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(o.i9.addTree(n,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!=(r=this.parse.stoppedAt)?r:this.state.doc.length,this.tree=n,this.parse=null,!(this.treeLen<(null!=e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(o.i9.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=k;k=this;try{return t()}finally{k=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=w(t,e.from,e.to);return t}changes(t,e){let{fragments:r,tree:n,treeLen:i,viewport:s,skipped:l}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,r,n,o)=>e.push({fromA:t,toA:r,fromB:n,toB:o})),r=o.i9.applyChanges(r,e),n=o.mp.empty,i=0,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length)for(let e of(l=[],this.skipped)){let r=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);r<n&&l.push({from:r,to:n})}}return new v(this.parser,e,r,n,i,s,l,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let e=0;e<this.skipped.length;e++){let{from:r,to:n}=this.skipped[e];r<t.to&&n>t.from&&(this.fragments=w(this.fragments,r,n),this.skipped.splice(e--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends o._b{createParse(e,r,n){let i=n[0].from,s=n[n.length-1].to;return{parsedPos:i,advance(){let e=k;if(e){for(let t of n)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=s,new o.mp(o.Jq.none,[],[],s-i)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return k}}function w(t,e,r){return o.i9.applyChanges(t,[{fromA:e,toA:r,fromB:e,toB:r}])}class y{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),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,r)||e.takeTree(),new y(e)}static init(t){let e=Math.min(3e3,t.doc.length),r=v.create(t.facet(A).parser,t,{from:0,to:e});return r.work(20,e)||r.takeTree(),new y(r)}}f.state=i.QQ.define({create:y.init,update(t,e){for(let t of e.effects)if(t.is(f.setState))return t.value;return e.startState.facet(A)!=e.state.facet(A)?y.init(e.state):t.apply(e)}});let b=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(b=t=>{let e=-1,r=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(r):cancelIdleCallback(e)});let x="undefined"!=typeof navigator&&(null==(n=navigator.scheduling)?void 0:n.isInputPending)?()=>navigator.scheduling.isInputPending():null,S=s.lg.fromClass(class{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(f.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(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(f.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=b(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),this.chunkBudget<=0)return;let{state:r,viewport:{to:n}}=this.view,o=r.field(f.state);if(o.tree==o.context.tree&&o.context.isDone(n+1e5))return;let i=Date.now()+Math.min(this.chunkBudget,100,t&&!x?Math.max(25,t.timeRemaining()-5):1e9),s=o.context.treeLen<n&&r.doc.length>n+1e3,l=o.context.work(()=>x&&x()||Date.now()>i,n+1e5*!s);this.chunkBudget-=Date.now()-e,(l||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:f.setState.of(new y(o.context))})),this.chunkBudget>0&&!(l&&!s)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(t=>(0,s.OO)(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()}}}),A=i.r$.define({combine:t=>t.length?t[0]:null,enables:t=>[f.state,S,s.tk.contentAttributes.compute([t],e=>{let r=e.facet(t);return r&&r.name?{"data-language":r.name}:{}})]});class C{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}let J=i.r$.define(),O=i.r$.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 Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function T(t){let e=t.facet(O);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function D(t,e){let r="",n=t.tabSize,o=t.facet(O)[0];if(" "==o){for(;e>=n;)r+=" ",e-=n;o=" "}for(let t=0;t<e;t++)r+=o;return r}function P(t,e){for(let r of(t instanceof i.yy&&(t=new B(t)),t.state.facet(J))){let n=r(t,e);if(void 0!==n)return n}let r=m(t.state);return r.length>=e?function(t,e,r){let n=e.resolveStack(r),o=e.resolveInner(r,-1).resolve(r,0).enterUnfinishedNodesBefore(r);if(o!=n.node){let t=[];for(let e=o;e&&!(e.from<n.node.from||e.to>n.node.to||e.from==n.node.from&&e.type==n.node.type);e=e.parent)t.push(e);for(let e=t.length-1;e>=0;e--)n={node:t[e],next:n}}return I(n,t,r)}(t,r,e):null}class B{constructor(t,e={}){this.state=t,this.options=e,this.unit=T(t)}lineAt(t,e=1){let r=this.state.doc.lineAt(t),{simulateBreak:n,simulateDoubleBreak:o}=this.options;if(null!=n&&n>=r.from&&n<=r.to)if(o&&n==t)return{text:"",from:t};else if(e<0?n<t:n<=t)return{text:r.text.slice(n-r.from),from:n};else return{text:r.text.slice(0,n-r.from),from:r.from};return r}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:r,from:n}=this.lineAt(t,e);return r.slice(t-n,Math.min(r.length,t+100-n))}column(t,e=1){let{text:r,from:n}=this.lineAt(t,e),o=this.countColumn(r,t-n),i=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return i>-1&&(o+=i-this.countColumn(r,r.search(/\S|$/))),o}countColumn(t,e=t.length){return(0,i.IS)(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:r,from:n}=this.lineAt(t,e),o=this.options.overrideIndentation;if(o){let t=o(n);if(t>-1)return t}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}let N=new o.md;function I(t,e,r){for(let n=t;n;n=n.next){let t=function(t){let e=t.type.prop(N);if(e)return e;let r=t.firstChild,n;if(r&&(n=r.type.prop(o.md.closedBy))){let e=t.lastChild,r=e&&n.indexOf(e.name)>-1;return t=>L(t,!0,1,void 0,r&&!(t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak)?e.from:void 0)}return null==t.parent?M:null}(n.node);if(t)return t($.create(e,r,n))}return 0}function M(){return 0}class $ extends B{constructor(t,e,r){super(t.state,t.options),this.base=t,this.pos=e,this.context=r}get node(){return this.context.node}static create(t,e,r){return new $(t,e,r)}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 r=t.resolve(e.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(function(t,e){for(let r=e;r;r=r.parent)if(t==r)return!0;return!1}(r,t))break;e=this.state.doc.lineAt(r.from)}return this.lineIndent(e.from)}continue(){return I(this.context.next,this.base,this.pos)}}function E({closing:t,align:e=!0,units:r=1}){return n=>L(n,e,r,t)}function L(t,e,r,n,o){let i=t.textAfter,s=i.match(/^\s*/)[0].length,l=n&&i.slice(s,s+n.length)==n||o==t.pos+s,a=e?function(t){let e=t.node,r=e.childAfter(e.from),n=e.lastChild;if(!r)return null;let o=t.options.simulateBreak,i=t.state.doc.lineAt(r.from),s=null==o||o<=i.from?i.to:Math.min(i.to,o);for(let t=r.to;;){let o=e.childAfter(t);if(!o||o==n)return null;if(!o.type.isSkipped){if(o.from>=s)return null;let t=/^ */.exec(i.text.slice(r.to-i.from))[0].length;return{from:r.from,to:r.to+t}}t=o.to}}(t):null;return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*r)}let R=t=>t.baseIndent;function W({except:t,units:e=1}={}){return r=>{let n=t&&t.test(r.textAfter);return r.baseIndent+(n?0:e*r.unit)}}function _(){return i.yy.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 r=t.newDoc,{head:n}=t.newSelection.main,o=r.lineAt(n);if(n>o.from+200)return t;let i=r.sliceString(o.from,n);if(!e.some(t=>t.test(i)))return t;let{state:s}=t,l=-1,a=[];for(let{head:t}of s.selection.ranges){let e=s.doc.lineAt(t);if(e.from==l)continue;l=e.from;let r=P(s,e.from);if(null==r)continue;let n=/^\s*/.exec(e.text)[0],o=D(s,r);n!=o&&a.push({from:e.from,to:e.from+n.length,insert:o})}return a.length?[t,{changes:a,sequential:!0}]:t})}let q=i.r$.define(),F=new o.md;function U(t){let e=t.firstChild,r=t.lastChild;return e&&e.to<r.from?{from:e.to,to:r.type.isError?t.to:r.from}:null}function j(t,e,r){for(let n of t.facet(q)){let o=n(t,e,r);if(o)return o}return function(t,e,r){let n=m(t);if(n.length<r)return null;let o=n.resolveStack(r,1),i=null;for(let s=o;s;s=s.next){let o=s.node;if(o.to<=r||o.from>r)continue;if(i&&o.from<e)break;let l=o.type.prop(F);if(l&&(o.to<n.length-50||n.length==t.doc.length||!function(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}(o))){let n=l(o,t);n&&n.from<=r&&n.from>=e&&n.to>r&&(i=n)}}return i}(t,e,r)}function Q(t,e){let r=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);return r>=n?void 0:{from:r,to:n}}let z=i.Py.define({map:Q}),V=i.Py.define({map:Q});function G(t){let e=[];for(let{head:r}of t.state.selection.ranges)e.some(t=>t.from<=r&&t.to>=r)||e.push(t.lineBlockAt(r));return e}let H=i.QQ.define({create:()=>s.p.none,update(t,e){for(let r of(e.isUserEvent("delete")&&e.changes.iterChangedRanges((e,r)=>t=K(t,e,r)),t=t.map(e.changes),e.effects))if(r.is(z)&&!function(t,e,r){let n=!1;return t.between(e,e,(t,o)=>{t==e&&o==r&&(n=!0)}),n}(t,r.value.from,r.value.to)){let{preparePlaceholder:n}=e.state.facet(tr),o=n?s.p.replace({widget:new ts(n(e.state,r.value))}):ti;t=t.update({add:[o.range(r.value.from,r.value.to)]})}else r.is(V)&&(t=t.update({filter:(t,e)=>r.value.from!=t||r.value.to!=e,filterFrom:r.value.from,filterTo:r.value.to}));return e.selection&&(t=K(t,e.selection.main.head)),t},provide:t=>s.tk.decorations.from(t),toJSON(t,e){let r=[];return t.between(0,e.doc.length,(t,e)=>{r.push(t,e)}),r},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw RangeError("Invalid JSON for fold state");let e=[];for(let r=0;r<t.length;){let n=t[r++],o=t[r++];if("number"!=typeof n||"number"!=typeof o)throw RangeError("Invalid JSON for fold state");e.push(ti.range(n,o))}return s.p.set(e,!0)}});function K(t,e,r=e){let n=!1;return t.between(e,r,(t,o)=>{t<r&&o>e&&(n=!0)}),n?t.update({filterFrom:e,filterTo:r,filter:(t,n)=>t>=r||n<=e}):t}function X(t,e,r){var n;let o=null;return null==(n=t.field(H,!1))||n.between(e,r,(t,e)=>{(!o||o.from>t)&&(o={from:t,to:e})}),o}function Y(t,e){return t.field(H,!1)?e:e.concat(i.Py.appendConfig.of(tn()))}function Z(t,e,r=!0){let n=t.state.doc.lineAt(e.from).number,o=t.state.doc.lineAt(e.to).number;return s.tk.announce.of(`${t.state.phrase(r?"Folded lines":"Unfolded lines")} ${n} ${t.state.phrase("to")} ${o}.`)}let tt=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:t=>{for(let e of G(t)){let r=j(t.state,e.from,e.to);if(r)return t.dispatch({effects:Y(t.state,[z.of(r),Z(t,r)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:t=>{if(!t.state.field(H,!1))return!1;let e=[];for(let r of G(t)){let n=X(t.state,r.from,r.to);n&&e.push(V.of(n),Z(t,n,!1))}return e.length&&t.dispatch({effects:e}),e.length>0}},{key:"Ctrl-Alt-[",run:t=>{let{state:e}=t,r=[];for(let n=0;n<e.doc.length;){let o=t.lineBlockAt(n),i=j(e,o.from,o.to);i&&r.push(z.of(i)),n=(i?t.lineBlockAt(i.to):o).to+1}return r.length&&t.dispatch({effects:Y(t.state,r)}),!!r.length}},{key:"Ctrl-Alt-]",run:t=>{let e=t.state.field(H,!1);if(!e||!e.size)return!1;let r=[];return e.between(0,t.state.doc.length,(t,e)=>{r.push(V.of({from:t,to:e}))}),t.dispatch({effects:r}),!0}}],te={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},tr=i.r$.define({combine:t=>(0,i.BO)(t,te)});function tn(t){let e=[H,tc];return t&&e.push(tr.of(t)),e}function to(t,e){let{state:r}=t,n=r.facet(tr),o=e=>{let r=t.lineBlockAt(t.posAtDOM(e.target)),n=X(t.state,r.from,r.to);n&&t.dispatch({effects:V.of(n)}),e.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(t,o,e);let i=document.createElement("span");return i.textContent=n.placeholderText,i.setAttribute("aria-label",r.phrase("folded code")),i.title=r.phrase("unfold"),i.className="cm-foldPlaceholder",i.onclick=o,i}let ti=s.p.replace({widget:new class extends s.l9{toDOM(t){return to(t,null)}}});class ts extends s.l9{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return to(t,this.value)}}let tl={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class ta extends s.SJ{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");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}function tu(t={}){let e={...tl,...t},r=new ta(e,!0),n=new ta(e,!1),o=s.lg.fromClass(class{constructor(t){this.from=t.viewport.from,this.markers=this.buildMarkers(t)}update(t){(t.docChanged||t.viewportChanged||t.startState.facet(A)!=t.state.facet(A)||t.startState.field(H,!1)!=t.state.field(H,!1)||m(t.startState)!=m(t.state)||e.foldingChanged(t))&&(this.markers=this.buildMarkers(t.view))}buildMarkers(t){let e=new i.f_;for(let o of t.viewportLineBlocks){let i=X(t.state,o.from,o.to)?n:j(t.state,o.from,o.to)?r:null;i&&e.add(o.from,o.from,i)}return e.finish()}}),{domEventHandlers:l}=e;return[o,(0,s.v5)({class:"cm-foldGutter",markers(t){var e;return(null==(e=t.plugin(o))?void 0:e.markers)||i.Xs.empty},initialSpacer:()=>new ta(e,!1),domEventHandlers:{...l,click:(t,e,r)=>{if(l.click&&l.click(t,e,r))return!0;let n=X(t.state,e.from,e.to);if(n)return t.dispatch({effects:V.of(n)}),!0;let o=j(t.state,e.from,e.to);return!!o&&(t.dispatch({effects:z.of(o)}),!0)}}}),tn()]}let tc=s.tk.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 th{constructor(t,e){let r;function n(t){let e=a.V.newName();return(r||(r=Object.create(null)))["."+e]=t,e}this.specs=t;let o="string"==typeof e.all?e.all:e.all?n(e.all):void 0,i=e.scope;this.scope=i instanceof f?t=>t.prop(u)==i.data:i?t=>t==i:void 0,this.style=(0,l.QR)(t.map(t=>({tag:t.tag,class:t.class||n(Object.assign({},t,{tag:null}))})),{all:o}).style,this.module=r?new a.V(r):null,this.themeType=e.themeType}static define(t,e){return new th(t,e||{})}}let tf=i.r$.define(),td=i.r$.define({combine:t=>t.length?[t[0]]:null});function tp(t){let e=t.facet(tf);return e.length?e:t.facet(td)}function tm(t,e){let r=[tg],n;return t instanceof th&&(t.module&&r.push(s.tk.styleModule.of(t.module)),n=t.themeType),(null==e?void 0:e.fallback)?r.push(td.of(t)):n?r.push(tf.computeN([s.tk.darkTheme],e=>e.facet(s.tk.darkTheme)==("dark"==n)?[t]:[])):r.push(tf.of(t)),r}let tg=i.Wl.high(s.lg.fromClass(class{constructor(t){this.markCache=Object.create(null),this.tree=m(t.state),this.decorations=this.buildDeco(t,tp(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=m(t.state),r=tp(t.state),n=r!=tp(t.startState),{viewport:o}=t.view,i=t.changes.mapPos(this.decoratedTo,1);e.length<o.to&&!n&&e.type==this.tree.type&&i>=o.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=i):(e!=this.tree||t.viewportChanged||n)&&(this.tree=e,this.decorations=this.buildDeco(t.view,r),this.decoratedTo=o.to)}buildDeco(t,e){if(!e||!this.tree.length)return s.p.none;let r=new i.f_;for(let{from:n,to:o}of t.visibleRanges)(0,l.bW)(this.tree,e,(t,e,n)=>{r.add(t,e,this.markCache[n]||(this.markCache[n]=s.p.mark({class:n})))},n,o);return r.finish()}},{decorations:t=>t.decorations})),tk=th.define([{tag:l.pJ.meta,color:"#404740"},{tag:l.pJ.link,textDecoration:"underline"},{tag:l.pJ.heading,textDecoration:"underline",fontWeight:"bold"},{tag:l.pJ.emphasis,fontStyle:"italic"},{tag:l.pJ.strong,fontWeight:"bold"},{tag:l.pJ.strikethrough,textDecoration:"line-through"},{tag:l.pJ.keyword,color:"#708"},{tag:[l.pJ.atom,l.pJ.bool,l.pJ.url,l.pJ.contentSeparator,l.pJ.labelName],color:"#219"},{tag:[l.pJ.literal,l.pJ.inserted],color:"#164"},{tag:[l.pJ.string,l.pJ.deleted],color:"#a11"},{tag:[l.pJ.regexp,l.pJ.escape,l.pJ.special(l.pJ.string)],color:"#e40"},{tag:l.pJ.definition(l.pJ.variableName),color:"#00f"},{tag:l.pJ.local(l.pJ.variableName),color:"#30a"},{tag:[l.pJ.typeName,l.pJ.namespace],color:"#085"},{tag:l.pJ.className,color:"#167"},{tag:[l.pJ.special(l.pJ.variableName),l.pJ.macroName],color:"#256"},{tag:l.pJ.definition(l.pJ.propertyName),color:"#00c"},{tag:l.pJ.comment,color:"#940"},{tag:l.pJ.invalid,color:"#f00"}]),tv=s.tk.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),tw="()[]{}",ty=i.r$.define({combine:t=>(0,i.BO)(t,{afterCursor:!0,brackets:tw,maxScanDistance:1e4,renderMatch:tS})}),tb=s.p.mark({class:"cm-matchingBracket"}),tx=s.p.mark({class:"cm-nonmatchingBracket"});function tS(t){let e=[],r=t.matched?tb:tx;return e.push(r.range(t.start.from,t.start.to)),t.end&&e.push(r.range(t.end.from,t.end.to)),e}let tA=[i.QQ.define({create:()=>s.p.none,update(t,e){if(!e.docChanged&&!e.selection)return t;let r=[],n=e.state.facet(ty);for(let t of e.state.selection.ranges){if(!t.empty)continue;let o=tD(e.state,t.head,-1,n)||t.head>0&&tD(e.state,t.head-1,1,n)||n.afterCursor&&(tD(e.state,t.head,1,n)||t.head<e.state.doc.length&&tD(e.state,t.head+1,-1,n));o&&(r=r.concat(n.renderMatch(o,e.state)))}return s.p.set(r,!0)},provide:t=>s.tk.decorations.from(t)}),tv];function tC(t={}){return[ty.of(t),tA]}let tJ=new o.md;function tO(t,e,r){let n=t.prop(e<0?o.md.openedBy:o.md.closedBy);if(n)return n;if(1==t.name.length){let n=r.indexOf(t.name);if(n>-1&&n%2==+(e<0))return[r[n+e]]}return null}function tT(t){let e=t.type.prop(tJ);return e?e(t.node):t}function tD(t,e,r,n={}){let o=n.maxScanDistance||1e4,i=n.brackets||tw,s=m(t),l=s.resolveInner(e,r);for(let t=l;t;t=t.parent){let n=tO(t.type,r,i);if(n&&t.from<t.to){let o=tT(t);if(o&&(r>0?e>=o.from&&e<o.to:e>o.from&&e<=o.to))return function(t,e,r,n,o,i,s){let l=n.parent,a={from:o.from,to:o.to},u=0,c=null==l?void 0:l.cursor();if(c&&(r<0?c.childBefore(n.from):c.childAfter(n.to)))do if(r<0?c.to<=n.from:c.from>=n.to){if(0==u&&i.indexOf(c.type.name)>-1&&c.from<c.to){let t=tT(c);return{start:a,end:t?{from:t.from,to:t.to}:void 0,matched:!0}}else if(tO(c.type,r,s))u++;else if(tO(c.type,-r,s)){if(0==u){let t=tT(c);return{start:a,end:t&&t.from<t.to?{from:t.from,to:t.to}:void 0,matched:!1}}u--}}while(r<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}(0,0,r,t,o,n,i)}}return function(t,e,r,n,o,i,s){let l=r<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),a=s.indexOf(l);if(a<0||a%2==0!=r>0)return null;let u={from:r<0?e-1:e,to:r>0?e+1:e},c=t.doc.iterRange(e,r>0?t.doc.length:0),h=0;for(let t=0;!c.next().done&&t<=i;){let i=c.value;r<0&&(t+=i.length);let l=e+t*r;for(let t=r>0?0:i.length-1,e=r>0?i.length:-1;t!=e;t+=r){let e=s.indexOf(i[t]);if(!(e<0)&&n.resolveInner(l+t,1).type==o)if(e%2==0==r>0)h++;else{if(1==h)return{start:u,end:{from:l+t,to:l+t+1},matched:e>>1==a>>1};h--}}r>0&&(t+=i.length)}return c.done?{start:u,matched:!1}:null}(t,e,r,s,l.type,o,i)}let tP=Object.create(null),tB=[o.Jq.none],tN=[],tI=Object.create(null),tM=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"]])tM[t]=function(t,e){let r=[];for(let n of e.split(" ")){let e=[];for(let r of n.split(".")){let n=t[r]||l.pJ[r];n?"function"==typeof n?e.length?e=e.map(n):t$(r,`Modifier ${r} used at start of tag`):e.length?t$(r,`Tag ${r} used as modifier`):e=Array.isArray(n)?n:[n]:t$(r,`Unknown highlighting tag ${r}`)}for(let t of e)r.push(t)}if(!r.length)return 0;let n=e.replace(/ /g,"_"),i=n+" "+r.map(t=>t.id),s=tI[i];if(s)return s.id;let a=tI[i]=o.Jq.define({id:tB.length,name:n,props:[(0,l.Gv)({[n]:r})]});return tB.push(a),a.id}(tP,e);function t$(t,e){tN.indexOf(t)>-1||(tN.push(t),console.warn(e))}s.Nm.RTL,s.Nm.LTR}}]);
@@ -1,10 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- "use strict";(self.webpackChunk_nocobase_plugin_field_code=self.webpackChunk_nocobase_plugin_field_code||[]).push([["856"],{490:function(t,e,n){n.d(e,{B1:function(){return tk},GA:function(){return ty},Gn:function(){return tr},Mb:function(){return a},eC:function(){return c},vQ:function(){return tu},ys:function(){return tO}});var i=n(263),o=n(990),s=n(858);class l{constructor(t,e,n,i){this.state=t,this.pos=e,this.explicit=n,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=(0,s.qz)(this.state).resolveInner(this.pos,-1);for(;e&&0>t.indexOf(e.name);)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),n=Math.max(e.from,this.pos-250),i=e.text.slice(n-e.from,this.pos-e.from),o=i.search(f(t,!1));return o<0?null:{from:n+o,to:this.pos,text:i.slice(o)}}get aborted(){return null==this.abortListeners}addEventListener(t,e,n){"abort"==t&&this.abortListeners&&(this.abortListeners.push(e),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function r(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function a(t){let e=t.map(t=>"string"==typeof t?{label:t}:t),[n,i]=e.every(t=>/^\w+$/.test(t.label))?[/\w*$/,/\w+$/]:function(t){let e=Object.create(null),n=Object.create(null);for(let{label:i}of t){e[i[0]]=!0;for(let t=1;t<i.length;t++)n[i[t]]=!0}let i=r(e)+r(n)+"*$";return[RegExp("^"+i),new RegExp(i)]}(e);return t=>{let o=t.matchBefore(i);return o||t.explicit?{from:o?o.from:t.pos,options:e,validFor:n}:null}}function c(t,e){return n=>{for(let e=(0,s.qz)(n.state).resolveInner(n.pos,-1);e;e=e.parent){if(t.indexOf(e.name)>-1)return null;if(e.type.isTop)break}return e(n)}}class h{constructor(t,e,n,i){this.completion=t,this.source=e,this.match=n,this.score=i}}function p(t){return t.selection.main.from}function f(t,e){var n;let{source:i}=t,o=e&&"^"!=i[0],s="$"!=i[i.length-1];return o||s?RegExp(`${o?"^":""}(?:${i})${s?"$":""}`,null!=(n=t.flags)?n:t.ignoreCase?"i":""):t}let u=i.q6.define(),d=new WeakMap;function m(t){if(!Array.isArray(t))return t;let e=d.get(t);return e||d.set(t,e=a(t)),e}let g=i.Py.define(),b=i.Py.define();class v{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let e=0;e<t.length;){let n=(0,i.gm)(t,e),o=(0,i.nZ)(n);this.chars.push(n);let s=t.slice(e,e+o),l=s.toUpperCase();this.folded.push((0,i.gm)(l==s?s.toLowerCase():l,0)),e+=o}this.astral=t.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,this}match(t){if(0==this.pattern.length)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:e,folded:n,any:o,precise:s,byWord:l}=this;if(1==e.length){let o=(0,i.gm)(t,0),s=(0,i.nZ)(o),l=s==t.length?0:-100;if(o==e[0]);else{if(o!=n[0])return null;l+=-200}return this.ret(l,[0,s])}let r=t.indexOf(this.pattern);if(0==r)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=e.length,c=0;if(r<0){for(let s=0,l=Math.min(t.length,200);s<l&&c<a;){let l=(0,i.gm)(t,s);(l==e[c]||l==n[c])&&(o[c++]=s),s+=(0,i.nZ)(l)}if(c<a)return null}let h=0,p=0,f=!1,u=0,d=-1,m=-1,g=/[a-z]/.test(t),b=!0;for(let o=0,c=Math.min(t.length,200),v=0;o<c&&p<a;){let c=(0,i.gm)(t,o);r<0&&(h<a&&c==e[h]&&(s[h++]=o),u<a&&(c==e[u]||c==n[u]?(0==u&&(d=o),m=o+1,u++):u=0));let y,w=c<255?c>=48&&c<=57||c>=97&&c<=122?2:+(c>=65&&c<=90):(y=(0,i.bg)(c))!=y.toLowerCase()?1:2*(y!=y.toUpperCase());(!o||1==w&&g||0==v&&0!=w)&&(e[p]==c||n[p]==c&&(f=!0)?l[p++]=o:l.length&&(b=!1)),v=w,o+=(0,i.nZ)(c)}return p==a&&0==l[0]&&b?this.result(-100+(f?-200:0),l,t):u==a&&0==d?this.ret(-200-t.length+(m==t.length?0:-100),[0,m]):r>-1?this.ret(-700-t.length,[r,r+this.pattern.length]):u==a?this.ret(-900-t.length,[d,m]):p==a?this.result(-100+(f?-200:0)+-700+(b?0:-1100),l,t):2==e.length?null:this.result((o[0]?-700:0)+-200+-1100,o,t)}result(t,e,n){let o=[],s=0;for(let t of e){let e=t+(this.astral?(0,i.nZ)((0,i.gm)(n,t)):1);s&&o[s-1]==t?o[s-1]=e:(o[s++]=t,o[s++]=e)}return this.ret(t-n.length,o)}}class y{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),n=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return null==n?null:(this.matched=[0,e.length],this.score=n+(t.length==this.pattern.length?0:-100),this)}}let w=i.r$.define({combine:t=>(0,i.BO)(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:C,filterStrict:!1,compareCompletions:(t,e)=>t.label.localeCompare(e.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>n=>x(t(n),e(n)),optionClass:(t,e)=>n=>x(t(n),e(n)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})});function x(t,e){return t?e?t+" "+e:t:e}function C(t,e,n,i,s,l){let r=t.textDirection==o.Nm.RTL,a=r,c=!1,h="top",p,f,u=e.left-s.left,d=s.right-e.right,m=i.right-i.left,g=i.bottom-i.top;if(a&&u<Math.min(m,d)?a=!1:!a&&d<Math.min(m,u)&&(a=!0),m<=(a?u:d))p=Math.max(s.top,Math.min(n.top,s.bottom-g))-e.top,f=Math.min(400,a?u:d);else{c=!0,f=Math.min(400,(r?e.right:s.right-e.left)-30);let t=s.bottom-e.bottom;t>=g||t>e.top?p=n.bottom-e.top:(h="bottom",p=e.bottom-n.top)}let b=(e.bottom-e.top)/l.offsetHeight,v=(e.right-e.left)/l.offsetWidth;return{style:`${h}: ${p/b}px; max-width: ${f/v}px`,class:"cm-completionInfo-"+(c?r?"left-narrow":"right-narrow":a?"left":"right")}}function I(t,e,n){if(t<=n)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let t=Math.floor(e/n);return{from:t*n,to:(t+1)*n}}let i=Math.floor((t-e)/n);return{from:t-(i+1)*n,to:t-i*n}}class O{constructor(t,e,n){let i;this.view=t,this.stateField=e,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:t=>this.placeInfo(t),key:this},this.space=null,this.currentClass="";let o=t.state.field(e),{options:s,selected:l}=o.open,r=t.state.facet(w);this.optionContent=(i=r.addToOptions.slice(),r.icons&&i.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}),i.push({render(t,e,n,i){let o=document.createElement("span");o.className="cm-completionLabel";let s=t.displayLabel||t.label,l=0;for(let t=0;t<i.length;){let e=i[t++],n=i[t++];e>l&&o.appendChild(document.createTextNode(s.slice(l,e)));let r=o.appendChild(document.createElement("span"));r.appendChild(document.createTextNode(s.slice(e,n))),r.className="cm-completionMatchedText",l=n}return l<s.length&&o.appendChild(document.createTextNode(s.slice(l))),o},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}),i.sort((t,e)=>t.position-e.position).map(t=>t.render)),this.optionClass=r.optionClass,this.tooltipClass=r.tooltipClass,this.range=I(s.length,l,r.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",n=>{let{options:i}=t.state.field(e).open;for(let e=n.target,o;e&&e!=this.dom;e=e.parentNode)if("LI"==e.nodeName&&(o=/-(\d+)$/.exec(e.id))&&+o[1]<i.length){this.applyCompletion(t,i[+o[1]]),n.preventDefault();return}}),this.dom.addEventListener("focusout",e=>{let n=t.state.field(this.stateField,!1);n&&n.tooltip&&t.state.facet(w).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:b.of(null)})}),this.showOptions(s,o.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 n=t.state.field(this.stateField),i=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),n!=i){let{options:o,selected:s,disabled:l}=n.open;i.open&&i.open.options==o||(this.range=I(o.length,s,t.state.facet(w).maxRenderedOptions),this.showOptions(o,n.id)),this.updateSel(),l!=(null==(e=i.open)?void 0:e.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}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),e=t.open;if((e.selected>-1&&e.selected<this.range.from||e.selected>=this.range.to)&&(this.range=I(e.options.length,e.selected,this.view.state.facet(w).maxRenderedOptions),this.showOptions(e.options,t.id)),this.updateSelectedOption(e.selected)){this.destroyInfo();let{completion:n}=e.options[e.selected],{info:i}=n;if(!i)return;let s="string"==typeof i?document.createTextNode(i):i(n);if(!s)return;"then"in s?s.then(e=>{e&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(e,n)}).catch(t=>(0,o.OO)(this.view.state,t,"completion info")):this.addInfoPane(s,n)}}addInfoPane(t,e){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",null!=t.nodeType)n.appendChild(t),this.infoDestroy=null;else{let{dom:e,destroy:i}=t;n.appendChild(e),this.infoDestroy=i||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){var e,n;let i,o,s,l=null;for(let e=this.list.firstChild,n=this.range.from;e;e=e.nextSibling,n++)"LI"==e.nodeName&&e.id?n==t?e.hasAttribute("aria-selected")||(e.setAttribute("aria-selected","true"),l=e):e.hasAttribute("aria-selected")&&e.removeAttribute("aria-selected"):n--;return l&&(e=this.list,n=l,i=e.getBoundingClientRect(),o=n.getBoundingClientRect(),s=i.height/e.offsetHeight,o.top<i.top?e.scrollTop-=(i.top-o.top)/s:o.bottom>i.bottom&&(e.scrollTop+=(o.bottom-i.bottom)/s)),l}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),i=t.getBoundingClientRect(),o=this.space;if(!o){let t=this.dom.ownerDocument.documentElement;o={left:0,top:0,right:t.clientWidth,bottom:t.clientHeight}}return i.top>Math.min(o.bottom,e.bottom)-10||i.bottom<Math.max(o.top,e.top)+10?null:this.view.state.facet(w).positionInfo(this.view,e,i,n,o,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,n){let 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 o=null;for(let s=n.from;s<n.to;s++){let{completion:l,match:r}=t[s],{section:a}=l;if(a){let t="string"==typeof a?a:a.name;t!=o&&(s>n.from||0==n.from)&&(o=t,"string"!=typeof a&&a.header?i.appendChild(a.header(a)):i.appendChild(document.createElement("completion-section")).textContent=t)}let c=i.appendChild(document.createElement("li"));c.id=e+"-"+s,c.setAttribute("role","option");let h=this.optionClass(l);for(let t of(h&&(c.className=h),this.optionContent)){let e=t(l,this.view.state,this.view,r);e&&c.appendChild(e)}}return n.from&&i.classList.add("cm-completionListIncompleteTop"),n.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 k(t){return 100*(t.boost||0)+10*!!t.apply+5*!!t.info+ +!!t.type}class T{constructor(t,e,n,i,o,s){this.options=t,this.attrs=e,this.tooltip=n,this.timestamp=i,this.selected=o,this.disabled=s}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new T(this.options,S(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,n,i,o,s){if(i&&!s&&t.some(t=>t.isPending))return i.setDisabled();let l=function(t,e){let n=[],i=null,o=t=>{n.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)}},s=e.facet(w);for(let i of t)if(i.hasResult()){let t=i.result.getMatch;if(!1===i.result.filter)for(let e of i.result.options)o(new h(e,i.source,t?t(e):[],1e9-n.length));else{let n=e.sliceDoc(i.from,i.to),l,r=s.filterStrict?new y(n):new v(n);for(let e of i.result.options)if(l=r.match(e.label)){let n=e.displayLabel?t?t(e,l.matched):[]:l.matched;o(new h(e,i.source,n,l.score+(e.boost||0)))}}}if(i){let t=Object.create(null),e=0;for(let n of i.sort((t,e)=>{var n,i;return(null!=(n=t.rank)?n:1e9)-(null!=(i=e.rank)?i:1e9)||(t.name<e.name?-1:1)}))e-=1e5,t[n.name]=e;for(let e of n){let{section:n}=e.completion;n&&(e.score+=t["string"==typeof n?n:n.name])}}let l=[],r=null,a=s.compareCompletions;for(let t of n.sort((t,e)=>e.score-t.score||a(t.completion,e.completion))){let e=t.completion;r&&r.label==e.label&&r.detail==e.detail&&(null==r.type||null==e.type||r.type==e.type)&&r.apply==e.apply&&r.boost==e.boost?k(t.completion)>k(r)&&(l[l.length-1]=t):l.push(t),r=t.completion}return l}(t,e);if(!l.length)return i&&t.some(t=>t.isPending)?i.setDisabled():null;let r=e.facet(w).selectOnOpen?0:-1;if(i&&i.selected!=r&&-1!=i.selected){let t=i.options[i.selected].completion;for(let e=0;e<l.length;e++)if(l[e].completion==t){r=e;break}}return new T(l,S(n,r),{pos:t.reduce((t,e)=>e.hasResult()?Math.min(t,e.from):t,1e8),create:q,above:o.aboveCursor},i?i.timestamp:Date.now(),r,!1)}map(t){return new T(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new T(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class D{constructor(t,e,n){this.active=t,this.id=e,this.open=n}static start(){return new D(L,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(t){let{state:e}=t,n=e.facet(w),i=(n.override||e.languageDataAt("autocomplete",p(e)).map(m)).map(e=>(this.active.find(t=>t.source==e)||new E(e,+!!this.active.some(t=>0!=t.state))).update(t,n));i.length==this.active.length&&i.every((t,e)=>t==this.active[e])&&(i=this.active);let o=this.open,s=t.effects.some(t=>t.is(B));for(let l of(o&&t.docChanged&&(o=o.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 n=0,i=0;;){for(;n<t.length&&!t[n].hasResult();)n++;for(;i<e.length&&!e[i].hasResult();)i++;let o=n==t.length,s=i==e.length;if(o||s)return o==s;if(t[n++].result!=e[i++].result)return!1}}(i,this.active)||s?o=T.build(i,e,this.id,o,n,s):o&&o.disabled&&!i.some(t=>t.isPending)&&(o=null),!o&&i.every(t=>!t.isPending)&&i.some(t=>t.hasResult())&&(i=i.map(t=>t.hasResult()?new E(t.source,0):t)),t.effects))l.is(j)&&(o=o&&o.setSelected(l.value,this.id));return i==this.active&&o==this.open?this:new D(i,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?P:A}}let P={"aria-autocomplete":"list"},A={};function S(t,e){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(n["aria-activedescendant"]=t+"-"+e),n}let L=[];function R(t,e){if(t.isUserEvent("input.complete")){let n=t.annotation(u);if(n&&e.activateOnCompletion(n))return 12}let n=t.isUserEvent("input.type");return n&&e.activateOnTyping?5:n?1:t.isUserEvent("delete.backward")?2:t.selection?8:16*!!t.docChanged}class E{constructor(t,e,n=!1){this.source=t,this.state=e,this.explicit=n}hasResult(){return!1}get isPending(){return 1==this.state}update(t,e){let n=R(t,e),i=this;for(let e of((8&n||16&n&&this.touches(t))&&(i=new E(i.source,0)),4&n&&0==i.state&&(i=new E(this.source,1)),i=i.updateFor(t,n),t.effects))if(e.is(g))i=new E(i.source,1,e.value);else if(e.is(b))i=new E(i.source,0);else if(e.is(B))for(let t of e.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(p(t.state))}}class M extends E{constructor(t,e,n,i,o,s){super(t,3,e),this.limit=n,this.result=i,this.from=o,this.to=s}hasResult(){return!0}updateFor(t,e){var n;if(!(3&e))return this.map(t.changes);let i=this.result;i.map&&!t.changes.empty&&(i=i.map(i,t.changes));let o=t.changes.mapPos(this.from),s=t.changes.mapPos(this.to,1),r=p(t.state);if(r>s||!i||2&e&&(p(t.startState)==this.from||r<this.limit))return new E(this.source,4&e?1:0);let a=t.changes.mapPos(this.limit);return!function(t,e,n,i){if(!t)return!1;let o=e.sliceDoc(n,i);return"function"==typeof t?t(o,n,i,e):f(t,!0).test(o)}(i.validFor,t.state,o,s)?i.update&&(i=i.update(i,o,s,new l(t.state,r,!1)))?new M(this.source,this.explicit,a,i,i.from,null!=(n=i.to)?n:p(t.state)):new E(this.source,1,this.explicit):new M(this.source,this.explicit,a,i,o,s)}map(t){return t.empty?this:(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 E(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}let B=i.Py.define({map:(t,e)=>t.map(t=>t.map(e))}),j=i.Py.define(),$=i.QQ.define({create:()=>D.start(),update:(t,e)=>t.update(e),provide:t=>[o.hJ.from(t,t=>t.tooltip),o.tk.contentAttributes.from(t,t=>t.attrs)]});function F(t,e){let n=e.completion.apply||e.completion.label,o=t.state.field($).active.find(t=>t.source==e.source);return o instanceof M&&("string"==typeof n?t.dispatch(Object.assign(Object.assign({},function(t,e,n,o){let{main:s}=t.selection,l=n-s.from,r=o-s.from;return Object.assign(Object.assign({},t.changeByRange(a=>{if(a!=s&&n!=o&&t.sliceDoc(a.from+l,a.from+r)!=t.sliceDoc(n,o))return{range:a};let c=t.toText(e);return{changes:{from:a.from+l,to:o==s.from?a.to:a.from+r,insert:c},range:i.jT.cursor(a.from+l+c.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}(t.state,n,o.from,o.to)),{annotations:u.of(e.completion)})):n(t,e.completion,o.from,o.to),!0)}let q=t=>new O(t,$,F);function N(t,e="option"){return n=>{let i=n.state.field($,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<n.state.facet(w).interactionDelay)return!1;let s=1,l;"page"==e&&(l=(0,o.gB)(n,i.open.tooltip))&&(s=Math.max(2,Math.floor(l.dom.offsetHeight/l.dom.querySelector("li").offsetHeight)-1));let{length:r}=i.open.options,a=i.open.selected>-1?i.open.selected+s*(t?1:-1):t?0:r-1;return a<0?a="page"==e?0:r-1:a>=r&&(a="page"==e?r-1:0),n.dispatch({effects:j.of(a)}),!0}}let U=t=>!!t.state.field($,!1)&&(t.dispatch({effects:g.of(!0)}),!0);class W{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}let z=o.lg.fromClass(class{constructor(t){for(let e of(this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0,t.state.field($).active))e.isPending&&this.startQuery(e)}update(t){let e=t.state.field($),n=t.state.facet(w);if(!t.selectionSet&&!t.docChanged&&t.startState.field($)==e)return;let i=t.transactions.some(t=>{let e=R(t,n);return 8&e||(t.selection||t.docChanged)&&!(3&e)});for(let e=0;e<this.running.length;e++){let n=this.running[e];if(i||n.context.abortOnDocChange&&t.docChanged||n.updates.length+t.transactions.length>50&&Date.now()-n.time>1e3){for(let t of n.context.abortListeners)try{t()}catch(t){(0,o.OO)(this.view.state,t)}n.context.abortListeners=null,this.running.splice(e--,1)}else n.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(t=>t.effects.some(t=>t.is(g)))&&(this.pendingStart=!0);let s=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.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($);for(let t of e.active)t.isPending&&!this.running.some(e=>e.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(w).updateSyncTime))}startQuery(t){let{state:e}=this.view,n=p(e),i=new l(e,n,t.explicit,this.view),s=new W(t,i);this.running.push(s),Promise.resolve(t.source(i)).then(t=>{s.context.aborted||(s.done=t||null,this.scheduleAccept())},t=>{this.view.dispatch({effects:b.of(null)}),(0,o.OO)(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(w).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(w),i=this.view.state.field($);for(let o=0;o<this.running.length;o++){let s=this.running[o];if(void 0===s.done)continue;if(this.running.splice(o--,1),s.done){let i=p(s.updates.length?s.updates[0].startState:this.view.state),o=Math.min(i,s.done.from+ +!s.active.explicit),l=new M(s.active.source,s.active.explicit,o,s.done,s.done.from,null!=(t=s.done.to)?t:i);for(let t of s.updates)l=l.update(t,n);if(l.hasResult()){e.push(l);continue}}let l=i.active.find(t=>t.source==s.active.source);if(l&&l.isPending)if(null==s.done){let t=new E(s.active.source,0);for(let e of s.updates)t=t.update(e,n);t.isPending||e.push(t)}else this.startQuery(l)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:B.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field($,!1);if(e&&e.tooltip&&this.view.state.facet(w).closeOnBlur){let n=e.open&&(0,o.gB)(this.view,e.open.tooltip);n&&n.dom.contains(t.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:b.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout(()=>this.view.dispatch({effects:g.of(!1)}),20),this.composing=0}}}),H="object"==typeof navigator&&/Win/.test(navigator.platform),Q=i.Wl.highest(o.tk.domEventHandlers({keydown(t,e){let n=e.state.field($,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||t.key.length>1||t.ctrlKey&&!(H&&t.altKey)||t.metaKey)return!1;let i=n.open.options[n.open.selected],o=n.active.find(t=>t.source==i.source),s=i.completion.commitCharacters||o.result.commitCharacters;return s&&s.indexOf(t.key)>-1&&F(e,i),!1}})),_=o.tk.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xb7\xb7\xb7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",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:"'\uD835\uDC65'"}},".cm-completionIcon-constant":{"&:after":{content:"'\uD835\uDC36'"}},".cm-completionIcon-type":{"&:after":{content:"'\uD835\uDC61'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\uD83D\uDD11︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class V{constructor(t,e,n,i){this.field=t,this.line=e,this.from=n,this.to=i}}class Z{constructor(t,e,n){this.field=t,this.from=e,this.to=n}map(t){let e=t.mapPos(this.from,-1,i.gc.TrackDel),n=t.mapPos(this.to,1,i.gc.TrackDel);return null==e||null==n?null:new Z(this.field,e,n)}}class K{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let n=[],i=[e],o=t.doc.lineAt(e),l=/^\s*/.exec(o.text)[0];for(let o of this.lines){if(n.length){let n=l,r=/^\t*/.exec(o)[0].length;for(let e=0;e<r;e++)n+=t.facet(s.c);i.push(e+n.length-r),o=n+o.slice(r)}n.push(o),e+=o.length+1}return{text:n,ranges:this.fieldPositions.map(t=>new Z(t.field,i[t.line]+t.from,i[t.line]+t.to))}}static parse(t){let e=[],n=[],i=[],o;for(let s of t.split(/\r\n?|\n/)){for(;o=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(s);){let t=o[1]?+o[1]:null,l=o[2]||o[3]||"",r=-1,a=l.replace(/\\[{}]/g,t=>t[1]);for(let n=0;n<e.length;n++)(null!=t?e[n].seq==t:a&&e[n].name==a)&&(r=n);if(r<0){let n=0;for(;n<e.length&&(null==t||null!=e[n].seq&&e[n].seq<t);)n++;for(let o of(e.splice(n,0,{seq:t,name:a}),r=n,i))o.field>=r&&o.field++}i.push(new V(r,n.length,o.index,o.index+a.length)),s=s.slice(0,o.index)+l+s.slice(o.index+o[0].length)}s=s.replace(/\\([{}])/g,(t,e,o)=>{for(let t of i)t.line==n.length&&t.from>o&&(t.from--,t.to--);return e}),n.push(s)}return new K(n,i)}}let X=o.p.widget({widget:new class extends o.l9{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),G=o.p.mark({class:"cm-snippetField"});class Y{constructor(t,e){this.ranges=t,this.active=e,this.deco=o.p.set(t.map(t=>(t.from==t.to?X:G).range(t.from,t.to)))}map(t){let e=[];for(let n of this.ranges){let i=n.map(t);if(!i)return null;e.push(i)}return new Y(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))}}let J=i.Py.define({map:(t,e)=>t&&t.map(e)}),tt=i.Py.define(),te=i.QQ.define({create:()=>null,update(t,e){for(let n of e.effects){if(n.is(J))return n.value;if(n.is(tt)&&t)return new Y(t.ranges,n.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>o.tk.decorations.from(t,t=>t?t.deco:o.p.none)});function tn(t,e){return i.jT.create(t.filter(t=>t.field==e).map(t=>i.jT.range(t.from,t.to)))}function ti(t){return({state:e,dispatch:n})=>{let i=e.field(te,!1);if(!i||t<0&&0==i.active)return!1;let o=i.active+t,s=t>0&&!i.ranges.some(e=>e.field==o+t);return n(e.update({selection:tn(i.ranges,o),effects:J.of(s?null:new Y(i.ranges,o)),scrollIntoView:!0})),!0}}let to=[{key:"Tab",run:ti(1),shift:ti(-1)},{key:"Escape",run:({state:t,dispatch:e})=>!!t.field(te,!1)&&(e(t.update({effects:J.of(null)})),!0)}],ts=i.r$.define({combine:t=>t.length?t[0]:to}),tl=i.Wl.highest(o.$f.compute([ts],t=>t.facet(ts)));function tr(t,e){let n;return Object.assign(Object.assign({},e),{apply:(n=K.parse(t),(t,e,o,s)=>{let{text:l,ranges:r}=n.instantiate(t.state,o),{main:a}=t.state.selection,c={changes:{from:o,to:s==a.from?a.to:s,insert:i.xv.of(l)},scrollIntoView:!0,annotations:e?[u.of(e),i.YW.userEvent.of("input.complete")]:void 0};if(r.length&&(c.selection=tn(r,0)),r.some(t=>t.field>0)){let e=new Y(r,0),n=c.effects=[J.of(e)];void 0===t.state.field(te,!1)&&n.push(i.Py.appendConfig.of([te,tl,ta,_]))}t.dispatch(t.state.update(c))})})}let ta=o.tk.domEventHandlers({mousedown(t,e){let n=e.state.field(te,!1),i;if(!n||null==(i=e.posAtCoords({x:t.clientX,y:t.clientY})))return!1;let o=n.ranges.find(t=>t.from<=i&&t.to>=i);return!!o&&o.field!=n.active&&(e.dispatch({selection:tn(n.ranges,o.field),effects:J.of(n.ranges.some(t=>t.field>o.field)?new Y(n.ranges,o.field):null),scrollIntoView:!0}),!0)}}),tc={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},th=i.Py.define({map(t,e){let n=e.mapPos(t,-1,i.gc.TrackAfter);return null==n?void 0:n}}),tp=new class extends i.uU{};tp.startSide=1,tp.endSide=-1;let tf=i.QQ.define({create:()=>i.Xs.empty,update(t,e){if(t=t.map(e.changes),e.selection){let n=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:t=>t>=n.from&&t<=n.to})}for(let n of e.effects)n.is(th)&&(t=t.update({add:[tp.range(n.value,n.value+1)]}));return t}});function tu(){return[tv,tf]}let td="()[]{}<>\xab\xbb\xbb\xab[]{}";function tm(t){for(let e=0;e<td.length;e+=2)if(td.charCodeAt(e)==t)return td.charAt(e+1);return(0,i.bg)(t<128?t:t+1)}function tg(t,e){return t.languageDataAt("closeBrackets",e)[0]||tc}let tb="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),tv=o.tk.inputHandler.of((t,e,n,o)=>{if((tb?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let l=t.state.selection.main;if(o.length>2||2==o.length&&1==(0,i.nZ)((0,i.gm)(o,0))||e!=l.from||n!=l.to)return!1;let r=function(t,e){let n=tg(t,t.selection.main.head),o=n.brackets||tc.brackets;for(let l of o){let r=tm((0,i.gm)(l,0));if(e==l)return r==l?function(t,e,n,o){let l=o.stringPrefixes||tc.stringPrefixes,r=null,a=t.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:e,from:o.to}],effects:th.of(o.to+e.length),range:i.jT.range(o.anchor+e.length,o.head+e.length)};let a=o.head,c=tx(t.doc,a),h;if(c==e){if(tC(t,a))return{changes:{insert:e+e,from:a},effects:th.of(a+e.length),range:i.jT.cursor(a+e.length)};else if(tw(t,a)){let o=n&&t.sliceDoc(a,a+3*e.length)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+o.length,insert:o},range:i.jT.cursor(a+o.length)}}}else if(n&&t.sliceDoc(a-2*e.length,a)==e+e&&(h=tI(t,a-2*e.length,l))>-1&&tC(t,h))return{changes:{insert:e+e+e+e,from:a},effects:th.of(a+e.length),range:i.jT.cursor(a+e.length)};else if(t.charCategorizer(a)(c)!=i.D0.Word&&tI(t,a,l)>-1&&!function(t,e,n,i){let o=(0,s.qz)(t).resolveInner(e,-1),l=i.reduce((t,e)=>Math.max(t,e.length),0);for(let s=0;s<5;s++){let s=t.sliceDoc(o.from,Math.min(o.to,o.from+n.length+l)),r=s.indexOf(n);if(!r||r>-1&&i.indexOf(s.slice(0,r))>-1){let e=o.firstChild;for(;e&&e.from==o.from&&e.to-e.from>n.length+r;){if(t.sliceDoc(e.to-n.length,e.to)==n)return!1;e=e.firstChild}return!0}let a=o.to==e&&o.parent;if(!a)break;o=a}return!1}(t,a,e,l))return{changes:{insert:e+e,from:a},effects:th.of(a+e.length),range:i.jT.cursor(a+e.length)};return{range:r=o}});return r?null:t.update(a,{scrollIntoView:!0,userEvent:"input.type"})}(t,l,o.indexOf(l+l+l)>-1,n):function(t,e,n,o){let s=null,l=t.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:n,from:l.to}],effects:th.of(l.to+e.length),range:i.jT.range(l.anchor+e.length,l.head+e.length)};let r=tx(t.doc,l.head);return!r||/\s/.test(r)||o.indexOf(r)>-1?{changes:{insert:e+n,from:l.head},effects:th.of(l.head+e.length),range:i.jT.cursor(l.head+e.length)}:{range:s=l}});return s?null:t.update(l,{scrollIntoView:!0,userEvent:"input.type"})}(t,l,r,n.before||tc.before);if(e==r&&tw(t,t.selection.main.from))return function(t,e,n){let o=null,s=t.changeByRange(e=>e.empty&&tx(t.doc,e.head)==n?{changes:{from:e.head,to:e.head+n.length,insert:n},range:i.jT.cursor(e.head+n.length)}:o={range:e});return o?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}(t,0,r)}return null}(t.state,o);return!!r&&(t.dispatch(r),!0)}),ty=[{key:"Backspace",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=tg(t,t.selection.main.head).brackets||tc.brackets,o=null,s=t.changeByRange(e=>{if(e.empty){var s,l;let o,r=(s=t.doc,l=e.head,o=s.sliceString(l-2,l),(0,i.nZ)((0,i.gm)(o,0))==o.length?o:o.slice(1));for(let o of n)if(o==r&&tx(t.doc,e.head)==tm((0,i.gm)(o,0)))return{changes:{from:e.head-o.length,to:e.head+o.length},range:i.jT.cursor(e.head-o.length)}}return{range:o=e}});return o||e(t.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!o}}];function tw(t,e){let n=!1;return t.field(tf).between(0,t.doc.length,t=>{t==e&&(n=!0)}),n}function tx(t,e){let n=t.sliceString(e,e+2);return n.slice(0,(0,i.nZ)((0,i.gm)(n,0)))}function tC(t,e){let n=(0,s.qz)(t).resolveInner(e+1);return n.parent&&n.from==e}function tI(t,e,n){let o=t.charCategorizer(e);if(o(t.sliceDoc(e-1,e))!=i.D0.Word)return e;for(let s of n){let n=e-s.length;if(t.sliceDoc(n,e)==s&&o(t.sliceDoc(n-1,n))!=i.D0.Word)return n}return -1}function tO(t={}){return[Q,$,w.of(t),z,tT,_]}let tk=[{key:"Ctrl-Space",run:U},{mac:"Alt-`",run:U},{key:"Escape",run:t=>{let e=t.state.field($,!1);return!!e&&!!e.active.some(t=>0!=t.state)&&(t.dispatch({effects:b.of(null)}),!0)}},{key:"ArrowDown",run:N(!0)},{key:"ArrowUp",run:N(!1)},{key:"PageDown",run:N(!0,"page")},{key:"PageUp",run:N(!1,"page")},{key:"Enter",run:t=>{let e=t.state.field($,!1);return!(t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(w).interactionDelay)&&F(t,e.open.options[e.open.selected])}}],tT=i.Wl.highest(o.$f.computeN([w],t=>t.facet(w).defaultKeymap?[tk]:[]))}}]);