@arcgis/portal-components 5.2.0-next.71 → 5.2.0-next.73

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,30 +1,30 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import { c as Ue } from "../../chunks/runtime.js";
3
- import { LitElement as Fe, createEvent as Oe } from "@arcgis/lumina";
4
- import { css as Ke, render as Ve, html as b } from "lit";
2
+ import { c as Rt } from "../../chunks/runtime.js";
3
+ import { LitElement as Ut, createEvent as Ft } from "@arcgis/lumina";
4
+ import { css as Ot, render as Lt, html as v } from "lit";
5
5
  import { createRef as P, ref as q } from "lit/directives/ref.js";
6
- import { u as je } from "../../chunks/useT9n.js";
7
- import { NodeInterrupt as fe, Annotation as h, StateGraph as G, START as A, END as w } from "@langchain/langgraph/web";
8
- import { sendTraceMessage as m, invokeStructuredPrompt as v, sendUXSuggestion as B, createAgentRuntimeStateWithSharedState as N, createChatModel as Q, getEmbeddings as Le } from "@arcgis/ai-components/utils/index.js";
6
+ import { u as jt } from "../../chunks/useT9n.js";
7
+ import { NodeInterrupt as ft, Annotation as h, StateGraph as A, START as N, END as w } from "@langchain/langgraph/web";
8
+ import { sendTraceMessage as m, invokeStructuredPrompt as b, sendUXSuggestion as Q, createAgentRuntimeStateWithSharedState as G, createChatModel as W, getEmbeddings as Vt } from "@arcgis/ai-components/utils/index.js";
9
9
  import s from "zod";
