@esri/solutions-components 0.6.36 → 0.6.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/cjs/basemap-gallery_7.cjs.entry.js +16 -0
  2. package/dist/cjs/calcite-alert_3.cjs.entry.js +2 -13
  3. package/dist/cjs/calcite-combobox_6.cjs.entry.js +1 -1
  4. package/dist/cjs/calcite-shell-panel_14.cjs.entry.js +2 -2
  5. package/dist/cjs/card-manager_3.cjs.entry.js +4 -3
  6. package/dist/cjs/{downloadUtils-37d9aaf3.js → downloadUtils-d8e48fbd.js} +55 -12
  7. package/dist/cjs/{index.es-d1d9b140.js → index.es-6159eedc.js} +4 -3
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/cjs/map-select-tools_3.cjs.entry.js +4 -3
  10. package/dist/cjs/{mapViewUtils-96172223.js → mapViewUtils-f7bbc35b.js} +5 -2
  11. package/dist/cjs/public-notification.cjs.entry.js +6 -5
  12. package/dist/cjs/{clean-url-d5326abb.js → restHelpersGet-c94617cf.js} +398 -0
  13. package/dist/cjs/solution-configuration.cjs.entry.js +565 -565
  14. package/dist/cjs/solution-contents_3.cjs.entry.js +2 -2
  15. package/dist/cjs/{solution-store-714601a2.js → solution-store-b40c2f46.js} +19 -383
  16. package/dist/cjs/solutions-components.cjs.js +1 -1
  17. package/dist/collection/components/basemap-gallery/basemap-gallery.js +8 -0
  18. package/dist/collection/components/edit-card/edit-card.js +1 -12
  19. package/dist/collection/components/map-legend/map-legend.js +9 -1
  20. package/dist/collection/components/public-notification/public-notification.js +7 -6
  21. package/dist/collection/utils/downloadUtils.js +50 -8
  22. package/dist/collection/utils/downloadUtils.ts +62 -9
  23. package/dist/collection/utils/queryUtils.js +5 -2
  24. package/dist/collection/utils/queryUtils.ts +4 -2
  25. package/dist/components/basemap-gallery2.js +8 -0
  26. package/dist/components/downloadUtils.js +51 -8
  27. package/dist/components/edit-card2.js +1 -12
  28. package/dist/components/map-legend2.js +8 -0
  29. package/dist/components/public-notification.js +3 -3
  30. package/dist/components/queryUtils.js +5 -2
  31. package/dist/components/{clean-url.js → restHelpersGet.js} +392 -1
  32. package/dist/components/solution-configuration.js +552 -552
  33. package/dist/components/solution-store.js +2 -365
  34. package/dist/esm/basemap-gallery_7.entry.js +16 -0
  35. package/dist/esm/calcite-alert_3.entry.js +2 -13
  36. package/dist/esm/calcite-combobox_6.entry.js +1 -1
  37. package/dist/esm/calcite-shell-panel_14.entry.js +2 -2
  38. package/dist/esm/card-manager_3.entry.js +4 -3
  39. package/dist/esm/{downloadUtils-76379e4a.js → downloadUtils-d41ecba9.js} +53 -10
  40. package/dist/esm/{index.es-0d134a52.js → index.es-b226bf47.js} +4 -3
  41. package/dist/esm/loader.js +1 -1
  42. package/dist/esm/map-select-tools_3.entry.js +4 -3
  43. package/dist/esm/{mapViewUtils-08f6cfce.js → mapViewUtils-1e2befd7.js} +5 -2
  44. package/dist/esm/public-notification.entry.js +6 -5
  45. package/dist/esm/{clean-url-bce022e6.js → restHelpersGet-a5ec2192.js} +392 -1
  46. package/dist/esm/solution-configuration.entry.js +552 -552
  47. package/dist/esm/solution-contents_3.entry.js +2 -2
  48. package/dist/esm/{solution-store-3ee6c7a3.js → solution-store-17bb0a75.js} +2 -365
  49. package/dist/esm/solutions-components.js +1 -1
  50. package/dist/solutions-components/{p-9800e602.entry.js → p-091120c5.entry.js} +1 -1
  51. package/dist/solutions-components/p-1b14b687.entry.js +6 -0
  52. package/dist/solutions-components/p-20e627ed.entry.js +6 -0
  53. package/dist/solutions-components/{p-646e983f.entry.js → p-2d143359.entry.js} +1 -1
  54. package/dist/solutions-components/{p-ac7332b3.entry.js → p-40e95e2b.entry.js} +1 -1
  55. package/dist/solutions-components/p-420e1585.entry.js +36 -0
  56. package/dist/solutions-components/p-4807b2a1.js +36 -0
  57. package/dist/solutions-components/p-56a3b81e.entry.js +6 -0
  58. package/dist/solutions-components/p-5856dc4f.js +66 -0
  59. package/dist/solutions-components/p-89b4b401.js +145 -0
  60. package/dist/solutions-components/{p-0f50087e.entry.js → p-973625f8.entry.js} +2 -2
  61. package/dist/solutions-components/{p-03130804.js → p-9ecb5d66.js} +1 -1
  62. package/dist/solutions-components/{p-b02eb8f4.js → p-a8661f1f.js} +30 -30
  63. package/dist/solutions-components/p-fbc7fc26.entry.js +6 -0
  64. package/dist/solutions-components/solutions-components.esm.js +1 -1
  65. package/dist/solutions-components/utils/downloadUtils.ts +62 -9
  66. package/dist/solutions-components/utils/queryUtils.ts +4 -2
  67. package/dist/types/components/basemap-gallery/basemap-gallery.d.ts +4 -0
  68. package/dist/types/components/map-legend/map-legend.d.ts +4 -0
  69. package/dist/types/components/public-notification/public-notification.d.ts +1 -1
  70. package/dist/types/components.d.ts +2 -2
  71. package/package.json +1 -1
  72. package/dist/esm/polyfills/core-js.js +0 -11
  73. package/dist/esm/polyfills/dom.js +0 -79
  74. package/dist/esm/polyfills/es5-html-element.js +0 -1
  75. package/dist/esm/polyfills/index.js +0 -34
  76. package/dist/esm/polyfills/system.js +0 -6
  77. package/dist/solutions-components/p-13b21d19.entry.js +0 -36
  78. package/dist/solutions-components/p-15070568.js +0 -36
  79. package/dist/solutions-components/p-1682bd0f.entry.js +0 -6
  80. package/dist/solutions-components/p-7b61f856.entry.js +0 -6
  81. package/dist/solutions-components/p-81a0c88f.entry.js +0 -6
  82. package/dist/solutions-components/p-d0544f24.js +0 -192
  83. package/dist/solutions-components/p-eba875d9.entry.js +0 -6
  84. package/dist/solutions-components/p-ecc95259.js +0 -20
