@arcgis/ai-components 5.2.0-next.2 → 5.2.0-next.20

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 (196) hide show
  1. package/dist/agent-utils/FunctionAgent.d.ts +2 -2
  2. package/dist/agent-utils/LLMAgent.d.ts +2 -2
  3. package/dist/agent-utils/LLMAgent.js +23 -22
  4. package/dist/agent-utils/WorkflowAgent.d.ts +2 -2
  5. package/dist/agent-utils/index.d.ts +177 -0
  6. package/dist/agent-utils/index.js +167 -0
  7. package/dist/agent-utils/middlewares/trace.d.ts +2 -0
  8. package/dist/agent-utils/middlewares/trace.js +25 -33
  9. package/dist/agent-utils/tools/FunctionTool.d.ts +2 -2
  10. package/dist/agent-utils/types.d.ts +36 -7
  11. package/dist/agent-utils/workflows/ConditionalWorkflow.d.ts +2 -2
  12. package/dist/agent-utils/workflows/LoopWorkflow.d.ts +2 -2
  13. package/dist/agent-utils/workflows/ParallelWorkflow.d.ts +2 -2
  14. package/dist/agent-utils/workflows/RouterWorkflow.d.ts +2 -2
  15. package/dist/agent-utils/workflows/SequentialWorkflow.d.ts +2 -2
  16. package/dist/agent-utils/workflows/SwitchWorkflow.d.ts +2 -2
  17. package/dist/cdn/27NEUQN3.js +2 -0
  18. package/dist/cdn/2NMR43NW.js +2 -0
  19. package/dist/cdn/3YMSOD5D.js +2 -0
  20. package/dist/cdn/434TAA3J.js +2 -0
  21. package/dist/cdn/4I4MCV7V.js +71 -0
  22. package/dist/cdn/4RZPOYZ7.js +9 -0
  23. package/dist/cdn/5SBLS4NW.js +2 -0
  24. package/dist/cdn/{AMP6IALT.js → 5W7S2RS4.js} +1 -1
  25. package/dist/cdn/6LZ6GOHF.js +56 -0
  26. package/dist/cdn/ADYIXCSG.js +2 -0
  27. package/dist/cdn/ASSH4WSC.js +36 -0
  28. package/dist/cdn/BFPMQT3A.js +2 -0
  29. package/dist/cdn/C7E7MJSR.js +2 -0
  30. package/dist/cdn/CAECQD75.js +2 -0
  31. package/dist/cdn/CIW3QMKV.js +2 -0
  32. package/dist/cdn/CJIV4KJZ.js +179 -0
  33. package/dist/cdn/CVHJMR5X.js +2 -0
  34. package/dist/cdn/DEAYZ3MK.js +2 -0
  35. package/dist/cdn/{H7422XUG.js → E2HENO3T.js} +1 -1
  36. package/dist/cdn/E7TMP4YV.js +3 -0
  37. package/dist/cdn/EBRNMPPO.js +48 -0
  38. package/dist/cdn/FWU6DFIB.js +2 -0
  39. package/dist/cdn/GJUD7EA3.js +3 -0
  40. package/dist/cdn/HCR23HJB.js +2 -0
  41. package/dist/cdn/HOCTVCHH.js +2 -0
  42. package/dist/cdn/I64KIZG3.js +2 -0
  43. package/dist/cdn/IB4WTK74.js +2 -0
  44. package/dist/cdn/IC5P5NYY.js +2 -0
  45. package/dist/cdn/ICA7JOSU.js +161 -0
  46. package/dist/cdn/IKEF7ZHH.js +181 -0
  47. package/dist/cdn/IXAKT6L3.js +2 -0
  48. package/dist/cdn/JEIMRNYM.js +2 -0
  49. package/dist/cdn/JN744CAW.js +2 -0
  50. package/dist/cdn/{NE7E52YR.js → KTK4HNL2.js} +8 -2
  51. package/dist/cdn/{4HU7735A.js → KTOL6IN7.js} +6 -4
  52. package/dist/cdn/L77BTGXY.js +2 -0
  53. package/dist/cdn/LODKJRS4.js +2 -0
  54. package/dist/cdn/M3SWPT3M.js +2 -0
  55. package/dist/cdn/MAV3DW27.js +4 -0
  56. package/dist/cdn/NOJYPREL.js +3 -0
  57. package/dist/cdn/NXKKG5TK.js +2 -0
  58. package/dist/cdn/O3F47IO5.js +2 -0
  59. package/dist/cdn/O7TGCM5P.js +6 -0
  60. package/dist/cdn/PBTINZTK.js +65 -0
  61. package/dist/cdn/PDEBKVBO.js +22 -0
  62. package/dist/cdn/PDT6I6TZ.js +2 -0
  63. package/dist/cdn/PSWI3MFB.js +2 -0
  64. package/dist/cdn/Q7TL5Q5N.js +2 -0
  65. package/dist/cdn/QSA4T3BU.js +2 -0
  66. package/dist/cdn/RMLXVQZ5.js +2 -0
  67. package/dist/cdn/ROLXMEVE.js +18 -0
  68. package/dist/cdn/RX45PCYB.js +9 -0
  69. package/dist/cdn/SMADRJ67.js +2 -0
  70. package/dist/cdn/{ZLXN7NMF.js → T537PKP4.js} +9 -7
  71. package/dist/cdn/{X2ZDYHCG.js → TNMXWUXU.js} +9 -4
  72. package/dist/cdn/U53OEX6L.js +2 -0
  73. package/dist/cdn/VDXSALQI.js +2 -0
  74. package/dist/cdn/VKU4WAQV.js +2 -0
  75. package/dist/cdn/W2JAKE2M.js +2 -0
  76. package/dist/cdn/WAVKMZA6.js +2 -0
  77. package/dist/cdn/WH6QQK6N.js +2 -0
  78. package/dist/cdn/WNS5ZUF5.js +2 -0
  79. package/dist/cdn/{FL4W4VYN.js → X7GE26KU.js} +16 -0
  80. package/dist/cdn/XGS5EIA5.js +14 -0
  81. package/dist/cdn/XVQJBUMY.js +2 -0
  82. package/dist/cdn/YJ3QQXF6.js +2 -0
  83. package/dist/cdn/YYY7HKYX.js +2 -0
  84. package/dist/cdn/ZEYIBYSF.js +66 -0
  85. package/dist/cdn/ZOSUDIJH.js +2 -0
  86. package/dist/cdn/ZPLFFLPF.js +2 -0
  87. package/dist/cdn/agent-utils/index.js +2 -0
  88. package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +3 -0
  89. package/dist/cdn/agent-utils/middlewares/middleware.js +2 -0
  90. package/dist/cdn/agent-utils/middlewares/trace.js +2 -0
  91. package/dist/cdn/index.js +1 -1
  92. package/dist/cdn/main.css +1 -1
  93. package/dist/chunks/adapter.js +1410 -1342
  94. package/dist/chunks/arcgisKnowledgeGraph.js +110 -72
  95. package/dist/chunks/converterUtils.js +39 -32
  96. package/dist/chunks/dataExplorationGraph.js +139 -113
  97. package/dist/chunks/data_explore_query_prompt.js +9 -4
  98. package/dist/chunks/generateLayerDescriptions.js +231 -191
  99. package/dist/chunks/helpGraph.js +17 -13
  100. package/dist/chunks/help_prompt.js +34 -17
  101. package/dist/chunks/index.js +11 -0
  102. package/dist/chunks/intent_prompt.js +16 -0
  103. package/dist/chunks/layerStylingGraph.js +24 -20
  104. package/dist/chunks/navigationGraph.js +33 -28
  105. package/dist/chunks/navigation_intent_prompt.js +8 -2
  106. package/dist/chunks/orchestrator.js +267 -226
  107. package/dist/chunks/slottableRequestUtils.js +3 -7
  108. package/dist/chunks/state.js +1 -1
  109. package/dist/chunks/summarize_query_response_prompt.js +9 -7
  110. package/dist/chunks/toolCallResponse.js +12 -9
  111. package/dist/chunks/utils2.js +8 -8
  112. package/dist/components/arcgis-assistant/customElement.d.ts +27 -0
  113. package/dist/components/arcgis-assistant/customElement.js +385 -152
  114. package/dist/components/arcgis-assistant/index.js +2 -3
  115. package/dist/components/arcgis-assistant/types.d.ts +14 -1
  116. package/dist/components/arcgis-assistant-agent/customElement.js +5 -1
  117. package/dist/components/arcgis-assistant-chat/customElement.d.ts +8 -2
  118. package/dist/components/arcgis-assistant-chat/customElement.js +23 -18
  119. package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +4 -1
  120. package/dist/components/arcgis-assistant-chat-entry/customElement.js +25 -18
  121. package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +11 -5
  122. package/dist/components/arcgis-assistant-help-agent/customElement.js +8 -2
  123. package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -1
  124. package/dist/components/arcgis-assistant-interrupt/customElement.js +12 -8
  125. package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +20 -0
  126. package/dist/components/arcgis-assistant-interrupt-preview/index.js +2 -0
  127. package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +7 -7
  128. package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +17 -11
  129. package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +10 -4
  130. package/dist/components/arcgis-assistant-message/customElement.d.ts +23 -0
  131. package/dist/components/arcgis-assistant-message/customElement.js +28 -26
  132. package/dist/components/arcgis-assistant-message/index.d.ts +1 -0
  133. package/dist/components/arcgis-assistant-message/index.js +2 -0
  134. package/dist/components/arcgis-assistant-message-block/customElement.d.ts +1 -1
  135. package/dist/components/arcgis-assistant-message-block/customElement.js +18 -11
  136. package/dist/components/arcgis-assistant-message-block/index.js +1 -0
  137. package/dist/components/arcgis-assistant-message-feedback/customElement.d.ts +4 -1
  138. package/dist/components/arcgis-assistant-message-footer/customElement.d.ts +4 -1
  139. package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +8 -1
  140. package/dist/components/arcgis-assistant-message-loading/customElement.js +8 -8
  141. package/dist/components/arcgis-assistant-message-loading/index.js +1 -0
  142. package/dist/components/arcgis-assistant-message-log/customElement.d.ts +4 -1
  143. package/dist/components/arcgis-assistant-message-read-aloud/customElement.d.ts +4 -1
  144. package/dist/components/arcgis-assistant-message-text/customElement.d.ts +5 -1
  145. package/dist/components/arcgis-assistant-message-text/customElement.js +12 -12
  146. package/dist/components/arcgis-assistant-navigation-agent/customElement.js +11 -5
  147. package/dist/components/arcgis-assistant-speech-input/customElement.d.ts +6 -1
  148. package/dist/components/arcgis-assistant-suggested-prompts/customElement.d.ts +4 -1
  149. package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +8 -8
  150. package/dist/components/arcgis-assistant-user-message/customElement.d.ts +4 -1
  151. package/dist/components/arcgis-assistant-user-message/customElement.js +10 -8
  152. package/dist/docs/api.json +1 -1
  153. package/dist/docs/docs.json +1 -1
  154. package/dist/docs/vscode.html-custom-data.json +1 -1
  155. package/dist/docs/web-types.json +1 -1
  156. package/dist/index.d.ts +4 -0
  157. package/dist/loader.js +7 -6
  158. package/dist/types/lumina.d.ts +11 -5
  159. package/dist/types/preact.d.ts +12 -5
  160. package/dist/types/react.d.ts +13 -5
  161. package/dist/types/stencil.d.ts +11 -5
  162. package/dist/utils/index.d.ts +85 -42
  163. package/dist/utils/index.js +54 -49
  164. package/package.json +8 -7
  165. package/dist/cdn/2AXF774U.js +0 -2
  166. package/dist/cdn/3PKJWIC3.js +0 -2
  167. package/dist/cdn/462JBSEV.js +0 -422
  168. package/dist/cdn/7BCR6TUO.js +0 -2
  169. package/dist/cdn/7GH7VSB2.js +0 -2
  170. package/dist/cdn/7PLV4QH6.js +0 -2
  171. package/dist/cdn/AO7BQHKC.js +0 -2
  172. package/dist/cdn/DDLZOMUY.js +0 -2
  173. package/dist/cdn/DHOVCT6R.js +0 -2
  174. package/dist/cdn/F2AHA4GB.js +0 -54
  175. package/dist/cdn/FHVXO2WG.js +0 -166
  176. package/dist/cdn/FX5JFRDL.js +0 -2
  177. package/dist/cdn/GSEPHN3A.js +0 -106
  178. package/dist/cdn/HB5A5R2E.js +0 -2
  179. package/dist/cdn/JY6LLOUJ.js +0 -22
  180. package/dist/cdn/MDVYQQUG.js +0 -14
  181. package/dist/cdn/MH5RPXHM.js +0 -2
  182. package/dist/cdn/NAUXSHIE.js +0 -72
  183. package/dist/cdn/NVI3I46B.js +0 -2
  184. package/dist/cdn/OAVEHGB6.js +0 -2
  185. package/dist/cdn/OH64RMOR.js +0 -4
  186. package/dist/cdn/ON2V5XI2.js +0 -3
  187. package/dist/cdn/P6OPJQMC.js +0 -3
  188. package/dist/cdn/QR54T33D.js +0 -2
  189. package/dist/cdn/RVOAPUBN.js +0 -2
  190. package/dist/cdn/S6W6HV4T.js +0 -36
  191. package/dist/cdn/SXDLXCIM.js +0 -2
  192. package/dist/cdn/USMDJUFS.js +0 -2
  193. package/dist/cdn/V2P4AIGG.js +0 -2
  194. package/dist/cdn/V5YEZSRY.js +0 -16
  195. package/dist/cdn/Y333DGV6.js +0 -2
  196. package/dist/cdn/YY2SBO3V.js +0 -2
@@ -1,56 +1,58 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import ce from "@arcgis/core/identity/IdentityManager.js";
2
+ import me from "@arcgis/core/identity/IdentityManager.js";
3
3
  import k from "@arcgis/core/portal/Portal.js";
4
- import { Annotation as b, messagesStateReducer as me } from "@langchain/langgraph/web";
5
- import { n as Ne, o as x, k as U, s as S, i as ze } from "./generateLayerDescriptions.js";
4
+ import { Annotation as b, messagesStateReducer as Te } from "@langchain/langgraph/web";
5
+ import "@arcgis/toolkit/string";
6
+ import { k as qe, j as B, i as De } from "./generateLayerDescriptions.js";
6
7
  import "@langchain/core/messages";
7
8
  import "@langchain/core/callbacks/dispatch/web";
8
9
  import "@langchain/openai";
9
- import * as qe from "@arcgis/core/core/reactiveUtils.js";
10
+ import X from "@arcgis/core/config.js";
11
+ import * as Ae from "@arcgis/core/core/reactiveUtils.js";
10
12
  import "@arcgis/core/layers/FeatureLayer.js";
11
- import le from "@arcgis/core/request.js";
13
+ import he from "@arcgis/core/request.js";
12
14
  import "@langchain/core/prompts";
13
15
  import { tool as f } from "@langchain/core/tools";
14
- import J from "@arcgis/core/config.js";
15
- import De from "@arcgis/core/Graphic.js";
16
- import { addressToLocations as Ae } from "@arcgis/core/rest/locator.js";
17
- import Le from "@arcgis/core/symbols/PictureMarkerSymbol.js";
18
- import i, { z as C } from "zod";
19
- import Pe from "@arcgis/core/geometry/Extent.js";
20
- import ye from "@arcgis/core/geometry/Point.js";
21
- import { createRenderer as je } from "@arcgis/core/smartMapping/renderers/pieChart.js";
22
- import { getSchemesByTag as Ge, getSchemes as Oe } from "@arcgis/core/smartMapping/symbology/pieChart.js";
23
- import { getBackgroundColorTheme as ue } from "@arcgis/core/views/support/colorUtils.js";
24
- import { createAgeRenderer as Me, createContinuousRenderer as Qe } from "@arcgis/core/smartMapping/renderers/color.js";
25
- import { getSchemesByTag as re } from "@arcgis/core/smartMapping/symbology/color.js";
26
- import { createContinuousRenderer as _e } from "@arcgis/core/smartMapping/renderers/univariateColorSize.js";
27
- import { createRenderer as We } from "@arcgis/core/smartMapping/renderers/dotDensity.js";
28
- import { getSchemesByTag as Ve } from "@arcgis/core/smartMapping/symbology/dotDensity.js";
29
- import { createRenderer as Ue } from "@arcgis/core/smartMapping/renderers/heatmap.js";
30
- import { getSchemesByTag as Ke } from "@arcgis/core/smartMapping/symbology/heatmap.js";
31
- import { createRenderer as Be } from "@arcgis/core/smartMapping/renderers/predominance.js";
32
- import { getSchemesByTag as He } from "@arcgis/core/smartMapping/symbology/predominance.js";
33
- import { createRenderer as Je } from "@arcgis/core/smartMapping/renderers/relationship.js";
34
- import { getSchemesByTag as Ze } from "@arcgis/core/smartMapping/symbology/relationship.js";
35
- import { createAgeRenderer as Ye, createContinuousRenderer as Xe } from "@arcgis/core/smartMapping/renderers/size.js";
36
- import { createRenderer as et } from "@arcgis/core/smartMapping/renderers/type.js";
37
- import { getSchemesByTag as tt } from "@arcgis/core/smartMapping/symbology/type.js";
38
- import { ToolNode as rt } from "@langchain/langgraph/prebuilt";
39
- import ot from "@arcgis/core/layers/support/FeatureEffect.js";
40
- import fe from "@arcgis/core/layers/support/FeatureFilter.js";
41
- import * as at from "@arcgis/core/geometry/operators/unionOperator.js";
42
- import { formatDateOnly as nt, convertDateFormatToIntlOptions as M, formatTimeOnly as it, formatDate as de } from "@arcgis/core/intl.js";
43
- import st from "@arcgis/core/smartMapping/statistics/summaryStatistics.js";
44
- import ct from "@arcgis/core/smartMapping/statistics/uniqueValues.js";
45
- import lt from "@arcgis/core/rest/support/TopFeaturesQuery.js";
46
- import ut from "@arcgis/core/rest/support/TopFilter.js";
47
- import dt from "@arcgis/core/WebLinkChart.js";
48
- import ge from "@arcgis/core/rest/knowledgeGraph/GraphQueryStreaming.js";
16
+ import Pe from "@arcgis/core/Graphic.js";
17
+ import { addressToLocations as Le } from "@arcgis/core/rest/locator.js";
18
+ import je from "@arcgis/core/symbols/PictureMarkerSymbol.js";
19
+ import i, { z as E } from "zod";
20
+ import Ge from "@arcgis/core/geometry/Extent.js";
21
+ import ve from "@arcgis/core/geometry/Point.js";
22
+ import { createRenderer as Oe } from "@arcgis/core/smartMapping/renderers/pieChart.js";
23
+ import { getSchemesByTag as Me, getSchemes as Qe } from "@arcgis/core/smartMapping/symbology/pieChart.js";
24
+ import { getBackgroundColorTheme as ye } from "@arcgis/core/views/support/colorUtils.js";
25
+ import { a as x, s as S } from "./index.js";
26
+ import { createAgeRenderer as _e, createContinuousRenderer as We } from "@arcgis/core/smartMapping/renderers/color.js";
27
+ import { getSchemesByTag as le } from "@arcgis/core/smartMapping/symbology/color.js";
28
+ import { createContinuousRenderer as Ve } from "@arcgis/core/smartMapping/renderers/univariateColorSize.js";
29
+ import { createRenderer as Ue } from "@arcgis/core/smartMapping/renderers/dotDensity.js";
30
+ import { getSchemesByTag as Ke } from "@arcgis/core/smartMapping/symbology/dotDensity.js";
31
+ import { createRenderer as Be } from "@arcgis/core/smartMapping/renderers/heatmap.js";
32
+ import { getSchemesByTag as He } from "@arcgis/core/smartMapping/symbology/heatmap.js";
33
+ import { createRenderer as Je } from "@arcgis/core/smartMapping/renderers/predominance.js";
34
+ import { getSchemesByTag as Ze } from "@arcgis/core/smartMapping/symbology/predominance.js";
35
+ import { createRenderer as Ye } from "@arcgis/core/smartMapping/renderers/relationship.js";
36
+ import { getSchemesByTag as Xe } from "@arcgis/core/smartMapping/symbology/relationship.js";
37
+ import { createAgeRenderer as et, createContinuousRenderer as tt } from "@arcgis/core/smartMapping/renderers/size.js";
38
+ import { createRenderer as rt } from "@arcgis/core/smartMapping/renderers/type.js";
39
+ import { getSchemesByTag as at } from "@arcgis/core/smartMapping/symbology/type.js";
40
+ import { ToolNode as ot } from "@langchain/langgraph/prebuilt";
41
+ import nt from "@arcgis/core/layers/support/FeatureEffect.js";
42
+ import Se from "@arcgis/core/layers/support/FeatureFilter.js";
43
+ import * as it from "@arcgis/core/geometry/operators/unionOperator.js";
44
+ import { formatDateOnly as st, convertDateFormatToIntlOptions as Q, formatTimeOnly as lt, formatDate as fe } from "@arcgis/core/intl.js";
45
+ import ct from "@arcgis/core/smartMapping/statistics/summaryStatistics.js";
46
+ import ut from "@arcgis/core/smartMapping/statistics/uniqueValues.js";
47
+ import dt from "@arcgis/core/rest/support/TopFeaturesQuery.js";
48
+ import pt from "@arcgis/core/rest/support/TopFilter.js";
49
+ import mt from "@arcgis/core/WebLinkChart.js";
50
+ import xe from "@arcgis/core/rest/knowledgeGraph/GraphQueryStreaming.js";
49
51
  import "@arcgis/core/views/LinkChartView.js";
