@arcgis/ai-components 5.2.0-next.3 → 5.2.0-next.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/dist/agent-utils/FunctionAgent.d.ts +2 -2
  2. package/dist/agent-utils/LLMAgent.d.ts +2 -2
  3. package/dist/agent-utils/LLMAgent.js +23 -22
  4. package/dist/agent-utils/WorkflowAgent.d.ts +2 -2
  5. package/dist/agent-utils/index.d.ts +177 -0
  6. package/dist/agent-utils/index.js +167 -0
  7. package/dist/agent-utils/middlewares/trace.d.ts +2 -0
  8. package/dist/agent-utils/middlewares/trace.js +25 -33
  9. package/dist/agent-utils/tools/FunctionTool.d.ts +2 -2
  10. package/dist/agent-utils/types.d.ts +36 -7
  11. package/dist/agent-utils/workflows/ConditionalWorkflow.d.ts +2 -2
  12. package/dist/agent-utils/workflows/LoopWorkflow.d.ts +2 -2
  13. package/dist/agent-utils/workflows/ParallelWorkflow.d.ts +2 -2
  14. package/dist/agent-utils/workflows/RouterWorkflow.d.ts +2 -2
  15. package/dist/agent-utils/workflows/SequentialWorkflow.d.ts +2 -2
  16. package/dist/agent-utils/workflows/SwitchWorkflow.d.ts +2 -2
  17. package/dist/cdn/27NEUQN3.js +2 -0
  18. package/dist/cdn/2NMR43NW.js +2 -0
  19. package/dist/cdn/3AXQTBIA.js +134 -0
  20. package/dist/cdn/434TAA3J.js +2 -0
  21. package/dist/cdn/4I4MCV7V.js +71 -0
  22. package/dist/cdn/4RZPOYZ7.js +9 -0
  23. package/dist/cdn/5SBLS4NW.js +2 -0
  24. package/dist/cdn/{AMP6IALT.js → 5W7S2RS4.js} +1 -1
  25. package/dist/cdn/6LZ6GOHF.js +56 -0
  26. package/dist/cdn/7IFCBXV7.js +2 -0
  27. package/dist/cdn/ADYIXCSG.js +2 -0
  28. package/dist/cdn/AFLQZIKS.js +180 -0
  29. package/dist/cdn/AMVOJNWN.js +2 -0
  30. package/dist/cdn/C7E7MJSR.js +2 -0
  31. package/dist/cdn/CAECQD75.js +2 -0
  32. package/dist/cdn/CIW3QMKV.js +2 -0
  33. package/dist/cdn/CJIV4KJZ.js +179 -0
  34. package/dist/cdn/CVHJMR5X.js +2 -0
  35. package/dist/cdn/DEAYZ3MK.js +2 -0
  36. package/dist/cdn/{H7422XUG.js → E2HENO3T.js} +1 -1
  37. package/dist/cdn/E7TMP4YV.js +3 -0
  38. package/dist/cdn/EBRNMPPO.js +48 -0
  39. package/dist/cdn/FWU6DFIB.js +2 -0
  40. package/dist/cdn/HBYZSLEZ.js +22 -0
  41. package/dist/cdn/HOCTVCHH.js +2 -0
  42. package/dist/cdn/{4HU7735A.js → HXOSLGWU.js} +6 -4
  43. package/dist/cdn/I64KIZG3.js +2 -0
  44. package/dist/cdn/IB4WTK74.js +2 -0
  45. package/dist/cdn/IC5P5NYY.js +2 -0
  46. package/dist/cdn/IGZWQJW7.js +3 -0
  47. package/dist/cdn/IKEF7ZHH.js +181 -0
  48. package/dist/cdn/IXAKT6L3.js +2 -0
  49. package/dist/cdn/JEIMRNYM.js +2 -0
  50. package/dist/cdn/JN744CAW.js +2 -0
  51. package/dist/cdn/KRE4U7V7.js +2 -0
  52. package/dist/cdn/{NE7E52YR.js → KTK4HNL2.js} +8 -2
  53. package/dist/cdn/L77BTGXY.js +2 -0
  54. package/dist/cdn/LEPJUN3X.js +22 -0
  55. package/dist/cdn/LODKJRS4.js +2 -0
  56. package/dist/cdn/M3SWPT3M.js +2 -0
  57. package/dist/cdn/MAV3DW27.js +4 -0
  58. package/dist/cdn/NOJYPREL.js +3 -0
  59. package/dist/cdn/NXKKG5TK.js +2 -0
  60. package/dist/cdn/O3F47IO5.js +2 -0
  61. package/dist/cdn/O7TGCM5P.js +6 -0
  62. package/dist/cdn/PBTINZTK.js +65 -0
  63. package/dist/cdn/PKHQW7QU.js +18 -0
  64. package/dist/cdn/PSWI3MFB.js +2 -0
  65. package/dist/cdn/Q73PK7Q7.js +2 -0
  66. package/dist/cdn/Q7TL5Q5N.js +2 -0
  67. package/dist/cdn/QSA4T3BU.js +2 -0
  68. package/dist/cdn/RMLXVQZ5.js +2 -0
  69. package/dist/cdn/RX45PCYB.js +9 -0
  70. package/dist/cdn/S27EJSLC.js +14 -0
  71. package/dist/cdn/SMADRJ67.js +2 -0
  72. package/dist/cdn/{ZLXN7NMF.js → T537PKP4.js} +9 -7
  73. package/dist/cdn/{X2ZDYHCG.js → TNMXWUXU.js} +9 -4
  74. package/dist/cdn/TSEQVE2H.js +36 -0
  75. package/dist/cdn/VKU4WAQV.js +2 -0
  76. package/dist/cdn/W2IHPJ54.js +34 -0
  77. package/dist/cdn/W2JAKE2M.js +2 -0
  78. package/dist/cdn/WAVKMZA6.js +2 -0
  79. package/dist/cdn/WDE3HN7K.js +2 -0
  80. package/dist/cdn/WH6QQK6N.js +2 -0
  81. package/dist/cdn/WNS5ZUF5.js +2 -0
  82. package/dist/cdn/{FL4W4VYN.js → X7GE26KU.js} +16 -0
  83. package/dist/cdn/XVQJBUMY.js +2 -0
  84. package/dist/cdn/YJ3QQXF6.js +2 -0
  85. package/dist/cdn/YRBANNQ5.js +2 -0
  86. package/dist/cdn/YYY7HKYX.js +2 -0
  87. package/dist/cdn/ZEYIBYSF.js +66 -0
  88. package/dist/cdn/ZMSJQB65.js +99 -0
  89. package/dist/cdn/ZOSUDIJH.js +2 -0
  90. package/dist/cdn/ZPLFFLPF.js +2 -0
  91. package/dist/cdn/agent-utils/index.js +2 -0
  92. package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +3 -0
  93. package/dist/cdn/agent-utils/middlewares/middleware.js +2 -0
  94. package/dist/cdn/agent-utils/middlewares/trace.js +2 -0
  95. package/dist/cdn/index.js +1 -1
  96. package/dist/cdn/main.css +1 -1
  97. package/dist/chunks/adapter.js +1794 -1597
  98. package/dist/chunks/arcgisKnowledgeGraph.js +126 -71
  99. package/dist/chunks/arcgis_knowledge_current_lc_context.js +19 -2
  100. package/dist/chunks/arcgis_knowledge_current_map_context.js +31 -2
  101. package/dist/chunks/arcgis_knowledge_cypher_query_prompt.js +102 -0
  102. package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +116 -27
  103. package/dist/chunks/converterUtils.js +39 -32
  104. package/dist/chunks/dataExplorationGraph.js +139 -113
  105. package/dist/chunks/data_explore_query_prompt.js +9 -4
  106. package/dist/chunks/generateLayerDescriptions.js +231 -191
  107. package/dist/chunks/helpGraph.js +17 -13
  108. package/dist/chunks/help_prompt.js +34 -17
  109. package/dist/chunks/index.js +11 -0
  110. package/dist/chunks/intent_prompt.js +16 -0
  111. package/dist/chunks/layerStylingGraph.js +24 -20
  112. package/dist/chunks/navigationGraph.js +33 -28
  113. package/dist/chunks/navigation_intent_prompt.js +8 -2
  114. package/dist/chunks/orchestrator.js +267 -226
  115. package/dist/chunks/slottableRequestUtils.js +3 -7
  116. package/dist/chunks/state.js +1 -1
  117. package/dist/chunks/summarize_query_response_prompt.js +9 -7
  118. package/dist/chunks/toolCallResponse.js +12 -9
  119. package/dist/chunks/utils2.js +8 -8
  120. package/dist/components/arcgis-assistant/customElement.d.ts +27 -0
  121. package/dist/components/arcgis-assistant/customElement.js +385 -152
  122. package/dist/components/arcgis-assistant/index.js +2 -3
  123. package/dist/components/arcgis-assistant/types.d.ts +14 -1
  124. package/dist/components/arcgis-assistant-agent/customElement.js +5 -1
  125. package/dist/components/arcgis-assistant-chat/customElement.d.ts +8 -2
  126. package/dist/components/arcgis-assistant-chat/customElement.js +23 -18
  127. package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +4 -1
  128. package/dist/components/arcgis-assistant-chat-entry/customElement.js +25 -18
  129. package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +11 -5
  130. package/dist/components/arcgis-assistant-help-agent/customElement.js +8 -2
  131. package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -1
  132. package/dist/components/arcgis-assistant-interrupt/customElement.js +12 -8
  133. package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +20 -0
  134. package/dist/components/arcgis-assistant-interrupt-preview/index.js +2 -0
  135. package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +7 -7
  136. package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +17 -11
  137. package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +10 -4
  138. package/dist/components/arcgis-assistant-message/customElement.d.ts +23 -0
  139. package/dist/components/arcgis-assistant-message/customElement.js +28 -26
  140. package/dist/components/arcgis-assistant-message/index.d.ts +1 -0
  141. package/dist/components/arcgis-assistant-message/index.js +2 -0
  142. package/dist/components/arcgis-assistant-message-block/customElement.d.ts +1 -1
  143. package/dist/components/arcgis-assistant-message-block/customElement.js +18 -11
  144. package/dist/components/arcgis-assistant-message-block/index.js +1 -0
  145. package/dist/components/arcgis-assistant-message-feedback/customElement.d.ts +4 -1
  146. package/dist/components/arcgis-assistant-message-footer/customElement.d.ts +4 -1
  147. package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +8 -1
  148. package/dist/components/arcgis-assistant-message-loading/customElement.js +8 -8
  149. package/dist/components/arcgis-assistant-message-loading/index.js +1 -0
  150. package/dist/components/arcgis-assistant-message-log/customElement.d.ts +4 -1
  151. package/dist/components/arcgis-assistant-message-read-aloud/customElement.d.ts +4 -1
  152. package/dist/components/arcgis-assistant-message-text/customElement.d.ts +5 -1
  153. package/dist/components/arcgis-assistant-message-text/customElement.js +12 -12
  154. package/dist/components/arcgis-assistant-navigation-agent/customElement.js +11 -5
  155. package/dist/components/arcgis-assistant-speech-input/customElement.d.ts +6 -1
  156. package/dist/components/arcgis-assistant-suggested-prompts/customElement.d.ts +4 -1
  157. package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +8 -8
  158. package/dist/components/arcgis-assistant-user-message/customElement.d.ts +4 -1
  159. package/dist/components/arcgis-assistant-user-message/customElement.js +10 -8
  160. package/dist/docs/api.json +1 -1
  161. package/dist/docs/docs.json +1 -1
  162. package/dist/docs/vscode.html-custom-data.json +1 -1
  163. package/dist/docs/web-types.json +1 -1
  164. package/dist/index.d.ts +4 -0
  165. package/dist/loader.js +7 -6
  166. package/dist/types/lumina.d.ts +11 -5
  167. package/dist/types/preact.d.ts +12 -5
  168. package/dist/types/react.d.ts +13 -5
  169. package/dist/types/stencil.d.ts +11 -5
  170. package/dist/utils/index.d.ts +85 -42
  171. package/dist/utils/index.js +54 -49
  172. package/package.json +8 -7
  173. package/dist/cdn/2AXF774U.js +0 -2
  174. package/dist/cdn/3PKJWIC3.js +0 -2
  175. package/dist/cdn/462JBSEV.js +0 -422
  176. package/dist/cdn/5QAHYX7Y.js +0 -5
  177. package/dist/cdn/7BCR6TUO.js +0 -2
  178. package/dist/cdn/7GH7VSB2.js +0 -2
  179. package/dist/cdn/7PLV4QH6.js +0 -2
  180. package/dist/cdn/AO7BQHKC.js +0 -2
  181. package/dist/cdn/AXDZBBNL.js +0 -45
  182. package/dist/cdn/DDLZOMUY.js +0 -2
  183. package/dist/cdn/DHOVCT6R.js +0 -2
  184. package/dist/cdn/F2AHA4GB.js +0 -54
  185. package/dist/cdn/FHVXO2WG.js +0 -166
  186. package/dist/cdn/FX5JFRDL.js +0 -2
  187. package/dist/cdn/GSEPHN3A.js +0 -106
  188. package/dist/cdn/HB5A5R2E.js +0 -2
  189. package/dist/cdn/JY6LLOUJ.js +0 -22
  190. package/dist/cdn/KMQ3SP4I.js +0 -5
  191. package/dist/cdn/MDVYQQUG.js +0 -14
  192. package/dist/cdn/MH5RPXHM.js +0 -2
  193. package/dist/cdn/NAUXSHIE.js +0 -72
  194. package/dist/cdn/NVI3I46B.js +0 -2
  195. package/dist/cdn/OAVEHGB6.js +0 -2
  196. package/dist/cdn/OH64RMOR.js +0 -4
  197. package/dist/cdn/ON2V5XI2.js +0 -3
  198. package/dist/cdn/P6OPJQMC.js +0 -3
  199. package/dist/cdn/QR54T33D.js +0 -2
  200. package/dist/cdn/RVOAPUBN.js +0 -2
  201. package/dist/cdn/S6W6HV4T.js +0 -36
  202. package/dist/cdn/SXDLXCIM.js +0 -2
  203. package/dist/cdn/USMDJUFS.js +0 -2
  204. package/dist/cdn/V2P4AIGG.js +0 -2
  205. package/dist/cdn/V5YEZSRY.js +0 -16
  206. package/dist/cdn/Y333DGV6.js +0 -2
  207. package/dist/cdn/YY2SBO3V.js +0 -2
