Socket
Socket
Sign inDemoInstall

@devbookhq/code-editor

Package Overview
Dependencies
Maintainers
2
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@devbookhq/code-editor - npm Package Compare versions

Comparing version 0.0.14 to 0.0.15

2

dist/cjs/index.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@codemirror/state"),n=require("@codemirror/view"),i=require("react"),o=require("vscode-languageserver-protocol"),r=require("vscode-ws-jsonrpc"),s=require("path-browserify"),l=require("@codemirror/autocomplete"),a=require("@codemirror/lint"),c=require("diff"),u=require("rehype-external-links"),d=require("rehype-highlight"),g=require("rehype-raw"),v=require("rehype-sanitize"),h=require("rehype-stringify"),m=require("remark-gfm"),p=require("remark-parse"),f=require("remark-rehype"),w=require("unified"),y=require("@codemirror/commands"),x=require("@codemirror/language"),C=require("@lezer/highlight");function S(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function z(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var b=S(s),D=z(c),H=S(u),E=S(d),P=S(g),I=S(v),R=S(h),L=S(m),_=S(p),V=S(f);function T(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{a(i.next(e))}catch(e){r(e)}}function l(e){try{a(i.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,l)}a((i=i.apply(e,t||[])).next())}))}class q{constructor(e,t=!1){this.logID=e,this.isEnabled=t}error(...e){console.error(`[${this.id()} ERROR]`,...e)}log(...e){this.isEnabled&&console.log(`[${this.id()}]`,...e)}id(){return"function"==typeof this.logID?this.logID():this.logID}}class M{constructor(e){this.plugins=[],this.languageID=e.languageID,this.lsp=e.lsp,this.capabilities=e.capabilities;const t=function(e,t="orange"){return function(...n){console.groupCollapsed(`%c[${e}]`,`color:${t};`,...n),console.trace(),console.groupEnd()}}(`LSP - ${this.languageID}`,"blue");this.lsp.onDiagnostics(this.processDiagnostics.bind(this)),this.lsp.onError((e=>{t("Error in language service",e)})),this.lsp.onLogMessage((e=>{})),this.lsp.onShowMessage((e=>{}))}close(){this.lsp.dispose()}attachPlugin(e){this.plugins.push(e)}detachPlugin(e){const t=this.plugins.indexOf(e);-1!==t&&this.plugins.splice(t,1)}processDiagnostics(e){for(const t of this.plugins)t.onDiagnostics(e)}}function O(){let e,t;const n=new Promise(((n,i)=>{e=n,t=i}));return{resolve:e,reject:t,promise:n}}function k(e){return null!=e}class K{constructor(e,t,n,i,o){this.rootdir=e,this.session=n,this.port=i,this.isDestroyed=!1,this.isStarted=!1,this.started=O(),this.serverSetup=t.filter(k).filter((e=>!!e.languageServerCommand)),this.startCmd=`lsp-ws-proxy -l ${this.port} `+this.serverSetup.map((e=>`-- ${e.languageServerCommand} --stdio`)).join(" "),this.logger=new q("LanguageServer",o),this.logger.log("Language server initialized",this.serverSetup)}get languages(){return this.serverSetup.map((e=>e.languageID))}stop(){var e,t;return T(this,void 0,void 0,(function*(){this.isDestroyed||(this.isDestroyed=!0,this.logger.log("Closing..."),yield null===(e=this.languageServer)||void 0===e?void 0:e.kill(),this.logger.log(`Closed (processID ${null===(t=this.languageServer)||void 0===t?void 0:t.processID})`))}))}start(){return T(this,void 0,void 0,(function*(){if(this.isStarted)return yield this.started.promise,this.languageServer;this.isStarted=!0,this.logger.log("Opening...");const e=this.session.getHostname(this.port);if(!e)throw new Error("Cannot get session url");const t=`wss://${e}`;try{return this.languageServer=Object.assign(Object.assign({},yield function(e,t,n,i,o,r){return T(this,void 0,void 0,(function*(){if(!n)throw new Error("Cannot create process - process manager is not defined");const{resolve:s,promise:l}=O(),a=yield n.start({cmd:e,onStdout:i,onStderr:o,onExit:()=>{s()},rootdir:t,processID:r});return{exited:l,processID:a.processID,kill:a.kill,sendStdin:a.sendStdin}}))}(this.startCmd,this.rootdir,this.session.process,(e=>this.logger.log(`Output: ${e.line}`)),(e=>this.logger.error(`Error: ${e.line}`)))),{websocketURL:t}),this.logger.log(`Open (processID ${this.languageServer.processID})`),this.started.resolve(),this.languageServer}catch(e){throw this.started.reject(),e}}))}getConnectionString(e){return T(this,void 0,void 0,(function*(){const t=this.serverSetup.find((t=>t.languageID===e));if(!t)return;const n=yield this.start();return n?encodeURI(`${n.websocketURL}?name=${t.languageServerCommand}`):void 0}))}}const j={"workspace/executeCommand":"executeCommandProvider","workspace/applyEdit":"workspace","textDocument/codeAction":"codeActionProvider","textDocument/codeLens":"codeLensProvider","textDocument/color":"colorProvider","textDocument/completion":"completionProvider","textDocument/declaration":"declarationProvider","textDocument/definition":"definitionProvider","textDocument/formatting":"documentFormattingProvider","textDocument/documentHighlight":"documentHighlightProvider","textDocument/documentLink":"documentLinkProvider","textDocument/onTypeFormatting":"documentOnTypeFormattingProvider","textDocument/rangeFormatting":"documentRangeFormattingProvider","textDocument/documentSymbol":"documentSymbolProvider","textDocument/executeCommand":"executeCommandProvider","textDocument/foldingRange":"foldingRangeProvider","textDocument/hover":"hoverProvider","textDocument/implementation":"implementationProvider","textDocument/references":"referencesProvider","textDocument/rename":"renameProvider","textDocument/signatureHelp":"signatureHelpProvider","textDocument/typeDefinition":"typeDefinitionProvider","textDocument/workspaceSymbol":"workspaceSymbolProvider"},F=e=>{let t="initial";const n=[],i=new r.Emitter,o=new r.Emitter,s=new r.Emitter,l=new r.Emitter,a=e=>{"initial"===t?n.push({message:e}):"listening"===t&&l.fire(JSON.parse(e))},c=e=>{"initial"===t?n.push({error:e}):"listening"===t&&i.fire(e)},u=e=>a(e.data),d=e=>{1e3!==e.code&&c(new Error(`WebSocket Error (${e.code}): ${e.reason}`)),"listening"===t&&o.fire(),t="closed"};return e.addEventListener("message",u),e.addEventListener("close",d),{get onError(){return i.event},get onClose(){return o.event},get onPartialMessage(){return s.event},listen(e){if("initial"!==t)throw new Error("Already listening");const i=l.event(e);if(t="listening",0===n.length)return i;for(const e of n)e.message?a(e.message):e.error&&c(e.error);return n.length=0,i},dispose(){e.removeEventListener("message",u),e.removeEventListener("close",d),i.dispose(),o.dispose(),s.dispose(),n.length=0}}},N=e=>{const t=new r.Emitter,n=new r.Emitter,i=()=>{n.fire()};e.addEventListener("close",i);let o=0;return{get onError(){return t.event},get onClose(){return n.event},write(n){return T(this,void 0,void 0,(function*(){try{e.send(JSON.stringify(n))}catch(e){t.fire([A(e),n,++o])}}))},end(){},dispose(){t.dispose(),n.dispose(),e.removeEventListener("close",i)}}},A=e=>e instanceof Error?e:new Error((null==e?void 0:e.message)||"Unknown error"),U=()=>({error:e=>console.error(e),warn:e=>console.warn(e),info:e=>console.info(e),log:e=>console.log(e)});function $({rootURI:e,connectionString:t}){return T(this,void 0,void 0,(function*(){const n=new WebSocket(t),i=yield((e,t=U())=>new Promise((n=>{e.onopen=()=>{const i=r.createMessageConnection(F(e),N(e),t);i.onDispose((()=>e.close())),i.onClose((()=>i.dispose())),n(i)}})))(n);i.listen();const s=(e=>{let t;e.onRequest(o.RegistrationRequest.type,(({registrations:e})=>{for(const{method:n,registerOptions:i}of e){const e=j[n];e&&(t[e]=null==i||i)}})),e.onRequest(o.UnregistrationRequest.type,(({unregisterations:e})=>{for(const{method:n}of e){const e=j[n];e&&(t[e]=void 0)}}));const n=(t,n)=>(i,o)=>t()?e.sendRequest(n,i,o):Promise.resolve(null),i=(t,n)=>i=>t()?e.sendNotification(n,i):Promise.resolve(),r=t=>n=>e.sendNotification(t,n),s=t=>n=>{e.onNotification(t,n)};return{listen:()=>e.listen(),dispose:()=>e.dispose(),initialize:n=>T(void 0,void 0,void 0,(function*(){const i=yield e.sendRequest(o.InitializeRequest.type,n);return t=i.capabilities,i})),initialized:()=>e.sendNotification(o.InitializedNotification.type,{}),shutdown:()=>e.sendRequest(o.ShutdownRequest.type),exit:()=>e.sendNotification(o.ExitNotification.type),onError:t=>e.onError((([e,n,i])=>t(e,n,i))),onClose:t=>e.onClose((()=>t())),onLogMessage:s(o.LogMessageNotification.type),onShowMessage:s(o.ShowMessageNotification.type),onDiagnostics:s(o.PublishDiagnosticsNotification.type),textDocumentOpened:r(o.DidOpenTextDocumentNotification.type),textDocumentClosed:r(o.DidCloseTextDocumentNotification.type),textDocumentChanged:r(o.DidChangeTextDocumentNotification.type),textDocumentWillSave:i((()=>{var e;const n=null!==(e=t.textDocumentSync)&&void 0!==e?e:o.TextDocumentSyncKind.None;return"number"!=typeof n&&!!n.willSave}),o.WillSaveTextDocumentNotification.type),getEditsBeforeSave:n((()=>{var e;const n=null!==(e=t.textDocumentSync)&&void 0!==e?e:o.TextDocumentSyncKind.None;return"number"!=typeof n&&!!n.willSaveWaitUntil}),o.WillSaveTextDocumentWaitUntilRequest.type),textDocumentSaved:i((()=>{var e;const n=null!==(e=t.textDocumentSync)&&void 0!==e?e:o.TextDocumentSyncKind.None;return"number"==typeof n?n!==o.TextDocumentSyncKind.None:!!n.save}),o.DidSaveTextDocumentNotification.type),configurationChanged:r(o.DidChangeConfigurationNotification.type),watchedFilesChanged:r(o.DidChangeWatchedFilesNotification.type),getDocumentFormatting:n((()=>!!t.documentFormattingProvider),o.DocumentFormattingRequest.type),applyEdits:n((()=>!!t.workspace),o.ApplyWorkspaceEditRequest.type),executeCommand:n((()=>!!t.executeCommandProvider),o.ExecuteCommandRequest.type),getCompletion:n((()=>!!t.completionProvider),o.CompletionRequest.type),getCompletionItemDetails:n((()=>{var e;return!!(null===(e=t.completionProvider)||void 0===e?void 0:e.resolveProvider)}),o.CompletionResolveRequest.type),getHoverInfo:n((()=>!!t.hoverProvider),o.HoverRequest.type),getSignatureHelp:n((()=>!!t.signatureHelpProvider),o.SignatureHelpRequest.type),getDeclaration:n((()=>!!t.declarationProvider),o.DeclarationRequest.type),getDefinition:n((()=>!!t.definitionProvider),o.DefinitionRequest.type),getTypeDefinition:n((()=>!!t.typeDefinitionProvider),o.TypeDefinitionRequest.type),getImplementation:n((()=>!!t.implementationProvider),o.ImplementationRequest.type),getReferences:n((()=>!!t.referencesProvider),o.ReferencesRequest.type),getDocumentHighlight:n((()=>!!t.documentHighlightProvider),o.DocumentHighlightRequest.type),getDocumentSymbol:n((()=>!!t.documentSymbolProvider),o.DocumentSymbolRequest.type),getCodeAction:n((()=>!!t.codeActionProvider),o.CodeActionRequest.type),getCodeLens:n((()=>!!t.codeLensProvider),o.CodeLensRequest.type),resolveCodeLens:n((()=>{var e;return!!(null===(e=t.codeLensProvider)||void 0===e?void 0:e.resolveProvider)}),o.CodeLensResolveRequest.type),getDocumentLink:n((()=>!!t.documentLinkProvider),o.DocumentLinkRequest.type),resolveDocumentLink:n((()=>{var e;return!!(null===(e=t.documentLinkProvider)||void 0===e?void 0:e.resolveProvider)}),o.DocumentLinkResolveRequest.type),getColorSymbols:n((()=>!!t.colorProvider),o.DocumentColorRequest.type),getFoldingRanges:n((()=>!!t.foldingRangeProvider),o.FoldingRangeRequest.type),getSelectionRanges:n((()=>!!t.selectionRangeProvider),o.SelectionRangeRequest.type),getWorkspaceSymbols:n((()=>!!t.workspaceSymbolProvider),o.WorkspaceSymbolRequest.type),get syncsIncrementally(){var e,n;let i=null!==(e=t.textDocumentSync)&&void 0!==e?e:o.TextDocumentSyncKind.None;return"number"!=typeof i&&(i=null!==(n=i.change)&&void 0!==n?n:o.TextDocumentSyncKind.None),i===o.TextDocumentSyncKind.Incremental},get completionTriggers(){var e;return(null===(e=t.completionProvider)||void 0===e?void 0:e.triggerCharacters)||[]},get signatureHelpTriggers(){var e;return(null===(e=t.signatureHelpProvider)||void 0===e?void 0:e.triggerCharacters)||[]},get signatureHelpRetriggers(){var e;return(null===(e=t.signatureHelpProvider)||void 0===e?void 0:e.retriggerCharacters)||[]}}})(i),{capabilities:l}=yield function(e,t){return T(this,void 0,void 0,(function*(){const n=yield e.initialize({capabilities:{textDocument:{synchronization:{dynamicRegistration:!0,didSave:!0},completion:{dynamicRegistration:!0,completionItem:{snippetSupport:!1,insertReplaceSupport:!1,commitCharactersSupport:!1,documentationFormat:["markdown","plaintext"],labelDetailsSupport:!0,deprecatedSupport:!0,preselectSupport:!0,resolveSupport:{properties:["documentation","detail"]}},contextSupport:!0},hover:{dynamicRegistration:!0,contentFormat:["markdown","plaintext"]},signatureHelp:{dynamicRegistration:!0,signatureInformation:{documentationFormat:["markdown","plaintext"],parameterInformation:{labelOffsetSupport:!0},activeParameterSupport:!0},contextSupport:!0},codeAction:{dynamicRegistration:!0},formatting:{dynamicRegistration:!0},rename:{dynamicRegistration:!0},publishDiagnostics:{versionSupport:!0,codeDescriptionSupport:!0,relatedInformation:!0,tagSupport:{valueSet:[o.DiagnosticTag.Unnecessary,o.DiagnosticTag.Deprecated]}},moniker:{}},workspace:{didChangeConfiguration:{dynamicRegistration:!0},didChangeWatchedFiles:{dynamicRegistration:!0}}},processId:null,rootUri:t,workspaceFolders:null});return e.initialized().catch((e=>console.error(e))),n}))}(s,e);return{lsp:s,capabilities:l}}))}const B=(W=49152,J=65535,function(e){return e>=J?W:e+1});var W,J;function G(e,t){if(t.line>=e.lines)return e.length;const n=e.line(t.line+1).from+t.character;return n>e.length?e.length:n}function Q(e,t){const n=e.lineAt(t);return{line:n.number-1,character:t-n.from}}function X(e){return Array.isArray(e)?e.map(X).join("\n\n"):"string"==typeof e?e:e.value}function Y(e){let t="",n=Array.from(e).join("");return/\w/.test(n)&&(t+="\\w",n=n.replace(/\w/g,"")),`[${t}${n.replace(/[^\w\s]/g,"\\$&")}]`}function Z(e){if(!b.default.isAbsolute(e))throw new Error("filepath must be absolute");return`file://${e}`}function ee(e){return Z(e.endsWith("/")?e:e+"/")}function te(e,t){return t.find((({fileExtensions:t})=>null==t?void 0:t.some((t=>e.endsWith(t)))))}var ne=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M14.5 3H7.71l-.85-.85L6.51 2h-5l-.5.5v11l.5.5h13l.5-.5v-10L14.5 3zm-.51 8.49V13h-12V7h4.49l.35-.15.86-.86H14v1.5l-.01 4zm0-6.49h-6.5l-.35.15-.86.86H2v-3h4.29l.85.85.36.15H14l-.01.99z"/></svg>'}),ie=Object.freeze({__proto__:null,default:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M11.105 4.561l-3.43 3.427-1.134-1.12 2.07-2.08h-4.8a2.4 2.4 0 1 0 0 4.8h.89v1.6h-.88a4 4 0 0 1 0-7.991h4.8L6.54 1.13 7.675 0l3.43 3.432v1.13zM16.62 24h-9.6l-.8-.8V10.412l.8-.8h9.6l.8.8V23.2l-.8.8zm-8.8-1.6h8V11.212h-8V22.4zm5.6-20.798h9.6l.8.8v12.786l-.8.8h-4v-1.6h3.2V3.2h-8v4.787h-1.6V2.401l.8-.8zm.8 11.186h-4.8v1.6h4.8v-1.6zm-4.8 3.2h4.8v1.6h-4.8v-1.6zm4.8 3.2h-4.8v1.6h4.8v-1.6zm1.6-14.4h4.8v1.6h-4.8v-1.6zm4.8 6.4h-1.6v1.6h1.6v-1.6zm-3.338-3.176v-.024h3.338v1.6h-1.762l-1.576-1.576z"/></svg>'}),oe=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M11.34 9.71h.71l2.67-2.67v-.71L13.38 5h-.7l-1.82 1.81h-5V5.56l1.86-1.85V3l-2-2H5L1 5v.71l2 2h.71l1.14-1.15v5.79l.5.5H10v.52l1.33 1.34h.71l2.67-2.67v-.71L13.37 10h-.7l-1.86 1.85h-5v-4H10v.48l1.34 1.38zm1.69-3.65l.63.63-2 2-.63-.63 2-2zm0 5l.63.63-2 2-.63-.63 2-2zM3.35 6.65l-1.29-1.3 3.29-3.29 1.3 1.29-3.3 3.3z"/></svg>'}),re=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M8 1.003a7 7 0 0 0-7 7v.43c.09 1.51 1.91 1.79 3 .7a1.87 1.87 0 0 1 2.64 2.64c-1.1 1.16-.79 3.07.8 3.2h.6a7 7 0 1 0 0-14l-.04.03zm0 13h-.52a.58.58 0 0 1-.36-.14.56.56 0 0 1-.15-.3 1.24 1.24 0 0 1 .35-1.08 2.87 2.87 0 0 0 0-4 2.87 2.87 0 0 0-4.06 0 1 1 0 0 1-.9.34.41.41 0 0 1-.22-.12.42.42 0 0 1-.1-.29v-.37a6 6 0 1 1 6 6l-.04-.04zM9 3.997a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 7.007a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-7-5a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm7-1a1 1 0 1 1-2 0 1 1 0 0 1 2 0zM13 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"/></svg>'}),se=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3l1-1h6l1 1v5l-1 1h-4V8h4V3H8v3H7V3zm2 6V8L8 7H2L1 8v5l1 1h6l1-1V9zM8 8v5H2V8h6zm1.414-1L9 6.586V6h4v1H9.414zM9 4h4v1H9V4zm-2 6H3v1h4v-1z"/></svg>'}),le=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M14 2H8L7 3v3h1V3h6v5h-4v1h4l1-1V3l-1-1zM9 6h4v1H9.41L9 6.59V6zM7 7H2L1 8v5l1 1h6l1-1V8L8 7H7zm1 6H2V8h6v5zM3 9h4v1H3V9zm0 2h4v1H3v-1zm6-7h4v1H9V4z"/></svg>'}),ae=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M7.414 1.56L8.312 1h3.294l.818 1.575L10.236 6h1.781l.72 1.695L5.618 15l-1.602-1.163L6.119 10H4.898L4 8.56l3.414-7zM7.78 9L4.9 14.305 12.018 7H8.312l3.294-5H8.312L4.898 9H7.78z"/></svg>'}),ce=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M14.45 4.5l-5-2.5h-.9l-7 3.5-.55.89v4.5l.55.9 5 2.5h.9l7-3.5.55-.9v-4.5l-.55-.89zm-8 8.64l-4.5-2.25V7.17l4.5 2v3.97zm.5-4.8L2.29 6.23l6.66-3.34 4.67 2.34-6.67 3.11zm7 1.55l-6.5 3.25V9.21l6.5-3v3.68z"/></svg>'}),ue=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M13.85 4.44l-3.28-3.3-.35-.14H2.5l-.5.5v13l.5.5h11l.5-.5V4.8l-.15-.36zM13 5h-3V2l3 3zM3 14V2h6v3.5l.5.5H13v8H3z"/></svg>'}),de=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M11.496 4a3.49 3.49 0 0 0-3.46 3h-3.1a2 2 0 1 0 0 1h3.1a3.5 3.5 0 1 0 3.46-4zm0 6a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5z"/></svg>'}),ge=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M15 4h-5V3h5v1zm-1 3h-2v1h2V7zm-4 0H1v1h9V7zm2 6H1v1h11v-1zm-5-3H1v1h6v-1zm8 0h-5v1h5v-1zM8 2v3H1V2h7zM7 3H2v1h5V3z"/></svg>'}),ve=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M13.51 4l-5-3h-1l-5 3-.49.86v6l.49.85 5 3h1l5-3 .49-.85v-6L13.51 4zm-6 9.56l-4.5-2.7V5.7l4.5 2.45v5.41zM3.27 4.7l4.74-2.84 4.74 2.84-4.74 2.59L3.27 4.7zm9.74 6.16l-4.5 2.7V8.15l4.5-2.45v5.16z"/></svg>'}),he=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M6 2.984V2h-.09c-.313 0-.616.062-.909.185a2.33 2.33 0 0 0-.775.53 2.23 2.23 0 0 0-.493.753v.001a3.542 3.542 0 0 0-.198.83v.002a6.08 6.08 0 0 0-.024.863c.012.29.018.58.018.869 0 .203-.04.393-.117.572v.001a1.504 1.504 0 0 1-.765.787 1.376 1.376 0 0 1-.558.115H2v.984h.09c.195 0 .38.04.556.121l.001.001c.178.078.329.184.455.318l.002.002c.13.13.233.285.307.465l.001.002c.078.18.117.368.117.566 0 .29-.006.58-.018.869-.012.296-.004.585.024.87v.001c.033.283.099.558.197.824v.001c.106.273.271.524.494.753.223.23.482.407.775.53.293.123.596.185.91.185H6v-.984h-.09c-.199 0-.387-.038-.562-.115a1.613 1.613 0 0 1-.457-.32 1.659 1.659 0 0 1-.309-.467c-.074-.18-.11-.37-.11-.573 0-.228.003-.453.011-.672.008-.228.008-.45 0-.665a4.639 4.639 0 0 0-.055-.64 2.682 2.682 0 0 0-.168-.609A2.284 2.284 0 0 0 3.522 8a2.284 2.284 0 0 0 .738-.955c.08-.192.135-.393.168-.602.033-.21.051-.423.055-.64.008-.22.008-.442 0-.666-.008-.224-.012-.45-.012-.678a1.47 1.47 0 0 1 .877-1.354 1.33 1.33 0 0 1 .563-.121H6zm4 10.032V14h.09c.313 0 .616-.062.909-.185.293-.123.552-.3.775-.53.223-.23.388-.48.493-.753v-.001c.1-.266.165-.543.198-.83v-.002c.028-.28.036-.567.024-.863-.012-.29-.018-.58-.018-.869 0-.203.04-.393.117-.572v-.001a1.504 1.504 0 0 1 .765-.787c.176-.077.362-.115.558-.115H14v-.984h-.09c-.195 0-.38-.04-.556-.121l-.001-.001a1.376 1.376 0 0 1-.455-.318l-.002-.002a1.414 1.414 0 0 1-.307-.465l-.001-.002a1.405 1.405 0 0 1-.117-.566c0-.29.006-.58.018-.869a6.19 6.19 0 0 0-.024-.87v-.001a3.542 3.542 0 0 0-.197-.824v-.001a2.23 2.23 0 0 0-.494-.753 2.33 2.33 0 0 0-.775-.53 2.325 2.325 0 0 0-.91-.185H10v.984h.09c.2 0 .386.038.562.115.174.082.326.188.457.32.127.134.23.29.309.467.074.18.11.37.11.573 0 .228-.003.452-.011.672-.008.228-.008.45 0 .665.004.222.022.435.055.64.033.214.089.416.168.609a2.282 2.282 0 0 0 .738.955 2.282 2.282 0 0 0-.738.955 2.7 2.7 0 0 0-.168.602c-.033.21-.051.423-.055.64-.008.22-.008.442 0 .666.008.224.012.45.012.678a1.47 1.47 0 0 1-.42 1.035 1.466 1.466 0 0 1-.457.319 1.33 1.33 0 0 1-.563.121H10z"/></svg>'}),me=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2.873 1.1c.335.136.602.398.745.73.072.17.109.352.107.537a1.34 1.34 0 0 1-.61 1.135 1.359 1.359 0 0 1-.753.223A1.355 1.355 0 0 1 1 2.362a1.355 1.355 0 0 1 .83-1.256A1.37 1.37 0 0 1 2.873 1.1zm-.298 1.765a.551.551 0 0 0 .332-.5.548.548 0 1 0-.332.5zM6.43 1.109L1.11 6.43l.686.687 5.32-5.32-.686-.687zM11.5 9h1v2.5H15v1h-2.5V15h-1v-2.5H9v-1h2.5V9zm-5.732.525l.707.707L4.707 12l1.768 1.768-.707.707L4 12.707l-1.768 1.768-.707-.707L3.293 12l-1.768-1.768.707-.707L4 11.293l1.768-1.768zm1.35-4.195a1.353 1.353 0 0 0-1.256-.83 1.355 1.355 0 0 0-1.256.83 1.362 1.362 0 0 0 1.257 1.895A1.358 1.358 0 0 0 7.118 5.33zm-.753.745a.553.553 0 0 1-.289.29.547.547 0 0 1-.599-.117.529.529 0 0 1-.117-.173.544.544 0 0 1 .716-.715.565.565 0 0 1 .173.116.549.549 0 0 1 .116.599zM14 3h-4v1h4V3z"/></svg>'}),pe=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M2.807 14.975a1.75 1.75 0 0 1-1.255-.556 1.684 1.684 0 0 1-.544-1.1A1.72 1.72 0 0 1 1.36 12.1c1.208-1.27 3.587-3.65 5.318-5.345a4.257 4.257 0 0 1 .048-3.078 4.095 4.095 0 0 1 1.665-1.969 4.259 4.259 0 0 1 4.04-.36l.617.268-2.866 2.951 1.255 1.259 2.944-2.877.267.619a4.295 4.295 0 0 1 .04 3.311 4.198 4.198 0 0 1-.923 1.392 4.27 4.27 0 0 1-.743.581 4.217 4.217 0 0 1-3.812.446c-1.098 1.112-3.84 3.872-5.32 5.254a1.63 1.63 0 0 1-1.084.423zm7.938-13.047a3.32 3.32 0 0 0-1.849.557c-.213.13-.412.284-.591.458a3.321 3.321 0 0 0-.657 3.733l.135.297-.233.227c-1.738 1.697-4.269 4.22-5.485 5.504a.805.805 0 0 0 .132 1.05.911.911 0 0 0 .298.22c.1.044.209.069.319.072a.694.694 0 0 0 .45-.181c1.573-1.469 4.612-4.539 5.504-5.44l.23-.232.294.135a3.286 3.286 0 0 0 3.225-.254 3.33 3.33 0 0 0 .591-.464 3.28 3.28 0 0 0 .964-2.358c0-.215-.021-.43-.064-.642L11.43 7.125 8.879 4.578l2.515-2.59a3.286 3.286 0 0 0-.65-.06z"/></svg>'}),fe=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M4 1L3 2v12l1 1h8l1-1V2l-1-1H4zm0 2V2h8v12H4v-1h2v-1H4v-2h4V9H4V7h2V6H4V4h4V3H4z"/></svg>'}),we=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2.5 1l-.5.5V13h1V2h11v11h1V1.5l-.5-.5h-12zM2 15v-1h1v1H2zm3-1H4v1h1v-1zm1 0h1v1H6v-1zm3 0H8v1h1v-1zm1 0h1v1h-1v-1zm5 1v-1h-1v1h1zm-3-1h1v1h-1v-1z"/></svg>'}),ye=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 2L1 3v9l1 1h12l1-1V3l-1-1H2zm0 10V3h12v9H2zm3.356-3.07H6V7.22C6 6.408 5.685 6 5.056 6c-.135 0-.285.024-.45.073a1.444 1.444 0 0 0-.388.167v.665c.237-.203.487-.304.75-.304.261 0 .392.156.392.469l-.6.103c-.506.086-.76.406-.76.961 0 .263.061.473.183.631A.61.61 0 0 0 4.69 9c.29 0 .509-.16.657-.48h.009v.41zm.004-1.355v.193a.75.75 0 0 1-.12.436.368.368 0 0 1-.313.17.276.276 0 0 1-.22-.095.38.38 0 0 1-.08-.248c0-.222.11-.351.332-.389l.4-.067zM7.6 8.626h-.007v.31H7V5h.593v1.677h.008c.146-.31.355-.465.625-.465.248 0 .44.118.573.353.134.236.201.557.201.966 0 .443-.078.798-.235 1.067C8.61 8.866 8.4 9 8.138 9c-.237 0-.416-.125-.537-.374zm-.016-1.121v.272a.78.78 0 0 0 .107.426c.071.113.163.169.274.169.135 0 .24-.072.314-.216.075-.145.113-.35.113-.615 0-.22-.035-.39-.104-.514-.067-.124-.164-.187-.29-.187-.12 0-.219.062-.298.185a.887.887 0 0 0-.116.48zM11.262 9c.321 0 .567-.058.738-.173v-.71a.9.9 0 0 1-.552.207.619.619 0 0 1-.5-.215c-.12-.145-.181-.345-.181-.598 0-.26.063-.464.189-.612a.644.644 0 0 1 .516-.223c.194 0 .37.069.528.207v-.749c-.129-.09-.338-.134-.626-.134-.417 0-.751.14-1.001.422-.249.28-.373.662-.373 1.148 0 .42.116.764.349 1.03.232.267.537.4.913.4z"/></svg>'}),xe=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 2L1 3v3l1 1h12l1-1V3l-1-1H2zm0 1h12v3H2V3zm-1 7l1-1h3l1 1v3l-1 1H2l-1-1v-3zm2 0H2v3h3v-3H3zm7 0l1-1h3l1 1v3l-1 1h-3l-1-1v-3zm2 0h-1v3h3v-3h-2z"/></svg>'}),Ce=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 5h2V4H1.5l-.5.5v8l.5.5H4v-1H2V5zm12.5-1H12v1h2v7h-2v1h2.5l.5-.5v-8l-.5-.5zm-2.74 2.57L12 7v2.51l-.3.45-4.5 2h-.46l-2.5-1.5-.24-.43v-2.5l.3-.46 4.5-2h.46l2.5 1.5zM5 9.71l1.5.9V9.28L5 8.38v1.33zm.58-2.15l1.45.87 3.39-1.5-1.45-.87-3.39 1.5zm1.95 3.17l3.5-1.56v-1.4l-3.5 1.55v1.41z"/></svg>'});function Se(e){return e[e.length-1]}function ze(e){const t=document.createElement("template");return t.innerHTML=e,Array.from(t.content.childNodes)}function be(e){return T(this,void 0,void 0,(function*(){const t=yield function(e){return T(this,void 0,void 0,(function*(){return(yield w.unified().use(_.default).use(L.default).use(V.default,{allowDangerousHtml:!0}).use(P.default).use(I.default).data("settings",{fragment:!0}).use(E.default,{detect:!0}).use(H.default,{rel:"noopener noreferrer",target:"_blank"}).use(R.default).process(e)).toString()}))}(e);return ze(t)}))}const De=Object.fromEntries(Object.entries(o.CompletionItemKind).map((([e,t])=>[t,e.toLowerCase()]))),He=Object.fromEntries(Object.entries(o.CompletionItemKind).map((([e,t])=>[e.toLowerCase(),t]))),Ee=t.Facet.define({combine:Se}),Pe=t.Facet.define({combine:Se}),Ie=t.Facet.define({combine:Se});class Re{constructor(e,t){this.view=e,this.documentVersion=0;const n=this.view.state;this.client=n.facet(Ee),this.documentURI=e.state.facet(Pe),this.client.attachPlugin(this),this.openPromise=t?this.client.lsp.textDocumentOpened({textDocument:{text:n.doc.toString(),languageId:n.facet(Ie),uri:this.documentURI,version:this.documentVersion}}):this.client.lsp.textDocumentChanged({textDocument:{uri:this.documentURI,version:this.nextDocumentVersion},contentChanges:[{text:n.doc.toString()}]})}get nextDocumentVersion(){return++this.documentVersion}update({docChanged:e,state:t}){return T(this,void 0,void 0,(function*(){e&&(yield this.openPromise,yield this.client.lsp.textDocumentChanged({textDocument:{uri:this.documentURI,version:this.nextDocumentVersion},contentChanges:[{text:t.doc.toString()}]}))}))}destroy(){this.client.detachPlugin(this)}requestFormatting(e){var n;return T(this,void 0,void 0,(function*(){if(!(null===(n=this.client.capabilities)||void 0===n?void 0:n.documentFormattingProvider))return null;const i=e.state,o=yield this.client.lsp.getDocumentFormatting({textDocument:{uri:this.documentURI},options:{insertSpaces:!0,tabSize:2,trimFinalNewlines:!0,insertFinalNewline:!0,trimTrailingWhitespace:!0}}),r=(null==o?void 0:o.map((e=>({from:G(i.doc,e.range.start)||0,to:G(i.doc,e.range.end),insert:e.newText}))))||[],s=function(e,n){let i=0;return n.reduce(((e,n)=>{if(n instanceof t.ChangeSet||Array.isArray(n)||!("from"in n))throw new Error("This function does not support ChangeSet or nested ChangeSpec");const o=i+n.from,r=i+((null==n?void 0:n.to)||0),s=n.insert||"";return i+=s.length-(r-o),e.slice(0,o)+s+e.slice(r)}),e)}(i.doc.toString(),r),l=D.diffChars(i.doc.toString(),s),a=[];let c=0;l.forEach((e=>{e.removed?(a.push({from:c,to:c+e.value.length}),c+=e.value.length):e.added?a.push({from:c,insert:e.value}):c+=e.value.length})),a.length&&e.dispatch({annotations:[t.Transaction.remote.of(!0),t.Transaction.addToHistory.of(!0)],changes:a})}))}requestHoverTooltip({state:{doc:e}},{line:t,character:n}){return T(this,void 0,void 0,(function*(){if(!this.client.capabilities.hoverProvider)return null;const i=yield this.client.lsp.getHoverInfo({textDocument:{uri:this.documentURI},position:{line:t,character:n}});if(!i)return null;const{contents:o,range:r}=i;let s=G(e,{line:t,character:n});const l=X(o),a=yield be(l);if(0===a.length)return null;const c=document.createElement("div");let u;return c.id="root2",c.classList.add("documentation"),c.append(...a),r&&(s=G(e,r.start),u=G(e,r.end)),null===s?null:{pos:s,end:u,create:()=>({dom:c}),above:!0}}))}requestSignatureHelp(e,t,n,i){var r,s,l,a,c;return T(this,void 0,void 0,(function*(){if(!(null===(r=this.client.capabilities)||void 0===r?void 0:r.signatureHelpProvider))return null;const{state:u,pos:d,explicit:g}=e;if(g)return null;const v=u.doc.lineAt(d),h=v.text[d-v.from-1];let m,p=o.SignatureHelpTriggerKind.ContentChange;if((i&&(null===(l=null===(s=this.client.capabilities.signatureHelpProvider)||void 0===s?void 0:s.triggerCharacters)||void 0===l?void 0:l.includes(h))||n&&(null===(c=null===(a=this.client.capabilities.signatureHelpProvider)||void 0===a?void 0:a.retriggerCharacters)||void 0===c?void 0:c.includes(h)))&&(m=h,p=o.SignatureHelpTriggerKind.TriggerCharacter),!t&&p===o.SignatureHelpTriggerKind.ContentChange)return null;const f=Q(u.doc,d);return yield this.client.lsp.getSignatureHelp({position:f,textDocument:{uri:this.documentURI},context:{triggerKind:p,triggerCharacter:m,isRetrigger:n,activeSignatureHelp:t}})}))}requestCompletion(e,{line:t,character:n},{triggerKind:i,triggerCharacter:r}){return T(this,void 0,void 0,(function*(){if(!this.client.capabilities.completionProvider)return null;const s=yield this.client.lsp.getCompletion({textDocument:{uri:this.documentURI},position:{line:t,character:n},context:{triggerKind:i,triggerCharacter:r}});if(!s)return null;let a=("items"in s?s.items:s).map((e=>{const{detail:t,label:n,kind:i,textEdit:r,documentation:s,sortText:a,insertText:c,insertTextFormat:u,additionalTextEdits:d,filterText:g}=e;let v,h=null;r?(v=r.newText,v=(e,t)=>{const n=[],i=e.state;"range"in r?u===o.InsertTextFormat.Snippet||n.push({from:G(i.doc,r.range.start),to:G(i.doc,r.range.end),insert:r.newText}):console.error("Not supporting insert replace language server capability"),null==d||d.forEach((e=>{n.push({from:G(i.doc,e.range.start),to:G(i.doc,e.range.end),insert:e.newText})})),e.dispatch({annotations:l.pickedCompletion.of(t),changes:n})}):v=c?u===o.InsertTextFormat.Snippet?(e,t,n,i)=>{const o=c.indexOf("$0"),r=c.replace("$0",""),s=-1===o?void 0:n+o;e.dispatch({annotations:l.pickedCompletion.of(t),changes:[{from:n,to:i,insert:r}],selection:s?{head:s,anchor:s}:void 0})}:c:n;return{label:n,detail:t,apply:v,type:i&&De[i],sortText:null!=a?a:n,filterText:null!=g?g:n,info:()=>T(this,void 0,void 0,(function*(){let t,n=s;if(n||h||(h=yield this.client.lsp.getCompletionItemDetails(e)),(null==h?void 0:h.labelDetails)&&(t=h.label+h.labelDetails.detail+h.labelDetails.description),n=(null==h?void 0:h.documentation)||s||t,!n)return null;const i=X(n),o=yield be(i);if(0===o.length)return null;const r=document.createElement("div");return r.id="root3",r.classList.add("documentation"),r.append(...o),r}))}}));if(0===a.length)return null;const[,c]=function(e){const t=new Set,n=new Set;for(const{label:i}of e){const[e,...o]=i;t.add(e);for(const e of o)n.add(e)}const i=Y(t)+Y(n)+"*$";return[new RegExp("^"+i),new RegExp(i)]}(a),u=e.matchBefore(c);let{pos:d}=e;if(u){const e=u.text.toLowerCase();d=u.from,/^\w+$/.test(e)&&(a=a.filter((({filterText:t})=>t.toLowerCase().startsWith(e))).sort((({label:e},{label:t})=>{switch(!0){case e.startsWith(u.text)&&!t.startsWith(u.text):return-1;case!e.startsWith(u.text)&&t.startsWith(u.text):return 1}return 0})))}const g=a.reduce(((e,t)=>Math.max(e,t.label.length)),0);return{from:d,options:a,validFor:e=>0!==e.length&&(!e.endsWith(".")&&(!e.endsWith(" ")&&!(e.length>g)))}}))}onDiagnostics(e){if(e.uri!==this.documentURI)return;const t=this.view.state,n=e.diagnostics.map((({range:e,message:n,severity:i})=>({from:G(t.doc,e.start),to:G(t.doc,e.end),severity:i&&{[o.DiagnosticSeverity.Error]:"error",[o.DiagnosticSeverity.Warning]:"warning",[o.DiagnosticSeverity.Information]:"info",[o.DiagnosticSeverity.Hint]:"info"}[i]||"info",message:n}))).filter((({from:e,to:t})=>null!==e&&null!==t&&void 0!==e&&void 0!==t)).sort(((e,t)=>{switch(!0){case e.from<t.from:return-1;case e.from>t.from:return 1}return 0}));this.view.dispatch(a.setDiagnostics(t,n))}}function Le(){const e=Object.fromEntries(Object.entries(He).map((([e,t])=>{const n=ze(function(e){switch(e){case o.CompletionItemKind.Class:return oe;case o.CompletionItemKind.Color:return re;case o.CompletionItemKind.Constant:return Ce;case o.CompletionItemKind.Constructor:return ve;case o.CompletionItemKind.Enum:return le;case o.CompletionItemKind.EnumMember:return se;case o.CompletionItemKind.Event:return ae;case o.CompletionItemKind.Field:return ce;case o.CompletionItemKind.File:return ue;case o.CompletionItemKind.Folder:return ne;case o.CompletionItemKind.Function:return ve;case o.CompletionItemKind.Interface:return de;case o.CompletionItemKind.Keyword:return ge;case o.CompletionItemKind.Method:return ve;case o.CompletionItemKind.Module:return he;case o.CompletionItemKind.Operator:return me;case o.CompletionItemKind.Property:return pe;case o.CompletionItemKind.Reference:return ie;case o.CompletionItemKind.Snippet:return we;case o.CompletionItemKind.Struct:return xe;case o.CompletionItemKind.Text:return ye;case o.CompletionItemKind.TypeParameter:return oe;case o.CompletionItemKind.Unit:return fe;case o.CompletionItemKind.Value:return le;case o.CompletionItemKind.Variable:return Ce}}(t).default),i=document.createElement("div");return i.classList.add("autocomplete-icon",`autocomplete-icon-${e}`),i.append(...n),[e,i]})));return{getImage(t){const n=e[t];if(n)return n.cloneNode(!0)}}}class _e{constructor(e,t,n){this.view=e,this.getPlugin=t,this.setSignatureHelp=n}update(e){return T(this,void 0,void 0,(function*(){const t=this.getPlugin();if(!t)return;if(!e.transactions.some((e=>e.isUserEvent("select.pointer")))&&(e.docChanged||e.startState.selection.main.head!==e.state.selection.main.head)){yield t.update(e);const n=e.state.selection.main.head,i=new l.CompletionContext(e.state,n,!1);yield this.updateSignature(e.state,i,e.docChanged)}}))}updateSignature(e,t,n){return T(this,void 0,void 0,(function*(){const i=this.getPlugin();if(!i)return;const o=yield i.requestSignatureHelp(t,this.lastSignature,!!this.lastSignature,n);this.lastSignature=o||void 0;const r=o?yield this.getTooltip(e,o):null;this.setTooltip(r)}))}getTooltip(e,t){return T(this,void 0,void 0,(function*(){const n=void 0!==t.activeSignature?t.signatures[t.activeSignature]:void 0;if(!n)return null;n.activeParameter=void 0!==n.activeParameter?n.activeParameter:null==t?void 0:t.activeParameter;const i=X(n.documentation||""),o=yield be(i),r=n.parameters&&void 0!==n.activeParameter?n.parameters[n.activeParameter]:void 0,s=X((null==r?void 0:r.documentation)||""),l=yield be(s);if(0===o.length)return null;const a=document.createElement("div");a.id="root4",a.classList.add("documentation");const c=document.createElement("code");c.classList.add("signature-label"),c.innerHTML=function(e,t){if(void 0===e.activeParameter)return e.label;if(!e.parameters)return e.label;const n=e.parameters[e.activeParameter];if(!n)return e.label;const i="string"==typeof n.label?n.label:e.label.slice(n.label[0],n.label[1]);return e.label.replace(i,t(i))}(n,(e=>`<code class="selected-param">${e}</code>`)),0===o.length&&0===l.length||(c.innerHTML+="<br/><br/>"),a.appendChild(c),a.append(...o),0!==l.length&&a.append(...l);return{pos:e.selection.main.head,create:()=>({dom:a}),above:!0}}))}setTooltip(e){const t=this.setSignatureHelp.of(e);this.view.dispatch({effects:t})}}const Ve=t.StateEffect.define(),Te=Ve.of(null);function qe(e){const i=t.StateField.define({create:()=>null,update(e,t){if(t.isUserEvent("select.pointer"))return null;for(const e of t.effects)if(e.is(Ve))return e.value;return e},provide:e=>n.showTooltip.compute(["selection",e],(t=>{if(!e)return null;const n=t.field(e);return n?(n.pos=t.selection.main.head,Object.assign({},n)):null}))});return[n.ViewPlugin.define((t=>new _e(t,e,Ve))),i]}const Me={"data-gramm":"false",spellcheck:"false"};function Oe(e){const i=new t.Compartment,o=new t.Compartment,r=new t.Compartment,s=new t.Compartment;return{state:t.EditorState.create({doc:e,extensions:[n.EditorView.contentAttributes.of(Me),s.of([]),n.lineNumbers(),x.bracketMatching(),n.highlightActiveLineGutter(),n.highlightSpecialChars(),y.history(),n.scrollPastEnd(),t.EditorState.tabSize.of(2),n.drawSelection(),n.dropCursor(),l.closeBrackets(),x.indentOnInput(),n.highlightActiveLine(),n.keymap.of([...y.defaultKeymap,...l.closeBracketsKeymap,...y.historyKeymap,...x.foldKeymap,y.indentWithTab,{key:"Mod-s",run:()=>!0}]),o.of([]),r.of([]),i.of([]),x.syntaxHighlighting(C.classHighlighter)]}),languageExtensions:i,languageServiceExtensions:o,contentHandlingExtensions:r,editabilityExtensions:s}}const ke=i.forwardRef((({content:r="",onContentChange:s,isReadOnly:a=!1,supportedLanguages:c,height:u,className:d="",autofocus:g,filename:v,languageClients:h,openFileInLanguageServer:m=!0},p)=>{const f=i.useRef(null),[w,y]=i.useState(),x=te(v,c),C=x&&(null==h?void 0:h[null==x?void 0:x.languageID]);return i.useImperativeHandle(p,(()=>({focus:()=>null==w?void 0:w.view.focus()})),[w]),i.useLayoutEffect((function(){if(!f.current)return;const{languageServiceExtensions:e,contentHandlingExtensions:t,languageExtensions:i,editabilityExtensions:o,state:s}=Oe(r),l=new n.EditorView({state:s,parent:f.current});return y({view:l,languageServiceExtensions:e,contentHandlingExtensions:t,languageExtensions:i,editabilityExtensions:o}),g&&l.focus(),()=>{l.destroy(),y(void 0)}}),[g,r]),i.useEffect((function(){if(w&&(null==x?void 0:x.languageExtensions))return w.view.dispatch({effects:w.languageExtensions.reconfigure(x.languageExtensions)}),()=>{w.view.dispatch({effects:w.languageExtensions.reconfigure([])})}}),[w,x]),i.useEffect((function(){if(!w)return;const e=[t.EditorState.readOnly.of(a),n.EditorView.editable.of(!a)];return w.view.dispatch({effects:w.editabilityExtensions.reconfigure(e)}),()=>{w.view.dispatch({effects:w.editabilityExtensions.reconfigure([])})}}),[w,a]),i.useEffect((function(){if(!w)return;if(!s)return;const e=n.EditorView.updateListener.of((e=>{e.docChanged&&(null==s||s(e.state.doc.toString()))}));return w.view.dispatch({effects:w.contentHandlingExtensions.reconfigure(e)}),()=>{w.view.dispatch({effects:w.contentHandlingExtensions.reconfigure([])})}}),[w,s]),i.useEffect((function(){if(!w)return;if(!v)return;if(!C)return;const e=function(e){let i=null;const{getImage:r}=Le();return[Ee.of(e.client),Pe.of(e.documentURI),Ie.of(e.client.languageID),n.ViewPlugin.define((t=>i=new Re(t,e.openFile))),t.Prec.highest(n.keymap.of([{key:"Mod-s",run:e=>(null==i||i.requestFormatting(e),!1)},{key:"Escape",run:e=>(e.dispatch({effects:[n.closeHoverTooltips,Te]}),!1)}])),qe((()=>i)),n.hoverTooltip(((e,t)=>T(this,void 0,void 0,(function*(){if(!i)return null;const n=Q(e.state.doc,t);return yield i.requestHoverTooltip(e,n)})))),l.autocompletion({activateOnTyping:!0,maxRenderedOptions:40,closeOnBlur:!1,icons:!1,addToOptions:[{render:e=>e.type?(e.iconCache||(e.iconCache=r(e.type)),e.iconCache||null):null,position:20}],override:[e=>T(this,void 0,void 0,(function*(){var t,n,r;if(!i)return null;const{state:s,pos:l,explicit:a}=e,c=s.doc.lineAt(l);let u,d=o.CompletionTriggerKind.Invoked;return!a&&(null===(r=null===(n=null===(t=i.client.capabilities)||void 0===t?void 0:t.completionProvider)||void 0===n?void 0:n.triggerCharacters)||void 0===r?void 0:r.includes(c.text[l-c.from-1]))&&(d=o.CompletionTriggerKind.TriggerCharacter,u=c.text[l-c.from-1]),yield i.requestCompletion(e,Q(s.doc,l),{triggerKind:d,triggerCharacter:u})}))]})]}({client:C,documentURI:Z(v),openFile:m});return w.view.dispatch({effects:w.languageServiceExtensions.reconfigure(e)}),()=>{w.view.dispatch({effects:w.languageServiceExtensions.reconfigure([])})}}),[w,C,v,m]),e.jsx("div",{className:`overflow-auto ${d}`,ref:f,style:Object.assign({},u&&{height:u})})}));ke.displayName="CodeEditor",exports.CodeEditor=ke,exports.getFileURI=Z,exports.getLanguageSetup=te,exports.getRootURI=ee,exports.useLanguageServer=function({supportedLanguages:e,session:t,debug:n,rootdir:o}){const[r,s]=i.useState(),[l,a]=i.useState(),{maybeEmptyPort:c,markPortAsNotEmpty:u}=function(){const[e,t]=i.useState(49152);return{maybeEmptyPort:e,markPortAsNotEmpty:i.useCallback((()=>{t(B)}),[])}}();return i.useEffect((function(){if(!(null==t?void 0:t.process))return;const i=new K(o,e,t,c,n);return s(i),i.start().then((e=>{null==e||e.exited.then((()=>{u(),s((e=>e===i?void 0:e))}))})).catch((e=>console.error("Error starting language server",e))),()=>{s((e=>e===i?void 0:e)),i.stop()}}),[t,n,c,u,e]),i.useEffect((function(){if(r)return a({process:r}),Promise.all(r.languages.map((e=>T(this,void 0,void 0,(function*(){try{const t=yield r.getConnectionString(e);if(!t)return;const{lsp:n,capabilities:i}=yield $({rootURI:ee(o),connectionString:t});return new M({languageID:e,capabilities:i,lsp:n})}catch(e){const t=e instanceof Error?e.message:JSON.stringify(e);console.error(t)}}))))).then((e=>{const t=e.reduce(((e,t)=>(t&&(e[t.languageID]=t),e)),{});a((e=>(null==e?void 0:e.process)===r?{process:e.process,clients:t}:e))})),()=>{a((e=>{if((null==e?void 0:e.process)!==r||!e.clients)return e;Object.values(e.clients).map((e=>e.close()))}))}}),[r,o]),null==l?void 0:l.clients};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@codemirror/state"),n=require("@codemirror/view"),i=require("react"),o=require("vscode-languageserver-protocol"),r=require("vscode-ws-jsonrpc"),s=require("path-browserify"),l=require("@codemirror/autocomplete"),a=require("@codemirror/lint"),c=require("diff"),u=require("rehype-external-links"),d=require("rehype-highlight"),g=require("rehype-raw"),v=require("rehype-sanitize"),h=require("rehype-stringify"),p=require("remark-gfm"),m=require("remark-parse"),f=require("remark-rehype"),w=require("unified"),y=require("@codemirror/commands"),x=require("@codemirror/language"),C=require("@lezer/highlight");function S(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function b(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var D=S(s),z=b(c),H=S(u),E=S(d),P=S(g),I=S(v),R=S(h),_=S(p),L=S(m),V=S(f);function M(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{a(i.next(e))}catch(e){r(e)}}function l(e){try{a(i.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,l)}a((i=i.apply(e,t||[])).next())}))}class T{constructor(e,t=!1){this.logID=e,this.isEnabled=t}error(...e){console.error(`[${this.id()} ERROR]`,...e)}log(...e){this.isEnabled&&console.log(`[${this.id()}]`,...e)}id(){return"function"==typeof this.logID?this.logID():this.logID}}class q{constructor(e){this.plugins=[],this.languageID=e.languageID,this.lsp=e.lsp,this.capabilities=e.capabilities;const t=function(e,t="orange"){return function(...n){console.groupCollapsed(`%c[${e}]`,`color:${t};`,...n),console.trace(),console.groupEnd()}}(`LSP - ${this.languageID}`,"blue");this.lsp.onDiagnostics(this.processDiagnostics.bind(this)),this.lsp.onError((e=>{t("Error in language service",e)})),this.lsp.onLogMessage((e=>{})),this.lsp.onShowMessage((e=>{}))}close(){this.lsp.dispose()}attachPlugin(e){this.plugins.push(e)}detachPlugin(e){const t=this.plugins.indexOf(e);-1!==t&&this.plugins.splice(t,1)}processDiagnostics(e){for(const t of this.plugins)t.onDiagnostics(e)}}function O(){let e,t;const n=new Promise(((n,i)=>{e=n,t=i}));return{resolve:e,reject:t,promise:n}}function k(e){return null!=e}class K{constructor(e,t,n,i,o){this.rootdir=e,this.session=n,this.port=i,this.isDestroyed=!1,this.isStarted=!1,this.started=O(),this.serverSetup=t.filter(k).filter((e=>!!e.languageServerCommand)),this.startCmd=`lsp-ws-proxy -l ${this.port} `+this.serverSetup.map((e=>`-- ${e.languageServerCommand} --stdio`)).join(" "),this.logger=new T("LanguageServer",o),this.logger.log("Language server initialized",this.serverSetup)}get languages(){return this.serverSetup.map((e=>e.languageID))}stop(){var e,t;return M(this,void 0,void 0,(function*(){this.isDestroyed||(this.isDestroyed=!0,this.logger.log("Closing..."),yield null===(e=this.languageServer)||void 0===e?void 0:e.kill(),this.logger.log(`Closed (processID ${null===(t=this.languageServer)||void 0===t?void 0:t.processID})`))}))}start(){return M(this,void 0,void 0,(function*(){if(this.isStarted)return yield this.started.promise,this.languageServer;this.isStarted=!0,this.logger.log("Opening...");const e=this.session.getHostname(this.port);if(!e)throw new Error("Cannot get session url");const t=`wss://${e}`;try{return this.languageServer=Object.assign(Object.assign({},yield function(e,t,n,i,o,r){return M(this,void 0,void 0,(function*(){if(!n)throw new Error("Cannot create process - process manager is not defined");const{resolve:s,promise:l}=O(),a=yield n.start({cmd:e,onStdout:i,onStderr:o,onExit:()=>{s()},rootdir:t,processID:r});return{exited:l,processID:a.processID,kill:a.kill,sendStdin:a.sendStdin}}))}(this.startCmd,this.rootdir,this.session.process,(e=>this.logger.log(`Output: ${e.line}`)),(e=>this.logger.error(`Error: ${e.line}`)))),{websocketURL:t}),this.logger.log(`Open (processID ${this.languageServer.processID})`),this.started.resolve(),this.languageServer}catch(e){throw this.started.reject(),e}}))}getConnectionString(e){return M(this,void 0,void 0,(function*(){const t=this.serverSetup.find((t=>t.languageID===e));if(!t)return;const n=yield this.start();return n?encodeURI(`${n.websocketURL}?name=${t.languageServerCommand}`):void 0}))}}const j={"workspace/executeCommand":"executeCommandProvider","workspace/applyEdit":"workspace","textDocument/codeAction":"codeActionProvider","textDocument/codeLens":"codeLensProvider","textDocument/color":"colorProvider","textDocument/completion":"completionProvider","textDocument/declaration":"declarationProvider","textDocument/definition":"definitionProvider","textDocument/formatting":"documentFormattingProvider","textDocument/documentHighlight":"documentHighlightProvider","textDocument/documentLink":"documentLinkProvider","textDocument/onTypeFormatting":"documentOnTypeFormattingProvider","textDocument/rangeFormatting":"documentRangeFormattingProvider","textDocument/documentSymbol":"documentSymbolProvider","textDocument/executeCommand":"executeCommandProvider","textDocument/foldingRange":"foldingRangeProvider","textDocument/hover":"hoverProvider","textDocument/implementation":"implementationProvider","textDocument/references":"referencesProvider","textDocument/rename":"renameProvider","textDocument/signatureHelp":"signatureHelpProvider","textDocument/typeDefinition":"typeDefinitionProvider","textDocument/workspaceSymbol":"workspaceSymbolProvider"},F=e=>{let t="initial";const n=[],i=new r.Emitter,o=new r.Emitter,s=new r.Emitter,l=new r.Emitter,a=e=>{"initial"===t?n.push({message:e}):"listening"===t&&l.fire(JSON.parse(e))},c=e=>{"initial"===t?n.push({error:e}):"listening"===t&&i.fire(e)},u=e=>a(e.data),d=e=>{1e3!==e.code&&c(new Error(`WebSocket Error (${e.code}): ${e.reason}`)),"listening"===t&&o.fire(),t="closed"};return e.addEventListener("message",u),e.addEventListener("close",d),{get onError(){return i.event},get onClose(){return o.event},get onPartialMessage(){return s.event},listen(e){if("initial"!==t)throw new Error("Already listening");const i=l.event(e);if(t="listening",0===n.length)return i;for(const e of n)e.message?a(e.message):e.error&&c(e.error);return n.length=0,i},dispose(){e.removeEventListener("message",u),e.removeEventListener("close",d),i.dispose(),o.dispose(),s.dispose(),n.length=0}}},N=e=>{const t=new r.Emitter,n=new r.Emitter,i=()=>{n.fire()};e.addEventListener("close",i);let o=0;return{get onError(){return t.event},get onClose(){return n.event},write(n){return M(this,void 0,void 0,(function*(){try{e.send(JSON.stringify(n))}catch(e){t.fire([A(e),n,++o])}}))},end(){},dispose(){t.dispose(),n.dispose(),e.removeEventListener("close",i)}}},A=e=>e instanceof Error?e:new Error((null==e?void 0:e.message)||"Unknown error"),U=()=>({error:e=>console.error(e),warn:e=>console.warn(e),info:e=>console.info(e),log:e=>console.log(e)});function $({rootURI:e,connectionString:t}){return M(this,void 0,void 0,(function*(){const n=new WebSocket(t),i=yield((e,t=U())=>new Promise((n=>{e.onopen=()=>{const i=r.createMessageConnection(F(e),N(e),t);i.onDispose((()=>e.close())),i.onClose((()=>i.dispose())),n(i)}})))(n);i.listen();const s=(e=>{let t;e.onRequest(o.RegistrationRequest.type,(({registrations:e})=>{for(const{method:n,registerOptions:i}of e){const e=j[n];e&&(t[e]=null==i||i)}})),e.onRequest(o.UnregistrationRequest.type,(({unregisterations:e})=>{for(const{method:n}of e){const e=j[n];e&&(t[e]=void 0)}}));const n=(t,n)=>(i,o)=>t()?e.sendRequest(n,i,o):Promise.resolve(null),i=(t,n)=>i=>t()?e.sendNotification(n,i):Promise.resolve(),r=t=>n=>e.sendNotification(t,n),s=t=>n=>{e.onNotification(t,n)};return{listen:()=>e.listen(),dispose:()=>e.dispose(),initialize:n=>M(void 0,void 0,void 0,(function*(){const i=yield e.sendRequest(o.InitializeRequest.type,n);return t=i.capabilities,i})),initialized:()=>e.sendNotification(o.InitializedNotification.type,{}),shutdown:()=>e.sendRequest(o.ShutdownRequest.type),exit:()=>e.sendNotification(o.ExitNotification.type),onError:t=>e.onError((([e,n,i])=>t(e,n,i))),onClose:t=>e.onClose((()=>t())),onLogMessage:s(o.LogMessageNotification.type),onShowMessage:s(o.ShowMessageNotification.type),onDiagnostics:s(o.PublishDiagnosticsNotification.type),textDocumentOpened:r(o.DidOpenTextDocumentNotification.type),textDocumentClosed:r(o.DidCloseTextDocumentNotification.type),textDocumentChanged:r(o.DidChangeTextDocumentNotification.type),textDocumentWillSave:i((()=>{var e;const n=null!==(e=t.textDocumentSync)&&void 0!==e?e:o.TextDocumentSyncKind.None;return"number"!=typeof n&&!!n.willSave}),o.WillSaveTextDocumentNotification.type),getEditsBeforeSave:n((()=>{var e;const n=null!==(e=t.textDocumentSync)&&void 0!==e?e:o.TextDocumentSyncKind.None;return"number"!=typeof n&&!!n.willSaveWaitUntil}),o.WillSaveTextDocumentWaitUntilRequest.type),textDocumentSaved:i((()=>{var e;const n=null!==(e=t.textDocumentSync)&&void 0!==e?e:o.TextDocumentSyncKind.None;return"number"==typeof n?n!==o.TextDocumentSyncKind.None:!!n.save}),o.DidSaveTextDocumentNotification.type),configurationChanged:r(o.DidChangeConfigurationNotification.type),watchedFilesChanged:r(o.DidChangeWatchedFilesNotification.type),getDocumentFormatting:n((()=>!!t.documentFormattingProvider),o.DocumentFormattingRequest.type),applyEdits:n((()=>!!t.workspace),o.ApplyWorkspaceEditRequest.type),executeCommand:n((()=>!!t.executeCommandProvider),o.ExecuteCommandRequest.type),getCompletion:n((()=>!!t.completionProvider),o.CompletionRequest.type),getCompletionItemDetails:n((()=>{var e;return!!(null===(e=t.completionProvider)||void 0===e?void 0:e.resolveProvider)}),o.CompletionResolveRequest.type),getHoverInfo:n((()=>!!t.hoverProvider),o.HoverRequest.type),getSignatureHelp:n((()=>!!t.signatureHelpProvider),o.SignatureHelpRequest.type),getDeclaration:n((()=>!!t.declarationProvider),o.DeclarationRequest.type),getDefinition:n((()=>!!t.definitionProvider),o.DefinitionRequest.type),getTypeDefinition:n((()=>!!t.typeDefinitionProvider),o.TypeDefinitionRequest.type),getImplementation:n((()=>!!t.implementationProvider),o.ImplementationRequest.type),getReferences:n((()=>!!t.referencesProvider),o.ReferencesRequest.type),getDocumentHighlight:n((()=>!!t.documentHighlightProvider),o.DocumentHighlightRequest.type),getDocumentSymbol:n((()=>!!t.documentSymbolProvider),o.DocumentSymbolRequest.type),getCodeAction:n((()=>!!t.codeActionProvider),o.CodeActionRequest.type),getCodeLens:n((()=>!!t.codeLensProvider),o.CodeLensRequest.type),resolveCodeLens:n((()=>{var e;return!!(null===(e=t.codeLensProvider)||void 0===e?void 0:e.resolveProvider)}),o.CodeLensResolveRequest.type),getDocumentLink:n((()=>!!t.documentLinkProvider),o.DocumentLinkRequest.type),resolveDocumentLink:n((()=>{var e;return!!(null===(e=t.documentLinkProvider)||void 0===e?void 0:e.resolveProvider)}),o.DocumentLinkResolveRequest.type),getColorSymbols:n((()=>!!t.colorProvider),o.DocumentColorRequest.type),getFoldingRanges:n((()=>!!t.foldingRangeProvider),o.FoldingRangeRequest.type),getSelectionRanges:n((()=>!!t.selectionRangeProvider),o.SelectionRangeRequest.type),getWorkspaceSymbols:n((()=>!!t.workspaceSymbolProvider),o.WorkspaceSymbolRequest.type),get syncsIncrementally(){var e,n;let i=null!==(e=t.textDocumentSync)&&void 0!==e?e:o.TextDocumentSyncKind.None;return"number"!=typeof i&&(i=null!==(n=i.change)&&void 0!==n?n:o.TextDocumentSyncKind.None),i===o.TextDocumentSyncKind.Incremental},get completionTriggers(){var e;return(null===(e=t.completionProvider)||void 0===e?void 0:e.triggerCharacters)||[]},get signatureHelpTriggers(){var e;return(null===(e=t.signatureHelpProvider)||void 0===e?void 0:e.triggerCharacters)||[]},get signatureHelpRetriggers(){var e;return(null===(e=t.signatureHelpProvider)||void 0===e?void 0:e.retriggerCharacters)||[]}}})(i),{capabilities:l}=yield function(e,t){return M(this,void 0,void 0,(function*(){const n=yield e.initialize({capabilities:{textDocument:{synchronization:{dynamicRegistration:!0,didSave:!0},completion:{dynamicRegistration:!0,completionItem:{snippetSupport:!1,insertReplaceSupport:!1,commitCharactersSupport:!1,documentationFormat:["markdown","plaintext"],labelDetailsSupport:!0,deprecatedSupport:!0,preselectSupport:!0,resolveSupport:{properties:["documentation","detail"]}},contextSupport:!0},hover:{dynamicRegistration:!0,contentFormat:["markdown","plaintext"]},signatureHelp:{dynamicRegistration:!0,signatureInformation:{documentationFormat:["markdown","plaintext"],parameterInformation:{labelOffsetSupport:!0},activeParameterSupport:!0},contextSupport:!0},codeAction:{dynamicRegistration:!0},formatting:{dynamicRegistration:!0},rename:{dynamicRegistration:!0},publishDiagnostics:{versionSupport:!0,codeDescriptionSupport:!0,relatedInformation:!0,tagSupport:{valueSet:[o.DiagnosticTag.Unnecessary,o.DiagnosticTag.Deprecated]}},moniker:{}},workspace:{didChangeConfiguration:{dynamicRegistration:!0},didChangeWatchedFiles:{dynamicRegistration:!0}}},processId:null,rootUri:t,workspaceFolders:null});return e.initialized().catch((e=>console.error(e))),n}))}(s,e);return{lsp:s,capabilities:l}}))}const B=(W=49152,J=65535,function(e){return e>=J?W:e+1});var W,J;function G(e,t){if(t.line>=e.lines)return e.length;const n=e.line(t.line+1).from+t.character;return n>e.length?e.length:n}function Q(e,t){const n=e.lineAt(t);return{line:n.number-1,character:t-n.from}}function X(e){return Array.isArray(e)?e.map(X).join("\n\n"):"string"==typeof e?e:e.value}function Y(e){let t="",n=Array.from(e).join("");return/\w/.test(n)&&(t+="\\w",n=n.replace(/\w/g,"")),`[${t}${n.replace(/[^\w\s]/g,"\\$&")}]`}function Z(e){if(!D.default.isAbsolute(e))throw new Error("filepath must be absolute");return`file://${e}`}function ee(e){return Z(e.endsWith("/")?e:e+"/")}function te(e,t){return t.find((({fileExtensions:t})=>null==t?void 0:t.some((t=>e.endsWith(t)))))}var ne=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M14.5 3H7.71l-.85-.85L6.51 2h-5l-.5.5v11l.5.5h13l.5-.5v-10L14.5 3zm-.51 8.49V13h-12V7h4.49l.35-.15.86-.86H14v1.5l-.01 4zm0-6.49h-6.5l-.35.15-.86.86H2v-3h4.29l.85.85.36.15H14l-.01.99z"/></svg>'}),ie=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M6 5.914l2.06-2.06v-.708L5.915 1l-.707.707.043.043.25.25 1 1h-3a2.5 2.5 0 0 0 0 5H4V7h-.5a1.5 1.5 0 1 1 0-3h3L5.207 5.293 5.914 6 6 5.914zM11 2H8.328l-1-1H12l.71.29 3 3L16 5v9l-1 1H6l-1-1V6.5l1 .847V14h9V6h-4V2zm1 0v3h3l-3-3z"/></svg>'}),oe=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M11.34 9.71h.71l2.67-2.67v-.71L13.38 5h-.7l-1.82 1.81h-5V5.56l1.86-1.85V3l-2-2H5L1 5v.71l2 2h.71l1.14-1.15v5.79l.5.5H10v.52l1.33 1.34h.71l2.67-2.67v-.71L13.37 10h-.7l-1.86 1.85h-5v-4H10v.48l1.34 1.38zm1.69-3.65l.63.63-2 2-.63-.63 2-2zm0 5l.63.63-2 2-.63-.63 2-2zM3.35 6.65l-1.29-1.3 3.29-3.29 1.3 1.29-3.3 3.3z"/></svg>'}),re=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M8 1.003a7 7 0 0 0-7 7v.43c.09 1.51 1.91 1.79 3 .7a1.87 1.87 0 0 1 2.64 2.64c-1.1 1.16-.79 3.07.8 3.2h.6a7 7 0 1 0 0-14l-.04.03zm0 13h-.52a.58.58 0 0 1-.36-.14.56.56 0 0 1-.15-.3 1.24 1.24 0 0 1 .35-1.08 2.87 2.87 0 0 0 0-4 2.87 2.87 0 0 0-4.06 0 1 1 0 0 1-.9.34.41.41 0 0 1-.22-.12.42.42 0 0 1-.1-.29v-.37a6 6 0 1 1 6 6l-.04-.04zM9 3.997a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 7.007a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-7-5a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm7-1a1 1 0 1 1-2 0 1 1 0 0 1 2 0zM13 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"/></svg>'}),se=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3l1-1h6l1 1v5l-1 1h-4V8h4V3H8v3H7V3zm2 6V8L8 7H2L1 8v5l1 1h6l1-1V9zM8 8v5H2V8h6zm1.414-1L9 6.586V6h4v1H9.414zM9 4h4v1H9V4zm-2 6H3v1h4v-1z"/></svg>'}),le=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M14 2H8L7 3v3h1V3h6v5h-4v1h4l1-1V3l-1-1zM9 6h4v1H9.41L9 6.59V6zM7 7H2L1 8v5l1 1h6l1-1V8L8 7H7zm1 6H2V8h6v5zM3 9h4v1H3V9zm0 2h4v1H3v-1zm6-7h4v1H9V4z"/></svg>'}),ae=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M7.414 1.56L8.312 1h3.294l.818 1.575L10.236 6h1.781l.72 1.695L5.618 15l-1.602-1.163L6.119 10H4.898L4 8.56l3.414-7zM7.78 9L4.9 14.305 12.018 7H8.312l3.294-5H8.312L4.898 9H7.78z"/></svg>'}),ce=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M14.45 4.5l-5-2.5h-.9l-7 3.5-.55.89v4.5l.55.9 5 2.5h.9l7-3.5.55-.9v-4.5l-.55-.89zm-8 8.64l-4.5-2.25V7.17l4.5 2v3.97zm.5-4.8L2.29 6.23l6.66-3.34 4.67 2.34-6.67 3.11zm7 1.55l-6.5 3.25V9.21l6.5-3v3.68z"/></svg>'}),ue=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M13.85 4.44l-3.28-3.3-.35-.14H2.5l-.5.5v13l.5.5h11l.5-.5V4.8l-.15-.36zM13 5h-3V2l3 3zM3 14V2h6v3.5l.5.5H13v8H3z"/></svg>'}),de=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M11.496 4a3.49 3.49 0 0 0-3.46 3h-3.1a2 2 0 1 0 0 1h3.1a3.5 3.5 0 1 0 3.46-4zm0 6a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5z"/></svg>'}),ge=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M15 4h-5V3h5v1zm-1 3h-2v1h2V7zm-4 0H1v1h9V7zm2 6H1v1h11v-1zm-5-3H1v1h6v-1zm8 0h-5v1h5v-1zM8 2v3H1V2h7zM7 3H2v1h5V3z"/></svg>'}),ve=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M13.51 4l-5-3h-1l-5 3-.49.86v6l.49.85 5 3h1l5-3 .49-.85v-6L13.51 4zm-6 9.56l-4.5-2.7V5.7l4.5 2.45v5.41zM3.27 4.7l4.74-2.84 4.74 2.84-4.74 2.59L3.27 4.7zm9.74 6.16l-4.5 2.7V8.15l4.5-2.45v5.16z"/></svg>'}),he=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M6 2.984V2h-.09c-.313 0-.616.062-.909.185a2.33 2.33 0 0 0-.775.53 2.23 2.23 0 0 0-.493.753v.001a3.542 3.542 0 0 0-.198.83v.002a6.08 6.08 0 0 0-.024.863c.012.29.018.58.018.869 0 .203-.04.393-.117.572v.001a1.504 1.504 0 0 1-.765.787 1.376 1.376 0 0 1-.558.115H2v.984h.09c.195 0 .38.04.556.121l.001.001c.178.078.329.184.455.318l.002.002c.13.13.233.285.307.465l.001.002c.078.18.117.368.117.566 0 .29-.006.58-.018.869-.012.296-.004.585.024.87v.001c.033.283.099.558.197.824v.001c.106.273.271.524.494.753.223.23.482.407.775.53.293.123.596.185.91.185H6v-.984h-.09c-.199 0-.387-.038-.562-.115a1.613 1.613 0 0 1-.457-.32 1.659 1.659 0 0 1-.309-.467c-.074-.18-.11-.37-.11-.573 0-.228.003-.453.011-.672.008-.228.008-.45 0-.665a4.639 4.639 0 0 0-.055-.64 2.682 2.682 0 0 0-.168-.609A2.284 2.284 0 0 0 3.522 8a2.284 2.284 0 0 0 .738-.955c.08-.192.135-.393.168-.602.033-.21.051-.423.055-.64.008-.22.008-.442 0-.666-.008-.224-.012-.45-.012-.678a1.47 1.47 0 0 1 .877-1.354 1.33 1.33 0 0 1 .563-.121H6zm4 10.032V14h.09c.313 0 .616-.062.909-.185.293-.123.552-.3.775-.53.223-.23.388-.48.493-.753v-.001c.1-.266.165-.543.198-.83v-.002c.028-.28.036-.567.024-.863-.012-.29-.018-.58-.018-.869 0-.203.04-.393.117-.572v-.001a1.504 1.504 0 0 1 .765-.787c.176-.077.362-.115.558-.115H14v-.984h-.09c-.195 0-.38-.04-.556-.121l-.001-.001a1.376 1.376 0 0 1-.455-.318l-.002-.002a1.414 1.414 0 0 1-.307-.465l-.001-.002a1.405 1.405 0 0 1-.117-.566c0-.29.006-.58.018-.869a6.19 6.19 0 0 0-.024-.87v-.001a3.542 3.542 0 0 0-.197-.824v-.001a2.23 2.23 0 0 0-.494-.753 2.33 2.33 0 0 0-.775-.53 2.325 2.325 0 0 0-.91-.185H10v.984h.09c.2 0 .386.038.562.115.174.082.326.188.457.32.127.134.23.29.309.467.074.18.11.37.11.573 0 .228-.003.452-.011.672-.008.228-.008.45 0 .665.004.222.022.435.055.64.033.214.089.416.168.609a2.282 2.282 0 0 0 .738.955 2.282 2.282 0 0 0-.738.955 2.7 2.7 0 0 0-.168.602c-.033.21-.051.423-.055.64-.008.22-.008.442 0 .666.008.224.012.45.012.678a1.47 1.47 0 0 1-.42 1.035 1.466 1.466 0 0 1-.457.319 1.33 1.33 0 0 1-.563.121H10z"/></svg>'}),pe=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2.873 1.1c.335.136.602.398.745.73.072.17.109.352.107.537a1.34 1.34 0 0 1-.61 1.135 1.359 1.359 0 0 1-.753.223A1.355 1.355 0 0 1 1 2.362a1.355 1.355 0 0 1 .83-1.256A1.37 1.37 0 0 1 2.873 1.1zm-.298 1.765a.551.551 0 0 0 .332-.5.548.548 0 1 0-.332.5zM6.43 1.109L1.11 6.43l.686.687 5.32-5.32-.686-.687zM11.5 9h1v2.5H15v1h-2.5V15h-1v-2.5H9v-1h2.5V9zm-5.732.525l.707.707L4.707 12l1.768 1.768-.707.707L4 12.707l-1.768 1.768-.707-.707L3.293 12l-1.768-1.768.707-.707L4 11.293l1.768-1.768zm1.35-4.195a1.353 1.353 0 0 0-1.256-.83 1.355 1.355 0 0 0-1.256.83 1.362 1.362 0 0 0 1.257 1.895A1.358 1.358 0 0 0 7.118 5.33zm-.753.745a.553.553 0 0 1-.289.29.547.547 0 0 1-.599-.117.529.529 0 0 1-.117-.173.544.544 0 0 1 .716-.715.565.565 0 0 1 .173.116.549.549 0 0 1 .116.599zM14 3h-4v1h4V3z"/></svg>'}),me=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M11 6h-1v-.5a.5.5 0 0 0-.5-.5H8.479v5.5a.5.5 0 0 0 .5.5h.5v1h-3v-1h.5a.5.5 0 0 0 .5-.5V5H6.5a.5.5 0 0 0-.5.5V6H5V4h6v2zm2.914 2.048l-1.462-1.462.707-.707 1.816 1.816v.707l-1.768 1.767-.707-.707 1.414-1.414zM3.548 9.462L2.086 8 3.5 6.586l-.707-.707-1.768 1.767v.708l1.816 1.815.707-.707z"/></svg>'}),fe=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M2.807 14.975a1.75 1.75 0 0 1-1.255-.556 1.684 1.684 0 0 1-.544-1.1A1.72 1.72 0 0 1 1.36 12.1c1.208-1.27 3.587-3.65 5.318-5.345a4.257 4.257 0 0 1 .048-3.078 4.095 4.095 0 0 1 1.665-1.969 4.259 4.259 0 0 1 4.04-.36l.617.268-2.866 2.951 1.255 1.259 2.944-2.877.267.619a4.295 4.295 0 0 1 .04 3.311 4.198 4.198 0 0 1-.923 1.392 4.27 4.27 0 0 1-.743.581 4.217 4.217 0 0 1-3.812.446c-1.098 1.112-3.84 3.872-5.32 5.254a1.63 1.63 0 0 1-1.084.423zm7.938-13.047a3.32 3.32 0 0 0-1.849.557c-.213.13-.412.284-.591.458a3.321 3.321 0 0 0-.657 3.733l.135.297-.233.227c-1.738 1.697-4.269 4.22-5.485 5.504a.805.805 0 0 0 .132 1.05.911.911 0 0 0 .298.22c.1.044.209.069.319.072a.694.694 0 0 0 .45-.181c1.573-1.469 4.612-4.539 5.504-5.44l.23-.232.294.135a3.286 3.286 0 0 0 3.225-.254 3.33 3.33 0 0 0 .591-.464 3.28 3.28 0 0 0 .964-2.358c0-.215-.021-.43-.064-.642L11.43 7.125 8.879 4.578l2.515-2.59a3.286 3.286 0 0 0-.65-.06z"/></svg>'}),we=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M4 1L3 2v12l1 1h8l1-1V2l-1-1H4zm0 2V2h8v12H4v-1h2v-1H4v-2h4V9H4V7h2V6H4V4h4V3H4z"/></svg>'}),ye=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2.5 1l-.5.5V13h1V2h11v11h1V1.5l-.5-.5h-12zM2 15v-1h1v1H2zm3-1H4v1h1v-1zm1 0h1v1H6v-1zm3 0H8v1h1v-1zm1 0h1v1h-1v-1zm5 1v-1h-1v1h1zm-3-1h1v1h-1v-1z"/></svg>'}),xe=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 2L1 3v9l1 1h12l1-1V3l-1-1H2zm0 10V3h12v9H2zm3.356-3.07H6V7.22C6 6.408 5.685 6 5.056 6c-.135 0-.285.024-.45.073a1.444 1.444 0 0 0-.388.167v.665c.237-.203.487-.304.75-.304.261 0 .392.156.392.469l-.6.103c-.506.086-.76.406-.76.961 0 .263.061.473.183.631A.61.61 0 0 0 4.69 9c.29 0 .509-.16.657-.48h.009v.41zm.004-1.355v.193a.75.75 0 0 1-.12.436.368.368 0 0 1-.313.17.276.276 0 0 1-.22-.095.38.38 0 0 1-.08-.248c0-.222.11-.351.332-.389l.4-.067zM7.6 8.626h-.007v.31H7V5h.593v1.677h.008c.146-.31.355-.465.625-.465.248 0 .44.118.573.353.134.236.201.557.201.966 0 .443-.078.798-.235 1.067C8.61 8.866 8.4 9 8.138 9c-.237 0-.416-.125-.537-.374zm-.016-1.121v.272a.78.78 0 0 0 .107.426c.071.113.163.169.274.169.135 0 .24-.072.314-.216.075-.145.113-.35.113-.615 0-.22-.035-.39-.104-.514-.067-.124-.164-.187-.29-.187-.12 0-.219.062-.298.185a.887.887 0 0 0-.116.48zM11.262 9c.321 0 .567-.058.738-.173v-.71a.9.9 0 0 1-.552.207.619.619 0 0 1-.5-.215c-.12-.145-.181-.345-.181-.598 0-.26.063-.464.189-.612a.644.644 0 0 1 .516-.223c.194 0 .37.069.528.207v-.749c-.129-.09-.338-.134-.626-.134-.417 0-.751.14-1.001.422-.249.28-.373.662-.373 1.148 0 .42.116.764.349 1.03.232.267.537.4.913.4z"/></svg>'}),Ce=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 2L1 3v3l1 1h12l1-1V3l-1-1H2zm0 1h12v3H2V3zm-1 7l1-1h3l1 1v3l-1 1H2l-1-1v-3zm2 0H2v3h3v-3H3zm7 0l1-1h3l1 1v3l-1 1h-3l-1-1v-3zm2 0h-1v3h3v-3h-2z"/></svg>'}),Se=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 5h2V4H1.5l-.5.5v8l.5.5H4v-1H2V5zm12.5-1H12v1h2v7h-2v1h2.5l.5-.5v-8l-.5-.5zm-2.74 2.57L12 7v2.51l-.3.45-4.5 2h-.46l-2.5-1.5-.24-.43v-2.5l.3-.46 4.5-2h.46l2.5 1.5zM5 9.71l1.5.9V9.28L5 8.38v1.33zm.58-2.15l1.45.87 3.39-1.5-1.45-.87-3.39 1.5zm1.95 3.17l3.5-1.56v-1.4l-3.5 1.55v1.41z"/></svg>'});function be(e){return e[e.length-1]}function De(e){const t=document.createElement("template");return t.innerHTML=e,Array.from(t.content.childNodes)}function ze(e){return M(this,void 0,void 0,(function*(){const t=yield function(e){return M(this,void 0,void 0,(function*(){return(yield w.unified().use(L.default).use(_.default).use(V.default,{allowDangerousHtml:!0}).use(P.default).use(I.default).data("settings",{fragment:!0}).use(E.default,{detect:!0}).use(H.default,{rel:"noopener noreferrer",target:"_blank"}).use(R.default).process(e)).toString()}))}(e);return De(t)}))}const He=Object.fromEntries(Object.entries(o.CompletionItemKind).map((([e,t])=>[t,e.toLowerCase()]))),Ee=Object.fromEntries(Object.entries(o.CompletionItemKind).map((([e,t])=>[e.toLowerCase(),t]))),Pe=t.Facet.define({combine:be}),Ie=t.Facet.define({combine:be}),Re=t.Facet.define({combine:be});class _e{constructor(e,t){this.view=e,this.documentVersion=0;const n=this.view.state;this.client=n.facet(Pe),this.documentURI=e.state.facet(Ie),this.client.attachPlugin(this),this.openPromise=t?this.client.lsp.textDocumentOpened({textDocument:{text:n.doc.toString(),languageId:n.facet(Re),uri:this.documentURI,version:this.documentVersion}}):this.client.lsp.textDocumentChanged({textDocument:{uri:this.documentURI,version:this.nextDocumentVersion},contentChanges:[{text:n.doc.toString()}]})}get nextDocumentVersion(){return++this.documentVersion}update({docChanged:e,state:t}){return M(this,void 0,void 0,(function*(){e&&(yield this.openPromise,yield this.client.lsp.textDocumentChanged({textDocument:{uri:this.documentURI,version:this.nextDocumentVersion},contentChanges:[{text:t.doc.toString()}]}))}))}destroy(){this.client.detachPlugin(this)}requestFormatting(e){var n;return M(this,void 0,void 0,(function*(){if(!(null===(n=this.client.capabilities)||void 0===n?void 0:n.documentFormattingProvider))return null;const i=e.state,o=yield this.client.lsp.getDocumentFormatting({textDocument:{uri:this.documentURI},options:{insertSpaces:!0,tabSize:2,trimFinalNewlines:!0,insertFinalNewline:!0,trimTrailingWhitespace:!0}}),r=(null==o?void 0:o.map((e=>({from:G(i.doc,e.range.start)||0,to:G(i.doc,e.range.end),insert:e.newText}))))||[],s=function(e,n){let i=0;return n.reduce(((e,n)=>{if(n instanceof t.ChangeSet||Array.isArray(n)||!("from"in n))throw new Error("This function does not support ChangeSet or nested ChangeSpec");const o=i+n.from,r=i+((null==n?void 0:n.to)||0),s=n.insert||"";return i+=s.length-(r-o),e.slice(0,o)+s+e.slice(r)}),e)}(i.doc.toString(),r),l=z.diffChars(i.doc.toString(),s),a=[];let c=0;l.forEach((e=>{e.removed?(a.push({from:c,to:c+e.value.length}),c+=e.value.length):e.added?a.push({from:c,insert:e.value}):c+=e.value.length})),a.length&&e.dispatch({annotations:[t.Transaction.remote.of(!0),t.Transaction.addToHistory.of(!0)],changes:a})}))}requestHoverTooltip({state:{doc:e}},{line:t,character:n}){return M(this,void 0,void 0,(function*(){if(!this.client.capabilities.hoverProvider)return null;const i=yield this.client.lsp.getHoverInfo({textDocument:{uri:this.documentURI},position:{line:t,character:n}});if(!i)return null;const{contents:o,range:r}=i;let s=G(e,{line:t,character:n});const l=X(o),a=yield ze(l);if(0===a.length)return null;const c=document.createElement("div");let u;return c.id="root2",c.classList.add("documentation"),c.append(...a),r&&(s=G(e,r.start),u=G(e,r.end)),null===s?null:{pos:s,end:u,create:()=>({dom:c}),above:!0}}))}requestSignatureHelp(e,t,n,i){var r,s,l,a,c;return M(this,void 0,void 0,(function*(){if(!(null===(r=this.client.capabilities)||void 0===r?void 0:r.signatureHelpProvider))return null;const{state:u,pos:d,explicit:g}=e;if(g)return null;const v=u.doc.lineAt(d),h=v.text[d-v.from-1];let p,m=o.SignatureHelpTriggerKind.ContentChange;if((i&&(null===(l=null===(s=this.client.capabilities.signatureHelpProvider)||void 0===s?void 0:s.triggerCharacters)||void 0===l?void 0:l.includes(h))||n&&(null===(c=null===(a=this.client.capabilities.signatureHelpProvider)||void 0===a?void 0:a.retriggerCharacters)||void 0===c?void 0:c.includes(h)))&&(p=h,m=o.SignatureHelpTriggerKind.TriggerCharacter),!t&&m===o.SignatureHelpTriggerKind.ContentChange)return null;const f=Q(u.doc,d);return yield this.client.lsp.getSignatureHelp({position:f,textDocument:{uri:this.documentURI},context:{triggerKind:m,triggerCharacter:p,isRetrigger:n,activeSignatureHelp:t}})}))}requestCompletion(e,{line:t,character:n},{triggerKind:i,triggerCharacter:r}){return M(this,void 0,void 0,(function*(){if(!this.client.capabilities.completionProvider)return null;const s=yield this.client.lsp.getCompletion({textDocument:{uri:this.documentURI},position:{line:t,character:n},context:{triggerKind:i,triggerCharacter:r}});if(!s)return null;let a=("items"in s?s.items:s).map((e=>{const{detail:t,label:n,kind:i,textEdit:r,documentation:s,sortText:a,insertText:c,insertTextFormat:u,additionalTextEdits:d,filterText:g}=e;let v,h=null;r?(v=r.newText,v=(e,t)=>{const n=[],i=e.state;"range"in r?u===o.InsertTextFormat.Snippet||n.push({from:G(i.doc,r.range.start),to:G(i.doc,r.range.end),insert:r.newText}):console.error("Not supporting insert replace language server capability"),null==d||d.forEach((e=>{n.push({from:G(i.doc,e.range.start),to:G(i.doc,e.range.end),insert:e.newText})})),e.dispatch({annotations:l.pickedCompletion.of(t),changes:n})}):v=c?u===o.InsertTextFormat.Snippet?(e,t,n,i)=>{const o=c.indexOf("$0"),r=c.replace("$0",""),s=-1===o?void 0:n+o;e.dispatch({annotations:l.pickedCompletion.of(t),changes:[{from:n,to:i,insert:r}],selection:s?{head:s,anchor:s}:void 0})}:c:n;return{label:n,detail:t,apply:v,type:i&&He[i],sortText:null!=a?a:n,filterText:null!=g?g:n,info:()=>M(this,void 0,void 0,(function*(){let t,n=s;if(n||h||(h=yield this.client.lsp.getCompletionItemDetails(e)),(null==h?void 0:h.labelDetails)&&(t=h.label+h.labelDetails.detail+h.labelDetails.description),n=(null==h?void 0:h.documentation)||s||t,!n)return null;const i=X(n),o=yield ze(i);if(0===o.length)return null;const r=document.createElement("div");return r.id="root3",r.classList.add("documentation"),r.append(...o),r}))}}));if(0===a.length)return null;const[,c]=function(e){const t=new Set,n=new Set;for(const{label:i}of e){const[e,...o]=i;t.add(e);for(const e of o)n.add(e)}const i=Y(t)+Y(n)+"*$";return[new RegExp("^"+i),new RegExp(i)]}(a),u=e.matchBefore(c);let{pos:d}=e;if(u){const e=u.text.toLowerCase();d=u.from,/^\w+$/.test(e)&&(a=a.filter((({filterText:t})=>t.toLowerCase().startsWith(e))).sort((({label:e},{label:t})=>{switch(!0){case e.startsWith(u.text)&&!t.startsWith(u.text):return-1;case!e.startsWith(u.text)&&t.startsWith(u.text):return 1}return 0})))}const g=a.reduce(((e,t)=>Math.max(e,t.label.length)),0);return{from:d,options:a,validFor:e=>0!==e.length&&(!e.endsWith(".")&&(!e.endsWith(" ")&&!(e.length>g)))}}))}onDiagnostics(e){if(e.uri!==this.documentURI)return;const t=this.view.state,n=e.diagnostics.map((({range:e,message:n,severity:i})=>({from:G(t.doc,e.start),to:G(t.doc,e.end),severity:i&&{[o.DiagnosticSeverity.Error]:"error",[o.DiagnosticSeverity.Warning]:"warning",[o.DiagnosticSeverity.Information]:"info",[o.DiagnosticSeverity.Hint]:"info"}[i]||"info",message:n}))).filter((({from:e,to:t})=>null!==e&&null!==t&&void 0!==e&&void 0!==t)).sort(((e,t)=>{switch(!0){case e.from<t.from:return-1;case e.from>t.from:return 1}return 0}));this.view.dispatch(a.setDiagnostics(t,n))}}function Le(){const e=Object.fromEntries(Object.entries(Ee).map((([e,t])=>{const n=De(function(e){switch(e){case o.CompletionItemKind.Class:return oe;case o.CompletionItemKind.Color:return re;case o.CompletionItemKind.Constant:return Se;case o.CompletionItemKind.Constructor:return ve;case o.CompletionItemKind.Enum:return le;case o.CompletionItemKind.EnumMember:return se;case o.CompletionItemKind.Event:return ae;case o.CompletionItemKind.Field:return ce;case o.CompletionItemKind.File:return ue;case o.CompletionItemKind.Folder:return ne;case o.CompletionItemKind.Function:return ve;case o.CompletionItemKind.Interface:return de;case o.CompletionItemKind.Keyword:return ge;case o.CompletionItemKind.Method:return ve;case o.CompletionItemKind.Module:return he;case o.CompletionItemKind.Operator:return pe;case o.CompletionItemKind.Property:return fe;case o.CompletionItemKind.Reference:return ie;case o.CompletionItemKind.Snippet:return ye;case o.CompletionItemKind.Struct:return Ce;case o.CompletionItemKind.Text:return xe;case o.CompletionItemKind.TypeParameter:return me;case o.CompletionItemKind.Unit:return we;case o.CompletionItemKind.Value:return le;case o.CompletionItemKind.Variable:return Se}}(t).default),i=document.createElement("div");return i.classList.add("autocomplete-icon",`autocomplete-icon-${e}`),i.append(...n),[e,i]})));return{getImage(t){const n=e[t];if(n)return n.cloneNode(!0)}}}class Ve{constructor(e,t,n){this.view=e,this.getPlugin=t,this.setSignatureHelp=n}update(e){return M(this,void 0,void 0,(function*(){const t=this.getPlugin();if(!t)return;if(!e.transactions.some((e=>e.isUserEvent("select.pointer")))&&(e.docChanged||e.startState.selection.main.head!==e.state.selection.main.head)){yield t.update(e);const n=e.state.selection.main.head,i=new l.CompletionContext(e.state,n,!1);yield this.updateSignature(e.state,i,e.docChanged)}}))}updateSignature(e,t,n){return M(this,void 0,void 0,(function*(){const i=this.getPlugin();if(!i)return;const o=yield i.requestSignatureHelp(t,this.lastSignature,!!this.lastSignature,n);this.lastSignature=o||void 0;const r=o?yield this.getTooltip(e,o):null;this.setTooltip(r)}))}getTooltip(e,t){return M(this,void 0,void 0,(function*(){const n=void 0!==t.activeSignature?t.signatures[t.activeSignature]:void 0;if(!n)return null;n.activeParameter=void 0!==n.activeParameter?n.activeParameter:null==t?void 0:t.activeParameter;const i=X(n.documentation||""),o=yield ze(i),r=n.parameters&&void 0!==n.activeParameter?n.parameters[n.activeParameter]:void 0,s=X((null==r?void 0:r.documentation)||""),l=yield ze(s);if(0===o.length)return null;const a=document.createElement("div");a.id="root4",a.classList.add("documentation");const c=document.createElement("code");c.classList.add("signature-label"),c.innerHTML=function(e,t){if(void 0===e.activeParameter)return e.label;if(!e.parameters)return e.label;const n=e.parameters[e.activeParameter];if(!n)return e.label;const i="string"==typeof n.label?n.label:e.label.slice(n.label[0],n.label[1]);return e.label.replace(i,t(i))}(n,(e=>`<code class="selected-param">${e}</code>`)),0===o.length&&0===l.length||(c.innerHTML+="<br/><br/>"),a.appendChild(c),a.append(...o),0!==l.length&&a.append(...l);return{pos:e.selection.main.head,create:()=>({dom:a}),above:!0}}))}setTooltip(e){const t=this.setSignatureHelp.of(e);this.view.dispatch({effects:t})}}const Me=t.StateEffect.define(),Te=Me.of(null);function qe(e){const i=t.StateField.define({create:()=>null,update(e,t){if(t.isUserEvent("select.pointer"))return null;for(const e of t.effects)if(e.is(Me))return e.value;return e},provide:e=>n.showTooltip.compute(["selection",e],(t=>{if(!e)return null;const n=t.field(e);return n?(n.pos=t.selection.main.head,Object.assign({},n)):null}))});return[n.ViewPlugin.define((t=>new Ve(t,e,Me))),i]}const Oe={"data-gramm":"false",spellcheck:"false"};function ke(e){const i=new t.Compartment,o=new t.Compartment,r=new t.Compartment,s=new t.Compartment;return{state:t.EditorState.create({doc:e,extensions:[n.EditorView.contentAttributes.of(Oe),s.of([]),n.lineNumbers(),x.bracketMatching(),n.highlightActiveLineGutter(),n.highlightSpecialChars(),y.history(),n.scrollPastEnd(),t.EditorState.tabSize.of(2),n.drawSelection(),n.dropCursor(),l.closeBrackets(),x.indentOnInput(),n.highlightActiveLine(),n.keymap.of([...y.defaultKeymap,...l.closeBracketsKeymap,...y.historyKeymap,...x.foldKeymap,y.indentWithTab,{key:"Mod-s",run:()=>!0}]),o.of([]),r.of([]),i.of([]),x.syntaxHighlighting(C.classHighlighter)]}),languageExtensions:i,languageServiceExtensions:o,contentHandlingExtensions:r,editabilityExtensions:s}}const Ke=i.forwardRef((({content:r="",onContentChange:s,isReadOnly:a=!1,supportedLanguages:c,height:u,className:d="",autofocus:g,filename:v,languageClients:h,openFileInLanguageServer:p=!0},m)=>{const f=i.useRef(null),[w,y]=i.useState(),x=te(v,c),C=x&&(null==h?void 0:h[null==x?void 0:x.languageID]);return i.useImperativeHandle(m,(()=>({focus:()=>null==w?void 0:w.view.focus()})),[w]),i.useLayoutEffect((function(){if(!f.current)return;const{languageServiceExtensions:e,contentHandlingExtensions:t,languageExtensions:i,editabilityExtensions:o,state:s}=ke(r),l=new n.EditorView({state:s,parent:f.current});return y({view:l,languageServiceExtensions:e,contentHandlingExtensions:t,languageExtensions:i,editabilityExtensions:o}),g&&l.focus(),()=>{l.destroy(),y(void 0)}}),[g,r]),i.useEffect((function(){if(w&&(null==x?void 0:x.languageExtensions))return w.view.dispatch({effects:w.languageExtensions.reconfigure(x.languageExtensions)}),()=>{w.view.dispatch({effects:w.languageExtensions.reconfigure([])})}}),[w,x]),i.useEffect((function(){if(!w)return;const e=[t.EditorState.readOnly.of(a),n.EditorView.editable.of(!a)];return w.view.dispatch({effects:w.editabilityExtensions.reconfigure(e)}),()=>{w.view.dispatch({effects:w.editabilityExtensions.reconfigure([])})}}),[w,a]),i.useEffect((function(){if(!w)return;if(!s)return;const e=n.EditorView.updateListener.of((e=>{e.docChanged&&(null==s||s(e.state.doc.toString()))}));return w.view.dispatch({effects:w.contentHandlingExtensions.reconfigure(e)}),()=>{w.view.dispatch({effects:w.contentHandlingExtensions.reconfigure([])})}}),[w,s]),i.useEffect((function(){if(!w)return;if(!v)return;if(!C)return;const e=function(e){let i=null;const{getImage:r}=Le();return[Pe.of(e.client),Ie.of(e.documentURI),Re.of(e.client.languageID),n.ViewPlugin.define((t=>i=new _e(t,e.openFile))),t.Prec.highest(n.keymap.of([{key:"Mod-s",run:e=>(null==i||i.requestFormatting(e),!1)},{key:"Escape",run:e=>(e.dispatch({effects:[n.closeHoverTooltips,Te]}),!1)}])),qe((()=>i)),n.hoverTooltip(((e,t)=>M(this,void 0,void 0,(function*(){if(!i)return null;const n=Q(e.state.doc,t);return yield i.requestHoverTooltip(e,n)})))),l.autocompletion({activateOnTyping:!0,maxRenderedOptions:40,closeOnBlur:!1,icons:!1,addToOptions:[{render:e=>e.type?(e.iconCache||(e.iconCache=r(e.type)),e.iconCache||null):null,position:20}],override:[e=>M(this,void 0,void 0,(function*(){var t,n,r;if(!i)return null;const{state:s,pos:l,explicit:a}=e,c=s.doc.lineAt(l);let u,d=o.CompletionTriggerKind.Invoked;return!a&&(null===(r=null===(n=null===(t=i.client.capabilities)||void 0===t?void 0:t.completionProvider)||void 0===n?void 0:n.triggerCharacters)||void 0===r?void 0:r.includes(c.text[l-c.from-1]))&&(d=o.CompletionTriggerKind.TriggerCharacter,u=c.text[l-c.from-1]),yield i.requestCompletion(e,Q(s.doc,l),{triggerKind:d,triggerCharacter:u})}))]})]}({client:C,documentURI:Z(v),openFile:p});return w.view.dispatch({effects:w.languageServiceExtensions.reconfigure(e)}),()=>{w.view.dispatch({effects:w.languageServiceExtensions.reconfigure([])})}}),[w,C,v,p]),e.jsx("div",{className:`overflow-auto ${d}`,ref:f,style:Object.assign({},u&&{height:u})})}));Ke.displayName="CodeEditor",exports.CodeEditor=Ke,exports.getFileURI=Z,exports.getLanguageSetup=te,exports.getRootURI=ee,exports.useLanguageServer=function({supportedLanguages:e,session:t,debug:n,rootdir:o}){const[r,s]=i.useState(),[l,a]=i.useState(),{maybeEmptyPort:c,markPortAsNotEmpty:u}=function(){const[e,t]=i.useState(49152);return{maybeEmptyPort:e,markPortAsNotEmpty:i.useCallback((()=>{t(B)}),[])}}();return i.useEffect((function(){if(!(null==t?void 0:t.process))return;const i=new K(o,e,t,c,n);return s(i),i.start().then((e=>{null==e||e.exited.then((()=>{u(),s((e=>e===i?void 0:e))}))})).catch((e=>console.error("Error starting language server",e))),()=>{s((e=>e===i?void 0:e)),i.stop()}}),[t,n,c,u,e]),i.useEffect((function(){if(r)return a({process:r}),Promise.all(r.languages.map((e=>M(this,void 0,void 0,(function*(){try{const t=yield r.getConnectionString(e);if(!t)return;const{lsp:n,capabilities:i}=yield $({rootURI:ee(o),connectionString:t});return new q({languageID:e,capabilities:i,lsp:n})}catch(e){const t=e instanceof Error?e.message:JSON.stringify(e);console.error(t)}}))))).then((e=>{const t=e.reduce(((e,t)=>(t&&(e[t.languageID]=t),e)),{});a((e=>(null==e?void 0:e.process)===r?{process:e.process,clients:t}:e))})),()=>{a((e=>{if((null==e?void 0:e.process)!==r||!e.clients)return e;Object.values(e.clients).map((e=>e.close()))}))}}),[r,o]),null==l?void 0:l.clients};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import{jsx as e}from"react/jsx-runtime";import{ChangeSet as t,Facet as n,Transaction as r,StateEffect as o,StateField as i,Prec as s,Compartment as l,EditorState as a}from"@codemirror/state";import{showTooltip as c,ViewPlugin as u,keymap as d,closeHoverTooltips as v,hoverTooltip as h,EditorView as g,lineNumbers as p,highlightActiveLineGutter as m,highlightSpecialChars as f,scrollPastEnd as w,drawSelection as y,dropCursor as x,highlightActiveLine as z}from"@codemirror/view";import{useState as b,useCallback as S,useEffect as C,forwardRef as H,useRef as D,useImperativeHandle as P,useLayoutEffect as E}from"react";import{RegistrationRequest as _,UnregistrationRequest as L,InitializeRequest as V,InitializedNotification as M,ShutdownRequest as I,ExitNotification as O,LogMessageNotification as R,ShowMessageNotification as k,PublishDiagnosticsNotification as j,DidOpenTextDocumentNotification as T,DidCloseTextDocumentNotification as F,DidChangeTextDocumentNotification as $,WillSaveTextDocumentNotification as A,WillSaveTextDocumentWaitUntilRequest as N,DidSaveTextDocumentNotification as B,DidChangeConfigurationNotification as U,DidChangeWatchedFilesNotification as W,DocumentFormattingRequest as q,ApplyWorkspaceEditRequest as K,ExecuteCommandRequest as J,CompletionRequest as G,CompletionResolveRequest as Q,HoverRequest as X,SignatureHelpRequest as Y,DeclarationRequest as Z,DefinitionRequest as ee,TypeDefinitionRequest as te,ImplementationRequest as ne,ReferencesRequest as re,DocumentHighlightRequest as oe,DocumentSymbolRequest as ie,CodeActionRequest as se,CodeLensRequest as le,CodeLensResolveRequest as ae,DocumentLinkRequest as ce,DocumentLinkResolveRequest as ue,DocumentColorRequest as de,FoldingRangeRequest as ve,SelectionRangeRequest as he,WorkspaceSymbolRequest as ge,TextDocumentSyncKind as pe,DiagnosticTag as me,CompletionItemKind as fe,SignatureHelpTriggerKind as we,InsertTextFormat as ye,DiagnosticSeverity as xe,CompletionTriggerKind as ze}from"vscode-languageserver-protocol";import{Emitter as be,createMessageConnection as Se}from"vscode-ws-jsonrpc";import Ce from"path-browserify";import{pickedCompletion as He,CompletionContext as De,autocompletion as Pe,closeBrackets as Ee,closeBracketsKeymap as _e}from"@codemirror/autocomplete";import{setDiagnostics as Le}from"@codemirror/lint";import*as Ve from"diff";import Me from"rehype-external-links";import Ie from"rehype-highlight";import Oe from"rehype-raw";import Re from"rehype-sanitize";import ke from"rehype-stringify";import je from"remark-gfm";import Te from"remark-parse";import Fe from"remark-rehype";import{unified as $e}from"unified";import{history as Ae,defaultKeymap as Ne,historyKeymap as Be,indentWithTab as Ue}from"@codemirror/commands";import{bracketMatching as We,indentOnInput as qe,foldKeymap as Ke,syntaxHighlighting as Je}from"@codemirror/language";import{classHighlighter as Ge}from"@lezer/highlight";function Qe(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function l(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,l)}a((r=r.apply(e,t||[])).next())}))}class Xe{constructor(e,t=!1){this.logID=e,this.isEnabled=t}error(...e){console.error(`[${this.id()} ERROR]`,...e)}log(...e){this.isEnabled&&console.log(`[${this.id()}]`,...e)}id(){return"function"==typeof this.logID?this.logID():this.logID}}class Ye{constructor(e){this.plugins=[],this.languageID=e.languageID,this.lsp=e.lsp,this.capabilities=e.capabilities;const t=function(e,t="orange"){return function(...n){console.groupCollapsed(`%c[${e}]`,`color:${t};`,...n),console.trace(),console.groupEnd()}}(`LSP - ${this.languageID}`,"blue");this.lsp.onDiagnostics(this.processDiagnostics.bind(this)),this.lsp.onError((e=>{t("Error in language service",e)})),this.lsp.onLogMessage((e=>{})),this.lsp.onShowMessage((e=>{}))}close(){this.lsp.dispose()}attachPlugin(e){this.plugins.push(e)}detachPlugin(e){const t=this.plugins.indexOf(e);-1!==t&&this.plugins.splice(t,1)}processDiagnostics(e){for(const t of this.plugins)t.onDiagnostics(e)}}function Ze(){let e,t;const n=new Promise(((n,r)=>{e=n,t=r}));return{resolve:e,reject:t,promise:n}}function et(e){return null!=e}class tt{constructor(e,t,n,r,o){this.rootdir=e,this.session=n,this.port=r,this.isDestroyed=!1,this.isStarted=!1,this.started=Ze(),this.serverSetup=t.filter(et).filter((e=>!!e.languageServerCommand)),this.startCmd=`lsp-ws-proxy -l ${this.port} `+this.serverSetup.map((e=>`-- ${e.languageServerCommand} --stdio`)).join(" "),this.logger=new Xe("LanguageServer",o),this.logger.log("Language server initialized",this.serverSetup)}get languages(){return this.serverSetup.map((e=>e.languageID))}stop(){var e,t;return Qe(this,void 0,void 0,(function*(){this.isDestroyed||(this.isDestroyed=!0,this.logger.log("Closing..."),yield null===(e=this.languageServer)||void 0===e?void 0:e.kill(),this.logger.log(`Closed (processID ${null===(t=this.languageServer)||void 0===t?void 0:t.processID})`))}))}start(){return Qe(this,void 0,void 0,(function*(){if(this.isStarted)return yield this.started.promise,this.languageServer;this.isStarted=!0,this.logger.log("Opening...");const e=this.session.getHostname(this.port);if(!e)throw new Error("Cannot get session url");const t=`wss://${e}`;try{return this.languageServer=Object.assign(Object.assign({},yield function(e,t,n,r,o,i){return Qe(this,void 0,void 0,(function*(){if(!n)throw new Error("Cannot create process - process manager is not defined");const{resolve:s,promise:l}=Ze(),a=yield n.start({cmd:e,onStdout:r,onStderr:o,onExit:()=>{s()},rootdir:t,processID:i});return{exited:l,processID:a.processID,kill:a.kill,sendStdin:a.sendStdin}}))}(this.startCmd,this.rootdir,this.session.process,(e=>this.logger.log(`Output: ${e.line}`)),(e=>this.logger.error(`Error: ${e.line}`)))),{websocketURL:t}),this.logger.log(`Open (processID ${this.languageServer.processID})`),this.started.resolve(),this.languageServer}catch(e){throw this.started.reject(),e}}))}getConnectionString(e){return Qe(this,void 0,void 0,(function*(){const t=this.serverSetup.find((t=>t.languageID===e));if(!t)return;const n=yield this.start();return n?encodeURI(`${n.websocketURL}?name=${t.languageServerCommand}`):void 0}))}}const nt={"workspace/executeCommand":"executeCommandProvider","workspace/applyEdit":"workspace","textDocument/codeAction":"codeActionProvider","textDocument/codeLens":"codeLensProvider","textDocument/color":"colorProvider","textDocument/completion":"completionProvider","textDocument/declaration":"declarationProvider","textDocument/definition":"definitionProvider","textDocument/formatting":"documentFormattingProvider","textDocument/documentHighlight":"documentHighlightProvider","textDocument/documentLink":"documentLinkProvider","textDocument/onTypeFormatting":"documentOnTypeFormattingProvider","textDocument/rangeFormatting":"documentRangeFormattingProvider","textDocument/documentSymbol":"documentSymbolProvider","textDocument/executeCommand":"executeCommandProvider","textDocument/foldingRange":"foldingRangeProvider","textDocument/hover":"hoverProvider","textDocument/implementation":"implementationProvider","textDocument/references":"referencesProvider","textDocument/rename":"renameProvider","textDocument/signatureHelp":"signatureHelpProvider","textDocument/typeDefinition":"typeDefinitionProvider","textDocument/workspaceSymbol":"workspaceSymbolProvider"},rt=e=>{let t="initial";const n=[],r=new be,o=new be,i=new be,s=new be,l=e=>{"initial"===t?n.push({message:e}):"listening"===t&&s.fire(JSON.parse(e))},a=e=>{"initial"===t?n.push({error:e}):"listening"===t&&r.fire(e)},c=e=>l(e.data),u=e=>{1e3!==e.code&&a(new Error(`WebSocket Error (${e.code}): ${e.reason}`)),"listening"===t&&o.fire(),t="closed"};return e.addEventListener("message",c),e.addEventListener("close",u),{get onError(){return r.event},get onClose(){return o.event},get onPartialMessage(){return i.event},listen(e){if("initial"!==t)throw new Error("Already listening");const r=s.event(e);if(t="listening",0===n.length)return r;for(const e of n)e.message?l(e.message):e.error&&a(e.error);return n.length=0,r},dispose(){e.removeEventListener("message",c),e.removeEventListener("close",u),r.dispose(),o.dispose(),i.dispose(),n.length=0}}},ot=e=>{const t=new be,n=new be,r=()=>{n.fire()};e.addEventListener("close",r);let o=0;return{get onError(){return t.event},get onClose(){return n.event},write(n){return Qe(this,void 0,void 0,(function*(){try{e.send(JSON.stringify(n))}catch(e){t.fire([it(e),n,++o])}}))},end(){},dispose(){t.dispose(),n.dispose(),e.removeEventListener("close",r)}}},it=e=>e instanceof Error?e:new Error((null==e?void 0:e.message)||"Unknown error"),st=()=>({error:e=>console.error(e),warn:e=>console.warn(e),info:e=>console.info(e),log:e=>console.log(e)});function lt({rootURI:e,connectionString:t}){return Qe(this,void 0,void 0,(function*(){const n=new WebSocket(t),r=yield((e,t=st())=>new Promise((n=>{e.onopen=()=>{const r=Se(rt(e),ot(e),t);r.onDispose((()=>e.close())),r.onClose((()=>r.dispose())),n(r)}})))(n);r.listen();const o=(e=>{let t;e.onRequest(_.type,(({registrations:e})=>{for(const{method:n,registerOptions:r}of e){const e=nt[n];e&&(t[e]=null==r||r)}})),e.onRequest(L.type,(({unregisterations:e})=>{for(const{method:n}of e){const e=nt[n];e&&(t[e]=void 0)}}));const n=(t,n)=>(r,o)=>t()?e.sendRequest(n,r,o):Promise.resolve(null),r=(t,n)=>r=>t()?e.sendNotification(n,r):Promise.resolve(),o=t=>n=>e.sendNotification(t,n),i=t=>n=>{e.onNotification(t,n)};return{listen:()=>e.listen(),dispose:()=>e.dispose(),initialize:n=>Qe(void 0,void 0,void 0,(function*(){const r=yield e.sendRequest(V.type,n);return t=r.capabilities,r})),initialized:()=>e.sendNotification(M.type,{}),shutdown:()=>e.sendRequest(I.type),exit:()=>e.sendNotification(O.type),onError:t=>e.onError((([e,n,r])=>t(e,n,r))),onClose:t=>e.onClose((()=>t())),onLogMessage:i(R.type),onShowMessage:i(k.type),onDiagnostics:i(j.type),textDocumentOpened:o(T.type),textDocumentClosed:o(F.type),textDocumentChanged:o($.type),textDocumentWillSave:r((()=>{var e;const n=null!==(e=t.textDocumentSync)&&void 0!==e?e:pe.None;return"number"!=typeof n&&!!n.willSave}),A.type),getEditsBeforeSave:n((()=>{var e;const n=null!==(e=t.textDocumentSync)&&void 0!==e?e:pe.None;return"number"!=typeof n&&!!n.willSaveWaitUntil}),N.type),textDocumentSaved:r((()=>{var e;const n=null!==(e=t.textDocumentSync)&&void 0!==e?e:pe.None;return"number"==typeof n?n!==pe.None:!!n.save}),B.type),configurationChanged:o(U.type),watchedFilesChanged:o(W.type),getDocumentFormatting:n((()=>!!t.documentFormattingProvider),q.type),applyEdits:n((()=>!!t.workspace),K.type),executeCommand:n((()=>!!t.executeCommandProvider),J.type),getCompletion:n((()=>!!t.completionProvider),G.type),getCompletionItemDetails:n((()=>{var e;return!!(null===(e=t.completionProvider)||void 0===e?void 0:e.resolveProvider)}),Q.type),getHoverInfo:n((()=>!!t.hoverProvider),X.type),getSignatureHelp:n((()=>!!t.signatureHelpProvider),Y.type),getDeclaration:n((()=>!!t.declarationProvider),Z.type),getDefinition:n((()=>!!t.definitionProvider),ee.type),getTypeDefinition:n((()=>!!t.typeDefinitionProvider),te.type),getImplementation:n((()=>!!t.implementationProvider),ne.type),getReferences:n((()=>!!t.referencesProvider),re.type),getDocumentHighlight:n((()=>!!t.documentHighlightProvider),oe.type),getDocumentSymbol:n((()=>!!t.documentSymbolProvider),ie.type),getCodeAction:n((()=>!!t.codeActionProvider),se.type),getCodeLens:n((()=>!!t.codeLensProvider),le.type),resolveCodeLens:n((()=>{var e;return!!(null===(e=t.codeLensProvider)||void 0===e?void 0:e.resolveProvider)}),ae.type),getDocumentLink:n((()=>!!t.documentLinkProvider),ce.type),resolveDocumentLink:n((()=>{var e;return!!(null===(e=t.documentLinkProvider)||void 0===e?void 0:e.resolveProvider)}),ue.type),getColorSymbols:n((()=>!!t.colorProvider),de.type),getFoldingRanges:n((()=>!!t.foldingRangeProvider),ve.type),getSelectionRanges:n((()=>!!t.selectionRangeProvider),he.type),getWorkspaceSymbols:n((()=>!!t.workspaceSymbolProvider),ge.type),get syncsIncrementally(){var e,n;let r=null!==(e=t.textDocumentSync)&&void 0!==e?e:pe.None;return"number"!=typeof r&&(r=null!==(n=r.change)&&void 0!==n?n:pe.None),r===pe.Incremental},get completionTriggers(){var e;return(null===(e=t.completionProvider)||void 0===e?void 0:e.triggerCharacters)||[]},get signatureHelpTriggers(){var e;return(null===(e=t.signatureHelpProvider)||void 0===e?void 0:e.triggerCharacters)||[]},get signatureHelpRetriggers(){var e;return(null===(e=t.signatureHelpProvider)||void 0===e?void 0:e.retriggerCharacters)||[]}}})(r),{capabilities:i}=yield function(e,t){return Qe(this,void 0,void 0,(function*(){const n=yield e.initialize({capabilities:{textDocument:{synchronization:{dynamicRegistration:!0,didSave:!0},completion:{dynamicRegistration:!0,completionItem:{snippetSupport:!1,insertReplaceSupport:!1,commitCharactersSupport:!1,documentationFormat:["markdown","plaintext"],labelDetailsSupport:!0,deprecatedSupport:!0,preselectSupport:!0,resolveSupport:{properties:["documentation","detail"]}},contextSupport:!0},hover:{dynamicRegistration:!0,contentFormat:["markdown","plaintext"]},signatureHelp:{dynamicRegistration:!0,signatureInformation:{documentationFormat:["markdown","plaintext"],parameterInformation:{labelOffsetSupport:!0},activeParameterSupport:!0},contextSupport:!0},codeAction:{dynamicRegistration:!0},formatting:{dynamicRegistration:!0},rename:{dynamicRegistration:!0},publishDiagnostics:{versionSupport:!0,codeDescriptionSupport:!0,relatedInformation:!0,tagSupport:{valueSet:[me.Unnecessary,me.Deprecated]}},moniker:{}},workspace:{didChangeConfiguration:{dynamicRegistration:!0},didChangeWatchedFiles:{dynamicRegistration:!0}}},processId:null,rootUri:t,workspaceFolders:null});return e.initialized().catch((e=>console.error(e))),n}))}(o,e);return{lsp:o,capabilities:i}}))}const at=(ct=49152,ut=65535,function(e){return e>=ut?ct:e+1});var ct,ut;function dt(e,t){if(t.line>=e.lines)return e.length;const n=e.line(t.line+1).from+t.character;return n>e.length?e.length:n}function vt(e,t){const n=e.lineAt(t);return{line:n.number-1,character:t-n.from}}function ht(e){return Array.isArray(e)?e.map(ht).join("\n\n"):"string"==typeof e?e:e.value}function gt(e){let t="",n=Array.from(e).join("");return/\w/.test(n)&&(t+="\\w",n=n.replace(/\w/g,"")),`[${t}${n.replace(/[^\w\s]/g,"\\$&")}]`}function pt(e){if(!Ce.isAbsolute(e))throw new Error("filepath must be absolute");return`file://${e}`}function mt(e){return pt(e.endsWith("/")?e:e+"/")}function ft(e,t){return t.find((({fileExtensions:t})=>null==t?void 0:t.some((t=>e.endsWith(t)))))}function wt({supportedLanguages:e,session:t,debug:n,rootdir:r}){const[o,i]=b(),[s,l]=b(),{maybeEmptyPort:a,markPortAsNotEmpty:c}=function(){const[e,t]=b(49152);return{maybeEmptyPort:e,markPortAsNotEmpty:S((()=>{t(at)}),[])}}();return C((function(){if(!(null==t?void 0:t.process))return;const o=new tt(r,e,t,a,n);return i(o),o.start().then((e=>{null==e||e.exited.then((()=>{c(),i((e=>e===o?void 0:e))}))})).catch((e=>console.error("Error starting language server",e))),()=>{i((e=>e===o?void 0:e)),o.stop()}}),[t,n,a,c,e]),C((function(){if(o)return l({process:o}),Promise.all(o.languages.map((e=>Qe(this,void 0,void 0,(function*(){try{const t=yield o.getConnectionString(e);if(!t)return;const{lsp:n,capabilities:i}=yield lt({rootURI:mt(r),connectionString:t});return new Ye({languageID:e,capabilities:i,lsp:n})}catch(e){const t=e instanceof Error?e.message:JSON.stringify(e);console.error(t)}}))))).then((e=>{const t=e.reduce(((e,t)=>(t&&(e[t.languageID]=t),e)),{});l((e=>(null==e?void 0:e.process)===o?{process:e.process,clients:t}:e))})),()=>{l((e=>{if((null==e?void 0:e.process)!==o||!e.clients)return e;Object.values(e.clients).map((e=>e.close()))}))}}),[o,r]),null==s?void 0:s.clients}var yt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M14.5 3H7.71l-.85-.85L6.51 2h-5l-.5.5v11l.5.5h13l.5-.5v-10L14.5 3zm-.51 8.49V13h-12V7h4.49l.35-.15.86-.86H14v1.5l-.01 4zm0-6.49h-6.5l-.35.15-.86.86H2v-3h4.29l.85.85.36.15H14l-.01.99z"/></svg>'}),xt=Object.freeze({__proto__:null,default:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M11.105 4.561l-3.43 3.427-1.134-1.12 2.07-2.08h-4.8a2.4 2.4 0 1 0 0 4.8h.89v1.6h-.88a4 4 0 0 1 0-7.991h4.8L6.54 1.13 7.675 0l3.43 3.432v1.13zM16.62 24h-9.6l-.8-.8V10.412l.8-.8h9.6l.8.8V23.2l-.8.8zm-8.8-1.6h8V11.212h-8V22.4zm5.6-20.798h9.6l.8.8v12.786l-.8.8h-4v-1.6h3.2V3.2h-8v4.787h-1.6V2.401l.8-.8zm.8 11.186h-4.8v1.6h4.8v-1.6zm-4.8 3.2h4.8v1.6h-4.8v-1.6zm4.8 3.2h-4.8v1.6h4.8v-1.6zm1.6-14.4h4.8v1.6h-4.8v-1.6zm4.8 6.4h-1.6v1.6h1.6v-1.6zm-3.338-3.176v-.024h3.338v1.6h-1.762l-1.576-1.576z"/></svg>'}),zt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M11.34 9.71h.71l2.67-2.67v-.71L13.38 5h-.7l-1.82 1.81h-5V5.56l1.86-1.85V3l-2-2H5L1 5v.71l2 2h.71l1.14-1.15v5.79l.5.5H10v.52l1.33 1.34h.71l2.67-2.67v-.71L13.37 10h-.7l-1.86 1.85h-5v-4H10v.48l1.34 1.38zm1.69-3.65l.63.63-2 2-.63-.63 2-2zm0 5l.63.63-2 2-.63-.63 2-2zM3.35 6.65l-1.29-1.3 3.29-3.29 1.3 1.29-3.3 3.3z"/></svg>'}),bt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M8 1.003a7 7 0 0 0-7 7v.43c.09 1.51 1.91 1.79 3 .7a1.87 1.87 0 0 1 2.64 2.64c-1.1 1.16-.79 3.07.8 3.2h.6a7 7 0 1 0 0-14l-.04.03zm0 13h-.52a.58.58 0 0 1-.36-.14.56.56 0 0 1-.15-.3 1.24 1.24 0 0 1 .35-1.08 2.87 2.87 0 0 0 0-4 2.87 2.87 0 0 0-4.06 0 1 1 0 0 1-.9.34.41.41 0 0 1-.22-.12.42.42 0 0 1-.1-.29v-.37a6 6 0 1 1 6 6l-.04-.04zM9 3.997a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 7.007a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-7-5a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm7-1a1 1 0 1 1-2 0 1 1 0 0 1 2 0zM13 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"/></svg>'}),St=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3l1-1h6l1 1v5l-1 1h-4V8h4V3H8v3H7V3zm2 6V8L8 7H2L1 8v5l1 1h6l1-1V9zM8 8v5H2V8h6zm1.414-1L9 6.586V6h4v1H9.414zM9 4h4v1H9V4zm-2 6H3v1h4v-1z"/></svg>'}),Ct=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M14 2H8L7 3v3h1V3h6v5h-4v1h4l1-1V3l-1-1zM9 6h4v1H9.41L9 6.59V6zM7 7H2L1 8v5l1 1h6l1-1V8L8 7H7zm1 6H2V8h6v5zM3 9h4v1H3V9zm0 2h4v1H3v-1zm6-7h4v1H9V4z"/></svg>'}),Ht=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M7.414 1.56L8.312 1h3.294l.818 1.575L10.236 6h1.781l.72 1.695L5.618 15l-1.602-1.163L6.119 10H4.898L4 8.56l3.414-7zM7.78 9L4.9 14.305 12.018 7H8.312l3.294-5H8.312L4.898 9H7.78z"/></svg>'}),Dt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M14.45 4.5l-5-2.5h-.9l-7 3.5-.55.89v4.5l.55.9 5 2.5h.9l7-3.5.55-.9v-4.5l-.55-.89zm-8 8.64l-4.5-2.25V7.17l4.5 2v3.97zm.5-4.8L2.29 6.23l6.66-3.34 4.67 2.34-6.67 3.11zm7 1.55l-6.5 3.25V9.21l6.5-3v3.68z"/></svg>'}),Pt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M13.85 4.44l-3.28-3.3-.35-.14H2.5l-.5.5v13l.5.5h11l.5-.5V4.8l-.15-.36zM13 5h-3V2l3 3zM3 14V2h6v3.5l.5.5H13v8H3z"/></svg>'}),Et=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M11.496 4a3.49 3.49 0 0 0-3.46 3h-3.1a2 2 0 1 0 0 1h3.1a3.5 3.5 0 1 0 3.46-4zm0 6a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5z"/></svg>'}),_t=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M15 4h-5V3h5v1zm-1 3h-2v1h2V7zm-4 0H1v1h9V7zm2 6H1v1h11v-1zm-5-3H1v1h6v-1zm8 0h-5v1h5v-1zM8 2v3H1V2h7zM7 3H2v1h5V3z"/></svg>'}),Lt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M13.51 4l-5-3h-1l-5 3-.49.86v6l.49.85 5 3h1l5-3 .49-.85v-6L13.51 4zm-6 9.56l-4.5-2.7V5.7l4.5 2.45v5.41zM3.27 4.7l4.74-2.84 4.74 2.84-4.74 2.59L3.27 4.7zm9.74 6.16l-4.5 2.7V8.15l4.5-2.45v5.16z"/></svg>'}),Vt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M6 2.984V2h-.09c-.313 0-.616.062-.909.185a2.33 2.33 0 0 0-.775.53 2.23 2.23 0 0 0-.493.753v.001a3.542 3.542 0 0 0-.198.83v.002a6.08 6.08 0 0 0-.024.863c.012.29.018.58.018.869 0 .203-.04.393-.117.572v.001a1.504 1.504 0 0 1-.765.787 1.376 1.376 0 0 1-.558.115H2v.984h.09c.195 0 .38.04.556.121l.001.001c.178.078.329.184.455.318l.002.002c.13.13.233.285.307.465l.001.002c.078.18.117.368.117.566 0 .29-.006.58-.018.869-.012.296-.004.585.024.87v.001c.033.283.099.558.197.824v.001c.106.273.271.524.494.753.223.23.482.407.775.53.293.123.596.185.91.185H6v-.984h-.09c-.199 0-.387-.038-.562-.115a1.613 1.613 0 0 1-.457-.32 1.659 1.659 0 0 1-.309-.467c-.074-.18-.11-.37-.11-.573 0-.228.003-.453.011-.672.008-.228.008-.45 0-.665a4.639 4.639 0 0 0-.055-.64 2.682 2.682 0 0 0-.168-.609A2.284 2.284 0 0 0 3.522 8a2.284 2.284 0 0 0 .738-.955c.08-.192.135-.393.168-.602.033-.21.051-.423.055-.64.008-.22.008-.442 0-.666-.008-.224-.012-.45-.012-.678a1.47 1.47 0 0 1 .877-1.354 1.33 1.33 0 0 1 .563-.121H6zm4 10.032V14h.09c.313 0 .616-.062.909-.185.293-.123.552-.3.775-.53.223-.23.388-.48.493-.753v-.001c.1-.266.165-.543.198-.83v-.002c.028-.28.036-.567.024-.863-.012-.29-.018-.58-.018-.869 0-.203.04-.393.117-.572v-.001a1.504 1.504 0 0 1 .765-.787c.176-.077.362-.115.558-.115H14v-.984h-.09c-.195 0-.38-.04-.556-.121l-.001-.001a1.376 1.376 0 0 1-.455-.318l-.002-.002a1.414 1.414 0 0 1-.307-.465l-.001-.002a1.405 1.405 0 0 1-.117-.566c0-.29.006-.58.018-.869a6.19 6.19 0 0 0-.024-.87v-.001a3.542 3.542 0 0 0-.197-.824v-.001a2.23 2.23 0 0 0-.494-.753 2.33 2.33 0 0 0-.775-.53 2.325 2.325 0 0 0-.91-.185H10v.984h.09c.2 0 .386.038.562.115.174.082.326.188.457.32.127.134.23.29.309.467.074.18.11.37.11.573 0 .228-.003.452-.011.672-.008.228-.008.45 0 .665.004.222.022.435.055.64.033.214.089.416.168.609a2.282 2.282 0 0 0 .738.955 2.282 2.282 0 0 0-.738.955 2.7 2.7 0 0 0-.168.602c-.033.21-.051.423-.055.64-.008.22-.008.442 0 .666.008.224.012.45.012.678a1.47 1.47 0 0 1-.42 1.035 1.466 1.466 0 0 1-.457.319 1.33 1.33 0 0 1-.563.121H10z"/></svg>'}),Mt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2.873 1.1c.335.136.602.398.745.73.072.17.109.352.107.537a1.34 1.34 0 0 1-.61 1.135 1.359 1.359 0 0 1-.753.223A1.355 1.355 0 0 1 1 2.362a1.355 1.355 0 0 1 .83-1.256A1.37 1.37 0 0 1 2.873 1.1zm-.298 1.765a.551.551 0 0 0 .332-.5.548.548 0 1 0-.332.5zM6.43 1.109L1.11 6.43l.686.687 5.32-5.32-.686-.687zM11.5 9h1v2.5H15v1h-2.5V15h-1v-2.5H9v-1h2.5V9zm-5.732.525l.707.707L4.707 12l1.768 1.768-.707.707L4 12.707l-1.768 1.768-.707-.707L3.293 12l-1.768-1.768.707-.707L4 11.293l1.768-1.768zm1.35-4.195a1.353 1.353 0 0 0-1.256-.83 1.355 1.355 0 0 0-1.256.83 1.362 1.362 0 0 0 1.257 1.895A1.358 1.358 0 0 0 7.118 5.33zm-.753.745a.553.553 0 0 1-.289.29.547.547 0 0 1-.599-.117.529.529 0 0 1-.117-.173.544.544 0 0 1 .716-.715.565.565 0 0 1 .173.116.549.549 0 0 1 .116.599zM14 3h-4v1h4V3z"/></svg>'}),It=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M2.807 14.975a1.75 1.75 0 0 1-1.255-.556 1.684 1.684 0 0 1-.544-1.1A1.72 1.72 0 0 1 1.36 12.1c1.208-1.27 3.587-3.65 5.318-5.345a4.257 4.257 0 0 1 .048-3.078 4.095 4.095 0 0 1 1.665-1.969 4.259 4.259 0 0 1 4.04-.36l.617.268-2.866 2.951 1.255 1.259 2.944-2.877.267.619a4.295 4.295 0 0 1 .04 3.311 4.198 4.198 0 0 1-.923 1.392 4.27 4.27 0 0 1-.743.581 4.217 4.217 0 0 1-3.812.446c-1.098 1.112-3.84 3.872-5.32 5.254a1.63 1.63 0 0 1-1.084.423zm7.938-13.047a3.32 3.32 0 0 0-1.849.557c-.213.13-.412.284-.591.458a3.321 3.321 0 0 0-.657 3.733l.135.297-.233.227c-1.738 1.697-4.269 4.22-5.485 5.504a.805.805 0 0 0 .132 1.05.911.911 0 0 0 .298.22c.1.044.209.069.319.072a.694.694 0 0 0 .45-.181c1.573-1.469 4.612-4.539 5.504-5.44l.23-.232.294.135a3.286 3.286 0 0 0 3.225-.254 3.33 3.33 0 0 0 .591-.464 3.28 3.28 0 0 0 .964-2.358c0-.215-.021-.43-.064-.642L11.43 7.125 8.879 4.578l2.515-2.59a3.286 3.286 0 0 0-.65-.06z"/></svg>'}),Ot=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M4 1L3 2v12l1 1h8l1-1V2l-1-1H4zm0 2V2h8v12H4v-1h2v-1H4v-2h4V9H4V7h2V6H4V4h4V3H4z"/></svg>'}),Rt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2.5 1l-.5.5V13h1V2h11v11h1V1.5l-.5-.5h-12zM2 15v-1h1v1H2zm3-1H4v1h1v-1zm1 0h1v1H6v-1zm3 0H8v1h1v-1zm1 0h1v1h-1v-1zm5 1v-1h-1v1h1zm-3-1h1v1h-1v-1z"/></svg>'}),kt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 2L1 3v9l1 1h12l1-1V3l-1-1H2zm0 10V3h12v9H2zm3.356-3.07H6V7.22C6 6.408 5.685 6 5.056 6c-.135 0-.285.024-.45.073a1.444 1.444 0 0 0-.388.167v.665c.237-.203.487-.304.75-.304.261 0 .392.156.392.469l-.6.103c-.506.086-.76.406-.76.961 0 .263.061.473.183.631A.61.61 0 0 0 4.69 9c.29 0 .509-.16.657-.48h.009v.41zm.004-1.355v.193a.75.75 0 0 1-.12.436.368.368 0 0 1-.313.17.276.276 0 0 1-.22-.095.38.38 0 0 1-.08-.248c0-.222.11-.351.332-.389l.4-.067zM7.6 8.626h-.007v.31H7V5h.593v1.677h.008c.146-.31.355-.465.625-.465.248 0 .44.118.573.353.134.236.201.557.201.966 0 .443-.078.798-.235 1.067C8.61 8.866 8.4 9 8.138 9c-.237 0-.416-.125-.537-.374zm-.016-1.121v.272a.78.78 0 0 0 .107.426c.071.113.163.169.274.169.135 0 .24-.072.314-.216.075-.145.113-.35.113-.615 0-.22-.035-.39-.104-.514-.067-.124-.164-.187-.29-.187-.12 0-.219.062-.298.185a.887.887 0 0 0-.116.48zM11.262 9c.321 0 .567-.058.738-.173v-.71a.9.9 0 0 1-.552.207.619.619 0 0 1-.5-.215c-.12-.145-.181-.345-.181-.598 0-.26.063-.464.189-.612a.644.644 0 0 1 .516-.223c.194 0 .37.069.528.207v-.749c-.129-.09-.338-.134-.626-.134-.417 0-.751.14-1.001.422-.249.28-.373.662-.373 1.148 0 .42.116.764.349 1.03.232.267.537.4.913.4z"/></svg>'}),jt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 2L1 3v3l1 1h12l1-1V3l-1-1H2zm0 1h12v3H2V3zm-1 7l1-1h3l1 1v3l-1 1H2l-1-1v-3zm2 0H2v3h3v-3H3zm7 0l1-1h3l1 1v3l-1 1h-3l-1-1v-3zm2 0h-1v3h3v-3h-2z"/></svg>'}),Tt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 5h2V4H1.5l-.5.5v8l.5.5H4v-1H2V5zm12.5-1H12v1h2v7h-2v1h2.5l.5-.5v-8l-.5-.5zm-2.74 2.57L12 7v2.51l-.3.45-4.5 2h-.46l-2.5-1.5-.24-.43v-2.5l.3-.46 4.5-2h.46l2.5 1.5zM5 9.71l1.5.9V9.28L5 8.38v1.33zm.58-2.15l1.45.87 3.39-1.5-1.45-.87-3.39 1.5zm1.95 3.17l3.5-1.56v-1.4l-3.5 1.55v1.41z"/></svg>'});function Ft(e){return e[e.length-1]}function $t(e){const t=document.createElement("template");return t.innerHTML=e,Array.from(t.content.childNodes)}function At(e){return Qe(this,void 0,void 0,(function*(){const t=yield function(e){return Qe(this,void 0,void 0,(function*(){return(yield $e().use(Te).use(je).use(Fe,{allowDangerousHtml:!0}).use(Oe).use(Re).data("settings",{fragment:!0}).use(Ie,{detect:!0}).use(Me,{rel:"noopener noreferrer",target:"_blank"}).use(ke).process(e)).toString()}))}(e);return $t(t)}))}const Nt=Object.fromEntries(Object.entries(fe).map((([e,t])=>[t,e.toLowerCase()]))),Bt=Object.fromEntries(Object.entries(fe).map((([e,t])=>[e.toLowerCase(),t]))),Ut=n.define({combine:Ft}),Wt=n.define({combine:Ft}),qt=n.define({combine:Ft});class Kt{constructor(e,t){this.view=e,this.documentVersion=0;const n=this.view.state;this.client=n.facet(Ut),this.documentURI=e.state.facet(Wt),this.client.attachPlugin(this),this.openPromise=t?this.client.lsp.textDocumentOpened({textDocument:{text:n.doc.toString(),languageId:n.facet(qt),uri:this.documentURI,version:this.documentVersion}}):this.client.lsp.textDocumentChanged({textDocument:{uri:this.documentURI,version:this.nextDocumentVersion},contentChanges:[{text:n.doc.toString()}]})}get nextDocumentVersion(){return++this.documentVersion}update({docChanged:e,state:t}){return Qe(this,void 0,void 0,(function*(){e&&(yield this.openPromise,yield this.client.lsp.textDocumentChanged({textDocument:{uri:this.documentURI,version:this.nextDocumentVersion},contentChanges:[{text:t.doc.toString()}]}))}))}destroy(){this.client.detachPlugin(this)}requestFormatting(e){var n;return Qe(this,void 0,void 0,(function*(){if(!(null===(n=this.client.capabilities)||void 0===n?void 0:n.documentFormattingProvider))return null;const o=e.state,i=yield this.client.lsp.getDocumentFormatting({textDocument:{uri:this.documentURI},options:{insertSpaces:!0,tabSize:2,trimFinalNewlines:!0,insertFinalNewline:!0,trimTrailingWhitespace:!0}}),s=(null==i?void 0:i.map((e=>({from:dt(o.doc,e.range.start)||0,to:dt(o.doc,e.range.end),insert:e.newText}))))||[],l=function(e,n){let r=0;return n.reduce(((e,n)=>{if(n instanceof t||Array.isArray(n)||!("from"in n))throw new Error("This function does not support ChangeSet or nested ChangeSpec");const o=r+n.from,i=r+((null==n?void 0:n.to)||0),s=n.insert||"";return r+=s.length-(i-o),e.slice(0,o)+s+e.slice(i)}),e)}(o.doc.toString(),s),a=Ve.diffChars(o.doc.toString(),l),c=[];let u=0;a.forEach((e=>{e.removed?(c.push({from:u,to:u+e.value.length}),u+=e.value.length):e.added?c.push({from:u,insert:e.value}):u+=e.value.length})),c.length&&e.dispatch({annotations:[r.remote.of(!0),r.addToHistory.of(!0)],changes:c})}))}requestHoverTooltip({state:{doc:e}},{line:t,character:n}){return Qe(this,void 0,void 0,(function*(){if(!this.client.capabilities.hoverProvider)return null;const r=yield this.client.lsp.getHoverInfo({textDocument:{uri:this.documentURI},position:{line:t,character:n}});if(!r)return null;const{contents:o,range:i}=r;let s=dt(e,{line:t,character:n});const l=ht(o),a=yield At(l);if(0===a.length)return null;const c=document.createElement("div");let u;return c.id="root2",c.classList.add("documentation"),c.append(...a),i&&(s=dt(e,i.start),u=dt(e,i.end)),null===s?null:{pos:s,end:u,create:()=>({dom:c}),above:!0}}))}requestSignatureHelp(e,t,n,r){var o,i,s,l,a;return Qe(this,void 0,void 0,(function*(){if(!(null===(o=this.client.capabilities)||void 0===o?void 0:o.signatureHelpProvider))return null;const{state:c,pos:u,explicit:d}=e;if(d)return null;const v=c.doc.lineAt(u),h=v.text[u-v.from-1];let g,p=we.ContentChange;if((r&&(null===(s=null===(i=this.client.capabilities.signatureHelpProvider)||void 0===i?void 0:i.triggerCharacters)||void 0===s?void 0:s.includes(h))||n&&(null===(a=null===(l=this.client.capabilities.signatureHelpProvider)||void 0===l?void 0:l.retriggerCharacters)||void 0===a?void 0:a.includes(h)))&&(g=h,p=we.TriggerCharacter),!t&&p===we.ContentChange)return null;const m=vt(c.doc,u);return yield this.client.lsp.getSignatureHelp({position:m,textDocument:{uri:this.documentURI},context:{triggerKind:p,triggerCharacter:g,isRetrigger:n,activeSignatureHelp:t}})}))}requestCompletion(e,{line:t,character:n},{triggerKind:r,triggerCharacter:o}){return Qe(this,void 0,void 0,(function*(){if(!this.client.capabilities.completionProvider)return null;const i=yield this.client.lsp.getCompletion({textDocument:{uri:this.documentURI},position:{line:t,character:n},context:{triggerKind:r,triggerCharacter:o}});if(!i)return null;let s=("items"in i?i.items:i).map((e=>{const{detail:t,label:n,kind:r,textEdit:o,documentation:i,sortText:s,insertText:l,insertTextFormat:a,additionalTextEdits:c,filterText:u}=e;let d,v=null;o?(d=o.newText,d=(e,t)=>{const n=[],r=e.state;"range"in o?a===ye.Snippet||n.push({from:dt(r.doc,o.range.start),to:dt(r.doc,o.range.end),insert:o.newText}):console.error("Not supporting insert replace language server capability"),null==c||c.forEach((e=>{n.push({from:dt(r.doc,e.range.start),to:dt(r.doc,e.range.end),insert:e.newText})})),e.dispatch({annotations:He.of(t),changes:n})}):d=l?a===ye.Snippet?(e,t,n,r)=>{const o=l.indexOf("$0"),i=l.replace("$0",""),s=-1===o?void 0:n+o;e.dispatch({annotations:He.of(t),changes:[{from:n,to:r,insert:i}],selection:s?{head:s,anchor:s}:void 0})}:l:n;return{label:n,detail:t,apply:d,type:r&&Nt[r],sortText:null!=s?s:n,filterText:null!=u?u:n,info:()=>Qe(this,void 0,void 0,(function*(){let t,n=i;if(n||v||(v=yield this.client.lsp.getCompletionItemDetails(e)),(null==v?void 0:v.labelDetails)&&(t=v.label+v.labelDetails.detail+v.labelDetails.description),n=(null==v?void 0:v.documentation)||i||t,!n)return null;const r=ht(n),o=yield At(r);if(0===o.length)return null;const s=document.createElement("div");return s.id="root3",s.classList.add("documentation"),s.append(...o),s}))}}));if(0===s.length)return null;const[,l]=function(e){const t=new Set,n=new Set;for(const{label:r}of e){const[e,...o]=r;t.add(e);for(const e of o)n.add(e)}const r=gt(t)+gt(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}(s),a=e.matchBefore(l);let{pos:c}=e;if(a){const e=a.text.toLowerCase();c=a.from,/^\w+$/.test(e)&&(s=s.filter((({filterText:t})=>t.toLowerCase().startsWith(e))).sort((({label:e},{label:t})=>{switch(!0){case e.startsWith(a.text)&&!t.startsWith(a.text):return-1;case!e.startsWith(a.text)&&t.startsWith(a.text):return 1}return 0})))}const u=s.reduce(((e,t)=>Math.max(e,t.label.length)),0);return{from:c,options:s,validFor:e=>0!==e.length&&(!e.endsWith(".")&&(!e.endsWith(" ")&&!(e.length>u)))}}))}onDiagnostics(e){if(e.uri!==this.documentURI)return;const t=this.view.state,n=e.diagnostics.map((({range:e,message:n,severity:r})=>({from:dt(t.doc,e.start),to:dt(t.doc,e.end),severity:r&&{[xe.Error]:"error",[xe.Warning]:"warning",[xe.Information]:"info",[xe.Hint]:"info"}[r]||"info",message:n}))).filter((({from:e,to:t})=>null!==e&&null!==t&&void 0!==e&&void 0!==t)).sort(((e,t)=>{switch(!0){case e.from<t.from:return-1;case e.from>t.from:return 1}return 0}));this.view.dispatch(Le(t,n))}}function Jt(){const e=Object.fromEntries(Object.entries(Bt).map((([e,t])=>{const n=$t(function(e){switch(e){case fe.Class:return zt;case fe.Color:return bt;case fe.Constant:return Tt;case fe.Constructor:return Lt;case fe.Enum:return Ct;case fe.EnumMember:return St;case fe.Event:return Ht;case fe.Field:return Dt;case fe.File:return Pt;case fe.Folder:return yt;case fe.Function:return Lt;case fe.Interface:return Et;case fe.Keyword:return _t;case fe.Method:return Lt;case fe.Module:return Vt;case fe.Operator:return Mt;case fe.Property:return It;case fe.Reference:return xt;case fe.Snippet:return Rt;case fe.Struct:return jt;case fe.Text:return kt;case fe.TypeParameter:return zt;case fe.Unit:return Ot;case fe.Value:return Ct;case fe.Variable:return Tt}}(t).default),r=document.createElement("div");return r.classList.add("autocomplete-icon",`autocomplete-icon-${e}`),r.append(...n),[e,r]})));return{getImage(t){const n=e[t];if(n)return n.cloneNode(!0)}}}class Gt{constructor(e,t,n){this.view=e,this.getPlugin=t,this.setSignatureHelp=n}update(e){return Qe(this,void 0,void 0,(function*(){const t=this.getPlugin();if(!t)return;if(!e.transactions.some((e=>e.isUserEvent("select.pointer")))&&(e.docChanged||e.startState.selection.main.head!==e.state.selection.main.head)){yield t.update(e);const n=e.state.selection.main.head,r=new De(e.state,n,!1);yield this.updateSignature(e.state,r,e.docChanged)}}))}updateSignature(e,t,n){return Qe(this,void 0,void 0,(function*(){const r=this.getPlugin();if(!r)return;const o=yield r.requestSignatureHelp(t,this.lastSignature,!!this.lastSignature,n);this.lastSignature=o||void 0;const i=o?yield this.getTooltip(e,o):null;this.setTooltip(i)}))}getTooltip(e,t){return Qe(this,void 0,void 0,(function*(){const n=void 0!==t.activeSignature?t.signatures[t.activeSignature]:void 0;if(!n)return null;n.activeParameter=void 0!==n.activeParameter?n.activeParameter:null==t?void 0:t.activeParameter;const r=ht(n.documentation||""),o=yield At(r),i=n.parameters&&void 0!==n.activeParameter?n.parameters[n.activeParameter]:void 0,s=ht((null==i?void 0:i.documentation)||""),l=yield At(s);if(0===o.length)return null;const a=document.createElement("div");a.id="root4",a.classList.add("documentation");const c=document.createElement("code");c.classList.add("signature-label"),c.innerHTML=function(e,t){if(void 0===e.activeParameter)return e.label;if(!e.parameters)return e.label;const n=e.parameters[e.activeParameter];if(!n)return e.label;const r="string"==typeof n.label?n.label:e.label.slice(n.label[0],n.label[1]);return e.label.replace(r,t(r))}(n,(e=>`<code class="selected-param">${e}</code>`)),0===o.length&&0===l.length||(c.innerHTML+="<br/><br/>"),a.appendChild(c),a.append(...o),0!==l.length&&a.append(...l);return{pos:e.selection.main.head,create:()=>({dom:a}),above:!0}}))}setTooltip(e){const t=this.setSignatureHelp.of(e);this.view.dispatch({effects:t})}}const Qt=o.define(),Xt=Qt.of(null);function Yt(e){const t=i.define({create:()=>null,update(e,t){if(t.isUserEvent("select.pointer"))return null;for(const e of t.effects)if(e.is(Qt))return e.value;return e},provide:e=>c.compute(["selection",e],(t=>{if(!e)return null;const n=t.field(e);return n?(n.pos=t.selection.main.head,Object.assign({},n)):null}))});return[u.define((t=>new Gt(t,e,Qt))),t]}const Zt={"data-gramm":"false",spellcheck:"false"};const en=H((({content:t="",onContentChange:n,isReadOnly:r=!1,supportedLanguages:o,height:i,className:c="",autofocus:S,filename:H,languageClients:_,openFileInLanguageServer:L=!0},V)=>{const M=D(null),[I,O]=b(),R=ft(H,o),k=R&&(null==_?void 0:_[null==R?void 0:R.languageID]);return P(V,(()=>({focus:()=>null==I?void 0:I.view.focus()})),[I]),E((function(){if(!M.current)return;const{languageServiceExtensions:e,contentHandlingExtensions:n,languageExtensions:r,editabilityExtensions:o,state:i}=function(e){const t=new l,n=new l,r=new l,o=new l;return{state:a.create({doc:e,extensions:[g.contentAttributes.of(Zt),o.of([]),p(),We(),m(),f(),Ae(),w(),a.tabSize.of(2),y(),x(),Ee(),qe(),z(),d.of([...Ne,..._e,...Be,...Ke,Ue,{key:"Mod-s",run:()=>!0}]),n.of([]),r.of([]),t.of([]),Je(Ge)]}),languageExtensions:t,languageServiceExtensions:n,contentHandlingExtensions:r,editabilityExtensions:o}}(t),s=new g({state:i,parent:M.current});return O({view:s,languageServiceExtensions:e,contentHandlingExtensions:n,languageExtensions:r,editabilityExtensions:o}),S&&s.focus(),()=>{s.destroy(),O(void 0)}}),[S,t]),C((function(){if(I&&(null==R?void 0:R.languageExtensions))return I.view.dispatch({effects:I.languageExtensions.reconfigure(R.languageExtensions)}),()=>{I.view.dispatch({effects:I.languageExtensions.reconfigure([])})}}),[I,R]),C((function(){if(!I)return;const e=[a.readOnly.of(r),g.editable.of(!r)];return I.view.dispatch({effects:I.editabilityExtensions.reconfigure(e)}),()=>{I.view.dispatch({effects:I.editabilityExtensions.reconfigure([])})}}),[I,r]),C((function(){if(!I)return;if(!n)return;const e=g.updateListener.of((e=>{e.docChanged&&(null==n||n(e.state.doc.toString()))}));return I.view.dispatch({effects:I.contentHandlingExtensions.reconfigure(e)}),()=>{I.view.dispatch({effects:I.contentHandlingExtensions.reconfigure([])})}}),[I,n]),C((function(){if(!I)return;if(!H)return;if(!k)return;const e=function(e){let t=null;const{getImage:n}=Jt();return[Ut.of(e.client),Wt.of(e.documentURI),qt.of(e.client.languageID),u.define((n=>t=new Kt(n,e.openFile))),s.highest(d.of([{key:"Mod-s",run:e=>(null==t||t.requestFormatting(e),!1)},{key:"Escape",run:e=>(e.dispatch({effects:[v,Xt]}),!1)}])),Yt((()=>t)),h(((e,n)=>Qe(this,void 0,void 0,(function*(){if(!t)return null;const r=vt(e.state.doc,n);return yield t.requestHoverTooltip(e,r)})))),Pe({activateOnTyping:!0,maxRenderedOptions:40,closeOnBlur:!1,icons:!1,addToOptions:[{render:e=>e.type?(e.iconCache||(e.iconCache=n(e.type)),e.iconCache||null):null,position:20}],override:[e=>Qe(this,void 0,void 0,(function*(){var n,r,o;if(!t)return null;const{state:i,pos:s,explicit:l}=e,a=i.doc.lineAt(s);let c,u=ze.Invoked;return!l&&(null===(o=null===(r=null===(n=t.client.capabilities)||void 0===n?void 0:n.completionProvider)||void 0===r?void 0:r.triggerCharacters)||void 0===o?void 0:o.includes(a.text[s-a.from-1]))&&(u=ze.TriggerCharacter,c=a.text[s-a.from-1]),yield t.requestCompletion(e,vt(i.doc,s),{triggerKind:u,triggerCharacter:c})}))]})]}({client:k,documentURI:pt(H),openFile:L});return I.view.dispatch({effects:I.languageServiceExtensions.reconfigure(e)}),()=>{I.view.dispatch({effects:I.languageServiceExtensions.reconfigure([])})}}),[I,k,H,L]),e("div",{className:`overflow-auto ${c}`,ref:M,style:Object.assign({},i&&{height:i})})}));en.displayName="CodeEditor";export{en as CodeEditor,pt as getFileURI,ft as getLanguageSetup,mt as getRootURI,wt as useLanguageServer};
import{jsx as e}from"react/jsx-runtime";import{ChangeSet as t,Facet as n,Transaction as r,StateEffect as o,StateField as i,Prec as s,Compartment as l,EditorState as a}from"@codemirror/state";import{showTooltip as c,ViewPlugin as u,keymap as d,closeHoverTooltips as v,hoverTooltip as g,EditorView as h,lineNumbers as p,highlightActiveLineGutter as m,highlightSpecialChars as f,scrollPastEnd as w,drawSelection as y,dropCursor as x,highlightActiveLine as z}from"@codemirror/view";import{useState as b,useCallback as H,useEffect as C,forwardRef as S,useRef as D,useImperativeHandle as P,useLayoutEffect as _}from"react";import{RegistrationRequest as E,UnregistrationRequest as L,InitializeRequest as V,InitializedNotification as M,ShutdownRequest as I,ExitNotification as O,LogMessageNotification as R,ShowMessageNotification as k,PublishDiagnosticsNotification as j,DidOpenTextDocumentNotification as T,DidCloseTextDocumentNotification as F,DidChangeTextDocumentNotification as $,WillSaveTextDocumentNotification as A,WillSaveTextDocumentWaitUntilRequest as B,DidSaveTextDocumentNotification as N,DidChangeConfigurationNotification as U,DidChangeWatchedFilesNotification as W,DocumentFormattingRequest as q,ApplyWorkspaceEditRequest as K,ExecuteCommandRequest as J,CompletionRequest as G,CompletionResolveRequest as Q,HoverRequest as X,SignatureHelpRequest as Y,DeclarationRequest as Z,DefinitionRequest as ee,TypeDefinitionRequest as te,ImplementationRequest as ne,ReferencesRequest as re,DocumentHighlightRequest as oe,DocumentSymbolRequest as ie,CodeActionRequest as se,CodeLensRequest as le,CodeLensResolveRequest as ae,DocumentLinkRequest as ce,DocumentLinkResolveRequest as ue,DocumentColorRequest as de,FoldingRangeRequest as ve,SelectionRangeRequest as ge,WorkspaceSymbolRequest as he,TextDocumentSyncKind as pe,DiagnosticTag as me,CompletionItemKind as fe,SignatureHelpTriggerKind as we,InsertTextFormat as ye,DiagnosticSeverity as xe,CompletionTriggerKind as ze}from"vscode-languageserver-protocol";import{Emitter as be,createMessageConnection as He}from"vscode-ws-jsonrpc";import Ce from"path-browserify";import{pickedCompletion as Se,CompletionContext as De,autocompletion as Pe,closeBrackets as _e,closeBracketsKeymap as Ee}from"@codemirror/autocomplete";import{setDiagnostics as Le}from"@codemirror/lint";import*as Ve from"diff";import Me from"rehype-external-links";import Ie from"rehype-highlight";import Oe from"rehype-raw";import Re from"rehype-sanitize";import ke from"rehype-stringify";import je from"remark-gfm";import Te from"remark-parse";import Fe from"remark-rehype";import{unified as $e}from"unified";import{history as Ae,defaultKeymap as Be,historyKeymap as Ne,indentWithTab as Ue}from"@codemirror/commands";import{bracketMatching as We,indentOnInput as qe,foldKeymap as Ke,syntaxHighlighting as Je}from"@codemirror/language";import{classHighlighter as Ge}from"@lezer/highlight";function Qe(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function l(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,l)}a((r=r.apply(e,t||[])).next())}))}class Xe{constructor(e,t=!1){this.logID=e,this.isEnabled=t}error(...e){console.error(`[${this.id()} ERROR]`,...e)}log(...e){this.isEnabled&&console.log(`[${this.id()}]`,...e)}id(){return"function"==typeof this.logID?this.logID():this.logID}}class Ye{constructor(e){this.plugins=[],this.languageID=e.languageID,this.lsp=e.lsp,this.capabilities=e.capabilities;const t=function(e,t="orange"){return function(...n){console.groupCollapsed(`%c[${e}]`,`color:${t};`,...n),console.trace(),console.groupEnd()}}(`LSP - ${this.languageID}`,"blue");this.lsp.onDiagnostics(this.processDiagnostics.bind(this)),this.lsp.onError((e=>{t("Error in language service",e)})),this.lsp.onLogMessage((e=>{})),this.lsp.onShowMessage((e=>{}))}close(){this.lsp.dispose()}attachPlugin(e){this.plugins.push(e)}detachPlugin(e){const t=this.plugins.indexOf(e);-1!==t&&this.plugins.splice(t,1)}processDiagnostics(e){for(const t of this.plugins)t.onDiagnostics(e)}}function Ze(){let e,t;const n=new Promise(((n,r)=>{e=n,t=r}));return{resolve:e,reject:t,promise:n}}function et(e){return null!=e}class tt{constructor(e,t,n,r,o){this.rootdir=e,this.session=n,this.port=r,this.isDestroyed=!1,this.isStarted=!1,this.started=Ze(),this.serverSetup=t.filter(et).filter((e=>!!e.languageServerCommand)),this.startCmd=`lsp-ws-proxy -l ${this.port} `+this.serverSetup.map((e=>`-- ${e.languageServerCommand} --stdio`)).join(" "),this.logger=new Xe("LanguageServer",o),this.logger.log("Language server initialized",this.serverSetup)}get languages(){return this.serverSetup.map((e=>e.languageID))}stop(){var e,t;return Qe(this,void 0,void 0,(function*(){this.isDestroyed||(this.isDestroyed=!0,this.logger.log("Closing..."),yield null===(e=this.languageServer)||void 0===e?void 0:e.kill(),this.logger.log(`Closed (processID ${null===(t=this.languageServer)||void 0===t?void 0:t.processID})`))}))}start(){return Qe(this,void 0,void 0,(function*(){if(this.isStarted)return yield this.started.promise,this.languageServer;this.isStarted=!0,this.logger.log("Opening...");const e=this.session.getHostname(this.port);if(!e)throw new Error("Cannot get session url");const t=`wss://${e}`;try{return this.languageServer=Object.assign(Object.assign({},yield function(e,t,n,r,o,i){return Qe(this,void 0,void 0,(function*(){if(!n)throw new Error("Cannot create process - process manager is not defined");const{resolve:s,promise:l}=Ze(),a=yield n.start({cmd:e,onStdout:r,onStderr:o,onExit:()=>{s()},rootdir:t,processID:i});return{exited:l,processID:a.processID,kill:a.kill,sendStdin:a.sendStdin}}))}(this.startCmd,this.rootdir,this.session.process,(e=>this.logger.log(`Output: ${e.line}`)),(e=>this.logger.error(`Error: ${e.line}`)))),{websocketURL:t}),this.logger.log(`Open (processID ${this.languageServer.processID})`),this.started.resolve(),this.languageServer}catch(e){throw this.started.reject(),e}}))}getConnectionString(e){return Qe(this,void 0,void 0,(function*(){const t=this.serverSetup.find((t=>t.languageID===e));if(!t)return;const n=yield this.start();return n?encodeURI(`${n.websocketURL}?name=${t.languageServerCommand}`):void 0}))}}const nt={"workspace/executeCommand":"executeCommandProvider","workspace/applyEdit":"workspace","textDocument/codeAction":"codeActionProvider","textDocument/codeLens":"codeLensProvider","textDocument/color":"colorProvider","textDocument/completion":"completionProvider","textDocument/declaration":"declarationProvider","textDocument/definition":"definitionProvider","textDocument/formatting":"documentFormattingProvider","textDocument/documentHighlight":"documentHighlightProvider","textDocument/documentLink":"documentLinkProvider","textDocument/onTypeFormatting":"documentOnTypeFormattingProvider","textDocument/rangeFormatting":"documentRangeFormattingProvider","textDocument/documentSymbol":"documentSymbolProvider","textDocument/executeCommand":"executeCommandProvider","textDocument/foldingRange":"foldingRangeProvider","textDocument/hover":"hoverProvider","textDocument/implementation":"implementationProvider","textDocument/references":"referencesProvider","textDocument/rename":"renameProvider","textDocument/signatureHelp":"signatureHelpProvider","textDocument/typeDefinition":"typeDefinitionProvider","textDocument/workspaceSymbol":"workspaceSymbolProvider"},rt=e=>{let t="initial";const n=[],r=new be,o=new be,i=new be,s=new be,l=e=>{"initial"===t?n.push({message:e}):"listening"===t&&s.fire(JSON.parse(e))},a=e=>{"initial"===t?n.push({error:e}):"listening"===t&&r.fire(e)},c=e=>l(e.data),u=e=>{1e3!==e.code&&a(new Error(`WebSocket Error (${e.code}): ${e.reason}`)),"listening"===t&&o.fire(),t="closed"};return e.addEventListener("message",c),e.addEventListener("close",u),{get onError(){return r.event},get onClose(){return o.event},get onPartialMessage(){return i.event},listen(e){if("initial"!==t)throw new Error("Already listening");const r=s.event(e);if(t="listening",0===n.length)return r;for(const e of n)e.message?l(e.message):e.error&&a(e.error);return n.length=0,r},dispose(){e.removeEventListener("message",c),e.removeEventListener("close",u),r.dispose(),o.dispose(),i.dispose(),n.length=0}}},ot=e=>{const t=new be,n=new be,r=()=>{n.fire()};e.addEventListener("close",r);let o=0;return{get onError(){return t.event},get onClose(){return n.event},write(n){return Qe(this,void 0,void 0,(function*(){try{e.send(JSON.stringify(n))}catch(e){t.fire([it(e),n,++o])}}))},end(){},dispose(){t.dispose(),n.dispose(),e.removeEventListener("close",r)}}},it=e=>e instanceof Error?e:new Error((null==e?void 0:e.message)||"Unknown error"),st=()=>({error:e=>console.error(e),warn:e=>console.warn(e),info:e=>console.info(e),log:e=>console.log(e)});function lt({rootURI:e,connectionString:t}){return Qe(this,void 0,void 0,(function*(){const n=new WebSocket(t),r=yield((e,t=st())=>new Promise((n=>{e.onopen=()=>{const r=He(rt(e),ot(e),t);r.onDispose((()=>e.close())),r.onClose((()=>r.dispose())),n(r)}})))(n);r.listen();const o=(e=>{let t;e.onRequest(E.type,(({registrations:e})=>{for(const{method:n,registerOptions:r}of e){const e=nt[n];e&&(t[e]=null==r||r)}})),e.onRequest(L.type,(({unregisterations:e})=>{for(const{method:n}of e){const e=nt[n];e&&(t[e]=void 0)}}));const n=(t,n)=>(r,o)=>t()?e.sendRequest(n,r,o):Promise.resolve(null),r=(t,n)=>r=>t()?e.sendNotification(n,r):Promise.resolve(),o=t=>n=>e.sendNotification(t,n),i=t=>n=>{e.onNotification(t,n)};return{listen:()=>e.listen(),dispose:()=>e.dispose(),initialize:n=>Qe(void 0,void 0,void 0,(function*(){const r=yield e.sendRequest(V.type,n);return t=r.capabilities,r})),initialized:()=>e.sendNotification(M.type,{}),shutdown:()=>e.sendRequest(I.type),exit:()=>e.sendNotification(O.type),onError:t=>e.onError((([e,n,r])=>t(e,n,r))),onClose:t=>e.onClose((()=>t())),onLogMessage:i(R.type),onShowMessage:i(k.type),onDiagnostics:i(j.type),textDocumentOpened:o(T.type),textDocumentClosed:o(F.type),textDocumentChanged:o($.type),textDocumentWillSave:r((()=>{var e;const n=null!==(e=t.textDocumentSync)&&void 0!==e?e:pe.None;return"number"!=typeof n&&!!n.willSave}),A.type),getEditsBeforeSave:n((()=>{var e;const n=null!==(e=t.textDocumentSync)&&void 0!==e?e:pe.None;return"number"!=typeof n&&!!n.willSaveWaitUntil}),B.type),textDocumentSaved:r((()=>{var e;const n=null!==(e=t.textDocumentSync)&&void 0!==e?e:pe.None;return"number"==typeof n?n!==pe.None:!!n.save}),N.type),configurationChanged:o(U.type),watchedFilesChanged:o(W.type),getDocumentFormatting:n((()=>!!t.documentFormattingProvider),q.type),applyEdits:n((()=>!!t.workspace),K.type),executeCommand:n((()=>!!t.executeCommandProvider),J.type),getCompletion:n((()=>!!t.completionProvider),G.type),getCompletionItemDetails:n((()=>{var e;return!!(null===(e=t.completionProvider)||void 0===e?void 0:e.resolveProvider)}),Q.type),getHoverInfo:n((()=>!!t.hoverProvider),X.type),getSignatureHelp:n((()=>!!t.signatureHelpProvider),Y.type),getDeclaration:n((()=>!!t.declarationProvider),Z.type),getDefinition:n((()=>!!t.definitionProvider),ee.type),getTypeDefinition:n((()=>!!t.typeDefinitionProvider),te.type),getImplementation:n((()=>!!t.implementationProvider),ne.type),getReferences:n((()=>!!t.referencesProvider),re.type),getDocumentHighlight:n((()=>!!t.documentHighlightProvider),oe.type),getDocumentSymbol:n((()=>!!t.documentSymbolProvider),ie.type),getCodeAction:n((()=>!!t.codeActionProvider),se.type),getCodeLens:n((()=>!!t.codeLensProvider),le.type),resolveCodeLens:n((()=>{var e;return!!(null===(e=t.codeLensProvider)||void 0===e?void 0:e.resolveProvider)}),ae.type),getDocumentLink:n((()=>!!t.documentLinkProvider),ce.type),resolveDocumentLink:n((()=>{var e;return!!(null===(e=t.documentLinkProvider)||void 0===e?void 0:e.resolveProvider)}),ue.type),getColorSymbols:n((()=>!!t.colorProvider),de.type),getFoldingRanges:n((()=>!!t.foldingRangeProvider),ve.type),getSelectionRanges:n((()=>!!t.selectionRangeProvider),ge.type),getWorkspaceSymbols:n((()=>!!t.workspaceSymbolProvider),he.type),get syncsIncrementally(){var e,n;let r=null!==(e=t.textDocumentSync)&&void 0!==e?e:pe.None;return"number"!=typeof r&&(r=null!==(n=r.change)&&void 0!==n?n:pe.None),r===pe.Incremental},get completionTriggers(){var e;return(null===(e=t.completionProvider)||void 0===e?void 0:e.triggerCharacters)||[]},get signatureHelpTriggers(){var e;return(null===(e=t.signatureHelpProvider)||void 0===e?void 0:e.triggerCharacters)||[]},get signatureHelpRetriggers(){var e;return(null===(e=t.signatureHelpProvider)||void 0===e?void 0:e.retriggerCharacters)||[]}}})(r),{capabilities:i}=yield function(e,t){return Qe(this,void 0,void 0,(function*(){const n=yield e.initialize({capabilities:{textDocument:{synchronization:{dynamicRegistration:!0,didSave:!0},completion:{dynamicRegistration:!0,completionItem:{snippetSupport:!1,insertReplaceSupport:!1,commitCharactersSupport:!1,documentationFormat:["markdown","plaintext"],labelDetailsSupport:!0,deprecatedSupport:!0,preselectSupport:!0,resolveSupport:{properties:["documentation","detail"]}},contextSupport:!0},hover:{dynamicRegistration:!0,contentFormat:["markdown","plaintext"]},signatureHelp:{dynamicRegistration:!0,signatureInformation:{documentationFormat:["markdown","plaintext"],parameterInformation:{labelOffsetSupport:!0},activeParameterSupport:!0},contextSupport:!0},codeAction:{dynamicRegistration:!0},formatting:{dynamicRegistration:!0},rename:{dynamicRegistration:!0},publishDiagnostics:{versionSupport:!0,codeDescriptionSupport:!0,relatedInformation:!0,tagSupport:{valueSet:[me.Unnecessary,me.Deprecated]}},moniker:{}},workspace:{didChangeConfiguration:{dynamicRegistration:!0},didChangeWatchedFiles:{dynamicRegistration:!0}}},processId:null,rootUri:t,workspaceFolders:null});return e.initialized().catch((e=>console.error(e))),n}))}(o,e);return{lsp:o,capabilities:i}}))}const at=(ct=49152,ut=65535,function(e){return e>=ut?ct:e+1});var ct,ut;function dt(e,t){if(t.line>=e.lines)return e.length;const n=e.line(t.line+1).from+t.character;return n>e.length?e.length:n}function vt(e,t){const n=e.lineAt(t);return{line:n.number-1,character:t-n.from}}function gt(e){return Array.isArray(e)?e.map(gt).join("\n\n"):"string"==typeof e?e:e.value}function ht(e){let t="",n=Array.from(e).join("");return/\w/.test(n)&&(t+="\\w",n=n.replace(/\w/g,"")),`[${t}${n.replace(/[^\w\s]/g,"\\$&")}]`}function pt(e){if(!Ce.isAbsolute(e))throw new Error("filepath must be absolute");return`file://${e}`}function mt(e){return pt(e.endsWith("/")?e:e+"/")}function ft(e,t){return t.find((({fileExtensions:t})=>null==t?void 0:t.some((t=>e.endsWith(t)))))}function wt({supportedLanguages:e,session:t,debug:n,rootdir:r}){const[o,i]=b(),[s,l]=b(),{maybeEmptyPort:a,markPortAsNotEmpty:c}=function(){const[e,t]=b(49152);return{maybeEmptyPort:e,markPortAsNotEmpty:H((()=>{t(at)}),[])}}();return C((function(){if(!(null==t?void 0:t.process))return;const o=new tt(r,e,t,a,n);return i(o),o.start().then((e=>{null==e||e.exited.then((()=>{c(),i((e=>e===o?void 0:e))}))})).catch((e=>console.error("Error starting language server",e))),()=>{i((e=>e===o?void 0:e)),o.stop()}}),[t,n,a,c,e]),C((function(){if(o)return l({process:o}),Promise.all(o.languages.map((e=>Qe(this,void 0,void 0,(function*(){try{const t=yield o.getConnectionString(e);if(!t)return;const{lsp:n,capabilities:i}=yield lt({rootURI:mt(r),connectionString:t});return new Ye({languageID:e,capabilities:i,lsp:n})}catch(e){const t=e instanceof Error?e.message:JSON.stringify(e);console.error(t)}}))))).then((e=>{const t=e.reduce(((e,t)=>(t&&(e[t.languageID]=t),e)),{});l((e=>(null==e?void 0:e.process)===o?{process:e.process,clients:t}:e))})),()=>{l((e=>{if((null==e?void 0:e.process)!==o||!e.clients)return e;Object.values(e.clients).map((e=>e.close()))}))}}),[o,r]),null==s?void 0:s.clients}var yt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M14.5 3H7.71l-.85-.85L6.51 2h-5l-.5.5v11l.5.5h13l.5-.5v-10L14.5 3zm-.51 8.49V13h-12V7h4.49l.35-.15.86-.86H14v1.5l-.01 4zm0-6.49h-6.5l-.35.15-.86.86H2v-3h4.29l.85.85.36.15H14l-.01.99z"/></svg>'}),xt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M6 5.914l2.06-2.06v-.708L5.915 1l-.707.707.043.043.25.25 1 1h-3a2.5 2.5 0 0 0 0 5H4V7h-.5a1.5 1.5 0 1 1 0-3h3L5.207 5.293 5.914 6 6 5.914zM11 2H8.328l-1-1H12l.71.29 3 3L16 5v9l-1 1H6l-1-1V6.5l1 .847V14h9V6h-4V2zm1 0v3h3l-3-3z"/></svg>'}),zt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M11.34 9.71h.71l2.67-2.67v-.71L13.38 5h-.7l-1.82 1.81h-5V5.56l1.86-1.85V3l-2-2H5L1 5v.71l2 2h.71l1.14-1.15v5.79l.5.5H10v.52l1.33 1.34h.71l2.67-2.67v-.71L13.37 10h-.7l-1.86 1.85h-5v-4H10v.48l1.34 1.38zm1.69-3.65l.63.63-2 2-.63-.63 2-2zm0 5l.63.63-2 2-.63-.63 2-2zM3.35 6.65l-1.29-1.3 3.29-3.29 1.3 1.29-3.3 3.3z"/></svg>'}),bt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M8 1.003a7 7 0 0 0-7 7v.43c.09 1.51 1.91 1.79 3 .7a1.87 1.87 0 0 1 2.64 2.64c-1.1 1.16-.79 3.07.8 3.2h.6a7 7 0 1 0 0-14l-.04.03zm0 13h-.52a.58.58 0 0 1-.36-.14.56.56 0 0 1-.15-.3 1.24 1.24 0 0 1 .35-1.08 2.87 2.87 0 0 0 0-4 2.87 2.87 0 0 0-4.06 0 1 1 0 0 1-.9.34.41.41 0 0 1-.22-.12.42.42 0 0 1-.1-.29v-.37a6 6 0 1 1 6 6l-.04-.04zM9 3.997a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 7.007a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-7-5a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm7-1a1 1 0 1 1-2 0 1 1 0 0 1 2 0zM13 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"/></svg>'}),Ht=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3l1-1h6l1 1v5l-1 1h-4V8h4V3H8v3H7V3zm2 6V8L8 7H2L1 8v5l1 1h6l1-1V9zM8 8v5H2V8h6zm1.414-1L9 6.586V6h4v1H9.414zM9 4h4v1H9V4zm-2 6H3v1h4v-1z"/></svg>'}),Ct=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M14 2H8L7 3v3h1V3h6v5h-4v1h4l1-1V3l-1-1zM9 6h4v1H9.41L9 6.59V6zM7 7H2L1 8v5l1 1h6l1-1V8L8 7H7zm1 6H2V8h6v5zM3 9h4v1H3V9zm0 2h4v1H3v-1zm6-7h4v1H9V4z"/></svg>'}),St=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M7.414 1.56L8.312 1h3.294l.818 1.575L10.236 6h1.781l.72 1.695L5.618 15l-1.602-1.163L6.119 10H4.898L4 8.56l3.414-7zM7.78 9L4.9 14.305 12.018 7H8.312l3.294-5H8.312L4.898 9H7.78z"/></svg>'}),Dt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M14.45 4.5l-5-2.5h-.9l-7 3.5-.55.89v4.5l.55.9 5 2.5h.9l7-3.5.55-.9v-4.5l-.55-.89zm-8 8.64l-4.5-2.25V7.17l4.5 2v3.97zm.5-4.8L2.29 6.23l6.66-3.34 4.67 2.34-6.67 3.11zm7 1.55l-6.5 3.25V9.21l6.5-3v3.68z"/></svg>'}),Pt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M13.85 4.44l-3.28-3.3-.35-.14H2.5l-.5.5v13l.5.5h11l.5-.5V4.8l-.15-.36zM13 5h-3V2l3 3zM3 14V2h6v3.5l.5.5H13v8H3z"/></svg>'}),_t=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M11.496 4a3.49 3.49 0 0 0-3.46 3h-3.1a2 2 0 1 0 0 1h3.1a3.5 3.5 0 1 0 3.46-4zm0 6a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5z"/></svg>'}),Et=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M15 4h-5V3h5v1zm-1 3h-2v1h2V7zm-4 0H1v1h9V7zm2 6H1v1h11v-1zm-5-3H1v1h6v-1zm8 0h-5v1h5v-1zM8 2v3H1V2h7zM7 3H2v1h5V3z"/></svg>'}),Lt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M13.51 4l-5-3h-1l-5 3-.49.86v6l.49.85 5 3h1l5-3 .49-.85v-6L13.51 4zm-6 9.56l-4.5-2.7V5.7l4.5 2.45v5.41zM3.27 4.7l4.74-2.84 4.74 2.84-4.74 2.59L3.27 4.7zm9.74 6.16l-4.5 2.7V8.15l4.5-2.45v5.16z"/></svg>'}),Vt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M6 2.984V2h-.09c-.313 0-.616.062-.909.185a2.33 2.33 0 0 0-.775.53 2.23 2.23 0 0 0-.493.753v.001a3.542 3.542 0 0 0-.198.83v.002a6.08 6.08 0 0 0-.024.863c.012.29.018.58.018.869 0 .203-.04.393-.117.572v.001a1.504 1.504 0 0 1-.765.787 1.376 1.376 0 0 1-.558.115H2v.984h.09c.195 0 .38.04.556.121l.001.001c.178.078.329.184.455.318l.002.002c.13.13.233.285.307.465l.001.002c.078.18.117.368.117.566 0 .29-.006.58-.018.869-.012.296-.004.585.024.87v.001c.033.283.099.558.197.824v.001c.106.273.271.524.494.753.223.23.482.407.775.53.293.123.596.185.91.185H6v-.984h-.09c-.199 0-.387-.038-.562-.115a1.613 1.613 0 0 1-.457-.32 1.659 1.659 0 0 1-.309-.467c-.074-.18-.11-.37-.11-.573 0-.228.003-.453.011-.672.008-.228.008-.45 0-.665a4.639 4.639 0 0 0-.055-.64 2.682 2.682 0 0 0-.168-.609A2.284 2.284 0 0 0 3.522 8a2.284 2.284 0 0 0 .738-.955c.08-.192.135-.393.168-.602.033-.21.051-.423.055-.64.008-.22.008-.442 0-.666-.008-.224-.012-.45-.012-.678a1.47 1.47 0 0 1 .877-1.354 1.33 1.33 0 0 1 .563-.121H6zm4 10.032V14h.09c.313 0 .616-.062.909-.185.293-.123.552-.3.775-.53.223-.23.388-.48.493-.753v-.001c.1-.266.165-.543.198-.83v-.002c.028-.28.036-.567.024-.863-.012-.29-.018-.58-.018-.869 0-.203.04-.393.117-.572v-.001a1.504 1.504 0 0 1 .765-.787c.176-.077.362-.115.558-.115H14v-.984h-.09c-.195 0-.38-.04-.556-.121l-.001-.001a1.376 1.376 0 0 1-.455-.318l-.002-.002a1.414 1.414 0 0 1-.307-.465l-.001-.002a1.405 1.405 0 0 1-.117-.566c0-.29.006-.58.018-.869a6.19 6.19 0 0 0-.024-.87v-.001a3.542 3.542 0 0 0-.197-.824v-.001a2.23 2.23 0 0 0-.494-.753 2.33 2.33 0 0 0-.775-.53 2.325 2.325 0 0 0-.91-.185H10v.984h.09c.2 0 .386.038.562.115.174.082.326.188.457.32.127.134.23.29.309.467.074.18.11.37.11.573 0 .228-.003.452-.011.672-.008.228-.008.45 0 .665.004.222.022.435.055.64.033.214.089.416.168.609a2.282 2.282 0 0 0 .738.955 2.282 2.282 0 0 0-.738.955 2.7 2.7 0 0 0-.168.602c-.033.21-.051.423-.055.64-.008.22-.008.442 0 .666.008.224.012.45.012.678a1.47 1.47 0 0 1-.42 1.035 1.466 1.466 0 0 1-.457.319 1.33 1.33 0 0 1-.563.121H10z"/></svg>'}),Mt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2.873 1.1c.335.136.602.398.745.73.072.17.109.352.107.537a1.34 1.34 0 0 1-.61 1.135 1.359 1.359 0 0 1-.753.223A1.355 1.355 0 0 1 1 2.362a1.355 1.355 0 0 1 .83-1.256A1.37 1.37 0 0 1 2.873 1.1zm-.298 1.765a.551.551 0 0 0 .332-.5.548.548 0 1 0-.332.5zM6.43 1.109L1.11 6.43l.686.687 5.32-5.32-.686-.687zM11.5 9h1v2.5H15v1h-2.5V15h-1v-2.5H9v-1h2.5V9zm-5.732.525l.707.707L4.707 12l1.768 1.768-.707.707L4 12.707l-1.768 1.768-.707-.707L3.293 12l-1.768-1.768.707-.707L4 11.293l1.768-1.768zm1.35-4.195a1.353 1.353 0 0 0-1.256-.83 1.355 1.355 0 0 0-1.256.83 1.362 1.362 0 0 0 1.257 1.895A1.358 1.358 0 0 0 7.118 5.33zm-.753.745a.553.553 0 0 1-.289.29.547.547 0 0 1-.599-.117.529.529 0 0 1-.117-.173.544.544 0 0 1 .716-.715.565.565 0 0 1 .173.116.549.549 0 0 1 .116.599zM14 3h-4v1h4V3z"/></svg>'}),It=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M11 6h-1v-.5a.5.5 0 0 0-.5-.5H8.479v5.5a.5.5 0 0 0 .5.5h.5v1h-3v-1h.5a.5.5 0 0 0 .5-.5V5H6.5a.5.5 0 0 0-.5.5V6H5V4h6v2zm2.914 2.048l-1.462-1.462.707-.707 1.816 1.816v.707l-1.768 1.767-.707-.707 1.414-1.414zM3.548 9.462L2.086 8 3.5 6.586l-.707-.707-1.768 1.767v.708l1.816 1.815.707-.707z"/></svg>'}),Ot=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M2.807 14.975a1.75 1.75 0 0 1-1.255-.556 1.684 1.684 0 0 1-.544-1.1A1.72 1.72 0 0 1 1.36 12.1c1.208-1.27 3.587-3.65 5.318-5.345a4.257 4.257 0 0 1 .048-3.078 4.095 4.095 0 0 1 1.665-1.969 4.259 4.259 0 0 1 4.04-.36l.617.268-2.866 2.951 1.255 1.259 2.944-2.877.267.619a4.295 4.295 0 0 1 .04 3.311 4.198 4.198 0 0 1-.923 1.392 4.27 4.27 0 0 1-.743.581 4.217 4.217 0 0 1-3.812.446c-1.098 1.112-3.84 3.872-5.32 5.254a1.63 1.63 0 0 1-1.084.423zm7.938-13.047a3.32 3.32 0 0 0-1.849.557c-.213.13-.412.284-.591.458a3.321 3.321 0 0 0-.657 3.733l.135.297-.233.227c-1.738 1.697-4.269 4.22-5.485 5.504a.805.805 0 0 0 .132 1.05.911.911 0 0 0 .298.22c.1.044.209.069.319.072a.694.694 0 0 0 .45-.181c1.573-1.469 4.612-4.539 5.504-5.44l.23-.232.294.135a3.286 3.286 0 0 0 3.225-.254 3.33 3.33 0 0 0 .591-.464 3.28 3.28 0 0 0 .964-2.358c0-.215-.021-.43-.064-.642L11.43 7.125 8.879 4.578l2.515-2.59a3.286 3.286 0 0 0-.65-.06z"/></svg>'}),Rt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M4 1L3 2v12l1 1h8l1-1V2l-1-1H4zm0 2V2h8v12H4v-1h2v-1H4v-2h4V9H4V7h2V6H4V4h4V3H4z"/></svg>'}),kt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2.5 1l-.5.5V13h1V2h11v11h1V1.5l-.5-.5h-12zM2 15v-1h1v1H2zm3-1H4v1h1v-1zm1 0h1v1H6v-1zm3 0H8v1h1v-1zm1 0h1v1h-1v-1zm5 1v-1h-1v1h1zm-3-1h1v1h-1v-1z"/></svg>'}),jt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 2L1 3v9l1 1h12l1-1V3l-1-1H2zm0 10V3h12v9H2zm3.356-3.07H6V7.22C6 6.408 5.685 6 5.056 6c-.135 0-.285.024-.45.073a1.444 1.444 0 0 0-.388.167v.665c.237-.203.487-.304.75-.304.261 0 .392.156.392.469l-.6.103c-.506.086-.76.406-.76.961 0 .263.061.473.183.631A.61.61 0 0 0 4.69 9c.29 0 .509-.16.657-.48h.009v.41zm.004-1.355v.193a.75.75 0 0 1-.12.436.368.368 0 0 1-.313.17.276.276 0 0 1-.22-.095.38.38 0 0 1-.08-.248c0-.222.11-.351.332-.389l.4-.067zM7.6 8.626h-.007v.31H7V5h.593v1.677h.008c.146-.31.355-.465.625-.465.248 0 .44.118.573.353.134.236.201.557.201.966 0 .443-.078.798-.235 1.067C8.61 8.866 8.4 9 8.138 9c-.237 0-.416-.125-.537-.374zm-.016-1.121v.272a.78.78 0 0 0 .107.426c.071.113.163.169.274.169.135 0 .24-.072.314-.216.075-.145.113-.35.113-.615 0-.22-.035-.39-.104-.514-.067-.124-.164-.187-.29-.187-.12 0-.219.062-.298.185a.887.887 0 0 0-.116.48zM11.262 9c.321 0 .567-.058.738-.173v-.71a.9.9 0 0 1-.552.207.619.619 0 0 1-.5-.215c-.12-.145-.181-.345-.181-.598 0-.26.063-.464.189-.612a.644.644 0 0 1 .516-.223c.194 0 .37.069.528.207v-.749c-.129-.09-.338-.134-.626-.134-.417 0-.751.14-1.001.422-.249.28-.373.662-.373 1.148 0 .42.116.764.349 1.03.232.267.537.4.913.4z"/></svg>'}),Tt=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 2L1 3v3l1 1h12l1-1V3l-1-1H2zm0 1h12v3H2V3zm-1 7l1-1h3l1 1v3l-1 1H2l-1-1v-3zm2 0H2v3h3v-3H3zm7 0l1-1h3l1 1v3l-1 1h-3l-1-1v-3zm2 0h-1v3h3v-3h-2z"/></svg>'}),Ft=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 5h2V4H1.5l-.5.5v8l.5.5H4v-1H2V5zm12.5-1H12v1h2v7h-2v1h2.5l.5-.5v-8l-.5-.5zm-2.74 2.57L12 7v2.51l-.3.45-4.5 2h-.46l-2.5-1.5-.24-.43v-2.5l.3-.46 4.5-2h.46l2.5 1.5zM5 9.71l1.5.9V9.28L5 8.38v1.33zm.58-2.15l1.45.87 3.39-1.5-1.45-.87-3.39 1.5zm1.95 3.17l3.5-1.56v-1.4l-3.5 1.55v1.41z"/></svg>'});function $t(e){return e[e.length-1]}function At(e){const t=document.createElement("template");return t.innerHTML=e,Array.from(t.content.childNodes)}function Bt(e){return Qe(this,void 0,void 0,(function*(){const t=yield function(e){return Qe(this,void 0,void 0,(function*(){return(yield $e().use(Te).use(je).use(Fe,{allowDangerousHtml:!0}).use(Oe).use(Re).data("settings",{fragment:!0}).use(Ie,{detect:!0}).use(Me,{rel:"noopener noreferrer",target:"_blank"}).use(ke).process(e)).toString()}))}(e);return At(t)}))}const Nt=Object.fromEntries(Object.entries(fe).map((([e,t])=>[t,e.toLowerCase()]))),Ut=Object.fromEntries(Object.entries(fe).map((([e,t])=>[e.toLowerCase(),t]))),Wt=n.define({combine:$t}),qt=n.define({combine:$t}),Kt=n.define({combine:$t});class Jt{constructor(e,t){this.view=e,this.documentVersion=0;const n=this.view.state;this.client=n.facet(Wt),this.documentURI=e.state.facet(qt),this.client.attachPlugin(this),this.openPromise=t?this.client.lsp.textDocumentOpened({textDocument:{text:n.doc.toString(),languageId:n.facet(Kt),uri:this.documentURI,version:this.documentVersion}}):this.client.lsp.textDocumentChanged({textDocument:{uri:this.documentURI,version:this.nextDocumentVersion},contentChanges:[{text:n.doc.toString()}]})}get nextDocumentVersion(){return++this.documentVersion}update({docChanged:e,state:t}){return Qe(this,void 0,void 0,(function*(){e&&(yield this.openPromise,yield this.client.lsp.textDocumentChanged({textDocument:{uri:this.documentURI,version:this.nextDocumentVersion},contentChanges:[{text:t.doc.toString()}]}))}))}destroy(){this.client.detachPlugin(this)}requestFormatting(e){var n;return Qe(this,void 0,void 0,(function*(){if(!(null===(n=this.client.capabilities)||void 0===n?void 0:n.documentFormattingProvider))return null;const o=e.state,i=yield this.client.lsp.getDocumentFormatting({textDocument:{uri:this.documentURI},options:{insertSpaces:!0,tabSize:2,trimFinalNewlines:!0,insertFinalNewline:!0,trimTrailingWhitespace:!0}}),s=(null==i?void 0:i.map((e=>({from:dt(o.doc,e.range.start)||0,to:dt(o.doc,e.range.end),insert:e.newText}))))||[],l=function(e,n){let r=0;return n.reduce(((e,n)=>{if(n instanceof t||Array.isArray(n)||!("from"in n))throw new Error("This function does not support ChangeSet or nested ChangeSpec");const o=r+n.from,i=r+((null==n?void 0:n.to)||0),s=n.insert||"";return r+=s.length-(i-o),e.slice(0,o)+s+e.slice(i)}),e)}(o.doc.toString(),s),a=Ve.diffChars(o.doc.toString(),l),c=[];let u=0;a.forEach((e=>{e.removed?(c.push({from:u,to:u+e.value.length}),u+=e.value.length):e.added?c.push({from:u,insert:e.value}):u+=e.value.length})),c.length&&e.dispatch({annotations:[r.remote.of(!0),r.addToHistory.of(!0)],changes:c})}))}requestHoverTooltip({state:{doc:e}},{line:t,character:n}){return Qe(this,void 0,void 0,(function*(){if(!this.client.capabilities.hoverProvider)return null;const r=yield this.client.lsp.getHoverInfo({textDocument:{uri:this.documentURI},position:{line:t,character:n}});if(!r)return null;const{contents:o,range:i}=r;let s=dt(e,{line:t,character:n});const l=gt(o),a=yield Bt(l);if(0===a.length)return null;const c=document.createElement("div");let u;return c.id="root2",c.classList.add("documentation"),c.append(...a),i&&(s=dt(e,i.start),u=dt(e,i.end)),null===s?null:{pos:s,end:u,create:()=>({dom:c}),above:!0}}))}requestSignatureHelp(e,t,n,r){var o,i,s,l,a;return Qe(this,void 0,void 0,(function*(){if(!(null===(o=this.client.capabilities)||void 0===o?void 0:o.signatureHelpProvider))return null;const{state:c,pos:u,explicit:d}=e;if(d)return null;const v=c.doc.lineAt(u),g=v.text[u-v.from-1];let h,p=we.ContentChange;if((r&&(null===(s=null===(i=this.client.capabilities.signatureHelpProvider)||void 0===i?void 0:i.triggerCharacters)||void 0===s?void 0:s.includes(g))||n&&(null===(a=null===(l=this.client.capabilities.signatureHelpProvider)||void 0===l?void 0:l.retriggerCharacters)||void 0===a?void 0:a.includes(g)))&&(h=g,p=we.TriggerCharacter),!t&&p===we.ContentChange)return null;const m=vt(c.doc,u);return yield this.client.lsp.getSignatureHelp({position:m,textDocument:{uri:this.documentURI},context:{triggerKind:p,triggerCharacter:h,isRetrigger:n,activeSignatureHelp:t}})}))}requestCompletion(e,{line:t,character:n},{triggerKind:r,triggerCharacter:o}){return Qe(this,void 0,void 0,(function*(){if(!this.client.capabilities.completionProvider)return null;const i=yield this.client.lsp.getCompletion({textDocument:{uri:this.documentURI},position:{line:t,character:n},context:{triggerKind:r,triggerCharacter:o}});if(!i)return null;let s=("items"in i?i.items:i).map((e=>{const{detail:t,label:n,kind:r,textEdit:o,documentation:i,sortText:s,insertText:l,insertTextFormat:a,additionalTextEdits:c,filterText:u}=e;let d,v=null;o?(d=o.newText,d=(e,t)=>{const n=[],r=e.state;"range"in o?a===ye.Snippet||n.push({from:dt(r.doc,o.range.start),to:dt(r.doc,o.range.end),insert:o.newText}):console.error("Not supporting insert replace language server capability"),null==c||c.forEach((e=>{n.push({from:dt(r.doc,e.range.start),to:dt(r.doc,e.range.end),insert:e.newText})})),e.dispatch({annotations:Se.of(t),changes:n})}):d=l?a===ye.Snippet?(e,t,n,r)=>{const o=l.indexOf("$0"),i=l.replace("$0",""),s=-1===o?void 0:n+o;e.dispatch({annotations:Se.of(t),changes:[{from:n,to:r,insert:i}],selection:s?{head:s,anchor:s}:void 0})}:l:n;return{label:n,detail:t,apply:d,type:r&&Nt[r],sortText:null!=s?s:n,filterText:null!=u?u:n,info:()=>Qe(this,void 0,void 0,(function*(){let t,n=i;if(n||v||(v=yield this.client.lsp.getCompletionItemDetails(e)),(null==v?void 0:v.labelDetails)&&(t=v.label+v.labelDetails.detail+v.labelDetails.description),n=(null==v?void 0:v.documentation)||i||t,!n)return null;const r=gt(n),o=yield Bt(r);if(0===o.length)return null;const s=document.createElement("div");return s.id="root3",s.classList.add("documentation"),s.append(...o),s}))}}));if(0===s.length)return null;const[,l]=function(e){const t=new Set,n=new Set;for(const{label:r}of e){const[e,...o]=r;t.add(e);for(const e of o)n.add(e)}const r=ht(t)+ht(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}(s),a=e.matchBefore(l);let{pos:c}=e;if(a){const e=a.text.toLowerCase();c=a.from,/^\w+$/.test(e)&&(s=s.filter((({filterText:t})=>t.toLowerCase().startsWith(e))).sort((({label:e},{label:t})=>{switch(!0){case e.startsWith(a.text)&&!t.startsWith(a.text):return-1;case!e.startsWith(a.text)&&t.startsWith(a.text):return 1}return 0})))}const u=s.reduce(((e,t)=>Math.max(e,t.label.length)),0);return{from:c,options:s,validFor:e=>0!==e.length&&(!e.endsWith(".")&&(!e.endsWith(" ")&&!(e.length>u)))}}))}onDiagnostics(e){if(e.uri!==this.documentURI)return;const t=this.view.state,n=e.diagnostics.map((({range:e,message:n,severity:r})=>({from:dt(t.doc,e.start),to:dt(t.doc,e.end),severity:r&&{[xe.Error]:"error",[xe.Warning]:"warning",[xe.Information]:"info",[xe.Hint]:"info"}[r]||"info",message:n}))).filter((({from:e,to:t})=>null!==e&&null!==t&&void 0!==e&&void 0!==t)).sort(((e,t)=>{switch(!0){case e.from<t.from:return-1;case e.from>t.from:return 1}return 0}));this.view.dispatch(Le(t,n))}}function Gt(){const e=Object.fromEntries(Object.entries(Ut).map((([e,t])=>{const n=At(function(e){switch(e){case fe.Class:return zt;case fe.Color:return bt;case fe.Constant:return Ft;case fe.Constructor:return Lt;case fe.Enum:return Ct;case fe.EnumMember:return Ht;case fe.Event:return St;case fe.Field:return Dt;case fe.File:return Pt;case fe.Folder:return yt;case fe.Function:return Lt;case fe.Interface:return _t;case fe.Keyword:return Et;case fe.Method:return Lt;case fe.Module:return Vt;case fe.Operator:return Mt;case fe.Property:return Ot;case fe.Reference:return xt;case fe.Snippet:return kt;case fe.Struct:return Tt;case fe.Text:return jt;case fe.TypeParameter:return It;case fe.Unit:return Rt;case fe.Value:return Ct;case fe.Variable:return Ft}}(t).default),r=document.createElement("div");return r.classList.add("autocomplete-icon",`autocomplete-icon-${e}`),r.append(...n),[e,r]})));return{getImage(t){const n=e[t];if(n)return n.cloneNode(!0)}}}class Qt{constructor(e,t,n){this.view=e,this.getPlugin=t,this.setSignatureHelp=n}update(e){return Qe(this,void 0,void 0,(function*(){const t=this.getPlugin();if(!t)return;if(!e.transactions.some((e=>e.isUserEvent("select.pointer")))&&(e.docChanged||e.startState.selection.main.head!==e.state.selection.main.head)){yield t.update(e);const n=e.state.selection.main.head,r=new De(e.state,n,!1);yield this.updateSignature(e.state,r,e.docChanged)}}))}updateSignature(e,t,n){return Qe(this,void 0,void 0,(function*(){const r=this.getPlugin();if(!r)return;const o=yield r.requestSignatureHelp(t,this.lastSignature,!!this.lastSignature,n);this.lastSignature=o||void 0;const i=o?yield this.getTooltip(e,o):null;this.setTooltip(i)}))}getTooltip(e,t){return Qe(this,void 0,void 0,(function*(){const n=void 0!==t.activeSignature?t.signatures[t.activeSignature]:void 0;if(!n)return null;n.activeParameter=void 0!==n.activeParameter?n.activeParameter:null==t?void 0:t.activeParameter;const r=gt(n.documentation||""),o=yield Bt(r),i=n.parameters&&void 0!==n.activeParameter?n.parameters[n.activeParameter]:void 0,s=gt((null==i?void 0:i.documentation)||""),l=yield Bt(s);if(0===o.length)return null;const a=document.createElement("div");a.id="root4",a.classList.add("documentation");const c=document.createElement("code");c.classList.add("signature-label"),c.innerHTML=function(e,t){if(void 0===e.activeParameter)return e.label;if(!e.parameters)return e.label;const n=e.parameters[e.activeParameter];if(!n)return e.label;const r="string"==typeof n.label?n.label:e.label.slice(n.label[0],n.label[1]);return e.label.replace(r,t(r))}(n,(e=>`<code class="selected-param">${e}</code>`)),0===o.length&&0===l.length||(c.innerHTML+="<br/><br/>"),a.appendChild(c),a.append(...o),0!==l.length&&a.append(...l);return{pos:e.selection.main.head,create:()=>({dom:a}),above:!0}}))}setTooltip(e){const t=this.setSignatureHelp.of(e);this.view.dispatch({effects:t})}}const Xt=o.define(),Yt=Xt.of(null);function Zt(e){const t=i.define({create:()=>null,update(e,t){if(t.isUserEvent("select.pointer"))return null;for(const e of t.effects)if(e.is(Xt))return e.value;return e},provide:e=>c.compute(["selection",e],(t=>{if(!e)return null;const n=t.field(e);return n?(n.pos=t.selection.main.head,Object.assign({},n)):null}))});return[u.define((t=>new Qt(t,e,Xt))),t]}const en={"data-gramm":"false",spellcheck:"false"};const tn=S((({content:t="",onContentChange:n,isReadOnly:r=!1,supportedLanguages:o,height:i,className:c="",autofocus:H,filename:S,languageClients:E,openFileInLanguageServer:L=!0},V)=>{const M=D(null),[I,O]=b(),R=ft(S,o),k=R&&(null==E?void 0:E[null==R?void 0:R.languageID]);return P(V,(()=>({focus:()=>null==I?void 0:I.view.focus()})),[I]),_((function(){if(!M.current)return;const{languageServiceExtensions:e,contentHandlingExtensions:n,languageExtensions:r,editabilityExtensions:o,state:i}=function(e){const t=new l,n=new l,r=new l,o=new l;return{state:a.create({doc:e,extensions:[h.contentAttributes.of(en),o.of([]),p(),We(),m(),f(),Ae(),w(),a.tabSize.of(2),y(),x(),_e(),qe(),z(),d.of([...Be,...Ee,...Ne,...Ke,Ue,{key:"Mod-s",run:()=>!0}]),n.of([]),r.of([]),t.of([]),Je(Ge)]}),languageExtensions:t,languageServiceExtensions:n,contentHandlingExtensions:r,editabilityExtensions:o}}(t),s=new h({state:i,parent:M.current});return O({view:s,languageServiceExtensions:e,contentHandlingExtensions:n,languageExtensions:r,editabilityExtensions:o}),H&&s.focus(),()=>{s.destroy(),O(void 0)}}),[H,t]),C((function(){if(I&&(null==R?void 0:R.languageExtensions))return I.view.dispatch({effects:I.languageExtensions.reconfigure(R.languageExtensions)}),()=>{I.view.dispatch({effects:I.languageExtensions.reconfigure([])})}}),[I,R]),C((function(){if(!I)return;const e=[a.readOnly.of(r),h.editable.of(!r)];return I.view.dispatch({effects:I.editabilityExtensions.reconfigure(e)}),()=>{I.view.dispatch({effects:I.editabilityExtensions.reconfigure([])})}}),[I,r]),C((function(){if(!I)return;if(!n)return;const e=h.updateListener.of((e=>{e.docChanged&&(null==n||n(e.state.doc.toString()))}));return I.view.dispatch({effects:I.contentHandlingExtensions.reconfigure(e)}),()=>{I.view.dispatch({effects:I.contentHandlingExtensions.reconfigure([])})}}),[I,n]),C((function(){if(!I)return;if(!S)return;if(!k)return;const e=function(e){let t=null;const{getImage:n}=Gt();return[Wt.of(e.client),qt.of(e.documentURI),Kt.of(e.client.languageID),u.define((n=>t=new Jt(n,e.openFile))),s.highest(d.of([{key:"Mod-s",run:e=>(null==t||t.requestFormatting(e),!1)},{key:"Escape",run:e=>(e.dispatch({effects:[v,Yt]}),!1)}])),Zt((()=>t)),g(((e,n)=>Qe(this,void 0,void 0,(function*(){if(!t)return null;const r=vt(e.state.doc,n);return yield t.requestHoverTooltip(e,r)})))),Pe({activateOnTyping:!0,maxRenderedOptions:40,closeOnBlur:!1,icons:!1,addToOptions:[{render:e=>e.type?(e.iconCache||(e.iconCache=n(e.type)),e.iconCache||null):null,position:20}],override:[e=>Qe(this,void 0,void 0,(function*(){var n,r,o;if(!t)return null;const{state:i,pos:s,explicit:l}=e,a=i.doc.lineAt(s);let c,u=ze.Invoked;return!l&&(null===(o=null===(r=null===(n=t.client.capabilities)||void 0===n?void 0:n.completionProvider)||void 0===r?void 0:r.triggerCharacters)||void 0===o?void 0:o.includes(a.text[s-a.from-1]))&&(u=ze.TriggerCharacter,c=a.text[s-a.from-1]),yield t.requestCompletion(e,vt(i.doc,s),{triggerKind:u,triggerCharacter:c})}))]})]}({client:k,documentURI:pt(S),openFile:L});return I.view.dispatch({effects:I.languageServiceExtensions.reconfigure(e)}),()=>{I.view.dispatch({effects:I.languageServiceExtensions.reconfigure([])})}}),[I,k,S,L]),e("div",{className:`overflow-auto ${c}`,ref:M,style:Object.assign({},i&&{height:i})})}));tn.displayName="CodeEditor";export{tn as CodeEditor,pt as getFileURI,ft as getLanguageSetup,mt as getRootURI,wt as useLanguageServer};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react/jsx-runtime"),require("@codemirror/state"),require("@codemirror/view"),require("react"),require("vscode-languageserver-protocol"),require("vscode-ws-jsonrpc"),require("path-browserify"),require("@codemirror/autocomplete"),require("@codemirror/lint"),require("diff"),require("rehype-external-links"),require("rehype-highlight"),require("rehype-raw"),require("rehype-sanitize"),require("rehype-stringify"),require("remark-gfm"),require("remark-parse"),require("remark-rehype"),require("unified"),require("@codemirror/commands"),require("@codemirror/language"),require("@lezer/highlight")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","@codemirror/state","@codemirror/view","react","vscode-languageserver-protocol","vscode-ws-jsonrpc","path-browserify","@codemirror/autocomplete","@codemirror/lint","diff","rehype-external-links","rehype-highlight","rehype-raw","rehype-sanitize","rehype-stringify","remark-gfm","remark-parse","remark-rehype","unified","@codemirror/commands","@codemirror/language","@lezer/highlight"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@devbookhq/code-editor"]={},e.jsxRuntime,e.state,e.view,e.react,e.vscodeLanguageserverProtocol,e.vscodeWsJsonrpc,e.path,e.autocomplete,e.lint,e.Diff,e.rehypeExternalLinks,e.rehypeHighlight,e.rehypeRaw,e.rehypeSanitize,e.rehypeStringify,e.remarkGfm,e.remarkParse,e.remarkRehype,e.unified,e.commands,e.language,e.highlight)}(this,(function(e,t,n,i,o,r,s,l,a,c,u,d,g,h,v,m,p,f,w,y,x,C,S){"use strict";function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function z(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var D=b(l),H=z(u),E=b(d),P=b(g),R=b(h),I=b(v),L=b(m),_=b(p),V=b(f),T=b(w);function q(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{a(i.next(e))}catch(e){r(e)}}function l(e){try{a(i.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,l)}a((i=i.apply(e,t||[])).next())}))}class k{constructor(e,t=!1){this.logID=e,this.isEnabled=t}error(...e){console.error(`[${this.id()} ERROR]`,...e)}log(...e){this.isEnabled&&console.log(`[${this.id()}]`,...e)}id(){return"function"==typeof this.logID?this.logID():this.logID}}class M{constructor(e){this.plugins=[],this.languageID=e.languageID,this.lsp=e.lsp,this.capabilities=e.capabilities;const t=function(e,t="orange"){return function(...n){console.groupCollapsed(`%c[${e}]`,`color:${t};`,...n),console.trace(),console.groupEnd()}}(`LSP - ${this.languageID}`,"blue");this.lsp.onDiagnostics(this.processDiagnostics.bind(this)),this.lsp.onError((e=>{t("Error in language service",e)})),this.lsp.onLogMessage((e=>{})),this.lsp.onShowMessage((e=>{}))}close(){this.lsp.dispose()}attachPlugin(e){this.plugins.push(e)}detachPlugin(e){const t=this.plugins.indexOf(e);-1!==t&&this.plugins.splice(t,1)}processDiagnostics(e){for(const t of this.plugins)t.onDiagnostics(e)}}function O(){let e,t;const n=new Promise(((n,i)=>{e=n,t=i}));return{resolve:e,reject:t,promise:n}}function j(e){return null!=e}class K{constructor(e,t,n,i,o){this.rootdir=e,this.session=n,this.port=i,this.isDestroyed=!1,this.isStarted=!1,this.started=O(),this.serverSetup=t.filter(j).filter((e=>!!e.languageServerCommand)),this.startCmd=`lsp-ws-proxy -l ${this.port} `+this.serverSetup.map((e=>`-- ${e.languageServerCommand} --stdio`)).join(" "),this.logger=new k("LanguageServer",o),this.logger.log("Language server initialized",this.serverSetup)}get languages(){return this.serverSetup.map((e=>e.languageID))}stop(){var e,t;return q(this,void 0,void 0,(function*(){this.isDestroyed||(this.isDestroyed=!0,this.logger.log("Closing..."),yield null===(e=this.languageServer)||void 0===e?void 0:e.kill(),this.logger.log(`Closed (processID ${null===(t=this.languageServer)||void 0===t?void 0:t.processID})`))}))}start(){return q(this,void 0,void 0,(function*(){if(this.isStarted)return yield this.started.promise,this.languageServer;this.isStarted=!0,this.logger.log("Opening...");const e=this.session.getHostname(this.port);if(!e)throw new Error("Cannot get session url");const t=`wss://${e}`;try{return this.languageServer=Object.assign(Object.assign({},yield function(e,t,n,i,o,r){return q(this,void 0,void 0,(function*(){if(!n)throw new Error("Cannot create process - process manager is not defined");const{resolve:s,promise:l}=O(),a=yield n.start({cmd:e,onStdout:i,onStderr:o,onExit:()=>{s()},rootdir:t,processID:r});return{exited:l,processID:a.processID,kill:a.kill,sendStdin:a.sendStdin}}))}(this.startCmd,this.rootdir,this.session.process,(e=>this.logger.log(`Output: ${e.line}`)),(e=>this.logger.error(`Error: ${e.line}`)))),{websocketURL:t}),this.logger.log(`Open (processID ${this.languageServer.processID})`),this.started.resolve(),this.languageServer}catch(e){throw this.started.reject(),e}}))}getConnectionString(e){return q(this,void 0,void 0,(function*(){const t=this.serverSetup.find((t=>t.languageID===e));if(!t)return;const n=yield this.start();return n?encodeURI(`${n.websocketURL}?name=${t.languageServerCommand}`):void 0}))}}const F={"workspace/executeCommand":"executeCommandProvider","workspace/applyEdit":"workspace","textDocument/codeAction":"codeActionProvider","textDocument/codeLens":"codeLensProvider","textDocument/color":"colorProvider","textDocument/completion":"completionProvider","textDocument/declaration":"declarationProvider","textDocument/definition":"definitionProvider","textDocument/formatting":"documentFormattingProvider","textDocument/documentHighlight":"documentHighlightProvider","textDocument/documentLink":"documentLinkProvider","textDocument/onTypeFormatting":"documentOnTypeFormattingProvider","textDocument/rangeFormatting":"documentRangeFormattingProvider","textDocument/documentSymbol":"documentSymbolProvider","textDocument/executeCommand":"executeCommandProvider","textDocument/foldingRange":"foldingRangeProvider","textDocument/hover":"hoverProvider","textDocument/implementation":"implementationProvider","textDocument/references":"referencesProvider","textDocument/rename":"renameProvider","textDocument/signatureHelp":"signatureHelpProvider","textDocument/typeDefinition":"typeDefinitionProvider","textDocument/workspaceSymbol":"workspaceSymbolProvider"},N=e=>{let t="initial";const n=[],i=new s.Emitter,o=new s.Emitter,r=new s.Emitter,l=new s.Emitter,a=e=>{"initial"===t?n.push({message:e}):"listening"===t&&l.fire(JSON.parse(e))},c=e=>{"initial"===t?n.push({error:e}):"listening"===t&&i.fire(e)},u=e=>a(e.data),d=e=>{1e3!==e.code&&c(new Error(`WebSocket Error (${e.code}): ${e.reason}`)),"listening"===t&&o.fire(),t="closed"};return e.addEventListener("message",u),e.addEventListener("close",d),{get onError(){return i.event},get onClose(){return o.event},get onPartialMessage(){return r.event},listen(e){if("initial"!==t)throw new Error("Already listening");const i=l.event(e);if(t="listening",0===n.length)return i;for(const e of n)e.message?a(e.message):e.error&&c(e.error);return n.length=0,i},dispose(){e.removeEventListener("message",u),e.removeEventListener("close",d),i.dispose(),o.dispose(),r.dispose(),n.length=0}}},A=e=>{const t=new s.Emitter,n=new s.Emitter,i=()=>{n.fire()};e.addEventListener("close",i);let o=0;return{get onError(){return t.event},get onClose(){return n.event},write(n){return q(this,void 0,void 0,(function*(){try{e.send(JSON.stringify(n))}catch(e){t.fire([U(e),n,++o])}}))},end(){},dispose(){t.dispose(),n.dispose(),e.removeEventListener("close",i)}}},U=e=>e instanceof Error?e:new Error((null==e?void 0:e.message)||"Unknown error"),$=()=>({error:e=>console.error(e),warn:e=>console.warn(e),info:e=>console.info(e),log:e=>console.log(e)});function B({rootURI:e,connectionString:t}){return q(this,void 0,void 0,(function*(){const n=new WebSocket(t),i=yield((e,t=$())=>new Promise((n=>{e.onopen=()=>{const i=s.createMessageConnection(N(e),A(e),t);i.onDispose((()=>e.close())),i.onClose((()=>i.dispose())),n(i)}})))(n);i.listen();const o=(e=>{let t;e.onRequest(r.RegistrationRequest.type,(({registrations:e})=>{for(const{method:n,registerOptions:i}of e){const e=F[n];e&&(t[e]=null==i||i)}})),e.onRequest(r.UnregistrationRequest.type,(({unregisterations:e})=>{for(const{method:n}of e){const e=F[n];e&&(t[e]=void 0)}}));const n=(t,n)=>(i,o)=>t()?e.sendRequest(n,i,o):Promise.resolve(null),i=(t,n)=>i=>t()?e.sendNotification(n,i):Promise.resolve(),o=t=>n=>e.sendNotification(t,n),s=t=>n=>{e.onNotification(t,n)};return{listen:()=>e.listen(),dispose:()=>e.dispose(),initialize:n=>q(void 0,void 0,void 0,(function*(){const i=yield e.sendRequest(r.InitializeRequest.type,n);return t=i.capabilities,i})),initialized:()=>e.sendNotification(r.InitializedNotification.type,{}),shutdown:()=>e.sendRequest(r.ShutdownRequest.type),exit:()=>e.sendNotification(r.ExitNotification.type),onError:t=>e.onError((([e,n,i])=>t(e,n,i))),onClose:t=>e.onClose((()=>t())),onLogMessage:s(r.LogMessageNotification.type),onShowMessage:s(r.ShowMessageNotification.type),onDiagnostics:s(r.PublishDiagnosticsNotification.type),textDocumentOpened:o(r.DidOpenTextDocumentNotification.type),textDocumentClosed:o(r.DidCloseTextDocumentNotification.type),textDocumentChanged:o(r.DidChangeTextDocumentNotification.type),textDocumentWillSave:i((()=>{var e;const n=null!==(e=t.textDocumentSync)&&void 0!==e?e:r.TextDocumentSyncKind.None;return"number"!=typeof n&&!!n.willSave}),r.WillSaveTextDocumentNotification.type),getEditsBeforeSave:n((()=>{var e;const n=null!==(e=t.textDocumentSync)&&void 0!==e?e:r.TextDocumentSyncKind.None;return"number"!=typeof n&&!!n.willSaveWaitUntil}),r.WillSaveTextDocumentWaitUntilRequest.type),textDocumentSaved:i((()=>{var e;const n=null!==(e=t.textDocumentSync)&&void 0!==e?e:r.TextDocumentSyncKind.None;return"number"==typeof n?n!==r.TextDocumentSyncKind.None:!!n.save}),r.DidSaveTextDocumentNotification.type),configurationChanged:o(r.DidChangeConfigurationNotification.type),watchedFilesChanged:o(r.DidChangeWatchedFilesNotification.type),getDocumentFormatting:n((()=>!!t.documentFormattingProvider),r.DocumentFormattingRequest.type),applyEdits:n((()=>!!t.workspace),r.ApplyWorkspaceEditRequest.type),executeCommand:n((()=>!!t.executeCommandProvider),r.ExecuteCommandRequest.type),getCompletion:n((()=>!!t.completionProvider),r.CompletionRequest.type),getCompletionItemDetails:n((()=>{var e;return!!(null===(e=t.completionProvider)||void 0===e?void 0:e.resolveProvider)}),r.CompletionResolveRequest.type),getHoverInfo:n((()=>!!t.hoverProvider),r.HoverRequest.type),getSignatureHelp:n((()=>!!t.signatureHelpProvider),r.SignatureHelpRequest.type),getDeclaration:n((()=>!!t.declarationProvider),r.DeclarationRequest.type),getDefinition:n((()=>!!t.definitionProvider),r.DefinitionRequest.type),getTypeDefinition:n((()=>!!t.typeDefinitionProvider),r.TypeDefinitionRequest.type),getImplementation:n((()=>!!t.implementationProvider),r.ImplementationRequest.type),getReferences:n((()=>!!t.referencesProvider),r.ReferencesRequest.type),getDocumentHighlight:n((()=>!!t.documentHighlightProvider),r.DocumentHighlightRequest.type),getDocumentSymbol:n((()=>!!t.documentSymbolProvider),r.DocumentSymbolRequest.type),getCodeAction:n((()=>!!t.codeActionProvider),r.CodeActionRequest.type),getCodeLens:n((()=>!!t.codeLensProvider),r.CodeLensRequest.type),resolveCodeLens:n((()=>{var e;return!!(null===(e=t.codeLensProvider)||void 0===e?void 0:e.resolveProvider)}),r.CodeLensResolveRequest.type),getDocumentLink:n((()=>!!t.documentLinkProvider),r.DocumentLinkRequest.type),resolveDocumentLink:n((()=>{var e;return!!(null===(e=t.documentLinkProvider)||void 0===e?void 0:e.resolveProvider)}),r.DocumentLinkResolveRequest.type),getColorSymbols:n((()=>!!t.colorProvider),r.DocumentColorRequest.type),getFoldingRanges:n((()=>!!t.foldingRangeProvider),r.FoldingRangeRequest.type),getSelectionRanges:n((()=>!!t.selectionRangeProvider),r.SelectionRangeRequest.type),getWorkspaceSymbols:n((()=>!!t.workspaceSymbolProvider),r.WorkspaceSymbolRequest.type),get syncsIncrementally(){var e,n;let i=null!==(e=t.textDocumentSync)&&void 0!==e?e:r.TextDocumentSyncKind.None;return"number"!=typeof i&&(i=null!==(n=i.change)&&void 0!==n?n:r.TextDocumentSyncKind.None),i===r.TextDocumentSyncKind.Incremental},get completionTriggers(){var e;return(null===(e=t.completionProvider)||void 0===e?void 0:e.triggerCharacters)||[]},get signatureHelpTriggers(){var e;return(null===(e=t.signatureHelpProvider)||void 0===e?void 0:e.triggerCharacters)||[]},get signatureHelpRetriggers(){var e;return(null===(e=t.signatureHelpProvider)||void 0===e?void 0:e.retriggerCharacters)||[]}}})(i),{capabilities:l}=yield function(e,t){return q(this,void 0,void 0,(function*(){const n=yield e.initialize({capabilities:{textDocument:{synchronization:{dynamicRegistration:!0,didSave:!0},completion:{dynamicRegistration:!0,completionItem:{snippetSupport:!1,insertReplaceSupport:!1,commitCharactersSupport:!1,documentationFormat:["markdown","plaintext"],labelDetailsSupport:!0,deprecatedSupport:!0,preselectSupport:!0,resolveSupport:{properties:["documentation","detail"]}},contextSupport:!0},hover:{dynamicRegistration:!0,contentFormat:["markdown","plaintext"]},signatureHelp:{dynamicRegistration:!0,signatureInformation:{documentationFormat:["markdown","plaintext"],parameterInformation:{labelOffsetSupport:!0},activeParameterSupport:!0},contextSupport:!0},codeAction:{dynamicRegistration:!0},formatting:{dynamicRegistration:!0},rename:{dynamicRegistration:!0},publishDiagnostics:{versionSupport:!0,codeDescriptionSupport:!0,relatedInformation:!0,tagSupport:{valueSet:[r.DiagnosticTag.Unnecessary,r.DiagnosticTag.Deprecated]}},moniker:{}},workspace:{didChangeConfiguration:{dynamicRegistration:!0},didChangeWatchedFiles:{dynamicRegistration:!0}}},processId:null,rootUri:t,workspaceFolders:null});return e.initialized().catch((e=>console.error(e))),n}))}(o,e);return{lsp:o,capabilities:l}}))}const W=(J=49152,G=65535,function(e){return e>=G?J:e+1});var J,G;function Q(e,t){if(t.line>=e.lines)return e.length;const n=e.line(t.line+1).from+t.character;return n>e.length?e.length:n}function X(e,t){const n=e.lineAt(t);return{line:n.number-1,character:t-n.from}}function Y(e){return Array.isArray(e)?e.map(Y).join("\n\n"):"string"==typeof e?e:e.value}function Z(e){let t="",n=Array.from(e).join("");return/\w/.test(n)&&(t+="\\w",n=n.replace(/\w/g,"")),`[${t}${n.replace(/[^\w\s]/g,"\\$&")}]`}function ee(e){if(!D.default.isAbsolute(e))throw new Error("filepath must be absolute");return`file://${e}`}function te(e){return ee(e.endsWith("/")?e:e+"/")}function ne(e,t){return t.find((({fileExtensions:t})=>null==t?void 0:t.some((t=>e.endsWith(t)))))}var ie=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M14.5 3H7.71l-.85-.85L6.51 2h-5l-.5.5v11l.5.5h13l.5-.5v-10L14.5 3zm-.51 8.49V13h-12V7h4.49l.35-.15.86-.86H14v1.5l-.01 4zm0-6.49h-6.5l-.35.15-.86.86H2v-3h4.29l.85.85.36.15H14l-.01.99z"/></svg>'}),oe=Object.freeze({__proto__:null,default:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M11.105 4.561l-3.43 3.427-1.134-1.12 2.07-2.08h-4.8a2.4 2.4 0 1 0 0 4.8h.89v1.6h-.88a4 4 0 0 1 0-7.991h4.8L6.54 1.13 7.675 0l3.43 3.432v1.13zM16.62 24h-9.6l-.8-.8V10.412l.8-.8h9.6l.8.8V23.2l-.8.8zm-8.8-1.6h8V11.212h-8V22.4zm5.6-20.798h9.6l.8.8v12.786l-.8.8h-4v-1.6h3.2V3.2h-8v4.787h-1.6V2.401l.8-.8zm.8 11.186h-4.8v1.6h4.8v-1.6zm-4.8 3.2h4.8v1.6h-4.8v-1.6zm4.8 3.2h-4.8v1.6h4.8v-1.6zm1.6-14.4h4.8v1.6h-4.8v-1.6zm4.8 6.4h-1.6v1.6h1.6v-1.6zm-3.338-3.176v-.024h3.338v1.6h-1.762l-1.576-1.576z"/></svg>'}),re=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M11.34 9.71h.71l2.67-2.67v-.71L13.38 5h-.7l-1.82 1.81h-5V5.56l1.86-1.85V3l-2-2H5L1 5v.71l2 2h.71l1.14-1.15v5.79l.5.5H10v.52l1.33 1.34h.71l2.67-2.67v-.71L13.37 10h-.7l-1.86 1.85h-5v-4H10v.48l1.34 1.38zm1.69-3.65l.63.63-2 2-.63-.63 2-2zm0 5l.63.63-2 2-.63-.63 2-2zM3.35 6.65l-1.29-1.3 3.29-3.29 1.3 1.29-3.3 3.3z"/></svg>'}),se=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M8 1.003a7 7 0 0 0-7 7v.43c.09 1.51 1.91 1.79 3 .7a1.87 1.87 0 0 1 2.64 2.64c-1.1 1.16-.79 3.07.8 3.2h.6a7 7 0 1 0 0-14l-.04.03zm0 13h-.52a.58.58 0 0 1-.36-.14.56.56 0 0 1-.15-.3 1.24 1.24 0 0 1 .35-1.08 2.87 2.87 0 0 0 0-4 2.87 2.87 0 0 0-4.06 0 1 1 0 0 1-.9.34.41.41 0 0 1-.22-.12.42.42 0 0 1-.1-.29v-.37a6 6 0 1 1 6 6l-.04-.04zM9 3.997a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 7.007a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-7-5a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm7-1a1 1 0 1 1-2 0 1 1 0 0 1 2 0zM13 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"/></svg>'}),le=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3l1-1h6l1 1v5l-1 1h-4V8h4V3H8v3H7V3zm2 6V8L8 7H2L1 8v5l1 1h6l1-1V9zM8 8v5H2V8h6zm1.414-1L9 6.586V6h4v1H9.414zM9 4h4v1H9V4zm-2 6H3v1h4v-1z"/></svg>'}),ae=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M14 2H8L7 3v3h1V3h6v5h-4v1h4l1-1V3l-1-1zM9 6h4v1H9.41L9 6.59V6zM7 7H2L1 8v5l1 1h6l1-1V8L8 7H7zm1 6H2V8h6v5zM3 9h4v1H3V9zm0 2h4v1H3v-1zm6-7h4v1H9V4z"/></svg>'}),ce=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M7.414 1.56L8.312 1h3.294l.818 1.575L10.236 6h1.781l.72 1.695L5.618 15l-1.602-1.163L6.119 10H4.898L4 8.56l3.414-7zM7.78 9L4.9 14.305 12.018 7H8.312l3.294-5H8.312L4.898 9H7.78z"/></svg>'}),ue=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M14.45 4.5l-5-2.5h-.9l-7 3.5-.55.89v4.5l.55.9 5 2.5h.9l7-3.5.55-.9v-4.5l-.55-.89zm-8 8.64l-4.5-2.25V7.17l4.5 2v3.97zm.5-4.8L2.29 6.23l6.66-3.34 4.67 2.34-6.67 3.11zm7 1.55l-6.5 3.25V9.21l6.5-3v3.68z"/></svg>'}),de=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M13.85 4.44l-3.28-3.3-.35-.14H2.5l-.5.5v13l.5.5h11l.5-.5V4.8l-.15-.36zM13 5h-3V2l3 3zM3 14V2h6v3.5l.5.5H13v8H3z"/></svg>'}),ge=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M11.496 4a3.49 3.49 0 0 0-3.46 3h-3.1a2 2 0 1 0 0 1h3.1a3.5 3.5 0 1 0 3.46-4zm0 6a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5z"/></svg>'}),he=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M15 4h-5V3h5v1zm-1 3h-2v1h2V7zm-4 0H1v1h9V7zm2 6H1v1h11v-1zm-5-3H1v1h6v-1zm8 0h-5v1h5v-1zM8 2v3H1V2h7zM7 3H2v1h5V3z"/></svg>'}),ve=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M13.51 4l-5-3h-1l-5 3-.49.86v6l.49.85 5 3h1l5-3 .49-.85v-6L13.51 4zm-6 9.56l-4.5-2.7V5.7l4.5 2.45v5.41zM3.27 4.7l4.74-2.84 4.74 2.84-4.74 2.59L3.27 4.7zm9.74 6.16l-4.5 2.7V8.15l4.5-2.45v5.16z"/></svg>'}),me=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M6 2.984V2h-.09c-.313 0-.616.062-.909.185a2.33 2.33 0 0 0-.775.53 2.23 2.23 0 0 0-.493.753v.001a3.542 3.542 0 0 0-.198.83v.002a6.08 6.08 0 0 0-.024.863c.012.29.018.58.018.869 0 .203-.04.393-.117.572v.001a1.504 1.504 0 0 1-.765.787 1.376 1.376 0 0 1-.558.115H2v.984h.09c.195 0 .38.04.556.121l.001.001c.178.078.329.184.455.318l.002.002c.13.13.233.285.307.465l.001.002c.078.18.117.368.117.566 0 .29-.006.58-.018.869-.012.296-.004.585.024.87v.001c.033.283.099.558.197.824v.001c.106.273.271.524.494.753.223.23.482.407.775.53.293.123.596.185.91.185H6v-.984h-.09c-.199 0-.387-.038-.562-.115a1.613 1.613 0 0 1-.457-.32 1.659 1.659 0 0 1-.309-.467c-.074-.18-.11-.37-.11-.573 0-.228.003-.453.011-.672.008-.228.008-.45 0-.665a4.639 4.639 0 0 0-.055-.64 2.682 2.682 0 0 0-.168-.609A2.284 2.284 0 0 0 3.522 8a2.284 2.284 0 0 0 .738-.955c.08-.192.135-.393.168-.602.033-.21.051-.423.055-.64.008-.22.008-.442 0-.666-.008-.224-.012-.45-.012-.678a1.47 1.47 0 0 1 .877-1.354 1.33 1.33 0 0 1 .563-.121H6zm4 10.032V14h.09c.313 0 .616-.062.909-.185.293-.123.552-.3.775-.53.223-.23.388-.48.493-.753v-.001c.1-.266.165-.543.198-.83v-.002c.028-.28.036-.567.024-.863-.012-.29-.018-.58-.018-.869 0-.203.04-.393.117-.572v-.001a1.504 1.504 0 0 1 .765-.787c.176-.077.362-.115.558-.115H14v-.984h-.09c-.195 0-.38-.04-.556-.121l-.001-.001a1.376 1.376 0 0 1-.455-.318l-.002-.002a1.414 1.414 0 0 1-.307-.465l-.001-.002a1.405 1.405 0 0 1-.117-.566c0-.29.006-.58.018-.869a6.19 6.19 0 0 0-.024-.87v-.001a3.542 3.542 0 0 0-.197-.824v-.001a2.23 2.23 0 0 0-.494-.753 2.33 2.33 0 0 0-.775-.53 2.325 2.325 0 0 0-.91-.185H10v.984h.09c.2 0 .386.038.562.115.174.082.326.188.457.32.127.134.23.29.309.467.074.18.11.37.11.573 0 .228-.003.452-.011.672-.008.228-.008.45 0 .665.004.222.022.435.055.64.033.214.089.416.168.609a2.282 2.282 0 0 0 .738.955 2.282 2.282 0 0 0-.738.955 2.7 2.7 0 0 0-.168.602c-.033.21-.051.423-.055.64-.008.22-.008.442 0 .666.008.224.012.45.012.678a1.47 1.47 0 0 1-.42 1.035 1.466 1.466 0 0 1-.457.319 1.33 1.33 0 0 1-.563.121H10z"/></svg>'}),pe=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2.873 1.1c.335.136.602.398.745.73.072.17.109.352.107.537a1.34 1.34 0 0 1-.61 1.135 1.359 1.359 0 0 1-.753.223A1.355 1.355 0 0 1 1 2.362a1.355 1.355 0 0 1 .83-1.256A1.37 1.37 0 0 1 2.873 1.1zm-.298 1.765a.551.551 0 0 0 .332-.5.548.548 0 1 0-.332.5zM6.43 1.109L1.11 6.43l.686.687 5.32-5.32-.686-.687zM11.5 9h1v2.5H15v1h-2.5V15h-1v-2.5H9v-1h2.5V9zm-5.732.525l.707.707L4.707 12l1.768 1.768-.707.707L4 12.707l-1.768 1.768-.707-.707L3.293 12l-1.768-1.768.707-.707L4 11.293l1.768-1.768zm1.35-4.195a1.353 1.353 0 0 0-1.256-.83 1.355 1.355 0 0 0-1.256.83 1.362 1.362 0 0 0 1.257 1.895A1.358 1.358 0 0 0 7.118 5.33zm-.753.745a.553.553 0 0 1-.289.29.547.547 0 0 1-.599-.117.529.529 0 0 1-.117-.173.544.544 0 0 1 .716-.715.565.565 0 0 1 .173.116.549.549 0 0 1 .116.599zM14 3h-4v1h4V3z"/></svg>'}),fe=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M2.807 14.975a1.75 1.75 0 0 1-1.255-.556 1.684 1.684 0 0 1-.544-1.1A1.72 1.72 0 0 1 1.36 12.1c1.208-1.27 3.587-3.65 5.318-5.345a4.257 4.257 0 0 1 .048-3.078 4.095 4.095 0 0 1 1.665-1.969 4.259 4.259 0 0 1 4.04-.36l.617.268-2.866 2.951 1.255 1.259 2.944-2.877.267.619a4.295 4.295 0 0 1 .04 3.311 4.198 4.198 0 0 1-.923 1.392 4.27 4.27 0 0 1-.743.581 4.217 4.217 0 0 1-3.812.446c-1.098 1.112-3.84 3.872-5.32 5.254a1.63 1.63 0 0 1-1.084.423zm7.938-13.047a3.32 3.32 0 0 0-1.849.557c-.213.13-.412.284-.591.458a3.321 3.321 0 0 0-.657 3.733l.135.297-.233.227c-1.738 1.697-4.269 4.22-5.485 5.504a.805.805 0 0 0 .132 1.05.911.911 0 0 0 .298.22c.1.044.209.069.319.072a.694.694 0 0 0 .45-.181c1.573-1.469 4.612-4.539 5.504-5.44l.23-.232.294.135a3.286 3.286 0 0 0 3.225-.254 3.33 3.33 0 0 0 .591-.464 3.28 3.28 0 0 0 .964-2.358c0-.215-.021-.43-.064-.642L11.43 7.125 8.879 4.578l2.515-2.59a3.286 3.286 0 0 0-.65-.06z"/></svg>'}),we=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M4 1L3 2v12l1 1h8l1-1V2l-1-1H4zm0 2V2h8v12H4v-1h2v-1H4v-2h4V9H4V7h2V6H4V4h4V3H4z"/></svg>'}),ye=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2.5 1l-.5.5V13h1V2h11v11h1V1.5l-.5-.5h-12zM2 15v-1h1v1H2zm3-1H4v1h1v-1zm1 0h1v1H6v-1zm3 0H8v1h1v-1zm1 0h1v1h-1v-1zm5 1v-1h-1v1h1zm-3-1h1v1h-1v-1z"/></svg>'}),xe=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 2L1 3v9l1 1h12l1-1V3l-1-1H2zm0 10V3h12v9H2zm3.356-3.07H6V7.22C6 6.408 5.685 6 5.056 6c-.135 0-.285.024-.45.073a1.444 1.444 0 0 0-.388.167v.665c.237-.203.487-.304.75-.304.261 0 .392.156.392.469l-.6.103c-.506.086-.76.406-.76.961 0 .263.061.473.183.631A.61.61 0 0 0 4.69 9c.29 0 .509-.16.657-.48h.009v.41zm.004-1.355v.193a.75.75 0 0 1-.12.436.368.368 0 0 1-.313.17.276.276 0 0 1-.22-.095.38.38 0 0 1-.08-.248c0-.222.11-.351.332-.389l.4-.067zM7.6 8.626h-.007v.31H7V5h.593v1.677h.008c.146-.31.355-.465.625-.465.248 0 .44.118.573.353.134.236.201.557.201.966 0 .443-.078.798-.235 1.067C8.61 8.866 8.4 9 8.138 9c-.237 0-.416-.125-.537-.374zm-.016-1.121v.272a.78.78 0 0 0 .107.426c.071.113.163.169.274.169.135 0 .24-.072.314-.216.075-.145.113-.35.113-.615 0-.22-.035-.39-.104-.514-.067-.124-.164-.187-.29-.187-.12 0-.219.062-.298.185a.887.887 0 0 0-.116.48zM11.262 9c.321 0 .567-.058.738-.173v-.71a.9.9 0 0 1-.552.207.619.619 0 0 1-.5-.215c-.12-.145-.181-.345-.181-.598 0-.26.063-.464.189-.612a.644.644 0 0 1 .516-.223c.194 0 .37.069.528.207v-.749c-.129-.09-.338-.134-.626-.134-.417 0-.751.14-1.001.422-.249.28-.373.662-.373 1.148 0 .42.116.764.349 1.03.232.267.537.4.913.4z"/></svg>'}),Ce=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 2L1 3v3l1 1h12l1-1V3l-1-1H2zm0 1h12v3H2V3zm-1 7l1-1h3l1 1v3l-1 1H2l-1-1v-3zm2 0H2v3h3v-3H3zm7 0l1-1h3l1 1v3l-1 1h-3l-1-1v-3zm2 0h-1v3h3v-3h-2z"/></svg>'}),Se=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 5h2V4H1.5l-.5.5v8l.5.5H4v-1H2V5zm12.5-1H12v1h2v7h-2v1h2.5l.5-.5v-8l-.5-.5zm-2.74 2.57L12 7v2.51l-.3.45-4.5 2h-.46l-2.5-1.5-.24-.43v-2.5l.3-.46 4.5-2h.46l2.5 1.5zM5 9.71l1.5.9V9.28L5 8.38v1.33zm.58-2.15l1.45.87 3.39-1.5-1.45-.87-3.39 1.5zm1.95 3.17l3.5-1.56v-1.4l-3.5 1.55v1.41z"/></svg>'});function be(e){return e[e.length-1]}function ze(e){const t=document.createElement("template");return t.innerHTML=e,Array.from(t.content.childNodes)}function De(e){return q(this,void 0,void 0,(function*(){const t=yield function(e){return q(this,void 0,void 0,(function*(){return(yield y.unified().use(V.default).use(_.default).use(T.default,{allowDangerousHtml:!0}).use(R.default).use(I.default).data("settings",{fragment:!0}).use(P.default,{detect:!0}).use(E.default,{rel:"noopener noreferrer",target:"_blank"}).use(L.default).process(e)).toString()}))}(e);return ze(t)}))}const He=Object.fromEntries(Object.entries(r.CompletionItemKind).map((([e,t])=>[t,e.toLowerCase()]))),Ee=Object.fromEntries(Object.entries(r.CompletionItemKind).map((([e,t])=>[e.toLowerCase(),t]))),Pe=n.Facet.define({combine:be}),Re=n.Facet.define({combine:be}),Ie=n.Facet.define({combine:be});class Le{constructor(e,t){this.view=e,this.documentVersion=0;const n=this.view.state;this.client=n.facet(Pe),this.documentURI=e.state.facet(Re),this.client.attachPlugin(this),this.openPromise=t?this.client.lsp.textDocumentOpened({textDocument:{text:n.doc.toString(),languageId:n.facet(Ie),uri:this.documentURI,version:this.documentVersion}}):this.client.lsp.textDocumentChanged({textDocument:{uri:this.documentURI,version:this.nextDocumentVersion},contentChanges:[{text:n.doc.toString()}]})}get nextDocumentVersion(){return++this.documentVersion}update({docChanged:e,state:t}){return q(this,void 0,void 0,(function*(){e&&(yield this.openPromise,yield this.client.lsp.textDocumentChanged({textDocument:{uri:this.documentURI,version:this.nextDocumentVersion},contentChanges:[{text:t.doc.toString()}]}))}))}destroy(){this.client.detachPlugin(this)}requestFormatting(e){var t;return q(this,void 0,void 0,(function*(){if(!(null===(t=this.client.capabilities)||void 0===t?void 0:t.documentFormattingProvider))return null;const i=e.state,o=yield this.client.lsp.getDocumentFormatting({textDocument:{uri:this.documentURI},options:{insertSpaces:!0,tabSize:2,trimFinalNewlines:!0,insertFinalNewline:!0,trimTrailingWhitespace:!0}}),r=(null==o?void 0:o.map((e=>({from:Q(i.doc,e.range.start)||0,to:Q(i.doc,e.range.end),insert:e.newText}))))||[],s=function(e,t){let i=0;return t.reduce(((e,t)=>{if(t instanceof n.ChangeSet||Array.isArray(t)||!("from"in t))throw new Error("This function does not support ChangeSet or nested ChangeSpec");const o=i+t.from,r=i+((null==t?void 0:t.to)||0),s=t.insert||"";return i+=s.length-(r-o),e.slice(0,o)+s+e.slice(r)}),e)}(i.doc.toString(),r),l=H.diffChars(i.doc.toString(),s),a=[];let c=0;l.forEach((e=>{e.removed?(a.push({from:c,to:c+e.value.length}),c+=e.value.length):e.added?a.push({from:c,insert:e.value}):c+=e.value.length})),a.length&&e.dispatch({annotations:[n.Transaction.remote.of(!0),n.Transaction.addToHistory.of(!0)],changes:a})}))}requestHoverTooltip({state:{doc:e}},{line:t,character:n}){return q(this,void 0,void 0,(function*(){if(!this.client.capabilities.hoverProvider)return null;const i=yield this.client.lsp.getHoverInfo({textDocument:{uri:this.documentURI},position:{line:t,character:n}});if(!i)return null;const{contents:o,range:r}=i;let s=Q(e,{line:t,character:n});const l=Y(o),a=yield De(l);if(0===a.length)return null;const c=document.createElement("div");let u;return c.id="root2",c.classList.add("documentation"),c.append(...a),r&&(s=Q(e,r.start),u=Q(e,r.end)),null===s?null:{pos:s,end:u,create:()=>({dom:c}),above:!0}}))}requestSignatureHelp(e,t,n,i){var o,s,l,a,c;return q(this,void 0,void 0,(function*(){if(!(null===(o=this.client.capabilities)||void 0===o?void 0:o.signatureHelpProvider))return null;const{state:u,pos:d,explicit:g}=e;if(g)return null;const h=u.doc.lineAt(d),v=h.text[d-h.from-1];let m,p=r.SignatureHelpTriggerKind.ContentChange;if((i&&(null===(l=null===(s=this.client.capabilities.signatureHelpProvider)||void 0===s?void 0:s.triggerCharacters)||void 0===l?void 0:l.includes(v))||n&&(null===(c=null===(a=this.client.capabilities.signatureHelpProvider)||void 0===a?void 0:a.retriggerCharacters)||void 0===c?void 0:c.includes(v)))&&(m=v,p=r.SignatureHelpTriggerKind.TriggerCharacter),!t&&p===r.SignatureHelpTriggerKind.ContentChange)return null;const f=X(u.doc,d);return yield this.client.lsp.getSignatureHelp({position:f,textDocument:{uri:this.documentURI},context:{triggerKind:p,triggerCharacter:m,isRetrigger:n,activeSignatureHelp:t}})}))}requestCompletion(e,{line:t,character:n},{triggerKind:i,triggerCharacter:o}){return q(this,void 0,void 0,(function*(){if(!this.client.capabilities.completionProvider)return null;const s=yield this.client.lsp.getCompletion({textDocument:{uri:this.documentURI},position:{line:t,character:n},context:{triggerKind:i,triggerCharacter:o}});if(!s)return null;let l=("items"in s?s.items:s).map((e=>{const{detail:t,label:n,kind:i,textEdit:o,documentation:s,sortText:l,insertText:c,insertTextFormat:u,additionalTextEdits:d,filterText:g}=e;let h,v=null;o?(h=o.newText,h=(e,t)=>{const n=[],i=e.state;"range"in o?u===r.InsertTextFormat.Snippet||n.push({from:Q(i.doc,o.range.start),to:Q(i.doc,o.range.end),insert:o.newText}):console.error("Not supporting insert replace language server capability"),null==d||d.forEach((e=>{n.push({from:Q(i.doc,e.range.start),to:Q(i.doc,e.range.end),insert:e.newText})})),e.dispatch({annotations:a.pickedCompletion.of(t),changes:n})}):h=c?u===r.InsertTextFormat.Snippet?(e,t,n,i)=>{const o=c.indexOf("$0"),r=c.replace("$0",""),s=-1===o?void 0:n+o;e.dispatch({annotations:a.pickedCompletion.of(t),changes:[{from:n,to:i,insert:r}],selection:s?{head:s,anchor:s}:void 0})}:c:n;return{label:n,detail:t,apply:h,type:i&&He[i],sortText:null!=l?l:n,filterText:null!=g?g:n,info:()=>q(this,void 0,void 0,(function*(){let t,n=s;if(n||v||(v=yield this.client.lsp.getCompletionItemDetails(e)),(null==v?void 0:v.labelDetails)&&(t=v.label+v.labelDetails.detail+v.labelDetails.description),n=(null==v?void 0:v.documentation)||s||t,!n)return null;const i=Y(n),o=yield De(i);if(0===o.length)return null;const r=document.createElement("div");return r.id="root3",r.classList.add("documentation"),r.append(...o),r}))}}));if(0===l.length)return null;const[,c]=function(e){const t=new Set,n=new Set;for(const{label:i}of e){const[e,...o]=i;t.add(e);for(const e of o)n.add(e)}const i=Z(t)+Z(n)+"*$";return[new RegExp("^"+i),new RegExp(i)]}(l),u=e.matchBefore(c);let{pos:d}=e;if(u){const e=u.text.toLowerCase();d=u.from,/^\w+$/.test(e)&&(l=l.filter((({filterText:t})=>t.toLowerCase().startsWith(e))).sort((({label:e},{label:t})=>{switch(!0){case e.startsWith(u.text)&&!t.startsWith(u.text):return-1;case!e.startsWith(u.text)&&t.startsWith(u.text):return 1}return 0})))}const g=l.reduce(((e,t)=>Math.max(e,t.label.length)),0);return{from:d,options:l,validFor:e=>0!==e.length&&(!e.endsWith(".")&&(!e.endsWith(" ")&&!(e.length>g)))}}))}onDiagnostics(e){if(e.uri!==this.documentURI)return;const t=this.view.state,n=e.diagnostics.map((({range:e,message:n,severity:i})=>({from:Q(t.doc,e.start),to:Q(t.doc,e.end),severity:i&&{[r.DiagnosticSeverity.Error]:"error",[r.DiagnosticSeverity.Warning]:"warning",[r.DiagnosticSeverity.Information]:"info",[r.DiagnosticSeverity.Hint]:"info"}[i]||"info",message:n}))).filter((({from:e,to:t})=>null!==e&&null!==t&&void 0!==e&&void 0!==t)).sort(((e,t)=>{switch(!0){case e.from<t.from:return-1;case e.from>t.from:return 1}return 0}));this.view.dispatch(c.setDiagnostics(t,n))}}function _e(){const e=Object.fromEntries(Object.entries(Ee).map((([e,t])=>{const n=ze(function(e){switch(e){case r.CompletionItemKind.Class:return re;case r.CompletionItemKind.Color:return se;case r.CompletionItemKind.Constant:return Se;case r.CompletionItemKind.Constructor:return ve;case r.CompletionItemKind.Enum:return ae;case r.CompletionItemKind.EnumMember:return le;case r.CompletionItemKind.Event:return ce;case r.CompletionItemKind.Field:return ue;case r.CompletionItemKind.File:return de;case r.CompletionItemKind.Folder:return ie;case r.CompletionItemKind.Function:return ve;case r.CompletionItemKind.Interface:return ge;case r.CompletionItemKind.Keyword:return he;case r.CompletionItemKind.Method:return ve;case r.CompletionItemKind.Module:return me;case r.CompletionItemKind.Operator:return pe;case r.CompletionItemKind.Property:return fe;case r.CompletionItemKind.Reference:return oe;case r.CompletionItemKind.Snippet:return ye;case r.CompletionItemKind.Struct:return Ce;case r.CompletionItemKind.Text:return xe;case r.CompletionItemKind.TypeParameter:return re;case r.CompletionItemKind.Unit:return we;case r.CompletionItemKind.Value:return ae;case r.CompletionItemKind.Variable:return Se}}(t).default),i=document.createElement("div");return i.classList.add("autocomplete-icon",`autocomplete-icon-${e}`),i.append(...n),[e,i]})));return{getImage(t){const n=e[t];if(n)return n.cloneNode(!0)}}}class Ve{constructor(e,t,n){this.view=e,this.getPlugin=t,this.setSignatureHelp=n}update(e){return q(this,void 0,void 0,(function*(){const t=this.getPlugin();if(!t)return;if(!e.transactions.some((e=>e.isUserEvent("select.pointer")))&&(e.docChanged||e.startState.selection.main.head!==e.state.selection.main.head)){yield t.update(e);const n=e.state.selection.main.head,i=new a.CompletionContext(e.state,n,!1);yield this.updateSignature(e.state,i,e.docChanged)}}))}updateSignature(e,t,n){return q(this,void 0,void 0,(function*(){const i=this.getPlugin();if(!i)return;const o=yield i.requestSignatureHelp(t,this.lastSignature,!!this.lastSignature,n);this.lastSignature=o||void 0;const r=o?yield this.getTooltip(e,o):null;this.setTooltip(r)}))}getTooltip(e,t){return q(this,void 0,void 0,(function*(){const n=void 0!==t.activeSignature?t.signatures[t.activeSignature]:void 0;if(!n)return null;n.activeParameter=void 0!==n.activeParameter?n.activeParameter:null==t?void 0:t.activeParameter;const i=Y(n.documentation||""),o=yield De(i),r=n.parameters&&void 0!==n.activeParameter?n.parameters[n.activeParameter]:void 0,s=Y((null==r?void 0:r.documentation)||""),l=yield De(s);if(0===o.length)return null;const a=document.createElement("div");a.id="root4",a.classList.add("documentation");const c=document.createElement("code");c.classList.add("signature-label"),c.innerHTML=function(e,t){if(void 0===e.activeParameter)return e.label;if(!e.parameters)return e.label;const n=e.parameters[e.activeParameter];if(!n)return e.label;const i="string"==typeof n.label?n.label:e.label.slice(n.label[0],n.label[1]);return e.label.replace(i,t(i))}(n,(e=>`<code class="selected-param">${e}</code>`)),0===o.length&&0===l.length||(c.innerHTML+="<br/><br/>"),a.appendChild(c),a.append(...o),0!==l.length&&a.append(...l);return{pos:e.selection.main.head,create:()=>({dom:a}),above:!0}}))}setTooltip(e){const t=this.setSignatureHelp.of(e);this.view.dispatch({effects:t})}}const Te=n.StateEffect.define(),qe=Te.of(null);function ke(e){const t=n.StateField.define({create:()=>null,update(e,t){if(t.isUserEvent("select.pointer"))return null;for(const e of t.effects)if(e.is(Te))return e.value;return e},provide:e=>i.showTooltip.compute(["selection",e],(t=>{if(!e)return null;const n=t.field(e);return n?(n.pos=t.selection.main.head,Object.assign({},n)):null}))});return[i.ViewPlugin.define((t=>new Ve(t,e,Te))),t]}const Me={"data-gramm":"false",spellcheck:"false"};function Oe(e){const t=new n.Compartment,o=new n.Compartment,r=new n.Compartment,s=new n.Compartment;return{state:n.EditorState.create({doc:e,extensions:[i.EditorView.contentAttributes.of(Me),s.of([]),i.lineNumbers(),C.bracketMatching(),i.highlightActiveLineGutter(),i.highlightSpecialChars(),x.history(),i.scrollPastEnd(),n.EditorState.tabSize.of(2),i.drawSelection(),i.dropCursor(),a.closeBrackets(),C.indentOnInput(),i.highlightActiveLine(),i.keymap.of([...x.defaultKeymap,...a.closeBracketsKeymap,...x.historyKeymap,...C.foldKeymap,x.indentWithTab,{key:"Mod-s",run:()=>!0}]),o.of([]),r.of([]),t.of([]),C.syntaxHighlighting(S.classHighlighter)]}),languageExtensions:t,languageServiceExtensions:o,contentHandlingExtensions:r,editabilityExtensions:s}}const je=o.forwardRef((({content:e="",onContentChange:s,isReadOnly:l=!1,supportedLanguages:c,height:u,className:d="",autofocus:g,filename:h,languageClients:v,openFileInLanguageServer:m=!0},p)=>{const f=o.useRef(null),[w,y]=o.useState(),x=ne(h,c),C=x&&(null==v?void 0:v[null==x?void 0:x.languageID]);return o.useImperativeHandle(p,(()=>({focus:()=>null==w?void 0:w.view.focus()})),[w]),o.useLayoutEffect((function(){if(!f.current)return;const{languageServiceExtensions:t,contentHandlingExtensions:n,languageExtensions:o,editabilityExtensions:r,state:s}=Oe(e),l=new i.EditorView({state:s,parent:f.current});return y({view:l,languageServiceExtensions:t,contentHandlingExtensions:n,languageExtensions:o,editabilityExtensions:r}),g&&l.focus(),()=>{l.destroy(),y(void 0)}}),[g,e]),o.useEffect((function(){if(w&&(null==x?void 0:x.languageExtensions))return w.view.dispatch({effects:w.languageExtensions.reconfigure(x.languageExtensions)}),()=>{w.view.dispatch({effects:w.languageExtensions.reconfigure([])})}}),[w,x]),o.useEffect((function(){if(!w)return;const e=[n.EditorState.readOnly.of(l),i.EditorView.editable.of(!l)];return w.view.dispatch({effects:w.editabilityExtensions.reconfigure(e)}),()=>{w.view.dispatch({effects:w.editabilityExtensions.reconfigure([])})}}),[w,l]),o.useEffect((function(){if(!w)return;if(!s)return;const e=i.EditorView.updateListener.of((e=>{e.docChanged&&(null==s||s(e.state.doc.toString()))}));return w.view.dispatch({effects:w.contentHandlingExtensions.reconfigure(e)}),()=>{w.view.dispatch({effects:w.contentHandlingExtensions.reconfigure([])})}}),[w,s]),o.useEffect((function(){if(!w)return;if(!h)return;if(!C)return;const e=function(e){let t=null;const{getImage:o}=_e();return[Pe.of(e.client),Re.of(e.documentURI),Ie.of(e.client.languageID),i.ViewPlugin.define((n=>t=new Le(n,e.openFile))),n.Prec.highest(i.keymap.of([{key:"Mod-s",run:e=>(null==t||t.requestFormatting(e),!1)},{key:"Escape",run:e=>(e.dispatch({effects:[i.closeHoverTooltips,qe]}),!1)}])),ke((()=>t)),i.hoverTooltip(((e,n)=>q(this,void 0,void 0,(function*(){if(!t)return null;const i=X(e.state.doc,n);return yield t.requestHoverTooltip(e,i)})))),a.autocompletion({activateOnTyping:!0,maxRenderedOptions:40,closeOnBlur:!1,icons:!1,addToOptions:[{render:e=>e.type?(e.iconCache||(e.iconCache=o(e.type)),e.iconCache||null):null,position:20}],override:[e=>q(this,void 0,void 0,(function*(){var n,i,o;if(!t)return null;const{state:s,pos:l,explicit:a}=e,c=s.doc.lineAt(l);let u,d=r.CompletionTriggerKind.Invoked;return!a&&(null===(o=null===(i=null===(n=t.client.capabilities)||void 0===n?void 0:n.completionProvider)||void 0===i?void 0:i.triggerCharacters)||void 0===o?void 0:o.includes(c.text[l-c.from-1]))&&(d=r.CompletionTriggerKind.TriggerCharacter,u=c.text[l-c.from-1]),yield t.requestCompletion(e,X(s.doc,l),{triggerKind:d,triggerCharacter:u})}))]})]}({client:C,documentURI:ee(h),openFile:m});return w.view.dispatch({effects:w.languageServiceExtensions.reconfigure(e)}),()=>{w.view.dispatch({effects:w.languageServiceExtensions.reconfigure([])})}}),[w,C,h,m]),t.jsx("div",{className:`overflow-auto ${d}`,ref:f,style:Object.assign({},u&&{height:u})})}));je.displayName="CodeEditor",e.CodeEditor=je,e.getFileURI=ee,e.getLanguageSetup=ne,e.getRootURI=te,e.useLanguageServer=function({supportedLanguages:e,session:t,debug:n,rootdir:i}){const[r,s]=o.useState(),[l,a]=o.useState(),{maybeEmptyPort:c,markPortAsNotEmpty:u}=function(){const[e,t]=o.useState(49152);return{maybeEmptyPort:e,markPortAsNotEmpty:o.useCallback((()=>{t(W)}),[])}}();return o.useEffect((function(){if(!(null==t?void 0:t.process))return;const o=new K(i,e,t,c,n);return s(o),o.start().then((e=>{null==e||e.exited.then((()=>{u(),s((e=>e===o?void 0:e))}))})).catch((e=>console.error("Error starting language server",e))),()=>{s((e=>e===o?void 0:e)),o.stop()}}),[t,n,c,u,e]),o.useEffect((function(){if(r)return a({process:r}),Promise.all(r.languages.map((e=>q(this,void 0,void 0,(function*(){try{const t=yield r.getConnectionString(e);if(!t)return;const{lsp:n,capabilities:o}=yield B({rootURI:te(i),connectionString:t});return new M({languageID:e,capabilities:o,lsp:n})}catch(e){const t=e instanceof Error?e.message:JSON.stringify(e);console.error(t)}}))))).then((e=>{const t=e.reduce(((e,t)=>(t&&(e[t.languageID]=t),e)),{});a((e=>(null==e?void 0:e.process)===r?{process:e.process,clients:t}:e))})),()=>{a((e=>{if((null==e?void 0:e.process)!==r||!e.clients)return e;Object.values(e.clients).map((e=>e.close()))}))}}),[r,i]),null==l?void 0:l.clients},Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react/jsx-runtime"),require("@codemirror/state"),require("@codemirror/view"),require("react"),require("vscode-languageserver-protocol"),require("vscode-ws-jsonrpc"),require("path-browserify"),require("@codemirror/autocomplete"),require("@codemirror/lint"),require("diff"),require("rehype-external-links"),require("rehype-highlight"),require("rehype-raw"),require("rehype-sanitize"),require("rehype-stringify"),require("remark-gfm"),require("remark-parse"),require("remark-rehype"),require("unified"),require("@codemirror/commands"),require("@codemirror/language"),require("@lezer/highlight")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","@codemirror/state","@codemirror/view","react","vscode-languageserver-protocol","vscode-ws-jsonrpc","path-browserify","@codemirror/autocomplete","@codemirror/lint","diff","rehype-external-links","rehype-highlight","rehype-raw","rehype-sanitize","rehype-stringify","remark-gfm","remark-parse","remark-rehype","unified","@codemirror/commands","@codemirror/language","@lezer/highlight"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@devbookhq/code-editor"]={},e.jsxRuntime,e.state,e.view,e.react,e.vscodeLanguageserverProtocol,e.vscodeWsJsonrpc,e.path,e.autocomplete,e.lint,e.Diff,e.rehypeExternalLinks,e.rehypeHighlight,e.rehypeRaw,e.rehypeSanitize,e.rehypeStringify,e.remarkGfm,e.remarkParse,e.remarkRehype,e.unified,e.commands,e.language,e.highlight)}(this,(function(e,t,n,i,o,r,s,l,a,c,u,d,g,h,v,p,m,f,w,y,x,C,S){"use strict";function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function z(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var D=b(l),H=z(u),E=b(d),P=b(g),R=b(h),L=b(v),I=b(p),_=b(m),V=b(f),T=b(w);function q(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{a(i.next(e))}catch(e){r(e)}}function l(e){try{a(i.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,l)}a((i=i.apply(e,t||[])).next())}))}class M{constructor(e,t=!1){this.logID=e,this.isEnabled=t}error(...e){console.error(`[${this.id()} ERROR]`,...e)}log(...e){this.isEnabled&&console.log(`[${this.id()}]`,...e)}id(){return"function"==typeof this.logID?this.logID():this.logID}}class k{constructor(e){this.plugins=[],this.languageID=e.languageID,this.lsp=e.lsp,this.capabilities=e.capabilities;const t=function(e,t="orange"){return function(...n){console.groupCollapsed(`%c[${e}]`,`color:${t};`,...n),console.trace(),console.groupEnd()}}(`LSP - ${this.languageID}`,"blue");this.lsp.onDiagnostics(this.processDiagnostics.bind(this)),this.lsp.onError((e=>{t("Error in language service",e)})),this.lsp.onLogMessage((e=>{})),this.lsp.onShowMessage((e=>{}))}close(){this.lsp.dispose()}attachPlugin(e){this.plugins.push(e)}detachPlugin(e){const t=this.plugins.indexOf(e);-1!==t&&this.plugins.splice(t,1)}processDiagnostics(e){for(const t of this.plugins)t.onDiagnostics(e)}}function O(){let e,t;const n=new Promise(((n,i)=>{e=n,t=i}));return{resolve:e,reject:t,promise:n}}function j(e){return null!=e}class K{constructor(e,t,n,i,o){this.rootdir=e,this.session=n,this.port=i,this.isDestroyed=!1,this.isStarted=!1,this.started=O(),this.serverSetup=t.filter(j).filter((e=>!!e.languageServerCommand)),this.startCmd=`lsp-ws-proxy -l ${this.port} `+this.serverSetup.map((e=>`-- ${e.languageServerCommand} --stdio`)).join(" "),this.logger=new M("LanguageServer",o),this.logger.log("Language server initialized",this.serverSetup)}get languages(){return this.serverSetup.map((e=>e.languageID))}stop(){var e,t;return q(this,void 0,void 0,(function*(){this.isDestroyed||(this.isDestroyed=!0,this.logger.log("Closing..."),yield null===(e=this.languageServer)||void 0===e?void 0:e.kill(),this.logger.log(`Closed (processID ${null===(t=this.languageServer)||void 0===t?void 0:t.processID})`))}))}start(){return q(this,void 0,void 0,(function*(){if(this.isStarted)return yield this.started.promise,this.languageServer;this.isStarted=!0,this.logger.log("Opening...");const e=this.session.getHostname(this.port);if(!e)throw new Error("Cannot get session url");const t=`wss://${e}`;try{return this.languageServer=Object.assign(Object.assign({},yield function(e,t,n,i,o,r){return q(this,void 0,void 0,(function*(){if(!n)throw new Error("Cannot create process - process manager is not defined");const{resolve:s,promise:l}=O(),a=yield n.start({cmd:e,onStdout:i,onStderr:o,onExit:()=>{s()},rootdir:t,processID:r});return{exited:l,processID:a.processID,kill:a.kill,sendStdin:a.sendStdin}}))}(this.startCmd,this.rootdir,this.session.process,(e=>this.logger.log(`Output: ${e.line}`)),(e=>this.logger.error(`Error: ${e.line}`)))),{websocketURL:t}),this.logger.log(`Open (processID ${this.languageServer.processID})`),this.started.resolve(),this.languageServer}catch(e){throw this.started.reject(),e}}))}getConnectionString(e){return q(this,void 0,void 0,(function*(){const t=this.serverSetup.find((t=>t.languageID===e));if(!t)return;const n=yield this.start();return n?encodeURI(`${n.websocketURL}?name=${t.languageServerCommand}`):void 0}))}}const F={"workspace/executeCommand":"executeCommandProvider","workspace/applyEdit":"workspace","textDocument/codeAction":"codeActionProvider","textDocument/codeLens":"codeLensProvider","textDocument/color":"colorProvider","textDocument/completion":"completionProvider","textDocument/declaration":"declarationProvider","textDocument/definition":"definitionProvider","textDocument/formatting":"documentFormattingProvider","textDocument/documentHighlight":"documentHighlightProvider","textDocument/documentLink":"documentLinkProvider","textDocument/onTypeFormatting":"documentOnTypeFormattingProvider","textDocument/rangeFormatting":"documentRangeFormattingProvider","textDocument/documentSymbol":"documentSymbolProvider","textDocument/executeCommand":"executeCommandProvider","textDocument/foldingRange":"foldingRangeProvider","textDocument/hover":"hoverProvider","textDocument/implementation":"implementationProvider","textDocument/references":"referencesProvider","textDocument/rename":"renameProvider","textDocument/signatureHelp":"signatureHelpProvider","textDocument/typeDefinition":"typeDefinitionProvider","textDocument/workspaceSymbol":"workspaceSymbolProvider"},N=e=>{let t="initial";const n=[],i=new s.Emitter,o=new s.Emitter,r=new s.Emitter,l=new s.Emitter,a=e=>{"initial"===t?n.push({message:e}):"listening"===t&&l.fire(JSON.parse(e))},c=e=>{"initial"===t?n.push({error:e}):"listening"===t&&i.fire(e)},u=e=>a(e.data),d=e=>{1e3!==e.code&&c(new Error(`WebSocket Error (${e.code}): ${e.reason}`)),"listening"===t&&o.fire(),t="closed"};return e.addEventListener("message",u),e.addEventListener("close",d),{get onError(){return i.event},get onClose(){return o.event},get onPartialMessage(){return r.event},listen(e){if("initial"!==t)throw new Error("Already listening");const i=l.event(e);if(t="listening",0===n.length)return i;for(const e of n)e.message?a(e.message):e.error&&c(e.error);return n.length=0,i},dispose(){e.removeEventListener("message",u),e.removeEventListener("close",d),i.dispose(),o.dispose(),r.dispose(),n.length=0}}},A=e=>{const t=new s.Emitter,n=new s.Emitter,i=()=>{n.fire()};e.addEventListener("close",i);let o=0;return{get onError(){return t.event},get onClose(){return n.event},write(n){return q(this,void 0,void 0,(function*(){try{e.send(JSON.stringify(n))}catch(e){t.fire([U(e),n,++o])}}))},end(){},dispose(){t.dispose(),n.dispose(),e.removeEventListener("close",i)}}},U=e=>e instanceof Error?e:new Error((null==e?void 0:e.message)||"Unknown error"),$=()=>({error:e=>console.error(e),warn:e=>console.warn(e),info:e=>console.info(e),log:e=>console.log(e)});function B({rootURI:e,connectionString:t}){return q(this,void 0,void 0,(function*(){const n=new WebSocket(t),i=yield((e,t=$())=>new Promise((n=>{e.onopen=()=>{const i=s.createMessageConnection(N(e),A(e),t);i.onDispose((()=>e.close())),i.onClose((()=>i.dispose())),n(i)}})))(n);i.listen();const o=(e=>{let t;e.onRequest(r.RegistrationRequest.type,(({registrations:e})=>{for(const{method:n,registerOptions:i}of e){const e=F[n];e&&(t[e]=null==i||i)}})),e.onRequest(r.UnregistrationRequest.type,(({unregisterations:e})=>{for(const{method:n}of e){const e=F[n];e&&(t[e]=void 0)}}));const n=(t,n)=>(i,o)=>t()?e.sendRequest(n,i,o):Promise.resolve(null),i=(t,n)=>i=>t()?e.sendNotification(n,i):Promise.resolve(),o=t=>n=>e.sendNotification(t,n),s=t=>n=>{e.onNotification(t,n)};return{listen:()=>e.listen(),dispose:()=>e.dispose(),initialize:n=>q(void 0,void 0,void 0,(function*(){const i=yield e.sendRequest(r.InitializeRequest.type,n);return t=i.capabilities,i})),initialized:()=>e.sendNotification(r.InitializedNotification.type,{}),shutdown:()=>e.sendRequest(r.ShutdownRequest.type),exit:()=>e.sendNotification(r.ExitNotification.type),onError:t=>e.onError((([e,n,i])=>t(e,n,i))),onClose:t=>e.onClose((()=>t())),onLogMessage:s(r.LogMessageNotification.type),onShowMessage:s(r.ShowMessageNotification.type),onDiagnostics:s(r.PublishDiagnosticsNotification.type),textDocumentOpened:o(r.DidOpenTextDocumentNotification.type),textDocumentClosed:o(r.DidCloseTextDocumentNotification.type),textDocumentChanged:o(r.DidChangeTextDocumentNotification.type),textDocumentWillSave:i((()=>{var e;const n=null!==(e=t.textDocumentSync)&&void 0!==e?e:r.TextDocumentSyncKind.None;return"number"!=typeof n&&!!n.willSave}),r.WillSaveTextDocumentNotification.type),getEditsBeforeSave:n((()=>{var e;const n=null!==(e=t.textDocumentSync)&&void 0!==e?e:r.TextDocumentSyncKind.None;return"number"!=typeof n&&!!n.willSaveWaitUntil}),r.WillSaveTextDocumentWaitUntilRequest.type),textDocumentSaved:i((()=>{var e;const n=null!==(e=t.textDocumentSync)&&void 0!==e?e:r.TextDocumentSyncKind.None;return"number"==typeof n?n!==r.TextDocumentSyncKind.None:!!n.save}),r.DidSaveTextDocumentNotification.type),configurationChanged:o(r.DidChangeConfigurationNotification.type),watchedFilesChanged:o(r.DidChangeWatchedFilesNotification.type),getDocumentFormatting:n((()=>!!t.documentFormattingProvider),r.DocumentFormattingRequest.type),applyEdits:n((()=>!!t.workspace),r.ApplyWorkspaceEditRequest.type),executeCommand:n((()=>!!t.executeCommandProvider),r.ExecuteCommandRequest.type),getCompletion:n((()=>!!t.completionProvider),r.CompletionRequest.type),getCompletionItemDetails:n((()=>{var e;return!!(null===(e=t.completionProvider)||void 0===e?void 0:e.resolveProvider)}),r.CompletionResolveRequest.type),getHoverInfo:n((()=>!!t.hoverProvider),r.HoverRequest.type),getSignatureHelp:n((()=>!!t.signatureHelpProvider),r.SignatureHelpRequest.type),getDeclaration:n((()=>!!t.declarationProvider),r.DeclarationRequest.type),getDefinition:n((()=>!!t.definitionProvider),r.DefinitionRequest.type),getTypeDefinition:n((()=>!!t.typeDefinitionProvider),r.TypeDefinitionRequest.type),getImplementation:n((()=>!!t.implementationProvider),r.ImplementationRequest.type),getReferences:n((()=>!!t.referencesProvider),r.ReferencesRequest.type),getDocumentHighlight:n((()=>!!t.documentHighlightProvider),r.DocumentHighlightRequest.type),getDocumentSymbol:n((()=>!!t.documentSymbolProvider),r.DocumentSymbolRequest.type),getCodeAction:n((()=>!!t.codeActionProvider),r.CodeActionRequest.type),getCodeLens:n((()=>!!t.codeLensProvider),r.CodeLensRequest.type),resolveCodeLens:n((()=>{var e;return!!(null===(e=t.codeLensProvider)||void 0===e?void 0:e.resolveProvider)}),r.CodeLensResolveRequest.type),getDocumentLink:n((()=>!!t.documentLinkProvider),r.DocumentLinkRequest.type),resolveDocumentLink:n((()=>{var e;return!!(null===(e=t.documentLinkProvider)||void 0===e?void 0:e.resolveProvider)}),r.DocumentLinkResolveRequest.type),getColorSymbols:n((()=>!!t.colorProvider),r.DocumentColorRequest.type),getFoldingRanges:n((()=>!!t.foldingRangeProvider),r.FoldingRangeRequest.type),getSelectionRanges:n((()=>!!t.selectionRangeProvider),r.SelectionRangeRequest.type),getWorkspaceSymbols:n((()=>!!t.workspaceSymbolProvider),r.WorkspaceSymbolRequest.type),get syncsIncrementally(){var e,n;let i=null!==(e=t.textDocumentSync)&&void 0!==e?e:r.TextDocumentSyncKind.None;return"number"!=typeof i&&(i=null!==(n=i.change)&&void 0!==n?n:r.TextDocumentSyncKind.None),i===r.TextDocumentSyncKind.Incremental},get completionTriggers(){var e;return(null===(e=t.completionProvider)||void 0===e?void 0:e.triggerCharacters)||[]},get signatureHelpTriggers(){var e;return(null===(e=t.signatureHelpProvider)||void 0===e?void 0:e.triggerCharacters)||[]},get signatureHelpRetriggers(){var e;return(null===(e=t.signatureHelpProvider)||void 0===e?void 0:e.retriggerCharacters)||[]}}})(i),{capabilities:l}=yield function(e,t){return q(this,void 0,void 0,(function*(){const n=yield e.initialize({capabilities:{textDocument:{synchronization:{dynamicRegistration:!0,didSave:!0},completion:{dynamicRegistration:!0,completionItem:{snippetSupport:!1,insertReplaceSupport:!1,commitCharactersSupport:!1,documentationFormat:["markdown","plaintext"],labelDetailsSupport:!0,deprecatedSupport:!0,preselectSupport:!0,resolveSupport:{properties:["documentation","detail"]}},contextSupport:!0},hover:{dynamicRegistration:!0,contentFormat:["markdown","plaintext"]},signatureHelp:{dynamicRegistration:!0,signatureInformation:{documentationFormat:["markdown","plaintext"],parameterInformation:{labelOffsetSupport:!0},activeParameterSupport:!0},contextSupport:!0},codeAction:{dynamicRegistration:!0},formatting:{dynamicRegistration:!0},rename:{dynamicRegistration:!0},publishDiagnostics:{versionSupport:!0,codeDescriptionSupport:!0,relatedInformation:!0,tagSupport:{valueSet:[r.DiagnosticTag.Unnecessary,r.DiagnosticTag.Deprecated]}},moniker:{}},workspace:{didChangeConfiguration:{dynamicRegistration:!0},didChangeWatchedFiles:{dynamicRegistration:!0}}},processId:null,rootUri:t,workspaceFolders:null});return e.initialized().catch((e=>console.error(e))),n}))}(o,e);return{lsp:o,capabilities:l}}))}const W=(J=49152,G=65535,function(e){return e>=G?J:e+1});var J,G;function Q(e,t){if(t.line>=e.lines)return e.length;const n=e.line(t.line+1).from+t.character;return n>e.length?e.length:n}function X(e,t){const n=e.lineAt(t);return{line:n.number-1,character:t-n.from}}function Y(e){return Array.isArray(e)?e.map(Y).join("\n\n"):"string"==typeof e?e:e.value}function Z(e){let t="",n=Array.from(e).join("");return/\w/.test(n)&&(t+="\\w",n=n.replace(/\w/g,"")),`[${t}${n.replace(/[^\w\s]/g,"\\$&")}]`}function ee(e){if(!D.default.isAbsolute(e))throw new Error("filepath must be absolute");return`file://${e}`}function te(e){return ee(e.endsWith("/")?e:e+"/")}function ne(e,t){return t.find((({fileExtensions:t})=>null==t?void 0:t.some((t=>e.endsWith(t)))))}var ie=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M14.5 3H7.71l-.85-.85L6.51 2h-5l-.5.5v11l.5.5h13l.5-.5v-10L14.5 3zm-.51 8.49V13h-12V7h4.49l.35-.15.86-.86H14v1.5l-.01 4zm0-6.49h-6.5l-.35.15-.86.86H2v-3h4.29l.85.85.36.15H14l-.01.99z"/></svg>'}),oe=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M6 5.914l2.06-2.06v-.708L5.915 1l-.707.707.043.043.25.25 1 1h-3a2.5 2.5 0 0 0 0 5H4V7h-.5a1.5 1.5 0 1 1 0-3h3L5.207 5.293 5.914 6 6 5.914zM11 2H8.328l-1-1H12l.71.29 3 3L16 5v9l-1 1H6l-1-1V6.5l1 .847V14h9V6h-4V2zm1 0v3h3l-3-3z"/></svg>'}),re=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M11.34 9.71h.71l2.67-2.67v-.71L13.38 5h-.7l-1.82 1.81h-5V5.56l1.86-1.85V3l-2-2H5L1 5v.71l2 2h.71l1.14-1.15v5.79l.5.5H10v.52l1.33 1.34h.71l2.67-2.67v-.71L13.37 10h-.7l-1.86 1.85h-5v-4H10v.48l1.34 1.38zm1.69-3.65l.63.63-2 2-.63-.63 2-2zm0 5l.63.63-2 2-.63-.63 2-2zM3.35 6.65l-1.29-1.3 3.29-3.29 1.3 1.29-3.3 3.3z"/></svg>'}),se=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M8 1.003a7 7 0 0 0-7 7v.43c.09 1.51 1.91 1.79 3 .7a1.87 1.87 0 0 1 2.64 2.64c-1.1 1.16-.79 3.07.8 3.2h.6a7 7 0 1 0 0-14l-.04.03zm0 13h-.52a.58.58 0 0 1-.36-.14.56.56 0 0 1-.15-.3 1.24 1.24 0 0 1 .35-1.08 2.87 2.87 0 0 0 0-4 2.87 2.87 0 0 0-4.06 0 1 1 0 0 1-.9.34.41.41 0 0 1-.22-.12.42.42 0 0 1-.1-.29v-.37a6 6 0 1 1 6 6l-.04-.04zM9 3.997a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 7.007a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-7-5a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm7-1a1 1 0 1 1-2 0 1 1 0 0 1 2 0zM13 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"/></svg>'}),le=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3l1-1h6l1 1v5l-1 1h-4V8h4V3H8v3H7V3zm2 6V8L8 7H2L1 8v5l1 1h6l1-1V9zM8 8v5H2V8h6zm1.414-1L9 6.586V6h4v1H9.414zM9 4h4v1H9V4zm-2 6H3v1h4v-1z"/></svg>'}),ae=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M14 2H8L7 3v3h1V3h6v5h-4v1h4l1-1V3l-1-1zM9 6h4v1H9.41L9 6.59V6zM7 7H2L1 8v5l1 1h6l1-1V8L8 7H7zm1 6H2V8h6v5zM3 9h4v1H3V9zm0 2h4v1H3v-1zm6-7h4v1H9V4z"/></svg>'}),ce=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M7.414 1.56L8.312 1h3.294l.818 1.575L10.236 6h1.781l.72 1.695L5.618 15l-1.602-1.163L6.119 10H4.898L4 8.56l3.414-7zM7.78 9L4.9 14.305 12.018 7H8.312l3.294-5H8.312L4.898 9H7.78z"/></svg>'}),ue=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M14.45 4.5l-5-2.5h-.9l-7 3.5-.55.89v4.5l.55.9 5 2.5h.9l7-3.5.55-.9v-4.5l-.55-.89zm-8 8.64l-4.5-2.25V7.17l4.5 2v3.97zm.5-4.8L2.29 6.23l6.66-3.34 4.67 2.34-6.67 3.11zm7 1.55l-6.5 3.25V9.21l6.5-3v3.68z"/></svg>'}),de=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M13.85 4.44l-3.28-3.3-.35-.14H2.5l-.5.5v13l.5.5h11l.5-.5V4.8l-.15-.36zM13 5h-3V2l3 3zM3 14V2h6v3.5l.5.5H13v8H3z"/></svg>'}),ge=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M11.496 4a3.49 3.49 0 0 0-3.46 3h-3.1a2 2 0 1 0 0 1h3.1a3.5 3.5 0 1 0 3.46-4zm0 6a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5z"/></svg>'}),he=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M15 4h-5V3h5v1zm-1 3h-2v1h2V7zm-4 0H1v1h9V7zm2 6H1v1h11v-1zm-5-3H1v1h6v-1zm8 0h-5v1h5v-1zM8 2v3H1V2h7zM7 3H2v1h5V3z"/></svg>'}),ve=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M13.51 4l-5-3h-1l-5 3-.49.86v6l.49.85 5 3h1l5-3 .49-.85v-6L13.51 4zm-6 9.56l-4.5-2.7V5.7l4.5 2.45v5.41zM3.27 4.7l4.74-2.84 4.74 2.84-4.74 2.59L3.27 4.7zm9.74 6.16l-4.5 2.7V8.15l4.5-2.45v5.16z"/></svg>'}),pe=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M6 2.984V2h-.09c-.313 0-.616.062-.909.185a2.33 2.33 0 0 0-.775.53 2.23 2.23 0 0 0-.493.753v.001a3.542 3.542 0 0 0-.198.83v.002a6.08 6.08 0 0 0-.024.863c.012.29.018.58.018.869 0 .203-.04.393-.117.572v.001a1.504 1.504 0 0 1-.765.787 1.376 1.376 0 0 1-.558.115H2v.984h.09c.195 0 .38.04.556.121l.001.001c.178.078.329.184.455.318l.002.002c.13.13.233.285.307.465l.001.002c.078.18.117.368.117.566 0 .29-.006.58-.018.869-.012.296-.004.585.024.87v.001c.033.283.099.558.197.824v.001c.106.273.271.524.494.753.223.23.482.407.775.53.293.123.596.185.91.185H6v-.984h-.09c-.199 0-.387-.038-.562-.115a1.613 1.613 0 0 1-.457-.32 1.659 1.659 0 0 1-.309-.467c-.074-.18-.11-.37-.11-.573 0-.228.003-.453.011-.672.008-.228.008-.45 0-.665a4.639 4.639 0 0 0-.055-.64 2.682 2.682 0 0 0-.168-.609A2.284 2.284 0 0 0 3.522 8a2.284 2.284 0 0 0 .738-.955c.08-.192.135-.393.168-.602.033-.21.051-.423.055-.64.008-.22.008-.442 0-.666-.008-.224-.012-.45-.012-.678a1.47 1.47 0 0 1 .877-1.354 1.33 1.33 0 0 1 .563-.121H6zm4 10.032V14h.09c.313 0 .616-.062.909-.185.293-.123.552-.3.775-.53.223-.23.388-.48.493-.753v-.001c.1-.266.165-.543.198-.83v-.002c.028-.28.036-.567.024-.863-.012-.29-.018-.58-.018-.869 0-.203.04-.393.117-.572v-.001a1.504 1.504 0 0 1 .765-.787c.176-.077.362-.115.558-.115H14v-.984h-.09c-.195 0-.38-.04-.556-.121l-.001-.001a1.376 1.376 0 0 1-.455-.318l-.002-.002a1.414 1.414 0 0 1-.307-.465l-.001-.002a1.405 1.405 0 0 1-.117-.566c0-.29.006-.58.018-.869a6.19 6.19 0 0 0-.024-.87v-.001a3.542 3.542 0 0 0-.197-.824v-.001a2.23 2.23 0 0 0-.494-.753 2.33 2.33 0 0 0-.775-.53 2.325 2.325 0 0 0-.91-.185H10v.984h.09c.2 0 .386.038.562.115.174.082.326.188.457.32.127.134.23.29.309.467.074.18.11.37.11.573 0 .228-.003.452-.011.672-.008.228-.008.45 0 .665.004.222.022.435.055.64.033.214.089.416.168.609a2.282 2.282 0 0 0 .738.955 2.282 2.282 0 0 0-.738.955 2.7 2.7 0 0 0-.168.602c-.033.21-.051.423-.055.64-.008.22-.008.442 0 .666.008.224.012.45.012.678a1.47 1.47 0 0 1-.42 1.035 1.466 1.466 0 0 1-.457.319 1.33 1.33 0 0 1-.563.121H10z"/></svg>'}),me=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2.873 1.1c.335.136.602.398.745.73.072.17.109.352.107.537a1.34 1.34 0 0 1-.61 1.135 1.359 1.359 0 0 1-.753.223A1.355 1.355 0 0 1 1 2.362a1.355 1.355 0 0 1 .83-1.256A1.37 1.37 0 0 1 2.873 1.1zm-.298 1.765a.551.551 0 0 0 .332-.5.548.548 0 1 0-.332.5zM6.43 1.109L1.11 6.43l.686.687 5.32-5.32-.686-.687zM11.5 9h1v2.5H15v1h-2.5V15h-1v-2.5H9v-1h2.5V9zm-5.732.525l.707.707L4.707 12l1.768 1.768-.707.707L4 12.707l-1.768 1.768-.707-.707L3.293 12l-1.768-1.768.707-.707L4 11.293l1.768-1.768zm1.35-4.195a1.353 1.353 0 0 0-1.256-.83 1.355 1.355 0 0 0-1.256.83 1.362 1.362 0 0 0 1.257 1.895A1.358 1.358 0 0 0 7.118 5.33zm-.753.745a.553.553 0 0 1-.289.29.547.547 0 0 1-.599-.117.529.529 0 0 1-.117-.173.544.544 0 0 1 .716-.715.565.565 0 0 1 .173.116.549.549 0 0 1 .116.599zM14 3h-4v1h4V3z"/></svg>'}),fe=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M11 6h-1v-.5a.5.5 0 0 0-.5-.5H8.479v5.5a.5.5 0 0 0 .5.5h.5v1h-3v-1h.5a.5.5 0 0 0 .5-.5V5H6.5a.5.5 0 0 0-.5.5V6H5V4h6v2zm2.914 2.048l-1.462-1.462.707-.707 1.816 1.816v.707l-1.768 1.767-.707-.707 1.414-1.414zM3.548 9.462L2.086 8 3.5 6.586l-.707-.707-1.768 1.767v.708l1.816 1.815.707-.707z"/></svg>'}),we=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M2.807 14.975a1.75 1.75 0 0 1-1.255-.556 1.684 1.684 0 0 1-.544-1.1A1.72 1.72 0 0 1 1.36 12.1c1.208-1.27 3.587-3.65 5.318-5.345a4.257 4.257 0 0 1 .048-3.078 4.095 4.095 0 0 1 1.665-1.969 4.259 4.259 0 0 1 4.04-.36l.617.268-2.866 2.951 1.255 1.259 2.944-2.877.267.619a4.295 4.295 0 0 1 .04 3.311 4.198 4.198 0 0 1-.923 1.392 4.27 4.27 0 0 1-.743.581 4.217 4.217 0 0 1-3.812.446c-1.098 1.112-3.84 3.872-5.32 5.254a1.63 1.63 0 0 1-1.084.423zm7.938-13.047a3.32 3.32 0 0 0-1.849.557c-.213.13-.412.284-.591.458a3.321 3.321 0 0 0-.657 3.733l.135.297-.233.227c-1.738 1.697-4.269 4.22-5.485 5.504a.805.805 0 0 0 .132 1.05.911.911 0 0 0 .298.22c.1.044.209.069.319.072a.694.694 0 0 0 .45-.181c1.573-1.469 4.612-4.539 5.504-5.44l.23-.232.294.135a3.286 3.286 0 0 0 3.225-.254 3.33 3.33 0 0 0 .591-.464 3.28 3.28 0 0 0 .964-2.358c0-.215-.021-.43-.064-.642L11.43 7.125 8.879 4.578l2.515-2.59a3.286 3.286 0 0 0-.65-.06z"/></svg>'}),ye=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M4 1L3 2v12l1 1h8l1-1V2l-1-1H4zm0 2V2h8v12H4v-1h2v-1H4v-2h4V9H4V7h2V6H4V4h4V3H4z"/></svg>'}),xe=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2.5 1l-.5.5V13h1V2h11v11h1V1.5l-.5-.5h-12zM2 15v-1h1v1H2zm3-1H4v1h1v-1zm1 0h1v1H6v-1zm3 0H8v1h1v-1zm1 0h1v1h-1v-1zm5 1v-1h-1v1h1zm-3-1h1v1h-1v-1z"/></svg>'}),Ce=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 2L1 3v9l1 1h12l1-1V3l-1-1H2zm0 10V3h12v9H2zm3.356-3.07H6V7.22C6 6.408 5.685 6 5.056 6c-.135 0-.285.024-.45.073a1.444 1.444 0 0 0-.388.167v.665c.237-.203.487-.304.75-.304.261 0 .392.156.392.469l-.6.103c-.506.086-.76.406-.76.961 0 .263.061.473.183.631A.61.61 0 0 0 4.69 9c.29 0 .509-.16.657-.48h.009v.41zm.004-1.355v.193a.75.75 0 0 1-.12.436.368.368 0 0 1-.313.17.276.276 0 0 1-.22-.095.38.38 0 0 1-.08-.248c0-.222.11-.351.332-.389l.4-.067zM7.6 8.626h-.007v.31H7V5h.593v1.677h.008c.146-.31.355-.465.625-.465.248 0 .44.118.573.353.134.236.201.557.201.966 0 .443-.078.798-.235 1.067C8.61 8.866 8.4 9 8.138 9c-.237 0-.416-.125-.537-.374zm-.016-1.121v.272a.78.78 0 0 0 .107.426c.071.113.163.169.274.169.135 0 .24-.072.314-.216.075-.145.113-.35.113-.615 0-.22-.035-.39-.104-.514-.067-.124-.164-.187-.29-.187-.12 0-.219.062-.298.185a.887.887 0 0 0-.116.48zM11.262 9c.321 0 .567-.058.738-.173v-.71a.9.9 0 0 1-.552.207.619.619 0 0 1-.5-.215c-.12-.145-.181-.345-.181-.598 0-.26.063-.464.189-.612a.644.644 0 0 1 .516-.223c.194 0 .37.069.528.207v-.749c-.129-.09-.338-.134-.626-.134-.417 0-.751.14-1.001.422-.249.28-.373.662-.373 1.148 0 .42.116.764.349 1.03.232.267.537.4.913.4z"/></svg>'}),Se=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 2L1 3v3l1 1h12l1-1V3l-1-1H2zm0 1h12v3H2V3zm-1 7l1-1h3l1 1v3l-1 1H2l-1-1v-3zm2 0H2v3h3v-3H3zm7 0l1-1h3l1 1v3l-1 1h-3l-1-1v-3zm2 0h-1v3h3v-3h-2z"/></svg>'}),be=Object.freeze({__proto__:null,default:'<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 5h2V4H1.5l-.5.5v8l.5.5H4v-1H2V5zm12.5-1H12v1h2v7h-2v1h2.5l.5-.5v-8l-.5-.5zm-2.74 2.57L12 7v2.51l-.3.45-4.5 2h-.46l-2.5-1.5-.24-.43v-2.5l.3-.46 4.5-2h.46l2.5 1.5zM5 9.71l1.5.9V9.28L5 8.38v1.33zm.58-2.15l1.45.87 3.39-1.5-1.45-.87-3.39 1.5zm1.95 3.17l3.5-1.56v-1.4l-3.5 1.55v1.41z"/></svg>'});function ze(e){return e[e.length-1]}function De(e){const t=document.createElement("template");return t.innerHTML=e,Array.from(t.content.childNodes)}function He(e){return q(this,void 0,void 0,(function*(){const t=yield function(e){return q(this,void 0,void 0,(function*(){return(yield y.unified().use(V.default).use(_.default).use(T.default,{allowDangerousHtml:!0}).use(R.default).use(L.default).data("settings",{fragment:!0}).use(P.default,{detect:!0}).use(E.default,{rel:"noopener noreferrer",target:"_blank"}).use(I.default).process(e)).toString()}))}(e);return De(t)}))}const Ee=Object.fromEntries(Object.entries(r.CompletionItemKind).map((([e,t])=>[t,e.toLowerCase()]))),Pe=Object.fromEntries(Object.entries(r.CompletionItemKind).map((([e,t])=>[e.toLowerCase(),t]))),Re=n.Facet.define({combine:ze}),Le=n.Facet.define({combine:ze}),Ie=n.Facet.define({combine:ze});class _e{constructor(e,t){this.view=e,this.documentVersion=0;const n=this.view.state;this.client=n.facet(Re),this.documentURI=e.state.facet(Le),this.client.attachPlugin(this),this.openPromise=t?this.client.lsp.textDocumentOpened({textDocument:{text:n.doc.toString(),languageId:n.facet(Ie),uri:this.documentURI,version:this.documentVersion}}):this.client.lsp.textDocumentChanged({textDocument:{uri:this.documentURI,version:this.nextDocumentVersion},contentChanges:[{text:n.doc.toString()}]})}get nextDocumentVersion(){return++this.documentVersion}update({docChanged:e,state:t}){return q(this,void 0,void 0,(function*(){e&&(yield this.openPromise,yield this.client.lsp.textDocumentChanged({textDocument:{uri:this.documentURI,version:this.nextDocumentVersion},contentChanges:[{text:t.doc.toString()}]}))}))}destroy(){this.client.detachPlugin(this)}requestFormatting(e){var t;return q(this,void 0,void 0,(function*(){if(!(null===(t=this.client.capabilities)||void 0===t?void 0:t.documentFormattingProvider))return null;const i=e.state,o=yield this.client.lsp.getDocumentFormatting({textDocument:{uri:this.documentURI},options:{insertSpaces:!0,tabSize:2,trimFinalNewlines:!0,insertFinalNewline:!0,trimTrailingWhitespace:!0}}),r=(null==o?void 0:o.map((e=>({from:Q(i.doc,e.range.start)||0,to:Q(i.doc,e.range.end),insert:e.newText}))))||[],s=function(e,t){let i=0;return t.reduce(((e,t)=>{if(t instanceof n.ChangeSet||Array.isArray(t)||!("from"in t))throw new Error("This function does not support ChangeSet or nested ChangeSpec");const o=i+t.from,r=i+((null==t?void 0:t.to)||0),s=t.insert||"";return i+=s.length-(r-o),e.slice(0,o)+s+e.slice(r)}),e)}(i.doc.toString(),r),l=H.diffChars(i.doc.toString(),s),a=[];let c=0;l.forEach((e=>{e.removed?(a.push({from:c,to:c+e.value.length}),c+=e.value.length):e.added?a.push({from:c,insert:e.value}):c+=e.value.length})),a.length&&e.dispatch({annotations:[n.Transaction.remote.of(!0),n.Transaction.addToHistory.of(!0)],changes:a})}))}requestHoverTooltip({state:{doc:e}},{line:t,character:n}){return q(this,void 0,void 0,(function*(){if(!this.client.capabilities.hoverProvider)return null;const i=yield this.client.lsp.getHoverInfo({textDocument:{uri:this.documentURI},position:{line:t,character:n}});if(!i)return null;const{contents:o,range:r}=i;let s=Q(e,{line:t,character:n});const l=Y(o),a=yield He(l);if(0===a.length)return null;const c=document.createElement("div");let u;return c.id="root2",c.classList.add("documentation"),c.append(...a),r&&(s=Q(e,r.start),u=Q(e,r.end)),null===s?null:{pos:s,end:u,create:()=>({dom:c}),above:!0}}))}requestSignatureHelp(e,t,n,i){var o,s,l,a,c;return q(this,void 0,void 0,(function*(){if(!(null===(o=this.client.capabilities)||void 0===o?void 0:o.signatureHelpProvider))return null;const{state:u,pos:d,explicit:g}=e;if(g)return null;const h=u.doc.lineAt(d),v=h.text[d-h.from-1];let p,m=r.SignatureHelpTriggerKind.ContentChange;if((i&&(null===(l=null===(s=this.client.capabilities.signatureHelpProvider)||void 0===s?void 0:s.triggerCharacters)||void 0===l?void 0:l.includes(v))||n&&(null===(c=null===(a=this.client.capabilities.signatureHelpProvider)||void 0===a?void 0:a.retriggerCharacters)||void 0===c?void 0:c.includes(v)))&&(p=v,m=r.SignatureHelpTriggerKind.TriggerCharacter),!t&&m===r.SignatureHelpTriggerKind.ContentChange)return null;const f=X(u.doc,d);return yield this.client.lsp.getSignatureHelp({position:f,textDocument:{uri:this.documentURI},context:{triggerKind:m,triggerCharacter:p,isRetrigger:n,activeSignatureHelp:t}})}))}requestCompletion(e,{line:t,character:n},{triggerKind:i,triggerCharacter:o}){return q(this,void 0,void 0,(function*(){if(!this.client.capabilities.completionProvider)return null;const s=yield this.client.lsp.getCompletion({textDocument:{uri:this.documentURI},position:{line:t,character:n},context:{triggerKind:i,triggerCharacter:o}});if(!s)return null;let l=("items"in s?s.items:s).map((e=>{const{detail:t,label:n,kind:i,textEdit:o,documentation:s,sortText:l,insertText:c,insertTextFormat:u,additionalTextEdits:d,filterText:g}=e;let h,v=null;o?(h=o.newText,h=(e,t)=>{const n=[],i=e.state;"range"in o?u===r.InsertTextFormat.Snippet||n.push({from:Q(i.doc,o.range.start),to:Q(i.doc,o.range.end),insert:o.newText}):console.error("Not supporting insert replace language server capability"),null==d||d.forEach((e=>{n.push({from:Q(i.doc,e.range.start),to:Q(i.doc,e.range.end),insert:e.newText})})),e.dispatch({annotations:a.pickedCompletion.of(t),changes:n})}):h=c?u===r.InsertTextFormat.Snippet?(e,t,n,i)=>{const o=c.indexOf("$0"),r=c.replace("$0",""),s=-1===o?void 0:n+o;e.dispatch({annotations:a.pickedCompletion.of(t),changes:[{from:n,to:i,insert:r}],selection:s?{head:s,anchor:s}:void 0})}:c:n;return{label:n,detail:t,apply:h,type:i&&Ee[i],sortText:null!=l?l:n,filterText:null!=g?g:n,info:()=>q(this,void 0,void 0,(function*(){let t,n=s;if(n||v||(v=yield this.client.lsp.getCompletionItemDetails(e)),(null==v?void 0:v.labelDetails)&&(t=v.label+v.labelDetails.detail+v.labelDetails.description),n=(null==v?void 0:v.documentation)||s||t,!n)return null;const i=Y(n),o=yield He(i);if(0===o.length)return null;const r=document.createElement("div");return r.id="root3",r.classList.add("documentation"),r.append(...o),r}))}}));if(0===l.length)return null;const[,c]=function(e){const t=new Set,n=new Set;for(const{label:i}of e){const[e,...o]=i;t.add(e);for(const e of o)n.add(e)}const i=Z(t)+Z(n)+"*$";return[new RegExp("^"+i),new RegExp(i)]}(l),u=e.matchBefore(c);let{pos:d}=e;if(u){const e=u.text.toLowerCase();d=u.from,/^\w+$/.test(e)&&(l=l.filter((({filterText:t})=>t.toLowerCase().startsWith(e))).sort((({label:e},{label:t})=>{switch(!0){case e.startsWith(u.text)&&!t.startsWith(u.text):return-1;case!e.startsWith(u.text)&&t.startsWith(u.text):return 1}return 0})))}const g=l.reduce(((e,t)=>Math.max(e,t.label.length)),0);return{from:d,options:l,validFor:e=>0!==e.length&&(!e.endsWith(".")&&(!e.endsWith(" ")&&!(e.length>g)))}}))}onDiagnostics(e){if(e.uri!==this.documentURI)return;const t=this.view.state,n=e.diagnostics.map((({range:e,message:n,severity:i})=>({from:Q(t.doc,e.start),to:Q(t.doc,e.end),severity:i&&{[r.DiagnosticSeverity.Error]:"error",[r.DiagnosticSeverity.Warning]:"warning",[r.DiagnosticSeverity.Information]:"info",[r.DiagnosticSeverity.Hint]:"info"}[i]||"info",message:n}))).filter((({from:e,to:t})=>null!==e&&null!==t&&void 0!==e&&void 0!==t)).sort(((e,t)=>{switch(!0){case e.from<t.from:return-1;case e.from>t.from:return 1}return 0}));this.view.dispatch(c.setDiagnostics(t,n))}}function Ve(){const e=Object.fromEntries(Object.entries(Pe).map((([e,t])=>{const n=De(function(e){switch(e){case r.CompletionItemKind.Class:return re;case r.CompletionItemKind.Color:return se;case r.CompletionItemKind.Constant:return be;case r.CompletionItemKind.Constructor:return ve;case r.CompletionItemKind.Enum:return ae;case r.CompletionItemKind.EnumMember:return le;case r.CompletionItemKind.Event:return ce;case r.CompletionItemKind.Field:return ue;case r.CompletionItemKind.File:return de;case r.CompletionItemKind.Folder:return ie;case r.CompletionItemKind.Function:return ve;case r.CompletionItemKind.Interface:return ge;case r.CompletionItemKind.Keyword:return he;case r.CompletionItemKind.Method:return ve;case r.CompletionItemKind.Module:return pe;case r.CompletionItemKind.Operator:return me;case r.CompletionItemKind.Property:return we;case r.CompletionItemKind.Reference:return oe;case r.CompletionItemKind.Snippet:return xe;case r.CompletionItemKind.Struct:return Se;case r.CompletionItemKind.Text:return Ce;case r.CompletionItemKind.TypeParameter:return fe;case r.CompletionItemKind.Unit:return ye;case r.CompletionItemKind.Value:return ae;case r.CompletionItemKind.Variable:return be}}(t).default),i=document.createElement("div");return i.classList.add("autocomplete-icon",`autocomplete-icon-${e}`),i.append(...n),[e,i]})));return{getImage(t){const n=e[t];if(n)return n.cloneNode(!0)}}}class Te{constructor(e,t,n){this.view=e,this.getPlugin=t,this.setSignatureHelp=n}update(e){return q(this,void 0,void 0,(function*(){const t=this.getPlugin();if(!t)return;if(!e.transactions.some((e=>e.isUserEvent("select.pointer")))&&(e.docChanged||e.startState.selection.main.head!==e.state.selection.main.head)){yield t.update(e);const n=e.state.selection.main.head,i=new a.CompletionContext(e.state,n,!1);yield this.updateSignature(e.state,i,e.docChanged)}}))}updateSignature(e,t,n){return q(this,void 0,void 0,(function*(){const i=this.getPlugin();if(!i)return;const o=yield i.requestSignatureHelp(t,this.lastSignature,!!this.lastSignature,n);this.lastSignature=o||void 0;const r=o?yield this.getTooltip(e,o):null;this.setTooltip(r)}))}getTooltip(e,t){return q(this,void 0,void 0,(function*(){const n=void 0!==t.activeSignature?t.signatures[t.activeSignature]:void 0;if(!n)return null;n.activeParameter=void 0!==n.activeParameter?n.activeParameter:null==t?void 0:t.activeParameter;const i=Y(n.documentation||""),o=yield He(i),r=n.parameters&&void 0!==n.activeParameter?n.parameters[n.activeParameter]:void 0,s=Y((null==r?void 0:r.documentation)||""),l=yield He(s);if(0===o.length)return null;const a=document.createElement("div");a.id="root4",a.classList.add("documentation");const c=document.createElement("code");c.classList.add("signature-label"),c.innerHTML=function(e,t){if(void 0===e.activeParameter)return e.label;if(!e.parameters)return e.label;const n=e.parameters[e.activeParameter];if(!n)return e.label;const i="string"==typeof n.label?n.label:e.label.slice(n.label[0],n.label[1]);return e.label.replace(i,t(i))}(n,(e=>`<code class="selected-param">${e}</code>`)),0===o.length&&0===l.length||(c.innerHTML+="<br/><br/>"),a.appendChild(c),a.append(...o),0!==l.length&&a.append(...l);return{pos:e.selection.main.head,create:()=>({dom:a}),above:!0}}))}setTooltip(e){const t=this.setSignatureHelp.of(e);this.view.dispatch({effects:t})}}const qe=n.StateEffect.define(),Me=qe.of(null);function ke(e){const t=n.StateField.define({create:()=>null,update(e,t){if(t.isUserEvent("select.pointer"))return null;for(const e of t.effects)if(e.is(qe))return e.value;return e},provide:e=>i.showTooltip.compute(["selection",e],(t=>{if(!e)return null;const n=t.field(e);return n?(n.pos=t.selection.main.head,Object.assign({},n)):null}))});return[i.ViewPlugin.define((t=>new Te(t,e,qe))),t]}const Oe={"data-gramm":"false",spellcheck:"false"};function je(e){const t=new n.Compartment,o=new n.Compartment,r=new n.Compartment,s=new n.Compartment;return{state:n.EditorState.create({doc:e,extensions:[i.EditorView.contentAttributes.of(Oe),s.of([]),i.lineNumbers(),C.bracketMatching(),i.highlightActiveLineGutter(),i.highlightSpecialChars(),x.history(),i.scrollPastEnd(),n.EditorState.tabSize.of(2),i.drawSelection(),i.dropCursor(),a.closeBrackets(),C.indentOnInput(),i.highlightActiveLine(),i.keymap.of([...x.defaultKeymap,...a.closeBracketsKeymap,...x.historyKeymap,...C.foldKeymap,x.indentWithTab,{key:"Mod-s",run:()=>!0}]),o.of([]),r.of([]),t.of([]),C.syntaxHighlighting(S.classHighlighter)]}),languageExtensions:t,languageServiceExtensions:o,contentHandlingExtensions:r,editabilityExtensions:s}}const Ke=o.forwardRef((({content:e="",onContentChange:s,isReadOnly:l=!1,supportedLanguages:c,height:u,className:d="",autofocus:g,filename:h,languageClients:v,openFileInLanguageServer:p=!0},m)=>{const f=o.useRef(null),[w,y]=o.useState(),x=ne(h,c),C=x&&(null==v?void 0:v[null==x?void 0:x.languageID]);return o.useImperativeHandle(m,(()=>({focus:()=>null==w?void 0:w.view.focus()})),[w]),o.useLayoutEffect((function(){if(!f.current)return;const{languageServiceExtensions:t,contentHandlingExtensions:n,languageExtensions:o,editabilityExtensions:r,state:s}=je(e),l=new i.EditorView({state:s,parent:f.current});return y({view:l,languageServiceExtensions:t,contentHandlingExtensions:n,languageExtensions:o,editabilityExtensions:r}),g&&l.focus(),()=>{l.destroy(),y(void 0)}}),[g,e]),o.useEffect((function(){if(w&&(null==x?void 0:x.languageExtensions))return w.view.dispatch({effects:w.languageExtensions.reconfigure(x.languageExtensions)}),()=>{w.view.dispatch({effects:w.languageExtensions.reconfigure([])})}}),[w,x]),o.useEffect((function(){if(!w)return;const e=[n.EditorState.readOnly.of(l),i.EditorView.editable.of(!l)];return w.view.dispatch({effects:w.editabilityExtensions.reconfigure(e)}),()=>{w.view.dispatch({effects:w.editabilityExtensions.reconfigure([])})}}),[w,l]),o.useEffect((function(){if(!w)return;if(!s)return;const e=i.EditorView.updateListener.of((e=>{e.docChanged&&(null==s||s(e.state.doc.toString()))}));return w.view.dispatch({effects:w.contentHandlingExtensions.reconfigure(e)}),()=>{w.view.dispatch({effects:w.contentHandlingExtensions.reconfigure([])})}}),[w,s]),o.useEffect((function(){if(!w)return;if(!h)return;if(!C)return;const e=function(e){let t=null;const{getImage:o}=Ve();return[Re.of(e.client),Le.of(e.documentURI),Ie.of(e.client.languageID),i.ViewPlugin.define((n=>t=new _e(n,e.openFile))),n.Prec.highest(i.keymap.of([{key:"Mod-s",run:e=>(null==t||t.requestFormatting(e),!1)},{key:"Escape",run:e=>(e.dispatch({effects:[i.closeHoverTooltips,Me]}),!1)}])),ke((()=>t)),i.hoverTooltip(((e,n)=>q(this,void 0,void 0,(function*(){if(!t)return null;const i=X(e.state.doc,n);return yield t.requestHoverTooltip(e,i)})))),a.autocompletion({activateOnTyping:!0,maxRenderedOptions:40,closeOnBlur:!1,icons:!1,addToOptions:[{render:e=>e.type?(e.iconCache||(e.iconCache=o(e.type)),e.iconCache||null):null,position:20}],override:[e=>q(this,void 0,void 0,(function*(){var n,i,o;if(!t)return null;const{state:s,pos:l,explicit:a}=e,c=s.doc.lineAt(l);let u,d=r.CompletionTriggerKind.Invoked;return!a&&(null===(o=null===(i=null===(n=t.client.capabilities)||void 0===n?void 0:n.completionProvider)||void 0===i?void 0:i.triggerCharacters)||void 0===o?void 0:o.includes(c.text[l-c.from-1]))&&(d=r.CompletionTriggerKind.TriggerCharacter,u=c.text[l-c.from-1]),yield t.requestCompletion(e,X(s.doc,l),{triggerKind:d,triggerCharacter:u})}))]})]}({client:C,documentURI:ee(h),openFile:p});return w.view.dispatch({effects:w.languageServiceExtensions.reconfigure(e)}),()=>{w.view.dispatch({effects:w.languageServiceExtensions.reconfigure([])})}}),[w,C,h,p]),t.jsx("div",{className:`overflow-auto ${d}`,ref:f,style:Object.assign({},u&&{height:u})})}));Ke.displayName="CodeEditor",e.CodeEditor=Ke,e.getFileURI=ee,e.getLanguageSetup=ne,e.getRootURI=te,e.useLanguageServer=function({supportedLanguages:e,session:t,debug:n,rootdir:i}){const[r,s]=o.useState(),[l,a]=o.useState(),{maybeEmptyPort:c,markPortAsNotEmpty:u}=function(){const[e,t]=o.useState(49152);return{maybeEmptyPort:e,markPortAsNotEmpty:o.useCallback((()=>{t(W)}),[])}}();return o.useEffect((function(){if(!(null==t?void 0:t.process))return;const o=new K(i,e,t,c,n);return s(o),o.start().then((e=>{null==e||e.exited.then((()=>{u(),s((e=>e===o?void 0:e))}))})).catch((e=>console.error("Error starting language server",e))),()=>{s((e=>e===o?void 0:e)),o.stop()}}),[t,n,c,u,e]),o.useEffect((function(){if(r)return a({process:r}),Promise.all(r.languages.map((e=>q(this,void 0,void 0,(function*(){try{const t=yield r.getConnectionString(e);if(!t)return;const{lsp:n,capabilities:o}=yield B({rootURI:te(i),connectionString:t});return new k({languageID:e,capabilities:o,lsp:n})}catch(e){const t=e instanceof Error?e.message:JSON.stringify(e);console.error(t)}}))))).then((e=>{const t=e.reduce(((e,t)=>(t&&(e[t.languageID]=t),e)),{});a((e=>(null==e?void 0:e.process)===r?{process:e.process,clients:t}:e))})),()=>{a((e=>{if((null==e?void 0:e.process)!==r||!e.clients)return e;Object.values(e.clients).map((e=>e.close()))}))}}),[r,i]),null==l?void 0:l.clients},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.js.map
{
"name": "@devbookhq/code-editor",
"version": "0.0.14",
"version": "0.0.15",
"description": "Code editor based on CM",

@@ -5,0 +5,0 @@ "homepage": "https://usedevbook.com",

import * as folderIcon from '@vscode/codicons/src/icons/folder.svg'
import * as referencesIcon from '@vscode/codicons/src/icons/references.svg'
import * as goToFileIcon from '@vscode/codicons/src/icons/go-to-file.svg'
import * as classIcon from '@vscode/codicons/src/icons/symbol-class.svg'

@@ -15,2 +15,3 @@ import * as colorIcon from '@vscode/codicons/src/icons/symbol-color.svg'

import * as operatorIcon from '@vscode/codicons/src/icons/symbol-operator.svg'
import * as parameterIcon from '@vscode/codicons/src/icons/symbol-parameter.svg'
import * as propertyIcon from '@vscode/codicons/src/icons/symbol-property.svg'

@@ -64,3 +65,3 @@ import * as rulerIcon from '@vscode/codicons/src/icons/symbol-ruler.svg'

case CompletionItemKind.Reference:
return referencesIcon
return goToFileIcon
case CompletionItemKind.Snippet:

@@ -73,3 +74,3 @@ return snippetIcon

case CompletionItemKind.TypeParameter:
return classIcon
return parameterIcon
case CompletionItemKind.Unit:

@@ -76,0 +77,0 @@ return rulerIcon

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc