@arcgis/ai-components 5.1.0-next.130 → 5.1.0-next.131

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