@arcgis/portal-components 5.2.0-next.121 → 5.2.0-next.122

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.
@@ -1,7 +1,7 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
2
  import { c as L } from "../../chunks/runtime.js";
3
3
  import { keyed as _ } from "lit/directives/keyed.js";
4
- import { LitElement as C, createEvent as w, safeClassMap as x, nothing as v } from "@arcgis/lumina";
4
+ import { LitElement as C, createEvent as k, safeClassMap as v, nothing as x } from "@arcgis/lumina";
5
5
  import { html as d, svg as T } from "lit";
6
6
  import { s as M } from "../../chunks/portal-account-switcher.js";
7
7
  import { g as K, a as N, l as E, u as H } from "../../chunks/user.js";
@@ -11,112 +11,113 @@ import { u as W } from "../../chunks/useT9n.js";
11
11
  import { m as B } from "../../chunks/icons.js";
12
12
  import { substitute as m } from "@arcgis/core/intl.js";
13
13
  import { g as R } from "../../chunks/services.js";
14
- const U = 1260 * 1e3;
15
- function I(o, t = "_blank", s = 582, e = 670) {
16
- const n = window.screenLeft ?? 0, i = window.screenTop ?? 0, a = window.innerWidth || document.documentElement.clientWidth || window.screen.width, r = window.innerHeight || document.documentElement.clientHeight || window.screen.height, c = a / 2 - s / 2 + n, u = r / 2 - e / 2 + i, l = window.open(o, t, `scrollbars=no, width=${s}, height=${e}, top=${u}, left=${c}`);
14
+ const U = 1260 * 1e3, J = 2500;
15
+ function I(r, e = "_blank", s = 582, t = 670) {
16
+ const n = window.screenLeft ?? 0, i = window.screenTop ?? 0, a = window.innerWidth || document.documentElement.clientWidth || window.screen.width, o = window.innerHeight || document.documentElement.clientHeight || window.screen.height, c = a / 2 - s / 2 + n, u = o / 2 - t / 2 + i, l = window.open(r, e, `scrollbars=no, width=${s}, height=${t}, top=${u}, left=${c}`);
17
17
  return l?.focus(), l;
18
18
  }
19
- function J(o, t) {
20
- const s = f.findOAuthInfo(o.url), { appId: e, locale: n = "en", expiration: i = U } = s ?? {}, a = new URLSearchParams({
21
- locale: n,
22
- client_id: t ?? e ?? "arcgisonline",
19
+ function D(r) {
20
+ const e = f.findOAuthInfo(r.url), { locale: s = "en", expiration: t = U } = e ?? {}, n = new URLSearchParams({
21
+ locale: s,
22
+ // Linking accounts ALWAYS uses the "arcgisonline" client id
23
+ client_id: "arcgisonline",
23
24
  response_type: "token",
24
- expiration: `${i}`,
25
+ expiration: `${t}`,
25
26
  linkUserRequest: "true",
26
27
  showSocialLogins: "true",
27
28
  hideEnterpriseLogins: "false",
28
29
  force_login: "true",
29
30
  parent: window.location.origin,
30
- redirect_uri: `https://${o.portalHostname}/home/link_account_callback.html`,
31
+ redirect_uri: `https://${r.portalHostname}/home/link_account_callback.html`,
31
32
  state: JSON.stringify({ useMessage: !0 })
32
- }), r = `https://${o.portalHostname}/sharing/oauth2/authorize?${a.toString()}`;
33
- I(r);
33
+ }), i = `https://${r.portalHostname}/sharing/oauth2/authorize?${n.toString()}`;
34
+ I(i);
34
35
  }
35
- function A(o) {
36
+ function A(r) {
36
37
  const {
37
- config: t,
38
+ config: e,
38
39
  token: s,
39
- clientId: e = "arcgisonline",
40
+ clientId: t = "arcgisonline",
40
41
  redirectToClientUri: n = !1,
41
42
  displaySignoutComplete: i = !1
42
- } = o, a = new URLSearchParams({
43
+ } = r, a = new URLSearchParams({
43
44
  display: "iframe",
44
- client_id: e,
45
+ client_id: t,
45
46
  ...s && { token: s },
46
47
  parent: window.location.origin,
47
- redirect_uri: `${t.baseUrl}signout_callback.html`,
48
+ redirect_uri: `${e.baseUrl}signout_callback.html`,
48
49
  state: JSON.stringify({
49
50
  signout: !0,
50
51
  origin: window.location.origin,
51
52
  redirectToClientUri: n,
52
53
  displaySignoutComplete: i
53
54
  })
54
- }), r = `${t.restBaseUrl}oauth2/signout?${a.toString()}`, c = document.createElement("iframe");
55
- c.src = r, c.style.display = "none", document.body.appendChild(c);
55
+ }), o = `${e.restBaseUrl}oauth2/signout?${a.toString()}`, c = document.createElement("iframe");
56
+ c.src = o, c.style.display = "none", document.body.appendChild(c);
56
57
  }
57
- function D(o, t, s) {
58
- const e = g(o.orgUrlKey, t), n = f.findOAuthInfo(e), { appId: i, locale: a = "en", expiration: r = U } = n ?? {}, c = S(o.provider), u = new URLSearchParams({
58
+ function j(r, e, s) {
59
+ const t = g(r.orgUrlKey, e), n = f.findOAuthInfo(t), { appId: i, locale: a = "en", expiration: o = U } = n ?? {}, c = S(r.provider), u = new URLSearchParams({
59
60
  locale: a,
60
61
  client_id: s ?? i ?? "arcgisonline",
61
62
  response_type: "token",
62
- expiration: `${r}`,
63
+ expiration: `${o}`,
63
64
  parent: window.location.origin,
64
- ...c === "social" && { socialLoginProviderName: o.provider },
65
- ...c === "default" && { prepopulatedusername: o.username },
65
+ ...c === "social" && { socialLoginProviderName: r.provider },
66
+ ...c === "default" && { prepopulatedusername: r.username },
66
67
  force_login: "true",
67
- redirect_uri: `${e}/home/sign_in_callback.html`,
68
+ redirect_uri: `${t}/home/sign_in_callback.html`,
68
69
  state: JSON.stringify({
69
- user: o.username,
70
- server: e,
71
- portalUrl: e,
70
+ user: r.username,
71
+ server: t,
72
+ portalUrl: t,
72
73
  origin: window.location.origin
73
74
  })
74
- }), l = `${y(o, t)}?${u.toString()}`;
75
+ }), l = `${y(r, e)}?${u.toString()}`;
75
76
  I(l);
76
77
  }
77
- function j({
78
- accounts: o,
79
- clientId: t = "arcgisonline",
78
+ function q({
79
+ accounts: r,
80
+ clientId: e = "arcgisonline",
80
81
  usersToFilter: s = [],
81
- accountsToFilter: e = ""
82
+ accountsToFilter: t = ""
82
83
  }) {
83
84
  const n = {};
84
- return o.reduce((i, a) => {
85
- const r = {
85
+ return r.reduce((i, a) => {
86
+ const o = {
86
87
  disabled: a.disabled ?? !1,
87
88
  allowed: a.clientAppAccessAllowed ?? !0
88
89
  };
89
- return i[a.username] = r, (s.includes(a.username) || s.includes(a.username.toLowerCase()) || e === "org" && a.orgUrlKey || t === "esriapps" && a.userType !== "both") && (r.allowed = !1), i;
90
+ return i[a.username] = o, (s.includes(a.username) || s.includes(a.username.toLowerCase()) || t === "org" && a.orgUrlKey || e === "esriapps" && a.userType !== "both") && (o.allowed = !1), i;
90
91
  }, n), n;
91
92
  }
92
- function q({
93
- account: o,
94
- credential: t,
93
+ function z({
94
+ account: r,
95
+ credential: e,
95
96
  client_id: s,
96
- portal: e
97
+ portal: t
97
98
  }) {
98
- const n = S(o.provider), i = y(o, e), a = O(o, e), r = new URLSearchParams({
99
+ const n = S(r.provider), i = y(r, t), a = O(r, t), o = new URLSearchParams({
99
100
  client_id: s,
100
101
  redirect_uri: a,
101
102
  parent: window.location.origin,
102
103
  response_type: "token",
103
104
  force_login: "false",
104
- ...t.userId && { prepopulatedusername: t.userId },
105
- ...n === "social" && { socialLoginProviderName: o.provider },
106
- expiration: `${(t?.expires ?? Date.now() + U) - Date.now()}`
105
+ ...e.userId && { prepopulatedusername: e.userId },
106
+ ...n === "social" && { socialLoginProviderName: r.provider },
107
+ expiration: `${(e?.expires ?? Date.now() + U) - Date.now()}`
107
108
  });
108
- return `${i}?${r.toString()}`;
109
+ return `${i}?${o.toString()}`;
109
110
  }
110
- function S(o) {
111
- return z(o) ? "social" : o === "enterprise" ? "enterprise" : o.includes("oidc") ? "oidc" : "default";
111
+ function S(r) {
112
+ return F(r) ? "social" : r === "enterprise" ? "enterprise" : r.includes("oidc") ? "oidc" : "default";
112
113
  }
113
- function z(o) {
114
- return ["apple", "facebook", "github", "google"].includes(o);
114
+ function F(r) {
115
+ return ["apple", "facebook", "github", "google"].includes(r);
115
116
  }
116
- function y(o, t) {
117
- const s = g(o.orgUrlKey, t).toLowerCase(), e = S(o.provider);
117
+ function y(r, e) {
118
+ const s = g(r.orgUrlKey, e).toLowerCase(), t = S(r.provider);
118
119
  let n = "";
119
- switch (e) {
120
+ switch (t) {
120
121
  case "social":
121
122
  n = "social/";
122
123
  break;
@@ -124,42 +125,42 @@ function y(o, t) {
124
125
  n = "saml/";
125
126
  break;
126
127
  case "oidc":
127
- n = `oidc/${o.provider.split("_")[1]}/`;
128
+ n = `oidc/${r.provider.split("_")[1]}/`;
128
129
  break;
129
130
  }
130
131
  return `${s}/sharing/rest/oauth2/${n}authorize`;
131
132
  }
132
- function g(o, t) {
133
- return o?.startsWith("https://") ? o : o && t.customBaseUrl ? `https://${o}.${t.customBaseUrl}` : `https://${t.portalHostname}`;
133
+ function g(r, e) {
134
+ return r?.startsWith("https://") ? r : r && e.customBaseUrl ? `https://${r}.${e.customBaseUrl}` : `https://${e.portalHostname}`;
134
135
  }
135
- function O(o, t) {
136
- return `${g(o.orgUrlKey, t)}/home/accountswitcher-callback.html`;
136
+ function O(r, e) {
137
+ return `${g(r.orgUrlKey, e)}/home/accountswitcher-callback.html`;
137
138
  }
138
- function F(o, t) {
139
- return f.findCredential(g(o.orgUrlKey, t), o.username);
139
+ function G(r, e) {
140
+ return f.findCredential(g(r.orgUrlKey, e), r.username);
140
141
  }
141
- function G(o, t) {
142
- const s = F(o, t);
142
+ function Q(r, e) {
143
+ const s = G(r, e);
143
144
  if (s)
144
145
  return s;
145
- const e = g(o.orgUrlKey, t), n = `${e}/home/check_sign_in_status.html#state=${JSON.stringify({
146
+ const t = g(r.orgUrlKey, e), n = `${t}/home/check_sign_in_status.html#state=${JSON.stringify({
146
147
  origin: window.location.origin,
147
- server: e,
148
- orgKey: e
148
+ server: t,
149
+ orgKey: t
149
150
  })}`;
150
- Q(n, `iframe__for-${e}`);
151
+ V(n, `iframe__for-${t}`);
151
152
  }
152
- function Q(o, t) {
153
+ function V(r, e) {
153
154
  const s = document.createElement("iframe");
154
- s.src = o, s.id = t, s.style.display = "none", document.body.appendChild(s);
155
+ s.src = r, s.id = e, s.style.display = "none", document.body.appendChild(s);
155
156
  }
156
157
  const $ = 100;
157
- class V extends C {
158
+ class X extends C {
158
159
  constructor() {
159
160
  super(), this.messages = W({ blocking: !0 }), this.targetUser = "", this.targetToken = "", this.accountAccess = {}, this.remainingSignouts = 0, this.signoutHandle = 0, this.linkedAccounts = [], this.loading = !1, this.signedInStatus = {}, this.showAssociatedAccountsWarning = !1, this.signedInAccounts = [], this.clientId = "arcgisonline", this.signout = !1, this.signoutOptions = {
160
161
  redirectToClientUri: !1,
161
162
  displaySignoutComplete: !1
162
- }, this.arcgisAccountSwitch = w(), this.arcgisClose = w(), this.arcgisSignoutComplete = w(), this.listenOn(window, "message", this.handleMessageEvent);
163
+ }, this.arcgisAccountSwitch = k(), this.arcgisClose = k(), this.arcgisSignoutComplete = k(), this.listenOn(window, "message", this.handleMessageEvent);
163
164
  }
164
165
  static {
165
166
  this.properties = { linkedAccounts: 16, userAccounts: 16, user: 16, credential: 16, alertOptions: 16, loading: 16, signedInStatus: 16, showAssociatedAccountsWarning: 16, signedInAccounts: 16, portal: 0, clientId: 1, signout: 5, signoutOptions: 0 };
@@ -167,62 +168,62 @@ class V extends C {
167
168
  static {
168
169
  this.styles = M;
169
170
  }
170
- willUpdate(t) {
171
- if (t.has("portal") && (this.user = this.portal?.user), (t.has("portal") || t.has("user")) && this.portal && this.user) {
171
+ willUpdate(e) {
172
+ if (e.has("portal") && (this.user = this.portal?.user), (e.has("portal") || e.has("user")) && this.portal && this.user) {
172
173
  this.findLinkedUsers();
173
174
  return;
174
175
  }
175
- if (t.has("linkedAccounts") || t.has("signedInStatus")) {
176
+ if (e.has("linkedAccounts") || e.has("signedInStatus")) {
176
177
  if (this.signout) {
177
- const { signedInStatus: s, linkedAccounts: e, portal: n, signoutOptions: i, clientId: a } = this, r = Object.keys(s).filter((p) => s[p] !== null).map((p) => e.find((k) => k.username === p));
178
- this.remainingSignouts = r.length + 1;
178
+ const { signedInStatus: s, linkedAccounts: t, portal: n, signoutOptions: i, clientId: a } = this, o = Object.keys(s).filter((p) => s[p] !== null).map((p) => t.find((w) => w.username === p));
179
+ this.remainingSignouts = o.length + 1;
179
180
  const c = g(n.urlKey ?? "", n), u = `${c}/sharing/rest`;
180
181
  let { displaySignoutComplete: l = !0, redirectToClientUri: h = !0 } = i;
181
- r.length > 0 && (l = !1, h = !1), this.loading = !0, A({ displaySignoutComplete: l, redirectToClientUri: h, clientId: a, config: { baseUrl: c, restBaseUrl: u } }), this.signoutHandle = window.setTimeout(() => {
182
+ o.length > 0 && (l = !1, h = !1), this.loading = !0, A({ displaySignoutComplete: l, redirectToClientUri: h, clientId: a, config: { baseUrl: c, restBaseUrl: u } }), this.signoutHandle = window.setTimeout(() => {
182
183
  this.remainingSignouts -= 1, this.finishSignout({ accountOrigin: c, redirectToClientUri: h, displaySignoutComplete: l });
183
- }, 1200);
184
+ }, J);
184
185
  }
185
186
  return;
186
187
  }
187
188
  }
188
- handleMessageEvent(t) {
189
- if (new URL(t.origin).hostname !== "localhost" && (t.origin.endsWith(".arcgis.com") || t.origin === window.location.origin)) {
190
- if (typeof t.data == "string") {
191
- JSON.parse(t.data).type === "token_exchange" && this.handleExchangeTokenMessage(t);
189
+ handleMessageEvent(e) {
190
+ if (new URL(e.origin).hostname !== "localhost" && (e.origin.endsWith(".arcgis.com") || e.origin === window.location.origin)) {
191
+ if (typeof e.data == "string") {
192
+ JSON.parse(e.data).type === "token_exchange" && this.handleExchangeTokenMessage(e);
192
193
  return;
193
194
  }
194
- if ("type" in t.data)
195
- switch (t.data.type) {
195
+ if ("type" in e.data)
196
+ switch (e.data.type) {
196
197
  case "signin":
197
- this.handleSigninMessage(t);
198
+ this.handleSigninMessage(e);
198
199
  return;
199
200
  case "signout":
200
- this.handleSignoutMessage(t);
201
+ this.handleSignoutMessage(e);
201
202
  return;
202
203
  case "linkUser":
203
- this.handleLinkUserMessage(t);
204
+ this.handleLinkUserMessage(e);
204
205
  return;
205
206
  case "token_exchange":
206
- this.handleExchangeTokenMessage(t);
207
+ this.handleExchangeTokenMessage(e);
207
208
  return;
208
209
  }
209
- if ("credential" in t.data) {
210
- this.handleSigninMessage(t);
210
+ if ("credential" in e.data) {
211
+ this.handleSigninMessage(e);
211
212
  return;
212
213
  }
213
- this.handleCheckSignInStatusMessage(t);
214
+ this.handleCheckSignInStatusMessage(e);
214
215
  }
215
216
  }
216
- handleSignoutMessage(t) {
217
- const { error: s, signout: e, accountOrigin: n, redirectToClientUri: i, displaySignoutComplete: a } = t.data;
217
+ handleSignoutMessage(e) {
218
+ const { error: s, signout: t, accountOrigin: n, redirectToClientUri: i, displaySignoutComplete: a } = e.data;
218
219
  if (this.remainingSignouts -= 1, s && s !== "unknown") {
219
220
  console.error(s), this.showAlert("danger", this.messages.errors.signout);
220
221
  return;
221
222
  }
222
- e && (this.user = void 0, this.credential = void 0, this.finishSignout({ accountOrigin: n, redirectToClientUri: i, displaySignoutComplete: a }));
223
+ t && (this.user = void 0, this.credential = void 0, this.finishSignout({ accountOrigin: n, redirectToClientUri: i, displaySignoutComplete: a }));
223
224
  }
224
- handleSigninMessage(t) {
225
- const { messages: s, clientId: e } = this, { error: n, status: i, state: a, access_token: r, ssl: c } = t.data;
225
+ handleSigninMessage(e) {
226
+ const { messages: s, clientId: t } = this, { error: n, status: i, state: a, access_token: o, ssl: c } = e.data;
226
227
  if (n) {
227
228
  console.error(n), this.showAlert("danger", s.errors.signin);
228
229
  return;
@@ -233,123 +234,123 @@ class V extends C {
233
234
  const p = {
234
235
  server: a.portalUrl,
235
236
  userId: a.user,
236
- token: r,
237
- expires: Number(t.data.expires_in) + Date.now(),
237
+ token: o,
238
+ expires: Number(e.data.expires_in) + Date.now(),
238
239
  ssl: c === void 0 || c !== "false"
239
240
  };
240
241
  f.registerToken(p);
241
- const k = q({
242
+ const w = z({
242
243
  account: h,
243
244
  credential: p,
244
245
  // eslint-disable-next-line @typescript-eslint/naming-convention
245
- client_id: e,
246
+ client_id: t,
246
247
  portal: u
247
248
  });
248
- window.self !== window.top ? window.top?.postMessage({ type: "navigate", url: k }) : window.location.href = k;
249
+ window.self !== window.top ? window.top?.postMessage({ type: "navigate", url: w }) : window.location.href = w;
249
250
  }
250
251
  }
251
- handleCheckSignInStatusMessage(t) {
252
- const { success: s, orgKey: e, server: n, userId: i, token: a, expires: r, ssl: c } = t.data;
253
- e && n && s && i && a && r && c !== void 0 && (this.signedInStatus[i] = { token: a, expires: r, ssl: c });
252
+ handleCheckSignInStatusMessage(e) {
253
+ const { success: s, orgKey: t, server: n, userId: i, token: a, expires: o, ssl: c } = e.data;
254
+ t && n && s && i && a && o && c !== void 0 && (this.signedInStatus[i] = { token: a, expires: o, ssl: c });
254
255
  }
255
- async handleLinkUserMessage(t) {
256
- const { error: s, username: e, access_token: n } = t.data, { portal: i, user: a, linkedAccounts: r, messages: c } = this;
256
+ async handleLinkUserMessage(e) {
257
+ const { error: s, username: t, access_token: n } = e.data, { portal: i, user: a, linkedAccounts: o, messages: c } = this;
257
258
  if (s) {
258
259
  if (s.toString().toLowerCase().includes("user denied your request"))
259
260
  return;
260
261
  this.showAlert("danger", c.errors.accessAccount);
261
262
  return;
262
263
  }
263
- if (e === a?.username) {
264
+ if (t === a?.username) {
264
265
  this.showAlert("danger", c.errors.selfLink);
265
266
  return;
266
267
  }
267
- if (r.find((l) => l.username === e)) {
268
- this.showAlert("danger", m(c.errors.alreadyLinked, { username: e }));
268
+ if (o.find((l) => l.username === t)) {
269
+ this.showAlert("danger", m(c.errors.alreadyLinked, { username: t }));
269
270
  return;
270
271
  }
271
- const u = await K(i, e, n);
272
+ const u = await K(i, t, n);
272
273
  if (u?.length) {
273
- this.userAccounts = u, this.targetUser = e ?? "", this.targetToken = n ?? "", this.showAssociatedAccountsWarning = !0;
274
+ this.userAccounts = u, this.targetUser = t ?? "", this.targetToken = n ?? "", this.showAssociatedAccountsWarning = !0;
274
275
  return;
275
276
  }
276
- this.linkAccount(e, n);
277
+ this.linkAccount(t, n);
277
278
  }
278
- handleExchangeTokenMessage(t) {
279
- const s = typeof t.data == "string" ? JSON.parse(t.data) : t.data;
279
+ handleExchangeTokenMessage(e) {
280
+ const s = typeof e.data == "string" ? JSON.parse(e.data) : e.data;
280
281
  if (!(s.type && s.type !== "token_exchange")) {
281
282
  if (s.error)
282
283
  console.error(s);
283
284
  else if (s.status === "success" && this.targetUser) {
284
- const { portal: e, linkedAccounts: n, targetUser: i, clientId: a } = this, r = n.find((p) => p.username === i);
285
- if (!r)
285
+ const { portal: t, linkedAccounts: n, targetUser: i, clientId: a } = this, o = n.find((p) => p.username === i);
286
+ if (!o)
286
287
  return;
287
- const c = O(r, e), u = g(r.orgUrlKey, e), l = new URLSearchParams({
288
+ const c = O(o, t), u = g(o.orgUrlKey, t), l = new URLSearchParams({
288
289
  // eslint-disable-next-line @typescript-eslint/naming-convention
289
290
  response_type: "token",
290
291
  // eslint-disable-next-line @typescript-eslint/naming-convention
291
292
  client_id: a,
292
293
  // eslint-disable-next-line @typescript-eslint/naming-convention
293
294
  redirect_uri: c,
294
- state: JSON.stringify({ user: r.username, portalUrl: u })
295
- }), h = `${y(r, e)}?${l.toString()}`;
295
+ state: JSON.stringify({ user: o.username, portalUrl: u })
296
+ }), h = `${y(o, t)}?${l.toString()}`;
296
297
  window.opener ? (window.opener.location.href = h, window.close()) : window.location.href = h;
297
298
  }
298
299
  }
299
300
  }
300
- finishSignout({ accountOrigin: t, redirectToClientUri: s, displaySignoutComplete: e }) {
301
- this.signoutHandle && window.clearTimeout(this.signoutHandle), console.info("Signout complete", t, s, e), this.remainingSignouts <= 0 && this.arcgisSignoutComplete.emit({ accountOrigin: t, redirectToClientUri: s, displaySignoutComplete: e });
301
+ finishSignout({ accountOrigin: e, redirectToClientUri: s, displaySignoutComplete: t }) {
302
+ this.signoutHandle && window.clearTimeout(this.signoutHandle), e === window.location.origin && f.destroyCredentials(), console.info("Signout complete", e, s, t), this.remainingSignouts <= 0 && this.arcgisSignoutComplete.emit({ accountOrigin: e, redirectToClientUri: s, displaySignoutComplete: t });
302
303
  }
303
304
  async findLinkedUsers() {
304
305
  if (this.loading = !0, !this.portal || !this.user) {
305
306
  this.linkedAccounts = [], this.loading = !1;
306
307
  return;
307
308
  }
308
- this.linkedAccounts = await N(this.portal, this.user), this.linkedAccounts.length && (this.signedInStatus = this.linkedAccounts.filter((t) => t.orgUrlKey !== this.portal.urlKey).reduce((t, s) => (t[s.username] = G(s, this.portal) ?? null, t), {}), this.accountAccess = j({ accounts: this.linkedAccounts, clientId: this.clientId })), this.loading = !1;
309
+ this.linkedAccounts = await N(this.portal, this.user), this.linkedAccounts.length && (this.signedInStatus = this.linkedAccounts.filter((e) => e.orgUrlKey !== this.portal.urlKey).reduce((e, s) => (e[s.username] = Q(s, this.portal) ?? null, e), {}), this.accountAccess = q({ accounts: this.linkedAccounts, clientId: this.clientId })), this.loading = !1;
309
310
  }
310
- async linkAccount(t, s) {
311
- const { portal: e, user: n } = this;
312
- if (!e || !n)
311
+ async linkAccount(e, s) {
312
+ const { portal: t, user: n } = this;
313
+ if (!t || !n)
313
314
  return;
314
- const i = await E({ portal: e, user: n, targetUser: t, targetToken: s }), { messages: a } = this;
315
+ const i = await E({ portal: t, user: n, targetUser: e, targetToken: s }), { messages: a } = this;
315
316
  if (i.error) {
316
- this.showAlert("danger", m(a.errors.linkAccount, { username: t })), this.targetUser = "", this.userAccounts = [];
317
+ this.showAlert("danger", m(a.errors.linkAccount, { username: e })), this.targetUser = "", this.userAccounts = [];
317
318
  return;
318
319
  }
319
- const r = this.userAccounts?.length ? a.success.linkAccountMultiple : a.success.linkAccount;
320
- this.showAlert("success", m(r, { username: t })), this.targetUser = "", this.userAccounts = [], await P(350), this.findLinkedUsers();
320
+ const o = this.userAccounts?.length ? a.success.linkAccountMultiple : a.success.linkAccount;
321
+ this.showAlert("success", m(o, { username: e })), this.targetUser = "", this.userAccounts = [], await P(350), this.findLinkedUsers();
321
322
  }
322
- async unlinkAccount(t) {
323
+ async unlinkAccount(e) {
323
324
  if (!this.portal || !this.user)
324
325
  return;
325
- const { messages: s, portal: e, user: n } = this, { success: i } = await H({ portal: e, user: n, linkedUsername: t.username });
326
- i ? this.showAlert("success", m(s.success.unlinkAccount, { username: t.username })) : this.showAlert("danger", m(s.errors.unlinkAccount, { username: t.username })), await this.findLinkedUsers();
326
+ const { messages: s, portal: t, user: n } = this, { success: i } = await H({ portal: t, user: n, linkedUsername: e.username });
327
+ i ? this.showAlert("success", m(s.success.unlinkAccount, { username: e.username })) : this.showAlert("danger", m(s.errors.unlinkAccount, { username: e.username })), await this.findLinkedUsers();
327
328
  }
328
329
  startAccountLink() {
329
- J(this.portal, this.clientId);
330
+ D(this.portal);
330
331
  }
331
- switchAccount(t) {
332
- const { portal: s, user: e, clientId: n } = this;
333
- if (!s || !e || !t)
332
+ switchAccount(e) {
333
+ const { portal: s, user: t, clientId: n } = this;
334
+ if (!s || !t || !e)
334
335
  return;
335
- const i = g(e.sourceJSON.orgUrlKey ?? "", s), a = f.findCredential(i, e.id || e.username);
336
- a && A({ config: { baseUrl: i, restBaseUrl: `${i}/sharing/rest` }, token: a?.token, clientId: n }), D(t, s, n);
336
+ const i = g(t.sourceJSON.orgUrlKey ?? "", s), a = f.findCredential(i, t.id || t.username);
337
+ a && A({ config: { baseUrl: i, restBaseUrl: `${i}/sharing/rest` }, token: a?.token, clientId: n }), j(e, s, n);
337
338
  }
338
- signoutAll(t) {
339
- const { portal: s, signedInStatus: e, clientId: n } = this;
340
- t.forEach((i) => {
341
- const a = g(i.orgUrlKey, s), r = `${a}/sharing/rest`, c = e[i.username];
342
- A({ config: { baseUrl: a, restBaseUrl: r }, token: c?.token, clientId: n });
339
+ signoutAll(e) {
340
+ const { portal: s, signedInStatus: t, clientId: n } = this;
341
+ e.forEach((i) => {
342
+ const a = g(i.orgUrlKey, s), o = `${a}/sharing/rest`, c = t[i.username];
343
+ A({ config: { baseUrl: a, restBaseUrl: o }, token: c?.token, clientId: n });
343
344
  });
344
345
  }
345
- showAlert(t, s, e) {
346
+ showAlert(e, s, t) {
346
347
  this.alertOptions = {
347
- kind: t,
348
- title: e,
348
+ kind: e,
349
+ title: t,
349
350
  message: s
350
351
  };
351
352
  }
352
- showUnlinkConfirmation(t) {
353
+ showUnlinkConfirmation(e) {
353
354
  const { messages: s } = this;
354
355
  this.alertOptions = {
355
356
  kind: "danger",
@@ -361,40 +362,40 @@ class V extends C {
361
362
  text: s.unlink,
362
363
  kind: "danger",
363
364
  clickHandler: () => {
364
- this.alertOptions = void 0, this.unlinkAccount(t);
365
+ this.alertOptions = void 0, this.unlinkAccount(e);
365
366
  }
366
367
  }
367
368
  ]
368
369
  };
369
370
  }
370
371
  render() {
371
- const { linkedAccounts: t, accountAccess: s, user: e, portal: n, messages: i, signout: a } = this;
372
- if (!n || !e)
372
+ const { linkedAccounts: e, accountAccess: s, user: t, portal: n, messages: i, signout: a } = this;
373
+ if (!n || !t)
373
374
  return null;
374
375
  if (a) {
375
- const { signedInAccounts: r } = this;
376
- return r.length === 0 ? d`<calcite-loader .label=${i.signingOut} .text=${i.signingOut}></calcite-loader>` : d`<arcgis-portal-account-switcher-signout .portal=${n} .signedInAccounts=${r} @arcgisSwitchAccount=${(c) => {
376
+ const { signedInAccounts: o } = this;
377
+ return o.length === 0 ? d`<calcite-loader .label=${i.signingOut} .text=${i.signingOut}></calcite-loader>` : d`<arcgis-portal-account-switcher-signout .portal=${n} .signedInAccounts=${o} @arcgisSwitchAccount=${(c) => {
377
378
  this.switchAccount(c.detail.account);
378
379
  }} @arcgisSignOutAll=${() => {
379
- this.signoutAll(r);
380
+ this.signoutAll(o);
380
381
  }}></arcgis-portal-account-switcher-signout>`;
381
382
  }
382
- return d`<calcite-dialog .heading=${i.switchAccounts} scale=m width=s open modal .loading=${this.loading} outside-close-disabled @calciteDialogClose=${() => {
383
+ return d`<calcite-dialog .heading=${i.switchAccounts} heading-level=2 scale=m width=s open modal .loading=${this.loading} outside-close-disabled @calciteDialogClose=${() => {
383
384
  this.arcgisClose.emit();
384
- }}><calcite-block .heading=${i.currentAccount} .description=${i.signedInAs} expanded class="current-account-block" tabindex=-1>${_(e.id ?? e.username, d`<calcite-block class="current-account" .label=${n.urlKey ? `${e.username}, ${n.name}` : e.username} heading-level=4 .heading=${e.username} .description=${n.urlKey ? `${e.fullName ?? e.username}, ${n.name}` : e.fullName ?? e.username}><calcite-avatar slot=content-start inert .fullName=${e.fullName ?? void 0} .username=${e.username} .userId=${e.id} .thumbnail=${R(e, n) ?? void 0}></calcite-avatar></calcite-block>`)}</calcite-block>${t.length > 0 ? d`<calcite-block .heading=${i.linkedAccounts} .description=${i.linkedAccountActions} expanded class="linked-accounts-block"><calcite-button slot=content-end icon-start=plus class="link-account-button" @click=${() => this.startAccountLink()} .disabled=${t.length >= $}>${i.addAccount}</calcite-button><arcgis-portal-account-switcher-list .portal=${n} .linkedAccounts=${t} .accountAccess=${s} .signedInUsers=${Object.keys(this.signedInStatus).filter((r) => this.signedInStatus[r] !== null)} interactive @arcgisAccountSwitch=${(r) => {
385
- this.switchAccount(r.detail.account);
386
- }} @arcgisAccountUnlink=${(r) => {
387
- this.showUnlinkConfirmation(r.detail.account);
388
- }}></arcgis-portal-account-switcher-list></calcite-block>` : d`<calcite-block .heading=${i.linkedAccounts} expanded class="empty-accounts-block"><div class="empty-accounts-info"><svg class="empty-accounts-icon" width=48 height=48 viewBox="0 0 48 48" fill=none xmlns=http://www.w3.org/2000/svg>${T`<path d=${B.couple ?? v} fill=currentColor />`}</svg><h4>${i.emptyListTitle}</h4><p>${i.emptyList}</p><calcite-button icon-start=plus class="link-account-button" @click=${() => this.startAccountLink()} .disabled=${t.length >= $}>${i.linkAccount}</calcite-button></div></calcite-block>`}<calcite-notice kind=info .open=${t.length >= $}><div slot=message>${i.maxAccounts}</div></calcite-notice><calcite-alert .label=${i.alertLabel} slot=alerts .autoClose=${this.alertOptions?.kind !== "danger"} auto-close-duration=fast placement=bottom .kind=${this.alertOptions?.kind} .icon=${this.alertOptions?.icon} .open=${!!this.alertOptions} @calciteAlertClose=${() => {
385
+ }}><calcite-block .heading=${i.currentAccount} heading-level=3 .description=${i.signedInAs} expanded class="current-account-block" tabindex=-1>${_(t.id ?? t.username, d`<calcite-block class="current-account" .label=${n.urlKey ? `${t.username}, ${n.name}` : t.username} heading-level=4 .heading=${t.username} .description=${n.urlKey ? `${t.fullName ?? t.username}, ${n.name}` : t.fullName ?? t.username}><calcite-avatar slot=content-start inert .fullName=${t.fullName ?? void 0} .username=${t.username} .userId=${t.id} .thumbnail=${R(t, n) ?? void 0}></calcite-avatar></calcite-block>`)}</calcite-block>${e.length > 0 ? d`<calcite-block .heading=${i.linkedAccounts} heading-level=3 .description=${i.linkedAccountActions} expanded class="linked-accounts-block"><calcite-button slot=content-end icon-start=plus class="link-account-button" @click=${() => this.startAccountLink()} .disabled=${e.length >= $}>${i.addAccount}</calcite-button><arcgis-portal-account-switcher-list .portal=${n} .linkedAccounts=${e} .accountAccess=${s} .signedInUsers=${Object.keys(this.signedInStatus).filter((o) => this.signedInStatus[o] !== null)} interactive @arcgisAccountSwitch=${(o) => {
386
+ this.switchAccount(o.detail.account);
387
+ }} @arcgisAccountUnlink=${(o) => {
388
+ this.showUnlinkConfirmation(o.detail.account);
389
+ }}></arcgis-portal-account-switcher-list></calcite-block>` : d`<calcite-block .heading=${i.linkedAccounts} heading-level=3 expanded class="empty-accounts-block"><div class="empty-accounts-info"><svg class="empty-accounts-icon" width=48 height=48 viewBox="0 0 48 48" fill=none xmlns=http://www.w3.org/2000/svg>${T`<path d=${B.couple ?? x} fill=currentColor />`}</svg><h4>${i.emptyListTitle}</h4><p>${i.emptyList}</p><calcite-button icon-start=plus class="link-account-button" @click=${() => this.startAccountLink()} .disabled=${e.length >= $}>${i.linkAccount}</calcite-button></div></calcite-block>`}<calcite-notice kind=info .open=${e.length >= $}><div slot=message>${i.maxAccounts}</div></calcite-notice><calcite-alert .label=${i.alertLabel} slot=alerts .autoClose=${this.alertOptions?.kind !== "danger"} auto-close-duration=fast placement=bottom .kind=${this.alertOptions?.kind} .icon=${this.alertOptions?.icon} .open=${!!this.alertOptions} @calciteAlertClose=${() => {
389
390
  this.alertOptions = void 0;
390
- }}>${this.alertOptions?.title && d`<h4 slot=title class="alert-title">${this.alertOptions.title}</h4>` || ""}${this.alertOptions?.message && d`<p slot=message class=${x({ "alert-message": !0, "short-message": !!this.alertOptions?.actions?.length })}>${this.alertOptions.message}</p>` || ""}${this.alertOptions?.actions?.map((r) => d`<calcite-button slot=actions-end .kind=${r.kind} .appearance=${r.appearance} @click=${r.clickHandler}>${r.text}</calcite-button>`)}</calcite-alert></calcite-dialog>${this.showAssociatedAccountsWarning && d`<arcgis-portal-account-switcher-accounts .portal=${n} .targetUser=${this.targetUser} .accounts=${this.userAccounts ?? []} @arcgisLinkAll=${() => {
391
+ }}>${this.alertOptions?.title && d`<h4 slot=title class="alert-title">${this.alertOptions.title}</h4>` || ""}${this.alertOptions?.message && d`<p slot=message class=${v({ "alert-message": !0, "short-message": !!this.alertOptions?.actions?.length })}>${this.alertOptions.message}</p>` || ""}${this.alertOptions?.actions?.map((o) => d`<calcite-button slot=actions-end .kind=${o.kind} .appearance=${o.appearance} @click=${o.clickHandler}>${o.text}</calcite-button>`)}</calcite-alert></calcite-dialog>${this.showAssociatedAccountsWarning && d`<arcgis-portal-account-switcher-accounts .portal=${n} .targetUser=${this.targetUser} .accounts=${this.userAccounts ?? []} @arcgisLinkAll=${() => {
391
392
  this.linkAccount(this.targetUser, this.targetToken);
392
393
  }} @arcgisCloseDialog=${() => {
393
394
  this.showAssociatedAccountsWarning = !1;
394
395
  }}></arcgis-portal-account-switcher-accounts>` || ""}`;
395
396
  }
396
397
  }
397
- L("arcgis-portal-account-switcher", V);
398
+ L("arcgis-portal-account-switcher", X);
398
399
  export {
399
- V as ArcgisPortalAccountSwitcher
400
+ X as ArcgisPortalAccountSwitcher
400
401
  };
@@ -1,12 +1,12 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import { c as o } from "../../chunks/runtime.js";
3
- import { html as a } from "lit";
2
+ import { c as a } from "../../chunks/runtime.js";
3
+ import { html as o } from "lit";
4
4
  import { LitElement as l, createEvent as e } from "@arcgis/lumina";
5
5
  import { createRef as r, ref as n } from "lit/directives/ref.js";
6
6
  import { u } from "../../chunks/useT9n.js";
7
7
  import { s as g } from "../../chunks/portal-account-switcher.js";
8
8
  import { substitute as m } from "@arcgis/core/intl.js";
9
- class p extends l {
9
+ class d extends l {
10
10
  constructor() {
11
11
  super(...arguments), this.messages = u({ blocking: !0, name: "portal-account-switcher" }), this.dialogRef = r(), this.accounts = [], this.arcgisLinkAll = e(), this.arcgisCloseDialog = e();
12
12
  }
@@ -18,14 +18,14 @@ class p extends l {
18
18
  }
19
19
  render() {
20
20
  const { messages: t, portal: i, accounts: c, targetUser: s } = this;
21
- return a`<calcite-dialog open modal width=s .heading=${t.linkTitle} outside-close-disabled @calciteDialogClose=${() => this.arcgisCloseDialog.emit()} ${n(this.dialogRef)}><calcite-block .heading=${m(t.linkWarning, { targetUser: s })} expanded class="linked-accounts-block"><arcgis-portal-account-switcher-list .portal=${i} .linkedAccounts=${c}></arcgis-portal-account-switcher-list></calcite-block><calcite-button slot=footer-end appearance=outline @click=${() => {
21
+ return o`<calcite-dialog open modal width=s .heading=${t.linkTitle} heading-level=2 outside-close-disabled @calciteDialogClose=${() => this.arcgisCloseDialog.emit()} ${n(this.dialogRef)}><calcite-block .heading=${m(t.linkWarning, { targetUser: s })} expanded class="linked-accounts-block"><arcgis-portal-account-switcher-list .portal=${i} .linkedAccounts=${c}></arcgis-portal-account-switcher-list></calcite-block><calcite-button slot=footer-end appearance=outline @click=${() => {
22
22
  this.dialogRef.value.open = !1;
23
23
  }}>${t.cancel}</calcite-button><calcite-button slot=footer-end kind=brand @click=${() => {
24
24
  this.arcgisLinkAll.emit(), this.dialogRef.value.open = !1;
25
25
  }}>${t.linkAll}</calcite-button></calcite-dialog>`;
26
26
  }
27
27
  }
28
- o("arcgis-portal-account-switcher-accounts", p);
28
+ a("arcgis-portal-account-switcher-accounts", d);
29
29
  export {
30
- p as ArcgisPortalAccountSwitcherAccounts
30
+ d as ArcgisPortalAccountSwitcherAccounts
31
31
  };
@@ -2,13 +2,13 @@ import "@esri/calcite-components/components/calcite-chip";
2
2
  import "@esri/calcite-components/components/calcite-tooltip";
3
3
  import "@esri/calcite-components/components/calcite-list-item";
4
4
  import "@esri/calcite-components/components/calcite-action";
5
+ import "@esri/calcite-components/components/calcite-dropdown-item";
5
6
  import "@esri/calcite-components/components/calcite-icon";
6
7
  import "@esri/calcite-components/components/calcite-popover";
7
8
  import "@esri/calcite-components/components/calcite-list";
8
9
  import "../arcgis-portal-item-type/index.js";
9
10
  import "@esri/calcite-components/components/calcite-loader";
10
11
  import "@esri/calcite-components/components/calcite-button";
11
- import "@esri/calcite-components/components/calcite-dropdown-item";
12
12
  import "@esri/calcite-components/components/calcite-input";
13
13
  import "@esri/calcite-components/components/calcite-dropdown";
14
14
  import "../arcgis-portal-user-avatar/index.js";