Home
last modified time | relevance | path

Searched refs:W0 (Results 1 – 5 of 5) sorted by relevance

/plugin/mermaid/
H A Dmermaid.min.js1192 …,XB,KB,ZB,QB,JB,eF,tF,rF,iF,FE,$E,nF,aF,sF,oF,lF,cF,uF,hF,rve,dF,m1e,Ze,bT,W0,TT,ny,U5,nve,sve,ylt…
1196W0=Lr({"../../node_modules/.pnpm/vscode-jsonrpc@8.2.0/node_modules/vscode-jsonrpc/lib/common/ral.j…
1197 …leStreamMessageWriter=e.AbstractMessageWriter=e.MessageWriter=void 0;var t=W0(),r=TT(),i=ove(),n=n…
1200 …aceValues=e.Trace=e.NullLogger=e.ProgressType=e.ProgressToken=void 0;var t=W0(),r=TT(),i=nve(),n=s…
1226 …",{enumerable:!0,get:S(function(){return d.MessageStrategy},"get")});var f=W0();e.RAL=f.default}})…
/plugin/bpmnio/vendor/dmn-js/dist/
H A Ddmn-viewer.production.min.js24 `&&n.lineWrapping&&(i&&(i=R.single(i.main.anchor-1,i.main.head-1)),t={from:s.from,to:s.to,insert:J.of([" "])}),t)return uh(n,t,i,o);if(i&&!Dl(i,s)){let a=!1,l="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(a=!0),l=n.inputState.lastSelectionOrigin,l=="select.pointer"&&(i=R0(r.facet(Fo).map(c=>c(n)),i))),n.dispatch({selection:i,scrollIntoView:a,userEvent:l}),!0}else return!1}function uh(n,e,t,i=-1){if(N.ios&&n.inputState.flushIOSKey(e))return!0;let r=n.state.selection.main;if(N.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&n.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&is(n.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||i==8&&e.insert.length<e.to-e.from&&e.to>r.head)&&is(n.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&is(n.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let o,a=()=>o||(o=FS(n,e,t));return n.state.facet(b0).some(l=>l(n,e.from,e.to,s,a))||n.dispatch(a()),!0}function FS(n,e,t){let i,r=n.state,s=r.selection.main,o=-1;if(e.from==e.to&&e.from<s.from||e.from>s.to){let l=e.from<s.from?-1:1,c=l<0?s.from:s.to,u=Do(r.facet(Fo).map(f=>f(n)),c,l);e.from==u&&(o=u)}if(o>-1)i={changes:e,selection:R.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let l=s.from<e.from?r.sliceDoc(s.from,e.from):"",c=s.to>e.to?r.sliceDoc(e.to,s.to):"";i=r.replaceSelection(n.state.toText(l+e.insert.sliceString(0,void 0,n.state.lineBreak)+c))}else{let l=r.changes(e),c=t&&t.main.to<=l.newLength?t.main:void 0;if(r.selection.ranges.length>1&&(n.inputState.composing>=0||n.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let u=n.state.sliceDoc(e.from,e.to),f,h=t&&M0(n,t.main.head);if(h){let p=e.insert.length-(e.to-e.from);f={from:h.from,to:h.to-p}}else f=n.state.doc.lineAt(s.head);let d=s.to-e.to;i=r.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:l,range:c||p.map(l)};let m=p.to-d,y=m-u.length;if(n.state.sliceDoc(y,m)!=u||m>=f.from&&y<=f.to)return{range:p};let g=r.changes({from:y,to:m,insert:e.insert}),w=p.to-s.to;return{changes:g,range:c?R.range(Math.max(0,c.anchor+w),Math.max(0,c.head+w)):p.map(g)}})}else i={changes:l,selection:c&&r.selection.replaceRange(c)}}let a="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,a+=".compose",n.inputState.compositionFirstChange&&(a+=".start",n.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:a,scrollIntoView:!0})}function B0(n,e,t,i){let r=Math.min(n.length,e.length),s=0;for(;s<r&&n.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&n.length==e.length)return null;let o=n.length,a=e.length;for(;o>0&&a>0&&n.charCodeAt(o-1)==e.charCodeAt(a-1);)o--,a--;if(i=="end"){let l=Math.max(0,s-Math.min(o,a));t-=o+l-s}if(o<s&&n.length<e.length){let l=t<=s&&t>=o?s-t:0;s-=l,a=s+(a-o),o=s}else if(a<s){let l=t<=s&&t>=a?s-t:0;s-=l,o=s+(o-a),a=s}return{from:s,toA:o,toB:a}}function jS(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}=n.observer.selectionRange;return t&&(e.push(new Pl(t,i)),(r!=t||s!=i)&&e.push(new Pl(r,s))),e}function VS(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t>-1&&i>-1?R.single(t+e,i+e):null}function Dl(n,e){return e.head==n.main.head&&e.anchor==n.main.anchor}var Nf=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,N.safari&&e.contentDOM.addEventListener("input",()=>null),N.gecko&&nE(e.contentDOM.ownerDocument)}handleEvent(e){!YS(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let r of i.observers)r(this.view,t);for(let r of i.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=QS(e),i=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,a=i[s];a&&o!=!a.handlers.length&&(r.removeEventListener(s,this.handleEvent),a=null),a||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&$0.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),N.android&&N.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return N.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&!e.shiftKey&&((t=I0.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||zS.indexOf(e.key)>-1&&e.ctrlKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,is(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:N.safari&&!N.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function $y(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(r){Pe(t.state,r)}}}function QS(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let r=i.spec,s=r&&r.plugin.domEventHandlers,o=r&&r.plugin.domEventObservers;if(s)for(let a in s){let l=s[a];l&&t(a).handlers.push($y(i.value,l))}if(o)for(let a in o){let l=o[a];l&&t(a).observers.push($y(i.value,l))}}for(let i in Xt)t(i).handlers.push(Xt[i]);for(let i in at)t(i).observers.push(at[i]);return e}var I0=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],zS="dthko",$0=[16,17,18,20,91,92,224,225],gl=6;function yl(n){return Math.max(0,n)*.7+8}function WS(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}var qf=class{constructor(e,t,i,r){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=o0(e.contentDOM),this.atoms=e.state.facet(Fo).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(he.allowMultipleSelections)&&HS(e,t),this.dragging=US(e,t)&&q0(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&WS(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,r=0,s=0,o=this.view.win.innerWidth,a=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:a}=this.scrollParents.y.getBoundingClientRect());let l=ch(this.view);e.clientX-l.left<=r+gl?t=-yl(r-e.clientX):e.clientX+l.right>=o-gl&&(t=yl(e.clientX-o)),e.clientY-l.top<=s+gl?i=-yl(s-e.clientY):e.clientY+l.bottom>=a-gl&&(i=yl(e.clientY-a)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=R0(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function HS(n,e){let t=n.state.facet(g0);return t.length?t[0](e):N.mac?e.metaKey:e.ctrlKey}function XS(n,e){let t=n.state.facet(y0);return t.length?t[0](e):N.mac?!e.altKey:!e.ctrlKey}function US(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=Lo(n.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let o=r[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function YS(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=pe.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}var Xt=Object.create(null),at=Object.create(null),L0=N.ie&&N.ie_version<15||N.ios&&N.webkit_version<604;function KS(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),N0(n,t.value)},50)}function zl(n,e,t){for(let i of n.facet(e))t=i(t,n);return t}function N0(n,e){e=zl(n.state,sh,e);let{state:t}=n,i,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(Ff!=null&&t.selection.ranges.every(l=>l.empty)&&Ff==s.toString()){let l=-1;i=t.changeByRange(c=>{let u=t.doc.lineAt(c.from);if(u.from==l)return{range:c};l=u.from;let f=t.toText((o?s.line(r++).text:e)+t.lineBreak);return{changes:{from:u.from,insert:f},range:R.cursor(c.from+f.length)}})}else o?i=t.changeByRange(l=>{let c=s.line(r++);return{changes:{from:l.from,to:l.to,insert:c.text},range:R.cursor(l.from+c.length)}}):i=t.replaceSelection(s);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}at.scroll=n=>{n.inputState.lastScrollTop=n.scrollDOM.scrollTop,n.inputState.lastScrollLeft=n.scrollDOM.scrollLeft};at.wheel=at.mousewheel=n=>{n.inputState.lastWheelEvent=Date.now()};Xt.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);at.touchstart=(n,e)=>{let t=n.inputState,i=e.targetTouches[0];t.lastTouchTime=Date.now(),i&&(t.lastTouchX=i.clientX,t.lastTouchY=i.clientY),t.setSelectionOrigin("select.pointer")};at.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};Xt.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet(v0))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=JS(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new qf(n,e,t,i)),i&&n.observer.ignore(()=>{a0(n.contentDOM);let s=n.root.activeElement;s&&!s.contains(n.contentDOM)&&s.blur()});let r=n.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else n.inputState.setSelectionOrigin("select.pointer");return!1};function Ly(n,e,t,i){if(i==1)return R.cursor(e,t);if(i==2)return PS(n.state,e,t);{let r=n.docView.lineAt(e,t),s=n.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,a=r?r.posAtEnd:s.to;return a<n.state.doc.length&&a==s.to&&a++,R.range(o,a)}}var GS=N.ie&&N.ie_version<=11,Ny=null,qy=0,Fy=0;function q0(n){if(!GS)return n.detail;let e=Ny,t=Fy;return Ny=n,Fy=Date.now(),qy=!e||t>Date.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(qy+1)%3:1}function JS(n,e){let t=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=q0(e),r=n.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,o,a){let l=n.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),c,u=Ly(n,l.pos,l.assoc,i);if(t.pos!=l.pos&&!o){let f=Ly(n,t.pos,t.assoc,i),h=Math.min(f.from,u.from),d=Math.max(f.to,u.to);u=h<u.from?R.range(h,d,u.assoc):R.range(d,h,u.assoc)}return o?r.replaceRange(r.main.extend(u.from,u.to,u.assoc)):a&&i==1&&r.ranges.length>1&&(c=ZS(r,l.pos))?c:a?r.addRange(u):R.create([u])}}}function ZS(n,e){for(let t=0;t<n.ranges.length;t++){let{from:i,to:r}=n.ranges[t];if(i<=e&&r>=e)return R.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}Xt.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let r=n.docView.tile.nearest(e.target);if(r&&r.isWidget()){let s=r.posAtStart,o=s+r.length;(s>=t.to||o<=t.from)&&(t=R.range(s,o))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",zl(n.state,oh,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Xt.dragend=n=>(n.inputState.draggedContent=null,!1);function jy(n,e,t,i){if(t=zl(n.state,sh,t),!t)return;let r=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=n.inputState,o=i&&s&&XS(n,e)?{from:s.from,to:s.to}:null,a={from:r,insert:t},l=n.state.changes(o?[o,a]:a);n.focus(),n.dispatch({changes:l,selection:{anchor:l.mapPos(r,-1),head:l.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}Xt.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),r=0,s=()=>{++r==t.length&&jy(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let a=new FileReader;a.onerror=s,a.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(i[o]=a.result),s()},a.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return jy(n,e,i,!0),!0}return!1};Xt.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=L0?null:e.clipboardData;return t?(N0(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(KS(n),!1)};function eE(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function tE(n){let e=[],t=[],i=!1;for(let r of n.selection.ranges)r.empty||(e.push(n.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of n.selection.ranges){let o=n.doc.lineAt(s);o.number>r&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),r=o.number}i=!0}return{text:zl(n,oh,e.join(n.lineBreak)),ranges:t,linewise:i}}var Ff=null;Xt.copy=Xt.cut=(n,e)=>{if(!Ao(n.contentDOM,n.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:r}=tE(n.state);if(!t&&!r)return!1;Ff=r?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=L0?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(eE(n,t),!1)};var F0=gt.define();function j0(n,e){let t=[];for(let i of n.facet(w0)){let r=i(n,e);r&&t.push(r)}return t.length?n.update({effects:t,annotations:F0.of(!0)}):null}function V0(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=j0(n.state,e);t?n.dispatch(t):n.update([])}},10)}at.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),V0(n)};at.blur=n=>{n.observer.clearSelectionRange(),V0(n)};at.compositionstart=at.compositionupdate=n=>{n.observer.editContext||(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0))};at.compositionend=n=>{n.observer.editContext||(n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,N.chrome&&N.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};at.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};Xt.beforeinput=(n,e)=>{var t,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(n.inputState.insertingText=e.data,n.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&n.observer.editContext){let s=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let a=o[0],l=n.posAtDOM(a.startContainer,a.startOffset),c=n.posAtDOM(a.endContainer,a.endOffset);return uh(n,{from:l,to:c,insert:n.state.toText(s)},null),!0}}let r;if(N.chrome&&N.android&&(r=I0.find(s=>s.inputType==e.inputType))&&(n.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return N.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),N.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>at.compositionend(n,e),20),!1};var Vy=new Set;function nE(n){Vy.has(n)||(Vy.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}var Qy=["pre-wrap","normal","pre-line","break-spaces"],ls=!1;function zy(){ls=!1}var jf=class{constructor(e){this.lineWrapping=e,this.doc=J.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Qy.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let r=e[i];r<0?i++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,i,r,s,o){let a=Qy.indexOf(e)>-1,l=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=a;if(this.lineWrapping=a,this.lineHeight=t,this.charWidth=i,this.textHeight=r,this.lineLength=s,l){this.heightSamples={};for(let c=0;c<o.length;c++){let u=o[c];u<0?c++:this.heightSamples[Math.floor(u*10)]=!0}}return l}},Vf=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},Wt=class n{constructor(e,t,i,r,s){this.from=e,this.length=t,this.top=i,this.height=r,this._content=s}get type(){return typeof this._content=="number"?Pt.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof $i?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new n(this.from,this.length+e.length,this.top,this.height+e.height,t)}},ce=(function(n){return n[n.ByPos=0]="ByPos",n[n.ByHeight=1]="ByHeight",n[n.ByPosNoHeight=2]="ByPosNoHeight",n})(ce||(ce={})),Cl=.001,vt=class n{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Cl&&(ls=!0),this.height=e)}replace(e,t,i){return n.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,r){let s=this,o=i.doc;for(let a=r.length-1;a>=0;a--){let{fromA:l,toA:c,fromB:u,toB:f}=r[a],h=s.lineAt(l,ce.ByPosNoHeight,i.setDoc(t),0,0),d=h.to>=c?h:s.lineAt(c,ce.ByPosNoHeight,i,0,0);for(f+=d.to-c,c=d.to;a>0&&h.from<=r[a-1].toA;)l=r[a-1].fromA,u=r[a-1].fromB,a--,l<h.from&&(h=s.lineAt(l,ce.ByPosNoHeight,i,0,0));u+=h.from-l,l=h.from;let p=zf.build(i.setDoc(o),e,u,f);s=Bl(s,s.replace(l,c,p))}return s.updateHeight(i,0)}static empty(){return new Tt(0,0,0)}static of(e){if(e.length==1)return e[0];let t=0,i=e.length,r=0,s=0;for(;;)if(t==i)if(r>s*2){let a=e[t-1];a.break?e.splice(--t,1,a.left,null,a.right):e.splice(--t,1,a.left,a.right),i+=1+a.break,r-=a.size}else if(s>r*2){let a=e[i];a.break?e.splice(i,1,a.left,null,a.right):e.splice(i,1,a.left,a.right),i+=2+a.break,s-=a.size}else break;else if(r<s){let a=e[t++];a&&(r+=a.size)}else{let a=e[--i];a&&(s+=a.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,i++),new Qf(n.of(e.slice(0,t)),o,n.of(e.slice(i)))}};function Bl(n,e){return n==e?n:(n.constructor!=e.constructor&&(ls=!0),e)}vt.prototype.size=1;var iE=X.replace({}),Il=class extends vt{constructor(e,t,i){super(e,t),this.deco=i,this.spaceAbove=0}mainBlock(e,t){return new Wt(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,i,r){return this.spaceAbove&&e<i+this.spaceAbove?new Wt(r,0,i,this.spaceAbove,iE):this.mainBlock(i,r)}lineAt(e,t,i,r,s){let o=this.mainBlock(r,s);return this.spaceAbove?this.blockAt(0,i,r,s).join(o):o}forEachLine(e,t,i,r,s,o){e<=s+this.length&&t>=s&&o(this.lineAt(0,ce.ByPos,i,r,s))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}},Tt=class n extends Il{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new Wt(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let r=i[0];return i.length==1&&(r instanceof n||r instanceof ni&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof ni?r=new n(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):vt.of(i)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},ni=class n extends vt{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-i+1,o,a=0;if(e.lineWrapping){let l=Math.min(this.height,e.lineHeight*s);o=l/s,this.length>s+1&&(a=(this.height-l)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:r,perLine:o,perChar:a}}blockAt(e,t,i,r){let{firstLine:s,lastLine:o,perLine:a,perChar:l}=this.heightMetrics(t,r);if(t.lineWrapping){let c=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),u=t.doc.lineAt(c),f=a+u.length*l,h=Math.max(i,e-f/2);return new Wt(u.from,u.length,h,f,0)}else{let c=Math.max(0,Math.min(o-s,Math.floor((e-i)/a))),{from:u,length:f}=t.doc.line(s+c);return new Wt(u,f,i+a*c,a,0)}}lineAt(e,t,i,r,s){if(t==ce.ByHeight)return this.blockAt(e,i,r,s);if(t==ce.ByPosNoHeight){let{from:d,to:p}=i.doc.lineAt(e);return new Wt(d,p-d,0,0,0)}let{firstLine:o,perLine:a,perChar:l}=this.heightMetrics(i,s),c=i.doc.lineAt(e),u=a+c.length*l,f=c.number-o,h=r+a*f+l*(c.from-s-f);return new Wt(c.from,c.length,Math.max(r,Math.min(h,r+this.height-u)),u,0)}forEachLine(e,t,i,r,s,o){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:a,perLine:l,perChar:c}=this.heightMetrics(i,s);for(let u=e,f=r;u<=t;){let h=i.doc.lineAt(u);if(u==e){let p=h.number-a;f+=l*p+c*(e-s-p)}let d=l+c*h.length;o(new Wt(h.from,h.length,f,d,0)),f+=d,u=h.to+1}}replace(e,t,i){let r=this.length-t;if(r>0){let s=i[i.length-1];s instanceof n?i[i.length-1]=new n(s.length+r):i.push(null,new n(r-1))}if(e>0){let s=i[0];s instanceof n?i[0]=new n(e+s.length):i.unshift(new n(e-1),null)}return vt.of(i)}decomposeLeft(e,t){t.push(new n(e-1),null)}decomposeRight(e,t){t.push(null,new n(this.length-e-1))}updateHeight(e,t=0,i=!1,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let o=[],a=Math.max(t,r.from),l=-1;for(r.from>t&&o.push(new n(r.from-t-1).updateHeight(e,t));a<=s&&r.more;){let u=e.doc.lineAt(a).length;o.length&&o.push(null);let f=r.heights[r.index++],h=0;f<0&&(h=-f,f=r.heights[r.index++]),l==-1?l=f:Math.abs(f-l)>=Cl&&(l=-2);let d=new Tt(u,f,h);d.outdated=!1,o.push(d),a+=u+1}a<=s&&o.push(null,new n(s-a).updateHeight(e,a));let c=vt.of(o);return(l<0||Math.abs(c.height-this.height)>=Cl||Math.abs(l-this.heightMetrics(e,t).perLine)>=Cl)&&(ls=!0),Bl(this,c)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},Qf=class extends vt{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,r){let s=i+this.left.height;return e<s?this.left.blockAt(e,t,i,r):this.right.blockAt(e,t,s,r+this.left.length+this.break)}lineAt(e,t,i,r,s){let o=r+this.left.height,a=s+this.left.length+this.break,l=t==ce.ByHeight?e<o:e<a,c=l?this.left.lineAt(e,t,i,r,s):this.right.lineAt(e,t,i,o,a);if(this.break||(l?c.to<a:c.from>a))return c;let u=t==ce.ByPosNoHeight?ce.ByPosNoHeight:ce.ByPos;return l?c.join(this.right.lineAt(a,u,i,o,a)):this.left.lineAt(a,u,i,r,s).join(c)}forEachLine(e,t,i,r,s,o){let a=r+this.left.height,l=s+this.left.length+this.break;if(this.break)e<l&&this.left.forEachLine(e,t,i,r,s,o),t>=l&&this.right.forEachLine(e,t,i,a,l,o);else{let c=this.lineAt(l,ce.ByPos,i,r,s);e<c.from&&this.left.forEachLine(e,c.from-1,i,r,s,o),c.to>=e&&c.from<=t&&o(c),t>c.to&&this.right.forEachLine(c.to+1,t,i,a,l,o)}}replace(e,t,i){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,i));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let a of i)s.push(a);if(e>0&&Wy(s,o-1),t<this.length){let a=s.length;this.decomposeRight(t,s),Wy(s,a)}return vt.of(s)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(i++,e>=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,r=i+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?vt.of(this.break?[e,null,t]:[e,t]):(this.left=Bl(this.left,e),this.right=Bl(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,r){let{left:s,right:o}=this,a=t+s.length+this.break,l=null;return r&&r.from<=t+s.length&&r.more?l=s=s.updateHeight(e,t,i,r):s.updateHeight(e,t,i),r&&r.from<=a+o.length&&r.more?l=o=o.updateHeight(e,a,i,r):o.updateHeight(e,a,i),l?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function Wy(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof ni&&(i=n[e+1])instanceof ni&&n.splice(e-1,3,new ni(t.length+1+i.length))}var rE=5,zf=class n{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof Tt?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new Tt(i-this.pos,-1,0)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e<t||i.heightRelevant){let r=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=t-e;i.block?this.addBlock(new Il(o,r,i)):(o||s||r>=rE)&&this.addLineDeco(r,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Tt(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new ni(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Tt)return e;let t=new Tt(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Tt)&&!this.isCovered?this.nodes.push(new Tt(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let r of this.nodes)r instanceof Tt&&r.updateHeight(this.oracle,i),i+=r?r.length:1;return this.nodes}static build(e,t,i,r){let s=new n(i,e);return re.spans(t,i,r,s,0),s.finish(i)}};function sE(n,e,t){let i=new Wf;return re.compare(n,e,t,i,0),i.changes}var Wf=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,r){(e<t||i&&i.heightRelevant||r&&r.heightRelevant)&&ns(e,t,this.changes,5)}};function oE(n,e){let t=n.getBoundingClientRect(),i=n.ownerDocument,r=i.defaultView||window,s=Math.max(0,t.left),o=Math.min(r.innerWidth,t.right),a=Math.max(0,t.top),l=Math.min(r.innerHeight,t.bottom);for(let c=n.parentNode;c&&c!=i.body;)if(c.nodeType==1){let u=c,f=window.getComputedStyle(u);if((u.scrollHeight>u.clientHeight||u.scrollWidth>u.clientWidth)&&f.overflow!="visible"){let h=u.getBoundingClientRect();s=Math.max(s,h.left),o=Math.min(o,h.right),a=Math.max(a,h.top),l=Math.min(c==n.parentNode?r.innerHeight:l,h.bottom)}c=f.position=="absolute"||f.position=="fixed"?u.offsetParent:u.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:a-(t.top+e),bottom:Math.max(a,l)-(t.top+e)}}function aE(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function lE(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var Bo=class{constructor(e,t,i,r){this.from=e,this.to=t,this.size=i,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let r=e[i],s=t[i];if(r.from!=s.from||r.to!=s.to||r.size!=s.size)return!1}return!0}draw(e,t){return X.replace({widget:new Hf(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},Hf=class extends Dt{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}},$l=class{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Hy,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=ue.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let i=t.facet(ah).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new jf(i),this.stateDeco=Xy(t),this.heightMap=vt.empty().applyChanges(this.stateDeco,J.empty,this.heightOracle.setDoc(t.doc),[new Ht(0,0,0,t.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=X.set(this.lineGaps.map(r=>r.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let r=i?t.head:t.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new es(s,o))}}return this.viewports=e.sort((i,r)=>i.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Hy:new Xf(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Eo(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=Xy(this.state);let r=e.changedRanges,s=Ht.extendWithRanges(r,sE(i,this.stateDeco,e?e.changes:Je.empty(this.state.doc.length))),o=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);zy(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||ls)&&(e.flags|=2),a?(this.scrollAnchorPos=e.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let l=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<l.from||t.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,t));let c=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(gS)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,i=window.getComputedStyle(t),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?ue.RTL:ue.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",a=t.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let c=0,u=0;if(a.width&&a.height){let{scaleX:C,scaleY:k}=s0(t,a);(C>.005&&Math.abs(this.scaleX-C)>.005||k>.005&&Math.abs(this.scaleY-k)>.005)&&(this.scaleX=C,this.scaleY=k,c|=16,o=l=!0)}let f=(parseInt(i.paddingTop)||0)*this.scaleY,h=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=h)&&(this.paddingTop=f,this.paddingBottom=h,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let d=o0(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=l0(this.scrollParent||e.win);let m=(this.printing?lE:oE)(t,this.paddingTop),y=m.top-this.pixelViewport.top,g=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let w=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(w!=this.inView&&(this.inView=w,w&&(l=!0)),!this.inView&&!this.scrollTarget&&!aE(e.dom))return 0;let x=a.width;if((this.contentDOMWidth!=x||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=a.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),l){let C=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(C)&&(o=!0),o||r.lineWrapping&&Math.abs(x-this.contentDOMWidth)>r.charWidth){let{lineHeight:k,charWidth:O,textHeight:v}=e.docView.measureTextSize();o=k>0&&r.refresh(s,k,O,v,Math.max(5,x/O),C),o&&(e.docView.minWidth=0,c|=16)}y>0&&g>0?u=Math.max(y,g):y<0&&g<0&&(u=Math.min(y,g)),zy();for(let k of this.viewports){let O=k.from==this.viewport.from?C:e.docView.measureVisibleLineHeights(k);this.heightMap=(o?vt.empty().applyChanges(this.stateDeco,J.empty,this.heightOracle,[new Ht(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new Vf(k.from,O))}ls&&(c|=2)}let b=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return b&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(u,this.scrollTarget),c|=this.updateForViewport()),(c&2||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:a}=this,l=new es(r.lineAt(o-i*1e3,ce.ByHeight,s,0,0).from,r.lineAt(a+(1-i)*1e3,ce.ByHeight,s,0,0).to);if(t){let{head:c}=t.range;if(c<l.from||c>l.to){let u=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=r.lineAt(c,ce.ByPos,s,0,0),h;t.y=="center"?h=(f.top+f.bottom)/2-u/2:t.y=="start"||t.y=="nearest"&&c<l.from?h=f.top:h=f.bottom-u,l=new es(r.lineAt(h-1e3/2,ce.ByHeight,s,0,0).from,r.lineAt(h+u+1e3/2,ce.ByHeight,s,0,0).to)}}return l}mapViewport(e,t){let i=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new es(this.heightMap.lineAt(i,ce.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,ce.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,ce.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,ce.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:a}=this;return(e==0||r<=o-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||s>=a+Math.max(10,Math.min(i,250)))&&r>o-2*1e3&&s<a+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let r of e)t.touchesRange(r.from,r.to)||i.push(new Bo(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,r=i?1e4:2e3,s=r>>1,o=r<<1;if(this.defaultTextDirection!=ue.LTR&&!i)return[];let a=[],l=(u,f,h,d)=>{if(f-u<s)return;let p=this.state.selection.main,m=[p.from];p.empty||m.push(p.to);for(let g of m)if(g>u&&g<f){l(u,g-10,h,d),l(g+10,f,h,d);return}let y=uE(e,g=>g.from>=h.from&&g.to<=h.to&&Math.abs(g.from-u)<s&&Math.abs(g.to-f)<s&&!m.some(w=>g.from<w&&g.to>w));if(!y){if(f<h.to&&t&&i&&t.visibleRanges.some(x=>x.from<=f&&x.to>=f)){let x=t.moveToLineBoundary(R.cursor(f),!1,!0).head;x>u&&(f=x)}let g=this.gapSize(h,u,f,d),w=i||g<2e6?g:2e6;y=new Bo(u,f,g,w)}a.push(y)},c=u=>{if(u.length<o||u.type!=Pt.Text)return;let f=cE(u.from,u.to,this.stateDeco);if(f.total<o)return;let h=this.scrollTarget?this.scrollTarget.range.head:null,d,p;if(i){let m=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,y,g;if(h!=null){let w=xl(f,h),x=((this.visibleBottom-this.visibleTop)/2+m)/u.height;y=w-x,g=w+x}else y=(this.visibleTop-u.top-m)/u.height,g=(this.visibleBottom-u.top+m)/u.height;d=vl(f,y),p=vl(f,g)}else{let m=f.total*this.heightOracle.charWidth,y=r*this.heightOracle.charWidth,g=0;if(m>2e6)for(let k of e)k.from>=u.from&&k.from<u.to&&k.size!=k.displaySize&&k.from*this.heightOracle.charWidth+g<this.pixelViewport.left&&(g=k.size-k.displaySize);let w=this.pixelViewport.left+g,x=this.pixelViewport.right+g,b,C;if(h!=null){let k=xl(f,h),O=((x-w)/2+y)/m;b=k-O,C=k+O}else b=(w-y)/m,C=(x+y)/m;d=vl(f,b),p=vl(f,C)}d>u.from&&l(u.from,d,u,f),p<u.to&&l(p,u.to,u,f)};for(let u of this.viewportLines)Array.isArray(u.type)?u.type.forEach(c):c(u);return a}gapSize(e,t,i,r){let s=xl(r,i)-xl(r,t);return this.heightOracle.lineWrapping?e.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(e){Bo.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=X.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];re.spans(t,this.viewport.from,this.viewport.to,{span(s,o){i.push({from:s,to:o})},point(){}},20);let r=0;if(i.length!=this.visibleRanges.length)r=12;else for(let s=0;s<i.length&&!(r&8);s++){let o=this.visibleRanges[s],a=i[s];(o.from!=a.from||o.to!=a.to)&&(r|=4,e&&e.mapPos(o.from,-1)==a.from&&e.mapPos(o.to,1)==a.to||(r|=8))}return this.visibleRanges=i,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Eo(this.heightMap.lineAt(e,ce.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Eo(this.heightMap.lineAt(this.scaler.fromDOM(e),ce.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Eo(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},es=class{constructor(e,t){this.from=e,this.to=t}};function cE(n,e,t){let i=[],r=n,s=0;return re.spans(t,n,e,{span(){},point(o,a){o>r&&(i.push({from:r,to:o}),s+=o-r),r=a}},20),r<e&&(i.push({from:r,to:e}),s+=e-r),{total:s,ranges:i}}function vl({total:n,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let r=0;;r++){let{from:s,to:o}=e[r],a=o-s;if(i<=a)return s+i;i-=a}}function xl(n,e){let t=0;for(let{from:i,to:r}of n.ranges){if(e<=r){t+=e-i;break}t+=r-i}return t/n.total}function uE(n,e){for(let t of n)if(e(t))return t}var Hy={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};function Xy(n){let e=n.facet(Ql).filter(i=>typeof i!="function"),t=n.facet(lh).filter(i=>typeof i!="function");return t.length&&e.push(re.join(t)),e}var Xf=class n{constructor(e,t,i){let r=0,s=0,o=0;this.viewports=i.map(({from:a,to:l})=>{let c=t.lineAt(a,ce.ByPos,e,0,0).top,u=t.lineAt(l,ce.ByPos,e,0,0).bottom;return r+=u-c,{from:a,to:l,top:c,bottom:u,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let a of this.viewports)a.domTop=o+(a.top-s)*this.scale,o=a.domBottom=a.domTop+(a.bottom-a.top),s=a.bottom}toDOM(e){for(let t=0,i=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return r+(e-i)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);i=s.bottom,r=s.domBottom}}fromDOM(e){for(let t=0,i=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return i+(e-r)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);i=s.bottom,r=s.domBottom}}eq(e){return e instanceof n?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,i)=>t.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}};function Eo(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new Wt(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(r=>Eo(r,e)):n._content)}var bl=L.define({combine:n=>n.join(" ")}),Uf=L.define({combine:n=>n.indexOf(!0)>-1}),Yf=_t.newName(),Q0=_t.newName(),z0=_t.newName(),W0={"&light":"."+Q0,"&dark":"."+z0};function Kf(n,e,t){return new _t(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return n;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):n+" "+i}})}var fE=Kf("."+Yf,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},W0),hE={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},mf=N.ie&&N.ie_version<=11,Gf=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new wf,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(N.ie&&N.ie_version<=11||N.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&N.android&&e.constructor.EDIT_CONTEXT!==!1&&!(N.chrome&&N.chrome_version<126)&&(this.editContext=new Jf(e),e.state.facet(Dn)&&(e.contentDOM.editContext=this.editContext.editContext)),mf&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,r=this.selectionRange;if(i.state.facet(Dn)?i.root.activeElement!=this.dom:!Ao(this.dom,r))return;let s=r.anchorNode&&i.docView.tile.nearest(r.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(N.ie&&N.ie_version<=11||N.android&&N.chrome)&&!i.state.selection.main.empty&&r.focusNode&&To(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Lo(e.root);if(!t)return!1;let i=N.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&dE(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let r=Ao(this.dom,i);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&oS(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(i.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=t)i.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,hE),mf&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),mf&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var i;if(!this.delayedAndroidKey){let r=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&is(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:r}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),r=this.selectionChanged&&Ao(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new Lf(this.view,e,t,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,r=D0(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!Dl(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let i=Uy(t,e.previousSibling||e.target.previousSibling,-1),r=Uy(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Dn)!=e.state.facet(Dn)&&(e.view.contentDOM.editContext=e.state.facet(Dn)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function Uy(n,e,t){for(;e;){let i=pe.get(e);if(i&&i.parent==n)return i;let r=e.parentNode;e=r!=n.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function Yy(n,e){let t=e.startContainer,i=e.startOffset,r=e.endContainer,s=e.endOffset,o=n.docView.domAtPos(n.state.selection.main.anchor,1);return To(o.node,o.offset,r,s)&&([t,i,r,s]=[r,s,t,i]),{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}}function dE(n,e){if(e.getComposedRanges){let r=e.getComposedRanges(n.root)[0];if(r)return Yy(n,r)}let t=null;function i(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",i,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",i,!0),t?Yy(n,t):null}var Jf=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let r=e.state.selection.main,{anchor:s,head:o}=r,a=this.toEditorPos(i.updateRangeStart),l=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:a,drifted:!1});let c=l-a>i.text.length;a==this.from&&s<this.from?a=s:l==this.to&&s>this.to&&(l=s);let u=B0(e.state.sliceDoc(a,l),i.text,(c?r.from:r.to)-a,c?"end":null);if(!u){let h=R.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));Dl(h,r)||e.dispatch({selection:h,userEvent:"select"});return}let f={from:u.from+a,to:u.toA+a,insert:J.of(i.text.slice(u.from,u.toB).split(`
25 `))};if((N.mac||N.android)&&f.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:a,to:l,insert:J.of([i.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let h=this.to-this.from+(f.to-f.from+f.insert.length);uh(e,f,R.single(this.toEditorPos(i.selectionStart,h),this.toEditorPos(i.selectionEnd,h)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),f.from<f.to&&!f.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let r=[],s=null;for(let o=this.toEditorPos(i.rangeStart),a=this.toEditorPos(i.rangeEnd);o<a;o++){let l=e.coordsForChar(o);s=l&&new DOMRect(l.left,l.top,l.right-l.left,l.bottom-l.top)||s||new DOMRect,r.push(s)}t.updateCharacterBounds(i.rangeStart,r)},this.handlers.textformatupdate=i=>{let r=[];for(let s of i.getTextFormats()){let o=s.underlineStyle,a=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(a)){let l=this.toEditorPos(s.rangeStart),c=this.toEditorPos(s.rangeEnd);if(l<c){let u=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(a)?1:2}px`;r.push(X.mark({attributes:{style:u}}).range(l,c))}}}e.dispatch({effects:C0.of(X.set(r))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{this.editContext.updateControlBounds(i.contentDOM.getBoundingClientRect());let r=Lo(i.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,r=this.pendingContextChange;return e.changes.iterChanges((s,o,a,l,c)=>{if(i)return;let u=c.length-(o-s);if(r&&o>=r.to)if(r.from==s&&r.to==o&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=u,this.to+=u;return}else r=null,this.revertPending(e.state);if(s+=t,o+=t,o<=this.from)this.from+=u,this.to+=u;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+c.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),c.toString()),this.to+=u}t+=u}),r&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(i,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},q=class n{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(r=>r.forEach(s=>i(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||sS(e.parent)||document,this.viewState=new $l(this,e.state||he.create(e)),e.scrollTo&&e.scrollTo.is(ml)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Zr).map(r=>new Ro(r));for(let r of this.plugins)r.update(this);this.observer=new Gf(this),this.inputState=new Nf(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Rl(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof Le?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,r,s=this.state;for(let h of e){if(h.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=h.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,a=0,l=null;e.some(h=>h.annotation(F0))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=j0(s,o),l||(a=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(u=null)):this.observer.clear(),s.facet(he.phrases)!=this.state.facet(he.phrases))return this.setState(s);r=Tl.create(this,s,e),r.flags|=a;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let h of e){if(f&&(f=f.map(h.changes)),h.scrollIntoView){let{main:d}=h.state.selection,{x:p,y:m}=this.state.facet(n.cursorScrollMargin);f=new Mo(d.empty?d:R.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",m,p)}for(let d of h.effects)d.is(ml)&&(f=d.value.clip(this.state))}this.viewState.update(r,f),this.bidiCache=Ll.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(So)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(h=>h.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(bl)!=r.state.facet(bl)&&(this.viewState.mustMeasureContent=!0),(t||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!r.empty)for(let h of this.state.facet(Sf))try{h(r)}catch(d){Pe(this.state,d,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!D0(this,u)&&c.force&&is(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new $l(this,e),this.plugins=e.facet(Zr).map(i=>new Ro(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new Rl(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Zr),i=e.state.facet(Zr);if(t!=i){let r=[];for(let s of i){let o=t.indexOf(s);if(o<0)r.push(new Ro(s));else{let a=this.plugins[o];a.mustUpdate=e,r.push(a)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(i){Pe(this.state,i,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0)if(l0(i||this.win))s=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(r);s=d.from,o=d.top}this.updateState=1;let l=this.viewState.measure();if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(d=>{try{return d.read(this)}catch(p){return Pe(this.state,p),Ky}}),f=Tl.create(this,this.state,[]),h=!1;f.flags|=l,t?t.flags|=l:t=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),h=this.docView.update(f),h&&this.docViewUpdate());for(let d=0;d<c.length;d++)if(u[d]!=Ky)try{let p=c[d];p.write&&p.write(u[d],this)}catch(p){Pe(this.state,p)}if(h&&this.docView.updateSelection(!0),!f.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let p=((s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o)/this.scaleY;if((p>1||p<-1)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r=r+p,i?i.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(Sf))a(t)}get themeClasses(){return Yf+" "+(this.state.facet(Uf)?z0:Q0)+" "+this.state.facet(bl)}updateAttrs(){let e=Gy(this,S0,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Dn)?"true":"false",class:"cm-content",style:`${N.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Gy(this,ah,t);let i=this.observer.ignore(()=>{let r=Ty(this.contentDOM,this.contentAttrs,t),s=Ty(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let r of i.effects)if(r.is(n.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(So);let e=this.state.facet(n.cspNonce);_t.mount(this.root,this.styleModules.concat(fE).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return pf(this,e,Iy(this,e,t,i))}moveByGroup(e,t){return pf(this,e,Iy(this,e,t,i=>$S(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),r=this.textDirectionAt(e.from),s=i[t?i.length-1:0];return R.cursor(s.side(t,r)+e.from,s.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,i=!0){return IS(this,e,t,i)}moveVertically(e,t,i){return pf(this,e,LS(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=Bf(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),Bf(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[Rt.find(s,e-r.from,-1,t)];return No(i,o.dir==ue.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(O0)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>pE)return p0(e.length);let t=this.textDirectionAt(e.from),i;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||d0(s.isolates,i=Py(this,e))))return s.order;i||(i=Py(this,e));let r=dS(e.text,t,i);return this.bidiCache.push(new Ll(e.from,e.to,t,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||N.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{a0(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var i,r,s,o;return ml.of(new Mo(typeof e=="number"?R.cursor(e):e,(i=t.y)!==null&&i!==void 0?i:"nearest",(r=t.x)!==null&&r!==void 0?r:"nearest",(s=t.yMargin)!==null&&s!==void 0?s:5,(o=t.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return ml.of(new Mo(R.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return ze.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return ze.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=_t.newName(),r=[bl.of(i),So.of(Kf(`.${i}`,e))];return t&&t.dark&&r.push(Uf.of(!0)),r}static baseTheme(e){return Rn.lowest(So.of(Kf("."+Yf,e,W0)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),r=i&&pe.get(i)||pe.get(e);return((t=r==null?void 0:r.root)===null||t===void 0?void 0:t.view)||null}};q.styleModule=So;q.inputHandler=b0;q.clipboardInputFilter=sh;q.clipboardOutputFilter=oh;q.scrollHandler=k0;q.focusChangeEffect=w0;q.perLineTextDirection=O0;q.exceptionSink=x0;q.updateListener=Sf;q.editable=Dn;q.mouseSelectionStyle=v0;q.dragMovesSelection=y0;q.clickAddsSelectionRange=g0;q.decorations=Ql;q.blockWrappers=E0;q.outerDecorations=lh;q.atomicRanges=Fo;q.bidiIsolatedRanges=A0;q.cursorScrollMargin=L.define({combine:n=>{let e=5,t=5;for(let i of n)typeof i=="number"?e=t=i:{x:e,y:t}=i;return{x:e,y:t}}});q.scrollMargins=_0;q.darkTheme=Uf;q.cspNonce=L.define({combine:n=>n.length?n[0]:""});q.contentAttributes=ah;q.editorAttributes=S0;q.lineWrapping=q.contentAttributes.of({class:"cm-lineWrapping"});q.announce=U.define();var pE=4096,Ky={},Ll=class n{constructor(e,t,i,r,s,o){this.from=e,this.to=t,this.dir=i,this.isolates=r,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:ue.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==r&&!t.touchesRange(o.from,o.to)&&i.push(new n(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}};function Gy(n,e,t){for(let i=n.state.facet(e),r=i.length-1;r>=0;r--){let s=i[r],o=typeof s=="function"?s(n):s;o&&nh(o,t)}return t}var mE=N.mac?"mac":N.windows?"win":N.linux?"linux":"key";function gE(n,e){let t=n.split(/-(?!$)/),i=t[t.length-1];i=="Space"&&(i=" ");let r,s,o,a;for(let l=0;l<t.length-1;++l){let c=t[l];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))e=="mac"?a=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(i="Alt-"+i),s&&(i="Ctrl-"+i),a&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function wl(n,e,t){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t!==!1&&e.shiftKey&&(n="Shift-"+n),n}var yE=Rn.default(q.domEventHandlers({keydown(n,e){return wE(vE(e.state),n,e,"editor")}})),cs=L.define({enables:yE}),Jy=new WeakMap;function vE(n){let e=n.facet(cs),t=Jy.get(e);return t||Jy.set(e,t=bE(e.reduce((i,r)=>i.concat(r),[]))),t}var ti=null,xE=4e3;function bE(n,e=mE){let t=Object.create(null),i=Object.create(null),r=(o,a)=>{let l=i[o];if(l==null)i[o]=a;else if(l!=a)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,a,l,c,u)=>{var f,h;let d=t[o]||(t[o]=Object.create(null)),p=a.split(/ (?!$)/).map(g=>gE(g,e));for(let g=1;g<p.length;g++){let w=p.slice(0,g).join(" ");r(w,!0),d[w]||(d[w]={preventDefault:!0,stopPropagation:!1,run:[x=>{let b=ti={view:x,prefix:w,scope:o};return setTimeout(()=>{ti==b&&(ti=null)},xE),!0}]})}let m=p.join(" ");r(m,!1);let y=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((h=(f=d._any)===null||f===void 0?void 0:f.run)===null||h===void 0?void 0:h.slice())||[]});l&&y.run.push(l),c&&(y.preventDefault=!0),u&&(y.stopPropagation=!0)};for(let o of n){let a=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of a){let u=t[c]||(t[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=o;for(let h in u)u[h].run.push(d=>f(d,Zf))}let l=o[e]||o.key;if(l)for(let c of a)s(c,l,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(c,"Shift-"+l,o.shift,o.preventDefault,o.stopPropagation)}return t}var Zf=null;function wE(n,e,t,i){Zf=e;let r=Cy(e),s=At(r,0),o=un(s)==r.length&&r!=" ",a="",l=!1,c=!1,u=!1;ti&&ti.view==t&&ti.scope==i&&(a=ti.prefix+" ",$0.indexOf(e.keyCode)<0&&(c=!0,ti=null));let f=new Set,h=y=>{if(y){for(let g of y.run)if(!f.has(g)&&(f.add(g),g(t)))return y.stopPropagation&&(u=!0),!0;y.preventDefault&&(y.stopPropagation&&(u=!0),c=!0)}return!1},d=n[i],p,m;return d&&(h(d[a+wl(r,e,!o)])?l=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(N.windows&&e.ctrlKey&&e.altKey)&&!(N.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=Pn[e.keyCode])&&p!=r?(h(d[a+wl(p,e,!0)])||e.shiftKey&&(m=Gr[e.keyCode])!=r&&m!=p&&h(d[a+wl(m,e,!1)]))&&(l=!0):o&&e.shiftKey&&h(d[a+wl(r,e,!0)])&&(l=!0),!l&&h(d._any)&&(l=!0)),c&&(l=!0),l&&u&&e.stopPropagation(),Zf=null,l}var m3=/x/.unicode!=null?"gu":"g";var eh=class extends Dt{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?_o(e.firstChild):[];if(!t.length)return null;let i=window.getComputedStyle(e.parentNode),r=No(t[0],i.direction!="rtl"),s=parseInt(i.lineHeight);return r.bottom-r.top>s*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+s}:r}ignoreEvent(){return!1}};function fh(n){let e=ze.fromClass(class{constructor(t){this.view=t,this.placeholder=n?X.set([X.widget({widget:new eh(n),side:1}).range(0)]):X.none}get decorations(){return this.view.state.doc.length?X.none:this.placeholder}},{decorations:t=>t.decorations});return typeof n=="string"?[e,q.contentAttributes.of({"aria-placeholder":n})]:e}var Ol="-10000px",Nl=class{constructor(e,t,i,r){this.facet=t,this.createTooltipView=i,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=i(o,s))}update(e,t){var i;let r=e.state.facet(this.facet),s=r.filter(l=>l);if(r===this.input){for(let l of this.tooltipViews)l.update&&l.update(e);return!1}let o=[],a=t?[]:null;for(let l=0;l<s.length;l++){let c=s[l],u=-1;if(c){for(let f=0;f<this.tooltips.length;f++){let h=this.tooltips[f];h&&h.create==c.create&&(u=f)}if(u<0)o[l]=this.createTooltipView(c,l?o[l-1]:null),a&&(a[l]=!!c.above);else{let f=o[l]=this.tooltipViews[u];a&&(a[l]=t[u]),f.update&&f.update(e)}}}for(let l of this.tooltipViews)o.indexOf(l)<0&&(this.removeTooltipView(l),(i=l.destroy)===null||i===void 0||i.call(l));return t&&(a.forEach((l,c)=>t[c]=l),t.length=a.length),this.input=r,this.tooltips=s,this.tooltipViews=o,!0}};function H0(n={}){return Sl.of(n)}function OE(n){let e=n.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}var Sl=L.define({combine:n=>{var e,t,i;return{position:N.ios?"absolute":((e=n.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(r=>r.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(r=>r.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||OE}}}),Zy=new WeakMap,hh=ze.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(Sl);this.position=e.position,this.parent=e.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Nl(n,jo,(t,i)=>this.createTooltip(t,i),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(Sl);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n,e){let t=n.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),n.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",t.dom.appendChild(r)}return t.dom.style.position=this.position,t.dom.style.top=Ol,t.dom.style.left="0px",this.container.insertBefore(t.dom,i),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var n,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(n=i.destroy)===null||n===void 0||n.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(N.safari){let o=s.getBoundingClientRect();t=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else t=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(n=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:n,scaleY:e}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),r=ch(this.view);return{visible:{left:i.left+r.left,top:i.top+r.top,right:i.right-r.right,bottom:i.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,o)=>{let a=this.manager.tooltipViews[o];return a.getCoords?a.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(Sl).tooltipSpace(this.view),scaleX:n,scaleY:e,makeAbsolute:t}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let a of this.manager.tooltipViews)a.dom.style.position="absolute"}let{visible:t,space:i,scaleX:r,scaleY:s}=n,o=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],c=this.manager.tooltipViews[a],{dom:u}=c,f=n.pos[a],h=n.size[a];if(!f||l.clip!==!1&&(f.bottom<=Math.max(t.top,i.top)||f.top>=Math.min(t.bottom,i.bottom)||f.right<Math.max(t.left,i.left)-.1||f.left>Math.min(t.right,i.right)+.1)){u.style.top=Ol;continue}let d=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,m=h.right-h.left,y=(e=Zy.get(c))!==null&&e!==void 0?e:h.bottom-h.top,g=c.offset||CE,w=this.view.textDirection==ue.LTR,x=h.width>i.right-i.left?w?i.left:i.right-h.width:w?Math.max(i.left,Math.min(f.left-(d?14:0)+g.x,i.right-m)):Math.min(Math.max(i.left,f.left-m+(d?14:0)-g.x),i.right-m),b=this.above[a];!l.strictSide&&(b?f.top-y-p-g.y<i.top:f.bottom+y+p+g.y>i.bottom)&&b==i.bottom-f.bottom>f.top-i.top&&(b=this.above[a]=!b);let C=(b?f.top-i.top:i.bottom-f.bottom)-p;if(C<y&&c.resize!==!1){if(C<this.view.defaultLineHeight){u.style.top=Ol;continue}Zy.set(c,y),u.style.height=(y=C)/s+"px"}else u.style.height&&(u.style.height="");let k=b?f.top-y-p-g.y:f.bottom+p+g.y,O=x+m;if(c.overlap!==!0)for(let v of o)v.left<O&&v.right>x&&v.top<k+y&&v.bottom>k&&(k=b?v.top-y-2-p:v.bottom+p+2);if(this.position=="absolute"?(u.style.top=(k-n.parent.top)/s+"px",e0(u,(x-n.parent.left)/r)):(u.style.top=k/s+"px",e0(u,x/r)),d){let v=f.left+(w?g.x:-g.x)-(x+14-7);d.style.left=v/r+"px"}c.overlap!==!0&&o.push({left:x,top:k,right:O,bottom:k+y}),u.classList.toggle("cm-tooltip-above",b),u.classList.toggle("cm-tooltip-below",!b),c.positioned&&c.positioned(n.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=Ol}},{eventObservers:{scroll(){this.maybeMeasure()}}});function e0(n,e){let t=parseInt(n.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(n.style.left=e+"px")}var kE=q.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),CE={x:0,y:0},jo=L.define({enables:[hh,kE]}),ql=L.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])}),Fl=class n{static create(e){return new n(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Nl(e,ql,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let r=i[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}},SE=jo.compute([ql],n=>{let e=n.facet(ql);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:Fl.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),EE=L.define(),th=class{constructor(e,t,i,r,s,o){this.view=e,this.source=t,this.field=i,this.locked=r,this.setHover=s,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,i=e.docView.tile.nearest(t.target);if(!i)return;let r,s=1;if(i.isWidget())r=i.posAtStart;else{if(r=e.posAtCoords(t),r==null)return;let o=e.coordsAtPos(r);if(!o||t.y<o.top||t.y>o.bottom||t.x<o.left-e.defaultCharacterWidth||t.x>o.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(r)).find(c=>c.from<=r&&c.to>=r),l=a&&a.dir==ue.RTL?-1:1;s=t.x<o.left?-l:l}this.activateHover(e,r,s)}activateHover(e,t,i,r){let s=this.source(e,t,i),o=a=>{if(a&&!(Array.isArray(a)&&!a.length)){let l=Array.isArray(a)?a:[a];r&&this.locked.set(l,r),e.dispatch({effects:this.setHover.of(l)})}};if(s&&"then"in s){let a=this.pending={pos:t};s.then(l=>{this.pending==a&&(this.pending=null,o(l))},l=>Pe(e.state,l,"hover tooltip"))}else o(s)}get tooltip(){let e=this.view.plugin(hh),t=e?e.manager.tooltips.findIndex(i=>i.create==Fl.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:r,tooltip:s}=this;if(r.length&&!this.locked.has(r)&&s&&!AE(s.dom,e)||this.pending){let{pos:o}=r[0]||this.pending,a=(i=(t=r[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:o;(o==a?this.view.posAtCoords(this.lastMove)!=o:!_E(this.view,o,a,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t);let{active:r}=this;r.length&&!this.locked.has(r)&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},kl=4;function AE(n,e){let{left:t,right:i,top:r,bottom:s}=n.getBoundingClientRect(),o;if(o=n.querySelector(".cm-tooltip-arrow")){let a=o.getBoundingClientRect();r=Math.min(a.top,r),s=Math.max(a.bottom,s)}return e.clientX>=t-kl&&e.clientX<=i+kl&&e.clientY>=r-kl&&e.clientY<=s+kl}function _E(n,e,t,i,r,s){let o=n.scrollDOM.getBoundingClientRect(),a=n.documentTop+n.documentPadding.top+n.contentHeight;if(o.left>i||o.right<i||o.top>r||Math.min(o.bottom,a)<r)return!1;let l=n.posAtCoords({x:i,y:r},!1);return l>=e&&l<=t}function X0(n,e={}){let t=U.define(),i=new WeakMap,r=Ne.define({create(){return[]},update(o,a){let l=i.get(o);if(o.length&&(e.hideOnChange&&(a.docChanged||a.selection)?o=[]:l&&l(a)?o=[]:e.hideOn&&(o=o.filter(c=>!e.hideOn(a,c)))),a.docChanged&&o.length){let c=[];for(let u of o){let f=a.changes.mapPos(u.pos,-1,Ee.TrackDel);if(f!=null){let h=Object.assign(Object.create(null),u);h.pos=f,h.end!=null&&(h.end=a.changes.mapPos(h.end)),c.push(h)}}o=c}for(let c of a.effects)c.is(t)&&(o=c.value,l=void 0),(c.is(TE)&&!c.value||c.value==r)&&(o=[]);return o.length&&l&&i.set(o,l),o},provide:o=>ql.from(o)}),s=ze.define(o=>new th(o,n,r,i,t,e.hoverTime||300));return{active:r,extension:[r,s,EE.of(s),SE]}}function dh(n,e){let t=n.plugin(hh);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}var TE=U.define();var t0=L.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});var ME=ze.fromClass(class{constructor(n){this.input=n.state.facet(jl),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(t0);this.top=new ts(n,!0,e.topContainer),this.bottom=new ts(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(t0);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new ts(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new ts(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(jl);if(t!=this.input){let i=t.filter(l=>l),r=[],s=[],o=[],a=[];for(let l of i){let c=this.specs.indexOf(l),u;c<0?(u=l(n.view),a.push(u)):(u=this.panels[c],u.update&&u.update(n)),r.push(u),(u.top?s:o).push(u)}this.specs=i,this.panels=r,this.top.sync(s),this.bottom.sync(o);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>q.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})}),ts=class{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=n0(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=n0(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}};function n0(n){let e=n.nextSibling;return n.remove(),e}var jl=L.define({enables:ME});var dn=class extends Et{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};dn.prototype.elementClass="";dn.prototype.toDOM=void 0;dn.prototype.mapMode=Ee.TrackBefore;dn.prototype.startSide=dn.prototype.endSide=-1;dn.prototype.point=!0;var RE=0,Vo=class{constructor(e,t){this.from=e,this.to=t}},H=class{constructor(e={}){this.id=RE++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=We.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}};H.closedBy=new H({deserialize:n=>n.split(" ")});H.openedBy=new H({deserialize:n=>n.split(" ")});H.group=new H({deserialize:n=>n.split(" ")});H.isolate=new H({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});H.contextHash=new H({perNode:!0});H.lookAhead=new H({perNode:!0});H.mounted=new H({perNode:!0});var qi=class{constructor(e,t,i,r=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=r}static get(e){return e&&e.props&&e.props[H.mounted.id]}},PE=Object.create(null),We=class n{constructor(e,t,i,r=0){this.name=e,this.props=t,this.id=i,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):PE,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new n(e.name||"",t,e.id,i);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(H.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let r of i.split(" "))t[r]=e[i];return i=>{for(let r=i.prop(H.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?i.name:r[s]];if(o)return o}}}};We.none=new We("",Object.create(null),0,8);var Qo=class n{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let r=null;for(let s of e){let o=s(i);if(o){r||(r=Object.assign({},i.props));let a=o[1],l=o[0];l.combine&&l.id in r&&(a=l.combine(r[l.id],a)),r[l.id]=a}}t.push(r?new We(i.name,r,i.id,i.flags):i)}return new n(t)}},Wl=new WeakMap,U0=new WeakMap,me;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays",n[n.EnterBracketed=16]="EnterBracketed"})(me||(me={}));var be=class n{constructor(e,t,i,r,s){if(this.type=e,this.children=t,this.positions=i,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,a]of s)this.props[typeof o=="number"?o:o.id]=a}}toString(){let e=qi.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let r=i.toString();r&&(t&&(t+=","),t+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new Ho(this.topNode,e)}cursorAt(e,t=0,i=0){let r=Wl.get(this)||this.topNode,s=new Ho(r);return s.moveTo(e,t),Wl.set(this,s._tree),s}get topNode(){return new pn(this,0,0,null)}resolve(e,t=0){let i=zo(Wl.get(this)||this.topNode,e,t,!1);return Wl.set(this,i),i}resolveInner(e,t=0){let i=zo(U0.get(this)||this.topNode,e,t,!0);return U0.set(this,i),i}resolveStack(e,t=0){return DE(this,e,t)}iterate(e){let{enter:t,leave:i,from:r=0,to:s=this.length}=e,o=e.mode||0,a=(o&me.IncludeAnonymous)>0;for(let l=this.cursor(o|me.IncludeAnonymous);;){let c=!1;if(l.from<=s&&l.to>=r&&(!a&&l.type.isAnonymous||t(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&i&&(a||!l.type.isAnonymous)&&i(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:bh(We.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,r)=>new n(this.type,t,i,r,this.propValues),e.makeTree||((t,i,r)=>new n(We.none,t,i,r)))}static build(e){return BE(e)}};be.empty=new be(We.none,[],[],0);var ph=class n{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new n(this.buffer,this.index)}},si=class n{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return We.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],r=this.set.types[t],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),e+=4,i==e)return s;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,t,i,r,s){let{buffer:o}=this,a=-1;for(let l=e;l!=t&&!(G0(s,r,o[l+1],o[l+2])&&(a=l,i>0));l=o[l+3]);return a}slice(e,t,i){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let a=e,l=0;a<t;){s[l++]=r[a++],s[l++]=r[a++]-i;let c=s[l++]=r[a++]-i;s[l++]=r[a++]-e,o=Math.max(o,c)}return new n(s,o,this.set)}};function G0(n,e,t,i){switch(n){case-2:return t<e;case-1:return i>=e&&t<e;case 0:return t<e&&i>e;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function zo(n,e,t,i){for(var r;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to<e);){let o=!i&&n instanceof pn&&n.index<0?null:n.parent;if(!o)return n;n=o}let s=i?0:me.IgnoreOverlays;if(i)for(let o=n,a=o.parent;a;o=a,a=o.parent)o instanceof pn&&o.index<0&&((r=a.enter(e,t,s))===null||r===void 0?void 0:r.from)!=o.from&&(n=a);for(;;){let o=n.enter(e,t,s);if(!o)return n;n=o}}var Xl=class{cursor(e=0){return new Ho(this,e)}getChild(e,t=null,i=null){let r=Y0(this,e,t,i);return r.length?r[0]:null}getChildren(e,t=null,i=null){return Y0(this,e,t,i)}resolve(e,t=0){return zo(this,e,t,!1)}resolveInner(e,t=0){return zo(this,e,t,!0)}matchContext(e){return mh(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(i=t,t=r.prevSibling):t=r}return i}get node(){return this}get next(){return this.parent}},pn=class n extends Xl{constructor(e,t,i,r){super(),this._tree=e,this.from=t,this.index=i,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,r,s=0){for(let o=this;;){for(let{children:a,positions:l}=o._tree,c=t>0?a.length:-1;e!=c;e+=t){let u=a[e],f=l[e]+o.from,h;if(!(!(s&me.EnterBracketed&&u instanceof be&&(h=qi.get(u))&&!h.overlay&&h.bracketed&&i>=f&&i<=f+u.length)&&!G0(r,i,f,f+u.length))){if(u instanceof si){if(s&me.ExcludeBuffers)continue;let d=u.findChild(0,u.buffer.length,t,i-f,r);if(d>-1)return new Wo(new gh(o,u,e,f),null,d)}else if(s&me.IncludeAnonymous||!u.type.isAnonymous||xh(u)){let d;if(!(s&me.IgnoreMounts)&&(d=qi.get(u))&&!d.overlay)return new n(d.tree,f,e,o);let p=new n(u,f,e,o);return s&me.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?u.children.length-1:0,t,i,r,s)}}}if(s&me.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let r;if(!(i&me.IgnoreOverlays)&&(r=qi.get(this._tree))&&r.overlay){let s=e-this.from,o=i&me.EnterBracketed&&r.bracketed;for(let{from:a,to:l}of r.overlay)if((t>0||o?a<=s:a<s)&&(t<0||o?l>=s:l>s))return new n(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function Y0(n,e,t,i){let r=n.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=r.type.is(t),!r.nextSibling())return s}for(;;){if(i!=null&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return i==null?s:[]}}function mh(n,e,t=e.length-1){for(let i=n;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}var gh=class{constructor(e,t,i,r){this.parent=e,this.buffer=t,this.index=i,this.start=r}},Wo=class n extends Xl{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,i);return s<0?null:new n(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&me.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new n(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new n(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new n(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,r=this.index+4,s=i.buffer[this.index+3];if(s>r){let o=i.buffer[this.index+1];e.push(i.slice(r,s,o)),t.push(0)}return new be(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function J0(n){if(!n.length)return null;let e=0,t=n[0];for(let s=1;s<n.length;s++){let o=n[s];(o.from>t.from||o.to<t.to)&&(t=o,e=s)}let i=t instanceof pn&&t.index<0?null:t.parent,r=n.slice();return i?r[e]=i:r.splice(e,1),new yh(r,t)}var yh=class{constructor(e,t){this.heads=e,this.node=t}get next(){return J0(this.heads)}};function DE(n,e,t){let i=n.resolveInner(e,t),r=null;for(let s=i instanceof pn?i:i.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(r||(r=[i])).push(o.resolve(e,t)),s=o}else{let o=qi.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let a=new pn(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(zo(a,e,t,!1))}}return r?J0(r):i}var Ho=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~me.EnterBracketed,e instanceof pn)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof pn?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&me.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&me.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&me.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:i}=r)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let s=t+e,o=e<0?-1:i._tree.children.length;s!=o;s+=e){let a=i._tree.children[s];if(this.mode&me.IncludeAnonymous||a instanceof si||!a.type.isAnonymous||xh(a))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let r=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,i=s+1;break e}r=this.stack[--s]}for(let r=i;r<this.stack.length;r++)t=new Wo(this.buffer,t,this.stack[r]);return this.bufferNode=new Wo(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,r=!0}}}matchContext(e){if(!this.buffer)return mh(this.node.parent,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let r=e.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return mh(this._tree,e,r);let o=i[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}};function xh(n){return n.children.some(e=>e instanceof si||!e.type.isAnonymous||xh(e))}function BE(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=i.types.length}=n,a=Array.isArray(t)?new ph(t,t.length):t,l=i.types,c=0,u=0;function f(C,k,O,v,A,S){let{id:M,start:_,end:P,size:j}=a,oe=u,ee=c;if(j<0)if(a.next(),j==-1){let ut=s[M];O.push(ut),v.push(_-C);return}else if(j==-3){c=M;return}else if(j==-4){u=M;return}else throw new RangeError(`Unrecognized record size: ${j}`);let Y=l[M],Zt,ct,Ae=_-C;if(P-_<=r&&(ct=y(a.pos-k,A))){let ut=new Uint16Array(ct.size-ct.skip),qe=a.pos-ct.size,et=ut.length;for(;a.pos>qe;)et=g(ct.start,ut,et);Zt=new si(ut,P-ct.start,i),Ae=ct.start-C}else{let ut=a.pos-j;a.next();let qe=[],et=[],Nt=M>=o?M:-1,ft=0,Fn=P;for(;a.pos>ut;)Nt>=0&&a.id==Nt&&a.size>=0?(a.end<=Fn-r&&(p(qe,et,_,ft,a.end,Fn,Nt,oe,ee),ft=qe.length,Fn=a.end),a.next()):S>2500?h(_,ut,qe,et):f(_,ut,qe,et,Nt,S+1);if(Nt>=0&&ft>0&&ft<qe.length&&p(qe,et,_,ft,_,Fn,Nt,oe,ee),qe.reverse(),et.reverse(),Nt>-1&&ft>0){let ua=d(Y,ee);Zt=bh(Y,qe,et,0,qe.length,0,P-_,ua,ua)}else Zt=m(Y,qe,et,P-_,oe-P,ee)}O.push(Zt),v.push(Ae)}function h(C,k,O,v){let A=[],S=0,M=-1;for(;a.pos>k;){let{id:_,start:P,end:j,size:oe}=a;if(oe>4)a.next();else{if(M>-1&&P<M)break;M<0&&(M=j-r),A.push(_,P,j),S++,a.next()}}if(S){let _=new Uint16Array(S*4),P=A[A.length-2];for(let j=A.length-3,oe=0;j>=0;j-=3)_[oe++]=A[j],_[oe++]=A[j+1]-P,_[oe++]=A[j+2]-P,_[oe++]=oe;O.push(new si(_,A[2]-P,i)),v.push(P-C)}}function d(C,k){return(O,v,A)=>{let S=0,M=O.length-1,_,P;if(M>=0&&(_=O[M])instanceof be){if(!M&&_.type==C&&_.length==A)return _;(P=_.prop(H.lookAhead))&&(S=v[M]+_.length+P)}return m(C,O,v,A,S,k)}}function p(C,k,O,v,A,S,M,_,P){let j=[],oe=[];for(;C.length>v;)j.push(C.pop()),oe.push(k.pop()+O-A);C.push(m(i.types[M],j,oe,S-A,_-S,P)),k.push(A-O)}function m(C,k,O,v,A,S,M){if(S){let _=[H.contextHash,S];M=M?[_].concat(M):[_]}if(A>25){let _=[H.lookAhead,A];M=M?[_].concat(M):[_]}return new be(C,k,O,v,M)}function y(C,k){let O=a.fork(),v=0,A=0,S=0,M=O.end-r,_={size:0,start:0,skip:0};e:for(let P=O.pos-C;O.pos>P;){let j=O.size;if(O.id==k&&j>=0){_.size=v,_.start=A,_.skip=S,S+=4,v+=4,O.next();continue}let oe=O.pos-j;if(j<0||oe<P||O.start<M)break;let ee=O.id>=o?4:0,Y=O.start;for(O.next();O.pos>oe;){if(O.size<0)if(O.size==-3||O.size==-4)ee+=4;else break e;else O.id>=o&&(ee+=4);O.next()}A=Y,v+=j,S+=ee}return(k<0||v==C)&&(_.size=v,_.start=A,_.skip=S),_.size>4?_:void 0}function g(C,k,O){let{id:v,start:A,end:S,size:M}=a;if(a.next(),M>=0&&v<o){let _=O;if(M>4){let P=a.pos-(M-4);for(;a.pos>P;)O=g(C,k,O)}k[--O]=_,k[--O]=S-C,k[--O]=A-C,k[--O]=v}else M==-3?c=v:M==-4&&(u=v);return O}let w=[],x=[];for(;a.pos>0;)f(n.start||0,n.bufferStart||0,w,x,-1,0);let b=(e=n.length)!==null&&e!==void 0?e:w.length?x[0]+w[0].length:0;return new be(l[n.topID],w.reverse(),x.reverse(),b)}var K0=new WeakMap;function Hl(n,e){if(!n.isAnonymous||e instanceof si||e.type!=n)return 1;let t=K0.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof be)){t=1;break}t+=Hl(n,i)}K0.set(e,t)}return t}function bh(n,e,t,i,r,s,o,a,l){let c=0;for(let p=i;p<r;p++)c+=Hl(n,e[p]);let u=Math.ceil(c*1.5/8),f=[],h=[];function d(p,m,y,g,w){for(let x=y;x<g;){let b=x,C=m[x],k=Hl(n,p[x]);for(x++;x<g;x++){let O=Hl(n,p[x]);if(k+O>=u)break;k+=O}if(x==b+1){if(k>u){let O=p[b];d(O.children,O.positions,0,O.children.length,m[b]+w);continue}f.push(p[b])}else{let O=m[x-1]+p[x-1].length-C;f.push(bh(n,p,m,b,x,C,O,null,l))}h.push(C+w-s)}}return d(e,t,i,r,0),(a||l)(f,h,o)}var Fi=class n{constructor(e,t,i,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let r=[new n(0,e.length,e,0,!1,i)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,i=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let u=a<t.length?t[a]:null,f=u?u.fromA:1e9;if(f-l>=i)for(;o&&o.from<f;){let h=o;if(l>=h.from||f<=h.to||c){let d=Math.max(h.from,l)-c,p=Math.min(h.to,f)-c;h=d>=p?null:new n(d,p,h.tree,h.offset+c,a>0,!!u)}if(h&&r.push(h),o.to>f)break;o=s<e.length?e[s++]:null}if(!u)break;l=u.toA,c=u.toA-u.toB}return r}},us=class{startParse(e,t,i){return typeof e=="string"&&(e=new vh(e)),i=i?i.length?i.map(r=>new Vo(r.from,r.to)):[new Vo(0,0)]:[new Vo(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let r=this.startParse(e,t,i);for(;;){let s=r.advance();if(s)return s}}},vh=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};var w3=new H({perNode:!0});var IE=0,Ut=class n{constructor(e,t,i,r){this.name=e,this.set=t,this.base=i,this.modified=r,this.id=IE++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof n&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let r=new n(i,[],null,[]);if(r.set.push(r),t)for(let s of t.set)r.set.push(s);return r}static defineModifier(e){let t=new Gl(e);return i=>i.modified.indexOf(t)>-1?i:Gl.get(i.base||i,i.modified.concat(t).sort((r,s)=>r.id-s.id))}},$E=0,Gl=class n{constructor(e){this.name=e,this.instances=[],this.id=$E++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(a=>a.base==e&&LE(t,a.modified));if(i)return i;let r=[],s=new Ut(e.name,r,e,t);for(let a of t)a.instances.push(s);let o=NE(t);for(let a of e.set)if(!a.modified.length)for(let l of o)r.push(n.get(a,l));return s}};function LE(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function NE(n){let e=[[]];for(let t=0;t<n.length;t++)for(let i=0,r=e.length;i<r;i++)e.push(e[i].concat(n[t]));return e.sort((t,i)=>i.length-t.length)}function Jl(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let r of t.split(" "))if(r){let s=[],o=2,a=r;for(let f=0;;){if(a=="..."&&f>0&&f+3==r.length){o=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!h)throw new RangeError("Invalid path: "+r);if(s.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),f+=h[0].length,f==r.length)break;let d=r[f++];if(f==r.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+r);a=r.slice(f)}let l=s.length-1,c=s[l];if(!c)throw new RangeError("Invalid path: "+r);let u=new Vi(i,o,l>0?s.slice(0,l):null);e[c]=u.sort(e[c])}}return tv.add(e)}var tv=new H({combine(n,e){let t,i,r;for(;n||e;){if(!n||e&&n.depth>=e.depth?(r=e,e=e.next):(r=n,n=n.next),t&&t.mode==r.mode&&!r.context&&!t.context)continue;let s=new Vi(r.tags,r.mode,r.context);t?t.next=s:i=s,t=s}return i}}),Vi=class{constructor(e,t,i,r){this.tags=e,this.mode=t,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};Vi.empty=new Vi([],2,null);function Ch(n,e){let t=Object.create(null);for(let s of n)if(!Array.isArray(s.tag))t[s.tag.id]=s.class;else for(let o of s.tag)t[o.id]=s.class;let{scope:i,all:r=null}=e||{};return{style:s=>{let o=r;for(let a of s)for(let l of a.set){let c=t[l.id];if(c){o=o?o+" "+c:c;break}}return o},scope:i}}function qE(n,e){let t=null;for(let i of n){let r=i.style(e);r&&(t=t?t+" "+r:r)}return t}function nv(n,e,t,i=0,r=n.length){let s=new Oh(i,Array.isArray(e)?e:[e],t);s.highlightRange(n.cursor(),i,r,"",s.highlighters),s.flush(r)}var Oh=class{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,r,s){let{type:o,from:a,to:l}=e;if(a>=i||l<=t)return;o.isTop&&(s=this.highlighters.filter(d=>!d.scope||d.scope(o)));let c=r,u=FE(e)||Vi.empty,f=qE(s,u.tags);if(f&&(c&&(c+=" "),c+=f,u.mode==1&&(r+=(r?" ":"")+f)),this.startSpan(Math.max(t,a),c),u.opaque)return;let h=e.tree&&e.tree.prop(H.mounted);if(h&&h.overlay){let d=e.node.enter(h.overlay[0].from+a,1),p=this.highlighters.filter(y=>!y.scope||y.scope(h.tree.type)),m=e.firstChild();for(let y=0,g=a;;y++){let w=y<h.overlay.length?h.overlay[y]:null,x=w?w.from+a:l,b=Math.max(t,g),C=Math.min(i,x);if(b<C&&m)for(;e.from<C&&(this.highlightRange(e,b,C,r,s),this.startSpan(Math.min(C,e.to),c),!(e.to>=x||!e.nextSibling())););if(!w||x>i)break;g=w.to+a,g>t&&(this.highlightRange(d.cursor(),Math.max(t,w.from+a),Math.min(i,g),"",p),this.startSpan(Math.min(i,g),c))}m&&e.parent()}else if(e.firstChild()){h&&(r="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,r,s),this.startSpan(Math.min(i,e.to),c)}while(e.nextSibling());e.parent()}}};function FE(n){let e=n.type.prop(tv);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}var I=Ut.define,Ul=I(),oi=I(),Z0=I(oi),ev=I(oi),ai=I(),Yl=I(ai),wh=I(ai),yn=I(),ji=I(yn),mn=I(),gn=I(),kh=I(),Xo=I(kh),Kl=I(),T={comment:Ul,lineComment:I(Ul),blockComment:I(Ul),docComment:I(Ul),name:oi,variableName:I(oi),typeName:Z0,tagName:I(Z0),propertyName:ev,attributeName:I(ev),className:I(oi),labelName:I(oi),namespace:I(oi),macroName:I(oi),literal:ai,string:Yl,docString:I(Yl),character:I(Yl),attributeValue:I(Yl),number:wh,integer:I(wh),float:I(wh),bool:I(ai),regexp:I(ai),escape:I(ai),color:I(ai),url:I(ai),keyword:mn,self:I(mn),null:I(mn),atom:I(mn),unit:I(mn),modifier:I(mn),operatorKeyword:I(mn),controlKeyword:I(mn),definitionKeyword:I(mn),moduleKeyword:I(mn),operator:gn,derefOperator:I(gn),arithmeticOperator:I(gn),logicOperator:I(gn),bitwiseOperator:I(gn),compareOperator:I(gn),updateOperator:I(gn),definitionOperator:I(gn),typeOperator:I(gn),controlOperator:I(gn),punctuation:kh,separator:I(kh),bracket:Xo,angleBracket:I(Xo),squareBracket:I(Xo),paren:I(Xo),brace:I(Xo),content:yn,heading:ji,heading1:I(ji),heading2:I(ji),heading3:I(ji),heading4:I(ji),heading5:I(ji),heading6:I(ji),contentSeparator:I(yn),list:I(yn),quote:I(yn),emphasis:I(yn),strong:I(yn),link:I(yn),monospace:I(yn),strikethrough:I(yn),inserted:I(),deleted:I(),changed:I(),invalid:I(),meta:Kl,documentMeta:I(Kl),annotation:I(Kl),processingInstruction:I(Kl),definition:Ut.defineModifier("definition"),constant:Ut.defineModifier("constant"),function:Ut.defineModifier("function"),standard:Ut.defineModifier("standard"),local:Ut.defineModifier("local"),special:Ut.defineModifier("special")};for(let n in T){let e=T[n];e instanceof Ut&&(e.name=n)}var C3=Ch([{tag:T.link,class:"tok-link"},{tag:T.heading,class:"tok-heading"},{tag:T.emphasis,class:"tok-emphasis"},{tag:T.strong,class:"tok-strong"},{tag:T.keyword,class:"tok-keyword"},{tag:T.atom,class:"tok-atom"},{tag:T.bool,class:"tok-bool"},{tag:T.url,class:"tok-url"},{tag:T.labelName,class:"tok-labelName"},{tag:T.inserted,class:"tok-inserted"},{tag:T.deleted,class:"tok-deleted"},{tag:T.literal,class:"tok-literal"},{tag:T.string,class:"tok-string"},{tag:T.number,class:"tok-number"},{tag:[T.regexp,T.escape,T.special(T.string)],class:"tok-string2"},{tag:T.variableName,class:"tok-variableName"},{tag:T.local(T.variableName),class:"tok-variableName tok-local"},{tag:T.definition(T.variableName),class:"tok-variableName tok-definition"},{tag:T.special(T.variableName),class:"tok-variableName2"},{tag:T.definition(T.propertyName),class:"tok-propertyName tok-definition"},{tag:T.typeName,class:"tok-typeName"},{tag:T.namespace,class:"tok-namespace"},{tag:T.className,class:"tok-className"},{tag:T.macroName,class:"tok-macroName"},{tag:T.propertyName,class:"tok-propertyName"},{tag:T.operator,class:"tok-operator"},{tag:T.comment,class:"tok-comment"},{tag:T.meta,class:"tok-meta"},{tag:T.invalid,class:"tok-invalid"},{tag:T.punctuation,class:"tok-punctuation"}]);var Sh,fs=new H;function VE(n){return L.define({combine:n?e=>e.concat(n):void 0})}var QE=new H,xt=class{constructor(e,t,i=[],r=""){this.data=e,this.name=r,he.prototype.hasOwnProperty("tree")||Object.defineProperty(he.prototype,"tree",{get(){return ge(this)}}),this.parser=t,this.extension=[hs.of(this),he.languageData.of((s,o,a)=>{let l=iv(s,o,a),c=l.type.prop(fs);if(!c)return[];let u=s.facet(c),f=l.type.prop(QE);if(f){let h=l.resolve(o-l.from,a);for(let d of f)if(d.test(h,s)){let p=s.facet(d.facet);return d.type=="replace"?p:p.concat(u)}}return u})].concat(i)}isActiveAt(e,t,i=-1){return iv(e,t,i).type.prop(fs)==this.data}findRegions(e){let t=e.facet(hs);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],r=(s,o)=>{if(s.prop(fs)==this.data){i.push({from:o,to:o+s.length});return}let a=s.prop(H.mounted);if(a){if(a.tree.prop(fs)==this.data){if(a.overlay)for(let l of a.overlay)i.push({from:l.from+o,to:l.to+o});else i.push({from:o,to:o+s.length});return}else if(a.overlay){let l=i.length;if(r(a.tree,a.overlay[0].from+o),i.length>l)return}}for(let l=0;l<s.children.length;l++){let c=s.children[l];c instanceof be&&r(c,s.positions[l]+o)}};return r(ge(e),0),i}get allowsNesting(){return!0}};xt.setState=U.define();function iv(n,e,t){let i=n.facet(hs),r=ge(n).topNode;if(!i||i.allowsNesting)for(let s=r;s;s=s.enter(e,t,me.ExcludeBuffers|me.EnterBracketed))s.type.isTop&&(r=s);return r}var Zl=class n extends xt{constructor(e,t,i){super(e,t,[],i),this.parser=t}static define(e){let t=VE(e.languageData);return new n(t,e.parser.configure({props:[fs.add(i=>i.isTop?t:void 0)]}),e.name)}configure(e,t){return new n(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function ge(n){let e=n.field(xt.state,!1);return e?e.tree:be.empty}var Th=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}},Uo=null,Mh=class n{constructor(e,t,i=[],r,s,o,a,l){this.parser=e,this.state=t,this.fragments=i,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new n(e,t,[],be.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Th(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=be.empty&&this.isDone(t!=null?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(Fi.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(t!=null?t:this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Fi.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Uo;Uo=this;try{return e()}finally{Uo=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=rv(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:r,treeLen:s,viewport:o,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,u,f,h)=>l.push({fromA:c,toA:u,fromB:f,toB:h})),i=Fi.applyChanges(i,l),r=be.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){a=[];for(let c of this.skipped){let u=e.mapPos(c.from,1),f=e.mapPos(c.to,-1);u<f&&a.push({from:u,to:f})}}}return new n(this.parser,t,i,r,s,o,a,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:r,to:s}=this.skipped[i];r<e.to&&s>e.from&&(this.fragments=rv(this.fragments,r,s),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends us{createParse(t,i,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let l=Uo;if(l){for(let c of r)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=o,new be(We.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Uo}};function rv(n,e,t){return Fi.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}var Yo=class n{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new n(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Mh.create(e.facet(hs).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new n(i)}};xt.state=Ne.define({create:Yo.init,update(n,e){for(let t of e.effects)if(t.is(xt.setState))return t.value;return e.startState.facet(hs)!=e.state.facet(hs)?Yo.init(e.state):n.apply(e)}});var cv=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback!="undefined"&&(cv=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var Eh=typeof navigator!="undefined"&&(!((Sh=navigator.scheduling)===null||Sh===void 0)&&Sh.isInputPending)?()=>navigator.scheduling.isInputPending():null,zE=ze.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(xt.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(xt.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=cv(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:r}}=this.view,s=i.field(xt.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!Eh?Math.max(25,e.timeRemaining()-5):1e9),a=s.context.treeLen<r&&i.doc.length>r+1e3,l=s.context.work(()=>Eh&&Eh()||Date.now()>o,r+(a?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:xt.setState.of(new Yo(s.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Pe(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),hs=L.define({combine(n){return n.length?n[0]:null},enables:n=>[xt.state,zE,q.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]}),ec=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}};var WE=L.define(),ps=L.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Ko(n){let e=n.facet(ps);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function ms(n,e){let t="",i=n.tabSize,r=n.facet(ps)[0];if(r==" "){for(;e>=i;)t+=" ",e-=i;r=" "}for(let s=0;s<e;s++)t+=r;return t}function tc(n,e){n instanceof he&&(n=new Qi(n));for(let i of n.state.facet(WE)){let r=i(n,e);if(r!==void 0)return r}let t=ge(n.state);return t.length>=e?HE(n,t,e):null}var Qi=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Ko(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=i.from&&r<=i.to?s&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:i.text.slice(r-i.from),from:r}:{text:i.text.slice(0,r-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:r}=this.lineAt(e,t);return i.slice(e-r,Math.min(i.length,e+100-r))}column(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.countColumn(i,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(e,t=e.length){return Di(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},$h=new H;function HE(n,e,t){let i=e.resolveStack(t),r=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(r!=i.node){let s=[];for(let o=r;o&&!(o.from<i.node.from||o.to>i.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)i={node:s[o],next:i}}return uv(i,n,t)}function uv(n,e,t){for(let i=n;i;i=i.next){let r=UE(i.node);if(r)return r(Rh.create(e,t,i))}return 0}function XE(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function UE(n){let e=n.type.prop($h);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(H.closedBy))){let r=n.lastChild,s=r&&i.indexOf(r.name)>-1;return o=>fv(o,!0,1,void 0,s&&!XE(o)?r.from:void 0)}return n.parent==null?YE:null}function YE(){return 0}var Rh=class n extends Qi{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new n(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(KE(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return uv(this.context.next,this.base,this.pos)}};function KE(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function GE(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let r=n.options.simulateBreak,s=n.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let a=t.to;;){let l=e.childAfter(a);if(!l||l==i)return null;if(!l.type.isSkipped){if(l.from>=o)return null;let c=/^ */.exec(s.text.slice(t.to-s.from))[0].length;return{from:t.from,to:t.to+c}}a=l.to}}function Lh({closing:n,align:e=!0,units:t=1}){return i=>fv(i,e,t,n)}function fv(n,e,t,i,r){let s=n.textAfter,o=s.match(/^\s*/)[0].length,a=i&&s.slice(o,o+i.length)==i||r==n.pos+o,l=e?GE(n):null;return l?a?n.column(l.from):n.column(l.to):n.baseIndent+(a?0:n.unit*t)}function nc({except:n,units:e=1}={}){return t=>{let i=n&&n.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}var JE=200;function hv(){return he.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,r=t.lineAt(i);if(i>r.from+JE)return n;let s=t.sliceString(r.from,i);if(!e.some(c=>c.test(s)))return n;let{state:o}=n,a=-1,l=[];for(let{head:c}of o.selection.ranges){let u=o.doc.lineAt(c);if(u.from==a)continue;a=u.from;let f=tc(o,u.from);if(f==null)continue;let h=/^\s*/.exec(u.text)[0],d=ms(o,f);h!=d&&l.push({from:u.from,to:u.from+h.length,insert:d})}return l.length?[n,{changes:l,sequential:!0}]:n})}var dv=new H;function ic(n){let e=n.firstChild,t=n.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?n.to:t.from}:null}var ds=class n{constructor(e,t){this.specs=e;let i;function r(a){let l=_t.newName();return(i||(i=Object.create(null)))["."+l]=a,l}let s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof xt?a=>a.prop(fs)==o.data:o?a=>a==o:void 0,this.style=Ch(e.map(a=>({tag:a.tag,class:a.class||r(Object.assign({},a,{tag:null}))})),{all:s}).style,this.module=i?new _t(i):null,this.themeType=t.themeType}static define(e,t){return new n(e,t||{})}},Ph=L.define(),pv=L.define({combine(n){return n.length?[n[0]]:null}});function Ah(n){let e=n.facet(Ph);return e.length?e:n.facet(pv)}function mv(n,e){let t=[ZE],i;return n instanceof ds&&(n.module&&t.push(q.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(pv.of(n)):i?t.push(Ph.computeN([q.darkTheme],r=>r.facet(q.darkTheme)==(i=="dark")?[n]:[])):t.push(Ph.of(n)),t}var Dh=class{constructor(e){this.markCache=Object.create(null),this.tree=ge(e.state),this.decorations=this.buildDeco(e,Ah(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=ge(e.state),i=Ah(e.state),r=i!=Ah(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<s.to&&!r&&t.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return X.none;let i=new Mn;for(let{from:r,to:s}of e.visibleRanges)nv(this.tree,t,(o,a,l)=>{i.add(o,a,this.markCache[l]||(this.markCache[l]=X.mark({class:l})))},r,s);return i.finish()}},ZE=Rn.high(ze.fromClass(Dh,{decorations:n=>n.decorations})),P3=ds.define([{tag:T.meta,color:"#404740"},{tag:T.link,textDecoration:"underline"},{tag:T.heading,textDecoration:"underline",fontWeight:"bold"},{tag:T.emphasis,fontStyle:"italic"},{tag:T.strong,fontWeight:"bold"},{tag:T.strikethrough,textDecoration:"line-through"},{tag:T.keyword,color:"#708"},{tag:[T.atom,T.bool,T.url,T.contentSeparator,T.labelName],color:"#219"},{tag:[T.literal,T.inserted],color:"#164"},{tag:[T.string,T.deleted],color:"#a11"},{tag:[T.regexp,T.escape,T.special(T.string)],color:"#e40"},{tag:T.definition(T.variableName),color:"#00f"},{tag:T.local(T.variableName),color:"#30a"},{tag:[T.typeName,T.namespace],color:"#085"},{tag:T.className,color:"#167"},{tag:[T.special(T.variableName),T.macroName],color:"#256"},{tag:T.definition(T.propertyName),color:"#00c"},{tag:T.comment,color:"#940"},{tag:T.invalid,color:"#f00"}]),eA=q.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),gv=1e4,yv="()[]{}",vv=L.define({combine(n){return ei(n,{afterCursor:!0,brackets:yv,maxScanDistance:gv,renderMatch:iA})}}),tA=X.mark({class:"cm-matchingBracket"}),nA=X.mark({class:"cm-nonmatchingBracket"});function iA(n){let e=[],t=n.matched?tA:nA;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}function sv(n){let e=[],t=n.facet(vv);for(let i of n.selection.ranges){if(!i.empty)continue;let r=Yt(n,i.head,-1,t)||i.head>0&&Yt(n,i.head-1,1,t)||t.afterCursor&&(Yt(n,i.head,1,t)||i.head<n.doc.length&&Yt(n,i.head+1,-1,t));r&&(e=e.concat(t.renderMatch(r,n)))}return X.set(e,!0)}var rA=ze.fromClass(class{constructor(n){this.paused=!1,this.decorations=sv(n.state)}update(n){(n.docChanged||n.selectionSet||this.paused)&&(n.view.composing?(this.decorations=this.decorations.map(n.changes),this.paused=!0):(this.decorations=sv(n.state),this.paused=!1))}},{decorations:n=>n.decorations}),sA=[rA,eA];function xv(n={}){return[vv.of(n),sA]}var oA=new H;function Bh(n,e,t){let i=n.prop(e<0?H.openedBy:H.closedBy);if(i)return i;if(n.name.length==1){let r=t.indexOf(n.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function Ih(n){let e=n.type.prop(oA);return e?e(n.node):n}function Yt(n,e,t,i={}){let r=i.maxScanDistance||gv,s=i.brackets||yv,o=ge(n),a=o.resolveInner(e,t);for(let l=a;l;l=l.parent){let c=Bh(l.type,t,s);if(c&&l.from<l.to){let u=Ih(l);if(u&&(t>0?e>=u.from&&e<u.to:e>u.from&&e<=u.to))return aA(n,e,t,l,u,c,s)}}return lA(n,e,t,o,a.type,r,s)}function aA(n,e,t,i,r,s,o){let a=i.parent,l={from:r.from,to:r.to},c=0,u=a==null?void 0:a.cursor();if(u&&(t<0?u.childBefore(i.from):u.childAfter(i.to)))do if(t<0?u.to<=i.from:u.from>=i.to){if(c==0&&s.indexOf(u.type.name)>-1&&u.from<u.to){let f=Ih(u);return{start:l,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(Bh(u.type,t,o))c++;else if(Bh(u.type,-t,o)){if(c==0){let f=Ih(u);return{start:l,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}c--}}while(t<0?u.prevSibling():u.nextSibling());return{start:l,matched:!1}}function lA(n,e,t,i,r,s,o){if(t<0?!e:e==n.doc.length)return null;let a=t<0?n.sliceDoc(e-1,e):n.sliceDoc(e,e+1),l=o.indexOf(a);if(l<0||l%2==0!=t>0)return null;let c={from:t<0?e-1:e,to:t>0?e+1:e},u=n.doc.iterRange(e,t>0?n.doc.length:0),f=0;for(let h=0;!u.next().done&&h<=s;){let d=u.value;t<0&&(h+=d.length);let p=e+h*t;for(let m=t>0?0:d.length-1,y=t>0?d.length:-1;m!=y;m+=t){let g=o.indexOf(d[m]);if(!(g<0||i.resolveInner(p+m,1).type!=r))if(g%2==0==t>0)f++;else{if(f==1)return{start:c,end:{from:p+m,to:p+m+1},matched:g>>1==l>>1};f--}}t>0&&(h+=d.length)}return u.done?{start:c,matched:!1}:null}var cA=Object.create(null),ov=[We.none];var av=[],lv=Object.create(null),uA=Object.create(null);for(let[n,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"]])uA[n]=fA(cA,e);function _h(n,e){av.indexOf(n)>-1||(av.push(n),console.warn(e))}function fA(n,e){let t=[];for(let a of e.split(" ")){let l=[];for(let c of a.split(".")){let u=n[c]||T[c];u?typeof u=="function"?l.length?l=l.map(u):_h(c,`Modifier ${c} used at start of tag`):l.length?_h(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:_h(c,`Unknown highlighting tag ${c}`)}for(let c of l)t.push(c)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+t.map(a=>a.id),s=lv[r];if(s)return s.id;let o=lv[r]=We.define({id:ov.length,name:i,props:[Jl({[i]:t})]});return ov.push(o),o.id}var D3={rtl:X.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:ue.RTL}),ltr:X.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:ue.LTR}),auto:X.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var sc=class{constructor(e,t,i,r){this.state=e,this.pos=t,this.explicit=i,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=ge(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),i=Math.max(t.from,this.pos-250),r=t.text.slice(i-t.from,this.pos-t.from),s=r.search(_v(e,!1));return s<0?null:{from:i+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}};function bv(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function hA(n){let e=Object.create(null),t=Object.create(null);for(let{label:r}of n){e[r[0]]=!0;for(let s=1;s<r.length;s++)t[r[s]]=!0}let i=bv(e)+bv(t)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function ys(n){let e=n.map(r=>typeof r=="string"?{label:r}:r),[t,i]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:hA(e);return r=>{let s=r.matchBefore(i);return s||r.explicit?{from:s?s.from:r.pos,options:e,validFor:t}:null}}var oc=class{constructor(e,t,i,r){this.completion=e,this.source=t,this.match=i,this.score=r}};function Wi(n){return n.selection.main.from}function _v(n,e){var t;let{source:i}=n,r=e&&i[0]!="^",s=i[i.length-1]!="$";return!r&&!s?n:new RegExp(`${r?"^":""}(?:${i})${s?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}var Kh=gt.define();function dA(n,e,t,i){let{main:r}=n.selection,s=t-r.from,o=i-r.from;return{...n.changeByRange(a=>{if(a!=r&&t!=i&&n.sliceDoc(a.from+s,a.from+o)!=n.sliceDoc(t,i))return{range:a};let l=n.toText(e);return{changes:{from:a.from+s,to:i==r.from?a.to:a.from+o,insert:l},range:R.cursor(a.from+s+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}var wv=new WeakMap;function pA(n){if(!Array.isArray(n))return n;let e=wv.get(n);return e||wv.set(n,e=ys(n)),e}var ac=U.define(),Go=U.define(),jh=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let i=At(e,t),r=un(i);this.chars.push(i);let s=e.slice(t,t+r),o=s.toUpperCase();this.folded.push(At(o==s?s.toLowerCase():o,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:i,any:r,precise:s,byWord:o}=this;if(t.length==1){let w=At(e,0),x=un(w),b=x==e.length?0:-100;if(w!=t[0])if(w==i[0])b+=-200;else return null;return this.ret(b,[0,x])}let a=e.indexOf(this.pattern);if(a==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=t.length,c=0;if(a<0){for(let w=0,x=Math.min(e.length,200);w<x&&c<l;){let b=At(e,w);(b==t[c]||b==i[c])&&(r[c++]=w),w+=un(b)}if(c<l)return null}let u=0,f=0,h=!1,d=0,p=-1,m=-1,y=/[a-z]/.test(e),g=!0;for(let w=0,x=Math.min(e.length,200),b=0;w<x&&f<l;){let C=At(e,w);a<0&&(u<l&&C==t[u]&&(s[u++]=w),d<l&&(C==t[d]||C==i[d]?(d==0&&(p=w),m=w+1,d++):d=0));let k,O=C<255?C>=48&&C<=57||C>=97&&C<=122?2:C>=65&&C<=90?1:0:(k=sf(C))!=k.toLowerCase()?1:k!=k.toUpperCase()?2:0;(!w||O==1&&y||b==0&&O!=0)&&(t[f]==C||i[f]==C&&(h=!0)?o[f++]=w:o.length&&(g=!1)),b=O,w+=un(C)}return f==l&&o[0]==0&&g?this.result(-100+(h?-200:0),o,e):d==l&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):d==l?this.ret(-900-e.length,[p,m]):f==l?this.result(-100+(h?-200:0)+-700+(g?0:-1100),o,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,i){let r=[],s=0;for(let o of t){let a=o+(this.astral?un(At(i,o)):1);s&&r[s-1]==o?r[s-1]=a:(r[s++]=o,r[s++]=a)}return this.ret(e-i.length,r)}},Vh=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),i=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return i==null?null:(this.matched=[0,t.length],this.score=i+(e.length==this.pattern.length?0:-100),this)}},De=L.define({combine(n){return ei(n,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:mA,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)=>i=>Ov(e(i),t(i)),optionClass:(e,t)=>i=>Ov(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function Ov(n,e){return n?e?n+" "+e:n:e}function mA(n,e,t,i,r,s){let o=n.textDirection==ue.RTL,a=o,l=!1,c="top",u,f,h=e.left-r.left,d=r.right-e.right,p=i.right-i.left,m=i.bottom-i.top;if(a&&h<Math.min(p,d)?a=!1:!a&&d<Math.min(p,h)&&(a=!0),p<=(a?h:d))u=Math.max(r.top,Math.min(t.top,r.bottom-m))-e.top,f=Math.min(400,a?h:d);else{l=!0,f=Math.min(400,(o?e.right:r.right-e.left)-30);let w=r.bottom-e.bottom;w>=m||w>e.top?u=t.bottom-e.top:(c="bottom",u=e.bottom-t.top)}let y=(e.bottom-e.top)/s.offsetHeight,g=(e.right-e.left)/s.offsetWidth;return{style:`${c}: ${u/y}px; max-width: ${f/g}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":a?"left":"right")}}var Gh=U.define();function gA(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,r,s){let o=document.createElement("span");o.className="cm-completionLabel";let a=t.displayLabel||t.label,l=0;for(let c=0;c<s.length;){let u=s[c++],f=s[c++];u>l&&o.appendChild(document.createTextNode(a.slice(l,u)));let h=o.appendChild(document.createElement("span"));h.appendChild(document.createTextNode(a.slice(u,f))),h.className="cm-completionMatchedText",l=f}return l<a.length&&o.appendChild(document.createTextNode(a.slice(l))),o},position:50},{render(t){if(!t.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=t.detail,i},position:80}),e.sort((t,i)=>t.position-i.position).map(t=>t.render)}function Nh(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let r=Math.floor(e/t);return{from:r*t,to:(r+1)*t}}let i=Math.ceil((n-e)/t);return{from:n-i*t,to:n-(i-1)*t}}var Qh=class{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:s,selected:o}=r.open,a=e.state.facet(De);this.optionContent=gA(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=Nh(s.length,o,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=e.state.field(t).open;for(let u=l.target,f;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(f=/-(\d+)$/.exec(u.id))&&+f[1]<c.length){this.applyCompletion(e,c[+f[1]]),l.preventDefault();return}if(l.target==this.list){let u=this.list.classList.contains("cm-completionListIncompleteTop")&&l.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&l.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;u!=null&&(e.dispatch({effects:Gh.of(u)}),l.preventDefault())}}),this.dom.addEventListener("focusout",l=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(De).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:Go.of(null)})}),this.showOptions(s,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=r){let{options:s,selected:o,disabled:a}=i.open;(!r.open||r.open.options!=s)&&(this.range=Nh(s.length,o,e.state.facet(De).maxRenderedOptions),this.showOptions(s,i.id)),this.updateSel(),a!=((t=r.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);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=Nh(t.options.length,t.selected,this.view.state.facet(De).maxRenderedOptions),this.showOptions(t.options,e.id));let i=this.updateSelectedOption(t.selected);if(i){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:s}=r;if(!s)return;let o=typeof s=="string"?document.createTextNode(s):s(r);if(!o)return;"then"in o?o.then(a=>{a&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(a,r)}).catch(a=>Pe(this.view.state,a,"completion info")):(this.addInfoPane(o,r),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:s}=e;i.appendChild(r),this.infoDestroy=s||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,r=this.range.from;i;i=i.nextSibling,r++)i.nodeName!="LI"||!i.id?r--:r==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return t&&vA(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),s=this.space;if(!s){let o=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return r.top>Math.min(s.bottom,t.bottom)-10||r.bottom<Math.max(s.top,t.top)+10?null:this.view.state.facet(De).positionInfo(this.view,t,r,i,s,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,i){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",o=>{o.target==r&&o.preventDefault()});let s=null;for(let o=i.from;o<i.to;o++){let{completion:a,match:l}=e[o],{section:c}=a;if(c){let h=typeof c=="string"?c:c.name;if(h!=s&&(o>i.from||i.from==0))if(s=h,typeof c!="string"&&c.header)r.appendChild(c.header(c));else{let d=r.appendChild(document.createElement("completion-section"));d.textContent=h}}let u=r.appendChild(document.createElement("li"));u.id=t+"-"+o,u.setAttribute("role","option");let f=this.optionClass(a);f&&(u.className=f);for(let h of this.optionContent){let d=h(a,this.view.state,this.view,l);d&&u.appendChild(d)}}return i.from&&r.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}};function yA(n,e){return t=>new Qh(t,n,e)}function vA(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),r=t.height/n.offsetHeight;i.top<t.top?n.scrollTop-=(t.top-i.top)/r:i.bottom>t.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/r)}function kv(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function xA(n,e){let t=[],i=null,r=null,s=u=>{t.push(u);let{section:f}=u.completion;if(f){i||(i=[]);let h=typeof f=="string"?f:f.name;i.some(d=>d.name==h)||i.push(typeof f=="string"?{name:h}:f)}},o=e.facet(De);for(let u of n)if(u.hasResult()){let f=u.result.getMatch;if(u.result.filter===!1)for(let h of u.result.options)s(new oc(h,u.source,f?f(h):[],1e9-t.length));else{let h=e.sliceDoc(u.from,u.to),d,p=o.filterStrict?new Vh(h):new jh(h);for(let m of u.result.options)if(d=p.match(m.label)){let y=m.displayLabel?f?f(m,d.matched):[]:d.matched,g=d.score+(m.boost||0);if(s(new oc(m,u.source,y,g)),typeof m.section=="object"&&m.section.rank==="dynamic"){let{name:w}=m.section;r||(r=Object.create(null)),r[w]=Math.max(g,r[w]||-1e9)}}}}if(i){let u=Object.create(null),f=0,h=(d,p)=>(d.rank==="dynamic"&&p.rank==="dynamic"?r[p.name]-r[d.name]:0)||(typeof d.rank=="number"?d.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(d.name<p.name?-1:1);for(let d of i.sort(h))f-=1e5,u[d.name]=f;for(let d of t){let{section:p}=d.completion;p&&(d.score+=u[typeof p=="string"?p:p.name])}}let a=[],l=null,c=o.compareCompletions;for(let u of t.sort((f,h)=>h.score-f.score||c(f.completion,h.completion))){let f=u.completion;!l||l.label!=f.label||l.detail!=f.detail||l.type!=null&&f.type!=null&&l.type!=f.type||l.apply!=f.apply||l.boost!=f.boost?a.push(u):kv(u.completion)>kv(l)&&(a[a.length-1]=u),l=u.completion}return a}var zh=class n{constructor(e,t,i,r,s,o){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=r,this.selected=s,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new n(this.options,Cv(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,r,s,o){if(r&&!o&&e.some(c=>c.isPending))return r.setDisabled();let a=xA(e,t);if(!a.length)return r&&e.some(c=>c.isPending)?r.setDisabled():null;let l=t.facet(De).selectOnOpen?0:-1;if(r&&r.selected!=l&&r.selected!=-1){let c=r.options[r.selected].completion;for(let u=0;u<a.length;u++)if(a[u].completion==c){l=u;break}}return new n(a,Cv(i,l),{pos:e.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:SA,above:s.aboveCursor},r?r.timestamp:Date.now(),l,!1)}map(e){return new n(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new n(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},Wh=class n{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new n(kA,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(De),s=(i.override||t.languageDataAt("autocomplete",Wi(t)).map(pA)).map(l=>(this.active.find(u=>u.source==l)||new $n(l,this.active.some(u=>u.state!=0)?1:0)).update(e,i));s.length==this.active.length&&s.every((l,c)=>l==this.active[c])&&(s=this.active);let o=this.open,a=e.effects.some(l=>l.is(Jh));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!bA(s,this.active)||a?o=zh.build(s,t,this.id,o,i,a):o&&o.disabled&&!s.some(l=>l.isPending)&&(o=null),!o&&s.every(l=>!l.isPending)&&s.some(l=>l.hasResult())&&(s=s.map(l=>l.hasResult()?new $n(l.source,0):l));for(let l of e.effects)l.is(Gh)&&(o=o&&o.setSelected(l.value,this.id));return s==this.active&&o==this.open?this:new n(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?wA:OA}};function bA(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t<n.length&&!n[t].hasResult();)t++;for(;i<e.length&&!e[i].hasResult();)i++;let r=t==n.length,s=i==e.length;if(r||s)return r==s;if(n[t++].result!=e[i++].result)return!1}}var wA={"aria-autocomplete":"list"},OA={};function Cv(n,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":n};return e>-1&&(t["aria-activedescendant"]=n+"-"+e),t}var kA=[];function Tv(n,e){if(n.isUserEvent("input.complete")){let i=n.annotation(Kh);if(i&&e.activateOnCompletion(i))return 12}let t=n.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:n.isUserEvent("delete.backward")?2:n.selection?8:n.docChanged?16:0}var $n=class n{constructor(e,t,i=!1){this.source=e,this.state=t,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let i=Tv(e,t),r=this;(i&8||i&16&&this.touches(e))&&(r=new n(r.source,0)),i&4&&r.state==0&&(r=new n(this.source,1)),r=r.updateFor(e,i);for(let s of e.effects)if(s.is(ac))r=new n(r.source,1,s.value);else if(s.is(Go))r=new n(r.source,0);else if(s.is(Jh))for(let o of s.value)o.source==r.source&&(r=o);return r}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Wi(e.state))}},lc=class n extends $n{constructor(e,t,i,r,s,o){super(e,3,t),this.limit=i,this.result=r,this.from=s,this.to=o}hasResult(){return!0}updateFor(e,t){var i;if(!(t&3))return this.map(e.changes);let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let s=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),a=Wi(e.state);if(a>o||!r||t&2&&(Wi(e.startState)==this.from||a<this.limit))return new $n(this.source,t&4?1:0);let l=e.changes.mapPos(this.limit);return CA(r.validFor,e.state,s,o)?new n(this.source,this.explicit,l,r,s,o):r.update&&(r=r.update(r,s,o,new sc(e.state,a,!1)))?new n(this.source,this.explicit,l,r,r.from,(i=r.to)!==null&&i!==void 0?i:Wi(e.state)):new $n(this.source,1,this.explicit)}map(e){if(e.empty)return this;let t=this.result.map?this.result.map(this.result,e):this.result;return t?new n(this.source,this.explicit,e.mapPos(this.limit),t,e.mapPos(this.from),e.mapPos(this.to,1)):new $n(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function CA(n,e,t,i){if(!n)return!1;let r=e.sliceDoc(t,i);return typeof n=="function"?n(r,t,i,e):_v(n,!0).test(r)}var Jh=U.define({map(n,e){return n.map(t=>t.map(e))}}),lt=Ne.define({create(){return Wh.start()},update(n,e){return n.update(e)},provide:n=>[jo.from(n,e=>e.tooltip),q.contentAttributes.from(n,e=>e.attrs)]});function Zh(n,e){let t=e.completion.apply||e.completion.label,i=n.state.field(lt).active.find(r=>r.source==e.source);return i instanceof lc?(typeof t=="string"?n.dispatch({...dA(n.state,t,i.from,i.to),annotations:Kh.of(e.completion)}):t(n,e.completion,i.from,i.to),!0):!1}var SA=yA(lt,Zh);function rc(n,e="option"){return t=>{let i=t.state.field(lt,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<t.state.facet(De).interactionDelay)return!1;let r=1,s;e=="page"&&(s=dh(t,i.open.tooltip))&&(r=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,a=i.open.selected>-1?i.open.selected+r*(n?1:-1):n?0:o-1;return a<0?a=e=="page"?0:o-1:a>=o&&(a=e=="page"?o-1:0),t.dispatch({effects:Gh.of(a)}),!0}}var EA=n=>{let e=n.state.field(lt,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<n.state.facet(De).interactionDelay?!1:Zh(n,e.open.options[e.open.selected])},qh=n=>n.state.field(lt,!1)?(n.dispatch({effects:ac.of(!0)}),!0):!1,AA=n=>{let e=n.state.field(lt,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:Go.of(null)}),!0)},Hh=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},_A=50,TA=1e3,MA=ze.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(lt).active)e.isPending&&this.startQuery(e)}update(n){let e=n.state.field(lt),t=n.state.facet(De);if(!n.selectionSet&&!n.docChanged&&n.startState.field(lt)==e)return;let i=n.transactions.some(s=>{let o=Tv(s,t);return o&8||(s.selection||s.docChanged)&&!(o&3)});for(let s=0;s<this.running.length;s++){let o=this.running[s];if(i||o.context.abortOnDocChange&&n.docChanged||o.updates.length+n.transactions.length>_A&&Date.now()-o.time>TA){for(let a of o.context.abortListeners)try{a()}catch(l){Pe(this.view.state,l)}o.context.abortListeners=null,this.running.splice(s--,1)}else o.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(s=>s.effects.some(o=>o.is(ac)))&&(this.pendingStart=!0);let r=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.isPending&&!this.running.some(o=>o.active.source==s.source))?setTimeout(()=>this.startUpdate(),r):-1,this.composing!=0)for(let s of n.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(lt);for(let t of e.active)t.isPending&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(De).updateSyncTime))}startQuery(n){let{state:e}=this.view,t=Wi(e),i=new sc(e,t,n.explicit,this.view),r=new Hh(n,i);this.running.push(r),Promise.resolve(n.source(i)).then(s=>{r.context.aborted||(r.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:Go.of(null)}),Pe(this.view.state,s)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(De).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(De),i=this.view.state.field(lt);for(let r=0;r<this.running.length;r++){let s=this.running[r];if(s.done===void 0)continue;if(this.running.splice(r--,1),s.done){let a=Wi(s.updates.length?s.updates[0].startState:this.view.state),l=Math.min(a,s.done.from+(s.active.explicit?0:1)),c=new lc(s.active.source,s.active.explicit,l,s.done,s.done.from,(n=s.done.to)!==null&&n!==void 0?n:a);for(let u of s.updates)c=c.update(u,t);if(c.hasResult()){e.push(c);continue}}let o=i.active.find(a=>a.source==s.active.source);if(o&&o.isPending)if(s.done==null){let a=new $n(s.active.source,0);for(let l of s.updates)a=a.update(l,t);a.isPending||e.push(a)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:Jh.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(lt,!1);if(e&&e.tooltip&&this.view.state.facet(De).closeOnBlur){let t=e.open&&dh(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Go.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:ac.of(!1)}),20),this.composing=0}}}),RA=typeof navigator=="object"&&/Win/.test(navigator.platform),PA=Rn.highest(q.domEventHandlers({keydown(n,e){let t=e.state.field(lt,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||n.key.length>1||n.ctrlKey&&!(RA&&n.altKey)||n.metaKey)return!1;let i=t.open.options[t.open.selected],r=t.active.find(o=>o.source==i.source),s=i.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(n.key)>-1&&Zh(e,i),!1}})),Mv=q.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",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:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25CB'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25CC'"}},".cm-completionIcon-variable":{"&:after":{content:"'\u{1D465}'"}},".cm-completionIcon-constant":{"&:after":{content:"'\u{1D436}'"}},".cm-completionIcon-type":{"&:after":{content:"'\u{1D461}'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222A'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25A1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\u{1F511}\uFE0E'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25A2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),Xh=class{constructor(e,t,i,r){this.field=e,this.line=t,this.from=i,this.to=r}},Uh=class n{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,Ee.TrackDel),i=e.mapPos(this.to,1,Ee.TrackDel);return t==null||i==null?null:new n(this.field,t,i)}},Yh=class n{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],r=[t],s=e.doc.lineAt(t),o=/^\s*/.exec(s.text)[0];for(let l of this.lines){if(i.length){let c=o,u=/^\t*/.exec(l)[0].length;for(let f=0;f<u;f++)c+=e.facet(ps);r.push(t+c.length-u),l=c+l.slice(u)}i.push(l),t+=l.length+1}let a=this.fieldPositions.map(l=>new Uh(l.field,r[l.line]+l.from,r[l.line]+l.to));return{text:i,ranges:a}}static parse(e){let t=[],i=[],r=[],s;for(let o of e.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o);){let a=s[1]?+s[1]:null,l=s[2]||s[3]||"",c=-1;a===0&&(a=1e9);let u=l.replace(/\\[{}]/g,f=>f[1]);for(let f=0;f<t.length;f++)(a!=null?t[f].seq==a:u&&t[f].name==u)&&(c=f);if(c<0){let f=0;for(;f<t.length&&(a==null||t[f].seq!=null&&t[f].seq<a);)f++;t.splice(f,0,{seq:a,name:u}),c=f;for(let h of r)h.field>=c&&h.field++}for(let f of r)if(f.line==i.length&&f.from>s.index){let h=s[2]?3+(s[1]||"").length:2;f.from-=h,f.to-=h}r.push(new Xh(c,i.length,s.index,s.index+u.length)),o=o.slice(0,s.index)+l+o.slice(s.index+s[0].length)}o=o.replace(/\\([{}])/g,(a,l,c)=>{for(let u of r)u.line==i.length&&u.from>c&&(u.from--,u.to--);return l}),i.push(o)}return new n(i,r)}},DA=X.widget({widget:new class extends Dt{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),BA=X.mark({class:"cm-snippetField"}),gs=class n{constructor(e,t){this.ranges=e,this.active=t,this.deco=X.set(e.map(i=>(i.from==i.to?DA:BA).range(i.from,i.to)),!0)}map(e){let t=[];for(let i of this.ranges){let r=i.map(e);if(!r)return null;t.push(r)}return new n(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}},Zo=U.define({map(n,e){return n&&n.map(e)}}),IA=U.define(),Jo=Ne.define({create(){return null},update(n,e){for(let t of e.effects){if(t.is(Zo))return t.value;if(t.is(IA)&&n)return new gs(n.ranges,t.value)}return n&&e.docChanged&&(n=n.map(e.changes)),n&&e.selection&&!n.selectionInsideField(e.selection)&&(n=null),n},provide:n=>q.decorations.from(n,e=>e?e.deco:X.none)});function ed(n,e){return R.create(n.filter(t=>t.field==e).map(t=>R.range(t.from,t.to)))}function $A(n){let e=Yh.parse(n);return(t,i,r,s)=>{let{text:o,ranges:a}=e.instantiate(t.state,r),{main:l}=t.state.selection,c={changes:{from:r,to:s==l.from?l.to:s,insert:J.of(o)},scrollIntoView:!0,annotations:i?[Kh.of(i),Le.userEvent.of("input.complete")]:void 0};if(a.length&&(c.selection=ed(a,0)),a.some(u=>u.field>0)){let u=new gs(a,0),f=c.effects=[Zo.of(u)];t.state.field(Jo,!1)===void 0&&f.push(U.appendConfig.of([Jo,jA,VA,Mv]))}t.dispatch(t.state.update(c))}}function Rv(n){return({state:e,dispatch:t})=>{let i=e.field(Jo,!1);if(!i||n<0&&i.active==0)return!1;let r=i.active+n,s=n>0&&!i.ranges.some(o=>o.field==r+n);return t(e.update({selection:ed(i.ranges,r),effects:Zo.of(s?null:new gs(i.ranges,r)),scrollIntoView:!0})),!0}}var LA=({state:n,dispatch:e})=>n.field(Jo,!1)?(e(n.update({effects:Zo.of(null)})),!0):!1,NA=Rv(1),qA=Rv(-1);var FA=[{key:"Tab",run:NA,shift:qA},{key:"Escape",run:LA}],Sv=L.define({combine(n){return n.length?n[0]:FA}}),jA=Rn.highest(cs.compute([Sv],n=>n.facet(Sv)));function Bt(n,e){return{...e,apply:$A(n)}}var VA=q.domEventHandlers({mousedown(n,e){let t=e.state.field(Jo,!1),i;if(!t||(i=e.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let r=t.ranges.find(s=>s.from<=i&&s.to>=i);return!r||r.field==t.active?!1:(e.dispatch({selection:ed(t.ranges,r.field),effects:Zo.of(t.ranges.some(s=>s.field>r.field)?new gs(t.ranges,r.field):null),scrollIntoView:!0}),!0)}});var cc={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},zi=U.define({map(n,e){let t=e.mapPos(n,-1,Ee.TrackAfter);return t==null?void 0:t}}),td=new class extends Et{};td.startSide=1;td.endSide=-1;var Pv=Ne.define({create(){return re.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(zi)&&(n=n.update({add:[td.range(t.value,t.value+1)]}));return n}});function Dv(){return[HA,Pv]}var Fh="()[]{}<>\xAB\xBB\xBB\xAB\uFF3B\uFF3D\uFF5B\uFF5D";function QA(n){for(let e=0;e<Fh.length;e+=2)if(Fh.charCodeAt(e)==n)return Fh.charAt(e+1);return sf(n<128?n:n+1)}function zA(n,e){return n.languageDataAt("closeBrackets",e)[0]||cc}var WA=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),HA=q.inputHandler.of((n,e,t,i)=>{if((WA?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let r=n.state.selection.main;if(i.length>2||i.length==2&&un(At(i,0))==1||e!=r.from||t!=r.to)return!1;let s=XA(n.state,i);return s?(n.dispatch(s),!0):!1});function XA(n,e){let t=zA(n,n.selection.main.head),i=t.brackets||cc.brackets;for(let r of i){let s=QA(At(r,0));if(e==r)return s==r?KA(n,r,i.indexOf(r+r+r)>-1,t):UA(n,r,s,t.before||cc.before);if(e==s&&Bv(n,n.selection.main.from))return YA(n,r,s)}return null}function Bv(n,e){let t=!1;return n.field(Pv).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function nd(n,e){let t=n.sliceString(e,e+2);return t.slice(0,un(At(t,0)))}function UA(n,e,t,i){let r=null,s=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:zi.of(o.to+e.length),range:R.range(o.anchor+e.length,o.head+e.length)};let a=nd(n.doc,o.head);return!a||/\s/.test(a)||i.indexOf(a)>-1?{changes:{insert:e+t,from:o.head},effects:zi.of(o.head+e.length),range:R.cursor(o.head+e.length)}:{range:r=o}});return r?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function YA(n,e,t){let i=null,r=n.changeByRange(s=>s.empty&&nd(n.doc,s.head)==t?{changes:{from:s.head,to:s.head+t.length,insert:t},range:R.cursor(s.head+t.length)}:i={range:s});return i?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function KA(n,e,t,i){let r=i.stringPrefixes||cc.stringPrefixes,s=null,o=n.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:zi.of(a.to+e.length),range:R.range(a.anchor+e.length,a.head+e.length)};let l=a.head,c=nd(n.doc,l),u;if(c==e){if(Ev(n,l))return{changes:{insert:e+e,from:l},effects:zi.of(l+e.length),range:R.cursor(l+e.length)};if(Bv(n,l)){let h=t&&n.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+h.length,insert:h},range:R.cursor(l+h.length)}}}else{if(t&&n.sliceDoc(l-2*e.length,l)==e+e&&(u=Av(n,l-2*e.length,r))>-1&&Ev(n,u))return{changes:{insert:e+e+e+e,from:l},effects:zi.of(l+e.length),range:R.cursor(l+e.length)};if(n.charCategorizer(l)(c)!=Ge.Word&&Av(n,l,r)>-1&&!GA(n,l,e,r))return{changes:{insert:e+e,from:l},effects:zi.of(l+e.length),range:R.cursor(l+e.length)}}return{range:s=a}});return s?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Ev(n,e){let t=ge(n).resolveInner(e+1);return t.parent&&t.from==e}function GA(n,e,t,i){let r=ge(n).resolveInner(e,-1),s=i.reduce((o,a)=>Math.max(o,a.length),0);for(let o=0;o<5;o++){let a=n.sliceDoc(r.from,Math.min(r.to,r.from+t.length+s)),l=a.indexOf(t);if(!l||l>-1&&i.indexOf(a.slice(0,l))>-1){let u=r.firstChild;for(;u&&u.from==r.from&&u.to-u.from>t.length+l;){if(n.sliceDoc(u.to-t.length,u.to)==t)return!1;u=u.firstChild}return!0}let c=r.to==e&&r.parent;if(!c)break;r=c}return!1}function Av(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=Ge.Word)return e;for(let r of t){let s=e-r.length;if(n.sliceDoc(s,e)==r&&i(n.sliceDoc(s-1,s))!=Ge.Word)return s}return-1}function Iv(n={}){return[PA,lt,De.of(n),MA,ZA,Mv]}var JA=[{key:"Ctrl-Space",run:qh},{mac:"Alt-`",run:qh},{mac:"Alt-i",run:qh},{key:"Escape",run:AA},{key:"ArrowDown",run:rc(!0)},{key:"ArrowUp",run:rc(!1)},{key:"PageDown",run:rc(!0,"page")},{key:"PageUp",run:rc(!1,"page")},{key:"Enter",run:EA}],ZA=Rn.highest(cs.computeN([De],n=>n.facet(De).defaultKeymap?[JA]:[]));var e2=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=ld(n.state,t.from);return i.line?t2(n):i.block?i2(n):!1};function ad(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let r=n(e,t);return r?(i(t.update(r)),!0):!1}}var t2=ad(o2,0);var n2=ad(Wv,0);var i2=ad((n,e)=>Wv(n,e,s2(e)),0);function ld(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}var ea=50;function r2(n,{open:e,close:t},i,r){let s=n.sliceDoc(i-ea,i),o=n.sliceDoc(r,r+ea),a=/\s*$/.exec(s)[0].length,l=/^\s*/.exec(o)[0].length,c=s.length-a;if(s.slice(c-e.length,c)==e&&o.slice(l,l+t.length)==t)return{open:{pos:i-a,margin:a&&1},close:{pos:r+l,margin:l&&1}};let u,f;r-i<=2*ea?u=f=n.sliceDoc(i,r):(u=n.sliceDoc(i,i+ea),f=n.sliceDoc(r-ea,r));let h=/^\s*/.exec(u)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-t.length;return u.slice(h,h+e.length)==e&&f.slice(p,p+t.length)==t?{open:{pos:i+h+e.length,margin:/\s/.test(u.charAt(h+e.length))?1:0},close:{pos:r-d-t.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function s2(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),r=t.to<=i.to?i:n.doc.lineAt(t.to);r.from>i.from&&r.from==t.to&&(r=t.to==i.to+1?i:n.doc.lineAt(t.to-1));let s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function Wv(n,e,t=e.selection.ranges){let i=t.map(s=>ld(e,s.from).block);if(!i.every(s=>s))return null;let r=t.map((s,o)=>r2(e,i[o],s.from,s.to));if(n!=2&&!r.every(s=>s))return{changes:e.changes(t.map((s,o)=>r[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(n!=1&&r.some(s=>s)){let s=[];for(let o=0,a;o<r.length;o++)if(a=r[o]){let l=i[o],{open:c,close:u}=a;s.push({from:c.pos-l.open.length,to:c.pos+c.margin},{from:u.pos-u.margin,to:u.pos+l.close.length})}return{changes:s}}return null}function o2(n,e,t=e.selection.ranges){let i=[],r=-1;e:for(let{from:s,to:o}of t){let a=i.length,l=1e9,c;for(let u=s;u<=o;){let f=e.doc.lineAt(u);if(c==null&&(c=ld(e,f.from).line,!c))continue e;if(f.from>r&&(s==o||o>f.from)){r=f.from;let h=/^\s*/.exec(f.text)[0].length,d=h==f.length,p=f.text.slice(h,h+c.length)==c?h:-1;h<f.text.length&&h<l&&(l=h),i.push({line:f,comment:p,token:c,indent:h,empty:d,single:!1})}u=f.to+1}if(l<1e9)for(let u=a;u<i.length;u++)i[u].indent<i[u].line.text.length&&(i[u].indent=l);i.length==a+1&&(i[a].single=!0)}if(n!=2&&i.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:a,token:l,indent:c,empty:u,single:f}of i)(f||!u)&&s.push({from:a.from+c,insert:l+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:a,token:l}of i)if(a>=0){let c=o.from+a,u=c+l.length;o.text[u-o.from]==" "&&u++,s.push({from:c,to:u})}return{changes:s}}return null}var $v=gt.define();var a2=L.define();var Hi=class n{constructor(e,t,i,r,s){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new n(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new n(e.changes&&Je.fromJSON(e.changes),[],e.mapped&&Tn.fromJSON(e.mapped),e.startSelection&&R.fromJSON(e.startSelection),e.selectionsAfter.map(R.fromJSON))}static fromTransaction(e,t){let i=It;for(let r of e.startState.facet(a2)){let s=r(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new n(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,It)}static selection(e){return new n(void 0,It,void 0,void 0,e)}};function rd(n,e,t,i){let r=e+1>t+20?e-t-1:0,s=n.slice(r,e);return s.push(i),s}function l2(n,e){let t=[],i=!1;return n.iterChangedRanges((r,s)=>t.push(r,s)),e.iterChangedRanges((r,s,o,a)=>{for(let l=0;l<t.length;){let c=t[l++],u=t[l++];a>=c&&o<=u&&(i=!0)}}),i}function c2(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function Hv(n,e){return n.length?e.length?n.concat(e):n:e}var It=[],u2=200;function f2(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-u2));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),rd(n,n.length-1,1e9,t.setSelAfter(i)))}else return[Hi.selection([e])]}function h2(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function id(n,e){if(!n.length)return n;let t=n.length,i=It;for(;t;){let r=d2(n[t-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let s=n.slice(0,t);return s[t-1]=r,s}else e=r.mapped,t--,i=r.selectionsAfter}return i.length?[Hi.selection(i)]:It}function d2(n,e,t){let i=Hv(n.selectionsAfter.length?n.selectionsAfter.map(a=>a.map(e)):It,t);if(!n.changes)return Hi.selection(i);let r=n.changes.map(e),s=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(s):s;return new Hi(r,U.mapEffects(n.effects,e),o,n.startSelection.map(s),i)}var p2=/^(input\.type|delete)($|\.)/,fc=class n{constructor(e,t,i=0,r=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new n(this.done,this.undone):this}addChanges(e,t,i,r,s){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!i||p2.test(i))&&(!a.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,l2(a.changes,e.changes))||i=="input.type.compose")?o=rd(o,o.length-1,r.minDepth,new Hi(e.changes.compose(a.changes),Hv(U.mapEffects(e.effects,a.changes),a.effects),a.mapped,a.startSelection,It)):o=rd(o,o.length,r.minDepth,e),new n(o,It,t,i)}addSelection(e,t,i,r){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:It;return s.length>0&&t-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&c2(s[s.length-1],e)?this:new n(f2(this.done,e),this.undone,t,i)}addMapping(e){return new n(id(this.done,e),id(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let r=e==0?this.done:this.undone;if(r.length==0)return null;let s=r[r.length-1],o=s.selectionsAfter[0]||(s.startSelection?s.startSelection.map(s.changes.invertedDesc,1):t.selection);if(i&&s.selectionsAfter.length)return t.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:$v.of({side:e,rest:h2(r),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let a=r.length==1?It:r.slice(0,r.length-1);return s.mapped&&(a=id(a,s.mapped)),t.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:$v.of({side:e,rest:a,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};fc.empty=new fc(It,It);function vs(n,e){return R.create(n.ranges.map(e),n.mainIndex)}function Kt(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Gt({state:n,dispatch:e},t){let i=vs(n.selection,t);return i.eq(n.selection,!0)?!1:(e(Kt(n,i)),!0)}function hc(n,e){return R.cursor(e?n.to:n.from)}function Xv(n,e){return Gt(n,t=>t.empty?n.moveByChar(t,e):hc(t,e))}function He(n){return n.textDirectionAt(n.state.selection.main.head)==ue.LTR}var Uv=n=>Xv(n,!He(n)),Yv=n=>Xv(n,He(n));function Kv(n,e){return Gt(n,t=>t.empty?n.moveByGroup(t,e):hc(t,e))}var m2=n=>Kv(n,!He(n)),g2=n=>Kv(n,He(n));var U3=typeof Intl!="undefined"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function y2(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function dc(n,e,t){let i=ge(n).resolveInner(e.head),r=t?H.closedBy:H.openedBy;for(let l=e.head;;){let c=t?i.childAfter(l):i.childBefore(l);if(!c)break;y2(n,c,r)?i=c:l=t?c.to:c.from}let s=i.type.prop(r),o,a;return s&&(o=t?Yt(n,i.from,1):Yt(n,i.to,-1))&&o.matched?a=t?o.end.to:o.end.from:a=t?i.to:i.from,R.cursor(a,t?-1:1)}var v2=n=>Gt(n,e=>dc(n.state,e,!He(n))),x2=n=>Gt(n,e=>dc(n.state,e,He(n)));function Gv(n,e){return Gt(n,t=>{if(!t.empty)return hc(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}var Jv=n=>Gv(n,!1),Zv=n=>Gv(n,!0);function ex(n){let e=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,t=0,i=0,r;if(e){for(let s of n.state.facet(q.scrollMargins)){let o=s(n);o!=null&&o.top&&(t=Math.max(o==null?void 0:o.top,t)),o!=null&&o.bottom&&(i=Math.max(o==null?void 0:o.bottom,i))}r=n.scrollDOM.clientHeight-t-i}else r=(n.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(n.defaultLineHeight,r-5)}}function tx(n,e){let t=ex(n),{state:i}=n,r=vs(i.selection,o=>o.empty?n.moveVertically(o,e,t.height):hc(o,e));if(r.eq(i.selection))return!1;let s;if(t.selfScroll){let o=n.coordsAtPos(i.selection.main.head),a=n.scrollDOM.getBoundingClientRect(),l=a.top+t.marginTop,c=a.bottom-t.marginBottom;o&&o.top>l&&o.bottom<c&&(s=q.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-l}))}return n.dispatch(Kt(i,r),{effects:s}),!0}var Lv=n=>tx(n,!1),sd=n=>tx(n,!0);function li(n,e,t){let i=n.lineBlockAt(e.head),r=n.moveToLineBoundary(e,t);if(r.head==e.head&&r.head!=(t?i.to:i.from)&&(r=n.moveToLineBoundary(e,t,!1)),!t&&r.head==i.from&&i.length){let s=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&e.head!=i.from+s&&(r=R.cursor(i.from+s))}return r}var b2=n=>Gt(n,e=>li(n,e,!0)),w2=n=>Gt(n,e=>li(n,e,!1)),O2=n=>Gt(n,e=>li(n,e,!He(n))),k2=n=>Gt(n,e=>li(n,e,He(n))),C2=n=>Gt(n,e=>R.cursor(n.lineBlockAt(e.head).from,1)),S2=n=>Gt(n,e=>R.cursor(n.lineBlockAt(e.head).to,-1));function E2(n,e,t){let i=!1,r=vs(n.selection,s=>{let o=Yt(n,s.head,-1)||Yt(n,s.head,1)||s.head>0&&Yt(n,s.head-1,1)||s.head<n.doc.length&&Yt(n,s.head+1,-1);if(!o||!o.end)return s;i=!0;let a=o.start.from==s.head?o.end.to:o.end.from;return t?R.range(s.anchor,a):R.cursor(a)});return i?(e(Kt(n,r)),!0):!1}var A2=({state:n,dispatch:e})=>E2(n,e,!1);function $t(n,e){let t=vs(n.state.selection,i=>{let r=e(i);return R.range(i.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return t.eq(n.state.selection)?!1:(n.dispatch(Kt(n.state,t)),!0)}function nx(n,e){return $t(n,t=>n.moveByChar(t,e))}var ix=n=>nx(n,!He(n)),rx=n=>nx(n,He(n));function sx(n,e){return $t(n,t=>n.moveByGroup(t,e))}var _2=n=>sx(n,!He(n)),T2=n=>sx(n,He(n));var M2=n=>$t(n,e=>dc(n.state,e,!He(n))),R2=n=>$t(n,e=>dc(n.state,e,He(n)));function ox(n,e){return $t(n,t=>n.moveVertically(t,e))}var ax=n=>ox(n,!1),lx=n=>ox(n,!0);function cx(n,e){return $t(n,t=>n.moveVertically(t,e,ex(n).height))}var Nv=n=>cx(n,!1),qv=n=>cx(n,!0),P2=n=>$t(n,e=>li(n,e,!0)),D2=n=>$t(n,e=>li(n,e,!1)),B2=n=>$t(n,e=>li(n,e,!He(n))),I2=n=>$t(n,e=>li(n,e,He(n))),$2=n=>$t(n,e=>R.cursor(n.lineBlockAt(e.head).from)),L2=n=>$t(n,e=>R.cursor(n.lineBlockAt(e.head).to)),Fv=({state:n,dispatch:e})=>(e(Kt(n,{anchor:0})),!0),jv=({state:n,dispatch:e})=>(e(Kt(n,{anchor:n.doc.length})),!0),Vv=({state:n,dispatch:e})=>(e(Kt(n,{anchor:n.selection.main.anchor,head:0})),!0),Qv=({state:n,dispatch:e})=>(e(Kt(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),N2=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),q2=({state:n,dispatch:e})=>{let t=pc(n).map(({from:i,to:r})=>R.range(i,Math.min(r+1,n.doc.length)));return e(n.update({selection:R.create(t),userEvent:"select"})),!0},F2=({state:n,dispatch:e})=>{let t=vs(n.selection,i=>{let r=ge(n),s=r.resolveStack(i.from,1);if(i.empty){let o=r.resolveStack(i.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:a}=o;if((a.from<i.from&&a.to>=i.to||a.to>i.to&&a.from<=i.from)&&o.next)return R.range(a.to,a.from)}return i});return t.eq(n.selection)?!1:(e(Kt(n,t)),!0)};function ux(n,e){let{state:t}=n,i=t.selection,r=t.selection.ranges.slice();for(let s of t.selection.ranges){let o=t.doc.lineAt(s.head);if(e?o.to<n.state.doc.length:o.from>0)for(let a=s;;){let l=n.moveVertically(a,e);if(l.head<o.from||l.head>o.to){r.some(c=>c.head==l.head)||r.push(l);break}else{if(l.head==a.head)break;a=l}}}return r.length==i.ranges.length?!1:(n.dispatch(Kt(t,R.create(r,r.length-1))),!0)}var j2=n=>ux(n,!1),V2=n=>ux(n,!0),Q2=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=R.create([t.main]):t.main.empty||(i=R.create([R.cursor(t.main.head)])),i?(e(Kt(n,i)),!0):!1};function ta(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,r=i.changeByRange(s=>{let{from:o,to:a}=s;if(o==a){let l=e(s);l<o?(t="delete.backward",l=uc(n,l,!1)):l>o&&(t="delete.forward",l=uc(n,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=uc(n,o,!1),a=uc(n,a,!0);return o==a?{range:s}:{changes:{from:o,to:a},range:R.cursor(o,o<s.head?-1:1)}});return r.changes.empty?!1:(n.dispatch(i.update(r,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?q.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function uc(n,e,t){if(n instanceof q)for(let i of n.state.facet(q.atomicRanges).map(r=>r(n)))i.between(e,e,(r,s)=>{r<e&&s>e&&(e=t?s:r)});return e}var fx=(n,e,t)=>ta(n,i=>{let r=i.from,{state:s}=n,o=s.doc.lineAt(r),a,l;if(t&&!e&&r>o.from&&r<o.from+200&&!/[^ \t]/.test(a=o.text.slice(0,r-o.from))){if(a[a.length-1]==" ")return r-1;let c=Di(a,s.tabSize),u=c%Ko(s)||Ko(s);for(let f=0;f<u&&a[a.length-1-f]==" ";f++)r--;l=r}else l=Re(o.text,r-o.from,e,e)+o.from,l==r&&o.number!=(e?s.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(l-o.from,r-o.from))&&(l=Re(o.text,l-o.from,!1,!1)+o.from);return l}),od=n=>fx(n,!1,!0);var hx=n=>fx(n,!0,!1),dx=(n,e)=>ta(n,t=>{let i=t.head,{state:r}=n,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let a=null;;){if(i==(e?s.to:s.from)){i==t.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let l=Re(s.text,i-s.from,e)+s.from,c=s.text.slice(Math.min(i,l)-s.from,Math.max(i,l)-s.from),u=o(c);if(a!=null&&u!=a)break;(c!=" "||i!=t.head)&&(a=u),i=l}return i}),px=n=>dx(n,!1),z2=n=>dx(n,!0);var W2=n=>ta(n,e=>{let t=n.lineBlockAt(e.head).to;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var H2=n=>ta(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),X2=n=>ta(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var U2=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:J.of(["",""])},range:R.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},Y2=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let r=i.from,s=n.doc.lineAt(r),o=r==s.from?r-1:Re(s.text,r-s.from,!1)+s.from,a=r==s.to?r+1:Re(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:a,insert:n.doc.slice(r,a).append(n.doc.slice(o,r))},range:R.cursor(a)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function pc(n){let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.from),s=n.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=n.doc.lineAt(i.to-1)),t>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});t=s.number+1}return e}function mx(n,e,t){if(n.readOnly)return!1;let i=[],r=[];for(let s of pc(n)){if(t?s.to==n.doc.length:s.from==0)continue;let o=n.doc.lineAt(t?s.to+1:s.from-1),a=o.length+1;if(t){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+n.lineBreak});for(let l of s.ranges)r.push(R.range(Math.min(n.doc.length,l.anchor+a),Math.min(n.doc.length,l.head+a)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:n.lineBreak+o.text});for(let l of s.ranges)r.push(R.range(l.anchor-a,l.head-a))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:R.create(r,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}var K2=({state:n,dispatch:e})=>mx(n,e,!1),G2=({state:n,dispatch:e})=>mx(n,e,!0);function gx(n,e,t){if(n.readOnly)return!1;let i=[];for(let s of pc(n))t?i.push({from:s.from,insert:n.doc.slice(s.from,s.to)+n.lineBreak}):i.push({from:s.to,insert:n.lineBreak+n.doc.slice(s.from,s.to)});let r=n.changes(i);return e(n.update({changes:r,selection:n.selection.map(r,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var J2=({state:n,dispatch:e})=>gx(n,e,!1),Z2=({state:n,dispatch:e})=>gx(n,e,!0),e_=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(pc(e).map(({from:r,to:s})=>(r>0?r--:s<e.doc.length&&s++,{from:r,to:s}))),i=vs(e.selection,r=>{let s;if(n.lineWrapping){let o=n.lineBlockAt(r.head),a=n.coordsAtPos(r.head,r.assoc||1);a&&(s=o.bottom+n.documentTop-a.bottom+n.defaultLineHeight/2)}return n.moveVertically(r,!0,s)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function t_(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=ge(n).resolveInner(e),i=t.childBefore(e),r=t.childAfter(e),s;return i&&r&&i.to<=e&&r.from>=e&&(s=i.type.prop(H.closedBy))&&s.indexOf(r.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(r.from).from&&!/\S/.test(n.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}var zv=yx(!1),n_=yx(!0);function yx(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:s,to:o}=r,a=e.doc.lineAt(s),l=!n&&s==o&&t_(e,s);n&&(s=o=(o<=a.to?a:e.doc.lineAt(o)).to);let c=new Qi(e,{simulateBreak:s,simulateDoubleBreak:!!l}),u=tc(c,s);for(u==null&&(u=Di(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<a.to&&/\s/.test(a.text[o-a.from]);)o++;l?{from:s,to:o}=l:s>a.from&&s<a.from+100&&!/\S/.test(a.text.slice(0,s))&&(s=a.from);let f=["",ms(e,u)];return l&&f.push(ms(e,c.lineIndent(a.from,-1))),{changes:{from:s,to:o,insert:J.of(f)},range:R.cursor(s+1+f[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function cd(n,e){let t=-1;return n.changeByRange(i=>{let r=[];for(let o=i.from;o<=i.to;){let a=n.doc.lineAt(o);a.number>t&&(i.empty||i.to>a.from)&&(e(a,r,i),t=a.number),o=a.to+1}let s=n.changes(r);return{changes:r,range:R.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}var i_=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new Qi(n,{overrideIndentation:s=>{let o=t[s];return o==null?-1:o}}),r=cd(n,(s,o,a)=>{let l=tc(i,s.from);if(l==null)return;/\S/.test(s.text)||(l=0);let c=/^\s*/.exec(s.text)[0],u=ms(n,l);(c!=u||a.from<s.from+c.length)&&(t[s.from]=l,o.push({from:s.from,to:s.from+c.length,insert:u}))});return r.changes.empty||e(n.update(r,{userEvent:"indent"})),!0},r_=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(cd(n,(t,i)=>{i.push({from:t.from,insert:n.facet(ps)})}),{userEvent:"input.indent"})),!0),s_=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(cd(n,(t,i)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let s=Di(r,n.tabSize),o=0,a=ms(n,Math.max(0,s-Ko(n)));for(;o<r.length&&o<a.length&&r.charCodeAt(o)==a.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+r.length,insert:a.slice(o)})}),{userEvent:"delete.dedent"})),!0),o_=n=>(n.setTabFocusMode(),!0);var a_=[{key:"Ctrl-b",run:Uv,shift:ix,preventDefault:!0},{key:"Ctrl-f",run:Yv,shift:rx},{key:"Ctrl-p",run:Jv,shift:ax},{key:"Ctrl-n",run:Zv,shift:lx},{key:"Ctrl-a",run:C2,shift:$2},{key:"Ctrl-e",run:S2,shift:L2},{key:"Ctrl-d",run:hx},{key:"Ctrl-h",run:od},{key:"Ctrl-k",run:W2},{key:"Ctrl-Alt-h",run:px},{key:"Ctrl-o",run:U2},{key:"Ctrl-t",run:Y2},{key:"Ctrl-v",run:sd}],l_=[{key:"ArrowLeft",run:Uv,shift:ix,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:m2,shift:_2,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:O2,shift:B2,preventDefault:!0},{key:"ArrowRight",run:Yv,shift:rx,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:g2,shift:T2,preventDefault:!0},{mac:"Cmd-ArrowRight",run:k2,shift:I2,preventDefault:!0},{key:"ArrowUp",run:Jv,shift:ax,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Fv,shift:Vv},{mac:"Ctrl-ArrowUp",run:Lv,shift:Nv},{key:"ArrowDown",run:Zv,shift:lx,preventDefault:!0},{mac:"Cmd-ArrowDown",run:jv,shift:Qv},{mac:"Ctrl-ArrowDown",run:sd,shift:qv},{key:"PageUp",run:Lv,shift:Nv},{key:"PageDown",run:sd,shift:qv},{key:"Home",run:w2,shift:D2,preventDefault:!0},{key:"Mod-Home",run:Fv,shift:Vv},{key:"End",run:b2,shift:P2,preventDefault:!0},{key:"Mod-End",run:jv,shift:Qv},{key:"Enter",run:zv,shift:zv},{key:"Mod-a",run:N2},{key:"Backspace",run:od,shift:od,preventDefault:!0},{key:"Delete",run:hx,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:px,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:z2,preventDefault:!0},{mac:"Mod-Backspace",run:H2,preventDefault:!0},{mac:"Mod-Delete",run:X2,preventDefault:!0}].concat(a_.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),vx=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:v2,shift:M2},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:x2,shift:R2},{key:"Alt-ArrowUp",run:K2},{key:"Shift-Alt-ArrowUp",run:J2},{key:"Alt-ArrowDown",run:G2},{key:"Shift-Alt-ArrowDown",run:Z2},{key:"Mod-Alt-ArrowUp",run:j2},{key:"Mod-Alt-ArrowDown",run:V2},{key:"Escape",run:Q2},{key:"Mod-Enter",run:n_},{key:"Alt-l",mac:"Ctrl-l",run:q2},{key:"Mod-i",run:F2,preventDefault:!0},{key:"Mod-[",run:s_},{key:"Mod-]",run:r_},{key:"Mod-Alt-\\",run:i_},{key:"Shift-Mod-k",run:e_},{key:"Shift-Mod-\\",run:A2},{key:"Mod-/",run:e2},{key:"Alt-A",run:n2},{key:"Ctrl-m",mac:"Shift-Alt-m",run:o_}].concat(l_);var gc=class{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}},Xi=class n{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let r=i.facet(vn).markerFilter;r&&(e=r(e,i));let s=e.slice().sort((d,p)=>d.from-p.from||d.to-p.to),o=new Mn,a=[],l=0,c=i.doc.iter(),u=0,f=i.doc.length;for(let d=0;;){let p=d==s.length?null:s[d];if(!p&&!a.length)break;let m,y;if(a.length)m=l,y=a.reduce((x,b)=>Math.min(x,b.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>f)break;y=p.to,a.push(p),d++}for(;d<s.length;){let x=s[d];if(x.from==m&&(x.to>x.from||x.to==m))a.push(x),d++,y=Math.min(x.to,y);else{y=Math.min(x.from,y);break}}y=Math.min(y,f);let g=!1;if(a.some(x=>x.from==m&&(x.to==y||y==f))&&(g=m==y,!g&&y-m<10)){let x=m-(u+c.value.length);x>0&&(c.next(x),u=m);for(let b=m;;){if(b>=y){g=!0;break}if(!c.lineBreak&&u+c.value.length>b)break;b=u+c.value.length,u+=c.value.length,c.next()}}let w=b_(a);if(g)o.add(m,m,X.widget({widget:new ud(w),diagnostics:a.slice()}));else{let x=a.reduce((b,C)=>C.markClass?b+" "+C.markClass:b,"");o.add(m,y,X.mark({class:"cm-lintRange cm-lintRange-"+w+x,diagnostics:a.slice(),inclusiveEnd:a.some(b=>b.to>y)}))}if(l=y,l==f)break;for(let x=0;x<a.length;x++)a[x].to<=l&&a.splice(x--,1)}let h=o.finish();return new n(h,t,xs(h))}};function xs(n,e=null,t=0){let i=null;return n.between(t,1e9,(r,s,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!i)i=new gc(r,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new gc(i.from,s,i.diagnostic)}}),i}function c_(n,e){let t=e.pos,i=e.end||t,r=n.state.facet(vn).hideOn(n,t,i);if(r!=null)return r;let s=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(o=>o.is(na))||n.changes.touchesRange(s.from,Math.max(s.to,i)))}function u_(n,e){return n.field(Jt,!1)?e:e.concat(U.appendConfig.of(Ex))}function f_(n,e){return{effects:u_(n,[na.of(e)])}}var na=U.define(),wx=U.define(),Ox=U.define(),Jt=Ne.define({create(){return new Xi(X.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),i=null,r=n.panel;if(n.selected){let s=e.changes.mapPos(n.selected.from,1);i=xs(t,n.selected.diagnostic,s)||xs(t,null,s)}!t.size&&r&&e.state.facet(vn).autoPanel&&(r=null),n=new Xi(t,r,i)}for(let t of e.effects)if(t.is(na)){let i=e.state.facet(vn).autoPanel?t.value.length?vc.open:null:n.panel;n=Xi.init(t.value,i,e.state)}else t.is(wx)?n=new Xi(n.diagnostics,t.value?vc.open:null,n.selected):t.is(Ox)&&(n=new Xi(n.diagnostics,n.panel,t.value));return n},provide:n=>[jl.from(n,e=>e.panel),q.decorations.from(n,e=>e.diagnostics)]});var h_=X.mark({class:"cm-lintRange cm-lintRange-active"});function d_(n,e,t){let{diagnostics:i}=n.state.field(Jt),r,s=-1,o=-1;i.between(e-(t<0?1:0),e+(t>0?1:0),(l,c,{spec:u})=>{if(e>=l&&e<=c&&(l==c||(e>l||t>0)&&(e<c||t<0)))return r=u.diagnostics,s=l,o=c,!1});let a=n.state.facet(vn).tooltipFilter;return r&&a&&(r=a(r,n.state)),r?{pos:s,end:o,above:!0,create(){return{dom:p_(n,r)}}}:null}function p_(n,e){return yt("ul",{class:"cm-tooltip-lint"},e.map(t=>Sx(n,t,!1)))}var xx=n=>{let e=n.state.field(Jt,!1);return!e||!e.panel?!1:(n.dispatch({effects:wx.of(!1)}),!0)};var m_=ze.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(vn);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let n=Date.now();if(n<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-n);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(vn);t.length&&g_(t.map(i=>Promise.resolve(i(this.view))),i=>{this.view.state.doc==e.doc&&this.view.dispatch(f_(this.view.state,i.reduce((r,s)=>r.concat(s))))},i=>{Pe(this.view.state,i)})}}update(n){let e=n.state.facet(vn);(n.docChanged||e!=n.startState.facet(vn)||e.needsRefresh&&e.needsRefresh(n))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function g_(n,e,t){let i=[],r=-1;for(let s of n)s.then(o=>{i.push(o),clearTimeout(r),i.length==n.length?e(i):r=setTimeout(()=>e(i),200)},t)}var vn=L.define({combine(n){return{sources:n.map(e=>e.source).filter(e=>e!=null),...ei(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:bx,tooltipFilter:bx,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,r,s)=>e(i,r,s)||t(i,r,s):e:t,autoPanel:(e,t)=>e||t})}}});function bx(n,e){return n?e?(t,i)=>e(n(t,i),i):n:e}function kx(n,e={}){return[vn.of({source:n,config:e}),m_,Ex]}function Cx(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;i<t.length;i++){let r=t[i];if(/[a-zA-Z]/.test(r)&&!e.some(s=>s.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function Sx(n,e,t){var i;let r=t?Cx(e.actions):[];return yt("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},yt("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((s,o)=>{let a=!1,l=d=>{if(d.preventDefault(),a)return;a=!0;let p=xs(n.state.field(Jt).diagnostics,e);p&&s.apply(n,p.from,p.to)},{name:c}=s,u=r[o]?c.indexOf(r[o]):-1,f=u<0?c:[c.slice(0,u),yt("u",c.slice(u,u+1)),c.slice(u+1)],h=s.markClass?" "+s.markClass:"";return yt("button",{type:"button",class:"cm-diagnosticAction"+h,onclick:l,onmousedown:l,"aria-label":` Action: ${c}${u<0?"":` (access key "${r[o]})"`}.`},f)}),e.source&&yt("div",{class:"cm-diagnosticSource"},e.source))}var ud=class extends Dt{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return yt("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}},yc=class{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Sx(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},vc=class n{constructor(e){this.view=e,this.items=[];let t=r=>{if(!(r.ctrlKey||r.altKey||r.metaKey)){if(r.keyCode==27)xx(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=Cx(s.actions);for(let a=0;a<o.length;a++)if(o[a].toUpperCase().charCodeAt(0)==r.keyCode){let l=xs(this.view.state.field(Jt).diagnostics,s);l&&s.actions[a].apply(e,l.from,l.to)}}else return;r.preventDefault()}},i=r=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(r.target)&&this.moveSelection(s)};this.list=yt("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=yt("div",{class:"cm-panel-lint"},this.list,yt("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>xx(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(Jt).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Jt),i=0,r=!1,s=null,o=new Set;for(e.between(0,this.view.state.doc.length,(a,l,{spec:c})=>{for(let u of c.diagnostics){if(o.has(u))continue;o.add(u);let f=-1,h;for(let d=i;d<this.items.length;d++)if(this.items[d].diagnostic==u){f=d;break}f<0?(h=new yc(this.view,u),this.items.splice(i,0,h),r=!0):(h=this.items[f],f>i&&(this.items.splice(i,f-i),r=!0)),t&&h.diagnostic==t.diagnostic?h.dom.hasAttribute("aria-selected")||(h.dom.setAttribute("aria-selected","true"),s=h):h.dom.hasAttribute("aria-selected")&&h.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new yc(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:l})=>{let c=l.height/this.list.offsetHeight;a.top<l.top?this.list.scrollTop-=(l.top-a.top)/c:a.bottom>l.bottom&&(this.list.scrollTop+=(a.bottom-l.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Jt),i=xs(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:Ox.of(i)})}static open(e){return new n(e)}};function y_(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`}function mc(n){return y_(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}var v_=q.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:mc("#f11")},".cm-lintRange-warning":{backgroundImage:mc("orange")},".cm-lintRange-info":{backgroundImage:mc("#999")},".cm-lintRange-hint":{backgroundImage:mc("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function x_(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function b_(n){let e="hint",t=1;for(let i of n){let r=x_(i.severity);r>t&&(t=r,e=i.severity)}return e}var w_=X0(d_,{hideOn:c_}),Ex=[Jt,q.decorations.compute([Jt],n=>{let{selected:e,panel:t}=n.field(Jt);return!e||!t||e.from==e.to?X.none:X.set([h_.range(e.from,e.to)])}),w_,v_];function Ax(n){return{all:n=n||new Map,on:function(e,t){var i=n.get(e);i?i.push(t):n.set(e,[t])},off:function(e,t){var i=n.get(e);i&&(t?i.splice(i.indexOf(t)>>>0,1):n.set(e,[]))},emit:function(e,t){var i=n.get(e);i&&i.slice().map(function(r){r(t)}),(i=n.get("*"))&&i.slice().map(function(r){r(e,t)})}}}var dd=class n{constructor(e,t,i,r,s,o,a,l,c,u=0,f){this.p=e,this.stack=t,this.state=i,this.reducePos=r,this.pos=s,this.score=o,this.buffer=a,this.bufferBase=l,this.curContext=c,this.lookAhead=u,this.parent=f}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let r=e.parser.context;return new n(e,[],t,i,i,0,[],0,r?new xc(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let i=e>>19,r=e&65535,{parser:s}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=s.dynamicPrecedence(r);if(a&&(this.score+=a),i==0){r<s.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(s.getGoto(this.state,r,!0),this.reducePos),r<s.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(r,this.reducePos);return}let l=this.stack.length-(i-1)*3-(e&262144?6:0),c=l?this.stack[l-2]:this.p.ranges[0].from;r<s.minRepeatTerm&&c==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let u=this.reducePos-c;u>=2e3&&!(!((t=this.p.parser.nodeSet.types[r])===null||t===void 0)&&t.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=c,this.p.lastBigReductionSize=u));let f=l?this.stack[l-1]:0,h=this.bufferBase+this.buffer.length-f;if(r<s.minRepeatTerm||e&131072){let d=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,c,d,h+4,!0)}if(e&262144)this.state=this.stack[l];else{let d=this.stack[l-3];this.state=s.getGoto(d,r,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(r,c)}storeNode(e,t,i,r=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this.buffer.length;if(o>0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(t==i)return;if(this.buffer[o-2]>=t){this.buffer[o-2]=i;return}}}if(!s||this.pos==i)this.buffer.push(e,t,i,r);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let a=!1;for(let l=o;l>0&&this.buffer[l-2]>i;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,r>4&&(r-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=i,this.buffer[o+3]=r}}shift(e,t,i,r){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let s=e,{parser:o}=this.p;this.pos=r;let a=o.stateFlag(s,1);!a&&(r>i||t<=o.maxNode)&&(this.reducePos=r),this.pushState(s,a?i:Math.min(i,this.reducePos)),this.shiftContext(t,i),t<=o.maxNode&&this.buffer.push(t,i,r,4)}else this.pos=r,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,r,4)}apply(e,t,i,r){e&65536?this.reduce(e):this.shift(e,t,i,r)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(i,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(t&&e.buffer[t-4]==0&&(t-=4);t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new n(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new pd(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if((i&65536)==0)return!0;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let r=[];for(let s=0,o;s<t.length;s+=2)(o=t[s+1])!=this.state&&this.p.parser.hasAction(o,e)&&r.push(t[s],o);if(this.stack.length<120)for(let s=0;r.length<8&&s<t.length;s+=2){let o=t[s+1];r.some((a,l)=>l&1&&a==o)||r.push(t[s],o)}t=r}let i=[];for(let r=0;r<t.length&&i.length<4;r+=2){let s=t[r+1];if(s==this.state)continue;let o=this.split();o.pushState(s,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(t[r],this.pos),o.reducePos=this.pos,o.score-=200,i.push(o)}return i}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if((t&65536)==0)return!1;if(!e.validAction(this.state,t)){let i=t>>19,r=t&65535,s=this.stack.length-i*3;if(s<0||e.getGoto(this.stack[s],r,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],i=(r,s)=>{if(!t.includes(r))return t.push(r),e.allActions(r,o=>{if(!(o&393216))if(o&65536){let a=(o>>19)-s;if(a>1){let l=o&65535,c=this.stack.length-a*3;if(c>=0&&e.getGoto(this.stack[c],l,!1)>=0)return a<<19|65536|l}}else{let a=i(o,s+1);if(a!=null)return a}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new xc(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},xc=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},pd=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},md=class n{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new n(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new n(this.stack,this.pos,this.index)}};function ia(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let i=0,r=0;i<n.length;){let s=0;for(;;){let o=n.charCodeAt(i++),a=!1;if(o==126){s=65535;break}o>=92&&o--,o>=34&&o--;let l=o-32;if(l>=46&&(l-=46,a=!0),s+=l,a)break;s*=46}t?t[r++]=s:t=new e(s)}return t}var bs=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},_x=new bs,gd=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=_x,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,r=this.rangeIndex,s=this.pos+e;for(;s<i.from;){if(!r)return null;let o=this.ranges[--r];s-=i.from-o.to,i=o}for(;t<0?s>i.to:s>=i.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];s+=o.from-i.to,i=o}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,r;if(t>=0&&t<this.chunk.length)i=this.pos+e,r=this.chunk.charCodeAt(t);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(i=s,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let o=this.rangeIndex,a=this.range;for(;a.to<=i;)a=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>a.to&&(this.chunk2=this.chunk2.slice(0,a.to-i)),r=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),r}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=i}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=_x,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(i+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return i}},ci=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;Dx(this.data,e,t,this.id,i.data,i.tokenPrecTable)}};ci.prototype.contextual=ci.prototype.fallback=ci.prototype.extend=!1;var yd=class{constructor(e,t,i){this.precTable=t,this.elseToken=i,this.data=typeof e=="string"?ia(e):e}token(e,t){let i=e.pos,r=0;for(;;){let s=e.next<0,o=e.resolveOffset(1,1);if(Dx(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(s||r++,o==null)break;e.reset(o,e.token)}r&&(e.reset(i,e.token),e.acceptToken(this.elseToken,r))}};yd.prototype.contextual=ci.prototype.fallback=ci.prototype.extend=!1;var ws=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function Dx(n,e,t,i,r,s){let o=0,a=1<<i,{dialect:l}=t.p.parser;e:for(;(a&n[o])!=0;){let c=n[o+1];for(let d=o+3;d<c;d+=2)if((n[d+1]&a)>0){let p=n[d];if(l.allows(p)&&(e.token.value==-1||e.token.value==p||k_(p,e.token.value,r,s))){e.acceptToken(p);break}}let u=e.next,f=0,h=n[o+2];if(e.next<0&&h>f&&n[c+h*3-3]==65535){o=n[c+h*3-1];continue e}for(;f<h;){let d=f+h>>1,p=c+d+(d<<1),m=n[p],y=n[p+1]||65536;if(u<m)h=d;else if(u>=y)f=d+1;else{o=n[p+2],e.advance();continue e}}break}}function Tx(n,e,t){for(let i=e,r;(r=n[i])!=65535;i++)if(r==t)return i-e;return-1}function k_(n,e,t,i){let r=Tx(t,i,e);return r<0||Tx(t,i,n)<r}var bt=typeof process!="undefined"&&process.env&&/\bparse\b/.test(process.env.LOG),fd=null;function Mx(n,e,t){let i=n.cursor(me.IncludeAnonymous);for(i.moveTo(e);;)if(!(t<0?i.childBefore(e):i.childAfter(e)))for(;;){if((t<0?i.to<e:i.from>e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(n.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:n.length}}var vd=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Mx(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Mx(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let i=this.trees[t],r=this.index[t];if(r==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=i.children[r],o=this.start[t]+i.positions[r];if(o>e)return this.nextStart=o,null;if(s instanceof be){if(o==e){if(o<this.safeFrom)return null;let a=o+s.length;if(a<=this.safeTo){let l=s.prop(H.lookAhead);if(!l||a+l<this.fragment.to)return s}}this.index[t]++,o+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+s.length}}},xd=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new bs)}getActions(e){let t=0,i=null,{parser:r}=e.p,{tokenizers:s}=r,o=r.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let c=0;c<s.length;c++){if((1<<c&o)==0)continue;let u=s[c],f=this.tokens[c];if(!(i&&!u.fallback)&&((u.contextual||f.start!=e.pos||f.mask!=o||f.context!=a)&&(this.updateCachedToken(f,u,e),f.mask=o,f.context=a),f.lookAhead>f.end+25&&(l=Math.max(f.lookAhead,l)),f.value!=0)){let h=t;if(f.extended>-1&&(t=this.addActions(e,f.extended,f.end,t)),t=this.addActions(e,f.value,f.end,t),!u.extend&&(i=f,t>h))break}}for(;this.actions.length>t;)this.actions.pop();return l&&e.setLookAhead(l),!i&&e.pos==this.stream.end&&(i=new bs,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new bs,{pos:i,p:r}=e;return t.start=i,t.end=Math.min(i+1,r.stream.end),t.value=i==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,i){let r=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(r,e),i),e.value>-1){let{parser:s}=i.p;for(let o=0;o<s.specialized.length;o++)if(s.specialized[o]==e.value){let a=s.specializers[o](this.stream.read(e.start,e.end),i);if(a>=0&&i.p.parser.dialect.allows(a>>1)){(a&1)==0?e.value=a>>1:e.extended=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,i,r){for(let s=0;s<r;s+=3)if(this.actions[s]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=i,r}addActions(e,t,i,r){let{state:s}=e,{parser:o}=e.p,{data:a}=o;for(let l=0;l<2;l++)for(let c=o.stateSlot(s,l?2:1);;c+=3){if(a[c]==65535)if(a[c+1]==1)c=Ln(a,c+2);else{r==0&&a[c+1]==2&&(r=this.putAction(Ln(a,c+2),t,i,r));break}a[c]==t&&(r=this.putAction(Ln(a,c+1),t,i,r))}return r}},bd=class{constructor(e,t,i,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new gd(t,r),this.tokens=new xd(e,this.stream),this.topTerm=e.top[1];let{from:s}=r[0];this.stacks=[dd.start(this,e.top[0],s)],this.fragments=i.length&&this.stream.end-s>e.bufferLength*4?new vd(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],r,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let a=e[o];for(;;){if(this.tokens.mainToken=null,a.pos>t)i.push(a);else{if(this.advanceStack(a,i,e))continue;{r||(r=[],s=[]),r.push(a);let l=this.tokens.getMainToken(a);s.push(l.value,l.end)}}break}}if(!i.length){let o=r&&C_(r);if(o)return bt&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw bt&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,i);if(o)return bt&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((a,l)=>l.score-a.score);i.length>o;)i.pop();i.some(a=>a.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let o=0;o<i.length-1;o++){let a=i[o];for(let l=o+1;l<i.length;l++){let c=i[l];if(a.sameState(c)||a.buffer.length>500&&c.buffer.length>500)if((a.score-c.score||a.buffer.length-c.buffer.length)>0)i.splice(l--,1);else{i.splice(o--,1);continue e}}}i.length>12&&(i.sort((o,a)=>a.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o<i.length;o++)i[o].pos<this.minStackPos&&(this.minStackPos=i[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,i){let r=e.pos,{parser:s}=this,o=bt?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,u=c?e.curContext.hash:0;for(let f=this.fragments.nodeAt(r);f;){let h=this.parser.nodeSet.types[f.type.id]==f.type?s.getGoto(e.state,f.type.id):-1;if(h>-1&&f.length&&(!c||(f.prop(H.contextHash)||0)==u))return e.useNode(f,h),bt&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(f.type.id)})`),!0;if(!(f instanceof be)||f.children.length==0||f.positions[0]>0)break;let d=f.children[0];if(d instanceof be&&f.positions[0]==0)f=d;else break}}let a=s.stateSlot(e.state,4);if(a>0)return e.reduce(a),bt&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(a&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let c=0;c<l.length;){let u=l[c++],f=l[c++],h=l[c++],d=c==l.length||!i,p=d?e:e.split(),m=this.tokens.mainToken;if(p.apply(u,f,m?m.start:p.pos,h),bt&&console.log(o+this.stackID(p)+` (via ${(u&65536)==0?"shift":`reduce of ${s.getName(u&65535)}`} for ${s.getName(f)} @ ${r}${p==e?"":", split"})`),d)return!0;p.pos>r?t.push(p):i.push(p)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return Rx(e,t),!0}}runRecovery(e,t,i){let r=null,s=!1;for(let o=0;o<e.length;o++){let a=e[o],l=t[o<<1],c=t[(o<<1)+1],u=bt?this.stackID(a)+" -> ":"";if(a.deadEnd&&(s||(s=!0,a.restart(),bt&&console.log(u+this.stackID(a)+" (restarted)"),this.advanceFully(a,i))))continue;let f=a.split(),h=u;for(let d=0;d<10&&f.forceReduce()&&(bt&&console.log(h+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,i));d++)bt&&(h=this.stackID(f)+" -> ");for(let d of a.recoverByInsert(l))bt&&console.log(u+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>a.pos?(c==a.pos&&(c++,l=0),a.recoverByDelete(l,c),bt&&console.log(u+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),Rx(a,i)):(!r||r.score<f.score)&&(r=f)}return r}stackToTree(e){return e.close(),be.build({buffer:md.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(fd||(fd=new WeakMap)).get(e);return t||fd.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function Rx(n,e){for(let t=0;t<e.length;t++){let i=e[t];if(i.pos==n.pos&&i.sameState(n)){e[t].score<n.score&&(e[t]=n);return}}e.push(n)}var wd=class{constructor(e,t,i){this.source=e,this.flags=t,this.disabled=i}allows(e){return!this.disabled||this.disabled[e]==0}},hd=n=>n,bc=class{constructor(e){this.start=e.start,this.shift=e.shift||hd,this.reduce=e.reduce||hd,this.reuse=e.reuse||hd,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}},wc=class n extends us{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let a=0;a<e.repeatNodeCount;a++)t.push("");let i=Object.keys(e.topRules).map(a=>e.topRules[a][1]),r=[];for(let a=0;a<t.length;a++)r.push([]);function s(a,l,c){r[a].push([l,l.deserialize(String(c))])}if(e.nodeProps)for(let a of e.nodeProps){let l=a[0];typeof l=="string"&&(l=H[l]);for(let c=1;c<a.length;){let u=a[c++];if(u>=0)s(u,l,a[c++]);else{let f=a[c+-u];for(let h=-u;h>0;h--)s(a[c++],l,f);c++}}}this.nodeSet=new Qo(t.map((a,l)=>We.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:r[l],top:i.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let o=ia(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(Px),this.states=ia(e.states,Uint32Array),this.data=ia(e.stateData),this.goto=ia(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(a=>typeof a=="number"?new ci(o,a):a),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let r=new bd(this,e,t,i);for(let s of this.wrappers)r=s(r,e,t,i);return r}getGoto(e,t,i=!1){let r=this.goto;if(t>=r[0])return-1;for(let s=r[t+1];;){let o=r[s++],a=o&1,l=r[s++];if(a&&i)return l;for(let c=s+(o>>1);s<c;s++)if(r[s]==e)return l;if(a)return-1}}hasAction(e,t){let i=this.data;for(let r=0;r<2;r++)for(let s=this.stateSlot(e,r?2:1),o;;s+=3){if((o=i[s])==65535)if(i[s+1]==1)o=i[s=Ln(i,s+2)];else{if(i[s+1]==2)return Ln(i,s+2);break}if(o==t||o==0)return Ln(i,s+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,i=>i==t?!0:null)}allActions(e,t){let i=this.stateSlot(e,4),r=i?t(i):void 0;for(let s=this.stateSlot(e,1);r==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Ln(this.data,s+2);else break;r=t(Ln(this.data,s+1))}return r}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Ln(this.data,i+2);else break;if((this.data[i+2]&1)==0){let r=this.data[i+1];t.some((s,o)=>o&1&&s==r)||t.push(this.data[i],r)}}return t}configure(e){let t=Object.assign(Object.create(n.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let r=e.tokenizers.find(s=>s.from==i);return r?r.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,r)=>{let s=e.specializers.find(a=>a.from==i.external);if(!s)return i;let o=Object.assign(Object.assign({},i),{external:s.to});return t.specializers[r]=Px(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let s of e.split(" ")){let o=t.indexOf(s);o>=0&&(i[o]=!0)}let r=null;for(let s=0;s<t.length;s++)if(!i[s])for(let o=this.dialects[t[s]],a;(a=this.data[o++])!=65535;)(r||(r=new Uint8Array(this.maxTerm+1)))[a]=1;return new wd(e,i,r)}static deserialize(e){return new n(e)}};function Ln(n,e){return n[e]|n[e+1]<<16}function C_(n){let e=null;for(let t of n){let i=t.p.stoppedAt;(t.pos==t.p.stream.end||i!=null&&t.pos>i)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function Px(n){if(n.external){let e=n.extend?1:0;return(t,i)=>n.external(t,i)<<1|e}return n.get}var S_=121,Cd=122,Fx=123,E_=124,Bx=128,A_=4,__=131,T_=7,M_=8,R_=9,P_=10,D_=139,jx=19,B_=140,I_=23,$_=141,L_=27,N_=37,q_=41,F_=144,j_=145,V_=146,Q_=147,z_=47,W_=68,Vx=153,Qx=70,zx=154,Wx=72,H_=155,X_=76,U_=160,Y_=79,K_=80,G_=81,J_=167,Hx=89,Z_=90,eT=169,tT=97,nT=171,iT=98,rT=100,sT=101,Sd=typeof process!="undefined"&&process.env&&/\bfparse(:dbg)?\b/.test(process.env.LOG),Ed=typeof process!="undefined"&&process.env&&/\bfparse:dbg\b/.test(process.env.LOG),Nn=typeof process!="undefined"&&process.env&&/\bcontext\b/.test(process.env.LOG),Xx=[9,11,12,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],oT=Ux(` class
/plugin/bpmnio/vendor/bpmn-js/dist/
H A Dbpmn-modeler.production.min.js2 (()=>{var zE=Object.create;var fc=Object.defineProperty;var GE=Object.getOwnPropertyDescriptor;var VE=Object.getOwnPropertyNames;var WE=Object.getPrototypeOf,UE=Object.prototype.hasOwnProperty;var qE=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(r){throw n=[r],r}};var dc=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}},KE=(e,t)=>{for(var n in t)fc(e,n,{get:t[n],enumerable:!0})},Xd=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of VE(t))!UE.call(e,i)&&i!==n&&fc(e,i,{get:()=>t[i],enumerable:!(r=GE(t,i))||r.enumerable});return e};var YE=(e,t,n)=>(n=e!=null?zE(WE(e)):{},Xd(t||!e||!e.__esModule?fc(n,"default",{value:e,enumerable:!0}):n,e)),XE=e=>Xd(fc({},"__esModule",{value:!0}),e);var em={};KE(em,{assign:()=>C,bind:()=>tt,debounce:()=>Ca,ensureArray:()=>Qd,every:()=>ln,filter:()=>Q,find:()=>re,findIndex:()=>Sa,flatten:()=>_i,forEach:()=>E,get:()=>o0,groupBy:()=>Vt,has:()=>dt,isArray:()=>q,isDefined:()=>Ue,isFunction:()=>Le,isNil:()=>Yn,isNumber:()=>ne,isObject:()=>Se,isString:()=>st,isUndefined:()=>wn,keys:()=>bi,map:()=>je,matchPattern:()=>Ct,merge:()=>Jd,omit:()=>Nt,pick:()=>mt,reduce:()=>Ge,set:()=>_l,size:()=>vl,some:()=>Lt,sortBy:()=>At,throttle:()=>i0,unionBy:()=>gl,uniqueBy:()=>mc,values:()=>Sn,without:()=>hl});function _i(e){return Array.prototype.concat.apply([],e)}function wn(e){return e===void 0}function Ue(e){return e!==void 0}function Yn(e){return e==null}function q(e){return wa.call(e)==="[object Array]"}function Se(e){return wa.call(e)==="[object Object]"}function ne(e){return wa.call(e)==="[object Number]"}function Le(e){let t=wa.call(e);return t==="[object Function]"||t==="[object AsyncFunction]"||t==="[object GeneratorFunction]"||t==="[object AsyncGeneratorFunction]"||t==="[object Proxy]"}function st(e){return wa.call(e)==="[object String]"}function Qd(e){if(!q(e))throw new Error("must supply array")}function dt(e,t){return!Yn(e)&&t0.call(e,t)}function re(e,t){let n=hc(t),r;return E(e,function(i,o){if(n(i,o))return r=i,!1}),r}function Sa(e,t){let n=hc(t),r=q(e)?-1:void 0;return E(e,function(i,o){if(n(i,o))return r=o,!1}),r}function Q(e,t){let n=hc(t),r=[];return E(e,function(i,o){n(i,o)&&r.push(i)}),r}function E(e,t){let n,r;if(wn(e))return;let i=q(e)?r0:n0;for(let o in e)if(dt(e,o)&&(n=e[o],r=t(n,i(o)),r===!1))return n}function hl(e,t){if(wn(e))return[];Qd(e);let n=hc(t);return e.filter(function(r,i){return!n(r,i)})}function Ge(e,t,n){return E(e,function(r,i){n=t(n,r,i)}),n}function ln(e,t){return!!Ge(e,function(n,r,i){return n&&t(r,i)},!0)}function Lt(e,t){return!!re(e,t)}function je(e,t){let n=[];return E(e,function(r,i){n.push(t(r,i))}),n}function bi(e){return e&&Object.keys(e)||[]}function vl(e){return bi(e).length}function Sn(e){return je(e,t=>t)}function Vt(e,t,n={}){return t=yl(t),E(e,function(r){let i=t(r)||"_",o=n[i];o||(o=n[i]=[]),o.push(r)}),n}function mc(e,...t){e=yl(e);let n={};return E(t,i=>Vt(i,e,n)),je(n,function(i,o){return i[0]})}function At(e,t){t=yl(t);let n=[];return E(e,function(r,i){let o=t(r,i),a={d:o,v:r};for(var s=0;s<n.length;s++){let{d:c}=n[s];if(o<c){n.splice(s,0,a);return}}n.push(a)}),je(n,r=>r.v)}function Ct(e){return function(t){return ln(e,function(n,r){return t[r]===n})}}function yl(e){return Le(e)?e:t=>t[e]}function hc(e){return Le(e)?e:t=>t===e}function n0(e){return e}function r0(e){return Number(e)}function Ca(e,t){let n,r,i,o;function a(l){let f=Date.now(),d=l?0:o+t-f;if(d>0)return s(d);e.apply(i,r),c()}function s(l){n=setTimeout(a,l)}function c(){n&&clearTimeout(n),n=o=r=i=void 0}function u(){n&&a(!0),c()}function p(...l){o=Date.now(),r=l,i=this,n||s(t)}return p.flush=u,p.cancel=c,p}function i0(e,t){let n=!1;return function(...r){n||(e(...r),n=!0,setTimeout(()=>{n=!1},t))}}function tt(e,t){return e.bind(t)}function C(e,...t){return Object.assign(e,...t)}function _l(e,t,n){let r=e;return E(t,function(i,o){if(typeof i!="number"&&typeof i!="string")throw new Error("illegal key type: "+typeof i+". Key should be of type number or string.");if(i==="constructor")throw new Error("illegal key: constructor");if(i==="__proto__")throw new Error("illegal key: __proto__");let a=t[o+1],s=r[i];Ue(a)&&Yn(s)&&(s=r[i]=isNaN(+a)?{}:[]),wn(a)?wn(n)?delete r[i]:r[i]=n:r=s}),e}function o0(e,t,n){let r=e;return E(t,function(i){if(Yn(r))return r=void 0,!1;r=r[i]}),wn(r)?n:r}function mt(e,t){let n={},r=Object(e);return E(t,function(i){i in r&&(n[i]=e[i])}),n}function Nt(e,t){let n={},r=Object(e);return E(r,function(i,o){t.indexOf(o)===-1&&(n[o]=i)}),n}function Jd(e,...t){return t.length&&E(t,function(n){!n||!Se(n)||E(n,function(r,i){if(i==="__proto__")return;let o=e[i];Se(r)?(Se(o)||(o={}),e[i]=Jd(o,r)):e[i]=r})}),e}var wa,t0,gl,N=qE(()=>{wa=Object.prototype.toString,t0=Object.prototype.hasOwnProperty;gl=mc});var jx=dc((qee,Lx)=>{function vD(e){return["String","Boolean","Integer","Real"].includes(e)}Lx.exports=function e(t,n){let r=n.enter,i=n.leave,o=r&&r(t),a=t.$descriptor;o!==!1&&!a.isGeneric&&a.properties.filter(c=>!c.isAttr&&!c.isReference&&!vD(c.type)).forEach(c=>{if(c.name in t){let u=t[c.name];c.isMany?u.forEach(p=>{e(p,n)}):e(u,n)}}),i&&i(t)}});var Hx=dc((Kee,Fx)=>{var gD=jx(),{isArray:yD,isObject:_D,isFunction:bD}=(N(),XE(em)),_d=class{constructor({moddleRoot:t,rule:n}){this.rule=n,this.moddleRoot=t,this.messages=[],this.report=this.report.bind(this)}report(t,n,r){let i={id:t,message:n};r&&yD(r)&&(i={...i,path:r}),r&&_D(r)&&(i={...i,...r}),this.messages.push(i)}};Fx.exports=function({moddleRoot:t,rule:n}){let r=new _d({rule:n,moddleRoot:t}),i=n.check||{},o="leave"in i?i.leave:void 0,a="enter"in i?i.enter:bD(i)?i:void 0;if(!a&&!o)throw new Error("no check implemented");return gD(t,{enter:a?s=>a(s,r):void 0,leave:o?s=>o(s,r):void 0}),r.messages}});var Gx=dc((Yee,zx)=>{var xD=Hx(),ED=(e,t)=>e,wD={0:"off",1:"warn",2:"error",3:"info"},SD="rule-error";function On(e){let{config:t={},resolver:n,transformRule:r=ED}=e||{};if(typeof n=="undefined")throw new Error("must provide <options.resolver>");this.config=t,this.resolver=n,this.transformRule=r,this.cachedRules={},this.cachedConfigs={}}zx.exports=On;On.prototype.applyRule=function(t,n){let{config:r,rule:i,category:o,name:a}=n;try{return xD({moddleRoot:t,rule:i,config:r}).map(function(c){return{...c,meta:i.meta,category:o}})}catch(s){return console.error("rule <"+a+"> failed with error: ",s),[{message:s.message,category:SD}]}};On.prototype.resolveRule=function(e,t){let{pkg:n,ruleName:r}=this.parseRuleName(e),i=`${n}-${r}`,o=this.cachedRules[i];return o?Promise.resolve(o):Promise.resolve(this.resolver.resolveRule(n,r)).then(a=>{if(!a)throw new Error(`unknown rule <${e}>`);return this.cachedRules[i]=this.transformRule(a(t),{pkg:n,ruleName:r})})};On.prototype.resolveConfig=function(e){let{pkg:t,configName:n}=this.parseConfigName(e),r=`${t}-${n}`,i=this.cachedConfigs[r];return i?Promise.resolve(i):Promise.resolve(this.resolver.resolveConfig(t,n)).then(o=>{if(!o)throw new Error(`unknown config <${e}>`);return this.cachedConfigs[r]=this.normalizeConfig(o,t)})};On.prototype.resolveRules=function(e){return this.resolveConfiguredRules(e).then(t=>{let i=Object.entries(t).map(([o,a])=>{let{category:s,config:c}=this.parseRuleValue(a);return{name:o,category:s,config:c}}).filter(o=>o.category!=="off").map(o=>{let{name:a,config:s}=o;return this.resolveRule(a,s).then(function(c){return{...o,rule:c}})});return Promise.all(i)})};On.prototype.resolveConfiguredRules=function(e){let t=e.extends;return typeof t=="string"&&(t=[t]),typeof t=="undefined"&&(t=[]),Promise.all(t.map(n=>this.resolveConfig(n).then(r=>this.resolveConfiguredRules(r)))).then(n=>{let r=this.normalizeConfig(e,"bpmnlint").rules;return[...n,r].reduce((o,a)=>({...o,...a}),{})})};On.prototype.lint=function(e,t){return t=t||this.config,this.resolveRules(t).then(n=>{let r={};return n.forEach(i=>{let{name:o}=i,a=this.applyRule(e,i);a.length&&(r[o]=a)}),r})};On.prototype.parseRuleValue=function(e){let t,n;return Array.isArray(e)?(t=e[0],n=e[1]):(t=e,n={}),typeof t=="string"&&(t=t.toLowerCase()),t=wD[t]||t,{config:n,category:t}};On.prototype.parseRuleName=function(e,t="bpmnlint"){let n=/^(?:(?:(@[^/]+)\/)?([^@]{1}[^/]*)\/)?([^/]+)$/.exec(e);if(!n)throw new Error(`unparseable rule name <${e}>`);let[r,i,o,a]=n;return o?{pkg:`${i?i+"/":""}${$x(o)}`,ruleName:a}:{pkg:t,ruleName:a}};On.prototype.parseConfigName=function(e){let t=/^(?:(?:plugin:(?:(@[^/]+)\/)?([^@]{1}[^/]*)\/)|bpmnlint:)([^/]+)$/.exec(e);if(!t)throw new Error(`unparseable config name <${e}>`);let[n,r,i,o]=t;return i?{pkg:`${r?r+"/":""}${$x(i)}`,configName:o}:{pkg:"bpmnlint",configName:o}};On.prototype.getSimplePackageName=function(e){let t=/^(?:(@[^/]+)\/)?([^/]+)$/.exec(e);if(!t)throw new Error(`unparseable package name <${e}>`);let[n,r,i]=t;return`${r?r+"/":""}${CD(i)}`};On.prototype.normalizeConfig=function(e,t){let n=e.rules||{},r=Object.keys(n).reduce((i,o)=>{let a=n[o],{pkg:s,ruleName:c}=this.parseRuleName(o,t),u=s==="bpmnlint"?c:`${this.getSimplePackageName(s)}/${c}`;return i[u]=a,i},{});return{...e,rules:r}};function $x(e){return e==="bpmnlint"?"bpmnlint":e.startsWith("bpmnlint-plugin-")?e:`bpmnlint-plugin-${e}`}function CD(e){return e.startsWith("bpmnlint-plugin-")?e.substring(16):e}});var Wx=dc((Xee,Vx)=>{var RD=Gx();Vx.exports={Linter:RD}});function B(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}function ZE(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ml={exports:{}},Zd;function QE(){if(Zd)return ml.exports;Zd=1;var e=ml.exports=function(t,n){if(n||(n=16),t===void 0&&(t=128),t<=0)return"0";for(var r=Math.log(Math.pow(2,t))/Math.log(n),i=2;r===1/0;i*=2)r=Math.log(Math.pow(2,t/i))/Math.log(n)*i;for(var o=r-Math.floor(r),a="",i=0;i<Math.floor(r);i++){var s=Math.floor(Math.random()*n).toString(n);a=s+a}if(o){var c=Math.pow(n,o),s=Math.floor(Math.random()*c).toString(n);a=s+a}var u=parseInt(a,n);return u!==1/0&&u>=Math.pow(2,t)?e(t,n):a};return e.rack=function(t,n,r){var i=function(a){var s=0;do{if(s++>10)if(r)t+=r;else throw new Error("too many ID collisions, use more bits");var c=e(t,n)}while(Object.hasOwnProperty.call(o,c));return o[c]=a,c},o=i.hats={};return i.get=function(a){return i.hats[a]},i.set=function(a,s){return i.hats[a]=s,i},i.bits=t||128,i.base=n||16,i},ml.exports}var JE=QE(),e0=ZE(JE);function En(e){if(!(this instanceof En))return new En(e);e=e||[128,36,1],this._seed=e.length?e0.rack(e[0],e[1],e[2]):e}En.prototype.next=function(e){return this._seed(e||!0)};En.prototype.nextPrefixed=function(e,t){var n;do n=e+this.next(!0);while(this.assigned(n));return this.claim(n,t),n};En.prototype.claim=function(e,t){this._seed.set(e,t||!0)};En.prototype.assigned=function(e){return this._seed.get(e)||!1};En.prototype.unclaim=function(e){delete this._seed.hats[e]};En.prototype.clear=function(){var e=this._seed.hats,t;for(t in e)this.unclaim(t)};N();N();var ht={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:[0,"",""]};ht.td=ht.th=[3,"<table><tbody><tr>","</tr></tbody></table>"];ht.option=ht.optgroup=[1,'<select multiple="multiple">',"</select>"];ht.thead=ht.tbody=ht.colgroup=ht.caption=ht.tfoot=[1,"<table>","</table>"];ht.polyline=ht.ellipse=ht.polygon=ht.circle=ht.text=ht.line=ht.path=ht.rect=ht.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];function ue(e,t=globalThis.document){var u;if(typeof e!="string")throw new TypeError("String expected");let n=/^<!--(.*?)-->$/s.exec(e);if(n)return t.createComment(n[1]);let r=(u=/<([\w:]+)/.exec(e))==null?void 0:u[1];if(!r)return t.createTextNode(e);if(e=e.trim(),r==="body"){let p=t.createElement("html");p.innerHTML=e;let{lastChild:l}=p;return l.remove(),l}let[i,o,a]=Object.hasOwn(ht,r)?ht[r]:ht._default,s=t.createElement("div");for(s.innerHTML=o+e+a;i--;)s=s.lastChild;if(s.firstChild===s.lastChild){let{firstChild:p}=s;return p.remove(),p}let c=t.createDocumentFragment();return c.append(...s.childNodes),c}function a0(e,t){return t.forEach(function(n){n&&typeof n!="string"&&!Array.isArray(n)&&Object.keys(n).forEach(function(r){if(r!=="default"&&!(r in e)){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}})}),Object.freeze(e)}function vt(e,...t){let n=e.style;return E(t,function(r){r&&E(r,function(i,o){n[o]=i})}),e}function nt(e,t,n){return arguments.length==2?e.getAttribute(t):n===null?e.removeAttribute(t):(e.setAttribute(t,n),e)}var s0=Object.prototype.toString;function Ne(e){return new Fr(e)}function Fr(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}Fr.prototype.add=function(e){return this.list.add(e),this};Fr.prototype.remove=function(e){return s0.call(e)=="[object RegExp]"?this.removeMatching(e):(this.list.remove(e),this)};Fr.prototype.removeMatching=function(e){let t=this.array();for(let n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this};Fr.prototype.toggle=function(e,t){return typeof t!="undefined"?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this};Fr.prototype.array=function(){return Array.from(this.list)};Fr.prototype.has=Fr.prototype.contains=function(e){return this.list.contains(e)};function Hr(e){for(var t;t=e.firstChild;)e.removeChild(t);return e}function Bn(e,t,n){var r=n?e:e.parentNode;return r&&typeof r.closest=="function"&&r.closest(t)||null}function c0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var vc={},tm;function u0(){if(tm)return vc;tm=1;var e,t,n;function r(){e=window.addEventListener?"addEventListener":"attachEvent",t=window.removeEventListener?"removeEventListener":"detachEvent",n=e!=="addEventListener"?"on":""}return vc.bind=function(i,o,a,s){return e||r(),i[e](n+o,a,s||!1),a},vc.unbind=function(i,o,a,s){return t||r(),i[t](n+o,a,s||!1),a},vc}var nm=u0(),p0=c0(nm),se=a0({__proto__:null,default:p0},[nm]),rm=["focus","blur"];function l0(e,t,n,r,i){return rm.indexOf(n)!==-1&&(i=!0),se.bind(e,n,function(o){var a=o.target||o.srcElement;o.delegateTarget=Bn(a,t,!0),o.delegateTarget&&r.call(e,o)},i)}function f0(e,t,n,r){return rm.indexOf(t)!==-1&&(r=!0),se.unbind(e,t,n,r)}var bt={bind:l0,unbind:f0};function Ra(e,t){return e&&typeof e.matches=="function"&&e.matches(t)||!1}function _e(e,t){return t=t||document,t.querySelector(e)}function xi(e,t){return t=t||document,t.querySelectorAll(e)}function Wt(e){e.parentNode&&e.parentNode.removeChild(e)}function d0(e,t){if(e.ownerDocument!==t.ownerDocument)try{return t.ownerDocument.importNode(e,!0)}catch{}return e}function sm(e,t){return t.appendChild(d0(e,t))}function J(e,t){return sm(t,e),e}var El=2,cm={"alignment-baseline":1,"baseline-shift":1,clip:1,"clip-path":1,"clip-rule":1,color:1,"color-interpolation":1,"color-interpolation-filters":1,"color-profile":1,"color-rendering":1,cursor:1,direction:1,display:1,"dominant-baseline":1,"enable-background":1,fill:1,"fill-opacity":1,"fill-rule":1,filter:1,"flood-color":1,"flood-opacity":1,font:1,"font-family":1,"font-size":El,"font-size-adjust":1,"font-stretch":1,"font-style":1,"font-variant":1,"font-weight":1,"glyph-orientation-horizontal":1,"glyph-orientation-vertical":1,"image-rendering":1,kerning:1,"letter-spacing":1,"lighting-color":1,marker:1,"marker-end":1,"marker-mid":1,"marker-start":1,mask:1,opacity:1,overflow:1,"pointer-events":1,"shape-rendering":1,"stop-color":1,"stop-opacity":1,stroke:1,"stroke-dasharray":1,"stroke-dashoffset":1,"stroke-linecap":1,"stroke-linejoin":1,"stroke-miterlimit":1,"stroke-opacity":1,"stroke-width":El,"text-anchor":1,"text-decoration":1,"text-rendering":1,"unicode-bidi":1,visibility:1,"word-spacing":1,"writing-mode":1};function m0(e,t){return cm[t]?e.style[t]:e.getAttributeNS(null,t)}function um(e,t,n){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),i=cm[r];i?(i===El&&typeof n=="number"&&(n=String(n)+"px"),e.style[r]=n):e.setAttributeNS(null,t,n)}function h0(e,t){var n=Object.keys(t),r,i;for(r=0,i;i=n[r];r++)um(e,i,t[i])}function $(e,t,n){if(typeof t=="string")if(n!==void 0)um(e,t,n);else return m0(e,t);else h0(e,t);return e}var v0=Object.prototype.toString;function pe(e){return new $r(e)}function $r(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}$r.prototype.add=function(e){return this.list.add(e),this};$r.prototype.remove=function(e){return v0.call(e)=="[object RegExp]"?this.removeMatching(e):(this.list.remove(e),this)};$r.prototype.removeMatching=function(e){let t=this.array();for(let n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this};$r.prototype.toggle=function(e,t){return typeof t!="undefined"?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this};$r.prototype.array=function(){return Array.from(this.list)};$r.prototype.has=$r.prototype.contains=function(e){return this.list.contains(e)};function _r(e){for(var t;t=e.firstChild;)e.removeChild(t);return e}function Sl(e){return e.cloneNode(!0)}var Cl={svg:"http://www.w3.org/2000/svg"},im='<svg xmlns="'+Cl.svg+'"';function pm(e){var t=!1;e.substring(0,4)==="<svg"?e.indexOf(Cl.svg)===-1&&(e=im+e.substring(4)):(e=im+">"+e+"</svg>",t=!0);var n=g0(e);if(!t)return n;for(var r=document.createDocumentFragment(),i=n.firstChild;i.firstChild;)r.appendChild(i.firstChild);return r}function g0(e){var t;return t=new DOMParser,t.async=!1,t.parseFromString(e,"text/xml")}function U(e,t){var n;return e=e.trim(),e.charAt(0)==="<"?(n=pm(e).firstChild,n=document.importNode(n,!0)):n=document.createElementNS(Cl.svg,e),t&&$(n,t),n}var bl=null;function wl(){return bl===null&&(bl=U("svg")),bl}function om(e,t){var n,r,i=Object.keys(t);for(n=0;r=i[n];n++)e[r]=t[r];return e}function lm(e,t,n,r,i,o){var a=wl().createSVGMatrix();switch(arguments.length){case 0:return a;case 1:return om(a,e);case 6:return om(a,{a:e,b:t,c:n,d:r,e:i,f:o})}}function so(e){return e?wl().createSVGTransformFromMatrix(e):wl().createSVGTransform()}var am=/([&<>]{1})/g,y0=/([&<>\n\r"]{1})/g,_0={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"'"};function xl(e,t){function n(r,i){return _0[i]||i}return e.replace(t,n)}function fm(e,t){var n,r,i,o,a;switch(e.nodeType){case 3:t.push(xl(e.textContent,am));break;case 1:if(t.push("<",e.tagName),e.hasAttributes())for(i=e.attributes,n=0,r=i.length;n<r;++n)o=i.item(n),t.push(" ",o.name,'="',xl(o.value,y0),'"');if(e.hasChildNodes()){for(t.push(">"),a=e.childNodes,n=0,r=a.length;n<r;++n)fm(a.item(n),t);t.push("</",e.tagName,">")}else t.push("/>");break;case 8:t.push("<!--",xl(e.nodeValue,am),"-->");break;case 4:t.push("<![CDATA[",e.nodeValue,"]]>");break;default:throw new Error("unable to handle node "+e.nodeType)}return t}function b0(e,t){var n=pm(t);if(_r(e),!!t){E0(n)||(n=n.documentElement);for(var r=w0(n.childNodes),i=0;i<r.length;i++)sm(r[i],e)}}function x0(e){for(var t=e.firstChild,n=[];t;)fm(t,n),t=t.nextSibling;return n.join("")}function E0(e){return e.nodeName==="#document-fragment"}function Rl(e,t){if(t!==void 0){try{b0(e,t)}catch(n){throw new Error("error parsing SVG: "+n.message)}return e}else return x0(e)}function w0(e){return Array.prototype.slice.call(e)}function Pe(e){var t=e.parentNode;return t&&t.removeChild(e),e}function S0(e,t){return t instanceof SVGMatrix?e.createSVGTransformFromMatrix(t):t}function C0(e,t){var n,r;for(e.clear(),n=0;r=t[n];n++)e.appendItem(S0(e,r))}function Ei(e,t){var n=e.transform.baseVal;return t&&(Array.isArray(t)||(t=[t]),C0(n,t)),n.consolidate()}var R0=/^class[ {]/;function P0(e){return R0.test(e.toString())}function Al(e){return Array.isArray(e)}function Pl(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function gc(...e){e.length===1&&Al(e[0])&&(e=e[0]),e=[...e];let t=e.pop();return t.$inject=e,t}var A0=/constructor\s*[^(]*\(\s*([^)]*)\)/m,T0=/^(?:async\s+)?(?:function\s*[^(]*)?(?:\(\s*([^)]*)\)|(\w+))/m,M0=/\/\*([^*]*)\*\//m;function D0(e){if(typeof e!="function")throw new Error(`Cannot annotate "${e}". Expected a function!`);let t=e.toString().match(P0(e)?A0:T0);if(!t)return[];let n=t[1]||t[2];return n&&n.split(",").map(r=>{let i=r.match(M0);return(i&&i[1]||r).trim()})||[]}function Tl(e,t){let n=t||{get:function(x,b){if(r.push(x),b===!1)return null;throw s(`No provider for "${x}"!`)}},r=[],i=this._providers=Object.create(n._providers||null),o=this._instances=Object.create(null),a=o.injector=this,s=function(x){let b=r.join(" -> ");return r.length=0,new Error(b?`${x} (Resolving: ${b})`:x)};function c(x,b){if(!i[x]&&x.includes(".")){let R=x.split("."),A=c(R.shift());for(;R.length;)A=A[R.shift()];return A}if(Pl(o,x))return o[x];if(Pl(i,x)){if(r.indexOf(x)!==-1)throw r.push(x),s("Cannot resolve circular dependency!");return r.push(x),o[x]=i[x][0](i[x][1]),r.pop(),o[x]}return n.get(x,b)}function u(x,b){if(typeof b=="undefined"&&(b={}),typeof x!="function")if(Al(x))x=gc(x.slice());else throw s(`Cannot invoke "${x}". Expected a function!`);let A=(x.$inject||D0(x)).map(O=>Pl(b,O)?b[O]:c(O));return{fn:x,dependencies:A}}function p(x){let{fn:b,dependencies:R}=u(x),A=Function.prototype.bind.call(b,null,...R);return new A}function l(x,b,R){let{fn:A,dependencies:O}=u(x,R);return A.apply(b,O)}function f(x){return gc(b=>x.get(b))}function d(x,b){if(b&&b.length){let R=Object.create(null),A=Object.create(null),O=[],T=[],I=[],L,W,z,K;for(let ve in i)L=i[ve],b.indexOf(ve)!==-1&&(L[2]==="private"?(W=O.indexOf(L[3]),W===-1?(z=L[3].createChild([],b),K=f(z),O.push(L[3]),T.push(z),I.push(K),R[ve]=[K,ve,"private",z]):R[ve]=[I[W],ve,"private",T[W]]):R[ve]=[L[2],L[1]],A[ve]=!0),(L[2]==="factory"||L[2]==="type")&&L[1].$scope&&b.forEach(Jt=>{L[1].$scope.indexOf(Jt)!==-1&&(R[ve]=[L[2],L[1]],A[Jt]=!0)});b.forEach(ve=>{if(!A[ve])throw new Error('No provider for "'+ve+'". Cannot use provider from the parent!')}),x.unshift(R)}return new Tl(x,a)}let m={factory:l,type:p,value:function(x){return x}};function g(x,b){let R=x.__init__||[];return function(){R.forEach(A=>{typeof A=="string"?b.get(A):b.invoke(A)})}}function v(x){let b=x.__exports__;if(b){let R=x.__modules__,A=Object.keys(x).reduce((W,z)=>(z!=="__exports__"&&z!=="__modules__"&&z!=="__init__"&&z!=="__depends__"&&(W[z]=x[z]),W),Object.create(null)),O=(R||[]).concat(A),T=d(O),I=gc(function(W){return T.get(W)});b.forEach(function(W){i[W]=[I,W,"private",T]});let L=(x.__init__||[]).slice();return L.unshift(function(){T.init()}),x=Object.assign({},x,{__init__:L}),g(x,T)}return Object.keys(x).forEach(function(R){if(R==="__init__"||R==="__depends__")return;let A=x[R];if(A[2]==="private"){i[R]=A;return}let O=A[0],T=A[1];i[R]=[m[O],k0(O,T),O]}),g(x,a)}function w(x,b){return x.indexOf(b)!==-1||(x=(b.__depends__||[]).reduce(w,x),x.indexOf(b)!==-1)?x:x.concat(b)}function S(x){let b=x.reduce(w,[]).map(v),R=!1;return function(){R||(R=!0,b.forEach(A=>A()))}}this.get=c,this.invoke=l,this.instantiate=p,this.createChild=d,this.init=S(e)}function k0(e,t){return e!=="value"&&Al(t)&&(t=gc(t.slice())),t}var N0=1e3;function Cn(e,t){var n=this;t=t||N0,e.on(["render.shape","render.connection"],t,function(r,i){var o=r.type,a=i.element,s=i.gfx,c=i.attrs;if(n.canRender(a))return o==="render.shape"?n.drawShape(s,a,c):n.drawConnection(s,a,c)}),e.on(["render.getShapePath","render.getConnectionPath"],t,function(r,i){if(n.canRender(i))return r.type==="render.getShapePath"?n.getShapePath(i):n.getConnectionPath(i)})}Cn.prototype.canRender=function(e){};Cn.prototype.drawShape=function(e,t){};Cn.prototype.drawConnection=function(e,t){};Cn.prototype.getShapePath=function(e){};Cn.prototype.getConnectionPath=function(e){};N();function br(e){return e.flat().join(",").replace(/,?([A-Za-z]),?/g,"$1")}function O0(e){return["M",e.x,e.y]}function Ml(e){return["L",e.x,e.y]}function B0(e,t,n){return["C",e.x,e.y,t.x,t.y,n.x,n.y]}function I0(e,t){let n=e.length,r=[O0(e[0])];for(let i=1;i<n;i++){let o=e[i-1],a=e[i],s=e[i+1];if(!s||!t){r.push(Ml(a));continue}let c=Math.min(t,Dl(a.x-o.x,a.y-o.y),Dl(s.x-a.x,s.y-a.y));if(!c){r.push(Ml(a));continue}let u=yc(a,o,c),p=yc(a,o,c*.5),l=yc(a,s,c),f=yc(a,s,c*.5);r.push(Ml(u)),r.push(B0(p,f,l))}return r}function yc(e,t,n){let r=t.x-e.x,i=t.y-e.y,o=Dl(r,i),a=n/o;return{x:e.x+r*a,y:e.y+i*a}}function Dl(e,t){return Math.sqrt(Math.pow(e,2)+Math.pow(t,2))}function Xn(e,t,n){ne(t)&&(n=t,t=null),t||(t={});let r=U("path",t);return ne(n)&&(r.dataset.cornerRadius=String(n)),Pa(r,e)}function Pa(e,t){let n=parseInt(e.dataset.cornerRadius,10)||0;return $(e,{d:br(I0(t,n))}),e}N();N();function zr(e){return Q(e,function(t){return!re(e,function(n){return n!==t&&mm(t,n)})})}function mm(e,t){if(t){if(e===t)return t;if(e.parent)return mm(e.parent,t)}}function dm(e,t,n){var r=!n||e.indexOf(t)===-1;return r&&e.push(t),r}function In(e,t,n){n=n||0,q(e)||(e=[e]),E(e,function(r,i){var o=t(r,i,n);q(o)&&o.length&&In(o,t,n+1)})}function Ta(e,t,n){var r=[],i=[];return In(e,function(o,a,s){dm(r,o,t);var c=o.children;if((n===-1||s<n)&&c&&dm(i,c,t))return c}),r}function Zn(e,t){return Ta(e,!t,-1)}function hm(e,t,n){wn(t)&&(t=!0),Se(t)&&(n=t,t=!0),n=n||{};var r=Aa(n.allShapes),i=Aa(n.allConnections),o=Aa(n.enclosedElements),a=Aa(n.enclosedConnections),s=Aa(n.topLevel,t&&Vt(e,function(p){return p.id}));function c(p){s[p.source.id]&&s[p.target.id]&&(s[p.id]=[p]),r[p.source.id]&&r[p.target.id]&&(a[p.id]=o[p.id]=p),i[p.id]=p}function u(p){if(o[p.id]=p,p.waypoints)a[p.id]=i[p.id]=p;else return r[p.id]=p,E(p.incoming,c),E(p.outgoing,c),p.children}return In(e,u),{allShapes:r,allConnections:i,topLevel:s,enclosedConnections:a,enclosedElements:o}}function Ce(e,t){t=!!t,q(e)||(e=[e]);var n,r,i,o;return E(e,function(a){var s=a;a.waypoints&&!t&&(s=Ce(a.waypoints,!0));var c=s.x,u=s.y,p=s.height||0,l=s.width||0;(c<n||n===void 0)&&(n=c),(u<r||r===void 0)&&(r=u),(c+l>i||i===void 0)&&(i=c+l),(u+p>o||o===void 0)&&(o=u+p)}),{x:n,y:r,height:o-r,width:i-n}}function wi(e,t){var n={};return E(e,function(r){var i=r;i.waypoints&&(i=Ce(i)),!ne(t.y)&&i.x>t.x&&(n[r.id]=r),!ne(t.x)&&i.y>t.y&&(n[r.id]=r),i.x>t.x&&i.y>t.y&&(ne(t.width)&&ne(t.height)&&i.width+i.x<t.width+t.x&&i.height+i.y<t.height+t.y||!ne(t.width)||!ne(t.height))&&(n[r.id]=r)}),n}function _c(e){return"waypoints"in e?"connection":"x"in e?"shape":"root"}function bc(e){return!!(e&&e.isFrame)}function Aa(e,t){return C({},e||{},t||{})}var L0=1;function Qn(e,t){Cn.call(this,e,L0),this.CONNECTION_STYLE=t.style(["no-fill"],{strokeWidth:5,stroke:"fuchsia"}),this.SHAPE_STYLE=t.style({fill:"white",stroke:"fuchsia",strokeWidth:2}),this.FRAME_STYLE=t.style(["no-fill"],{stroke:"fuchsia",strokeDasharray:4,strokeWidth:2})}B(Qn,Cn);Qn.prototype.canRender=function(){return!0};Qn.prototype.drawShape=function(t,n,r){var i=U("rect");return $(i,{x:0,y:0,width:n.width||0,height:n.height||0}),bc(n)?$(i,C({},this.FRAME_STYLE,r||{})):$(i,C({},this.SHAPE_STYLE,r||{})),J(t,i),i};Qn.prototype.drawConnection=function(t,n,r){var i=Xn(n.waypoints,C({},this.CONNECTION_STYLE,r||{}));return J(t,i),i};Qn.prototype.getShapePath=function(t){var n=t.x,r=t.y,i=t.width,o=t.height,a=[["M",n,r],["l",i,0],["l",0,o],["l",-i,0],["z"]];return br(a)};Qn.prototype.getConnectionPath=function(t){var n=t.waypoints,r,i,o=[];for(r=0;i=n[r];r++)i=i.original||i,o.push([r===0?"M":"L",i.x,i.y]);return br(o)};Qn.$inject=["eventBus","styles"];N();function kl(){var e={"no-fill":{fill:"none"},"no-border":{strokeOpacity:0},"no-events":{pointerEvents:"none"}},t=this;this.cls=function(n,r,i){var o=this.style(r,i);return C(o,{class:n})},this.style=function(n,r){!q(n)&&!r&&(r=n,n=[]);var i=Ge(n,function(o,a){return C(o,e[a]||{})},{});return r?C(i,r):i},this.computeStyle=function(n,r,i){return q(r)||(i=r,r=[]),t.style(r||[],C({},i,n||{}))}}var vm={__init__:["defaultRenderer"],defaultRenderer:["type",Qn],styles:["type",kl]};N();function Oe(e,t){if(!e||!t)return-1;var n=e.indexOf(t);return n!==-1&&e.splice(n,1),n}function Ae(e,t,n){if(!(!e||!t)){typeof n!="number"&&(n=-1);var r=e.indexOf(t);if(r!==-1){if(r===n)return;if(n!==-1)e.splice(r,1);else return}n!==-1?e.splice(n,0,t):e.push(t)}}function co(e,t){return!e||!t?-1:e.indexOf(t)}N();N();function Gr(e,t){return!e||!t?-1:Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function uo(e,t,n,r){if(typeof r=="undefined"&&(r=5),!e||!t||!n)return!1;var i=(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x),o=Gr(e,t);return Math.abs(i/o)<=r}var j0=2;function en(e,t){var n=Array.from(arguments).flat();let r={x:"v",y:"h"};for(let[i,o]of Object.entries(r))if(F0(i,n))return o;return!1}function F0(e,t){let n=t[0];return ln(t,function(r){return Math.abs(n[e]-r[e])<=j0})}function Nl(e,t,n){return n=n||0,e.x>t.x-n&&e.y>t.y-n&&e.x<t.x+t.width+n&&e.y<t.y+t.height+n}function Ma(e,t){return{x:Math.round(e.x+(t.x-e.x)/2),y:Math.round(e.y+(t.y-e.y)/2)}}var H0=/,?([a-z]),?/gi,gm=parseFloat,pt=Math,Vr=pt.PI,Jn=pt.min,er=pt.max,ym=pt.pow,Ur=pt.abs,$0=/([a-z])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?[\s]*,?[\s]*)+)/ig,z0=/(-?\d*\.?\d*(?:e[-+]?\d+)?)[\s]*,?[\s]*/ig,_m=Array.isArray||function(e){return e instanceof Array};function G0(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function V0(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return e.push(e.splice(n,1)[0])}function W0(e){function t(){var n=Array.prototype.slice.call(arguments,0),r=n.join("\u2400"),i=t.cache=t.cache||{},o=t.count=t.count||[];return G0(i,r)?(V0(o,r),i[r]):(o.length>=1e3&&delete i[o.shift()],o.push(r),i[r]=e(...arguments),i[r])}return t}function U0(e){if(!e)return null;var t={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},n=[];return String(e).replace($0,function(r,i,o){var a=[],s=i.toLowerCase();for(o.replace(z0,function(c,u){u&&a.push(+u)}),s=="m"&&a.length>2&&(n.push([i,...a.splice(0,2)]),s="l",i=i=="m"?"l":"L");a.length>=t[s]&&(n.push([i,...a.splice(0,t[s])]),!!t[s]););}),n.toString=Bl,n}function q0(e){for(var t=0,n=e.length;t<n;t++){var r=e[t][0];if(typeof r=="string"&&r!==r.toUpperCase())return!1}return!0}function K0(e){for(var t=0,n=e.length;t<n;t++){var r=e[t][0];if(r!=="M"&&r!=="C")return!1}return!0}function Ol(e,t,n,r){return arguments.length===1&&(t=e.y,n=e.width,r=e.height,e=e.x),{x:e,y:t,width:n,height:r,x2:e+n,y2:t+r}}function Bl(){return this.join(",").replace(H0,"$1")}function Y0(e){for(var t=new Array(e.length),n=0,r=e.length;n<r;n++)for(var i=e[n],o=t[n]=new Array(i.length),a=0,s=i.length;a<s;a++)o[a]=i[a];return t.toString=Bl,t}function bm(e,t,n,r,i,o,a,s,c){var u=1-c,p=ym(u,3),l=ym(u,2),f=c*c,d=f*c,m=p*e+l*3*c*n+u*3*c*c*i+d*a,g=p*t+l*3*c*r+u*3*c*c*o+d*s;return{x:Ec(m),y:Ec(g)}}function xm(e){var t=tw(...e);return Ol(t.x0,t.y0,t.x1-t.x0,t.y1-t.y0)}function Wr(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function X0(e,t){return e=Ol(e),t=Ol(t),Wr(t,e.x,e.y)||Wr(t,e.x2,e.y)||Wr(t,e.x,e.y2)||Wr(t,e.x2,e.y2)||Wr(e,t.x,t.y)||Wr(e,t.x2,t.y)||Wr(e,t.x,t.y2)||Wr(e,t.x2,t.y2)||(e.x<t.x2&&e.x>t.x||t.x<e.x2&&t.x>e.x)&&(e.y<t.y2&&e.y>t.y||t.y<e.y2&&t.y>e.y)}function Em(e,t,n,r,i){var o=-3*t+9*n-9*r+3*i,a=e*o+6*t-12*n+6*r;return e*a-3*t+3*n}function wm(e,t,n,r,i,o,a,s,c){c==null&&(c=1),c=c>1?1:c<0?0:c;for(var u=c/2,p=12,l=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],f=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],d=0,m=0;m<p;m++){var g=u*l[m]+u,v=Em(g,e,n,i,a),w=Em(g,t,r,o,s),S=v*v+w*w;d+=f[m]*pt.sqrt(S)}return u*d}function Z0(e,t,n,r,i,o,a,s){if(!(er(e,n)<Jn(i,a)||Jn(e,n)>er(i,a)||er(t,r)<Jn(o,s)||Jn(t,r)>er(o,s))){var c=(e*r-t*n)*(i-a)-(e-n)*(i*s-o*a),u=(e*r-t*n)*(o-s)-(t-r)*(i*s-o*a),p=(e-n)*(o-s)-(t-r)*(i-a);if(p){var l=Ec(c/p),f=Ec(u/p),d=+l.toFixed(2),m=+f.toFixed(2);if(!(d<+Jn(e,n).toFixed(2)||d>+er(e,n).toFixed(2)||d<+Jn(i,a).toFixed(2)||d>+er(i,a).toFixed(2)||m<+Jn(t,r).toFixed(2)||m>+er(t,r).toFixed(2)||m<+Jn(o,s).toFixed(2)||m>+er(o,s).toFixed(2)))return{x:l,y:f}}}}function Ec(e){return Math.round(e*1e11)/1e11}function Q0(e,t,n){var r=xm(e),i=xm(t);if(!X0(r,i))return n?0:[];var o=wm(...e),a=wm(...t),s=Sm(e)?1:~~(o/5)||1,c=Sm(t)?1:~~(a/5)||1,u=new Array(s+1),p=new Array(c+1),l={},f=n?0:[],d,m;for(d=0;d<s+1;d++){var g=bm(...e,d/s);u[d]={x:g.x,y:g.y,t:d/s}}for(d=0;d<c+1;d++)g=bm(...t,d/c),p[d]={x:g.x,y:g.y,t:d/c};for(d=0;d<s;d++)for(m=0;m<c;m++){var v=u[d],w=u[d+1],S=p[m],x=p[m+1],b=Ur(w.x-v.x)<.01?"y":"x",R=Ur(x.x-S.x)<.01?"y":"x",A=Z0(v.x,v.y,w.x,w.y,S.x,S.y,x.x,x.y),O;if(A){if(O=A.x.toFixed(9)+"#"+A.y.toFixed(9),l[O])continue;l[O]=!0;var T=v.t+Ur((A[b]-v[b])/(w[b]-v[b]))*(w.t-v.t),I=S.t+Ur((A[R]-S[R])/(x[R]-S[R]))*(x.t-S.t);T>=0&&T<=1&&I>=0&&I<=1&&(n?f++:f.push({x:A.x,y:A.y,t1:T,t2:I}))}}return f}function Da(e,t,n){e=Rm(e),t=Rm(t);for(var r,i,o,a,s,c,u,p,l,f,d=n?0:[],m=0,g=e.length;m<g;m++){var v=e[m];if(v[0]=="M")r=s=v[1],i=c=v[2];else{v[0]=="C"?(l=[r,i,...v.slice(1)],r=l[6],i=l[7]):(l=[r,i,r,i,s,c,s,c],r=s,i=c);for(var w=0,S=t.length;w<S;w++){var x=t[w];if(x[0]=="M")o=u=x[1],a=p=x[2];else{x[0]=="C"?(f=[o,a,...x.slice(1)],o=f[6],a=f[7]):(f=[o,a,o,a,u,p,u,p],o=u,a=p);var b=Q0(l,f,n);if(n)d+=b;else{for(var R=0,A=b.length;R<A;R++)b[R].segment1=m,b[R].segment2=w,b[R].bez1=l,b[R].bez2=f;d=d.concat(b)}}}}}return d}function J0(e){return _m(e)&&_m(e[0])}function ew(e){if(q0(e))return e;var t=new Array(e.length),n=0,r=0,i=0,o=0,a=0,s;e[0][0]=="M"&&(n=+e[0][1],r=+e[0][2],i=n,o=r,a++,t[0]=["M",n,r]);for(var c,u,p=a,l=e.length;p<l;p++){if(u=e[p],s=u[0],t[p]=c=new Array(u.length),s!=s.toUpperCase())switch(c[0]=s.toUpperCase(),c[0]){case"A":c[1]=u[1],c[2]=u[2],c[3]=u[3],c[4]=u[4],c[5]=u[5],c[6]=+u[6]+n,c[7]=+u[7]+r;break;case"V":c[1]=+u[1]+r;break;case"H":c[1]=+u[1]+n;break;case"M":i=+u[1]+n,o=+u[2]+r;default:for(var f=1,d=u.length;f<d;f++)c[f]=+u[f]+(f%2?n:r)}else for(var m=0,g=u.length;m<g;m++)c[m]=u[m];switch(s=s.toUpperCase(),c[0]){case"Z":n=+i,r=+o;break;case"H":n=c[1];break;case"V":r=c[1];break;case"M":i=c[c.length-2],o=c[c.length-1];default:n=c[c.length-2],r=c[c.length-1]}}return t.toString=Bl,t}function Sm(e){return e[0]===e[2]&&e[1]===e[3]&&e[4]===e[6]&&e[5]===e[7]}function xc(e,t,n,r){return[e,t,n,r,n,r]}function Cm(e,t,n,r,i,o){var a=.3333333333333333,s=2/3;return[a*e+s*n,a*t+s*r,a*i+s*n,a*o+s*r,i,o]}function Pm(e,t,n,r,i,o,a,s,c,u){var p=Vr*120/180,l=Vr/180*(+i||0),f=[],d,m=W0(function(P,_,y){var M=P*pt.cos(y)-_*pt.sin(y),D=P*pt.sin(y)+_*pt.cos(y);return{x:M,y:D}});if(u)O=u[0],T=u[1],R=u[2],A=u[3];else{d=m(e,t,-l),e=d.x,t=d.y,d=m(s,c,-l),s=d.x,c=d.y;var g=(e-s)/2,v=(t-c)/2,w=g*g/(n*n)+v*v/(r*r);w>1&&(w=pt.sqrt(w),n=w*n,r=w*r);var S=n*n,x=r*r,b=(o==a?-1:1)*pt.sqrt(Ur((S*x-S*v*v-x*g*g)/(S*v*v+x*g*g))),R=b*n*v/r+(e+s)/2,A=b*-r*g/n+(t+c)/2,O=pt.asin(((t-A)/r).toFixed(9)),T=pt.asin(((c-A)/r).toFixed(9));O=e<R?Vr-O:O,T=s<R?Vr-T:T,O<0&&(O=Vr*2+O),T<0&&(T=Vr*2+T),a&&O>T&&(O=O-Vr*2),!a&&T>O&&(T=T-Vr*2)}var I=T-O;if(Ur(I)>p){var L=T,W=s,z=c;T=O+p*(a&&T>O?1:-1),s=R+n*pt.cos(T),c=A+r*pt.sin(T),f=Pm(s,c,n,r,i,0,a,W,z,[T,L,R,A])}I=T-O;var K=pt.cos(O),ve=pt.sin(O),Jt=pt.cos(T),ke=pt.sin(T),ye=pt.tan(I/4),he=4/3*n*ye,we=4/3*r*ye,Ie=[e,t],Ze=[e+he*ve,t-we*K],H=[s+he*ke,c-we*Jt],G=[s,c];if(Ze[0]=2*Ie[0]-Ze[0],Ze[1]=2*Ie[1]-Ze[1],u)return[Ze,H,G].concat(f);f=[Ze,H,G].concat(f).join().split(",");for(var oe=[],xe=0,Gt=f.length;xe<Gt;xe++)oe[xe]=xe%2?m(f[xe-1],f[xe],l).y:m(f[xe],f[xe+1],l).x;return oe}function tw(e,t,n,r,i,o,a,s){for(var c=[],u=[[],[]],p,l,f,d,m,g,v,w,S=0;S<2;++S){if(S==0?(l=6*e-12*n+6*i,p=-3*e+9*n-9*i+3*a,f=3*n-3*e):(l=6*t-12*r+6*o,p=-3*t+9*r-9*o+3*s,f=3*r-3*t),Ur(p)<1e-12){if(Ur(l)<1e-12)continue;d=-f/l,0<d&&d<1&&c.push(d);continue}v=l*l-4*f*p,w=pt.sqrt(v),!(v<0)&&(m=(-l+w)/(2*p),0<m&&m<1&&c.push(m),g=(-l-w)/(2*p),0<g&&g<1&&c.push(g))}for(var x=c.length,b=x,R;x--;)d=c[x],R=1-d,u[0][x]=R*R*R*e+3*R*R*d*n+3*R*d*d*i+d*d*d*a,u[1][x]=R*R*R*t+3*R*R*d*r+3*R*d*d*o+d*d*d*s;return u[0][b]=e,u[1][b]=t,u[0][b+1]=a,u[1][b+1]=s,u[0].length=u[1].length=b+2,{x0:Jn(...u[0]),y0:Jn(...u[1]),x1:er(...u[0]),y1:er(...u[1])}}function Rm(e){if(J0(e)||(e=U0(e)),K0(e))return e;for(var t=Y0(ew(e)),n={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},r=function(f,d,m){var g,v;if(!f)return["C",d.x,d.y,d.x,d.y,d.x,d.y];switch(!(f[0]in{T:1,Q:1})&&(d.qx=d.qy=null),f[0]){case"M":d.X=f[1],d.Y=f[2];break;case"A":f=["C",...Pm(d.x,d.y,...f.slice(1))];break;case"S":m=="C"||m=="S"?(g=d.x*2-d.bx,v=d.y*2-d.by):(g=d.x,v=d.y),f=["C",g,v,...f.slice(1)];break;case"T":m=="Q"||m=="T"?(d.qx=d.x*2-d.qx,d.qy=d.y*2-d.qy):(d.qx=d.x,d.qy=d.y),f=["C",...Cm(d.x,d.y,d.qx,d.qy,f[1],f[2])];break;case"Q":d.qx=f[1],d.qy=f[2],f=["C",...Cm(d.x,d.y,f[1],f[2],f[3],f[4])];break;case"L":f=["C",...xc(d.x,d.y,f[1],f[2])];break;case"H":f=["C",...xc(d.x,d.y,f[1],d.y)];break;case"V":f=["C",...xc(d.x,d.y,d.x,f[1])];break;case"Z":f=["C",...xc(d.x,d.y,d.X,d.Y)];break}return f},i=function(f,d){if(f[d].length>7){f[d].shift();for(var m=f[d];m.length;)o[d]="A",f.splice(d++,0,["C",...m.splice(0,6)]);f.splice(d,1),u=t.length}},o=[],a="",s="",c=0,u=t.length;c<u;c++){t[c]&&(a=t[c][0]),a!="C"&&(o[c]=a,c&&(s=o[c-1])),t[c]=r(t[c],n,s),o[c]!="A"&&a=="C"&&(o[c]="C"),i(t,c);var p=t[c],l=p.length;n.x=p[l-2],n.y=p[l-1],n.bx=gm(p[l-4])||n.x,n.by=gm(p[l-3])||n.y}return t}N();function de(e){return Se(e)&&dt(e,"waypoints")}function ee(e){return Se(e)&&dt(e,"labelTarget")}function wc(e){return{x:Math.round(e.x),y:Math.round(e.y),width:Math.round(e.width),height:Math.round(e.height)}}function Rn(e){return{x:Math.round(e.x),y:Math.round(e.y)}}function Z(e){return{top:e.y,right:e.x+(e.width||0),bottom:e.y+(e.height||0),left:e.x}}function Si(e){return{x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top}}function nw(e){return Rn({x:e.x+(e.width||0)/2,y:e.y+(e.height||0)/2})}function rw(e){for(var t=e.waypoints,n=t.reduce(function(u,p,l){var f=t[l-1];if(f){var d=u[u.length-1],m=d&&d.endLength||0,g=ow(f,p);u.push({start:f,end:p,startLength:m,endLength:m+g,length:g})}return u},[]),r=n.reduce(function(u,p){return u+p.length},0),i=r/2,o=0,a=n[o];a.endLength<i;)a=n[++o];var s=(i-a.startLength)/a.length,c={x:a.start.x+(a.end.x-a.start.x)*s,y:a.start.y+(a.end.y-a.start.y)*s};return c}function X(e){return de(e)?rw(e):nw(e)}function He(e,t,n){n=n||0,Se(n)||(n={x:n,y:n});var r=Z(e),i=Z(t),o=r.bottom+n.y<=i.top,a=r.left-n.x>=i.right,s=r.top-n.y>=i.bottom,c=r.right+n.x<=i.left,u=o?"top":s?"bottom":null,p=c?"left":a?"right":null;return p&&u?u+"-"+p:p||u||"intersect"}function qr(e,t,n){var r=iw(e,t);return r.length===1||r.length===2&&Gr(r[0],r[1])<1?Rn(r[0]):r.length>1?(r=At(r,function(i){var o=Math.floor(i.t2*100)||1;return o=100-o,o=(o<10?"0":"")+o,i.segment2+"#"+o}),Rn(r[n?0:r.length-1])):null}function iw(e,t){return Da(e,t)}function Am(e){e=e.slice();for(var t=0,n,r,i;e[t];)n=e[t],r=e[t-1],i=e[t+1],Gr(n,i)===0||uo(r,i,n)?e.splice(t,1):t++;return e}function ow(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Sc(e,t){return Math.round(e*t)/t}function Tm(e){return ne(e)?e+"px":e}function aw(e){for(;e.parent;)e=e.parent;return e}function sw(e){e=C({},{width:"100%",height:"100%"},e);let t=e.container||document.body,n=document.createElement("div");return n.setAttribute("class","djs-container djs-parent"),vt(n,{position:"relative",overflow:"hidden",width:Tm(e.width),height:Tm(e.height)}),t.appendChild(n),n}function Mm(e,t,n){let r=U("g");pe(r).add(t);let i=n!==void 0?n:e.childNodes.length-1;return e.insertBefore(r,e.childNodes[i]||null),r}var cw="base",Dm=0,uw=1,pw={shape:["x","y","width","height"],connection:["waypoints"]};function le(e,t,n,r){this._eventBus=t,this._elementRegistry=r,this._graphicsFactory=n,this._rootsIdx=0,this._layers={},this._planes=[],this._rootElement=null,this._focused=!1,this._init(e||{})}le.$inject=["config.canvas","eventBus","graphicsFactory","elementRegistry"];le.prototype._init=function(e){let t=this._eventBus,n=this._container=sw(e),r=this._svg=U("svg");$(r,{width:"100%",height:"100%"}),nt(r,"tabindex",0),e.autoFocus&&t.on("element.hover",()=>{this.restoreFocus()}),t.on("element.mousedown",500,o=>{this.focus()}),r.addEventListener("focusin",()=>{this._setFocused(!0)}),r.addEventListener("focusout",()=>{this._setFocused(!1)}),r.addEventListener("mouseover",()=>{this._eventBus.fire("canvas.mouseover")}),r.addEventListener("mouseout",()=>{this._eventBus.fire("canvas.mouseout")}),J(n,r);let i=this._viewport=Mm(r,"viewport");e.deferUpdate&&(this._viewboxChanged=Ca(tt(this._viewboxChanged,this),300)),t.on("diagram.init",()=>{t.fire("canvas.init",{svg:r,viewport:i})}),t.on(["shape.added","connection.added","shape.removed","connection.removed","elements.changed","root.set"],()=>{delete this._cachedViewbox}),t.on("diagram.destroy",500,this._destroy,this),t.on("diagram.clear",500,this._clear,this)};le.prototype._destroy=function(){this._eventBus.fire("canvas.destroy",{svg:this._svg,viewport:this._viewport});let e=this._container.parentNode;e&&e.removeChild(this._container),delete this._svg,delete this._container,delete this._layers,delete this._planes,delete this._rootElement,delete this._viewport};le.prototype._setFocused=function(e){e!=this._focused&&(this._focused=e,this._eventBus.fire("canvas.focus.changed",{focused:e}))};le.prototype._clear=function(){this._elementRegistry.getAll().forEach(t=>{let n=_c(t);n==="root"?this.removeRootElement(t):this._removeElement(t,n)}),this._planes=[],this._rootElement=null,delete this._cachedViewbox};le.prototype.focus=function(){this._svg.focus({preventScroll:!0}),this._setFocused(!0)};le.prototype.restoreFocus=function(){document.activeElement===document.body&&this.focus()};le.prototype.isFocused=function(){return this._focused};le.prototype.getDefaultLayer=function(){return this.getLayer(cw,Dm)};le.prototype.getLayer=function(e,t){if(!e)throw new Error("must specify a name");let n=this._layers[e];if(n||(n=this._layers[e]=this._createLayer(e,t)),typeof t!="undefined"&&n.index!==t)throw new Error("layer <"+e+"> already created at index <"+t+">");return n.group};le.prototype._getChildIndex=function(e){return Ge(this._layers,function(t,n){return n.visible&&e>=n.index&&t++,t},0)};le.prototype._createLayer=function(e,t){typeof t=="undefined"&&(t=uw);let n=this._getChildIndex(t);return{group:Mm(this._viewport,"layer-"+e,n),index:t,visible:!0}};le.prototype.showLayer=function(e){if(!e)throw new Error("must specify a name");let t=this._layers[e];if(!t)throw new Error("layer <"+e+"> does not exist");let n=this._viewport,r=t.group,i=t.index;if(t.visible)return r;let o=this._getChildIndex(i);return n.insertBefore(r,n.childNodes[o]||null),t.visible=!0,r};le.prototype.hideLayer=function(e){if(!e)throw new Error("must specify a name");let t=this._layers[e];if(!t)throw new Error("layer <"+e+"> does not exist");let n=t.group;return t.visible&&(Pe(n),t.visible=!1),n};le.prototype._removeLayer=function(e){let t=this._layers[e];t&&(delete this._layers[e],Pe(t.group))};le.prototype.getActiveLayer=function(){let e=this._findPlaneForRoot(this.getRootElement());return e?e.layer:null};le.prototype.findRoot=function(e){return typeof e=="string"&&(e=this._elementRegistry.get(e)),e?(this._findPlaneForRoot(aw(e))||{}).rootElement:void 0};le.prototype.getRootElements=function(){return this._planes.map(function(e){return e.rootElement})};le.prototype._findPlaneForRoot=function(e){return re(this._planes,function(t){return t.rootElement===e})};le.prototype.getContainer=function(){return this._container};le.prototype._updateMarker=function(e,t,n){let r;e.id||(e=this._elementRegistry.get(e)),e.markers=e.markers||new Set,r=this._elementRegistry._elements[e.id],r&&(E([r.gfx,r.secondaryGfx],function(i){i&&(n?(e.markers.add(t),pe(i).add(t)):(e.markers.delete(t),pe(i).remove(t)))}),this._eventBus.fire("element.marker.update",{element:e,gfx:r.gfx,marker:t,add:!!n}))};le.prototype.addMarker=function(e,t){this._updateMarker(e,t,!0)};le.prototype.removeMarker=function(e,t){this._updateMarker(e,t,!1)};le.prototype.hasMarker=function(e,t){return e.id||(e=this._elementRegistry.get(e)),e.markers?e.markers.has(t):!1};le.prototype.toggleMarker=function(e,t){this.hasMarker(e,t)?this.removeMarker(e,t):this.addMarker(e,t)};le.prototype.getRootElement=function(){let e=this._rootElement;return e||this._planes.length?e:this.setRootElement(this.addRootElement(null))};le.prototype.addRootElement=function(e){let t=this._rootsIdx++;e||(e={id:"__implicitroot_"+t,children:[],isImplicit:!0});let n=e.layer="root-"+t;this._ensureValid("root",e);let r=this.getLayer(n,Dm);return this.hideLayer(n),this._addRoot(e,r),this._planes.push({rootElement:e,layer:r}),e};le.prototype.removeRootElement=function(e){if(typeof e=="string"&&(e=this._elementRegistry.get(e)),!!this._findPlaneForRoot(e))return this._removeRoot(e),this._removeLayer(e.layer),this._planes=this._planes.filter(function(n){return n.rootElement!==e}),this._rootElement===e&&(this._rootElement=null),e};le.prototype.setRootElement=function(e){if(e===this._rootElement)return e;let t;if(!e)throw new Error("rootElement required");return t=this._findPlaneForRoot(e),t||(e=this.addRootElement(e)),this._setRoot(e),e};le.prototype._removeRoot=function(e){let t=this._elementRegistry,n=this._eventBus;n.fire("root.remove",{element:e}),n.fire("root.removed",{element:e}),t.remove(e)};le.prototype._addRoot=function(e,t){let n=this._elementRegistry,r=this._eventBus;r.fire("root.add",{element:e}),n.add(e,t),r.fire("root.added",{element:e,gfx:t})};le.prototype._setRoot=function(e,t){let n=this._rootElement;n&&(this._elementRegistry.updateGraphics(n,null,!0),this.hideLayer(n.layer)),e&&(t||(t=this._findPlaneForRoot(e).layer),this._elementRegistry.updateGraphics(e,this._svg,!0),this.showLayer(e.layer)),this._rootElement=e,this._eventBus.fire("root.set",{element:e})};le.prototype._ensureValid=function(e,t){if(!t.id)throw new Error("element must have an id");if(this._elementRegistry.get(t.id))throw new Error("element <"+t.id+"> already exists");let n=pw[e];if(!ln(n,function(i){return typeof t[i]!="undefined"}))throw new Error("must supply { "+n.join(", ")+" } with "+e)};le.prototype._setParent=function(e,t,n){Ae(t.children,e,n),e.parent=t};le.prototype._addElement=function(e,t,n,r){n=n||this.getRootElement();let i=this._eventBus,o=this._graphicsFactory;this._ensureValid(e,t),i.fire(e+".add",{element:t,parent:n}),this._setParent(t,n,r);let a=o.create(e,t,r);return this._elementRegistry.add(t,a),o.update(e,t,a),i.fire(e+".added",{element:t,gfx:a}),t};le.prototype.addShape=function(e,t,n){return this._addElement("shape",e,t,n)};le.prototype.addConnection=function(e,t,n){return this._addElement("connection",e,t,n)};le.prototype._removeElement=function(e,t){let n=this._elementRegistry,r=this._graphicsFactory,i=this._eventBus;if(e=n.get(e.id||e),!!e)return i.fire(t+".remove",{element:e}),r.remove(e),Oe(e.parent&&e.parent.children,e),e.parent=null,i.fire(t+".removed",{element:e}),n.remove(e),e};le.prototype.removeShape=function(e){return this._removeElement(e,"shape")};le.prototype.removeConnection=function(e){return this._removeElement(e,"connection")};le.prototype.getGraphics=function(e,t){return this._elementRegistry.getGraphics(e,t)};le.prototype._changeViewbox=function(e){this._eventBus.fire("canvas.viewbox.changing"),e.apply(this),this._cachedViewbox=null,this._viewboxChanged()};le.prototype._viewboxChanged=function(){this._eventBus.fire("canvas.viewbox.changed",{viewbox:this.viewbox()})};le.prototype.viewbox=function(e){if(e===void 0&&this._cachedViewbox)return structuredClone(this._cachedViewbox);let t=this._viewport,n=this.getSize(),r,i,o,a,s,c,u;if(e)this._changeViewbox(function(){s=Math.min(n.width/e.width,n.height/e.height);let p=this._svg.createSVGMatrix().scale(s).translate(-e.x,-e.y);Ei(t,p)});else return o=this._rootElement?this.getActiveLayer():null,r=o&&o.getBBox()||{},a=Ei(t),i=a?a.matrix:lm(),s=Sc(i.a,1e3),c=Sc(-i.e||0,1e3),u=Sc(-i.f||0,1e3),e=this._cachedViewbox={x:c?c/s:0,y:u?u/s:0,width:n.width/s,height:n.height/s,scale:s,inner:{width:r.width||0,height:r.height||0,x:r.x||0,y:r.y||0},outer:n},e;return e};le.prototype.scroll=function(e){let t=this._viewport,n=t.getCTM();return e&&this._changeViewbox(function(){e=C({dx:0,dy:0},e||{}),n=this._svg.createSVGMatrix().translate(e.dx,e.dy).multiply(n),km(t,n)}),{x:n.e,y:n.f}};le.prototype.scrollToElement=function(e,t){let n=100;typeof e=="string"&&(e=this._elementRegistry.get(e));let r=this.findRoot(e);if(r!==this.getRootElement()&&this.setRootElement(r),r===e)return;t||(t={}),typeof t=="number"&&(n=t),t={top:t.top||n,right:t.right||n,bottom:t.bottom||n,left:t.left||n};let i=Ce(e),o=Z(i),a=this.viewbox(),s=this.zoom(),c,u;a.y+=t.top/s,a.x+=t.left/s,a.width-=(t.right+t.left)/s,a.height-=(t.bottom+t.top)/s;let p=Z(a);if(!(i.width<a.width&&i.height<a.height))c=i.x-a.x,u=i.y-a.y;else{let f=Math.max(0,o.right-p.right),d=Math.min(0,o.left-p.left),m=Math.max(0,o.bottom-p.bottom),g=Math.min(0,o.top-p.top);c=f||d,u=m||g}this.scroll({dx:-c*s,dy:-u*s})};le.prototype.zoom=function(e,t){if(!e)return this.viewbox(e).scale;if(e==="fit-viewport")return this._fitViewport(t);let n,r;return this._changeViewbox(function(){typeof t!="object"&&(n=this.viewbox().outer,t={x:n.width/2,y:n.height/2}),r=this._setZoom(e,t)}),Sc(r.a,1e3)};function km(e,t){let n="matrix("+t.a+","+t.b+","+t.c+","+t.d+","+t.e+","+t.f+")";e.setAttribute("transform",n)}le.prototype._fitViewport=function(e){let t=this.viewbox(),n=t.outer,r=t.inner,i,o;return r.x>=0&&r.y>=0&&r.x+r.width<=n.width&&r.y+r.height<=n.height&&!e?o={x:0,y:0,width:Math.max(r.width+r.x,n.width),height:Math.max(r.height+r.y,n.height)}:(i=Math.min(1,n.width/r.width,n.height/r.height),o={x:r.x+(e?r.width/2-n.width/i/2:0),y:r.y+(e?r.height/2-n.height/i/2:0),width:n.width/i,height:n.height/i}),this.viewbox(o),this.viewbox(!1).scale};le.prototype._setZoom=function(e,t){let n=this._svg,r=this._viewport,i=n.createSVGMatrix(),o=n.createSVGPoint(),a,s,c,u,p;c=r.getCTM();let l=c.a;return t?(a=C(o,t),s=a.matrixTransform(c.inverse()),u=i.translate(s.x,s.y).scale(1/l*e).translate(-s.x,-s.y),p=c.multiply(u)):p=i.scale(e),km(this._viewport,p),p};le.prototype.getSize=function(){return{width:this._container.clientWidth,height:this._container.clientHeight}};le.prototype.getAbsoluteBBox=function(e){let t=this.viewbox(),n;e.waypoints?n=this.getGraphics(e).getBBox():n=e;let r=n.x*t.scale-t.x*t.scale,i=n.y*t.scale-t.y*t.scale,o=n.width*t.scale,a=n.height*t.scale;return{x:r,y:i,width:o,height:a}};le.prototype.resized=function(){delete this._cachedViewbox,this._eventBus.fire("canvas.resized")};var po="data-element-id";function Ut(e){this._elements={},this._eventBus=e}Ut.$inject=["eventBus"];Ut.prototype.add=function(e,t,n){var r=e.id;this._validateId(r),$(t,po,r),n&&$(n,po,r),this._elements[r]={element:e,gfx:t,secondaryGfx:n}};Ut.prototype.remove=function(e){var t=this._elements,n=e.id||e,r=n&&t[n];r&&($(r.gfx,po,""),r.secondaryGfx&&$(r.secondaryGfx,po,""),delete t[n])};Ut.prototype.updateId=function(e,t){this._validateId(t),typeof e=="string"&&(e=this.get(e)),this._eventBus.fire("element.updateId",{element:e,newId:t});var n=this.getGraphics(e),r=this.getGraphics(e,!0);this.remove(e),e.id=t,this.add(e,n,r)};Ut.prototype.updateGraphics=function(e,t,n){var r=e.id||e,i=this._elements[r];return n?i.secondaryGfx=t:i.gfx=t,t&&$(t,po,r),t};Ut.prototype.get=function(e){var t;typeof e=="string"?t=e:t=e&&$(e,po);var n=this._elements[t];return n&&n.element};Ut.prototype.filter=function(e){var t=[];return this.forEach(function(n,r){e(n,r)&&t.push(n)}),t};Ut.prototype.find=function(e){for(var t=this._elements,n=Object.keys(t),r=0;r<n.length;r++){var i=n[r],o=t[i],a=o.element,s=o.gfx;if(e(a,s))return a}};Ut.prototype.getAll=function(){return this.filter(function(e){return e})};Ut.prototype.forEach=function(e){var t=this._elements;Object.keys(t).forEach(function(n){var r=t[n],i=r.element,o=r.gfx;return e(i,o)})};Ut.prototype.getGraphics=function(e,t){var n=e.id||e,r=this._elements[n];return r&&(t?r.secondaryGfx:r.gfx)};Ut.prototype._validateId=function(e){if(!e)throw new Error("element must have an id");if(this._elements[e])throw new Error("element with id "+e+" already added")};N();function lw(e,t,n,r){var i=n.inverse;return Object.defineProperty(e,"remove",{value:function(o){var a=this.indexOf(o);return a!==-1&&(this.splice(a,1),t.unset(o,i,r)),o}}),Object.defineProperty(e,"contains",{value:function(o){return this.indexOf(o)!==-1}}),Object.defineProperty(e,"add",{value:function(o,a){var s=this.indexOf(o);if(typeof a=="undefined"){if(s!==-1)return;a=this.length}s!==-1&&this.splice(s,1),this.splice(a,0,o),s===-1&&t.set(o,i,r)}}),Object.defineProperty(e,"__refs_collection",{value:!0}),e}function fw(e){return e.__refs_collection===!0}function dw(e,t){return Object.prototype.hasOwnProperty.call(e,t.name||t)}function Nm(e,t,n){var r=lw(n[t.name]||[],e,t,n);Object.defineProperty(n,t.name,{enumerable:t.enumerable,value:r}),r.length&&r.forEach(function(i){e.set(i,t.inverse,n)})}function mw(e,t,n){var r=t.inverse,i=n[t.name];Object.defineProperty(n,t.name,{configurable:t.configurable,enumerable:t.enumerable,get:function(){return i},set:function(o){if(o!==i){var a=i;i=null,a&&e.unset(a,r,n),i=o,e.set(i,r,n)}}})}function fn(e,t){if(!(this instanceof fn))return new fn(e,t);e.inverse=t,t.inverse=e,this.props={},this.props[e.name]=e,this.props[t.name]=t}fn.prototype.bind=function(e,t){if(typeof t=="string"){if(!this.props[t])throw new Error("no property <"+t+"> in ref");t=this.props[t]}t.collection?Nm(this,t,e):mw(this,t,e)};fn.prototype.ensureRefsCollection=function(e,t){var n=e[t.name];return fw(n)||Nm(this,t,e),n};fn.prototype.ensureBound=function(e,t){dw(e,t)||this.bind(e,t)};fn.prototype.unset=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).remove(n):e[t.name]=void 0)};fn.prototype.set=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).add(n):e[t.name]=n)};var Il=new fn({name:"children",enumerable:!0,collection:!0},{name:"parent"}),Bm=new fn({name:"labels",enumerable:!0,collection:!0},{name:"labelTarget"}),Om=new fn({name:"attachers",collection:!0},{name:"host"}),Im=new fn({name:"outgoing",collection:!0},{name:"source"}),Lm=new fn({name:"incoming",collection:!0},{name:"target"});function lo(){Object.defineProperty(this,"businessObject",{writable:!0}),Object.defineProperty(this,"label",{get:function(){return this.labels[0]},set:function(e){var t=this.label,n=this.labels;!e&&t?n.remove(t):n.add(e,0)}}),Il.bind(this,"parent"),Bm.bind(this,"labels"),Im.bind(this,"outgoing"),Lm.bind(this,"incoming")}function ka(){lo.call(this),Il.bind(this,"children"),Om.bind(this,"host"),Om.bind(this,"attachers")}B(ka,lo);function jm(){lo.call(this),Il.bind(this,"children")}B(jm,ka);function Fm(){ka.call(this),Bm.bind(this,"labelTarget")}B(Fm,ka);function Hm(){lo.call(this),Im.bind(this,"source"),Lm.bind(this,"target")}B(Hm,lo);var hw={connection:Hm,shape:ka,label:Fm,root:jm};function $m(e,t){var n=hw[e];if(!n)throw new Error("unknown type: <"+e+">");return C(new n,t)}function zm(e){return e instanceof lo}N();function Pn(){this._uid=12}Pn.prototype.createRoot=function(e){return this.create("root",e)};Pn.prototype.createLabel=function(e){return this.create("label",e)};Pn.prototype.createShape=function(e){return this.create("shape",e)};Pn.prototype.createConnection=function(e){return this.create("connection",e)};Pn.prototype.create=function(e,t){return t=C({},t||{}),t.id||(t.id=e+"_"+this._uid++),$m(e,t)};N();var Cc="__fn",Gm=1e3,vw=Array.prototype.slice;function jt(){this._listeners={},this.on("diagram.destroy",1,this._destroy,this)}jt.prototype.on=function(e,t,n,r){if(e=q(e)?e:[e],Le(t)&&(r=n,n=t,t=Gm),!ne(t))throw new Error("priority must be a number");var i=n;r&&(i=tt(n,r),i[Cc]=n[Cc]||n);var o=this;e.forEach(function(a){o._addListener(a,{priority:t,callback:i,next:null})})};jt.prototype.once=function(e,t,n,r){var i=this;if(Le(t)&&(r=n,n=t,t=Gm),!ne(t))throw new Error("priority must be a number");function o(){o.__isTomb=!0;var a=n.apply(r,arguments);return i.off(e,o),a}o[Cc]=n,this.on(e,t,o)};jt.prototype.off=function(e,t){e=q(e)?e:[e];var n=this;e.forEach(function(r){n._removeListener(r,t)})};jt.prototype.createEvent=function(e){var t=new Na;return t.init(e),t};jt.prototype.fire=function(e,t){var n,r,i,o;if(o=vw.call(arguments),typeof e=="object"&&(t=e,e=t.type),!e)throw new Error("no event type specified");if(r=this._listeners[e],!!r){t instanceof Na?n=t:n=this.createEvent(t),o[0]=n;var a=n.type;e!==a&&(n.type=e);try{i=this._invokeListeners(n,o,r)}finally{e!==a&&(n.type=a)}return i===void 0&&n.defaultPrevented&&(i=!1),i}};jt.prototype.handleError=function(e){return this.fire("error",{error:e})===!1};jt.prototype._destroy=function(){this._listeners={}};jt.prototype._invokeListeners=function(e,t,n){for(var r;n&&!e.cancelBubble;)r=this._invokeListener(e,t,n),n=n.next;return r};jt.prototype._invokeListener=function(e,t,n){var r;if(n.callback.__isTomb)return r;try{r=gw(n.callback,t),r!==void 0&&(e.returnValue=r,e.stopPropagation()),r===!1&&e.preventDefault()}catch(i){if(!this.handleError(i))throw console.error("unhandled error in event listener",i),i}return r};jt.prototype._addListener=function(e,t){var n=this._getListeners(e),r;if(!n){this._setListeners(e,t);return}for(;n;){if(n.priority<t.priority){t.next=n,r?r.next=t:this._setListeners(e,t);return}r=n,n=n.next}r.next=t};jt.prototype._getListeners=function(e){return this._listeners[e]};jt.prototype._setListeners=function(e,t){this._listeners[e]=t};jt.prototype._removeListener=function(e,t){var n=this._getListeners(e),r,i,o;if(!t){this._setListeners(e,null);return}for(;n;)r=n.next,o=n.callback,(o===t||o[Cc]===t)&&(i?i.next=r:this._setListeners(e,r)),i=n,n=r};function Na(){}Na.prototype.stopPropagation=function(){this.cancelBubble=!0};Na.prototype.preventDefault=function(){this.defaultPrevented=!0};Na.prototype.init=function(e){C(this,e||{})};function gw(e,t){return e.apply(null,t)}N();function Ln(e){return e.childNodes[0]}function Vm(e){return e.parentNode.childNodes[1]}function fo(e,t,n,r,i){var o=so();o.setTranslate(t,n);var a=so();a.setRotate(r||0,0,0);var s=so();s.setScale(i||1,i||1),Ei(e,[o,a,s])}function Fe(e,t,n){var r=so();r.setTranslate(t,n),Ei(e,r)}function Rc(e,t){var n=so();n.setRotate(t,0,0),Ei(e,n)}function qt(e,t){this._eventBus=e,this._elementRegistry=t}qt.$inject=["eventBus","elementRegistry"];qt.prototype._getChildrenContainer=function(e){var t=this._elementRegistry.getGraphics(e),n;return e.parent?(n=Vm(t),n||(n=U("g"),pe(n).add("djs-children"),J(t.parentNode,n))):n=t,n};qt.prototype._clear=function(e){var t=Ln(e);return Hr(t),t};qt.prototype._createContainer=function(e,t,n,r){var i=U("g");pe(i).add("djs-group"),typeof n!="undefined"?Wm(i,t,t.childNodes[n]):J(t,i);var o=U("g");pe(o).add("djs-element"),pe(o).add("djs-"+e),r&&pe(o).add("djs-frame"),J(i,o);var a=U("g");return pe(a).add("djs-visual"),J(o,a),o};qt.prototype.create=function(e,t,n){var r=this._getChildrenContainer(t.parent);return this._createContainer(e,r,n,bc(t))};qt.prototype.updateContainments=function(e){var t=this,n=this._elementRegistry,r;r=Ge(e,function(i,o){return o.parent&&(i[o.parent.id]=o.parent),i},{}),E(r,function(i){var o=i.children;if(o){var a=t._getChildrenContainer(i);E(o.slice().reverse(),function(s){var c=n.getGraphics(s);Wm(c.parentNode,a)})}})};qt.prototype.drawShape=function(e,t,n={}){var r=this._eventBus;return r.fire("render.shape",{gfx:e,element:t,attrs:n})};qt.prototype.getShapePath=function(e){var t=this._eventBus;return t.fire("render.getShapePath",e)};qt.prototype.drawConnection=function(e,t,n={}){var r=this._eventBus;return r.fire("render.connection",{gfx:e,element:t,attrs:n})};qt.prototype.getConnectionPath=function(e){var t=this._eventBus;return t.fire("render.getConnectionPath",e)};qt.prototype.update=function(e,t,n){if(t.parent){var r=this._clear(n);if(e==="shape")this.drawShape(r,t),Fe(n,t.x,t.y);else if(e==="connection")this.drawConnection(r,t);else throw new Error("unknown type: "+e);t.hidden?$(n,"display","none"):$(n,"display","block")}};qt.prototype.remove=function(e){var t=this._elementRegistry.getGraphics(e);Pe(t.parentNode)};function Wm(e,t,n){var r=n||t.firstChild;e!==r&&t.insertBefore(e,r)}var Um={__depends__:[vm],__init__:["canvas"],canvas:["type",le],elementRegistry:["type",Ut],elementFactory:["type",Pn],eventBus:["type",jt],graphicsFactory:["type",qt]};function yw(e){var t=new Tl(e);return t.init(),t}function _w(e){e=e||{};var t={config:["value",e]},n=[t,Um].concat(e.modules||[]);return yw(n)}function tr(e,t){this._injector=t||_w(e),this.get("eventBus").fire("diagram.init")}tr.prototype.get=function(e,t){return this._injector.get(e,t)};tr.prototype.invoke=function(e,t,n){return this._injector.invoke(e,t,n)};tr.prototype.destroy=function(){this.get("eventBus").fire("diagram.destroy")};tr.prototype.clear=function(){this.get("eventBus").fire("diagram.clear")};N();N();function Fl(){}Fl.prototype.get=function(e){return this.$model.properties.get(this,e)};Fl.prototype.set=function(e,t){this.$model.properties.set(this,e,t)};function Km(e,t){this.model=e,this.properties=t}Km.prototype.createType=function(e){var t=this.model,n=this.properties,r=Object.create(Fl.prototype);E(e.properties,function(a){!a.isMany&&a.default!==void 0&&(r[a.name]=a.default)}),n.defineModel(r,t),n.defineDescriptor(r,e);var i=e.ns.name;function o(a){n.define(this,"$type",{value:i,enumerable:!0}),n.define(this,"$attrs",{value:{}}),n.define(this,"$parent",{writable:!0}),E(a,tt(function(s,c){this.set(c,s)},this))}return o.prototype=r,o.hasType=r.$instanceOf=this.model.hasType,n.defineModel(o,t),n.defineDescriptor(o,e),o};var bw={String:!0,Boolean:!0,Integer:!0,Real:!0,Element:!0},Ym={String:function(e){return e},Boolean:function(e){return e==="true"},Integer:function(e){return parseInt(e,10)},Real:function(e){return parseFloat(e)}};function Pc(e,t){var n=Ym[e];return n?n(t):t}function Ll(e){return!!bw[e]}function Hl(e){return!!Ym[e]}function Tt(e,t){var n=e.split(/:/),r,i;if(n.length===1)r=e,i=t;else if(n.length===2)r=n[1],i=n[0];else throw new Error("expected <prefix:localName> or <localName>, got "+e);return e=(i?i+":":"")+r,{name:e,prefix:i,localName:r}}function dn(e){this.ns=e,this.name=e.name,this.allTypes=[],this.allTypesByName={},this.properties=[],this.propertiesByName={}}dn.prototype.build=function(){return mt(this,["ns","name","allTypes","allTypesByName","properties","propertiesByName","bodyProperty","idProperty"])};dn.prototype.addProperty=function(e,t,n){typeof t=="boolean"&&(n=t,t=void 0),this.addNamedProperty(e,n!==!1);var r=this.properties;t!==void 0?r.splice(t,0,e):r.push(e)};dn.prototype.replaceProperty=function(e,t,n){var r=e.ns,i=this.properties,o=this.propertiesByName,a=e.name!==t.name;if(e.isId){if(!t.isId)throw new Error("property <"+t.ns.name+"> must be id property to refine <"+e.ns.name+">");this.setIdProperty(t,!1)}if(e.isBody){if(!t.isBody)throw new Error("property <"+t.ns.name+"> must be body property to refine <"+e.ns.name+">");this.setBodyProperty(t,!1)}var s=i.indexOf(e);if(s===-1)throw new Error("property <"+r.name+"> not found in property list");i.splice(s,1),this.addProperty(t,n?void 0:s,a),o[r.name]=o[r.localName]=t};dn.prototype.redefineProperty=function(e,t,n){var r=e.ns.prefix,i=t.split("#"),o=Tt(i[0],r),a=Tt(i[1],o.prefix).name,s=this.propertiesByName[a];if(s)this.replaceProperty(s,e,n);else throw new Error("refined property <"+a+"> not found");delete e.redefines};dn.prototype.addNamedProperty=function(e,t){var n=e.ns,r=this.propertiesByName;t&&(this.assertNotDefined(e,n.name),this.assertNotDefined(e,n.localName)),r[n.name]=r[n.localName]=e};dn.prototype.removeNamedProperty=function(e){var t=e.ns,n=this.propertiesByName;delete n[t.name],delete n[t.localName]};dn.prototype.setBodyProperty=function(e,t){if(t&&this.bodyProperty)throw new Error("body property defined multiple times (<"+this.bodyProperty.ns.name+">, <"+e.ns.name+">)");this.bodyProperty=e};dn.prototype.setIdProperty=function(e,t){if(t&&this.idProperty)throw new Error("id property defined multiple times (<"+this.idProperty.ns.name+">, <"+e.ns.name+">)");this.idProperty=e};dn.prototype.assertNotTrait=function(e){if((e.extends||[]).length)throw new Error(`cannot create <${e.name}> extending <${e.extends}>`)};dn.prototype.assertNotDefined=function(e,t){var n=e.name,r=this.propertiesByName[n];if(r)throw new Error("property <"+n+"> already defined; override of <"+r.definedBy.ns.name+"#"+r.ns.name+"> by <"+e.definedBy.ns.name+"#"+e.ns.name+"> not allowed without redefines")};dn.prototype.hasProperty=function(e){return this.propertiesByName[e]};dn.prototype.addTrait=function(e,t){t&&this.assertNotTrait(e);var n=this.allTypesByName,r=this.allTypes,i=e.name;i in n||(E(e.properties,tt(function(o){o=C({},o,{name:o.ns.localName,inherited:t}),Object.defineProperty(o,"definedBy",{value:e});var a=o.replaces,s=o.redefines;a||s?this.redefineProperty(o,a||s,a):(o.isBody&&this.setBodyProperty(o),o.isId&&this.setIdProperty(o),this.addProperty(o))},this)),r.push(e),n[i]=e)};function Kr(e,t){this.packageMap={},this.typeMap={},this.packages=[],this.properties=t,E(e,tt(this.registerPackage,this))}Kr.prototype.getPackage=function(e){return this.packageMap[e]};Kr.prototype.getPackages=function(){return this.packages};Kr.prototype.registerPackage=function(e){e=C({},e);var t=this.packageMap;qm(t,e,"prefix"),qm(t,e,"uri"),E(e.types,tt(function(n){this.registerType(n,e)},this)),t[e.uri]=t[e.prefix]=e,this.packages.push(e)};Kr.prototype.registerType=function(e,t){e=C({},e,{superClass:(e.superClass||[]).slice(),extends:(e.extends||[]).slice(),properties:(e.properties||[]).slice(),meta:C(e.meta||{})});var n=Tt(e.name,t.prefix),r=n.name,i={};E(e.properties,tt(function(o){var a=Tt(o.name,n.prefix),s=a.name;Ll(o.type)||(o.type=Tt(o.type,a.prefix).name),C(o,{ns:a,name:s}),i[s]=o},this)),C(e,{ns:n,name:r,propertiesByName:i}),E(e.extends,tt(function(o){var a=Tt(o,n.prefix),s=this.typeMap[a.name];s.traits=s.traits||[],s.traits.push(r)},this)),this.definePackage(e,t),this.typeMap[r]=e};Kr.prototype.mapTypes=function(e,t,n){var r=Ll(e.name)?{name:e.name}:this.typeMap[e.name],i=this;function o(c,u){var p=Tt(c,Ll(c)?"":e.prefix);i.mapTypes(p,t,u)}function a(c){return o(c,!0)}function s(c){return o(c,!1)}if(!r)throw new Error("unknown type <"+e.name+">");E(r.superClass,n?a:s),t(r,!n),E(r.traits,a)};Kr.prototype.getEffectiveDescriptor=function(e){var t=Tt(e),n=new dn(t);this.mapTypes(t,function(i,o){n.addTrait(i,o)});var r=n.build();return this.definePackage(r,r.allTypes[r.allTypes.length-1].$pkg),r};Kr.prototype.definePackage=function(e,t){this.properties.define(e,"$pkg",{value:t})};function qm(e,t,n){var r=t[n];if(r in e)throw new Error("package with "+n+" <"+r+"> already defined")}function Ci(e){this.model=e}Ci.prototype.set=function(e,t,n){if(!st(t)||!t.length)throw new TypeError("property name must be a non-empty string");var r=this.getProperty(e,t),i=r&&r.name;xw(n)?r?delete e[i]:delete e.$attrs[jl(t)]:r?i in e?e[i]=n:Xm(e,r,n):e.$attrs[jl(t)]=n};Ci.prototype.get=function(e,t){var n=this.getProperty(e,t);if(!n)return e.$attrs[jl(t)];var r=n.name;return!e[r]&&n.isMany&&Xm(e,n,[]),e[r]};Ci.prototype.define=function(e,t,n){if(!n.writable){var r=n.value;n=C({},n,{get:function(){return r}}),delete n.value}Object.defineProperty(e,t,n)};Ci.prototype.defineDescriptor=function(e,t){this.define(e,"$descriptor",{value:t})};Ci.prototype.defineModel=function(e,t){this.define(e,"$model",{value:t})};Ci.prototype.getProperty=function(e,t){var n=this.model,r=n.getPropertyDescriptor(e,t);if(r)return r;if(t.includes(":"))return null;let i=n.config.strict;if(typeof i!="undefined"){let o=new TypeError(`unknown property <${t}> on <${e.$type}>`);if(i)throw o;typeof console!="undefined"&&console.warn(o)}return null};function xw(e){return typeof e=="undefined"}function Xm(e,t,n){Object.defineProperty(e,t.name,{enumerable:!t.isReference,writable:!0,value:n,configurable:!0})}function jl(e){return e.replace(/^:/,"")}function tn(e,t={}){this.properties=new Ci(this),this.factory=new Km(this,this.properties),this.registry=new Kr(e,this.properties),this.typeCache={},this.config=t}tn.prototype.create=function(e,t){var n=this.getType(e);if(!n)throw new Error("unknown type <"+e+">");return new n(t)};tn.prototype.getType=function(e){var t=this.typeCache,n=st(e)?e:e.ns.name,r=t[n];return r||(e=this.registry.getEffectiveDescriptor(n),r=t[n]=this.factory.createType(e)),r};tn.prototype.createAny=function(e,t,n){var r=Tt(e),i={$type:e,$instanceOf:function(a){return a===this.$type},get:function(a){return this[a]},set:function(a,s){_l(this,[a],s)}},o={name:e,isGeneric:!0,ns:{prefix:r.prefix,localName:r.localName,uri:t}};return this.properties.defineDescriptor(i,o),this.properties.defineModel(i,this),this.properties.define(i,"get",{enumerable:!1,writable:!0}),this.properties.define(i,"set",{enumerable:!1,writable:!0}),this.properties.define(i,"$parent",{enumerable:!1,writable:!0}),this.properties.define(i,"$instanceOf",{enumerable:!1,writable:!0}),E(n,function(a,s){Se(a)&&a.value!==void 0?i[a.name]=a.value:i[s]=a}),i};tn.prototype.getPackage=function(e){return this.registry.getPackage(e)};tn.prototype.getPackages=function(){return this.registry.getPackages()};tn.prototype.getElementDescriptor=function(e){return e.$descriptor};tn.prototype.hasType=function(e,t){t===void 0&&(t=e,e=this);var n=e.$model.getElementDescriptor(e);return t in n.allTypesByName};tn.prototype.getPropertyDescriptor=function(e,t){return this.getElementDescriptor(e).propertiesByName[t]};tn.prototype.getTypeDescriptor=function(e){return this.registry.typeMap[e]};N();var Zm=String.fromCharCode,Ew=Object.prototype.hasOwnProperty,ww=/&#(\d+);|&#x([0-9a-f]+);|&(\w+);/ig,Oa={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'};Object.keys(Oa).forEach(function(e){Oa[e.toUpperCase()]=Oa[e]});function Sw(e,t,n,r){return r?Ew.call(Oa,r)?Oa[r]:"&"+r+";":Zm(t||parseInt(n,16))}function Ri(e){return e.length>3&&e.indexOf("&")!==-1?e.replace(ww,Sw):e}var Qm="non-whitespace outside of root node";function mo(e){return new Error(e)}function Jm(e){return"missing namespace for prefix <"+e+">"}function Ac(e){return{get:e,enumerable:!0}}function Cw(e){var t={},n;for(n in e)t[n]=e[n];return t}function $l(e){return e+"$uri"}function Rw(e){var t={},n,r;for(n in e)r=e[n],t[r]=r,t[$l(r)]=n;return t}function eh(){return{line:0,column:0}}function Pw(e){throw e}function zl(e){if(!this)return new zl(e);var t=e&&e.proxy,n,r,i,o,a=Pw,s,c,u,p,l=eh,f=!1,d=!1,m=null,g=!1,v;function w(b){b instanceof Error||(b=mo(b)),m=b,a(b,l)}function S(b){s&&(b instanceof Error||(b=mo(b)),s(b,l))}this.on=function(b,R){if(typeof R!="function")throw mo("required args <name, cb>");switch(b){case"openTag":r=R;break;case"text":n=R;break;case"closeTag":i=R;break;case"error":a=R;break;case"warn":s=R;break;case"cdata":o=R;break;case"attention":p=R;break;case"question":u=R;break;case"comment":c=R;break;default:throw mo("unsupported event: "+b)}return this},this.ns=function(b){if(typeof b=="undefined"&&(b={}),typeof b!="object")throw mo("required args <nsMap={}>");var R={},A;for(A in b)R[A]=b[A];return d=!0,v=R,this},this.parse=function(b){if(typeof b!="string")throw mo("required args <xml=string>");return m=null,x(b),l=eh,g=!1,m},this.stop=function(){g=!0};function x(b){var R=d?[]:null,A=d?Rw(v):null,O,T=[],I=0,L=!1,W=!1,z=0,K=0,ve,Jt,ke,ye,he,we,Ie,Ze,H,G="",oe=0,xe;function Gt(){if(xe!==null)return xe;var _,y,M,D=d&&A.xmlns,F=d&&f?[]:null,V=oe,ae=G,be=ae.length,ft,at,St,xn,Be,yr={},lc={},pn,me,Te;e:for(;V<be;V++)if(pn=!1,me=ae.charCodeAt(V),!(me===32||me<14&&me>8)){for((me<65||me>122||me>90&&me<97)&&me!==95&&me!==58&&(S("illegal first char attribute name"),pn=!0),Te=V+1;Te<be;Te++)if(me=ae.charCodeAt(Te),!(me>96&&me<123||me>64&&me<91||me>47&&me<59||me===46||me===45||me===95)){if(me===32||me<14&&me>8){S("missing attribute value"),V=Te;continue e}if(me===61)break;S("illegal attribute name char"),pn=!0}if(Be=ae.substring(V,Te),Be==="xmlns:xmlns"&&(S("illegal declaration of xmlns"),pn=!0),me=ae.charCodeAt(Te+1),me===34)Te=ae.indexOf('"',V=Te+2),Te===-1&&(Te=ae.indexOf("'",V),Te!==-1&&(S("attribute value quote missmatch"),pn=!0));else if(me===39)Te=ae.indexOf("'",V=Te+2),Te===-1&&(Te=ae.indexOf('"',V),Te!==-1&&(S("attribute value quote missmatch"),pn=!0));else for(S("missing attribute value quotes"),pn=!0,Te=Te+1;Te<be&&(me=ae.charCodeAt(Te+1),!(me===32||me<14&&me>8));Te++);for(Te===-1&&(S("missing closing quotes"),Te=be,pn=!0),pn||(St=ae.substring(V,Te)),V=Te;Te+1<be&&(me=ae.charCodeAt(Te+1),!(me===32||me<14&&me>8));Te++)V===Te&&(S("illegal character after attribute end"),pn=!0);if(V=Te+1,pn)continue e;if(Be in lc){S("attribute <"+Be+"> already defined");continue}if(lc[Be]=!0,!d){yr[Be]=St;continue}if(f){if(at=Be==="xmlns"?"xmlns":Be.charCodeAt(0)===120&&Be.substr(0,6)==="xmlns:"?Be.substr(6):null,at!==null){if(_=Ri(St),y=$l(at),xn=v[_],!xn){if(at==="xmlns"||y in A&&A[y]!==_)do xn="ns"+I++;while(typeof A[xn]!="undefined");else xn=at;v[_]=xn}A[at]!==xn&&(ft||(A=Cw(A),ft=!0),A[at]=xn,at==="xmlns"&&(A[$l(xn)]=_,D=xn),A[y]=_),yr[Be]=St;continue}F.push(Be,St);continue}if(me=Be.indexOf(":"),me===-1){yr[Be]=St;continue}if(!(M=A[Be.substring(0,me)])){S(Jm(Be.substring(0,me)));continue}Be=D===M?Be.substr(me+1):M+Be.substr(me),yr[Be]=St}if(f)for(V=0,be=F.length;V<be;V++){if(Be=F[V++],St=F[V],me=Be.indexOf(":"),me!==-1){if(!(M=A[Be.substring(0,me)])){S(Jm(Be.substring(0,me)));continue}Be=D===M?Be.substr(me+1):M+Be.substr(me)}yr[Be]=St}return xe=yr}function P(){for(var _=/(\r\n|\r|\n)/g,y=0,M=0,D=0,F=K,V,ae;z>=D&&(V=_.exec(b),!(!V||(F=V[0].length+V.index,F>z)));)y+=1,D=F;return z==-1?(M=F,ae=b.substring(K)):K===0?ae=b.substring(K,z):(M=z-D,ae=K==-1?b.substring(z):b.substring(z,K+1)),{data:ae,line:y,column:M}}for(l=P,t&&(H=Object.create({},{name:Ac(function(){return Ie}),originalName:Ac(function(){return Ze}),attrs:Ac(Gt),ns:Ac(function(){return A})}));K!==-1;){if(b.charCodeAt(K)===60?z=K:z=b.indexOf("<",K),z===-1){if(T.length)return w("unexpected end of file");if(K===0)return w("missing start tag");K<b.length&&b.substring(K).trim()&&S(Qm);return}if(K!==z){if(T.length){if(n&&(n(b.substring(K,z),Ri,l),g))return}else if(b.substring(K,z).trim()&&(S(Qm),g))return}if(ye=b.charCodeAt(z+1),ye===33){if(ke=b.charCodeAt(z+2),ke===91&&b.substr(z+3,6)==="CDATA["){if(K=b.indexOf("]]>",z),K===-1)return w("unclosed cdata");if(o&&(o(b.substring(z+9,K),l),g))return;K+=3;continue}if(ke===45&&b.charCodeAt(z+3)===45){if(K=b.indexOf("-->",z),K===-1)return w("unclosed comment");if(c&&(c(b.substring(z+4,K),Ri,l),g))return;K+=3;continue}}if(ye===63){if(K=b.indexOf("?>",z),K===-1)return w("unclosed question");if(u&&(u(b.substring(z,K+2),l),g))return;K+=2;continue}for(ve=z+1;;ve++){if(he=b.charCodeAt(ve),isNaN(he))return K=-1,w("unclosed tag");if(he===34)ke=b.indexOf('"',ve+1),ve=ke!==-1?ke:ve;else if(he===39)ke=b.indexOf("'",ve+1),ve=ke!==-1?ke:ve;else if(he===62){K=ve;break}}if(ye===33){if(p&&(p(b.substring(z,K+1),Ri,l),g))return;K+=1;continue}if(xe={},ye===47){if(L=!1,W=!0,!T.length)return w("missing open tag");if(ve=Ie=T.pop(),ke=z+2+ve.length,b.substring(z+2,ke)!==ve)return w("closing tag mismatch");for(;ke<K;ke++)if(ye=b.charCodeAt(ke),!(ye===32||ye>8&&ye<14))return w("close tag")}else{if(b.charCodeAt(K-1)===47?(ve=Ie=b.substring(z+1,K-1),L=!0,W=!0):(ve=Ie=b.substring(z+1,K),L=!0,W=!1),!(ye>96&&ye<123||ye>64&&ye<91||ye===95||ye===58))return w("illegal first char nodeName");for(ke=1,Jt=ve.length;ke<Jt;ke++)if(ye=ve.charCodeAt(ke),!(ye>96&&ye<123||ye>64&&ye<91||ye>47&&ye<59||ye===45||ye===95||ye==46)){if(ye===32||ye<14&&ye>8){Ie=ve.substring(0,ke),xe=null;break}return w("invalid nodeName")}W||T.push(Ie)}if(d){if(O=A,L&&(W||R.push(O),xe===null&&(f=ve.indexOf("xmlns",ke)!==-1)&&(oe=ke,G=ve,Gt(),f=!1)),Ze=Ie,ye=Ie.indexOf(":"),ye!==-1){if(we=A[Ie.substring(0,ye)],!we)return w("missing namespace on <"+Ze+">");Ie=Ie.substr(ye+1)}else we=A.xmlns;we&&(Ie=we+":"+Ie)}if(L&&(oe=ke,G=ve,r&&(t?r(H,Ri,W,l):r(Ie,Gt,Ri,W,l),g)))return;if(W){if(i&&(i(t?H:Ie,Ri,L,l),g))return;d&&(L?A=O:A=R.pop())}K+=1}}}function th(e){return e.xml&&e.xml.tagAlias==="lowerCase"}var Gl={xsi:"http://www.w3.org/2001/XMLSchema-instance",xml:"http://www.w3.org/XML/1998/namespace"},nh="property";function rh(e){return e.xml&&e.xml.serialize}function Aw(e){let t=rh(e);return t!==nh&&(t||null)}function Tw(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ih(e,t){return th(t)?e.prefix+":"+Tw(e.localName):e.name}function Mw(e,t){var n=e.name,r=e.localName,i=t&&t.xml&&t.xml.typePrefix;return i&&r.indexOf(i)===0?e.prefix+":"+r.slice(i.length):n}function Dw(e,t,n){let r=Tt(e,t.xmlns),i=`${t[r.prefix]||r.prefix}:${r.localName}`,o=Tt(i);var a=n.getPackage(o.prefix);return Mw(o,a)}function Yr(e){return new Error(e)}function xr(e){return e.$descriptor}function kw(e){C(this,e),this.elementsById={},this.references=[],this.warnings=[],this.addReference=function(t){this.references.push(t)},this.addElement=function(t){if(!t)throw Yr("expected element");var n=this.elementsById,r=xr(t),i=r.idProperty,o;if(i&&(o=t.get(i.name),o)){if(!/^([a-z][\w-.]*:)?[a-z_][\w-.]*$/i.test(o))throw new Error("illegal ID <"+o+">");if(n[o])throw Yr("duplicate ID <"+o+">");n[o]=t}},this.addWarning=function(t){this.warnings.push(t)}}function Ba(){}Ba.prototype.handleEnd=function(){};Ba.prototype.handleText=function(){};Ba.prototype.handleNode=function(){};function Vl(){}Vl.prototype=Object.create(Ba.prototype);Vl.prototype.handleNode=function(){return this};function vo(){}vo.prototype=Object.create(Ba.prototype);vo.prototype.handleText=function(e){this.body=(this.body||"")+e};function Ia(e,t){this.property=e,this.context=t}Ia.prototype=Object.create(vo.prototype);Ia.prototype.handleNode=function(e){if(this.element)throw Yr("expected no sub nodes");return this.element=this.createReference(e),this};Ia.prototype.handleEnd=function(){this.element.id=this.body};Ia.prototype.createReference=function(e){return{property:this.property.ns.name,id:""}};function Wl(e,t){this.element=t,this.propertyDesc=e}Wl.prototype=Object.create(vo.prototype);Wl.prototype.handleEnd=function(){var e=this.body||"",t=this.element,n=this.propertyDesc;e=Pc(n.type,e),n.isMany?t.get(n.name).push(e):t.set(n.name,e)};function Tc(){}Tc.prototype=Object.create(vo.prototype);Tc.prototype.handleNode=function(e){var t=this,n=this.element;return n?t=this.handleChild(e):(n=this.element=this.createElement(e),this.context.addElement(n)),t};function Ft(e,t,n){this.model=e,this.type=e.getType(t),this.context=n}Ft.prototype=Object.create(Tc.prototype);Ft.prototype.addReference=function(e){this.context.addReference(e)};Ft.prototype.handleText=function(e){var t=this.element,n=xr(t),r=n.bodyProperty;if(!r)throw Yr("unexpected body text <"+e+">");vo.prototype.handleText.call(this,e)};Ft.prototype.handleEnd=function(){var e=this.body,t=this.element,n=xr(t),r=n.bodyProperty;r&&e!==void 0&&(e=Pc(r.type,e),t.set(r.name,e))};Ft.prototype.createElement=function(e){var t=e.attributes,n=this.type,r=xr(n),i=this.context,o=new n({}),a=this.model,s;return E(t,function(c,u){var p=r.propertiesByName[u],l;p&&p.isReference?p.isMany?(l=c.split(" "),E(l,function(f){i.addReference({element:o,property:p.ns.name,id:f})})):i.addReference({element:o,property:p.ns.name,id:c}):(p?c=Pc(p.type,c):u==="xmlns"?u=":"+u:(s=Tt(u,r.ns.prefix),a.getPackage(s.prefix)&&i.addWarning({message:"unknown attribute <"+u+">",element:o,property:u,value:c})),o.set(u,c))}),o};Ft.prototype.getPropertyForNode=function(e){var t=e.name,n=Tt(t),r=this.type,i=this.model,o=xr(r),a=n.name,s=o.propertiesByName[a];if(s&&!s.isAttr){let u=Aw(s);if(u){let p=e.attributes[u];if(p){let l=Dw(p,e.ns,i),f=i.getType(l);return C({},s,{effectiveType:xr(f).name})}}return s}var c=i.getPackage(n.prefix);if(c){let u=ih(n,c),p=i.getType(u);if(s=re(o.properties,function(l){return!l.isVirtual&&!l.isReference&&!l.isAttribute&&p.hasType(l.type)}),s)return C({},s,{effectiveType:xr(p).name})}else if(s=re(o.properties,function(u){return!u.isReference&&!u.isAttribute&&u.type==="Element"}),s)return s;throw Yr("unrecognized element <"+n.name+">")};Ft.prototype.toString=function(){return"ElementDescriptor["+xr(this.type).name+"]"};Ft.prototype.valueHandler=function(e,t){return new Wl(e,t)};Ft.prototype.referenceHandler=function(e){return new Ia(e,this.context)};Ft.prototype.handler=function(e){return e==="Element"?new ho(this.model,e,this.context):new Ft(this.model,e,this.context)};Ft.prototype.handleChild=function(e){var t,n,r,i;if(t=this.getPropertyForNode(e),r=this.element,n=t.effectiveType||t.type,Hl(n))return this.valueHandler(t,r);t.isReference?i=this.referenceHandler(t).handleNode(e):i=this.handler(n).handleNode(e);var o=i.element;return o!==void 0&&(t.isMany?r.get(t.name).push(o):r.set(t.name,o),t.isReference?(C(o,{element:r}),this.context.addReference(o)):o.$parent=r),i};function Ul(e,t,n){Ft.call(this,e,t,n)}Ul.prototype=Object.create(Ft.prototype);Ul.prototype.createElement=function(e){var t=e.name,n=Tt(t),r=this.model,i=this.type,o=r.getPackage(n.prefix),a=o&&ih(n,o)||t;if(!i.hasType(a))throw Yr("unexpected element <"+e.originalName+">");return Ft.prototype.createElement.call(this,e)};function ho(e,t,n){this.model=e,this.context=n}ho.prototype=Object.create(Tc.prototype);ho.prototype.createElement=function(e){var t=e.name,n=Tt(t),r=n.prefix,i=e.ns[r+"$uri"],o=e.attributes;return this.model.createAny(t,i,o)};ho.prototype.handleChild=function(e){var t=new ho(this.model,"Element",this.context).handleNode(e),n=this.element,r=t.element,i;return r!==void 0&&(i=n.$children=n.$children||[],i.push(r),r.$parent=n),t};ho.prototype.handleEnd=function(){this.body&&(this.element.$body=this.body)};function Mc(e){e instanceof tn&&(e={model:e}),C(this,{lax:!1},e)}Mc.prototype.fromXML=function(e,t,n){var r=t.rootHandler;t instanceof Ft?(r=t,t={}):typeof t=="string"?(r=this.handler(t),t={}):typeof r=="string"&&(r=this.handler(r));var i=this.model,o=this.lax,a=new kw(C({},t,{rootHandler:r})),s=new zl({proxy:!0}),c=Nw();r.context=a,c.push(r);function u(R,A,O){var T=A(),I=T.line,L=T.column,W=T.data;W.charAt(0)==="<"&&W.indexOf(" ")!==-1&&(W=W.slice(0,W.indexOf(" "))+">");var z="unparsable content "+(W?W+" ":"")+`detected
/plugin/dirtylittlehelper/script/
Dmermaid.min.js.map1W0","W1","Z0","Z1","X2","Y2","Z2","z0","deltaMax","feature","centroidStream","centroidPoint","cent…
/plugin/dirtylittlehelper/mermaid/editor/docs/
Dbundle.js.map1W0, W1,\n X0, Y0, Z0,\n X1, Y1, Z1,\n X2, Y2, Z2,\n lambda00, phi00, // first point\n …