@esri/solutions-components 0.7.52 → 0.8.0

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