@arcgis/ai-components 5.2.0-next.7 → 5.2.0-next.70

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 (208) hide show
  1. package/README.md +2 -2
  2. package/dist/agent-utils/FunctionAgent.d.ts +2 -2
  3. package/dist/agent-utils/LLMAgent.d.ts +2 -2
  4. package/dist/agent-utils/LLMAgent.js +2 -1
  5. package/dist/agent-utils/WorkflowAgent.d.ts +2 -2
  6. package/dist/agent-utils/index.d.ts +177 -0
  7. package/dist/agent-utils/index.js +167 -0
  8. package/dist/agent-utils/middlewares/trace.d.ts +2 -0
  9. package/dist/agent-utils/middlewares/trace.js +25 -33
  10. package/dist/agent-utils/tools/FunctionTool.d.ts +2 -2
  11. package/dist/agent-utils/types.d.ts +36 -7
  12. package/dist/agent-utils/workflows/ConditionalWorkflow.d.ts +2 -2
  13. package/dist/agent-utils/workflows/LoopWorkflow.d.ts +2 -2
  14. package/dist/agent-utils/workflows/ParallelWorkflow.d.ts +2 -2
  15. package/dist/agent-utils/workflows/RouterWorkflow.d.ts +2 -2
  16. package/dist/agent-utils/workflows/SequentialWorkflow.d.ts +2 -2
  17. package/dist/agent-utils/workflows/SwitchWorkflow.d.ts +2 -2
  18. package/dist/cdn/{H7422XUG.js → 2GH3K5JP.js} +1 -1
  19. package/dist/cdn/2Y4DTOGT.js +2 -0
  20. package/dist/cdn/3DJDRAGV.js +2 -0
  21. package/dist/cdn/3S5G5SIX.js +2 -0
  22. package/dist/cdn/{AMP6IALT.js → 3UEKINYC.js} +1 -1
  23. package/dist/cdn/3ZPPYCNL.js +2 -0
  24. package/dist/cdn/434TAA3J.js +2 -0
  25. package/dist/cdn/4CEMUECT.js +2 -0
  26. package/dist/cdn/4PCAK3ET.js +2 -0
  27. package/dist/cdn/57OMVTIU.js +2 -0
  28. package/dist/cdn/5TI2F5XX.js +2 -0
  29. package/dist/cdn/6TA5KFAQ.js +4 -0
  30. package/dist/cdn/6U7TEAAJ.js +2 -0
  31. package/dist/cdn/{ZS2TZ6BF.js → AOVJ34QE.js} +1 -1
  32. package/dist/cdn/APFZY4PI.js +2 -0
  33. package/dist/cdn/B6CJG5UH.js +66 -0
  34. package/dist/cdn/BE7ZN5FZ.js +2 -0
  35. package/dist/cdn/{FL4W4VYN.js → BL273EGZ.js} +17 -1
  36. package/dist/cdn/BNSJO6X2.js +2 -0
  37. package/dist/cdn/{5ZZGKP7N.js → CEKOEHB3.js} +1 -1
  38. package/dist/cdn/CMDRED5H.js +2 -0
  39. package/dist/cdn/CXW5URTF.js +14 -0
  40. package/dist/cdn/DCSZPL7R.js +2 -0
  41. package/dist/cdn/DTIVDIDY.js +2 -0
  42. package/dist/cdn/DUSILSNJ.js +9 -0
  43. package/dist/cdn/E5ZKBC24.js +36 -0
  44. package/dist/cdn/FSGIG7UN.js +2 -0
  45. package/dist/cdn/{ZLXN7NMF.js → FYZATVB3.js} +10 -8
  46. package/dist/cdn/GLBE7OW2.js +2 -0
  47. package/dist/cdn/GP6NDTUE.js +18 -0
  48. package/dist/cdn/HBLRVXEB.js +2 -0
  49. package/dist/cdn/HJG7QM2R.js +9 -0
  50. package/dist/cdn/HQXPPYMD.js +2 -0
  51. package/dist/cdn/{FX7UOGHP.js → ICBIUFK7.js} +1 -1
  52. package/dist/cdn/ICYUPLZM.js +56 -0
  53. package/dist/cdn/IEHPNCTL.js +2 -0
  54. package/dist/cdn/IHP25JWI.js +99 -0
  55. package/dist/cdn/J6A4AS7E.js +22 -0
  56. package/dist/cdn/{NE7E52YR.js → JEBRN3EU.js} +9 -3
  57. package/dist/cdn/KKLAQF3Z.js +2 -0
  58. package/dist/cdn/KLYNL2ZT.js +2 -0
  59. package/dist/cdn/KQHLOYKL.js +3 -0
  60. package/dist/cdn/LHLO6PTD.js +2 -0
  61. package/dist/cdn/{7RCQFLPP.js → LK7ZIQW6.js} +1 -1
  62. package/dist/cdn/LUY6V4TP.js +181 -0
  63. package/dist/cdn/M3MRIGDZ.js +2 -0
  64. package/dist/cdn/{VOQX4AVB.js → MW5S2XCB.js} +6 -4
  65. package/dist/cdn/MWYBF3F3.js +66 -0
  66. package/dist/cdn/NEV6OZN3.js +71 -0
  67. package/dist/cdn/OKMZQXBQ.js +2 -0
  68. package/dist/cdn/OKTBWKNG.js +2 -0
  69. package/dist/cdn/{23EQTPO3.js → OKVLGJAG.js} +1 -1
  70. package/dist/cdn/OWXCOUIQ.js +2 -0
  71. package/dist/cdn/OYNIFMCJ.js +2 -0
  72. package/dist/cdn/{LQ6R5YRN.js → PQ2DPOFM.js} +1 -1
  73. package/dist/cdn/PUFTYLJ2.js +22 -0
  74. package/dist/cdn/PVE7Q43N.js +2 -0
  75. package/dist/cdn/R74ZHFA6.js +2 -0
  76. package/dist/cdn/RLEHNAIA.js +2 -0
  77. package/dist/cdn/{X2ZDYHCG.js → SDWWUWAF.js} +10 -5
  78. package/dist/cdn/ST5FQYT7.js +180 -0
  79. package/dist/cdn/SXHH575T.js +48 -0
  80. package/dist/cdn/T4ECSHM7.js +2 -0
  81. package/dist/cdn/TFT6HK3O.js +208 -0
  82. package/dist/cdn/TPULIO6I.js +34 -0
  83. package/dist/cdn/U3XIDLHO.js +3 -0
  84. package/dist/cdn/{6YMR4QSD.js → UHEYPSOR.js} +1 -1
  85. package/dist/cdn/UZLQALHY.js +2 -0
  86. package/dist/cdn/V6HOUZPZ.js +2 -0
  87. package/dist/cdn/VAXH6RUQ.js +134 -0
  88. package/dist/cdn/VXFQANGJ.js +2 -0
  89. package/dist/cdn/WQGJATNJ.js +2 -0
  90. package/dist/cdn/WSHWQDO2.js +2 -0
  91. package/dist/cdn/WUNCZOGU.js +2 -0
  92. package/dist/cdn/WVPU4QOO.js +2 -0
  93. package/dist/cdn/WXWO5D3W.js +2 -0
  94. package/dist/cdn/XCRR2EEG.js +6 -0
  95. package/dist/cdn/XETNZW4D.js +3 -0
  96. package/dist/cdn/XRE5USHA.js +2 -0
  97. package/dist/cdn/YHQJ66WJ.js +2 -0
  98. package/dist/cdn/ZCEMEUP7.js +2 -0
  99. package/dist/cdn/ZS6SXJP2.js +2 -0
  100. package/dist/cdn/{ZTBA5PM7.js → ZU2FHVNK.js} +1 -1
  101. package/dist/cdn/agent-utils/index.js +2 -0
  102. package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +3 -0
  103. package/dist/cdn/agent-utils/middlewares/middleware.js +2 -0
  104. package/dist/cdn/agent-utils/middlewares/trace.js +2 -0
  105. package/dist/cdn/index.js +1 -1
  106. package/dist/chunks/adapter.js +1795 -1598
  107. package/dist/chunks/arcgisKnowledgeGraph.js +127 -72
  108. package/dist/chunks/arcgis_knowledge_current_lc_context.js +19 -2
  109. package/dist/chunks/arcgis_knowledge_current_map_context.js +31 -2
  110. package/dist/chunks/arcgis_knowledge_cypher_query_prompt.js +102 -0
  111. package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +116 -27
  112. package/dist/chunks/converterUtils.js +39 -32
  113. package/dist/chunks/dataExplorationGraph.js +140 -114
  114. package/dist/chunks/data_explore_query_prompt.js +9 -4
  115. package/dist/chunks/generateLayerDescriptions.js +265 -240
  116. package/dist/chunks/helpGraph.js +30 -23
  117. package/dist/chunks/help_prompt.js +34 -17
  118. package/dist/chunks/index.js +11 -0
  119. package/dist/chunks/intent_prompt.js +16 -0
  120. package/dist/chunks/layerStylingGraph.js +25 -21
  121. package/dist/chunks/navigationGraph.js +79 -70
  122. package/dist/chunks/navigation_intent_prompt.js +8 -2
  123. package/dist/chunks/orchestrator.js +205 -175
  124. package/dist/chunks/slottableRequestUtils.js +3 -7
  125. package/dist/chunks/state.js +1 -1
  126. package/dist/chunks/summarize_query_response_prompt.js +9 -7
  127. package/dist/chunks/toolCallResponse.js +13 -10
  128. package/dist/chunks/utils2.js +8 -8
  129. package/dist/components/arcgis-assistant/customElement.d.ts +27 -0
  130. package/dist/components/arcgis-assistant/customElement.js +386 -152
  131. package/dist/components/arcgis-assistant/index.js +2 -3
  132. package/dist/components/arcgis-assistant/types.d.ts +14 -1
  133. package/dist/components/arcgis-assistant-agent/customElement.js +5 -1
  134. package/dist/components/arcgis-assistant-chat/customElement.d.ts +2 -1
  135. package/dist/components/arcgis-assistant-chat/customElement.js +23 -18
  136. package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +2 -0
  137. package/dist/components/arcgis-assistant-chat-entry/customElement.js +25 -18
  138. package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +12 -6
  139. package/dist/components/arcgis-assistant-help-agent/customElement.js +9 -3
  140. package/dist/components/arcgis-assistant-interrupt/customElement.js +12 -8
  141. package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +20 -0
  142. package/dist/components/arcgis-assistant-interrupt-preview/index.js +2 -0
  143. package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +7 -7
  144. package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +18 -12
  145. package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +11 -5
  146. package/dist/components/arcgis-assistant-message/customElement.d.ts +2 -0
  147. package/dist/components/arcgis-assistant-message/customElement.js +28 -26
  148. package/dist/components/arcgis-assistant-message/index.js +2 -0
  149. package/dist/components/arcgis-assistant-message-block/customElement.js +18 -11
  150. package/dist/components/arcgis-assistant-message-block/index.js +1 -0
  151. package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +4 -0
  152. package/dist/components/arcgis-assistant-message-loading/customElement.js +10 -10
  153. package/dist/components/arcgis-assistant-message-loading/index.js +1 -0
  154. package/dist/components/arcgis-assistant-message-text/customElement.d.ts +1 -0
  155. package/dist/components/arcgis-assistant-message-text/customElement.js +12 -12
  156. package/dist/components/arcgis-assistant-navigation-agent/customElement.js +12 -6
  157. package/dist/components/arcgis-assistant-speech-input/customElement.js +29 -46
  158. package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +8 -8
  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/loader.js +7 -6
  165. package/dist/oauth-callback.html +1 -1
  166. package/dist/types/lumina.d.ts +7 -6
  167. package/dist/types/preact.d.ts +7 -6
  168. package/dist/types/react.d.ts +7 -6
  169. package/dist/types/stencil.d.ts +7 -6
  170. package/dist/utils/index.d.ts +95 -47
  171. package/dist/utils/index.js +80 -65
  172. package/package.json +12 -11
  173. package/dist/cdn/2AXF774U.js +0 -2
  174. package/dist/cdn/3NI46YCE.js +0 -2
  175. package/dist/cdn/3PKJWIC3.js +0 -2
  176. package/dist/cdn/462JBSEV.js +0 -422
  177. package/dist/cdn/47FWPQ2A.js +0 -16
  178. package/dist/cdn/5QAHYX7Y.js +0 -5
  179. package/dist/cdn/7BCR6TUO.js +0 -2
  180. package/dist/cdn/7GH7VSB2.js +0 -2
  181. package/dist/cdn/7PLV4QH6.js +0 -2
  182. package/dist/cdn/AEJHYRGT.js +0 -166
  183. package/dist/cdn/AO7BQHKC.js +0 -2
  184. package/dist/cdn/AXDZBBNL.js +0 -45
  185. package/dist/cdn/BFZJNJL6.js +0 -22
  186. package/dist/cdn/DDLZOMUY.js +0 -2
  187. package/dist/cdn/DHOVCT6R.js +0 -2
  188. package/dist/cdn/F2AHA4GB.js +0 -54
  189. package/dist/cdn/FX5JFRDL.js +0 -2
  190. package/dist/cdn/GCQLVNNC.js +0 -14
  191. package/dist/cdn/HB5A5R2E.js +0 -2
  192. package/dist/cdn/JV4SI65E.js +0 -108
  193. package/dist/cdn/KMQ3SP4I.js +0 -5
  194. package/dist/cdn/MH5RPXHM.js +0 -2
  195. package/dist/cdn/NAUXSHIE.js +0 -72
  196. package/dist/cdn/NVI3I46B.js +0 -2
  197. package/dist/cdn/OAVEHGB6.js +0 -2
  198. package/dist/cdn/OH64RMOR.js +0 -4
  199. package/dist/cdn/P6OPJQMC.js +0 -3
  200. package/dist/cdn/QR54T33D.js +0 -2
  201. package/dist/cdn/R6HV42YW.js +0 -3
  202. package/dist/cdn/RVOAPUBN.js +0 -2
  203. package/dist/cdn/SXDLXCIM.js +0 -2
  204. package/dist/cdn/USMDJUFS.js +0 -2
  205. package/dist/cdn/V2P4AIGG.js +0 -2
  206. package/dist/cdn/V7OJRG26.js +0 -36
  207. package/dist/cdn/Y333DGV6.js +0 -2
  208. package/dist/cdn/YIMNOUTF.js +0 -2
