0}_computeGridLineItems(e){const t=this.axis,n=this.chart,s=this.options,{grid:a,position:r,border:o}=s,c=a.offset,d=this.isHorizontal(),p=this.ticks.length+(c?1:0),_=Ed(a),y=[],x=o.setContext(this.getContext()),v=x.display?x.width:0,w=v/2,k=function(U){return sl(n,U,v)};let M,O,A,C,P,R,E,L,D,q,B,H;if(r==="top")M=k(this.bottom),R=this.bottom-_,L=M-w,q=k(e.top)+w,H=e.bottom;else if(r==="bottom")M=k(this.top),q=e.top,H=k(e.bottom)-w,R=M+w,L=this.top+_;else if(r==="left")M=k(this.right),P=this.right-_,E=M-w,D=k(e.left)+w,B=e.right;else if(r==="right")M=k(this.left),D=e.left,B=k(e.right)-w,P=M+w,E=this.left+_;else if(t==="x"){if(r==="center")M=k((e.top+e.bottom)/2+.5);else if(pt(r)){const U=Object.keys(r)[0],G=r[U];M=k(this.chart.scales[U].getPixelForValue(G))}q=e.top,H=e.bottom,R=M+w,L=R+_}else if(t==="y"){if(r==="center")M=k((e.left+e.right)/2);else if(pt(r)){const U=Object.keys(r)[0],G=r[U];M=k(this.chart.scales[U].getPixelForValue(G))}P=M-w,E=P-_,D=e.left,B=e.right}const W=dt(s.ticks.maxTicksLimit,p),V=Math.max(1,Math.ceil(p/W));for(O=0;O0&&(Se-=J/2);break}F={left:Se,top:me,width:J+Y.width,height:ce+Y.height,color:V.backdropColor}}w.push({label:A,font:L,textOffset:B,options:{rotation:v,color:G,strokeColor:$,strokeWidth:ie,textAlign:ue,textBaseline:H,translation:[C,P],backdrop:F}})}return w}_getXAxisLabelAlignment(){const{position:e,ticks:t}=this.options;if(-xl(this.labelRotation))return e==="top"?"left":"right";let s="center";return t.align==="start"?s="left":t.align==="end"?s="right":t.align==="inner"&&(s="inner"),s}_getYAxisLabelAlignment(e){const{position:t,ticks:{crossAlign:n,mirror:s,padding:a}}=this.options,r=this._getLabelSizes(),o=e+a,c=r.widest.width;let d,h;return t==="left"?s?(h=this.right+a,n==="near"?d="left":n==="center"?(d="center",h+=c/2):(d="right",h+=c)):(h=this.right-o,n==="near"?d="right":n==="center"?(d="center",h-=c/2):(d="left",h=this.left)):t==="right"?s?(h=this.left+a,n==="near"?d="right":n==="center"?(d="center",h-=c/2):(d="left",h-=c)):(h=this.left+o,n==="near"?d="left":n==="center"?(d="center",h+=c/2):(d="right",h=this.right)):d="right",{textAlign:d,x:h}}_computeLabelArea(){if(this.options.ticks.mirror)return;const e=this.chart,t=this.options.position;if(t==="left"||t==="right")return{top:0,left:this.left,bottom:e.height,right:this.right};if(t==="top"||t==="bottom")return{top:this.top,left:0,bottom:this.bottom,right:e.width}}drawBackground(){const{ctx:e,options:{backgroundColor:t},left:n,top:s,width:a,height:r}=this;t&&(e.save(),e.fillStyle=t,e.fillRect(n,s,a,r),e.restore())}getLineWidthForValue(e){const t=this.options.grid;if(!this._isVisible()||!t.display)return 0;const s=this.ticks.findIndex(a=>a.value===e);return s>=0?t.setContext(this.getContext(s)).lineWidth:0}drawGrid(e){const t=this.options.grid,n=this.ctx,s=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(e));let a,r;const o=(c,d,h)=>{!h.width||!h.color||(n.save(),n.lineWidth=h.width,n.strokeStyle=h.color,n.setLineDash(h.borderDash||[]),n.lineDashOffset=h.borderDashOffset,n.beginPath(),n.moveTo(c.x,c.y),n.lineTo(d.x,d.y),n.stroke(),n.restore())};if(t.display)for(a=0,r=s.length;a{this.draw(a)}}]:[{z:n,draw:a=>{this.drawBackground(),this.drawGrid(a),this.drawTitle()}},{z:s,draw:()=>{this.drawBorder()}},{z:t,draw:a=>{this.drawLabels(a)}}]}getMatchingVisibleMetas(e){const t=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+"AxisID",s=[];let a,r;for(a=0,r=t.length;a{const n=t.split("."),s=n.pop(),a=[i].concat(n).join("."),r=e[t].split("."),o=r.pop(),c=r.join(".");xi.route(a,s,c,o)})}function $Q(i){return"id"in i&&"defaults"in i}class eY{constructor(){this.controllers=new pm(hh,"datasets",!0),this.elements=new pm(br,"elements"),this.plugins=new pm(Object,"plugins"),this.scales=new pm(Ou,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...e){this._each("register",e)}remove(...e){this._each("unregister",e)}addControllers(...e){this._each("register",e,this.controllers)}addElements(...e){this._each("register",e,this.elements)}addPlugins(...e){this._each("register",e,this.plugins)}addScales(...e){this._each("register",e,this.scales)}getController(e){return this._get(e,this.controllers,"controller")}getElement(e){return this._get(e,this.elements,"element")}getPlugin(e){return this._get(e,this.plugins,"plugin")}getScale(e){return this._get(e,this.scales,"scale")}removeControllers(...e){this._each("unregister",e,this.controllers)}removeElements(...e){this._each("unregister",e,this.elements)}removePlugins(...e){this._each("unregister",e,this.plugins)}removeScales(...e){this._each("unregister",e,this.scales)}_each(e,t,n){[...t].forEach(s=>{const a=n||this._getRegistryForType(s);n||a.isForType(s)||a===this.plugins&&s.id?this._exec(e,a,s):jt(s,r=>{const o=n||this._getRegistryForType(r);this._exec(e,o,r)})})}_exec(e,t,n){const s=y2(e);Qt(n["before"+s],[],n),t[e](n),Qt(n["after"+s],[],n)}_getRegistryForType(e){for(let t=0;ta.filter(o=>!r.some(c=>o.plugin.id===c.plugin.id));this._notify(s(t,n),e,"stop"),this._notify(s(n,t),e,"start")}}function iY(i){const e={},t=[],n=Object.keys(ba.plugins.items);for(let a=0;a1&&PT(i[0].toLowerCase());if(n)return n}throw new Error(`Cannot determine type of '${i}' axis. Please provide 'axis' or 'position' option.`)}function LT(i,e,t){if(t[e+"AxisID"]===i)return{axis:e}}function cY(i,e){if(e.data&&e.data.datasets){const t=e.data.datasets.filter(n=>n.xAxisID===i||n.yAxisID===i);if(t.length)return LT(i,"x",t[0])||LT(i,"y",t[0])}return{}}function uY(i,e){const t=El[i.type]||{scales:{}},n=e.scales||{},s=pb(i.type,e),a=Object.create(null);return Object.keys(n).forEach(r=>{const o=n[r];if(!pt(o))return console.error(`Invalid scale configuration for scale: ${r}`);if(o._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${r}`);const c=mb(r,o,cY(r,i),xi.scales[o.type]),d=oY(c,s),h=t.scales||{};a[r]=oh(Object.create(null),[{axis:c},o,h[c],h[d]])}),i.data.datasets.forEach(r=>{const o=r.type||i.type,c=r.indexAxis||pb(o,e),h=(El[o]||{}).scales||{};Object.keys(h).forEach(p=>{const _=rY(p,c),y=r[_+"AxisID"]||_;a[y]=a[y]||Object.create(null),oh(a[y],[{axis:_},n[y],h[p]])})}),Object.keys(a).forEach(r=>{const o=a[r];oh(o,[xi.scales[o.type],xi.scale])}),a}function NL(i){const e=i.options||(i.options={});e.plugins=dt(e.plugins,{}),e.scales=uY(i,e)}function RL(i){return i=i||{},i.datasets=i.datasets||[],i.labels=i.labels||[],i}function dY(i){return i=i||{},i.data=RL(i.data),NL(i),i}const jT=new Map,PL=new Set;function mm(i,e){let t=jT.get(i);return t||(t=e(),jT.set(i,t),PL.add(t)),t}const Dd=(i,e,t)=>{const n=Lg(e,t);n!==void 0&&i.add(n)};class hY{constructor(e){this._config=dY(e),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(e){this._config.type=e}get data(){return this._config.data}set data(e){this._config.data=RL(e)}get options(){return this._config.options}set options(e){this._config.options=e}get plugins(){return this._config.plugins}update(){const e=this._config;this.clearCache(),NL(e)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(e){return mm(e,()=>[[`datasets.${e}`,""]])}datasetAnimationScopeKeys(e,t){return mm(`${e}.transition.${t}`,()=>[[`datasets.${e}.transitions.${t}`,`transitions.${t}`],[`datasets.${e}`,""]])}datasetElementScopeKeys(e,t){return mm(`${e}-${t}`,()=>[[`datasets.${e}.elements.${t}`,`datasets.${e}`,`elements.${t}`,""]])}pluginScopeKeys(e){const t=e.id,n=this.type;return mm(`${n}-plugin-${t}`,()=>[[`plugins.${t}`,...e.additionalOptionScopes||[]]])}_cachedScopes(e,t){const n=this._scopeCache;let s=n.get(e);return(!s||t)&&(s=new Map,n.set(e,s)),s}getOptionScopes(e,t,n){const{options:s,type:a}=this,r=this._cachedScopes(e,n),o=r.get(t);if(o)return o;const c=new Set;t.forEach(h=>{e&&(c.add(e),h.forEach(p=>Dd(c,e,p))),h.forEach(p=>Dd(c,s,p)),h.forEach(p=>Dd(c,El[a]||{},p)),h.forEach(p=>Dd(c,xi,p)),h.forEach(p=>Dd(c,db,p))});const d=Array.from(c);return d.length===0&&d.push(Object.create(null)),PL.has(t)&&r.set(t,d),d}chartOptionScopes(){const{options:e,type:t}=this;return[e,El[t]||{},xi.datasets[t]||{},{type:t},xi,db]}resolveNamedOptions(e,t,n,s=[""]){const a={$shared:!0},{resolver:r,subPrefixes:o}=ET(this._resolverCache,e,s);let c=r;if(pY(r,t)){a.$shared=!1,n=Ao(n)?n():n;const d=this.createResolver(e,n,o);c=hu(r,n,d)}for(const d of t)a[d]=c[d];return a}createResolver(e,t,n=[""],s){const{resolver:a}=ET(this._resolverCache,e,n);return pt(t)?hu(a,t,void 0,s):a}}function ET(i,e,t){let n=i.get(e);n||(n=new Map,i.set(e,n));const s=t.join();let a=n.get(s);return a||(a={resolver:S2(e,t),subPrefixes:t.filter(o=>!o.toLowerCase().includes("hover"))},n.set(s,a)),a}const fY=i=>pt(i)&&Object.getOwnPropertyNames(i).some(e=>Ao(i[e]));function pY(i,e){const{isScriptable:t,isIndexable:n}=hL(i);for(const s of e){const a=t(s),r=n(s),o=(r||a)&&i[s];if(a&&(Ao(o)||fY(o))||r&&Ui(o))return!0}return!1}var mY="4.5.1";const gY=["top","bottom","left","right","chartArea"];function DT(i,e){return i==="top"||i==="bottom"||gY.indexOf(i)===-1&&e==="x"}function UT(i,e){return function(t,n){return t[i]===n[i]?t[e]-n[e]:t[i]-n[i]}}function FT(i){const e=i.chart,t=e.options.animation;e.notifyPlugins("afterRender"),Qt(t&&t.onComplete,[i],e)}function _Y(i){const e=i.chart,t=e.options.animation;Qt(t&&t.onProgress,[i],e)}function LL(i){return A2()&&typeof i=="string"?i=document.getElementById(i):i&&i.length&&(i=i[0]),i&&i.canvas&&(i=i.canvas),i}const ig={},BT=i=>{const e=LL(i);return Object.values(ig).filter(t=>t.canvas===e).pop()};function yY(i,e,t){const n=Object.keys(i);for(const s of n){const a=+s;if(a>=e){const r=i[s];delete i[s],(t>0||a>e)&&(i[a+t]=r)}}}function xY(i,e,t,n){return!t||i.type==="mouseout"?null:n?e:i}var no;let j0=(no=class{static register(...e){ba.add(...e),zT()}static unregister(...e){ba.remove(...e),zT()}constructor(e,t){const n=this.config=new hY(t),s=LL(e),a=BT(s);if(a)throw new Error("Canvas is already in use. Chart with ID '"+a.id+"' must be destroyed before the canvas with ID '"+a.canvas.id+"' can be reused.");const r=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||UQ(s)),this.platform.updateConfig(n);const o=this.platform.acquireContext(s,r.aspectRatio),c=o&&o.canvas,d=c&&c.height,h=c&&c.width;if(this.id=AX(),this.ctx=o,this.canvas=c,this.width=h,this.height=d,this._options=r,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new tY,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=WX(p=>this.update(p),r.resizeDelay||0),this._dataChanges=[],ig[this.id]=this,!o||!c){console.error("Failed to create chart: can't acquire context from the given item");return}sr.listen(this,"complete",FT),sr.listen(this,"progress",_Y),this._initialize(),this.attached&&this.update()}get aspectRatio(){const{options:{aspectRatio:e,maintainAspectRatio:t},width:n,height:s,_aspectRatio:a}=this;return It(e)?t&&a?a:s?n/s:null:e}get data(){return this.config.data}set data(e){this.config.data=e}get options(){return this._options}set options(e){this.config.options=e}get registry(){return ba}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():dT(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return lT(this.canvas,this.ctx),this}stop(){return sr.stop(this),this}resize(e,t){sr.running(this)?this._resizeBeforeDraw={width:e,height:t}:this._resize(e,t)}_resize(e,t){const n=this.options,s=this.canvas,a=n.maintainAspectRatio&&this.aspectRatio,r=this.platform.getMaximumSize(s,e,t,a),o=n.devicePixelRatio||this.platform.getDevicePixelRatio(),c=this.width?"resize":"attach";this.width=r.width,this.height=r.height,this._aspectRatio=this.aspectRatio,dT(this,o,!0)&&(this.notifyPlugins("resize",{size:r}),Qt(n.onResize,[this,r],this),this.attached&&this._doResize(c)&&this.render())}ensureScalesHaveIDs(){const t=this.options.scales||{};jt(t,(n,s)=>{n.id=s})}buildOrUpdateScales(){const e=this.options,t=e.scales,n=this.scales,s=Object.keys(n).reduce((r,o)=>(r[o]=!1,r),{});let a=[];t&&(a=a.concat(Object.keys(t).map(r=>{const o=t[r],c=mb(r,o),d=c==="r",h=c==="x";return{options:o,dposition:d?"chartArea":h?"bottom":"left",dtype:d?"radialLinear":h?"category":"linear"}}))),jt(a,r=>{const o=r.options,c=o.id,d=mb(c,o),h=dt(o.type,r.dtype);(o.position===void 0||DT(o.position,d)!==DT(r.dposition))&&(o.position=r.dposition),s[c]=!0;let p=null;if(c in n&&n[c].type===h)p=n[c];else{const _=ba.getScale(h);p=new _({id:c,type:h,ctx:this.ctx,chart:this}),n[p.id]=p}p.init(o,e)}),jt(s,(r,o)=>{r||delete n[o]}),jt(n,r=>{Ds.configure(this,r,r.options),Ds.addBox(this,r)})}_updateMetasets(){const e=this._metasets,t=this.data.datasets.length,n=e.length;if(e.sort((s,a)=>s.index-a.index),n>t){for(let s=t;st.length&&delete this._stacks,e.forEach((n,s)=>{t.filter(a=>a===n._dataset).length===0&&this._destroyDatasetMeta(s)})}buildOrUpdateControllers(){const e=[],t=this.data.datasets;let n,s;for(this._removeUnreferencedMetasets(),n=0,s=t.length;n{this.getDatasetMeta(t).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(e){const t=this.config;t.update();const n=this._options=t.createResolver(t.chartOptionScopes(),this.getContext()),s=this._animationsDisabled=!n.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:e,cancelable:!0})===!1)return;const a=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let r=0;for(let d=0,h=this.data.datasets.length;d{d.reset()}),this._updateDatasets(e),this.notifyPlugins("afterUpdate",{mode:e}),this._layers.sort(UT("z","_idx"));const{_active:o,_lastEvent:c}=this;c?this._eventHandler(c,!0):o.length&&this._updateHoverStyles(o,o,!0),this.render()}_updateScales(){jt(this.scales,e=>{Ds.removeBox(this,e)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const e=this.options,t=new Set(Object.keys(this._listeners)),n=new Set(e.events);(!JO(t,n)||!!this._responsiveListeners!==e.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:e}=this,t=this._getUniformDataChanges()||[];for(const{method:n,start:s,count:a}of t){const r=n==="_removeElements"?-a:a;yY(e,s,r)}}_getUniformDataChanges(){const e=this._dataChanges;if(!e||!e.length)return;this._dataChanges=[];const t=this.data.datasets.length,n=a=>new Set(e.filter(r=>r[0]===a).map((r,o)=>o+","+r.splice(1).join(","))),s=n(0);for(let a=1;aa.split(",")).map(a=>({method:a[1],start:+a[2],count:+a[3]}))}_updateLayout(e){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;Ds.update(this,this.width,this.height,e);const t=this.chartArea,n=t.width<=0||t.height<=0;this._layers=[],jt(this.boxes,s=>{n&&s.position==="chartArea"||(s.configure&&s.configure(),this._layers.push(...s._layers()))},this),this._layers.forEach((s,a)=>{s._idx=a}),this.notifyPlugins("afterLayout")}_updateDatasets(e){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:e,cancelable:!0})!==!1){for(let t=0,n=this.data.datasets.length;t=0;--t)this._drawDataset(e[t]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(e){const t=this.ctx,n={meta:e,index:e.index,cancelable:!0},s=SL(this,e);this.notifyPlugins("beforeDatasetDraw",n)!==!1&&(s&&N0(t,s),e.controller.draw(),s&&R0(t),n.cancelable=!1,this.notifyPlugins("afterDatasetDraw",n))}isPointInArea(e){return Dh(e,this.chartArea,this._minPadding)}getElementsAtEventForMode(e,t,n,s){const a=gQ.modes[t];return typeof a=="function"?a(this,e,n,s):[]}getDatasetMeta(e){const t=this.data.datasets[e],n=this._metasets;let s=n.filter(a=>a&&a._dataset===t).pop();return s||(s={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:t&&t.order||0,index:e,_dataset:t,_parsed:[],_sorted:!1},n.push(s)),s}getContext(){return this.$context||(this.$context=Il(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(e){const t=this.data.datasets[e];if(!t)return!1;const n=this.getDatasetMeta(e);return typeof n.hidden=="boolean"?!n.hidden:!t.hidden}setDatasetVisibility(e,t){const n=this.getDatasetMeta(e);n.hidden=!t}toggleDataVisibility(e){this._hiddenIndices[e]=!this._hiddenIndices[e]}getDataVisibility(e){return!this._hiddenIndices[e]}_updateVisibility(e,t,n){const s=n?"show":"hide",a=this.getDatasetMeta(e),r=a.controller._resolveAnimations(void 0,s);jg(t)?(a.data[t].hidden=!n,this.update()):(this.setDatasetVisibility(e,n),r.update(a,{visible:n}),this.update(o=>o.datasetIndex===e?s:void 0))}hide(e,t){this._updateVisibility(e,t,!1)}show(e,t){this._updateVisibility(e,t,!0)}_destroyDatasetMeta(e){const t=this._metasets[e];t&&t.controller&&t.controller._destroy(),delete this._metasets[e]}_stop(){let e,t;for(this.stop(),sr.remove(this),e=0,t=this.data.datasets.length;e{t.addEventListener(this,a,r),e[a]=r},s=(a,r,o)=>{a.offsetX=r,a.offsetY=o,this._eventHandler(a)};jt(this.options.events,a=>n(a,s))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const e=this._responsiveListeners,t=this.platform,n=(c,d)=>{t.addEventListener(this,c,d),e[c]=d},s=(c,d)=>{e[c]&&(t.removeEventListener(this,c,d),delete e[c])},a=(c,d)=>{this.canvas&&this.resize(c,d)};let r;const o=()=>{s("attach",o),this.attached=!0,this.resize(),n("resize",a),n("detach",r)};r=()=>{this.attached=!1,s("resize",a),this._stop(),this._resize(0,0),n("attach",o)},t.isAttached(this.canvas)?o():r()}unbindEvents(){jt(this._listeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._listeners={},jt(this._responsiveListeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._responsiveListeners=void 0}updateHoverStyle(e,t,n){const s=n?"set":"remove";let a,r,o,c;for(t==="dataset"&&(a=this.getDatasetMeta(e[0].datasetIndex),a.controller["_"+s+"DatasetHoverStyle"]()),o=0,c=e.length;o{const o=this.getDatasetMeta(a);if(!o)throw new Error("No dataset found at index "+a);return{datasetIndex:a,element:o.data[r],index:r}});!Rg(n,t)&&(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,t))}notifyPlugins(e,t,n){return this._plugins.notify(this,e,t,n)}isPluginEnabled(e){return this._plugins._cache.filter(t=>t.plugin.id===e).length===1}_updateHoverStyles(e,t,n){const s=this.options.hover,a=(c,d)=>c.filter(h=>!d.some(p=>h.datasetIndex===p.datasetIndex&&h.index===p.index)),r=a(t,e),o=n?e:a(e,t);r.length&&this.updateHoverStyle(r,s.mode,!1),o.length&&s.mode&&this.updateHoverStyle(o,s.mode,!0)}_eventHandler(e,t){const n={event:e,replay:t,cancelable:!0,inChartArea:this.isPointInArea(e)},s=r=>(r.options.events||this.options.events).includes(e.native.type);if(this.notifyPlugins("beforeEvent",n,s)===!1)return;const a=this._handleEvent(e,t,n.inChartArea);return n.cancelable=!1,this.notifyPlugins("afterEvent",n,s),(a||n.changed)&&this.render(),this}_handleEvent(e,t,n){const{_active:s=[],options:a}=this,r=t,o=this._getActiveElements(e,s,n,r),c=RX(e),d=xY(e,this._lastEvent,n,c);n&&(this._lastEvent=null,Qt(a.onHover,[e,o,this],this),c&&Qt(a.onClick,[e,o,this],this));const h=!Rg(o,s);return(h||t)&&(this._active=o,this._updateHoverStyles(o,s,t)),this._lastEvent=d,h}_getActiveElements(e,t,n,s){if(e.type==="mouseout")return[];if(!n)return t;const a=this.options.hover;return this.getElementsAtEventForMode(e,a.mode,a,s)}},Ge(no,"defaults",xi),Ge(no,"instances",ig),Ge(no,"overrides",El),Ge(no,"registry",ba),Ge(no,"version",mY),Ge(no,"getChart",BT),no);function zT(){return jt(j0.instances,i=>i._plugins.invalidate())}function jL(i,e,t=e){i.lineCap=dt(t.borderCapStyle,e.borderCapStyle),i.setLineDash(dt(t.borderDash,e.borderDash)),i.lineDashOffset=dt(t.borderDashOffset,e.borderDashOffset),i.lineJoin=dt(t.borderJoinStyle,e.borderJoinStyle),i.lineWidth=dt(t.borderWidth,e.borderWidth),i.strokeStyle=dt(t.borderColor,e.borderColor)}function bY(i,e,t){i.lineTo(t.x,t.y)}function vY(i){return i.stepped?rG:i.tension||i.cubicInterpolationMode==="monotone"?oG:bY}function EL(i,e,t={}){const n=i.length,{start:s=0,end:a=n-1}=t,{start:r,end:o}=e,c=Math.max(s,r),d=Math.min(a,o),h=so&&a>o;return{count:n,start:c,loop:e.loop,ilen:d(r+(d?o-A:A))%a,O=()=>{v!==w&&(i.lineTo(h,w),i.lineTo(h,v),i.lineTo(h,k))};for(c&&(y=s[M(0)],i.moveTo(y.x,y.y)),_=0;_<=o;++_){if(y=s[M(_)],y.skip)continue;const A=y.x,C=y.y,P=A|0;P===x?(Cw&&(w=C),h=(p*h+A)/++p):(O(),i.lineTo(A,C),x=P,p=0,v=w=C),k=C}O()}function gb(i){const e=i.options,t=e.borderDash&&e.borderDash.length;return!i._decimated&&!i._loop&&!e.tension&&e.cubicInterpolationMode!=="monotone"&&!e.stepped&&!t?wY:SY}function kY(i){return i.stepped?zG:i.tension||i.cubicInterpolationMode==="monotone"?qG:cl}function AY(i,e,t,n){let s=e._path;s||(s=e._path=new Path2D,e.path(s,t,n)&&s.closePath()),jL(i,e.options),i.stroke(s)}function CY(i,e,t,n){const{segments:s,options:a}=e,r=gb(e);for(const o of s)jL(i,a,o.style),i.beginPath(),r(i,e,o,{start:t,end:t+n-1})&&i.closePath(),i.stroke()}const OY=typeof Path2D=="function";function TY(i,e,t,n){OY&&!e.options.segment?AY(i,e,t,n):CY(i,e,t,n)}class po extends br{constructor(e){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,e&&Object.assign(this,e)}updateControlPoints(e,t){const n=this.options;if((n.tension||n.cubicInterpolationMode==="monotone")&&!n.stepped&&!this._pointsUpdated){const s=n.spanGaps?this._loop:this._fullLoop;PG(this._points,n,e,s,t),this._pointsUpdated=!0}}set points(e){this._points=e,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=XG(this,this.options.segment))}first(){const e=this.segments,t=this.points;return e.length&&t[e[0].start]}last(){const e=this.segments,t=this.points,n=e.length;return n&&t[e[n-1].end]}interpolate(e,t){const n=this.options,s=e[t],a=this.points,r=vL(this,{property:t,start:s,end:s});if(!r.length)return;const o=[],c=kY(n);let d,h;for(d=0,h=r.length;de!=="borderDash"&&e!=="fill"});function qT(i,e,t,n){const s=i.options,{[t]:a}=i.getProps([t],n);return Math.abs(e-a){o=E0(r,o,s);const c=s[r],d=s[o];n!==null?(a.push({x:c.x,y:n}),a.push({x:d.x,y:n})):t!==null&&(a.push({x:t,y:c.y}),a.push({x:t,y:d.y}))}),a}function E0(i,e,t){for(;e>i;e--){const n=t[e];if(!isNaN(n.x)&&!isNaN(n.y))break}return e}function HT(i,e,t,n){return i&&e?n(i[t],e[t]):i?i[t]:e?e[t]:0}function DL(i,e){let t=[],n=!1;return Ui(i)?(n=!0,t=i):t=NY(i,e),t.length?new po({points:t,options:{tension:0},_loop:n,_fullLoop:n}):null}function KT(i){return i&&i.fill!==!1}function RY(i,e,t){let s=i[e].fill;const a=[e];let r;if(!t)return s;for(;s!==!1&&a.indexOf(s)===-1;){if(!mn(s))return s;if(r=i[s],!r)return!1;if(r.visible)return s;a.push(s),s=r.fill}return!1}function PY(i,e,t){const n=DY(i);if(pt(n))return isNaN(n.value)?!1:n;let s=parseFloat(n);return mn(s)&&Math.floor(s)===s?LY(n[0],e,s,t):["origin","start","end","stack","shape"].indexOf(n)>=0&&n}function LY(i,e,t,n){return(i==="-"||i==="+")&&(t=e+t),t===e||t<0||t>=n?!1:t}function jY(i,e){let t=null;return i==="start"?t=e.bottom:i==="end"?t=e.top:pt(i)?t=e.getPixelForValue(i.value):e.getBasePixel&&(t=e.getBasePixel()),t}function EY(i,e,t){let n;return i==="start"?n=t:i==="end"?n=e.options.reverse?e.min:e.max:pt(i)?n=i.value:n=e.getBaseValue(),n}function DY(i){const e=i.options,t=e.fill;let n=dt(t&&t.target,t);return n===void 0&&(n=!!e.backgroundColor),n===!1||n===null?!1:n===!0?"origin":n}function UY(i){const{scale:e,index:t,line:n}=i,s=[],a=n.segments,r=n.points,o=FY(e,t);o.push(DL({x:null,y:e.bottom},n));for(let c=0;c=0;--r){const o=s[r].$filler;o&&(o.line.updateControlPoints(a,o.axis),n&&o.fill&&X1(i.ctx,o,a))}},beforeDatasetsDraw(i,e,t){if(t.drawTime!=="beforeDatasetsDraw")return;const n=i.getSortedVisibleDatasetMetas();for(let s=n.length-1;s>=0;--s){const a=n[s].$filler;KT(a)&&X1(i.ctx,a,i.chartArea)}},beforeDatasetDraw(i,e,t){const n=e.meta.$filler;!KT(n)||t.drawTime!=="beforeDatasetDraw"||X1(i.ctx,n,i.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const XT=(i,e)=>{let{boxHeight:t=e,boxWidth:n=e}=i;return i.usePointStyle&&(t=Math.min(t,e),n=i.pointStyleWidth||Math.min(n,e)),{boxWidth:n,boxHeight:t,itemHeight:Math.max(e,t)}},QY=(i,e)=>i!==null&&e!==null&&i.datasetIndex===e.datasetIndex&&i.index===e.index;class GT extends br{constructor(e){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t,n){this.maxWidth=e,this.maxHeight=t,this._margins=n,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const e=this.options.labels||{};let t=Qt(e.generateLabels,[this.chart],this)||[];e.filter&&(t=t.filter(n=>e.filter(n,this.chart.data))),e.sort&&(t=t.sort((n,s)=>e.sort(n,s,this.chart.data))),this.options.reverse&&t.reverse(),this.legendItems=t}fit(){const{options:e,ctx:t}=this;if(!e.display){this.width=this.height=0;return}const n=e.labels,s=hn(n.font),a=s.size,r=this._computeTitleHeight(),{boxWidth:o,itemHeight:c}=XT(n,a);let d,h;t.font=s.string,this.isHorizontal()?(d=this.maxWidth,h=this._fitRows(r,a,o,c)+10):(h=this.maxHeight,d=this._fitCols(r,s,o,c)+10),this.width=Math.min(d,e.maxWidth||this.maxWidth),this.height=Math.min(h,e.maxHeight||this.maxHeight)}_fitRows(e,t,n,s){const{ctx:a,maxWidth:r,options:{labels:{padding:o}}}=this,c=this.legendHitBoxes=[],d=this.lineWidths=[0],h=s+o;let p=e;a.textAlign="left",a.textBaseline="middle";let _=-1,y=-h;return this.legendItems.forEach((x,v)=>{const w=n+t/2+a.measureText(x.text).width;(v===0||d[d.length-1]+w+2*o>r)&&(p+=h,d[d.length-(v>0?0:1)]=0,y+=h,_++),c[v]={left:0,top:y,row:_,width:w,height:s},d[d.length-1]+=w+o}),p}_fitCols(e,t,n,s){const{ctx:a,maxHeight:r,options:{labels:{padding:o}}}=this,c=this.legendHitBoxes=[],d=this.columnSizes=[],h=r-e;let p=o,_=0,y=0,x=0,v=0;return this.legendItems.forEach((w,k)=>{const{itemWidth:M,itemHeight:O}=YY(n,t,a,w,s);k>0&&y+O+2*o>h&&(p+=_+o,d.push({width:_,height:y}),x+=_+o,v++,_=y=0),c[k]={left:x,top:y,col:v,width:M,height:O},_=Math.max(_,M),y+=O+o}),p+=_,d.push({width:_,height:y}),p}adjustHitBoxes(){if(!this.options.display)return;const e=this._computeTitleHeight(),{legendHitBoxes:t,options:{align:n,labels:{padding:s},rtl:a}}=this,r=Zc(a,this.left,this.width);if(this.isHorizontal()){let o=0,c=on(n,this.left+s,this.right-this.lineWidths[o]);for(const d of t)o!==d.row&&(o=d.row,c=on(n,this.left+s,this.right-this.lineWidths[o])),d.top+=this.top+e+s,d.left=r.leftForLtr(r.x(c),d.width),c+=d.width+s}else{let o=0,c=on(n,this.top+e+s,this.bottom-this.columnSizes[o].height);for(const d of t)d.col!==o&&(o=d.col,c=on(n,this.top+e+s,this.bottom-this.columnSizes[o].height)),d.top=c,d.left+=this.left+s,d.left=r.leftForLtr(r.x(d.left),d.width),c+=d.height+s}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){const e=this.ctx;N0(e,this),this._draw(),R0(e)}}_draw(){const{options:e,columnSizes:t,lineWidths:n,ctx:s}=this,{align:a,labels:r}=e,o=xi.color,c=Zc(e.rtl,this.left,this.width),d=hn(r.font),{padding:h}=r,p=d.size,_=p/2;let y;this.drawTitle(),s.textAlign=c.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=d.string;const{boxWidth:x,boxHeight:v,itemHeight:w}=XT(r,p),k=function(P,R,E){if(isNaN(x)||x<=0||isNaN(v)||v<0)return;s.save();const L=dt(E.lineWidth,1);if(s.fillStyle=dt(E.fillStyle,o),s.lineCap=dt(E.lineCap,"butt"),s.lineDashOffset=dt(E.lineDashOffset,0),s.lineJoin=dt(E.lineJoin,"miter"),s.lineWidth=L,s.strokeStyle=dt(E.strokeStyle,o),s.setLineDash(dt(E.lineDash,[])),r.usePointStyle){const D={radius:v*Math.SQRT2/2,pointStyle:E.pointStyle,rotation:E.rotation,borderWidth:L},q=c.xPlus(P,x/2),B=R+_;uL(s,D,q,B,r.pointStyleWidth&&x)}else{const D=R+Math.max((p-v)/2,0),q=c.leftForLtr(P,x),B=dh(E.borderRadius);s.beginPath(),Object.values(B).some(H=>H!==0)?fb(s,{x:q,y:D,w:x,h:v,radius:B}):s.rect(q,D,x,v),s.fill(),L!==0&&s.stroke()}s.restore()},M=function(P,R,E){Uh(s,E.text,P,R+w/2,d,{strikethrough:E.hidden,textAlign:c.textAlign(E.textAlign)})},O=this.isHorizontal(),A=this._computeTitleHeight();O?y={x:on(a,this.left+h,this.right-n[0]),y:this.top+h+A,line:0}:y={x:this.left+h,y:on(a,this.top+A+h,this.bottom-t[0].height),line:0},_L(this.ctx,e.textDirection);const C=w+h;this.legendItems.forEach((P,R)=>{s.strokeStyle=P.fontColor,s.fillStyle=P.fontColor;const E=s.measureText(P.text).width,L=c.textAlign(P.textAlign||(P.textAlign=r.textAlign)),D=x+_+E;let q=y.x,B=y.y;c.setWidth(this.width),O?R>0&&q+D+h>this.right&&(B=y.y+=C,y.line++,q=y.x=on(a,this.left+h,this.right-n[y.line])):R>0&&B+C>this.bottom&&(q=y.x=q+t[y.line].width+h,y.line++,B=y.y=on(a,this.top+A+h,this.bottom-t[y.line].height));const H=c.x(q);if(k(H,B,P),q=XX(L,q+x+_,O?q+D:this.right,e.rtl),M(c.x(q),B,P),O)y.x+=D+h;else if(typeof P.text!="string"){const W=d.lineHeight;y.y+=FL(P,W)+h}else y.y+=C}),yL(this.ctx,e.textDirection)}drawTitle(){const e=this.options,t=e.title,n=hn(t.font),s=Hs(t.padding);if(!t.display)return;const a=Zc(e.rtl,this.left,this.width),r=this.ctx,o=t.position,c=n.size/2,d=s.top+c;let h,p=this.left,_=this.width;if(this.isHorizontal())_=Math.max(...this.lineWidths),h=this.top+d,p=on(e.align,p,this.right-_);else{const x=this.columnSizes.reduce((v,w)=>Math.max(v,w.height),0);h=d+on(e.align,this.top,this.bottom-x-e.labels.padding-this._computeTitleHeight())}const y=on(o,p,p+_);r.textAlign=a.textAlign(b2(o)),r.textBaseline="middle",r.strokeStyle=t.color,r.fillStyle=t.color,r.font=n.string,Uh(r,t.text,y,h,n)}_computeTitleHeight(){const e=this.options.title,t=hn(e.font),n=Hs(e.padding);return e.display?t.lineHeight+n.height:0}_getLegendItemAt(e,t){let n,s,a;if(qc(e,this.left,this.right)&&qc(t,this.top,this.bottom)){for(a=this.legendHitBoxes,n=0;na.length>r.length?a:r)),e+t.size/2+n.measureText(s).width}function JY(i,e,t){let n=i;return typeof e.text!="string"&&(n=FL(e,t)),n}function FL(i,e){const t=i.text?i.text.length:0;return e*t}function $Y(i,e){return!!((i==="mousemove"||i==="mouseout")&&(e.onHover||e.onLeave)||e.onClick&&(i==="click"||i==="mouseup"))}var eZ={id:"legend",_element:GT,start(i,e,t){const n=i.legend=new GT({ctx:i.ctx,options:t,chart:i});Ds.configure(i,n,t),Ds.addBox(i,n)},stop(i){Ds.removeBox(i,i.legend),delete i.legend},beforeUpdate(i,e,t){const n=i.legend;Ds.configure(i,n,t),n.options=t},afterUpdate(i){const e=i.legend;e.buildLabels(),e.adjustHitBoxes()},afterEvent(i,e){e.replay||i.legend.handleEvent(e.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(i,e,t){const n=e.datasetIndex,s=t.chart;s.isDatasetVisible(n)?(s.hide(n),e.hidden=!0):(s.show(n),e.hidden=!1)},onHover:null,onLeave:null,labels:{color:i=>i.chart.options.color,boxWidth:40,padding:10,generateLabels(i){const e=i.data.datasets,{labels:{usePointStyle:t,pointStyle:n,textAlign:s,color:a,useBorderRadius:r,borderRadius:o}}=i.legend.options;return i._getSortedDatasetMetas().map(c=>{const d=c.controller.getStyle(t?0:void 0),h=Hs(d.borderWidth);return{text:e[c.index].label,fillStyle:d.backgroundColor,fontColor:a,hidden:!c.visible,lineCap:d.borderCapStyle,lineDash:d.borderDash,lineDashOffset:d.borderDashOffset,lineJoin:d.borderJoinStyle,lineWidth:(h.width+h.height)/4,strokeStyle:d.borderColor,pointStyle:n||d.pointStyle,rotation:d.rotation,textAlign:s||d.textAlign,borderRadius:r&&(o||d.borderRadius),datasetIndex:c.index}},this)}},title:{color:i=>i.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:i=>!i.startsWith("on"),labels:{_scriptable:i=>!["generateLabels","filter","sort"].includes(i)}}};class BL extends br{constructor(e){super(),this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t){const n=this.options;if(this.left=0,this.top=0,!n.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=e,this.height=this.bottom=t;const s=Ui(n.text)?n.text.length:1;this._padding=Hs(n.padding);const a=s*hn(n.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=a:this.width=a}isHorizontal(){const e=this.options.position;return e==="top"||e==="bottom"}_drawArgs(e){const{top:t,left:n,bottom:s,right:a,options:r}=this,o=r.align;let c=0,d,h,p;return this.isHorizontal()?(h=on(o,n,a),p=t+e,d=a-n):(r.position==="left"?(h=n+e,p=on(o,s,t),c=Vi*-.5):(h=a-e,p=on(o,t,s),c=Vi*.5),d=s-t),{titleX:h,titleY:p,maxWidth:d,rotation:c}}draw(){const e=this.ctx,t=this.options;if(!t.display)return;const n=hn(t.font),a=n.lineHeight/2+this._padding.top,{titleX:r,titleY:o,maxWidth:c,rotation:d}=this._drawArgs(a);Uh(e,t.text,0,0,n,{color:t.color,maxWidth:c,rotation:d,textAlign:b2(t.align),textBaseline:"middle",translation:[r,o]})}}function tZ(i,e){const t=new BL({ctx:i.ctx,options:e,chart:i});Ds.configure(i,t,e),Ds.addBox(i,t),i.titleBlock=t}var iZ={id:"title",_element:BL,start(i,e,t){tZ(i,t)},stop(i){const e=i.titleBlock;Ds.removeBox(i,e),delete i.titleBlock},beforeUpdate(i,e,t){const n=i.titleBlock;Ds.configure(i,n,t),n.options=t},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const Gd={average(i){if(!i.length)return!1;let e,t,n=new Set,s=0,a=0;for(e=0,t=i.length;eo+c)/n.size,y:s/a}},nearest(i,e){if(!i.length)return!1;let t=e.x,n=e.y,s=Number.POSITIVE_INFINITY,a,r,o;for(a=0,r=i.length;a-1?i.split(`
@@ -38,7 +38,7 @@ Please change the parent to =0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let s=[],a=null;for(let r=this.toEditorPos(n.rangeStart),o=this.toEditorPos(n.rangeEnd);r{let s=[];for(let a of n.getTextFormats()){let r=a.underlineStyle,o=a.underlineThickness;if(!/none/i.test(r)&&!/none/i.test(o)){let c=this.toEditorPos(a.rangeStart),d=this.toEditorPos(a.rangeEnd);if(c{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:n}=this.composing;this.composing=null,n&&this.reset(e.state)}};for(let n in this.handlers)t.addEventListener(n,this.handlers[n]);this.measureReq={read:n=>{this.editContext.updateControlBounds(n.contentDOM.getBoundingClientRect());let s=Hh(n.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,s=this.pendingContextChange;return e.changes.iterChanges((a,r,o,c,d)=>{if(n)return;let h=d.length-(r-a);if(s&&r>=s.to)if(s.from==a&&s.to==r&&s.insert.eq(d)){s=this.pendingContextChange=null,t+=h,this.to+=h;return}else s=null,this.revertPending(e.state);if(a+=t,r+=t,r<=this.from)this.from+=h,this.to+=h;else if(athis.to||this.to-this.from+d.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(r),d.toString()),this.to+=h}t+=h}),s&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),s=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(n,s)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Ne{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(s=>s.forEach(a=>n(a,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||C$(e.parent)||document,this.viewState=new GM(e.state||ut.create(e)),e.scrollTo&&e.scrollTo.is(Sm)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Hc).map(s=>new $1(s));for(let s of this.plugins)s.update(this);this.observer=new Kee(this),this.inputState=new hee(this),this.inputState.ensureHandlers(this.plugins),this.docView=new MM(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let t=e.length==1&&e[0]instanceof Fi?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,n=!1,s,a=this.state;for(let _ of e){if(_.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=_.state}if(this.destroyed){this.viewState.state=a;return}let r=this.hasFocus,o=0,c=null;e.some(_=>_.annotation(t5))?(this.inputState.notifiedFocused=r,o=1):r!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=r,c=i5(a,r),c||(o=1));let d=this.observer.delayedAndroidKey,h=null;if(d?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(h=null)):this.observer.clear(),a.facet(ut.phrases)!=this.state.facet(ut.phrases))return this.setState(a);s=Kg.create(this,a,e),s.flags|=o;let p=this.viewState.scrollTarget;try{this.updateState=2;for(let _ of e){if(p&&(p=p.map(_.changes)),_.scrollIntoView){let{main:y}=_.state.selection;p=new eu(y.empty?y:xe.cursor(y.head,y.head>y.anchor?-1:1))}for(let y of _.effects)y.is(Sm)&&(p=y.value.clip(this.state))}this.viewState.update(s,p),this.bidiCache=Ig.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),t=this.docView.update(s),this.state.facet(Qd)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(_=>_.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(Tm)!=s.state.facet(Tm)&&(this.viewState.mustMeasureContent=!0),(t||n||p||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!s.empty)for(let _ of this.state.facet(Gb))try{_(s)}catch(y){qn(this.state,y,"update listener")}(c||h)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),h&&!G4(this,h)&&d.force&&$c(this.contentDOM,d.key,d.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new GM(e),this.plugins=e.facet(Hc).map(n=>new $1(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new MM(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(Hc),n=e.state.facet(Hc);if(t!=n){let s=[];for(let a of n){let r=t.indexOf(a);if(r<0)s.push(new $1(a));else{let o=this.plugins[r];o.mustUpdate=e,s.push(o)}}for(let a of this.plugins)a.mustUpdate!=e&&a.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,s=n.scrollTop*this.scaleY,{scrollAnchorPos:a,scrollAnchorHeight:r}=this.viewState;Math.abs(s-this.viewState.scrollTop)>1&&(r=-1),this.viewState.scrollAnchorHeight=-1;try{for(let o=0;;o++){if(r<0)if(m4(n))a=-1,r=this.viewState.heightMap.height;else{let y=this.viewState.scrollAnchorAt(s);a=y.from,r=y.top}this.updateState=1;let c=this.viewState.measure(this);if(!c&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(o>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let d=[];c&4||([this.measureRequests,d]=[d,this.measureRequests]);let h=d.map(y=>{try{return y.read(this)}catch(x){return qn(this.state,x),JM}}),p=Kg.create(this,this.state,[]),_=!1;p.flags|=c,t?t.flags|=c:t=p,this.updateState=2,p.empty||(this.updatePlugins(p),this.inputState.update(p),this.updateAttrs(),_=this.docView.update(p),_&&this.docViewUpdate());for(let y=0;y1||x<-1){s=s+x,n.scrollTop=s/this.scaleY,r=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let o of this.state.facet(Gb))o(t)}get themeClasses(){return $b+" "+(this.state.facet(Jb)?r5:a5)+" "+this.state.facet(Tm)}updateAttrs(){let e=$M(this,z4,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(dr)?"true":"false",class:"cm-content",style:`${Me.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),$M(this,D2,t);let n=this.observer.ignore(()=>{let s=Kb(this.contentDOM,this.contentAttrs,t),a=Kb(this.dom,this.editorAttrs,e);return s||a});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let s of n.effects)if(s.is(Ne.announce)){t&&(this.announceDOM.textContent=""),t=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Qd);let e=this.state.facet(Ne.cspNonce);Co.mount(this.root,this.styleModules.concat(qee).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;tn.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return tx(this,e,jM(this,e,t,n))}moveByGroup(e,t){return tx(this,e,jM(this,e,t,n=>nee(this,e.head,n)))}visualLineSide(e,t){let n=this.bidiSpans(e),s=this.textDirectionAt(e.from),a=n[t?n.length-1:0];return xe.cursor(a.side(t,s)+e.from,a.forward(!t,s)?1:-1)}moveToLineBoundary(e,t,n=!0){return iee(this,e,t,n)}moveVertically(e,t,n){return tx(this,e,see(this,e,t,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),I4(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let s=this.state.doc.lineAt(e),a=this.bidiSpans(s),r=a[go.find(a,e-s.from,-1,t)];return xf(n,r.dir==Zt.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(D4)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Wee)return T4(e.length);let t=this.textDirectionAt(e.from),n;for(let a of this.bidiCache)if(a.from==e.from&&a.dir==t&&(a.fresh||O4(a.isolates,n=TM(this,e))))return a.order;n||(n=TM(this,e));let s=z$(e.text,t,n);return this.bidiCache.push(new Ig(e.from,e.to,t,n,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Me.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{f4(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Sm.of(new eu(typeof e=="number"?xe.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return Sm.of(new eu(xe.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return bi.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return bi.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=Co.newName(),s=[Tm.of(n),Qd.of(ev(`.${n}`,e))];return t&&t.dark&&s.push(Jb.of(!0)),s}static baseTheme(e){return Wl.lowest(Qd.of(ev("."+$b,e,o5)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),s=n&&Ft.get(n)||Ft.get(e);return((t=s==null?void 0:s.rootView)===null||t===void 0?void 0:t.view)||null}}Ne.styleModule=Qd;Ne.inputHandler=j4;Ne.clipboardInputFilter=j2;Ne.clipboardOutputFilter=E2;Ne.scrollHandler=F4;Ne.focusChangeEffect=E4;Ne.perLineTextDirection=D4;Ne.exceptionSink=L4;Ne.updateListener=Gb;Ne.editable=dr;Ne.mouseSelectionStyle=P4;Ne.dragMovesSelection=R4;Ne.clickAddsSelectionRange=N4;Ne.decorations=Kh;Ne.outerDecorations=q4;Ne.atomicRanges=Sf;Ne.bidiIsolatedRanges=H4;Ne.scrollMargins=K4;Ne.darkTheme=Jb;Ne.cspNonce=Le.define({combine:i=>i.length?i[0]:""});Ne.contentAttributes=D2;Ne.editorAttributes=z4;Ne.lineWrapping=Ne.contentAttributes.of({class:"cm-lineWrapping"});Ne.announce=Ze.define();const Wee=4096,JM={};class Ig{constructor(e,t,n,s,a,r){this.from=e,this.to=t,this.dir=n,this.isolates=s,this.fresh=a,this.order=r}static update(e,t){if(t.empty&&!e.some(a=>a.fresh))return e;let n=[],s=e.length?e[e.length-1].dir:Zt.LTR;for(let a=Math.max(0,e.length-10);a=0;s--){let a=n[s],r=typeof a=="function"?a(i):a;r&&Hb(r,t)}return t}const Xee=Me.mac?"mac":Me.windows?"win":Me.linux?"linux":"key";function Gee(i,e){const t=i.split(/-(?!$)/);let n=t[t.length-1];n=="Space"&&(n=" ");let s,a,r,o;for(let c=0;cn.concat(s),[]))),t}function Yee(i,e,t){return c5(l5(i.state),e,i,t)}let oo=null;const Zee=4e3;function Jee(i,e=Xee){let t=Object.create(null),n=Object.create(null),s=(r,o)=>{let c=n[r];if(c==null)n[r]=o;else if(c!=o)throw new Error("Key binding "+r+" is used both as a regular binding and as a multi-stroke prefix")},a=(r,o,c,d,h)=>{var p,_;let y=t[r]||(t[r]=Object.create(null)),x=o.split(/ (?!$)/).map(k=>Gee(k,e));for(let k=1;k{let A=oo={view:O,prefix:M,scope:r};return setTimeout(()=>{oo==A&&(oo=null)},Zee),!0}]})}let v=x.join(" ");s(v,!1);let w=y[v]||(y[v]={preventDefault:!1,stopPropagation:!1,run:((_=(p=y._any)===null||p===void 0?void 0:p.run)===null||_===void 0?void 0:_.slice())||[]});c&&w.run.push(c),d&&(w.preventDefault=!0),h&&(w.stopPropagation=!0)};for(let r of i){let o=r.scope?r.scope.split(" "):["editor"];if(r.any)for(let d of o){let h=t[d]||(t[d]=Object.create(null));h._any||(h._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:p}=r;for(let _ in h)h[_].run.push(y=>p(y,tv))}let c=r[e]||r.key;if(c)for(let d of o)a(d,c,r.run,r.preventDefault,r.stopPropagation),r.shift&&a(d,"Shift-"+c,r.shift,r.preventDefault,r.stopPropagation)}return t}let tv=null;function c5(i,e,t,n){tv=e;let s=b$(e),a=Un(s,0),r=Aa(a)==s.length&&s!=" ",o="",c=!1,d=!1,h=!1;oo&&oo.view==t&&oo.scope==n&&(o=oo.prefix+" ",Z4.indexOf(e.keyCode)<0&&(d=!0,oo=null));let p=new Set,_=w=>{if(w){for(let k of w.run)if(!p.has(k)&&(p.add(k),k(t)))return w.stopPropagation&&(h=!0),!0;w.preventDefault&&(w.stopPropagation&&(h=!0),d=!0)}return!1},y=i[n],x,v;return y&&(_(y[o+Mm(s,e,!r)])?c=!0:r&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Me.windows&&e.ctrlKey&&e.altKey)&&!(Me.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(x=Oo[e.keyCode])&&x!=s?(_(y[o+Mm(x,e,!0)])||e.shiftKey&&(v=qh[e.keyCode])!=s&&v!=x&&_(y[o+Mm(v,e,!1)]))&&(c=!0):r&&e.shiftKey&&_(y[o+Mm(s,e,!0)])&&(c=!0),!c&&_(y._any)&&(c=!0)),d&&(c=!0),c&&h&&e.stopPropagation(),tv=null,c}class kf{constructor(e,t,n,s,a){this.className=e,this.left=t,this.top=n,this.width=s,this.height=a}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(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,t,n){if(n.empty){let s=e.coordsAtPos(n.head,n.assoc||1);if(!s)return[];let a=u5(e);return[new kf(t,s.left-a.left,s.top-a.top,null,s.bottom-s.top)]}else return $ee(e,t,n)}}function u5(i){let e=i.scrollDOM.getBoundingClientRect();return{left:(i.textDirection==Zt.LTR?e.left:e.right-i.scrollDOM.clientWidth*i.scaleX)-i.scrollDOM.scrollLeft*i.scaleX,top:e.top-i.scrollDOM.scrollTop*i.scaleY}}function t3(i,e,t,n){let s=i.coordsAtPos(e,t*2);if(!s)return n;let a=i.dom.getBoundingClientRect(),r=(s.top+s.bottom)/2,o=i.posAtCoords({x:a.left+1,y:r}),c=i.posAtCoords({x:a.right-1,y:r});return o==null||c==null?n:{from:Math.max(n.from,Math.min(o,c)),to:Math.min(n.to,Math.max(o,c))}}function $ee(i,e,t){if(t.to<=i.viewport.from||t.from>=i.viewport.to)return[];let n=Math.max(t.from,i.viewport.from),s=Math.min(t.to,i.viewport.to),a=i.textDirection==Zt.LTR,r=i.contentDOM,o=r.getBoundingClientRect(),c=u5(i),d=r.querySelector(".cm-line"),h=d&&window.getComputedStyle(d),p=o.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),_=o.right-(h?parseInt(h.paddingRight):0),y=Yb(i,n,1),x=Yb(i,s,-1),v=y.type==Cn.Text?y:null,w=x.type==Cn.Text?x:null;if(v&&(i.lineWrapping||y.widgetLineBreaks)&&(v=t3(i,n,1,v)),w&&(i.lineWrapping||x.widgetLineBreaks)&&(w=t3(i,s,-1,w)),v&&w&&v.from==w.from&&v.to==w.to)return M(O(t.from,t.to,v));{let C=v?O(t.from,null,v):A(y,!1),P=w?O(null,t.to,w):A(x,!0),R=[];return(v||y).to<(w||x).from-(v&&w?1:0)||y.widgetLineBreaks>1&&C.bottom+i.defaultLineHeight/2B&&W.from=U)break;ue>V&&q(Math.max(ie,V),C==null&&ie<=B,Math.min(ue,U),P==null&&ue>=H,$.dir)}if(V=G.to+1,V>=U)break}return D.length==0&&q(B,C==null,H,P==null,i.textDirection),{top:E,bottom:L,horizontal:D}}function A(C,P){let R=o.top+(P?C.top:C.bottom);return{top:R,bottom:R,horizontal:[]}}}function ete(i,e){return i.constructor==e.constructor&&i.eq(e)}class tte{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(cg)!=e.state.facet(cg)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(cg);for(;t!ete(t,this.drawn[n]))){let t=this.dom.firstChild,n=0;for(let s of e)s.update&&t&&s.constructor&&this.drawn[n].constructor&&s.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(s.draw(),t);for(;t;){let s=t.nextSibling;t.remove(),t=s}this.drawn=e,Me.safari&&Me.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const cg=Le.define();function d5(i){return[bi.define(e=>new tte(e,i)),cg.of(i)]}const Vh=Le.define({combine(i){return Da(i,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function ite(i={}){return[Vh.of(i),nte,ste,ate,U4.of(!0)]}function h5(i){return i.startState.facet(Vh)!=i.state.facet(Vh)}const nte=d5({above:!0,markers(i){let{state:e}=i,t=e.facet(Vh),n=[];for(let s of e.selection.ranges){let a=s==e.selection.main;if(s.empty||t.drawRangeCursor){let r=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",o=s.empty?s:xe.cursor(s.head,s.head>s.anchor?-1:1);for(let c of kf.forRange(i,r,o))n.push(c)}}return n},update(i,e){i.transactions.some(n=>n.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=h5(i);return t&&i3(i.state,e),i.docChanged||i.selectionSet||t},mount(i,e){i3(e.state,i)},class:"cm-cursorLayer"});function i3(i,e){e.style.animationDuration=i.facet(Vh).cursorBlinkRate+"ms"}const ste=d5({above:!1,markers(i){return i.state.selection.ranges.map(e=>e.empty?[]:kf.forRange(i,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(i,e){return i.docChanged||i.selectionSet||i.viewportChanged||h5(i)},class:"cm-selectionLayer"}),ate=Wl.highest(Ne.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),f5=Ze.define({map(i,e){return i==null?null:e.mapPos(i)}}),Jd=an.define({create(){return null},update(i,e){return i!=null&&(i=e.changes.mapPos(i)),e.effects.reduce((t,n)=>n.is(f5)?n.value:t,i)}}),rte=bi.fromClass(class{constructor(i){this.view=i,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(i){var e;let t=i.state.field(Jd);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(i.startState.field(Jd)!=t||i.docChanged||i.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:i}=this,e=i.state.field(Jd),t=e!=null&&i.coordsAtPos(e);if(!t)return null;let n=i.scrollDOM.getBoundingClientRect();return{left:t.left-n.left+i.scrollDOM.scrollLeft*i.scaleX,top:t.top-n.top+i.scrollDOM.scrollTop*i.scaleY,height:t.bottom-t.top}}drawCursor(i){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;i?(this.cursor.style.left=i.left/e+"px",this.cursor.style.top=i.top/t+"px",this.cursor.style.height=i.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(i){this.view.state.field(Jd)!=i&&this.view.dispatch({effects:f5.of(i)})}},{eventObservers:{dragover(i){this.setDropPos(this.view.posAtCoords({x:i.clientX,y:i.clientY}))},dragleave(i){(i.target==this.view.contentDOM||!this.view.contentDOM.contains(i.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function ote(){return[Jd,rte]}function n3(i,e,t,n,s){e.lastIndex=0;for(let a=i.iterRange(t,n),r=t,o;!a.next().done;r+=a.value.length)if(!a.lineBreak)for(;o=e.exec(a.value);)s(r+o.index,o)}function lte(i,e){let t=i.visibleRanges;if(t.length==1&&t[0].from==i.viewport.from&&t[0].to==i.viewport.to)return t;let n=[];for(let{from:s,to:a}of t)s=Math.max(i.state.doc.lineAt(s).from,s-e),a=Math.min(i.state.doc.lineAt(a).to,a+e),n.length&&n[n.length-1].to>=s?n[n.length-1].to=a:n.push({from:s,to:a});return n}class cte{constructor(e){const{regexp:t,decoration:n,decorate:s,boundary:a,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,s)this.addMatch=(o,c,d,h)=>s(h,d,d+o[0].length,o,c);else if(typeof n=="function")this.addMatch=(o,c,d,h)=>{let p=n(o,c,d);p&&h(d,d+o[0].length,p)};else if(n)this.addMatch=(o,c,d,h)=>h(d,d+o[0].length,n);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=a,this.maxLength=r}createDeco(e){let t=new vr,n=t.add.bind(t);for(let{from:s,to:a}of lte(e,this.maxLength))n3(e.state.doc,this.regexp,s,a,(r,o)=>this.addMatch(o,e,r,n));return t.finish()}updateDeco(e,t){let n=1e9,s=-1;return e.docChanged&&e.changes.iterChanges((a,r,o,c)=>{c>=e.view.viewport.from&&o<=e.view.viewport.to&&(n=Math.min(o,n),s=Math.max(c,s))}),e.viewportMoved||s-n>1e3?this.createDeco(e.view):s>-1?this.updateRange(e.view,t.map(e.changes),n,s):t}updateRange(e,t,n,s){for(let a of e.visibleRanges){let r=Math.max(a.from,n),o=Math.min(a.to,s);if(o>=r){let c=e.state.doc.lineAt(r),d=c.toc.from;r--)if(this.boundary.test(c.text[r-1-c.from])){h=r;break}for(;o_.push(k.range(v,w));if(c==d)for(this.regexp.lastIndex=h-c.from;(y=this.regexp.exec(c.text))&&y.indexthis.addMatch(w,e,v,x));t=t.update({filterFrom:h,filterTo:p,filter:(v,w)=>vp,add:_})}}return t}}const iv=/x/.unicode!=null?"gu":"g",ute=new RegExp(`[\0-\b
--\u2028\u2029\uFEFF-]`,iv),dte={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 sx=null;function hte(){var i;if(sx==null&&typeof document!="undefined"&&document.body){let e=document.body.style;sx=((i=e.tabSize)!==null&&i!==void 0?i:e.MozTabSize)!=null}return sx||!1}const ug=Le.define({combine(i){let e=Da(i,{render:null,specialChars:ute,addSpecialChars:null});return(e.replaceTabs=!hte())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,iv)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,iv)),e}});function fte(i={}){return[ug.of(i),pte()]}let s3=null;function pte(){return s3||(s3=bi.fromClass(class{constructor(i){this.view=i,this.decorations=qe.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(i.state.facet(ug)),this.decorations=this.decorator.createDeco(i)}makeDecorator(i){return new cte({regexp:i.specialChars,decoration:(e,t,n)=>{let{doc:s}=t.state,a=Un(e[0],0);if(a==9){let r=s.lineAt(n),o=t.state.tabSize,c=Tu(r.text,o,n-r.from);return qe.replace({widget:new yte((o-c%o)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[a]||(this.decorationCache[a]=qe.replace({widget:new _te(i,a)}))},boundary:i.replaceTabs?void 0:/[^]/})}update(i){let e=i.state.facet(ug);i.startState.facet(ug)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(i.view)):this.decorations=this.decorator.updateDeco(i,this.decorations)}},{decorations:i=>i.decorations}))}const mte="•";function gte(i){return i>=32?mte:i==10?"":String.fromCharCode(9216+i)}class _te extends Ar{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=gte(this.code),n=e.state.phrase("Control character")+" "+(dte[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,n,t);if(s)return s;let a=document.createElement("span");return a.textContent=t,a.title=n,a.setAttribute("aria-label",n),a.className="cm-specialChar",a}ignoreEvent(){return!1}}class yte extends Ar{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function xte(){return vte}const bte=qe.line({class:"cm-activeLine"}),vte=bi.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.docChanged||i.selectionSet)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=-1,t=[];for(let n of i.state.selection.ranges){let s=i.lineBlockAt(n.head);s.from>e&&(t.push(bte.range(s.from)),e=s.from)}return qe.set(t)}},{decorations:i=>i.decorations});class Ste extends Ar{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?mu(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),s=xf(t[0],n.direction!="rtl"),a=parseInt(n.lineHeight);return s.bottom-s.top>a*1.5?{left:s.left,right:s.right,top:s.top,bottom:s.top+a}:s}ignoreEvent(){return!1}}function wte(i){let e=bi.fromClass(class{constructor(t){this.view=t,this.placeholder=i?qe.set([qe.widget({widget:new Ste(i),side:1}).range(0)]):qe.none}get decorations(){return this.view.state.doc.length?qe.none:this.placeholder}},{decorations:t=>t.decorations});return typeof i=="string"?[e,Ne.contentAttributes.of({"aria-placeholder":i})]:e}const nv=2e3;function kte(i,e,t){let n=Math.min(e.line,t.line),s=Math.max(e.line,t.line),a=[];if(e.off>nv||t.off>nv||e.col<0||t.col<0){let r=Math.min(e.off,t.off),o=Math.max(e.off,t.off);for(let c=n;c<=s;c++){let d=i.doc.line(c);d.length<=o&&a.push(xe.range(d.from+r,d.to+o))}}else{let r=Math.min(e.col,t.col),o=Math.max(e.col,t.col);for(let c=n;c<=s;c++){let d=i.doc.line(c),h=jb(d.text,r,i.tabSize,!0);if(h<0)a.push(xe.cursor(d.to));else{let p=jb(d.text,o,i.tabSize);a.push(xe.range(d.from+h,d.from+p))}}}return a}function Ate(i,e){let t=i.coordsAtPos(i.viewport.from);return t?Math.round(Math.abs((t.left-e)/i.defaultCharacterWidth)):-1}function a3(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1),n=i.state.doc.lineAt(t),s=t-n.from,a=s>nv?-1:s==n.length?Ate(i,e.clientX):Tu(n.text,i.state.tabSize,t-n.from);return{line:n.number,col:a,off:s}}function Cte(i,e){let t=a3(i,e),n=i.state.selection;return t?{update(s){if(s.docChanged){let a=s.changes.mapPos(s.startState.doc.line(t.line).from),r=s.state.doc.lineAt(a);t={line:r.number,col:t.col,off:Math.min(t.off,r.length)},n=n.map(s.changes)}},get(s,a,r){let o=a3(i,s);if(!o)return n;let c=kte(i.state,t,o);return c.length?r?xe.create(c.concat(n.ranges)):xe.create(c):n}}:null}function Ote(i){let e=(t=>t.altKey&&t.button==0);return Ne.mouseSelectionStyle.of((t,n)=>e(n)?Cte(t,n):null)}const Tte={Alt:[18,i=>!!i.altKey],Control:[17,i=>!!i.ctrlKey],Shift:[16,i=>!!i.shiftKey],Meta:[91,i=>!!i.metaKey]},Mte={style:"cursor: crosshair"};function Nte(i={}){let[e,t]=Tte[i.key||"Alt"],n=bi.fromClass(class{constructor(s){this.view=s,this.isDown=!1}set(s){this.isDown!=s&&(this.isDown=s,this.view.update([]))}},{eventObservers:{keydown(s){this.set(s.keyCode==e||t(s))},keyup(s){(s.keyCode==e||!t(s))&&this.set(!1)},mousemove(s){this.set(t(s))}}});return[n,Ne.contentAttributes.of(s=>{var a;return!((a=s.plugin(n))===null||a===void 0)&&a.isDown?Mte:null})]}const Nm="-10000px";class p5{constructor(e,t,n,s){this.facet=t,this.createTooltipView=n,this.removeTooltipView=s,this.input=e.state.facet(t),this.tooltips=this.input.filter(r=>r);let a=null;this.tooltipViews=this.tooltips.map(r=>a=n(r,a))}update(e,t){var n;let s=e.state.facet(this.facet),a=s.filter(c=>c);if(s===this.input){for(let c of this.tooltipViews)c.update&&c.update(e);return!1}let r=[],o=t?[]:null;for(let c=0;ct[d]=c),t.length=o.length),this.input=s,this.tooltips=a,this.tooltipViews=r,!0}}function Rte(i){let e=i.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const ax=Le.define({combine:i=>{var e,t,n;return{position:Me.ios?"absolute":((e=i.find(s=>s.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=i.find(s=>s.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((n=i.find(s=>s.tooltipSpace))===null||n===void 0?void 0:n.tooltipSpace)||Rte}}}),r3=new WeakMap,q2=bi.fromClass(class{constructor(i){this.view=i,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=i.state.facet(ax);this.position=e.position,this.parent=e.parent,this.classes=i.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new p5(i,H2,(t,n)=>this.createTooltip(t,n),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),i.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 i of this.manager.tooltipViews)this.intersectionObserver.observe(i.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(i){i.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(i,this.above);e&&this.observeIntersection();let t=e||i.geometryChanged,n=i.state.facet(ax);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let s of this.manager.tooltipViews)s.dom.style.position=this.position;t=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let s of this.manager.tooltipViews)this.container.appendChild(s.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(i,e){let t=i.create(this.view),n=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),i.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let s=document.createElement("div");s.className="cm-tooltip-arrow",t.dom.appendChild(s)}return t.dom.style.position=this.position,t.dom.style.top=Nm,t.dom.style.left="0px",this.container.insertBefore(t.dom,n),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var i,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let n of this.manager.tooltipViews)n.dom.remove(),(i=n.destroy)===null||i===void 0||i.call(n);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let i=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:a}=this.manager.tooltipViews[0];if(Me.safari){let r=a.getBoundingClientRect();t=Math.abs(r.top+1e4)>1||Math.abs(r.left)>1}else t=!!a.offsetParent&&a.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let a=this.parent.getBoundingClientRect();a.width&&a.height&&(i=a.width/this.parent.offsetWidth,e=a.height/this.parent.offsetHeight)}else({scaleX:i,scaleY:e}=this.view.viewState);let n=this.view.scrollDOM.getBoundingClientRect(),s=U2(this.view);return{visible:{left:n.left+s.left,top:n.top+s.top,right:n.right-s.right,bottom:n.bottom-s.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((a,r)=>{let o=this.manager.tooltipViews[r];return o.getCoords?o.getCoords(a.pos):this.view.coordsAtPos(a.pos)}),size:this.manager.tooltipViews.map(({dom:a})=>a.getBoundingClientRect()),space:this.view.state.facet(ax).tooltipSpace(this.view),scaleX:i,scaleY:e,makeAbsolute:t}}writeMeasure(i){var e;if(i.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let o of this.manager.tooltipViews)o.dom.style.position="absolute"}let{visible:t,space:n,scaleX:s,scaleY:a}=i,r=[];for(let o=0;o=Math.min(t.bottom,n.bottom)||p.rightMath.min(t.right,n.right)+.1)){h.style.top=Nm;continue}let y=c.arrow?d.dom.querySelector(".cm-tooltip-arrow"):null,x=y?7:0,v=_.right-_.left,w=(e=r3.get(d))!==null&&e!==void 0?e:_.bottom-_.top,k=d.offset||Lte,M=this.view.textDirection==Zt.LTR,O=_.width>n.right-n.left?M?n.left:n.right-_.width:M?Math.max(n.left,Math.min(p.left-(y?14:0)+k.x,n.right-v)):Math.min(Math.max(n.left,p.left-v+(y?14:0)-k.x),n.right-v),A=this.above[o];!c.strictSide&&(A?p.top-w-x-k.yn.bottom)&&A==n.bottom-p.bottom>p.top-n.top&&(A=this.above[o]=!A);let C=(A?p.top-n.top:n.bottom-p.bottom)-x;if(CO&&E.topP&&(P=A?E.top-w-2-x:E.bottom+x+2);if(this.position=="absolute"?(h.style.top=(P-i.parent.top)/a+"px",o3(h,(O-i.parent.left)/s)):(h.style.top=P/a+"px",o3(h,O/s)),y){let E=p.left+(M?k.x:-k.x)-(O+14-7);y.style.left=E/s+"px"}d.overlap!==!0&&r.push({left:O,top:P,right:R,bottom:P+w}),h.classList.toggle("cm-tooltip-above",A),h.classList.toggle("cm-tooltip-below",!A),d.positioned&&d.positioned(i.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 i of this.manager.tooltipViews)i.dom.style.top=Nm}},{eventObservers:{scroll(){this.maybeMeasure()}}});function o3(i,e){let t=parseInt(i.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(i.style.left=e+"px")}const Pte=Ne.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),Lte={x:0,y:0},H2=Le.define({enables:[q2,Pte]}),Wg=Le.define({combine:i=>i.reduce((e,t)=>e.concat(t),[])});class z0{static create(e){return new z0(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new p5(e,Wg,(t,n)=>this.createHostedView(t,n),t=>t.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let s=n[e];if(s!==void 0){if(t===void 0)t=s;else if(t!==s)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 jte=H2.compute([Wg],i=>{let e=i.facet(Wg);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var n;return(n=t.end)!==null&&n!==void 0?n:t.pos})),create:z0.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class Ete{constructor(e,t,n,s,a){this.view=e,this.source=t,this.field=n,this.setHover=s,this.hoverTime=a,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;eo.bottom||t.xo.right+e.defaultCharacterWidth)return;let c=e.bidiSpans(e.state.doc.lineAt(s)).find(h=>h.from<=s&&h.to>=s),d=c&&c.dir==Zt.RTL?-1:1;a=t.x{this.pending==o&&(this.pending=null,c&&!(Array.isArray(c)&&!c.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(c)?c:[c])}))},c=>qn(e.state,c,"hover tooltip"))}else r&&!(Array.isArray(r)&&!r.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(r)?r:[r])})}get tooltip(){let e=this.view.plugin(q2),t=e?e.manager.tooltips.findIndex(n=>n.create==z0.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;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:s,tooltip:a}=this;if(s.length&&a&&!Dte(a.dom,e)||this.pending){let{pos:r}=s[0]||this.pending,o=(n=(t=s[0])===null||t===void 0?void 0:t.end)!==null&&n!==void 0?n:r;(r==o?this.view.posAtCoords(this.lastMove)!=r:!Ute(this.view,r,o,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:n}=this;n&&n.dom.contains(e.relatedTarget)?this.watchTooltipLeave(n.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(n.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 Rm=4;function Dte(i,e){let{left:t,right:n,top:s,bottom:a}=i.getBoundingClientRect(),r;if(r=i.querySelector(".cm-tooltip-arrow")){let o=r.getBoundingClientRect();s=Math.min(o.top,s),a=Math.max(o.bottom,a)}return e.clientX>=t-Rm&&e.clientX<=n+Rm&&e.clientY>=s-Rm&&e.clientY<=a+Rm}function Ute(i,e,t,n,s,a){let r=i.scrollDOM.getBoundingClientRect(),o=i.documentTop+i.documentPadding.top+i.contentHeight;if(r.left>n||r.rights||Math.min(r.bottom,o)=e&&c<=t}function Fte(i,e={}){let t=Ze.define(),n=an.define({create(){return[]},update(s,a){if(s.length&&(e.hideOnChange&&(a.docChanged||a.selection)?s=[]:e.hideOn&&(s=s.filter(r=>!e.hideOn(a,r))),a.docChanged)){let r=[];for(let o of s){let c=a.changes.mapPos(o.pos,-1,An.TrackDel);if(c!=null){let d=Object.assign(Object.create(null),o);d.pos=c,d.end!=null&&(d.end=a.changes.mapPos(d.end)),r.push(d)}}s=r}for(let r of a.effects)r.is(t)&&(s=r.value),r.is(Bte)&&(s=[]);return s},provide:s=>Wg.from(s)});return{active:n,extension:[n,bi.define(s=>new Ete(s,i,n,t,e.hoverTime||300)),jte]}}function m5(i,e){let t=i.plugin(q2);if(!t)return null;let n=t.manager.tooltips.indexOf(e);return n<0?null:t.manager.tooltipViews[n]}const Bte=Ze.define(),l3=Le.define({combine(i){let e,t;for(let n of i)e=e||n.topContainer,t=t||n.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Ih(i,e){let t=i.plugin(g5),n=t?t.specs.indexOf(e):-1;return n>-1?t.panels[n]:null}const g5=bi.fromClass(class{constructor(i){this.input=i.state.facet(Wh),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(i));let e=i.state.facet(l3);this.top=new Pm(i,!0,e.topContainer),this.bottom=new Pm(i,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(i){let e=i.state.facet(l3);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Pm(i.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Pm(i.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=i.state.facet(Wh);if(t!=this.input){let n=t.filter(c=>c),s=[],a=[],r=[],o=[];for(let c of n){let d=this.specs.indexOf(c),h;d<0?(h=c(i.view),o.push(h)):(h=this.panels[d],h.update&&h.update(i)),s.push(h),(h.top?a:r).push(h)}this.specs=n,this.panels=s,this.top.sync(a),this.bottom.sync(r);for(let c of o)c.dom.classList.add("cm-panel"),c.mount&&c.mount()}else for(let n of this.panels)n.update&&n.update(i)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:i=>Ne.scrollMargins.of(e=>{let t=e.plugin(i);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class Pm{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=c3(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=c3(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 c3(i){let e=i.nextSibling;return i.remove(),e}const Wh=Le.define({enables:g5});class wr extends Dl{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}wr.prototype.elementClass="";wr.prototype.toDOM=void 0;wr.prototype.mapMode=An.TrackBefore;wr.prototype.startSide=wr.prototype.endSide=-1;wr.prototype.point=!0;const dg=Le.define(),zte=Le.define(),qte={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>mt.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},yh=Le.define();function Hte(i){return[_5(),yh.of(z(z({},qte),i))]}const u3=Le.define({combine:i=>i.some(e=>e)});function _5(i){return[Kte]}const Kte=bi.fromClass(class{constructor(i){this.view=i,this.domAfter=null,this.prevViewport=i.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=i.state.facet(yh).map(e=>new h3(i,e)),this.fixed=!i.state.facet(u3);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),i.scrollDOM.insertBefore(this.dom,i.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(i){if(this.updateGutters(i)){let e=this.prevViewport,t=i.view.viewport,n=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(n<(t.to-t.from)*.8)}if(i.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(u3)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=i.view.viewport}syncGutters(i){let e=this.dom.nextSibling;i&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=mt.iter(this.view.state.facet(dg),this.view.viewport.from),n=[],s=this.gutters.map(a=>new Vte(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(a.type)){let r=!0;for(let o of a.type)if(o.type==Cn.Text&&r){sv(t,n,o.from);for(let c of s)c.line(this.view,o,n);r=!1}else if(o.widget)for(let c of s)c.widget(this.view,o)}else if(a.type==Cn.Text){sv(t,n,a.from);for(let r of s)r.line(this.view,a,n)}else if(a.widget)for(let r of s)r.widget(this.view,a);for(let a of s)a.finish();i&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(i){let e=i.startState.facet(yh),t=i.state.facet(yh),n=i.docChanged||i.heightChanged||i.viewportChanged||!mt.eq(i.startState.facet(dg),i.state.facet(dg),i.view.viewport.from,i.view.viewport.to);if(e==t)for(let s of this.gutters)s.update(i)&&(n=!0);else{n=!0;let s=[];for(let a of t){let r=e.indexOf(a);r<0?s.push(new h3(this.view,a)):(this.gutters[r].update(i),s.push(this.gutters[r]))}for(let a of this.gutters)a.dom.remove(),s.indexOf(a)<0&&a.destroy();for(let a of s)a.config.side=="after"?this.getDOMAfter().appendChild(a.dom):this.dom.appendChild(a.dom);this.gutters=s}return n}destroy(){for(let i of this.gutters)i.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:i=>Ne.scrollMargins.of(e=>{let t=e.plugin(i);if(!t||t.gutters.length==0||!t.fixed)return null;let n=t.dom.offsetWidth*e.scaleX,s=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Zt.LTR?{left:n,right:s}:{right:n,left:s}})});function d3(i){return Array.isArray(i)?i:[i]}function sv(i,e,t){for(;i.value&&i.from<=t;)i.from==t&&e.push(i.value),i.next()}class Vte{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=mt.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:s}=this,a=(t.top-this.height)/e.scaleY,r=t.height/e.scaleY;if(this.i==s.elements.length){let o=new y5(e,r,a,n);s.elements.push(o),s.dom.appendChild(o.dom)}else s.elements[this.i].update(e,r,a,n);this.height=t.bottom,this.i++}line(e,t,n){let s=[];sv(this.cursor,s,t.from),n.length&&(s=s.concat(n));let a=this.gutter.config.lineMarker(e,t,s);a&&s.unshift(a);let r=this.gutter;s.length==0&&!r.config.renderEmptyElements||this.addElement(e,t,s)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),s=n?[n]:null;for(let a of e.state.facet(zte)){let r=a(e,t.widget,t);r&&(s||(s=[])).push(r)}s&&this.addElement(e,t,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class h3{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 n in t.domEventHandlers)this.dom.addEventListener(n,s=>{let a=s.target,r;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let c=a.getBoundingClientRect();r=(c.top+c.bottom)/2}else r=s.clientY;let o=e.lineBlockAtHeight(r-e.documentTop);t.domEventHandlers[n](e,o,s)&&s.preventDefault()});this.markers=d3(t.markers(e)),t.initialSpacer&&(this.spacer=new y5(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=d3(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let n=e.view.viewport;return!mt.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class y5{constructor(e,t,n,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,s)}update(e,t,n,s){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),Ite(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,t){let n="cm-gutterElement",s=this.dom.firstChild;for(let a=0,r=0;;){let o=r,c=aa(o,c,d)||r(o,c,d):r}return n}})}});class rx extends wr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function ox(i,e){return i.state.facet(Kc).formatNumber(e,i.state)}const Gte=yh.compute([Kc],i=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Wte)},lineMarker(e,t,n){return n.some(s=>s.toDOM)?null:new rx(ox(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let s of e.state.facet(Xte)){let a=s(e,t,n);if(a)return a}return null},lineMarkerChange:e=>e.startState.facet(Kc)!=e.state.facet(Kc),initialSpacer(e){return new rx(ox(e,f3(e.state.doc.lines)))},updateSpacer(e,t){let n=ox(t.view,f3(t.view.state.doc.lines));return n==e.number?e:new rx(n)},domEventHandlers:i.facet(Kc).domEventHandlers,side:"before"}));function Qte(i={}){return[Kc.of(i),_5(),Gte]}function f3(i){let e=9;for(;e{let e=[],t=-1;for(let n of i.selection.ranges){let s=i.doc.lineAt(n.head).from;s>t&&(t=s,e.push(Yte.range(s)))}return mt.of(e)});function Jte(){return Zte}const x5=1024;let $te=0;class lx{constructor(e,t){this.from=e,this.to=t}}class nt{constructor(e={}){this.id=$te++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Yn.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}}nt.closedBy=new nt({deserialize:i=>i.split(" ")});nt.openedBy=new nt({deserialize:i=>i.split(" ")});nt.group=new nt({deserialize:i=>i.split(" ")});nt.isolate=new nt({deserialize:i=>{if(i&&i!="rtl"&&i!="ltr"&&i!="auto")throw new RangeError("Invalid value for isolate: "+i);return i||"auto"}});nt.contextHash=new nt({perNode:!0});nt.lookAhead=new nt({perNode:!0});nt.mounted=new nt({perNode:!0});class Xg{constructor(e,t,n){this.tree=e,this.overlay=t,this.parser=n}static get(e){return e&&e.props&&e.props[nt.mounted.id]}}const eie=Object.create(null);class Yn{constructor(e,t,n,s=0){this.name=e,this.props=t,this.id=n,this.flags=s}static define(e){let t=e.props&&e.props.length?Object.create(null):eie,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new Yn(e.name||"",t,e.id,n);if(e.props){for(let a of e.props)if(Array.isArray(a)||(a=a(s)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[a[0].id]=a[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(nt.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let s of n.split(" "))t[s]=e[n];return n=>{for(let s=n.prop(nt.group),a=-1;a<(s?s.length:0);a++){let r=t[a<0?n.name:s[a]];if(r)return r}}}}Yn.none=new Yn("",Object.create(null),0,8);class K2{constructor(e){this.types=e;for(let t=0;t0;for(let c=this.cursor(r|Hi.IncludeAnonymous);;){let d=!1;if(c.from<=a&&c.to>=s&&(!o&&c.type.isAnonymous||t(c)!==!1)){if(c.firstChild())continue;d=!0}for(;d&&n&&(o||!c.type.isAnonymous)&&n(c),!c.nextSibling();){if(!c.parent())return;d=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:W2(Yn.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,s)=>new Ri(this.type,t,n,s,this.propValues),e.makeTree||((t,n,s)=>new Ri(Yn.none,t,n,s)))}static build(e){return sie(e)}}Ri.empty=new Ri(Yn.none,[],[],0);class V2{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new V2(this.buffer,this.index)}}class Mo{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Yn.none}toString(){let e=[];for(let t=0;t0));c=r[c+3]);return o}slice(e,t,n){let s=this.buffer,a=new Uint16Array(t-e),r=0;for(let o=e,c=0;o=e&&te;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function Xh(i,e,t,n){for(var s;i.from==i.to||(t<1?i.from>=e:i.from>e)||(t>-1?i.to<=e:i.to0?o.length:-1;e!=d;e+=t){let h=o[e],p=c[e]+r.from;if(b5(s,n,p,p+h.length)){if(h instanceof Mo){if(a&Hi.ExcludeBuffers)continue;let _=h.findChild(0,h.buffer.length,t,n-p,s);if(_>-1)return new _o(new tie(r,h,e,p),null,_)}else if(a&Hi.IncludeAnonymous||!h.type.isAnonymous||I2(h)){let _;if(!(a&Hi.IgnoreMounts)&&(_=Xg.get(h))&&!_.overlay)return new zs(_.tree,p,e,r);let y=new zs(h,p,e,r);return a&Hi.IncludeAnonymous||!y.type.isAnonymous?y:y.nextChild(t<0?h.children.length-1:0,t,n,s)}}}if(a&Hi.IncludeAnonymous||!r.type.isAnonymous||(r.index>=0?e=r.index+t:e=t<0?-1:r._parent._tree.children.length,r=r._parent,!r))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,n=0){let s;if(!(n&Hi.IgnoreOverlays)&&(s=Xg.get(this._tree))&&s.overlay){let a=e-this.from;for(let{from:r,to:o}of s.overlay)if((t>0?r<=a:r=a:o>a))return new zs(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function m3(i,e,t,n){let s=i.cursor(),a=[];if(!s.firstChild())return a;if(t!=null){for(let r=!1;!r;)if(r=s.type.is(t),!s.nextSibling())return a}for(;;){if(n!=null&&s.type.is(n))return a;if(s.type.is(e)&&a.push(s.node),!s.nextSibling())return n==null?a:[]}}function av(i,e,t=e.length-1){for(let n=i;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}class tie{constructor(e,t,n,s){this.parent=e,this.buffer=t,this.index=n,this.start=s}}class _o extends v5{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.context.start,n);return a<0?null:new _o(this.context,this,a)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,n=0){if(n&Hi.ExcludeBuffers)return null;let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return a<0?null:new _o(this.context,this,a)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new _o(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new _o(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,s=this.index+4,a=n.buffer[this.index+3];if(a>s){let r=n.buffer[this.index+1];e.push(n.slice(s,a,r)),t.push(0)}return new Ri(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function S5(i){if(!i.length)return null;let e=0,t=i[0];for(let a=1;at.from||r.to=e){let o=new zs(r.tree,r.overlay[0].from+a.from,-1,a);(s||(s=[n])).push(Xh(o,e,t,!1))}}return s?S5(s):n}class rv{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof zs)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:s}=this.buffer;return this.type=t||s.set.types[s.buffer[e]],this.from=n+s.buffer[e+1],this.to=n+s.buffer[e+2],!0}yield(e){return e?e instanceof zs?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:s}=this.buffer,a=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.buffer.start,n);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&Hi.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Hi.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Hi.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let s=n<0?0:this.stack[n]+4;if(this.index!=s)return this.yieldBuf(t.findChild(s,this.index,-1,0,4))}else{let s=t.buffer[this.index+3];if(s<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(s)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let a=t+e,r=e<0?-1:n._tree.children.length;a!=r;a+=e){let o=n._tree.children[a];if(this.mode&Hi.IncludeAnonymous||o instanceof Mo||!o.type.isAnonymous||I2(o))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let r=e;r;r=r._parent)if(r.index==s){if(s==this.index)return r;t=r,n=a+1;break e}s=this.stack[--a]}for(let s=n;s=0;a--){if(a<0)return av(this._tree,e,s);let r=n[t.buffer[this.stack[a]]];if(!r.isAnonymous){if(e[s]&&e[s]!=r.name)return!1;s--}}return!0}}function I2(i){return i.children.some(e=>e instanceof Mo||!e.type.isAnonymous||I2(e))}function sie(i){var e;let{buffer:t,nodeSet:n,maxBufferLength:s=x5,reused:a=[],minRepeatType:r=n.types.length}=i,o=Array.isArray(t)?new V2(t,t.length):t,c=n.types,d=0,h=0;function p(C,P,R,E,L,D){let{id:q,start:B,end:H,size:W}=o,V=h,U=d;if(W<0)if(o.next(),W==-1){let F=a[q];R.push(F),E.push(B-C);return}else if(W==-3){d=q;return}else if(W==-4){h=q;return}else throw new RangeError(`Unrecognized record size: ${W}`);let G=c[q],$,ie,ue=B-C;if(H-B<=s&&(ie=w(o.pos-P,L))){let F=new Uint16Array(ie.size-ie.skip),Y=o.pos-ie.size,ce=F.length;for(;o.pos>Y;)ce=k(ie.start,F,ce);$=new Mo(F,H-ie.start,n),ue=ie.start-C}else{let F=o.pos-W;o.next();let Y=[],ce=[],J=q>=r?q:-1,me=0,Se=H;for(;o.pos>F;)J>=0&&o.id==J&&o.size>=0?(o.end<=Se-s&&(x(Y,ce,B,me,o.end,Se,J,V,U),me=Y.length,Se=o.end),o.next()):D>2500?_(B,F,Y,ce):p(B,F,Y,ce,J,D+1);if(J>=0&&me>0&&me-1&&me>0){let Re=y(G,U);$=W2(G,Y,ce,0,Y.length,0,H-B,Re,Re)}else $=v(G,Y,ce,H-B,V-H,U)}R.push($),E.push(ue)}function _(C,P,R,E){let L=[],D=0,q=-1;for(;o.pos>P;){let{id:B,start:H,end:W,size:V}=o;if(V>4)o.next();else{if(q>-1&&H=0;W-=3)B[V++]=L[W],B[V++]=L[W+1]-H,B[V++]=L[W+2]-H,B[V++]=V;R.push(new Mo(B,L[2]-H,n)),E.push(H-C)}}function y(C,P){return(R,E,L)=>{let D=0,q=R.length-1,B,H;if(q>=0&&(B=R[q])instanceof Ri){if(!q&&B.type==C&&B.length==L)return B;(H=B.prop(nt.lookAhead))&&(D=E[q]+B.length+H)}return v(C,R,E,L,D,P)}}function x(C,P,R,E,L,D,q,B,H){let W=[],V=[];for(;C.length>E;)W.push(C.pop()),V.push(P.pop()+R-L);C.push(v(n.types[q],W,V,D-L,B-D,H)),P.push(L-R)}function v(C,P,R,E,L,D,q){if(D){let B=[nt.contextHash,D];q=q?[B].concat(q):[B]}if(L>25){let B=[nt.lookAhead,L];q=q?[B].concat(q):[B]}return new Ri(C,P,R,E,q)}function w(C,P){let R=o.fork(),E=0,L=0,D=0,q=R.end-s,B={size:0,start:0,skip:0};e:for(let H=R.pos-C;R.pos>H;){let W=R.size;if(R.id==P&&W>=0){B.size=E,B.start=L,B.skip=D,D+=4,E+=4,R.next();continue}let V=R.pos-W;if(W<0||V=r?4:0,G=R.start;for(R.next();R.pos>V;){if(R.size<0)if(R.size==-3||R.size==-4)U+=4;else break e;else R.id>=r&&(U+=4);R.next()}L=G,E+=W,D+=U}return(P<0||E==C)&&(B.size=E,B.start=L,B.skip=D),B.size>4?B:void 0}function k(C,P,R){let{id:E,start:L,end:D,size:q}=o;if(o.next(),q>=0&&E4){let H=o.pos-(q-4);for(;o.pos>H;)R=k(C,P,R)}P[--R]=B,P[--R]=D-C,P[--R]=L-C,P[--R]=E}else q==-3?d=E:q==-4&&(h=E);return R}let M=[],O=[];for(;o.pos>0;)p(i.start||0,i.bufferStart||0,M,O,-1,0);let A=(e=i.length)!==null&&e!==void 0?e:M.length?O[0]+M[0].length:0;return new Ri(c[i.topID],M.reverse(),O.reverse(),A)}const g3=new WeakMap;function hg(i,e){if(!i.isAnonymous||e instanceof Mo||e.type!=i)return 1;let t=g3.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=i||!(n instanceof Ri)){t=1;break}t+=hg(i,n)}g3.set(e,t)}return t}function W2(i,e,t,n,s,a,r,o,c){let d=0;for(let x=n;x=h)break;P+=R}if(O==A+1){if(P>h){let R=x[A];y(R.children,R.positions,0,R.children.length,v[A]+M);continue}p.push(x[A])}else{let R=v[O-1]+x[O-1].length-C;p.push(W2(i,x,v,A,O,C,R,null,c))}_.push(C+M-a)}}return y(e,t,n,s,0),(o||c)(p,_,r)}class Rl{constructor(e,t,n,s,a=!1,r=!1){this.from=e,this.to=t,this.tree=n,this.offset=s,this.open=(a?1:0)|(r?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let s=[new Rl(0,e.length,e,0,!1,n)];for(let a of t)a.to>e.length&&s.push(a);return s}static applyChanges(e,t,n=128){if(!t.length)return e;let s=[],a=1,r=e.length?e[0]:null;for(let o=0,c=0,d=0;;o++){let h=o=n)for(;r&&r.from=_.from||p<=_.to||d){let y=Math.max(_.from,c)-d,x=Math.min(_.to,p)-d;_=y>=x?null:new Rl(y,x,_.tree,_.offset+d,o>0,!!h)}if(_&&s.push(_),r.to>p)break;r=anew lx(s.from,s.to)):[new lx(0,0)]:[new lx(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let s=this.startParse(e,t,n);for(;;){let a=s.advance();if(a)return a}}}class aie{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new nt({perNode:!0});let rie=0,cr=class ov{constructor(e,t,n,s){this.name=e,this.set=t,this.base=n,this.modified=s,this.id=rie++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n=typeof e=="string"?e:"?";if(e instanceof ov&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let s=new ov(n,[],null,[]);if(s.set.push(s),t)for(let a of t.set)s.set.push(a);return s}static defineModifier(e){let t=new Gg(e);return n=>n.modified.indexOf(t)>-1?n:Gg.get(n.base||n,n.modified.concat(t).sort((s,a)=>s.id-a.id))}},oie=0;class Gg{constructor(e){this.name=e,this.instances=[],this.id=oie++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(o=>o.base==e&&lie(t,o.modified));if(n)return n;let s=[],a=new cr(e.name,s,e,t);for(let o of t)o.instances.push(a);let r=cie(t);for(let o of e.set)if(!o.modified.length)for(let c of r)s.push(Gg.get(o,c));return a}}function lie(i,e){return i.length==e.length&&i.every((t,n)=>t==e[n])}function cie(i){let e=[[]];for(let t=0;tn.length-t.length)}function k5(i){let e=Object.create(null);for(let t in i){let n=i[t];Array.isArray(n)||(n=[n]);for(let s of t.split(" "))if(s){let a=[],r=2,o=s;for(let p=0;;){if(o=="..."&&p>0&&p+3==s.length){r=1;break}let _=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!_)throw new RangeError("Invalid path: "+s);if(a.push(_[0]=="*"?"":_[0][0]=='"'?JSON.parse(_[0]):_[0]),p+=_[0].length,p==s.length)break;let y=s[p++];if(p==s.length&&y=="!"){r=0;break}if(y!="/")throw new RangeError("Invalid path: "+s);o=s.slice(p)}let c=a.length-1,d=a[c];if(!d)throw new RangeError("Invalid path: "+s);let h=new Gh(n,r,c>0?a.slice(0,c):null);e[d]=h.sort(e[d])}}return A5.add(e)}const A5=new nt({combine(i,e){let t,n,s;for(;i||e;){if(!i||e&&i.depth>=e.depth?(s=e,e=e.next):(s=i,i=i.next),t&&t.mode==s.mode&&!s.context&&!t.context)continue;let a=new Gh(s.tags,s.mode,s.context);t?t.next=a:n=a,t=a}return n}});class Gh{constructor(e,t,n,s){this.tags=e,this.mode=t,this.context=n,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let r=s;for(let o of a)for(let c of o.set){let d=t[c.id];if(d){r=r?r+" "+d:d;break}}return r},scope:n}}function uie(i,e){let t=null;for(let n of i){let s=n.style(e);s&&(t=t?t+" "+s:s)}return t}function die(i,e,t,n=0,s=i.length){let a=new hie(n,Array.isArray(e)?e:[e],t);a.highlightRange(i.cursor(),n,s,"",a.highlighters),a.flush(s)}class hie{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,s,a){let{type:r,from:o,to:c}=e;if(o>=n||c<=t)return;r.isTop&&(a=this.highlighters.filter(y=>!y.scope||y.scope(r)));let d=s,h=fie(e)||Gh.empty,p=uie(a,h.tags);if(p&&(d&&(d+=" "),d+=p,h.mode==1&&(s+=(s?" ":"")+p)),this.startSpan(Math.max(t,o),d),h.opaque)return;let _=e.tree&&e.tree.prop(nt.mounted);if(_&&_.overlay){let y=e.node.enter(_.overlay[0].from+o,1),x=this.highlighters.filter(w=>!w.scope||w.scope(_.tree.type)),v=e.firstChild();for(let w=0,k=o;;w++){let M=w<_.overlay.length?_.overlay[w]:null,O=M?M.from+o:c,A=Math.max(t,k),C=Math.min(n,O);if(A=O||!e.nextSibling())););if(!M||O>n)break;k=M.to+o,k>t&&(this.highlightRange(y.cursor(),Math.max(t,M.from+o),Math.min(n,k),"",x),this.startSpan(Math.min(n,k),d))}v&&e.parent()}else if(e.firstChild()){_&&(s="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,s,a),this.startSpan(Math.min(n,e.to),d)}while(e.nextSibling());e.parent()}}}function fie(i){let e=i.type.prop(A5);for(;e&&e.context&&!i.matchContext(e.context);)e=e.next;return e||null}const Oe=cr.define,jm=Oe(),so=Oe(),_3=Oe(so),y3=Oe(so),ao=Oe(),Em=Oe(ao),cx=Oe(ao),xa=Oe(),rl=Oe(xa),pa=Oe(),ma=Oe(),lv=Oe(),Bd=Oe(lv),Dm=Oe(),le={comment:jm,lineComment:Oe(jm),blockComment:Oe(jm),docComment:Oe(jm),name:so,variableName:Oe(so),typeName:_3,tagName:Oe(_3),propertyName:y3,attributeName:Oe(y3),className:Oe(so),labelName:Oe(so),namespace:Oe(so),macroName:Oe(so),literal:ao,string:Em,docString:Oe(Em),character:Oe(Em),attributeValue:Oe(Em),number:cx,integer:Oe(cx),float:Oe(cx),bool:Oe(ao),regexp:Oe(ao),escape:Oe(ao),color:Oe(ao),url:Oe(ao),keyword:pa,self:Oe(pa),null:Oe(pa),atom:Oe(pa),unit:Oe(pa),modifier:Oe(pa),operatorKeyword:Oe(pa),controlKeyword:Oe(pa),definitionKeyword:Oe(pa),moduleKeyword:Oe(pa),operator:ma,derefOperator:Oe(ma),arithmeticOperator:Oe(ma),logicOperator:Oe(ma),bitwiseOperator:Oe(ma),compareOperator:Oe(ma),updateOperator:Oe(ma),definitionOperator:Oe(ma),typeOperator:Oe(ma),controlOperator:Oe(ma),punctuation:lv,separator:Oe(lv),bracket:Bd,angleBracket:Oe(Bd),squareBracket:Oe(Bd),paren:Oe(Bd),brace:Oe(Bd),content:xa,heading:rl,heading1:Oe(rl),heading2:Oe(rl),heading3:Oe(rl),heading4:Oe(rl),heading5:Oe(rl),heading6:Oe(rl),contentSeparator:Oe(xa),list:Oe(xa),quote:Oe(xa),emphasis:Oe(xa),strong:Oe(xa),link:Oe(xa),monospace:Oe(xa),strikethrough:Oe(xa),inserted:Oe(),deleted:Oe(),changed:Oe(),invalid:Oe(),meta:Dm,documentMeta:Oe(Dm),annotation:Oe(Dm),processingInstruction:Oe(Dm),definition:cr.defineModifier("definition"),constant:cr.defineModifier("constant"),function:cr.defineModifier("function"),standard:cr.defineModifier("standard"),local:cr.defineModifier("local"),special:cr.defineModifier("special")};for(let i in le){let e=le[i];e instanceof cr&&(e.name=i)}C5([{tag:le.link,class:"tok-link"},{tag:le.heading,class:"tok-heading"},{tag:le.emphasis,class:"tok-emphasis"},{tag:le.strong,class:"tok-strong"},{tag:le.keyword,class:"tok-keyword"},{tag:le.atom,class:"tok-atom"},{tag:le.bool,class:"tok-bool"},{tag:le.url,class:"tok-url"},{tag:le.labelName,class:"tok-labelName"},{tag:le.inserted,class:"tok-inserted"},{tag:le.deleted,class:"tok-deleted"},{tag:le.literal,class:"tok-literal"},{tag:le.string,class:"tok-string"},{tag:le.number,class:"tok-number"},{tag:[le.regexp,le.escape,le.special(le.string)],class:"tok-string2"},{tag:le.variableName,class:"tok-variableName"},{tag:le.local(le.variableName),class:"tok-variableName tok-local"},{tag:le.definition(le.variableName),class:"tok-variableName tok-definition"},{tag:le.special(le.variableName),class:"tok-variableName2"},{tag:le.definition(le.propertyName),class:"tok-propertyName tok-definition"},{tag:le.typeName,class:"tok-typeName"},{tag:le.namespace,class:"tok-namespace"},{tag:le.className,class:"tok-className"},{tag:le.macroName,class:"tok-macroName"},{tag:le.propertyName,class:"tok-propertyName"},{tag:le.operator,class:"tok-operator"},{tag:le.comment,class:"tok-comment"},{tag:le.meta,class:"tok-meta"},{tag:le.invalid,class:"tok-invalid"},{tag:le.punctuation,class:"tok-punctuation"}]);var ux;const Vc=new nt;function pie(i){return Le.define({combine:i?e=>e.concat(i):void 0})}const mie=new nt;class Js{constructor(e,t,n=[],s=""){this.data=e,this.name=s,ut.prototype.hasOwnProperty("tree")||Object.defineProperty(ut.prototype,"tree",{get(){return gn(this)}}),this.parser=t,this.extension=[No.of(this),ut.languageData.of((a,r,o)=>{let c=x3(a,r,o),d=c.type.prop(Vc);if(!d)return[];let h=a.facet(d),p=c.type.prop(mie);if(p){let _=c.resolve(r-c.from,o);for(let y of p)if(y.test(_,a)){let x=a.facet(y.facet);return y.type=="replace"?x:x.concat(h)}}return h})].concat(n)}isActiveAt(e,t,n=-1){return x3(e,t,n).type.prop(Vc)==this.data}findRegions(e){let t=e.facet(No);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],s=(a,r)=>{if(a.prop(Vc)==this.data){n.push({from:r,to:r+a.length});return}let o=a.prop(nt.mounted);if(o){if(o.tree.prop(Vc)==this.data){if(o.overlay)for(let c of o.overlay)n.push({from:c.from+r,to:c.to+r});else n.push({from:r,to:r+a.length});return}else if(o.overlay){let c=n.length;if(s(o.tree,o.overlay[0].from+r),n.length>c)return}}for(let c=0;cn.isTop?t:void 0)]}),e.name)}configure(e,t){return new Qg(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function gn(i){let e=i.field(Js.state,!1);return e?e.tree:Ri.empty}class gie{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 n=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let zd=null;class Yg{constructor(e,t,n=[],s,a,r,o,c){this.parser=e,this.state=t,this.fragments=n,this.tree=s,this.treeLen=a,this.viewport=r,this.skipped=o,this.scheduleOn=c,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new Yg(e,t,[],Ri.empty,0,n,[],null)}startParse(){return this.parser.startParse(new gie(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=Ri.empty&&this.isDone(t!=null?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Rl.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=zd;zd=this;try{return e()}finally{zd=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=b3(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:s,treeLen:a,viewport:r,skipped:o}=this;if(this.takeTree(),!e.empty){let c=[];if(e.iterChangedRanges((d,h,p,_)=>c.push({fromA:d,toA:h,fromB:p,toB:_})),n=Rl.applyChanges(n,c),s=Ri.empty,a=0,r={from:e.mapPos(r.from,-1),to:e.mapPos(r.to,1)},this.skipped.length){o=[];for(let d of this.skipped){let h=e.mapPos(d.from,1),p=e.mapPos(d.to,-1);he.from&&(this.fragments=b3(this.fragments,s,a),this.skipped.splice(n--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends w5{createParse(t,n,s){let a=s[0].from,r=s[s.length-1].to;return{parsedPos:a,advance(){let c=zd;if(c){for(let d of s)c.tempSkipped.push(d);e&&(c.scheduleOn=c.scheduleOn?Promise.all([c.scheduleOn,e]):e)}return this.parsedPos=r,new Ri(Yn.none,[],[],r-a)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return zd}}function b3(i,e,t){return Rl.applyChanges(i,[{fromA:e,toA:t,fromB:e,toB:t}])}class xu{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),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new xu(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Yg.create(e.facet(No).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new xu(n)}}Js.state=an.define({create:xu.init,update(i,e){for(let t of e.effects)if(t.is(Js.setState))return t.value;return e.startState.facet(No)!=e.state.facet(No)?xu.init(e.state):i.apply(e)}});let O5=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback!="undefined"&&(O5=i=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(i,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const dx=typeof navigator!="undefined"&&(!((ux=navigator.scheduling)===null||ux===void 0)&&ux.isInputPending)?()=>navigator.scheduling.isInputPending():null,_ie=bi.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(Js.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(Js.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=O5(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnds+1e3,c=a.context.work(()=>dx&&dx()||Date.now()>r,s+(o?0:1e5));this.chunkBudget-=Date.now()-t,(c||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:Js.setState.of(new xu(a.context))})),this.chunkBudget>0&&!(c&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>qn(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),No=Le.define({combine(i){return i.length?i[0]:null},enables:i=>[Js.state,_ie,Ne.contentAttributes.compute([i],e=>{let t=e.facet(i);return t&&t.name?{"data-language":t.name}:{}})]});class yie{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const xie=Le.define(),q0=Le.define({combine:i=>{if(!i.length)return" ";let e=i[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(i[0]));return e}});function Zg(i){let e=i.facet(q0);return e.charCodeAt(0)==9?i.tabSize*e.length:e.length}function Qh(i,e){let t="",n=i.tabSize,s=i.facet(q0)[0];if(s==" "){for(;e>=n;)t+=" ",e-=n;s=" "}for(let a=0;a=e?bie(i,t,e):null}class H0{constructor(e,t={}){this.state=e,this.options=t,this.unit=Zg(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:a}=this.options;return s!=null&&s>=n.from&&s<=n.to?a&&s==e?{text:"",from:e}:(t<0?s-1&&(a+=r-this.countColumn(n,n.search(/\S|$/))),a}countColumn(e,t=e.length){return Tu(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:s}=this.lineAt(e,t),a=this.options.overrideIndentation;if(a){let r=a(s);if(r>-1)return r}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const T5=new nt;function bie(i,e,t){let n=e.resolveStack(t),s=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(s!=n.node){let a=[];for(let r=s;r&&!(r.fromn.node.to||r.from==n.node.from&&r.type==n.node.type);r=r.parent)a.push(r);for(let r=a.length-1;r>=0;r--)n={node:a[r],next:n}}return M5(n,i,t)}function M5(i,e,t){for(let n=i;n;n=n.next){let s=Sie(n.node);if(s)return s(G2.create(e,t,n))}return 0}function vie(i){return i.pos==i.options.simulateBreak&&i.options.simulateDoubleBreak}function Sie(i){let e=i.type.prop(T5);if(e)return e;let t=i.firstChild,n;if(t&&(n=t.type.prop(nt.closedBy))){let s=i.lastChild,a=s&&n.indexOf(s.name)>-1;return r=>N5(r,!0,1,void 0,a&&!vie(r)?s.from:void 0)}return i.parent==null?wie:null}function wie(){return 0}class G2 extends H0{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new G2(e,t,n)}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 n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(kie(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return M5(this.context.next,this.base,this.pos)}}function kie(i,e){for(let t=e;t;t=t.parent)if(i==t)return!0;return!1}function Aie(i){let e=i.node,t=e.childAfter(e.from),n=e.lastChild;if(!t)return null;let s=i.options.simulateBreak,a=i.state.doc.lineAt(t.from),r=s==null||s<=a.from?a.to:Math.min(a.to,s);for(let o=t.to;;){let c=e.childAfter(o);if(!c||c==n)return null;if(!c.type.isSkipped){if(c.from>=r)return null;let d=/^ */.exec(a.text.slice(t.to-a.from))[0].length;return{from:t.from,to:t.to+d}}o=c.to}}function v3({closing:i,align:e=!0,units:t=1}){return n=>N5(n,e,t,i)}function N5(i,e,t,n,s){let a=i.textAfter,r=a.match(/^\s*/)[0].length,o=n&&a.slice(r,r+n.length)==n||s==i.pos+r,c=e?Aie(i):null;return c?o?i.column(c.from):i.column(c.to):i.baseIndent+(o?0:i.unit*t)}const Cie=200;function Oie(){return ut.transactionFilter.of(i=>{if(!i.docChanged||!i.isUserEvent("input.type")&&!i.isUserEvent("input.complete"))return i;let e=i.startState.languageDataAt("indentOnInput",i.startState.selection.main.head);if(!e.length)return i;let t=i.newDoc,{head:n}=i.newSelection.main,s=t.lineAt(n);if(n>s.from+Cie)return i;let a=t.sliceString(s.from,n);if(!e.some(d=>d.test(a)))return i;let{state:r}=i,o=-1,c=[];for(let{head:d}of r.selection.ranges){let h=r.doc.lineAt(d);if(h.from==o)continue;o=h.from;let p=X2(r,h.from);if(p==null)continue;let _=/^\s*/.exec(h.text)[0],y=Qh(r,p);_!=y&&c.push({from:h.from,to:h.from+_.length,insert:y})}return c.length?[i,{changes:c,sequential:!0}]:i})}const Tie=Le.define(),R5=new nt;function Mie(i){let e=i.firstChild,t=i.lastChild;return e&&e.tot)continue;if(a&&o.from=e&&d.to>t&&(a=d)}}return a}function Rie(i){let e=i.lastChild;return e&&e.to==i.to&&e.type.isError}function Jg(i,e,t){for(let n of i.facet(Tie)){let s=n(i,e,t);if(s)return s}return Nie(i,e,t)}function P5(i,e){let t=e.mapPos(i.from,1),n=e.mapPos(i.to,-1);return t>=n?void 0:{from:t,to:n}}const K0=Ze.define({map:P5}),Af=Ze.define({map:P5});function L5(i){let e=[];for(let{head:t}of i.state.selection.ranges)e.some(n=>n.from<=t&&n.to>=t)||e.push(i.lineBlockAt(t));return e}const zl=an.define({create(){return qe.none},update(i,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((t,n)=>i=S3(i,t,n)),i=i.map(e.changes);for(let t of e.effects)if(t.is(K0)&&!Pie(i,t.value.from,t.value.to)){let{preparePlaceholder:n}=e.state.facet(D5),s=n?qe.replace({widget:new Bie(n(e.state,t.value))}):w3;i=i.update({add:[s.range(t.value.from,t.value.to)]})}else t.is(Af)&&(i=i.update({filter:(n,s)=>t.value.from!=n||t.value.to!=s,filterFrom:t.value.from,filterTo:t.value.to}));return e.selection&&(i=S3(i,e.selection.main.head)),i},provide:i=>Ne.decorations.from(i),toJSON(i,e){let t=[];return i.between(0,e.doc.length,(n,s)=>{t.push(n,s)}),t},fromJSON(i){if(!Array.isArray(i)||i.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t{se&&(n=!0)}),n?i.update({filterFrom:e,filterTo:t,filter:(s,a)=>s>=t||a<=e}):i}function $g(i,e,t){var n;let s=null;return(n=i.field(zl,!1))===null||n===void 0||n.between(e,t,(a,r)=>{(!s||s.from>a)&&(s={from:a,to:r})}),s}function Pie(i,e,t){let n=!1;return i.between(e,e,(s,a)=>{s==e&&a==t&&(n=!0)}),n}function j5(i,e){return i.field(zl,!1)?e:e.concat(Ze.appendConfig.of(U5()))}const Lie=i=>{for(let e of L5(i)){let t=Jg(i.state,e.from,e.to);if(t)return i.dispatch({effects:j5(i.state,[K0.of(t),E5(i,t)])}),!0}return!1},jie=i=>{if(!i.state.field(zl,!1))return!1;let e=[];for(let t of L5(i)){let n=$g(i.state,t.from,t.to);n&&e.push(Af.of(n),E5(i,n,!1))}return e.length&&i.dispatch({effects:e}),e.length>0};function E5(i,e,t=!0){let n=i.state.doc.lineAt(e.from).number,s=i.state.doc.lineAt(e.to).number;return Ne.announce.of(`${i.state.phrase(t?"Folded lines":"Unfolded lines")} ${n} ${i.state.phrase("to")} ${s}.`)}const Eie=i=>{let{state:e}=i,t=[];for(let n=0;n{let e=i.state.field(zl,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,i.state.doc.length,(n,s)=>{t.push(Af.of({from:n,to:s}))}),i.dispatch({effects:t}),!0},Uie=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Lie},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:jie},{key:"Ctrl-Alt-[",run:Eie},{key:"Ctrl-Alt-]",run:Die}],Fie={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},D5=Le.define({combine(i){return Da(i,Fie)}});function U5(i){return[zl,Hie]}function F5(i,e){let{state:t}=i,n=t.facet(D5),s=r=>{let o=i.lineBlockAt(i.posAtDOM(r.target)),c=$g(i.state,o.from,o.to);c&&i.dispatch({effects:Af.of(c)}),r.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(i,s,e);let a=document.createElement("span");return a.textContent=n.placeholderText,a.setAttribute("aria-label",t.phrase("folded code")),a.title=t.phrase("unfold"),a.className="cm-foldPlaceholder",a.onclick=s,a}const w3=qe.replace({widget:new class extends Ar{toDOM(i){return F5(i,null)}}});class Bie extends Ar{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return F5(e,this.value)}}const zie={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class hx extends wr{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}}function qie(i={}){let e=z(z({},zie),i),t=new hx(e,!0),n=new hx(e,!1),s=bi.fromClass(class{constructor(r){this.from=r.viewport.from,this.markers=this.buildMarkers(r)}update(r){(r.docChanged||r.viewportChanged||r.startState.facet(No)!=r.state.facet(No)||r.startState.field(zl,!1)!=r.state.field(zl,!1)||gn(r.startState)!=gn(r.state)||e.foldingChanged(r))&&(this.markers=this.buildMarkers(r.view))}buildMarkers(r){let o=new vr;for(let c of r.viewportLineBlocks){let d=$g(r.state,c.from,c.to)?n:Jg(r.state,c.from,c.to)?t:null;d&&o.add(c.from,c.from,d)}return o.finish()}}),{domEventHandlers:a}=e;return[s,Hte({class:"cm-foldGutter",markers(r){var o;return((o=r.plugin(s))===null||o===void 0?void 0:o.markers)||mt.empty},initialSpacer(){return new hx(e,!1)},domEventHandlers:ee(z({},a),{click:(r,o,c)=>{if(a.click&&a.click(r,o,c))return!0;let d=$g(r.state,o.from,o.to);if(d)return r.dispatch({effects:Af.of(d)}),!0;let h=Jg(r.state,o.from,o.to);return h?(r.dispatch({effects:K0.of(h)}),!0):!1}})}),U5()]}const Hie=Ne.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 Cf{constructor(e,t){this.specs=e;let n;function s(o){let c=Co.newName();return(n||(n=Object.create(null)))["."+c]=o,c}const a=typeof t.all=="string"?t.all:t.all?s(t.all):void 0,r=t.scope;this.scope=r instanceof Js?o=>o.prop(Vc)==r.data:r?o=>o==r:void 0,this.style=C5(e.map(o=>({tag:o.tag,class:o.class||s(Object.assign({},o,{tag:null}))})),{all:a}).style,this.module=n?new Co(n):null,this.themeType=t.themeType}static define(e,t){return new Cf(e,t||{})}}const cv=Le.define(),B5=Le.define({combine(i){return i.length?[i[0]]:null}});function fx(i){let e=i.facet(cv);return e.length?e:i.facet(B5)}function z5(i,e){let t=[Vie],n;return i instanceof Cf&&(i.module&&t.push(Ne.styleModule.of(i.module)),n=i.themeType),e!=null&&e.fallback?t.push(B5.of(i)):n?t.push(cv.computeN([Ne.darkTheme],s=>s.facet(Ne.darkTheme)==(n=="dark")?[i]:[])):t.push(cv.of(i)),t}class Kie{constructor(e){this.markCache=Object.create(null),this.tree=gn(e.state),this.decorations=this.buildDeco(e,fx(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=gn(e.state),n=fx(e.state),s=n!=fx(e.startState),{viewport:a}=e.view,r=e.changes.mapPos(this.decoratedTo,1);t.length=a.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=r):(t!=this.tree||e.viewportChanged||s)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=a.to)}buildDeco(e,t){if(!t||!this.tree.length)return qe.none;let n=new vr;for(let{from:s,to:a}of e.visibleRanges)die(this.tree,t,(r,o,c)=>{n.add(r,o,this.markCache[c]||(this.markCache[c]=qe.mark({class:c})))},s,a);return n.finish()}}const Vie=Wl.high(bi.fromClass(Kie,{decorations:i=>i.decorations})),Iie=Cf.define([{tag:le.meta,color:"#404740"},{tag:le.link,textDecoration:"underline"},{tag:le.heading,textDecoration:"underline",fontWeight:"bold"},{tag:le.emphasis,fontStyle:"italic"},{tag:le.strong,fontWeight:"bold"},{tag:le.strikethrough,textDecoration:"line-through"},{tag:le.keyword,color:"#708"},{tag:[le.atom,le.bool,le.url,le.contentSeparator,le.labelName],color:"#219"},{tag:[le.literal,le.inserted],color:"#164"},{tag:[le.string,le.deleted],color:"#a11"},{tag:[le.regexp,le.escape,le.special(le.string)],color:"#e40"},{tag:le.definition(le.variableName),color:"#00f"},{tag:le.local(le.variableName),color:"#30a"},{tag:[le.typeName,le.namespace],color:"#085"},{tag:le.className,color:"#167"},{tag:[le.special(le.variableName),le.macroName],color:"#256"},{tag:le.definition(le.propertyName),color:"#00c"},{tag:le.comment,color:"#940"},{tag:le.invalid,color:"#f00"}]),Wie=Ne.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),q5=1e4,H5="()[]{}",K5=Le.define({combine(i){return Da(i,{afterCursor:!0,brackets:H5,maxScanDistance:q5,renderMatch:Qie})}}),Xie=qe.mark({class:"cm-matchingBracket"}),Gie=qe.mark({class:"cm-nonmatchingBracket"});function Qie(i){let e=[],t=i.matched?Xie:Gie;return e.push(t.range(i.start.from,i.start.to)),i.end&&e.push(t.range(i.end.from,i.end.to)),e}const Yie=an.define({create(){return qe.none},update(i,e){if(!e.docChanged&&!e.selection)return i;let t=[],n=e.state.facet(K5);for(let s of e.state.selection.ranges){if(!s.empty)continue;let a=Ma(e.state,s.head,-1,n)||s.head>0&&Ma(e.state,s.head-1,1,n)||n.afterCursor&&(Ma(e.state,s.head,1,n)||s.headNe.decorations.from(i)}),Zie=[Yie,Wie];function Jie(i={}){return[K5.of(i),Zie]}const $ie=new nt;function uv(i,e,t){let n=i.prop(e<0?nt.openedBy:nt.closedBy);if(n)return n;if(i.name.length==1){let s=t.indexOf(i.name);if(s>-1&&s%2==(e<0?1:0))return[t[s+e]]}return null}function dv(i){let e=i.type.prop($ie);return e?e(i.node):i}function Ma(i,e,t,n={}){let s=n.maxScanDistance||q5,a=n.brackets||H5,r=gn(i),o=r.resolveInner(e,t);for(let c=o;c;c=c.parent){let d=uv(c.type,t,a);if(d&&c.from0?e>=h.from&&eh.from&&e<=h.to))return ene(i,e,t,c,h,d,a)}}return tne(i,e,t,r,o.type,s,a)}function ene(i,e,t,n,s,a,r){let o=n.parent,c={from:s.from,to:s.to},d=0,h=o==null?void 0:o.cursor();if(h&&(t<0?h.childBefore(n.from):h.childAfter(n.to)))do if(t<0?h.to<=n.from:h.from>=n.to){if(d==0&&a.indexOf(h.type.name)>-1&&h.from0)return null;let d={from:t<0?e-1:e,to:t>0?e+1:e},h=i.doc.iterRange(e,t>0?i.doc.length:0),p=0;for(let _=0;!h.next().done&&_<=a;){let y=h.value;t<0&&(_+=y.length);let x=e+_*t;for(let v=t>0?0:y.length-1,w=t>0?y.length:-1;v!=w;v+=t){let k=r.indexOf(y[v]);if(!(k<0||n.resolveInner(x+v,1).type!=s))if(k%2==0==t>0)p++;else{if(p==1)return{start:d,end:{from:x+v,to:x+v+1},matched:k>>1==c>>1};p--}}t>0&&(_+=y.length)}return h.done?{start:d,matched:!1}:null}const ine=Object.create(null),k3=[Yn.none],A3=[],C3=Object.create(null),nne=Object.create(null);for(let[i,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])nne[i]=sne(ine,e);function px(i,e){A3.indexOf(i)>-1||(A3.push(i),console.warn(e))}function sne(i,e){let t=[];for(let o of e.split(" ")){let c=[];for(let d of o.split(".")){let h=i[d]||le[d];h?typeof h=="function"?c.length?c=c.map(h):px(d,`Modifier ${d} used at start of tag`):c.length?px(d,`Tag ${d} used as modifier`):c=Array.isArray(h)?h:[h]:px(d,`Unknown highlighting tag ${d}`)}for(let d of c)t.push(d)}if(!t.length)return 0;let n=e.replace(/ /g,"_"),s=n+" "+t.map(o=>o.id),a=C3[s];if(a)return a.id;let r=C3[s]=Yn.define({id:k3.length,name:n,props:[k5({[n]:t})]});return k3.push(r),r.id}Zt.RTL,Zt.LTR;const ane=i=>{let{state:e}=i,t=e.doc.lineAt(e.selection.main.from),n=Y2(i.state,t.from);return n.line?rne(i):n.block?lne(i):!1};function Q2(i,e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let s=i(e,t);return s?(n(t.update(s)),!0):!1}}const rne=Q2(dne,0),one=Q2(V5,0),lne=Q2((i,e)=>V5(i,e,une(e)),0);function Y2(i,e){let t=i.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const qd=50;function cne(i,{open:e,close:t},n,s){let a=i.sliceDoc(n-qd,n),r=i.sliceDoc(s,s+qd),o=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(r)[0].length,d=a.length-o;if(a.slice(d-e.length,d)==e&&r.slice(c,c+t.length)==t)return{open:{pos:n-o,margin:o&&1},close:{pos:s+c,margin:c&&1}};let h,p;s-n<=2*qd?h=p=i.sliceDoc(n,s):(h=i.sliceDoc(n,n+qd),p=i.sliceDoc(s-qd,s));let _=/^\s*/.exec(h)[0].length,y=/\s*$/.exec(p)[0].length,x=p.length-y-t.length;return h.slice(_,_+e.length)==e&&p.slice(x,x+t.length)==t?{open:{pos:n+_+e.length,margin:/\s/.test(h.charAt(_+e.length))?1:0},close:{pos:s-y-t.length,margin:/\s/.test(p.charAt(x-1))?1:0}}:null}function une(i){let e=[];for(let t of i.selection.ranges){let n=i.doc.lineAt(t.from),s=t.to<=n.to?n:i.doc.lineAt(t.to);s.from>n.from&&s.from==t.to&&(s=t.to==n.to+1?n:i.doc.lineAt(t.to-1));let a=e.length-1;a>=0&&e[a].to>n.from?e[a].to=s.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:s.to})}return e}function V5(i,e,t=e.selection.ranges){let n=t.map(a=>Y2(e,a.from).block);if(!n.every(a=>a))return null;let s=t.map((a,r)=>cne(e,n[r],a.from,a.to));if(i!=2&&!s.every(a=>a))return{changes:e.changes(t.map((a,r)=>s[r]?[]:[{from:a.from,insert:n[r].open+" "},{from:a.to,insert:" "+n[r].close}]))};if(i!=1&&s.some(a=>a)){let a=[];for(let r=0,o;rs&&(a==r||r>p.from)){s=p.from;let _=/^\s*/.exec(p.text)[0].length,y=_==p.length,x=p.text.slice(_,_+d.length)==d?_:-1;_a.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:o,token:c,indent:d,empty:h,single:p}of n)(p||!h)&&a.push({from:o.from+d,insert:c+" "});let r=e.changes(a);return{changes:r,selection:e.selection.map(r,1)}}else if(i!=1&&n.some(a=>a.comment>=0)){let a=[];for(let{line:r,comment:o,token:c}of n)if(o>=0){let d=r.from+o,h=d+c.length;r.text[h-r.from]==" "&&h++,a.push({from:d,to:h})}return{changes:a}}return null}const hv=Ea.define(),hne=Ea.define(),fne=Le.define(),I5=Le.define({combine(i){return Da(i,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,s)=>e(n,s)||t(n,s)})}}),W5=an.define({create(){return Na.empty},update(i,e){let t=e.state.facet(I5),n=e.annotation(hv);if(n){let c=Hn.fromTransaction(e,n.selection),d=n.side,h=d==0?i.undone:i.done;return c?h=e0(h,h.length,t.minDepth,c):h=Q5(h,e.startState.selection),new Na(d==0?n.rest:h,d==0?h:n.rest)}let s=e.annotation(hne);if((s=="full"||s=="before")&&(i=i.isolate()),e.annotation(Fi.addToHistory)===!1)return e.changes.empty?i:i.addMapping(e.changes.desc);let a=Hn.fromTransaction(e),r=e.annotation(Fi.time),o=e.annotation(Fi.userEvent);return a?i=i.addChanges(a,r,o,t,e):e.selection&&(i=i.addSelection(e.startState.selection,r,o,t.newGroupDelay)),(s=="full"||s=="after")&&(i=i.isolate()),i},toJSON(i){return{done:i.done.map(e=>e.toJSON()),undone:i.undone.map(e=>e.toJSON())}},fromJSON(i){return new Na(i.done.map(Hn.fromJSON),i.undone.map(Hn.fromJSON))}});function pne(i={}){return[W5,I5.of(i),Ne.domEventHandlers({beforeinput(e,t){let n=e.inputType=="historyUndo"?X5:e.inputType=="historyRedo"?fv:null;return n?(e.preventDefault(),n(t)):!1}})]}function V0(i,e){return function({state:t,dispatch:n}){if(!e&&t.readOnly)return!1;let s=t.field(W5,!1);if(!s)return!1;let a=s.pop(i,t,e);return a?(n(a),!0):!1}}const X5=V0(0,!1),fv=V0(1,!1),mne=V0(0,!0),gne=V0(1,!0);class Hn{constructor(e,t,n,s,a){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=s,this.selectionsAfter=a}setSelAfter(e){return new Hn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new Hn(e.changes&&Di.fromJSON(e.changes),[],e.mapped&&Ra.fromJSON(e.mapped),e.startSelection&&xe.fromJSON(e.startSelection),e.selectionsAfter.map(xe.fromJSON))}static fromTransaction(e,t){let n=Us;for(let s of e.startState.facet(fne)){let a=s(e);a.length&&(n=n.concat(a))}return!n.length&&e.changes.empty?null:new Hn(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,Us)}static selection(e){return new Hn(void 0,Us,void 0,void 0,e)}}function e0(i,e,t,n){let s=e+1>t+20?e-t-1:0,a=i.slice(s,e);return a.push(n),a}function _ne(i,e){let t=[],n=!1;return i.iterChangedRanges((s,a)=>t.push(s,a)),e.iterChangedRanges((s,a,r,o)=>{for(let c=0;c=d&&r<=h&&(n=!0)}}),n}function yne(i,e){return i.ranges.length==e.ranges.length&&i.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length===0}function G5(i,e){return i.length?e.length?i.concat(e):i:e}const Us=[],xne=200;function Q5(i,e){if(i.length){let t=i[i.length-1],n=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-xne));return n.length&&n[n.length-1].eq(e)?i:(n.push(e),e0(i,i.length-1,1e9,t.setSelAfter(n)))}else return[Hn.selection([e])]}function bne(i){let e=i[i.length-1],t=i.slice();return t[i.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function mx(i,e){if(!i.length)return i;let t=i.length,n=Us;for(;t;){let s=vne(i[t-1],e,n);if(s.changes&&!s.changes.empty||s.effects.length){let a=i.slice(0,t);return a[t-1]=s,a}else e=s.mapped,t--,n=s.selectionsAfter}return n.length?[Hn.selection(n)]:Us}function vne(i,e,t){let n=G5(i.selectionsAfter.length?i.selectionsAfter.map(o=>o.map(e)):Us,t);if(!i.changes)return Hn.selection(n);let s=i.changes.map(e),a=e.mapDesc(i.changes,!0),r=i.mapped?i.mapped.composeDesc(a):a;return new Hn(s,Ze.mapEffects(i.effects,e),r,i.startSelection.map(a),n)}const Sne=/^(input\.type|delete)($|\.)/;class Na{constructor(e,t,n=0,s=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=s}isolate(){return this.prevTime?new Na(this.done,this.undone):this}addChanges(e,t,n,s,a){let r=this.done,o=r[r.length-1];return o&&o.changes&&!o.changes.empty&&e.changes&&(!n||Sne.test(n))&&(!o.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?i.moveByChar(t,e):I0(t,e))}function yn(i){return i.textDirectionAt(i.state.selection.main.head)==Zt.LTR}const Z5=i=>Y5(i,!yn(i)),J5=i=>Y5(i,yn(i));function $5(i,e){return sa(i,t=>t.empty?i.moveByGroup(t,e):I0(t,e))}const kne=i=>$5(i,!yn(i)),Ane=i=>$5(i,yn(i));function Cne(i,e,t){if(e.type.prop(t))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(i.sliceDoc(e.from,e.to)))||e.firstChild}function W0(i,e,t){let n=gn(i).resolveInner(e.head),s=t?nt.closedBy:nt.openedBy;for(let c=e.head;;){let d=t?n.childAfter(c):n.childBefore(c);if(!d)break;Cne(i,d,s)?n=d:c=t?d.to:d.from}let a=n.type.prop(s),r,o;return a&&(r=t?Ma(i,n.from,1):Ma(i,n.to,-1))&&r.matched?o=t?r.end.to:r.end.from:o=t?n.to:n.from,xe.cursor(o,t?-1:1)}const One=i=>sa(i,e=>W0(i.state,e,!yn(i))),Tne=i=>sa(i,e=>W0(i.state,e,yn(i)));function ej(i,e){return sa(i,t=>{if(!t.empty)return I0(t,e);let n=i.moveVertically(t,e);return n.head!=t.head?n:i.moveToLineBoundary(t,e)})}const tj=i=>ej(i,!1),ij=i=>ej(i,!0);function nj(i){let e=i.scrollDOM.clientHeightr.empty?i.moveVertically(r,e,t.height):I0(r,e));if(s.eq(n.selection))return!1;let a;if(t.selfScroll){let r=i.coordsAtPos(n.selection.main.head),o=i.scrollDOM.getBoundingClientRect(),c=o.top+t.marginTop,d=o.bottom-t.marginBottom;r&&r.top>c&&r.bottomsj(i,!1),pv=i=>sj(i,!0);function Lo(i,e,t){let n=i.lineBlockAt(e.head),s=i.moveToLineBoundary(e,t);if(s.head==e.head&&s.head!=(t?n.to:n.from)&&(s=i.moveToLineBoundary(e,t,!1)),!t&&s.head==n.from&&n.length){let a=/^\s*/.exec(i.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;a&&e.head!=n.from+a&&(s=xe.cursor(n.from+a))}return s}const Mne=i=>sa(i,e=>Lo(i,e,!0)),Nne=i=>sa(i,e=>Lo(i,e,!1)),Rne=i=>sa(i,e=>Lo(i,e,!yn(i))),Pne=i=>sa(i,e=>Lo(i,e,yn(i))),Lne=i=>sa(i,e=>xe.cursor(i.lineBlockAt(e.head).from,1)),jne=i=>sa(i,e=>xe.cursor(i.lineBlockAt(e.head).to,-1));function Ene(i,e,t){let n=!1,s=Mu(i.selection,a=>{let r=Ma(i,a.head,-1)||Ma(i,a.head,1)||a.head>0&&Ma(i,a.head-1,1)||a.headEne(i,e);function Is(i,e){let t=Mu(i.state.selection,n=>{let s=e(n);return xe.range(n.anchor,s.head,s.goalColumn,s.bidiLevel||void 0)});return t.eq(i.state.selection)?!1:(i.dispatch(na(i.state,t)),!0)}function aj(i,e){return Is(i,t=>i.moveByChar(t,e))}const rj=i=>aj(i,!yn(i)),oj=i=>aj(i,yn(i));function lj(i,e){return Is(i,t=>i.moveByGroup(t,e))}const Une=i=>lj(i,!yn(i)),Fne=i=>lj(i,yn(i)),Bne=i=>Is(i,e=>W0(i.state,e,!yn(i))),zne=i=>Is(i,e=>W0(i.state,e,yn(i)));function cj(i,e){return Is(i,t=>i.moveVertically(t,e))}const uj=i=>cj(i,!1),dj=i=>cj(i,!0);function hj(i,e){return Is(i,t=>i.moveVertically(t,e,nj(i).height))}const T3=i=>hj(i,!1),M3=i=>hj(i,!0),qne=i=>Is(i,e=>Lo(i,e,!0)),Hne=i=>Is(i,e=>Lo(i,e,!1)),Kne=i=>Is(i,e=>Lo(i,e,!yn(i))),Vne=i=>Is(i,e=>Lo(i,e,yn(i))),Ine=i=>Is(i,e=>xe.cursor(i.lineBlockAt(e.head).from)),Wne=i=>Is(i,e=>xe.cursor(i.lineBlockAt(e.head).to)),N3=({state:i,dispatch:e})=>(e(na(i,{anchor:0})),!0),R3=({state:i,dispatch:e})=>(e(na(i,{anchor:i.doc.length})),!0),P3=({state:i,dispatch:e})=>(e(na(i,{anchor:i.selection.main.anchor,head:0})),!0),L3=({state:i,dispatch:e})=>(e(na(i,{anchor:i.selection.main.anchor,head:i.doc.length})),!0),Xne=({state:i,dispatch:e})=>(e(i.update({selection:{anchor:0,head:i.doc.length},userEvent:"select"})),!0),Gne=({state:i,dispatch:e})=>{let t=X0(i).map(({from:n,to:s})=>xe.range(n,Math.min(s+1,i.doc.length)));return e(i.update({selection:xe.create(t),userEvent:"select"})),!0},Qne=({state:i,dispatch:e})=>{let t=Mu(i.selection,n=>{let s=gn(i),a=s.resolveStack(n.from,1);if(n.empty){let r=s.resolveStack(n.from,-1);r.node.from>=a.node.from&&r.node.to<=a.node.to&&(a=r)}for(let r=a;r;r=r.next){let{node:o}=r;if((o.from=n.to||o.to>n.to&&o.from<=n.from)&&r.next)return xe.range(o.to,o.from)}return n});return t.eq(i.selection)?!1:(e(na(i,t)),!0)};function fj(i,e){let{state:t}=i,n=t.selection,s=t.selection.ranges.slice();for(let a of t.selection.ranges){let r=t.doc.lineAt(a.head);if(e?r.to0)for(let o=a;;){let c=i.moveVertically(o,e);if(c.headr.to){s.some(d=>d.head==c.head)||s.push(c);break}else{if(c.head==o.head)break;o=c}}}return s.length==n.ranges.length?!1:(i.dispatch(na(t,xe.create(s,s.length-1))),!0)}const Yne=i=>fj(i,!1),Zne=i=>fj(i,!0),Jne=({state:i,dispatch:e})=>{let t=i.selection,n=null;return t.ranges.length>1?n=xe.create([t.main]):t.main.empty||(n=xe.create([xe.cursor(t.main.head)])),n?(e(na(i,n)),!0):!1};function Of(i,e){if(i.state.readOnly)return!1;let t="delete.selection",{state:n}=i,s=n.changeByRange(a=>{let{from:r,to:o}=a;if(r==o){let c=e(a);cr&&(t="delete.forward",c=Um(i,c,!0)),r=Math.min(r,c),o=Math.max(o,c)}else r=Um(i,r,!1),o=Um(i,o,!0);return r==o?{range:a}:{changes:{from:r,to:o},range:xe.cursor(r,rs(i)))n.between(e,e,(s,a)=>{se&&(e=t?a:s)});return e}const pj=(i,e,t)=>Of(i,n=>{let s=n.from,{state:a}=i,r=a.doc.lineAt(s),o,c;if(t&&!e&&s>r.from&&spj(i,!1,!0),mj=i=>pj(i,!0,!1),gj=(i,e)=>Of(i,t=>{let n=t.head,{state:s}=i,a=s.doc.lineAt(n),r=s.charCategorizer(n);for(let o=null;;){if(n==(e?a.to:a.from)){n==t.head&&a.number!=(e?s.doc.lines:1)&&(n+=e?1:-1);break}let c=tn(a.text,n-a.from,e)+a.from,d=a.text.slice(Math.min(n,c)-a.from,Math.max(n,c)-a.from),h=r(d);if(o!=null&&h!=o)break;(d!=" "||n!=t.head)&&(o=h),n=c}return n}),_j=i=>gj(i,!1),$ne=i=>gj(i,!0),ese=i=>Of(i,e=>{let t=i.lineBlockAt(e.head).to;return e.headOf(i,e=>{let t=i.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),ise=i=>Of(i,e=>{let t=i.moveToLineBoundary(e,!0).head;return e.head{if(i.readOnly)return!1;let t=i.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:gt.of(["",""])},range:xe.cursor(n.from)}));return e(i.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},sse=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=i.changeByRange(n=>{if(!n.empty||n.from==0||n.from==i.doc.length)return{range:n};let s=n.from,a=i.doc.lineAt(s),r=s==a.from?s-1:tn(a.text,s-a.from,!1)+a.from,o=s==a.to?s+1:tn(a.text,s-a.from,!0)+a.from;return{changes:{from:r,to:o,insert:i.doc.slice(s,o).append(i.doc.slice(r,s))},range:xe.cursor(o)}});return t.changes.empty?!1:(e(i.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function X0(i){let e=[],t=-1;for(let n of i.selection.ranges){let s=i.doc.lineAt(n.from),a=i.doc.lineAt(n.to);if(!n.empty&&n.to==a.from&&(a=i.doc.lineAt(n.to-1)),t>=s.number){let r=e[e.length-1];r.to=a.to,r.ranges.push(n)}else e.push({from:s.from,to:a.to,ranges:[n]});t=a.number+1}return e}function yj(i,e,t){if(i.readOnly)return!1;let n=[],s=[];for(let a of X0(i)){if(t?a.to==i.doc.length:a.from==0)continue;let r=i.doc.lineAt(t?a.to+1:a.from-1),o=r.length+1;if(t){n.push({from:a.to,to:r.to},{from:a.from,insert:r.text+i.lineBreak});for(let c of a.ranges)s.push(xe.range(Math.min(i.doc.length,c.anchor+o),Math.min(i.doc.length,c.head+o)))}else{n.push({from:r.from,to:a.from},{from:a.to,insert:i.lineBreak+r.text});for(let c of a.ranges)s.push(xe.range(c.anchor-o,c.head-o))}}return n.length?(e(i.update({changes:n,scrollIntoView:!0,selection:xe.create(s,i.selection.mainIndex),userEvent:"move.line"})),!0):!1}const ase=({state:i,dispatch:e})=>yj(i,e,!1),rse=({state:i,dispatch:e})=>yj(i,e,!0);function xj(i,e,t){if(i.readOnly)return!1;let n=[];for(let s of X0(i))t?n.push({from:s.from,insert:i.doc.slice(s.from,s.to)+i.lineBreak}):n.push({from:s.to,insert:i.lineBreak+i.doc.slice(s.from,s.to)});return e(i.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const ose=({state:i,dispatch:e})=>xj(i,e,!1),lse=({state:i,dispatch:e})=>xj(i,e,!0),cse=i=>{if(i.state.readOnly)return!1;let{state:e}=i,t=e.changes(X0(e).map(({from:s,to:a})=>(s>0?s--:a{let a;if(i.lineWrapping){let r=i.lineBlockAt(s.head),o=i.coordsAtPos(s.head,s.assoc||1);o&&(a=r.bottom+i.documentTop-o.bottom+i.defaultLineHeight/2)}return i.moveVertically(s,!0,a)}).map(t);return i.dispatch({changes:t,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function use(i,e){if(/\(\)|\[\]|\{\}/.test(i.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=gn(i).resolveInner(e),n=t.childBefore(e),s=t.childAfter(e),a;return n&&s&&n.to<=e&&s.from>=e&&(a=n.type.prop(nt.closedBy))&&a.indexOf(s.name)>-1&&i.doc.lineAt(n.to).from==i.doc.lineAt(s.from).from&&!/\S/.test(i.sliceDoc(n.to,s.from))?{from:n.to,to:s.from}:null}const j3=bj(!1),dse=bj(!0);function bj(i){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(s=>{let{from:a,to:r}=s,o=e.doc.lineAt(a),c=!i&&a==r&&use(e,a);i&&(a=r=(r<=o.to?o:e.doc.lineAt(r)).to);let d=new H0(e,{simulateBreak:a,simulateDoubleBreak:!!c}),h=X2(d,a);for(h==null&&(h=Tu(/^\s*/.exec(e.doc.lineAt(a).text)[0],e.tabSize));ro.from&&a{let s=[];for(let r=n.from;r<=n.to;){let o=i.doc.lineAt(r);o.number>t&&(n.empty||n.to>o.from)&&(e(o,s,n),t=o.number),r=o.to+1}let a=i.changes(s);return{changes:s,range:xe.range(a.mapPos(n.anchor,1),a.mapPos(n.head,1))}})}const hse=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=Object.create(null),n=new H0(i,{overrideIndentation:a=>{let r=t[a];return r==null?-1:r}}),s=Z2(i,(a,r,o)=>{let c=X2(n,a.from);if(c==null)return;/\S/.test(a.text)||(c=0);let d=/^\s*/.exec(a.text)[0],h=Qh(i,c);(d!=h||o.fromi.readOnly?!1:(e(i.update(Z2(i,(t,n)=>{n.push({from:t.from,insert:i.facet(q0)})}),{userEvent:"input.indent"})),!0),Sj=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(Z2(i,(t,n)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let a=Tu(s,i.tabSize),r=0,o=Qh(i,Math.max(0,a-Zg(i)));for(;r(i.setTabFocusMode(),!0),pse=[{key:"Ctrl-b",run:Z5,shift:rj,preventDefault:!0},{key:"Ctrl-f",run:J5,shift:oj},{key:"Ctrl-p",run:tj,shift:uj},{key:"Ctrl-n",run:ij,shift:dj},{key:"Ctrl-a",run:Lne,shift:Ine},{key:"Ctrl-e",run:jne,shift:Wne},{key:"Ctrl-d",run:mj},{key:"Ctrl-h",run:mv},{key:"Ctrl-k",run:ese},{key:"Ctrl-Alt-h",run:_j},{key:"Ctrl-o",run:nse},{key:"Ctrl-t",run:sse},{key:"Ctrl-v",run:pv}],mse=[{key:"ArrowLeft",run:Z5,shift:rj,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:kne,shift:Une,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Rne,shift:Kne,preventDefault:!0},{key:"ArrowRight",run:J5,shift:oj,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Ane,shift:Fne,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Pne,shift:Vne,preventDefault:!0},{key:"ArrowUp",run:tj,shift:uj,preventDefault:!0},{mac:"Cmd-ArrowUp",run:N3,shift:P3},{mac:"Ctrl-ArrowUp",run:O3,shift:T3},{key:"ArrowDown",run:ij,shift:dj,preventDefault:!0},{mac:"Cmd-ArrowDown",run:R3,shift:L3},{mac:"Ctrl-ArrowDown",run:pv,shift:M3},{key:"PageUp",run:O3,shift:T3},{key:"PageDown",run:pv,shift:M3},{key:"Home",run:Nne,shift:Hne,preventDefault:!0},{key:"Mod-Home",run:N3,shift:P3},{key:"End",run:Mne,shift:qne,preventDefault:!0},{key:"Mod-End",run:R3,shift:L3},{key:"Enter",run:j3,shift:j3},{key:"Mod-a",run:Xne},{key:"Backspace",run:mv,shift:mv,preventDefault:!0},{key:"Delete",run:mj,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:_j,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:$ne,preventDefault:!0},{mac:"Mod-Backspace",run:tse,preventDefault:!0},{mac:"Mod-Delete",run:ise,preventDefault:!0}].concat(pse.map(i=>({mac:i.key,run:i.run,shift:i.shift}))),gse=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:One,shift:Bne},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Tne,shift:zne},{key:"Alt-ArrowUp",run:ase},{key:"Shift-Alt-ArrowUp",run:ose},{key:"Alt-ArrowDown",run:rse},{key:"Shift-Alt-ArrowDown",run:lse},{key:"Mod-Alt-ArrowUp",run:Yne},{key:"Mod-Alt-ArrowDown",run:Zne},{key:"Escape",run:Jne},{key:"Mod-Enter",run:dse},{key:"Alt-l",mac:"Ctrl-l",run:Gne},{key:"Mod-i",run:Qne,preventDefault:!0},{key:"Mod-[",run:Sj},{key:"Mod-]",run:vj},{key:"Mod-Alt-\\",run:hse},{key:"Shift-Mod-k",run:cse},{key:"Shift-Mod-\\",run:Dne},{key:"Mod-/",run:ane},{key:"Alt-A",run:one},{key:"Ctrl-m",mac:"Shift-Alt-m",run:fse}].concat(mse),_se={key:"Tab",run:vj,shift:Sj},E3=typeof String.prototype.normalize=="function"?i=>i.normalize("NFKD"):i=>i;class bu{constructor(e,t,n=0,s=e.length,a,r){this.test=r,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,s),this.bufferStart=n,this.normalize=a?o=>a(E3(o)):E3,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 Un(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=T2(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Aa(e);let s=this.normalize(t);if(s.length)for(let a=0,r=n;;a++){let o=s.charCodeAt(a),c=this.match(o,r,this.bufferPos+this.bufferStart);if(a==s.length-1){if(c)return this.value=c,this;break}r==n&&athis.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 n=this.curLineStart+t.index,s=n+t[0].length;if(this.matchPos=t0(this.text,s+(n==s?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(nthis.value.to)&&(!this.test||this.test(n,s,t)))return this.value={from:n,to:s,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=n||s.to<=t){let o=new tu(t,e.sliceString(t,n));return gx.set(e,o),o}if(s.from==t&&s.to==n)return s;let{text:a,from:r}=s;return r>t&&(a=e.sliceString(t,r)+a,r=t),s.to=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 n=this.flat.from+t.index,s=n+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,s,t)))return this.value={from:n,to:s,match:t},this.matchPos=t0(this.text,s+(n==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=tu.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol!="undefined"&&(kj.prototype[Symbol.iterator]=Aj.prototype[Symbol.iterator]=function(){return this});function yse(i){try{return new RegExp(i,J2),!0}catch(e){return!1}}function t0(i,e){if(e>=i.length)return e;let t=i.lineAt(e),n;for(;e=56320&&n<57344;)e++;return e}function gv(i){let e=String(i.state.doc.lineAt(i.state.selection.main.head).number),t=Ht("input",{class:"cm-textfield",name:"line",value:e}),n=Ht("form",{class:"cm-gotoLine",onkeydown:a=>{a.keyCode==27?(a.preventDefault(),i.dispatch({effects:xh.of(!1)}),i.focus()):a.keyCode==13&&(a.preventDefault(),s())},onsubmit:a=>{a.preventDefault(),s()}},Ht("label",i.state.phrase("Go to line"),": ",t)," ",Ht("button",{class:"cm-button",type:"submit"},i.state.phrase("go")),Ht("button",{name:"close",onclick:()=>{i.dispatch({effects:xh.of(!1)}),i.focus()},"aria-label":i.state.phrase("close"),type:"button"},["×"]));function s(){let a=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!a)return;let{state:r}=i,o=r.doc.lineAt(r.selection.main.head),[,c,d,h,p]=a,_=h?+h.slice(1):0,y=d?+d:o.number;if(d&&p){let w=y/100;c&&(w=w*(c=="-"?-1:1)+o.number/r.doc.lines),y=Math.round(r.doc.lines*w)}else d&&c&&(y=y*(c=="-"?-1:1)+o.number);let x=r.doc.line(Math.max(1,Math.min(r.doc.lines,y))),v=xe.cursor(x.from+Math.max(0,Math.min(_,x.length)));i.dispatch({effects:[xh.of(!1),Ne.scrollIntoView(v.from,{y:"center"})],selection:v}),i.focus()}return{dom:n}}const xh=Ze.define(),D3=an.define({create(){return!0},update(i,e){for(let t of e.effects)t.is(xh)&&(i=t.value);return i},provide:i=>Wh.from(i,e=>e?gv:null)}),xse=i=>{let e=Ih(i,gv);if(!e){let t=[xh.of(!0)];i.state.field(D3,!1)==null&&t.push(Ze.appendConfig.of([D3,bse])),i.dispatch({effects:t}),e=Ih(i,gv)}return e&&e.dom.querySelector("input").select(),!0},bse=Ne.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),vse={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Sse=Le.define({combine(i){return Da(i,vse,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Cj(i){return[Ose,Cse]}const wse=qe.mark({class:"cm-selectionMatch"}),kse=qe.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function U3(i,e,t,n){return(t==0||i(e.sliceDoc(t-1,t))!=ei.Word)&&(n==e.doc.length||i(e.sliceDoc(n,n+1))!=ei.Word)}function Ase(i,e,t,n){return i(e.sliceDoc(t,t+1))==ei.Word&&i(e.sliceDoc(n-1,n))==ei.Word}const Cse=bi.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.selectionSet||i.docChanged||i.viewportChanged)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=i.state.facet(Sse),{state:t}=i,n=t.selection;if(n.ranges.length>1)return qe.none;let s=n.main,a,r=null;if(s.empty){if(!e.highlightWordAroundCursor)return qe.none;let c=t.wordAt(s.head);if(!c)return qe.none;r=t.charCategorizer(s.head),a=t.sliceDoc(c.from,c.to)}else{let c=s.to-s.from;if(c200)return qe.none;if(e.wholeWords){if(a=t.sliceDoc(s.from,s.to),r=t.charCategorizer(s.head),!(U3(r,t,s.from,s.to)&&Ase(r,t,s.from,s.to)))return qe.none}else if(a=t.sliceDoc(s.from,s.to),!a)return qe.none}let o=[];for(let c of i.visibleRanges){let d=new bu(t.doc,a,c.from,c.to);for(;!d.next().done;){let{from:h,to:p}=d.value;if((!r||U3(r,t,h,p))&&(s.empty&&h<=s.from&&p>=s.to?o.push(kse.range(h,p)):(h>=s.to||p<=s.from)&&o.push(wse.range(h,p)),o.length>e.maxMatches))return qe.none}}return qe.set(o)}},{decorations:i=>i.decorations}),Ose=Ne.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Tse=({state:i,dispatch:e})=>{let{selection:t}=i,n=xe.create(t.ranges.map(s=>i.wordAt(s.head)||xe.cursor(s.head)),t.mainIndex);return n.eq(t)?!1:(e(i.update({selection:n})),!0)};function Mse(i,e){let{main:t,ranges:n}=i.selection,s=i.wordAt(t.head),a=s&&s.from==t.from&&s.to==t.to;for(let r=!1,o=new bu(i.doc,e,n[n.length-1].to);;)if(o.next(),o.done){if(r)return null;o=new bu(i.doc,e,0,Math.max(0,n[n.length-1].from-1)),r=!0}else{if(r&&n.some(c=>c.from==o.value.from))continue;if(a){let c=i.wordAt(o.value.from);if(!c||c.from!=o.value.from||c.to!=o.value.to)continue}return o.value}}const Nse=({state:i,dispatch:e})=>{let{ranges:t}=i.selection;if(t.some(a=>a.from===a.to))return Tse({state:i,dispatch:e});let n=i.sliceDoc(t[0].from,t[0].to);if(i.selection.ranges.some(a=>i.sliceDoc(a.from,a.to)!=n))return!1;let s=Mse(i,n);return s?(e(i.update({selection:i.selection.addRange(xe.range(s.from,s.to),!1),effects:Ne.scrollIntoView(s.to)})),!0):!1},Xl=Le.define({combine(i){return Da(i,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Hse(e),scrollToMatch:e=>Ne.scrollIntoView(e)})}});function Rse(i){return i?[Xl.of(i),yv]:yv}class Oj{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||yse(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,n)=>n=="n"?`
`:n=="r"?"\r":n=="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 Ese(this):new Lse(this)}getCursor(e,t=0,n){let s=e.doc?e:ut.create({doc:e});return n==null&&(n=s.doc.length),this.regexp?Uc(this,s,t,n):Dc(this,s,t,n)}}class Tj{constructor(e){this.spec=e}}function Dc(i,e,t,n){return new bu(e.doc,i.unquoted,t,n,i.caseSensitive?void 0:s=>s.toLowerCase(),i.wholeWord?Pse(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function Pse(i,e){return(t,n,s,a)=>((a>t||a+s.length=t)return null;s.push(n.value)}return s}highlight(e,t,n,s){let a=Dc(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!a.next().done;)s(a.value.from,a.value.to)}}function Uc(i,e,t,n){return new kj(e.doc,i.search,{ignoreCase:!i.caseSensitive,test:i.wholeWord?jse(e.charCategorizer(e.selection.main.head)):void 0},t,n)}function i0(i,e){return i.slice(tn(i,e,!1),e)}function n0(i,e){return i.slice(e,tn(i,e))}function jse(i){return(e,t,n)=>!n[0].length||(i(i0(n.input,n.index))!=ei.Word||i(n0(n.input,n.index))!=ei.Word)&&(i(n0(n.input,n.index+n[0].length))!=ei.Word||i(i0(n.input,n.index+n[0].length))!=ei.Word)}class Ese extends Tj{nextMatch(e,t,n){let s=Uc(this.spec,e,n,e.doc.length).next();return s.done&&(s=Uc(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,n){for(let s=1;;s++){let a=Math.max(t,n-s*1e4),r=Uc(this.spec,e,a,n),o=null;for(;!r.next().done;)o=r.value;if(o&&(a==t||o.from>a+10))return o;if(a==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n=="&")return e.match[0];if(n=="$")return"$";for(let s=n.length;s>0;s--){let a=+n.slice(0,s);if(a>0&&a=t)return null;s.push(n.value)}return s}highlight(e,t,n,s){let a=Uc(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!a.next().done;)s(a.value.from,a.value.to)}}const Yh=Ze.define(),$2=Ze.define(),vo=an.define({create(i){return new _x(_v(i).create(),null)},update(i,e){for(let t of e.effects)t.is(Yh)?i=new _x(t.value.create(),i.panel):t.is($2)&&(i=new _x(i.query,t.value?eS:null));return i},provide:i=>Wh.from(i,e=>e.panel)});class _x{constructor(e,t){this.query=e,this.panel=t}}const Dse=qe.mark({class:"cm-searchMatch"}),Use=qe.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Fse=bi.fromClass(class{constructor(i){this.view=i,this.decorations=this.highlight(i.state.field(vo))}update(i){let e=i.state.field(vo);(e!=i.startState.field(vo)||i.docChanged||i.selectionSet||i.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:i,panel:e}){if(!e||!i.spec.valid)return qe.none;let{view:t}=this,n=new vr;for(let s=0,a=t.visibleRanges,r=a.length;sa[s+1].from-500;)c=a[++s].to;i.highlight(t.state,o,c,(d,h)=>{let p=t.state.selection.ranges.some(_=>_.from==d&&_.to==h);n.add(d,h,p?Use:Dse)})}return n.finish()}},{decorations:i=>i.decorations});function Tf(i){return e=>{let t=e.state.field(vo,!1);return t&&t.query.spec.valid?i(e,t):Rj(e)}}const s0=Tf((i,{query:e})=>{let{to:t}=i.state.selection.main,n=e.nextMatch(i.state,t,t);if(!n)return!1;let s=xe.single(n.from,n.to),a=i.state.facet(Xl);return i.dispatch({selection:s,effects:[tS(i,n),a.scrollToMatch(s.main,i)],userEvent:"select.search"}),Nj(i),!0}),a0=Tf((i,{query:e})=>{let{state:t}=i,{from:n}=t.selection.main,s=e.prevMatch(t,n,n);if(!s)return!1;let a=xe.single(s.from,s.to),r=i.state.facet(Xl);return i.dispatch({selection:a,effects:[tS(i,s),r.scrollToMatch(a.main,i)],userEvent:"select.search"}),Nj(i),!0}),Bse=Tf((i,{query:e})=>{let t=e.matchAll(i.state,1e3);return!t||!t.length?!1:(i.dispatch({selection:xe.create(t.map(n=>xe.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),zse=({state:i,dispatch:e})=>{let t=i.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:n,to:s}=t.main,a=[],r=0;for(let o=new bu(i.doc,i.sliceDoc(n,s));!o.next().done;){if(a.length>1e3)return!1;o.value.from==n&&(r=a.length),a.push(xe.range(o.value.from,o.value.to))}return e(i.update({selection:xe.create(a,r),userEvent:"select.search.matches"})),!0},F3=Tf((i,{query:e})=>{let{state:t}=i,{from:n,to:s}=t.selection.main;if(t.readOnly)return!1;let a=e.nextMatch(t,n,n);if(!a)return!1;let r=a,o=[],c,d,h=[];r.from==n&&r.to==s&&(d=t.toText(e.getReplacement(r)),o.push({from:r.from,to:r.to,insert:d}),r=e.nextMatch(t,r.from,r.to),h.push(Ne.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(n).number)+".")));let p=i.state.changes(o);return r&&(c=xe.single(r.from,r.to).map(p),h.push(tS(i,r)),h.push(t.facet(Xl).scrollToMatch(c.main,i))),i.dispatch({changes:p,selection:c,effects:h,userEvent:"input.replace"}),!0}),qse=Tf((i,{query:e})=>{if(i.state.readOnly)return!1;let t=e.matchAll(i.state,1e9).map(s=>{let{from:a,to:r}=s;return{from:a,to:r,insert:e.getReplacement(s)}});if(!t.length)return!1;let n=i.state.phrase("replaced $ matches",t.length)+".";return i.dispatch({changes:t,effects:Ne.announce.of(n),userEvent:"input.replace.all"}),!0});function eS(i){return i.state.facet(Xl).createPanel(i)}function _v(i,e){var t,n,s,a,r;let o=i.selection.main,c=o.empty||o.to>o.from+100?"":i.sliceDoc(o.from,o.to);if(e&&!c)return e;let d=i.facet(Xl);return new Oj({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:d.literal)?c:c.replace(/\n/g,"\\n"),caseSensitive:(n=e==null?void 0:e.caseSensitive)!==null&&n!==void 0?n:d.caseSensitive,literal:(s=e==null?void 0:e.literal)!==null&&s!==void 0?s:d.literal,regexp:(a=e==null?void 0:e.regexp)!==null&&a!==void 0?a:d.regexp,wholeWord:(r=e==null?void 0:e.wholeWord)!==null&&r!==void 0?r:d.wholeWord})}function Mj(i){let e=Ih(i,eS);return e&&e.dom.querySelector("[main-field]")}function Nj(i){let e=Mj(i);e&&e==i.root.activeElement&&e.select()}const Rj=i=>{let e=i.state.field(vo,!1);if(e&&e.panel){let t=Mj(i);if(t&&t!=i.root.activeElement){let n=_v(i.state,e.query.spec);n.valid&&i.dispatch({effects:Yh.of(n)}),t.focus(),t.select()}}else i.dispatch({effects:[$2.of(!0),e?Yh.of(_v(i.state,e.query.spec)):Ze.appendConfig.of(yv)]});return!0},Pj=i=>{let e=i.state.field(vo,!1);if(!e||!e.panel)return!1;let t=Ih(i,eS);return t&&t.dom.contains(i.root.activeElement)&&i.focus(),i.dispatch({effects:$2.of(!1)}),!0},Lj=[{key:"Mod-f",run:Rj,scope:"editor search-panel"},{key:"F3",run:s0,shift:a0,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:s0,shift:a0,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Pj,scope:"editor search-panel"},{key:"Mod-Shift-l",run:zse},{key:"Mod-Alt-g",run:xse},{key:"Mod-d",run:Nse,preventDefault:!0}];class Hse{constructor(e){this.view=e;let t=this.query=e.state.field(vo).query.spec;this.commit=this.commit.bind(this),this.searchField=Ht("input",{value:t.search,placeholder:rs(e,"Find"),"aria-label":rs(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Ht("input",{value:t.replace,placeholder:rs(e,"Replace"),"aria-label":rs(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Ht("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=Ht("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=Ht("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function n(s,a,r){return Ht("button",{class:"cm-button",name:s,onclick:a,type:"button"},r)}this.dom=Ht("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,n("next",()=>s0(e),[rs(e,"next")]),n("prev",()=>a0(e),[rs(e,"previous")]),n("select",()=>Bse(e),[rs(e,"all")]),Ht("label",null,[this.caseField,rs(e,"match case")]),Ht("label",null,[this.reField,rs(e,"regexp")]),Ht("label",null,[this.wordField,rs(e,"by word")]),...e.state.readOnly?[]:[Ht("br"),this.replaceField,n("replace",()=>F3(e),[rs(e,"replace")]),n("replaceAll",()=>qse(e),[rs(e,"replace all")])],Ht("button",{name:"close",onclick:()=>Pj(e),"aria-label":rs(e,"close"),type:"button"},["×"])])}commit(){let e=new Oj({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:Yh.of(e)}))}keydown(e){Yee(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?a0:s0)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),F3(this.view))}update(e){for(let t of e.transactions)for(let n of t.effects)n.is(Yh)&&!n.value.eq(this.query)&&this.setQuery(n.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(Xl).top}}function rs(i,e){return i.state.phrase(e)}const Fm=30,Bm=/[\s\.,:;?!]/;function tS(i,{from:e,to:t}){let n=i.state.doc.lineAt(e),s=i.state.doc.lineAt(t).to,a=Math.max(n.from,e-Fm),r=Math.min(s,t+Fm),o=i.state.sliceDoc(a,r);if(a!=n.from){for(let c=0;co.length-Fm;c--)if(!Bm.test(o[c-1])&&Bm.test(o[c])){o=o.slice(0,c);break}}return Ne.announce.of(`${i.state.phrase("current match")}. ${o} ${i.state.phrase("on line")} ${n.number}.`)}const Kse=Ne.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"}}),yv=[vo,Wl.low(Fse),Kse];class jj{constructor(e,t,n,s){this.state=e,this.pos=t,this.explicit=n,this.view=s,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=gn(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),s=t.text.slice(n-t.from,this.pos-t.from),a=s.search(Ej(e,!1));return a<0?null:{from:n+a,to:this.pos,text:s.slice(a)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function B3(i){let e=Object.keys(i).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function Vse(i){let e=Object.create(null),t=Object.create(null);for(let{label:s}of i){e[s[0]]=!0;for(let a=1;atypeof s=="string"?{label:s}:s),[t,n]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:Vse(e);return s=>{let a=s.matchBefore(n);return a||s.explicit?{from:a?a.from:s.pos,options:e,validFor:t}:null}}class z3{constructor(e,t,n,s){this.completion=e,this.source=t,this.match=n,this.score=s}}function Pl(i){return i.selection.main.from}function Ej(i,e){var t;let{source:n}=i,s=e&&n[0]!="^",a=n[n.length-1]!="$";return!s&&!a?i:new RegExp(`${s?"^":""}(?:${n})${a?"$":""}`,(t=i.flags)!==null&&t!==void 0?t:i.ignoreCase?"i":"")}const Dj=Ea.define();function Wse(i,e,t,n){let{main:s}=i.selection,a=t-s.from,r=n-s.from;return ee(z({},i.changeByRange(o=>{if(o!=s&&t!=n&&i.sliceDoc(o.from+a,o.from+r)!=i.sliceDoc(t,n))return{range:o};let c=i.toText(e);return{changes:{from:o.from+a,to:n==s.from?o.to:o.from+r,insert:c},range:xe.cursor(o.from+a+c.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const q3=new WeakMap;function Xse(i){if(!Array.isArray(i))return i;let e=q3.get(i);return e||q3.set(i,e=Ise(i)),e}const r0=Ze.define(),Zh=Ze.define();class Gse{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=48&&C<=57||C>=97&&C<=122?2:C>=65&&C<=90?1:0:(P=T2(C))!=P.toLowerCase()?1:P!=P.toUpperCase()?2:0;(!M||R==1&&w||A==0&&R!=0)&&(t[p]==C||n[p]==C&&(_=!0)?r[p++]=M:r.length&&(k=!1)),A=R,M+=Aa(C)}return p==c&&r[0]==0&&k?this.result(-100+(_?-200:0),r,e):y==c&&x==0?this.ret(-200-e.length+(v==e.length?0:-100),[0,v]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):y==c?this.ret(-900-e.length,[x,v]):p==c?this.result(-100+(_?-200:0)+-700+(k?0:-1100),r,e):t.length==2?null:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,n){let s=[],a=0;for(let r of t){let o=r+(this.astral?Aa(Un(n,r)):1);a&&s[a-1]==r?s[a-1]=o:(s[a++]=r,s[a++]=o)}return this.ret(e-n.length,s)}}class Qse{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Yse,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>H3(e(n),t(n)),optionClass:(e,t)=>n=>H3(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function H3(i,e){return i?e?i+" "+e:i:e}function Yse(i,e,t,n,s,a){let r=i.textDirection==Zt.RTL,o=r,c=!1,d="top",h,p,_=e.left-s.left,y=s.right-e.right,x=n.right-n.left,v=n.bottom-n.top;if(o&&_=v||M>e.top?h=t.bottom-e.top:(d="bottom",h=e.bottom-t.top)}let w=(e.bottom-e.top)/a.offsetHeight,k=(e.right-e.left)/a.offsetWidth;return{style:`${d}: ${h/w}px; max-width: ${p/k}px`,class:"cm-completionInfo-"+(c?r?"left-narrow":"right-narrow":o?"left":"right")}}function Zse(i){let e=i.addToOptions.slice();return i.icons&&e.push({render(t){let n=document.createElement("div");return n.classList.add("cm-completionIcon"),t.type&&n.classList.add(...t.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),n.setAttribute("aria-hidden","true"),n},position:20}),e.push({render(t,n,s,a){let r=document.createElement("span");r.className="cm-completionLabel";let o=t.displayLabel||t.label,c=0;for(let d=0;dc&&r.appendChild(document.createTextNode(o.slice(c,h)));let _=r.appendChild(document.createElement("span"));_.appendChild(document.createTextNode(o.slice(h,p))),_.className="cm-completionMatchedText",c=p}return ct.position-n.position).map(t=>t.render)}function yx(i,e,t){if(i<=t)return{from:0,to:i};if(e<0&&(e=0),e<=i>>1){let s=Math.floor(e/t);return{from:s*t,to:(s+1)*t}}let n=Math.floor((i-e)/t);return{from:i-(n+1)*t,to:i-n*t}}class Jse{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:c=>this.placeInfo(c),key:this},this.space=null,this.currentClass="";let s=e.state.field(t),{options:a,selected:r}=s.open,o=e.state.facet(Ki);this.optionContent=Zse(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=yx(a.length,r,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",c=>{let{options:d}=e.state.field(t).open;for(let h=c.target,p;h&&h!=this.dom;h=h.parentNode)if(h.nodeName=="LI"&&(p=/-(\d+)$/.exec(h.id))&&+p[1]{let d=e.state.field(this.stateField,!1);d&&d.tooltip&&e.state.facet(Ki).closeOnBlur&&c.relatedTarget!=e.contentDOM&&e.dispatch({effects:Zh.of(null)})}),this.showOptions(a,s.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 n=e.state.field(this.stateField),s=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=s){let{options:a,selected:r,disabled:o}=n.open;(!s.open||s.open.options!=a)&&(this.range=yx(a.length,r,e.state.facet(Ki).maxRenderedOptions),this.showOptions(a,n.id)),this.updateSel(),o!=((t=s.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let n of this.currentClass.split(" "))n&&this.dom.classList.remove(n);for(let n of t.split(" "))n&&this.dom.classList.add(n);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected=this.range.to)&&(this.range=yx(t.options.length,t.selected,this.view.state.facet(Ki).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:s}=t.options[t.selected],{info:a}=s;if(!a)return;let r=typeof a=="string"?document.createTextNode(a):a(s);if(!r)return;"then"in r?r.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o,s)}).catch(o=>qn(this.view.state,o,"completion info")):(this.addInfoPane(r,s),n.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",n.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:s,destroy:a}=e;n.appendChild(s),this.infoDestroy=a||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,s=this.range.from;n;n=n.nextSibling,s++)n.nodeName!="LI"||!n.id?s--:s==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&(n.removeAttribute("aria-selected"),n.removeAttribute("aria-describedby"));return t&&eae(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),s=e.getBoundingClientRect(),a=this.space;if(!a){let r=this.dom.ownerDocument.documentElement;a={left:0,top:0,right:r.clientWidth,bottom:r.clientHeight}}return s.top>Math.min(a.bottom,t.bottom)-10||s.bottom{r.target==s&&r.preventDefault()});let a=null;for(let r=n.from;rn.from||n.from==0))if(a=_,typeof d!="string"&&d.header)s.appendChild(d.header(d));else{let y=s.appendChild(document.createElement("completion-section"));y.textContent=_}}const h=s.appendChild(document.createElement("li"));h.id=t+"-"+r,h.setAttribute("role","option");let p=this.optionClass(o);p&&(h.className=p);for(let _ of this.optionContent){let y=_(o,this.view.state,this.view,c);y&&h.appendChild(y)}}return n.from&&s.classList.add("cm-completionListIncompleteTop"),n.tonew Jse(t,i,e)}function eae(i,e){let t=i.getBoundingClientRect(),n=e.getBoundingClientRect(),s=t.height/i.offsetHeight;n.topt.bottom&&(i.scrollTop+=(n.bottom-t.bottom)/s)}function K3(i){return(i.boost||0)*100+(i.apply?10:0)+(i.info?5:0)+(i.type?1:0)}function tae(i,e){let t=[],n=null,s=null,a=h=>{t.push(h);let{section:p}=h.completion;if(p){n||(n=[]);let _=typeof p=="string"?p:p.name;n.some(y=>y.name==_)||n.push(typeof p=="string"?{name:_}:p)}},r=e.facet(Ki);for(let h of i)if(h.hasResult()){let p=h.result.getMatch;if(h.result.filter===!1)for(let _ of h.result.options)a(new z3(_,h.source,p?p(_):[],1e9-t.length));else{let _=e.sliceDoc(h.from,h.to),y,x=r.filterStrict?new Qse(_):new Gse(_);for(let v of h.result.options)if(y=x.match(v.label)){let w=v.displayLabel?p?p(v,y.matched):[]:y.matched,k=y.score+(v.boost||0);if(a(new z3(v,h.source,w,k)),typeof v.section=="object"&&v.section.rank==="dynamic"){let{name:M}=v.section;s||(s=Object.create(null)),s[M]=Math.max(k,s[M]||-1e9)}}}}if(n){let h=Object.create(null),p=0,_=(y,x)=>(y.rank==="dynamic"&&x.rank==="dynamic"?s[x.name]-s[y.name]:0)||(typeof y.rank=="number"?y.rank:1e9)-(typeof x.rank=="number"?x.rank:1e9)||(y.name_.score-p.score||d(p.completion,_.completion))){let p=h.completion;!c||c.label!=p.label||c.detail!=p.detail||c.type!=null&&p.type!=null&&c.type!=p.type||c.apply!=p.apply||c.boost!=p.boost?o.push(h):K3(h.completion)>K3(c)&&(o[o.length-1]=h),c=h.completion}return o}class Ic{constructor(e,t,n,s,a,r){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=s,this.selected=a,this.disabled=r}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Ic(this.options,V3(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,s,a,r){if(s&&!r&&e.some(d=>d.isPending))return s.setDisabled();let o=tae(e,t);if(!o.length)return s&&e.some(d=>d.isPending)?s.setDisabled():null;let c=t.facet(Ki).selectOnOpen?0:-1;if(s&&s.selected!=c&&s.selected!=-1){let d=s.options[s.selected].completion;for(let h=0;hh.hasResult()?Math.min(d,h.from):d,1e8),create:oae,above:a.aboveCursor},s?s.timestamp:Date.now(),c,!1)}map(e){return new Ic(this.options,this.attrs,ee(z({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new Ic(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class o0{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new o0(aae,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,n=t.facet(Ki),a=(n.override||t.languageDataAt("autocomplete",Pl(t)).map(Xse)).map(c=>(this.active.find(h=>h.source==c)||new Fs(c,this.active.some(h=>h.state!=0)?1:0)).update(e,n));a.length==this.active.length&&a.every((c,d)=>c==this.active[d])&&(a=this.active);let r=this.open,o=e.effects.some(c=>c.is(iS));r&&e.docChanged&&(r=r.map(e.changes)),e.selection||a.some(c=>c.hasResult()&&e.changes.touchesRange(c.from,c.to))||!iae(a,this.active)||o?r=Ic.build(a,t,this.id,r,n,o):r&&r.disabled&&!a.some(c=>c.isPending)&&(r=null),!r&&a.every(c=>!c.isPending)&&a.some(c=>c.hasResult())&&(a=a.map(c=>c.hasResult()?new Fs(c.source,0):c));for(let c of e.effects)c.is(Fj)&&(r=r&&r.setSelected(c.value,this.id));return a==this.active&&r==this.open?this:new o0(a,this.id,r)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?nae:sae}}function iae(i,e){if(i==e)return!0;for(let t=0,n=0;;){for(;t-1&&(t["aria-activedescendant"]=i+"-"+e),t}const aae=[];function Uj(i,e){if(i.isUserEvent("input.complete")){let n=i.annotation(Dj);if(n&&e.activateOnCompletion(n))return 12}let t=i.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:i.isUserEvent("delete.backward")?2:i.selection?8:i.docChanged?16:0}class Fs{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let n=Uj(e,t),s=this;(n&8||n&16&&this.touches(e))&&(s=new Fs(s.source,0)),n&4&&s.state==0&&(s=new Fs(this.source,1)),s=s.updateFor(e,n);for(let a of e.effects)if(a.is(r0))s=new Fs(s.source,1,a.value);else if(a.is(Zh))s=new Fs(s.source,0);else if(a.is(iS))for(let r of a.value)r.source==s.source&&(s=r);return s}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Pl(e.state))}}class iu extends Fs{constructor(e,t,n,s,a,r){super(e,3,t),this.limit=n,this.result=s,this.from=a,this.to=r}hasResult(){return!0}updateFor(e,t){var n;if(!(t&3))return this.map(e.changes);let s=this.result;s.map&&!e.changes.empty&&(s=s.map(s,e.changes));let a=e.changes.mapPos(this.from),r=e.changes.mapPos(this.to,1),o=Pl(e.state);if(o>r||!s||t&2&&(Pl(e.startState)==this.from||ot.map(e))}}),Fj=Ze.define(),Fn=an.define({create(){return o0.start()},update(i,e){return i.update(e)},provide:i=>[H2.from(i,e=>e.tooltip),Ne.contentAttributes.from(i,e=>e.attrs)]});function nS(i,e){const t=e.completion.apply||e.completion.label;let n=i.state.field(Fn).active.find(s=>s.source==e.source);return n instanceof iu?(typeof t=="string"?i.dispatch(ee(z({},Wse(i.state,t,n.from,n.to)),{annotations:Dj.of(e.completion)})):t(i,e.completion,n.from,n.to),!0):!1}const oae=$se(Fn,nS);function zm(i,e="option"){return t=>{let n=t.state.field(Fn,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp-1?n.open.selected+s*(i?1:-1):i?0:r-1;return o<0?o=e=="page"?0:r-1:o>=r&&(o=e=="page"?r-1:0),t.dispatch({effects:Fj.of(o)}),!0}}const lae=i=>{let e=i.state.field(Fn,!1);return i.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestampi.state.field(Fn,!1)?(i.dispatch({effects:r0.of(!0)}),!0):!1,cae=i=>{let e=i.state.field(Fn,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(i.dispatch({effects:Zh.of(null)}),!0)};class uae{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const dae=50,hae=1e3,fae=bi.fromClass(class{constructor(i){this.view=i,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of i.state.field(Fn).active)e.isPending&&this.startQuery(e)}update(i){let e=i.state.field(Fn),t=i.state.facet(Ki);if(!i.selectionSet&&!i.docChanged&&i.startState.field(Fn)==e)return;let n=i.transactions.some(a=>{let r=Uj(a,t);return r&8||(a.selection||a.docChanged)&&!(r&3)});for(let a=0;adae&&Date.now()-r.time>hae){for(let o of r.context.abortListeners)try{o()}catch(c){qn(this.view.state,c)}r.context.abortListeners=null,this.running.splice(a--,1)}else r.updates.push(...i.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),i.transactions.some(a=>a.effects.some(r=>r.is(r0)))&&(this.pendingStart=!0);let s=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(a=>a.isPending&&!this.running.some(r=>r.active.source==a.source))?setTimeout(()=>this.startUpdate(),s):-1,this.composing!=0)for(let a of i.transactions)a.isUserEvent("input.type")?this.composing=2:this.composing==2&&a.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:i}=this.view,e=i.field(Fn);for(let t of e.active)t.isPending&&!this.running.some(n=>n.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ki).updateSyncTime))}startQuery(i){let{state:e}=this.view,t=Pl(e),n=new jj(e,t,i.explicit,this.view),s=new uae(i,n);this.running.push(s),Promise.resolve(i.source(n)).then(a=>{s.context.aborted||(s.done=a||null,this.scheduleAccept())},a=>{this.view.dispatch({effects:Zh.of(null)}),qn(this.view.state,a)})}scheduleAccept(){this.running.every(i=>i.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ki).updateSyncTime))}accept(){var i;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Ki),n=this.view.state.field(Fn);for(let s=0;s