@arcgis/coding-components 5.2.0-next.98 → 5.2.0-next.99

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.
@@ -14,8 +14,8 @@ import "@arcgis/toolkit/function";
14
14
  import { generateGuid as fe } from "@arcgis/toolkit/string";
15
15
  import { unsafeHTML as T } from "lit/directives/unsafe-html.js";
16
16
  import be from "@arcgis/core/layers/FeatureLayer.js";
17
- import L from "@arcgis/core/config.js";
18
- import O from "@arcgis/core/Graphic.js";
17
+ import z from "@arcgis/core/config.js";
18
+ import L from "@arcgis/core/Graphic.js";
19
19
  import { log as w } from "@arcgis/toolkit/log";
20
20
  import { getDeclaredVoxelMembers as ge, getDeclaredPixelMembers as ve } from "@arcgis/core/applications/Components/arcadeEditorUtils.js";
21
21
  import { s as ye } from "../../chunks/fields.js";
@@ -34,7 +34,7 @@ class A extends Error {
34
34
  super(e), this.name = "ArcadeAssistantError", this.code = t, this.subCode = o, this.details = s, this.source = n;
35
35
  }
36
36
  }
37
- function z(i) {
37
+ function O(i) {
38
38
  if (!i)
39
39
  return;
40
40
  const e = i.indexOf('{"error":');
@@ -59,13 +59,13 @@ async function Se(i) {
59
59
  method: "post",
60
60
  headers: {
61
61
  "Content-Type": "application/json",
62
- token: s
62
+ "X-Esri-Authorization": `Bearer ${s}`
63
63
  },
64
64
  body: JSON.stringify(a),
65
65
  responseType: "json"
66
66
  });
67
67
  } catch (g) {
68
- const v = g, k = v.details?.rawResponse || v.message || String(g), S = z(k);
68
+ const v = g, k = v.details?.rawResponse || v.message || String(g), S = O(k);
69
69
  throw S ? new A(S) : g;
70
70
  }
71
71
  const l = u.data;
@@ -84,13 +84,13 @@ async function Se(i) {
84
84
  method: "post",
85
85
  headers: {
86
86
  "Content-Type": "application/json",
87
- token: s
87
+ "X-Esri-Authorization": `Bearer ${s}`
88
88
  },
89
89
  body: JSON.stringify(k),
90
90
  responseType: "json"
91
91
  });
92
92
  } catch (C) {
93
- const q = C, ae = q.details?.rawResponse || q.message || String(C), _ = z(ae);
93
+ const q = C, ae = q.details?.rawResponse || q.message || String(C), _ = O(ae);
94
94
  throw _ ? new A(_) : C;
95
95
  }
96
96
  const y = S.data;
