var Md=Object.create;var Rn=Object.defineProperty;var Yd=Object.getOwnPropertyDescriptor;var Id=Object.getOwnPropertyNames;var Dd=Object.getPrototypeOf,Vd=Object.prototype.hasOwnProperty;var Oa=n=>Rn(n,"__esModule",{value:!0});var Bd=(n,t)=>{Oa(n);for(var e in t)Rn(n,e,{get:t[e],enumerable:!0})},Ld=(n,t,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Id(t))!Vd.call(n,i)&&i!=="default"&&Rn(n,i,{get:()=>t[i],enumerable:!(e=Yd(t,i))||e.enumerable});return n},re=n=>Ld(Oa(Rn(n!=null?Md(Dd(n)):{},"default",n&&n.__esModule&&"default"in n?{get:()=>n.default,enumerable:!0}:{value:n,enumerable:!0})),n);Bd(exports,{default:()=>da});var z=re(require("obsidian")),Wn={split:"tab: ",defaultTabNavItem:"New tab",defaultTabContent:"New tab content",actionButtonType:"action-add",ignoreNotice:!1,autorefreshMarkdownView:!0,dragAndDrop:!1,doubleClickToEdit:!1,showToolbar:!0,tabSize:4,editorAutoSaveInterval:5e3,defaultTabsBorder:"border-hover",defaultTabsBorderColor:"#e0e0e0",hideTabsEditBlockButton:!0,defaultTitleLineClamp:"one",defaultTitlePosition:"top",defaultTitleLimited:!1,defaultTabsContentsPadding:"1em 2em",defaultTabsContentsMaxHeight:"none"},Is=class extends z.PluginSettingTab{constructor(t,e){super(t,e);this.needRefresh=!1;this.plugin=e,t.setting.onClose=()=>{this.plugin.settings.autorefreshMarkdownView&&this.needRefresh&&this.plugin.refreshOpenViews()&&(this.needRefresh=!1),t.setting.closeActiveTab()}}display(){let{containerEl:t}=this;t.empty(),this.displayNormalSetting(t),this.displayEditorSetting(t),this.displayAppearanceSetting(t)}displayNormalSetting(t){new z.Setting(t).setName("Separator").setDesc("The symbols to split each tab").addText(e=>e.setValue(this.plugin.settings.split).setPlaceholder("tab:").onChange(i=>{i==""&&(i="tab:"),this.plugin.settings.split=i,this.plugin.saveSettings(),this.needRefresh=!0})).then(e=>this.addResetButton(e,"defaultTabContent")),new z.Setting(t).setName("Default tab title").setDesc("Default title of new tab").addText(e=>e.setValue(this.plugin.settings.defaultTabNavItem).setPlaceholder("New tab").onChange(i=>{i==""&&(i="New tab"),this.plugin.settings.defaultTabNavItem=i,this.plugin.saveSettings()})).then(e=>this.addResetButton(e,"defaultTabNavItem")),new z.Setting(t).setName("Default tabs content").setDesc("Default content of new content").addTextArea(e=>e.setValue(this.plugin.settings.defaultTabContent).setPlaceholder("New tab content").onChange(i=>{i==""&&(i="New tab content"),this.plugin.settings.defaultTabContent=i})).then(e=>this.addResetButton(e,"defaultTabContent")),new z.Setting(t).setName("Action button").setDesc("Function of top right button. Select 'None' if you don't need it.").addDropdown(e=>e.addOptions({"action-none":"None","action-add":"Add new tab","action-edit":"Edit tab"}).setValue(this.plugin.settings.actionButtonType).onChange(i=>{this.plugin.settings.actionButtonType=i,this.needRefresh=!0,this.plugin.saveSettings(),this.sampleTabs.refresh()})),new z.Setting(t).setName("Ignore notice").setDesc("Ignore notice when adding, deleting tabs and so on.").addToggle(e=>e.setValue(this.plugin.settings.ignoreNotice).onChange(i=>{this.plugin.settings.ignoreNotice=i,this.plugin.saveSettings()})),new z.Setting(t).setName("Autorefresh markdown view").setDesc("When enabled, after you modify the settings of the tabs, all markdown files that opened will automatically refresh when you close the settings panel. If disabled, the changes will not take effect immediately on the Tabs in opened markdown file, and you will need to re-render them matually.").addToggle(e=>e.setValue(this.plugin.settings.autorefreshMarkdownView).onChange(i=>{this.plugin.settings.autorefreshMarkdownView=i,this.needRefresh=!0,this.plugin.saveSettings()})),new z.Setting(t).setName("Drag and drop").setDesc("You can drag and drop tabs to reorder them in the same file.").addToggle(e=>e.setValue(this.plugin.settings.dragAndDrop).onChange(i=>{this.plugin.settings.dragAndDrop=i,this.needRefresh=!0,this.plugin.saveSettings()}))}displayEditorSetting(t){new z.Setting(t).setName("Editor").setHeading(),new z.Setting(t).setName("Double click to edit").setDesc("Double click tab content to edit").addToggle(e=>e.setValue(this.plugin.settings.doubleClickToEdit).onChange(i=>{this.plugin.settings.doubleClickToEdit=i,this.needRefresh=!0,this.plugin.saveSettings()})),new z.Setting(t).setName("Show toolbar").setDesc("Show toolbar in tabs editor").addToggle(e=>e.setValue(this.plugin.settings.showToolbar).onChange(i=>{this.plugin.settings.showToolbar=i,this.needRefresh=!0,this.plugin.saveSettings()})),new z.Setting(t).setName("Tab size").setDesc("Tab size in tabs editor").addSlider(e=>{e.setLimits(1,8,1),e.setValue(this.plugin.settings.tabSize),e.onChange(i=>{this.plugin.settings.tabSize=i,this.needRefresh=!0,this.plugin.saveSettings()}),e.setDynamicTooltip()}).then(e=>this.addResetButton(e,"defaultTabContent")),new z.Setting(t).setName("Auto save interval").setDesc("Set the duration of inactivity after which the editor will automatically save your work. (default: 5000ms, 0 means only save on exit)").addText(e=>e.setValue(this.plugin.settings.editorAutoSaveInterval.toString()).setPlaceholder(Wn.editorAutoSaveInterval.toString()).onChange(i=>{let s=parseInt(i);isNaN(s)||(this.plugin.settings.editorAutoSaveInterval=s,this.needRefresh=!0,this.plugin.saveSettings())})).then(e=>this.addResetButton(e,"defaultTabContent"))}displayAppearanceSetting(t){new z.Setting(t).setName("Appearance").setHeading(),this.sampleTabs=new ma(this.plugin,this,t.createDiv())}addResetButton(t,e,i=!0){t.addExtraButton(s=>s.setIcon("reset").setTooltip("Reset to default").onClick(()=>{this.plugin.settings[e]=Wn[e],this.needRefresh=!0,this.plugin.saveSettings(),i&&this.display()}))}},ma=class{constructor(t,e,i){this.tabsnavItems=[];this.tabscontentsItems=[];this.plugin=t,this.settingsTab=e,this.containerEl=i,this.createTabsContainer(),this.createSampleTabNav(this.tabscontainerEl),this.createSampleTabContent(this.tabscontainerEl)}createTabsContainer(){this.containerEl.addClass("sample-tabs-container"),this.tabscontainerEl=this.containerEl.createDiv("tabs-container"),this.tabscontainerEl.classList.add("tabs-"+this.plugin.settings.defaultTabsBorder),this.tabscontainerEl.style.setProperty("--tabs-border-color",this.plugin.settings.defaultTabsBorderColor),this.tabscontainerEl.style.setProperty("--tabs-max-height",this.plugin.settings.defaultTabsContentsMaxHeight),this.tabscontainerEl.classList.add("tabs-nav-"+this.plugin.settings.defaultTitlePosition),(this.plugin.settings.defaultTitlePosition==="top"||this.plugin.settings.defaultTitlePosition==="bottom")&&this.tabscontainerEl.classList.add("tabs-nav-line-clamp-"+this.plugin.settings.defaultTitleLineClamp),this.tabscontainerEl.style.setProperty("--tabs-contents-padding",this.plugin.settings.defaultTabsContentsPadding);let t=this.containerEl.createDiv("edit-block-button");t.setAttribute("aria-label","Edit this block"),(0,z.setIcon)(t,"lucide-code-2")}createSampleTabNav(t){this.tabsnavEl=t.createEl("div"),this.tabsnavEl.className="tabs-nav";let e=this.tabsnavEl.createEl("div");e.className="tabs-nav-item-wrapper";let i=["Tabs","Tabs nav","Tabs contents","Lorem ipsum"];if(this.currentIndex=0,i.forEach((s,r)=>{let o=e.createEl("div");o.classList.add("tabs-nav-item"),o.textContent=s,r===0&&o.classList.add("tabs-nav-item-active"),o.addEventListener("click",()=>{e.children[this.currentIndex].classList.remove("tabs-nav-item-active"),this.tabscontentsItems[this.currentIndex].classList.remove("tabs-content-active"),this.currentIndex=r,e.children[r].classList.add("tabs-nav-item-active"),this.tabscontentsItems[r].classList.add("tabs-content-active")})}),this.plugin.settings.actionButtonType!=="action-none"){let s=this.tabsnavEl.createEl("div");s.className="tabs-nav-button",this.plugin.settings.actionButtonType==="action-add"?(0,z.setIcon)(s,"plus"):this.plugin.settings.actionButtonType==="action-edit"&&(0,z.setIcon)(s,"lucide-pencil")}}createSampleTabContent(t){this.tabscontentsEl=t.createDiv("tabs-contents");let e=this.tabscontentsEl.createDiv("tabs-content");this.generateTabsStyleSettings(e),e.classList.add("tabs-content-active");let i=this.tabscontentsEl.createDiv("tabs-content");this.generateTabsNavStyleSettings(i);let s=this.tabscontentsEl.createDiv("tabs-content");this.generateTabsContentStyleSettings(s);let r=this.tabscontentsEl.createDiv("tabs-content"),o=r.createEl("p");o.style.userSelect="text",o.textContent="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",this.tabscontentsItems=[e,i,s,r]}generateTabsStyleSettings(t){new z.Setting(t).setName("Tabs border").setDesc("Show tabs border when hover or always.").addDropdown(e=>e.addOptions({"border-none":"None","border-hover":"Hover","border-always":"Always"}).setValue(this.plugin.settings.defaultTabsBorder).onChange(i=>{i!==this.plugin.settings.defaultTabsBorder&&(this.tabscontainerEl.removeClass("tabs-"+this.plugin.settings.defaultTabsBorder),this.plugin.settings.defaultTabsBorder=i,this.settingsTab.needRefresh=!0,this.tabscontainerEl.addClass("tabs-"+i),this.plugin.saveSettings())})),new z.Setting(t).setName("Tabs border color").setDesc("Takes effect when 'Tabs border' set 'Hover' or 'Always").addColorPicker(e=>e.setValue(this.plugin.settings.defaultTabsBorderColor).onChange(i=>{this.tabscontainerEl.style.setProperty("--tabs-border-color",i),this.plugin.settings.defaultTabsBorderColor=i,this.settingsTab.needRefresh=!0,this.plugin.saveSettings()})).then(e=>this.settingsTab.addResetButton(e,"defaultTabsBorderColor")),new z.Setting(t).setName("Hide tabs code block edit block button").setDesc("It's just a decorative setting. If you turn on it, you can still control the cursor into tabs to edit the source code.").addToggle(e=>e.setValue(this.plugin.settings.hideTabsEditBlockButton).onChange(i=>{i?document.body.addClass("hide-tabs-edit-block-button"):document.body.removeClass("hide-tabs-edit-block-button"),this.plugin.settings.hideTabsEditBlockButton=i,this.plugin.saveSettings()}))}generateTabsNavStyleSettings(t){new z.Setting(t).setName("Tabs nav default posi tion").setDesc("Show tabs nav at the top, bottom, left or right.").addDropdown(e=>e.addOptions({top:"Top",bottom:"Bottom",left:"Left",right:"Right"}).setValue(this.plugin.settings.defaultTitlePosition).onChange(i=>{this.refreshNavPosition(this.plugin.settings.defaultTitlePosition,i),this.plugin.settings.defaultTitlePosition=i,this.settingsTab.needRefresh=!0,this.plugin.saveSettings()})),new z.Setting(t).setName("Tabs nav line clamp").setDesc("Show tabs nav in one line or multiple lines. Only works when the position is 'top' or 'bottom'").addDropdown(e=>e.addOptions({one:"One line",multi:"Multiple lines"}).setValue(this.plugin.settings.defaultTitleLineClamp==="one"||this.plugin.settings.defaultTitleLineClamp==="multi"?this.plugin.settings.defaultTitleLineClamp:"one").onChange(i=>{this.plugin.settings.defaultTitleLineClamp=i,this.settingsTab.needRefresh=!0,this.plugin.saveSettings()})),new z.Setting(t).setName("Limit tab title width").setDesc("If set true, tab title will be limited to the width of the tab. Otherwise, the tab title will be displayed the full width.").addToggle(e=>e.setValue(this.plugin.settings.defaultTitleLimited).onChange(i=>{i?this.tabsnavEl.addClass("tabs-nav-title-limited"):this.tabsnavEl.removeClass("tabs-nav-title-limited"),this.plugin.settings.defaultTitleLimited=i,this.settingsTab.needRefresh=!0,this.plugin.saveSettings()}))}generateTabsContentStyleSettings(t){new z.Setting(t).setName("Tabs contents padding").setDesc('The padding of tabs contents. You can set one to four values(same as css padding). For example, "0" means no padding. "10px" means 10 pixels on all sides. "10px 20px" means 10 pixels on top and bottom, 20 pixels on left and right.Not only "px" but also "em", "rem" and other units are supported.').addText(e=>e.setValue(this.plugin.settings.defaultTabsContentsPadding).setPlaceholder("1em 2em").onChange(i=>{this.tabscontainerEl.style.setProperty("--tabs-contents-padding",i),this.plugin.settings.defaultTabsContentsPadding=i,this.settingsTab.needRefresh=!0,this.plugin.saveSettings()})).then(e=>this.settingsTab.addResetButton(e,"defaultTabsContentsPadding")),new z.Setting(t).setName("Tabs contents max height").setDesc("If a feasible CSS size is set (for example, 250px, 15em, 50vh, etc.), then when the height of the tabs reaches this size, the excess part can be scrolled. Note that the value should not be set too small, otherwise the tabs will not display properly.").addText(e=>e.setValue(this.plugin.settings.defaultTabsContentsMaxHeight).setPlaceholder("none").onChange(i=>{i!=="none"?(this.tabscontainerEl.addClass("tabs-height-limited"),this.tabscontainerEl.setAttribute("style","--tabs-max-height: none;")):(this.tabscontainerEl.removeClass("tabs-height-limited"),this.tabscontainerEl.style.removeProperty("--tabs-max-height")),this.plugin.settings.defaultTabsContentsMaxHeight=i,this.settingsTab.needRefresh=!0,this.plugin.saveSettings()})).then(e=>this.settingsTab.addResetButton(e,"defaultTabsMaxHeight"))}refreshNavPosition(t,e){this.tabscontainerEl&&(this.tabscontainerEl.classList.remove("tabs-nav-"+t),this.tabscontainerEl.classList.add("tabs-nav-"+e))}refresh(){this.clear(),this.createTabsContainer(),this.createSampleTabNav(this.tabscontainerEl),this.createSampleTabContent(this.tabscontainerEl)}clear(){this.containerEl.empty()}};var Ys=re(require("obsidian"));var Mn=re(require("obsidian"));var qn=re(require("obsidian")),Mi=class{constructor(t,e,i,s,r){this.isActiveed=!1;this.index=t,this.title=e,this.content=i,this.createTabContentEl(i,s,r)}createTabContentEl(t,e,i){this.contentEl=createDiv(),this.contentEl.className="tabs-content";let s=new qn.MarkdownRenderChild(this.contentEl);qn.MarkdownRenderer.render(e,t,this.contentEl,i==null?void 0:i.sourcePath,s)}};var Ds=class{constructor(t,e){this.currentTab=0;this.plugin=t,this.tabcontents=e,this.tabcontentsEl=this.createTabContentsEl(),this.tabcontents[0].isActiveed=!0,this.tabcontents[0].contentEl.classList.add("tabs-content-active")}createTabContentsEl(){let t=document.createElement("div");return t.className="tabs-contents",this.tabcontents.forEach(e=>{t.appendChild(e.contentEl)}),t}refreshActiveTabContent(t){this.tabcontents[this.currentTab].isActiveed=!1,this.tabcontents[this.currentTab].contentEl.classList.remove("tabs-content-active"),this.tabcontents[t].isActiveed=!0,this.tabcontents[t].contentEl.classList.add("tabs-content-active"),this.currentTab=t}};var Tt=re(require("obsidian")),Vs=class extends Tt.Menu{constructor(t,e){super();this.addItem(i=>{i.setTitle("Add new tab"),i.setIcon("plus"),i.onClick(()=>{let r=t.app.workspace.getActiveViewOfType(Tt.MarkdownView).editor;r.setLine(t.sectionInfo.lineEnd,t.split+t.plugin.settings.defaultTabNavItem+` `+t.plugin.settings.defaultTabContent+` `+r.getLine(t.sectionInfo.lineEnd)),!t.plugin.settings.ignoreNotice&&new Tt.Notice("\u{1F7E2} Add new tab successfully")})}),this.addItem(i=>{i.setTitle("Delete tab"),i.setIcon("trash"),i.onClick(()=>{var a,l;let s=-1;for(let h=0;h{i.setTitle("Copy tab"),i.setIcon("copy"),i.onClick(()=>{let s=-1,r="";for(let o=0;o{!t.plugin.settings.ignoreNotice&&new Tt.Notice("\u{1F7E2} Copied to clipboard successfully.")}).catch(o=>{!t.plugin.settings.ignoreNotice&&new Tt.Notice("\u{1F534} Failed to copy to clipboard"),console.error(o)})})}),this.addItem(i=>{i.setTitle("Paste tab"),i.setIcon("paste"),i.onClick(()=>{navigator.clipboard.readText().then(s=>{var l;if(!s||s.trim()===""||s.trim()==t.split){!t.plugin.settings.ignoreNotice&&new Tt.Notice("\u{1F7E0} No content in clipboard.");return}let r=t.plugin.settings.defaultTabNavItem+` `,o=s.trim();s.startsWith(t.split)&&(r=s.substring(t.split.length,s.indexOf(` `)),o=o.substring(s.indexOf(` `)));let a=(l=t.activeView)==null?void 0:l.editor;a.setLine(t.sectionInfo.lineEnd,t.split+r.trim()+` `+o.trim()+` `+a.getLine(t.sectionInfo.lineEnd))}).catch(s=>{!t.plugin.settings.ignoreNotice&&new Tt.Notice("\u{1F534} Failed to paste from clipboard"),console.error(s)})})})}};var Bs=class{constructor(t,e,i){this.rawConfig=t.trim(),this.tabsborder=i.defaultTabsBorder,this.tabsBorderColor=i.defaultTabsBorderColor,this.hideTabsEditBlockButton=i.hideTabsEditBlockButton,this.titlePosition=i.defaultTitlePosition,this.titleLineClamp=i.defaultTitleLineClamp,this.actionButton=i.actionButtonType,this.titleLimited=i.defaultTitleLimited,this.tabsMaxHeight=i.defaultTabsContentsMaxHeight,this.tabsContentsPadding=i.defaultTabsContentsPadding,this.parseConfig(t)}parseConfig(t){t.trim().toLowerCase().split(` `).forEach(e=>{e.split(",").forEach(i=>{switch(i.trim()){case"top":this.titlePosition="top";break;case"bottom":this.titlePosition="bottom";break;case"left":this.titlePosition="left";break;case"right":this.titlePosition="right";break;case"action-add":this.actionButton="action-add";break;case"action-edit":this.actionButton="action-edit";break;case"action-none":this.actionButton="action-none";break;case"one":this.titleLineClamp="one";break;case"multi":this.titleLineClamp="multi";break;default:break}})})}decorate(t,e,i){t.classList.add("tabs-"+this.tabsborder),t.style.setProperty("--tabs-border-color",this.tabsBorderColor),t.style.setProperty("--tabs-max-height",this.tabsMaxHeight),this.hideTabsEditBlockButton&&document.body.classList.add("hide-tabs-edit-block-button"),t.classList.add("tabs-nav-"+(this.titlePosition||"top")),t.classList.add("tabs-nav-"+(this.titleLineClamp||"one")),this.titleLimited&&e.classList.add("tabs-nav-title-limited"),i.style.setProperty("--tabs-contents-padding",this.tabsContentsPadding)}};var Ls=re(require("obsidian")),Ns=class{constructor(t,e,i){this.tabnav=t,this.sectioninfo=i,this.buttonEl=this.createTabNavButtonEl(e)}createTabNavButtonEl(t){if(t==="action-none")return null;let e=document.createElement("div");return e.className="tabs-nav-button",t==="action-add"?(0,Ls.setIcon)(e,"plus"):t==="action-edit"&&(0,Ls.setIcon)(e,"lucide-pencil"),e}};var li=re(require("obsidian"));var Yi=class{constructor(t,e,i,s=!0){this.isActiveed=!1;this.index=e,this.title=i.trim(),this.tabnav=t,this.tabs=t.tabs,this.tabitemEl=createDiv(),this.tabitemEl.className="tabs-nav-item",s&&this.tabitemEl.setAttr("draggable","true"),this.tabitemMDEl=this.tabitemEl.createDiv(),this.tabitemMDEl.className="tabs-nav-item-md";let r=new li.MarkdownRenderChild(this.tabitemMDEl);li.MarkdownRenderer.render(this.tabs.app,this.title,this.tabitemMDEl,this.tabs.context.sourcePath,r)}registerdndEvents(){this.tabs.plugin.registerDomEvent(this.tabitemEl,"dragstart",t=>{let e=this.tabs.tabsNav.navItems.indexOf(this),i=this.title+` `+this.tabs.tabsContents.tabcontents[e].content;t.dataTransfer.setData("text/plain",i),t.dataTransfer.effectAllowed="copy",this.tabs.plugin.tabDragger={fromTabs:this.tabnav.tabs,draggedTab:this,draggedContent:this.tabs.tabsContents.tabcontents[e],draggedContentLineCount:this.tabs.tabsContents.tabcontents[e].content.split(` `).length,draggedIndex:e},this.tabitemEl.style.opacity="0.9"}),this.tabs.plugin.registerDomEvent(this.tabitemEl,"drag",t=>{t.preventDefault()}),this.tabs.plugin.registerDomEvent(this.tabitemEl,"dragenter",t=>{t.preventDefault(),!(this.tabs.plugin.tabDragger.draggedTab===this||this.tabs.plugin.tabDragger.draggedTab.tabs.activeView!==this.tabs.activeView||this.tabs.plugin.tabDragger.draggedTab.tabs.context.sourcePath!==this.tabs.context.sourcePath)&&this.tabitemEl.classList.add("tabs-nav-item-dragover")}),this.tabs.plugin.registerDomEvent(this.tabitemEl,"dragover",t=>{t.preventDefault(),t.dataTransfer.dropEffect="copy",!(this.tabs.plugin.tabDragger.draggedTab===this||this.tabs.plugin.tabDragger.draggedTab.tabs.activeView!==this.tabs.activeView||this.tabs.plugin.tabDragger.draggedTab.tabs.context.sourcePath!==this.tabs.context.sourcePath)&&(this.tabitemEl.classList.add("tabs-nav-item-dragover"),this.tabs.tabsConfig.titlePosition==="top"||this.tabs.tabsConfig.titlePosition==="bottom"?t.clientX-this.tabitemEl.getBoundingClientRect().left>this.tabitemEl.clientWidth*.5?(this.tabitemEl.classList.remove("tabs-nav-item-dragover-before"),this.tabitemEl.classList.add("tabs-nav-item-dragover-after")):t.clientX-this.tabitemEl.getBoundingClientRect().leftthis.tabitemEl.clientHeight*.5?(this.tabitemEl.classList.remove("tabs-nav-item-dragover-before"),this.tabitemEl.classList.add("tabs-nav-item-dragover-after")):t.clientY-this.tabitemEl.getBoundingClientRect().top{this.tabitemEl.classList.remove("tabs-nav-item-dragover"),this.tabitemEl.classList.remove("tabs-nav-item-dragover-before"),this.tabitemEl.classList.remove("tabs-nav-item-dragover-after")}),this.tabs.plugin.registerDomEvent(this.tabitemEl,"drop",t=>{var r,o,a,l,h,c;if(t.preventDefault(),this.tabitemEl.classList.remove("tabs-nav-item-dragover"),this.tabitemEl.classList.remove("tabs-nav-item-dragover-before"),this.tabitemEl.classList.remove("tabs-nav-item-dragover-after"),this.tabitemEl.style.opacity="",this.tabs.plugin.tabDragger.draggedTab===this)return;this.tabs.plugin.tabDragger.toTabs=this.tabnav.tabs;let e=this.tabs.plugin.tabDragger,i=this.tabs.plugin.tabDragger.draggedIndex,s=this.tabs.tabsConfig.titlePosition==="top"||this.tabs.tabsConfig.titlePosition==="bottom"?t.clientX-this.tabitemEl.getBoundingClientRect().lefte.draggedTab.index&&(s-=1),e.dropIndex=s,i===s)return;let f="",u=this.tabs.tabsNav.navItems.splice(i,1)[0];this.tabs.tabsNav.navItems.splice(s,0,u);let d=this.tabs.tabsContents.tabcontents.splice(i,1)[0];if(this.tabs.tabsContents.tabcontents.splice(s,0,d),i{let p=f.toTabs.tabsNav.navItems.indexOf(f.draggedTab);f.toTabs.tabsNav.refreshActiveTabNav(p),f.toTabs.tabsContents.refreshActiveTabContent(p),f.toTabs.currentIndex=p}),this.tabs.plugin.settings.doubleClickToEdit&&f.toTabs.plugin.registerDomEvent(f.draggedContent.contentEl,"dblclick",p=>{p.preventDefault(),!(!f.toTabs.activeView||f.toTabs.isPreviewMode())&&f.toTabs.plugin.tabsEditorModal.startEditing(f.toTabs)}),f.draggedTab.registerdndEvents();let u="";for(let p=0;p0&&(f.fromTabs.currentIndex-=1),f.fromTabs.tabsNav.refreshActiveTabNav(f.fromTabs.currentIndex),f.fromTabs.tabsContents.refreshActiveTabContent(f.fromTabs.currentIndex),this.tabs.plugin.lastTabsCache.set(f.fromTabs.tabsId,f.fromTabs.currentIndex)),f.fromTabs.tabsNav.navWrapperEl.removeChild(f.fromTabs.tabsNav.navItems[i].tabitemEl),f.fromTabs.tabsContents.tabcontentsEl.removeChild(f.fromTabs.tabsContents.tabcontents[i].contentEl),f.fromTabs.tabsNav.navItems.splice(i,1),f.fromTabs.tabsContents.tabcontents.splice(i,1);for(let p=0;pf.fromTabs.sectionInfo.lineEnd?(p.editor.replaceRange(u,{line:f.toTabs.sectionInfo.lineStart,ch:0},{line:f.toTabs.sectionInfo.lineEnd,ch:(a=f.toTabs.activeView)==null?void 0:a.editor.getLine(f.toTabs.sectionInfo.lineEnd).length}),p.editor.replaceRange(d,{line:f.fromTabs.sectionInfo.lineStart,ch:0},{line:f.fromTabs.sectionInfo.lineEnd,ch:(l=f.fromTabs.activeView)==null?void 0:l.editor.getLine(f.fromTabs.sectionInfo.lineEnd).length}),f.toTabs.sectionInfo.lineStart=f.toTabs.sectionInfo.lineStart-f.draggedContentLineCount,f.fromTabs.sectionInfo.lineEnd=f.fromTabs.sectionInfo.lineEnd-f.draggedContentLineCount):f.toTabs.sectionInfo.lineEnd0&&(this.navItems=new Array(e.length),this.tabsButton=new Ns(this,i,s),this.createTabNavEl(e),this.currentTab=0)}createTabNavEl(t){for(let e=0;e0&&this.navItems.forEach(e=>{this.navWrapperEl.appendChild(e.tabitemEl)}),this.tabsButton.buttonEl&&this.navEl.appendChild(this.tabsButton.buttonEl)}refreshActiveTabNav(t){this.navItems[this.currentTab].isActiveed=!1,this.navItems[this.currentTab].tabitemEl.classList.remove("tabs-nav-item-active"),this.navItems[t].isActiveed=!0,this.navItems[t].tabitemEl.classList.add("tabs-nav-item-active"),this.currentTab=t}registerDragEvents(){this.navItems.forEach(t=>{t.registerdndEvents()})}};var zs=class{constructor(t,e,i,s,r){this.currentIndex=0;this.tabsType="outertabs";this.backquote="`";this.backquoteCount=3;e.className="tabs-container",this.plugin=r,this.tabsEl=e,this.split=this.plugin.settings.split,this.app=s,this.activeView=s.workspace.getActiveViewOfType(Mn.MarkdownView),this.sectionInfo=i==null?void 0:i.getSectionInfo(e),this.context=i,this.updateBackquote(t),this.sectionInfo||(this.tabsType="innertabs",this.tabsEl.classList.add("tabs-innertabs"));let[o,a]=this.parseTabs(t,this.plugin.settings.defaultTabNavItem,this.plugin.settings.defaultTabContent);this.tabsConfig=new Bs(a[0],this.tabsEl,this.plugin.settings),this.tabsNav=new _s(this,o.slice(1),this.tabsType==="innertabs"?"action-none":this.tabsConfig.actionButton,this.sectionInfo),this.tabsContents=new Ds(r,a.map((l,h)=>new Mi(h,o[h],l,s,i)).slice(1)),this.registerEventHandlers(),e.appendChild(this.tabsNav.navEl),e.appendChild(this.tabsContents.tabcontentsEl),this.tabsConfig.decorate(this.tabsEl,this.tabsNav.navEl,this.tabsContents.tabcontentsEl),this.tabsId="/",this.context&&this.sectionInfo&&(this.tabsId=this.context.sourcePath+this.sectionInfo.lineStart),this.plugin.lastTabsCache.has(this.tabsId)||this.plugin.lastTabsCache.set(this.tabsId,0),this.currentIndex=this.plugin.lastTabsCache.get(this.tabsId),this.tabsNav.refreshActiveTabNav(this.currentIndex),this.tabsContents.refreshActiveTabContent(this.currentIndex)}parseTabs(t,e,i){let s=[],r=[],o="",a="";if(!t.contains(this.split))s.push(""),r.push(""),s.push(e),r.push(t.trim()===""?i:t);else{let l=t.split(` `);for(let h=0,c=0;h{this.plugin.registerDomEvent(t.tabitemEl,"click",()=>{let e=this.tabsNav.navItems.indexOf(t);this.tabsNav.refreshActiveTabNav(e),this.tabsContents.refreshActiveTabContent(e),this.currentIndex=e,this.plugin.lastTabsCache.set(this.context.sourcePath+this.sectionInfo.lineStart,e)})}),this.tabsType==="outertabs"&&this.plugin.settings.doubleClickToEdit&&this.plugin.registerDomEvent(this.tabsContents.tabcontentsEl,"dblclick",t=>{t.preventDefault(),!(!this.activeView||this.isPreviewMode())&&this.plugin.tabsEditorModal.startEditing(this)}),this.tabsConfig.actionButton){case"action-none":break;case"action-edit":this.activeView&&!this.isPreviewMode()&&this.tabsType!=="innertabs"&&this.tabsNav.tabsButton.buttonEl&&this.plugin.registerDomEvent(this.tabsNav.tabsButton.buttonEl,"click",()=>{this.plugin.tabsEditorModal.startEditing(this)});break;case"action-add":this.activeView&&!this.isPreviewMode()&&this.tabsType!=="innertabs"&&this.tabsNav.tabsButton.buttonEl&&this.plugin.registerDomEvent(this.tabsNav.tabsButton.buttonEl,"click",()=>{var e;this.plugin.lastTabsCache[this.context.sourcePath+this.sectionInfo.lineStart]=this.tabsNav.navItems.length;let t=(e=this.activeView)==null?void 0:e.editor;t.setLine(this.sectionInfo.lineEnd,this.split+this.plugin.settings.defaultTabNavItem+` `+this.plugin.settings.defaultTabContent+` `+t.getLine(this.sectionInfo.lineEnd))});break;default:this.plugin.settings.actionButtonType="action-none",this.plugin.saveSettings(),new Mn.Notice("Invalid action button type. Set to 'None'.")}this.activeView&&!this.isPreviewMode()&&this.tabsType!=="innertabs"&&this.plugin.registerDomEvent(this.tabsNav.navEl,"contextmenu",t=>{t.preventDefault(),new Vs(this,t).showAtMouseEvent(t)}),this.tabsType!=="innertabs"&&this.plugin.settings.dragAndDrop&&this.tabsNav.registerDragEvents()}isPreviewMode(){var t;return((t=this.activeView)==null?void 0:t.leaf.getViewState().state.mode)==="preview"}updateBackquote(t){var i,s,r,o,a;if(this.activeView&&this.sectionInfo){let l=(s=this.activeView)==null?void 0:s.editor.getLine((i=this.sectionInfo)==null?void 0:i.lineStart).trim();l.contains("```tabs")?this.backquote="`":l.contains("~~~tabs")&&(this.backquote="~")}let e=this.sectionInfo?(a=(o=this.activeView)==null?void 0:o.editor.getLine((r=this.sectionInfo)==null?void 0:r.lineStart).trim().replace("tabs",""))==null?void 0:a.length:0;if(this.backquoteCount=Math.max(this.backquoteCount,e),t.contains("```")||t.contains("~~~")){e=0;for(let l=0;lthis.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){[t,e]=ci(this,t,e);let s=[];return this.decompose(0,t,s,2),i.length&&i.decompose(0,i.length,s,1|2),this.decompose(e,this.length,s,1),Gt.from(s,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=ci(this,t,e);let i=[];return this.decompose(t,e,i,0),Gt.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),s=new hi(this),r=new hi(t);for(let o=e,a=e;;){if(s.next(o),r.next(o),o=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(a+=s.value.length,s.done||a>=i)return!0}}iter(t=1){return new hi(this,t)}iterRange(t,e=this.length){return new js(this,t,e)}iterLines(t,e){let i;if(t==null)i=this.iter();else{e==null&&(e=this.lines+1);let s=this.line(t).from;i=this.iterRange(s,Math.max(s,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new Gs(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(t.length==0)throw new RangeError("A document must have at least one line");return t.length==1&&!t[0]?W.empty:t.length<=32?new nt(t):Gt.from(nt.split(t,[]))}},nt=class extends W{constructor(t,e=Nd(t)){super();this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,s){for(let r=0;;r++){let o=this.text[r],a=s+o.length;if((e?i:a)>=t)return new ba(s,a,i,o);s=a+1,i++}}decompose(t,e,i,s){let r=t<=0&&e>=this.length?this:new nt(ga(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(s&1){let o=i.pop(),a=Yn(r.text,o.text.slice(),0,r.length);if(a.length<=32)i.push(new nt(a,o.length+r.length));else{let l=a.length>>1;i.push(new nt(a.slice(0,l)),new nt(a.slice(l)))}}else i.push(r)}replace(t,e,i){if(!(i instanceof nt))return super.replace(t,e,i);[t,e]=ci(this,t,e);let s=Yn(this.text,Yn(i.text,ga(this.text,0,t)),e),r=this.length+i.length-(e-t);return s.length<=32?new nt(s,r):Gt.from(nt.split(s,[]),r)}sliceString(t,e=this.length,i=` `){[t,e]=ci(this,t,e);let s="";for(let r=0,o=0;r<=e&&ot&&o&&(s+=i),tr&&(s+=a.slice(Math.max(0,t-r),e-r)),r=l+1}return s}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],s=-1;for(let r of t)i.push(r),s+=r.length+1,i.length==32&&(e.push(new nt(i,s)),i=[],s=-1);return s>-1&&e.push(new nt(i,s)),e}},Gt=class extends W{constructor(t,e){super();this.children=t,this.length=e,this.lines=0;for(let i of t)this.lines+=i.lines}lineInner(t,e,i,s){for(let r=0;;r++){let o=this.children[r],a=s+o.length,l=i+o.lines-1;if((e?l:a)>=t)return o.lineInner(t,e,i,s);s=a+1,i=l+1}}decompose(t,e,i,s){for(let r=0,o=0;o<=e&&r=o){let h=s&((o<=t?1:0)|(l>=e?2:0));o>=t&&l<=e&&!h?i.push(a):a.decompose(t-o,e-o,i,h)}o=l+1}}replace(t,e,i){if([t,e]=ci(this,t,e),i.lines=r&&e<=a){let l=o.replace(t-r,e-r,i),h=this.lines-o.lines+l.lines;if(l.lines>5-1&&l.lines>h>>5+1){let c=this.children.slice();return c[s]=l,new Gt(c,this.length-(e-t)+i.length)}return super.replace(r,a,l)}r=a+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i=` `){[t,e]=ci(this,t,e);let s="";for(let r=0,o=0;rt&&r&&(s+=i),to&&(s+=a.sliceString(t-o,e-o,i)),o=l+1}return s}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof Gt))return 0;let i=0,[s,r,o,a]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;s+=e,r+=e){if(s==o||r==a)return i;let l=this.children[s],h=t.children[r];if(l!=h)return i+l.scanIdentical(h,e);i+=l.length+1}}static from(t,e=t.reduce((i,s)=>i+s.length+1,-1)){let i=0;for(let d of t)i+=d.lines;if(i<32){let d=[];for(let p of t)p.flatten(d);return new nt(d,e)}let s=Math.max(32,i>>5),r=s<<1,o=s>>1,a=[],l=0,h=-1,c=[];function f(d){let p;if(d.lines>r&&d instanceof Gt)for(let m of d.children)f(m);else d.lines>o&&(l>o||!l)?(u(),a.push(d)):d instanceof nt&&l&&(p=c[c.length-1])instanceof nt&&d.lines+p.lines<=32?(l+=d.lines,h+=d.length+1,c[c.length-1]=new nt(p.text.concat(d.text),p.length+1+d.length)):(l+d.lines>s&&u(),l+=d.lines,h+=d.length+1,c.push(d))}function u(){l!=0&&(a.push(c.length==1?c[0]:Gt.from(c,h)),h=-1,l=c.length=0)}for(let d of t)f(d);return u(),a.length==1?a[0]:new Gt(a,e)}};W.empty=new nt([""],0);function Nd(n){let t=-1;for(let e of n)t+=e.length+1;return t}function Yn(n,t,e=0,i=1e9){for(let s=0,r=0,o=!0;r=e&&(l>i&&(a=a.slice(0,i-s)),s0?1:(t instanceof nt?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,s=this.nodes[i],r=this.offsets[i],o=r>>1,a=s instanceof nt?s.text.length:s.children.length;if(o==(e>0?a:0)){if(i==0)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(e>0?0:1)){if(this.offsets[i]+=e,t==0)return this.lineBreak=!0,this.value=` `,this;t--}else if(s instanceof nt){let l=s.text[o+(e<0?-1:0)];if(this.offsets[i]+=e,l.length>Math.max(0,t))return this.value=t==0?l:e>0?l.slice(t):l.slice(0,l.length-t),this;t-=l.length}else{let l=s.children[o+(e<0?-1:0)];t>l.length?(t-=l.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(l),this.offsets.push(e>0?1:(l instanceof nt?l.text.length:l.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}},js=class{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new hi(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:s}=this.cursor.next(t);return this.pos+=(s.length+t)*e,this.value=s.length<=i?s:e<0?s.slice(s.length-i):s.slice(0,i),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},Gs=class{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:s}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol!="undefined"&&(W.prototype[Symbol.iterator]=function(){return this.iter()},hi.prototype[Symbol.iterator]=js.prototype[Symbol.iterator]=Gs.prototype[Symbol.iterator]=function(){return this});var ba=class{constructor(t,e,i,s){this.from=t,this.to=e,this.number=i,this.text=s}get length(){return this.to-this.from}};function ci(n,t,e){return t=Math.max(0,Math.min(n.length,t)),[t,Math.max(t,Math.min(n.length,e))]}var fi="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(n=>n?parseInt(n,36):1);for(let n=1;nn)return fi[t-1]<=n;return!1}function Sa(n){return n>=127462&&n<=127487}var wa=8205;function ht(n,t,e=!0,i=!0){return(e?ya:zd)(n,t,i)}function ya(n,t,e){if(t==n.length)return t;t&&ka(n.charCodeAt(t))&&va(n.charCodeAt(t-1))&&t--;let i=Le(n,t);for(t+=Ii(i);t=0&&Sa(Le(n,o));)r++,o-=2;if(r%2==0)break;t+=2}else break}return t}function zd(n,t,e){for(;t>0;){let i=ya(n,t-2,e);if(i=56320&&n<57344}function va(n){return n>=55296&&n<56320}function Le(n,t){let e=n.charCodeAt(t);if(!va(e)||t+1==n.length)return e;let i=n.charCodeAt(t+1);return ka(i)?(e-55296<<10)+(i-56320)+65536:e}function Ii(n){return n<65536?1:2}var Us=/\r\n?|\n/,ct=function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n}(ct||(ct={})),Dt=class{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;et)return r+(t-s);r+=a}else{if(i!=ct.Simple&&h>=t&&(i==ct.TrackDel&&st||i==ct.TrackBefore&&st))return null;if(h>t||h==t&&e<0&&!a)return t==s||e<0?r:r+l;r+=l}s=h}if(t>s)throw new RangeError(`Position ${t} is out of range for changeset of length ${s}`);return r}touchesRange(t,e=t){for(let i=0,s=0;i=0&&s<=e&&a>=t)return se?"cover":!0;s=a}return!1}toString(){let t="";for(let e=0;e=0?":"+s:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Dt(t)}static create(t){return new Dt(t)}},st=class extends Dt{constructor(t,e){super(t);this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return Hs(this,(e,i,s,r,o)=>t=t.replace(s,s+(i-e),o),!1),t}mapDesc(t,e=!1){return Fs(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let s=0,r=0;s=0){e[s]=a,e[s+1]=o;let l=s>>1;for(;i.length0&&Ze(i,e,r.text),r.forward(c),a+=c}let h=t[o++];for(;a>1].toJSON()))}return t}static of(t,e,i){let s=[],r=[],o=0,a=null;function l(c=!1){if(!c&&!s.length)return;ou||f<0||u>e)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${e})`);let p=d?typeof d=="string"?W.of(d.split(i||Us)):d:W.empty,m=p.length;if(f==u&&m==0)return;fo&&dt(s,f-o,-1),dt(s,u-f,m),Ze(r,s,p),o=u}}return h(t),l(!a),a}static empty(t){return new st(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let s=0;sa&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)e.push(r[0],0);else{for(;i.length=0&&e<=0&&e==n[s+1]?n[s]+=t:t==0&&n[s]==0?n[s+1]+=e:i?(n[s]+=t,n[s+1]+=e):n.push(t,e)}function Ze(n,t,e){if(e.length==0)return;let i=t.length-2>>1;if(i>1])),!(e||o==n.sections.length||n.sections[o+1]<0);)a=n.sections[o++],l=n.sections[o++];t(s,h,r,c,f),s=h,r=c}}}function Fs(n,t,e,i=!1){let s=[],r=i?[]:null,o=new ui(n),a=new ui(t);for(let l=-1;;)if(o.ins==-1&&a.ins==-1){let h=Math.min(o.len,a.len);dt(s,h,-1),o.forward(h),a.forward(h)}else if(a.ins>=0&&(o.ins<0||l==o.i||o.off==0&&(a.len=0&&l=0){let h=0,c=o.len;for(;c;)if(a.ins==-1){let f=Math.min(c,a.len);h+=f,c-=f,a.forward(f)}else if(a.ins==0&&a.lenl||o.ins>=0&&o.len>l)&&(a||i.length>h),r.forward2(l),o.forward(l)}}}}var ui=class{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i>1;return e>=t.length?W.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?W.empty:e[i].slice(this.off,t==null?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){this.ins==-1?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}},Ae=class{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let t=this.flags&7;return t==7?null:t}get goalColumn(){let t=this.flags>>6;return t==16777215?void 0:t}map(t,e=-1){let i,s;return this.empty?i=s=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),s=t.mapPos(this.to,-1)),i==this.from&&s==this.to?this:new Ae(i,s,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return S.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return S.range(this.anchor,i)}eq(t,e=!1){return this.anchor==t.anchor&&this.head==t.head&&(!e||!this.empty||this.assoc==t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return S.range(t.anchor,t.head)}static create(t,e,i){return new Ae(t,e,i)}},S=class{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:S.create(this.ranges.map(i=>i.map(t,e)),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;it.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!="number"||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new S(t.ranges.map(e=>Ae.fromJSON(e)),t.main)}static single(t,e=t){return new S([S.range(t,e)],0)}static create(t,e=0){if(t.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,s=0;st?8:0)|r)}static normalized(t,e=0){let i=t[e];t.sort((s,r)=>s.from-r.from),e=t.indexOf(i);for(let s=1;sr.head?S.range(l,a):S.range(a,l))}}return new S(t,e)}};function Qa(n,t){for(let e of n.ranges)if(e.to>t)throw new RangeError("Selection points outside of document")}var Ks=0,A=class{constructor(t,e,i,s,r){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=s,this.id=Ks++,this.default=t([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(t={}){return new A(t.combine||(e=>e),t.compareInput||((e,i)=>e===i),t.compare||(t.combine?(e,i)=>e===i:Js),!!t.static,t.enables)}of(t){return new Di([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new Di(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new Di(t,this,2,e)}from(t,e){return e||(e=i=>i),this.compute([t],i=>e(i.field(t)))}};function Js(n,t){return n==t||n.length==t.length&&n.every((e,i)=>e===t[i])}var Di=class{constructor(t,e,i,s){this.dependencies=t,this.facet=e,this.type=i,this.value=s,this.id=Ks++}dynamicSlot(t){var e;let i=this.value,s=this.facet.compareInput,r=this.id,o=t[r]>>1,a=this.type==2,l=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?l=!0:f=="selection"?h=!0:(((e=t[f.id])!==null&&e!==void 0?e:1)&1)==0&&c.push(t[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(l&&u.docChanged||h&&(u.docChanged||u.selection)||tr(f,c)){let d=i(f);if(a?!Pa(d,f.values[o],s):!s(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d,p=u.config.address[r];if(p!=null){let m=Dn(u,p);if(this.dependencies.every(g=>g instanceof A?u.facet(g)===f.facet(g):g instanceof yt?u.field(g,!1)==f.field(g,!1):!0)||(a?Pa(d=i(f),m,s):s(d=i(f),m)))return f.values[o]=m,0}else d=i(f);return f.values[o]=d,1}}}};function Pa(n,t,e){if(n.length!=t.length)return!1;for(let i=0;in[l.id]),s=e.map(l=>l.type),r=i.filter(l=>!(l&1)),o=n[t.id]>>1;function a(l){let h=[];for(let c=0;ci===s),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet($a).find(i=>i.field==this);return((e==null?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:i=>(i.values[e]=this.create(i),1),update:(i,s)=>{let r=i.values[e],o=this.updateF(r,s);return this.compareF(r,o)?0:(i.values[e]=o,1)},reconfigure:(i,s)=>s.config.address[this.id]!=null?(i.values[e]=s.field(this),0):(i.values[e]=this.create(i),1)}}init(t){return[this,$a.of({field:this,create:t})]}get extension(){return this}},Ne={lowest:4,low:3,default:2,high:1,highest:0};function Vi(n){return t=>new er(t,n)}var oe={highest:Vi(Ne.highest),high:Vi(Ne.high),default:Vi(Ne.default),low:Vi(Ne.low),lowest:Vi(Ne.lowest)},er=class{constructor(t,e){this.inner=t,this.prec=e}},Bi=class{of(t){return new In(this,t)}reconfigure(t){return Bi.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}},In=class{constructor(t,e){this.compartment=t,this.inner=e}},Li=class{constructor(t,e,i,s,r,o){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=s,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(t,e,i){let s=[],r=Object.create(null),o=new Map;for(let u of Gd(t,e,o))u instanceof yt?s.push(u):(r[u.facet.id]||(r[u.facet.id]=[])).push(u);let a=Object.create(null),l=[],h=[];for(let u of s)a[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=i==null?void 0:i.config.facets;for(let u in r){let d=r[u],p=d[0].facet,m=c&&c[u]||[];if(d.every(g=>g.type==0))if(a[p.id]=l.length<<1|1,Js(m,d))l.push(i.facet(p));else{let g=p.combine(d.map(b=>b.value));l.push(i&&p.compare(g,i.facet(p))?i.facet(p):g)}else{for(let g of d)g.type==0?(a[g.id]=l.length<<1|1,l.push(g.value)):(a[g.id]=h.length<<1,h.push(b=>g.dynamicSlot(b)));a[p.id]=h.length<<1,h.push(g=>jd(g,p,d))}}let f=h.map(u=>u(a));return new Li(t,o,f,a,l,r)}};function Gd(n,t,e){let i=[[],[],[],[],[]],s=new Map;function r(o,a){let l=s.get(o);if(l!=null){if(l<=a)return;let h=i[l].indexOf(o);h>-1&&i[l].splice(h,1),o instanceof In&&e.delete(o.compartment)}if(s.set(o,a),Array.isArray(o))for(let h of o)r(h,a);else if(o instanceof In){if(e.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=t.get(o.compartment)||o.inner;e.set(o.compartment,h),r(h,a)}else if(o instanceof er)r(o.inner,o.prec);else if(o instanceof yt)i[a].push(o),o.provides&&r(o.provides,a);else if(o instanceof Di)i[a].push(o),o.facet.extensions&&r(o.facet.extensions,Ne.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(h,a)}}return r(n,Ne.default),i.reduce((o,a)=>o.concat(a))}function Ni(n,t){if(t&1)return 2;let e=t>>1,i=n.status[e];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[e]=4;let s=n.computeSlot(n,n.config.dynamicSlots[e]);return n.status[e]=2|s}function Dn(n,t){return t&1?n.config.staticValues[t>>1]:n.values[t>>1]}var Ta=A.define(),ir=A.define({combine:n=>n.some(t=>t),static:!0}),Ca=A.define({combine:n=>n.length?n[0]:void 0,static:!0}),Za=A.define(),Aa=A.define(),Ea=A.define(),Xa=A.define({combine:n=>n.length?n[0]:!1}),Ct=class{constructor(t,e){this.type=t,this.value=e}static define(){return new Ra}},Ra=class{of(t){return new Ct(this,t)}},Wa=class{constructor(t){this.map=t}of(t){return new U(this,t)}},U=class{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return e===void 0?void 0:e==this.value?this:new U(this.type,e)}is(t){return this.type==t}static define(t={}){return new Wa(t.map||(e=>e))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let s of t){let r=s.map(e);r&&i.push(r)}return i}};U.reconfigure=U.define();U.appendConfig=U.define();var J=class{constructor(t,e,i,s,r,o){this.startState=t,this.changes=e,this.selection=i,this.effects=s,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Qa(i,e.newLength),r.some(a=>a.type==J.time)||(this.annotations=r.concat(J.time.of(Date.now())))}static create(t,e,i,s,r,o){return new J(t,e,i,s,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(J.userEvent);return!!(e&&(e==t||e.length>t.length&&e.slice(0,t.length)==t&&e[t.length]=="."))}};J.time=Ct.define();J.userEvent=Ct.define();J.addToHistory=Ct.define();J.remote=Ct.define();function Ud(n,t){let e=[];for(let i=0,s=0;;){let r,o;if(i=n[i]))r=n[i++],o=n[i++];else if(s=0;s--){let r=i[s](n);r instanceof J?n=r:Array.isArray(r)&&r.length==1&&r[0]instanceof J?n=r[0]:n=Ma(t,di(r),!1)}return n}function Fd(n){let t=n.startState,e=t.facet(Ea),i=n;for(let s=e.length-1;s>=0;s--){let r=e[s](n);r&&Object.keys(r).length&&(i=qa(i,nr(t,r,n.changes.newLength),!0))}return i==n?n:J.create(t,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}var Kd=[];function di(n){return n==null?Kd:Array.isArray(n)?n:[n]}var Vt=function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n}(Vt||(Vt={})),Jd=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,sr;try{sr=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(n){}function tp(n){if(sr)return sr.test(n);for(let t=0;t"\x80"&&(e.toUpperCase()!=e.toLowerCase()||Jd.test(e)))return!0}return!1}function ep(n){return t=>{if(!/\S/.test(t))return Vt.Space;if(tp(t))return Vt.Word;for(let e=0;e-1)return Vt.Word;return Vt.Other}}var q=class{constructor(t,e,i,s,r,o){this.config=t,this.doc=e,this.selection=i,this.values=s,this.status=t.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let a=0;as.set(h,l)),e=null),s.set(a.value.compartment,a.value.extension)):a.is(U.reconfigure)?(e=null,i=a.value):a.is(U.appendConfig)&&(e=null,i=di(i).concat(a.value));let r;e?r=t.startState.values.slice():(e=Li.resolve(i,s,this),r=new q(e,this.doc,this.selection,e.dynamicSlots.map(()=>null),(l,h)=>h.reconfigure(l,this),null).values);let o=t.startState.facet(ir)?t.newSelection:t.newSelection.asSingle();new q(e,t.newDoc,o,r,(a,l)=>l.update(a,t),t)}replaceSelection(t){return typeof t=="string"&&(t=this.toText(t)),this.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:t},range:S.cursor(e.from+t.length)}))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),s=this.changes(i.changes),r=[i.range],o=di(i.effects);for(let a=1;ao.spec.fromJSON(a,l)))}}return q.create({doc:t.doc,selection:S.fromJSON(t.selection),extensions:e.extensions?s.concat([e.extensions]):s})}static create(t={}){let e=Li.resolve(t.extensions||[],new Map),i=t.doc instanceof W?t.doc:W.of((t.doc||"").split(e.staticFacet(q.lineSeparator)||Us)),s=t.selection?t.selection instanceof S?t.selection:S.single(t.selection.anchor,t.selection.head):S.single(0);return Qa(s,i.length),e.staticFacet(ir)||(s=s.asSingle()),new q(e,i,s,e.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(q.tabSize)}get lineBreak(){return this.facet(q.lineSeparator)||` `}get readOnly(){return this.facet(Xa)}phrase(t,...e){for(let i of this.facet(q.phrases))if(Object.prototype.hasOwnProperty.call(i,t)){t=i[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,(i,s)=>{if(s=="$")return"$";let r=+(s||1);return!r||r>e.length?i:e[r-1]})),t}languageDataAt(t,e,i=-1){let s=[];for(let r of this.facet(Ta))for(let o of r(this,e,i))Object.prototype.hasOwnProperty.call(o,t)&&s.push(o[t]);return s}charCategorizer(t){return ep(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:s}=this.doc.lineAt(t),r=this.charCategorizer(t),o=t-i,a=t-i;for(;o>0;){let l=ht(e,o,!1);if(r(e.slice(l,o))!=Vt.Word)break;o=l}for(;an.length?n[0]:4});q.lineSeparator=Ca;q.readOnly=Xa;q.phrases=A.define({compare(n,t){let e=Object.keys(n),i=Object.keys(t);return e.length==i.length&&e.every(s=>n[s]==t[s])}});q.languageData=Ta;q.changeFilter=Za;q.transactionFilter=Aa;q.transactionExtender=Ea;Bi.reconfigure=U.define();function _e(n,t,e={}){let i={};for(let s of n)for(let r of Object.keys(s)){let o=s[r],a=i[r];if(a===void 0)i[r]=o;else if(!(a===o||o===void 0))if(Object.hasOwnProperty.call(e,r))i[r]=e[r](a,o);else throw new Error("Config merge conflict for field "+r)}for(let s in t)i[s]===void 0&&(i[s]=t[s]);return i}var ae=class{eq(t){return this==t}range(t,e=t){return pi.create(t,e,this)}};ae.prototype.startSide=ae.prototype.endSide=0;ae.prototype.point=!1;ae.prototype.mapMode=ct.TrackDel;var pi=class{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new pi(t,e,i)}};function rr(n,t){return n.from-t.from||n.value.startSide-t.value.startSide}var Vn=class{constructor(t,e,i,s){this.from=t,this.to=e,this.value=i,this.maxPoint=s}get length(){return this.to[this.to.length-1]}findIndex(t,e,i,s=0){let r=i?this.to:this.from;for(let o=s,a=r.length;;){if(o==a)return o;let l=o+a>>1,h=r[l]-t||(i?this.value[l].endSide:this.value[l].startSide)-e;if(l==o)return h>=0?o:a;h>=0?a=l:o=l+1}}between(t,e,i,s){for(let r=this.findIndex(e,-1e9,!0),o=this.findIndex(i,1e9,!1,r);rd||u==d&&h.startSide>0&&h.endSide<=0)continue;(d-u||h.endSide-h.startSide)<0||(o<0&&(o=u),h.point&&(a=Math.max(a,d-u)),i.push(h),s.push(u-o),r.push(d-o))}return{mapped:i.length?new Vn(s,r,i,a):null,pos:o}}},_=class{constructor(t,e,i,s){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=s}static create(t,e,i,s){return new _(t,e,i,s)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:i=!1,filterFrom:s=0,filterTo:r=this.length}=t,o=t.filter;if(e.length==0&&!o)return this;if(i&&(e=e.slice().sort(rr)),this.isEmpty)return e.length?_.of(e):this;let a=new or(this,null,-1).goto(0),l=0,h=[],c=new ge;for(;a.value||l=0){let f=e[l++];c.addInner(f.from,f.to,f.value)||h.push(f)}else a.rangeIndex==1&&a.chunkIndexthis.chunkEnd(a.chunkIndex)||ra.to||r=r&&t<=r+o.length&&o.between(r,t-r,e-r,i)===!1)return}this.nextLayer.between(t,e,i)}}iter(t=0){return Oi.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Oi.from(t).goto(e)}static compare(t,e,i,s,r=-1){let o=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=r),a=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=r),l=Ya(o,a,i),h=new mi(o,l,r),c=new mi(a,l,r);i.iterGaps((f,u,d)=>Ia(h,f,c,u,d,s)),i.empty&&i.length==0&&Ia(h,0,c,0,0,s)}static eq(t,e,i=0,s){s==null&&(s=1e9-1);let r=t.filter(c=>!c.isEmpty&&e.indexOf(c)<0),o=e.filter(c=>!c.isEmpty&&t.indexOf(c)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let a=Ya(r,o),l=new mi(r,a,0).goto(i),h=new mi(o,a,0).goto(i);for(;;){if(l.to!=h.to||!lr(l.active,h.active)||l.point&&(!h.point||!l.point.eq(h.point)))return!1;if(l.to>s)return!0;l.next(),h.next()}}static spans(t,e,i,s,r=-1){let o=new mi(t,null,r).goto(e),a=e,l=o.openStart;for(;;){let h=Math.min(o.to,i);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFroma&&(s.span(a,h,o.active,l),l=o.openEnd(h));if(o.to>i)return l+(o.point&&o.to>i?1:0);a=o.to,o.next()}}static of(t,e=!1){let i=new ge;for(let s of t instanceof pi?[t]:e?ip(t):t)i.add(s.from,s.to,s.value);return i.finish()}static join(t){if(!t.length)return _.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let s=t[i];s!=_.empty;s=s.nextLayer)e=new _(s.chunkPos,s.chunk,e,Math.max(s.maxPoint,e.maxPoint));return e}};_.empty=new _([],[],null,-1);function ip(n){if(n.length>1)for(let t=n[0],e=1;e0)return n.slice().sort(rr);t=i}return n}_.empty.nextLayer=_.empty;var ge=class{finishChunk(t){this.chunks.push(new Vn(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,t&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new ge)).add(t,e,i)}addInner(t,e,i){let s=t-this.lastTo||i.startSide-this.last.endSide;if(s<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=t),this.from.push(t-this.chunkStart),this.to.push(e-this.chunkStart),this.last=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(t,e){if((t-this.lastTo||e.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);let i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(_.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return t;let e=_.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}};function Ya(n,t,e){let i=new Map;for(let r of n)for(let o=0;o=this.minPoint)break}}setRangeIndex(t){if(t==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&s.push(new or(o,e,i,r));return s.length==1?s[0]:new Oi(s)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let i=this.heap.length>>1;i>=0;i--)ar(this.heap,i);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let i=this.heap.length>>1;i>=0;i--)ar(this.heap,i);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),ar(this.heap,0)}}};function ar(n,t){for(let e=n[t];;){let i=(t<<1)+1;if(i>=n.length)break;let s=n[i];if(i+1=0&&(s=n[i+1],i++),e.compare(s)<0)break;n[i]=e,n[t]=s,t=i}}var mi=class{constructor(t,e,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Oi.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){Bn(this.active,t),Bn(this.activeTo,t),Bn(this.activeRank,t),this.minActive=Da(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:s,rank:r}=this.cursor;for(;e0;)e++;Ln(this.active,e,i),Ln(this.activeTo,e,s),Ln(this.activeRank,e,r),t&&Ln(t,e,this.cursor.from),this.minActive=Da(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>t){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),i&&Bn(i,s)}else if(this.cursor.value)if(this.cursor.from>t){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let r=this.cursor.value;if(!r.point)this.addActive(i),this.cursor.next();else if(e&&this.cursor.to==this.to&&this.cursor.from=0&&i[s]=0&&!(this.activeRank[i]t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}};function Ia(n,t,e,i,s,r){n.goto(t),e.goto(i);let o=i+s,a=i,l=i-t;for(;;){let h=n.to+l-e.to||n.endSide-e.endSide,c=h<0?n.to+l:e.to,f=Math.min(c,o);if(n.point||e.point?n.point&&e.point&&(n.point==e.point||n.point.eq(e.point))&&lr(n.activeForPoint(n.to),e.activeForPoint(e.to))||r.comparePoint(a,f,n.point,e.point):f>a&&!lr(n.active,e.active)&&r.compareRange(a,f,n.active,e.active),c>o)break;a=c,h<=0&&n.next(),h>=0&&e.next()}}function lr(n,t){if(n.length!=t.length)return!1;for(let e=0;e=t;i--)n[i+1]=n[i];n[t]=e}function Da(n,t){let e=-1,i=1e9;for(let s=0;s=t)return s;if(s==n.length)break;r+=n.charCodeAt(s)==9?e-r%e:1,s=ht(n,s)}return i===!0?-1:n.length}var hr="\u037C",Ba=typeof Symbol=="undefined"?"__"+hr:Symbol.for(hr),cr=typeof Symbol=="undefined"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),La=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{},Ut=class{constructor(t,e){this.rules=[];let{finish:i}=e||{};function s(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function r(o,a,l,h){let c=[],f=/^@(\w+)\b/.exec(o[0]),u=f&&f[1]=="keyframes";if(f&&a==null)return l.push(o[0]+";");for(let d in a){let p=a[d];if(/&/.test(d))r(d.split(/,\s*/).map(m=>o.map(g=>m.replace(/&/,g))).reduce((m,g)=>m.concat(g)),p,l);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+d+") should be a primitive value.");r(s(d),p,c,u)}else p!=null&&c.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(c.length||u)&&l.push((i&&!f&&!h?o.map(i):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in t)r(s(o),t[o],this.rules)}getRules(){return this.rules.join(` `)}static newName(){let t=La[Ba]||1;return La[Ba]=t+1,hr+t.toString(36)}static mount(t,e,i){let s=t[cr],r=i&&i.nonce;s?r&&s.setNonce(r):s=new _a(t,r),s.mount(Array.isArray(e)?e:[e],t)}},Na=new Map,_a=class{constructor(t,e){let i=t.ownerDocument||t,s=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&s.CSSStyleSheet){let r=Na.get(i);if(r)return t[cr]=r;this.sheet=new s.CSSStyleSheet,Na.set(i,this)}else this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);this.modules=[],t[cr]=this}mount(t,e){let i=this.sheet,s=0,r=0;for(let o=0;o-1&&(this.modules.splice(l,1),r--,l=-1),l==-1){if(this.modules.splice(r++,0,a),i)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},za=typeof navigator!="undefined"&&/Chrome\/(\d+)/.exec(navigator.userAgent),RS=typeof navigator!="undefined"&&/Gecko\/\d+/.test(navigator.userAgent),np=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),sp=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),rp=np||za&&+za[1]<57;for(rt=0;rt<10;rt++)be[48+rt]=be[96+rt]=String(rt);var rt;for(rt=1;rt<=24;rt++)be[rt+111]="F"+rt;var rt;for(rt=65;rt<=90;rt++)be[rt]=String.fromCharCode(rt+32),gi[rt]=String.fromCharCode(rt);var rt;for(Nn in be)gi.hasOwnProperty(Nn)||(gi[Nn]=be[Nn]);var Nn;function ja(n){var t=rp&&(n.ctrlKey||n.altKey||n.metaKey)||sp&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",e=!t&&n.key||(n.shiftKey?gi:be)[n.keyCode]||n.key||"Unidentified";return e=="Esc"&&(e="Escape"),e=="Del"&&(e="Delete"),e=="Left"&&(e="ArrowLeft"),e=="Up"&&(e="ArrowUp"),e=="Right"&&(e="ArrowRight"),e=="Down"&&(e="ArrowDown"),e}function _n(n){let t;return n.nodeType==11?t=n.getSelection?n:n.ownerDocument:t=n,t.getSelection()}function fr(n,t){return t?n==t||n.contains(t.nodeType!=1?t.parentNode:t):!1}function op(n){let t=n.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function zn(n,t){if(!t.anchorNode)return!1;try{return fr(n,t.anchorNode)}catch(e){return!1}}function _i(n){return n.nodeType==3?je(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function zi(n,t,e,i){return e?Ga(n,t,e,i,-1)||Ga(n,t,e,i,1):!1}function ze(n){for(var t=0;;t++)if(n=n.previousSibling,!n)return t}function jn(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function Ga(n,t,e,i,s){for(;;){if(n==e&&t==i)return!0;if(t==(s<0?0:Se(n))){if(n.nodeName=="DIV")return!1;let r=n.parentNode;if(!r||r.nodeType!=1)return!1;t=ze(n)+(s<0?0:1),n=r}else if(n.nodeType==1){if(n=n.childNodes[t+(s<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;t=s<0?Se(n):0}else return!1}}function Se(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ur(n,t){let e=t?n.left:n.right;return{left:e,right:e,top:n.top,bottom:n.bottom}}function ap(n){let t=n.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function Ua(n,t){let e=t.width/n.offsetWidth,i=t.height/n.offsetHeight;return(e>.995&&e<1.005||!isFinite(e)||Math.abs(t.width-n.offsetWidth)<1)&&(e=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(t.height-n.offsetHeight)<1)&&(i=1),{scaleX:e,scaleY:i}}function lp(n,t,e,i,s,r,o,a){let l=n.ownerDocument,h=l.defaultView||window;for(let c=n,f=!1;c&&!f;)if(c.nodeType==1){let u,d=c==l.body,p=1,m=1;if(d)u=ap(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let w=c.getBoundingClientRect();({scaleX:p,scaleY:m}=Ua(c,w)),u={left:w.left,right:w.left+c.clientWidth*p,top:w.top,bottom:w.top+c.clientHeight*m}}let g=0,b=0;if(s=="nearest")t.top0&&t.bottom>u.bottom+b&&(b=t.bottom-u.bottom+b+o)):t.bottom>u.bottom&&(b=t.bottom-u.bottom+o,e<0&&t.top-b0&&t.right>u.right+g&&(g=t.right-u.right+g+r)):t.right>u.right&&(g=t.right-u.right+r,e<0&&t.lefte.clientHeight||e.scrollWidth>e.clientWidth)return e;e=e.assignedSlot||e.parentNode}else if(e.nodeType==11)e=e.host;else break;return null}var Ha=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?Se(e):0),i,Math.min(t.focusOffset,i?Se(i):0))}set(t,e,i,s){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=s}},bi=null;function Fa(n){if(n.setActive)return n.setActive();if(bi)return n.focus(bi);let t=[];for(let e=n;e&&(t.push(e,e.scrollTop,e.scrollLeft),e!=e.ownerDocument);e=e.parentNode);if(n.focus(bi==null?{get preventScroll(){return bi={preventScroll:!0},!0}}:void 0),!bi){bi=!1;for(let e=0;eMath.max(1,n.scrollHeight-n.clientHeight-4)}function el(n,t){for(let e=n,i=t;;){if(e.nodeType==3&&i>0)return{node:e,offset:i};if(e.nodeType==1&&i>0){if(e.contentEditable=="false")return null;e=e.childNodes[i-1],i=Se(e)}else if(e.parentNode&&!jn(e))i=ze(e),e=e.parentNode;else return null}}function il(n,t){for(let e=n,i=t;;){if(e.nodeType==3&&ie)return f.domBoundsAround(t,e,h);if(u>=t&&s==-1&&(s=l,r=h),h>e&&f.dom.parentNode==this.dom){o=l,a=c;break}c=u,h=u+f.breakAfter}return{from:r,to:a<0?i+this.length:a,startDOM:(s?this.children[s-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o=0?this.children[o].dom:null}}markDirty(t=!1){this.flags|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.flags|=2),e.flags&1)return;e.flags|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,this.flags&7&&this.markParentsDirty(!0))}setDOM(t){this.dom!=t&&(this.dom&&(this.dom.cmView=null),this.dom=t,t.cmView=this)}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,i=dr){this.markDirty();for(let s=t;sthis.pos||t==this.pos&&(e>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=t-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}};function sl(n,t,e,i,s,r,o,a,l){let{children:h}=n,c=h.length?h[t]:null,f=r.length?r[r.length-1]:null,u=f?f.breakAfter:o;if(!(t==i&&c&&!o&&!u&&r.length<2&&c.merge(e,s,r.length?f:null,e==0,a,l))){if(i0&&(!o&&r.length&&c.merge(e,c.length,r[0],!1,a,0)?c.breakAfter=r.shift().breakAfter:(e2),$={mac:cl||/Mac/.test(Zt.platform),windows:/Win/.test(Zt.platform),linux:/Linux|X11/.test(Zt.platform),ie:Gn,ie_version:ol?Or.documentMode||6:gr?+gr[1]:mr?+mr[1]:0,gecko:al,gecko_version:al?+(/Firefox\/(\d+)/.exec(Zt.userAgent)||[0,0])[1]:0,chrome:!!br,chrome_version:br?+br[1]:0,ios:cl,android:/Android\b/.test(Zt.userAgent),webkit:ll,safari:hl,webkit_version:ll?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:Or.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"},up=256,Bt=class extends j{constructor(t){super();this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){t.nodeType==3&&this.createDOM(t)}merge(t,e,i){return this.flags&8||i&&(!(i instanceof Bt)||this.length-(e-t)+i.length>up||i.flags&8)?!1:(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new Bt(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e.flags|=this.flags&8,e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new ft(this.dom,t)}domBoundsAround(t,e,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return dp(this.dom,t,e)}},le=class extends j{constructor(t,e=[],i=0){super();this.mark=t,this.children=e,this.length=i;for(let s of e)s.setParent(this)}setAttrs(t){if(Ja(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}canReuseDOM(t){return super.canReuseDOM(t)&&!((this.flags|t.flags)&8)}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.flags|=4|2)}sync(t,e){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,s,r,o){return i&&(!(i instanceof le&&i.mark.eq(this.mark))||t&&r<=0||et&&e.push(i=t&&(s=r),i=l,r++}let o=this.length-t;return this.length=t,s>-1&&(this.children.length=s,this.markDirty()),new le(this.mark,e,o)}domAtPos(t){return fl(this,t)}coordsAt(t,e){return dl(this,t,e)}};function dp(n,t,e){let i=n.nodeValue.length;t>i&&(t=i);let s=t,r=t,o=0;t==0&&e<0||t==i&&e>=0?$.chrome||$.gecko||(t?(s--,o=1):r=0)?0:a.length-1];return $.safari&&!o&&l.width==0&&(l=Array.prototype.find.call(a,h=>h.width)||l),o?ur(l,o<0):l||null}var Ee=class extends j{static create(t,e,i){return new Ee(t,e,i)}constructor(t,e,i){super();this.widget=t,this.length=e,this.side=i,this.prevWidget=null}split(t){let e=Ee.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){(!this.dom||!this.widget.updateDOM(this.dom,t))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(t,e,i,s,r,o){return i&&(!(i instanceof Ee)||!this.widget.compare(i.widget)||t>0&&r<=0||e0)?ft.before(this.dom):ft.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let s=this.dom.getClientRects(),r=null;if(!s.length)return null;let o=this.side?this.side<0:t>0;for(let a=o?s.length-1:0;r=s[a],!(t>0?a==0:a==s.length-1||r.top0?ft.before(this.dom):ft.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return W.empty}get isHidden(){return!0}};Bt.prototype.children=Ee.prototype.children=Ge.prototype.children=dr;function fl(n,t){let e=n.dom,{children:i}=n,s=0;for(let r=0;sr&&t0;r--){let o=i[r-1];if(o.dom.parentNode==e)return o.domAtPos(o.length)}for(let r=s;r0&&t instanceof le&&s.length&&(i=s[s.length-1])instanceof le&&i.mark.eq(t.mark)?ul(i,t.children[0],e-1):(s.push(t),t.setParent(n)),n.length+=t.length}function dl(n,t,e){let i=null,s=-1,r=null,o=-1;function a(h,c){for(let f=0,u=0;f=c&&(d.children.length?a(d,c-u):(!r||r.isHidden&&e>0)&&(p>c||u==p&&d.getSide()>0)?(r=d,o=c-u):(u-1?1:0)!=s.length-(e&&s.indexOf(e)>-1?1:0))return!1;for(let r of i)if(r!=e&&(s.indexOf(r)==-1||n[r]!==t[r]))return!1;return!0}function yr(n,t,e){let i=!1;if(t)for(let s in t)e&&s in e||(i=!0,s=="style"?n.style.cssText="":n.removeAttribute(s));if(e)for(let s in e)t&&t[s]==e[s]||(i=!0,s=="style"?n.style.cssText=e[s]:n.setAttribute(s,e[s]));return i}function Op(n){let t=Object.create(null);for(let e=0;e0&&this.children[i-1].length==0;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=t,e}transferDOM(t){!this.dom||(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){wr(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){ul(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=Sr(e,this.attrs||{})),i&&(this.attrs=Sr({class:i},this.attrs||{}))}domAtPos(t){return fl(this,t)}reuseDOM(t){t.nodeName=="DIV"&&(this.setDOM(t),this.flags|=4|2)}sync(t,e){var i;this.dom?this.flags&4&&(Ja(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(yr(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let s=this.dom.lastChild;for(;s&&j.get(s)instanceof le;)s=s.lastChild;if(!s||!this.length||s.nodeName!="BR"&&((i=j.get(s))===null||i===void 0?void 0:i.isEditable)==!1&&(!$.ios||!this.children.some(r=>r instanceof Bt))){let r=document.createElement("BR");r.cmIgnore=!0,this.dom.appendChild(r)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let t=0,e;for(let i of this.children){if(!(i instanceof Bt)||/[^ -~]/.test(i.text))return null;let s=_i(i.dom);if(s.length!=1)return null;t+=s[0].width,e=s[0].height}return t?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:t/this.length,textHeight:e}:null}coordsAt(t,e){let i=dl(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:s}=this.parent.view.viewState,r=i.bottom-i.top;if(Math.abs(r-s.lineHeight)<2&&s.textHeight=e){if(r instanceof ot)return r;if(o>e)break}s=o+r.breakAfter}return null}},we=class extends j{constructor(t,e,i){super();this.widget=t,this.length=e,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,s,r,o){return i&&(!(i instanceof we)||!this.widget.compare(i.widget)||t>0&&r<=0||e0}},ye=class{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}},At=function(n){return n[n.Text=0]="Text",n[n.WidgetBefore=1]="WidgetBefore",n[n.WidgetAfter=2]="WidgetAfter",n[n.WidgetRange=3]="WidgetRange",n}(At||(At={})),V=class extends ae{constructor(t,e,i,s){super();this.startSide=t,this.endSide=e,this.widget=i,this.spec=s}get heightRelevant(){return!1}static mark(t){return new wi(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new ke(t,e,e,i,t.widget||null,!1)}static replace(t){let e=!!t.block,i,s;if(t.isBlockGap)i=-5e8,s=4e8;else{let{start:r,end:o}=Ol(t,e);i=(r?e?-3e8:-1:5e8)-1,s=(o?e?2e8:1:-6e8)+1}return new ke(t,i,s,e,t.widget||null,!0)}static line(t){return new yi(t)}static set(t,e=!1){return _.of(t,e)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};V.none=_.empty;var wi=class extends V{constructor(t){let{start:e,end:i}=Ol(t);super(e?-1:5e8,i?1:-6e8,null,t);this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){var e,i;return this==t||t instanceof wi&&this.tagName==t.tagName&&(this.class||((e=this.attrs)===null||e===void 0?void 0:e.class))==(t.class||((i=t.attrs)===null||i===void 0?void 0:i.class))&&wr(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}};wi.prototype.point=!1;var yi=class extends V{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof yi&&this.spec.class==t.spec.class&&wr(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}};yi.prototype.mapMode=ct.TrackBefore;yi.prototype.point=!0;var ke=class extends V{constructor(t,e,i,s,r,o){super(e,i,r,t);this.block=s,this.isReplace=o,this.mapMode=s?e<=0?ct.TrackBefore:ct.TrackAfter:ct.TrackDel}get type(){return this.startSide!=this.endSide?At.WidgetRange:this.startSide<=0?At.WidgetBefore:At.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof ke&&mp(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}};ke.prototype.point=!0;function Ol(n,t=!1){let{inclusiveStart:e,inclusiveEnd:i}=n;return e==null&&(e=n.inclusive),i==null&&(i=n.inclusive),{start:e??t,end:i??t}}function mp(n,t){return n==t||!!(n&&t&&n.compare(t))}function kr(n,t,e,i=0){let s=e.length-1;s>=0&&e[s]+i>=n?e[s]=Math.max(e[s],t):e.push(n,t)}var ki=class{constructor(t,e,i,s){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=s,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=t.iter(),this.skip=e}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!(t.breakAfter||t instanceof we&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new ot),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Un(new Ge(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(t&&this.content.length&&this.content[this.content.length-1]instanceof we)&&this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:r,lineBreak:o,done:a}=this.cursor.next(this.skip);if(this.skip=0,a)throw new Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}else this.text=r,this.textOff=0}let s=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(Un(new Bt(this.text.slice(this.textOff,this.textOff+s)),e),i),this.atCursorPos=!0,this.textOff+=s,t-=s,i=0}}span(t,e,i,s){this.buildText(e-t,i,s),this.pos=e,this.openStart<0&&(this.openStart=s)}point(t,e,i,s,r,o){if(this.disallowBlockEffectsFor[o]&&i instanceof ke){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(e>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let a=e-t;if(i instanceof ke)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new we(i.widget||Xe.block,a,i));else{let l=Ee.create(i.widget||Xe.inline,a,a?0:i.startSide),h=this.atCursorPos&&!l.isEditable&&r<=s.length&&(t0),c=!l.isEditable&&(ts.length||i.startSide<=0),f=this.getLine();this.pendingBuffer==2&&!h&&!l.isEditable&&(this.pendingBuffer=0),this.flushBuffer(s),h&&(f.append(Un(new Ge(1),s),r),r=s.length+Math.max(0,r-s.length)),f.append(Un(l,s),r),this.atCursorPos=c,this.pendingBuffer=c?ts.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=s.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);a&&(this.textOff+a<=this.text.length?this.textOff+=a:(this.skip+=a-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=r)}static build(t,e,i,s,r){let o=new ki(t,e,i,r);return o.openEnd=_.spans(s,e,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}};function Un(n,t){for(let e of t)n=new le(e,[n],n.length);return n}var Xe=class extends ye{constructor(t){super();this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};Xe.inline=new Xe("span");Xe.block=new Xe("div");var tt=function(n){return n[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n}(tt||(tt={})),Ue=tt.LTR,vr=tt.RTL;function ml(n){let t=[];for(let e=0;e=e){if(a.level==i)return o;(r<0||(s!=0?s<0?a.frome:t[r].level>a.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}};function bl(n,t){if(n.length!=t.length)return!1;for(let e=0;e=0;m-=3)if(he[m+1]==-d){let g=he[m+2],b=g&2?s:g&4?g&1?r:s:0;b&&(H[f]=H[he[m]]=b),a=m;break}}else{if(he.length==189)break;he[a++]=f,he[a++]=u,he[a++]=l}else if((p=H[f])==2||p==1){let m=p==s;l=m?0:1;for(let g=a-3;g>=0;g-=3){let b=he[g+2];if(b&2)break;if(m)he[g+2]|=2;else{if(b&4)break;he[g+2]|=4}}}}}function kp(n,t,e,i){for(let s=0,r=i;s<=e.length;s++){let o=s?e[s-1].to:n,a=sl;)p==g&&(p=e[--m].from,g=m?e[m-1].to:n),H[--p]=d;l=c}else r=h,l++}}}function Qr(n,t,e,i,s,r,o){let a=i%2?2:1;if(i%2==s%2)for(let l=t,h=0;ll&&o.push(new ve(l,m.from,d));let g=m.direction==Ue!=!(d%2);Pr(n,g?i+1:i,s,m.inner,m.from,m.to,o),l=m.to}p=m.to}else{if(p==e||(c?H[p]!=a:H[p]==a))break;p++}u?Qr(n,l,p,i+1,s,u,o):lt;){let c=!0,f=!1;if(!h||l>r[h-1].to){let m=H[l-1];m!=a&&(c=!1,f=m==16)}let u=!c&&a==1?[]:null,d=c?i:i+1,p=l;t:for(;;)if(h&&p==r[h-1].to){if(f)break t;let m=r[--h];if(!c)for(let g=m.from,b=h;;){if(g==t)break t;if(b&&r[b-1].to==g)g=r[--b].from;else{if(H[g-1]==a)break t;break}}if(u)u.push(m);else{m.toH.length;)H[H.length]=256;let i=[],s=t==Ue?0:1;return Pr(n,s,s,e,0,n.length,i),i}function Sl(n){return[new ve(0,n,0)]}var wl="";function xp(n,t,e,i,s){var r;let o=i.head-n.from,a=ve.find(t,o,(r=i.bidiLevel)!==null&&r!==void 0?r:-1,i.assoc),l=t[a],h=l.side(s,e);if(o==h){let u=a+=s?1:-1;if(u<0||u>=t.length)return null;l=t[a=u],o=l.side(!s,e),h=l.side(s,e)}let c=ht(n.text,o,l.forward(s,e));(cl.to)&&(c=h),wl=n.text.slice(Math.min(o,c),Math.max(o,c));let f=a==(s?t.length-1:0)?null:t[a+(s?1:-1)];return f&&c==h&&f.level+(s?0:1)n.some(t=>t)}),Tl=A.define({combine:n=>n.some(t=>t)}),Cl=A.define(),He=class{constructor(t,e="nearest",i="nearest",s=5,r=5,o=!1){this.range=t,this.y=e,this.x=i,this.yMargin=s,this.xMargin=r,this.isSnapshot=o}map(t){return t.empty?this:new He(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new He(S.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},Hn=U.define({map:(n,t)=>n.map(t)});function Lt(n,t,e){let i=n.facet(xl);i.length?i[0](t):window.onerror?window.onerror(String(t),e,void 0,void 0,t):e?console.error(e+":",t):console.error(t)}var Fn=A.define({combine:n=>n.length?n[0]:!0}),Pp=0,ji=A.define(),vt=class{constructor(t,e,i,s,r){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=s,this.extension=r(this)}static define(t,e){let{eventHandlers:i,eventObservers:s,provide:r,decorations:o}=e||{};return new vt(Pp++,t,i,s,a=>{let l=[ji.of(a)];return o&&l.push(Gi.of(h=>{let c=h.plugin(a);return c?o(c):V.none})),r&&l.push(r(a)),l})}static fromClass(t,e){return vt.define(i=>new t(i),e)}},Kn=class{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}update(t){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(i){if(Lt(e.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(s){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(t)}catch(e){Lt(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if((e=this.value)===null||e===void 0?void 0:e.destroy)try{this.value.destroy()}catch(i){Lt(t.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},Zl=A.define(),Tr=A.define(),Gi=A.define(),Al=A.define(),Cr=A.define(),El=A.define();function Xl(n,t){let e=n.state.facet(El);if(!e.length)return e;let i=e.map(r=>r instanceof Function?r(n):r),s=[];return _.spans(i,t.from,t.to,{point(){},span(r,o,a,l){let h=r-t.from,c=o-t.from,f=s;for(let u=a.length-1;u>=0;u--,l--){let d=a[u].spec.bidiIsolate,p;if(d==null&&(d=Qp(t.text,h,c)),l>0&&f.length&&(p=f[f.length-1]).to==h&&p.direction==d)p.to=c,f=p.inner;else{let m={from:h,to:c,direction:d,inner:[]};f.push(m),f=m.inner}}}}),s}var Rl=A.define();function Wl(n){let t=0,e=0,i=0,s=0;for(let r of n.state.facet(Rl)){let o=r(n);o&&(o.left!=null&&(t=Math.max(t,o.left)),o.right!=null&&(e=Math.max(e,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(s=Math.max(s,o.bottom)))}return{left:t,right:e,top:i,bottom:s}}var Ui=A.define(),Et=class{constructor(t,e,i,s){this.fromA=t,this.toA=e,this.fromB=i,this.toB=s}join(t){return new Et(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let s=t[e-1];if(!(s.fromA>i.toA)){if(s.toAc)break;r+=2}if(!l)return i;new Et(l.fromA,l.toA,l.fromB,l.toB).addToSet(i),o=l.toA,a=l.toB}}},Hi=class{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=st.empty(this.startState.doc.length);for(let r of i)this.changes=this.changes.compose(r.changes);let s=[];this.changes.iterChangedRanges((r,o,a,l)=>s.push(new Et(r,o,a,l))),this.changedRanges=s}static create(t,e,i){return new Hi(t,e,i)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&(8|2))>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},Zr=class extends j{get length(){return this.view.state.doc.length}constructor(t){super();this.view=t,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.compositionBarrier=V.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new ot],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Et(0,0,0,t.state.doc.length)],0,null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:h,toA:c})=>cthis.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0);let s=-1;this.view.inputState.composing>=0&&(((e=this.domChanged)===null||e===void 0?void 0:e.newSel)?s=this.domChanged.newSel.head:!Rp(t.changes,this.hasComposition)&&!t.selectionSet&&(s=t.state.selection.main.head));let r=s>-1?Cp(this.view,t.changes,s):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:h,to:c}=this.hasComposition;i=new Et(h,c,t.changes.mapPos(h,-1),t.changes.mapPos(c,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,($.ie||$.chrome)&&!r&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,a=this.updateDeco(),l=Ep(o,a,t.changes);return i=Et.extendWithRanges(i,l),!(this.flags&7)&&i.length==0?!1:(this.updateInner(i,t.startState.doc.length,r),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e,i);let{observer:s}=this.view;s.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=$.chrome||$.ios?{node:s.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=~7,o&&(o.written||s.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(o=>o.flags&=~8);let r=[];if(this.view.viewport.from||this.view.viewport.to=0?s[o]:null;if(!a)break;let{fromA:l,toA:h,fromB:c,toB:f}=a,u,d,p,m;if(i&&i.range.fromBc){let P=ki.build(this.view.state.doc,c,i.range.fromB,this.decorations,this.dynamicDecorationMap),k=ki.build(this.view.state.doc,i.range.toB,f,this.decorations,this.dynamicDecorationMap);d=P.breakAtStart,p=P.openStart,m=k.openEnd;let T=this.compositionView(i);k.breakAtStart?T.breakAfter=1:k.content.length&&T.merge(T.length,T.length,k.content[0],!1,k.openStart,0)&&(T.breakAfter=k.content[0].breakAfter,k.content.shift()),P.content.length&&T.merge(0,0,P.content[P.content.length-1],!0,0,P.openEnd)&&P.content.pop(),u=P.content.concat(T).concat(k.content)}else({content:u,breakAtStart:d,openStart:p,openEnd:m}=ki.build(this.view.state.doc,c,f,this.decorations,this.dynamicDecorationMap));let{i:g,off:b}=r.findPos(h,1),{i:w,off:x}=r.findPos(l,-1);sl(this,w,x,g,b,u,d,p,m)}i&&this.fixCompositionDOM(i)}compositionView(t){let e=new Bt(t.text.nodeValue);e.flags|=8;for(let{deco:s}of t.marks)e=new le(s,[e],e.length);let i=new ot;return i.append(e,0),i}fixCompositionDOM(t){let e=(r,o)=>{o.flags|=8|(o.children.some(l=>l.flags&7)?1:0),this.markedForComposition.add(o);let a=j.get(r);a&&a!=o&&(a.dom=null),o.setDOM(r)},i=this.childPos(t.range.fromB,1),s=this.children[i.i];e(t.line,s);for(let r=t.marks.length-1;r>=-1;r--)i=s.childPos(i.off,1),s=s.children[i.i],e(r>=0?t.marks[r].node:t.text,s)}updateSelection(t=!1,e=!1){(t||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let i=this.view.root.activeElement,s=i==this.dom,r=!s&&zn(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(s||e||r))return;let o=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,l=this.moveToLine(this.domAtPos(a.anchor)),h=a.empty?l:this.moveToLine(this.domAtPos(a.head));if($.gecko&&a.empty&&!this.hasComposition&&Tp(l)){let f=document.createTextNode("");this.view.observer.ignore(()=>l.node.insertBefore(f,l.node.childNodes[l.offset]||null)),l=h=new ft(f,0),o=!0}let c=this.view.observer.selectionRange;(o||!c.focusNode||(!zi(l.node,l.offset,c.anchorNode,c.anchorOffset)||!zi(h.node,h.offset,c.focusNode,c.focusOffset))&&!this.suppressWidgetCursorChange(c,a))&&(this.view.observer.ignore(()=>{$.android&&$.chrome&&this.dom.contains(c.focusNode)&&Xp(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let f=_n(this.view.root);if(f)if(a.empty){if($.gecko){let u=Zp(l.node,l.offset);if(u&&u!=(1|2)){let d=(u==1?el:il)(l.node,l.offset);d&&(l=new ft(d.node,d.offset))}}f.collapse(l.node,l.offset),a.bidiLevel!=null&&f.caretBidiLevel!==void 0&&(f.caretBidiLevel=a.bidiLevel)}else if(f.extend){f.collapse(l.node,l.offset);try{f.extend(h.node,h.offset)}catch(u){}}else{let u=document.createRange();a.anchor>a.head&&([l,h]=[h,l]),u.setEnd(h.node,h.offset),u.setStart(l.node,l.offset),f.removeAllRanges(),f.addRange(u)}r&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(l,h)),this.impreciseAnchor=l.precise?null:new ft(c.anchorNode,c.anchorOffset),this.impreciseHead=h.precise?null:new ft(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&!this.compositionBarrier.size&&zi(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=_n(t.root),{anchorNode:s,anchorOffset:r}=t.observer.selectionRange;if(!i||!e.empty||!e.assoc||!i.modify)return;let o=ot.find(this,e.head);if(!o)return;let a=o.posAtStart;if(e.head==a||e.head==a+o.length)return;let l=this.coordsAt(e.head,-1),h=this.coordsAt(e.head,1);if(!l||!h||l.bottom>h.top)return;let c=this.domAtPos(e.head+e.assoc);i.collapse(c.node,c.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let f=t.observer.selectionRange;t.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=e.from&&i.collapse(s,r)}moveToLine(t){let e=this.dom,i;if(t.node!=e)return t;for(let s=t.offset;!i&&s=0;s--){let r=j.get(e.childNodes[s]);r instanceof ot&&(i=r.domAtPos(r.length))}return i?new ft(i.node,i.offset,!0):t}nearest(t){for(let e=t;e;){let i=j.get(e);if(i&&i.rootView==this)return i;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e=0;o--){let a=this.children[o],l=r-a.breakAfter,h=l-a.length;if(lt||a.covers(1))&&(!i||a instanceof ot&&!(i instanceof ot&&e>=0))&&(i=a,s=h),r=h}return i?i.coordsAt(t-s,e):null}coordsForChar(t){let{i:e,off:i}=this.childPos(t,1),s=this.children[e];if(!(s instanceof ot))return null;for(;s.children.length;){let{i:a,off:l}=s.childPos(i,1);for(;;a++){if(a==s.children.length)return null;if((s=s.children[a]).length)break}i=l}if(!(s instanceof Bt))return null;let r=ht(s.text,i);if(r==i)return null;let o=je(s.dom,i,r).getClientRects();for(let a=0;aMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,a=-1,l=this.view.textDirection==tt.LTR;for(let h=0,c=0;cs)break;if(h>=i){let d=f.dom.getBoundingClientRect();if(e.push(d.height),o){let p=f.dom.lastChild,m=p?_i(p):[];if(m.length){let g=m[m.length-1],b=l?g.right-d.left:d.right-g.left;b>a&&(a=b,this.minWidth=r,this.minWidthFrom=h,this.minWidthTo=u)}}}h=u+f.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return getComputedStyle(this.children[e].dom).direction=="rtl"?tt.RTL:tt.LTR}measureTextSize(){for(let r of this.children)if(r instanceof ot){let o=r.measureTextSize();if(o)return o}let t=document.createElement("div"),e,i,s;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(t);let r=_i(t.firstChild)[0];e=t.getBoundingClientRect().height,i=r?r.width/27:7,s=r?r.height:e,t.remove()}),{lineHeight:e,charWidth:i,textHeight:s}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new pr(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,s=0;;s++){let r=s==e.viewports.length?null:e.viewports[s],o=r?r.from-1:this.length;if(o>i){let a=(e.lineBlockAt(o).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(V.replace({widget:new Ar(a),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!r)break;i=r.to+1}return V.set(t)}updateDeco(){let t=1,e=this.view.state.facet(Gi).map(r=>(this.dynamicDecorationMap[t++]=typeof r=="function")?r(this.view):r),i=!1,s=this.view.state.facet(Al).map((r,o)=>{let a=typeof r=="function";return a&&(i=!0),a?r(this.view):r});for(s.length&&(this.dynamicDecorationMap[t++]=i,e.push(_.join(s))),this.decorations=[this.compositionBarrier,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];t{a.point?i=!1:a.endSide<0&&re.anchor?-1:1),s;if(!i)return;!e.empty&&(s=this.coordsAt(e.anchor,e.anchor>e.head?-1:1))&&(i={left:Math.min(i.left,s.left),top:Math.min(i.top,s.top),right:Math.max(i.right,s.right),bottom:Math.max(i.bottom,s.bottom)});let r=Wl(this.view),o={left:i.left-r.left,top:i.top-r.top,right:i.right+r.right,bottom:i.bottom+r.bottom},{offsetWidth:a,offsetHeight:l}=this.view.scrollDOM;lp(this.view.scrollDOM,o,e.head{it.from&&(e=!0)}),e}function Wp(n,t,e=1){let i=n.charCategorizer(t),s=n.doc.lineAt(t),r=t-s.from;if(s.length==0)return S.cursor(t);r==0?e=1:r==s.length&&(e=-1);let o=r,a=r;e<0?o=ht(s.text,r,!1):a=ht(s.text,r);let l=i(s.text.slice(o,a));for(;o>0;){let h=ht(s.text,o,!1);if(i(s.text.slice(h,o))!=l)break;o=h}for(;an?t.left-n:Math.max(0,n-t.right)}function Mp(n,t){return t.top>n?t.top-n:Math.max(0,n-t.bottom)}function Er(n,t){return n.topt.top+1}function Ml(n,t){return tn.bottom?{top:n.top,left:n.left,right:n.right,bottom:t}:n}function Xr(n,t,e){let i,s,r,o,a=!1,l,h,c,f;for(let p=n.firstChild;p;p=p.nextSibling){let m=_i(p);for(let g=0;gx||o==x&&r>w){i=p,s=b,r=w,o=x;let P=x?e0?g0)}w==0?e>b.bottom&&(!c||c.bottomb.top)&&(h=p,f=b):c&&Er(c,b)?c=Yl(c,b.bottom):f&&Er(f,b)&&(f=Ml(f,b.top))}}if(c&&c.bottom>=e?(i=l,s=c):f&&f.top<=e&&(i=h,s=f),!i)return{node:n,offset:0};let u=Math.max(s.left,Math.min(s.right,t));if(i.nodeType==3)return Il(i,u,e);if(a&&i.contentEditable!="false")return Xr(i,u,e);let d=Array.prototype.indexOf.call(n.childNodes,i)+(t>=(s.left+s.right)/2?1:0);return{node:n,offset:d}}function Il(n,t,e){let i=n.nodeValue.length,s=-1,r=1e9,o=0;for(let a=0;ae?c.top-e:e-c.bottom)-1;if(c.left-1<=t&&c.right+1>=t&&f=(c.left+c.right)/2,d=u;if(($.chrome||$.gecko)&&je(n,a).getBoundingClientRect().left==c.right&&(d=!u),f<=0)return{node:n,offset:a+(d?1:0)};s=a+(d?1:0),r=f}}}return{node:n,offset:s>-1?s:o>0?n.nodeValue.length:0}}function Dl(n,t,e,i=-1){var s,r;let o=n.contentDOM.getBoundingClientRect(),a=o.top+n.viewState.paddingTop,l,{docHeight:h}=n.viewState,{x:c,y:f}=t,u=f-a;if(u<0)return 0;if(u>h)return n.state.doc.length;for(let P=n.viewState.heightOracle.textHeight/2,k=!1;l=n.elementAtHeight(u),l.type!=At.Text;)for(;u=i>0?l.bottom+P:l.top-P,!(u>=0&&u<=h);){if(k)return e?null:0;k=!0,i=-i}f=a+u;let d=l.from;if(dn.viewport.to)return n.viewport.to==n.state.doc.length?n.state.doc.length:e?null:Vl(n,o,l,c,f);let p=n.dom.ownerDocument,m=n.root.elementFromPoint?n.root:p,g=m.elementFromPoint(c,f);g&&!n.contentDOM.contains(g)&&(g=null),g||(c=Math.max(o.left+1,Math.min(o.right-1,c)),g=m.elementFromPoint(c,f),g&&!n.contentDOM.contains(g)&&(g=null));let b,w=-1;if(g&&((s=n.docView.nearest(g))===null||s===void 0?void 0:s.isEditable)!=!1){if(p.caretPositionFromPoint){let P=p.caretPositionFromPoint(c,f);P&&({offsetNode:b,offset:w}=P)}else if(p.caretRangeFromPoint){let P=p.caretRangeFromPoint(c,f);P&&({startContainer:b,startOffset:w}=P,(!n.contentDOM.contains(b)||$.safari&&Yp(b,w,c)||$.chrome&&Ip(b,w,c))&&(b=void 0))}}if(!b||!n.docView.dom.contains(b)){let P=ot.find(n.docView,d);if(!P)return u>l.top+l.height/2?l.to:l.from;({node:b,offset:w}=Xr(P.dom,c,f))}let x=n.docView.nearest(b);if(!x)return null;if(x.isWidget&&((r=x.dom)===null||r===void 0?void 0:r.nodeType)==1){let P=x.dom.getBoundingClientRect();return t.yn.defaultLineHeight*1.5){let a=n.viewState.heightOracle.textHeight;r+=Math.floor((s-e.top-(n.defaultLineHeight-a)*.5)/a)*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(e.from,e.to);return e.from+Va(o,r,n.state.tabSize)}function Yp(n,t,e){let i;if(n.nodeType!=3||t!=(i=n.nodeValue.length))return!1;for(let s=n.nextSibling;s;s=s.nextSibling)if(s.nodeType!=1||s.nodeName!="BR")return!1;return je(n,i-1,i).getBoundingClientRect().left>e}function Ip(n,t,e){if(t!=0)return!1;for(let s=n;;){let r=s.parentNode;if(!r||r.nodeType!=1||r.firstChild!=s)return!1;if(r.classList.contains("cm-line"))break;s=r}let i=n.nodeType==1?n.getBoundingClientRect():je(n,0,Math.max(n.nodeValue.length,1)).getBoundingClientRect();return e-i.left>5}function Rr(n,t){let e=n.lineBlockAt(t);if(Array.isArray(e.type)){for(let i of e.type)if(i.to>t||i.to==t&&(i.to==e.to||i.type==At.Text))return i}return e}function Dp(n,t,e,i){let s=Rr(n,t.head),r=!i||s.type!=At.Text||!(n.lineWrapping||s.widgetLineBreaks)?null:n.coordsAtPos(t.assoc<0&&t.head>s.from?t.head-1:t.head);if(r){let o=n.dom.getBoundingClientRect(),a=n.textDirectionAt(s.from),l=n.posAtCoords({x:e==(a==tt.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(l!=null)return S.cursor(l,e?-1:1)}return S.cursor(e?s.to:s.from,e?-1:1)}function Bl(n,t,e,i){let s=n.state.doc.lineAt(t.head),r=n.bidiSpans(s),o=n.textDirectionAt(s.from);for(let a=t,l=null;;){let h=xp(s,r,o,a,e),c=wl;if(!h){if(s.number==(e?n.state.doc.lines:1))return a;c=` `,s=n.state.doc.line(s.number+(e?1:-1)),r=n.bidiSpans(s),h=n.visualLineSide(s,!e)}if(l){if(!l(c))return a}else{if(!i)return h;l=i(c)}a=h}}function Vp(n,t,e){let i=n.state.charCategorizer(t),s=i(e);return r=>{let o=i(r);return s==Vt.Space&&(s=o),s==o}}function Bp(n,t,e,i){let s=t.head,r=e?1:-1;if(s==(e?n.state.doc.length:0))return S.cursor(s,t.assoc);let o=t.goalColumn,a,l=n.contentDOM.getBoundingClientRect(),h=n.coordsAtPos(s,t.assoc||-1),c=n.documentTop;if(h)o==null&&(o=h.left-l.left),a=r<0?h.top:h.bottom;else{let d=n.viewState.lineBlockAt(s);o==null&&(o=Math.min(l.right-l.left,n.defaultCharacterWidth*(s-d.from))),a=(r<0?d.top:d.bottom)+c}let f=l.left+o,u=i??n.viewState.heightOracle.textHeight>>1;for(let d=0;;d+=10){let p=a+(u+d)*r,m=Dl(n,{x:f,y:p},!1,r);if(pl.bottom||(r<0?ms)){let g=n.docView.coordsForChar(m),b=!g||p{if(t>r&&ts(n)),e.from,t.head>e.from?-1:1);return i==e.from?e:S.cursor(i,inull),$.gecko&&nO(t.contentDOM.ownerDocument)}handleEvent(t){!Up(this.view,t)||this.ignoreDuringComposition(t)||t.type=="keydown"&&this.keydown(t)||this.runHandlers(t.type,t)}runHandlers(t,e){let i=this.handlers[t];if(i){for(let s of i.observers)s(this.view,e);for(let s of i.handlers){if(e.defaultPrevented)break;if(s(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=Lp(t),i=this.handlers,s=this.view.contentDOM;for(let r in e)if(r!="scroll"){let o=!e[r].handlers.length,a=i[r];a&&o!=!a.handlers.length&&(s.removeEventListener(r,this.handleEvent),a=null),a||s.addEventListener(r,this.handleEvent,{passive:o})}for(let r in i)r!="scroll"&&!e[r]&&s.removeEventListener(r,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),t.keyCode==9&&Date.now()i.keyCode==t.keyCode))&&!t.ctrlKey||Np.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(this.pendingIOSKey=e||t,setTimeout(()=>this.flushIOSKey(),250),!0):(t.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(t){let e=this.pendingIOSKey;return!e||e.key=="Enter"&&t&&t.from0?!0:$.safari&&!$.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function Nl(n,t){return(e,i)=>{try{return t.call(n,i,e)}catch(s){Lt(e.state,s)}}}function Lp(n){let t=Object.create(null);function e(i){return t[i]||(t[i]={observers:[],handlers:[]})}for(let i of n){let s=i.spec;if(s&&s.domEventHandlers)for(let r in s.domEventHandlers){let o=s.domEventHandlers[r];o&&e(r).handlers.push(Nl(i.value,o))}if(s&&s.domEventObservers)for(let r in s.domEventObservers){let o=s.domEventObservers[r];o&&e(r).observers.push(Nl(i.value,o))}}for(let i in Ht)e(i).handlers.push(Ht[i]);for(let i in Nt)e(i).observers.push(Nt[i]);return t}var _l=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Np="dthko",zl=[16,17,18,20,91,92,224,225],ts=6;function es(n){return Math.max(0,n)*.7+8}function _p(n,t){return Math.max(Math.abs(n.clientX-t.clientX),Math.abs(n.clientY-t.clientY))}var jl=class{constructor(t,e,i,s){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParent=hp(t.contentDOM),this.atoms=t.state.facet(Cr).map(o=>o(t));let r=t.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(q.allowMultipleSelections)&&zp(t,e),this.dragging=Gp(t,e)&&nh(e)==1?null:!1}start(t){this.dragging===!1&&this.select(t)}move(t){var e;if(t.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&_p(this.startEvent,t)<10)return;this.select(this.lastEvent=t);let i=0,s=0,r=((e=this.scrollParent)===null||e===void 0?void 0:e.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},o=Wl(this.view);t.clientX-o.left<=r.left+ts?i=-es(r.left-t.clientX):t.clientX+o.right>=r.right-ts&&(i=es(t.clientX-r.right)),t.clientY-o.top<=r.top+ts?s=-es(r.top-t.clientY):t.clientY+o.bottom>=r.bottom-ts&&(s=es(t.clientY-r.bottom)),this.setScrollSpeed(i,s)}up(t){this.dragging==null&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;ithis.select(this.lastEvent),20)}};function zp(n,t){let e=n.state.facet(yl);return e.length?e[0](t):$.mac?t.metaKey:t.ctrlKey}function jp(n,t){let e=n.state.facet(kl);return e.length?e[0](t):$.mac?!t.altKey:!t.ctrlKey}function Gp(n,t){let{main:e}=n.state.selection;if(e.empty)return!1;let i=_n(n.root);if(!i||i.rangeCount==0)return!0;let s=i.getRangeAt(0).getClientRects();for(let r=0;r=t.clientX&&o.top<=t.clientY&&o.bottom>=t.clientY)return!0}return!1}function Up(n,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let e=t.target,i;e!=n.contentDOM;e=e.parentNode)if(!e||e.nodeType==11||(i=j.get(e))&&i.ignoreEvent(t))return!1;return!0}var Ht=Object.create(null),Nt=Object.create(null),Gl=$.ie&&$.ie_version<15||$.ios&&$.webkit_version<604;function Hp(n){let t=n.dom.parentNode;if(!t)return;let e=t.appendChild(document.createElement("textarea"));e.style.cssText="position: fixed; left: -10000px; top: 10px",e.focus(),setTimeout(()=>{n.focus(),e.remove(),Ul(n,e.value)},50)}function Ul(n,t){let{state:e}=n,i,s=1,r=e.toText(t),o=r.lines==e.selection.ranges.length;if(qr!=null&&e.selection.ranges.every(l=>l.empty)&&qr==r.toString()){let l=-1;i=e.changeByRange(h=>{let c=e.doc.lineAt(h.from);if(c.from==l)return{range:h};l=c.from;let f=e.toText((o?r.line(s++).text:t)+e.lineBreak);return{changes:{from:c.from,insert:f},range:S.cursor(h.from+f.length)}})}else o?i=e.changeByRange(l=>{let h=r.line(s++);return{changes:{from:l.from,to:l.to,insert:h.text},range:S.cursor(l.from+h.length)}}):i=e.replaceSelection(r);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}Nt.scroll=n=>{n.inputState.lastScrollTop=n.scrollDOM.scrollTop,n.inputState.lastScrollLeft=n.scrollDOM.scrollLeft};Ht.keydown=(n,t)=>(n.inputState.setSelectionOrigin("select"),t.keyCode==27&&(n.inputState.lastEscPress=Date.now()),!1);Nt.touchstart=(n,t)=>{n.inputState.lastTouchTime=Date.now(),n.inputState.setSelectionOrigin("select.pointer")};Nt.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};Ht.mousedown=(n,t)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let e=null;for(let i of n.state.facet(vl))if(e=i(n,t),e)break;if(!e&&t.button==0&&(e=Jp(n,t)),e){let i=!n.hasFocus;n.inputState.startMouseSelection(new jl(n,t,e,i)),i&&n.observer.ignore(()=>Fa(n.contentDOM));let s=n.inputState.mouseSelection;if(s)return s.start(t),s.dragging===!1}return!1};function Hl(n,t,e,i){if(i==1)return S.cursor(t,e);if(i==2)return Wp(n.state,t,e);{let s=ot.find(n.docView,t),r=n.state.doc.lineAt(s?s.posAtEnd:t),o=s?s.posAtStart:r.from,a=s?s.posAtEnd:r.to;return an>=t.top&&n<=t.bottom,Kl=(n,t,e)=>Fl(t,e)&&n>=e.left&&n<=e.right;function Fp(n,t,e,i){let s=ot.find(n.docView,t);if(!s)return 1;let r=t-s.posAtStart;if(r==0)return 1;if(r==s.length)return-1;let o=s.coordsAt(r,-1);if(o&&Kl(e,i,o))return-1;let a=s.coordsAt(r,1);return a&&Kl(e,i,a)?1:o&&Fl(i,o)?-1:1}function Jl(n,t){let e=n.posAtCoords({x:t.clientX,y:t.clientY},!1);return{pos:e,bias:Fp(n,e,t.clientX,t.clientY)}}var Kp=$.ie&&$.ie_version<=11,th=null,eh=0,ih=0;function nh(n){if(!Kp)return n.detail;let t=th,e=ih;return th=n,ih=Date.now(),eh=!t||e>Date.now()-400&&Math.abs(t.clientX-n.clientX)<2&&Math.abs(t.clientY-n.clientY)<2?(eh+1)%3:1}function Jp(n,t){let e=Jl(n,t),i=nh(t),s=n.state.selection;return{update(r){r.docChanged&&(e.pos=r.changes.mapPos(e.pos),s=s.map(r.changes))},get(r,o,a){let l=Jl(n,r),h,c=Hl(n,l.pos,l.bias,i);if(e.pos!=l.pos&&!o){let f=Hl(n,e.pos,e.bias,i),u=Math.min(f.from,c.from),d=Math.max(f.to,c.to);c=u1&&(h=tO(s,l.pos))?h:a?s.addRange(c):S.create([c])}}}function tO(n,t){for(let e=0;e=t)return S.create(n.ranges.slice(0,e).concat(n.ranges.slice(e+1)),n.mainIndex==e?0:n.mainIndex-(n.mainIndex>e?1:0))}return null}Ht.dragstart=(n,t)=>{let{selection:{main:e}}=n.state;if(t.target.draggable){let s=n.docView.nearest(t.target);if(s&&s.isWidget){let r=s.posAtStart,o=r+s.length;(r>=e.to||o<=e.from)&&(e=S.range(r,o))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=e,t.dataTransfer&&(t.dataTransfer.setData("Text",n.state.sliceDoc(e.from,e.to)),t.dataTransfer.effectAllowed="copyMove"),!1};Ht.dragend=n=>(n.inputState.draggedContent=null,!1);function sh(n,t,e,i){if(!e)return;let s=n.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:r}=n.inputState,o=i&&r&&jp(n,t)?{from:r.from,to:r.to}:null,a={from:s,insert:e},l=n.state.changes(o?[o,a]:a);n.focus(),n.dispatch({changes:l,selection:{anchor:l.mapPos(s,-1),head:l.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}Ht.drop=(n,t)=>{if(!t.dataTransfer)return!1;if(n.state.readOnly)return!0;let e=t.dataTransfer.files;if(e&&e.length){let i=Array(e.length),s=0,r=()=>{++s==e.length&&sh(n,t,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(i[o]=a.result),r()},a.readAsText(e[o])}return!0}else{let i=t.dataTransfer.getData("Text");if(i)return sh(n,t,i,!0),!0}return!1};Ht.paste=(n,t)=>{if(n.state.readOnly)return!0;n.observer.flush();let e=Gl?null:t.clipboardData;return e?(Ul(n,e.getData("text/plain")||e.getData("text/uri-list")),!0):(Hp(n),!1)};function eO(n,t){let e=n.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=t,i.focus(),i.selectionEnd=t.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function iO(n){let t=[],e=[],i=!1;for(let s of n.selection.ranges)s.empty||(t.push(n.sliceDoc(s.from,s.to)),e.push(s));if(!t.length){let s=-1;for(let{from:r}of n.selection.ranges){let o=n.doc.lineAt(r);o.number>s&&(t.push(o.text),e.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),s=o.number}i=!0}return{text:t.join(n.lineBreak),ranges:e,linewise:i}}var qr=null;Ht.copy=Ht.cut=(n,t)=>{let{text:e,ranges:i,linewise:s}=iO(n.state);if(!e&&!s)return!1;qr=s?e:null,t.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let r=Gl?null:t.clipboardData;return r?(r.clearData(),r.setData("text/plain",e),!0):(eO(n,e),!1)};var rh=Ct.define();function oh(n,t){let e=[];for(let i of n.facet(Pl)){let s=i(n,t);s&&e.push(s)}return e?n.update({effects:e,annotations:rh.of(!0)}):null}function ah(n){setTimeout(()=>{let t=n.hasFocus;if(t!=n.inputState.notifiedFocused){let e=oh(n.state,t);e?n.dispatch(e):n.update([])}},10)}Nt.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),ah(n)};Nt.blur=n=>{n.observer.clearSelectionRange(),ah(n)};Nt.compositionstart=Nt.compositionupdate=n=>{n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0,n.docView.maybeCreateCompositionBarrier()&&(n.update([]),n.docView.clearCompositionBarrier()))};Nt.compositionend=n=>{n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,$.chrome&&$.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50)};Nt.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};Ht.beforeinput=(n,t)=>{var e;let i;if($.chrome&&$.android&&(i=_l.find(s=>s.inputType==t.inputType))&&(n.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let s=((e=window.visualViewport)===null||e===void 0?void 0:e.height)||0;setTimeout(()=>{var r;(((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0)>s+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return $.ios&&t.inputType=="deleteContentForward"&&n.observer.flushSoon(),$.safari&&t.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>Nt.compositionend(n,t),20),!1};var lh=new Set;function nO(n){lh.has(n)||(lh.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}var hh=["pre-wrap","normal","pre-line","break-spaces"],ch=class{constructor(t){this.lineWrapping=t,this.doc=W.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return hh.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i-1,l=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=a;if(this.lineWrapping=a,this.lineHeight=e,this.charWidth=i,this.textHeight=s,this.lineLength=r,l){this.heightSamples={};for(let h=0;h0}set outdated(t){this.flags=(t?2:0)|this.flags&~2}setHeight(t,e){this.height!=e&&(Math.abs(this.height-e)>is&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return pt.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,s){let r=this,o=i.doc;for(let a=s.length-1;a>=0;a--){let{fromA:l,toA:h,fromB:c,toB:f}=s[a],u=r.lineAt(l,K.ByPosNoHeight,i.setDoc(e),0,0),d=u.to>=h?u:r.lineAt(h,K.ByPosNoHeight,i,0,0);for(f+=d.to-h,h=d.to;a>0&&u.from<=s[a-1].toA;)l=s[a-1].fromA,c=s[a-1].fromB,a--,lr*2){let a=t[e-1];a.break?t.splice(--e,1,a.left,null,a.right):t.splice(--e,1,a.left,a.right),i+=1+a.break,s-=a.size}else if(r>s*2){let a=t[i];a.break?t.splice(i,1,a.left,null,a.right):t.splice(i,1,a.left,a.right),i+=2+a.break,r-=a.size}else break;else if(s=r&&o(this.blockAt(0,i,s,r))}updateHeight(t,e=0,i=!1,s){return s&&s.from<=e&&s.more&&this.setHeight(t,s.heights[s.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}},xt=class extends Mr{constructor(t,e){super(t,e,null);this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,s){return new Ft(s,this.length,i,this.height,this.breaks)}replace(t,e,i){let s=i[0];return i.length==1&&(s instanceof xt||s instanceof lt&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof lt?s=new xt(s.length,this.height):s.height=this.height,this.outdated||(s.outdated=!1),s):pt.of(i)}updateHeight(t,e=0,i=!1,s){return s&&s.from<=e&&s.more?this.setHeight(t,s.heights[s.index++]):(i||this.outdated)&&this.setHeight(t,Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},lt=class extends pt{constructor(t){super(t,0)}heightMetrics(t,e){let i=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,r=s-i+1,o,a=0;if(t.lineWrapping){let l=Math.min(this.height,t.lineHeight*r);o=l/r,this.length>r+1&&(a=(this.height-l)/(this.length-r-1))}else o=this.height/r;return{firstLine:i,lastLine:s,perLine:o,perChar:a}}blockAt(t,e,i,s){let{firstLine:r,lastLine:o,perLine:a,perChar:l}=this.heightMetrics(e,s);if(e.lineWrapping){let h=s+(t0){let r=i[i.length-1];r instanceof lt?i[i.length-1]=new lt(r.length+s):i.push(null,new lt(s-1))}if(t>0){let r=i[0];r instanceof lt?i[0]=new lt(t+r.length):i.unshift(new lt(t-1),null)}return pt.of(i)}decomposeLeft(t,e){e.push(new lt(t-1),null)}decomposeRight(t,e){e.push(null,new lt(this.length-t-1))}updateHeight(t,e=0,i=!1,s){let r=e+this.length;if(s&&s.from<=e+this.length&&s.more){let o=[],a=Math.max(e,s.from),l=-1;for(s.from>e&&o.push(new lt(s.from-e-1).updateHeight(t,e));a<=r&&s.more;){let c=t.doc.lineAt(a).length;o.length&&o.push(null);let f=s.heights[s.index++];l==-1?l=f:Math.abs(f-l)>=is&&(l=-2);let u=new xt(c,f);u.outdated=!1,o.push(u),a+=c+1}a<=r&&o.push(null,new lt(r-a).updateHeight(t,a));let h=pt.of(o);return(l<0||Math.abs(h.height-this.height)>=is||Math.abs(l-this.heightMetrics(t,e).perLine)>=is)&&(t.heightChanged=!0),h}else(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},uh=class extends pt{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0));this.left=t,this.right=i,this.size=t.size+i.size}get break(){return this.flags&1}blockAt(t,e,i,s){let r=i+this.left.height;return ta))return h;let c=e==K.ByPosNoHeight?K.ByPosNoHeight:K.ByPos;return l?h.join(this.right.lineAt(a,c,i,o,a)):this.left.lineAt(a,c,i,s,r).join(h)}forEachLine(t,e,i,s,r,o){let a=s+this.left.height,l=r+this.left.length+this.break;if(this.break)t=l&&this.right.forEachLine(t,e,i,a,l,o);else{let h=this.lineAt(l,K.ByPos,i,s,r);t=t&&h.from<=e&&o(h),e>h.to&&this.right.forEachLine(h.to+1,e,i,a,l,o)}}replace(t,e,i){let s=this.left.length+this.break;if(ethis.left.length)return this.balanced(this.left,this.right.replace(t-s,e-s,i));let r=[];t>0&&this.decomposeLeft(t,r);let o=r.length;for(let a of i)r.push(a);if(t>0&&dh(r,o-1),e=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,s=i+this.break;if(t>=s)return this.right.decomposeRight(t-s,e);t2*e.size||e.size>2*t.size?pt.of(this.break?[t,null,e]:[t,e]):(this.left=t,this.right=e,this.height=t.height+e.height,this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,s){let{left:r,right:o}=this,a=e+r.length+this.break,l=null;return s&&s.from<=e+r.length&&s.more?l=r=r.updateHeight(t,e,i,s):r.updateHeight(t,e,i),s&&s.from<=a+o.length&&s.more?l=o=o.updateHeight(t,a,i,s):o.updateHeight(t,a,i),l?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function dh(n,t){let e,i;n[t]==null&&(e=n[t-1])instanceof lt&&(i=n[t+1])instanceof lt&&n.splice(t-1,3,new lt(e.length+1+i.length))}var sO=5,ns=class{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let i=Math.min(e,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof xt?s.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new xt(i-this.pos,-1)),this.writtenTo=i,e>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t=sO)&&this.addLineDeco(s,r,o)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTot&&this.nodes.push(new xt(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new lt(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof xt)return t;let e=new xt(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let s=this.ensureLine();s.length+=i,s.collapsed+=i,s.widgetHeight=Math.max(s.widgetHeight,t),s.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(e instanceof xt)&&!this.isCovered?this.nodes.push(new xt(0,-1)):(this.writtenToc.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let u=c.getBoundingClientRect();r=Math.max(r,u.left),o=Math.min(o,u.right),a=Math.max(a,u.top),l=h==n.parentNode?u.bottom:Math.min(l,u.bottom)}h=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:r-e.left,right:Math.max(r,o)-e.left,top:a-(e.top+t),bottom:Math.max(a,l)-(e.top+t)}}function aO(n,t){let e=n.getBoundingClientRect();return{left:0,right:e.right-e.left,top:t,bottom:e.bottom-(e.top+t)}}var ss=class{constructor(t,e,i){this.from=t,this.to=e,this.size=i}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;itypeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new ch(e),this.stateDeco=t.facet(Gi).filter(i=>typeof i!="function"),this.heightMap=pt.empty().applyChanges(this.stateDeco,W.empty,this.heightOracle.setDoc(t.doc),[new Et(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=V.set(this.lineGaps.map(i=>i.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let s=i?e.head:e.anchor;if(!t.some(({from:r,to:o})=>s>=r&&s<=o)){let{from:r,to:o}=this.lineBlockAt(s);t.push(new Fi(r,o))}}this.viewports=t.sort((i,s)=>i.from-s.from),this.scaler=this.heightMap.height<=7e6?mh:new gh(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,t=>{this.viewportLines.push(this.scaler.scale==1?t:Ki(t,this.scaler))})}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Gi).filter(c=>typeof c!="function");let s=t.changedRanges,r=Et.extendWithRanges(s,rO(i,this.stateDeco,t?t.changes:st.empty(this.state.doc.length))),o=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),r),this.heightMap.height!=o&&(t.flags|=2),a?(this.scrollAnchorPos=t.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let l=r.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.headl.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,e));let h=!t.changes.empty||t.flags&2||l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,this.updateForViewport(),h&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>2e3<<1)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(Tl)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),s=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?tt.RTL:tt.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),a=e.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let h=0,c=0;if(a.width&&a.height){let{scaleX:P,scaleY:k}=Ua(e,a);(P>.005&&Math.abs(this.scaleX-P)>.005||k>.005&&Math.abs(this.scaleY-k)>.005)&&(this.scaleX=P,this.scaleY=k,h|=8,o=l=!0)}let f=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=u)&&(this.paddingTop=f,this.paddingBottom=u,h|=8|2),this.editorWidth!=t.scrollDOM.clientWidth&&(s.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,h|=8);let d=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=tl(t.scrollDOM);let p=(this.printing?aO:oO)(e,this.paddingTop),m=p.top-this.pixelViewport.top,g=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let b=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(b!=this.inView&&(this.inView=b,b&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let w=a.width;if((this.contentDOMWidth!=w||this.editorHeight!=t.scrollDOM.clientHeight)&&(this.contentDOMWidth=a.width,this.editorHeight=t.scrollDOM.clientHeight,h|=8),l){let P=t.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(P)&&(o=!0),o||s.lineWrapping&&Math.abs(w-this.contentDOMWidth)>s.charWidth){let{lineHeight:k,charWidth:T,textHeight:Q}=t.docView.measureTextSize();o=k>0&&s.refresh(r,k,T,Q,w/T,P),o&&(t.docView.minWidth=0,h|=8)}m>0&&g>0?c=Math.max(m,g):m<0&&g<0&&(c=Math.min(m,g)),s.heightChanged=!1;for(let k of this.viewports){let T=k.from==this.viewport.from?P:t.docView.measureVisibleLineHeights(k);this.heightMap=(o?pt.empty().applyChanges(this.stateDeco,W.empty,this.heightOracle,[new Et(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new fh(k.from,T))}s.heightChanged&&(h|=2)}let x=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return x&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(h&2||x)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>2e3<<1)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),s=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:a}=this,l=new Fi(s.lineAt(o-i*1e3,K.ByHeight,r,0,0).from,s.lineAt(a+(1-i)*1e3,K.ByHeight,r,0,0).to);if(e){let{head:h}=e.range;if(hl.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=s.lineAt(h,K.ByPos,r,0,0),u;e.y=="center"?u=(f.top+f.bottom)/2-c/2:e.y=="start"||e.y=="nearest"&&h=a+Math.max(10,Math.min(i,250)))&&s>o-2*1e3&&r>1,o=s<<1;if(this.defaultTextDirection!=tt.LTR&&!i)return[];let a=[],l=(h,c,f,u)=>{if(c-hh&&gg.from>=f.from&&g.to<=f.to&&Math.abs(g.from-h)g.fromb));if(!m){if(cg.from<=c&&g.to>=c)){let g=e.moveToLineBoundary(S.cursor(c),!1,!0).head;g>h&&(c=g)}m=new ss(h,c,this.gapSize(f,h,c,u))}a.push(m)};for(let h of this.viewportLines){if(h.lengthh.from&&l(h.from,u,h,c),de.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];_.spans(t,this.viewport.from,this.viewport.to,{span(s,r){e.push({from:s,to:r})},point(){}},20);let i=e.length!=this.visibleRanges.length||this.visibleRanges.some((s,r)=>s.from!=e[r].from||s.to!=e[r].to);return this.visibleRanges=e,i?4:0}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(e=>e.from<=t&&e.to>=t)||Ki(this.heightMap.lineAt(t,K.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return Ki(this.heightMap.lineAt(this.scaler.fromDOM(t),K.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return Ki(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},Fi=class{constructor(t,e){this.from=t,this.to=e}};function lO(n,t,e){let i=[],s=n,r=0;return _.spans(e,n,t,{span(){},point(o,a){o>s&&(i.push({from:s,to:o}),r+=o-s),s=a}},20),s=1)return t[t.length-1].to;let i=Math.floor(n*e);for(let s=0;;s++){let{from:r,to:o}=t[s],a=o-r;if(i<=a)return r+i;i-=a}}function os(n,t){let e=0;for(let{from:i,to:s}of n.ranges){if(t<=s){e+=t-i;break}e+=s-i}return e/n.total}function hO(n,t){for(let e of n)if(t(e))return e}var mh={toDOM(n){return n},fromDOM(n){return n},scale:1},gh=class{constructor(t,e,i){let s=0,r=0,o=0;this.viewports=i.map(({from:a,to:l})=>{let h=e.lineAt(a,K.ByPos,t,0,0).top,c=e.lineAt(l,K.ByPos,t,0,0).bottom;return s+=c-h,{from:a,to:l,top:h,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(e.height-s);for(let a of this.viewports)a.domTop=o+(a.top-r)*this.scale,o=a.domBottom=a.domTop+(a.bottom-a.top),r=a.bottom}toDOM(t){for(let e=0,i=0,s=0;;e++){let r=eKi(s,t)):n._content)}var as=A.define({combine:n=>n.join(" ")}),Ir=A.define({combine:n=>n.indexOf(!0)>-1}),Dr=Ut.newName(),bh=Ut.newName(),Sh=Ut.newName(),wh={"&light":"."+bh,"&dark":"."+Sh};function Vr(n,t,e){return new Ut(t,{finish(i){return/&/.test(i)?i.replace(/&\w*/,s=>{if(s=="&")return n;if(!e||!e[s])throw new RangeError(`Unsupported selector: ${s}`);return e[s]}):n+" "+i}})}var cO=Vr("."+Dr,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},wh),Ji="\uFFFF",yh=class{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(q.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=Ji}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let s=t;;){this.findPointBefore(i,s);let r=this.text.length;this.readNode(s);let o=s.nextSibling;if(o==e)break;let a=j.get(s),l=j.get(o);(a&&l?a.breakAfter:(a?a.breakAfter:jn(s))||jn(o)&&(s.nodeName!="BR"||s.cmIgnore)&&this.text.length>r)&&this.lineBreak(),s=o}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,o=1,a;if(this.lineSeparator?(r=e.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(a=s.exec(e))&&(r=a.index,o=a[0].length),this.append(e.slice(i,r<0?e.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let l of this.points)l.node==t&&l.pos>this.text.length&&(l.pos-=o-1);i=r+o}}readNode(t){if(t.cmIgnore)return;let e=j.get(t),i=e&&e.overrideDOMText;if(i!=null){this.findPointInside(t,i.length);for(let s=i.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else t.nodeType==3?this.readTextNode(t):t.nodeName=="BR"?t.nextSibling&&this.lineBreak():t.nodeType==1&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(t.nodeType==3?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(fO(t,i.node,i.offset)?e:0))}};function fO(n,t,e){for(;;){if(!t||e-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let a=r||o?[]:pO(t),l=new yh(a,t.state);l.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=l.text,this.newSel=OO(a,this.bounds.from)}else{let a=t.observer.selectionRange,l=r&&r.node==a.focusNode&&r.offset==a.focusOffset||!fr(t.contentDOM,a.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(a.focusNode,a.focusOffset),h=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!fr(t.contentDOM,a.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(a.anchorNode,a.anchorOffset),c=t.viewport;if(($.ios||$.chrome)&&t.state.selection.main.empty&&l!=h&&(c.from>0||c.toDate.now()-100?n.inputState.lastKeyCode:-1;if(t.bounds){let{from:o,to:a}=t.bounds,l=s.from,h=null;(r===8||$.android&&t.text.length=s.from&&e.to<=s.to&&(e.from!=s.from||e.to!=s.to)&&s.to-s.from-(e.to-e.from)<=4?e={from:s.from,to:s.to,insert:n.state.doc.slice(s.from,e.from).append(e.insert).append(n.state.doc.slice(e.to,s.to))}:($.mac||$.android)&&e&&e.from==e.to&&e.from==s.head-1&&/^\. ?$/.test(e.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&e.insert.length==2&&(i=S.single(i.main.anchor-1,i.main.head-1)),e={from:s.from,to:s.to,insert:W.of([" "])}):$.chrome&&e&&e.from==e.to&&e.from==s.head&&e.insert.toString()==` `&&n.lineWrapping&&(i&&(i=S.single(i.main.anchor-1,i.main.head-1)),e={from:s.from,to:s.to,insert:W.of([" "])}),e){if($.ios&&n.inputState.flushIOSKey(e)||$.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&n.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Si(n.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&Si(n.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&Si(n.contentDOM,"Delete",46)))return!0;let o=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let a,l=()=>a||(a=uO(n,e,i));return n.state.facet(Ql).some(h=>h(n,e.from,e.to,o,l))||n.dispatch(l()),!0}else if(i&&!i.main.eq(s)){let o=!1,a="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(o=!0),a=n.inputState.lastSelectionOrigin),n.dispatch({selection:i,scrollIntoView:o,userEvent:a}),!0}else return!1}function uO(n,t,e){let i,s=n.state,r=s.selection.main;if(t.from>=r.from&&t.to<=r.to&&t.to-t.from>=(r.to-r.from)/3&&(!e||e.main.empty&&e.main.from==t.from+t.insert.length)&&n.inputState.composing<0){let a=r.fromt.to?s.sliceDoc(t.to,r.to):"";i=s.replaceSelection(n.state.toText(a+t.insert.sliceString(0,void 0,n.state.lineBreak)+l))}else{let a=s.changes(t),l=e&&e.main.to<=a.newLength?e.main:void 0;if(s.selection.ranges.length>1&&n.inputState.composing>=0&&t.to<=r.to&&t.to>=r.to-10){let h=n.state.sliceDoc(t.from,t.to),c,f=e&&ql(n,e.main.head);if(f){let p=t.insert.length-(t.to-t.from);c={from:f.from,to:f.to-p}}else c=n.state.doc.lineAt(r.head);let u=r.to-t.to,d=r.to-r.from;i=s.changeByRange(p=>{if(p.from==r.from&&p.to==r.to)return{changes:a,range:l||p.map(a)};let m=p.to-u,g=m-h.length;if(p.to-p.from!=d||n.state.sliceDoc(g,m)!=h||p.to>=c.from&&p.from<=c.to)return{range:p};let b=s.changes({from:g,to:m,insert:t.insert}),w=p.to-r.to;return{changes:b,range:l?S.range(Math.max(0,l.anchor+w),Math.max(0,l.head+w)):p.map(b)}})}else i={changes:a,selection:l&&s.selection.replaceRange(l)}}let o="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,o+=".compose",n.inputState.compositionFirstChange&&(o+=".start",n.inputState.compositionFirstChange=!1)),s.update(i,{userEvent:o,scrollIntoView:!0})}function dO(n,t,e,i){let s=Math.min(n.length,t.length),r=0;for(;r0&&a>0&&n.charCodeAt(o-1)==t.charCodeAt(a-1);)o--,a--;if(i=="end"){let l=Math.max(0,r-Math.min(o,a));e-=o+l-r}return o=o?r-e:0,a=r+(a-o),o=r):a=a?r-e:0,o=r+(o-a),a=r),{from:r,toA:o,toB:a}}function pO(n){let t=[];if(n.root.activeElement!=n.contentDOM)return t;let{anchorNode:e,anchorOffset:i,focusNode:s,focusOffset:r}=n.observer.selectionRange;return e&&(t.push(new Br(e,i)),(s!=e||r!=i)&&t.push(new Br(s,r))),t}function OO(n,t){if(n.length==0)return null;let e=n[0].pos,i=n.length==2?n[1].pos:e;return e>-1&&i>-1?S.single(e+t,i+t):null}var mO={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Lr=$.ie&&$.ie_version<=11,xh=class{constructor(t){this.view=t,this.active=!1,this.selectionRange=new Ha,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(e=>{for(let i of e)this.queue.push(i);($.ie&&$.ie_version<=11||$.ios&&t.composing)&&e.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),Lr&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var e;((e=this.view.docView)===null||e===void 0?void 0:e.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(t){t.type=="change"&&!t.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((e,i)=>e!=t[i]))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,s=this.selectionRange;if(i.state.facet(Fn)?i.root.activeElement!=this.dom:!zn(i.dom,s))return;let r=s.anchorNode&&i.docView.nearest(s.anchorNode);if(r&&r.ignoreEvent(t)){e||(this.selectionChanged=!1);return}($.ie&&$.ie_version<=11||$.android&&$.chrome)&&!i.state.selection.main.empty&&s.focusNode&&zi(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=$.safari&&t.root.nodeType==11&&op(this.dom.ownerDocument)==this.dom&&gO(this.view)||_n(t.root);if(!e||this.selectionRange.eq(e))return!1;let i=zn(this.dom,e);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&Si(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||t=="Enter")&&(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,s=!1;for(let r of t){let o=this.readMutation(r);!o||(o.typeOver&&(s=!0),e==-1?{from:e,to:i}=o:(e=Math.min(o.from,e),i=Math.max(o.to,i)))}return{from:e,to:i,typeOver:s}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),s=this.selectionChanged&&zn(this.dom,this.selectionRange);if(t<0&&!s)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new kh(this.view,t,e,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,s=vh(this.view,e);return this.view.state==i&&this.view.update([]),s}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty(t.type=="attributes"),t.type=="attributes"&&(e.flags|=4),t.type=="childList"){let i=Qh(e,t.previousSibling||t.target.previousSibling,-1),s=Qh(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:s?e.posBefore(s):e.posAtEnd,typeOver:!1}}else return t.type=="characterData"?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener("change",this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener("change",this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var t,e,i;this.stop(),(t=this.intersection)===null||t===void 0||t.disconnect(),(e=this.gapIntersection)===null||e===void 0||e.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}};function Qh(n,t,e){for(;t;){let i=j.get(t);if(i&&i.parent==n)return i;let s=t.parentNode;t=s!=n.dom?s:e>0?t.nextSibling:t.previousSibling}return null}function gO(n){let t=null;function e(l){l.preventDefault(),l.stopImmediatePropagation(),t=l.getTargetRanges()[0]}if(n.contentDOM.addEventListener("beforeinput",e,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",e,!0),!t)return null;let i=t.startContainer,s=t.startOffset,r=t.endContainer,o=t.endOffset,a=n.docView.domAtPos(n.state.selection.main.anchor);return zi(a.node,a.offset,r,o)&&([i,s,r,o]=[r,o,i,s]),{anchorNode:i,anchorOffset:s,focusNode:r,focusOffset:o}}var Z=class{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(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),t.parent&&t.parent.appendChild(this.dom);let{dispatch:e}=t;this.dispatchTransactions=t.dispatchTransactions||e&&(i=>i.forEach(s=>e(s,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=t.root||cp(t.parent)||document,this.viewState=new Yr(t.state||q.create(t)),t.scrollTo&&t.scrollTo.is(Hn)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ji).map(i=>new Kn(i));for(let i of this.plugins)i.update(this);this.observer=new xh(this),this.inputState=new Ll(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Zr(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...t){let e=t.length==1&&t[0]instanceof J?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e=!1,i=!1,s,r=this.state;for(let u of t){if(u.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=u.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,a=0,l=null;t.some(u=>u.annotation(rh))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=oh(r,o),l||(a=1));let h=this.observer.delayedAndroidKey,c=null;if(h?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(c=null)):this.observer.clear(),r.facet(q.phrases)!=this.state.facet(q.phrases))return this.setState(r);s=Hi.create(this,r,t),s.flags|=a;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let u of t){if(f&&(f=f.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection;f=new He(d.empty?d:S.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of u.effects)d.is(Hn)&&(f=d.value.clip(this.state))}this.viewState.update(s,f),this.bidiCache=tn.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),e=this.docView.update(s),this.state.facet(Ui)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(e,t.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(as)!=s.state.facet(as)&&(this.viewState.mustMeasureContent=!0),(e||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),e&&this.docViewUpdate(),!s.empty)for(let u of this.state.facet($r))try{u(s)}catch(d){Lt(this.state,d,"update listener")}(l||c)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),c&&!vh(this,c)&&h.force&&Si(this.contentDOM,h.key,h.keyCode)})}setState(t){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=t;return}this.updateState=2;let e=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Yr(t),this.plugins=t.facet(ji).map(i=>new Kn(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new Zr(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(ji),i=t.state.facet(ji);if(e!=i){let s=[];for(let r of i){let o=e.indexOf(r);if(o<0)s.push(new Kn(r));else{let a=this.plugins[o];a.mustUpdate=t,s.push(a)}}for(let r of this.plugins)r.mustUpdate!=t&&r.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=t;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,s=i.scrollTop*this.scaleY,{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;Math.abs(s-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0)if(tl(i))r=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(s);r=d.from,o=d.top}this.updateState=1;let l=this.viewState.measure(this);if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];l&4||([this.measureRequests,h]=[h,this.measureRequests]);let c=h.map(d=>{try{return d.read(this)}catch(p){return Lt(this.state,p),Ph}}),f=Hi.create(this,this.state,[]),u=!1;f.flags|=l,e?e.flags|=l:e=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),u=this.docView.update(f),u&&this.docViewUpdate());for(let d=0;d1||p<-1){s=s+p,i.scrollTop=s/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let a of this.state.facet($r))a(e)}get themeClasses(){return Dr+" "+(this.state.facet(Ir)?Sh:bh)+" "+this.state.facet(as)}updateAttrs(){let t=$h(this,Zl,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(Fn)?"true":"false",class:"cm-content",style:`${$.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),$h(this,Tr,e);let i=this.observer.ignore(()=>{let s=yr(this.contentDOM,this.contentAttrs,e),r=yr(this.dom,this.editorAttrs,t);return s||r});return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let s of i.effects)if(s.is(Z.announce)){e&&(this.announceDOM.textContent=""),e=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ui);let t=this.state.facet(Z.cspNonce);Ut.mount(this.root,this.styleModules.concat(cO).reverse(),t?{nonce:t}: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(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(t.key!=null){for(let e=0;ei.spec==t)||null),e&&e.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(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return Wr(this,t,Bl(this,t,e,i))}moveByGroup(t,e){return Wr(this,t,Bl(this,t,e,i=>Vp(this,t.head,i)))}visualLineSide(t,e){let i=this.bidiSpans(t),s=this.textDirectionAt(t.from),r=i[e?i.length-1:0];return S.cursor(r.side(e,s)+t.from,r.forward(!e,s)?1:-1)}moveToLineBoundary(t,e,i=!0){return Dp(this,t,e,i)}moveVertically(t,e,i){return Wr(this,t,Bp(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),Dl(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let s=this.state.doc.lineAt(t),r=this.bidiSpans(s),o=r[ve.find(r,t-s.from,-1,e)];return ur(i,o.dir==tt.LTR==e>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet($l)||tthis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>bO)return Sl(t.length);let e=this.textDirectionAt(t.from),i;for(let r of this.bidiCache)if(r.from==t.from&&r.dir==e&&(r.fresh||bl(r.isolates,i=Xl(this,t))))return r.order;i||(i=Xl(this,t));let s=vp(t.text,e,i);return this.bidiCache.push(new tn(t.from,t.to,e,i,!0,s)),s}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||$.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Fa(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((t.nodeType==9?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let t of this.plugins)t.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(t,e={}){return Hn.of(new He(typeof t=="number"?S.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return Hn.of(new He(S.cursor(i.from),"start","start",i.top-t,e,!0))}static domEventHandlers(t){return vt.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return vt.define(()=>({}),{eventObservers:t})}static theme(t,e){let i=Ut.newName(),s=[as.of(i),Ui.of(Vr(`.${i}`,t))];return e&&e.dark&&s.push(Ir.of(!0)),s}static baseTheme(t){return oe.lowest(Ui.of(Vr("."+Dr,t,wh)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),s=i&&j.get(i)||j.get(t);return((e=s==null?void 0:s.rootView)===null||e===void 0?void 0:e.view)||null}};Z.styleModule=Ui;Z.inputHandler=Ql;Z.scrollHandler=Cl;Z.focusChangeEffect=Pl;Z.perLineTextDirection=$l;Z.exceptionSink=xl;Z.updateListener=$r;Z.editable=Fn;Z.mouseSelectionStyle=vl;Z.dragMovesSelection=kl;Z.clickAddsSelectionRange=yl;Z.decorations=Gi;Z.outerDecorations=Al;Z.atomicRanges=Cr;Z.bidiIsolatedRanges=El;Z.scrollMargins=Rl;Z.darkTheme=Ir;Z.cspNonce=A.define({combine:n=>n.length?n[0]:""});Z.contentAttributes=Tr;Z.editorAttributes=Zl;Z.lineWrapping=Z.contentAttributes.of({class:"cm-lineWrapping"});Z.announce=U.define();var bO=4096,Ph={},tn=class{constructor(t,e,i,s,r,o){this.from=t,this.to=e,this.dir=i,this.isolates=s,this.fresh=r,this.order=o}static update(t,e){if(e.empty&&!t.some(r=>r.fresh))return t;let i=[],s=t.length?t[t.length-1].dir:tt.LTR;for(let r=Math.max(0,t.length-10);r=0;s--){let r=i[s],o=typeof r=="function"?r(n):r;o&&Sr(o,e)}return e}var SO=$.mac?"mac":$.windows?"win":$.linux?"linux":"key";function wO(n,t){let e=n.split(/-(?!$)/),i=e[e.length-1];i=="Space"&&(i=" ");let s,r,o,a;for(let l=0;li.concat(s),[]))),e}var Re=null,vO=4e3;function xO(n,t=SO){let e=Object.create(null),i=Object.create(null),s=(o,a)=>{let l=i[o];if(l==null)i[o]=a;else if(l!=a)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},r=(o,a,l,h,c)=>{var f,u;let d=e[o]||(e[o]=Object.create(null)),p=a.split(/ (?!$)/).map(b=>wO(b,t));for(let b=1;b{let P=Re={view:x,prefix:w,scope:o};return setTimeout(()=>{Re==P&&(Re=null)},vO),!0}]})}let m=p.join(" ");s(m,!1);let g=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((u=(f=d._any)===null||f===void 0?void 0:f.run)===null||u===void 0?void 0:u.slice())||[]});l&&g.run.push(l),h&&(g.preventDefault=!0),c&&(g.stopPropagation=!0)};for(let o of n){let a=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of a){let c=e[h]||(e[h]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});for(let f in c)c[f].run.push(o.any)}let l=o[t]||o.key;if(!!l)for(let h of a)r(h,l,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(h,"Shift-"+l,o.shift,o.preventDefault,o.stopPropagation)}return e}function QO(n,t,e,i){let s=ja(t),r=Le(s,0),o=Ii(r)==s.length&&s!=" ",a="",l=!1,h=!1,c=!1;Re&&Re.view==e&&Re.scope==i&&(a=Re.prefix+" ",zl.indexOf(t.keyCode)<0&&(h=!0,Re=null));let f=new Set,u=g=>{if(g){for(let b of g.run)if(!f.has(b)&&(f.add(b),b(e,t)))return g.stopPropagation&&(c=!0),!0;g.preventDefault&&(g.stopPropagation&&(c=!0),h=!0)}return!1},d=n[i],p,m;return d&&(u(d[a+ls(s,t,!o)])?l=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!($.windows&&t.ctrlKey&&t.altKey)&&(p=be[t.keyCode])&&p!=s?(u(d[a+ls(p,t,!0)])||t.shiftKey&&(m=gi[t.keyCode])!=s&&m!=p&&u(d[a+ls(m,t,!1)]))&&(l=!0):o&&t.shiftKey&&u(d[a+ls(s,t,!0)])&&(l=!0),!l&&u(d._any)&&(l=!0)),h&&(l=!0),l&&c&&t.stopPropagation(),l}var vi=class{constructor(t,e,i,s,r){this.className=t,this.left=e,this.top=i,this.width=s,this.height=r}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,e){return e.className!=this.className?!1:(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",this.width!=null&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,e,i){if(i.empty){let s=t.coordsAtPos(i.head,i.assoc||1);if(!s)return[];let r=Ch(t);return[new vi(e,s.left-r.left,s.top-r.top,null,s.bottom-s.top)]}else return PO(t,e,i)}};function Ch(n){let t=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==tt.LTR?t.left:t.right-n.scrollDOM.clientWidth*n.scaleX)-n.scrollDOM.scrollLeft*n.scaleX,top:t.top-n.scrollDOM.scrollTop*n.scaleY}}function Zh(n,t,e){let i=S.cursor(t);return{from:Math.max(e.from,n.moveToLineBoundary(i,!1,!0).from),to:Math.min(e.to,n.moveToLineBoundary(i,!0,!0).from),type:At.Text}}function PO(n,t,e){if(e.to<=n.viewport.from||e.from>=n.viewport.to)return[];let i=Math.max(e.from,n.viewport.from),s=Math.min(e.to,n.viewport.to),r=n.textDirection==tt.LTR,o=n.contentDOM,a=o.getBoundingClientRect(),l=Ch(n),h=o.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),f=a.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),u=a.right-(c?parseInt(c.paddingRight):0),d=Rr(n,i),p=Rr(n,s),m=d.type==At.Text?d:null,g=p.type==At.Text?p:null;if(m&&(n.lineWrapping||d.widgetLineBreaks)&&(m=Zh(n,i,m)),g&&(n.lineWrapping||p.widgetLineBreaks)&&(g=Zh(n,s,g)),m&&g&&m.from==g.from)return w(x(e.from,e.to,m));{let k=m?x(e.from,null,m):P(d,!1),T=g?x(null,e.to,g):P(p,!0),Q=[];return(m||d).to<(g||p).from-(m&&g?1:0)||d.widgetLineBreaks>1&&k.bottom+n.defaultLineHeight/2X&&L.from=St)break;at>et&&R(Math.max(Yt,et),k==null&&Yt<=X,Math.min(at,St),T==null&&at>=G,$t.dir)}if(et=wt.to+1,et>=St)break}return Y.length==0&&R(X,k==null,G,T==null,n.textDirection),{top:B,bottom:M,horizontal:Y}}function P(k,T){let Q=a.top+(T?k.top:k.bottom);return{top:Q,bottom:Q,horizontal:[]}}}function $O(n,t){return n.constructor==t.constructor&&n.eq(t)}var Ah=class{constructor(t,e){this.view=t,this.layer=e,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),e.above&&this.dom.classList.add("cm-layer-above"),e.class&&this.dom.classList.add(e.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),e.mount&&e.mount(this.dom,t)}update(t){t.startState.facet(hs)!=t.state.facet(hs)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&(this.scale(),t.view.requestMeasure(this.measureReq))}docViewUpdate(t){this.layer.updateOnDocViewUpdate!==!1&&t.requestMeasure(this.measureReq)}setOrder(t){let e=0,i=t.facet(hs);for(;e!$O(e,this.drawn[i]))){let e=this.dom.firstChild,i=0;for(let s of t)s.update&&e&&s.constructor&&this.drawn[i].constructor&&s.update(e,this.drawn[i])?(e=e.nextSibling,i++):this.dom.insertBefore(s.draw(),e);for(;e;){let s=e.nextSibling;e.remove(),e=s}this.drawn=t}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},hs=A.define();function Eh(n){return[vt.define(t=>new Ah(t,n)),hs.of(n)]}var Xh=!$.ios,en=A.define({combine(n){return _e(n,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})}});function Rh(n={}){return[en.of(n),TO,CO,ZO,Tl.of(!0)]}function Wh(n){return n.startState.facet(en)!=n.state.facet(en)}var TO=Eh({above:!0,markers(n){let{state:t}=n,e=t.facet(en),i=[];for(let s of t.selection.ranges){let r=s==t.selection.main;if(s.empty?!r||Xh:e.drawRangeCursor){let o=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",a=s.empty?s:S.cursor(s.head,s.head>s.anchor?-1:1);for(let l of vi.forRange(n,o,a))i.push(l)}}return i},update(n,t){n.transactions.some(i=>i.selection)&&(t.style.animationName=t.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let e=Wh(n);return e&&qh(n.state,t),n.docChanged||n.selectionSet||e},mount(n,t){qh(t.state,n)},class:"cm-cursorLayer"});function qh(n,t){t.style.animationDuration=n.facet(en).cursorBlinkRate+"ms"}var CO=Eh({above:!1,markers(n){return n.state.selection.ranges.map(t=>t.empty?[]:vi.forRange(n,"cm-selectionBackground",t)).reduce((t,e)=>t.concat(e))},update(n,t){return n.docChanged||n.selectionSet||n.viewportChanged||Wh(n)},class:"cm-selectionLayer"}),Nr={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};Xh&&(Nr[".cm-line"].caretColor="transparent !important",Nr[".cm-content"]={caretColor:"transparent !important"});var ZO=oe.highest(Z.theme(Nr));function Mh(n,t,e,i,s){t.lastIndex=0;for(let r=n.iterRange(e,i),o=e,a;!r.next().done;o+=r.value.length)if(!r.lineBreak)for(;a=t.exec(r.value);)s(o+a.index,a)}function AO(n,t){let e=n.visibleRanges;if(e.length==1&&e[0].from==n.viewport.from&&e[0].to==n.viewport.to)return e;let i=[];for(let{from:s,to:r}of e)s=Math.max(n.state.doc.lineAt(s).from,s-t),r=Math.min(n.state.doc.lineAt(r).to,r+t),i.length&&i[i.length-1].to>=s?i[i.length-1].to=r:i.push({from:s,to:r});return i}var Yh=class{constructor(t){let{regexp:e,decoration:i,decorate:s,boundary:r,maxLength:o=1e3}=t;if(!e.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=e,s)this.addMatch=(a,l,h,c)=>s(c,h,h+a[0].length,a,l);else if(typeof i=="function")this.addMatch=(a,l,h,c)=>{let f=i(a,l,h);f&&c(h,h+a[0].length,f)};else if(i)this.addMatch=(a,l,h,c)=>c(h,h+a[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=o}createDeco(t){let e=new ge,i=e.add.bind(e);for(let{from:s,to:r}of AO(t,this.maxLength))Mh(t.state.doc,this.regexp,s,r,(o,a)=>this.addMatch(a,t,o,i));return e.finish()}updateDeco(t,e){let i=1e9,s=-1;return t.docChanged&&t.changes.iterChanges((r,o,a,l)=>{l>t.view.viewport.from&&a1e3?this.createDeco(t.view):s>-1?this.updateRange(t.view,e.map(t.changes),i,s):e}updateRange(t,e,i,s){for(let r of t.visibleRanges){let o=Math.max(r.from,i),a=Math.min(r.to,s);if(a>o){let l=t.state.doc.lineAt(o),h=l.tol.from;o--)if(this.boundary.test(l.text[o-1-l.from])){c=o;break}for(;au.push(b.range(m,g));if(l==h)for(this.regexp.lastIndex=c-l.from;(d=this.regexp.exec(l.text))&&d.indexthis.addMatch(g,t,m,p));e=e.update({filterFrom:c,filterTo:f,filter:(m,g)=>mf,add:u})}}return e}},_r=/x/.unicode!=null?"gu":"g",EO=new RegExp(`[\0-\b -\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\u2066\u2067\u2069\uFEFF\uFFF9-\uFFFC]`,_r),XO={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"},zr=null;function RO(){var n;if(zr==null&&typeof document!="undefined"&&document.body){let t=document.body.style;zr=((n=t.tabSize)!==null&&n!==void 0?n:t.MozTabSize)!=null}return zr||!1}var cs=A.define({combine(n){let t=_e(n,{render:null,specialChars:EO,addSpecialChars:null});return(t.replaceTabs=!RO())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,_r)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,_r)),t}});function Ih(n={}){return[cs.of(n),WO()]}var Dh=null;function WO(){return Dh||(Dh=vt.fromClass(class{constructor(n){this.view=n,this.decorations=V.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(cs)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new Yh({regexp:n.specialChars,decoration:(t,e,i)=>{let{doc:s}=e.state,r=Le(t[0],0);if(r==9){let o=s.lineAt(i),a=e.state.tabSize,l=kt(o.text,a,i-o.from);return V.replace({widget:new Bh((a-l%a)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=V.replace({widget:new Vh(n,r)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let t=n.state.facet(cs);n.startState.facet(cs)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}var qO="\u2022";function MO(n){return n>=32?qO:n==10?"\u2424":String.fromCharCode(9216+n)}var Vh=class extends ye{constructor(t,e){super();this.options=t,this.code=e}eq(t){return t.code==this.code}toDOM(t){let e=MO(this.code),i=t.state.phrase("Control character")+" "+(XO[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,i,e);if(s)return s;let r=document.createElement("span");return r.textContent=e,r.title=i,r.setAttribute("aria-label",i),r.className="cm-specialChar",r}ignoreEvent(){return!1}},Bh=class extends ye{constructor(t){super();this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent=" ",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}};var DS=Z.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:`${7}px`,width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:`${7}px solid transparent`,borderRight:`${7}px solid transparent`},".cm-tooltip-above &":{bottom:`-${7}px`,"&:before":{borderTop:`${7}px solid #bbb`},"&:after":{borderTop:`${7}px solid #f5f5f5`,bottom:"1px"}},".cm-tooltip-below &":{top:`-${7}px`,"&:before":{borderBottom:`${7}px solid #bbb`},"&:after":{borderBottom:`${7}px solid #f5f5f5`,top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}});var We=class extends ae{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}};We.prototype.elementClass="";We.prototype.toDOM=void 0;We.prototype.mapMode=ct.TrackBefore;We.prototype.startSide=We.prototype.endSide=-1;We.prototype.point=!0;var jr=1024,YO=0,Xt=class{constructor(t,e){this.from=t,this.to=e}},E=class{constructor(t={}){this.id=YO++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=it.match(t)),e=>{let i=t(e);return i===void 0?null:[this,i]}}};E.closedBy=new E({deserialize:n=>n.split(" ")});E.openedBy=new E({deserialize:n=>n.split(" ")});E.group=new E({deserialize:n=>n.split(" ")});E.isolate=new E({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});E.contextHash=new E({perNode:!0});E.lookAhead=new E({perNode:!0});E.mounted=new E({perNode:!0});var xi=class{constructor(t,e,i){this.tree=t,this.overlay=e,this.parser=i}static get(t){return t&&t.props&&t.props[E.mounted.id]}},IO=Object.create(null),it=class{constructor(t,e,i,s=0){this.name=t,this.props=e,this.id=i,this.flags=s}static define(t){let e=t.props&&t.props.length?Object.create(null):IO,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),s=new it(t.name||"",e,t.id,i);if(t.props){for(let r of t.props)if(Array.isArray(r)||(r=r(s)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[r[0].id]=r[1]}}return s}prop(t){return this.props[t.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(t){if(typeof t=="string"){if(this.name==t)return!0;let e=this.prop(E.group);return e?e.indexOf(t)>-1:!1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let s of i.split(" "))e[s]=t[i];return i=>{for(let s=i.prop(E.group),r=-1;r<(s?s.length:0);r++){let o=e[r<0?i.name:s[r]];if(o)return o}}}};it.none=new it("",Object.create(null),0,8);var Qe=class{constructor(t){this.types=t;for(let e=0;e0;for(let l=this.cursor(o|N.IncludeAnonymous);;){let h=!1;if(l.from<=r&&l.to>=s&&(!a&&l.type.isAnonymous||e(l)!==!1)){if(l.firstChild())continue;h=!0}for(;h&&i&&(a||!l.type.isAnonymous)&&i(l),!l.nextSibling();){if(!l.parent())return;h=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:Fr(it.none,this.children,this.positions,0,this.children.length,0,this.length,(e,i,s)=>new I(this.type,e,i,s,this.propValues),t.makeTree||((e,i,s)=>new I(it.none,e,i,s)))}static build(t){return VO(t)}};I.empty=new I(it.none,[],[],0);var us=class{constructor(t,e){this.buffer=t,this.index=e}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 us(this.buffer,this.index)}},Pe=class{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return it.none}toString(){let t=[];for(let e=0;e0));l=o[l+3]);return a}slice(t,e,i){let s=this.buffer,r=new Uint16Array(e-t),o=0;for(let a=t,l=0;a=t&&et;case 1:return e<=t&&i>t;case 2:return i>t;case 4:return!0}}function nn(n,t,e,i){for(var s;n.from==n.to||(e<1?n.from>=t:n.from>t)||(e>-1?n.to<=t:n.to0?a.length:-1;t!=h;t+=e){let c=a[t],f=l[t]+o.from;if(!!Nh(s,i,f,f+c.length)){if(c instanceof Pe){if(r&N.ExcludeBuffers)continue;let u=c.findChild(0,c.buffer.length,e,i-f,s);if(u>-1)return new Kt(new zh(o,c,t,f),null,u)}else if(r&N.IncludeAnonymous||!c.type.isAnonymous||Hr(c)){let u;if(!(r&N.IgnoreMounts)&&(u=xi.get(c))&&!u.overlay)return new ut(u.tree,f,t,o);let d=new ut(c,f,t,o);return r&N.IncludeAnonymous||!d.type.isAnonymous?d:d.nextChild(e<0?c.children.length-1:0,e,i,s)}}}if(r&N.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?t=o.index+e:t=e<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,i=0){let s;if(!(i&N.IgnoreOverlays)&&(s=xi.get(this._tree))&&s.overlay){let r=t-this.from;for(let{from:o,to:a}of s.overlay)if((e>0?o<=r:o=r:a>r))return new ut(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}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 _h(n,t,e,i){let s=n.cursor(),r=[];if(!s.firstChild())return r;if(e!=null){for(let o=!1;!o;)if(o=s.type.is(e),!s.nextSibling())return r}for(;;){if(i!=null&&s.type.is(i))return r;if(s.type.is(t)&&r.push(s.node),!s.nextSibling())return i==null?r:[]}}function Ur(n,t,e=t.length-1){for(let i=n.parent;e>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[e]&&t[e]!=i.name)return!1;e--}}return!0}var zh=class{constructor(t,e,i,s){this.parent=t,this.buffer=e,this.index=i,this.start=s}},Kt=class extends Gr{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(t,e,i){super();this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],t,e-this.context.start,i);return r<0?null:new Kt(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,i=0){if(i&N.ExcludeBuffers)return null;let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return r<0?null:new Kt(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new Kt(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new Kt(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,s=this.index+4,r=i.buffer[this.index+3];if(r>s){let o=i.buffer[this.index+1];t.push(i.slice(s,r,o)),e.push(0)}return new I(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function jh(n){if(!n.length)return null;let t=0,e=n[0];for(let r=1;re.from||o.to=t){let a=new ut(o.tree,o.overlay[0].from+r.from,-1,r);(s||(s=[i])).push(nn(a,t,e,!1))}}return s?jh(s):i}var sn=class{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof ut)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let i=t._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,e){this.index=t;let{start:i,buffer:s}=this.buffer;return this.type=e||s.set.types[s.buffer[t]],this.from=i+s.buffer[t+1],this.to=i+s.buffer[t+2],!0}yield(t){return t?t instanceof ut?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:s}=this.buffer,r=s.findChild(this.index+4,s.buffer[this.index+3],t,e-this.buffer.start,i);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?i&N.ExcludeBuffers?!1:this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&N.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&N.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let s=i<0?0:this.stack[i]+4;if(this.index!=s)return this.yieldBuf(e.findChild(s,this.index,-1,0,4))}else{let s=e.buffer[this.index+3];if(s<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(s)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:s}=this;if(s){if(t>0){if(this.index-1)for(let r=e+t,o=t<0?-1:i._tree.children.length;r!=o;r+=t){let a=i._tree.children[r];if(this.mode&N.IncludeAnonymous||a instanceof Pe||!a.type.isAnonymous||Hr(a))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to=0;){for(let o=t;o;o=o._parent)if(o.index==s){if(s==this.index)return o;e=o,i=r+1;break t}s=this.stack[--r]}}for(let s=i;s=0;r--){if(r<0)return Ur(this.node,t,s);let o=i[e.buffer[this.stack[r]]];if(!o.isAnonymous){if(t[s]&&t[s]!=o.name)return!1;s--}}return!0}};function Hr(n){return n.children.some(t=>t instanceof Pe||!t.type.isAnonymous||Hr(t))}function VO(n){var t;let{buffer:e,nodeSet:i,maxBufferLength:s=jr,reused:r=[],minRepeatType:o=i.types.length}=n,a=Array.isArray(e)?new us(e,e.length):e,l=i.types,h=0,c=0;function f(k,T,Q,B,M,Y){let{id:R,start:X,end:G,size:L}=a,et=c;for(;L<0;)if(a.next(),L==-1){let at=r[R];Q.push(at),B.push(X-k);return}else if(L==-3){h=R;return}else if(L==-4){c=R;return}else throw new RangeError(`Unrecognized record size: ${L}`);let St=l[R],wt,$t,Yt=X-k;if(G-X<=s&&($t=g(a.pos-T,M))){let at=new Uint16Array($t.size-$t.skip),It=a.pos-$t.size,se=at.length;for(;a.pos>It;)se=b($t.start,at,se);wt=new Pe(at,G-$t.start,i),Yt=$t.start-k}else{let at=a.pos-L;a.next();let It=[],se=[],Be=R>=o?R:-1,ai=0,Xn=G;for(;a.pos>at;)Be>=0&&a.id==Be&&a.size>=0?(a.end<=Xn-s&&(p(It,se,X,ai,a.end,Xn,Be,et),ai=It.length,Xn=a.end),a.next()):Y>2500?u(X,at,It,se):f(X,at,It,se,Be,Y+1);if(Be>=0&&ai>0&&ai-1&&ai>0){let pa=d(St);wt=Fr(St,It,se,0,It.length,0,G-X,pa,pa)}else wt=m(St,It,se,G-X,et-G)}Q.push(wt),B.push(Yt)}function u(k,T,Q,B){let M=[],Y=0,R=-1;for(;a.pos>T;){let{id:X,start:G,end:L,size:et}=a;if(et>4)a.next();else{if(R>-1&&G=0;L-=3)X[et++]=M[L],X[et++]=M[L+1]-G,X[et++]=M[L+2]-G,X[et++]=et;Q.push(new Pe(X,M[2]-G,i)),B.push(G-k)}}function d(k){return(T,Q,B)=>{let M=0,Y=T.length-1,R,X;if(Y>=0&&(R=T[Y])instanceof I){if(!Y&&R.type==k&&R.length==B)return R;(X=R.prop(E.lookAhead))&&(M=Q[Y]+R.length+X)}return m(k,T,Q,B,M)}}function p(k,T,Q,B,M,Y,R,X){let G=[],L=[];for(;k.length>B;)G.push(k.pop()),L.push(T.pop()+Q-M);k.push(m(i.types[R],G,L,Y-M,X-Y)),T.push(M-Q)}function m(k,T,Q,B,M=0,Y){if(h){let R=[E.contextHash,h];Y=Y?[R].concat(Y):[R]}if(M>25){let R=[E.lookAhead,M];Y=Y?[R].concat(Y):[R]}return new I(k,T,Q,B,Y)}function g(k,T){let Q=a.fork(),B=0,M=0,Y=0,R=Q.end-s,X={size:0,start:0,skip:0};t:for(let G=Q.pos-k;Q.pos>G;){let L=Q.size;if(Q.id==T&&L>=0){X.size=B,X.start=M,X.skip=Y,Y+=4,B+=4,Q.next();continue}let et=Q.pos-L;if(L<0||et=o?4:0,wt=Q.start;for(Q.next();Q.pos>et;){if(Q.size<0)if(Q.size==-3)St+=4;else break t;else Q.id>=o&&(St+=4);Q.next()}M=wt,B+=L,Y+=St}return(T<0||B==k)&&(X.size=B,X.start=M,X.skip=Y),X.size>4?X:void 0}function b(k,T,Q){let{id:B,start:M,end:Y,size:R}=a;if(a.next(),R>=0&&B4){let G=a.pos-(R-4);for(;a.pos>G;)Q=b(k,T,Q)}T[--Q]=X,T[--Q]=Y-k,T[--Q]=M-k,T[--Q]=B}else R==-3?h=B:R==-4&&(c=B);return Q}let w=[],x=[];for(;a.pos>0;)f(n.start||0,n.bufferStart||0,w,x,-1,0);let P=(t=n.length)!==null&&t!==void 0?t:w.length?x[0]+w[0].length:0;return new I(l[n.topID],w.reverse(),x.reverse(),P)}var Uh=new WeakMap;function ds(n,t){if(!n.isAnonymous||t instanceof Pe||t.type!=n)return 1;let e=Uh.get(t);if(e==null){e=1;for(let i of t.children){if(i.type!=n||!(i instanceof I)){e=1;break}e+=ds(n,i)}Uh.set(t,e)}return e}function Fr(n,t,e,i,s,r,o,a,l){let h=0;for(let p=i;p=c)break;T+=Q}if(x==P+1){if(T>c){let Q=p[P];d(Q.children,Q.positions,0,Q.children.length,m[P]+w);continue}f.push(p[P])}else{let Q=m[x-1]+p[x-1].length-k;f.push(Fr(n,p,m,P,x,k,Q,null,l))}u.push(k+w-r)}}return d(t,e,i,s,0),(a||l)(f,u,o)}var rn=class{constructor(){this.map=new WeakMap}setBuffer(t,e,i){let s=this.map.get(t);s||this.map.set(t,s=new Map),s.set(e,i)}getBuffer(t,e){let i=this.map.get(t);return i&&i.get(e)}set(t,e){t instanceof Kt?this.setBuffer(t.context.buffer,t.index,e):t instanceof ut&&this.map.set(t.tree,e)}get(t){return t instanceof Kt?this.getBuffer(t.context.buffer,t.index):t instanceof ut?this.map.get(t.tree):void 0}cursorSet(t,e){t.buffer?this.setBuffer(t.buffer.buffer,t.index,e):this.map.set(t.tree,e)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}},Jt=class{constructor(t,e,i,s,r=!1,o=!1){this.from=t,this.to=e,this.tree=i,this.offset=s,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,e=[],i=!1){let s=[new Jt(0,t.length,t,0,!1,i)];for(let r of e)r.to>t.length&&s.push(r);return s}static applyChanges(t,e,i=128){if(!e.length)return t;let s=[],r=1,o=t.length?t[0]:null;for(let a=0,l=0,h=0;;a++){let c=a=i)for(;o&&o.from=u.from||f<=u.to||h){let d=Math.max(u.from,l)-h,p=Math.min(u.to,f)-h;u=d>=p?null:new Jt(d,p,u.tree,u.offset+h,a>0,!!c)}if(u&&s.push(u),o.to>f)break;o=rnew Xt(s.from,s.to)):[new Xt(0,0)]:[new Xt(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let s=this.startParse(t,e,i);for(;;){let r=s.advance();if(r)return r}}},Hh=class{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}};function ps(n){return(t,e,i,s)=>new Jh(t,n,e,i,s)}var Kr=class{constructor(t,e,i,s,r){this.parser=t,this.parse=e,this.overlay=i,this.target=s,this.from=r}};function Fh(n){if(!n.length||n.some(t=>t.from>=t.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(n))}var Kh=class{constructor(t,e,i,s,r,o,a){this.parser=t,this.predicate=e,this.mounts=i,this.index=s,this.start=r,this.target=o,this.prev=a,this.depth=0,this.ranges=[]}},Jr=new E({perNode:!0}),Jh=class{constructor(t,e,i,s,r){this.nest=e,this.input=i,this.fragments=s,this.ranges=r,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=t}advance(){if(this.baseParse){let i=this.baseParse.advance();if(!i)return null;if(this.baseParse=null,this.baseTree=i,this.startInner(),this.stoppedAt!=null)for(let s of this.inner)s.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new I(i.type,i.children,i.positions,i.length,i.propValues.concat([[Jr,this.stoppedAt]]))),i}let t=this.inner[this.innerDone],e=t.parse.advance();if(e){this.innerDone++;let i=Object.assign(Object.create(null),t.target.props);i[E.mounted.id]=new xi(e,t.overlay,t.parser),t.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let t=this.input.length;for(let e=this.innerDone;e=this.stoppedAt)a=!1;else if(t.hasNode(s)){if(e){let h=e.mounts.find(c=>c.frag.from<=s.from&&c.frag.to>=s.to&&c.mount.overlay);if(h)for(let c of h.mount.overlay){let f=c.from+h.pos,u=c.to+h.pos;f>=s.from&&u<=s.to&&!e.ranges.some(d=>d.fromf)&&e.ranges.push({from:f,to:u})}}a=!1}else if(i&&(o=BO(i.ranges,s.from,s.to)))a=o!=2;else if(!s.type.isAnonymous&&(r=this.nest(s,this.input))&&(s.fromnew Xt(f.from-s.from,f.to-s.from)):null,s.tree,c.length?c[0].from:s.from)),r.overlay?c.length&&(i={ranges:c,depth:0,prev:i}):a=!1}}else e&&(l=e.predicate(s))&&(l===!0&&(l=new Xt(s.from,s.to)),l.fromnew Xt(c.from-e.start,c.to-e.start)),e.target,h[0].from))),e=e.prev}i&&!--i.depth&&(i=i.prev)}}}};function BO(n,t,e){for(let i of n){if(i.from>=e)break;if(i.to>t)return i.from<=t&&i.to>=e?2:1}return 0}function tc(n,t,e,i,s,r){if(t=t&&e.enter(i,1,N.IgnoreOverlays|N.ExcludeBuffers)||e.next(!1)||(this.done=!0)}hasNode(t){if(this.moveTo(t.from),!this.done&&this.cursor.from+this.offset==t.from&&this.cursor.tree)for(let e=this.cursor.tree;;){if(e==t.tree)return!0;if(e.children.length&&e.positions[0]==0&&e.children[0]instanceof I)e=e.children[0];else break}return!1}},ec=class{constructor(t){var e;if(this.fragments=t,this.curTo=0,this.fragI=0,t.length){let i=this.curFrag=t[0];this.curTo=(e=i.tree.prop(Jr))!==null&&e!==void 0?e:i.to,this.inner=new to(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(t){for(;this.curFrag&&t.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=t.from&&this.curTo>=t.to&&this.inner.hasNode(t)}nextFrag(){var t;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=(t=e.tree.prop(Jr))!==null&&t!==void 0?t:e.to,this.inner=new to(e.tree,-e.offset)}}findMounts(t,e){var i;let s=[];if(this.inner){this.inner.cursor.moveTo(t,1);for(let r=this.inner.cursor.node;r;r=r.parent){let o=(i=r.tree)===null||i===void 0?void 0:i.prop(E.mounted);if(o&&o.parser==e)for(let a=this.fragI;a=r.to)break;l.tree==this.curFrag.tree&&s.push({frag:l,pos:r.from-l.offset,mount:o})}}}return s}};function ic(n,t){let e=null,i=t;for(let s=1,r=0;s=a)break;l.to<=o||(e||(i=e=t.slice()),l.froma&&e.splice(r+1,0,new Xt(a,l.to))):l.to>a?e[r--]=new Xt(a,l.to):e.splice(r--,1))}}return i}function NO(n,t,e,i){let s=0,r=0,o=!1,a=!1,l=-1e9,h=[];for(;;){let c=s==n.length?1e9:o?n[s].to:n[s].from,f=r==t.length?1e9:a?t[r].to:t[r].from;if(o!=a){let u=Math.max(l,e),d=Math.min(c,f,i);unew Xt(u.from+i,u.to+i)),f=NO(t,c,l,h);for(let u=0,d=l;;u++){let p=u==f.length,m=p?h:f[u].from;if(m>d&&e.push(new Jt(d,m,s.tree,-o,r.from>=d||r.openStart,r.to<=m||r.openEnd)),p)break;d=f[u].to}}else e.push(new Jt(l,h,s.tree,-o,r.from>=o||r.openStart,r.to<=a||r.openEnd))}return e}var _O=0,Rt=class{constructor(t,e,i){this.set=t,this.base=e,this.modified=i,this.id=_O++}static define(t){if(t==null?void 0:t.base)throw new Error("Can not derive from a modified tag");let e=new Rt([],null,[]);if(e.set.push(e),t)for(let i of t.set)e.set.push(i);return e}static defineModifier(){let t=new on;return e=>e.modified.indexOf(t)>-1?e:on.get(e.base||e,e.modified.concat(t).sort((i,s)=>i.id-s.id))}},zO=0,on=class{constructor(){this.instances=[],this.id=zO++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find(a=>a.base==t&&jO(e,a.modified));if(i)return i;let s=[],r=new Rt(s,t,e);for(let a of e)a.instances.push(r);let o=GO(e);for(let a of t.set)if(!a.modified.length)for(let l of o)s.push(on.get(a,l));return r}};function jO(n,t){return n.length==t.length&&n.every((e,i)=>e==t[i])}function GO(n){let t=[[]];for(let e=0;ei.length-e.length)}function te(n){let t=Object.create(null);for(let e in n){let i=n[e];Array.isArray(i)||(i=[i]);for(let s of e.split(" "))if(s){let r=[],o=2,a=s;for(let f=0;;){if(a=="..."&&f>0&&f+3==s.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!u)throw new RangeError("Invalid path: "+s);if(r.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),f+=u[0].length,f==s.length)break;let d=s[f++];if(f==s.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+s);a=s.slice(f)}let l=r.length-1,h=r[l];if(!h)throw new RangeError("Invalid path: "+s);let c=new an(i,o,l>0?r.slice(0,l):null);t[h]=c.sort(t[h])}}return sc.add(t)}var sc=new E,an=class{constructor(t,e,i,s){this.tags=t,this.mode=e,this.context=i,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth{let o=s;for(let a of r)for(let l of a.set){let h=e[l.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function UO(n,t){let e=null;for(let i of n){let s=i.style(t);s&&(e=e?e+" "+s:s)}return e}function rc(n,t,e,i=0,s=n.length){let r=new oc(i,Array.isArray(t)?t:[t],e);r.highlightRange(n.cursor(),i,s,"",r.highlighters),r.flush(s)}var oc=class{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,s,r){let{type:o,from:a,to:l}=t;if(a>=i||l<=e)return;o.isTop&&(r=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=s,c=HO(t)||an.empty,f=UO(r,c.tags);if(f&&(h&&(h+=" "),h+=f,c.mode==1&&(s+=(s?" ":"")+f)),this.startSpan(Math.max(e,a),h),c.opaque)return;let u=t.tree&&t.tree.prop(E.mounted);if(u&&u.overlay){let d=t.node.enter(u.overlay[0].from+a,1),p=this.highlighters.filter(g=>!g.scope||g.scope(u.tree.type)),m=t.firstChild();for(let g=0,b=a;;g++){let w=g=x||!t.nextSibling())););if(!w||x>i)break;b=w.to+a,b>e&&(this.highlightRange(d.cursor(),Math.max(e,w.from+a),Math.min(i,b),"",p),this.startSpan(Math.min(i,b),h))}m&&t.parent()}else if(t.firstChild()){u&&(s="");do if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,s,r),this.startSpan(Math.min(i,t.to),h)}while(t.nextSibling());t.parent()}}};function HO(n){let t=n.type.prop(sc);for(;t&&t.context&&!n.matchContext(t.context);)t=t.next;return t||null}var v=Rt.define,Os=v(),qe=v(),ac=v(qe),lc=v(qe),Me=v(),ms=v(Me),io=v(Me),ce=v(),Ke=v(ce),fe=v(),ue=v(),no=v(),ln=v(no),gs=v(),O={comment:Os,lineComment:v(Os),blockComment:v(Os),docComment:v(Os),name:qe,variableName:v(qe),typeName:ac,tagName:v(ac),propertyName:lc,attributeName:v(lc),className:v(qe),labelName:v(qe),namespace:v(qe),macroName:v(qe),literal:Me,string:ms,docString:v(ms),character:v(ms),attributeValue:v(ms),number:io,integer:v(io),float:v(io),bool:v(Me),regexp:v(Me),escape:v(Me),color:v(Me),url:v(Me),keyword:fe,self:v(fe),null:v(fe),atom:v(fe),unit:v(fe),modifier:v(fe),operatorKeyword:v(fe),controlKeyword:v(fe),definitionKeyword:v(fe),moduleKeyword:v(fe),operator:ue,derefOperator:v(ue),arithmeticOperator:v(ue),logicOperator:v(ue),bitwiseOperator:v(ue),compareOperator:v(ue),updateOperator:v(ue),definitionOperator:v(ue),typeOperator:v(ue),controlOperator:v(ue),punctuation:no,separator:v(no),bracket:ln,angleBracket:v(ln),squareBracket:v(ln),paren:v(ln),brace:v(ln),content:ce,heading:Ke,heading1:v(Ke),heading2:v(Ke),heading3:v(Ke),heading4:v(Ke),heading5:v(Ke),heading6:v(Ke),contentSeparator:v(ce),list:v(ce),quote:v(ce),emphasis:v(ce),strong:v(ce),link:v(ce),monospace:v(ce),strikethrough:v(ce),inserted:v(),deleted:v(),changed:v(),invalid:v(),meta:gs,documentMeta:v(gs),annotation:v(gs),processingInstruction:v(gs),definition:Rt.defineModifier(),constant:Rt.defineModifier(),function:Rt.defineModifier(),standard:Rt.defineModifier(),local:Rt.defineModifier(),special:Rt.defineModifier()},NS=eo([{tag:O.link,class:"tok-link"},{tag:O.heading,class:"tok-heading"},{tag:O.emphasis,class:"tok-emphasis"},{tag:O.strong,class:"tok-strong"},{tag:O.keyword,class:"tok-keyword"},{tag:O.atom,class:"tok-atom"},{tag:O.bool,class:"tok-bool"},{tag:O.url,class:"tok-url"},{tag:O.labelName,class:"tok-labelName"},{tag:O.inserted,class:"tok-inserted"},{tag:O.deleted,class:"tok-deleted"},{tag:O.literal,class:"tok-literal"},{tag:O.string,class:"tok-string"},{tag:O.number,class:"tok-number"},{tag:[O.regexp,O.escape,O.special(O.string)],class:"tok-string2"},{tag:O.variableName,class:"tok-variableName"},{tag:O.local(O.variableName),class:"tok-variableName tok-local"},{tag:O.definition(O.variableName),class:"tok-variableName tok-definition"},{tag:O.special(O.variableName),class:"tok-variableName2"},{tag:O.definition(O.propertyName),class:"tok-propertyName tok-definition"},{tag:O.typeName,class:"tok-typeName"},{tag:O.namespace,class:"tok-namespace"},{tag:O.className,class:"tok-className"},{tag:O.macroName,class:"tok-macroName"},{tag:O.propertyName,class:"tok-propertyName"},{tag:O.operator,class:"tok-operator"},{tag:O.comment,class:"tok-comment"},{tag:O.meta,class:"tok-meta"},{tag:O.invalid,class:"tok-invalid"},{tag:O.punctuation,class:"tok-punctuation"}]);var so,Ye=new E;function hn(n){return A.define({combine:n?t=>t.concat(n):void 0})}var bs=new E,Qt=class{constructor(t,e,i=[],s=""){this.data=t,this.name=s,q.prototype.hasOwnProperty("tree")||Object.defineProperty(q.prototype,"tree",{get(){return F(this)}}),this.parser=e,this.extension=[Qi.of(this),q.languageData.of((r,o,a)=>{let l=hc(r,o,a),h=l.type.prop(Ye);if(!h)return[];let c=r.facet(h),f=l.type.prop(bs);if(f){let u=l.resolve(o-l.from,a);for(let d of f)if(d.test(u,r)){let p=r.facet(d.facet);return d.type=="replace"?p:p.concat(c)}}return c})].concat(i)}isActiveAt(t,e,i=-1){return hc(t,e,i).type.prop(Ye)==this.data}findRegions(t){let e=t.facet(Qi);if((e==null?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],s=(r,o)=>{if(r.prop(Ye)==this.data){i.push({from:o,to:o+r.length});return}let a=r.prop(E.mounted);if(a){if(a.tree.prop(Ye)==this.data){if(a.overlay)for(let l of a.overlay)i.push({from:l.from+o,to:l.to+o});else i.push({from:o,to:o+r.length});return}else if(a.overlay){let l=i.length;if(s(a.tree,a.overlay[0].from+o),i.length>l)return}}for(let l=0;li.isTop?e:void 0)]}),t.name)}configure(t,e){return new de(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function F(n){let t=n.field(Qt.state,!1);return t?t.tree:I.empty}var cc=class{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}},cn=null,Je=class{constructor(t,e,i=[],s,r,o,a,l){this.parser=t,this.state=e,this.fragments=i,this.tree=s,this.treeLen=r,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new Je(t,e,[],I.empty,0,i,[],null)}startParse(){return this.parser.startParse(new cc(this.state.doc),this.fragments)}work(t,e){return e!=null&&e>=this.state.doc.length&&(e=void 0),this.tree!=I.empty&&this.isDone(e??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof t=="number"){let s=Date.now()+t;t=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),e!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&e=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(Jt.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=cn;cn=this;try{return t()}finally{cn=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=fc(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:s,treeLen:r,viewport:o,skipped:a}=this;if(this.takeTree(),!t.empty){let l=[];if(t.iterChangedRanges((h,c,f,u)=>l.push({fromA:h,toA:c,fromB:f,toB:u})),i=Jt.applyChanges(i,l),s=I.empty,r=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){a=[];for(let h of this.skipped){let c=t.mapPos(h.from,1),f=t.mapPos(h.to,-1);ct.from&&(this.fragments=fc(this.fragments,s,r),this.skipped.splice(i--,1))}return this.skipped.length>=e?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends Fe{createParse(e,i,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let l=cn;if(l){for(let h of s)l.tempSkipped.push(h);t&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,t]):t)}return this.parsedPos=o,new I(it.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&e[0].from==0&&e[0].to>=t}static get(){return cn}};function fc(n,t,e){return Jt.applyChanges(n,[{fromA:t,toA:e,fromB:t,toB:e}])}var ti=class{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new ti(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=Je.create(t.facet(Qi).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new ti(i)}};Qt.state=yt.define({create:ti.init,update(n,t){for(let e of t.effects)if(e.is(Qt.setState))return e.value;return t.startState.facet(Qi)!=t.state.facet(Qi)?ti.init(t.state):n.apply(t)}});var uc=n=>{let t=setTimeout(()=>n(),500);return()=>clearTimeout(t)};typeof requestIdleCallback!="undefined"&&(uc=n=>{let t=-1,e=setTimeout(()=>{t=requestIdleCallback(n,{timeout:500-100})},100);return()=>t<0?clearTimeout(e):cancelIdleCallback(t)});var ro=typeof navigator!="undefined"&&((so=navigator.scheduling)===null||so===void 0?void 0:so.isInputPending)?()=>navigator.scheduling.isInputPending():null,FO=vt.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(Qt.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(Qt.state);(e.tree!=e.context.tree||!e.context.isDone(t.doc.length))&&(this.working=uc(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnds+1e3,l=r.context.work(()=>ro&&ro()||Date.now()>o,s+(a?0:1e5));this.chunkBudget-=Date.now()-e,(l||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Qt.setState.of(new ti(r.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(e=>Lt(this.view.state,e)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Qi=A.define({combine(n){return n.length?n[0]:null},enables:n=>[Qt.state,FO,Z.contentAttributes.compute([n],t=>{let e=t.facet(n);return e&&e.name?{"data-language":e.name}:{}})]}),pe=class{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}},Pi=class{constructor(t,e,i,s,r,o=void 0){this.name=t,this.alias=e,this.extensions=i,this.filename=s,this.loadFunc=r,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(t=>this.support=t,t=>{throw this.loading=null,t}))}static of(t){let{load:e,support:i}=t;if(!e){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");e=()=>Promise.resolve(i)}return new Pi(t.name,(t.alias||[]).concat(t.name).map(s=>s.toLowerCase()),t.extensions||[],t.filename,e,i)}static matchFilename(t,e){for(let s of t)if(s.filename&&s.filename.test(e))return s;let i=/\.([^.]+)$/.exec(e);if(i){for(let s of t)if(s.extensions.indexOf(i[1])>-1)return s}return null}static matchLanguageName(t,e,i=!0){e=e.toLowerCase();for(let s of t)if(s.alias.some(r=>r==e))return s;if(i)for(let s of t)for(let r of s.alias){let o=e.indexOf(r);if(o>-1&&(r.length>2||!/\w/.test(e[o-1])&&!/\w/.test(e[o+r.length])))return s}return null}},KO=A.define(),Ie=A.define({combine:n=>{if(!n.length)return" ";let t=n[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return t}});function fn(n){let t=n.facet(Ie);return t.charCodeAt(0)==9?n.tabSize*t.length:t.length}function un(n,t){let e="",i=n.tabSize,s=n.facet(Ie)[0];if(s==" "){for(;t>=i;)e+=" ",t-=i;s=" "}for(let r=0;r=t?JO(n,e,t):null}var $i=class{constructor(t,e={}){this.state=t,this.options=e,this.unit=fn(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:s,simulateDoubleBreak:r}=this.options;return s!=null&&s>=i.from&&s<=i.to?r&&s==t?{text:"",from:t}:(e<0?s-1&&(r+=o-this.countColumn(i,i.search(/\S|$/))),r}countColumn(t,e=t.length){return kt(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:s}=this.lineAt(t,e),r=this.options.overrideIndentation;if(r){let o=r(s);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},$e=new E;function JO(n,t,e){let i=t.resolveStack(e),s=i.node.enterUnfinishedNodesBefore(e);if(s!=i.node){let r=[];for(let o=s;o!=i.node;o=o.parent)r.push(o);for(let o=r.length-1;o>=0;o--)i={node:r[o],next:i}}return dc(i,n,e)}function dc(n,t,e){for(let i=n;i;i=i.next){let s=em(i.node);if(s)return s(Ss.create(t,e,i))}return 0}function tm(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function em(n){let t=n.type.prop($e);if(t)return t;let e=n.firstChild,i;if(e&&(i=e.type.prop(E.closedBy))){let s=n.lastChild,r=s&&i.indexOf(s.name)>-1;return o=>Oc(o,!0,1,void 0,r&&!tm(o)?s.from:void 0)}return n.parent==null?im:null}function im(){return 0}var Ss=class extends $i{constructor(t,e,i){super(t.state,t.options);this.base=t,this.pos=e,this.context=i}get node(){return this.context.node}static create(t,e,i){return new Ss(t,e,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let i=t.resolve(e.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(nm(i,t))break;e=this.state.doc.lineAt(i.from)}return this.lineIndent(e.from)}continue(){return dc(this.context.next,this.base,this.pos)}};function nm(n,t){for(let e=t;e;e=e.parent)if(n==e)return!0;return!1}function sm(n){let t=n.node,e=t.childAfter(t.from),i=t.lastChild;if(!e)return null;let s=n.options.simulateBreak,r=n.state.doc.lineAt(e.from),o=s==null||s<=r.from?r.to:Math.min(r.to,s);for(let a=e.to;;){let l=t.childAfter(a);if(!l||l==i)return null;if(!l.type.isSkipped)return l.fromOc(i,t,e,n)}function Oc(n,t,e,i,s){let r=n.textAfter,o=r.match(/^\s*/)[0].length,a=i&&r.slice(o,o+i.length)==i||s==n.pos+o,l=t?sm(n):null;return l?a?n.column(l.from):n.column(l.to):n.baseIndent+(a?0:n.unit*e)}var mc=n=>n.baseIndent;function Ti({except:n,units:t=1}={}){return e=>{let i=n&&n.test(e.textAfter);return e.baseIndent+(i?0:t*e.unit)}}var gc=A.define(),Te=new E;function ws(n){let t=n.firstChild,e=n.lastChild;return t&&t.toa.prop(Ye)==o.data:o?a=>a==o:void 0,this.style=eo(t.map(a=>({tag:a.tag,class:a.class||s(Object.assign({},a,{tag:null}))})),{all:r}).style,this.module=i?new Ut(i):null,this.themeType=e.themeType}static define(t,e){return new ei(t,e||{})}},ao=A.define(),bc=A.define({combine(n){return n.length?[n[0]]:null}});function lo(n){let t=n.facet(ao);return t.length?t:n.facet(bc)}function ys(n,t){let e=[rm],i;return n instanceof ei&&(n.module&&e.push(Z.styleModule.of(n.module)),i=n.themeType),(t==null?void 0:t.fallback)?e.push(bc.of(n)):i?e.push(ao.computeN([Z.darkTheme],s=>s.facet(Z.darkTheme)==(i=="dark")?[n]:[])):e.push(ao.of(n)),e}var Sc=class{constructor(t){this.markCache=Object.create(null),this.tree=F(t.state),this.decorations=this.buildDeco(t,lo(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=F(t.state),i=lo(t.state),s=i!=lo(t.startState),{viewport:r}=t.view,o=t.changes.mapPos(this.decoratedTo,1);e.length=r.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=o):(e!=this.tree||t.viewportChanged||s)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i),this.decoratedTo=r.to)}buildDeco(t,e){if(!e||!this.tree.length)return V.none;let i=new ge;for(let{from:s,to:r}of t.visibleRanges)rc(this.tree,e,(o,a,l)=>{i.add(o,a,this.markCache[l]||(this.markCache[l]=V.mark({class:l})))},s,r);return i.finish()}},rm=oe.high(vt.fromClass(Sc,{decorations:n=>n.decorations})),wc=ei.define([{tag:O.meta,color:"#404740"},{tag:O.link,textDecoration:"underline"},{tag:O.heading,textDecoration:"underline",fontWeight:"bold"},{tag:O.emphasis,fontStyle:"italic"},{tag:O.strong,fontWeight:"bold"},{tag:O.strikethrough,textDecoration:"line-through"},{tag:O.keyword,color:"#708"},{tag:[O.atom,O.bool,O.url,O.contentSeparator,O.labelName],color:"#219"},{tag:[O.literal,O.inserted],color:"#164"},{tag:[O.string,O.deleted],color:"#a11"},{tag:[O.regexp,O.escape,O.special(O.string)],color:"#e40"},{tag:O.definition(O.variableName),color:"#00f"},{tag:O.local(O.variableName),color:"#30a"},{tag:[O.typeName,O.namespace],color:"#085"},{tag:O.className,color:"#167"},{tag:[O.special(O.variableName),O.macroName],color:"#256"},{tag:O.definition(O.propertyName),color:"#00c"},{tag:O.comment,color:"#940"},{tag:O.invalid,color:"#f00"}]);var om=1e4,am="()[]{}";var ho=new E;function co(n,t,e){let i=n.prop(t<0?E.openedBy:E.closedBy);if(i)return i;if(n.name.length==1){let s=e.indexOf(n.name);if(s>-1&&s%2==(t<0?1:0))return[e[s+t]]}return null}function fo(n){let t=n.type.prop(ho);return t?t(n.node):n}function ii(n,t,e,i={}){let s=i.maxScanDistance||om,r=i.brackets||am,o=F(n),a=o.resolveInner(t,e);for(let l=a;l;l=l.parent){let h=co(l.type,e,r);if(h&&l.from0?t>=c.from&&tc.from&&t<=c.to))return lm(n,t,e,l,c,h,r)}}return hm(n,t,e,o,a.type,s,r)}function lm(n,t,e,i,s,r,o){let a=i.parent,l={from:s.from,to:s.to},h=0,c=a==null?void 0:a.cursor();if(c&&(e<0?c.childBefore(i.from):c.childAfter(i.to)))do if(e<0?c.to<=i.from:c.from>=i.to){if(h==0&&r.indexOf(c.type.name)>-1&&c.from0)return null;let h={from:e<0?t-1:t,to:e>0?t+1:t},c=n.doc.iterRange(t,e>0?n.doc.length:0),f=0;for(let u=0;!c.next().done&&u<=r;){let d=c.value;e<0&&(u+=d.length);let p=t+u*e;for(let m=e>0?0:d.length-1,g=e>0?d.length:-1;m!=g;m+=e){let b=o.indexOf(d[m]);if(!(b<0||i.resolveInner(p+m,1).type!=s))if(b%2==0==e>0)f++;else{if(f==1)return{start:h,end:{from:p+m,to:p+m+1},matched:b>>1==l>>1};f--}}e>0&&(u+=d.length)}return c.done?{start:h,matched:!1}:null}var cm=Object.create(null),yc=[it.none];var kc=[],vc=Object.create(null),fm=Object.create(null);for(let[n,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])fm[n]=um(cm,t);function uo(n,t){kc.indexOf(n)>-1||(kc.push(n),console.warn(t))}function um(n,t){let e=[];for(let a of t.split(" ")){let l=[];for(let h of a.split(".")){let c=n[h]||O[h];c?typeof c=="function"?l.length?l=l.map(c):uo(h,`Modifier ${h} used at start of tag`):l.length?uo(h,`Tag ${h} used as modifier`):l=Array.isArray(c)?c:[c]:uo(h,`Unknown highlighting tag ${h}`)}for(let h of l)e.push(h)}if(!e.length)return 0;let i=t.replace(/ /g,"_"),s=i+" "+e.map(a=>a.id),r=vc[s];if(r)return r.id;let o=vc[s]=it.define({id:yc.length,name:i,props:[te({[i]:e})]});return yc.push(o),o.id}var JS={rtl:V.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:tt.RTL}),ltr:V.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:tt.LTR}),auto:V.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var dm=n=>{let{state:t}=n,e=t.doc.lineAt(t.selection.main.from),i=Oo(n.state,e.from);return i.line?pm(n):i.block?mm(n):!1};function po(n,t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let s=n(t,e);return s?(i(e.update(s)),!0):!1}}var pm=po(Sm,0);var Om=po(xc,0);var mm=po((n,t)=>xc(n,t,bm(t)),0);function Oo(n,t){let e=n.languageDataAt("commentTokens",t);return e.length?e[0]:{}}var dn=50;function gm(n,{open:t,close:e},i,s){let r=n.sliceDoc(i-dn,i),o=n.sliceDoc(s,s+dn),a=/\s*$/.exec(r)[0].length,l=/^\s*/.exec(o)[0].length,h=r.length-a;if(r.slice(h-t.length,h)==t&&o.slice(l,l+e.length)==e)return{open:{pos:i-a,margin:a&&1},close:{pos:s+l,margin:l&&1}};let c,f;s-i<=2*dn?c=f=n.sliceDoc(i,s):(c=n.sliceDoc(i,i+dn),f=n.sliceDoc(s-dn,s));let u=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-e.length;return c.slice(u,u+t.length)==t&&f.slice(p,p+e.length)==e?{open:{pos:i+u+t.length,margin:/\s/.test(c.charAt(u+t.length))?1:0},close:{pos:s-d-e.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function bm(n){let t=[];for(let e of n.selection.ranges){let i=n.doc.lineAt(e.from),s=e.to<=i.to?i:n.doc.lineAt(e.to),r=t.length-1;r>=0&&t[r].to>i.from?t[r].to=s.to:t.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:s.to})}return t}function xc(n,t,e=t.selection.ranges){let i=e.map(r=>Oo(t,r.from).block);if(!i.every(r=>r))return null;let s=e.map((r,o)=>gm(t,i[o],r.from,r.to));if(n!=2&&!s.every(r=>r))return{changes:t.changes(e.map((r,o)=>s[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(n!=1&&s.some(r=>r)){let r=[];for(let o=0,a;os&&(r==o||o>f.from)){s=f.from;let u=/^\s*/.exec(f.text)[0].length,d=u==f.length,p=f.text.slice(u,u+h.length)==h?u:-1;ur.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:a,token:l,indent:h,empty:c,single:f}of i)(f||!c)&&r.push({from:a.from+h,insert:l+" "});let o=t.changes(r);return{changes:o,selection:t.selection.map(o,1)}}else if(n!=1&&i.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:a,token:l}of i)if(a>=0){let h=o.from+a,c=h+l.length;o.text[c-o.from]==" "&&c++,r.push({from:h,to:c})}return{changes:r}}return null}var mo=Ct.define(),wm=Ct.define(),ym=A.define(),Qc=A.define({combine(n){return _e(n,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(i,s)=>t(i,s)||e(i,s)})}}),Pc=yt.define({create(){return ee.empty},update(n,t){let e=t.state.facet(Qc),i=t.annotation(mo);if(i){let l=mt.fromTransaction(t,i.selection),h=i.side,c=h==0?n.undone:n.done;return l?c=xs(c,c.length,e.minDepth,l):c=Cc(c,t.startState.selection),new ee(h==0?i.rest:c,h==0?c:i.rest)}let s=t.annotation(wm);if((s=="full"||s=="before")&&(n=n.isolate()),t.annotation(J.addToHistory)===!1)return t.changes.empty?n:n.addMapping(t.changes.desc);let r=mt.fromTransaction(t),o=t.annotation(J.time),a=t.annotation(J.userEvent);return r?n=n.addChanges(r,o,a,e,t):t.selection&&(n=n.addSelection(t.startState.selection,o,a,e.newGroupDelay)),(s=="full"||s=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(t=>t.toJSON()),undone:n.undone.map(t=>t.toJSON())}},fromJSON(n){return new ee(n.done.map(mt.fromJSON),n.undone.map(mt.fromJSON))}});function $c(n={}){return[Pc,Qc.of(n),Z.domEventHandlers({beforeinput(t,e){let i=t.inputType=="historyUndo"?vs:t.inputType=="historyRedo"?pn:null;return i?(t.preventDefault(),i(e)):!1}})]}function ks(n,t){return function({state:e,dispatch:i}){if(!t&&e.readOnly)return!1;let s=e.field(Pc,!1);if(!s)return!1;let r=s.pop(n,e,t);return r?(i(r),!0):!1}}var vs=ks(0,!1),pn=ks(1,!1),km=ks(0,!0),vm=ks(1,!0);var mt=class{constructor(t,e,i,s,r){this.changes=t,this.effects=e,this.mapped=i,this.startSelection=s,this.selectionsAfter=r}setSelAfter(t){return new mt(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,i;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(e=this.mapped)===null||e===void 0?void 0:e.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(t){return new mt(t.changes&&st.fromJSON(t.changes),[],t.mapped&&Dt.fromJSON(t.mapped),t.startSelection&&S.fromJSON(t.startSelection),t.selectionsAfter.map(S.fromJSON))}static fromTransaction(t,e){let i=_t;for(let s of t.startState.facet(ym)){let r=s(t);r.length&&(i=i.concat(r))}return!i.length&&t.changes.empty?null:new mt(t.changes.invert(t.startState.doc),i,void 0,e||t.startState.selection,_t)}static selection(t){return new mt(void 0,_t,void 0,void 0,t)}};function xs(n,t,e,i){let s=t+1>e+20?t-e-1:0,r=n.slice(s,t);return r.push(i),r}function xm(n,t){let e=[],i=!1;return n.iterChangedRanges((s,r)=>e.push(s,r)),t.iterChangedRanges((s,r,o,a)=>{for(let l=0;l=h&&o<=c&&(i=!0)}}),i}function Qm(n,t){return n.ranges.length==t.ranges.length&&n.ranges.filter((e,i)=>e.empty!=t.ranges[i].empty).length===0}function Tc(n,t){return n.length?t.length?n.concat(t):n:t}var _t=[],Pm=200;function Cc(n,t){if(n.length){let e=n[n.length-1],i=e.selectionsAfter.slice(Math.max(0,e.selectionsAfter.length-Pm));return i.length&&i[i.length-1].eq(t)?n:(i.push(t),xs(n,n.length-1,1e9,e.setSelAfter(i)))}else return[mt.selection([t])]}function $m(n){let t=n[n.length-1],e=n.slice();return e[n.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),e}function go(n,t){if(!n.length)return n;let e=n.length,i=_t;for(;e;){let s=Tm(n[e-1],t,i);if(s.changes&&!s.changes.empty||s.effects.length){let r=n.slice(0,e);return r[e-1]=s,r}else t=s.mapped,e--,i=s.selectionsAfter}return i.length?[mt.selection(i)]:_t}function Tm(n,t,e){let i=Tc(n.selectionsAfter.length?n.selectionsAfter.map(a=>a.map(t)):_t,e);if(!n.changes)return mt.selection(i);let s=n.changes.map(t),r=t.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(r):r;return new mt(s,U.mapEffects(n.effects,t),o,n.startSelection.map(r),i)}var Cm=/^(input\.type|delete)($|\.)/,ee=class{constructor(t,e,i=0,s=void 0){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=s}isolate(){return this.prevTime?new ee(this.done,this.undone):this}addChanges(t,e,i,s,r){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&t.changes&&(!i||Cm.test(i))&&(!a.selectionsAfter.length&&e-this.prevTime0&&e-this.prevTimee.empty?n.moveByChar(e,t):Qs(e,t))}function Ot(n){return n.textDirectionAt(n.state.selection.main.head)==tt.LTR}var Ec=n=>Ac(n,!Ot(n)),Xc=n=>Ac(n,Ot(n));function Rc(n,t){return ie(n,e=>e.empty?n.moveByGroup(e,t):Qs(e,t))}var Zm=n=>Rc(n,!Ot(n)),Am=n=>Rc(n,Ot(n));var rw=typeof Intl!="undefined"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function Em(n,t,e){if(t.type.prop(e))return!0;let i=t.to-t.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(t.from,t.to)))||t.firstChild}function Ps(n,t,e){let i=F(n).resolveInner(t.head),s=e?E.closedBy:E.openedBy;for(let l=t.head;;){let h=e?i.childAfter(l):i.childBefore(l);if(!h)break;Em(n,h,s)?i=h:l=e?h.to:h.from}let r=i.type.prop(s),o,a;return r&&(o=e?ii(n,i.from,1):ii(n,i.to,-1))&&o.matched?a=e?o.end.to:o.end.from:a=e?i.to:i.from,S.cursor(a,e?-1:1)}var Xm=n=>ie(n,t=>Ps(n.state,t,!Ot(n))),Rm=n=>ie(n,t=>Ps(n.state,t,Ot(n)));function Wc(n,t){return ie(n,e=>{if(!e.empty)return Qs(e,t);let i=n.moveVertically(e,t);return i.head!=e.head?i:n.moveToLineBoundary(e,t)})}var qc=n=>Wc(n,!1),Mc=n=>Wc(n,!0);function Yc(n){let t=n.scrollDOM.clientHeighto.empty?n.moveVertically(o,t,e.height):Qs(o,t));if(s.eq(i.selection))return!1;let r;if(e.selfScroll){let o=n.coordsAtPos(i.selection.main.head),a=n.scrollDOM.getBoundingClientRect(),l=a.top+e.marginTop,h=a.bottom-e.marginBottom;o&&o.top>l&&o.bottomIc(n,!1),bo=n=>Ic(n,!0);function De(n,t,e){let i=n.lineBlockAt(t.head),s=n.moveToLineBoundary(t,e);if(s.head==t.head&&s.head!=(e?i.to:i.from)&&(s=n.moveToLineBoundary(t,e,!1)),!e&&s.head==i.from&&i.length){let r=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&t.head!=i.from+r&&(s=S.cursor(i.from+r))}return s}var Wm=n=>ie(n,t=>De(n,t,!0)),qm=n=>ie(n,t=>De(n,t,!1)),Mm=n=>ie(n,t=>De(n,t,!Ot(n))),Ym=n=>ie(n,t=>De(n,t,Ot(n))),Im=n=>ie(n,t=>S.cursor(n.lineBlockAt(t.head).from,1)),Dm=n=>ie(n,t=>S.cursor(n.lineBlockAt(t.head).to,-1));function Vm(n,t,e){let i=!1,s=Ci(n.selection,r=>{let o=ii(n,r.head,-1)||ii(n,r.head,1)||r.head>0&&ii(n,r.head-1,1)||r.headVm(n,t,!1);function zt(n,t){let e=Ci(n.state.selection,i=>{let s=t(i);return S.range(i.anchor,s.head,s.goalColumn,s.bidiLevel||void 0)});return e.eq(n.state.selection)?!1:(n.dispatch(Oe(n.state,e)),!0)}function Vc(n,t){return zt(n,e=>n.moveByChar(e,t))}var Bc=n=>Vc(n,!Ot(n)),Lc=n=>Vc(n,Ot(n));function Nc(n,t){return zt(n,e=>n.moveByGroup(e,t))}var Lm=n=>Nc(n,!Ot(n)),Nm=n=>Nc(n,Ot(n));var _m=n=>zt(n,t=>Ps(n.state,t,!Ot(n))),zm=n=>zt(n,t=>Ps(n.state,t,Ot(n)));function _c(n,t){return zt(n,e=>n.moveVertically(e,t))}var zc=n=>_c(n,!1),jc=n=>_c(n,!0);function Gc(n,t){return zt(n,e=>n.moveVertically(e,t,Yc(n).height))}var Uc=n=>Gc(n,!1),Hc=n=>Gc(n,!0),jm=n=>zt(n,t=>De(n,t,!0)),Gm=n=>zt(n,t=>De(n,t,!1)),Um=n=>zt(n,t=>De(n,t,!Ot(n))),Hm=n=>zt(n,t=>De(n,t,Ot(n))),Fm=n=>zt(n,t=>S.cursor(n.lineBlockAt(t.head).from)),Km=n=>zt(n,t=>S.cursor(n.lineBlockAt(t.head).to)),Fc=({state:n,dispatch:t})=>(t(Oe(n,{anchor:0})),!0),Kc=({state:n,dispatch:t})=>(t(Oe(n,{anchor:n.doc.length})),!0),Jc=({state:n,dispatch:t})=>(t(Oe(n,{anchor:n.selection.main.anchor,head:0})),!0),tf=({state:n,dispatch:t})=>(t(Oe(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),Jm=({state:n,dispatch:t})=>(t(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),tg=({state:n,dispatch:t})=>{let e=Ts(n).map(({from:i,to:s})=>S.range(i,Math.min(s+1,n.doc.length)));return t(n.update({selection:S.create(e),userEvent:"select"})),!0},eg=({state:n,dispatch:t})=>{let e=Ci(n.selection,i=>{var s;let r=F(n).resolveStack(i.from,1);for(let o=r;o;o=o.next){let{node:a}=o;if((a.from=i.to||a.to>i.to&&a.from<=i.from)&&((s=a.parent)===null||s===void 0?void 0:s.parent))return S.range(a.to,a.from)}return i});return t(Oe(n,e)),!0},ig=({state:n,dispatch:t})=>{let e=n.selection,i=null;return e.ranges.length>1?i=S.create([e.main]):e.main.empty||(i=S.create([S.cursor(e.main.head)])),i?(t(Oe(n,i)),!0):!1};function On(n,t){if(n.state.readOnly)return!1;let e="delete.selection",{state:i}=n,s=i.changeByRange(r=>{let{from:o,to:a}=r;if(o==a){let l=t(r);lo&&(e="delete.forward",l=$s(n,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=$s(n,o,!1),a=$s(n,a,!0);return o==a?{range:r}:{changes:{from:o,to:a},range:S.cursor(o,os(n)))i.between(t,t,(s,r)=>{st&&(t=e?r:s)});return t}var ef=(n,t)=>On(n,e=>{let i=e.from,{state:s}=n,r=s.doc.lineAt(i),o,a;if(!t&&i>r.from&&ief(n,!1),nf=n=>ef(n,!0),sf=(n,t)=>On(n,e=>{let i=e.head,{state:s}=n,r=s.doc.lineAt(i),o=s.charCategorizer(i);for(let a=null;;){if(i==(t?r.to:r.from)){i==e.head&&r.number!=(t?s.doc.lines:1)&&(i+=t?1:-1);break}let l=ht(r.text,i-r.from,t)+r.from,h=r.text.slice(Math.min(i,l)-r.from,Math.max(i,l)-r.from),c=o(h);if(a!=null&&c!=a)break;(h!=" "||i!=e.head)&&(a=c),i=l}return i}),rf=n=>sf(n,!1),ng=n=>sf(n,!0),sg=n=>On(n,t=>{let e=n.lineBlockAt(t.head).to;return t.headOn(n,t=>{let e=n.moveToLineBoundary(t,!1).head;return t.head>e?e:Math.max(0,t.head-1)}),og=n=>On(n,t=>{let e=n.moveToLineBoundary(t,!0).head;return t.head{if(n.readOnly)return!1;let e=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:W.of(["",""])},range:S.cursor(i.from)}));return t(n.update(e,{scrollIntoView:!0,userEvent:"input"})),!0},lg=({state:n,dispatch:t})=>{if(n.readOnly)return!1;let e=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let s=i.from,r=n.doc.lineAt(s),o=s==r.from?s-1:ht(r.text,s-r.from,!1)+r.from,a=s==r.to?s+1:ht(r.text,s-r.from,!0)+r.from;return{changes:{from:o,to:a,insert:n.doc.slice(s,a).append(n.doc.slice(o,s))},range:S.cursor(a)}});return e.changes.empty?!1:(t(n.update(e,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Ts(n){let t=[],e=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.from),r=n.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=n.doc.lineAt(i.to-1)),e>=s.number){let o=t[t.length-1];o.to=r.to,o.ranges.push(i)}else t.push({from:s.from,to:r.to,ranges:[i]});e=r.number+1}return t}function of(n,t,e){if(n.readOnly)return!1;let i=[],s=[];for(let r of Ts(n)){if(e?r.to==n.doc.length:r.from==0)continue;let o=n.doc.lineAt(e?r.to+1:r.from-1),a=o.length+1;if(e){i.push({from:r.to,to:o.to},{from:r.from,insert:o.text+n.lineBreak});for(let l of r.ranges)s.push(S.range(Math.min(n.doc.length,l.anchor+a),Math.min(n.doc.length,l.head+a)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:n.lineBreak+o.text});for(let l of r.ranges)s.push(S.range(l.anchor-a,l.head-a))}}return i.length?(t(n.update({changes:i,scrollIntoView:!0,selection:S.create(s,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}var hg=({state:n,dispatch:t})=>of(n,t,!1),cg=({state:n,dispatch:t})=>of(n,t,!0);function af(n,t,e){if(n.readOnly)return!1;let i=[];for(let s of Ts(n))e?i.push({from:s.from,insert:n.doc.slice(s.from,s.to)+n.lineBreak}):i.push({from:s.to,insert:n.lineBreak+n.doc.slice(s.from,s.to)});return t(n.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var fg=({state:n,dispatch:t})=>af(n,t,!1),ug=({state:n,dispatch:t})=>af(n,t,!0),dg=n=>{if(n.state.readOnly)return!1;let{state:t}=n,e=t.changes(Ts(t).map(({from:s,to:r})=>(s>0?s--:rn.moveVertically(s,!0)).map(e);return n.dispatch({changes:e,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function pg(n,t){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(t-1,t+1)))return{from:t,to:t};let e=F(n).resolveInner(t),i=e.childBefore(t),s=e.childAfter(t),r;return i&&s&&i.to<=t&&s.from>=t&&(r=i.type.prop(E.closedBy))&&r.indexOf(s.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(s.from).from&&!/\S/.test(n.sliceDoc(i.to,s.from))?{from:i.to,to:s.from}:null}var Og=lf(!1),mg=lf(!0);function lf(n){return({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(s=>{let{from:r,to:o}=s,a=t.doc.lineAt(r),l=!n&&r==o&&pg(t,r);n&&(r=o=(o<=a.to?a:t.doc.lineAt(o)).to);let h=new $i(t,{simulateBreak:r,simulateDoubleBreak:!!l}),c=oo(h,r);for(c==null&&(c=kt(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize));oa.from&&r{let s=[];for(let o=i.from;o<=i.to;){let a=n.doc.lineAt(o);a.number>e&&(i.empty||i.to>a.from)&&(t(a,s,i),e=a.number),o=a.to+1}let r=n.changes(s);return{changes:s,range:S.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}var gg=({state:n,dispatch:t})=>{if(n.readOnly)return!1;let e=Object.create(null),i=new $i(n,{overrideIndentation:r=>{let o=e[r];return o??-1}}),s=wo(n,(r,o,a)=>{let l=oo(i,r.from);if(l==null)return;/\S/.test(r.text)||(l=0);let h=/^\s*/.exec(r.text)[0],c=un(n,l);(h!=c||a.fromn.readOnly?!1:(t(n.update(wo(n,(e,i)=>{i.push({from:e.from,insert:n.facet(Ie)})}),{userEvent:"input.indent"})),!0),Sg=({state:n,dispatch:t})=>n.readOnly?!1:(t(n.update(wo(n,(e,i)=>{let s=/^\s*/.exec(e.text)[0];if(!s)return;let r=kt(s,n.tabSize),o=0,a=un(n,Math.max(0,r-fn(n)));for(;o({mac:n.key,run:n.run,shift:n.shift}))),hf=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Xm,shift:_m},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Rm,shift:zm},{key:"Alt-ArrowUp",run:hg},{key:"Shift-Alt-ArrowUp",run:fg},{key:"Alt-ArrowDown",run:cg},{key:"Shift-Alt-ArrowDown",run:ug},{key:"Escape",run:ig},{key:"Mod-Enter",run:mg},{key:"Alt-l",mac:"Ctrl-l",run:tg},{key:"Mod-i",run:eg,preventDefault:!0},{key:"Mod-[",run:Sg},{key:"Mod-]",run:bg},{key:"Mod-Alt-\\",run:gg},{key:"Shift-Mod-k",run:dg},{key:"Shift-Mod-\\",run:Bm},{key:"Mod-/",run:dm},{key:"Alt-A",run:Om}].concat(yg);var yo=class{constructor(t,e,i){this.state=t,this.pos=e,this.explicit=i,this.abortListeners=[]}tokenBefore(t){let e=F(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),i=Math.max(e.from,this.pos-250),s=e.text.slice(i-e.from,this.pos-e.from),r=s.search(vg(t,!1));return r<0?null:{from:i+r,to:this.pos,text:s.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(t,e){t=="abort"&&this.abortListeners&&this.abortListeners.push(e)}};function cf(n){let t=Object.keys(n).join(""),e=/\w/.test(t);return e&&(t=t.replace(/\w/g,"")),`[${e?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function kg(n){let t=Object.create(null),e=Object.create(null);for(let{label:s}of n){t[s[0]]=!0;for(let r=1;rtypeof s=="string"?{label:s}:s),[e,i]=t.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:kg(t);return s=>{let r=s.matchBefore(i);return r||s.explicit?{from:r?r.from:s.pos,options:t,validFor:e}:null}}function uf(n,t){return e=>{for(let i=F(e.state).resolveInner(e.pos,-1);i;i=i.parent){if(n.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return t(e)}}function vg(n,t){var e;let{source:i}=n,s=t&&i[0]!="^",r=i[i.length-1]!="$";return!s&&!r?n:new RegExp(`${s?"^":""}(?:${i})${r?"$":""}`,(e=n.flags)!==null&&e!==void 0?e:n.ignoreCase?"i":"")}var xg=Ct.define();var dw=typeof navigator=="object"&&/Win/.test(navigator.platform);var Qg=Z.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xB7\xB7\xB7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:`${400}px`,boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`${30}px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`${30}px`},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25CB'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25CC'"}},".cm-completionIcon-variable":{"&:after":{content:"'\u{1D465}'"}},".cm-completionIcon-constant":{"&:after":{content:"'\u{1D436}'"}},".cm-completionIcon-type":{"&:after":{content:"'\u{1D461}'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222A'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25A1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\u{1F511}\uFE0E'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25A2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),df=class{constructor(t,e,i,s){this.field=t,this.line=e,this.from=i,this.to=s}},Cs=class{constructor(t,e,i){this.field=t,this.from=e,this.to=i}map(t){let e=t.mapPos(this.from,-1,ct.TrackDel),i=t.mapPos(this.to,1,ct.TrackDel);return e==null||i==null?null:new Cs(this.field,e,i)}},Zs=class{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let i=[],s=[e],r=t.doc.lineAt(e),o=/^\s*/.exec(r.text)[0];for(let l of this.lines){if(i.length){let h=o,c=/^\t*/.exec(l)[0].length;for(let f=0;fnew Cs(l.field,s[l.line]+l.from,s[l.line]+l.to));return{text:i,ranges:a}}static parse(t){let e=[],i=[],s=[],r;for(let o of t.split(/\r\n?|\n/)){for(;r=/[#$]\{(?:(\d+)(?::([^}]*))?|([^}]*))\}/.exec(o);){let a=r[1]?+r[1]:null,l=r[2]||r[3]||"",h=-1;for(let c=0;c=h&&f.field++}s.push(new df(h,i.length,r.index,r.index+l.length)),o=o.slice(0,r.index)+l+o.slice(r.index+r[0].length)}for(let a;a=/\\([{}])/.exec(o);){o=o.slice(0,a.index)+a[1]+o.slice(a.index+a[0].length);for(let l of s)l.line==i.length&&l.from>a.index&&(l.from--,l.to--)}i.push(o)}return new Zs(i,s)}},Pg=V.widget({widget:new class extends ye{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),$g=V.mark({class:"cm-snippetField"}),ni=class{constructor(t,e){this.ranges=t,this.active=e,this.deco=V.set(t.map(i=>(i.from==i.to?Pg:$g).range(i.from,i.to)))}map(t){let e=[];for(let i of this.ranges){let s=i.map(t);if(!s)return null;e.push(s)}return new ni(e,this.active)}selectionInsideField(t){return t.ranges.every(e=>this.ranges.some(i=>i.field==this.active&&i.from<=e.from&&i.to>=e.to))}},mn=U.define({map(n,t){return n&&n.map(t)}}),Tg=U.define(),gn=yt.define({create(){return null},update(n,t){for(let e of t.effects){if(e.is(mn))return e.value;if(e.is(Tg)&&n)return new ni(n.ranges,e.value)}return n&&t.docChanged&&(n=n.map(t.changes)),n&&t.selection&&!n.selectionInsideField(t.selection)&&(n=null),n},provide:n=>Z.decorations.from(n,t=>t?t.deco:V.none)});function ko(n,t){return S.create(n.filter(e=>e.field==t).map(e=>S.range(e.from,e.to)))}function Cg(n){let t=Zs.parse(n);return(e,i,s,r)=>{let{text:o,ranges:a}=t.instantiate(e.state,s),l={changes:{from:s,to:r,insert:W.of(o)},scrollIntoView:!0,annotations:i?[xg.of(i),J.userEvent.of("input.complete")]:void 0};if(a.length&&(l.selection=ko(a,0)),a.some(h=>h.field>0)){let h=new ni(a,0),c=l.effects=[mn.of(h)];e.state.field(gn,!1)===void 0&&c.push(U.appendConfig.of([gn,Rg,Wg,Qg]))}e.dispatch(e.state.update(l))}}function pf(n){return({state:t,dispatch:e})=>{let i=t.field(gn,!1);if(!i||n<0&&i.active==0)return!1;let s=i.active+n,r=n>0&&!i.ranges.some(o=>o.field==s+n);return e(t.update({selection:ko(i.ranges,s),effects:mn.of(r?null:new ni(i.ranges,s)),scrollIntoView:!0})),!0}}var Zg=({state:n,dispatch:t})=>n.field(gn,!1)?(t(n.update({effects:mn.of(null)})),!0):!1,Ag=pf(1),Eg=pf(-1);var Xg=[{key:"Tab",run:Ag,shift:Eg},{key:"Escape",run:Zg}],Of=A.define({combine(n){return n.length?n[0]:Xg}}),Rg=oe.highest(xe.compute([Of],n=>n.facet(Of)));function gt(n,t){return Object.assign(Object.assign({},t),{apply:Cg(n)})}var Wg=Z.domEventHandlers({mousedown(n,t){let e=t.state.field(gn,!1),i;if(!e||(i=t.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let s=e.ranges.find(r=>r.from<=i&&r.to>=i);return!s||s.field==e.active?!1:(t.dispatch({selection:ko(e.ranges,s.field),effects:mn.of(e.ranges.some(r=>r.field>s.field)?new ni(e.ranges,s.field):null),scrollIntoView:!0}),!0)}});var mf=new class extends ae{};mf.startSide=1;mf.endSide=-1;var pw=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent);var gf=(()=>[Ih(),$c(),Rh(),ys(wc,{fallback:!0}),xe.of([...hf,...Zc])])();var bf=Z.baseTheme({"&":{color:"var(--text-normal)",backgroundColor:"var(--background-primary)",outline:"none",height:"100%"},"&.cm-focused":{outline:"none"},".cm-content":{"max-width":"100%","text-wrap":"wrap",outline:"none","caret-color":"var(--caret-color)"},".cm-content .cm-line":{padding:"0 1px","font-family":"var(--font-text)","line-height":"var(--line-height-normal)","scroll-padding-block-end":"var(--status-bar-scroll-padding)","scrollbar-gutter":"stable","overflow-wrap":"break-word"},".cm-content .cm-header-1":{"--font-weight":"var(--h1-weight)","font-variant":"var(--h1-variant)","letter-spacing":"-0.015em","line-height":"var(--h1-line-height)","font-size":"var(--h1-size)",color:"var(--h1-color)","font-weight":"var(--font-weight)","font-style":"var(--h1-style)","font-family":"var(--h1-font)"},".cm-content .cm-header-2":{"--font-weight":"var(--h2-weight)","font-variant":"var(--h2-variant)","letter-spacing":"-0.015em","line-height":"var(--h2-line-height)","font-size":"var(--h2-size)",color:"var(--h2-color)","font-weight":"var(--font-weight)","font-style":"var(--h2-style)","font-family":"var(--h2-font)"},".cm-content .cm-header-3":{"--font-weight":"var(--h3-weight)","font-variant":"var(--h3-variant)","letter-spacing":"-0.015em","line-height":"var(--h3-line-height)","font-size":"var(--h3-size)",color:"var(--h3-color)","font-weight":"var(--font-weight)","font-style":"var(--h3-style)","font-family":"var(--h3-font)"},".cm-content .cm-header-4":{"--font-weight":"var(--h4-weight)","font-variant":"var(--h4-variant)","letter-spacing":"-0.015em","line-height":"var(--h4-line-height)","font-size":"var(--h4-size)",color:"var(--h4-color)","font-weight":"var(--font-weight)","font-style":"var(--h4-style)","font-family":"var(--h4-font)"},".cm-content .cm-header-5":{"--font-weight":"var(--h5-weight)","font-variant":"var(--h5-variant)","letter-spacing":"-0.015em","line-height":"var(--h5-line-height)","font-size":"var(--h5-size)",color:"var(--h5-color)","font-weight":"var(--font-weight)","font-style":"var(--h5-style)","font-family":"var(--h5-font)"},".cm-content .cm-header-6":{"--font-weight":"var(--h6-weight)","font-variant":"var(--h6-variant)","letter-spacing":"-0.015em","line-height":"var(--h6-line-height)","font-size":"var(--h6-size)",color:"var(--h6-color)","font-weight":"var(--font-weight)","font-style":"var(--h6-style)","font-family":"var(--h6-font)"},".cm-em":{"font-style":"italic",color:"var(--italic-color)","font-weight":"var(--italic-weight)"},".cm-strong":{"font-weight":"bold",color:"var(--bold-color)"},".cm-strikethrough":{"text-decoration":"line-through",color:"var(--strikethrough-color)"},".cm-quote":{"border-left":"2px solid var(--blockquote-border-color)","padding-left":"10px"}}),qg=ei.define([{tag:O.heading1,class:"cm-header cm-header-1"},{tag:O.heading2,class:"cm-header cm-header-2"},{tag:O.heading3,class:"cm-header cm-header-3"},{tag:O.heading4,class:"cm-header cm-header-4"},{tag:O.heading5,class:"cm-header cm-header-5"},{tag:O.heading6,class:"cm-header cm-header-6"},{tag:O.angleBracket,class:"cm-html-embed cm-embed-block"},{tag:O.squareBracket,class:"cm-hmd-barelink cm-link"},{tag:O.paren,class:"cm-inline-code"},{tag:O.emphasis,class:"cm-em"},{tag:O.strong,class:"cm-strong"},{tag:O.quote,class:"cm-formatting cm-formatting-quote cm-quote"}]),Sf=ys(qg);function wf(n,t=""){let e=3;if(n.includes("```"))for(let i=0,s=0;ie.setDisabled(!0))}onload(){super.onload();let t=this.dom,e=activeDocument.createDocumentFragment(),i=e.createDiv({cls:"table-generator-container"}),s=e.createDiv({cls:["table-generator-counter","menu-item"]});for(let r=0;r<7;r++)for(let o=0;o<7;o++){let a=createDiv({cls:"table-generator-grid"});a.setAttr("i",r),a.setAttr("j",o),a.addEventListener("click",async()=>{await this.editor.createEmptyTable(r+1,o+1)}),this.editor.plugin.registerDomEvent(a,"mouseenter",async()=>{i.querySelectorAll(".table-generator-grid").forEach(l=>{let h=parseInt(l.getAttr("i")),c=parseInt(l.getAttr("j"));h>r||c>o?l.removeClass("select"):l.addClass("select")}),s.innerText=`${r+1} rows ${o+1} columns`}),i.append(a)}t.append(e)}};var bn=class{constructor(t,e,i,s,r,o,a,l,h,c=0,f){this.p=t,this.stack=e,this.state=i,this.reducePos=s,this.pos=r,this.score=o,this.buffer=a,this.bufferBase=l,this.curContext=h,this.lookAhead=c,this.parent=f}toString(){return`[${this.stack.filter((t,e)=>e%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,e,i=0){let s=t.parser.context;return new bn(t,[],e,i,i,0,[],0,s?new xo(s,s.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,e){this.stack.push(this.state,e,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var e;let i=t>>19,s=t&65535,{parser:r}=this.p,o=r.dynamicPrecedence(s);if(o&&(this.score+=o),i==0){this.pushState(r.getGoto(this.state,s,!0),this.reducePos),s=2e3&&!((e=this.p.parser.nodeSet.types[s])===null||e===void 0?void 0:e.isAnonymous)&&(l==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=h):this.p.lastBigReductionSizea;)this.stack.pop();this.reduceContext(s,l)}storeNode(t,e,i,s=4,r=!1){if(t==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&o.buffer[a-4]==0&&o.buffer[a-1]>-1){if(e==i)return;if(o.buffer[a-2]>=e){o.buffer[a-2]=i;return}}}if(!r||this.pos==i)this.buffer.push(t,e,i,s);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,s>4&&(s-=4);this.buffer[o]=t,this.buffer[o+1]=e,this.buffer[o+2]=i,this.buffer[o+3]=s}}shift(t,e,i,s){if(t&131072)this.pushState(t&65535,this.pos);else if((t&262144)==0){let r=t,{parser:o}=this.p;(s>this.pos||e<=o.maxNode)&&(this.pos=s,o.stateFlag(r,1)||(this.reducePos=s)),this.pushState(r,i),this.shiftContext(e,i),e<=o.maxNode&&this.buffer.push(e,i,s,4)}else this.pos=s,this.shiftContext(e,i),e<=this.p.parser.maxNode&&this.buffer.push(e,i,s,4)}apply(t,e,i,s){t&65536?this.reduce(t):this.shift(t,e,i,s)}useNode(t,e){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=t)&&(this.p.reused.push(t),i++);let s=this.pos;this.reducePos=this.pos=s+t.length,this.pushState(e,s),this.buffer.push(i,s,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,e=t.buffer.length;for(;e>0&&t.buffer[e-2]>t.reducePos;)e-=4;let i=t.buffer.slice(e),s=t.bufferBase+e;for(;t&&s==t.bufferBase;)t=t.parent;return new bn(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,s,this.curContext,this.lookAhead,t)}recoverByDelete(t,e){let i=t<=this.p.parser.maxNode;i&&this.storeNode(t,this.pos,e,4),this.storeNode(0,this.pos,e,i?8:4),this.pos=this.reducePos=e,this.score-=190}canShift(t){for(let e=new kf(this);;){let i=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,t);if(i==0)return!1;if((i&65536)==0)return!0;e.reduce(i)}}recoverByInsert(t){if(this.stack.length>=300)return[];let e=this.p.parser.nextStates(this.state);if(e.length>4<<1||this.stack.length>=120){let s=[];for(let r=0,o;rl&1&&a==o)||s.push(e[r],o)}e=s}let i=[];for(let s=0;s>19,s=e&65535,r=this.stack.length-i*3;if(r<0||t.getGoto(this.stack[r],s,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;e=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}findForcedReduction(){let{parser:t}=this.p,e=[],i=(s,r)=>{if(!e.includes(s))return e.push(s),t.allActions(s,o=>{if(!(o&(262144|131072)))if(o&65536){let a=(o>>19)-r;if(a>1){let l=o&65535,h=this.stack.length-a*3;if(h>=0&&t.getGoto(this.stack[h],l,!1)>=0)return a<<19|65536|l}}else{let a=i(o,r+1);if(a!=null)return a}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:t}=this.p;return t.data[t.stateSlot(this.state,1)]==65535&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let e=0;ethis.lookAhead&&(this.emitLookAhead(),this.lookAhead=t)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},xo=class{constructor(t,e){this.tracker=t,this.context=e,this.hash=t.strict?t.hash(e):0}},kf=class{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let e=t&65535,i=t>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let s=this.start.p.parser.getGoto(this.stack[this.base-3],e,!0);this.state=s}},Sn=class{constructor(t,e,i){this.stack=t,this.pos=e,this.index=i,this.buffer=t.buffer,this.index==0&&this.maybeNext()}static create(t,e=t.bufferBase+t.buffer.length){return new Sn(t,e,e-t.bufferBase)}maybeNext(){let t=this.stack.parent;t!=null&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Sn(this.stack,this.pos,this.index)}};function wn(n,t=Uint16Array){if(typeof n!="string")return n;let e=null;for(let i=0,s=0;i=92&&o--,o>=34&&o--;let l=o-32;if(l>=46&&(l-=46,a=!0),r+=l,a)break;r*=46}e?e[s++]=r:e=new t(r)}return e}var yn=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},vf=new yn,xf=class{constructor(t,e){this.input=t,this.ranges=e,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=vf,this.rangeIndex=0,this.pos=this.chunkPos=e[0].from,this.range=e[0],this.end=e[e.length-1].to,this.readNext()}resolveOffset(t,e){let i=this.range,s=this.rangeIndex,r=this.pos+t;for(;ri.to:r>=i.to;){if(s==this.ranges.length-1)return null;let o=this.ranges[++s];r+=o.from-i.to,i=o}return r}clipPos(t){if(t>=this.range.from&&tt)return Math.max(t,e.from);return this.end}peek(t){let e=this.chunkOff+t,i,s;if(e>=0&&e=this.chunk2Pos&&ia.to&&(this.chunk2=this.chunk2.slice(0,a.to-i)),s=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),s}acceptToken(t,e=0){let i=e?this.resolveOffset(e,-1):this.pos;if(i==null||i=this.chunk2Pos&&this.posthis.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,e){if(e?(this.token=e,e.start=t,e.lookAhead=t+1,e.value=e.extended=-1):this.token=vf,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t=this.chunkPos&&e<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,e-this.chunkPos);if(t>=this.chunk2Pos&&e<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,e-this.chunk2Pos);if(t>=this.range.from&&e<=this.range.to)return this.input.read(t,e);let i="";for(let s of this.ranges){if(s.from>=e)break;s.to>t&&(i+=this.input.read(Math.max(s.from,t),Math.min(s.to,e)))}return i}},si=class{constructor(t,e){this.data=t,this.id=e}token(t,e){let{parser:i}=e.p;Qf(this.data,t,e,this.id,i.data,i.tokenPrecTable)}};si.prototype.contextual=si.prototype.fallback=si.prototype.extend=!1;var ri=class{constructor(t,e,i){this.precTable=e,this.elseToken=i,this.data=typeof t=="string"?wn(t):t}token(t,e){let i=t.pos,s=0;for(;;){let r=t.next<0,o=t.resolveOffset(1,1);if(Qf(this.data,t,e,0,this.data,this.precTable),t.token.value>-1)break;if(this.elseToken==null)return;if(r||s++,o==null)break;t.reset(o,t.token)}s&&(t.reset(i,t.token),t.acceptToken(this.elseToken,s))}};ri.prototype.contextual=si.prototype.fallback=si.prototype.extend=!1;var bt=class{constructor(t,e={}){this.token=t,this.contextual=!!e.contextual,this.fallback=!!e.fallback,this.extend=!!e.extend}};function Qf(n,t,e,i,s,r){let o=0,a=1<0){let p=n[d];if(l.allows(p)&&(t.token.value==-1||t.token.value==p||Mg(p,t.token.value,s,r))){t.acceptToken(p);break}}let c=t.next,f=0,u=n[o+2];if(t.next<0&&u>f&&n[h+u*3-3]==65535){o=n[h+u*3-1];continue t}for(;f>1,p=h+d+(d<<1),m=n[p],g=n[p+1]||65536;if(c=g)f=d+1;else{o=n[p+2],t.advance();continue t}}break}}function Pf(n,t,e){for(let i=t,s;(s=n[i])!=65535;i++)if(s==e)return i-t;return-1}function Mg(n,t,e,i){let s=Pf(e,i,t);return s<0||Pf(e,i,n)t)&&!i.type.isError)return e<0?Math.max(0,Math.min(i.to-1,t-25)):Math.min(n.length,Math.max(i.from+1,t+25));if(e<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return e<0?0:n.length}}var Tf=class{constructor(t,e){this.fragments=t,this.nodeSet=e,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?$f(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?$f(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(tt)return this.nextStart=o,null;if(r instanceof I){if(o==t){if(o=Math.max(this.safeFrom,t)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[e]++,this.nextStart=o+r.length}}},Cf=class{constructor(t,e){this.stream=e,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(i=>new yn)}getActions(t){let e=0,i=null,{parser:s}=t.p,{tokenizers:r}=s,o=s.stateSlot(t.state,3),a=t.curContext?t.curContext.hash:0,l=0;for(let h=0;hf.end+25&&(l=Math.max(f.lookAhead,l)),f.value!=0)){let u=e;if(f.extended>-1&&(e=this.addActions(t,f.extended,f.end,e)),e=this.addActions(t,f.value,f.end,e),!c.extend&&(i=f,e>u))break}}for(;this.actions.length>e;)this.actions.pop();return l&&t.setLookAhead(l),!i&&t.pos==this.stream.end&&(i=new yn,i.value=t.p.parser.eofTerm,i.start=i.end=t.pos,e=this.addActions(t,i.value,i.end,e)),this.mainToken=i,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let e=new yn,{pos:i,p:s}=t;return e.start=i,e.end=Math.min(i+1,s.stream.end),e.value=i==s.stream.end?s.parser.eofTerm:0,e}updateCachedToken(t,e,i){let s=this.stream.clipPos(i.pos);if(e.token(this.stream.reset(s,t),i),t.value>-1){let{parser:r}=i.p;for(let o=0;o=0&&i.p.parser.dialect.allows(a>>1)){(a&1)==0?t.value=a>>1:t.extended=a>>1;break}}}else t.value=0,t.end=this.stream.clipPos(s+1)}putAction(t,e,i,s){for(let r=0;rt.bufferLength*4?new Tf(i,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t=this.stacks,e=this.minStackPos,i=this.stacks=[],s,r;if(this.bigReductionCount>300&&t.length==1){let[o]=t;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;oe)i.push(a);else{if(this.advanceStack(a,i,t))continue;{s||(s=[],r=[]),s.push(a);let l=this.tokens.getMainToken(a);r.push(l.value,l.end)}}break}}if(!i.length){let o=s&&Yg(s);if(o)return Wt&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw Wt&&s&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+e);this.recovering||(this.recovering=5)}if(this.recovering&&s){let o=this.stoppedAt!=null&&s[0].pos>this.stoppedAt?s[0]:this.runRecovery(s,r,i);if(o)return Wt&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((a,l)=>l.score-a.score);i.length>o;)i.pop();i.some(a=>a.reducePos>e)&&this.recovering--}else if(i.length>1){t:for(let o=0;o500&&h.buffer.length>500)if((a.score-h.score||a.buffer.length-h.buffer.length)>0)i.splice(l--,1);else{i.splice(o--,1);continue t}}}i.length>12&&i.splice(12,i.length-12)}this.minStackPos=i[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&s>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let h=t.curContext&&t.curContext.tracker.strict,c=h?t.curContext.hash:0;for(let f=this.fragments.nodeAt(s);f;){let u=this.parser.nodeSet.types[f.type.id]==f.type?r.getGoto(t.state,f.type.id):-1;if(u>-1&&f.length&&(!h||(f.prop(E.contextHash)||0)==c))return t.useNode(f,u),Wt&&console.log(o+this.stackID(t)+` (via reuse of ${r.getName(f.type.id)})`),!0;if(!(f instanceof I)||f.children.length==0||f.positions[0]>0)break;let d=f.children[0];if(d instanceof I&&f.positions[0]==0)f=d;else break}}let a=r.stateSlot(t.state,4);if(a>0)return t.reduce(a),Wt&&console.log(o+this.stackID(t)+` (via always-reduce ${r.getName(a&65535)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let l=this.tokens.getActions(t);for(let h=0;hs?e.push(p):i.push(p)}return!1}advanceFully(t,e){let i=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>i)return Af(t,e),!0}}runRecovery(t,e,i){let s=null,r=!1;for(let o=0;o ":"";if(a.deadEnd&&(r||(r=!0,a.restart(),Wt&&console.log(c+this.stackID(a)+" (restarted)"),this.advanceFully(a,i))))continue;let f=a.split(),u=c;for(let d=0;f.forceReduce()&&d<10&&(Wt&&console.log(u+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,i));d++)Wt&&(u=this.stackID(f)+" -> ");for(let d of a.recoverByInsert(l))Wt&&console.log(c+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>a.pos?(h==a.pos&&(h++,l=0),a.recoverByDelete(l,h),Wt&&console.log(c+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),Af(a,i)):(!s||s.scoren,kn=class{constructor(t){this.start=t.start,this.shift=t.shift||Po,this.reduce=t.reduce||Po,this.reuse=t.reuse||Po,this.hash=t.hash||(()=>0),this.strict=t.strict!==!1}},me=class extends Fe{constructor(t){super();if(this.wrappers=[],t.version!=14)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (${14})`);let e=t.nodeNames.split(" ");this.minRepeatTerm=e.length;for(let a=0;at.topRules[a][1]),s=[];for(let a=0;a=0)r(c,l,a[h++]);else{let f=a[h+-c];for(let u=-c;u>0;u--)r(a[h++],l,f);h++}}}this.nodeSet=new Qe(e.map((a,l)=>it.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:s[l],top:i.indexOf(l)>-1,error:l==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(l)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=jr;let o=wn(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;atypeof a=="number"?new si(o,a):a),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,e,i){let s=new Zf(this,t,e,i);for(let r of this.wrappers)s=r(s,t,e,i);return s}getGoto(t,e,i=!1){let s=this.goto;if(e>=s[0])return-1;for(let r=s[e+1];;){let o=s[r++],a=o&1,l=s[r++];if(a&&i)return l;for(let h=r+(o>>1);r0}validAction(t,e){return!!this.allActions(t,i=>i==e?!0:null)}allActions(t,e){let i=this.stateSlot(t,4),s=i?e(i):void 0;for(let r=this.stateSlot(t,1);s==null;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=Ce(this.data,r+2);else break;s=e(Ce(this.data,r+1))}return s}nextStates(t){let e=[];for(let i=this.stateSlot(t,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Ce(this.data,i+2);else break;if((this.data[i+2]&65536>>16)==0){let s=this.data[i+1];e.some((r,o)=>o&1&&r==s)||e.push(this.data[i],s)}}return e}configure(t){let e=Object.assign(Object.create(me.prototype),this);if(t.props&&(e.nodeSet=this.nodeSet.extend(...t.props)),t.top){let i=this.topRules[t.top];if(!i)throw new RangeError(`Invalid top rule name ${t.top}`);e.top=i}return t.tokenizers&&(e.tokenizers=this.tokenizers.map(i=>{let s=t.tokenizers.find(r=>r.from==i);return s?s.to:i})),t.specializers&&(e.specializers=this.specializers.slice(),e.specializerSpecs=this.specializerSpecs.map((i,s)=>{let r=t.specializers.find(a=>a.from==i.external);if(!r)return i;let o=Object.assign(Object.assign({},i),{external:r.to});return e.specializers[s]=Xf(o),o})),t.contextTracker&&(e.context=t.contextTracker),t.dialect&&(e.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(e.strict=t.strict),t.wrap&&(e.wrappers=e.wrappers.concat(t.wrap)),t.bufferLength!=null&&(e.bufferLength=t.bufferLength),e}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let e=this.dynamicPrecedences;return e==null?0:e[t]||0}parseDialect(t){let e=Object.keys(this.dialects),i=e.map(()=>!1);if(t)for(let r of t.split(" ")){let o=e.indexOf(r);o>=0&&(i[o]=!0)}let s=null;for(let r=0;ri)&&e.p.parser.stateFlag(e.state,2)&&(!t||t.scoren.external(e,i)<<1|t}return n.get}var Ig=54,Dg=1,Vg=55,Bg=2,Lg=56,Ng=3,Rf=4,_g=5,As=6,Wf=7,qf=8,Mf=9,Yf=10,zg=11,jg=12,Gg=13,$o=57,Ug=14,If=58,Df=20,Hg=22,Vf=23,Fg=24,To=26,Bf=27,Kg=28,Jg=31,tb=34,eb=36,ib=37,nb=0,sb=1,rb={area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},ob={dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},Lf={dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}};function ab(n){return n==45||n==46||n==58||n>=65&&n<=90||n==95||n>=97&&n<=122||n>=161}function Nf(n){return n==9||n==10||n==13||n==32}var _f=null,zf=null,jf=0;function Co(n,t){let e=n.pos+t;if(jf==e&&zf==n)return _f;let i=n.peek(t);for(;Nf(i);)i=n.peek(++t);let s="";for(;ab(i);)s+=String.fromCharCode(i),i=n.peek(++t);return zf=n,jf=e,_f=s?s.toLowerCase():i==lb||i==hb?void 0:null}var Gf=60,Es=62,Zo=47,lb=63,hb=33,cb=45;function Uf(n,t){this.name=n,this.parent=t,this.hash=t?t.hash:0;for(let e=0;e-1?new Uf(Co(i,1)||"",n):n},reduce(n,t){return t==Df&&n?n.parent:n},reuse(n,t,e,i){let s=t.type.id;return s==As||s==eb?new Uf(Co(i,1)||"",n):n},hash(n){return n?n.hash:0},strict:!1}),db=new bt((n,t)=>{if(n.next!=Gf){n.next<0&&t.context&&n.acceptToken($o);return}n.advance();let e=n.next==Zo;e&&n.advance();let i=Co(n,0);if(i===void 0)return;if(!i)return n.acceptToken(e?Ug:As);let s=t.context?t.context.name:null;if(e){if(i==s)return n.acceptToken(zg);if(s&&ob[s])return n.acceptToken($o,-2);if(t.dialectEnabled(nb))return n.acceptToken(jg);for(let r=t.context;r;r=r.parent)if(r.name==i)return;n.acceptToken(Gg)}else{if(i=="script")return n.acceptToken(Wf);if(i=="style")return n.acceptToken(qf);if(i=="textarea")return n.acceptToken(Mf);if(rb.hasOwnProperty(i))return n.acceptToken(Yf);s&&Lf[s]&&Lf[s][i]?n.acceptToken($o,-1):n.acceptToken(As)}},{contextual:!0}),pb=new bt(n=>{for(let t=0,e=0;;e++){if(n.next<0){e&&n.acceptToken(If);break}if(n.next==cb)t++;else if(n.next==Es&&t>=2){e>=3&&n.acceptToken(If,-2);break}else t=0;n.advance()}});function Ob(n){for(;n;n=n.parent)if(n.name=="svg"||n.name=="math")return!0;return!1}var mb=new bt((n,t)=>{if(n.next==Zo&&n.peek(1)==Es){let e=t.dialectEnabled(sb)||Ob(t.context);n.acceptToken(e?_g:Rf,2)}else n.next==Es&&n.acceptToken(Rf,1)});function Ao(n,t,e){let i=2+n.length;return new bt(s=>{for(let r=0,o=0,a=0;;a++){if(s.next<0){a&&s.acceptToken(t);break}if(r==0&&s.next==Gf||r==1&&s.next==Zo||r>=2&&ro?s.acceptToken(t,-o):s.acceptToken(e,-(o-2));break}else if((s.next==10||s.next==13)&&a){s.acceptToken(t,1);break}else r=o=0;s.advance()}})}var gb=Ao("script",Ig,Dg),bb=Ao("style",Vg,Bg),Sb=Ao("textarea",Lg,Ng),wb=te({"Text RawText":O.content,"StartTag StartCloseTag SelfClosingEndTag EndTag":O.angleBracket,TagName:O.tagName,"MismatchedCloseTag/TagName":[O.tagName,O.invalid],AttributeName:O.attributeName,"AttributeValue UnquotedAttributeValue":O.attributeValue,Is:O.definitionOperator,"EntityReference CharacterReference":O.character,Comment:O.blockComment,ProcessingInst:O.processingInstruction,DoctypeDecl:O.documentMeta}),Hf=me.deserialize({version:14,states:",xOVO!rOOO!WQ#tO'#CqO!]Q#tO'#CzO!bQ#tO'#C}O!gQ#tO'#DQO!lQ#tO'#DSO!qOaO'#CpO!|ObO'#CpO#XOdO'#CpO$eO!rO'#CpOOO`'#Cp'#CpO$lO$fO'#DTO$tQ#tO'#DVO$yQ#tO'#DWOOO`'#Dk'#DkOOO`'#DY'#DYQVO!rOOO%OQ&rO,59]O%ZQ&rO,59fO%fQ&rO,59iO%qQ&rO,59lO%|Q&rO,59nOOOa'#D^'#D^O&XOaO'#CxO&dOaO,59[OOOb'#D_'#D_O&lObO'#C{O&wObO,59[OOOd'#D`'#D`O'POdO'#DOO'[OdO,59[OOO`'#Da'#DaO'dO!rO,59[O'kQ#tO'#DROOO`,59[,59[OOOp'#Db'#DbO'pO$fO,59oOOO`,59o,59oO'xQ#|O,59qO'}Q#|O,59rOOO`-E7W-E7WO(SQ&rO'#CsOOQW'#DZ'#DZO(bQ&rO1G.wOOOa1G.w1G.wOOO`1G/Y1G/YO(mQ&rO1G/QOOOb1G/Q1G/QO(xQ&rO1G/TOOOd1G/T1G/TO)TQ&rO1G/WOOO`1G/W1G/WO)`Q&rO1G/YOOOa-E7[-E7[O)kQ#tO'#CyOOO`1G.v1G.vOOOb-E7]-E7]O)pQ#tO'#C|OOOd-E7^-E7^O)uQ#tO'#DPOOO`-E7_-E7_O)zQ#|O,59mOOOp-E7`-E7`OOO`1G/Z1G/ZOOO`1G/]1G/]OOO`1G/^1G/^O*PQ,UO,59_OOQW-E7X-E7XOOOa7+$c7+$cOOO`7+$t7+$tOOOb7+$l7+$lOOOd7+$o7+$oOOO`7+$r7+$rO*[Q#|O,59eO*aQ#|O,59hO*fQ#|O,59kOOO`1G/X1G/XO*kO7[O'#CvO*|OMhO'#CvOOQW1G.y1G.yOOO`1G/P1G/POOO`1G/S1G/SOOO`1G/V1G/VOOOO'#D['#D[O+_O7[O,59bOOQW,59b,59bOOOO'#D]'#D]O+pOMhO,59bOOOO-E7Y-E7YOOQW1G.|1G.|OOOO-E7Z-E7Z",stateData:",]~O!^OS~OUSOVPOWQOXROYTO[]O][O^^O`^Oa^Ob^Oc^Ox^O{_O!dZO~OfaO~OfbO~OfcO~OfdO~OfeO~O!WfOPlP!ZlP~O!XiOQoP!ZoP~O!YlORrP!ZrP~OUSOVPOWQOXROYTOZqO[]O][O^^O`^Oa^Ob^Oc^Ox^O!dZO~O!ZrO~P#dO![sO!euO~OfvO~OfwO~OS|OT}OhyO~OS!POT}OhyO~OS!ROT}OhyO~OS!TOT}OhyO~OS}OT}OhyO~O!WfOPlX!ZlX~OP!WO!Z!XO~O!XiOQoX!ZoX~OQ!ZO!Z!XO~O!YlORrX!ZrX~OR!]O!Z!XO~O!Z!XO~P#dOf!_O~O![sO!e!aO~OS!bO~OS!cO~Oi!dOSgXTgXhgX~OS!fOT!gOhyO~OS!hOT!gOhyO~OS!iOT!gOhyO~OS!jOT!gOhyO~OS!gOT!gOhyO~Of!kO~Of!lO~Of!mO~OS!nO~Ok!qO!`!oO!b!pO~OS!rO~OS!sO~OS!tO~Oa!uOb!uOc!uO!`!wO!a!uO~Oa!xOb!xOc!xO!b!wO!c!xO~Oa!uOb!uOc!uO!`!{O!a!uO~Oa!xOb!xOc!xO!b!{O!c!xO~OT~bac!dx{!d~",goto:"%p!`PPPPPPPPPPPPPPPPPPPP!a!gP!mPP!yP!|#P#S#Y#]#`#f#i#l#r#x!aP!a!aP$O$U$l$r$x%O%U%[%bPPPPPPPP%hX^OX`pXUOX`pezabcde{!O!Q!S!UR!q!dRhUR!XhXVOX`pRkVR!XkXWOX`pRnWR!XnXXOX`pQrXR!XpXYOX`pQ`ORx`Q{aQ!ObQ!QcQ!SdQ!UeZ!e{!O!Q!S!UQ!v!oR!z!vQ!y!pR!|!yQgUR!VgQjVR!YjQmWR![mQpXR!^pQtZR!`tS_O`ToXp",nodeNames:"\u26A0 StartCloseTag StartCloseTag StartCloseTag EndTag SelfClosingEndTag StartTag StartTag StartTag StartTag StartTag StartCloseTag StartCloseTag StartCloseTag IncompleteCloseTag Document Text EntityReference CharacterReference InvalidEntity Element OpenTag TagName Attribute AttributeName Is AttributeValue UnquotedAttributeValue ScriptText CloseTag OpenTag StyleText CloseTag OpenTag TextareaText CloseTag OpenTag CloseTag SelfClosingTag Comment ProcessingInst MismatchedCloseTag CloseTag DoctypeDecl",maxTerm:67,context:ub,nodeProps:[["closedBy",-10,1,2,3,7,8,9,10,11,12,13,"EndTag",6,"EndTag SelfClosingEndTag",-4,21,30,33,36,"CloseTag"],["openedBy",4,"StartTag StartCloseTag",5,"StartTag",-4,29,32,35,37,"OpenTag"],["group",-9,14,17,18,19,20,39,40,41,42,"Entity",16,"Entity TextContent",-3,28,31,34,"TextContent Entity"],["isolate",-11,21,29,30,32,33,35,36,37,38,41,42,"ltr",-3,26,27,39,""]],propSources:[wb],skippedNodes:[0],repeatNodeCount:9,tokenData:"!]tw8twx7Sx!P8t!P!Q5u!Q!]8t!]!^/^!^!a7S!a#S8t#S#T;{#T#s8t#s$f5u$f;'S8t;'S;=`>V<%l?Ah8t?Ah?BY5u?BY?Mn8t?MnO5u!Z5zbkWOX5uXZ7SZ[5u[^7S^p5uqr5urs7Sst+Ptw5uwx7Sx!]5u!]!^7w!^!a7S!a#S5u#S#T7S#T;'S5u;'S;=`8n<%lO5u!R7VVOp7Sqs7St!]7S!]!^7l!^;'S7S;'S;=`7q<%lO7S!R7qOa!R!R7tP;=`<%l7S!Z8OYkWa!ROX+PZ[+P^p+Pqr+Psw+Px!^+P!a#S+P#T;'S+P;'S;=`+t<%lO+P!Z8qP;=`<%l5u!_8{ihSkWOX5uXZ7SZ[5u[^7S^p5uqr8trs7Sst/^tw8twx7Sx!P8t!P!Q5u!Q!]8t!]!^:j!^!a7S!a#S8t#S#T;{#T#s8t#s$f5u$f;'S8t;'S;=`>V<%l?Ah8t?Ah?BY5u?BY?Mn8t?MnO5u!_:sbhSkWa!ROX+PZ[+P^p+Pqr/^sw/^x!P/^!P!Q+P!Q!^/^!a#S/^#S#T0m#T#s/^#s$f+P$f;'S/^;'S;=`1e<%l?Ah/^?Ah?BY+P?BY?Mn/^?MnO+P!VP<%l?Ah;{?Ah?BY7S?BY?Mn;{?MnO7S!V=dXhSa!Rqr0msw0mx!P0m!Q!^0m!a#s0m$f;'S0m;'S;=`1_<%l?Ah0m?BY?Mn0m!V>SP;=`<%l;{!_>YP;=`<%l8t!_>dhhSkWOX@OXZAYZ[@O[^AY^p@OqrBwrsAYswBwwxAYx!PBw!P!Q@O!Q!]Bw!]!^/^!^!aAY!a#SBw#S#TE{#T#sBw#s$f@O$f;'SBw;'S;=`HS<%l?AhBw?Ah?BY@O?BY?MnBw?MnO@O!Z@TakWOX@OXZAYZ[@O[^AY^p@Oqr@OrsAYsw@OwxAYx!]@O!]!^Az!^!aAY!a#S@O#S#TAY#T;'S@O;'S;=`Bq<%lO@O!RA]UOpAYq!]AY!]!^Ao!^;'SAY;'S;=`At<%lOAY!RAtOb!R!RAwP;=`<%lAY!ZBRYkWb!ROX+PZ[+P^p+Pqr+Psw+Px!^+P!a#S+P#T;'S+P;'S;=`+t<%lO+P!ZBtP;=`<%l@O!_COhhSkWOX@OXZAYZ[@O[^AY^p@OqrBwrsAYswBwwxAYx!PBw!P!Q@O!Q!]Bw!]!^Dj!^!aAY!a#SBw#S#TE{#T#sBw#s$f@O$f;'SBw;'S;=`HS<%l?AhBw?Ah?BY@O?BY?MnBw?MnO@O!_DsbhSkWb!ROX+PZ[+P^p+Pqr/^sw/^x!P/^!P!Q+P!Q!^/^!a#S/^#S#T0m#T#s/^#s$f+P$f;'S/^;'S;=`1e<%l?Ah/^?Ah?BY+P?BY?Mn/^?MnO+P!VFQbhSOpAYqrE{rsAYswE{wxAYx!PE{!P!QAY!Q!]E{!]!^GY!^!aAY!a#sE{#s$fAY$f;'SE{;'S;=`G|<%l?AhE{?Ah?BYAY?BY?MnE{?MnOAY!VGaXhSb!Rqr0msw0mx!P0m!Q!^0m!a#s0m$f;'S0m;'S;=`1_<%l?Ah0m?BY?Mn0m!VHPP;=`<%lE{!_HVP;=`<%lBw!ZHcW!bx`P!a`Or(trs'ksv(tw!^(t!^!_)e!_;'S(t;'S;=`*P<%lO(t!aIYlhS`PkW!a`!cpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx}-_}!OKQ!O!P-_!P!Q$q!Q!^-_!^!_*V!_!a&X!a#S-_#S#T1k#T#s-_#s$f$q$f;'S-_;'S;=`3X<%l?Ah-_?Ah?BY$q?BY?Mn-_?MnO$q!aK_khS`PkW!a`!cpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx!P-_!P!Q$q!Q!^-_!^!_*V!_!`&X!`!aMS!a#S-_#S#T1k#T#s-_#s$f$q$f;'S-_;'S;=`3X<%l?Ah-_?Ah?BY$q?BY?Mn-_?MnO$q!TM_X`P!a`!cp!eQOr&Xrs&}sv&Xwx(tx!^&X!^!_*V!_;'S&X;'S;=`*y<%lO&X!aNZ!ZhSfQ`PkW!a`!cpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx}-_}!OMz!O!PMz!P!Q$q!Q![Mz![!]Mz!]!^-_!^!_*V!_!a&X!a!c-_!c!}Mz!}#R-_#R#SMz#S#T1k#T#oMz#o#s-_#s$f$q$f$}-_$}%OMz%O%W-_%W%oMz%o%p-_%p&aMz&a&b-_&b1pMz1p4UMz4U4dMz4d4e-_4e$ISMz$IS$I`-_$I`$IbMz$Ib$Je-_$Je$JgMz$Jg$Kh-_$Kh%#tMz%#t&/x-_&/x&EtMz&Et&FV-_&FV;'SMz;'S;:j!#|;:j;=`3X<%l?&r-_?&r?AhMz?Ah?BY$q?BY?MnMz?MnO$q!a!$PP;=`<%lMz!R!$ZY!a`!cpOq*Vqr!$yrs(Vsv*Vwx)ex!a*V!a!b!4t!b;'S*V;'S;=`*s<%lO*V!R!%Q]!a`!cpOr*Vrs(Vsv*Vwx)ex}*V}!O!%y!O!f*V!f!g!']!g#W*V#W#X!0`#X;'S*V;'S;=`*s<%lO*V!R!&QX!a`!cpOr*Vrs(Vsv*Vwx)ex}*V}!O!&m!O;'S*V;'S;=`*s<%lO*V!R!&vV!a`!cp!dPOr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!'dX!a`!cpOr*Vrs(Vsv*Vwx)ex!q*V!q!r!(P!r;'S*V;'S;=`*s<%lO*V!R!(WX!a`!cpOr*Vrs(Vsv*Vwx)ex!e*V!e!f!(s!f;'S*V;'S;=`*s<%lO*V!R!(zX!a`!cpOr*Vrs(Vsv*Vwx)ex!v*V!v!w!)g!w;'S*V;'S;=`*s<%lO*V!R!)nX!a`!cpOr*Vrs(Vsv*Vwx)ex!{*V!{!|!*Z!|;'S*V;'S;=`*s<%lO*V!R!*bX!a`!cpOr*Vrs(Vsv*Vwx)ex!r*V!r!s!*}!s;'S*V;'S;=`*s<%lO*V!R!+UX!a`!cpOr*Vrs(Vsv*Vwx)ex!g*V!g!h!+q!h;'S*V;'S;=`*s<%lO*V!R!+xY!a`!cpOr!+qrs!,hsv!+qvw!-Swx!.[x!`!+q!`!a!/j!a;'S!+q;'S;=`!0Y<%lO!+qq!,mV!cpOv!,hvx!-Sx!`!,h!`!a!-q!a;'S!,h;'S;=`!.U<%lO!,hP!-VTO!`!-S!`!a!-f!a;'S!-S;'S;=`!-k<%lO!-SP!-kO{PP!-nP;=`<%l!-Sq!-xS!cp{POv(Vx;'S(V;'S;=`(h<%lO(Vq!.XP;=`<%l!,ha!.aX!a`Or!.[rs!-Ssv!.[vw!-Sw!`!.[!`!a!.|!a;'S!.[;'S;=`!/d<%lO!.[a!/TT!a`{POr)esv)ew;'S)e;'S;=`)y<%lO)ea!/gP;=`<%l!.[!R!/sV!a`!cp{POr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!0]P;=`<%l!+q!R!0gX!a`!cpOr*Vrs(Vsv*Vwx)ex#c*V#c#d!1S#d;'S*V;'S;=`*s<%lO*V!R!1ZX!a`!cpOr*Vrs(Vsv*Vwx)ex#V*V#V#W!1v#W;'S*V;'S;=`*s<%lO*V!R!1}X!a`!cpOr*Vrs(Vsv*Vwx)ex#h*V#h#i!2j#i;'S*V;'S;=`*s<%lO*V!R!2qX!a`!cpOr*Vrs(Vsv*Vwx)ex#m*V#m#n!3^#n;'S*V;'S;=`*s<%lO*V!R!3eX!a`!cpOr*Vrs(Vsv*Vwx)ex#d*V#d#e!4Q#e;'S*V;'S;=`*s<%lO*V!R!4XX!a`!cpOr*Vrs(Vsv*Vwx)ex#X*V#X#Y!+q#Y;'S*V;'S;=`*s<%lO*V!R!4{Y!a`!cpOr!4trs!5ksv!4tvw!6Vwx!8]x!a!4t!a!b!:]!b;'S!4t;'S;=`!;r<%lO!4tq!5pV!cpOv!5kvx!6Vx!a!5k!a!b!7W!b;'S!5k;'S;=`!8V<%lO!5kP!6YTO!a!6V!a!b!6i!b;'S!6V;'S;=`!7Q<%lO!6VP!6lTO!`!6V!`!a!6{!a;'S!6V;'S;=`!7Q<%lO!6VP!7QOxPP!7TP;=`<%l!6Vq!7]V!cpOv!5kvx!6Vx!`!5k!`!a!7r!a;'S!5k;'S;=`!8V<%lO!5kq!7yS!cpxPOv(Vx;'S(V;'S;=`(h<%lO(Vq!8YP;=`<%l!5ka!8bX!a`Or!8]rs!6Vsv!8]vw!6Vw!a!8]!a!b!8}!b;'S!8];'S;=`!:V<%lO!8]a!9SX!a`Or!8]rs!6Vsv!8]vw!6Vw!`!8]!`!a!9o!a;'S!8];'S;=`!:V<%lO!8]a!9vT!a`xPOr)esv)ew;'S)e;'S;=`)y<%lO)ea!:YP;=`<%l!8]!R!:dY!a`!cpOr!4trs!5ksv!4tvw!6Vwx!8]x!`!4t!`!a!;S!a;'S!4t;'S;=`!;r<%lO!4t!R!;]V!a`!cpxPOr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!;uP;=`<%l!4t!V!{let h=a.type.id;if(h==Kg)return Eo(a,l,e);if(h==Jg)return Eo(a,l,i);if(h==tb)return Eo(a,l,s);if(h==Df&&r.length){let c=a.node,f=c.firstChild,u=f&&Kf(f,l),d;if(u){for(let p of r)if(p.tag==u&&(!p.attrs||p.attrs(d||(d=Ff(c,l))))){let m=c.lastChild,g=m.type.id==ib?m.from:c.to;if(g>f.to)return{parser:p.parser,overlay:[{from:f.to,to:g}]}}}}if(o&&h==Vf){let c=a.node,f;if(f=c.firstChild){let u=o[l.read(f.from,f.to)];if(u)for(let d of u){if(d.tagName&&d.tagName!=Kf(c.parent,l))continue;let p=c.lastChild;if(p.type.id==To){let m=p.from+1,g=p.lastChild,b=p.to-(g&&g.isError?0:1);if(b>m)return{parser:d.parser,overlay:[{from:m,to:b}]}}else if(p.type.id==Bf)return{parser:d.parser,overlay:[{from:p.from,to:p.to}]}}}}return null})}var yb=99,Jf=1,kb=100,vb=101,tu=2,eu=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],xb=58,Qb=40,iu=95,Pb=91,Xs=45,$b=46,Tb=35,Cb=37,Zb=38,Ab=92,Eb=10;function vn(n){return n>=65&&n<=90||n>=97&&n<=122||n>=161}function nu(n){return n>=48&&n<=57}var Xb=new bt((n,t)=>{for(let e=!1,i=0,s=0;;s++){let{next:r}=n;if(vn(r)||r==Xs||r==iu||e&&nu(r))!e&&(r!=Xs||s>0)&&(e=!0),i===s&&r==Xs&&i++,n.advance();else if(r==Ab&&n.peek(1)!=Eb)n.advance(),n.next>-1&&n.advance(),e=!0;else{e&&n.acceptToken(r==Qb?kb:i==2&&t.canShift(tu)?tu:vb);break}}}),Rb=new bt(n=>{if(eu.includes(n.peek(-1))){let{next:t}=n;(vn(t)||t==iu||t==Tb||t==$b||t==Pb||t==xb&&vn(n.peek(1))||t==Xs||t==Zb)&&n.acceptToken(yb)}}),Wb=new bt(n=>{if(!eu.includes(n.peek(-1))){let{next:t}=n;if(t==Cb&&(n.advance(),n.acceptToken(Jf)),vn(t)){do n.advance();while(vn(n.next)||nu(n.next));n.acceptToken(Jf)}}}),qb=te({"AtKeyword import charset namespace keyframes media supports":O.definitionKeyword,"from to selector":O.keyword,NamespaceName:O.namespace,KeyframeName:O.labelName,KeyframeRangeName:O.operatorKeyword,TagName:O.tagName,ClassName:O.className,PseudoClassName:O.constant(O.className),IdName:O.labelName,"FeatureName PropertyName":O.propertyName,AttributeName:O.attributeName,NumberLiteral:O.number,KeywordQuery:O.keyword,UnaryQueryOp:O.operatorKeyword,"CallTag ValueName":O.atom,VariableName:O.variableName,Callee:O.operatorKeyword,Unit:O.unit,"UniversalSelector NestingSelector":O.definitionOperator,MatchOp:O.compareOperator,"ChildOp SiblingOp, LogicOp":O.logicOperator,BinOp:O.arithmeticOperator,Important:O.modifier,Comment:O.blockComment,ColorLiteral:O.color,"ParenthesizedContent StringLiteral":O.string,":":O.punctuation,"PseudoOp #":O.derefOperator,"; ,":O.separator,"( )":O.paren,"[ ]":O.squareBracket,"{ }":O.brace}),Mb={__proto__:null,lang:32,"nth-child":32,"nth-last-child":32,"nth-of-type":32,"nth-last-of-type":32,dir:32,"host-context":32,url:60,"url-prefix":60,domain:60,regexp:60,selector:138},Yb={__proto__:null,"@import":118,"@media":142,"@charset":146,"@namespace":150,"@keyframes":156,"@supports":168},Ib={__proto__:null,not:132,only:132},su=me.deserialize({version:14,states:":^QYQ[OOO#_Q[OOP#fOWOOOOQP'#Cd'#CdOOQP'#Cc'#CcO#kQ[O'#CfO$_QXO'#CaO$fQ[O'#ChO$qQ[O'#DTO$vQ[O'#DWOOQP'#Em'#EmO${QdO'#DgO%jQ[O'#DtO${QdO'#DvO%{Q[O'#DxO&WQ[O'#D{O&`Q[O'#ERO&nQ[O'#ETOOQS'#El'#ElOOQS'#EW'#EWQYQ[OOO&uQXO'#CdO'jQWO'#DcO'oQWO'#EsO'zQ[O'#EsQOQWOOP(UO#tO'#C_POOO)C@[)C@[OOQP'#Cg'#CgOOQP,59Q,59QO#kQ[O,59QO(aQ[O'#E[O({QWO,58{O)TQ[O,59SO$qQ[O,59oO$vQ[O,59rO(aQ[O,59uO(aQ[O,59wO(aQ[O,59xO)`Q[O'#DbOOQS,58{,58{OOQP'#Ck'#CkOOQO'#DR'#DROOQP,59S,59SO)gQWO,59SO)lQWO,59SOOQP'#DV'#DVOOQP,59o,59oOOQO'#DX'#DXO)qQ`O,59rOOQS'#Cp'#CpO${QdO'#CqO)yQvO'#CsO+ZQtO,5:ROOQO'#Cx'#CxO)lQWO'#CwO+oQWO'#CyO+tQ[O'#DOOOQS'#Ep'#EpOOQO'#Dj'#DjO+|Q[O'#DqO,[QWO'#EtO&`Q[O'#DoO,jQWO'#DrOOQO'#Eu'#EuO)OQWO,5:`O,oQpO,5:bOOQS'#Dz'#DzO,wQWO,5:dO,|Q[O,5:dOOQO'#D}'#D}O-UQWO,5:gO-ZQWO,5:mO-cQWO,5:oOOQS-E8U-E8UO${QdO,59}O-kQ[O'#E^O-xQWO,5;_O-xQWO,5;_POOO'#EV'#EVP.TO#tO,58yPOOO,58y,58yOOQP1G.l1G.lO.zQXO,5:vOOQO-E8Y-E8YOOQS1G.g1G.gOOQP1G.n1G.nO)gQWO1G.nO)lQWO1G.nOOQP1G/Z1G/ZO/XQ`O1G/^O/rQXO1G/aO0YQXO1G/cO0pQXO1G/dO1WQWO,59|O1]Q[O'#DSO1dQdO'#CoOOQP1G/^1G/^O${QdO1G/^O1kQpO,59]OOQS,59_,59_O${QdO,59aO1sQWO1G/mOOQS,59c,59cO1xQ!bO,59eOOQS'#DP'#DPOOQS'#EY'#EYO2QQ[O,59jOOQS,59j,59jO2YQWO'#DjO2eQWO,5:VO2jQWO,5:]O&`Q[O,5:XO&`Q[O'#E_O2rQWO,5;`O2}QWO,5:ZO(aQ[O,5:^OOQS1G/z1G/zOOQS1G/|1G/|OOQS1G0O1G0OO3`QWO1G0OO3eQdO'#EOOOQS1G0R1G0ROOQS1G0X1G0XOOQS1G0Z1G0ZO3pQtO1G/iOOQO,5:x,5:xO4WQ[O,5:xOOQO-E8[-E8[O4eQWO1G0yPOOO-E8T-E8TPOOO1G.e1G.eOOQP7+$Y7+$YOOQP7+$x7+$xO${QdO7+$xOOQS1G/h1G/hO4pQXO'#ErO4wQWO,59nO4|QtO'#EXO5tQdO'#EoO6OQWO,59ZO6TQpO7+$xOOQS1G.w1G.wOOQS1G.{1G.{OOQS7+%X7+%XO6]QWO1G/POOQS-E8W-E8WOOQS1G/U1G/UO${QdO1G/qOOQO1G/w1G/wOOQO1G/s1G/sO6bQWO,5:yOOQO-E8]-E8]O6pQXO1G/xOOQS7+%j7+%jO6wQYO'#CsOOQO'#EQ'#EQO7SQ`O'#EPOOQO'#EP'#EPO7_QWO'#E`O7gQdO,5:jOOQS,5:j,5:jO7rQtO'#E]O${QdO'#E]O8sQdO7+%TOOQO7+%T7+%TOOQO1G0d1G0dO9WQpO<OAN>OO:xQdO,5:uOOQO-E8X-E8XOOQO<T![;'S%^;'S;=`%o<%lO%^l;TUo`Oy%^z!Q%^!Q![;g![;'S%^;'S;=`%o<%lO%^l;nYo`#e[Oy%^z!Q%^!Q![;g![!g%^!g!h<^!h#X%^#X#Y<^#Y;'S%^;'S;=`%o<%lO%^l[[o`#e[Oy%^z!O%^!O!P;g!P!Q%^!Q![>T![!g%^!g!h<^!h#X%^#X#Y<^#Y;'S%^;'S;=`%o<%lO%^n?VSt^Oy%^z;'S%^;'S;=`%o<%lO%^l?hWjWOy%^z!O%^!O!P;O!P!Q%^!Q![>T![;'S%^;'S;=`%o<%lO%^n@VU#bQOy%^z!Q%^!Q![;g![;'S%^;'S;=`%o<%lO%^~@nTjWOy%^z{@}{;'S%^;'S;=`%o<%lO%^~AUSo`#[~Oy%^z;'S%^;'S;=`%o<%lO%^lAg[#e[Oy%^z!O%^!O!P;g!P!Q%^!Q![>T![!g%^!g!h<^!h#X%^#X#Y<^#Y;'S%^;'S;=`%o<%lO%^bBbU]QOy%^z![%^![!]Bt!];'S%^;'S;=`%o<%lO%^bB{S^Qo`Oy%^z;'S%^;'S;=`%o<%lO%^nC^S!Y^Oy%^z;'S%^;'S;=`%o<%lO%^dCoS|SOy%^z;'S%^;'S;=`%o<%lO%^bDQU!OQOy%^z!`%^!`!aDd!a;'S%^;'S;=`%o<%lO%^bDkS!OQo`Oy%^z;'S%^;'S;=`%o<%lO%^bDzWOy%^z!c%^!c!}Ed!}#T%^#T#oEd#o;'S%^;'S;=`%o<%lO%^bEk[![Qo`Oy%^z}%^}!OEd!O!Q%^!Q![Ed![!c%^!c!}Ed!}#T%^#T#oEd#o;'S%^;'S;=`%o<%lO%^nFfSq^Oy%^z;'S%^;'S;=`%o<%lO%^nFwSp^Oy%^z;'S%^;'S;=`%o<%lO%^bGWUOy%^z#b%^#b#cGj#c;'S%^;'S;=`%o<%lO%^bGoUo`Oy%^z#W%^#W#XHR#X;'S%^;'S;=`%o<%lO%^bHYS!bQo`Oy%^z;'S%^;'S;=`%o<%lO%^bHiUOy%^z#f%^#f#gHR#g;'S%^;'S;=`%o<%lO%^fIQS!TUOy%^z;'S%^;'S;=`%o<%lO%^nIcS!S^Oy%^z;'S%^;'S;=`%o<%lO%^fItU!RQOy%^z!_%^!_!`6y!`;'S%^;'S;=`%o<%lO%^`JZP;=`<%l$}",tokenizers:[Rb,Wb,Xb,1,2,3,4,new ri("m~RRYZ[z{a~~g~aO#^~~dP!P!Qg~lO#_~~",28,105)],topRules:{StyleSheet:[0,4],Styles:[1,86]},specialized:[{term:100,get:n=>Mb[n]||-1},{term:58,get:n=>Yb[n]||-1},{term:101,get:n=>Ib[n]||-1}],tokenPrec:1200});var Ro=null;function Wo(){if(!Ro&&typeof document=="object"&&document.body){let{style:n}=document.body,t=[],e=new Set;for(let i in n)i!="cssText"&&i!="cssFloat"&&typeof n[i]=="string"&&(/[A-Z]/.test(i)&&(i=i.replace(/[A-Z]/g,s=>"-"+s.toLowerCase())),e.has(i)||(t.push(i),e.add(i)));Ro=t.sort().map(i=>({type:"property",label:i}))}return Ro||[]}var ru=["active","after","any-link","autofill","backdrop","before","checked","cue","default","defined","disabled","empty","enabled","file-selector-button","first","first-child","first-letter","first-line","first-of-type","focus","focus-visible","focus-within","fullscreen","has","host","host-context","hover","in-range","indeterminate","invalid","is","lang","last-child","last-of-type","left","link","marker","modal","not","nth-child","nth-last-child","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","part","placeholder","placeholder-shown","read-only","read-write","required","right","root","scope","selection","slotted","target","target-text","valid","visited","where"].map(n=>({type:"class",label:n})),ou=["above","absolute","activeborder","additive","activecaption","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","antialiased","appworkspace","asterisks","attr","auto","auto-flow","avoid","avoid-column","avoid-page","avoid-region","axis-pan","background","backwards","baseline","below","bidi-override","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","contain","content","contents","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic-abegede-gez","ethiopic-halehame-aa-er","ethiopic-halehame-gez","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fill-box","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","graytext","grid","groove","hand","hard-light","help","hidden","hide","higher","highlight","highlighttext","horizontal","hsl","hsla","hue","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","justify","keep-all","landscape","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-hexadecimal","lower-latin","lower-norwegian","lowercase","ltr","luminosity","manipulation","match","matrix","matrix3d","medium","menu","menutext","message-box","middle","min-intrinsic","mix","monospace","move","multiple","multiple_mask_images","multiply","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","opacity","open-quote","optimizeLegibility","optimizeSpeed","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","perspective","pinch-zoom","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","se-resize","self-start","self-end","semi-condensed","semi-expanded","separate","serif","show","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","source-atop","source-in","source-out","source-over","space","space-around","space-between","space-evenly","spell-out","square","start","static","status-bar","stretch","stroke","stroke-box","sub","subpixel-antialiased","svg_masks","super","sw-resize","symbolic","symbols","system-ui","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","text","text-bottom","text-top","textarea","textfield","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","to","top","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unidirectional-pan","unset","up","upper-latin","uppercase","url","var","vertical","vertical-text","view-box","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"].map(n=>({type:"keyword",label:n})).concat(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"].map(n=>({type:"constant",label:n}))),Db=["a","abbr","address","article","aside","b","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","dd","del","details","dfn","dialog","div","dl","dt","em","figcaption","figure","footer","form","header","hgroup","h1","h2","h3","h4","h5","h6","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","main","meter","nav","ol","output","p","pre","ruby","section","select","small","source","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","tr","u","ul"].map(n=>({type:"type",label:n})),Ve=/^(\w[\w-]*|-\w[\w-]*|)$/,Vb=/^-(-[\w-]*)?$/;function Bb(n,t){var e;if((n.name=="("||n.type.isError)&&(n=n.parent||n),n.name!="ArgList")return!1;let i=(e=n.parent)===null||e===void 0?void 0:e.firstChild;return(i==null?void 0:i.name)!="Callee"?!1:t.sliceString(i.from,i.to)=="var"}var au=new rn,Lb=["Declaration"];function Nb(n){for(let t=n;;){if(t.type.isTop)return t;if(!(t=t.parent))return n}}function lu(n,t,e){if(t.to-t.from>4096){let i=au.get(t);if(i)return i;let s=[],r=new Set,o=t.cursor(N.IncludeAnonymous);if(o.firstChild())do for(let a of lu(n,o.node,e))r.has(a.label)||(r.add(a.label),s.push(a));while(o.nextSibling());return au.set(t,s),s}else{let i=[],s=new Set;return t.cursor().iterate(r=>{var o;if(e(r)&&r.matchContext(Lb)&&((o=r.node.nextSibling)===null||o===void 0?void 0:o.name)==":"){let a=n.sliceString(r.from,r.to);s.has(a)||(s.add(a),i.push({label:a,type:"variable"}))}}),i}}var _b=n=>t=>{let{state:e,pos:i}=t,s=F(e).resolveInner(i,-1),r=s.type.isError&&s.from==s.to-1&&e.doc.sliceString(s.from,s.to)=="-";if(s.name=="PropertyName"||(r||s.name=="TagName")&&/^(Block|Styles)$/.test(s.resolve(s.to).name))return{from:s.from,options:Wo(),validFor:Ve};if(s.name=="ValueName")return{from:s.from,options:ou,validFor:Ve};if(s.name=="PseudoClassName")return{from:s.from,options:ru,validFor:Ve};if(n(s)||(t.explicit||r)&&Bb(s,e.doc))return{from:n(s)||r?s.from:i,options:lu(e.doc,Nb(s),n),validFor:Vb};if(s.name=="TagName"){for(let{parent:l}=s;l;l=l.parent)if(l.name=="Block")return{from:s.from,options:Wo(),validFor:Ve};return{from:s.from,options:Db,validFor:Ve}}if(!t.explicit)return null;let o=s.resolve(i),a=o.childBefore(i);return a&&a.name==":"&&o.name=="PseudoClassSelector"?{from:i,options:ru,validFor:Ve}:a&&a.name==":"&&o.name=="Declaration"||o.name=="ArgList"?{from:i,options:ou,validFor:Ve}:o.name=="Block"||o.name=="Styles"?{from:i,options:Wo(),validFor:Ve}:null},zb=_b(n=>n.name=="VariableName"),xn=de.define({name:"css",parser:su.configure({props:[$e.add({Declaration:Ti()}),Te.add({"Block KeyframeList":ws})]}),languageData:{commentTokens:{block:{open:"/*",close:"*/"}},indentOnInput:/^\s*\}$/,wordChars:"-"}});function hu(){return new pe(xn,xn.data.of({autocomplete:zb}))}var jb=309,cu=1,Gb=2,Ub=3,Hb=310,Fb=312,Kb=313,Jb=4,t0=5,e0=0,qo=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],fu=125,i0=59,Mo=47,n0=42,s0=43,r0=45,o0=60,a0=44,l0=new kn({start:!1,shift(n,t){return t==Jb||t==t0||t==Fb?n:t==Kb},strict:!1}),h0=new bt((n,t)=>{let{next:e}=n;(e==fu||e==-1||t.context)&&n.acceptToken(Hb)},{contextual:!0,fallback:!0}),c0=new bt((n,t)=>{let{next:e}=n,i;qo.indexOf(e)>-1||e==Mo&&((i=n.peek(1))==Mo||i==n0)||e!=fu&&e!=i0&&e!=-1&&!t.context&&n.acceptToken(jb)},{contextual:!0}),f0=new bt((n,t)=>{let{next:e}=n;if((e==s0||e==r0)&&(n.advance(),e==n.next)){n.advance();let i=!t.context&&t.canShift(cu);n.acceptToken(i?cu:Gb)}},{contextual:!0});function Yo(n,t){return n>=65&&n<=90||n>=97&&n<=122||n==95||n>=192||!t&&n>=48&&n<=57}var u0=new bt((n,t)=>{if(n.next!=o0||!t.dialectEnabled(e0)||(n.advance(),n.next==Mo))return;let e=0;for(;qo.indexOf(n.next)>-1;)n.advance(),e++;if(Yo(n.next,!0)){for(n.advance(),e++;Yo(n.next,!1);)n.advance(),e++;for(;qo.indexOf(n.next)>-1;)n.advance(),e++;if(n.next==a0)return;for(let i=0;;i++){if(i==7){if(!Yo(n.next,!0))return;break}if(n.next!="extends".charCodeAt(i))break;n.advance(),e++}}n.acceptToken(Ub,-e)}),d0=te({"get set async static":O.modifier,"for while do if else switch try catch finally return throw break continue default case":O.controlKeyword,"in of await yield void typeof delete instanceof":O.operatorKeyword,"let var const using function class extends":O.definitionKeyword,"import export from":O.moduleKeyword,"with debugger as new":O.keyword,TemplateString:O.special(O.string),super:O.atom,BooleanLiteral:O.bool,this:O.self,null:O.null,Star:O.modifier,VariableName:O.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":O.function(O.variableName),VariableDefinition:O.definition(O.variableName),Label:O.labelName,PropertyName:O.propertyName,PrivatePropertyName:O.special(O.propertyName),"CallExpression/MemberExpression/PropertyName":O.function(O.propertyName),"FunctionDeclaration/VariableDefinition":O.function(O.definition(O.variableName)),"ClassDeclaration/VariableDefinition":O.definition(O.className),PropertyDefinition:O.definition(O.propertyName),PrivatePropertyDefinition:O.definition(O.special(O.propertyName)),UpdateOp:O.updateOperator,"LineComment Hashbang":O.lineComment,BlockComment:O.blockComment,Number:O.number,String:O.string,Escape:O.escape,ArithOp:O.arithmeticOperator,LogicOp:O.logicOperator,BitOp:O.bitwiseOperator,CompareOp:O.compareOperator,RegExp:O.regexp,Equals:O.definitionOperator,Arrow:O.function(O.punctuation),": Spread":O.punctuation,"( )":O.paren,"[ ]":O.squareBracket,"{ }":O.brace,"InterpolationStart InterpolationEnd":O.special(O.brace),".":O.derefOperator,", ;":O.separator,"@":O.meta,TypeName:O.typeName,TypeDefinition:O.definition(O.typeName),"type enum interface implements namespace module declare":O.definitionKeyword,"abstract global Privacy readonly override":O.modifier,"is keyof unique infer":O.operatorKeyword,JSXAttributeValue:O.attributeValue,JSXText:O.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":O.angleBracket,"JSXIdentifier JSXNameSpacedName":O.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":O.attributeName,"JSXBuiltin/JSXIdentifier":O.standard(O.tagName)}),p0={__proto__:null,export:18,as:23,from:31,default:34,async:39,function:40,extends:52,this:56,true:64,false:64,null:76,void:80,typeof:84,super:102,new:136,delete:152,yield:161,await:165,class:170,public:227,private:227,protected:227,readonly:229,instanceof:248,satisfies:251,in:252,const:254,import:286,keyof:339,unique:343,infer:349,is:385,abstract:405,implements:407,type:409,let:412,var:414,using:417,interface:423,enum:427,namespace:433,module:435,declare:439,global:443,for:462,of:471,while:474,with:478,do:482,if:486,else:488,switch:492,case:498,try:504,catch:508,finally:512,return:516,throw:520,break:524,continue:528,debugger:532},O0={__proto__:null,async:123,get:125,set:127,declare:187,public:189,private:189,protected:189,static:191,abstract:193,override:195,readonly:201,accessor:203,new:389},m0={__proto__:null,"<":143},uu=me.deserialize({version:14,states:"$=WO%TQ^OOO%[Q^OOO'_Q`OOP(lOWOOO*zQ08SO'#ChO+RO!bO'#CiO+aO#tO'#CiO+oO?MpO'#D^O.QQ^O'#DdO.bQ^O'#DoO%[Q^O'#DyO0fQ^O'#EROOQ07b'#EZ'#EZO1PQWO'#EWOOQO'#El'#ElOOQO'#Ie'#IeO1XQWO'#GmO1dQWO'#EkO1iQWO'#EkO3kQ08SO'#JiO6[Q08SO'#JjO6xQWO'#FZO6}Q&jO'#FqOOQ07b'#Fc'#FcO7YO,YO'#FcO7hQ7[O'#FxO9UQWO'#FwOOQ07b'#Jj'#JjOOQ07`'#Ji'#JiO9ZQWO'#GqOOQU'#KV'#KVO9fQWO'#IRO9kQ07hO'#ISOOQU'#JW'#JWOOQU'#IW'#IWQ`Q^OOO`Q^OOO%[Q^O'#DqO9sQ^O'#D}O9zQ^O'#EPO9aQWO'#GmO:RQ7[O'#CnO:aQWO'#EjO:lQWO'#EuO:qQ7[O'#FbO;`QWO'#GmOOQO'#KW'#KWO;eQWO'#KWO;sQWO'#GuO;sQWO'#GvO;sQWO'#GxO9aQWO'#G{ORQWO'#CdO>cQWO'#H[O>kQWO'#HbO>kQWO'#HdO`Q^O'#HfO>kQWO'#HhO>kQWO'#HkO>pQWO'#HqO>uQ07iO'#HwO%[Q^O'#HyO?QQ07iO'#H{O?]Q07iO'#H}O9kQ07hO'#IPO?hQ08SO'#ChO@jQ`O'#DiQOQWOOO%[Q^O'#EPOAQQWO'#ESO:RQ7[O'#EjOA]QWO'#EjOAhQpO'#FbOOQU'#Cf'#CfOOQ07`'#Dn'#DnOOQ07`'#Jm'#JmO%[Q^O'#JmOOQO'#Jq'#JqOOQO'#Ib'#IbOBhQ`O'#EcOOQ07`'#Eb'#EbOOQ07`'#Jt'#JtOCdQ07pO'#EcOCnQ`O'#EVOOQO'#Jp'#JpODSQ`O'#JqOEaQ`O'#EVOCnQ`O'#EcPEnO!0LbO'#CaPOOO)CDu)CDuOOOO'#IX'#IXOEyO!bO,59TOOQ07b,59T,59TOOOO'#IY'#IYOFXO#tO,59TO%[Q^O'#D`OOOO'#I['#I[OFgO?MpO,59xOOQ07b,59x,59xOFuQ^O'#I]OGYQWO'#JkOI[QrO'#JkO+}Q^O'#JkOIcQWO,5:OOIyQWO'#ElOJWQWO'#JzOJcQWO'#JyOJcQWO'#JyOJkQWO,5;YOJpQWO'#JxOOQ07f,5:Z,5:ZOJwQ^O,5:ZOLxQ08SO,5:eOMiQWO,5:mONSQ07hO'#JwONZQWO'#JvO9ZQWO'#JvONoQWO'#JvONwQWO,5;XON|QWO'#JvO!#UQrO'#JjOOQ07b'#Ch'#ChO%[Q^O'#ERO!#tQpO,5:rOOQO'#Jr'#JrOOQO-EmOOQU'#J`'#J`OOQU,5>n,5>nOOQU-E_Q08SO,5:iO%[Q^O,5:iO!@xQ08SO,5:kOOQO,5@r,5@rO!AiQ7[O,5=XO!AwQ07hO'#JaO9UQWO'#JaO!BYQ07hO,59YO!BeQ`O,59YO!BmQ7[O,59YO:RQ7[O,59YO!BxQWO,5;VO!CQQWO'#HZO!CfQWO'#K[O%[Q^O,5;zO!9cQ`O,5;|O!CnQWO,5=tO!CsQWO,5=tO!CxQWO,5=tO9kQ07hO,5=tO;sQWO,5=dOOQO'#Cu'#CuO!DWQ`O,5=aO!D`Q7[O,5=bO!DkQWO,5=dO!DpQpO,5=gO!DxQWO'#KWO>pQWO'#HQO9aQWO'#HSO!D}QWO'#HSO:RQ7[O'#HUO!ESQWO'#HUOOQU,5=j,5=jO!EXQWO'#HVO!EjQWO'#CnO!EoQWO,59OO!EyQWO,59OO!HOQ^O,59OOOQU,59O,59OO!H`Q07hO,59OO%[Q^O,59OO!JkQ^O'#H^OOQU'#H_'#H_OOQU'#H`'#H`O`Q^O,5=vO!KRQWO,5=vO`Q^O,5=|O`Q^O,5>OO!KWQWO,5>QO`Q^O,5>SO!K]QWO,5>VO!KbQ^O,5>]OOQU,5>c,5>cO%[Q^O,5>cO9kQ07hO,5>eOOQU,5>g,5>gO# lQWO,5>gOOQU,5>i,5>iO# lQWO,5>iOOQU,5>k,5>kO#!YQ`O'#D[O%[Q^O'#JmO#!dQ`O'#JmO##RQ`O'#DjO##dQ`O'#DjO#%uQ^O'#DjO#%|QWO'#JlO#&UQWO,5:TO#&ZQWO'#EpO#&iQWO'#J{O#&qQWO,5;ZO#&vQ`O'#DjO#'TQ`O'#EUOOQ07b,5:n,5:nO%[Q^O,5:nO#'[QWO,5:nO>pQWO,5;UO!BeQ`O,5;UO!BmQ7[O,5;UO:RQ7[O,5;UO#'dQWO,5@XO#'iQ$ISO,5:rOOQO-E<`-E<`O#(oQ07pO,5:}OCnQ`O,5:qO#(yQ`O,5:qOCnQ`O,5:}O!BYQ07hO,5:qOOQ07`'#Ef'#EfOOQO,5:},5:}O%[Q^O,5:}O#)WQ07hO,5:}O#)cQ07hO,5:}O!BeQ`O,5:qOOQO,5;T,5;TO#)qQ07hO,5:}POOO'#IV'#IVP#*VO!0LbO,58{POOO,58{,58{OOOO-EwO+}Q^O,5>wOOQO,5>},5>}O#*qQ^O'#I]OOQO-EkQWO1G3lO$5qQ^O1G3nO$9uQ^O'#HmOOQU1G3q1G3qO$:SQWO'#HsO>pQWO'#HuOOQU1G3w1G3wO$:[Q^O1G3wO9kQ07hO1G3}OOQU1G4P1G4POOQ07`'#GY'#GYO9kQ07hO1G4RO9kQ07hO1G4TO$>cQWO,5@XO!*fQ^O,5;[O9ZQWO,5;[O>pQWO,5:UO!*fQ^O,5:UO!BeQ`O,5:UO$>hQ(CYO,5:UOOQO,5;[,5;[O$>rQ`O'#I^O$?YQWO,5@WOOQ07b1G/o1G/oO$?bQ`O'#IdO$?lQWO,5@gOOQ07`1G0u1G0uO##dQ`O,5:UOOQO'#Ia'#IaO$?tQ`O,5:pOOQ07f,5:p,5:pO#'_QWO1G0YOOQ07b1G0Y1G0YO%[Q^O1G0YOOQ07b1G0p1G0pO>pQWO1G0pO!BeQ`O1G0pO!BmQ7[O1G0pOOQ07`1G5s1G5sO!BYQ07hO1G0]OOQO1G0i1G0iO%[Q^O1G0iO$?{Q07hO1G0iO$@WQ07hO1G0iO!BeQ`O1G0]OCnQ`O1G0]O$@fQ07hO1G0iOOQO1G0]1G0]O$@zQ08SO1G0iPOOO-EwO$AhQWO1G5qO$ApQWO1G6PO$AxQrO1G6QO9ZQWO,5>}O$BSQ08SO1G5}O%[Q^O1G5}O$BdQ07hO1G5}O$BuQWO1G5|O$BuQWO1G5|O9ZQWO1G5|O$B}QWO,5?QO9ZQWO,5?QOOQO,5?Q,5?QO$CcQWO,5?QO$*hQWO,5?QOOQO-EXOOQU,5>X,5>XO%[Q^O'#HnO%;mQWO'#HpOOQU,5>_,5>_O9ZQWO,5>_OOQU,5>a,5>aOOQU7+)c7+)cOOQU7+)i7+)iOOQU7+)m7+)mOOQU7+)o7+)oO%;rQ`O1G5sO%pQWO1G/pO!*fQ^O'#DjOOQO,5>x,5>xOOQO-E<[-E<[OOQO,5?O,5?OOOQO-EpQWO7+&[O!BeQ`O7+&[OOQO7+%w7+%wO$@zQ08SO7+&TOOQO7+&T7+&TO%[Q^O7+&TO%YQWO<bQWO<mQ08SO,5?YO%@xQ08SO,5?[O%CTQ08SO1G2ZO%EfQ08SO1G2mO%GqQ08SO1G2oO%I|Q7[O,5>yOOQO-E<]-E<]O%JWQrO,5>zO%[Q^O,5>zOOQO-E<^-E<^O%JbQWO1G5uOOQ07b<YOOQU,5>[,5>[O&pQWO7+%[OOQ07b<pQWO<pQWO7+)eO'*rQWO<}AN>}O%[Q^OAN?ZOOQO<T#>Z#>a#>o#?U#@s#AR#AY#Bn#B|#Dh#Dv#D|#ES#EY#Ed#Ej#Ep#Ez#F^#FdPPPPPPPPPP#FjPPPPPPP#G_#Jf#Ku#K|#LUPPPP$#[$&S$,l$,o$,r$-_$-b$-e$-l$-tP$-zP$.h$.l$/d$0r$0w$1_PP$1d$1j$1nP$1q$1u$1y$2o$3W$3o$3s$3v$3y$4P$4S$4W$4[R!|RoqOXst!Z#d%k&n&p&q&s,k,p1}2QY!vQ'[-]1b5dQ%qvQ%yyQ&Q|Q&f!VS'S!e-TQ'b!iS'h!r!yU*f$}*W*kQ+i%zQ+v&SQ,[&`Q-Z'ZQ-e'cQ-m'iQ0S*mQ1l,]R;`:m%QdOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#y#|$P$Q$R$S$T$U$V$W$X$Y$Z$b$f%k%q&O&g&j&n&p&q&s&w'P'^'n(O(Q(W(_(s(w({)z+R+V,h,k,p-a-i-w-}.o.v/g0b0g0w1e1u1v1x1z1}2Q2S2s2y3a5a5k5{5|6P6d7}8S8c8mS#q]:j!r)]$]$n'T)o,|-P/O2c3v5_6Z9^9o:i:l:m:p:q:r:s:t:u:v:w:x:y:z:{:|:};R;`;b;c;e;m;n;w;x < TypeParamList TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . ?. PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewExpression new TypeArgList CompareOp < ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies in const CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast ArrowFunction TypeParamList SequenceExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:372,context:l0,nodeProps:[["isolate",-8,4,5,13,33,35,48,50,52,""],["group",-26,8,16,18,65,201,205,209,210,212,215,218,228,230,236,238,240,242,245,251,257,259,261,263,265,267,268,"Statement",-32,12,13,28,31,32,38,48,51,52,54,59,67,75,79,81,83,84,106,107,116,117,134,137,139,140,141,142,144,145,164,165,167,"Expression",-23,27,29,33,37,39,41,168,170,172,173,175,176,177,179,180,181,183,184,185,195,197,199,200,"Type",-3,87,99,105,"ClassItem"],["openedBy",22,"<",34,"InterpolationStart",53,"[",57,"{",72,"(",157,"JSXStartCloseTag"],["closedBy",23,">",36,"InterpolationEnd",47,"]",58,"}",73,")",162,"JSXEndTag"]],propSources:[d0],skippedNodes:[0,4,5,271],repeatNodeCount:37,tokenData:"$HR(CSR!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$.S!c!}Er!}#O$/^#O#P$0h#P#Q$6P#Q#R$7Z#R#SEr#S#T$8h#T#o$9r#o#p$>S#p#q$>x#q#r$@Y#r#s$Af#s$f%Z$f$g+g$g#BYEr#BY#BZ$Bp#BZ$ISEr$IS$I_$Bp$I_$I|Er$I|$I}$E{$I}$JO$E{$JO$JTEr$JT$JU$Bp$JU$KVEr$KV$KW$Bp$KW&FUEr&FU&FV$Bp&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$Bp?HUOEr(n%d_$f&j(Op(R!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z&j&hT$f&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c&j&zP;=`<%l&c'|'U]$f&j(R!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!b(SU(R!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!b(iP;=`<%l'}'|(oP;=`<%l&}'[(y]$f&j(OpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(rp)wU(OpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)rp*^P;=`<%l)r'[*dP;=`<%l(r#S*nX(Op(R!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g#S+^P;=`<%l*g(n+dP;=`<%l%Z(CS+rq$f&j(Op(R!b't(;dOX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p$f%Z$f$g+g$g#BY%Z#BY#BZ+g#BZ$IS%Z$IS$I_+g$I_$JT%Z$JT$JU+g$JU$KV%Z$KV$KW+g$KW&FU%Z&FU&FV+g&FV;'S%Z;'S;=`+a<%l?HT%Z?HT?HU+g?HUO%Z(CS.ST(P#S$f&j'u(;dO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c(CS.n_$f&j(Op(R!b'u(;dOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z%#`/x`$f&j!o$Ip(Op(R!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z%#S1V`#t$Id$f&j(Op(R!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`2X!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z%#S2d_#t$Id$f&j(Op(R!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z$/|3l_'}$(n$f&j(R!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k(^4r_$f&j(R!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k&z5vX$f&jOr5qrs6cs!^5q!^!_6y!_#o5q#o#p6y#p;'S5q;'S;=`7h<%lO5q&z6jT$a`$f&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c`6|TOr6yrs7]s;'S6y;'S;=`7b<%lO6y`7bO$a``7eP;=`<%l6y&z7kP;=`<%l5q(^7w]$a`$f&j(R!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!r8uZ(R!bOY8pYZ6yZr8prs9hsw8pwx6yx#O8p#O#P6y#P;'S8p;'S;=`:R<%lO8p!r9oU$a`(R!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!r:UP;=`<%l8p(^:[P;=`<%l4k#%|:hh$f&j(Op(R!bOY%ZYZ&cZq%Zqr`#P#o`x!^=^!^!_?q!_#O=^#O#P>`#P#o=^#o#p?q#p;'S=^;'S;=`@h<%lO=^&n>gXVS$f&jOY>`YZ&cZ!^>`!^!_?S!_#o>`#o#p?S#p;'S>`;'S;=`?k<%lO>`S?XSVSOY?SZ;'S?S;'S;=`?e<%lO?SS?hP;=`<%l?S&n?nP;=`<%l>`!f?xWVS(R!bOY?qZw?qwx?Sx#O?q#O#P?S#P;'S?q;'S;=`@b<%lO?q!f@eP;=`<%l?q(Q@kP;=`<%l=^'`@w]VS$f&j(OpOY@nYZ&cZr@nrs>`s!^@n!^!_Ap!_#O@n#O#P>`#P#o@n#o#pAp#p;'S@n;'S;=`Bg<%lO@ntAwWVS(OpOYApZrAprs?Ss#OAp#O#P?S#P;'SAp;'S;=`Ba<%lOAptBdP;=`<%lAp'`BjP;=`<%l@n#WBvYVS(Op(R!bOYBmZrBmrs?qswBmwxApx#OBm#O#P?S#P;'SBm;'S;=`Cf<%lOBm#WCiP;=`<%lBm(rCoP;=`<%lQ^$f&j!USOY!=yYZ&cZ!P!=y!P!Q!>|!Q!^!=y!^!_!@c!_!}!=y!}#O!CW#O#P!Dy#P#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y&n!?Td$f&j!USO!^&c!_#W&c#W#X!>|#X#Z&c#Z#[!>|#[#]&c#]#^!>|#^#a&c#a#b!>|#b#g&c#g#h!>|#h#i&c#i#j!>|#j#k!>|#k#m&c#m#n!>|#n#o&c#p;'S&c;'S;=`&w<%lO&cS!@hX!USOY!@cZ!P!@c!P!Q!AT!Q!}!@c!}#O!Ar#O#P!Bq#P;'S!@c;'S;=`!CQ<%lO!@cS!AYW!US#W#X!AT#Z#[!AT#]#^!AT#a#b!AT#g#h!AT#i#j!AT#j#k!AT#m#n!ATS!AuVOY!ArZ#O!Ar#O#P!B[#P#Q!@c#Q;'S!Ar;'S;=`!Bk<%lO!ArS!B_SOY!ArZ;'S!Ar;'S;=`!Bk<%lO!ArS!BnP;=`<%l!ArS!BtSOY!@cZ;'S!@c;'S;=`!CQ<%lO!@cS!CTP;=`<%l!@c&n!C][$f&jOY!CWYZ&cZ!^!CW!^!_!Ar!_#O!CW#O#P!DR#P#Q!=y#Q#o!CW#o#p!Ar#p;'S!CW;'S;=`!Ds<%lO!CW&n!DWX$f&jOY!CWYZ&cZ!^!CW!^!_!Ar!_#o!CW#o#p!Ar#p;'S!CW;'S;=`!Ds<%lO!CW&n!DvP;=`<%l!CW&n!EOX$f&jOY!=yYZ&cZ!^!=y!^!_!@c!_#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y&n!EnP;=`<%l!=y(Q!Ezl$f&j(R!b!USOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#W&}#W#X!Eq#X#Z&}#Z#[!Eq#[#]&}#]#^!Eq#^#a&}#a#b!Eq#b#g&}#g#h!Eq#h#i&}#i#j!Eq#j#k!Eq#k#m&}#m#n!Eq#n#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!f!GyZ(R!b!USOY!GrZw!Grwx!@cx!P!Gr!P!Q!Hl!Q!}!Gr!}#O!JU#O#P!Bq#P;'S!Gr;'S;=`!J|<%lO!Gr!f!Hse(R!b!USOY'}Zw'}x#O'}#P#W'}#W#X!Hl#X#Z'}#Z#[!Hl#[#]'}#]#^!Hl#^#a'}#a#b!Hl#b#g'}#g#h!Hl#h#i'}#i#j!Hl#j#k!Hl#k#m'}#m#n!Hl#n;'S'};'S;=`(f<%lO'}!f!JZX(R!bOY!JUZw!JUwx!Arx#O!JU#O#P!B[#P#Q!Gr#Q;'S!JU;'S;=`!Jv<%lO!JU!f!JyP;=`<%l!JU!f!KPP;=`<%l!Gr(Q!KZ^$f&j(R!bOY!KSYZ&cZw!KSwx!CWx!^!KS!^!_!JU!_#O!KS#O#P!DR#P#Q!_#c#d#Bq#d#l%Z#l#m#Es#m#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z$/l#_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z$/l#>j_$f&j(Op(R!bo$'|OY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z$/l#?rd$f&j(Op(R!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z$/l#A]f$f&j(Op(R!bo$'|OY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z$/l#Bzc$f&j(Op(R!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z$/l#Dbe$f&j(Op(R!bo$'|OY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z$/l#E|g$f&j(Op(R!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z$/l#Gpi$f&j(Op(R!bo$'|OY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z%Gh#Il_!d$b$f&j#|%PP;=`<%l$9r!5p$>]X![!3l(Op(R!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g&CO$?Ta(p&;`$f&j(Op(R!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p#q$,u#q;'S%Z;'S;=`+a<%lO%Z%#`$@g_!Z$I`r`$f&j(Op(R!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(r$Aq_!pS$f&j(Op(R!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(CS$CR|$f&j(Op(R!b't(;d$Y#t'{&;d([!LYOX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$f%Z$f$g+g$g#BYEr#BY#BZ$Bp#BZ$ISEr$IS$I_$Bp$I_$JTEr$JT$JU$Bp$JU$KVEr$KV$KW$Bp$KW&FUEr&FU&FV$Bp&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$Bp?HUOEr(CS$F^k$f&j(Op(R!b'u(;d$Y#t'{&;d([!LYOY%ZYZ&cZr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr",tokenizers:[c0,f0,u0,2,3,4,5,6,7,8,9,10,11,12,13,h0,new ri("$S~RRtu[#O#Pg#S#T#|~_P#o#pb~gOt~~jVO#i!P#i#j!U#j#l!P#l#m!q#m;'S!P;'S;=`#v<%lO!P~!UO!R~~!XS!Q![!e!c!i!e#T#Z!e#o#p#Z~!hR!Q![!q!c!i!q#T#Z!q~!tR!Q![!}!c!i!}#T#Z!}~#QR!Q![!P!c!i!P#T#Z!P~#^R!Q![#g!c!i#g#T#Z#g~#jS!Q![#g!c!i#g#T#Z#g#q#r!P~#yP;=`<%l!P~$RO(Z~~",141,332),new ri("j~RQYZXz{^~^O'x~~aP!P!Qd~iO'y~~",25,315)],topRules:{Script:[0,6],SingleExpression:[1,269],SingleClassItem:[2,270]},dialects:{jsx:0,ts:14826},dynamicPrecedences:{"69":1,"79":1,"81":1,"165":1,"193":1},specialized:[{term:319,get:n=>p0[n]||-1},{term:334,get:n=>O0[n]||-1},{term:70,get:n=>m0[n]||-1}],tokenPrec:14850});var du=[gt("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),gt("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),gt("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),gt("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),gt("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),gt(`try { \${} } catch (\${error}) { \${} }`,{label:"try",detail:"/ catch block",type:"keyword"}),gt("if (${}) {\n ${}\n}",{label:"if",detail:"block",type:"keyword"}),gt(`if (\${}) { \${} } else { \${} }`,{label:"if",detail:"/ else block",type:"keyword"}),gt(`class \${name} { constructor(\${params}) { \${} } }`,{label:"class",detail:"definition",type:"keyword"}),gt('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),gt('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],g0=du.concat([gt("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),gt("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),gt("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),pu=new rn,Ou=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function Qn(n){return(t,e)=>{let i=t.node.getChild("VariableDefinition");return i&&e(i,n),!0}}var b0=["FunctionDeclaration"],S0={FunctionDeclaration:Qn("function"),ClassDeclaration:Qn("class"),ClassExpression:()=>!0,EnumDeclaration:Qn("constant"),TypeAliasDeclaration:Qn("type"),NamespaceDeclaration:Qn("namespace"),VariableDefinition(n,t){n.matchContext(b0)||t(n,"variable")},TypeDefinition(n,t){t(n,"type")},__proto__:null};function mu(n,t){let e=pu.get(t);if(e)return e;let i=[],s=!0;function r(o,a){let l=n.sliceString(o.from,o.to);i.push({label:l,type:a})}return t.cursor(N.IncludeAnonymous).iterate(o=>{if(s)s=!1;else if(o.name){let a=S0[o.name];if(a&&a(o,r)||Ou.has(o.name))return!1}else if(o.to-o.from>8192){for(let a of mu(n,o.node))i.push(a);return!1}}),pu.set(t,i),i}var gu=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,bu=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName",".","?."];function w0(n){let t=F(n.state).resolveInner(n.pos,-1);if(bu.indexOf(t.name)>-1)return null;let e=t.name=="VariableName"||t.to-t.from<20&&gu.test(n.state.sliceDoc(t.from,t.to));if(!e&&!n.explicit)return null;let i=[];for(let s=t;s;s=s.parent)Ou.has(s.name)&&(i=i.concat(mu(n.state.doc,s)));return{options:i,from:e?t.from:n.pos,validFor:gu}}var ne=de.define({name:"javascript",parser:uu.configure({props:[$e.add({IfStatement:Ti({except:/^\s*({|else\b)/}),TryStatement:Ti({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:mc,SwitchBody:n=>{let t=n.textAfter,e=/^\s*\}/.test(t),i=/^\s*(case|default)\b/.test(t);return n.baseIndent+(e?0:i?1:2)*n.unit},Block:pc({closing:"}"}),ArrowFunction:n=>n.baseIndent+n.unit,"TemplateString BlockComment":()=>null,"Statement Property":Ti({except:/^{/}),JSXElement(n){let t=/^\s*<\//.test(n.textAfter);return n.lineIndent(n.node.from)+(t?0:n.unit)},JSXEscape(n){let t=/\s*\}/.test(n.textAfter);return n.lineIndent(n.node.from)+(t?0:n.unit)},"JSXOpenTag JSXSelfClosingTag"(n){return n.column(n.node.from)+n.unit}}),Te.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":ws,BlockComment(n){return{from:n.from+2,to:n.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),Su={test:n=>/^JSX/.test(n.name),facet:hn({commentTokens:{block:{open:"{/*",close:"*/}"}}})},Io=ne.configure({dialect:"ts"},"typescript"),Do=ne.configure({dialect:"jsx",props:[bs.add(n=>n.isTop?[Su]:void 0)]}),Vo=ne.configure({dialect:"jsx ts",props:[bs.add(n=>n.isTop?[Su]:void 0)]},"typescript"),wu=n=>({label:n,type:"keyword"}),yu="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(wu),y0=yu.concat(["declare","implements","private","protected","public"].map(wu));function ku(n={}){let t=n.jsx?n.typescript?Vo:Do:n.typescript?Io:ne,e=n.typescript?g0.concat(y0):du.concat(yu);return new pe(t,[ne.data.of({autocomplete:uf(bu,ff(e))}),ne.data.of({autocomplete:w0}),n.jsx?x0:[]])}function k0(n){for(;;){if(n.name=="JSXOpenTag"||n.name=="JSXSelfClosingTag"||n.name=="JSXFragmentTag")return n;if(n.name=="JSXEscape"||!n.parent)return null;n=n.parent}}function vu(n,t,e=n.length){for(let i=t==null?void 0:t.firstChild;i;i=i.nextSibling)if(i.name=="JSXIdentifier"||i.name=="JSXBuiltin"||i.name=="JSXNamespacedName"||i.name=="JSXMemberExpression")return n.sliceString(i.from,Math.min(i.to,e));return""}var v0=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),x0=Z.inputHandler.of((n,t,e,i,s)=>{if((v0?n.composing:n.compositionStarted)||n.state.readOnly||t!=e||i!=">"&&i!="/"||!ne.isActiveAt(n.state,t,-1))return!1;let r=s(),{state:o}=r,a=o.changeByRange(l=>{var h;let{head:c}=l,f=F(o).resolveInner(c-1,-1),u;if(f.name=="JSXStartTag"&&(f=f.parent),!(o.doc.sliceString(c-1,c)!=i||f.name=="JSXAttributeValue"&&f.to>c)){if(i==">"&&f.name=="JSXFragmentTag")return{range:l,changes:{from:c,insert:""}};if(i=="/"&&f.name=="JSXStartCloseTag"){let d=f.parent,p=d.parent;if(p&&d.from==c-2&&((u=vu(o.doc,p.firstChild,c))||((h=p.firstChild)===null||h===void 0?void 0:h.name)=="JSXFragmentTag")){let m=`${u}>`;return{range:S.cursor(c+m.length,-1),changes:{from:c,insert:m}}}}else if(i==">"){let d=k0(f);if(d&&d.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(c,c+2))&&(u=vu(o.doc,d,c)))return{range:l,changes:{from:c,insert:``}}}}return{range:l}});return a.changes.empty?!1:(n.dispatch([r,o.update(a,{userEvent:"input.complete",scrollIntoView:!0})]),!0)});var Pn=["_blank","_self","_top","_parent"],Bo=["ascii","utf-8","utf-16","latin1","latin1"],Lo=["get","post","put","delete"],No=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],qt=["true","false"],C={},Q0={a:{attrs:{href:null,ping:null,type:null,media:null,target:Pn,hreflang:null}},abbr:C,address:C,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:C,aside:C,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:C,base:{attrs:{href:null,target:Pn}},bdi:C,bdo:C,blockquote:{attrs:{cite:null}},body:C,br:C,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:No,formmethod:Lo,formnovalidate:["novalidate"],formtarget:Pn,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:C,center:C,cite:C,code:C,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:C,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:C,div:C,dl:C,dt:C,em:C,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:C,figure:C,footer:C,form:{attrs:{action:null,name:null,"accept-charset":Bo,autocomplete:["on","off"],enctype:No,method:Lo,novalidate:["novalidate"],target:Pn}},h1:C,h2:C,h3:C,h4:C,h5:C,h6:C,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:C,hgroup:C,hr:C,html:{attrs:{manifest:null}},i:C,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:No,formmethod:Lo,formnovalidate:["novalidate"],formtarget:Pn,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:C,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:C,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:C,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:Bo,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:C,noscript:C,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:C,param:{attrs:{name:null,value:null}},pre:C,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:C,rt:C,ruby:C,samp:C,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:Bo}},section:C,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:C,source:{attrs:{src:null,type:null,media:null}},span:C,strong:C,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:C,summary:C,sup:C,table:C,tbody:C,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:C,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:C,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:C,time:{attrs:{datetime:null}},title:C,tr:C,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:C,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:C},xu={accesskey:null,class:null,contenteditable:qt,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:qt,autocorrect:qt,autocapitalize:qt,style:null,tabindex:null,title:null,translate:["yes","no"],rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":qt,"aria-autocomplete":["inline","list","both","none"],"aria-busy":qt,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":qt,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":qt,"aria-hidden":qt,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":qt,"aria-multiselectable":qt,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":qt,"aria-relevant":null,"aria-required":qt,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},Qu="beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(n=>"on"+n);for(let n of Qu)xu[n]=null;var Zi=class{constructor(t,e){this.tags=Object.assign(Object.assign({},Q0),t),this.globalAttrs=Object.assign(Object.assign({},xu),e),this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}};Zi.default=new Zi;function Ai(n,t,e=n.length){if(!t)return"";let i=t.firstChild,s=i&&i.getChild("TagName");return s?n.sliceString(s.from,Math.min(s.to,e)):""}function Ei(n,t=!1){for(;n;n=n.parent)if(n.name=="Element")if(t)t=!1;else return n;return null}function Pu(n,t,e){let i=e.tags[Ai(n,Ei(t))];return(i==null?void 0:i.children)||e.allTags}function _o(n,t){let e=[];for(let i=Ei(t);i&&!i.type.isTop;i=Ei(i.parent)){let s=Ai(n,i);if(s&&i.lastChild.name=="CloseTag")break;s&&e.indexOf(s)<0&&(t.name=="EndTag"||t.from>=i.firstChild.to)&&e.push(s)}return e}var $u=/^[:\-\.\w\u00b7-\uffff]*$/;function Tu(n,t,e,i,s){let r=/\s*>/.test(n.sliceDoc(s,s+5))?"":">",o=Ei(e,!0);return{from:i,to:s,options:Pu(n.doc,o,t).map(a=>({label:a,type:"type"})).concat(_o(n.doc,e).map((a,l)=>({label:"/"+a,apply:"/"+a+r,type:"type",boost:99-l}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function Cu(n,t,e,i){let s=/\s*>/.test(n.sliceDoc(i,i+5))?"":">";return{from:e,to:i,options:_o(n.doc,t).map((r,o)=>({label:r,apply:r+s,type:"type",boost:99-o})),validFor:$u}}function P0(n,t,e,i){let s=[],r=0;for(let o of Pu(n.doc,e,t))s.push({label:"<"+o,type:"type"});for(let o of _o(n.doc,e))s.push({label:"",type:"type",boost:99-r++});return{from:i,to:i,options:s,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function $0(n,t,e,i,s){let r=Ei(e),o=r?t.tags[Ai(n.doc,r)]:null,a=o&&o.attrs?Object.keys(o.attrs):[],l=o&&o.globalAttrs===!1?a:a.length?a.concat(t.globalAttrNames):t.globalAttrNames;return{from:i,to:s,options:l.map(h=>({label:h,type:"property"})),validFor:$u}}function T0(n,t,e,i,s){var r;let o=(r=e.parent)===null||r===void 0?void 0:r.getChild("AttributeName"),a=[],l;if(o){let h=n.sliceDoc(o.from,o.to),c=t.globalAttrs[h];if(!c){let f=Ei(e),u=f?t.tags[Ai(n.doc,f)]:null;c=(u==null?void 0:u.attrs)&&u.attrs[h]}if(c){let f=n.sliceDoc(i,s).toLowerCase(),u='"',d='"';/^['"]/.test(f)?(l=f[0]=='"'?/^[^"]*$/:/^[^']*$/,u="",d=n.sliceDoc(s,s+1)==f[0]?"":f[0],f=f.slice(1),i++):l=/^[^\s<>='"]*$/;for(let p of c)a.push({label:p,apply:u+p+d,type:"constant"})}}return{from:i,to:s,options:a,validFor:l}}function Zu(n,t){let{state:e,pos:i}=t,s=F(e).resolveInner(i,-1),r=s.resolve(i);for(let o=i,a;r==s&&(a=s.childBefore(o));){let l=a.lastChild;if(!l||!l.type.isError||l.fromZu(i,s)}var Z0=ne.parser.configure({top:"SingleExpression"}),Eu=[{tag:"script",attrs:n=>n.type=="text/typescript"||n.lang=="ts",parser:Io.parser},{tag:"script",attrs:n=>n.type=="text/babel"||n.type=="text/jsx",parser:Do.parser},{tag:"script",attrs:n=>n.type=="text/typescript-jsx",parser:Vo.parser},{tag:"script",attrs(n){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(n.type)},parser:Z0},{tag:"script",attrs(n){return!n.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(n.type)},parser:ne.parser},{tag:"style",attrs(n){return(!n.lang||n.lang=="css")&&(!n.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(n.type))},parser:xn.parser}],Xu=[{name:"style",parser:xn.parser.configure({top:"Styles"})}].concat(Qu.map(n=>({name:n,parser:ne.parser}))),Ru=de.define({name:"html",parser:Hf.configure({props:[$e.add({Element(n){let t=/^(\s*)(<\/)?/.exec(n.textAfter);return n.node.to<=n.pos+t[0].length?n.continue():n.lineIndent(n.node.from)+(t[2]?0:n.unit)},"OpenTag CloseTag SelfClosingTag"(n){return n.column(n.node.from)+n.unit},Document(n){if(n.pos+/\s*/.exec(n.textAfter)[0].lengthn.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:""}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-._"}}),Rs=Ru.configure({wrap:Xo(Eu,Xu)});function Ws(n={}){let t="",e;n.matchClosingTags===!1&&(t="noMatch"),n.selfClosingTags===!0&&(t=(t?t+" ":"")+"selfClosing"),(n.nestedLanguages&&n.nestedLanguages.length||n.nestedAttributes&&n.nestedAttributes.length)&&(e=Xo((n.nestedLanguages||[]).concat(Eu),(n.nestedAttributes||[]).concat(Xu)));let i=e?Ru.configure({wrap:e,dialect:t}):t?Rs.configure({dialect:t}):Rs;return new pe(i,[Rs.data.of({autocomplete:C0(n)}),n.autoCloseTags!==!1?A0:[],ku().support,hu().support])}var Wu=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")),A0=Z.inputHandler.of((n,t,e,i,s)=>{if(n.composing||n.state.readOnly||t!=e||i!=">"&&i!="/"||!Rs.isActiveAt(n.state,t,-1))return!1;let r=s(),{state:o}=r,a=o.changeByRange(l=>{var h,c,f;let u=o.doc.sliceString(l.from-1,l.to)==i,{head:d}=l,p=F(o).resolveInner(d-1,-1),m;if((p.name=="TagName"||p.name=="StartTag")&&(p=p.parent),u&&i==">"&&p.name=="OpenTag"){if(((c=(h=p.parent)===null||h===void 0?void 0:h.lastChild)===null||c===void 0?void 0:c.name)!="CloseTag"&&(m=Ai(o.doc,p.parent,d))&&!Wu.has(m)){let g=d+(o.doc.sliceString(d,d+1)===">"?1:0),b=``;return{range:l,changes:{from:d,to:g,insert:b}}}}else if(u&&i=="/"&&p.name=="IncompleteCloseTag"){let g=p.parent;if(p.from==d-2&&((f=g.lastChild)===null||f===void 0?void 0:f.name)!="CloseTag"&&(m=Ai(o.doc,g,d))&&!Wu.has(m)){let b=d+(o.doc.sliceString(d,d+1)===">"?1:0),w=`${m}>`;return{range:S.cursor(d+w.length,-1),changes:{from:d,to:b,insert:w}}}}return{range:l}});return a.changes.empty?!1:(n.dispatch([r,o.update(a,{userEvent:"input.complete",scrollIntoView:!0})]),!0)});var $n=class{static create(t,e,i,s,r){let o=s+(s<<8)+t+(e<<4)|0;return new $n(t,e,i,o,r,[],[])}constructor(t,e,i,s,r,o,a){this.type=t,this.value=e,this.from=i,this.hash=s,this.end=r,this.children=o,this.positions=a,this.hashProp=[[E.contextHash,s]]}addChild(t,e){t.prop(E.contextHash)!=this.hash&&(t=new I(t.type,t.children,t.positions,t.length,this.hashProp)),this.children.push(t),this.positions.push(e)}toTree(t,e=this.end){let i=this.children.length-1;return i>=0&&(e=Math.max(e,this.positions[i]+this.children[i].length+this.from)),new I(t.types[this.type],this.children,this.positions,e-this.from).balance({makeTree:(s,r,o)=>new I(it.none,s,r,o,this.hashProp)})}},y;(function(n){n[n.Document=1]="Document",n[n.CodeBlock=2]="CodeBlock",n[n.FencedCode=3]="FencedCode",n[n.Blockquote=4]="Blockquote",n[n.HorizontalRule=5]="HorizontalRule",n[n.BulletList=6]="BulletList",n[n.OrderedList=7]="OrderedList",n[n.ListItem=8]="ListItem",n[n.ATXHeading1=9]="ATXHeading1",n[n.ATXHeading2=10]="ATXHeading2",n[n.ATXHeading3=11]="ATXHeading3",n[n.ATXHeading4=12]="ATXHeading4",n[n.ATXHeading5=13]="ATXHeading5",n[n.ATXHeading6=14]="ATXHeading6",n[n.SetextHeading1=15]="SetextHeading1",n[n.SetextHeading2=16]="SetextHeading2",n[n.HTMLBlock=17]="HTMLBlock",n[n.LinkReference=18]="LinkReference",n[n.Paragraph=19]="Paragraph",n[n.CommentBlock=20]="CommentBlock",n[n.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",n[n.Escape=22]="Escape",n[n.Entity=23]="Entity",n[n.HardBreak=24]="HardBreak",n[n.Emphasis=25]="Emphasis",n[n.StrongEmphasis=26]="StrongEmphasis",n[n.Link=27]="Link",n[n.Image=28]="Image",n[n.InlineCode=29]="InlineCode",n[n.HTMLTag=30]="HTMLTag",n[n.Comment=31]="Comment",n[n.ProcessingInstruction=32]="ProcessingInstruction",n[n.Autolink=33]="Autolink",n[n.HeaderMark=34]="HeaderMark",n[n.QuoteMark=35]="QuoteMark",n[n.ListMark=36]="ListMark",n[n.LinkMark=37]="LinkMark",n[n.EmphasisMark=38]="EmphasisMark",n[n.CodeMark=39]="CodeMark",n[n.CodeText=40]="CodeText",n[n.CodeInfo=41]="CodeInfo",n[n.LinkTitle=42]="LinkTitle",n[n.LinkLabel=43]="LinkLabel",n[n.URL=44]="URL"})(y||(y={}));var qu=class{constructor(t,e){this.start=t,this.content=e,this.marks=[],this.parsers=[]}},Mu=class{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let t=this.skipSpace(this.basePos);this.indent=this.countIndent(t,this.pos,this.indent),this.pos=t,this.next=t==this.text.length?-1:this.text.charCodeAt(t)}skipSpace(t){return Tn(this.text,t)}reset(t){for(this.text=t,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(t){this.basePos=t,this.baseIndent=this.countIndent(t,this.pos,this.indent)}moveBaseColumn(t){this.baseIndent=t,this.basePos=this.findColumn(t)}addMarker(t){this.markers.push(t)}countIndent(t,e=0,i=0){for(let s=e;s=t.stack[e.depth+1].value+e.baseIndent)return!0;if(e.indent>=e.baseIndent+4)return!1;let i=(n.type==y.OrderedList?Go:jo)(e,t,!1);return i>0&&(n.type!=y.BulletList||zo(e,t,!1)<0)&&e.text.charCodeAt(e.pos+i-1)==n.value}var Iu={[y.Blockquote](n,t,e){return e.next!=62?!1:(e.markers.push(D(y.QuoteMark,t.lineStart+e.pos,t.lineStart+e.pos+1)),e.moveBase(e.pos+(jt(e.text.charCodeAt(e.pos+1))?2:1)),n.end=t.lineStart+e.text.length,!0)},[y.ListItem](n,t,e){return e.indent-1?!1:(e.moveBaseColumn(e.baseIndent+n.value),!0)},[y.OrderedList]:Yu,[y.BulletList]:Yu,[y.Document](){return!0}};function jt(n){return n==32||n==9||n==10||n==13}function Tn(n,t=0){for(;te&&jt(n.charCodeAt(t-1));)t--;return t}function Vu(n){if(n.next!=96&&n.next!=126)return-1;let t=n.pos+1;for(;t-1&&n.depth==t.stack.length||i<3?-1:1}function Lu(n,t){for(let e=n.stack.length-1;e>=0;e--)if(n.stack[e].type==t)return!0;return!1}function jo(n,t,e){return(n.next==45||n.next==43||n.next==42)&&(n.pos==n.text.length-1||jt(n.text.charCodeAt(n.pos+1)))&&(!e||Lu(t,y.BulletList)||n.skipSpace(n.pos+2)=48&&s<=57;){i++;if(i==n.text.length)return-1;s=n.text.charCodeAt(i)}return i==n.pos||i>n.pos+9||s!=46&&s!=41||in.pos+1||n.next!=49)?-1:i+1-n.pos}function Nu(n){if(n.next!=35)return-1;let t=n.pos+1;for(;t6?-1:e}function _u(n){if(n.next!=45&&n.next!=61||n.indent>=n.baseIndent+4)return-1;let t=n.pos+1;for(;t/,ju=/\?>/,Ho=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*/i.exec(i);if(r)return n.append(D(y.Comment,e,e+1+r[0].length));let o=/^\?[^]*?\?>/.exec(i);if(o)return n.append(D(y.ProcessingInstruction,e,e+1+o[0].length));let a=/^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(i);return a?n.append(D(y.HTMLTag,e,e+1+a[0].length)):-1},Emphasis(n,t,e){if(t!=95&&t!=42)return-1;let i=e+1;for(;n.char(i)==t;)i++;let s=n.slice(e-1,e),r=n.slice(i,i+1),o=Zn.test(s),a=Zn.test(r),l=/\s|^$/.test(s),h=/\s|^$/.test(r),c=!h&&(!a||l||o),f=!l&&(!o||h||a),u=c&&(t==42||!f||o),d=f&&(t==42||!c||a);return n.append(new Mt(t==95?ed:id,e,i,(u?1:0)|(d?2:0)))},HardBreak(n,t,e){if(t==92&&n.char(e+1)==10)return n.append(D(y.HardBreak,e,e+2));if(t==32){let i=e+1;for(;n.char(i)==32;)i++;if(n.char(i)==10&&i>=e+2)return n.append(D(y.HardBreak,e,i+1))}return-1},Link(n,t,e){return t==91?n.append(new Mt(qi,e,e+1,1)):-1},Image(n,t,e){return t==33&&n.char(e+1)==91?n.append(new Mt(ea,e,e+2,1)):-1},LinkEnd(n,t,e){if(t!=93)return-1;for(let i=n.parts.length-1;i>=0;i--){let s=n.parts[i];if(s instanceof Mt&&(s.type==qi||s.type==ea)){if(!s.side||n.skipSpace(s.to)==e&&!/[(\[]/.test(n.slice(e+1,e+2)))return n.parts[i]=null,-1;let r=n.takeContent(i),o=n.parts[i]=W0(n,r,s.type==qi?y.Link:y.Image,s.from,e+1);if(s.type==qi)for(let a=0;at?D(y.URL,t+e,r+e):r==n.length?null:!1}}function rd(n,t,e){let i=n.charCodeAt(t);if(i!=39&&i!=34&&i!=40)return!1;let s=i==40?41:i;for(let r=t+1,o=!1;r=this.end?-1:this.text.charCodeAt(t-this.offset)}get end(){return this.offset+this.text.length}slice(t,e){return this.text.slice(t-this.offset,e-this.offset)}append(t){return this.parts.push(t),t.to}addDelimiter(t,e,i,s,r){return this.append(new Mt(t,e,i,(s?1:0)|(r?2:0)))}get hasOpenLink(){for(let t=this.parts.length-1;t>=0;t--){let e=this.parts[t];if(e instanceof Mt&&(e.type==qi||e.type==ea))return!0}return!1}addElement(t){return this.append(t)}resolveMarkers(t){for(let i=t;i=t;l--){let m=this.parts[l];if(m instanceof Mt&&m.side&1&&m.type==s.type&&!(r&&(s.side&1||m.side&2)&&(m.to-m.from+o)%3==0&&((m.to-m.from)%3||o%3))){a=m;break}}if(!a)continue;let h=s.type.resolve,c=[],f=a.from,u=s.to;if(r){let m=Math.min(2,a.to-a.from,o);f=a.to-m,u=s.from+m,h=m==1?"Emphasis":"StrongEmphasis"}a.type.mark&&c.push(this.elt(a.type.mark,f,a.to));for(let m=l+1;m=0;e--){let i=this.parts[e];if(i instanceof Mt&&i.type==t)return e}return null}takeContent(t){let e=this.resolveMarkers(t);return this.parts.length=t,e}skipSpace(t){return Tn(this.text,t-this.offset)+this.offset}elt(t,e,i,s){return typeof t=="string"?D(this.parser.getNodeType(t),e,i,s):new ta(t,e)}};function na(n,t){if(!t.length)return n;if(!n.length)return t;let e=n.slice(),i=0;for(let s of t){for(;i(t?t-1:0))return!1;if(this.fragmentEnd<0){let r=this.fragment.to;for(;r>0&&this.input.read(r-1,r)!=` `;)r--;this.fragmentEnd=r?r-1:0}let i=this.cursor;i||(i=this.cursor=this.fragment.tree.cursor(),i.firstChild());let s=t+this.fragment.offset;for(;i.to<=s;)if(!i.parent())return!1;for(;;){if(i.from>=s)return this.fragment.from<=e;if(!i.childAfter(s))return!1}}matches(t){let e=this.cursor.tree;return e&&e.prop(E.contextHash)==t}takeNodes(t){let e=this.cursor,i=this.fragment.offset,s=this.fragmentEnd-(this.fragment.openEnd?1:0),r=t.absoluteLineStart,o=r,a=t.block.children.length,l=o,h=a;for(;;){if(e.to-i>s){if(e.type.isAnonymous&&e.firstChild())continue;break}let c=hd(e.from-i,t.ranges);if(e.to-i<=t.ranges[t.rangeI].to)t.addNode(e.tree,c);else{let f=new I(t.parser.nodeSet.types[y.Paragraph],[],[],0,t.block.hashProp);t.reusePlaceholders.set(f,e.tree),t.addNode(f,c)}if(e.type.is("Block")&&(q0.indexOf(e.type.id)<0?(o=e.to-i,a=t.block.children.length):(o=l,a=h,l=e.to-i,h=t.block.children.length)),!e.nextSibling())break}for(;t.block.children.length>a;)t.block.children.pop(),t.block.positions.pop();return o-r}};function hd(n,t){let e=n;for(let i=1;iqs[n]),Object.keys(qs).map(n=>E0[n]),Object.keys(qs),X0,Iu,Object.keys(ia).map(n=>ia[n]),Object.keys(ia),[]);function Y0(n,t,e){let i=[];for(let s=n.firstChild,r=t;;s=s.nextSibling){let o=s?s.from:e;if(o>r&&i.push({from:r,to:o}),!s)break;r=s.to}return i}function fd(n){let{codeParser:t,htmlParser:e}=n;return{wrap:ps((s,r)=>{let o=s.type.id;if(t&&(o==y.CodeBlock||o==y.FencedCode)){let a="";if(o==y.FencedCode){let h=s.node.getChild(y.CodeInfo);h&&(a=r.read(h.from,h.to))}let l=t(a);if(l)return{parser:l,overlay:h=>h.type.id==y.CodeText}}else if(e&&(o==y.HTMLBlock||o==y.HTMLTag))return{parser:e,overlay:Y0(s.node,s.from,s.to)};return null})}}var I0={resolve:"Strikethrough",mark:"StrikethroughMark"},D0={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":O.strikethrough}},{name:"StrikethroughMark",style:O.processingInstruction}],parseInline:[{name:"Strikethrough",parse(n,t,e){if(t!=126||n.char(e+1)!=126||n.char(e+2)==126)return-1;let i=n.slice(e-1,e),s=n.slice(e+2,e+3),r=/\s|^$/.test(i),o=/\s|^$/.test(s),a=Zn.test(i),l=Zn.test(s);return n.addDelimiter(I0,e,e+2,!o&&(!l||r||a),!r&&(!a||o||l))},after:"Emphasis"}]};function An(n,t,e=0,i,s=0){let r=0,o=!0,a=-1,l=-1,h=!1,c=()=>{i.push(n.elt("TableCell",s+a,s+l,n.parser.parseInline(t.slice(a,l),s+a)))};for(let f=e;f-1)&&r++,o=!1,i&&(a>-1&&c(),i.push(n.elt("TableDelimiter",f+s,f+s+1))),a=l=-1):(h||u!=32&&u!=9)&&(a<0&&(a=f),l=f+1),h=!h&&u==92}return a>-1&&(r++,i&&c()),r}function ud(n,t){for(let e=t;es instanceof sa)||!ud(t.text,t.basePos))return!1;let i=n.scanLine(n.absoluteLineEnd+1).text;return dd.test(i)&&An(n,t.text,t.basePos)==An(n,i,t.basePos)},before:"SetextHeading"}]},pd=class{nextLine(){return!1}finish(t,e){return t.addLeafElement(e,t.elt("Task",e.start,e.start+e.content.length,[t.elt("TaskMarker",e.start,e.start+3),...t.parser.parseInline(e.content.slice(3),e.start+3)])),!0}},B0={defineNodes:[{name:"Task",block:!0,style:O.list},{name:"TaskMarker",style:O.atom}],parseBlock:[{name:"TaskList",leaf(n,t){return/^\[[ xX]\][ \t]/.test(t.content)&&n.parentType().name=="ListItem"?new pd:null},after:"SetextHeading"}]},Od=/(www\.)|(https?:\/\/)|([\w.+-]+@)|(mailto:|xmpp:)/gy,md=/[\w-]+(\.[\w-]+)+(\/[^\s<]*)?/gy,L0=/[\w-]+\.[\w-]+($|\/)/,gd=/[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy,bd=/\/[a-zA-Z\d@.]+/gy;function Sd(n,t,e,i){let s=0;for(let r=t;r-1)return-1;let i=t+e[0].length;for(;;){let s=n[i-1],r;if(/[?!.,:*_~]/.test(s)||s==")"&&Sd(n,t,i,")")>Sd(n,t,i,"("))i--;else if(s==";"&&(r=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(n.slice(t,i))))i=t+r.index;else break}return i}function wd(n,t){gd.lastIndex=t;let e=gd.exec(n);if(!e)return-1;let i=e[0][e[0].length-1];return i=="_"||i=="-"?-1:t+e[0].length-(i=="."?1:0)}var _0={parseInline:[{name:"Autolink",parse(n,t,e){let i=e-n.offset;Od.lastIndex=i;let s=Od.exec(n.text),r=-1;if(!s)return-1;if(s[1]||s[2]){if(r=N0(n.text,i+s[0].length),r>-1&&n.hasOpenLink){let o=/([^\[\]]|\[[^\]]*\])*/.exec(n.text.slice(i,r));r=i+o[0].length}}else s[3]?r=wd(n.text,i):(r=wd(n.text,i+s[0].length),r>-1&&s[0]=="xmpp:"&&(bd.lastIndex=r,s=bd.exec(n.text),s&&(r=s.index+s[0].length)));return r<0?-1:(n.addElement(n.elt("URL",e,r+n.offset)),r+n.offset)}}]},yd=[V0,B0,D0,_0];function kd(n,t,e){return(i,s,r)=>{if(s!=n||i.char(r+1)==n)return-1;let o=[i.elt(e,r,r+1)];for(let a=r+1;a"}}}),$d=new E,Td=cd.configure({props:[Te.add(n=>!n.is("Block")||n.is("Document")||ra(n)!=null?void 0:(t,e)=>({from:e.doc.lineAt(t.from).to,to:t.to})),$d.add(ra),$e.add({Document:()=>null}),Ye.add({Document:Pd})]});function ra(n){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(n.name);return t?+t[1]:void 0}function z0(n,t){let e=n;for(;;){let i=e.nextSibling,s;if(!i||(s=ra(i.type))!=null&&s<=t)break;e=i}return e.to}var j0=gc.of((n,t,e)=>{for(let i=F(n).resolveInner(e,-1);i&&!(i.frome)return{from:e,to:r}}return null});function oa(n){return new Qt(Pd,n,[j0],"markdown")}var G0=oa(Td),U0=Td.configure([yd,xd,vd,Qd,{props:[Te.add({Table:(n,t)=>({from:t.doc.lineAt(n.from).to,to:n.to})})]}]),Cd=oa(U0);function H0(n,t){return e=>{if(e&&n){let i=null;if(e=/\S*/.exec(e)[0],typeof n=="function"?i=n(e):i=Pi.matchLanguageName(n,e,!0),i instanceof Pi)return i.support?i.support.language.parser:Je.getSkippingParser(i.load());if(i)return i.parser}return t?t.parser:null}}var En=class{constructor(t,e,i,s,r,o,a){this.node=t,this.from=e,this.to=i,this.spaceBefore=s,this.spaceAfter=r,this.type=o,this.item=a}blank(t,e=!0){let i=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(t!=null){for(;i.length0;s--)i+=" ";return i+(e?this.spaceAfter:"")}}marker(t,e){let i=this.node.name=="OrderedList"?String(+Ad(this.item,t)[2]+e):"";return this.spaceBefore+i+this.type+this.spaceAfter}};function Zd(n,t){let e=[];for(let s=n;s&&s.name!="Document";s=s.parent)(s.name=="ListItem"||s.name=="Blockquote"||s.name=="FencedCode")&&e.push(s);let i=[];for(let s=e.length-1;s>=0;s--){let r=e[s],o,a=t.lineAt(r.from),l=r.from-a.from;if(r.name=="FencedCode")i.push(new En(r,l,l,"","","",null));else if(r.name=="Blockquote"&&(o=/^ *>( ?)/.exec(a.text.slice(l))))i.push(new En(r,l,l+o[0].length,"",o[1],">",null));else if(r.name=="ListItem"&&r.parent.name=="OrderedList"&&(o=/^( *)\d+([.)])( *)/.exec(a.text.slice(l)))){let h=o[3],c=o[0].length;h.length>=4&&(h=h.slice(0,h.length-4),c-=4),i.push(new En(r.parent,l,l+c,o[1],h,o[2],r))}else if(r.name=="ListItem"&&r.parent.name=="BulletList"&&(o=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(a.text.slice(l)))){let h=o[4],c=o[0].length;h.length>4&&(h=h.slice(0,h.length-4),c-=4);let f=o[2];o[3]&&(f+=o[3].replace(/[xX]/," ")),i.push(new En(r.parent,l,l+c,o[1],h,f,r))}}return i}function Ad(n,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(n.from,n.from+10))}function aa(n,t,e,i=0){for(let s=-1,r=n;;){if(r.name=="ListItem"){let a=Ad(r,t),l=+a[2];if(s>=0){if(l!=s+1)return;e.push({from:r.from+a[1].length,to:r.from+a[0].length,insert:String(s+2+i)})}s=l}let o=r.nextSibling;if(!o)break;r=o}}function la(n,t){let e=/^[ \t]*/.exec(n)[0].length;if(!e||t.facet(Ie)!=" ")return n;let i=kt(n,4,e),s="";for(let r=i;r>0;)r>=4?(s+=" ",r-=4):(s+=" ",r--);return s+n.slice(e)}var F0=({state:n,dispatch:t})=>{let e=F(n),{doc:i}=n,s=null,r=n.changeByRange(o=>{if(!o.empty||!Cd.isActiveAt(n,o.from))return s={range:o};let a=o.from,l=i.lineAt(a),h=Zd(e.resolveInner(a,-1),i);for(;h.length&&h[h.length-1].from>a-l.from;)h.pop();if(!h.length)return s={range:o};let c=h[h.length-1];if(c.to-c.spaceAfter.length>a-l.from)return s={range:o};let f=a>=c.to-c.spaceAfter.length&&!/\S/.test(l.text.slice(c.to));if(c.item&&f){let g=c.node.firstChild,b=c.node.getChild("ListItem","ListItem");if(g.to>=a||b&&b.to0&&!/[^\s>]/.test(i.lineAt(l.from-1).text)){let w=h.length>1?h[h.length-2]:null,x,P="";w&&w.item?(x=l.from+w.from,P=w.marker(i,1)):x=l.from+(w?w.to:0);let k=[{from:x,to:a,insert:P}];return c.node.name=="OrderedList"&&aa(c.item,i,k,-2),w&&w.node.name=="OrderedList"&&aa(w.item,i,k),{range:S.cursor(x+P.length),changes:k}}else{let w=Xd(h,n,l);return{range:S.cursor(a+w.length+1),changes:{from:l.from,insert:w+n.lineBreak}}}}if(c.node.name=="Blockquote"&&f&&l.from){let g=i.lineAt(l.from-1),b=/>\s*$/.exec(g.text);if(b&&b.index==c.from){let w=n.changes([{from:g.from+b.index,to:g.to},{from:l.from+c.from,to:l.to}]);return{range:o.map(w),changes:w}}}let u=[];c.node.name=="OrderedList"&&aa(c.item,i,u);let d=c.item&&c.item.from]*/.exec(l.text)[0].length>=c.to)for(let g=0,b=h.length-1;g<=b;g++)p+=g==b&&!d?h[g].marker(i,1):h[g].blank(gl.from&&/\s/.test(l.text.charAt(m-l.from-1));)m--;return p=la(p,n),K0(c.node,n.doc)&&(p=Xd(h,n,l)+n.lineBreak+p),u.push({from:m,to:a,insert:n.lineBreak+p}),{range:S.cursor(m+p.length+1),changes:u}});return s?!1:(t(n.update(r,{scrollIntoView:!0,userEvent:"input"})),!0)};function Ed(n){return n.name=="QuoteMark"||n.name=="ListMark"}function K0(n,t){if(n.name!="OrderedList"&&n.name!="BulletList")return!1;let e=n.firstChild,i=n.getChild("ListItem","ListItem");if(!i)return!1;let s=t.lineAt(e.to),r=t.lineAt(i.from),o=/^[\s>]*$/.test(s.text);return s.number+(o?0:1){let e=F(n),i=null,s=n.changeByRange(r=>{let o=r.from,{doc:a}=n;if(r.empty&&Cd.isActiveAt(n,r.from)){let l=a.lineAt(o),h=Zd(J0(e,o),a);if(h.length){let c=h[h.length-1],f=c.to-c.spaceAfter.length+(c.spaceAfter?1:0);if(o-l.from>f&&!/\S/.test(l.text.slice(f,o-l.from)))return{range:S.cursor(l.from+f),changes:{from:l.from+f,to:o}};if(o-l.from==f&&(!c.item||l.from<=c.item.from||!/\S/.test(l.text.slice(0,c.to)))){let u=l.from+c.from;if(c.item&&c.node.frome&&(i.push(V.line({class:"cm-active"}).range(r.from)),e=r.from)}return V.set(i)}},{decorations:t=>t.decorations});this.basicMDKeymap=[{key:"Mod-b",run:t=>(t.dispatch({changes:{from:t.state.selection.main.from,to:t.state.selection.main.to,insert:Pt(t.state.doc.sliceString(t.state.selection.main.from,t.state.selection.main.to),"**")}}),!0)},{key:"*",run:t=>(t.dispatch({changes:{from:t.state.selection.main.from,to:t.state.selection.main.to,insert:"*"+t.state.doc.sliceString(t.state.selection.main.from,t.state.selection.main.to)+"*"}}),!0)},{key:"=",run:t=>(t.dispatch({changes:{from:t.state.selection.main.from,to:t.state.selection.main.to,insert:"="+t.state.doc.sliceString(t.state.selection.main.from,t.state.selection.main.to)+"="}}),!0)},{key:"Mod-i",run:t=>(t.dispatch({changes:{from:t.state.selection.main.from,to:t.state.selection.main.to,insert:Pt(t.state.doc.sliceString(t.state.selection.main.from,t.state.selection.main.to),"*")}}),!0)},{key:"Mod-u",run:t=>(console.log(1),t.dispatch({changes:{from:t.state.selection.main.from,to:t.state.selection.main.to,insert:Pt(t.state.doc.sliceString(t.state.selection.main.from,t.state.selection.main.to),"","")}}),!0)},{key:"Ctrl-l",run:t=>{let{from:e,to:i}=t.state.selection.main,s=t.state.doc.lineAt(e),r=s.text;if(r.length<2)return t.dispatch({changes:{from:e,to:i,insert:"- "+r}}),!0;if(r.startsWith("- [ ] "))t.dispatch({changes:{from:s.from,to:s.to,insert:"- [x] "+r.slice(6)}});else if(r.startsWith("* [ ] "))t.dispatch({changes:{from:s.from,to:s.to,insert:"* [x]"+r.slice(6)}});else if(r.startsWith("- [x] "))t.dispatch({changes:{from:s.from,to:s.to,insert:"- "+r.slice(6)}});else if(r.startsWith("* [x] "))t.dispatch({changes:{from:s.from,to:s.to,insert:"* "+r.slice(6)}});else{if(r.startsWith("* "))return t.dispatch({changes:{from:s.from,to:s.to,insert:"* [ ] "+r.slice(2)}}),!0;if(r.startsWith("- "))return t.dispatch({changes:{from:s.from,to:s.to,insert:"- [ ] "+r.slice(2)}}),!0;t.dispatch({changes:{from:s.from,to:s.to,insert:"- "+r}})}return!0}},{key:"$",run:t=>(t.dispatch({changes:{from:t.state.selection.main.from,to:t.state.selection.main.to,insert:"$"+t.state.doc.sliceString(t.state.selection.main.from,t.state.selection.main.to)+"$"}}),!0)},{key:"[",run:t=>(t.dispatch({changes:{from:t.state.selection.main.from,to:t.state.selection.main.to,insert:"["+t.state.doc.sliceString(t.state.selection.main.from,t.state.selection.main.to)+"]"}}),t.dispatch({selection:{anchor:t.state.selection.main.anchor+1,head:t.state.selection.main.head+1}}),!0)},{key:"{",run:t=>(t.dispatch({changes:{from:t.state.selection.main.from,to:t.state.selection.main.to,insert:"{"+t.state.doc.sliceString(t.state.selection.main.from,t.state.selection.main.to)+"}"}}),t.dispatch({selection:{anchor:t.state.selection.main.anchor+1,head:t.state.selection.main.head+1}}),!0)},{key:"Tab",run:t=>{let e=t.state.selection.main,i=t.state.doc.lineAt(e.from),s=t.state.doc.lineAt(e.to),r=" ".repeat(this.plugin.settings.tabSize)+i.text;for(let o=i.number+1;o<=s.number;o++){let a=t.state.doc.line(o);r+=` `+" ".repeat(this.plugin.settings.tabSize)+a.text}return t.dispatch({changes:{from:i.from,to:s.to,insert:r}}),e.from===e.to&&t.dispatch({selection:{anchor:e.from+this.plugin.settings.tabSize,head:e.to+this.plugin.settings.tabSize}}),!0}},{key:"Shift-Tab",run:t=>{let e=t.state.selection.main,i=t.state.doc.lineAt(e.from),s=t.state.doc.lineAt(e.to),r=i.text.startsWith(" ".repeat(this.plugin.settings.tabSize))?i.text.slice(this.plugin.settings.tabSize):i.text;for(let o=i.number+1;o<=s.number;o++){let a=t.state.doc.line(o);a.text.startsWith(" ")?a.text.length-a.text.trimStart().length>=this.plugin.settings.tabSize?r+=` `+a.text.slice(this.plugin.settings.tabSize):r+=` `+a.text.trimStart():r+=` `+a.text}return t.dispatch({changes:{from:i.from,to:s.to,insert:r}}),!0}},{key:"Ctrl-s",run:t=>(this.plugin.tabsEditorModal.saveEditorData(),!0)}];this.plugin=t,t.settings.showToolbar&&this.initToolbar(e),this.initEditor(e,i),t.settings.showToolbar&&this.registerToolbarEvents()}addButton(t,e,i){return new Wd.ButtonComponent(this.editToolbarEl).setIcon(t).setTooltip(e).setClass("toolbar-button").setClass(i)}addSplitLine(){this.editToolbarEl.createEl("span").addClass("split-line")}initToolbar(t){this.editToolbarEl=t.createEl("div"),this.editToolbarEl.addClass("toolbar"),this.initHistoryTool(),this.addSplitLine(),this.initFormatTool(),this.addSplitLine(),this.initParagraphTool(),this.addSplitLine(),this.initInsertTool()}initEditor(t,e=""){this.tabseditorEl=t.createEl("div"),this.tabseditorEl.addClass("tabs-editor");let i=Z.updateListener.of(s=>{s.docChanged&&(this.lastEditTime=Date.now(),this.docChange=!0)});this.state=q.create({doc:e,extensions:[gf,bf,Rd(),Ws(),xe.of(this.basicMDKeymap),this.activeLineHighlighter,Sf,i]}),this.view=new Z({state:this.state,parent:this.tabseditorEl,extensions:[Z.lineWrapping]})}initHistoryTool(){this.historyTools.push(this.addButton("undo","Undo (Ctrl+Z)","undo-button"),this.addButton("redo","Redo (Ctrl+Shift+Z)","redo-button"))}initFormatTool(){this.formatTools=[this.addButton("bold","Bold (Ctrl+B)","bold-button"),this.addButton("italic","Italic (Ctrl+I)","italic-button"),this.addButton("underline","Underline (Ctrl+U)","underline-button"),this.addButton("strikethrough","Strike (Ctrl+Shift+S)","strike-button")]}initParagraphTool(){this.paragraphTools=[this.addButton("lucide-list","Unordered List","unordered-list-button"),this.addButton("lucide-list-ordered","Ordered List","ordered-list-button"),this.addButton("quote","Quote","quote-button")]}initInsertTool(){this.insertTools=[this.addButton("code","Code","code-button"),this.addButton("lucide-quote","Callout","callout-button"),this.addButton("table","Table","table-button")]}registerToolbarEvents(){this.registerHistoryToolEvents(),this.registerFormatToolEvents(),this.registerPragraphToolEvents(),this.registerInsertToolEvents()}registerHistoryToolEvents(){this.historyTools[0].onClick(()=>{vs({state:this.view.state,dispatch:this.view.dispatch})}),this.historyTools[1].onClick(()=>{pn({state:this.view.state,dispatch:this.view.dispatch})})}registerFormatToolEvents(){this.formatTools[0].onClick(()=>{let{from:t,to:e}=this.view.state.selection.main,i=this.view.state.doc.lineAt(t),s=this.view.state.doc.lineAt(e);if(i.number===s.number)this.view.dispatch({changes:{from:t,to:e,insert:Pt(this.view.state.doc.sliceString(this.view.state.selection.main.from,this.view.state.selection.main.to),"**")}});else{let r=Pt(this.view.state.doc.sliceString(this.view.state.selection.main.from,i.to),"**");for(let o=i.number;o{let{from:t,to:e}=this.view.state.selection.main,i=this.view.state.doc.lineAt(t),s=this.view.state.doc.lineAt(e);if(i.number===s.number)this.view.dispatch({changes:{from:t,to:e,insert:Pt(this.view.state.doc.sliceString(this.view.state.selection.main.from,this.view.state.selection.main.to),"*")}});else{let r=Pt(this.view.state.doc.sliceString(this.view.state.selection.main.from,i.to),"*");for(let o=i.number;o{this.view.dispatch({changes:{from:this.view.state.selection.main.from,to:this.view.state.selection.main.to,insert:Pt(this.view.state.doc.sliceString(this.view.state.selection.main.from,this.view.state.selection.main.to),"","")}})}),this.formatTools[3].onClick(()=>{this.view.dispatch({changes:{from:this.view.state.selection.main.from,to:this.view.state.selection.main.to,insert:Pt(this.view.state.doc.sliceString(this.view.state.selection.main.from,this.view.state.selection.main.to),"~~")}})})}registerPragraphToolEvents(){this.paragraphTools[0].onClick(()=>{let t=this.view.state.selection.main,e=this.view.state.doc.lineAt(t.from),i=this.view.state.doc.lineAt(t.to),s=!1;for(let r=e.number;r<=i.number;r++)if(!this.view.state.doc.line(r).text.trimStart().startsWith("- ")){s=!0;break}if(s)for(let r=e.number;r<=i.number;r++){let o=this.view.state.doc.line(r);o.text.trimStart().startsWith("- ")||this.view.dispatch({changes:{from:o.from,to:o.to,insert:" ".repeat(o.text.length-o.text.trimStart().length)+"- "+o.text.trimStart()}})}else for(let r=e.number;r<=i.number;r++){let o=this.view.state.doc.line(r);!o.text.trimStart().startsWith("- ")||this.view.dispatch({changes:{from:o.from,to:o.to,insert:o.text.slice(0,o.text.indexOf("- "))+o.text.slice(o.text.indexOf("- ")+2)}})}}),this.paragraphTools[1].onClick(()=>{let t=this.view.state.selection.main,e=this.view.state.doc.lineAt(t.from),i=this.view.state.doc.lineAt(t.to),s=!1,r=l=>{let h=l.indexOf(". ");return h>0&&!isNaN(parseInt(l.slice(0,h)))};for(let l=e.number;l<=i.number;l++){let h=this.view.state.doc.line(l);if(!r(h.text.trimStart())){s=!0;break}}let o={},a=e.text.length-e.text.trimStart().length;if(e.number>1)for(let l=e.number-1;l>0&&r(this.view.state.doc.line(l).text.trimStart());l--){let h=this.view.state.doc.line(l).text,c=h.length-h.trimStart().length;if(c>a){o[c]=1;continue}else if(c===a){let f=parseInt(h.slice(0,h.indexOf(". ")));o[a]||(o[a]=f+1)}else a=c,o[a]=parseInt(h.slice(0,h.indexOf(". ")))+1}if(s)for(let l=e.number;l<=i.number;l++){let h=this.view.state.doc.line(l),c=h.text,f=h.text.length-h.text.trimStart().length;o[f]===void 0&&(o[f]=1),c=r(h.text.trimStart())?o[f].toString()+h.text.slice(h.text.indexOf(". ")+2):c=o[f].toString()+". "+h.text.trimStart(),o[f]++;for(let u in o)parseInt(u)>f&&(o[u]=1);this.view.dispatch({changes:{from:h.from,to:h.to,insert:" ".repeat(f)+c}})}else for(let l=e.number;l<=i.number;l++){let h=this.view.state.doc.line(l),c=h.text.length-h.text.trimStart().length;this.view.dispatch({changes:{from:h.from,to:h.to,insert:" ".repeat(c)+h.text.slice(h.text.indexOf(". ")+2)}})}}),this.paragraphTools[2].onClick(()=>{let t=this.view.state.selection.main,e=this.view.state.doc.lineAt(t.from),i=this.view.state.doc.lineAt(t.to),s=!1;for(let r=e.number;r<=i.number;r++)if(!this.view.state.doc.line(r).text.trimStart().startsWith("> ")){s=!0;break}if(s)for(let r=e.number;r<=i.number;r++){let o=this.view.state.doc.line(r);this.view.dispatch({changes:{from:o.from,to:o.to,insert:"> "+o.text}})}else for(let r=e.number;r<=i.number;r++){let o=this.view.state.doc.line(r);this.view.dispatch({changes:{from:o.from,to:o.to,insert:o.text.slice(2)}})}})}registerInsertToolEvents(){this.insertTools[0].onClick(()=>{let t=this.view.state.selection.main,e=wf(this.view.state.doc.sliceString(t.from,t.to));this.view.dispatch({changes:{from:t.from,to:t.to,insert:e}})}),this.insertTools[1].onClick(()=>{let t=this.view.state.selection.main,e=this.view.state.doc.lineAt(t.from),i=this.view.state.doc.lineAt(t.to);for(let s=e.number;s<=i.number;s++){let r=this.view.state.doc.line(s);this.view.dispatch({changes:{from:r.from,to:r.to,insert:"> "+r.text}})}this.view.dispatch({changes:{from:e.from,to:e.from,insert:`> [!NOTE] Title `}})}),this.insertTools[2].onClick(()=>{let t=new vo(this),e=this.insertTools[2].buttonEl.getBoundingClientRect().left,i=this.insertTools[2].buttonEl.getBoundingClientRect().bottom;t.showAtPosition({x:e,y:i})})}createEmptyTable(t,e){let i=[];i.push(Array(e).fill(" ")),i.push(Array(e).fill(":-:"));for(let a=0;a"| "+a.join(" | ")+" |").join(` `),r=this.view.state.selection;if(r.ranges.some(a=>a.empty===!1))this.view.state.doc.lineAt(r.main.from).from!==r.main.from?this.view.dispatch({changes:{from:this.view.state.selection.main.from,to:this.view.state.selection.main.to,insert:` `+s}}):this.view.dispatch({changes:{from:this.view.state.selection.main.from,to:this.view.state.selection.main.to,insert:s}});else{this.view.dispatch({changes:{from:this.view.state.doc.length,to:this.view.state.doc.length,insert:` `+s}});return}}};var ua=class extends qd.Modal{constructor(t,e){super(e);this.app=e,this.plugin=t,this.modalEl.addClass("tabs-editor-modal")}startEditing(t){this.contentEl.empty(),this.tabs=t;let e=t.split+t.tabsNav.navItems[t.currentIndex].title+` `+t.tabsContents.tabcontents[t.currentIndex].content.trim();this.editor=new fa(this.plugin,this.contentEl,e),this.open()}onOpen(){this.plugin.settings.editorAutoSaveInterval!==0&&(this.timer=setInterval(()=>{this.editor.docChange&&this.editor.lastEditTime&&Date.now()-this.editor.lastEditTime>this.plugin.settings.editorAutoSaveInterval&&this.saveEditorData()},1e3))}onClose(){this.saveEditorData(),clearInterval(this.timer)}saveEditorData(){var e,i;this.editor.docChange=!1;let t=this.getUpdatedTabsByIndex(this.tabs.currentIndex);(i=this.tabs.activeView)==null||i.editor.replaceRange(t,{line:this.tabs.sectionInfo.lineStart,ch:0},{line:this.tabs.sectionInfo.lineEnd,ch:(e=this.tabs.activeView)==null?void 0:e.editor.getLine(this.tabs.sectionInfo.lineEnd).length})}getUpdatedTabsByIndex(t){let e=this.editor.view.state.doc.toString(),i="";for(let s=0;s{new zs(t,e,i,this.app,this)}),this.registerCommands(),this.tabsEditorModal=new ua(this,this.app),this.app.workspace.onLayoutReady(()=>{this.settings.autorefreshMarkdownView&&this.refreshActiveView()}),this.lastTabsCache=new Map,this.lastTabsCache.set("/",0),this.app.workspace.on("active-leaf-change",()=>{this.lastTabsCache=new Map,this.lastTabsCache.set("/",0)})}async loadSettings(){this.settings=Object.assign({},Wn,await this.loadData())}async saveSettings(){await this.saveData(this.settings)}async registerCommands(){this.addCommand({id:"convert-to-tabs",name:"Convert selected text to tabs",editorCallback:(t,e)=>{let i=t.getSelection();if(i.trim()==="")t.replaceSelection("```tabs\n"+this.settings.split+this.settings.defaultTabNavItem+` `+this.settings.defaultTabContent+"\n```");else if(i.includes("```")){let s=0;for(let r=0,o=0;r{this.refreshOpenViews()}})}refreshOpenViews(){try{return this.app.workspace.getLeavesOfType("markdown").forEach(t=>t.rebuildView()),!0}catch(t){return console.error(t),!1}}refreshActiveView(){try{let t=this.app.workspace.getActiveViewOfType(Ys.MarkdownView);return t&&t.leaf.rebuildView(),!0}catch(t){return console.error(t),!1}}};0&&(module.exports={}); /* nosourcemap */