@esri/solutions-components 0.7.52 → 0.8.0

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 (191) hide show
  1. package/dist/assets/t9n/consent-manager/resources.json +12 -0
  2. package/dist/assets/t9n/consent-manager/resources_en.json +12 -0
  3. package/dist/cjs/{_commonjsHelpers-384729db.js → _commonjsHelpers-480c2e77.js} +16 -0
  4. package/dist/cjs/basemap-gallery_7.cjs.entry.js +3 -3
  5. package/dist/cjs/buffer-tools_3.cjs.entry.js +3 -3
  6. package/dist/cjs/calcite-action-pad_2.cjs.entry.js +3 -3
  7. package/dist/cjs/calcite-alert_4.cjs.entry.js +4 -4
  8. package/dist/cjs/calcite-color-picker-hex-input_2.cjs.entry.js +2 -2
  9. package/dist/cjs/calcite-color-picker.cjs.entry.js +2 -2
  10. package/dist/cjs/calcite-combobox_5.cjs.entry.js +3 -3
  11. package/dist/cjs/calcite-flow_5.cjs.entry.js +4 -4
  12. package/dist/cjs/calcite-input-date-picker_3.cjs.entry.js +5 -5
  13. package/dist/cjs/calcite-shell-panel_14.cjs.entry.js +6 -6
  14. package/dist/cjs/card-manager_3.cjs.entry.js +6 -6
  15. package/dist/cjs/{common-4cd3537b.js → common-e6e9f7d6.js} +1 -1
  16. package/dist/cjs/consent-manager.cjs.entry.js +1769 -0
  17. package/dist/cjs/crowdsource-manager.cjs.entry.js +3 -3
  18. package/dist/cjs/crowdsource-reporter.cjs.entry.js +3 -3
  19. package/dist/cjs/{downloadUtils-82bc9a04.js → downloadUtils-c2bd7c80.js} +6 -6
  20. package/dist/cjs/{esri-loader-a91c0ec1.js → esri-loader-ce6c3d3d.js} +1 -1
  21. package/dist/cjs/{helpers-e328869d.js → helpers-81779c18.js} +1 -1
  22. package/dist/cjs/{html2canvas-34208bbf.js → html2canvas-27a2547c.js} +1 -1
  23. package/dist/cjs/{index.es-79d8773c.js → index.es-22b3d1a2.js} +6 -6
  24. package/dist/cjs/instant-apps-ckeditor-wrapper_3.cjs.entry.js +6 -6
  25. package/dist/cjs/instant-apps-control-panel.cjs.entry.js +3 -3
  26. package/dist/cjs/instant-apps-export.cjs.entry.js +5 -5
  27. package/dist/cjs/instant-apps-header.cjs.entry.js +3 -3
  28. package/dist/cjs/instant-apps-interactive-legend-classic.cjs.entry.js +4 -4
  29. package/dist/cjs/instant-apps-interactive-legend-count_2.cjs.entry.js +4 -4
  30. package/dist/cjs/instant-apps-interactive-legend-group-legend-element-caption.cjs.entry.js +4 -4
  31. package/dist/cjs/instant-apps-interactive-legend-group-legend-element_5.cjs.entry.js +4 -4
  32. package/dist/cjs/instant-apps-interactive-legend.cjs.entry.js +6 -6
  33. package/dist/cjs/instant-apps-keyboard-shortcuts.cjs.entry.js +5 -5
  34. package/dist/cjs/instant-apps-language-switcher.cjs.entry.js +7 -7
  35. package/dist/cjs/instant-apps-language-translator.cjs.entry.js +7 -7
  36. package/dist/cjs/instant-apps-measurement.cjs.entry.js +5 -5
  37. package/dist/cjs/instant-apps-popover.cjs.entry.js +5 -5
  38. package/dist/cjs/instant-apps-scoreboard.cjs.entry.js +5 -5
  39. package/dist/cjs/instant-apps-splash.cjs.entry.js +5 -5
  40. package/dist/cjs/{languageSwitcher-7de41e17.js → languageSwitcher-4822684b.js} +1 -1
  41. package/dist/cjs/{languageUtil-a3b464f8.js → languageUtil-9bd00bad.js} +1 -1
  42. package/dist/cjs/layout-manager.cjs.entry.js +3 -3
  43. package/dist/cjs/{loadModules-51c30ab9.js → loadModules-69fc5b98.js} +1 -1
  44. package/dist/cjs/loader.cjs.js +1 -1
  45. package/dist/cjs/{locale-8c42ba7a.js → locale-3d0a4bc2.js} +1 -1
  46. package/dist/cjs/{locale-dab3f46a.js → locale-3e33f44c.js} +2 -2
  47. package/dist/cjs/map-select-tools_3.cjs.entry.js +6 -6
  48. package/dist/cjs/{popupUtils-824d2f7c.js → popupUtils-6be3588c.js} +1 -1
  49. package/dist/cjs/public-notification.cjs.entry.js +6 -6
  50. package/dist/cjs/{purify-f8c3e427.js → purify-4791ecca.js} +1 -1
  51. package/dist/cjs/{resources-adfcb1ec.js → resources-02142b99.js} +1 -1
  52. package/dist/cjs/{restHelpersGet-e0737480.js → restHelpersGet-2ed729ab.js} +1 -1
  53. package/dist/cjs/solution-configuration.cjs.entry.js +6 -6
  54. package/dist/cjs/solution-contents_3.cjs.entry.js +7 -7
  55. package/dist/cjs/{solution-resource-abec7452.js → solution-resource-97186521.js} +1 -1
  56. package/dist/cjs/{solution-store-2f7fbcc5.js → solution-store-67bcf552.js} +2 -2
  57. package/dist/cjs/solutions-components.cjs.js +1 -1
  58. package/dist/cjs/spatial-ref.cjs.entry.js +5 -5
  59. package/dist/cjs/{utils-a137dc1a.js → utils-ea7a5a63.js} +1 -1
  60. package/dist/collection/collection-manifest.json +1 -0
  61. package/dist/collection/components/consent-manager/consent-manager.css +67 -0
  62. package/dist/collection/components/consent-manager/consent-manager.js +278 -0
  63. package/dist/collection/components/consent-manager/test/consent-manager.e2e.js +29 -0
  64. package/dist/collection/components/consent-manager/test/consent-manager.spec.js +37 -0
  65. package/dist/collection/utils/interfaces.ts +4 -0
  66. package/dist/components/_commonjsHelpers.js +16 -1
  67. package/dist/components/consent-manager.d.ts +11 -0
  68. package/dist/components/consent-manager.js +1844 -0
  69. package/dist/components/downloadUtils.js +1 -1
  70. package/dist/components/index.es.js +1 -1
  71. package/dist/esm/{_commonjsHelpers-d5f9d613.js → _commonjsHelpers-0f74c230.js} +16 -1
  72. package/dist/esm/basemap-gallery_7.entry.js +3 -3
  73. package/dist/esm/buffer-tools_3.entry.js +3 -3
  74. package/dist/esm/calcite-action-pad_2.entry.js +3 -3
  75. package/dist/esm/calcite-alert_4.entry.js +4 -4
  76. package/dist/esm/calcite-color-picker-hex-input_2.entry.js +2 -2
  77. package/dist/esm/calcite-color-picker.entry.js +2 -2
  78. package/dist/esm/calcite-combobox_5.entry.js +3 -3
  79. package/dist/esm/calcite-flow_5.entry.js +4 -4
  80. package/dist/esm/calcite-input-date-picker_3.entry.js +5 -5
  81. package/dist/esm/calcite-shell-panel_14.entry.js +6 -6
  82. package/dist/esm/card-manager_3.entry.js +6 -6
  83. package/dist/esm/{common-d04ccc0d.js → common-06bcfe81.js} +1 -1
  84. package/dist/esm/consent-manager.entry.js +1765 -0
  85. package/dist/esm/crowdsource-manager.entry.js +3 -3
  86. package/dist/esm/crowdsource-reporter.entry.js +3 -3
  87. package/dist/esm/{downloadUtils-3bab4b5f.js → downloadUtils-a6c0e25f.js} +6 -6
  88. package/dist/esm/{esri-loader-eda07632.js → esri-loader-1b324844.js} +1 -1
  89. package/dist/esm/{helpers-633917fe.js → helpers-aeddac74.js} +1 -1
  90. package/dist/esm/{html2canvas-a0a4df55.js → html2canvas-7f5bb1cc.js} +1 -1
  91. package/dist/esm/{index.es-be703f2b.js → index.es-b0a676ae.js} +6 -6
  92. package/dist/esm/instant-apps-ckeditor-wrapper_3.entry.js +6 -6
  93. package/dist/esm/instant-apps-control-panel.entry.js +3 -3
  94. package/dist/esm/instant-apps-export.entry.js +5 -5
  95. package/dist/esm/instant-apps-header.entry.js +3 -3
  96. package/dist/esm/instant-apps-interactive-legend-classic.entry.js +4 -4
  97. package/dist/esm/instant-apps-interactive-legend-count_2.entry.js +4 -4
  98. package/dist/esm/instant-apps-interactive-legend-group-legend-element-caption.entry.js +4 -4
  99. package/dist/esm/instant-apps-interactive-legend-group-legend-element_5.entry.js +4 -4
  100. package/dist/esm/instant-apps-interactive-legend.entry.js +6 -6
  101. package/dist/esm/instant-apps-keyboard-shortcuts.entry.js +5 -5
  102. package/dist/esm/instant-apps-language-switcher.entry.js +7 -7
  103. package/dist/esm/instant-apps-language-translator.entry.js +7 -7
  104. package/dist/esm/instant-apps-measurement.entry.js +5 -5
  105. package/dist/esm/instant-apps-popover.entry.js +5 -5
  106. package/dist/esm/instant-apps-scoreboard.entry.js +5 -5
  107. package/dist/esm/instant-apps-splash.entry.js +5 -5
  108. package/dist/esm/{languageSwitcher-62232826.js → languageSwitcher-4faa659f.js} +1 -1
  109. package/dist/esm/{languageUtil-8b54477c.js → languageUtil-dc3111c1.js} +1 -1
  110. package/dist/esm/layout-manager.entry.js +3 -3
  111. package/dist/esm/{loadModules-b677d6d7.js → loadModules-877bbb89.js} +1 -1
  112. package/dist/esm/loader.js +1 -1
  113. package/dist/esm/{locale-25a5ae3e.js → locale-bcbea4ef.js} +1 -1
  114. package/dist/esm/{locale-c7d9e9aa.js → locale-bd9034e1.js} +2 -2
  115. package/dist/esm/map-select-tools_3.entry.js +6 -6
  116. package/dist/esm/{popupUtils-23fe3c9f.js → popupUtils-af124b47.js} +1 -1
  117. package/dist/esm/public-notification.entry.js +6 -6
  118. package/dist/esm/{purify-c99d2ace.js → purify-dce4d86b.js} +1 -1
  119. package/dist/esm/{resources-79914606.js → resources-61b0cdad.js} +1 -1
  120. package/dist/esm/{restHelpersGet-af032ab2.js → restHelpersGet-2a85d395.js} +1 -1
  121. package/dist/esm/solution-configuration.entry.js +6 -6
  122. package/dist/esm/solution-contents_3.entry.js +7 -7
  123. package/dist/esm/{solution-resource-7b8d302d.js → solution-resource-77aa99c8.js} +1 -1
  124. package/dist/esm/{solution-store-01769bbf.js → solution-store-13ddaf1c.js} +2 -2
  125. package/dist/esm/solutions-components.js +1 -1
  126. package/dist/esm/spatial-ref.entry.js +5 -5
  127. package/dist/esm/{utils-b46c535b.js → utils-28d0a086.js} +1 -1
  128. package/dist/solutions-components/{p-54b7b859.entry.js → p-015a45e2.entry.js} +1 -1
  129. package/dist/solutions-components/{p-b756d01f.js → p-03037cf9.js} +1 -1
  130. package/dist/solutions-components/{p-2917dae0.entry.js → p-03a65871.entry.js} +1 -1
  131. package/dist/solutions-components/{p-86b21da1.js → p-07626c45.js} +1 -1
  132. package/dist/solutions-components/{p-14a48b14.js → p-090e0241.js} +1 -1
  133. package/dist/solutions-components/{p-531ccf84.entry.js → p-09312a7a.entry.js} +1 -1
  134. package/dist/solutions-components/{p-8595b4aa.entry.js → p-09801ba6.entry.js} +1 -1
  135. package/dist/solutions-components/{p-2f017ad2.entry.js → p-0d72a9ca.entry.js} +1 -1
  136. package/dist/solutions-components/p-0e5274bd.entry.js +6 -0
  137. package/dist/solutions-components/{p-bb94c414.entry.js → p-104f07e3.entry.js} +1 -1
  138. package/dist/solutions-components/{p-2592e0dd.js → p-188ed8b6.js} +1 -1
  139. package/dist/solutions-components/{p-16a82c20.js → p-192b6455.js} +1 -1
  140. package/dist/solutions-components/{p-7cfc4ba5.entry.js → p-1a7cef7b.entry.js} +1 -1
  141. package/dist/solutions-components/{p-463712ef.entry.js → p-1ac2125a.entry.js} +2 -2
  142. package/dist/solutions-components/{p-23fed594.entry.js → p-1bca71bf.entry.js} +1 -1
  143. package/dist/solutions-components/{p-ce4eed51.entry.js → p-220c46c2.entry.js} +1 -1
  144. package/dist/solutions-components/{p-c8ca9b8c.entry.js → p-299d1eaf.entry.js} +3 -3
  145. package/dist/solutions-components/{p-7cfce9ee.entry.js → p-2e7a9b9b.entry.js} +2 -2
  146. package/dist/solutions-components/{p-df468e80.entry.js → p-35c9256b.entry.js} +2 -2
  147. package/dist/solutions-components/{p-d561c970.entry.js → p-41bc9e9d.entry.js} +1 -1
  148. package/dist/solutions-components/{p-4742efa8.entry.js → p-5a28d60c.entry.js} +1 -1
  149. package/dist/solutions-components/{p-e46617d1.entry.js → p-5c7e3941.entry.js} +1 -1
  150. package/dist/solutions-components/{p-8dbf3319.entry.js → p-63466518.entry.js} +1 -1
  151. package/dist/solutions-components/{p-c05467fd.entry.js → p-6512dc44.entry.js} +1 -1
  152. package/dist/solutions-components/{p-0f66fd89.js → p-66bca043.js} +3 -3
  153. package/dist/solutions-components/{p-a8a0187d.js → p-70359c2b.js} +1 -1
  154. package/dist/solutions-components/{p-91d3732f.js → p-734d1dc5.js} +1 -1
  155. package/dist/solutions-components/{p-de459c0a.entry.js → p-7d6ee026.entry.js} +1 -1
  156. package/dist/solutions-components/{p-91710f0e.entry.js → p-8ad937b4.entry.js} +1 -1
  157. package/dist/solutions-components/{p-d918ec36.js → p-8ddc7786.js} +1 -1
  158. package/dist/solutions-components/p-8e9f96db.js +6 -0
  159. package/dist/solutions-components/{p-220ec0d1.js → p-94c634ba.js} +1 -1
  160. package/dist/solutions-components/{p-e2b0b3fa.entry.js → p-a2544cba.entry.js} +1 -1
  161. package/dist/solutions-components/{p-3cf84035.entry.js → p-a455c3f0.entry.js} +1 -1
  162. package/dist/solutions-components/{p-044cd52c.entry.js → p-a59078ee.entry.js} +1 -1
  163. package/dist/solutions-components/{p-701ed205.js → p-a7b7f8d1.js} +1 -1
  164. package/dist/solutions-components/{p-96104375.entry.js → p-aec4441b.entry.js} +1 -1
  165. package/dist/solutions-components/{p-d9995b7e.js → p-b41e2c4c.js} +3 -3
  166. package/dist/solutions-components/{p-d89fff3a.js → p-b503d01d.js} +1 -1
  167. package/dist/solutions-components/{p-cacd0307.entry.js → p-b80bc5b9.entry.js} +1 -1
  168. package/dist/solutions-components/{p-b04c9dc3.js → p-be8ef276.js} +1 -1
  169. package/dist/solutions-components/{p-6ac459d9.entry.js → p-c10b44ee.entry.js} +1 -1
  170. package/dist/solutions-components/{p-88cd4a24.entry.js → p-c302bbea.entry.js} +1 -1
  171. package/dist/solutions-components/{p-547b4dba.entry.js → p-c375881a.entry.js} +1 -1
  172. package/dist/solutions-components/{p-e05b02c5.entry.js → p-cd1ca3a6.entry.js} +1 -1
  173. package/dist/solutions-components/{p-3cce003d.js → p-cde1d741.js} +1 -1
  174. package/dist/solutions-components/{p-ccfdd890.entry.js → p-cfe890f6.entry.js} +1 -1
  175. package/dist/solutions-components/{p-a4bb0787.entry.js → p-df29f4c2.entry.js} +1 -1
  176. package/dist/solutions-components/p-e2d0ad1b.js +6 -0
  177. package/dist/solutions-components/{p-bf9e18d4.js → p-eab00813.js} +1 -1
  178. package/dist/solutions-components/{p-e8cd89c2.entry.js → p-efe1694a.entry.js} +1 -1
  179. package/dist/solutions-components/{p-697e9e11.entry.js → p-f3467807.entry.js} +1 -1
  180. package/dist/solutions-components/{p-3cb1de38.entry.js → p-f6be44e6.entry.js} +1 -1
  181. package/dist/solutions-components/{p-f23e6499.js → p-fb7a5f6e.js} +2 -2
  182. package/dist/solutions-components/{p-dbb6f1e2.entry.js → p-ff302d95.entry.js} +1 -1
  183. package/dist/solutions-components/solutions-components.esm.js +1 -1
  184. package/dist/solutions-components/utils/interfaces.ts +4 -0
  185. package/dist/types/components/consent-manager/consent-manager.d.ts +109 -0
  186. package/dist/types/components.d.ts +62 -2
  187. package/dist/types/preact.d.ts +4 -0
  188. package/dist/types/utils/interfaces.d.ts +3 -0
  189. package/package.json +5 -2
  190. package/dist/solutions-components/p-00f9774c.js +0 -6
  191. package/dist/solutions-components/p-e1a4994d.js +0 -6
