@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.
- package/dist/addons/arcade-coding-assistant/chat-helper.d.ts +25 -7
- package/dist/addons/arcade-coding-assistant/temporary-strings.d.ts +47 -0
- package/dist/addons/arcade-coding-assistant/useArcadeAssistant.d.ts +15 -7
- package/dist/addons.js +32 -23
- package/dist/cdn/{TUHPJEG5.js → 243HZ7UI.js} +2 -2
- package/dist/cdn/{J3HINC5N.js → 275GUA3M.js} +2 -2
- package/dist/cdn/{HAL3EXK4.js → 3J5TNLID.js} +2 -2
- package/dist/cdn/{Q4NJDLN3.js → 4DTIYTO6.js} +2 -2
- package/dist/cdn/{XNMOJ2SC.js → 4YQMMXJW.js} +2 -2
- package/dist/cdn/{D2Q4JNSY.js → 63FQPWTO.js} +2 -2
- package/dist/cdn/{CCQCZKCC.js → 6FY2AO4H.js} +2 -2
- package/dist/cdn/{Z3HBU3YI.js → 6TAOJNTW.js} +2 -2
- package/dist/cdn/73X3KSHQ.js +4 -0
- package/dist/cdn/{E4PTTXH5.js → 7ZZRCI6T.js} +2 -2
- package/dist/cdn/{FKQ7SSE6.js → ACFFT2B3.js} +2 -2
- package/dist/cdn/AQUP2HXZ.js +4 -0
- package/dist/cdn/AUUFEK2C.js +4 -0
- package/dist/cdn/{D4OPUHHF.js → C6IJOPEB.js} +2 -2
- package/dist/cdn/{ZBGL3SYO.js → CG3PBJU2.js} +1 -1
- package/dist/cdn/{RKCAAVN6.js → CSS7NGXW.js} +2 -2
- package/dist/cdn/{PULCYE7H.js → D3YK5GGC.js} +2 -2
- package/dist/cdn/{RFV2R57W.js → DQ3CWBLF.js} +2 -2
- package/dist/cdn/DU4OWFNM.js +6 -0
- package/dist/cdn/{YHNSFDD7.js → DU5TBBFS.js} +6 -5
- package/dist/cdn/{CPQVVDWR.js → E6HEGXX7.js} +2 -2
- package/dist/cdn/{HD2PUJ4M.js → EYUSBYIW.js} +2 -2
- package/dist/cdn/{NRWICP4W.js → G2IB3XMP.js} +1 -1
- package/dist/cdn/{PN27PZAJ.js → HJJWMOF6.js} +1 -1
- package/dist/cdn/IOZSQPXO.js +4 -0
- package/dist/cdn/{5PZD27HR.js → KBZEMXOZ.js} +2 -2
- package/dist/cdn/{JWPIQMYD.js → KT6QWFGE.js} +2 -2
- package/dist/cdn/{K7OR2NZQ.js → KYTS4Y5Z.js} +2 -2
- package/dist/cdn/{6QMJS7YE.js → L7QUBKS2.js} +2 -2
- package/dist/cdn/{X52LNMUC.js → LCWDBLK5.js} +2 -2
- package/dist/cdn/{NUXDGLLB.js → MWJDLSR7.js} +2 -2
- package/dist/cdn/{QD7WBTTH.js → MXYCSRPO.js} +2 -2
- package/dist/cdn/{PGN77MRP.js → N72EMFRZ.js} +2 -2
- package/dist/cdn/{GOQNPC4I.js → OBNBH4MW.js} +2 -2
- package/dist/cdn/{4UJSQGRR.js → OR4EO6XC.js} +3 -3
- package/dist/cdn/{IB5UEIFQ.js → PUWOUCEX.js} +3 -3
- package/dist/cdn/{IYAABMEA.js → S33IAILZ.js} +2 -2
- package/dist/cdn/{SPSZUVWZ.js → SDJ67XRE.js} +2 -2
- package/dist/cdn/{3OPZD6HG.js → VNQVJXEK.js} +2 -2
- package/dist/cdn/{VPRYSGQQ.js → WG2TPIR6.js} +2 -2
- package/dist/cdn/{F2YRSIVP.js → X5FPHYTE.js} +2 -2
- package/dist/cdn/assets/code-editor/sql-expr.worker.js +66327 -65375
- package/dist/cdn/index.js +2 -2
- package/dist/chunks/arcade-defaults.js +2 -2
- package/dist/chunks/arcade-executor.js +42 -41
- package/dist/chunks/arcade-mode.js +1 -1
- package/dist/chunks/arcade-service-accessors.js +1 -1
- package/dist/chunks/editor.js +1 -1
- package/dist/chunks/fields.js +1 -1
- package/dist/chunks/language-defaults-base.js +4 -3
- package/dist/chunks/markdown.js +1 -1
- package/dist/chunks/monaco-importer.js +64 -44
- package/dist/chunks/runtime.js +1 -1
- package/dist/chunks/setup-monaco.js +1 -1
- package/dist/chunks/sql-expr-contribution.js +1 -1
- package/dist/chunks/sql-expr-defaults.js +1 -1
- package/dist/chunks/sql-expr-mode.js +1 -1
- package/dist/chunks/useT9n.js +1 -1
- package/dist/components/arcgis-arcade-coding-assistant/customElement.d.ts +6 -7
- package/dist/components/arcgis-arcade-coding-assistant/customElement.js +395 -176
- package/dist/components/arcgis-arcade-coding-assistant/functional.d.ts +69 -13
- package/dist/components/arcgis-arcade-coding-assistant/index.d.ts +12 -6
- package/dist/components/arcgis-arcade-coding-assistant/index.js +12 -6
- package/dist/components/arcgis-arcade-coding-assistant/types.d.ts +45 -0
- package/dist/components/arcgis-arcade-editor/customElement.js +1 -1
- package/dist/components/arcgis-arcade-results/customElement.js +1 -1
- package/dist/components/arcgis-arcade-suggestions/customElement.js +1 -1
- package/dist/components/arcgis-code-editor/customElement.js +2 -2
- package/dist/components/arcgis-editor-variables/customElement.js +1 -1
- package/dist/components/arcgis-language-api-panel/customElement.js +1 -1
- package/dist/components/arcgis-sql-expression-editor/customElement.js +1 -1
- package/dist/components/arcgis-sql-expression-fields/customElement.js +1 -1
- package/dist/docs/api.json +5 -5
- package/dist/docs/docs.json +5 -5
- package/dist/docs/web-types.json +1 -1
- package/dist/index.js +1 -1
- package/dist/loader.js +2 -2
- package/dist/utils/arcade-executor.d.ts +4 -0
- package/dist/utils/utilities.d.ts +1 -1
- package/package.json +6 -6
- package/dist/cdn/K3KP6FDP.js +0 -4
- package/dist/cdn/MX7D2TXJ.js +0 -5
- package/dist/cdn/SLKYJBMF.js +0 -4
- 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 {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
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.
|
|
19
|
-
const
|
|
20
|
-
|
|
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),
|
|
27
|
-
if (
|
|
28
|
-
return
|
|
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
|
|
34
|
-
const { baseUrl: e, skillId: t, message:
|
|
35
|
-
message:
|
|
36
|
-
context:
|
|
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 && (
|
|
39
|
-
let
|
|
51
|
+
c && (m.conversation_id = c);
|
|
52
|
+
let a;
|
|
40
53
|
try {
|
|
41
|
-
|
|
54
|
+
a = await T(d, {
|
|
42
55
|
method: "post",
|
|
43
56
|
headers: {
|
|
44
57
|
"Content-Type": "application/json",
|
|
45
|
-
token:
|
|
58
|
+
token: r
|
|
46
59
|
},
|
|
47
|
-
body: JSON.stringify(
|
|
60
|
+
body: JSON.stringify(m),
|
|
48
61
|
responseType: "json"
|
|
49
62
|
});
|
|
50
|
-
} catch (
|
|
51
|
-
const b =
|
|
52
|
-
|
|
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
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
l.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
79
|
+
v = await T(d, {
|
|
71
80
|
method: "post",
|
|
72
81
|
headers: {
|
|
73
82
|
"Content-Type": "application/json",
|
|
74
|
-
token:
|
|
83
|
+
token: r
|
|
75
84
|
},
|
|
76
|
-
body: JSON.stringify(
|
|
85
|
+
body: JSON.stringify(x),
|
|
77
86
|
responseType: "json"
|
|
78
87
|
});
|
|
79
|
-
} catch (
|
|
80
|
-
const
|
|
81
|
-
|
|
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
|
|
86
|
-
if (
|
|
87
|
-
throw new
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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 (
|
|
94
|
-
throw new
|
|
104
|
+
if (b === g)
|
|
105
|
+
throw new $({
|
|
106
|
+
message: "Request timed out",
|
|
107
|
+
code: "TIMEOUT",
|
|
108
|
+
source: "polling"
|
|
109
|
+
});
|
|
95
110
|
}
|
|
96
|
-
|
|
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
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
|
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
|
|
113
|
-
return n`<calcite-action icon=information slot=header-actions-end id=legal-disclaimer text></calcite-action><calcite-
|
|
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
|
|
116
|
-
return n`<calcite-
|
|
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
|
|
119
|
-
return n`<calcite-
|
|
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
|
|
122
|
-
return n`<
|
|
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
|
|
131
|
-
|
|
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
|
|
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
|
|
145
|
-
class
|
|
250
|
+
let U = [], N = !0;
|
|
251
|
+
class $e extends L {
|
|
146
252
|
constructor() {
|
|
147
|
-
super(...arguments), this.textAreaRef =
|
|
148
|
-
this.
|
|
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.
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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.
|
|
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,
|
|
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 =
|
|
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 =
|
|
348
|
+
super.connectedCallback(), this.history = U, this.splashActive = N;
|
|
209
349
|
}
|
|
210
350
|
disconnectedCallback() {
|
|
211
|
-
super.disconnectedCallback(),
|
|
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.
|
|
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:
|
|
413
|
+
const { profileName: o, metadata: r, layerName: c } = await this.getProfileAndMetadata(t.uri), d = (await ie({
|
|
224
414
|
baseUrl: this.serviceUrl,
|
|
225
|
-
skillId:
|
|
415
|
+
skillId: be,
|
|
226
416
|
message: this.question,
|
|
227
417
|
authToken: e,
|
|
228
418
|
context: {
|
|
229
|
-
kind:
|
|
419
|
+
kind: ge,
|
|
230
420
|
context: {
|
|
231
|
-
profile_name:
|
|
232
|
-
metadata:
|
|
421
|
+
profile_name: o,
|
|
422
|
+
metadata: r
|
|
233
423
|
}
|
|
234
424
|
}
|
|
235
|
-
})).find((
|
|
236
|
-
if (!
|
|
425
|
+
})).find((s) => s.context?.kind === "ArcadeCodeResponse");
|
|
426
|
+
if (!d)
|
|
237
427
|
return;
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
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
|
-
|
|
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.
|
|
444
|
+
this.isSubmitting = !1;
|
|
247
445
|
}
|
|
248
446
|
}
|
|
249
447
|
}
|
|
250
448
|
async getToken() {
|
|
251
|
-
const { token: e } = await
|
|
449
|
+
const { token: e } = await W.getCredential(this.portalUrl);
|
|
252
450
|
return e;
|
|
253
451
|
}
|
|
254
452
|
async getProfileAndMetadata(e) {
|
|
255
|
-
let t =
|
|
256
|
-
const
|
|
257
|
-
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
const c =
|
|
261
|
-
let
|
|
262
|
-
return c?.definition && "fields" in c.definition && (
|
|
263
|
-
name:
|
|
264
|
-
type:
|
|
265
|
-
alias:
|
|
266
|
-
}))), { profileName: t, metadata:
|
|
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 ?
|
|
270
|
-
|
|
271
|
-
}}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
this.
|
|
280
|
-
|
|
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",
|
|
502
|
+
V("arcgis-arcade-coding-assistant", $e);
|
|
284
503
|
export {
|
|
285
|
-
|
|
504
|
+
$e as ArcgisArcadeCodingAssistant
|
|
286
505
|
};
|