@@ -1,35 +1,171 @@
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 "@arcgis/core/request.js";
17
+ import V from "@arcgis/core/identity/IdentityManager.js";
18
+ import "@arcgis/toolkit/string";
19
+ import "@arcgis/core/config.js";
16
20
  import "@langchain/core/messages";
17
21
  import "@arcgis/core/layers/FeatureLayer.js";
18
22
  import "../../chunks/generateLayerDescriptions.js";
19
23
  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;
24
+ import j from "@arcgis/core/core/Accessor.js";
25
+ import { property as m, subclass as q } from "@arcgis/core/core/accessorSupport/decorators.js";
26
+ import { marked as E } from "marked";
27
+ import { g as H } from "../../chunks/utils3.js";
28
+ import { g as S } from "../../chunks/slottableRequestUtils.js";
29
+ 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)}`;
30
+ function w(o) {
31
+ return o.trim() ? E.lexer(o).filter((t) => t.type !== "space").map((t) => E.parser([t])) : [];
32
+ }
33
+ class I {
34
+ constructor() {
35
+ this._stableParts = [], this._stableText = "", this._rawText = "";
36
+ }
37
+ // full streamed markdown so far
38
+ // Add one chunk and return all current segments.
39
+ push(t) {
40
+ return this._rawText += t, this._advanceStableBoundary(), this.getParts();
41
+ }
42
+ // Parse the remaining live tail. Call once at stream end.
43
+ finalize() {
44
+ const t = this._rawText.slice(this._stableText.length);
45
+ return t.trim() && (this._stableParts.push(...w(t)), this._stableText = this._rawText), this._stableParts;
46
+ }
47
+ // Get full output: stable segments + current live tail.
48
+ getParts() {
49
+ const t = this._trimIncompleteTail(this._rawText.slice(this._stableText.length)), s = t.trim() ? w(t) : [];
50
+ return [...this._stableParts, ...s];
51
+ }
52
+ reset() {
53
+ this._stableParts = [], this._stableText = "", this._rawText = "";
54
+ }
55
+ // Move parse-safe content from live tail into stable content.
56
+ _advanceStableBoundary() {
57
+ const t = this._rawText.slice(this._stableText.length), s = this._lastSafeBoundary(t);
58
+ if (s <= 0)
59
+ return;
60
+ const i = t.slice(0, s);
61
+ this._stableParts.push(...w(i)), this._stableText += i;
62
+ }
63
+ /**
64
+ * Find the last blank-line boundary that is outside code fences.
65
+ * Returns 0 if no safe boundary is available yet.
66
+ */
67
+ _lastSafeBoundary(t) {
68
+ const s = t.split(`
69
+ `);
70
+ let i = !1, e = 0, n = 0;
71
+ for (const r of s)
72
+ /^\s*(```|~~~)/u.test(r) && (i = !i), n += r.length + 1, r.trim() === "" && !i && (e = n);
73
+ return e < t.length ? e : 0;
74
+ }
75
+ /**
76
+ * Remove incomplete syntax at the end so we do not render partial markup.
77
+ * Handles:
78
+ * - open HTML tags without closing '>'
79
+ * - HTML elements missing closing tags
80
+ * - markdown links missing closing ')'
81
+ */
82
+ _trimIncompleteTail(t) {
83
+ const s = t.lastIndexOf("<");
84
+ if (s !== -1 && !t.includes(">", s))
85
+ return t.slice(0, s);
86
+ const i = this._earliestUnclosedTag(t);
87
+ if (i !== -1)
88
+ return t.slice(0, i);
89
+ const e = t.lastIndexOf("[");
90
+ if (e !== -1) {
91
+ const n = t.slice(e);
92
+ if (!/\[[^\]]*\]\([^)]*\)/u.test(n))
93
+ return t.slice(0, e);
94
+ }
95
+ return t;
96
+ }
97
+ /**
98
+ * Return the index of the earliest unclosed opening tag, or -1.
99
+ * Ignores void elements (img, br, input, etc.) and self-closing tags.
100
+ */
101
+ _earliestUnclosedTag(t) {
102
+ const s = /* @__PURE__ */ new Set([
103
+ "br",
104
+ "img",
105
+ "hr",
106
+ "input",
107
+ "meta",
108
+ "link",
109
+ "area",
110
+ "base",
111
+ "col",
112
+ "embed",
113
+ "source",
114
+ "track",
115
+ "wbr"
116
+ ]), i = /<(\/?)([a-zA-Z][\w-]*)\b[^>]*?(\/?)>/gu, e = [];
117
+ for (let n = i.exec(t); n; n = i.exec(t)) {
118
+ const [, r, a, l] = n, h = a.toLowerCase();
119
+ if (!(s.has(h) || l === "/"))
120
+ if (r === "/") {
121
+ for (let p = e.length - 1; p >= 0; p--)
122
+ if (e[p].name === h) {
123
+ e.splice(p);
124
+ break;
125
+ }
126
+ } else
127
+ e.push({ name: h, index: n.index });
128
+ }
129
+ return e.length ? e[0].index : -1;
130
+ }
131
+ }
132
+ function G(o) {
133
+ const t = new I();
134
+ return t.push(o), t.finalize();
135
+ }
136
+ const W = async (o) => await new Promise((t) => setTimeout(t, o));
137
+ async function* Y(o, { chunkSize: t = 15, delay: s = 50 } = {}) {
138
+ const i = new I();
139
+ for (let e = 0; e < o.length; e += t)
140
+ yield i.push(o.slice(e, e + t)), await W(s);
141
+ yield i.finalize();
142
+ }
143
+ var Z = Object.defineProperty, J = Object.getOwnPropertyDescriptor, u = (o, t, s, i) => {
144
+ for (var e = i > 1 ? void 0 : i ? J(t, s) : t, n = o.length - 1, r; n >= 0; n--)
145
+ (r = o[n]) && (e = (i ? r(t, s, e) : r(e)) || e);
146
+ return i && e && Z(t, s, e), e;
29
147
  };