@@ -4,8 +4,9 @@
4
4
  * http://www.apache.org/licenses/LICENSE-2.0
5
5
  */
6
6
  import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
7
- import { g as getProp, s as state } from './solution-store.js';
7
+ import { s as state } from './solution-store.js';
8
8
  import './solution-resource.js';
9
+ import { r as request, N as NODEJS_DEFAULT_REFERER_HEADER, c as cleanUrl, e as encodeQueryString, A as ArcGISAuthError, a as getProp } from './restHelpersGet.js';
9
10
  import { g as getLocaleComponentStrings } from './locale.js';
10
11
  import { d as defineCustomElement$C } from './action.js';
11
12
  import { d as defineCustomElement$B } from './action-group.js';
@@ -44,7 +45,6 @@ import { d as defineCustomElement$5 } from './solution-spatial-ref2.js';
44
45
  import { d as defineCustomElement$4 } from './solution-template-data2.js';
45
46
  import { d as defineCustomElement$3 } from './solution-variables2.js';
46
47
  import { d as defineCustomElement$2 } from './spatial-ref2.js';
47
- import { r as request, N as NODEJS_DEFAULT_REFERER_HEADER, c as cleanUrl, e as encodeQueryString, A as ArcGISAuthError } from './clean-url.js';
48
48
 
49
49
  /* Copyright (c) 2017-2020 Environmental Systems Research Institute, Inc.
50
50
  * Apache-2.0 */
@@ -69,576 +69,234 @@ function decodeQueryString(query) {
69
69
  }, {});
70
70
  }
71
71
 
72
- /** @license
73
- * Copyright 2022 Esri
74
- *
75
- * Licensed under the Apache License, Version 2.0 (the "License");
76
- * you may not use this file except in compliance with the License.
77
- * You may obtain a copy of the License at
78
- *
79
- * http://www.apache.org/licenses/LICENSE-2.0
80
- *
81
- * Unless required by applicable law or agreed to in writing, software
82
- * distributed under the License is distributed on an "AS IS" BASIS,
83
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
84
- * See the License for the specific language governing permissions and
85
- * limitations under the License.
86
- */
87
- //--------------------------------------------------------------------------
88
- //
89
- // Public Functions
90
- //
91
- //--------------------------------------------------------------------------
92
- /**
93
- * Sort the solution items
94
- *
95
- * @param templates a list of item templates from the solution
96
- *
97
- * @returns a sorted list of solution items
98
- */
99
- function getInventoryItems(templates) {
100
- const hierarchy = getItemHierarchy(templates);
101
- const ids = hierarchy.reduce((prev, cur) => {
102
- prev.push(cur.id);
103
- return prev;
104
- }, []);
105
- return templates.reduce((prev, cur) => {
106
- if (ids.indexOf(cur.itemId) > -1) {
107
- const hierarchyItems = hierarchy.filter(hi => hi.id === cur.itemId);
108
- prev.push(_getItemFromTemplate(cur, templates, hierarchyItems[0].dependencies));
109
- }
110
- return prev;
111
- }, []);
72
+ /*! *****************************************************************************
73
+ Copyright (c) Microsoft Corporation.
74
+
75
+ Permission to use, copy, modify, and/or distribute this software for any
76
+ purpose with or without fee is hereby granted.
77
+
78
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
79
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
80
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
81
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
82
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
83
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
84
+ PERFORMANCE OF THIS SOFTWARE.
85
+ ***************************************************************************** */
86
+
87
+ var __assign = function() {
88
+ __assign = Object.assign || function __assign(t) {
89
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
90
+ s = arguments[i];
91
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
92
+ }
93
+ return t;
94
+ };
95
+ return __assign.apply(this, arguments);
96
+ };
97
+
98
+ /* Copyright (c) 2017 Environmental Systems Research Institute, Inc.
99
+ * Apache-2.0 */
100
+ function fetchToken(url, requestOptions) {
101
+ var options = requestOptions;
102
+ // we generate a response, so we can't return the raw response
103
+ options.rawResponse = false;
104
+ return request(url, options).then(function (response) {
105
+ var r = {
106
+ token: response.access_token,
107
+ username: response.username,
108
+ expires: new Date(
109
+ // convert seconds in response to milliseconds and add the value to the current time to calculate a static expiration timestamp
110
+ Date.now() + (response.expires_in * 1000 - 1000)),
111
+ ssl: response.ssl === true
112
+ };
113
+ if (response.refresh_token) {
114
+ r.refreshToken = response.refresh_token;
115
+ }
116
+ return r;
117
+ });
112
118
  }