50
- import { fetchKnowledgeGraph as pe, executeQueryStreaming as pt, executeSearchStreaming as ht } from "@arcgis/core/rest/knowledgeGraphService.js";
51
- import mt from "@arcgis/core/rest/knowledgeGraph/GraphSearchStreaming.js";
52
- const L = (e, t) => t ?? e, Tn = b.Root({
53
- ...Ne(),
52
+ import { fetchKnowledgeGraph as ge, executeQueryStreaming as ht, executeSearchStreaming as yt } from "@arcgis/core/rest/knowledgeGraphService.js";
53
+ import ft from "@arcgis/core/rest/knowledgeGraph/GraphSearchStreaming.js";
54
+ const L = (e, t) => t ?? e, Rn = b.Root({
55
+ ...qe(),
54
56
  // internal to the navigation agent
55
57
  intent: b({
56
58
  reducer: L
@@ -69,122 +71,122 @@ const L = (e, t) => t ?? e, Tn = b.Root({
69
71
  })
70
72
  })
71
73
  });
72
- async function yt(e, t) {
73
- const o = k.getDefault().helperServices, a = o.geocode.find((h) => h.name === "ArcGIS World Geocoding Service") ?? o.geocode[0];
74
- if (!a)
74
+ async function gt(e, t) {
75
+ const a = k.getDefault().helperServices, o = a.geocode.find((m) => m.name === "ArcGIS World Geocoding Service") ?? a.geocode[0];
76
+ if (!o)
75
77
  throw new Error("No geocoding service found in helperServices.");
76
- const n = a.url, s = `${J.assetsPath?.endsWith("/") ? J.assetsPath : `${J.assetsPath}/`}esri/images/search/search-symbol-32.png`, u = (await Ae(n, {
78
+ const n = o.url, l = `${X.assetsPath?.endsWith("/") ? X.assetsPath : `${X.assetsPath}/`}esri/images/search/search-symbol-32.png`, c = (await Le(n, {
77
79
  address: { SingleLine: e },
78
80
  outFields: ["Match_addr"]
79
81
  }))?.[0];
80
- if (!u?.extent || !u.location)
82
+ if (!c?.extent || !c.location)
81
83
  throw new Error(`Could not find location for: ${e}`);
82
- const l = new Le({
83
- url: s,
84
+ const u = new je({
85
+ url: l,
84
86
  width: 24,
85
87
  height: 24
86
- }), d = new De({
87
- geometry: u.location,
88
- symbol: l
88
+ }), d = new Pe({
89
+ geometry: c.location,
90
+ symbol: u
89
91
  });
90
- t.graphics.removeAll(), t.graphics.add(d), await t.goTo(u.extent);
92
+ t.graphics.removeAll(), t.graphics.add(d), await t.goTo(c.extent);
91
93
  const p = {
92
- address: u.address ?? "",
93
- location: u.location ? u.location.toJSON() : null,
94
- extent: u.extent ? u.extent.toJSON() : null
94
+ address: c.address ?? "",
95
+ location: c.location ? c.location.toJSON() : null,
96
+ extent: c.extent ? c.extent.toJSON() : null
95
97
  };
96
98
  return {
97
99
  text: `Successfully zoomed to ${e}.`,
98
100
  sharedStatePatch: { lastResolvedLocation: { value: p } }
99
101
  };
100
102
  }
101
- const ft = ["mapView"];
103
+ const wt = ["mapView"];
102
104
  function $(e) {
103
105
  const r = e?.configurable?.context;
104
106
  if (!r || typeof r != "object")
105
107
  throw new Error("NavigationAgent context missing");
106
- const o = ft.filter((a) => !(a in r));
107
- if (o.length)
108
- throw new Error(`NavigationAgent context missing: ${o.join(", ")}`);
108
+ const a = wt.filter((o) => !(o in r));
109
+ if (a.length)
110
+ throw new Error(`NavigationAgent context missing: ${a.join(", ")}`);
109
111
  return r;
110
112
  }
111
- async function gt({ address: e }, t) {
113
+ async function bt({ address: e }, t) {
112
114
  const { mapView: r } = $(t);
113
- return await yt(e, r);
115
+ return await gt(e, r);
114
116
  }
115
- const wt = i.object({
117
+ const Tt = i.object({
116
118
  address: i.string().describe("The full address or place name to locate.")
117
- }), vn = f(gt, {
119
+ }), $n = f(bt, {
118
120
  name: "goToAddress",
119
121
  description: "Geocodes an address using Esri's World Geocoding Service and zooms the map to that location.",
120
- schema: wt
122
+ schema: Tt
121
123
  });
122
- async function bt(e, t) {
123
- const o = t.map.bookmarks;
124
- if (!o || o.length === 0)
124
+ async function vt(e, t) {
125
+ const a = t.map.bookmarks;
126
+ if (!a || a.length === 0)
125
127
  throw new Error("No bookmarks found in the map.");
126
- const a = o.find((s) => s.name === e);
127
- if (!a)
128
+ const o = a.find((l) => l.name === e);
129
+ if (!o)
128
130
  throw new Error(`Bookmark with name "${e}" not found.`);
129
- const n = a.viewpoint;
131
+ const n = o.viewpoint;
130
132
  if (!n)
131
133
  throw new Error(`Bookmark with name "${e}" does not have a valid viewpoint.`);
132
134
  return await t.goTo(n), { text: `Navigated to bookmark: ${e}` };
133
135
  }
134
- async function Tt({ bookmarkName: e }, t) {
136
+ async function St({ bookmarkName: e }, t) {
135
137
  const { mapView: r } = $(t);
136
- return await Promise.resolve(bt(e, r));
138
+ return await Promise.resolve(vt(e, r));
137
139
  }
138
- const vt = C.object({
139
- bookmarkName: C.string().describe("The name of the bookmark to navigate to.")
140
- }), Sn = f(Tt, {
140
+ const xt = E.object({
141
+ bookmarkName: E.string().describe("The name of the bookmark to navigate to.")
142
+ }), Cn = f(St, {
141
143
  name: "goToBookmark",
142
144
  description: "Go to the extent of the bookmark with the given name.",
143
- schema: vt
145
+ schema: xt
144
146
  });
145
- async function St(e, t, r) {
146
- const o = r.map?.allLayers.find((s) => s.id === e);
147
- if (!o)
147
+ async function Rt(e, t, r) {
148
+ const a = r.map?.allLayers.find((l) => l.id === e);
149
+ if (!a)
148
150
  return { text: `Error: Layer with id ${e} not found` };
149
- const a = t?.trim() ? t : "1=1", n = o.createQuery();
150
- n.where = a;
151
+ const o = t?.trim() ? t : "1=1", n = a.createQuery();
152
+ n.where = o;
151
153
  try {
152
- const { extent: s, count: c } = await o.queryExtent(n);
153
- if (c === 0)
154
- return { text: `No features found in ${o.title} matching: ${a}`, where: a };
155
- if (s)
156
- await r.goTo(s);
154
+ const { extent: l, count: s } = await a.queryExtent(n);
155
+ if (s === 0)
156
+ return { text: `No features found in ${a.title} matching: ${o}`, where: o };
157
+ if (l)
158
+ await r.goTo(l);
157
159
  else
158
- return { text: `Error: Unable to determine extent for ${o.title}`, where: a };
159
- const u = {
160
+ return { text: `Error: Unable to determine extent for ${a.title}`, where: o };
161
+ const c = {
160
162
  layerId: e,
161
- layerTitle: o.title ?? e,
162
- where: a,
163
- count: c
163
+ layerTitle: a.title ?? e,
164
+ where: o,
165
+ count: s
164
166
  };
165
167
  return {
166
- text: `Successfully zoomed to ${c} feature(s) in ${o.title} matching: ${a}`,
167
- where: a,
168
- sharedStatePatch: { lastNavigatedFeatures: { value: u } }
168
+ text: `Successfully zoomed to ${s} feature(s) in ${a.title} matching: ${o}`,
169
+ where: o,
170
+ sharedStatePatch: { lastNavigatedFeatures: { value: c } }
169
171
  };
170
- } catch (s) {
171
- return console.error("Error in goToFeatures:", s), { text: `Error: ${s instanceof Error ? s.message : "Unknown error"}`, where: a };
172
+ } catch (l) {
173
+ return console.error("Error in goToFeatures:", l), { text: `Error: ${l instanceof Error ? l.message : "Unknown error"}`, where: o };
172
174
  }
173
175
  }
174
- async function xt({ layerId: e, where: t }, r) {
175
- const { mapView: o } = $(r);
176
- return await St(e, t, o);
176
+ async function $t({ layerId: e, where: t }, r) {
177
+ const { mapView: a } = $(r);
178
+ return await Rt(e, t, a);
177
179
  }
178
- const Rt = C.object({
179
- layerId: C.string().describe("The layerId of the layer to zoom to."),
180
- where: C.string().describe("The sql-92 where clause used to query features to zoom to")
181
- }), xn = f(xt, {
180
+ const Ct = E.object({
181
+ layerId: E.string().describe("The layerId of the layer to zoom to."),
182
+ where: E.string().describe("The sql-92 where clause used to query features to zoom to")
183
+ }), En = f($t, {
182
184
  name: "goToFeatures",
183
185
  description: "Go to the features that match the given filter related to the given layerId.",
184
- schema: Rt
186
+ schema: Ct
185
187
  });
186
- async function $t(e) {
187
- const r = new Pe({
188
+ async function Et(e) {
189
+ const r = new Ge({
188
190
  xmin: -180,
189
191
  ymin: -90,
190
192
  xmax: 180,
@@ -193,16 +195,16 @@ async function $t(e) {
193
195
  }).expand(0.7);
194
196
  return await e.goTo(r), { text: "Successfully zoomed to world extent" };
195
197
  }
196
- async function Et(e, t) {
198
+ async function Nt(e, t) {
197
199
  const { mapView: r } = $(t);
198
- return await $t(r);
200
+ return await Et(r);
199
201
  }
200
- const Ct = C.object({}), Rn = f(Et, {
202
+ const It = E.object({}), Nn = f(Nt, {
201
203
  name: "goToFullExtent",
202
204
  description: "Zooms the map to the full world extent using Esri's Geocoding Service.",
203
- schema: Ct
205
+ schema: It
204
206
  });
205
- async function It(e) {
207
+ async function kt(e) {
206
208
  const r = e.map.initialViewProperties?.viewpoint?.targetGeometry;
207
209
  if (r)
208
210
  await e.goTo(r);
@@ -212,94 +214,94 @@ async function It(e) {
212
214
  }
213
215
  async function Ft(e, t) {
214
216
  const { mapView: r } = $(t);
215
- return await It(r);
217
+ return await kt(r);
216
218
  }
217
- const kt = i.object({}), $n = f(Ft, {
219
+ const zt = i.object({}), In = f(Ft, {
218
220
  name: "goToHomeExtent",
219
221
  description: "Go to the initial web map view extent",
220
- schema: kt
222
+ schema: zt
221
223
  });
222
- async function Nt(e, t) {
224
+ async function qt(e, t) {
223
225
  await t.when();
224
- const r = t.map?.allLayers.find((a) => a.id === e);
226
+ const r = t.map?.allLayers.find((o) => o.id === e);
225
227
  if (!r)
226
228
  return console.warn(`[goToLayer] No matching FeatureLayer found for: ${e}`), { text: `Could not find layer for: ${e}` };
227
- let o;
228
- return (r.type === "link-chart" || r.type === "knowledge-graph-sublayer") && t.map?.activeLinkChartLayer ? o = t.map.diagramNodesExtent : o = r.fullExtent, o ? (await t.goTo(o), r.visible = !0, { text: `Successfully zoomed to: ${r.title ?? ""}` }) : { text: "Layer has no defined extent. Cannot zoom to layer." };
229
+ let a;
230
+ return (r.type === "link-chart" || r.type === "knowledge-graph-sublayer") && t.map?.activeLinkChartLayer ? a = t.map.diagramNodesExtent : a = r.fullExtent, a ? (await t.goTo(a), r.visible = !0, { text: `Successfully zoomed to: ${r.title ?? ""}` }) : { text: "Layer has no defined extent. Cannot zoom to layer." };
229
231
  }
230
- async function zt({ layerId: e }, t) {
232
+ async function Dt({ layerId: e }, t) {
231
233
  const { mapView: r } = $(t);
232
- return await Nt(e, r);
234
+ return await qt(e, r);
233
235
  }
234
- const qt = C.object({
235
- layerId: C.string().describe("The id of the layer to navigate to")
236
- }), En = f(zt, {
236
+ const At = E.object({
237
+ layerId: E.string().describe("The id of the layer to navigate to")
238
+ }), kn = f(Dt, {
237
239
  name: "goToLayer",
238
240
  description: "Zooms the map view to the full extent of the top matching layer.",
239
- schema: qt
241
+ schema: At
240
242
  });
241
- async function Dt(e, t) {
243
+ async function Pt(e, t) {
242
244
  return await t.goTo({ scale: e }), { text: `Successfully zoomed to: ${e}` };
243
245
  }
244
- async function At({ scale: e }, t) {
246
+ async function Lt({ scale: e }, t) {
245
247
  const { mapView: r } = $(t);
246
- return await Dt(e, r);
248
+ return await Pt(e, r);
247
249
  }
248
- const Lt = i.object({
250
+ const jt = i.object({
249
251
  scale: i.number().describe("The map scale of the view to go to.")
250
- }), Cn = f(At, {
252
+ }), Fn = f(Lt, {
251
253
  name: "goToScale",
252
254
  description: "Go to the specified view scale.",
253
- schema: Lt
255
+ schema: jt
254
256
  });
255
- async function Pt(e, t, r) {
256
- const a = {
257
- target: new ye({
257
+ async function Gt(e, t, r) {
258
+ const o = {
259
+ target: new ve({
258
260
  longitude: e.longitude,
259
261
  latitude: e.latitude,
260
262
  spatialReference: { wkid: 4326 }
261
263
  })
262
264
  };
263
- return r?.zoom !== void 0 && (a.zoom = r.zoom), r?.scale !== void 0 && (a.scale = r.scale), await t.goTo(a), { text: `Successfully navigated to: ${[
265
+ return r?.zoom !== void 0 && (o.zoom = r.zoom), r?.scale !== void 0 && (o.scale = r.scale), await t.goTo(o), { text: `Successfully navigated to: ${[
264
266
  `(${e.latitude}°, ${e.longitude}°)`,
265
267
  r?.zoom !== void 0 ? `zoom ${r.zoom}` : "",
266
268
  r?.scale !== void 0 ? `scale 1:${r.scale}` : ""
267
269
  ].filter(Boolean).join(", ")}` };
268
270
  }
269
- async function jt({
271
+ async function Ot({
270
272
  center: e,
271
273
  zoom: t,
272
274
  scale: r
273
- }, o) {
274
- const { mapView: a } = $(o);
275
- return await Pt(e, a, { zoom: t, scale: r });
275
+ }, a) {
276
+ const { mapView: o } = $(a);
277
+ return await Gt(e, o, { zoom: t, scale: r });
276
278
  }
277
- const Gt = i.object({
279
+ const Mt = i.object({
278
280
  center: i.object({
279
281
  longitude: i.number().describe("The longitude (x-coordinate) of the point to navigate to."),
280
282
  latitude: i.number().describe("The latitude (y-coordinate) of the point to navigate to.")
281
283
  }),
282
284
  zoom: i.number().optional().describe("The zoom level. Higher values = more zoomed in."),
283
285
  scale: i.number().optional().describe("The map scale. Alternative to zoom. Smaller numbers = more zoomed in.")
284
- }), In = f(jt, {
286
+ }), zn = f(Ot, {
285
287
  name: "goToViewpoint",
286
288
  description: "Go to the specified viewpoint. This can contain a combination of scale, center, zoom, etc.",
287
- schema: Gt
289
+ schema: Mt
288
290
  });
289
- async function Ot(e, t) {
291
+ async function Qt(e, t) {
290
292
  return await t.goTo({ zoom: e }), { text: `Successfully zoomed to: ${e}` };
291
293
  }
292
- async function Mt({ zoom: e }, t) {
294
+ async function _t({ zoom: e }, t) {
293
295
  const { mapView: r } = $(t);
294
- return await Ot(e, r);
296
+ return await Qt(e, r);
295
297
  }
296
- const Qt = i.object({
298
+ const Wt = i.object({
297
299
  zoom: i.number().min(1).max(20).describe("The zoom level of the view to go to.")
298
- }), Fn = f(Mt, {
300
+ }), qn = f(_t, {
299
301
  name: "goToZoom",
300
302
  description: 'Go to the specified zoom level. If input is generic (e.g. "zoom in", then only zoom to the next appropriate level - increase level for zooming in and decrease for zooming out.).',
301
- schema: Qt
302
- }), he = /* @__PURE__ */ Object.assign({
303
+ schema: Wt
304
+ }), we = /* @__PURE__ */ Object.assign({
303
305
  "../agents/arcgisKnowledge/prompts/arcgis_knowledge_current_lc_context.md": () => import("./arcgis_knowledge_current_lc_context.js").then((e) => e.default),
304
306
  "../agents/arcgisKnowledge/prompts/arcgis_knowledge_current_map_context.md": () => import("./arcgis_knowledge_current_map_context.js").then((e) => e.default),
305
307
  "../agents/arcgisKnowledge/prompts/arcgis_knowledge_lucene_generation_prompt.md": () => import("./arcgis_knowledge_lucene_generation_prompt.js").then((e) => e.default),
@@ -313,115 +315,115 @@ const Qt = i.object({
313
315
  "../agents/navigation/prompts/navigation_intent_prompt.md": () => import("./navigation_intent_prompt.js").then((e) => e.default),
314
316
  "../agents/navigation/prompts/navigation_tool_prompt.md": () => import("./navigation_tool_prompt.js").then((e) => e.default)
315
317
  });
316
- async function Y(e) {
317
- const t = Object.entries(he).find(([r]) => r.endsWith(`/${e}.md`));
318
+ async function te(e) {
319
+ const t = Object.entries(we).find(([r]) => r.endsWith(`/${e}.md`));
318
320
  if (!t)
319
321
  throw new Error(`Prompt not found: ${e}
320
322
  Available prompts:
321
- ${Object.keys(he).join(`
323
+ ${Object.keys(we).join(`
322
324
  `)}`);
323
325
  return await t[1]();
324
326
  }
325
- const _t = (e, t = 300) => {
327
+ const Vt = (e, t = 300) => {
326
328
  const r = e.replace(/\s+/gu, " ").replace(/[*_`#>\-]/gu, "").trim();
327
329
  return r.length > t ? `${r.slice(0, t)}...` : r;
328
- }, we = (e, t) => {
329
- const o = e?.configurable?.services?.[t];
330
- if (o == null)
330
+ }, Re = (e, t) => {
331
+ const a = e?.configurable?.services?.[t];
332
+ if (a == null)
331
333
  throw new Error(`${t} missing in config.configurable.services`);
332
- return o;
333
- }, kn = (e, t) => (r, o) => {
334
- const a = o?.configurable?.services;
334
+ return a;
335
+ }, Dn = (e, t) => (r, a) => {
336
+ const o = a?.configurable?.services;
335
337
  for (const n of e)
336
- if (!a?.[n])
338
+ if (!o?.[n])
337
339
  throw new Error(`${t} requires services.${n} to be available.`);
338
340
  return r;
339
341
  };
340
- async function Wt(e) {
341
- const { fields: t, layer: r, view: o, styleName: a, colorSchemeTags: n } = e;
342
- let s;
343
- return n ? s = Ge({
344
- basemapTheme: await ue(o),
342
+ async function Ut(e) {
343
+ const { fields: t, layer: r, view: a, styleName: o, colorSchemeTags: n } = e;
344
+ let l;
345
+ return n ? l = Me({
346
+ basemapTheme: await ye(a),
345
347
  geometryType: r.geometryType,
346
348
  includedTags: n,
347
349
  numColors: Math.min(t.length, 8)
348
- })[0] : s = Oe({
349
- basemapTheme: await ue(o),
350
+ })[0] : l = Qe({
351
+ basemapTheme: await ye(a),
350
352
  geometryType: r.geometryType,
351
353
  numColors: Math.min(t.length, 8)
352
354
  }).primaryScheme, {
353
355
  layer: r,
354
- view: o,
355
- attributes: t.map((c) => ({
356
- field: c,
357
- label: r.fields.find((u) => u.name === c)?.alias ?? ""
356
+ view: a,
357
+ attributes: t.map((s) => ({
358
+ field: s,
359
+ label: r.fields.find((c) => c.name === s)?.alias ?? ""
358
360
  })).slice(0, 8),
359
361
  outlineOptimizationEnabled: !0,
360
362
  sizeOptimizationEnabled: !0,
361
- includeSizeVariable: a.includes("Size"),
362
- pieChartScheme: s
363
+ includeSizeVariable: o.includes("Size"),
364
+ pieChartScheme: l
363
365
  };
364
366
  }
365
- async function Vt(e) {
366
- return await je(e);
367
+ async function Kt(e) {
368
+ return await Oe(e);
367
369
  }
368
- async function Ut({
370
+ async function Bt({
369
371
  arcgisMap: e,
370
372
  arcgisMapView: t,
371
373
  layerId: r,
372
- fields: o,
373
- colorSchemes: a,
374
+ fields: a,
375
+ colorSchemes: o,
374
376
  includeSize: n
375
377
  }) {
376
- const s = t, c = e?.allLayers.find((d) => d.id === r);
377
- if (!c)
378
+ const l = t, s = e?.allLayers.find((d) => d.id === r);
379
+ if (!s)
378
380
  return `Could not find layer for id: ${r}`;
379
- const l = {
381
+ const u = {
380
382
  styleName: n ? "chart-size" : "chart",
381
- fields: o,
382
- layer: c,
383
- view: s,
384
- colorSchemeTags: a
383
+ fields: a,
384
+ layer: s,
385
+ view: l,
386
+ colorSchemeTags: o
385
387
  };
386
388
  try {
387
- const d = await Wt(l), p = await Vt(d);
388
- return c.renderer = p.renderer, c.visible = !0, `Chart renderer applied to layer: ${c.title ?? c.id} using fields ${o.join(", ")}`;
389
+ const d = await Ut(u), p = await Kt(d);
390
+ return s.renderer = p.renderer, s.visible = !0, `Chart renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
389
391
  } catch (d) {
390
392
  return `Error applying chart renderer: ${d instanceof Error ? d.message : String(d)}`;
391
393
  }
392
394
  }
393
- const Kt = ["mapView"];
395
+ const Ht = ["mapView"];
394
396
  function R(e) {
395
397
  const r = e?.configurable?.context;
396
398
  if (!r || typeof r != "object")
397
399
  throw new Error("LayerStylingAgent context missing");
398
- const o = Kt.filter((a) => !(a in r));
399
- if (o.length)
400
- throw new Error(`LayerStylingAgent context missing: ${o.join(", ")}`);
400
+ const a = Ht.filter((o) => !(o in r));
401
+ if (a.length)
402
+ throw new Error(`LayerStylingAgent context missing: ${a.join(", ")}`);
401
403
  return r;
402
404
  }
403
- async function Bt({
405
+ async function Jt({
404
406
  layerId: e,
405
407
  fields: t,
406
408
  colorSchemes: r,
407
- includeSize: o
408
- }, a) {
409
- const { mapView: n } = R(a);
410
- return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await Ut({
409
+ includeSize: a
410
+ }, o) {
411
+ const { mapView: n } = R(o);
412
+ return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await Bt({
411
413
  arcgisMap: n.map,
412
414
  arcgisMapView: n,
413
415
  layerId: e,
414
416
  fields: t,
415
417
  colorSchemes: r,
416
- includeSize: o
418
+ includeSize: a
417
419
  });
418
420
  }
419
- const Ht = i.object({
421
+ const Zt = i.object({
420
422
  layerId: i.string().describe("The id of the layer to apply the chart renderer to"),
421
423
  fields: i.array(i.string()).describe("The fields to use for the chart renderer (multiple numeric fields)"),
422
424
  colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
423
425
  includeSize: i.boolean().optional().describe("Whether to vary the chart size (chart-size)")
424
- }), Nn = f(Bt, {
426
+ }), An = f(Jt, {
425
427
  name: "chart",
426
428
  description: `Label: Charts
427
429
  Description: Show the values of two or more categories as a proportion of the total using a pie chart.
@@ -434,308 +436,308 @@ const Ht = i.object({
434
436
  Keywords: pie, chart, all categories, breakdown, proportion, total, amount, how much, sum, graduated size, proportional size
435
437
  Example: Show the total number of homes built in each decade using a pie chart for each feature and vary the size of each chart based on the total of all categories.
436
438
  Fields: This style requires 2-8 number fields.`,
437
- schema: Ht
439
+ schema: Zt
438
440
  });
439
- function Jt(e) {
440
- const { fields: t, layer: r, view: o, theme: a, colorSchemeTags: n } = e, s = t[0];
441
- let c;
442
- return n && (c = re({
441
+ function Yt(e) {
442
+ const { fields: t, layer: r, view: a, theme: o, colorSchemeTags: n } = e, l = t[0];
443
+ let s;
444
+ return n && (s = le({
443
445
  geometryType: r.geometryType,
444
446
  includedTags: n,
445
- theme: a || "high-to-low"
447
+ theme: o || "high-to-low"
446
448
  })[0]), {
447
449
  layer: r,
448
- view: o,
449
- startTime: s,
450
+ view: a,
451
+ startTime: l,
450
452
  endTime: /* @__PURE__ */ new Date(),
451
- theme: a,
453
+ theme: o,
452
454
  sizeOptimizationEnabled: !0,
453
455
  outlineOptimizationEnabled: !0,
454
- colorScheme: c
456
+ colorScheme: s
455
457
  };
456
458
  }
457
- async function Zt(e) {
458
- return await Me(e);
459
+ async function Xt(e) {
460
+ return await _e(e);
459
461
  }
460
- async function Yt({
462
+ async function er({
461
463
  arcgisMap: e,
462
464
  arcgisMapView: t,
463
465
  layerId: r,
464
- fields: o,
465
- colorSchemes: a,
466
+ fields: a,
467
+ colorSchemes: o,
466
468
  theme: n
467
469
  }) {
468
- const s = t, c = e?.allLayers.find((l) => l.id === r);
469
- if (!c)
470
+ const l = t, s = e?.allLayers.find((u) => u.id === r);
471
+ if (!s)
470
472
  return `Could not find layer for id: ${r}`;
471
- const u = {
473
+ const c = {
472
474
  styleName: "color-age",
473
- fields: o,
474
- layer: c,
475
- view: s,
476
- colorSchemeTags: a,
475
+ fields: a,
476
+ layer: s,
477
+ view: l,
478
+ colorSchemeTags: o,
477
479
  theme: n
478
480
  };
479
481
  try {
480
- const l = Jt(u), d = await Zt(l);
481
- return c.renderer = d.renderer, c.visible = !0, `Color-age renderer applied to layer: ${c.title ?? c.id} using fields ${o.join(", ")}`;
482
- } catch (l) {
483
- return `Error applying color-age renderer: ${l instanceof Error ? l.message : String(l)}`;
482
+ const u = Yt(c), d = await Xt(u);
483
+ return s.renderer = d.renderer, s.visible = !0, `Color-age renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
484
+ } catch (u) {
485
+ return `Error applying color-age renderer: ${u instanceof Error ? u.message : String(u)}`;
484
486
  }
485
487
  }
486
- async function Xt({
488
+ async function tr({
487
489
  layerId: e,
488
490
  fields: t,
489
491
  colorSchemes: r,
490
- theme: o
491
- }, a) {
492
- const { mapView: n } = R(a);
493
- return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await Yt({
492
+ theme: a
493
+ }, o) {
494
+ const { mapView: n } = R(o);
495
+ return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await er({
494
496
  arcgisMap: n.map,
495
497
  arcgisMapView: n,
496
498
  layerId: e,
497
499
  fields: t,
498
500
  colorSchemes: r,
499
- theme: o
501
+ theme: a
500
502
  });
501
503
  }
502
- const er = i.object({
504
+ const rr = i.object({
503
505
  layerId: i.string().describe("The id of the layer to apply the color-age renderer to"),
504
506
  fields: i.array(i.string()).describe("The field(s) to use for the color-age renderer (temporal/date data)"),
505
507
  colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
506
508
  theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color ramp")
507
- }), zn = f(Xt, {
509
+ }), Pn = f(tr, {
508
510
  name: "color-age",
509
511
  description: `Label: Age (color)
510
512
  Description: Use colors along a continuous color ramp to represent the age of features. Age reflects the length of time from a start date to an end date.
511
513
  Keywords: since, age, how old, how long
512
514
  Example: Show the age of each feature based on its reported date.
513
515
  Fields: This style requires at least one field with a date type.`,
514
- schema: er
516
+ schema: rr
515
517
  });
516
- function tr(e) {
517
- const { fields: t, layer: r, view: o, colorSchemeTags: a } = e;
518
- let { theme: n } = e, s = t[1];
519
- const c = t[0];
520
- let u;
521
- return a && (u = re({
518
+ function ar(e) {
519
+ const { fields: t, layer: r, view: a, colorSchemeTags: o } = e;
520
+ let { theme: n } = e, l = t[1];
521
+ const s = t[0];
522
+ let c;
523
+ return o && (c = le({
522
524
  geometryType: r.geometryType,
523
- includedTags: a,
525
+ includedTags: o,
524
526
  theme: n || "high-to-low"
525
527
  })[0]), {
526
528
  layer: r,
527
- view: o,
528
- field: c,
529
- normalizationField: s,
529
+ view: a,
530
+ field: s,
531
+ normalizationField: l,
530
532
  theme: n,
531
533
  sizeOptimizationEnabled: !0,
532
534
  outlineOptimizationEnabled: !0,
533
- colorScheme: u
535
+ colorScheme: c
534
536
  };
535
537
  }
536
- async function rr(e) {
537
- return await Qe(e);
538
+ async function or(e) {
539
+ return await We(e);
538
540
  }
539
- async function or({
541
+ async function nr({
540
542
  arcgisMap: e,
541
543
  arcgisMapView: t,
542
544
  layerId: r,
543
- fields: o,
544
- colorSchemes: a,
545
+ fields: a,
546
+ colorSchemes: o,
545
547
  theme: n
546
548
  }) {
547
- const s = t, c = e?.allLayers.find((l) => l.id === r);
548
- if (!c)
549
+ const l = t, s = e?.allLayers.find((u) => u.id === r);
550
+ if (!s)
549
551
  return `Could not find layer for id: ${r}`;
550
- const u = {
552
+ const c = {
551
553
  styleName: "color",
552
- fields: o,
553
- layer: c,
554
- view: s,
555
- colorSchemeTags: a,
554
+ fields: a,
555
+ layer: s,
556
+ view: l,
557
+ colorSchemeTags: o,
556
558
  theme: n
557
559
  };
558
560
  try {
559
- const l = tr(u), d = await rr(l);
560
- return c.renderer = d.renderer, c.visible = !0, `Color renderer applied to layer: ${c.title ?? c.id} using fields ${o.join(", ")}`;
561
- } catch (l) {
562
- return `Error applying color renderer: ${l instanceof Error ? l.message : String(l)}`;
561
+ const u = ar(c), d = await or(u);
562
+ return s.renderer = d.renderer, s.visible = !0, `Color renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
563
+ } catch (u) {
564
+ return `Error applying color renderer: ${u instanceof Error ? u.message : String(u)}`;
563
565
  }
564
566
  }
565
- async function ar({
567
+ async function ir({
566
568
  layerId: e,
567
569
  fields: t,
568
570
  colorSchemes: r,
569
- theme: o
570
- }, a) {
571
- const { mapView: n } = R(a);
572
- return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await or({
571
+ theme: a
572
+ }, o) {
573
+ const { mapView: n } = R(o);
574
+ return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await nr({
573
575
  arcgisMap: n.map,
574
576
  arcgisMapView: n,
575
577
  layerId: e,
576
578
  fields: t,
577
579
  colorSchemes: r,
578
- theme: o
580
+ theme: a
579
581
  });
580
582
  }
581
- const nr = i.object({
583
+ const sr = i.object({
582
584
  layerId: i.string().describe("The id of the layer to apply the color renderer to"),
583
585
  fields: i.array(i.string()).describe("The field(s) to use for the color renderer"),
584
586
  colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
585
587
  theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color ramp")
586
- }), qn = f(ar, {
588
+ }), Ln = f(ir, {
587
589
  name: "color",
588
590
  description: `Label: Counts and Amounts (color)
589
591
  Description: Vary color along a continuous color ramp to represent numeric or ranked data.
590
592
  Keywords: graduated color, choropleth, continuous color, hue, color, gradation, saturation, lightness, percent, rate, ratio, index, how much, increase, decrease
591
593
  Example: Color each feature based on the population density.
592
594
  Fields: This style requires a single field with a number type. A second number field may be specified for normalizing the value of the first field.`,
593
- schema: nr
595
+ schema: sr
594
596
  });
595
- function ir(e) {
596
- const { fields: t, layer: r, view: o, colorSchemeTags: a, theme: n } = e;
597
- let s, c;
598
- const u = t[0];
599
- return a && (c = re({
597
+ function lr(e) {
598
+ const { fields: t, layer: r, view: a, colorSchemeTags: o, theme: n } = e;
599
+ let l, s;
600
+ const c = t[0];
601
+ return o && (s = le({
600
602
  geometryType: r.geometryType,
601
- includedTags: a,
603
+ includedTags: o,
602
604
  theme: n || "high-to-low"
603
605
  })[0]), {
604
606
  layer: r,
605
- view: o,
606
- field: u,
607
- normalizationField: s,
607
+ view: a,
608
+ field: c,
609
+ normalizationField: l,
608
610
  theme: n,
609
611
  colorOptions: {
610
- colorScheme: c
612
+ colorScheme: s
611
613
  }
612
614
  };
613
615
  }
614
- async function sr(e) {
615
- return await _e(e);
616
+ async function cr(e) {
617
+ return await Ve(e);
616
618
  }
617
- async function cr({
619
+ async function ur({
618
620
  arcgisMap: e,
619
621
  arcgisMapView: t,
620
622
  layerId: r,
621
- fields: o,
622
- colorSchemes: a,
623
+ fields: a,
624
+ colorSchemes: o,
623
625
  theme: n
624
626
  }) {
625
- const s = t, c = e?.allLayers.find((l) => l.id === r);
626
- if (!c)
627
+ const l = t, s = e?.allLayers.find((u) => u.id === r);
628
+ if (!s)
627
629
  return `Could not find layer for id: ${r}`;
628
- const u = {
630
+ const c = {
629
631
  styleName: "color-size-univariate",
630
- fields: o,
631
- layer: c,
632
- view: s,
633
- colorSchemeTags: a,
632
+ fields: a,
633
+ layer: s,
634
+ view: l,
635
+ colorSchemeTags: o,
634
636
  theme: n
635
637
  };
636
638
  try {
637
- const l = ir(u), d = await sr(l);
638
- return c.renderer = d.renderer, c.visible = !0, `Color-size-univariate renderer applied to layer: ${c.title ?? c.id} using fields ${o.join(", ")}`;
639
- } catch (l) {
640
- return `Error applying color-size-univariate renderer: ${l instanceof Error ? l.message : String(l)}`;
639
+ const u = lr(c), d = await cr(u);
640
+ return s.renderer = d.renderer, s.visible = !0, `Color-size-univariate renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
641
+ } catch (u) {
642
+ return `Error applying color-size-univariate renderer: ${u instanceof Error ? u.message : String(u)}`;
641
643
  }
642
644
  }
643
- async function lr({
645
+ async function dr({
644
646
  layerId: e,
645
647
  fields: t,
646
648
  colorSchemes: r,
647
- theme: o
648
- }, a) {
649
- const { mapView: n } = R(a);
650
- return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await cr({
649
+ theme: a
650
+ }, o) {
651
+ const { mapView: n } = R(o);
652
+ return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await ur({
651
653
  arcgisMap: n.map,
652
654
  arcgisMapView: n,
653
655
  layerId: e,
654
656
  fields: t,
655
657
  colorSchemes: r,
656
- theme: o
658
+ theme: a
657
659
  });
658
660
  }
659
- const ur = i.object({
661
+ const pr = i.object({
660
662
  layerId: i.string().describe("The id of the layer to apply the color-size univariate renderer to"),
661
663
  fields: i.array(i.string()).describe("The fields to use for the color-size univariate renderer"),
662
664
  colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
663
665
  theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color and size ramps")
664
- }), Dn = f(lr, {
666
+ }), jn = f(dr, {
665
667
  name: "color-size-univariate",
666
668
  description: `Label: Color and Size (univariate)
667
669
  Description: Vary symbol size and color based on the values of two numeric attributes.
668
670
  Keywords: continuous color, hue, color, size, gradation, saturation, lightness, percent, rate, ratio, index, how much, increase, decrease, amount
669
671
  Example: Color each feature based on the percentage of the population that owns a home and vary the size of each point based on total population.
670
672
  Fields: This style requires at least two fields: one determining the color of each feature, the other determining the size of each feature. Each field may be normalized by an additional normalization field.`,
671
- schema: ur
673
+ schema: pr
672
674
  });
673
- function dr(e) {
674
- const { fields: t, layer: r, view: o, colorSchemeTags: a } = e;
675
+ function mr(e) {
676
+ const { fields: t, layer: r, view: a, colorSchemeTags: o } = e;
675
677
  let n;
676
- return a && (n = Ve({
677
- includedTags: a,
678
+ return o && (n = Ke({
679
+ includedTags: o,
678
680
  numColors: Math.min(t.length, 8)
679
681
  })[0]), {
680
682
  layer: r,
681
- view: o,
683
+ view: a,
682
684
  legendOptions: {
683
685
  unit: "units"
684
686
  },
685
- attributes: t.map((s) => ({
686
- field: s,
687
- label: r.fields.find((c) => c.name === s)?.alias ?? ""
687
+ attributes: t.map((l) => ({
688
+ field: l,
689
+ label: r.fields.find((s) => s.name === l)?.alias ?? ""
688
690
  })).slice(0, 8),
689
691
  outlineOptimizationEnabled: !0,
690
692
  dotDensityScheme: n
691
693
  };
692
694
  }
693
- async function pr(e) {
694
- return await We(e);
695
+ async function hr(e) {
696
+ return await Ue(e);
695
697
  }
696
- async function hr({
698
+ async function yr({
697
699
  arcgisMap: e,
698
700
  arcgisMapView: t,
699
701
  layerId: r,
700
- fields: o,
701
- colorSchemes: a
702
+ fields: a,
703
+ colorSchemes: o
702
704
  }) {
703
- const n = t, s = e?.allLayers.find((u) => u.id === r);
704
- if (!s)
705
+ const n = t, l = e?.allLayers.find((c) => c.id === r);
706
+ if (!l)
705
707
  return `Could not find layer for id: ${r}`;
706
- const c = {
708
+ const s = {
707
709
  styleName: "dot-density",
708
- fields: o,
709
- layer: s,
710
+ fields: a,
711
+ layer: l,
710
712
  view: n,
711
- colorSchemeTags: a
713
+ colorSchemeTags: o
712
714
  };
713
715
  try {
714
- const u = dr(c), l = await pr(u);
715
- return s.renderer = l.renderer, s.visible = !0, `Dot Density renderer applied to layer: ${s.title ?? s.id} using fields ${o.join(", ")}`;
716
- } catch (u) {
717
- return `Error applying dot density renderer: ${u instanceof Error ? u.message : String(u)}`;
716
+ const c = mr(s), u = await hr(c);
717
+ return l.renderer = u.renderer, l.visible = !0, `Dot Density renderer applied to layer: ${l.title ?? l.id} using fields ${a.join(", ")}`;
718
+ } catch (c) {
719
+ return `Error applying dot density renderer: ${c instanceof Error ? c.message : String(c)}`;
718
720
  }
719
721
  }
720
- async function mr({
722
+ async function fr({
721
723
  layerId: e,
722
724
  fields: t,
723
725
  colorSchemes: r
724
- }, o) {
725
- const { mapView: a } = R(o);
726
- return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await hr({
727
- arcgisMap: a.map,
728
- arcgisMapView: a,
726
+ }, a) {
727
+ const { mapView: o } = R(a);
728
+ return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await yr({
729
+ arcgisMap: o.map,
730
+ arcgisMapView: o,
729
731
  layerId: e,
730
732
  fields: t,
731
733
  colorSchemes: r
732
734
  });
733
735
  }
734
- const yr = i.object({
736
+ const gr = i.object({
735
737
  layerId: i.string().describe("The id of the layer to apply the dot density renderer to"),
736
738
  fields: i.array(i.string()).describe("The field(s) to use for the dot density renderer (population or count data)"),
737
739
  colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use")
738
- }), An = f(mr, {
740
+ }), Gn = f(fr, {
739
741
  name: "dot-density",
740
742
  description: `Dot Density
741
743
  Use dot density to visualize the distribution of one attribute or compare the density of multiple attributes. This is only valid for polygon layers.
@@ -749,143 +751,143 @@ const yr = i.object({
749
751
  - Display demographic patterns within census tracts
750
752
  **Fields:** Requires 2-8 number fields.
751
753
  **Keywords:** density, how much, how many, total, number, amount`,
752
- schema: yr
754
+ schema: gr
753
755
  });
754
- function fr(e) {
755
- const { fields: t, layer: r, view: o, colorSchemeTags: a } = e;
756
+ function wr(e) {
757
+ const { fields: t, layer: r, view: a, colorSchemeTags: o } = e;
756
758
  let n;
757
- const s = t[0];
758
- return a && (n = Ke({
759
- includedTags: a,
760
- basemap: o.map?.basemap || "topo"
759
+ const l = t[0];
760
+ return o && (n = He({
761
+ includedTags: o,
762
+ basemap: a.map?.basemap || "topo"
761
763
  })[0]), {
762
764
  layer: r,
763
- view: o,
764
- field: s,
765
+ view: a,
766
+ field: l,
765
767
  heatmapScheme: n
766
768
  };
767
769
  }
768
- async function gr(e) {
769
- return await Ue(e);
770
+ async function br(e) {
771
+ return await Be(e);
770
772
  }
771
- async function wr({
773
+ async function Tr({
772
774
  arcgisMap: e,
773
775
  arcgisMapView: t,
774
776
  layerId: r,
775
- fields: o,
776
- colorSchemes: a
777
+ fields: a,
778
+ colorSchemes: o
777
779
  }) {
778
- const n = t, s = e?.allLayers.find((u) => u.id === r);
779
- if (!s)
780
+ const n = t, l = e?.allLayers.find((c) => c.id === r);
781
+ if (!l)
780
782
  return `Could not find layer for id: ${r}`;
781
- const c = {
783
+ const s = {
782
784
  styleName: "heatmap",
783
- fields: o,
784
- layer: s,
785
+ fields: a,
786
+ layer: l,
785
787
  view: n,
786
- colorSchemeTags: a
788
+ colorSchemeTags: o
787
789
  };
788
790
  try {
789
- const u = fr(c), l = await gr(u);
790
- return s.renderer = l.renderer, s.visible = !0, `Heatmap renderer applied to layer: ${s.title ?? s.id} using fields ${o.join(", ")}`;
791
- } catch (u) {
792
- return `Error applying heatmap renderer: ${u instanceof Error ? u.message : String(u)}`;
791
+ const c = wr(s), u = await br(c);
792
+ return l.renderer = u.renderer, l.visible = !0, `Heatmap renderer applied to layer: ${l.title ?? l.id} using fields ${a.join(", ")}`;
793
+ } catch (c) {
794
+ return `Error applying heatmap renderer: ${c instanceof Error ? c.message : String(c)}`;
793
795
  }
794
796
  }
795
- async function br({
797
+ async function vr({
796
798
  layerId: e,
797
799
  fields: t,
798
800
  colorSchemes: r
799
- }, o) {
800
- const { mapView: a } = R(o);
801
- return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await wr({
802
- arcgisMap: a.map,
803
- arcgisMapView: a,
801
+ }, a) {
802
+ const { mapView: o } = R(a);
803
+ return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await Tr({
804
+ arcgisMap: o.map,
805
+ arcgisMapView: o,
804
806
  layerId: e,
805
807
  fields: t,
806
808
  colorSchemes: r
807
809
  });
808
810
  }
809
- const Tr = i.object({
811
+ const Sr = i.object({
810
812
  layerId: i.string().describe("The id of the layer to apply the heatmap renderer to"),
811
813
  fields: i.array(i.string()).describe("The field(s) to use for the heatmap renderer (typically point density)"),
812
814
  colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use")
813
- }), Ln = f(br, {
815
+ }), On = f(vr, {
814
816
  name: "heatmap",
815
817
  description: `Label: Heat Map
816
818
  Description: Show areas of high density with colors that appear to glow hotter. This is only valid for point layers.
817
819
  Keywords: density, heatmap, hot spots, pattern, cluster
818
820
  Example: Create a heatmap
819
821
  Fields: This typically requires zero or one field of type number.`,
820
- schema: Tr
822
+ schema: Sr
821
823
  });
822
- function vr(e) {
823
- const { fields: t, layer: r, view: o, styleName: a, colorSchemeTags: n } = e;
824
- let s;
825
- return n && (s = He({
824
+ function xr(e) {
825
+ const { fields: t, layer: r, view: a, styleName: o, colorSchemeTags: n } = e;
826
+ let l;
827
+ return n && (l = Ze({
826
828
  geometryType: r.geometryType,
827
829
  includedTags: n,
828
830
  numColors: Math.min(t.length, 10)
829
831
  })[0]), {
830
832
  layer: r,
831
- view: o,
832
- fields: t.map((c) => ({ name: c })).slice(0, 9),
833
+ view: a,
834
+ fields: t.map((s) => ({ name: s })).slice(0, 9),
833
835
  outlineOptimizationEnabled: !0,
834
836
  sizeOptimizationEnabled: !0,
835
- includeSizeVariable: a.includes("Size"),
836
- predominanceScheme: s
837
+ includeSizeVariable: o.includes("Size"),
838
+ predominanceScheme: l
837
839
  };
838
840
  }
839
- async function Sr(e) {
840
- return await Be(e);
841
+ async function Rr(e) {
842
+ return await Je(e);
841
843
  }
842
- async function xr({
844
+ async function $r({
843
845
  arcgisMap: e,
844
846
  arcgisMapView: t,
845
847
  layerId: r,
846
- fields: o,
847
- colorSchemes: a,
848
+ fields: a,
849
+ colorSchemes: o,
848
850
  includeSize: n
849
851
  }) {
850
- const s = t, c = e?.allLayers.find((d) => d.id === r);
851
- if (!c)
852
+ const l = t, s = e?.allLayers.find((d) => d.id === r);
853
+ if (!s)
852
854
  return `Could not find layer for id: ${r}`;
853
- const l = {
855
+ const u = {
854
856
  styleName: n ? "predominance-size" : "predominance",
855
- fields: o,
856
- layer: c,
857
- view: s,
858
- colorSchemeTags: a
857
+ fields: a,
858
+ layer: s,
859
+ view: l,
860
+ colorSchemeTags: o
859
861
  };
860
862
  try {
861
- const d = vr(l), p = await Sr(d);
862
- return c.renderer = p.renderer, c.visible = !0, `Predominance renderer applied to layer: ${c.title ?? c.id} using fields ${o.join(", ")}`;
863
+ const d = xr(u), p = await Rr(d);
864
+ return s.renderer = p.renderer, s.visible = !0, `Predominance renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
863
865
  } catch (d) {
864
866
  return `Error applying predominance renderer: ${d instanceof Error ? d.message : String(d)}`;
865
867
  }
866
868
  }
867
- async function Rr({
869
+ async function Cr({
868
870
  layerId: e,
869
871
  fields: t,
870
872
  colorSchemes: r,
871
- includeSize: o
872
- }, a) {
873
- const { mapView: n } = R(a);
874
- return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await xr({
873
+ includeSize: a
874
+ }, o) {
875
+ const { mapView: n } = R(o);
876
+ return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await $r({
875
877
  arcgisMap: n.map,
876
878
  arcgisMapView: n,
877
879
  layerId: e,
878
880
  fields: t,
879
881
  colorSchemes: r,
880
- includeSize: o
882
+ includeSize: a
881
883
  });
882
884
  }
883
- const $r = i.object({
885
+ const Er = i.object({
884
886
  layerId: i.string().describe("The id of the layer to apply the predominance renderer to"),
885
887
  fields: i.array(i.string()).describe("The fields to use for the predominance renderer (competing categories)"),
886
888
  colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
887
889
  includeSize: i.boolean().optional().describe("Whether to include size visualization (predominance-size)")
888
- }), Pn = f(Rr, {
890
+ }), Mn = f(Cr, {
889
891
  name: "predominance",
890
892
  description: `Label: Predominant category
891
893
  Description: Compare attributes that share a common subject and unit of measurement to see which has the highest value.
@@ -898,219 +900,219 @@ const $r = i.object({
898
900
  Keywords: predominant, winner, won, competing, most, most common, most frequent, dominant, prevalent, top, amount, total, how much, proportional size, graduated size, sum
899
901
  Example: Show the predominant crop in each area and vary the size of each symbol based on the total of all categories.
900
902
  Fields: This style relies on 2-10 number fields.`,
901
- schema: $r
903
+ schema: Er
902
904
  });
903
- function Er(e) {
904
- const { fields: t, layer: r, view: o, colorSchemeTags: a } = e;
905
+ function Nr(e) {
906
+ const { fields: t, layer: r, view: a, colorSchemeTags: o } = e;
905
907
  let n;
906
- const s = {
908
+ const l = {
907
909
  field: t[0]
908
- }, c = {
910
+ }, s = {
909
911
  field: t[1]
910
912
  };
911
- return a && (n = Ze({
913
+ return o && (n = Xe({
912
914
  geometryType: r.geometryType,
913
- includedTags: a
915
+ includedTags: o
914
916
  })[0]), {
915
917
  layer: r,
916
- view: o,
917
- field1: s,
918
- field2: c,
918
+ view: a,
919
+ field1: l,
920
+ field2: s,
919
921
  outlineOptimizationEnabled: !0,
920
922
  sizeOptimizationEnabled: !0,
921
923
  relationshipScheme: n
922
924
  };
923
925
  }
924
- async function Cr(e) {
925
- return await Je(e);
926
+ async function Ir(e) {
927
+ return await Ye(e);
926
928
  }
927
- async function Ir({
929
+ async function kr({
928
930
  arcgisMap: e,
929
931
  arcgisMapView: t,
930
932
  layerId: r,
931
- fields: o,
932
- colorSchemes: a
933
+ fields: a,
934
+ colorSchemes: o
933
935
  }) {
934
- const n = t, s = e?.allLayers.find((u) => u.id === r);
935
- if (!s)
936
+ const n = t, l = e?.allLayers.find((c) => c.id === r);
937
+ if (!l)
936
938
  return `Could not find layer for id: ${r}`;
937
- const c = {
939
+ const s = {
938
940
  styleName: "relationship",
939
- fields: o,
940
- layer: s,
941
+ fields: a,
942
+ layer: l,
941
943
  view: n,
942
- colorSchemeTags: a
944
+ colorSchemeTags: o
943
945
  };
944
946
  try {
945
- const u = Er(c), l = await Cr(u);
946
- return s.renderer = l.renderer, s.visible = !0, `Relationship renderer applied to layer: ${s.title ?? s.id} using fields ${o.join(", ")}`;
947
- } catch (u) {
948
- return `Error applying relationship renderer: ${u instanceof Error ? u.message : String(u)}`;
947
+ const c = Nr(s), u = await Ir(c);
948
+ return l.renderer = u.renderer, l.visible = !0, `Relationship renderer applied to layer: ${l.title ?? l.id} using fields ${a.join(", ")}`;
949
+ } catch (c) {
950
+ return `Error applying relationship renderer: ${c instanceof Error ? c.message : String(c)}`;
949
951
  }
950
952
  }
951
953
  async function Fr({
952
954
  layerId: e,
953
955
  fields: t,
954
956
  colorSchemes: r
955
- }, o) {
956
- const { mapView: a } = R(o);
957
- return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await Ir({
958
- arcgisMap: a.map,
959
- arcgisMapView: a,
957
+ }, a) {
958
+ const { mapView: o } = R(a);
959
+ return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await kr({
960
+ arcgisMap: o.map,
961
+ arcgisMapView: o,
960
962
  layerId: e,
961
963
  fields: t,
962
964
  colorSchemes: r
963
965
  });
964
966
  }
965
- const kr = i.object({
967
+ const zr = i.object({
966
968
  layerId: i.string().describe("The id of the layer to apply the relationship renderer to"),
967
969
  fields: i.array(i.string()).describe("The two fields to use for the relationship renderer (bivariate visualization)"),
968
970
  colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use")
969
- }), jn = f(Fr, {
971
+ }), Qn = f(Fr, {
970
972
  name: "relationship",
971
973
  description: `Label: Relationship
972
974
  Description: Overlays two color ramps to represent the relationship between two numeric attributes.
973
975
  Keywords: relationship, correlation, compare, related, bivariate choropleth, bivariate color
974
976
  Example: Show the relationship between tree height and carbon storage
975
977
  Fields: This style requires two number fields.`,
976
- schema: kr
978
+ schema: zr
977
979
  });
978
- function Nr(e) {
979
- const { fields: t, layer: r, view: o, theme: a } = e, n = t[0];
980
+ function qr(e) {
981
+ const { fields: t, layer: r, view: a, theme: o } = e, n = t[0];
980
982
  return {
981
983
  layer: r,
982
- view: o,
984
+ view: a,
983
985
  startTime: n,
984
986
  endTime: /* @__PURE__ */ new Date(),
985
- theme: a,
987
+ theme: o,
986
988
  sizeOptimizationEnabled: !0,
987
989
  outlineOptimizationEnabled: !0
988
990
  };
989
991
  }
990
- async function zr(e) {
991
- return await Ye(e);
992
+ async function Dr(e) {
993
+ return await et(e);
992
994
  }
993
- async function qr({
995
+ async function Ar({
994
996
  arcgisMap: e,
995
997
  arcgisMapView: t,
996
998
  layerId: r,
997
- fields: o,
998
- colorSchemes: a,
999
+ fields: a,
1000
+ colorSchemes: o,
999
1001
  theme: n
1000
1002
  }) {
1001
- const s = t, c = e?.allLayers.find((l) => l.id === r);
1002
- if (!c)
1003
+ const l = t, s = e?.allLayers.find((u) => u.id === r);
1004
+ if (!s)
1003
1005
  return `Could not find layer for id: ${r}`;
1004
- const u = {
1006
+ const c = {
1005
1007
  styleName: "size-age",
1006
- fields: o,
1007
- layer: c,
1008
- view: s,
1009
- colorSchemeTags: a,
1008
+ fields: a,
1009
+ layer: s,
1010
+ view: l,
1011
+ colorSchemeTags: o,
1010
1012
  theme: n
1011
1013
  };
1012
1014
  try {
1013
- const l = Nr(u), d = await zr(l);
1014
- return c.renderer = d.renderer, c.visible = !0, `Size-age renderer applied to layer: ${c.title ?? c.id} using fields ${o.join(", ")}`;
1015
- } catch (l) {
1016
- return `Error applying size-age renderer: ${l instanceof Error ? l.message : String(l)}`;
1015
+ const u = qr(c), d = await Dr(u);
1016
+ return s.renderer = d.renderer, s.visible = !0, `Size-age renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
1017
+ } catch (u) {
1018
+ return `Error applying size-age renderer: ${u instanceof Error ? u.message : String(u)}`;
1017
1019
  }
1018
1020
  }
1019
- async function Dr({
1021
+ async function Pr({
1020
1022
  layerId: e,
1021
1023
  fields: t,
1022
1024
  colorSchemes: r,
1023
- theme: o
1024
- }, a) {
1025
- const { mapView: n } = R(a);
1026
- return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await qr({
1025
+ theme: a
1026
+ }, o) {
1027
+ const { mapView: n } = R(o);
1028
+ return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await Ar({
1027
1029
  arcgisMap: n.map,
1028
1030
  arcgisMapView: n,
1029
1031
  layerId: e,
1030
1032
  fields: t,
1031
1033
  colorSchemes: r,
1032
- theme: o
1034
+ theme: a
1033
1035
  });
1034
1036
  }
1035
- const Ar = i.object({
1037
+ const Lr = i.object({
1036
1038
  layerId: i.string().describe("The id of the layer to apply the size-age renderer to"),
1037
1039
  fields: i.array(i.string()).describe("The field(s) to use for the size-age renderer (temporal data with size)"),
1038
1040
  colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
1039
1041
  theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the size ramp")
1040
- }), Gn = f(Dr, {
1042
+ }), _n = f(Pr, {
1041
1043
  name: "size-age",
1042
1044
  description: `Label: Age (size)
1043
1045
  Description: Vary symbol sizes along a continuous ramp to represent the age of features. Age reflects the length of time from a start date to an end date.
1044
1046
  Keywords: since, age, how old, how long
1045
1047
  Example: Change the size of features so older features are larger than new features.
1046
1048
  Fields: This style requires at least one field with a date type.`,
1047
- schema: Ar
1049
+ schema: Lr
1048
1050
  });
1049
- function Lr(e) {
1050
- const { fields: t, layer: r, view: o } = e;
1051
- let { theme: a } = e, n = t[1];
1052
- const s = t[0];
1051
+ function jr(e) {
1052
+ const { fields: t, layer: r, view: a } = e;
1053
+ let { theme: o } = e, n = t[1];
1054
+ const l = t[0];
1053
1055
  return {
1054
1056
  layer: r,
1055
- view: o,
1056
- field: s,
1057
+ view: a,
1058
+ field: l,
1057
1059
  normalizationField: n,
1058
- theme: a,
1060
+ theme: o,
1059
1061
  sizeOptimizationEnabled: !0,
1060
1062
  outlineOptimizationEnabled: !0
1061
1063
  };
1062
1064
  }
1063
- async function Pr(e) {
1064
- return await Xe(e);
1065
+ async function Gr(e) {
1066
+ return await tt(e);
1065
1067
  }
1066
- async function jr({
1068
+ async function Or({
1067
1069
  arcgisMap: e,
1068
1070
  arcgisMapView: t,
1069
1071
  layerId: r,
1070
- fields: o,
1071
- colorSchemes: a,
1072
+ fields: a,
1073
+ colorSchemes: o,
1072
1074
  theme: n
1073
1075
  }) {
1074
- const s = t, c = e?.allLayers.find((l) => l.id === r);
1075
- if (!c)
1076
+ const l = t, s = e?.allLayers.find((u) => u.id === r);
1077
+ if (!s)
1076
1078
  return `Could not find layer for id: ${r}`;
1077
- const u = {
1079
+ const c = {
1078
1080
  styleName: "size",
1079
- fields: o,
1080
- layer: c,
1081
- view: s,
1082
- colorSchemeTags: a,
1081
+ fields: a,
1082
+ layer: s,
1083
+ view: l,
1084
+ colorSchemeTags: o,
1083
1085
  theme: n
1084
1086
  };
1085
1087
  try {
1086
- const l = Lr(u), d = await Pr(l);
1087
- return c.renderer = d.renderer, c.visible = !0, `Size renderer applied to layer: ${c.title ?? c.id} using fields ${o.join(", ")}`;
1088
- } catch (l) {
1089
- return `Error applying size renderer: ${l instanceof Error ? l.message : String(l)}`;
1088
+ const u = jr(c), d = await Gr(u);
1089
+ return s.renderer = d.renderer, s.visible = !0, `Size renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
1090
+ } catch (u) {
1091
+ return `Error applying size renderer: ${u instanceof Error ? u.message : String(u)}`;
1090
1092
  }
1091
1093
  }
1092
- async function Gr({
1094
+ async function Mr({
1093
1095
  layerId: e,
1094
1096
  fields: t,
1095
1097
  colorSchemes: r,
1096
- theme: o
1097
- }, a) {
1098
- const { mapView: n } = R(a);
1099
- return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await jr({
1098
+ theme: a
1099
+ }, o) {
1100
+ const { mapView: n } = R(o);
1101
+ return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await Or({
1100
1102
  arcgisMap: n.map,
1101
1103
  arcgisMapView: n,
1102
1104
  layerId: e,
1103
1105
  fields: t,
1104
1106
  colorSchemes: r,
1105
- theme: o
1107
+ theme: a
1106
1108
  });
1107
1109
  }
1108
- const Or = i.object({
1110
+ const Qr = i.object({
1109
1111
  layerId: i.string().describe("The id of the layer to apply the size renderer to"),
1110
1112
  fields: i.array(i.string()).describe("The field(s) to use for the size renderer (numeric data)"),
1111
1113
  colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
1112
1114
  theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the size ramp")
1113
- }), On = f(Gr, {
1115
+ }), Wn = f(Mr, {
1114
1116
  name: "size",
1115
1117
  description: `Label: Counts and Amounts (size)
1116
1118
  Description: Vary symbol sizes along a continuous ramp to represent numeric or ranked data.
@@ -1123,255 +1125,252 @@ const Or = i.object({
1123
1125
  Keywords: graduated size, proportional size, classed size, how much, total, number, when
1124
1126
  Example: Vary the size of each feature based on the date a ticket was completed.
1125
1127
  Fields: This style requires a single field with a date type.`,
1126
- schema: Or
1128
+ schema: Qr
1127
1129
  });
1128
- function Mr(e) {
1129
- const { fields: t, layer: r, view: o, colorSchemeTags: a } = e, n = t[0], s = t[1], c = t[2];
1130
- let u;
1131
- return a && (u = tt({
1130
+ function _r(e) {
1131
+ const { fields: t, layer: r, view: a, colorSchemeTags: o } = e, n = t[0], l = t[1], s = t[2];
1132
+ let c;
1133
+ return o && (c = at({
1132
1134
  geometryType: r.geometryType,
1133
- includedTags: a
1135
+ includedTags: o
1134
1136
  })[0]), {
1135
1137
  layer: r,
1136
- view: o,
1138
+ view: a,
1137
1139
  field: n,
1138
- field2: s,
1139
- field3: c,
1140
+ field2: l,
1141
+ field3: s,
1140
1142
  outlineOptimizationEnabled: !0,
1141
1143
  sizeOptimizationEnabled: !0,
1142
- typeScheme: u
1144
+ typeScheme: c
1143
1145
  };
1144
1146
  }
1145
- async function Qr(e) {
1146
- return await et(e);
1147
+ async function Wr(e) {
1148
+ return await rt(e);
1147
1149
  }
1148
- async function _r({
1150
+ async function Vr({
1149
1151
  arcgisMap: e,
1150
1152
  arcgisMapView: t,
1151
1153
  layerId: r,
1152
- fields: o,
1153
- colorSchemes: a,
1154
+ fields: a,
1155
+ colorSchemes: o,
1154
1156
  theme: n
1155
1157
  }) {
1156
- const s = t, c = e?.allLayers.find((l) => l.id === r);
1157
- if (!c)
1158
+ const l = t, s = e?.allLayers.find((u) => u.id === r);
1159
+ if (!s)
1158
1160
  return `Could not find layer for id: ${r}`;
1159
- const u = {
1161
+ const c = {
1160
1162
  styleName: "type",
1161
- fields: o,
1162
- layer: c,
1163
- view: s,
1164
- colorSchemeTags: a,
1163
+ fields: a,
1164
+ layer: s,
1165
+ view: l,
1166
+ colorSchemeTags: o,
1165
1167
  theme: n
1166
1168
  };
1167
1169
  try {
1168
- const l = Mr(u), d = await Qr(l);
1169
- return c.renderer = d.renderer, c.visible = !0, `Type renderer applied to layer: ${c.title ?? c.id} using fields ${o.join(", ")}`;
1170
- } catch (l) {
1171
- return `Error applying type renderer: ${l instanceof Error ? l.message : String(l)}`;
1170
+ const u = _r(c), d = await Wr(u);
1171
+ return s.renderer = d.renderer, s.visible = !0, `Type renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
1172
+ } catch (u) {
1173
+ return `Error applying type renderer: ${u instanceof Error ? u.message : String(u)}`;
1172
1174
  }
1173
1175
  }
1174
- async function Wr({
1176
+ async function Ur({
1175
1177
  layerId: e,
1176
1178
  fields: t,
1177
1179
  colorSchemes: r,
1178
- theme: o
1179
- }, a) {
1180
- const { mapView: n } = R(a);
1181
- return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await _r({
1180
+ theme: a
1181
+ }, o) {
1182
+ const { mapView: n } = R(o);
1183
+ return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await Vr({
1182
1184
  arcgisMap: n.map,
1183
1185
  arcgisMapView: n,
1184
1186
  layerId: e,
1185
1187
  fields: t,
1186
1188
  colorSchemes: r,
1187
- theme: o
1189
+ theme: a
1188
1190
  });
1189
1191
  }
1190
- const Vr = i.object({
1192
+ const Kr = i.object({
1191
1193
  layerId: i.string().describe("The id of the layer to apply the type renderer to"),
1192
1194
  fields: i.array(i.string()).describe("The field(s) to use for the type renderer (categorical data)"),
1193
1195
  colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
1194
1196
  theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color scheme")
1195
- }), Mn = f(Wr, {
1197
+ }), Vn = f(Ur, {
1196
1198
  name: "type",
1197
1199
  description: `Label: Types (unique symbols)
1198
1200
  Description: Represent features as categories with different symbol colors or shapes. Examples include type of tree, road class, or province name.
1199
1201
  Keywords: categorical, category, type, unique, discrete, point of interest, region, group
1200
1202
  Example: Color each feature based on the region it belongs to
1201
1203
  Fields: This style requires a single field which may be a string, number, or date type. It is usually a string.`,
1202
- schema: Vr
1203
- }), Qn = b.Root({
1204
- ...U(),
1204
+ schema: Kr
1205
+ }), Un = b.Root({
1206
+ ...B(),
1205
1207
  vectorSearchLayerIds: b(),
1206
1208
  vectorSearchFieldResults: b(),
1207
1209
  layerFieldInfo: b(),
1208
1210
  selectedLayerId: b()
1209
- }), _n = b.Root({
1210
- ...U(),
1211
+ }), Kn = b.Root({
1212
+ ...B(),
1211
1213
  vectorSearchLayerIds: b(),
1212
1214
  vectorSearchFieldResults: b(),
1213
1215
  layerFieldInfo: b(),
1214
1216
  queryResponse: b(),
1215
1217
  dataExplorationMessages: b({
1216
- reducer: me,
1218
+ reducer: Te,
1217
1219
  default: () => []
1218
1220
  })
1219
- }), Ur = ["mapView"];
1220
- function N(e) {
1221
+ }), Br = ["mapView"];
1222
+ function F(e) {
1221
1223
  const r = e?.configurable?.context;
1222
1224
  if (!r || typeof r != "object")
1223
1225
  throw new Error("DataExplorationAgent context missing");
1224
- const o = Ur.filter((a) => !(a in r));
1225
- if (o.length)
1226
- throw new Error(`DataExplorationAgent context missing: ${o.join(", ")}`);
1226
+ const a = Br.filter((o) => !(o in r));
1227
+ if (a.length)
1228
+ throw new Error(`DataExplorationAgent context missing: ${a.join(", ")}`);
1227
1229
  return r;
1228
1230
  }
1229
- const Kr = (e) => {
1230
- const t = e.map?.allLayers.filter((o) => o.type === "feature");
1231
+ const Hr = (e) => {
1232
+ const t = e.map?.allLayers.filter((a) => a.type === "feature");
1231
1233
  let r = 0;
1232
- return t?.forEach((o) => {
1233
- const a = o;
1234
- a.featureEffect && (a.featureEffect = null, r++);
1234
+ return t?.forEach((a) => {
1235
+ const o = a;
1236
+ o.featureEffect && (o.featureEffect = null, r++);
1235
1237
  }), r > 0 ? `Cleared filters from ${r} layer(s). View unchanged.` : "No active filters to clear. View unchanged.";
1236
- }, Br = async (e, t) => {
1237
- const { mapView: r } = N(t);
1238
- return Kr(r);
1239
- }, Hr = f(Br, {
1238
+ }, Jr = async (e, t) => {
1239
+ const { mapView: r } = F(t);
1240
+ return Hr(r);
1241
+ }, Zr = f(Jr, {
1240
1242
  name: "clearFilters",
1241
1243
  description: "Clears all feature effects/filters from the map but does NOT change the current view. Use when user says 'clear filters', 'reset filters', 'remove filters', 'show all features', or wants to remove emphasis without navigating anywhere.",
1242
1244
  schema: i.object({})
1243
- }), Jr = async (e) => {
1244
- e.map?.allLayers.filter((a) => a.type === "feature")?.forEach((a) => {
1245
- const n = a;
1245
+ }), Yr = async (e) => {
1246
+ e.map?.allLayers.filter((o) => o.type === "feature")?.forEach((o) => {
1247
+ const n = o;
1246
1248
  n.featureEffect && (n.featureEffect = null);
1247
1249
  });
1248
- const o = e.map.initialViewProperties?.viewpoint?.targetGeometry;
1249
- return o ? (await e.goTo(o), "Cleared all filters and returned to home extent.") : "Cleared all filters. Could not determine home extent.";
1250
- }, Zr = async (e, t) => {
1251
- const { mapView: r } = N(t);
1252
- return await Jr(r);
1253
- }, Yr = f(Zr, {
1250
+ const a = e.map.initialViewProperties?.viewpoint?.targetGeometry;
1251
+ return a ? (await e.goTo(a), "Cleared all filters and returned to home extent.") : "Cleared all filters. Could not determine home extent.";
1252
+ }, Xr = async (e, t) => {
1253
+ const { mapView: r } = F(t);
1254
+ return await Yr(r);
1255
+ }, ea = f(Xr, {
1254
1256
  name: "resetMap",
1255
1257
  description: "Clears all feature effects/filters from the map AND zooms to the home extent (initial map view). Use when user says 'reset map', 'reset the map', 'start over', or wants to both clear filters and return to the initial view.",
1256
1258
  schema: i.object({})
1257
- });
1258
- function W(e) {
1259
+ }), be = 750;
1260
+ function U(e) {
1259
1261
  return "point" in e && e.point !== void 0;
1260
1262
  }
1261
- function P(e) {
1263
+ function j(e) {
1262
1264
  return "layerId" in e && e.layerId !== void 0;
1263
1265
  }
1264
- const K = async (e, t) => {
1265
- if (W(e)) {
1266
+ const H = async (e, t) => {
1267
+ if (U(e)) {
1266
1268
  const { point: r } = e;
1267
- return { geometry: new ye({
1269
+ return { geometry: new ve({
1268
1270
  x: r.x,
1269
1271
  y: r.y,
1270
1272
  spatialReference: r.spatialReference ? { wkid: r.spatialReference.wkid } : t.spatialReference
1271
1273
  }) };
1272
1274
  }
1273
- if (P(e)) {
1275
+ if (j(e)) {
1274
1276
  const r = t.map?.allLayers.find(
1275
- (a) => a.id === e.layerId
1277
+ (n) => n.id === e.layerId
1276
1278
  );
1277
1279
  if (!r)
1278
1280
  return { error: `Could not find geometry layer with ID: ${e.layerId}` };
1279
- const o = r.title ?? r.id;
1281
+ const a = r.title ?? r.id, o = e.where?.trim() || "1=1";
1280
1282
  try {
1281
- const a = await r.queryFeatures({
1282
- where: e.where,
1283
+ const n = await r.queryFeatures({
1284
+ where: o,
1283
1285
  returnGeometry: !0,
1284
- outSpatialReference: t.spatialReference
1286
+ outSpatialReference: t.spatialReference,
1287
+ num: be + 1
1285
1288
  });
1286
- if (!a.features.length)
1289
+ if (!n.features.length)
1287
1290
  return {
1288
- error: `No features found in geometry layer "${o}" with the specified where clause: ${e.where}`
1291
+ error: `No features found in geometry layer "${a}" with the specified where clause: ${o}`
1289
1292
  };
1290
- let n;
1291
- if (a.features.length === 1) {
1292
- const s = a.features[0].geometry;
1293
- if (!s)
1294
- return { error: "The geometry of the first feature is undefined or null." };
1295
- n = s;
1296
- } else {
1297
- const s = a.features.map((u) => u.geometry), c = at.executeMany(s);
1298
- if (!c)
1299
- return { error: "Failed to create a combined geometry." };
1300
- n = c;
1301
- }
1302
- return n.spatialReference || (n.spatialReference = t.spatialReference), { geometry: n };
1303
- } catch (a) {
1304
- return { error: `Failed to query geometry: ${String(a)}` };
1293
+ if (n.features.length > be)
1294
+ return {
1295
+ error: `Geometry filter for layer "${a}" matched too many features (${n.features.length}+). Please narrow the geometry layer filter.`
1296
+ };
1297
+ const l = n.features.map((c) => c.geometry).filter((c) => !!c);
1298
+ if (!l.length)
1299
+ return { error: "No valid geometries found for the matched geometry layer features." };
1300
+ const s = l.length === 1 ? l[0] : it.executeMany(l);
1301
+ return s ? (s.spatialReference || (s.spatialReference = t.spatialReference), { geometry: s }) : { error: "Failed to combine geometries from geometry layer." };
1302
+ } catch (n) {
1303
+ return { error: `Failed to query geometry: ${String(n)}` };
1305
1304
  }
1306
1305
  }
1307
1306
  return { error: "Invalid geometry configuration provided" };
1308
- }, Xr = async (e, t, r, o, a, n) => {
1309
- const s = e.map?.allLayers.find((u) => u.id === t);
1310
- if (!s)
1307
+ }, ta = async (e, t, r, a, o, n) => {
1308
+ const l = e.map?.allLayers.find((c) => c.id === t);
1309
+ if (!l)
1311
1310
  return { success: !1, error: `Layer '${t}' not found.` };
1312
- const c = s.createQuery();
1313
- c.where = r ?? "1=1", o && (c.geometry = o, c.spatialRelationship = "intersects", a && (c.distance = a), n && (c.units = n));
1311
+ const s = l.createQuery();
1312
+ s.where = r ?? "1=1", a && (s.geometry = a, s.spatialRelationship = "intersects", o && (s.distance = o), n && (s.units = n));
1314
1313
  try {
1315
- const { extent: u, count: l } = await s.queryExtent(c);
1316
- return !u || l === 0 ? {
1314
+ const { extent: c, count: u } = await l.queryExtent(s);
1315
+ return !c || u === 0 ? {
1317
1316
  success: !1,
1318
- error: `No features found for filter (where: ${c.where}${o ? ", spatial filter used" : ""})`
1319
- } : (await e.goTo(u), { success: !0 });
1320
- } catch (u) {
1317
+ error: `No features found for filter (where: ${s.where}${a ? ", spatial filter used" : ""})`
1318
+ } : (await e.goTo(c), { success: !0 });
1319
+ } catch (c) {
1321
1320
  return {
1322
1321
  success: !1,
1323
- error: u instanceof Error ? u.message : String(u)
1322
+ error: c instanceof Error ? c.message : String(c)
1324
1323
  };
1325
1324
  }
1326
- }, eo = async (e, t, r, o, a, n) => {
1327
- const s = t.map?.allLayers.find(
1325
+ }, ra = async (e, t, r, a, o, n) => {
1326
+ const l = t.map?.allLayers.find(
1328
1327
  (p) => p.id === e.layerId
1329
1328
  );
1330
- if (!s)
1329
+ if (!l)
1331
1330
  return `Could not find target layer with ID: ${e.layerId}`;
1332
- let c;
1333
- if (a) {
1334
- const p = await K(a, t);
1331
+ let s;
1332
+ if (o) {
1333
+ const p = await H(o, t);
1335
1334
  if ("error" in p)
1336
1335
  return p.error;
1337
- c = p.geometry;
1336
+ s = p.geometry;
1338
1337
  }
1339
- if (s.featureEffect = null, s.featureEffect = new ot({
1340
- filter: new fe({
1338
+ if (l.featureEffect = null, l.featureEffect = new nt({
1339
+ filter: new Se({
1341
1340
  ...e.objectIds?.length ? { objectIds: e.objectIds } : { where: e.where },
1342
- geometry: c,
1341
+ geometry: s,
1343
1342
  spatialRelationship: "intersects",
1344
- distance: a?.distance,
1345
- units: a?.units
1343
+ distance: o?.distance,
1344
+ units: o?.units
1346
1345
  }),
1347
1346
  includedEffect: r,
1348
- excludedEffect: o
1349
- }), s.visible = !0, n)
1350
- return `Applied feature effects to "${s.title ?? e.layerId}" within current map extent.`;
1351
- const u = e.objectIds?.length ? `${s.objectIdField} IN (${e.objectIds.join(",")})` : e.where, l = await Xr(
1347
+ excludedEffect: a
1348
+ }), l.visible = !0, n)
1349
+ return `Applied feature effects to "${l.title ?? e.layerId}" within current map extent.`;
1350
+ const c = e.objectIds?.length ? `${l.objectIdField} IN (${e.objectIds.join(",")})` : e.where, u = await ta(
1352
1351
  t,
1353
1352
  e.layerId,
1354
- u,
1355
1353
  c,
1356
- a?.distance,
1357
- a?.units
1358
- ), d = s.title ?? e.layerId;
1359
- return l.success ? `Applied feature effects to target layer "${s.title ?? e.layerId}"${a && "layerId" in a ? ` using geometry from layer "${a.layerId}"` : ""}.` : `Applied filter to "${d}" but no features matched. ${l.error}`;
1360
- }, to = ["feet", "kilometers", "meters", "miles", "nautical-miles", "us-nautical-miles"], I = i.enum(to), ro = async ({
1354
+ s,
1355
+ o?.distance,
1356
+ o?.units
1357
+ ), d = l.title ?? e.layerId;
1358
+ return u.success ? `Applied feature effects to target layer "${l.title ?? e.layerId}"${o && "layerId" in o ? ` using geometry from layer "${o.layerId}"` : ""}.` : `Applied filter to "${d}" but no features matched. ${u.error}`;
1359
+ }, aa = ["feet", "kilometers", "meters", "miles", "nautical-miles", "us-nautical-miles"], I = i.enum(aa), oa = async ({
1361
1360
  targetLayer: e,
1362
1361
  geometryFilter: t,
1363
1362
  useCurrentExtent: r,
1364
- includedEffect: o = "drop-shadow(2px, 2px, 2px, gray)",
1365
- excludedEffect: a = "grayscale(100%) opacity(60%) blur(2px)"
1363
+ includedEffect: a = "drop-shadow(2px, 2px, 2px, gray)",
1364
+ excludedEffect: o = "grayscale(100%) opacity(60%) blur(2px)"
1366
1365
  }, n) => {
1367
- const { mapView: s } = N(n);
1368
- return await eo(e, s, o, a, t, r);
1369
- }, oo = i.object({
1366
+ const { mapView: l } = F(n);
1367
+ return await ra(e, l, a, o, t, r);
1368
+ }, na = i.object({
1370
1369
  layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
1371
1370
  where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
1372
1371
  distance: i.number().optional().describe("The buffer distance around the geometry."),
1373
1372
  units: I.optional().describe("The units for the distance buffer.")
1374
- }), ao = i.object({
1373
+ }), ia = i.object({
1375
1374
  point: i.object({
1376
1375
  x: i.number().describe("X coordinate (longitude) from navigation result"),
1377
1376
  y: i.number().describe("Y coordinate (latitude) from navigation result"),
@@ -1381,7 +1380,7 @@ const K = async (e, t) => {
1381
1380
  }).describe("Point coordinates from a previous navigation/geocoding result"),
1382
1381
  distance: i.number().optional().describe("Optional buffer distance around the point."),
1383
1382
  units: I.optional().describe("The units for the distance buffer.")
1384
- }), no = i.object({
1383
+ }), sa = i.object({
1385
1384
  targetLayer: i.object({
1386
1385
  layerId: i.string().describe("The layerId of the layer on which to set a feature effect."),
1387
1386
  where: i.string().describe("The SQL-92 where clause representing the features to emphasize."),
@@ -1389,7 +1388,7 @@ const K = async (e, t) => {
1389
1388
  "Array of objectIds from a previous query result. Use this instead of a where clause when the query returned objectIds (e.g. top N results). If provided, takes precedence over where clause."
1390
1389
  )
1391
1390
  }),
1392
- geometryFilter: i.union([oo, ao]).optional().describe("Optional geometry-based filtering parameters for spatial queries."),
1391
+ geometryFilter: i.union([na, ia]).optional().describe("Optional geometry-based filtering parameters for spatial queries."),
1393
1392
  useCurrentExtent: i.boolean().optional().describe(
1394
1393
  "Set to true when the previous query used the current map extent as a spatial filter. This ensures the feature effect applies only to features visible in the current view. Default is false."
1395
1394
  ),
@@ -1399,11 +1398,11 @@ const K = async (e, t) => {
1399
1398
  excludedEffect: i.string().default("grayscale(100%) opacity(60%) blur(2px)").describe(
1400
1399
  "The effect applied to features that do not meet the filter requirements. Valid effects include: bloom, blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate, and sepia. Prefer default unless specified."
1401
1400
  )
1402
- }), io = f(ro, {
1401
+ }), la = f(oa, {
1403
1402
  name: "setFeatureEffect",
1404
1403
  description: "Sets a feature effect on a given layer with given filter parameters and feature effects to emphasize certain features that meet a filter requirement. If no feature effect information is provided, then use the default effect provided.",
1405
- schema: no
1406
- }), X = (e) => {
1404
+ schema: sa
1405
+ }), re = (e) => {
1407
1406
  if (e instanceof Date)
1408
1407
  return Number.isNaN(e.getTime()) ? null : e;
1409
1408
  if (typeof e == "number" && Number.isFinite(e)) {
@@ -1411,44 +1410,44 @@ const K = async (e, t) => {
1411
1410
  return Number.isNaN(t.getTime()) ? null : t;
1412
1411
  }
1413
1412
  return null;
1414
- }, so = (e) => !e || e === "system" ? Intl.DateTimeFormat().resolvedOptions().timeZone : e === "unknown" ? "UTC" : e, co = (e) => {
1413
+ }, ca = (e) => !e || e === "system" ? Intl.DateTimeFormat().resolvedOptions().timeZone : e === "unknown" ? "UTC" : e, ua = (e) => {
1415
1414
  if (typeof e == "string" && e)
1416
1415
  return e;
1417
- const t = X(e);
1416
+ const t = re(e);
1418
1417
  return t ? t.toISOString().slice(0, 10) : null;
1419
- }, Wn = () => {
1420
- const e = (/* @__PURE__ */ new Date()).getTimezoneOffset(), t = e <= 0 ? "+" : "-", r = Math.floor(Math.abs(e) / 60).toString().padStart(2, "0"), o = (Math.abs(e) % 60).toString().padStart(2, "0"), a = `${t}${r}:${o}`;
1421
- return { userTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone, userTimezoneOffset: a };
1422
- }, lo = (e, t, r) => {
1423
- const o = t?.toLowerCase();
1424
- if (o === "date-only") {
1425
- const n = co(e);
1426
- return n ? nt(n, M("short-date")) : e;
1418
+ }, Bn = () => {
1419
+ const e = (/* @__PURE__ */ new Date()).getTimezoneOffset(), t = e <= 0 ? "+" : "-", r = Math.floor(Math.abs(e) / 60).toString().padStart(2, "0"), a = (Math.abs(e) % 60).toString().padStart(2, "0"), o = `${t}${r}:${a}`;
1420
+ return { userTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone, userTimezoneOffset: o };
1421
+ }, da = (e, t, r) => {
1422
+ const a = t?.toLowerCase();
1423
+ if (a === "date-only") {
1424
+ const n = ua(e);
1425
+ return n ? st(n, Q("short-date")) : e;
1427
1426
  }
1428
- if (o === "time-only") {
1427
+ if (a === "time-only") {
1429
1428
  if (typeof e == "string" && e)
1430
- return it(e, M("long-time"));
1431
- const n = X(e);
1432
- return n ? de(n, {
1433
- ...M("long-time"),
1429
+ return lt(e, Q("long-time"));
1430
+ const n = re(e);
1431
+ return n ? fe(n, {
1432
+ ...Q("long-time"),
1434
1433
  timeZone: "UTC"
1435
1434
  }) : e;
1436
1435
  }
1437
- const a = X(e);
1438
- return a ? de(a, {
1439
- ...M("short-date-short-time"),
1440
- timeZone: so(r)
1436
+ const o = re(e);
1437
+ return o ? fe(o, {
1438
+ ...Q("short-date-short-time"),
1439
+ timeZone: ca(r)
1441
1440
  }) : e;
1442
- }, be = (e, t, r) => {
1441
+ }, $e = (e, t, r) => {
1443
1442
  if (e && typeof e != "function") {
1444
- const o = "getField" in r && r.getField?.(e), a = o && "getFieldDomain" in r && r.getFieldDomain ? r.getFieldDomain(o.name) : null;
1445
- if (a?.type === "coded-value") {
1446
- const s = a.codedValues.find((c) => c.code === t);
1447
- return s ? s.name : null;
1443
+ const a = "getField" in r && r.getField?.(e), o = a && "getFieldDomain" in r && r.getFieldDomain ? r.getFieldDomain(a.name) : null;
1444
+ if (o?.type === "coded-value") {
1445
+ const l = o.codedValues.find((s) => s.code === t);
1446
+ return l ? l.name : null;
1448
1447
  }
1449
1448
  }
1450
1449
  return null;
1451
- }, uo = (e) => !e || e === "system" ? Intl.DateTimeFormat().resolvedOptions().timeZone : e === "unknown" ? "UTC" : e, po = (e) => {
1450
+ }, pa = (e) => !e || e === "system" ? Intl.DateTimeFormat().resolvedOptions().timeZone : e === "unknown" ? "UTC" : e, ma = (e) => {
1452
1451
  if (e instanceof Date)
1453
1452
  return Number.isNaN(e.getTime()) ? null : e;
1454
1453
  if (typeof e == "number" && Number.isFinite(e)) {
@@ -1460,7 +1459,7 @@ const K = async (e, t) => {
1460
1459
  return Number.isNaN(t.getTime()) ? null : t;
1461
1460
  }
1462
1461
  return null;
1463
- }, ho = (e, t) => {
1462
+ }, ha = (e, t) => {
1464
1463
  if (typeof e != "number")
1465
1464
  return e;
1466
1465
  const r = {};
@@ -1470,184 +1469,184 @@ const K = async (e, t) => {
1470
1469
  } catch {
1471
1470
  return e;
1472
1471
  }
1473
- }, mo = (e, t, r) => {
1474
- const o = po(e);
1475
- if (!o)
1472
+ }, ya = (e, t, r) => {
1473
+ const a = ma(e);
1474
+ if (!a)
1476
1475
  return e;
1477
- const a = {};
1478
- t.dateStyle ? a.dateStyle = t.dateStyle : (t.year && (a.year = t.year), t.month && (a.month = t.month)), t.timeStyle && (a.timeStyle = t.timeStyle), t.timeStyle && t.hour12 === "always" ? a.hour12 = !0 : t.timeStyle && t.hour12 === "never" && (a.hour12 = !1), a.timeZone = uo(r);
1476
+ const o = {};
1477
+ t.dateStyle ? o.dateStyle = t.dateStyle : (t.year && (o.year = t.year), t.month && (o.month = t.month)), t.timeStyle && (o.timeStyle = t.timeStyle), t.timeStyle && t.hour12 === "always" ? o.hour12 = !0 : t.timeStyle && t.hour12 === "never" && (o.hour12 = !1), o.timeZone = pa(r);
1479
1478
  try {
1480
- return new Intl.DateTimeFormat(void 0, a).format(o);
1479
+ return new Intl.DateTimeFormat(void 0, o).format(a);
1481
1480
  } catch {
1482
1481
  return e;
1483
1482
  }
1484
- }, Te = (e, t) => e.getFieldAlias?.(t) ?? e.fieldsIndex?.get(t)?.alias ?? e.fieldsIndex?.get(t)?.name ?? t, ve = (e, t, r, o, a) => {
1483
+ }, Ce = (e, t) => e.getFieldAlias?.(t) ?? e.fieldsIndex?.get(t)?.alias ?? e.fieldsIndex?.get(t)?.name ?? t, Ee = (e, t, r, a, o) => {
1485
1484
  if (r == null)
1486
1485
  return r;
1487
- const s = e.getFieldConfiguration?.(t)?.fieldFormat;
1488
- return s?.type === "number" ? ho(r, s) : s?.type === "date-time" ? mo(r, s, a) : lo(r, o, a);
1489
- }, yo = (e, t, r, o) => {
1490
- const a = e.fieldsIndex?.get(t), n = be(t, r, e) ?? r;
1491
- return ve(e, t, n, a?.type, o);
1492
- }, fo = (e, t) => Te(e, t), Se = (e, t, r) => {
1493
- const o = e.objectIdField, a = t.features.map(
1494
- (s) => s.attributes[o]
1495
- ), n = t.features.map((s) => {
1496
- const c = s.attributes, u = {};
1497
- return e.fields.forEach((l) => {
1498
- if (!Object.hasOwn(c, l.name))
1486
+ const l = e.getFieldConfiguration?.(t)?.fieldFormat;
1487
+ return l?.type === "number" ? ha(r, l) : l?.type === "date-time" ? ya(r, l, o) : da(r, a, o);
1488
+ }, fa = (e, t, r, a) => {
1489
+ const o = e.fieldsIndex?.get(t), n = $e(t, r, e) ?? r;
1490
+ return Ee(e, t, n, o?.type, a);
1491
+ }, ga = (e, t) => Ce(e, t), Ne = (e, t, r) => {
1492
+ const a = e.objectIdField, o = t.features.map(
1493
+ (l) => l.attributes[a]
1494
+ ), n = t.features.map((l) => {
1495
+ const s = l.attributes, c = {};
1496
+ return e.fields.forEach((u) => {
1497
+ if (!Object.hasOwn(s, u.name))
1499
1498
  return;
1500
- const d = c[l.name];
1501
- if (l.name === o) {
1502
- u[l.name] = d;
1499
+ const d = s[u.name];
1500
+ if (u.name === a) {
1501
+ c[u.name] = d;
1503
1502
  return;
1504
1503
  }
1505
- const p = be(l.name, d, e) ?? d, h = Te(e, l.name);
1506
- u[h] = ve(e, l.name, p, l.type, r);
1507
- }), u;
1504
+ const p = $e(u.name, d, e) ?? d, m = Ce(e, u.name);
1505
+ c[m] = Ee(e, u.name, p, u.type, r);
1506
+ }), c;
1508
1507
  });
1509
- return { objectIds: a, attributes: n };
1510
- }, go = (e, t, r) => {
1511
- const o = e.createQuery();
1512
- return o.outFields = [t], o.where = r || "1=1", o.num = 1, o;
1513
- }, wo = async (e, t, r, o) => {
1514
- const a = o.map?.allLayers.find((h) => h.id === e), n = go(a, t, r.where), c = (await a.queryFeatures(n)).features[0], u = c ? c.attributes[t] : null, l = yo(a, t, u, o.timeZone), d = fo(a, t);
1508
+ return { objectIds: o, attributes: n };
1509
+ }, wa = (e, t, r) => {
1510
+ const a = e.createQuery();
1511
+ return a.outFields = [t], a.where = r || "1=1", a.num = 1, a;
1512
+ }, ba = async (e, t, r, a) => {
1513
+ const o = a.map?.allLayers.find((m) => m.id === e), n = wa(o, t, r.where), s = (await o.queryFeatures(n)).features[0], c = s ? s.attributes[t] : null, u = fa(o, t, c, a.timeZone), d = ga(o, t);
1515
1514
  return {
1516
1515
  tool: "getAttribute",
1517
- layerName: a.title ?? e,
1518
- summary: `${d} = ${l}`,
1516
+ layerName: o.title ?? e,
1517
+ summary: `${d} = ${u}`,
1519
1518
  details: {
1520
1519
  fieldName: t,
1521
1520
  fieldAlias: d !== t ? d : void 0,
1522
- value: l,
1521
+ value: u,
1523
1522
  where: r.where
1524
1523
  }
1525
1524
  };
1526
1525
  };
1527
- async function bo({ layerId: e, fieldName: t, query: r }, o) {
1528
- const { mapView: a } = N(o), n = await wo(e, t, r, a);
1526
+ async function Ta({ layerId: e, fieldName: t, query: r }, a) {
1527
+ const { mapView: o } = F(a), n = await ba(e, t, r, o);
1529
1528
  return JSON.stringify(n, null, 2);
1530
1529
  }
1531
- const To = i.object({
1530
+ const va = i.object({
1532
1531
  layerId: i.string().describe("The layerId of the layer containing the field from which to get a value."),
1533
1532
  fieldName: i.string().describe("The name of the field/attribute from which to get a field value."),
1534
1533
  query: i.object({
1535
1534
  where: i.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")
1536
1535
  })
1537
- }), vo = f(bo, {
1536
+ }), Sa = f(Ta, {
1538
1537
  name: "getAttribute",
1539
1538
  description: "Returns an attribute value for a given feature.",
1540
- schema: To
1541
- }), oe = (e, t, r) => r ? e.hasAllFeaturesInView && e.availableFields === t : e.hasAllFeatures && e.availableFields === t;
1542
- function V(e, t) {
1539
+ schema: va
1540
+ }), ce = (e, t, r) => r ? e.hasAllFeaturesInView && e.availableFields === t : e.hasAllFeatures && e.availableFields === t;
1541
+ function K(e, t) {
1543
1542
  let r = e ?? "";
1544
1543
  return t != null && t && (r = r ? `(${r}) AND (${t})` : t), r || null;
1545
1544
  }
1546
- const So = async (e) => {
1547
- const { targetLayer: t, fieldName: r, statisticType: o, mapView: a, layersAndFieldsRegistry: n, geometryFilter: s } = e, c = a.map?.allLayers.find((v) => v.id === t.layerId);
1548
- if (!c)
1545
+ const xa = async (e) => {
1546
+ const { targetLayer: t, fieldName: r, statisticType: a, mapView: o, layersAndFieldsRegistry: n, geometryFilter: l } = e, s = o.map?.allLayers.find((v) => v.id === t.layerId);
1547
+ if (!s)
1549
1548
  throw new Error(`Layer '${t.layerId}' not found.`);
1550
- const u = await a.whenLayerView(c), d = n.get(t.layerId)?.fieldRegistry.get(r), p = d?.alias;
1549
+ const c = await o.whenLayerView(s), d = n.get(t.layerId)?.fieldRegistry.get(r), p = d?.alias;
1551
1550
  if (!d)
1552
1551
  throw new Error(`Field '${r}' not found.`);
1553
- let h, m;
1554
- if (s) {
1555
- const v = await K(s, a);
1552
+ let m, y;
1553
+ if (l) {
1554
+ const v = await H(l, o);
1556
1555
  if ("error" in v)
1557
1556
  throw new Error(v.error);
1558
1557
  if (!v.geometry)
1559
- throw P(s) ? new Error(`No features found matching: ${s.where}`) : new Error("Failed to create geometry");
1560
- if (P(s)) {
1561
- const O = a.map?.allLayers.find((A) => A.id === s.layerId);
1562
- h = {
1563
- geometryLayerName: O?.title ?? O?.id,
1564
- geometryLayerId: s.layerId,
1565
- geometryWhere: s.where,
1566
- distance: s.distance,
1567
- units: s.units,
1558
+ throw j(l) ? new Error(`No features found matching: ${l.where}`) : new Error("Failed to create geometry");
1559
+ if (j(l)) {
1560
+ const M = o.map?.allLayers.find((P) => P.id === l.layerId);
1561
+ m = {
1562
+ geometryLayerName: M?.title ?? M?.id,
1563
+ geometryLayerId: l.layerId,
1564
+ geometryWhere: l.where,
1565
+ distance: l.distance,
1566
+ units: l.units,
1568
1567
  applied: !0
1569
1568
  };
1570
- } else W(s) && (h = {
1571
- point: s.point,
1572
- distance: s.distance,
1573
- units: s.units,
1569
+ } else U(l) && (m = {
1570
+ point: l.point,
1571
+ distance: l.distance,
1572
+ units: l.units,
1574
1573
  applied: !0
1575
1574
  });
1576
- m = new fe({
1575
+ y = new Se({
1577
1576
  geometry: v.geometry,
1578
- distance: s.distance,
1579
- units: s.units,
1577
+ distance: l.distance,
1578
+ units: l.units,
1580
1579
  spatialRelationship: "intersects"
1581
1580
  });
1582
1581
  }
1583
- const w = oe(u, [r], !1);
1584
- let y = null, g = null;
1582
+ const g = ce(c, [r], !1);
1583
+ let h = null, w = null;
1585
1584
  const T = 10;
1586
1585
  if (d.type !== "geometry" && d.type !== "oid" && d.type !== "global-id")
1587
1586
  try {
1588
1587
  const v = {
1589
- layer: c,
1590
- useFeaturesInView: w,
1591
- view: w ? a : void 0,
1588
+ layer: s,
1589
+ useFeaturesInView: g,
1590
+ view: g ? o : void 0,
1592
1591
  field: r,
1593
- sqlWhere: V(c.definitionExpression, t.where),
1594
- ...m && { filter: m },
1595
- outStatisticTypes: { include: [o] }
1592
+ sqlWhere: K(s.definitionExpression, t.where),
1593
+ ...y && { filter: y },
1594
+ outStatisticTypes: { include: [a] }
1596
1595
  };
1597
- y = await st(v);
1598
- const O = ["string", "small-integer", "integer"], A = d.domain?.type === "coded-value" ? d.domain : null;
1599
- (O.includes(d.type) || A) && (g = (await ct({
1600
- layer: c,
1601
- useFeaturesInView: w,
1602
- view: w ? a : void 0,
1596
+ h = await ct(v);
1597
+ const M = ["string", "small-integer", "integer"], P = d.domain?.type === "coded-value" ? d.domain : null;
1598
+ (M.includes(d.type) || P) && (w = (await ut({
1599
+ layer: s,
1600
+ useFeaturesInView: g,
1601
+ view: g ? o : void 0,
1603
1602
  field: r,
1604
- sqlWhere: V(c.definitionExpression, t.where),
1605
- ...m && { filter: m }
1606
- })).uniqueValueInfos.sort((q, ke) => ke.count - q.count).slice(0, T)), g && d.domain?.type === "coded-value" && (g = g.map((q) => ({
1607
- ...q,
1608
- value: A ? A.getName(q.value) ?? q.value : q.value
1603
+ sqlWhere: K(s.definitionExpression, t.where),
1604
+ ...y && { filter: y }
1605
+ })).uniqueValueInfos.sort((z, ze) => ze.count - z.count).slice(0, T)), w && d.domain?.type === "coded-value" && (w = w.map((z) => ({
1606
+ ...z,
1607
+ value: P ? P.getName(z.value) ?? z.value : z.value
1609
1608
  })));
1610
1609
  } catch (v) {
1611
1610
  console.error("Statistics error:", v);
1612
1611
  }
1613
1612
  return {
1614
1613
  tool: "getStatistics",
1615
- layerName: c.title ?? t.layerId,
1616
- summary: `${o} = ${typeof y?.[o] == "number" ? y[o] : "N/A"}`,
1614
+ layerName: s.title ?? t.layerId,
1615
+ summary: `${a} = ${typeof h?.[a] == "number" ? h[a] : "N/A"}`,
1617
1616
  details: {
1618
1617
  fieldName: r,
1619
1618
  fieldAlias: p,
1620
- statisticType: o,
1621
- statistic: y?.[o] ?? null,
1622
- summaryStatistics: y,
1623
- uniqueValues: g,
1619
+ statisticType: a,
1620
+ statistic: h?.[a] ?? null,
1621
+ summaryStatistics: h,
1622
+ uniqueValues: w,
1624
1623
  where: t.where,
1625
- spatialFilterInfo: h
1624
+ spatialFilterInfo: m
1626
1625
  }
1627
1626
  };
1628
1627
  };
1629
- async function xo({
1628
+ async function Ra({
1630
1629
  targetLayer: e,
1631
1630
  fieldName: t,
1632
1631
  statisticType: r,
1633
- geometryFilter: o
1634
- }, a) {
1635
- const n = we(a, "layersAndFieldsRegistry"), { mapView: s } = N(a), c = await So({
1632
+ geometryFilter: a
1633
+ }, o) {
1634
+ const n = Re(o, "layersAndFieldsRegistry"), { mapView: l } = F(o), s = await xa({
1636
1635
  targetLayer: e,
1637
1636
  fieldName: t,
1638
1637
  statisticType: r,
1639
- mapView: s,
1638
+ mapView: l,
1640
1639
  layersAndFieldsRegistry: n,
1641
- geometryFilter: o
1640
+ geometryFilter: a
1642
1641
  });
1643
- return JSON.stringify(c, null, 2);
1642
+ return JSON.stringify(s, null, 2);
1644
1643
  }
1645
- const Ro = i.object({
1644
+ const $a = i.object({
1646
1645
  layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
1647
1646
  where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
1648
1647
  distance: i.number().optional().describe("The buffer distance around the geometry."),
1649
1648
  units: I.optional().describe("The units for the distance buffer.")
1650
- }), $o = i.object({
1649
+ }), Ca = i.object({
1651
1650
  point: i.object({
1652
1651
  x: i.number().describe("X coordinate (longitude) from navigation result"),
1653
1652
  y: i.number().describe("Y coordinate (latitude) from navigation result"),
@@ -1657,17 +1656,17 @@ const Ro = i.object({
1657
1656
  }).describe("Point coordinates from a previous navigation/geocoding result"),
1658
1657
  distance: i.number().optional().describe("Optional buffer distance around the point."),
1659
1658
  units: I.optional().describe("The units for the distance buffer.")
1660
- }), Eo = i.object({
1659
+ }), Ea = i.object({
1661
1660
  targetLayer: i.object({
1662
1661
  layerId: i.string().describe("The layerId of the layer containing the field from which to get a value."),
1663
1662
  where: i.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")
1664
1663
  }),
1665
- geometryFilter: i.union([Ro, $o]).optional().describe(
1664
+ geometryFilter: i.union([$a, Ca]).optional().describe(
1666
1665
  "Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."
1667
1666
  ),
1668
1667
  fieldName: i.string().describe("The name of the field for which to get statistics. STRICTLY DO NOT use OBJECTID. Use any other field"),
1669
1668
  statisticType: i.enum(["avg", "max", "median", "min", "stddev", "sum", "variance", "nullcount", "count"]).describe("The statistic type to calculate.")
1670
- }), Co = f(xo, {
1669
+ }), Na = f(Ra, {
1671
1670
  name: "getStatistics",
1672
1671
  description: `Computes a single aggregate statistic (max, min, avg, sum, median, stddev, variance) for a numeric field across matching features. Also returns frequency analysis for categorical fields.
1673
1672
 
@@ -1682,96 +1681,96 @@ DO NOT USE FOR:
1682
1681
  - Simple counts of features matching a condition — use queryFeatures instead
1683
1682
 
1684
1683
  Only call this tool when the answer requires computing an aggregate (avg, max, min, sum, median, stddev) over a field's values, not just counting or listing features.`,
1685
- schema: Eo
1686
- }), Io = async (e, t, r, o, a) => {
1687
- const n = r.map?.allLayers.find((h) => h.id === e.layerId), s = await r.whenLayerView(n), c = n.title ?? e.layerId;
1688
- let u;
1689
- if (o) {
1690
- const h = await K(o, r);
1691
- if ("error" in h)
1684
+ schema: Ea
1685
+ }), Ia = async (e, t, r, a, o) => {
1686
+ const n = r.map?.allLayers.find((m) => m.id === e.layerId), l = await r.whenLayerView(n), s = n.title ?? e.layerId;
1687
+ let c;
1688
+ if (a) {
1689
+ const m = await H(a, r);
1690
+ if ("error" in m)
1692
1691
  return {
1693
1692
  tool: "getTopFeatures",
1694
- layerName: c,
1693
+ layerName: s,
1695
1694
  summary: "Geometry lookup failed",
1696
- details: { error: h.error }
1695
+ details: { error: m.error }
1697
1696
  };
1698
- if (!h.geometry)
1697
+ if (!m.geometry)
1699
1698
  return {
1700
1699
  tool: "getTopFeatures",
1701
- layerName: c,
1700
+ layerName: s,
1702
1701
  summary: "No features found for geometry filter",
1703
1702
  details: {
1704
- error: `No features found matching: ${"where" in o ? o.where : "unknown criteria"}`
1703
+ error: `No features found matching: ${"where" in a ? a.where : "unknown criteria"}`
1705
1704
  }
1706
1705
  };
1707
- u = h.geometry;
1708
- } else a && (u = r.extent.clone());
1709
- const l = t.groupByFields && t.groupByFields.length > 0, d = n.objectIdField, p = e.outFields.includes("*") ? ["*"] : [.../* @__PURE__ */ new Set([...e.outFields, d])];
1706
+ c = m.geometry;
1707
+ } else o && (c = r.extent.clone());
1708
+ const u = t.groupByFields && t.groupByFields.length > 0, d = n.objectIdField, p = e.outFields.includes("*") ? ["*"] : [.../* @__PURE__ */ new Set([...e.outFields, d])];
1710
1709
  try {
1711
- let h;
1712
- if (l) {
1713
- const y = new lt({
1710
+ let m;
1711
+ if (u) {
1712
+ const h = new dt({
1714
1713
  where: e.where || "1=1",
1715
1714
  outFields: p,
1716
1715
  orderByFields: e.orderByFields,
1717
- geometry: u,
1718
- spatialRelationship: u ? "intersects" : void 0,
1719
- distance: o?.distance,
1720
- units: o?.units,
1721
- topFilter: new ut({
1716
+ geometry: c,
1717
+ spatialRelationship: c ? "intersects" : void 0,
1718
+ distance: a?.distance,
1719
+ units: a?.units,
1720
+ topFilter: new pt({
1722
1721
  topCount: t.topCount,
1723
1722
  groupByFields: t.groupByFields,
1724
1723
  orderByFields: t.orderByFields
1725
1724
  })
1726
1725
  });
1727
- h = await n.queryTopFeatures(y);
1726
+ m = await n.queryTopFeatures(h);
1728
1727
  } else {
1729
- const y = n.createQuery();
1730
- y.where = V(n.definitionExpression, e.where || "1=1"), y.outFields = p.length ? p : ["*"], y.orderByFields = t.orderByFields, y.num = t.topCount, u && (y.geometry = u, y.spatialRelationship = "intersects"), o?.distance && (y.distance = o.distance), o?.units && (y.units = o.units), y.outSpatialReference = r.spatialReference;
1731
- const g = oe(s, e.outFields, a ?? !1);
1728
+ const h = n.createQuery();
1729
+ h.where = K(n.definitionExpression, e.where || "1=1"), h.outFields = p.length ? p : ["*"], h.orderByFields = t.orderByFields, h.num = t.topCount, c && (h.geometry = c, h.spatialRelationship = "intersects"), a?.distance && (h.distance = a.distance), a?.units && (h.units = a.units), h.outSpatialReference = r.spatialReference;
1730
+ const w = ce(l, e.outFields, o ?? !1);
1732
1731
  try {
1733
- h = g ? await s.queryFeatures(y) : await n.queryFeatures(y);
1732
+ m = w ? await l.queryFeatures(h) : await n.queryFeatures(h);
1734
1733
  } catch (T) {
1735
- console.warn("Client-side query failed, falling back to server:", T), h = await n.queryFeatures(y);
1734
+ console.warn("Client-side query failed, falling back to server:", T), m = await n.queryFeatures(h);
1736
1735
  }
1737
1736
  }
1738
- const m = h.features.map((y) => y.attributes[d]), { attributes: w } = Se(n, h, r.timeZone);
1737
+ const y = m.features.map((h) => h.attributes[d]), { attributes: g } = Ne(n, m, r.timeZone);
1739
1738
  return {
1740
1739
  tool: "getTopFeatures",
1741
- layerName: c,
1740
+ layerName: s,
1742
1741
  summary: `Top ${t.topCount} features extracted`,
1743
1742
  details: {
1744
1743
  topCount: t.topCount,
1745
- attributes: w,
1746
- objectIds: m,
1744
+ attributes: g,
1745
+ objectIds: y,
1747
1746
  objectIdField: d,
1748
1747
  where: e.where,
1749
1748
  orderByFields: t.orderByFields,
1750
- ...l && { groupByFields: t.groupByFields }
1749
+ ...u && { groupByFields: t.groupByFields }
1751
1750
  }
1752
1751
  };
1753
- } catch (h) {
1752
+ } catch (m) {
1754
1753
  return {
1755
1754
  tool: "getTopFeatures",
1756
- layerName: c,
1755
+ layerName: s,
1757
1756
  summary: "Query failed",
1758
- details: { error: h instanceof Error ? h.message : String(h) }
1757
+ details: { error: m instanceof Error ? m.message : String(m) }
1759
1758
  };
1760
1759
  }
1761
- }, Fo = async ({
1760
+ }, ka = async ({
1762
1761
  targetLayer: e,
1763
1762
  topFilter: t,
1764
1763
  geometryFilter: r,
1765
- useCurrentExtent: o
1766
- }, a) => {
1767
- const { mapView: n } = N(a), s = await Io(e, t, n, r, o);
1768
- return JSON.stringify(s, null, 2);
1769
- }, ko = i.object({
1764
+ useCurrentExtent: a
1765
+ }, o) => {
1766
+ const { mapView: n } = F(o), l = await Ia(e, t, n, r, a);
1767
+ return JSON.stringify(l, null, 2);
1768
+ }, Fa = i.object({
1770
1769
  layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
1771
1770
  where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
1772
1771
  distance: i.number().optional().describe("The buffer distance around the geometry."),
1773
1772
  units: I.optional().describe("The units for the distance buffer.")
1774
- }), No = i.object({
1773
+ }), za = i.object({
1775
1774
  point: i.object({
1776
1775
  x: i.number().describe("X coordinate (longitude) from navigation result"),
1777
1776
  y: i.number().describe("Y coordinate (latitude) from navigation result"),
@@ -1781,7 +1780,7 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
1781
1780
  }).describe("Point coordinates from a previous navigation/geocoding result"),
1782
1781
  distance: i.number().optional().describe("Optional buffer distance around the point."),
1783
1782
  units: I.optional().describe("The units for the distance buffer.")
1784
- }), zo = i.object({
1783
+ }), qa = i.object({
1785
1784
  targetLayer: i.object({
1786
1785
  layerId: i.string().describe("The layerId of the layer containing the field from which to get a value."),
1787
1786
  where: i.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),
@@ -1792,7 +1791,7 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
1792
1791
  ).default("*")
1793
1792
  )
1794
1793
  }),
1795
- geometryFilter: i.union([ko, No]).optional().describe(
1794
+ geometryFilter: i.union([Fa, za]).optional().describe(
1796
1795
  "Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."
1797
1796
  ),
1798
1797
  topFilter: i.object({
@@ -1805,83 +1804,83 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
1805
1804
  useCurrentExtent: i.boolean().optional().describe(
1806
1805
  "Set to true ONLY when user explicitly asks about features 'in my view', 'on my map', 'I am looking at'. Default is false (queries entire layer)."
1807
1806
  )
1808
- }), qo = f(Fo, {
1807
+ }), Da = f(ka, {
1809
1808
  name: "getTopFeatures",
1810
1809
  description: 'Returns top N features ranked by an existing field value. Use for "highest", "lowest", "top N" questions where ranking is based on a field that already exists in the data (e.g., population, value, date, depth). orderByFields must be actual field names with ASC/DESC. Do NOT use aggregate functions like COUNT(), SUM(), AVG() - those require getStatistics.',
1811
- schema: zo
1812
- }), Z = 25, Do = async (e, t, r, o) => {
1813
- const a = t.map?.allLayers.find((y) => y.id === e.layerId), n = await t.whenLayerView(a), s = a.title ?? e.layerId;
1814
- let c;
1810
+ schema: qa
1811
+ }), ee = 25, Aa = async (e, t, r, a) => {
1812
+ const o = t.map?.allLayers.find((h) => h.id === e.layerId), n = await t.whenLayerView(o), l = o.title ?? e.layerId;
1813
+ let s;
1815
1814
  if (r) {
1816
- const y = await K(r, t);
1817
- if ("error" in y) {
1818
- const g = { error: y.error };
1819
- if (P(r)) {
1820
- const T = t.map?.allLayers.find((E) => E.id === r.layerId);
1821
- g.geometryLayerName = T?.title ?? T?.id, g.geometryLayerId = r.layerId, g.geometryWhere = r.where;
1822
- } else W(r) && (g.point = r.point);
1815
+ const h = await H(r, t);
1816
+ if ("error" in h) {
1817
+ const w = { error: h.error };
1818
+ if (j(r)) {
1819
+ const T = t.map?.allLayers.find((C) => C.id === r.layerId);
1820
+ w.geometryLayerName = T?.title ?? T?.id, w.geometryLayerId = r.layerId, w.geometryWhere = r.where;
1821
+ } else U(r) && (w.point = r.point);
1823
1822
  return {
1824
1823
  tool: "queryFeatures",
1825
- layerName: s,
1824
+ layerName: l,
1826
1825
  summary: "Geometry lookup failed",
1827
- details: g
1826
+ details: w
1828
1827
  };
1829
1828
  }
1830
- if (!y.geometry) {
1831
- const g = {};
1832
- if (P(r)) {
1833
- const T = t.map?.allLayers.find((E) => E.id === r.layerId);
1834
- g.error = `No features found matching: ${r.where}`, g.geometryLayerName = T?.title ?? T?.id, g.geometryLayerId = r.layerId, g.geometryWhere = r.where;
1835
- } else W(r) && (g.error = "Failed to create point geometry", g.point = r.point);
1829
+ if (!h.geometry) {
1830
+ const w = {};
1831
+ if (j(r)) {
1832
+ const T = t.map?.allLayers.find((C) => C.id === r.layerId);
1833
+ w.error = `No features found matching: ${r.where}`, w.geometryLayerName = T?.title ?? T?.id, w.geometryLayerId = r.layerId, w.geometryWhere = r.where;
1834
+ } else U(r) && (w.error = "Failed to create point geometry", w.point = r.point);
1836
1835
  return {
1837
1836
  tool: "queryFeatures",
1838
- layerName: s,
1837
+ layerName: l,
1839
1838
  summary: "No features found for geometry filter",
1840
- details: g
1839
+ details: w
1841
1840
  };
1842
1841
  }
1843
- c = y.geometry;
1844
- } else o && (c = t.extent.clone());
1845
- const u = oe(n, e.outFields, o ?? !1), l = a.objectIdField, d = a.createQuery();
1846
- d.where = V(a.definitionExpression, e.where || "1=1"), d.outFields = e.outFields.includes("*") ? ["*"] : [.../* @__PURE__ */ new Set([...e.outFields, l])], d.orderByFields = e.orderByFields, c && (d.geometry = c, d.spatialRelationship = "intersects"), r?.distance && (d.distance = r.distance), r?.units && (d.units = r.units), d.outSpatialReference = t.spatialReference;
1847
- let p, h;
1842
+ s = h.geometry;
1843
+ } else a && (s = t.extent.clone());
1844
+ const c = ce(n, e.outFields, a ?? !1), u = o.objectIdField, d = o.createQuery();
1845
+ d.where = K(o.definitionExpression, e.where || "1=1"), d.outFields = e.outFields.includes("*") ? ["*"] : [.../* @__PURE__ */ new Set([...e.outFields, u])], d.orderByFields = e.orderByFields, s && (d.geometry = s, d.spatialRelationship = "intersects"), r?.distance && (d.distance = r.distance), r?.units && (d.units = r.units), d.outSpatialReference = t.spatialReference;
1846
+ let p, m;
1848
1847
  try {
1849
- p = u ? await n.queryFeatureCount(d) : await a.queryFeatureCount(d), p > 0 && p <= Z && (h = u ? await n.queryFeatures(d) : await a.queryFeatures(d));
1850
- } catch (y) {
1851
- console.warn("Client-side query failed, falling back to server:", y), p = await a.queryFeatureCount(d), p > 0 && p <= Z && (h = await a.queryFeatures(d));
1848
+ p = c ? await n.queryFeatureCount(d) : await o.queryFeatureCount(d), p > 0 && p <= ee && (m = c ? await n.queryFeatures(d) : await o.queryFeatures(d));
1849
+ } catch (h) {
1850
+ console.warn("Client-side query failed, falling back to server:", h), p = await o.queryFeatureCount(d), p > 0 && p <= ee && (m = await o.queryFeatures(d));
1852
1851
  }
1853
- const { objectIds: m, attributes: w } = h ? Se(a, h, t.timeZone) : { objectIds: void 0, attributes: void 0 };
1852
+ const { objectIds: y, attributes: g } = m ? Ne(o, m, t.timeZone) : { objectIds: void 0, attributes: void 0 };
1854
1853
  return {
1855
1854
  tool: "queryFeatures",
1856
- layerName: s,
1855
+ layerName: l,
1857
1856
  summary: `${p} features found`,
1858
1857
  details: {
1859
1858
  totalCount: p,
1860
1859
  where: e.where,
1861
1860
  orderByFields: e.orderByFields,
1862
1861
  outFields: e.outFields,
1863
- ...m && { objectIds: m, objectIdField: l },
1864
- ...w && { attributes: w },
1865
- ...p > Z && {
1862
+ ...y && { objectIds: y, objectIdField: u },
1863
+ ...g && { attributes: g },
1864
+ ...p > ee && {
1866
1865
  note: `${p} features found.`
1867
1866
  }
1868
1867
  }
1869
1868
  };
1870
1869
  };
1871
- async function Ao({
1870
+ async function Pa({
1872
1871
  targetLayer: e,
1873
1872
  geometryFilter: t,
1874
1873
  useCurrentExtent: r
1875
- }, o) {
1876
- const { mapView: a } = N(o), n = await Do(e, a, t, r);
1874
+ }, a) {
1875
+ const { mapView: o } = F(a), n = await Aa(e, o, t, r);
1877
1876
  return JSON.stringify(n, null, 2);
1878
1877
  }
1879
- const Lo = i.object({
1878
+ const La = i.object({
1880
1879
  layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
1881
1880
  where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
1882
1881
  distance: i.number().optional().describe("The buffer distance around the geometry."),
1883
1882
  units: I.optional().describe("The units for the distance buffer.")
1884
- }), Po = i.object({
1883
+ }), ja = i.object({
1885
1884
  point: i.object({
1886
1885
  x: i.number().describe("X coordinate (longitude) from navigation result"),
1887
1886
  y: i.number().describe("Y coordinate (latitude) from navigation result"),
@@ -1891,7 +1890,7 @@ const Lo = i.object({
1891
1890
  }).describe("Point coordinates from a previous navigation/geocoding result"),
1892
1891
  distance: i.number().optional().describe("Optional buffer distance around the point."),
1893
1892
  units: I.optional().describe("The units for the distance buffer.")
1894
- }), jo = i.object({
1893
+ }), Ga = i.object({
1895
1894
  targetLayer: i.object({
1896
1895
  layerId: i.string().describe("The layerId of the layer containing the field from which to get a value."),
1897
1896
  where: i.string().describe(
@@ -1904,13 +1903,13 @@ const Lo = i.object({
1904
1903
  ).default("*")
1905
1904
  )
1906
1905
  }),
1907
- geometryFilter: i.union([Lo, Po]).optional().describe(
1906
+ geometryFilter: i.union([La, ja]).optional().describe(
1908
1907
  "Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."
1909
1908
  ),
1910
1909
  useCurrentExtent: i.boolean().optional().describe(
1911
1910
  "Set to true ONLY when user explicitly asks about features 'in my view', 'on my map', 'I am looking at', OR when the user refers back to features previously identified using the current extent (e.g. 'these', 'those', 'them', 'the same ones'). Default is false (queries entire layer)."
1912
1911
  )
1913
- }), Go = f(Ao, {
1912
+ }), Oa = f(Pa, {
1914
1913
  name: "queryFeatures",
1915
1914
  description: `Queries features from a layer. Returns the total count of matching features, plus individual feature attributes if ≤25 features match.
1916
1915
 
@@ -1922,49 +1921,47 @@ USE THIS TOOL FOR:
1922
1921
  - Any question where the user wants to SEE or COUNT matching features
1923
1922
 
1924
1923
  This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
1925
- schema: jo
1926
- }), Oo = [vo, Co, qo, Go], Vn = [io, Yr, Hr], Mo = new rt(Oo);
1927
- async function Un(e, t) {
1928
- const { messages: r } = await Mo.invoke({ messages: e.dataExplorationMessages }, t), o = [], a = [];
1924
+ schema: Ga
1925
+ }), Ma = [Sa, Na, Da, Oa], Hn = [la, ea, Zr], Qa = new ot(Ma, { handleToolErrors: !1 });
1926
+ async function Jn(e, t) {
1927
+ const { messages: r } = await Qa.invoke({ messages: e.dataExplorationMessages }, t), a = [], o = [];
1929
1928
  for (const n of r) {
1930
- const s = n.content;
1931
- let c;
1932
- typeof s != "string" && (c = {
1929
+ const l = n.content;
1930
+ let s;
1931
+ typeof l != "string" && (s = {
1933
1932
  tool: n.name ?? "unknown",
1934
1933
  layerName: "unknown",
1935
1934
  summary: "Query failed",
1936
- details: { error: "Skipping non-string tool output:", raw: s }
1935
+ details: { error: "Skipping non-string tool output:", raw: l }
1937
1936
  });
1938
1937
  try {
1939
- typeof s == "string" ? c = JSON.parse(s) : c = {
1938
+ typeof l == "string" ? s = JSON.parse(l) : s = {
1940
1939
  tool: n.name ?? "unknown",
1941
1940
  layerName: "unknown",
1942
1941
  summary: "Query failed",
1943
- details: { error: "Invalid tool output type", raw: s }
1942
+ details: { error: "Invalid tool output type", raw: l }
1944
1943
  };
1945
1944
  } catch {
1946
- c = {
1945
+ s = {
1947
1946
  tool: n.name ?? "unknown",
1948
1947
  layerName: "unknown",
1949
1948
  summary: "Query failed",
1950
- details: { error: s }
1949
+ details: { error: l }
1951
1950
  };
1952
1951
  }
1953
- o.push(c), c.details && typeof c.details == "object" && "error" in c.details ? a.push(`- ${c.tool}: Error - ${String(c.details.error)}`) : a.push(`- ${c.layerName}: ${c.summary}`);
1952
+ a.push(s), s.details && typeof s.details == "object" && "error" in s.details ? o.push(`- ${s.tool}: Error - ${String(s.details.error)}`) : o.push(`- ${s.layerName}: ${s.summary}`);
1954
1953
  }
1955
- return await S({ text: `Finished executing layer query tool: ${a.join(", ")}` }, t), {
1954
+ return await S({ text: `Finished executing layer query tool: ${o.join(", ")}` }, t), {
1956
1955
  ...e,
1957
1956
  dataExplorationMessages: [...e.dataExplorationMessages, ...r],
1958
- queryResponse: o,
1957
+ queryResponse: a,
1959
1958
  status: "success",
1960
- outputMessage: a.join(`
1961
- `),
1962
- summary: a.length > 0 ? _t(a.join(`
1959
+ summary: o.length > 0 ? Vt(o.join(`
1963
1960
  `)) : "Query executed."
1964
1961
  };
1965
1962
  }
1966
- const Kn = b.Root({
1967
- ...U(),
1963
+ const Zn = b.Root({
1964
+ ...B(),
1968
1965
  // internal to the help agent
1969
1966
  helpInternalState: b({
1970
1967
  reducer: L,
@@ -1972,100 +1969,100 @@ const Kn = b.Root({
1972
1969
  toolCallMessage: void 0
1973
1970
  })
1974
1971
  })
1975
- }), Qo = (e, t) => {
1972
+ }), _a = (e, t) => {
1976
1973
  const r = Array.from(e.values()).find(
1977
1974
  ({ layerItem: n }) => n.title?.toLowerCase().includes(t.toLowerCase())
1978
1975
  );
1979
1976
  if (!r) {
1980
- const n = Array.from(e.values()).map((s) => s.layerItem.title).join(", ");
1977
+ const n = Array.from(e.values()).map((l) => l.layerItem.title).join(", ");
1981
1978
  return `Could not find a layer matching "${t}". Available layers: ${n}`;
1982
1979
  }
1983
- const o = Array.from(r.fieldRegistry.values()), a = o.map((n) => `- **${n.alias || n.name}** (\`${n.name}\`, ${n.type})${n.description ? `: ${n.description}` : ""}`).join(`
1980
+ const a = Array.from(r.fieldRegistry.values()), o = a.map((n) => `- **${n.alias || n.name}** (\`${n.name}\`, ${n.type})${n.description ? `: ${n.description}` : ""}`).join(`
1984
1981
  `);
1985
- return `**${r.layerItem.title}** has ${o.length} field(s):
1982
+ return `**${r.layerItem.title}** has ${a.length} field(s):
1986
1983
 
1987
- ${a}`;
1988
- }, _o = async ({ layerTitle: e }, t) => {
1989
- const r = we(t, "layersAndFieldsRegistry");
1990
- return Qo(r, e);
1991
- }, Bn = f(_o, {
1984
+ ${o}`;
1985
+ }, Wa = async ({ layerTitle: e }, t) => {
1986
+ const r = Re(t, "layersAndFieldsRegistry");
1987
+ return _a(r, e);
1988
+ }, Yn = f(Wa, {
1992
1989
  name: "listLayerFields",
1993
1990
  description: "Lists all fields for a given layer by title. Use ONLY when the user explicitly asks to see fields, columns, or attributes of a specific named layer. Do NOT call this tool for general help questions, capability overviews, or layer listing.",
1994
1991
  schema: i.object({
1995
1992
  layerTitle: i.string().describe("The title or partial title of the layer to list fields for.")
1996
1993
  })
1997
- }), Hn = b.Root({
1998
- ...U(),
1994
+ }), Xn = b.Root({
1995
+ ...B(),
1999
1996
  intent: b({
2000
1997
  reducer: (e, t) => t
2001
1998
  }),
2002
1999
  arcgisKnowledgeMessages: b({
2003
- reducer: me,
2000
+ reducer: Te,
2004
2001
  default: () => []
2005
2002
  }),
2006
2003
  arcgisKnowledgeToolResult: b({
2007
2004
  reducer: (e, t) => t,
2008
2005
  default: () => null
2009
2006
  })
2010
- }), Q = {
2007
+ }), _ = {
2011
2008
  conversationId: ""
2012
2009
  };
2013
- function ae(e) {
2010
+ function ue(e) {
2014
2011
  const t = e.map?.allLayers.filter((r) => r.type === "knowledge-graph");
2015
2012
  if (!t || t?.length !== 1)
2016
2013
  throw new Error("The Knowledge Agent currently only supports maps with exactly one Knowledge Graph Layer.");
2017
2014
  }
2018
- function z(e) {
2015
+ function N(e) {
2019
2016
  return !!e?.map && !("activeLinkChartLayer" in e.map);
2020
2017
  }
2021
- async function B(e) {
2022
- !e || z(e) || !e.map?.diagramNodesExtent || await e.goTo(e.map.diagramNodesExtent);
2018
+ async function J(e) {
2019
+ !e || N(e) || !e.map?.diagramNodesExtent || await e.goTo(e.map.diagramNodesExtent);
2023
2020
  }
2024
- function H(e) {
2021
+ function Z(e) {
2025
2022
  const r = e?.configurable?.context;
2026
2023
  if (!r || typeof r != "object")
2027
2024
  throw new Error("ArcgisKnowledgeAgent context missing");
2028
2025
  if (!("view" in r))
2029
2026
  throw new Error("View context missing");
2030
- const o = r.view;
2031
- return o.map && !("activeLinkChartLayer" in o.map) && ae(o), {
2032
- view: o
2027
+ const a = r.view;
2028
+ return a.map && !("activeLinkChartLayer" in a.map) && ue(a), {
2029
+ view: a
2033
2030
  };
2034
2031
  }
2035
- function Jn(e) {
2032
+ function ei(e) {
2036
2033
  const r = e?.configurable?.context;
2037
- if (xe(e) === "knowledgeGraph")
2034
+ if (Ie(e) === "knowledgeGraph")
2038
2035
  return "knowledgeGraph";
2039
- const a = r.view;
2040
- return z(a) ? (ae(a), "map") : "linkChart";
2036
+ const o = r.view;
2037
+ return N(o) ? (ue(o), "map") : "linkChart";
2041
2038
  }
2042
- async function G(e) {
2039
+ async function O(e) {
2043
2040
  const r = e?.configurable?.context;
2044
- if (xe(e) === "knowledgeGraph")
2041
+ if (Ie(e) === "knowledgeGraph")
2045
2042
  return r;
2046
2043
  {
2047
- const a = r.view.map;
2048
- if (a && "activeLinkChartLayer" in a) {
2049
- const n = a.knowledgeGraph?.url;
2044
+ const o = r.view.map;
2045
+ if (o && "activeLinkChartLayer" in o) {
2046
+ const n = o.knowledgeGraph?.url;
2050
2047
  if (!n)
2051
2048
  throw new Error("Knowledge graph url missing from link chart.");
2052
2049
  return {
2053
- knowledgeGraph: await pe(n)
2050
+ knowledgeGraph: await ge(n)
2054
2051
  };
2055
2052
  } else {
2056
- ae(r.view);
2057
- const s = (r.view.map?.allLayers.find(
2058
- (u) => u.type === "knowledge-graph"
2053
+ ue(r.view);
2054
+ const l = (r.view.map?.allLayers.find(
2055
+ (c) => c.type === "knowledge-graph"
2059
2056
  )).url;
2060
- if (!s)
2057
+ if (!l)
2061
2058
  throw new Error("Knowledge graph url missing from map.");
2062
2059
  return {
2063
- knowledgeGraph: await pe(s)
2060
+ knowledgeGraph: await ge(l)
2064
2061
  };
2065
2062
  }
2066
2063
  }
2067
2064
  }
2068
- function xe(e) {
2065
+ function Ie(e) {
2069
2066
  const r = e?.configurable?.context;
2070
2067
  if (!r || typeof r != "object")
2071
2068
  throw new Error("ArcgisKnowledgeAgent context missing");
@@ -2077,12 +2074,12 @@ function xe(e) {
2077
2074
  return "view";
2078
2075
  throw new Error("ArcgisKnowledgeAgent context must have either a view or knowledgeGraph property.");
2079
2076
  }
2080
- class Wo {
2077
+ class Va {
2081
2078
  constructor(t) {
2082
- this.dataModel = t, this.kind = "GraphQueryGenerationRequest", this.explainQuery = !0, this.schemaInformation = ne.fromDataModel(t);
2079
+ this.dataModel = t, this.kind = "GraphQueryGenerationRequest", this.explainQuery = !0, this.schemaInformation = de.fromDataModel(t);
2083
2080
  }
2084
2081
  }
2085
- class ne {
2082
+ class de {
2086
2083
  constructor() {
2087
2084
  this.schemaType = "ArcgisGraphSchema", this.entityTypes = [], this.relationshipTypes = [], this.identifierInfo = {
2088
2085
  mappingInfo: {
@@ -2092,14 +2089,14 @@ class ne {
2092
2089
  };
2093
2090
  }
2094
2091
  static fromDataModel(t) {
2095
- const r = new ne();
2096
- for (const o of t.entityTypes)
2097
- r.entityTypes.push(j.fromEntityType(o));
2098
- for (const o of t.relationshipTypes)
2099
- r.relationshipTypes.push(Vo.fromRelationshipType(o));
2092
+ const r = new de();
2093
+ for (const a of t.entityTypes)
2094
+ r.entityTypes.push(G.fromEntityType(a));
2095
+ for (const a of t.relationshipTypes)
2096
+ r.relationshipTypes.push(Ua.fromRelationshipType(a));
2100
2097
  return r.identifierInfo = {
2101
2098
  mappingInfo: {
2102
- identifierMapsTo: Uo(
2099
+ identifierMapsTo: Ka(
2103
2100
  t.identifierInfo.identifierMappingInfo.identifierInfoType
2104
2101
  ),
2105
2102
  identifierPropertyName: t.identifierInfo.identifierMappingInfo.uniformPropertyIdentifier.identifierPropertyName
@@ -2108,51 +2105,51 @@ class ne {
2108
2105
  }
2109
2106
  // Generates a short summary of the types in the data model for LLM consumption.
2110
2107
  static getDataModelTypesSummary(t) {
2111
- const r = t.entityTypes.map((a) => a.name).join(", "), o = t.relationshipTypes.map((a) => a.name).join(", ");
2108
+ const r = t.entityTypes.map((o) => o.name).join(", "), a = t.relationshipTypes.map((o) => o.name).join(", ");
2112
2109
  return `Entity Types: ${r}.
2113
- Relationship Types: ${o}.`;
2110
+ Relationship Types: ${a}.`;
2114
2111
  }
2115
2112
  }
2116
- class j {
2113
+ class G {
2117
2114
  constructor() {
2118
2115
  this.name = "", this.properties = [];
2119
2116
  }
2120
2117
  static fromEntityType(t) {
2121
- const r = new j();
2122
- r.name = t.name, r.alias = t.alias ? t.alias : void 0, r.role = Ko(t.role);
2123
- for (const o of t.properties) {
2124
- const a = {
2125
- name: o.name,
2126
- alias: o.alias ? o.alias : void 0,
2127
- fieldType: o.fieldType,
2128
- role: Bo(o.role),
2129
- geometryDef: o.fieldType === "esriFieldTypeGeometry" ? {
2130
- geometryType: o.geometryType ?? "esriGeometryAny",
2131
- hasM: o.hasM ? o.hasM : void 0,
2132
- hasZ: o.hasZ ? o.hasZ : void 0
2118
+ const r = new G();
2119
+ r.name = t.name, r.alias = t.alias ? t.alias : void 0, r.role = Ba(t.role);
2120
+ for (const a of t.properties) {
2121
+ const o = {
2122
+ name: a.name,
2123
+ alias: a.alias ? a.alias : void 0,
2124
+ fieldType: a.fieldType,
2125
+ role: Ha(a.role),
2126
+ geometryDef: a.fieldType === "esriFieldTypeGeometry" ? {
2127
+ geometryType: a.geometryType ?? "esriGeometryAny",
2128
+ hasM: a.hasM ? a.hasM : void 0,
2129
+ hasZ: a.hasZ ? a.hasZ : void 0
2133
2130
  } : void 0
2134
2131
  };
2135
- r.properties.push(a);
2132
+ r.properties.push(o);
2136
2133
  }
2137
2134
  return r;
2138
2135
  }
2139
2136
  }
2140
- class Vo extends j {
2137
+ class Ua extends G {
2141
2138
  constructor() {
2142
2139
  super(...arguments), this.observedEndPoints = [];
2143
2140
  }
2144
2141
  static fromRelationshipType(t) {
2145
- const r = j.fromEntityType(t);
2142
+ const r = G.fromEntityType(t);
2146
2143
  r.observedEndPoints = [];
2147
- for (const o of t.endPoints)
2144
+ for (const a of t.endPoints)
2148
2145
  r.observedEndPoints.push({
2149
- originEntityType: o.originEntityType,
2150
- destinationEntityType: o.destinationEntityType
2146
+ originEntityType: a.originEntityType,
2147
+ destinationEntityType: a.destinationEntityType
2151
2148
  });
2152
2149
  return r;
2153
2150
  }
2154
2151
  }
2155
- const Uo = (e) => {
2152
+ const Ka = (e) => {
2156
2153
  switch (e) {
2157
2154
  case "esriIdentifierInfoTypeUNSPECIFIED":
2158
2155
  return "UNSPECIFIED";
@@ -2163,7 +2160,7 @@ const Uo = (e) => {
2163
2160
  default:
2164
2161
  return e;
2165
2162
  }
2166
- }, Ko = (e) => {
2163
+ }, Ba = (e) => {
2167
2164
  switch (e) {
2168
2165
  case "Regular":
2169
2166
  return "esriGraphNamedObjectRegular";
@@ -2175,7 +2172,7 @@ const Uo = (e) => {
2175
2172
  return e;
2176
2173
  }
2177
2174
  };
2178
- function Bo(e) {
2175
+ function Ha(e) {
2179
2176
  switch (e) {
2180
2177
  case "esriGraphPropertyRegular":
2181
2178
  return "Regular";
@@ -2213,7 +2210,10 @@ function Bo(e) {
2213
2210
  return "Regular";
2214
2211
  }
2215
2212
  }
2216
- function Ho(e, t) {
2213
+ function Y(e) {
2214
+ return e?.signal;
2215
+ }
2216
+ function Ja(e, t) {
2217
2217
  return t ? `${e}
2218
2218
 
2219
2219
  Your previous attempt to generate a cypher query failed. See the details below and generate a new cypher query that avoids this error.
@@ -2223,249 +2223,257 @@ Execution Error: ${t.executionError}
2223
2223
  Failed Query:
2224
2224
  ${t.failedGraphQuery}` : e;
2225
2225
  }
2226
- async function Jo(e, t, r, o) {
2227
- const { graphQuery: a, explanation: n } = await ie(e, t, r, o);
2228
- return `Generated Graph Query:
2229
- ${a}
2230
-
2231
- Explanation: ${n}`;
2226
+ async function Za(e, t, r, a) {
2227
+ const { graphQuery: o, explanation: n } = await pe(e, t, r, a);
2228
+ return { graphQuery: o, explanation: n };
2232
2229
  }
2233
- async function ie(e, t, r, o, a) {
2230
+ async function pe(e, t, r, a, o) {
2234
2231
  const n = {
2235
- message: Ho(e, a),
2236
- context: new Wo(t)
2232
+ message: Ja(e, o),
2233
+ context: new Va(t)
2237
2234
  };
2238
- Q.conversationId && (n.conversationId = Q.conversationId), await S({ text: "Attempting to generate a cypher query from your prompt..." }, o);
2239
- const s = await le(`${r}/chat`, {
2235
+ _.conversationId && (n.conversationId = _.conversationId);
2236
+ const l = Y(a);
2237
+ await S({ text: "Attempting to generate a cypher query from your prompt..." }, a);
2238
+ const s = await he(`${r}/chat`, {
2240
2239
  method: "post",
2241
2240
  body: JSON.stringify(n),
2242
2241
  headers: {
2243
2242
  "Content-Type": "application/json",
2244
- token: ce.findCredential(k.getDefault().url)?.token ?? ""
2245
- }
2243
+ token: me.findCredential(k.getDefault().url)?.token ?? ""
2244
+ },
2245
+ signal: l
2246
2246
  });
2247
2247
  if (s.httpStatus !== 200)
2248
2248
  throw new Error(`Graph query service returned an error: ${s.httpStatus}`, {
2249
2249
  cause: s.data
2250
2250
  });
2251
- Q.conversationId || (Q.conversationId = s.data.conversationId);
2251
+ _.conversationId || (_.conversationId = s.data.conversationId);
2252
2252
  let c = !1;
2253
2253
  const u = Date.now();
2254
- let l = s.data.sequenceNumber, d = "", p = "", h = 1;
2254
+ let d = s.data.sequenceNumber, p = "", m = "", y = 1;
2255
2255
  for (; !c; ) {
2256
- await new Promise((w) => setTimeout(w, 1e3)), await S(
2257
- { text: `Periodically requesting status of job from ArcGIS AI Services${"...".substring(0, h)}` },
2258
- o
2259
- ), h = h % 3 + 1;
2260
- const m = await le(`${r}/chat`, {
2256
+ await new Promise((h) => setTimeout(h, 1e3)), await S(
2257
+ { text: `Periodically requesting status of job from ArcGIS AI Services${"...".substring(0, y)}` },
2258
+ a
2259
+ ), y = y % 3 + 1;
2260
+ const g = await he(`${r}/chat`, {
2261
2261
  method: "post",
2262
2262
  body: JSON.stringify({
2263
2263
  conversationId: s.data.conversationId,
2264
2264
  inquiryId: s.data.inquiryId,
2265
- ackSequenceNumber: l
2265
+ ackSequenceNumber: d
2266
2266
  }),
2267
2267
  headers: {
2268
2268
  "Content-Type": "application/json",
2269
- token: ce.findCredential(k.getDefault().url)?.token ?? ""
2270
- }
2269
+ token: me.findCredential(k.getDefault().url)?.token ?? ""
2270
+ },
2271
+ signal: l
2271
2272
  });
2272
- if (m.httpStatus !== 200)
2273
- throw new Error(`Graph query service polling returned an error: ${m.httpStatus}`, {
2274
- cause: m.data
2273
+ if (g.httpStatus !== 200)
2274
+ throw new Error(`Graph query service polling returned an error: ${g.httpStatus}`, {
2275
+ cause: g.data
2275
2276
  });
2276
- if (m.data.context)
2277
- d = m.data.context.graphQuery, p = m.data.message || "";
2278
- else if (!m.data.hasMore)
2277
+ if (g.data.context?.kind) {
2278
+ if (g.data.context.kind !== "GraphQueryGenerationResponse")
2279
+ throw new Error(`Unexpected response from graph query service polling. Message: ${g.data.message}`, {
2280
+ cause: g.data
2281
+ });
2282
+ p = g.data.context.graphQuery, m = g.data.message || "", c = !0;
2283
+ } else if (!g.data.hasMore)
2279
2284
  c = !0;
2280
2285
  else if (Date.now() - u > 6e4)
2281
2286
  throw new Error("Graph query service polling timed out after 1 minute.");
2282
- l = m.data.sequenceNumber;
2287
+ d = g.data.sequenceNumber;
2283
2288
  }
2284
- return { graphQuery: d, explanation: p };
2289
+ return { graphQuery: p, explanation: m };
2285
2290
  }
2286
- const F = 3;
2287
- function Re(e, t = 100) {
2291
+ const q = 3;
2292
+ function ke(e, t = 100) {
2288
2293
  const r = {};
2289
- for (const o of Object.entries(e.properties ?? {})) {
2290
- const [a, n] = o;
2291
- typeof n == "string" && n.length > t ? r[a] = `${n.slice(0, t)}... (truncated, original length: ${n.length})` : r[a] = n;
2294
+ for (const a of Object.entries(e.properties ?? {})) {
2295
+ const [o, n] = a;
2296
+ typeof n == "string" && n.length > t ? r[o] = `${n.slice(0, t)}... (truncated, original length: ${n.length})` : r[o] = n;
2292
2297
  }
2293
2298
  return e.properties = r, e;
2294
2299
  }
2295
- function se(e) {
2300
+ function A(e) {
2296
2301
  return typeof e != "object" || e === null ? String(e) : "details" in e && typeof e.details == "object" && e.details !== null && "errorMessage" in e.details && typeof e.details.errorMessage == "string" ? e.details.errorMessage : "message" in e && typeof e.message == "string" ? e.message : String(e);
2297
2302
  }
2298
- const Zo = async ({
2303
+ const Ya = async ({
2299
2304
  kg: e,
2300
2305
  queryParams: t,
2301
2306
  targetStructure: r,
2302
- targetStructureReducer: o,
2303
- requestOptions: a,
2307
+ targetStructureReducer: a,
2308
+ requestOptions: o,
2304
2309
  queryRowLimit: n,
2305
- queryTimeoutMs: s
2310
+ queryTimeoutMs: l
2306
2311
  }) => {
2307
- let c = null, u = r;
2308
- const l = new AbortController(), d = a?.signal, p = () => {
2309
- l.abort(d?.reason);
2312
+ let s = null, c = r;
2313
+ const u = new AbortController(), d = o?.signal, p = () => {
2314
+ u.abort(d?.reason);
2310
2315
  };
2311
- d && (d.aborted ? l.abort(d.reason) : d.addEventListener("abort", p, { once: !0 }));
2316
+ d && (d.aborted ? u.abort(d.reason) : d.addEventListener("abort", p, { once: !0 }));
2312
2317
  try {
2313
- const h = await pt(e, t, a);
2314
- c = h.resultHeader;
2315
- const m = h.resultRowsStream.getReader();
2316
- let w = 0;
2317
- const y = Date.now(), g = !1;
2318
+ const m = await ht(e, t, o);
2319
+ s = m.resultHeader;
2320
+ const y = m.resultRowsStream.getReader();
2321
+ let g = 0;
2322
+ const h = Date.now(), w = !1;
2318
2323
  for (; ; ) {
2319
- const { done: T, value: E } = await m.read();
2324
+ const { done: T, value: C } = await y.read();
2320
2325
  if (T)
2321
2326
  break;
2322
- if (!g && s && Date.now() - y > s)
2323
- return l.abort(), { type: "timeout" };
2324
- for (const v of E) {
2325
- if (w++, n && w > n)
2326
- return l.abort(), { type: "success", rowLimitReached: !0, resultHeader: c, processedResult: u };
2327
- u = o(u, v);
2327
+ if (!w && l && Date.now() - h > l)
2328
+ return u.abort(), { type: "timeout" };
2329
+ for (const v of C) {
2330
+ if (g++, n && g > n)
2331
+ return u.abort(), { type: "success", rowLimitReached: !0, resultHeader: s, processedResult: c };
2332
+ c = a(c, v);
2328
2333
  }
2329
2334
  }
2330
- } catch (h) {
2331
- return l.signal.aborted ? { type: "aborted" } : { type: "error", errorMessage: se(h), error: h };
2335
+ } catch (m) {
2336
+ return u.signal.aborted ? { type: "aborted" } : { type: "error", errorMessage: A(m), error: m };
2332
2337
  } finally {
2333
2338
  d?.removeEventListener("abort", p);
2334
2339
  }
2335
- return { type: "success", rowLimitReached: !1, resultHeader: c, processedResult: u };
2340
+ return { type: "success", rowLimitReached: !1, resultHeader: s, processedResult: c };
2336
2341
  };
2337
- async function $e({
2342
+ async function Fe({
2338
2343
  prompt: e,
2339
2344
  kg: t,
2340
2345
  graphQueryServiceUrl: r,
2341
- targetStructure: o,
2342
- targetStructureReducer: a,
2346
+ targetStructure: a,
2347
+ targetStructureReducer: o,
2343
2348
  requestOptions: n,
2344
- queryRowLimit: s,
2345
- queryTimeoutMs: c,
2346
- config: u
2349
+ queryRowLimit: l,
2350
+ queryTimeoutMs: s,
2351
+ config: c
2347
2352
  }) {
2348
- let l;
2349
- for (let d = 1; d <= F; d++) {
2353
+ let u;
2354
+ for (let d = 1; d <= q; d++) {
2350
2355
  let p;
2351
2356
  try {
2352
- p = await ie(e, t.dataModel, r, u, l);
2353
- } catch (w) {
2357
+ p = await pe(e, t.dataModel, r, c, u);
2358
+ } catch (g) {
2354
2359
  return {
2355
2360
  type: "generation-error",
2356
- errorMessage: se(w),
2357
- error: w
2361
+ errorMessage: A(g),
2362
+ error: g
2358
2363
  };
2359
2364
  }
2360
2365
  await S(
2361
2366
  {
2362
2367
  text: `Attempting to execute query: ${p.graphQuery.substring(0, 500)}${p.graphQuery.length > 500 ? "..." : ""}`
2363
2368
  },
2364
- u
2369
+ c
2365
2370
  );
2366
- const h = await Zo({
2371
+ const m = await Ya({
2367
2372
  kg: t,
2368
- queryParams: new ge({
2373
+ queryParams: new xe({
2369
2374
  openCypherQuery: p.graphQuery
2370
2375
  }),
2371
- targetStructure: o,
2372
- targetStructureReducer: a,
2376
+ targetStructure: a,
2377
+ targetStructureReducer: o,
2373
2378
  requestOptions: n,
2374
- queryRowLimit: s,
2375
- queryTimeoutMs: c
2376
- }), m = h.type === "aborted" ? "Query execution was aborted." : h.type === "timeout" ? "Query execution timed out." : h.type === "error" ? `Query failed with error: ${h.errorMessage}` : "";
2377
- if (h.type === "success")
2379
+ queryRowLimit: l,
2380
+ queryTimeoutMs: s
2381
+ }), y = m.type === "aborted" ? "Query execution was aborted." : m.type === "timeout" ? "Query execution timed out." : m.type === "error" ? `Query failed with error: ${m.errorMessage}` : "";
2382
+ if (m.type === "success")
2378
2383
  return {
2379
2384
  type: "success",
2380
2385
  graphQuery: p.graphQuery,
2381
2386
  explanation: p.explanation,
2382
- rowLimitReached: h.rowLimitReached,
2383
- resultHeader: h.resultHeader,
2384
- processedResult: h.processedResult
2387
+ rowLimitReached: m.rowLimitReached,
2388
+ resultHeader: m.resultHeader,
2389
+ processedResult: m.processedResult
2385
2390
  };
2386
- if (h.type === "aborted")
2391
+ if (m.type === "aborted")
2387
2392
  return {
2388
2393
  type: "aborted",
2389
- errorMessage: m,
2394
+ errorMessage: y,
2390
2395
  graphQuery: p.graphQuery,
2391
2396
  explanation: p.explanation
2392
2397
  };
2393
- if (d >= F)
2394
- return h.type === "timeout" ? {
2398
+ if (d >= q)
2399
+ return m.type === "timeout" ? {
2395
2400
  type: "timeout",
2396
- errorMessage: m,
2401
+ errorMessage: y,
2397
2402
  graphQuery: p.graphQuery,
2398
2403
  explanation: p.explanation
2399
2404
  } : {
2400
2405
  type: "execution-error",
2401
- errorMessage: m,
2402
- error: h.error,
2406
+ errorMessage: y,
2407
+ error: m.error,
2403
2408
  graphQuery: p.graphQuery,
2404
2409
  explanation: p.explanation
2405
2410
  };
2406
- l = {
2411
+ u = {
2407
2412
  failedGraphQuery: p.graphQuery,
2408
- executionError: m,
2413
+ executionError: y,
2409
2414
  attemptCount: d
2410
2415
  }, await S(
2411
- { text: `Attempt ${d} failed with error: ${m}. Retrying...` },
2412
- u
2416
+ { text: `Attempt ${d} failed with error: ${y}. Retrying...` },
2417
+ c
2413
2418
  );
2414
2419
  }
2415
2420
  throw new Error(
2416
- `Failed to execute generated cypher due to an unexpected error after ${F} attempts.`
2421
+ `Failed to execute generated cypher due to an unexpected error after ${q} attempts.`
2417
2422
  );
2418
2423
  }
2419
- const Yo = async ({
2424
+ const Xa = async ({
2420
2425
  kg: e,
2421
2426
  searchQuery: t,
2422
2427
  typeCategoryFilter: r,
2423
- namedTypesFilter: o,
2424
- searchResultLimit: a,
2428
+ namedTypesFilter: a,
2429
+ searchResultLimit: o,
2425
2430
  requestOptions: n
2426
2431
  }) => {
2427
- const s = [];
2428
- let c = [r];
2429
- r === "both" && !e.serviceDefinition.serviceCapabilities.searchCapabilities.searchTypeFilterCapabilities.includes("esriTypeBoth") && (c = ["entity", "relationship"]);
2430
- const u = a ?? 1 / 0;
2432
+ const l = [];
2433
+ let s = [r];
2434
+ r === "both" && !e.serviceDefinition.serviceCapabilities.searchCapabilities.searchTypeFilterCapabilities.includes("esriTypeBoth") && (s = ["entity", "relationship"]);
2435
+ const c = o ?? 1 / 0;
2431
2436
  try {
2432
- for (const l of c) {
2433
- const d = u - s.length;
2437
+ for (const u of s) {
2438
+ const d = c - l.length;
2434
2439
  if (d <= 0)
2435
2440
  break;
2436
- const m = (await ht(
2441
+ const y = (await yt(
2437
2442
  e,
2438
- new mt({
2443
+ new ft({
2439
2444
  searchQuery: t,
2440
- typeCategoryFilter: l,
2441
- namedTypesFilter: o ?? void 0,
2445
+ typeCategoryFilter: u,
2446
+ namedTypesFilter: a ?? void 0,
2442
2447
  num: d
2443
2448
  }),
2444
2449
  n
2445
2450
  )).resultRowsStream.getReader();
2446
- let w = !1;
2447
- for (; !w; ) {
2448
- const { done: y, value: g } = await m.read();
2449
- if (y) {
2450
- w = !0;
2451
+ let g = !1;
2452
+ for (; !g; ) {
2453
+ const { done: h, value: w } = await y.read();
2454
+ if (h) {
2455
+ g = !0;
2451
2456
  break;
2452
2457
  }
2453
- for (const T of g)
2454
- for (const E of T)
2455
- s.push(E);
2458
+ for (const T of w)
2459
+ for (const C of T)
2460
+ l.push(C);
2456
2461
  }
2457
2462
  }
2458
- } catch (l) {
2459
- return console.log('Error when running graph search with query: "', t, '" - error: ', l), n?.signal?.aborted ? {
2460
- type: "aborted"
2461
- } : { type: "error", errorMessage: se(l), error: l };
2463
+ } catch (u) {
2464
+ const d = A(u);
2465
+ return n?.signal?.aborted ? {
2466
+ type: "aborted",
2467
+ errorMessage: d,
2468
+ error: u
2469
+ } : { type: "error", errorMessage: d, error: u };
2462
2470
  }
2463
2471
  return {
2464
2472
  type: "success",
2465
- results: s
2473
+ results: l
2466
2474
  };
2467
2475
  };
2468
- function Xo(e, t) {
2476
+ function eo(e, t) {
2469
2477
  D(e, (r) => {
2470
2478
  t.set(`${r.typeName}__${r.id}`, {
2471
2479
  id: r.id,
@@ -2475,126 +2483,144 @@ function Xo(e, t) {
2475
2483
  }
2476
2484
  function D(e, t) {
2477
2485
  if (!(!e || typeof e != "object")) {
2478
- if (ta(e))
2486
+ if (ro(e))
2479
2487
  for (const r of e.path)
2480
2488
  D(r, t);
2481
- else if (ea(e))
2489
+ else if (to(e))
2482
2490
  t(e);
2483
2491
  else if (Array.isArray(e))
2484
2492
  for (const r of e)
2485
2493
  D(r, t);
2486
- else if (ra(e))
2494
+ else if (ao(e))
2487
2495
  for (const r of Object.values(e.properties ?? {}))
2488
2496
  D(r, t);
2489
2497
  }
2490
2498
  }
2491
- function ea(e) {
2499
+ function to(e) {
2492
2500
  return !e || typeof e != "object" || Array.isArray(e) ? !1 : "id" in e && "typeName" in e;
2493
2501
  }
2494
- function ta(e) {
2502
+ function ro(e) {
2495
2503
  return !e || typeof e != "object" || Array.isArray(e) ? !1 : e && "path" in e && Array.isArray(e.path);
2496
2504
  }
2497
- function ra(e) {
2505
+ function ao(e) {
2498
2506
  return !e || typeof e != "object" || Array.isArray(e) || "id" in e ? !1 : "properties" in e && typeof e.properties == "object";
2499
2507
  }
2500
- function oa(e, t) {
2508
+ function oo(e, t) {
2501
2509
  const r = [];
2502
- for (const o of [...t.dataModel.entityTypes, ...t.dataModel.relationshipTypes]) {
2503
- const a = e.getMemberIdsByType(o.name);
2504
- for (const n of a)
2505
- r.push({ id: n, typeName: o.name });
2510
+ for (const a of [...t.dataModel.entityTypes, ...t.dataModel.relationshipTypes]) {
2511
+ const o = e.getMemberIdsByType(a.name);
2512
+ for (const n of o)
2513
+ r.push({ id: n, typeName: a.name });
2506
2514
  }
2507
2515
  return r;
2508
2516
  }
2509
- function aa(e) {
2510
- const t = [], r = [], a = e?.allLayers.find((n) => n.type === "knowledge-graph")?.inclusionModeDefinition;
2511
- if (a?.generateAllSublayers)
2517
+ function no(e) {
2518
+ const t = [], r = [], o = e?.allLayers.find((n) => n.type === "knowledge-graph")?.inclusionModeDefinition;
2519
+ if (o?.generateAllSublayers)
2512
2520
  return { allNamedTypesFullyDynamic: !0, idTypePairs: t, dynamicTypes: r };
2513
- for (const [n, s] of a?.namedTypeDefinitions ?? [])
2514
- if (s.useAllData)
2521
+ for (const [n, l] of o?.namedTypeDefinitions ?? [])
2522
+ if (l.useAllData)
2515
2523
  r.push(n);
2516
2524
  else
2517
- for (const [c] of s.members)
2518
- t.push({ id: c, typeName: n });
2525
+ for (const [s] of l.members)
2526
+ t.push({ id: s, typeName: n });
2519
2527
  return { allNamedTypesFullyDynamic: !1, idTypePairs: t, dynamicTypes: r };
2520
2528
  }
2521
- async function na(e, t, r, o, a) {
2522
- const { view: n } = o, s = await $e({
2529
+ async function io(e, t, r, a, o) {
2530
+ const { view: n } = a, l = await Fe({
2523
2531
  prompt: e,
2524
2532
  kg: t,
2525
2533
  graphQueryServiceUrl: r,
2526
2534
  targetStructure: /* @__PURE__ */ new Map(),
2527
- targetStructureReducer: (p, h) => {
2528
- for (const m of h)
2529
- Xo(m, p);
2535
+ targetStructureReducer: (p, m) => {
2536
+ for (const y of m)
2537
+ eo(y, p);
2530
2538
  return p;
2531
2539
  },
2532
2540
  requestOptions: {
2533
- signal: a?.signal,
2534
- timeout: a?.timeout
2541
+ signal: Y(o),
2542
+ timeout: o?.timeout
2535
2543
  },
2536
- config: a
2544
+ config: o
2537
2545
  });
2538
- if (s.type !== "success") {
2539
- const p = s.type === "generation-error" ? s.errorMessage : `${s.errorMessage} Cypher query: ${s.graphQuery}`;
2546
+ if (l.type !== "success") {
2547
+ const p = l.type === "generation-error" ? l.errorMessage : `${l.errorMessage} Cypher query: ${l.graphQuery}`;
2540
2548
  throw new Error(`Failed to add records to the link chart. ${p}`);
2541
2549
  }
2542
- const { graphQuery: c, explanation: u, processedResult: l } = s, d = Array.from(l.values());
2550
+ const { graphQuery: s, explanation: c, processedResult: u } = l, d = Array.from(u.values());
2543
2551
  return await S(
2544
2552
  {
2545
2553
  text: `Query Results parsed into ${d.length} unique relationships and entities. Atempting to add to link chart...`
2546
2554
  },
2547
- a
2548
- ), !z(n) && n?.map ? (await n.map.addRecords(d), await B(n), `Link Chart updated successfully. Cypher Query used:
2549
- ${c}
2550
-
2551
- Explanation: ${u}`) : (await n?.map?.allLayers.find(
2552
- (h) => h.type === "knowledge-graph"
2553
- )?.addRecords(d), `Map updated successfully. Cypher Query used:
2554
- ${c}
2555
-
2556
- Explanation: ${u}`);
2555
+ o
2556
+ ), !N(n) && n?.map ? (await n.map.addRecords(d), await J(n), { generatedQuery: s, explanation: c, addedIdTypePairs: d }) : (await n?.map?.allLayers.find(
2557
+ (m) => m.type === "knowledge-graph"
2558
+ )?.addRecords(d), { generatedQuery: s, explanation: c, addedIdTypePairs: d });
2557
2559
  }
2558
- const Ee = "addRecords", ia = i.object({
2560
+ const W = "addRecords", so = i.object({
2559
2561
  prompt: i.string().describe("The user's inquiry into the knowledge graph that needs to be run.")
2560
- }), sa = async ({ prompt: e }, t) => {
2561
- const { knowledgeGraph: r } = await G(t), o = H(t), { view: a } = o, s = k.getDefault().helperServices;
2562
- let c = e;
2563
- if (z(a)) {
2564
- const l = a.map, { allNamedTypesFullyDynamic: d, idTypePairs: p, dynamicTypes: h } = aa(l), m = await Y("arcgis_knowledge_current_map_context");
2565
- if (c = `${e}
2562
+ }), lo = async ({ prompt: e }, t) => {
2563
+ const { knowledgeGraph: r } = await O(t), a = Z(t), { view: o } = a, l = k.getDefault().helperServices;
2564
+ let s = e;
2565
+ if (!N(o) && o.map) {
2566
+ const c = o.map, u = await te("arcgis_knowledge_current_lc_context"), d = oo(c, r);
2567
+ s = `${e}
2566
2568
 
2567
- ${m}${JSON.stringify(p)} and all entities or relationships with the the following typeNames in the array: ${JSON.stringify(h)}`, d)
2568
- throw new Error(
2569
- "No records have been added to the map because all data in the knowledge graph is contained in the map."
2570
- );
2571
- } else {
2572
- const l = a.map, d = await Y("arcgis_knowledge_current_lc_context"), p = oa(l, r);
2573
- c = `${e}
2569
+ ${u}${JSON.stringify(d)}`;
2570
+ } else if (N(o) && o.map) {
2571
+ const c = o.map, { allNamedTypesFullyDynamic: u, idTypePairs: d, dynamicTypes: p } = no(c), m = await te("arcgis_knowledge_current_map_context");
2572
+ if (s = `${e}
2574
2573
 
2575
- ${d}${JSON.stringify(p)}`;
2574
+ ${m}${JSON.stringify(d)} and all entities or relationships with the the following typeNames in the array: ${JSON.stringify(p)}`, u)
2575
+ return {
2576
+ toolName: W,
2577
+ status: "success",
2578
+ summary: "No records have been added to the map because all data in the knowledge graph is contained in the map.",
2579
+ details: {
2580
+ generatedQuery: "N/A",
2581
+ explanation: "All named types in the knowledge graph are fully dynamic and therefore all data is already contained in the map. No records have been added.",
2582
+ addedIdTypePairs: []
2583
+ }
2584
+ };
2576
2585
  }
2577
- const u = await na(
2578
- c,
2579
- r,
2580
- `${s.aiAssistantServices.url}${s.aiAssistantServices.graphQueryAssistant}`,
2581
- o,
2582
- t
2583
- );
2584
- return {
2585
- toolName: Ee,
2586
- status: "success",
2587
- summary: u
2588
- };
2589
- }, Zn = f(sa, {
2590
- name: Ee,
2586
+ try {
2587
+ const { generatedQuery: c, explanation: u, addedIdTypePairs: d } = await io(
2588
+ s,
2589
+ r,
2590
+ `${l.aiAssistantServices.url}${l.aiAssistantServices.graphQueryAssistant}`,
2591
+ a,
2592
+ t
2593
+ );
2594
+ return {
2595
+ toolName: W,
2596
+ status: "success",
2597
+ summary: `Records added successfully. Cypher Query used: ${c}
2598
+
2599
+ Number of records added: ${d.length}`,
2600
+ details: {
2601
+ generatedQuery: c,
2602
+ explanation: u,
2603
+ addedIdTypePairs: d
2604
+ }
2605
+ };
2606
+ } catch (c) {
2607
+ const u = A(c);
2608
+ return console.error(`Failed to add records to the link chart. ${u}`, c), {
2609
+ toolName: W,
2610
+ status: "error",
2611
+ errorMessage: `Failed to add records to the link chart. ${u}`,
2612
+ error: c
2613
+ };
2614
+ }
2615
+ }, ti = f(lo, {
2616
+ name: W,
2591
2617
  description: "Adds records (entities or relationships) to the current link chart visualization from an inquiry into the knowledge graph data. The inquiry will retrieve data from the graph database that will serve as the basis for the records to be added to the link chart. The user should have explicitly requested to add records to the current link chart from their prompt.",
2592
- schema: ia
2618
+ schema: so
2593
2619
  });
2594
- async function ca(e, t) {
2595
- return await t.map?.applyLayout(e), await B(t), `Successfully applied layout: ${e}.`;
2620
+ async function co(e, t) {
2621
+ return await t.map?.applyLayout(e), await J(t), { appliedLayout: e };
2596
2622
  }
2597
- const ee = "applyLayout", la = i.object({
2623
+ const ae = "applyLayout", uo = i.object({
2598
2624
  layout: i.enum([
2599
2625
  "organic-standard",
2600
2626
  "organic-community",
@@ -2608,143 +2634,160 @@ const ee = "applyLayout", la = i.object({
2608
2634
  ]).describe(
2609
2635
  "The layout mode to apply to the link chart. The value must be one of the following: organic-standard, organic-community, basic-grid, hierarchical-bottom-to-top, radial-root-centric, tree-left-to-right, geographic-organic-standard, chronological-mono-timeline, chronological-multi-timeline"
2610
2636
  )
2611
- }), ua = async ({ layout: e }, t) => {
2612
- const { view: r } = H(t);
2613
- if (z(r))
2637
+ }), po = async ({ layout: e }, t) => {
2638
+ const { view: r } = Z(t);
2639
+ if (N(r))
2614
2640
  return {
2615
- toolName: ee,
2641
+ toolName: ae,
2616
2642
  status: "error",
2617
2643
  errorMessage: "The applyLayout tool can only be used with a LinkChartView.",
2618
2644
  error: new Error()
2619
2645
  };
2620
2646
  {
2621
- const o = await ca(e, r);
2647
+ const { appliedLayout: a } = await co(e, r);
2622
2648
  return {
2623
- toolName: ee,
2649
+ toolName: ae,
2624
2650
  status: "success",
2625
- summary: o
2651
+ summary: `Successfully applied layout: ${a}.`,
2652
+ details: {
2653
+ appliedLayout: a
2654
+ }
2626
2655
  };
2627
2656
  }
2628
- }, Yn = f(ua, {
2629
- name: ee,
2657
+ }, ri = f(po, {
2658
+ name: ae,
2630
2659
  description: "Apply a diagram layout to the link chart",
2631
- schema: la
2660
+ schema: uo
2632
2661
  });
2633
- async function da(e, t) {
2634
- return t.map?.changeNonspatialDataDisplay(e), await B(t), `Successfully applied nonspatial visibility setting: ${e}.`;
2662
+ async function mo(e, t) {
2663
+ return t.map?.changeNonspatialDataDisplay(e), await J(t), { appliedNonspatialDataDisplayMode: e };
2635
2664
  }
2636
- const te = "changeNonspatialVisibility", pa = i.object({
2665
+ const oe = "changeNonspatialVisibility", ho = i.object({
2637
2666
  setting: i.enum(["hidden", "visible"]).describe("The setting of nonspatial visibility")
2638
- }), ha = async ({ setting: e }, t) => {
2639
- const { view: r } = H(t);
2640
- if (z(r))
2667
+ }), yo = async ({ setting: e }, t) => {
2668
+ const { view: r } = Z(t);
2669
+ if (N(r))
2641
2670
  return {
2642
- toolName: te,
2671
+ toolName: oe,
2643
2672
  status: "error",
2644
2673
  errorMessage: "The changeNonspatialVisibility tool can only be used with a LinkChartView.",
2645
2674
  error: new Error()
2646
2675
  };
2647
2676
  {
2648
- const o = await da(e, r);
2677
+ const { appliedNonspatialDataDisplayMode: a } = await mo(e, r);
2649
2678
  return {
2650
- toolName: te,
2679
+ toolName: oe,
2651
2680
  status: "success",
2652
- summary: o
2681
+ summary: `Successfully applied nonspatial visibility setting: ${a}.`,
2682
+ details: {
2683
+ appliedNonspatialDataDisplayMode: a
2684
+ }
2653
2685
  };
2654
2686
  }
2655
- }, Xn = f(ha, {
2656
- name: te,
2687
+ }, ai = f(yo, {
2688
+ name: oe,
2657
2689
  description: "Change whether or not nonspatial data is visible in the link chart. The value must be either 'hidden' or 'visible'.",
2658
- schema: pa
2690
+ schema: ho
2659
2691
  });
2660
- async function ma(e, t, r, o, a) {
2661
- let n;
2662
- for (let s = 1; s <= F; s++) {
2663
- const { graphQuery: c, explanation: u } = await ie(
2692
+ async function fo(e, t, r, a, o) {
2693
+ let n, l = "";
2694
+ for (let s = 1; s <= q; s++) {
2695
+ const { graphQuery: c, explanation: u } = await pe(
2664
2696
  e,
2665
2697
  t.dataModel,
2666
2698
  r,
2667
- a,
2699
+ o,
2668
2700
  n
2669
2701
  );
2670
2702
  try {
2671
- await S({ text: `Attempting to create link chart from derived query: ${c}` }, a);
2672
- const l = await dt.fromCypherQuery(
2703
+ await S({ text: `Attempting to create link chart from derived query: ${c}` }, o);
2704
+ const d = await mt.fromCypherQuery(
2673
2705
  t,
2674
- new ge({
2706
+ new xe({
2675
2707
  openCypherQuery: c
2676
2708
  })
2677
2709
  );
2678
- await S({ text: "Link chart created successfully, loading..." }, a), await l.load();
2679
- const d = o.map;
2680
- return o.map = l, await o.when(), await qe.whenOnce(() => !o.updating), l.entityCount === 0 && l.relationshipCount === 0 ? (o.map === l && (o.map = d), l.destroy(), {
2710
+ await S({ text: "Link chart created successfully, loading..." }, o), await d.load();
2711
+ const p = a.map;
2712
+ return a.map = d, await a.when(), await Ae.whenOnce(() => !a.updating), d.entityCount === 0 && d.relationshipCount === 0 ? (a.map === d && (a.map = p), d.destroy(), {
2681
2713
  type: "error",
2682
- message: `Query returned no results. Cypher Query used to create the link chart:
2714
+ errorMessage: `Query returned no results. Cypher Query used to create the link chart:
2683
2715
  ${c}
2684
2716
 
2685
2717
  Explanation: ${u}`
2686
- }) : (await B(o), {
2718
+ }) : (await J(a), {
2687
2719
  type: "success",
2688
- message: `Link chart created successfully. Cypher Query used to create the link chart:
2689
- ${c}
2690
-
2691
- Explanation: ${u}`
2720
+ graphQuery: c,
2721
+ explanation: u
2692
2722
  });
2693
- } catch (l) {
2694
- const d = l instanceof Error ? l.message : String(l);
2695
- if (s >= F)
2696
- throw new Error(
2697
- `Failed to create link chart after ${F} attempts. Last error: ${d}`
2698
- );
2723
+ } catch (d) {
2724
+ const p = A(d);
2725
+ if (s >= q) {
2726
+ l = p;
2727
+ break;
2728
+ }
2699
2729
  n = {
2700
2730
  failedGraphQuery: c,
2701
- executionError: d,
2731
+ executionError: p,
2702
2732
  attemptCount: s
2703
2733
  }, await S(
2704
- { text: `Attempt ${s} to create link chart failed with error: ${d}. Retrying ...` },
2705
- a
2734
+ { text: `Attempt ${s} to create link chart failed with error: ${p}. Retrying ...` },
2735
+ o
2706
2736
  );
2707
2737
  }
2708
2738
  }
2709
- throw new Error(`Failed to create link chart after ${F} attempts.`);
2739
+ return {
2740
+ type: "error",
2741
+ errorMessage: `Failed to create link chart after ${q} attempts. Last error: ${l}`
2742
+ };
2710
2743
  }
2711
- const _ = "createLinkChart", ya = i.object({
2744
+ const V = "createLinkChart", go = i.object({
2712
2745
  prompt: i.string().describe(
2713
2746
  "The user's inquiry into the knowledge graph that needs to be transformed into a link chart visualization."
2714
2747
  )
2715
- }), fa = async ({ prompt: e }, t) => {
2716
- const { knowledgeGraph: r } = await G(t), { view: o } = H(t);
2717
- if (z(o))
2748
+ }), wo = async ({ prompt: e }, t) => {
2749
+ const { knowledgeGraph: r } = await O(t), { view: a } = Z(t);
2750
+ if (N(a))
2718
2751
  return {
2719
- toolName: _,
2752
+ toolName: V,
2720
2753
  status: "error",
2721
2754
  errorMessage: "The createLinkChart tool can only be used with a LinkChartView.",
2722
2755
  error: new Error()
2723
2756
  };
2724
2757
  {
2725
- const n = k.getDefault().helperServices, s = await ma(
2758
+ const n = k.getDefault().helperServices, l = await fo(
2726
2759
  e,
2727
2760
  r,
2728
2761
  `${n.aiAssistantServices.url}${n.aiAssistantServices.graphQueryAssistant}`,
2729
- o,
2762
+ a,
2730
2763
  t
2731
2764
  );
2732
- return s.type === "error" ? {
2733
- toolName: _,
2734
- status: "error",
2735
- errorMessage: s.message,
2736
- error: new Error()
2737
- } : {
2738
- toolName: _,
2765
+ if (l.type === "error")
2766
+ return {
2767
+ toolName: V,
2768
+ status: "error",
2769
+ errorMessage: l.errorMessage,
2770
+ error: new Error()
2771
+ };
2772
+ const { graphQuery: s, explanation: c } = l;
2773
+ return {
2774
+ toolName: V,
2739
2775
  status: "success",
2740
- summary: s.message
2776
+ summary: `Link chart created successfully. Cypher Query used to create the link chart:
2777
+ ${s}
2778
+
2779
+ Explanation: ${c}`,
2780
+ details: {
2781
+ generatedQuery: s,
2782
+ explanation: c
2783
+ }
2741
2784
  };
2742
2785
  }
2743
- }, ei = f(fa, {
2744
- name: _,
2786
+ }, oi = f(wo, {
2787
+ name: V,
2745
2788
  description: "Creates a new link chart visualization from an inquiry into the knowledge graph data. The inquiry will retrieve data from the graph database that will serve as the basis for the new link chart. The user should have explicitly requested the creation of a new link chart from their prompt.",
2746
- schema: ya
2747
- }), Ce = "queryGraphData", ga = i.object({
2789
+ schema: go
2790
+ }), ne = "queryGraphData", bo = i.object({
2748
2791
  prompt: i.string().describe(
2749
2792
  `The user's inquiry into the knowledge graph, from which a cypher query will be generated and executed to answer the inquiry. IMPORTANT:
2750
2793
 
@@ -2752,223 +2795,248 @@ REQUEST LIMIT: If the user does not specifically request for no limits or an exp
2752
2795
 
2753
2796
  DESCRIPTIVE COLUMN NAMES: If the user's prompt does not explicitly request for specific column names in the result, ensure that the generated query has descriptive column names (using AS statements) to make the results easier to understand when displayed in a table format.`
2754
2797
  )
2755
- }), wa = async ({ prompt: e }, t) => {
2756
- const { knowledgeGraph: r } = await G(t), a = k.getDefault().helperServices, n = await $e({
2798
+ }), To = async ({ prompt: e }, t) => {
2799
+ const { knowledgeGraph: r } = await O(t), o = k.getDefault().helperServices, n = await Fe({
2757
2800
  prompt: e,
2758
2801
  kg: r,
2759
- graphQueryServiceUrl: `${a.aiAssistantServices.url}${a.aiAssistantServices.graphQueryAssistant}`,
2802
+ graphQueryServiceUrl: `${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,
2760
2803
  targetStructure: new Array(),
2761
- targetStructureReducer: (h, m) => (h.push(m), h),
2804
+ targetStructureReducer: (y, g) => (y.push(g), y),
2762
2805
  requestOptions: {
2763
- signal: t?.signal,
2806
+ signal: Y(t),
2764
2807
  timeout: t?.timeout
2765
2808
  },
2766
2809
  config: t
2767
2810
  });
2768
2811
  if (n.type !== "success") {
2769
- const h = n.type === "generation-error" ? n.errorMessage : `${n.errorMessage} Cypher query: ${n.graphQuery}`;
2770
- throw new Error(`Failed to query the knowledge graph. ${h}`);
2812
+ const y = n.type === "generation-error" ? n.errorMessage : `${n.errorMessage} Cypher query: ${n.graphQuery}`;
2813
+ return {
2814
+ toolName: ne,
2815
+ status: "error",
2816
+ errorMessage: `Failed to query the knowledge graph. ${y}`,
2817
+ error: "error" in n ? n.error : null
2818
+ };
2771
2819
  }
2772
- const { graphQuery: s, processedResult: c, resultHeader: u } = n, l = u.headerKeys;
2773
- for (const h of c)
2774
- for (const m of h)
2820
+ const { graphQuery: l, explanation: s, processedResult: c, resultHeader: u } = n, d = u.headerKeys;
2821
+ for (const y of c)
2822
+ for (const g of y)
2775
2823
  D(
2776
- m,
2777
- (w) => Re(w)
2824
+ g,
2825
+ (h) => ke(h)
2778
2826
  );
2779
- const d = 50, p = c.slice(0, d).map((h) => JSON.stringify(h));
2827
+ const p = 50, m = c.slice(0, p).map((y) => JSON.stringify(y));
2780
2828
  return {
2781
- toolName: Ce,
2829
+ toolName: ne,
2782
2830
  status: "success",
2783
2831
  summary: `To answer the inquiry, the following cypher query was executed against the knowledge graph:
2784
2832
 
2785
2833
  \`\`\`cypher
2786
- ${s}
2834
+ ${l}
2787
2835
  \`\`\`
2788
2836
 
2789
2837
  Query Results:
2790
- ${p.length} result(s) found.
2838
+ ${m.length} result(s) found.
2791
2839
 
2792
- Column Headers: ${l.join(", ")}
2840
+ Column Headers: ${d.join(", ")}
2793
2841
 
2794
- ${p.length > d ? `Showing top ${d} results:
2842
+ ${m.length > p ? `Showing top ${p} results:
2795
2843
 
2796
2844
  ` : `Results:
2797
2845
 
2798
- `}${p.join(`
2846
+ `}${m.join(`
2799
2847
  `)}
2800
2848
  `,
2801
2849
  details: {
2802
- generatedQuery: s,
2850
+ generatedQuery: l,
2851
+ explanation: s,
2803
2852
  resultHeader: u,
2804
2853
  queryResults: c
2805
2854
  }
2806
2855
  };
2807
- }, ti = f(wa, {
2808
- name: Ce,
2856
+ }, ni = f(To, {
2857
+ name: ne,
2809
2858
  description: "Allows users to explore the data in their knowledge graph via cypher query. Generates and executes a cypher query based on the user's inquiry into the knowledge graph, and displays the results in the chat pane without modifying the user's link chart if any. Use this tool when the user is asking an exploratory question about their data as a whole that can be answered via cypher query, for example 'What are the top 5 suppliers by total parts cost?' or 'How many employees do we have in each department?'.",
2810
- schema: ga
2811
- }), Ie = "generateCypher", ba = i.object({
2859
+ schema: bo
2860
+ }), ie = "generateCypher", vo = i.object({
2812
2861
  prompt: i.string().describe("The user's inquiry into the knowledge graph that needs to be translated into a cypher query.")
2813
- }), Ta = async ({ prompt: e }, t) => {
2814
- const { knowledgeGraph: r } = await G(t), a = k.getDefault().helperServices, n = await Jo(
2815
- e,
2816
- r.dataModel,
2817
- `${a.aiAssistantServices.url}${a.aiAssistantServices.graphQueryAssistant}`,
2818
- t
2819
- );
2820
- return {
2821
- toolName: Ie,
2822
- status: "success",
2823
- summary: n
2824
- };
2825
- }, ri = f(Ta, {
2826
- name: Ie,
2862
+ }), So = async ({ prompt: e }, t) => {
2863
+ const { knowledgeGraph: r } = await O(t), o = k.getDefault().helperServices;
2864
+ try {
2865
+ const { graphQuery: n, explanation: l } = await Za(
2866
+ e,
2867
+ r.dataModel,
2868
+ `${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,
2869
+ t
2870
+ );
2871
+ return {
2872
+ toolName: ie,
2873
+ status: "success",
2874
+ summary: `Generated Graph Query:
2875
+ ${n}
2876
+
2877
+ Explanation: ${l}`,
2878
+ details: {
2879
+ generatedQuery: n,
2880
+ explanation: l
2881
+ }
2882
+ };
2883
+ } catch (n) {
2884
+ const l = A(n);
2885
+ return {
2886
+ toolName: ie,
2887
+ status: "error",
2888
+ errorMessage: `Failed to generate Cypher query. ${l}`,
2889
+ error: n
2890
+ };
2891
+ }
2892
+ }, ii = f(So, {
2893
+ name: ie,
2827
2894
  description: "Generates an Open Cypher query based on the user's prompt which represents an inquiry into the data of the knowledge service and its graph database, attempting to filter based on certain conditions and traverse specified relationships. The generated query should be syntactically correct and optimized for performance.",
2828
- schema: ba
2829
- }), va = (e) => {
2895
+ schema: vo
2896
+ }), xo = (e) => {
2830
2897
  const t = e.dataModel, r = /* @__PURE__ */ new Map();
2831
- for (const c of t.searchIndexes)
2832
- if (c.supportedCategory !== "esriTypeMetaEntityProvenance")
2833
- for (const [u, l] of c.searchProperties.entries()) {
2834
- const d = r.get(u) ?? /* @__PURE__ */ new Set();
2835
- l.propertyNames.forEach((p) => d.add(p)), r.set(u, d);
2898
+ for (const s of t.searchIndexes)
2899
+ if (s.supportedCategory !== "esriTypeMetaEntityProvenance")
2900
+ for (const [c, u] of s.searchProperties.entries()) {
2901
+ const d = r.get(c) ?? /* @__PURE__ */ new Set();
2902
+ u.propertyNames.forEach((p) => d.add(p)), r.set(c, d);
2836
2903
  }
2837
- const o = t.entityTypes.filter((c) => r.has(c.name)), a = t.relationshipTypes.filter((c) => r.has(c.name)), n = `Entity Types:
2838
- ${o.map(({ name: c }) => `${c}: [${Array.from(r.get(c) ?? []).join(", ")}]`).join(`
2839
- `)}`, s = `Relationship Types:
2840
- ${a.map(({ name: c }) => `${c}: [${Array.from(r.get(c) ?? []).join(", ")}]`).join(`
2904
+ const a = t.entityTypes.filter((s) => r.has(s.name)), o = t.relationshipTypes.filter((s) => r.has(s.name)), n = `Entity Types:
2905
+ ${a.map(({ name: s }) => `${s}: [${Array.from(r.get(s) ?? []).join(", ")}]`).join(`
2906
+ `)}`, l = `Relationship Types:
2907
+ ${o.map(({ name: s }) => `${s}: [${Array.from(r.get(s) ?? []).join(", ")}]`).join(`
2841
2908
  `)}`;
2842
2909
  return `${n}
2843
2910
 
2844
- ${s}`;
2911
+ ${l}`;
2845
2912
  };
2846
- async function Sa(e, t) {
2847
- const r = await Y("arcgis_knowledge_lucene_generation_prompt"), o = {
2913
+ async function Ro(e, t) {
2914
+ const r = await te("arcgis_knowledge_lucene_generation_prompt"), a = {
2848
2915
  inquiry: e,
2849
- dataModelForSearch: va(t)
2850
- }, a = i.enum(["entity", "relationship", "both"]).describe("The graph element category to search against - entity, relationship, or both"), n = i.number().int().positive().nullable().describe(
2916
+ dataModelForSearch: xo(t)
2917
+ }, o = i.enum(["entity", "relationship", "both"]).describe("The graph element category to search against - entity, relationship, or both"), n = i.number().int().positive().nullable().describe(
2851
2918
  "The maximum number of search results to return. Default to 10 if not specified by the user, or set to null if the user specifically requests no limits or all results."
2852
- ), s = i.array(
2919
+ ), l = i.array(
2853
2920
  i.enum(
2854
- t.dataModel.entityTypes.map((l) => l.name).concat(t.dataModel.relationshipTypes.map((l) => l.name))
2921
+ t.dataModel.entityTypes.map((u) => u.name).concat(t.dataModel.relationshipTypes.map((u) => u.name))
2855
2922
  )
2856
- ).min(1), c = i.object({
2923
+ ).min(1), s = i.object({
2857
2924
  query: i.string().describe("A lucene syntax query string to be executed against the knowledge graph search API"),
2858
- typeFilters: s.nullable().describe(
2925
+ typeFilters: l.nullable().describe(
2859
2926
  "Nullable list of entity or relationship types from the graph to limit the search to. If set to null, search will execute against all named types with indexed properties in the graph"
2860
2927
  ),
2861
- typeCategoryFilter: a,
2928
+ typeCategoryFilter: o,
2862
2929
  resultLimit: n
2863
2930
  });
2864
- return await ze({
2931
+ return await De({
2865
2932
  promptText: r,
2866
- inputVariables: o,
2867
- schema: c
2933
+ inputVariables: a,
2934
+ schema: s
2868
2935
  });
2869
2936
  }
2870
- const Fe = "searchGraphData", xa = i.object({
2937
+ const se = "searchGraphData", $o = i.object({
2871
2938
  prompt: i.string().describe(
2872
2939
  "The user's inquiry into the knowledge graph, from which a lucene search query will be generated and executed against the graph to return relevant results."
2873
2940
  )
2874
- }), Ra = async ({ prompt: e }, t) => {
2875
- const { knowledgeGraph: r } = await G(t);
2941
+ }), Co = async ({ prompt: e }, t) => {
2942
+ const { knowledgeGraph: r } = await O(t);
2876
2943
  await S({ text: "Generating search query for the user inquiry" }, t);
2877
- const o = await Sa(e, r);
2944
+ const a = await Ro(e, r);
2878
2945
  await S({ text: "Executing graph search with generated search query" }, t);
2879
- const a = await Yo({
2946
+ const o = await Xa({
2880
2947
  kg: r,
2881
- searchQuery: o.query,
2882
- typeCategoryFilter: o.typeCategoryFilter,
2883
- namedTypesFilter: o.typeFilters,
2884
- searchResultLimit: o.resultLimit,
2948
+ searchQuery: a.query,
2949
+ typeCategoryFilter: a.typeCategoryFilter,
2950
+ namedTypesFilter: a.typeFilters,
2951
+ searchResultLimit: a.resultLimit,
2885
2952
  requestOptions: {
2886
- signal: t?.signal,
2953
+ signal: Y(t),
2887
2954
  timeout: t?.timeout
2888
2955
  }
2889
2956
  });
2890
- if (a.type !== "success")
2891
- throw new Error(
2892
- `Graph search failed with error: ${a.type === "error" ? a.errorMessage : "aborted"}`
2893
- );
2894
- for (const c of a.results)
2957
+ if (o.type !== "success")
2958
+ return {
2959
+ toolName: se,
2960
+ status: "error",
2961
+ errorMessage: o.errorMessage,
2962
+ error: "error" in o ? o.error : null
2963
+ };
2964
+ for (const s of o.results)
2895
2965
  D(
2896
- c,
2897
- (u) => Re(u)
2966
+ s,
2967
+ (c) => ke(c)
2898
2968
  );
2899
- const n = 10, s = a.results.slice(0, n);
2969
+ const n = 10, l = o.results.slice(0, n);
2900
2970
  return {
2901
- toolName: Fe,
2971
+ toolName: se,
2902
2972
  status: "success",
2903
2973
  summary: `To answer the query, the following lucene query was generated and executed:
2904
- Query: ${o.query}
2905
- Type Category Filter: ${o.typeCategoryFilter}
2906
- Named Type Filters: ${o.typeFilters ? o.typeFilters.join(", ") : "None"}
2907
- Result Limit: ${o.resultLimit ?? "No limit"}
2974
+ Query: ${a.query}
2975
+ Type Category Filter: ${a.typeCategoryFilter}
2976
+ Named Type Filters: ${a.typeFilters ? a.typeFilters.join(", ") : "None"}
2977
+ Result Limit: ${a.resultLimit ?? "No limit"}
2908
2978
 
2909
- Search Results: ${a.results.length} result(s) found.
2979
+ Search Results: ${o.results.length} result(s) found.
2910
2980
 
2911
- ${a.results.length > n ? `Showing top ${n} results:
2981
+ ${o.results.length > n ? `Showing top ${n} results:
2912
2982
 
2913
- ` : ""}${s.map((c) => JSON.stringify(c)).join(`
2983
+ ` : ""}${l.map((s) => JSON.stringify(s)).join(`
2914
2984
  `)}`,
2915
2985
  details: {
2916
- generatedQuery: o,
2917
- searchResults: {
2918
- ...a
2919
- }
2986
+ generatedSearchQuery: a,
2987
+ searchResults: o.results
2920
2988
  }
2921
2989
  };
2922
- }, oi = f(Ra, {
2923
- name: Fe,
2990
+ }, si = f(Co, {
2991
+ name: se,
2924
2992
  description: "Allows users to search the knowledge graph for text matching their inquiry, using lucene search syntax, against indexed string properties defined on their entities and relationships. Use this tool when the user asks a question about their knowledge graph data as a whole, that could be answered via lucene text search of properties stored on graph elements, e.g requiring fuzzy matching. Otherwise if the inquiry is looking for connected records (e.g. paths), data aggregations, etc explore the data via the queryGraphData tool.",
2925
- schema: xa
2993
+ schema: $o
2926
2994
  });
2927
2995
  export {
2928
- zn as A,
2929
- qn as B,
2930
- Dn as C,
2931
- An as D,
2932
- Ln as E,
2933
- Pn as F,
2934
- ne as G,
2935
- Kn as H,
2936
- jn as I,
2937
- Gn as J,
2938
- On as K,
2939
- Mn as L,
2940
- Qn as M,
2941
- Tn as N,
2942
- Wn as O,
2943
- Vn as P,
2944
- Oo as Q,
2945
- N as R,
2946
- _n as S,
2947
- Un as T,
2948
- Yn as a,
2949
- ri as b,
2950
- Xn as c,
2951
- ei as d,
2952
- Zn as e,
2953
- we as f,
2954
- Y as g,
2955
- Jn as h,
2956
- G as i,
2957
- Hn as j,
2958
- vn as k,
2959
- Bn as l,
2960
- Sn as m,
2961
- xn as n,
2962
- Rn as o,
2963
- $n as p,
2964
- ti as q,
2965
- kn as r,
2966
- oi as s,
2967
- _t as t,
2968
- En as u,
2969
- Cn as v,
2970
- In as w,
2971
- Fn as x,
2996
+ Pn as A,
2997
+ Ln as B,
2998
+ jn as C,
2999
+ Gn as D,
3000
+ On as E,
3001
+ Mn as F,
3002
+ de as G,
3003
+ Zn as H,
3004
+ Qn as I,
3005
+ _n as J,
3006
+ Wn as K,
3007
+ Vn as L,
3008
+ Un as M,
3009
+ Rn as N,
3010
+ Bn as O,
3011
+ Hn as P,
3012
+ Ma as Q,
3013
+ F as R,
3014
+ Kn as S,
3015
+ Jn as T,
3016
+ ri as a,
3017
+ ii as b,
3018
+ ai as c,
3019
+ oi as d,
3020
+ ti as e,
3021
+ Re as f,
3022
+ te as g,
3023
+ ei as h,
3024
+ O as i,
3025
+ Xn as j,
3026
+ $n as k,
3027
+ Yn as l,
3028
+ Cn as m,
3029
+ En as n,
3030
+ Nn as o,
3031
+ In as p,
3032
+ ni as q,
3033
+ Dn as r,
3034
+ si as s,
3035
+ Vt as t,
3036
+ kn as u,
3037
+ Fn as v,
3038
+ zn as w,
3039
+ qn as x,
2972
3040
  $ as y,
2973
- Nn as z
3041
+ An as z
2974
3042
  };