@@ -0,0 +1,1844 @@
1
+ /*!
2
+ * Copyright 2022 Esri
3
+ * Licensed under the Apache License, Version 2.0
4
+ * http://www.apache.org/licenses/LICENSE-2.0
5
+ */
6
+ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
7
+ import { g as getLocaleComponentStrings } from './locale.js';
8
+ import { g as getAugmentedNamespace, c as createCommonjsModule, a as commonjsGlobal, b as commonjsRequire } from './_commonjsHelpers.js';
9
+ import { d as defineCustomElement$a } from './action.js';
10
+ import { d as defineCustomElement$9 } from './action-menu.js';
11
+ import { d as defineCustomElement$8 } from './button.js';
12
+ import { d as defineCustomElement$7 } from './icon.js';
13
+ import { d as defineCustomElement$6 } from './link.js';
14
+ import { d as defineCustomElement$5 } from './loader.js';
15
+ import { d as defineCustomElement$4 } from './panel.js';
16
+ import { d as defineCustomElement$3 } from './popover.js';
17
+ import { d as defineCustomElement$2 } from './scrim.js';
18
+
19
+ const _nodeResolve_empty = {};
20
+
21
+ const _nodeResolve_empty$1 = /*#__PURE__*/Object.freeze({
22
+ __proto__: null,
23
+ 'default': _nodeResolve_empty
24
+ });
25
+
26
+ const require$$0 = /*@__PURE__*/getAugmentedNamespace(_nodeResolve_empty$1);
27
+
28
+ var core = createCommonjsModule(function (module, exports) {
29
+ (function (root, factory) {
30
+ {
31
+ // CommonJS
32
+ module.exports = factory();
33
+ }
34
+ }(commonjsGlobal, function () {
35
+
36
+ /*globals window, global, require*/
37
+
38
+ /**
39
+ * CryptoJS core components.
40
+ */
41
+ var CryptoJS = CryptoJS || (function (Math, undefined$1) {
42
+
43
+ var crypto;
44
+
45
+ // Native crypto from window (Browser)
46
+ if (typeof window !== 'undefined' && window.crypto) {
47
+ crypto = window.crypto;
48
+ }
49
+
50
+ // Native crypto in web worker (Browser)
51
+ if (typeof self !== 'undefined' && self.crypto) {
52
+ crypto = self.crypto;
53
+ }
54
+
55
+ // Native crypto from worker
56
+ if (typeof globalThis !== 'undefined' && globalThis.crypto) {
57
+ crypto = globalThis.crypto;
58
+ }
59
+
60
+ // Native (experimental IE 11) crypto from window (Browser)
61
+ if (!crypto && typeof window !== 'undefined' && window.msCrypto) {
62
+ crypto = window.msCrypto;
63
+ }
64
+
65
+ // Native crypto from global (NodeJS)
66
+ if (!crypto && typeof commonjsGlobal !== 'undefined' && commonjsGlobal.crypto) {
67
+ crypto = commonjsGlobal.crypto;
68
+ }
69
+
70
+ // Native crypto import via require (NodeJS)
71
+ if (!crypto && typeof commonjsRequire === 'function') {
72
+ try {
73
+ crypto = require$$0;
74
+ } catch (err) {}
75
+ }
76
+
77
+ /*
78
+ * Cryptographically secure pseudorandom number generator
79
+ *
80
+ * As Math.random() is cryptographically not safe to use
81
+ */
82
+ var cryptoSecureRandomInt = function () {
83
+ if (crypto) {
84
+ // Use getRandomValues method (Browser)
85
+ if (typeof crypto.getRandomValues === 'function') {
86
+ try {
87
+ return crypto.getRandomValues(new Uint32Array(1))[0];
88
+ } catch (err) {}
89
+ }
90
+
91
+ // Use randomBytes method (NodeJS)
92
+ if (typeof crypto.randomBytes === 'function') {
93
+ try {
94
+ return crypto.randomBytes(4).readInt32LE();
95
+ } catch (err) {}
96
+ }
97
+ }
98
+
99
+ throw new Error('Native crypto module could not be used to get secure random number.');
100
+ };
101
+
102
+ /*
103
+ * Local polyfill of Object.create
104
+
105
+ */
106
+ var create = Object.create || (function () {
107
+ function F() {}
108
+
109
+ return function (obj) {
110
+ var subtype;
111
+
112
+ F.prototype = obj;
113
+
114
+ subtype = new F();
115
+
116
+ F.prototype = null;
117
+
118
+ return subtype;
119
+ };
120
+ }());
121
+
122
+ /**
123
+ * CryptoJS namespace.
124
+ */
125
+ var C = {};
126
+
127
+ /**
128
+ * Library namespace.
129
+ */
130
+ var C_lib = C.lib = {};
131
+
132
+ /**
133
+ * Base object for prototypal inheritance.
134
+ */
135
+ var Base = C_lib.Base = (function () {
136
+
137
+
138
+ return {
139
+ /**
140
+ * Creates a new object that inherits from this object.
141
+ *
142
+ * @param {Object} overrides Properties to copy into the new object.
143
+ *
144
+ * @return {Object} The new object.
145
+ *
146
+ * @static
147
+ *
148
+ * @example
149
+ *
150
+ * var MyType = CryptoJS.lib.Base.extend({
151
+ * field: 'value',
152
+ *
153
+ * method: function () {
154
+ * }
155
+ * });
156
+ */
157
+ extend: function (overrides) {
158
+ // Spawn
159
+ var subtype = create(this);
160
+
161
+ // Augment
162
+ if (overrides) {
163
+ subtype.mixIn(overrides);
164
+ }
165
+
166
+ // Create default initializer
167
+ if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
168
+ subtype.init = function () {
169
+ subtype.$super.init.apply(this, arguments);
170
+ };
171
+ }
172
+
173
+ // Initializer's prototype is the subtype object
174
+ subtype.init.prototype = subtype;
175
+
176
+ // Reference supertype
177
+ subtype.$super = this;
178
+
179
+ return subtype;
180
+ },
181
+
182
+ /**
183
+ * Extends this object and runs the init method.
184
+ * Arguments to create() will be passed to init().
185
+ *
186
+ * @return {Object} The new object.
187
+ *
188
+ * @static
189
+ *
190
+ * @example
191
+ *
192
+ * var instance = MyType.create();
193
+ */
194
+ create: function () {
195
+ var instance = this.extend();
196
+ instance.init.apply(instance, arguments);
197
+
198
+ return instance;
199
+ },
200
+
201
+ /**
202
+ * Initializes a newly created object.
203
+ * Override this method to add some logic when your objects are created.
204
+ *
205
+ * @example
206
+ *
207
+ * var MyType = CryptoJS.lib.Base.extend({
208
+ * init: function () {
209
+ * // ...
210
+ * }
211
+ * });
212
+ */
213
+ init: function () {
214
+ },
215
+
216
+ /**
217
+ * Copies properties into this object.
218
+ *
219
+ * @param {Object} properties The properties to mix in.
220
+ *
221
+ * @example
222
+ *
223
+ * MyType.mixIn({
224
+ * field: 'value'
225
+ * });
226
+ */
227
+ mixIn: function (properties) {
228
+ for (var propertyName in properties) {
229
+ if (properties.hasOwnProperty(propertyName)) {
230
+ this[propertyName] = properties[propertyName];
231
+ }
232
+ }
233
+
234
+ // IE won't copy toString using the loop above
235
+ if (properties.hasOwnProperty('toString')) {
236
+ this.toString = properties.toString;
237
+ }
238
+ },
239
+
240
+ /**
241
+ * Creates a copy of this object.
242
+ *
243
+ * @return {Object} The clone.
244
+ *
245
+ * @example
246
+ *
247
+ * var clone = instance.clone();
248
+ */
249
+ clone: function () {
250
+ return this.init.prototype.extend(this);
251
+ }
252
+ };
253
+ }());
254
+
255
+ /**
256
+ * An array of 32-bit words.
257
+ *
258
+ * @property {Array} words The array of 32-bit words.
259
+ * @property {number} sigBytes The number of significant bytes in this word array.
260
+ */
261
+ var WordArray = C_lib.WordArray = Base.extend({
262
+ /**
263
+ * Initializes a newly created word array.
264
+ *
265
+ * @param {Array} words (Optional) An array of 32-bit words.
266
+ * @param {number} sigBytes (Optional) The number of significant bytes in the words.
267
+ *
268
+ * @example
269
+ *
270
+ * var wordArray = CryptoJS.lib.WordArray.create();
271
+ * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
272
+ * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
273
+ */
274
+ init: function (words, sigBytes) {
275
+ words = this.words = words || [];
276
+
277
+ if (sigBytes != undefined$1) {
278
+ this.sigBytes = sigBytes;
279
+ } else {
280
+ this.sigBytes = words.length * 4;
281
+ }
282
+ },
283
+
284
+ /**
285
+ * Converts this word array to a string.
286
+ *
287
+ * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
288
+ *
289
+ * @return {string} The stringified word array.
290
+ *
291
+ * @example
292
+ *
293
+ * var string = wordArray + '';
294
+ * var string = wordArray.toString();
295
+ * var string = wordArray.toString(CryptoJS.enc.Utf8);
296
+ */
297
+ toString: function (encoder) {
298
+ return (encoder || Hex).stringify(this);
299
+ },
300
+
301
+ /**
302
+ * Concatenates a word array to this word array.
303
+ *
304
+ * @param {WordArray} wordArray The word array to append.
305
+ *
306
+ * @return {WordArray} This word array.
307
+ *
308
+ * @example
309
+ *
310
+ * wordArray1.concat(wordArray2);
311
+ */
312
+ concat: function (wordArray) {
313
+ // Shortcuts
314
+ var thisWords = this.words;
315
+ var thatWords = wordArray.words;
316
+ var thisSigBytes = this.sigBytes;
317
+ var thatSigBytes = wordArray.sigBytes;
318
+
319
+ // Clamp excess bits
320
+ this.clamp();
321
+
322
+ // Concat
323
+ if (thisSigBytes % 4) {
324
+ // Copy one byte at a time
325
+ for (var i = 0; i < thatSigBytes; i++) {
326
+ var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
327
+ thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
328
+ }
329
+ } else {
330
+ // Copy one word at a time
331
+ for (var j = 0; j < thatSigBytes; j += 4) {
332
+ thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];
333
+ }
334
+ }
335
+ this.sigBytes += thatSigBytes;
336
+
337
+ // Chainable
338
+ return this;
339
+ },
340
+
341
+ /**
342
+ * Removes insignificant bits.
343
+ *
344
+ * @example
345
+ *
346
+ * wordArray.clamp();
347
+ */
348
+ clamp: function () {
349
+ // Shortcuts
350
+ var words = this.words;
351
+ var sigBytes = this.sigBytes;
352
+
353
+ // Clamp
354
+ words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
355
+ words.length = Math.ceil(sigBytes / 4);
356
+ },
357
+
358
+ /**
359
+ * Creates a copy of this word array.
360
+ *
361
+ * @return {WordArray} The clone.
362
+ *
363
+ * @example
364
+ *
365
+ * var clone = wordArray.clone();
366
+ */
367
+ clone: function () {
368
+ var clone = Base.clone.call(this);
369
+ clone.words = this.words.slice(0);
370
+
371
+ return clone;
372
+ },
373
+
374
+ /**
375
+ * Creates a word array filled with random bytes.
376
+ *
377
+ * @param {number} nBytes The number of random bytes to generate.
378
+ *
379
+ * @return {WordArray} The random word array.
380
+ *
381
+ * @static
382
+ *
383
+ * @example
384
+ *
385
+ * var wordArray = CryptoJS.lib.WordArray.random(16);
386
+ */
387
+ random: function (nBytes) {
388
+ var words = [];
389
+
390
+ for (var i = 0; i < nBytes; i += 4) {
391
+ words.push(cryptoSecureRandomInt());
392
+ }
393
+
394
+ return new WordArray.init(words, nBytes);
395
+ }
396
+ });
397
+
398
+ /**
399
+ * Encoder namespace.
400
+ */
401
+ var C_enc = C.enc = {};
402
+
403
+ /**
404
+ * Hex encoding strategy.
405
+ */
406
+ var Hex = C_enc.Hex = {
407
+ /**
408
+ * Converts a word array to a hex string.
409
+ *
410
+ * @param {WordArray} wordArray The word array.
411
+ *
412
+ * @return {string} The hex string.
413
+ *
414
+ * @static
415
+ *
416
+ * @example
417
+ *
418
+ * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
419
+ */
420
+ stringify: function (wordArray) {
421
+ // Shortcuts
422
+ var words = wordArray.words;
423
+ var sigBytes = wordArray.sigBytes;
424
+
425
+ // Convert
426
+ var hexChars = [];
427
+ for (var i = 0; i < sigBytes; i++) {
428
+ var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
429
+ hexChars.push((bite >>> 4).toString(16));
430
+ hexChars.push((bite & 0x0f).toString(16));
431
+ }
432
+
433
+ return hexChars.join('');
434
+ },
435
+
436
+ /**
437
+ * Converts a hex string to a word array.
438
+ *
439
+ * @param {string} hexStr The hex string.
440
+ *
441
+ * @return {WordArray} The word array.
442
+ *
443
+ * @static
444
+ *
445
+ * @example
446
+ *
447
+ * var wordArray = CryptoJS.enc.Hex.parse(hexString);
448
+ */
449
+ parse: function (hexStr) {
450
+ // Shortcut
451
+ var hexStrLength = hexStr.length;
452
+
453
+ // Convert
454
+ var words = [];
455
+ for (var i = 0; i < hexStrLength; i += 2) {
456
+ words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
457
+ }
458
+
459
+ return new WordArray.init(words, hexStrLength / 2);
460
+ }
461
+ };
462
+
463
+ /**
464
+ * Latin1 encoding strategy.
465
+ */
466
+ var Latin1 = C_enc.Latin1 = {
467
+ /**
468
+ * Converts a word array to a Latin1 string.
469
+ *
470
+ * @param {WordArray} wordArray The word array.
471
+ *
472
+ * @return {string} The Latin1 string.
473
+ *
474
+ * @static
475
+ *
476
+ * @example
477
+ *
478
+ * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
479
+ */
480
+ stringify: function (wordArray) {
481
+ // Shortcuts
482
+ var words = wordArray.words;
483
+ var sigBytes = wordArray.sigBytes;
484
+
485
+ // Convert
486
+ var latin1Chars = [];
487
+ for (var i = 0; i < sigBytes; i++) {
488
+ var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
489
+ latin1Chars.push(String.fromCharCode(bite));
490
+ }
491
+
492
+ return latin1Chars.join('');
493
+ },
494
+
495
+ /**
496
+ * Converts a Latin1 string to a word array.
497
+ *
498
+ * @param {string} latin1Str The Latin1 string.
499
+ *
500
+ * @return {WordArray} The word array.
501
+ *
502
+ * @static
503
+ *
504
+ * @example
505
+ *
506
+ * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
507
+ */
508
+ parse: function (latin1Str) {
509
+ // Shortcut
510
+ var latin1StrLength = latin1Str.length;
511
+
512
+ // Convert
513
+ var words = [];
514
+ for (var i = 0; i < latin1StrLength; i++) {
515
+ words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
516
+ }
517
+
518
+ return new WordArray.init(words, latin1StrLength);
519
+ }
520
+ };
521
+
522
+ /**
523
+ * UTF-8 encoding strategy.
524
+ */
525
+ var Utf8 = C_enc.Utf8 = {
526
+ /**
527
+ * Converts a word array to a UTF-8 string.
528
+ *
529
+ * @param {WordArray} wordArray The word array.
530
+ *
531
+ * @return {string} The UTF-8 string.
532
+ *
533
+ * @static
534
+ *
535
+ * @example
536
+ *
537
+ * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
538
+ */
539
+ stringify: function (wordArray) {
540
+ try {
541
+ return decodeURIComponent(escape(Latin1.stringify(wordArray)));
542
+ } catch (e) {
543
+ throw new Error('Malformed UTF-8 data');
544
+ }
545
+ },
546
+
547
+ /**
548
+ * Converts a UTF-8 string to a word array.
549
+ *
550
+ * @param {string} utf8Str The UTF-8 string.
551
+ *
552
+ * @return {WordArray} The word array.
553
+ *
554
+ * @static
555
+ *
556
+ * @example
557
+ *
558
+ * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
559
+ */
560
+ parse: function (utf8Str) {
561
+ return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
562
+ }
563
+ };
564
+
565
+ /**
566
+ * Abstract buffered block algorithm template.
567
+ *
568
+ * The property blockSize must be implemented in a concrete subtype.
569
+ *
570
+ * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
571
+ */
572
+ var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
573
+ /**
574
+ * Resets this block algorithm's data buffer to its initial state.
575
+ *
576
+ * @example
577
+ *
578
+ * bufferedBlockAlgorithm.reset();
579
+ */
580
+ reset: function () {
581
+ // Initial values
582
+ this._data = new WordArray.init();
583
+ this._nDataBytes = 0;
584
+ },
585
+
586
+ /**
587
+ * Adds new data to this block algorithm's buffer.
588
+ *
589
+ * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
590
+ *
591
+ * @example
592
+ *
593
+ * bufferedBlockAlgorithm._append('data');
594
+ * bufferedBlockAlgorithm._append(wordArray);
595
+ */
596
+ _append: function (data) {
597
+ // Convert string to WordArray, else assume WordArray already
598
+ if (typeof data == 'string') {
599
+ data = Utf8.parse(data);
600
+ }
601
+
602
+ // Append
603
+ this._data.concat(data);
604
+ this._nDataBytes += data.sigBytes;
605
+ },
606
+
607
+ /**
608
+ * Processes available data blocks.
609
+ *
610
+ * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
611
+ *
612
+ * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
613
+ *
614
+ * @return {WordArray} The processed data.
615
+ *
616
+ * @example
617
+ *
618
+ * var processedData = bufferedBlockAlgorithm._process();
619
+ * var processedData = bufferedBlockAlgorithm._process(!!'flush');
620
+ */
621
+ _process: function (doFlush) {
622
+ var processedWords;
623
+
624
+ // Shortcuts
625
+ var data = this._data;
626
+ var dataWords = data.words;
627
+ var dataSigBytes = data.sigBytes;
628
+ var blockSize = this.blockSize;
629
+ var blockSizeBytes = blockSize * 4;
630
+
631
+ // Count blocks ready
632
+ var nBlocksReady = dataSigBytes / blockSizeBytes;
633
+ if (doFlush) {
634
+ // Round up to include partial blocks
635
+ nBlocksReady = Math.ceil(nBlocksReady);
636
+ } else {
637
+ // Round down to include only full blocks,
638
+ // less the number of blocks that must remain in the buffer
639
+ nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
640
+ }
641
+
642
+ // Count words ready
643
+ var nWordsReady = nBlocksReady * blockSize;
644
+
645
+ // Count bytes ready
646
+ var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
647
+
648
+ // Process blocks
649
+ if (nWordsReady) {
650
+ for (var offset = 0; offset < nWordsReady; offset += blockSize) {
651
+ // Perform concrete-algorithm logic
652
+ this._doProcessBlock(dataWords, offset);
653
+ }
654
+
655
+ // Remove processed words
656
+ processedWords = dataWords.splice(0, nWordsReady);
657
+ data.sigBytes -= nBytesReady;
658
+ }
659
+
660
+ // Return processed words
661
+ return new WordArray.init(processedWords, nBytesReady);
662
+ },
663
+
664
+ /**
665
+ * Creates a copy of this object.
666
+ *
667
+ * @return {Object} The clone.
668
+ *
669
+ * @example
670
+ *
671
+ * var clone = bufferedBlockAlgorithm.clone();
672
+ */
673
+ clone: function () {
674
+ var clone = Base.clone.call(this);
675
+ clone._data = this._data.clone();
676
+
677
+ return clone;
678
+ },
679
+
680
+ _minBufferSize: 0
681
+ });
682
+
683
+ /**
684
+ * Abstract hasher template.
685
+ *
686
+ * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
687
+ */
688
+ C_lib.Hasher = BufferedBlockAlgorithm.extend({
689
+ /**
690
+ * Configuration options.
691
+ */
692
+ cfg: Base.extend(),
693
+
694
+ /**
695
+ * Initializes a newly created hasher.
696
+ *
697
+ * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
698
+ *
699
+ * @example
700
+ *
701
+ * var hasher = CryptoJS.algo.SHA256.create();
702
+ */
703
+ init: function (cfg) {
704
+ // Apply config defaults
705
+ this.cfg = this.cfg.extend(cfg);
706
+
707
+ // Set initial values
708
+ this.reset();
709
+ },
710
+
711
+ /**
712
+ * Resets this hasher to its initial state.
713
+ *
714
+ * @example
715
+ *
716
+ * hasher.reset();
717
+ */
718
+ reset: function () {
719
+ // Reset data buffer
720
+ BufferedBlockAlgorithm.reset.call(this);
721
+
722
+ // Perform concrete-hasher logic
723
+ this._doReset();
724
+ },
725
+
726
+ /**
727
+ * Updates this hasher with a message.
728
+ *
729
+ * @param {WordArray|string} messageUpdate The message to append.
730
+ *
731
+ * @return {Hasher} This hasher.
732
+ *
733
+ * @example
734
+ *
735
+ * hasher.update('message');
736
+ * hasher.update(wordArray);
737
+ */
738
+ update: function (messageUpdate) {
739
+ // Append
740
+ this._append(messageUpdate);
741
+
742
+ // Update the hash
743
+ this._process();
744
+
745
+ // Chainable
746
+ return this;
747
+ },
748
+
749
+ /**
750
+ * Finalizes the hash computation.
751
+ * Note that the finalize operation is effectively a destructive, read-once operation.
752
+ *
753
+ * @param {WordArray|string} messageUpdate (Optional) A final message update.
754
+ *
755
+ * @return {WordArray} The hash.
756
+ *
757
+ * @example
758
+ *
759
+ * var hash = hasher.finalize();
760
+ * var hash = hasher.finalize('message');
761
+ * var hash = hasher.finalize(wordArray);
762
+ */
763
+ finalize: function (messageUpdate) {
764
+ // Final message update
765
+ if (messageUpdate) {
766
+ this._append(messageUpdate);
767
+ }
768
+
769
+ // Perform concrete-hasher logic
770
+ var hash = this._doFinalize();
771
+
772
+ return hash;
773
+ },
774
+
775
+ blockSize: 512/32,
776
+
777
+ /**
778
+ * Creates a shortcut function to a hasher's object interface.
779
+ *
780
+ * @param {Hasher} hasher The hasher to create a helper for.
781
+ *
782
+ * @return {Function} The shortcut function.
783
+ *
784
+ * @static
785
+ *
786
+ * @example
787
+ *
788
+ * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
789
+ */
790
+ _createHelper: function (hasher) {
791
+ return function (message, cfg) {
792
+ return new hasher.init(cfg).finalize(message);
793
+ };
794
+ },
795
+
796
+ /**
797
+ * Creates a shortcut function to the HMAC's object interface.
798
+ *
799
+ * @param {Hasher} hasher The hasher to use in this HMAC helper.
800
+ *
801
+ * @return {Function} The shortcut function.
802
+ *
803
+ * @static
804
+ *
805
+ * @example
806
+ *
807
+ * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
808
+ */
809
+ _createHmacHelper: function (hasher) {
810
+ return function (message, key) {
811
+ return new C_algo.HMAC.init(hasher, key).finalize(message);
812
+ };
813
+ }
814
+ });
815
+
816
+ /**
817
+ * Algorithm namespace.
818
+ */
819
+ var C_algo = C.algo = {};
820
+
821
+ return C;
822
+ }(Math));
823
+
824
+
825
+ return CryptoJS;
826
+
827
+ }));
828
+ });
829
+
830
+ var sha256 = createCommonjsModule(function (module, exports) {
831
+ (function (root, factory) {
832
+ {
833
+ // CommonJS
834
+ module.exports = factory(core);
835
+ }
836
+ }(commonjsGlobal, function (CryptoJS) {
837
+
838
+ (function (Math) {
839
+ // Shortcuts
840
+ var C = CryptoJS;
841
+ var C_lib = C.lib;
842
+ var WordArray = C_lib.WordArray;
843
+ var Hasher = C_lib.Hasher;
844
+ var C_algo = C.algo;
845
+
846
+ // Initialization and round constants tables
847
+ var H = [];
848
+ var K = [];
849
+
850
+ // Compute constants
851
+ (function () {
852
+ function isPrime(n) {
853
+ var sqrtN = Math.sqrt(n);
854
+ for (var factor = 2; factor <= sqrtN; factor++) {
855
+ if (!(n % factor)) {
856
+ return false;
857
+ }
858
+ }
859
+
860
+ return true;
861
+ }
862
+
863
+ function getFractionalBits(n) {
864
+ return ((n - (n | 0)) * 0x100000000) | 0;
865
+ }
866
+
867
+ var n = 2;
868
+ var nPrime = 0;
869
+ while (nPrime < 64) {
870
+ if (isPrime(n)) {
871
+ if (nPrime < 8) {
872
+ H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
873
+ }
874
+ K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
875
+
876
+ nPrime++;
877
+ }
878
+
879
+ n++;
880
+ }
881
+ }());
882
+
883
+ // Reusable object
884
+ var W = [];
885
+
886
+ /**
887
+ * SHA-256 hash algorithm.
888
+ */
889
+ var SHA256 = C_algo.SHA256 = Hasher.extend({
890
+ _doReset: function () {
891
+ this._hash = new WordArray.init(H.slice(0));
892
+ },
893
+
894
+ _doProcessBlock: function (M, offset) {
895
+ // Shortcut
896
+ var H = this._hash.words;
897
+
898
+ // Working variables
899
+ var a = H[0];
900
+ var b = H[1];
901
+ var c = H[2];
902
+ var d = H[3];
903
+ var e = H[4];
904
+ var f = H[5];
905
+ var g = H[6];
906
+ var h = H[7];
907
+
908
+ // Computation
909
+ for (var i = 0; i < 64; i++) {
910
+ if (i < 16) {
911
+ W[i] = M[offset + i] | 0;
912
+ } else {
913
+ var gamma0x = W[i - 15];
914
+ var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
915
+ ((gamma0x << 14) | (gamma0x >>> 18)) ^
916
+ (gamma0x >>> 3);
917
+
918
+ var gamma1x = W[i - 2];
919
+ var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
920
+ ((gamma1x << 13) | (gamma1x >>> 19)) ^
921
+ (gamma1x >>> 10);
922
+
923
+ W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
924
+ }
925
+
926
+ var ch = (e & f) ^ (~e & g);
927
+ var maj = (a & b) ^ (a & c) ^ (b & c);
928
+
929
+ var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
930
+ var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
931
+
932
+ var t1 = h + sigma1 + ch + K[i] + W[i];
933
+ var t2 = sigma0 + maj;
934
+
935
+ h = g;
936
+ g = f;
937
+ f = e;
938
+ e = (d + t1) | 0;
939
+ d = c;
940
+ c = b;
941
+ b = a;
942
+ a = (t1 + t2) | 0;
943
+ }
944
+
945
+ // Intermediate hash value
946
+ H[0] = (H[0] + a) | 0;
947
+ H[1] = (H[1] + b) | 0;
948
+ H[2] = (H[2] + c) | 0;
949
+ H[3] = (H[3] + d) | 0;
950
+ H[4] = (H[4] + e) | 0;
951
+ H[5] = (H[5] + f) | 0;
952
+ H[6] = (H[6] + g) | 0;
953
+ H[7] = (H[7] + h) | 0;
954
+ },
955
+
956
+ _doFinalize: function () {
957
+ // Shortcuts
958
+ var data = this._data;
959
+ var dataWords = data.words;
960
+
961
+ var nBitsTotal = this._nDataBytes * 8;
962
+ var nBitsLeft = data.sigBytes * 8;
963
+
964
+ // Add padding
965
+ dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
966
+ dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
967
+ dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
968
+ data.sigBytes = dataWords.length * 4;
969
+
970
+ // Hash final blocks
971
+ this._process();
972
+
973
+ // Return final computed hash
974
+ return this._hash;
975
+ },
976
+
977
+ clone: function () {
978
+ var clone = Hasher.clone.call(this);
979
+ clone._hash = this._hash.clone();
980
+
981
+ return clone;
982
+ }
983
+ });
984
+
985
+ /**
986
+ * Shortcut function to the hasher's object interface.
987
+ *
988
+ * @param {WordArray|string} message The message to hash.
989
+ *
990
+ * @return {WordArray} The hash.
991
+ *
992
+ * @static
993
+ *
994
+ * @example
995
+ *
996
+ * var hash = CryptoJS.SHA256('message');
997
+ * var hash = CryptoJS.SHA256(wordArray);
998
+ */
999
+ C.SHA256 = Hasher._createHelper(SHA256);
1000
+
1001
+ /**
1002
+ * Shortcut function to the HMAC's object interface.
1003
+ *
1004
+ * @param {WordArray|string} message The message to hash.
1005
+ * @param {WordArray|string} key The secret key.
1006
+ *
1007
+ * @return {WordArray} The HMAC.
1008
+ *
1009
+ * @static
1010
+ *
1011
+ * @example
1012
+ *
1013
+ * var hmac = CryptoJS.HmacSHA256(message, key);
1014
+ */
1015
+ C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
1016
+ }(Math));
1017
+
1018
+
1019
+ return CryptoJS.SHA256;
1020
+
1021
+ }));
1022
+ });
1023
+
1024
+ var encHex = createCommonjsModule(function (module, exports) {
1025
+ (function (root, factory) {
1026
+ {
1027
+ // CommonJS
1028
+ module.exports = factory(core);
1029
+ }
1030
+ }(commonjsGlobal, function (CryptoJS) {
1031
+
1032
+ return CryptoJS.enc.Hex;
1033
+
1034
+ }));
1035
+ });
1036
+
1037
+ function shouldDisableTracking(options = {}) {
1038
+ const { disabled, portal } = options;
1039
+ if (disabled || (portal === null || portal === void 0 ? void 0 : portal.eueiEnabled) === false) {
1040
+ return true;
1041
+ }
1042
+ if (!portal || hasEueiEnabledAndIsMemberOfOrg(portal) || isRegisteredUserWithoutOrgInUSA(portal) || isAnonymousUserInUSA(portal)) {
1043
+ return false;
1044
+ }
1045
+ return true;
1046
+ }
1047
+ function hasEueiEnabledAndIsMemberOfOrg(portal) {
1048
+ return portal.eueiEnabled && portal.user && portal.user.orgId === portal.id;
1049
+ }
1050
+ function isRegisteredUserWithoutOrgInUSA(portal) {
1051
+ return portal.user && !portal.user.orgId && portal.ipCntryCode === 'US';
1052
+ }
1053
+ function isAnonymousUserInUSA(portal) {
1054
+ return !portal.user && portal.ipCntryCode === 'US';
1055
+ }
1056
+
1057
+ const storage = {
1058
+ storage: {},
1059
+ memory: true,
1060
+ get(key) {
1061
+ let stored;
1062
+ try {
1063
+ stored =
1064
+ (window.localStorage && window.localStorage.getItem(key)) ||
1065
+ this.storage[key];
1066
+ }
1067
+ catch (e) {
1068
+ stored = this.storage[key];
1069
+ }
1070
+ if (stored) {
1071
+ try {
1072
+ return JSON.parse(stored);
1073
+ }
1074
+ catch (e) {
1075
+ return undefined;
1076
+ }
1077
+ }
1078
+ else {
1079
+ return undefined;
1080
+ }
1081
+ },
1082
+ set(key, value) {
1083
+ // handle Safari private mode (setItem is not allowed)
1084
+ const valueToString = JSON.stringify(value);
1085
+ try {
1086
+ window.localStorage.setItem(key, valueToString);
1087
+ }
1088
+ catch (e) {
1089
+ if (!this.memory) {
1090
+ console.error('setting local storage failed, falling back to in-memory storage');
1091
+ this.memory = true;
1092
+ }
1093
+ this.storage[key] = value;
1094
+ }
1095
+ },
1096
+ delete(key) {
1097
+ try {
1098
+ window.localStorage.removeItem(key);
1099
+ }
1100
+ catch (e) {
1101
+ if (!this.memory) {
1102
+ console.error('setting local storage failed, falling back to in-memory storage');
1103
+ this.memory = true;
1104
+ }
1105
+ delete this.storage[key];
1106
+ }
1107
+ },
1108
+ };
1109
+
1110
+ const ESRI_TELEMETRY_DATA_ATTRIBUTE = 'esri-telemetry';
1111
+ function injectScriptElementAsync(attributes) {
1112
+ const onloadPromise = new Promise((resolve, reject) => {
1113
+ attributes.onload = resolve;
1114
+ attributes.onerror = reject;
1115
+ const script = injectScriptElement(attributes);
1116
+ if (!script || attributes.body) {
1117
+ // this is for the case where the script is already loaded or it has a body instead of a src
1118
+ resolve();
1119
+ }
1120
+ });
1121
+ return onloadPromise;
1122
+ }
1123
+ function scriptExists(attributes) {
1124
+ const { id, dataAttribute } = attributes;
1125
+ return !!document.getElementById(id) || !!document.querySelector(`[data-${ESRI_TELEMETRY_DATA_ATTRIBUTE}="${dataAttribute}"]`);
1126
+ }
1127
+ function injectScriptElement(attributes) {
1128
+ const { body, src, id, dataAttribute, section = 'body', type = 'text/javascript', async = false, defer = false, onload, onerror } = attributes;
1129
+ if (typeof window === 'undefined') {
1130
+ throw new WindowUndefinedError('Window is undefined: Cannot add script element.');
1131
+ }
1132
+ if (scriptExists(attributes)) {
1133
+ console.log(`script (${id || dataAttribute}) is already present, skipping`);
1134
+ return;
1135
+ }
1136
+ const scriptElement = createScriptElementWithAttributes({
1137
+ id,
1138
+ dataAttribute,
1139
+ type,
1140
+ async,
1141
+ defer,
1142
+ body,
1143
+ src,
1144
+ onload,
1145
+ onerror
1146
+ });
1147
+ return section === 'body'
1148
+ ? document.body.appendChild(scriptElement)
1149
+ : document.head.appendChild(scriptElement);
1150
+ }
1151
+ class WindowUndefinedError extends Error {
1152
+ }
1153
+ function createScriptElementWithAttributes({ id, dataAttribute, type, async, defer, body, src, onload, onerror }) {
1154
+ const scriptElement = document.createElement('script');
1155
+ if (id) {
1156
+ scriptElement.id = id;
1157
+ }
1158
+ if (dataAttribute) {
1159
+ scriptElement.setAttribute(`data-${ESRI_TELEMETRY_DATA_ATTRIBUTE}`, dataAttribute);
1160
+ }
1161
+ src && (scriptElement.src = src);
1162
+ body && (scriptElement.innerText = body);
1163
+ scriptElement.type = type;
1164
+ scriptElement.async = async;
1165
+ scriptElement.defer = defer;
1166
+ onload && (scriptElement.onload = onload);
1167
+ onerror && (scriptElement.onerror = onerror);
1168
+ return scriptElement;
1169
+ }
1170
+
1171
+ function createScriptTags(scripts) {
1172
+ return scripts.map(scriptObj => {
1173
+ const attrs = [];
1174
+ ['src', 'id', 'dataAttribute', 'type'].forEach(attr => {
1175
+ let attrName = attr;
1176
+ if (attr === 'dataAttribute') {
1177
+ attrName = 'data-esri-telemetry';
1178
+ }
1179
+ if (scriptObj[attr]) {
1180
+ attrs.push(`${attrName}="${scriptObj[attr]}"`);
1181
+ }
1182
+ });
1183
+ ['async', 'defer'].forEach(attr => {
1184
+ if (scriptObj[attr]) {
1185
+ attrs.push(`${attr}`);
1186
+ }
1187
+ });
1188
+ return `<script ${attrs.join(' ')}>${scriptObj.body ? scriptObj.body : ''}</script>`;
1189
+ }).join('');
1190
+ }
1191
+
1192
+ const INTERNAL_ORGS = [
1193
+ 'esri.com',
1194
+ 'esriuk.com',
1195
+ 'esri.de',
1196
+ 'esri.ca',
1197
+ 'esrifrance.fr',
1198
+ 'esri.nl',
1199
+ 'esri-portugal.pt',
1200
+ 'esribulgaria.com',
1201
+ 'esri.fi',
1202
+ 'esri.kr',
1203
+ 'esrimalaysia.com.my',
1204
+ 'esri.es',
1205
+ 'esriaustralia.com.au',
1206
+ 'esri-southafrica.com',
1207
+ 'esri.cl',
1208
+ 'esrichina.com.cn',
1209
+ 'esri.co',
1210
+ 'esriturkey.com.tr',
1211
+ 'geodata.no',
1212
+ 'esriitalia.it',
1213
+ 'esri.pl',
1214
+ ];
1215
+ /**
1216
+ * Telemetry class
1217
+ */
1218
+ class Telemetry {
1219
+ constructor(options) {
1220
+ var _a, _b, _c;
1221
+ this.trackers = [];
1222
+ this.options = options;
1223
+ this.debug = options.debug;
1224
+ this.suppressDisabledWarnings = options.suppressDisabledWarnings;
1225
+ this.disabled = shouldDisableTracking(options);
1226
+ this.logger = options.logger || console;
1227
+ if (this.disabled && !this.suppressDisabledWarnings) {
1228
+ this.logger.info('Telemetry Disabled');
1229
+ }
1230
+ const user = ((_a = options.portal) === null || _a === void 0 ? void 0 : _a.user) || options.user;
1231
+ if (user) {
1232
+ this.setUser(user, (_c = (_b = options.portal) === null || _b === void 0 ? void 0 : _b.subscriptionInfo) === null || _c === void 0 ? void 0 : _c.type);
1233
+ }
1234
+ if (!this.disabled) {
1235
+ this.initializeTrackers();
1236
+ }
1237
+ }
1238
+ initializeTrackers() {
1239
+ if (this.options.plugins) {
1240
+ this.trackers.push(...this.options.plugins);
1241
+ }
1242
+ if (!this.trackers.length) {
1243
+ this.logger.error(new Error('No trackers configured'));
1244
+ }
1245
+ }
1246
+ getScriptTags() {
1247
+ return this.trackers.map((tracker) => {
1248
+ return tracker.getScriptTags && tracker.getScriptTags();
1249
+ }).join('');
1250
+ }
1251
+ async init() {
1252
+ const promises = this.trackers.map((tracker) => {
1253
+ return tracker.init();
1254
+ });
1255
+ await Promise.all(promises);
1256
+ }
1257
+ setUser(user = {}, orgType = 'Public') {
1258
+ user = typeof user === 'string' ? { username: user } : user;
1259
+ this.user = user;
1260
+ this.user.accountType = orgType;
1261
+ let internalDomain;
1262
+ if (user.email && user.email.split) {
1263
+ const domain = user.email.split('@')[1];
1264
+ internalDomain =
1265
+ INTERNAL_ORGS.filter((org) => {
1266
+ return domain === org;
1267
+ }).length > 0;
1268
+ }
1269
+ if (internalDomain ||
1270
+ ['In House', 'Demo and Marketing'].indexOf(orgType) > -1) {
1271
+ this.user.internalUser = true;
1272
+ }
1273
+ }
1274
+ logPageView(page, event = {}, options = {}) {
1275
+ if (this.disabled && !this.suppressDisabledWarnings) {
1276
+ this.logger.info('Page view was not logged because telemetry is disabled.');
1277
+ return false;
1278
+ }
1279
+ const enabledTrackers = this.trackers.filter(({ disabled, hasError }) => !disabled && !hasError);
1280
+ if (!enabledTrackers.length) {
1281
+ this.logger.warn('Page view was not logged because no enabled telemetry-plugins are registered.');
1282
+ return false;
1283
+ }
1284
+ const attributes = this.preProcess(event, options);
1285
+ if (this.debug) {
1286
+ this.logger.info('Tracking page view', JSON.stringify(attributes));
1287
+ }
1288
+ const promises = enabledTrackers.map((tracker) => {
1289
+ return tracker.logPageView(page, attributes);
1290
+ });
1291
+ Promise.all(promises).then();
1292
+ return true;
1293
+ }
1294
+ logEvent(event, options = {}) {
1295
+ if (this.disabled && !this.suppressDisabledWarnings) {
1296
+ this.logger.info('Event was not logged because telemetry is disabled.');
1297
+ return false;
1298
+ }
1299
+ const enabledTrackers = this.trackers.filter(({ disabled, hasError }) => !disabled && !hasError);
1300
+ if (!enabledTrackers.length) {
1301
+ this.logger.warn('Event was not logged because no enabled telemetry-plugins are registered.');
1302
+ return false;
1303
+ }
1304
+ const eventAttributes = this.preProcess(event, options);
1305
+ if (this.debug) {
1306
+ this.logger.info('Tracking event', JSON.stringify(eventAttributes));
1307
+ }
1308
+ const promises = enabledTrackers.map((tracker) => {
1309
+ return tracker.logEvent(eventAttributes);
1310
+ });
1311
+ Promise.all(promises).then();
1312
+ return true;
1313
+ }
1314
+ logError(event = {}) {
1315
+ event = Object.assign({ eventType: 'error' }, event);
1316
+ this.logEvent(event);
1317
+ }
1318
+ startWorkflow(name, attributes = {}) {
1319
+ const workflow = {
1320
+ name,
1321
+ start: Date.now(),
1322
+ steps: [],
1323
+ workflowId: Math.floor((1 + Math.random()) * 0x100000000000).toString(16),
1324
+ };
1325
+ this.saveWorkflow(workflow);
1326
+ const workflowObj = Object.assign({ name, step: 'start' }, attributes);
1327
+ this.logWorkflow(workflowObj);
1328
+ return workflow;
1329
+ }
1330
+ stepWorkflow(name, step, attributes = {}) {
1331
+ //TODO: check if the check for attributes being a string is useful or can be removed
1332
+ const details = typeof attributes === 'string' ? attributes : attributes.details;
1333
+ const workflowObj = Object.assign({ name, step, details }, attributes);
1334
+ this.logWorkflow(workflowObj);
1335
+ }
1336
+ endWorkflow(name, attributes = {}) {
1337
+ const workflowObj = Object.assign({ name, step: 'finish' }, attributes);
1338
+ this.logWorkflow(workflowObj);
1339
+ }
1340
+ cancelWorkflow(name, attributes = {}) {
1341
+ const workflowObj = Object.assign({ name, step: 'cancel' }, attributes);
1342
+ this.logWorkflow(workflowObj);
1343
+ }
1344
+ getWorkflow(name) {
1345
+ const workflow = storage.get(`TELEMETRY-WORKFLOW:${name}`);
1346
+ // do not let old workflows be returned
1347
+ if (workflow) {
1348
+ const workflowAge = Date.now() - workflow.start;
1349
+ const timeout = 30 * 60 * 1000;
1350
+ if (workflowAge < timeout) {
1351
+ return workflow;
1352
+ }
1353
+ else {
1354
+ this.deleteWorkflow(workflow);
1355
+ }
1356
+ }
1357
+ }
1358
+ saveWorkflow(workflow) {
1359
+ storage.set(`TELEMETRY-WORKFLOW:${workflow.name}`, workflow);
1360
+ }
1361
+ deleteWorkflow(workflow) {
1362
+ storage.delete(`TELEMETRY-WORKFLOW:${workflow.name}`);
1363
+ }
1364
+ logWorkflow(options = {}) {
1365
+ /*
1366
+ const workflow = {
1367
+ name: 'add layer to map',
1368
+ step: 'start',
1369
+ details: 'some details about the step'
1370
+ }
1371
+ */
1372
+ options = this.preProcess(options);
1373
+ let workflow = this.getWorkflow(options.name);
1374
+ if (!workflow) {
1375
+ this.startWorkflow(options.name);
1376
+ workflow = this.getWorkflow(options.name);
1377
+ }
1378
+ workflow.steps.push(options.step);
1379
+ workflow.duration = (Date.now() - workflow.start) / 1000;
1380
+ if (['cancel', 'finish'].indexOf(options.step) > -1) {
1381
+ this.deleteWorkflow(workflow);
1382
+ }
1383
+ else {
1384
+ this.saveWorkflow(workflow);
1385
+ }
1386
+ const track = Object.assign(options, {
1387
+ eventType: 'workflow',
1388
+ category: options.name,
1389
+ action: options.step,
1390
+ label: options.details,
1391
+ duration: workflow.duration,
1392
+ workflowId: workflow.workflowId,
1393
+ });
1394
+ this.logEvent(track);
1395
+ }
1396
+ preProcess(event = {}, options = {}) {
1397
+ let userMetadata = {};
1398
+ if (this.user) {
1399
+ userMetadata = {
1400
+ user: anonymize(this.user.username),
1401
+ org: anonymize(this.user.orgId),
1402
+ lastLogin: this.user.lastLogin,
1403
+ userSince: this.user.created,
1404
+ internalUser: this.user.internalUser || false,
1405
+ accountType: this.user.accountType,
1406
+ };
1407
+ }
1408
+ return Object.entries(Object.assign(Object.assign({}, event), userMetadata)).reduce(makeEventPayload(options.omitComplexData, this.logger), {});
1409
+ }
1410
+ disableTracker(trackerName) {
1411
+ var _a;
1412
+ const tracker = this.trackers.find(({ name }) => name === trackerName);
1413
+ if (tracker && !tracker.hasError) {
1414
+ tracker.disabled = true;
1415
+ (_a = tracker.disable) === null || _a === void 0 ? void 0 : _a.call(tracker);
1416
+ }
1417
+ }
1418
+ enableTracker(trackerName) {
1419
+ var _a;
1420
+ const tracker = this.trackers.find(({ name }) => name === trackerName);
1421
+ if (tracker && !tracker.hasError) {
1422
+ tracker.disabled = false;
1423
+ (_a = tracker.enable) === null || _a === void 0 ? void 0 : _a.call(tracker);
1424
+ }
1425
+ }
1426
+ }
1427
+ function anonymize(user) {
1428
+ if (!user)
1429
+ return;
1430
+ return sha256(user).toString(encHex);
1431
+ }
1432
+ function makeEventPayload(omitComplexData, logger) {
1433
+ return function (acc, [key, val]) {
1434
+ if (isPrimitive(val)) {
1435
+ acc[key] = val;
1436
+ }
1437
+ else if (!omitComplexData) {
1438
+ logger.warn(`You are trying to log a non-primitive value, ${key}:${JSON.stringify(val)}. This will get logged as [object Object]`);
1439
+ acc[key] = val;
1440
+ }
1441
+ return acc;
1442
+ };
1443
+ }
1444
+ function isPrimitive(val) {
1445
+ const primitives = ['string', 'number', 'boolean', 'undefined'];
1446
+ return (primitives.includes(typeof val) ||
1447
+ (val && typeof val.valueOf() === 'string'));
1448
+ }
1449
+
1450
+ /******************************************************************************
1451
+ Copyright (c) Microsoft Corporation.
1452
+
1453
+ Permission to use, copy, modify, and/or distribute this software for any
1454
+ purpose with or without fee is hereby granted.
1455
+
1456
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1457
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1458
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1459
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1460
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1461
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1462
+ PERFORMANCE OF THIS SOFTWARE.
1463
+ ***************************************************************************** */
1464
+
1465
+ function __rest(s, e) {
1466
+ var t = {};
1467
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1468
+ t[p] = s[p];
1469
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
1470
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1471
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1472
+ t[p[i]] = s[p[i]];
1473
+ }
1474
+ return t;
1475
+ }
1476
+
1477
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1478
+ var e = new Error(message);
1479
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1480
+ };
1481
+
1482
+ /**
1483
+ * Class supporting Google Analytics 4
1484
+ */
1485
+ class GoogleAnalytics {
1486
+ constructor(options) {
1487
+ var _a;
1488
+ this.name = 'googleAnalytics';
1489
+ this.dimensions = {};
1490
+ this.metrics = {};
1491
+ if (typeof window !== 'undefined' && !((_a = options === null || options === void 0 ? void 0 : options.measurementIds) === null || _a === void 0 ? void 0 : _a.length)) {
1492
+ // browser environment
1493
+ throw new Error('at least one measurementId needs to be provided in your configuration');
1494
+ }
1495
+ Object.assign(this, options);
1496
+ }
1497
+ _getScripts() {
1498
+ const measurementId = this.measurementIds ? this.measurementIds[0] : '';
1499
+ return [
1500
+ {
1501
+ dataAttribute: 'google-analytics',
1502
+ async: true,
1503
+ src: `https://www.googletagmanager.com/gtag/js?id=${measurementId}`
1504
+ },
1505
+ ];
1506
+ }
1507
+ getScriptTags() {
1508
+ return createScriptTags(this._getScripts());
1509
+ }
1510
+ async init() {
1511
+ // for use in a broswer environment
1512
+ if (typeof window === 'undefined') {
1513
+ throw new WindowUndefinedError('Window is undefined: Cannot add script element.');
1514
+ }
1515
+ // calls _getScripts() and then iterates over the array and adds dom nodes for each and resolves once all have loaded.
1516
+ // injectScriptElementAsync will check if a script with the specified id already exists and, if so, do nothing
1517
+ await Promise.all(this._getScripts().map(scriptObj => {
1518
+ return injectScriptElementAsync(scriptObj);
1519
+ }));
1520
+ // runs second script
1521
+ this.injectConfig();
1522
+ }
1523
+ // we log page views manually, even though ga4 can do so automatically for pages now
1524
+ logPageView(page, options = {}) {
1525
+ const cleanedOptions = this.buildCustomParams(options);
1526
+ const pageViewOptionsObject = Object.assign({ page_title: page || window.location.pathname }, cleanedOptions);
1527
+ window.gtag('event', 'page_view', pageViewOptionsObject);
1528
+ return true;
1529
+ }
1530
+ logEvent(event) {
1531
+ // eventType is name of our event
1532
+ let { action } = event, customParams = __rest(event, ["action"]);
1533
+ const eventType = action || 'other';
1534
+ // if using telemetry wrapper, custom metrics/dimensions in customParams; if not, in options
1535
+ const eventParams = this.buildCustomParams(customParams);
1536
+ // should have custom metric & dimension data that looks like
1537
+ // metric_name: metric_value
1538
+ // dimension_name: dimension_value
1539
+ window.gtag('event', eventType, eventParams);
1540
+ return true;
1541
+ }
1542
+ disable() {
1543
+ if (this.measurementIds) {
1544
+ this.measurementIds.forEach(id => {
1545
+ window[`ga-disable-${id}`] = true;
1546
+ });
1547
+ }
1548
+ }
1549
+ enable() {
1550
+ if (this.measurementIds) {
1551
+ this.measurementIds.forEach(id => {
1552
+ window[`ga-disable-${id}`] = undefined;
1553
+ });
1554
+ }
1555
+ }
1556
+ // injects configs for each measurement id
1557
+ injectConfig() {
1558
+ window.dataLayer = window.dataLayer || [];
1559
+ window.gtag = function () { window.dataLayer.push(arguments); };
1560
+ window.gtag('js', new Date());
1561
+ const configOptions = {
1562
+ 'custom_map': this.createDimensionsAndMetricsCustomMap(this.dimensions, this.metrics),
1563
+ 'send_page_view': false,
1564
+ 'anonymize_ip': true // anonymize ip for each event/page view tracked
1565
+ };
1566
+ this.measurementIds.forEach(measurementId => {
1567
+ window.gtag('config', measurementId, configOptions);
1568
+ });
1569
+ }
1570
+ buildCustomParams(eventParams) {
1571
+ let cleanedEventParams;
1572
+ let { category, label } = eventParams;
1573
+ // verify that all are valid custom metrics/dimensions
1574
+ cleanedEventParams = this.verifyCustomDimensionAndMetrics(eventParams);
1575
+ // ga3 syntax uses category/action/label, which have been changed
1576
+ // to event_category, event_action, and event_label in ga4
1577
+ if (category) {
1578
+ cleanedEventParams = Object.assign(Object.assign({}, cleanedEventParams), { event_category: category });
1579
+ }
1580
+ if (label) {
1581
+ cleanedEventParams = Object.assign(Object.assign({}, cleanedEventParams), { event_label: label });
1582
+ }
1583
+ return cleanedEventParams;
1584
+ }
1585
+ verifyCustomDimensionAndMetrics(eventParams) {
1586
+ // all valid metric names and dimension names
1587
+ // since we store metrics/dimensions as dimension<index>: dimension_name, we want values
1588
+ const metricAndDimensionsMap = this.createDimensionsAndMetricsCustomMap(this.dimensions, this.metrics);
1589
+ const metricAndDimensionNames = Object.values(metricAndDimensionsMap);
1590
+ // get all keys (name of metric/dimension),
1591
+ // filter out any keys not in valid names,
1592
+ // and then recreate new object with filtered keys and values only
1593
+ const cleanedEventParams = Object.keys(eventParams)
1594
+ .filter(key => metricAndDimensionNames.includes(key))
1595
+ .reduce((cur, key) => { return Object.assign(cur, { [key]: eventParams[key] }); }, {});
1596
+ return cleanedEventParams;
1597
+ }
1598
+ createDimensionsAndMetricsCustomMap(dimensions = {}, metrics = {}) {
1599
+ const metricsMap = this.createMetricCustomMap(metrics);
1600
+ const dimensionsMap = this.createDimensionCustomMap(dimensions);
1601
+ return Object.assign(Object.assign({}, metricsMap), dimensionsMap);
1602
+ }
1603
+ // under the assumption that our metrics come like { timeMetric: 1, otherMetric: 3} where metric_name: index
1604
+ createMetricCustomMap(metrics = {}) {
1605
+ return Object.keys(metrics)
1606
+ .map(function (key) {
1607
+ return {
1608
+ // format of metric<Index>: metric_name
1609
+ key: `metric${metrics[key]}`,
1610
+ value: key
1611
+ };
1612
+ })
1613
+ .filter((val) => val)
1614
+ .reduce((acc, { key, value }) => {
1615
+ acc[key] = value;
1616
+ return acc;
1617
+ }, {});
1618
+ }
1619
+ // under the assumption that our dimensions come like { someAttribute: 7, datasetId: 6} where dimension_name: index
1620
+ createDimensionCustomMap(dimensions = {}) {
1621
+ return Object.keys(dimensions)
1622
+ .map(function (key) {
1623
+ return {
1624
+ // format of dimension<Index>: dimension_name
1625
+ key: `dimension${dimensions[key]}`,
1626
+ value: key
1627
+ };
1628
+ })
1629
+ .filter((val) => val)
1630
+ .reduce((acc, { key, value }) => {
1631
+ acc[key] = value;
1632
+ return acc;
1633
+ }, {});
1634
+ }
1635
+ }
1636
+
1637
+ const consentManagerCss = ":host{display:block}.consent-panel{position:fixed;display:block;z-index:5000;bottom:0;left:0;width:100%;height:auto;text-align:center}.cookie-consent-popup-container{position:relative;display:block;bottom:0;left:0;width:100%;margin:0;padding-top:1rem;padding-bottom:1rem;transition:transform 0.5s ease-out 0s;background-color:rgba(51, 51, 51, 0.95);color:#fff}.button-container{position:static;margin-bottom:1rem;display:flex;justify-content:center;flex-wrap:wrap}.padding-end-1{padding-inline-end:1rem}.link-text{--calcite-ui-text-link:var(--calcite-color-text-inverse);--calcite-ui-brand:var(--calcite-color-text-inverse);--calcite-color-text-link:var(--calcite-color-text-inverse);--calcite-color-brand-underline:var(--calcite-color-text-inverse);--calcite-color-brand:var(--calcite-color-text-inverse)}";
1638
+
1639
+ const ConsentManager$1 = /*@__PURE__*/ proxyCustomElement(class ConsentManager extends HTMLElement {
1640
+ constructor() {
1641
+ super();
1642
+ this.__registerHost();
1643
+ this.__attachShadow();
1644
+ this.consentGranted = createEvent(this, "consentGranted", 7);
1645
+ //--------------------------------------------------------------------------
1646
+ //
1647
+ // Properties (protected)
1648
+ //
1649
+ //--------------------------------------------------------------------------
1650
+ /**
1651
+ * boolean: When true the user has granted consent and the telemetry instance will be avaliable
1652
+ */
1653
+ this._consentGranted = false;
1654
+ /**
1655
+ * boolean: When true the telemetry instance has been loaded
1656
+ */
1657
+ this._loaded = false;
1658
+ this.firstUseVar = "solutions-first-use";
1659
+ this.measurementIds = undefined;
1660
+ this.portal = undefined;
1661
+ this._shouldRender = undefined;
1662
+ this._translations = undefined;
1663
+ }
1664
+ //--------------------------------------------------------------------------
1665
+ //
1666
+ // Watch handlers
1667
+ //
1668
+ //--------------------------------------------------------------------------
1669
+ //--------------------------------------------------------------------------
1670
+ //
1671
+ // Methods (public)
1672
+ //
1673
+ //--------------------------------------------------------------------------
1674
+ /**
1675
+ * Initialize and return the telemetry instance if consent has been granted
1676
+ */
1677
+ async getInstance() {
1678
+ if (localStorage.getItem(this.firstUseVar) === "true") {
1679
+ await this._init();
1680
+ return this._telemetryInstance;
1681
+ }
1682
+ else {
1683
+ return undefined;
1684
+ }
1685
+ }
1686
+ //--------------------------------------------------------------------------
1687
+ //
1688
+ // Functions (lifecycle)
1689
+ //
1690
+ //--------------------------------------------------------------------------
1691
+ /**
1692
+ * StencilJS: Called once just after the component is first connected to the DOM.
1693
+ *
1694
+ * @returns Promise when complete
1695
+ */
1696
+ async componentWillLoad() {
1697
+ await this._getTranslations();
1698
+ this._shouldRender = localStorage.getItem(this.firstUseVar) === null;
1699
+ }
1700
+ /**
1701
+ * Renders the component.
1702
+ */
1703
+ render() {
1704
+ return this._shouldRender ? (h(Host, null, h("calcite-panel", { class: "consent-panel calcite-mode-dark", id: "cookie-policy" }, h("div", { class: "cookie-consent-popup-container" }, h("div", { id: "cookie-policy-description-top", tabindex: "-1" }, h("p", null, this._translations.dearVisitor), h("p", null, this._translations.useAnalytics)), h("div", { class: "button-container" }, h("calcite-button", { appearance: "solid", class: "padding-end-1", kind: "brand", onClick: () => this._refuse() }, this._translations.refuseAnalytics), h("calcite-button", { appearance: "solid", kind: "brand", onClick: () => this._accept() }, this._translations.acceptAnalytics)), h("div", null, h("p", null, this._translations.moreInfo, "\u00A0", h("calcite-link", { class: "link-text", href: "https://www.arcgis.com/", rel: "noopener noreferrer", target: "_blank" }, this._translations.protectionPolicy), this._translations.our, "\u00A0", h("calcite-link", { class: "link-text", href: "https://www.arcgis.com/", rel: "noopener noreferrer", target: "_blank" }, this._translations.cookiePolicy, "\u00A0"), this._translations.andOur, "\u00A0", h("calcite-link", { class: "link-text", href: "https://www.arcgis.com/", rel: "noopener noreferrer", target: "_blank" }, this._translations.cookiesInventory))))))) : undefined;
1705
+ }
1706
+ //--------------------------------------------------------------------------
1707
+ //
1708
+ // Functions (protected)
1709
+ //
1710
+ //--------------------------------------------------------------------------
1711
+ /**
1712
+ * Fetches the component's translations
1713
+ *
1714
+ * @returns Promise when complete
1715
+ * @protected
1716
+ */
1717
+ async _init() {
1718
+ var _a;
1719
+ if (!this._loaded && ((_a = this.measurementIds) === null || _a === void 0 ? void 0 : _a.length) > 0 && this.portal) {
1720
+ const googleAnalyticsTracker = new GoogleAnalytics({
1721
+ measurementIds: this.measurementIds
1722
+ });
1723
+ this._telemetryInstance = new Telemetry({
1724
+ plugins: [googleAnalyticsTracker],
1725
+ portal: this.portal
1726
+ });
1727
+ await this._telemetryInstance.init();
1728
+ this._loaded = true;
1729
+ }
1730
+ }
1731
+ /**
1732
+ * Store the users granting of consent
1733
+ *
1734
+ * @protected
1735
+ */
1736
+ _accept() {
1737
+ this._consentGranted = true;
1738
+ this._handleConsent();
1739
+ }
1740
+ /**
1741
+ * Store the users refusal of consent
1742
+ *
1743
+ * @protected
1744
+ */
1745
+ _refuse() {
1746
+ this._consentGranted = false;
1747
+ this._handleConsent();
1748
+ }
1749
+ /**
1750
+ * Store and emit the users choice for consent
1751
+ *
1752
+ * @protected
1753
+ */
1754
+ _handleConsent() {
1755
+ this._shouldRender = false;
1756
+ localStorage.setItem(this.firstUseVar, this._consentGranted.toString());
1757
+ this.consentGranted.emit({
1758
+ granted: this._consentGranted
1759
+ });
1760
+ }
1761
+ /**
1762
+ * Fetches the component's translations
1763
+ *
1764
+ * @returns Promise when complete
1765
+ * @protected
1766
+ */
1767
+ async _getTranslations() {
1768
+ const messages = await getLocaleComponentStrings(this.el);
1769
+ this._translations = messages[0];
1770
+ }
1771
+ get el() { return this; }
1772
+ static get style() { return consentManagerCss; }
1773
+ }, [1, "consent-manager", {
1774
+ "firstUseVar": [1, "first-use-var"],
1775
+ "measurementIds": [16],
1776
+ "portal": [16],
1777
+ "_shouldRender": [32],
1778
+ "_translations": [32],
1779
+ "getInstance": [64]
1780
+ }]);
1781
+ function defineCustomElement$1() {
1782
+ if (typeof customElements === "undefined") {
1783
+ return;
1784
+ }
1785
+ const components = ["consent-manager", "calcite-action", "calcite-action-menu", "calcite-button", "calcite-icon", "calcite-link", "calcite-loader", "calcite-panel", "calcite-popover", "calcite-scrim"];
1786
+ components.forEach(tagName => { switch (tagName) {
1787
+ case "consent-manager":
1788
+ if (!customElements.get(tagName)) {
1789
+ customElements.define(tagName, ConsentManager$1);
1790
+ }
1791
+ break;
1792
+ case "calcite-action":
1793
+ if (!customElements.get(tagName)) {
1794
+ defineCustomElement$a();
1795
+ }
1796
+ break;
1797
+ case "calcite-action-menu":
1798
+ if (!customElements.get(tagName)) {
1799
+ defineCustomElement$9();
1800
+ }
1801
+ break;
1802
+ case "calcite-button":
1803
+ if (!customElements.get(tagName)) {
1804
+ defineCustomElement$8();
1805
+ }
1806
+ break;
1807
+ case "calcite-icon":
1808
+ if (!customElements.get(tagName)) {
1809
+ defineCustomElement$7();
1810
+ }
1811
+ break;
1812
+ case "calcite-link":
1813
+ if (!customElements.get(tagName)) {
1814
+ defineCustomElement$6();
1815
+ }
1816
+ break;
1817
+ case "calcite-loader":
1818
+ if (!customElements.get(tagName)) {
1819
+ defineCustomElement$5();
1820
+ }
1821
+ break;
1822
+ case "calcite-panel":
1823
+ if (!customElements.get(tagName)) {
1824
+ defineCustomElement$4();
1825
+ }
1826
+ break;
1827
+ case "calcite-popover":
1828
+ if (!customElements.get(tagName)) {
1829
+ defineCustomElement$3();
1830
+ }
1831
+ break;
1832
+ case "calcite-scrim":
1833
+ if (!customElements.get(tagName)) {
1834
+ defineCustomElement$2();
1835
+ }
1836
+ break;
1837
+ } });
1838
+ }
1839
+ defineCustomElement$1();
1840
+
1841
+ const ConsentManager = ConsentManager$1;
1842
+ const defineCustomElement = defineCustomElement$1;
1843
+
1844
+ export { ConsentManager, defineCustomElement };