????
Current Path : C:/opt/pgsql/pgAdmin 4/web/pgadmin/static/js/generated/ |
Current File : C:/opt/pgsql/pgAdmin 4/web/pgadmin/static/js/generated/vendor.main.js |
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[683],{91620:(e,t,i)=>{i(63534),i(17),i(58476),i(36012),i(15852),i(10678),i(3101),i(7899),i(5086),i(58379);var n=i(24994);Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){var t=e.otherVars.editor;return{".cm-editor":{height:"100%",color:t.fg,backgroundColor:t.bg,"&.cm-focused":{outline:"none","& .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:t.selectionBg}},"& .cm-scroller":s(s({},e.mixins.fontSourceCode),{},{"& .cm-content":{'&[aria-readonly="true"] + .cm-cursorLayer':{display:"none"},"& .cm-activeLine":{backgroundColor:t.activeline},"& .cm-activeLineManual":{backgroundColor:t.activeline},"& .tok-keyword":{color:t.keyword,fontWeight:600},"& .tok-number":{color:t.number,fontWeight:600},"& .tok-string":{color:t.string},"& .tok-variable":{color:t.variable},"& .tok-comment":{color:t.comment},"& .tok-operator":{color:t.operator},"& .tok-punctuation":{color:t.punctuation},"& .tok-typeName":{color:t.type}},"& .cm-selectionLayer":{"& .cm-selectionBackground":{background:t.selectionBg}}}),"& .cm-cursorLayer":{"& .cm-cursor, & .cm-dropCursor":{borderLeftColor:t.fg}},"& .cm-gutters":{backgroundColor:t.guttersBg,color:t.guttersFg,borderRight:"none","& .cm-foldGutter":{padding:"0px",color:t.fg},"& .cm-breakpoint-gutter":{padding:"0px 2px",cursor:"pointer","& .cm-gutterElement":{fontSize:"1.3em",lineHeight:"1.1",color:"red"}}},"& .cm-panels-bottom":{border:"0 !important","& .cm-search":{display:"none"}},"& .cm-error-highlight":{borderBottom:"2px dotted red"}},".cm-tooltip":s(s({},e.mixins.fontSourceCode),{},{backgroundColor:e.palette.background.default+"!important",color:e.palette.text.primary+"!important",border:"1px solid ".concat(e.otherVars.borderColor," !important"),fontSize:"0.9em",'& li[aria-selected="true"]':{backgroundColor:e.otherVars.tree.treeBgSelected+"!important",color:e.otherVars.tree.treeFgSelected+"!important"},"& .pg-cm-autocomplete-icon":{marginLeft:"-2px",padding:"0px 8px",backgroundPosition:"50%",width:"20px",display:"inline-block"},"&.pg-autocomp-loader":{position:"absolute",paddingRight:"1px 12px 1px 2px"}})}};var o=n(i(43693));function r(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function s(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?r(Object(i),!0).forEach((function(t){(0,o.default)(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}},26151:(e,t,i)=>{i.d(t,{A:()=>o});var n=i(75517);const o=991!=i.j?n.A:null},95779:(e,t,i)=>{i.r(t),i.d(t,{Divider:()=>u.c,DividerBox:()=>d.X,DockBox:()=>s.t,DockContextConsumer:()=>o.BG,DockContextProvider:()=>o.kN,DockContextType:()=>o.DF,DockLayout:()=>l.w,DockPanel:()=>r.C,DockTabs:()=>n.K,DragDropDiv:()=>c.$,DragState:()=>a.mq,GestureState:()=>h.X,TabCache:()=>n.q,addDragStateListener:()=>a.$U,addHandlers:()=>a.FE,default:()=>f,defaultGroup:()=>o.jF,destroyDraggingElement:()=>a.MP,isDragging:()=>a.Id,maximePlaceHolderId:()=>o.KP,placeHolderGroup:()=>o.T3,placeHolderStyle:()=>o.bc,removeDragStateListener:()=>a.Gw,removeHandlers:()=>a.CY});var n=i(99399),o=i(27124),r=i(55364),s=i(62895),l=i(40793),a=i(57954);if(991!=i.j)var h=i(44253);var c=i(71349),u=i(6498),d=i(83665);const f=991!=i.j?l.w:null},12873:(e,t,i)=>{i.d(t,{A:()=>o});var n=i(16232);const o=991!=i.j?n.A:null},72147:(e,t,i)=>{i.d(t,{Ay:()=>h,Dr:()=>o.A,Uh:()=>s.A,cG:()=>l.A,g8:()=>r.A});var n=i(44274),o=i(19879),r=i(51013),s=i(71408),l=(i(44821),i(38866)),a=n.A;a.Item=o.A,a.SubMenu=r.A,a.ItemGroup=s.A,a.Divider=l.A;const h=991!=i.j?a:null},30156:(e,t,i)=>{i.d(t,{Ay:()=>o});var n=i(76173);i(598),i(85423);const o=991!=i.j?n.A:null},74321:(e,t,i)=>{i.d(t,{A:()=>c});var n=i(96540),o=i(40961),r=i(38221),s=i.n(r),l=i(95699);const a=s()((()=>{let e=document.createElement("div");document.body.append(e),e.remove()}),200);class h extends n.PureComponent{constructor(e){super(e),this.released=!1,this.container=document.createElement("div"),this.state={mounted:!1},this.onMainWindowUnload=()=>{this.window&&this.window.close()},this.release=e=>{if(!this.released&&(this.released=!0,this.windowCheckerInterval&&(clearInterval(this.windowCheckerInterval),this.windowCheckerInterval=null),window.removeEventListener("beforeunload",this.onMainWindowUnload),this.window.removeEventListener("beforeunload",this.release),e)){const{onClose:e}=this.props;"function"==typeof e&&e()}}}render(){return this.state.mounted?o.createPortal(this.props.children,this.container):null}componentDidMount(){this.openChild(),this.setState({mounted:!0})}openChild(){const{url:e,title:t,name:i,width:n,height:o,initPopupInnerRect:r,initPopupOuterRect:s,onBlock:h,onOpen:c,onClose:u}=this.props;let d={width:n,height:o};if(s){d=s();const[e,t,i]=l.r_;l.nr||(d.width-=2*t,d.height-=e+i)}else if(r){d=r();const[e,t]=l.r_;d.left-=t,d.top-=e,l.nr&&(d.height+=e)}else d.left=window.top.outerWidth/2+window.top.screenX-n/2,d.top=window.top.outerHeight/2+window.top.screenY-o/2;var f;this.window=window.open(e,i,(f=d,Object.keys(f).reduce(((e,t)=>{const i=f[t];return"boolean"==typeof i?e.push(`${t}=${i?"yes":"no"}`):e.push(`${t}=${i}`),e}),[]).join(","))),this.window?(window.addEventListener("beforeunload",this.onMainWindowUnload),this.window.addEventListener("resize",a),this.window.document.title=t||document.title,this.window.document.body.appendChild(this.container),this.props.copyStyles&&setTimeout((()=>{return e=document,t=this.window.document,void Array.from(e.styleSheets).forEach((i=>{let n;if(i.href){const n=e.createElement("link");n.rel="stylesheet",n.href=i.href,t.head.appendChild(n)}else{try{n=i.cssRules}catch(e){}if(n){const n=e.createElement("style");Array.from(i.cssRules).forEach((t=>{const{cssText:i,type:o}=t;let r=i;[3,5].includes(o)&&(r=i.split("url(").map((e=>"/"===e[1]?`${e.slice(0,1)}${window.location.origin}${e.slice(1)}`:e)).join("url(")),n.appendChild(e.createTextNode(r))})),t.head.appendChild(n)}}}));var e,t}),0),"function"==typeof c&&c(this.window),e&&u&&(this.windowCheckerInterval=setInterval((()=>{this.window&&!this.window.closed||this.release(!0)}),50)),this.window.addEventListener("beforeunload",this.release)):"function"==typeof h?h():console.warn("A new window could not be opened. Maybe it was blocked.")}componentWillUnmount(){this.window&&(this.release(),this.window.close())}}h.supported=l.Fw,h.defaultProps={url:"",name:"",width:640,height:480,copyStyles:!0};const c=991!=i.j?h:null},50517:(e,t,i)=>{t.y=t.OS=void 0;const n=i(66560);function o(e){let[t,i,o]=n.gerWindowBorder();e.outerWidth===e.screen.availWidth&&(i=0,o=0);let r=(e.outerWidth-2*i)/e.innerWidth,s=(e.outerHeight-t-o)/e.innerHeight,l=Math.min(s,r);return l=l>1.8?Math.round(l):l>.73?Math.round(20*l)/20:2/Math.round(2/l),l}function r(e,t=!1){let i=e?o(e):1,n=e.outerWidth-e.innerWidth*i>>1,r=Math.round(e.outerHeight-e.innerHeight*i);return n>32?n=8:r-=n,[n,r,i]}class s{init(e,t,i,n,o,r,s,l){this.scaleX=s/i,this.scaleY=l/n,this.offsetX=o-e*this.scaleX,this.offsetY=r-t*this.scaleY}map(e){return{x:e.x*this.scaleX+this.offsetX,y:e.y*this.scaleY+this.offsetY}}revertMap(e){return{x:(e.x-this.offsetX)/this.scaleX,y:(e.y-this.offsetY)/this.scaleY}}}t.OS=function e(t,i){if(!t)return null;let n,o=t.getBoundingClientRect(),l=new s;if(l.init(0,0,t.offsetWidth,t.offsetHeight,o.x,o.y,o.width,o.height),i){let{x:e,y:t}=l.map({x:i.left,y:i.top}),{x:o,y:r}=l.map({x:i.left+i.width,y:i.top+i.height});n={left:e,top:t,width:o-e,height:r-t}}else n={left:o.left,top:o.top,width:o.width,height:o.height};let a=t.ownerDocument.defaultView;if(!a)return o;if(a.frameElement)return e(a.frameElement,n);let[h,c,u]=r(a);return 1!==u&&(n.left*=u,n.top*=u,n.width*=u,n.height*=u),n.left+=a.screenX+h,n.top+=a.screenY+c,n},t.y=function e(t,i,o,l=!0){if(!t)return null;if(i){if(o={left:i.screenX,top:i.screenY,width:i.outerWidth,height:i.outerHeight},l){const[e,t,i]=n.popupWindowBorder;o.left+=t,o.top+=e,o.width-=2*t,o.height-=e+i}}else if(!o)return null;let a=t.ownerDocument.defaultView;if(!a)return o;if(a.frameElement)o=e(a.frameElement,null,o);else{let[e,t,i]=r(a);o.left-=a.screenX+e,o.top-=a.screenY+t,1!==i&&(o.left/=i,o.top/=i,o.width/=i,o.height/=i)}let h,c=t.getBoundingClientRect(),u=new s;u.init(0,0,t.offsetWidth,t.offsetHeight,c.x,c.y,c.width,c.height);let{x:d,y:f}=u.revertMap({x:o.left,y:o.top}),{x:p,y:m}=u.revertMap({x:o.left+o.width,y:o.top+o.height});return h={left:d,top:f,width:p-d,height:m-f},h}},44336:(e,t,i)=>{i.d(t,{A:()=>o});var n=i(82331);const o=991!=i.j?n.A:null},76567:(e,t,i)=>{i.d(t,{A:()=>c});var n=i(58168),o=i(96540),r=i(82546),s=(i(68210),i(63675)),l=i(26551);i(59823);function a(e,t){var i=e.children;return("function"==typeof i?[i]:(0,r.A)(i)).map((function(i,r){var l=(null==i?void 0:i.key)||"".concat("rc-observer-key","-").concat(r);return o.createElement(s.A,(0,n.A)({},e,{key:l,ref:0===r?t:void 0}),i)}))}var h=o.forwardRef(a);h.Collection=l.p;const c=991!=i.j?h:null},21970:(e,t,i)=>{i.d(t,{A:()=>o});var n=i(15854);i(96557);const o=991!=i.j?n.A:null},11587:(e,t,i)=>{i.d(t,{Ay:()=>h,Dr:()=>o.A,Uh:()=>s.A,cG:()=>l.A,g8:()=>r.A});var n=i(52162),o=i(57655),r=i(32277),s=i(86528),l=(i(15717),i(68322)),a=n.A;a.Item=o.A,a.SubMenu=r.A,a.ItemGroup=s.A,a.Divider=l.A;const h=991!=i.j?a:null},91531:(e,t,i)=>{i.d(t,{A:()=>E});var n=i(89379),o=i(58168),r=i(23029),s=i(92901),l=i(9417),a=i(85501),h=i(52962),c=i(64467),u=i(96540),d=i(40961),f=i(25371),p=i(54808),m=i(66588),g=i(8719),v=i(69916),w=i(20998),y=(0,u.forwardRef)((function(e,t){var i=e.didUpdate,n=e.getContainer,o=e.children,r=(0,u.useRef)(),s=(0,u.useRef)();(0,u.useImperativeHandle)(t,(function(){return{}}));var l=(0,u.useRef)(!1);return!l.current&&(0,w.A)()&&(s.current=n(),r.current=s.current.parentNode,l.current=!0),(0,u.useEffect)((function(){null==i||i(e)})),(0,u.useEffect)((function(){return null===s.current.parentNode&&null!==r.current&&r.current.appendChild(s.current),function(){var e;null===(e=s.current)||void 0===e||null===(e=e.parentNode)||void 0===e||e.removeChild(s.current)}}),[]),s.current?d.createPortal(o,s.current):null}));const b=y;var x=i(46942),k=i.n(x),S=i(21643),C=i(24927),A=i(2939);function M(){}function O(){return""}function T(e){return e?e.ownerDocument:window.document}var D=["onClick","onMouseDown","onTouchStart","onMouseEnter","onMouseLeave","onFocus","onBlur","onContextMenu"];const E=(P=b,R=function(e){(0,a.A)(i,e);var t=(0,h.A)(i);function i(e){var n,s;return(0,r.A)(this,i),n=t.call(this,e),(0,c.A)((0,l.A)(n),"popupRef",u.createRef()),(0,c.A)((0,l.A)(n),"triggerRef",u.createRef()),(0,c.A)((0,l.A)(n),"portalContainer",void 0),(0,c.A)((0,l.A)(n),"attachId",void 0),(0,c.A)((0,l.A)(n),"clickOutsideHandler",void 0),(0,c.A)((0,l.A)(n),"touchOutsideHandler",void 0),(0,c.A)((0,l.A)(n),"contextMenuOutsideHandler1",void 0),(0,c.A)((0,l.A)(n),"contextMenuOutsideHandler2",void 0),(0,c.A)((0,l.A)(n),"mouseDownTimeout",void 0),(0,c.A)((0,l.A)(n),"focusTime",void 0),(0,c.A)((0,l.A)(n),"preClickTime",void 0),(0,c.A)((0,l.A)(n),"preTouchTime",void 0),(0,c.A)((0,l.A)(n),"delayTimer",void 0),(0,c.A)((0,l.A)(n),"hasPopupMouseDown",void 0),(0,c.A)((0,l.A)(n),"onMouseEnter",(function(e){var t=n.props.mouseEnterDelay;n.fireEvents("onMouseEnter",e),n.delaySetPopupVisible(!0,t,t?null:e)})),(0,c.A)((0,l.A)(n),"onMouseMove",(function(e){n.fireEvents("onMouseMove",e),n.setPoint(e)})),(0,c.A)((0,l.A)(n),"onMouseLeave",(function(e){n.fireEvents("onMouseLeave",e),n.delaySetPopupVisible(!1,n.props.mouseLeaveDelay)})),(0,c.A)((0,l.A)(n),"onPopupMouseEnter",(function(){n.clearDelayTimer()})),(0,c.A)((0,l.A)(n),"onPopupMouseLeave",(function(e){var t;e.relatedTarget&&!e.relatedTarget.setTimeout&&(0,p.A)(null===(t=n.popupRef.current)||void 0===t?void 0:t.getElement(),e.relatedTarget)||n.delaySetPopupVisible(!1,n.props.mouseLeaveDelay)})),(0,c.A)((0,l.A)(n),"onFocus",(function(e){n.fireEvents("onFocus",e),n.clearDelayTimer(),n.isFocusToShow()&&(n.focusTime=Date.now(),n.delaySetPopupVisible(!0,n.props.focusDelay))})),(0,c.A)((0,l.A)(n),"onMouseDown",(function(e){n.fireEvents("onMouseDown",e),n.preClickTime=Date.now()})),(0,c.A)((0,l.A)(n),"onTouchStart",(function(e){n.fireEvents("onTouchStart",e),n.preTouchTime=Date.now()})),(0,c.A)((0,l.A)(n),"onBlur",(function(e){n.fireEvents("onBlur",e),n.clearDelayTimer(),n.isBlurToHide()&&n.delaySetPopupVisible(!1,n.props.blurDelay)})),(0,c.A)((0,l.A)(n),"onContextMenu",(function(e){e.preventDefault(),n.fireEvents("onContextMenu",e),n.setPopupVisible(!0,e)})),(0,c.A)((0,l.A)(n),"onContextMenuClose",(function(){n.isContextMenuToShow()&&n.close()})),(0,c.A)((0,l.A)(n),"onClick",(function(e){if(n.fireEvents("onClick",e),n.focusTime){var t;if(n.preClickTime&&n.preTouchTime?t=Math.min(n.preClickTime,n.preTouchTime):n.preClickTime?t=n.preClickTime:n.preTouchTime&&(t=n.preTouchTime),Math.abs(t-n.focusTime)<20)return;n.focusTime=0}n.preClickTime=0,n.preTouchTime=0,n.isClickToShow()&&(n.isClickToHide()||n.isBlurToHide())&&e&&e.preventDefault&&e.preventDefault();var i=!n.state.popupVisible;(n.isClickToHide()&&!i||i&&n.isClickToShow())&&n.setPopupVisible(!n.state.popupVisible,e)})),(0,c.A)((0,l.A)(n),"onPopupMouseDown",(function(){var e;n.hasPopupMouseDown=!0,clearTimeout(n.mouseDownTimeout),n.mouseDownTimeout=window.setTimeout((function(){n.hasPopupMouseDown=!1}),0),n.context&&(e=n.context).onPopupMouseDown.apply(e,arguments)})),(0,c.A)((0,l.A)(n),"onDocumentClick",(function(e){if(!n.props.mask||n.props.maskClosable){var t=e.target,i=n.getRootDomNode(),o=n.getPopupDomNode();(0,p.A)(i,t)&&!n.isContextMenuOnly()||(0,p.A)(o,t)||n.hasPopupMouseDown||n.close()}})),(0,c.A)((0,l.A)(n),"getRootDomNode",(function(){var e=n.props.getTriggerDOMNode;if(e)return e(n.triggerRef.current);try{var t=(0,m.A)(n.triggerRef.current);if(t)return t}catch(e){}return d.findDOMNode((0,l.A)(n))})),(0,c.A)((0,l.A)(n),"getPopupClassNameFromAlign",(function(e){var t=[],i=n.props,o=i.popupPlacement,r=i.builtinPlacements,s=i.prefixCls,l=i.alignPoint,a=i.getPopupClassNameFromAlign;return o&&r&&t.push((0,S.H)(r,s,e,l)),a&&t.push(a(e)),t.join(" ")})),(0,c.A)((0,l.A)(n),"getComponent",(function(){var e=n.props,t=e.prefixCls,i=e.destroyPopupOnHide,r=e.popupClassName,s=e.onPopupAlign,l=e.popupMotion,a=e.popupAnimation,h=e.popupTransitionName,c=e.popupStyle,d=e.mask,f=e.maskAnimation,p=e.maskTransitionName,m=e.maskMotion,g=e.zIndex,v=e.popup,w=e.stretch,y=e.alignPoint,b=e.mobile,x=e.forceRender,k=e.onPopupClick,S=n.state,A=S.popupVisible,M=S.point,O=n.getPopupAlign(),T={};return n.isMouseEnterToShow()&&(T.onMouseEnter=n.onPopupMouseEnter),n.isMouseLeaveToHide()&&(T.onMouseLeave=n.onPopupMouseLeave),T.onMouseDown=n.onPopupMouseDown,T.onTouchStart=n.onPopupMouseDown,u.createElement(C.A,(0,o.A)({prefixCls:t,destroyPopupOnHide:i,visible:A,point:y&&M,className:r,align:O,onAlign:s,animation:a,getClassNameFromAlign:n.getPopupClassNameFromAlign},T,{stretch:w,getRootDomNode:n.getRootDomNode,style:c,mask:d,zIndex:g,transitionName:h,maskAnimation:f,maskTransitionName:p,maskMotion:m,ref:n.popupRef,motion:l,mobile:b,forceRender:x,onClick:k}),"function"==typeof v?v():v)})),(0,c.A)((0,l.A)(n),"attachParent",(function(e){f.A.cancel(n.attachId);var t,i=n.props,o=i.getPopupContainer,r=i.getDocument,s=n.getRootDomNode();o?(s||0===o.length)&&(t=o(s)):t=r(n.getRootDomNode()).body,t?t.appendChild(e):n.attachId=(0,f.A)((function(){n.attachParent(e)}))})),(0,c.A)((0,l.A)(n),"getContainer",(function(){if(!n.portalContainer){var e=(0,n.props.getDocument)(n.getRootDomNode()).createElement("div");e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.width="100%",n.portalContainer=e}return n.attachParent(n.portalContainer),n.portalContainer})),(0,c.A)((0,l.A)(n),"setPoint",(function(e){n.props.alignPoint&&e&&n.setState({point:{pageX:e.pageX,pageY:e.pageY}})})),(0,c.A)((0,l.A)(n),"handlePortalUpdate",(function(){n.state.prevPopupVisible!==n.state.popupVisible&&n.props.afterPopupVisibleChange(n.state.popupVisible)})),(0,c.A)((0,l.A)(n),"triggerContextValue",{onPopupMouseDown:n.onPopupMouseDown}),s="popupVisible"in e?!!e.popupVisible:!!e.defaultPopupVisible,n.state={prevPopupVisible:s,popupVisible:s},D.forEach((function(e){n["fire".concat(e)]=function(t){n.fireEvents(e,t)}})),n}return(0,s.A)(i,[{key:"componentDidMount",value:function(){this.componentDidUpdate()}},{key:"componentDidUpdate",value:function(){var e,t=this.props;if(this.state.popupVisible)return this.clickOutsideHandler||!this.isClickToHide()&&!this.isContextMenuToShow()||(e=t.getDocument(this.getRootDomNode()),this.clickOutsideHandler=(0,v.A)(e,"mousedown",this.onDocumentClick)),this.touchOutsideHandler||(e=e||t.getDocument(this.getRootDomNode()),this.touchOutsideHandler=(0,v.A)(e,"touchstart",this.onDocumentClick)),!this.contextMenuOutsideHandler1&&this.isContextMenuToShow()&&(e=e||t.getDocument(this.getRootDomNode()),this.contextMenuOutsideHandler1=(0,v.A)(e,"scroll",this.onContextMenuClose)),void(!this.contextMenuOutsideHandler2&&this.isContextMenuToShow()&&(this.contextMenuOutsideHandler2=(0,v.A)(window,"blur",this.onContextMenuClose)));this.clearOutsideHandler()}},{key:"componentWillUnmount",value:function(){this.clearDelayTimer(),this.clearOutsideHandler(),clearTimeout(this.mouseDownTimeout),f.A.cancel(this.attachId)}},{key:"getPopupDomNode",value:function(){var e;return(null===(e=this.popupRef.current)||void 0===e?void 0:e.getElement())||null}},{key:"getPopupAlign",value:function(){var e=this.props,t=e.popupPlacement,i=e.popupAlign,n=e.builtinPlacements;return t&&n?(0,S.R)(n,t,i):i}},{key:"setPopupVisible",value:function(e,t){var i=this.props.alignPoint,n=this.state.popupVisible;this.clearDelayTimer(),n!==e&&("popupVisible"in this.props||this.setState({popupVisible:e,prevPopupVisible:n}),this.props.onPopupVisibleChange(e)),i&&t&&e&&this.setPoint(t)}},{key:"delaySetPopupVisible",value:function(e,t,i){var n=this,o=1e3*t;if(this.clearDelayTimer(),o){var r=i?{pageX:i.pageX,pageY:i.pageY}:null;this.delayTimer=window.setTimeout((function(){n.setPopupVisible(e,r),n.clearDelayTimer()}),o)}else this.setPopupVisible(e,i)}},{key:"clearDelayTimer",value:function(){this.delayTimer&&(clearTimeout(this.delayTimer),this.delayTimer=null)}},{key:"clearOutsideHandler",value:function(){this.clickOutsideHandler&&(this.clickOutsideHandler.remove(),this.clickOutsideHandler=null),this.contextMenuOutsideHandler1&&(this.contextMenuOutsideHandler1.remove(),this.contextMenuOutsideHandler1=null),this.contextMenuOutsideHandler2&&(this.contextMenuOutsideHandler2.remove(),this.contextMenuOutsideHandler2=null),this.touchOutsideHandler&&(this.touchOutsideHandler.remove(),this.touchOutsideHandler=null)}},{key:"createTwoChains",value:function(e){var t=this.props.children.props,i=this.props;return t[e]&&i[e]?this["fire".concat(e)]:t[e]||i[e]}},{key:"isClickToShow",value:function(){var e=this.props,t=e.action,i=e.showAction;return-1!==t.indexOf("click")||-1!==i.indexOf("click")}},{key:"isContextMenuOnly",value:function(){var e=this.props.action;return"contextMenu"===e||1===e.length&&"contextMenu"===e[0]}},{key:"isContextMenuToShow",value:function(){var e=this.props,t=e.action,i=e.showAction;return-1!==t.indexOf("contextMenu")||-1!==i.indexOf("contextMenu")}},{key:"isClickToHide",value:function(){var e=this.props,t=e.action,i=e.hideAction;return-1!==t.indexOf("click")||-1!==i.indexOf("click")}},{key:"isMouseEnterToShow",value:function(){var e=this.props,t=e.action,i=e.showAction;return-1!==t.indexOf("hover")||-1!==i.indexOf("mouseEnter")}},{key:"isMouseLeaveToHide",value:function(){var e=this.props,t=e.action,i=e.hideAction;return-1!==t.indexOf("hover")||-1!==i.indexOf("mouseLeave")}},{key:"isFocusToShow",value:function(){var e=this.props,t=e.action,i=e.showAction;return-1!==t.indexOf("focus")||-1!==i.indexOf("focus")}},{key:"isBlurToHide",value:function(){var e=this.props,t=e.action,i=e.hideAction;return-1!==t.indexOf("focus")||-1!==i.indexOf("blur")}},{key:"forcePopupAlign",value:function(){var e;this.state.popupVisible&&(null===(e=this.popupRef.current)||void 0===e||e.forceAlign())}},{key:"fireEvents",value:function(e,t){var i=this.props.children.props[e];i&&i(t);var n=this.props[e];n&&n(t)}},{key:"close",value:function(){this.setPopupVisible(!1)}},{key:"render",value:function(){var e=this.state.popupVisible,t=this.props,i=t.children,o=t.forceRender,r=t.alignPoint,s=t.className,l=t.autoDestroy,a=u.Children.only(i),h={key:"trigger"};this.isContextMenuToShow()?h.onContextMenu=this.onContextMenu:h.onContextMenu=this.createTwoChains("onContextMenu"),this.isClickToHide()||this.isClickToShow()?(h.onClick=this.onClick,h.onMouseDown=this.onMouseDown,h.onTouchStart=this.onTouchStart):(h.onClick=this.createTwoChains("onClick"),h.onMouseDown=this.createTwoChains("onMouseDown"),h.onTouchStart=this.createTwoChains("onTouchStart")),this.isMouseEnterToShow()?(h.onMouseEnter=this.onMouseEnter,r&&(h.onMouseMove=this.onMouseMove)):h.onMouseEnter=this.createTwoChains("onMouseEnter"),this.isMouseLeaveToHide()?h.onMouseLeave=this.onMouseLeave:h.onMouseLeave=this.createTwoChains("onMouseLeave"),this.isFocusToShow()||this.isBlurToHide()?(h.onFocus=this.onFocus,h.onBlur=this.onBlur):(h.onFocus=this.createTwoChains("onFocus"),h.onBlur=this.createTwoChains("onBlur"));var c=k()(a&&a.props&&a.props.className,s);c&&(h.className=c);var d=(0,n.A)({},h);(0,g.f3)(a)&&(d.ref=(0,g.K4)(this.triggerRef,a.ref));var f,p=u.cloneElement(a,d);return(e||this.popupRef.current||o)&&(f=u.createElement(P,{key:"portal",getContainer:this.getContainer,didUpdate:this.handlePortalUpdate},this.getComponent())),!e&&l&&(f=null),u.createElement(A.A.Provider,{value:this.triggerContextValue},p,f)}}],[{key:"getDerivedStateFromProps",value:function(e,t){var i=e.popupVisible,n={};return void 0!==i&&t.popupVisible!==i&&(n.popupVisible=i,n.prevPopupVisible=t.popupVisible),n}}]),i}(u.Component),(0,c.A)(R,"contextType",A.A),(0,c.A)(R,"defaultProps",{prefixCls:"rc-trigger-popup",getPopupClassNameFromAlign:O,getDocument:T,onPopupVisibleChange:M,afterPopupVisibleChange:M,onPopupAlign:M,popupClassName:"",mouseEnterDelay:0,mouseLeaveDelay:.1,focusDelay:0,blurDelay:.15,popupStyle:{},destroyPopupOnHide:!1,popupAlign:{},defaultPopupVisible:!1,mask:!1,maskClosable:!0,action:[],showAction:[],hideAction:[],autoDestroy:!1}),R);var P,R},82546:(e,t,i)=>{i.d(t,{A:()=>r});var n=i(96540),o=i(44363);function r(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=[];return n.Children.forEach(e,(function(e){(null!=e||t.keepEmpty)&&(Array.isArray(e)?i=i.concat(r(e)):(0,o.isFragment)(e)&&e.props?i=i.concat(r(e.props.children,t)):i.push(e))})),i}},69916:(e,t,i)=>{i.d(t,{A:()=>o});var n=i(40961);function o(e,t,i,o){var r=n.unstable_batchedUpdates?function(e){n.unstable_batchedUpdates(i,e)}:i;return null!=e&&e.addEventListener&&e.addEventListener(t,r,o),{remove:function(){null!=e&&e.removeEventListener&&e.removeEventListener(t,r,o)}}}},54808:(e,t,i)=>{function n(e,t){if(!e)return!1;if(e.contains)return e.contains(t);for(var i=t;i;){if(i===e)return!0;i=i.parentNode}return!1}i.d(t,{A:()=>n})},66588:(e,t,i)=>{i.d(t,{A:()=>r});var n=i(96540),o=i(40961);function r(e){return function(e){return e instanceof HTMLElement||e instanceof SVGElement}(e)?e:e instanceof n.Component?o.findDOMNode(e):null}},4989:(e,t,i)=>{if(i.d(t,{jD:()=>s}),991!=i.j)var n=i(45458);if(991!=i.j)var o=i(42467);function r(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if((0,o.A)(e)){var i=e.nodeName.toLowerCase(),n=["input","select","textarea","button"].includes(i)||e.isContentEditable||"a"===i&&!!e.getAttribute("href"),r=e.getAttribute("tabindex"),s=Number(r),l=null;return r&&!Number.isNaN(s)?l=s:n&&null===l&&(l=0),n&&e.disabled&&(l=null),null!==l&&(l>=0||t&&l<0)}return!1}function s(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=(0,n.A)(e.querySelectorAll("*")).filter((function(e){return r(e,t)}));return r(e,t)&&i.unshift(e),i}},16928:(e,t,i)=>{i.d(t,{A:()=>o});var n={MAC_ENTER:3,BACKSPACE:8,TAB:9,NUM_CENTER:12,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PRINT_SCREEN:44,INSERT:45,DELETE:46,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,QUESTION_MARK:63,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,META:91,WIN_KEY_RIGHT:92,CONTEXT_MENU:93,NUM_ZERO:96,NUM_ONE:97,NUM_TWO:98,NUM_THREE:99,NUM_FOUR:100,NUM_FIVE:101,NUM_SIX:102,NUM_SEVEN:103,NUM_EIGHT:104,NUM_NINE:105,NUM_MULTIPLY:106,NUM_PLUS:107,NUM_MINUS:109,NUM_PERIOD:110,NUM_DIVISION:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,NUMLOCK:144,SEMICOLON:186,DASH:189,EQUALS:187,COMMA:188,PERIOD:190,SLASH:191,APOSTROPHE:192,SINGLE_QUOTE:222,OPEN_SQUARE_BRACKET:219,BACKSLASH:220,CLOSE_SQUARE_BRACKET:221,WIN_KEY:224,MAC_FF_META:224,WIN_IME:229,isTextModifyingKeyEvent:function(e){var t=e.keyCode;if(e.altKey&&!e.ctrlKey||e.metaKey||t>=n.F1&&t<=n.F12)return!1;switch(t){case n.ALT:case n.CAPS_LOCK:case n.CONTEXT_MENU:case n.CTRL:case n.DOWN:case n.END:case n.ESC:case n.HOME:case n.INSERT:case n.LEFT:case n.MAC_FF_META:case n.META:case n.NUMLOCK:case n.NUM_CENTER:case n.PAGE_DOWN:case n.PAGE_UP:case n.PAUSE:case n.PRINT_SCREEN:case n.RIGHT:case n.SHIFT:case n.UP:case n.WIN_KEY:case n.WIN_KEY_RIGHT:return!1;default:return!0}},isCharacterKey:function(e){if(e>=n.ZERO&&e<=n.NINE)return!0;if(e>=n.NUM_ZERO&&e<=n.NUM_MULTIPLY)return!0;if(e>=n.A&&e<=n.Z)return!0;if(-1!==window.navigator.userAgent.indexOf("WebKit")&&0===e)return!0;switch(e){case n.SPACE:case n.QUESTION_MARK:case n.NUM_PLUS:case n.NUM_MINUS:case n.NUM_PERIOD:case n.NUM_DIVISION:case n.SEMICOLON:case n.DASH:case n.EQUALS:case n.COMMA:case n.PERIOD:case n.SLASH:case n.APOSTROPHE:case n.SINGLE_QUOTE:case n.OPEN_SQUARE_BRACKET:case n.BACKSLASH:case n.CLOSE_SQUARE_BRACKET:return!0;default:return!1}}};const o=991!=i.j?n:null},28104:(e,t,i)=>{i.d(t,{A:()=>o});var n=i(96540);function o(e,t,i){var o=n.useRef({});return"value"in o.current&&!i(o.current.condition,t)||(o.current.value=e(),o.current.condition=t),o.current.value}},12533:(e,t,i)=>{if(i.d(t,{A:()=>a}),991!=i.j)var n=i(80296);var o=i(26956),r=i(30981),s=i(1233);function l(e){return void 0!==e}function a(e,t){var i=t||{},a=i.defaultValue,h=i.value,c=i.onChange,u=i.postState,d=(0,s.A)((function(){return l(h)?h:l(a)?"function"==typeof a?a():a:"function"==typeof e?e():e})),f=(0,n.A)(d,2),p=f[0],m=f[1],g=void 0!==h?h:p,v=u?u(g):g,w=(0,o.A)(c),y=(0,s.A)([g]),b=(0,n.A)(y,2),x=b[0],k=b[1];return(0,r.o)((function(){var e=x[0];p!==e&&w(p,e)}),[x]),(0,r.o)((function(){l(h)||m(h)}),[h]),[v,(0,o.A)((function(e,t){m(e,t),k([g],t)}))]}},43210:(e,t,i)=>{if(i.d(t,{A:()=>r}),991!=i.j)var n=i(82284);var o=i(68210);const r=991!=i.j?function(e,t){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=new Set;return function e(t,s){var l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=r.has(t);if((0,o.Ay)(!a,"Warning: There may be circular references"),a)return!1;if(t===s)return!0;if(i&&l>1)return!1;r.add(t);var h=l+1;if(Array.isArray(t)){if(!Array.isArray(s)||t.length!==s.length)return!1;for(var c=0;c<t.length;c++)if(!e(t[c],s[c],h))return!1;return!0}if(t&&s&&"object"===(0,n.A)(t)&&"object"===(0,n.A)(s)){var u=Object.keys(t);return u.length===Object.keys(s).length&&u.every((function(i){return e(t[i],s[i],h)}))}return!1}(e,t)}:null},68430:(e,t,i)=>{i.d(t,{A:()=>n});const n=function(){if("undefined"==typeof navigator||"undefined"==typeof window)return!1;var e=navigator.userAgent||navigator.vendor||window.opera;return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(null==e?void 0:e.substr(0,4))}},19853:(e,t,i)=>{if(i.d(t,{A:()=>o}),991!=i.j)var n=i(89379);function o(e,t){var i=(0,n.A)({},e);return Array.isArray(t)&&t.forEach((function(e){delete i[e]})),i}},25371:(e,t,i)=>{i.d(t,{A:()=>h});var n=function(e){return+setTimeout(e,16)},o=function(e){return clearTimeout(e)};"undefined"!=typeof window&&"requestAnimationFrame"in window&&(n=function(e){return window.requestAnimationFrame(e)},o=function(e){return window.cancelAnimationFrame(e)});var r=0,s=new Map;function l(e){s.delete(e)}var a=function(e){var t=r+=1;return function i(o){if(0===o)l(t),e();else{var r=n((function(){i(o-1)}));s.set(t,r)}}(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1),t};a.cancel=function(e){var t=s.get(e);return l(e),o(t)};const h=991!=i.j?a:null},8719:(e,t,i)=>{if(i.d(t,{K4:()=>l,Xf:()=>s,f3:()=>h,xK:()=>a}),991!=i.j)var n=i(82284);i(96540);var o=i(44363),r=i(28104),s=function(e,t){"function"==typeof e?e(t):"object"===(0,n.A)(e)&&e&&"current"in e&&(e.current=t)},l=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];var n=t.filter(Boolean);return n.length<=1?n[0]:function(e){t.forEach((function(t){s(t,e)}))}},a=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return(0,r.A)((function(){return l.apply(void 0,t)}),t,(function(e,t){return e.length!==t.length||e.every((function(e,i){return e!==t[i]}))}))},h=function(e){var t,i,n=(0,o.isMemo)(e)?e.type.type:e.type;return!!("function"!=typeof n||null!==(t=n.prototype)&&void 0!==t&&t.render||n.$$typeof===o.ForwardRef)&&!!("function"!=typeof e||null!==(i=e.prototype)&&void 0!==i&&i.render||e.$$typeof===o.ForwardRef)}},68210:(e,t,i)=>{i.d(t,{Ay:()=>h});var n={},o=[];function r(e,t){}function s(e,t){}function l(e,t,i){t||n[i]||(e(!1,i),n[i]=!0)}function a(e,t){l(r,e,t)}a.preMessage=function(e){o.push(e)},a.resetWarned=function(){n={}},a.noteOnce=function(e,t){l(s,e,t)};const h=991!=i.j?a:null},80591:(e,t,i)=>{var n=i(89064),o=i(61506),r=i(92533);class s{constructor(e,t,i){this.state=e,this.pos=t,this.explicit=i,this.abortListeners=[]}tokenBefore(e){let t=r.syntaxTree(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),n=t.text.slice(i-t.from,this.pos-t.from),o=n.search(u(e,!1));return o<0?null:{from:i+o,to:this.pos,text:n.slice(o)}}get aborted(){return null==this.abortListeners}addEventListener(e,t){"abort"==e&&this.abortListeners&&this.abortListeners.push(t)}}function l(e){let t=Object.keys(e).join(""),i=/\w/.test(t);return i&&(t=t.replace(/\w/g,"")),`[${i?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function a(e){let t=e.map((e=>"string"==typeof e?{label:e}:e)),[i,n]=t.every((e=>/^\w+$/.test(e.label)))?[/\w*$/,/\w+$/]:function(e){let t=Object.create(null),i=Object.create(null);for(let{label:n}of e){t[n[0]]=!0;for(let e=1;e<n.length;e++)i[n[e]]=!0}let n=l(t)+l(i)+"*$";return[new RegExp("^"+n),new RegExp(n)]}(t);return e=>{let o=e.matchBefore(n);return o||e.explicit?{from:o?o.from:e.pos,options:t,validFor:i}:null}}class h{constructor(e,t,i,n){this.completion=e,this.source=t,this.match=i,this.score=n}}function c(e){return e.selection.main.from}function u(e,t){var i;let{source:n}=e,o=t&&"^"!=n[0],r="$"!=n[n.length-1];return o||r?new RegExp(`${o?"^":""}(?:${n})${r?"$":""}`,null!==(i=e.flags)&&void 0!==i?i:e.ignoreCase?"i":""):e}const d=n.Annotation.define();function f(e,t,i,o){let{main:r}=e.selection,s=i-r.from,l=o-r.from;return Object.assign(Object.assign({},e.changeByRange((a=>a!=r&&i!=o&&e.sliceDoc(a.from+s,a.from+l)!=e.sliceDoc(i,o)?{range:a}:{changes:{from:a.from+s,to:o==r.from?a.to:a.from+l,insert:t},range:n.EditorSelection.cursor(a.from+s+t.length)}))),{scrollIntoView:!0,userEvent:"input.complete"})}const p=new WeakMap;function m(e){if(!Array.isArray(e))return e;let t=p.get(e);return t||p.set(e,t=a(e)),t}const g=n.StateEffect.define(),v=n.StateEffect.define();class w{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=n.codePointAt(e,t),o=n.codePointSize(i);this.chars.push(i);let r=e.slice(t,t+o),s=r.toUpperCase();this.folded.push(n.codePointAt(s==r?r.toLowerCase():s,0)),t+=o}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(0==this.pattern.length)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:i,any:o,precise:r,byWord:s}=this;if(1==t.length){let o=n.codePointAt(e,0),r=n.codePointSize(o),s=r==e.length?0:-100;if(o==t[0]);else{if(o!=i[0])return null;s+=-200}return this.ret(s,[0,r])}let l=e.indexOf(this.pattern);if(0==l)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,h=0;if(l<0){for(let r=0,s=Math.min(e.length,200);r<s&&h<a;){let s=n.codePointAt(e,r);s!=t[h]&&s!=i[h]||(o[h++]=r),r+=n.codePointSize(s)}if(h<a)return null}let c=0,u=0,d=!1,f=0,p=-1,m=-1,g=/[a-z]/.test(e),v=!0;for(let o=0,h=Math.min(e.length,200),w=0;o<h&&u<a;){let h=n.codePointAt(e,o);l<0&&(c<a&&h==t[c]&&(r[c++]=o),f<a&&(h==t[f]||h==i[f]?(0==f&&(p=o),m=o+1,f++):f=0));let y,b=h<255?h>=48&&h<=57||h>=97&&h<=122?2:h>=65&&h<=90?1:0:(y=n.fromCodePoint(h))!=y.toLowerCase()?1:y!=y.toUpperCase()?2:0;(!o||1==b&&g||0==w&&0!=b)&&(t[u]==h||i[u]==h&&(d=!0)?s[u++]=o:s.length&&(v=!1)),w=b,o+=n.codePointSize(h)}return u==a&&0==s[0]&&v?this.result((d?-200:0)-100,s,e):f==a&&0==p?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):f==a?this.ret(-900-e.length,[p,m]):u==a?this.result((d?-200:0)-100-700+(v?0:-1100),s,e):2==t.length?null:this.result((o[0]?-700:0)-200-1100,o,e)}result(e,t,i){let o=[],r=0;for(let e of t){let t=e+(this.astral?n.codePointSize(n.codePointAt(i,e)):1);r&&o[r-1]==e?o[r-1]=t:(o[r++]=e,o[r++]=t)}return this.ret(e-i.length,o)}}class y{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 null==i?null:(this.matched=[0,t.length],this.score=i+(e.length==this.pattern.length?0:-100),this)}}const b=n.Facet.define({combine:e=>n.combineConfig(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:k,filterStrict:!1,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>x(e(i),t(i)),optionClass:(e,t)=>i=>x(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})});function x(e,t){return e?t?e+" "+t:e:t}function k(e,t,i,n,r,s){let l,a,h=e.textDirection==o.Direction.RTL,c=h,u=!1,d="top",f=t.left-r.left,p=r.right-t.right,m=n.right-n.left,g=n.bottom-n.top;if(c&&f<Math.min(m,p)?c=!1:!c&&p<Math.min(m,f)&&(c=!0),m<=(c?f:p))l=Math.max(r.top,Math.min(i.top,r.bottom-g))-t.top,a=Math.min(400,c?f:p);else{u=!0,a=Math.min(400,(h?t.right:r.right-t.left)-30);let e=r.bottom-t.bottom;e>=g||e>t.top?l=i.bottom-t.top:(d="bottom",l=t.bottom-i.top)}return{style:`${d}: ${l/((t.bottom-t.top)/s.offsetHeight)}px; max-width: ${a/((t.right-t.left)/s.offsetWidth)}px`,class:"cm-completionInfo-"+(u?h?"left-narrow":"right-narrow":c?"left":"right")}}function S(e,t,i){if(e<=i)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/i);return{from:e*i,to:(e+1)*i}}let n=Math.floor((e-t)/i);return{from:e-(n+1)*i,to:e-n*i}}class C{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:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass="";let n=e.state.field(t),{options:o,selected:r}=n.open,s=e.state.facet(b);this.optionContent=function(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement("div");return t.classList.add("cm-completionIcon"),e.type&&t.classList.add(...e.type.split(/\s+/g).map((e=>"cm-completionIcon-"+e))),t.setAttribute("aria-hidden","true"),t},position:20}),t.push({render(e,t,i,n){let o=document.createElement("span");o.className="cm-completionLabel";let r=e.displayLabel||e.label,s=0;for(let e=0;e<n.length;){let t=n[e++],i=n[e++];t>s&&o.appendChild(document.createTextNode(r.slice(s,t)));let l=o.appendChild(document.createElement("span"));l.appendChild(document.createTextNode(r.slice(t,i))),l.className="cm-completionMatchedText",s=i}return s<r.length&&o.appendChild(document.createTextNode(r.slice(s))),o},position:50},{render(e){if(!e.detail)return null;let t=document.createElement("span");return t.className="cm-completionDetail",t.textContent=e.detail,t},position:80}),t.sort(((e,t)=>e.position-t.position)).map((e=>e.render))}(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=S(o.length,r,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",(i=>{let{options:n}=e.state.field(t).open;for(let t,o=i.target;o&&o!=this.dom;o=o.parentNode)if("LI"==o.nodeName&&(t=/-(\d+)$/.exec(o.id))&&+t[1]<n.length)return this.applyCompletion(e,n[+t[1]]),void i.preventDefault()})),this.dom.addEventListener("focusout",(t=>{let i=e.state.field(this.stateField,!1);i&&i.tooltip&&e.state.facet(b).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:v.of(null)})})),this.showOptions(o,n.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),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=n){let{options:o,selected:r,disabled:s}=i.open;n.open&&n.open.options==o||(this.range=S(o.length,r,e.state.facet(b).maxRenderedOptions),this.showOptions(o,i.id)),this.updateSel(),s!=(null===(t=n.open)||void 0===t?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(" "))e&&this.dom.classList.remove(e);for(let e of t.split(" "))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=S(t.options.length,t.selected,this.view.state.facet(b).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:i}=t.options[t.selected],{info:n}=i;if(!n)return;let r="string"==typeof n?document.createTextNode(n):n(i);if(!r)return;"then"in r?r.then((t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,i)})).catch((e=>o.logException(this.view.state,e,"completion info"))):this.addInfoPane(r,i)}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",null!=e.nodeType)i.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:n}=e;i.appendChild(t),this.infoDestroy=n||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,n=this.range.from;i;i=i.nextSibling,n++)"LI"==i.nodeName&&i.id?n==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected"):n--;return t&&function(e,t){let i=e.getBoundingClientRect(),n=t.getBoundingClientRect(),o=i.height/e.offsetHeight;n.top<i.top?e.scrollTop-=(i.top-n.top)/o:n.bottom>i.bottom&&(e.scrollTop+=(n.bottom-i.bottom)/o)}(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(),n=e.getBoundingClientRect(),o=this.space;if(!o){let e=this.dom.ownerDocument.defaultView||window;o={left:0,top:0,right:e.innerWidth,bottom:e.innerHeight}}return n.top>Math.min(o.bottom,t.bottom)-10||n.bottom<Math.max(o.top,t.top)+10?null:this.view.state.facet(b).positionInfo(this.view,t,n,i,o,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){const n=document.createElement("ul");n.id=t,n.setAttribute("role","listbox"),n.setAttribute("aria-expanded","true"),n.setAttribute("aria-label",this.view.state.phrase("Completions"));let o=null;for(let r=i.from;r<i.to;r++){let{completion:s,match:l}=e[r],{section:a}=s;if(a){let e="string"==typeof a?a:a.name;if(e!=o&&(r>i.from||0==i.from))if(o=e,"string"!=typeof a&&a.header)n.appendChild(a.header(a));else{n.appendChild(document.createElement("completion-section")).textContent=e}}const h=n.appendChild(document.createElement("li"));h.id=t+"-"+r,h.setAttribute("role","option");let c=this.optionClass(s);c&&(h.className=c);for(let e of this.optionContent){let t=e(s,this.view.state,this.view,l);t&&h.appendChild(t)}}return i.from&&n.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&n.classList.add("cm-completionListIncompleteBottom"),n}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function A(e){return 100*(e.boost||0)+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}class M{constructor(e,t,i,n,o,r){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=n,this.selected=o,this.disabled=r}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new M(this.options,D(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,n,o){let r=function(e,t){let i=[],n=null,o=e=>{i.push(e);let{section:t}=e.completion;if(t){n||(n=[]);let e="string"==typeof t?t:t.name;n.some((t=>t.name==e))||n.push("string"==typeof t?{name:e}:t)}},r=t.facet(b);for(let n of e)if(n.hasResult()){let e=n.result.getMatch;if(!1===n.result.filter)for(let t of n.result.options)o(new h(t,n.source,e?e(t):[],1e9-i.length));else{let i,s=t.sliceDoc(n.from,n.to),l=r.filterStrict?new y(s):new w(s);for(let t of n.result.options)if(i=l.match(t.label)){let r=t.displayLabel?e?e(t,i.matched):[]:i.matched;o(new h(t,n.source,r,i.score+(t.boost||0)))}}}if(n){let e=Object.create(null),t=0,o=(e,t)=>{var i,n;return(null!==(i=e.rank)&&void 0!==i?i:1e9)-(null!==(n=t.rank)&&void 0!==n?n:1e9)||(e.name<t.name?-1:1)};for(let i of n.sort(o))t-=1e5,e[i.name]=t;for(let t of i){let{section:i}=t.completion;i&&(t.score+=e["string"==typeof i?i:i.name])}}let s=[],l=null,a=r.compareCompletions;for(let e of i.sort(((e,t)=>t.score-e.score||a(e.completion,t.completion)))){let t=e.completion;!l||l.label!=t.label||l.detail!=t.detail||null!=l.type&&null!=t.type&&l.type!=t.type||l.apply!=t.apply||l.boost!=t.boost?s.push(e):A(e.completion)>A(l)&&(s[s.length-1]=e),l=e.completion}return s}(e,t);if(!r.length)return n&&e.some((e=>1==e.state))?new M(n.options,n.attrs,n.tooltip,n.timestamp,n.selected,!0):null;let s=t.facet(b).selectOnOpen?0:-1;if(n&&n.selected!=s&&-1!=n.selected){let e=n.options[n.selected].completion;for(let t=0;t<r.length;t++)if(r[t].completion==e){s=t;break}}return new M(r,D(i,s),{pos:e.reduce(((e,t)=>t.hasResult()?Math.min(e,t.from):e),1e8),create:V,above:o.aboveCursor},n?n.timestamp:Date.now(),s,!1)}map(e){return new M(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}}class O{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new O(E,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,i=t.facet(b),n=(i.override||t.languageDataAt("autocomplete",c(t)).map(m)).map((t=>(this.active.find((e=>e.source==t))||new R(t,this.active.some((e=>0!=e.state))?1:0)).update(e,i)));n.length==this.active.length&&n.every(((e,t)=>e==this.active[t]))&&(n=this.active);let o=this.open;o&&e.docChanged&&(o=o.map(e.changes)),e.selection||n.some((t=>t.hasResult()&&e.changes.touchesRange(t.from,t.to)))||!function(e,t){if(e==t)return!0;for(let i=0,n=0;;){for(;i<e.length&&!e[i].hasResult;)i++;for(;n<t.length&&!t[n].hasResult;)n++;let o=i==e.length,r=n==t.length;if(o||r)return o==r;if(e[i++].result!=t[n++].result)return!1}}(n,this.active)?o=M.build(n,t,this.id,o,i):o&&o.disabled&&!n.some((e=>1==e.state))&&(o=null),!o&&n.every((e=>1!=e.state))&&n.some((e=>e.hasResult()))&&(n=n.map((e=>e.hasResult()?new R(e.source,0):e)));for(let t of e.effects)t.is(N)&&(o=o&&o.setSelected(t.value,this.id));return n==this.active&&o==this.open?this:new O(n,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:T}}const T={"aria-autocomplete":"list"};function D(e,t){let i={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(i["aria-activedescendant"]=e+"-"+t),i}const E=[];function P(e,t){if(e.isUserEvent("input.complete")){let i=e.annotation(d);if(i&&t.activateOnCompletion(i))return"input"}return e.isUserEvent("input.type")?"input":e.isUserEvent("delete.backward")?"delete":null}class R{constructor(e,t,i=-1){this.source=e,this.state=t,this.explicitPos=i}hasResult(){return!1}update(e,t){let i=P(e,t),n=this;i?n=n.handleUserEvent(e,i,t):e.docChanged?n=n.handleChange(e):e.selection&&0!=n.state&&(n=new R(n.source,0));for(let t of e.effects)if(t.is(g))n=new R(n.source,1,t.value?c(e.state):-1);else if(t.is(v))n=new R(n.source,0);else if(t.is(B))for(let e of t.value)e.source==n.source&&(n=e);return n}handleUserEvent(e,t,i){return"delete"!=t&&i.activateOnTyping?new R(this.source,1):this.map(e.changes)}handleChange(e){return e.changes.touchesRange(c(e.startState))?new R(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new R(this.source,this.state,e.mapPos(this.explicitPos))}}class L extends R{constructor(e,t,i,n,o){super(e,2,t),this.result=i,this.from=n,this.to=o}hasResult(){return!0}handleUserEvent(e,t,i){var n;let o=this.result;o.map&&!e.changes.empty&&(o=o.map(o,e.changes));let r=e.changes.mapPos(this.from),l=e.changes.mapPos(this.to,1),a=c(e.state);if((this.explicitPos<0?a<=r:a<this.from)||a>l||!o||"delete"==t&&c(e.startState)==this.from)return new R(this.source,"input"==t&&i.activateOnTyping?1:0);let h=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos);return function(e,t,i,n){if(!e)return!1;let o=t.sliceDoc(i,n);return"function"==typeof e?e(o,i,n,t):u(e,!0).test(o)}(o.validFor,e.state,r,l)?new L(this.source,h,o,r,l):o.update&&(o=o.update(o,r,l,new s(e.state,a,h>=0)))?new L(this.source,h,o,o.from,null!==(n=o.to)&&void 0!==n?n:c(e.state)):new R(this.source,1,h)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new R(this.source,0):this.map(e.changes)}map(e){if(e.empty)return this;return(this.result.map?this.result.map(this.result,e):this.result)?new L(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new R(this.source,0)}}const B=n.StateEffect.define({map:(e,t)=>e.map((e=>e.map(t)))}),N=n.StateEffect.define(),I=n.StateField.define({create:()=>O.start(),update:(e,t)=>e.update(t),provide:e=>[o.showTooltip.from(e,(e=>e.tooltip)),o.EditorView.contentAttributes.from(e,(e=>e.attrs))]});function _(e,t){const i=t.completion.apply||t.completion.label;let n=e.state.field(I).active.find((e=>e.source==t.source));return n instanceof L&&("string"==typeof i?e.dispatch(Object.assign(Object.assign({},f(e.state,i,n.from,n.to)),{annotations:d.of(t.completion)})):i(e,t.completion,n.from,n.to),!0)}const V=function(e,t){return i=>new C(i,e,t)}(I,_);function F(e,t="option"){return i=>{let n=i.state.field(I,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<i.state.facet(b).interactionDelay)return!1;let r,s=1;"page"==t&&(r=o.getTooltip(i,n.open.tooltip))&&(s=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:l}=n.open.options,a=n.open.selected>-1?n.open.selected+s*(e?1:-1):e?0:l-1;return a<0?a="page"==t?0:l-1:a>=l&&(a="page"==t?l-1:0),i.dispatch({effects:N.of(a)}),!0}}const H=e=>{let t=e.state.field(I,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(b).interactionDelay)&&_(e,t.open.options[t.open.selected])},W=e=>!!e.state.field(I,!1)&&(e.dispatch({effects:g.of(!0)}),!0),q=e=>{let t=e.state.field(I,!1);return!(!t||!t.active.some((e=>0!=e.state)))&&(e.dispatch({effects:v.of(null)}),!0)};class z{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const U=o.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(I).active)1==t.state&&this.startQuery(t)}update(e){let t=e.state.field(I),i=e.state.facet(b);if(!e.selectionSet&&!e.docChanged&&e.startState.field(I)==t)return;let n=e.transactions.some((e=>(e.selection||e.docChanged)&&!P(e,i)));for(let t=0;t<this.running.length;t++){let i=this.running[t];if(n||i.updates.length+e.transactions.length>50&&Date.now()-i.time>1e3){for(let e of i.context.abortListeners)try{e()}catch(e){o.logException(this.view.state,e)}i.context.abortListeners=null,this.running.splice(t--,1)}else i.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some((e=>e.effects.some((e=>e.is(g)))))&&(this.pendingStart=!0);let r=this.pendingStart?50:i.activateOnTypingDelay;if(this.debounceUpdate=t.active.some((e=>1==e.state&&!this.running.some((t=>t.active.source==e.source))))?setTimeout((()=>this.startUpdate()),r):-1,0!=this.composing)for(let t of e.transactions)"input"==P(t,i)?this.composing=2:2==this.composing&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(I);for(let e of t.active)1!=e.state||this.running.some((t=>t.active.source==e.source))||this.startQuery(e)}startQuery(e){let{state:t}=this.view,i=c(t),n=new s(t,i,e.explicitPos==i),r=new z(e,n);this.running.push(r),Promise.resolve(e.source(n)).then((e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())}),(e=>{this.view.dispatch({effects:v.of(null)}),o.logException(this.view.state,e)}))}scheduleAccept(){this.running.every((e=>void 0!==e.done))?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(b).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],i=this.view.state.facet(b);for(let n=0;n<this.running.length;n++){let o=this.running[n];if(void 0===o.done)continue;if(this.running.splice(n--,1),o.done){let n=new L(o.active.source,o.active.explicitPos,o.done,o.done.from,null!==(e=o.done.to)&&void 0!==e?e:c(o.updates.length?o.updates[0].startState:this.view.state));for(let e of o.updates)n=n.update(e,i);if(n.hasResult()){t.push(n);continue}}let r=this.view.state.field(I).active.find((e=>e.source==o.active.source));if(r&&1==r.state)if(null==o.done){let e=new R(o.active.source,0);for(let t of o.updates)e=e.update(t,i);1!=e.state&&t.push(e)}else this.startQuery(r)}t.length&&this.view.dispatch({effects:B.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(I,!1);if(t&&t.tooltip&&this.view.state.facet(b).closeOnBlur){let i=t.open&&o.getTooltip(this.view,t.open.tooltip);i&&i.dom.contains(e.relatedTarget)||setTimeout((()=>this.view.dispatch({effects:v.of(null)})),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:g.of(!1)})),20),this.composing=0}}}),j="object"==typeof navigator&&/Win/.test(navigator.platform),Q=n.Prec.highest(o.EditorView.domEventHandlers({keydown(e,t){let i=t.state.field(I,!1);if(!i||!i.open||i.open.disabled||i.open.selected<0||e.key.length>1||e.ctrlKey&&(!j||!e.altKey)||e.metaKey)return!1;let n=i.open.options[i.open.selected],o=i.active.find((e=>e.source==n.source)),r=n.completion.commitCharacters||o.result.commitCharacters;return r&&r.indexOf(e.key)>-1&&_(t,n),!1}})),K=o.EditorView.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class ${constructor(e,t,i,n){this.field=e,this.line=t,this.from=i,this.to=n}}class G{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,n.MapMode.TrackDel),i=e.mapPos(this.to,1,n.MapMode.TrackDel);return null==t||null==i?null:new G(this.field,t,i)}}class X{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],n=[t],o=e.doc.lineAt(t),s=/^\s*/.exec(o.text)[0];for(let o of this.lines){if(i.length){let i=s,l=/^\t*/.exec(o)[0].length;for(let t=0;t<l;t++)i+=e.facet(r.indentUnit);n.push(t+i.length-l),o=i+o.slice(l)}i.push(o),t+=o.length+1}let l=this.fieldPositions.map((e=>new G(e.field,n[e.line]+e.from,n[e.line]+e.to)));return{text:i,ranges:l}}static parse(e){let t,i=[],n=[],o=[];for(let r of e.split(/\r\n?|\n/)){for(;t=/[#$]\{(?:(\d+)(?::([^}]*))?|([^}]*))\}/.exec(r);){let e=t[1]?+t[1]:null,s=t[2]||t[3]||"",l=-1;for(let t=0;t<i.length;t++)(null!=e?i[t].seq==e:s&&i[t].name==s)&&(l=t);if(l<0){let t=0;for(;t<i.length&&(null==e||null!=i[t].seq&&i[t].seq<e);)t++;i.splice(t,0,{seq:e,name:s}),l=t;for(let e of o)e.field>=l&&e.field++}o.push(new $(l,n.length,t.index,t.index+s.length)),r=r.slice(0,t.index)+s+r.slice(t.index+t[0].length)}for(let e;e=/\\([{}])/.exec(r);){r=r.slice(0,e.index)+e[1]+r.slice(e.index+e[0].length);for(let t of o)t.line==n.length&&t.from>e.index&&(t.from--,t.to--)}n.push(r)}return new X(n,o)}}let Y=o.Decoration.widget({widget:new class extends o.WidgetType{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),J=o.Decoration.mark({class:"cm-snippetField"});class Z{constructor(e,t){this.ranges=e,this.active=t,this.deco=o.Decoration.set(e.map((e=>(e.from==e.to?Y:J).range(e.from,e.to))))}map(e){let t=[];for(let i of this.ranges){let n=i.map(e);if(!n)return null;t.push(n)}return new Z(t,this.active)}selectionInsideField(e){return e.ranges.every((e=>this.ranges.some((t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))))}}const ee=n.StateEffect.define({map:(e,t)=>e&&e.map(t)}),te=n.StateEffect.define(),ie=n.StateField.define({create:()=>null,update(e,t){for(let i of t.effects){if(i.is(ee))return i.value;if(i.is(te)&&e)return new Z(e.ranges,i.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>o.EditorView.decorations.from(e,(e=>e?e.deco:o.Decoration.none))});function ne(e,t){return n.EditorSelection.create(e.filter((e=>e.field==t)).map((e=>n.EditorSelection.range(e.from,e.to))))}function oe(e){let t=X.parse(e);return(e,i,o,r)=>{let{text:s,ranges:l}=t.instantiate(e.state,o),a={changes:{from:o,to:r,insert:n.Text.of(s)},scrollIntoView:!0,annotations:i?[d.of(i),n.Transaction.userEvent.of("input.complete")]:void 0};if(l.length&&(a.selection=ne(l,0)),l.some((e=>e.field>0))){let t=new Z(l,0),i=a.effects=[ee.of(t)];void 0===e.state.field(ie,!1)&&i.push(n.StateEffect.appendConfig.of([ie,ue,de,K]))}e.dispatch(e.state.update(a))}}function re(e){return({state:t,dispatch:i})=>{let n=t.field(ie,!1);if(!n||e<0&&0==n.active)return!1;let o=n.active+e,r=e>0&&!n.ranges.some((t=>t.field==o+e));return i(t.update({selection:ne(n.ranges,o),effects:ee.of(r?null:new Z(n.ranges,o)),scrollIntoView:!0})),!0}}const se=({state:e,dispatch:t})=>!!e.field(ie,!1)&&(t(e.update({effects:ee.of(null)})),!0),le=re(1),ae=re(-1);const he=[{key:"Tab",run:le,shift:ae},{key:"Escape",run:se}],ce=n.Facet.define({combine:e=>e.length?e[0]:he}),ue=n.Prec.highest(o.keymap.compute([ce],(e=>e.facet(ce))));const de=o.EditorView.domEventHandlers({mousedown(e,t){let i,n=t.state.field(ie,!1);if(!n||null==(i=t.posAtCoords({x:e.clientX,y:e.clientY})))return!1;let o=n.ranges.find((e=>e.from<=i&&e.to>=i));return!(!o||o.field==n.active)&&(t.dispatch({selection:ne(n.ranges,o.field),effects:ee.of(n.ranges.some((e=>e.field>o.field))?new Z(n.ranges,o.field):null),scrollIntoView:!0}),!0)}});function fe(e,t){return new RegExp(t(e.source),e.unicode?"u":"")}const pe=Object.create(null);function me(e,t,i,n,o){for(let r=e.iterLines(),s=0;!r.next().done;){let e,{value:l}=r;for(t.lastIndex=0;e=t.exec(l);)if(!n[e[0]]&&s+e.index!=o&&(i.push({type:"text",label:e[0]}),n[e[0]]=!0,i.length>=2e3))return;s+=l.length+1}}function ge(e,t,i,n,o){let r=e.length>=1e3,s=r&&t.get(e);if(s)return s;let l=[],a=Object.create(null);if(e.children){let r=0;for(let s of e.children){if(s.length>=1e3)for(let e of ge(s,t,i,n-r,o-r))a[e.label]||(a[e.label]=!0,l.push(e));else me(s,i,l,a,o-r);r+=s.length+1}}else me(e,i,l,a,o);return r&&l.length<2e3&&t.set(e,l),l}const ve={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},we=n.StateEffect.define({map(e,t){let i=t.mapPos(e,-1,n.MapMode.TrackAfter);return null==i?void 0:i}}),ye=new class extends n.RangeValue{};ye.startSide=1,ye.endSide=-1;const be=n.StateField.define({create:()=>n.RangeSet.empty,update(e,t){if(e=e.map(t.changes),t.selection){let i=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=i.from&&e<=i.to})}for(let i of t.effects)i.is(we)&&(e=e.update({add:[ye.range(i.value,i.value+1)]}));return e}});const xe="()[]{}<>";function ke(e){for(let t=0;t<xe.length;t+=2)if(xe.charCodeAt(t)==e)return xe.charAt(t+1);return n.fromCodePoint(e<128?e:e+1)}function Se(e,t){return e.languageDataAt("closeBrackets",t)[0]||ve}const Ce="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),Ae=o.EditorView.inputHandler.of(((e,t,i,o)=>{if((Ce?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let r=e.state.selection.main;if(o.length>2||2==o.length&&1==n.codePointSize(n.codePointAt(o,0))||t!=r.from||i!=r.to)return!1;let s=Te(e.state,o);return!!s&&(e.dispatch(s),!0)})),Me=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=Se(e,e.selection.main.head).brackets||ve.brackets,o=null,r=e.changeByRange((t=>{if(t.empty){let o=function(e,t){let i=e.sliceString(t-2,t);return n.codePointSize(n.codePointAt(i,0))==i.length?i:i.slice(1)}(e.doc,t.head);for(let r of i)if(r==o&&Ee(e.doc,t.head)==ke(n.codePointAt(r,0)))return{changes:{from:t.head-r.length,to:t.head+r.length},range:n.EditorSelection.cursor(t.head-r.length)}}return{range:o=t}}));return o||t(e.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!o},Oe=[{key:"Backspace",run:Me}];function Te(e,t){let i=Se(e,e.selection.main.head),o=i.brackets||ve.brackets;for(let r of o){let s=ke(n.codePointAt(r,0));if(t==r)return s==r?Le(e,r,o.indexOf(r+r+r)>-1,i):Pe(e,r,s,i.before||ve.before);if(t==s&&De(e,e.selection.main.from))return Re(e,r,s)}return null}function De(e,t){let i=!1;return e.field(be).between(0,e.doc.length,(e=>{e==t&&(i=!0)})),i}function Ee(e,t){let i=e.sliceString(t,t+2);return i.slice(0,n.codePointSize(n.codePointAt(i,0)))}function Pe(e,t,i,o){let r=null,s=e.changeByRange((s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:i,from:s.to}],effects:we.of(s.to+t.length),range:n.EditorSelection.range(s.anchor+t.length,s.head+t.length)};let l=Ee(e.doc,s.head);return!l||/\s/.test(l)||o.indexOf(l)>-1?{changes:{insert:t+i,from:s.head},effects:we.of(s.head+t.length),range:n.EditorSelection.cursor(s.head+t.length)}:{range:r=s}}));return r?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function Re(e,t,i){let o=null,r=e.changeByRange((t=>t.empty&&Ee(e.doc,t.head)==i?{changes:{from:t.head,to:t.head+i.length,insert:i},range:n.EditorSelection.cursor(t.head+i.length)}:o={range:t}));return o?null:e.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Le(e,t,i,o){let s=o.stringPrefixes||ve.stringPrefixes,l=null,a=e.changeByRange((o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:t,from:o.to}],effects:we.of(o.to+t.length),range:n.EditorSelection.range(o.anchor+t.length,o.head+t.length)};let a,h=o.head,c=Ee(e.doc,h);if(c==t){if(Be(e,h))return{changes:{insert:t+t,from:h},effects:we.of(h+t.length),range:n.EditorSelection.cursor(h+t.length)};if(De(e,h)){let o=i&&e.sliceDoc(h,h+3*t.length)==t+t+t?t+t+t:t;return{changes:{from:h,to:h+o.length,insert:o},range:n.EditorSelection.cursor(h+o.length)}}}else{if(i&&e.sliceDoc(h-2*t.length,h)==t+t&&(a=Ne(e,h-2*t.length,s))>-1&&Be(e,a))return{changes:{insert:t+t+t+t,from:h},effects:we.of(h+t.length),range:n.EditorSelection.cursor(h+t.length)};if(e.charCategorizer(h)(c)!=n.CharCategory.Word&&Ne(e,h,s)>-1&&!function(e,t,i,n){let o=r.syntaxTree(e).resolveInner(t,-1),s=n.reduce(((e,t)=>Math.max(e,t.length)),0);for(let r=0;r<5;r++){let r=e.sliceDoc(o.from,Math.min(o.to,o.from+i.length+s)),l=r.indexOf(i);if(!l||l>-1&&n.indexOf(r.slice(0,l))>-1){let t=o.firstChild;for(;t&&t.from==o.from&&t.to-t.from>i.length+l;){if(e.sliceDoc(t.to-i.length,t.to)==i)return!1;t=t.firstChild}return!0}let a=o.to==t&&o.parent;if(!a)break;o=a}return!1}(e,h,t,s))return{changes:{insert:t+t,from:h},effects:we.of(h+t.length),range:n.EditorSelection.cursor(h+t.length)}}return{range:l=o}}));return l?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function Be(e,t){let i=r.syntaxTree(e).resolveInner(t+1);return i.parent&&i.from==t}function Ne(e,t,i){let o=e.charCategorizer(t);if(o(e.sliceDoc(t-1,t))!=n.CharCategory.Word)return t;for(let r of i){let i=t-r.length;if(e.sliceDoc(i,t)==r&&o(e.sliceDoc(i-1,i))!=n.CharCategory.Word)return i}return-1}const Ie=[{key:"Ctrl-Space",run:W},{key:"Escape",run:q},{key:"ArrowDown",run:F(!0)},{key:"ArrowUp",run:F(!1)},{key:"PageDown",run:F(!0,"page")},{key:"PageUp",run:F(!1,"page")},{key:"Enter",run:H}],_e=n.Prec.highest(o.keymap.computeN([b],(e=>e.facet(b).defaultKeymap?[Ie]:[])));const Ve=new WeakMap;t.CompletionContext=s,t.acceptCompletion=H,t.autocompletion=function(e={}){return[Q,I,b.of(e),U,_e,K]},t.clearSnippet=se,t.closeBrackets=function(){return[Ae,be]},t.closeBracketsKeymap=Oe,t.closeCompletion=q,t.completeAnyWord=e=>{let t=e.state.languageDataAt("wordChars",e.pos).join(""),i=function(e){let t=e.replace(/[\]\-\\]/g,"\\$&");try{return new RegExp(`[\\p{Alphabetic}\\p{Number}_${t}]+`,"ug")}catch(e){return new RegExp(`[w${t}]`,"g")}}(t),n=e.matchBefore(fe(i,(e=>e+"$")));if(!n&&!e.explicit)return null;let o=n?n.from:e.pos,r=ge(e.state.doc,function(e){return pe[e]||(pe[e]=new WeakMap)}(t),i,5e4,o);return{from:o,options:r,validFor:fe(i,(e=>"^"+e))}},t.completeFromList=a,t.completionKeymap=Ie,t.completionStatus=function(e){let t=e.field(I,!1);return t&&t.active.some((e=>1==e.state))?"pending":t&&t.active.some((e=>0!=e.state))?"active":null},t.currentCompletions=function(e){var t;let i=null===(t=e.field(I,!1))||void 0===t?void 0:t.open;if(!i||i.disabled)return[];let n=Ve.get(i.options);return n||Ve.set(i.options,n=i.options.map((e=>e.completion))),n},t.deleteBracketPair=Me,t.hasNextSnippetField=function(e){let t=e.field(ie,!1);return!(!t||!t.ranges.some((e=>e.field==t.active+1)))},t.hasPrevSnippetField=function(e){let t=e.field(ie,!1);return!!(t&&t.active>0)},t.ifIn=function(e,t){return i=>{for(let n=r.syntaxTree(i.state).resolveInner(i.pos,-1);n;n=n.parent){if(e.indexOf(n.name)>-1)return t(i);if(n.type.isTop)break}return null}},t.ifNotIn=function(e,t){return i=>{for(let t=r.syntaxTree(i.state).resolveInner(i.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(i)}},t.insertBracket=Te,t.insertCompletionText=f,t.moveCompletionSelection=F,t.nextSnippetField=le,t.pickedCompletion=d,t.prevSnippetField=ae,t.selectedCompletion=function(e){var t;let i=null===(t=e.field(I,!1))||void 0===t?void 0:t.open;return i&&!i.disabled&&i.selected>=0?i.options[i.selected].completion:null},t.selectedCompletionIndex=function(e){var t;let i=null===(t=e.field(I,!1))||void 0===t?void 0:t.open;return i&&!i.disabled&&i.selected>=0?i.selected:null},t.setSelectedCompletion=function(e){return N.of(e)},t.snippet=oe,t.snippetCompletion=function(e,t){return Object.assign(Object.assign({},t),{apply:oe(e)})},t.snippetKeymap=ce,t.startCompletion=W},59277:(e,t,i)=>{var n=i(89064),o=i(61506),r=i(92533),s=i(52696);const l=e=>{let{state:t}=e,i=t.doc.lineAt(t.selection.main.from),n=g(e.state,i.from);return n.line?h(e):!!n.block&&m(e)};function a(e,t){return({state:i,dispatch:n})=>{if(i.readOnly)return!1;let o=e(t,i);return!!o&&(n(i.update(o)),!0)}}const h=a(y,0),c=a(y,1),u=a(y,2),d=a(w,0),f=a(w,1),p=a(w,2),m=a(((e,t)=>w(e,t,function(e){let t=[];for(let i of e.selection.ranges){let n=e.doc.lineAt(i.from),o=i.to<=n.to?n:e.doc.lineAt(i.to),r=t.length-1;r>=0&&t[r].to>n.from?t[r].to=o.to:t.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:o.to})}return t}(t))),0);function g(e,t){let i=e.languageDataAt("commentTokens",t);return i.length?i[0]:{}}const v=50;function w(e,t,i=t.selection.ranges){let n=i.map((e=>g(t,e.from).block));if(!n.every((e=>e)))return null;let o=i.map(((e,i)=>function(e,{open:t,close:i},n,o){let r,s,l=e.sliceDoc(n-v,n),a=e.sliceDoc(o,o+v),h=/\s*$/.exec(l)[0].length,c=/^\s*/.exec(a)[0].length,u=l.length-h;if(l.slice(u-t.length,u)==t&&a.slice(c,c+i.length)==i)return{open:{pos:n-h,margin:h&&1},close:{pos:o+c,margin:c&&1}};o-n<=2*v?r=s=e.sliceDoc(n,o):(r=e.sliceDoc(n,n+v),s=e.sliceDoc(o-v,o));let d=/^\s*/.exec(r)[0].length,f=/\s*$/.exec(s)[0].length,p=s.length-f-i.length;return r.slice(d,d+t.length)==t&&s.slice(p,p+i.length)==i?{open:{pos:n+d+t.length,margin:/\s/.test(r.charAt(d+t.length))?1:0},close:{pos:o-f-i.length,margin:/\s/.test(s.charAt(p-1))?1:0}}:null}(t,n[i],e.from,e.to)));if(2!=e&&!o.every((e=>e)))return{changes:t.changes(i.map(((e,t)=>o[t]?[]:[{from:e.from,insert:n[t].open+" "},{from:e.to,insert:" "+n[t].close}])))};if(1!=e&&o.some((e=>e))){let e=[];for(let t,i=0;i<o.length;i++)if(t=o[i]){let o=n[i],{open:r,close:s}=t;e.push({from:r.pos-o.open.length,to:r.pos+r.margin},{from:s.pos-s.margin,to:s.pos+o.close.length})}return{changes:e}}return null}function y(e,t,i=t.selection.ranges){let n=[],o=-1;for(let{from:e,to:r}of i){let i=n.length,s=1e9,l=g(t,e).line;if(l){for(let i=e;i<=r;){let a=t.doc.lineAt(i);if(a.from>o&&(e==r||r>a.from)){o=a.from;let e=/^\s*/.exec(a.text)[0].length,t=e==a.length,i=a.text.slice(e,e+l.length)==l?e:-1;e<a.text.length&&e<s&&(s=e),n.push({line:a,comment:i,token:l,indent:e,empty:t,single:!1})}i=a.to+1}if(s<1e9)for(let e=i;e<n.length;e++)n[e].indent<n[e].line.text.length&&(n[e].indent=s);n.length==i+1&&(n[i].single=!0)}}if(2!=e&&n.some((e=>e.comment<0&&(!e.empty||e.single)))){let e=[];for(let{line:t,token:i,indent:o,empty:r,single:s}of n)!s&&r||e.push({from:t.from+o,insert:i+" "});let i=t.changes(e);return{changes:i,selection:t.selection.map(i,1)}}if(1!=e&&n.some((e=>e.comment>=0))){let e=[];for(let{line:t,comment:i,token:o}of n)if(i>=0){let n=t.from+i,r=n+o.length;" "==t.text[r-t.from]&&r++,e.push({from:n,to:r})}return{changes:e}}return null}const b=n.Annotation.define(),x=n.Annotation.define(),k=n.Facet.define(),S=n.Facet.define({combine:e=>n.combineConfig(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,n)=>e(i,n)||t(i,n)})}),C=n.StateField.define({create:()=>U.empty,update(e,t){let i=t.state.facet(S),o=t.annotation(b);if(o){let n=B.fromTransaction(t,o.selection),r=o.side,s=0==r?e.undone:e.done;return s=n?N(s,s.length,i.minDepth,n):F(s,t.startState.selection),new U(0==r?o.rest:s,0==r?s:o.rest)}let r=t.annotation(x);if("full"!=r&&"before"!=r||(e=e.isolate()),!1===t.annotation(n.Transaction.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let s=B.fromTransaction(t),l=t.annotation(n.Transaction.time),a=t.annotation(n.Transaction.userEvent);return s?e=e.addChanges(s,l,a,i,t):t.selection&&(e=e.addSelection(t.startState.selection,l,a,i.newGroupDelay)),"full"!=r&&"after"!=r||(e=e.isolate()),e},toJSON:e=>({done:e.done.map((e=>e.toJSON())),undone:e.undone.map((e=>e.toJSON()))}),fromJSON:e=>new U(e.done.map(B.fromJSON),e.undone.map(B.fromJSON))});const A=C;function M(e,t){return function({state:i,dispatch:n}){if(!t&&i.readOnly)return!1;let o=i.field(C,!1);if(!o)return!1;let r=o.pop(e,i,t);return!!r&&(n(r),!0)}}const O=M(0,!1),T=M(1,!1),D=M(0,!0),E=M(1,!0);function P(e){return function(t){let i=t.field(C,!1);if(!i)return 0;let n=0==e?i.done:i.undone;return n.length-(n.length&&!n[0].changes?1:0)}}const R=P(0),L=P(1);class B{constructor(e,t,i,n,o){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=n,this.selectionsAfter=o}setSelAfter(e){return new B(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(i=this.startSelection)||void 0===i?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map((e=>e.toJSON()))}}static fromJSON(e){return new B(e.changes&&n.ChangeSet.fromJSON(e.changes),[],e.mapped&&n.ChangeDesc.fromJSON(e.mapped),e.startSelection&&n.EditorSelection.fromJSON(e.startSelection),e.selectionsAfter.map(n.EditorSelection.fromJSON))}static fromTransaction(e,t){let i=_;for(let t of e.startState.facet(k)){let n=t(e);n.length&&(i=i.concat(n))}return!i.length&&e.changes.empty?null:new B(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,_)}static selection(e){return new B(void 0,_,void 0,void 0,e)}}function N(e,t,i,n){let o=t+1>i+20?t-i-1:0,r=e.slice(o,t);return r.push(n),r}function I(e,t){return e.length?t.length?e.concat(t):e:t}const _=[],V=200;function F(e,t){if(e.length){let i=e[e.length-1],n=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-V));return n.length&&n[n.length-1].eq(t)?e:(n.push(t),N(e,e.length-1,1e9,i.setSelAfter(n)))}return[B.selection([t])]}function H(e){let t=e[e.length-1],i=e.slice();return i[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),i}function W(e,t){if(!e.length)return e;let i=e.length,n=_;for(;i;){let o=q(e[i-1],t,n);if(o.changes&&!o.changes.empty||o.effects.length){let t=e.slice(0,i);return t[i-1]=o,t}t=o.mapped,i--,n=o.selectionsAfter}return n.length?[B.selection(n)]:_}function q(e,t,i){let o=I(e.selectionsAfter.length?e.selectionsAfter.map((e=>e.map(t))):_,i);if(!e.changes)return B.selection(o);let r=e.changes.map(t),s=t.mapDesc(e.changes,!0),l=e.mapped?e.mapped.composeDesc(s):s;return new B(r,n.StateEffect.mapEffects(e.effects,t),l,e.startSelection.map(s),o)}const z=/^(input\.type|delete)($|\.)/;class U{constructor(e,t,i=0,n=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new U(this.done,this.undone):this}addChanges(e,t,i,n,o){let r=this.done,s=r[r.length-1];return r=s&&s.changes&&!s.changes.empty&&e.changes&&(!i||z.test(i))&&(!s.selectionsAfter.length&&t-this.prevTime<n.newGroupDelay&&n.joinToEvent(o,function(e,t){let i=[],n=!1;return e.iterChangedRanges(((e,t)=>i.push(e,t))),t.iterChangedRanges(((e,t,o,r)=>{for(let e=0;e<i.length;){let t=i[e++],s=i[e++];r>=t&&o<=s&&(n=!0)}})),n}(s.changes,e.changes))||"input.type.compose"==i)?N(r,r.length-1,n.minDepth,new B(e.changes.compose(s.changes),I(e.effects,s.effects),s.mapped,s.startSelection,_)):N(r,r.length,n.minDepth,e),new U(r,_,t,i)}addSelection(e,t,i,n){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:_;return o.length>0&&t-this.prevTime<n&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&(r=o[o.length-1],s=e,r.ranges.length==s.ranges.length&&0===r.ranges.filter(((e,t)=>e.empty!=s.ranges[t].empty)).length)?this:new U(F(this.done,e),this.undone,t,i);var r,s}addMapping(e){return new U(W(this.done,e),W(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let n=0==e?this.done:this.undone;if(0==n.length)return null;let o=n[n.length-1],r=o.selectionsAfter[0]||t.selection;if(i&&o.selectionsAfter.length)return t.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:b.of({side:e,rest:H(n),selection:r}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let i=1==n.length?_:n.slice(0,n.length-1);return o.mapped&&(i=W(i,o.mapped)),t.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:b.of({side:e,rest:i,selection:r}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}U.empty=new U(_,_);const j=[{key:"Mod-z",run:O,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:T,preventDefault:!0},{linux:"Ctrl-Shift-z",run:T,preventDefault:!0},{key:"Mod-u",run:D,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:E,preventDefault:!0}];function Q(e,t){return n.EditorSelection.create(e.ranges.map(t),e.mainIndex)}function K(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function $({state:e,dispatch:t},i){let n=Q(e.selection,i);return!n.eq(e.selection,!0)&&(t(K(e,n)),!0)}function G(e,t){return n.EditorSelection.cursor(t?e.to:e.from)}function X(e,t){return $(e,(i=>i.empty?e.moveByChar(i,t):G(i,t)))}function Y(e){return e.textDirectionAt(e.state.selection.main.head)==o.Direction.LTR}const J=e=>X(e,!Y(e)),Z=e=>X(e,Y(e));function ee(e,t){return $(e,(i=>i.empty?e.moveByGroup(i,t):G(i,t)))}const te=e=>ee(e,!Y(e)),ie=e=>ee(e,Y(e)),ne="undefined"!=typeof Intl&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function oe(e,t,i){let o=e.state.charCategorizer(t.from),r=n.CharCategory.Space,s=t.from,l=0,a=!1,h=!1,c=!1,u=t=>{if(a)return!1;s+=i?t.length:-t.length;let u,d=o(t);if(d==n.CharCategory.Word&&t.charCodeAt(0)<128&&/[\W_]/.test(t)&&(d=-1),r==n.CharCategory.Space&&(r=d),r!=d)return!1;if(r==n.CharCategory.Word)if(t.toLowerCase()==t){if(!i&&h)return!1;c=!0}else if(c){if(i)return!1;a=!0}else{if(h&&i&&o(u=e.state.sliceDoc(s,s+1))==n.CharCategory.Word&&u.toLowerCase()==u)return!1;h=!0}return l++,!0},d=e.moveByChar(t,i,(e=>(u(e),u)));if(ne&&r==n.CharCategory.Word&&d.from==t.from+l*(i?1:-1)){let o=Math.min(t.head,d.head),r=Math.max(t.head,d.head),s=e.state.sliceDoc(o,r);if(s.length>1&&/[\u4E00-\uffff]/.test(s)){let e=Array.from(ne.segment(s));if(e.length>1)return i?n.EditorSelection.cursor(t.head+e[1].index,-1):n.EditorSelection.cursor(d.head+e[e.length-1].index,1)}}return d}function re(e,t){return $(e,(i=>i.empty?oe(e,i,t):G(i,t)))}function se(e,t,i){if(t.type.prop(i))return!0;let n=t.to-t.from;return n&&(n>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function le(e,t,i){let o,l,a=r.syntaxTree(e).resolveInner(t.head),h=i?s.NodeProp.closedBy:s.NodeProp.openedBy;for(let n=t.head;;){let t=i?a.childAfter(n):a.childBefore(n);if(!t)break;se(e,t,h)?a=t:n=i?t.to:t.from}return l=a.type.prop(h)&&(o=i?r.matchBrackets(e,a.from,1):r.matchBrackets(e,a.to,-1))&&o.matched?i?o.end.to:o.end.from:i?a.to:a.from,n.EditorSelection.cursor(l,i?-1:1)}const ae=e=>$(e,(t=>le(e.state,t,!Y(e)))),he=e=>$(e,(t=>le(e.state,t,Y(e))));function ce(e,t){return $(e,(i=>{if(!i.empty)return G(i,t);let n=e.moveVertically(i,t);return n.head!=i.head?n:e.moveToLineBoundary(i,t)}))}const ue=e=>ce(e,!1),de=e=>ce(e,!0);function fe(e){let t,i=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0;if(i){for(let t of e.state.facet(o.EditorView.scrollMargins)){let i=t(e);(null==i?void 0:i.top)&&(n=Math.max(null==i?void 0:i.top,n)),(null==i?void 0:i.bottom)&&(r=Math.max(null==i?void 0:i.bottom,r))}t=e.scrollDOM.clientHeight-n-r}else t=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:i,height:Math.max(e.defaultLineHeight,t-5)}}function pe(e,t){let i,n=fe(e),{state:r}=e,s=Q(r.selection,(i=>i.empty?e.moveVertically(i,t,n.height):G(i,t)));if(s.eq(r.selection))return!1;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),l=e.scrollDOM.getBoundingClientRect(),a=l.top+n.marginTop,h=l.bottom-n.marginBottom;t&&t.top>a&&t.bottom<h&&(i=o.EditorView.scrollIntoView(s.main.head,{y:"start",yMargin:t.top-a}))}return e.dispatch(K(r,s),{effects:i}),!0}const me=e=>pe(e,!1),ge=e=>pe(e,!0);function ve(e,t,i){let o=e.lineBlockAt(t.head),r=e.moveToLineBoundary(t,i);if(r.head==t.head&&r.head!=(i?o.to:o.from)&&(r=e.moveToLineBoundary(t,i,!1)),!i&&r.head==o.from&&o.length){let i=/^\s*/.exec(e.state.sliceDoc(o.from,Math.min(o.from+100,o.to)))[0].length;i&&t.head!=o.from+i&&(r=n.EditorSelection.cursor(o.from+i))}return r}const we=e=>$(e,(t=>ve(e,t,!0))),ye=e=>$(e,(t=>ve(e,t,!1))),be=e=>$(e,(t=>ve(e,t,!Y(e)))),xe=e=>$(e,(t=>ve(e,t,Y(e)))),ke=e=>$(e,(t=>n.EditorSelection.cursor(e.lineBlockAt(t.head).from,1))),Se=e=>$(e,(t=>n.EditorSelection.cursor(e.lineBlockAt(t.head).to,-1)));function Ce(e,t,i){let o=!1,s=Q(e.selection,(t=>{let s=r.matchBrackets(e,t.head,-1)||r.matchBrackets(e,t.head,1)||t.head>0&&r.matchBrackets(e,t.head-1,1)||t.head<e.doc.length&&r.matchBrackets(e,t.head+1,-1);if(!s||!s.end)return t;o=!0;let l=s.start.from==t.head?s.end.to:s.end.from;return i?n.EditorSelection.range(t.anchor,l):n.EditorSelection.cursor(l)}));return!!o&&(t(K(e,s)),!0)}const Ae=({state:e,dispatch:t})=>Ce(e,t,!1);function Me(e,t){let i=Q(e.state.selection,(e=>{let i=t(e);return n.EditorSelection.range(e.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)}));return!i.eq(e.state.selection)&&(e.dispatch(K(e.state,i)),!0)}function Oe(e,t){return Me(e,(i=>e.moveByChar(i,t)))}const Te=e=>Oe(e,!Y(e)),De=e=>Oe(e,Y(e));function Ee(e,t){return Me(e,(i=>e.moveByGroup(i,t)))}const Pe=e=>Ee(e,!Y(e)),Re=e=>Ee(e,Y(e));function Le(e,t){return Me(e,(i=>oe(e,i,t)))}const Be=e=>Me(e,(t=>le(e.state,t,!Y(e)))),Ne=e=>Me(e,(t=>le(e.state,t,Y(e))));function Ie(e,t){return Me(e,(i=>e.moveVertically(i,t)))}const _e=e=>Ie(e,!1),Ve=e=>Ie(e,!0);function Fe(e,t){return Me(e,(i=>e.moveVertically(i,t,fe(e).height)))}const He=e=>Fe(e,!1),We=e=>Fe(e,!0),qe=e=>Me(e,(t=>ve(e,t,!0))),ze=e=>Me(e,(t=>ve(e,t,!1))),Ue=e=>Me(e,(t=>ve(e,t,!Y(e)))),je=e=>Me(e,(t=>ve(e,t,Y(e)))),Qe=e=>Me(e,(t=>n.EditorSelection.cursor(e.lineBlockAt(t.head).from))),Ke=e=>Me(e,(t=>n.EditorSelection.cursor(e.lineBlockAt(t.head).to))),$e=({state:e,dispatch:t})=>(t(K(e,{anchor:0})),!0),Ge=({state:e,dispatch:t})=>(t(K(e,{anchor:e.doc.length})),!0),Xe=({state:e,dispatch:t})=>(t(K(e,{anchor:e.selection.main.anchor,head:0})),!0),Ye=({state:e,dispatch:t})=>(t(K(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Je=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),Ze=({state:e,dispatch:t})=>{let i=mt(e).map((({from:t,to:i})=>n.EditorSelection.range(t,Math.min(i+1,e.doc.length))));return t(e.update({selection:n.EditorSelection.create(i),userEvent:"select"})),!0},et=({state:e,dispatch:t})=>{let i=Q(e.selection,(t=>{var i;for(let o=r.syntaxTree(e).resolveStack(t.from,1);o;o=o.next){let{node:e}=o;if((e.from<t.from&&e.to>=t.to||e.to>t.to&&e.from<=t.from)&&(null===(i=e.parent)||void 0===i?void 0:i.parent))return n.EditorSelection.range(e.to,e.from)}return t}));return t(K(e,i)),!0},tt=({state:e,dispatch:t})=>{let i=e.selection,o=null;return i.ranges.length>1?o=n.EditorSelection.create([i.main]):i.main.empty||(o=n.EditorSelection.create([n.EditorSelection.cursor(i.main.head)])),!!o&&(t(K(e,o)),!0)};function it(e,t){if(e.state.readOnly)return!1;let i="delete.selection",{state:r}=e,s=r.changeByRange((o=>{let{from:r,to:s}=o;if(r==s){let n=t(o);n<r?(i="delete.backward",n=nt(e,n,!1)):n>r&&(i="delete.forward",n=nt(e,n,!0)),r=Math.min(r,n),s=Math.max(s,n)}else r=nt(e,r,!1),s=nt(e,s,!0);return r==s?{range:o}:{changes:{from:r,to:s},range:n.EditorSelection.cursor(r,r<o.head?-1:1)}}));return!s.changes.empty&&(e.dispatch(r.update(s,{scrollIntoView:!0,userEvent:i,effects:"delete.selection"==i?o.EditorView.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function nt(e,t,i){if(e instanceof o.EditorView)for(let n of e.state.facet(o.EditorView.atomicRanges).map((t=>t(e))))n.between(t,t,((e,n)=>{e<t&&n>t&&(t=i?n:e)}));return t}const ot=(e,t,i)=>it(e,(o=>{let s,l,a=o.from,{state:h}=e,c=h.doc.lineAt(a);if(i&&!t&&a>c.from&&a<c.from+200&&!/[^ \t]/.test(s=c.text.slice(0,a-c.from))){if("\t"==s[s.length-1])return a-1;let e=n.countColumn(s,h.tabSize)%r.getIndentUnit(h)||r.getIndentUnit(h);for(let t=0;t<e&&" "==s[s.length-1-t];t++)a--;l=a}else l=n.findClusterBreak(c.text,a-c.from,t,t)+c.from,l==a&&c.number!=(t?h.doc.lines:1)?l+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(c.text.slice(l-c.from,a-c.from))&&(l=n.findClusterBreak(c.text,l-c.from,!1,!1)+c.from);return l})),rt=e=>ot(e,!1,!0),st=e=>ot(e,!0,!1),lt=(e,t)=>it(e,(i=>{let o=i.head,{state:r}=e,s=r.doc.lineAt(o),l=r.charCategorizer(o);for(let e=null;;){if(o==(t?s.to:s.from)){o==i.head&&s.number!=(t?r.doc.lines:1)&&(o+=t?1:-1);break}let a=n.findClusterBreak(s.text,o-s.from,t)+s.from,h=s.text.slice(Math.min(o,a)-s.from,Math.max(o,a)-s.from),c=l(h);if(null!=e&&c!=e)break;" "==h&&o==i.head||(e=c),o=a}return o})),at=e=>lt(e,!1),ht=e=>lt(e,!0),ct=e=>it(e,(t=>{let i=e.lineBlockAt(t.head).to;return t.head<i?i:Math.min(e.state.doc.length,t.head+1)})),ut=e=>it(e,(t=>{let i=e.moveToLineBoundary(t,!1).head;return t.head>i?i:Math.max(0,t.head-1)})),dt=e=>it(e,(t=>{let i=e.moveToLineBoundary(t,!0).head;return t.head<i?i:Math.min(e.state.doc.length,t.head+1)})),ft=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:n.Text.of(["",""])},range:n.EditorSelection.cursor(e.from)})));return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0},pt=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange((t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let i=t.from,o=e.doc.lineAt(i),r=i==o.from?i-1:n.findClusterBreak(o.text,i-o.from,!1)+o.from,s=i==o.to?i+1:n.findClusterBreak(o.text,i-o.from,!0)+o.from;return{changes:{from:r,to:s,insert:e.doc.slice(i,s).append(e.doc.slice(r,i))},range:n.EditorSelection.cursor(s)}}));return!i.changes.empty&&(t(e.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function mt(e){let t=[],i=-1;for(let n of e.selection.ranges){let o=e.doc.lineAt(n.from),r=e.doc.lineAt(n.to);if(n.empty||n.to!=r.from||(r=e.doc.lineAt(n.to-1)),i>=o.number){let e=t[t.length-1];e.to=r.to,e.ranges.push(n)}else t.push({from:o.from,to:r.to,ranges:[n]});i=r.number+1}return t}function gt(e,t,i){if(e.readOnly)return!1;let o=[],r=[];for(let t of mt(e)){if(i?t.to==e.doc.length:0==t.from)continue;let s=e.doc.lineAt(i?t.to+1:t.from-1),l=s.length+1;if(i){o.push({from:t.to,to:s.to},{from:t.from,insert:s.text+e.lineBreak});for(let i of t.ranges)r.push(n.EditorSelection.range(Math.min(e.doc.length,i.anchor+l),Math.min(e.doc.length,i.head+l)))}else{o.push({from:s.from,to:t.from},{from:t.to,insert:e.lineBreak+s.text});for(let e of t.ranges)r.push(n.EditorSelection.range(e.anchor-l,e.head-l))}}return!!o.length&&(t(e.update({changes:o,scrollIntoView:!0,selection:n.EditorSelection.create(r,e.selection.mainIndex),userEvent:"move.line"})),!0)}const vt=({state:e,dispatch:t})=>gt(e,t,!1),wt=({state:e,dispatch:t})=>gt(e,t,!0);function yt(e,t,i){if(e.readOnly)return!1;let n=[];for(let t of mt(e))i?n.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):n.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});return t(e.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const bt=({state:e,dispatch:t})=>yt(e,t,!1),xt=({state:e,dispatch:t})=>yt(e,t,!0),kt=e=>{if(e.state.readOnly)return!1;let{state:t}=e,i=t.changes(mt(t).map((({from:e,to:i})=>(e>0?e--:i<t.doc.length&&i++,{from:e,to:i})))),n=Q(t.selection,(t=>{let i;if(e.lineWrapping){let n=e.lineBlockAt(t.head),o=e.coordsAtPos(t.head,t.assoc||1);o&&(i=n.bottom+e.documentTop-o.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,i)})).map(i);return e.dispatch({changes:i,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};const St=At(!1),Ct=At(!0);function At(e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let o=t.changeByRange((i=>{let{from:o,to:l}=i,a=t.doc.lineAt(o),h=!e&&o==l&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let i,n=r.syntaxTree(e).resolveInner(t),o=n.childBefore(t),l=n.childAfter(t);return o&&l&&o.to<=t&&l.from>=t&&(i=o.type.prop(s.NodeProp.closedBy))&&i.indexOf(l.name)>-1&&e.doc.lineAt(o.to).from==e.doc.lineAt(l.from).from&&!/\S/.test(e.sliceDoc(o.to,l.from))?{from:o.to,to:l.from}:null}(t,o);e&&(o=l=(l<=a.to?a:t.doc.lineAt(l)).to);let c=new r.IndentContext(t,{simulateBreak:o,simulateDoubleBreak:!!h}),u=r.getIndentation(c,o);for(null==u&&(u=n.countColumn(/^\s*/.exec(t.doc.lineAt(o).text)[0],t.tabSize));l<a.to&&/\s/.test(a.text[l-a.from]);)l++;h?({from:o,to:l}=h):o>a.from&&o<a.from+100&&!/\S/.test(a.text.slice(0,o))&&(o=a.from);let d=["",r.indentString(t,u)];return h&&d.push(r.indentString(t,c.lineIndent(a.from,-1))),{changes:{from:o,to:l,insert:n.Text.of(d)},range:n.EditorSelection.cursor(o+1+d[1].length)}}));return i(t.update(o,{scrollIntoView:!0,userEvent:"input"})),!0}}function Mt(e,t){let i=-1;return e.changeByRange((o=>{let r=[];for(let n=o.from;n<=o.to;){let s=e.doc.lineAt(n);s.number>i&&(o.empty||o.to>s.from)&&(t(s,r,o),i=s.number),n=s.to+1}let s=e.changes(r);return{changes:r,range:n.EditorSelection.range(s.mapPos(o.anchor,1),s.mapPos(o.head,1))}}))}const Ot=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=Object.create(null),n=new r.IndentContext(e,{overrideIndentation:e=>{let t=i[e];return null==t?-1:t}}),o=Mt(e,((t,o,s)=>{let l=r.getIndentation(n,t.from);if(null==l)return;/\S/.test(t.text)||(l=0);let a=/^\s*/.exec(t.text)[0],h=r.indentString(e,l);(a!=h||s.from<t.from+a.length)&&(i[t.from]=l,o.push({from:t.from,to:t.from+a.length,insert:h}))}));return o.changes.empty||t(e.update(o,{userEvent:"indent"})),!0},Tt=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Mt(e,((t,i)=>{i.push({from:t.from,insert:e.facet(r.indentUnit)})})),{userEvent:"input.indent"})),!0),Dt=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Mt(e,((t,i)=>{let o=/^\s*/.exec(t.text)[0];if(!o)return;let s=n.countColumn(o,e.tabSize),l=0,a=r.indentString(e,Math.max(0,s-r.getIndentUnit(e)));for(;l<o.length&&l<a.length&&o.charCodeAt(l)==a.charCodeAt(l);)l++;i.push({from:t.from+l,to:t.from+o.length,insert:a.slice(l)})})),{userEvent:"delete.dedent"})),!0),Et=[{key:"Ctrl-b",run:J,shift:Te,preventDefault:!0},{key:"Ctrl-f",run:Z,shift:De},{key:"Ctrl-p",run:ue,shift:_e},{key:"Ctrl-n",run:de,shift:Ve},{key:"Ctrl-a",run:ke,shift:Qe},{key:"Ctrl-e",run:Se,shift:Ke},{key:"Ctrl-d",run:st},{key:"Ctrl-h",run:rt},{key:"Ctrl-k",run:ct},{key:"Ctrl-Alt-h",run:at},{key:"Ctrl-o",run:ft},{key:"Ctrl-t",run:pt},{key:"Ctrl-v",run:ge}],Pt=[{key:"ArrowLeft",run:J,shift:Te,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:te,shift:Pe,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:be,shift:Ue,preventDefault:!0},{key:"ArrowRight",run:Z,shift:De,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:ie,shift:Re,preventDefault:!0},{mac:"Cmd-ArrowRight",run:xe,shift:je,preventDefault:!0},{key:"ArrowUp",run:ue,shift:_e,preventDefault:!0},{mac:"Cmd-ArrowUp",run:$e,shift:Xe},{mac:"Ctrl-ArrowUp",run:me,shift:He},{key:"ArrowDown",run:de,shift:Ve,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Ge,shift:Ye},{mac:"Ctrl-ArrowDown",run:ge,shift:We},{key:"PageUp",run:me,shift:He},{key:"PageDown",run:ge,shift:We},{key:"Home",run:ye,shift:ze,preventDefault:!0},{key:"Mod-Home",run:$e,shift:Xe},{key:"End",run:we,shift:qe,preventDefault:!0},{key:"Mod-End",run:Ge,shift:Ye},{key:"Enter",run:St},{key:"Mod-a",run:Je},{key:"Backspace",run:rt,shift:rt},{key:"Delete",run:st},{key:"Mod-Backspace",mac:"Alt-Backspace",run:at},{key:"Mod-Delete",mac:"Alt-Delete",run:ht},{mac:"Mod-Backspace",run:ut},{mac:"Mod-Delete",run:dt}].concat(Et.map((e=>({mac:e.key,run:e.run,shift:e.shift})))),Rt=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ae,shift:Be},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:he,shift:Ne},{key:"Alt-ArrowUp",run:vt},{key:"Shift-Alt-ArrowUp",run:bt},{key:"Alt-ArrowDown",run:wt},{key:"Shift-Alt-ArrowDown",run:xt},{key:"Escape",run:tt},{key:"Mod-Enter",run:Ct},{key:"Alt-l",mac:"Ctrl-l",run:Ze},{key:"Mod-i",run:et,preventDefault:!0},{key:"Mod-[",run:Dt},{key:"Mod-]",run:Tt},{key:"Mod-Alt-\\",run:Ot},{key:"Shift-Mod-k",run:kt},{key:"Shift-Mod-\\",run:Ae},{key:"Mod-/",run:l},{key:"Alt-A",run:d}].concat(Pt),Lt={key:"Tab",run:Tt,shift:Dt};t.blockComment=f,t.blockUncomment=p,t.copyLineDown=xt,t.copyLineUp=bt,t.cursorCharBackward=e=>X(e,!1),t.cursorCharForward=e=>X(e,!0),t.cursorCharLeft=J,t.cursorCharRight=Z,t.cursorDocEnd=Ge,t.cursorDocStart=$e,t.cursorGroupBackward=e=>ee(e,!1),t.cursorGroupForward=e=>ee(e,!0),t.cursorGroupLeft=te,t.cursorGroupRight=ie,t.cursorLineBoundaryBackward=ye,t.cursorLineBoundaryForward=we,t.cursorLineBoundaryLeft=be,t.cursorLineBoundaryRight=xe,t.cursorLineDown=de,t.cursorLineEnd=Se,t.cursorLineStart=ke,t.cursorLineUp=ue,t.cursorMatchingBracket=Ae,t.cursorPageDown=ge,t.cursorPageUp=me,t.cursorSubwordBackward=e=>re(e,!1),t.cursorSubwordForward=e=>re(e,!0),t.cursorSyntaxLeft=ae,t.cursorSyntaxRight=he,t.defaultKeymap=Rt,t.deleteCharBackward=rt,t.deleteCharBackwardStrict=e=>ot(e,!1,!1),t.deleteCharForward=st,t.deleteGroupBackward=at,t.deleteGroupForward=ht,t.deleteLine=kt,t.deleteLineBoundaryBackward=ut,t.deleteLineBoundaryForward=dt,t.deleteToLineEnd=ct,t.deleteToLineStart=e=>it(e,(t=>{let i=e.lineBlockAt(t.head).from;return t.head>i?i:Math.max(0,t.head-1)})),t.deleteTrailingWhitespace=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=[];for(let t=0,n="",o=e.doc.iter();;){if(o.next(),o.lineBreak||o.done){let e=n.search(/\s+$/);if(e>-1&&i.push({from:t-(n.length-e),to:t}),o.done)break;n=""}else n=o.value;t+=o.value.length}return!!i.length&&(t(e.update({changes:i,userEvent:"delete"})),!0)},t.emacsStyleKeymap=Et,t.history=function(e={}){return[C,S.of(e),o.EditorView.domEventHandlers({beforeinput(e,t){let i="historyUndo"==e.inputType?O:"historyRedo"==e.inputType?T:null;return!!i&&(e.preventDefault(),i(t))}})]},t.historyField=A,t.historyKeymap=j,t.indentLess=Dt,t.indentMore=Tt,t.indentSelection=Ot,t.indentWithTab=Lt,t.insertBlankLine=Ct,t.insertNewline=({state:e,dispatch:t})=>(t(e.update(e.replaceSelection(e.lineBreak),{scrollIntoView:!0,userEvent:"input"})),!0),t.insertNewlineAndIndent=St,t.insertNewlineKeepIndent=({state:e,dispatch:t})=>(t(e.update(e.changeByRange((t=>{let i=/^\s*/.exec(e.doc.lineAt(t.from).text)[0];return{changes:{from:t.from,to:t.to,insert:e.lineBreak+i},range:n.EditorSelection.cursor(t.from+i.length+1)}})),{scrollIntoView:!0,userEvent:"input"})),!0),t.insertTab=({state:e,dispatch:t})=>e.selection.ranges.some((e=>!e.empty))?Tt({state:e,dispatch:t}):(t(e.update(e.replaceSelection("\t"),{scrollIntoView:!0,userEvent:"input"})),!0),t.invertedEffects=k,t.isolateHistory=x,t.lineComment=c,t.lineUncomment=u,t.moveLineDown=wt,t.moveLineUp=vt,t.redo=T,t.redoDepth=L,t.redoSelection=E,t.selectAll=Je,t.selectCharBackward=e=>Oe(e,!1),t.selectCharForward=e=>Oe(e,!0),t.selectCharLeft=Te,t.selectCharRight=De,t.selectDocEnd=Ye,t.selectDocStart=Xe,t.selectGroupBackward=e=>Ee(e,!1),t.selectGroupForward=e=>Ee(e,!0),t.selectGroupLeft=Pe,t.selectGroupRight=Re,t.selectLine=Ze,t.selectLineBoundaryBackward=ze,t.selectLineBoundaryForward=qe,t.selectLineBoundaryLeft=Ue,t.selectLineBoundaryRight=je,t.selectLineDown=Ve,t.selectLineEnd=Ke,t.selectLineStart=Qe,t.selectLineUp=_e,t.selectMatchingBracket=({state:e,dispatch:t})=>Ce(e,t,!0),t.selectPageDown=We,t.selectPageUp=He,t.selectParentSyntax=et,t.selectSubwordBackward=e=>Le(e,!1),t.selectSubwordForward=e=>Le(e,!0),t.selectSyntaxLeft=Be,t.selectSyntaxRight=Ne,t.simplifySelection=tt,t.splitLine=ft,t.standardKeymap=Pt,t.toggleBlockComment=d,t.toggleBlockCommentByLine=m,t.toggleComment=l,t.toggleLineComment=h,t.transposeChars=pt,t.undo=O,t.undoDepth=R,t.undoSelection=D},91278:(e,t,i)=>{var n=i(92533),o=i(67359),r=i(41827),s=i(80591);const l=5,a=6,h=20,c=21,u=24;function d(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57}function f(e,t,i){for(let n=!1;;){if(e.next<0)return;if(e.next==t&&!n)return void e.advance();n=i&&!n&&92==e.next,e.advance()}}function p(e,t){for(;95==e.next||d(e.next);)null!=t&&(t+=String.fromCharCode(e.next)),e.advance();return t}function m(e,t){for(;48==e.next||49==e.next;)e.advance();t&&e.next==t&&e.advance()}function g(e,t){for(;;){if(46==e.next){if(t)break;t=!0}else if(e.next<48||e.next>57)break;e.advance()}if(69==e.next||101==e.next)for(e.advance(),43!=e.next&&45!=e.next||e.advance();e.next>=48&&e.next<=57;)e.advance()}function v(e){for(;!(e.next<0||10==e.next);)e.advance()}function w(e,t){for(let i=0;i<t.length;i++)if(t.charCodeAt(i)==e)return!0;return!1}const y=" \t\r\n";function b(e,t,i){let n=Object.create(null);n.true=n.false=l,n.null=n.unknown=a;for(let t of e.split(" "))t&&(n[t]=h);for(let e of t.split(" "))e&&(n[e]=c);for(let e of(i||"").split(" "))e&&(n[e]=u);return n}const x="array binary bit boolean char character clob date decimal double float int integer interval large national nchar nclob numeric object precision real smallint time timestamp varchar varying ",k="absolute action add after all allocate alter and any are as asc assertion at authorization before begin between both breadth by call cascade cascaded case cast catalog check close collate collation column commit condition connect connection constraint constraints constructor continue corresponding count create cross cube current current_date current_default_transform_group current_transform_group_for_type current_path current_role current_time current_timestamp current_user cursor cycle data day deallocate declare default deferrable deferred delete depth deref desc describe descriptor deterministic diagnostics disconnect distinct do domain drop dynamic each else elseif end end-exec equals escape except exception exec execute exists exit external fetch first for foreign found from free full function general get global go goto grant group grouping handle having hold hour identity if immediate in indicator initially inner inout input insert intersect into is isolation join key language last lateral leading leave left level like limit local localtime localtimestamp locator loop map match method minute modifies module month names natural nesting new next no none not of old on only open option or order ordinality out outer output overlaps pad parameter partial path prepare preserve primary prior privileges procedure public read reads recursive redo ref references referencing relative release repeat resignal restrict result return returns revoke right role rollback rollup routine row rows savepoint schema scroll search second section select session session_user set sets signal similar size some space specific specifictype sql sqlexception sqlstate sqlwarning start state static system_user table temporary then timezone_hour timezone_minute to trailing transaction translation treat trigger under undo union unique unnest until update usage user using value values view when whenever where while with without work write year zone ",S={backslashEscapes:!1,hashComments:!1,spaceAfterDashes:!1,slashComments:!1,doubleQuotedStrings:!1,doubleDollarQuotedStrings:!1,unquotedBitLiterals:!1,treatBitsAsBytes:!1,charSetCasts:!1,plsqlQuotingMechanism:!1,operatorChars:"*+-%<>!=&|~^/",specialVar:"?",identifierQuotes:'"',words:b(k,x)};function C(e){return new r.ExternalTokenizer((t=>{var i;let{next:n}=t;if(t.advance(),w(n,y)){for(;w(t.next,y);)t.advance();t.acceptToken(36)}else if(36==n&&e.doubleDollarQuotedStrings){let e=p(t,"");36==t.next&&(t.advance(),function(e,t){e:for(;;){if(e.next<0)return console.log("exit at end",e.pos);if(36==e.next){e.advance();for(let i=0;i<t.length;i++){if(e.next!=t.charCodeAt(i))continue e;e.advance()}if(36==e.next)return void e.advance()}else e.advance()}}(t,e),t.acceptToken(3))}else if(39==n||34==n&&e.doubleQuotedStrings)f(t,n,e.backslashEscapes),t.acceptToken(3);else if(35==n&&e.hashComments||47==n&&47==t.next&&e.slashComments)v(t),t.acceptToken(1);else if(45!=n||45!=t.next||e.spaceAfterDashes&&32!=t.peek(1))if(47==n&&42==t.next){t.advance();for(let e=1;;){let i=t.next;if(t.next<0)break;if(t.advance(),42==i&&47==t.next){if(e--,t.advance(),!e)break}else 47==i&&42==t.next&&(e++,t.advance())}t.acceptToken(2)}else if(101!=n&&69!=n||39!=t.next)if(110!=n&&78!=n||39!=t.next||!e.charSetCasts)if(95==n&&e.charSetCasts)for(let i=0;;i++){if(39==t.next&&i>1){t.advance(),f(t,39,e.backslashEscapes),t.acceptToken(3);break}if(!d(t.next))break;t.advance()}else if(e.plsqlQuotingMechanism&&(113==n||81==n)&&39==t.next&&t.peek(1)>0&&!w(t.peek(1),y)){let e=t.peek(1);t.advance(2),function(e,t){let i="[{<(".indexOf(String.fromCharCode(t)),n=i<0?t:"]}>)".charCodeAt(i);for(;;){if(e.next<0)return;if(e.next==n&&39==e.peek(1))return void e.advance(2);e.advance()}}(t,e),t.acceptToken(3)}else if(40==n)t.acceptToken(7);else if(41==n)t.acceptToken(8);else if(123==n)t.acceptToken(9);else if(125==n)t.acceptToken(10);else if(91==n)t.acceptToken(11);else if(93==n)t.acceptToken(12);else if(59==n)t.acceptToken(13);else if(e.unquotedBitLiterals&&48==n&&98==t.next)t.advance(),m(t),t.acceptToken(22);else if(98!=n&&66!=n||39!=t.next&&34!=t.next){if(48==n&&(120==t.next||88==t.next)||(120==n||88==n)&&39==t.next){let e=39==t.next;for(t.advance();(o=t.next)>=48&&o<=57||o>=97&&o<=102||o>=65&&o<=70;)t.advance();e&&39==t.next&&t.advance(),t.acceptToken(4)}else if(46==n&&t.next>=48&&t.next<=57)g(t,!0),t.acceptToken(4);else if(46==n)t.acceptToken(14);else if(n>=48&&n<=57)g(t,!1),t.acceptToken(4);else if(w(n,e.operatorChars)){for(;w(t.next,e.operatorChars);)t.advance();t.acceptToken(15)}else if(w(n,e.specialVar))t.next==n&&t.advance(),function(e){if(39==e.next||34==e.next||96==e.next){let t=e.next;e.advance(),f(e,t,!1)}else p(e)}(t),t.acceptToken(17);else if(w(n,e.identifierQuotes))f(t,n,!1),t.acceptToken(19);else if(58==n||44==n)t.acceptToken(16);else if(d(n)){let o=p(t,String.fromCharCode(n));t.acceptToken(46==t.next||46==t.peek(-o.length-1)?18:null!==(i=e.words[o.toLowerCase()])&&void 0!==i?i:18)}}else{const i=t.next;t.advance(),e.treatBitsAsBytes?(f(t,i,e.backslashEscapes),t.acceptToken(23)):(m(t,i),t.acceptToken(22))}else t.advance(),f(t,39,e.backslashEscapes),t.acceptToken(3);else t.advance(),f(t,39,!0);else v(t),t.acceptToken(1);var o}))}const A=C(S),M=r.LRParser.deserialize({version:14,states:"%vQ]QQOOO#wQRO'#DSO$OQQO'#CwO%eQQO'#CxO%lQQO'#CyO%sQQO'#CzOOQQ'#DS'#DSOOQQ'#C}'#C}O'UQRO'#C{OOQQ'#Cv'#CvOOQQ'#C|'#C|Q]QQOOQOQQOOO'`QQO'#DOO(xQRO,59cO)PQQO,59cO)UQQO'#DSOOQQ,59d,59dO)cQQO,59dOOQQ,59e,59eO)jQQO,59eOOQQ,59f,59fO)qQQO,59fOOQQ-E6{-E6{OOQQ,59b,59bOOQQ-E6z-E6zOOQQ,59j,59jOOQQ-E6|-E6|O+VQRO1G.}O+^QQO,59cOOQQ1G/O1G/OOOQQ1G/P1G/POOQQ1G/Q1G/QP+kQQO'#C}O+rQQO1G.}O)PQQO,59cO,PQQO'#Cw",stateData:",[~OtOSPOSQOS~ORUOSUOTUOUUOVROXSOZTO]XO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O^]ORvXSvXTvXUvXVvXXvXZvX]vX_vX`vXavXbvXcvXdvXevXfvXgvXhvX~OsvX~P!jOa_Ob_Oc_O~ORUOSUOTUOUUOVROXSOZTO^tO_UO`UOa`Ob`Oc`OdUOeUOfUOgUOhUO~OWaO~P$ZOYcO~P$ZO[eO~P$ZORUOSUOTUOUUOVROXSOZTO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O]hOsoX~P%zOajObjOcjO~O^]ORkaSkaTkaUkaVkaXkaZka]ka_ka`kaakabkackadkaekafkagkahka~Oska~P'kO^]O~OWvXYvX[vX~P!jOWnO~P$ZOYoO~P$ZO[pO~P$ZO^]ORkiSkiTkiUkiVkiXkiZki]ki_ki`kiakibkickidkiekifkigkihki~Oski~P)xOWkaYka[ka~P'kO]hO~P$ZOWkiYki[ki~P)xOasObsOcsO~O",goto:"#hwPPPPPPPPPPPPPPPPPPPPPPPPPPx||||!Y!^!d!xPPP#[TYOZeUORSTWZbdfqT[OZQZORiZSWOZQbRQdSQfTZgWbdfqQ^PWk^lmrQl_Qm`RrseVORSTWZbdfq",nodeNames:"⚠ LineComment BlockComment String Number Bool Null ( ) { } [ ] ; . Operator Punctuation SpecialVar Identifier QuotedIdentifier Keyword Type Bits Bytes Builtin Script Statement CompositeIdentifier Parens Braces Brackets Statement",maxTerm:38,nodeProps:[["isolate",-4,1,2,3,19,""]],skippedNodes:[0,1,2],repeatNodeCount:3,tokenData:"RORO",tokenizers:[0,A],topRules:{Script:[0,25]},tokenPrec:0});function O(e){let t=e.cursor().moveTo(e.from,-1);for(;/Comment/.test(t.name);)t.moveTo(t.from,-1);return t.node}function T(e,t){let i=e.sliceString(t.from,t.to),n=/^([`'"])(.*)\1$/.exec(i);return n?n[2]:i}function D(e){return e&&("Identifier"==e.name||"QuotedIdentifier"==e.name)}function E(e,t){if("CompositeIdentifier"==t.name){let i=[];for(let n=t.firstChild;n;n=n.nextSibling)D(n)&&i.push(T(e,n));return i}return[T(e,t)]}function P(e,t){for(let i=[];;){if(!t||"."!=t.name)return i;let n=O(t);if(!D(n))return i;i.unshift(T(e,n)),t=O(n)}}function R(e,t){let i=n.syntaxTree(e).resolveInner(t,-1),o=function(e,t){let i;for(let e=t;!i;e=e.parent){if(!e)return null;"Statement"==e.name&&(i=e)}let n=null;for(let t=i.firstChild,o=!1,r=null;t;t=t.nextSibling){let i="Keyword"==t.name?e.sliceString(t.from,t.to).toLowerCase():null,s=null;if(o)if("as"==i&&r&&D(t.nextSibling))s=T(e,t.nextSibling);else{if(i&&L.has(i))break;r&&D(t)&&(s=T(e,t))}else o="from"==i;s&&(n||(n=Object.create(null)),n[s]=E(e,r)),r=/Identifier$/.test(t.name)?t:null}return n}(e.doc,i);return"Identifier"==i.name||"QuotedIdentifier"==i.name||"Keyword"==i.name?{from:i.from,quoted:"QuotedIdentifier"==i.name?e.doc.sliceString(i.from,i.from+1):null,parents:P(e.doc,O(i)),aliases:o}:"."==i.name?{from:t,quoted:null,parents:P(e.doc,i),aliases:o}:{from:t,quoted:null,parents:[],empty:!0,aliases:o}}const L=new Set("where group having order union intersect except all distinct limit offset fetch for".split(" "));const B=/^\w*$/,N=/^[`'"]?\w*[`'"]?$/;function I(e){return e.self&&"string"==typeof e.self.label}class _{constructor(e){this.idQuote=e,this.list=[],this.children=void 0}child(e){let t=this.children||(this.children=Object.create(null)),i=t[e];return i||(e&&!this.list.some((t=>t.label==e))&&this.list.push(V(e,"type",this.idQuote)),t[e]=new _(this.idQuote))}maybeChild(e){return this.children?this.children[e]:null}addCompletion(e){let t=this.list.findIndex((t=>t.label==e.label));t>-1?this.list[t]=e:this.list.push(e)}addCompletions(e){for(let t of e)this.addCompletion("string"==typeof t?V(t,"property",this.idQuote):t)}addNamespace(e){Array.isArray(e)?this.addCompletions(e):I(e)?this.addNamespace(e.children):this.addNamespaceObject(e)}addNamespaceObject(e){for(let t of Object.keys(e)){let i=e[t],n=null,o=t.replace(/\\?\./g,(e=>"."==e?"\0":e)).split("\0"),r=this;I(i)&&(n=i.self,i=i.children);for(let e=0;e<o.length;e++)n&&e==o.length-1&&r.addCompletion(n),r=r.child(o[e].replace(/\\\./g,"."));r.addNamespace(i)}}}function V(e,t,i){return/^[a-z_][a-z_\d]*$/.test(e)?{label:e,type:t}:{label:e,type:t,apply:i+e+i}}let F=M.configure({props:[n.indentNodeProp.add({Statement:n.continuedIndent()}),n.foldNodeProp.add({Statement:(e,t)=>({from:Math.min(e.from+100,t.doc.lineAt(e.from).to),to:e.to}),BlockComment:e=>({from:e.from+2,to:e.to-2})}),o.styleTags({Keyword:o.tags.keyword,Type:o.tags.typeName,Builtin:o.tags.standard(o.tags.name),Bits:o.tags.number,Bytes:o.tags.string,Bool:o.tags.bool,Null:o.tags.null,Number:o.tags.number,String:o.tags.string,Identifier:o.tags.name,QuotedIdentifier:o.tags.special(o.tags.string),SpecialVar:o.tags.special(o.tags.name),LineComment:o.tags.lineComment,BlockComment:o.tags.blockComment,Operator:o.tags.operator,"Semi Punctuation":o.tags.punctuation,"( )":o.tags.paren,"{ }":o.tags.brace,"[ ]":o.tags.squareBracket})]});class H{constructor(e,t,i){this.dialect=e,this.language=t,this.spec=i}get extension(){return this.language.extension}static define(e){let t=function(e,t,i,n){let o={};for(let t in S)o[t]=(e.hasOwnProperty(t)?e:S)[t];return t&&(o.words=b(t,i||"",n)),o}(e,e.keywords,e.types,e.builtin),i=n.LRLanguage.define({name:"sql",parser:F.configure({tokenizers:[{from:A,to:C(t)}]}),languageData:{commentTokens:{line:"--",block:{open:"/*",close:"*/"}},closeBrackets:{brackets:["(","[","{","'",'"',"`"]}}});return new H(t,i,e)}}function W(e,t=!1){return function(e,t){let i=Object.keys(e).map((i=>({label:t?i.toUpperCase():i,type:e[i]==c?"type":e[i]==h?"keyword":"variable",boost:-1})));return s.ifNotIn(["QuotedIdentifier","SpecialVar","String","LineComment","BlockComment","."],s.completeFromList(i))}(e.dialect.words,t)}function q(e,t=!1){return e.language.data.of({autocomplete:W(e,t)})}function z(e){return e.schema?function(e,t,i,n,o,r){var s;let l=(null===(s=null==r?void 0:r.spec.identifierQuotes)||void 0===s?void 0:s[0])||'"',a=new _(l),h=o?a.child(o):null;return a.addNamespace(e),t&&(h||a).addCompletions(t),i&&a.addCompletions(i),h&&a.addCompletions(h.list),n&&a.addCompletions((h||a).child(n).list),e=>{let{parents:t,from:i,quoted:o,empty:r,aliases:s}=R(e.state,e.pos);if(r&&!e.explicit)return null;s&&1==t.length&&(t=s[t[0]]||t);let l=a;for(let e of t){for(;!l.children||!l.children[e];)if(l==a&&h)l=h;else{if(l!=h||!n)return null;l=l.child(n)}let t=l.maybeChild(e);if(!t)return null;l=t}let c=o&&e.state.sliceDoc(e.pos,e.pos+1)==o,u=l.list;return l==a&&s&&(u=u.concat(Object.keys(s).map((e=>({label:e,type:"constant"}))))),{from:i,to:c?e.pos+1:void 0,options:(d=o,f=u,d?f.map((e=>Object.assign(Object.assign({},e),{label:e.label[0]==d?e.label:d+e.label+d,apply:void 0}))):f),validFor:o?N:B};var d,f}}(e.schema,e.tables,e.schemas,e.defaultTable,e.defaultSchema,e.dialect||j):()=>null}function U(e){return e.schema?(e.dialect||j).language.data.of({autocomplete:z(e)}):[]}const j=H.define({}),Q=H.define({charSetCasts:!0,doubleDollarQuotedStrings:!0,operatorChars:"+-*/<>=~!@#%^&|`?",specialVar:"",keywords:k+"a abort abs absent access according ada admin aggregate alias also always analyse analyze array_agg array_max_cardinality asensitive assert assignment asymmetric atomic attach attribute attributes avg backward base64 begin_frame begin_partition bernoulli bit_length blocked bom c cache called cardinality catalog_name ceil ceiling chain char_length character_length character_set_catalog character_set_name character_set_schema characteristics characters checkpoint class class_origin cluster coalesce cobol collation_catalog collation_name collation_schema collect column_name columns command_function command_function_code comment comments committed concurrently condition_number configuration conflict connection_name constant constraint_catalog constraint_name constraint_schema contains content control conversion convert copy corr cost covar_pop covar_samp csv cume_dist current_catalog current_row current_schema cursor_name database datalink datatype datetime_interval_code datetime_interval_precision db debug defaults defined definer degree delimiter delimiters dense_rank depends derived detach detail dictionary disable discard dispatch dlnewcopy dlpreviouscopy dlurlcomplete dlurlcompleteonly dlurlcompletewrite dlurlpath dlurlpathonly dlurlpathwrite dlurlscheme dlurlserver dlvalue document dump dynamic_function dynamic_function_code element elsif empty enable encoding encrypted end_frame end_partition endexec enforced enum errcode error event every exclude excluding exclusive exp explain expression extension extract family file filter final first_value flag floor following force foreach fortran forward frame_row freeze fs functions fusion g generated granted greatest groups handler header hex hierarchy hint id ignore ilike immediately immutable implementation implicit import include including increment indent index indexes info inherit inherits inline insensitive instance instantiable instead integrity intersection invoker isnull k key_member key_type label lag last_value lead leakproof least length library like_regex link listen ln load location lock locked log logged lower m mapping matched materialized max max_cardinality maxvalue member merge message message_length message_octet_length message_text min minvalue mod mode more move multiset mumps name namespace nfc nfd nfkc nfkd nil normalize normalized nothing notice notify notnull nowait nth_value ntile nullable nullif nulls number occurrences_regex octet_length octets off offset oids operator options ordering others over overlay overriding owned owner p parallel parameter_mode parameter_name parameter_ordinal_position parameter_specific_catalog parameter_specific_name parameter_specific_schema parser partition pascal passing passthrough password percent percent_rank percentile_cont percentile_disc perform period permission pg_context pg_datatype_name pg_exception_context pg_exception_detail pg_exception_hint placing plans pli policy portion position position_regex power precedes preceding prepared print_strict_params procedural procedures program publication query quote raise range rank reassign recheck recovery refresh regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy regr_syy reindex rename repeatable replace replica requiring reset respect restart restore result_oid returned_cardinality returned_length returned_octet_length returned_sqlstate returning reverse routine_catalog routine_name routine_schema routines row_count row_number rowtype rule scale schema_name schemas scope scope_catalog scope_name scope_schema security selective self sensitive sequence sequences serializable server server_name setof share show simple skip slice snapshot source specific_name sqlcode sqlerror sqrt stable stacked standalone statement statistics stddev_pop stddev_samp stdin stdout storage strict strip structure style subclass_origin submultiset subscription substring substring_regex succeeds sum symmetric sysid system system_time t table_name tables tablesample tablespace temp template ties token top_level_count transaction_active transactions_committed transactions_rolled_back transform transforms translate translate_regex trigger_catalog trigger_name trigger_schema trim trim_array truncate trusted type types uescape unbounded uncommitted unencrypted unlink unlisten unlogged unnamed untyped upper uri use_column use_variable user_defined_type_catalog user_defined_type_code user_defined_type_name user_defined_type_schema vacuum valid validate validator value_of var_pop var_samp varbinary variable_conflict variadic verbose version versioning views volatile warning whitespace width_bucket window within wrapper xmlagg xmlattributes xmlbinary xmlcast xmlcomment xmlconcat xmldeclaration xmldocument xmlelement xmlexists xmlforest xmliterate xmlnamespaces xmlparse xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltext xmlvalidate yes",types:x+"bigint int8 bigserial serial8 varbit bool box bytea cidr circle precision float8 inet int4 json jsonb line lseg macaddr macaddr8 money numeric pg_lsn point polygon float4 int2 smallserial serial2 serial serial4 text timetz timestamptz tsquery tsvector txid_snapshot uuid xml"}),K="accessible algorithm analyze asensitive authors auto_increment autocommit avg avg_row_length binlog btree cache catalog_name chain change changed checkpoint checksum class_origin client_statistics coalesce code collations columns comment committed completion concurrent consistent contains contributors convert database databases day_hour day_microsecond day_minute day_second delay_key_write delayed delimiter des_key_file dev_pop dev_samp deviance directory disable discard distinctrow div dual dumpfile enable enclosed ends engine engines enum errors escaped even event events every explain extended fast field fields flush force found_rows fulltext grants handler hash high_priority hosts hour_microsecond hour_minute hour_second ignore ignore_server_ids import index index_statistics infile innodb insensitive insert_method install invoker iterate keys kill linear lines list load lock logs low_priority master master_heartbeat_period master_ssl_verify_server_cert masters max max_rows maxvalue message_text middleint migrate min min_rows minute_microsecond minute_second mod mode modify mutex mysql_errno no_write_to_binlog offline offset one online optimize optionally outfile pack_keys parser partition partitions password phase plugin plugins prev processlist profile profiles purge query quick range read_write rebuild recover regexp relaylog remove rename reorganize repair repeatable replace require resume rlike row_format rtree schedule schema_name schemas second_microsecond security sensitive separator serializable server share show slave slow snapshot soname spatial sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_no_cache sql_small_result ssl starting starts std stddev stddev_pop stddev_samp storage straight_join subclass_origin sum suspend table_name table_statistics tables tablespace terminated triggers truncate uncommitted uninstall unlock upgrade use use_frm user_resources user_statistics utc_date utc_time utc_timestamp variables views warnings xa xor year_month zerofill",$=x+"bool blob long longblob longtext medium mediumblob mediumint mediumtext tinyblob tinyint tinytext text bigint int1 int2 int3 int4 int8 float4 float8 varbinary varcharacter precision datetime unsigned signed",G="charset clear edit ego help nopager notee nowarning pager print prompt quit rehash source status system tee",X=H.define({operatorChars:"*+-%<>!=&|^",charSetCasts:!0,doubleQuotedStrings:!0,unquotedBitLiterals:!0,hashComments:!0,spaceAfterDashes:!0,specialVar:"@?",identifierQuotes:"`",keywords:k+"group_concat "+K,types:$,builtin:G}),Y=H.define({operatorChars:"*+-%<>!=&|^",charSetCasts:!0,doubleQuotedStrings:!0,unquotedBitLiterals:!0,hashComments:!0,spaceAfterDashes:!0,specialVar:"@?",identifierQuotes:"`",keywords:k+"always generated groupby_concat hard persistent shutdown soft virtual "+K,types:$,builtin:G}),J=H.define({keywords:k+"trigger proc view index for add constraint key primary foreign collate clustered nonclustered declare exec go if use index holdlock nolock nowait paglock pivot readcommitted readcommittedlock readpast readuncommitted repeatableread rowlock serializable snapshot tablock tablockx unpivot updlock with",types:x+"bigint smallint smallmoney tinyint money real text nvarchar ntext varbinary image hierarchyid uniqueidentifier sql_variant xml",builtin:"binary_checksum checksum connectionproperty context_info current_request_id error_line error_message error_number error_procedure error_severity error_state formatmessage get_filestream_transaction_context getansinull host_id host_name isnull isnumeric min_active_rowversion newid newsequentialid rowcount_big xact_state object_id",operatorChars:"*+-%<>!=^&|/",specialVar:"@"}),Z=H.define({keywords:k+"abort analyze attach autoincrement conflict database detach exclusive fail glob ignore index indexed instead isnull notnull offset plan pragma query raise regexp reindex rename replace temp vacuum virtual",types:x+"bool blob long longblob longtext medium mediumblob mediumint mediumtext tinyblob tinyint tinytext text bigint int2 int8 unsigned signed real",builtin:"auth backup bail changes clone databases dbinfo dump echo eqp explain fullschema headers help import imposter indexes iotrace lint load log mode nullvalue once print prompt quit restore save scanstats separator shell show stats system tables testcase timeout timer trace vfsinfo vfslist vfsname width",operatorChars:"*+-%<>!=&|/~",identifierQuotes:'`"',specialVar:"@:?$"}),ee=H.define({keywords:"add all allow alter and any apply as asc authorize batch begin by clustering columnfamily compact consistency count create custom delete desc distinct drop each_quorum exists filtering from grant if in index insert into key keyspace keyspaces level limit local_one local_quorum modify nan norecursive nosuperuser not of on one order password permission permissions primary quorum rename revoke schema select set storage superuser table three to token truncate ttl two type unlogged update use user users using values where with writetime infinity NaN",types:x+"ascii bigint blob counter frozen inet list map static text timeuuid tuple uuid varint",slashComments:!0}),te=H.define({keywords:k+"abort accept access add all alter and any arraylen as asc assert assign at attributes audit authorization avg base_table begin between binary_integer body by case cast char_base check close cluster clusters colauth column comment commit compress connected constant constraint crash create current currval cursor data_base database dba deallocate debugoff debugon declare default definition delay delete desc digits dispose distinct do drop else elseif elsif enable end entry exception exception_init exchange exclusive exists external fast fetch file for force form from function generic goto grant group having identified if immediate in increment index indexes indicator initial initrans insert interface intersect into is key level library like limited local lock log logging loop master maxextents maxtrans member minextents minus mislabel mode modify multiset new next no noaudit nocompress nologging noparallel not nowait number_base of off offline on online only option or order out package parallel partition pctfree pctincrease pctused pls_integer positive positiven pragma primary prior private privileges procedure public raise range raw rebuild record ref references refresh rename replace resource restrict return returning returns reverse revoke rollback row rowid rowlabel rownum rows run savepoint schema segment select separate set share snapshot some space split sql start statement storage subtype successful synonym tabauth table tables tablespace task terminate then to trigger truncate type union unique unlimited unrecoverable unusable update use using validate value values variable view views when whenever where while with work",builtin:"appinfo arraysize autocommit autoprint autorecovery autotrace blockterminator break btitle cmdsep colsep compatibility compute concat copycommit copytypecheck define echo editfile embedded feedback flagger flush heading headsep instance linesize lno loboffset logsource longchunksize markup native newpage numformat numwidth pagesize pause pno recsep recsepchar repfooter repheader serveroutput shiftinout show showmode spool sqlblanklines sqlcase sqlcode sqlcontinue sqlnumber sqlpluscompatibility sqlprefix sqlprompt sqlterminator suffix tab term termout timing trimout trimspool ttitle underline verify version wrap",types:x+"ascii bfile bfilename bigserial bit blob dec long number nvarchar nvarchar2 serial smallint string text uid varchar2 xml",operatorChars:"*/+-%<>!=~",doubleQuotedStrings:!0,charSetCasts:!0,plsqlQuotingMechanism:!0});t.Cassandra=ee,t.MSSQL=J,t.MariaSQL=Y,t.MySQL=X,t.PLSQL=te,t.PostgreSQL=Q,t.SQLDialect=H,t.SQLite=Z,t.StandardSQL=j,t.keywordCompletion=q,t.keywordCompletionSource=W,t.schemaCompletion=U,t.schemaCompletionSource=z,t.sql=function(e={}){let t=e.dialect||j;return new n.LanguageSupport(t.language,[U(e),q(t,!!e.upperCaseKeywords)])}},92533:(e,t,i)=>{var n,o=i(52696),r=i(89064),s=i(61506),l=i(67359),a=i(9172);const h=new o.NodeProp;function c(e){return r.Facet.define({combine:e?t=>t.concat(e):void 0})}const u=new o.NodeProp;class d{constructor(e,t,i=[],n=""){this.data=e,this.name=n,r.EditorState.prototype.hasOwnProperty("tree")||Object.defineProperty(r.EditorState.prototype,"tree",{get(){return m(this)}}),this.parser=t,this.extension=[A.of(this),r.EditorState.languageData.of(((e,t,i)=>{let n=f(e,t,i),o=n.type.prop(h);if(!o)return[];let r=e.facet(o),s=n.type.prop(u);if(s){let o=n.resolve(t-n.from,i);for(let t of s)if(t.test(o,e)){let i=e.facet(t.facet);return"replace"==t.type?i:i.concat(r)}}return r}))].concat(i)}isActiveAt(e,t,i=-1){return f(e,t,i).type.prop(h)==this.data}findRegions(e){let t=e.facet(A);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],n=(e,t)=>{if(e.prop(h)==this.data)return void i.push({from:t,to:t+e.length});let r=e.prop(o.NodeProp.mounted);if(r){if(r.tree.prop(h)==this.data){if(r.overlay)for(let e of r.overlay)i.push({from:e.from+t,to:e.to+t});else i.push({from:t,to:t+e.length});return}if(r.overlay){let e=i.length;if(n(r.tree,r.overlay[0].from+t),i.length>e)return}}for(let i=0;i<e.children.length;i++){let r=e.children[i];r instanceof o.Tree&&n(r,e.positions[i]+t)}};return n(m(e),0),i}get allowsNesting(){return!0}}function f(e,t,i){let n=e.facet(A),r=m(e).topNode;if(!n||n.allowsNesting)for(let e=r;e;e=e.enter(t,i,o.IterMode.ExcludeBuffers))e.type.isTop&&(r=e);return r}d.setState=r.StateEffect.define();class p extends d{constructor(e,t,i){super(e,t,[],i),this.parser=t}static define(e){let t=c(e.languageData);return new p(t,e.parser.configure({props:[h.add((e=>e.isTop?t:void 0))]}),e.name)}configure(e,t){return new p(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function m(e){let t=e.field(d.state,!1);return t?t.tree:o.Tree.empty}function g(e,t,i=50){var n;let o=null===(n=e.field(d.state,!1))||void 0===n?void 0:n.context;if(!o)return null;let r=o.viewport;o.updateViewport({from:0,to:t});let s=o.isDone(t)||o.work(i,t)?o.tree:null;return o.updateViewport(r),s}class v{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)}}let w=null;class y{constructor(e,t,i=[],n,o,r,s,l){this.parser=e,this.state=t,this.fragments=i,this.tree=n,this.treeLen=o,this.viewport=r,this.skipped=s,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new y(e,t,[],o.Tree.empty,0,i,[],null)}startParse(){return this.parser.startParse(new v(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=o.Tree.empty&&this.isDone(null!=t?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var i;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(o.TreeFragment.addTree(n,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(i=this.parse.stoppedAt)&&void 0!==i?i:this.state.doc.length,this.tree=n,this.parse=null,!(this.treeLen<(null!=t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}}))}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||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(o.TreeFragment.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=w;w=this;try{return e()}finally{w=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=b(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:n,treeLen:r,viewport:s,skipped:l}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges(((e,i,n,o)=>t.push({fromA:e,toA:i,fromB:n,toB:o}))),i=o.TreeFragment.applyChanges(i,t),n=o.Tree.empty,r=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length){l=[];for(let t of this.skipped){let i=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);i<n&&l.push({from:i,to:n})}}}return new y(this.parser,t,i,n,r,s,l,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 t=0;t<this.skipped.length;t++){let{from:i,to:n}=this.skipped[t];i<e.to&&n>e.from&&(this.fragments=b(this.fragments,i,n),this.skipped.splice(t--,1))}return!(this.skipped.length>=t)&&(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 o.Parser{createParse(t,i,n){let r=n[0].from,s=n[n.length-1].to;return{parsedPos:r,advance(){let t=w;if(t){for(let e of n)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=s,new o.Tree(o.NodeType.none,[],[],s-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return w}}function b(e,t,i){return o.TreeFragment.applyChanges(e,[{fromA:t,toA:i,fromB:t,toB:i}])}class x{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 x(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=y.create(e.facet(A).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new x(i)}}d.state=r.StateField.define({create:x.init,update(e,t){for(let e of t.effects)if(e.is(d.setState))return e.value;return t.startState.facet(A)!=t.state.facet(A)?x.init(t.state):e.apply(t)}});let k=e=>{let t=setTimeout((()=>e()),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(k=e=>{let t=-1,i=setTimeout((()=>{t=requestIdleCallback(e,{timeout:400})}),100);return()=>t<0?clearTimeout(i):cancelIdleCallback(t)});const S="undefined"!=typeof navigator&&(null===(n=navigator.scheduling)||void 0===n?void 0:n.isInputPending)?()=>navigator.scheduling.isInputPending():null,C=s.ViewPlugin.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(d.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(d.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=k(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:n}}=this.view,o=i.field(d.state);if(o.tree==o.context.tree&&o.context.isDone(n+1e5))return;let r=Date.now()+Math.min(this.chunkBudget,100,e&&!S?Math.max(25,e.timeRemaining()-5):1e9),s=o.context.treeLen<n&&i.doc.length>n+1e3,l=o.context.work((()=>S&&S()||Date.now()>r),n+(s?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:d.setState.of(new x(o.context))})),this.chunkBudget>0&&(!l||s)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then((()=>this.scheduleWork())).catch((e=>s.logException(this.view.state,e))).then((()=>this.workScheduled--)),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),A=r.Facet.define({combine:e=>e.length?e[0]:null,enables:e=>[d.state,C,s.EditorView.contentAttributes.compute([e],(t=>{let i=t.facet(e);return i&&i.name?{"data-language":i.name}:{}}))]});class M{constructor(e,t,i,n,o,r=void 0){this.name=e,this.alias=t,this.extensions=i,this.filename=n,this.loadFunc=o,this.support=r,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then((e=>this.support=e),(e=>{throw this.loading=null,e})))}static of(e){let{load:t,support:i}=e;if(!t){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");t=()=>Promise.resolve(i)}return new M(e.name,(e.alias||[]).concat(e.name).map((e=>e.toLowerCase())),e.extensions||[],e.filename,t,i)}static matchFilename(e,t){for(let i of e)if(i.filename&&i.filename.test(t))return i;let i=/\.([^.]+)$/.exec(t);if(i)for(let t of e)if(t.extensions.indexOf(i[1])>-1)return t;return null}static matchLanguageName(e,t,i=!0){t=t.toLowerCase();for(let i of e)if(i.alias.some((e=>e==t)))return i;if(i)for(let i of e)for(let e of i.alias){let n=t.indexOf(e);if(n>-1&&(e.length>2||!/\w/.test(t[n-1])&&!/\w/.test(t[n+e.length])))return i}return null}}const O=r.Facet.define(),T=r.Facet.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some((e=>e!=t[0])))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function D(e){let t=e.facet(T);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function E(e,t){let i="",n=e.tabSize,o=e.facet(T)[0];if("\t"==o){for(;t>=n;)i+="\t",t-=n;o=" "}for(let e=0;e<t;e++)i+=o;return i}function P(e,t){e instanceof r.EditorState&&(e=new R(e));for(let i of e.state.facet(O)){let n=i(e,t);if(void 0!==n)return n}let i=m(e.state);return i.length>=t?function(e,t,i){let n=t.resolveStack(i),o=n.node.enterUnfinishedNodesBefore(i);if(o!=n.node){let e=[];for(let t=o;t!=n.node;t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)n={node:e[t],next:n}}return B(n,e,i)}(e,i,t):null}class R{constructor(e,t={}){this.state=e,this.options=t,this.unit=D(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:n,simulateDoubleBreak:o}=this.options;return null!=n&&n>=i.from&&n<=i.to?o&&n==e?{text:"",from:e}:(t<0?n<e:n<=e)?{text:i.text.slice(n-i.from),from:n}:{text:i.text.slice(0,n-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:n}=this.lineAt(e,t);return i.slice(e-n,Math.min(i.length,e+100-n))}column(e,t=1){let{text:i,from:n}=this.lineAt(e,t),o=this.countColumn(i,e-n),r=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return r>-1&&(o+=r-this.countColumn(i,i.search(/\S|$/))),o}countColumn(e,t=e.length){return r.countColumn(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:n}=this.lineAt(e,t),o=this.options.overrideIndentation;if(o){let e=o(n);if(e>-1)return e}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const L=new o.NodeProp;function B(e,t,i){for(let n=e;n;n=n.next){let e=N(n.node);if(e)return e(_.create(t,i,n))}return 0}function N(e){let t=e.type.prop(L);if(t)return t;let i,n=e.firstChild;if(n&&(i=n.type.prop(o.NodeProp.closedBy))){let t=e.lastChild,n=t&&i.indexOf(t.name)>-1;return e=>F(e,!0,1,void 0,n&&!function(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}(e)?t.from:void 0)}return null==e.parent?I:null}function I(){return 0}class _ extends R{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 _(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(V(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return B(this.context.next,this.base,this.pos)}}function V(e,t){for(let i=t;i;i=i.parent)if(e==i)return!0;return!1}function F(e,t,i,n,o){let r=e.textAfter,s=r.match(/^\s*/)[0].length,l=n&&r.slice(s,s+n.length)==n||o==e.pos+s,a=t?function(e){let t=e.node,i=t.childAfter(t.from),n=t.lastChild;if(!i)return null;let o=e.options.simulateBreak,r=e.state.doc.lineAt(i.from),s=null==o||o<=r.from?r.to:Math.min(r.to,o);for(let e=i.to;;){let o=t.childAfter(e);if(!o||o==n)return null;if(!o.type.isSkipped)return o.from<s?i:null;e=o.to}}(e):null;return a?l?e.column(a.from):e.column(a.to):e.baseIndent+(l?0:e.unit*i)}const H=r.Facet.define(),W=new o.NodeProp;function q(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function z(e,t,i){for(let n of e.facet(H)){let o=n(e,t,i);if(o)return o}return function(e,t,i){let n=m(e);if(n.length<i)return null;let o=null;for(let r=n.resolveStack(i,1);r;r=r.next){let s=r.node;if(s.to<=i||s.from>i)continue;if(o&&s.from<t)break;let l=s.type.prop(W);if(l&&(s.to<n.length-50||n.length==e.doc.length||!q(s))){let n=l(s,e);n&&n.from<=i&&n.from>=t&&n.to>i&&(o=n)}}return o}(e,t,i)}function U(e,t){let i=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);return i>=n?void 0:{from:i,to:n}}const j=r.StateEffect.define({map:U}),Q=r.StateEffect.define({map:U});function K(e){let t=[];for(let{head:i}of e.state.selection.ranges)t.some((e=>e.from<=i&&e.to>=i))||t.push(e.lineBlockAt(i));return t}const $=r.StateField.define({create:()=>s.Decoration.none,update(e,t){e=e.map(t.changes);for(let i of t.effects)if(i.is(j)&&!X(e,i.value.from,i.value.to)){let{preparePlaceholder:n}=t.state.facet(se),o=n?s.Decoration.replace({widget:new ce(n(t.state,i.value))}):he;e=e.update({add:[o.range(i.value.from,i.value.to)]})}else i.is(Q)&&(e=e.update({filter:(e,t)=>i.value.from!=e||i.value.to!=t,filterFrom:i.value.from,filterTo:i.value.to}));if(t.selection){let i=!1,{head:n}=t.selection.main;e.between(n,n,((e,t)=>{e<n&&t>n&&(i=!0)})),i&&(e=e.update({filterFrom:n,filterTo:n,filter:(e,t)=>t<=n||e>=n}))}return e},provide:e=>s.EditorView.decorations.from(e),toJSON(e,t){let i=[];return e.between(0,t.doc.length,((e,t)=>{i.push(e,t)})),i},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let i=0;i<e.length;){let n=e[i++],o=e[i++];if("number"!=typeof n||"number"!=typeof o)throw new RangeError("Invalid JSON for fold state");t.push(he.range(n,o))}return s.Decoration.set(t,!0)}});function G(e,t,i){var n;let o=null;return null===(n=e.field($,!1))||void 0===n||n.between(t,i,((e,t)=>{(!o||o.from>e)&&(o={from:e,to:t})})),o}function X(e,t,i){let n=!1;return e.between(t,t,((e,o)=>{e==t&&o==i&&(n=!0)})),n}function Y(e,t){return e.field($,!1)?t:t.concat(r.StateEffect.appendConfig.of(le()))}const J=e=>{for(let t of K(e)){let i=z(e.state,t.from,t.to);if(i)return e.dispatch({effects:Y(e.state,[j.of(i),ee(e,i)])}),!0}return!1},Z=e=>{if(!e.state.field($,!1))return!1;let t=[];for(let i of K(e)){let n=G(e.state,i.from,i.to);n&&t.push(Q.of(n),ee(e,n,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function ee(e,t,i=!0){let n=e.state.doc.lineAt(t.from).number,o=e.state.doc.lineAt(t.to).number;return s.EditorView.announce.of(`${e.state.phrase(i?"Folded lines":"Unfolded lines")} ${n} ${e.state.phrase("to")} ${o}.`)}const te=e=>{let{state:t}=e,i=[];for(let n=0;n<t.doc.length;){let o=e.lineBlockAt(n),r=z(t,o.from,o.to);r&&i.push(j.of(r)),n=(r?e.lineBlockAt(r.to):o).to+1}return i.length&&e.dispatch({effects:Y(e.state,i)}),!!i.length},ie=e=>{let t=e.state.field($,!1);if(!t||!t.size)return!1;let i=[];return t.between(0,e.state.doc.length,((e,t)=>{i.push(Q.of({from:e,to:t}))})),e.dispatch({effects:i}),!0};function ne(e,t){for(let i=t;;){let n=z(e.state,i.from,i.to);if(n&&n.to>t.from)return n;if(!i.from)return null;i=e.lineBlockAt(i.from-1)}}const oe=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:J},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Z},{key:"Ctrl-Alt-[",run:te},{key:"Ctrl-Alt-]",run:ie}],re={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},se=r.Facet.define({combine:e=>r.combineConfig(e,re)});function le(e){let t=[$,fe];return e&&t.push(se.of(e)),t}function ae(e,t){let{state:i}=e,n=i.facet(se),o=t=>{let i=e.lineBlockAt(e.posAtDOM(t.target)),n=G(e.state,i.from,i.to);n&&e.dispatch({effects:Q.of(n)}),t.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(e,o,t);let r=document.createElement("span");return r.textContent=n.placeholderText,r.setAttribute("aria-label",i.phrase("folded code")),r.title=i.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=o,r}const he=s.Decoration.replace({widget:new class extends s.WidgetType{toDOM(e){return ae(e,null)}}});class ce extends s.WidgetType{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return ae(e,this.value)}}const ue={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class de extends s.GutterMarker{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}const fe=s.EditorView.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class pe{constructor(e,t){let i;function n(e){let t=a.StyleModule.newName();return(i||(i=Object.create(null)))["."+t]=e,t}this.specs=e;const o="string"==typeof t.all?t.all:t.all?n(t.all):void 0,r=t.scope;this.scope=r instanceof d?e=>e.prop(h)==r.data:r?e=>e==r:void 0,this.style=l.tagHighlighter(e.map((e=>({tag:e.tag,class:e.class||n(Object.assign({},e,{tag:null}))}))),{all:o}).style,this.module=i?new a.StyleModule(i):null,this.themeType=t.themeType}static define(e,t){return new pe(e,t||{})}}const me=r.Facet.define(),ge=r.Facet.define({combine:e=>e.length?[e[0]]:null});function ve(e){let t=e.facet(me);return t.length?t:e.facet(ge)}const we=r.Prec.high(s.ViewPlugin.fromClass(class{constructor(e){this.markCache=Object.create(null),this.tree=m(e.state),this.decorations=this.buildDeco(e,ve(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=m(e.state),i=ve(e.state),n=i!=ve(e.startState),{viewport:o}=e.view,r=e.changes.mapPos(this.decoratedTo,1);t.length<o.to&&!n&&t.type==this.tree.type&&r>=o.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=r):(t!=this.tree||e.viewportChanged||n)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=o.to)}buildDeco(e,t){if(!t||!this.tree.length)return s.Decoration.none;let i=new r.RangeSetBuilder;for(let{from:n,to:o}of e.visibleRanges)l.highlightTree(this.tree,t,((e,t,n)=>{i.add(e,t,this.markCache[n]||(this.markCache[n]=s.Decoration.mark({class:n})))}),n,o);return i.finish()}},{decorations:e=>e.decorations})),ye=pe.define([{tag:l.tags.meta,color:"#404740"},{tag:l.tags.link,textDecoration:"underline"},{tag:l.tags.heading,textDecoration:"underline",fontWeight:"bold"},{tag:l.tags.emphasis,fontStyle:"italic"},{tag:l.tags.strong,fontWeight:"bold"},{tag:l.tags.strikethrough,textDecoration:"line-through"},{tag:l.tags.keyword,color:"#708"},{tag:[l.tags.atom,l.tags.bool,l.tags.url,l.tags.contentSeparator,l.tags.labelName],color:"#219"},{tag:[l.tags.literal,l.tags.inserted],color:"#164"},{tag:[l.tags.string,l.tags.deleted],color:"#a11"},{tag:[l.tags.regexp,l.tags.escape,l.tags.special(l.tags.string)],color:"#e40"},{tag:l.tags.definition(l.tags.variableName),color:"#00f"},{tag:l.tags.local(l.tags.variableName),color:"#30a"},{tag:[l.tags.typeName,l.tags.namespace],color:"#085"},{tag:l.tags.className,color:"#167"},{tag:[l.tags.special(l.tags.variableName),l.tags.macroName],color:"#256"},{tag:l.tags.definition(l.tags.propertyName),color:"#00c"},{tag:l.tags.comment,color:"#940"},{tag:l.tags.invalid,color:"#f00"}]),be=s.EditorView.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),xe="()[]{}",ke=r.Facet.define({combine:e=>r.combineConfig(e,{afterCursor:!0,brackets:xe,maxScanDistance:1e4,renderMatch:Ae})}),Se=s.Decoration.mark({class:"cm-matchingBracket"}),Ce=s.Decoration.mark({class:"cm-nonmatchingBracket"});function Ae(e){let t=[],i=e.matched?Se:Ce;return t.push(i.range(e.start.from,e.start.to)),e.end&&t.push(i.range(e.end.from,e.end.to)),t}const Me=[r.StateField.define({create:()=>s.Decoration.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let i=[],n=t.state.facet(ke);for(let e of t.state.selection.ranges){if(!e.empty)continue;let o=Ee(t.state,e.head,-1,n)||e.head>0&&Ee(t.state,e.head-1,1,n)||n.afterCursor&&(Ee(t.state,e.head,1,n)||e.head<t.state.doc.length&&Ee(t.state,e.head+1,-1,n));o&&(i=i.concat(n.renderMatch(o,t.state)))}return s.Decoration.set(i,!0)},provide:e=>s.EditorView.decorations.from(e)}),be];const Oe=new o.NodeProp;function Te(e,t,i){let n=e.prop(t<0?o.NodeProp.openedBy:o.NodeProp.closedBy);if(n)return n;if(1==e.name.length){let n=i.indexOf(e.name);if(n>-1&&n%2==(t<0?1:0))return[i[n+t]]}return null}function De(e){let t=e.type.prop(Oe);return t?t(e.node):e}function Ee(e,t,i,n={}){let o=n.maxScanDistance||1e4,r=n.brackets||xe,s=m(e),l=s.resolveInner(t,i);for(let n=l;n;n=n.parent){let o=Te(n.type,i,r);if(o&&n.from<n.to){let s=De(n);if(s&&(i>0?t>=s.from&&t<s.to:t>s.from&&t<=s.to))return Pe(e,t,i,n,s,o,r)}}return function(e,t,i,n,o,r,s){let l=i<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),a=s.indexOf(l);if(a<0||a%2==0!=i>0)return null;let h={from:i<0?t-1:t,to:i>0?t+1:t},c=e.doc.iterRange(t,i>0?e.doc.length:0),u=0;for(let e=0;!c.next().done&&e<=r;){let r=c.value;i<0&&(e+=r.length);let l=t+e*i;for(let e=i>0?0:r.length-1,t=i>0?r.length:-1;e!=t;e+=i){let t=s.indexOf(r[e]);if(!(t<0||n.resolveInner(l+e,1).type!=o))if(t%2==0==i>0)u++;else{if(1==u)return{start:h,end:{from:l+e,to:l+e+1},matched:t>>1==a>>1};u--}}i>0&&(e+=r.length)}return c.done?{start:h,matched:!1}:null}(e,t,i,s,l.type,o,r)}function Pe(e,t,i,n,o,r,s){let l=n.parent,a={from:o.from,to:o.to},h=0,c=null==l?void 0:l.cursor();if(c&&(i<0?c.childBefore(n.from):c.childAfter(n.to)))do{if(i<0?c.to<=n.from:c.from>=n.to){if(0==h&&r.indexOf(c.type.name)>-1&&c.from<c.to){let e=De(c);return{start:a,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(Te(c.type,i,s))h++;else if(Te(c.type,-i,s)){if(0==h){let e=De(c);return{start:a,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}h--}}}while(i<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function Re(e,t,i,n=0,o=0){null==t&&-1==(t=e.search(/[^\s\u00a0]/))&&(t=e.length);let r=o;for(let o=n;o<t;o++)9==e.charCodeAt(o)?r+=i-r%i:r++;return r}class Le{constructor(e,t,i,n){this.string=e,this.tabSize=t,this.indentUnit=i,this.overrideIndent=n,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return 0==this.pos}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t,i=this.string.charAt(this.pos);if(t="string"==typeof e?i==e:i&&(e instanceof RegExp?e.test(i):e(i)),t)return++this.pos,i}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Re(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var e;return null!==(e=this.overrideIndent)&&void 0!==e?e:Re(this.string,null,this.tabSize)}match(e,t,i){if("string"==typeof e){let n=e=>i?e.toLowerCase():e;return n(this.string.substr(this.pos,e.length))==n(e)?(!1!==t&&(this.pos+=e.length),!0):null}{let i=this.string.slice(this.pos).match(e);return i&&i.index>0?null:(i&&!1!==t&&(this.pos+=i[0].length),i)}}current(){return this.string.slice(this.start,this.pos)}}function Be(e){if("object"!=typeof e)return e;let t={};for(let i in e){let n=e[i];t[i]=n instanceof Array?n.slice():n}return t}const Ne=new WeakMap;class Ie extends d{constructor(e){let t,i=c(e.languageData),n={name:(r=e).name||"",token:r.token,blankLine:r.blankLine||(()=>{}),startState:r.startState||(()=>!0),copyState:r.copyState||Be,indent:r.indent||(()=>null),languageData:r.languageData||{},tokenTable:r.tokenTable||We};var r;super(i,new class extends o.Parser{createParse(e,i,n){return new Fe(t,e,i,n)}},[O.of(((e,t)=>this.getIndent(e,t)))],e.name),this.topNode=function(e){let t=o.NodeType.define({id:qe.length,name:"Document",props:[h.add((()=>e))],top:!0});return qe.push(t),t}(i),t=this,this.streamParser=n,this.stateAfter=new o.NodeProp({perNode:!0}),this.tokenTable=e.tokenTable?new Ke(n.tokenTable):$e}static define(e){return new Ie(e)}getIndent(e,t){let i,n=m(e.state),o=n.resolve(t);for(;o&&o.type!=this.topNode;)o=o.parent;if(!o)return null;let{overrideIndentation:r}=e.options;r&&(i=Ne.get(e.state),null!=i&&i<t-1e4&&(i=void 0));let s,l,a=_e(this,n,0,o.from,null!=i?i:t);if(a?(l=a.state,s=a.pos+1):(l=this.streamParser.startState(e.unit),s=0),t-s>1e4)return null;for(;s<t;){let i=e.state.doc.lineAt(s),n=Math.min(t,i.to);if(i.length){let t=r?r(i.from):-1,o=new Le(i.text,e.state.tabSize,e.unit,t<0?void 0:t);for(;o.pos<n-i.from;)He(this.streamParser.token,o,l)}else this.streamParser.blankLine(l,e.unit);if(n==t)break;s=i.to+1}let h=e.lineAt(t);return r&&null==i&&Ne.set(e.state,h.from),this.streamParser.indent(l,/^\s*(.*)/.exec(h.text)[1],e)}get allowsNesting(){return!1}}function _e(e,t,i,n,r){let s=i>=n&&i+t.length<=r&&t.prop(e.stateAfter);if(s)return{state:e.streamParser.copyState(s),pos:i+t.length};for(let s=t.children.length-1;s>=0;s--){let l=t.children[s],a=i+t.positions[s],h=l instanceof o.Tree&&a<r&&_e(e,l,a,n,r);if(h)return h}return null}function Ve(e,t,i,n,r){if(r&&i<=0&&n>=t.length)return t;r||t.type!=e.topNode||(r=!0);for(let s=t.children.length-1;s>=0;s--){let l,a=t.positions[s],h=t.children[s];if(a<n&&h instanceof o.Tree){if(!(l=Ve(e,h,i-a,n-a,r)))break;return r?new o.Tree(t.type,t.children.slice(0,s).concat(l),t.positions.slice(0,s+1),a+l.length):l}}return null}class Fe{constructor(e,t,i,n){this.lang=e,this.input=t,this.fragments=i,this.ranges=n,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=n[n.length-1].to;let r=y.get(),s=n[0].from,{state:l,tree:a}=function(e,t,i,n){for(let n of t){let t,o=n.from+(n.openStart?25:0),r=n.to-(n.openEnd?25:0),s=o<=i&&r>i&&_e(e,n.tree,0-n.offset,i,r);if(s&&(t=Ve(e,n.tree,i+n.offset,s.pos+n.offset,!1)))return{state:s.state,tree:t}}return{state:e.streamParser.startState(n?D(n):4),tree:o.Tree.empty}}(e,i,s,null==r?void 0:r.state);this.state=l,this.parsedPos=this.chunkStart=s+a.length;for(let e=0;e<a.children.length;e++)this.chunks.push(a.children[e]),this.chunkPos.push(a.positions[e]);r&&this.parsedPos<r.viewport.from-1e5&&(this.state=this.lang.streamParser.startState(D(r.state)),r.skipUntilInView(this.parsedPos,r.viewport.from),this.parsedPos=r.viewport.from),this.moveRangeIndex()}advance(){let e=y.get(),t=null==this.stoppedAt?this.to:Math.min(this.to,this.stoppedAt),i=Math.min(t,this.chunkStart+2048);for(e&&(i=Math.min(i,e.viewport.to));this.parsedPos<i;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)"\n"==t&&(t="");else{let e=t.indexOf("\n");e>-1&&(t=t.slice(0,e))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),i=e+t.length;for(let e=this.rangeIndex;;){let n=this.ranges[e].to;if(n>=i)break;if(t=t.slice(0,n-(i-t.length)),e++,e==this.ranges.length)break;let o=this.ranges[e].from,r=this.lineAfter(o);t+=r,i=o+r.length}return{line:t,end:i}}skipGapsTo(e,t,i){for(;;){let n=this.ranges[this.rangeIndex].to,o=e+t;if(i>0?n>o:n>=o)break;t+=this.ranges[++this.rangeIndex].from-n}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,i,n,o){if(this.ranges.length>1){t+=o=this.skipGapsTo(t,o,1);let e=this.chunk.length;i+=o=this.skipGapsTo(i,o,-1),n+=this.chunk.length-e}return this.chunk.push(e,t,i,n),o}parseLine(e){let{line:t,end:i}=this.nextLine(),n=0,{streamParser:o}=this.lang,r=new Le(t,e?e.state.tabSize:4,e?D(e.state):2);if(r.eol())o.blankLine(this.state,r.indentUnit);else for(;!r.eol();){let e=He(o.token,r,this.state);if(e&&(n=this.emitToken(this.lang.tokenTable.resolve(e),this.parsedPos+r.start,this.parsedPos+r.pos,4,n)),r.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=o.Tree.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:ze,topID:0,maxBufferLength:2048,reused:this.chunkReused});e=new o.Tree(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new o.Tree(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function He(e,t,i){t.start=t.pos;for(let n=0;n<10;n++){let n=e(t,i);if(t.pos>t.start)return n}throw new Error("Stream parser failed to advance stream.")}const We=Object.create(null),qe=[o.NodeType.none],ze=new o.NodeSet(qe),Ue=[],je=Object.create(null),Qe=Object.create(null);for(let[e,t]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"]])Qe[e]=Xe(We,t);class Ke{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),Qe)}resolve(e){return e?this.table[e]||(this.table[e]=Xe(this.extra,e)):0}}const $e=new Ke(We);function Ge(e,t){Ue.indexOf(e)>-1||(Ue.push(e),console.warn(t))}function Xe(e,t){let i=[];for(let n of t.split(" ")){let t=[];for(let i of n.split(".")){let n=e[i]||l.tags[i];n?"function"==typeof n?t.length?t=t.map(n):Ge(i,`Modifier ${i} used at start of tag`):t.length?Ge(i,`Tag ${i} used as modifier`):t=Array.isArray(n)?n:[n]:Ge(i,`Unknown highlighting tag ${i}`)}for(let e of t)i.push(e)}if(!i.length)return 0;let n=t.replace(/ /g,"_"),r=n+" "+i.map((e=>e.id)),s=je[r];if(s)return s.id;let a=je[r]=o.NodeType.define({id:qe.length,name:n,props:[l.styleTags({[n]:i})]});return qe.push(a),a.id}function Ye(e){return e.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(e)}function Je(e){for(let t=e.iter();!t.next().done;)if(Ye(t.value))return!0;return!1}const Ze=r.Facet.define({combine:e=>e.some((e=>e))});const et=s.ViewPlugin.fromClass(class{constructor(e){this.always=e.state.facet(Ze)||e.textDirection!=s.Direction.LTR||e.state.facet(s.EditorView.perLineTextDirection),this.hasRTL=!this.always&&Je(e.state.doc),this.tree=m(e.state),this.decorations=this.always||this.hasRTL?tt(e,this.tree,this.always):s.Decoration.none}update(e){let t=e.state.facet(Ze)||e.view.textDirection!=s.Direction.LTR||e.state.facet(s.EditorView.perLineTextDirection);if(t||this.hasRTL||!function(e){let t=!1;return e.iterChanges(((e,i,n,o,r)=>{!t&&Je(r)&&(t=!0)})),t}(e.changes)||(this.hasRTL=!0),!t&&!this.hasRTL)return;let i=m(e.state);(t!=this.always||i!=this.tree||e.docChanged||e.viewportChanged)&&(this.tree=i,this.always=t,this.decorations=tt(e.view,i,t))}},{provide:e=>{function t(t){var i,n;return null!==(n=null===(i=t.plugin(e))||void 0===i?void 0:i.decorations)&&void 0!==n?n:s.Decoration.none}return[s.EditorView.outerDecorations.of(t),r.Prec.lowest(s.EditorView.bidiIsolatedRanges.of(t))]}});function tt(e,t,i){let n=new r.RangeSetBuilder,s=e.visibleRanges;i||(s=function(e,t){let i=t.iter(),n=0,o=[],r=null;for(let{from:t,to:s}of e)for(t!=n&&(n<t&&i.next(t-n),n=t);;){let e=n,t=n+i.value.length;if(!i.lineBreak&&Ye(i.value)&&(r&&r.to>e-10?r.to=Math.min(s,t):o.push(r={from:e,to:Math.min(s,t)})),n>=s)break;n=t,i.next()}return o}(s,e.state.doc));for(let{from:e,to:i}of s)t.iterate({enter:e=>{let t=e.type.prop(o.NodeProp.isolate);t&&n.add(e.from,e.to,it[t])},from:e,to:i});return n.finish()}const it={rtl:s.Decoration.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:s.Direction.RTL}),ltr:s.Decoration.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:s.Direction.LTR}),auto:s.Decoration.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};t.DocInput=v,t.HighlightStyle=pe,t.IndentContext=R,t.LRLanguage=p,t.Language=d,t.LanguageDescription=M,t.LanguageSupport=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},t.ParseContext=y,t.StreamLanguage=Ie,t.StringStream=Le,t.TreeIndentContext=_,t.bidiIsolates=function(e={}){let t=[et];return e.alwaysIsolate&&t.push(Ze.of(!0)),t},t.bracketMatching=function(e={}){return[ke.of(e),Me]},t.bracketMatchingHandle=Oe,t.codeFolding=le,t.continuedIndent=function({except:e,units:t=1}={}){return i=>{let n=e&&e.test(i.textAfter);return i.baseIndent+(n?0:t*i.unit)}},t.defaultHighlightStyle=ye,t.defineLanguageFacet=c,t.delimitedIndent=function({closing:e,align:t=!0,units:i=1}){return n=>F(n,t,i,e)},t.ensureSyntaxTree=g,t.flatIndent=e=>e.baseIndent,t.foldAll=te,t.foldCode=J,t.foldEffect=j,t.foldGutter=function(e={}){let t=Object.assign(Object.assign({},ue),e),i=new de(t,!0),n=new de(t,!1),o=s.ViewPlugin.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(A)!=e.state.facet(A)||e.startState.field($,!1)!=e.state.field($,!1)||m(e.startState)!=m(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new r.RangeSetBuilder;for(let o of e.viewportLineBlocks){let r=G(e.state,o.from,o.to)?n:z(e.state,o.from,o.to)?i:null;r&&t.add(o.from,o.from,r)}return t.finish()}}),{domEventHandlers:l}=t;return[o,s.gutter({class:"cm-foldGutter",markers(e){var t;return(null===(t=e.plugin(o))||void 0===t?void 0:t.markers)||r.RangeSet.empty},initialSpacer:()=>new de(t,!1),domEventHandlers:Object.assign(Object.assign({},l),{click:(e,t,i)=>{if(l.click&&l.click(e,t,i))return!0;let n=G(e.state,t.from,t.to);if(n)return e.dispatch({effects:Q.of(n)}),!0;let o=z(e.state,t.from,t.to);return!!o&&(e.dispatch({effects:j.of(o)}),!0)}})}),le()]},t.foldInside=function(e){let t=e.firstChild,i=e.lastChild;return t&&t.to<i.from?{from:t.to,to:i.type.isError?e.to:i.from}:null},t.foldKeymap=oe,t.foldNodeProp=W,t.foldService=H,t.foldState=$,t.foldable=z,t.foldedRanges=function(e){return e.field($,!1)||r.RangeSet.empty},t.forceParsing=function(e,t=e.viewport.to,i=100){let n=g(e.state,t,i);return n!=m(e.state)&&e.dispatch({}),!!n},t.getIndentUnit=D,t.getIndentation=P,t.highlightingFor=function(e,t,i){let n=ve(e),o=null;if(n)for(let e of n)if(!e.scope||i&&e.scope(i)){let i=e.style(t);i&&(o=o?o+" "+i:i)}return o},t.indentNodeProp=L,t.indentOnInput=function(){return r.EditorState.transactionFilter.of((e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let i=e.newDoc,{head:n}=e.newSelection.main,o=i.lineAt(n);if(n>o.from+200)return e;let r=i.sliceString(o.from,n);if(!t.some((e=>e.test(r))))return e;let{state:s}=e,l=-1,a=[];for(let{head:e}of s.selection.ranges){let t=s.doc.lineAt(e);if(t.from==l)continue;l=t.from;let i=P(s,t.from);if(null==i)continue;let n=/^\s*/.exec(t.text)[0],o=E(s,i);n!=o&&a.push({from:t.from,to:t.from+n.length,insert:o})}return a.length?[e,{changes:a,sequential:!0}]:e}))},t.indentRange=function(e,t,i){let n=Object.create(null),o=new R(e,{overrideIndentation:e=>{var t;return null!==(t=n[e])&&void 0!==t?t:-1}}),r=[];for(let s=t;s<=i;){let t=e.doc.lineAt(s);s=t.to+1;let i=P(o,t.from);if(null==i)continue;/\S/.test(t.text)||(i=0);let l=/^\s*/.exec(t.text)[0],a=E(e,i);l!=a&&(n[t.from]=i,r.push({from:t.from,to:t.from+l.length,insert:a}))}return e.changes(r)},t.indentService=O,t.indentString=E,t.indentUnit=T,t.language=A,t.languageDataProp=h,t.matchBrackets=Ee,t.sublanguageProp=u,t.syntaxHighlighting=function(e,t){let i,n=[we];return e instanceof pe&&(e.module&&n.push(s.EditorView.styleModule.of(e.module)),i=e.themeType),(null==t?void 0:t.fallback)?n.push(ge.of(e)):i?n.push(me.computeN([s.EditorView.darkTheme],(t=>t.facet(s.EditorView.darkTheme)==("dark"==i)?[e]:[]))):n.push(me.of(e)),n},t.syntaxParserRunning=function(e){var t;return(null===(t=e.plugin(C))||void 0===t?void 0:t.isWorking())||!1},t.syntaxTree=m,t.syntaxTreeAvailable=function(e,t=e.doc.length){var i;return(null===(i=e.field(d.state,!1))||void 0===i?void 0:i.context.isDone(t))||!1},t.toggleFold=e=>{let t=[];for(let i of K(e)){let n=G(e.state,i.from,i.to);if(n)t.push(Q.of(n),ee(e,n,!1));else{let n=ne(e,i);n&&t.push(j.of(n),ee(e,n))}}return t.length>0&&e.dispatch({effects:Y(e.state,t)}),!!t.length},t.unfoldAll=ie,t.unfoldCode=Z,t.unfoldEffect=Q},78539:(e,t,i)=>{var n=i(61506),o=i(89064),r=i(38748);const s="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class l{constructor(e,t,i=0,n=e.length,o,r){this.test=r,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,n),this.bufferStart=i,this.normalize=o?e=>o(s(e)):s,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return o.codePointAt(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=o.fromCodePoint(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=o.codePointSize(e);let n=this.normalize(t);for(let e=0,o=i;;e++){let r=n.charCodeAt(e),s=this.match(r,o,this.bufferPos+this.bufferStart);if(e==n.length-1){if(s)return this.value=s,this;break}o==i&&e<t.length&&t.charCodeAt(e)==r&&o++}}}match(e,t,i){let n=null;for(let t=0;t<this.matches.length;t+=2){let o=this.matches[t],r=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?n={from:this.matches[t+1],to:i}:(this.matches[t]++,r=!0)),r||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?n={from:t,to:i}:this.matches.push(1,t)),n&&this.test&&!this.test(n.from,n.to,this.buffer,this.bufferStart)&&(n=null),n}}"undefined"!=typeof Symbol&&(l.prototype[Symbol.iterator]=function(){return this});const a={from:-1,to:-1,match:/.*/.exec("")},h="gm"+(null==/x/.unicode?"":"u");class c{constructor(e,t,i,n=0,o=e.length){if(this.text=e,this.to=o,this.curLine="",this.done=!1,this.value=a,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new f(e,t,i,n,o);this.re=new RegExp(t,h+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.iter=e.iter();let r=e.lineAt(n);this.curLineStart=r.from,this.matchPos=p(e,n),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,n=i+t[0].length;if(this.matchPos=p(this.text,n+(i==n?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<n||i>this.value.to)&&(!this.test||this.test(i,n,t)))return this.value={from:i,to:n,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}const u=new WeakMap;class d{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let n=u.get(e);if(!n||n.from>=i||n.to<=t){let n=new d(t,e.sliceString(t,i));return u.set(e,n),n}if(n.from==t&&n.to==i)return n;let{text:o,from:r}=n;return r>t&&(o=e.sliceString(t,r)+o,r=t),n.to<i&&(o+=e.sliceString(n.to,i)),u.set(e,new d(r,o)),new d(t,o.slice(t-r,i-r))}}class f{constructor(e,t,i,n,o){this.text=e,this.to=o,this.done=!1,this.value=a,this.matchPos=p(e,n),this.re=new RegExp(t,h+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.flat=d.get(e,n,this.chunkEnd(n+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,i=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,i,t)))return this.value={from:e,to:i,match:t},this.matchPos=p(this.text,i+(e==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=d.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function p(e,t){if(t>=e.length)return t;let i,n=e.lineAt(t);for(;t<n.to&&(i=n.text.charCodeAt(t-n.from))>=56320&&i<57344;)t++;return t}function m(e){let t=String(e.state.doc.lineAt(e.state.selection.main.head).number),i=r("input",{class:"cm-textfield",name:"line",value:t});function s(){let t=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(i.value);if(!t)return;let{state:r}=e,s=r.doc.lineAt(r.selection.main.head),[,l,a,h,c]=t,u=h?+h.slice(1):0,d=a?+a:s.number;if(a&&c){let e=d/100;l&&(e=e*("-"==l?-1:1)+s.number/r.doc.lines),d=Math.round(r.doc.lines*e)}else a&&l&&(d=d*("-"==l?-1:1)+s.number);let f=r.doc.line(Math.max(1,Math.min(r.doc.lines,d))),p=o.EditorSelection.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[g.of(!1),n.EditorView.scrollIntoView(p.from,{y:"center"})],selection:p}),e.focus()}return{dom:r("form",{class:"cm-gotoLine",onkeydown:t=>{27==t.keyCode?(t.preventDefault(),e.dispatch({effects:g.of(!1)}),e.focus()):13==t.keyCode&&(t.preventDefault(),s())},onsubmit:e=>{e.preventDefault(),s()}},r("label",e.state.phrase("Go to line"),": ",i)," ",r("button",{class:"cm-button",type:"submit"},e.state.phrase("go")))}}"undefined"!=typeof Symbol&&(c.prototype[Symbol.iterator]=f.prototype[Symbol.iterator]=function(){return this});const g=o.StateEffect.define(),v=o.StateField.define({create:()=>!0,update(e,t){for(let i of t.effects)i.is(g)&&(e=i.value);return e},provide:e=>n.showPanel.from(e,(e=>e?m:null))}),w=e=>{let t=n.getPanel(e,m);if(!t){let i=[g.of(!0)];null==e.state.field(v,!1)&&i.push(o.StateEffect.appendConfig.of([v,y])),e.dispatch({effects:i}),t=n.getPanel(e,m)}return t&&t.dom.querySelector("input").select(),!0},y=n.EditorView.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),b={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},x=o.Facet.define({combine:e=>o.combineConfig(e,b,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});const k=n.Decoration.mark({class:"cm-selectionMatch"}),S=n.Decoration.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function C(e,t,i,n){return!(0!=i&&e(t.sliceDoc(i-1,i))==o.CharCategory.Word||n!=t.doc.length&&e(t.sliceDoc(n,n+1))==o.CharCategory.Word)}function A(e,t,i,n){return e(t.sliceDoc(i,i+1))==o.CharCategory.Word&&e(t.sliceDoc(n-1,n))==o.CharCategory.Word}const M=n.ViewPlugin.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(x),{state:i}=e,o=i.selection;if(o.ranges.length>1)return n.Decoration.none;let r,s=o.main,a=null;if(s.empty){if(!t.highlightWordAroundCursor)return n.Decoration.none;let e=i.wordAt(s.head);if(!e)return n.Decoration.none;a=i.charCategorizer(s.head),r=i.sliceDoc(e.from,e.to)}else{let e=s.to-s.from;if(e<t.minSelectionLength||e>200)return n.Decoration.none;if(t.wholeWords){if(r=i.sliceDoc(s.from,s.to),a=i.charCategorizer(s.head),!C(a,i,s.from,s.to)||!A(a,i,s.from,s.to))return n.Decoration.none}else if(r=i.sliceDoc(s.from,s.to),!r)return n.Decoration.none}let h=[];for(let o of e.visibleRanges){let e=new l(i.doc,r,o.from,o.to);for(;!e.next().done;){let{from:o,to:r}=e.value;if((!a||C(a,i,o,r))&&(s.empty&&o<=s.from&&r>=s.to?h.push(S.range(o,r)):(o>=s.to||r<=s.from)&&h.push(k.range(o,r)),h.length>t.maxMatches))return n.Decoration.none}}return n.Decoration.set(h)}},{decorations:e=>e.decorations}),O=n.EditorView.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const T=({state:e,dispatch:t})=>{let{ranges:i}=e.selection;if(i.some((e=>e.from===e.to)))return(({state:e,dispatch:t})=>{let{selection:i}=e,n=o.EditorSelection.create(i.ranges.map((t=>e.wordAt(t.head)||o.EditorSelection.cursor(t.head))),i.mainIndex);return!n.eq(i)&&(t(e.update({selection:n})),!0)})({state:e,dispatch:t});let r=e.sliceDoc(i[0].from,i[0].to);if(e.selection.ranges.some((t=>e.sliceDoc(t.from,t.to)!=r)))return!1;let s=function(e,t){let{main:i,ranges:n}=e.selection,o=e.wordAt(i.head),r=o&&o.from==i.from&&o.to==i.to;for(let i=!1,o=new l(e.doc,t,n[n.length-1].to);;){if(o.next(),!o.done){if(i&&n.some((e=>e.from==o.value.from)))continue;if(r){let t=e.wordAt(o.value.from);if(!t||t.from!=o.value.from||t.to!=o.value.to)continue}return o.value}if(i)return null;o=new l(e.doc,t,0,Math.max(0,n[n.length-1].from-1)),i=!0}}(e,r);return!!s&&(t(e.update({selection:e.selection.addRange(o.EditorSelection.range(s.from,s.to),!1),effects:n.EditorView.scrollIntoView(s.to)})),!0)},D=o.Facet.define({combine:e=>o.combineConfig(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new le(e),scrollToMatch:e=>n.EditorView.scrollIntoView(e)})});class E{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,h),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,((e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?"\t":"\\"))}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new F(this):new B(this)}getCursor(e,t=0,i){let n=e.doc?e:o.EditorState.create({doc:e});return null==i&&(i=n.doc.length),this.regexp?N(this,n,t,i):R(this,n,t,i)}}class P{constructor(e){this.spec=e}}function R(e,t,i,n){return new l(t.doc,e.unquoted,i,n,e.caseSensitive?void 0:e=>e.toLowerCase(),e.wholeWord?L(t.doc,t.charCategorizer(t.selection.main.head)):void 0)}function L(e,t){return(i,n,r,s)=>((s>i||s+r.length<n)&&(s=Math.max(0,i-2),r=e.sliceString(s,Math.min(e.length,n+2))),!(t(I(r,i-s))==o.CharCategory.Word&&t(_(r,i-s))==o.CharCategory.Word||t(_(r,n-s))==o.CharCategory.Word&&t(I(r,n-s))==o.CharCategory.Word))}class B extends P{constructor(e){super(e)}nextMatch(e,t,i){let n=R(this.spec,e,i,e.doc.length).nextOverlapping();return n.done&&(n=R(this.spec,e,0,t).nextOverlapping()),n.done?null:n.value}prevMatchInRange(e,t,i){for(let n=i;;){let i=Math.max(t,n-1e4-this.spec.unquoted.length),o=R(this.spec,e,i,n),r=null;for(;!o.nextOverlapping().done;)r=o.value;if(r)return r;if(i==t)return null;n-=1e4}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=R(this.spec,e,0,e.doc.length),n=[];for(;!i.next().done;){if(n.length>=t)return null;n.push(i.value)}return n}highlight(e,t,i,n){let o=R(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!o.next().done;)n(o.value.from,o.value.to)}}function N(e,t,i,n){return new c(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:e.wholeWord?V(t.charCategorizer(t.selection.main.head)):void 0},i,n)}function I(e,t){return e.slice(o.findClusterBreak(e,t,!1),t)}function _(e,t){return e.slice(t,o.findClusterBreak(e,t))}function V(e){return(t,i,n)=>!n[0].length||(e(I(n.input,n.index))!=o.CharCategory.Word||e(_(n.input,n.index))!=o.CharCategory.Word)&&(e(_(n.input,n.index+n[0].length))!=o.CharCategory.Word||e(I(n.input,n.index+n[0].length))!=o.CharCategory.Word)}class F extends P{nextMatch(e,t,i){let n=N(this.spec,e,i,e.doc.length).next();return n.done&&(n=N(this.spec,e,0,t).next()),n.done?null:n.value}prevMatchInRange(e,t,i){for(let n=1;;n++){let o=Math.max(t,i-1e4*n),r=N(this.spec,e,o,i),s=null;for(;!r.next().done;)s=r.value;if(s&&(o==t||s.from>o+10))return s;if(o==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,((t,i)=>"$"==i?"$":"&"==i?e.match[0]:"0"!=i&&+i<e.match.length?e.match[i]:t))}matchAll(e,t){let i=N(this.spec,e,0,e.doc.length),n=[];for(;!i.next().done;){if(n.length>=t)return null;n.push(i.value)}return n}highlight(e,t,i,n){let o=N(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!o.next().done;)n(o.value.from,o.value.to)}}const H=o.StateEffect.define(),W=o.StateEffect.define(),q=o.StateField.define({create:e=>new z(te(e).create(),null),update(e,t){for(let i of t.effects)i.is(H)?e=new z(i.value.create(),e.panel):i.is(W)&&(e=new z(e.query,i.value?ee:null));return e},provide:e=>n.showPanel.from(e,(e=>e.panel))});class z{constructor(e,t){this.query=e,this.panel=t}}const U=n.Decoration.mark({class:"cm-searchMatch"}),j=n.Decoration.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Q=n.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(q))}update(e){let t=e.state.field(q);(t!=e.startState.field(q)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return n.Decoration.none;let{view:i}=this,r=new o.RangeSetBuilder;for(let t=0,n=i.visibleRanges,o=n.length;t<o;t++){let{from:s,to:l}=n[t];for(;t<o-1&&l>n[t+1].from-500;)l=n[++t].to;e.highlight(i.state,s,l,((e,t)=>{let n=i.state.selection.ranges.some((i=>i.from==e&&i.to==t));r.add(e,t,n?j:U)}))}return r.finish()}},{decorations:e=>e.decorations});function K(e){return t=>{let i=t.state.field(q,!1);return i&&i.query.spec.valid?e(t,i):oe(t)}}const $=K(((e,{query:t})=>{let{to:i}=e.state.selection.main,n=t.nextMatch(e.state,i,i);if(!n)return!1;let r=o.EditorSelection.single(n.from,n.to),s=e.state.facet(D);return e.dispatch({selection:r,effects:[ue(e,n),s.scrollToMatch(r.main,e)],userEvent:"select.search"}),ne(e),!0})),G=K(((e,{query:t})=>{let{state:i}=e,{from:n}=i.selection.main,r=t.prevMatch(i,n,n);if(!r)return!1;let s=o.EditorSelection.single(r.from,r.to),l=e.state.facet(D);return e.dispatch({selection:s,effects:[ue(e,r),l.scrollToMatch(s.main,e)],userEvent:"select.search"}),ne(e),!0})),X=K(((e,{query:t})=>{let i=t.matchAll(e.state,1e3);return!(!i||!i.length)&&(e.dispatch({selection:o.EditorSelection.create(i.map((e=>o.EditorSelection.range(e.from,e.to)))),userEvent:"select.search.matches"}),!0)})),Y=({state:e,dispatch:t})=>{let i=e.selection;if(i.ranges.length>1||i.main.empty)return!1;let{from:n,to:r}=i.main,s=[],a=0;for(let t=new l(e.doc,e.sliceDoc(n,r));!t.next().done;){if(s.length>1e3)return!1;t.value.from==n&&(a=s.length),s.push(o.EditorSelection.range(t.value.from,t.value.to))}return t(e.update({selection:o.EditorSelection.create(s,a),userEvent:"select.search.matches"})),!0},J=K(((e,{query:t})=>{let{state:i}=e,{from:r,to:s}=i.selection.main;if(i.readOnly)return!1;let l=t.nextMatch(i,r,r);if(!l)return!1;let a,h,c=[],u=[];if(l.from==r&&l.to==s&&(h=i.toText(t.getReplacement(l)),c.push({from:l.from,to:l.to,insert:h}),l=t.nextMatch(i,l.from,l.to),u.push(n.EditorView.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(r).number)+"."))),l){let t=0==c.length||c[0].from>=l.to?0:l.to-l.from-h.length;a=o.EditorSelection.single(l.from-t,l.to-t),u.push(ue(e,l)),u.push(i.facet(D).scrollToMatch(a.main,e))}return e.dispatch({changes:c,selection:a,effects:u,userEvent:"input.replace"}),!0})),Z=K(((e,{query:t})=>{if(e.state.readOnly)return!1;let i=t.matchAll(e.state,1e9).map((e=>{let{from:i,to:n}=e;return{from:i,to:n,insert:t.getReplacement(e)}}));if(!i.length)return!1;let o=e.state.phrase("replaced $ matches",i.length)+".";return e.dispatch({changes:i,effects:n.EditorView.announce.of(o),userEvent:"input.replace.all"}),!0}));function ee(e){return e.state.facet(D).createPanel(e)}function te(e,t){var i,n,o,r,s;let l=e.selection.main,a=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!a)return t;let h=e.facet(D);return new E({search:(null!==(i=null==t?void 0:t.literal)&&void 0!==i?i:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:null!==(n=null==t?void 0:t.caseSensitive)&&void 0!==n?n:h.caseSensitive,literal:null!==(o=null==t?void 0:t.literal)&&void 0!==o?o:h.literal,regexp:null!==(r=null==t?void 0:t.regexp)&&void 0!==r?r:h.regexp,wholeWord:null!==(s=null==t?void 0:t.wholeWord)&&void 0!==s?s:h.wholeWord})}function ie(e){let t=n.getPanel(e,ee);return t&&t.dom.querySelector("[main-field]")}function ne(e){let t=ie(e);t&&t==e.root.activeElement&&t.select()}const oe=e=>{let t=e.state.field(q,!1);if(t&&t.panel){let i=ie(e);if(i&&i!=e.root.activeElement){let n=te(e.state,t.query.spec);n.valid&&e.dispatch({effects:H.of(n)}),i.focus(),i.select()}}else e.dispatch({effects:[W.of(!0),t?H.of(te(e.state,t.query.spec)):o.StateEffect.appendConfig.of(fe)]});return!0},re=e=>{let t=e.state.field(q,!1);if(!t||!t.panel)return!1;let i=n.getPanel(e,ee);return i&&i.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:W.of(!1)}),!0},se=[{key:"Mod-f",run:oe,scope:"editor search-panel"},{key:"F3",run:$,shift:G,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:$,shift:G,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:re,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Y},{key:"Mod-Alt-g",run:w},{key:"Mod-d",run:T,preventDefault:!0}];class le{constructor(e){this.view=e;let t=this.query=e.state.field(q).query.spec;function i(e,t,i){return r("button",{class:"cm-button",name:e,onclick:t,type:"button"},i)}this.commit=this.commit.bind(this),this.searchField=r("input",{value:t.search,placeholder:ae(e,"Find"),"aria-label":ae(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=r("input",{value:t.replace,placeholder:ae(e,"Replace"),"aria-label":ae(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=r("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=r("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=r("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=r("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,i("next",(()=>$(e)),[ae(e,"next")]),i("prev",(()=>G(e)),[ae(e,"previous")]),i("select",(()=>X(e)),[ae(e,"all")]),r("label",null,[this.caseField,ae(e,"match case")]),r("label",null,[this.reField,ae(e,"regexp")]),r("label",null,[this.wordField,ae(e,"by word")]),...e.state.readOnly?[]:[r("br"),this.replaceField,i("replace",(()=>J(e)),[ae(e,"replace")]),i("replaceAll",(()=>Z(e)),[ae(e,"replace all")])],r("button",{name:"close",onclick:()=>re(e),"aria-label":ae(e,"close"),type:"button"},["×"])])}commit(){let e=new E({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:H.of(e)}))}keydown(e){n.runScopeHandlers(this.view,e,"search-panel")?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?G:$)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),J(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(H)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(D).top}}function ae(e,t){return e.state.phrase(t)}const he=30,ce=/[\s\.,:;?!]/;function ue(e,{from:t,to:i}){let o=e.state.doc.lineAt(t),r=e.state.doc.lineAt(i).to,s=Math.max(o.from,t-he),l=Math.min(r,i+he),a=e.state.sliceDoc(s,l);if(s!=o.from)for(let e=0;e<he;e++)if(!ce.test(a[e+1])&&ce.test(a[e])){a=a.slice(e);break}if(l!=r)for(let e=a.length-1;e>a.length-he;e--)if(!ce.test(a[e-1])&&ce.test(a[e])){a=a.slice(0,e);break}return n.EditorView.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${o.number}.`)}const de=n.EditorView.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),fe=[q,o.Prec.low(Q),de];t.RegExpCursor=c,t.SearchCursor=l,t.SearchQuery=E,t.closeSearchPanel=re,t.findNext=$,t.findPrevious=G,t.getSearchQuery=function(e){let t=e.field(q,!1);return t?t.query.spec:te(e)},t.gotoLine=w,t.highlightSelectionMatches=function(e){let t=[O,M];return e&&t.push(x.of(e)),t},t.openSearchPanel=oe,t.replaceAll=Z,t.replaceNext=J,t.search=function(e){return e?[D.of(e),fe]:fe},t.searchKeymap=se,t.searchPanelOpen=function(e){var t;return null!=(null===(t=e.field(q,!1))||void 0===t?void 0:t.panel)},t.selectMatches=X,t.selectNextOccurrence=T,t.selectSelectionMatches=Y,t.setSearchQuery=H},89064:(e,t)=>{class i{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=u(this,e,t);let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(t,this.length,n,1),o.from(n,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=u(this,e,t);let i=[];return this.decompose(e,t,i,0),o.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new l(this),o=new l(e);for(let e=t,r=t;;){if(n.next(e),o.next(e),e=0,n.lineBreak!=o.lineBreak||n.done!=o.done||n.value!=o.value)return!1;if(r+=n.value.length,n.done||r>=i)return!0}}iter(e=1){return new l(this,e)}iterRange(e,t=this.length){return new a(this,e,t)}iterLines(e,t){let i;if(null==e)i=this.iter();else{null==t&&(t=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new h(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(0==e.length)throw new RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new n(e):o.from(n.split(e,[])):i.empty}}class n extends i{constructor(e,t=function(e){let t=-1;for(let i of e)t+=i.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,n){for(let o=0;;o++){let r=this.text[o],s=n+r.length;if((t?i:s)>=e)return new c(n,s,i,r);n=s+1,i++}}decompose(e,t,i,o){let l=e<=0&&t>=this.length?this:new n(s(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(1&o){let e=i.pop(),t=r(l.text,e.text.slice(),0,l.length);if(t.length<=32)i.push(new n(t,e.length+l.length));else{let e=t.length>>1;i.push(new n(t.slice(0,e)),new n(t.slice(e)))}}else i.push(l)}replace(e,t,i){if(!(i instanceof n))return super.replace(e,t,i);[e,t]=u(this,e,t);let l=r(this.text,r(i.text,s(this.text,0,e)),t),a=this.length+i.length-(t-e);return l.length<=32?new n(l,a):o.from(n.split(l,[]),a)}sliceString(e,t=this.length,i="\n"){[e,t]=u(this,e,t);let n="";for(let o=0,r=0;o<=t&&r<this.text.length;r++){let s=this.text[r],l=o+s.length;o>e&&r&&(n+=i),e<l&&t>o&&(n+=s.slice(Math.max(0,e-o),t-o)),o=l+1}return n}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],o=-1;for(let r of e)i.push(r),o+=r.length+1,32==i.length&&(t.push(new n(i,o)),i=[],o=-1);return o>-1&&t.push(new n(i,o)),t}}class o extends i{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,i,n){for(let o=0;;o++){let r=this.children[o],s=n+r.length,l=i+r.lines-1;if((t?l:s)>=e)return r.lineInner(e,t,i,n);n=s+1,i=l+1}}decompose(e,t,i,n){for(let o=0,r=0;r<=t&&o<this.children.length;o++){let s=this.children[o],l=r+s.length;if(e<=l&&t>=r){let o=n&((r<=e?1:0)|(l>=t?2:0));r>=e&&l<=t&&!o?i.push(s):s.decompose(e-r,t-r,i,o)}r=l+1}}replace(e,t,i){if([e,t]=u(this,e,t),i.lines<this.lines)for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],l=r+s.length;if(e>=r&&t<=l){let a=s.replace(e-r,t-r,i),h=this.lines-s.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let r=this.children.slice();return r[n]=a,new o(r,this.length-(t-e)+i.length)}return super.replace(r,l,a)}r=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i="\n"){[e,t]=u(this,e,t);let n="";for(let o=0,r=0;o<this.children.length&&r<=t;o++){let s=this.children[o],l=r+s.length;r>e&&o&&(n+=i),e<l&&t>r&&(n+=s.sliceString(e-r,t-r,i)),r=l+1}return n}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof o))return 0;let i=0,[n,r,s,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=t,r+=t){if(n==s||r==l)return i;let o=this.children[n],a=e.children[r];if(o!=a)return i+o.scanIdentical(a,t);i+=o.length+1}}static from(e,t=e.reduce(((e,t)=>e+t.length+1),-1)){let i=0;for(let t of e)i+=t.lines;if(i<32){let i=[];for(let t of e)t.flatten(i);return new n(i,t)}let r=Math.max(32,i>>5),s=r<<1,l=r>>1,a=[],h=0,c=-1,u=[];function d(e){let t;if(e.lines>s&&e instanceof o)for(let t of e.children)d(t);else e.lines>l&&(h>l||!h)?(f(),a.push(e)):e instanceof n&&h&&(t=u[u.length-1])instanceof n&&e.lines+t.lines<=32?(h+=e.lines,c+=e.length+1,u[u.length-1]=new n(t.text.concat(e.text),t.length+1+e.length)):(h+e.lines>r&&f(),h+=e.lines,c+=e.length+1,u.push(e))}function f(){0!=h&&(a.push(1==u.length?u[0]:o.from(u,c)),c=-1,h=u.length=0)}for(let t of e)d(t);return f(),1==a.length?a[0]:new o(a,t)}}function r(e,t,i=0,n=1e9){for(let o=0,r=0,s=!0;r<e.length&&o<=n;r++){let l=e[r],a=o+l.length;a>=i&&(a>n&&(l=l.slice(0,n-o)),o<i&&(l=l.slice(i-o)),s?(t[t.length-1]+=l,s=!1):t.push(l)),o=a+1}return t}function s(e,t,i){return r(e,[""],t,i)}i.empty=new n([""],0);class l{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof n?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,o=this.nodes[i],r=this.offsets[i],s=r>>1,l=o instanceof n?o.text.length:o.children.length;if(s==(t>0?l:0)){if(0==i)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&r)==(t>0?0:1)){if(this.offsets[i]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(o instanceof n){let n=o.text[s+(t<0?-1:0)];if(this.offsets[i]+=t,n.length>Math.max(0,e))return this.value=0==e?n:t>0?n.slice(e):n.slice(0,n.length-e),this;e-=n.length}else{let r=o.children[s+(t<0?-1:0)];e>r.length?(e-=r.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(r),this.offsets.push(t>0?1:(r instanceof n?r.text.length:r.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class a{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new l(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:n}=this.cursor.next(e);return this.pos+=(n.length+e)*t,this.value=n.length<=i?n:t<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class h{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:n}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(i.prototype[Symbol.iterator]=function(){return this.iter()},l.prototype[Symbol.iterator]=a.prototype[Symbol.iterator]=h.prototype[Symbol.iterator]=function(){return this});class c{constructor(e,t,i,n){this.from=e,this.to=t,this.number=i,this.text=n}get length(){return this.to-this.from}}function u(e,t,i){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,i))]}let d="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((e=>e?parseInt(e,36):1));for(let e=1;e<d.length;e++)d[e]+=d[e-1];function f(e){for(let t=1;t<d.length;t+=2)if(d[t]>e)return d[t-1]<=e;return!1}function p(e){return e>=127462&&e<=127487}const m=8205;function g(e,t,i=!0,n=!0){return(i?v:w)(e,t,n)}function v(e,t,i){if(t==e.length)return t;t&&y(e.charCodeAt(t))&&b(e.charCodeAt(t-1))&&t--;let n=x(e,t);for(t+=k(n);t<e.length;){let o=x(e,t);if(n==m||o==m||i&&f(o))t+=k(o),n=o;else{if(!p(o))break;{let i=0,n=t-2;for(;n>=0&&p(x(e,n));)i++,n-=2;if(i%2==0)break;t+=2}}}return t}function w(e,t,i){for(;t>0;){let n=v(e,t-2,i);if(n<t)return n;t--}return 0}function y(e){return e>=56320&&e<57344}function b(e){return e>=55296&&e<56320}function x(e,t){let i=e.charCodeAt(t);if(!b(i)||t+1==e.length)return i;let n=e.charCodeAt(t+1);return y(n)?n-56320+(i-55296<<10)+65536:i}function k(e){return e<65536?1:2}const S=/\r\n?|\n/;var C;t.MapMode=void 0,(C=t.MapMode||(t.MapMode={}))[C.Simple=0]="Simple",C[C.TrackDel=1]="TrackDel",C[C.TrackBefore=2]="TrackBefore",C[C.TrackAfter=3]="TrackAfter";class A{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,n=0;t<this.sections.length;){let o=this.sections[t++],r=this.sections[t++];r<0?(e(i,n,o),n+=o):n+=r,i+=o}}iterChangedRanges(e,t=!1){D(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];n<0?e.push(i,n):e.push(n,i)}return new A(e)}composeDesc(e){return this.empty?e:e.empty?this:P(this,e)}mapDesc(e,t=!1){return e.empty?this:E(this,e,t)}mapPos(e,i=-1,n=t.MapMode.Simple){let o=0,r=0;for(let s=0;s<this.sections.length;){let l=this.sections[s++],a=this.sections[s++],h=o+l;if(a<0){if(h>e)return r+(e-o);r+=l}else{if(n!=t.MapMode.Simple&&h>=e&&(n==t.MapMode.TrackDel&&o<e&&h>e||n==t.MapMode.TrackBefore&&o<e||n==t.MapMode.TrackAfter&&h>e))return null;if(h>e||h==e&&i<0&&!l)return e==o||i<0?r:r+a;r+=a}o=h}if(e>o)throw new RangeError(`Position ${e} is out of range for changeset of length ${o}`);return r}touchesRange(e,t=e){for(let i=0,n=0;i<this.sections.length&&n<=t;){let o=n+this.sections[i++];if(this.sections[i++]>=0&&n<=t&&o>=e)return!(n<e&&o>t)||"cover";n=o}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];e+=(e?" ":"")+i+(n>=0?":"+n:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some((e=>"number"!=typeof e)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new A(e)}static create(e){return new A(e)}}class M extends A{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return D(this,((t,i,n,o,r)=>e=e.replace(n,n+(i-t),r)),!1),e}mapDesc(e,t=!1){return E(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let o=0,r=0;o<t.length;o+=2){let s=t[o],l=t[o+1];if(l>=0){t[o]=l,t[o+1]=s;let a=o>>1;for(;n.length<a;)n.push(i.empty);n.push(s?e.slice(r,r+s):i.empty)}r+=s}return new M(t,n)}compose(e){return this.empty?e:e.empty?this:P(this,e,!0)}map(e,t=!1){return e.empty?this:E(this,e,t,!0)}iterChanges(e,t=!1){D(this,e,t)}get desc(){return A.create(this.sections)}filter(e){let t=[],i=[],n=[],o=new R(this);e:for(let r=0,s=0;;){let l=r==e.length?1e9:e[r++];for(;s<l||s==l&&0==o.len;){if(o.done)break e;let e=Math.min(o.len,l-s);O(n,e,-1);let r=-1==o.ins?-1:0==o.off?o.ins:0;O(t,e,r),r>0&&T(i,t,o.text),o.forward(e),s+=e}let a=e[r++];for(;s<a;){if(o.done)break e;let e=Math.min(o.len,a-s);O(t,e,-1),O(n,e,-1==o.ins?-1:0==o.off?o.ins:0),o.forward(e),s+=e}}return{changes:new M(t,i),filtered:A.create(n)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],n=this.sections[t+1];n<0?e.push(i):0==n?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let o=[],r=[],s=0,l=null;function a(e=!1){if(!e&&!o.length)return;s<t&&O(o,t-s,-1);let i=new M(o,r);l=l?l.compose(i.map(l)):i,o=[],r=[],s=0}return function e(h){if(Array.isArray(h))for(let t of h)e(t);else if(h instanceof M){if(h.length!=t)throw new RangeError(`Mismatched change set length (got ${h.length}, expected ${t})`);a(),l=l?l.compose(h.map(l)):h}else{let{from:e,to:l=e,insert:c}=h;if(e>l||e<0||l>t)throw new RangeError(`Invalid change range ${e} to ${l} (in doc of length ${t})`);let u=c?"string"==typeof c?i.of(c.split(n||S)):c:i.empty,d=u.length;if(e==l&&0==d)return;e<s&&a(),e>s&&O(o,e-s,-1),O(o,l-e,d),T(r,o,u),s=l}}(e),a(!l),l}static empty(e){return new M(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let o=0;o<e.length;o++){let r=e[o];if("number"==typeof r)t.push(r,-1);else{if(!Array.isArray(r)||"number"!=typeof r[0]||r.some(((e,t)=>t&&"string"!=typeof e)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)t.push(r[0],0);else{for(;n.length<o;)n.push(i.empty);n[o]=i.of(r.slice(1)),t.push(r[0],n[o].length)}}}return new M(t,n)}static createSet(e,t){return new M(e,t)}}function O(e,t,i,n=!1){if(0==t&&i<=0)return;let o=e.length-2;o>=0&&i<=0&&i==e[o+1]?e[o]+=t:0==t&&0==e[o]?e[o+1]+=i:n?(e[o]+=t,e[o+1]+=i):e.push(t,i)}function T(e,t,n){if(0==n.length)return;let o=t.length-2>>1;if(o<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<o;)e.push(i.empty);e.push(n)}}function D(e,t,n){let o=e.inserted;for(let r=0,s=0,l=0;l<e.sections.length;){let a=e.sections[l++],h=e.sections[l++];if(h<0)r+=a,s+=a;else{let c=r,u=s,d=i.empty;for(;c+=a,u+=h,h&&o&&(d=d.append(o[l-2>>1])),!(n||l==e.sections.length||e.sections[l+1]<0);)a=e.sections[l++],h=e.sections[l++];t(r,c,s,u,d),r=c,s=u}}}function E(e,t,i,n=!1){let o=[],r=n?[]:null,s=new R(e),l=new R(t);for(let e=-1;;)if(-1==s.ins&&-1==l.ins){let e=Math.min(s.len,l.len);O(o,e,-1),s.forward(e),l.forward(e)}else if(l.ins>=0&&(s.ins<0||e==s.i||0==s.off&&(l.len<s.len||l.len==s.len&&!i))){let t=l.len;for(O(o,l.ins,-1);t;){let i=Math.min(s.len,t);s.ins>=0&&e<s.i&&s.len<=i&&(O(o,0,s.ins),r&&T(r,o,s.text),e=s.i),s.forward(i),t-=i}l.next()}else{if(!(s.ins>=0)){if(s.done&&l.done)return r?M.createSet(o,r):A.create(o);throw new Error("Mismatched change set lengths")}{let t=0,i=s.len;for(;i;)if(-1==l.ins){let e=Math.min(i,l.len);t+=e,i-=e,l.forward(e)}else{if(!(0==l.ins&&l.len<i))break;i-=l.len,l.next()}O(o,t,e<s.i?s.ins:0),r&&e<s.i&&T(r,o,s.text),e=s.i,s.forward(s.len-i)}}}function P(e,t,i=!1){let n=[],o=i?[]:null,r=new R(e),s=new R(t);for(let e=!1;;){if(r.done&&s.done)return o?M.createSet(n,o):A.create(n);if(0==r.ins)O(n,r.len,0,e),r.next();else if(0!=s.len||s.done){if(r.done||s.done)throw new Error("Mismatched change set lengths");{let t=Math.min(r.len2,s.len),i=n.length;if(-1==r.ins){let i=-1==s.ins?-1:s.off?0:s.ins;O(n,t,i,e),o&&i&&T(o,n,s.text)}else-1==s.ins?(O(n,r.off?0:r.len,t,e),o&&T(o,n,r.textBit(t))):(O(n,r.off?0:r.len,s.off?0:s.ins,e),o&&!s.off&&T(o,n,s.text));e=(r.ins>t||s.ins>=0&&s.len>t)&&(e||n.length>i),r.forward2(t),s.forward(t)}}else O(n,0,s.ins,e),o&&T(o,n,s.text),s.next()}}class R{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?i.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?i.empty:t[n].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class L{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}get goalColumn(){let e=this.flags>>6;return 16777215==e?void 0:e}map(e,t=-1){let i,n;return this.empty?i=n=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new L(i,n,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return B.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return B.range(this.anchor,i)}eq(e,t=!1){return!(this.anchor!=e.anchor||this.head!=e.head||t&&this.empty&&this.assoc!=e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid JSON representation for SelectionRange");return B.range(e.anchor,e.head)}static create(e,t,i){return new L(e,t,i)}}class B{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:B.create(this.ranges.map((i=>i.map(e,t))),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new B([this.main],0)}addRange(e,t=!0){return B.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,B.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map((e=>e.toJSON())),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new B(e.ranges.map((e=>L.fromJSON(e))),e.main)}static single(e,t=e){return new B([B.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<e.length;n++){let o=e[n];if(o.empty?o.from<=i:o.from<i)return B.normalized(e.slice(),t);i=o.to}return new B(e,t)}static cursor(e,t=0,i,n){return L.create(e,e,(0==t?0:t<0?8:16)|(null==i?7:Math.min(6,i))|(null!=n?n:16777215)<<6)}static range(e,t,i,n){let o=(null!=i?i:16777215)<<6|(null==n?7:Math.min(6,n));return t<e?L.create(t,e,48|o):L.create(e,t,(t>e?8:0)|o)}static normalized(e,t=0){let i=e[t];e.sort(((e,t)=>e.from-t.from)),t=e.indexOf(i);for(let i=1;i<e.length;i++){let n=e[i],o=e[i-1];if(n.empty?n.from<=o.to:n.from<o.to){let r=o.from,s=Math.max(n.to,o.to);i<=t&&t--,e.splice(--i,2,n.anchor>n.head?B.range(s,r):B.range(r,s))}}return new B(e,t)}}function N(e,t){for(let i of e.ranges)if(i.to>t)throw new RangeError("Selection points outside of document")}let I=0;class _{constructor(e,t,i,n,o){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=n,this.id=I++,this.default=e([]),this.extensions="function"==typeof o?o(this):o}get reader(){return this}static define(e={}){return new _(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:V),!!e.static,e.enables)}of(e){return new F([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new F(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new F(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],(i=>t(i.field(e))))}}function V(e,t){return e==t||e.length==t.length&&e.every(((e,i)=>e===t[i]))}class F{constructor(e,t,i,n){this.dependencies=e,this.facet=t,this.type=i,this.value=n,this.id=I++}dynamicSlot(e){var t;let i=this.value,n=this.facet.compareInput,o=this.id,r=e[o]>>1,s=2==this.type,l=!1,a=!1,h=[];for(let i of this.dependencies)"doc"==i?l=!0:"selection"==i?a=!0:1&(null!==(t=e[i.id])&&void 0!==t?t:1)||h.push(e[i.id]);return{create:e=>(e.values[r]=i(e),1),update(e,t){if(l&&t.docChanged||a&&(t.docChanged||t.selection)||W(e,h)){let t=i(e);if(s?!H(t,e.values[r],n):!n(t,e.values[r]))return e.values[r]=t,1}return 0},reconfigure:(e,t)=>{let l,a=t.config.address[o];if(null!=a){let o=ie(t,a);if(this.dependencies.every((i=>i instanceof _?t.facet(i)===e.facet(i):!(i instanceof U)||t.field(i,!1)==e.field(i,!1)))||(s?H(l=i(e),o,n):n(l=i(e),o)))return e.values[r]=o,0}else l=i(e);return e.values[r]=l,1}}}}function H(e,t,i){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!i(e[n],t[n]))return!1;return!0}function W(e,t){let i=!1;for(let n of t)1&te(e,n)&&(i=!0);return i}function q(e,t,i){let n=i.map((t=>e[t.id])),o=i.map((e=>e.type)),r=n.filter((e=>!(1&e))),s=e[t.id]>>1;function l(e){let i=[];for(let t=0;t<n.length;t++){let r=ie(e,n[t]);if(2==o[t])for(let e of r)i.push(e);else i.push(r)}return t.combine(i)}return{create(e){for(let t of n)te(e,t);return e.values[s]=l(e),1},update(e,i){if(!W(e,r))return 0;let n=l(e);return t.compare(n,e.values[s])?0:(e.values[s]=n,1)},reconfigure(e,o){let r=W(e,n),a=o.config.facets[t.id],h=o.facet(t);if(a&&!r&&V(i,a))return e.values[s]=h,0;let c=l(e);return t.compare(c,h)?(e.values[s]=h,0):(e.values[s]=c,1)}}}const z=_.define({static:!0});class U{constructor(e,t,i,n,o){this.id=e,this.createF=t,this.updateF=i,this.compareF=n,this.spec=o,this.provides=void 0}static define(e){let t=new U(I++,e.create,e.update,e.compare||((e,t)=>e===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(z).find((e=>e.field==this));return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,i)=>{let n=e.values[t],o=this.updateF(n,i);return this.compareF(n,o)?0:(e.values[t]=o,1)},reconfigure:(e,i)=>null!=i.config.address[this.id]?(e.values[t]=i.field(this),0):(e.values[t]=this.create(e),1)}}init(e){return[this,z.of({field:this,create:e})]}get extension(){return this}}const j=4,Q=3,K=2,$=1;function G(e){return t=>new Y(t,e)}const X={highest:G(0),high:G($),default:G(K),low:G(Q),lowest:G(j)};class Y{constructor(e,t){this.inner=e,this.prec=t}}class J{of(e){return new Z(this,e)}reconfigure(e){return J.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Z{constructor(e,t){this.compartment=e,this.inner=t}}class ee{constructor(e,t,i,n,o,r){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=n,this.staticValues=o,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return null==t?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let n=[],o=Object.create(null),r=new Map;for(let i of function(e,t,i){let n=[[],[],[],[],[]],o=new Map;function r(e,s){let l=o.get(e);if(null!=l){if(l<=s)return;let t=n[l].indexOf(e);t>-1&&n[l].splice(t,1),e instanceof Z&&i.delete(e.compartment)}if(o.set(e,s),Array.isArray(e))for(let t of e)r(t,s);else if(e instanceof Z){if(i.has(e.compartment))throw new RangeError("Duplicate use of compartment in extensions");let n=t.get(e.compartment)||e.inner;i.set(e.compartment,n),r(n,s)}else if(e instanceof Y)r(e.inner,e.prec);else if(e instanceof U)n[s].push(e),e.provides&&r(e.provides,s);else if(e instanceof F)n[s].push(e),e.facet.extensions&&r(e.facet.extensions,K);else{let t=e.extension;if(!t)throw new Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(t,s)}}return r(e,K),n.reduce(((e,t)=>e.concat(t)))}(e,t,r))i instanceof U?n.push(i):(o[i.facet.id]||(o[i.facet.id]=[])).push(i);let s=Object.create(null),l=[],a=[];for(let e of n)s[e.id]=a.length<<1,a.push((t=>e.slot(t)));let h=null==i?void 0:i.config.facets;for(let e in o){let t=o[e],n=t[0].facet,r=h&&h[e]||[];if(t.every((e=>0==e.type)))if(s[n.id]=l.length<<1|1,V(r,t))l.push(i.facet(n));else{let e=n.combine(t.map((e=>e.value)));l.push(i&&n.compare(e,i.facet(n))?i.facet(n):e)}else{for(let e of t)0==e.type?(s[e.id]=l.length<<1|1,l.push(e.value)):(s[e.id]=a.length<<1,a.push((t=>e.dynamicSlot(t))));s[n.id]=a.length<<1,a.push((e=>q(e,n,t)))}}let c=a.map((e=>e(s)));return new ee(e,r,c,s,l,o)}}function te(e,t){if(1&t)return 2;let i=t>>1,n=e.status[i];if(4==n)throw new Error("Cyclic dependency between fields and/or facets");if(2&n)return n;e.status[i]=4;let o=e.computeSlot(e,e.config.dynamicSlots[i]);return e.status[i]=2|o}function ie(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}const ne=_.define(),oe=_.define({combine:e=>e.some((e=>e)),static:!0}),re=_.define({combine:e=>e.length?e[0]:void 0,static:!0}),se=_.define(),le=_.define(),ae=_.define(),he=_.define({combine:e=>!!e.length&&e[0]});class ce{constructor(e,t){this.type=e,this.value=t}static define(){return new ue}}class ue{of(e){return new ce(this,e)}}class de{constructor(e){this.map=e}of(e){return new fe(this,e)}}class fe{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new fe(this.type,t)}is(e){return this.type==e}static define(e={}){return new de(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let n of e){let e=n.map(t);e&&i.push(e)}return i}}fe.reconfigure=fe.define(),fe.appendConfig=fe.define();class pe{constructor(e,t,i,n,o,r){this.startState=e,this.changes=t,this.selection=i,this.effects=n,this.annotations=o,this.scrollIntoView=r,this._doc=null,this._state=null,i&&N(i,t.newLength),o.some((e=>e.type==pe.time))||(this.annotations=o.concat(pe.time.of(Date.now())))}static create(e,t,i,n,o,r){return new pe(e,t,i,n,o,r)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(pe.userEvent);return!(!t||!(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function me(e,t){let i=[];for(let n=0,o=0;;){let r,s;if(n<e.length&&(o==t.length||t[o]>=e[n]))r=e[n++],s=e[n++];else{if(!(o<t.length))return i;r=t[o++],s=t[o++]}!i.length||i[i.length-1]<r?i.push(r,s):i[i.length-1]<s&&(i[i.length-1]=s)}}function ge(e,t,i){var n;let o,r,s;return i?(o=t.changes,r=M.empty(t.changes.length),s=e.changes.compose(t.changes)):(o=t.changes.map(e.changes),r=e.changes.mapDesc(t.changes,!0),s=e.changes.compose(o)),{changes:s,selection:t.selection?t.selection.map(r):null===(n=e.selection)||void 0===n?void 0:n.map(o),effects:fe.mapEffects(e.effects,o).concat(fe.mapEffects(t.effects,r)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function ve(e,t,i){let n=t.selection,o=be(t.annotations);return t.userEvent&&(o=o.concat(pe.userEvent.of(t.userEvent))),{changes:t.changes instanceof M?t.changes:M.of(t.changes||[],i,e.facet(re)),selection:n&&(n instanceof B?n:B.single(n.anchor,n.head)),effects:be(t.effects),annotations:o,scrollIntoView:!!t.scrollIntoView}}function we(e,t,i){let n=ve(e,t.length?t[0]:{},e.doc.length);t.length&&!1===t[0].filter&&(i=!1);for(let o=1;o<t.length;o++){!1===t[o].filter&&(i=!1);let r=!!t[o].sequential;n=ge(n,ve(e,t[o],r?n.changes.newLength:e.doc.length),r)}let o=pe.create(e,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(e){let t=e.startState,i=t.facet(ae),n=e;for(let o=i.length-1;o>=0;o--){let r=i[o](e);r&&Object.keys(r).length&&(n=ge(n,ve(t,r,e.changes.newLength),!0))}return n==e?e:pe.create(t,e.changes,e.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(e){let t=e.startState,i=!0;for(let n of t.facet(se)){let t=n(e);if(!1===t){i=!1;break}Array.isArray(t)&&(i=!0===i?t:me(i,t))}if(!0!==i){let n,o;if(!1===i)o=e.changes.invertedDesc,n=M.empty(t.doc.length);else{let t=e.changes.filter(i);n=t.changes,o=t.filtered.mapDesc(t.changes).invertedDesc}e=pe.create(t,n,e.selection&&e.selection.map(o),fe.mapEffects(e.effects,o),e.annotations,e.scrollIntoView)}let n=t.facet(le);for(let i=n.length-1;i>=0;i--){let o=n[i](e);e=o instanceof pe?o:Array.isArray(o)&&1==o.length&&o[0]instanceof pe?o[0]:we(t,be(o),!1)}return e}(o):o)}pe.time=ce.define(),pe.userEvent=ce.define(),pe.addToHistory=ce.define(),pe.remote=ce.define();const ye=[];function be(e){return null==e?ye:Array.isArray(e)?e:[e]}var xe;t.CharCategory=void 0,(xe=t.CharCategory||(t.CharCategory={}))[xe.Word=0]="Word",xe[xe.Space=1]="Space",xe[xe.Other=2]="Other";const ke=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Se;try{Se=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}function Ce(e){return i=>{if(!/\S/.test(i))return t.CharCategory.Space;if(function(e){if(Se)return Se.test(e);for(let t=0;t<e.length;t++){let i=e[t];if(/\w/.test(i)||i>""&&(i.toUpperCase()!=i.toLowerCase()||ke.test(i)))return!0}return!1}(i))return t.CharCategory.Word;for(let n=0;n<e.length;n++)if(i.indexOf(e[n])>-1)return t.CharCategory.Word;return t.CharCategory.Other}}class Ae{constructor(e,t,i,n,o,r){this.config=e,this.doc=t,this.selection=i,this.values=n,this.status=e.statusTemplate.slice(),this.computeSlot=o,r&&(r._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)te(this,e<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(null!=i)return te(this,i),ie(this,i);if(t)throw new RangeError("Field is not present in this state")}update(...e){return we(this,e,!0)}applyTransaction(e){let t,i=this.config,{base:n,compartments:o}=i;for(let t of e.effects)t.is(J.reconfigure)?(i&&(o=new Map,i.compartments.forEach(((e,t)=>o.set(t,e))),i=null),o.set(t.value.compartment,t.value.extension)):t.is(fe.reconfigure)?(i=null,n=t.value):t.is(fe.appendConfig)&&(i=null,n=be(n).concat(t.value));if(i)t=e.startState.values.slice();else{i=ee.resolve(n,o,this),t=new Ae(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((e,t)=>t.reconfigure(e,this)),null).values}let r=e.startState.facet(oe)?e.newSelection:e.newSelection.asSingle();new Ae(i,e.newDoc,r,t,((t,i)=>i.update(t,e)),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange((t=>({changes:{from:t.from,to:t.to,insert:e},range:B.cursor(t.from+e.length)})))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),n=this.changes(i.changes),o=[i.range],r=be(i.effects);for(let i=1;i<t.ranges.length;i++){let s=e(t.ranges[i]),l=this.changes(s.changes),a=l.map(n);for(let e=0;e<i;e++)o[e]=o[e].map(a);let h=n.mapDesc(l,!0);o.push(s.range.map(h)),n=n.compose(a),r=fe.mapEffects(r,a).concat(fe.mapEffects(be(s.effects),h))}return{changes:n,selection:B.create(o,t.mainIndex),effects:r}}changes(e=[]){return e instanceof M?e:M.of(e,this.doc.length,this.facet(Ae.lineSeparator))}toText(e){return i.of(e.split(this.facet(Ae.lineSeparator)||S))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return null==t?e.default:(te(this,t),ie(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let n=e[i];n instanceof U&&null!=this.config.address[n.id]&&(t[i]=n.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||"string"!=typeof e.doc)throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i)for(let t in i)if(Object.prototype.hasOwnProperty.call(e,t)){let o=i[t],r=e[t];n.push(o.init((e=>o.spec.fromJSON(r,e))))}return Ae.create({doc:e.doc,selection:B.fromJSON(e.selection),extensions:t.extensions?n.concat([t.extensions]):n})}static create(e={}){let t=ee.resolve(e.extensions||[],new Map),n=e.doc instanceof i?e.doc:i.of((e.doc||"").split(t.staticFacet(Ae.lineSeparator)||S)),o=e.selection?e.selection instanceof B?e.selection:B.single(e.selection.anchor,e.selection.head):B.single(0);return N(o,n.length),t.staticFacet(oe)||(o=o.asSingle()),new Ae(t,n,o,t.dynamicSlots.map((()=>null)),((e,t)=>t.create(e)),null)}get tabSize(){return this.facet(Ae.tabSize)}get lineBreak(){return this.facet(Ae.lineSeparator)||"\n"}get readOnly(){return this.facet(he)}phrase(e,...t){for(let t of this.facet(Ae.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,((e,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>t.length?e:t[n-1]}))),e}languageDataAt(e,t,i=-1){let n=[];for(let o of this.facet(ne))for(let r of o(this,t,i))Object.prototype.hasOwnProperty.call(r,e)&&n.push(r[e]);return n}charCategorizer(e){return Ce(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:i,from:n,length:o}=this.doc.lineAt(e),r=this.charCategorizer(e),s=e-n,l=e-n;for(;s>0;){let e=g(i,s,!1);if(r(i.slice(e,s))!=t.CharCategory.Word)break;s=e}for(;l<o;){let e=g(i,l);if(r(i.slice(l,e))!=t.CharCategory.Word)break;l=e}return s==l?null:B.range(s+n,l+n)}}Ae.allowMultipleSelections=oe,Ae.tabSize=_.define({combine:e=>e.length?e[0]:4}),Ae.lineSeparator=re,Ae.readOnly=he,Ae.phrases=_.define({compare(e,t){let i=Object.keys(e),n=Object.keys(t);return i.length==n.length&&i.every((i=>e[i]==t[i]))}}),Ae.languageData=ne,Ae.changeFilter=se,Ae.transactionFilter=le,Ae.transactionExtender=ae,J.reconfigure=fe.define();class Me{eq(e){return this==e}range(e,t=e){return Oe.create(e,t,this)}}Me.prototype.startSide=Me.prototype.endSide=0,Me.prototype.point=!1,Me.prototype.mapMode=t.MapMode.TrackDel;class Oe{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new Oe(e,t,i)}}function Te(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class De{constructor(e,t,i,n){this.from=e,this.to=t,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,n=0){let o=i?this.to:this.from;for(let r=n,s=o.length;;){if(r==s)return r;let n=r+s>>1,l=o[n]-e||(i?this.value[n].endSide:this.value[n].startSide)-t;if(n==r)return l>=0?r:s;l>=0?s=n:r=n+1}}between(e,t,i,n){for(let o=this.findIndex(t,-1e9,!0),r=this.findIndex(i,1e9,!1,o);o<r;o++)if(!1===n(this.from[o]+e,this.to[o]+e,this.value[o]))return!1}map(e,t){let i=[],n=[],o=[],r=-1,s=-1;for(let l=0;l<this.value.length;l++){let a,h,c=this.value[l],u=this.from[l]+e,d=this.to[l]+e;if(u==d){let e=t.mapPos(u,c.startSide,c.mapMode);if(null==e)continue;if(a=h=e,c.startSide!=c.endSide&&(h=t.mapPos(u,c.endSide),h<a))continue}else if(a=t.mapPos(u,c.startSide),h=t.mapPos(d,c.endSide),a>h||a==h&&c.startSide>0&&c.endSide<=0)continue;(h-a||c.endSide-c.startSide)<0||(r<0&&(r=a),c.point&&(s=Math.max(s,h-a)),i.push(c),n.push(a-r),o.push(h-r))}return{mapped:i.length?new De(n,o,i,s):null,pos:r}}}class Ee{constructor(e,t,i,n){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=n}static create(e,t,i,n){return new Ee(e,t,i,n)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:n=0,filterTo:o=this.length}=e,r=e.filter;if(0==t.length&&!r)return this;if(i&&(t=t.slice().sort(Te)),this.isEmpty)return t.length?Ee.of(t):this;let s=new Le(this,null,-1).goto(0),l=0,a=[],h=new Pe;for(;s.value||l<t.length;)if(l<t.length&&(s.from-t[l].from||s.startSide-t[l].value.startSide)>=0){let e=t[l++];h.addInner(e.from,e.to,e.value)||a.push(e)}else 1==s.rangeIndex&&s.chunkIndex<this.chunk.length&&(l==t.length||this.chunkEnd(s.chunkIndex)<t[l].from)&&(!r||n>this.chunkEnd(s.chunkIndex)||o<this.chunkPos[s.chunkIndex])&&h.addChunk(this.chunkPos[s.chunkIndex],this.chunk[s.chunkIndex])?s.nextChunk():((!r||n>s.to||o<s.from||r(s.from,s.to,s.value))&&(h.addInner(s.from,s.to,s.value)||a.push(Oe.create(s.from,s.to,s.value))),s.next());return h.finishInner(this.nextLayer.isEmpty&&!a.length?Ee.empty:this.nextLayer.update({add:a,filter:r,filterFrom:n,filterTo:o}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],n=-1;for(let o=0;o<this.chunk.length;o++){let r=this.chunkPos[o],s=this.chunk[o],l=e.touchesRange(r,r+s.length);if(!1===l)n=Math.max(n,s.maxPoint),t.push(s),i.push(e.mapPos(r));else if(!0===l){let{mapped:o,pos:l}=s.map(r,e);o&&(n=Math.max(n,o.maxPoint),t.push(o),i.push(l))}}let o=this.nextLayer.map(e);return 0==t.length?o:new Ee(i,t,o||Ee.empty,n)}between(e,t,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let o=this.chunkPos[n],r=this.chunk[n];if(t>=o&&e<=o+r.length&&!1===r.between(o,e-o,t-o,i))return}this.nextLayer.between(e,t,i)}}iter(e=0){return Be.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Be.from(e).goto(t)}static compare(e,t,i,n,o=-1){let r=e.filter((e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=o)),s=t.filter((e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=o)),l=Re(r,s,i),a=new Ie(r,l,o),h=new Ie(s,l,o);i.iterGaps(((e,t,i)=>_e(a,e,h,t,i,n))),i.empty&&0==i.length&&_e(a,0,h,0,0,n)}static eq(e,t,i=0,n){null==n&&(n=999999999);let o=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0)),r=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0));if(o.length!=r.length)return!1;if(!o.length)return!0;let s=Re(o,r),l=new Ie(o,s,0).goto(i),a=new Ie(r,s,0).goto(i);for(;;){if(l.to!=a.to||!Ve(l.active,a.active)||l.point&&(!a.point||!l.point.eq(a.point)))return!1;if(l.to>n)return!0;l.next(),a.next()}}static spans(e,t,i,n,o=-1){let r=new Ie(e,null,o).goto(t),s=t,l=r.openStart;for(;;){let e=Math.min(r.to,i);if(r.point){let i=r.activeForPoint(r.to),o=r.pointFrom<t?i.length+1:r.point.startSide<0?i.length:Math.min(i.length,l);n.point(s,e,r.point,i,o,r.pointRank),l=Math.min(r.openEnd(e),i.length)}else e>s&&(n.span(s,e,r.active,l),l=r.openEnd(e));if(r.to>i)return l+(r.point&&r.to>i?1:0);s=r.to,r.next()}}static of(e,t=!1){let i=new Pe;for(let n of e instanceof Oe?[e]:t?function(e){if(e.length>1)for(let t=e[0],i=1;i<e.length;i++){let n=e[i];if(Te(t,n)>0)return e.slice().sort(Te);t=n}return e}(e):e)i.add(n.from,n.to,n.value);return i.finish()}static join(e){if(!e.length)return Ee.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let n=e[i];n!=Ee.empty;n=n.nextLayer)t=new Ee(n.chunkPos,n.chunk,t,Math.max(n.maxPoint,t.maxPoint));return t}}Ee.empty=new Ee([],[],null,-1),Ee.empty.nextLayer=Ee.empty;class Pe{finishChunk(e){this.chunks.push(new De(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new Pe)).add(e,t,i)}addInner(e,t,i){let n=e-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(Ee.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=Ee.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function Re(e,t,i){let n=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&n.set(t.chunk[e],t.chunkPos[e]);let o=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let r=n.get(e.chunk[t]);null==r||(i?i.mapPos(r):r)!=e.chunkPos[t]||(null==i?void 0:i.touchesRange(r,r+e.chunk[t].length))||o.add(e.chunk[t])}return o}class Le{constructor(e,t,i,n=0){this.layer=e,this.skip=t,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,i){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],i=e+t.from[this.rangeIndex];if(this.from=i,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class Be{constructor(e){this.heap=e}static from(e,t=null,i=-1){let n=[];for(let o=0;o<e.length;o++)for(let r=e[o];!r.isEmpty;r=r.nextLayer)r.maxPoint>=i&&n.push(new Le(r,t,i,o));return 1==n.length?n[0]:new Be(n)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)Ne(this.heap,e);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)Ne(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Ne(this.heap,0)}}}function Ne(e,t){for(let i=e[t];;){let n=1+(t<<1);if(n>=e.length)break;let o=e[n];if(n+1<e.length&&o.compare(e[n+1])>=0&&(o=e[n+1],n++),i.compare(o)<0)break;e[n]=i,e[t]=o,t=n}}class Ie{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Be.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Fe(this.active,e),Fe(this.activeTo,e),Fe(this.activeRank,e),this.minActive=We(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:n,rank:o}=this.cursor;for(;t<this.activeRank.length&&(o-this.activeRank[t]||n-this.activeTo[t])>0;)t++;He(this.active,t,i),He(this.activeTo,t,n),He(this.activeRank,t,o),e&&He(e,t,this.cursor.from),this.minActive=We(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>e){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&Fe(i,n)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let e=this.cursor.value;if(e.point){if(!(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let t=i.length-1;t>=0&&i[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function _e(e,t,i,n,o,r){e.goto(t),i.goto(n);let s=n+o,l=n,a=n-t;for(;;){let t=e.to+a-i.to||e.endSide-i.endSide,n=t<0?e.to+a:i.to,o=Math.min(n,s);if(e.point||i.point?e.point&&i.point&&(e.point==i.point||e.point.eq(i.point))&&Ve(e.activeForPoint(e.to),i.activeForPoint(i.to))||r.comparePoint(l,o,e.point,i.point):o>l&&!Ve(e.active,i.active)&&r.compareRange(l,o,e.active,i.active),n>s)break;l=n,t<=0&&e.next(),t>=0&&i.next()}}function Ve(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!=t[i]&&!e[i].eq(t[i]))return!1;return!0}function Fe(e,t){for(let i=t,n=e.length-1;i<n;i++)e[i]=e[i+1];e.pop()}function He(e,t,i){for(let i=e.length-1;i>=t;i--)e[i+1]=e[i];e[t]=i}function We(e,t){let i=-1,n=1e9;for(let o=0;o<t.length;o++)(t[o]-n||e[o].endSide-e[i].endSide)<0&&(i=o,n=t[o]);return i}t.Annotation=ce,t.AnnotationType=ue,t.ChangeDesc=A,t.ChangeSet=M,t.Compartment=J,t.EditorSelection=B,t.EditorState=Ae,t.Facet=_,t.Line=c,t.Prec=X,t.Range=Oe,t.RangeSet=Ee,t.RangeSetBuilder=Pe,t.RangeValue=Me,t.SelectionRange=L,t.StateEffect=fe,t.StateEffectType=de,t.StateField=U,t.Text=i,t.Transaction=pe,t.codePointAt=x,t.codePointSize=k,t.combineConfig=function(e,t,i={}){let n={};for(let t of e)for(let e of Object.keys(t)){let o=t[e],r=n[e];if(void 0===r)n[e]=o;else if(r===o||void 0===o);else{if(!Object.hasOwnProperty.call(i,e))throw new Error("Config merge conflict for field "+e);n[e]=i[e](r,o)}}for(let e in t)void 0===n[e]&&(n[e]=t[e]);return n},t.countColumn=function(e,t,i=e.length){let n=0;for(let o=0;o<i;)9==e.charCodeAt(o)?(n+=t-n%t,o++):(n++,o=g(e,o));return n},t.findClusterBreak=g,t.findColumn=function(e,t,i,n){for(let n=0,o=0;;){if(o>=t)return n;if(n==e.length)break;o+=9==e.charCodeAt(n)?i-o%i:1,n=g(e,n)}return!0===n?-1:e.length},t.fromCodePoint=function(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}},61506:(e,t,i)=>{var n=i(89064),o=i(9172),r=i(76237);function s(e){let t;return t=11==e.nodeType?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function l(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function a(e,t){if(!t.anchorNode)return!1;try{return l(e,t.anchorNode)}catch(e){return!1}}function h(e){return 3==e.nodeType?k(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function c(e,t,i,n){return!!i&&(f(e,t,i,n,-1)||f(e,t,i,n,1))}function u(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function d(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function f(e,t,i,n,o){for(;;){if(e==i&&t==n)return!0;if(t==(o<0?0:p(e))){if("DIV"==e.nodeName)return!1;let i=e.parentNode;if(!i||1!=i.nodeType)return!1;t=u(e)+(o<0?0:1),e=i}else{if(1!=e.nodeType)return!1;if(1==(e=e.childNodes[t+(o<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=o<0?p(e):0}}}function p(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function m(e,t){let i=t?e.left:e.right;return{left:i,right:i,top:e.top,bottom:e.bottom}}function g(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function v(e,t){let i=t.width/e.offsetWidth,n=t.height/e.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(t.width-e.offsetWidth)<1)&&(i=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.height-e.offsetHeight)<1)&&(n=1),{scaleX:i,scaleY:n}}class w{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?p(t):0),i,Math.min(e.focusOffset,i?p(i):0))}set(e,t,i,n){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=n}}let y,b=null;function x(e){if(e.setActive)return e.setActive();if(b)return e.focus(b);let t=[];for(let i=e;i&&(t.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(e.focus(null==b?{get preventScroll(){return b={preventScroll:!0},!0}}:void 0),!b){b=!1;for(let e=0;e<t.length;){let i=t[e++],n=t[e++],o=t[e++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=o&&(i.scrollLeft=o)}}}function k(e,t,i=t){let n=y||(y=document.createRange());return n.setEnd(e,i),n.setStart(e,t),n}function S(e,t,i,n){let o={key:t,code:t,keyCode:i,which:i,cancelable:!0};n&&({altKey:o.altKey,ctrlKey:o.ctrlKey,shiftKey:o.shiftKey,metaKey:o.metaKey}=n);let r=new KeyboardEvent("keydown",o);r.synthetic=!0,e.dispatchEvent(r);let s=new KeyboardEvent("keyup",o);return s.synthetic=!0,e.dispatchEvent(s),r.defaultPrevented||s.defaultPrevented}function C(e){for(;e.attributes.length;)e.removeAttributeNode(e.attributes[0])}function A(e){return e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function M(e,t){for(let i=e,n=t;;){if(3==i.nodeType&&n>0)return{node:i,offset:n};if(1==i.nodeType&&n>0){if("false"==i.contentEditable)return null;i=i.childNodes[n-1],n=p(i)}else{if(!i.parentNode||d(i))return null;n=u(i),i=i.parentNode}}}function O(e,t){for(let i=e,n=t;;){if(3==i.nodeType&&n<i.nodeValue.length)return{node:i,offset:n};if(1==i.nodeType&&n<i.childNodes.length){if("false"==i.contentEditable)return null;i=i.childNodes[n],n=0}else{if(!i.parentNode||d(i))return null;n=u(i)+1,i=i.parentNode}}}class T{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new T(e.parentNode,u(e),t)}static after(e,t){return new T(e.parentNode,u(e)+1,t)}}const D=[];class E{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let i of this.children){if(i==e)return t;t+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(2&this.flags){let i,n=this.dom,o=null;for(let r of this.children){if(7&r.flags){if(!r.dom&&(i=o?o.nextSibling:n.firstChild)){let e=E.get(i);(!e||!e.parent&&e.canReuseDOM(r))&&r.reuseDOM(i)}r.sync(e,t),r.flags&=-8}if(i=o?o.nextSibling:n.firstChild,t&&!t.written&&t.node==n&&i!=r.dom&&(t.written=!0),r.dom.parentNode==n)for(;i&&i!=r.dom;)i=P(i);else n.insertBefore(r.dom,i);o=r.dom}for(i=o?o.nextSibling:n.firstChild,i&&t&&t.node==n&&(t.written=!0);i;)i=P(i)}else if(1&this.flags)for(let i of this.children)7&i.flags&&(i.sync(e,t),i.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let i;if(e==this.dom)i=this.dom.childNodes[t];else{let n=0==p(e)?0:0==t?-1:1;for(;;){let t=e.parentNode;if(t==this.dom)break;0==n&&t.firstChild!=t.lastChild&&(n=e==t.firstChild?-1:1),e=t}i=n<0?e:e.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!E.get(i);)i=i.nextSibling;if(!i)return this.length;for(let e=0,t=0;;e++){let n=this.children[e];if(n.dom==i)return t;t+=n.length+n.breakAfter}}domBoundsAround(e,t,i=0){let n=-1,o=-1,r=-1,s=-1;for(let l=0,a=i,h=i;l<this.children.length;l++){let i=this.children[l],c=a+i.length;if(a<e&&c>t)return i.domBoundsAround(e,t,a);if(c>=e&&-1==n&&(n=l,o=a),a>t&&i.dom.parentNode==this.dom){r=l,s=h;break}h=c,a=c+i.breakAfter}return{from:o,to:s<0?i+this.length:s,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:r<this.children.length&&r>=0?this.children[r].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),1&t.flags)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,7&this.flags&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,i=D){this.markDirty();for(let n=e;n<t;n++){let e=this.children[n];e.parent==this&&i.indexOf(e)<0&&e.destroy()}this.children.splice(e,t-e,...i);for(let e=0;e<i.length;e++)i[e].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new R(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==e?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,i,n,o,r){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!(8&(this.flags|e.flags))}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}}function P(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}E.prototype.breakAfter=0;class R{constructor(e,t,i){this.children=e,this.pos=t,this.i=i,this.off=0}findPos(e,t=1){for(;;){if(e>this.pos||e==this.pos&&(t>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function L(e,t,i,n,o,r,s,l,a){let{children:h}=e,c=h.length?h[t]:null,u=r.length?r[r.length-1]:null,d=u?u.breakAfter:s;if(!(t==n&&c&&!s&&!d&&r.length<2&&c.merge(i,o,r.length?u:null,0==i,l,a))){if(n<h.length){let e=h[n];e&&(o<e.length||e.breakAfter&&(null==u?void 0:u.breakAfter))?(t==n&&(e=e.split(o),o=0),!d&&u&&e.merge(0,o,u,!0,0,a)?r[r.length-1]=e:((o||e.children.length&&!e.children[0].length)&&e.merge(0,o,null,!1,0,a),r.push(e))):(null==e?void 0:e.breakAfter)&&(u?u.breakAfter=1:s=1),n++}for(c&&(c.breakAfter=s,i>0&&(!s&&r.length&&c.merge(i,c.length,r[0],!1,l,0)?c.breakAfter=r.shift().breakAfter:(i<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(i,c.length,null,!1,l,0),t++));t<n&&r.length;)if(h[n-1].become(r[r.length-1]))n--,r.pop(),a=r.length?0:l;else{if(!h[t].become(r[0]))break;t++,r.shift(),l=r.length?0:a}!r.length&&t&&n<h.length&&!h[t-1].breakAfter&&h[n].merge(0,0,h[t-1],!1,l,a)&&t--,(t<n||r.length)&&e.replaceChildren(t,n,r)}}function B(e,t,i,n,o,r){let s=e.childCursor(),{i:l,off:a}=s.findPos(i,1),{i:h,off:c}=s.findPos(t,-1),u=t-i;for(let e of n)u+=e.length;e.length+=u,L(e,h,c,l,a,n,0,o,r)}let N="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},I="undefined"!=typeof document?document:{documentElement:{style:{}}};const _=/Edge\/(\d+)/.exec(N.userAgent),V=/MSIE \d/.test(N.userAgent),F=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(N.userAgent),H=!!(V||F||_),W=!H&&/gecko\/(\d+)/i.test(N.userAgent),q=!H&&/Chrome\/(\d+)/.exec(N.userAgent),z="webkitFontSmoothing"in I.documentElement.style,U=!H&&/Apple Computer/.test(N.vendor),j=U&&(/Mobile\/\w+/.test(N.userAgent)||N.maxTouchPoints>2);var Q={mac:j||/Mac/.test(N.platform),windows:/Win/.test(N.platform),linux:/Linux|X11/.test(N.platform),ie:H,ie_version:V?I.documentMode||6:F?+F[1]:_?+_[1]:0,gecko:W,gecko_version:W?+(/Firefox\/(\d+)/.exec(N.userAgent)||[0,0])[1]:0,chrome:!!q,chrome_version:q?+q[1]:0,ios:j,android:/Android\b/.test(N.userAgent),webkit:z,safari:U,webkit_version:z?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=I.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class K extends E{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){3==e.nodeType&&this.createDOM(e)}merge(e,t,i){return!(8&this.flags||i&&(!(i instanceof K)||this.length-(t-e)+i.length>256||8&i.flags))&&(this.text=this.text.slice(0,e)+(i?i.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new K(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=8&this.flags,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new T(this.dom,e)}domBoundsAround(e,t,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return function(e,t,i){let n=e.nodeValue.length;t>n&&(t=n);let o=t,r=t,s=0;0==t&&i<0||t==n&&i>=0?Q.chrome||Q.gecko||(t?(o--,s=1):r<n&&(r++,s=-1)):i<0?o--:r<n&&r++;let l=k(e,o,r).getClientRects();if(!l.length)return null;let a=l[(s?s<0:i>=0)?0:l.length-1];Q.safari&&!s&&0==a.width&&(a=Array.prototype.find.call(l,(e=>e.width))||a);return s?m(a,s<0):a||null}(this.dom,e,t)}}class $ extends E{constructor(e,t=[],i=0){super(),this.mark=e,this.children=t,this.length=i;for(let e of t)e.setParent(this)}setAttrs(e){if(C(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!(8&(this.flags|e.flags))}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,i,n,o,r){return(!i||!(!(i instanceof $&&i.mark.eq(this.mark))||e&&o<=0||t<this.length&&r<=0))&&(B(this,e,t,i?i.children.slice():[],o-1,r-1),this.markDirty(),!0)}split(e){let t=[],i=0,n=-1,o=0;for(let r of this.children){let s=i+r.length;s>e&&t.push(i<e?r.split(e-i):r),n<0&&i>=e&&(n=o),i=s,o++}let r=this.length-e;return this.length=e,n>-1&&(this.children.length=n,this.markDirty()),new $(this.mark,t,r)}domAtPos(e){return Y(this,e)}coordsAt(e,t){return Z(this,e,t)}}class G extends E{static create(e,t,i){return new G(e,t,i)}constructor(e,t,i){super(),this.widget=e,this.length=t,this.side=i,this.prevWidget=null}split(e){let t=G.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){this.dom&&this.widget.updateDOM(this.dom,e)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,t,i,n,o,r){return!(i&&(!(i instanceof G&&this.widget.compare(i.widget))||e>0&&o<=0||t<this.length&&r<=0))&&(this.length=e+(i?i.length:0)+(this.length-t),!0)}become(e){return e instanceof G&&e.side==this.side&&this.widget.constructor==e.widget.constructor&&(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0)}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(0==this.length)return n.Text.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,i=t&&t.state.doc,o=this.posAtStart;return i?i.slice(o,o+this.length):n.Text.empty}domAtPos(e){return(this.length?0==e:this.side>0)?T.before(this.dom):T.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let i=this.widget.coordsAt(this.dom,e,t);if(i)return i;let n=this.dom.getClientRects(),o=null;if(!n.length)return null;let r=this.side?this.side<0:e>0;for(let t=r?n.length-1:0;o=n[t],!(e>0?0==t:t==n.length-1||o.top<o.bottom);t+=r?-1:1);return m(o,!r)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class X extends E{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof X&&e.side==this.side}split(){return new X(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?T.before(this.dom):T.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return n.Text.empty}get isHidden(){return!0}}function Y(e,t){let i=e.dom,{children:n}=e,o=0;for(let e=0;o<n.length;o++){let r=n[o],s=e+r.length;if(!(s==e&&r.getSide()<=0)){if(t>e&&t<s&&r.dom.parentNode==i)return r.domAtPos(t-e);if(t<=e)break;e=s}}for(let e=o;e>0;e--){let t=n[e-1];if(t.dom.parentNode==i)return t.domAtPos(t.length)}for(let e=o;e<n.length;e++){let t=n[e];if(t.dom.parentNode==i)return t.domAtPos(0)}return new T(i,0)}function J(e,t,i){let n,{children:o}=e;i>0&&t instanceof $&&o.length&&(n=o[o.length-1])instanceof $&&n.mark.eq(t.mark)?J(n,t.children[0],i-1):(o.push(t),t.setParent(e)),e.length+=t.length}function Z(e,t,i){let n=null,o=-1,r=null,s=-1;!function e(t,l){for(let a=0,h=0;a<t.children.length&&h<=l;a++){let c=t.children[a],u=h+c.length;u>=l&&(c.children.length?e(c,l-h):(!r||r.isHidden&&i>0)&&(u>l||h==u&&c.getSide()>0)?(r=c,s=l-h):(h<l||h==u&&c.getSide()<0&&!c.isHidden)&&(n=c,o=l-h)),h=u}}(e,t);let l=(i<0?n:r)||n||r;return l?l.coordsAt(Math.max(0,l==n?o:s),i):function(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let i=h(t);return i[i.length-1]||null}(e)}function ee(e,t){for(let i in e)"class"==i&&t.class?t.class+=" "+e.class:"style"==i&&t.style?t.style+=";"+e.style:t[i]=e[i];return t}K.prototype.children=G.prototype.children=X.prototype.children=D;const te=Object.create(null);function ie(e,t,i){if(e==t)return!0;e||(e=te),t||(t=te);let n=Object.keys(e),o=Object.keys(t);if(n.length-(i&&n.indexOf(i)>-1?1:0)!=o.length-(i&&o.indexOf(i)>-1?1:0))return!1;for(let r of n)if(r!=i&&(-1==o.indexOf(r)||e[r]!==t[r]))return!1;return!0}function ne(e,t,i){let n=!1;if(t)for(let o in t)i&&o in i||(n=!0,"style"==o?e.style.cssText="":e.removeAttribute(o));if(i)for(let o in i)t&&t[o]==i[o]||(n=!0,"style"==o?e.style.cssText=i[o]:e.setAttribute(o,i[o]));return n}function oe(e){let t=Object.create(null);for(let i=0;i<e.attributes.length;i++){let n=e.attributes[i];t[n.name]=n.value}return t}class re extends E{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,i,n,o,r){if(i){if(!(i instanceof re))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),B(this,e,t,i?i.children.slice():[],o,r),!0}split(e){let t=new re;if(t.breakAfter=this.breakAfter,0==this.length)return t;let{i,off:n}=this.childPos(e);n&&(t.append(this.children[i].split(n),0),this.children[i].merge(n,this.children[i].length,null,!1,0,0),i++);for(let e=i;e<this.children.length;e++)t.append(this.children[e],0);for(;i>0&&0==this.children[i-1].length;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){ie(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){J(this,e,t)}addLineDeco(e){let t=e.spec.attributes,i=e.spec.class;t&&(this.attrs=ee(t,this.attrs||{})),i&&(this.attrs=ee({class:i},this.attrs||{}))}domAtPos(e){return Y(this,e)}reuseDOM(e){"DIV"==e.nodeName&&(this.setDOM(e),this.flags|=6)}sync(e,t){var i;this.dom?4&this.flags&&(C(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(ne(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let n=this.dom.lastChild;for(;n&&E.get(n)instanceof $;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=E.get(n))||void 0===i?void 0:i.isEditable)||Q.ios&&this.children.some((e=>e instanceof K))))){let e=document.createElement("BR");e.cmIgnore=!0,this.dom.appendChild(e)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let e,t=0;for(let i of this.children){if(!(i instanceof K)||/[^ -~]/.test(i.text))return null;let n=h(i.dom);if(1!=n.length)return null;t+=n[0].width,e=n[0].height}return t?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:t/this.length,textHeight:e}:null}coordsAt(e,t){let i=Z(this,e,t);if(!this.children.length&&i&&this.parent){let{heightOracle:e}=this.parent.view.viewState,t=i.bottom-i.top;if(Math.abs(t-e.lineHeight)<2&&e.textHeight<t){let n=(t-e.textHeight)/2;return{top:i.top+n,bottom:i.bottom-n,left:i.left,right:i.left}}}return i}become(e){return!1}covers(){return!0}static find(e,t){for(let i=0,n=0;i<e.children.length;i++){let o=e.children[i],r=n+o.length;if(r>=t){if(o instanceof re)return o;if(r>t)break}n=r+o.breakAfter}return null}}class se extends E{constructor(e,t,i){super(),this.widget=e,this.length=t,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(e,t,i,n,o,r){return!(i&&(!(i instanceof se&&this.widget.compare(i.widget))||e>0&&o<=0||t<this.length&&r<=0))&&(this.length=e+(i?i.length:0)+(this.length-t),!0)}domAtPos(e){return 0==e?T.before(this.dom):T.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let i=new se(this.widget,t,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return D}sync(e){this.dom&&this.widget.updateDOM(this.dom,e)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):n.Text.empty}domBoundsAround(){return null}become(e){return e instanceof se&&e.widget.constructor==this.widget.constructor&&(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){return this.widget.coordsAt(this.dom,e,t)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:t,endSide:i}=this.deco;return t!=i&&(e<0?t<0:i>0)}}class le{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var ae,he;t.BlockType=void 0,(ae=t.BlockType||(t.BlockType={}))[ae.Text=0]="Text",ae[ae.WidgetBefore=1]="WidgetBefore",ae[ae.WidgetAfter=2]="WidgetAfter",ae[ae.WidgetRange=3]="WidgetRange";class ce extends n.RangeValue{constructor(e,t,i,n){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(e){return new ue(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new fe(e,t,t,i,e.widget||null,!1)}static replace(e){let t,i,n=!!e.block;if(e.isBlockGap)t=-5e8,i=4e8;else{let{start:o,end:r}=pe(e,n);t=(o?n?-3e8:-1:5e8)-1,i=1+(r?n?2e8:1:-6e8)}return new fe(e,t,i,n,e.widget||null,!0)}static line(e){return new de(e)}static set(e,t=!1){return n.RangeSet.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}ce.none=n.RangeSet.empty;class ue extends ce{constructor(e){let{start:t,end:i}=pe(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,i;return this==e||e instanceof ue&&this.tagName==e.tagName&&(this.class||(null===(t=this.attrs)||void 0===t?void 0:t.class))==(e.class||(null===(i=e.attrs)||void 0===i?void 0:i.class))&&ie(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}ue.prototype.point=!1;class de extends ce{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof de&&this.spec.class==e.spec.class&&ie(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}de.prototype.mapMode=n.MapMode.TrackBefore,de.prototype.point=!0;class fe extends ce{constructor(e,t,i,o,r,s){super(t,i,r,e),this.block=o,this.isReplace=s,this.mapMode=o?t<=0?n.MapMode.TrackBefore:n.MapMode.TrackAfter:n.MapMode.TrackDel}get type(){return this.startSide!=this.endSide?t.BlockType.WidgetRange:this.startSide<=0?t.BlockType.WidgetBefore:t.BlockType.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof fe&&(t=this.widget,i=e.widget,t==i||!!(t&&i&&t.compare(i)))&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide;var t,i}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}function pe(e,t=!1){let{inclusiveStart:i,inclusiveEnd:n}=e;return null==i&&(i=e.inclusive),null==n&&(n=e.inclusive),{start:null!=i?i:t,end:null!=n?n:t}}function me(e,t,i,n=0){let o=i.length-1;o>=0&&i[o]+n>=e?i[o]=Math.max(i[o],t):i.push(e,t)}fe.prototype.point=!0;class ge{constructor(e,t,i,n){this.doc=e,this.pos=t,this.end=i,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof se&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new re),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(ve(new X(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||e&&this.content.length&&this.content[this.content.length-1]instanceof se||this.getLine()}buildText(e,t,i){for(;e>0;){if(this.textOff==this.text.length){let{value:t,lineBreak:i,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw new Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}this.text=t,this.textOff=0}let n=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-i)),this.getLine().append(ve(new K(this.text.slice(this.textOff,this.textOff+n)),t),i),this.atCursorPos=!0,this.textOff+=n,e-=n,i=0}}span(e,t,i,n){this.buildText(t-e,i,n),this.pos=t,this.openStart<0&&(this.openStart=n)}point(e,t,i,n,o,r){if(this.disallowBlockEffectsFor[r]&&i instanceof fe){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let s=t-e;if(i instanceof fe)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new se(i.widget||we.block,s,i));else{let r=G.create(i.widget||we.inline,s,s?0:i.startSide),l=this.atCursorPos&&!r.isEditable&&o<=n.length&&(e<t||i.startSide>0),a=!r.isEditable&&(e<t||o>n.length||i.startSide<=0),h=this.getLine();2!=this.pendingBuffer||l||r.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),l&&(h.append(ve(new X(1),n),o),o=n.length+Math.max(0,o-n.length)),h.append(ve(r,n),o),this.atCursorPos=a,this.pendingBuffer=a?e<t||o>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);s&&(this.textOff+s<=this.text.length?this.textOff+=s:(this.skip+=s-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=o)}static build(e,t,i,o,r){let s=new ge(e,t,i,r);return s.openEnd=n.RangeSet.spans(o,t,i,s),s.openStart<0&&(s.openStart=s.openEnd),s.finish(s.openEnd),s}}function ve(e,t){for(let i of t)e=new $(i,[e],e.length);return e}class we extends le{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}we.inline=new we("span"),we.block=new we("div"),t.Direction=void 0,(he=t.Direction||(t.Direction={}))[he.LTR=0]="LTR",he[he.RTL=1]="RTL";const ye=t.Direction.LTR,be=t.Direction.RTL;function xe(e){let t=[];for(let i=0;i<e.length;i++)t.push(1<<+e[i]);return t}const ke=xe("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Se=xe("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Ce=Object.create(null),Ae=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),i=e.charCodeAt(1);Ce[t]=i,Ce[i]=-t}function Me(e){return e<=247?ke[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?Se[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}const Oe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Te{get dir(){return this.level%2?be:ye}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,i,n){let o=-1;for(let r=0;r<e.length;r++){let s=e[r];if(s.from<=t&&s.to>=t){if(s.level==i)return r;(o<0||(0!=n?n<0?s.from<t:s.to>t:e[o].level>s.level))&&(o=r)}}if(o<0)throw new RangeError("Index out of range");return o}}function De(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let n=e[i],o=t[i];if(n.from!=o.from||n.to!=o.to||n.direction!=o.direction||!De(n.inner,o.inner))return!1}return!0}const Ee=[];function Pe(e,t,i,n,o,r,s){let l=n%2?2:1;if(n%2==o%2)for(let a=t,h=0;a<i;){let t=!0,c=!1;if(h==r.length||a<r[h].from){let e=Ee[a];e!=l&&(t=!1,c=16==e)}let u=t||1!=l?null:[],d=t?n:n+1,f=a;e:for(;;)if(h<r.length&&f==r[h].from){if(c)break e;let p=r[h];if(!t)for(let e=p.to,t=h+1;;){if(e==i)break e;if(!(t<r.length&&r[t].from==e)){if(Ee[e]==l)break e;break}e=r[t++].to}if(h++,u)u.push(p);else{p.from>a&&s.push(new Te(a,p.from,d)),Re(e,p.direction==ye!=!(d%2)?n+1:n,o,p.inner,p.from,p.to,s),a=p.to}f=p.to}else{if(f==i||(t?Ee[f]!=l:Ee[f]==l))break;f++}u?Pe(e,a,f,n+1,o,u,s):a<f&&s.push(new Te(a,f,d)),a=f}else for(let a=i,h=r.length;a>t;){let i=!0,c=!1;if(!h||a>r[h-1].to){let e=Ee[a-1];e!=l&&(i=!1,c=16==e)}let u=i||1!=l?null:[],d=i?n:n+1,f=a;e:for(;;)if(h&&f==r[h-1].to){if(c)break e;let p=r[--h];if(!i)for(let e=p.from,i=h;;){if(e==t)break e;if(!i||r[i-1].to!=e){if(Ee[e-1]==l)break e;break}e=r[--i].from}if(u)u.push(p);else{p.to<a&&s.push(new Te(p.to,a,d)),Re(e,p.direction==ye!=!(d%2)?n+1:n,o,p.inner,p.from,p.to,s),a=p.from}f=p.from}else{if(f==t||(i?Ee[f-1]!=l:Ee[f-1]==l))break;f--}u?Pe(e,f,a,n+1,o,u,s):f<a&&s.push(new Te(f,a,d)),a=f}}function Re(e,t,i,n,o,r,s){let l=t%2?2:1;!function(e,t,i,n,o){for(let r=0;r<=n.length;r++){let s=r?n[r-1].to:t,l=r<n.length?n[r].from:i,a=r?256:o;for(let t=s,i=a,n=a;t<l;t++){let o=Me(e.charCodeAt(t));512==o?o=i:8==o&&4==n&&(o=16),Ee[t]=4==o?2:o,7&o&&(n=o),i=o}for(let e=s,t=a,n=a;e<l;e++){let o=Ee[e];if(128==o)e<l-1&&t==Ee[e+1]&&24&t?o=Ee[e]=t:Ee[e]=256;else if(64==o){let o=e+1;for(;o<l&&64==Ee[o];)o++;let r=e&&8==t||o<i&&8==Ee[o]?1==n?1:8:256;for(let t=e;t<o;t++)Ee[t]=r;e=o-1}else 8==o&&1==n&&(Ee[e]=1);t=o,7&o&&(n=o)}}}(e,o,r,n,l),function(e,t,i,n,o){let r=1==o?2:1;for(let s=0,l=0,a=0;s<=n.length;s++){let h=s?n[s-1].to:t,c=s<n.length?n[s].from:i;for(let t,i,n,s=h;s<c;s++)if(i=Ce[t=e.charCodeAt(s)])if(i<0){for(let e=l-3;e>=0;e-=3)if(Ae[e+1]==-i){let t=Ae[e+2],i=2&t?o:4&t?1&t?r:o:0;i&&(Ee[s]=Ee[Ae[e]]=i),l=e;break}}else{if(189==Ae.length)break;Ae[l++]=s,Ae[l++]=t,Ae[l++]=a}else if(2==(n=Ee[s])||1==n){let e=n==o;a=e?0:1;for(let t=l-3;t>=0;t-=3){let i=Ae[t+2];if(2&i)break;if(e)Ae[t+2]|=2;else{if(4&i)break;Ae[t+2]|=4}}}}}(e,o,r,n,l),function(e,t,i,n){for(let o=0,r=n;o<=i.length;o++){let s=o?i[o-1].to:e,l=o<i.length?i[o].from:t;for(let a=s;a<l;){let s=Ee[a];if(256==s){let s=a+1;for(;;)if(s==l){if(o==i.length)break;s=i[o++].to,l=o<i.length?i[o].from:t}else{if(256!=Ee[s])break;s++}let h=1==r,c=h==(1==(s<t?Ee[s]:n))?h?1:2:n;for(let t=s,n=o,r=n?i[n-1].to:e;t>a;)t==r&&(t=i[--n].from,r=n?i[n-1].to:e),Ee[--t]=c;a=s}else r=s,a++}}}(o,r,n,l),Pe(e,o,r,t,i,n,s)}function Le(e,t,i){if(!e)return[new Te(0,0,t==be?1:0)];if(t==ye&&!i.length&&!Oe.test(e))return Be(e.length);if(i.length)for(;e.length>Ee.length;)Ee[Ee.length]=256;let n=[],o=t==ye?0:1;return Re(e,o,o,i,0,e.length,n),n}function Be(e){return[new Te(0,e,0)]}let Ne="";function Ie(e,t,i,o,r){var s;let l=o.head-e.from,a=Te.find(t,l,null!==(s=o.bidiLevel)&&void 0!==s?s:-1,o.assoc),h=t[a],c=h.side(r,i);if(l==c){let e=a+=r?1:-1;if(e<0||e>=t.length)return null;h=t[a=e],l=h.side(!r,i),c=h.side(r,i)}let u=n.findClusterBreak(e.text,l,h.forward(r,i));(u<h.from||u>h.to)&&(u=c),Ne=e.text.slice(Math.min(l,u),Math.max(l,u));let d=a==(r?t.length-1:0)?null:t[a+(r?1:-1)];return d&&u==c&&d.level+(r?0:1)<h.level?n.EditorSelection.cursor(d.side(!r,i)+e.from,d.forward(r,i)?1:-1,d.level):n.EditorSelection.cursor(u+e.from,h.forward(r,i)?-1:1,h.level)}function _e(e,t,i){for(let n=t;n<i;n++){let t=Me(e.charCodeAt(n));if(1==t)return ye;if(2==t||4==t)return be}return ye}const Ve=n.Facet.define(),Fe=n.Facet.define(),He=n.Facet.define(),We=n.Facet.define(),qe=n.Facet.define(),ze=n.Facet.define(),Ue=n.Facet.define(),je=n.Facet.define({combine:e=>e.some((e=>e))}),Qe=n.Facet.define({combine:e=>e.some((e=>e))}),Ke=n.Facet.define();class $e{constructor(e,t="nearest",i="nearest",n=5,o=5,r=!1){this.range=e,this.y=t,this.x=i,this.yMargin=n,this.xMargin=o,this.isSnapshot=r}map(e){return e.empty?this:new $e(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new $e(n.EditorSelection.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Ge=n.StateEffect.define({map:(e,t)=>e.map(t)});function Xe(e,t,i){let n=e.facet(We);n.length?n[0](t):window.onerror?window.onerror(String(t),i,void 0,void 0,t):i?console.error(i+":",t):console.error(t)}const Ye=n.Facet.define({combine:e=>!e.length||e[0]});let Je=0;const Ze=n.Facet.define();class et{constructor(e,t,i,n,o){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=n,this.extension=o(this)}static define(e,t){const{eventHandlers:i,eventObservers:n,provide:o,decorations:r}=t||{};return new et(Je++,e,i,n,(e=>{let t=[Ze.of(e)];return r&&t.push(ot.of((t=>{let i=t.plugin(e);return i?r(i):ce.none}))),o&&t.push(o(e)),t}))}static fromClass(e,t){return et.define((t=>new e(t)),t)}}class tt{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(Xe(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){Xe(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null===(t=this.value)||void 0===t?void 0:t.destroy)try{this.value.destroy()}catch(t){Xe(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const it=n.Facet.define(),nt=n.Facet.define(),ot=n.Facet.define(),rt=n.Facet.define(),st=n.Facet.define(),lt=n.Facet.define();function at(e,t){let i=e.state.facet(lt);if(!i.length)return i;let o=i.map((t=>t instanceof Function?t(e):t)),r=[];return n.RangeSet.spans(o,t.from,t.to,{point(){},span(e,i,n,o){let s=e-t.from,l=i-t.from,a=r;for(let e=n.length-1;e>=0;e--,o--){let i,r=n[e].spec.bidiIsolate;if(null==r&&(r=_e(t.text,s,l)),o>0&&a.length&&(i=a[a.length-1]).to==s&&i.direction==r)i.to=l,a=i.inner;else{let e={from:s,to:l,direction:r,inner:[]};a.push(e),a=e.inner}}}}),r}const ht=n.Facet.define();function ct(e){let t=0,i=0,n=0,o=0;for(let r of e.state.facet(ht)){let s=r(e);s&&(null!=s.left&&(t=Math.max(t,s.left)),null!=s.right&&(i=Math.max(i,s.right)),null!=s.top&&(n=Math.max(n,s.top)),null!=s.bottom&&(o=Math.max(o,s.bottom)))}return{left:t,right:i,top:n,bottom:o}}const ut=n.Facet.define();class dt{constructor(e,t,i,n){this.fromA=e,this.toA=t,this.fromB=i,this.toB=n}join(e){return new dt(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let n=e[t-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(0==t.length)return e;let i=[];for(let n=0,o=0,r=0,s=0;;n++){let l=n==e.length?null:e[n],a=r-s,h=l?l.fromB:1e9;for(;o<t.length&&t[o]<h;){let e=t[o],n=t[o+1],r=Math.max(s,e),l=Math.min(h,n);if(r<=l&&new dt(r+a,l+a,r,l).addToSet(i),n>h)break;o+=2}if(!l)return i;new dt(l.fromA,l.toA,l.fromB,l.toB).addToSet(i),r=l.toA,s=l.toB}}}class ft{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=n.ChangeSet.empty(this.startState.doc.length);for(let e of i)this.changes=this.changes.compose(e.changes);let o=[];this.changes.iterChangedRanges(((e,t,i,n)=>o.push(new dt(e,t,i,n)))),this.changedRanges=o}static create(e,t,i){return new ft(e,t,i)}get viewportChanged(){return(4&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(10&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((e=>e.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}class pt extends E{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new re],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new dt(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every((({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo))?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0);let o=-1;this.view.inputState.composing>=0&&((null===(t=this.domChanged)||void 0===t?void 0:t.newSel)?o=this.domChanged.newSel.head:function(e,t){let i=!1;t&&e.iterChangedRanges(((e,n)=>{e<t.to&&n>t.from&&(i=!0)}));return i}(e.changes,this.hasComposition)||e.selectionSet||(o=e.state.selection.main.head));let r=o>-1?function(e,t,i){let n=gt(e,i);if(!n)return null;let{node:o,from:r,to:s}=n,l=o.nodeValue;if(/[\n\r]/.test(l))return null;if(e.state.doc.sliceString(n.from,n.to)!=l)return null;let a=t.invertedDesc,h=new dt(a.mapPos(r),a.mapPos(s),r,s),c=[];for(let t=o.parentNode;;t=t.parentNode){let i=E.get(t);if(i instanceof $)c.push({node:t,deco:i.mark});else{if(i instanceof re||"DIV"==t.nodeName&&t.parentNode==e.contentDOM)return{range:h,text:o,marks:c,line:t};if(t==e.contentDOM)return null;c.push({node:t,deco:new ue({inclusive:!0,attributes:oe(t),tagName:t.tagName.toLowerCase()})})}}}(this.view,e.changes,o):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:t,to:n}=this.hasComposition;i=new dt(t,n,e.changes.mapPos(t,-1),e.changes.mapPos(n,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(Q.ie||Q.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let s=function(e,t,i){let o=new vt;return n.RangeSet.compare(e,t,i,o),o.changes}(this.decorations,this.updateDeco(),e.changes);return i=dt.extendWithRanges(i,s),!!(7&this.flags||0!=i.length)&&(this.updateInner(i,e.startState.doc.length,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,i);let{observer:n}=this.view;n.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let e=Q.chrome||Q.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,e),this.flags&=-8,e&&(e.written||n.selectionRange.focusNode!=e.node)&&(this.forceSelection=!0),this.dom.style.height=""})),this.markedForComposition.forEach((e=>e.flags&=-9));let o=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.children)e instanceof se&&e.widget instanceof mt&&o.push(e.dom);n.updateGaps(o)}updateChildren(e,t,i){let n=i?i.range.addToSet(e.slice()):e,o=this.childCursor(t);for(let e=n.length-1;;e--){let t=e>=0?n[e]:null;if(!t)break;let r,s,l,a,{fromA:h,toA:c,fromB:u,toB:d}=t;if(i&&i.range.fromB<d&&i.range.toB>u){let e=ge.build(this.view.state.doc,u,i.range.fromB,this.decorations,this.dynamicDecorationMap),t=ge.build(this.view.state.doc,i.range.toB,d,this.decorations,this.dynamicDecorationMap);s=e.breakAtStart,l=e.openStart,a=t.openEnd;let n=this.compositionView(i);t.breakAtStart?n.breakAfter=1:t.content.length&&n.merge(n.length,n.length,t.content[0],!1,t.openStart,0)&&(n.breakAfter=t.content[0].breakAfter,t.content.shift()),e.content.length&&n.merge(0,0,e.content[e.content.length-1],!0,0,e.openEnd)&&e.content.pop(),r=e.content.concat(n).concat(t.content)}else({content:r,breakAtStart:s,openStart:l,openEnd:a}=ge.build(this.view.state.doc,u,d,this.decorations,this.dynamicDecorationMap));let{i:f,off:p}=o.findPos(c,1),{i:m,off:g}=o.findPos(h,-1);L(this,m,g,f,p,r,s,l,a)}i&&this.fixCompositionDOM(i)}compositionView(e){let t=new K(e.text.nodeValue);t.flags|=8;for(let{deco:i}of e.marks)t=new $(i,[t],t.length);let i=new re;return i.append(t,0),i}fixCompositionDOM(e){let t=(e,t)=>{t.flags|=8|(t.children.some((e=>7&e.flags))?1:0),this.markedForComposition.add(t);let i=E.get(e);i&&i!=t&&(i.dom=null),t.setDOM(e)},i=this.childPos(e.range.fromB,1),n=this.children[i.i];t(e.line,n);for(let o=e.marks.length-1;o>=-1;o--)i=n.childPos(i.off,1),n=n.children[i.i],t(o>=0?e.marks[o].node:e.text,n)}updateSelection(e=!1,t=!1){!e&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,o=!n&&a(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||t||o))return;let r=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,h=this.moveToLine(this.domAtPos(l.anchor)),u=l.empty?h:this.moveToLine(this.domAtPos(l.head));if(Q.gecko&&l.empty&&!this.hasComposition&&(1==(d=h).node.nodeType&&d.node.firstChild&&(0==d.offset||"false"==d.node.childNodes[d.offset-1].contentEditable)&&(d.offset==d.node.childNodes.length||"false"==d.node.childNodes[d.offset].contentEditable))){let e=document.createTextNode("");this.view.observer.ignore((()=>h.node.insertBefore(e,h.node.childNodes[h.offset]||null))),h=u=new T(e,0),r=!0}var d;let f=this.view.observer.selectionRange;!r&&f.focusNode&&(c(h.node,h.offset,f.anchorNode,f.anchorOffset)&&c(u.node,u.offset,f.focusNode,f.focusOffset)||this.suppressWidgetCursorChange(f,l))||(this.view.observer.ignore((()=>{Q.android&&Q.chrome&&this.dom.contains(f.focusNode)&&function(e,t){for(let i=e;i&&i!=t;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(f.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let e=s(this.view.root);if(e)if(l.empty){if(Q.gecko){let e=(t=h.node,n=h.offset,1!=t.nodeType?0:(n&&"false"==t.childNodes[n-1].contentEditable?1:0)|(n<t.childNodes.length&&"false"==t.childNodes[n].contentEditable?2:0));if(e&&3!=e){let t=(1==e?M:O)(h.node,h.offset);t&&(h=new T(t.node,t.offset))}}e.collapse(h.node,h.offset),null!=l.bidiLevel&&void 0!==e.caretBidiLevel&&(e.caretBidiLevel=l.bidiLevel)}else if(e.extend){e.collapse(h.node,h.offset);try{e.extend(u.node,u.offset)}catch(e){}}else{let t=document.createRange();l.anchor>l.head&&([h,u]=[u,h]),t.setEnd(u.node,u.offset),t.setStart(h.node,h.offset),e.removeAllRanges(),e.addRange(t)}else;var t,n;o&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())})),this.view.observer.setSelectionRange(h,u)),this.impreciseAnchor=h.precise?null:new T(f.anchorNode,f.anchorOffset),this.impreciseHead=u.precise?null:new T(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&c(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=s(e.root),{anchorNode:n,anchorOffset:o}=e.observer.selectionRange;if(!(i&&t.empty&&t.assoc&&i.modify))return;let r=re.find(this,t.head);if(!r)return;let l=r.posAtStart;if(t.head==l||t.head==l+r.length)return;let a=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!a||!h||a.bottom>h.top)return;let c=this.domAtPos(t.head+t.assoc);i.collapse(c.node,c.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&i.collapse(n,o)}moveToLine(e){let t,i=this.dom;if(e.node!=i)return e;for(let n=e.offset;!t&&n<i.childNodes.length;n++){let e=E.get(i.childNodes[n]);e instanceof re&&(t=e.domAtPos(0))}for(let n=e.offset-1;!t&&n>=0;n--){let e=E.get(i.childNodes[n]);e instanceof re&&(t=e.domAtPos(e.length))}return t?new T(t.node,t.offset,!0):e}nearest(e){for(let t=e;t;){let e=E.get(t);if(e&&e.rootView==this)return e;t=t.parentNode}return null}posFromDOM(e,t){let i=this.nearest(e);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(e,t)+i.posAtStart}domAtPos(e){let{i:t,off:i}=this.childCursor().findPos(e,-1);for(;t<this.children.length-1;){let e=this.children[t];if(i<e.length||e instanceof re)break;t++,i=0}return this.children[t].domAtPos(i)}coordsAt(e,t){let i=null,n=0;for(let o=this.length,r=this.children.length-1;r>=0;r--){let s=this.children[r],l=o-s.breakAfter,a=l-s.length;if(l<e)break;a<=e&&(a<e||s.covers(-1))&&(l>e||s.covers(1))&&(!i||s instanceof re&&!(i instanceof re&&t>=0))&&(i=s,n=a),o=a}return i?i.coordsAt(e-n,t):null}coordsForChar(e){let{i:t,off:i}=this.childPos(e,1),o=this.children[t];if(!(o instanceof re))return null;for(;o.children.length;){let{i:e,off:t}=o.childPos(i,1);for(;;e++){if(e==o.children.length)return null;if((o=o.children[e]).length)break}i=t}if(!(o instanceof K))return null;let r=n.findClusterBreak(o.text,i);if(r==i)return null;let s=k(o.dom,i,r).getClientRects();for(let e=0;e<s.length;e++){let t=s[e];if(e==s.length-1||t.top<t.bottom&&t.left<t.right)return t}return null}measureVisibleLineHeights(e){let i=[],{from:n,to:o}=e,r=this.view.contentDOM.clientWidth,s=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==t.Direction.LTR;for(let e=0,t=0;t<this.children.length;t++){let c=this.children[t],u=e+c.length;if(u>o)break;if(e>=n){let t=c.dom.getBoundingClientRect();if(i.push(t.height),s){let i=c.dom.lastChild,n=i?h(i):[];if(n.length){let i=n[n.length-1],o=a?i.right-t.left:t.right-i.left;o>l&&(l=o,this.minWidth=r,this.minWidthFrom=e,this.minWidthTo=u)}}}e=u+c.breakAfter}return i}textDirectionAt(e){let{i}=this.childPos(e,1);return"rtl"==getComputedStyle(this.children[i].dom).direction?t.Direction.RTL:t.Direction.LTR}measureTextSize(){for(let e of this.children)if(e instanceof re){let t=e.measureTextSize();if(t)return t}let e,t,i,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(n);let o=h(n.firstChild)[0];e=n.getBoundingClientRect().height,t=o?o.width/27:7,i=o?o.height:e,n.remove()})),{lineHeight:e,charWidth:t,textHeight:i}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new R(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,n=0;;n++){let o=n==t.viewports.length?null:t.viewports[n],r=o?o.from-1:this.length;if(r>i){let n=(t.lineBlockAt(r).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(ce.replace({widget:new mt(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,r))}if(!o)break;i=o.to+1}return ce.set(e)}updateDeco(){let e=0,t=this.view.state.facet(ot).map((t=>(this.dynamicDecorationMap[e++]="function"==typeof t)?t(this.view):t)),i=!1,o=this.view.state.facet(rt).map(((e,t)=>{let n="function"==typeof e;return n&&(i=!0),n?e(this.view):e}));for(o.length&&(this.dynamicDecorationMap[e++]=i,t.push(n.RangeSet.join(o))),this.decorations=[...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;return this.decorations}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);return this.view.scrollDOM.scrollTop=t.top-e.yMargin,void(this.view.scrollDOM.scrollLeft=e.xMargin)}for(let t of this.view.state.facet(Ke))try{if(t(this.view,e.range,e))return!0}catch(e){Xe(this.view.state,e,"scroll handler")}let i,{range:n}=e,o=this.coordsAt(n.head,n.empty?n.assoc:n.head>n.anchor?-1:1);if(!o)return;!n.empty&&(i=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(o={left:Math.min(o.left,i.left),top:Math.min(o.top,i.top),right:Math.max(o.right,i.right),bottom:Math.max(o.bottom,i.bottom)});let r=ct(this.view),s={left:o.left-r.left,top:o.top-r.top,right:o.right+r.right,bottom:o.bottom+r.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;!function(e,t,i,n,o,r,s,l){let a=e.ownerDocument,h=a.defaultView||window;for(let c=e,u=!1;c&&!u;)if(1==c.nodeType){let e,d=c==a.body,f=1,p=1;if(d)e=g(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(u=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let t=c.getBoundingClientRect();({scaleX:f,scaleY:p}=v(c,t)),e={left:t.left,right:t.left+c.clientWidth*f,top:t.top,bottom:t.top+c.clientHeight*p}}let m=0,w=0;if("nearest"==o)t.top<e.top?(w=-(e.top-t.top+s),i>0&&t.bottom>e.bottom+w&&(w=t.bottom-e.bottom+w+s)):t.bottom>e.bottom&&(w=t.bottom-e.bottom+s,i<0&&t.top-w<e.top&&(w=-(e.top+w-t.top+s)));else{let n=t.bottom-t.top,r=e.bottom-e.top;w=("center"==o&&n<=r?t.top+n/2-r/2:"start"==o||"center"==o&&i<0?t.top-s:t.bottom-r+s)-e.top}if("nearest"==n?t.left<e.left?(m=-(e.left-t.left+r),i>0&&t.right>e.right+m&&(m=t.right-e.right+m+r)):t.right>e.right&&(m=t.right-e.right+r,i<0&&t.left<e.left+m&&(m=-(e.left+m-t.left+r))):m=("center"==n?t.left+(t.right-t.left)/2-(e.right-e.left)/2:"start"==n==l?t.left-r:t.right-(e.right-e.left)+r)-e.left,m||w)if(d)h.scrollBy(m,w);else{let e=0,i=0;if(w){let e=c.scrollTop;c.scrollTop+=w/p,i=(c.scrollTop-e)*p}if(m){let t=c.scrollLeft;c.scrollLeft+=m/f,e=(c.scrollLeft-t)*f}t={left:t.left-e,top:t.top-i,right:t.right-e,bottom:t.bottom-i},e&&Math.abs(e-m)<1&&(n="nearest"),i&&Math.abs(i-w)<1&&(o="nearest")}if(d)break;c=c.assignedSlot||c.parentNode}else{if(11!=c.nodeType)break;c=c.host}}(this.view.scrollDOM,s,n.head<n.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==t.Direction.LTR)}}class mt extends le{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function gt(e,t){let i=e.observer.selectionRange;if(!i.focusNode)return null;let n=M(i.focusNode,i.focusOffset),o=O(i.focusNode,i.focusOffset),r=n||o;if(o&&n&&o.node!=n.node){let t=E.get(o.node);if(!t||t instanceof K&&t.text!=o.node.nodeValue)r=o;else if(e.docView.lastCompositionAfterCursor){let e=E.get(n.node);!e||e instanceof K&&e.text!=n.node.nodeValue||(r=o)}}if(e.docView.lastCompositionAfterCursor=r!=n,!r)return null;let s=t-r.offset;return{from:s,to:s+r.node.nodeValue.length,node:r.node}}let vt=class{constructor(){this.changes=[]}compareRange(e,t){me(e,t,this.changes)}comparePoint(e,t){me(e,t,this.changes)}};function wt(e,t){return t.left>e?t.left-e:Math.max(0,e-t.right)}function yt(e,t){return t.top>e?t.top-e:Math.max(0,e-t.bottom)}function bt(e,t){return e.top<t.bottom-1&&e.bottom>t.top+1}function xt(e,t){return t<e.top?{top:t,left:e.left,right:e.right,bottom:e.bottom}:e}function kt(e,t){return t>e.bottom?{top:e.top,left:e.left,right:e.right,bottom:t}:e}function St(e,t,i){let n,o,r,s,l,a,c,u,d=!1;for(let f=e.firstChild;f;f=f.nextSibling){let e=h(f);for(let h=0;h<e.length;h++){let p=e[h];o&&bt(o,p)&&(p=xt(kt(p,o.bottom),o.top));let m=wt(t,p),g=yt(i,p);if(0==m&&0==g)return 3==f.nodeType?Ct(f,t,i):St(f,t,i);if(!n||s>g||s==g&&r>m){n=f,o=p,r=m,s=g;let l=g?i<p.top?-1:1:m?t<p.left?-1:1:0;d=!l||(l>0?h<e.length-1:h>0)}0==m?i>p.bottom&&(!c||c.bottom<p.bottom)?(l=f,c=p):i<p.top&&(!u||u.top>p.top)&&(a=f,u=p):c&&bt(c,p)?c=kt(c,p.bottom):u&&bt(u,p)&&(u=xt(u,p.top))}}if(c&&c.bottom>=i?(n=l,o=c):u&&u.top<=i&&(n=a,o=u),!n)return{node:e,offset:0};let f=Math.max(o.left,Math.min(o.right,t));return 3==n.nodeType?Ct(n,f,i):d&&"false"!=n.contentEditable?St(n,f,i):{node:e,offset:Array.prototype.indexOf.call(e.childNodes,n)+(t>=(o.left+o.right)/2?1:0)}}function Ct(e,t,i){let n=e.nodeValue.length,o=-1,r=1e9,s=0;for(let l=0;l<n;l++){let n=k(e,l,l+1).getClientRects();for(let a=0;a<n.length;a++){let h=n[a];if(h.top==h.bottom)continue;s||(s=t-h.left);let c=(h.top>i?h.top-i:i-h.bottom)-1;if(h.left-1<=t&&h.right+1>=t&&c<r){let i=t>=(h.left+h.right)/2,n=i;if(Q.chrome||Q.gecko){k(e,l).getBoundingClientRect().left==h.right&&(n=!i)}if(c<=0)return{node:e,offset:l+(n?1:0)};o=l+(n?1:0),r=c}}}return{node:e,offset:o>-1?o:s>0?e.nodeValue.length:0}}function At(e,i,n,o=-1){var r,s;let l,a=e.contentDOM.getBoundingClientRect(),h=a.top+e.viewState.paddingTop,{docHeight:c}=e.viewState,{x:u,y:d}=i,f=d-h;if(f<0)return 0;if(f>c)return e.state.doc.length;for(let i=e.viewState.heightOracle.textHeight/2,r=!1;l=e.elementAtHeight(f),l.type!=t.BlockType.Text;)for(;f=o>0?l.bottom+i:l.top-i,!(f>=0&&f<=c);){if(r)return n?null:0;r=!0,o=-o}d=h+f;let p=l.from;if(p<e.viewport.from)return 0==e.viewport.from?0:n?null:Mt(e,a,l,u,d);if(p>e.viewport.to)return e.viewport.to==e.state.doc.length?e.state.doc.length:n?null:Mt(e,a,l,u,d);let m=e.dom.ownerDocument,g=e.root.elementFromPoint?e.root:m,v=g.elementFromPoint(u,d);v&&!e.contentDOM.contains(v)&&(v=null),v||(u=Math.max(a.left+1,Math.min(a.right-1,u)),v=g.elementFromPoint(u,d),v&&!e.contentDOM.contains(v)&&(v=null));let w,y=-1;if(v&&0!=(null===(r=e.docView.nearest(v))||void 0===r?void 0:r.isEditable))if(m.caretPositionFromPoint){let e=m.caretPositionFromPoint(u,d);e&&({offsetNode:w,offset:y}=e)}else if(m.caretRangeFromPoint){let t=m.caretRangeFromPoint(u,d);t&&(({startContainer:w,startOffset:y}=t),(!e.contentDOM.contains(w)||Q.safari&&function(e,t,i){let n;if(3!=e.nodeType||t!=(n=e.nodeValue.length))return!1;for(let t=e.nextSibling;t;t=t.nextSibling)if(1!=t.nodeType||"BR"!=t.nodeName)return!1;return k(e,n-1,n).getBoundingClientRect().left>i}(w,y,u)||Q.chrome&&function(e,t,i){if(0!=t)return!1;for(let t=e;;){let e=t.parentNode;if(!e||1!=e.nodeType||e.firstChild!=t)return!1;if(e.classList.contains("cm-line"))break;t=e}let n=1==e.nodeType?e.getBoundingClientRect():k(e,0,Math.max(e.nodeValue.length,1)).getBoundingClientRect();return i-n.left>5}(w,y,u))&&(w=void 0))}if(!w||!e.docView.dom.contains(w)){let t=re.find(e.docView,p);if(!t)return f>l.top+l.height/2?l.to:l.from;({node:w,offset:y}=St(t.dom,u,d))}let b=e.docView.nearest(w);if(!b)return null;if(b.isWidget&&1==(null===(s=b.dom)||void 0===s?void 0:s.nodeType)){let e=b.dom.getBoundingClientRect();return i.y<e.top||i.y<=e.bottom&&i.x<=(e.left+e.right)/2?b.posAtStart:b.posAtEnd}return b.localPosFromDOM(w,y)+b.posAtStart}function Mt(e,t,i,o,r){let s=Math.round((o-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&i.height>1.5*e.defaultLineHeight){let t=e.viewState.heightOracle.textHeight;s+=Math.floor((r-i.top-.5*(e.defaultLineHeight-t))/t)*e.viewState.heightOracle.lineLength}let l=e.state.sliceDoc(i.from,i.to);return i.from+n.findColumn(l,s,e.state.tabSize)}function Ot(e,i){let n=e.lineBlockAt(i);if(Array.isArray(n.type))for(let e of n.type)if(e.to>i||e.to==i&&(e.to==n.to||e.type==t.BlockType.Text))return e;return n}function Tt(e,t,i,n){let o=e.state.doc.lineAt(t.head),r=e.bidiSpans(o),s=e.textDirectionAt(o.from);for(let l=t,a=null;;){let t=Ie(o,r,s,l,i),h=Ne;if(!t){if(o.number==(i?e.state.doc.lines:1))return l;h="\n",o=e.state.doc.line(o.number+(i?1:-1)),r=e.bidiSpans(o),t=e.visualLineSide(o,!i)}if(a){if(!a(h))return l}else{if(!n)return t;a=n(h)}l=t}}function Dt(e,t,i){for(;;){let n=0;for(let o of e)o.between(t-1,t+1,((e,o,r)=>{if(t>e&&t<o){let r=n||i||(t-e<o-t?-1:1);t=r<0?e:o,n=r}}));if(!n)return t}}function Et(e,t,i){let o=Dt(e.state.facet(st).map((t=>t(e))),i.from,t.head>i.from?-1:1);return o==i.from?i:n.EditorSelection.cursor(o,o<i.from?1:-1)}class Pt{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=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.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Q.safari&&e.contentDOM.addEventListener("input",(()=>null)),Q.gecko&&function(e){oi.has(e)||(oi.add(e),e.addEventListener("copy",(()=>{})),e.addEventListener("cut",(()=>{})))}(e.contentDOM.ownerDocument)}handleEvent(e){(function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let i,n=t.target;n!=e.contentDOM;n=n.parentNode)if(!n||11==n.nodeType||(i=E.get(n))&&i.ignoreEvent(t))return!1;return!0})(this.view,e)&&!this.ignoreDuringComposition(e)&&("keydown"==e.type&&this.keydown(e)||this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let e of i.observers)e(this.view,t);for(let e of i.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Lt(e),i=this.handlers,n=this.view.contentDOM;for(let e in t)if("scroll"!=e){let o=!t[e].handlers.length,r=i[e];r&&o!=!r.handlers.length&&(n.removeEventListener(e,this.handleEvent),r=null),r||n.addEventListener(e,this.handleEvent,{passive:o})}for(let e in i)"scroll"==e||t[e]||n.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&Date.now()<this.lastEscPress+2e3)return!0;if(27!=e.keyCode&&It.indexOf(e.keyCode)<0&&(this.view.inputState.lastEscPress=0),Q.android&&Q.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return!Q.ios||e.synthetic||e.altKey||e.metaKey||!((t=Bt.find((t=>t.keyCode==e.keyCode)))&&!e.ctrlKey||Nt.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(229!=e.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=t||e,setTimeout((()=>this.flushIOSKey()),250),!0)}flushIOSKey(e){let t=this.pendingIOSKey;return!!t&&(!("Enter"==t.key&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString()))&&(this.pendingIOSKey=void 0,S(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0)))}ignoreDuringComposition(e){return!!/^key/.test(e.type)&&(this.composing>0||!!(Q.safari&&!Q.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}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 Rt(e,t){return(i,n)=>{try{return t.call(e,n,i)}catch(e){Xe(i.state,e)}}}function Lt(e){let t=Object.create(null);function i(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec;if(e&&e.domEventHandlers)for(let n in e.domEventHandlers){let o=e.domEventHandlers[n];o&&i(n).handlers.push(Rt(t.value,o))}if(e&&e.domEventObservers)for(let n in e.domEventObservers){let o=e.domEventObservers[n];o&&i(n).observers.push(Rt(t.value,o))}}for(let e in Ft)i(e).handlers.push(Ft[e]);for(let e in Ht)i(e).observers.push(Ht[e]);return t}const Bt=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Nt="dthko",It=[16,17,18,20,91,92,224,225];function _t(e){return.7*Math.max(0,e)+8}class Vt{constructor(e,t,i,o){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=o,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParent=function(e){let t=e.ownerDocument;for(let i=e.parentNode;i&&i!=t.body;)if(1==i.nodeType){if(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)return i;i=i.assignedSlot||i.parentNode}else{if(11!=i.nodeType)break;i=i.host}return null}(e.contentDOM),this.atoms=e.state.facet(st).map((t=>t(e)));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(n.EditorState.allowMultipleSelections)&&function(e,t){let i=e.state.facet(Ve);return i.length?i[0](t):Q.mac?t.metaKey:t.ctrlKey}(e,t),this.dragging=!(!function(e,t){let{main:i}=e.state.selection;if(i.empty)return!1;let n=s(e.root);if(!n||0==n.rangeCount)return!0;let o=n.getRangeAt(0).getClientRects();for(let e=0;e<o.length;e++){let i=o[e];if(i.left<=t.clientX&&i.right>=t.clientX&&i.top<=t.clientY&&i.bottom>=t.clientY)return!0}return!1}(e,t)||1!=Jt(t))&&null}start(e){!1===this.dragging&&this.select(e)}move(e){var t,i,n;if(0==e.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(i=this.startEvent,n=e,Math.max(Math.abs(i.clientX-n.clientX),Math.abs(i.clientY-n.clientY))<10))return;this.select(this.lastEvent=e);let o=0,r=0,s=(null===(t=this.scrollParent)||void 0===t?void 0:t.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},l=ct(this.view);e.clientX-l.left<=s.left+6?o=-_t(s.left-e.clientX):e.clientX+l.right>=s.right-6&&(o=_t(e.clientX-s.right)),e.clientY-l.top<=s.top+6?r=-_t(s.top-e.clientY):e.clientY+l.bottom>=s.bottom-6&&(r=_t(e.clientY-s.bottom)),this.setScrollSpeed(o,r)}up(e){null==this.dragging&&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(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let i=0;i<e.ranges.length;i++){let o=e.ranges[i],r=null;if(o.empty){let e=Dt(this.atoms,o.from,0);e!=o.from&&(r=n.EditorSelection.cursor(e,-1))}else{let e=Dt(this.atoms,o.from,-1),t=Dt(this.atoms,o.to,1);e==o.from&&t==o.to||(r=n.EditorSelection.range(o.from==o.anchor?e:t,o.from==o.head?e:t))}r&&(t||(t=e.ranges.slice()),t[i]=r)}return t?n.EditorSelection.create(t,e.mainIndex):e}select(e){let{view:t}=this,i=this.skipAtoms(this.style.get(e,this.extend,this.multiple));!this.mustSelect&&i.eq(t.state.selection,!1===this.dragging)||this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){this.style.update(e)&&setTimeout((()=>this.select(this.lastEvent)),20)}}const Ft=Object.create(null),Ht=Object.create(null),Wt=Q.ie&&Q.ie_version<15||Q.ios&&Q.webkit_version<604;function qt(e,t){let i,{state:o}=e,r=1,s=o.toText(t),l=s.lines==o.selection.ranges.length;if(null!=ei&&o.selection.ranges.every((e=>e.empty))&&ei==s.toString()){let e=-1;i=o.changeByRange((i=>{let a=o.doc.lineAt(i.from);if(a.from==e)return{range:i};e=a.from;let h=o.toText((l?s.line(r++).text:t)+o.lineBreak);return{changes:{from:a.from,insert:h},range:n.EditorSelection.cursor(i.from+h.length)}}))}else i=l?o.changeByRange((e=>{let t=s.line(r++);return{changes:{from:e.from,to:e.to,insert:t.text},range:n.EditorSelection.cursor(e.from+t.length)}})):o.replaceSelection(s);e.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function zt(e,t,i,o){if(1==o)return n.EditorSelection.cursor(t,i);if(2==o)return function(e,t,i=1){let o=e.charCategorizer(t),r=e.doc.lineAt(t),s=t-r.from;if(0==r.length)return n.EditorSelection.cursor(t);0==s?i=1:s==r.length&&(i=-1);let l=s,a=s;i<0?l=n.findClusterBreak(r.text,s,!1):a=n.findClusterBreak(r.text,s);let h=o(r.text.slice(l,a));for(;l>0;){let e=n.findClusterBreak(r.text,l,!1);if(o(r.text.slice(e,l))!=h)break;l=e}for(;a<r.length;){let e=n.findClusterBreak(r.text,a);if(o(r.text.slice(a,e))!=h)break;a=e}return n.EditorSelection.range(l+r.from,a+r.from)}(e.state,t,i);{let i=re.find(e.docView,t),o=e.state.doc.lineAt(i?i.posAtEnd:t),r=i?i.posAtStart:o.from,s=i?i.posAtEnd:o.to;return s<e.state.doc.length&&s==o.to&&s++,n.EditorSelection.range(r,s)}}Ht.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},Ft.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&(e.inputState.lastEscPress=Date.now()),!1),Ht.touchstart=(e,t)=>{e.inputState.lastTouchTime=Date.now(),e.inputState.setSelectionOrigin("select.pointer")},Ht.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},Ft.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let n of e.state.facet(He))if(i=n(e,t),i)break;if(i||0!=t.button||(i=function(e,t){let i=Kt(e,t),o=Jt(t),r=e.state.selection;return{update(e){e.docChanged&&(i.pos=e.changes.mapPos(i.pos),r=r.map(e.changes))},get(t,s,l){let a,h=Kt(e,t),c=zt(e,h.pos,h.bias,o);if(i.pos!=h.pos&&!s){let t=zt(e,i.pos,i.bias,o),r=Math.min(t.from,c.from),s=Math.max(t.to,c.to);c=r<c.from?n.EditorSelection.range(r,s):n.EditorSelection.range(s,r)}return s?r.replaceRange(r.main.extend(c.from,c.to)):l&&1==o&&r.ranges.length>1&&(a=function(e,t){for(let i=0;i<e.ranges.length;i++){let{from:o,to:r}=e.ranges[i];if(o<=t&&r>=t)return n.EditorSelection.create(e.ranges.slice(0,i).concat(e.ranges.slice(i+1)),e.mainIndex==i?0:e.mainIndex-(e.mainIndex>i?1:0))}return null}(r,h.pos))?a:l?r.addRange(c):n.EditorSelection.create([c])}}}(e,t)),i){let n=!e.hasFocus;e.inputState.startMouseSelection(new Vt(e,t,i,n)),n&&e.observer.ignore((()=>x(e.contentDOM)));let o=e.inputState.mouseSelection;if(o)return o.start(t),!1===o.dragging}return!1};let Ut=(e,t)=>e>=t.top&&e<=t.bottom,jt=(e,t,i)=>Ut(t,i)&&e>=i.left&&e<=i.right;function Qt(e,t,i,n){let o=re.find(e.docView,t);if(!o)return 1;let r=t-o.posAtStart;if(0==r)return 1;if(r==o.length)return-1;let s=o.coordsAt(r,-1);if(s&&jt(i,n,s))return-1;let l=o.coordsAt(r,1);return l&&jt(i,n,l)?1:s&&Ut(n,s)?-1:1}function Kt(e,t){let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1);return{pos:i,bias:Qt(e,i,t.clientX,t.clientY)}}const $t=Q.ie&&Q.ie_version<=11;let Gt=null,Xt=0,Yt=0;function Jt(e){if(!$t)return e.detail;let t=Gt,i=Yt;return Gt=e,Yt=Date.now(),Xt=!t||i>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(Xt+1)%3:1}function Zt(e,t,i,n){if(!i)return;let o=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:r}=e.inputState,s=n&&r&&function(e,t){let i=e.state.facet(Fe);return i.length?i[0](t):Q.mac?!t.altKey:!t.ctrlKey}(e,t)?{from:r.from,to:r.to}:null,l={from:o,insert:i},a=e.state.changes(s?[s,l]:l);e.focus(),e.dispatch({changes:a,selection:{anchor:a.mapPos(o,-1),head:a.mapPos(o,1)},userEvent:s?"move.drop":"input.drop"}),e.inputState.draggedContent=null}Ft.dragstart=(e,t)=>{let{selection:{main:i}}=e.state;if(t.target.draggable){let o=e.docView.nearest(t.target);if(o&&o.isWidget){let e=o.posAtStart,t=e+o.length;(e>=i.to||t<=i.from)&&(i=n.EditorSelection.range(e,t))}}let{inputState:o}=e;return o.mouseSelection&&(o.mouseSelection.dragging=!0),o.draggedContent=i,t.dataTransfer&&(t.dataTransfer.setData("Text",e.state.sliceDoc(i.from,i.to)),t.dataTransfer.effectAllowed="copyMove"),!1},Ft.dragend=e=>(e.inputState.draggedContent=null,!1),Ft.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let i=t.dataTransfer.files;if(i&&i.length){let n=Array(i.length),o=0,r=()=>{++o==i.length&&Zt(e,t,n.filter((e=>null!=e)).join(e.state.lineBreak),!1)};for(let e=0;e<i.length;e++){let t=new FileReader;t.onerror=r,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(n[e]=t.result),r()},t.readAsText(i[e])}return!0}{let i=t.dataTransfer.getData("Text");if(i)return Zt(e,t,i,!0),!0}return!1},Ft.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let i=Wt?null:t.clipboardData;return i?(qt(e,i.getData("text/plain")||i.getData("text/uri-list")),!0):(function(e){let t=e.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout((()=>{e.focus(),i.remove(),qt(e,i.value)}),50)}(e),!1)};let ei=null;Ft.copy=Ft.cut=(e,t)=>{let{text:i,ranges:n,linewise:o}=function(e){let t=[],i=[],n=!1;for(let n of e.selection.ranges)n.empty||(t.push(e.sliceDoc(n.from,n.to)),i.push(n));if(!t.length){let o=-1;for(let{from:n}of e.selection.ranges){let r=e.doc.lineAt(n);r.number>o&&(t.push(r.text),i.push({from:r.from,to:Math.min(e.doc.length,r.to+1)})),o=r.number}n=!0}return{text:t.join(e.lineBreak),ranges:i,linewise:n}}(e.state);if(!i&&!o)return!1;ei=o?i:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let r=Wt?null:t.clipboardData;return r?(r.clearData(),r.setData("text/plain",i),!0):(function(e,t){let i=e.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=t,n.focus(),n.selectionEnd=t.length,n.selectionStart=0,setTimeout((()=>{n.remove(),e.focus()}),50)}(e,i),!1)};const ti=n.Annotation.define();function ii(e,t){let i=[];for(let n of e.facet(Ue)){let o=n(e,t);o&&i.push(o)}return i?e.update({effects:i,annotations:ti.of(!0)}):null}function ni(e){setTimeout((()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let i=ii(e.state,t);i?e.dispatch(i):e.update([])}}),10)}Ht.focus=e=>{e.inputState.lastFocusTime=Date.now(),e.scrollDOM.scrollTop||!e.inputState.lastScrollTop&&!e.inputState.lastScrollLeft||(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),ni(e)},Ht.blur=e=>{e.observer.clearSelectionRange(),ni(e)},Ht.compositionstart=Ht.compositionupdate=e=>{null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0)},Ht.compositionend=e=>{e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,Q.chrome&&Q.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then((()=>e.observer.flush())):setTimeout((()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])}),50)},Ht.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},Ft.beforeinput=(e,t)=>{var i;let n;if(Q.chrome&&Q.android&&(n=Bt.find((e=>e.inputType==t.inputType)))&&(e.observer.delayAndroidKey(n.key,n.keyCode),"Backspace"==n.key||"Delete"==n.key)){let t=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout((()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())}),100)}return Q.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),Q.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout((()=>Ht.compositionend(e,t)),20),!1};const oi=new Set;const ri=["pre-wrap","normal","pre-line","break-spaces"];class si{constructor(e){this.lineWrapping=e,this.doc=n.Text.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}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){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return ri.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let n=e[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(t=!0,this.heightSamples[Math.floor(10*n)]=!0)}return t}refresh(e,t,i,n,o,r){let s=ri.indexOf(e)>-1,l=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=s;if(this.lineWrapping=s,this.lineHeight=t,this.charWidth=i,this.textHeight=n,this.lineLength=o,l){this.heightSamples={};for(let e=0;e<r.length;e++){let t=r[e];t<0?e++:this.heightSamples[Math.floor(10*t)]=!0}}return l}}class li{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class ai{constructor(e,t,i,n,o){this.from=e,this.length=t,this.top=i,this.height=n,this._content=o}get type(){return"number"==typeof this._content?t.BlockType.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 fe?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new ai(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var hi;!function(e){e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight"}(hi||(hi={}));const ci=.001;class ui{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(e){this.flags=(e?2:0)|-3&this.flags}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>ci&&(e.heightChanged=!0),this.height=t)}replace(e,t,i){return ui.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,n){let o=this,r=i.doc;for(let s=n.length-1;s>=0;s--){let{fromA:l,toA:a,fromB:h,toB:c}=n[s],u=o.lineAt(l,hi.ByPosNoHeight,i.setDoc(t),0,0),d=u.to>=a?u:o.lineAt(a,hi.ByPosNoHeight,i,0,0);for(c+=d.to-a,a=d.to;s>0&&u.from<=n[s-1].toA;)l=n[s-1].fromA,h=n[s-1].fromB,s--,l<u.from&&(u=o.lineAt(l,hi.ByPosNoHeight,i,0,0));h+=u.from-l,l=u.from;let f=vi.build(i.setDoc(r),e,h,c);o=o.replace(l,a,f)}return o.updateHeight(i,0)}static empty(){return new fi(0,0)}static of(e){if(1==e.length)return e[0];let t=0,i=e.length,n=0,o=0;for(;;)if(t==i)if(n>2*o){let o=e[t-1];o.break?e.splice(--t,1,o.left,null,o.right):e.splice(--t,1,o.left,o.right),i+=1+o.break,n-=o.size}else{if(!(o>2*n))break;{let t=e[i];t.break?e.splice(i,1,t.left,null,t.right):e.splice(i,1,t.left,t.right),i+=2+t.break,o-=t.size}}else if(n<o){let i=e[t++];i&&(n+=i.size)}else{let t=e[--i];t&&(o+=t.size)}let r=0;return null==e[t-1]?(r=1,t--):null==e[t]&&(r=1,i++),new mi(ui.of(e.slice(0,t)),r,ui.of(e.slice(i)))}}ui.prototype.size=1;class di extends ui{constructor(e,t,i){super(e,t),this.deco=i}blockAt(e,t,i,n){return new ai(n,this.length,i,this.height,this.deco||0)}lineAt(e,t,i,n,o){return this.blockAt(0,i,n,o)}forEachLine(e,t,i,n,o,r){e<=o+this.length&&t>=o&&r(this.blockAt(0,i,n,o))}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more&&this.setHeight(e,n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class fi extends di{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,i,n){return new ai(n,this.length,i,this.height,this.breaks)}replace(e,t,i){let n=i[0];return 1==i.length&&(n instanceof fi||n instanceof pi&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof pi?n=new fi(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):ui.of(i)}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more?this.setHeight(e,n.heights[n.index++]):(i||this.outdated)&&this.setHeight(e,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:""})`}}class pi extends ui{constructor(e){super(e,0)}heightMetrics(e,t){let i,n=e.doc.lineAt(t).number,o=e.doc.lineAt(t+this.length).number,r=o-n+1,s=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*r);i=t/r,this.length>r+1&&(s=(this.height-t)/(this.length-r-1))}else i=this.height/r;return{firstLine:n,lastLine:o,perLine:i,perChar:s}}blockAt(e,t,i,n){let{firstLine:o,lastLine:r,perLine:s,perChar:l}=this.heightMetrics(t,n);if(t.lineWrapping){let o=n+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),r=t.doc.lineAt(o),a=s+r.length*l,h=Math.max(i,e-a/2);return new ai(r.from,r.length,h,a,0)}{let n=Math.max(0,Math.min(r-o,Math.floor((e-i)/s))),{from:l,length:a}=t.doc.line(o+n);return new ai(l,a,i+s*n,s,0)}}lineAt(e,t,i,n,o){if(t==hi.ByHeight)return this.blockAt(e,i,n,o);if(t==hi.ByPosNoHeight){let{from:t,to:n}=i.doc.lineAt(e);return new ai(t,n-t,0,0,0)}let{firstLine:r,perLine:s,perChar:l}=this.heightMetrics(i,o),a=i.doc.lineAt(e),h=s+a.length*l,c=a.number-r,u=n+s*c+l*(a.from-o-c);return new ai(a.from,a.length,Math.max(n,Math.min(u,n+this.height-h)),h,0)}forEachLine(e,t,i,n,o,r){e=Math.max(e,o),t=Math.min(t,o+this.length);let{firstLine:s,perLine:l,perChar:a}=this.heightMetrics(i,o);for(let h=e,c=n;h<=t;){let t=i.doc.lineAt(h);if(h==e){let i=t.number-s;c+=l*i+a*(e-o-i)}let n=l+a*t.length;r(new ai(t.from,t.length,c,n,0)),c+=n,h=t.to+1}}replace(e,t,i){let n=this.length-t;if(n>0){let e=i[i.length-1];e instanceof pi?i[i.length-1]=new pi(e.length+n):i.push(null,new pi(n-1))}if(e>0){let t=i[0];t instanceof pi?i[0]=new pi(e+t.length):i.unshift(new pi(e-1),null)}return ui.of(i)}decomposeLeft(e,t){t.push(new pi(e-1),null)}decomposeRight(e,t){t.push(null,new pi(this.length-e-1))}updateHeight(e,t=0,i=!1,n){let o=t+this.length;if(n&&n.from<=t+this.length&&n.more){let i=[],r=Math.max(t,n.from),s=-1;for(n.from>t&&i.push(new pi(n.from-t-1).updateHeight(e,t));r<=o&&n.more;){let t=e.doc.lineAt(r).length;i.length&&i.push(null);let o=n.heights[n.index++];-1==s?s=o:Math.abs(o-s)>=ci&&(s=-2);let l=new fi(t,o);l.outdated=!1,i.push(l),r+=t+1}r<=o&&i.push(null,new pi(o-r).updateHeight(e,r));let l=ui.of(i);return(s<0||Math.abs(l.height-this.height)>=ci||Math.abs(s-this.heightMetrics(e,t).perLine)>=ci)&&(e.heightChanged=!0),l}return(i||this.outdated)&&(this.setHeight(e,e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class mi extends ui{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 1&this.flags}blockAt(e,t,i,n){let o=i+this.left.height;return e<o?this.left.blockAt(e,t,i,n):this.right.blockAt(e,t,o,n+this.left.length+this.break)}lineAt(e,t,i,n,o){let r=n+this.left.height,s=o+this.left.length+this.break,l=t==hi.ByHeight?e<r:e<s,a=l?this.left.lineAt(e,t,i,n,o):this.right.lineAt(e,t,i,r,s);if(this.break||(l?a.to<s:a.from>s))return a;let h=t==hi.ByPosNoHeight?hi.ByPosNoHeight:hi.ByPos;return l?a.join(this.right.lineAt(s,h,i,r,s)):this.left.lineAt(s,h,i,n,o).join(a)}forEachLine(e,t,i,n,o,r){let s=n+this.left.height,l=o+this.left.length+this.break;if(this.break)e<l&&this.left.forEachLine(e,t,i,n,o,r),t>=l&&this.right.forEachLine(e,t,i,s,l,r);else{let a=this.lineAt(l,hi.ByPos,i,n,o);e<a.from&&this.left.forEachLine(e,a.from-1,i,n,o,r),a.to>=e&&a.from<=t&&r(a),t>a.to&&this.right.forEachLine(a.to+1,t,i,s,l,r)}}replace(e,t,i){let n=this.left.length+this.break;if(t<n)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-n,t-n,i));let o=[];e>0&&this.decomposeLeft(e,o);let r=o.length;for(let e of i)o.push(e);if(e>0&&gi(o,r-1),t<this.length){let e=o.length;this.decomposeRight(t,o),gi(o,e)}return ui.of(o)}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,n=i+this.break;if(e>=n)return this.right.decomposeRight(e-n,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<n&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?ui.of(this.break?[e,null,t]:[e,t]):(this.left=e,this.right=t,this.height=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,n){let{left:o,right:r}=this,s=t+o.length+this.break,l=null;return n&&n.from<=t+o.length&&n.more?l=o=o.updateHeight(e,t,i,n):o.updateHeight(e,t,i),n&&n.from<=s+r.length&&n.more?l=r=r.updateHeight(e,s,i,n):r.updateHeight(e,s,i),l?this.balanced(o,r):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function gi(e,t){let i,n;null==e[t]&&(i=e[t-1])instanceof pi&&(n=e[t+1])instanceof pi&&e.splice(t-1,3,new pi(i.length+1+n.length))}class vi{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 e=Math.min(t,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof fi?i.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new fi(e-this.pos,-1)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e<t||i.heightRelevant){let n=i.widget?i.widget.estimatedHeight:0,o=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let r=t-e;i.block?this.addBlock(new di(r,n,i)):(r||o||n>=5)&&this.addLineDeco(n,o,r)}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||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new fi(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let i=new pi(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 fi)return e;let t=new fi(0,-1);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 n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,e),n.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof fi||this.isCovered?(this.writtenTo<this.pos||null==t)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new fi(0,-1));let i=e;for(let e of this.nodes)e instanceof fi&&e.updateHeight(this.oracle,i),i+=e?e.length:1;return this.nodes}static build(e,t,i,o){let r=new vi(i,e);return n.RangeSet.spans(t,i,o,r,0),r.finish(i)}}class wi{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,n){(e<t||i&&i.heightRelevant||n&&n.heightRelevant)&&me(e,t,this.changes,5)}}function yi(e,t){let i=e.getBoundingClientRect(),n=e.ownerDocument,o=n.defaultView||window,r=Math.max(0,i.left),s=Math.min(o.innerWidth,i.right),l=Math.max(0,i.top),a=Math.min(o.innerHeight,i.bottom);for(let t=e.parentNode;t&&t!=n.body;)if(1==t.nodeType){let i=t,n=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=n.overflow){let n=i.getBoundingClientRect();r=Math.max(r,n.left),s=Math.min(s,n.right),l=Math.max(l,n.top),a=t==e.parentNode?n.bottom:Math.min(a,n.bottom)}t="absolute"==n.position||"fixed"==n.position?i.offsetParent:i.parentNode}else{if(11!=t.nodeType)break;t=t.host}return{left:r-i.left,right:Math.max(r,s)-i.left,top:l-(i.top+t),bottom:Math.max(l,a)-(i.top+t)}}function bi(e,t){let i=e.getBoundingClientRect();return{left:0,right:i.right-i.left,top:t,bottom:i.bottom-(i.top+t)}}class xi{constructor(e,t,i){this.from=e,this.to=t,this.size=i}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let n=e[i],o=t[i];if(n.from!=o.from||n.to!=o.to||n.size!=o.size)return!1}return!0}draw(e,t){return ce.replace({widget:new ki(this.size*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class ki extends le{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}}class Si{constructor(e){this.state=e,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.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Ti,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=t.Direction.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let i=e.facet(nt).some((e=>"function"!=typeof e&&"cm-lineWrapping"==e.class));this.heightOracle=new si(i),this.stateDeco=e.facet(ot).filter((e=>"function"!=typeof e)),this.heightMap=ui.empty().applyChanges(this.stateDeco,n.Text.empty,this.heightOracle.setDoc(e.doc),[new dt(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ce.set(this.lineGaps.map((e=>e.draw(this,!1)))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let n=i?t.head:t.anchor;if(!e.some((({from:e,to:t})=>n>=e&&n<=t))){let{from:t,to:i}=this.lineBlockAt(n);e.push(new Ci(t,i))}}this.viewports=e.sort(((e,t)=>e.from-t.from)),this.scaler=this.heightMap.height<=7e6?Ti:new Di(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(e=>{this.viewportLines.push(1==this.scaler.scale?e:Ei(e,this.scaler))}))}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=this.state.facet(ot).filter((e=>"function"!=typeof e));let o=e.changedRanges,r=dt.extendWithRanges(o,function(e,t,i){let o=new wi;return n.RangeSet.compare(e,t,i,o,0),o.changes}(i,this.stateDeco,e?e.changes:n.ChangeSet.empty(this.state.doc.length))),s=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),this.heightMap.height!=s&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let a=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let h=!e.changes.empty||2&e.flags||a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,this.updateForViewport(),h&&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(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Qe)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let i=e.contentDOM,o=window.getComputedStyle(i),r=this.heightOracle,s=o.whiteSpace;this.defaultTextDirection="rtl"==o.direction?t.Direction.RTL:t.Direction.LTR;let l=this.heightOracle.mustRefreshForWrapping(s),a=i.getBoundingClientRect(),h=l||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:e,scaleY:t}=v(i,a);(e>.005&&Math.abs(this.scaleX-e)>.005||t>.005&&Math.abs(this.scaleY-t)>.005)&&(this.scaleX=e,this.scaleY=t,c|=8,l=h=!0)}let d=(parseInt(o.paddingTop)||0)*this.scaleY,f=(parseInt(o.paddingBottom)||0)*this.scaleY;this.paddingTop==d&&this.paddingBottom==f||(this.paddingTop=d,this.paddingBottom=f,c|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(h=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=8);let p=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=p&&(this.scrollAnchorHeight=-1,this.scrollTop=p),this.scrolledToBottom=A(e.scrollDOM);let m=(this.printing?bi:yi)(i,this.paddingTop),g=m.top-this.pixelViewport.top,w=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(h=!0)),!this.inView&&!this.scrollTarget)return 0;let b=a.width;if(this.contentDOMWidth==b&&this.editorHeight==e.scrollDOM.clientHeight||(this.contentDOMWidth=a.width,this.editorHeight=e.scrollDOM.clientHeight,c|=8),h){let t=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(t)&&(l=!0),l||r.lineWrapping&&Math.abs(b-this.contentDOMWidth)>r.charWidth){let{lineHeight:i,charWidth:n,textHeight:o}=e.docView.measureTextSize();l=i>0&&r.refresh(s,i,n,o,b/n,t),l&&(e.docView.minWidth=0,c|=8)}g>0&&w>0?u=Math.max(g,w):g<0&&w<0&&(u=Math.min(g,w)),r.heightChanged=!1;for(let i of this.viewports){let o=i.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(i);this.heightMap=(l?ui.empty().applyChanges(this.stateDeco,n.Text.empty,this.heightOracle,[new dt(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,l,new li(i.from,o))}r.heightChanged&&(c|=2)}let x=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return x&&(this.viewport=this.getViewport(u,this.scrollTarget)),this.updateForViewport(),(2&c||x)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(l?[]: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)),n=this.heightMap,o=this.heightOracle,{visibleTop:r,visibleBottom:s}=this,l=new Ci(n.lineAt(r-1e3*i,hi.ByHeight,o,0,0).from,n.lineAt(s+1e3*(1-i),hi.ByHeight,o,0,0).to);if(t){let{head:e}=t.range;if(e<l.from||e>l.to){let i,r=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),s=n.lineAt(e,hi.ByPos,o,0,0);i="center"==t.y?(s.top+s.bottom)/2-r/2:"start"==t.y||"nearest"==t.y&&e<l.from?s.top:s.bottom-r,l=new Ci(n.lineAt(i-500,hi.ByHeight,o,0,0).from,n.lineAt(i+r+500,hi.ByHeight,o,0,0).to)}}return l}mapViewport(e,t){let i=t.mapPos(e.from,-1),n=t.mapPos(e.to,1);return new Ci(this.heightMap.lineAt(i,hi.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,hi.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(e,hi.ByPos,this.heightOracle,0,0),{bottom:o}=this.heightMap.lineAt(t,hi.ByPos,this.heightOracle,0,0),{visibleTop:r,visibleBottom:s}=this;return(0==e||n<=r-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||o>=s+Math.max(10,Math.min(i,250)))&&n>r-2e3&&o<s+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let n of e)t.touchesRange(n.from,n.to)||i.push(new xi(t.mapPos(n.from),t.mapPos(n.to),n.size));return i}ensureLineGaps(e,i){let o=this.heightOracle.lineWrapping,r=o?1e4:2e3,s=r>>1,l=r<<1;if(this.defaultTextDirection!=t.Direction.LTR&&!o)return[];let a=[],h=(t,r,l,c)=>{if(r-t<s)return;let u=this.state.selection.main,d=[u.from];u.empty||d.push(u.to);for(let e of d)if(e>t&&e<r)return h(t,e-10,l,c),void h(e+10,r,l,c);let f=function(e,t){for(let i of e)if(t(i))return i;return}(e,(e=>e.from>=l.from&&e.to<=l.to&&Math.abs(e.from-t)<s&&Math.abs(e.to-r)<s&&!d.some((t=>e.from<t&&e.to>t))));if(!f){if(r<l.to&&i&&o&&i.visibleRanges.some((e=>e.from<=r&&e.to>=r))){let e=i.moveToLineBoundary(n.EditorSelection.cursor(r),!1,!0).head;e>t&&(r=e)}f=new xi(t,r,this.gapSize(l,t,r,c))}a.push(f)};for(let e of this.viewportLines){if(e.length<l)continue;let t=Ai(e.from,e.to,this.stateDeco);if(t.total<l)continue;let i,n,s=this.scrollTarget?this.scrollTarget.range.head:null;if(o){let o,l,a=r/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=s){let i=Oi(t,s),n=((this.visibleBottom-this.visibleTop)/2+a)/e.height;o=i-n,l=i+n}else o=(this.visibleTop-e.top-a)/e.height,l=(this.visibleBottom-e.top+a)/e.height;i=Mi(t,o),n=Mi(t,l)}else{let e,o,l=t.total*this.heightOracle.charWidth,a=r*this.heightOracle.charWidth;if(null!=s){let i=Oi(t,s),n=((this.pixelViewport.right-this.pixelViewport.left)/2+a)/l;e=i-n,o=i+n}else e=(this.pixelViewport.left-a)/l,o=(this.pixelViewport.right+a)/l;i=Mi(t,e),n=Mi(t,o)}i>e.from&&h(e.from,i,e,t),n<e.to&&h(n,e.to,e,t)}return a}gapSize(e,t,i,n){let o=Oi(n,i)-Oi(n,t);return this.heightOracle.lineWrapping?e.height*o:n.total*this.heightOracle.charWidth*o}updateLineGaps(e){xi.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=ce.set(e.map((e=>e.draw(this,this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];n.RangeSet.spans(e,this.viewport.from,this.viewport.to,{span(e,i){t.push({from:e,to:i})},point(){}},20);let i=t.length!=this.visibleRanges.length||this.visibleRanges.some(((e,i)=>e.from!=t[i].from||e.to!=t[i].to));return this.visibleRanges=t,i?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find((t=>t.from<=e&&t.to>=e))||Ei(this.heightMap.lineAt(e,hi.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return Ei(this.heightMap.lineAt(this.scaler.fromDOM(e),hi.ByHeight,this.heightOracle,0,0),this.scaler)}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 Ei(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}}class Ci{constructor(e,t){this.from=e,this.to=t}}function Ai(e,t,i){let o=[],r=e,s=0;return n.RangeSet.spans(i,e,t,{span(){},point(e,t){e>r&&(o.push({from:r,to:e}),s+=e-r),r=t}},20),r<t&&(o.push({from:r,to:t}),s+=t-r),{total:s,ranges:o}}function Mi({total:e,ranges:t},i){if(i<=0)return t[0].from;if(i>=1)return t[t.length-1].to;let n=Math.floor(e*i);for(let e=0;;e++){let{from:i,to:o}=t[e],r=o-i;if(n<=r)return i+n;n-=r}}function Oi(e,t){let i=0;for(let{from:n,to:o}of e.ranges){if(t<=o){i+=t-n;break}i+=o-n}return i/e.total}const Ti={toDOM:e=>e,fromDOM:e=>e,scale:1};class Di{constructor(e,t,i){let n=0,o=0,r=0;this.viewports=i.map((({from:i,to:o})=>{let r=t.lineAt(i,hi.ByPos,e,0,0).top,s=t.lineAt(o,hi.ByPos,e,0,0).bottom;return n+=s-r,{from:i,to:o,top:r,bottom:s,domTop:0,domBottom:0}})),this.scale=(7e6-n)/(t.height-n);for(let e of this.viewports)e.domTop=r+(e.top-o)*this.scale,r=e.domBottom=e.domTop+(e.bottom-e.top),o=e.bottom}toDOM(e){for(let t=0,i=0,n=0;;t++){let o=t<this.viewports.length?this.viewports[t]:null;if(!o||e<o.top)return n+(e-i)*this.scale;if(e<=o.bottom)return o.domTop+(e-o.top);i=o.bottom,n=o.domBottom}}fromDOM(e){for(let t=0,i=0,n=0;;t++){let o=t<this.viewports.length?this.viewports[t]:null;if(!o||e<o.domTop)return i+(e-n)/this.scale;if(e<=o.domBottom)return o.top+(e-o.domTop);i=o.bottom,n=o.domBottom}}}function Ei(e,t){if(1==t.scale)return e;let i=t.toDOM(e.top),n=t.toDOM(e.bottom);return new ai(e.from,e.length,i,n-i,Array.isArray(e._content)?e._content.map((e=>Ei(e,t))):e._content)}const Pi=n.Facet.define({combine:e=>e.join(" ")}),Ri=n.Facet.define({combine:e=>e.indexOf(!0)>-1}),Li=o.StyleModule.newName(),Bi=o.StyleModule.newName(),Ni=o.StyleModule.newName(),Ii={"&light":"."+Bi,"&dark":"."+Ni};function _i(e,t,i){return new o.StyleModule(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,(t=>{if("&"==t)return e;if(!i||!i[t])throw new RangeError(`Unsupported selector: ${t}`);return i[t]})):e+" "+t})}const Vi=_i("."+Li,{"&":{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},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".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",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&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},"&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-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"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".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"}},Ii),Fi="";class Hi{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(n.EditorState.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Fi}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let n=e;;){this.findPointBefore(i,n);let e=this.text.length;this.readNode(n);let o=n.nextSibling;if(o==t)break;let r=E.get(n),s=E.get(o);(r&&s?r.breakAfter:(r?r.breakAfter:d(n))||d(o)&&("BR"!=n.nodeName||n.cmIgnore)&&this.text.length>e)&&this.lineBreak(),n=o}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let o,r=-1,s=1;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,i),s=this.lineSeparator.length):(o=n.exec(t))&&(r=o.index,s=o[0].length),this.append(t.slice(i,r<0?t.length:r)),r<0)break;if(this.lineBreak(),s>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=s-1);i=r+s}}readNode(e){if(e.cmIgnore)return;let t=E.get(e),i=t&&t.overrideDOMText;if(null!=i){this.findPointInside(e,i.length);for(let e=i.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(3==e.nodeType?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(Wi(e,i.node,i.offset)?t:0))}}function Wi(e,t,i){for(;;){if(!t||i<p(t))return!1;if(t==e)return!0;i=u(t)+1,t=t.parentNode}}class qi{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class zi{constructor(e,t,i,o){this.typeOver=o,this.bounds=null,this.text="";let{impreciseHead:r,impreciseAnchor:s}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,i,0))){let t=r||s?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:i,anchorOffset:n,focusNode:o,focusOffset:r}=e.observer.selectionRange;i&&(t.push(new qi(i,n)),o==i&&r==n||t.push(new qi(o,r)));return t}(e),i=new Hi(t,e.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(e,t){if(0==e.length)return null;let i=e[0].pos,o=2==e.length?e[1].pos:i;return i>-1&&o>-1?n.EditorSelection.single(i+t,o+t):null}(t,this.bounds.from)}else{let t=e.observer.selectionRange,i=r&&r.node==t.focusNode&&r.offset==t.focusOffset||!l(e.contentDOM,t.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),o=s&&s.node==t.anchorNode&&s.offset==t.anchorOffset||!l(e.contentDOM,t.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),a=e.viewport;if((Q.ios||Q.chrome)&&e.state.selection.main.empty&&i!=o&&(a.from>0||a.to<e.state.doc.length)){let t=Math.min(i,o),n=Math.max(i,o),r=a.from-t,s=a.to-n;0!=r&&1!=r&&0!=t||0!=s&&-1!=s&&n!=e.state.doc.length||(i=0,o=e.state.doc.length)}this.newSel=n.EditorSelection.single(o,i)}}}function Ui(e,t){let i,{newSel:o}=t,r=e.state.selection.main,s=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:o,to:l}=t.bounds,a=r.from,h=null;(8===s||Q.android&&t.text.length<l-o)&&(a=r.to,h="end");let c=function(e,t,i,n){let o=Math.min(e.length,t.length),r=0;for(;r<o&&e.charCodeAt(r)==t.charCodeAt(r);)r++;if(r==o&&e.length==t.length)return null;let s=e.length,l=t.length;for(;s>0&&l>0&&e.charCodeAt(s-1)==t.charCodeAt(l-1);)s--,l--;if("end"==n){i-=s+Math.max(0,r-Math.min(s,l))-r}if(s<r&&e.length<t.length){r-=i<=r&&i>=s?r-i:0,l=r+(l-s),s=r}else if(l<r){r-=i<=r&&i>=l?r-i:0,s=r+(s-l),l=r}return{from:r,toA:s,toB:l}}(e.state.doc.sliceString(o,l,Fi),t.text,a-o,h);c&&(Q.chrome&&13==s&&c.toB==c.from+2&&t.text.slice(c.from,c.toB)==Fi+Fi&&c.toB--,i={from:o+c.from,to:o+c.toA,insert:n.Text.of(t.text.slice(c.from,c.toB).split(Fi))})}else o&&(!e.hasFocus&&e.state.facet(Ye)||o.main.eq(r))&&(o=null);if(!i&&!o)return!1;if(!i&&t.typeOver&&!r.empty&&o&&o.main.empty?i={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,r.to)}:i&&i.from>=r.from&&i.to<=r.to&&(i.from!=r.from||i.to!=r.to)&&r.to-r.from-(i.to-i.from)<=4?i={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,i.from).append(i.insert).append(e.state.doc.slice(i.to,r.to))}:(Q.mac||Q.android)&&i&&i.from==i.to&&i.from==r.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==e.contentDOM.getAttribute("autocorrect")?(o&&2==i.insert.length&&(o=n.EditorSelection.single(o.main.anchor-1,o.main.head-1)),i={from:r.from,to:r.to,insert:n.Text.of([" "])}):Q.chrome&&i&&i.from==i.to&&i.from==r.head&&"\n "==i.insert.toString()&&e.lineWrapping&&(o&&(o=n.EditorSelection.single(o.main.anchor-1,o.main.head-1)),i={from:r.from,to:r.to,insert:n.Text.of([" "])}),i){if(Q.ios&&e.inputState.flushIOSKey(i))return!0;if(Q.android&&(i.to==r.to&&(i.from==r.from||i.from==r.from-1&&" "==e.state.sliceDoc(i.from,r.from))&&1==i.insert.length&&2==i.insert.lines&&S(e.contentDOM,"Enter",13)||(i.from==r.from-1&&i.to==r.to&&0==i.insert.length||8==s&&i.insert.length<i.to-i.from&&i.to>r.head)&&S(e.contentDOM,"Backspace",8)||i.from==r.from&&i.to==r.to+1&&0==i.insert.length&&S(e.contentDOM,"Delete",46)))return!0;let t,l=i.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let a=()=>t||(t=function(e,t,i){let o,r=e.state,s=r.selection.main;if(t.from>=s.from&&t.to<=s.to&&t.to-t.from>=(s.to-s.from)/3&&(!i||i.main.empty&&i.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let i=s.from<t.from?r.sliceDoc(s.from,t.from):"",n=s.to>t.to?r.sliceDoc(t.to,s.to):"";o=r.replaceSelection(e.state.toText(i+t.insert.sliceString(0,void 0,e.state.lineBreak)+n))}else{let l=r.changes(t),a=i&&i.main.to<=l.newLength?i.main:void 0;if(r.selection.ranges.length>1&&e.inputState.composing>=0&&t.to<=s.to&&t.to>=s.to-10){let h,c=e.state.sliceDoc(t.from,t.to),u=i&>(e,i.main.head);if(u){let e=t.insert.length-(t.to-t.from);h={from:u.from,to:u.to-e}}else h=e.state.doc.lineAt(s.head);let d=s.to-t.to,f=s.to-s.from;o=r.changeByRange((i=>{if(i.from==s.from&&i.to==s.to)return{changes:l,range:a||i.map(l)};let o=i.to-d,u=o-c.length;if(i.to-i.from!=f||e.state.sliceDoc(u,o)!=c||i.to>=h.from&&i.from<=h.to)return{range:i};let p=r.changes({from:u,to:o,insert:t.insert}),m=i.to-s.to;return{changes:p,range:a?n.EditorSelection.range(Math.max(0,a.anchor+m),Math.max(0,a.head+m)):i.map(p)}}))}else o={changes:l,selection:a&&r.selection.replaceRange(a)}}let l="input.type";(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,l+=".compose",e.inputState.compositionFirstChange&&(l+=".start",e.inputState.compositionFirstChange=!1));return r.update(o,{userEvent:l,scrollIntoView:!0})}(e,i,o));return e.state.facet(ze).some((t=>t(e,i.from,i.to,l,a)))||e.dispatch(a()),!0}if(o&&!o.main.eq(r)){let t=!1,i="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),i=e.inputState.lastSelectionOrigin),e.dispatch({selection:o,scrollIntoView:t,userEvent:i}),!0}return!1}const ji={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Qi=Q.ie&&Q.ie_version<=11;class Ki{constructor(e){this.view=e,this.active=!1,this.selectionRange=new w,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 e of t)this.queue.push(e);(Q.ie&&Q.ie_version<=11||Q.ios&&e.composing)&&t.some((e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length))?this.flushSoon():this.flush()})),Qi&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var e;(null===(e=this.view.docView)||void 0===e?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()})),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver((e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.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((e=>{e.length>0&&e[e.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.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))}onPrint(e){("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,n=this.selectionRange;if(i.state.facet(Ye)?i.root.activeElement!=this.dom:!a(i.dom,n))return;let o=n.anchorNode&&i.docView.nearest(n.anchorNode);o&&o.ignoreEvent(e)?t||(this.selectionChanged=!1):(Q.ie&&Q.ie_version<=11||Q.android&&Q.chrome)&&!i.state.selection.main.empty&&n.focusNode&&c(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=s(e.root);if(!t)return!1;let i=Q.safari&&11==e.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){let i=t.getComposedRanges(e.root)[0];if(i)return Gi(e,i)}let i=null;function n(e){e.preventDefault(),e.stopImmediatePropagation(),i=e.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",n,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",n,!0),i?Gi(e,i):null}(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let n=a(this.dom,i);return n&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&function(e,t){let i=t.focusNode,n=t.focusOffset;if(!i||t.anchorNode!=i||t.anchorOffset!=n)return!1;for(n=Math.min(n,p(i));;)if(n){if(1!=i.nodeType)return!1;let e=i.childNodes[n-1];"false"==e.contentEditable?n--:(i=e,n=p(i))}else{if(i==e)return!0;n=u(i),i=i.parentNode}}(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),n&&(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(1==i.nodeType)!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(11!=i.nodeType)break;i=i.host}if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);for(let e of this.scrollTargets=t)e.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,ji),Qi&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Qi&&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 e=()=>{let e=this.delayedAndroidKey;if(e){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&S(this.dom,e.key,e.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===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,n=!1;for(let o of e){let e=this.readMutation(o);e&&(e.typeOver&&(n=!0),-1==t?({from:t,to:i}=e):(t=Math.min(e.from,t),i=Math.max(e.to,i)))}return{from:t,to:i,typeOver:n}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),n=this.selectionChanged&&a(this.dom,this.selectionRange);if(e<0&&!n)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let o=new zi(this.view,e,t,i);return this.view.docView.domChanged={newSel:o.newSel?o.newSel.main:null},o}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,n=Ui(this.view,t);return this.view.state==i&&this.view.update([]),n}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty("attributes"==e.type),"attributes"==e.type&&(t.flags|=4),"childList"==e.type){let i=$i(t,e.previousSibling||e.target.previousSibling,-1),n=$i(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:n?t.posBefore(n):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{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("change",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("change",this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var e,t,i;this.stop(),null===(e=this.intersection)||void 0===e||e.disconnect(),null===(t=this.gapIntersection)||void 0===t||t.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect();for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function $i(e,t,i){for(;t;){let n=E.get(t);if(n&&n.parent==e)return n;let o=t.parentNode;t=o!=e.dom?o:i>0?t.nextSibling:t.previousSibling}return null}function Gi(e,t){let i=t.startContainer,n=t.startOffset,o=t.endContainer,r=t.endOffset,s=e.docView.domAtPos(e.state.selection.main.anchor);return c(s.node,s.offset,o,r)&&([i,n,o,r]=[o,r,i,n]),{anchorNode:i,anchorOffset:n,focusNode:o,focusOffset:r}}class Xi{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.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){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:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(e=>e.forEach((e=>t(e,this))))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(e.parent)||document,this.viewState=new Si(e.state||n.EditorState.create(e)),e.scrollTo&&e.scrollTo.is(Ge)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ze).map((e=>new tt(e)));for(let e of this.plugins)e.update(this);this.observer=new Ki(this),this.inputState=new Pt(this),this.inputState.ensureHandlers(this.plugins),this.docView=new pt(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...e){let t=1==e.length&&e[0]instanceof n.Transaction?e:1==e.length&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t,i=!1,o=!1,r=this.state;for(let t of e){if(t.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=t.state}if(this.destroyed)return void(this.viewState.state=r);let s=this.hasFocus,l=0,a=null;e.some((e=>e.annotation(ti)))?(this.inputState.notifiedFocused=s,l=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,a=ii(r,s),a||(l=1));let h=this.observer.delayedAndroidKey,c=null;if(h?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(c=null)):this.observer.clear(),r.facet(n.EditorState.phrases)!=this.state.facet(n.EditorState.phrases))return this.setState(r);t=ft.create(this,r,e),t.flags|=l;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let t of e){if(u&&(u=u.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection;u=new $e(e.empty?e:n.EditorSelection.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(Ge)&&(u=e.value.clip(this.state))}this.viewState.update(t,u),this.bidiCache=Zi.update(this.bidiCache,t.changes),t.empty||(this.updatePlugins(t),this.inputState.update(t)),i=this.docView.update(t),this.state.facet(ut)!=this.styleModules&&this.mountStyles(),o=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(i,e.some((e=>e.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(t.startState.facet(Pi)!=t.state.facet(Pi)&&(this.viewState.mustMeasureContent=!0),(i||o||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),i&&this.docViewUpdate(),!t.empty)for(let e of this.state.facet(qe))try{e(t)}catch(e){Xe(this.state,e,"update listener")}(a||c)&&Promise.resolve().then((()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!Ui(this,c)&&h.force&&S(this.contentDOM,h.key,h.keyCode)}))}setState(e){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=e);this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new Si(e),this.plugins=e.facet(Ze).map((e=>new tt(e))),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new pt(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(Ze),i=e.state.facet(Ze);if(t!=i){let n=[];for(let o of i){let i=t.indexOf(o);if(i<0)n.push(new tt(o));else{let t=this.plugins[i];t.mustUpdate=e,n.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].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(e){Xe(this.state,e,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:o,scrollAnchorHeight:r}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(r=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(r<0)if(A(i))o=-1,r=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(n);o=e.from,r=e.top}this.updateState=1;let s=this.viewState.measure(this);if(!s&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let l=[];4&s||([this.measureRequests,l]=[l,this.measureRequests]);let a=l.map((e=>{try{return e.read(this)}catch(e){return Xe(this.state,e),Ji}})),h=ft.create(this,this.state,[]),c=!1;h.flags|=s,t?t.flags|=s:t=h,this.updateState=2,h.empty||(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),c=this.docView.update(h),c&&this.docViewUpdate());for(let e=0;e<l.length;e++)if(a[e]!=Ji)try{let t=l[e];t.write&&t.write(a[e],this)}catch(e){Xe(this.state,e)}if(c&&this.docView.updateSelection(!0),!h.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,r=-1;continue}{let e=(o<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(o).top)-r;if(e>1||e<-1){n+=e,i.scrollTop=n/this.scaleY,r=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(qe))e(t)}get themeClasses(){return Li+" "+(this.state.facet(Ri)?Ni:Bi)+" "+this.state.facet(Pi)}updateAttrs(){let e=en(this,it,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(Ye)?"true":"false",class:"cm-content",style:`${Q.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),en(this,nt,t);let i=this.observer.ignore((()=>{let i=ne(this.contentDOM,this.contentAttrs,t),n=ne(this.dom,this.editorAttrs,e);return i||n}));return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let e of i.effects)if(e.is(Xi.announce)){t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value}}mountStyles(){this.styleModules=this.state.facet(ut);let e=this.state.facet(Xi.cspNonce);o.StyleModule.mount(this.root,this.styleModules.concat(Vi).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(2==this.updateState)throw new Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&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(null!=e.key)for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key)return void(this.measureRequests[t]=e);this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(void 0===t||t&&t.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find((t=>t.spec==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 Et(this,e,Tt(this,e,t,i))}moveByGroup(e,t){return Et(this,e,Tt(this,e,t,(t=>function(e,t,i){let o=e.state.charCategorizer(t),r=o(i);return e=>{let t=o(e);return r==n.CharCategory.Space&&(r=t),r==t}}(this,e.head,t))))}visualLineSide(e,t){let i=this.bidiSpans(e),o=this.textDirectionAt(e.from),r=i[t?i.length-1:0];return n.EditorSelection.cursor(r.side(t,o)+e.from,r.forward(!t,o)?1:-1)}moveToLineBoundary(e,i,o=!0){return function(e,i,o,r){let s=Ot(e,i.head),l=r&&s.type==t.BlockType.Text&&(e.lineWrapping||s.widgetLineBreaks)?e.coordsAtPos(i.assoc<0&&i.head>s.from?i.head-1:i.head):null;if(l){let i=e.dom.getBoundingClientRect(),r=e.textDirectionAt(s.from),a=e.posAtCoords({x:o==(r==t.Direction.LTR)?i.right-1:i.left+1,y:(l.top+l.bottom)/2});if(null!=a)return n.EditorSelection.cursor(a,o?-1:1)}return n.EditorSelection.cursor(o?s.to:s.from,o?-1:1)}(this,e,i,o)}moveVertically(e,t,i){return Et(this,e,function(e,t,i,o){let r=t.head,s=i?1:-1;if(r==(i?e.state.doc.length:0))return n.EditorSelection.cursor(r,t.assoc);let l,a=t.goalColumn,h=e.contentDOM.getBoundingClientRect(),c=e.coordsAtPos(r,t.assoc||-1),u=e.documentTop;if(c)null==a&&(a=c.left-h.left),l=s<0?c.top:c.bottom;else{let t=e.viewState.lineBlockAt(r);null==a&&(a=Math.min(h.right-h.left,e.defaultCharacterWidth*(r-t.from))),l=(s<0?t.top:t.bottom)+u}let d=h.left+a,f=null!=o?o:e.viewState.heightOracle.textHeight>>1;for(let t=0;;t+=10){let i=l+(f+t)*s,o=At(e,{x:d,y:i},!1,s);if(i<h.top||i>h.bottom||(s<0?o<r:o>r)){let t=e.docView.coordsForChar(o),r=!t||i<t.top?-1:1;return n.EditorSelection.cursor(o,r,void 0,a)}}}(this,e,t,i))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),At(this,e,t)}coordsAtPos(e,i=1){this.readMeasured();let n=this.docView.coordsAt(e,i);if(!n||n.left==n.right)return n;let o=this.state.doc.lineAt(e),r=this.bidiSpans(o);return m(n,r[Te.find(r,e-o.from,-1,i)].dir==t.Direction.LTR==i>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(je)||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>Yi)return Be(e.length);let t,i=this.textDirectionAt(e.from);for(let n of this.bidiCache)if(n.from==e.from&&n.dir==i&&(n.fresh||De(n.isolates,t=at(this,e))))return n.order;t||(t=at(this,e));let n=Le(e.text,i,t);return this.bidiCache.push(new Zi(e.from,e.to,i,t,!0,n)),n}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Q.safari&&(null===(e=this.inputState)||void 0===e?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{x(this.contentDOM),this.docView.updateSelection()}))}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((9==e.nodeType?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){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={}){return Ge.of(new $e("number"==typeof e?n.EditorSelection.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return Ge.of(new $e(n.EditorSelection.cursor(i.from),"start","start",i.top-e,t,!0))}static domEventHandlers(e){return et.define((()=>({})),{eventHandlers:e})}static domEventObservers(e){return et.define((()=>({})),{eventObservers:e})}static theme(e,t){let i=o.StyleModule.newName(),n=[Pi.of(i),ut.of(_i(`.${i}`,e))];return t&&t.dark&&n.push(Ri.of(!0)),n}static baseTheme(e){return n.Prec.lowest(ut.of(_i("."+Li,e,Ii)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),n=i&&E.get(i)||E.get(e);return(null===(t=null==n?void 0:n.rootView)||void 0===t?void 0:t.view)||null}}Xi.styleModule=ut,Xi.inputHandler=ze,Xi.scrollHandler=Ke,Xi.focusChangeEffect=Ue,Xi.perLineTextDirection=je,Xi.exceptionSink=We,Xi.updateListener=qe,Xi.editable=Ye,Xi.mouseSelectionStyle=He,Xi.dragMovesSelection=Fe,Xi.clickAddsSelectionRange=Ve,Xi.decorations=ot,Xi.outerDecorations=rt,Xi.atomicRanges=st,Xi.bidiIsolatedRanges=lt,Xi.scrollMargins=ht,Xi.darkTheme=Ri,Xi.cspNonce=n.Facet.define({combine:e=>e.length?e[0]:""}),Xi.contentAttributes=nt,Xi.editorAttributes=it,Xi.lineWrapping=Xi.contentAttributes.of({class:"cm-lineWrapping"}),Xi.announce=n.StateEffect.define();const Yi=4096,Ji={};class Zi{constructor(e,t,i,n,o,r){this.from=e,this.to=t,this.dir=i,this.isolates=n,this.fresh=o,this.order=r}static update(e,i){if(i.empty&&!e.some((e=>e.fresh)))return e;let n=[],o=e.length?e[e.length-1].dir:t.Direction.LTR;for(let t=Math.max(0,e.length-10);t<e.length;t++){let r=e[t];r.dir!=o||i.touchesRange(r.from,r.to)||n.push(new Zi(i.mapPos(r.from,1),i.mapPos(r.to,-1),r.dir,r.isolates,!1,r.order))}return n}}function en(e,t,i){for(let n=e.state.facet(t),o=n.length-1;o>=0;o--){let t=n[o],r="function"==typeof t?t(e):t;r&&ee(r,i)}return i}const tn=Q.mac?"mac":Q.windows?"win":Q.linux?"linux":"key";function nn(e,t,i){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==i&&t.shiftKey&&(e="Shift-"+e),e}const on=n.Prec.default(Xi.domEventHandlers({keydown:(e,t)=>cn(ln(t.state),e,t,"editor")})),rn=n.Facet.define({enables:on}),sn=new WeakMap;function ln(e){let t=e.facet(rn),i=sn.get(t);return i||sn.set(t,i=function(e,t=tn){let i=Object.create(null),n=Object.create(null),o=(e,t)=>{let i=n[e];if(null==i)n[e]=t;else if(i!=t)throw new Error("Key binding "+e+" is used both as a regular binding and as a multi-stroke prefix")},r=(e,n,r,s,l)=>{var a,h;let c=i[e]||(i[e]=Object.create(null)),u=n.split(/ (?!$)/).map((e=>function(e,t){const i=e.split(/-(?!$)/);let n,o,r,s,l=i[i.length-1];"Space"==l&&(l=" ");for(let e=0;e<i.length-1;++e){const l=i[e];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))n=!0;else if(/^(c|ctrl|control)$/i.test(l))o=!0;else if(/^s(hift)?$/i.test(l))r=!0;else{if(!/^mod$/i.test(l))throw new Error("Unrecognized modifier name: "+l);"mac"==t?s=!0:o=!0}}return n&&(l="Alt-"+l),o&&(l="Ctrl-"+l),s&&(l="Meta-"+l),r&&(l="Shift-"+l),l}(e,t)));for(let t=1;t<u.length;t++){let i=u.slice(0,t).join(" ");o(i,!0),c[i]||(c[i]={preventDefault:!0,stopPropagation:!1,run:[t=>{let n=an={view:t,prefix:i,scope:e};return setTimeout((()=>{an==n&&(an=null)}),hn),!0}]})}let d=u.join(" ");o(d,!1);let f=c[d]||(c[d]={preventDefault:!1,stopPropagation:!1,run:(null===(h=null===(a=c._any)||void 0===a?void 0:a.run)||void 0===h?void 0:h.slice())||[]});r&&f.run.push(r),s&&(f.preventDefault=!0),l&&(f.stopPropagation=!0)};for(let n of e){let e=n.scope?n.scope.split(" "):["editor"];if(n.any)for(let t of e){let e=i[t]||(i[t]=Object.create(null));e._any||(e._any={preventDefault:!1,stopPropagation:!1,run:[]});for(let t in e)e[t].run.push(n.any)}let o=n[t]||n.key;if(o)for(let t of e)r(t,o,n.run,n.preventDefault,n.stopPropagation),n.shift&&r(t,"Shift-"+o,n.shift,n.preventDefault,n.stopPropagation)}return i}(t.reduce(((e,t)=>e.concat(t)),[]))),i}let an=null;const hn=4e3;function cn(e,t,i,o){let s=r.keyName(t),l=n.codePointAt(s,0),a=n.codePointSize(l)==s.length&&" "!=s,h="",c=!1,u=!1,d=!1;an&&an.view==i&&an.scope==o&&(h=an.prefix+" ",It.indexOf(t.keyCode)<0&&(u=!0,an=null));let f,p,m=new Set,g=e=>{if(e){for(let n of e.run)if(!m.has(n)&&(m.add(n),n(i,t)))return e.stopPropagation&&(d=!0),!0;e.preventDefault&&(e.stopPropagation&&(d=!0),u=!0)}return!1},v=e[o];return v&&(g(v[h+nn(s,t,!a)])?c=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(Q.windows&&t.ctrlKey&&t.altKey)&&(f=r.base[t.keyCode])&&f!=s?(g(v[h+nn(f,t,!0)])||t.shiftKey&&(p=r.shift[t.keyCode])!=s&&p!=f&&g(v[h+nn(p,t,!1)]))&&(c=!0):a&&t.shiftKey&&g(v[h+nn(s,t,!0)])&&(c=!0),!c&&g(v._any)&&(c=!0)),u&&(c=!0),c&&d&&t.stopPropagation(),c}class un{constructor(e,t,i,n,o){this.className=e,this.left=t,this.top=i,this.width=n,this.height=o}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className&&(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",null!=this.width&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,i,n){if(n.empty){let t=e.coordsAtPos(n.head,n.assoc||1);if(!t)return[];let o=dn(e);return[new un(i,t.left-o.left,t.top-o.top,null,t.bottom-t.top)]}return function(e,i,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let o=Math.max(n.from,e.viewport.from),r=Math.min(n.to,e.viewport.to),s=e.textDirection==t.Direction.LTR,l=e.contentDOM,a=l.getBoundingClientRect(),h=dn(e),c=l.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),d=a.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=a.right-(u?parseInt(u.paddingRight):0),p=Ot(e,o),m=Ot(e,r),g=p.type==t.BlockType.Text?p:null,v=m.type==t.BlockType.Text?m:null;g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=fn(e,o,g));v&&(e.lineWrapping||m.widgetLineBreaks)&&(v=fn(e,r,v));if(g&&v&&g.from==v.from)return y(b(n.from,n.to,g));{let i=g?b(n.from,null,g):x(p,!1),o=v?b(null,n.to,v):x(m,!0),r=[];return(g||p).to<(v||m).from-(g&&v?1:0)||p.widgetLineBreaks>1&&i.bottom+e.defaultLineHeight/2<o.top?r.push(w(d,i.bottom,f,o.top)):i.bottom<o.top&&e.elementAtHeight((i.bottom+o.top)/2).type==t.BlockType.Text&&(i.bottom=o.top=(i.bottom+o.top)/2),y(i).concat(r).concat(y(o))}function w(e,t,n,o){return new un(i,e-h.left,t-h.top-.01,n-e,o-t+.01)}function y({top:e,bottom:t,horizontal:i}){let n=[];for(let o=0;o<i.length;o+=2)n.push(w(i[o],e,i[o+1],t));return n}function b(i,n,o){let r=1e9,l=-1e9,a=[];function h(i,n,h,c,u){let p=e.coordsAtPos(i,i==o.to?-2:2),m=e.coordsAtPos(h,h==o.from?2:-2);p&&m&&(r=Math.min(p.top,m.top,r),l=Math.max(p.bottom,m.bottom,l),u==t.Direction.LTR?a.push(s&&n?d:p.left,s&&c?f:m.right):a.push(!s&&c?d:m.left,!s&&n?f:p.right))}let c=null!=i?i:o.from,u=null!=n?n:o.to;for(let t of e.visibleRanges)if(t.to>c&&t.from<u)for(let o=Math.max(t.from,c),r=Math.min(t.to,u);;){let t=e.state.doc.lineAt(o);for(let s of e.bidiSpans(t)){let e=s.from+t.from,l=s.to+t.from;if(e>=r)break;l>o&&h(Math.max(e,o),null==i&&e<=c,Math.min(l,r),null==n&&l>=u,s.dir)}if(o=t.to+1,o>=r)break}return 0==a.length&&h(c,null==i,u,null==n,e.textDirection),{top:r,bottom:l,horizontal:a}}function x(e,t){let i=a.top+(t?e.top:e.bottom);return{top:i,bottom:i,horizontal:[]}}}(e,i,n)}}function dn(e){let i=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==t.Direction.LTR?i.left:i.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:i.top-e.scrollDOM.scrollTop*e.scaleY}}function fn(e,i,o){let r=n.EditorSelection.cursor(i);return{from:Math.max(o.from,e.moveToLineBoundary(r,!1,!0).from),to:Math.min(o.to,e.moveToLineBoundary(r,!0,!0).from),type:t.BlockType.Text}}class pn{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(mn)!=e.state.facet(mn)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){!1!==this.layer.updateOnDocViewUpdate&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,i=e.facet(mn);for(;t<i.length&&i[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;e==this.scaleX&&t==this.scaleY||(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some(((e,t)=>{return i=e,n=this.drawn[t],!(i.constructor==n.constructor&&i.eq(n));var i,n}))){let t=this.dom.firstChild,i=0;for(let n of e)n.update&&t&&n.constructor&&this.drawn[i].constructor&&n.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(n.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const mn=n.Facet.define();function gn(e){return[et.define((t=>new pn(t,e))),mn.of(e)]}const vn=!Q.ios,wn=n.Facet.define({combine:e=>n.combineConfig(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})});function yn(e){return e.startState.facet(wn)!=e.state.facet(wn)}const bn=gn({above:!0,markers(e){let{state:t}=e,i=t.facet(wn),o=[];for(let r of t.selection.ranges){let s=r==t.selection.main;if(r.empty?!s||vn:i.drawRangeCursor){let t=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",i=r.empty?r:n.EditorSelection.cursor(r.head,r.head>r.anchor?-1:1);for(let n of un.forRange(e,t,i))o.push(n)}}return o},update(e,t){e.transactions.some((e=>e.selection))&&(t.style.animationName="cm-blink"==t.style.animationName?"cm-blink2":"cm-blink");let i=yn(e);return i&&xn(e.state,t),e.docChanged||e.selectionSet||i},mount(e,t){xn(t.state,e)},class:"cm-cursorLayer"});function xn(e,t){t.style.animationDuration=e.facet(wn).cursorBlinkRate+"ms"}const kn=gn({above:!1,markers:e=>e.state.selection.ranges.map((t=>t.empty?[]:un.forRange(e,"cm-selectionBackground",t))).reduce(((e,t)=>e.concat(t))),update:(e,t)=>e.docChanged||e.selectionSet||e.viewportChanged||yn(e),class:"cm-selectionLayer"}),Sn={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};vn&&(Sn[".cm-line"].caretColor="transparent !important",Sn[".cm-content"]={caretColor:"transparent !important"});const Cn=n.Prec.highest(Xi.theme(Sn)),An=n.StateEffect.define({map:(e,t)=>null==e?null:t.mapPos(e)}),Mn=n.StateField.define({create:()=>null,update:(e,t)=>(null!=e&&(e=t.changes.mapPos(e)),t.effects.reduce(((e,t)=>t.is(An)?t.value:e),e))}),On=et.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let i=e.state.field(Mn);null==i?null!=this.cursor&&(null===(t=this.cursor)||void 0===t||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(e.startState.field(Mn)!=i||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(Mn),i=null!=t&&e.coordsAtPos(t);if(!i)return null;let n=e.scrollDOM.getBoundingClientRect();return{left:i.left-n.left+e.scrollDOM.scrollLeft*e.scaleX,top:i.top-n.top+e.scrollDOM.scrollTop*e.scaleY,height:i.bottom-i.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:i}=this.view;e?(this.cursor.style.left=e.left/t+"px",this.cursor.style.top=e.top/i+"px",this.cursor.style.height=e.height/i+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(Mn)!=e&&this.view.dispatch({effects:An.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){e.target!=this.view.contentDOM&&this.view.contentDOM.contains(e.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Tn(e,t,i,n,o){t.lastIndex=0;for(let r,s=e.iterRange(i,n),l=i;!s.next().done;l+=s.value.length)if(!s.lineBreak)for(;r=t.exec(s.value);)o(l+r.index,r)}class Dn{constructor(e){const{regexp:t,decoration:i,decorate:n,boundary:o,maxLength:r=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,n)this.addMatch=(e,t,i,o)=>n(o,i,i+e[0].length,e,t);else if("function"==typeof i)this.addMatch=(e,t,n,o)=>{let r=i(e,t,n);r&&o(n,n+e[0].length,r)};else{if(!i)throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.addMatch=(e,t,n,o)=>o(n,n+e[0].length,i)}this.boundary=o,this.maxLength=r}createDeco(e){let t=new n.RangeSetBuilder,i=t.add.bind(t);for(let{from:t,to:n}of function(e,t){let i=e.visibleRanges;if(1==i.length&&i[0].from==e.viewport.from&&i[0].to==e.viewport.to)return i;let n=[];for(let{from:o,to:r}of i)o=Math.max(e.state.doc.lineAt(o).from,o-t),r=Math.min(e.state.doc.lineAt(r).to,r+t),n.length&&n[n.length-1].to>=o?n[n.length-1].to=r:n.push({from:o,to:r});return n}(e,this.maxLength))Tn(e.state.doc,this.regexp,t,n,((t,n)=>this.addMatch(n,e,t,i)));return t.finish()}updateDeco(e,t){let i=1e9,n=-1;return e.docChanged&&e.changes.iterChanges(((t,o,r,s)=>{s>e.view.viewport.from&&r<e.view.viewport.to&&(i=Math.min(r,i),n=Math.max(s,n))})),e.viewportChanged||n-i>1e3?this.createDeco(e.view):n>-1?this.updateRange(e.view,t.map(e.changes),i,n):t}updateRange(e,t,i,n){for(let o of e.visibleRanges){let r=Math.max(o.from,i),s=Math.min(o.to,n);if(s>r){let i=e.state.doc.lineAt(r),n=i.to<s?e.state.doc.lineAt(s):i,l=Math.max(o.from,i.from),a=Math.min(o.to,n.to);if(this.boundary){for(;r>i.from;r--)if(this.boundary.test(i.text[r-1-i.from])){l=r;break}for(;s<n.to;s++)if(this.boundary.test(n.text[s-n.from])){a=s;break}}let h,c=[],u=(e,t,i)=>c.push(i.range(e,t));if(i==n)for(this.regexp.lastIndex=l-i.from;(h=this.regexp.exec(i.text))&&h.index<a-i.from;)this.addMatch(h,e,h.index+i.from,u);else Tn(e.state.doc,this.regexp,l,a,((t,i)=>this.addMatch(i,e,t,u)));t=t.update({filterFrom:l,filterTo:a,filter:(e,t)=>e<l||t>a,add:c})}}return t}}const En=null!=/x/.unicode?"gu":"g",Pn=new RegExp("[\0-\b\n--\u2028\u2029\ufeff-]",En),Rn={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Ln=null;const Bn=n.Facet.define({combine(e){let t=n.combineConfig(e,{render:null,specialChars:Pn,addSpecialChars:null});return(t.replaceTabs=!function(){var e;if(null==Ln&&"undefined"!=typeof document&&document.body){let t=document.body.style;Ln=null!=(null!==(e=t.tabSize)&&void 0!==e?e:t.MozTabSize)}return Ln||!1}())&&(t.specialChars=new RegExp("\t|"+t.specialChars.source,En)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,En)),t}});let Nn=null;class In extends le{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=(i=this.code)>=32?"•":10==i?"":String.fromCharCode(9216+i);var i;let n=e.state.phrase("Control character")+" "+(Rn[this.code]||"0x"+this.code.toString(16)),o=this.options.render&&this.options.render(this.code,n,t);if(o)return o;let r=document.createElement("span");return r.textContent=t,r.title=n,r.setAttribute("aria-label",n),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class _n extends le{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent="\t",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}const Vn=et.fromClass(class{constructor(){this.height=1e3,this.attrs={style:"padding-bottom: 1000px"}}update(e){let{view:t}=e,i=t.viewState.editorHeight-t.defaultLineHeight-t.documentPadding.top-.5;i>=0&&i!=this.height&&(this.height=i,this.attrs={style:`padding-bottom: ${i}px`})}});const Fn=ce.line({class:"cm-activeLine"}),Hn=et.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,i=[];for(let n of e.state.selection.ranges){let o=e.lineBlockAt(n.head);o.from>t&&(i.push(Fn.range(o.from)),t=o.from)}return ce.set(i)}},{decorations:e=>e.decorations});class Wn extends le{constructor(e){super(),this.content=e}toDOM(){let e=document.createElement("span");return e.className="cm-placeholder",e.style.pointerEvents="none",e.appendChild("string"==typeof this.content?document.createTextNode(this.content):this.content),"string"==typeof this.content?e.setAttribute("aria-label","placeholder "+this.content):e.setAttribute("aria-hidden","true"),e}coordsAt(e){let t=e.firstChild?h(e.firstChild):[];if(!t.length)return null;let i=window.getComputedStyle(e.parentNode),n=m(t[0],"rtl"!=i.direction),o=parseInt(i.lineHeight);return n.bottom-n.top>1.5*o?{left:n.left,right:n.right,top:n.top,bottom:n.top+o}:n}ignoreEvent(){return!1}}const qn=2e3;function zn(e,t){let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),o=e.state.doc.lineAt(i),r=i-o.from,s=r>qn?-1:r==o.length?function(e,t){let i=e.coordsAtPos(e.viewport.from);return i?Math.round(Math.abs((i.left-t)/e.defaultCharacterWidth)):-1}(e,t.clientX):n.countColumn(o.text,e.state.tabSize,i-o.from);return{line:o.number,col:s,off:r}}function Un(e,t){let i=zn(e,t),o=e.state.selection;return i?{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(i.line).from),n=e.state.doc.lineAt(t);i={line:n.number,col:i.col,off:Math.min(i.off,n.length)},o=o.map(e.changes)}},get(t,r,s){let l=zn(e,t);if(!l)return o;let a=function(e,t,i){let o=Math.min(t.line,i.line),r=Math.max(t.line,i.line),s=[];if(t.off>qn||i.off>qn||t.col<0||i.col<0){let l=Math.min(t.off,i.off),a=Math.max(t.off,i.off);for(let t=o;t<=r;t++){let i=e.doc.line(t);i.length<=a&&s.push(n.EditorSelection.range(i.from+l,i.to+a))}}else{let l=Math.min(t.col,i.col),a=Math.max(t.col,i.col);for(let t=o;t<=r;t++){let i=e.doc.line(t),o=n.findColumn(i.text,l,e.tabSize,!0);if(o<0)s.push(n.EditorSelection.cursor(i.to));else{let t=n.findColumn(i.text,a,e.tabSize);s.push(n.EditorSelection.range(i.from+o,i.from+t))}}}return s}(e.state,i,l);return a.length?s?n.EditorSelection.create(a.concat(o.ranges)):n.EditorSelection.create(a):o}}:null}const jn={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},Qn={style:"cursor: crosshair"};const Kn="-10000px";class $n{constructor(e,t,i,n){this.facet=t,this.createTooltipView=i,this.removeTooltipView=n,this.input=e.state.facet(t),this.tooltips=this.input.filter((e=>e));let o=null;this.tooltipViews=this.tooltips.map((e=>o=i(e,o)))}update(e,t){var i;let n=e.state.facet(this.facet),o=n.filter((e=>e));if(n===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let r=[],s=t?[]:null;for(let i=0;i<o.length;i++){let n=o[i],l=-1;if(n){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==n.create&&(l=e)}if(l<0)r[i]=this.createTooltipView(n,i?r[i-1]:null),s&&(s[i]=!!n.above);else{let n=r[i]=this.tooltipViews[l];s&&(s[i]=t[l]),n.update&&n.update(e)}}}for(let e of this.tooltipViews)r.indexOf(e)<0&&(this.removeTooltipView(e),null===(i=e.destroy)||void 0===i||i.call(e));return t&&(s.forEach(((e,i)=>t[i]=e)),t.length=s.length),this.input=n,this.tooltips=o,this.tooltipViews=r,!0}}function Gn(e){let{win:t}=e;return{top:0,left:0,bottom:t.innerHeight,right:t.innerWidth}}const Xn=n.Facet.define({combine:e=>{var t,i,n;return{position:Q.ios?"absolute":(null===(t=e.find((e=>e.position)))||void 0===t?void 0:t.position)||"fixed",parent:(null===(i=e.find((e=>e.parent)))||void 0===i?void 0:i.parent)||null,tooltipSpace:(null===(n=e.find((e=>e.tooltipSpace)))||void 0===n?void 0:n.tooltipSpace)||Gn}}}),Yn=new WeakMap,Jn=et.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(Xn);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver="function"==typeof ResizeObserver?new ResizeObserver((()=>this.measureSoon())):null,this.manager=new $n(e,to,((e,t)=>this.createTooltip(e,t)),(e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()})),this.above=this.manager.tooltips.map((e=>!!e.above)),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver((e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()}),{threshold:[1]}):null,this.observeIntersection(),e.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 e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout((()=>{this.measureTimeout=-1,this.maybeMeasure()}),50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let i=t||e.geometryChanged,n=e.state.facet(Xn);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;i=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let e of this.manager.tooltipViews)this.container.appendChild(e.dom);i=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);i&&this.maybeMeasure()}createTooltip(e,t){let i=e.create(this.view),n=t?t.dom:null;if(i.dom.classList.add("cm-tooltip"),e.arrow&&!i.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let e=document.createElement("div");e.className="cm-tooltip-arrow",i.dom.appendChild(e)}return i.dom.style.position=this.position,i.dom.style.top=Kn,i.dom.style.left="0px",this.container.insertBefore(i.dom,n),i.mount&&i.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(i.dom),i}destroy(){var e,t,i;this.view.win.removeEventListener("resize",this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),null===(e=t.destroy)||void 0===e||e.call(t);this.parent&&this.container.remove(),null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(i=this.intersectionObserver)||void 0===i||i.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=this.view.dom.getBoundingClientRect(),t=1,i=1,n=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(Q.gecko)n=e.offsetParent!=this.container.ownerDocument.body;else if(e.style.top==Kn&&"0px"==e.style.left){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}}if(n||"absolute"==this.position)if(this.parent){let e=this.parent.getBoundingClientRect();e.width&&e.height&&(t=e.width/this.parent.offsetWidth,i=e.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:i}=this.view.viewState);return{editor:e,parent:this.parent?this.container.getBoundingClientRect():e,pos:this.manager.tooltips.map(((e,t)=>{let i=this.manager.tooltipViews[t];return i.getCoords?i.getCoords(e.pos):this.view.coordsAtPos(e.pos)})),size:this.manager.tooltipViews.map((({dom:e})=>e.getBoundingClientRect())),space:this.view.state.facet(Xn).tooltipSpace(this.view),scaleX:t,scaleY:i,makeAbsolute:n}}writeMeasure(e){var i;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let e of this.manager.tooltipViews)e.dom.style.position="absolute"}let{editor:n,space:o,scaleX:r,scaleY:s}=e,l=[];for(let a=0;a<this.manager.tooltips.length;a++){let h=this.manager.tooltips[a],c=this.manager.tooltipViews[a],{dom:u}=c,d=e.pos[a],f=e.size[a];if(!d||d.bottom<=Math.max(n.top,o.top)||d.top>=Math.min(n.bottom,o.bottom)||d.right<Math.max(n.left,o.left)-.1||d.left>Math.min(n.right,o.right)+.1){u.style.top=Kn;continue}let p=h.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,m=p?7:0,g=f.right-f.left,v=null!==(i=Yn.get(c))&&void 0!==i?i:f.bottom-f.top,w=c.offset||eo,y=this.view.textDirection==t.Direction.LTR,b=f.width>o.right-o.left?y?o.left:o.right-f.width:y?Math.min(d.left-(p?14:0)+w.x,o.right-g):Math.max(o.left,d.left-g+(p?14:0)-w.x),x=this.above[a];!h.strictSide&&(x?d.top-(f.bottom-f.top)-w.y<o.top:d.bottom+(f.bottom-f.top)+w.y>o.bottom)&&x==o.bottom-d.bottom>d.top-o.top&&(x=this.above[a]=!x);let k=(x?d.top-o.top:o.bottom-d.bottom)-m;if(k<v&&!1!==c.resize){if(k<this.view.defaultLineHeight){u.style.top=Kn;continue}Yn.set(c,v),u.style.height=(v=k)/s+"px"}else u.style.height&&(u.style.height="");let S=x?d.top-v-m-w.y:d.bottom+m+w.y,C=b+g;if(!0!==c.overlap)for(let e of l)e.left<C&&e.right>b&&e.top<S+v&&e.bottom>S&&(S=x?e.top-v-2-m:e.bottom+m+2);if("absolute"==this.position?(u.style.top=(S-e.parent.top)/s+"px",u.style.left=(b-e.parent.left)/r+"px"):(u.style.top=S/s+"px",u.style.left=b/r+"px"),p){let e=d.left+(y?w.x:-w.x)-(b+14-7);p.style.left=e/r+"px"}!0!==c.overlap&&l.push({left:b,top:S,right:C,bottom:S+v}),u.classList.toggle("cm-tooltip-above",x),u.classList.toggle("cm-tooltip-below",!x),c.positioned&&c.positioned(e.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 e of this.manager.tooltipViews)e.dom.style.top=Kn}},{eventObservers:{scroll(){this.maybeMeasure()}}}),Zn=Xi.baseTheme({".cm-tooltip":{zIndex:100,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"}}}),eo={x:0,y:0},to=n.Facet.define({enables:[Jn,Zn]}),io=n.Facet.define({combine:e=>e.reduce(((e,t)=>e.concat(t)),[])});class no{static create(e){return new no(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new $n(e,io,((e,t)=>this.createHostedView(e,t)),(e=>e.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)null===(e=t.destroy)||void 0===e||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let n=i[e];if(void 0!==n)if(void 0===t)t=n;else if(t!==n)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")}}const oo=to.compute([io],(e=>{let t=e.facet(io);return 0===t.length?null:{pos:Math.min(...t.map((e=>e.pos))),end:Math.max(...t.map((e=>{var t;return null!==(t=e.end)&&void 0!==t?t:e.pos}))),create:no.create,above:t[0].above,arrow:t.some((e=>e.arrow))}}));class ro{constructor(e,t,i,n,o){this.view=e,this.source=t,this.field=i,this.setHover=n,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(){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:i}=this,n=e.docView.nearest(i.target);if(!n)return;let o,r=1;if(n instanceof G)o=n.posAtStart;else{if(o=e.posAtCoords(i),null==o)return;let n=e.coordsAtPos(o);if(!n||i.y<n.top||i.y>n.bottom||i.x<n.left-e.defaultCharacterWidth||i.x>n.right+e.defaultCharacterWidth)return;let s=e.bidiSpans(e.state.doc.lineAt(o)).find((e=>e.from<=o&&e.to>=o)),l=s&&s.dir==t.Direction.RTL?-1:1;r=i.x<n.left?-l:l}let s=this.source(e,o,r);if(null==s?void 0:s.then){let t=this.pending={pos:o};s.then((i=>{this.pending==t&&(this.pending=null,!i||Array.isArray(i)&&!i.length||e.dispatch({effects:this.setHover.of(Array.isArray(i)?i:[i])}))}),(t=>Xe(e.state,t,"hover tooltip")))}else!s||Array.isArray(s)&&!s.length||e.dispatch({effects:this.setHover.of(Array.isArray(s)?s:[s])})}get tooltip(){let e=this.view.plugin(Jn),t=e?e.manager.tooltips.findIndex((e=>e.create==no.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:n,tooltip:o}=this;if(n.length&&o&&!function(e,t){let i=e.getBoundingClientRect();return t.clientX>=i.left-so&&t.clientX<=i.right+so&&t.clientY>=i.top-so&&t.clientY<=i.bottom+so}(o.dom,e)||this.pending){let{pos:o}=n[0]||this.pending,r=null!==(i=null===(t=n[0])||void 0===t?void 0:t.end)&&void 0!==i?i:o;(o==r?this.view.posAtCoords(this.lastMove)==o:function(e,t,i,n,o,r){let s=e.scrollDOM.getBoundingClientRect(),l=e.documentTop+e.documentPadding.top+e.contentHeight;if(s.left>n||s.right<n||s.top>o||Math.min(s.bottom,l)<o)return!1;let a=e.posAtCoords({x:n,y:o},!1);return a>=t&&a<=i}(this.view,o,r,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){let{tooltip:t}=this;t&&t.dom.contains(e.relatedTarget)?this.watchTooltipLeave(t.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const so=4;const lo=n.StateEffect.define(),ao=lo.of(null);const ho=n.Facet.define({combine(e){let t,i;for(let n of e)t=t||n.topContainer,i=i||n.bottomContainer;return{topContainer:t,bottomContainer:i}}});const co=et.fromClass(class{constructor(e){this.input=e.state.facet(po),this.specs=this.input.filter((e=>e)),this.panels=this.specs.map((t=>t(e)));let t=e.state.facet(ho);this.top=new uo(e,!0,t.topContainer),this.bottom=new uo(e,!1,t.bottomContainer),this.top.sync(this.panels.filter((e=>e.top))),this.bottom.sync(this.panels.filter((e=>!e.top)));for(let e of this.panels)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}update(e){let t=e.state.facet(ho);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new uo(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new uo(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=e.state.facet(po);if(i!=this.input){let t=i.filter((e=>e)),n=[],o=[],r=[],s=[];for(let i of t){let t,l=this.specs.indexOf(i);l<0?(t=i(e.view),s.push(t)):(t=this.panels[l],t.update&&t.update(e)),n.push(t),(t.top?o:r).push(t)}this.specs=t,this.panels=n,this.top.sync(o),this.bottom.sync(r);for(let e of s)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>Xi.scrollMargins.of((t=>{let i=t.plugin(e);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}}))});class uo{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(0==this.panels.length)return void(this.dom&&(this.dom.remove(),this.dom=void 0));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 e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=fo(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=fo(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 fo(e){let t=e.nextSibling;return e.remove(),t}const po=n.Facet.define({enables:co});class mo extends n.RangeValue{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}mo.prototype.elementClass="",mo.prototype.toDOM=void 0,mo.prototype.mapMode=n.MapMode.TrackBefore,mo.prototype.startSide=mo.prototype.endSide=-1,mo.prototype.point=!0;const go=n.Facet.define(),vo={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>n.RangeSet.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},wo=n.Facet.define();const yo=n.Facet.define({combine:e=>e.some((e=>e))});function bo(e){let t=[xo];return e&&!1===e.fixed&&t.push(yo.of(!0)),t}const xo=et.fromClass(class{constructor(e){this.view=e,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=e.state.facet(wo).map((t=>new Ao(e,t)));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!e.state.facet(yo),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}update(e){if(this.updateGutters(e)){let t=this.prevViewport,i=e.view.viewport,n=Math.min(t.to,i.to)-Math.max(t.from,i.from);this.syncGutters(n<.8*(i.to-i.from))}e.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(yo)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=e.view.viewport}syncGutters(e){let i=this.dom.nextSibling;e&&this.dom.remove();let o=n.RangeSet.iter(this.view.state.facet(go),this.view.viewport.from),r=[],s=this.gutters.map((e=>new Co(e,this.view.viewport,-this.view.documentPadding.top)));for(let e of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(e.type)){let i=!0;for(let n of e.type)if(n.type==t.BlockType.Text&&i){So(o,r,n.from);for(let e of s)e.line(this.view,n,r);i=!1}else if(n.widget)for(let e of s)e.widget(this.view,n)}else if(e.type==t.BlockType.Text){So(o,r,e.from);for(let t of s)t.line(this.view,e,r)}else if(e.widget)for(let t of s)t.widget(this.view,e);for(let e of s)e.finish();e&&this.view.scrollDOM.insertBefore(this.dom,i)}updateGutters(e){let t=e.startState.facet(wo),i=e.state.facet(wo),o=e.docChanged||e.heightChanged||e.viewportChanged||!n.RangeSet.eq(e.startState.facet(go),e.state.facet(go),e.view.viewport.from,e.view.viewport.to);if(t==i)for(let t of this.gutters)t.update(e)&&(o=!0);else{o=!0;let n=[];for(let o of i){let i=t.indexOf(o);i<0?n.push(new Ao(this.view,o)):(this.gutters[i].update(e),n.push(this.gutters[i]))}for(let e of this.gutters)e.dom.remove(),n.indexOf(e)<0&&e.destroy();for(let e of n)this.dom.appendChild(e.dom);this.gutters=n}return o}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove()}},{provide:e=>Xi.scrollMargins.of((i=>{let n=i.plugin(e);return n&&0!=n.gutters.length&&n.fixed?i.textDirection==t.Direction.LTR?{left:n.dom.offsetWidth*i.scaleX}:{right:n.dom.offsetWidth*i.scaleX}:null}))});function ko(e){return Array.isArray(e)?e:[e]}function So(e,t,i){for(;e.value&&e.from<=i;)e.from==i&&t.push(e.value),e.next()}class Co{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=n.RangeSet.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:n}=this,o=(t.top-this.height)/e.scaleY,r=t.height/e.scaleY;if(this.i==n.elements.length){let t=new Mo(e,r,o,i);n.elements.push(t),n.dom.appendChild(t.dom)}else n.elements[this.i].update(e,r,o,i);this.height=t.bottom,this.i++}line(e,t,i){let n=[];So(this.cursor,n,t.from),i.length&&(n=n.concat(i));let o=this.gutter.config.lineMarker(e,t,n);o&&n.unshift(o);let r=this.gutter;(0!=n.length||r.config.renderEmptyElements)&&this.addElement(e,t,n)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t);i&&this.addElement(e,t,[i])}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Ao{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,(n=>{let o,r=n.target;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let e=r.getBoundingClientRect();o=(e.top+e.bottom)/2}else o=n.clientY;let s=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,s,n)&&n.preventDefault()}));this.markers=ko(t.markers(e)),t.initialSpacer&&(this.spacer=new Mo(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=ko(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let i=e.view.viewport;return!n.RangeSet.eq(this.markers,t,i.from,i.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(e)}destroy(){for(let e of this.elements)e.destroy()}}class Mo{constructor(e,t,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,n)}update(e,t,i,n){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),function(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!e[i].compare(t[i]))return!1;return!0}(this.markers,n)||this.setMarkers(e,n)}setMarkers(e,t){let i="cm-gutterElement",n=this.dom.firstChild;for(let o=0,r=0;;){let s=r,l=o<t.length?t[o++]:null,a=!1;if(l){let e=l.elementClass;e&&(i+=" "+e);for(let e=r;e<this.markers.length;e++)if(this.markers[e].compare(l)){s=e,a=!0;break}}else s=this.markers.length;for(;r<s;){let e=this.markers[r++];if(e.toDOM){e.destroy(n);let t=n.nextSibling;n.remove(),n=t}}if(!l)break;l.toDOM&&(a?n=n.nextSibling:this.dom.insertBefore(l.toDOM(e),n)),a&&r++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}}const Oo=n.Facet.define(),To=n.Facet.define({combine:e=>n.combineConfig(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let e in t){let n=i[e],o=t[e];i[e]=n?(e,t,i)=>n(e,t,i)||o(e,t,i):o}return i}})});class Do extends mo{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Eo(e,t){return e.state.facet(To).formatNumber(t,e.state)}const Po=wo.compute([To],(e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:e=>e.state.facet(Oo),lineMarker:(e,t,i)=>i.some((e=>e.toDOM))?null:new Do(Eo(e,e.state.doc.lineAt(t.from).number)),widgetMarker:()=>null,lineMarkerChange:e=>e.startState.facet(To)!=e.state.facet(To),initialSpacer:e=>new Do(Eo(e,Ro(e.state.doc.lines))),updateSpacer(e,t){let i=Eo(t.view,Ro(t.view.state.doc.lines));return i==e.number?e:new Do(i)},domEventHandlers:e.facet(To).domEventHandlers})));function Ro(e){let t=9;for(;t<e;)t=10*t+9;return t}const Lo=new class extends mo{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},Bo=go.compute(["selection"],(e=>{let t=[],i=-1;for(let n of e.selection.ranges){let o=e.doc.lineAt(n.head).from;o>i&&(i=o,t.push(Lo.range(o)))}return n.RangeSet.of(t)}));const No=new Map;function Io(e){return et.define((t=>({decorations:e.createDeco(t),update(t){this.decorations=e.updateDeco(t,this.decorations)}})),{decorations:e=>e.decorations})}const _o=Io(new Dn({regexp:/\t| +/g,decoration:e=>function(e){let t=No.get(e);return t||No.set(e,t=ce.mark({attributes:"\t"===e?{class:"cm-highlightTab"}:{class:"cm-highlightSpace","data-display":e.replace(/ /g,"·")}})),t}(e[0]),boundary:/\S/}));const Vo=Io(new Dn({regexp:/\s+$/g,decoration:ce.mark({class:"cm-trailingSpace"}),boundary:/\S/}));const Fo={HeightMap:ui,HeightOracle:si,MeasuredHeights:li,QueryType:hi,ChangedRange:dt,computeOrder:Le,moveVisually:Ie};t.BidiSpan=Te,t.BlockInfo=ai,t.Decoration=ce,t.EditorView=Xi,t.GutterMarker=mo,t.MatchDecorator=Dn,t.RectangleMarker=un,t.ViewPlugin=et,t.ViewUpdate=ft,t.WidgetType=le,t.__test=Fo,t.closeHoverTooltips=ao,t.crosshairCursor=function(e={}){let[t,i]=jn[e.key||"Alt"],n=et.fromClass(class{constructor(e){this.view=e,this.isDown=!1}set(e){this.isDown!=e&&(this.isDown=e,this.view.update([]))}},{eventObservers:{keydown(e){this.set(e.keyCode==t||i(e))},keyup(e){e.keyCode!=t&&i(e)||this.set(!1)},mousemove(e){this.set(i(e))}}});return[n,Xi.contentAttributes.of((e=>{var t;return(null===(t=e.plugin(n))||void 0===t?void 0:t.isDown)?Qn:null}))]},t.drawSelection=function(e={}){return[wn.of(e),bn,kn,Cn,Qe.of(!0)]},t.dropCursor=function(){return[Mn,On]},t.getDrawSelectionConfig=function(e){return e.facet(wn)},t.getPanel=function(e,t){let i=e.plugin(co),n=i?i.specs.indexOf(t):-1;return n>-1?i.panels[n]:null},t.getTooltip=function(e,t){let i=e.plugin(Jn);if(!i)return null;let n=i.manager.tooltips.indexOf(t);return n<0?null:i.manager.tooltipViews[n]},t.gutter=function(e){return[bo(),wo.of(Object.assign(Object.assign({},vo),e))]},t.gutterLineClass=go,t.gutters=bo,t.hasHoverTooltips=function(e){return e.facet(io).some((e=>e))},t.highlightActiveLine=function(){return Hn},t.highlightActiveLineGutter=function(){return Bo},t.highlightSpecialChars=function(e={}){return[Bn.of(e),Nn||(Nn=et.fromClass(class{constructor(e){this.view=e,this.decorations=ce.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(Bn)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new Dn({regexp:e.specialChars,decoration:(t,i,o)=>{let{doc:r}=i.state,s=n.codePointAt(t[0],0);if(9==s){let e=r.lineAt(o),t=i.state.tabSize,s=n.countColumn(e.text,t,o-e.from);return ce.replace({widget:new _n((t-s%t)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=ce.replace({widget:new In(e,s)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(Bn);e.startState.facet(Bn)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))]},t.highlightTrailingWhitespace=function(){return Vo},t.highlightWhitespace=function(){return _o},t.hoverTooltip=function(e,t={}){let i=n.StateEffect.define(),o=n.StateField.define({create:()=>[],update(e,o){if(e.length&&(t.hideOnChange&&(o.docChanged||o.selection)?e=[]:t.hideOn&&(e=e.filter((e=>!t.hideOn(o,e)))),o.docChanged)){let t=[];for(let i of e){let e=o.changes.mapPos(i.pos,-1,n.MapMode.TrackDel);if(null!=e){let n=Object.assign(Object.create(null),i);n.pos=e,null!=n.end&&(n.end=o.changes.mapPos(n.end)),t.push(n)}}e=t}for(let t of o.effects)t.is(i)&&(e=t.value),t.is(lo)&&(e=[]);return e},provide:e=>io.from(e)});return[o,et.define((n=>new ro(n,e,o,i,t.hoverTime||300))),oo]},t.keymap=rn,t.layer=gn,t.lineNumberMarkers=Oo,t.lineNumbers=function(e={}){return[To.of(e),bo(),Po]},t.logException=Xe,t.panels=function(e){return e?[ho.of(e)]:[]},t.placeholder=function(e){return et.fromClass(class{constructor(t){this.view=t,this.placeholder=e?ce.set([ce.widget({widget:new Wn(e),side:1}).range(0)]):ce.none}get decorations(){return this.view.state.doc.length?ce.none:this.placeholder}},{decorations:e=>e.decorations})},t.rectangularSelection=function(e){let t=(null==e?void 0:e.eventFilter)||(e=>e.altKey&&0==e.button);return Xi.mouseSelectionStyle.of(((e,i)=>t(i)?Un(e,i):null))},t.repositionTooltips=function(e){let t=e.plugin(Jn);t&&t.maybeMeasure()},t.runScopeHandlers=function(e,t,i){return cn(ln(e.state),t,e,i)},t.scrollPastEnd=function(){return[Vn,nt.of((e=>{var t;return(null===(t=e.plugin(Vn))||void 0===t?void 0:t.attrs)||null}))]},t.showPanel=po,t.showTooltip=to,t.tooltips=function(e={}){return Xn.of(e)}}}]);