diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/JsonRpc2.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/JsonRpc2.cs new file mode 100644 index 0000000..3e30b2f --- /dev/null +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/JsonRpc2.cs @@ -0,0 +1,85 @@ +using log4net; +using System; +using System.Net; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; + +namespace WelsonJS.Launcher.ApiEndpoints +{ + public class JsonRpc2 : IApiEndpoint + { + private readonly ResourceServer Server; + private readonly HttpClient _httpClient; + private readonly ILog _logger; + private const string Prefix = "jsonrpc2"; + + public JsonRpc2(ResourceServer server, HttpClient httpClient, ILog logger) + { + Server = server; + + _httpClient = httpClient; + _logger = logger; + } + + public bool CanHandle(HttpListenerContext context, string path) + { + if (context == null) + return false; + + if (!string.Equals(context.Request.HttpMethod, "POST", StringComparison.OrdinalIgnoreCase)) + return false; + + if (path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase) == false) + return false; + + string contentType = context.Request.ContentType?.ToLowerInvariant() ?? string.Empty; + if (!(contentType.StartsWith("application/json") + || contentType.StartsWith("application/json-rpc") + || contentType.StartsWith("application/jsonrpc") + || contentType.StartsWith("text/json"))) + return false; + + if (!context.Request.HasEntityBody) + return false; + + return true; + } + + public async Task HandleAsync(HttpListenerContext context, string path) + { + string body; + try + { + using (var input = context.Request.InputStream) + using (var reader = new System.IO.StreamReader(input, System.Text.Encoding.UTF8)) + { + body = await reader.ReadToEndAsync(); + } + + _logger.Debug($"[JsonRpc2] Request body received ({body.Length} bytes)"); + } + catch (Exception ex) + { + _logger.Error("[JsonRpc2] Failed to read request body", ex); + + context.Response.StatusCode = (int)HttpStatusCode.BadRequest; + context.Response.Close(); + return; + } + + var dispatcher = new JsonRpc2Dispatcher(_logger); + + using (var cts = new CancellationTokenSource(TimeSpan.FromSeconds(300))) + { + await dispatcher.HandleAsync( + body, + async (method, ser, id, ct) => + { + throw new NotImplementedException(); + }, + cts.Token); + } + } + } +} \ No newline at end of file diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/JsNative.cs b/WelsonJS.Augmented/WelsonJS.Launcher/JsNative.cs index 3f44823..a5ed2a0 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/JsNative.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/JsNative.cs @@ -1,4 +1,9 @@ -using System; +// JsNative.cs +// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2025 Catswords OSS and WelsonJS Contributors +// https://github.com/gnh1201/welsonjs +// +using System; using System.Runtime.InteropServices; namespace WelsonJS.Launcher diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/JsSerializer.cs b/WelsonJS.Augmented/WelsonJS.Launcher/JsSerializer.cs index 8261edc..c037786 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/JsSerializer.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/JsSerializer.cs @@ -44,7 +44,7 @@ namespace WelsonJS.Launcher // Create slot and parse // Using Object.create(null) for a clean dictionary without prototype. var sb = new StringBuilder(); - sb.Append("(function(){var S=globalThis.__WJ_STORE;"); + sb.Append("(function(){var S=globalThis.__WJS__;"); sb.Append("S[").Append(id.ToString(CultureInfo.InvariantCulture)).Append("]=JSON.parse(").Append(Q(json)).Append(");"); sb.Append("return '1';})()"); string r = _core.EvaluateToString(sb.ToString()); @@ -59,7 +59,7 @@ namespace WelsonJS.Launcher public void Unload(int id) { EnsureStore(); - string script = "(function(){var S=globalThis.__WJ_STORE; delete S[" + id.ToString(CultureInfo.InvariantCulture) + "]; return '1';})()"; + string script = "(function(){var S=globalThis.__WJS__; delete S[" + id.ToString(CultureInfo.InvariantCulture) + "]; return '1';})()"; _core.EvaluateToString(script); } @@ -70,7 +70,7 @@ namespace WelsonJS.Launcher { if (json == null) throw new ArgumentNullException("json"); EnsureStore(); - string script = "(function(){var S=globalThis.__WJ_STORE; S[" + id.ToString(CultureInfo.InvariantCulture) + "]=JSON.parse(" + Q(json) + "); return '1';})()"; + string script = "(function(){var S=globalThis.__WJS__; S[" + id.ToString(CultureInfo.InvariantCulture) + "]=JSON.parse(" + Q(json) + "); return '1';})()"; _core.EvaluateToString(script); } @@ -81,7 +81,7 @@ namespace WelsonJS.Launcher { EnsureStore(); space = Clamp(space, 0, 10); - string script = "(function(){var v=globalThis.__WJ_STORE[" + id.ToString(CultureInfo.InvariantCulture) + "]; return JSON.stringify(v,null," + space.ToString(CultureInfo.InvariantCulture) + ");})()"; + string script = "(function(){var v=globalThis.__WJS__[" + id.ToString(CultureInfo.InvariantCulture) + "]; return JSON.stringify(v,null," + space.ToString(CultureInfo.InvariantCulture) + ");})()"; return _core.EvaluateToString(script); } @@ -96,13 +96,13 @@ namespace WelsonJS.Launcher string jsPath = BuildJsPath(path); var sb = new StringBuilder(); - sb.Append("(function(){var v=globalThis.__WJ_STORE[") + sb.Append("(function(){var v=globalThis.__WJS__[") .Append(id.ToString(CultureInfo.InvariantCulture)) .Append("];var p=").Append(jsPath).Append(";"); sb.Append("for(var i=0;i HandleAsync( + string requestBody, + Func> dispatchMethodAsync, + CancellationToken ct) + { + if (string.IsNullOrEmpty(requestBody)) + throw new JsonRpc2Exception("Empty request body"); + + if (dispatchMethodAsync == null) + throw new ArgumentNullException("dispatchMethodAsync"); + + using (var ser = new JsSerializer()) + { + int id = ser.Load(requestBody); + + try + { + string version = ser.ExtractFrom(id, "jsonrpc"); + if (!string.Equals(version, "2.0", StringComparison.Ordinal)) + throw new JsonRpc2Exception("Unsupported JSON-RPC version: " + version); + + string method = ser.ExtractFrom(id, "method"); + if (string.IsNullOrEmpty(method)) + throw new JsonRpc2Exception("Missing method"); + + var req = new JsonRpc2Request + { + Version = version, + Method = method + }; + + return await dispatchMethodAsync(req.Method, ser, id, ct); + } + catch (JsonRpc2Exception) + { + throw; + } + catch (Exception ex) + { + if (_logger != null) + _logger.Error("[JsonRpc2] Parse error", ex); + + throw new JsonRpc2Exception("Parse error", ex); + } + finally + { + ser.Unload(id); + } + } + } + } +} \ No newline at end of file diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/Program.cs b/WelsonJS.Augmented/WelsonJS.Launcher/Program.cs index d4f8c57..83c6630 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/Program.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/Program.cs @@ -11,8 +11,12 @@ using System.Diagnostics; using System.IO; using System.IO.Compression; using System.Linq; +using System.Net.Http; +using System.Net.Http.Headers; using System.Reflection; +using System.Text; using System.Threading; +using System.Threading.Tasks; using System.Windows.Forms; namespace WelsonJS.Launcher @@ -49,7 +53,8 @@ namespace WelsonJS.Launcher string targetFilePath = GetTargetFilePath(args); if (!string.IsNullOrEmpty(targetFilePath)) { - try { + try + { HandleTargetFilePath(targetFilePath); } catch (Exception e) @@ -59,6 +64,14 @@ namespace WelsonJS.Launcher return; } + // if use the stdio-jsonrpc2 forwarder + if (HasArg(args, "--stdio-jsonrpc2")) + { + _logger.Info("Starting in the stdio-jsonrpc2 forwarder..."); + ProcessStdioJsonRpc2().GetAwaiter().GetResult(); + return; + } + // create the mutex _mutex = new Mutex(true, "WelsonJS.Launcher", out bool createdNew); if (!createdNew) @@ -81,6 +94,135 @@ namespace WelsonJS.Launcher _mutex.Dispose(); } + private static bool HasArg(string[] args, string key) + { + if (args == null) + return false; + + for (int i = 0; i < args.Length; i++) + if (string.Equals(args[i], key, StringComparison.OrdinalIgnoreCase)) + return true; + + return false; + } + + private async static Task ProcessStdioJsonRpc2() + { + string serverPrefix = GetAppConfig("ResourceServerPrefix"); + string endpoint = $"{serverPrefix}jsonrpc2"; + int timeout = int.TryParse(GetAppConfig("HttpClientTimeout"), out timeout) ? timeout : 300; + + var http = new HttpClient + { + Timeout = TimeSpan.FromSeconds(timeout) + }; + + using (var stdin = Console.OpenStandardInput()) + using (var stdout = Console.OpenStandardOutput()) + { + var buffer = new byte[8192]; + + while (true) + { + int read; + try + { + read = await stdin.ReadAsync(buffer, 0, buffer.Length); + } + catch (Exception ex) + { + _logger.Error("[stdio] stdin read failed", ex); + break; + } + + if (read <= 0) + { + _logger.Info("[stdio] EOF received, exiting loop"); + break; + } + + byte[] payload = new byte[read]; + Buffer.BlockCopy(buffer, 0, payload, 0, read); + + _logger.Debug($"[stdio] recv {payload.Length} bytes"); + _logger.Debug($"[stdio] payload preview: {SafePreviewUtf8(payload, 512)}"); + + try + { + using (var content = new ByteArrayContent(payload)) + { + // Content-Type: application/json + content.Headers.ContentType = + new MediaTypeHeaderValue("application/json") + { + CharSet = "utf-8" + }; + + _logger.Debug($"[http] POST {endpoint}"); + + using (var response = await http.PostAsync(endpoint, content)) + { + _logger.Info( + $"[http] status={(int)response.StatusCode} {response.ReasonPhrase}"); + + foreach (var h in response.Headers) + _logger.Debug($"[http] H {h.Key}: {string.Join(", ", h.Value)}"); + + foreach (var h in response.Content.Headers) + _logger.Debug($"[http] HC {h.Key}: {string.Join(", ", h.Value)}"); + + byte[] responseBytes = + await response.Content.ReadAsByteArrayAsync(); + + _logger.Debug($"[http] body {responseBytes.Length} bytes"); + + _logger.Debug( + $"[http] body preview: {SafePreviewUtf8(responseBytes, 2048)}"); + + await stdout.WriteAsync(responseBytes, 0, responseBytes.Length); + await stdout.FlushAsync(); + } + } + } + catch (TaskCanceledException ex) + { + _logger.Error("[http] request timed out or canceled", ex); + } + catch (HttpRequestException ex) + { + _logger.Error("[http] request failed", ex); + } + catch (Exception ex) + { + _logger.Error("[http] unexpected error", ex); + } + } + } + } + + private static string SafePreviewUtf8(byte[] bytes, int maxBytes) + { + if (bytes == null || bytes.Length == 0) + return "(empty)"; + + try + { + int len = Math.Min(bytes.Length, maxBytes); + string s = Encoding.UTF8.GetString(bytes, 0, len); + + s = s.Replace("\r", "\\r").Replace("\n", "\\n"); + + if (bytes.Length > maxBytes) + s += $"...(truncated, total {bytes.Length} bytes)"; + + return s; + } + catch + { + return "(binary / non-utf8 response)"; + } + } + private static void InitializeAssemblyLoader() { byte[] gzBytes = Properties.Resources.Phantomizer; @@ -182,7 +324,8 @@ namespace WelsonJS.Launcher private static string GetTargetFilePath(string[] args) { - if (args == null || args.Length == 0) return null; + if (args == null || args.Length == 0) + return null; for (int i = 0; i < args.Length; i++) { @@ -498,7 +641,7 @@ namespace WelsonJS.Launcher public static void InitializeResourceServer() { - lock(typeof(Program)) + lock (typeof(Program)) { if (_resourceServer == null) { diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/Properties/Resources.Designer.cs b/WelsonJS.Augmented/WelsonJS.Launcher/Properties/Resources.Designer.cs index 4edcfc2..7252004 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/Properties/Resources.Designer.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace WelsonJS.Launcher.Properties { // 클래스에서 자동으로 생성되었습니다. // 멤버를 추가하거나 제거하려면 .ResX 파일을 편집한 다음 /str 옵션을 사용하여 ResGen을 // 다시 실행하거나 VS 프로젝트를 다시 빌드하십시오. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -81,27 +81,27 @@ namespace WelsonJS.Launcher.Properties { /// /// 과(와) 유사한 지역화된 문자열을 찾습니다. /// - internal static string AzureAiServiceApiKey { + internal static string AzureCognitiveApiKey { get { - return ResourceManager.GetString("AzureAiServiceApiKey", resourceCulture); + return ResourceManager.GetString("AzureCognitiveApiKey", resourceCulture); } } /// /// 2024-05-01-preview과(와) 유사한 지역화된 문자열을 찾습니다. /// - internal static string AzureAiServiceApiVersion { + internal static string AzureCognitiveApiVersion { get { - return ResourceManager.GetString("AzureAiServiceApiVersion", resourceCulture); + return ResourceManager.GetString("AzureCognitiveApiVersion", resourceCulture); } } /// - /// https://ai-catswords656881030318.services.ai.azure.com/과(와) 유사한 지역화된 문자열을 찾습니다. + /// https://catswords-ai-resource.services.ai.azure.com/과(와) 유사한 지역화된 문자열을 찾습니다. /// - internal static string AzureAiServicePrefix { + internal static string AzureCognitivePrefix { get { - return ResourceManager.GetString("AzureAiServicePrefix", resourceCulture); + return ResourceManager.GetString("AzureCognitivePrefix", resourceCulture); } } @@ -197,7 +197,7 @@ namespace WelsonJS.Launcher.Properties { } /// - /// 90과(와) 유사한 지역화된 문자열을 찾습니다. + /// 300과(와) 유사한 지역화된 문자열을 찾습니다. /// internal static string HttpClientTimeout { get { @@ -407,7 +407,7 @@ namespace WelsonJS.Launcher.Properties { } /// - /// 141.101.82.1과(와) 유사한 지역화된 문자열을 찾습니다. + /// 49.8.14.101과(와) 유사한 지역화된 문자열을 찾습니다. /// internal static string WhoisClientAddress { get { @@ -416,7 +416,7 @@ namespace WelsonJS.Launcher.Properties { } /// - /// https://xn--c79as89aj0e29b77z.xn--3e0b707e/kor/whois/whois.jsp과(와) 유사한 지역화된 문자열을 찾습니다. + /// https://whois.kr/kor/whois/whois.jsp과(와) 유사한 지역화된 문자열을 찾습니다. /// internal static string WhoisReferrerUrl { get { @@ -425,7 +425,7 @@ namespace WelsonJS.Launcher.Properties { } /// - /// https://xn--c79as89aj0e29b77z.xn--3e0b707e/kor/whois.jsc과(와) 유사한 지역화된 문자열을 찾습니다. + /// https://whois.kr/kor/whois.jsc과(와) 유사한 지역화된 문자열을 찾습니다. /// internal static string WhoisServerUrl { get { diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/Properties/Resources.resx b/WelsonJS.Augmented/WelsonJS.Launcher/Properties/Resources.resx index bb52cbb..b5f737d 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/Properties/Resources.resx +++ b/WelsonJS.Augmented/WelsonJS.Launcher/Properties/Resources.resx @@ -160,35 +160,35 @@ http://localhost:9222/ - + - - https://ai-catswords656881030318.services.ai.azure.com/ + + https://catswords-ai-resource.services.ai.azure.com/ 1.1.1.1 - 141.101.82.1 + 49.8.14.101 - https://xn--c79as89aj0e29b77z.xn--3e0b707e/kor/whois/whois.jsp + https://whois.kr/kor/whois/whois.jsp - https://xn--c79as89aj0e29b77z.xn--3e0b707e/kor/whois.jsc + https://whois.kr/kor/whois.jsc https://catswords.blob.core.windows.net/welsonjs/ - + 2024-05-01-preview https://catswords.blob.core.windows.net/welsonjs/blob.config.xml - 90 + 300 diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ResourceServer.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ResourceServer.cs index 2a83aef..b6c780a 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ResourceServer.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ResourceServer.cs @@ -4,8 +4,6 @@ // https://github.com/gnh1201/welsonjs // using log4net; -using log4net.Core; -using Microsoft.Isam.Esent.Interop; using System; using System.Collections.Generic; using System.IO; @@ -75,6 +73,7 @@ namespace WelsonJS.Launcher _apis.Add(new ApiEndpoints.TwoFactorAuth(this, _httpClient, _logger)); _apis.Add(new ApiEndpoints.Whois(this, _httpClient, _logger)); _apis.Add(new ApiEndpoints.ImageColorPicker(this, _httpClient, _logger)); + _apis.Add(new ApiEndpoints.JsonRpc2(this, _httpClient, _logger)); // Register the prefix _listener.Prefixes.Add(prefix); @@ -164,8 +163,8 @@ namespace WelsonJS.Launcher // Serve from the blob server if (await ServeBlob(context, path)) return; - // Fallback to serve from a resource name - await ServeResource(context, GetResource(_resourceName), "text/html"); + // Fallback to 404 (Not Found) + await ServeResource(context); } private async Task ServeBlob(HttpListenerContext context, string path, string prefix = null) @@ -398,7 +397,7 @@ namespace WelsonJS.Launcher await ServeResource(context, Encoding.UTF8.GetBytes(data), mimeType, statusCode); } - private byte[] GetResource(string resourceName) + public static byte[] GetResource(string resourceName) { // Try to fetch embedded resource. byte[] data = GetEmbeddedResource(typeof(Program).Namespace + "." + resourceName); @@ -408,7 +407,7 @@ namespace WelsonJS.Launcher return GetResourceFromManager(resourceName); } - private byte[] GetEmbeddedResource(string fullResourceName) + private static byte[] GetEmbeddedResource(string fullResourceName) { Assembly assembly = Assembly.GetExecutingAssembly(); using (Stream stream = assembly.GetManifestResourceStream(fullResourceName)) @@ -425,7 +424,7 @@ namespace WelsonJS.Launcher return null; } - private byte[] GetResourceFromManager(string resourceName) + private static byte[] GetResourceFromManager(string resourceName) { object resourceObject = Properties.Resources.ResourceManager.GetObject(resourceName); switch (resourceObject) @@ -439,7 +438,7 @@ namespace WelsonJS.Launcher } } - private byte[] ConvertIconToBytes(System.Drawing.Icon icon) + private static byte[] ConvertIconToBytes(System.Drawing.Icon icon) { using (MemoryStream memoryStream = new MemoryStream()) { diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/WelsonJS.Launcher.csproj b/WelsonJS.Augmented/WelsonJS.Launcher/WelsonJS.Launcher.csproj index 17227f7..8a6e59b 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/WelsonJS.Launcher.csproj +++ b/WelsonJS.Augmented/WelsonJS.Launcher/WelsonJS.Launcher.csproj @@ -91,9 +91,11 @@ + + diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/app.config b/WelsonJS.Augmented/WelsonJS.Launcher/app.config index b858537..80f9244 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/app.config +++ b/WelsonJS.Augmented/WelsonJS.Launcher/app.config @@ -10,12 +10,12 @@ - - - - - - + + + + + + diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/editor.html b/WelsonJS.Augmented/WelsonJS.Launcher/editor.html index 9a72022..dd8c33b 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/editor.html +++ b/WelsonJS.Augmented/WelsonJS.Launcher/editor.html @@ -28,6 +28,10 @@ #editor { flex: 3; } + + #mapView { + flex: 3; + } #promptEditor { flex: 1; @@ -60,6 +64,7 @@ } }; + @@ -103,7 +108,8 @@ loadResource("http://localhost:3000/ajax/libs/metroui/dev/lib/metro.css", "text/css", "sha384-4XgOiXH2ZMaWt5s5B35yKi7EAOabhZvx7wO8Jr71q2vZ+uONdRza/6CsK2kpyocd"), loadResource("http://localhost:3000/ajax/libs/metroui/dev/lib/icons.css", "text/css", "sha384-FuLND994etg+RtnpPSPMyNBvL+fEz+xGhbN61WUWuDEeZ+wJzcQ8SGqAMuI5hWrt"), loadResource("http://localhost:3000/ajax/libs/monaco-editor/0.52.2/min/vs/editor/editor.main.css", "text/css", "sha384-06yHXpYRlHEPaR4AS0fB/W+lMN09Zh5e1XMtfkNQdHV38OlhfkOEW5M+pCj3QskC"), - loadResource("http://localhost:3000/ajax/libs/jsoneditor/10.1.3/jsoneditor.min.css", "text/css", "sha384-cj1rYBc4/dVYAknZMTkVCDRL6Knzugf32igVqsuFW0iRWFHKH8Ci8+ekC8gNsFZ+") + loadResource("http://localhost:3000/ajax/libs/jsoneditor/10.1.3/jsoneditor.min.css", "text/css", "sha384-cj1rYBc4/dVYAknZMTkVCDRL6Knzugf32igVqsuFW0iRWFHKH8Ci8+ekC8gNsFZ+"), + loadResource("http://localhost:3000/ajax/libs/leaflet/1.9.4/leaflet.min.css", "text/css", "sha384-c6Rcwz4e4CITMbu/NBmnNS8yN2sC3cUElMEMfP3vqqKFp7GOYaaBBCqmaWBjmkjb") ]).then(() => { const _e = React.createElement; @@ -128,9 +134,9 @@ } function RibbonMenu({ - onOpenFileClick, onSaveFileClick, onCopliotClick, onAzureAiClick, + onOpenFileClick, onSaveFileClick, onCopliotClick, onAzureCognitiveClick, onSavePromptClick, onLoadPromptClick, onQueryWhoisClick, onQueryDnsClick, - onQueryIpClick + onQueryIpClick, onMapClick }) { const fileButtons = [ { @@ -147,9 +153,9 @@ } ]; - const aiButtons = [ + const cognitiveToolsButtons = [ { id: 'btnCopilot', icon: 'mif-rocket', caption: 'Copilot', onClick: onCopliotClick }, - { id: 'btnAzureAi', icon: 'mif-rocket', caption: 'Azure AI', onClick: onAzureAiClick }, + { id: 'btnAzureCognitive', icon: 'mif-rocket', caption: 'Azure', onClick: onAzureCognitiveClick }, { id: 'btnSavePrompt', icon: 'mif-floppy-disks', caption: 'Save', onClick: onSavePromptClick }, { id: 'btnLoadPrompt', icon: 'mif-file-upload', caption: 'Load', onClick: onLoadPromptClick } ]; @@ -157,7 +163,8 @@ const networkToolsButtons = [ { id: 'btnWhois', icon: 'mif-earth', caption: 'Whois', onClick: onQueryWhoisClick }, { id: 'btnQueryDns', icon: 'mif-earth', caption: 'DNS', onClick: onQueryDnsClick }, - { id: 'btnQueryIp', icon: 'mif-user-secret', caption: 'IP', onClick: onQueryIpClick } + { id: 'btnQueryIp', icon: 'mif-user-secret', caption: 'IP', onClick: onQueryIpClick }, + { id: 'btnMap', icon: 'mif-rocket', caption: 'Map', onClick: onMapClick } ]; return _e( @@ -170,14 +177,14 @@ _e('div', { className: 'content-holder' }, _e('div', { className: 'section active', id: 'editor-tab' }, _e(Group, { title: 'File', buttons: fileButtons }), - _e(Group, { title: 'Generative AI', buttons: aiButtons }), - _e(Group, { title: 'Network tools', buttons: networkToolsButtons }) + _e(Group, { title: 'Cognitive Tools (AI)', buttons: cognitiveToolsButtons }), + _e(Group, { title: 'Network Tools', buttons: networkToolsButtons }) ) ) ); } - function Editor({ editorRef }) { + function Editor({ editorRef, visible }) { const containerRef = React.useRef(null); const getSuggestions = (word, range) => axios.get(`/completion/${encodeURIComponent(word)}`) @@ -232,6 +239,11 @@ editorRef.current = instance; }); }, []); + + React.useEffect(() => { + // toggle the display style attribute + containerRef.current.style.display = (visible ? "" : "none"); + }, [visible]); return _e('div', { id: 'editor', ref: containerRef }); } @@ -281,6 +293,95 @@ return _e('div', { id: 'promptEditor', ref: containerRef }); } + + function useLocationMarker(mapViewRef) { + const markerRef = React.useRef(null); + + const mark = React.useCallback((lat, lng, description) => { + const map = mapViewRef.current; + if (!map) return; + + const latlng = L.latLng(lat, lng); + + if (!markerRef.current) { + markerRef.current = L.marker(latlng).addTo(map) + .bindPopup(description || "(no description)") + .openPopup(); + } else { + markerRef.current.setLatLng(latlng); + } + }, [mapViewRef]); + + return { mark, markerRef }; + } + + function MapView({ mapViewRef, visible }) { + const containerRef = React.useRef(null); + + const { mark } = useLocationMarker(mapViewRef); + + // init once + React.useEffect(() => { + if (!containerRef.current) + return; + + if (typeof L === "undefined" || !L || !L.map) { + console.error("[MapView] Leaflet (L) is not loaded."); + return; + } + + if (mapViewRef && mapViewRef.current && mapViewRef.current._leaflet_id) + return; + + const map = L.map(containerRef.current, { + zoomControl: true, + attributionControl: true + }).setView([37.5665, 126.9780], 12); + + L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { + maxZoom: 19, + attribution: '© OpenStreetMap contributors' + }).addTo(map); + + if (mapViewRef) + mapViewRef.current = map; + + return function () { + try { + if (mapViewRef && mapViewRef.current === map) + mapViewRef.current = null; + + map.remove(); + } catch (e) {} + }; + }, []); + + // handle show/hide toggles + React.useEffect(() => { + // when becoming visible, leaflet needs a resize recalculation + const map = mapViewRef ? mapViewRef.current : null; + if (!map || !map.invalidateSize) + return; + + // toggle the display style attribute + containerRef.current.style.display = (visible ? "block" : "none"); + + // defer until after layout/display change + if (visible) { + setTimeout(function () { + try { + map.invalidateSize(); + + navigator.geolocation.getCurrentPosition(pos => { + mark(pos.coords.latitude, pos.coords.longitude, `My Location: (${pos.coords.latitude}, ${pos.coords.longitude})`); + }); + } catch (e) {} + }, 0); + } + }, [visible]); + + return _e('div', { id: 'mapView', ref: containerRef }); + } function App() { const editorRef = React.useRef(null); @@ -288,6 +389,8 @@ const settingsRef = React.useRef({}); const fileNameRef = React.useRef('sayhello.js'); const promptMessagesRef = React.useRef([]); + const mapViewRef = React.useRef(null); + const [showMap, setShowMap] = React.useState(false); const fetchSettings = () => axios.get(`/settings`) .then(response => { @@ -472,23 +575,23 @@ } }; - const sendMessageToAzureAi = () => { + const sendMessageToAzureCognitive = () => { const promptMessage = prompt("Enter a prompt message:", ''); if (!promptMessage || promptMessage.trim() == '') { alert("A prompt message is required."); return; } - appendTextToEditor(`\n// ${promptMessage}... Generating text with Azure AI...`); + appendTextToEditor(`\n// ${promptMessage}... Generating text with Azure Cognitive...`); pushPromptMessage("user", promptMessage); - const apiKey = settingsRef.current.AzureAiServiceApiKey; + const apiKey = settingsRef.current.AzureCognitiveApiKey; if (!apiKey || apiKey.trim() == '') { - alert("Azure AI API key is not set."); + alert("Azure Cognitive API key is not set."); return; } - const url = `${settingsRef.current.AzureAiServicePrefix}models/chat/completions?api-version=${settingsRef.current.AzureAiServiceApiVersion}`; + const url = `${settingsRef.current.AzureCognitivePrefix}models/chat/completions?api-version=${settingsRef.current.AzureCognitiveApiVersion}`; const data = { messages: promptMessagesRef.current, @@ -647,6 +750,10 @@ appendTextToEditor(`\n// Failed to query the IP: ${error.message}`); }); }; + + function toggleMap() { + setShowMap(v => !v); + } React.useEffect(() => { window.addEventListener('resize', () => { @@ -662,15 +769,17 @@ onOpenFileClick: openFile, onSaveFileClick: saveFile, onCopliotClick: sendMessageToCopilot, - onAzureAiClick: sendMessageToAzureAi, + onAzureCognitiveClick: sendMessageToAzureCognitive, onSavePromptClick: savePromptMessages, onLoadPromptClick: loadPromptMessages, onQueryWhoisClick: queryWhois, onQueryDnsClick: queryDns, - onQueryIpClick: queryIp + onQueryIpClick: queryIp, + onMapClick: toggleMap }), _e('div', { id: 'container' }, - _e(Editor, { editorRef }), + _e(Editor, { editorRef: editorRef, visible: !showMap }), + _e(MapView, { mapViewRef: mapViewRef, visible: showMap }), _e(PromptEditor, { promptEditorRef, promptMessagesRef }) ), _e('div', { className: 'banner' }, _e('a', { href: 'https://github.com/gnh1201/welsonjs' }, '❤️ Contribute this project')), diff --git a/app.js b/app.js index 57f88eb..c0b96aa 100644 --- a/app.js +++ b/app.js @@ -36,12 +36,25 @@ var console = { } return res; }, - _echoDefault: function(message) { + _muted: (function() { + try { + if (typeof WScript !== "undefined") + return WScript.Arguments.Named.Exists("quiet"); + } catch (e) { /* ignore */ } + + return false; + })(), + _echoCallback: function(params, type) { + if (this._muted) return; + if (typeof WScript !== "undefined") { - WScript.Echo("[*] " + message) + if (this._muted) { + WScript.StdErr.WriteLine("[*] " + params.message); + return; + } + WScript.StdOut.WriteLine("[*] " + params.message); } }, - _echoCallback: null, _echo: function(args, type) { var messages = []; var params = { @@ -80,19 +93,15 @@ var console = { } } - var message = messages.join(' '); + params.message = messages.join(' '); if (typeof type !== "undefined") { - message = type + ": " + message; + params.message = type + ": " + params.message; } - this._echoDefault(message); - this._messages.push(message); - - if (params.scope.length > 0 && this._echoCallback != null) { - try { - this._echoCallback(params, type); - } catch (e) { - this._echoDefault("Exception:" + e.message); - } + this._echoCallback(params); + this._messages.push(params.message); + + if (params.scope.length > 0) { + this._echoCallback(params, type); } }, assert: function(assertion) { @@ -238,7 +247,7 @@ function TraceError(severity, message, callee) { })([ function (s) { fn.call(console, s); }, // 1) severity-specific console function (s) { console.log(s); }, // 2) generic console.log - function (s) { WScript.Echo(s); } // 3) WSH fallback + function (s) { WScript.StdOut.WriteLine(s); } // 3) WSH fallback ]); } @@ -404,7 +413,7 @@ function require(pathname) { if (pos > -1) { var scheme = FN.substring(0, pos); - // load script from a remote server + // request a script from a remote server if (["http", "https"].indexOf(scheme) > -1) { require._addScriptProvider(function(url) { try { @@ -415,7 +424,7 @@ function require(pathname) { }); } - // load script from LIE(Language Inference Engine) service + // request a script from LLM based AI services if (["ai"].indexOf(scheme) > -1) { require._addScriptProvider(function(url) { try { @@ -472,7 +481,7 @@ function require(pathname) { })({ existsSync: function(filename) { return UseObject("Scripting.FileSystemObject", function(fso) { - return fso.FileExists(filename); + return fso.FileExists(require._getCurrentScriptDirectory() + "\\" + filename); }); } }, { @@ -715,22 +724,20 @@ require._addScriptProvider = function(f) { } }; -///////////////////////////////////////////////////////////////////////////////// // Load script, and call app.main() -///////////////////////////////////////////////////////////////////////////////// - function initializeConsole() { if (typeof WScript === "undefined") { console.error("This is not a console application"); return; } - - var argl = WScript.arguments.length; - if (argl > 0) { - var args = []; - for (var i = 0; i < argl; i++) { - args.push(WScript.arguments(i)); - } + + var args = (function(acc, length) { + for (var i = 0; i < length; i++) + acc.push(WScript.arguments(i)); + return acc; + })([], WScript.arguments.length); + + if (args.length > 0) { var name = args.shift(); var app = require(name); if (app) { @@ -779,14 +786,12 @@ function initializeWindow(name, args, w, h) { function dispatchServiceEvent(name, eventType, w_args, argl) { var app = require(name); - var args = []; + var args = (function(acc, length) { + for (var i = 0; i < argl; i++) + acc.push(w_args(i)); + return acc; + })([], argl); - // convert the arguments to Array - for (var i = 0; i < argl; i++) { - args.push(w_args(i)); - } - - // load the service if (app) { var bind = function(eventType) { var event_callback_name = "on" + eventType; @@ -846,8 +851,8 @@ if (typeof JSON === "undefined") { __evalFile__("app/assets/js/json2.js"); } -// core-js (formerly, babel-polyfill) -require("app/assets/js/core-js-3.38.0.minified"); +// core-js (polyfills) +require("app/assets/js/core-js-3.49.0.wsh"); // Squel.js SQL query string builder for Javascript var squel = require("app/assets/js/squel-basic-5.13.0-afa1cb5.wsh"); diff --git a/app/assets/js/core-js-3.26.1.minified.js b/app/assets/js/core-js-3.26.1.minified.js deleted file mode 100644 index 565a39e..0000000 --- a/app/assets/js/core-js-3.26.1.minified.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * core-js 3.26.1 - * © 2014-2022 Denis Pushkarev (zloirock.ru) - * license: https://github.com/zloirock/core-js/blob/v3.26.1/LICENSE - * source: https://github.com/zloirock/core-js - */ -!function(t){"use strict";var r,e,n;r=[function(t,r,e){e(1),e(98),e(99),e(100),e(101),e(102),e(103),e(104),e(105),e(106),e(107),e(108),e(109),e(110),e(111),e(112),e(122),e(124),e(134),e(135),e(137),e(140),e(143),e(145),e(147),e(148),e(149),e(150),e(152),e(153),e(155),e(156),e(158),e(162),e(163),e(164),e(165),e(170),e(171),e(173),e(174),e(175),e(177),e(180),e(181),e(182),e(183),e(184),e(189),e(191),e(192),e(193),e(194),e(195),e(202),e(204),e(207),e(209),e(210),e(211),e(212),e(213),e(217),e(218),e(220),e(221),e(222),e(224),e(225),e(226),e(94),e(227),e(228),e(236),e(238),e(239),e(240),e(242),e(243),e(245),e(246),e(248),e(249),e(250),e(252),e(253),e(254),e(255),e(256),e(257),e(258),e(259),e(263),e(264),e(266),e(268),e(269),e(270),e(271),e(272),e(274),e(276),e(277),e(278),e(279),e(281),e(282),e(284),e(285),e(286),e(287),e(289),e(290),e(291),e(292),e(293),e(294),e(295),e(296),e(298),e(299),e(300),e(301),e(302),e(303),e(304),e(305),e(307),e(308),e(309),e(311),e(312),e(313),e(314),e(337),e(338),e(339),e(340),e(341),e(342),e(343),e(344),e(346),e(347),e(348),e(349),e(350),e(351),e(352),e(353),e(354),e(355),e(362),e(363),e(365),e(366),e(367),e(368),e(369),e(371),e(372),e(374),e(377),e(378),e(379),e(380),e(384),e(385),e(387),e(388),e(389),e(390),e(392),e(393),e(394),e(395),e(396),e(397),e(399),e(402),e(405),e(408),e(409),e(410),e(411),e(412),e(413),e(414),e(415),e(416),e(417),e(418),e(419),e(420),e(428),e(429),e(430),e(431),e(432),e(433),e(434),e(435),e(436),e(437),e(438),e(439),e(440),e(444),e(445),e(446),e(447),e(448),e(449),e(450),e(451),e(452),e(453),e(454),e(455),e(456),e(457),e(458),e(459),e(460),e(461),e(462),e(463),e(464),e(465),e(466),e(467),e(468),e(471),e(473),e(482),e(483),e(484),e(486),e(487),e(489),e(490),e(491),e(492),e(493),e(495),e(496),e(497),e(499),e(501),e(502),e(505),e(507),e(508),e(509),e(510),e(512),e(513),e(515),e(516),e(517),e(518),e(519),e(520),e(521),e(523),e(525),e(526),e(527),e(528),e(529),e(530),e(533),e(534),e(535),e(536),e(537),e(539),e(540),e(541),e(542),e(543),e(544),e(545),e(546),e(547),e(548),e(550),e(552),e(554),e(555),e(556),e(557),e(559),e(560),e(562),e(563),e(564),e(565),e(566),e(567),e(569),e(570),e(571),e(572),e(574),e(575),e(576),e(577),e(578),e(580),e(581),e(582),e(583),e(584),e(585),e(586),e(587),e(588),e(589),e(590),e(591),e(593),e(594),e(595),e(600),e(601),e(603),e(604),e(605),e(606),e(607),e(608),e(609),e(610),e(611),e(613),e(614),e(615),e(617),e(618),e(619),e(620),e(621),e(622),e(623),e(624),e(625),e(626),e(627),e(628),e(629),e(630),e(631),e(632),e(633),e(634),e(635),e(636),e(637),e(638),e(639),e(640),e(641),e(642),e(643),e(644),e(645),e(646),e(647),e(648),e(649),e(650),e(651),e(652),e(653),e(654),e(655),e(656),e(657),e(658),e(659),e(660),e(661),e(662),e(664),e(665),e(668),e(669),e(672),e(673),e(674),e(677),e(678),e(679),e(680),e(684),e(689),t.exports=e(690)},function(t,r,e){e(2),e(91),e(93),e(94),e(97)},function(r,e,n){var o=n(3),i=n(4),a=n(8),u=n(14),c=n(36),f=n(6),s=n(27),l=n(7),h=n(39),p=n(25),g=n(47),v=n(12),d=n(18),y=n(69),m=n(11),b=n(72),x=n(74),w=n(58),E=n(76),S=n(67),A=n(5),I=n(45),R=n(73),O=n(10),T=n(48),M=n(35),P=n(54),j=n(55),k=n(41),_=n(34),N=n(79),C=n(80),D=n(82),U=n(83),L=n(52),B=n(84).forEach,W=P("hidden"),z="Symbol",V=L.set,H=L.getterFor(z),q=Object.prototype,G=i.Symbol,K=G&&G.prototype,Y=i.TypeError,$=i.QObject,J=A.f,X=I.f,Q=E.f,Z=O.f,tt=u([].push),rt=M("symbols"),et=M("op-symbols"),nt=M("wks"),ot=!$||!$.prototype||!$.prototype.findChild,it=f&&l((function(){return 7!=b(X({},"a",{get:function(){return X(this,"a",{value:7}).a}})).a}))?function(t,r,e){var n=J(q,r);n&&delete q[r],X(t,r,e),n&&t!==q&&X(q,r,n)}:X,wrap=function(t,r){var e=rt[t]=b(K);return V(e,{type:z,tag:t,description:r}),f||(e.description=r),e},ut=function defineProperty(t,r,e){t===q&&ut(et,r,e),g(t);var n=d(r);return g(e),h(rt,n)?(e.enumerable?(h(t,W)&&t[W][n]&&(t[W][n]=!1),e=b(e,{enumerable:m(0,!1)})):(h(t,W)||X(t,W,m(1,{})),t[W][n]=!0),it(t,n,e)):X(t,n,e)},ct=function defineProperties(t,r){var e,n;return g(t),e=v(r),n=x(e).concat($getOwnPropertySymbols(e)),B(n,(function(r){f&&!a(ft,e,r)||ut(t,r,e[r])})),t},ft=function propertyIsEnumerable(t){var r=d(t),e=a(Z,this,r);return!(this===q&&h(rt,r)&&!h(et,r))&&(!(e||!h(this,r)||!h(rt,r)||h(this,W)&&this[W][r])||e)},st=function getOwnPropertyDescriptor(t,r){var e,n=v(t),o=d(r);if(n!==q||!h(rt,o)||h(et,o))return!(e=J(n,o))||!h(rt,o)||h(n,W)&&n[W][o]||(e.enumerable=!0),e},lt=function getOwnPropertyNames(t){var r=Q(v(t)),e=[];return B(r,(function(t){h(rt,t)||h(j,t)||tt(e,t)})),e},$getOwnPropertySymbols=function(t){var r=t===q,e=Q(r?et:v(t)),n=[];return B(e,(function(t){!h(rt,t)||r&&!h(q,t)||tt(n,rt[t])})),n};s||(G=function Symbol(){var r,e,n;if(p(K,this))throw Y("Symbol is not a constructor");return r=arguments.length&&arguments[0]!==t?y(arguments[0]):t,e=k(r),n=function(t){this===q&&a(n,et,t),h(this,W)&&h(this[W],e)&&(this[W][e]=!1),it(this,e,m(1,t))},f&&ot&&it(q,e,{configurable:!0,set:n}),wrap(e,r)},T(K=G.prototype,"toString",(function toString(){return H(this).tag})),T(G,"withoutSetter",(function(t){return wrap(k(t),t)})),O.f=ft,I.f=ut,R.f=ct,A.f=st,w.f=E.f=lt,S.f=$getOwnPropertySymbols,N.f=function(t){return wrap(_(t),t)},f&&(X(K,"description",{configurable:!0,get:function description(){return H(this).description}}),c||T(q,"propertyIsEnumerable",ft,{unsafe:!0}))),o({global:!0,constructor:!0,wrap:!0,forced:!s,sham:!s},{Symbol:G}),B(x(nt),(function(t){C(t)})),o({target:z,stat:!0,forced:!s},{useSetter:function(){ot=!0},useSimple:function(){ot=!1}}),o({target:"Object",stat:!0,forced:!s,sham:!f},{create:function create(r,e){return e===t?b(r):ct(b(r),e)},defineProperty:ut,defineProperties:ct,getOwnPropertyDescriptor:st}),o({target:"Object",stat:!0,forced:!s},{getOwnPropertyNames:lt}),D(),U(G,z),j[W]=!0},function(r,e,n){var o=n(4),i=n(5).f,a=n(44),u=n(48),c=n(38),f=n(56),s=n(68);r.exports=function(r,e){var n,l,h,p,g,v=r.target,d=r.global,y=r.stat;if(n=d?o:y?o[v]||c(v,{}):(o[v]||{}).prototype)for(l in e){if(p=e[l],h=r.dontCallGetSet?(g=i(n,l))&&g.value:n[l],!s(d?l:v+(y?".":"#")+l,r.forced)&&h!==t){if(typeof p==typeof h)continue;f(p,h)}(r.sham||h&&h.sham)&&a(p,"sham",!0),u(n,l,p,r)}}},function(t,r){var check=function(t){return t&&t.Math==Math&&t};t.exports=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof global&&global)||function(){return this}()||Function("return this")()},function(t,r,e){var n=e(6),o=e(8),i=e(10),a=e(11),u=e(12),c=e(18),f=e(39),s=e(42),l=Object.getOwnPropertyDescriptor;r.f=n?l:function getOwnPropertyDescriptor(t,r){if(t=u(t),r=c(r),s)try{return l(t,r)}catch(e){}if(f(t,r))return a(!o(i.f,t,r),t[r])}},function(t,r,e){var n=e(7);t.exports=!n((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},function(t,r){t.exports=function(t){try{return!!t()}catch(r){return!0}}},function(t,r,e){var n=e(9),o=function(){}.call;t.exports=n?o.bind(o):function(){return o.apply(o,arguments)}},function(t,r,e){var n=e(7);t.exports=!n((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}))},function(t,r,e){var n={}.propertyIsEnumerable,o=Object.getOwnPropertyDescriptor,i=o&&!n.call({1:2},1);r.f=i?function propertyIsEnumerable(t){var r=o(this,t);return!!r&&r.enumerable}:n},function(t,r){t.exports=function(t,r){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:r}}},function(t,r,e){var n=e(13),o=e(16);t.exports=function(t){return n(o(t))}},function(t,r,e){var n=e(14),o=e(7),i=e(15),a=Object,u=n("".split);t.exports=o((function(){return!a("z").propertyIsEnumerable(0)}))?function(t){return"String"==i(t)?u(t,""):a(t)}:a},function(t,r,e){var n=e(9),o=Function.prototype,i=o.call,a=n&&o.bind.bind(i,i);t.exports=n?a:function(t){return function(){return i.apply(t,arguments)}}},function(t,r,e){var n=e(14),o=n({}.toString),i=n("".slice);t.exports=function(t){return i(o(t),8,-1)}},function(t,r,e){var n=e(17),o=TypeError;t.exports=function(t){if(n(t))throw o("Can't call method on "+t);return t}},function(r,e){r.exports=function(r){return null===r||r===t}},function(t,r,e){var n=e(19),o=e(23);t.exports=function(t){var r=n(t,"string");return o(r)?r:r+""}},function(r,e,n){var o=n(8),i=n(20),a=n(23),u=n(30),c=n(33),f=n(34),s=TypeError,l=f("toPrimitive");r.exports=function(r,e){var n,f;if(!i(r)||a(r))return r;if(n=u(r,l)){if(e===t&&(e="default"),f=o(n,r,e),!i(f)||a(f))return f;throw s("Can't convert object to primitive value")}return e===t&&(e="number"),c(r,e)}},function(t,r,e){var n=e(21),o=e(22),i=o.all;t.exports=o.IS_HTMLDDA?function(t){return"object"==typeof t?null!==t:n(t)||t===i}:function(t){return"object"==typeof t?null!==t:n(t)}},function(t,r,e){var n=e(22),o=n.all;t.exports=n.IS_HTMLDDA?function(t){return"function"==typeof t||t===o}:function(t){return"function"==typeof t}},function(r,e){var n="object"==typeof document&&document.all;r.exports={all:n,IS_HTMLDDA:t===n&&n!==t}},function(t,r,e){var n=e(24),o=e(21),i=e(25),a=e(26),u=Object;t.exports=a?function(t){return"symbol"==typeof t}:function(t){var r=n("Symbol");return o(r)&&i(r.prototype,u(t))}},function(r,e,n){var o=n(4),i=n(21),aFunction=function(r){return i(r)?r:t};r.exports=function(t,r){return arguments.length<2?aFunction(o[t]):o[t]&&o[t][r]}},function(t,r,e){var n=e(14);t.exports=n({}.isPrototypeOf)},function(t,r,e){var n=e(27);t.exports=n&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},function(t,r,e){var n=e(28),o=e(7);t.exports=!!Object.getOwnPropertySymbols&&!o((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&n&&n<41}))},function(t,r,e){var n,o,i=e(4),a=e(29),u=i.process,c=i.Deno,f=u&&u.versions||c&&c.version,s=f&&f.v8;s&&(o=(n=s.split("."))[0]>0&&n[0]<4?1:+(n[0]+n[1])),!o&&a&&(!(n=a.match(/Edge\/(\d+)/))||n[1]>=74)&&(n=a.match(/Chrome\/(\d+)/))&&(o=+n[1]),t.exports=o},function(t,r,e){var n=e(24);t.exports=n("navigator","userAgent")||""},function(r,e,n){var o=n(31),i=n(17);r.exports=function(r,e){var n=r[e];return i(n)?t:o(n)}},function(t,r,e){var n=e(21),o=e(32),i=TypeError;t.exports=function(t){if(n(t))return t;throw i(o(t)+" is not a function")}},function(t,r){var e=String;t.exports=function(t){try{return e(t)}catch(r){return"Object"}}},function(t,r,e){var n=e(8),o=e(21),i=e(20),a=TypeError;t.exports=function(t,r){var e,u;if("string"===r&&o(e=t.toString)&&!i(u=n(e,t)))return u;if(o(e=t.valueOf)&&!i(u=n(e,t)))return u;if("string"!==r&&o(e=t.toString)&&!i(u=n(e,t)))return u;throw a("Can't convert object to primitive value")}},function(t,r,e){var n=e(4),o=e(35),i=e(39),a=e(41),u=e(27),c=e(26),f=o("wks"),s=n.Symbol,l=s&&s["for"],h=c?s:s&&s.withoutSetter||a;t.exports=function(t){if(!i(f,t)||!u&&"string"!=typeof f[t]){var r="Symbol."+t;f[t]=u&&i(s,t)?s[t]:c&&l?l(r):h(r)}return f[t]}},function(r,e,n){var o=n(36),i=n(37);(r.exports=function(r,e){return i[r]||(i[r]=e!==t?e:{})})("versions",[]).push({version:"3.26.1",mode:o?"pure":"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.26.1/LICENSE",source:"https://github.com/zloirock/core-js"})},function(t,r){t.exports=!1},function(t,r,e){var n=e(4),o=e(38),i="__core-js_shared__",a=n[i]||o(i,{});t.exports=a},function(t,r,e){var n=e(4),o=Object.defineProperty;t.exports=function(t,r){try{o(n,t,{value:r,configurable:!0,writable:!0})}catch(e){n[t]=r}return r}},function(t,r,e){var n=e(14),o=e(40),i=n({}.hasOwnProperty);t.exports=Object.hasOwn||function hasOwn(t,r){return i(o(t),r)}},function(t,r,e){var n=e(16),o=Object;t.exports=function(t){return o(n(t))}},function(r,e,n){var o=n(14),i=0,a=Math.random(),u=o(1..toString);r.exports=function(r){return"Symbol("+(r===t?"":r)+")_"+u(++i+a,36)}},function(t,r,e){var n=e(6),o=e(7),i=e(43);t.exports=!n&&!o((function(){return 7!=Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a}))},function(t,r,e){var n=e(4),o=e(20),i=n.document,a=o(i)&&o(i.createElement);t.exports=function(t){return a?i.createElement(t):{}}},function(t,r,e){var n=e(6),o=e(45),i=e(11);t.exports=n?function(t,r,e){return o.f(t,r,i(1,e))}:function(t,r,e){return t[r]=e,t}},function(t,r,e){var n=e(6),o=e(42),i=e(46),a=e(47),u=e(18),c=TypeError,f=Object.defineProperty,s=Object.getOwnPropertyDescriptor;r.f=n?i?function defineProperty(t,r,e){if(a(t),r=u(r),a(e),"function"==typeof t&&"prototype"===r&&"value"in e&&"writable"in e&&!e.writable){var n=s(t,r);n&&n.writable&&(t[r]=e.value,e={configurable:"configurable"in e?e.configurable:n.configurable,enumerable:"enumerable"in e?e.enumerable:n.enumerable,writable:!1})}return f(t,r,e)}:f:function defineProperty(t,r,e){if(a(t),r=u(r),a(e),o)try{return f(t,r,e)}catch(n){}if("get"in e||"set"in e)throw c("Accessors not supported");return"value"in e&&(t[r]=e.value),t}},function(t,r,e){var n=e(6),o=e(7);t.exports=n&&o((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))},function(t,r,e){var n=e(20),o=String,i=TypeError;t.exports=function(t){if(n(t))return t;throw i(o(t)+" is not an object")}},function(r,e,n){var o=n(21),i=n(45),a=n(49),u=n(38);r.exports=function(r,e,n,c){var f,s;if(c||(c={}),f=c.enumerable,s=c.name!==t?c.name:e,o(n)&&a(n,s,c),c.global)f?r[e]=n:u(e,n);else{try{c.unsafe?r[e]&&(f=!0):delete r[e]}catch(l){}f?r[e]=n:i.f(r,e,{value:n,enumerable:!1,configurable:!c.nonConfigurable,writable:!c.nonWritable})}return r}},function(r,e,n){var o=n(7),i=n(21),a=n(39),u=n(6),c=n(50).CONFIGURABLE,f=n(51),s=n(52),l=s.enforce,h=s.get,p=Object.defineProperty,g=u&&!o((function(){return 8!==p((function(){}),"length",{value:8}).length})),v=String(String).split("String"),d=r.exports=function(r,e,n){"Symbol("===String(e).slice(0,7)&&(e="["+String(e).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),n&&n.getter&&(e="get "+e),n&&n.setter&&(e="set "+e),(!a(r,"name")||c&&r.name!==e)&&(u?p(r,"name",{value:e,configurable:!0}):r.name=e),g&&n&&a(n,"arity")&&r.length!==n.arity&&p(r,"length",{value:n.arity});try{n&&a(n,"constructor")&&n.constructor?u&&p(r,"prototype",{writable:!1}):r.prototype&&(r.prototype=t)}catch(i){}var o=l(r);return a(o,"source")||(o.source=v.join("string"==typeof e?e:"")),r};Function.prototype.toString=d((function toString(){return i(this)&&h(this).source||f(this)}),"toString")},function(t,r,e){var n=e(6),o=e(39),i=Function.prototype,a=n&&Object.getOwnPropertyDescriptor,u=o(i,"name"),c=u&&"something"===function something(){}.name,f=u&&(!n||n&&a(i,"name").configurable);t.exports={EXISTS:u,PROPER:c,CONFIGURABLE:f}},function(t,r,e){var n=e(14),o=e(21),i=e(37),a=n(Function.toString);o(i.inspectSource)||(i.inspectSource=function(t){return a(t)}),t.exports=i.inspectSource},function(t,r,e){var n,o,i,a,u,c=e(53),f=e(4),s=e(20),l=e(44),h=e(39),p=e(37),g=e(54),v=e(55),d="Object already initialized",y=f.TypeError;c||p.state?((a=p.state||(p.state=new(0,f.WeakMap))).get=a.get,a.has=a.has,a.set=a.set,n=function(t,r){if(a.has(t))throw y(d);return r.facade=t,a.set(t,r),r},o=function(t){return a.get(t)||{}},i=function(t){return a.has(t)}):(v[u=g("state")]=!0,n=function(t,r){if(h(t,u))throw y(d);return r.facade=t,l(t,u,r),r},o=function(t){return h(t,u)?t[u]:{}},i=function(t){return h(t,u)}),t.exports={set:n,get:o,has:i,enforce:function(t){return i(t)?o(t):n(t,{})},getterFor:function(t){return function(r){var e;if(!s(r)||(e=o(r)).type!==t)throw y("Incompatible receiver, "+t+" required");return e}}}},function(t,r,e){var n=e(4),o=e(21),i=n.WeakMap;t.exports=o(i)&&/native code/.test(String(i))},function(t,r,e){var n=e(35),o=e(41),i=n("keys");t.exports=function(t){return i[t]||(i[t]=o(t))}},function(t,r){t.exports={}},function(t,r,e){var n=e(39),o=e(57),i=e(5),a=e(45);t.exports=function(t,r,e){var u,c,f=o(r),s=a.f,l=i.f;for(u=0;uf;)o(n,e=r[f++])&&(~a(s,e)||c(s,e));return s}},function(t,r,e){var n=e(12),o=e(61),i=e(64),createMethod=function(t){return function(r,e,a){var u,c=n(r),f=i(c),s=o(a,f);if(t&&e!=e){for(;f>s;)if((u=c[s++])!=u)return!0}else for(;f>s;s++)if((t||s in c)&&c[s]===e)return t||s||0;return!t&&-1}};t.exports={includes:createMethod(!0),indexOf:createMethod(!1)}},function(t,r,e){var n=e(62),o=Math.max,i=Math.min;t.exports=function(t,r){var e=n(t);return e<0?o(e+r,0):i(e,r)}},function(t,r,e){var n=e(63);t.exports=function(t){var r=+t;return r!=r||0===r?0:n(r)}},function(t,r){var e=Math.ceil,n=Math.floor;t.exports=Math.trunc||function trunc(t){var r=+t;return(r>0?n:e)(r)}},function(t,r,e){var n=e(65);t.exports=function(t){return n(t.length)}},function(t,r,e){var n=e(62),o=Math.min;t.exports=function(t){return t>0?o(n(t),9007199254740991):0}},function(t,r){t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},function(t,r){r.f=Object.getOwnPropertySymbols},function(t,r,e){var n=e(7),o=e(21),i=/#|\.prototype\./,isForced=function(t,r){var e=u[a(t)];return e==f||e!=c&&(o(r)?n(r):!!r)},a=isForced.normalize=function(t){return String(t).replace(i,".").toLowerCase()},u=isForced.data={},c=isForced.NATIVE="N",f=isForced.POLYFILL="P";t.exports=isForced},function(t,r,e){var n=e(70),o=String;t.exports=function(t){if("Symbol"===n(t))throw TypeError("Cannot convert a Symbol value to a string");return o(t)}},function(r,e,n){var o=n(71),i=n(21),a=n(15),u=n(34)("toStringTag"),c=Object,f="Arguments"==a(function(){return arguments}());r.exports=o?a:function(r){var e,n,o;return r===t?"Undefined":null===r?"Null":"string"==typeof(n=function(t,r){try{return t[r]}catch(e){}}(e=c(r),u))?n:f?a(e):"Object"==(o=a(e))&&i(e.callee)?"Arguments":o}},function(t,r,e){var n={};n[e(34)("toStringTag")]="z",t.exports="[object z]"===String(n)},function(r,e,n){var o,i=n(47),a=n(73),u=n(66),c=n(55),f=n(75),s=n(43),l=n(54)("IE_PROTO"),EmptyConstructor=function(){},scriptTag=function(t){return"