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