10
- import { a as Be, c as Qe, q as We } from "../../chunks/groups.js";
11
- import Je from "@arcgis/core/identity/IdentityManager.js";
12
- import Y from "@arcgis/core/request.js";
13
- import { a as R, t as _e, b as Ye } from "../../chunks/functionalities.js";
14
- import { ChatPromptTemplate as W } from "@langchain/core/prompts";
15
- import { tool as ye } from "@langchain/core/tools";
16
- import { s as He, a as Xe } from "../../chunks/item2.js";
17
- import { g as Ze, e as et, i as tt, c as at, a as nt } from "../../chunks/groups2.js";
18
- import rt from "@arcgis/core/portal/Portal.js";
19
- const we = (e) => {
20
- const { portal: t, user: a } = e ?? {};
21
- return !!e && !!t && !!a;
10
+ import { a as Bt, c as Kt, q as Qt } from "../../chunks/groups.js";
11
+ import Wt from "@arcgis/core/identity/IdentityManager.js";
12
+ import H from "@arcgis/core/request.js";
13
+ import { a as D, t as Jt, b as B } from "../../chunks/functionalities.js";
14
+ import { ChatPromptTemplate as J } from "@langchain/core/prompts";
15
+ import { tool as yt } from "@langchain/core/tools";
16
+ import { s as _t, a as Yt } from "../../chunks/item2.js";
17
+ import { g as Ht, e as Xt, i as Zt, c as te, a as ee } from "../../chunks/groups2.js";
18
+ import ae from "@arcgis/core/portal/Portal.js";
19
+ const wt = (t) => {
20
+ const { portal: e, user: a } = t ?? {};
21
+ return !!t && !!e && !!a;
22
22
  };
23
- function T(e) {
24
- if (!we(e))
23
+ function T(t) {
24
+ if (!wt(t))
25
25
  throw new Error("Invalid context: PortalAssistantContext with portal and user is required.");
26
26
  }
27
- const ot = `
27
+ const ne = `
28
28
  Write a concise, friendly success message for adding members to a group.
29
29
 
30
30
  Rules:
@@ -39,68 +39,68 @@ Added members:
39
39
 
40
40
  Not added members:
41
41
  {notAddedMembers}
42
- `, st = (e) => e.map((t) => `"${t}"`).join(", "), it = s.object({
42
+ `, oe = (t) => t.map((e) => `"${e}"`).join(", "), re = s.object({
43
43
  successMessage: s.string().default("")
44
- }), H = "portal-group-creation", X = "approveAddMembers", ut = async (e, t) => {
45
- if (e.intentParams.intent !== "addMembers")
44
+ }), X = "portal-group-creation", Z = "approveAddMembers", se = async (t, e) => {
45
+ if (t.intentParams.intent !== "addMembers")
46
46
  return {
47
47
  status: "success",
48
48
  outputMessage: "Use @mention usernames for the members you want to add."
49
49
  };
50
- const a = e.agentExecutionContext.sharedState.createdGroupId?.value;
50
+ const a = t.agentExecutionContext.sharedState.createdGroupId?.value;
51
51
  if (!a)
52
52
  return {
53
53
  status: "success",
54
54
  outputMessage: "Create a group first, then add members using @mention usernames."
55
55
  };
56
- const n = e.intentParams.memberInfo.memberIdentifiers.map((p) => p.trim()).filter(Boolean);
56
+ const n = t.intentParams.memberInfo.memberIdentifiers.map((p) => p.trim()).filter(Boolean);
57
57
  if (!n.length)
58
58
  return {
59
59
  status: "success",
60
60
  outputMessage: "Use @mention usernames for the members you want to add."
61
61
  };
62
- const o = `The following member(s) will be added to the newly created group:
62
+ const r = `The following member(s) will be added to the newly created group:
63
63
 
64
64
  ${n.map((p) => `- **@${p}**`).join(`
65
65
  `)}
66
66
 
67
- Do you want to continue?`, { hitlResponse: u } = t?.configurable ?? {};
68
- if (u?.agentId !== H || u.id !== X) {
67
+ Do you want to continue?`, { hitlResponse: c } = e?.configurable ?? {};
68
+ if (c?.agentId !== X || c.id !== Z) {
69
69
  const p = {
70
- agentId: H,
71
- id: X,
70
+ agentId: X,
71
+ id: Z,
72
72
  kind: "booleanChoice",
73
- message: o,
73
+ message: r,
74
74
  metadata: {
75
75
  action: "addMembers",
76
76
  groupId: a,
77
77
  members: [...n]
78
78
  }
79
79
  };
80
- throw new fe(p);
80
+ throw new ft(p);
81
81
  }
82
- if (u.payload !== !0)
82
+ if (c.payload !== !0)
83
83
  return {
84
84
  status: "success",
85
85
  outputMessage: "Okay, I cancelled adding members to the group."
86
86
  };
87
87
  await m(
88
- { text: `Adding members ${st(n)}...`, agentName: "group-creation" },
89
- t
88
+ { text: `Adding members ${oe(n)}...`, agentName: "group-creation" },
89
+ e
90
90
  );
91
- const i = t?.configurable?.context;
91
+ const i = e?.configurable?.context;
92
92
  T(i);
93
- const { result: l, error: c } = await Be(i.portal, a, n);
94
- if (c || !l)
93
+ const { result: l, error: u } = await Bt(i.portal, a, n);
94
+ if (u || !l)
95
95
  return {
96
96
  status: "success",
97
97
  outputMessage: "I could not add members to that group. Please confirm group access and user accounts, then try again."
98
98
  };
99
99
  const { addedUsernames: d, notAddedUsers: g } = l;
100
100
  try {
101
- const f = (await v({
102
- promptText: ot,
103
- schema: it,
101
+ const f = (await b({
102
+ promptText: ne,
103
+ schema: re,
104
104
  modelTier: "fast",
105
105
  inputVariables: {
106
106
  addedMembers: d.join(", "),
@@ -115,7 +115,7 @@ Do you want to continue?`, { hitlResponse: u } = t?.configurable ?? {};
115
115
  console.error("Error generating add-members success message:", p);
116
116
  }
117
117
  return {};
118
- }, ct = `
118
+ }, ie = `
119
119
  Write a concise, friendly success message after creating a portal group.
120
120
 
121
121
  Rules:
@@ -126,7 +126,7 @@ Rules:
126
126
 
127
127
  Group title:
128
128
  {groupTitle}
129
- `, lt = `
129
+ `, ce = `
130
130
  Write a concise, friendly failure message after an attempt to create a portal group.
131
131
 
132
132
  Rules:
@@ -141,27 +141,27 @@ Group title:
141
141
 
142
142
  Failure reason:
143
143
  {failureReason}
144
- `, Z = "portal-group-creation", ee = "approveCreateGroup", dt = s.object({
144
+ `, tt = "portal-group-creation", et = "approveCreateGroup", ue = s.object({
145
145
  successMessage: s.string().default("")
146
- }), pt = s.object({
146
+ }), le = s.object({
147
147
  failureMessage: s.string().default("")
148
- }), mt = async (e, t) => {
149
- if (e.intentParams.intent !== "create")
148
+ }), de = async (t, e) => {
149
+ if (t.intentParams.intent !== "create")
150
150
  return {
151
151
  status: "success",
152
152
  outputMessage: "Tell me the group title you want to use."
153
153
  };
154
- const a = e.intentParams.title.trim();
154
+ const a = t.intentParams.title.trim();
155
155
  if (!a)
156
156
  return {
157
157
  status: "success",
158
158
  outputMessage: "What title would you like for the new group?"
159
159
  };
160
- const n = `A group with the title **${a}** will be created. Do you want to continue?`, { hitlResponse: r } = t?.configurable;
161
- if (r?.agentId !== Z || r.id !== ee) {
162
- const c = {
163
- agentId: Z,
164
- id: ee,
160
+ const n = `A group with the title **${a}** will be created. Do you want to continue?`, { hitlResponse: o } = e?.configurable;
161
+ if (o?.agentId !== tt || o.id !== et) {
162
+ const u = {
163
+ agentId: tt,
164
+ id: et,
165
165
  kind: "booleanChoice",
166
166
  message: n,
167
167
  metadata: {
@@ -170,30 +170,30 @@ Failure reason:
170
170
  access: "private"
171
171
  }
172
172
  };
173
- throw new fe(c);
173
+ throw new ft(u);
174
174
  }
175
- if (r.payload !== !0)
175
+ if (o.payload !== !0)
176
176
  return {
177
177
  status: "success",
178
178
  outputMessage: `Okay, I cancelled creating **${a}**.`
179
179
  };
180
- await m({ text: `Creating group "${a}"...`, agentName: "group-creation" }, t);
181
- const o = t?.configurable?.context;
182
- T(o);
183
- const { result: u, error: i } = await Qe(o.portal, {
180
+ await m({ text: `Creating group "${a}"...`, agentName: "group-creation" }, e);
181
+ const r = e?.configurable?.context;
182
+ T(r);
183
+ const { result: c, error: i } = await Kt(r.portal, {
184
184
  title: a,
185
185
  access: "private"
186
186
  });
187
- if (i || !u) {
188
- const c = i?.message?.trim() || "No additional details were provided.";
187
+ if (i || !c) {
188
+ const u = i?.message?.trim() || "No additional details were provided.";
189
189
  try {
190
- const g = (await v({
191
- promptText: lt,
192
- schema: pt,
190
+ const g = (await b({
191
+ promptText: ce,
192
+ schema: le,
193
193
  modelTier: "fast",
194
194
  inputVariables: {
195
195
  groupTitle: a,
196
- failureReason: c
196
+ failureReason: u
197
197
  }
198
198
  })).failureMessage.trim();
199
199
  if (g)
@@ -209,11 +209,11 @@ Failure reason:
209
209
  outputMessage: "I could not create that group. Please confirm your permissions and try again with the group title."
210
210
  };
211
211
  }
212
- const l = u.id;
212
+ const l = c.id;
213
213
  try {
214
- const d = (await v({
215
- promptText: ct,
216
- schema: dt,
214
+ const d = (await b({
215
+ promptText: ie,
216
+ schema: ue,
217
217
  modelTier: "fast",
218
218
  inputVariables: {
219
219
  groupTitle: a
@@ -226,13 +226,13 @@ Failure reason:
226
226
  sharedStatePatch: { createdGroupId: { value: l } },
227
227
  createdGroupId: l
228
228
  };
229
- } catch (c) {
230
- console.error("Error generating create-group success message:", c);
229
+ } catch (u) {
230
+ console.error("Error generating create-group success message:", u);
231
231
  }
232
232
  return {};
233
- }, I = (e) => {
234
- for (let t = e.length - 1; t >= 0; t -= 1) {
235
- const a = e[t];
233
+ }, I = (t) => {
234
+ for (let e = t.length - 1; e >= 0; e -= 1) {
235
+ const a = t[e];
236
236
  if (a.type !== "human")
237
237
  continue;
238
238
  const n = a.content;
@@ -240,11 +240,11 @@ Failure reason:
240
240
  return n;
241
241
  if (Array.isArray(n))
242
242
  return n.map(
243
- (r) => typeof r == "string" ? r : "text" in r && typeof r.text == "string" ? r.text : ""
243
+ (o) => typeof o == "string" ? o : "text" in o && typeof o.text == "string" ? o.text : ""
244
244
  ).join(" ").trim();
245
245
  }
246
246
  return "";
247
- }, gt = `
247
+ }, pe = `
248
248
  You classify whether a user is asking to create a new ArcGIS Portal group or add members to an existing group.
249
249
 
250
250
  Rules:
@@ -270,77 +270,96 @@ Examples:
270
270
 
271
271
  User message:
272
272
  {userMessage}
273
- `, ht = s.object({
273
+ `, me = s.object({
274
274
  intent: s.enum(["clarify", "create", "addMembers"]).default("clarify"),
275
275
  title: s.string().default(""),
276
276
  memberIdentifiers: s.array(s.string()).default([]),
277
277
  clarifyMessage: s.string().default("")
278
- }), ft = async (e, t) => {
279
- await m({ text: "Thinking about groups...", agentName: "group-creation" }, t);
280
- const a = I(e.agentExecutionContext.messages).trim(), n = await v({
281
- promptText: gt,
282
- schema: ht,
278
+ }), ge = async (t, e) => {
279
+ await m({ text: "Thinking about groups...", agentName: "group-creation" }, e);
280
+ const a = I(t.agentExecutionContext.messages).trim(), n = await b({
281
+ promptText: pe,
282
+ schema: me,
283
283
  modelTier: "default",
284
284
  inputVariables: { userMessage: a }
285
- }), r = n.title.trim(), o = n.memberIdentifiers.filter(Boolean), u = n.clarifyMessage.trim(), i = n.intent === "create" && !!r, l = n.intent === "addMembers" && o.length > 0;
285
+ }), o = n.title.trim(), r = n.memberIdentifiers.filter(Boolean), c = n.clarifyMessage.trim(), i = n.intent === "create" && !!o, l = n.intent === "addMembers" && r.length > 0;
286
286
  return {
287
- intentParams: i ? { intent: "create", title: r } : l ? { intent: "addMembers", memberInfo: { memberIdentifiers: o } } : { intent: "clarify" },
287
+ intentParams: i ? { intent: "create", title: o } : l ? { intent: "addMembers", memberInfo: { memberIdentifiers: r } } : { intent: "clarify" },
288
288
  status: "success",
289
- outputMessage: !i && !l ? u : ""
289
+ outputMessage: !i && !l ? c : ""
290
290
  };
291
- }, yt = ["favorites", "group", "living-atlas", "org"], wt = ["featured", "my", "organization"], bt = ["licenses", "members", "overview", "reports", "settings", "status"], vt = s.object({
291
+ }, he = [
292
+ "customSignInSection",
293
+ "loginsSection",
294
+ "changeLoginProviderSection",
295
+ "multiFactorAuthSection",
296
+ "multifactorEnforcementSection",
297
+ "multifactorDesignatedAdminsSection"
298
+ ], fe = ["customSignInCard", "loginCard", "multifactorAuthCard"], ye = ["newItem", "createLayer", "developerCredentials"], we = {
299
+ customSignInSection: "customSignInCard",
300
+ loginsSection: "loginCard",
301
+ changeLoginProviderSection: "loginCard",
302
+ multiFactorAuthSection: "multifactorAuthCard",
303
+ multifactorEnforcementSection: "multifactorAuthCard",
304
+ multifactorDesignatedAdminsSection: "multifactorAuthCard"
305
+ }, ve = ["favorites", "group", "living-atlas", "org"], be = ["featured", "my", "organization"], Ie = ["licenses", "members", "overview", "reports", "settings", "status"], Se = s.object({
292
306
  destinationType: s.literal("portal-content"),
293
- hash: s.enum(yt).optional(),
294
- t9nKey: s.string().min(1).optional()
295
- }), It = s.object({
307
+ hash: s.enum(ve).optional(),
308
+ queryParams: s.object({
309
+ newItem: s.enum(ye).optional()
310
+ }).optional()
311
+ }), xe = s.object({
296
312
  destinationType: s.literal("portal-groups"),
297
- hash: s.enum(wt).optional(),
298
- t9nKey: s.string().min(1).optional()
299
- }), xt = s.object({
313
+ hash: s.enum(be).optional()
314
+ }), Te = s.object({
300
315
  destinationType: s.literal("portal-org"),
301
- hash: s.enum(bt).optional(),
302
- t9nKey: s.string().min(1).optional()
303
- }), St = s.object({
316
+ hash: s.enum(Ie).optional(),
317
+ queryParams: s.object({
318
+ tab: s.literal("security").optional(),
319
+ section: s.enum(fe).optional(),
320
+ subsection: s.enum(he).optional(),
321
+ period: s.string().optional(),
322
+ startTime: s.string().optional(),
323
+ endTime: s.string().optional()
324
+ }).optional()
325
+ }), Ce = s.object({
304
326
  destinationType: s.literal("portal-item"),
305
- itemId: s.string().trim().min(1),
306
- t9nKey: s.string().min(1).optional()
307
- }), Tt = s.object({
327
+ itemId: s.string().trim().min(1)
328
+ }), Me = s.object({
308
329
  destinationType: s.literal("portal-group"),
309
- groupId: s.string().trim().min(1),
310
- t9nKey: s.string().min(1).optional()
311
- }), Mt = s.object({
330
+ groupId: s.string().trim().min(1)
331
+ }), Ae = s.object({
312
332
  destinationType: s.union([
313
333
  s.literal("portal-gallery"),
314
334
  s.literal("portal-map-viewer"),
315
335
  s.literal("portal-notebooks"),
316
336
  s.literal("portal-scene-viewer")
317
- ]),
318
- t9nKey: s.string().min(1).optional()
319
- }), Ct = s.union([
320
- vt,
321
- It,
322
- xt,
323
- St,
324
- Tt,
325
- Mt
326
- ]), be = "portal-navigation", D = async (e, t) => {
327
- const a = t?.configurable?.context;
328
- !we(a) || !a.navigationTargetMap?.[e.destinationType] || await B({ type: be, data: { ...e } }, t);
329
- }, Gt = async (e, t) => {
330
- const a = e.createdGroupId ?? e.agentExecutionContext.sharedState.createdGroupId?.value;
331
- return a ? (await m({ text: "Preparing navigation...", agentName: "group-creation" }, t), await D({ destinationType: "portal-group", groupId: a }, t), {}) : {};
332
- }, te = (e, t) => t ?? e, ve = h.Root({
333
- ...N(),
337
+ ])
338
+ }), Ne = s.union([
339
+ Se,
340
+ xe,
341
+ Te,
342
+ Ce,
343
+ Me,
344
+ Ae
345
+ ]), vt = "portal-navigation", R = async (t, e) => {
346
+ const a = e?.configurable?.context;
347
+ !wt(a) || !a.navigationTargetMap?.[t.destinationType] || await Q({ type: vt, data: { ...t } }, e);
348
+ }, Ge = async (t, e) => {
349
+ const a = t.createdGroupId ?? t.agentExecutionContext.sharedState.createdGroupId?.value;
350
+ return a ? (await m({ text: "Preparing navigation...", agentName: "group-creation" }, e), await R({ destinationType: "portal-group", groupId: a }, e), {}) : {};
351
+ }, at = (t, e) => e ?? t, bt = h.Root({
352
+ ...G(),
334
353
  // * Shared state between nodes (but not persisted to the agent execution context)
335
354
  /** Parameters related to the user's intent for group creation actions */
336
- intentParams: h({ reducer: te, default: () => ({ intent: "clarify" }) }),
355
+ intentParams: h({ reducer: at, default: () => ({ intent: "clarify" }) }),
337
356
  /** The ID of the group that was created
338
357
  * even though we already have this in the shared state
339
358
  * we still need it here to also share between nodes
340
359
  */
341
- createdGroupId: h({ reducer: te, default: () => "" })
342
- }), At = () => new G(ve).addNode("detectGroupCreationIntent", ft).addNode("createPortalGroup", mt).addNode("addMembersToPortalGroup", ut).addNode("suggestCreatedGroupNavigation", Gt).addEdge(A, "detectGroupCreationIntent").addConditionalEdges("detectGroupCreationIntent", (t) => {
343
- switch (t.intentParams.intent) {
360
+ createdGroupId: h({ reducer: at, default: () => "" })
361
+ }), Pe = () => new A(bt).addNode("detectGroupCreationIntent", ge).addNode("createPortalGroup", de).addNode("addMembersToPortalGroup", se).addNode("suggestCreatedGroupNavigation", Ge).addEdge(N, "detectGroupCreationIntent").addConditionalEdges("detectGroupCreationIntent", (e) => {
362
+ switch (e.intentParams.intent) {
344
363
  case "create":
345
364
  return "createPortalGroup";
346
365
  case "addMembers":
@@ -348,154 +367,154 @@ User message:
348
367
  default:
349
368
  return w;
350
369
  }
351
- }).addEdge("createPortalGroup", "suggestCreatedGroupNavigation").addEdge("addMembersToPortalGroup", "suggestCreatedGroupNavigation").addEdge("suggestCreatedGroupNavigation", w), Nt = String.raw`- **portal-group-creation** - Portal group creation assistant:
370
+ }).addEdge("createPortalGroup", "suggestCreatedGroupNavigation").addEdge("addMembersToPortalGroup", "suggestCreatedGroupNavigation").addEdge("suggestCreatedGroupNavigation", w), qe = String.raw`- **portal-group-creation** - Portal group creation assistant:
352
371
  - creates a new ArcGIS Portal group for the signed-in user
353
372
  - adds users to the newly created group using @mention usernames
354
- `, Pt = {
373
+ `, Ee = {
355
374
  id: "portal-group-creation",
356
375
  name: "Portal Group Creation",
357
- description: Nt,
358
- createGraph: At,
359
- workspace: ve
360
- }, Ie = "portalDocAssistantMemory", qt = () => ({ conversationId: "" }), Et = (e) => {
361
- const t = e?.[Ie]?.value;
362
- if (!t || typeof t != "object")
363
- return qt();
364
- const a = t;
376
+ description: qe,
377
+ createGraph: Pe,
378
+ workspace: bt
379
+ }, It = "portalDocAssistantMemory", ze = () => ({ conversationId: "" }), ke = (t) => {
380
+ const e = t?.[It]?.value;
381
+ if (!e || typeof e != "object")
382
+ return ze();
383
+ const a = e;
365
384
  return {
366
385
  conversationId: typeof a.conversationId == "string" ? a.conversationId : ""
367
386
  };
368
- }, kt = (e) => ({
369
- [Ie]: { value: e }
370
- }), zt = {
387
+ }, $e = (t) => ({
388
+ [It]: { value: t }
389
+ }), De = {
371
390
  pipeline: {
372
391
  follow_up: { allow: !1 }
373
392
  }
374
393
  };
375
- function $t(e) {
394
+ function Re(t) {
376
395
  return {
377
396
  kind: "DocAIAssistantRequest",
378
397
  filters: {
379
- ...zt,
380
- persona: { persona: e }
398
+ ...De,
399
+ persona: { persona: t }
381
400
  }
382
401
  };
383
402
  }
384
- async function Rt({
385
- portal: e,
386
- question: t,
403
+ async function Ue({
404
+ portal: t,
405
+ question: e,
387
406
  persona: a,
388
407
  previousConversationId: n,
389
- signal: r,
390
- skillId: o
408
+ signal: o,
409
+ skillId: r
391
410
  }) {
392
- o ??= "doc_ai_assistant";
393
- const u = $t(a), i = await Dt({
394
- portal: e,
395
- skillId: o,
396
- message: t,
397
- options: { context: u, previousConversationId: n, signal: r }
411
+ r ??= "doc_ai_assistant";
412
+ const c = Re(a), i = await Fe({
413
+ portal: t,
414
+ skillId: r,
415
+ message: e,
416
+ options: { context: c, previousConversationId: n, signal: o }
398
417
  });
399
418
  return {
400
- reply: Ut(i, o),
419
+ reply: Oe(i, r),
401
420
  conversationId: i[0]?.conversationId ?? ""
402
421
  };
403
422
  }
404
- async function Dt({
405
- portal: e,
406
- skillId: t,
423
+ async function Fe({
424
+ portal: t,
425
+ skillId: e,
407
426
  message: a,
408
427
  options: n
409
428
  }) {
410
- const o = `${e.helperServices.aiAssistantServices.url}/skills/${t}/chat`, u = {
429
+ const r = `${t.helperServices.aiAssistantServices.url}/skills/${e}/chat`, c = {
411
430
  "Content-Type": "application/json",
412
- token: Je.findCredential(e.url)?.token ?? ""
413
- }, i = await Y(o, {
431
+ token: Wt.findCredential(t.url)?.token ?? ""
432
+ }, i = await H(r, {
414
433
  method: "post",
415
434
  body: JSON.stringify({
416
435
  message: a,
417
436
  context: n.context,
418
437
  conversationId: n.previousConversationId
419
438
  }),
420
- headers: u,
439
+ headers: c,
421
440
  signal: n.signal
422
441
  });
423
442
  if (i.httpStatus !== 200)
424
443
  throw new Error(`Doc assistant chat failed (${i.httpStatus})`, {
425
444
  cause: i.data
426
445
  });
427
- const l = i.data, c = [l], { conversationId: d, inquiryId: g } = l, p = async (f, y) => {
446
+ const l = i.data, u = [l], { conversationId: d, inquiryId: g } = l, p = async (f, y) => {
428
447
  if (!y)
429
448
  return;
430
- await _e(500);
431
- const x = await Y(o, {
449
+ await Jt(500);
450
+ const S = await H(r, {
432
451
  method: "post",
433
452
  body: JSON.stringify({ conversationId: d, inquiryId: g, ackSequenceNumber: f }),
434
- headers: u,
453
+ headers: c,
435
454
  signal: n.signal
436
455
  });
437
- if (x.httpStatus !== 200)
438
- throw new Error(`Doc assistant poll failed (${x.httpStatus})`, {
439
- cause: x.data
456
+ if (S.httpStatus !== 200)
457
+ throw new Error(`Doc assistant poll failed (${S.httpStatus})`, {
458
+ cause: S.data
440
459
  });
441
- const M = x.data;
442
- c.push(M), await p(M.sequenceNumber, M.hasMore);
460
+ const C = S.data;
461
+ u.push(C), await p(C.sequenceNumber, C.hasMore);
443
462
  };
444
- return l.hasMore && await p(l.sequenceNumber, l.hasMore), c;
463
+ return l.hasMore && await p(l.sequenceNumber, l.hasMore), u;
445
464
  }
446
- function Ut(e, t) {
447
- switch (t) {
465
+ function Oe(t, e) {
466
+ switch (e) {
448
467
  case "doc_chat":
449
- return e.find((a) => a.message != null)?.message ?? "";
468
+ return t.find((a) => a.message != null)?.message ?? "";
450
469
  case "doc_ai_assistant":
451
- for (let a = e.length - 1; a >= 0; a -= 1) {
452
- const n = e[a];
470
+ for (let a = t.length - 1; a >= 0; a -= 1) {
471
+ const n = t[a];
453
472
  if (n.context?.kind === "DocAIAssistantContext") {
454
- const r = n.context.results?.[0]?.reply;
455
- if (r)
456
- return r;
473
+ const o = n.context.results?.[0]?.reply;
474
+ if (o)
475
+ return o;
457
476
  }
458
477
  }
459
478
  return "";
460
479
  default:
461
- return R(t);
480
+ return D(e);
462
481
  }
463
482
  }
464
- const Ft = async (e, t) => {
465
- await m({ text: "Asking documentation assistant...", agentName: "doc-assistant" }, t);
466
- const a = I(e.agentExecutionContext.messages).trim();
483
+ const Le = async (t, e) => {
484
+ await m({ text: "Asking documentation assistant...", agentName: "doc-assistant" }, e);
485
+ const a = I(t.agentExecutionContext.messages).trim();
467
486
  if (!a)
468
487
  return {
469
488
  status: "success",
470
489
  outputMessage: "Please share your question and I can help with ArcGIS and Portal documentation."
471
490
  };
472
- const n = t?.configurable?.context;
491
+ const n = e?.configurable?.context;
473
492
  T(n);
474
- const r = Et(e.agentExecutionContext.sharedState), { reply: o, conversationId: u } = await Rt({
493
+ const o = ke(t.agentExecutionContext.sharedState), { reply: r, conversationId: c } = await Ue({
475
494
  portal: n.portal,
476
495
  question: a,
477
- previousConversationId: r.conversationId || void 0,
496
+ previousConversationId: o.conversationId || void 0,
478
497
  skillId: "doc_ai_assistant",
479
498
  persona: "doc-online"
480
499
  });
481
500
  return {
482
501
  status: "success",
483
- outputMessage: o.trim() || "I could not retrieve a response from the documentation assistant.",
484
- sharedStatePatch: kt({
485
- conversationId: u || r.conversationId
502
+ outputMessage: r.trim() || "I could not retrieve a response from the documentation assistant.",
503
+ sharedStatePatch: $e({
504
+ conversationId: c || o.conversationId
486
505
  })
487
506
  };
488
- }, xe = ye(
489
- async ({ groupTitle: e }, t) => {
490
- const a = e.trim();
507
+ }, St = yt(
508
+ async ({ groupTitle: t }, e) => {
509
+ const a = t.trim();
491
510
  if (!a)
492
511
  return null;
493
- const n = t?.configurable?.context;
512
+ const n = e?.configurable?.context;
494
513
  T(n);
495
514
  try {
496
- return (await We(n.portal, { query: `title:${a}`, num: 1 }))?.results[0]?.id || null;
497
- } catch (r) {
498
- return console.error("Error searching for portal group by title:", r), null;
515
+ return (await Qt(n.portal, { query: `title:${a}`, num: 1 }))?.results[0]?.id || null;
516
+ } catch (o) {
517
+ return console.error("Error searching for portal group by title:", o), null;
499
518
  }
500
519
  },
501
520
  {
@@ -505,15 +524,15 @@ const Ft = async (e, t) => {
505
524
  groupTitle: s.string().describe("The portal group title to resolve to a group id.")
506
525
  })
507
526
  }
508
- ), Se = ye(
509
- async ({ itemTitle: e }, t) => {
510
- const a = e.trim();
527
+ ), xt = yt(
528
+ async ({ itemTitle: t }, e) => {
529
+ const a = t.trim();
511
530
  if (!a)
512
531
  return null;
513
- const n = t?.configurable?.context;
532
+ const n = e?.configurable?.context;
514
533
  T(n);
515
- const { result: r, error: o } = await He(n.portal, a, { num: 1 });
516
- return o && console.error("Error searching for portal item by title:", o), r?.results[0]?.id || null;
534
+ const { result: o, error: r } = await _t(n.portal, a, { num: 1 });
535
+ return r && console.error("Error searching for portal item by title:", r), o?.results[0]?.id || null;
517
536
  },
518
537
  {
519
538
  name: "resolvePortalItemIdByTitle",
@@ -523,86 +542,174 @@ const Ft = async (e, t) => {
523
542
  })
524
543
  }
525
544
  );
526
- function C(e, t = "#") {
527
- const a = e.match(new RegExp(`\\${t}"([^"]+)"`, "u"));
545
+ function M(t, e = "#") {
546
+ const a = t.match(new RegExp(`\\${e}"([^"]+)"`, "u"));
528
547
  if (a?.[1])
529
548
  return a[1].trim();
530
- const n = e.match(new RegExp(`\\${t}([^\\s"']+)`, "u"));
549
+ const n = t.match(new RegExp(`\\${e}([^\\s"']+)`, "u"));
531
550
  return n?.[1] ? n[1].trim() : null;
532
551
  }
533
- const Te = {
552
+ function je(t) {
553
+ const e = B(t).flatMap((a) => {
554
+ const n = a, o = t[a], r = [
555
+ n,
556
+ {
557
+ description: o.description,
558
+ hints: o.hints
559
+ }
560
+ ], c = o.sections ? B(o.sections).map((i) => {
561
+ const l = o.sections?.[i];
562
+ return [`${n}-${i}`, l];
563
+ }) : [];
564
+ return [r, ...c];
565
+ });
566
+ return Object.fromEntries(e);
567
+ }
568
+ function Ve(t) {
569
+ return Object.entries(t).map(([e, { description: a, hints: n }]) => ` - ${e}: ${a} (hints: ${n.join(", ")})`).join(`
570
+ `);
571
+ }
572
+ const Be = {
573
+ // Example prompt: "Take me to my content"
534
574
  "portal-content": {
535
575
  description: "The main content page of the portal.",
536
576
  hints: ["My content", "Content"]
537
577
  },
578
+ // Example prompt: "Show my content favorites"
538
579
  "portal-content-favorites": {
539
580
  description: "The Favorites view under Content in the portal.",
540
581
  hints: ["My favorites", "Favorites", "Content favorites"]
541
582
  },
583
+ // Example prompt: "Open group content"
542
584
  "portal-content-group": {
543
585
  description: "The Groups view under Content in the portal.",
544
586
  hints: ["Content groups", "Group content", "My groups content"]
545
587
  },
588
+ // Example prompt: "Browse Living Atlas content"
546
589
  "portal-content-living-atlas": {
547
590
  description: "The Living Atlas view under Content in the portal.",
548
591
  hints: ["Living Atlas", "Content living atlas"]
549
592
  },
593
+ // Example prompt: "Show my organization's content"
550
594
  "portal-content-organization": {
551
595
  description: "The Organization view under Content in the portal.",
552
596
  hints: ["Organization content", "Content organization", "My organization content"]
553
597
  },
598
+ // Example prompt: "Open the gallery"
554
599
  "portal-gallery": {
555
600
  description: "The gallery page of the portal.",
556
601
  hints: ["Gallery", "Featured content", "Maps and apps"]
557
602
  },
603
+ // Example prompt: "Go to the group called #Urban Planning"
558
604
  "portal-group": {
559
605
  description: "A specific group page in the portal.",
560
606
  hints: ["Group", "group page"]
561
607
  },
608
+ // Example prompt: "Browse groups"
562
609
  "portal-groups": {
563
610
  description: "The groups listing page of the portal.",
564
611
  hints: ["Groups", "Browse groups"]
565
612
  },
613
+ // Example prompt: "Show featured groups"
566
614
  "portal-groups-featured": {
567
615
  description: "The Featured groups view under Groups in the portal.",
568
616
  hints: ["Featured groups", "Groups featured"]
569
617
  },
618
+ // Example prompt: "Show my groups"
570
619
  "portal-groups-my": {
571
620
  description: "The My groups view under Groups in the portal.",
572
621
  hints: ["My groups", "Groups my"]
573
622
  },
623
+ // Example prompt: "Show organization groups"
574
624
  "portal-groups-organization": {
575
625
  description: "The Organization groups view under Groups in the portal.",
576
626
  hints: ["Organization groups", "Groups organization", "My organization groups"]
577
627
  },
628
+ // Example prompt: "Open item #Road Closures Map"
578
629
  "portal-item": {
579
630
  description: "A specific item page in the portal.",
580
631
  hints: ["Item", "item page"]
581
632
  },
633
+ // Example prompt: "Open Map Viewer"
582
634
  "portal-map-viewer": {
583
635
  description: "The Map Viewer app of the portal.",
584
636
  hints: ["Map Viewer", "Map", "Open map"]
585
637
  },
638
+ // Example prompt: "Take me to notebooks"
586
639
  "portal-notebooks": {
587
640
  description: "The Notebooks home page of the portal.",
588
641
  hints: ["Notebooks", "Notebook home", "My notebooks"]
589
642
  },
643
+ // Example prompt: "Open Scene Viewer"
590
644
  "portal-scene-viewer": {
591
645
  description: "The Scene Viewer app of the portal.",
592
646
  hints: ["Scene Viewer", "Scene", "3D scene"]
593
647
  },
648
+ // Example prompt: "Open organization security settings"
594
649
  "portal-org-security": {
595
650
  description: "The Organization > Settings > Security page of the portal.",
596
- hints: ["Organization settings", "Security", "Organization > Settings > Security"]
651
+ hints: ["Organization settings", "Security", "Organization > Settings > Security"],
652
+ sections: {
653
+ // Example prompt: "How do I set up custom sign in?"
654
+ "custom-sign-in": {
655
+ description: "The Organization > Settings > Security > Custom Sign In section of the portal.",
656
+ hints: ["Custom Sign In", "Organization > Settings > Security > Custom Sign In"]
657
+ },
658
+ // Example prompt: "How do I configure login options?"
659
+ logins: {
660
+ description: "The Organization > Settings > Security > Logins section of the portal.",
661
+ hints: ["Logins", "Organization > Settings > Security > Logins"]
662
+ },
663
+ // Example prompt: "How do I change our login provider?"
664
+ "change-login-provider": {
665
+ description: "The Organization > Settings > Security > Change Login Provider section of the portal.",
666
+ hints: ["Change Login Provider", "Organization > Settings > Security > Change Login Provider"]
667
+ },
668
+ // Example prompt: "How do I configure MFA?"
669
+ "multifactor-auth": {
670
+ description: "The Organization > Settings > Security > Multifactor Authentication section of the portal.",
671
+ hints: ["MFA", "Multifactor Authentication", "Organization > Settings > Security > MFA"]
672
+ },
673
+ // Example prompt: "How do I configure Enforce MFA?"
674
+ "multifactor-enforcement": {
675
+ description: "The Organization > Settings > Security > Enforce MFA section of the portal.",
676
+ hints: ["Enforce MFA", "MFA enforcement", "Organization > Settings > Security > Enforce MFA"]
677
+ },
678
+ // Example prompt: "How do I set designated admins for MFA?"
679
+ "multifactor-designated-admins": {
680
+ description: "The Organization > Settings > Security > Designated Admins section of the portal.",
681
+ hints: ["Designated admins", "MFA designated admins", "Organization > Settings > Security > Designated Admins"]
682
+ }
683
+ }
684
+ },
685
+ // Example prompt: "I want to add a new item"
686
+ "portal-content-new-item": {
687
+ description: "The Content page with the New Item flow opened.",
688
+ hints: ["New item", "Create new item", "Content > My Content > New Item"],
689
+ sections: {
690
+ // Example prompt: "Create a new feature layer"
691
+ "feature-layer": {
692
+ description: "The Content page with New Item flow set to Feature Layer as the starting step.",
693
+ hints: ["Feature Layer", "New Feature Layer", "Content > My Content > New Item > Feature Layer"]
694
+ },
695
+ // Example prompt: "Create developer credentials"
696
+ "developer-credentials": {
697
+ description: "The Content page with New Item flow set to Developer Credentials as the starting step.",
698
+ hints: [
699
+ "Developer Credentials",
700
+ "New developer credentials",
701
+ "Content > My Content > New Item > Developer Credentials"
702
+ ]
703
+ }
704
+ }
597
705
  }
598
- }, Ot = Ye(Te), Kt = Object.entries(Te).map(([e, { description: t, hints: a }]) => ` - ${e}: ${t} (hints: ${a.join(", ")})`).join(`
599
- `), Vt = `
706
+ }, Tt = je(Be), Ke = B(Tt), Qe = Ve(Tt), We = `
600
707
  You decide whether the assistant response should include a navigation action to ArcGIS Portal.
601
708
 
602
709
  Given the user question and assistant response:
603
710
  - Decide if a navigation action would help the user complete the task.
604
711
  - If yes, choose one destinationType:
605
- ${Kt}
712
+ ${Qe}
606
713
 
607
714
  Rules:
608
715
  - Only suggest navigation when you are highly confident the destination will help complete the user's task.
@@ -625,98 +732,144 @@ User question:
625
732
 
626
733
  Assistant response:
627
734
  {response}
628
- `, ae = s.object({
735
+ `, nt = s.object({
629
736
  shouldSuggestNavigation: s.boolean().default(!1),
630
- destinationType: s.enum(["none", ...Ot]).default("none"),
737
+ destinationType: s.enum(["none", ...Ke]).default("none"),
631
738
  itemId: s.string().default(""),
632
739
  groupId: s.string().default(""),
633
740
  confidence: s.number().min(0).max(1).default(0)
634
- }), jt = async (e, t) => {
635
- await m({ text: "Extracting navigation intent...", agentName: "doc-assistant" }, t);
636
- const a = e.outputMessage.trim();
741
+ }), Je = async (t, e) => {
742
+ await m({ text: "Extracting navigation intent...", agentName: "doc-assistant" }, e);
743
+ const a = t.outputMessage.trim();
637
744
  if (!a)
638
745
  return {};
639
- const n = I(e.agentExecutionContext.messages).trim(), r = await W.fromTemplate(Vt).format({
746
+ const n = I(t.agentExecutionContext.messages).trim(), o = await J.fromTemplate(We).format({
640
747
  question: n,
641
748
  response: a
642
- }), u = (await Q({ modelTier: "fast" })).withStructuredOutput(ae), i = ae.parse(await u.invoke(r));
749
+ }), c = (await W({ modelTier: "fast" })).withStructuredOutput(nt), i = nt.parse(await c.invoke(o));
643
750
  if (!i.shouldSuggestNavigation || i.destinationType === "none")
644
751
  return {};
645
752
  if (i.destinationType === "portal-item" && !i.itemId) {
646
- const c = C(n, "#");
647
- c && (i.itemId = await Se.invoke({ itemTitle: c }, t) ?? "");
753
+ const u = M(n, "#");
754
+ u && (i.itemId = await xt.invoke({ itemTitle: u }, e) ?? "");
648
755
  }
649
756
  if (i.destinationType === "portal-group" && !i.groupId) {
650
- const c = C(n, "$") ?? C(n, "#");
651
- c && (i.groupId = await xe.invoke({ groupTitle: c }, t) ?? "");
757
+ const u = M(n, "$") ?? M(n, "#");
758
+ u && (i.groupId = await St.invoke({ groupTitle: u }, e) ?? "");
652
759
  }
653
- const l = Lt(i);
654
- return l ? (await D(l, t), {}) : {};
760
+ const l = _e(i);
761
+ return l ? (await R(l, e), {}) : {};
655
762
  };
656
- function Lt({
657
- destinationType: e,
658
- itemId: t,
763
+ function _e({
764
+ destinationType: t,
765
+ itemId: e,
659
766
  groupId: a
660
767
  }) {
661
- switch (e) {
768
+ switch (t) {
662
769
  case "portal-content":
663
770
  case "portal-gallery":
664
771
  case "portal-groups":
665
772
  case "portal-map-viewer":
666
773
  case "portal-notebooks":
667
774
  case "portal-scene-viewer":
668
- return { destinationType: e };
775
+ return { destinationType: t };
669
776
  case "portal-org-security":
670
- return { destinationType: "portal-org", hash: "settings" };
777
+ return {
778
+ destinationType: "portal-org",
779
+ hash: "settings",
780
+ queryParams: {
781
+ tab: "security"
782
+ }
783
+ };
784
+ case "portal-content-new-item":
785
+ case "portal-content-new-item-feature-layer":
786
+ case "portal-content-new-item-developer-credentials":
787
+ return {
788
+ queryParams: {
789
+ newItem: Ye[t]
790
+ },
791
+ destinationType: "portal-content"
792
+ };
671
793
  case "portal-content-favorites":
672
- return { destinationType: "portal-content", hash: "favorites" };
673
794
  case "portal-content-group":
674
- return { destinationType: "portal-content", hash: "group" };
675
795
  case "portal-content-living-atlas":
676
- return { destinationType: "portal-content", hash: "living-atlas" };
677
796
  case "portal-content-organization":
678
- return { destinationType: "portal-content", hash: "org" };
797
+ return { destinationType: "portal-content", hash: He[t] };
679
798
  case "portal-groups-featured":
680
- return { destinationType: "portal-groups", hash: "featured" };
681
799
  case "portal-groups-my":
682
- return { destinationType: "portal-groups", hash: "my" };
683
800
  case "portal-groups-organization":
684
- return { destinationType: "portal-groups", hash: "organization" };
801
+ return { destinationType: "portal-groups", hash: Xe[t] };
802
+ case "portal-org-security-custom-sign-in":
803
+ case "portal-org-security-logins":
804
+ case "portal-org-security-change-login-provider":
805
+ case "portal-org-security-multifactor-auth":
806
+ case "portal-org-security-multifactor-enforcement":
807
+ case "portal-org-security-multifactor-designated-admins":
808
+ const n = Ze[t];
809
+ return {
810
+ destinationType: "portal-org",
811
+ hash: "settings",
812
+ queryParams: {
813
+ tab: "security",
814
+ section: we[n],
815
+ subsection: n
816
+ }
817
+ };
685
818
  case "portal-item":
686
- return t ? { destinationType: e, itemId: t } : null;
819
+ return e ? { destinationType: t, itemId: e } : null;
687
820
  case "portal-group":
688
- return a ? { destinationType: e, groupId: a } : null;
821
+ return a ? { destinationType: t, groupId: a } : null;
689
822
  case "none":
690
823
  return null;
691
824
  default:
692
- return R(e);
825
+ return D(t);
693
826
  }
694
827
  }
695
- const Me = h.Root({
696
- ...N()
697
- }), Bt = () => new G(Me).addNode("answerDocQuestion", Ft).addNode("extractNavigationIntent", jt).addEdge(A, "answerDocQuestion").addEdge("answerDocQuestion", "extractNavigationIntent").addEdge("extractNavigationIntent", w), Qt = String.raw`- **portal-doc-assistant** - General ArcGIS documentation and Portal help assistant:
828
+ const Ye = {
829
+ "portal-content-new-item": "newItem",
830
+ "portal-content-new-item-feature-layer": "createLayer",
831
+ "portal-content-new-item-developer-credentials": "developerCredentials"
832
+ }, He = {
833
+ "portal-content-favorites": "favorites",
834
+ "portal-content-group": "group",
835
+ "portal-content-living-atlas": "living-atlas",
836
+ "portal-content-organization": "org"
837
+ }, Xe = {
838
+ "portal-groups-featured": "featured",
839
+ "portal-groups-my": "my",
840
+ "portal-groups-organization": "organization"
841
+ }, Ze = {
842
+ "portal-org-security-custom-sign-in": "customSignInSection",
843
+ "portal-org-security-logins": "loginsSection",
844
+ "portal-org-security-change-login-provider": "changeLoginProviderSection",
845
+ "portal-org-security-multifactor-auth": "multiFactorAuthSection",
846
+ "portal-org-security-multifactor-enforcement": "multifactorEnforcementSection",
847
+ "portal-org-security-multifactor-designated-admins": "multifactorDesignatedAdminsSection"
848
+ }, Ct = h.Root({
849
+ ...G()
850
+ }), ta = () => new A(Ct).addNode("answerDocQuestion", Le).addNode("extractNavigationIntent", Je).addEdge(N, "answerDocQuestion").addEdge("answerDocQuestion", "extractNavigationIntent").addEdge("extractNavigationIntent", w), ea = String.raw`- **portal-doc-assistant** - General ArcGIS documentation and Portal help assistant:
698
851
  - answers general ArcGIS, Portal, Enterprise, and JavaScript SDK questions
699
852
  - acts as a fallback when specialized agents are not applicable
700
- `, Wt = {
853
+ `, aa = {
701
854
  id: "portal-doc-assistant",
702
855
  name: "Portal Doc Assistant",
703
- description: Qt,
704
- createGraph: Bt,
705
- workspace: Me
706
- }, Jt = () => ({ latestGroupId: null, memory: {} }), U = (e) => {
707
- const t = e?.agentExecutionContext.sharedState.portalGroupSummaryMemory?.value;
708
- return t ? { latestGroupId: t.latestGroupId, memory: t.memory } : Jt();
709
- }, Ce = `
856
+ description: ea,
857
+ createGraph: ta,
858
+ workspace: Ct
859
+ }, na = () => ({ latestGroupId: null, memory: {} }), U = (t) => {
860
+ const e = t?.agentExecutionContext.sharedState.portalGroupSummaryMemory?.value;
861
+ return e ? { latestGroupId: e.latestGroupId, memory: e.memory } : na();
862
+ }, Mt = `
710
863
  Shared markdown formatting rules:
711
864
  - Use clear markdown headings (##) to separate sections.
712
865
  - Use concise bullet points for lists of facts, counts, or signals.
713
866
  - Emphasize key metrics with bold labels (for example: **Recent items:** 4).
714
867
  - Keep wording direct and analytical; avoid filler language but make sure the language is friendly.
715
868
  - Do not include raw internal IDs unless explicitly requested.
716
- `, _t = `
869
+ `, oa = `
717
870
  You answer follow-up questions about ArcGIS group analytics.
718
871
 
719
- ${Ce}
872
+ ${Mt}
720
873
 
721
874
  Ground your answer in the provided group analytics summary and context.
722
875
  If the answer is not available from the provided context, state that clearly and suggest what to check next.
@@ -738,29 +891,29 @@ Group full context:
738
891
 
739
892
  Question:
740
893
  {question}
741
- `, Yt = async (e, t) => {
742
- await m({ text: "Answering group follow-up...", agentName: "group-analytics" }, t);
743
- const a = U(e), n = e.groupSummaryGroupId ?? a.latestGroupId, r = n ? a.memory[n] : void 0, o = e.groupSummaryQuestion || I(e.agentExecutionContext.messages);
744
- return r ? {
894
+ `, ra = async (t, e) => {
895
+ await m({ text: "Answering group follow-up...", agentName: "group-analytics" }, e);
896
+ const a = U(t), n = t.groupSummaryGroupId ?? a.latestGroupId, o = n ? a.memory[n] : void 0, r = t.groupSummaryQuestion || I(t.agentExecutionContext.messages);
897
+ return o ? {
745
898
  status: "success",
746
- outputMessage: (await v({
747
- promptText: _t,
748
- schema: Ht,
899
+ outputMessage: (await b({
900
+ promptText: oa,
901
+ schema: sa,
749
902
  modelTier: "default",
750
903
  inputVariables: {
751
- summary: r.summary,
752
- question: o,
753
- fullContext: JSON.stringify(r.fullContext)
904
+ summary: o.summary,
905
+ question: r,
906
+ fullContext: JSON.stringify(o.fullContext)
754
907
  }
755
908
  })).answer
756
909
  } : {
757
910
  status: "success",
758
911
  outputMessage: "I do not have group analytics context yet. Ask me to analyze a group first with analyze group <group id>."
759
912
  };
760
- }, Ht = s.object({
913
+ }, sa = s.object({
761
914
  answer: s.string(),
762
915
  isRelevant: s.boolean()
763
- }), Xt = `
916
+ }), ia = `
764
917
  Classify the user's request for ArcGIS Portal group analytics.
765
918
 
766
919
  Rules:
@@ -789,121 +942,121 @@ hasAnalyticsContext:
789
942
 
790
943
  User message:
791
944
  {userMessage}
792
- `, Zt = async (e, t) => {
793
- await m({ text: "Analyzing group-analytics intent...", agentName: "group-analytics" }, t);
794
- const a = I(e.agentExecutionContext.messages), n = !!U(e).latestGroupId, r = await W.fromTemplate(Xt).format({
945
+ `, ca = async (t, e) => {
946
+ await m({ text: "Analyzing group-analytics intent...", agentName: "group-analytics" }, e);
947
+ const a = I(t.agentExecutionContext.messages), n = !!U(t).latestGroupId, o = await J.fromTemplate(ia).format({
795
948
  userMessage: a,
796
949
  hasAnalyticsContext: String(n)
797
- }), u = (await Q({ modelTier: "fast" })).withStructuredOutput(ne), i = ne.parse(await u.invoke(r));
950
+ }), c = (await W({ modelTier: "fast" })).withStructuredOutput(ot), i = ot.parse(await c.invoke(o));
798
951
  let l = i.groupId;
799
952
  if ((i.intent === "summarize" || i.intent === "navigation") && !l) {
800
- const y = C(a, "$");
801
- y && (l = await xe.invoke({ groupTitle: y }, t) ?? "");
953
+ const y = M(a, "$");
954
+ y && (l = await St.invoke({ groupTitle: y }, e) ?? "");
802
955
  }
803
- const { intent: c, question: d } = i, g = c === "summarize" && !l, p = c === "followUp" && !(d ?? "").trim(), f = c === "clarify" || g || p;
956
+ const { intent: u, question: d } = i, g = u === "summarize" && !l, p = u === "followUp" && !(d ?? "").trim(), f = u === "clarify" || g || p;
804
957
  return {
805
- groupSummaryIntent: f ? "clarify" : c,
958
+ groupSummaryIntent: f ? "clarify" : u,
806
959
  groupSummaryGroupId: l || null,
807
960
  groupSummaryQuestion: d || "",
808
961
  status: "success",
809
962
  outputMessage: f ? "Please clarify with a group id or title" : ""
810
963
  };
811
- }, ne = s.object({
964
+ }, ot = s.object({
812
965
  intent: s.enum(["summarize", "followUp", "navigation", "clarify"]),
813
966
  groupId: s.string().default(""),
814
967
  question: s.string().default("")
815
- }), ea = async (e, t) => {
816
- const a = U(e), n = e.groupSummaryGroupId ?? a.latestGroupId;
817
- return await m({ text: "Preparing navigation...", agentName: "group-analytics" }, t), await D(
968
+ }), ua = async (t, e) => {
969
+ const a = U(t), n = t.groupSummaryGroupId ?? a.latestGroupId;
970
+ return await m({ text: "Preparing navigation...", agentName: "group-analytics" }, e), await R(
818
971
  n ? { destinationType: "portal-group", groupId: n } : { destinationType: "portal-groups" },
819
- t
972
+ e
820
973
  ), { status: "success" };
821
974
  };
822
- function Ge({ timestamp: e, now: t, windowMs: a }) {
823
- return e ? t - e <= a : !1;
975
+ function At({ timestamp: t, now: e, windowMs: a }) {
976
+ return t ? e - t <= a : !1;
824
977
  }
825
- const ta = 720 * 60 * 60 * 1e3;
826
- function aa(e) {
827
- const t = Ze(e);
978
+ const la = 720 * 60 * 60 * 1e3;
979
+ function da(t) {
980
+ const e = Ht(t);
828
981
  return {
829
- id: e.id ?? "",
830
- title: e.title ?? "",
831
- description: e.description ?? "",
832
- snippet: e.snippet ?? "",
833
- access: e.access ?? null,
834
- owner: e.owner ?? "",
835
- tags: e.tags ?? [],
836
- created: e.created?.getTime(),
837
- modified: e.modified?.getTime(),
838
- isInvitationOnly: e.isInvitationOnly,
982
+ id: t.id ?? "",
983
+ title: t.title ?? "",
984
+ description: t.description ?? "",
985
+ snippet: t.snippet ?? "",
986
+ access: t.access ?? null,
987
+ owner: t.owner ?? "",
988
+ tags: t.tags ?? [],
989
+ created: t.created?.getTime(),
990
+ modified: t.modified?.getTime(),
991
+ isInvitationOnly: t.isInvitationOnly,
839
992
  sourceSignals: {
840
- capabilities: nt(e),
841
- membershipAccess: at(e),
842
- isOpenData: tt(e),
843
- isDistributedCollaborationGroup: et(e),
844
- orgId: t.orgId,
845
- hiddenMembers: t.hiddenMembers,
846
- isViewOnly: t.isViewOnly,
847
- isReadOnly: t.isReadOnly,
848
- leavingDisallowed: t.leavingDisallowed
993
+ capabilities: ee(t),
994
+ membershipAccess: te(t),
995
+ isOpenData: Zt(t),
996
+ isDistributedCollaborationGroup: Xt(t),
997
+ orgId: e.orgId,
998
+ hiddenMembers: e.hiddenMembers,
999
+ isViewOnly: e.isViewOnly,
1000
+ isReadOnly: e.isReadOnly,
1001
+ leavingDisallowed: e.leavingDisallowed
849
1002
  }
850
1003
  };
851
1004
  }
852
- async function na(e) {
853
- const t = { owner: e.owner ?? "", admins: [], users: [] };
1005
+ async function pa(t) {
1006
+ const e = { owner: t.owner ?? "", admins: [], users: [] };
854
1007
  try {
855
- return await e.fetchMembers();
1008
+ return await t.fetchMembers();
856
1009
  } catch (a) {
857
- return console.warn("Unable to fetch group members for analytics context", a), t;
1010
+ return console.warn("Unable to fetch group members for analytics context", a), e;
858
1011
  }
859
1012
  }
860
- function ra(e) {
861
- return e.map((t) => ({
862
- id: t.id ?? "",
863
- title: t.title ?? "Untitled",
864
- type: t.type ?? "Unknown",
865
- owner: t.owner ?? "",
866
- created: t.created?.getTime(),
867
- modified: t.modified?.getTime()
1013
+ function ma(t) {
1014
+ return t.map((e) => ({
1015
+ id: e.id ?? "",
1016
+ title: e.title ?? "Untitled",
1017
+ type: e.type ?? "Unknown",
1018
+ owner: e.owner ?? "",
1019
+ created: e.created?.getTime(),
1020
+ modified: e.modified?.getTime()
868
1021
  }));
869
1022
  }
870
- function oa(e, t) {
871
- return e.filter(
872
- (a) => a.modified ? Ge({ timestamp: a.modified, now: t, windowMs: ta }) : !1
1023
+ function ga(t, e) {
1024
+ return t.filter(
1025
+ (a) => a.modified ? At({ timestamp: a.modified, now: e, windowMs: la }) : !1
873
1026
  );
874
1027
  }
875
- function sa(e) {
876
- const t = /* @__PURE__ */ new Map();
877
- for (const a of e)
878
- t.set(a.type, (t.get(a.type) ?? 0) + 1);
879
- return [...t.entries()].sort((a, n) => n[1] - a[1] || a[0].localeCompare(n[0])).slice(0, 6).map(([a, n]) => ({ type: a, count: n }));
1028
+ function ha(t) {
1029
+ const e = /* @__PURE__ */ new Map();
1030
+ for (const a of t)
1031
+ e.set(a.type, (e.get(a.type) ?? 0) + 1);
1032
+ return [...e.entries()].sort((a, n) => n[1] - a[1] || a[0].localeCompare(n[0])).slice(0, 6).map(([a, n]) => ({ type: a, count: n }));
880
1033
  }
881
- async function ia(e) {
882
- const t = await e.queryItems({ num: 20, sortField: "modified", sortOrder: "desc" }), a = ra(t.results), n = Date.now();
1034
+ async function fa(t) {
1035
+ const e = await t.queryItems({ num: 20, sortField: "modified", sortOrder: "desc" }), a = ma(e.results), n = Date.now();
883
1036
  return {
884
- total: t.total,
1037
+ total: e.total,
885
1038
  topItems: a,
886
- recentlyModifiedItems: oa(a, n),
887
- topItemTypes: sa(a)
1039
+ recentlyModifiedItems: ga(a, n),
1040
+ topItemTypes: ha(a)
888
1041
  };
889
1042
  }
890
- async function ua(e, t) {
891
- if (!t)
1043
+ async function ya(t, e) {
1044
+ if (!e)
892
1045
  return { error: { code: "missingGroupId", message: "Group id is required." } };
893
1046
  try {
894
- const n = (await e.queryGroups({ query: `id:${t}`, num: 1 })).results[0];
1047
+ const n = (await t.queryGroups({ query: `id:${e}`, num: 1 })).results[0];
895
1048
  if (!n)
896
- return { error: { code: "groupNotFound", message: `No group found for id: ${t}` } };
897
- const r = aa(n), o = await na(n), u = await ia(n);
898
- return { result: { group: r, members: o, items: u } };
1049
+ return { error: { code: "groupNotFound", message: `No group found for id: ${e}` } };
1050
+ const o = da(n), r = await pa(n), c = await fa(n);
1051
+ return { result: { group: o, members: r, items: c } };
899
1052
  } catch (a) {
900
1053
  return console.error("Error fetching portal group analytics context:", a), { error: { code: "unhandledError" } };
901
1054
  }
902
1055
  }
903
- const ca = `
1056
+ const wa = `
904
1057
  You summarize ArcGIS Portal groups based on structured context and deterministic activity signals.
905
1058
 
906
- ${Ce}
1059
+ ${Mt}
907
1060
 
908
1061
  Output format requirements:
909
1062
  - Return concise markdown with clear sections in this order:
@@ -939,28 +1092,28 @@ Group context:
939
1092
 
940
1093
  Deterministic signals:
941
1094
  {deterministicSignals}
942
- `, la = 2160 * 60 * 60 * 1e3, da = async (e, t) => {
943
- const a = e.groupSummaryGroupId;
1095
+ `, va = 2160 * 60 * 60 * 1e3, ba = async (t, e) => {
1096
+ const a = t.groupSummaryGroupId;
944
1097
  if (!a)
945
1098
  return {
946
1099
  status: "success",
947
1100
  outputMessage: 'Please clarify with analyze group <group id>, analyze group $<title>, or analyze group $"<title with spaces>".'
948
1101
  };
949
- await m({ text: `Analyzing group ${a}...`, agentName: "group-analytics" }, t);
950
- const n = t?.configurable?.context;
1102
+ await m({ text: `Analyzing group ${a}...`, agentName: "group-analytics" }, e);
1103
+ const n = e?.configurable?.context;
951
1104
  T(n);
952
- const { result: r, error: o } = await ua(n.portal, a);
953
- if (o || !r)
954
- return await m({ text: "Failed to fetch group context", agentName: "group-analytics" }, t), {
1105
+ const { result: o, error: r } = await ya(n.portal, a);
1106
+ if (r || !o)
1107
+ return await m({ text: "Failed to fetch group context", agentName: "group-analytics" }, e), {
955
1108
  status: "success",
956
1109
  outputMessage: "Unable to retrieve group context for analytics."
957
1110
  };
958
- const { group: u, items: i } = r, l = Date.now(), c = u.modified, d = c ? Ge({ timestamp: c, now: l, windowMs: la }) : !1, g = i.recentlyModifiedItems.length, p = g > 0, f = d || p, y = await v({
959
- promptText: ca,
960
- schema: pa,
1111
+ const { group: c, items: i } = o, l = Date.now(), u = c.modified, d = u ? At({ timestamp: u, now: l, windowMs: va }) : !1, g = i.recentlyModifiedItems.length, p = g > 0, f = d || p, y = await b({
1112
+ promptText: wa,
1113
+ schema: Ia,
961
1114
  modelTier: "default",
962
1115
  inputVariables: {
963
- context: JSON.stringify(r),
1116
+ context: JSON.stringify(o),
964
1117
  deterministicSignals: JSON.stringify({
965
1118
  isGroupActive: f,
966
1119
  isGroupRecentlyModified: d,
@@ -968,23 +1121,23 @@ Deterministic signals:
968
1121
  recentItemCount: g
969
1122
  })
970
1123
  }
971
- }), { followUpQuestions: x, summary: M } = y, Re = U(e), De = {
1124
+ }), { followUpQuestions: S, summary: C } = y, $t = U(t), Dt = {
972
1125
  latestGroupId: a,
973
1126
  memory: {
974
- ...Re.memory,
975
- [a]: { summary: M, followUpQuestions: x, fullContext: r }
1127
+ ...$t.memory,
1128
+ [a]: { summary: C, followUpQuestions: S, fullContext: o }
976
1129
  }
977
1130
  };
978
- return x.length && await B({ type: "suggested-prompts", data: { prompts: x } }, t), {
1131
+ return S.length && await Q({ type: "suggested-prompts", data: { prompts: S } }, e), {
979
1132
  status: "success",
980
- outputMessage: M,
981
- sharedStatePatch: { portalGroupSummaryMemory: { value: De } }
1133
+ outputMessage: C,
1134
+ sharedStatePatch: { portalGroupSummaryMemory: { value: Dt } }
982
1135
  };
983
- }, pa = s.object({
1136
+ }, Ia = s.object({
984
1137
  summary: s.string(),
985
1138
  followUpQuestions: s.array(s.string()).default([])
986
- }), F = (e, t) => t ?? e, Ae = h.Root({
987
- ...N(),
1139
+ }), F = (t, e) => e ?? t, Nt = h.Root({
1140
+ ...G(),
988
1141
  groupSummaryIntent: h({
989
1142
  reducer: F,
990
1143
  default: () => "clarify"
@@ -997,24 +1150,24 @@ Deterministic signals:
997
1150
  reducer: F,
998
1151
  default: () => ""
999
1152
  })
1000
- }), ma = () => new G(Ae).addNode("detectGroupSummaryIntent", Zt).addNode("summarizePortalGroup", da).addNode("answerGroupSummaryFollowUp", Yt).addNode("suggestGroupSummaryNavigation", ea).addEdge(A, "detectGroupSummaryIntent").addConditionalEdges("detectGroupSummaryIntent", (t) => t.groupSummaryIntent === "summarize" ? "summarizePortalGroup" : t.groupSummaryIntent === "followUp" ? "answerGroupSummaryFollowUp" : t.groupSummaryIntent === "navigation" ? "suggestGroupSummaryNavigation" : w).addEdge("summarizePortalGroup", w).addEdge("answerGroupSummaryFollowUp", w).addEdge("suggestGroupSummaryNavigation", w), ga = String.raw`- **portal-group-analytics** - Portal group analytics assistant:
1153
+ }), Sa = () => new A(Nt).addNode("detectGroupSummaryIntent", ca).addNode("summarizePortalGroup", ba).addNode("answerGroupSummaryFollowUp", ra).addNode("suggestGroupSummaryNavigation", ua).addEdge(N, "detectGroupSummaryIntent").addConditionalEdges("detectGroupSummaryIntent", (e) => e.groupSummaryIntent === "summarize" ? "summarizePortalGroup" : e.groupSummaryIntent === "followUp" ? "answerGroupSummaryFollowUp" : e.groupSummaryIntent === "navigation" ? "suggestGroupSummaryNavigation" : w).addEdge("summarizePortalGroup", w).addEdge("answerGroupSummaryFollowUp", w).addEdge("suggestGroupSummaryNavigation", w), xa = String.raw`- **portal-group-analytics** - Portal group analytics assistant:
1001
1154
  - summarizes ArcGIS portal groups from group context and sourceJSON details
1002
1155
  - answers follow-up questions grounded in the summarized group
1003
1156
  - suggests navigation to groups when relevant
1004
- `, ha = {
1157
+ `, Ta = {
1005
1158
  id: "portal-group-analytics",
1006
1159
  name: "Portal Group Analytics",
1007
- description: ga,
1008
- createGraph: ma,
1009
- workspace: Ae
1010
- }, fa = () => ({ latestItemId: null, memory: {} }), J = (e) => {
1011
- const t = e?.agentExecutionContext.sharedState.portalItemAnalyticsSummaryMemory?.value;
1012
- return t ? { latestItemId: t.latestItemId, memory: t.memory } : fa();
1013
- }, re = s.object({
1160
+ description: xa,
1161
+ createGraph: Sa,
1162
+ workspace: Nt
1163
+ }, Ca = () => ({ latestItemId: null, memory: {} }), _ = (t) => {
1164
+ const e = t?.agentExecutionContext.sharedState.portalItemAnalyticsSummaryMemory?.value;
1165
+ return e ? { latestItemId: e.latestItemId, memory: e.memory } : Ca();
1166
+ }, rt = s.object({
1014
1167
  intent: s.enum(["summarize", "followUp", "clarify"]),
1015
1168
  itemId: s.string().default(""),
1016
1169
  question: s.string().default("")
1017
- }), ya = s.object({ summary: s.string(), followUpQuestions: s.array(s.string()).default([]) }), wa = s.object({ answer: s.string(), isRelevant: s.boolean() }), ba = `
1170
+ }), Ma = s.object({ summary: s.string(), followUpQuestions: s.array(s.string()).default([]) }), Aa = s.object({ answer: s.string(), isRelevant: s.boolean() }), Na = `
1018
1171
  You answer follow-up questions about an ArcGIS item.
1019
1172
 
1020
1173
  Ground your answer in the provided item context.
@@ -1034,26 +1187,26 @@ Item full context
1034
1187
 
1035
1188
  Question:
1036
1189
  {question}
1037
- `, va = async (e, t) => {
1038
- await m({ text: "Answering follow-up...", agentName: "analytics" }, t);
1039
- const a = J(e), n = e.analyticsItemId ?? a.latestItemId, r = n ? a.memory[n] : void 0, o = e.analyticsQuestion || I(e.agentExecutionContext.messages);
1040
- return r ? {
1190
+ `, Ga = async (t, e) => {
1191
+ await m({ text: "Answering follow-up...", agentName: "analytics" }, e);
1192
+ const a = _(t), n = t.analyticsItemId ?? a.latestItemId, o = n ? a.memory[n] : void 0, r = t.analyticsQuestion || I(t.agentExecutionContext.messages);
1193
+ return o ? {
1041
1194
  status: "success",
1042
- outputMessage: (await v({
1043
- promptText: ba,
1044
- schema: wa,
1195
+ outputMessage: (await b({
1196
+ promptText: Na,
1197
+ schema: Aa,
1045
1198
  modelTier: "default",
1046
1199
  inputVariables: {
1047
- summary: r.summary,
1048
- question: o,
1049
- fullContext: JSON.stringify(r.fullContext)
1200
+ summary: o.summary,
1201
+ question: r,
1202
+ fullContext: JSON.stringify(o.fullContext)
1050
1203
  }
1051
1204
  })).answer
1052
1205
  } : {
1053
1206
  status: "success",
1054
1207
  outputMessage: "I don't have enough information yet. Please ask me to summarize the item first using summarize item <item id>."
1055
1208
  };
1056
- }, Ia = `
1209
+ }, Pa = `
1057
1210
  Classify the user analytics request.
1058
1211
 
1059
1212
  Rules:
@@ -1083,27 +1236,27 @@ hasSummaryContext:
1083
1236
 
1084
1237
  User message:
1085
1238
  {userMessage}
1086
- `, xa = async (e, t) => {
1087
- await m({ text: "Analyzing intent...", agentName: "analytics" }, t);
1088
- const a = I(e.agentExecutionContext.messages), n = !!J(e).latestItemId, r = await W.fromTemplate(Ia).format({
1239
+ `, qa = async (t, e) => {
1240
+ await m({ text: "Analyzing intent...", agentName: "analytics" }, e);
1241
+ const a = I(t.agentExecutionContext.messages), n = !!_(t).latestItemId, o = await J.fromTemplate(Pa).format({
1089
1242
  userMessage: a,
1090
1243
  hasSummaryContext: String(n)
1091
- }), u = (await Q({ modelTier: "fast" })).withStructuredOutput(re), i = re.parse(await u.invoke(r));
1244
+ }), c = (await W({ modelTier: "fast" })).withStructuredOutput(rt), i = rt.parse(await c.invoke(o));
1092
1245
  let l = i.itemId;
1093
1246
  if (i.intent === "summarize" && !l) {
1094
- const y = C(a, "#");
1095
- y && (l = await Se.invoke({ itemTitle: y }, t) ?? "");
1247
+ const y = M(a, "#");
1248
+ y && (l = await xt.invoke({ itemTitle: y }, e) ?? "");
1096
1249
  }
1097
- const { intent: c, question: d } = i, f = c === "clarify" || c === "summarize" && !l || c === "followUp" && !d;
1250
+ const { intent: u, question: d } = i, f = u === "clarify" || u === "summarize" && !l || u === "followUp" && !d;
1098
1251
  return {
1099
- agentExecutionContext: { ...e.agentExecutionContext },
1100
- analyticsIntent: f ? "clarify" : c,
1252
+ agentExecutionContext: { ...t.agentExecutionContext },
1253
+ analyticsIntent: f ? "clarify" : u,
1101
1254
  analyticsItemId: l || null,
1102
1255
  analyticsQuestion: d || "",
1103
1256
  status: "success",
1104
1257
  outputMessage: f ? 'Please clarify with summarize item <item id>, summarize item #<title>, or summarize item #"<title with spaces>".' : ""
1105
1258
  };
1106
- }, Sa = `
1259
+ }, Ea = `
1107
1260
  You are a item summary tool for ArcGIS. Your job is to summarize an item's info based on the provided context.
1108
1261
  Summary rules:
1109
1262
  - The summary should be concise markdown, make sure to format the output nicely so it's easy to read.
@@ -1118,41 +1271,41 @@ Do not include internal identifiers.
1118
1271
  If the user asks for a detailed summary, you may expand the response up to 300 words.
1119
1272
  Item context:
1120
1273
  {context}
1121
- `, Ta = async (e, t) => {
1122
- const a = e.analyticsItemId;
1274
+ `, za = async (t, e) => {
1275
+ const a = t.analyticsItemId;
1123
1276
  if (!a)
1124
1277
  return {
1125
1278
  status: "success",
1126
1279
  outputMessage: 'Please clarify with summarize item <item id>, summarize item #<title>, or summarize item #"<title with spaces>".'
1127
1280
  };
1128
- await m({ text: `Summarizing item ${a}...`, agentName: "analytics" }, t);
1129
- const n = t?.configurable?.context;
1281
+ await m({ text: `Summarizing item ${a}...`, agentName: "analytics" }, e);
1282
+ const n = e?.configurable?.context;
1130
1283
  T(n);
1131
- const { portal: r, user: o } = n, { result: u, error: i } = await Xe(o, r, a);
1132
- if (i || !u)
1133
- return await m({ text: "Failed to get item context for summarization", agentName: "analytics" }, t), {
1284
+ const { portal: o, user: r } = n, { result: c, error: i } = await Yt(r, o, a);
1285
+ if (i || !c)
1286
+ return await m({ text: "Failed to get item context for summarization", agentName: "analytics" }, e), {
1134
1287
  status: "success",
1135
1288
  outputMessage: "Unable to retrieve item context for summarization."
1136
1289
  };
1137
- const { context: l } = u, c = await v({
1138
- promptText: Sa,
1139
- schema: ya,
1290
+ const { context: l } = c, u = await b({
1291
+ promptText: Ea,
1292
+ schema: Ma,
1140
1293
  modelTier: "default",
1141
1294
  inputVariables: { context: JSON.stringify(l) }
1142
- }), { followUpQuestions: d, summary: g } = c, p = J(e), f = {
1295
+ }), { followUpQuestions: d, summary: g } = u, p = _(t), f = {
1143
1296
  latestItemId: a,
1144
1297
  memory: {
1145
1298
  ...p.memory,
1146
1299
  [a]: { summary: g, followUpQuestions: d, fullContext: l }
1147
1300
  }
1148
1301
  };
1149
- return d.length && await B({ type: "suggested-prompts", data: { prompts: d } }, t), {
1302
+ return d.length && await Q({ type: "suggested-prompts", data: { prompts: d } }, e), {
1150
1303
  status: "success",
1151
1304
  outputMessage: g,
1152
1305
  sharedStatePatch: { portalItemAnalyticsSummaryMemory: { value: f } }
1153
1306
  };
1154
- }, O = (e, t) => t ?? e, Ne = h.Root({
1155
- ...N(),
1307
+ }, O = (t, e) => e ?? t, Gt = h.Root({
1308
+ ...G(),
1156
1309
  // States shared only across nodes in the graph, not between invocations
1157
1310
  analyticsIntent: h({
1158
1311
  reducer: O,
@@ -1166,18 +1319,18 @@ Item context:
1166
1319
  reducer: O,
1167
1320
  default: () => ""
1168
1321
  })
1169
- }), Ma = () => new G(Ne).addNode("detectAnalyticsIntent", xa).addNode("summarizePortalItem", Ta).addNode("answerAnalyticsFollowUp", va).addEdge(A, "detectAnalyticsIntent").addConditionalEdges("detectAnalyticsIntent", (t) => t.analyticsIntent === "summarize" ? "summarizePortalItem" : t.analyticsIntent === "followUp" ? "answerAnalyticsFollowUp" : w).addEdge("summarizePortalItem", w).addEdge("answerAnalyticsFollowUp", w), Ca = String.raw`- **portal-item-analytics** - Portal item analytics assistant:
1322
+ }), ka = () => new A(Gt).addNode("detectAnalyticsIntent", qa).addNode("summarizePortalItem", za).addNode("answerAnalyticsFollowUp", Ga).addEdge(N, "detectAnalyticsIntent").addConditionalEdges("detectAnalyticsIntent", (e) => e.analyticsIntent === "summarize" ? "summarizePortalItem" : e.analyticsIntent === "followUp" ? "answerAnalyticsFollowUp" : w).addEdge("summarizePortalItem", w).addEdge("answerAnalyticsFollowUp", w), $a = String.raw`- **portal-item-analytics** - Portal item analytics assistant:
1170
1323
  - answers questions about one specific ArcGIS portal item when item context is present
1171
1324
  - summarizes item details, metadata, and context grounded in that item
1172
1325
  - suggests follow-up prompts grounded in the same item
1173
1326
  - use for item-specific requests, not for gallery browsing, featured content, or opening Map Viewer
1174
- `, Ga = {
1327
+ `, Da = {
1175
1328
  id: "portal-item-analytics",
1176
1329
  name: "Portal Item Analytics",
1177
- description: Ca,
1178
- createGraph: Ma,
1179
- workspace: Ne
1180
- }, Aa = {
1330
+ description: $a,
1331
+ createGraph: ka,
1332
+ workspace: Gt
1333
+ }, Ra = {
1181
1334
  schemaVersion: "1.0",
1182
1335
  capabilities: [
1183
1336
  {
@@ -1217,7 +1370,7 @@ Item context:
1217
1370
  }
1218
1371
  }
1219
1372
  ]
1220
- }, Na = {
1373
+ }, Ua = {
1221
1374
  schemaVersion: "1.0",
1222
1375
  capabilities: [
1223
1376
  {
@@ -1271,7 +1424,7 @@ Item context:
1271
1424
  }
1272
1425
  }
1273
1426
  ]
1274
- }, Pa = {
1427
+ }, Fa = {
1275
1428
  schemaVersion: "1.0",
1276
1429
  capabilities: [
1277
1430
  {
@@ -1291,34 +1444,34 @@ Item context:
1291
1444
  }
1292
1445
  }
1293
1446
  ]
1294
- }, qa = {
1295
- "contentRouteRegistry.ts": Aa,
1296
- "groupsRouteRegistry.ts": Na,
1297
- "orgSettingsRouteRegistry.ts": Pa
1447
+ }, Oa = {
1448
+ "contentRouteRegistry.ts": Ra,
1449
+ "groupsRouteRegistry.ts": Ua,
1450
+ "orgSettingsRouteRegistry.ts": Fa
1298
1451
  };
1299
- function oe(e) {
1300
- const t = [], a = /* @__PURE__ */ new Set();
1301
- for (const [n, r] of Object.entries(e))
1302
- for (const o of r.capabilities) {
1303
- if (a.has(o.id))
1304
- throw new Error(`${n}: duplicate capability id "${o.id}" across registries`);
1305
- a.add(o.id), t.push(o);
1452
+ function st(t) {
1453
+ const e = [], a = /* @__PURE__ */ new Set();
1454
+ for (const [n, o] of Object.entries(t))
1455
+ for (const r of o.capabilities) {
1456
+ if (a.has(r.id))
1457
+ throw new Error(`${n}: duplicate capability id "${r.id}" across registries`);
1458
+ a.add(r.id), e.push(r);
1306
1459
  }
1307
- return t;
1460
+ return e;
1308
1461
  }
1309
1462
  let E;
1310
- function S(e) {
1311
- return e ? E = oe({ customCapabilities: e }) : E || (E = oe(qa)), E;
1463
+ function x(t) {
1464
+ return t ? E = st({ customCapabilities: t }) : E || (E = st(Oa)), E;
1312
1465
  }
1313
- const Ea = /^(?:take me to|navigate to|go to|show me|open)\s+(?:the\s+)?/u;
1314
- function $(e) {
1315
- return e.toLowerCase().replace(/[^a-z0-9]+/gu, " ").trim().replace(Ea, "").trim();
1466
+ const La = /^(?:take me to|navigate to|go to|show me|open)\s+(?:the\s+)?/u;
1467
+ function $(t) {
1468
+ return t.toLowerCase().replace(/[^a-z0-9]+/gu, " ").trim().replace(La, "").trim();
1316
1469
  }
1317
- const ka = s.object({
1470
+ const ja = s.object({
1318
1471
  capabilityIds: s.array(s.string()).default([]),
1319
1472
  confidence: s.number().min(0).max(1).default(0),
1320
1473
  reason: s.string().default("")
1321
- }), se = 0.8, za = String.raw`You select Portal navigation capabilities for a user's request.
1474
+ }), it = 0.8, Va = String.raw`You select Portal navigation capabilities for a user's request.
1322
1475
 
1323
1476
  Select only capability IDs from the supplied candidates. Return an empty array when none fit.
1324
1477
  A named surface is required: do not select a capability on another Portal surface.
@@ -1328,44 +1481,44 @@ User request:
1328
1481
  {userRequest}
1329
1482
 
1330
1483
  Candidates:
1331
- {candidates}`, $a = async (e, t) => {
1332
- if (e.outputMessage || e.targets.length === 0)
1484
+ {candidates}`, Ba = async (t, e) => {
1485
+ if (t.outputMessage || t.targets.length === 0)
1333
1486
  return {};
1334
- const a = I(e.agentExecutionContext.messages).trim(), n = Ra(a, e);
1487
+ const a = I(t.agentExecutionContext.messages).trim(), n = Ka(a, t);
1335
1488
  if (n.length === 1)
1336
1489
  return console.info("[arcgis-portal-ai-assistant] navigation capability selection:", {
1337
1490
  method: "exact-match",
1338
1491
  request: a,
1339
1492
  selectedCapabilityIds: n
1340
1493
  }), { chosenCapabilityIds: n };
1341
- await m({ text: "Choosing a navigation destination...", agentName: "navigation" }, t);
1342
- const r = JSON.stringify(
1343
- e.targets.map(({ capability: o, keywordScore: u, semanticScore: i }) => ({
1344
- id: o.id,
1345
- title: o.title,
1346
- description: o.description,
1347
- route: o.resolutions.navigate,
1348
- keywordScore: u,
1494
+ await m({ text: "Choosing a navigation destination...", agentName: "navigation" }, e);
1495
+ const o = JSON.stringify(
1496
+ t.targets.map(({ capability: r, keywordScore: c, semanticScore: i }) => ({
1497
+ id: r.id,
1498
+ title: r.title,
1499
+ description: r.description,
1500
+ route: r.resolutions.navigate,
1501
+ keywordScore: c,
1349
1502
  semanticScore: i
1350
1503
  }))
1351
1504
  );
1352
1505
  try {
1353
- const o = await v({
1354
- promptText: za,
1355
- schema: ka,
1506
+ const r = await b({
1507
+ promptText: Va,
1508
+ schema: ja,
1356
1509
  modelTier: "fast",
1357
- inputVariables: { candidates: r, userRequest: a }
1358
- }), u = new Set(e.targets.map(({ capability: l }) => l.id)), i = o.capabilityIds.filter((l) => u.has(l));
1510
+ inputVariables: { candidates: o, userRequest: a }
1511
+ }), c = new Set(t.targets.map(({ capability: l }) => l.id)), i = r.capabilityIds.filter((l) => c.has(l));
1359
1512
  return console.info("[arcgis-portal-ai-assistant] navigation capability selection:", {
1360
- confidence: o.confidence,
1513
+ confidence: r.confidence,
1361
1514
  method: "structured-model",
1362
- reason: o.reason,
1515
+ reason: r.reason,
1363
1516
  request: a,
1364
1517
  selectedCapabilityIds: i
1365
- }), o.confidence < se ? {
1518
+ }), r.confidence < it ? {
1366
1519
  chosenCapabilityIds: [],
1367
1520
  status: "failed",
1368
- summary: `Navigation selection confidence ${o.confidence} is below the required ${se}; defer to the Portal Doc Assistant.`
1521
+ summary: `Navigation selection confidence ${r.confidence} is below the required ${it}; defer to the Portal Doc Assistant.`
1369
1522
  } : { chosenCapabilityIds: i };
1370
1523
  } catch {
1371
1524
  return console.info("[arcgis-portal-ai-assistant] navigation capability selection:", {
@@ -1375,19 +1528,19 @@ Candidates:
1375
1528
  }), { chosenCapabilityIds: [] };
1376
1529
  }
1377
1530
  };
1378
- function Ra(e, t) {
1379
- const a = $(e);
1380
- return t.targets.filter(
1531
+ function Ka(t, e) {
1532
+ const a = $(t);
1533
+ return e.targets.filter(
1381
1534
  ({ capability: n }) => [n.title, ...n.hints].some(
1382
- (r) => $(r) === a
1535
+ (o) => $(o) === a
1383
1536
  )
1384
1537
  ).map(({ capability: n }) => n.id);
1385
1538
  }
1386
- const Pe = /* @__PURE__ */ new Set(["1d", "7d", "14d", "30d", "3m", "6m"]), Da = s.object({
1539
+ const Pt = /* @__PURE__ */ new Set(["1d", "7d", "14d", "30d", "3m", "6m"]), Qa = s.object({
1387
1540
  period: s.string(),
1388
1541
  startTime: s.string(),
1389
1542
  endTime: s.string()
1390
- }), Ua = String.raw`Extract temporal filters for an ArcGIS storage-credits query.
1543
+ }), Wa = String.raw`Extract temporal filters for an ArcGIS storage-credits query.
1391
1544
 
1392
1545
  Return JSON only with these optional string fields:
1393
1546
  - period
@@ -1413,171 +1566,171 @@ Now UTC:
1413
1566
 
1414
1567
  User request:
1415
1568
  {userRequest}`;
1416
- async function Fa(e, t = /* @__PURE__ */ new Date()) {
1417
- const a = e.trim();
1569
+ async function Ja(t, e = /* @__PURE__ */ new Date()) {
1570
+ const a = t.trim();
1418
1571
  if (!a)
1419
1572
  return {};
1420
1573
  try {
1421
- const n = await v({
1422
- promptText: Ua,
1423
- schema: Da,
1574
+ const n = await b({
1575
+ promptText: Wa,
1576
+ schema: Qa,
1424
1577
  modelTier: "fast",
1425
1578
  inputVariables: {
1426
- nowEpochMs: String(t.getTime()),
1427
- nowIso: t.toISOString(),
1579
+ nowEpochMs: String(e.getTime()),
1580
+ nowIso: e.toISOString(),
1428
1581
  userRequest: a
1429
1582
  }
1430
1583
  });
1431
- return Oa(n, t);
1584
+ return _a(n, e);
1432
1585
  } catch (n) {
1433
1586
  return console.error(n), {};
1434
1587
  }
1435
1588
  }
1436
- function Oa(e, t = /* @__PURE__ */ new Date()) {
1437
- const a = ie(e.startTime), n = ie(e.endTime), r = Ka(e.period);
1438
- if (r) {
1589
+ function _a(t, e = /* @__PURE__ */ new Date()) {
1590
+ const a = ct(t.startTime), n = ct(t.endTime), o = Ya(t.period);
1591
+ if (o) {
1439
1592
  if (a !== void 0 && n !== void 0 && a < n)
1440
- return { period: r, startTime: String(a), endTime: String(n) };
1441
- const o = Pe.has(r);
1442
- if (!o || n !== void 0 && !ja(n, t.getTime())) {
1443
- const i = n ?? t.getTime(), l = Va(r, new Date(i));
1593
+ return { period: o, startTime: String(a), endTime: String(n) };
1594
+ const r = Pt.has(o);
1595
+ if (!r || n !== void 0 && !Xa(n, e.getTime())) {
1596
+ const i = n ?? e.getTime(), l = Ha(o, new Date(i));
1444
1597
  if (l !== void 0)
1445
1598
  return {
1446
- period: r,
1599
+ period: o,
1447
1600
  startTime: String(l),
1448
1601
  endTime: String(i)
1449
1602
  };
1450
1603
  }
1451
- return o ? {
1452
- period: r,
1604
+ return r ? {
1605
+ period: o,
1453
1606
  ...a !== void 0 ? { startTime: String(a) } : {},
1454
1607
  ...n !== void 0 ? { endTime: String(n) } : {}
1455
- } : { period: r };
1608
+ } : { period: o };
1456
1609
  }
1457
- return a !== void 0 && n !== void 0 && a < n ? { startTime: String(a), endTime: String(n) } : a !== void 0 ? { startTime: String(a), endTime: String(t.getTime()) } : {};
1610
+ return a !== void 0 && n !== void 0 && a < n ? { startTime: String(a), endTime: String(n) } : a !== void 0 ? { startTime: String(a), endTime: String(e.getTime()) } : {};
1458
1611
  }
1459
- function Ka(e) {
1460
- const t = e?.trim().match(/^(\d+)\s*([dwm])$/iu);
1461
- if (!t)
1612
+ function Ya(t) {
1613
+ const e = t?.trim().match(/^(\d+)\s*([dwm])$/iu);
1614
+ if (!e)
1462
1615
  return;
1463
- const a = Number.parseInt(t[1], 10);
1616
+ const a = Number.parseInt(e[1], 10);
1464
1617
  if (!Number.isFinite(a) || a <= 0)
1465
1618
  return;
1466
- const n = t[2].toLowerCase();
1619
+ const n = e[2].toLowerCase();
1467
1620
  if (n === "w") {
1468
- const r = a * 7;
1469
- if (Pe.has(`${r}d`))
1470
- return `${r}d`;
1621
+ const o = a * 7;
1622
+ if (Pt.has(`${o}d`))
1623
+ return `${o}d`;
1471
1624
  }
1472
1625
  return `${a}${n}`;
1473
1626
  }
1474
- function Va(e, t) {
1475
- const a = e.match(/^(\d+)([dwm])$/u);
1627
+ function Ha(t, e) {
1628
+ const a = t.match(/^(\d+)([dwm])$/u);
1476
1629
  if (!a)
1477
1630
  return;
1478
1631
  const n = Number.parseInt(a[1], 10);
1479
1632
  if (!Number.isFinite(n) || n <= 0)
1480
1633
  return;
1481
- const r = a[2];
1482
- if (r === "d")
1483
- return t.getTime() - n * 24 * 60 * 60 * 1e3;
1484
- if (r === "w")
1485
- return t.getTime() - n * 7 * 24 * 60 * 60 * 1e3;
1486
- const o = new Date(t.getTime());
1487
- return o.setUTCMonth(o.getUTCMonth() - n), o.getTime();
1634
+ const o = a[2];
1635
+ if (o === "d")
1636
+ return e.getTime() - n * 24 * 60 * 60 * 1e3;
1637
+ if (o === "w")
1638
+ return e.getTime() - n * 7 * 24 * 60 * 60 * 1e3;
1639
+ const r = new Date(e.getTime());
1640
+ return r.setUTCMonth(r.getUTCMonth() - n), r.getTime();
1488
1641
  }
1489
- function ie(e) {
1490
- if (!e)
1642
+ function ct(t) {
1643
+ if (!t)
1491
1644
  return;
1492
- const t = Number.parseInt(e, 10);
1493
- if (!(!Number.isFinite(t) || t <= 0))
1494
- return t;
1645
+ const e = Number.parseInt(t, 10);
1646
+ if (!(!Number.isFinite(e) || e <= 0))
1647
+ return e;
1495
1648
  }
1496
- function ja(e, t) {
1497
- const a = new Date(e), n = new Date(t);
1649
+ function Xa(t, e) {
1650
+ const a = new Date(t), n = new Date(e);
1498
1651
  return a.getUTCFullYear() === n.getUTCFullYear() && a.getUTCMonth() === n.getUTCMonth() && a.getUTCDate() === n.getUTCDate();
1499
1652
  }
1500
- async function La(e, t, a) {
1501
- const n = S().find((o) => o.id === e);
1653
+ async function Za(t, e, a) {
1654
+ const n = x().find((r) => r.id === t);
1502
1655
  if (!n)
1503
1656
  return;
1504
- const r = await Qa(Ba(n), a);
1505
- return r && Ja(r, t) ? { capability: n, target: r } : void 0;
1657
+ const o = await en(tn(n), a);
1658
+ return o && nn(o, e) ? { capability: n, target: o } : void 0;
1506
1659
  }
1507
- function Ba(e) {
1508
- const { hash: t, queryParams: a, routeKey: n } = e.resolutions.navigate;
1660
+ function tn(t) {
1661
+ const { hash: e, queryParams: a, routeKey: n } = t.resolutions.navigate;
1509
1662
  switch (n) {
1510
1663
  case "content":
1511
- switch (e.id) {
1664
+ switch (t.id) {
1512
1665
  case "my-content":
1513
- return { destinationType: "portal-content", t9nKey: "myContent" };
1666
+ return { destinationType: "portal-content" };
1514
1667
  case "create-feature-layer":
1515
- return { destinationType: "portal-content", t9nKey: "createFeatureLayer" };
1668
+ return { destinationType: "portal-content" };
1516
1669
  case "create-folder":
1517
- return { destinationType: "portal-content", t9nKey: "createFolder" };
1670
+ return { destinationType: "portal-content" };
1518
1671
  default:
1519
1672
  return { destinationType: "portal-content" };
1520
1673
  }
1521
1674
  case "groups":
1522
- if (t === "featured")
1523
- return { destinationType: "portal-groups", hash: "featured", t9nKey: "featuredGroups" };
1524
- if (t === "organization")
1525
- return { destinationType: "portal-groups", hash: "organization", t9nKey: "organizationGroups" };
1526
- switch (e.id) {
1675
+ if (e === "featured")
1676
+ return { destinationType: "portal-groups", hash: "featured" };
1677
+ if (e === "organization")
1678
+ return { destinationType: "portal-groups", hash: "organization" };
1679
+ switch (t.id) {
1527
1680
  case "my groups":
1528
- return { destinationType: "portal-groups", hash: "my", t9nKey: "myGroups" };
1681
+ return { destinationType: "portal-groups", hash: "my" };
1529
1682
  case "create-group":
1530
- return { destinationType: "portal-groups", t9nKey: "createGroup" };
1683
+ return { destinationType: "portal-groups" };
1531
1684
  default:
1532
1685
  return { destinationType: "portal-groups" };
1533
1686
  }
1534
1687
  case "organization":
1535
1688
  return {
1536
1689
  destinationType: "portal-org",
1537
- hash: t,
1690
+ hash: e,
1538
1691
  queryParams: a,
1539
- buttonLabel: e.buttonLabel
1692
+ buttonLabel: t.buttonLabel
1540
1693
  };
1541
1694
  default:
1542
1695
  return;
1543
1696
  }
1544
1697
  }
1545
- async function Qa(e, t) {
1546
- if (!e || !t || !Wa(e))
1547
- return e;
1548
- const a = await Fa(t);
1698
+ async function en(t, e) {
1699
+ if (!t || !e || !an(t))
1700
+ return t;
1701
+ const a = await Ja(e);
1549
1702
  if (!a.period && !a.startTime && !a.endTime)
1550
- return e;
1703
+ return t;
1551
1704
  const n = {
1552
- ...e.queryParams,
1705
+ ...t.queryParams ?? {},
1553
1706
  ...a.period ? { period: a.period } : {},
1554
1707
  ...a.startTime ? { startTime: a.startTime } : {},
1555
1708
  ...a.endTime ? { endTime: a.endTime } : {}
1556
1709
  };
1557
- return { ...e, queryParams: n };
1710
+ return { ...t, queryParams: n };
1558
1711
  }
1559
- function Wa(e) {
1560
- return e.destinationType === "portal-org" && e.hash === "status";
1712
+ function an(t) {
1713
+ return t.destinationType === "portal-org" && t.hash === "status";
1561
1714
  }
1562
- function Ja(e, t) {
1563
- return !t || !!t[e.destinationType];
1715
+ function nn(t, e) {
1716
+ return !e || !!e[t.destinationType];
1564
1717
  }
1565
- const _a = async (e, t) => {
1566
- if (e.outputMessage || e.status === "failed")
1718
+ const on = async (t, e) => {
1719
+ if (t.outputMessage || t.status === "failed")
1567
1720
  return {};
1568
- const a = e.targets.find(({ capability: o }) => e.chosenCapabilityIds.includes(o.id)) ?? e.targets[0];
1721
+ const a = t.targets.find(({ capability: r }) => t.chosenCapabilityIds.includes(r.id)) ?? t.targets[0];
1569
1722
  if (!a)
1570
1723
  return {
1571
1724
  outputMessage: "I couldn't find a matching Portal page. Try asking to open your content, groups, or organization settings.",
1572
- sharedStatePatch: { navLastAnsweredRequest: { value: ue(e) } },
1725
+ sharedStatePatch: { navLastAnsweredRequest: { value: ut(t) } },
1573
1726
  status: "success",
1574
1727
  summary: "Navigation could not find a matching capability; route another agent if appropriate."
1575
1728
  };
1576
- const n = ue(e), r = await La(a.capability.id, void 0, n);
1577
- return r ? (await m({ text: "Preparing navigation...", agentName: "navigation" }, t), await D(r.target, t), {
1578
- outputMessage: e.chosenCapabilityIds.length ? a.capability.description : `The closest place to start is ${a.capability.title}. Click the button below to open it.`,
1729
+ const n = ut(t), o = await Za(a.capability.id, void 0, n);
1730
+ return o ? (await m({ text: "Preparing navigation...", agentName: "navigation" }, e), await R(o.target, e), {
1731
+ outputMessage: t.chosenCapabilityIds.length ? a.capability.description : `The closest place to start is ${a.capability.title}. Click the button below to open it.`,
1579
1732
  status: "success",
1580
- summary: `Navigation suggested ${a.capability.id}${e.retrievalDegraded ? " using keyword-only retrieval" : ""}.`,
1733
+ summary: `Navigation suggested ${a.capability.id}${t.retrievalDegraded ? " using keyword-only retrieval" : ""}.`,
1581
1734
  sharedStatePatch: { navLastAnsweredRequest: { value: n } }
1582
1735
  }) : (console.warn(`Navigation capability ${a.capability.id} was not found in the resolver.`), {
1583
1736
  outputMessage: "I found a possible destination, but couldn't resolve a valid Portal navigation target. Try asking to open your content, groups, or organization settings.",
@@ -1586,208 +1739,208 @@ const _a = async (e, t) => {
1586
1739
  sharedStatePatch: { navLastAnsweredRequest: { value: n } }
1587
1740
  });
1588
1741
  };
1589
- function ue(e) {
1590
- return I(e.agentExecutionContext.messages) || e.agentExecutionContext.userRequest;
1742
+ function ut(t) {
1743
+ return I(t.agentExecutionContext.messages) || t.agentExecutionContext.userRequest;
1591
1744
  }
1592
- async function qe(e) {
1593
- return e.length === 0 ? [] : (await rt.getDefault().load(), await Le(e));
1745
+ async function qt(t) {
1746
+ return t.length === 0 ? [] : (await ae.getDefault().load(), await Vt(t));
1594
1747
  }
1595
- const Ya = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1748
+ const rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1596
1749
  __proto__: null,
1597
- generateEmbeddings: qe
1750
+ generateEmbeddings: qt
1598
1751
  }, Symbol.toStringTag, { value: "Module" }));
1599
- function Ha(e) {
1600
- const t = [], a = `${e.title}. ${e.description}`;
1601
- a.trim().length > 0 && t.push({ field: "summary", text: a });
1602
- const n = e.hints;
1752
+ function sn(t) {
1753
+ const e = [], a = `${t.title}. ${t.description}`;
1754
+ a.trim().length > 0 && e.push({ field: "summary", text: a });
1755
+ const n = t.hints;
1603
1756
  if (Array.isArray(n))
1604
- for (const r of n)
1605
- typeof r == "string" && r.trim().length > 0 && t.push({ field: "hint", text: r });
1606
- return t;
1757
+ for (const o of n)
1758
+ typeof o == "string" && o.trim().length > 0 && e.push({ field: "hint", text: o });
1759
+ return e;
1607
1760
  }
1608
- let k, _, z = 0;
1609
- async function Xa(e = {}) {
1610
- const t = z;
1611
- return k ??= en(e.embed ?? tn).then((a) => (t === z && (_ = a), a)).catch((a) => {
1612
- throw t === z && (k = void 0), a;
1613
- }), await k;
1761
+ let z, Y, k = 0;
1762
+ async function cn(t = {}) {
1763
+ const e = k;
1764
+ return z ??= ln(t.embed ?? dn).then((a) => (e === k && (Y = a), a)).catch((a) => {
1765
+ throw e === k && (z = void 0), a;
1766
+ }), await z;
1614
1767
  }
1615
- function Za() {
1616
- return _;
1768
+ function un() {
1769
+ return Y;
1617
1770
  }
1618
- function ce() {
1619
- z += 1, _ = void 0, k = void 0;
1771
+ function lt() {
1772
+ k += 1, Y = void 0, z = void 0;
1620
1773
  }
1621
- async function en(e) {
1622
- const t = an(), a = await e(t.map((n) => n.text));
1623
- if (a.length !== t.length)
1624
- throw new Error(`Expected ${t.length} vectors, got ${a.length}`);
1625
- return t.map((n, r) => ({
1774
+ async function ln(t) {
1775
+ const e = pn(), a = await t(e.map((n) => n.text));
1776
+ if (a.length !== e.length)
1777
+ throw new Error(`Expected ${e.length} vectors, got ${a.length}`);
1778
+ return e.map((n, o) => ({
1626
1779
  ...n,
1627
- vector: a[r]
1780
+ vector: a[o]
1628
1781
  }));
1629
1782
  }
1630
- async function tn(e) {
1631
- const { generateEmbeddings: t } = await Promise.resolve().then(() => Ya);
1632
- return await t(e);
1783
+ async function dn(t) {
1784
+ const { generateEmbeddings: e } = await Promise.resolve().then(() => rn);
1785
+ return await e(t);
1633
1786
  }
1634
- function an() {
1635
- return S().flatMap(
1636
- (e) => Ha(e).map(({ field: t, text: a }) => ({
1637
- capabilityId: e.id,
1638
- field: t,
1787
+ function pn() {
1788
+ return x().flatMap(
1789
+ (t) => sn(t).map(({ field: e, text: a }) => ({
1790
+ capabilityId: t.id,
1791
+ field: e,
1639
1792
  text: a
1640
1793
  }))
1641
1794
  );
1642
1795
  }
1643
- const le = 1.2, de = 0.75, nn = 60, rn = 0.65, K = {
1796
+ const dt = 1.2, pt = 0.75, mn = 60, gn = 0.65, L = {
1644
1797
  description: 1,
1645
1798
  hint: 2,
1646
1799
  title: 3
1647
1800
  };
1648
- let L;
1649
- function on() {
1650
- L = void 0;
1801
+ let K;
1802
+ function hn() {
1803
+ K = void 0;
1651
1804
  }
1652
- async function sn(e, t = {}) {
1653
- const a = dn(Ee(e));
1654
- let n = [], r = !1, o;
1655
- if (e.trim()) {
1656
- const u = t.loadEmbeddings, i = Za();
1657
- if (!u && !i)
1658
- r = !0, o = "Capability embeddings are still loading.";
1805
+ async function fn(t, e = {}) {
1806
+ const a = bn(Et(t));
1807
+ let n = [], o = !1, r;
1808
+ if (t.trim()) {
1809
+ const c = e.loadEmbeddings, i = un();
1810
+ if (!c && !i)
1811
+ o = !0, r = "Capability embeddings are still loading.";
1659
1812
  else
1660
1813
  try {
1661
- if (u) {
1662
- const [l, c] = await Promise.all([
1663
- (t.embedQuery ?? me)(e),
1664
- u()
1814
+ if (c) {
1815
+ const [l, u] = await Promise.all([
1816
+ (e.embedQuery ?? gt)(t),
1817
+ c()
1665
1818
  ]);
1666
- n = pe(l, c);
1819
+ n = mt(l, u);
1667
1820
  } else if (i) {
1668
- const l = await (t.embedQuery ?? me)(e);
1669
- n = pe(l, i);
1821
+ const l = await (e.embedQuery ?? gt)(t);
1822
+ n = mt(l, i);
1670
1823
  }
1671
1824
  } catch {
1672
- r = !0, o = "Semantic search is unavailable.";
1825
+ o = !0, r = "Semantic search is unavailable.";
1673
1826
  }
1674
1827
  }
1675
1828
  return {
1676
- degraded: r,
1677
- ...o ? { degradedReason: o } : {},
1829
+ degraded: o,
1830
+ ...r ? { degradedReason: r } : {},
1678
1831
  // RRF combines ranks rather than raw scores because BM25 and cosine
1679
1832
  // similarity are on different scales.
1680
- matches: mn(a, n, t.topN ?? 5)
1833
+ matches: Sn(a, n, e.topN ?? 5)
1681
1834
  };
1682
1835
  }
1683
- function un() {
1684
- return L ??= cn(S()), L;
1836
+ function yn() {
1837
+ return K ??= wn(x()), K;
1685
1838
  }
1686
- function cn(e) {
1687
- const t = /* @__PURE__ */ new Map(), a = e.map((n) => {
1688
- const r = /* @__PURE__ */ new Map();
1689
- V(r, n.title, K.title), V(r, n.description, K.description);
1690
- for (const o of n.hints)
1691
- V(r, o, K.hint);
1692
- for (const o of r.keys())
1693
- t.set(o, (t.get(o) ?? 0) + 1);
1839
+ function wn(t) {
1840
+ const e = /* @__PURE__ */ new Map(), a = t.map((n) => {
1841
+ const o = /* @__PURE__ */ new Map();
1842
+ j(o, n.title, L.title), j(o, n.description, L.description);
1843
+ for (const r of n.hints)
1844
+ j(o, r, L.hint);
1845
+ for (const r of o.keys())
1846
+ e.set(r, (e.get(r) ?? 0) + 1);
1694
1847
  return {
1695
1848
  capability: n,
1696
- length: ln(r),
1697
- termFrequencies: r
1849
+ length: vn(o),
1850
+ termFrequencies: o
1698
1851
  };
1699
1852
  });
1700
1853
  return {
1701
- averageDocumentLength: a.length ? a.reduce((n, r) => n + r.length, 0) / a.length : 0,
1702
- documentFrequency: t,
1854
+ averageDocumentLength: a.length ? a.reduce((n, o) => n + o.length, 0) / a.length : 0,
1855
+ documentFrequency: e,
1703
1856
  documents: a
1704
1857
  };
1705
1858
  }
1706
- function V(e, t, a) {
1707
- for (const n of Ee(t))
1708
- e.set(n, (e.get(n) ?? 0) + a);
1859
+ function j(t, e, a) {
1860
+ for (const n of Et(e))
1861
+ t.set(n, (t.get(n) ?? 0) + a);
1709
1862
  }
1710
- function ln(e) {
1711
- return [...e.values()].reduce((t, a) => t + a, 0);
1863
+ function vn(t) {
1864
+ return [...t.values()].reduce((e, a) => e + a, 0);
1712
1865
  }
1713
- function Ee(e) {
1714
- return e.toLowerCase().split(/[^a-z0-9]+/u).filter(Boolean);
1866
+ function Et(t) {
1867
+ return t.toLowerCase().split(/[^a-z0-9]+/u).filter(Boolean);
1715
1868
  }
1716
- function dn(e) {
1717
- const t = un(), a = new Set(e), n = t.documents.length;
1718
- return t.documents.map(({ capability: r, length: o, termFrequencies: u }) => {
1869
+ function bn(t) {
1870
+ const e = yn(), a = new Set(t), n = e.documents.length;
1871
+ return e.documents.map(({ capability: o, length: r, termFrequencies: c }) => {
1719
1872
  let i = 0;
1720
1873
  for (const l of a) {
1721
- const c = u.get(l), d = t.documentFrequency.get(l);
1722
- if (!c || !d)
1874
+ const u = c.get(l), d = e.documentFrequency.get(l);
1875
+ if (!u || !d)
1723
1876
  continue;
1724
- const g = Math.log(1 + (n - d + 0.5) / (d + 0.5)), p = le * (1 - de + de * (o / t.averageDocumentLength));
1725
- i += g * (c * (le + 1) / (c + p));
1877
+ const g = Math.log(1 + (n - d + 0.5) / (d + 0.5)), p = dt * (1 - pt + pt * (r / e.averageDocumentLength));
1878
+ i += g * (u * (dt + 1) / (u + p));
1726
1879
  }
1727
- return { capability: r, score: i };
1728
- }).filter(({ score: r }) => r > 0).sort(ke);
1880
+ return { capability: o, score: i };
1881
+ }).filter(({ score: o }) => o > 0).sort(zt);
1729
1882
  }
1730
- function pe(e, t) {
1883
+ function mt(t, e) {
1731
1884
  const a = /* @__PURE__ */ new Map();
1732
- for (const r of t) {
1733
- const o = pn(e, r.vector);
1734
- if (o === void 0)
1885
+ for (const o of e) {
1886
+ const r = In(t, o.vector);
1887
+ if (r === void 0)
1735
1888
  continue;
1736
- const u = a.get(r.capabilityId);
1737
- (u === void 0 || o > u) && a.set(r.capabilityId, o);
1889
+ const c = a.get(o.capabilityId);
1890
+ (c === void 0 || r > c) && a.set(o.capabilityId, r);
1738
1891
  }
1739
- const n = new Map(S().map((r) => [r.id, r]));
1740
- return [...a.entries()].flatMap(([r, o]) => {
1741
- const u = n.get(r);
1742
- return u && o >= rn ? [{ capability: u, score: o }] : [];
1743
- }).sort(ke);
1892
+ const n = new Map(x().map((o) => [o.id, o]));
1893
+ return [...a.entries()].flatMap(([o, r]) => {
1894
+ const c = n.get(o);
1895
+ return c && r >= gn ? [{ capability: c, score: r }] : [];
1896
+ }).sort(zt);
1744
1897
  }
1745
- function pn(e, t) {
1746
- if (e.length === 0 || e.length !== t.length)
1898
+ function In(t, e) {
1899
+ if (t.length === 0 || t.length !== e.length)
1747
1900
  return;
1748
- let a = 0, n = 0, r = 0;
1749
- for (let u = 0; u < e.length; u += 1)
1750
- a += e[u] * t[u], n += e[u] ** 2, r += t[u] ** 2;
1751
- const o = Math.sqrt(n) * Math.sqrt(r);
1752
- return o === 0 ? void 0 : a / o;
1901
+ let a = 0, n = 0, o = 0;
1902
+ for (let c = 0; c < t.length; c += 1)
1903
+ a += t[c] * e[c], n += t[c] ** 2, o += e[c] ** 2;
1904
+ const r = Math.sqrt(n) * Math.sqrt(o);
1905
+ return r === 0 ? void 0 : a / r;
1753
1906
  }
1754
- async function me(e) {
1755
- const [t] = await qe([e]);
1756
- if (!t)
1907
+ async function gt(t) {
1908
+ const [e] = await qt([t]);
1909
+ if (!e)
1757
1910
  throw new Error("Expected one query embedding.");
1758
- return t;
1911
+ return e;
1759
1912
  }
1760
- function mn(e, t, a) {
1913
+ function Sn(t, e, a) {
1761
1914
  const n = /* @__PURE__ */ new Map();
1762
- return ge(n, e, "keyword"), ge(n, t, "semantic"), [...n.values()].sort((r, o) => o.score !== r.score ? o.score - r.score : (o.semanticScore ?? 0) !== (r.semanticScore ?? 0) ? (o.semanticScore ?? 0) - (r.semanticScore ?? 0) : (o.keywordScore ?? 0) !== (r.keywordScore ?? 0) ? (o.keywordScore ?? 0) - (r.keywordScore ?? 0) : r.capability.id.localeCompare(o.capability.id)).slice(0, Math.max(0, a));
1915
+ return ht(n, t, "keyword"), ht(n, e, "semantic"), [...n.values()].sort((o, r) => r.score !== o.score ? r.score - o.score : (r.semanticScore ?? 0) !== (o.semanticScore ?? 0) ? (r.semanticScore ?? 0) - (o.semanticScore ?? 0) : (r.keywordScore ?? 0) !== (o.keywordScore ?? 0) ? (r.keywordScore ?? 0) - (o.keywordScore ?? 0) : o.capability.id.localeCompare(r.capability.id)).slice(0, Math.max(0, a));
1763
1916
  }
1764
- function ge(e, t, a) {
1765
- for (const [n, { capability: r, score: o }] of t.entries()) {
1766
- const u = n + 1, i = e.get(r.id) ?? { capability: r, score: 0 };
1767
- i.score += 1 / (nn + u), a === "keyword" ? (i.keywordRank = u, i.keywordScore = o) : (i.semanticRank = u, i.semanticScore = o), e.set(r.id, i);
1917
+ function ht(t, e, a) {
1918
+ for (const [n, { capability: o, score: r }] of e.entries()) {
1919
+ const c = n + 1, i = t.get(o.id) ?? { capability: o, score: 0 };
1920
+ i.score += 1 / (mn + c), a === "keyword" ? (i.keywordRank = c, i.keywordScore = r) : (i.semanticRank = c, i.semanticScore = r), t.set(o.id, i);
1768
1921
  }
1769
1922
  }
1770
- function ke(e, t) {
1771
- return t.score - e.score || e.capability.id.localeCompare(t.capability.id);
1923
+ function zt(t, e) {
1924
+ return e.score - t.score || t.capability.id.localeCompare(e.capability.id);
1772
1925
  }
1773
- const gn = async (e, t) => {
1774
- await m({ text: "Finding a place to navigate...", agentName: "navigation" }, t);
1775
- const a = I(e.agentExecutionContext.messages).trim();
1926
+ const xn = async (t, e) => {
1927
+ await m({ text: "Finding a place to navigate...", agentName: "navigation" }, e);
1928
+ const a = I(t.agentExecutionContext.messages).trim();
1776
1929
  try {
1777
- const n = await sn(a, { topN: 5 });
1930
+ const n = await fn(a, { topN: 5 });
1778
1931
  return console.table(
1779
- n.matches.map(({ capability: r, keywordRank: o, keywordScore: u, semanticRank: i, semanticScore: l, score: c }) => ({
1780
- capability: r.title,
1781
- fusedScore: c,
1782
- keywordRank: o,
1783
- keywordScore: u,
1932
+ n.matches.map(({ capability: o, keywordRank: r, keywordScore: c, semanticRank: i, semanticScore: l, score: u }) => ({
1933
+ capability: o.title,
1934
+ fusedScore: u,
1935
+ keywordRank: r,
1936
+ keywordScore: c,
1784
1937
  semanticRank: i,
1785
1938
  semanticScore: l
1786
1939
  }))
1787
1940
  ), n.degradedReason && console.info("[arcgis-portal-ai-assistant] navigation semantic search:", n.degradedReason), {
1788
1941
  chosenCapabilityIds: [],
1789
1942
  retrievalDegraded: n.degradedReason ?? "",
1790
- targets: hn(a, n.matches)
1943
+ targets: Tn(a, n.matches)
1791
1944
  };
1792
1945
  } catch {
1793
1946
  return {
@@ -1798,233 +1951,220 @@ const gn = async (e, t) => {
1798
1951
  };
1799
1952
  }
1800
1953
  };
1801
- function hn(e, t) {
1802
- const a = $(e), n = t.filter(
1803
- ({ capability: o }) => [o.title, ...o.hints].some(
1804
- (u) => $(u) === a
1954
+ function Tn(t, e) {
1955
+ const a = $(t), n = e.filter(
1956
+ ({ capability: r }) => [r.title, ...r.hints].some(
1957
+ (c) => $(c) === a
1805
1958
  )
1806
1959
  );
1807
1960
  if (n.length !== 1)
1808
- return t;
1809
- const [r] = n;
1810
- return [r, ...t.filter((o) => o !== r)];
1961
+ return e;
1962
+ const [o] = n;
1963
+ return [o, ...e.filter((r) => r !== o)];
1811
1964
  }
1812
- const j = (e, t) => t ?? e, ze = h.Root({
1813
- ...N(),
1814
- chosenCapabilityIds: h({ reducer: j, default: () => [] }),
1965
+ const V = (t, e) => e ?? t, kt = h.Root({
1966
+ ...G(),
1967
+ chosenCapabilityIds: h({ reducer: V, default: () => [] }),
1815
1968
  // Empty when hybrid keyword-and-semantic retrieval succeeds; otherwise
1816
1969
  // contains the semantic-search failure reason for response diagnostics.
1817
- retrievalDegraded: h({ reducer: j, default: () => "" }),
1818
- targets: h({ reducer: j, default: () => [] })
1819
- }), fn = () => new G(ze).addNode("retrieveNavigationTargets", gn).addNode("chooseNavigationTargets", $a).addNode("respondWithNavigation", _a).addEdge(A, "retrieveNavigationTargets").addEdge("retrieveNavigationTargets", "chooseNavigationTargets").addEdge("chooseNavigationTargets", "respondWithNavigation").addEdge("respondWithNavigation", w);
1820
- function yn() {
1821
- const e = S().map(({ hints: t, title: a }) => t[0] ?? a).join(", ");
1970
+ retrievalDegraded: h({ reducer: V, default: () => "" }),
1971
+ targets: h({ reducer: V, default: () => [] })
1972
+ }), Cn = () => new A(kt).addNode("retrieveNavigationTargets", xn).addNode("chooseNavigationTargets", Ba).addNode("respondWithNavigation", on).addEdge(N, "retrieveNavigationTargets").addEdge("retrieveNavigationTargets", "chooseNavigationTargets").addEdge("chooseNavigationTargets", "respondWithNavigation").addEdge("respondWithNavigation", w);
1973
+ function Mn() {
1974
+ const t = x().map(({ hints: e, title: a }) => e[0] ?? a).join(", ");
1822
1975
  return String.raw`- **portal-navigation** - Portal page navigation assistant:
1823
1976
  - routes requests to open, show, or navigate to a Portal page, including creation-flow pages
1824
1977
  - falls back to the closest Portal page where a workflow starts when another agent cannot perform the action
1825
1978
  - handles short navigation follow-ups after asking the user to open a page
1826
- - capability examples: ${e}
1979
+ - capability examples: ${t}
1827
1980
  - do not use for general "how do I" questions unless the user explicitly asks to reach a page
1828
1981
  `;
1829
1982
  }
1830
- const wn = {
1983
+ const An = {
1831
1984
  id: "navigation",
1832
1985
  name: "Portal Navigation",
1833
1986
  get description() {
1834
- return yn();
1987
+ return Mn();
1835
1988
  },
1836
- createGraph: fn,
1837
- workspace: ze
1838
- }, bn = Ke`:host{height:100%;border-width:1px;border-style:solid;border-color:var(--calcite-color-border-3);display:block;width:100%;--tw-shadow: 0 1px 6px -1px rgba(0, 0, 0, .16), 0 1px 2px -1px rgba(0, 0, 0, .08);--tw-shadow-colored: 0 1px 6px -1px var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.chat-entry{display:flex;flex-direction:column;gap:.75rem;width:100%}.chat-actions{display:flex;justify-content:flex-end;gap:.5rem}.header-actions{display:flex;gap:.5rem;padding-inline-start:.75rem}.navigation-block{display:flex;flex-direction:column;align-items:stretch;gap:.35rem;margin-top:.5rem}.navigation-button{width:100%;margin-block:.25rem}.navigation-block-description{font-size:.75rem;color:var(--calcite-color-text-3)}`;
1839
- function vn(e, t) {
1840
- if (!t)
1989
+ createGraph: Cn,
1990
+ workspace: kt
1991
+ }, Nn = Ot`:host{height:100%;border-width:1px;border-style:solid;border-color:var(--calcite-color-border-3);display:block;width:100%;--tw-shadow: 0 1px 6px -1px rgba(0, 0, 0, .16), 0 1px 2px -1px rgba(0, 0, 0, .08);--tw-shadow-colored: 0 1px 6px -1px var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.chat-entry{display:flex;flex-direction:column;gap:.75rem;width:100%}.chat-actions{display:flex;justify-content:flex-end;gap:.5rem}.header-actions{display:flex;gap:.5rem;padding-inline-start:.75rem}.navigation-block{display:flex;flex-direction:column;align-items:stretch;gap:.35rem;margin-top:.5rem}.navigation-button{width:100%;margin-block:.25rem}.navigation-block-description{font-size:.75rem;color:var(--calcite-color-text-3)}`;
1992
+ function Gn(t, e) {
1993
+ if (!e)
1841
1994
  return;
1842
- const { destinationType: a } = e;
1995
+ const { destinationType: a } = t;
1843
1996
  switch (a) {
1844
1997
  case "portal-content":
1845
- return t[a]?.(e.hash);
1998
+ return e[a]?.(t.hash, t.queryParams);
1846
1999
  case "portal-groups":
1847
- return t[a]?.(e.hash);
2000
+ return e[a]?.(t.hash);
1848
2001
  case "portal-org":
1849
- return t[a]?.(e.hash, e.queryParams);
2002
+ return e[a]?.(t.hash, t.queryParams);
1850
2003
  case "portal-gallery":
1851
- return t[a];
2004
+ return e[a];
1852
2005
  case "portal-map-viewer":
1853
2006
  case "portal-notebooks":
1854
2007
  case "portal-scene-viewer":
1855
- return t[a];
2008
+ return e[a];
1856
2009
  case "portal-item":
1857
- return t[a]?.(e.itemId);
2010
+ return e[a]?.(t.itemId);
1858
2011
  case "portal-group":
1859
- return t[a]?.(e.groupId);
2012
+ return e[a]?.(t.groupId);
1860
2013
  default:
1861
- return R(a);
2014
+ return D(a);
1862
2015
  }
1863
2016
  }
1864
- function In(e) {
1865
- const t = Ct.safeParse(e);
1866
- return t.success ? t.data : void 0;
2017
+ function Pn(t) {
2018
+ const e = Ne.safeParse(t);
2019
+ return e.success ? e.data : void 0;
1867
2020
  }
1868
- const xn = { myContent: "My content", createFeatureLayer: "Create feature layer", createFolder: "Create folder", myGroups: "My groups", createGroup: "Create group", featuredGroups: "Featured groups", organizationGroups: "Organization groups", configureMultifactorAuthentication: "Configure multifactor authentication" }, $e = {
1869
- navigationTargets: xn
1870
- };
1871
- function Sn(e, t) {
1872
- const a = he(e.t9nKey, t.navigationTargets) ?? he(e.t9nKey, $e.navigationTargets);
1873
- if (a)
1874
- return a;
1875
- const n = t.navigation;
1876
- switch (e.destinationType) {
2021
+ function qn(t, e) {
2022
+ const a = e.navigation;
2023
+ switch (t.destinationType) {
1877
2024
  case "portal-content":
1878
- switch (e.hash) {
2025
+ switch (t.hash) {
1879
2026
  case "favorites":
1880
- return n.openContentFavorites;
2027
+ return a.openContentFavorites;
1881
2028
  case "group":
1882
- return n.openContentGroup;
2029
+ return a.openContentGroup;
1883
2030
  case "living-atlas":
1884
- return n.openContentLivingAtlas;
2031
+ return a.openContentLivingAtlas;
1885
2032
  case "org":
1886
- return n.openContentOrganization;
2033
+ return a.openContentOrganization;
1887
2034
  default:
1888
- return n.openContent;
2035
+ return a.openContent;
1889
2036
  }
1890
2037
  case "portal-gallery":
1891
- return n.openGallery;
2038
+ return a.openGallery;
1892
2039
  case "portal-groups":
1893
- switch (e.hash) {
2040
+ switch (t.hash) {
1894
2041
  case "featured":
1895
- return n.openGroupsFeatured;
2042
+ return a.openGroupsFeatured;
1896
2043
  case "my":
1897
- return n.openGroupsMy;
2044
+ return a.openGroupsMy;
1898
2045
  case "organization":
1899
- return n.openGroupsOrganization;
2046
+ return a.openGroupsOrganization;
1900
2047
  default:
1901
- return n.openGroups;
2048
+ return a.openGroups;
1902
2049
  }
1903
2050
  case "portal-map-viewer":
1904
- return n.openMapViewer;
2051
+ return a.openMapViewer;
1905
2052
  case "portal-notebooks":
1906
- return n.openNotebooks;
2053
+ return a.openNotebooks;
1907
2054
  case "portal-scene-viewer":
1908
- return n.openSceneViewer;
2055
+ return a.openSceneViewer;
1909
2056
  case "portal-org":
1910
- return n.openOrgSettings;
2057
+ return a.openOrgSettings;
1911
2058
  case "portal-item":
1912
- return n.openItem;
2059
+ return a.openItem;
1913
2060
  case "portal-group":
1914
- return n.openGroup;
2061
+ return a.openGroup;
1915
2062
  default:
1916
- return R(e);
2063
+ return D(t);
1917
2064
  }
1918
2065
  }
1919
- function he(e, t) {
1920
- if (!(!e || !t || !Tn(e)))
1921
- return t[e];
1922
- }
1923
- function Tn(e) {
1924
- return e in $e.navigationTargets;
1925
- }
1926
- class Mn extends Fe {
2066
+ class En extends Ut {
1927
2067
  constructor() {
1928
- super(), this.t9n = je({ blocking: !0 }), this.assistantEl = P(), this.formEl = P(), this.voiceInputEl = P(), this.inputEl = P(), this.navigationSlotElements = /* @__PURE__ */ new Map(), this.handleSlottableRequest = (t) => {
1929
- const a = t.detail, n = a.data?.block;
2068
+ super(), this.t9n = jt({ blocking: !0 }), this.assistantEl = P(), this.formEl = P(), this.voiceInputEl = P(), this.inputEl = P(), this.navigationSlotElements = /* @__PURE__ */ new Map(), this.handleSlottableRequest = (e) => {
2069
+ const a = e.detail, n = a.data?.block;
1930
2070
  if (!n)
1931
2071
  return;
1932
- const r = this.getNavigationAction(n);
1933
- r && this.upsertNavigationSlotElement(a.slotName, r);
1934
- }, this.inputText = "", this.showVoiceInput = !0, this.isListening = !1, this.isVoiceInputDisabled = !1, this.interrupt = null, this.autoDestroyDisabled = !1, this.defaultClosed = !1, this.arcgisPortalNavigationRequest = Oe(), S();
2072
+ const o = this.getNavigationAction(n);
2073
+ o && this.upsertNavigationSlotElement(a.slotName, o);
2074
+ }, this.inputText = "", this.showVoiceInput = !0, this.isListening = !1, this.isVoiceInputDisabled = !1, this.interrupt = null, this.autoDestroyDisabled = !1, this.defaultClosed = !1, this.arcgisPortalNavigationRequest = Ft(), x();
1935
2075
  }
1936
2076
  static {
1937
2077
  this.properties = { inputText: 16, showVoiceInput: 16, isListening: 16, isVoiceInputDisabled: 16, interrupt: 16, autoDestroyDisabled: 5, portal: 0, user: 0, config: 0, navigationTargetMap: 0, disabledAgents: 0, defaultClosed: 5, navigationCapabilities: 0 };
1938
2078
  }
1939
2079
  static {
1940
- this.styles = bn;
2080
+ this.styles = Nn;
1941
2081
  }
1942
2082
  async load() {
1943
2083
  await this.refreshCapabilityEmbeddings();
1944
2084
  }
1945
- willUpdate(t) {
1946
- !this.hasUpdated || !t.has("navigationCapabilities") || this.refreshCapabilityEmbeddings();
2085
+ willUpdate(e) {
2086
+ !this.hasUpdated || !e.has("navigationCapabilities") || this.refreshCapabilityEmbeddings();
1947
2087
  }
1948
2088
  async clearEmbeddingsCache() {
1949
- ce();
2089
+ lt();
1950
2090
  }
1951
- isAgentEnabled(t) {
1952
- return !this.disabledAgents?.[t];
2091
+ isAgentEnabled(e) {
2092
+ return !this.disabledAgents?.[e];
1953
2093
  }
1954
2094
  async refreshCapabilityEmbeddings() {
1955
2095
  try {
1956
- S(this.navigationCapabilities), on(), ce(), await Xa();
1957
- } catch (t) {
1958
- console.warn("[arcgis-portal-ai-assistant] embeddings warm-up failed:", t);
2096
+ x(this.navigationCapabilities), hn(), lt(), await cn();
2097
+ } catch (e) {
2098
+ console.warn("[arcgis-portal-ai-assistant] embeddings warm-up failed:", e);
1959
2099
  }
1960
2100
  }
1961
- getNavigationAction(t) {
1962
- if (t?.type !== be)
2101
+ getNavigationAction(e) {
2102
+ if (e?.type !== vt)
1963
2103
  return;
1964
- const a = t.data, n = In(a);
2104
+ const a = e.data, n = Pn(a);
1965
2105
  if (!n)
1966
2106
  return;
1967
- const r = vn(a, this.navigationTargetMap);
1968
- if (r)
2107
+ const o = Gn(a, this.navigationTargetMap);
2108
+ if (o)
1969
2109
  return {
1970
- href: r,
2110
+ href: o,
1971
2111
  targetDetail: a,
1972
- label: a?.buttonLabel || Sn(n, this.t9n)
2112
+ label: a?.buttonLabel || qn(n, this.t9n)
1973
2113
  };
1974
2114
  }
1975
- upsertNavigationSlotElement(t, a) {
2115
+ upsertNavigationSlotElement(e, a) {
1976
2116
  const n = this.assistantEl.value;
1977
2117
  if (!n)
1978
2118
  return;
1979
- const r = `navigation:${t}`;
1980
- let o = this.navigationSlotElements.get(r);
1981
- o || (o = document.createElement("div"), o.slot = t, this.navigationSlotElements.set(r, o), n.append(o)), Ve(b`<div><calcite-button class="navigation-button" appearance=outline width=full .href=${a.href} icon-end=launch @click=${(u) => {
1982
- u.preventDefault(), this.arcgisPortalNavigationRequest.emit({
2119
+ const o = `navigation:${e}`;
2120
+ let r = this.navigationSlotElements.get(o);
2121
+ r || (r = document.createElement("div"), r.slot = e, this.navigationSlotElements.set(o, r), n.append(r)), Lt(v`<div><calcite-button class="navigation-button" appearance=outline width=full .href=${a.href} icon-end=launch @click=${(c) => {
2122
+ c.preventDefault(), this.arcgisPortalNavigationRequest.emit({
1983
2123
  href: a.href,
1984
2124
  targetDetail: a.targetDetail
1985
2125
  });
1986
- }}>${a.label}</calcite-button>${a.description ? b`<div class="navigation-block-description">${a.description}</div>` : null}</div>`, o);
2126
+ }}>${a.label}</calcite-button>${a.description ? v`<div class="navigation-block-description">${a.description}</div>` : null}</div>`, r);
1987
2127
  }
1988
2128
  render() {
1989
- const { t9n: t, inputText: a, portal: n, user: r, navigationTargetMap: o, showVoiceInput: u, isListening: i, isVoiceInputDisabled: l } = this;
1990
- return b`<arcgis-assistant log-enabled keep-suggested-prompts .heading=${t.heading} .entryMessage=${t.entryMessage} @arcgisSlottableRequest=${this.handleSlottableRequest} @arcgisInterrupt=${({ detail: c }) => {
1991
- this.interrupt = c;
2129
+ const { t9n: e, inputText: a, portal: n, user: o, navigationTargetMap: r, showVoiceInput: c, isListening: i, isVoiceInputDisabled: l } = this;
2130
+ return v`<arcgis-assistant log-enabled keep-suggested-prompts .heading=${e.heading} .entryMessage=${e.entryMessage} @arcgisSlottableRequest=${this.handleSlottableRequest} @arcgisInterrupt=${({ detail: u }) => {
2131
+ this.interrupt = u;
1992
2132
  }} @arcgisInterruptCancel=${() => {
1993
2133
  this.interrupt = null;
1994
2134
  }} @arcgisInterruptSubmit=${() => {
1995
2135
  this.interrupt = null;
1996
- }} @arcgisPromptSelect=${({ detail: c }) => {
1997
- this.inputText = c.prompt, requestAnimationFrame(() => {
2136
+ }} @arcgisPromptSelect=${({ detail: u }) => {
2137
+ this.inputText = u.prompt, requestAnimationFrame(() => {
1998
2138
  this.inputEl.value?.focusTextArea();
1999
2139
  });
2000
- }} ${q(this.assistantEl)}><div slot=header-actions-start class="header-actions"><calcite-icon icon=effects></calcite-icon></div><form slot=chat-entry class="chat-entry" @submit=${(c) => {
2001
- c.preventDefault();
2140
+ }} ${q(this.assistantEl)}><div slot=header-actions-start class="header-actions"><calcite-icon icon=effects></calcite-icon></div><form slot=chat-entry class="chat-entry" @submit=${(u) => {
2141
+ u.preventDefault();
2002
2142
  const d = a.trim();
2003
2143
  d && (this.assistantEl.value?.submitMessage(d), this.inputText = "");
2004
- }} ${q(this.formEl)}><arcgis-portal-mentionable-text-area .portal=${n} .user=${r} rows=3 .popoverListLabel=${t.mentionEntities} .placeholder=${t.placeholder} .value=${a} @arcgisUserMentionableTextAreaKeyDown=${({ detail: c }) => {
2005
- c.key === "Enter" && !c.shiftKey && (c.preventDefault(), this.formEl.value?.requestSubmit());
2006
- }} @arcgisUserMentionableTextAreaChange=${({ detail: c }) => {
2007
- this.inputText = c ?? "";
2144
+ }} ${q(this.formEl)}><arcgis-portal-mentionable-text-area .portal=${n} .user=${o} rows=3 .popoverListLabel=${e.mentionEntities} .placeholder=${e.placeholder} .value=${a} @arcgisUserMentionableTextAreaKeyDown=${({ detail: u }) => {
2145
+ u.key === "Enter" && !u.shiftKey && (u.preventDefault(), this.formEl.value?.requestSubmit());
2146
+ }} @arcgisUserMentionableTextAreaChange=${({ detail: u }) => {
2147
+ this.inputText = u ?? "";
2008
2148
  }} ${q(this.inputEl)}></arcgis-portal-mentionable-text-area><div class="chat-actions"><arcgis-portal-voice-input @arcgisVoiceInputStart=${() => {
2009
2149
  this.isListening = !0, this.isVoiceInputDisabled = !1;
2010
2150
  }} @arcgisVoiceInputStop=${() => {
2011
2151
  this.isListening = !1, this.isVoiceInputDisabled = !1;
2012
- }} @arcgisVoiceInputError=${(c) => {
2013
- c.detail.errorCode === "not-supported" && (this.showVoiceInput = !1);
2014
- }} @arcgisVoiceInputInterimTranscription=${(c) => {
2015
- this.inputText = c.detail.text;
2016
- }} ${q(this.voiceInputEl)}></arcgis-portal-voice-input>${u && b`<calcite-button icon-start=microphone .label=${t.voiceInput} round .disabled=${l} .appearance=${i ? "solid" : "outline-fill"} @click=${async () => {
2152
+ }} @arcgisVoiceInputError=${(u) => {
2153
+ u.detail.errorCode === "not-supported" && (this.showVoiceInput = !1);
2154
+ }} @arcgisVoiceInputInterimTranscription=${(u) => {
2155
+ this.inputText = u.detail.text;
2156
+ }} ${q(this.voiceInputEl)}></arcgis-portal-voice-input>${c && v`<calcite-button icon-start=microphone .label=${e.voiceInput} round .disabled=${l} .appearance=${i ? "solid" : "outline-fill"} @click=${async () => {
2017
2157
  this.isVoiceInputDisabled = !0;
2018
- const c = this.voiceInputEl.value;
2019
- i ? await c?.stopListening() : await c?.startListening();
2020
- }}></calcite-button>` || ""}<calcite-button type=submit icon-start=send round .disabled=${!a.trim()} .label=${t.send}>${t.send}</calcite-button></div></form>${this.isAgentEnabled("itemAnalytics") && b`<arcgis-assistant-agent .agent=${Ga} .context=${{ portal: n, user: r, navigationTargetMap: o }}></arcgis-assistant-agent>` || ""}${this.isAgentEnabled("groupCreation") && b`<arcgis-assistant-agent .agent=${Pt} .context=${{ portal: n, user: r, navigationTargetMap: o }}></arcgis-assistant-agent>` || ""}${this.isAgentEnabled("docAssistant") && b`<arcgis-assistant-agent .agent=${Wt} .context=${{ portal: n, user: r, navigationTargetMap: o }}></arcgis-assistant-agent>` || ""}${this.isAgentEnabled("groupAnalytics") && b`<arcgis-assistant-agent .agent=${ha} .context=${{ portal: n, user: r, navigationTargetMap: o }}></arcgis-assistant-agent>` || ""}${this.isAgentEnabled("navigation") && b`<arcgis-assistant-agent .agent=${wn} .context=${{ portal: n, user: r, navigationTargetMap: o }}></arcgis-assistant-agent>` || ""}${this.interrupt && b`<arcgis-portal-ai-assistant-interrupt slot=interrupt .type=${this.interrupt.type} .message=${this.interrupt.message} .options=${this.interrupt.options} @arcgisSubmit=${({ detail: c }) => {
2021
- this.assistantEl.value?.submitInterrupt(c);
2158
+ const u = this.voiceInputEl.value;
2159
+ i ? await u?.stopListening() : await u?.startListening();
2160
+ }}></calcite-button>` || ""}<calcite-button type=submit icon-start=send round .disabled=${!a.trim()} .label=${e.send}>${e.send}</calcite-button></div></form>${this.isAgentEnabled("itemAnalytics") && v`<arcgis-assistant-agent .agent=${Da} .context=${{ portal: n, user: o, navigationTargetMap: r }}></arcgis-assistant-agent>` || ""}${this.isAgentEnabled("groupCreation") && v`<arcgis-assistant-agent .agent=${Ee} .context=${{ portal: n, user: o, navigationTargetMap: r }}></arcgis-assistant-agent>` || ""}${this.isAgentEnabled("docAssistant") && v`<arcgis-assistant-agent .agent=${aa} .context=${{ portal: n, user: o, navigationTargetMap: r }}></arcgis-assistant-agent>` || ""}${this.isAgentEnabled("groupAnalytics") && v`<arcgis-assistant-agent .agent=${Ta} .context=${{ portal: n, user: o, navigationTargetMap: r }}></arcgis-assistant-agent>` || ""}${this.isAgentEnabled("navigation") && v`<arcgis-assistant-agent .agent=${An} .context=${{ portal: n, user: o, navigationTargetMap: r }}></arcgis-assistant-agent>` || ""}${this.interrupt && v`<arcgis-portal-ai-assistant-interrupt slot=interrupt .type=${this.interrupt.type} .message=${this.interrupt.message} .options=${this.interrupt.options} @arcgisSubmit=${({ detail: u }) => {
2161
+ this.assistantEl.value?.submitInterrupt(u);
2022
2162
  }} @arcgisCancel=${() => {
2023
2163
  this.assistantEl.value?.cancelInterrupt();
2024
2164
  }}></arcgis-portal-ai-assistant-interrupt>` || ""}</arcgis-assistant>`;
2025
2165
  }
2026
2166
  }
2027
- Ue("arcgis-portal-ai-assistant", Mn);
2167
+ Rt("arcgis-portal-ai-assistant", En);
2028
2168
  export {
2029
- Mn as ArcgisPortalAiAssistant
2169
+ En as ArcgisPortalAiAssistant
2030
2170
  };