113
- /**
114
- * Create item hierarchy that will avoid issues from cylical dependencies
115
- *
116
- * @param templates a list of item templates from the solution
117
- *
118
- * @returns a hierarchy for item and item dependency display
119
- */
120
- function getItemHierarchy(templates) {
121
- const hierarchy = [];
122
- // Get the template specified by id out of a list of templates
123
- function getTemplateInSolution(templates, id) {
124
- const iTemplate = templates.findIndex((template) => id === template.itemId);
125
- return iTemplate >= 0 ? templates[iTemplate] : null;
126
- }
127
- // Hierarchically list the dependencies of specified node
128
- function traceItemId(id, accumulatedHierarchy, alreadyVisitedIds = []) {
129
- // Get the dependencies of the node
130
- const template = getTemplateInSolution(templates, id);
119
+
120
+ /* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.
121
+ * Apache-2.0 */
122
+ function generateToken(url, requestOptions) {
123
+ var options = requestOptions;
131
124
  /* istanbul ignore else */
132
- if (template) {
133
- const templateEntry = {
134
- id,
135
- dependencies: []
136
- };
137
- // Visit each dependency, but only if this template is not in the alreadyVisitedIds list to avoid infinite loops
138
- /* istanbul ignore else */
139
- if (alreadyVisitedIds.indexOf(id) < 0) {
140
- // Add dependency to alreadyVisitedIds list
141
- alreadyVisitedIds.push(id);
142
- template.dependencies.forEach((dependencyId) => {
143
- // Remove dependency from list of templates to visit in the top-level loop
144
- const iDependencyTemplate = templateItemIds.indexOf(dependencyId);
145
- /* istanbul ignore else */
146
- if (iDependencyTemplate >= 0) {
147
- templateItemIds.splice(iDependencyTemplate, 1);
148
- }
149
- traceItemId(dependencyId, templateEntry.dependencies, alreadyVisitedIds);
150
- });
151
- }
152
- accumulatedHierarchy.push(templateEntry);
125
+ if (typeof window !== "undefined" &&
126
+ window.location &&
127
+ window.location.host) {
128
+ options.params.referer = window.location.host;
153
129
  }
154
- }
155
- // Start with top-level nodes and add in the rest of the nodes to catch cycles without top-level nodes
156
- let templateItemIds = _getTopLevelItemIds(templates);
157
- const otherItems = templates
158
- .filter((template) => templateItemIds.indexOf(template.itemId) < 0) // only keep non-top-level nodes
159
- .sort((a, b) => b.dependencies.length - a.dependencies.length); // sort so that nodes with more dependencies come first--reduces stubs
160
- templateItemIds = templateItemIds.concat(otherItems.map((template) => template.itemId));
161
- // Step through the list of nodes; we'll also remove nodes as we visit them
162
- let itemId = templateItemIds.shift();
163
- while (typeof itemId !== "undefined") {
164
- traceItemId(itemId, hierarchy);
165
- itemId = templateItemIds.shift();
166
- }
167
- return hierarchy;
130
+ else {
131
+ options.params.referer = NODEJS_DEFAULT_REFERER_HEADER;
132
+ }
133
+ return request(url, options);
168
134
  }
135
+
169
136
  /**
170
- * Explore the solution item templates for variables we will allow users to insert at runtime
171
- *
172
- * @param templates a list of item templates from the solution
173
- * @param translations nls translation object
174
- *
175
- * @returns a list of variables from the solution item templates
137
+ * Used to test if a URL is an ArcGIS Online URL
176
138
  */
177
- function getSolutionVariables(templates, translations) {
178
- const vars = [];
179
- templates.forEach(t => {
180
- const item = {
181
- id: t.itemId,
182
- title: t.item.title || t.item.name,
183
- type: t.type,
184
- value: undefined,
185
- dependencies: [{
186
- id: t.itemId,
187
- title: translations.itemId,
188
- value: `{{${t.itemId}.itemId}}`,
189
- }]
190
- };
191
- if (t.item.url) {
192
- item.dependencies.push({
193
- id: t.itemId,
194
- title: translations.url,
195
- value: `{{${t.itemId}.url}}`,
196
- });
139
+ var arcgisOnlineUrlRegex = /^https?:\/\/(\S+)\.arcgis\.com.+/;
140
+ function isOnline(url) {
141
+ return arcgisOnlineUrlRegex.test(url);
142
+ }
143
+ function normalizeOnlinePortalUrl(portalUrl) {
144
+ if (!arcgisOnlineUrlRegex.test(portalUrl)) {
145
+ return portalUrl;
197
146
  }
198
- if (t.type === "Feature Service") {
199
- // TODO need to set source service name var...
200
- // TODO need to set soure service shape field name "{{d05b3cf1ffcb4a4fa677627dfb18609e.name}}.Shape"
201
- item.dependencies.push({
202
- id: t.itemId,
203
- title: translations.solutionExtent,
204
- value: `{{${t.itemId}.solutionExtent}}`,
205
- });
206
- _addLayersOrTables(t.properties.layers || [], item, t, translations);
207
- _addLayersOrTables(t.properties.tables || [], item, t, translations);
147
+ switch (getOnlineEnvironment(portalUrl)) {
148
+ case "dev":
149
+ return "https://devext.arcgis.com/sharing/rest";
150
+ case "qa":
151
+ return "https://qaext.arcgis.com/sharing/rest";
152
+ default:
153
+ return "https://www.arcgis.com/sharing/rest";
208
154
  }
209
- vars.push(item);
210
- });
211
- return vars;
212
155
  }
156
+ function getOnlineEnvironment(url) {
157
+ if (!arcgisOnlineUrlRegex.test(url)) {
158
+ return null;
159
+ }
160
+ var match = url.match(arcgisOnlineUrlRegex);
161
+ var subdomain = match[1].split(".").pop();
162
+ if (subdomain.includes("dev")) {
163
+ return "dev";
164
+ }
165
+ if (subdomain.includes("qa")) {
166
+ return "qa";
167
+ }
168
+ return "production";
169
+ }
170
+ function isFederated(owningSystemUrl, portalUrl) {
171
+ var normalizedPortalUrl = cleanUrl(normalizeOnlinePortalUrl(portalUrl)).replace(/https?:\/\//, "");
172
+ var normalizedOwningSystemUrl = cleanUrl(owningSystemUrl).replace(/https?:\/\//, "");
173
+ return new RegExp(normalizedOwningSystemUrl, "i").test(normalizedPortalUrl);
174
+ }
175
+ function canUseOnlineToken(portalUrl, requestUrl) {
176
+ var portalIsOnline = isOnline(portalUrl);
177
+ var requestIsOnline = isOnline(requestUrl);
178
+ var portalEnv = getOnlineEnvironment(portalUrl);
179
+ var requestEnv = getOnlineEnvironment(requestUrl);
180
+ if (portalIsOnline && requestIsOnline && portalEnv === requestEnv) {
181
+ return true;
182
+ }
183
+ return false;
184
+ }
185
+
186
+ /* Copyright (c) 2018-2020 Environmental Systems Research Institute, Inc.
187
+ * Apache-2.0 */
213
188
  /**
214
- * Set key organization variables we will allow users to insert at runtime
189
+ * Validates that the user has access to the application
190
+ * and if they user should be presented a "View Only" mode
215
191
  *
216
- * @param translations nls translation object
192
+ * This is only needed/valid for Esri applications that are "licensed"
193
+ * and shipped in ArcGIS Online or ArcGIS Enterprise. Most custom applications
194
+ * should not need or use this.
217
195
  *
218
- * @returns a list of variables for the organization
219
- */
220
- function getOrganizationVariables(translations) {
221
- const orgVars = [{
222
- id: "",
223
- title: translations.geocodeUrl,
224
- value: "{{organization.helperServices.geocode:getDefaultLocatorURL}}"
225
- }, {
226
- id: "",
227
- title: translations.geometryUrl,
228
- value: "{{organization.helperServices.geometry.url}}"
229
- }, {
230
- id: "",
231
- title: translations.portalBaseUrl,
232
- value: "{{portalBaseUrl}}"
233
- }, {
234
- id: "",
235
- title: translations.routeUrl,
236
- value: "{{organization.helperServices.route.url}}"
237
- }, {
238
- id: "",
239
- title: translations.solutionItemExtent,
240
- value: "{{solutionItemExtent}}"
241
- }];
242
- return orgVars;
243
- }
244
- //--------------------------------------------------------------------------
245
- //
246
- // Private Functions
247
- //
248
- //--------------------------------------------------------------------------
249
- /**
250
- * Explore a solution item template for variables we will allow users to insert at runtime.
251
- * This function will update the item argument that is passed in with the var details.
252
- *
253
- * @param children a list of layers or tables from a template
254
- * @param item an object that store key details for a given variable
255
- * @param template one of the templates from the current solution
256
- * @param translations nls translations object
257
- *
258
- */
259
- function _addLayersOrTables(children, item, template, translations) {
260
- children.forEach(l => {
261
- const name = l.name && l.name.indexOf("||") > -1 ? l.name.split("||")[1].replace("}}", "").trim() : l.name;
262
- item.dependencies.push({
263
- id: template.itemId,
264
- title: `${name} (${translations.id})`,
265
- value: `{{${template.itemId}.layer${l.id}.id}}`,
266
- });
267
- item.dependencies.push({
268
- id: template.itemId,
269
- title: `${name} (${translations.name})`,
270
- value: `{{${template.itemId}.layer${l.id}.name||${name}}}`,
271
- });
272
- });
273
- }
274
- /**
275
- * Capture key details from the solution item template
276
- *
277
- * @param template one of the templates from the current solution
278
- * @param templates full list of templates
279
- * @param dependencies list of hierarchical dependencies
196
+ * ```js
197
+ * import { validateAppAccess } from '@esri/arcgis-rest-auth';
280
198
  *
281
- * @returns an IInventoryItem that is used by other components to work with this template
282
- */
283
- function _getItemFromTemplate(template, templates, dependencies) {
284
- return {
285
- id: template.itemId || "",
286
- title: template.item.title || "",
287
- dependencies: _getDependencies(dependencies, templates),
288
- type: template.item.type || "",
289
- typeKeywords: template.item.typeKeywords || [] /*,
290
- solutionItem: {
291
- itemId: template.itemId,
292
- itemDetails: _getItemDetails(template.item, template.type === "Group"),
293
- isResource: _getIsResource(template),
294
- data: template.data,
295
- properties: template.properties,
296
- type: template.type,
297
- groupDetails: _getGroupDetails(template, templates)
298
- }*/
299
- };
300
- }
301
- /**
302
- * Capture key details from the solution item template
199
+ * return validateAppAccess('your-token', 'theClientId')
200
+ * .then((result) => {
201
+ * if (!result.value) {
202
+ * // redirect or show some other ui
203
+ * } else {
204
+ * if (result.viewOnlyUserTypeApp) {
205
+ * // use this to inform your app to show a "View Only" mode
206
+ * }
207
+ * }
208
+ * })
209
+ * .catch((err) => {
210
+ * // two possible errors
211
+ * // invalid clientId: {"error":{"code":400,"messageCode":"GWM_0007","message":"Invalid request","details":[]}}
212
+ * // invalid token: {"error":{"code":498,"message":"Invalid token.","details":[]}}
213
+ * })
214
+ * ```
303
215
  *
304
- * @param dependencies list of dependencies from a template
305
- * @param templates full list of templates
216
+ * Note: This is only usable by Esri applications hosted on *arcgis.com, *esri.com or within
217
+ * an ArcGIS Enterprise installation. Custom applications can not use this.
306
218
  *
307
- * @returns a list of IInventoryItem that are used by other components to work with the templates
219
+ * @param token platform token
220
+ * @param clientId application client id
221
+ * @param portal Optional
308
222
  */
309
- function _getDependencies(dependencies, templates) {
310
- const dependencyItems = [];
311
- const depIds = dependencies.reduce((prev, cur) => {
312
- prev.push(cur.id);
313
- dependencyItems.push(cur);
314
- return prev;
315
- }, []);
316
- return templates.reduce((prev, curr) => {
317
- const i = depIds.indexOf(curr.itemId);
318
- if (i > -1) {
319
- prev.push(_getItemFromTemplate(curr, templates, dependencyItems[i].dependencies));
320
- }
321
- return prev;
322
- }, []);
223
+ function validateAppAccess(token, clientId, portal) {
224
+ if (portal === void 0) { portal = "https://www.arcgis.com/sharing/rest"; }
225
+ var url = portal + "/oauth2/validateAppAccess";
226
+ var ro = {
227
+ method: "POST",
228
+ params: {
229
+ f: "json",
230
+ client_id: clientId,
231
+ token: token,
232
+ },
233
+ };
234
+ return request(url, ro);
323
235
  }
324
- /**
325
- * Capture the key item details for a given template
326
- *
327
- * @param item the templates item
328
- * @param isGroup boolean to indicate if the item is a group
329
- * @param itemId the item id of the template
330
- *
331
- * @returns a IItemDetails object for the current item
332
- */
333
- /*
334
- function _getItemDetails(
335
- item: any,
336
- isGroup: boolean
337
- ): IItemDetails {
338
- return {
339
- title: item.title || "",
340
- snippet: item.snippet || "",
341
- description: item.description || "",
342
- tags: item.tags || [],
343
- accessInformation: !isGroup ? item.accessInformation || "" : "",
344
- licenseInfo: !isGroup ? item.licenseInfo || "" : ""
345
- };
236
+
237
+ /* Copyright (c) 2017-2019 Environmental Systems Research Institute, Inc.
238
+ * Apache-2.0 */
239
+ function defer() {
240
+ var deferred = {
241
+ promise: null,
242
+ resolve: null,
243
+ reject: null,
244
+ };
245
+ deferred.promise = new Promise(function (resolve, reject) {
246
+ deferred.resolve = resolve;
247
+ deferred.reject = reject;
248
+ });
249
+ return deferred;
346
250
  }
347
- */
348
251
  /**
349
- * Capture the key item details for a given group template
350
- *
351
- * @param template one of the templates from the current solution
352
- * @param templates full list of templates
353
- *
354
- * @returns a list of IItemShare objects
252
+ * ```js
253
+ * import { UserSession } from '@esri/arcgis-rest-auth';
254
+ * UserSession.beginOAuth2({
255
+ * // register an app of your own to create a unique clientId
256
+ * clientId: "abc123",
257
+ * redirectUri: 'https://yourapp.com/authenticate.html'
258
+ * })
259
+ * .then(session)
260
+ * // or
261
+ * new UserSession({
262
+ * username: "jsmith",
263
+ * password: "123456"
264
+ * })
265
+ * // or
266
+ * UserSession.deserialize(cache)
267
+ * ```
268
+ * Used to authenticate both ArcGIS Online and ArcGIS Enterprise users. `UserSession` includes helper methods for [OAuth 2.0](/arcgis-rest-js/guides/browser-authentication/) in both browser and server applications.
355
269
  */
356
- /*
357
- function _getGroupDetails(
358
- template: any,
359
- templates: any[]
360
- ): IItemShare[] {
361
- return template.type === "Group" ? templates.reduce((prev, cur) => {
362
- if (cur.itemId !== template.itemId && cur.type !== "Group") {
363
- prev.push({
364
- id: cur.itemId,
365
- title: cur.item.name || cur.item.title,
366
- isShared: (cur.groups || []).indexOf(template.itemId) > -1,
367
- shareItem: (cur.groups || []).indexOf(template.itemId) > -1,
368
- type: cur.type,
369
- typeKeywords: cur.item.typeKeywords
370
- });
371
- }
372
- return prev;
373
- }, []) : [];
374
- }
375
- */
376
- /**
377
- * Used to understand if we are dealing with a binary object that will support upload/download
378
- *
379
- * @param template one of the templates from the current solution
380
- *
381
- * @returns true if this item supports upload/download
382
- */
383
- /*
384
- function _getIsResource(
385
- template: any
386
- ): boolean {
387
- return template.type !== "Group" && template.resources.some(r => r.indexOf("_info_thumbnail") < 0) &&
388
- (template.data === null || JSON.stringify(template.data) === "{}");
389
- }
390
- */
391
- /**
392
- * Sort the template ids based on their dependencies
393
- *
394
- * @param templates full list of templates
395
- *
396
- * @returns a list of Itop level item ids
397
- */
398
- function _getTopLevelItemIds(templates) {
399
- // Find the top-level nodes. Start with all nodes, then remove those that other nodes depend on
400
- const topLevelItemCandidateIds = templates.map((template) => template.itemId);
401
- templates.forEach((template) => {
402
- (template.dependencies || []).forEach((dependencyId) => {
403
- const iNode = topLevelItemCandidateIds.indexOf(dependencyId);
404
- if (iNode >= 0) {
405
- // Node is somebody's dependency, so remove the node from the list of top-level nodes
406
- // If iNode == -1, then it's a shared dependency and it has already been removed
407
- topLevelItemCandidateIds.splice(iNode, 1);
408
- }
409
- });
410
- });
411
- return topLevelItemCandidateIds;
412
- }
413
-
414
- /*! *****************************************************************************
415
- Copyright (c) Microsoft Corporation.
416
-
417
- Permission to use, copy, modify, and/or distribute this software for any
418
- purpose with or without fee is hereby granted.
419
-
420
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
421
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
422
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
423
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
424
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
425
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
426
- PERFORMANCE OF THIS SOFTWARE.
427
- ***************************************************************************** */
428
-
429
- var __assign = function() {
430
- __assign = Object.assign || function __assign(t) {
431
- for (var s, i = 1, n = arguments.length; i < n; i++) {
432
- s = arguments[i];
433
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
434
- }
435
- return t;
436
- };
437
- return __assign.apply(this, arguments);
438
- };
439
-
440
- /* Copyright (c) 2017 Environmental Systems Research Institute, Inc.
441
- * Apache-2.0 */
442
- function fetchToken(url, requestOptions) {
443
- var options = requestOptions;
444
- // we generate a response, so we can't return the raw response
445
- options.rawResponse = false;
446
- return request(url, options).then(function (response) {
447
- var r = {
448
- token: response.access_token,
449
- username: response.username,
450
- expires: new Date(
451
- // convert seconds in response to milliseconds and add the value to the current time to calculate a static expiration timestamp
452
- Date.now() + (response.expires_in * 1000 - 1000)),
453
- ssl: response.ssl === true
454
- };
455
- if (response.refresh_token) {
456
- r.refreshToken = response.refresh_token;
457
- }
458
- return r;
459
- });
460
- }
461
-
462
- /* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.
463
- * Apache-2.0 */
464
- function generateToken(url, requestOptions) {
465
- var options = requestOptions;
466
- /* istanbul ignore else */
467
- if (typeof window !== "undefined" &&
468
- window.location &&
469
- window.location.host) {
470
- options.params.referer = window.location.host;
471
- }
472
- else {
473
- options.params.referer = NODEJS_DEFAULT_REFERER_HEADER;
474
- }
475
- return request(url, options);
476
- }
477
-
478
- /**
479
- * Used to test if a URL is an ArcGIS Online URL
480
- */
481
- var arcgisOnlineUrlRegex = /^https?:\/\/(\S+)\.arcgis\.com.+/;
482
- function isOnline(url) {
483
- return arcgisOnlineUrlRegex.test(url);
484
- }
485
- function normalizeOnlinePortalUrl(portalUrl) {
486
- if (!arcgisOnlineUrlRegex.test(portalUrl)) {
487
- return portalUrl;
488
- }
489
- switch (getOnlineEnvironment(portalUrl)) {
490
- case "dev":
491
- return "https://devext.arcgis.com/sharing/rest";
492
- case "qa":
493
- return "https://qaext.arcgis.com/sharing/rest";
494
- default:
495
- return "https://www.arcgis.com/sharing/rest";
496
- }
497
- }
498
- function getOnlineEnvironment(url) {
499
- if (!arcgisOnlineUrlRegex.test(url)) {
500
- return null;
501
- }
502
- var match = url.match(arcgisOnlineUrlRegex);
503
- var subdomain = match[1].split(".").pop();
504
- if (subdomain.includes("dev")) {
505
- return "dev";
506
- }
507
- if (subdomain.includes("qa")) {
508
- return "qa";
509
- }
510
- return "production";
511
- }
512
- function isFederated(owningSystemUrl, portalUrl) {
513
- var normalizedPortalUrl = cleanUrl(normalizeOnlinePortalUrl(portalUrl)).replace(/https?:\/\//, "");
514
- var normalizedOwningSystemUrl = cleanUrl(owningSystemUrl).replace(/https?:\/\//, "");
515
- return new RegExp(normalizedOwningSystemUrl, "i").test(normalizedPortalUrl);
516
- }
517
- function canUseOnlineToken(portalUrl, requestUrl) {
518
- var portalIsOnline = isOnline(portalUrl);
519
- var requestIsOnline = isOnline(requestUrl);
520
- var portalEnv = getOnlineEnvironment(portalUrl);
521
- var requestEnv = getOnlineEnvironment(requestUrl);
522
- if (portalIsOnline && requestIsOnline && portalEnv === requestEnv) {
523
- return true;
524
- }
525
- return false;
526
- }
527
-
528
- /* Copyright (c) 2018-2020 Environmental Systems Research Institute, Inc.
529
- * Apache-2.0 */
530
- /**
531
- * Validates that the user has access to the application
532
- * and if they user should be presented a "View Only" mode
533
- *
534
- * This is only needed/valid for Esri applications that are "licensed"
535
- * and shipped in ArcGIS Online or ArcGIS Enterprise. Most custom applications
536
- * should not need or use this.
537
- *
538
- * ```js
539
- * import { validateAppAccess } from '@esri/arcgis-rest-auth';
540
- *
541
- * return validateAppAccess('your-token', 'theClientId')
542
- * .then((result) => {
543
- * if (!result.value) {
544
- * // redirect or show some other ui
545
- * } else {
546
- * if (result.viewOnlyUserTypeApp) {
547
- * // use this to inform your app to show a "View Only" mode
548
- * }
549
- * }
550
- * })
551
- * .catch((err) => {
552
- * // two possible errors
553
- * // invalid clientId: {"error":{"code":400,"messageCode":"GWM_0007","message":"Invalid request","details":[]}}
554
- * // invalid token: {"error":{"code":498,"message":"Invalid token.","details":[]}}
555
- * })
556
- * ```
557
- *
558
- * Note: This is only usable by Esri applications hosted on *arcgis.com, *esri.com or within
559
- * an ArcGIS Enterprise installation. Custom applications can not use this.
560
- *
561
- * @param token platform token
562
- * @param clientId application client id
563
- * @param portal Optional
564
- */
565
- function validateAppAccess(token, clientId, portal) {
566
- if (portal === void 0) { portal = "https://www.arcgis.com/sharing/rest"; }
567
- var url = portal + "/oauth2/validateAppAccess";
568
- var ro = {
569
- method: "POST",
570
- params: {
571
- f: "json",
572
- client_id: clientId,
573
- token: token,
574
- },
575
- };
576
- return request(url, ro);
577
- }
578
-
579
- /* Copyright (c) 2017-2019 Environmental Systems Research Institute, Inc.
580
- * Apache-2.0 */
581
- function defer() {
582
- var deferred = {
583
- promise: null,
584
- resolve: null,
585
- reject: null,
586
- };
587
- deferred.promise = new Promise(function (resolve, reject) {
588
- deferred.resolve = resolve;
589
- deferred.reject = reject;
590
- });
591
- return deferred;
592
- }
593
- /**
594
- * ```js
595
- * import { UserSession } from '@esri/arcgis-rest-auth';
596
- * UserSession.beginOAuth2({
597
- * // register an app of your own to create a unique clientId
598
- * clientId: "abc123",
599
- * redirectUri: 'https://yourapp.com/authenticate.html'
600
- * })
601
- * .then(session)
602
- * // or
603
- * new UserSession({
604
- * username: "jsmith",
605
- * password: "123456"
606
- * })
607
- * // or
608
- * UserSession.deserialize(cache)
609
- * ```
610
- * Used to authenticate both ArcGIS Online and ArcGIS Enterprise users. `UserSession` includes helper methods for [OAuth 2.0](/arcgis-rest-js/guides/browser-authentication/) in both browser and server applications.
611
- */
612
- var UserSession = /** @class */ (function () {
613
- function UserSession(options) {
614
- this.clientId = options.clientId;
615
- this._refreshToken = options.refreshToken;
616
- this._refreshTokenExpires = options.refreshTokenExpires;
617
- this.username = options.username;
618
- this.password = options.password;
619
- this._token = options.token;
620
- this._tokenExpires = options.tokenExpires;
621
- this.portal = options.portal
622
- ? cleanUrl(options.portal)
623
- : "https://www.arcgis.com/sharing/rest";
624
- this.ssl = options.ssl;
625
- this.provider = options.provider || "arcgis";
626
- this.tokenDuration = options.tokenDuration || 20160;
627
- this.redirectUri = options.redirectUri;
628
- this.refreshTokenTTL = options.refreshTokenTTL || 20160;
629
- this.server = options.server;
630
- this.federatedServers = {};
631
- this.trustedDomains = [];
632
- // if a non-federated server was passed explicitly, it should be trusted.
633
- if (options.server) {
634
- // if the url includes more than '/arcgis/', trim the rest
635
- var root = this.getServerRootUrl(options.server);
636
- this.federatedServers[root] = {
637
- token: options.token,
638
- expires: options.tokenExpires,
639
- };
640
- }
641
- this._pendingTokenRequests = {};
270
+ var UserSession = /** @class */ (function () {
271
+ function UserSession(options) {
272
+ this.clientId = options.clientId;
273
+ this._refreshToken = options.refreshToken;
274
+ this._refreshTokenExpires = options.refreshTokenExpires;
275
+ this.username = options.username;
276
+ this.password = options.password;
277
+ this._token = options.token;
278
+ this._tokenExpires = options.tokenExpires;
279
+ this.portal = options.portal
280
+ ? cleanUrl(options.portal)
281
+ : "https://www.arcgis.com/sharing/rest";
282
+ this.ssl = options.ssl;
283
+ this.provider = options.provider || "arcgis";
284
+ this.tokenDuration = options.tokenDuration || 20160;
285
+ this.redirectUri = options.redirectUri;
286
+ this.refreshTokenTTL = options.refreshTokenTTL || 20160;
287
+ this.server = options.server;
288
+ this.federatedServers = {};
289
+ this.trustedDomains = [];
290
+ // if a non-federated server was passed explicitly, it should be trusted.
291
+ if (options.server) {
292
+ // if the url includes more than '/arcgis/', trim the rest
293
+ var root = this.getServerRootUrl(options.server);
294
+ this.federatedServers[root] = {
295
+ token: options.token,
296
+ expires: options.tokenExpires,
297
+ };
298
+ }
299
+ this._pendingTokenRequests = {};
642
300
  }
643
301
  Object.defineProperty(UserSession.prototype, "token", {
644
302
  /**
@@ -1472,6 +1130,348 @@ var UserSession = /** @class */ (function () {
1472
1130
  return UserSession;
1473
1131
  }());
1474
1132
 
1133
+ /** @license
1134
+ * Copyright 2022 Esri
1135
+ *
1136
+ * Licensed under the Apache License, Version 2.0 (the "License");
1137
+ * you may not use this file except in compliance with the License.
1138
+ * You may obtain a copy of the License at
1139
+ *
1140
+ * http://www.apache.org/licenses/LICENSE-2.0
1141
+ *
1142
+ * Unless required by applicable law or agreed to in writing, software
1143
+ * distributed under the License is distributed on an "AS IS" BASIS,
1144
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1145
+ * See the License for the specific language governing permissions and
1146
+ * limitations under the License.
1147
+ */
1148
+ //--------------------------------------------------------------------------
1149
+ //
1150
+ // Public Functions
1151
+ //
1152
+ //--------------------------------------------------------------------------
1153
+ /**
1154
+ * Sort the solution items
1155
+ *
1156
+ * @param templates a list of item templates from the solution
1157
+ *
1158
+ * @returns a sorted list of solution items
1159
+ */
1160
+ function getInventoryItems(templates) {
1161
+ const hierarchy = getItemHierarchy(templates);
1162
+ const ids = hierarchy.reduce((prev, cur) => {
1163
+ prev.push(cur.id);
1164
+ return prev;
1165
+ }, []);
1166
+ return templates.reduce((prev, cur) => {
1167
+ if (ids.indexOf(cur.itemId) > -1) {
1168
+ const hierarchyItems = hierarchy.filter(hi => hi.id === cur.itemId);
1169
+ prev.push(_getItemFromTemplate(cur, templates, hierarchyItems[0].dependencies));
1170
+ }
1171
+ return prev;
1172
+ }, []);
1173
+ }
1174
+ /**
1175
+ * Create item hierarchy that will avoid issues from cylical dependencies
1176
+ *
1177
+ * @param templates a list of item templates from the solution
1178
+ *
1179
+ * @returns a hierarchy for item and item dependency display
1180
+ */
1181
+ function getItemHierarchy(templates) {
1182
+ const hierarchy = [];
1183
+ // Get the template specified by id out of a list of templates
1184
+ function getTemplateInSolution(templates, id) {
1185
+ const iTemplate = templates.findIndex((template) => id === template.itemId);
1186
+ return iTemplate >= 0 ? templates[iTemplate] : null;
1187
+ }
1188
+ // Hierarchically list the dependencies of specified node
1189
+ function traceItemId(id, accumulatedHierarchy, alreadyVisitedIds = []) {
1190
+ // Get the dependencies of the node
1191
+ const template = getTemplateInSolution(templates, id);
1192
+ /* istanbul ignore else */
1193
+ if (template) {
1194
+ const templateEntry = {
1195
+ id,
1196
+ dependencies: []
1197
+ };
1198
+ // Visit each dependency, but only if this template is not in the alreadyVisitedIds list to avoid infinite loops
1199
+ /* istanbul ignore else */
1200
+ if (alreadyVisitedIds.indexOf(id) < 0) {
1201
+ // Add dependency to alreadyVisitedIds list
1202
+ alreadyVisitedIds.push(id);
1203
+ template.dependencies.forEach((dependencyId) => {
1204
+ // Remove dependency from list of templates to visit in the top-level loop
1205
+ const iDependencyTemplate = templateItemIds.indexOf(dependencyId);
1206
+ /* istanbul ignore else */
1207
+ if (iDependencyTemplate >= 0) {
1208
+ templateItemIds.splice(iDependencyTemplate, 1);
1209
+ }
1210
+ traceItemId(dependencyId, templateEntry.dependencies, alreadyVisitedIds);
1211
+ });
1212
+ }
1213
+ accumulatedHierarchy.push(templateEntry);
1214
+ }
1215
+ }
1216
+ // Start with top-level nodes and add in the rest of the nodes to catch cycles without top-level nodes
1217
+ let templateItemIds = _getTopLevelItemIds(templates);
1218
+ const otherItems = templates
1219
+ .filter((template) => templateItemIds.indexOf(template.itemId) < 0) // only keep non-top-level nodes
1220
+ .sort((a, b) => b.dependencies.length - a.dependencies.length); // sort so that nodes with more dependencies come first--reduces stubs
1221
+ templateItemIds = templateItemIds.concat(otherItems.map((template) => template.itemId));
1222
+ // Step through the list of nodes; we'll also remove nodes as we visit them
1223
+ let itemId = templateItemIds.shift();
1224
+ while (typeof itemId !== "undefined") {
1225
+ traceItemId(itemId, hierarchy);
1226
+ itemId = templateItemIds.shift();
1227
+ }
1228
+ return hierarchy;
1229
+ }
1230
+ /**
1231
+ * Explore the solution item templates for variables we will allow users to insert at runtime
1232
+ *
1233
+ * @param templates a list of item templates from the solution
1234
+ * @param translations nls translation object
1235
+ *
1236
+ * @returns a list of variables from the solution item templates
1237
+ */
1238
+ function getSolutionVariables(templates, translations) {
1239
+ const vars = [];
1240
+ templates.forEach(t => {
1241
+ const item = {
1242
+ id: t.itemId,
1243
+ title: t.item.title || t.item.name,
1244
+ type: t.type,
1245
+ value: undefined,
1246
+ dependencies: [{
1247
+ id: t.itemId,
1248
+ title: translations.itemId,
1249
+ value: `{{${t.itemId}.itemId}}`,
1250
+ }]
1251
+ };
1252
+ if (t.item.url) {
1253
+ item.dependencies.push({
1254
+ id: t.itemId,
1255
+ title: translations.url,
1256
+ value: `{{${t.itemId}.url}}`,
1257
+ });
1258
+ }
1259
+ if (t.type === "Feature Service") {
1260
+ // TODO need to set source service name var...
1261
+ // TODO need to set soure service shape field name "{{d05b3cf1ffcb4a4fa677627dfb18609e.name}}.Shape"
1262
+ item.dependencies.push({
1263
+ id: t.itemId,
1264
+ title: translations.solutionExtent,
1265
+ value: `{{${t.itemId}.solutionExtent}}`,
1266
+ });
1267
+ _addLayersOrTables(t.properties.layers || [], item, t, translations);
1268
+ _addLayersOrTables(t.properties.tables || [], item, t, translations);
1269
+ }
1270
+ vars.push(item);
1271
+ });
1272
+ return vars;
1273
+ }
1274
+ /**
1275
+ * Set key organization variables we will allow users to insert at runtime
1276
+ *
1277
+ * @param translations nls translation object
1278
+ *
1279
+ * @returns a list of variables for the organization
1280
+ */
1281
+ function getOrganizationVariables(translations) {
1282
+ const orgVars = [{
1283
+ id: "",
1284
+ title: translations.geocodeUrl,
1285
+ value: "{{organization.helperServices.geocode:getDefaultLocatorURL}}"
1286
+ }, {
1287
+ id: "",
1288
+ title: translations.geometryUrl,
1289
+ value: "{{organization.helperServices.geometry.url}}"
1290
+ }, {
1291
+ id: "",
1292
+ title: translations.portalBaseUrl,
1293
+ value: "{{portalBaseUrl}}"
1294
+ }, {
1295
+ id: "",
1296
+ title: translations.routeUrl,
1297
+ value: "{{organization.helperServices.route.url}}"
1298
+ }, {
1299
+ id: "",
1300
+ title: translations.solutionItemExtent,
1301
+ value: "{{solutionItemExtent}}"
1302
+ }];
1303
+ return orgVars;
1304
+ }
1305
+ //--------------------------------------------------------------------------
1306
+ //
1307
+ // Private Functions
1308
+ //
1309
+ //--------------------------------------------------------------------------
1310
+ /**
1311
+ * Explore a solution item template for variables we will allow users to insert at runtime.
1312
+ * This function will update the item argument that is passed in with the var details.
1313
+ *
1314
+ * @param children a list of layers or tables from a template
1315
+ * @param item an object that store key details for a given variable
1316
+ * @param template one of the templates from the current solution
1317
+ * @param translations nls translations object
1318
+ *
1319
+ */
1320
+ function _addLayersOrTables(children, item, template, translations) {
1321
+ children.forEach(l => {
1322
+ const name = l.name && l.name.indexOf("||") > -1 ? l.name.split("||")[1].replace("}}", "").trim() : l.name;
1323
+ item.dependencies.push({
1324
+ id: template.itemId,
1325
+ title: `${name} (${translations.id})`,
1326
+ value: `{{${template.itemId}.layer${l.id}.id}}`,
1327
+ });
1328
+ item.dependencies.push({
1329
+ id: template.itemId,
1330
+ title: `${name} (${translations.name})`,
1331
+ value: `{{${template.itemId}.layer${l.id}.name||${name}}}`,
1332
+ });
1333
+ });
1334
+ }
1335
+ /**
1336
+ * Capture key details from the solution item template
1337
+ *
1338
+ * @param template one of the templates from the current solution
1339
+ * @param templates full list of templates
1340
+ * @param dependencies list of hierarchical dependencies
1341
+ *
1342
+ * @returns an IInventoryItem that is used by other components to work with this template
1343
+ */
1344
+ function _getItemFromTemplate(template, templates, dependencies) {
1345
+ return {
1346
+ id: template.itemId || "",
1347
+ title: template.item.title || "",
1348
+ dependencies: _getDependencies(dependencies, templates),
1349
+ type: template.item.type || "",
1350
+ typeKeywords: template.item.typeKeywords || [] /*,
1351
+ solutionItem: {
1352
+ itemId: template.itemId,
1353
+ itemDetails: _getItemDetails(template.item, template.type === "Group"),
1354
+ isResource: _getIsResource(template),
1355
+ data: template.data,
1356
+ properties: template.properties,
1357
+ type: template.type,
1358
+ groupDetails: _getGroupDetails(template, templates)
1359
+ }*/
1360
+ };
1361
+ }
1362
+ /**
1363
+ * Capture key details from the solution item template
1364
+ *
1365
+ * @param dependencies list of dependencies from a template
1366
+ * @param templates full list of templates
1367
+ *
1368
+ * @returns a list of IInventoryItem that are used by other components to work with the templates
1369
+ */
1370
+ function _getDependencies(dependencies, templates) {
1371
+ const dependencyItems = [];
1372
+ const depIds = dependencies.reduce((prev, cur) => {
1373
+ prev.push(cur.id);
1374
+ dependencyItems.push(cur);
1375
+ return prev;
1376
+ }, []);
1377
+ return templates.reduce((prev, curr) => {
1378
+ const i = depIds.indexOf(curr.itemId);
1379
+ if (i > -1) {
1380
+ prev.push(_getItemFromTemplate(curr, templates, dependencyItems[i].dependencies));
1381
+ }
1382
+ return prev;
1383
+ }, []);
1384
+ }
1385
+ /**
1386
+ * Capture the key item details for a given template
1387
+ *
1388
+ * @param item the templates item
1389
+ * @param isGroup boolean to indicate if the item is a group
1390
+ * @param itemId the item id of the template
1391
+ *
1392
+ * @returns a IItemDetails object for the current item
1393
+ */
1394
+ /*
1395
+ function _getItemDetails(
1396
+ item: any,
1397
+ isGroup: boolean
1398
+ ): IItemDetails {
1399
+ return {
1400
+ title: item.title || "",
1401
+ snippet: item.snippet || "",
1402
+ description: item.description || "",
1403
+ tags: item.tags || [],
1404
+ accessInformation: !isGroup ? item.accessInformation || "" : "",
1405
+ licenseInfo: !isGroup ? item.licenseInfo || "" : ""
1406
+ };
1407
+ }
1408
+ */
1409
+ /**
1410
+ * Capture the key item details for a given group template
1411
+ *
1412
+ * @param template one of the templates from the current solution
1413
+ * @param templates full list of templates
1414
+ *
1415
+ * @returns a list of IItemShare objects
1416
+ */
1417
+ /*
1418
+ function _getGroupDetails(
1419
+ template: any,
1420
+ templates: any[]
1421
+ ): IItemShare[] {
1422
+ return template.type === "Group" ? templates.reduce((prev, cur) => {
1423
+ if (cur.itemId !== template.itemId && cur.type !== "Group") {
1424
+ prev.push({
1425
+ id: cur.itemId,
1426
+ title: cur.item.name || cur.item.title,
1427
+ isShared: (cur.groups || []).indexOf(template.itemId) > -1,
1428
+ shareItem: (cur.groups || []).indexOf(template.itemId) > -1,
1429
+ type: cur.type,
1430
+ typeKeywords: cur.item.typeKeywords
1431
+ });
1432
+ }
1433
+ return prev;
1434
+ }, []) : [];
1435
+ }
1436
+ */
1437
+ /**
1438
+ * Used to understand if we are dealing with a binary object that will support upload/download
1439
+ *
1440
+ * @param template one of the templates from the current solution
1441
+ *
1442
+ * @returns true if this item supports upload/download
1443
+ */
1444
+ /*
1445
+ function _getIsResource(
1446
+ template: any
1447
+ ): boolean {
1448
+ return template.type !== "Group" && template.resources.some(r => r.indexOf("_info_thumbnail") < 0) &&
1449
+ (template.data === null || JSON.stringify(template.data) === "{}");
1450
+ }
1451
+ */
1452
+ /**
1453
+ * Sort the template ids based on their dependencies
1454
+ *
1455
+ * @param templates full list of templates
1456
+ *
1457
+ * @returns a list of Itop level item ids
1458
+ */
1459
+ function _getTopLevelItemIds(templates) {
1460
+ // Find the top-level nodes. Start with all nodes, then remove those that other nodes depend on
1461
+ const topLevelItemCandidateIds = templates.map((template) => template.itemId);
1462
+ templates.forEach((template) => {
1463
+ (template.dependencies || []).forEach((dependencyId) => {
1464
+ const iNode = topLevelItemCandidateIds.indexOf(dependencyId);
1465
+ if (iNode >= 0) {
1466
+ // Node is somebody's dependency, so remove the node from the list of top-level nodes
1467
+ // If iNode == -1, then it's a shared dependency and it has already been removed
1468
+ topLevelItemCandidateIds.splice(iNode, 1);
1469
+ }
1470
+ });
1471
+ });
1472
+ return topLevelItemCandidateIds;
1473
+ }
1474
+
1475
1475
  const solutionConfigurationCss = ".configuration-container{position:relative;height:100%;width:100%}.configuration{position:absolute;top:0px;right:0px;bottom:0px;left:0px;display:flex;padding:0.5rem;border:1px #808080 solid}.config-tabs{width:100%}.config-tab{width:100%}.config-solution{position:absolute;top:3.5rem;right:-1px;bottom:-1px;left:-1px;display:flex;padding:0.5rem}.config-inventory{display:inline;max-width:-moz-min-content;max-width:min-content;flex-grow:0;overflow-y:auto}.config-inventory-hide{display:none;max-width:-moz-min-content;max-width:min-content;flex-grow:0;overflow-y:auto}.config-item{position:relative;display:inline;flex-grow:1;overflow-y:auto;margin-inline-start:0.5rem}solution-contents{position:relative;height:100%}solution-item{position:relative;height:100%}solution-spatial-ref{position:relative;height:100%;width:100%;overflow-y:auto}";
1476
1476
 
1477
1477
  const SolutionConfiguration$1 = /*@__PURE__*/ proxyCustomElement(class SolutionConfiguration extends HTMLElement {