30
- let l = class extends A {
31
- constructor(p) {
32
- super(p), this.view = null, this.loading = !1, this.processing = !1, this.processingStep = "";
148
+ const $ = (o) => !o || typeof o != "object" ? !1 : o.name === "AbortError";
149
+ async function* C(o, t, s, i, e = !1) {
150
+ if (e) {
151
+ if (i?.aborted) {
152
+ yield { type: "cancelled", log: s, runId: t };
153
+ return;
154
+ }
155
+ yield { type: "block-data", blockType: "text", data: { parts: G(o) }, runId: t };
156
+ return;
157
+ }
158
+ for await (const n of Y(o)) {
159
+ if (i?.aborted) {
160
+ yield { type: "cancelled", log: s, runId: t };
161
+ return;
162
+ }
163
+ yield { type: "block-data", blockType: "text", data: { parts: n }, runId: t };
164
+ }
165
+ }
166
+ let d = class extends j {
167
+ constructor(o) {
168
+ super(o), this.view = null, this.streamingDisabled = !1, this.loading = !1, this.processing = !1, this.processingStep = "";
33
169
  }
34
170
  async load() {
35
171
  this._set("loading", !0);
@@ -43,14 +179,14 @@ let l = class extends A {
43
179
  this.orchestrator?.dispose(), super.destroy();
44
180
  }
45
181
  async _initialize() {
46
- this.removeHandles(), await Promise.all([this.portal.load(), this.view?.when()]), this.view && await C(() => !this.view.updating), this._set(
182
+ this.removeHandles(), await Promise.all([this.portal.load(), this.view?.when()]), this.view && await L(() => !this.view.updating), this._set(
47
183
  "orchestrator",
48
- await O.init({
184
+ await U.init({
49
185
  agents: [...this.agents],
50
186
  view: this.view ?? void 0
51
187
  })
52
188
  ), this.addHandles([
53
- L(
189
+ R(
54
190
  () => [this.view, this.agents],
55
191
  () => {
56
192
  this._initialize();
@@ -61,64 +197,78 @@ let l = class extends A {
61
197
  clearChatHistory() {
62
198
  this.orchestrator?.newConversation();
63
199
  }
64
- async *ask(p, t) {
200
+ async *ask(o, t) {
65
201
  if (!this.orchestrator)
66
202
  throw new Error("Orchestrator not initialized yet.");
67
203
  this._set("processing", !0), this._set("processingStep", "");
68
- const e = [];
69
- let i;
204
+ const s = [];
205
+ let i, e = "pending";
70
206
  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) {
207
+ const n = this.orchestrator.ask(o);
208
+ for await (const r of n)
209
+ switch (e = r.runId, r.type) {
79
210
  case "trace": {
80
- this._set("processingStep", r.data.text), e.push(r.data.text);
211
+ this._set("processingStep", r.data.text), s.push(r.data.text);
81
212
  break;
82
213
  }
83
214
  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 };
215
+ this._set("processing", !1), this._set("processingStep", "");
216
+ const a = r.result, l = !!a.content.length, h = !!i?.length;
217
+ if (!l && !h) {
218
+ yield { type: "completed", error: "No response received.", log: s, runId: e };
87
219
  return;
88
220
  }
89
- const d = c.content;
90
- this._set("processingStep", ""), yield { type: "completed", response: d, blocks: i, log: e, runId: n };
221
+ const p = a.content;
222
+ 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)
223
+ for (const f of i) {
224
+ if (t?.aborted) {
225
+ yield { type: "cancelled", log: s, runId: e };
226
+ return;
227
+ }
228
+ const { type: b, data: _ } = f;
229
+ if (yield { type: "block-start", blockType: b, runId: e }, b === "text") {
230
+ const P = typeof _?.content == "string" ? _.content : "";
231
+ yield* C(P, e, s, t, this.streamingDisabled);
232
+ } else
233
+ yield { type: "block-data", blockType: b, data: _, runId: e };
234
+ yield { type: "block-end", blockType: b, runId: e };
235
+ }
236
+ yield { type: "completed", response: p, blocks: i, log: s, runId: e };
91
237
  return;
92
238
  }
93
239
  case "ux-suggestion": {
94
- const c = r.suggestion;
95
- i = i ? [...i, c] : [c];
240
+ const a = r.suggestion;
241
+ i = i ? [...i, a] : [a];
96
242
  break;
97
243
  }
98
244
  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) {
245
+ const { kind: a, message: l, metadata: h } = r.interrupt, p = Array.isArray(h) ? h.filter((b) => typeof b == "string") : [], f = (() => {
246
+ switch (a) {
101
247
  case "booleanChoice":
102
- return { type: "boolean-choice", message: g, options: d };
248
+ return { type: "boolean-choice", message: l, options: p };
103
249
  case "singleSelection":
104
- return { type: "single-select", message: g, options: d };
250
+ return { type: "single-select", message: l, options: p };
105
251
  case "multipleSelection":
106
- return { type: "multi-select", message: g, options: d };
252
+ return { type: "multi-select", message: l, options: p };
107
253
  case "textInput":
108
- return { type: "text-input", message: g };
254
+ return { type: "text-input", message: l };
109
255
  default:
110
- return { type: c, message: g, options: d };
256
+ return { type: a, message: l, options: p };
111
257
  }
112
258
  })();
113
- this._set("processingStep", "Waiting for user input..."), yield { type: "interrupt", payload: w, runId: n };
259
+ this._set("processingStep", "Waiting for user input..."), yield { type: "interrupt", payload: f, runId: e };
114
260
  break;
115
261
  }
116
262
  case "cancelled": {
117
- yield { type: "cancelled", runId: n };
263
+ yield { type: "cancelled", log: s, runId: e };
118
264
  return;
119
265
  }
120
266
  case "error": {
121
- yield { type: "completed", error: r.error.message, log: e, runId: n };
267
+ if (t?.aborted || $(r.error)) {
268
+ yield { type: "cancelled", log: s, runId: e };
269
+ return;
270
+ }
271
+ yield { type: "completed", error: r.error.message, log: s, runId: e };
122
272
  return;
123
273
  }
124
274
  default: {
@@ -126,105 +276,118 @@ let l = class extends A {
126
276
  break;
127
277
  }
128
278
  }
279
+ } catch (n) {
280
+ if (t?.aborted || $(n)) {
281
+ yield { type: "cancelled", log: s, runId: e };
282
+ return;
129
283
  }
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" };
284
+ console.warn("Error during message processing:", n), yield { type: "completed", error: "An error occurred during message processing.", log: s, runId: "error" };
132
285
  return;
133
286
  } finally {
134
287
  this._set("processing", !1);
135
288
  }
136
289
  }
290
+ cancel() {
291
+ this.orchestrator?.cancel();
292
+ }
137
293
  };
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([
294
+ u([
295
+ m({ readOnly: !0 })
296
+ ], d.prototype, "orchestrator", 2);
297
+ u([
298
+ m()
299
+ ], d.prototype, "agents", 2);
300
+ u([
301
+ m()
302
+ ], d.prototype, "portal", 2);
303
+ u([
304
+ m()
305
+ ], d.prototype, "view", 2);
306
+ u([
307
+ m()
308
+ ], d.prototype, "streamingDisabled", 2);
309
+ u([
310
+ m({ readOnly: !0 })
311
+ ], d.prototype, "loading", 2);
312
+ u([
313
+ m({ readOnly: !0 })
314
+ ], d.prototype, "processing", 2);
315
+ u([
316
+ m({ readOnly: !0 })
317
+ ], d.prototype, "processingStep", 2);
318
+ d = u([
160
319
  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 {
320
+ ], d);
321
+ 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";
322
+ class tt extends M {
164
323
  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) => {
324
+ 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
325
  t.stopPropagation(), this.cancelInterrupt();
167
- }, this.#a = (t) => {
326
+ }, this.#n = (t) => {
168
327
  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);
328
+ const s = t.detail;
329
+ this.submitInterrupt(s);
175
330
  }, this.#c = (t) => {
176
- if (t.stopPropagation(), this.arcgisCancel.emit(), this._interrupt) {
331
+ t.stopPropagation(), this.keepSuggestedPrompts || (this.suggestedPrompts = []);
332
+ const s = t.detail;
333
+ this._inputValue = "", this.arcgisSubmit.emit(s), this.submitMessage(s);
334
+ }, this.#h = (t) => {
335
+ if (this._canceling = !0, t.stopPropagation(), this.arcgisCancel.emit(), this._interrupt) {
177
336
  this.orchestrator?.cancelInterrupt(), this._interrupt = null;
178
337
  return;
179
338
  }
180
- this.#s?.abort();
181
- }, this.#h = (t) => {
182
- t.stopPropagation();
183
- const e = t.detail;
184
- this.arcgisFeedback.emit(e);
339
+ this._orchestratorController?.cancel(), this.#e?.abort(), this.#e = null;
185
340
  }, this.#p = (t) => {
186
341
  t.stopPropagation();
187
- const e = t.detail;
188
- this._inputValue = e.prompt, this.arcgisPromptSelect.emit(e);
342
+ const s = t.detail;
343
+ this.arcgisFeedback.emit(s);
189
344
  }, this.#g = (t) => {
345
+ t.stopPropagation();
346
+ const s = t.detail;
347
+ this._inputValue = s.prompt, this.arcgisPromptSelect.emit(s);
348
+ }, this.#d = (t) => {
190
349
  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 });
350
+ }, 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
351
  }
193
352
  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 };
353
+ 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
354
  }