@@ -1,35 +1,170 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import { c as $ } from "../../chunks/runtime.js";
3
- import { css as k, html as a } from "lit";
4
- import S from "@arcgis/core/core/Collection.js";
5
- import { whenOnce as C, watch as L, when as I } from "@arcgis/core/core/reactiveUtils.js";
6
- import P from "@arcgis/core/portal/Portal.js";
7
- import { LitElement as R, createEvent as o, nothing as b } from "@arcgis/lumina";
8
- import { rethrowError as x } from "@arcgis/toolkit/log";
9
- import { createRef as f, ref as y } from "lit/directives/ref.js";
10
- import { u as M } from "../../chunks/useT9n.js";
11
- import { O } from "../../chunks/orchestrator.js";
2
+ import { c as x } from "../../chunks/runtime.js";
3
+ import { css as A, html as c } from "lit";
4
+ import T from "@arcgis/core/core/Collection.js";
5
+ import { whenOnce as L, watch as R, when as D } from "@arcgis/core/core/reactiveUtils.js";
6
+ import O from "@arcgis/core/portal/Portal.js";
7
+ import { LitElement as M, createEvent as g, nothing as k } from "@arcgis/lumina";
8
+ import * as B from "@arcgis/toolkit/log";
9
+ import { rethrowError as z } from "@arcgis/toolkit/log";
10
+ import { createRef as y, ref as v } from "lit/directives/ref.js";
11
+ import { u as N } from "../../chunks/useT9n.js";
12
+ import { O as U } from "../../chunks/orchestrator.js";
12
13
  import "@langchain/core/callbacks/dispatch/web";
