@arcgis/coding-components 4.34.0-next.3 → 4.34.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 (88) hide show
  1. package/dist/addons/arcade-coding-assistant/chat-helper.d.ts +25 -7
  2. package/dist/addons/arcade-coding-assistant/temporary-strings.d.ts +47 -0
  3. package/dist/addons/arcade-coding-assistant/useArcadeAssistant.d.ts +15 -7
  4. package/dist/addons.js +32 -23
  5. package/dist/cdn/{TUHPJEG5.js → 243HZ7UI.js} +2 -2
  6. package/dist/cdn/{J3HINC5N.js → 275GUA3M.js} +2 -2
  7. package/dist/cdn/{HAL3EXK4.js → 3J5TNLID.js} +2 -2
  8. package/dist/cdn/{Q4NJDLN3.js → 4DTIYTO6.js} +2 -2
  9. package/dist/cdn/{XNMOJ2SC.js → 4YQMMXJW.js} +2 -2
  10. package/dist/cdn/{D2Q4JNSY.js → 63FQPWTO.js} +2 -2
  11. package/dist/cdn/{CCQCZKCC.js → 6FY2AO4H.js} +2 -2
  12. package/dist/cdn/{Z3HBU3YI.js → 6TAOJNTW.js} +2 -2
  13. package/dist/cdn/73X3KSHQ.js +4 -0
  14. package/dist/cdn/{E4PTTXH5.js → 7ZZRCI6T.js} +2 -2
  15. package/dist/cdn/{FKQ7SSE6.js → ACFFT2B3.js} +2 -2
  16. package/dist/cdn/AQUP2HXZ.js +4 -0
  17. package/dist/cdn/AUUFEK2C.js +4 -0
  18. package/dist/cdn/{D4OPUHHF.js → C6IJOPEB.js} +2 -2
  19. package/dist/cdn/{ZBGL3SYO.js → CG3PBJU2.js} +1 -1
  20. package/dist/cdn/{RKCAAVN6.js → CSS7NGXW.js} +2 -2
  21. package/dist/cdn/{PULCYE7H.js → D3YK5GGC.js} +2 -2
  22. package/dist/cdn/{RFV2R57W.js → DQ3CWBLF.js} +2 -2
  23. package/dist/cdn/DU4OWFNM.js +6 -0
  24. package/dist/cdn/{YHNSFDD7.js → DU5TBBFS.js} +6 -5
  25. package/dist/cdn/{CPQVVDWR.js → E6HEGXX7.js} +2 -2
  26. package/dist/cdn/{HD2PUJ4M.js → EYUSBYIW.js} +2 -2
  27. package/dist/cdn/{NRWICP4W.js → G2IB3XMP.js} +1 -1
  28. package/dist/cdn/{PN27PZAJ.js → HJJWMOF6.js} +1 -1
  29. package/dist/cdn/IOZSQPXO.js +4 -0
  30. package/dist/cdn/{5PZD27HR.js → KBZEMXOZ.js} +2 -2
  31. package/dist/cdn/{JWPIQMYD.js → KT6QWFGE.js} +2 -2
  32. package/dist/cdn/{K7OR2NZQ.js → KYTS4Y5Z.js} +2 -2
  33. package/dist/cdn/{6QMJS7YE.js → L7QUBKS2.js} +2 -2
  34. package/dist/cdn/{X52LNMUC.js → LCWDBLK5.js} +2 -2
  35. package/dist/cdn/{NUXDGLLB.js → MWJDLSR7.js} +2 -2
  36. package/dist/cdn/{QD7WBTTH.js → MXYCSRPO.js} +2 -2
  37. package/dist/cdn/{PGN77MRP.js → N72EMFRZ.js} +2 -2
  38. package/dist/cdn/{GOQNPC4I.js → OBNBH4MW.js} +2 -2
  39. package/dist/cdn/{4UJSQGRR.js → OR4EO6XC.js} +3 -3
  40. package/dist/cdn/{IB5UEIFQ.js → PUWOUCEX.js} +3 -3
  41. package/dist/cdn/{IYAABMEA.js → S33IAILZ.js} +2 -2
  42. package/dist/cdn/{SPSZUVWZ.js → SDJ67XRE.js} +2 -2
  43. package/dist/cdn/{3OPZD6HG.js → VNQVJXEK.js} +2 -2
  44. package/dist/cdn/{VPRYSGQQ.js → WG2TPIR6.js} +2 -2
  45. package/dist/cdn/{F2YRSIVP.js → X5FPHYTE.js} +2 -2
  46. package/dist/cdn/assets/code-editor/sql-expr.worker.js +66327 -65375
  47. package/dist/cdn/index.js +2 -2
  48. package/dist/chunks/arcade-defaults.js +2 -2
  49. package/dist/chunks/arcade-executor.js +42 -41
  50. package/dist/chunks/arcade-mode.js +1 -1
  51. package/dist/chunks/arcade-service-accessors.js +1 -1
  52. package/dist/chunks/editor.js +1 -1
  53. package/dist/chunks/fields.js +1 -1
  54. package/dist/chunks/language-defaults-base.js +4 -3
  55. package/dist/chunks/markdown.js +1 -1
  56. package/dist/chunks/monaco-importer.js +64 -44
  57. package/dist/chunks/runtime.js +1 -1
  58. package/dist/chunks/setup-monaco.js +1 -1
  59. package/dist/chunks/sql-expr-contribution.js +1 -1
  60. package/dist/chunks/sql-expr-defaults.js +1 -1
  61. package/dist/chunks/sql-expr-mode.js +1 -1
  62. package/dist/chunks/useT9n.js +1 -1
  63. package/dist/components/arcgis-arcade-coding-assistant/customElement.d.ts +6 -7
  64. package/dist/components/arcgis-arcade-coding-assistant/customElement.js +395 -176
  65. package/dist/components/arcgis-arcade-coding-assistant/functional.d.ts +69 -13
  66. package/dist/components/arcgis-arcade-coding-assistant/index.d.ts +12 -6
  67. package/dist/components/arcgis-arcade-coding-assistant/index.js +12 -6
  68. package/dist/components/arcgis-arcade-coding-assistant/types.d.ts +45 -0
  69. package/dist/components/arcgis-arcade-editor/customElement.js +1 -1
  70. package/dist/components/arcgis-arcade-results/customElement.js +1 -1
  71. package/dist/components/arcgis-arcade-suggestions/customElement.js +1 -1
  72. package/dist/components/arcgis-code-editor/customElement.js +2 -2
  73. package/dist/components/arcgis-editor-variables/customElement.js +1 -1
  74. package/dist/components/arcgis-language-api-panel/customElement.js +1 -1
  75. package/dist/components/arcgis-sql-expression-editor/customElement.js +1 -1
  76. package/dist/components/arcgis-sql-expression-fields/customElement.js +1 -1
  77. package/dist/docs/api.json +5 -5
  78. package/dist/docs/docs.json +5 -5
  79. package/dist/docs/web-types.json +1 -1
  80. package/dist/index.js +1 -1
  81. package/dist/loader.js +2 -2
  82. package/dist/utils/arcade-executor.d.ts +4 -0
  83. package/dist/utils/utilities.d.ts +1 -1
  84. package/package.json +6 -6
  85. package/dist/cdn/K3KP6FDP.js +0 -4
  86. package/dist/cdn/MX7D2TXJ.js +0 -5
  87. package/dist/cdn/SLKYJBMF.js +0 -4
  88. package/dist/cdn/Z75HQNTN.js +0 -4
@@ -1,136 +1,242 @@
1
1
  import { c as V } from "../../chunks/runtime.js";
2
+ import { nothing as C, LitElement as L } from "@arcgis/lumina";
3
+ import { ref as B, createRef as j } from "lit/directives/ref.js";
4
+ import W from "@arcgis/core/identity/IdentityManager.js";
5
+ import { u as Q } from "../../chunks/useT9n.js";
6
+ import { b as E } from "../../chunks/arcade-defaults.js";
7
+ import { css as G } from "@lit/reactive-element/css-tag.js";
8
+ import { html as w } from "lit";
9
+ import T from "@arcgis/core/request.js";
10
+ import { e as J, a as Y } from "../../chunks/monaco-importer.js";
2
11
  import { html as n } from "lit-html";
