@arcgis/ai-components 5.2.0-next.11 → 5.2.0-next.111

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