13
14
  import "@langchain/core/prompts";
14
15
  import "@langchain/openai";
15
- import "@arcgis/core/identity/IdentityManager.js";
16
+ import V from "@arcgis/core/identity/IdentityManager.js";
17
+ import "@arcgis/toolkit/string";
18
+ import "@arcgis/core/config.js";
16
19
  import "@langchain/core/messages";
17
20
  import "@arcgis/core/layers/FeatureLayer.js";
18
21
  import "../../chunks/generateLayerDescriptions.js";
19
22
  import "@langchain/langgraph/web";
20
- import A from "@arcgis/core/core/Accessor.js";
21
- import { property as u, subclass as q } from "@arcgis/core/core/accessorSupport/decorators.js";
22
- import { g as z } from "../../chunks/utils3.js";
23
- import { g as v, a as _ } from "../../chunks/slottableRequestUtils.js";
24
- const V = k`:host{display:block;width:var(--arcgis-internal-panel-width, 100%);height:var(--arcgis-internal-expand-max-height, 100%)}.footer-container{display:flex;flex-direction:column;flex:1 1 0;gap:var(--calcite-spacing-md)}.content-container{display:flex;flex-direction:column;flex:1 1 0;min-height:0;position:relative;overflow:auto}.suggested-prompts-container{display:flex;justify-content:center;width:100%}.suggested-prompts{display:block;padding:var(--calcite-spacing-md);max-width:100%;box-sizing:border-box}.error-notice{padding:var(--calcite-spacing-sm)}`;
25
- var N = Object.defineProperty, j = Object.getOwnPropertyDescriptor, h = (p, t, e, i) => {
26
- for (var s = i > 1 ? void 0 : i ? j(t, e) : t, r = p.length - 1, n; r >= 0; r--)
27
- (n = p[r]) && (s = (i ? n(t, e, s) : n(s)) || s);
28
- return i && s && N(t, e, s), s;
23
+ import j from "@arcgis/core/core/Accessor.js";
24
+ import { property as m, subclass as q } from "@arcgis/core/core/accessorSupport/decorators.js";
25
+ import { marked as E } from "marked";
26
+ import { g as H } from "../../chunks/utils3.js";
27
+ import { g as S } from "../../chunks/slottableRequestUtils.js";
28
+ const F = A`:host{display:block;width:var(--arcgis-internal-panel-width, 100%);height:var(--arcgis-internal-expand-max-height, 100%);--calcite-panel-content-bottom-space: 0}.footer-container{display:flex;flex-direction:column;flex:1 1 0;gap:var(--calcite-spacing-md)}.content-container{display:flex;flex-direction:column;flex:1 1 0;min-height:0;position:relative;overflow:auto}.suggested-prompts-container{display:flex;justify-content:center;width:100%;background:var(--calcite-panel-background-color, var(--calcite-color-background))}.suggested-prompts{display:block;padding:var(--calcite-spacing-md);max-width:100%;box-sizing:border-box}.error-notice{padding:var(--calcite-spacing-sm)}.interrupt-waiting-message{font-style:italic;color:var(--calcite-color-text-2)}`;
29
+ function w(o) {
30
+ return o.trim() ? E.lexer(o).filter((t) => t.type !== "space").map((t) => E.parser([t])) : [];
31
+ }
32
+ class I {
33
+ constructor() {
34
+ this._stableParts = [], this._stableText = "", this._rawText = "";
35
+ }
36
+ // full streamed markdown so far
37
+ // Add one chunk and return all current segments.
38
+ push(t) {
39
+ return this._rawText += t, this._advanceStableBoundary(), this.getParts();
40
+ }
41
+ // Parse the remaining live tail. Call once at stream end.
42
+ finalize() {
43
+ const t = this._rawText.slice(this._stableText.length);
44
+ return t.trim() && (this._stableParts.push(...w(t)), this._stableText = this._rawText), this._stableParts;
45
+ }
46
+ // Get full output: stable segments + current live tail.
47
+ getParts() {
48
+ const t = this._trimIncompleteTail(this._rawText.slice(this._stableText.length)), s = t.trim() ? w(t) : [];
49
+ return [...this._stableParts, ...s];
50
+ }
51
+ reset() {
52
+ this._stableParts = [], this._stableText = "", this._rawText = "";
53
+ }
54
+ // Move parse-safe content from live tail into stable content.
55
+ _advanceStableBoundary() {
56
+ const t = this._rawText.slice(this._stableText.length), s = this._lastSafeBoundary(t);
57
+ if (s <= 0)
58
+ return;
59
+ const i = t.slice(0, s);
60
+ this._stableParts.push(...w(i)), this._stableText += i;
61
+ }
62
+ /**
63
+ * Find the last blank-line boundary that is outside code fences.
64
+ * Returns 0 if no safe boundary is available yet.
65
+ */
66
+ _lastSafeBoundary(t) {
67
+ const s = t.split(`
68
+ `);
69
+ let i = !1, e = 0, n = 0;
70
+ for (const r of s)
71
+ /^\s*(```|~~~)/u.test(r) && (i = !i), n += r.length + 1, r.trim() === "" && !i && (e = n);
72
+ return e < t.length ? e : 0;
73
+ }
74
+ /**
75
+ * Remove incomplete syntax at the end so we do not render partial markup.
76
+ * Handles:
77
+ * - open HTML tags without closing '>'
78
+ * - HTML elements missing closing tags
79
+ * - markdown links missing closing ')'
80
+ */
81
+ _trimIncompleteTail(t) {
82
+ const s = t.lastIndexOf("<");
83
+ if (s !== -1 && !t.includes(">", s))
84
+ return t.slice(0, s);
85
+ const i = this._earliestUnclosedTag(t);
86
+ if (i !== -1)
87
+ return t.slice(0, i);
88
+ const e = t.lastIndexOf("[");
89
+ if (e !== -1) {
90
+ const n = t.slice(e);
91
+ if (!/\[[^\]]*\]\([^)]*\)/u.test(n))
92
+ return t.slice(0, e);
93
+ }
94
+ return t;
95
+ }
96
+ /**
97
+ * Return the index of the earliest unclosed opening tag, or -1.
98
+ * Ignores void elements (img, br, input, etc.) and self-closing tags.
99
+ */
100
+ _earliestUnclosedTag(t) {
101
+ const s = /* @__PURE__ */ new Set([
102
+ "br",
103
+ "img",
104
+ "hr",
105
+ "input",
106
+ "meta",
107
+ "link",
108
+ "area",
109
+ "base",
110
+ "col",
111
+ "embed",
112
+ "source",
113
+ "track",
114
+ "wbr"
115
+ ]), i = /<(\/?)([a-zA-Z][\w-]*)\b[^>]*?(\/?)>/gu, e = [];
116
+ for (let n = i.exec(t); n; n = i.exec(t)) {
117
+ const [, r, a, l] = n, h = a.toLowerCase();
118
+ if (!(s.has(h) || l === "/"))
119
+ if (r === "/") {
120
+ for (let p = e.length - 1; p >= 0; p--)
121
+ if (e[p].name === h) {
122
+ e.splice(p);
123
+ break;
124
+ }
125
+ } else
126
+ e.push({ name: h, index: n.index });
127
+ }
128
+ return e.length ? e[0].index : -1;
129
+ }
130
+ }
131
+ function G(o) {
132
+ const t = new I();
133
+ return t.push(o), t.finalize();
134
+ }
135
+ const W = async (o) => await new Promise((t) => setTimeout(t, o));
136
+ async function* Y(o, { chunkSize: t = 15, delay: s = 50 } = {}) {
137
+ const i = new I();
138
+ for (let e = 0; e < o.length; e += t)
139
+ yield i.push(o.slice(e, e + t)), await W(s);
140
+ yield i.finalize();
141
+ }
142
+ var Z = Object.defineProperty, J = Object.getOwnPropertyDescriptor, u = (o, t, s, i) => {
143
+ for (var e = i > 1 ? void 0 : i ? J(t, s) : t, n = o.length - 1, r; n >= 0; n--)
144
+ (r = o[n]) && (e = (i ? r(t, s, e) : r(e)) || e);
145
+ return i && e && Z(t, s, e), e;
29
146
  };
30
- let l = class extends A {
31
- constructor(p) {
32
- super(p), this.view = null, this.loading = !1, this.processing = !1, this.processingStep = "";
147
+ const $ = (o) => !o || typeof o != "object" ? !1 : o.name === "AbortError";
148
+ async function* C(o, t, s, i, e = !1) {
149
+ if (e) {
150
+ if (i?.aborted) {
151
+ yield { type: "cancelled", log: s, runId: t };
152
+ return;
153
+ }
154
+ yield { type: "block-data", blockType: "text", data: { parts: G(o) }, runId: t };
155
+ return;
156
+ }
157
+ for await (const n of Y(o)) {
158
+ if (i?.aborted) {
159
+ yield { type: "cancelled", log: s, runId: t };
160
+ return;
161
+ }
162
+ yield { type: "block-data", blockType: "text", data: { parts: n }, runId: t };
163
+ }
164
+ }
165
+ let d = class extends j {
166
+ constructor(o) {
167
+ super(o), this.view = null, this.streamingDisabled = !1, this.loading = !1, this.processing = !1, this.processingStep = "";
33
168
  }
34
169
  async load() {
35
170
  this._set("loading", !0);
@@ -43,14 +178,14 @@ let l = class extends A {
43
178
  this.orchestrator?.dispose(), super.destroy();
44
179
  }
45
180
  async _initialize() {
46
- this.removeHandles(), await Promise.all([this.portal.load(), this.view?.when()]), this.view && await C(() => !this.view.updating), this._set(
181
+ this.removeHandles(), await Promise.all([this.portal.load(), this.view?.when()]), this.view && await L(() => !this.view.updating), this._set(
47
182
  "orchestrator",
48
- await O.init({
183
+ await U.init({
49
184
  agents: [...this.agents],
50
185
  view: this.view ?? void 0
51
186
  })
52
187
  ), this.addHandles([
53
- L(
188
+ R(
54
189
  () => [this.view, this.agents],
55
190
  () => {
56
191
  this._initialize();
@@ -61,64 +196,78 @@ let l = class extends A {
61
196
  clearChatHistory() {
62
197
  this.orchestrator?.newConversation();
63
198
  }
64
- async *ask(p, t) {
199
+ async *ask(o, t) {
65
200
  if (!this.orchestrator)
66
201
  throw new Error("Orchestrator not initialized yet.");
67
202
  this._set("processing", !0), this._set("processingStep", "");
68
- const e = [];
69
- let i;
203
+ const s = [];
204
+ let i, e = "pending";
70
205
  try {
71
- const s = this.orchestrator.ask(p);
72
- for await (const r of s) {
73
- const n = r.runId;
74
- if (t?.aborted) {
75
- yield { type: "cancelled", runId: n };
76
- break;
77
- }
78
- switch (r.type) {
206
+ const n = this.orchestrator.ask(o);
207
+ for await (const r of n)
208
+ switch (e = r.runId, r.type) {
79
209
  case "trace": {
80
- this._set("processingStep", r.data.text), e.push(r.data.text);
210
+ this._set("processingStep", r.data.text), s.push(r.data.text);
81
211
  break;
82
212
  }
83
213
  case "completed": {
84
- const c = r.result, g = !!c.content.length, m = !!i?.length;
85
- if (!g && !m) {
86
- yield { type: "completed", error: "Could not process the request.", log: e, runId: n };
214
+ this._set("processing", !1), this._set("processingStep", "");
215
+ const a = r.result, l = !!a.content.length, h = !!i?.length;
216
+ if (!l && !h) {
217
+ yield { type: "completed", error: "No response received.", log: s, runId: e };
87
218
  return;
88
219
  }
89
- const d = c.content;
90
- this._set("processingStep", ""), yield { type: "completed", response: d, blocks: i, log: e, runId: n };
220
+ const p = a.content;
221
+ if (yield { type: "block-start", blockType: "text", runId: e }, yield* C(p, e, s, t, this.streamingDisabled), yield { type: "block-end", blockType: "text", runId: e }, h)
222
+ for (const f of i) {
223
+ if (t?.aborted) {
224
+ yield { type: "cancelled", log: s, runId: e };
225
+ return;
226
+ }
227
+ const { type: b, data: _ } = f;
228
+ if (yield { type: "block-start", blockType: b, runId: e }, b === "text") {
229
+ const P = typeof _?.content == "string" ? _.content : "";
230
+ yield* C(P, e, s, t, this.streamingDisabled);
231
+ } else
232
+ yield { type: "block-data", blockType: b, data: _, runId: e };
233
+ yield { type: "block-end", blockType: b, runId: e };
234
+ }
235
+ yield { type: "completed", response: p, blocks: i, log: s, runId: e };
91
236
  return;
92
237
  }
93
238
  case "ux-suggestion": {
94
- const c = r.suggestion;
95
- i = i ? [...i, c] : [c];
239
+ const a = r.suggestion;
240
+ i = i ? [...i, a] : [a];
96
241
  break;
97
242
  }
98
243
  case "interrupt": {
99
- const { kind: c, message: g, metadata: m } = r.interrupt, d = Array.isArray(m) ? m.filter((E) => typeof E == "string") : [], w = (() => {
100
- switch (c) {
244
+ const { kind: a, message: l, metadata: h } = r.interrupt, p = Array.isArray(h) ? h.filter((b) => typeof b == "string") : [], f = (() => {
245
+ switch (a) {
101
246
  case "booleanChoice":
102
- return { type: "boolean-choice", message: g, options: d };
247
+ return { type: "boolean-choice", message: l, options: p };
103
248
  case "singleSelection":
104
- return { type: "single-select", message: g, options: d };
249
+ return { type: "single-select", message: l, options: p };
105
250
  case "multipleSelection":
106
- return { type: "multi-select", message: g, options: d };
251
+ return { type: "multi-select", message: l, options: p };
107
252
  case "textInput":
108
- return { type: "text-input", message: g };
253
+ return { type: "text-input", message: l };
109
254
  default:
110
- return { type: c, message: g, options: d };
255
+ return { type: a, message: l, options: p };
111
256
  }
112
257
  })();
113
- this._set("processingStep", "Waiting for user input..."), yield { type: "interrupt", payload: w, runId: n };
258
+ this._set("processingStep", "Waiting for user input..."), yield { type: "interrupt", payload: f, runId: e };
114
259
  break;
115
260
  }
116
261
  case "cancelled": {
117
- yield { type: "cancelled", runId: n };
262
+ yield { type: "cancelled", log: s, runId: e };
118
263
  return;
119
264
  }
120
265
  case "error": {
121
- yield { type: "completed", error: r.error.message, log: e, runId: n };
266
+ if (t?.aborted || $(r.error)) {
267
+ yield { type: "cancelled", log: s, runId: e };
268
+ return;
269
+ }
270
+ yield { type: "completed", error: r.error.message, log: s, runId: e };
122
271
  return;
123
272
  }
124
273
  default: {
@@ -126,105 +275,118 @@ let l = class extends A {
126
275
  break;
127
276
  }
128
277
  }
278
+ } catch (n) {
279
+ if (t?.aborted || $(n)) {
280
+ yield { type: "cancelled", log: s, runId: e };
281
+ return;
129
282
  }
130
- } catch (s) {
131
- console.warn("Error during message processing:", s), yield { type: "completed", error: "An error occurred during message processing.", log: e, runId: "error" };
283
+ console.warn("Error during message processing:", n), yield { type: "completed", error: "An error occurred during message processing.", log: s, runId: "error" };
132
284
  return;
133
285
  } finally {
134
286
  this._set("processing", !1);
135
287
  }
136
288
  }
289
+ cancel() {
290
+ this.orchestrator?.cancel();
291
+ }
137
292
  };
138
- h([
139
- u({ readOnly: !0 })
140
- ], l.prototype, "orchestrator", 2);
141
- h([
142
- u()
143
- ], l.prototype, "agents", 2);
144
- h([
145
- u()
146
- ], l.prototype, "portal", 2);
147
- h([
148
- u()
149
- ], l.prototype, "view", 2);
150
- h([
151
- u({ readOnly: !0 })
152
- ], l.prototype, "loading", 2);
153
- h([
154
- u({ readOnly: !0 })
155
- ], l.prototype, "processing", 2);
156
- h([
157
- u({ readOnly: !0 })
158
- ], l.prototype, "processingStep", 2);
159
- l = h([
293
+ u([
294
+ m({ readOnly: !0 })
295
+ ], d.prototype, "orchestrator", 2);
296
+ u([
297
+ m()
298
+ ], d.prototype, "agents", 2);
299
+ u([
300
+ m()
301
+ ], d.prototype, "portal", 2);
302
+ u([
303
+ m()
304
+ ], d.prototype, "view", 2);
305
+ u([
306
+ m()
307
+ ], d.prototype, "streamingDisabled", 2);
308
+ u([
309
+ m({ readOnly: !0 })
310
+ ], d.prototype, "loading", 2);
311
+ u([
312
+ m({ readOnly: !0 })
313
+ ], d.prototype, "processing", 2);
314
+ u([
315
+ m({ readOnly: !0 })
316
+ ], d.prototype, "processingStep", 2);
317
+ d = u([
160
318
  q("OrchestratorController")
161
- ], l);
162
- const B = "Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.", H = "Embeddings not found for this web map.", D = "https://developers.arcgis.com/javascript/latest/agentic-apps/ai-webmap-setup/#embeddings";
163
- class F extends R {
319
+ ], d);
320
+ const K = "Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.", Q = "Embeddings not found for this web map.", X = "https://developers.arcgis.com/javascript/latest/agentic-apps/ai-webmap-setup/#embeddings";
321
+ class tt extends M {
164
322
  constructor() {
165
- super(...arguments), this._messages = M({ blocking: !0 }), this.#t = f(), this.#n = f(), this.#e = f(), this.#s = null, this.#o = /* @__PURE__ */ new Map(), this.#r = P.getDefault(), this.#i = (t) => {
323
+ super(...arguments), this._messages = N({ blocking: !0 }), this.#t = y(), this.#l = y(), this.#s = y(), this.#e = null, this.#r = /* @__PURE__ */ new Map(), this.#i = O.getDefault(), this.#a = (t) => {
166
324
  t.stopPropagation(), this.cancelInterrupt();
167
- }, this.#a = (t) => {
325
+ }, this.#n = (t) => {
168
326
  t.stopPropagation();
169
- const e = t.detail;
170
- this.submitInterrupt(e);
171
- }, this.#l = (t) => {
172
- t.stopPropagation(), this.keepSuggestedPrompts || (this.suggestedPrompts = []);
173
- const e = t.detail;
174
- this._inputValue = "", this.arcgisSubmit.emit(e), this.submitMessage(e);
327
+ const s = t.detail;
328
+ this.submitInterrupt(s);
175
329
  }, this.#c = (t) => {
176
- if (t.stopPropagation(), this.arcgisCancel.emit(), this._interrupt) {
330
+ t.stopPropagation(), this.keepSuggestedPrompts || (this.suggestedPrompts = []);
331
+ const s = t.detail;
332
+ this._inputValue = "", this.arcgisSubmit.emit(s), this.submitMessage(s);
333
+ }, this.#h = (t) => {
334
+ if (this._canceling = !0, t.stopPropagation(), this.arcgisCancel.emit(), this._interrupt) {
177
335
  this.orchestrator?.cancelInterrupt(), this._interrupt = null;
178
336
  return;
179
337
  }
180
- this.#s?.abort();
181
- }, this.#h = (t) => {
182
- t.stopPropagation();
183
- const e = t.detail;
184
- this.arcgisFeedback.emit(e);
338
+ this._orchestratorController?.cancel(), this.#e?.abort(), this.#e = null;
185
339
  }, this.#p = (t) => {
186
340
  t.stopPropagation();
187
- const e = t.detail;
188
- this._inputValue = e.prompt, this.arcgisPromptSelect.emit(e);
341
+ const s = t.detail;
342
+ this.arcgisFeedback.emit(s);
189
343
  }, this.#g = (t) => {
344
+ t.stopPropagation();
345
+ const s = t.detail;
346
+ this._inputValue = s.prompt, this.arcgisPromptSelect.emit(s);
347
+ }, this.#d = (t) => {
190
348
  this.arcgisSlottableRequest.emit(t.detail);
191
- }, this._orchestratorController = null, this._interrupt = null, this._error = null, this._inputValue = "", this.messages = new S([]), this.referenceElement = null, this.suggestedPrompts = [], this.feedbackEnabled = !1, this.keepSuggestedPrompts = !1, this.logEnabled = !1, this.copyEnabled = !1, this.voiceInputEnabled = !1, this.readAloudEnabled = !1, this.arcgisCancel = o(), this.arcgisError = o(), this.arcgisFeedback = o(), this.arcgisInterrupt = o(), this.arcgisInterruptCancel = o(), this.arcgisInterruptSubmit = o(), this.arcgisPromptSelect = o(), this.arcgisReady = o(), this.arcgisSubmit = o(), this.arcgisSlottableRequest = o({ bubbles: !1, composed: !1 });
349
+ }, this._orchestratorController = null, this._interrupt = null, this._interruptDetails = [], this._error = null, this._inputValue = "", this._isAnswering = !1, this._canceling = !1, this.messages = new T([]), this.referenceElement = null, this.suggestedPrompts = [], this.feedbackEnabled = !1, this.keepSuggestedPrompts = !1, this.streamingDisabled = !1, this.logEnabled = !1, this.copyEnabled = !1, this.voiceInputEnabled = !1, this.readAloudEnabled = !1, this.assistantAvatarEnabled = !1, this.arcgisCancel = g(), this.arcgisError = g(), this.arcgisFeedback = g(), this.arcgisInterrupt = g(), this.arcgisInterruptCancel = g(), this.arcgisInterruptSubmit = g(), this.arcgisPromptSelect = g(), this.arcgisReady = g(), this.arcgisSubmit = g(), this.arcgisSlottableRequest = g({ bubbles: !1, composed: !1 }), this.arcgisResponse = g();
192
350
  }
193
351
  static {
194
- this.properties = { _orchestratorController: 16, _interrupt: 16, _error: 16, _inputValue: 16, _user: 16, awaitingResponse: 32, awaitingResponseStep: 32, interrupt: 32, messages: 0, orchestrator: 32, entryMessage: 1, heading: 1, description: 1, referenceElement: 1, suggestedPrompts: 0, feedbackEnabled: 5, keepSuggestedPrompts: 5, logEnabled: 5, copyEnabled: 5, voiceInputEnabled: 5, readAloudEnabled: 5 };
352
+ this.properties = { _orchestratorController: 16, _interrupt: 16, _interruptDetails: 16, _error: 16, _inputValue: 16, _isAnswering: 16, _signedInUserId: 16, _canceling: 16, _isSignedIn: 16, _user: 16, awaitingResponse: 32, awaitingResponseStep: 32, interrupt: 32, messages: 0, orchestrator: 32, entryMessage: 1, heading: 1, description: 1, referenceElement: 1, suggestedPrompts: 0, feedbackEnabled: 5, keepSuggestedPrompts: 5, streamingDisabled: 5, logEnabled: 5, copyEnabled: 5, voiceInputEnabled: 5, readAloudEnabled: 5, assistantAvatarEnabled: 5 };
195
353
  }
196
354
  static {
197
- this.styles = V;
355
+ this.styles = F;
198
356
  }
199
357
  #t;
200
- #n;
201
- #e;
358
+ #l;
202
359
  #s;
203
- #o;
360
+ #e;
204
361
  #r;
205
362
  #i;
206
363
  #a;
207
- #l;
364
+ #n;
208
365
  #c;
209
366
  #h;
210
367
  #p;
211
368
  #g;
212
- async #u() {
369
+ #d;
370
+ async #o() {
213
371
  try {
214
- const t = z(this.el, this.referenceElement);
372
+ const t = H(this.el, this.referenceElement);
215
373
  await t?.componentOnReady();
216
- const e = [...this.#o.values()];
217
- return e.length ? (this._orchestratorController = new l({
218
- agents: e,
219
- portal: this.#r,
374
+ const s = [...this.#r.values()];
375
+ return s.length ? (this._orchestratorController?.destroy(), this._orchestratorController = new d({
376
+ agents: s,
377
+ portal: this.#i,
378
+ streamingDisabled: this.streamingDisabled,
220
379
  view: t?.view
221
380
  }), await this._orchestratorController.load(), !0) : (this._error = "No agents found.", !1);
222
381
  } catch (t) {
223
- return this._error = t?.message ?? "Error initializing orchestrator.", x(this)(t), !1;
382
+ return this._error = t?.message ?? "Error initializing orchestrator.", z(this)(t), !1;
224
383
  }
225
384
  }
385
+ get _isSignedIn() {
386
+ return !!this.#i?.user || !!this._signedInUserId;
387
+ }
226
388
  get _user() {
227
- return this.#r?.user?.fullName || this.#r?.user?.username;
389
+ return this.#i?.user?.fullName || this.#i?.user?.username;
228
390
  }
229
391
  get awaitingResponse() {
230
392
  return this._orchestratorController?.processing ?? !1;
@@ -245,85 +407,156 @@ class F extends R {
245
407
  this.arcgisInterruptCancel.emit(), this.orchestrator?.cancelInterrupt(), this._interrupt = null;
246
408
  }
247
409
  register(t) {
248
- this.#o.set(t.agent.id, t);
410
+ this.#r.set(t.agent.id, t), this._orchestratorController && this.#o();
411
+ }
412
+ unregister(t) {
413
+ this.#r.delete(t), this._orchestratorController && this.#o();
249
414
  }
250
415
  async submitMessage(t) {
251
- const e = t.trim();
252
- if (!e || (this.messages.push({
416
+ const s = t.trim();
417
+ if (!s || (this.messages.push({
253
418
  id: Date.now().toString(),
254
419
  // TODO: Replace with a more robust ID generation method or get from orchestrator
255
420
  role: "user",
256
- content: e
421
+ content: s
257
422
  }), !this._orchestratorController))
258
423
  return;
259
- const i = this._orchestratorController.ask(e, this.#s?.signal);
260
- for await (const s of i) {
261
- const r = s.runId;
262
- switch (s.type) {
424
+ this.#e = new AbortController(), this._orchestratorController.streamingDisabled = this.streamingDisabled;
425
+ const i = this._orchestratorController.ask(s, this.#e?.signal);
426
+ for await (const e of i) {
427
+ const n = e.runId, r = this.messages.at(-1);
428
+ switch (e.type) {
429
+ case "block-start": {
430
+ this._isAnswering = !0;
431
+ const a = { type: e.blockType, isPending: !0 };
432
+ if (r?.role === "assistant" && r.id === n) {
433
+ const l = [...r.blocks ?? [], a];
434
+ this.messages.splice(-1, 1, { ...r, blocks: l });
435
+ } else
436
+ this.messages.push({
437
+ role: "assistant",
438
+ blocks: [a],
439
+ id: n,
440
+ isStreaming: !0,
441
+ interrupts: this._interruptDetails
442
+ }), this._interruptDetails = [];
443
+ break;
444
+ }
445
+ case "block-data": {
446
+ if (r?.role !== "assistant" || r?.id !== n)
447
+ break;
448
+ const a = [...r.blocks ?? []], l = a[a.length - 1], { blockType: h, data: p } = e;
449
+ if (l?.type !== h || !l.isPending)
450
+ break;
451
+ h === "text" ? a[a.length - 1] = {
452
+ ...l,
453
+ data: {
454
+ ...l.data,
455
+ parts: p?.parts
456
+ }
457
+ } : a[a.length - 1] = { ...l, data: { ...l.data, ...p ?? {} } }, this.messages.splice(-1, 1, { ...r, blocks: a });
458
+ break;
459
+ }
460
+ case "block-end": {
461
+ if (r?.role !== "assistant" || r?.id !== n)
462
+ break;
463
+ const a = [...r.blocks ?? []], l = a[a.length - 1];
464
+ if (l?.type !== e.blockType || !l.isPending)
465
+ break;
466
+ const h = l;
467
+ a[a.length - 1] = { ...h, data: { ...h.data }, isPending: !1 }, this.messages.splice(-1, 1, { ...r, blocks: a });
468
+ break;
469
+ }
263
470
  case "completed":
264
- this.messages.push({
471
+ e.error ? (this.messages.push({
265
472
  role: "assistant",
266
- content: s.response,
267
- blocks: s.blocks,
268
- log: s.log,
269
- error: s.error,
270
- id: r
271
- });
473
+ log: e.log,
474
+ error: e.error,
475
+ id: n,
476
+ interrupts: this._interruptDetails
477
+ }), this._interruptDetails = []) : r?.role === "assistant" && r.id === n && this.messages.splice(-1, 1, {
478
+ ...r,
479
+ content: e.response,
480
+ blocks: r.blocks?.map((a) => ({ ...a, data: { ...a.data }, isPending: !1 })) ?? [],
481
+ isStreaming: !1,
482
+ log: e.log
483
+ }), this._isAnswering = !1, this.#e = null, this._canceling = !1;
272
484
  break;
273
485
  case "interrupt":
274
- this._interrupt = { ...s.payload, id: r }, this.arcgisInterrupt.emit(this._interrupt);
486
+ this._interrupt = { ...e.payload, id: n }, this.arcgisInterrupt.emit(this._interrupt);
275
487
  break;
276
488
  case "cancelled":
277
- this.messages.push({
489
+ r?.role === "assistant" && r.id === n ? this.messages.splice(-1, 1, {
490
+ ...r,
491
+ blocks: r.blocks?.filter((a) => a.type === "text" || !a.isPending) ?? [],
492
+ isStreaming: !1,
493
+ log: e.log,
494
+ error: "(Stopped by user)"
495
+ // TODO: use strings from t9n
496
+ }) : (this.messages.push({
278
497
  role: "assistant",
279
- error: "Request cancelled.",
280
- id: r
281
- });
498
+ log: e.log,
499
+ error: "(Stopped by user)",
500
+ // TODO: use strings from t9n
501
+ id: n,
502
+ interrupts: this._interruptDetails
503
+ }), this._interruptDetails = []), this._isAnswering = !1, this.#e = null, this._canceling = !1;
282
504
  break;
283
505
  }
284
506
  }
285
507
  }
286
508
  submitInterrupt(t) {
287
- this.arcgisInterruptSubmit.emit(t), this.orchestrator?.resumeInterrupt(t), this._interrupt = null;
509
+ this.arcgisInterruptSubmit.emit(t), this._interrupt && (this._interruptDetails = [...this._interruptDetails, { interrupt: this._interrupt, response: t }]), this.orchestrator?.resumeInterrupt(t), this._interrupt = null;
288
510
  }
289
511
  load() {
290
512
  this.manager.onLifecycle(this._reset.bind(this));
291
513
  }
292
514
  loaded() {
293
515
  this.manager.onLifecycle(() => {
294
- this.#t.value?.addEventListener("arcgisPromptSelect", this.#p), this.#t.value?.addEventListener("arcgisSubmit", this.#l), this.#t.value?.addEventListener("arcgisCancel", this.#c), this.#t.value?.addEventListener("arcgisFeedback", this.#h);
295
- const t = I(() => !!this._interrupt && !!this.#e.value, () => {
296
- const e = this.#e.value;
297
- e.removeEventListener("arcgisSubmit", this.#a), e.removeEventListener("arcgisCancel", this.#i), e.addEventListener("arcgisSubmit", this.#a, { once: !0 }), e.addEventListener("arcgisCancel", this.#i, { once: !0 });
516
+ this.#t.value?.addEventListener("arcgisPromptSelect", this.#g), this.#t.value?.addEventListener("arcgisSubmit", this.#c), this.#t.value?.addEventListener("arcgisCancel", this.#h), this.#t.value?.addEventListener("arcgisFeedback", this.#p);
517
+ const t = D(() => !!this._interrupt && !!this.#s.value, () => {
518
+ const i = this.#s.value;
519
+ i.removeEventListener("arcgisSubmit", this.#n), i.removeEventListener("arcgisCancel", this.#a), i.addEventListener("arcgisSubmit", this.#n, { once: !0 }), i.addEventListener("arcgisCancel", this.#a, { once: !0 });
520
+ }), s = this.messages.on("after-add", (i) => {
521
+ const e = i.item;
522
+ e.role === "assistant" && (e.error || e.content) && this.arcgisResponse.emit(e);
298
523
  });
299
524
  return queueMicrotask(() => {
300
- this.#u().then((e) => {
301
- e ? this.arcgisReady.emit() : this._error && this.arcgisError.emit(new Error(this._error));
525
+ this.#o().then((i) => {
526
+ i ? this.arcgisReady.emit() : this._error && this.arcgisError.emit(new Error(this._error));
302
527
  });
303
528
  }), () => {
304
- t.remove(), this.#t.value?.removeEventListener("arcgisPromptSelect", this.#p), this.#e.value?.removeEventListener("arcgisSubmit", this.#a), this.#e.value?.removeEventListener("arcgisCancel", this.#i), this.#t.value?.removeEventListener("arcgisSubmit", this.#l), this.#t.value?.removeEventListener("arcgisCancel", this.#c), this.#t.value?.removeEventListener("arcgisFeedback", this.#h), this._orchestratorController?.destroy(), this._orchestratorController = null;
529
+ t.remove(), s.remove(), this.#t.value?.removeEventListener("arcgisPromptSelect", this.#g), this.#s.value?.removeEventListener("arcgisSubmit", this.#n), this.#s.value?.removeEventListener("arcgisCancel", this.#a), this.#t.value?.removeEventListener("arcgisSubmit", this.#c), this.#t.value?.removeEventListener("arcgisCancel", this.#h), this.#t.value?.removeEventListener("arcgisFeedback", this.#p), this._orchestratorController?.destroy(), this._orchestratorController = null;
305
530
  };
306
531
  });
307
532
  }
308
533
  _reset() {
309
- this.#s?.abort(), this._interrupt = null, this.messages.removeAll(), this._error = null, this._inputValue = "";
534
+ this._orchestratorController?.cancel(), this.#e?.abort(), this._interrupt = null, this.messages.removeAll(), this._error = null, this._inputValue = "", this._signedInUserId = void 0;
310
535
  }
311
536
  _renderEntryMessage() {
312
- return this._interrupt ? a`<slot name=interrupt><arcgis-assistant-interrupt .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${y(this.#e)}></arcgis-assistant-interrupt></slot>` : this._error ? this._renderErrorNotice() : this.entryMessage ? this.messages.length > 0 ? null : a`<calcite-notice open kind=info closable icon width=full><div slot=message>${this.entryMessage}</div></calcite-notice>` : a`<slot name=entry-message></slot>`;
537
+ return this._isSignedIn ? this._error ? this._renderErrorNotice() : this.entryMessage ? this.messages.length > 0 ? null : c`<calcite-notice open kind=brand closable icon width=full><div slot=message>${this.entryMessage}</div></calcite-notice>` : c`<slot name=entry-message></slot>` : this._renderSignInNotice();
313
538
  }
314
- _renderErrorNotice() {
315
- return this._error ? a`<calcite-notice closable slot=entry-message open kind=danger icon width=full>${this._error === B ? a`<div slot=message>${H}</div><calcite-link slot=link .href=${D} target=_blank title="Learn about web map embeddings">Read more</calcite-link>` : a`<div slot=message>${this._error}</div>`}</calcite-notice>` : null;
539
+ _renderSignInNotice() {
540
+ const t = this.#i;
541
+ return c`<calcite-notice slot=entry-message open kind=brand icon width=full><div slot=message>You need to sign in to use the assistant chat.</div>${t ? c`<calcite-link slot=link @click=${async () => {
542
+ try {
543
+ const s = await V.getCredential(`${t.url}/sharing`);
544
+ this._signedInUserId = s.userId, this._error = null, this.requestUpdate(), await this.#o() ? this.arcgisReady.emit() : this._error && this.arcgisError.emit(new Error(this._error));
545
+ } catch (s) {
546
+ this._error = s?.message ?? "Error signing in.", this.arcgisError.emit(new Error(this._error)), B.log("error", this, "Error signing in:", { detail: { error: s } });
547
+ }
548
+ }} target=_blank title="Sign in to ArcGIS Online">Sign in</calcite-link>` : c`<div slot=link>No portal information available</div>`}</calcite-notice>`;
316
549
  }
317
- _renderSuggestedPrompts() {
318
- return this.suggestedPrompts?.length ? a`<div class="suggested-prompts-container"><arcgis-assistant-suggested-prompts class="suggested-prompts" .prompts=${this.suggestedPrompts}></arcgis-assistant-suggested-prompts></div>` : null;
550
+ _renderErrorNotice() {
551
+ return this._error ? c`<calcite-notice slot=entry-message open kind=brand icon width=full>${this._error === K ? c`<div slot=message>${Q}</div><calcite-link slot=link .href=${X} target=_blank title="Learn about web map embeddings">Read more</calcite-link>` : c`<div slot=message>${this._error}</div>`}</calcite-notice>` : null;
319
552
  }
320
553
  render() {
321
- return a`<calcite-panel .loading=${!this._orchestratorController && !this._error || this._orchestratorController?.loading} .heading=${this.heading ?? this._messages.assistantLabel} .description=${this.description} ${y(this.#t)}><slot name=header-actions-start slot=header-actions-start></slot><slot name=header-actions-end slot=header-actions-end></slot><div class="content-container"><arcgis-assistant-chat .loading=${this.awaitingResponse} .messages=${this.messages}><slot name=message-starter slot=message-starter></slot><slot name=messages slot=messages>${this.messages.map((t) => t.role === "assistant" ? a`<arcgis-assistant-message .message=${t} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled} .readAloudEnabled=${this.readAloudEnabled} @arcgisSlottableRequest=${this.#g}><slot name=${v(t.id) ?? b} slot=${v(t.id) ?? b}>${t?.error ? a`<calcite-notice class="error-notice" open icon kind=warning width=full><div slot=message>${t.error}</div></calcite-notice>` : a`<arcgis-assistant-message-text .content=${t?.content}></arcgis-assistant-message-text>`}</slot>${t.blocks?.map((e, i) => a`<slot name=${_(t.id, i) ?? b} slot=${_(t.id, i) ?? b}><arcgis-assistant-message-block .block=${e}></arcgis-assistant-message-block></slot>`)}</arcgis-assistant-message>` : a`<arcgis-assistant-user-message .message=${t} .user=${this._user}></arcgis-assistant-user-message>`)}</slot><slot name=message-loading slot=message-loading><arcgis-assistant-message-loading .loading=${this.awaitingResponse} .loadingMessage=${this.awaitingResponseStep}></arcgis-assistant-message-loading></slot></arcgis-assistant-chat></div>${this._renderSuggestedPrompts()}<div class="footer-container" slot=footer>${this._renderEntryMessage()}<slot name=chat-entry><arcgis-assistant-chat-entry .awaitingResponse=${this.awaitingResponse} .inputValue=${this._inputValue} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled} ${y(this.#n)}><slot name=entry-actions-start slot=entry-actions-start></slot><slot name=entry-actions-end slot=entry-actions-end><calcite-button .iconStart=${this.awaitingResponse ? "circle-stop" : "send"} @click=${() => {
322
- this.#n.value?.submitMessage();
323
- }} round>${this.awaitingResponse ? this._messages.stopButtonLabel : this._messages.askButtonLabel}</calcite-button></slot></arcgis-assistant-chat-entry></slot><slot name=footer-content></slot></div></calcite-panel>`;
554
+ return c`<calcite-panel .loading=${!this._orchestratorController && !this._error || this._orchestratorController?.loading} .heading=${this.heading ?? this._messages.assistantLabel} .description=${this.description} ${v(this.#t)}><slot name=header-actions-start slot=header-actions-start></slot><slot name=header-actions-end slot=header-actions-end></slot><div class="content-container"><arcgis-assistant-chat .loading=${this.awaitingResponse} .messages=${this.messages} .interrupt=${this._interrupt}><slot name=message-starter slot=message-starter></slot><slot name=messages slot=messages>${this.messages.map((t) => t.role === "assistant" ? c`<arcgis-assistant-message .message=${t} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled} .readAloudEnabled=${this.readAloudEnabled} @arcgisSlottableRequest=${this.#d} .assistantAvatarEnabled=${this.assistantAvatarEnabled}>${t.blocks?.map((s, i) => c`<slot name=${S(t.id, i) ?? k} slot=${S(t.id, i) ?? k}><arcgis-assistant-message-block .block=${s}></arcgis-assistant-message-block></slot>`)}</arcgis-assistant-message>` : c`<arcgis-assistant-user-message .message=${t} .user=${this._user}></arcgis-assistant-user-message>`)}</slot>${this._interrupt ? c`<div slot=message-loading><div class="interrupt-waiting-message">waiting for user input...</div></div>` : c`<slot name=message-loading slot=message-loading><arcgis-assistant-message-loading .loading=${this.awaitingResponse} .loadingMessage=${this.awaitingResponseStep} .assistantAvatarEnabled=${this.assistantAvatarEnabled} .interrupts=${this._interruptDetails}></arcgis-assistant-message-loading></slot>`}</arcgis-assistant-chat></div>${this._interrupt ? c`<slot name=interrupt><arcgis-assistant-interrupt slot=content-bottom .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${v(this.#s)}></arcgis-assistant-interrupt></slot>` : this.suggestedPrompts?.length ? c`<div class="suggested-prompts-container" slot=content-bottom><arcgis-assistant-suggested-prompts class="suggested-prompts" .prompts=${this.suggestedPrompts}></arcgis-assistant-suggested-prompts></div>` : null}<div class="footer-container" slot=footer>${this._renderEntryMessage()}<slot name=chat-entry><arcgis-assistant-chat-entry .awaitingResponse=${this.awaitingResponse || this._isAnswering} .inputValue=${this._inputValue} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled} .disabled=${this._canceling || !this._isSignedIn || !!this._interrupt} ${v(this.#l)}><slot name=entry-actions-start slot=entry-actions-start></slot><slot name=entry-actions-end slot=entry-actions-end><calcite-button .iconStart=${this.awaitingResponse || this._isAnswering ? "circle-stop" : "send"} @click=${() => {
555
+ this.#l.value?.submitMessage();
556
+ }} round>${this.awaitingResponse || this._isAnswering ? this._messages.stopButtonLabel : this._messages.askButtonLabel}</calcite-button></slot></arcgis-assistant-chat-entry></slot><slot name=footer-content></slot></div></calcite-panel>`;
324
557
  }
325
558
  }
326
- $("arcgis-assistant", F);
559
+ x("arcgis-assistant", tt);
327
560
  export {
328
- F as ArcgisAssistant
561
+ tt as ArcgisAssistant
329
562
  };