3
- import { LitElement as T, safeClassMap as F } from "@arcgis/lumina";
4
- import { ref as I, createRef as D } from "lit/directives/ref.js";
5
- import P from "@arcgis/core/identity/IdentityManager.js";
6
- import { u as j } from "../../chunks/useT9n.js";
7
- import { b as N } from "../../chunks/arcade-defaults.js";
8
- import { css as U } from "@lit/reactive-element/css-tag.js";
9
- import "lit";
10
- import $ from "@arcgis/core/request.js";
11
- import { a as A, e as R } from "../../chunks/monaco-importer.js";
12
- import "@arcgis/components-utils";
13
- import _ from "@arcgis/core/layers/FeatureLayer.js";
14
- import z from "@arcgis/core/Graphic.js";
15
- import { unsafeHTML as H } from "lit/directives/unsafe-html.js";
12
+ import { repeat as F } from "lit-html/directives/repeat.js";
13
+ import { generateGuid as K } from "@arcgis/components-utils";
14
+ import { unsafeHTML as k } from "lit/directives/unsafe-html.js";
15
+ import X from "@arcgis/core/layers/FeatureLayer.js";
16
+ import Z from "@arcgis/core/Graphic.js";
17
+ import { b as ee } from "../../chunks/language-defaults-base.js";
16
18
  /*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
17
19
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
18
- v4.34.0-next.3 */
19
- const O = U`:host(:not([closed])){flex:1 0 auto;border-inline-start:var(--arcgis-coding-components-border);box-sizing:border-box;max-width:var(--arcgis-coding-components-side-panel-max-w);width:var(--arcgis-coding-components-side-panel-w)}:host([closed]){display:none}.response-actions{display:flex;align-items:center;padding:.5rem;gap:.5rem}.response-actions>div{display:flex;gap:.5rem}.prompt-list calcite-list-item{margin-block-end:.5rem;border-radius:var(--calcite-corner-radius-round);--calcite-color-border-3: transparent;overflow:hidden}.feedback-content{padding:1rem;display:flex;flex-direction:column;gap:.75rem}.feedback-sheet{--calcite-sheet-height: auto;--calcite-sheet-max-height: auto;--calcite-sheet-min-height: auto}calcite-chip[slot=header-actions-end]{align-self:center;margin-inline-end:.5rem}calcite-list-item:focus calcite-button{position:relative;top:-2px}.prompt-list calcite-list-item:last-of-type{margin-block-end:0}calcite-list{--calcite-color-foreground-1: transparent;background-color:transparent}calcite-list-item{--calcite-color-foreground-1: white}calcite-flow-item calcite-shell{background:transparent}calcite-block{width:100%;max-width:100%;align-self:flex-end;background-color:transparent}calcite-sheet{--calcite-sheet-scrim-background: rgba(200, 200, 200, .5)}.type-suggestion{--calcite-color-foreground-1: var(--calcite-color-foreground-current);--calcite-color-text-3: var(--calcite-color-text-2);--calcite-icon-color: var(--calcite-color-brand)}.type-history{--calcite-icon-color: var(--calcite-color-text-2)}.type-response{--calcite-icon-color: var(--calcite-color-brand);--calcite-font-family: monospace}.block-response{align-self:flex-start;margin-block-end:4rem;border-block-end:0;--calcite-block-text-color: var(--calcite-color-brand)}calcite-list-item calcite-button{margin-inline-end:.25rem}.type-docs{--calcite-color-foreground-1: var(--calcite-color-foreground-3);--calcite-icon-color: var(--calcite-color-text-1)}.type-error{--calcite-icon-color: var(--calcite-color-status-danger);--calcite-font-family: monospace;border:1px solid var(--calcite-color-status-danger)}#thumbs-up{margin-inline-start:auto;--calcite-icon-color: var(--calcite-color-border-input)}#thumbs-down{--calcite-icon-color: var(--calcite-color-border-input)}calcite-flow-item calcite-shell calcite-notice{margin-block:1rem}.no-space-block,.no-space-block[open]{margin:0}calcite-block[open]:last-of-type{border-block-end:0}.text-area-wrapper{display:flex;flex-direction:column;background:#fff;border-radius:4px;margin:.75rem;width:calc(100% - 1.5rem);overflow:hidden;max-width:calc(100% - 1.5rem);--calcite-color-border-input: transparent;--calcite-text-area-divider-color: transparent;position:sticky;align-self:flex-end;box-shadow:var(--calcite-shadow-sm);flex:none}.text-area-wrapper calcite-button:last-of-type{margin-inline-start:auto;align-self:flex-end}calcite-text-area{height:auto;min-height:5.75rem;overflow:hidden;border-radius:4px 4px 0 0;--calcite-font-weight-normal: 500;font-weight:500;line-height:1.2}calcite-tooltip{--calcite-tooltip-z-index: 1000}.standalone-list{margin:1rem;width:calc(100% - 2rem)}.result-disclaimer{display:block;width:24rem;max-width:90%;margin:2rem auto .25rem;text-align:center;line-height:1.125rem;font-size:.875rem;font-style:italic}calcite-flow{height:100%}calcite-popover calcite-list{--calcite-list-background-color: transparent;--calcite-input-border-color: transparent}calcite-popover calcite-list calcite-filter{--calcite-spacing-sm: 0}.break-spaces{white-space:break-spaces}.feedback-button-container{margin-inline-start:auto;gap:0}.info-heading{font-size:var(--calcite-font-size-1);color:var(--calcite-color-text-1)}`;
20
- function S(i) {
20
+ v4.34.0-next.30 */
21
+ const te = G`:host(:not([closed])){--calcite-block-border-color: var(--calcite-color-transparent);flex:1 0 auto;border-inline-start:var(--arcgis-coding-components-border);box-sizing:border-box;max-width:var(--arcgis-coding-components-side-panel-max-w);width:var(--arcgis-coding-components-side-panel-w);.submission-actions-wrapper{display:flex;flex-direction:column;width:100%;gap:.75rem}.submission-actions{display:flex;flex-direction:row;gap:.5rem;justify-content:space-between}.gaps{display:flex;gap:.25rem}.align-inline-end{margin-inline-start:auto}.action .error-display{display:flex;flex-direction:row;gap:.5rem;justify-content:space-between}.context-popover p{padding:0 .5rem;font-size:var(--calcite-font-size-sm)}.prompt-list calcite-list-item{margin-block-end:.5rem;border-radius:var(--calcite-corner-radius-round);--calcite-color-border-3: transparent;overflow:hidden}.feedback-content{padding:1rem;display:flex;flex-direction:column;gap:.75rem}.feedback-sheet{--calcite-sheet-height: auto;--calcite-sheet-max-height: auto;--calcite-sheet-min-height: auto}calcite-chip[slot=header-actions-end]{align-self:center;margin-inline-end:.5rem}calcite-list-item:focus calcite-button{position:relative;top:-2px}.prompt-list calcite-list-item:last-of-type{margin-block-end:0}calcite-list{--calcite-color-foreground-1: transparent;background-color:transparent}calcite-list-item{--calcite-color-foreground-1: white}calcite-flow-item calcite-shell{background:transparent}calcite-block{width:100%;max-width:100%;align-self:flex-end;background-color:transparent;margin-block:0}calcite-sheet{--calcite-sheet-scrim-background: rgba(200, 200, 200, .5)}.type-suggestion{--calcite-color-foreground-1: var(--calcite-color-foreground-current);--calcite-color-text-3: var(--calcite-color-text-2);--calcite-icon-color: var(--calcite-color-brand)}.type-history{--calcite-icon-color: var(--calcite-color-text-2)}.type-response{--calcite-icon-color: var(--calcite-color-brand);--calcite-font-family: monospace}.block-response{align-self:flex-start;margin-block-end:4rem;border-block-end:0;--calcite-block-text-color: var(--calcite-color-brand)}calcite-list-item calcite-button{margin-inline-end:.25rem}.type-docs{--calcite-color-foreground-1: var(--calcite-color-foreground-3);--calcite-icon-color: var(--calcite-color-text-1)}.type-error{--calcite-icon-color: var(--calcite-color-status-danger);--calcite-font-family: monospace;border:1px solid var(--calcite-color-status-danger)}#thumbs-up{margin-inline-start:auto;--calcite-icon-color: var(--calcite-color-border-input)}#thumbs-down{--calcite-icon-color: var(--calcite-color-border-input)}calcite-flow-item calcite-shell calcite-notice{margin-block:1rem}.no-space-block,.no-space-block[open]{margin:0}calcite-block[open]:last-of-type{border-block-end:0}.text-area-wrapper{display:flex;border-radius:var(--calcite-corner-radius-round);margin:.75rem;overflow:hidden;--calcite-color-border-input: transparent;position:sticky;box-shadow:var(--calcite-shadow-sm);flex:none}calcite-text-area{height:auto;min-height:5.75rem;overflow:hidden;border-radius:var(--calcite-corner-radius-round) var(--calcite-corner-radius-round) 0 0;--calcite-font-weight-normal: 500;font-weight:500;line-height:1.2}calcite-tooltip{--calcite-tooltip-z-index: 1000}.standalone-list{margin:1rem;width:calc(100% - 2rem)}.result-disclaimer{display:block;width:24rem;max-width:90%;margin:1rem auto;text-align:center;line-height:1.125rem;font-size:.875rem;font-style:italic}calcite-flow{height:100%}calcite-popover calcite-list{--calcite-list-background-color: transparent;--calcite-input-border-color: transparent}calcite-popover calcite-list calcite-filter{--calcite-spacing-sm: 0}.break-spaces{white-space:break-spaces}.feedback-button-container{margin-inline-start:auto;gap:0}.info-heading{font-size:var(--calcite-font-size-1);color:var(--calcite-color-text-1)}.unstyled-h3{margin:unset;font-size:var(--calcite-font-size-md)}.unstyled-shell{position:unset;inset:unset;display:unset;block-size:unset;inline-size:unset}.suggestion-button{font-weight:var(--calcite-font-weight-medium)}.info-block{max-width:450px}#result-block{calcite-card-group{--calcite-card-group-gap: 1.25rem}calcite-card{--calcite-card-corner-radius: var(--calcite-corner-radius-round);--calcite-card-background-color: white;--calcite-card-border-color: transparent;width:100%}.positioned-code-content{display:flex;flex-direction:row;gap:.5rem;padding:.5rem}calcite-card [slot=title] calcite-chip{margin-block-start:.25rem}.code-response-wrapper{position:relative;background:var(--calcite-color-foreground-2);border-radius:var(--calcite-corner-radius-round);margin-top:-1.5rem}.prior-prompt{display:flex;flex-direction:row;padding:0;overflow-y:hidden;overflow-x:auto;margin:.25rem 0 .75rem;align-items:center;max-width:100%;span{overflow-x:auto;overflow-y:hidden}}.copy-feedback{display:none}.copy-prompt-button{align-self:flex-start;margin-inline-start:auto}.response-secondary-action-button[data-copied]+.copy-feedback,.copy-prompt-button[data-copied]+.copy-feedback{display:block;span{padding:.75rem 1rem;font-size:var(--calcite-font-size--2);line-height:1.375;color:var(--calcite-color-text--2);font-weight:var(--calcite-font-weight-medium)}}.copy-prompt-button[data-copied]~.copy-tooltip,.response-secondary-action-button[data-copied]~.copy-tooltip{display:none}code{white-space:pre;font-size:12px;margin:0;overflow-x:auto;font-family:Fira Mono,Consolas,Menlo,monospace;display:block;max-height:12rem;position:relative;padding:.5rem}.code-collapse{margin-inline-start:auto}.response-secondary-action-button{margin-left:.5rem}.add-to-editor-button{--calcite-internal-button-border-color: unset}}.collapsible-code{padding:.5rem}.collapsible-code summary{cursor:pointer;font-weight:500;color:var(--calcite-color-brand);outline:none;padding:.25rem 0}.collapsible-code[open] summary{color:var(--calcite-color-text-2)}.collapsible-error{padding:.5rem}.collapsible-error summary{cursor:pointer;font-weight:500;color:var(--calcite-color-status-danger);outline:none;padding:.25rem 0}.collapsible-error[open] summary{color:var(--calcite-color-text-2)}.response-error-container{padding:.5rem;background:color-mix(in srgb,var(--calcite-color-status-warning) 10%,transparent);border-radius:var(--calcite-corner-radius-round);margin:1rem 0;font-size:var(--calcite-font-size--2);--calcite-input-message-icon-color: var(--calcite-color-status-warning)}.response-error-chip{--calcite-internal-chip-background-color: var(--calcite-color-status-warning);--calcite-chip-icon-color: var(--calcite-color-foreground-1);--calcite-chip-border-color: var(--calcite-color-transparent)}.feedback-actions{gap:unset}}:host([closed]){display:none}`;
22
+ class $ extends Error {
23
+ constructor({
24
+ message: e,
25
+ code: t,
26
+ subCode: o,
27
+ details: r,
28
+ source: c
29
+ }) {
30
+ super(e), this.name = "ArcadeAssistantError", this.code = t, this.subCode = o, this.details = r, this.source = c;
31
+ }
32
+ }
33
+ function P(i) {
21
34
  if (!i)
22
35
  return;
23
36
  const e = i.indexOf('{"error":');
24
37
  if (e !== -1)
25
38
  try {
26
- const t = i.slice(e), s = JSON.parse(t);
27
- if (s && typeof s == "object" && s.error)
28
- return s.error;
39
+ const t = i.slice(e), o = JSON.parse(t);
40
+ if (o && typeof o == "object" && o.error)
41
+ return o.error;
29
42
  } catch {
30
43
  return;
31
44
  }
32
45
  }
33
- async function Q(i) {
34
- const { baseUrl: e, skillId: t, message: s, authToken: o, previousConversationId: c, context: r } = i, a = t ? `${e}/skills/${t}/chat` : `${e}/chat`, l = [], d = {
35
- message: s,
36
- context: r
46
+ async function ie(i) {
47
+ const { baseUrl: e, skillId: t, message: o, authToken: r, previousConversationId: c, context: h } = i, d = t ? `${e}/skills/${t}/chat` : `${e}/chat`, s = [], m = {
48
+ message: o,
49
+ context: h
37
50
  };
38
- c && (d.conversation_id = c);
39
- let f;
51
+ c && (m.conversation_id = c);
52
+ let a;
40
53
  try {
41
- f = await $(a, {
54
+ a = await T(d, {
42
55
  method: "post",
43
56
  headers: {
44
57
  "Content-Type": "application/json",
45
- token: o
58
+ token: r
46
59
  },
47
- body: JSON.stringify(d),
60
+ body: JSON.stringify(m),
48
61
  responseType: "json"
49
62
  });
50
- } catch (h) {
51
- const b = h?.details?.rawResponse || h?.message || String(h), k = S(b), g = new Error(
52
- `Failed to send message: ${s}. Response: ${b}`
53
- );
54
- throw k && (g.arcadeAssistantError = k), g;
63
+ } catch (b) {
64
+ const g = b, x = g.details?.rawResponse || g.message || String(b), v = P(x);
65
+ throw v ? new $(v) : b;
55
66
  }
56
- const m = f.data;
57
- if (!m.hasMore)
58
- throw new Error("Expected hasMore to be true");
59
- l.push(m);
60
- const E = m.conversationId, M = m.inquiryId;
61
- let y = m.sequenceNumber;
62
- async function q() {
63
- let h = 0;
64
- const b = 25;
65
- for (; h < b; ) {
66
- await new Promise((u) => setTimeout(u, 1e3));
67
- const k = B(E, y, M);
68
- let g;
67
+ const l = a.data;
68
+ s.push(l);
69
+ const p = l.conversationId, _ = l.inquiryId;
70
+ let S = l.sequenceNumber;
71
+ async function z() {
72
+ let b = 0;
73
+ const g = 25;
74
+ for (; b < g; ) {
75
+ await new Promise((y) => setTimeout(y, 1e3));
76
+ const x = oe(p, S, _);
77
+ let v;
69
78
  try {
70
- g = await $(a, {
79
+ v = await T(d, {
71
80
  method: "post",
72
81
  headers: {
73
82
  "Content-Type": "application/json",
74
- token: o
83
+ token: r
75
84
  },
76
- body: JSON.stringify(k),
85
+ body: JSON.stringify(x),
77
86
  responseType: "json"
78
87
  });
79
- } catch (u) {
80
- const v = u?.details?.rawResponse || u?.message || String(u), x = S(v), w = new Error(
81
- `Polling failed. Response: ${v}`
82
- );
83
- throw x && (w.arcadeAssistantError = x), w;
88
+ } catch (y) {
89
+ const R = y, H = R.details?.rawResponse || R.message || String(y), I = P(H);
90
+ throw I ? new $(I) : y;
84
91
  }
85
- const p = g.data;
86
- if (p.context && p.context.kind === "ArcgisErrorAsContext" && p.context.error)
87
- throw new Error(
88
- p.context.error.message || "ArcGIS Assistant error"
89
- );
90
- if (l.push(p), y = p.sequenceNumber, h++, !p.hasMore)
92
+ const f = v.data;
93
+ if (f.context && f.context.kind === "ArcgisErrorAsContext" && f.context.error)
94
+ throw new $({
95
+ message: f.context.error.message || "ArcGIS Assistant error",
96
+ code: f.context.error.code,
97
+ subCode: f.context.error.subCode,
98
+ details: f.context.error.details,
99
+ source: "polling-response"
100
+ });
101
+ if (s.push(f), S = f.sequenceNumber, b++, !f.hasMore)
91
102
  break;
92
103
  }
93
- if (h === b)
94
- throw new Error("Request timed out");
104
+ if (b === g)
105
+ throw new $({
106
+ message: "Request timed out",
107
+ code: "TIMEOUT",
108
+ source: "polling"
109
+ });
95
110
  }
96
- return await q(), l;
111
+ const O = 2 * 60 * 1e3;
112
+ return await Promise.race([
113
+ z(),
114
+ new Promise(
115
+ (b, g) => setTimeout(
116
+ () => g(
117
+ new $({
118
+ message: "Request timed out",
119
+ code: "TIMEOUT",
120
+ source: "hard-timeout"
121
+ })
122
+ ),
123
+ O
124
+ )
125
+ )
126
+ ]), s;
97
127
  }
98
- function B(i, e, t) {
128
+ function oe(i, e, t) {
99
129
  return {
100
130
  conversationId: i,
101
131
  inquiryId: t,
102
132
  ackSequenceNumber: e
103
133
  };
104
134
  }
105
- const L = (i) => {
106
- const e = i.value.length, t = 72, s = 180, o = i.offsetWidth, r = Math.max(1, Math.floor(o / 8)), a = Math.ceil(e / r), l = t + (a - 2) * 24;
107
- i.style.setProperty("--calcite-text-area-min-height", `${Math.min(l, s)}px`);
135
+ function ae(i) {
136
+ return i.message.match(/Error in prompt shield/u) ? "I'm having trouble with this request. Try again by rephrasing the question." : i.code === "TIMEOUT" ? "I'm having trouble with this request. Try again by re-asking the same question or rephrasing it." : i.message;
137
+ }
138
+ const se = (i) => {
139
+ const e = i.value.length, t = 72, o = 180, r = i.offsetWidth, h = Math.max(1, Math.floor(r / 8)), d = Math.ceil(e / h), s = t + (d - 2) * 24;
140
+ i.style.setProperty("--calcite-text-area-min-height", `${Math.min(s, o)}px`);
108
141
  };
109
- function W({ messages: i }) {
142
+ function re({ messages: i }) {
110
143
  return n`<calcite-chip slot=header-actions-end scale=s appearance=outline-fill .label=${i.beta ?? "Beta"}>${i.beta ?? "Beta"}</calcite-chip>`;
111
144
  }
112
- function G({ messages: i }) {
113
- return n`<calcite-action icon=information slot=header-actions-end id=legal-disclaimer text></calcite-action><calcite-tooltip reference-element=legal-disclaimer>${i.legaldisclaimer}</calcite-tooltip>`;
145
+ function ce({ popoverContent: i }) {
146
+ return n`<calcite-action icon=information slot=header-actions-end id=legal-disclaimer text></calcite-action><calcite-popover reference-element=legal-disclaimer overlay-positioning=fixed label=legal-disclaimer placement=bottom auto-close>${i}</calcite-popover>`;
147
+ }
148
+ function D({ errorMessage: i, slot: e }) {
149
+ return n`<div class="error-display"><calcite-input-message id=error-message status=invalid icon=exclamation-mark-triangle scale=m slot=${e ?? C}>${i}</calcite-input-message></div>`;
150
+ }
151
+ function ne({ active: i, setActive: e, messages: t }) {
152
+ return n`<calcite-alert slot=alerts .open=${i} placement=bottom kind=success icon=check-circle-f auto-close @calciteAlertClose=${() => e(!1)} .label=${t.expressionapplied ?? "Expression applied"}><div slot=message>${t.expressionapplied ?? "Expression applied to editor."}</div></calcite-alert>`;
153
+ }
154
+ function le({ context: i, messages: e }) {
155
+ return i ? n`<div class="gaps">${i.profileName && n`<calcite-popover auto-close placement=top .label=${e.profilecontextlabel.replace("{profileName}", i.profileName)} reference-element=profile-context-button class="context-popover"><p>${e.profilecontextlabel.replace("{profileName}", i.profileName)}</p></calcite-popover><calcite-button round kind=neutral icon-start=map-information id=profile-context-button></calcite-button>` || ""}${i.layerName && n`<calcite-popover auto-close placement=top .label=${e.layercontextlabel.replace("{layerName}", i.layerName)} reference-element=layer-context-button class="context-popover"><p>${e.layercontextlabel.replace("{layerName}", i.layerName)}</p></calcite-popover><calcite-button round kind=neutral icon-start=layers id=layer-context-button></calcite-button>` || ""}</div>` : null;
156
+ }
157
+ function de({ isDisabled: i, isReadOnly: e, setQuestion: t, setIsViewingResult: o, textAreaRef: r, question: c, errorMessage: h, setErrorMessage: d, submitQuestion: s, messages: m, mode: a, context: l }) {
158
+ return n`<div class="text-area-wrapper"><calcite-text-area resize=vertical .readOnly=${i || e} class="styled-text-area" .placeholder=${m.askaquestion ?? `Specify the calculation or logic you need in an Arcade expression. (e.g., 'Return "Yes" if value > 10')`} .value=${c} @calciteTextAreaInput=${(p) => {
159
+ se(p.target), t(p.target.value);
160
+ }} ${B(r)}><div class="submission-actions-wrapper" slot=footer-start>${h && D({ errorMessage: h, slot: "footer-start" }) || ""}<div class="submission-actions">${le({ context: l, messages: m })}<div class="align-inline-end gaps"><calcite-button round kind=neutral .hidden=${a !== "refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid .disabled=${i} @click=${async () => {
161
+ o(!1), t("");
162
+ }}>${m.startover ?? "Start Over"}</calcite-button><calcite-button round icon-end=effects appearance=solid .loading=${i} .disabled=${i} @click=${async () => {
163
+ d(c ? "" : m.enteraprompt ?? "Please enter a prompt"), await s();
164
+ }}>${a === "prompt" ? m.ask ?? "Generate" : m.refine ?? "Refine"}</calcite-button></div></div></div></calcite-text-area></div>`;
165
+ }
166
+ const pe = "https://www.esri.com/en-us/privacy/privacy-statements/privacy-statement", ue = "https://www.esri.com/en-us/privacy/privacy-statements/privacy-supplement";
167
+ function he({ setOpen: i, messages: e, feedback: t, setFeedback: o, onSubmit: r }) {
168
+ return n`<calcite-sheet class="feedback-sheet" .label=${e.feedback ?? "Feedback"} slot=sheets display-mode=float position=block-end .open=${t.active} @calciteSheetClose=${() => i(!1)}><calcite-panel .heading=${e.providefeedback ?? "Provide feedback"} .description=${e.experiencehelps ?? "Your experience helps guide future improvements"}><div class="feedback-content"><calcite-label>${e.experiencehelpful ?? "Was the assistant helpful?"}<calcite-segmented-control scale=l><calcite-segmented-control-item icon-start=thumbs-up .checked=${t.value === "good"} @click=${() => o({ ...t, value: "good" })}></calcite-segmented-control-item><calcite-segmented-control-item icon-start=thumbs-down .checked=${t.value === "bad"} @click=${() => o({ ...t, value: "bad" })}></calcite-segmented-control-item></calcite-segmented-control></calcite-label><calcite-label>${e.describeexperience ?? "Describe your experience"}<calcite-text-area resize=vertical .value=${t.text} @calciteTextAreaInput=${(c) => o({ ...t, text: c.target.value })}></calcite-text-area></calcite-label><calcite-label layout=inline scale=s><calcite-checkbox scale=l .checked=${t.termsAccepted} @calciteCheckboxChange=${(c) => {
169
+ o({ ...t, termsAccepted: c.target.checked });
170
+ }}></calcite-checkbox><span>${k(e.agreement?.replace("{EsriPrivacyStatement}", `<calcite-link href=${pe} target="_blank">${e.esriprivacystatement ?? "Esri Privacy Statement"}</calcite-link>`).replace("{Supplement}", `<calcite-link href=${ue} target="_blank">${e.supplement ?? "Supplement"}</calcite-link>`))}</span></calcite-label></div><calcite-button slot=footer width=full @click=${r} .disabled=${!t.termsAccepted || t.submitting} .loading=${t.submitting}>${e.submitfeedback ?? "Submit Feedback"}</calcite-button></calcite-panel></calcite-sheet>`;
114
171
  }
115
- function J({ errorMessage: i }) {
116
- return n`<calcite-input-message id=error-message status=invalid slot=footer-start icon=exclamation-mark-triangle scale=m>${i}</calcite-input-message>`;
172
+ function q({ assistantsEnabled: i, messages: e, slot: t, assistantHelpUrl: o, helpTopicUrl: r }) {
173
+ return n`<calcite-block .label=${e.assistantinformation ?? "Assistant information"} slot=${t ?? C} expanded class="info-block"><calcite-chip .label=${e.new ?? "new"} kind=brand>${e.new}</calcite-chip><h1 class="info-heading">${e.introducing}</h1><p>${e.capabilities}</p>${i ? n`<p>${e.keepinmind ?? "Keep in mind the following:"}<ul><li>${e.beconsise ?? "Be concise, but also clear in your request"}</li><li>${e.avoidambiguity ?? "Avoid ambiguity and vagueness"}</li><li>${e.moredetails ?? "you do not need to use exact field names in your instructions, but more detail is generally better"}</li></ul>${k((e.seedocumentation ?? "Please see the {documentation} for more information, including limitations and additional resources.").replace("{documentation}", `<calcite-link href=${r} target="_blank">${e.documentation ?? "documentation"}</calcite-link>`))}</p>` : n`<p>${k(e.useofassistant?.replace("{aiassistants}", `<strong>${e.aiassistants ?? "Ai Assistants"}</strong>`))}<calcite-link .href=${o} target=_blank icon-end=launch-2>${e.opensettings ?? "Open Settings"}</calcite-link></p>`}</calcite-block>`;
117
174
  }
118
- function Y({ active: i, setActive: e, messages: t }) {
119
- return n`<calcite-alert slot=alerts .open=${i} placement=bottom kind=success icon=check-circle-f auto-close @calciteAlertClose=${() => e(!1)} label=confirmation-alert><div slot=message>${t.expressionapplied ?? "Expression applied to editor."}</div></calcite-alert>`;
175
+ function me({ messages: i, onProceed: e, onExit: t, helpTopicUrl: o }) {
176
+ return n`<calcite-dialog close-disabled placement=top .heading=${i.welcome} slot=dialogs open width-scale=m id=welcome-dialog><h3 class="unstyled-h3">${i.beforeyougetstarted}</h3><ul><li>${i.maybeincorrect}</li><li>${k(i.pleasereadhelp.replace("{helpTopic}", `<calcite-link href=${o} target="_blank">${i.helptopic}</calcite-link>`))}</li></ul><calcite-button id=welcome-proceed slot=footer-end @click=${e}>${i.proceed}</calcite-button><calcite-button id=welcome-decline slot=footer-start @click=${t} kind=neutral>${i.exit}</calcite-button></calcite-dialog>`;
120
177
  }
121
- function K({ isDisabled: i, isReadOnly: e, setQuestion: t, setIsViewingResult: s, textAreaRef: o, question: c, errorMessage: r, setErrorMessage: a, submitQuestion: l, messages: d }) {
122
- return n`<div class="text-area-wrapper"><calcite-text-area resize=none .readOnly=${i || e} class="styled-text-area" .placeholder=${d.askaquestion ?? `Specify the calculation or logic you need in an Arcade expression. (e.g., 'Return "Yes" if value > 10')`} .value=${c} @calciteTextAreaInput=${(f) => {
123
- L(f.target), t(f.target.value);
124
- }} ${I(o)}>${r && J({ errorMessage: r }) || ""}</calcite-text-area><div class="response-actions">${e ? n`<calcite-button round appearance=outline-fill icon-start=speech-bubble-plus @click=${() => {
125
- t(""), s(!1);
126
- }}>${d.askagain || "Ask again"}</calcite-button>` : n`<calcite-button alignment=end round icon-end=effects appearance=solid .loading=${i} .disabled=${i} @click=${async () => {
127
- a(c ? "" : d.enteraprompt ?? "Please enter a prompt"), await l();
128
- }}>${d.ask || "Ask"}</calcite-button>`}</div></div>`;
178
+ function fe({ messages: i, suggestions: e, onSuggestionClick: t }) {
179
+ return n`<calcite-block .heading=${i.promptsuggestions} expanded collapsible id=suggestion-block><calcite-chip-group class="suggestions" .label=${i.promptsuggestions ?? "Prompt Suggestions"}>${F(e, (o) => o, (o) => n`<calcite-button round appearance=outline-fill kind=neutral .label=${i.promptsuggestion} class="suggestion-button" @click=${() => t?.(o)}>${o}</calcite-button>`)}</calcite-chip-group></calcite-block>`;
129
180
  }
130
- function X({ open: i, setOpen: e, messages: t, feedbackValue: s, setFeedbackValue: o, feedbackText: c, setFeedbackText: r, onSubmit: a }) {
131
- return n`<calcite-sheet class="feedback-sheet" .label=${t.feedback ?? "Feedback"} slot=sheets display-mode=float position=block-end .open=${i} @calciteSheetClose=${() => e(!1)}><calcite-panel .heading=${t.providefeedback ?? "Provide feedback"} .description=${t.experiencehelps ?? "Your experience helps guide future improvements"}><div class="feedback-content"><calcite-label>${t.experiencehelpful ?? "Was the assistant helpful?"}<calcite-segmented-control scale=l><calcite-segmented-control-item icon-start=thumbs-up .checked=${s === "good"} @click=${() => o("good")}></calcite-segmented-control-item><calcite-segmented-control-item icon-start=thumbs-down .checked=${s === "bad"} @click=${() => o("bad")}></calcite-segmented-control-item></calcite-segmented-control></calcite-label><calcite-label>${t.describeexperience ?? "Describe your experience"}<calcite-text-area resize=vertical .value=${c} @calciteTextAreaInput=${(l) => r(l.target.value)}></calcite-text-area></calcite-label></div><calcite-button slot=footer width=full @click=${a}>${t.submitfeedback ?? "Submit Feedback"}</calcite-button></calcite-panel></calcite-sheet>`;
181
+ function M({ hidden: i = !1, expanded: e = !1, messages: t, cards: o, heading: r, collapsible: c = !1, showEffectsIcon: h = !1, onCopyCode: d, standalone: s }) {
182
+ const m = t.addtoeditor ?? "Add to editor";
183
+ return n`<calcite-block .hidden=${i} id=result-block .heading=${r ?? t.besteffort ?? "Here is the assistant's best effort"} .expanded=${e} .collapsible=${c}>${h && n`<calcite-chip .label=${t.assistantresponses} slot=content-start icon=effects scale=m class="suggestion-chips"></calcite-chip>` || ""}<calcite-card-group .label=${t.assistantresponses}>${F(o, (a) => a.conversationId, (a) => n`<calcite-card><div slot=heading><div class="prior-prompt"><span>${a.priorPrompt}</span><calcite-action icon=duplicate scale=s slot=actions-end class="copy-prompt-button" text .id=${`copy-prompt-${a.conversationId}-${s ? "standalone" : "list"}`} @click=${(l) => {
184
+ const p = l.currentTarget;
185
+ navigator.clipboard.writeText(a.priorPrompt).then(() => {
186
+ p.setAttribute("data-copied", "true"), setTimeout(() => p.removeAttribute("data-copied"), 1500);
187
+ });
188
+ }}></calcite-action><calcite-popover .referenceElement=${`copy-prompt-${a.conversationId}-${s ? "standalone" : "list"}`} placement=top-start class="copy-feedback" .label=${t.copiedsuccessfully ?? "copied successfully"} open trigger-disabled><span>${t.copiedsuccessfully ?? "copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-prompt-${a.conversationId}-${s ? "standalone" : "list"}`} placement=top-start class="copy-tooltip">${t.copyprompttoclipboard}</calcite-tooltip></div>${a.message && s && n`<div class="response-error-container">${D({ errorMessage: a.message })}</div>` || ""}</div><div><div class="code-response-wrapper"><div class="positioned-code-content"><calcite-chip-group .label=${t.responsecontext ?? "Response Context"} scale=s>${a.message && !s && n`<calcite-tooltip .referenceElement=${`response-chip-${a.conversationId}-error`} placement=top-start overlay-positioning=fixed>${a.message}</calcite-tooltip><calcite-chip .id=${`response-chip-${a.conversationId}-error`} .label=${t.error ?? "Error"} scale=s appearance=outline icon=exclamation-mark-triangle-f class="response-error-chip"></calcite-chip>` || ""}${a.chips?.map((l) => {
189
+ const p = K();
190
+ return n`${l.tooltip && n`<calcite-tooltip .referenceElement=${`response-chip-${l.conversationId}-${p}`} placement=top-start overlay-positioning=fixed>${l.tooltip}</calcite-tooltip>` || ""}<calcite-chip .label=${l.label} .scale=${l.scale ?? "s"} .appearance=${l.appearance ?? "outline"} .icon=${l.icon} .id=${`response-chip-${l.conversationId}-${p}`}>${l.label}</calcite-chip>`;
191
+ })}</calcite-chip-group></div><details class="collapsible-code" open><summary>Code response</summary><code>${a.code}</code></details></div></div><div slot=footer-start class="feedback-actions"><calcite-button primary-text=${m ?? C} class="add-to-editor-button" @click=${() => a.onAddToEditor("add")} overlay-positioning=fixed scale=s icon-start=plus round>${t.addtoeditor ?? "Add to editor"}</calcite-button><calcite-button round icon-start=file-code kind=neutral scale=s @click=${() => a.onAddToEditor("replace")} class="response-secondary-action-button" .id=${`replace-${a.conversationId}-${s ? "standalone" : "list"}`}></calcite-button><calcite-tooltip .referenceElement=${`replace-${a.conversationId}-${s ? "standalone" : "list"}`} placement=top-start><span>${t.replaceineditor ?? "Replace all code in editor"}</span></calcite-tooltip><calcite-button round icon-start=copy-to-clipboard kind=neutral scale=s @click=${(l) => {
192
+ const p = l.currentTarget;
193
+ d(a.code).then(() => {
194
+ p.setAttribute("data-copied", "true"), setTimeout(() => p.removeAttribute("data-copied"), 1500);
195
+ });
196
+ }} class="response-secondary-action-button" .id=${`copy-response-${a.conversationId}-${s ? "standalone" : "list"}`}></calcite-button><calcite-popover .referenceElement=${`copy-response-${a.conversationId}-${s ? "standalone" : "list"}`} placement=top-start class="copy-feedback" .label=${t.copiedsuccessfully ?? "copied successfully"} open trigger-disabled><span>${t.copiedsuccessfully ?? "copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-response-${a.conversationId}-${s ? "standalone" : "list"}`} placement=top-start class="copy-tooltip">${t.copytoclipboard}</calcite-tooltip></div><div slot=footer-end class="feedback-actions"><calcite-action .text=${t.thumbsup} scale=s icon=thumbs-up @click=${a.onThumbsUp} .id=${`thumbs-up-${a.conversationId}-${s ? "standalone" : "list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-up-${a.conversationId}-${s ? "standalone" : "list"}`} placement=top-start><span>${t.helpful ?? "Helpful"}</span></calcite-tooltip><calcite-action .text=${t.thumbsdown} scale=s icon=thumbs-down @click=${a.onThumbsDown} .id=${`thumbs-down-${a.conversationId}-${s ? "standalone" : "list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-down-${a.conversationId}-${s ? "standalone" : "list"}`} placement=top-start><span>${t.unhelpful ?? "Unhelpful"}</span></calcite-tooltip></div></calcite-card>`)}</calcite-card-group></calcite-block>`;
132
197
  }
133
- const Z = "arcade_generation", ee = "ArcadeCodeRequest", te = "visualization", ie = "ArcadeAssistant", se = [
198
+ const u = {
199
+ welcome: "Welcome to the new assistant experience",
200
+ beforeyougetstarted: "Before you get started be aware:",
201
+ maybeincorrect: "AI generated code may occasionally be incorrect or biased. Review carefully.",
202
+ pleasereadhelp: "Read the Arcade Assistant (beta) {helpTopic} to get started and learn details on security, privacy and limitations.",
203
+ proceed: "Proceed",
204
+ exit: "Exit",
205
+ promptsuggestions: "Prompt suggestions",
206
+ promptsuggestion: "Prompt suggestion",
207
+ assistantresponses: "Assistant responses",
208
+ collapse: "Collapse",
209
+ thumbsup: "Thumbs up",
210
+ thumbsdown: "Thumbs down",
211
+ refine: "Refine",
212
+ startover: "Start over",
213
+ helptopic: "help topic",
214
+ agreement: "I agree to the {EsriPrivacyStatement} (and {Supplement}).",
215
+ esriprivacystatement: "Esri Privacy Statement",
216
+ supplement: "Supplement",
217
+ disclaimerpt2: "AI-generated content may be inaccurate. Review before using.",
218
+ replaceineditor: "Replace all code in editor",
219
+ keepinmind: "Keep in mind the following:",
220
+ beconsise: "Be concise, but also clear in your request",
221
+ avoidambiguity: "Avoid ambiguity and vagueness",
222
+ documentation: "documentation",
223
+ useexamples: "Use examples to clarify your request",
224
+ moredetails: "You do not need to use exact field names in your instructions, but more detail is generally better",
225
+ seedocumentation: "Please see the {documentation} for more information, including limitations and additional resources.",
226
+ assistantinformation: "Assistant information",
227
+ profilecontextlabel: "Profile context: {profileName}",
228
+ layercontextlabel: "Layer context: {layerName}",
229
+ numlayers: "{numLayers} {layerOrLayers}",
230
+ numlayersplural: "layers",
231
+ numlayerssingular: "layer",
232
+ responsecontext: "Response context",
233
+ error: "Error",
234
+ copytoclipboard: "Copy code to clipboard",
235
+ copyprompttoclipboard: "Copy prompt to clipboard",
236
+ copiedsuccessfully: "Copied successfully",
237
+ helpful: "Helpful",
238
+ unhelpful: "Unhelpful"
239
+ }, be = "arcade_generation", ge = "ArcadeCodeRequest", A = "visualization", ve = "ArcadeAssistant", ye = [
134
240
  "your_comments",
135
241
  "user_evaluation",
136
242
  "question",
@@ -141,146 +247,259 @@ const Z = "arcade_generation", ee = "ArcadeCodeRequest", te = "visualization", i
141
247
  "context",
142
248
  "extras"
143
249
  ];
144
- let C = [];
145
- class ae extends T {
250
+ let U = [], N = !0;
251
+ class $e extends L {
146
252
  constructor() {
147
- super(...arguments), this.textAreaRef = D(), this.messages = j(), this.feedbackService = void 0, this.handleFeedbackButton = (e) => {
148
- this.feedbackValue === e && this.feedbackActive ? (this.feedbackActive = !1, this.feedbackValue = void 0, this.feedbackText = "") : (this.feedbackValue = e, this.feedbackActive = !0);
253
+ super(...arguments), this.textAreaRef = j(), this.messages = Q(), this._feedbackService = void 0, this.handleFeedbackButton = (e, t) => {
254
+ this.feedback = { ...this.feedback, active: !0, value: e, item: t };
149
255
  }, this.handleFeedbackSheetClose = () => {
150
- this.feedbackActive = !1, this.feedbackValue = void 0, this.feedbackText = "";
256
+ this.feedback = {
257
+ active: !1,
258
+ value: void 0,
259
+ text: "",
260
+ item: void 0,
261
+ submitting: !1,
262
+ termsAccepted: !1
263
+ };
151
264
  }, this.handleFeedbackSubmit = async () => {
152
- if (this.feedbackValue) {
153
- if (this.feedbackServiceUrl) {
154
- if (!this.feedbackService) {
155
- const c = new _({
156
- url: this.feedbackServiceUrl
157
- });
158
- await c.load();
159
- const r = c.fields, a = [];
160
- if (se.forEach((l) => {
161
- r.some((d) => d.name === l) || a.push(l);
162
- }), a.length > 0) {
163
- console.error(`Missing the following fields in feedback service: ${a.join(", ")}.
164
- Feedback will not be logged.`), this.handleFeedbackSheetClose();
165
- return;
166
- }
167
- this.feedbackService = c;
168
- }
169
- const e = this.getModel(), t = e ? await this.getProfileAndMetadata(e.uri) : void 0, s = {
170
- user_evaluation: this.feedbackValue,
171
- your_comments: this.feedbackText,
172
- question: this.question,
173
- answer: this.history[0]?.script ?? "",
174
- useragent: navigator.userAgent,
175
- _source: ie,
176
- version: this.appVersion ?? "",
177
- // TODO: this comes from app
178
- context: t ? JSON.stringify(t) : "",
179
- extras: t?.profileName ?? ""
180
- }, o = new z({
181
- attributes: s
182
- });
183
- try {
184
- await this.feedbackService?.applyEdits({
185
- addFeatures: [o]
186
- });
187
- } catch (c) {
188
- console.error("Error submitting feedback:", c);
189
- }
190
- }
265
+ this.feedback = { ...this.feedback, submitting: !0 };
266
+ const e = await this.ensureFeedbackService();
267
+ if (!e) {
191
268
  this.handleFeedbackSheetClose();
269
+ return;
270
+ }
271
+ const t = this.getModel(), o = t ? await this.getProfileAndMetadata(t.uri) : void 0, r = {
272
+ user_evaluation: this.feedback.value,
273
+ your_comments: this.feedback.text || void 0,
274
+ question: this.question,
275
+ answer: this.feedback.item?.formattedScript ?? this.feedback.item?.script ?? "",
276
+ useragent: navigator.userAgent,
277
+ _source: ve,
278
+ version: this.appVersion ?? "",
279
+ context: o ? JSON.stringify(o) : "",
280
+ extras: o?.profileName ?? "",
281
+ conversation_id: this.feedback.item?.conversationId ?? "",
282
+ privacy_statement: this.feedback.termsAccepted ? "I_agree" : ""
283
+ };
284
+ try {
285
+ await e.applyEdits({ addFeatures: [new Z({ attributes: r })] });
286
+ } catch (c) {
287
+ console.error("Error submitting feedback:", c);
192
288
  }
289
+ this.handleFeedbackSheetClose();
193
290
  }, this.handleClose = (e) => {
194
291
  this.closed = !0, this.closePanel?.(e);
195
292
  }, this.setQuestion = (e) => {
196
293
  this.question = e;
197
- }, this.isViewingResult = !1, this.confirmationActive = !1, this.isDisabled = !1, this.errorMessage = void 0, this.question = "", this.history = [], this.feedbackActive = !1, this.feedbackValue = void 0, this.feedbackText = "", this.copySuccess = !1, this.assistantsEnabled = !1, this.closed = !1;
294
+ }, this.onSuggestionClick = (e) => {
295
+ this.textAreaRef.value && (this.textAreaRef.value.value = e, this.textAreaRef.value.setFocus(), this.setQuestion(e));
296
+ }, this.isViewingResult = !1, this.confirmationActive = !1, this.isSubmitting = !1, this.errorMessage = void 0, this.question = "", this.history = [], this.feedback = {
297
+ active: !1,
298
+ value: void 0,
299
+ text: "",
300
+ item: void 0,
301
+ termsAccepted: !1,
302
+ submitting: !1
303
+ }, this.splashActive = !0, this.context = void 0, this.historyCards = [], this.helpBase = "", this.assistantsEnabled = !1, this.closed = !1;
198
304
  }
199
305
  static {
200
- this.properties = { isViewingResult: 16, confirmationActive: 16, isDisabled: 16, errorMessage: 16, question: 16, history: 16, feedbackActive: 16, feedbackValue: 16, feedbackText: 16, copySuccess: 16, closePanel: 0, insertText: 0, assistantsEnabled: 5, layer: [1, { type: Object }], orgBaseUrl: 1, serviceUrl: 1, closed: 7, editorRef: 0, feedbackServiceUrl: 1, appVersion: 1 };
306
+ this.properties = { isViewingResult: 16, confirmationActive: 16, isSubmitting: 16, errorMessage: 16, question: 16, history: 16, feedback: 16, splashActive: 16, context: 16, historyCards: 16, closePanel: 0, insertText: 0, helpBase: 1, assistantsEnabled: 5, layer: [1, { type: Object }], portalUrl: 1, serviceUrl: 1, closed: 7, editorRef: 0, feedbackServiceUrl: 1, appVersion: 1 };
201
307
  }
202
308
  static {
203
- this.styles = O;
309
+ this.styles = te;
310
+ }
311
+ get disclaimerComment() {
312
+ return `// ${this.messages.disclaimercomment}
313
+ // ${u.disclaimerpt2}`;
314
+ }
315
+ get assistantHelpUrl() {
316
+ return `${this.helpBase ?? "https://doc.arcgis.com/en/arcgis-online/"}administer/configure-assistants.htm`;
317
+ }
318
+ get assistantOverviewDocUrl() {
319
+ return `${this.helpBase ?? "https://doc.arcgis.com/en/arcgis-online/"}create-maps/understand-arcade-assistant.htm`;
320
+ }
321
+ get usingTheAssitantDocUrl() {
322
+ return `${this.helpBase ?? "https://doc.arcgis.com/en/arcgis-online/"}create-maps/use-arcade-assistant.htm`;
204
323
  }
205
324
  async destroy() {
206
325
  }
326
+ load() {
327
+ const e = async () => {
328
+ const t = this.getModel();
329
+ if (!t) {
330
+ this.context = void 0;
331
+ return;
332
+ }
333
+ const o = await this.getProfileAndMetadata(t.uri);
334
+ this.context = o;
335
+ };
336
+ e().catch((t) => {
337
+ console.error("Error setting initial context in Arcade Assistant:", t);
338
+ }), this.manager.onLifecycle(() => ({ remove: E.onModelContextDidChange(async () => {
339
+ e().catch((o) => {
340
+ console.error("Error setting context in Arcade Assistant:", o);
341
+ });
342
+ }).dispose }));
343
+ }
344
+ willUpdate(e) {
345
+ e.has("history") && (this.historyCards = this.getHistoryCards());
346
+ }
207
347
  connectedCallback() {
208
- super.connectedCallback(), this.history = C;
348
+ super.connectedCallback(), this.history = U, this.splashActive = N;
209
349
  }
210
350
  disconnectedCallback() {
211
- super.disconnectedCallback(), C = this.history;
351
+ super.disconnectedCallback(), U = this.history, N = this.splashActive, this.copySuccessTimer && (clearTimeout(this.copySuccessTimer), this.copySuccessTimer = void 0);
352
+ }
353
+ getHistoryCards() {
354
+ return this.history.reduce((e, t) => (!t.script || (e.push({
355
+ priorPrompt: t.question,
356
+ code: t.formattedScript || t.error || "",
357
+ chips: [
358
+ {
359
+ label: t.profile ?? A,
360
+ icon: "map-information",
361
+ appearance: "outline",
362
+ scale: "s",
363
+ conversationId: t.conversationId ?? "",
364
+ tooltip: u.profilecontextlabel.replace("{profileName}", t.profile ?? A)
365
+ },
366
+ ...t.layerName ? [
367
+ {
368
+ label: u.numlayers.replace("{numLayers}", "1").replace("{layerOrLayers}", u.numlayerssingular),
369
+ icon: "layer",
370
+ appearance: "outline",
371
+ scale: "s",
372
+ conversationId: t.conversationId ?? "",
373
+ tooltip: u.layercontextlabel.replace("{layerName}", t.layerName ?? "No layer")
374
+ }
375
+ ] : []
376
+ ],
377
+ onAddToEditor: (o) => {
378
+ J(this.editorRef.editorInstance, t.formattedScript ?? "", o, this.disclaimerComment);
379
+ },
380
+ onThumbsUp: () => this.handleFeedbackButton("good", t),
381
+ onThumbsDown: () => this.handleFeedbackButton("bad", t),
382
+ conversationId: t.conversationId ?? "",
383
+ message: t.message
384
+ }), this.isViewingResult), e), []);
385
+ }
386
+ setFeedbackState(e) {
387
+ this.feedback = e;
388
+ }
389
+ async ensureFeedbackService() {
390
+ if (this._feedbackService)
391
+ return this._feedbackService;
392
+ if (!this.feedbackServiceUrl)
393
+ return;
394
+ const e = new X({ url: this.feedbackServiceUrl });
395
+ await e.load();
396
+ const t = ye.filter((o) => !e.fields.some((r) => r.name === o));
397
+ if (t.length > 0) {
398
+ console.error(`Missing the following fields in feedback service: ${t.join(", ")}. Feedback will not be logged.`);
399
+ return;
400
+ }
401
+ return this._feedbackService = e, e;
212
402
  }
213
403
  getModel() {
214
404
  return this.editorRef.editorInstance?.getModel();
215
405
  }
216
406
  async submitQuestion() {
217
407
  if (this.question) {
218
- this.isDisabled = !0;
408
+ this.isSubmitting = !0;
219
409
  try {
220
410
  const e = await this.getToken(), t = this.getModel();
221
411
  if (!t)
222
412
  return;
223
- const { profileName: s, metadata: o } = await this.getProfileAndMetadata(t.uri), r = (await Q({
413
+ const { profileName: o, metadata: r, layerName: c } = await this.getProfileAndMetadata(t.uri), d = (await ie({
224
414
  baseUrl: this.serviceUrl,
225
- skillId: Z,
415
+ skillId: be,
226
416
  message: this.question,
227
417
  authToken: e,
228
418
  context: {
229
- kind: ee,
419
+ kind: ge,
230
420
  context: {
231
- profile_name: s,
232
- metadata: o
421
+ profile_name: o,
422
+ metadata: r
233
423
  }
234
424
  }
235
- })).find((a) => a.context?.kind === "ArcadeCodeResponse");
236
- if (!r)
425
+ })).find((s) => s.context?.kind === "ArcadeCodeResponse");
426
+ if (!d)
237
427
  return;
238
- r.context?.kind === "ArcadeCodeResponse" && (this.history.unshift({
239
- script: r?.context?.arcadeCode?.code,
240
- error: void 0,
241
- question: this.question
242
- }), this.isViewingResult = !0, this.errorMessage = void 0);
428
+ d.context?.kind === "ArcadeCodeResponse" && (this.history = [
429
+ {
430
+ script: d?.context?.arcadeCode?.code,
431
+ formattedScript: Y(d?.context?.arcadeCode?.code ?? ""),
432
+ error: void 0,
433
+ question: this.question,
434
+ profile: o,
435
+ conversationId: d.conversationId,
436
+ layerName: c ?? void 0,
437
+ ...d.message ? { message: d.message } : {}
438
+ },
439
+ ...this.history
440
+ ], this.isViewingResult = !0, this.errorMessage = void 0);
243
441
  } catch (e) {
244
- typeof e == "object" && e && "arcadeAssistantError" in e ? this.errorMessage = e.arcadeAssistantError.message || this.messages.erroroccurred || "An error occurred." : e instanceof Error ? this.errorMessage = this.messages.erroroccurred ?? "An error occurred." : this.errorMessage = this.messages.erroroccurred || "An error occurred.", console.error("Error in Arcade Assistant:", e);
442
+ e instanceof Error && e.name === "ArcadeAssistantError" ? this.errorMessage = ae(e) || this.messages.erroroccurred || "An error occurred." : this.errorMessage = this.messages.erroroccurred || "An error occurred.", console.error("Error in Arcade Assistant:", e);
245
443
  } finally {
246
- this.isDisabled = !1;
444
+ this.isSubmitting = !1;
247
445
  }
248
446
  }
249
447
  }
250
448
  async getToken() {
251
- const { token: e } = await P.getCredential(this.orgBaseUrl);
449
+ const { token: e } = await W.getCredential(this.portalUrl);
252
450
  return e;
253
451
  }
254
452
  async getProfileAndMetadata(e) {
255
- let t = te;
256
- const s = N.getEditorProfileForModel(e);
257
- s?.loaded || await s?.loadSource();
258
- const o = this.editorRef.profile;
259
- o && "id" in o && (t = o.id);
260
- const c = s?.definition?.variables?.find((a) => a.type === "feature");
261
- let r = [];
262
- return c?.definition && "fields" in c.definition && (r = c.definition.fields.map((a) => ({
263
- name: a.name,
264
- type: a.type,
265
- alias: a.alias
266
- }))), { profileName: t, metadata: r };
453
+ let t = A;
454
+ const o = E.getEditorProfileForModel(e);
455
+ o?.loaded || await o?.loadSource();
456
+ const r = this.editorRef.profile;
457
+ r && "id" in r && (t = r.id);
458
+ const c = o?.definition?.variables?.find((s) => s.type === "feature");
459
+ let h = [], d;
460
+ return c?.definition && "fields" in c.definition && (h = c.definition.fields.map((s) => ({
461
+ name: s.name,
462
+ type: s.type,
463
+ alias: s.alias
464
+ })), ee(c?.definition) && (d = c.definition.title)), { profileName: t, metadata: h, layerName: d };
465
+ }
466
+ onCopyCode(e) {
467
+ const t = e ? `${this.disclaimerComment}
468
+ ${e}` : "";
469
+ return navigator.clipboard.writeText(t);
267
470
  }
268
471
  render() {
269
- return this.closed ? null : this.assistantsEnabled ? n`<calcite-flow><calcite-flow-item .selected=${!this.isViewingResult} closable .heading=${this.messages.arcadeassistant ?? "Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${W({ messages: this.messages })}${G({ messages: this.messages })}${Y({ active: this.confirmationActive, setActive: (e) => this.confirmationActive = e, messages: this.messages })}${K({ isDisabled: this.isDisabled, isReadOnly: this.isViewingResult, setQuestion: this.setQuestion, setIsViewingResult: (e) => this.isViewingResult = e, textAreaRef: this.textAreaRef, question: this.question, errorMessage: this.errorMessage, setErrorMessage: (e) => this.errorMessage = e, submitQuestion: this.submitQuestion.bind(this), messages: this.messages })}<calcite-block .hidden=${!this.isDisabled} .heading=${this.messages.generatingresponse ?? "Generating response..."}></calcite-block>${this.isViewingResult && n`<calcite-block class="block-response" icon-start=effects .heading=${this.messages.besteffort ?? "Here's the assistant's best effort"} expanded><calcite-list class="prompt-list" .label=${this.messages.promptlist ?? "Prompt list"}><calcite-list-item expanded class=${F(this.history[0]?.error ? "type-error" : "type-response")} .label=${A(this.history[0]?.script ?? "") || this.history[0]?.error} @calciteListItemSelect=${() => {
270
- R(this.editorRef.editorInstance, this.history[0]?.script ?? "", this.messages.disclaimercomment ?? "Expression generated by ArcGIS Arcade Assistant (beta)"), this.isViewingResult = !1, this.setQuestion("");
271
- }}><code slot=content><pre class="break-spaces">${A(this.history[0]?.script ?? "")}</pre></code></calcite-list-item></calcite-list><div class="response-actions"><calcite-button icon-start=plus round kind=brand @click=${() => {
272
- R(this.editorRef.editorInstance, this.history[0]?.script ?? "", this.messages.disclaimercomment ?? "Expression generated by ArcGIS Arcade Assistant (beta)"), this.isViewingResult = !1, this.setQuestion("");
273
- }}>${this.messages.addtoeditor ?? "Add to editor"}</calcite-button><calcite-button id=copy-to-clipboard icon-start=${this.copySuccess ? "check" : "copy-to-clipboard"} round kind=neutral @click=${async () => {
274
- const e = this.history[0]?.script ?? "";
275
- e && (await navigator.clipboard.writeText(e), this.copySuccess = !0, setTimeout(() => {
276
- this.copySuccess = !1;
277
- }, 1500));
278
- }}>${this.copySuccess ? this.messages.copied ?? "Copied!" : ""}</calcite-button><div class="feedback-button-container" id=feedback-buttons><calcite-button id=thumbs-up icon-start=thumbs-up appearance=transparent @click=${() => this.handleFeedbackButton("good")}></calcite-button><calcite-button id=thumbs-down appearance=transparent icon-start=thumbs-down @click=${() => this.handleFeedbackButton("bad")}></calcite-button><calcite-tooltip reference-element=feedback-buttons>${this.messages.providefeedback ?? "Provide feedback"}</calcite-tooltip></div></div><span class="result-disclaimer">${this.messages.reviewcodedisclaimer ?? "Review AI-generated code for accuracy, coherence, and relevance before using it."}</span></calcite-block>` || ""}<calcite-block .hidden=${this.isViewingResult || this.isDisabled || this.history.length < 1} .disabled=${this.isViewingResult || this.isDisabled || this.history.length < 1} class="no-space-block" collapsible .expanded=${this.history.length > 0} .heading=${this.messages.recentprompts ?? "Recent prompts"}><calcite-list class="prompt-list" .label=${this.messages.historylist ?? "History list"}>${this.history.map((e) => n`<calcite-list-item class="type-history" .label=${e.question} @calciteListItemSelect=${() => {
279
- this.errorMessage = "", this.setQuestion(e.question), this.textAreaRef.value?.setFocus();
280
- }}><calcite-icon icon=recent scale=s slot=content-end></calcite-icon></calcite-list-item>`)}</calcite-list></calcite-block>${this.feedbackActive ? n`<calcite-shell>${X({ open: this.feedbackActive, setOpen: this.handleFeedbackSheetClose, messages: this.messages, feedbackValue: this.feedbackValue ?? "good", setFeedbackValue: (e) => this.feedbackValue = e, feedbackText: this.feedbackText ?? "", setFeedbackText: (e) => this.feedbackText = e, onSubmit: this.handleFeedbackSubmit })}</calcite-shell>` : null}${!this.isViewingResult && n`<span class="result-disclaimer">${this.messages.aigenerated} ${this.messages.seeterms}</span>` || ""}</calcite-flow-item></calcite-flow>` : n`<calcite-flow><calcite-flow-item .selected=${!this.isViewingResult} closable .heading=${this.messages.arcadeassistant ?? "Arcade assistant"} @calciteFlowItemClose=${this.handleClose}><calcite-block label=info slot=content-top expanded><calcite-chip .label=${this.messages.new ?? "new"} kind=brand>${this.messages.new}</calcite-chip><h1 class="info-heading">${this.messages.introducing}</h1><p>${this.messages.capabilities}</p><p>${H(this.messages.useofassistant?.replace("{aiassistants}", `<strong>${this.messages.aiassistants ?? "Ai Assistants"}</strong>`))}</p></calcite-block></calcite-flow-item></calcite-flow>`;
472
+ return this.closed ? null : this.assistantsEnabled ? w`<calcite-flow><calcite-flow-item closable .heading=${this.messages.arcadeassistant ?? "Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${this.splashActive && w`<calcite-scrim></calcite-scrim>` || ""}${re({ messages: this.messages })}${ce({ popoverContent: q({ assistantsEnabled: this.assistantsEnabled, messages: { ...this.messages, ...u }, assistantHelpUrl: this.assistantHelpUrl, helpTopicUrl: this.usingTheAssitantDocUrl }) })}<calcite-shell class="unstyled-shell">${this.splashActive && me({ messages: { ...u, ...this.messages }, onProceed: () => {
473
+ this.splashActive = !1;
474
+ }, helpTopicUrl: this.assistantOverviewDocUrl, onExit: (e) => this.closePanel && this.closePanel(e) }) || ""}${ne({ active: this.confirmationActive, setActive: (e) => this.confirmationActive = e, messages: this.messages })}${de({ isDisabled: this.isSubmitting, isReadOnly: !1, setQuestion: this.setQuestion, setIsViewingResult: (e) => this.isViewingResult = e, mode: this.isViewingResult ? "refine" : "prompt", textAreaRef: this.textAreaRef, question: this.question, errorMessage: this.errorMessage, setErrorMessage: (e) => this.errorMessage = e, submitQuestion: this.submitQuestion.bind(this), messages: { ...u, ...this.messages }, context: this.context })}<calcite-block-group label="interactive blocks">${!this.isViewingResult && !this.isSubmitting && fe({ messages: { ...this.messages, ...u }, suggestions: ["Round value to one decimal place", 'Return "Yes" if value > 10'], onSuggestionClick: this.onSuggestionClick }) || ""}<calcite-block .hidden=${!this.isSubmitting} .heading=${this.messages.generatingresponse ?? "Generating response..."}></calcite-block>${M({
475
+ expanded: this.isViewingResult,
476
+ messages: { ...this.messages, ...u },
477
+ collapsible: !0,
478
+ showEffectsIcon: !0,
479
+ /** Only show the latest history card */
480
+ cards: this.historyCards.length ? [this.historyCards[0]] : [],
481
+ heading: this.messages.besteffort ?? "Here's the assistant's best effort",
482
+ hidden: this.isSubmitting || !this.isViewingResult,
483
+ onCopyCode: this.onCopyCode.bind(this),
484
+ standalone: !0
485
+ })}${M({
486
+ expanded: !this.isViewingResult,
487
+ messages: { ...this.messages, ...u },
488
+ collapsible: !0,
489
+ /**
490
+ * When the user is viewing the latest result, we display the first history card
491
+ * (historyCards[0]) separately at the top in "standalone" mode.
492
+ * To avoid showing the same card twice, we remove (slice out) the first card
493
+ * from the list of recent prompts below.
494
+ */
495
+ cards: this.isViewingResult ? this.historyCards.slice(1) : this.historyCards,
496
+ heading: this.messages.recentprompts ?? "Recent prompts",
497
+ hidden: this.isSubmitting || this.history.length === 0,
498
+ onCopyCode: this.onCopyCode.bind(this)
499
+ })}</calcite-block-group>${this.feedback.active ? he({ setOpen: this.handleFeedbackSheetClose, messages: { ...this.messages, ...u }, onSubmit: this.handleFeedbackSubmit, feedback: this.feedback, setFeedback: this.setFeedbackState.bind(this) }) : null}</calcite-shell></calcite-flow-item></calcite-flow>` : w`<calcite-flow><calcite-flow-item .selected=${!this.isViewingResult} closable .heading=${this.messages.arcadeassistant ?? "Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${q({ slot: "content-top", messages: { ...this.messages, ...u }, assistantsEnabled: this.assistantsEnabled, assistantHelpUrl: this.assistantHelpUrl, helpTopicUrl: this.usingTheAssitantDocUrl })}</calcite-flow-item></calcite-flow>`;
281
500
  }
282
501
  }
283
- V("arcgis-arcade-coding-assistant", ae);
502
+ V("arcgis-arcade-coding-assistant", $e);
284
503
  export {
285
- ae as ArcgisArcadeCodingAssistant
504
+ $e as ArcgisArcadeCodingAssistant
286
505
  };