"use strict";var Ot=Object.defineProperty;var Nt=(r,n,t)=>n in r?Ot(r,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[n]=t;var V=(r,n,t)=>(Nt(r,typeof n!="symbol"?n+"":n,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react"),Re=require("@monaco-editor/react"),B=require("@ws-ui/shared"),Ve=require("monaco-languageclient"),Be=require("vscode-languageclient"),W=require("monaco-editor"),xe=require("vscode-ws-jsonrpc"),J=require("vscode-languageserver-protocol"),H=require("vscode/services");function Pt(r){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(n,t,i.get?i:{enumerable:!0,get:()=>r[t]})}}return n.default=r,Object.freeze(n)}const c=Pt(W);var Ee={exports:{}},te={};/*
object-assign
(c) Sindre Sorhus
@license MIT
*/var be,ze;function Xe(){if(ze)return be;ze=1;var r=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,t=Object.prototype.propertyIsEnumerable;function i(u){if(u==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(u)}function l(){try{if(!Object.assign)return!1;var u=new String("abc");if(u[5]="de",Object.getOwnPropertyNames(u)[0]==="5")return!1;for(var d={},a=0;a<10;a++)d["_"+String.fromCharCode(a)]=a;var f=Object.getOwnPropertyNames(d).map(function(b){return d[b]});if(f.join("")!=="0123456789")return!1;var h={};return"abcdefghijklmnopqrst".split("").forEach(function(b){h[b]=b}),Object.keys(Object.assign({},h)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return be=l()?Object.assign:function(u,d){for(var a,f=i(u),h,b=1;b<arguments.length;b++){a=Object(arguments[b]);for(var S in a)n.call(a,S)&&(f[S]=a[S]);if(r){h=r(a);for(var v=0;v<h.length;v++)t.call(a,h[v])&&(f[h[v]]=a[h[v]])}}return f},be}/** @license React v17.0.2
 * react-jsx-runtime.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Ge;function jt(){if(Ge)return te;Ge=1,Xe();var r=w,n=60103;if(te.Fragment=60107,typeof Symbol=="function"&&Symbol.for){var t=Symbol.for;n=t("react.element"),te.Fragment=t("react.fragment")}var i=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l=Object.prototype.hasOwnProperty,u={key:!0,ref:!0,__self:!0,__source:!0};function d(a,f,h){var b,S={},v=null,P=null;h!==void 0&&(v=""+h),f.key!==void 0&&(v=""+f.key),f.ref!==void 0&&(P=f.ref);for(b in f)l.call(f,b)&&!u.hasOwnProperty(b)&&(S[b]=f[b]);if(a&&a.defaultProps)for(b in f=a.defaultProps,f)S[b]===void 0&&(S[b]=f[b]);return{$$typeof:n,type:a,key:v,ref:P,props:S,_owner:i.current}}return te.jsx=d,te.jsxs=d,te}var Ce={};/** @license React v17.0.2
 * react-jsx-runtime.development.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Ze;function At(){return Ze||(Ze=1,function(r){process.env.NODE_ENV!=="production"&&function(){var n=w,t=Xe(),i=60103,l=60106;r.Fragment=60107;var u=60108,d=60114,a=60109,f=60110,h=60112,b=60113,S=60120,v=60115,P=60116,L=60121,j=60122,M=60117,I=60129,R=60131;if(typeof Symbol=="function"&&Symbol.for){var y=Symbol.for;i=y("react.element"),l=y("react.portal"),r.Fragment=y("react.fragment"),u=y("react.strict_mode"),d=y("react.profiler"),a=y("react.provider"),f=y("react.context"),h=y("react.forward_ref"),b=y("react.suspense"),S=y("react.suspense_list"),v=y("react.memo"),P=y("react.lazy"),L=y("react.block"),j=y("react.server.block"),M=y("react.fundamental"),y("react.scope"),y("react.opaque.id"),I=y("react.debug_trace_mode"),y("react.offscreen"),R=y("react.legacy_hidden")}var m=typeof Symbol=="function"&&Symbol.iterator,p="@@iterator";function K(e){if(e===null||typeof e!="object")return null;var o=m&&e[m]||e[p];return typeof o=="function"?o:null}var F=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function k(e){{for(var o=arguments.length,s=new Array(o>1?o-1:0),g=1;g<o;g++)s[g-1]=arguments[g];U("error",e,s)}}function U(e,o,s){{var g=F.ReactDebugCurrentFrame,O=g.getStackAddendum();O!==""&&(o+="%s",s=s.concat([O]));var N=s.map(function(E){return""+E});N.unshift("Warning: "+o),Function.prototype.apply.call(console[e],console,N)}}var ue=!1;function x(e){return!!(typeof e=="string"||typeof e=="function"||e===r.Fragment||e===d||e===I||e===u||e===b||e===S||e===R||ue||typeof e=="object"&&e!==null&&(e.$$typeof===P||e.$$typeof===v||e.$$typeof===a||e.$$typeof===f||e.$$typeof===h||e.$$typeof===M||e.$$typeof===L||e[0]===j))}function T(e,o,s){var g=o.displayName||o.name||"";return e.displayName||(g!==""?s+"("+g+")":s)}function _(e){return e.displayName||"Context"}function q(e){if(e==null)return null;if(typeof e.tag=="number"&&k("Received an unexpected object in getComponentName(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case r.Fragment:return"Fragment";case l:return"Portal";case d:return"Profiler";case u:return"StrictMode";case b:return"Suspense";case S:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case f:var o=e;return _(o)+".Consumer";case a:var s=e;return _(s._context)+".Provider";case h:return T(e,e.render,"ForwardRef");case v:return q(e.type);case L:return q(e._render);case P:{var g=e,O=g._payload,N=g._init;try{return q(N(O))}catch{return null}}}return null}var ne=0,ye,_e,we,Ie,Te,Oe,Ne;function Pe(){}Pe.__reactDisabledLog=!0;function lt(){{if(ne===0){ye=console.log,_e=console.info,we=console.warn,Ie=console.error,Te=console.group,Oe=console.groupCollapsed,Ne=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Pe,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}ne++}}function ut(){{if(ne--,ne===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:t({},e,{value:ye}),info:t({},e,{value:_e}),warn:t({},e,{value:we}),error:t({},e,{value:Ie}),group:t({},e,{value:Te}),groupCollapsed:t({},e,{value:Oe}),groupEnd:t({},e,{value:Ne})})}ne<0&&k("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ce=F.ReactCurrentDispatcher,de;function oe(e,o,s){{if(de===void 0)try{throw Error()}catch(O){var g=O.stack.trim().match(/\n( *(at )?)/);de=g&&g[1]||""}return`
`+de+e}}var fe=!1,se;{var ct=typeof WeakMap=="function"?WeakMap:Map;se=new ct}function je(e,o){if(!e||fe)return"";{var s=se.get(e);if(s!==void 0)return s}var g;fe=!0;var O=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var N;N=ce.current,ce.current=null,lt();try{if(o){var E=function(){throw Error()};if(Object.defineProperty(E.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(E,[])}catch(Z){g=Z}Reflect.construct(e,[],E)}else{try{E.call()}catch(Z){g=Z}e.call(E.prototype)}}else{try{throw Error()}catch(Z){g=Z}e()}}catch(Z){if(Z&&g&&typeof Z.stack=="string"){for(var C=Z.stack.split(`
`),Y=g.stack.split(`
`),D=C.length-1,$=Y.length-1;D>=1&&$>=0&&C[D]!==Y[$];)$--;for(;D>=1&&$>=0;D--,$--)if(C[D]!==Y[$]){if(D!==1||$!==1)do if(D--,$--,$<0||C[D]!==Y[$]){var G=`
`+C[D].replace(" at new "," at ");return typeof e=="function"&&se.set(e,G),G}while(D>=1&&$>=0);break}}}finally{fe=!1,ce.current=N,ut(),Error.prepareStackTrace=O}var ee=e?e.displayName||e.name:"",Ue=ee?oe(ee):"";return typeof e=="function"&&se.set(e,Ue),Ue}function Ae(e,o,s){return je(e,!1)}function dt(e){var o=e.prototype;return!!(o&&o.isReactComponent)}function ae(e,o,s){if(e==null)return"";if(typeof e=="function")return je(e,dt(e));if(typeof e=="string")return oe(e);switch(e){case b:return oe("Suspense");case S:return oe("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case h:return Ae(e.render);case v:return ae(e.type,o,s);case L:return Ae(e._render);case P:{var g=e,O=g._payload,N=g._init;try{return ae(N(O),o,s)}catch{}}}return""}var Le={},ke=F.ReactDebugCurrentFrame;function le(e){if(e){var o=e._owner,s=ae(e.type,e._source,o?o.type:null);ke.setExtraStackFrame(s)}else ke.setExtraStackFrame(null)}function ft(e,o,s,g,O){{var N=Function.call.bind(Object.prototype.hasOwnProperty);for(var E in e)if(N(e,E)){var C=void 0;try{if(typeof e[E]!="function"){var Y=Error((g||"React class")+": "+s+" type `"+E+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[E]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Y.name="Invariant Violation",Y}C=e[E](o,E,g,s,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(D){C=D}C&&!(C instanceof Error)&&(le(O),k("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",g||"React class",s,E,typeof C),le(null)),C instanceof Error&&!(C.message in Le)&&(Le[C.message]=!0,le(O),k("Failed %s type: %s",s,C.message),le(null))}}}var re=F.ReactCurrentOwner,ge=Object.prototype.hasOwnProperty,gt={key:!0,ref:!0,__self:!0,__source:!0},De,$e,me;me={};function mt(e){if(ge.call(e,"ref")){var o=Object.getOwnPropertyDescriptor(e,"ref").get;if(o&&o.isReactWarning)return!1}return e.ref!==void 0}function pt(e){if(ge.call(e,"key")){var o=Object.getOwnPropertyDescriptor(e,"key").get;if(o&&o.isReactWarning)return!1}return e.key!==void 0}function vt(e,o){if(typeof e.ref=="string"&&re.current&&o&&re.current.stateNode!==o){var s=q(re.current.type);me[s]||(k('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',q(re.current.type),e.ref),me[s]=!0)}}function ht(e,o){{var s=function(){De||(De=!0,k("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",o))};s.isReactWarning=!0,Object.defineProperty(e,"key",{get:s,configurable:!0})}}function bt(e,o){{var s=function(){$e||($e=!0,k("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",o))};s.isReactWarning=!0,Object.defineProperty(e,"ref",{get:s,configurable:!0})}}var Ct=function(e,o,s,g,O,N,E){var C={$$typeof:i,type:e,key:o,ref:s,props:E,_owner:N};return C._store={},Object.defineProperty(C._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(C,"_self",{configurable:!1,enumerable:!1,writable:!1,value:g}),Object.defineProperty(C,"_source",{configurable:!1,enumerable:!1,writable:!1,value:O}),Object.freeze&&(Object.freeze(C.props),Object.freeze(C)),C};function Et(e,o,s,g,O){{var N,E={},C=null,Y=null;s!==void 0&&(C=""+s),pt(o)&&(C=""+o.key),mt(o)&&(Y=o.ref,vt(o,O));for(N in o)ge.call(o,N)&&!gt.hasOwnProperty(N)&&(E[N]=o[N]);if(e&&e.defaultProps){var D=e.defaultProps;for(N in D)E[N]===void 0&&(E[N]=D[N])}if(C||Y){var $=typeof e=="function"?e.displayName||e.name||"Unknown":e;C&&ht(E,$),Y&&bt(E,$)}return Ct(e,C,Y,O,g,re.current,E)}}var pe=F.ReactCurrentOwner,Me=F.ReactDebugCurrentFrame;function Q(e){if(e){var o=e._owner,s=ae(e.type,e._source,o?o.type:null);Me.setExtraStackFrame(s)}else Me.setExtraStackFrame(null)}var ve;ve=!1;function he(e){return typeof e=="object"&&e!==null&&e.$$typeof===i}function Fe(){{if(pe.current){var e=q(pe.current.type);if(e)return`

Check the render method of \``+e+"`."}return""}}function Rt(e){{if(e!==void 0){var o=e.fileName.replace(/^.*[\\\/]/,""),s=e.lineNumber;return`

Check your code at `+o+":"+s+"."}return""}}var We={};function xt(e){{var o=Fe();if(!o){var s=typeof e=="string"?e:e.displayName||e.name;s&&(o=`

Check the top-level render call using <`+s+">.")}return o}}function Ke(e,o){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var s=xt(o);if(We[s])return;We[s]=!0;var g="";e&&e._owner&&e._owner!==pe.current&&(g=" It was passed a child from "+q(e._owner.type)+"."),Q(e),k('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',s,g),Q(null)}}function qe(e,o){{if(typeof e!="object")return;if(Array.isArray(e))for(var s=0;s<e.length;s++){var g=e[s];he(g)&&Ke(g,o)}else if(he(e))e._store&&(e._store.validated=!0);else if(e){var O=K(e);if(typeof O=="function"&&O!==e.entries)for(var N=O.call(e),E;!(E=N.next()).done;)he(E.value)&&Ke(E.value,o)}}}function St(e){{var o=e.type;if(o==null||typeof o=="string")return;var s;if(typeof o=="function")s=o.propTypes;else if(typeof o=="object"&&(o.$$typeof===h||o.$$typeof===v))s=o.propTypes;else return;if(s){var g=q(o);ft(s,e.props,"prop",g,e)}else if(o.PropTypes!==void 0&&!ve){ve=!0;var O=q(o);k("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",O||"Unknown")}typeof o.getDefaultProps=="function"&&!o.getDefaultProps.isReactClassApproved&&k("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function yt(e){{for(var o=Object.keys(e.props),s=0;s<o.length;s++){var g=o[s];if(g!=="children"&&g!=="key"){Q(e),k("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",g),Q(null);break}}e.ref!==null&&(Q(e),k("Invalid attribute `ref` supplied to `React.Fragment`."),Q(null))}}function Ye(e,o,s,g,O,N){{var E=x(e);if(!E){var C="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(C+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Y=Rt(O);Y?C+=Y:C+=Fe();var D;e===null?D="null":Array.isArray(e)?D="array":e!==void 0&&e.$$typeof===i?(D="<"+(q(e.type)||"Unknown")+" />",C=" Did you accidentally export a JSX literal instead of a component?"):D=typeof e,k("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",D,C)}var $=Et(e,o,s,O,N);if($==null)return $;if(E){var G=o.children;if(G!==void 0)if(g)if(Array.isArray(G)){for(var ee=0;ee<G.length;ee++)qe(G[ee],e);Object.freeze&&Object.freeze(G)}else k("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else qe(G,e)}return e===r.Fragment?yt($):St($),$}}function _t(e,o,s){return Ye(e,o,s,!0)}function wt(e,o,s){return Ye(e,o,s,!1)}var It=wt,Tt=_t;r.jsx=It,r.jsxs=Tt}()}(Ce)),Ce}process.env.NODE_ENV==="production"?Ee.exports=jt():Ee.exports=At();var A=Ee.exports;class Lt extends xe.WebSocketMessageReader{constructor(t,i){super(t);V(this,"onMessage");this.onMessage=i}readMessage(t){this.onMessage&&this.onMessage();const[,i]=t.split(`\r
\r
`);if(this.state==="initial")this.events.splice(0,0,{message:i});else if(this.state==="listening"){const l=JSON.parse(i);this.callback(l)}}}class kt extends xe.WebSocketMessageWriter{constructor(t,i){super(t);V(this,"onSend");this.onSend=i}async write(t){try{const i=JSON.stringify(t);this.socket.send(i),this.onSend&&this.onSend()}catch(i){this.errorCount++,this.fireError(i,t,this.errorCount)}}}const Dt={base:"vs-dark",inherit:!0,colors:{"editor.background":"#313131"},rules:[{token:"",background:"#313131"}]};function z(r){return`file:///PACKAGE/Project/Sources/${r}`}function Se(r,n=0){setTimeout(r,n)}function Qe(r,n){const t=new W.Selection(n.startLineNumber,n.startColumn,n.endLineNumber||n.startLineNumber,n.endColumn||n.startColumn);Se(()=>{r.setSelection(t),r.revealRangeInCenter(t),r.focus()})}function et(r,n,t=0){t>0&&(n=t+n),Se(()=>{r.setPosition({lineNumber:n,column:1}),r.revealLineInCenter(n),r.focus()})}function $t(r,n,t){const l=r.getModel();if(l&&n){const u=l.getLineCount();for(let d=1;d<=u;d++){const a=l.getLineContent(d);if(new RegExp(`(?:Function|function) ${t}`).test(a))return d}}return 0}const Mt={getServiceOverride:({openHandler:r})=>({get[H.ICodeEditorService.toString()](){const n=H.StandaloneServices.get(H.ICodeEditorService);return r&&n.registerCodeEditorOpenHandler(r),n}})},Ft={getServiceOverride:()=>({get[H.ILanguageFeaturesService.toString()](){return H.StandaloneServices.get(H.ILanguageFeaturesService)}})},Wt={getServiceOverride:()=>({get[H.ITextModelService.toString()](){const r=H.StandaloneServices.get(H.ITextModelService);return r.createModelReference=n=>Promise.resolve({dispose:()=>{}}),r}})},Kt={comments:{lineComment:"//",blockComment:["/**","**/"]},brackets:[["{","}"],["(",")"],["[","]"]],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],autoClosingPairs:[{open:"(",close:")"},{open:"{",close:"}"},{open:"[",close:"]"},{open:"'",close:"'",notIn:["string","comment"]},{open:'"',close:'"',notIn:["string"]},{open:"`",close:"`",notIn:["string","comment"]},{open:"/**",close:" **/",notIn:["string"]}],autoCloseBefore:";:.,=}])>` \n	",wordPattern:new RegExp("(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\r\\n\\t\\f\\v ]+)|(?<=[a-zA-Z]) ?(?=[a-zA-Z])"),indentationRules:{increaseIndentPattern:new RegExp("(^(?![^\\s])*\\s*(class constructor))|(^(?![^\\s])*\\s*(exposed|local|\\s*){1}\\s*function{1}\\s*\\w)|(^(?![^\\s])*\\s*(If|Else|For|For each|While|Begin SQL|Case of|Use|Repeat|: *\\(.*)).*$","i"),decreaseIndentPattern:new RegExp("(^(?![^\\s])*\\s*(exposed|local|\\s*){1}\\s*function{1}\\s*\\w)|(End If|End For|Else|End for each|End While|End SQL|End case|End use|Until|: *\\(.*).*$","i")},onEnterRules:[{beforeText:new RegExp("^exposed","i"),action:{indentAction:1}}]},qt={provideCompletionItems:async(r,n)=>{const t=r.getWordUntilPosition(n);return{suggestions:[{label:"var",kind:c.languages.CompletionItemKind.Snippet,range:new c.Range(n.lineNumber,t.startColumn,n.lineNumber,t.endColumn),insertText:["var ${1:var_name} : ${2:var_type}"].join(`
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"While",kind:c.languages.CompletionItemKind.Snippet,range:new c.Range(n.lineNumber,t.startColumn,n.lineNumber,t.endColumn),insertText:["While(${1:expression})","	${2:body}","End while"].join(`
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"Case of",kind:c.languages.CompletionItemKind.Snippet,range:new c.Range(n.lineNumber,t.startColumn,n.lineNumber,t.endColumn),insertText:["Case of","	:(${1:boolean_expression})","		${2:body}","End case"].join(`
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"Else",kind:c.languages.CompletionItemKind.Snippet,range:new c.Range(n.lineNumber,t.startColumn,n.lineNumber,t.endColumn),insertText:["Else","	"].join(`
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"If",kind:c.languages.CompletionItemKind.Snippet,range:new c.Range(n.lineNumber,t.startColumn,n.lineNumber,t.endColumn),insertText:["If (${1:expression})","	${5:body}","End if"].join(`
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"For",kind:c.languages.CompletionItemKind.Snippet,range:new c.Range(n.lineNumber,t.startColumn,n.lineNumber,t.endColumn),insertText:["For(${1:counter};${2:start};${3:end}${4:;increment})","	${5:body}","End for"].join(`
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"Function",kind:c.languages.CompletionItemKind.Snippet,range:new c.Range(n.lineNumber,t.startColumn,n.lineNumber,t.endColumn),insertText:["Function ${1:function_name}(${2:params}) -> ${3:var_name} : ${4:var_type}","	${5:body}"].join(`
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet}]}}},Yt={provideCompletionItems:async(r,n)=>{const t=r.getWordUntilPosition(n);return{suggestions:[{label:"var",kind:c.languages.CompletionItemKind.Snippet,range:new c.Range(n.lineNumber,t.startColumn,n.lineNumber,t.endColumn),insertText:["var ${1:var_name} : ${2:var_type}"].join(`
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"while",kind:c.languages.CompletionItemKind.Snippet,range:new c.Range(n.lineNumber,t.startColumn,n.lineNumber,t.endColumn),insertText:["while(${1:expression})","	${2:body}","end"].join(`
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"switch",kind:c.languages.CompletionItemKind.Snippet,range:new c.Range(n.lineNumber,t.startColumn,n.lineNumber,t.endColumn),insertText:["switch","	:(${1:boolean_expression})","		${2:body}","end"].join(`
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"else",kind:c.languages.CompletionItemKind.Snippet,range:new c.Range(n.lineNumber,t.startColumn,n.lineNumber,t.endColumn),insertText:["else","	"].join(`
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"if",kind:c.languages.CompletionItemKind.Snippet,range:new c.Range(n.lineNumber,t.startColumn,n.lineNumber,t.endColumn),insertText:["if (${1:expression})","	${5:body}","end"].join(`
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"for",kind:c.languages.CompletionItemKind.Snippet,range:new c.Range(n.lineNumber,t.startColumn,n.lineNumber,t.endColumn),insertText:["for(${1:counter},${2:start},${3:end}${4:,increment})","	${5:body}","end"].join(`
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"function",kind:c.languages.CompletionItemKind.Snippet,range:new c.Range(n.lineNumber,t.startColumn,n.lineNumber,t.endColumn),insertText:["function ${1:function_name}(${2:params}) -> ${3:var_name} : ${4:var_type}","	${5:body}"].join(`
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet}]}}},Ut=[{keybinding:W.KeyMod.CtrlCmd|W.KeyCode.NumpadAdd,command:"editor.action.fontZoomIn"},{keybinding:W.KeyMod.CtrlCmd|W.KeyCode.Equal,command:"editor.action.fontZoomIn"},{keybinding:W.KeyMod.CtrlCmd|W.KeyCode.NumpadSubtract,command:"editor.action.fontZoomOut"},{keybinding:W.KeyMod.CtrlCmd|W.KeyCode.Minus,command:"editor.action.fontZoomOut"},{keybinding:W.KeyMod.CtrlCmd|W.KeyCode.Numpad0,command:"editor.action.fontZoomReset"},{keybinding:W.KeyMod.CtrlCmd|W.KeyCode.Digit0,command:"editor.action.fontZoomReset"}],Vt=({defaultZoom:r})=>(w.useEffect(()=>{r!==void 0&&W.editor.EditorZoom.setZoomLevel(r)},[]),null);({}).VITE_DISABLE_MONACO_LOADER||Re.loader.config({monaco:c});const tt=w.createContext(void 0),Bt=({children:r,url:n,qodly:t,defaultZoom:i,openHandler:l,language:u="4d",defaultInited:d=!1})=>{const a=Re.useMonaco(),[f,h]=w.useState(d),[b,S]=w.useState(null),v=w.useRef(),P=w.useRef(0);w.useEffect(()=>{Ve.initServices({configureEditorOrViewsService:{enableViewsService:!1},debugLogging:!1,userServices:{...Mt.getServiceOverride({openHandler:l}),...Ft.getServiceOverride(),...Wt.getServiceOverride()}})},[]),w.useEffect(()=>{n&&a&&L()},[n,a]);const L=async()=>{if(!a)return;const x=await B.getMonacoTheme();a.editor.defineTheme("fd-dark",x||Dt),a.languages.register({id:u,extensions:[".4dm",".4qm",".4qs"],aliases:["4d","4D"]}),a.languages.setLanguageConfiguration(u,Kt),a.languages.registerCompletionItemProvider(u,t?Yt:qt),W.editor.addKeybindingRules(Ut),j()},j=()=>{S(null);let x;try{x=new WebSocket(localStorage.LSP_SERVER||n)}catch{S(new Event("INVALID_URL"));return}x.onopen=M,x.onclose=I,x.onerror=R,P.current=0},M=async function(){const x=xe.toSocket(this),T=new Lt(x),_=new kt(x),q=new Ve.MonacoLanguageClient({name:"4D Language Client",clientOptions:{workspaceFolder:{uri:W.Uri.parse("file:///PACKAGE")},documentSelector:[{scheme:"file",language:u}],errorHandler:{error:()=>({action:Be.ErrorAction.Continue}),closed:()=>({action:Be.CloseAction.DoNotRestart})}},connectionProvider:{get:()=>Promise.resolve({reader:T,writer:_})}});v.current=q,T.onClose(()=>{q.stop(),P.current<3?setTimeout(()=>{P.current++,j()},1e3):S(new Event("WEBSOCKET_CLOSED"))}),q.needsStart()&&await q.start(),h(!0)},I=()=>{},R=x=>{S(x)};w.useEffect(()=>{const x=B.lspSubject.subscribe(({action:T,payload:_})=>{switch(T){case B.LspActions.WILL_SAVE:y(_.filePath);break;case B.LspActions.DID_SAVE:m(_.filePath,_.content);break;case B.LspActions.WILL_CREATE:p(_.filePath);break;case B.LspActions.DID_CREATE:k(_.filePath);break;case B.LspActions.WILL_RENAME:K(_.oldPath,_.newPath);break;case B.LspActions.DID_RENAME:U(_.oldPath,_.newPath);break;case B.LspActions.WILL_DELETE:F(_.filePath);break;case B.LspActions.DID_DELETE:ue(_.filePath);break}});return()=>x.unsubscribe()},[]);const y=(x,T=J.TextDocumentSaveReason.Manual)=>{var _;(_=v.current)==null||_.sendNotification(J.WillSaveTextDocumentNotification.type,{textDocument:{uri:z(x)},reason:T})},m=(x,T)=>{var _;(_=v.current)==null||_.sendNotification(J.DidSaveTextDocumentNotification.type,{textDocument:{uri:z(x)},text:T})},p=x=>{var T;(T=v.current)==null||T.sendRequest(J.WillCreateFilesRequest.type,{files:[{uri:z(x)}]})},K=(x,T)=>{var _;(_=v.current)==null||_.sendRequest(J.WillRenameFilesRequest.type,{files:[{oldUri:z(x),newUri:z(T)}]})},F=x=>{var T;(T=v.current)==null||T.sendRequest(J.WillDeleteFilesRequest.type,{files:[{uri:z(x)}]})},k=x=>{var T;(T=v.current)==null||T.sendNotification(J.DidCreateFilesNotification.type,{files:[{uri:z(x)}]})},U=(x,T)=>{var _;(_=v.current)==null||_.sendNotification(J.DidRenameFilesNotification.type,{files:[{oldUri:z(x),newUri:z(T)}]})},ue=x=>{var T;(T=v.current)==null||T.sendNotification(J.DidDeleteFilesNotification.type,{files:[{uri:z(x)}]})};return A.jsxs(tt.Provider,{value:{inited:f||!!b,clientRef:v,lastError:b,reload:j},children:[r,A.jsx(Vt,{defaultZoom:i})]})};function zt(){const r=w.useContext(tt);if(r===void 0)throw new Error("useLSP must be used within an LSPContext");return r}const nt=w.createContext(void 0),Gt=w.memo(({children:r})=>{const[n,t]=w.useState(null);return A.jsx(nt.Provider,{value:{editor:n,setEditor:t},children:r})});function rt(){const r=w.useContext(nt),n=w.useState(null);if(r===void 0){const[t,i]=n;return{editor:t,setEditor:i}}return r}var it={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Je=w.createContext&&w.createContext(it),X=globalThis&&globalThis.__assign||function(){return X=Object.assign||function(r){for(var n,t=1,i=arguments.length;t<i;t++){n=arguments[t];for(var l in n)Object.prototype.hasOwnProperty.call(n,l)&&(r[l]=n[l])}return r},X.apply(this,arguments)},Zt=globalThis&&globalThis.__rest||function(r,n){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&n.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var l=0,i=Object.getOwnPropertySymbols(r);l<i.length;l++)n.indexOf(i[l])<0&&Object.prototype.propertyIsEnumerable.call(r,i[l])&&(t[i[l]]=r[i[l]]);return t};function ot(r){return r&&r.map(function(n,t){return w.createElement(n.tag,X({key:t},n.attr),ot(n.child))})}function st(r){return function(n){return w.createElement(Jt,X({attr:X({},r.attr)},n),ot(r.child))}}function Jt(r){var n=function(t){var i=r.attr,l=r.size,u=r.title,d=Zt(r,["attr","size","title"]),a=l||t.size||"1em",f;return t.className&&(f=t.className),r.className&&(f=(f?f+" ":"")+r.className),w.createElement("svg",X({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,i,d,{className:f,style:X(X({color:r.color||t.color},t.style),r.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),u&&w.createElement("title",null,u),r.children)};return Je!==void 0?w.createElement(Je.Consumer,null,function(t){return n(t)}):n(it)}function Ht(r){return st({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 10.5858L9.17157 7.75736L7.75736 9.17157L10.5858 12L7.75736 14.8284L9.17157 16.2426L12 13.4142L14.8284 16.2426L16.2426 14.8284L13.4142 12L16.2426 9.17157L14.8284 7.75736L12 10.5858Z"}}]})(r)}function Xt(r){return st({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M449.07 399.08L278.64 82.58c-12.08-22.44-44.26-22.44-56.35 0L51.87 399.08A32 32 0 0080 446.25h340.89a32 32 0 0028.18-47.17zm-198.6-1.83a20 20 0 1120-20 20 20 0 01-20 20zm21.72-201.15l-5.74 122a16 16 0 01-32 0l-5.74-121.95a21.73 21.73 0 0121.5-22.69h.21a21.74 21.74 0 0121.73 22.7z"}}]})(r)}const at=({lspProps:{lastError:r,reload:n}})=>{const[t,i]=w.useState(!1),l=()=>{n()},u=()=>{i(!1)};return w.useEffect(()=>{i(!!r)},[r]),t?A.jsxs("div",{className:"flex items-center border-b border-fd-gray-darker bg-grey-800 px-2 py-1.5 text-xs text-grey-50",children:[A.jsxs("span",{className:"flex flex-1 justify-center gap-1",children:[A.jsx(Xt,{className:"h-4 w-4 text-yellow-600"}),A.jsxs("span",{children:["LSP not loaded."," ",A.jsx("button",{className:"text-primary-dark underline",onClick:l,children:"Reload?"})]})]}),A.jsx("button",{className:"focus:outline-none",children:A.jsx(Ht,{className:"h-4 w-4 text-white",onClick:u})})]}):null},Qt={provideCompletionItems:(r,n)=>{const t=r.getWordUntilPosition(n);return{suggestions:[{label:"device:xs",kind:c.languages.CompletionItemKind.Snippet,documentation:"Media query for phone device",range:new c.Range(n.lineNumber,t.startColumn,n.lineNumber,t.endColumn),insertText:["@media screen and (max-width: ${1:365px}) {","  self {","    ${2:background-color}:${3:red};","  }","}"].join(`
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet}]}}};function en(r,n){const t=document.createElement("style");t.dataset.id=n,t.textContent=r,document.head.append(t)}function tn(r){return Array.from(document.styleSheets).find(n=>n.ownerNode.getAttribute("data-id")===r)}function nn(r,n){const t=[];let i=[];const l=[],u=(m,p,K,F)=>{t.push({startLineNumber:m,endLineNumber:K,startColumn:p,endColumn:F}),h(),f()},d=m=>{l.indexOf(m)<0&&l.push(m)},a=m=>{const p=l.indexOf(m);p<0||l.splice(p,1)},f=()=>{for(const m of l)try{m(i)}catch(p){console.error(p)}},h=()=>{const m=r.getModel();m&&(i=on(t.map(p=>[m.getOffsetAt({lineNumber:p.startLineNumber,column:p.startColumn}),m.getOffsetAt({lineNumber:p.endLineNumber,column:p.endColumn})]),!0),i.length>0&&(i[0][0]<=0&&(i[0][0]=Number.NEGATIVE_INFINITY),i[i.length-1][1]>=m.getValueLength()&&(i[i.length-1][1]=Number.POSITIVE_INFINITY)))},b=m=>{const p={isDeletion:!1,isAddition:!1,isReplacement:!1};return m.text===""?p.isDeletion=!0:m.range.startLineNumber===m.range.endLineNumber&&m.range.startColumn===m.range.endColumn?p.isAddition=!0:p.isReplacement=!0,p},S=r.onDidChangeModel(m=>{h(),R()}),v=r.onDidChangeModelContent(m=>{if(!m.isUndoing)for(const p of m.changes){const K=b(p);if(K.isReplacement||K.isDeletion||K.isAddition){const F=t.some(U=>p.range.startLineNumber>=U.startLineNumber&&p.range.endLineNumber<=U.endLineNumber&&p.range.startColumn>=U.startColumn&&p.range.endColumn<=U.endColumn),k=!F&&n&&p.range.startLineNumber===1&&p.range.startColumn===1&&!B.hasAttributesString(p.text);if(F||k){const U=r.getModel();if(U){U.undo();return}}}}}),P=()=>{S.dispose(),v.dispose()};let L=[],j=`
    .idoc-readonly-mark {
      cursor: not-allowed;
      z-index: 1;
    }
  `;if(j){const m="monaco-read-only";tn(m)||en(j,m),j=null}const M=()=>{d(R),R()},I=()=>{a(R),L=r.deltaDecorations(L,[])},R=()=>{const m=r.getModel();m&&(L=r.deltaDecorations(L,i.map(y(m))))},y=m=>p=>{const K=m.getPositionAt(p[0]),F=m.getPositionAt(p[1]);return{range:new c.Range(K.lineNumber,K.column,F.lineNumber,F.column),options:{className:"idoc-readonly-mark"}}};return{get buffer(){return i},exclude:u,attach:d,detach:a,dispose:P,show:M,hide:I}}function rn(r,n,t){let i=!1;const l=I=>I[1]<I[0]?(i=!0,[[I[1],I[0]]]):[[...I]],u=I=>i?I.map(R=>R[1]>R[0]?a(R):R).reverse():I;let d;const a=I=>(d=I[1],I[1]=I[0],I[0]=d,I),f=l(r);let h,b,S,v,P,L,j,M;S=f[0];for(b of n)for(j=b[0],M=b[1],v=0;v<f.length;v++){if(S=f[v],P=S[0],L=S[1],P<j)L<j?h=[S]:L<=M?h=[[P,j-1]]:h=[[P,j-1],[M+1,L]];else if(P<=M)if(j===Number.NEGATIVE_INFINITY){const I=M+1;h=t===0?[]:[[I,L>I?L:I]]}else M===Number.POSITIVE_INFINITY?h=t===0?[]:[[j-1,j-1]]:L<=M?h=t<0?[[j-1,j-1]]:t>0?[[M+1,M+1]]:[]:h=[[M+1,L]];else h=[S];if(f.splice(v,1,...h),f.length===1&&f[0][1]<j)return u(f)}return u(f)}function on(r,n){if(r.length<2)return r;const t=[];let i=null,l,u;r=r.map(d=>(d[1]<d[0]&&(l=d[1],d[1]=d[0],d[1]=l),d)).sort((d,a)=>d[0]-a[0]),t.push(r[0]);for(let d=1;d<r.length;d++)i=t[t.length-1],u=r[d],i[1]===u[0]&&!n?t.push(u):i[1]===u[0]-1&&n?(i[1]=u[1],t.splice(t.length-1,1,i)):i[1]<u[0]?t.push(u):i[1]<u[1]&&(i[1]=u[1],t.splice(t.length-1,1,i));return t}function ie(r,n){return n.bind(r)}class sn{constructor(n,t){V(this,"editor");V(this,"intervals");V(this,"disposables",[]);V(this,"prefer",1);V(this,"lastPrefer",1);V(this,"onCursor",ie(this,function(n){if(n.source==="api")return;const t=this.getApprovedSelections();t.length!==0&&this.editor.setSelections(t)}));V(this,"onRectangleSelectionStart",ie(this,function({event:n}){n.middleButton&&(this.lastPrefer=this.prefer,this.prefer=0,window.addEventListener("pointerup",this.onRectangleSelectionStop))}));V(this,"onRectangleSelectionStop",ie(this,function(){this.prefer=this.lastPrefer,window.removeEventListener("pointerup",this.onRectangleSelectionStop)}));V(this,"onKey",ie(this,function(n){const t=n.keyCode,i=c.KeyCode;if(n.altKey||i.F1<=t&&t<=i.F19||n.ctrlKey&&t!==i.Backspace)return;if(t===i.UpArrow||t===i.LeftArrow||t===i.Home||t===i.PageUp){this.prefer=-1;return}if(t===i.DownArrow||t===i.RightArrow||t===i.End||t===i.PageDown){this.prefer=1;return}const l=this.getSelections(),u=this.intervals.buffer;let d;if(t===i.Delete)d=a=>a[0]===a[1]&&u.find(f=>a[1]+1===f[0])!=null;else if(t===i.Backspace)d=a=>a[0]===a[1]&&u.find(f=>f[1]+1===a[0])!=null;else return;l.findIndex(d)!==-1&&(n.stopPropagation(),n.preventDefault())}));V(this,"getOffsetAt",ie(this,function(n){let t;for(let i=0;i<this.intervals.buffer.length;i++)if(t=this.intervals.buffer[i],n<=t[1])return t[0]-n<n-t[1]?t[0]:t[1]}));var i;this.editor=n,this.intervals=nn(n,t),(i=this.editor.getModel())==null||i.setEOL(c.editor.EndOfLineSequence.LF)}enable(){this.disposables.push(this.editor.onDidChangeCursorPosition(this.onCursor),this.editor.onKeyDown(this.onKey),this.editor.onMouseDown(this.onRectangleSelectionStart)),this.intervals.show()}dispose(){for(const n of this.disposables)n.dispose();this.disposables.splice(0)}exclude(n,t,i,l){arguments.length===1?this.intervals.exclude(n,0,n,Number.MAX_SAFE_INTEGER):this.intervals.exclude(n,t,i,l)}getApprovedSelections(){const n=this.editor.getModel();return this.getSelections().map(i=>rn(i,this.intervals.buffer,this.prefer)).flat().map(i=>{const l=n.getPositionAt(i[0]),u=n.getPositionAt(i[1]);return new c.Selection(l.lineNumber,l.column,u.lineNumber,u.column)})}getSelections(){const n=this.editor.getModel();return(this.editor.getSelections()||[]).map(t=>[n.getOffsetAt({lineNumber:t.selectionStartLineNumber,column:t.selectionStartColumn}),n.getOffsetAt({lineNumber:t.positionLineNumber,column:t.positionColumn})])}}const an=new RegExp("^[	s]+(exposed|Function)","i"),He=()=>A.jsx("div",{className:"absolute inset-0 animate-pulse",children:A.jsx("div",{className:"w-full space-y-4 px-4 py-1",children:A.jsxs("div",{className:"space-y-2",children:[A.jsx("div",{className:"h-3 w-3/4 rounded bg-grey-200"}),A.jsx("div",{className:"h-3 rounded bg-grey-200"}),A.jsx("div",{className:"h-3 w-5/6 rounded bg-grey-200"}),A.jsx("div",{className:"h-3 rounded bg-grey-200"}),A.jsx("div",{className:"h-3 rounded bg-grey-200"})]})})}),ln=({path:r,initialValue:n,theme:t="fd-dark",type:i,language:l,onChange:u,options:d={},extra:a={},showAlerts:f=!1,lspProps:h,...b})=>{const{initialLineInfo:S,initialSelectionInfo:v}=a,{editor:P,setEditor:L}=rt(),{inited:j}=h;function M(R){l==="css"&&R.languages.registerCompletionItemProvider("css",Qt)}function I(R,y){L(R);const m=R.getModel();if(m&&(m.updateOptions({insertSpaces:!1}),R.onKeyUp(()=>{var K;const p=(K=R.getPosition())==null?void 0:K.lineNumber;if(p){const F=m.getLineFirstNonWhitespaceColumn(p),k=m.getLineLength(p),U=m.getLineContent(p);an.test(U)&&R.executeEdits("edit-handler",[{range:new y.Range(p,0,p,k),text:U.substr(F-1,k-F)}])}})),i===B.FileFolderType.METHOD&&B.hasAttributesString(n)){const p=new sn(R,!0);p.exclude(1,1,1,Number.POSITIVE_INFINITY),p.enable()}}return w.useEffect(()=>{if(!P)return;const{line:R,offset:y}=S||{};R&&et(P,R,y)},[S,P]),w.useEffect(()=>{if(!P)return;const{selection:R}=v||{};R&&Qe(P,R)},[v,P]),j?A.jsxs(A.Fragment,{children:[f?A.jsx(at,{lspProps:h}):null,A.jsx(Re.Editor,{options:{readOnly:!0,fontSize:12,"semanticHighlighting.enabled":!0,...d},path:z(r),value:n,theme:"fd-dark",onChange:R=>u&&u(R||""),language:l,beforeMount:M,onMount:I,loading:A.jsx(He,{}),...b})]}):A.jsx(He,{})};exports.Alerts=at;exports.CodeEditor=ln;exports.CodeEditorProvider=Gt;exports.LSPProvider=Bt;exports._await=Se;exports.getFileSystemPath=z;exports.getFunctionOffset=$t;exports.jumpToLine=et;exports.jumpToSelection=Qe;exports.useCodeEditor=rt;exports.useLSP=zt;
//# sourceMappingURL=index.cjs.js.map
