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

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.
@@ -1,9 +1,9 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
2
  import me from "@arcgis/core/identity/IdentityManager.js";
3
- import k from "@arcgis/core/portal/Portal.js";
4
- import { Annotation as b, messagesStateReducer as Te } from "@langchain/langgraph/web";
3
+ import I from "@arcgis/core/portal/Portal.js";
4
+ import { Annotation as w, messagesStateReducer as Te } from "@langchain/langgraph/web";
5
5
  import "@arcgis/toolkit/string";
6
- import { k as qe, j as B, i as De } from "./generateLayerDescriptions.js";
6
+ import { k as ze, j as K, i as De } from "./generateLayerDescriptions.js";
7
7
  import "@langchain/core/messages";
8
8
  import "@langchain/core/callbacks/dispatch/web";
9
9
  import "@langchain/openai";
@@ -22,13 +22,13 @@ import ve from "@arcgis/core/geometry/Point.js";
22
22
  import { createRenderer as Oe } from "@arcgis/core/smartMapping/renderers/pieChart.js";
23
23
  import { getSchemesByTag as Me, getSchemes as Qe } from "@arcgis/core/smartMapping/symbology/pieChart.js";
24
24
  import { getBackgroundColorTheme as ye } from "@arcgis/core/views/support/colorUtils.js";
25
- import { a as x, s as S } from "./index.js";
25
+ import { a as R, s as x } from "./index.js";
26
26
  import { createAgeRenderer as _e, createContinuousRenderer as We } from "@arcgis/core/smartMapping/renderers/color.js";
27
27
  import { getSchemesByTag as le } from "@arcgis/core/smartMapping/symbology/color.js";
28
28
  import { createContinuousRenderer as Ve } from "@arcgis/core/smartMapping/renderers/univariateColorSize.js";
29
29
  import { createRenderer as Ue } from "@arcgis/core/smartMapping/renderers/dotDensity.js";
30
- import { getSchemesByTag as Ke } from "@arcgis/core/smartMapping/symbology/dotDensity.js";
31
- import { createRenderer as Be } from "@arcgis/core/smartMapping/renderers/heatmap.js";
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
32
  import { getSchemesByTag as He } from "@arcgis/core/smartMapping/symbology/heatmap.js";
33
33
  import { createRenderer as Je } from "@arcgis/core/smartMapping/renderers/predominance.js";
34
34
  import { getSchemesByTag as Ze } from "@arcgis/core/smartMapping/symbology/predominance.js";
@@ -51,20 +51,20 @@ import xe from "@arcgis/core/rest/knowledgeGraph/GraphQueryStreaming.js";
51
51
  import "@arcgis/core/views/LinkChartView.js";
52
52
  import { fetchKnowledgeGraph as ge, executeQueryStreaming as ht, executeSearchStreaming as yt } from "@arcgis/core/rest/knowledgeGraphService.js";
53
53
  import ft from "@arcgis/core/rest/knowledgeGraph/GraphSearchStreaming.js";
