@arcgis/ai-components 5.2.0-next.3 → 5.2.0-next.30

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