@arcgis/coding-components 4.29.0-beta.47 → 4.29.0-beta.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/dist/arcgis-coding-components/arcgis-coding-components.esm.js +1 -1
  2. package/dist/arcgis-coding-components/assets/code-editor/arcade.worker.js +13 -13
  3. package/dist/arcgis-coding-components/index.esm.js +1 -1
  4. package/dist/arcgis-coding-components/{p-10a322ec.js → p-0d616249.js} +9 -9
  5. package/dist/arcgis-coding-components/p-2c0d6f15.js +2 -0
  6. package/dist/arcgis-coding-components/{p-71faf9a4.js → p-5802524a.js} +1 -1
  7. package/dist/arcgis-coding-components/{p-9eabda86.js → p-5ddccf04.js} +1 -1
  8. package/dist/arcgis-coding-components/p-7475f3a6.js +1 -0
  9. package/dist/arcgis-coding-components/{p-e6ede32d.js → p-7d8caba9.js} +1 -1
  10. package/dist/arcgis-coding-components/{p-f7d7d78d.js → p-9f6db08a.js} +1 -1
  11. package/dist/arcgis-coding-components/{p-e475e6cd.js → p-aefe77ce.js} +1 -1
  12. package/dist/arcgis-coding-components/p-ce2be55e.entry.js +1 -0
  13. package/dist/arcgis-coding-components/{p-ce586a8c.js → p-d425a387.js} +1 -1
  14. package/dist/arcgis-coding-components/{p-c084ada8.js → p-ff21f230.js} +1 -1
  15. package/dist/cjs/{arcade-defaults-8445d852.js → arcade-defaults-2d513b59.js} +1534 -1534
  16. package/dist/cjs/arcade-mode-6219f1b8.js +599 -0
  17. package/dist/cjs/arcgis-arcade-api_6.cjs.entry.js +1404 -1408
  18. package/dist/cjs/arcgis-coding-components.cjs.js +2 -2
  19. package/dist/cjs/{cssMode-e63287bb.js → cssMode-1ec48254.js} +2 -2
  20. package/dist/cjs/{html-c0d4db3b.js → html-0e1741fe.js} +2 -2
  21. package/dist/cjs/{htmlMode-fdc44d57.js → htmlMode-279d3c29.js} +2 -2
  22. package/dist/cjs/{index-6a382a34.js → index-ac186201.js} +67 -24
  23. package/dist/cjs/index.cjs.js +2 -2
  24. package/dist/cjs/{javascript-a419d064.js → javascript-04f1bce0.js} +3 -3
  25. package/dist/cjs/{jsonMode-73aee5d2.js → jsonMode-59322f7a.js} +2 -2
  26. package/dist/cjs/loader.cjs.js +1 -1
  27. package/dist/cjs/{tsMode-37d1b053.js → tsMode-17561f70.js} +2 -2
  28. package/dist/cjs/{typescript-53f9f36a.js → typescript-b7da8629.js} +2 -2
  29. package/dist/components/arcade-api.js +160 -160
  30. package/dist/components/arcade-contribution.js +60 -60
  31. package/dist/components/arcade-defaults.js +1240 -1240
  32. package/dist/components/arcade-mode.js +514 -513
  33. package/dist/components/arcade-results.js +426 -430
  34. package/dist/components/arcade-suggestions.js +130 -132
  35. package/dist/components/arcade-variables.js +157 -155
  36. package/dist/components/arcgis-arcade-api.d.ts +2 -2
  37. package/dist/components/arcgis-arcade-editor.d.ts +2 -2
  38. package/dist/components/arcgis-arcade-editor.js +391 -391
  39. package/dist/components/arcgis-arcade-results.d.ts +2 -2
  40. package/dist/components/arcgis-arcade-suggestions.d.ts +2 -2
  41. package/dist/components/arcgis-arcade-variables.d.ts +2 -2
  42. package/dist/components/arcgis-code-editor.d.ts +2 -2
  43. package/dist/components/code-editor.js +251 -251
  44. package/dist/components/fields.js +69 -69
  45. package/dist/components/functional-components.js +1 -1
  46. package/dist/components/index2.js +2 -2
  47. package/dist/components/markdown.js +28 -28
  48. package/dist/components/utilities.js +20 -20
  49. package/dist/esm/{arcade-defaults-d7893362.js → arcade-defaults-0bafa696.js} +1534 -1534
  50. package/dist/esm/arcade-mode-c17a1fa1.js +595 -0
  51. package/dist/esm/arcgis-arcade-api_6.entry.js +1404 -1408
  52. package/dist/esm/arcgis-coding-components.js +3 -3
  53. package/dist/esm/{cssMode-b1771f92.js → cssMode-3d18bd2b.js} +2 -2
  54. package/dist/esm/{html-af635d52.js → html-2bce5d77.js} +2 -2
  55. package/dist/esm/{htmlMode-3021c301.js → htmlMode-69d56956.js} +2 -2
  56. package/dist/esm/{index-fd6b2fd8.js → index-022fb97b.js} +67 -24
  57. package/dist/esm/index.js +2 -2
  58. package/dist/esm/{javascript-70589186.js → javascript-ded5c9d7.js} +3 -3
  59. package/dist/esm/{jsonMode-cb509b79.js → jsonMode-0bf84cb2.js} +2 -2
  60. package/dist/esm/loader.js +2 -2
  61. package/dist/esm/{tsMode-ed90c9aa.js → tsMode-15d4e936.js} +2 -2
  62. package/dist/esm/{typescript-db8a0b18.js → typescript-cc4d00f0.js} +2 -2
  63. package/dist/types/components/arcade-api/arcade-api.d.ts +40 -40
  64. package/dist/types/components/arcade-api/t9n-types.d.ts +6 -6
  65. package/dist/types/components/arcade-editor/arcade-editor.d.ts +127 -127
  66. package/dist/types/components/arcade-editor/t9n-types.d.ts +6 -6
  67. package/dist/types/components/arcade-results/arcade-results.d.ts +47 -47
  68. package/dist/types/components/arcade-results/t9n-types.d.ts +11 -11
  69. package/dist/types/components/arcade-suggestions/arcade-suggestions.d.ts +34 -34
  70. package/dist/types/components/arcade-suggestions/t9n-types.d.ts +4 -4
  71. package/dist/types/components/arcade-variables/arcade-variables.d.ts +41 -41
  72. package/dist/types/components/arcade-variables/t9n-types.d.ts +6 -6
  73. package/dist/types/components/code-editor/code-editor.d.ts +73 -73
  74. package/dist/types/stencil-public-runtime.d.ts +8 -0
  75. package/dist/types/utils/arcade-executor.d.ts +79 -79
  76. package/dist/types/utils/arcade-monaco/arcade-defaults.d.ts +66 -66
  77. package/dist/types/utils/arcade-monaco/arcade-language-features.d.ts +23 -23
  78. package/dist/types/utils/arcade-monaco/arcade-mode.d.ts +9 -9
  79. package/dist/types/utils/arcade-monaco/arcade-theme.d.ts +7 -7
  80. package/dist/types/utils/arcade-monaco/arcade-worker-manager.d.ts +9 -9
  81. package/dist/types/utils/arcade-monaco/arcade.worker.d.ts +12 -12
  82. package/dist/types/utils/arcade-monaco/types.d.ts +29 -29
  83. package/dist/types/utils/editor-suggestions.d.ts +24 -24
  84. package/dist/types/utils/functional-components.d.ts +1 -1
  85. package/dist/types/utils/markdown.d.ts +1 -1
  86. package/dist/types/utils/profile/editor-profile.d.ts +185 -185
  87. package/dist/types/utils/profile/types.d.ts +101 -101
  88. package/dist/types/utils/utilities.d.ts +1 -1
  89. package/package.json +7 -7
  90. package/dist/arcgis-coding-components/p-5d670bd2.js +0 -2
  91. package/dist/arcgis-coding-components/p-9e242e76.js +0 -1
  92. package/dist/arcgis-coding-components/p-ccdf0ac1.entry.js +0 -1
  93. package/dist/cjs/arcade-mode-b77afcc9.js +0 -598
  94. package/dist/esm/arcade-mode-70e22d22.js +0 -594
@@ -1,37 +1,37 @@
1
- import { h, r as registerInstance, c as createEvent, g as getAssetPath, H as Host, a as getElement, F as Fragment } from './index-fd6b2fd8.js';
2
- import { g as generateTokensCSSForColorMap, e as editor, S as StandaloneServices, I as IStandaloneThemeService, c as createCommonjsModule, b as commonjsGlobal, X, V, i as importRequest, l as languages, d as arcadeDefaults, F, U as Uri, f as U, O, h as filterCollection, q, j as importArcade, p, k as j, P, K as KeyCode, H, z, s as supportedFields, B, R as Range, T, m as KeyMod } from './arcade-defaults-d7893362.js';
1
+ import { h, r as registerInstance, c as createEvent, g as getAssetPath, H as Host, a as getElement, F as Fragment } from './index-022fb97b.js';
2
+ import { g as generateTokensCSSForColorMap, e as editor, S as StandaloneServices, I as IStandaloneThemeService, c as createCommonjsModule, b as commonjsGlobal, X, V, i as importRequest, l as languages, d as arcadeDefaults, F, U as Uri, f as U, O, h as filterCollection, q, j as importArcade, p, $, P, K as KeyCode, H, z, s as supportedFields, B, R as Range, T, k as KeyMod } from './arcade-defaults-0bafa696.js';
3
3
 
4
4
  async function colorizeCode(code) {
5
- return editor.colorize(code, "arcade", { tabSize: 2 });
5
+ return editor.colorize(code, "arcade", { tabSize: 2 });
6
6
  }
7
7
  async function colorizedAllCodeElements(e) {
8
- if (!e) {
9
- return;
10
- }
11
- const codeElements = Array.from(e.querySelectorAll("code.language-arcade"));
12
- await Promise.all(codeElements.map(async (codeElement) => await colorizeCodeElement(codeElement, codeElement.textContent)));
8
+ if (!e) {
9
+ return;
10
+ }
11
+ const codeElements = Array.from(e.querySelectorAll("code.language-arcade"));
12
+ await Promise.all(codeElements.map(async (codeElement) => await colorizeCodeElement(codeElement, codeElement.textContent)));
13
13
  }
14
14
  async function colorizeCodeElement(e, text) {
15
- if (!e || e.tagName !== "CODE") {
16
- return;
17
- }
18
- e.innerHTML = await colorizeCode(text ?? "");
15
+ if (!e || e.tagName !== "CODE") {
16
+ return;
17
+ }
18
+ e.innerHTML = await colorizeCode(text ?? "");
19
19
  }
20
20
  function generateColorizeStyles() {
21
- const themeService = StandaloneServices.get(IStandaloneThemeService);
22
- const theme = themeService.getColorTheme();
23
- return generateTokensCSSForColorMap(theme.tokenTheme.getColorMap());
21
+ const themeService = StandaloneServices.get(IStandaloneThemeService);
22
+ const theme = themeService.getColorTheme();
23
+ return generateTokensCSSForColorMap(theme.tokenTheme.getColorMap());
24
24
  }
25
25
  function onColorizeThemeChanged(func) {
26
- const themeService = StandaloneServices.get(IStandaloneThemeService);
27
- return themeService.onDidColorThemeChange(() => func());
26
+ const themeService = StandaloneServices.get(IStandaloneThemeService);
27
+ return themeService.onDidColorThemeChange(() => func());
28
28
  }
29
29
 
30
30
  const StickyFilterInput = ({ filterValue, ...rest }) => (
31
31
  // TODO: Remove when calcite-input bug with scale is fixed
32
32
  // @ts-expect-error
33
33
  h("div", { class: "sticky", scale: "m" },
34
- h("calcite-input", { value: filterValue, icon: "magnifying-glass", clearable: true, ...rest })));
34
+ h("calcite-input", { value: filterValue, icon: "magnifying-glass", clearable: true, ...rest })));
35
35
 