@@ -228,7 +228,7 @@ function B({ promptingEnabled: i, messages: e, slot: t, helpTopicUrl: o }) {
228
228
  function Ue({ messages: i, onProceed: e, onExit: t, helpTopicUrl: o }) {
229
229
  return d`<calcite-dialog close-disabled placement=top .heading=${i.welcome ?? "Welcome to the new assistant experience"} slot=dialogs open width-scale=m id=welcome-dialog><h3 class="unstyled-h3">${i.beforeyougetstarted ?? "Before you get started be aware:"}</h3><ul><li>${i.maybeincorrect ?? "AI generated code may occasionally be incorrect or biased. Review carefully."}</li><li>${T((i.pleasereadhelp ?? "Read the Arcade Assistant (beta) {helpTopic} to get started and learn details on security, privacy and limitations.").replace("{helpTopic}", `<calcite-link href=${o} target="_blank">${i.helptopic ?? "help topic"}</calcite-link>`))}</li></ul><calcite-button id=welcome-proceed slot=footer-end @click=${e}>${i.proceed ?? "Proceed"}</calcite-button><calcite-button id=welcome-decline slot=footer-start @click=${t} kind=neutral>${i.exit ?? "Exit"}</calcite-button></calcite-dialog>`;
230
230
  }
231
- function Le({ messages: i, suggestions: e, onSuggestionClick: t }) {
231
+ function ze({ messages: i, suggestions: e, onSuggestionClick: t }) {
232
232
  return d`<calcite-block .heading=${i.promptsuggestions} expanded collapsible id=suggestion-block scale=s><div class="suggestions">${e.map((o) => d`<calcite-button round scale=s appearance=outline-fill kind=neutral .label=${i.promptsuggestion} class="suggestion-button" @click=${() => t?.(o)}>${o}</calcite-button>`)}</div></calcite-block>`;
233
233
  }
234
234
  const j = 200;
@@ -238,14 +238,14 @@ function H({ hidden: i = !1, expanded: e = !1, messages: t, cards: o, heading: s
238
238
  navigator.clipboard.writeText(a.priorPrompt).then(() => {
239
239
  l.setAttribute("data-copied", "true"), setTimeout(() => l.removeAttribute("data-copied"), 1500);
240
240
  });
241
- }}></calcite-action><calcite-popover .referenceElement=${`copy-prompt-${a.conversationId}-${c ? "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}-${c ? "standalone" : "list"}`} placement=top-start class="copy-tooltip">${t.copyprompttoclipboard ?? "Copy prompt to clipboard"}</calcite-tooltip></div>${a.message && c && d`<div class="response-error-container">${Me({ 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 && !c && d`<calcite-tooltip .referenceElement=${`response-chip-${a.conversationId}-error`} placement=top-start>${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>` || ""}${Oe({ card: a, messages: t })}</calcite-chip-group></div><details class="collapsible-code" open><summary>Code response</summary><arcgis-code-viewer language=arcade round>${a.code}</arcgis-code-viewer></details></div></div><div slot=footer-start class="feedback-actions"><calcite-button class="add-to-editor-button hidden-above-380" @click=${() => a.onAddToEditor("add")} scale=s icon-start=plus round .label=${t.addtoeditor ?? "Add to editor"} .id=${`add-to-editor-button-${a.conversationId}-${c ? "standalone" : "list"}`}></calcite-button><calcite-tooltip class="hidden-above-380" .referenceElement=${`add-to-editor-button-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start>${t.addtoeditor ?? "Add to editor"}</calcite-tooltip><calcite-button class="add-to-editor-button hidden-below-380" @click=${() => a.onAddToEditor("add")} 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}-${c ? "standalone" : "list"}`}></calcite-button><calcite-tooltip .referenceElement=${`replace-${a.conversationId}-${c ? "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=${(u) => {
241
+ }}></calcite-action><calcite-popover .referenceElement=${`copy-prompt-${a.conversationId}-${c ? "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}-${c ? "standalone" : "list"}`} placement=top-start class="copy-tooltip">${t.copyprompttoclipboard ?? "Copy prompt to clipboard"}</calcite-tooltip></div>${a.message && c && d`<div class="response-error-container">${Me({ 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 && !c && d`<calcite-tooltip .referenceElement=${`response-chip-${a.conversationId}-error`} placement=top-start>${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>` || ""}${Le({ card: a, messages: t })}</calcite-chip-group></div><details class="collapsible-code" open><summary>Code response</summary><arcgis-code-viewer language=arcade round>${a.code}</arcgis-code-viewer></details></div></div><div slot=footer-start class="feedback-actions"><calcite-button class="add-to-editor-button hidden-above-380" @click=${() => a.onAddToEditor("add")} scale=s icon-start=plus round .label=${t.addtoeditor ?? "Add to editor"} .id=${`add-to-editor-button-${a.conversationId}-${c ? "standalone" : "list"}`}></calcite-button><calcite-tooltip class="hidden-above-380" .referenceElement=${`add-to-editor-button-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start>${t.addtoeditor ?? "Add to editor"}</calcite-tooltip><calcite-button class="add-to-editor-button hidden-below-380" @click=${() => a.onAddToEditor("add")} 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}-${c ? "standalone" : "list"}`}></calcite-button><calcite-tooltip .referenceElement=${`replace-${a.conversationId}-${c ? "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=${(u) => {
242
242
  const l = u.currentTarget;
243
243
  p(a.code).then(() => {
244
244
  l.setAttribute("data-copied", "true"), setTimeout(() => l.removeAttribute("data-copied"), 1500);
245
245
  });
246
246
  }} class="response-secondary-action-button" .id=${`copy-response-${a.conversationId}-${c ? "standalone" : "list"}`}></calcite-button><calcite-popover .referenceElement=${`copy-response-${a.conversationId}-${c ? "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}-${c ? "standalone" : "list"}`} placement=top-start class="copy-tooltip">${t.copytoclipboard ?? "Copy code to clipboard"}</calcite-tooltip></div><div slot=footer-end class="feedback-actions"><calcite-action .text=${t.thumbsup ?? "Thumbs up"} scale=s icon=thumbs-up @click=${a.onThumbsUp} .id=${`thumbs-up-${a.conversationId}-${c ? "standalone" : "list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-up-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start><span>${t.helpful ?? "Helpful"}</span></calcite-tooltip><calcite-action .text=${t.thumbsdown ?? "Thumbs down"} scale=s icon=thumbs-down @click=${a.onThumbsDown} .id=${`thumbs-down-${a.conversationId}-${c ? "standalone" : "list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-down-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start><span>${t.unhelpful ?? "Unhelpful"}</span></calcite-tooltip></div></calcite-card>`)}</calcite-card-group></calcite-block>`;
247
247
  }
248
- const Oe = ({ card: i, messages: e }) => {
248
+ const Le = ({ card: i, messages: e }) => {
249
249
  const t = fe(), o = `response-chip-profile-${i.conversationId}-${t}`, s = (e.profilecontextlabel ?? "Profile context: {profileId}").replace("{profileId}", i.profileId);
250
250
  return d`<calcite-tooltip .referenceElement=${o} placement=top-start class="contained-popover-or-tooltip">${s}</calcite-tooltip><calcite-chip .label=${i.profileId} scale=s appearance=outline icon=map-information id=${o ?? P}>${i.profileId}</calcite-chip>`;
251
251
  }, G = (i) => i.type === "featureSet";
@@ -259,12 +259,12 @@ const R = (i) => {
259
259
  return i.relationships?.forEach((t) => {
260
260
  e.push(t.toJSON());
261
261
  }), e;
262
- }, F = (i) => i.length > 0 ? { relationships: i } : {}, ze = (i) => ye(i).map((e) => ({
262
+ }, F = (i) => i.length > 0 ? { relationships: i } : {}, Oe = (i) => ye(i).map((e) => ({
263
263
  alias: e.alias,
264
264
  name: e.name,
265
265
  type: e.type,
266
266
  ...e.domain ? { domain: e.domain } : {}
267
- })), M = (i) => i ? { fields: ze(i) } : { fields: [] };
267
+ })), M = (i) => i ? { fields: Oe(i) } : { fields: [] };
268
268
  async function J(i) {
269
269
  const e = await i.loadSource(), t = te(e) && e.isTable, o = R(e);
270
270
  return {
@@ -543,7 +543,7 @@ class et extends ce {
543
543
  }, t = !0;
544
544
  } else
545
545
  o = this.viewState.feedback.item.contextSnapshot;
546
- const s = L.applicationName;
546
+ const s = z.applicationName;
547
547
  !s && !this.appVersion && w("warn", this, "esriConfig.applicationName is not set. Consider setting it to help identify the application version in feedback.");
548
548
  const { value: n, text: r, termsAccepted: p, item: { question: c, formattedScript: a, conversationId: u } } = this.viewState.feedback, l = {
549
549
  user_evaluation: n,
@@ -564,7 +564,7 @@ class et extends ce {
564
564
  privacy_statement: p ? "I_agree" : ""
565
565
  };
566
566
  try {
567
- await e.applyEdits({ addFeatures: [new O({ attributes: l })] });
567
+ await e.applyEdits({ addFeatures: [new L({ attributes: l })] });
568
568
  } catch (m) {
569
569
  w("error", this, "Error submitting feedback.", { detail: { error: m } });
570
570
  }
@@ -700,7 +700,7 @@ class et extends ce {
700
700
  }
701
701
  if (!t)
702
702
  return;
703
- const o = L.applicationName, s = e.contextSnapshot, n = {
703
+ const o = z.applicationName, s = e.contextSnapshot, n = {
704
704
  question: e.question,
705
705
  answer: this.encodeForFeedback(e.answer),
706
706
  useragent: navigator.userAgent,
@@ -713,7 +713,7 @@ class et extends ce {
713
713
  privacy_statement: ""
714
714
  };
715
715
  try {
716
- await t.applyEdits({ addFeatures: [new O({ attributes: n })] });
716
+ await t.applyEdits({ addFeatures: [new L({ attributes: n })] });
717
717
  } catch (r) {
718
718
  w("error", this, "Error logging arcade assistant question/answer interaction.", { detail: { error: r } });
719
719
  }
@@ -828,7 +828,7 @@ ${e}` : "";
828
828
  const e = this.viewState.viewMode === "result", t = this.getHistoryCards();
829
829
  return this.promptingEnabled ? d`<calcite-flow><calcite-flow-item closable heading-level=2 .heading=${this.messages.arcadeassistant ?? "Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${this.viewState.splashActive && d`<calcite-scrim></calcite-scrim>` || ""}${Re({ messages: this.messages })}${Fe({ messages: this.messages, popoverContent: B({ promptingEnabled: this.promptingEnabled, messages: this.messages, helpTopicUrl: this.usingTheAssitantDocUrl }) })}<calcite-shell class="unstyled-shell">${this.viewState.splashActive && Ue({ messages: this.messages, onProceed: () => {
830
830
  this.updateViewState({ splashActive: !1 });
831
- }, helpTopicUrl: this.assistantOverviewDocUrl, onExit: (o) => this.closePanel?.(o) }) || ""}${Ve({ active: this.viewState.confirmationActive, setActive: (o) => this.updateViewState({ confirmationActive: o }), messages: this.messages })}${qe({ isDisabled: this.viewState.isSubmitting, isReadOnly: !1, setQuestion: this.setQuestionState, setIsViewingResult: (o) => this.updateViewState({ viewMode: o ? "result" : "prompt" }), mode: e ? "refine" : "prompt", textAreaRef: this.textAreaRef, question: this.viewState.question, errorMessage: this.viewState.errorMessage, setErrorMessage: (o) => this.updateViewState({ errorMessage: o }), promptValidationMessage: this.viewState.promptValidationMessage, setPromptValidationMessage: (o) => this.updateViewState({ promptValidationMessage: o }), submitQuestion: this.submitQuestion.bind(this), assistantRef: this.el, messages: this.messages, context: this.viewState.context, contextReducedNoticeDismissed: this.viewState.contextReducedNoticeDismissed, setContextReducedNoticeDismissed: (o) => this.updateViewState({ contextReducedNoticeDismissed: o }) })}<calcite-block-group .label=${this.messages.interactiveblocks ?? "interactive blocks"}>${!e && !this.viewState.isSubmitting && Le({ messages: this.messages, suggestions: [this.messages.prompsuggestion1 ?? "", this.messages.prompsuggestion2 ?? ""], onSuggestionClick: this.onSuggestionClick }) || ""}<calcite-block .hidden=${!this.viewState.isSubmitting} .heading=${this.messages.generatingresponse ?? "Generating response..."}></calcite-block>${H({
831
+ }, helpTopicUrl: this.assistantOverviewDocUrl, onExit: (o) => this.closePanel?.(o) }) || ""}${Ve({ active: this.viewState.confirmationActive, setActive: (o) => this.updateViewState({ confirmationActive: o }), messages: this.messages })}${qe({ isDisabled: this.viewState.isSubmitting, isReadOnly: !1, setQuestion: this.setQuestionState, setIsViewingResult: (o) => this.updateViewState({ viewMode: o ? "result" : "prompt" }), mode: e ? "refine" : "prompt", textAreaRef: this.textAreaRef, question: this.viewState.question, errorMessage: this.viewState.errorMessage, setErrorMessage: (o) => this.updateViewState({ errorMessage: o }), promptValidationMessage: this.viewState.promptValidationMessage, setPromptValidationMessage: (o) => this.updateViewState({ promptValidationMessage: o }), submitQuestion: this.submitQuestion.bind(this), assistantRef: this.el, messages: this.messages, context: this.viewState.context, contextReducedNoticeDismissed: this.viewState.contextReducedNoticeDismissed, setContextReducedNoticeDismissed: (o) => this.updateViewState({ contextReducedNoticeDismissed: o }) })}<calcite-block-group .label=${this.messages.interactiveblocks ?? "interactive blocks"}>${!e && !this.viewState.isSubmitting && ze({ messages: this.messages, suggestions: [this.messages.prompsuggestion1 ?? "", this.messages.prompsuggestion2 ?? ""], onSuggestionClick: this.onSuggestionClick }) || ""}<calcite-block .hidden=${!this.viewState.isSubmitting} .heading=${this.messages.generatingresponse ?? "Generating response..."}></calcite-block>${H({
832
832
  expanded: e,
833
833
  messages: this.messages,
834
834
  collapsible: !0,