@arcgis/ai-components 5.2.0-next.24 → 5.2.0-next.25

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