54
- const L = (e, t) => t ?? e, Rn = b.Root({
55
- ...qe(),
54
+ const L = (e, t) => t ?? e, Cn = w.Root({
55
+ ...ze(),
56
56
  // internal to the navigation agent
57
- intent: b({
57
+ intent: w({
58
58
  reducer: L
59
59
  }),
60
- vectorSearchLayerResults: b({
60
+ vectorSearchLayerResults: w({
61
61
  reducer: L,
62
62
  default: () => []
63
63
  }),
64
- vectorSearchFieldResults: b({
64
+ vectorSearchFieldResults: w({
65
65
  reducer: L
66
66
  }),
67
- navigationInternalState: b({
67
+ navigationInternalState: w({
68
68
  reducer: L,
69
69
  default: () => ({
70
70
  toolCallMessage: void 0
@@ -72,7 +72,7 @@ const L = (e, t) => t ?? e, Rn = b.Root({
72
72
  })
73
73
  });
74
74
  async function gt(e, t) {
75
- const a = k.getDefault().helperServices, o = a.geocode.find((m) => m.name === "ArcGIS World Geocoding Service") ?? a.geocode[0];
75
+ const a = I.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
78
  const n = o.url, l = `${X.assetsPath?.endsWith("/") ? X.assetsPath : `${X.assetsPath}/`}esri/images/search/search-symbol-32.png`, c = (await Le(n, {
@@ -101,7 +101,7 @@ async function gt(e, t) {
101
101
  };
102
102
  }
103
103
  const wt = ["mapView"];
104
- function $(e) {
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");
@@ -111,12 +111,12 @@ function $(e) {
111
111
  return r;
112
112
  }
113
113
  async function bt({ address: e }, t) {
114
- const { mapView: r } = $(t);
114
+ const { mapView: r } = C(t);
115
115
  return await gt(e, r);
116
116
  }
117
117
  const Tt = i.object({
118
118
  address: i.string().describe("The full address or place name to locate.")
119
- }), $n = f(bt, {
119
+ }), En = f(bt, {
120
120
  name: "goToAddress",
121
121
  description: "Geocodes an address using Esri's World Geocoding Service and zooms the map to that location.",
122
122
  schema: Tt
@@ -134,12 +134,12 @@ async function vt(e, t) {
134
134
  return await t.goTo(n), { text: `Navigated to bookmark: ${e}` };
135
135
  }
136
136
  async function St({ bookmarkName: e }, t) {
137
- const { mapView: r } = $(t);
137
+ const { mapView: r } = C(t);
138
138
  return await Promise.resolve(vt(e, r));
139
139
  }
140
140
  const xt = E.object({
141
141
  bookmarkName: E.string().describe("The name of the bookmark to navigate to.")
142
- }), Cn = f(St, {
142
+ }), Fn = f(St, {
143
143
  name: "goToBookmark",
144
144
  description: "Go to the extent of the bookmark with the given name.",
145
145
  schema: xt
@@ -174,13 +174,13 @@ async function Rt(e, t, r) {
174
174
  }
175
175
  }
176
176
  async function $t({ layerId: e, where: t }, r) {
177
- const { mapView: a } = $(r);
177
+ const { mapView: a } = C(r);
178
178
  return await Rt(e, t, a);
179
179
  }
180
180
  const Ct = 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
- }), En = f($t, {
183
+ }), Nn = f($t, {
184
184
  name: "goToFeatures",
185
185
  description: "Go to the features that match the given filter related to the given layerId.",
186
186
  schema: Ct
@@ -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 Nt(e, t) {
199
- const { mapView: r } = $(t);
198
+ async function Ft(e, t) {
199
+ const { mapView: r } = C(t);
200
200
  return await Et(r);
201
201
  }
202
- const It = E.object({}), Nn = f(Nt, {
202
+ const Nt = E.object({}), In = f(Ft, {
203
203
  name: "goToFullExtent",
204
204
  description: "Zooms the map to the full world extent using Esri's Geocoding Service.",
205
- schema: It
205
+ schema: Nt
206
206
  });
207
- async function kt(e) {
207
+ async function It(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 kt(e) {
212
212
  throw new Error("Initial extent is undefined");
213
213
  return { text: "Successfully zoomed to home extent" };
214
214
  }
215
- async function Ft(e, t) {
216
- const { mapView: r } = $(t);
217
- return await kt(r);
215
+ async function kt(e, t) {
216
+ const { mapView: r } = C(t);
217
+ return await It(r);
218
218
  }
219
- const zt = i.object({}), In = f(Ft, {
219
+ const qt = i.object({}), kn = f(kt, {
220
220
  name: "goToHomeExtent",
221
221
  description: "Go to the initial web map view extent",
222
- schema: zt
222
+ schema: qt
223
223
  });
224
- async function qt(e, t) {
224
+ async function zt(e, t) {
225
225
  await t.when();
226
226
  const r = t.map?.allLayers.find((o) => o.id === e);
227
227
  if (!r)
@@ -230,12 +230,12 @@ async function qt(e, t) {
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
232
  async function Dt({ layerId: e }, t) {
233
- const { mapView: r } = $(t);
234
- return await qt(e, r);
233
+ const { mapView: r } = C(t);
234
+ return await zt(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
- }), kn = f(Dt, {
238
+ }), qn = f(Dt, {
239
239
  name: "goToLayer",
240
240
  description: "Zooms the map view to the full extent of the top matching layer.",
241
241
  schema: At
@@ -244,12 +244,12 @@ async function Pt(e, t) {
244
244
  return await t.goTo({ scale: e }), { text: `Successfully zoomed to: ${e}` };
245
245
  }
246
246
  async function Lt({ scale: e }, t) {
247
- const { mapView: r } = $(t);
247
+ const { mapView: r } = C(t);
248
248
  return await Pt(e, r);
249
249
  }
250
250
  const jt = i.object({
251
251
  scale: i.number().describe("The map scale of the view to go to.")
252
- }), Fn = f(Lt, {
252
+ }), zn = f(Lt, {
253
253
  name: "goToScale",
254
254
  description: "Go to the specified view scale.",
255
255
  schema: jt
@@ -273,7 +273,7 @@ async function Ot({
273
273
  zoom: t,
274
274
  scale: r
275
275
  }, a) {
276
- const { mapView: o } = $(a);
276
+ const { mapView: o } = C(a);
277
277
  return await Gt(e, o, { zoom: t, scale: r });
278
278
  }
279
279
  const Mt = i.object({
@@ -283,7 +283,7 @@ const Mt = i.object({
283
283
  }),
284
284
  zoom: i.number().optional().describe("The zoom level. Higher values = more zoomed in."),
285
285
  scale: i.number().optional().describe("The map scale. Alternative to zoom. Smaller numbers = more zoomed in.")
286
- }), zn = f(Ot, {
286
+ }), Dn = f(Ot, {
287
287
  name: "goToViewpoint",
288
288
  description: "Go to the specified viewpoint. This can contain a combination of scale, center, zoom, etc.",
289
289
  schema: Mt
@@ -292,12 +292,12 @@ async function Qt(e, t) {
292
292
  return await t.goTo({ zoom: e }), { text: `Successfully zoomed to: ${e}` };
293
293
  }
294
294
  async function _t({ zoom: e }, t) {
295
- const { mapView: r } = $(t);
295
+ const { mapView: r } = C(t);
296
296
  return await Qt(e, r);
297
297
  }
298
298
  const Wt = i.object({
299
299
  zoom: i.number().min(1).max(20).describe("The zoom level of the view to go to.")
300
- }), qn = f(_t, {
300
+ }), An = f(_t, {
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
303
  schema: Wt
@@ -332,7 +332,7 @@ const Vt = (e, t = 300) => {
332
332
  if (a == null)
333
333
  throw new Error(`${t} missing in config.configurable.services`);
334
334
  return a;
335
- }, Dn = (e, t) => (r, a) => {
335
+ }, Pn = (e, t) => (r, a) => {
336
336
  const o = a?.configurable?.services;
337
337
  for (const n of e)
338
338
  if (!o?.[n])
@@ -364,10 +364,10 @@ async function Ut(e) {
364
364
  pieChartScheme: l
365
365
  };
366
366
  }
367
- async function Kt(e) {
367
+ async function Bt(e) {
368
368
  return await Oe(e);
369
369
  }
370
- async function Bt({
370
+ async function Kt({
371
371
  arcgisMap: e,
372
372
  arcgisMapView: t,
373
373
  layerId: r,
@@ -386,14 +386,14 @@ async function Bt({
386
386
  colorSchemeTags: o
387
387
  };
388
388
  try {
389
- const d = await Ut(u), p = await Kt(d);
389
+ const d = await Ut(u), p = await Bt(d);
390
390
  return s.renderer = p.renderer, s.visible = !0, `Chart renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
391
391
  } catch (d) {
392
392
  return `Error applying chart renderer: ${d instanceof Error ? d.message : String(d)}`;
393
393
  }
394
394
  }
395
395
  const Ht = ["mapView"];
396
- function R(e) {
396
+ function $(e) {
397
397
  const r = e?.configurable?.context;
398
398
  if (!r || typeof r != "object")
399
399
  throw new Error("LayerStylingAgent context missing");
@@ -408,8 +408,8 @@ async function Jt({
408
408
  colorSchemes: r,
409
409
  includeSize: a
410
410
  }, o) {
411
- const { mapView: n } = R(o);
412
- return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await Bt({
411
+ const { mapView: n } = $(o);
412
+ return await R({ type: "show-legend", data: { layerIds: [e] } }, o), await Kt({
413
413
  arcgisMap: n.map,
414
414
  arcgisMapView: n,
415
415
  layerId: e,
@@ -423,7 +423,7 @@ const Zt = i.object({
423
423
  fields: i.array(i.string()).describe("The fields to use for the chart renderer (multiple numeric fields)"),
424
424
  colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
425
425
  includeSize: i.boolean().optional().describe("Whether to vary the chart size (chart-size)")
426
- }), An = f(Jt, {
426
+ }), Ln = f(Jt, {
427
427
  name: "chart",
428
428
  description: `Label: Charts
429
429
  Description: Show the values of two or more categories as a proportion of the total using a pie chart.
@@ -491,8 +491,8 @@ async function tr({
491
491
  colorSchemes: r,
492
492
  theme: a
493
493
  }, o) {
494
- const { mapView: n } = R(o);
495
- return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await er({
494
+ const { mapView: n } = $(o);
495
+ return await R({ type: "show-legend", data: { layerIds: [e] } }, o), await er({
496
496
  arcgisMap: n.map,
497
497
  arcgisMapView: n,
498
498
  layerId: e,
@@ -506,7 +506,7 @@ const rr = i.object({
506
506
  fields: i.array(i.string()).describe("The field(s) to use for the color-age renderer (temporal/date data)"),
507
507
  colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
508
508
  theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color ramp")
509
- }), Pn = f(tr, {
509
+ }), jn = f(tr, {
510
510
  name: "color-age",
511
511
  description: `Label: Age (color)
512
512
  Description: Use colors along a continuous color ramp to represent the age of features. Age reflects the length of time from a start date to an end date.
@@ -570,8 +570,8 @@ async function ir({
570
570
  colorSchemes: r,
571
571
  theme: a
572
572
  }, o) {
573
- const { mapView: n } = R(o);
574
- return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await nr({
573
+ const { mapView: n } = $(o);
574
+ return await R({ type: "show-legend", data: { layerIds: [e] } }, o), await nr({
575
575
  arcgisMap: n.map,
576
576
  arcgisMapView: n,
577
577
  layerId: e,
@@ -585,7 +585,7 @@ const sr = i.object({
585
585
  fields: i.array(i.string()).describe("The field(s) to use for the color renderer"),
586
586
  colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
587
587
  theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color ramp")
588
- }), Ln = f(ir, {
588
+ }), Gn = f(ir, {
589
589
  name: "color",
590
590
  description: `Label: Counts and Amounts (color)
591
591
  Description: Vary color along a continuous color ramp to represent numeric or ranked data.
@@ -648,8 +648,8 @@ async function dr({
648
648
  colorSchemes: r,
649
649
  theme: a
650
650
  }, o) {
651
- const { mapView: n } = R(o);
652
- return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await ur({
651
+ const { mapView: n } = $(o);
652
+ return await R({ type: "show-legend", data: { layerIds: [e] } }, o), await ur({
653
653
  arcgisMap: n.map,
654
654
  arcgisMapView: n,
655
655
  layerId: e,
@@ -663,7 +663,7 @@ const pr = i.object({
663
663
  fields: i.array(i.string()).describe("The fields to use for the color-size univariate renderer"),
664
664
  colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
665
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
- }), jn = f(dr, {
666
+ }), On = f(dr, {
667
667
  name: "color-size-univariate",
668
668
  description: `Label: Color and Size (univariate)
669
669
  Description: Vary symbol size and color based on the values of two numeric attributes.
@@ -675,7 +675,7 @@ const pr = i.object({
675
675
  function mr(e) {
676
676
  const { fields: t, layer: r, view: a, colorSchemeTags: o } = e;
677
677
  let n;
678
- return o && (n = Ke({
678
+ return o && (n = Be({
679
679
  includedTags: o,
680
680
  numColors: Math.min(t.length, 8)
681
681
  })[0]), {
@@ -724,8 +724,8 @@ async function fr({
724
724
  fields: t,
725
725
  colorSchemes: r
726
726
  }, a) {
727
- const { mapView: o } = R(a);
728
- return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await yr({
727
+ const { mapView: o } = $(a);
728
+ return await R({ type: "show-legend", data: { layerIds: [e] } }, a), await yr({
729
729
  arcgisMap: o.map,
730
730
  arcgisMapView: o,
731
731
  layerId: e,
@@ -737,7 +737,7 @@ const gr = i.object({
737
737
  layerId: i.string().describe("The id of the layer to apply the dot density renderer to"),
738
738
  fields: i.array(i.string()).describe("The field(s) to use for the dot density renderer (population or count data)"),
739
739
  colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use")
740
- }), Gn = f(fr, {
740
+ }), Mn = f(fr, {
741
741
  name: "dot-density",
742
742
  description: `Dot Density
743
743
  Use dot density to visualize the distribution of one attribute or compare the density of multiple attributes. This is only valid for polygon layers.
@@ -768,7 +768,7 @@ function wr(e) {
768
768
  };
769
769
  }
770
770
  async function br(e) {
771
- return await Be(e);
771
+ return await Ke(e);
772
772
  }
773
773
  async function Tr({
774
774
  arcgisMap: e,
@@ -799,8 +799,8 @@ async function vr({
799
799
  fields: t,
800
800
  colorSchemes: r
801
801
  }, a) {
802
- const { mapView: o } = R(a);
803
- return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await Tr({
802
+ const { mapView: o } = $(a);
803
+ return await R({ type: "show-legend", data: { layerIds: [e] } }, a), await Tr({
804
804
  arcgisMap: o.map,
805
805
  arcgisMapView: o,
806
806
  layerId: e,
@@ -812,7 +812,7 @@ const Sr = i.object({
812
812
  layerId: i.string().describe("The id of the layer to apply the heatmap renderer to"),
813
813
  fields: i.array(i.string()).describe("The field(s) to use for the heatmap renderer (typically point density)"),
814
814
  colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use")
815
- }), On = f(vr, {
815
+ }), Qn = f(vr, {
816
816
  name: "heatmap",
817
817
  description: `Label: Heat Map
818
818
  Description: Show areas of high density with colors that appear to glow hotter. This is only valid for point layers.
@@ -872,8 +872,8 @@ async function Cr({
872
872
  colorSchemes: r,
873
873
  includeSize: a
874
874
  }, o) {
875
- const { mapView: n } = R(o);
876
- return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await $r({
875
+ const { mapView: n } = $(o);
876
+ return await R({ type: "show-legend", data: { layerIds: [e] } }, o), await $r({
877
877
  arcgisMap: n.map,
878
878
  arcgisMapView: n,
879
879
  layerId: e,
@@ -887,7 +887,7 @@ const Er = i.object({
887
887
  fields: i.array(i.string()).describe("The fields to use for the predominance renderer (competing categories)"),
888
888
  colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
889
889
  includeSize: i.boolean().optional().describe("Whether to include size visualization (predominance-size)")
890
- }), Mn = f(Cr, {
890
+ }), _n = f(Cr, {
891
891
  name: "predominance",
892
892
  description: `Label: Predominant category
893
893
  Description: Compare attributes that share a common subject and unit of measurement to see which has the highest value.
@@ -902,7 +902,7 @@ const Er = i.object({
902
902
  Fields: This style relies on 2-10 number fields.`,
903
903
  schema: Er
904
904
  });
905
- function Nr(e) {
905
+ function Fr(e) {
906
906
  const { fields: t, layer: r, view: a, colorSchemeTags: o } = e;
907
907
  let n;
908
908
  const l = {
@@ -923,10 +923,10 @@ function Nr(e) {
923
923
  relationshipScheme: n
924
924
  };
925
925
  }
926
- async function Ir(e) {
926
+ async function Nr(e) {
927
927
  return await Ye(e);
928
928
  }
929
- async function kr({
929
+ async function Ir({
930
930
  arcgisMap: e,
931
931
  arcgisMapView: t,
932
932
  layerId: r,
@@ -944,19 +944,19 @@ async function kr({
944
944
  colorSchemeTags: o
945
945
  };
946
946
  try {
947
- const c = Nr(s), u = await Ir(c);
947
+ const c = Fr(s), u = await Nr(c);
948
948
  return l.renderer = u.renderer, l.visible = !0, `Relationship renderer applied to layer: ${l.title ?? l.id} using fields ${a.join(", ")}`;
949
949
  } catch (c) {
950
950
  return `Error applying relationship renderer: ${c instanceof Error ? c.message : String(c)}`;
951
951
  }
952
952
  }
953
- async function Fr({
953
+ async function kr({
954
954
  layerId: e,
955
955
  fields: t,
956
956
  colorSchemes: r
957
957
  }, a) {
958
- const { mapView: o } = R(a);
959
- return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await kr({
958
+ const { mapView: o } = $(a);
959
+ return await R({ type: "show-legend", data: { layerIds: [e] } }, a), await Ir({
960
960
  arcgisMap: o.map,
961
961
  arcgisMapView: o,
962
962
  layerId: e,
@@ -964,20 +964,20 @@ async function Fr({
964
964
  colorSchemes: r
965
965
  });
966
966
  }
967
- const zr = i.object({
967
+ const qr = i.object({
968
968
  layerId: i.string().describe("The id of the layer to apply the relationship renderer to"),
969
969
  fields: i.array(i.string()).describe("The two fields to use for the relationship renderer (bivariate visualization)"),
970
970
  colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use")
971
- }), Qn = f(Fr, {
971
+ }), Wn = f(kr, {
972
972
  name: "relationship",
973
973
  description: `Label: Relationship
974
974
  Description: Overlays two color ramps to represent the relationship between two numeric attributes.
975
975
  Keywords: relationship, correlation, compare, related, bivariate choropleth, bivariate color
976
976
  Example: Show the relationship between tree height and carbon storage
977
977
  Fields: This style requires two number fields.`,
978
- schema: zr
978
+ schema: qr
979
979
  });
980
- function qr(e) {
980
+ function zr(e) {
981
981
  const { fields: t, layer: r, view: a, theme: o } = e, n = t[0];
982
982
  return {
983
983
  layer: r,
@@ -1012,7 +1012,7 @@ async function Ar({
1012
1012
  theme: n
1013
1013
  };
1014
1014
  try {
1015
- const u = qr(c), d = await Dr(u);
1015
+ const u = zr(c), d = await Dr(u);
1016
1016
  return s.renderer = d.renderer, s.visible = !0, `Size-age renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
1017
1017
  } catch (u) {
1018
1018
  return `Error applying size-age renderer: ${u instanceof Error ? u.message : String(u)}`;
@@ -1024,8 +1024,8 @@ async function Pr({
1024
1024
  colorSchemes: r,
1025
1025
  theme: a
1026
1026
  }, o) {
1027
- const { mapView: n } = R(o);
1028
- return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await Ar({
1027
+ const { mapView: n } = $(o);
1028
+ return await R({ type: "show-legend", data: { layerIds: [e] } }, o), await Ar({
1029
1029
  arcgisMap: n.map,
1030
1030
  arcgisMapView: n,
1031
1031
  layerId: e,
@@ -1039,7 +1039,7 @@ const Lr = i.object({
1039
1039
  fields: i.array(i.string()).describe("The field(s) to use for the size-age renderer (temporal data with size)"),
1040
1040
  colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
1041
1041
  theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the size ramp")
1042
- }), _n = f(Pr, {
1042
+ }), Vn = f(Pr, {
1043
1043
  name: "size-age",
1044
1044
  description: `Label: Age (size)
1045
1045
  Description: Vary symbol sizes along a continuous ramp to represent the age of features. Age reflects the length of time from a start date to an end date.
@@ -1097,8 +1097,8 @@ async function Mr({
1097
1097
  colorSchemes: r,
1098
1098
  theme: a
1099
1099
  }, o) {
1100
- const { mapView: n } = R(o);
1101
- return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await Or({
1100
+ const { mapView: n } = $(o);
1101
+ return await R({ type: "show-legend", data: { layerIds: [e] } }, o), await Or({
1102
1102
  arcgisMap: n.map,
1103
1103
  arcgisMapView: n,
1104
1104
  layerId: e,
@@ -1112,7 +1112,7 @@ const Qr = i.object({
1112
1112
  fields: i.array(i.string()).describe("The field(s) to use for the size renderer (numeric data)"),
1113
1113
  colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
1114
1114
  theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the size ramp")
1115
- }), Wn = f(Mr, {
1115
+ }), Un = f(Mr, {
1116
1116
  name: "size",
1117
1117
  description: `Label: Counts and Amounts (size)
1118
1118
  Description: Vary symbol sizes along a continuous ramp to represent numeric or ranked data.
@@ -1179,8 +1179,8 @@ async function Ur({
1179
1179
  colorSchemes: r,
1180
1180
  theme: a
1181
1181
  }, o) {
1182
- const { mapView: n } = R(o);
1183
- return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await Vr({
1182
+ const { mapView: n } = $(o);
1183
+ return await R({ type: "show-legend", data: { layerIds: [e] } }, o), await Vr({
1184
1184
  arcgisMap: n.map,
1185
1185
  arcgisMapView: n,
1186
1186
  layerId: e,
@@ -1189,41 +1189,41 @@ async function Ur({
1189
1189
  theme: a
1190
1190
  });
1191
1191
  }
1192
- const Kr = i.object({
1192
+ const Br = i.object({
1193
1193
  layerId: i.string().describe("The id of the layer to apply the type renderer to"),
1194
1194
  fields: i.array(i.string()).describe("The field(s) to use for the type renderer (categorical data)"),
1195
1195
  colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
1196
1196
  theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color scheme")
1197
- }), Vn = f(Ur, {
1197
+ }), Bn = f(Ur, {
1198
1198
  name: "type",
1199
1199
  description: `Label: Types (unique symbols)
1200
1200
  Description: Represent features as categories with different symbol colors or shapes. Examples include type of tree, road class, or province name.
1201
1201
  Keywords: categorical, category, type, unique, discrete, point of interest, region, group
1202
1202
  Example: Color each feature based on the region it belongs to
1203
1203
  Fields: This style requires a single field which may be a string, number, or date type. It is usually a string.`,
1204
- schema: Kr
1205
- }), Un = b.Root({
1206
- ...B(),
1207
- vectorSearchLayerIds: b(),
1208
- vectorSearchFieldResults: b(),
1209
- layerFieldInfo: b(),
1210
- selectedLayerId: b()
1211
- }), Kn = b.Root({
1212
- ...B(),
1213
- vectorSearchLayerIds: b(),
1214
- vectorSearchFieldResults: b(),
1215
- layerFieldInfo: b(),
1216
- queryResponse: b(),
1217
- dataExplorationMessages: b({
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
1218
  reducer: Te,
1219
1219
  default: () => []
1220
1220
  })
1221
- }), Br = ["mapView"];
1222
- function F(e) {
1221
+ }), Kr = ["mapView"];
1222
+ function k(e) {
1223
1223
  const r = e?.configurable?.context;
1224
1224
  if (!r || typeof r != "object")
1225
1225
  throw new Error("DataExplorationAgent context missing");
1226
- const a = Br.filter((o) => !(o in r));
1226
+ const a = Kr.filter((o) => !(o in r));
1227
1227
  if (a.length)
1228
1228
  throw new Error(`DataExplorationAgent context missing: ${a.join(", ")}`);
1229
1229
  return r;
@@ -1236,7 +1236,7 @@ const Hr = (e) => {
1236
1236
  o.featureEffect && (o.featureEffect = null, r++);
1237
1237
  }), r > 0 ? `Cleared filters from ${r} layer(s). View unchanged.` : "No active filters to clear. View unchanged.";
1238
1238
  }, Jr = async (e, t) => {
1239
- const { mapView: r } = F(t);
1239
+ const { mapView: r } = k(t);
1240
1240
  return Hr(r);
1241
1241
  }, Zr = f(Jr, {
1242
1242
  name: "clearFilters",
@@ -1250,7 +1250,7 @@ const Hr = (e) => {
1250
1250
  const a = e.map.initialViewProperties?.viewpoint?.targetGeometry;
1251
1251
  return a ? (await e.goTo(a), "Cleared all filters and returned to home extent.") : "Cleared all filters. Could not determine home extent.";
1252
1252
  }, Xr = async (e, t) => {
1253
- const { mapView: r } = F(t);
1253
+ const { mapView: r } = k(t);
1254
1254
  return await Yr(r);
1255
1255
  }, ea = f(Xr, {
1256
1256
  name: "resetMap",
@@ -1356,20 +1356,20 @@ const H = async (e, t) => {
1356
1356
  o?.units
1357
1357
  ), d = l.title ?? e.layerId;
1358
1358
  return u.success ? `Applied feature effects to target layer "${l.title ?? e.layerId}"${o && "layerId" in o ? ` using geometry from layer "${o.layerId}"` : ""}.` : `Applied filter to "${d}" but no features matched. ${u.error}`;
1359
- }, aa = ["feet", "kilometers", "meters", "miles", "nautical-miles", "us-nautical-miles"], I = i.enum(aa), oa = async ({
1359
+ }, aa = ["feet", "kilometers", "meters", "miles", "nautical-miles", "us-nautical-miles"], N = i.enum(aa), oa = async ({
1360
1360
  targetLayer: e,
1361
1361
  geometryFilter: t,
1362
1362
  useCurrentExtent: r,
1363
1363
  includedEffect: a = "drop-shadow(2px, 2px, 2px, gray)",
1364
1364
  excludedEffect: o = "grayscale(100%) opacity(60%) blur(2px)"
1365
1365
  }, n) => {
1366
- const { mapView: l } = F(n);
1366
+ const { mapView: l } = k(n);
1367
1367
  return await ra(e, l, a, o, t, r);
1368
1368
  }, na = i.object({
1369
1369
  layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
1370
1370
  where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
1371
1371
  distance: i.number().optional().describe("The buffer distance around the geometry."),
1372
- units: I.optional().describe("The units for the distance buffer.")
1372
+ units: N.optional().describe("The units for the distance buffer.")
1373
1373
  }), ia = i.object({
1374
1374
  point: i.object({
1375
1375
  x: i.number().describe("X coordinate (longitude) from navigation result"),
@@ -1379,7 +1379,7 @@ const H = async (e, t) => {
1379
1379
  }).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
1380
1380
  }).describe("Point coordinates from a previous navigation/geocoding result"),
1381
1381
  distance: i.number().optional().describe("Optional buffer distance around the point."),
1382
- units: I.optional().describe("The units for the distance buffer.")
1382
+ units: N.optional().describe("The units for the distance buffer.")
1383
1383
  }), sa = i.object({
1384
1384
  targetLayer: i.object({
1385
1385
  layerId: i.string().describe("The layerId of the layer on which to set a feature effect."),
@@ -1415,7 +1415,7 @@ const H = async (e, t) => {
1415
1415
  return e;
1416
1416
  const t = re(e);
1417
1417
  return t ? t.toISOString().slice(0, 10) : null;
1418
- }, Bn = () => {
1418
+ }, Jn = () => {
1419
1419
  const e = (/* @__PURE__ */ new Date()).getTimezoneOffset(), t = e <= 0 ? "+" : "-", r = Math.floor(Math.abs(e) / 60).toString().padStart(2, "0"), a = (Math.abs(e) % 60).toString().padStart(2, "0"), o = `${t}${r}:${a}`;
1420
1420
  return { userTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone, userTimezoneOffset: o };
1421
1421
  }, da = (e, t, r) => {
@@ -1488,7 +1488,7 @@ const H = async (e, t) => {
1488
1488
  }, fa = (e, t, r, a) => {
1489
1489
  const o = e.fieldsIndex?.get(t), n = $e(t, r, e) ?? r;
1490
1490
  return Ee(e, t, n, o?.type, a);
1491
- }, ga = (e, t) => Ce(e, t), Ne = (e, t, r) => {
1491
+ }, ga = (e, t) => Ce(e, t), Fe = (e, t, r) => {
1492
1492
  const a = e.objectIdField, o = t.features.map(
1493
1493
  (l) => l.attributes[a]
1494
1494
  ), n = t.features.map((l) => {
@@ -1524,7 +1524,7 @@ const H = async (e, t) => {
1524
1524
  };
1525
1525
  };
1526
1526
  async function Ta({ layerId: e, fieldName: t, query: r }, a) {
1527
- const { mapView: o } = F(a), n = await ba(e, t, r, o);
1527
+ const { mapView: o } = k(a), n = await ba(e, t, r, o);
1528
1528
  return JSON.stringify(n, null, 2);
1529
1529
  }
1530
1530
  const va = i.object({
@@ -1537,8 +1537,13 @@ const va = i.object({
1537
1537
  name: "getAttribute",
1538
1538
  description: "Returns an attribute value for a given feature.",
1539
1539
  schema: va
1540
- }), ce = (e, t, r) => r ? e.hasAllFeaturesInView && e.availableFields === t : e.hasAllFeatures && e.availableFields === t;
1541
- function K(e, t) {
1540
+ }), ce = (e, t, r) => {
1541
+ if (!(r ? e.hasAllFeaturesInView : e.hasAllFeatures))
1542
+ return !1;
1543
+ const o = new Set((e.availableFields ?? []).map((n) => n.toLowerCase()));
1544
+ return o.has("*") ? !0 : t.every((n) => o.has(n.toLowerCase()));
1545
+ };
1546
+ function B(e, t) {
1542
1547
  let r = e ?? "";
1543
1548
  return t != null && t && (r = r ? `(${r}) AND (${t})` : t), r || null;
1544
1549
  }
@@ -1549,7 +1554,7 @@ const xa = async (e) => {
1549
1554
  const c = await o.whenLayerView(s), d = n.get(t.layerId)?.fieldRegistry.get(r), p = d?.alias;
1550
1555
  if (!d)
1551
1556
  throw new Error(`Field '${r}' not found.`);
1552
- let m, y;
1557
+ let m, h;
1553
1558
  if (l) {
1554
1559
  const v = await H(l, o);
1555
1560
  if ("error" in v)
@@ -1572,7 +1577,7 @@ const xa = async (e) => {
1572
1577
  units: l.units,
1573
1578
  applied: !0
1574
1579
  });
1575
- y = new Se({
1580
+ h = new Se({
1576
1581
  geometry: v.geometry,
1577
1582
  distance: l.distance,
1578
1583
  units: l.units,
@@ -1580,7 +1585,7 @@ const xa = async (e) => {
1580
1585
  });
1581
1586
  }
1582
1587
  const g = ce(c, [r], !1);
1583
- let h = null, w = null;
1588
+ let y = null, b = null;
1584
1589
  const T = 10;
1585
1590
  if (d.type !== "geometry" && d.type !== "oid" && d.type !== "global-id")
1586
1591
  try {
@@ -1589,22 +1594,22 @@ const xa = async (e) => {
1589
1594
  useFeaturesInView: g,
1590
1595
  view: g ? o : void 0,
1591
1596
  field: r,
1592
- sqlWhere: K(s.definitionExpression, t.where),
1593
- ...y && { filter: y },
1597
+ sqlWhere: B(s.definitionExpression, t.where),
1598
+ ...h && { filter: h },
1594
1599
  outStatisticTypes: { include: [a] }
1595
1600
  };
1596
- h = await ct(v);
1601
+ y = await ct(v);
1597
1602
  const M = ["string", "small-integer", "integer"], P = d.domain?.type === "coded-value" ? d.domain : null;
1598
- (M.includes(d.type) || P) && (w = (await ut({
1603
+ (M.includes(d.type) || P) && (b = (await ut({
1599
1604
  layer: s,
1600
1605
  useFeaturesInView: g,
1601
1606
  view: g ? o : void 0,
1602
1607
  field: r,
1603
- sqlWhere: K(s.definitionExpression, t.where),
1604
- ...y && { filter: y }
1605
- })).uniqueValueInfos.sort((z, ze) => ze.count - z.count).slice(0, T)), w && d.domain?.type === "coded-value" && (w = w.map((z) => ({
1606
- ...z,
1607
- value: P ? P.getName(z.value) ?? z.value : z.value
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
1608
1613
  })));
1609
1614
  } catch (v) {
1610
1615
  console.error("Statistics error:", v);
@@ -1612,14 +1617,14 @@ const xa = async (e) => {
1612
1617
  return {
1613
1618
  tool: "getStatistics",
1614
1619
  layerName: s.title ?? t.layerId,
1615
- summary: `${a} = ${typeof h?.[a] == "number" ? h[a] : "N/A"}`,
1620
+ summary: `${a} = ${typeof y?.[a] == "number" ? y[a] : "N/A"}`,
1616
1621
  details: {
1617
1622
  fieldName: r,
1618
1623
  fieldAlias: p,
1619
1624
  statisticType: a,
1620
- statistic: h?.[a] ?? null,
1621
- summaryStatistics: h,
1622
- uniqueValues: w,
1625
+ statistic: y?.[a] ?? null,
1626
+ summaryStatistics: y,
1627
+ uniqueValues: b,
1623
1628
  where: t.where,
1624
1629
  spatialFilterInfo: m
1625
1630
  }
@@ -1631,7 +1636,7 @@ async function Ra({
1631
1636
  statisticType: r,
1632
1637
  geometryFilter: a
1633
1638
  }, o) {
1634
- const n = Re(o, "layersAndFieldsRegistry"), { mapView: l } = F(o), s = await xa({
1639
+ const n = Re(o, "layersAndFieldsRegistry"), { mapView: l } = k(o), s = await xa({
1635
1640
  targetLayer: e,
1636
1641
  fieldName: t,
1637
1642
  statisticType: r,
@@ -1645,7 +1650,7 @@ const $a = i.object({
1645
1650
  layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
1646
1651
  where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
1647
1652
  distance: i.number().optional().describe("The buffer distance around the geometry."),
1648
- units: I.optional().describe("The units for the distance buffer.")
1653
+ units: N.optional().describe("The units for the distance buffer.")
1649
1654
  }), Ca = i.object({
1650
1655
  point: i.object({
1651
1656
  x: i.number().describe("X coordinate (longitude) from navigation result"),
@@ -1655,7 +1660,7 @@ const $a = i.object({
1655
1660
  }).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
1656
1661
  }).describe("Point coordinates from a previous navigation/geocoding result"),
1657
1662
  distance: i.number().optional().describe("Optional buffer distance around the point."),
1658
- units: I.optional().describe("The units for the distance buffer.")
1663
+ units: N.optional().describe("The units for the distance buffer.")
1659
1664
  }), Ea = i.object({
1660
1665
  targetLayer: i.object({
1661
1666
  layerId: i.string().describe("The layerId of the layer containing the field from which to get a value."),
@@ -1666,7 +1671,7 @@ const $a = i.object({
1666
1671
  ),
1667
1672
  fieldName: i.string().describe("The name of the field for which to get statistics. STRICTLY DO NOT use OBJECTID. Use any other field"),
1668
1673
  statisticType: i.enum(["avg", "max", "median", "min", "stddev", "sum", "variance", "nullcount", "count"]).describe("The statistic type to calculate.")
1669
- }), Na = f(Ra, {
1674
+ }), Fa = f(Ra, {
1670
1675
  name: "getStatistics",
1671
1676
  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.
1672
1677
 
@@ -1682,7 +1687,7 @@ DO NOT USE FOR:
1682
1687
 
1683
1688
  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.`,
1684
1689
  schema: Ea
1685
- }), Ia = async (e, t, r, a, o) => {
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) => {
1686
1691
  const n = r.map?.allLayers.find((m) => m.id === e.layerId), l = await r.whenLayerView(n), s = n.title ?? e.layerId;
1687
1692
  let c;
1688
1693
  if (a) {
@@ -1709,7 +1714,7 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
1709
1714
  try {
1710
1715
  let m;
1711
1716
  if (u) {
1712
- const h = new dt({
1717
+ const y = new dt({
1713
1718
  where: e.where || "1=1",
1714
1719
  outFields: p,
1715
1720
  orderByFields: e.orderByFields,
@@ -1723,18 +1728,20 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
1723
1728
  orderByFields: t.orderByFields
1724
1729
  })
1725
1730
  });
1726
- m = await n.queryTopFeatures(h);
1731
+ m = await n.queryTopFeatures(y);
1727
1732
  } else {
1728
- const h = n.createQuery();
1729
- h.where = K(n.definitionExpression, e.where || "1=1"), h.outFields = p.length ? p : ["*"], h.orderByFields = t.orderByFields, h.num = t.topCount, c && (h.geometry = c, h.spatialRelationship = "intersects"), a?.distance && (h.distance = a.distance), a?.units && (h.units = a.units), h.outSpatialReference = r.spatialReference;
1730
- const w = ce(l, e.outFields, o ?? !1);
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 = [
1736
+ .../* @__PURE__ */ new Set([...e.outFields, ...Na(t.orderByFields)])
1737
+ ], T = ce(l, b, o ?? !1);
1731
1738
  try {
1732
- m = w ? await l.queryFeatures(h) : await n.queryFeatures(h);
1733
- } catch (T) {
1734
- console.warn("Client-side query failed, falling back to server:", T), m = await n.queryFeatures(h);
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);
1735
1742
  }
1736
1743
  }
1737
- const y = m.features.map((h) => h.attributes[d]), { attributes: g } = Ne(n, m, r.timeZone);
1744
+ const h = m.features.map((y) => y.attributes[d]), { attributes: g } = Fe(n, m, r.timeZone);
1738
1745
  return {
1739
1746
  tool: "getTopFeatures",
1740
1747
  layerName: s,
@@ -1742,7 +1749,7 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
1742
1749
  details: {
1743
1750
  topCount: t.topCount,
1744
1751
  attributes: g,
1745
- objectIds: y,
1752
+ objectIds: h,
1746
1753
  objectIdField: d,
1747
1754
  where: e.where,
1748
1755
  orderByFields: t.orderByFields,
@@ -1763,13 +1770,13 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
1763
1770
  geometryFilter: r,
1764
1771
  useCurrentExtent: a
1765
1772
  }, o) => {
1766
- const { mapView: n } = F(o), l = await Ia(e, t, n, r, a);
1773
+ const { mapView: n } = k(o), l = await Ia(e, t, n, r, a);
1767
1774
  return JSON.stringify(l, null, 2);
1768
- }, Fa = i.object({
1775
+ }, qa = i.object({
1769
1776
  layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
1770
1777
  where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
1771
1778
  distance: i.number().optional().describe("The buffer distance around the geometry."),
1772
- units: I.optional().describe("The units for the distance buffer.")
1779
+ units: N.optional().describe("The units for the distance buffer.")
1773
1780
  }), za = i.object({
1774
1781
  point: i.object({
1775
1782
  x: i.number().describe("X coordinate (longitude) from navigation result"),
@@ -1779,8 +1786,8 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
1779
1786
  }).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
1780
1787
  }).describe("Point coordinates from a previous navigation/geocoding result"),
1781
1788
  distance: i.number().optional().describe("Optional buffer distance around the point."),
1782
- units: I.optional().describe("The units for the distance buffer.")
1783
- }), qa = i.object({
1789
+ units: N.optional().describe("The units for the distance buffer.")
1790
+ }), Da = i.object({
1784
1791
  targetLayer: i.object({
1785
1792
  layerId: i.string().describe("The layerId of the layer containing the field from which to get a value."),
1786
1793
  where: i.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),
@@ -1791,7 +1798,7 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
1791
1798
  ).default("*")
1792
1799
  )
1793
1800
  }),
1794
- geometryFilter: i.union([Fa, za]).optional().describe(
1801
+ geometryFilter: i.union([qa, za]).optional().describe(
1795
1802
  "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."
1796
1803
  ),
1797
1804
  topFilter: i.object({
@@ -1804,83 +1811,85 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
1804
1811
  useCurrentExtent: i.boolean().optional().describe(
1805
1812
  "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)."
1806
1813
  )
1807
- }), Da = f(ka, {
1814
+ }), Aa = f(ka, {
1808
1815
  name: "getTopFeatures",
1809
1816
  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.',
1810
- schema: qa
1811
- }), ee = 25, Aa = async (e, t, r, a) => {
1812
- const o = t.map?.allLayers.find((h) => h.id === e.layerId), n = await t.whenLayerView(o), l = o.title ?? e.layerId;
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;
1813
1820
  let s;
1814
1821
  if (r) {
1815
- const h = await H(r, t);
1816
- if ("error" in h) {
1817
- const w = { error: h.error };
1822
+ const b = await H(r, t);
1823
+ if ("error" in b) {
1824
+ const T = { error: b.error };
1818
1825
  if (j(r)) {
1819
- const T = t.map?.allLayers.find((C) => C.id === r.layerId);
1820
- w.geometryLayerName = T?.title ?? T?.id, w.geometryLayerId = r.layerId, w.geometryWhere = r.where;
1821
- } else U(r) && (w.point = r.point);
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);
1822
1829
  return {
1823
1830
  tool: "queryFeatures",
1824
1831
  layerName: l,
1825
1832
  summary: "Geometry lookup failed",
1826
- details: w
1833
+ details: T
1827
1834
  };
1828
1835
  }
1829
- if (!h.geometry) {
1830
- const w = {};
1836
+ if (!b.geometry) {
1837
+ const T = {};
1831
1838
  if (j(r)) {
1832
- const T = t.map?.allLayers.find((C) => C.id === r.layerId);
1833
- w.error = `No features found matching: ${r.where}`, w.geometryLayerName = T?.title ?? T?.id, w.geometryLayerId = r.layerId, w.geometryWhere = r.where;
1834
- } else U(r) && (w.error = "Failed to create point geometry", w.point = r.point);
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);
1835
1842
  return {
1836
1843
  tool: "queryFeatures",
1837
1844
  layerName: l,
1838
1845
  summary: "No features found for geometry filter",
1839
- details: w
1846
+ details: T
1840
1847
  };
1841
1848
  }
1842
- s = h.geometry;
1849
+ s = b.geometry;
1843
1850
  } else a && (s = t.extent.clone());
1844
- const c = ce(n, e.outFields, a ?? !1), u = o.objectIdField, d = o.createQuery();
1845
- d.where = K(o.definitionExpression, e.where || "1=1"), d.outFields = e.outFields.includes("*") ? ["*"] : [.../* @__PURE__ */ new Set([...e.outFields, u])], d.orderByFields = e.orderByFields, s && (d.geometry = s, d.spatialRelationship = "intersects"), r?.distance && (d.distance = r.distance), r?.units && (d.units = r.units), d.outSpatialReference = t.spatialReference;
1846
- let p, m;
1851
+ 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;
1847
1856
  try {
1848
- p = c ? await n.queryFeatureCount(d) : await o.queryFeatureCount(d), p > 0 && p <= ee && (m = c ? await n.queryFeatures(d) : await o.queryFeatures(d));
1849
- } catch (h) {
1850
- console.warn("Client-side query failed, falling back to server:", h), p = await o.queryFeatureCount(d), p > 0 && p <= ee && (m = await o.queryFeatures(d));
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));
1851
1860
  }
1852
- const { objectIds: y, attributes: g } = m ? Ne(o, m, t.timeZone) : { objectIds: void 0, attributes: void 0 };
1861
+ const { objectIds: g, attributes: y } = h ? Fe(o, h, t.timeZone) : { objectIds: void 0, attributes: void 0 };
1853
1862
  return {
1854
1863
  tool: "queryFeatures",
1855
1864
  layerName: l,
1856
- summary: `${p} features found`,
1865
+ summary: `${m} features found`,
1857
1866
  details: {
1858
- totalCount: p,
1867
+ totalCount: m,
1859
1868
  where: e.where,
1860
1869
  orderByFields: e.orderByFields,
1861
1870
  outFields: e.outFields,
1862
- ...y && { objectIds: y, objectIdField: u },
1863
- ...g && { attributes: g },
1864
- ...p > ee && {
1865
- note: `${p} features found.`
1871
+ ...g && { objectIds: g, objectIdField: d },
1872
+ ...y && { attributes: y },
1873
+ ...m > ee && {
1874
+ note: `${m} features found.`
1866
1875
  }
1867
1876
  }
1868
1877
  };
1869
1878
  };
1870
- async function Pa({
1879
+ async function ja({
1871
1880
  targetLayer: e,
1872
1881
  geometryFilter: t,
1873
1882
  useCurrentExtent: r
1874
1883
  }, a) {
1875
- const { mapView: o } = F(a), n = await Aa(e, o, t, r);
1884
+ const { mapView: o } = k(a), n = await La(e, o, t, r);
1876
1885
  return JSON.stringify(n, null, 2);
1877
1886
  }
1878
- const La = i.object({
1887
+ const Ga = i.object({
1879
1888
  layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
1880
1889
  where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
1881
1890
  distance: i.number().optional().describe("The buffer distance around the geometry."),
1882
- units: I.optional().describe("The units for the distance buffer.")
1883
- }), ja = i.object({
1891
+ units: N.optional().describe("The units for the distance buffer.")
1892
+ }), Oa = i.object({
1884
1893
  point: i.object({
1885
1894
  x: i.number().describe("X coordinate (longitude) from navigation result"),
1886
1895
  y: i.number().describe("Y coordinate (latitude) from navigation result"),
@@ -1889,8 +1898,8 @@ const La = i.object({
1889
1898
  }).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
1890
1899
  }).describe("Point coordinates from a previous navigation/geocoding result"),
1891
1900
  distance: i.number().optional().describe("Optional buffer distance around the point."),
1892
- units: I.optional().describe("The units for the distance buffer.")
1893
- }), Ga = i.object({
1901
+ units: N.optional().describe("The units for the distance buffer.")
1902
+ }), Ma = i.object({
1894
1903
  targetLayer: i.object({
1895
1904
  layerId: i.string().describe("The layerId of the layer containing the field from which to get a value."),
1896
1905
  where: i.string().describe(
@@ -1903,13 +1912,13 @@ const La = i.object({
1903
1912
  ).default("*")
1904
1913
  )
1905
1914
  }),
1906
- geometryFilter: i.union([La, ja]).optional().describe(
1915
+ geometryFilter: i.union([Ga, Oa]).optional().describe(
1907
1916
  "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."
1908
1917
  ),
1909
1918
  useCurrentExtent: i.boolean().optional().describe(
1910
1919
  "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)."
1911
1920
  )
1912
- }), Oa = f(Pa, {
1921
+ }), Qa = f(ja, {
1913
1922
  name: "queryFeatures",
1914
1923
  description: `Queries features from a layer. Returns the total count of matching features, plus individual feature attributes if ≤25 features match.
1915
1924
 
@@ -1921,10 +1930,10 @@ USE THIS TOOL FOR:
1921
1930
  - Any question where the user wants to SEE or COUNT matching features
1922
1931
 
1923
1932
  This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
1924
- schema: Ga
1925
- }), Ma = [Sa, Na, Da, Oa], Hn = [la, ea, Zr], Qa = new ot(Ma, { handleToolErrors: !1 });
1926
- async function Jn(e, t) {
1927
- const { messages: r } = await Qa.invoke({ messages: e.dataExplorationMessages }, t), a = [], o = [];
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 = [];
1928
1937
  for (const n of r) {
1929
1938
  const l = n.content;
1930
1939
  let s;
@@ -1951,7 +1960,7 @@ async function Jn(e, t) {
1951
1960
  }
1952
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}`);
1953
1962
  }
1954
- return await S({ text: `Finished executing layer query tool: ${o.join(", ")}` }, t), {
1963
+ return await x({ text: `Finished executing layer query tool: ${o.join(", ")}` }, t), {
1955
1964
  ...e,
1956
1965
  dataExplorationMessages: [...e.dataExplorationMessages, ...r],
1957
1966
  queryResponse: a,
@@ -1960,16 +1969,16 @@ async function Jn(e, t) {
1960
1969
  `)) : "Query executed."
1961
1970
  };
1962
1971
  }
1963
- const Zn = b.Root({
1964
- ...B(),
1972
+ const Xn = w.Root({
1973
+ ...K(),
1965
1974
  // internal to the help agent
1966
- helpInternalState: b({
1975
+ helpInternalState: w({
1967
1976
  reducer: L,
1968
1977
  default: () => ({
1969
1978
  toolCallMessage: void 0
1970
1979
  })
1971
1980
  })
1972
- }), _a = (e, t) => {
1981
+ }), Va = (e, t) => {
1973
1982
  const r = Array.from(e.values()).find(
1974
1983
  ({ layerItem: n }) => n.title?.toLowerCase().includes(t.toLowerCase())
1975
1984
  );
@@ -1982,25 +1991,25 @@ const Zn = b.Root({
1982
1991
  return `**${r.layerItem.title}** has ${a.length} field(s):
1983
1992
 
1984
1993
  ${o}`;
1985
- }, Wa = async ({ layerTitle: e }, t) => {
1994
+ }, Ua = async ({ layerTitle: e }, t) => {
1986
1995
  const r = Re(t, "layersAndFieldsRegistry");
1987
- return _a(r, e);
1988
- }, Yn = f(Wa, {
1996
+ return Va(r, e);
1997
+ }, ei = f(Ua, {
1989
1998
  name: "listLayerFields",
1990
1999
  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.",
1991
2000
  schema: i.object({
1992
2001
  layerTitle: i.string().describe("The title or partial title of the layer to list fields for.")
1993
2002
  })
1994
- }), Xn = b.Root({
1995
- ...B(),
1996
- intent: b({
2003
+ }), ti = w.Root({
2004
+ ...K(),
2005
+ intent: w({
1997
2006
  reducer: (e, t) => t
1998
2007
  }),
1999
- arcgisKnowledgeMessages: b({
2008
+ arcgisKnowledgeMessages: w({
2000
2009
  reducer: Te,
2001
2010
  default: () => []
2002
2011
  }),
2003
- arcgisKnowledgeToolResult: b({
2012
+ arcgisKnowledgeToolResult: w({
2004
2013
  reducer: (e, t) => t,
2005
2014
  default: () => null
2006
2015
  })
@@ -2012,11 +2021,11 @@ function ue(e) {
2012
2021
  if (!t || t?.length !== 1)
2013
2022
  throw new Error("The Knowledge Agent currently only supports maps with exactly one Knowledge Graph Layer.");
2014
2023
  }
2015
- function N(e) {
2024
+ function F(e) {
2016
2025
  return !!e?.map && !("activeLinkChartLayer" in e.map);
2017
2026
  }
2018
2027
  async function J(e) {
2019
- !e || N(e) || !e.map?.diagramNodesExtent || await e.goTo(e.map.diagramNodesExtent);
2028
+ !e || F(e) || !e.map?.diagramNodesExtent || await e.goTo(e.map.diagramNodesExtent);
2020
2029
  }
2021
2030
  function Z(e) {
2022
2031
  const r = e?.configurable?.context;
@@ -2029,16 +2038,16 @@ function Z(e) {
2029
2038
  view: a
2030
2039
  };
2031
2040
  }
2032
- function ei(e) {
2041
+ function ri(e) {
2033
2042
  const r = e?.configurable?.context;
2034
- if (Ie(e) === "knowledgeGraph")
2043
+ if (Ne(e) === "knowledgeGraph")
2035
2044
  return "knowledgeGraph";
2036
2045
  const o = r.view;
2037
- return N(o) ? (ue(o), "map") : "linkChart";
2046
+ return F(o) ? (ue(o), "map") : "linkChart";
2038
2047
  }
2039
2048
  async function O(e) {
2040
2049
  const r = e?.configurable?.context;
2041
- if (Ie(e) === "knowledgeGraph")
2050
+ if (Ne(e) === "knowledgeGraph")
2042
2051
  return r;
2043
2052
  {
2044
2053
  const o = r.view.map;
@@ -2062,7 +2071,7 @@ async function O(e) {
2062
2071
  }
2063
2072
  }
2064
2073
  }
2065
- function Ie(e) {
2074
+ function Ne(e) {
2066
2075
  const r = e?.configurable?.context;
2067
2076
  if (!r || typeof r != "object")
2068
2077
  throw new Error("ArcgisKnowledgeAgent context missing");
@@ -2074,7 +2083,7 @@ function Ie(e) {
2074
2083
  return "view";
2075
2084
  throw new Error("ArcgisKnowledgeAgent context must have either a view or knowledgeGraph property.");
2076
2085
  }
2077
- class Va {
2086
+ class Ba {
2078
2087
  constructor(t) {
2079
2088
  this.dataModel = t, this.kind = "GraphQueryGenerationRequest", this.explainQuery = !0, this.schemaInformation = de.fromDataModel(t);
2080
2089
  }
@@ -2093,10 +2102,10 @@ class de {
2093
2102
  for (const a of t.entityTypes)
2094
2103
  r.entityTypes.push(G.fromEntityType(a));
2095
2104
  for (const a of t.relationshipTypes)
2096
- r.relationshipTypes.push(Ua.fromRelationshipType(a));
2105
+ r.relationshipTypes.push(Ka.fromRelationshipType(a));
2097
2106
  return r.identifierInfo = {
2098
2107
  mappingInfo: {
2099
- identifierMapsTo: Ka(
2108
+ identifierMapsTo: Ha(
2100
2109
  t.identifierInfo.identifierMappingInfo.identifierInfoType
2101
2110
  ),
2102
2111
  identifierPropertyName: t.identifierInfo.identifierMappingInfo.uniformPropertyIdentifier.identifierPropertyName
@@ -2116,13 +2125,13 @@ class G {
2116
2125
  }
2117
2126
  static fromEntityType(t) {
2118
2127
  const r = new G();
2119
- r.name = t.name, r.alias = t.alias ? t.alias : void 0, r.role = Ba(t.role);
2128
+ r.name = t.name, r.alias = t.alias ? t.alias : void 0, r.role = Ja(t.role);
2120
2129
  for (const a of t.properties) {
2121
2130
  const o = {
2122
2131
  name: a.name,
2123
2132
  alias: a.alias ? a.alias : void 0,
2124
2133
  fieldType: a.fieldType,
2125
- role: Ha(a.role),
2134
+ role: Za(a.role),
2126
2135
  geometryDef: a.fieldType === "esriFieldTypeGeometry" ? {
2127
2136
  geometryType: a.geometryType ?? "esriGeometryAny",
2128
2137
  hasM: a.hasM ? a.hasM : void 0,
@@ -2134,7 +2143,7 @@ class G {
2134
2143
  return r;
2135
2144
  }
2136
2145
  }
2137
- class Ua extends G {
2146
+ class Ka extends G {
2138
2147
  constructor() {
2139
2148
  super(...arguments), this.observedEndPoints = [];
2140
2149
  }
@@ -2149,7 +2158,7 @@ class Ua extends G {
2149
2158
  return r;
2150
2159
  }
2151
2160
  }
2152
- const Ka = (e) => {
2161
+ const Ha = (e) => {
2153
2162
  switch (e) {
2154
2163
  case "esriIdentifierInfoTypeUNSPECIFIED":
2155
2164
  return "UNSPECIFIED";
@@ -2160,7 +2169,7 @@ const Ka = (e) => {
2160
2169
  default:
2161
2170
  return e;
2162
2171
  }
2163
- }, Ba = (e) => {
2172
+ }, Ja = (e) => {
2164
2173
  switch (e) {
2165
2174
  case "Regular":
2166
2175
  return "esriGraphNamedObjectRegular";
@@ -2172,7 +2181,7 @@ const Ka = (e) => {
2172
2181
  return e;
2173
2182
  }
2174
2183
  };
2175
- function Ha(e) {
2184
+ function Za(e) {
2176
2185
  switch (e) {
2177
2186
  case "esriGraphPropertyRegular":
2178
2187
  return "Regular";
@@ -2213,7 +2222,7 @@ function Ha(e) {
2213
2222
  function Y(e) {
2214
2223
  return e?.signal;
2215
2224
  }
2216
- function Ja(e, t) {
2225
+ function Ya(e, t) {
2217
2226
  return t ? `${e}
2218
2227
 
2219
2228
  Your previous attempt to generate a cypher query failed. See the details below and generate a new cypher query that avoids this error.
@@ -2223,24 +2232,24 @@ Execution Error: ${t.executionError}
2223
2232
  Failed Query:
2224
2233
  ${t.failedGraphQuery}` : e;
2225
2234
  }
2226
- async function Za(e, t, r, a) {
2235
+ async function Xa(e, t, r, a) {
2227
2236
  const { graphQuery: o, explanation: n } = await pe(e, t, r, a);
2228
2237
  return { graphQuery: o, explanation: n };
2229
2238
  }
2230
2239
  async function pe(e, t, r, a, o) {
2231
2240
  const n = {
2232
- message: Ja(e, o),
2233
- context: new Va(t)
2241
+ message: Ya(e, o),
2242
+ context: new Ba(t)
2234
2243
  };
2235
2244
  _.conversationId && (n.conversationId = _.conversationId);
2236
2245
  const l = Y(a);
2237
- await S({ text: "Attempting to generate a cypher query from your prompt..." }, a);
2246
+ await x({ text: "Attempting to generate a cypher query from your prompt..." }, a);
2238
2247
  const s = await he(`${r}/chat`, {
2239
2248
  method: "post",
2240
2249
  body: JSON.stringify(n),
2241
2250
  headers: {
2242
2251
  "Content-Type": "application/json",
2243
- token: me.findCredential(k.getDefault().url)?.token ?? ""
2252
+ token: me.findCredential(I.getDefault().url)?.token ?? ""
2244
2253
  },
2245
2254
  signal: l
2246
2255
  });
@@ -2251,12 +2260,12 @@ async function pe(e, t, r, a, o) {
2251
2260
  _.conversationId || (_.conversationId = s.data.conversationId);
2252
2261
  let c = !1;
2253
2262
  const u = Date.now();
2254
- let d = s.data.sequenceNumber, p = "", m = "", y = 1;
2263
+ let d = s.data.sequenceNumber, p = "", m = "", h = 1;
2255
2264
  for (; !c; ) {
2256
- await new Promise((h) => setTimeout(h, 1e3)), await S(
2257
- { text: `Periodically requesting status of job from ArcGIS AI Services${"...".substring(0, y)}` },
2265
+ await new Promise((y) => setTimeout(y, 1e3)), await x(
2266
+ { text: `Periodically requesting status of job from ArcGIS AI Services${"...".substring(0, h)}` },
2258
2267
  a
2259
- ), y = y % 3 + 1;
2268
+ ), h = h % 3 + 1;
2260
2269
  const g = await he(`${r}/chat`, {
2261
2270
  method: "post",
2262
2271
  body: JSON.stringify({
@@ -2266,7 +2275,7 @@ async function pe(e, t, r, a, o) {
2266
2275
  }),
2267
2276
  headers: {
2268
2277
  "Content-Type": "application/json",
2269
- token: me.findCredential(k.getDefault().url)?.token ?? ""
2278
+ token: me.findCredential(I.getDefault().url)?.token ?? ""
2270
2279
  },
2271
2280
  signal: l
2272
2281
  });
@@ -2288,8 +2297,8 @@ async function pe(e, t, r, a, o) {
2288
2297
  }
2289
2298
  return { graphQuery: p, explanation: m };
2290
2299
  }
2291
- const q = 3;
2292
- function ke(e, t = 100) {
2300
+ const z = 3;
2301
+ function Ie(e, t = 100) {
2293
2302
  const r = {};
2294
2303
  for (const a of Object.entries(e.properties ?? {})) {
2295
2304
  const [o, n] = a;
@@ -2300,7 +2309,7 @@ function ke(e, t = 100) {
2300
2309
  function A(e) {
2301
2310
  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);
2302
2311
  }
2303
- const Ya = async ({
2312
+ const eo = async ({
2304
2313
  kg: e,
2305
2314
  queryParams: t,
2306
2315
  targetStructure: r,
@@ -2317,16 +2326,16 @@ const Ya = async ({
2317
2326
  try {
2318
2327
  const m = await ht(e, t, o);
2319
2328
  s = m.resultHeader;
2320
- const y = m.resultRowsStream.getReader();
2329
+ const h = m.resultRowsStream.getReader();
2321
2330
  let g = 0;
2322
- const h = Date.now(), w = !1;
2331
+ const y = Date.now(), b = !1;
2323
2332
  for (; ; ) {
2324
- const { done: T, value: C } = await y.read();
2333
+ const { done: T, value: S } = await h.read();
2325
2334
  if (T)
2326
2335
  break;
2327
- if (!w && l && Date.now() - h > l)
2336
+ if (!b && l && Date.now() - y > l)
2328
2337
  return u.abort(), { type: "timeout" };
2329
- for (const v of C) {
2338
+ for (const v of S) {
2330
2339
  if (g++, n && g > n)
2331
2340
  return u.abort(), { type: "success", rowLimitReached: !0, resultHeader: s, processedResult: c };
2332
2341
  c = a(c, v);
@@ -2339,7 +2348,7 @@ const Ya = async ({
2339
2348
  }
2340
2349
  return { type: "success", rowLimitReached: !1, resultHeader: s, processedResult: c };
2341
2350
  };
2342
- async function Fe({
2351
+ async function ke({
2343
2352
  prompt: e,
2344
2353
  kg: t,
2345
2354
  graphQueryServiceUrl: r,
@@ -2351,7 +2360,7 @@ async function Fe({
2351
2360
  config: c
2352
2361
  }) {
2353
2362
  let u;
2354
- for (let d = 1; d <= q; d++) {
2363
+ for (let d = 1; d <= z; d++) {
2355
2364
  let p;
2356
2365
  try {
2357
2366
  p = await pe(e, t.dataModel, r, c, u);
@@ -2362,13 +2371,13 @@ async function Fe({
2362
2371
  error: g
2363
2372
  };
2364
2373
  }
2365
- await S(
2374
+ await x(
2366
2375
  {
2367
2376
  text: `Attempting to execute query: ${p.graphQuery.substring(0, 500)}${p.graphQuery.length > 500 ? "..." : ""}`
2368
2377
  },
2369
2378
  c
2370
2379
  );
2371
- const m = await Ya({
2380
+ const m = await eo({
2372
2381
  kg: t,
2373
2382
  queryParams: new xe({
2374
2383
  openCypherQuery: p.graphQuery
@@ -2378,7 +2387,7 @@ async function Fe({
2378
2387
  requestOptions: n,
2379
2388
  queryRowLimit: l,
2380
2389
  queryTimeoutMs: s
2381
- }), y = m.type === "aborted" ? "Query execution was aborted." : m.type === "timeout" ? "Query execution timed out." : m.type === "error" ? `Query failed with error: ${m.errorMessage}` : "";
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}` : "";
2382
2391
  if (m.type === "success")
2383
2392
  return {
2384
2393
  type: "success",
@@ -2391,37 +2400,37 @@ async function Fe({
2391
2400
  if (m.type === "aborted")
2392
2401
  return {
2393
2402
  type: "aborted",
2394
- errorMessage: y,
2403
+ errorMessage: h,
2395
2404
  graphQuery: p.graphQuery,
2396
2405
  explanation: p.explanation
2397
2406
  };
2398
- if (d >= q)
2407
+ if (d >= z)
2399
2408
  return m.type === "timeout" ? {
2400
2409
  type: "timeout",
2401
- errorMessage: y,
2410
+ errorMessage: h,
2402
2411
  graphQuery: p.graphQuery,
2403
2412
  explanation: p.explanation
2404
2413
  } : {
2405
2414
  type: "execution-error",
2406
- errorMessage: y,
2415
+ errorMessage: h,
2407
2416
  error: m.error,
2408
2417
  graphQuery: p.graphQuery,
2409
2418
  explanation: p.explanation
2410
2419
  };
2411
2420
  u = {
2412
2421
  failedGraphQuery: p.graphQuery,
2413
- executionError: y,
2422
+ executionError: h,
2414
2423
  attemptCount: d
2415
- }, await S(
2416
- { text: `Attempt ${d} failed with error: ${y}. Retrying...` },
2424
+ }, await x(
2425
+ { text: `Attempt ${d} failed with error: ${h}. Retrying...` },
2417
2426
  c
2418
2427
  );
2419
2428
  }
2420
2429
  throw new Error(
2421
- `Failed to execute generated cypher due to an unexpected error after ${q} attempts.`
2430
+ `Failed to execute generated cypher due to an unexpected error after ${z} attempts.`
2422
2431
  );
2423
2432
  }
2424
- const Xa = async ({
2433
+ const to = async ({
2425
2434
  kg: e,
2426
2435
  searchQuery: t,
2427
2436
  typeCategoryFilter: r,
@@ -2438,7 +2447,7 @@ const Xa = async ({
2438
2447
  const d = c - l.length;
2439
2448
  if (d <= 0)
2440
2449
  break;
2441
- const y = (await yt(
2450
+ const h = (await yt(
2442
2451
  e,
2443
2452
  new ft({
2444
2453
  searchQuery: t,
@@ -2450,14 +2459,14 @@ const Xa = async ({
2450
2459
  )).resultRowsStream.getReader();
2451
2460
  let g = !1;
2452
2461
  for (; !g; ) {
2453
- const { done: h, value: w } = await y.read();
2454
- if (h) {
2462
+ const { done: y, value: b } = await h.read();
2463
+ if (y) {
2455
2464
  g = !0;
2456
2465
  break;
2457
2466
  }
2458
- for (const T of w)
2459
- for (const C of T)
2460
- l.push(C);
2467
+ for (const T of b)
2468
+ for (const S of T)
2469
+ l.push(S);
2461
2470
  }
2462
2471
  }
2463
2472
  } catch (u) {
@@ -2473,7 +2482,7 @@ const Xa = async ({
2473
2482
  results: l
2474
2483
  };
2475
2484
  };
2476
- function eo(e, t) {
2485
+ function ro(e, t) {
2477
2486
  D(e, (r) => {
2478
2487
  t.set(`${r.typeName}__${r.id}`, {
2479
2488
  id: r.id,
@@ -2483,29 +2492,29 @@ function eo(e, t) {
2483
2492
  }
2484
2493
  function D(e, t) {
2485
2494
  if (!(!e || typeof e != "object")) {
2486
- if (ro(e))
2495
+ if (oo(e))
2487
2496
  for (const r of e.path)
2488
2497
  D(r, t);
2489
- else if (to(e))
2498
+ else if (ao(e))
2490
2499
  t(e);
2491
2500
  else if (Array.isArray(e))
2492
2501
  for (const r of e)
2493
2502
  D(r, t);
2494
- else if (ao(e))
2503
+ else if (no(e))
2495
2504
  for (const r of Object.values(e.properties ?? {}))
2496
2505
  D(r, t);
2497
2506
  }
2498
2507
  }
2499
- function to(e) {
2508
+ function ao(e) {
2500
2509
  return !e || typeof e != "object" || Array.isArray(e) ? !1 : "id" in e && "typeName" in e;
2501
2510
  }
2502
- function ro(e) {
2511
+ function oo(e) {
2503
2512
  return !e || typeof e != "object" || Array.isArray(e) ? !1 : e && "path" in e && Array.isArray(e.path);
2504
2513
  }
2505
- function ao(e) {
2514
+ function no(e) {
2506
2515
  return !e || typeof e != "object" || Array.isArray(e) || "id" in e ? !1 : "properties" in e && typeof e.properties == "object";
2507
2516
  }
2508
- function oo(e, t) {
2517
+ function io(e, t) {
2509
2518
  const r = [];
2510
2519
  for (const a of [...t.dataModel.entityTypes, ...t.dataModel.relationshipTypes]) {
2511
2520
  const o = e.getMemberIdsByType(a.name);
@@ -2514,7 +2523,7 @@ function oo(e, t) {
2514
2523
  }
2515
2524
  return r;
2516
2525
  }
2517
- function no(e) {
2526
+ function so(e) {
2518
2527
  const t = [], r = [], o = e?.allLayers.find((n) => n.type === "knowledge-graph")?.inclusionModeDefinition;
2519
2528
  if (o?.generateAllSublayers)
2520
2529
  return { allNamedTypesFullyDynamic: !0, idTypePairs: t, dynamicTypes: r };
@@ -2526,15 +2535,15 @@ function no(e) {
2526
2535
  t.push({ id: s, typeName: n });
2527
2536
  return { allNamedTypesFullyDynamic: !1, idTypePairs: t, dynamicTypes: r };
2528
2537
  }
2529
- async function io(e, t, r, a, o) {
2530
- const { view: n } = a, l = await Fe({
2538
+ async function lo(e, t, r, a, o) {
2539
+ const { view: n } = a, l = await ke({
2531
2540
  prompt: e,
2532
2541
  kg: t,
2533
2542
  graphQueryServiceUrl: r,
2534
2543
  targetStructure: /* @__PURE__ */ new Map(),
2535
2544
  targetStructureReducer: (p, m) => {
2536
- for (const y of m)
2537
- eo(y, p);
2545
+ for (const h of m)
2546
+ ro(h, p);
2538
2547
  return p;
2539
2548
  },
2540
2549
  requestOptions: {
@@ -2548,27 +2557,27 @@ async function io(e, t, r, a, o) {
2548
2557
  throw new Error(`Failed to add records to the link chart. ${p}`);
2549
2558
  }
2550
2559
  const { graphQuery: s, explanation: c, processedResult: u } = l, d = Array.from(u.values());
2551
- return await S(
2560
+ return await x(
2552
2561
  {
2553
2562
  text: `Query Results parsed into ${d.length} unique relationships and entities. Atempting to add to link chart...`
2554
2563
  },
2555
2564
  o
2556
- ), !N(n) && n?.map ? (await n.map.addRecords(d), await J(n), { generatedQuery: s, explanation: c, addedIdTypePairs: d }) : (await n?.map?.allLayers.find(
2565
+ ), !F(n) && n?.map ? (await n.map.addRecords(d), await J(n), { generatedQuery: s, explanation: c, addedIdTypePairs: d }) : (await n?.map?.allLayers.find(
2557
2566
  (m) => m.type === "knowledge-graph"
2558
2567
  )?.addRecords(d), { generatedQuery: s, explanation: c, addedIdTypePairs: d });
2559
2568
  }
2560
- const W = "addRecords", so = i.object({
2569
+ const W = "addRecords", co = i.object({
2561
2570
  prompt: i.string().describe("The user's inquiry into the knowledge graph that needs to be run.")
2562
- }), lo = async ({ prompt: e }, t) => {
2563
- const { knowledgeGraph: r } = await O(t), a = Z(t), { view: o } = a, l = k.getDefault().helperServices;
2571
+ }), uo = async ({ prompt: e }, t) => {
2572
+ const { knowledgeGraph: r } = await O(t), a = Z(t), { view: o } = a, l = I.getDefault().helperServices;
2564
2573
  let s = e;
2565
- if (!N(o) && o.map) {
2566
- const c = o.map, u = await te("arcgis_knowledge_current_lc_context"), d = oo(c, r);
2574
+ if (!F(o) && o.map) {
2575
+ const c = o.map, u = await te("arcgis_knowledge_current_lc_context"), d = io(c, r);
2567
2576
  s = `${e}
2568
2577
 
2569
2578
  ${u}${JSON.stringify(d)}`;
2570
- } else if (N(o) && o.map) {
2571
- const c = o.map, { allNamedTypesFullyDynamic: u, idTypePairs: d, dynamicTypes: p } = no(c), m = await te("arcgis_knowledge_current_map_context");
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");
2572
2581
  if (s = `${e}
2573
2582
 
2574
2583
  ${m}${JSON.stringify(d)} and all entities or relationships with the the following typeNames in the array: ${JSON.stringify(p)}`, u)
@@ -2584,7 +2593,7 @@ ${m}${JSON.stringify(d)} and all entities or relationships with the the followin
2584
2593
  };
2585
2594
  }
2586
2595
  try {
2587
- const { generatedQuery: c, explanation: u, addedIdTypePairs: d } = await io(
2596
+ const { generatedQuery: c, explanation: u, addedIdTypePairs: d } = await lo(
2588
2597
  s,
2589
2598
  r,
2590
2599
  `${l.aiAssistantServices.url}${l.aiAssistantServices.graphQueryAssistant}`,
@@ -2612,15 +2621,15 @@ Number of records added: ${d.length}`,
2612
2621
  error: c
2613
2622
  };
2614
2623
  }
2615
- }, ti = f(lo, {
2624
+ }, ai = f(uo, {
2616
2625
  name: W,
2617
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.",
2618
- schema: so
2627
+ schema: co
2619
2628
  });
2620
- async function co(e, t) {
2629
+ async function po(e, t) {
2621
2630
  return await t.map?.applyLayout(e), await J(t), { appliedLayout: e };
2622
2631
  }
2623
- const ae = "applyLayout", uo = i.object({
2632
+ const ae = "applyLayout", mo = i.object({
2624
2633
  layout: i.enum([
2625
2634
  "organic-standard",
2626
2635
  "organic-community",
@@ -2634,9 +2643,9 @@ const ae = "applyLayout", uo = i.object({
2634
2643
  ]).describe(
2635
2644
  "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"
2636
2645
  )
2637
- }), po = async ({ layout: e }, t) => {
2646
+ }), ho = async ({ layout: e }, t) => {
2638
2647
  const { view: r } = Z(t);
2639
- if (N(r))
2648
+ if (F(r))
2640
2649
  return {
2641
2650
  toolName: ae,
2642
2651
  status: "error",
@@ -2644,7 +2653,7 @@ const ae = "applyLayout", uo = i.object({
2644
2653
  error: new Error()
2645
2654
  };
2646
2655
  {
2647
- const { appliedLayout: a } = await co(e, r);
2656
+ const { appliedLayout: a } = await po(e, r);
2648
2657
  return {
2649
2658
  toolName: ae,
2650
2659
  status: "success",
@@ -2654,19 +2663,19 @@ const ae = "applyLayout", uo = i.object({
2654
2663
  }
2655
2664
  };
2656
2665
  }
2657
- }, ri = f(po, {
2666
+ }, oi = f(ho, {
2658
2667
  name: ae,
2659
2668
  description: "Apply a diagram layout to the link chart",
2660
- schema: uo
2669
+ schema: mo
2661
2670
  });
2662
- async function mo(e, t) {
2671
+ async function yo(e, t) {
2663
2672
  return t.map?.changeNonspatialDataDisplay(e), await J(t), { appliedNonspatialDataDisplayMode: e };
2664
2673
  }
2665
- const oe = "changeNonspatialVisibility", ho = i.object({
2674
+ const oe = "changeNonspatialVisibility", fo = i.object({
2666
2675
  setting: i.enum(["hidden", "visible"]).describe("The setting of nonspatial visibility")
2667
- }), yo = async ({ setting: e }, t) => {
2676
+ }), go = async ({ setting: e }, t) => {
2668
2677
  const { view: r } = Z(t);
2669
- if (N(r))
2678
+ if (F(r))
2670
2679
  return {
2671
2680
  toolName: oe,
2672
2681
  status: "error",
@@ -2674,7 +2683,7 @@ const oe = "changeNonspatialVisibility", ho = i.object({
2674
2683
  error: new Error()
2675
2684
  };
2676
2685
  {
2677
- const { appliedNonspatialDataDisplayMode: a } = await mo(e, r);
2686
+ const { appliedNonspatialDataDisplayMode: a } = await yo(e, r);
2678
2687
  return {
2679
2688
  toolName: oe,
2680
2689
  status: "success",
@@ -2684,14 +2693,14 @@ const oe = "changeNonspatialVisibility", ho = i.object({
2684
2693
  }
2685
2694
  };
2686
2695
  }
2687
- }, ai = f(yo, {
2696
+ }, ni = f(go, {
2688
2697
  name: oe,
2689
2698
  description: "Change whether or not nonspatial data is visible in the link chart. The value must be either 'hidden' or 'visible'.",
2690
- schema: ho
2699
+ schema: fo
2691
2700
  });
2692
- async function fo(e, t, r, a, o) {
2701
+ async function wo(e, t, r, a, o) {
2693
2702
  let n, l = "";
2694
- for (let s = 1; s <= q; s++) {
2703
+ for (let s = 1; s <= z; s++) {
2695
2704
  const { graphQuery: c, explanation: u } = await pe(
2696
2705
  e,
2697
2706
  t.dataModel,
@@ -2700,14 +2709,14 @@ async function fo(e, t, r, a, o) {
2700
2709
  n
2701
2710
  );
2702
2711
  try {
2703
- await S({ text: `Attempting to create link chart from derived query: ${c}` }, o);
2712
+ await x({ text: `Attempting to create link chart from derived query: ${c}` }, o);
2704
2713
  const d = await mt.fromCypherQuery(
2705
2714
  t,
2706
2715
  new xe({
2707
2716
  openCypherQuery: c
2708
2717
  })
2709
2718
  );
2710
- await S({ text: "Link chart created successfully, loading..." }, o), await d.load();
2719
+ await x({ text: "Link chart created successfully, loading..." }, o), await d.load();
2711
2720
  const p = a.map;
2712
2721
  return a.map = d, await a.when(), await Ae.whenOnce(() => !a.updating), d.entityCount === 0 && d.relationshipCount === 0 ? (a.map === d && (a.map = p), d.destroy(), {
2713
2722
  type: "error",
@@ -2722,7 +2731,7 @@ Explanation: ${u}`
2722
2731
  });
2723
2732
  } catch (d) {
2724
2733
  const p = A(d);
2725
- if (s >= q) {
2734
+ if (s >= z) {
2726
2735
  l = p;
2727
2736
  break;
2728
2737
  }
@@ -2730,7 +2739,7 @@ Explanation: ${u}`
2730
2739
  failedGraphQuery: c,
2731
2740
  executionError: p,
2732
2741
  attemptCount: s
2733
- }, await S(
2742
+ }, await x(
2734
2743
  { text: `Attempt ${s} to create link chart failed with error: ${p}. Retrying ...` },
2735
2744
  o
2736
2745
  );
@@ -2738,16 +2747,16 @@ Explanation: ${u}`
2738
2747
  }
2739
2748
  return {
2740
2749
  type: "error",
2741
- errorMessage: `Failed to create link chart after ${q} attempts. Last error: ${l}`
2750
+ errorMessage: `Failed to create link chart after ${z} attempts. Last error: ${l}`
2742
2751
  };
2743
2752
  }
2744
- const V = "createLinkChart", go = i.object({
2753
+ const V = "createLinkChart", bo = i.object({
2745
2754
  prompt: i.string().describe(
2746
2755
  "The user's inquiry into the knowledge graph that needs to be transformed into a link chart visualization."
2747
2756
  )
2748
- }), wo = async ({ prompt: e }, t) => {
2757
+ }), To = async ({ prompt: e }, t) => {
2749
2758
  const { knowledgeGraph: r } = await O(t), { view: a } = Z(t);
2750
- if (N(a))
2759
+ if (F(a))
2751
2760
  return {
2752
2761
  toolName: V,
2753
2762
  status: "error",
@@ -2755,7 +2764,7 @@ const V = "createLinkChart", go = i.object({
2755
2764
  error: new Error()
2756
2765
  };
2757
2766
  {
2758
- const n = k.getDefault().helperServices, l = await fo(
2767
+ const n = I.getDefault().helperServices, l = await wo(
2759
2768
  e,
2760
2769
  r,
2761
2770
  `${n.aiAssistantServices.url}${n.aiAssistantServices.graphQueryAssistant}`,
@@ -2783,11 +2792,11 @@ Explanation: ${c}`,
2783
2792
  }
2784
2793
  };
2785
2794
  }
2786
- }, oi = f(wo, {
2795
+ }, ii = f(To, {
2787
2796
  name: V,
2788
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.",
2789
- schema: go
2790
- }), ne = "queryGraphData", bo = i.object({
2798
+ schema: bo
2799
+ }), ne = "queryGraphData", vo = i.object({
2791
2800
  prompt: i.string().describe(
2792
2801
  `The user's inquiry into the knowledge graph, from which a cypher query will be generated and executed to answer the inquiry. IMPORTANT:
2793
2802
 
@@ -2795,13 +2804,13 @@ REQUEST LIMIT: If the user does not specifically request for no limits or an exp
2795
2804
 
2796
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.`
2797
2806
  )
2798
- }), To = async ({ prompt: e }, t) => {
2799
- const { knowledgeGraph: r } = await O(t), o = k.getDefault().helperServices, n = await Fe({
2807
+ }), So = async ({ prompt: e }, t) => {
2808
+ const { knowledgeGraph: r } = await O(t), o = I.getDefault().helperServices, n = await ke({
2800
2809
  prompt: e,
2801
2810
  kg: r,
2802
2811
  graphQueryServiceUrl: `${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,
2803
2812
  targetStructure: new Array(),
2804
- targetStructureReducer: (y, g) => (y.push(g), y),
2813
+ targetStructureReducer: (h, g) => (h.push(g), h),
2805
2814
  requestOptions: {
2806
2815
  signal: Y(t),
2807
2816
  timeout: t?.timeout
@@ -2809,22 +2818,22 @@ DESCRIPTIVE COLUMN NAMES: If the user's prompt does not explicitly request for s
2809
2818
  config: t
2810
2819
  });
2811
2820
  if (n.type !== "success") {
2812
- const y = n.type === "generation-error" ? n.errorMessage : `${n.errorMessage} Cypher query: ${n.graphQuery}`;
2821
+ const h = n.type === "generation-error" ? n.errorMessage : `${n.errorMessage} Cypher query: ${n.graphQuery}`;
2813
2822
  return {
2814
2823
  toolName: ne,
2815
2824
  status: "error",
2816
- errorMessage: `Failed to query the knowledge graph. ${y}`,
2825
+ errorMessage: `Failed to query the knowledge graph. ${h}`,
2817
2826
  error: "error" in n ? n.error : null
2818
2827
  };
2819
2828
  }
2820
2829
  const { graphQuery: l, explanation: s, processedResult: c, resultHeader: u } = n, d = u.headerKeys;
2821
- for (const y of c)
2822
- for (const g of y)
2830
+ for (const h of c)
2831
+ for (const g of h)
2823
2832
  D(
2824
2833
  g,
2825
- (h) => ke(h)
2834
+ (y) => Ie(y)
2826
2835
  );
2827
- const p = 50, m = c.slice(0, p).map((y) => JSON.stringify(y));
2836
+ const p = 50, m = c.slice(0, p).map((h) => JSON.stringify(h));
2828
2837
  return {
2829
2838
  toolName: ne,
2830
2839
  status: "success",
@@ -2853,16 +2862,16 @@ ${m.length > p ? `Showing top ${p} results:
2853
2862
  queryResults: c
2854
2863
  }
2855
2864
  };
2856
- }, ni = f(To, {
2865
+ }, si = f(So, {
2857
2866
  name: ne,
2858
2867
  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?'.",
2859
- schema: bo
2860
- }), ie = "generateCypher", vo = i.object({
2868
+ schema: vo
2869
+ }), ie = "generateCypher", xo = i.object({
2861
2870
  prompt: i.string().describe("The user's inquiry into the knowledge graph that needs to be translated into a cypher query.")
2862
- }), So = async ({ prompt: e }, t) => {
2863
- const { knowledgeGraph: r } = await O(t), o = k.getDefault().helperServices;
2871
+ }), Ro = async ({ prompt: e }, t) => {
2872
+ const { knowledgeGraph: r } = await O(t), o = I.getDefault().helperServices;
2864
2873
  try {
2865
- const { graphQuery: n, explanation: l } = await Za(
2874
+ const { graphQuery: n, explanation: l } = await Xa(
2866
2875
  e,
2867
2876
  r.dataModel,
2868
2877
  `${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,
@@ -2889,11 +2898,11 @@ Explanation: ${l}`,
2889
2898
  error: n
2890
2899
  };
2891
2900
  }
2892
- }, ii = f(So, {
2901
+ }, li = f(Ro, {
2893
2902
  name: ie,
2894
2903
  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.",
2895
- schema: vo
2896
- }), xo = (e) => {
2904
+ schema: xo
2905
+ }), $o = (e) => {
2897
2906
  const t = e.dataModel, r = /* @__PURE__ */ new Map();
2898
2907
  for (const s of t.searchIndexes)
2899
2908
  if (s.supportedCategory !== "esriTypeMetaEntityProvenance")
@@ -2910,10 +2919,10 @@ ${o.map(({ name: s }) => `${s}: [${Array.from(r.get(s) ?? []).join(", ")}]`).joi
2910
2919
 
2911
2920
  ${l}`;
2912
2921
  };
2913
- async function Ro(e, t) {
2922
+ async function Co(e, t) {
2914
2923
  const r = await te("arcgis_knowledge_lucene_generation_prompt"), a = {
2915
2924
  inquiry: e,
2916
- dataModelForSearch: xo(t)
2925
+ dataModelForSearch: $o(t)
2917
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(
2918
2927
  "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."
2919
2928
  ), l = i.array(
@@ -2934,16 +2943,16 @@ async function Ro(e, t) {
2934
2943
  schema: s
2935
2944
  });
2936
2945
  }
2937
- const se = "searchGraphData", $o = i.object({
2946
+ const se = "searchGraphData", Eo = i.object({
2938
2947
  prompt: i.string().describe(
2939
2948
  "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."
2940
2949
  )
2941
- }), Co = async ({ prompt: e }, t) => {
2950
+ }), Fo = async ({ prompt: e }, t) => {
2942
2951
  const { knowledgeGraph: r } = await O(t);
2943
- await S({ text: "Generating search query for the user inquiry" }, t);
2944
- const a = await Ro(e, r);
2945
- await S({ text: "Executing graph search with generated search query" }, t);
2946
- const o = await Xa({
2952
+ await x({ text: "Generating search query for the user inquiry" }, t);
2953
+ const a = await Co(e, r);
2954
+ await x({ text: "Executing graph search with generated search query" }, t);
2955
+ const o = await to({
2947
2956
  kg: r,
2948
2957
  searchQuery: a.query,
2949
2958
  typeCategoryFilter: a.typeCategoryFilter,
@@ -2964,7 +2973,7 @@ const se = "searchGraphData", $o = i.object({
2964
2973
  for (const s of o.results)
2965
2974
  D(
2966
2975
  s,
2967
- (c) => ke(c)
2976
+ (c) => Ie(c)
2968
2977
  );
2969
2978
  const n = 10, l = o.results.slice(0, n);
2970
2979
  return {
@@ -2987,56 +2996,56 @@ const se = "searchGraphData", $o = i.object({
2987
2996
  searchResults: o.results
2988
2997
  }
2989
2998
  };
2990
- }, si = f(Co, {
2999
+ }, ci = f(Fo, {
2991
3000
  name: se,
2992
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.",
2993
- schema: $o
3002
+ schema: Eo
2994
3003
  });
2995
3004
  export {
2996
- Pn as A,
2997
- Ln as B,
2998
- jn as C,
2999
- Gn as D,
3000
- On as E,
3001
- Mn as F,
3005
+ jn as A,
3006
+ Gn as B,
3007
+ On as C,
3008
+ Mn as D,
3009
+ Qn as E,
3010
+ _n as F,
3002
3011
  de as G,
3003
- Zn as H,
3004
- Qn as I,
3005
- _n as J,
3006
- Wn as K,
3007
- Vn as L,
3008
- Un as M,
3009
- Rn as N,
3010
- Bn as O,
3011
- Hn as P,
3012
- Ma as Q,
3013
- F as R,
3014
- Kn as S,
3015
- Jn as T,
3016
- ri as a,
3017
- ii as b,
3018
- ai as c,
3019
- oi as d,
3020
- ti as e,
3012
+ Xn as H,
3013
+ Wn as I,
3014
+ Vn as J,
3015
+ 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,
3021
3030
  Re as f,
3022
3031
  te as g,
3023
- ei as h,
3032
+ ri as h,
3024
3033
  O as i,
3025
- Xn as j,
3026
- $n as k,
3027
- Yn as l,
3028
- Cn as m,
3029
- En as n,
3030
- Nn as o,
3031
- In as p,
3032
- ni as q,
3033
- Dn as r,
3034
- si as s,
3034
+ ti as j,
3035
+ En as k,
3036
+ ei as l,
3037
+ Fn as m,
3038
+ Nn as n,
3039
+ In as o,
3040
+ kn as p,
3041
+ si as q,
3042
+ Pn as r,
3043
+ ci as s,
3035
3044
  Vt as t,
3036
- kn as u,
3037
- Fn as v,
3038
- zn as w,
3039
- qn as x,
3040
- $ as y,
3041
- An as z
3045
+ qn as u,
3046
+ zn as v,
3047
+ Dn as w,
3048
+ An as x,
3049
+ C as y,
3050
+ Ln as z
3042
3051
  };