36
36
  var marked_umd = createCommonjsModule(function (module, exports) {
37
37
  /**
@@ -2911,76 +2911,76 @@ var marked_umd = createCommonjsModule(function (module, exports) {
2911
2911
  });
2912
2912
 
2913
2913
  marked_umd.marked.use({
2914
- gfm: true,
2915
- renderer: {
2916
- link(href, title, text) {
2917
- return `<calcite-link href="${href}" title="${title ?? text}" target="Arcade Help">${text}</calcite-link>`;
2914
+ gfm: true,
2915
+ renderer: {
2916
+ link(href, title, text) {
2917
+ return `<calcite-link href="${href}" title="${title ?? text}" target="Arcade Help">${text}</calcite-link>`;
2918
+ }
2918
2919
  }
2919
- }
2920
2920
  });
2921
2921
  function convertMarkdownString(value) {
2922
- value = value ?? "";
2923
- const result = marked_umd.marked(typeof value === "string" ? value : value.value, {
2924
- gfm: true,
2925
- breaks: true,
2926
- headerIds: false,
2927
- mangle: false
2928
- });
2929
- return result;
2922
+ value ?? (value = "");
2923
+ const result = marked_umd.marked(typeof value === "string" ? value : value.value, {
2924
+ gfm: true,
2925
+ breaks: true,
2926
+ headerIds: false,
2927
+ mangle: false
2928
+ });
2929
+ return result;
2930
2930
  }
2931
2931
 
2932
2932
  function isMonacoEnvironmentSetup() {
2933
- return !!self.MonacoEnvironment?.getWorkerUrl;
2933
+ return !!globalThis.MonacoEnvironment?.getWorkerUrl;
2934
2934
  }
2935
2935
  const additionalLanguageWorkersMap = new Map();
2936
2936
  function getAssetsPath() {
2937
- return self.MonacoEnvironment?.assetsPath;
2937
+ return globalThis.MonacoEnvironment?.assetsPath;
2938
2938
  }
2939
2939
  function setupMonacoEnvironment(assetsPath) {
2940
- //
2941
- // Check if the worker loading logic has already been defined.
2942
- if (isMonacoEnvironmentSetup()) {
2943
- return;
2944
- }
2945
- // Since we are using workers, monaco needs to find them.
2946
- // Using the global MonacoEnvironment.
2947
- self.MonacoEnvironment = {
2948
- assetsPath,
2949
- getWorker: async (_, languageId) => {
2950
- // Manufacture the url for the web worker
2951
- let url = additionalLanguageWorkersMap.get(languageId) ?? `${assetsPath}/code-editor/editor.worker.js`;
2952
- switch (languageId) {
2953
- case "json":
2954
- url = `${assetsPath}/code-editor/json.worker.js`;
2955
- break;
2956
- case "css":
2957
- url = `${assetsPath}/code-editor/css.worker.js`;
2958
- break;
2959
- case "html":
2960
- url = `${assetsPath}/code-editor/html.worker.js`;
2961
- break;
2962
- case "typescript":
2963
- case "javascript":
2964
- url = `${assetsPath}/code-editor/ts.worker.js`;
2965
- break;
2966
- case "arcade":
2967
- url = `${assetsPath}/code-editor/arcade.worker.js`;
2968
- break;
2969
- }
2970
- // If we have a relative path or we are on same orgin, we can use the default js implementation
2971
- if (!X(url) || V(url, location.href, true)) {
2972
- return new Worker(url, { name: languageId });
2973
- }
2974
- // For cross orgin, we will load the worker code as a string and manufacture a blob
2975
- const esriRequest = await importRequest();
2976
- const response = await esriRequest(url, {
2977
- responseType: "text"
2978
- });
2979
- return new Worker(URL.createObjectURL(new Blob([response.data], {
2980
- type: "text/javascript"
2981
- })));
2940
+ //
2941
+ // Check if the worker loading logic has already been defined.
2942
+ if (isMonacoEnvironmentSetup()) {
2943
+ return;
2982
2944
  }
2983
- };
2945
+ // Since we are using workers, monaco needs to find them.
2946
+ // Using the global MonacoEnvironment.
2947
+ globalThis.MonacoEnvironment = {
2948
+ assetsPath,
2949
+ getWorker: async (_, languageId) => {
2950
+ // Manufacture the url for the web worker
2951
+ let url = additionalLanguageWorkersMap.get(languageId) ?? `${assetsPath}/code-editor/editor.worker.js`;
2952
+ switch (languageId) {
2953
+ case "json":
2954
+ url = `${assetsPath}/code-editor/json.worker.js`;
2955
+ break;
2956
+ case "css":
2957
+ url = `${assetsPath}/code-editor/css.worker.js`;
2958
+ break;
2959
+ case "html":
2960
+ url = `${assetsPath}/code-editor/html.worker.js`;
2961
+ break;
2962
+ case "typescript":
2963
+ case "javascript":
2964
+ url = `${assetsPath}/code-editor/ts.worker.js`;
2965
+ break;
2966
+ case "arcade":
2967
+ url = `${assetsPath}/code-editor/arcade.worker.js`;
2968
+ break;
2969
+ }
2970
+ // If we have a relative path or we are on same orgin, we can use the default js implementation
2971
+ if (!X(url) || V(url, globalThis.location.href, true)) {
2972
+ return new Worker(url, { name: languageId });
2973
+ }
2974
+ // For cross orgin, we will load the worker code as a string and manufacture a blob
2975
+ const esriRequest = await importRequest();
2976
+ const response = await esriRequest(url, {
2977
+ responseType: "text"
2978
+ });
2979
+ return new Worker(URL.createObjectURL(new Blob([response.data], {
2980
+ type: "text/javascript"
2981
+ })));
2982
+ }
2983
+ };
2984
2984
  }
2985
2985
 
2986
2986
  /**
@@ -2995,8 +2995,8 @@ function setupMonacoEnvironment(assetsPath) {
2995
2995
  * ```
2996
2996
  */
2997
2997
  async function getArcadeDiagnosticService() {
2998
- const mode = await getMode();
2999
- return mode.getArcadeDiagnosticService();
2998
+ const mode = await getMode();
2999
+ return mode.getArcadeDiagnosticService();
3000
3000
  }
3001
3001
  /**
3002
3002
  * Returns the arcade worker for the model.
@@ -3007,180 +3007,180 @@ async function getArcadeDiagnosticService() {
3007
3007
  * @returns arcade worker
3008
3008
  */
3009
3009
  async function getArcadeWorker(uri) {
3010
- const mode = await getMode();
3011
- return mode.getArcadeWorker(uri);
3010
+ const mode = await getMode();
3011
+ return mode.getArcadeWorker(uri);
3012
3012
  }
3013
3013
  /**
3014
3014
  * Request the arcade mode
3015
3015
  * @returns mode for arcade
3016
3016
  */
3017
3017
  function getMode() {
3018
- return import('./arcade-mode-70e22d22.js');
3018
+ return import('./arcade-mode-c17a1fa1.js');
3019
3019
  }
3020
3020
  // Register the language in Monaco
3021
3021
  languages.register({
3022
- id: arcadeDefaults.languageId,
3023
- aliases: ["Arcade", "arcade"],
3024
- extensions: [".arc"],
3025
- mimetypes: ["application/arcade"]
3022
+ id: arcadeDefaults.languageId,
3023
+ aliases: ["Arcade", "arcade"],
3024
+ extensions: [".arc"],
3025
+ mimetypes: ["application/arcade"]
3026
3026
  });
3027
3027
  // An event emitted when a language is first time needed
3028
3028
  languages.onLanguage(arcadeDefaults.languageId, async () => {
3029
- // Setup the assets path on the arcadeDefaults
3030
- arcadeDefaults.setLanguageOptions({ assetsPath: `${getAssetsPath() ?? "."}/arcade-language` });
3031
- // Async import the language mode
3032
- const mode = await getMode();
3033
- // Setup the language mode
3034
- mode.setupMode(arcadeDefaults);
3029
+ // Setup the assets path on the arcadeDefaults
3030
+ arcadeDefaults.setLanguageOptions({ assetsPath: `${getAssetsPath() ?? "."}/arcade-language` });
3031
+ // Async import the language mode
3032
+ const mode = await getMode();
3033
+ // Setup the language mode
3034
+ mode.setupMode(arcadeDefaults);
3035
3035
  });
3036
3036
 
3037
3037
  const arcadeApiCss = ":host{background-color:var(--calcite-ui-foreground-1)}:host .notice-container{margin:var(--calcite-spacing-quarter);padding:var(--calcite-spacing-half);background-color:var(--calcite-ui-foreground-1)}:host .sticky{position:sticky;top:0px;z-index:10}:host calcite-flow{height:100%}:host calcite-block p:first-of-type{margin-top:0}:host calcite-block code{font-family:var(--calcite-code-family)}:host calcite-block pre{direction:ltr;overflow-x:auto;background-color:var(--calcite-ui-foreground-2);padding:var(--calcite-spacing-half)}:host calcite-block pre code{font-size:var(--calcite-font-size--2)}";
3038
3038
 
3039
3039
  const ArcgisArcadeApi = class {
3040
- constructor(hostRef) {
3041
- registerInstance(this, hostRef);
3042
- this.close = createEvent(this, "close", 3);
3043
- this.itemSelected = createEvent(this, "itemSelected", 3);
3044
- this._emitItemSelected = (e) => {
3045
- // @ts-expect-error
3046
- const item = e.target?.["data-item"];
3047
- if (!item) {
3048
- return;
3049
- }
3050
- const keyEvent = e;
3051
- if (!keyEvent.key || keyEvent.key === "Enter") {
3052
- e.preventDefault();
3053
- this.itemSelected.emit(item.completion.insertText);
3054
- }
3055
- };
3056
- this._emitClose = () => this.close.emit();
3057
- this._emitItemSelectedAndClose = (e) => {
3058
- if (!e.target) {
3059
- return;
3060
- }
3061
- const keyEvent = e;
3062
- if (!keyEvent.key || keyEvent.key === "Enter") {
3063
- e.preventDefault();
3040
+ constructor(hostRef) {
3041
+ registerInstance(this, hostRef);
3042
+ this.close = createEvent(this, "close", 3);
3043
+ this.itemSelected = createEvent(this, "itemSelected", 3);
3044
+ this._emitItemSelected = (e) => {
3045
+ // @ts-expect-error
3046
+ const item = e.target?.["data-item"];
3047
+ if (!item) {
3048
+ return;
3049
+ }
3050
+ const keyEvent = e;
3051
+ if (!keyEvent.key || keyEvent.key === "Enter") {
3052
+ e.preventDefault();
3053
+ this.itemSelected.emit(item.completion.insertText);
3054
+ }
3055
+ };
3056
+ this._emitClose = () => this.close.emit();
3057
+ this._emitItemSelectedAndClose = (e) => {
3058
+ if (!e.target) {
3059
+ return;
3060
+ }
3061
+ const keyEvent = e;
3062
+ if (!keyEvent.key || keyEvent.key === "Enter") {
3063
+ e.preventDefault();
3064
+ // @ts-expect-error
3065
+ this.itemSelected.emit(e.target["data-item"].completion.insertText);
3066
+ }
3067
+ };
3068
+ this._selectItem = (e) => {
3069
+ if (!e.target) {
3070
+ return;
3071
+ }
3072
+ e.stopPropagation();
3073
+ // @ts-expect-error
3074
+ this._selectedApiItem = e.target["data-item"];
3075
+ };
3076
+ this._unselectItem = async () => {
3077
+ this._selectedApiItem = undefined;
3078
+ };
3064
3079
  // @ts-expect-error
3065
- this.itemSelected.emit(e.target["data-item"].completion.insertText);
3066
- }
3067
- };
3068
- this._selectItem = (e) => {
3069
- if (!e.target) {
3070
- return;
3071
- }
3072
- e.stopPropagation();
3073
- // @ts-expect-error
3074
- this._selectedApiItem = e.target["data-item"];
3075
- };
3076
- this._unselectItem = async () => {
3077
- this._selectedApiItem = undefined;
3078
- };
3079
- // @ts-expect-error
3080
- this._updateFilterValue = (e) => (this._filterValue = e.target?.["value"] ?? "");
3081
- this._lang = "";
3082
- this._t9nLocale = "";
3083
- this._t9nStrings = undefined;
3084
- this._selectedApiItem = undefined;
3085
- this._filterValue = "";
3086
- this._colorizeStyle = "";
3087
- this._preparingApi = false;
3088
- this._apiLibrary = undefined;
3089
- this.hideDocumentationActions = false;
3090
- this.modelId = undefined;
3091
- }
3092
- //#endregion
3093
- // #region Component lifecycle events
3094
- async componentWillLoad() {
3095
- this._colorizeStyle = generateColorizeStyles();
3096
- this._themeChangedListner = onColorizeThemeChanged(() => (this._colorizeStyle = generateColorizeStyles()));
3097
- await F(this, getAssetPath("./assets"));
3098
- arcadeDefaults.onModelContextDidChange((key) => {
3099
- if (!this.modelId || key !== Uri.parse(this.modelId).toString()) {
3100
- return;
3101
- }
3102
- this._updateApiLibrary();
3103
- });
3104
- this._updateApiLibrary();
3105
- }
3106
- disconnectedCallback() {
3107
- U(this);
3108
- this._flowObserver?.disconnect();
3109
- this._themeChangedListner?.dispose();
3110
- }
3111
- // #endregion
3112
- //#region Private Methods
3113
- async _updateApiLibrary() {
3114
- if (!this.modelId) {
3115
- return;
3080
+ this._updateFilterValue = (e) => (this._filterValue = e.target?.value ?? "");
3081
+ this._lang = "";
3082
+ this._t9nLocale = "";
3083
+ this._t9nStrings = undefined;
3084
+ this._selectedApiItem = undefined;
3085
+ this._filterValue = "";
3086
+ this._colorizeStyle = "";
3087
+ this._preparingApi = false;
3088
+ this._apiLibrary = undefined;
3089
+ this.hideDocumentationActions = false;
3090
+ this.modelId = undefined;
3116
3091
  }
3117
- this._preparingApi = true;
3118
- try {
3119
- const arcadeWorker = await getArcadeWorker(Uri.parse(this.modelId));
3120
- if (!arcadeWorker) {
3121
- // Something went wrong
3122
- throw new Error("Undefined worker");
3123
- }
3124
- // Fetch the api definitions from the arcade LS worker.
3125
- const context = arcadeDefaults.getApiContextForModel(this.modelId);
3126
- this._apiLibrary = await arcadeWorker.getApiLibrary(context);
3092
+ //#endregion
3093
+ // #region Component lifecycle events
3094
+ async componentWillLoad() {
3095
+ this._colorizeStyle = generateColorizeStyles();
3096
+ this._themeChangedListner = onColorizeThemeChanged(() => (this._colorizeStyle = generateColorizeStyles()));
3097
+ await F(this, getAssetPath("./assets"));
3098
+ arcadeDefaults.onModelContextDidChange((key) => {
3099
+ if (!this.modelId || key !== Uri.parse(this.modelId).toString()) {
3100
+ return;
3101
+ }
3102
+ this._updateApiLibrary();
3103
+ });
3104
+ this._updateApiLibrary();
3127
3105
  }
3128
- catch (e) {
3129
- console.error("Could not load api library", e);
3130
- console.error(e.stack);
3131
- this._apiLibrary = undefined;
3106
+ disconnectedCallback() {
3107
+ U(this);
3108
+ this._flowObserver?.disconnect();
3109
+ this._themeChangedListner?.dispose();
3132
3110
  }
3133
- finally {
3134
- this._preparingApi = false;
3111
+ // #endregion
3112
+ //#region Private Methods
3113
+ async _updateApiLibrary() {
3114
+ if (!this.modelId) {
3115
+ return;
3116
+ }
3117
+ this._preparingApi = true;
3118
+ try {
3119
+ const arcadeWorker = await getArcadeWorker(Uri.parse(this.modelId));
3120
+ if (!arcadeWorker) {
3121
+ // Something went wrong
3122
+ throw new Error("Undefined worker");
3123
+ }
3124
+ // Fetch the api definitions from the arcade LS worker.
3125
+ const context = arcadeDefaults.getApiContextForModel(this.modelId);
3126
+ this._apiLibrary = await arcadeWorker.getApiLibrary(context);
3127
+ }
3128
+ catch (e) {
3129
+ console.error("Could not load api library", e);
3130
+ console.error(e.stack);
3131
+ this._apiLibrary = undefined;
3132
+ }
3133
+ finally {
3134
+ this._preparingApi = false;
3135
+ }
3135
3136
  }
3136
- }
3137
- flowFocusHandler(ref) {
3138
- // When a flow is removed from the document then a null ref will be passed in
3139
- if (!ref) {
3140
- this._flowObserver?.disconnect();
3141
- this._flowObserver = undefined;
3142
- return;
3137
+ flowFocusHandler(ref) {
3138
+ // When a flow is removed from the document then a null ref will be passed in
3139
+ if (!ref) {
3140
+ this._flowObserver?.disconnect();
3141
+ this._flowObserver = undefined;
3142
+ return;
3143
+ }
3144
+ if (this._flowObserver) {
3145
+ return;
3146
+ }
3147
+ // Observer panel added/removed and also observe the flow id
3148
+ // When switching between flow the same reference is reused
3149
+ this._flowObserver = new MutationObserver(() => {
3150
+ // Get the last panel and try to set focus on the input element
3151
+ O(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
3152
+ });
3153
+ this._flowObserver.observe(ref, { attributes: true, attributeFilter: ["id"], childList: true });
3143
3154
  }
3144
- if (this._flowObserver) {
3145
- return;
3155
+ //#endregion
3156
+ //#region Renderers
3157
+ renderApiCategory(category) {
3158
+ const filteredApiItems = filterCollection(category.items, "name", this._filterValue);
3159
+ if (!filteredApiItems.length) {
3160
+ return null;
3161
+ }
3162
+ return (h("calcite-list-item-group", { heading: category.title }, filteredApiItems.map((apiItem) => (h("calcite-list-item", { label: q(apiItem.completion.detail), onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": apiItem }, h("calcite-action", { slot: "actions-end", text: this._t9nStrings?.expand ?? "Expand", icon: "chevron-right", iconFlipRtl: true, scale: "s", onClick: this._selectItem, "data-item": apiItem }))))));
3146
3163
  }
3147
- // Observer panel added/removed and also observe the flow id
3148
- // When switching between flow the same reference is reused
3149
- this._flowObserver = new MutationObserver(() => {
3150
- // Get the last panel and try to set focus on the input element
3151
- O(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
3152
- });
3153
- this._flowObserver.observe(ref, { attributes: true, attributeFilter: ["id"], childList: true });
3154
- }
3155
- //#endregion
3156
- //#region Renderers
3157
- renderApiCategory(category) {
3158
- const filteredApiItems = filterCollection(category.items, "name", this._filterValue);
3159
- if (!filteredApiItems.length) {
3160
- return null;
3164
+ renderApiItemFlowItem() {
3165
+ const apiItem = this._selectedApiItem;
3166
+ if (!apiItem) {
3167
+ return null;
3168
+ }
3169
+ return (h("calcite-flow-item", { heading: this._t9nStrings?.constantsandfunctions, beforeBack: this._unselectItem, closable: true, onCalciteFlowItemClose: this._emitClose }, this.hideDocumentationActions ? null : (h("calcite-button", { width: "half", slot: "footer", appearance: "outline", kind: "brand", scale: "s", href: apiItem.link, target: "Arcade Help", "icon-start": "information" }, this._t9nStrings?.moreinformation)), h("calcite-button", { width: "half", slot: "footer", appearance: "outline", kind: "brand", "icon-start": "code", scale: "s", onClick: this._emitItemSelectedAndClose, "data-item": apiItem, ref: (e) => e?.setFocus() }, this._t9nStrings?.insert ?? "Insert"), h("calcite-block", { open: true, heading: q(apiItem.completion.detail) }, h("div", { innerHTML: convertMarkdownString(apiItem.completion.documentation) }), apiItem.examples ? (h("div", { ref: (e) => {
3170
+ if (!e) {
3171
+ return;
3172
+ }
3173
+ e.innerHTML = convertMarkdownString(apiItem.examples);
3174
+ colorizedAllCodeElements(e);
3175
+ } })) : null)));
3161
3176
  }
3162
- return (h("calcite-list-item-group", { heading: category.title }, filteredApiItems.map((apiItem) => (h("calcite-list-item", { label: q(apiItem.completion.detail), onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": apiItem }, h("calcite-action", { slot: "actions-end", text: this._t9nStrings?.expand ?? "Expand", icon: "chevron-right", iconFlipRtl: true, scale: "s", onClick: this._selectItem, "data-item": apiItem }))))));
3163
- }
3164
- renderApiItemFlowItem() {
3165
- const apiItem = this._selectedApiItem;
3166
- if (!apiItem) {
3167
- return null;
3177
+ render() {
3178
+ const categories = (this._apiLibrary ?? []).map((apiCategory) => this.renderApiCategory(apiCategory));
3179
+ const empty = categories.every((g) => !g);
3180
+ return (h(Host, null, h("style", null, this._colorizeStyle), h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, h("calcite-flow-item", { heading: this._t9nStrings?.constantsandfunctions, closable: true, onCalciteFlowItemClose: this._emitClose }, h(StickyFilterInput, { filterValue: this._filterValue, onCalciteInputInput: this._updateFilterValue }), this._preparingApi ? (h("calcite-loader", { scale: "s", type: "indeterminate", label: this._t9nStrings?.loading ?? "Loading" })) : (h("calcite-list", null, empty ? h("div", { class: "notice-container" }, this._t9nStrings?.noitems ?? "No items") : categories))), this.renderApiItemFlowItem())));
3168
3181
  }
3169
- return (h("calcite-flow-item", { heading: this._t9nStrings?.constantsandfunctions, beforeBack: this._unselectItem, closable: true, onCalciteFlowItemClose: this._emitClose }, this.hideDocumentationActions ? null : (h("calcite-button", { width: "half", slot: "footer", appearance: "outline", kind: "brand", scale: "s", href: apiItem.link, target: "Arcade Help", "icon-start": "information" }, this._t9nStrings?.moreinformation)), h("calcite-button", { width: "half", slot: "footer", appearance: "outline", kind: "brand", "icon-start": "code", scale: "s", onClick: this._emitItemSelectedAndClose, "data-item": apiItem, ref: (e) => e?.setFocus() }, this._t9nStrings?.insert ?? "Insert"), h("calcite-block", { open: true, heading: q(apiItem.completion.detail) }, h("div", { innerHTML: convertMarkdownString(apiItem.completion.documentation) }), apiItem.examples ? (h("div", { ref: (e) => {
3170
- if (!e) {
3171
- return;
3172
- }
3173
- e.innerHTML = convertMarkdownString(apiItem.examples);
3174
- colorizedAllCodeElements(e);
3175
- } })) : null)));
3176
- }
3177
- render() {
3178
- const categories = (this._apiLibrary ?? []).map((apiCategory) => this.renderApiCategory(apiCategory));
3179
- const empty = categories.every((g) => !g);
3180
- return (h(Host, null, h("style", null, this._colorizeStyle), h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, h("calcite-flow-item", { heading: this._t9nStrings?.constantsandfunctions, closable: true, onCalciteFlowItemClose: this._emitClose }, h(StickyFilterInput, { filterValue: this._filterValue, onCalciteInputInput: this._updateFilterValue }), this._preparingApi ? (h("calcite-loader", { scale: "s", type: "indeterminate", label: this._t9nStrings?.loading ?? "Loading" })) : (h("calcite-list", null, empty ? h("div", { class: "notice-container" }, this._t9nStrings?.noitems ?? "No items") : categories))), this.renderApiItemFlowItem())));
3181
- }
3182
- static get assetsDirs() { return ["assets"]; }
3183
- get _hostElement() { return getElement(this); }
3182
+ static get assetsDirs() { return ["assets"]; }
3183
+ get _hostElement() { return getElement(this); }
3184
3184
  };
3185
3185
  ArcgisArcadeApi.style = arcadeApiCss;
3186
3186
 
@@ -3189,177 +3189,177 @@ const MaxArrayItems = 100;
3189
3189
  const BatchSize = 100;
3190
3190
 
3191
3191
  function isArcadeFeatureSet(value) {
3192
- return value.declaredRootClass === "esri.arcade.featureset.support.FeatureSet";
3192
+ return value.declaredRootClass === "esri.arcade.featureset.support.FeatureSet";
3193
3193
  }
3194
3194
  function isArcadeFeature(value) {
3195
- return value.arcadeDeclaredClass === "esri.arcade.Feature";
3195
+ return value.arcadeDeclaredClass === "esri.arcade.Feature";
3196
3196
  }
3197
3197
  function isArcadeDictionary(value) {
3198
- return value.declaredClass === "esri.arcade.Dictionary";
3198
+ return value.declaredClass === "esri.arcade.Dictionary";
3199
3199
  }
3200
3200
  function isGeometry(value) {
3201
- const declaredClass = value.declaredClass;
3202
- return typeof declaredClass === "string" && declaredClass.startsWith("esri.geometry.");
3201
+ const declaredClass = value.declaredClass;
3202
+ return typeof declaredClass === "string" && declaredClass.startsWith("esri.geometry.");
3203
3203
  }
3204
3204
  function isArcadePortal(value) {
3205
- const declaredClass = value.declaredClass;
3206
- return typeof declaredClass === "string" && declaredClass === "esri.arcade.Portal";
3205
+ const declaredClass = value.declaredClass;
3206
+ return typeof declaredClass === "string" && declaredClass === "esri.arcade.Portal";
3207
3207
  }
3208
3208
  function isArcadeAttachment(value) {
3209
- const declaredClass = value.declaredClass;
3210
- return typeof declaredClass === "string" && declaredClass === "esri.arcade.Attachment";
3209
+ const declaredClass = value.declaredClass;
3210
+ return typeof declaredClass === "string" && declaredClass === "esri.arcade.Attachment";
3211
3211
  }
3212
3212
  function isArcadeDate(value) {
3213
- const declaredRootClass = value.declaredRootClass;
3214
- return typeof declaredRootClass === "string" && declaredRootClass === "esri.arcade.arcadedate";
3213
+ const declaredRootClass = value.declaredRootClass;
3214
+ return typeof declaredRootClass === "string" && declaredRootClass === "esri.arcade.arcadedate";
3215
3215
  }
3216
3216
  function isArcadeDateOnly(value) {
3217
- const declaredRootClass = value.declaredRootClass;
3218
- return typeof declaredRootClass === "string" && declaredRootClass === "esri.core.sql.dateonly";
3217
+ const declaredRootClass = value.declaredRootClass;
3218
+ return typeof declaredRootClass === "string" && declaredRootClass === "esri.core.sql.dateonly";
3219
3219
  }
3220
3220
  function isArcadeTimeOnly(value) {
3221
- const declaredRootClass = value.declaredRootClass;
3222
- return typeof declaredRootClass === "string" && declaredRootClass === "esri.core.sql.timeonly";
3221
+ const declaredRootClass = value.declaredRootClass;
3222
+ return typeof declaredRootClass === "string" && declaredRootClass === "esri.core.sql.timeonly";
3223
3223
  }
3224
3224
  function isArcadeImmutableArray(value) {
3225
- return (typeof value.length === "function" &&
3226
- typeof value.get === "function" &&
3227
- typeof value.toArray === "function" &&
3228
- Array.isArray(value._elements));
3225
+ return (typeof value.length === "function" &&
3226
+ typeof value.get === "function" &&
3227
+ typeof value.toArray === "function" &&
3228
+ Array.isArray(value._elements));
3229
3229
  }
3230
3230
  function valueToArcadeResult(value) {
3231
- if (value == null || value === undefined) {
3232
- return { type: "null" };
3233
- }
3234
- if (Array.isArray(value)) {
3235
- return { type: "array", value };
3236
- }
3237
- if (isArcadeImmutableArray(value)) {
3238
- return { type: "array", value: value.toArray() };
3239
- }
3240
- if (value instanceof Date) {
3241
- return { type: "date", value };
3242
- }
3243
- if (typeof value === "string") {
3244
- return { type: "text", value };
3245
- }
3246
- if (typeof value === "number") {
3247
- return { type: "number", value };
3248
- }
3249
- if (typeof value === "boolean") {
3250
- return { type: "boolean", value };
3251
- }
3252
- if (typeof value !== "object") {
3231
+ if (value == null || value === undefined) {
3232
+ return { type: "null" };
3233
+ }
3234
+ if (Array.isArray(value)) {
3235
+ return { type: "array", value };
3236
+ }
3237
+ if (isArcadeImmutableArray(value)) {
3238
+ return { type: "array", value: value.toArray() };
3239
+ }
3240
+ if (value instanceof Date) {
3241
+ return { type: "date", value };
3242
+ }
3243
+ if (typeof value === "string") {
3244
+ return { type: "text", value };
3245
+ }
3246
+ if (typeof value === "number") {
3247
+ return { type: "number", value };
3248
+ }
3249
+ if (typeof value === "boolean") {
3250
+ return { type: "boolean", value };
3251
+ }
3252
+ if (typeof value !== "object") {
3253
+ return { type: "unknown" };
3254
+ }
3255
+ if (isArcadeDate(value)) {
3256
+ return { type: "date", value };
3257
+ }
3258
+ if (isArcadeDateOnly(value)) {
3259
+ return { type: "dateOnly", value };
3260
+ }
3261
+ if (isArcadeTimeOnly(value)) {
3262
+ return { type: "time", value };
3263
+ }
3264
+ if (isArcadeAttachment(value)) {
3265
+ return { type: "attachment", value };
3266
+ }
3267
+ if (isArcadePortal(value)) {
3268
+ return { type: "portal", value };
3269
+ }
3270
+ if (isArcadeFeatureSet(value)) {
3271
+ return { type: "featureSet", value, features: [], iterator: null };
3272
+ }
3273
+ if (isArcadeFeature(value)) {
3274
+ return { type: "feature", value };
3275
+ }
3276
+ if (isArcadeDictionary(value)) {
3277
+ return { type: "dictionary", value };
3278
+ }
3279
+ if (isGeometry(value)) {
3280
+ return { type: "geometry", value };
3281
+ }
3253
3282
  return { type: "unknown" };
3254
- }
3255
- if (isArcadeDate(value)) {
3256
- return { type: "date", value };
3257
- }
3258
- if (isArcadeDateOnly(value)) {
3259
- return { type: "dateOnly", value };
3260
- }
3261
- if (isArcadeTimeOnly(value)) {
3262
- return { type: "time", value };
3263
- }
3264
- if (isArcadeAttachment(value)) {
3265
- return { type: "attachment", value };
3266
- }
3267
- if (isArcadePortal(value)) {
3268
- return { type: "portal", value };
3269
- }
3270
- if (isArcadeFeatureSet(value)) {
3271
- return { type: "featureSet", value, features: [], iterator: null };
3272
- }
3273
- if (isArcadeFeature(value)) {
3274
- return { type: "feature", value };
3275
- }
3276
- if (isArcadeDictionary(value)) {
3277
- return { type: "dictionary", value };
3278
- }
3279
- if (isGeometry(value)) {
3280
- return { type: "geometry", value };
3281
- }
3282
- return { type: "unknown" };
3283
3283
  }
3284
3284
  function formatArcadeResultDate(dateObject, lang = "en") {
3285
- // Default to english
3286
- if (dateObject.value instanceof Date) {
3287
- return new Intl.DateTimeFormat(lang, { dateStyle: "medium", timeStyle: "long" }).format(dateObject.value);
3288
- }
3289
- return dateObject.value
3290
- .toDateTime()
3291
- .setLocale(lang)
3292
- .toFormat(dateObject.value.isUnknownTimeZone ? "FF" : "FF ZZZZZ");
3285
+ // Default to english
3286
+ if (dateObject.value instanceof Date) {
3287
+ return new Intl.DateTimeFormat(lang, { dateStyle: "medium", timeStyle: "long" }).format(dateObject.value);
3288
+ }
3289
+ return dateObject.value
3290
+ .toDateTime()
3291
+ .setLocale(lang)
3292
+ .toFormat(dateObject.value.isUnknownTimeZone ? "FF" : "FF ZZZZZ");
3293
3293
  }
3294
3294
  function formatArcadeResultDateOnly(dateObject) {
3295
- return dateObject.value.toString();
3295
+ return dateObject.value.toString();
3296
3296
  }
3297
3297
  function formatArcadeResultTimeOnly(dateObject) {
3298
- return dateObject.value.toString();
3298
+ return dateObject.value.toString();
3299
3299
  }
3300
3300
  async function loadArcadeResult(result, timeZone = "system") {
3301
- if (result.type !== "featureSet") {
3302
- return result;
3303
- }
3304
- // Feature Set needs to be loaded
3305
- await result.value.load();
3306
- // Create the first iterator
3307
- result.iterator = result.value.iterator({ aborted: false });
3308
- if (result.iterator == null) {
3301
+ if (result.type !== "featureSet") {
3302
+ return result;
3303
+ }
3304
+ // Feature Set needs to be loaded
3305
+ await result.value.load();
3306
+ // Create the first iterator
3307
+ result.iterator = result.value.iterator({ aborted: false });
3308
+ if (result.iterator == null) {
3309
+ return result;
3310
+ }
3311
+ // Load the first batch of items
3312
+ result.features = (await result.iterator.nextBatchAsArcadeFeatures(BatchSize, timeZone)) ?? [];
3309
3313
  return result;
3310
- }
3311
- // Load the first batch of items
3312
- result.features = (await result.iterator.nextBatchAsArcadeFeatures(BatchSize, timeZone)) ?? [];
3313
- return result;
3314
3314
  }
3315
3315
  async function executeScript(editorProfile, script, testContext, console) {
3316
- //
3317
- const timeStamp = new Date();
3318
- // Provide a default console function is missing
3319
- console = console ?? (() => undefined);
3320
- try {
3321
- // We want to measure compilation time
3322
- const t0 = performance.now();
3323
- // Setup an executor with the script
3324
- const arcade = await importArcade();
3325
- const executor = await arcade.createArcadeExecutor(script ?? "", {
3326
- variables: editorProfile?.variables ?? []
3327
- });
3328
- // We want to measure the execution time
3329
- const t1 = performance.now();
3330
- // Manufacture our execution context
3331
- const { profileVariableInstances, spatialReference, timeZone } = testContext;
3332
- const executeContext = {
3333
- spatialReference,
3334
- timeZone,
3335
- rawOutput: true,
3336
- console
3337
- };
3338
- // Execute the script
3339
- const scriptOutput = await executor.executeAsync(profileVariableInstances ?? {}, executeContext);
3340
- // Convert script output to arcade result object and load data if necessary
3341
- const scriptResult = await loadArcadeResult(valueToArcadeResult(scriptOutput), timeZone);
3342
- // Timestamp and measure cost
3343
- scriptResult.timeStamp = timeStamp;
3344
- scriptResult.compilationTime = t1 - t0;
3345
- scriptResult.executionTime = performance.now() - t1;
3346
- return scriptResult;
3347
3316
  //
3348
- }
3349
- catch (error) {
3350
- let message = "Unknown Error";
3351
- if (error instanceof Error) {
3352
- message = error.message;
3317
+ const timeStamp = new Date();
3318
+ // Provide a default console function if missing
3319
+ console ?? (console = () => undefined);
3320
+ try {
3321
+ // We want to measure compilation time
3322
+ const t0 = performance.now();
3323
+ // Setup an executor with the script
3324
+ const arcade = await importArcade();
3325
+ const executor = await arcade.createArcadeExecutor(script ?? "", {
3326
+ variables: editorProfile?.variables ?? []
3327
+ });
3328
+ // We want to measure the execution time
3329
+ const t1 = performance.now();
3330
+ // Manufacture our execution context
3331
+ const { profileVariableInstances, spatialReference, timeZone } = testContext;
3332
+ const executeContext = {
3333
+ spatialReference,
3334
+ timeZone,
3335
+ rawOutput: true,
3336
+ console
3337
+ };
3338
+ // Execute the script
3339
+ const scriptOutput = await executor.executeAsync(profileVariableInstances ?? {}, executeContext);
3340
+ // Convert script output to arcade result object and load data if necessary
3341
+ const scriptResult = await loadArcadeResult(valueToArcadeResult(scriptOutput), timeZone);
3342
+ // Timestamp and measure cost
3343
+ scriptResult.timeStamp = timeStamp;
3344
+ scriptResult.compilationTime = t1 - t0;
3345
+ scriptResult.executionTime = performance.now() - t1;
3346
+ return scriptResult;
3347
+ //
3348
+ }
3349
+ catch (error) {
3350
+ let message = "Unknown Error";
3351
+ if (error instanceof Error) {
3352
+ message = error.message;
3353
+ }
3354
+ return {
3355
+ type: "error",
3356
+ value: message,
3357
+ error,
3358
+ timeStamp,
3359
+ compilationTime: 0,
3360
+ executionTime: 0
3361
+ };
3353
3362
  }
3354
- return {
3355
- type: "error",
3356
- value: message,
3357
- error,
3358
- timeStamp: timeStamp,
3359
- compilationTime: 0,
3360
- executionTime: 0
3361
- };
3362
- }
3363
3363
  }
3364
3364
 
3365
3365
  const themeConfig = {
@@ -3384,912 +3384,908 @@ const themeConfig = {
3384
3384
  };
3385
3385
 
3386
3386
  function setupArcadeTheme() {
3387
- ["light", "dark"].forEach((theme) => {
3388
- const base = theme === "light" ? "vs" : "vs-dark";
3389
- const colors = themeConfig[`arcade-${theme}-theme`];
3390
- // Defines the light and dark theme based on the calcite theme name
3391
- editor.defineTheme(base, {
3392
- base,
3393
- inherit: true,
3394
- rules: [
3395
- { token: "comment.arc", foreground: colors.comment },
3396
- { token: "constant.arc", foreground: colors.constant },
3397
- { token: "keyword.arc", foreground: colors.keyword },
3398
- { token: "identifier.arc", foreground: colors.identifier },
3399
- { token: "number.arc", foreground: colors.number },
3400
- { token: "string.arc", foreground: colors.string }
3401
- ],
3402
- colors: {}
3387
+ ["light", "dark"].forEach((theme) => {
3388
+ const base = theme === "light" ? "vs" : "vs-dark";
3389
+ const colors = themeConfig[`arcade-${theme}-theme`];
3390
+ // Defines the light and dark theme based on the calcite theme name
3391
+ editor.defineTheme(base, {
3392
+ base,
3393
+ inherit: true,
3394
+ rules: [
3395
+ { token: "comment.arc", foreground: colors.comment },
3396
+ { token: "constant.arc", foreground: colors.constant },
3397
+ { token: "keyword.arc", foreground: colors.keyword },
3398
+ { token: "identifier.arc", foreground: colors.identifier },
3399
+ { token: "number.arc", foreground: colors.number },
3400
+ { token: "string.arc", foreground: colors.string }
3401
+ ],
3402
+ colors: {}
3403
+ });
3403
3404
  });
3404
- });
3405
3405
  }
3406
3406
  function updateThemeColors(theme, colorRules) {
3407
- if (colorRules === undefined) {
3408
- setupArcadeTheme();
3409
- return;
3410
- }
3411
- const base = theme === "light" ? "vs" : "vs-dark";
3412
- const rules = [];
3413
- ["comment", "keyword", "identifier", "string", "number", "constant"].forEach((key) => {
3414
- // @ts-expect-error
3415
- const foreground = colorRules[key];
3416
- if (!foreground) {
3417
- return;
3407
+ if (colorRules === undefined) {
3408
+ setupArcadeTheme();
3409
+ return;
3418
3410
  }
3419
- rules.push({ token: `${key}.arc`, foreground });
3420
- });
3421
- editor.defineTheme(base, { base, inherit: true, rules, colors: {} });
3411
+ const base = theme === "light" ? "vs" : "vs-dark";
3412
+ const rules = [];
3413
+ ["comment", "keyword", "identifier", "string", "number", "constant"].forEach((key) => {
3414
+ // @ts-expect-error
3415
+ const foreground = colorRules[key];
3416
+ if (!foreground) {
3417
+ return;
3418
+ }
3419
+ rules.push({ token: `${key}.arc`, foreground });
3420
+ });
3421
+ editor.defineTheme(base, { base, inherit: true, rules, colors: {} });
3422
3422
  }
3423
3423
 
3424
3424
  const arcadeEditorCss = "arcgis-arcade-editor{display:flex;flex-direction:column;height:100%;width:100%;position:relative;overflow:hidden;border:1px solid var(--calcite-ui-border-3);box-sizing:border-box;background-color:var(--calcite-ui-foreground-1)}arcgis-arcade-editor .flex-adjustable{flex:1 1 auto;overflow:hidden}arcgis-arcade-editor .flex-panel{flex:1 0 auto}arcgis-arcade-editor .position-relative{position:relative}arcgis-arcade-editor .flex-row{display:flex;flex-direction:row;overflow:hidden}arcgis-arcade-editor .flex-column{display:flex;flex-direction:column;overflow:hidden}arcgis-arcade-editor .border-inline-start{border-inline-start:1px solid var(--calcite-ui-border-3);box-sizing:border-box}arcgis-arcade-editor .border-inline-end{border-inline-end:1px solid var(--calcite-ui-border-3);box-sizing:border-box}arcgis-arcade-editor .sticky{position:sticky;top:0px;z-index:10}arcgis-arcade-editor .notice-container{margin:var(--calcite-spacing-quarter);padding:var(--calcite-spacing-half);background-color:var(--calcite-ui-foreground-1);text-align:center}arcgis-arcade-editor .side-action-bar{max-width:25%}arcgis-arcade-editor .side-panel{max-width:45%;width:600px}arcgis-arcade-editor .side-panel calcite-flow{height:100%}arcgis-arcade-editor .main-action-bar{border-bottom:1px solid var(--calcite-ui-border-3);flex:0 0 auto}arcgis-arcade-editor .main-action-bar calcite-action-group{padding-inline-end:var(--calcite-spacing-half)}arcgis-arcade-editor .main-action-bar calcite-action-group calcite-action{padding-inline-end:var(--calcite-spacing-half)}arcgis-arcade-editor .main-action-bar calcite-action-group calcite-action:not(:first-child){padding-inline-start:var(--calcite-spacing-half)}arcgis-arcade-editor .main-action-bar calcite-action-group:last-child{border-inline-end-width:0px}arcgis-arcade-editor .main-action-bar calcite-action-group:not(:first-child){padding-inline-start:var(--calcite-spacing-half)}arcgis-arcade-editor arcgis-arcade-results{border-top:1px solid var(--calcite-ui-border-3);box-sizing:border-box;max-height:50%;min-height:50%;margin-bottom:-1px}arcgis-arcade-editor calcite-flow [slot=footer]{word-break:break-word}arcgis-arcade-editor calcite-list-item-group calcite-list-item{margin-bottom:1px;box-shadow:0 1px 0 var(--calcite-ui-border-3)}arcgis-arcade-editor calcite-list-item-group calcite-list-item:last-child{box-shadow:none}arcgis-arcade-editor calcite-list-item-group:last-child{margin-bottom:var(--calcite-spacing-1)}";
3425
3425
 
3426
3426
  setupArcadeTheme();
3427
3427
  const ArcgisArcadeEditor = class {
3428
- constructor(hostRef) {
3429
- registerInstance(this, hostRef);
3430
- this.scriptChange = createEvent(this, "scriptChange", 3);
3431
- this.diagnosticsChange = createEvent(this, "diagnosticsChange", 3);
3432
- this._componentReadyDefer = new p();
3433
- this._modelId = j();
3434
- this._editorProfilePromise = Promise.resolve(undefined);
3435
- this._disposables = [];
3436
- this._executeScript = async () => {
3437
- const testContext = this.testData;
3438
- if (!this._codeEditorElt || !testContext) {
3439
- return;
3440
- }
3441
- const editorProfile = await this._editorProfilePromise;
3442
- if (!editorProfile) {
3443
- this._executionResult = { type: "error", value: "Missing editor profile", error: null };
3444
- return;
3445
- }
3446
- this._showExecutionPanel = true;
3447
- this._executingScript = true;
3448
- this._consoleLogs = [];
3449
- setTimeout(async () => {
3450
- const script = await this._codeEditorElt?.getValue();
3451
- this._executionResult = await executeScript(editorProfile.definition, script, testContext, (log) => setTimeout(() => (this._consoleLogs = [...this._consoleLogs, log]), 0));
3428
+ constructor(hostRef) {
3429
+ registerInstance(this, hostRef);
3430
+ this.scriptChange = createEvent(this, "scriptChange", 3);
3431
+ this.diagnosticsChange = createEvent(this, "diagnosticsChange", 3);
3432
+ this._componentReadyDefer = new p();
3433
+ this._modelId = $();
3434
+ this._editorProfilePromise = Promise.resolve(undefined);
3435
+ this._disposables = [];
3436
+ this._executeScript = async () => {
3437
+ const testContext = this.testData;
3438
+ if (!this._codeEditorElt || !testContext) {
3439
+ return;
3440
+ }
3441
+ const editorProfile = await this._editorProfilePromise;
3442
+ if (!editorProfile) {
3443
+ this._executionResult = { type: "error", value: "Missing editor profile", error: null };
3444
+ return;
3445
+ }
3446
+ this._showExecutionPanel = true;
3447
+ this._executingScript = true;
3448
+ this._consoleLogs = [];
3449
+ setTimeout(async () => {
3450
+ const script = await this._codeEditorElt?.getValue();
3451
+ this._executionResult = await executeScript(editorProfile.definition, script, testContext, (log) => setTimeout(() => (this._consoleLogs = [...this._consoleLogs, log]), 0));
3452
+ this._executingScript = false;
3453
+ }, 0);
3454
+ };
3455
+ this._toggleShowExecutionPanel = () => (this._showExecutionPanel = !this._showExecutionPanel);
3456
+ this._toggleSideActionBarExpanded = () => (this.sideActionBarExpanded = !this.sideActionBarExpanded);
3457
+ this._toggleSidePanel = async (e) => {
3458
+ if (!e.target) {
3459
+ return;
3460
+ }
3461
+ const panelName = e.target?.dataset.panelName ?? "none";
3462
+ // Setup the new panel. Toggle to none if already opened
3463
+ this.openedSidePanel = panelName === this.openedSidePanel ? "none" : panelName;
3464
+ if (this.openedSidePanel === "none") {
3465
+ // Reset focus on the code editor if no panel displayed
3466
+ await this._codeEditorElt?.setFocus();
3467
+ }
3468
+ };
3469
+ this._openArcadeHelp = () => window.open(DevelopersWebSitePath, "Arcade Help");
3470
+ this._emitScriptChange = (e) => {
3471
+ e.stopPropagation();
3472
+ this.scriptChange.emit(e.detail);
3473
+ };
3474
+ this._insertAsSnippet = (e) => this._codeEditorElt?.insertSnippet(e.detail);
3475
+ this._insertAsText = (e) => this._codeEditorElt?.insertText(e.detail);
3476
+ this._onResultPanelChange = (e) => (this._resultPanel = e.detail);
3477
+ this._onExecutionPanelClose = () => (this._showExecutionPanel = false);
3478
+ this._lang = "";
3479
+ this._t9nLocale = "";
3480
+ this._t9nStrings = undefined;
3481
+ this._standaloneCodeEditor = undefined;
3482
+ this._preparingProfile = false;
3483
+ this._editorProfile = undefined;
3484
+ this._showExecutionPanel = false;
3485
+ this._resultPanel = "output";
3452
3486
  this._executingScript = false;
3453
- }, 0);
3454
- };
3455
- this._toggleShowExecutionPanel = () => (this._showExecutionPanel = !this._showExecutionPanel);
3456
- this._toggleSideActionBarExpanded = () => (this.sideActionBarExpanded = !this.sideActionBarExpanded);
3457
- this._toggleSidePanel = async (e) => {
3458
- if (!e.target) {
3459
- return;
3460
- }
3461
- const panelName = e.target?.dataset.panelName ?? "none";
3462
- // Setup the new panel. Toggle to none if already opened
3463
- this.openedSidePanel = panelName === this.openedSidePanel ? "none" : panelName;
3464
- if (this.openedSidePanel === "none") {
3465
- // Reset focus on the code editor if no panel displayed
3466
- await this._codeEditorElt?.setFocus();
3467
- }
3468
- };
3469
- this._openArcadeHelp = () => window.open(DevelopersWebSitePath, "Arcade Help");
3470
- this._emitScriptChange = (e) => {
3471
- e.stopPropagation();
3472
- this.scriptChange.emit(e.detail);
3473
- };
3474
- this._insertAsSnippet = (e) => this._codeEditorElt?.insertSnippet(e.detail);
3475
- this._insertAsText = (e) => this._codeEditorElt?.insertText(e.detail);
3476
- this._onResultPanelChange = (e) => (this._resultPanel = e.detail);
3477
- this._onExecutionPanelClose = () => (this._showExecutionPanel = false);
3478
- this._lang = "";
3479
- this._t9nLocale = "";
3480
- this._t9nStrings = undefined;
3481
- this._standaloneCodeEditor = undefined;
3482
- this._preparingProfile = false;
3483
- this._editorProfile = undefined;
3484
- this._showExecutionPanel = false;
3485
- this._resultPanel = "output";
3486
- this._executingScript = false;
3487
- this._consoleLogs = [];
3488
- this._executionResult = undefined;
3489
- this.profile = undefined;
3490
- this.script = "";
3491
- this.testData = undefined;
3492
- this.suggestions = undefined;
3493
- this.snippets = undefined;
3494
- this.hideDocumentationActions = false;
3495
- this.hideSideBar = false;
3496
- this.sideActionBarExpanded = false;
3497
- this.openedSidePanel = "none";
3498
- }
3499
- _profileChanged(newValue, oldValue) {
3500
- // Prevent the execution as long as the component has not been fully loaded
3501
- if (newValue === oldValue) {
3502
- return;
3487
+ this._consoleLogs = [];
3488
+ this._executionResult = undefined;
3489
+ this.profile = undefined;
3490
+ this.script = "";
3491
+ this.testData = undefined;
3492
+ this.suggestions = undefined;
3493
+ this.snippets = undefined;
3494
+ this.hideDocumentationActions = false;
3495
+ this.hideSideBar = false;
3496
+ this.sideActionBarExpanded = false;
3497
+ this.openedSidePanel = "none";
3503
3498
  }
3504
- this._updateEditorProfile();
3505
- }
3506
- _testDataChanged(newValue, oldValue) {
3507
- if (newValue === oldValue || !this._showExecutionPanel) {
3508
- return;
3499
+ _profileChanged(newValue, oldValue) {
3500
+ // Prevent the execution as long as the component has not been fully loaded
3501
+ if (newValue === oldValue) {
3502
+ return;
3503
+ }
3504
+ this._updateEditorProfile();
3509
3505
  }
3510
- this._executeScript();
3511
- }
3512
- _snippetChanged(newValue, oldValue) {
3513
- if (newValue === oldValue) {
3514
- return;
3506
+ _testDataChanged(newValue, oldValue) {
3507
+ if (newValue === oldValue || !this._showExecutionPanel) {
3508
+ return;
3509
+ }
3510
+ this._executeScript();
3515
3511
  }
3516
- arcadeDefaults.updateApiContextForModel(this._modelId, {
3517
- snippets: this.snippets
3518
- });
3519
- }
3520
- // #endregion
3521
- // #region Public methods API
3522
- /**
3523
- * Returns the current script.
3524
- * @returns {Promise<string>}
3525
- */
3526
- async getScript() {
3527
- await this._componentReadyDefer.promise;
3528
- return this._codeEditorElt?.getValue();
3529
- }
3530
- /**
3531
- * Set the focus on the element.
3532
- */
3533
- async setFocus() {
3534
- await this._componentReadyDefer.promise;
3535
- await this._codeEditorElt?.setFocus();
3536
- }
3537
- /**
3538
- * @internal
3539
- * Returns the editor instance.
3540
- * @returns {Promise<IStandaloneCodeEditor>} - The monaco editor instance
3541
- */
3542
- async getEditorInstance() {
3543
- await this._componentReadyDefer.promise;
3544
- return this._codeEditorElt?.getEditorInstance();
3545
- }
3546
- /**
3547
- * Returns the Arcade result for the script for the provided test data.
3548
- */
3549
- async getTestResult() {
3550
- if (!this.testData) {
3551
- return { type: "error", value: "Missing test data", error: null };
3512
+ _snippetChanged(newValue, oldValue) {
3513
+ if (newValue === oldValue) {
3514
+ return;
3515
+ }
3516
+ arcadeDefaults.updateApiContextForModel(this._modelId, {
3517
+ snippets: this.snippets
3518
+ });
3552
3519
  }
3553
- const editorProfile = await this._editorProfilePromise;
3554
- if (!editorProfile) {
3555
- return { type: "error", value: "Missing editor profile", error: null };
3520
+ // #endregion
3521
+ // #region Public methods API
3522
+ /**
3523
+ * Returns the current script.
3524
+ * @returns {Promise<string>}
3525
+ */
3526
+ async getScript() {
3527
+ await this._componentReadyDefer.promise;
3528
+ return this._codeEditorElt?.getValue();
3556
3529
  }
3557
- await this._componentReadyDefer.promise;
3558
- const script = await this._codeEditorElt?.getValue();
3559
- return executeScript(editorProfile.definition, script, this.testData);
3560
- }
3561
- /**
3562
- * Returns the Arcade output type for the script.
3563
- * @deprecated Use getTestResult
3564
- * @internal
3565
- */
3566
- async getOutputType() {
3567
- return (await this.getTestResult()).type;
3568
- }
3569
- /**
3570
- * Allows to change theme colors
3571
- * @internal
3572
- */
3573
- async updateThemeColors(colorRules) {
3574
- const theme = P(this._hostElement);
3575
- updateThemeColors(theme, colorRules);
3576
- if (colorRules === undefined) {
3577
- ["comment", "keyword", "identifier", "string", "number", "constant", "date"].forEach((key) => {
3578
- this._hostElement.style.removeProperty(`--arcgis-arcade-editor-${key}`);
3579
- });
3580
- return;
3530
+ /**
3531
+ * Set the focus on the element.
3532
+ */
3533
+ async setFocus() {
3534
+ await this._componentReadyDefer.promise;
3535
+ await this._codeEditorElt?.setFocus();
3581
3536
  }
3582
- ["comment", "keyword", "identifier", "string", "number", "constant", "date"].forEach((key) => {
3583
- // @ts-expect-error
3584
- const foreground = colorRules[key];
3585
- if (!foreground) {
3586
- return;
3587
- }
3588
- this._hostElement.style.setProperty(`--arcgis-arcade-editor-${key}`, foreground);
3589
- });
3590
- }
3591
- // #endregion
3592
- // #region Component lifecycle events
3593
- async componentWillLoad() {
3594
- const assetsPath = getAssetPath("./assets");
3595
- // We are a bit in a chicken and egg situation here.
3596
- // Normally, it is the code editor that is responsible for setting up the Monaco environement.
3597
- // However, we need to setup the environment before the code editor is instantiated because
3598
- // we need to access the arcade language service to get the api library.
3599
- setupMonacoEnvironment(assetsPath);
3600
- // Starts a locale observer. It will load the correct t9n strings for the component
3601
- // when the locale changes. We also pass updateEditorProfile. It will be invoked the first
3602
- // and on each locale change. The profile has to be refreshed on locale change as well.
3603
- await F(this, assetsPath, async () => await this._updateEditorProfile());
3604
- }
3605
- async componentDidLoad() {
3606
- // Mark on component as ready.
3607
- // Some methods are waiting for this state to actually continue.
3608
- this._componentReadyDefer.resolve();
3609
- // Start listening to the validation diagnostics.
3610
- // We are doing this as late as possible
3611
- const diagnosticsService = await getArcadeDiagnosticService();
3612
- this._disposables.push(diagnosticsService.onDiagnosticsChange((ev) => !this._preparingProfile && this.diagnosticsChange.emit(ev.diagnostics)));
3613
- // Get editor instance and add action
3614
- this._standaloneCodeEditor = await this.getEditorInstance();
3615
- this._standaloneCodeEditor?.addAction({
3616
- // An unique identifier for the action.
3617
- id: "run-script",
3618
- label: "Run Arcade Expression",
3619
- keybindings: [KeyCode.F5],
3620
- contextMenuGroupId: "code",
3621
- contextMenuOrder: 1,
3622
- run: () => {
3623
- if (this.testData) {
3624
- this._executeScript();
3537
+ /**
3538
+ * @internal
3539
+ * Returns the editor instance.
3540
+ * @returns {Promise<IStandaloneCodeEditor>} - The monaco editor instance
3541
+ */
3542
+ async getEditorInstance() {
3543
+ await this._componentReadyDefer.promise;
3544
+ return this._codeEditorElt?.getEditorInstance();
3545
+ }
3546
+ /**
3547
+ * Returns the Arcade result for the script for the provided test data.
3548
+ */
3549
+ async getTestResult() {
3550
+ if (!this.testData) {
3551
+ return { type: "error", value: "Missing test data", error: null };
3625
3552
  }
3626
- }
3627
- });
3628
- await this._codeEditorElt?.setFocus();
3629
- }
3630
- disconnectedCallback() {
3631
- U(this);
3632
- arcadeDefaults.disposeApiContextForModel(this._modelId);
3633
- arcadeDefaults.disposeEditorProfileForModel(this._modelId);
3634
- while (this._disposables.length) {
3635
- this._disposables.pop()?.dispose();
3553
+ const editorProfile = await this._editorProfilePromise;
3554
+ if (!editorProfile) {
3555
+ return { type: "error", value: "Missing editor profile", error: null };
3556
+ }
3557
+ await this._componentReadyDefer.promise;
3558
+ const script = await this._codeEditorElt?.getValue();
3559
+ return executeScript(editorProfile.definition, script, this.testData);
3636
3560
  }
3637
- }
3638
- // #endregion
3639
- // #region Private methods API
3640
- async _updateEditorProfile() {
3641
- // The goal is to
3642
- // - convert the runtime profile into a specialized instance that will serve the UI better.
3643
- // - extract the language service profile that is specialized for completion and validation
3644
- this._preparingProfile = true;
3645
- try {
3646
- // Set a new profile for the model using the profile definition and the locale.
3647
- await arcadeDefaults.setProfileForModel(this._modelId, this.profile, {
3648
- locale: this._t9nLocale,
3649
- snippets: this.snippets
3650
- });
3651
- // Get the corresponding editor profile for the model.
3652
- // The editor profile contains the specialized profile for the UI.
3653
- this._editorProfile = arcadeDefaults.getEditorProfileForModel(this._modelId);
3561
+ /**
3562
+ * Returns the Arcade output type for the script.
3563
+ * @deprecated Use getTestResult
3564
+ * @internal
3565
+ */
3566
+ async getOutputType() {
3567
+ return (await this.getTestResult()).type;
3654
3568
  }
3655
- catch (e) {
3656
- this._editorProfile = undefined;
3569
+ /**
3570
+ * Allows to change theme colors
3571
+ * @internal
3572
+ */
3573
+ async updateThemeColors(colorRules) {
3574
+ const theme = P(this._hostElement);
3575
+ updateThemeColors(theme, colorRules);
3576
+ if (colorRules === undefined) {
3577
+ ["comment", "keyword", "identifier", "string", "number", "constant", "date"].forEach((key) => {
3578
+ this._hostElement.style.removeProperty(`--arcgis-arcade-editor-${key}`);
3579
+ });
3580
+ return;
3581
+ }
3582
+ ["comment", "keyword", "identifier", "string", "number", "constant", "date"].forEach((key) => {
3583
+ // @ts-expect-error
3584
+ const foreground = colorRules[key];
3585
+ if (!foreground) {
3586
+ return;
3587
+ }
3588
+ this._hostElement.style.setProperty(`--arcgis-arcade-editor-${key}`, foreground);
3589
+ });
3657
3590
  }
3658
- finally {
3659
- this._editorProfilePromise = Promise.resolve(this._editorProfile);
3660
- this._preparingProfile = false;
3591
+ // #endregion
3592
+ // #region Component lifecycle events
3593
+ async componentWillLoad() {
3594
+ const assetsPath = getAssetPath("./assets");
3595
+ // We are a bit in a chicken and egg situation here.
3596
+ // Normally, it is the code editor that is responsible for setting up the Monaco environement.
3597
+ // However, we need to setup the environment before the code editor is instantiated because
3598
+ // we need to access the arcade language service to get the api library.
3599
+ setupMonacoEnvironment(assetsPath);
3600
+ // Starts a locale observer. It will load the correct t9n strings for the component
3601
+ // when the locale changes. We also pass updateEditorProfile. It will be invoked the first
3602
+ // and on each locale change. The profile has to be refreshed on locale change as well.
3603
+ await F(this, assetsPath, async () => await this._updateEditorProfile());
3661
3604
  }
3662
- }
3663
- // #endregion
3664
- //#region Render Main Action Bar
3665
- renderMainActionBar() {
3666
- if (!this.testData) {
3667
- return null;
3605
+ async componentDidLoad() {
3606
+ // Mark on component as ready.
3607
+ // Some methods are waiting for this state to actually continue.
3608
+ this._componentReadyDefer.resolve();
3609
+ // Start listening to the validation diagnostics.
3610
+ // We are doing this as late as possible
3611
+ const diagnosticsService = await getArcadeDiagnosticService();
3612
+ this._disposables.push(diagnosticsService.onDiagnosticsChange((event) => !this._preparingProfile && this.diagnosticsChange.emit(event.diagnostics)));
3613
+ // Get editor instance and add action
3614
+ this._standaloneCodeEditor = await this.getEditorInstance();
3615
+ this._standaloneCodeEditor?.addAction({
3616
+ // An unique identifier for the action.
3617
+ id: "run-script",
3618
+ label: "Run Arcade Expression",
3619
+ keybindings: [KeyCode.F5],
3620
+ contextMenuGroupId: "code",
3621
+ contextMenuOrder: 1,
3622
+ run: () => {
3623
+ if (this.testData) {
3624
+ this._executeScript();
3625
+ }
3626
+ }
3627
+ });
3628
+ await this._codeEditorElt?.setFocus();
3668
3629
  }
3669
- return (h("calcite-action-bar", { class: "main-action-bar", layout: "horizontal", scale: "s", expanded: true, "expand-disabled": true }, h("calcite-action-group", { scale: "s" }, h("calcite-action", { text: this._t9nStrings?.run ?? "Run", "text-enabled": true, icon: "play", scale: "s", loading: this._preparingProfile, onClick: this._executeScript }), this._executionResult ? (h("calcite-action", { text: this._t9nStrings?.lastresults ?? "Last results", active: this._showExecutionPanel, "text-enabled": true, icon: "access-string-results", iconFlipRtl: true, scale: "s", onClick: this._toggleShowExecutionPanel })) : null)));
3670
- }
3671
- //#endregion
3672
- //#region Render Main Panel
3673
- renderMainPanel() {
3674
- return (
3675
- // <div class="flex-adjustable">
3676
- h("arcgis-code-editor", { class: "flex-adjustable", language: arcadeDefaults.languageId, value: this.script ?? "", modelId: this._modelId, onValueChange: this._emitScriptChange, ref: (e) => (this._codeEditorElt = e) })
3677
- // </div>
3678
- );
3679
- }
3680
- //#endregion
3681
- //#region Rendering the Action Bar
3682
- renderSideActionBar() {
3683
- if (this.hideSideBar) {
3684
- return null;
3630
+ disconnectedCallback() {
3631
+ U(this);
3632
+ arcadeDefaults.disposeApiContextForModel(this._modelId);
3633
+ arcadeDefaults.disposeEditorProfileForModel(this._modelId);
3634
+ while (this._disposables.length) {
3635
+ this._disposables.pop()?.dispose();
3636
+ }
3685
3637
  }
3686
- return (h("calcite-action-bar", { class: "side-action-bar border-inline-start", expanded: !!this.sideActionBarExpanded, position: "end", onCalciteActionBarToggle: this._toggleSideActionBarExpanded }, h("calcite-action-group", null, h("calcite-action", { id: "profile-variables-action", text: this._t9nStrings?.profilevariables ?? "Profile variables", icon: "profile-variables", active: this.openedSidePanel === "variables", onClick: this._toggleSidePanel, "data-panel-name": "variables" }), h("calcite-action", { id: "function-action", text: this._t9nStrings?.constantsandfunctions ?? "Constants and functions", icon: "function", active: this.openedSidePanel === "api", onClick: this._toggleSidePanel, "data-panel-name": "api" }), this.suggestions?.length ? (h(Fragment, null, h("calcite-action", { id: "suggestions-action", text: this._t9nStrings?.suggestions ?? "Suggestions", icon: "lightbulb", active: this.openedSidePanel === "suggestions", onClick: this._toggleSidePanel, "data-panel-name": "suggestions" }))) : null, this.hideDocumentationActions ? null : (h(Fragment, null, h("calcite-action", { id: "developer-website-action", text: this._t9nStrings?.help ?? "Help", icon: "question", iconFlipRtl: this._t9nLocale === "ar", onClick: this._openArcadeHelp }))))));
3687
- }
3688
- // private renderTooltip(id: string, label: string | undefined): VNode | null {
3689
- // if (this.sideActionBarExpanded || !label) {
3690
- // return null;
3691
- // }
3692
- // return (
3693
- // <calcite-tooltip label={label} reference-element={id} placement="leading-start">
3694
- // <span>{label}</span>
3695
- // </calcite-tooltip>
3696
- // );
3697
- // }
3698
- //#endregion
3699
- //#region Render Side Panel
3700
- renderSidePanel() {
3701
- if (this.hideSideBar) {
3702
- return null;
3638
+ // #endregion
3639
+ // #region Private methods API
3640
+ async _updateEditorProfile() {
3641
+ // The goal is to
3642
+ // - convert the runtime profile into a specialized instance that will serve the UI better.
3643
+ // - extract the language service profile that is specialized for completion and validation
3644
+ this._preparingProfile = true;
3645
+ try {
3646
+ // Set a new profile for the model using the profile definition and the locale.
3647
+ await arcadeDefaults.setProfileForModel(this._modelId, this.profile, {
3648
+ locale: this._t9nLocale,
3649
+ snippets: this.snippets
3650
+ });
3651
+ // Get the corresponding editor profile for the model.
3652
+ // The editor profile contains the specialized profile for the UI.
3653
+ this._editorProfile = arcadeDefaults.getEditorProfileForModel(this._modelId);
3654
+ }
3655
+ catch (e) {
3656
+ this._editorProfile = undefined;
3657
+ }
3658
+ finally {
3659
+ this._editorProfilePromise = Promise.resolve(this._editorProfile);
3660
+ this._preparingProfile = false;
3661
+ }
3703
3662
  }
3704
- switch (this.openedSidePanel) {
3705
- case "api":
3706
- return (h("arcgis-arcade-api", { class: "side-panel flex-panel border-inline-start", modelId: this._modelId, hideDocumentationActions: this.hideDocumentationActions, onItemSelected: this._insertAsSnippet, onClose: this._toggleSidePanel, "data-panel-name": "none" }));
3707
- case "variables":
3708
- return (h("arcgis-arcade-variables", { class: "side-panel flex-panel border-inline-start", loading: this._preparingProfile, modelId: this._modelId, onItemSelected: this._insertAsText, onClose: this._toggleSidePanel, "data-panel-name": "none" }));
3709
- case "suggestions":
3710
- return (h("arcgis-arcade-suggestions", { class: "side-panel flex-panel border-inline-start", suggestions: this.suggestions, onItemSelected: this._insertAsText, onClose: this._toggleSidePanel, "data-panel-name": "none" }));
3711
- default:
3712
- return null;
3663
+ // #endregion
3664
+ //#region Render Main Action Bar
3665
+ renderMainActionBar() {
3666
+ if (!this.testData) {
3667
+ return null;
3668
+ }
3669
+ return (h("calcite-action-bar", { class: "main-action-bar", layout: "horizontal", scale: "s", expanded: true, "expand-disabled": true }, h("calcite-action-group", { scale: "s" }, h("calcite-action", { text: this._t9nStrings?.run ?? "Run", "text-enabled": true, icon: "play", scale: "s", loading: this._preparingProfile, onClick: this._executeScript }), this._executionResult ? (h("calcite-action", { text: this._t9nStrings?.lastresults ?? "Last results", active: this._showExecutionPanel, "text-enabled": true, icon: "access-string-results", iconFlipRtl: true, scale: "s", onClick: this._toggleShowExecutionPanel })) : null)));
3713
3670
  }
3714
- }
3715
- //#endregion
3716
- //#region Rendering Results Panel
3717
- renderResultsPanel() {
3718
- if (!this._showExecutionPanel) {
3719
- return null;
3671
+ //#endregion
3672
+ //#region Render Main Panel
3673
+ renderMainPanel() {
3674
+ return (
3675
+ // <div class="flex-adjustable">
3676
+ h("arcgis-code-editor", { class: "flex-adjustable", language: arcadeDefaults.languageId, value: this.script ?? "", modelId: this._modelId, onValueChange: this._emitScriptChange, ref: (e) => (this._codeEditorElt = e) })
3677
+ // </div>
3678
+ );
3720
3679
  }
3721
- return (h("arcgis-arcade-results", { class: "flex-adjustable", openedResultPanel: this._resultPanel, loading: this._executingScript, result: this._executionResult, consoleLogs: this._consoleLogs, onOpenedResultPanelChange: this._onResultPanelChange, onClose: this._onExecutionPanelClose }));
3722
- }
3723
- //#endregion
3724
- //#region Render
3725
- render() {
3726
- return (h(Host, null, this.renderMainActionBar(), h("div", { class: "flex-row flex-adjustable" }, h("div", { class: "flex-column flex-adjustable" }, this.renderMainPanel(), this.renderResultsPanel()), this.renderSidePanel(), this.renderSideActionBar())));
3727
- }
3728
- static get assetsDirs() { return ["assets"]; }
3729
- get _hostElement() { return getElement(this); }
3730
- static get watchers() { return {
3731
- "profile": ["_profileChanged"],
3732
- "testData": ["_testDataChanged"],
3733
- "snippets": ["_snippetChanged"]
3734
- }; }
3680
+ //#endregion
3681
+ //#region Rendering the Action Bar
3682
+ renderSideActionBar() {
3683
+ if (this.hideSideBar) {
3684
+ return null;
3685
+ }
3686
+ return (h("calcite-action-bar", { class: "side-action-bar border-inline-start", expanded: !!this.sideActionBarExpanded, position: "end", onCalciteActionBarToggle: this._toggleSideActionBarExpanded }, h("calcite-action-group", null, h("calcite-action", { id: "profile-variables-action", text: this._t9nStrings?.profilevariables ?? "Profile variables", icon: "profile-variables", active: this.openedSidePanel === "variables", onClick: this._toggleSidePanel, "data-panel-name": "variables" }), h("calcite-action", { id: "function-action", text: this._t9nStrings?.constantsandfunctions ?? "Constants and functions", icon: "function", active: this.openedSidePanel === "api", onClick: this._toggleSidePanel, "data-panel-name": "api" }), this.suggestions?.length ? (h(Fragment, null, h("calcite-action", { id: "suggestions-action", text: this._t9nStrings?.suggestions ?? "Suggestions", icon: "lightbulb", active: this.openedSidePanel === "suggestions", onClick: this._toggleSidePanel, "data-panel-name": "suggestions" }))) : null, this.hideDocumentationActions ? null : (h(Fragment, null, h("calcite-action", { id: "developer-website-action", text: this._t9nStrings?.help ?? "Help", icon: "question", iconFlipRtl: this._t9nLocale === "ar", onClick: this._openArcadeHelp }))))));
3687
+ }
3688
+ // private renderTooltip(id: string, label: string | undefined): VNode | null {
3689
+ // if (this.sideActionBarExpanded || !label) {
3690
+ // return null;
3691
+ // }
3692
+ // return (
3693
+ // <calcite-tooltip label={label} reference-element={id} placement="leading-start">
3694
+ // <span>{label}</span>
3695
+ // </calcite-tooltip>
3696
+ // );
3697
+ // }
3698
+ //#endregion
3699
+ //#region Render Side Panel
3700
+ renderSidePanel() {
3701
+ if (this.hideSideBar) {
3702
+ return null;
3703
+ }
3704
+ switch (this.openedSidePanel) {
3705
+ case "api":
3706
+ return (h("arcgis-arcade-api", { class: "side-panel flex-panel border-inline-start", modelId: this._modelId, hideDocumentationActions: this.hideDocumentationActions, onItemSelected: this._insertAsSnippet, onClose: this._toggleSidePanel, "data-panel-name": "none" }));
3707
+ case "variables":
3708
+ return (h("arcgis-arcade-variables", { class: "side-panel flex-panel border-inline-start", loading: this._preparingProfile, modelId: this._modelId, onItemSelected: this._insertAsText, onClose: this._toggleSidePanel, "data-panel-name": "none" }));
3709
+ case "suggestions":
3710
+ return (h("arcgis-arcade-suggestions", { class: "side-panel flex-panel border-inline-start", suggestions: this.suggestions, onItemSelected: this._insertAsText, onClose: this._toggleSidePanel, "data-panel-name": "none" }));
3711
+ default:
3712
+ return null;
3713
+ }
3714
+ }
3715
+ //#endregion
3716
+ //#region Rendering Results Panel
3717
+ renderResultsPanel() {
3718
+ if (!this._showExecutionPanel) {
3719
+ return null;
3720
+ }
3721
+ return (h("arcgis-arcade-results", { class: "flex-adjustable", openedResultPanel: this._resultPanel, loading: this._executingScript, result: this._executionResult, consoleLogs: this._consoleLogs, onOpenedResultPanelChange: this._onResultPanelChange, onClose: this._onExecutionPanelClose }));
3722
+ }
3723
+ //#endregion
3724
+ //#region Render
3725
+ render() {
3726
+ return (h(Host, null, this.renderMainActionBar(), h("div", { class: "flex-row flex-adjustable" }, h("div", { class: "flex-column flex-adjustable" }, this.renderMainPanel(), this.renderResultsPanel()), this.renderSidePanel(), this.renderSideActionBar())));
3727
+ }
3728
+ static get assetsDirs() { return ["assets"]; }
3729
+ get _hostElement() { return getElement(this); }
3730
+ static get watchers() { return {
3731
+ "profile": ["_profileChanged"],
3732
+ "testData": ["_testDataChanged"],
3733
+ "snippets": ["_snippetChanged"]
3734
+ }; }
3735
3735
  };
3736
3736
  ArcgisArcadeEditor.style = arcadeEditorCss;
3737
3737
 
3738
3738
  const indentSpecs = { char: " ", size: 2 };
3739
3739
  const indentType = new Array(indentSpecs.size + 1).join(indentSpecs.char);
3740
3740
  function createPushFunc(p) {
3741
- return (substring) => "\\" + p.push(substring) + "\\";
3741
+ return (substring) => `\\${p.push(substring)}\\`;
3742
3742
  }
3743
3743
  function createPopFunc(p) {
3744
- return (_, offset) => p[offset - 1];
3744
+ return (_, offset) => p[offset - 1];
3745
3745
  }
3746
3746
  function indent(index, indentType) {
3747
- return new Array(index + 1).join(indentType);
3747
+ return new Array(index + 1).join(indentType);
3748
3748
  }
3749
3749
  function jsonFormat(json) {
3750
- // Convert to string and extract backslashes and strings
3751
- const p = [];
3752
- const pushFunc = createPushFunc(p);
3753
- const jsonString = JSON.stringify(json)
3754
- .replace(/\\./g, pushFunc)
3755
- .replace(/(".*?"|'.*?')/g, pushFunc)
3756
- .replace(/\s+/, "");
3757
- // Indent and insert newlines
3758
- let indentIndex = 0;
3759
- let out = "";
3760
- for (let i = 0; i < jsonString.length; i++) {
3761
- const c = jsonString.charAt(i);
3762
- switch (c) {
3763
- case "{":
3764
- case "[":
3765
- out += c + "\n" + indent(++indentIndex, indentType);
3766
- break;
3767
- case "}":
3768
- case "]":
3769
- out += "\n" + indent(--indentIndex, indentType) + c;
3770
- break;
3771
- case ",":
3772
- out += ",\n" + indent(indentIndex, indentType);
3773
- break;
3774
- case ":":
3775
- out += ": ";
3776
- break;
3777
- default:
3778
- out += c;
3779
- break;
3750
+ // Convert to string and extract backslashes and strings
3751
+ const p = [];
3752
+ const pushFunc = createPushFunc(p);
3753
+ const jsonString = JSON.stringify(json)
3754
+ .replace(/\\./gu, pushFunc)
3755
+ .replace(/(".*?"|'.*?')/gu, pushFunc)
3756
+ .replace(/\s+/u, "");
3757
+ // Indent and insert newlines
3758
+ let indentIndex = 0;
3759
+ let out = "";
3760
+ for (let i = 0; i < jsonString.length; i += 1) {
3761
+ const c = jsonString.charAt(i);
3762
+ switch (c) {
3763
+ case "{":
3764
+ case "[":
3765
+ indentIndex += 1;
3766
+ out += `${c}\n${indent(indentIndex, indentType)}`;
3767
+ break;
3768
+ case "}":
3769
+ case "]":
3770
+ indentIndex -= 1;
3771
+ out += `\n${indent(indentIndex, indentType)}${c}`;
3772
+ break;
3773
+ case ",":
3774
+ out += `,\n${indent(indentIndex, indentType)}`;
3775
+ break;
3776
+ case ":":
3777
+ out += ": ";
3778
+ break;
3779
+ default:
3780
+ out += c;
3781
+ break;
3782
+ }
3780
3783
  }
3781
- }
3782
- // Strip whitespace from numeric arrays and put backslashes
3783
- // and strings back in
3784
- const popFunc = createPopFunc(p);
3785
- return out
3786
- .replace(/\[[\d,\s]+?\]/g, function (m) {
3787
- return m.replace(/\s/g, "");
3788
- })
3789
- .replace(/\\(\d+)\\/g, popFunc) // strings
3790
- .replace(/\\(\d+)\\/g, popFunc); // backslashes in strings
3784
+ // Strip whitespace from numeric arrays and put backslashes
3785
+ // and strings back in
3786
+ const popFunc = createPopFunc(p);
3787
+ return out
3788
+ .replace(/\[[\d,\s]+?\]/gu, (m) => m.replace(/\s/gu, ""))
3789
+ .replace(/\\(\d+)\\/gu, popFunc) // strings
3790
+ .replace(/\\(\d+)\\/gu, popFunc); // backslashes in strings
3791
3791
  }
3792
3792
 
3793
3793
  const arcadeResultsCss = ":host{display:flex;flex-direction:column;width:100%;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-2)}:host .flex-adjustable{flex:1 1 auto;overflow:hidden}:host .flex-row{display:flex;flex-direction:row;overflow:hidden}:host .flex-column{display:flex;flex-direction:column;overflow:hidden}:host .y-scrollable-container{overflow-y:auto;block-size:100%;background-color:var(--calcite-ui-foreground-1)}:host header{border-bottom:1px solid var(--calcite-ui-border-3);flex:0 0 auto}:host .ltr-container{direction:ltr}:host calcite-action-bar calcite-action-group{padding-inline-end:var(--calcite-spacing-half)}:host calcite-action-bar calcite-action-group calcite-action{padding-inline-end:var(--calcite-spacing-half)}:host calcite-action-bar calcite-action-group calcite-action:not(:first-child){padding-inline-start:var(--calcite-spacing-half)}:host calcite-action-bar calcite-action-group:last-child{border-inline-end-width:0px}:host calcite-action-bar calcite-action-group:not(:first-child){padding-inline-start:var(--calcite-spacing-half)}:host .notice-container{margin:var(--calcite-spacing-quarter);padding:var(--calcite-spacing-half);background-color:var(--calcite-ui-foreground-1)}:host .color-info{color:var(--calcite-ui-info)}:host .color-error{color:var(--calcite-ui-danger)}:host .color-success{color:var(--calcite-ui-success)}:host [class*=result-value-]{font-size:var(--calcite-font-size--2);line-height:1.25rem;background-color:var(--calcite-ui-foreground-1);margin:var(--calcite-spacing-three-quarter)}:host .console-logs-container{background-color:var(--calcite-ui-foreground-1);padding:0 var(--calcite-spacing-three-quarter);font-family:var(--calcite-code-family);font-size:var(--calcite-font-size--2);font-weight:var(--calcite-font-weight-normal)}:host .result-value-table table{display:block;max-width:fit-content;overflow-x:auto;border-spacing:0;border-collapse:collapse;text-align:start;white-space:nowrap}:host .result-value-table table thead{background-color:var(--calcite-ui-foreground-2)}:host .result-value-table table tr{border-top:1px solid var(--calcite-ui-border-3);border-bottom:1px solid var(--calcite-ui-border-3)}:host .result-value-table table th,:host .result-value-table table td{border-inline-start:1px solid var(--calcite-ui-border-3);border-inline-end:1px solid var(--calcite-ui-border-3);text-align:start;padding:var(--calcite-spacing-quarter)}:host .result-value-table table th .string-value,:host .result-value-table table td .string-value{white-space:pre}:host .result-value-table table th{font-weight:var(--calcite-font-weight-medium)}:host .tree-item-label,:host .number-value,:host .string-value,:host .boolean-value{font-family:var(--calcite-code-family)}:host .tree-item-label,:host .value-type{color:var(--calcite-text-2);font-weight:var(--calcite-font-weight-normal)}:host .dictionary-property{color:var(--arcgis-arcade-editor-identifier)}:host .number-value{color:var(--arcgis-arcade-editor-number)}:host .string-value{color:var(--arcgis-arcade-editor-string);white-space:pre-wrap}:host .constant-value{color:var(--arcgis-arcade-editor-constant)}:host .date-value{color:var(--arcgis-arcade-editor-date)}";
3794
3794
 
3795
3795
  //#region Specialized Constants
3796
3796
  const treeProps = {
3797
- lines: true,
3798
- selectionMode: "none",
3799
- scale: "s",
3800
- onCalciteTreeSelect: (e) => e.target.selectedItems.forEach((itemElt) => (itemElt.selected = false))
3797
+ lines: true,
3798
+ selectionMode: "none",
3799
+ scale: "s",
3800
+ onCalciteTreeSelect: (e) => e.target.selectedItems.forEach((itemElt) => (itemElt.selected = false))
3801
3801
  };
3802
3802
  const expandableTreeItemProps = {
3803
- onClick: (e) => {
3804
- const item = e.currentTarget;
3805
- item.expanded = !item.expanded;
3806
- }
3803
+ onClick: (e) => {
3804
+ const item = e.currentTarget;
3805
+ item.expanded = !item.expanded;
3806
+ }
3807
3807
  };
3808
3808
  const ArcgisArcadeResults = class {
3809
- constructor(hostRef) {
3810
- registerInstance(this, hostRef);
3811
- this.openedResultPanelChange = createEvent(this, "openedResultPanelChange", 3);
3812
- this.close = createEvent(this, "close", 3);
3813
- this._switchResultPanel = (e) => {
3814
- if (!e.target) {
3815
- return;
3816
- }
3817
- const panelName = e.target?.dataset.panelName;
3818
- if (!panelName) {
3819
- return;
3820
- }
3821
- this.updateResultPanel(panelName);
3822
- };
3823
- this._emitClose = () => this.close.emit();
3824
- this._lang = "";
3825
- this._t9nLocale = "";
3826
- this._t9nStrings = undefined;
3827
- this.loading = true;
3828
- this.openedResultPanel = "output";
3829
- this.result = undefined;
3830
- this.consoleLogs = undefined;
3831
- }
3832
- //#endregion
3833
- // #region Component lifecycle events
3834
- async componentWillLoad() {
3835
- await F(this, getAssetPath("./assets"));
3836
- }
3837
- disconnectedCallback() {
3838
- U(this);
3839
- }
3840
- // #endregion
3841
- //#region Private Methods
3842
- updateResultPanel(resultPanelType) {
3843
- this.openedResultPanel = resultPanelType;
3844
- this.openedResultPanelChange.emit(resultPanelType);
3845
- }
3846
- //#endregion
3847
- //#region Rendering
3848
- renderConsolePanel() {
3849
- if (this.openedResultPanel !== "console") {
3850
- return null;
3809
+ constructor(hostRef) {
3810
+ registerInstance(this, hostRef);
3811
+ this.openedResultPanelChange = createEvent(this, "openedResultPanelChange", 3);
3812
+ this.close = createEvent(this, "close", 3);
3813
+ this._switchResultPanel = (e) => {
3814
+ if (!e.target) {
3815
+ return;
3816
+ }
3817
+ const panelName = e.target?.dataset.panelName;
3818
+ if (!panelName) {
3819
+ return;
3820
+ }
3821
+ this.updateResultPanel(panelName);
3822
+ };
3823
+ this._emitClose = () => this.close.emit();
3824
+ this._lang = "";
3825
+ this._t9nLocale = "";
3826
+ this._t9nStrings = undefined;
3827
+ this.loading = true;
3828
+ this.openedResultPanel = "output";
3829
+ this.result = undefined;
3830
+ this.consoleLogs = undefined;
3851
3831
  }
3852
- if (this.loading && !this.consoleLogs?.length) {
3853
- return h("calcite-loader", { scale: "s", type: "indeterminate", label: "" });
3832
+ //#endregion
3833
+ // #region Component lifecycle events
3834
+ async componentWillLoad() {
3835
+ await F(this, getAssetPath("./assets"));
3854
3836
  }
3855
- return (h("div", { class: "console-logs-container ltr-container" }, this.consoleLogs?.length ? (this.consoleLogs.map((log) => {
3856
- return h("p", null, log);
3857
- })) : (h("p", null, this._t9nStrings?.consolemessage))));
3858
- }
3859
- renderLogPanel() {
3860
- if (this.openedResultPanel !== "log") {
3861
- return null;
3837
+ disconnectedCallback() {
3838
+ U(this);
3862
3839
  }
3863
- if (this.loading) {
3864
- return h("calcite-loader", { scale: "s", type: "indeterminate", label: "" });
3865
- }
3866
- const iconClass = this.result?.type === "error" ? "color-error" : "color-success";
3867
- return (h("calcite-list", null, this.result ? (h(Fragment, null, h("calcite-list-item", { label: H(this._t9nStrings?.lastexecutionformat, {
3868
- timeStamp: new Intl.DateTimeFormat(this._t9nLocale, {
3869
- dateStyle: "medium",
3870
- timeStyle: "medium"
3871
- }).format(this.result.timeStamp)
3872
- }) }, h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })), h("calcite-list-item", { label: H(this._t9nStrings?.compilationtimeformat, {
3873
- time: new Intl.NumberFormat(this._t9nLocale, {
3874
- style: "unit",
3875
- unit: "millisecond",
3876
- maximumFractionDigits: 2
3877
- }).format(this.result.compilationTime ?? 0)
3878
- }) }, h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })), h("calcite-list-item", { label: H(this._t9nStrings?.executiontimeformat, {
3879
- time: new Intl.NumberFormat(this._t9nLocale, {
3880
- style: "unit",
3881
- unit: "millisecond",
3882
- maximumFractionDigits: 2
3883
- }).format(this.result.executionTime ?? 0)
3884
- }) }, h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })))) : (h("calcite-list-item", { label: this._t9nStrings?.runscriptmessage ?? "No output, run the script once." }, h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: "color-info" })))));
3885
- }
3886
- renderOutputPanel() {
3887
- if (this.openedResultPanel !== "output") {
3888
- return null;
3840
+ // #endregion
3841
+ //#region Private Methods
3842
+ updateResultPanel(resultPanelType) {
3843
+ this.openedResultPanel = resultPanelType;
3844
+ this.openedResultPanelChange.emit(resultPanelType);
3889
3845
  }
3890
- if (this.loading) {
3891
- return h("calcite-loader", { scale: "s", type: "indeterminate", label: "" });
3846
+ //#endregion
3847
+ //#region Rendering
3848
+ renderConsolePanel() {
3849
+ if (this.openedResultPanel !== "console") {
3850
+ return null;
3851
+ }
3852
+ if (this.loading && !this.consoleLogs?.length) {
3853
+ return h("calcite-loader", { scale: "s", type: "indeterminate", label: "" });
3854
+ }
3855
+ return (h("div", { class: "console-logs-container ltr-container" }, this.consoleLogs?.length ? (this.consoleLogs.map((log) => h("p", null, log))) : (h("p", null, this._t9nStrings?.consolemessage))));
3892
3856
  }
3893
- switch (this.result?.type) {
3894
- case "error":
3895
- return (h("div", { class: "result-value-simple flex-adjustable" }, H(this._t9nStrings?.executionerrorformat, {
3896
- message: this.result.value
3897
- })));
3898
- case "null":
3899
- case "unknown":
3900
- return h("div", { class: "result-value-simple ltr-container" }, this.renderSimpleValue(this.result));
3901
- case "text":
3902
- case "number":
3903
- case "date":
3904
- case "dateOnly":
3905
- case "time":
3906
- case "boolean":
3907
- return (h("div", { class: "result-value-simple ltr-container" }, h("span", { class: "value-type" }, this.result.type, ":\u00A0"), this.renderSimpleValue(this.result)));
3908
- case "array": {
3909
- const items = this.result.value ?? [];
3910
- const firstItems = items.slice(0, MaxArrayItems);
3911
- return (h("div", { class: "result-value-simple ltr-container" }, h("calcite-tree", { ...treeProps }, h("calcite-tree-item", { expanded: true, ...expandableTreeItemProps }, h("div", { class: "tree-item-label" }, this.renderArrayHeader(this.result)), this.renderArrayTree(firstItems, true)))));
3912
- }
3913
- case "geometry":
3914
- return (h("div", { class: "result-value-simple ltr-container" }, h("calcite-tree", { ...treeProps }, h("calcite-tree-item", { expanded: true, ...expandableTreeItemProps }, h("div", { class: "tree-item-label" }, this.result.type), this.renderGeometryTree(this.result.value, true)))));
3915
- case "attachment":
3916
- return (h("div", { class: "result-value-simple ltr-container" }, h("calcite-tree", { ...treeProps }, h("calcite-tree-item", { expanded: true, ...expandableTreeItemProps }, h("div", { class: "tree-item-label" }, this.result.type), this.renderDictionaryAsJsonTree(this.result.value, true)))));
3917
- case "feature":
3918
- case "dictionary":
3919
- case "portal":
3920
- return (h("div", { class: "result-value-simple ltr-container" }, h("calcite-tree", { ...treeProps }, h("calcite-tree-item", { expanded: true, ...expandableTreeItemProps }, h("div", { class: "tree-item-label" }, this.result.type), this.renderDictionaryTree(this.result.value, true)))));
3921
- case "featureSet":
3922
- return (h("div", { class: "result-value-table ltr-container" }, this.renderFeatureSetLabel(this.result), this.renderFeatureSetTable(this.result)));
3923
- default:
3924
- return (h("div", { class: "result-value-simple flex-adjustable ltr-container" }, this._t9nStrings?.runscriptmessage));
3857
+ renderLogPanel() {
3858
+ if (this.openedResultPanel !== "log") {
3859
+ return null;
3860
+ }
3861
+ if (this.loading) {
3862
+ return h("calcite-loader", { scale: "s", type: "indeterminate", label: "" });
3863
+ }
3864
+ const iconClass = this.result?.type === "error" ? "color-error" : "color-success";
3865
+ return (h("calcite-list", null, this.result ? (h(Fragment, null, h("calcite-list-item", { label: H(this._t9nStrings?.lastexecutionformat, {
3866
+ timeStamp: new Intl.DateTimeFormat(this._t9nLocale, {
3867
+ dateStyle: "medium",
3868
+ timeStyle: "medium"
3869
+ }).format(this.result.timeStamp)
3870
+ }) }, h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })), h("calcite-list-item", { label: H(this._t9nStrings?.compilationtimeformat, {
3871
+ time: new Intl.NumberFormat(this._t9nLocale, {
3872
+ style: "unit",
3873
+ unit: "millisecond",
3874
+ maximumFractionDigits: 2
3875
+ }).format(this.result.compilationTime ?? 0)
3876
+ }) }, h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })), h("calcite-list-item", { label: H(this._t9nStrings?.executiontimeformat, {
3877
+ time: new Intl.NumberFormat(this._t9nLocale, {
3878
+ style: "unit",
3879
+ unit: "millisecond",
3880
+ maximumFractionDigits: 2
3881
+ }).format(this.result.executionTime ?? 0)
3882
+ }) }, h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })))) : (h("calcite-list-item", { label: this._t9nStrings?.runscriptmessage ?? "No output, run the script once." }, h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: "color-info" })))));
3925
3883
  }
3926
- }
3927
- renderDictionaryProperty(key) {
3928
- return (h(Fragment, null, h("span", { class: "dictionary-property" }, key), h("span", null, ":\u00A0")));
3929
- }
3930
- renderSimpleValue(arcadeResult) {
3931
- switch (arcadeResult.type) {
3932
- case "unknown":
3933
- case "null":
3934
- return h("span", { class: "constant-value" }, arcadeResult.type);
3935
- case "text":
3936
- return h("span", { class: "string-value" }, z(arcadeResult.value));
3937
- case "number":
3938
- return h("span", { class: "number-value" }, arcadeResult.value.toString());
3939
- case "boolean":
3940
- return h("span", { class: "constant-value" }, arcadeResult.value.toString());
3941
- case "date":
3942
- return h("span", { class: "date-value" }, formatArcadeResultDate(arcadeResult));
3943
- case "dateOnly":
3944
- return h("span", { class: "string-value" }, z(formatArcadeResultDateOnly(arcadeResult)));
3945
- case "time":
3946
- return h("span", { class: "string-value" }, z(formatArcadeResultTimeOnly(arcadeResult)));
3947
- default:
3948
- return null;
3884
+ renderOutputPanel() {
3885
+ if (this.openedResultPanel !== "output") {
3886
+ return null;
3887
+ }
3888
+ if (this.loading) {
3889
+ return h("calcite-loader", { scale: "s", type: "indeterminate", label: "" });
3890
+ }
3891
+ switch (this.result?.type) {
3892
+ case "error":
3893
+ return (h("div", { class: "result-value-simple flex-adjustable" }, H(this._t9nStrings?.executionerrorformat, {
3894
+ message: this.result.value
3895
+ })));
3896
+ case "null":
3897
+ case "unknown":
3898
+ return h("div", { class: "result-value-simple ltr-container" }, this.renderSimpleValue(this.result));
3899
+ case "text":
3900
+ case "number":
3901
+ case "date":
3902
+ case "dateOnly":
3903
+ case "time":
3904
+ case "boolean":
3905
+ return (h("div", { class: "result-value-simple ltr-container" }, h("span", { class: "value-type" }, this.result.type, ":\u00A0"), this.renderSimpleValue(this.result)));
3906
+ case "array": {
3907
+ const items = this.result.value ?? [];
3908
+ const firstItems = items.slice(0, MaxArrayItems);
3909
+ return (h("div", { class: "result-value-simple ltr-container" }, h("calcite-tree", { ...treeProps }, h("calcite-tree-item", { expanded: true, ...expandableTreeItemProps }, h("div", { class: "tree-item-label" }, this.renderArrayHeader(this.result)), this.renderArrayTree(firstItems, true)))));
3910
+ }
3911
+ case "geometry":
3912
+ return (h("div", { class: "result-value-simple ltr-container" }, h("calcite-tree", { ...treeProps }, h("calcite-tree-item", { expanded: true, ...expandableTreeItemProps }, h("div", { class: "tree-item-label" }, this.result.type), this.renderGeometryTree(this.result.value, true)))));
3913
+ case "attachment":
3914
+ return (h("div", { class: "result-value-simple ltr-container" }, h("calcite-tree", { ...treeProps }, h("calcite-tree-item", { expanded: true, ...expandableTreeItemProps }, h("div", { class: "tree-item-label" }, this.result.type), this.renderDictionaryAsJsonTree(this.result.value, true)))));
3915
+ case "feature":
3916
+ case "dictionary":
3917
+ case "portal":
3918
+ return (h("div", { class: "result-value-simple ltr-container" }, h("calcite-tree", { ...treeProps }, h("calcite-tree-item", { expanded: true, ...expandableTreeItemProps }, h("div", { class: "tree-item-label" }, this.result.type), this.renderDictionaryTree(this.result.value, true)))));
3919
+ case "featureSet":
3920
+ return (h("div", { class: "result-value-table ltr-container" }, this.renderFeatureSetLabel(this.result), this.renderFeatureSetTable(this.result)));
3921
+ default:
3922
+ return (h("div", { class: "result-value-simple flex-adjustable ltr-container" }, this._t9nStrings?.runscriptmessage));
3923
+ }
3949
3924
  }
3950
- }
3951
- renderArrayHeader(arcadeResult) {
3952
- const items = arcadeResult.value ?? [];
3953
- const leftoverCount = Math.max(items.length - MaxArrayItems, 0);
3954
- return (h(Fragment, null, h("span", null, `${arcadeResult.type}(${items.length ?? 0})`), leftoverCount > 0 ? (h("span", null, "\u00A0", H(this._t9nStrings?.showingfirstitemsformat, {
3955
- count: MaxArrayItems.toString()
3956
- }))) : null));
3957
- }
3958
- renderArrayTree(items, subtree = false) {
3959
- return (h("calcite-tree", { slot: subtree ? "children" : undefined, ...treeProps }, items.map((value, key) => {
3960
- const arcadeValue = valueToArcadeResult(value);
3961
- return this.renderTreeItem(arcadeValue, key, !subtree);
3962
- })));
3963
- }
3964
- renderGeometryTree(value, subtree = false) {
3965
- return (h("calcite-tree", { slot: subtree ? "children" : undefined, ...treeProps }, h("calcite-tree-item", null, h("div", { class: "tree-item-label" }, this.renderDictionaryProperty("type"), value.type)), h("calcite-tree-item", null, h("div", { class: "tree-item-label" }, this.renderDictionaryProperty("value"), h("span", { class: "string-value" }, jsonFormat(value.toJSON()))))));
3966
- }
3967
- renderDictionaryAsJsonTree(value, subtree = false) {
3968
- return (h("calcite-tree", { slot: subtree ? "children" : undefined, ...treeProps }, h("calcite-tree-item", { class: "string-value" }, jsonFormat(value.castAsJson()))));
3969
- }
3970
- renderDictionaryTree(value, subtree = false) {
3971
- const geometry = value.geometry?.();
3972
- return (h("calcite-tree", { slot: subtree ? "children" : undefined, ...treeProps }, value.keys().map((key) => {
3973
- const arcadeValue = valueToArcadeResult(value.field(key));
3974
- return this.renderTreeItem(arcadeValue, key);
3975
- }), geometry ? this.renderTreeItem({ type: "geometry", value: geometry }, "geometry") : null));
3976
- }
3977
- renderTreeItem(arcadeResult, key, expanded = false) {
3978
- switch (arcadeResult.type) {
3979
- case "null":
3980
- case "unknown":
3981
- case "text":
3982
- case "number":
3983
- case "date":
3984
- case "dateOnly":
3985
- case "time":
3986
- case "boolean":
3987
- return (h("calcite-tree-item", null, h("div", { class: "tree-item-label" }, this.renderDictionaryProperty(key), this.renderSimpleValue(arcadeResult))));
3988
- case "array": {
3989
- const items = arcadeResult.value ?? [];
3990
- const firstItems = items.slice(0, MaxArrayItems);
3991
- return (h("calcite-tree-item", { expanded: expanded, ...expandableTreeItemProps }, h("div", { class: "tree-item-label" }, this.renderDictionaryProperty(key), this.renderArrayHeader(arcadeResult)), this.renderArrayTree(firstItems, true)));
3992
- }
3993
- case "geometry":
3994
- return (h("calcite-tree-item", { expanded: expanded, ...expandableTreeItemProps }, h("div", { class: "tree-item-label" }, this.renderDictionaryProperty(key), h("span", null, arcadeResult.type)), this.renderGeometryTree(arcadeResult.value, true)));
3995
- case "attachment":
3996
- return (h("calcite-tree-item", { expanded: expanded, ...expandableTreeItemProps }, h("div", { class: "tree-item-label" }, this.renderDictionaryProperty(key), h("span", null, arcadeResult.type)), this.renderDictionaryAsJsonTree(arcadeResult.value, true)));
3997
- case "feature":
3998
- case "dictionary":
3999
- case "portal":
4000
- return (h("calcite-tree-item", { expanded: expanded, ...expandableTreeItemProps }, h("div", { class: "tree-item-label" }, this.renderDictionaryProperty(key), h("span", null, arcadeResult.type)), this.renderDictionaryTree(arcadeResult.value, true)));
4001
- default:
4002
- return null;
3925
+ renderDictionaryProperty(key) {
3926
+ return (h(Fragment, null, h("span", { class: "dictionary-property" }, key), h("span", null, ":\u00A0")));
4003
3927
  }
4004
- }
4005
- renderFeatureSetLabel(arcadeResult) {
4006
- return (h("div", { class: "value-type" }, h("span", null, arcadeResult.type, ":"), arcadeResult.features.length >= BatchSize ? (h("span", null, "\u00A0", H(this._t9nStrings?.showingfirstitemsformat, {
4007
- count: BatchSize.toString()
4008
- }))) : null));
4009
- }
4010
- renderFeatureSetTable(arcadeResult) {
4011
- const fields = supportedFields(arcadeResult.value.fields);
4012
- return (h("table", null, h("thead", null, h("tr", null, fields.map((field) => (h("th", null, field.name))))), h("tbody", null, arcadeResult.features.map((feature) => {
4013
- return (h("tr", null, fields.map((field) => {
4014
- try {
4015
- const arcadeResult = valueToArcadeResult(feature.field(field.name));
4016
- return h("td", null, this.renderSimpleValue(arcadeResult));
3928
+ renderSimpleValue(arcadeResult) {
3929
+ switch (arcadeResult.type) {
3930
+ case "unknown":
3931
+ case "null":
3932
+ return h("span", { class: "constant-value" }, arcadeResult.type);
3933
+ case "text":
3934
+ return h("span", { class: "string-value" }, z(arcadeResult.value));
3935
+ case "number":
3936
+ return h("span", { class: "number-value" }, arcadeResult.value.toString());
3937
+ case "boolean":
3938
+ return h("span", { class: "constant-value" }, arcadeResult.value.toString());
3939
+ case "date":
3940
+ return h("span", { class: "date-value" }, formatArcadeResultDate(arcadeResult));
3941
+ case "dateOnly":
3942
+ return h("span", { class: "string-value" }, z(formatArcadeResultDateOnly(arcadeResult)));
3943
+ case "time":
3944
+ return h("span", { class: "string-value" }, z(formatArcadeResultTimeOnly(arcadeResult)));
3945
+ default:
3946
+ return null;
4017
3947
  }
4018
- catch (e) {
4019
- return h("td", null);
3948
+ }
3949
+ renderArrayHeader(arcadeResult) {
3950
+ const items = arcadeResult.value ?? [];
3951
+ const leftoverCount = Math.max(items.length - MaxArrayItems, 0);
3952
+ return (h(Fragment, null, h("span", null, `${arcadeResult.type}(${items.length ?? 0})`), leftoverCount > 0 ? (h("span", null, "\u00A0", H(this._t9nStrings?.showingfirstitemsformat, {
3953
+ count: MaxArrayItems.toString()
3954
+ }))) : null));
3955
+ }
3956
+ renderArrayTree(items, subtree = false) {
3957
+ return (h("calcite-tree", { slot: subtree ? "children" : undefined, ...treeProps }, items.map((value, key) => {
3958
+ const arcadeValue = valueToArcadeResult(value);
3959
+ return this.renderTreeItem(arcadeValue, key, !subtree);
3960
+ })));
3961
+ }
3962
+ renderGeometryTree(value, subtree = false) {
3963
+ return (h("calcite-tree", { slot: subtree ? "children" : undefined, ...treeProps }, h("calcite-tree-item", null, h("div", { class: "tree-item-label" }, this.renderDictionaryProperty("type"), value.type)), h("calcite-tree-item", null, h("div", { class: "tree-item-label" }, this.renderDictionaryProperty("value"), h("span", { class: "string-value" }, jsonFormat(value.toJSON()))))));
3964
+ }
3965
+ renderDictionaryAsJsonTree(value, subtree = false) {
3966
+ return (h("calcite-tree", { slot: subtree ? "children" : undefined, ...treeProps }, h("calcite-tree-item", { class: "string-value" }, jsonFormat(value.castAsJson()))));
3967
+ }
3968
+ renderDictionaryTree(value, subtree = false) {
3969
+ const geometry = value.geometry?.();
3970
+ return (h("calcite-tree", { slot: subtree ? "children" : undefined, ...treeProps }, value.keys().map((key) => {
3971
+ const arcadeValue = valueToArcadeResult(value.field(key));
3972
+ return this.renderTreeItem(arcadeValue, key);
3973
+ }), geometry ? this.renderTreeItem({ type: "geometry", value: geometry }, "geometry") : null));
3974
+ }
3975
+ renderTreeItem(arcadeResult, key, expanded = false) {
3976
+ switch (arcadeResult.type) {
3977
+ case "null":
3978
+ case "unknown":
3979
+ case "text":
3980
+ case "number":
3981
+ case "date":
3982
+ case "dateOnly":
3983
+ case "time":
3984
+ case "boolean":
3985
+ return (h("calcite-tree-item", null, h("div", { class: "tree-item-label" }, this.renderDictionaryProperty(key), this.renderSimpleValue(arcadeResult))));
3986
+ case "array": {
3987
+ const items = arcadeResult.value ?? [];
3988
+ const firstItems = items.slice(0, MaxArrayItems);
3989
+ return (h("calcite-tree-item", { expanded: expanded, ...expandableTreeItemProps }, h("div", { class: "tree-item-label" }, this.renderDictionaryProperty(key), this.renderArrayHeader(arcadeResult)), this.renderArrayTree(firstItems, true)));
3990
+ }
3991
+ case "geometry":
3992
+ return (h("calcite-tree-item", { expanded: expanded, ...expandableTreeItemProps }, h("div", { class: "tree-item-label" }, this.renderDictionaryProperty(key), h("span", null, arcadeResult.type)), this.renderGeometryTree(arcadeResult.value, true)));
3993
+ case "attachment":
3994
+ return (h("calcite-tree-item", { expanded: expanded, ...expandableTreeItemProps }, h("div", { class: "tree-item-label" }, this.renderDictionaryProperty(key), h("span", null, arcadeResult.type)), this.renderDictionaryAsJsonTree(arcadeResult.value, true)));
3995
+ case "feature":
3996
+ case "dictionary":
3997
+ case "portal":
3998
+ return (h("calcite-tree-item", { expanded: expanded, ...expandableTreeItemProps }, h("div", { class: "tree-item-label" }, this.renderDictionaryProperty(key), h("span", null, arcadeResult.type)), this.renderDictionaryTree(arcadeResult.value, true)));
3999
+ default:
4000
+ return null;
4020
4001
  }
4021
- })));
4022
- }))));
4023
- }
4024
- render() {
4025
- return (h(Host, null, h("header", { class: "flex-row" }, h("calcite-action-bar", { class: "flex-adjustable", layout: "horizontal", scale: "s", expanded: true, "expand-disabled": true }, h("calcite-action-group", { scale: "s" }, h("calcite-action", { active: this.openedResultPanel === "output", text: this._t9nStrings?.output ?? "Output", "text-enabled": true, scale: "s", icon: "list-show-all", iconFlipRtl: true, onClick: this._switchResultPanel, "data-panel-name": "output" }), h("calcite-action", { active: this.openedResultPanel === "console", text: this._t9nStrings?.console ?? "Console", "text-enabled": true, scale: "s", icon: "console", iconFlipRtl: true, onClick: this._switchResultPanel, "data-panel-name": "console" }), h("calcite-action", { active: this.openedResultPanel === "log", text: this._t9nStrings?.log ?? "Log", "text-enabled": true, scale: "s", icon: "list", iconFlipRtl: true, onClick: this._switchResultPanel, "data-panel-name": "log" }))), h("calcite-action", { scale: "s", icon: "x", text: this._t9nStrings?.close ?? "", onClick: this._emitClose })), h("article", { class: "flex-adjustable" }, this.loading ? (h("calcite-loader", { scale: "s", type: "indeterminate", label: "" })) : (h("div", { class: "flex-column y-scrollable-container" }, this.renderOutputPanel(), this.renderConsolePanel(), this.renderLogPanel())))));
4026
- }
4027
- static get assetsDirs() { return ["assets"]; }
4028
- get _hostElement() { return getElement(this); }
4002
+ }
4003
+ renderFeatureSetLabel(arcadeResult) {
4004
+ return (h("div", { class: "value-type" }, h("span", null, arcadeResult.type, ":"), arcadeResult.features.length >= BatchSize ? (h("span", null, "\u00A0", H(this._t9nStrings?.showingfirstitemsformat, {
4005
+ count: BatchSize.toString()
4006
+ }))) : null));
4007
+ }
4008
+ renderFeatureSetTable(arcadeResult) {
4009
+ const fields = supportedFields(arcadeResult.value.fields);
4010
+ return (h("table", null, h("thead", null, h("tr", null, fields.map((field) => (h("th", null, field.name))))), h("tbody", null, arcadeResult.features.map((feature) => (h("tr", null, fields.map((field) => {
4011
+ try {
4012
+ const arcadeResult = valueToArcadeResult(feature.field(field.name));
4013
+ return h("td", null, this.renderSimpleValue(arcadeResult));
4014
+ }
4015
+ catch (e) {
4016
+ return h("td", null);
4017
+ }
4018
+ })))))));
4019
+ }
4020
+ render() {
4021
+ return (h(Host, null, h("header", { class: "flex-row" }, h("calcite-action-bar", { class: "flex-adjustable", layout: "horizontal", scale: "s", expanded: true, "expand-disabled": true }, h("calcite-action-group", { scale: "s" }, h("calcite-action", { active: this.openedResultPanel === "output", text: this._t9nStrings?.output ?? "Output", "text-enabled": true, scale: "s", icon: "list-show-all", iconFlipRtl: true, onClick: this._switchResultPanel, "data-panel-name": "output" }), h("calcite-action", { active: this.openedResultPanel === "console", text: this._t9nStrings?.console ?? "Console", "text-enabled": true, scale: "s", icon: "console", iconFlipRtl: true, onClick: this._switchResultPanel, "data-panel-name": "console" }), h("calcite-action", { active: this.openedResultPanel === "log", text: this._t9nStrings?.log ?? "Log", "text-enabled": true, scale: "s", icon: "list", iconFlipRtl: true, onClick: this._switchResultPanel, "data-panel-name": "log" }))), h("calcite-action", { scale: "s", icon: "x", text: this._t9nStrings?.close ?? "", onClick: this._emitClose })), h("article", { class: "flex-adjustable" }, this.loading ? (h("calcite-loader", { scale: "s", type: "indeterminate", label: "" })) : (h("div", { class: "flex-column y-scrollable-container" }, this.renderOutputPanel(), this.renderConsolePanel(), this.renderLogPanel())))));
4022
+ }
4023
+ static get assetsDirs() { return ["assets"]; }
4024
+ get _hostElement() { return getElement(this); }
4029
4025
  };
4030
4026
  ArcgisArcadeResults.style = arcadeResultsCss;
4031
4027
 
4032
4028
  function isSuggestionGroups(item) {
4033
- if (!Array.isArray(item)) {
4034
- return false;
4035
- }
4036
- if (!item.length) {
4037
- return false;
4038
- }
4039
- return Array.isArray(item[0]?.suggestions);
4029
+ if (!Array.isArray(item)) {
4030
+ return false;
4031
+ }
4032
+ if (!item.length) {
4033
+ return false;
4034
+ }
4035
+ return Array.isArray(item[0]?.suggestions);
4040
4036
  }
4041
4037
 
4042
4038
  const arcadeSuggestionsCss = ":host{background-color:var(--calcite-ui-foreground-1)}:host .notice-container{margin:var(--calcite-spacing-quarter);padding:var(--calcite-spacing-half);background-color:var(--calcite-ui-foreground-1)}:host .sticky{position:sticky;top:0px;z-index:10}:host calcite-flow{height:100%}:host calcite-block p:first-of-type{margin-top:0}:host calcite-block code{font-family:var(--calcite-code-family)}:host calcite-block pre{direction:ltr;overflow-x:auto;background-color:var(--calcite-ui-foreground-2);padding:var(--calcite-spacing-half)}:host calcite-block pre code{font-size:var(--calcite-font-size--2)}";
4043
4039
 
4044
4040
  const ArcgisArcadeSuggestions = class {
4045
- constructor(hostRef) {
4046
- registerInstance(this, hostRef);
4047
- this.close = createEvent(this, "close", 3);
4048
- this.itemSelected = createEvent(this, "itemSelected", 3);
4049
- // @ts-expect-error
4050
- this._updateFilterValue = (e) => (this._filterValue = e.target?.["value"] ?? "");
4051
- this._emitItemSelected = (e) => {
4052
- // @ts-expect-error
4053
- const item = e.target?.["data-item"];
4054
- if (!item) {
4055
- return;
4056
- }
4057
- const keyEvent = e;
4058
- if (!keyEvent.key || keyEvent.key === "Enter") {
4059
- e.preventDefault();
4060
- this.itemSelected.emit(item.code);
4061
- }
4062
- };
4063
- this._showSuggestionDetail = (e) => {
4064
- // @ts-expect-error
4065
- const item = e.target?.["data-item"];
4066
- if (!item) {
4067
- return;
4068
- }
4069
- e.stopPropagation();
4070
- this._selectedSuggestion = item;
4071
- };
4072
- this._emitClose = () => this.close.emit();
4073
- this._beforeBack = async () => (this._selectedSuggestion = undefined);
4074
- this._lang = "";
4075
- this._t9nLocale = "";
4076
- this._t9nStrings = undefined;
4077
- this._selectedSuggestion = undefined;
4078
- this._filterValue = "";
4079
- this._colorizeStyle = "";
4080
- this.suggestions = undefined;
4081
- }
4082
- suggestionsPropChanged() {
4083
- this._selectedSuggestion = undefined;
4084
- }
4085
- //#endregion
4086
- // #region Component lifecycle events
4087
- async componentWillLoad() {
4088
- this._colorizeStyle = generateColorizeStyles();
4089
- this._themeChangedListner = onColorizeThemeChanged(() => (this._colorizeStyle = generateColorizeStyles()));
4090
- await F(this, getAssetPath("./assets"));
4091
- }
4092
- disconnectedCallback() {
4093
- this._flowObserver?.disconnect();
4094
- this._themeChangedListner?.dispose();
4095
- U(this);
4096
- }
4097
- // #endregion
4098
- //#region Private Methods
4099
- flowFocusHandler(ref) {
4100
- // When a flow is removed from the document then a null ref will be passed in
4101
- if (!ref) {
4102
- this._flowObserver?.disconnect();
4103
- this._flowObserver = undefined;
4104
- return;
4041
+ constructor(hostRef) {
4042
+ registerInstance(this, hostRef);
4043
+ this.close = createEvent(this, "close", 3);
4044
+ this.itemSelected = createEvent(this, "itemSelected", 3);
4045
+ // @ts-expect-error
4046
+ this._updateFilterValue = (e) => (this._filterValue = e.target?.value ?? "");
4047
+ this._emitItemSelected = (e) => {
4048
+ // @ts-expect-error
4049
+ const item = e.target?.["data-item"];
4050
+ if (!item) {
4051
+ return;
4052
+ }
4053
+ const keyEvent = e;
4054
+ if (!keyEvent.key || keyEvent.key === "Enter") {
4055
+ e.preventDefault();
4056
+ this.itemSelected.emit(item.code);
4057
+ }
4058
+ };
4059
+ this._showSuggestionDetail = (e) => {
4060
+ // @ts-expect-error
4061
+ const item = e.target?.["data-item"];
4062
+ if (!item) {
4063
+ return;
4064
+ }
4065
+ e.stopPropagation();
4066
+ this._selectedSuggestion = item;
4067
+ };
4068
+ this._emitClose = () => this.close.emit();
4069
+ this._beforeBack = async () => (this._selectedSuggestion = undefined);
4070
+ this._lang = "";
4071
+ this._t9nLocale = "";
4072
+ this._t9nStrings = undefined;
4073
+ this._selectedSuggestion = undefined;
4074
+ this._filterValue = "";
4075
+ this._colorizeStyle = "";
4076
+ this.suggestions = undefined;
4105
4077
  }
4106
- if (this._flowObserver) {
4107
- return;
4078
+ suggestionsPropChanged() {
4079
+ this._selectedSuggestion = undefined;
4108
4080
  }
4109
- // Observer panel added/removed and also observe the flow id
4110
- // When switching between flow the same reference is reused
4111
- this._flowObserver = new MutationObserver(() => {
4112
- // Get the last panel and try to set focus on the input element
4113
- O(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
4114
- });
4115
- this._flowObserver.observe(ref, { attributes: true, attributeFilter: ["id"], childList: true });
4116
- }
4117
- //#endregion
4118
- //#region Renderers
4119
- renderSuggestionGroups() {
4120
- if (this.suggestions === undefined) {
4121
- return null;
4081
+ //#endregion
4082
+ // #region Component lifecycle events
4083
+ async componentWillLoad() {
4084
+ this._colorizeStyle = generateColorizeStyles();
4085
+ this._themeChangedListner = onColorizeThemeChanged(() => (this._colorizeStyle = generateColorizeStyles()));
4086
+ await F(this, getAssetPath("./assets"));
4122
4087
  }
4123
- if (isSuggestionGroups(this.suggestions)) {
4124
- return this.suggestions.map((suggestionGroup) => {
4125
- return (h("calcite-list-item-group", { heading: suggestionGroup.label }, this.renderSuggestionListItems(suggestionGroup.suggestions)));
4126
- });
4088
+ disconnectedCallback() {
4089
+ this._flowObserver?.disconnect();
4090
+ this._themeChangedListner?.dispose();
4091
+ U(this);
4127
4092
  }
4128
- return this.renderSuggestionListItems(this.suggestions);
4129
- }
4130
- renderSuggestionListItems(suggestions) {
4131
- suggestions = filterCollection(suggestions, "label", this._filterValue);
4132
- if (!suggestions.length) {
4133
- return h("div", { class: "notice-container" }, this._t9nStrings?.noitems ?? "No item");
4093
+ // #endregion
4094
+ //#region Private Methods
4095
+ flowFocusHandler(ref) {
4096
+ // When a flow is removed from the document then a null ref will be passed in
4097
+ if (!ref) {
4098
+ this._flowObserver?.disconnect();
4099
+ this._flowObserver = undefined;
4100
+ return;
4101
+ }
4102
+ if (this._flowObserver) {
4103
+ return;
4104
+ }
4105
+ // Observer panel added/removed and also observe the flow id
4106
+ // When switching between flow the same reference is reused
4107
+ this._flowObserver = new MutationObserver(() => {
4108
+ // Get the last panel and try to set focus on the input element
4109
+ O(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
4110
+ });
4111
+ this._flowObserver.observe(ref, { attributes: true, attributeFilter: ["id"], childList: true });
4134
4112
  }
4135
- return suggestions.map((suggestion) => (h("calcite-list-item", { label: suggestion.label, description: suggestion.description, onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": suggestion }, h("calcite-action", { slot: "actions-end", text: this._t9nStrings?.expand ?? "", scale: "s", icon: "chevron-right", iconFlipRtl: true, onClick: this._showSuggestionDetail, "data-item": suggestion }))));
4136
- }
4137
- renderSuggestionFlowItem() {
4138
- const suggestion = this._selectedSuggestion;
4139
- if (!suggestion) {
4140
- return null;
4113
+ //#endregion
4114
+ //#region Renderers
4115
+ renderSuggestionGroups() {
4116
+ if (this.suggestions === undefined) {
4117
+ return null;
4118
+ }
4119
+ if (isSuggestionGroups(this.suggestions)) {
4120
+ return this.suggestions.map((suggestionGroup) => (h("calcite-list-item-group", { heading: suggestionGroup.label }, this.renderSuggestionListItems(suggestionGroup.suggestions))));
4121
+ }
4122
+ return this.renderSuggestionListItems(this.suggestions);
4141
4123
  }
4142
- return (h("calcite-flow-item", { heading: this._t9nStrings?.suggestions, closable: true, onCalciteFlowItemClose: this._emitClose, beforeBack: this._beforeBack }, h("calcite-button", { width: "half", slot: "footer", appearance: "outline", kind: "brand", "icon-start": "code", scale: "s", onClick: this._emitItemSelected, ref: (e) => e?.setFocus(), "data-item": suggestion }, this._t9nStrings?.insert), h("calcite-block", { open: true, heading: suggestion.label, description: suggestion.description }, h("div", { innerHTML: convertMarkdownString(suggestion.documentation) }), h("pre", null, h("code", { ref: async (e) => await colorizeCodeElement(e, suggestion.code) })))));
4143
- }
4144
- render() {
4145
- return (h(Host, null, h("style", null, this._colorizeStyle), h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, h("calcite-flow-item", { heading: this._t9nStrings?.suggestions, closable: true, onCalciteFlowItemClose: this._emitClose }, h(StickyFilterInput, { filterValue: this._filterValue, onCalciteInputInput: this._updateFilterValue }), h("calcite-list", null, this.renderSuggestionGroups())), this.renderSuggestionFlowItem())));
4146
- }
4147
- static get assetsDirs() { return ["assets"]; }
4148
- get _hostElement() { return getElement(this); }
4149
- static get watchers() { return {
4150
- "suggestions": ["suggestionsPropChanged"]
4151
- }; }
4124
+ renderSuggestionListItems(suggestions) {
4125
+ suggestions = filterCollection(suggestions, "label", this._filterValue);
4126
+ if (!suggestions.length) {
4127
+ return h("div", { class: "notice-container" }, this._t9nStrings?.noitems ?? "No item");
4128
+ }
4129
+ return suggestions.map((suggestion) => (h("calcite-list-item", { label: suggestion.label, description: suggestion.description, onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": suggestion }, h("calcite-action", { slot: "actions-end", text: this._t9nStrings?.expand ?? "", scale: "s", icon: "chevron-right", iconFlipRtl: true, onClick: this._showSuggestionDetail, "data-item": suggestion }))));
4130
+ }
4131
+ renderSuggestionFlowItem() {
4132
+ const suggestion = this._selectedSuggestion;
4133
+ if (!suggestion) {
4134
+ return null;
4135
+ }
4136
+ return (h("calcite-flow-item", { heading: this._t9nStrings?.suggestions, closable: true, onCalciteFlowItemClose: this._emitClose, beforeBack: this._beforeBack }, h("calcite-button", { width: "half", slot: "footer", appearance: "outline", kind: "brand", "icon-start": "code", scale: "s", onClick: this._emitItemSelected, ref: (e) => e?.setFocus(), "data-item": suggestion }, this._t9nStrings?.insert), h("calcite-block", { open: true, heading: suggestion.label, description: suggestion.description }, h("div", { innerHTML: convertMarkdownString(suggestion.documentation) }), h("pre", null, h("code", { ref: async (e) => await colorizeCodeElement(e, suggestion.code) })))));
4137
+ }
4138
+ render() {
4139
+ return (h(Host, null, h("style", null, this._colorizeStyle), h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, h("calcite-flow-item", { heading: this._t9nStrings?.suggestions, closable: true, onCalciteFlowItemClose: this._emitClose }, h(StickyFilterInput, { filterValue: this._filterValue, onCalciteInputInput: this._updateFilterValue }), h("calcite-list", null, this.renderSuggestionGroups())), this.renderSuggestionFlowItem())));
4140
+ }
4141
+ static get assetsDirs() { return ["assets"]; }
4142
+ get _hostElement() { return getElement(this); }
4143
+ static get watchers() { return {
4144
+ "suggestions": ["suggestionsPropChanged"]
4145
+ }; }
4152
4146
  };
4153
4147
  ArcgisArcadeSuggestions.style = arcadeSuggestionsCss;
4154
4148
 
4155
4149
  const arcadeVariablesCss = ":host{background-color:var(--calcite-ui-foreground-1)}:host .notice-container{margin:var(--calcite-spacing-quarter);padding:var(--calcite-spacing-half);background-color:var(--calcite-ui-foreground-1)}:host .sticky{position:sticky;top:0px;z-index:10}:host calcite-flow{height:100%}";
4156
4150
 
4157
4151
  const ArcgisArcadeVariables = class {
4158
- constructor(hostRef) {
4159
- registerInstance(this, hostRef);
4160
- this.close = createEvent(this, "close", 3);
4161
- this.itemSelected = createEvent(this, "itemSelected", 3);
4162
- // @ts-expect-error
4163
- this._updateFilterValue = (e) => (this._filterValue = e.target?.["value"] ?? "");
4164
- this._beforeBack = async () => {
4165
- this.removeLastPanelRenderer();
4166
- this._filterValue = "";
4167
- };
4168
- this._emitClose = () => this.close.emit();
4169
- this._backToTop = () => (this._flowItemRenderers = []);
4170
- this._emitItemSelected = (e) => {
4171
- // @ts-expect-error
4172
- const variable = e.target?.["data-item"];
4173
- if (!variable || variable.nonInteractive) {
4174
- return;
4175
- }
4176
- const keyEvent = e;
4177
- if (!keyEvent.key || keyEvent.key === "Enter") {
4178
- e.preventDefault();
4179
- this.itemSelected.emit(variable.snippet);
4180
- }
4181
- };
4182
- this._stopEnterPropagation = (e) => {
4183
- if (e.key === "Enter") {
4184
- e.stopPropagation();
4185
- }
4186
- };
4187
- this._showCollectionPanel = (e) => {
4188
- // @ts-expect-error
4189
- const collectionVariable = e.target?.["data-item"];
4190
- if (!collectionVariable) {
4191
- return;
4192
- }
4193
- e.stopPropagation();
4194
- this.addPanelRenderer(this.collectionBasedVariableRenderer(collectionVariable));
4195
- };
4196
- this._lang = "";
4197
- this._t9nLocale = "";
4198
- this._t9nStrings = undefined;
4199
- this._mutationCounter = 1;
4200
- this._flowItemRenderers = [];
4201
- this._filterValue = "";
4202
- this.loading = false;
4203
- this.modelId = undefined;
4204
- }
4205
- modelIdPropChanged() {
4206
- this._flowItemRenderers = [];
4207
- }
4208
- //#endregion
4209
- // #region Component lifecycle events
4210
- async componentWillLoad() {
4211
- await F(this, getAssetPath("./assets"));
4212
- }
4213
- disconnectedCallback() {
4214
- U(this);
4215
- this._flowObserver?.disconnect();
4216
- }
4217
- // #endregion
4218
- //#region Private Methods
4219
- addPanelRenderer(panelRenderer) {
4220
- this._flowItemRenderers = [...this._flowItemRenderers, panelRenderer];
4221
- }
4222
- removeLastPanelRenderer() {
4223
- this._flowItemRenderers = this._flowItemRenderers.slice(0, -1);
4224
- }
4225
- flowFocusHandler(ref) {
4226
- // When a flow is removed from the document then a null ref will be passed in
4227
- if (!ref) {
4228
- this._flowObserver?.disconnect();
4229
- this._flowObserver = undefined;
4230
- return;
4152
+ constructor(hostRef) {
4153
+ registerInstance(this, hostRef);
4154
+ this.close = createEvent(this, "close", 3);
4155
+ this.itemSelected = createEvent(this, "itemSelected", 3);
4156
+ // @ts-expect-error
4157
+ this._updateFilterValue = (e) => (this._filterValue = e.target?.value ?? "");
4158
+ this._beforeBack = async () => {
4159
+ this.removeLastPanelRenderer();
4160
+ this._filterValue = "";
4161
+ };
4162
+ this._emitClose = () => this.close.emit();
4163
+ this._backToTop = () => (this._flowItemRenderers = []);
4164
+ this._emitItemSelected = (e) => {
4165
+ // @ts-expect-error
4166
+ const variable = e.target?.["data-item"];
4167
+ if (!variable || variable.nonInteractive) {
4168
+ return;
4169
+ }
4170
+ const keyEvent = e;
4171
+ if (!keyEvent.key || keyEvent.key === "Enter") {
4172
+ e.preventDefault();
4173
+ this.itemSelected.emit(variable.snippet);
4174
+ }
4175
+ };
4176
+ this._stopEnterPropagation = (e) => {
4177
+ if (e.key === "Enter") {
4178
+ e.stopPropagation();
4179
+ }
4180
+ };
4181
+ this._showCollectionPanel = (e) => {
4182
+ // @ts-expect-error
4183
+ const collectionVariable = e.target?.["data-item"];
4184
+ if (!collectionVariable) {
4185
+ return;
4186
+ }
4187
+ e.stopPropagation();
4188
+ this.addPanelRenderer(this.collectionBasedVariableRenderer(collectionVariable));
4189
+ };
4190
+ this._lang = "";
4191
+ this._t9nLocale = "";
4192
+ this._t9nStrings = undefined;
4193
+ this._mutationCounter = 1;
4194
+ this._flowItemRenderers = [];
4195
+ this._filterValue = "";
4196
+ this.loading = false;
4197
+ this.modelId = undefined;
4231
4198
  }
4232
- if (this._flowObserver) {
4233
- return;
4199
+ modelIdPropChanged() {
4200
+ this._flowItemRenderers = [];
4234
4201
  }
4235
- // Observer panel added/removed and also observe the flow id
4236
- // When switching between flow the same reference is reused
4237
- this._flowObserver = new MutationObserver(() => {
4238
- // Get the last panel and try to set focus on the input element
4239
- O(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
4240
- });
4241
- this._flowObserver.observe(ref, { attributes: true, attributeFilter: ["id"], childList: true });
4242
- }
4243
- //#endregion
4244
- //#region Renderers
4245
- collectionBasedVariableRenderer(collection, topPanel = false) {
4246
- // Returns a function to be added to the subpanel render collection
4247
- return () => {
4248
- if (!collection) {
4249
- return null;
4250
- }
4251
- // If the collection actually exists then two options:
4252
- // - the collection still need to be loaded
4253
- // - the collection is ready
4254
- let loading = this.loading;
4255
- if (!loading && !collection.loaded) {
4256
- // Request to load and update mutation counter when done
4257
- collection.loadSource().then(() => setTimeout(() => this._mutationCounter++));
4258
- loading = true;
4259
- }
4260
- return (h("calcite-flow-item", { heading: this._t9nStrings?.profilevariables, beforeBack: this._beforeBack, closable: true, onCalciteFlowItemClose: this._emitClose }, h("calcite-action", { slot: "header-actions-end", text: this._t9nStrings?.backtotop ?? "Back to top", scale: "m", hidden: topPanel, icon: "chevrons-left", iconFlipRtl: true, onClick: this._backToTop }), h(StickyFilterInput, { filterValue: this._filterValue, onCalciteInputInput: this._updateFilterValue }), loading ? (h("calcite-loader", { scale: "s", type: "indeterminate", label: this._t9nStrings?.loading ?? "Loading" })) : (h("calcite-list", null, this.renderEditorVariables(collection)))));
4261
- };
4262
- }
4263
- renderEditorVariables(collection) {
4264
- // Filter the variables. Skip group, we will filter the children later on.
4265
- const filterExpression = B(this._filterValue);
4266
- const filteredVariables = collection.variables.filter((variable) => variable.passFilter(filterExpression));
4267
- if (!filteredVariables.length) {
4268
- return h("div", { class: "notice-container" }, this._t9nStrings?.noitems ?? "No item");
4269
- }
4270
- return filteredVariables.map((variable) => this.renderEditorVariable(variable));
4271
- }
4272
- renderEditorVariable(variable) {
4273
- switch (variable.type) {
4274
- case "group":
4275
- // Group is a collection but we represent it differently
4276
- return (h("calcite-list-item-group", { heading: variable.getLabel() }, this.renderEditorVariables(variable)));
4277
- default:
4278
- return (h("calcite-list-item", { label: variable.getLabel(), description: variable.getDescription(), onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": variable }, variable.isCollection ? (h("calcite-action", { slot: "actions-end", text: this._t9nStrings?.expand ?? "", scale: "s", icon: "chevron-right", iconFlipRtl: true, onClick: this._showCollectionPanel, onKeyPress: this._stopEnterPropagation, "data-item": variable })) : null, variable.icon ? h("calcite-icon", { icon: variable.icon, scale: "s", slot: "content-start" }) : null));
4202
+ //#endregion
4203
+ // #region Component lifecycle events
4204
+ async componentWillLoad() {
4205
+ await F(this, getAssetPath("./assets"));
4279
4206
  }
4280
- }
4281
- render() {
4282
- const profile = arcadeDefaults.getEditorProfileForModel(this.modelId ?? "");
4283
- if (!this.loading && !profile?.variables.length) {
4284
- return (h("calcite-flow", null, h("calcite-flow-item", { heading: this._t9nStrings?.profilevariables, closable: true, onCalciteFlowItemClose: this._emitClose }, h("div", { class: "notice-container" }, this._t9nStrings?.noprofilevariablesmessage ?? ""))));
4207
+ disconnectedCallback() {
4208
+ U(this);
4209
+ this._flowObserver?.disconnect();
4285
4210
  }
4286
- return (h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, this.collectionBasedVariableRenderer(profile, true)(), this._flowItemRenderers.map((renderer) => renderer())));
4287
- }
4288
- static get assetsDirs() { return ["assets"]; }
4289
- get _hostElement() { return getElement(this); }
4290
- static get watchers() { return {
4291
- "modelId": ["modelIdPropChanged"]
4292
- }; }
4211
+ // #endregion
4212
+ //#region Private Methods
4213
+ addPanelRenderer(panelRenderer) {
4214
+ this._flowItemRenderers = [...this._flowItemRenderers, panelRenderer];
4215
+ }
4216
+ removeLastPanelRenderer() {
4217
+ this._flowItemRenderers = this._flowItemRenderers.slice(0, -1);
4218
+ }
4219
+ flowFocusHandler(ref) {
4220
+ // When a flow is removed from the document then a null ref will be passed in
4221
+ if (!ref) {
4222
+ this._flowObserver?.disconnect();
4223
+ this._flowObserver = undefined;
4224
+ return;
4225
+ }
4226
+ if (this._flowObserver) {
4227
+ return;
4228
+ }
4229
+ // Observer panel added/removed and also observe the flow id
4230
+ // When switching between flow the same reference is reused
4231
+ this._flowObserver = new MutationObserver(() => {
4232
+ // Get the last panel and try to set focus on the input element
4233
+ O(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
4234
+ });
4235
+ this._flowObserver.observe(ref, { attributes: true, attributeFilter: ["id"], childList: true });
4236
+ }
4237
+ //#endregion
4238
+ //#region Renderers
4239
+ collectionBasedVariableRenderer(collection, topPanel = false) {
4240
+ // Returns a function to be added to the subpanel render collection
4241
+ return () => {
4242
+ if (!collection) {
4243
+ return null;
4244
+ }
4245
+ // If the collection actually exists then two options:
4246
+ // - the collection still need to be loaded
4247
+ // - the collection is ready
4248
+ let loading = this.loading;
4249
+ if (!loading && !collection.loaded) {
4250
+ // Request to load and update mutation counter when done
4251
+ collection.loadSource().then(() => setTimeout(() => {
4252
+ this._mutationCounter += 1;
4253
+ }));
4254
+ loading = true;
4255
+ }
4256
+ return (h("calcite-flow-item", { heading: this._t9nStrings?.profilevariables, beforeBack: this._beforeBack, closable: true, onCalciteFlowItemClose: this._emitClose }, h("calcite-action", { slot: "header-actions-end", text: this._t9nStrings?.backtotop ?? "Back to top", scale: "m", hidden: topPanel, icon: "chevrons-left", iconFlipRtl: true, onClick: this._backToTop }), h(StickyFilterInput, { filterValue: this._filterValue, onCalciteInputInput: this._updateFilterValue }), loading ? (h("calcite-loader", { scale: "s", type: "indeterminate", label: this._t9nStrings?.loading ?? "Loading" })) : (h("calcite-list", null, this.renderEditorVariables(collection)))));
4257
+ };
4258
+ }
4259
+ renderEditorVariables(collection) {
4260
+ // Filter the variables. Skip group, we will filter the children later on.
4261
+ const filterExpression = B(this._filterValue);
4262
+ const filteredVariables = collection.variables.filter((variable) => variable.passFilter(filterExpression));
4263
+ if (!filteredVariables.length) {
4264
+ return h("div", { class: "notice-container" }, this._t9nStrings?.noitems ?? "No item");
4265
+ }
4266
+ return filteredVariables.map((variable) => this.renderEditorVariable(variable));
4267
+ }
4268
+ renderEditorVariable(variable) {
4269
+ switch (variable.type) {
4270
+ case "group":
4271
+ // Group is a collection but we represent it differently
4272
+ return (h("calcite-list-item-group", { heading: variable.getLabel() }, this.renderEditorVariables(variable)));
4273
+ default:
4274
+ return (h("calcite-list-item", { label: variable.getLabel(), description: variable.getDescription(), onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": variable }, variable.isCollection ? (h("calcite-action", { slot: "actions-end", text: this._t9nStrings?.expand ?? "", scale: "s", icon: "chevron-right", iconFlipRtl: true, onClick: this._showCollectionPanel, onKeyPress: this._stopEnterPropagation, "data-item": variable })) : null, variable.icon ? h("calcite-icon", { icon: variable.icon, scale: "s", slot: "content-start" }) : null));
4275
+ }
4276
+ }
4277
+ render() {
4278
+ const profile = arcadeDefaults.getEditorProfileForModel(this.modelId ?? "");
4279
+ if (!this.loading && !profile?.variables.length) {
4280
+ return (h("calcite-flow", null, h("calcite-flow-item", { heading: this._t9nStrings?.profilevariables, closable: true, onCalciteFlowItemClose: this._emitClose }, h("div", { class: "notice-container" }, this._t9nStrings?.noprofilevariablesmessage ?? ""))));
4281
+ }
4282
+ return (h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, this.collectionBasedVariableRenderer(profile, true)(), this._flowItemRenderers.map((renderer) => renderer())));
4283
+ }
4284
+ static get assetsDirs() { return ["assets"]; }
4285
+ get _hostElement() { return getElement(this); }
4286
+ static get watchers() { return {
4287
+ "modelId": ["modelIdPropChanged"]
4288
+ }; }
4293
4289
  };
4294
4290
  ArcgisArcadeVariables.style = arcadeVariablesCss;
4295
4291
 
@@ -4297,243 +4293,243 @@ const codeEditorCss = "@charset \"UTF-8\";.monaco-action-bar{white-space:nowrap;
4297
4293
 
4298
4294
  // Our default options for the Editor
4299
4295
  const EditorOptionsDefaults = {
4300
- autoIndent: "advanced",
4301
- automaticLayout: true,
4302
- bracketPairColorization: { enabled: true },
4303
- minimap: { enabled: false },
4304
- renderLineHighlight: "none",
4305
- suggest: {
4306
- snippetsPreventQuickSuggestions: false,
4307
- showWords: false
4308
- },
4309
- tabSize: 2,
4310
- useShadowDOM: true
4296
+ autoIndent: "advanced",
4297
+ automaticLayout: true,
4298
+ bracketPairColorization: { enabled: true },
4299
+ minimap: { enabled: false },
4300
+ renderLineHighlight: "none",
4301
+ suggest: {
4302
+ snippetsPreventQuickSuggestions: false,
4303
+ showWords: false
4304
+ },
4305
+ tabSize: 2,
4306
+ useShadowDOM: true
4311
4307
  };
4312
4308
  const ArcgisCodeEditor = class {
4313
- constructor(hostRef) {
4314
- registerInstance(this, hostRef);
4315
- this.valueChange = createEvent(this, "valueChange", 3);
4316
- this._componentReadyDefer = new p();
4317
- this._disposables = [];
4318
- this.value = undefined;
4319
- this.language = undefined;
4320
- this.modelId = "";
4321
- }
4322
- valuePropChange(newValue, oldValue) {
4323
- if (!this._editorInstance || newValue === oldValue) {
4324
- return;
4309
+ constructor(hostRef) {
4310
+ registerInstance(this, hostRef);
4311
+ this.valueChange = createEvent(this, "valueChange", 3);
4312
+ this._componentReadyDefer = new p();
4313
+ this._disposables = [];
4314
+ this.value = undefined;
4315
+ this.language = undefined;
4316
+ this.modelId = "";
4325
4317
  }
4326
- this._editorInstance.setValue(newValue ?? "");
4327
- }
4328
- languagePropChange(newValue, oldValue) {
4329
- if (!this._editorInstance || newValue === oldValue) {
4330
- return;
4318
+ valuePropChange(newValue, oldValue) {
4319
+ if (!this._editorInstance || newValue === oldValue) {
4320
+ return;
4321
+ }
4322
+ this._editorInstance.setValue(newValue ?? "");
4331
4323
  }
4332
- this.updateModel();
4333
- }
4334
- modelIdPropChange(newValue, oldValue) {
4335
- if (!this._editorInstance || newValue === oldValue) {
4336
- return;
4324
+ languagePropChange(newValue, oldValue) {
4325
+ if (!this._editorInstance || newValue === oldValue) {
4326
+ return;
4327
+ }
4328
+ this.updateModel();
4337
4329
  }
4338
- this.updateModel();
4339
- }
4340
- //#endregion
4341
- // #region Public methods API
4342
- /**
4343
- * Gets the current value in the editor.
4344
- * @returns {Promise<string>}
4345
- */
4346
- async getValue() {
4347
- await this._componentReadyDefer.promise;
4348
- return this._editorInstance?.getValue() ?? "";
4349
- }
4350
- /**
4351
- * Sets the new value in the editor. Use this method instead of setting the value
4352
- * on the model to preserve undo/redo stack.
4353
- * @param text
4354
- * @returns {Promise<void>}
4355
- */
4356
- async setValue(text) {
4357
- await this._componentReadyDefer.promise;
4358
- if (!this._editorInstance) {
4359
- return;
4330
+ modelIdPropChange(newValue, oldValue) {
4331
+ if (!this._editorInstance || newValue === oldValue) {
4332
+ return;
4333
+ }
4334
+ this.updateModel();
4360
4335
  }
4361
- const model = this._editorInstance.getModel();
4362
- if (!model) {
4363
- return;
4336
+ //#endregion
4337
+ // #region Public methods API
4338
+ /**
4339
+ * Gets the current value in the editor.
4340
+ * @returns {Promise<string>}
4341
+ */
4342
+ async getValue() {
4343
+ await this._componentReadyDefer.promise;
4344
+ return this._editorInstance?.getValue() ?? "";
4364
4345
  }
4365
- const range = model.getFullModelRange();
4366
- this._editorInstance.executeEdits("", [{ range, text: text ?? "", forceMoveMarkers: true }]);
4367
- this._editorInstance.pushUndoStop();
4368
- }
4369
- /**
4370
- * Inserts a text at the current position in the editor.
4371
- * @param {string} text - The string to insert
4372
- * @returns {Promise<void>}
4373
- */
4374
- async insertText(text) {
4375
- await this._componentReadyDefer.promise;
4376
- if (!this._editorInstance) {
4377
- return;
4346
+ /**
4347
+ * Sets the new value in the editor. Use this method instead of setting the value
4348
+ * on the model to preserve undo/redo stack.
4349
+ * @param text
4350
+ * @returns {Promise<void>}
4351
+ */
4352
+ async setValue(text) {
4353
+ await this._componentReadyDefer.promise;
4354
+ if (!this._editorInstance) {
4355
+ return;
4356
+ }
4357
+ const model = this._editorInstance.getModel();
4358
+ if (!model) {
4359
+ return;
4360
+ }
4361
+ const range = model.getFullModelRange();
4362
+ this._editorInstance.executeEdits("", [{ range, text: text ?? "", forceMoveMarkers: true }]);
4363
+ this._editorInstance.pushUndoStop();
4378
4364
  }
4379
- const model = this._editorInstance.getModel();
4380
- if (!model) {
4381
- return;
4365
+ /**
4366
+ * Inserts a text at the current position in the editor.
4367
+ * @param {string} text - The string to insert
4368
+ * @returns {Promise<void>}
4369
+ */
4370
+ async insertText(text) {
4371
+ await this._componentReadyDefer.promise;
4372
+ if (!this._editorInstance) {
4373
+ return;
4374
+ }
4375
+ const model = this._editorInstance.getModel();
4376
+ if (!model) {
4377
+ return;
4378
+ }
4379
+ const range = this._editorInstance.getSelection() ?? new Range(1, 1, 1, 1);
4380
+ this._editorInstance.executeEdits("", [{ range, text: text ?? "", forceMoveMarkers: true }]);
4382
4381
  }
4383
- const range = this._editorInstance.getSelection() ?? new Range(1, 1, 1, 1);
4384
- this._editorInstance.executeEdits("", [{ range, text: text ?? "", forceMoveMarkers: true }]);
4385
- }
4386
- /**
4387
- * Inserts a snippet at the current position in the editor.
4388
- * @param {string} text - The string snippet to insert
4389
- * @returns {Promise<void>}
4390
- */
4391
- async insertSnippet(text) {
4392
- await this._componentReadyDefer.promise;
4393
- if (!this._editorInstance) {
4394
- return;
4382
+ /**
4383
+ * Inserts a snippet at the current position in the editor.
4384
+ * @param {string} text - The string snippet to insert
4385
+ * @returns {Promise<void>}
4386
+ */
4387
+ async insertSnippet(text) {
4388
+ await this._componentReadyDefer.promise;
4389
+ if (!this._editorInstance) {
4390
+ return;
4391
+ }
4392
+ const snippetController = this._editorInstance.getContribution("snippetController2");
4393
+ snippetController.insert(text ?? "");
4394
+ this._editorInstance.focus();
4395
4395
  }
4396
- const snippetController = this._editorInstance.getContribution("snippetController2");
4397
- snippetController.insert(text ?? "");
4398
- this._editorInstance.focus();
4399
- }
4400
- /**
4401
- * @internal
4402
- * Returns the editor instance.
4403
- * @returns {Promise<IStandaloneCodeEditor>} - The monaco editor instance
4404
- */
4405
- async getEditorInstance() {
4406
- await this._componentReadyDefer.promise;
4407
- return this._editorInstance;
4408
- }
4409
- /**
4410
- * Sets the focus on the editor.
4411
- * @returns {Promise<void>}
4412
- */
4413
- async setFocus() {
4414
- await this._componentReadyDefer.promise;
4415
- this._editorInstance?.focus();
4416
- }
4417
- //#endregion
4418
- //#region Listeners
4419
- //#endregion
4420
- // #region Component lifecycle events
4421
- componentWillLoad() {
4422
- // Define the Monaco environemt.
4423
- // Can only do this when assets path has been defined.
4424
- // If we were placing this logic in connectedCallback, assets path would have not yet been defined.
4425
- // setupMonacoEnvironment will not redefine if already defined.
4426
- setupMonacoEnvironment(getAssetPath("./assets"));
4427
- }
4428
- componentDidLoad() {
4429
- // Create and attach and instance of Monaco Editor to the inner element
4430
- editor.getModel(this.getUri())?.dispose();
4431
- // Create the model without the value.
4432
- // Since it's not yet attached to the editor the diagnostic service will not process it.
4433
- // We will set the value after the editor has been created to trigger the diagnostic again.
4434
- const model = editor.createModel("", this.language, this.getUri());
4435
- // Create the editor for the host element.
4436
- // This will not trigger a diagnostic.
4437
- this._editorInstance = editor.create(this._hostElt, {
4438
- model,
4439
- fixedOverflowWidgets: true,
4440
- scrollBeyondLastLine: false
4441
- });
4442
- this._disposables.push(this._editorInstance);
4443
- // Set the value now to trigger a diagnostic again
4444
- model.setValue(this.value ?? "");
4445
- // Now we can set are component as ready
4446
- this._componentReadyDefer.resolve();
4447
- this._editorInstance.updateOptions(EditorOptionsDefaults);
4448
- // Listen to the Monaco Editor content change event and propagate
4449
- this._editorInstance.onDidChangeModelContent(() => {
4450
- const script = this._editorInstance?.getValue() ?? "";
4451
- this.valueChange.emit(script);
4452
- });
4453
- // Detect if the host element or its ancestors got a theme attribute mutation
4454
- this._themeObserver = T(this._hostElt, ["class"], () => this.updateTheme());
4455
- // Update the theme of the Monaco Editor
4456
- this.updateTheme();
4457
- // Creates a resize observer to re-layout the editor on size changing
4458
- const resizeObserver = new ResizeObserver(() => this._editorInstance?.layout());
4459
- resizeObserver.observe(this._hostElt);
4460
- // Add common actions to the Monaco Editor's context menu and command palette
4461
- this.addCommonEditorActions();
4462
- }
4463
- disconnectedCallback() {
4464
- while (this._disposables.length) {
4465
- this._disposables.pop()?.dispose();
4396
+ /**
4397
+ * @internal
4398
+ * Returns the editor instance.
4399
+ * @returns {Promise<IStandaloneCodeEditor>} - The monaco editor instance
4400
+ */
4401
+ async getEditorInstance() {
4402
+ await this._componentReadyDefer.promise;
4403
+ return this._editorInstance;
4466
4404
  }
4467
- this._themeObserver?.disconnect();
4468
- }
4469
- //#endregion
4470
- // #region Private methods API
4471
- updateModel() {
4472
- if (!this._editorInstance) {
4473
- return;
4405
+ /**
4406
+ * Sets the focus on the editor.
4407
+ * @returns {Promise<void>}
4408
+ */
4409
+ async setFocus() {
4410
+ await this._componentReadyDefer.promise;
4411
+ this._editorInstance?.focus();
4474
4412
  }
4475
- this._editorInstance.getModel()?.dispose();
4476
- this._editorInstance.setModel(editor.createModel(this.value ?? "", this.language, this.getUri()));
4477
- }
4478
- getUri() {
4479
- return this.modelId ? Uri.parse(this.modelId) : Uri.parse("");
4480
- }
4481
- updateTheme() {
4482
- // This is called the first time and subsequently by the Mutation Observer
4483
- // Figure out the theme by walking the ancestor path.
4484
- // If no theme is found then default to light.
4485
- const theme = P(this._hostElt) === "light" ? "vs" : "vs-dark";
4486
- if (theme === this._currentTheme) {
4487
- return;
4413
+ //#endregion
4414
+ //#region Listeners
4415
+ //#endregion
4416
+ // #region Component lifecycle events
4417
+ componentWillLoad() {
4418
+ // Define the Monaco environemt.
4419
+ // Can only do this when assets path has been defined.
4420
+ // If we were placing this logic in connectedCallback, assets path would have not yet been defined.
4421
+ // setupMonacoEnvironment will not redefine if already defined.
4422
+ setupMonacoEnvironment(getAssetPath("./assets"));
4488
4423
  }
4489
- this._currentTheme = theme;
4490
- editor.setTheme(theme);
4491
- }
4492
- //#endregion
4493
- // #region Private methods API
4494
- addCommonEditorActions() {
4495
- // Copy zoom in / out command functions
4496
- const zoomInFn = this._editorInstance?.getAction("editor.action.fontZoomIn");
4497
- const zoomOutFn = this._editorInstance?.getAction("editor.action.fontZoomOut");
4498
- // Override the two existing commands so that they appear in the context menu
4499
- this._editorInstance?.addAction({
4500
- // Use an existing action's ID to override it
4501
- id: "editor.action.fontZoomIn",
4502
- // A label of the action that will be presented to the user.
4503
- label: "Editor Font Zoom In",
4504
- // An optional array of keybindings for the action.
4505
- keybindings: [KeyMod.CtrlCmd | KeyCode.Equal],
4506
- contextMenuGroupId: "zooming",
4507
- contextMenuOrder: 1,
4508
- // Method that will be executed when the action is triggered.
4509
- // @param editor The editor instance is passed in as a convenience
4510
- run: () => {
4511
- zoomInFn?.run();
4512
- }
4513
- });
4514
- this._editorInstance?.addAction({
4515
- id: "editor.action.fontZoomOut",
4516
- label: "Editor Font Zoom Out",
4517
- keybindings: [KeyMod.CtrlCmd | KeyCode.Minus],
4518
- contextMenuGroupId: "zooming",
4519
- contextMenuOrder: 2,
4520
- run: () => {
4521
- zoomOutFn?.run();
4522
- }
4523
- });
4524
- }
4525
- //#endregion
4526
- // #region Rendering
4527
- render() {
4528
- return h(Host, null);
4529
- }
4530
- static get assetsDirs() { return ["assets"]; }
4531
- get _hostElt() { return getElement(this); }
4532
- static get watchers() { return {
4533
- "value": ["valuePropChange"],
4534
- "language": ["languagePropChange"],
4535
- "modelId": ["modelIdPropChange"]
4536
- }; }
4424
+ componentDidLoad() {
4425
+ // Create and attach and instance of Monaco Editor to the inner element
4426
+ editor.getModel(this.getUri())?.dispose();
4427
+ // Create the model without the value.
4428
+ // Since it's not yet attached to the editor the diagnostic service will not process it.
4429
+ // We will set the value after the editor has been created to trigger the diagnostic again.
4430
+ const model = editor.createModel("", this.language, this.getUri());
4431
+ // Create the editor for the host element.
4432
+ // This will not trigger a diagnostic.
4433
+ this._editorInstance = editor.create(this._hostElt, {
4434
+ model,
4435
+ fixedOverflowWidgets: true,
4436
+ scrollBeyondLastLine: false
4437
+ });
4438
+ this._disposables.push(this._editorInstance);
4439
+ // Set the value now to trigger a diagnostic again
4440
+ model.setValue(this.value ?? "");
4441
+ // Now we can set are component as ready
4442
+ this._componentReadyDefer.resolve();
4443
+ this._editorInstance.updateOptions(EditorOptionsDefaults);
4444
+ // Listen to the Monaco Editor content change event and propagate
4445
+ this._editorInstance.onDidChangeModelContent(() => {
4446
+ const script = this._editorInstance?.getValue() ?? "";
4447
+ this.valueChange.emit(script);
4448
+ });
4449
+ // Detect if the host element or its ancestors got a theme attribute mutation
4450
+ this._themeObserver = T(this._hostElt, ["class"], () => this.updateTheme());
4451
+ // Update the theme of the Monaco Editor
4452
+ this.updateTheme();
4453
+ // Creates a resize observer to re-layout the editor on size changing
4454
+ const resizeObserver = new ResizeObserver(() => this._editorInstance?.layout());
4455
+ resizeObserver.observe(this._hostElt);
4456
+ // Add common actions to the Monaco Editor's context menu and command palette
4457
+ this.addCommonEditorActions();
4458
+ }
4459
+ disconnectedCallback() {
4460
+ while (this._disposables.length) {
4461
+ this._disposables.pop()?.dispose();
4462
+ }
4463
+ this._themeObserver?.disconnect();
4464
+ }
4465
+ //#endregion
4466
+ // #region Private methods API
4467
+ updateModel() {
4468
+ if (!this._editorInstance) {
4469
+ return;
4470
+ }
4471
+ this._editorInstance.getModel()?.dispose();
4472
+ this._editorInstance.setModel(editor.createModel(this.value ?? "", this.language, this.getUri()));
4473
+ }
4474
+ getUri() {
4475
+ return this.modelId ? Uri.parse(this.modelId) : Uri.parse("");
4476
+ }
4477
+ updateTheme() {
4478
+ // This is called the first time and subsequently by the Mutation Observer
4479
+ // Figure out the theme by walking the ancestor path.
4480
+ // If no theme is found then default to light.
4481
+ const theme = P(this._hostElt) === "light" ? "vs" : "vs-dark";
4482
+ if (theme === this._currentTheme) {
4483
+ return;
4484
+ }
4485
+ this._currentTheme = theme;
4486
+ editor.setTheme(theme);
4487
+ }
4488
+ //#endregion
4489
+ // #region Private methods API
4490
+ addCommonEditorActions() {
4491
+ // Copy zoom in / out command functions
4492
+ const zoomInFn = this._editorInstance?.getAction("editor.action.fontZoomIn");
4493
+ const zoomOutFn = this._editorInstance?.getAction("editor.action.fontZoomOut");
4494
+ // Override the two existing commands so that they appear in the context menu
4495
+ this._editorInstance?.addAction({
4496
+ // Use an existing action's ID to override it
4497
+ id: "editor.action.fontZoomIn",
4498
+ // A label of the action that will be presented to the user.
4499
+ label: "Editor Font Zoom In",
4500
+ // An optional array of keybindings for the action.
4501
+ keybindings: [KeyMod.CtrlCmd | KeyCode.Equal],
4502
+ contextMenuGroupId: "zooming",
4503
+ contextMenuOrder: 1,
4504
+ // Method that will be executed when the action is triggered.
4505
+ // @param editor The editor instance is passed in as a convenience
4506
+ run: () => {
4507
+ zoomInFn?.run();
4508
+ }
4509
+ });
4510
+ this._editorInstance?.addAction({
4511
+ id: "editor.action.fontZoomOut",
4512
+ label: "Editor Font Zoom Out",
4513
+ keybindings: [KeyMod.CtrlCmd | KeyCode.Minus],
4514
+ contextMenuGroupId: "zooming",
4515
+ contextMenuOrder: 2,
4516
+ run: () => {
4517
+ zoomOutFn?.run();
4518
+ }
4519
+ });
4520
+ }
4521
+ //#endregion
4522
+ // #region Rendering
4523
+ render() {
4524
+ return h(Host, null);
4525
+ }
4526
+ static get assetsDirs() { return ["assets"]; }
4527
+ get _hostElt() { return getElement(this); }
4528
+ static get watchers() { return {
4529
+ "value": ["valuePropChange"],
4530
+ "language": ["languagePropChange"],
4531
+ "modelId": ["modelIdPropChange"]
4532
+ }; }
4537
4533
  };
4538
4534
  ArcgisCodeEditor.style = codeEditorCss;
4539
4535