/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
import{parser as e}from"../../../@lezer/javascript/dist/index.js";import{LanguageSupport as t,sublanguageProp as n,LRLanguage as o,indentNodeProp as a,flatIndent as r,continuedIndent as i,delimitedIndent as l,foldNodeProp as s,foldInside as c,syntaxTree as p,defineLanguageFacet as d}from"../../language/dist/index.js";import{EditorSelection as m}from"../../state/dist/index.js";import{EditorView as f}from"../../view/dist/index.js";import{ifNotIn as u,completeFromList as y,snippetCompletion as g}from"../../autocomplete/dist/index.js";import{NodeWeakMap as S,IterMode as b}from"../../../@lezer/common/dist/index.js";const $=[
/* @__PURE__ */g("function ${name}(${params}) {\n\t${}\n}",{label:"function",detail:"definition",type:"keyword"}),
/* @__PURE__ */g("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n\t${}\n}",{label:"for",detail:"loop",type:"keyword"}),
/* @__PURE__ */g("for (let ${name} of ${collection}) {\n\t${}\n}",{label:"for",detail:"of loop",type:"keyword"}),
/* @__PURE__ */g("do {\n\t${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),
/* @__PURE__ */g("while (${}) {\n\t${}\n}",{label:"while",detail:"loop",type:"keyword"}),
/* @__PURE__ */g("try {\n\t${}\n} catch (${error}) {\n\t${}\n}",{label:"try",detail:"/ catch block",type:"keyword"}),
/* @__PURE__ */g("if (${}) {\n\t${}\n}",{label:"if",detail:"block",type:"keyword"}),
/* @__PURE__ */g("if (${}) {\n\t${}\n} else {\n\t${}\n}",{label:"if",detail:"/ else block",type:"keyword"}),
/* @__PURE__ */g("class ${name} {\n\tconstructor(${params}) {\n\t\t${}\n\t}\n}",{label:"class",detail:"definition",type:"keyword"}),
/* @__PURE__ */g('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),
/* @__PURE__ */g('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],x=/* @__PURE__ */$.concat([
/* @__PURE__ */g("interface ${name} {\n\t${}\n}",{label:"interface",detail:"definition",type:"keyword"}),
/* @__PURE__ */g("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),
/* @__PURE__ */g("enum ${name} {\n\t${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),w=/* @__PURE__ */new S,h=/* @__PURE__ */new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function k(e){return(t,n)=>{let o=t.node.getChild("VariableDefinition");return o&&n(o,e),!0}}const T=["FunctionDeclaration"],J={FunctionDeclaration:/* @__PURE__ */k("function"),ClassDeclaration:/* @__PURE__ */k("class"),ClassExpression:()=>!0,EnumDeclaration:/* @__PURE__ */k("constant"),TypeAliasDeclaration:/* @__PURE__ */k("type"),NamespaceDeclaration:/* @__PURE__ */k("namespace"),VariableDefinition(e,t){e.matchContext(T)||t(e,"variable")},TypeDefinition(e,t){t(e,"type")},__proto__:null};function X(e,t){let n=w.get(t);if(n)return n;let o=[],a=!0;function r(t,n){let a=e.sliceString(t.from,t.to);o.push({label:a,type:n})}return t.cursor(b.IncludeAnonymous).iterate(t=>{if(a)a=!1;else if(t.name){let e=J[t.name];if(e&&e(t,r)||h.has(t.name))return!1}else if(t.to-t.from>8192){for(let n of X(e,t.node))o.push(n);return!1}}),w.set(t,o),o}const v=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,C=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function D(e){let t=p(e.state).resolveInner(e.pos,-1);if(C.indexOf(t.name)>-1)return null;let n="VariableName"==t.name||t.to-t.from<20&&v.test(e.state.sliceDoc(t.from,t.to));if(!n&&!e.explicit)return null;let o=[];for(let a=t;a;a=a.parent)h.has(a.name)&&(o=o.concat(X(e.state.doc,a)));return{options:o,from:n?t.from:e.pos,validFor:v}}const j=/* @__PURE__ */o.define({name:"javascript",parser:/* @__PURE__ */e.configure({props:[
/* @__PURE__ */a.add({IfStatement:/* @__PURE__ */i({except:/^\s*({|else\b)/}),TryStatement:/* @__PURE__ */i({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:r,SwitchBody:e=>{let t=e.textAfter,n=/^\s*\}/.test(t),o=/^\s*(case|default)\b/.test(t);return e.baseIndent+(n?0:o?1:2)*e.unit},Block:/* @__PURE__ */l({closing:"}"}),ArrowFunction:e=>e.baseIndent+e.unit,"TemplateString BlockComment":()=>null,"Statement Property":/* @__PURE__ */i({except:/^\s*{/}),JSXElement(e){let t=/^\s*<\//.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},JSXEscape(e){let t=/\s*\}/.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},"JSXOpenTag JSXSelfClosingTag":e=>e.column(e.node.from)+e.unit}),
/* @__PURE__ */s.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":c,BlockComment:e=>({from:e.from+2,to:e.to-2})})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),A={test:e=>/^JSX/.test(e.name),facet:/* @__PURE__ */d({commentTokens:{block:{open:"{/*",close:"*/}"}}})},B=/* @__PURE__ */j.configure({dialect:"ts"},"typescript"),E=/* @__PURE__ */j.configure({dialect:"jsx",props:[/* @__PURE__ */n.add(e=>e.isTop?[A]:void 0)]}),F=/* @__PURE__ */j.configure({dialect:"jsx ts",props:[/* @__PURE__ */n.add(e=>e.isTop?[A]:void 0)]},"typescript");let I=e=>({label:e,type:"keyword"});const O=/* @__PURE__ */"break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(I),P=/* @__PURE__ */O.concat(/* @__PURE__ */["declare","implements","private","protected","public"].map(I));function V(e={}){let n=e.jsx?e.typescript?F:E:e.typescript?B:j,o=e.typescript?x.concat(P):$.concat(O);return new t(n,[j.data.of({autocomplete:u(C,y(o))}),j.data.of({autocomplete:D}),e.jsx?L:[]])}function N(e,t,n=e.length){for(let o=null==t?void 0:t.firstChild;o;o=o.nextSibling)if("JSXIdentifier"==o.name||"JSXBuiltin"==o.name||"JSXNamespacedName"==o.name||"JSXMemberExpression"==o.name)return e.sliceString(o.from,Math.min(o.to,n));return""}const _="object"==typeof navigator&&/* @__PURE__ */ /Android\b/.test(navigator.userAgent),L=/* @__PURE__ */f.inputHandler.of((e,t,n,o,a)=>{if((_?e.composing:e.compositionStarted)||e.state.readOnly||t!=n||">"!=o&&"/"!=o||!j.isActiveAt(e.state,t,-1))return!1;let r=a(),{state:i}=r,l=i.changeByRange(e=>{var t;let n,{head:a}=e,r=p(i).resolveInner(a-1,-1);if("JSXStartTag"==r.name&&(r=r.parent),i.doc.sliceString(a-1,a)!=o||"JSXAttributeValue"==r.name&&r.to>a);else{if(">"==o&&"JSXFragmentTag"==r.name)return{range:e,changes:{from:a,insert:"</>"}};if("/"==o&&"JSXStartCloseTag"==r.name){let e=r.parent,o=e.parent;if(o&&e.from==a-2&&((n=N(i.doc,o.firstChild,a))||"JSXFragmentTag"==(null===(t=o.firstChild)||void 0===t?void 0:t.name))){let e=`${n}>`;return{range:m.cursor(a+e.length,-1),changes:{from:a,insert:e}}}}else if(">"==o){let t=function(e){for(;;){if("JSXOpenTag"==e.name||"JSXSelfClosingTag"==e.name||"JSXFragmentTag"==e.name)return e;if("JSXEscape"==e.name||!e.parent)return null;e=e.parent}}(r);if(t&&"JSXOpenTag"==t.name&&!/^\/?>|^<\//.test(i.doc.sliceString(a,a+2))&&(n=N(i.doc,t,a)))return{range:e,changes:{from:a,insert:`</${n}>`}}}}return{range:e}});return!l.changes.empty&&(e.dispatch([r,i.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)});export{L as autoCloseTags,V as javascript,j as javascriptLanguage,E as jsxLanguage,D as localCompletionSource,$ as snippets,F as tsxLanguage,B as typescriptLanguage,x as typescriptSnippets};