@arcgis/coding-components 4.33.0-next.159 → 4.33.0-next.160
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 +1 -0
- package/dist/addons.js +1 -1
- package/dist/cdn/{PWL3LLFK.js → 2NSAO3BQ.js} +2 -2
- package/dist/cdn/{AFEL3H6J.js → 2QXCR5YU.js} +2 -2
- package/dist/cdn/{HNCYN2JT.js → 2ZQA5JD2.js} +2 -2
- package/dist/cdn/{DWHBPDYP.js → 3YCYG4KW.js} +2 -2
- package/dist/cdn/{5SNVZH4G.js → 4PDW3HA6.js} +1 -1
- package/dist/cdn/{GP5ZRQRC.js → 5NADOAQD.js} +2 -2
- package/dist/cdn/{ICD2DOTW.js → 6WSKB3LZ.js} +2 -2
- package/dist/cdn/{OPJJALI4.js → 72TQWGCF.js} +2 -2
- package/dist/cdn/{MROWFPLE.js → CNMOWAL7.js} +2 -2
- package/dist/cdn/{QMCEWN5I.js → CPMRD2UC.js} +2 -2
- package/dist/cdn/{2S4UQAUQ.js → DKPJFLB7.js} +2 -2
- package/dist/cdn/{CQRTFEI4.js → E5FQ6V7E.js} +2 -2
- package/dist/cdn/{CKB7MPWZ.js → FBJ5GSV5.js} +2 -2
- package/dist/cdn/{2N3K2DTA.js → FEBRJ4AG.js} +2 -2
- package/dist/cdn/{2O5RPSXV.js → GG57GV3Z.js} +2 -2
- package/dist/cdn/{XGKSQ37I.js → H6GZE5GV.js} +1 -1
- package/dist/cdn/{F2UFY3RX.js → HA22JR2C.js} +2 -2
- package/dist/cdn/{AQGWSXEM.js → HCNSKBQ2.js} +1 -1
- package/dist/cdn/{IPPUV6EE.js → HZOWMCAR.js} +4 -4
- package/dist/cdn/{ILF5Q6DK.js → J7AJUDB4.js} +2 -2
- package/dist/cdn/{BKAX43XK.js → MG33KLLO.js} +2 -2
- package/dist/cdn/{PBM6WNXJ.js → NCZTUBOY.js} +2 -2
- package/dist/cdn/{OUFLMSN5.js → PFS4N2ZF.js} +2 -2
- package/dist/cdn/{P3PNT4CY.js → PJMN2B75.js} +2 -2
- package/dist/cdn/{KRIIXM7I.js → QG5A2NJ5.js} +2 -2
- package/dist/cdn/{V7SC4CIM.js → QSNKNLXX.js} +2 -2
- package/dist/cdn/{YQ57PCM5.js → R2ZFLZIE.js} +2 -2
- package/dist/cdn/{W4BTM2ZK.js → RB2HX4BV.js} +2 -2
- package/dist/cdn/SZIDTVM5.js +6 -0
- package/dist/cdn/{X6FMPCMO.js → TDDM42QP.js} +2 -2
- package/dist/cdn/{6WWFCVZB.js → TDPYCZYH.js} +2 -2
- package/dist/cdn/{WYDZSWHV.js → TG7W2MUK.js} +2 -2
- package/dist/cdn/{G4BNUVHU.js → U33YFCJ3.js} +2 -2
- package/dist/cdn/{WAATIDDH.js → U4DVUCWU.js} +1 -1
- package/dist/cdn/{FPH6NDHK.js → U5AA63OY.js} +2 -2
- package/dist/cdn/{4SV5TVK4.js → UXT2NSH4.js} +2 -2
- package/dist/cdn/{BYYHEISS.js → VMXI4ZR6.js} +2 -2
- package/dist/cdn/{VXOLFZKS.js → WLEU7HWL.js} +2 -2
- package/dist/cdn/{ZQ3NYHSG.js → XN2VBWAB.js} +2 -2
- package/dist/cdn/{IQBUSAE6.js → Y6C5EOVW.js} +2 -2
- package/dist/cdn/{TKXDIBWX.js → ZVQ3IJZB.js} +1 -1
- package/dist/cdn/assets/code-editor/sql-expr.worker.js +12781 -12760
- package/dist/cdn/index.js +2 -2
- package/dist/chunks/arcade-defaults.js +1 -1
- package/dist/chunks/arcade-executor.js +1 -1
- 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 +1 -1
- package/dist/chunks/markdown.js +1 -1
- package/dist/chunks/monaco-importer.js +1 -1
- 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 +3 -1
- package/dist/components/arcgis-arcade-coding-assistant/customElement.js +225 -182
- package/dist/components/arcgis-arcade-coding-assistant/functional.d.ts +16 -8
- package/dist/components/arcgis-arcade-coding-assistant/index.d.ts +1 -1
- package/dist/components/arcgis-arcade-coding-assistant/index.js +1 -1
- package/dist/components/arcgis-arcade-coding-assistant/types.d.ts +9 -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 +1 -1
- 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 +2 -2
- package/dist/docs/docs.json +2 -2
- package/dist/docs/web-types.json +1 -1
- package/dist/index.js +1 -1
- package/dist/loader.js +1 -1
- package/package.json +5 -5
- package/dist/cdn/LYA74LSW.js +0 -6
|
@@ -1,187 +1,190 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import "
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import { repeat as
|
|
1
|
+
import { c as B } from "../../chunks/runtime.js";
|
|
2
|
+
import { nothing as R, LitElement as H } from "@arcgis/lumina";
|
|
3
|
+
import { ref as L, 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 M } from "../../chunks/arcade-defaults.js";
|
|
7
|
+
import { css as G } from "@lit/reactive-element/css-tag.js";
|
|
8
|
+
import { html as C } from "lit";
|
|
9
|
+
import q from "@arcgis/core/request.js";
|
|
10
|
+
import { e as J, a as Y } from "../../chunks/monaco-importer.js";
|
|
11
|
+
import { html as r } from "lit-html";
|
|
12
|
+
import { repeat as D } from "lit-html/directives/repeat.js";
|
|
13
13
|
import "@arcgis/components-utils";
|
|
14
14
|
import { unsafeHTML as S } from "lit/directives/unsafe-html.js";
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import { b as
|
|
15
|
+
import K from "@arcgis/core/layers/FeatureLayer.js";
|
|
16
|
+
import X from "@arcgis/core/Graphic.js";
|
|
17
|
+
import { b as Z } from "../../chunks/language-defaults-base.js";
|
|
18
18
|
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
19
19
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
20
|
-
v4.33.0-next.
|
|
21
|
-
const
|
|
22
|
-
class
|
|
20
|
+
v4.33.0-next.160 */
|
|
21
|
+
const ee = 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-chips{--calcite-chip-background-color: var(--calcite-color-foreground-current);--calcite-chip-text-color: var(--calcite-color-brand);calcite-chip{cursor:pointer}}.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{margin:.25rem 0 .75rem;max-width:90%;overflow-y:hidden;overflow-x:auto;padding:0}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}.copy-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-danger) 10%,transparent);border-radius:var(--calcite-corner-radius-round);margin:1rem 0;font-size:var(--calcite-font-size--2);border:var(--calcite-color-status-danger) solid 1px}.response-error-container p{margin:0 0 0 1em}}:host([closed]){display:none}`;
|
|
22
|
+
class $ extends Error {
|
|
23
23
|
constructor({
|
|
24
24
|
message: e,
|
|
25
25
|
code: t,
|
|
26
|
-
subCode:
|
|
27
|
-
details:
|
|
28
|
-
source:
|
|
26
|
+
subCode: o,
|
|
27
|
+
details: a,
|
|
28
|
+
source: s
|
|
29
29
|
}) {
|
|
30
|
-
super(e), this.name = "ArcadeAssistantError", this.code = t, this.subCode =
|
|
30
|
+
super(e), this.name = "ArcadeAssistantError", this.code = t, this.subCode = o, this.details = a, this.source = s;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function P(i) {
|
|
34
34
|
if (!i)
|
|
35
35
|
return;
|
|
36
36
|
const e = i.indexOf('{"error":');
|
|
37
37
|
if (e !== -1)
|
|
38
38
|
try {
|
|
39
|
-
const t = i.slice(e),
|
|
40
|
-
if (
|
|
41
|
-
return
|
|
39
|
+
const t = i.slice(e), o = JSON.parse(t);
|
|
40
|
+
if (o && typeof o == "object" && o.error)
|
|
41
|
+
return o.error;
|
|
42
42
|
} catch {
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
async function
|
|
47
|
-
const { baseUrl: e, skillId: t, message:
|
|
48
|
-
message:
|
|
49
|
-
context:
|
|
46
|
+
async function te(i) {
|
|
47
|
+
const { baseUrl: e, skillId: t, message: o, authToken: a, previousConversationId: s, context: p } = i, c = t ? `${e}/skills/${t}/chat` : `${e}/chat`, n = [], h = {
|
|
48
|
+
message: o,
|
|
49
|
+
context: p
|
|
50
50
|
};
|
|
51
|
-
|
|
52
|
-
let
|
|
51
|
+
s && (h.conversation_id = s);
|
|
52
|
+
let f;
|
|
53
53
|
try {
|
|
54
|
-
|
|
54
|
+
f = await q(c, {
|
|
55
55
|
method: "post",
|
|
56
56
|
headers: {
|
|
57
57
|
"Content-Type": "application/json",
|
|
58
|
-
token:
|
|
58
|
+
token: a
|
|
59
59
|
},
|
|
60
|
-
body: JSON.stringify(
|
|
60
|
+
body: JSON.stringify(h),
|
|
61
61
|
responseType: "json"
|
|
62
62
|
});
|
|
63
63
|
} catch (g) {
|
|
64
|
-
const v = g, A = v.details?.rawResponse || v.message || String(g),
|
|
65
|
-
throw
|
|
64
|
+
const v = g, A = v.details?.rawResponse || v.message || String(g), k = P(A);
|
|
65
|
+
throw k ? new $(k) : g;
|
|
66
66
|
}
|
|
67
|
-
const
|
|
68
|
-
n.push(
|
|
69
|
-
const
|
|
70
|
-
let
|
|
67
|
+
const b = f.data;
|
|
68
|
+
n.push(b);
|
|
69
|
+
const y = b.conversationId, l = b.inquiryId;
|
|
70
|
+
let u = b.sequenceNumber;
|
|
71
71
|
async function w() {
|
|
72
72
|
let g = 0;
|
|
73
73
|
const v = 25;
|
|
74
74
|
for (; g < v; ) {
|
|
75
|
-
await new Promise((
|
|
76
|
-
const A =
|
|
77
|
-
let
|
|
75
|
+
await new Promise((x) => setTimeout(x, 1e3));
|
|
76
|
+
const A = ie(y, u, l);
|
|
77
|
+
let k;
|
|
78
78
|
try {
|
|
79
|
-
|
|
79
|
+
k = await q(c, {
|
|
80
80
|
method: "post",
|
|
81
81
|
headers: {
|
|
82
82
|
"Content-Type": "application/json",
|
|
83
|
-
token:
|
|
83
|
+
token: a
|
|
84
84
|
},
|
|
85
85
|
body: JSON.stringify(A),
|
|
86
86
|
responseType: "json"
|
|
87
87
|
});
|
|
88
|
-
} catch (
|
|
89
|
-
const T =
|
|
90
|
-
throw
|
|
88
|
+
} catch (x) {
|
|
89
|
+
const T = x, V = T.details?.rawResponse || T.message || String(x), E = P(V);
|
|
90
|
+
throw E ? new $(E) : x;
|
|
91
91
|
}
|
|
92
|
-
const m =
|
|
92
|
+
const m = k.data;
|
|
93
93
|
if (m.context && m.context.kind === "ArcgisErrorAsContext" && m.context.error)
|
|
94
|
-
throw new
|
|
94
|
+
throw new $({
|
|
95
95
|
message: m.context.error.message || "ArcGIS Assistant error",
|
|
96
96
|
code: m.context.error.code,
|
|
97
97
|
subCode: m.context.error.subCode,
|
|
98
98
|
details: m.context.error.details,
|
|
99
99
|
source: "polling-response"
|
|
100
100
|
});
|
|
101
|
-
if (n.push(m),
|
|
101
|
+
if (n.push(m), u = m.sequenceNumber, g++, !m.hasMore)
|
|
102
102
|
break;
|
|
103
103
|
}
|
|
104
104
|
if (g === v)
|
|
105
|
-
throw new
|
|
105
|
+
throw new $({
|
|
106
106
|
message: "Request timed out",
|
|
107
107
|
code: "TIMEOUT",
|
|
108
108
|
source: "polling"
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
-
const
|
|
111
|
+
const O = 2 * 60 * 1e3;
|
|
112
112
|
return await Promise.race([
|
|
113
113
|
w(),
|
|
114
114
|
new Promise(
|
|
115
115
|
(g, v) => setTimeout(
|
|
116
116
|
() => v(
|
|
117
|
-
new
|
|
117
|
+
new $({
|
|
118
118
|
message: "Request timed out",
|
|
119
119
|
code: "TIMEOUT",
|
|
120
120
|
source: "hard-timeout"
|
|
121
121
|
})
|
|
122
122
|
),
|
|
123
|
-
|
|
123
|
+
O
|
|
124
124
|
)
|
|
125
125
|
)
|
|
126
126
|
]), n;
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function ie(i, e, t) {
|
|
129
129
|
return {
|
|
130
130
|
conversationId: i,
|
|
131
131
|
inquiryId: t,
|
|
132
132
|
ackSequenceNumber: e
|
|
133
133
|
};
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function oe(i) {
|
|
136
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
137
|
}
|
|
138
|
-
const
|
|
139
|
-
const e = i.value.length, t = 72,
|
|
140
|
-
i.style.setProperty("--calcite-text-area-min-height", `${Math.min(n,
|
|
138
|
+
const ae = (i) => {
|
|
139
|
+
const e = i.value.length, t = 72, o = 180, a = i.offsetWidth, p = Math.max(1, Math.floor(a / 8)), c = Math.ceil(e / p), n = t + (c - 2) * 24;
|
|
140
|
+
i.style.setProperty("--calcite-text-area-min-height", `${Math.min(n, o)}px`);
|
|
141
141
|
};
|
|
142
|
-
function
|
|
143
|
-
return
|
|
142
|
+
function se({ messages: i }) {
|
|
143
|
+
return r`<calcite-chip slot=header-actions-end scale=s appearance=outline-fill .label=${i.beta ?? "Beta"}>${i.beta ?? "Beta"}</calcite-chip>`;
|
|
144
144
|
}
|
|
145
|
-
function
|
|
146
|
-
return
|
|
145
|
+
function re({ popoverContent: i }) {
|
|
146
|
+
return r`<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
147
|
}
|
|
148
|
-
function
|
|
149
|
-
return
|
|
148
|
+
function z({ errorMessage: i, slot: e }) {
|
|
149
|
+
return r`<div class="error-display"><calcite-input-message id=error-message status=invalid icon=exclamation-mark-triangle scale=m slot=${e ?? R}>${i}</calcite-input-message></div>`;
|
|
150
150
|
}
|
|
151
|
-
function
|
|
152
|
-
return
|
|
151
|
+
function ce({ active: i, setActive: e, messages: t }) {
|
|
152
|
+
return r`<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
153
|
}
|
|
154
|
-
function
|
|
155
|
-
return
|
|
156
|
-
te(f.target), t(f.target.value);
|
|
157
|
-
}} ${D(s)}>${l && oe({ errorMessage: l }) || ""}</calcite-text-area><div class="response-actions" slot=footer-end><calcite-button round kind=neutral .hidden=${b !== "refine"} icon-start=arrow-left appearance=solid .disabled=${i} @click=${async () => {
|
|
158
|
-
a(!1), t("");
|
|
159
|
-
}}>${d.startover ?? "Start Over"}</calcite-button><calcite-button round icon-end=effects appearance=solid .loading=${i} .disabled=${i} @click=${async () => {
|
|
160
|
-
r(o ? "" : d.enteraprompt ?? "Please enter a prompt"), await n();
|
|
161
|
-
}}>${b === "prompt" ? d.ask ?? "Generate" : d.refine ?? "Refine"}</calcite-button></div></div>`;
|
|
154
|
+
function ne({ context: i, messages: e }) {
|
|
155
|
+
return i ? r`<div class="gaps">${i.profileName && r`<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 && r`<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;
|
|
162
156
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
157
|
+
function le({ isDisabled: i, isReadOnly: e, setQuestion: t, setIsViewingResult: o, textAreaRef: a, question: s, errorMessage: p, setErrorMessage: c, submitQuestion: n, messages: h, mode: f, context: b }) {
|
|
158
|
+
return r`<div class="text-area-wrapper"><calcite-text-area resize=vertical .readOnly=${i || e} class="styled-text-area" .placeholder=${h.askaquestion ?? `Specify the calculation or logic you need in an Arcade expression. (e.g., 'Return "Yes" if value > 10')`} .value=${s} @calciteTextAreaInput=${(y) => {
|
|
159
|
+
ae(y.target), t(y.target.value);
|
|
160
|
+
}} ${L(a)}><div class="submission-actions-wrapper" slot=footer-start>${p && z({ errorMessage: p, slot: "footer-start" }) || ""}<div class="submission-actions">${ne({ context: b, messages: h })}<div class="align-inline-end gaps"><calcite-button round kind=neutral .hidden=${f !== "refine"} icon-start=arrow-left appearance=solid .disabled=${i} @click=${async () => {
|
|
161
|
+
o(!1), t("");
|
|
162
|
+
}}>${h.startover ?? "Start Over"}</calcite-button><calcite-button round icon-end=effects appearance=solid .loading=${i} .disabled=${i} @click=${async () => {
|
|
163
|
+
c(s ? "" : h.enteraprompt ?? "Please enter a prompt"), await n();
|
|
164
|
+
}}>${f === "prompt" ? h.ask ?? "Generate" : h.refine ?? "Refine"}</calcite-button></div></div></div></calcite-text-area></div>`;
|
|
168
165
|
}
|
|
169
|
-
|
|
170
|
-
|
|
166
|
+
const de = "https://www.esri.com/en-us/privacy/privacy-statements/privacy-statement", pe = "https://www.esri.com/en-us/privacy/privacy-statements/privacy-supplement";
|
|
167
|
+
function ue({ setOpen: i, messages: e, feedback: t, setFeedback: o, onSubmit: a }) {
|
|
168
|
+
return r`<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=${(s) => o({ ...t, text: s.target.value })}></calcite-text-area></calcite-label><calcite-label layout=inline scale=s><calcite-checkbox scale=l .checked=${t.termsAccepted} @calciteCheckboxChange=${(s) => {
|
|
169
|
+
o({ ...t, termsAccepted: s.target.checked });
|
|
170
|
+
}}></calcite-checkbox><span>${S(e.agreement?.replace("{EsriPrivacyStatement}", `<calcite-link href=${de} target="_blank">${e.esriprivacystatement ?? "Esri Privacy Statement"}</calcite-link>`).replace("{Supplement}", `<calcite-link href=${pe} target="_blank">${e.supplement ?? "Supplement"}</calcite-link>`))}</span></calcite-label></div><calcite-button slot=footer width=full @click=${a} .disabled=${!t.termsAccepted || t.submitting} .loading=${t.submitting}>${e.submitfeedback ?? "Submit Feedback"}</calcite-button></calcite-panel></calcite-sheet>`;
|
|
171
171
|
}
|
|
172
|
-
function
|
|
173
|
-
return
|
|
172
|
+
function N({ assistantsEnabled: i, messages: e, slot: t, assistantHelpUrl: o, helpTopicUrl: a }) {
|
|
173
|
+
return r`<calcite-block .label=${e.assistantinformation ?? "Assistant information"} slot=${t ?? R} 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 ? r`<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>${S((e.seedocumentation ?? "Please see the {documentation} for more information, including limitations and additional resources.").replace("{documentation}", `<calcite-link href=${a} target="_blank">${e.documentation ?? "documentation"}</calcite-link>`))}</p>` : r`<p>${S(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>`;
|
|
174
174
|
}
|
|
175
|
-
function
|
|
176
|
-
return
|
|
175
|
+
function he({ messages: i, onProceed: e, onExit: t, helpTopicUrl: o }) {
|
|
176
|
+
return r`<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>${S(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>`;
|
|
177
177
|
}
|
|
178
|
-
function
|
|
179
|
-
|
|
180
|
-
return c`<calcite-block .hidden=${i} id=result-block .heading=${s ?? t.besteffort ?? "Here is the assistant's best effort"} .expanded=${e} .collapsible=${o}>${l && c`<calcite-chip label slot=content-start icon=effects kind=brand></calcite-chip>` || ""}<calcite-card-group .label=${t.assistantresponses}>${a.map((h, $) => c`<calcite-card><div slot=heading><div class="prior-prompt">${h.priorPrompt}</div></div><div><div class="code-response-wrapper"><div class="positioned-code-content">${h.chips?.map((p, w) => c`${p.tooltip && c`<calcite-tooltip .referenceElement=${`response-chip-${p.conversationId}-${w}`}>${p.tooltip}</calcite-tooltip>` || ""}<calcite-chip .label=${p.label} .scale=${p.scale ?? "s"} .appearance=${p.appearance ?? "outline"} .icon=${p.icon} .id=${`response-chip-${p.conversationId}-${w}`}>${p.label}</calcite-chip>`)}</div><code>${h.code}</code></div></div><div slot=footer-start><calcite-split-button primary-text=${b ?? U} appearance=outline-fill class="add-to-editor-button" @calciteSplitButtonPrimaryClick=${() => h.onAddToEditor()} overlay-positioning=fixed><calcite-dropdown-item @calciteDropdownItemSelect=${() => {
|
|
181
|
-
n?.(d ? "add" : "replace");
|
|
182
|
-
}}>${f}</calcite-dropdown-item></calcite-split-button><calcite-button round icon-start=copy-to-clipboard kind=neutral @click=${() => h.onCopy($)} class="copy-button">${h.copySuccessIndex === $ ? t.copied ?? "copied" : ""}</calcite-button></div><div slot=footer-end class="feedback-actions"><calcite-action .text=${t.thumbsup} scale=s icon=thumbs-up @click=${h.onThumbsUp}></calcite-action><calcite-action .text=${t.thumbsdown} scale=s icon=thumbs-down @click=${h.onThumbsDown}></calcite-action></div></calcite-card>`)}</calcite-card-group></calcite-block>`;
|
|
178
|
+
function me({ messages: i, suggestions: e, onSuggestionClick: t }) {
|
|
179
|
+
return r`<calcite-block .heading=${i.promptsuggestions} expanded collapsible id=suggestion-block><calcite-chip-group .label=${i.promptsuggestions} class="suggestion-chips">${D(e, (o) => o, (o) => r`<calcite-chip .label=${i.promptsuggestion} .value=${o} icon=effects @click=${() => t?.(o)}>${o}</calcite-chip>`)}</calcite-chip-group></calcite-block>`;
|
|
183
180
|
}
|
|
184
|
-
|
|
181
|
+
function U({ hidden: i = !1, expanded: e = !1, messages: t, cards: o, heading: a, collapsible: s = !1, showEffectsIcon: p = !1, editorInsertMode: c = "add", setEditorInsertMode: n, copySuccessConversationId: h }) {
|
|
182
|
+
const f = c === "replace", b = f ? t.replaceineditor ?? "Replace in editor" : t.addtoeditor ?? "Add to editor", y = f ? t.addtoeditor ?? "Add to editor" : t.replaceineditor ?? "Replace in editor";
|
|
183
|
+
return r`<calcite-block .hidden=${i} id=result-block .heading=${a ?? t.besteffort ?? "Here is the assistant's best effort"} .expanded=${e} .collapsible=${s}>${p && r`<calcite-chip .label=${t.assistantresponses} slot=content-start icon=effects scale=m class="suggestion-chips"></calcite-chip>` || ""}<calcite-card-group .label=${t.assistantresponses}>${D(o, (l) => l.conversationId, (l) => r`<calcite-card><div slot=heading><div class="prior-prompt">${l.priorPrompt}</div>${l.message && r`<div class="collapsible-error response-error-container"><div class="error-display">${z({ errorMessage: r`<details open><summary>Error</summary><p>${l.message}</p></details>` })}</div></div>` || ""}</div><div><div class="code-response-wrapper"><div class="positioned-code-content">${l.chips?.map((u, w) => r`${u.tooltip && r`<calcite-tooltip .referenceElement=${`response-chip-${u.conversationId}-${w}`} placement=top-start>${u.tooltip}</calcite-tooltip>` || ""}<calcite-chip .label=${u.label} .scale=${u.scale ?? "s"} .appearance=${u.appearance ?? "outline"} .icon=${u.icon} .id=${`response-chip-${u.conversationId}-${w}`}>${u.label}</calcite-chip>`)}</div><details class="collapsible-code" open><summary>Code response</summary><code>${l.code}</code></details></div></div><div slot=footer-start><calcite-split-button primary-text=${b ?? R} appearance=outline-fill class="add-to-editor-button" @calciteSplitButtonPrimaryClick=${() => l.onAddToEditor()} overlay-positioning=fixed><calcite-dropdown-item @calciteDropdownItemSelect=${() => {
|
|
184
|
+
n?.(f ? "add" : "replace");
|
|
185
|
+
}}>${y}</calcite-dropdown-item></calcite-split-button><calcite-button round icon-start=copy-to-clipboard kind=neutral @click=${() => l.onCopy(l.conversationId)} class="copy-button">${l.conversationId === h ? t.copied ?? "copied" : ""}</calcite-button></div><div slot=footer-end class="feedback-actions"><calcite-action .text=${t.thumbsup} scale=s icon=thumbs-up @click=${l.onThumbsUp}></calcite-action><calcite-action .text=${t.thumbsdown} scale=s icon=thumbs-down @click=${l.onThumbsDown}></calcite-action></div></calcite-card>`)}</calcite-card-group></calcite-block>`;
|
|
186
|
+
}
|
|
187
|
+
const d = {
|
|
185
188
|
welcome: "Welcome to the new assistant experience",
|
|
186
189
|
beforeyougetstarted: "Before you get started be aware:",
|
|
187
190
|
maybeincorrect: "AI generated code may occasionally be incorrect or biased. Review carefully.",
|
|
@@ -215,7 +218,7 @@ const u = {
|
|
|
215
218
|
numlayers: "{numLayers} {layerOrLayers}",
|
|
216
219
|
numlayersplural: "layers",
|
|
217
220
|
numlayerssingular: "layer"
|
|
218
|
-
},
|
|
221
|
+
}, fe = "arcade_generation", be = "ArcadeCodeRequest", I = "visualization", ge = "ArcadeAssistant", ve = [
|
|
219
222
|
"your_comments",
|
|
220
223
|
"user_evaluation",
|
|
221
224
|
"question",
|
|
@@ -226,10 +229,10 @@ const u = {
|
|
|
226
229
|
"context",
|
|
227
230
|
"extras"
|
|
228
231
|
];
|
|
229
|
-
let
|
|
230
|
-
class
|
|
232
|
+
let F = [], _ = !0;
|
|
233
|
+
class ye extends H {
|
|
231
234
|
constructor() {
|
|
232
|
-
super(...arguments), this.textAreaRef =
|
|
235
|
+
super(...arguments), this.textAreaRef = j(), this.messages = Q(), this._feedbackService = void 0, this.handleFeedbackButton = (e, t) => {
|
|
233
236
|
this.feedback = { ...this.feedback, active: !0, value: e, item: t };
|
|
234
237
|
}, this.handleFeedbackSheetClose = () => {
|
|
235
238
|
this.feedback = {
|
|
@@ -247,23 +250,23 @@ class be extends V {
|
|
|
247
250
|
this.handleFeedbackSheetClose();
|
|
248
251
|
return;
|
|
249
252
|
}
|
|
250
|
-
const t = this.getModel(),
|
|
253
|
+
const t = this.getModel(), o = t ? await this.getProfileAndMetadata(t.uri) : void 0, a = {
|
|
251
254
|
user_evaluation: this.feedback.value,
|
|
252
255
|
your_comments: this.feedback.text || void 0,
|
|
253
256
|
question: this.question,
|
|
254
257
|
answer: this.feedback.item?.script ?? "",
|
|
255
258
|
useragent: navigator.userAgent,
|
|
256
|
-
_source:
|
|
259
|
+
_source: ge,
|
|
257
260
|
version: this.appVersion ?? "",
|
|
258
|
-
context:
|
|
259
|
-
extras:
|
|
261
|
+
context: o ? JSON.stringify(o) : "",
|
|
262
|
+
extras: o?.profileName ?? "",
|
|
260
263
|
conversation_id: this.feedback.item?.conversationId ?? "",
|
|
261
264
|
privacy_statement: this.feedback.termsAccepted ? "I_agree" : ""
|
|
262
265
|
};
|
|
263
266
|
try {
|
|
264
|
-
await e.applyEdits({ addFeatures: [new
|
|
265
|
-
} catch (
|
|
266
|
-
console.error("Error submitting feedback:",
|
|
267
|
+
await e.applyEdits({ addFeatures: [new X({ attributes: a })] });
|
|
268
|
+
} catch (s) {
|
|
269
|
+
console.error("Error submitting feedback:", s);
|
|
267
270
|
}
|
|
268
271
|
this.handleFeedbackSheetClose();
|
|
269
272
|
}, this.handleClose = (e) => {
|
|
@@ -279,17 +282,17 @@ class be extends V {
|
|
|
279
282
|
item: void 0,
|
|
280
283
|
termsAccepted: !1,
|
|
281
284
|
submitting: !1
|
|
282
|
-
}, this.
|
|
285
|
+
}, this.copySuccessConversationId = void 0, this.splashActive = !0, this.editorInsertMode = "add", this.context = void 0, this.historyCards = [], this.helpBase = "", this.assistantsEnabled = !1, this.closed = !1;
|
|
283
286
|
}
|
|
284
287
|
static {
|
|
285
|
-
this.properties = { isViewingResult: 16, confirmationActive: 16, isSubmitting: 16, errorMessage: 16, question: 16, history: 16, feedback: 16,
|
|
288
|
+
this.properties = { isViewingResult: 16, confirmationActive: 16, isSubmitting: 16, errorMessage: 16, question: 16, history: 16, feedback: 16, copySuccessConversationId: 16, splashActive: 16, editorInsertMode: 16, context: 16, historyCards: 16, closePanel: 0, insertText: 0, helpBase: 1, assistantsEnabled: 5, layer: [1, { type: Object }], orgBaseUrl: 1, serviceUrl: 1, closed: 7, editorRef: 0, feedbackServiceUrl: 1, appVersion: 1 };
|
|
286
289
|
}
|
|
287
290
|
static {
|
|
288
|
-
this.styles =
|
|
291
|
+
this.styles = ee;
|
|
289
292
|
}
|
|
290
293
|
get disclaimerComment() {
|
|
291
294
|
return `// ${this.messages.disclaimercomment}
|
|
292
|
-
// ${
|
|
295
|
+
// ${d.disclaimerpt2}`;
|
|
293
296
|
}
|
|
294
297
|
get assistantHelpUrl() {
|
|
295
298
|
return `${this.helpBase ?? "https://doc.arcgis.com/en/arcgis-online/"}administer/configure-assistants.htm`;
|
|
@@ -299,11 +302,74 @@ class be extends V {
|
|
|
299
302
|
}
|
|
300
303
|
async destroy() {
|
|
301
304
|
}
|
|
305
|
+
load() {
|
|
306
|
+
const e = async () => {
|
|
307
|
+
const t = this.getModel();
|
|
308
|
+
if (!t) {
|
|
309
|
+
this.context = void 0;
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
const o = await this.getProfileAndMetadata(t.uri);
|
|
313
|
+
this.context = o;
|
|
314
|
+
};
|
|
315
|
+
e().catch((t) => {
|
|
316
|
+
console.error("Error setting initial context in Arcade Assistant:", t);
|
|
317
|
+
}), this.manager.onLifecycle(() => ({ remove: M.onModelContextDidChange(async () => {
|
|
318
|
+
e().catch((o) => {
|
|
319
|
+
console.error("Error setting context in Arcade Assistant:", o);
|
|
320
|
+
});
|
|
321
|
+
}).dispose }));
|
|
322
|
+
}
|
|
323
|
+
willUpdate(e) {
|
|
324
|
+
e.has("history") && (this.historyCards = this.getHistoryCards());
|
|
325
|
+
}
|
|
302
326
|
connectedCallback() {
|
|
303
|
-
super.connectedCallback(), this.history =
|
|
327
|
+
super.connectedCallback(), this.history = F, this.splashActive = _;
|
|
304
328
|
}
|
|
305
329
|
disconnectedCallback() {
|
|
306
|
-
super.disconnectedCallback(),
|
|
330
|
+
super.disconnectedCallback(), F = this.history, _ = this.splashActive, this.copySuccessTimer && (clearTimeout(this.copySuccessTimer), this.copySuccessTimer = void 0);
|
|
331
|
+
}
|
|
332
|
+
getHistoryCards() {
|
|
333
|
+
return this.history.reduce((e, t) => (!t.script || (e.push({
|
|
334
|
+
priorPrompt: t.question,
|
|
335
|
+
code: t.formattedScript || t.error || "",
|
|
336
|
+
chips: [
|
|
337
|
+
{
|
|
338
|
+
label: t.profile ?? I,
|
|
339
|
+
icon: "map-information",
|
|
340
|
+
appearance: "outline",
|
|
341
|
+
scale: "s",
|
|
342
|
+
conversationId: t.conversationId ?? "",
|
|
343
|
+
tooltip: d.profilecontextlabel.replace("{profileName}", t.profile ?? I)
|
|
344
|
+
},
|
|
345
|
+
...t.layerName ? [
|
|
346
|
+
{
|
|
347
|
+
label: d.numlayers.replace("{numLayers}", "1").replace("{layerOrLayers}", d.numlayerssingular),
|
|
348
|
+
icon: "layer",
|
|
349
|
+
appearance: "outline",
|
|
350
|
+
scale: "s",
|
|
351
|
+
conversationId: t.conversationId ?? "",
|
|
352
|
+
tooltip: d.layercontextlabel.replace("{layerName}", t.layerName ?? "No layer")
|
|
353
|
+
}
|
|
354
|
+
] : []
|
|
355
|
+
],
|
|
356
|
+
onAddToEditor: () => {
|
|
357
|
+
J(this.editorRef.editorInstance, t.formattedScript ?? "", this.editorInsertMode, this.disclaimerComment);
|
|
358
|
+
},
|
|
359
|
+
onCopy: (o) => {
|
|
360
|
+
const a = t.formattedScript ? `${this.disclaimerComment}
|
|
361
|
+
${t.formattedScript}` : "";
|
|
362
|
+
a && navigator.clipboard.writeText(a).then(() => {
|
|
363
|
+
this.copySuccessConversationId = o, this.copySuccessTimer && clearTimeout(this.copySuccessTimer), this.copySuccessTimer = window.setTimeout(() => {
|
|
364
|
+
this.copySuccessConversationId = void 0, this.copySuccessTimer = void 0;
|
|
365
|
+
}, 1500);
|
|
366
|
+
});
|
|
367
|
+
},
|
|
368
|
+
onThumbsUp: () => this.handleFeedbackButton("good", t),
|
|
369
|
+
onThumbsDown: () => this.handleFeedbackButton("bad", t),
|
|
370
|
+
conversationId: t.conversationId ?? "",
|
|
371
|
+
message: t.message
|
|
372
|
+
}), this.isViewingResult), e), []);
|
|
307
373
|
}
|
|
308
374
|
setFeedbackState(e) {
|
|
309
375
|
this.feedback = e;
|
|
@@ -313,9 +379,9 @@ class be extends V {
|
|
|
313
379
|
return this._feedbackService;
|
|
314
380
|
if (!this.feedbackServiceUrl)
|
|
315
381
|
return;
|
|
316
|
-
const e = new
|
|
382
|
+
const e = new K({ url: this.feedbackServiceUrl });
|
|
317
383
|
await e.load();
|
|
318
|
-
const t =
|
|
384
|
+
const t = ve.filter((o) => !e.fields.some((a) => a.name === o));
|
|
319
385
|
if (t.length > 0) {
|
|
320
386
|
console.error(`Missing the following fields in feedback service: ${t.join(", ")}. Feedback will not be logged.`);
|
|
321
387
|
return;
|
|
@@ -332,101 +398,78 @@ class be extends V {
|
|
|
332
398
|
const e = await this.getToken(), t = this.getModel();
|
|
333
399
|
if (!t)
|
|
334
400
|
return;
|
|
335
|
-
const { profileName:
|
|
401
|
+
const { profileName: o, metadata: a, layerName: s } = await this.getProfileAndMetadata(t.uri), c = (await te({
|
|
336
402
|
baseUrl: this.serviceUrl,
|
|
337
|
-
skillId:
|
|
403
|
+
skillId: fe,
|
|
338
404
|
message: this.question,
|
|
339
405
|
authToken: e,
|
|
340
406
|
context: {
|
|
341
|
-
kind:
|
|
407
|
+
kind: be,
|
|
342
408
|
context: {
|
|
343
|
-
profile_name:
|
|
344
|
-
metadata:
|
|
409
|
+
profile_name: o,
|
|
410
|
+
metadata: a
|
|
345
411
|
}
|
|
346
412
|
}
|
|
347
413
|
})).find((n) => n.context?.kind === "ArcadeCodeResponse");
|
|
348
|
-
if (!
|
|
414
|
+
if (!c)
|
|
349
415
|
return;
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
416
|
+
c.context?.kind === "ArcadeCodeResponse" && (this.history = [
|
|
417
|
+
{
|
|
418
|
+
script: c?.context?.arcadeCode?.code,
|
|
419
|
+
formattedScript: Y(c?.context?.arcadeCode?.code ?? ""),
|
|
420
|
+
error: void 0,
|
|
421
|
+
question: this.question,
|
|
422
|
+
profile: o,
|
|
423
|
+
conversationId: c.conversationId,
|
|
424
|
+
layerName: s ?? void 0,
|
|
425
|
+
...c.message ? { message: c.message } : {}
|
|
426
|
+
},
|
|
427
|
+
...this.history
|
|
428
|
+
], this.isViewingResult = !0, this.errorMessage = void 0);
|
|
359
429
|
} catch (e) {
|
|
360
|
-
e instanceof Error && e.name === "ArcadeAssistantError" ? this.errorMessage =
|
|
430
|
+
e instanceof Error && e.name === "ArcadeAssistantError" ? this.errorMessage = oe(e) || this.messages.erroroccurred || "An error occurred." : this.errorMessage = this.messages.erroroccurred || "An error occurred.", console.error("Error in Arcade Assistant:", e);
|
|
361
431
|
} finally {
|
|
362
432
|
this.isSubmitting = !1;
|
|
363
433
|
}
|
|
364
434
|
}
|
|
365
435
|
}
|
|
366
436
|
async getToken() {
|
|
367
|
-
const { token: e } = await
|
|
437
|
+
const { token: e } = await W.getCredential(this.orgBaseUrl);
|
|
368
438
|
return e;
|
|
369
439
|
}
|
|
370
440
|
async getProfileAndMetadata(e) {
|
|
371
|
-
let t =
|
|
372
|
-
const
|
|
373
|
-
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
const
|
|
377
|
-
let
|
|
378
|
-
return
|
|
441
|
+
let t = I;
|
|
442
|
+
const o = M.getEditorProfileForModel(e);
|
|
443
|
+
o?.loaded || await o?.loadSource();
|
|
444
|
+
const a = this.editorRef.profile;
|
|
445
|
+
a && "id" in a && (t = a.id);
|
|
446
|
+
const s = o?.definition?.variables?.find((n) => n.type === "feature");
|
|
447
|
+
let p = [], c;
|
|
448
|
+
return s?.definition && "fields" in s.definition && (p = s.definition.fields.map((n) => ({
|
|
379
449
|
name: n.name,
|
|
380
450
|
type: n.type,
|
|
381
451
|
alias: n.alias
|
|
382
|
-
})),
|
|
452
|
+
})), Z(s?.definition) && (c = s.definition.title)), { profileName: t, metadata: p, layerName: c };
|
|
383
453
|
}
|
|
384
454
|
render() {
|
|
385
|
-
return this.closed ? null : this.assistantsEnabled ?
|
|
455
|
+
return this.closed ? null : this.assistantsEnabled ? C`<calcite-flow><calcite-flow-item closable .heading=${this.messages.arcadeassistant ?? "Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${this.splashActive && C`<calcite-scrim></calcite-scrim>` || ""}${se({ messages: this.messages })}${re({ popoverContent: N({ assistantsEnabled: this.assistantsEnabled, messages: { ...this.messages, ...d }, assistantHelpUrl: this.assistantHelpUrl, helpTopicUrl: this.helpTopicUrl }) })}<calcite-shell class="unstyled-shell">${this.splashActive && he({ messages: { ...d, ...this.messages }, onProceed: () => {
|
|
386
456
|
this.splashActive = !1;
|
|
387
|
-
}, helpTopicUrl: this.helpTopicUrl, onExit: (e) => this.closePanel && this.closePanel(e) }) || ""}${
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
...t.layerName ? [
|
|
401
|
-
{
|
|
402
|
-
label: u.numlayers.replace("{numLayers}", "1").replace("{layerOrLayers}", u.numlayerssingular),
|
|
403
|
-
icon: "layer",
|
|
404
|
-
appearance: "outline",
|
|
405
|
-
scale: "s",
|
|
406
|
-
conversationId: t.conversationId ?? "",
|
|
407
|
-
tooltip: u.layercontextlabel.replace("{layerName}", t.layerName ?? "No layer")
|
|
408
|
-
}
|
|
409
|
-
] : []
|
|
410
|
-
],
|
|
411
|
-
onAddToEditor: () => {
|
|
412
|
-
W(this.editorRef.editorInstance, t.formattedScript ?? "", this.editorInsertMode, this.disclaimerComment);
|
|
413
|
-
},
|
|
414
|
-
onCopy: (s) => {
|
|
415
|
-
const o = t.formattedScript ? `${this.disclaimerComment}
|
|
416
|
-
${t.formattedScript}` : "";
|
|
417
|
-
o && navigator.clipboard.writeText(o).then(() => {
|
|
418
|
-
this.copySuccessIndex = s, this.copySuccessTimer && clearTimeout(this.copySuccessTimer), this.copySuccessTimer = window.setTimeout(() => {
|
|
419
|
-
this.copySuccessIndex = -1, this.copySuccessTimer = void 0;
|
|
420
|
-
}, 1500);
|
|
421
|
-
});
|
|
422
|
-
},
|
|
423
|
-
onThumbsUp: () => this.handleFeedbackButton("good", t),
|
|
424
|
-
onThumbsDown: () => this.handleFeedbackButton("bad", t),
|
|
425
|
-
copySuccessIndex: this.copySuccessIndex
|
|
426
|
-
}), this.isViewingResult), e), []), heading: this.isViewingResult ? this.messages.besteffort ?? "Here's the assistant's best effort" : this.messages.recentprompts ?? "Recent prompts", hidden: this.isViewingResult ? !this.isViewingResult : !1 })}</calcite-block-group>${this.feedback.active ? le({ 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>` : c`<calcite-flow><calcite-flow-item .selected=${!this.isViewingResult} closable .heading=${this.messages.arcadeassistant ?? "Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${M({ slot: "content-top", messages: { ...this.messages, ...u }, assistantsEnabled: this.assistantsEnabled, assistantHelpUrl: this.assistantHelpUrl, helpTopicUrl: this.helpTopicUrl })}</calcite-flow-item></calcite-flow>`;
|
|
457
|
+
}, helpTopicUrl: this.helpTopicUrl, onExit: (e) => this.closePanel && this.closePanel(e) }) || ""}${ce({ active: this.confirmationActive, setActive: (e) => this.confirmationActive = e, messages: this.messages })}${le({ 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: { ...d, ...this.messages }, context: this.context })}<calcite-block-group label="interactive blocks">${!this.isViewingResult && !this.isSubmitting && me({ messages: { ...this.messages, ...d }, 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>${U({
|
|
458
|
+
expanded: this.isViewingResult,
|
|
459
|
+
messages: { ...this.messages, ...d },
|
|
460
|
+
collapsible: !0,
|
|
461
|
+
showEffectsIcon: !0,
|
|
462
|
+
editorInsertMode: this.editorInsertMode,
|
|
463
|
+
setEditorInsertMode: (e) => this.editorInsertMode = e,
|
|
464
|
+
/** Only show the latest history card */
|
|
465
|
+
cards: this.historyCards.length ? [this.historyCards[0]] : [],
|
|
466
|
+
heading: this.messages.besteffort ?? "Here's the assistant's best effort",
|
|
467
|
+
hidden: this.isSubmitting || !this.isViewingResult,
|
|
468
|
+
copySuccessConversationId: this.copySuccessConversationId
|
|
469
|
+
})}${U({ expanded: !this.isViewingResult, messages: { ...this.messages, ...d }, collapsible: !0, editorInsertMode: this.editorInsertMode, setEditorInsertMode: (e) => this.editorInsertMode = e, cards: this.isViewingResult ? this.historyCards.slice(1) : this.historyCards, heading: this.messages.recentprompts ?? "Recent prompts", hidden: this.isSubmitting || this.history.length === 0, copySuccessConversationId: this.copySuccessConversationId })}</calcite-block-group>${this.feedback.active ? ue({ setOpen: this.handleFeedbackSheetClose, messages: { ...this.messages, ...d }, onSubmit: this.handleFeedbackSubmit, feedback: this.feedback, setFeedback: this.setFeedbackState.bind(this) }) : null}</calcite-shell></calcite-flow-item></calcite-flow>` : C`<calcite-flow><calcite-flow-item .selected=${!this.isViewingResult} closable .heading=${this.messages.arcadeassistant ?? "Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${N({ slot: "content-top", messages: { ...this.messages, ...d }, assistantsEnabled: this.assistantsEnabled, assistantHelpUrl: this.assistantHelpUrl, helpTopicUrl: this.helpTopicUrl })}</calcite-flow-item></calcite-flow>`;
|
|
427
470
|
}
|
|
428
471
|
}
|
|
429
|
-
|
|
472
|
+
B("arcgis-arcade-coding-assistant", ye);
|
|
430
473
|
export {
|
|
431
|
-
|
|
474
|
+
ye as ArcgisArcadeCodingAssistant
|
|
432
475
|
};
|