196
355
  static {
197
- this.styles = V;
356
+ this.styles = F;
198
357
  }
199
358
  #t;
200
- #n;
201
- #e;
359
+ #l;
202
360
  #s;
203
- #o;
361
+ #e;
204
362
  #r;
205
363
  #i;
206
364
  #a;
207
- #l;
365
+ #n;
208
366
  #c;
209
367
  #h;
210
368
  #p;
211
369
  #g;
212
- async #u() {
370
+ #d;
371
+ async #o() {
213
372
  try {
214
- const t = z(this.el, this.referenceElement);
373
+ const t = H(this.el, this.referenceElement);
215
374
  await t?.componentOnReady();
216
- const e = [...this.#o.values()];
217
- return e.length ? (this._orchestratorController = new l({
218
- agents: e,
219
- portal: this.#r,
375
+ const s = [...this.#r.values()];
376
+ return s.length ? (this._orchestratorController?.destroy(), this._orchestratorController = new d({
377
+ agents: s,
378
+ portal: this.#i,
379
+ streamingDisabled: this.streamingDisabled,
220
380
  view: t?.view
221
381
  }), await this._orchestratorController.load(), !0) : (this._error = "No agents found.", !1);
222
382
  } catch (t) {
223
- return this._error = t?.message ?? "Error initializing orchestrator.", x(this)(t), !1;
383
+ return this._error = t?.message ?? "Error initializing orchestrator.", z(this)(t), !1;
224
384
  }
225
385
  }
386
+ get _isSignedIn() {
387
+ return !!this.#i?.user || !!this._signedInUserId;
388
+ }
226
389
  get _user() {
227
- return this.#r?.user?.fullName || this.#r?.user?.username;
390
+ return this.#i?.user?.fullName || this.#i?.user?.username;
228
391
  }
229
392
  get awaitingResponse() {
230
393
  return this._orchestratorController?.processing ?? !1;
@@ -245,85 +408,156 @@ class F extends R {
245
408
  this.arcgisInterruptCancel.emit(), this.orchestrator?.cancelInterrupt(), this._interrupt = null;
246
409
  }
247
410
  register(t) {
248
- this.#o.set(t.agent.id, t);
411
+ this.#r.set(t.agent.id, t), this._orchestratorController && this.#o();
412
+ }
413
+ unregister(t) {
414
+ this.#r.delete(t), this._orchestratorController && this.#o();
249
415
  }
250
416
  async submitMessage(t) {
251
- const e = t.trim();
252
- if (!e || (this.messages.push({
417
+ const s = t.trim();
418
+ if (!s || (this.messages.push({
253
419
  id: Date.now().toString(),
254
420
  // TODO: Replace with a more robust ID generation method or get from orchestrator
255
421
  role: "user",
256
- content: e
422
+ content: s
257
423
  }), !this._orchestratorController))
258
424
  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) {
425
+ this.#e = new AbortController(), this._orchestratorController.streamingDisabled = this.streamingDisabled;
426
+ const i = this._orchestratorController.ask(s, this.#e?.signal);
427
+ for await (const e of i) {
428
+ const n = e.runId, r = this.messages.at(-1);
429
+ switch (e.type) {
430
+ case "block-start": {
431
+ this._isAnswering = !0;
432
+ const a = { type: e.blockType, isPending: !0 };
433
+ if (r?.role === "assistant" && r.id === n) {
434
+ const l = [...r.blocks ?? [], a];
435
+ this.messages.splice(-1, 1, { ...r, blocks: l });
436
+ } else
437
+ this.messages.push({
438
+ role: "assistant",
439
+ blocks: [a],
440
+ id: n,
441
+ isStreaming: !0,
442
+ interrupts: this._interruptDetails
443
+ }), this._interruptDetails = [];
444
+ break;
445
+ }
446
+ case "block-data": {
447
+ if (r?.role !== "assistant" || r?.id !== n)
448
+ break;
449
+ const a = [...r.blocks ?? []], l = a[a.length - 1], { blockType: h, data: p } = e;
450
+ if (l?.type !== h || !l.isPending)
451
+ break;
452
+ h === "text" ? a[a.length - 1] = {
453
+ ...l,
454
+ data: {
455
+ ...l.data,
456
+ parts: p?.parts
457
+ }
458
+ } : a[a.length - 1] = { ...l, data: { ...l.data, ...p ?? {} } }, this.messages.splice(-1, 1, { ...r, blocks: a });
459
+ break;
460
+ }
461
+ case "block-end": {
462
+ if (r?.role !== "assistant" || r?.id !== n)
463
+ break;
464
+ const a = [...r.blocks ?? []], l = a[a.length - 1];
465
+ if (l?.type !== e.blockType || !l.isPending)
466
+ break;
467
+ const h = l;
468
+ a[a.length - 1] = { ...h, data: { ...h.data }, isPending: !1 }, this.messages.splice(-1, 1, { ...r, blocks: a });
469
+ break;
470
+ }
263
471
  case "completed":
264
- this.messages.push({
472
+ e.error ? (this.messages.push({
265
473
  role: "assistant",
266
- content: s.response,
267
- blocks: s.blocks,
268
- log: s.log,
269
- error: s.error,
270
- id: r
271
- });
474
+ log: e.log,
475
+ error: e.error,
476
+ id: n,
477
+ interrupts: this._interruptDetails
478
+ }), this._interruptDetails = []) : r?.role === "assistant" && r.id === n && this.messages.splice(-1, 1, {
479
+ ...r,
480
+ content: e.response,
481
+ blocks: r.blocks?.map((a) => ({ ...a, data: { ...a.data }, isPending: !1 })) ?? [],
482
+ isStreaming: !1,
483
+ log: e.log
484
+ }), this._isAnswering = !1, this.#e = null, this._canceling = !1;
272
485
  break;
273
486
  case "interrupt":
274
- this._interrupt = { ...s.payload, id: r }, this.arcgisInterrupt.emit(this._interrupt);
487
+ this._interrupt = { ...e.payload, id: n }, this.arcgisInterrupt.emit(this._interrupt);
275
488
  break;
276
489
  case "cancelled":
277
- this.messages.push({
490
+ r?.role === "assistant" && r.id === n ? this.messages.splice(-1, 1, {
491
+ ...r,
492
+ blocks: r.blocks?.filter((a) => a.type === "text" || !a.isPending) ?? [],
493
+ isStreaming: !1,
494
+ log: e.log,
495
+ error: "(Stopped by user)"
496
+ // TODO: use strings from t9n
497
+ }) : (this.messages.push({
278
498
  role: "assistant",
279
- error: "Request cancelled.",
280
- id: r
281
- });
499
+ log: e.log,
500
+ error: "(Stopped by user)",
501
+ // TODO: use strings from t9n
502
+ id: n,
503
+ interrupts: this._interruptDetails
504
+ }), this._interruptDetails = []), this._isAnswering = !1, this.#e = null, this._canceling = !1;
282
505
  break;
283
506
  }
284
507
  }
285
508
  }
286
509
  submitInterrupt(t) {
287
- this.arcgisInterruptSubmit.emit(t), this.orchestrator?.resumeInterrupt(t), this._interrupt = null;
510
+ this.arcgisInterruptSubmit.emit(t), this._interrupt && (this._interruptDetails = [...this._interruptDetails, { interrupt: this._interrupt, response: t }]), this.orchestrator?.resumeInterrupt(t), this._interrupt = null;
288
511
  }
289
512
  load() {
290
513
  this.manager.onLifecycle(this._reset.bind(this));
291
514
  }
292
515
  loaded() {
293
516
  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 });
517
+ 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);
518
+ const t = D(() => !!this._interrupt && !!this.#s.value, () => {
519
+ const i = this.#s.value;
520
+ i.removeEventListener("arcgisSubmit", this.#n), i.removeEventListener("arcgisCancel", this.#a), i.addEventListener("arcgisSubmit", this.#n, { once: !0 }), i.addEventListener("arcgisCancel", this.#a, { once: !0 });
521
+ }), s = this.messages.on("after-add", (i) => {
522
+ const e = i.item;
523
+ e.role === "assistant" && (e.error || e.content) && this.arcgisResponse.emit(e);
298
524
  });
299
525
  return queueMicrotask(() => {
300
- this.#u().then((e) => {
301
- e ? this.arcgisReady.emit() : this._error && this.arcgisError.emit(new Error(this._error));
526
+ this.#o().then((i) => {
527
+ i ? this.arcgisReady.emit() : this._error && this.arcgisError.emit(new Error(this._error));
302
528
  });
303
529
  }), () => {
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;
530
+ 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
531
  };
306
532
  });
307
533
  }
308
534
  _reset() {
309
- this.#s?.abort(), this._interrupt = null, this.messages.removeAll(), this._error = null, this._inputValue = "";
535
+ this._orchestratorController?.cancel(), this.#e?.abort(), this._interrupt = null, this.messages.removeAll(), this._error = null, this._inputValue = "", this._signedInUserId = void 0;
310
536
  }
311
537
  _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>`;
538
+ 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
539
  }
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;
540
+ _renderSignInNotice() {
541
+ const t = this.#i;
542
+ 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 () => {
543
+ try {
544
+ const s = await V.getCredential(`${t.url}/sharing`);
545
+ this._signedInUserId = s.userId, this._error = null, this.requestUpdate(), await this.#o() ? this.arcgisReady.emit() : this._error && this.arcgisError.emit(new Error(this._error));
546
+ } catch (s) {
547
+ this._error = s?.message ?? "Error signing in.", this.arcgisError.emit(new Error(this._error)), B.log("error", this, "Error signing in:", { detail: { error: s } });
548
+ }
549
+ }} target=_blank title="Sign in to ArcGIS Online">Sign in</calcite-link>` : c`<div slot=link>No portal information available</div>`}</calcite-notice>`;
316
550
  }
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;
551
+ _renderErrorNotice() {
552
+ 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
553
  }
320
554
  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>`;
555
+ 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=${() => {
556
+ this.#l.value?.submitMessage();
557
+ }} 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
558
  }
325
559
  }
326
- $("arcgis-assistant", F);
560
+ x("arcgis-assistant", tt);
327
561
  export {
328
- F as ArcgisAssistant
562
+ tt as ArcgisAssistant
329
563
  };