@leed-ai/cli 0.0.0-stage → 6.19.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 (263) hide show
  1. package/LICENSE.md +57 -0
  2. package/README.md +125 -2
  3. package/dist/LICENSE.md +57 -0
  4. package/dist/acorn-DAgDT1om.js +5087 -0
  5. package/dist/angular-l0_4PK8N.js +3598 -0
  6. package/dist/authShared-Dray38Ls.js +1161 -0
  7. package/dist/babel-CJeRQd5u.js +10038 -0
  8. package/dist/buildResults-tiq1nugP.js +21180 -0
  9. package/dist/chunk-1VJ9lAw7.js +42 -0
  10. package/dist/cliAuth-38JjD6hw.js +15 -0
  11. package/dist/env-B0bHiXJJ.js +29 -0
  12. package/dist/errors-CqKamGCu.js +481 -0
  13. package/dist/estree-E8WG8UHj.js +6930 -0
  14. package/dist/flow-6xaRIbPQ.js +52255 -0
  15. package/dist/glimmer-aJPjsfbT.js +7272 -0
  16. package/dist/graphql-mcgtPEiZ.js +1901 -0
  17. package/dist/html--eeea3Kl.js +6553 -0
  18. package/dist/leed.eleventy.mjs +6525 -0
  19. package/dist/leed.mjs +88952 -0
  20. package/dist/leed.sources.json +798 -0
  21. package/dist/leedLogger-Zkada5aO.js +78 -0
  22. package/dist/markdown-D73jNKwx.js +6836 -0
  23. package/dist/meriyah-CMp1nDDW.js +8932 -0
  24. package/dist/package.json +101 -0
  25. package/dist/postcss-h4fBr2Fn.js +6760 -0
  26. package/dist/prettier-CwFSKxfN.js +16821 -0
  27. package/dist/static/customer-site-worker/package.json +9 -0
  28. package/dist/static/customer-site-worker/src/assetsHydration.ts +55 -0
  29. package/dist/static/customer-site-worker/src/constants.ts +20 -0
  30. package/dist/static/customer-site-worker/src/cors.ts +120 -0
  31. package/dist/static/customer-site-worker/src/index.ts +242 -0
  32. package/dist/static/customer-site-worker/src/mcp-proxy.ts +98 -0
  33. package/dist/static/customer-site-worker/src/proxy.ts +92 -0
  34. package/dist/static/customer-site-worker/src/proxyHeaders.ts +47 -0
  35. package/dist/static/customer-site-worker/src/tier.ts +40 -0
  36. package/dist/static/customer-site-worker/src/types.ts +82 -0
  37. package/dist/static/customer-site-worker/test/functions-mock.worker.js +50 -0
  38. package/dist/static/customer-site-worker/tsconfig.json +19 -0
  39. package/dist/static/customer-site-worker/vitest.workers.config.ts +61 -0
  40. package/dist/static/install/husky/colors.mjs +5 -0
  41. package/dist/static/install/husky/hooks/commit-msg +1 -0
  42. package/dist/static/install/husky/hooks/pre-commit +1 -0
  43. package/dist/static/install/husky/hooks/pre-push +1 -0
  44. package/dist/static/install/husky/valid-command.mjs +29 -0
  45. package/dist/static/install/husky/valid-commit-msg.mjs +20 -0
  46. package/dist/static/install/package.json +10 -0
  47. package/dist/static/install/packages.txt +4 -0
  48. package/dist/static/install/tasks.json +111 -0
  49. package/dist/static/javascript/detectIncognito.js +195 -0
  50. package/dist/static/javascript/documentation.js +2781 -0
  51. package/dist/static/javascript/fp/fp.esm.js +2896 -0
  52. package/dist/static/javascript/fp/fp.js +3067 -0
  53. package/dist/static/javascript/live-search.js +986 -0
  54. package/dist/static/javascript/lunr-search.js +843 -0
  55. package/dist/static/javascript/timeme.js +451 -0
  56. package/dist/static/javascript/tracker/webmcp.js +67 -0
  57. package/dist/static/javascript/tracker/whisper.js +1 -0
  58. package/dist/static/javascript/utilities.js +819 -0
  59. package/dist/static/javascript/versions.json +74 -0
  60. package/dist/static/javascript/zoomable.js +488 -0
  61. package/dist/static/site/_data/eleventyComputed.js +228 -0
  62. package/dist/static/site/_data/leed-form-data.json +253 -0
  63. package/dist/static/site/_includes/leed/api/bits/array-type.hbs +24 -0
  64. package/dist/static/site/_includes/leed/api/bits/badges.hbs +9 -0
  65. package/dist/static/site/_includes/leed/api/bits/description.hbs +9 -0
  66. package/dist/static/site/_includes/leed/api/bits/examples.hbs +42 -0
  67. package/dist/static/site/_includes/leed/api/bits/scopes.hbs +28 -0
  68. package/dist/static/site/_includes/leed/api/object.hbs +110 -0
  69. package/dist/static/site/_includes/leed/api/parameters.hbs +11 -0
  70. package/dist/static/site/_includes/leed/api/property.hbs +153 -0
  71. package/dist/static/site/_includes/leed/api/request-body.hbs +51 -0
  72. package/dist/static/site/_includes/leed/api/responses.hbs +89 -0
  73. package/dist/static/site/_includes/leed/api/security-constraints.hbs +59 -0
  74. package/dist/static/site/_includes/leed/api/security.hbs +75 -0
  75. package/dist/static/site/_includes/leed/components/pagination.hbs +45 -0
  76. package/dist/static/site/_includes/leed/components/scroll-status-indicator-horizontal.hbs +22 -0
  77. package/dist/static/site/_includes/leed/docs/alpha/api.hbs +6 -0
  78. package/dist/static/site/_includes/leed/docs/alpha/base.hbs +26 -0
  79. package/dist/static/site/_includes/leed/docs/alpha/documentation.hbs +7 -0
  80. package/dist/static/site/_includes/leed/docs/api-article.hbs +75 -0
  81. package/dist/static/site/_includes/leed/docs/bravo/api.hbs +5 -0
  82. package/dist/static/site/_includes/leed/docs/bravo/base.hbs +31 -0
  83. package/dist/static/site/_includes/leed/docs/bravo/documentation.hbs +7 -0
  84. package/dist/static/site/_includes/leed/docs/charlie/api.hbs +6 -0
  85. package/dist/static/site/_includes/leed/docs/charlie/base.hbs +27 -0
  86. package/dist/static/site/_includes/leed/docs/charlie/documentation.hbs +10 -0
  87. package/dist/static/site/_includes/leed/docs/doc-article.hbs +40 -0
  88. package/dist/static/site/_includes/leed/docs/docs-footer.hbs +35 -0
  89. package/dist/static/site/_includes/leed/docs/docs-header.hbs +59 -0
  90. package/dist/static/site/_includes/leed/docs/document-search-modal.hbs +36 -0
  91. package/dist/static/site/_includes/leed/docs/document-search.hbs +23 -0
  92. package/dist/static/site/_includes/leed/docs/footer.hbs +12 -0
  93. package/dist/static/site/_includes/leed/docs/header/brand.hbs +19 -0
  94. package/dist/static/site/_includes/leed/docs/header/chrome.hbs +33 -0
  95. package/dist/static/site/_includes/leed/docs/header/compact.hbs +19 -0
  96. package/dist/static/site/_includes/leed/docs/header/cta.hbs +15 -0
  97. package/dist/static/site/_includes/leed/docs/header/nav.hbs +18 -0
  98. package/dist/static/site/_includes/leed/docs/header/top-search.hbs +15 -0
  99. package/dist/static/site/_includes/leed/docs/mini-bar.hbs +53 -0
  100. package/dist/static/site/_includes/leed/docs/pagination.hbs +19 -0
  101. package/dist/static/site/_includes/leed/docs/shell.hbs +56 -0
  102. package/dist/static/site/_includes/leed/docs/sidebar.hbs +52 -0
  103. package/dist/static/site/_includes/leed/docs/social-icons.hbs +81 -0
  104. package/dist/static/site/_includes/leed/docs/style.hbs +17 -0
  105. package/dist/static/site/_includes/leed/docs/toc.hbs +7 -0
  106. package/dist/static/site/_includes/leed/form.hbs +266 -0
  107. package/dist/static/site/_includes/leed/head.hbs +67 -0
  108. package/dist/static/site/_includes/leed/menu/builder.hbs +35 -0
  109. package/dist/static/site/_includes/leed/menu/item.hbs +67 -0
  110. package/dist/static/site/_includes/leed/menu/link.hbs +59 -0
  111. package/dist/static/site/_includes/leed/metadata/ogCard.hbs +40 -0
  112. package/dist/static/site/_includes/leed/metadata/siteMetadata.hbs +24 -0
  113. package/dist/static/site/_includes/leed/metadata/twitterCard.hbs +34 -0
  114. package/dist/static/site/_includes/leed/popup-video.hbs +21 -0
  115. package/dist/static/site/_includes/leed/stub-template.hbs +17 -0
  116. package/dist/static/site/_includes/leed/unsubscribe-form.hbs +30 -0
  117. package/dist/static/site/_layouts/leed-documentation.hbs +12 -0
  118. package/dist/static/site/leed-feed-atom.hbs +42 -0
  119. package/dist/static/site/leed-feed-json.hbs +56 -0
  120. package/dist/static/site/leed-feed-rss.hbs +39 -0
  121. package/dist/static/site/leed-headers.hbs +38 -0
  122. package/dist/static/site/leed-redirects.hbs +10 -0
  123. package/dist/static/site/leed-sitemap-pageType.hbs +28 -0
  124. package/dist/static/site/leed-sitemap.hbs +19 -0
  125. package/dist/static/site/leed-unsubscribe.hbs +44 -0
  126. package/dist/static/site/leed-unsubscribed.hbs +40 -0
  127. package/dist/static/tailwind/components/alerts.css +132 -0
  128. package/dist/static/tailwind/components/api-methods.css +39 -0
  129. package/dist/static/tailwind/components/breadcrumbs.css +31 -0
  130. package/dist/static/tailwind/components/code.css +88 -0
  131. package/dist/static/tailwind/components/collapsible.css +38 -0
  132. package/dist/static/tailwind/components/document-search.css +222 -0
  133. package/dist/static/tailwind/components/form.css +185 -0
  134. package/dist/static/tailwind/components/kbd.css +7 -0
  135. package/dist/static/tailwind/components/pagination.css +81 -0
  136. package/dist/static/tailwind/components/scroll-status-indicator.css +5 -0
  137. package/dist/static/tailwind/components/tab-groups.css +117 -0
  138. package/dist/static/tailwind/components/tables.css +0 -0
  139. package/dist/static/tailwind/components/toc.css +60 -0
  140. package/dist/static/tailwind/components.css +248 -0
  141. package/dist/static/tailwind/defaults.css +260 -0
  142. package/dist/static/tailwind/docs/api.css +701 -0
  143. package/dist/static/tailwind/docs/components/blockquote.css +5 -0
  144. package/dist/static/tailwind/docs/components/button.css +11 -0
  145. package/dist/static/tailwind/docs/components/docs-pagination.css +71 -0
  146. package/dist/static/tailwind/docs/components/mobile-bar.css +83 -0
  147. package/dist/static/tailwind/docs/components/navigation.css +279 -0
  148. package/dist/static/tailwind/docs/components/table.css +54 -0
  149. package/dist/static/tailwind/docs/components.css +6 -0
  150. package/dist/static/tailwind/docs/docs.css +427 -0
  151. package/dist/static/tailwind/docs/layouts/alpha.css +108 -0
  152. package/dist/static/tailwind/docs/layouts/bravo.css +218 -0
  153. package/dist/static/tailwind/docs/layouts/charlie.css +105 -0
  154. package/dist/static/tailwind/docs/layouts.css +3 -0
  155. package/dist/static/tailwind/docs/themes/amber.css +113 -0
  156. package/dist/static/tailwind/docs/themes/blue.css +94 -0
  157. package/dist/static/tailwind/docs/themes/cyan.css +111 -0
  158. package/dist/static/tailwind/docs/themes/emerald.css +111 -0
  159. package/dist/static/tailwind/docs/themes/fuchsia.css +111 -0
  160. package/dist/static/tailwind/docs/themes/green.css +95 -0
  161. package/dist/static/tailwind/docs/themes/indigo.css +111 -0
  162. package/dist/static/tailwind/docs/themes/lime.css +111 -0
  163. package/dist/static/tailwind/docs/themes/orange.css +111 -0
  164. package/dist/static/tailwind/docs/themes/pink.css +111 -0
  165. package/dist/static/tailwind/docs/themes/purple.css +111 -0
  166. package/dist/static/tailwind/docs/themes/red.css +111 -0
  167. package/dist/static/tailwind/docs/themes/rose.css +111 -0
  168. package/dist/static/tailwind/docs/themes/sky.css +111 -0
  169. package/dist/static/tailwind/docs/themes/teal.css +111 -0
  170. package/dist/static/tailwind/docs/themes/violet.css +111 -0
  171. package/dist/static/tailwind/docs/themes/yellow.css +111 -0
  172. package/dist/static/tailwind/docs/themes.css +84 -0
  173. package/dist/static/tailwind/font-awesome/free-7.3.1/brands.css +2455 -0
  174. package/dist/static/tailwind/font-awesome/free-7.3.1/fontawesome.css +8997 -0
  175. package/dist/static/tailwind/font-awesome/free-7.3.1/fonts.css +45 -0
  176. package/dist/static/tailwind/font-awesome/free-7.3.1/icons.json +2608 -0
  177. package/dist/static/tailwind/font-awesome/free-7.3.1.css +3 -0
  178. package/dist/static/tailwind/font-awesome/pro-7.0.0/brands.css +2215 -0
  179. package/dist/static/tailwind/font-awesome/pro-7.0.0/fontawesome.css +19281 -0
  180. package/dist/static/tailwind/font-awesome/pro-7.0.0/fonts.css +445 -0
  181. package/dist/static/tailwind/font-awesome/pro-7.0.0.css +3 -0
  182. package/dist/static/tailwind/font-awesome/pro-7.3.1/brands.css +2455 -0
  183. package/dist/static/tailwind/font-awesome/pro-7.3.1/fontawesome.css +20365 -0
  184. package/dist/static/tailwind/font-awesome/pro-7.3.1/fonts.css +589 -0
  185. package/dist/static/tailwind/font-awesome/pro-7.3.1.css +3 -0
  186. package/dist/static/tailwind/fonts/all.css +6 -0
  187. package/dist/static/tailwind/fonts/config.jsonc +31 -0
  188. package/dist/static/tailwind/fonts/geist-mono.css +142 -0
  189. package/dist/static/tailwind/fonts/geist.css +142 -0
  190. package/dist/static/tailwind/fonts/inter.css +215 -0
  191. package/dist/static/tailwind/fonts/jetbrains-mono.css +126 -0
  192. package/dist/static/tailwind/fonts/noto-sans.css +134 -0
  193. package/dist/static/tailwind/fonts/open-sans.css +89 -0
  194. package/dist/static/tailwind/highlighters.css +14 -0
  195. package/dist/static/tailwind/hljs/README.md +53 -0
  196. package/dist/static/tailwind/hljs/a11y.css +96 -0
  197. package/dist/static/tailwind/hljs/atom-fruit.css +90 -0
  198. package/dist/static/tailwind/hljs/atom-one.css +164 -0
  199. package/dist/static/tailwind/hljs/default.css +164 -0
  200. package/dist/static/tailwind/hljs/github.css +101 -0
  201. package/dist/static/tailwind/hljs/google-code.css +112 -0
  202. package/dist/static/tailwind/hljs/grayscale.css +115 -0
  203. package/dist/static/tailwind/hljs/gruvbox-hard.css +115 -0
  204. package/dist/static/tailwind/hljs/gruvbox-medium.css +115 -0
  205. package/dist/static/tailwind/hljs/gruvbox-soft.css +115 -0
  206. package/dist/static/tailwind/hljs/papercolor.css +120 -0
  207. package/dist/static/tailwind/hljs/qt-creator.css +91 -0
  208. package/dist/static/tailwind/hljs/summerfruit.css +115 -0
  209. package/dist/static/tailwind/hljs/tomorrow.css +115 -0
  210. package/dist/static/tailwind/leed.css +170 -0
  211. package/dist/static/tailwind/site-tokens.reference.css +105 -0
  212. package/dist/static/tailwind/utils/icons.css +102 -0
  213. package/dist/static/tailwind/utils/utilities.css +105 -0
  214. package/dist/static/templates/pages/PAGE.hbs +27 -0
  215. package/dist/static/templates/pages/PAGE_LAYOUT.hbs +19 -0
  216. package/dist/static/templates/pages/PAGE_TYPE_INDEX.hbs +89 -0
  217. package/dist/static/templates/pages/PAGINATED_PAGE_TYPE_ITEM.hbs +52 -0
  218. package/dist/static/templates/pages/PAGINATED_PAGE_TYPE_LIST.hbs +39 -0
  219. package/dist/static/templates/pages/PAGINATED_PAGE_TYPE_PAGINATION.hbs +11 -0
  220. package/dist/static/templates/raw-content/.ci/build.sh +58 -0
  221. package/dist/static/templates/raw-content/README.md +179 -0
  222. package/dist/static/templates/raw-content/_gitignore +50 -0
  223. package/dist/static/templates/raw-content/src/404.hbs +21 -0
  224. package/dist/static/templates/raw-content/src/_data/autolink.json +1 -0
  225. package/dist/static/templates/raw-content/src/_data/ctaList.json +1 -0
  226. package/dist/static/templates/raw-content/src/_data/leedForms.json +1 -0
  227. package/dist/static/templates/raw-content/src/_data/menu.json +1 -0
  228. package/dist/static/templates/raw-content/src/_includes/footer.hbs +18 -0
  229. package/dist/static/templates/raw-content/src/_includes/header-includes.hbs +25 -0
  230. package/dist/static/templates/raw-content/src/_includes/header.hbs +5 -0
  231. package/dist/static/templates/raw-content/src/_includes/site-template.hbs +23 -0
  232. package/dist/static/templates/raw-content/src/_includes/unsubscribe-DISABLED.hbs +17 -0
  233. package/dist/static/templates/raw-content/src/_includes/unsubscribed-DISABLED.hbs +13 -0
  234. package/dist/static/templates/raw-content/src/_layouts/empty.hbs +2 -0
  235. package/dist/static/templates/raw-content/src/index.hbs +21 -0
  236. package/dist/static/templates/raw-content/src/robots.hbs +9 -0
  237. package/dist/static/templates/raw-content/tailwind/site/base.css +44 -0
  238. package/dist/static/templates/raw-content/tailwind/site.config.css +3 -0
  239. package/dist/static/templates/sandbox/_gitignore +50 -0
  240. package/dist/static/templates/sandbox/identity.json +1 -0
  241. package/dist/static/templates/sandbox/src/404.hbs +21 -0
  242. package/dist/static/templates/sandbox/src/_data/autolink.json +1 -0
  243. package/dist/static/templates/sandbox/src/_data/ctaList.json +1 -0
  244. package/dist/static/templates/sandbox/src/_data/labelList.json +9 -0
  245. package/dist/static/templates/sandbox/src/_data/leedForms.json +20 -0
  246. package/dist/static/templates/sandbox/src/_data/menu.json +19 -0
  247. package/dist/static/templates/sandbox/src/_data/pageTypeList.json +14 -0
  248. package/dist/static/templates/sandbox/src/_data/searchIndexList.json +1 -0
  249. package/dist/static/templates/sandbox/src/_data/userList.json +11 -0
  250. package/dist/static/templates/sandbox/src/_includes/footer.hbs +18 -0
  251. package/dist/static/templates/sandbox/src/_includes/header-includes.hbs +25 -0
  252. package/dist/static/templates/sandbox/src/_includes/header.hbs +5 -0
  253. package/dist/static/templates/sandbox/src/_includes/site-template.hbs +23 -0
  254. package/dist/static/templates/sandbox/src/_layouts/empty.hbs +2 -0
  255. package/dist/static/templates/sandbox/src/index.hbs +20 -0
  256. package/dist/static/templates/sandbox/src/robots.hbs +9 -0
  257. package/dist/static/templates/sandbox/src/src.11tydata.json +39 -0
  258. package/dist/static/templates/sandbox/tailwind/site/base.css +44 -0
  259. package/dist/static/templates/sandbox/tailwind/site.config.css +3 -0
  260. package/dist/thrown-sukVkp_1.js +113 -0
  261. package/dist/typescript-D4T0V_Hn.js +23004 -0
  262. package/dist/yaml-9wR8GxF_.js +5236 -0
  263. package/package.json +157 -4
@@ -0,0 +1,2896 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * FingerprintJS v3.4.2 - Copyright (c) FingerprintJS, Inc, 2023 (https://fingerprint.com)
4
+ * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
5
+ *
6
+ * This software contains code from open-source projects:
7
+ * MurmurHash3 by Karan Lyons (https://github.com/karanlyons/murmurHash3.js)
8
+ */
9
+
10
+ import { __awaiter, __generator, __assign, __spreadArray } from "tslib";
11
+
12
+ var version = "3.4.2";
13
+
14
+ function wait(durationMs, resolveWith) {
15
+ return new Promise(function (resolve) {
16
+ return setTimeout(resolve, durationMs, resolveWith);
17
+ });
18
+ }
19
+ function requestIdleCallbackIfAvailable(fallbackTimeout, deadlineTimeout) {
20
+ if (deadlineTimeout === void 0) {
21
+ deadlineTimeout = Infinity;
22
+ }
23
+ var requestIdleCallback = window.requestIdleCallback;
24
+ if (requestIdleCallback) {
25
+ // The function `requestIdleCallback` loses the binding to `window` here.
26
+ // `globalThis` isn't always equal `window` (see https://github.com/fingerprintjs/fingerprintjs/issues/683).
27
+ // Therefore, an error can occur. `call(window,` prevents the error.
28
+ return new Promise(function (resolve) {
29
+ return requestIdleCallback.call(
30
+ window,
31
+ function () {
32
+ return resolve();
33
+ },
34
+ { timeout: deadlineTimeout },
35
+ );
36
+ });
37
+ }
38
+ else {
39
+ return wait(Math.min(fallbackTimeout, deadlineTimeout));
40
+ }
41
+ }
42
+ function isPromise(value) {
43
+ return !!value && typeof value.then === "function";
44
+ }
45
+ /**
46
+ * Calls a maybe asynchronous function without creating microtasks when the function is synchronous.
47
+ * Catches errors in both cases.
48
+ *
49
+ * If just you run a code like this:
50
+ * ```
51
+ * console.time('Action duration')
52
+ * await action()
53
+ * console.timeEnd('Action duration')
54
+ * ```
55
+ * The synchronous function time can be measured incorrectly because another microtask may run before the `await`
56
+ * returns the control back to the code.
57
+ */
58
+ function awaitIfAsync(action, callback) {
59
+ try {
60
+ var returnedValue = action();
61
+ if (isPromise(returnedValue)) {
62
+ returnedValue.then(
63
+ function (result) {
64
+ return callback(true, result);
65
+ },
66
+ function (error) {
67
+ return callback(false, error);
68
+ },
69
+ );
70
+ }
71
+ else {
72
+ callback(true, returnedValue);
73
+ }
74
+ }
75
+ catch (error) {
76
+ callback(false, error);
77
+ }
78
+ }
79
+ /**
80
+ * If you run many synchronous tasks without using this function, the JS main loop will be busy and asynchronous tasks
81
+ * (e.g. completing a network request, rendering the page) won't be able to happen.
82
+ * This function allows running many synchronous tasks such way that asynchronous tasks can run too in background.
83
+ */
84
+ function mapWithBreaks(items, callback, loopReleaseInterval) {
85
+ if (loopReleaseInterval === void 0) {
86
+ loopReleaseInterval = 16;
87
+ }
88
+ return __awaiter(this, void 0, void 0, function () {
89
+ var results, lastLoopReleaseTime, i, now;
90
+ return __generator(this, function (_a) {
91
+ switch (_a.label) {
92
+ case 0:
93
+ results = Array(items.length);
94
+ lastLoopReleaseTime = Date.now();
95
+ i = 0;
96
+ _a.label = 1;
97
+ case 1:
98
+ if (!(i < items.length)) return [3 /*break*/, 4];
99
+ results[i] = callback(items[i], i);
100
+ now = Date.now();
101
+ if (!(now >= lastLoopReleaseTime + loopReleaseInterval)) return [3 /*break*/, 3];
102
+ lastLoopReleaseTime = now;
103
+ // Allows asynchronous actions and microtasks to happen
104
+ return [4 /*yield*/, wait(0)];
105
+ case 2:
106
+ // Allows asynchronous actions and microtasks to happen
107
+ _a.sent();
108
+ _a.label = 3;
109
+ case 3:
110
+ ++i;
111
+ return [3 /*break*/, 1];
112
+ case 4:
113
+ return [2 /*return*/, results];
114
+ }
115
+ });
116
+ });
117
+ }
118
+ /**
119
+ * Makes the given promise never emit an unhandled promise rejection console warning.
120
+ * The promise will still pass errors to the next promises.
121
+ *
122
+ * Otherwise, promise emits a console warning unless it has a `catch` listener.
123
+ */
124
+ function suppressUnhandledRejectionWarning(promise) {
125
+ promise.then(undefined, function () {
126
+ return undefined;
127
+ });
128
+ }
129
+
130
+ /*
131
+ * Taken from https://github.com/karanlyons/murmurHash3.js/blob/a33d0723127e2e5415056c455f8aed2451ace208/murmurHash3.js
132
+ */
133
+ //
134
+ // Given two 64bit ints (as an array of two 32bit ints) returns the two
135
+ // added together as a 64bit int (as an array of two 32bit ints).
136
+ //
137
+ function x64Add(m, n) {
138
+ m = [m[0] >>> 16, m[0] & 0xffff, m[1] >>> 16, m[1] & 0xffff];
139
+ n = [n[0] >>> 16, n[0] & 0xffff, n[1] >>> 16, n[1] & 0xffff];
140
+ var o = [0, 0, 0, 0];
141
+ o[3] += m[3] + n[3];
142
+ o[2] += o[3] >>> 16;
143
+ o[3] &= 0xffff;
144
+ o[2] += m[2] + n[2];
145
+ o[1] += o[2] >>> 16;
146
+ o[2] &= 0xffff;
147
+ o[1] += m[1] + n[1];
148
+ o[0] += o[1] >>> 16;
149
+ o[1] &= 0xffff;
150
+ o[0] += m[0] + n[0];
151
+ o[0] &= 0xffff;
152
+ return [(o[0] << 16) | o[1], (o[2] << 16) | o[3]];
153
+ }
154
+ //
155
+ // Given two 64bit ints (as an array of two 32bit ints) returns the two
156
+ // multiplied together as a 64bit int (as an array of two 32bit ints).
157
+ //
158
+ function x64Multiply(m, n) {
159
+ m = [m[0] >>> 16, m[0] & 0xffff, m[1] >>> 16, m[1] & 0xffff];
160
+ n = [n[0] >>> 16, n[0] & 0xffff, n[1] >>> 16, n[1] & 0xffff];
161
+ var o = [0, 0, 0, 0];
162
+ o[3] += m[3] * n[3];
163
+ o[2] += o[3] >>> 16;
164
+ o[3] &= 0xffff;
165
+ o[2] += m[2] * n[3];
166
+ o[1] += o[2] >>> 16;
167
+ o[2] &= 0xffff;
168
+ o[2] += m[3] * n[2];
169
+ o[1] += o[2] >>> 16;
170
+ o[2] &= 0xffff;
171
+ o[1] += m[1] * n[3];
172
+ o[0] += o[1] >>> 16;
173
+ o[1] &= 0xffff;
174
+ o[1] += m[2] * n[2];
175
+ o[0] += o[1] >>> 16;
176
+ o[1] &= 0xffff;
177
+ o[1] += m[3] * n[1];
178
+ o[0] += o[1] >>> 16;
179
+ o[1] &= 0xffff;
180
+ o[0] += m[0] * n[3] + m[1] * n[2] + m[2] * n[1] + m[3] * n[0];
181
+ o[0] &= 0xffff;
182
+ return [(o[0] << 16) | o[1], (o[2] << 16) | o[3]];
183
+ }
184
+ //
185
+ // Given a 64bit int (as an array of two 32bit ints) and an int
186
+ // representing a number of bit positions, returns the 64bit int (as an
187
+ // array of two 32bit ints) rotated left by that number of positions.
188
+ //
189
+ function x64Rotl(m, n) {
190
+ n %= 64;
191
+ if (n === 32) {
192
+ return [m[1], m[0]];
193
+ }
194
+ else if (n < 32) {
195
+ return [(m[0] << n) | (m[1] >>> (32 - n)), (m[1] << n) | (m[0] >>> (32 - n))];
196
+ }
197
+ else {
198
+ n -= 32;
199
+ return [(m[1] << n) | (m[0] >>> (32 - n)), (m[0] << n) | (m[1] >>> (32 - n))];
200
+ }
201
+ }
202
+ //
203
+ // Given a 64bit int (as an array of two 32bit ints) and an int
204
+ // representing a number of bit positions, returns the 64bit int (as an
205
+ // array of two 32bit ints) shifted left by that number of positions.
206
+ //
207
+ function x64LeftShift(m, n) {
208
+ n %= 64;
209
+ if (n === 0) {
210
+ return m;
211
+ }
212
+ else if (n < 32) {
213
+ return [(m[0] << n) | (m[1] >>> (32 - n)), m[1] << n];
214
+ }
215
+ else {
216
+ return [m[1] << (n - 32), 0];
217
+ }
218
+ }
219
+ //
220
+ // Given two 64bit ints (as an array of two 32bit ints) returns the two
221
+ // xored together as a 64bit int (as an array of two 32bit ints).
222
+ //
223
+ function x64Xor(m, n) {
224
+ return [m[0] ^ n[0], m[1] ^ n[1]];
225
+ }
226
+ //
227
+ // Given a block, returns murmurHash3's final x64 mix of that block.
228
+ // (`[0, h[0] >>> 1]` is a 33 bit unsigned right shift. This is the
229
+ // only place where we need to right shift 64bit ints.)
230
+ //
231
+ function x64Fmix(h) {
232
+ h = x64Xor(h, [0, h[0] >>> 1]);
233
+ h = x64Multiply(h, [0xff51afd7, 0xed558ccd]);
234
+ h = x64Xor(h, [0, h[0] >>> 1]);
235
+ h = x64Multiply(h, [0xc4ceb9fe, 0x1a85ec53]);
236
+ h = x64Xor(h, [0, h[0] >>> 1]);
237
+ return h;
238
+ }
239
+ //
240
+ // Given a string and an optional seed as an int, returns a 128 bit
241
+ // hash using the x64 flavor of MurmurHash3, as an unsigned hex.
242
+ //
243
+ function x64hash128(key, seed) {
244
+ key = key || "";
245
+ seed = seed || 0;
246
+ var remainder = key.length % 16;
247
+ var bytes = key.length - remainder;
248
+ var h1 = [0, seed];
249
+ var h2 = [0, seed];
250
+ var k1 = [0, 0];
251
+ var k2 = [0, 0];
252
+ var c1 = [0x87c37b91, 0x114253d5];
253
+ var c2 = [0x4cf5ad43, 0x2745937f];
254
+ var i;
255
+ for (i = 0; i < bytes; i = i + 16) {
256
+ k1 = [
257
+ (key.charCodeAt(i + 4) & 0xff) |
258
+ ((key.charCodeAt(i + 5) & 0xff) << 8) |
259
+ ((key.charCodeAt(i + 6) & 0xff) << 16) |
260
+ ((key.charCodeAt(i + 7) & 0xff) << 24),
261
+ (key.charCodeAt(i) & 0xff) |
262
+ ((key.charCodeAt(i + 1) & 0xff) << 8) |
263
+ ((key.charCodeAt(i + 2) & 0xff) << 16) |
264
+ ((key.charCodeAt(i + 3) & 0xff) << 24),
265
+ ];
266
+ k2 = [
267
+ (key.charCodeAt(i + 12) & 0xff) |
268
+ ((key.charCodeAt(i + 13) & 0xff) << 8) |
269
+ ((key.charCodeAt(i + 14) & 0xff) << 16) |
270
+ ((key.charCodeAt(i + 15) & 0xff) << 24),
271
+ (key.charCodeAt(i + 8) & 0xff) |
272
+ ((key.charCodeAt(i + 9) & 0xff) << 8) |
273
+ ((key.charCodeAt(i + 10) & 0xff) << 16) |
274
+ ((key.charCodeAt(i + 11) & 0xff) << 24),
275
+ ];
276
+ k1 = x64Multiply(k1, c1);
277
+ k1 = x64Rotl(k1, 31);
278
+ k1 = x64Multiply(k1, c2);
279
+ h1 = x64Xor(h1, k1);
280
+ h1 = x64Rotl(h1, 27);
281
+ h1 = x64Add(h1, h2);
282
+ h1 = x64Add(x64Multiply(h1, [0, 5]), [0, 0x52dce729]);
283
+ k2 = x64Multiply(k2, c2);
284
+ k2 = x64Rotl(k2, 33);
285
+ k2 = x64Multiply(k2, c1);
286
+ h2 = x64Xor(h2, k2);
287
+ h2 = x64Rotl(h2, 31);
288
+ h2 = x64Add(h2, h1);
289
+ h2 = x64Add(x64Multiply(h2, [0, 5]), [0, 0x38495ab5]);
290
+ }
291
+ k1 = [0, 0];
292
+ k2 = [0, 0];
293
+ switch (remainder) {
294
+ case 15:
295
+ k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 14)], 48));
296
+ // fallthrough
297
+ case 14:
298
+ k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 13)], 40));
299
+ // fallthrough
300
+ case 13:
301
+ k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 12)], 32));
302
+ // fallthrough
303
+ case 12:
304
+ k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 11)], 24));
305
+ // fallthrough
306
+ case 11:
307
+ k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 10)], 16));
308
+ // fallthrough
309
+ case 10:
310
+ k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 9)], 8));
311
+ // fallthrough
312
+ case 9:
313
+ k2 = x64Xor(k2, [0, key.charCodeAt(i + 8)]);
314
+ k2 = x64Multiply(k2, c2);
315
+ k2 = x64Rotl(k2, 33);
316
+ k2 = x64Multiply(k2, c1);
317
+ h2 = x64Xor(h2, k2);
318
+ // fallthrough
319
+ case 8:
320
+ k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 7)], 56));
321
+ // fallthrough
322
+ case 7:
323
+ k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 6)], 48));
324
+ // fallthrough
325
+ case 6:
326
+ k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 5)], 40));
327
+ // fallthrough
328
+ case 5:
329
+ k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 4)], 32));
330
+ // fallthrough
331
+ case 4:
332
+ k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 3)], 24));
333
+ // fallthrough
334
+ case 3:
335
+ k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 2)], 16));
336
+ // fallthrough
337
+ case 2:
338
+ k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 1)], 8));
339
+ // fallthrough
340
+ case 1:
341
+ k1 = x64Xor(k1, [0, key.charCodeAt(i)]);
342
+ k1 = x64Multiply(k1, c1);
343
+ k1 = x64Rotl(k1, 31);
344
+ k1 = x64Multiply(k1, c2);
345
+ h1 = x64Xor(h1, k1);
346
+ // fallthrough
347
+ }
348
+ h1 = x64Xor(h1, [0, key.length]);
349
+ h2 = x64Xor(h2, [0, key.length]);
350
+ h1 = x64Add(h1, h2);
351
+ h2 = x64Add(h2, h1);
352
+ h1 = x64Fmix(h1);
353
+ h2 = x64Fmix(h2);
354
+ h1 = x64Add(h1, h2);
355
+ h2 = x64Add(h2, h1);
356
+ return (
357
+ ("00000000" + (h1[0] >>> 0).toString(16)).slice(-8) +
358
+ ("00000000" + (h1[1] >>> 0).toString(16)).slice(-8) +
359
+ ("00000000" + (h2[0] >>> 0).toString(16)).slice(-8) +
360
+ ("00000000" + (h2[1] >>> 0).toString(16)).slice(-8)
361
+ );
362
+ }
363
+
364
+ /**
365
+ * Converts an error object to a plain object that can be used with `JSON.stringify`.
366
+ * If you just run `JSON.stringify(error)`, you'll get `'{}'`.
367
+ */
368
+ function errorToObject(error) {
369
+ var _a;
370
+ return __assign(
371
+ {
372
+ name: error.name,
373
+ message: error.message,
374
+ stack: (_a = error.stack) === null || _a === void 0 ? void 0 : _a.split("\n"),
375
+ },
376
+ error,
377
+ );
378
+ }
379
+
380
+ /*
381
+ * This file contains functions to work with pure data only (no browser features, DOM, side effects, etc).
382
+ */
383
+ /**
384
+ * Does the same as Array.prototype.includes but has better typing
385
+ */
386
+ function includes(haystack, needle) {
387
+ for (var i = 0, l = haystack.length; i < l; ++i) {
388
+ if (haystack[i] === needle) {
389
+ return true;
390
+ }
391
+ }
392
+ return false;
393
+ }
394
+ /**
395
+ * Like `!includes()` but with proper typing
396
+ */
397
+ function excludes(haystack, needle) {
398
+ return !includes(haystack, needle);
399
+ }
400
+ /**
401
+ * Be careful, NaN can return
402
+ */
403
+ function toInt(value) {
404
+ return parseInt(value);
405
+ }
406
+ /**
407
+ * Be careful, NaN can return
408
+ */
409
+ function toFloat(value) {
410
+ return parseFloat(value);
411
+ }
412
+ function replaceNaN(value, replacement) {
413
+ return typeof value === "number" && isNaN(value) ? replacement : value;
414
+ }
415
+ function countTruthy(values) {
416
+ return values.reduce(function (sum, value) {
417
+ return sum + (value ? 1 : 0);
418
+ }, 0);
419
+ }
420
+ function round(value, base) {
421
+ if (base === void 0) {
422
+ base = 1;
423
+ }
424
+ if (Math.abs(base) >= 1) {
425
+ return Math.round(value / base) * base;
426
+ }
427
+ else {
428
+ // Sometimes when a number is multiplied by a small number, precision is lost,
429
+ // for example 1234 * 0.0001 === 0.12340000000000001, and it's more precise divide: 1234 / (1 / 0.0001) === 0.1234.
430
+ var counterBase = 1 / base;
431
+ return Math.round(value * counterBase) / counterBase;
432
+ }
433
+ }
434
+ /**
435
+ * Parses a CSS selector into tag name with HTML attributes.
436
+ * Only single element selector are supported (without operators like space, +, >, etc).
437
+ *
438
+ * Multiple values can be returned for each attribute. You decide how to handle them.
439
+ */
440
+ function parseSimpleCssSelector(selector) {
441
+ var _a, _b;
442
+ var errorMessage = "Unexpected syntax '".concat(selector, "'");
443
+ var tagMatch = /^\s*([a-z-]*)(.*)$/i.exec(selector);
444
+ var tag = tagMatch[1] || undefined;
445
+ var attributes = {};
446
+ var partsRegex = /([.:#][\w-]+|\[.+?\])/gi;
447
+ var addAttribute = function (name, value) {
448
+ attributes[name] = attributes[name] || [];
449
+ attributes[name].push(value);
450
+ };
451
+ for (;;) {
452
+ var match = partsRegex.exec(tagMatch[2]);
453
+ if (!match) {
454
+ break;
455
+ }
456
+ var part = match[0];
457
+ switch (part[0]) {
458
+ case ".":
459
+ addAttribute("class", part.slice(1));
460
+ break;
461
+ case "#":
462
+ addAttribute("id", part.slice(1));
463
+ break;
464
+ case "[": {
465
+ var attributeMatch = /^\[([\w-]+)([~|^$*]?=("(.*?)"|([\w-]+)))?(\s+[is])?\]$/.exec(part);
466
+ if (attributeMatch) {
467
+ addAttribute(
468
+ attributeMatch[1],
469
+ (_b = (_a = attributeMatch[4]) !== null && _a !== void 0 ? _a : attributeMatch[5]) !== null && _b !== void 0
470
+ ? _b
471
+ : "",
472
+ );
473
+ }
474
+ else {
475
+ throw new Error(errorMessage);
476
+ }
477
+ break;
478
+ }
479
+ default:
480
+ throw new Error(errorMessage);
481
+ }
482
+ }
483
+ return [tag, attributes];
484
+ }
485
+
486
+ function ensureErrorWithMessage(error) {
487
+ return error && typeof error === "object" && "message" in error ? error : { message: error };
488
+ }
489
+ function isFinalResultLoaded(loadResult) {
490
+ return typeof loadResult !== "function";
491
+ }
492
+ /**
493
+ * Loads the given entropy source. Returns a function that gets an entropy component from the source.
494
+ *
495
+ * The result is returned synchronously to prevent `loadSources` from
496
+ * waiting for one source to load before getting the components from the other sources.
497
+ */
498
+ function loadSource(source, sourceOptions) {
499
+ var sourceLoadPromise = new Promise(function (resolveLoad) {
500
+ var loadStartTime = Date.now();
501
+ // `awaitIfAsync` is used instead of just `await` in order to measure the duration of synchronous sources
502
+ // correctly (other microtasks won't affect the duration).
503
+ awaitIfAsync(source.bind(null, sourceOptions), function () {
504
+ var loadArgs = [];
505
+ for (var _i = 0; _i < arguments.length; _i++) {
506
+ loadArgs[_i] = arguments[_i];
507
+ }
508
+ var loadDuration = Date.now() - loadStartTime;
509
+ // Source loading failed
510
+ if (!loadArgs[0]) {
511
+ return resolveLoad(function () {
512
+ return { error: ensureErrorWithMessage(loadArgs[1]), duration: loadDuration };
513
+ });
514
+ }
515
+ var loadResult = loadArgs[1];
516
+ // Source loaded with the final result
517
+ if (isFinalResultLoaded(loadResult)) {
518
+ return resolveLoad(function () {
519
+ return { value: loadResult, duration: loadDuration };
520
+ });
521
+ }
522
+ // Source loaded with "get" stage
523
+ resolveLoad(function () {
524
+ return new Promise(function (resolveGet) {
525
+ var getStartTime = Date.now();
526
+ awaitIfAsync(loadResult, function () {
527
+ var getArgs = [];
528
+ for (var _i = 0; _i < arguments.length; _i++) {
529
+ getArgs[_i] = arguments[_i];
530
+ }
531
+ var duration = loadDuration + Date.now() - getStartTime;
532
+ // Source getting failed
533
+ if (!getArgs[0]) {
534
+ return resolveGet({ error: ensureErrorWithMessage(getArgs[1]), duration: duration });
535
+ }
536
+ // Source getting succeeded
537
+ resolveGet({ value: getArgs[1], duration: duration });
538
+ });
539
+ });
540
+ });
541
+ });
542
+ });
543
+ suppressUnhandledRejectionWarning(sourceLoadPromise);
544
+ return function getComponent() {
545
+ return sourceLoadPromise.then(function (finalizeSource) {
546
+ return finalizeSource();
547
+ });
548
+ };
549
+ }
550
+ /**
551
+ * Loads the given entropy sources. Returns a function that collects the entropy components.
552
+ *
553
+ * The result is returned synchronously in order to allow start getting the components
554
+ * before the sources are loaded completely.
555
+ *
556
+ * Warning for package users:
557
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
558
+ */
559
+ function loadSources(sources, sourceOptions, excludeSources) {
560
+ var includedSources = Object.keys(sources).filter(function (sourceKey) {
561
+ return excludes(excludeSources, sourceKey);
562
+ });
563
+ // Using `mapWithBreaks` allows asynchronous sources to complete between synchronous sources
564
+ // and measure the duration correctly
565
+ var sourceGettersPromise = mapWithBreaks(includedSources, function (sourceKey) {
566
+ return loadSource(sources[sourceKey], sourceOptions);
567
+ });
568
+ suppressUnhandledRejectionWarning(sourceGettersPromise);
569
+ return function getComponents() {
570
+ return __awaiter(this, void 0, void 0, function () {
571
+ var sourceGetters, componentPromises, componentArray, components, index;
572
+ return __generator(this, function (_a) {
573
+ switch (_a.label) {
574
+ case 0:
575
+ return [4 /*yield*/, sourceGettersPromise];
576
+ case 1:
577
+ sourceGetters = _a.sent();
578
+ return [
579
+ 4 /*yield*/,
580
+ mapWithBreaks(sourceGetters, function (sourceGetter) {
581
+ var componentPromise = sourceGetter();
582
+ suppressUnhandledRejectionWarning(componentPromise);
583
+ return componentPromise;
584
+ }),
585
+ ];
586
+ case 2:
587
+ componentPromises = _a.sent();
588
+ return [
589
+ 4 /*yield*/,
590
+ Promise.all(componentPromises),
591
+ // Keeping the component keys order the same as the source keys order
592
+ ];
593
+ case 3:
594
+ componentArray = _a.sent();
595
+ components = {};
596
+ for (index = 0; index < includedSources.length; ++index) {
597
+ components[includedSources[index]] = componentArray[index];
598
+ }
599
+ return [2 /*return*/, components];
600
+ }
601
+ });
602
+ });
603
+ };
604
+ }
605
+ /**
606
+ * Modifies an entropy source by transforming its returned value with the given function.
607
+ * Keeps the source properties: sync/async, 1/2 stages.
608
+ *
609
+ * Warning for package users:
610
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
611
+ */
612
+ function transformSource(source, transformValue) {
613
+ var transformLoadResult = function (loadResult) {
614
+ if (isFinalResultLoaded(loadResult)) {
615
+ return transformValue(loadResult);
616
+ }
617
+ return function () {
618
+ var getResult = loadResult();
619
+ if (isPromise(getResult)) {
620
+ return getResult.then(transformValue);
621
+ }
622
+ return transformValue(getResult);
623
+ };
624
+ };
625
+ return function (options) {
626
+ var loadResult = source(options);
627
+ if (isPromise(loadResult)) {
628
+ return loadResult.then(transformLoadResult);
629
+ }
630
+ return transformLoadResult(loadResult);
631
+ };
632
+ }
633
+
634
+ /*
635
+ * Functions to help with features that vary through browsers
636
+ */
637
+ /**
638
+ * Checks whether the browser is based on Trident (the Internet Explorer engine) without using user-agent.
639
+ *
640
+ * Warning for package users:
641
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
642
+ */
643
+ function isTrident() {
644
+ var w = window;
645
+ var n = navigator;
646
+ // The properties are checked to be in IE 10, IE 11 and not to be in other browsers in October 2020
647
+ return (
648
+ countTruthy([
649
+ "MSCSSMatrix" in w,
650
+ "msSetImmediate" in w,
651
+ "msIndexedDB" in w,
652
+ "msMaxTouchPoints" in n,
653
+ "msPointerEnabled" in n,
654
+ ]) >= 4
655
+ );
656
+ }
657
+ /**
658
+ * Checks whether the browser is based on EdgeHTML (the pre-Chromium Edge engine) without using user-agent.
659
+ *
660
+ * Warning for package users:
661
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
662
+ */
663
+ function isEdgeHTML() {
664
+ // Based on research in October 2020
665
+ var w = window;
666
+ var n = navigator;
667
+ return (
668
+ countTruthy(["msWriteProfilerMark" in w, "MSStream" in w, "msLaunchUri" in n, "msSaveBlob" in n]) >= 3 &&
669
+ !isTrident()
670
+ );
671
+ }
672
+ /**
673
+ * Checks whether the browser is based on Chromium without using user-agent.
674
+ *
675
+ * Warning for package users:
676
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
677
+ */
678
+ function isChromium() {
679
+ // Based on research in October 2020. Tested to detect Chromium 42-86.
680
+ var w = window;
681
+ var n = navigator;
682
+ return (
683
+ countTruthy([
684
+ "webkitPersistentStorage" in n,
685
+ "webkitTemporaryStorage" in n,
686
+ n.vendor.indexOf("Google") === 0,
687
+ "webkitResolveLocalFileSystemURL" in w,
688
+ "BatteryManager" in w,
689
+ "webkitMediaStream" in w,
690
+ "webkitSpeechGrammar" in w,
691
+ ]) >= 5
692
+ );
693
+ }
694
+ /**
695
+ * Checks whether the browser is based on mobile or desktop Safari without using user-agent.
696
+ * All iOS browsers use WebKit (the Safari engine).
697
+ *
698
+ * Warning for package users:
699
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
700
+ */
701
+ function isWebKit() {
702
+ // Based on research in September 2020
703
+ var w = window;
704
+ var n = navigator;
705
+ return (
706
+ countTruthy([
707
+ "ApplePayError" in w,
708
+ "CSSPrimitiveValue" in w,
709
+ "Counter" in w,
710
+ n.vendor.indexOf("Apple") === 0,
711
+ "getStorageUpdates" in n,
712
+ "WebKitMediaKeys" in w,
713
+ ]) >= 4
714
+ );
715
+ }
716
+ /**
717
+ * Checks whether the WebKit browser is a desktop Safari.
718
+ *
719
+ * Warning for package users:
720
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
721
+ */
722
+ function isDesktopSafari() {
723
+ var w = window;
724
+ return (
725
+ countTruthy(["safari" in w, !("DeviceMotionEvent" in w), !("ongestureend" in w), !("standalone" in navigator)]) >= 3
726
+ );
727
+ }
728
+ /**
729
+ * Checks whether the browser is based on Gecko (Firefox engine) without using user-agent.
730
+ *
731
+ * Warning for package users:
732
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
733
+ */
734
+ function isGecko() {
735
+ var _a, _b;
736
+ var w = window;
737
+ // Based on research in September 2020
738
+ return (
739
+ countTruthy([
740
+ "buildID" in navigator,
741
+ "MozAppearance" in
742
+ ((_b = (_a = document.documentElement) === null || _a === void 0 ? void 0 : _a.style) !== null && _b !== void 0
743
+ ? _b
744
+ : {}),
745
+ "onmozfullscreenchange" in w,
746
+ "mozInnerScreenX" in w,
747
+ "CSSMozDocumentRule" in w,
748
+ "CanvasCaptureMediaStream" in w,
749
+ ]) >= 4
750
+ );
751
+ }
752
+ /**
753
+ * Checks whether the browser is based on Chromium version ≥86 without using user-agent.
754
+ * It doesn't check that the browser is based on Chromium, there is a separate function for this.
755
+ */
756
+ function isChromium86OrNewer() {
757
+ // Checked in Chrome 85 vs Chrome 86 both on desktop and Android
758
+ var w = window;
759
+ return (
760
+ countTruthy([
761
+ !("MediaSettingsRange" in w),
762
+ "RTCEncodedAudioFrame" in w,
763
+ "" + w.Intl === "[object Intl]",
764
+ "" + w.Reflect === "[object Reflect]",
765
+ ]) >= 3
766
+ );
767
+ }
768
+ /**
769
+ * Checks whether the browser is based on WebKit version ≥606 (Safari ≥12) without using user-agent.
770
+ * It doesn't check that the browser is based on WebKit, there is a separate function for this.
771
+ *
772
+ * @link https://en.wikipedia.org/wiki/Safari_version_history#Release_history Safari-WebKit versions map
773
+ */
774
+ function isWebKit606OrNewer() {
775
+ // Checked in Safari 9–14
776
+ var w = window;
777
+ return (
778
+ countTruthy([
779
+ "DOMRectList" in w,
780
+ "RTCPeerConnectionIceEvent" in w,
781
+ "SVGGeometryElement" in w,
782
+ "ontransitioncancel" in w,
783
+ ]) >= 3
784
+ );
785
+ }
786
+ /**
787
+ * Checks whether the device is an iPad.
788
+ * It doesn't check that the engine is WebKit and that the WebKit isn't desktop.
789
+ */
790
+ function isIPad() {
791
+ // Checked on:
792
+ // Safari on iPadOS (both mobile and desktop modes): 8, 11, 12, 13, 14
793
+ // Chrome on iPadOS (both mobile and desktop modes): 11, 12, 13, 14
794
+ // Safari on iOS (both mobile and desktop modes): 9, 10, 11, 12, 13, 14
795
+ // Chrome on iOS (both mobile and desktop modes): 9, 10, 11, 12, 13, 14
796
+ // Before iOS 13. Safari tampers the value in "request desktop site" mode since iOS 13.
797
+ if (navigator.platform === "iPad") {
798
+ return true;
799
+ }
800
+ var s = screen;
801
+ var screenRatio = s.width / s.height;
802
+ return (
803
+ countTruthy([
804
+ "MediaSource" in window,
805
+ !!Element.prototype.webkitRequestFullscreen,
806
+ // iPhone 4S that runs iOS 9 matches this. But it won't match the criteria above, so it won't be detected as iPad.
807
+ screenRatio > 0.65 && screenRatio < 1.53,
808
+ ]) >= 2
809
+ );
810
+ }
811
+ /**
812
+ * Warning for package users:
813
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
814
+ */
815
+ function getFullscreenElement() {
816
+ var d = document;
817
+ return d.fullscreenElement || d.msFullscreenElement || d.mozFullScreenElement || d.webkitFullscreenElement || null;
818
+ }
819
+ function exitFullscreen() {
820
+ var d = document;
821
+ // `call` is required because the function throws an error without a proper "this" context
822
+ return (d.exitFullscreen || d.msExitFullscreen || d.mozCancelFullScreen || d.webkitExitFullscreen).call(d);
823
+ }
824
+ /**
825
+ * Checks whether the device runs on Android without using user-agent.
826
+ *
827
+ * Warning for package users:
828
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
829
+ */
830
+ function isAndroid() {
831
+ var isItChromium = isChromium();
832
+ var isItGecko = isGecko();
833
+ // Only 2 browser engines are presented on Android.
834
+ // Actually, there is also Android 4.1 browser, but it's not worth detecting it at the moment.
835
+ if (!isItChromium && !isItGecko) {
836
+ return false;
837
+ }
838
+ var w = window;
839
+ // Chrome removes all words "Android" from `navigator` when desktop version is requested
840
+ // Firefox keeps "Android" in `navigator.appVersion` when desktop version is requested
841
+ return (
842
+ countTruthy([
843
+ "onorientationchange" in w,
844
+ "orientation" in w,
845
+ isItChromium && !("SharedWorker" in w),
846
+ isItGecko && /android/i.test(navigator.appVersion),
847
+ ]) >= 2
848
+ );
849
+ }
850
+
851
+ /**
852
+ * A deep description: https://fingerprint.com/blog/audio-fingerprinting/
853
+ * Inspired by and based on https://github.com/cozylife/audio-fingerprint
854
+ */
855
+ function getAudioFingerprint() {
856
+ var w = window;
857
+ var AudioContext = w.OfflineAudioContext || w.webkitOfflineAudioContext;
858
+ if (!AudioContext) {
859
+ return -2 /* SpecialFingerprint.NotSupported */;
860
+ }
861
+ // In some browsers, audio context always stays suspended unless the context is started in response to a user action
862
+ // (e.g. a click or a tap). It prevents audio fingerprint from being taken at an arbitrary moment of time.
863
+ // Such browsers are old and unpopular, so the audio fingerprinting is just skipped in them.
864
+ // See a similar case explanation at https://stackoverflow.com/questions/46363048/onaudioprocess-not-called-on-ios11#46534088
865
+ if (doesCurrentBrowserSuspendAudioContext()) {
866
+ return -1 /* SpecialFingerprint.KnownToSuspend */;
867
+ }
868
+ var hashFromIndex = 4500;
869
+ var hashToIndex = 5000;
870
+ var context = new AudioContext(1, hashToIndex, 44100);
871
+ var oscillator = context.createOscillator();
872
+ oscillator.type = "triangle";
873
+ oscillator.frequency.value = 10000;
874
+ var compressor = context.createDynamicsCompressor();
875
+ compressor.threshold.value = -50;
876
+ compressor.knee.value = 40;
877
+ compressor.ratio.value = 12;
878
+ compressor.attack.value = 0;
879
+ compressor.release.value = 0.25;
880
+ oscillator.connect(compressor);
881
+ compressor.connect(context.destination);
882
+ oscillator.start(0);
883
+ var _a = startRenderingAudio(context),
884
+ renderPromise = _a[0],
885
+ finishRendering = _a[1];
886
+ var fingerprintPromise = renderPromise.then(
887
+ function (buffer) {
888
+ return getHash(buffer.getChannelData(0).subarray(hashFromIndex));
889
+ },
890
+ function (error) {
891
+ if (
892
+ error.name === "timeout" /* InnerErrorName.Timeout */ ||
893
+ error.name === "suspended" /* InnerErrorName.Suspended */
894
+ ) {
895
+ return -3 /* SpecialFingerprint.Timeout */;
896
+ }
897
+ throw error;
898
+ },
899
+ );
900
+ // Suppresses the console error message in case when the fingerprint fails before requested
901
+ suppressUnhandledRejectionWarning(fingerprintPromise);
902
+ return function () {
903
+ finishRendering();
904
+ return fingerprintPromise;
905
+ };
906
+ }
907
+ /**
908
+ * Checks if the current browser is known to always suspend audio context
909
+ */
910
+ function doesCurrentBrowserSuspendAudioContext() {
911
+ return isWebKit() && !isDesktopSafari() && !isWebKit606OrNewer();
912
+ }
913
+ /**
914
+ * Starts rendering the audio context.
915
+ * When the returned function is called, the render process starts finishing.
916
+ */
917
+ function startRenderingAudio(context) {
918
+ var renderTryMaxCount = 3;
919
+ var renderRetryDelay = 500;
920
+ var runningMaxAwaitTime = 500;
921
+ var runningSufficientTime = 5000;
922
+ var finalize = function () {
923
+ return undefined;
924
+ };
925
+ var resultPromise = new Promise(function (resolve, reject) {
926
+ var isFinalized = false;
927
+ var renderTryCount = 0;
928
+ var startedRunningAt = 0;
929
+ context.oncomplete = function (event) {
930
+ return resolve(event.renderedBuffer);
931
+ };
932
+ var startRunningTimeout = function () {
933
+ setTimeout(
934
+ function () {
935
+ return reject(makeInnerError("timeout" /* InnerErrorName.Timeout */));
936
+ },
937
+ Math.min(runningMaxAwaitTime, startedRunningAt + runningSufficientTime - Date.now()),
938
+ );
939
+ };
940
+ var tryRender = function () {
941
+ try {
942
+ var renderingPromise = context.startRendering();
943
+ // `context.startRendering` has two APIs: Promise and callback, we check that it's really a promise just in case
944
+ if (isPromise(renderingPromise)) {
945
+ // Suppresses all unhadled rejections in case of scheduled redundant retries after successful rendering
946
+ suppressUnhandledRejectionWarning(renderingPromise);
947
+ }
948
+ switch (context.state) {
949
+ case "running":
950
+ startedRunningAt = Date.now();
951
+ if (isFinalized) {
952
+ startRunningTimeout();
953
+ }
954
+ break;
955
+ // Sometimes the audio context doesn't start after calling `startRendering` (in addition to the cases where
956
+ // audio context doesn't start at all). A known case is starting an audio context when the browser tab is in
957
+ // background on iPhone. Retries usually help in this case.
958
+ case "suspended":
959
+ // The audio context can reject starting until the tab is in foreground. Long fingerprint duration
960
+ // in background isn't a problem, therefore the retry attempts don't count in background. It can lead to
961
+ // a situation when a fingerprint takes very long time and finishes successfully. FYI, the audio context
962
+ // can be suspended when `document.hidden === false` and start running after a retry.
963
+ if (!document.hidden) {
964
+ renderTryCount++;
965
+ }
966
+ if (isFinalized && renderTryCount >= renderTryMaxCount) {
967
+ reject(makeInnerError("suspended" /* InnerErrorName.Suspended */));
968
+ }
969
+ else {
970
+ setTimeout(tryRender, renderRetryDelay);
971
+ }
972
+ break;
973
+ }
974
+ }
975
+ catch (error) {
976
+ reject(error);
977
+ }
978
+ };
979
+ tryRender();
980
+ finalize = function () {
981
+ if (!isFinalized) {
982
+ isFinalized = true;
983
+ if (startedRunningAt > 0) {
984
+ startRunningTimeout();
985
+ }
986
+ }
987
+ };
988
+ });
989
+ return [resultPromise, finalize];
990
+ }
991
+ function getHash(signal) {
992
+ var hash = 0;
993
+ for (var i = 0; i < signal.length; ++i) {
994
+ hash += Math.abs(signal[i]);
995
+ }
996
+ return hash;
997
+ }
998
+ function makeInnerError(name) {
999
+ var error = new Error(name);
1000
+ error.name = name;
1001
+ return error;
1002
+ }
1003
+
1004
+ /**
1005
+ * Creates and keeps an invisible iframe while the given function runs.
1006
+ * The given function is called when the iframe is loaded and has a body.
1007
+ * The iframe allows to measure DOM sizes inside itself.
1008
+ *
1009
+ * Notice: passing an initial HTML code doesn't work in IE.
1010
+ *
1011
+ * Warning for package users:
1012
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
1013
+ */
1014
+ function withIframe(action, initialHtml, domPollInterval) {
1015
+ var _a, _b, _c;
1016
+ if (domPollInterval === void 0) {
1017
+ domPollInterval = 50;
1018
+ }
1019
+ return __awaiter(this, void 0, void 0, function () {
1020
+ var d, iframe;
1021
+ return __generator(this, function (_d) {
1022
+ switch (_d.label) {
1023
+ case 0:
1024
+ d = document;
1025
+ _d.label = 1;
1026
+ case 1:
1027
+ if (!!d.body) return [3 /*break*/, 3];
1028
+ return [4 /*yield*/, wait(domPollInterval)];
1029
+ case 2:
1030
+ _d.sent();
1031
+ return [3 /*break*/, 1];
1032
+ case 3:
1033
+ iframe = d.createElement("iframe");
1034
+ _d.label = 4;
1035
+ case 4:
1036
+ _d.trys.push([4, , 10, 11]);
1037
+ return [
1038
+ 4 /*yield*/,
1039
+ new Promise(function (_resolve, _reject) {
1040
+ var isComplete = false;
1041
+ var resolve = function () {
1042
+ isComplete = true;
1043
+ _resolve();
1044
+ };
1045
+ var reject = function (error) {
1046
+ isComplete = true;
1047
+ _reject(error);
1048
+ };
1049
+ iframe.onload = resolve;
1050
+ iframe.onerror = reject;
1051
+ var style = iframe.style;
1052
+ style.setProperty("display", "block", "important"); // Required for browsers to calculate the layout
1053
+ style.position = "absolute";
1054
+ style.top = "0";
1055
+ style.left = "0";
1056
+ style.visibility = "hidden";
1057
+ if (initialHtml && "srcdoc" in iframe) {
1058
+ iframe.srcdoc = initialHtml;
1059
+ }
1060
+ else {
1061
+ iframe.src = "about:blank";
1062
+ }
1063
+ d.body.appendChild(iframe);
1064
+ // WebKit in WeChat doesn't fire the iframe's `onload` for some reason.
1065
+ // This code checks for the loading state manually.
1066
+ // See https://github.com/fingerprintjs/fingerprintjs/issues/645
1067
+ var checkReadyState = function () {
1068
+ var _a, _b;
1069
+ // The ready state may never become 'complete' in Firefox despite the 'load' event being fired.
1070
+ // So an infinite setTimeout loop can happen without this check.
1071
+ // See https://github.com/fingerprintjs/fingerprintjs/pull/716#issuecomment-986898796
1072
+ if (isComplete) {
1073
+ return;
1074
+ }
1075
+ // Make sure iframe.contentWindow and iframe.contentWindow.document are both loaded
1076
+ // The contentWindow.document can miss in JSDOM (https://github.com/jsdom/jsdom).
1077
+ if (
1078
+ ((_b = (_a = iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.document) === null ||
1079
+ _b === void 0
1080
+ ? void 0
1081
+ : _b.readyState) === "complete"
1082
+ ) {
1083
+ resolve();
1084
+ }
1085
+ else {
1086
+ setTimeout(checkReadyState, 10);
1087
+ }
1088
+ };
1089
+ checkReadyState();
1090
+ }),
1091
+ ];
1092
+ case 5:
1093
+ _d.sent();
1094
+ _d.label = 6;
1095
+ case 6:
1096
+ if (
1097
+ !!((_b = (_a = iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.document) === null ||
1098
+ _b === void 0
1099
+ ? void 0
1100
+ : _b.body)
1101
+ )
1102
+ return [3 /*break*/, 8];
1103
+ return [4 /*yield*/, wait(domPollInterval)];
1104
+ case 7:
1105
+ _d.sent();
1106
+ return [3 /*break*/, 6];
1107
+ case 8:
1108
+ return [4 /*yield*/, action(iframe, iframe.contentWindow)];
1109
+ case 9:
1110
+ return [2 /*return*/, _d.sent()];
1111
+ case 10:
1112
+ (_c = iframe.parentNode) === null || _c === void 0 ? void 0 : _c.removeChild(iframe);
1113
+ return [7 /*endfinally*/];
1114
+ case 11:
1115
+ return [2 /*return*/];
1116
+ }
1117
+ });
1118
+ });
1119
+ }
1120
+ /**
1121
+ * Creates a DOM element that matches the given selector.
1122
+ * Only single element selector are supported (without operators like space, +, >, etc).
1123
+ */
1124
+ function selectorToElement(selector) {
1125
+ var _a = parseSimpleCssSelector(selector),
1126
+ tag = _a[0],
1127
+ attributes = _a[1];
1128
+ var element = document.createElement(tag !== null && tag !== void 0 ? tag : "div");
1129
+ for (var _i = 0, _b = Object.keys(attributes); _i < _b.length; _i++) {
1130
+ var name_1 = _b[_i];
1131
+ var value = attributes[name_1].join(" ");
1132
+ // Changing the `style` attribute can cause a CSP error, therefore we change the `style.cssText` property.
1133
+ // https://github.com/fingerprintjs/fingerprintjs/issues/733
1134
+ if (name_1 === "style") {
1135
+ addStyleString(element.style, value);
1136
+ }
1137
+ else {
1138
+ element.setAttribute(name_1, value);
1139
+ }
1140
+ }
1141
+ return element;
1142
+ }
1143
+ /**
1144
+ * Adds CSS styles from a string in such a way that doesn't trigger a CSP warning (unsafe-inline or unsafe-eval)
1145
+ */
1146
+ function addStyleString(style, source) {
1147
+ // We don't use `style.cssText` because browsers must block it when no `unsafe-eval` CSP is presented: https://csplite.com/csp145/#w3c_note
1148
+ // Even though the browsers ignore this standard, we don't use `cssText` just in case.
1149
+ for (var _i = 0, _a = source.split(";"); _i < _a.length; _i++) {
1150
+ var property = _a[_i];
1151
+ var match = /^\s*([\w-]+)\s*:\s*(.+?)(\s*!([\w-]+))?\s*$/.exec(property);
1152
+ if (match) {
1153
+ var name_2 = match[1],
1154
+ value = match[2],
1155
+ priority = match[4];
1156
+ style.setProperty(name_2, value, priority || ""); // The last argument can't be undefined in IE11
1157
+ }
1158
+ }
1159
+ }
1160
+
1161
+ // We use m or w because these two characters take up the maximum width.
1162
+ // And we use a LLi so that the same matching fonts can get separated.
1163
+ var testString = "mmMwWLliI0O&1";
1164
+ // We test using 48px font size, we may use any size. I guess larger the better.
1165
+ var textSize = "48px";
1166
+ // A font will be compared against all the three default fonts.
1167
+ // And if for any default fonts it doesn't match, then that font is available.
1168
+ var baseFonts = ["monospace", "sans-serif", "serif"];
1169
+ var fontList = [
1170
+ // This is android-specific font from "Roboto" family
1171
+ "sans-serif-thin",
1172
+ "ARNO PRO",
1173
+ "Agency FB",
1174
+ "Arabic Typesetting",
1175
+ "Arial Unicode MS",
1176
+ "AvantGarde Bk BT",
1177
+ "BankGothic Md BT",
1178
+ "Batang",
1179
+ "Bitstream Vera Sans Mono",
1180
+ "Calibri",
1181
+ "Century",
1182
+ "Century Gothic",
1183
+ "Clarendon",
1184
+ "EUROSTILE",
1185
+ "Franklin Gothic",
1186
+ "Futura Bk BT",
1187
+ "Futura Md BT",
1188
+ "GOTHAM",
1189
+ "Gill Sans",
1190
+ "HELV",
1191
+ "Haettenschweiler",
1192
+ "Helvetica Neue",
1193
+ "Humanst521 BT",
1194
+ "Leelawadee",
1195
+ "Letter Gothic",
1196
+ "Levenim MT",
1197
+ "Lucida Bright",
1198
+ "Lucida Sans",
1199
+ "Menlo",
1200
+ "MS Mincho",
1201
+ "MS Outlook",
1202
+ "MS Reference Specialty",
1203
+ "MS UI Gothic",
1204
+ "MT Extra",
1205
+ "MYRIAD PRO",
1206
+ "Marlett",
1207
+ "Meiryo UI",
1208
+ "Microsoft Uighur",
1209
+ "Minion Pro",
1210
+ "Monotype Corsiva",
1211
+ "PMingLiU",
1212
+ "Pristina",
1213
+ "SCRIPTINA",
1214
+ "Segoe UI Light",
1215
+ "Serifa",
1216
+ "SimHei",
1217
+ "Small Fonts",
1218
+ "Staccato222 BT",
1219
+ "TRAJAN PRO",
1220
+ "Univers CE 55 Medium",
1221
+ "Vrinda",
1222
+ "ZWAdobeF",
1223
+ ];
1224
+ // kudos to http://www.lalit.org/lab/javascript-css-font-detect/
1225
+ function getFonts() {
1226
+ // Running the script in an iframe makes it not affect the page look and not be affected by the page CSS. See:
1227
+ // https://github.com/fingerprintjs/fingerprintjs/issues/592
1228
+ // https://github.com/fingerprintjs/fingerprintjs/issues/628
1229
+ return withIframe(function (_, _a) {
1230
+ var document = _a.document;
1231
+ var holder = document.body;
1232
+ holder.style.fontSize = textSize;
1233
+ // div to load spans for the default fonts and the fonts to detect
1234
+ var spansContainer = document.createElement("div");
1235
+ var defaultWidth = {};
1236
+ var defaultHeight = {};
1237
+ // creates a span where the fonts will be loaded
1238
+ var createSpan = function (fontFamily) {
1239
+ var span = document.createElement("span");
1240
+ var style = span.style;
1241
+ style.position = "absolute";
1242
+ style.top = "0";
1243
+ style.left = "0";
1244
+ style.fontFamily = fontFamily;
1245
+ span.textContent = testString;
1246
+ spansContainer.appendChild(span);
1247
+ return span;
1248
+ };
1249
+ // creates a span and load the font to detect and a base font for fallback
1250
+ var createSpanWithFonts = function (fontToDetect, baseFont) {
1251
+ return createSpan("'".concat(fontToDetect, "',").concat(baseFont));
1252
+ };
1253
+ // creates spans for the base fonts and adds them to baseFontsDiv
1254
+ var initializeBaseFontsSpans = function () {
1255
+ return baseFonts.map(createSpan);
1256
+ };
1257
+ // creates spans for the fonts to detect and adds them to fontsDiv
1258
+ var initializeFontsSpans = function () {
1259
+ // Stores {fontName : [spans for that font]}
1260
+ var spans = {};
1261
+ var _loop_1 = function (font) {
1262
+ spans[font] = baseFonts.map(function (baseFont) {
1263
+ return createSpanWithFonts(font, baseFont);
1264
+ });
1265
+ };
1266
+ for (var _i = 0, fontList_1 = fontList; _i < fontList_1.length; _i++) {
1267
+ var font = fontList_1[_i];
1268
+ _loop_1(font);
1269
+ }
1270
+ return spans;
1271
+ };
1272
+ // checks if a font is available
1273
+ var isFontAvailable = function (fontSpans) {
1274
+ return baseFonts.some(function (baseFont, baseFontIndex) {
1275
+ return (
1276
+ fontSpans[baseFontIndex].offsetWidth !== defaultWidth[baseFont] ||
1277
+ fontSpans[baseFontIndex].offsetHeight !== defaultHeight[baseFont]
1278
+ );
1279
+ });
1280
+ };
1281
+ // create spans for base fonts
1282
+ var baseFontsSpans = initializeBaseFontsSpans();
1283
+ // create spans for fonts to detect
1284
+ var fontsSpans = initializeFontsSpans();
1285
+ // add all the spans to the DOM
1286
+ holder.appendChild(spansContainer);
1287
+ // get the default width for the three base fonts
1288
+ for (var index = 0; index < baseFonts.length; index++) {
1289
+ defaultWidth[baseFonts[index]] = baseFontsSpans[index].offsetWidth; // width for the default font
1290
+ defaultHeight[baseFonts[index]] = baseFontsSpans[index].offsetHeight; // height for the default font
1291
+ }
1292
+ // check available fonts
1293
+ return fontList.filter(function (font) {
1294
+ return isFontAvailable(fontsSpans[font]);
1295
+ });
1296
+ });
1297
+ }
1298
+
1299
+ function getPlugins() {
1300
+ var rawPlugins = navigator.plugins;
1301
+ if (!rawPlugins) {
1302
+ return undefined;
1303
+ }
1304
+ var plugins = [];
1305
+ // Safari 10 doesn't support iterating navigator.plugins with for...of
1306
+ for (var i = 0; i < rawPlugins.length; ++i) {
1307
+ var plugin = rawPlugins[i];
1308
+ if (!plugin) {
1309
+ continue;
1310
+ }
1311
+ var mimeTypes = [];
1312
+ for (var j = 0; j < plugin.length; ++j) {
1313
+ var mimeType = plugin[j];
1314
+ mimeTypes.push({
1315
+ type: mimeType.type,
1316
+ suffixes: mimeType.suffixes,
1317
+ });
1318
+ }
1319
+ plugins.push({
1320
+ name: plugin.name,
1321
+ description: plugin.description,
1322
+ mimeTypes: mimeTypes,
1323
+ });
1324
+ }
1325
+ return plugins;
1326
+ }
1327
+
1328
+ // https://www.browserleaks.com/canvas#how-does-it-work
1329
+ function getCanvasFingerprint() {
1330
+ var winding = false;
1331
+ var geometry;
1332
+ var text;
1333
+ var _a = makeCanvasContext(),
1334
+ canvas = _a[0],
1335
+ context = _a[1];
1336
+ if (!isSupported(canvas, context)) {
1337
+ geometry = text = ""; // The value will be 'unsupported' in v3.4
1338
+ }
1339
+ else {
1340
+ winding = doesSupportWinding(context);
1341
+ renderTextImage(canvas, context);
1342
+ var textImage1 = canvasToString(canvas);
1343
+ var textImage2 = canvasToString(canvas); // It's slightly faster to double-encode the text image
1344
+ // Some browsers add a noise to the canvas: https://github.com/fingerprintjs/fingerprintjs/issues/791
1345
+ // The canvas is excluded from the fingerprint in this case
1346
+ if (textImage1 !== textImage2) {
1347
+ geometry = text = "unstable";
1348
+ }
1349
+ else {
1350
+ text = textImage1;
1351
+ // Text is unstable:
1352
+ // https://github.com/fingerprintjs/fingerprintjs/issues/583
1353
+ // https://github.com/fingerprintjs/fingerprintjs/issues/103
1354
+ // Therefore it's extracted into a separate image.
1355
+ renderGeometryImage(canvas, context);
1356
+ geometry = canvasToString(canvas);
1357
+ }
1358
+ }
1359
+ return { winding: winding, geometry: geometry, text: text };
1360
+ }
1361
+ function makeCanvasContext() {
1362
+ var canvas = document.createElement("canvas");
1363
+ canvas.width = 1;
1364
+ canvas.height = 1;
1365
+ return [canvas, canvas.getContext("2d")];
1366
+ }
1367
+ function isSupported(canvas, context) {
1368
+ return !!(context && canvas.toDataURL);
1369
+ }
1370
+ function doesSupportWinding(context) {
1371
+ // https://web.archive.org/web/20170825024655/http://blogs.adobe.com/webplatform/2013/01/30/winding-rules-in-canvas/
1372
+ // https://github.com/Modernizr/Modernizr/blob/master/feature-detects/canvas/winding.js
1373
+ context.rect(0, 0, 10, 10);
1374
+ context.rect(2, 2, 6, 6);
1375
+ return !context.isPointInPath(5, 5, "evenodd");
1376
+ }
1377
+ function renderTextImage(canvas, context) {
1378
+ // Resizing the canvas cleans it
1379
+ canvas.width = 240;
1380
+ canvas.height = 60;
1381
+ context.textBaseline = "alphabetic";
1382
+ context.fillStyle = "#f60";
1383
+ context.fillRect(100, 1, 62, 20);
1384
+ context.fillStyle = "#069";
1385
+ // It's important to use explicit built-in fonts in order to exclude the affect of font preferences
1386
+ // (there is a separate entropy source for them).
1387
+ context.font = '11pt "Times New Roman"';
1388
+ // The choice of emojis has a gigantic impact on rendering performance (especially in FF).
1389
+ // Some newer emojis cause it to slow down 50-200 times.
1390
+ // There must be no text to the right of the emoji, see https://github.com/fingerprintjs/fingerprintjs/issues/574
1391
+ // A bare emoji shouldn't be used because the canvas will change depending on the script encoding:
1392
+ // https://github.com/fingerprintjs/fingerprintjs/issues/66
1393
+ // Escape sequence shouldn't be used too because Terser will turn it into a bare unicode.
1394
+ var printedText = "Cwm fjordbank gly ".concat(String.fromCharCode(55357, 56835) /* 😃 */);
1395
+ context.fillText(printedText, 2, 15);
1396
+ context.fillStyle = "rgba(102, 204, 0, 0.2)";
1397
+ context.font = "18pt Arial";
1398
+ context.fillText(printedText, 4, 45);
1399
+ }
1400
+ function renderGeometryImage(canvas, context) {
1401
+ // Resizing the canvas cleans it
1402
+ canvas.width = 122;
1403
+ canvas.height = 110;
1404
+ // Canvas blending
1405
+ // https://web.archive.org/web/20170826194121/http://blogs.adobe.com/webplatform/2013/01/28/blending-features-in-canvas/
1406
+ // http://jsfiddle.net/NDYV8/16/
1407
+ context.globalCompositeOperation = "multiply";
1408
+ for (
1409
+ var _i = 0,
1410
+ _a = [
1411
+ ["#f2f", 40, 40],
1412
+ ["#2ff", 80, 40],
1413
+ ["#ff2", 60, 80],
1414
+ ];
1415
+ _i < _a.length;
1416
+ _i++
1417
+ ) {
1418
+ var _b = _a[_i],
1419
+ color = _b[0],
1420
+ x = _b[1],
1421
+ y = _b[2];
1422
+ context.fillStyle = color;
1423
+ context.beginPath();
1424
+ context.arc(x, y, 40, 0, Math.PI * 2, true);
1425
+ context.closePath();
1426
+ context.fill();
1427
+ }
1428
+ // Canvas winding
1429
+ // https://web.archive.org/web/20130913061632/http://blogs.adobe.com/webplatform/2013/01/30/winding-rules-in-canvas/
1430
+ // http://jsfiddle.net/NDYV8/19/
1431
+ context.fillStyle = "#f9c";
1432
+ context.arc(60, 60, 60, 0, Math.PI * 2, true);
1433
+ context.arc(60, 60, 20, 0, Math.PI * 2, true);
1434
+ context.fill("evenodd");
1435
+ }
1436
+ function canvasToString(canvas) {
1437
+ return canvas.toDataURL();
1438
+ }
1439
+
1440
+ /**
1441
+ * This is a crude and primitive touch screen detection. It's not possible to currently reliably detect the availability
1442
+ * of a touch screen with a JS, without actually subscribing to a touch event.
1443
+ *
1444
+ * @see http://www.stucox.com/blog/you-cant-detect-a-touchscreen/
1445
+ * @see https://github.com/Modernizr/Modernizr/issues/548
1446
+ */
1447
+ function getTouchSupport() {
1448
+ var n = navigator;
1449
+ var maxTouchPoints = 0;
1450
+ var touchEvent;
1451
+ if (n.maxTouchPoints !== undefined) {
1452
+ maxTouchPoints = toInt(n.maxTouchPoints);
1453
+ }
1454
+ else if (n.msMaxTouchPoints !== undefined) {
1455
+ maxTouchPoints = n.msMaxTouchPoints;
1456
+ }
1457
+ try {
1458
+ document.createEvent("TouchEvent");
1459
+ touchEvent = true;
1460
+ }
1461
+ catch (_a) {
1462
+ touchEvent = false;
1463
+ }
1464
+ var touchStart = "ontouchstart" in window;
1465
+ return {
1466
+ maxTouchPoints: maxTouchPoints,
1467
+ touchEvent: touchEvent,
1468
+ touchStart: touchStart,
1469
+ };
1470
+ }
1471
+
1472
+ function getOsCpu() {
1473
+ return navigator.oscpu;
1474
+ }
1475
+
1476
+ function getLanguages() {
1477
+ var n = navigator;
1478
+ var result = [];
1479
+ var language = n.language || n.userLanguage || n.browserLanguage || n.systemLanguage;
1480
+ if (language !== undefined) {
1481
+ result.push([language]);
1482
+ }
1483
+ if (Array.isArray(n.languages)) {
1484
+ // Starting from Chromium 86, there is only a single value in `navigator.language` in Incognito mode:
1485
+ // the value of `navigator.language`. Therefore the value is ignored in this browser.
1486
+ if (!(isChromium() && isChromium86OrNewer())) {
1487
+ result.push(n.languages);
1488
+ }
1489
+ }
1490
+ else if (typeof n.languages === "string") {
1491
+ var languages = n.languages;
1492
+ if (languages) {
1493
+ result.push(languages.split(","));
1494
+ }
1495
+ }
1496
+ return result;
1497
+ }
1498
+
1499
+ function getColorDepth() {
1500
+ return window.screen.colorDepth;
1501
+ }
1502
+
1503
+ function getDeviceMemory() {
1504
+ // `navigator.deviceMemory` is a string containing a number in some unidentified cases
1505
+ return replaceNaN(toFloat(navigator.deviceMemory), undefined);
1506
+ }
1507
+
1508
+ function getScreenResolution() {
1509
+ var s = screen;
1510
+ // Some browsers return screen resolution as strings, e.g. "1200", instead of a number, e.g. 1200.
1511
+ // I suspect it's done by certain plugins that randomize browser properties to prevent fingerprinting.
1512
+ // Some browsers even return screen resolution as not numbers.
1513
+ var parseDimension = function (value) {
1514
+ return replaceNaN(toInt(value), null);
1515
+ };
1516
+ var dimensions = [parseDimension(s.width), parseDimension(s.height)];
1517
+ dimensions.sort().reverse();
1518
+ return dimensions;
1519
+ }
1520
+
1521
+ var screenFrameCheckInterval = 2500;
1522
+ var roundingPrecision = 10;
1523
+ // The type is readonly to protect from unwanted mutations
1524
+ var screenFrameBackup;
1525
+ var screenFrameSizeTimeoutId;
1526
+ /**
1527
+ * Starts watching the screen frame size. When a non-zero size appears, the size is saved and the watch is stopped.
1528
+ * Later, when `getScreenFrame` runs, it will return the saved non-zero size if the current size is null.
1529
+ *
1530
+ * This trick is required to mitigate the fact that the screen frame turns null in some cases.
1531
+ * See more on this at https://github.com/fingerprintjs/fingerprintjs/issues/568
1532
+ */
1533
+ function watchScreenFrame() {
1534
+ if (screenFrameSizeTimeoutId !== undefined) {
1535
+ return;
1536
+ }
1537
+ var checkScreenFrame = function () {
1538
+ var frameSize = getCurrentScreenFrame();
1539
+ if (isFrameSizeNull(frameSize)) {
1540
+ screenFrameSizeTimeoutId = setTimeout(checkScreenFrame, screenFrameCheckInterval);
1541
+ }
1542
+ else {
1543
+ screenFrameBackup = frameSize;
1544
+ screenFrameSizeTimeoutId = undefined;
1545
+ }
1546
+ };
1547
+ checkScreenFrame();
1548
+ }
1549
+ function getScreenFrame() {
1550
+ var _this = this;
1551
+ watchScreenFrame();
1552
+ return function () {
1553
+ return __awaiter(_this, void 0, void 0, function () {
1554
+ var frameSize;
1555
+ return __generator(this, function (_a) {
1556
+ switch (_a.label) {
1557
+ case 0:
1558
+ frameSize = getCurrentScreenFrame();
1559
+ if (!isFrameSizeNull(frameSize)) return [3 /*break*/, 2];
1560
+ if (screenFrameBackup) {
1561
+ return [2 /*return*/, __spreadArray([], screenFrameBackup, true)];
1562
+ }
1563
+ if (!getFullscreenElement()) return [3 /*break*/, 2];
1564
+ // Some browsers set the screen frame to zero when programmatic fullscreen is on.
1565
+ // There is a chance of getting a non-zero frame after exiting the fullscreen.
1566
+ // See more on this at https://github.com/fingerprintjs/fingerprintjs/issues/568
1567
+ return [4 /*yield*/, exitFullscreen()];
1568
+ case 1:
1569
+ // Some browsers set the screen frame to zero when programmatic fullscreen is on.
1570
+ // There is a chance of getting a non-zero frame after exiting the fullscreen.
1571
+ // See more on this at https://github.com/fingerprintjs/fingerprintjs/issues/568
1572
+ _a.sent();
1573
+ frameSize = getCurrentScreenFrame();
1574
+ _a.label = 2;
1575
+ case 2:
1576
+ if (!isFrameSizeNull(frameSize)) {
1577
+ screenFrameBackup = frameSize;
1578
+ }
1579
+ return [2 /*return*/, frameSize];
1580
+ }
1581
+ });
1582
+ });
1583
+ };
1584
+ }
1585
+ /**
1586
+ * Sometimes the available screen resolution changes a bit, e.g. 1900x1440 → 1900x1439. A possible reason: macOS Dock
1587
+ * shrinks to fit more icons when there is too little space. The rounding is used to mitigate the difference.
1588
+ */
1589
+ function getRoundedScreenFrame() {
1590
+ var _this = this;
1591
+ var screenFrameGetter = getScreenFrame();
1592
+ return function () {
1593
+ return __awaiter(_this, void 0, void 0, function () {
1594
+ var frameSize, processSize;
1595
+ return __generator(this, function (_a) {
1596
+ switch (_a.label) {
1597
+ case 0:
1598
+ return [4 /*yield*/, screenFrameGetter()];
1599
+ case 1:
1600
+ frameSize = _a.sent();
1601
+ processSize = function (sideSize) {
1602
+ return sideSize === null ? null : round(sideSize, roundingPrecision);
1603
+ };
1604
+ // It might look like I don't know about `for` and `map`.
1605
+ // In fact, such code is used to avoid TypeScript issues without using `as`.
1606
+ return [
1607
+ 2 /*return*/,
1608
+ [
1609
+ processSize(frameSize[0]),
1610
+ processSize(frameSize[1]),
1611
+ processSize(frameSize[2]),
1612
+ processSize(frameSize[3]),
1613
+ ],
1614
+ ];
1615
+ }
1616
+ });
1617
+ });
1618
+ };
1619
+ }
1620
+ function getCurrentScreenFrame() {
1621
+ var s = screen;
1622
+ // Some browsers return screen resolution as strings, e.g. "1200", instead of a number, e.g. 1200.
1623
+ // I suspect it's done by certain plugins that randomize browser properties to prevent fingerprinting.
1624
+ //
1625
+ // Some browsers (IE, Edge ≤18) don't provide `screen.availLeft` and `screen.availTop`. The property values are
1626
+ // replaced with 0 in such cases to not lose the entropy from `screen.availWidth` and `screen.availHeight`.
1627
+ return [
1628
+ replaceNaN(toFloat(s.availTop), null),
1629
+ replaceNaN(toFloat(s.width) - toFloat(s.availWidth) - replaceNaN(toFloat(s.availLeft), 0), null),
1630
+ replaceNaN(toFloat(s.height) - toFloat(s.availHeight) - replaceNaN(toFloat(s.availTop), 0), null),
1631
+ replaceNaN(toFloat(s.availLeft), null),
1632
+ ];
1633
+ }
1634
+ function isFrameSizeNull(frameSize) {
1635
+ for (var i = 0; i < 4; ++i) {
1636
+ if (frameSize[i]) {
1637
+ return false;
1638
+ }
1639
+ }
1640
+ return true;
1641
+ }
1642
+
1643
+ function getHardwareConcurrency() {
1644
+ // sometimes hardware concurrency is a string
1645
+ return replaceNaN(toInt(navigator.hardwareConcurrency), undefined);
1646
+ }
1647
+
1648
+ function getTimezone() {
1649
+ var _a;
1650
+ var DateTimeFormat = (_a = window.Intl) === null || _a === void 0 ? void 0 : _a.DateTimeFormat;
1651
+ if (DateTimeFormat) {
1652
+ var timezone = new DateTimeFormat().resolvedOptions().timeZone;
1653
+ if (timezone) {
1654
+ return timezone;
1655
+ }
1656
+ }
1657
+ // For browsers that don't support timezone names
1658
+ // The minus is intentional because the JS offset is opposite to the real offset
1659
+ var offset = -getTimezoneOffset();
1660
+ return "UTC".concat(offset >= 0 ? "+" : "").concat(Math.abs(offset));
1661
+ }
1662
+ function getTimezoneOffset() {
1663
+ var currentYear = new Date().getFullYear();
1664
+ // The timezone offset may change over time due to daylight saving time (DST) shifts.
1665
+ // The non-DST timezone offset is used as the result timezone offset.
1666
+ // Since the DST season differs in the northern and the southern hemispheres,
1667
+ // both January and July timezones offsets are considered.
1668
+ return Math.max(
1669
+ // `getTimezoneOffset` returns a number as a string in some unidentified cases
1670
+ toFloat(new Date(currentYear, 0, 1).getTimezoneOffset()),
1671
+ toFloat(new Date(currentYear, 6, 1).getTimezoneOffset()),
1672
+ );
1673
+ }
1674
+
1675
+ function getSessionStorage() {
1676
+ try {
1677
+ return !!window.sessionStorage;
1678
+ }
1679
+ catch (error) {
1680
+ /* SecurityError when referencing it means it exists */
1681
+ return true;
1682
+ }
1683
+ }
1684
+
1685
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=781447
1686
+ function getLocalStorage() {
1687
+ try {
1688
+ return !!window.localStorage;
1689
+ }
1690
+ catch (e) {
1691
+ /* SecurityError when referencing it means it exists */
1692
+ return true;
1693
+ }
1694
+ }
1695
+
1696
+ function getIndexedDB() {
1697
+ // IE and Edge don't allow accessing indexedDB in private mode, therefore IE and Edge will have different
1698
+ // visitor identifier in normal and private modes.
1699
+ if (isTrident() || isEdgeHTML()) {
1700
+ return undefined;
1701
+ }
1702
+ try {
1703
+ return !!window.indexedDB;
1704
+ }
1705
+ catch (e) {
1706
+ /* SecurityError when referencing it means it exists */
1707
+ return true;
1708
+ }
1709
+ }
1710
+
1711
+ function getOpenDatabase() {
1712
+ return !!window.openDatabase;
1713
+ }
1714
+
1715
+ function getCpuClass() {
1716
+ return navigator.cpuClass;
1717
+ }
1718
+
1719
+ function getPlatform() {
1720
+ // Android Chrome 86 and 87 and Android Firefox 80 and 84 don't mock the platform value when desktop mode is requested
1721
+ var platform = navigator.platform;
1722
+ // iOS mocks the platform value when desktop version is requested: https://github.com/fingerprintjs/fingerprintjs/issues/514
1723
+ // iPad uses desktop mode by default since iOS 13
1724
+ // The value is 'MacIntel' on M1 Macs
1725
+ // The value is 'iPhone' on iPod Touch
1726
+ if (platform === "MacIntel") {
1727
+ if (isWebKit() && !isDesktopSafari()) {
1728
+ return isIPad() ? "iPad" : "iPhone";
1729
+ }
1730
+ }
1731
+ return platform;
1732
+ }
1733
+
1734
+ function getVendor() {
1735
+ return navigator.vendor || "";
1736
+ }
1737
+
1738
+ /**
1739
+ * Checks for browser-specific (not engine specific) global variables to tell browsers with the same engine apart.
1740
+ * Only somewhat popular browsers are considered.
1741
+ */
1742
+ function getVendorFlavors() {
1743
+ var flavors = [];
1744
+ for (
1745
+ var _i = 0,
1746
+ _a = [
1747
+ // Blink and some browsers on iOS
1748
+ "chrome",
1749
+ // Safari on macOS
1750
+ "safari",
1751
+ // Chrome on iOS (checked in 85 on 13 and 87 on 14)
1752
+ "__crWeb",
1753
+ "__gCrWeb",
1754
+ // Yandex Browser on iOS, macOS and Android (checked in 21.2 on iOS 14, macOS and Android)
1755
+ "yandex",
1756
+ // Yandex Browser on iOS (checked in 21.2 on 14)
1757
+ "__yb",
1758
+ "__ybro",
1759
+ // Firefox on iOS (checked in 32 on 14)
1760
+ "__firefox__",
1761
+ // Edge on iOS (checked in 46 on 14)
1762
+ "__edgeTrackingPreventionStatistics",
1763
+ "webkit",
1764
+ // Opera Touch on iOS (checked in 2.6 on 14)
1765
+ "oprt",
1766
+ // Samsung Internet on Android (checked in 11.1)
1767
+ "samsungAr",
1768
+ // UC Browser on Android (checked in 12.10 and 13.0)
1769
+ "ucweb",
1770
+ "UCShellJava",
1771
+ // Puffin on Android (checked in 9.0)
1772
+ "puffinDevice",
1773
+ // UC on iOS and Opera on Android have no specific global variables
1774
+ // Edge for Android isn't checked
1775
+ ];
1776
+ _i < _a.length;
1777
+ _i++
1778
+ ) {
1779
+ var key = _a[_i];
1780
+ var value = window[key];
1781
+ if (value && typeof value === "object") {
1782
+ flavors.push(key);
1783
+ }
1784
+ }
1785
+ return flavors.sort();
1786
+ }
1787
+
1788
+ /**
1789
+ * navigator.cookieEnabled cannot detect custom or nuanced cookie blocking configurations. For example, when blocking
1790
+ * cookies via the Advanced Privacy Settings in IE9, it always returns true. And there have been issues in the past with
1791
+ * site-specific exceptions. Don't rely on it.
1792
+ *
1793
+ * @see https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cookies.js Taken from here
1794
+ */
1795
+ function areCookiesEnabled() {
1796
+ var d = document;
1797
+ // Taken from here: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cookies.js
1798
+ // navigator.cookieEnabled cannot detect custom or nuanced cookie blocking configurations. For example, when blocking
1799
+ // cookies via the Advanced Privacy Settings in IE9, it always returns true. And there have been issues in the past
1800
+ // with site-specific exceptions. Don't rely on it.
1801
+ // try..catch because some in situations `document.cookie` is exposed but throws a
1802
+ // SecurityError if you try to access it; e.g. documents created from data URIs
1803
+ // or in sandboxed iframes (depending on flags/context)
1804
+ try {
1805
+ // Create cookie
1806
+ d.cookie = "cookietest=1; SameSite=Strict;";
1807
+ var result = d.cookie.indexOf("cookietest=") !== -1;
1808
+ // Delete cookie
1809
+ d.cookie = "cookietest=1; SameSite=Strict; expires=Thu, 01-Jan-1970 00:00:01 GMT";
1810
+ return result;
1811
+ }
1812
+ catch (e) {
1813
+ return false;
1814
+ }
1815
+ }
1816
+
1817
+ /**
1818
+ * Only single element selector are supported (no operators like space, +, >, etc).
1819
+ * `embed` and `position: fixed;` will be considered as blocked anyway because it always has no offsetParent.
1820
+ * Avoid `iframe` and anything with `[src=]` because they produce excess HTTP requests.
1821
+ *
1822
+ * The "inappropriate" selectors are obfuscated. See https://github.com/fingerprintjs/fingerprintjs/issues/734.
1823
+ * A function is used instead of a plain object to help tree-shaking.
1824
+ *
1825
+ * The function code is generated automatically. See docs/content_blockers.md to learn how to make the list.
1826
+ */
1827
+ function getFilters() {
1828
+ var fromB64 = atob; // Just for better minification
1829
+ return {
1830
+ abpIndo: [
1831
+ "#Iklan-Melayang",
1832
+ "#Kolom-Iklan-728",
1833
+ "#SidebarIklan-wrapper",
1834
+ '[title="ALIENBOLA" i]',
1835
+ fromB64("I0JveC1CYW5uZXItYWRz"),
1836
+ ],
1837
+ abpvn: [".quangcao", "#mobileCatfish", fromB64("LmNsb3NlLWFkcw=="), '[id^="bn_bottom_fixed_"]', "#pmadv"],
1838
+ adBlockFinland: [
1839
+ ".mainostila",
1840
+ fromB64("LnNwb25zb3JpdA=="),
1841
+ ".ylamainos",
1842
+ fromB64("YVtocmVmKj0iL2NsaWNrdGhyZ2guYXNwPyJd"),
1843
+ fromB64("YVtocmVmXj0iaHR0cHM6Ly9hcHAucmVhZHBlYWsuY29tL2FkcyJd"),
1844
+ ],
1845
+ adBlockPersian: [
1846
+ "#navbar_notice_50",
1847
+ ".kadr",
1848
+ 'TABLE[width="140px"]',
1849
+ "#divAgahi",
1850
+ fromB64("YVtocmVmXj0iaHR0cDovL2cxLnYuZndtcm0ubmV0L2FkLyJd"),
1851
+ ],
1852
+ adBlockWarningRemoval: [
1853
+ "#adblock-honeypot",
1854
+ ".adblocker-root",
1855
+ ".wp_adblock_detect",
1856
+ fromB64("LmhlYWRlci1ibG9ja2VkLWFk"),
1857
+ fromB64("I2FkX2Jsb2NrZXI="),
1858
+ ],
1859
+ adGuardAnnoyances: [
1860
+ ".hs-sosyal",
1861
+ "#cookieconsentdiv",
1862
+ 'div[class^="app_gdpr"]',
1863
+ ".as-oil",
1864
+ '[data-cypress="soft-push-notification-modal"]',
1865
+ ],
1866
+ adGuardBase: [
1867
+ ".BetterJsPopOverlay",
1868
+ fromB64("I2FkXzMwMFgyNTA="),
1869
+ fromB64("I2Jhbm5lcmZsb2F0MjI="),
1870
+ fromB64("I2NhbXBhaWduLWJhbm5lcg=="),
1871
+ fromB64("I0FkLUNvbnRlbnQ="),
1872
+ ],
1873
+ adGuardChinese: [
1874
+ fromB64("LlppX2FkX2FfSA=="),
1875
+ fromB64("YVtocmVmKj0iLmh0aGJldDM0LmNvbSJd"),
1876
+ "#widget-quan",
1877
+ fromB64("YVtocmVmKj0iLzg0OTkyMDIwLnh5eiJd"),
1878
+ fromB64("YVtocmVmKj0iLjE5NTZobC5jb20vIl0="),
1879
+ ],
1880
+ adGuardFrench: [
1881
+ "#pavePub",
1882
+ fromB64("LmFkLWRlc2t0b3AtcmVjdGFuZ2xl"),
1883
+ ".mobile_adhesion",
1884
+ ".widgetadv",
1885
+ fromB64("LmFkc19iYW4="),
1886
+ ],
1887
+ adGuardGerman: ['aside[data-portal-id="leaderboard"]'],
1888
+ adGuardJapanese: [
1889
+ "#kauli_yad_1",
1890
+ fromB64("YVtocmVmXj0iaHR0cDovL2FkMi50cmFmZmljZ2F0ZS5uZXQvIl0="),
1891
+ fromB64("Ll9wb3BJbl9pbmZpbml0ZV9hZA=="),
1892
+ fromB64("LmFkZ29vZ2xl"),
1893
+ fromB64("Ll9faXNib29zdFJldHVybkFk"),
1894
+ ],
1895
+ adGuardMobile: [
1896
+ fromB64("YW1wLWF1dG8tYWRz"),
1897
+ fromB64("LmFtcF9hZA=="),
1898
+ 'amp-embed[type="24smi"]',
1899
+ "#mgid_iframe1",
1900
+ fromB64("I2FkX2ludmlld19hcmVh"),
1901
+ ],
1902
+ adGuardRussian: [
1903
+ fromB64("YVtocmVmXj0iaHR0cHM6Ly9hZC5sZXRtZWFkcy5jb20vIl0="),
1904
+ fromB64("LnJlY2xhbWE="),
1905
+ 'div[id^="smi2adblock"]',
1906
+ fromB64("ZGl2W2lkXj0iQWRGb3hfYmFubmVyXyJd"),
1907
+ "#psyduckpockeball",
1908
+ ],
1909
+ adGuardSocial: [
1910
+ fromB64("YVtocmVmXj0iLy93d3cuc3R1bWJsZXVwb24uY29tL3N1Ym1pdD91cmw9Il0="),
1911
+ fromB64("YVtocmVmXj0iLy90ZWxlZ3JhbS5tZS9zaGFyZS91cmw/Il0="),
1912
+ ".etsy-tweet",
1913
+ "#inlineShare",
1914
+ ".popup-social",
1915
+ ],
1916
+ adGuardSpanishPortuguese: ["#barraPublicidade", "#Publicidade", "#publiEspecial", "#queTooltip", ".cnt-publi"],
1917
+ adGuardTrackingProtection: [
1918
+ "#qoo-counter",
1919
+ fromB64("YVtocmVmXj0iaHR0cDovL2NsaWNrLmhvdGxvZy5ydS8iXQ=="),
1920
+ fromB64("YVtocmVmXj0iaHR0cDovL2hpdGNvdW50ZXIucnUvdG9wL3N0YXQucGhwIl0="),
1921
+ fromB64("YVtocmVmXj0iaHR0cDovL3RvcC5tYWlsLnJ1L2p1bXAiXQ=="),
1922
+ "#top100counter",
1923
+ ],
1924
+ adGuardTurkish: [
1925
+ "#backkapat",
1926
+ fromB64("I3Jla2xhbWk="),
1927
+ fromB64("YVtocmVmXj0iaHR0cDovL2Fkc2Vydi5vbnRlay5jb20udHIvIl0="),
1928
+ fromB64("YVtocmVmXj0iaHR0cDovL2l6bGVuemkuY29tL2NhbXBhaWduLyJd"),
1929
+ fromB64("YVtocmVmXj0iaHR0cDovL3d3dy5pbnN0YWxsYWRzLm5ldC8iXQ=="),
1930
+ ],
1931
+ bulgarian: [fromB64("dGQjZnJlZW5ldF90YWJsZV9hZHM="), "#ea_intext_div", ".lapni-pop-over", "#xenium_hot_offers"],
1932
+ easyList: [
1933
+ ".yb-floorad",
1934
+ fromB64("LndpZGdldF9wb19hZHNfd2lkZ2V0"),
1935
+ fromB64("LnRyYWZmaWNqdW5reS1hZA=="),
1936
+ ".textad_headline",
1937
+ fromB64("LnNwb25zb3JlZC10ZXh0LWxpbmtz"),
1938
+ ],
1939
+ easyListChina: [
1940
+ fromB64("LmFwcGd1aWRlLXdyYXBbb25jbGljayo9ImJjZWJvcy5jb20iXQ=="),
1941
+ fromB64("LmZyb250cGFnZUFkdk0="),
1942
+ "#taotaole",
1943
+ "#aafoot.top_box",
1944
+ ".cfa_popup",
1945
+ ],
1946
+ easyListCookie: [
1947
+ ".ezmob-footer",
1948
+ ".cc-CookieWarning",
1949
+ "[data-cookie-number]",
1950
+ fromB64("LmF3LWNvb2tpZS1iYW5uZXI="),
1951
+ ".sygnal24-gdpr-modal-wrap",
1952
+ ],
1953
+ easyListCzechSlovak: [
1954
+ "#onlajny-stickers",
1955
+ fromB64("I3Jla2xhbW5pLWJveA=="),
1956
+ fromB64("LnJla2xhbWEtbWVnYWJvYXJk"),
1957
+ ".sklik",
1958
+ fromB64("W2lkXj0ic2tsaWtSZWtsYW1hIl0="),
1959
+ ],
1960
+ easyListDutch: [
1961
+ fromB64("I2FkdmVydGVudGll"),
1962
+ fromB64("I3ZpcEFkbWFya3RCYW5uZXJCbG9jaw=="),
1963
+ ".adstekst",
1964
+ fromB64("YVtocmVmXj0iaHR0cHM6Ly94bHR1YmUubmwvY2xpY2svIl0="),
1965
+ "#semilo-lrectangle",
1966
+ ],
1967
+ easyListGermany: [
1968
+ "#SSpotIMPopSlider",
1969
+ fromB64("LnNwb25zb3JsaW5rZ3J1ZW4="),
1970
+ fromB64("I3dlcmJ1bmdza3k="),
1971
+ fromB64("I3Jla2xhbWUtcmVjaHRzLW1pdHRl"),
1972
+ fromB64("YVtocmVmXj0iaHR0cHM6Ly9iZDc0Mi5jb20vIl0="),
1973
+ ],
1974
+ easyListItaly: [
1975
+ fromB64("LmJveF9hZHZfYW5udW5jaQ=="),
1976
+ ".sb-box-pubbliredazionale",
1977
+ fromB64("YVtocmVmXj0iaHR0cDovL2FmZmlsaWF6aW9uaWFkcy5zbmFpLml0LyJd"),
1978
+ fromB64("YVtocmVmXj0iaHR0cHM6Ly9hZHNlcnZlci5odG1sLml0LyJd"),
1979
+ fromB64("YVtocmVmXj0iaHR0cHM6Ly9hZmZpbGlhemlvbmlhZHMuc25haS5pdC8iXQ=="),
1980
+ ],
1981
+ easyListLithuania: [
1982
+ fromB64("LnJla2xhbW9zX3RhcnBhcw=="),
1983
+ fromB64("LnJla2xhbW9zX251b3JvZG9z"),
1984
+ fromB64("aW1nW2FsdD0iUmVrbGFtaW5pcyBza3lkZWxpcyJd"),
1985
+ fromB64("aW1nW2FsdD0iRGVkaWt1b3RpLmx0IHNlcnZlcmlhaSJd"),
1986
+ fromB64("aW1nW2FsdD0iSG9zdGluZ2FzIFNlcnZlcmlhaS5sdCJd"),
1987
+ ],
1988
+ estonian: [fromB64("QVtocmVmKj0iaHR0cDovL3BheTRyZXN1bHRzMjQuZXUiXQ==")],
1989
+ fanboyAnnoyances: ["#ac-lre-player", ".navigate-to-top", "#subscribe_popup", ".newsletter_holder", "#back-top"],
1990
+ fanboyAntiFacebook: [".util-bar-module-firefly-visible"],
1991
+ fanboyEnhancedTrackers: [
1992
+ ".open.pushModal",
1993
+ "#issuem-leaky-paywall-articles-zero-remaining-nag",
1994
+ "#sovrn_container",
1995
+ 'div[class$="-hide"][zoompage-fontsize][style="display: block;"]',
1996
+ ".BlockNag__Card",
1997
+ ],
1998
+ fanboySocial: ["#FollowUs", "#meteored_share", "#social_follow", ".article-sharer", ".community__social-desc"],
1999
+ frellwitSwedish: [
2000
+ fromB64("YVtocmVmKj0iY2FzaW5vcHJvLnNlIl1bdGFyZ2V0PSJfYmxhbmsiXQ=="),
2001
+ fromB64("YVtocmVmKj0iZG9rdG9yLXNlLm9uZWxpbmsubWUiXQ=="),
2002
+ "article.category-samarbete",
2003
+ fromB64("ZGl2LmhvbGlkQWRz"),
2004
+ "ul.adsmodern",
2005
+ ],
2006
+ greekAdBlock: [
2007
+ fromB64("QVtocmVmKj0iYWRtYW4ub3RlbmV0LmdyL2NsaWNrPyJd"),
2008
+ fromB64("QVtocmVmKj0iaHR0cDovL2F4aWFiYW5uZXJzLmV4b2R1cy5nci8iXQ=="),
2009
+ fromB64("QVtocmVmKj0iaHR0cDovL2ludGVyYWN0aXZlLmZvcnRobmV0LmdyL2NsaWNrPyJd"),
2010
+ "DIV.agores300",
2011
+ "TABLE.advright",
2012
+ ],
2013
+ hungarian: [
2014
+ "#cemp_doboz",
2015
+ ".optimonk-iframe-container",
2016
+ fromB64("LmFkX19tYWlu"),
2017
+ fromB64("W2NsYXNzKj0iR29vZ2xlQWRzIl0="),
2018
+ "#hirdetesek_box",
2019
+ ],
2020
+ iDontCareAboutCookies: [
2021
+ '.alert-info[data-block-track*="CookieNotice"]',
2022
+ ".ModuleTemplateCookieIndicator",
2023
+ ".o--cookies--container",
2024
+ "#cookies-policy-sticky",
2025
+ "#stickyCookieBar",
2026
+ ],
2027
+ icelandicAbp: [fromB64("QVtocmVmXj0iL2ZyYW1ld29yay9yZXNvdXJjZXMvZm9ybXMvYWRzLmFzcHgiXQ==")],
2028
+ latvian: [
2029
+ fromB64(
2030
+ "YVtocmVmPSJodHRwOi8vd3d3LnNhbGlkemluaS5sdi8iXVtzdHlsZT0iZGlzcGxheTogYmxvY2s7IHdpZHRoOiAxMjBweDsgaGVpZ2h0O" +
2031
+ "iA0MHB4OyBvdmVyZmxvdzogaGlkZGVuOyBwb3NpdGlvbjogcmVsYXRpdmU7Il0=",
2032
+ ),
2033
+ fromB64(
2034
+ "YVtocmVmPSJodHRwOi8vd3d3LnNhbGlkemluaS5sdi8iXVtzdHlsZT0iZGlzcGxheTogYmxvY2s7IHdpZHRoOiA4OHB4OyBoZWlnaHQ6I" +
2035
+ "DMxcHg7IG92ZXJmbG93OiBoaWRkZW47IHBvc2l0aW9uOiByZWxhdGl2ZTsiXQ==",
2036
+ ),
2037
+ ],
2038
+ listKr: [
2039
+ fromB64("YVtocmVmKj0iLy9hZC5wbGFuYnBsdXMuY28ua3IvIl0="),
2040
+ fromB64("I2xpdmVyZUFkV3JhcHBlcg=="),
2041
+ fromB64("YVtocmVmKj0iLy9hZHYuaW1hZHJlcC5jby5rci8iXQ=="),
2042
+ fromB64("aW5zLmZhc3R2aWV3LWFk"),
2043
+ ".revenue_unit_item.dable",
2044
+ ],
2045
+ listeAr: [
2046
+ fromB64("LmdlbWluaUxCMUFk"),
2047
+ ".right-and-left-sponsers",
2048
+ fromB64("YVtocmVmKj0iLmFmbGFtLmluZm8iXQ=="),
2049
+ fromB64("YVtocmVmKj0iYm9vcmFxLm9yZyJd"),
2050
+ fromB64("YVtocmVmKj0iZHViaXp6bGUuY29tL2FyLz91dG1fc291cmNlPSJd"),
2051
+ ],
2052
+ listeFr: [
2053
+ fromB64("YVtocmVmXj0iaHR0cDovL3Byb21vLnZhZG9yLmNvbS8iXQ=="),
2054
+ fromB64("I2FkY29udGFpbmVyX3JlY2hlcmNoZQ=="),
2055
+ fromB64("YVtocmVmKj0id2Vib3JhbWEuZnIvZmNnaS1iaW4vIl0="),
2056
+ ".site-pub-interstitiel",
2057
+ 'div[id^="crt-"][data-criteo-id]',
2058
+ ],
2059
+ officialPolish: [
2060
+ "#ceneo-placeholder-ceneo-12",
2061
+ fromB64("W2hyZWZePSJodHRwczovL2FmZi5zZW5kaHViLnBsLyJd"),
2062
+ fromB64("YVtocmVmXj0iaHR0cDovL2Fkdm1hbmFnZXIudGVjaGZ1bi5wbC9yZWRpcmVjdC8iXQ=="),
2063
+ fromB64("YVtocmVmXj0iaHR0cDovL3d3dy50cml6ZXIucGwvP3V0bV9zb3VyY2UiXQ=="),
2064
+ fromB64("ZGl2I3NrYXBpZWNfYWQ="),
2065
+ ],
2066
+ ro: [
2067
+ fromB64("YVtocmVmXj0iLy9hZmZ0cmsuYWx0ZXgucm8vQ291bnRlci9DbGljayJd"),
2068
+ fromB64("YVtocmVmXj0iaHR0cHM6Ly9ibGFja2ZyaWRheXNhbGVzLnJvL3Ryay9zaG9wLyJd"),
2069
+ fromB64("YVtocmVmXj0iaHR0cHM6Ly9ldmVudC4ycGVyZm9ybWFudC5jb20vZXZlbnRzL2NsaWNrIl0="),
2070
+ fromB64("YVtocmVmXj0iaHR0cHM6Ly9sLnByb2ZpdHNoYXJlLnJvLyJd"),
2071
+ 'a[href^="/url/"]',
2072
+ ],
2073
+ ruAd: [
2074
+ fromB64("YVtocmVmKj0iLy9mZWJyYXJlLnJ1LyJd"),
2075
+ fromB64("YVtocmVmKj0iLy91dGltZy5ydS8iXQ=="),
2076
+ fromB64("YVtocmVmKj0iOi8vY2hpa2lkaWtpLnJ1Il0="),
2077
+ "#pgeldiz",
2078
+ ".yandex-rtb-block",
2079
+ ],
2080
+ thaiAds: [
2081
+ "a[href*=macau-uta-popup]",
2082
+ fromB64("I2Fkcy1nb29nbGUtbWlkZGxlX3JlY3RhbmdsZS1ncm91cA=="),
2083
+ fromB64("LmFkczMwMHM="),
2084
+ ".bumq",
2085
+ ".img-kosana",
2086
+ ],
2087
+ webAnnoyancesUltralist: [
2088
+ "#mod-social-share-2",
2089
+ "#social-tools",
2090
+ fromB64("LmN0cGwtZnVsbGJhbm5lcg=="),
2091
+ ".zergnet-recommend",
2092
+ ".yt.btn-link.btn-md.btn",
2093
+ ],
2094
+ };
2095
+ }
2096
+ /**
2097
+ * The order of the returned array means nothing (it's always sorted alphabetically).
2098
+ *
2099
+ * Notice that the source is slightly unstable.
2100
+ * Safari provides a 2-taps way to disable all content blockers on a page temporarily.
2101
+ * Also content blockers can be disabled permanently for a domain, but it requires 4 taps.
2102
+ * So empty array shouldn't be treated as "no blockers", it should be treated as "no signal".
2103
+ * If you are a website owner, don't make your visitors want to disable content blockers.
2104
+ */
2105
+ function getDomBlockers(_a) {
2106
+ var _b = _a === void 0 ? {} : _a,
2107
+ debug = _b.debug;
2108
+ return __awaiter(this, void 0, void 0, function () {
2109
+ var filters, filterNames, allSelectors, blockedSelectors, activeBlockers;
2110
+ var _c;
2111
+ return __generator(this, function (_d) {
2112
+ switch (_d.label) {
2113
+ case 0:
2114
+ if (!isApplicable()) {
2115
+ return [2 /*return*/, undefined];
2116
+ }
2117
+ filters = getFilters();
2118
+ filterNames = Object.keys(filters);
2119
+ allSelectors = (_c = []).concat.apply(
2120
+ _c,
2121
+ filterNames.map(function (filterName) {
2122
+ return filters[filterName];
2123
+ }),
2124
+ );
2125
+ return [4 /*yield*/, getBlockedSelectors(allSelectors)];
2126
+ case 1:
2127
+ blockedSelectors = _d.sent();
2128
+ if (debug) {
2129
+ printDebug(filters, blockedSelectors);
2130
+ }
2131
+ activeBlockers = filterNames.filter(function (filterName) {
2132
+ var selectors = filters[filterName];
2133
+ var blockedCount = countTruthy(
2134
+ selectors.map(function (selector) {
2135
+ return blockedSelectors[selector];
2136
+ }),
2137
+ );
2138
+ return blockedCount > selectors.length * 0.6;
2139
+ });
2140
+ activeBlockers.sort();
2141
+ return [2 /*return*/, activeBlockers];
2142
+ }
2143
+ });
2144
+ });
2145
+ }
2146
+ function isApplicable() {
2147
+ // Safari (desktop and mobile) and all Android browsers keep content blockers in both regular and private mode
2148
+ return isWebKit() || isAndroid();
2149
+ }
2150
+ function getBlockedSelectors(selectors) {
2151
+ var _a;
2152
+ return __awaiter(this, void 0, void 0, function () {
2153
+ var d, root, elements, blockedSelectors, i, element, holder, i;
2154
+ return __generator(this, function (_b) {
2155
+ switch (_b.label) {
2156
+ case 0:
2157
+ d = document;
2158
+ root = d.createElement("div");
2159
+ elements = new Array(selectors.length);
2160
+ blockedSelectors = {}; // Set() isn't used just in case somebody need older browser support
2161
+ forceShow(root);
2162
+ // First create all elements that can be blocked. If the DOM steps below are done in a single cycle,
2163
+ // browser will alternate tree modification and layout reading, that is very slow.
2164
+ for (i = 0; i < selectors.length; ++i) {
2165
+ element = selectorToElement(selectors[i]);
2166
+ if (element.tagName === "DIALOG") {
2167
+ element.show();
2168
+ }
2169
+ holder = d.createElement("div"); // Protects from unwanted effects of `+` and `~` selectors of filters
2170
+ forceShow(holder);
2171
+ holder.appendChild(element);
2172
+ root.appendChild(holder);
2173
+ elements[i] = element;
2174
+ }
2175
+ _b.label = 1;
2176
+ case 1:
2177
+ if (!!d.body) return [3 /*break*/, 3];
2178
+ return [4 /*yield*/, wait(50)];
2179
+ case 2:
2180
+ _b.sent();
2181
+ return [3 /*break*/, 1];
2182
+ case 3:
2183
+ d.body.appendChild(root);
2184
+ try {
2185
+ // Then check which of the elements are blocked
2186
+ for (i = 0; i < selectors.length; ++i) {
2187
+ if (!elements[i].offsetParent) {
2188
+ blockedSelectors[selectors[i]] = true;
2189
+ }
2190
+ }
2191
+ }
2192
+ finally {
2193
+ // Then remove the elements
2194
+ (_a = root.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(root);
2195
+ }
2196
+ return [2 /*return*/, blockedSelectors];
2197
+ }
2198
+ });
2199
+ });
2200
+ }
2201
+ function forceShow(element) {
2202
+ element.style.setProperty("display", "block", "important");
2203
+ }
2204
+ function printDebug(filters, blockedSelectors) {
2205
+ var message = "DOM blockers debug:\n```";
2206
+ for (var _i = 0, _a = Object.keys(filters); _i < _a.length; _i++) {
2207
+ var filterName = _a[_i];
2208
+ message += "\n".concat(filterName, ":");
2209
+ for (var _b = 0, _c = filters[filterName]; _b < _c.length; _b++) {
2210
+ var selector = _c[_b];
2211
+ message += "\n ".concat(blockedSelectors[selector] ? "🚫" : "➡️", " ").concat(selector);
2212
+ }
2213
+ }
2214
+ // console.log is ok here because it's under a debug clause
2215
+ // eslint-disable-next-line no-console
2216
+ console.log("".concat(message, "\n```"));
2217
+ }
2218
+
2219
+ /**
2220
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/color-gamut
2221
+ */
2222
+ function getColorGamut() {
2223
+ // rec2020 includes p3 and p3 includes srgb
2224
+ for (var _i = 0, _a = ["rec2020", "p3", "srgb"]; _i < _a.length; _i++) {
2225
+ var gamut = _a[_i];
2226
+ if (matchMedia("(color-gamut: ".concat(gamut, ")")).matches) {
2227
+ return gamut;
2228
+ }
2229
+ }
2230
+ return undefined;
2231
+ }
2232
+
2233
+ /**
2234
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/inverted-colors
2235
+ */
2236
+ function areColorsInverted() {
2237
+ if (doesMatch$4("inverted")) {
2238
+ return true;
2239
+ }
2240
+ if (doesMatch$4("none")) {
2241
+ return false;
2242
+ }
2243
+ return undefined;
2244
+ }
2245
+ function doesMatch$4(value) {
2246
+ return matchMedia("(inverted-colors: ".concat(value, ")")).matches;
2247
+ }
2248
+
2249
+ /**
2250
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/forced-colors
2251
+ */
2252
+ function areColorsForced() {
2253
+ if (doesMatch$3("active")) {
2254
+ return true;
2255
+ }
2256
+ if (doesMatch$3("none")) {
2257
+ return false;
2258
+ }
2259
+ return undefined;
2260
+ }
2261
+ function doesMatch$3(value) {
2262
+ return matchMedia("(forced-colors: ".concat(value, ")")).matches;
2263
+ }
2264
+
2265
+ var maxValueToCheck = 100;
2266
+ /**
2267
+ * If the display is monochrome (e.g. black&white), the value will be ≥0 and will mean the number of bits per pixel.
2268
+ * If the display is not monochrome, the returned value will be 0.
2269
+ * If the browser doesn't support this feature, the returned value will be undefined.
2270
+ *
2271
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/monochrome
2272
+ */
2273
+ function getMonochromeDepth() {
2274
+ if (!matchMedia("(min-monochrome: 0)").matches) {
2275
+ // The media feature isn't supported by the browser
2276
+ return undefined;
2277
+ }
2278
+ // A variation of binary search algorithm can be used here.
2279
+ // But since expected values are very small (≤10), there is no sense in adding the complexity.
2280
+ for (var i = 0; i <= maxValueToCheck; ++i) {
2281
+ if (matchMedia("(max-monochrome: ".concat(i, ")")).matches) {
2282
+ return i;
2283
+ }
2284
+ }
2285
+ throw new Error("Too high value");
2286
+ }
2287
+
2288
+ /**
2289
+ * @see https://www.w3.org/TR/mediaqueries-5/#prefers-contrast
2290
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-contrast
2291
+ */
2292
+ function getContrastPreference() {
2293
+ if (doesMatch$2("no-preference")) {
2294
+ return 0 /* ContrastPreference.None */;
2295
+ }
2296
+ // The sources contradict on the keywords. Probably 'high' and 'low' will never be implemented.
2297
+ // Need to check it when all browsers implement the feature.
2298
+ if (doesMatch$2("high") || doesMatch$2("more")) {
2299
+ return 1 /* ContrastPreference.More */;
2300
+ }
2301
+ if (doesMatch$2("low") || doesMatch$2("less")) {
2302
+ return -1 /* ContrastPreference.Less */;
2303
+ }
2304
+ if (doesMatch$2("forced")) {
2305
+ return 10 /* ContrastPreference.ForcedColors */;
2306
+ }
2307
+ return undefined;
2308
+ }
2309
+ function doesMatch$2(value) {
2310
+ return matchMedia("(prefers-contrast: ".concat(value, ")")).matches;
2311
+ }
2312
+
2313
+ /**
2314
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion
2315
+ */
2316
+ function isMotionReduced() {
2317
+ if (doesMatch$1("reduce")) {
2318
+ return true;
2319
+ }
2320
+ if (doesMatch$1("no-preference")) {
2321
+ return false;
2322
+ }
2323
+ return undefined;
2324
+ }
2325
+ function doesMatch$1(value) {
2326
+ return matchMedia("(prefers-reduced-motion: ".concat(value, ")")).matches;
2327
+ }
2328
+
2329
+ /**
2330
+ * @see https://www.w3.org/TR/mediaqueries-5/#dynamic-range
2331
+ */
2332
+ function isHDR() {
2333
+ if (doesMatch("high")) {
2334
+ return true;
2335
+ }
2336
+ if (doesMatch("standard")) {
2337
+ return false;
2338
+ }
2339
+ return undefined;
2340
+ }
2341
+ function doesMatch(value) {
2342
+ return matchMedia("(dynamic-range: ".concat(value, ")")).matches;
2343
+ }
2344
+
2345
+ var M = Math; // To reduce the minified code size
2346
+ var fallbackFn = function () {
2347
+ return 0;
2348
+ };
2349
+ /**
2350
+ * @see https://gitlab.torproject.org/legacy/trac/-/issues/13018
2351
+ * @see https://bugzilla.mozilla.org/show_bug.cgi?id=531915
2352
+ */
2353
+ function getMathFingerprint() {
2354
+ // Native operations
2355
+ var acos = M.acos || fallbackFn;
2356
+ var acosh = M.acosh || fallbackFn;
2357
+ var asin = M.asin || fallbackFn;
2358
+ var asinh = M.asinh || fallbackFn;
2359
+ var atanh = M.atanh || fallbackFn;
2360
+ var atan = M.atan || fallbackFn;
2361
+ var sin = M.sin || fallbackFn;
2362
+ var sinh = M.sinh || fallbackFn;
2363
+ var cos = M.cos || fallbackFn;
2364
+ var cosh = M.cosh || fallbackFn;
2365
+ var tan = M.tan || fallbackFn;
2366
+ var tanh = M.tanh || fallbackFn;
2367
+ var exp = M.exp || fallbackFn;
2368
+ var expm1 = M.expm1 || fallbackFn;
2369
+ var log1p = M.log1p || fallbackFn;
2370
+ // Operation polyfills
2371
+ var powPI = function (value) {
2372
+ return M.pow(M.PI, value);
2373
+ };
2374
+ var acoshPf = function (value) {
2375
+ return M.log(value + M.sqrt(value * value - 1));
2376
+ };
2377
+ var asinhPf = function (value) {
2378
+ return M.log(value + M.sqrt(value * value + 1));
2379
+ };
2380
+ var atanhPf = function (value) {
2381
+ return M.log((1 + value) / (1 - value)) / 2;
2382
+ };
2383
+ var sinhPf = function (value) {
2384
+ return M.exp(value) - 1 / M.exp(value) / 2;
2385
+ };
2386
+ var coshPf = function (value) {
2387
+ return (M.exp(value) + 1 / M.exp(value)) / 2;
2388
+ };
2389
+ var expm1Pf = function (value) {
2390
+ return M.exp(value) - 1;
2391
+ };
2392
+ var tanhPf = function (value) {
2393
+ return (M.exp(2 * value) - 1) / (M.exp(2 * value) + 1);
2394
+ };
2395
+ var log1pPf = function (value) {
2396
+ return M.log(1 + value);
2397
+ };
2398
+ // Note: constant values are empirical
2399
+ return {
2400
+ acos: acos(0.123124234234234242),
2401
+ acosh: acosh(1e308),
2402
+ acoshPf: acoshPf(1e154),
2403
+ asin: asin(0.123124234234234242),
2404
+ asinh: asinh(1),
2405
+ asinhPf: asinhPf(1),
2406
+ atanh: atanh(0.5),
2407
+ atanhPf: atanhPf(0.5),
2408
+ atan: atan(0.5),
2409
+ sin: sin(-1e300),
2410
+ sinh: sinh(1),
2411
+ sinhPf: sinhPf(1),
2412
+ cos: cos(10.000000000123),
2413
+ cosh: cosh(1),
2414
+ coshPf: coshPf(1),
2415
+ tan: tan(-1e300),
2416
+ tanh: tanh(1),
2417
+ tanhPf: tanhPf(1),
2418
+ exp: exp(1),
2419
+ expm1: expm1(1),
2420
+ expm1Pf: expm1Pf(1),
2421
+ log1p: log1p(10),
2422
+ log1pPf: log1pPf(10),
2423
+ powPI: powPI(-100),
2424
+ };
2425
+ }
2426
+
2427
+ /**
2428
+ * We use m or w because these two characters take up the maximum width.
2429
+ * Also there are a couple of ligatures.
2430
+ */
2431
+ var defaultText = "mmMwWLliI0fiflO&1";
2432
+ /**
2433
+ * Settings of text blocks to measure. The keys are random but persistent words.
2434
+ */
2435
+ var presets = {
2436
+ /**
2437
+ * The default font. User can change it in desktop Chrome, desktop Firefox, IE 11,
2438
+ * Android Chrome (but only when the size is ≥ than the default) and Android Firefox.
2439
+ */
2440
+ default: [],
2441
+ /** OS font on macOS. User can change its size and weight. Applies after Safari restart. */
2442
+ apple: [{ font: "-apple-system-body" }],
2443
+ /** User can change it in desktop Chrome and desktop Firefox. */
2444
+ serif: [{ fontFamily: "serif" }],
2445
+ /** User can change it in desktop Chrome and desktop Firefox. */
2446
+ sans: [{ fontFamily: "sans-serif" }],
2447
+ /** User can change it in desktop Chrome and desktop Firefox. */
2448
+ mono: [{ fontFamily: "monospace" }],
2449
+ /**
2450
+ * Check the smallest allowed font size. User can change it in desktop Chrome, desktop Firefox and desktop Safari.
2451
+ * The height can be 0 in Chrome on a retina display.
2452
+ */
2453
+ min: [{ fontSize: "1px" }],
2454
+ /** Tells one OS from another in desktop Chrome. */
2455
+ system: [{ fontFamily: "system-ui" }],
2456
+ };
2457
+ /**
2458
+ * The result is a dictionary of the width of the text samples.
2459
+ * Heights aren't included because they give no extra entropy and are unstable.
2460
+ *
2461
+ * The result is very stable in IE 11, Edge 18 and Safari 14.
2462
+ * The result changes when the OS pixel density changes in Chromium 87. The real pixel density is required to solve,
2463
+ * but seems like it's impossible: https://stackoverflow.com/q/1713771/1118709.
2464
+ * The "min" and the "mono" (only on Windows) value may change when the page is zoomed in Firefox 87.
2465
+ */
2466
+ function getFontPreferences() {
2467
+ return withNaturalFonts(function (document, container) {
2468
+ var elements = {};
2469
+ var sizes = {};
2470
+ // First create all elements to measure. If the DOM steps below are done in a single cycle,
2471
+ // browser will alternate tree modification and layout reading, that is very slow.
2472
+ for (var _i = 0, _a = Object.keys(presets); _i < _a.length; _i++) {
2473
+ var key = _a[_i];
2474
+ var _b = presets[key],
2475
+ _c = _b[0],
2476
+ style = _c === void 0 ? {} : _c,
2477
+ _d = _b[1],
2478
+ text = _d === void 0 ? defaultText : _d;
2479
+ var element = document.createElement("span");
2480
+ element.textContent = text;
2481
+ element.style.whiteSpace = "nowrap";
2482
+ for (var _e = 0, _f = Object.keys(style); _e < _f.length; _e++) {
2483
+ var name_1 = _f[_e];
2484
+ var value = style[name_1];
2485
+ if (value !== undefined) {
2486
+ element.style[name_1] = value;
2487
+ }
2488
+ }
2489
+ elements[key] = element;
2490
+ container.appendChild(document.createElement("br"));
2491
+ container.appendChild(element);
2492
+ }
2493
+ // Then measure the created elements
2494
+ for (var _g = 0, _h = Object.keys(presets); _g < _h.length; _g++) {
2495
+ var key = _h[_g];
2496
+ sizes[key] = elements[key].getBoundingClientRect().width;
2497
+ }
2498
+ return sizes;
2499
+ });
2500
+ }
2501
+ /**
2502
+ * Creates a DOM environment that provides the most natural font available, including Android OS font.
2503
+ * Measurements of the elements are zoom-independent.
2504
+ * Don't put a content to measure inside an absolutely positioned element.
2505
+ */
2506
+ function withNaturalFonts(action, containerWidthPx) {
2507
+ if (containerWidthPx === void 0) {
2508
+ containerWidthPx = 4000;
2509
+ }
2510
+ /*
2511
+ * Requirements for Android Chrome to apply the system font size to a text inside an iframe:
2512
+ * - The iframe mustn't have a `display: none;` style;
2513
+ * - The text mustn't be positioned absolutely;
2514
+ * - The text block must be wide enough.
2515
+ * 2560px on some devices in portrait orientation for the biggest font size option (32px);
2516
+ * - There must be much enough text to form a few lines (I don't know the exact numbers);
2517
+ * - The text must have the `text-size-adjust: none` style. Otherwise the text will scale in "Desktop site" mode;
2518
+ *
2519
+ * Requirements for Android Firefox to apply the system font size to a text inside an iframe:
2520
+ * - The iframe document must have a header: `<meta name="viewport" content="width=device-width, initial-scale=1" />`.
2521
+ * The only way to set it is to use the `srcdoc` attribute of the iframe;
2522
+ * - The iframe content must get loaded before adding extra content with JavaScript;
2523
+ *
2524
+ * https://example.com as the iframe target always inherits Android font settings so it can be used as a reference.
2525
+ *
2526
+ * Observations on how page zoom affects the measurements:
2527
+ * - macOS Safari 11.1, 12.1, 13.1, 14.0: zoom reset + offsetWidth = 100% reliable;
2528
+ * - macOS Safari 11.1, 12.1, 13.1, 14.0: zoom reset + getBoundingClientRect = 100% reliable;
2529
+ * - macOS Safari 14.0: offsetWidth = 5% fluctuation;
2530
+ * - macOS Safari 14.0: getBoundingClientRect = 5% fluctuation;
2531
+ * - iOS Safari 9, 10, 11.0, 12.0: haven't found a way to zoom a page (pinch doesn't change layout);
2532
+ * - iOS Safari 13.1, 14.0: zoom reset + offsetWidth = 100% reliable;
2533
+ * - iOS Safari 13.1, 14.0: zoom reset + getBoundingClientRect = 100% reliable;
2534
+ * - iOS Safari 14.0: offsetWidth = 100% reliable;
2535
+ * - iOS Safari 14.0: getBoundingClientRect = 100% reliable;
2536
+ * - Chrome 42, 65, 80, 87: zoom 1/devicePixelRatio + offsetWidth = 1px fluctuation;
2537
+ * - Chrome 42, 65, 80, 87: zoom 1/devicePixelRatio + getBoundingClientRect = 100% reliable;
2538
+ * - Chrome 87: offsetWidth = 1px fluctuation;
2539
+ * - Chrome 87: getBoundingClientRect = 0.7px fluctuation;
2540
+ * - Firefox 48, 51: offsetWidth = 10% fluctuation;
2541
+ * - Firefox 48, 51: getBoundingClientRect = 10% fluctuation;
2542
+ * - Firefox 52, 53, 57, 62, 66, 67, 68, 71, 75, 80, 84: offsetWidth = width 100% reliable, height 10% fluctuation;
2543
+ * - Firefox 52, 53, 57, 62, 66, 67, 68, 71, 75, 80, 84: getBoundingClientRect = width 100% reliable, height 10%
2544
+ * fluctuation;
2545
+ * - Android Chrome 86: haven't found a way to zoom a page (pinch doesn't change layout);
2546
+ * - Android Firefox 84: font size in accessibility settings changes all the CSS sizes, but offsetWidth and
2547
+ * getBoundingClientRect keep measuring with regular units, so the size reflects the font size setting and doesn't
2548
+ * fluctuate;
2549
+ * - IE 11, Edge 18: zoom 1/devicePixelRatio + offsetWidth = 100% reliable;
2550
+ * - IE 11, Edge 18: zoom 1/devicePixelRatio + getBoundingClientRect = reflects the zoom level;
2551
+ * - IE 11, Edge 18: offsetWidth = 100% reliable;
2552
+ * - IE 11, Edge 18: getBoundingClientRect = 100% reliable;
2553
+ */
2554
+ return withIframe(function (_, iframeWindow) {
2555
+ var iframeDocument = iframeWindow.document;
2556
+ var iframeBody = iframeDocument.body;
2557
+ var bodyStyle = iframeBody.style;
2558
+ bodyStyle.width = "".concat(containerWidthPx, "px");
2559
+ bodyStyle.webkitTextSizeAdjust = bodyStyle.textSizeAdjust = "none";
2560
+ // See the big comment above
2561
+ if (isChromium()) {
2562
+ iframeBody.style.zoom = "".concat(1 / iframeWindow.devicePixelRatio);
2563
+ }
2564
+ else if (isWebKit()) {
2565
+ iframeBody.style.zoom = "reset";
2566
+ }
2567
+ // See the big comment above
2568
+ var linesOfText = iframeDocument.createElement("div");
2569
+ linesOfText.textContent = __spreadArray([], Array((containerWidthPx / 20) << 0), true)
2570
+ .map(function () {
2571
+ return "word";
2572
+ })
2573
+ .join(" ");
2574
+ iframeBody.appendChild(linesOfText);
2575
+ return action(iframeDocument, iframeBody);
2576
+ }, '<!doctype html><html><head><meta name="viewport" content="width=device-width, initial-scale=1">');
2577
+ }
2578
+
2579
+ /**
2580
+ * @see Credits: https://stackoverflow.com/a/49267844
2581
+ */
2582
+ function getVideoCard() {
2583
+ var _a;
2584
+ var canvas = document.createElement("canvas");
2585
+ var gl = (_a = canvas.getContext("webgl")) !== null && _a !== void 0 ? _a : canvas.getContext("experimental-webgl");
2586
+ if (gl && "getExtension" in gl) {
2587
+ var debugInfo = gl.getExtension("WEBGL_debug_renderer_info");
2588
+ if (debugInfo) {
2589
+ return {
2590
+ vendor: (gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL) || "").toString(),
2591
+ renderer: (gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL) || "").toString(),
2592
+ };
2593
+ }
2594
+ }
2595
+ return undefined;
2596
+ }
2597
+
2598
+ function isPdfViewerEnabled() {
2599
+ return navigator.pdfViewerEnabled;
2600
+ }
2601
+
2602
+ /**
2603
+ * Unlike most other architectures, on x86/x86-64 when floating-point instructions
2604
+ * have no NaN arguments, but produce NaN output, the output NaN has sign bit set.
2605
+ * We use it to distinguish x86/x86-64 from other architectures, by doing subtraction
2606
+ * of two infinities (must produce NaN per IEEE 754 standard).
2607
+ *
2608
+ * See https://codebrowser.bddppq.com/pytorch/pytorch/third_party/XNNPACK/src/init.c.html#79
2609
+ */
2610
+ function getArchitecture() {
2611
+ var f = new Float32Array(1);
2612
+ var u8 = new Uint8Array(f.buffer);
2613
+ f[0] = Infinity;
2614
+ f[0] = f[0] - f[0];
2615
+ return u8[3];
2616
+ }
2617
+
2618
+ /**
2619
+ * The list of entropy sources used to make visitor identifiers.
2620
+ *
2621
+ * This value isn't restricted by Semantic Versioning, i.e. it may be changed without bumping minor or major version of
2622
+ * this package.
2623
+ *
2624
+ * Note: Rollup and Webpack are smart enough to remove unused properties of this object during tree-shaking, so there is
2625
+ * no need to export the sources individually.
2626
+ */
2627
+ var sources = {
2628
+ // READ FIRST:
2629
+ // See https://github.com/fingerprintjs/fingerprintjs/blob/master/contributing.md#how-to-make-an-entropy-source
2630
+ // to learn how entropy source works and how to make your own.
2631
+ // The sources run in this exact order.
2632
+ // The asynchronous sources are at the start to run in parallel with other sources.
2633
+ fonts: getFonts,
2634
+ domBlockers: getDomBlockers,
2635
+ fontPreferences: getFontPreferences,
2636
+ audio: getAudioFingerprint,
2637
+ screenFrame: getRoundedScreenFrame,
2638
+ osCpu: getOsCpu,
2639
+ languages: getLanguages,
2640
+ colorDepth: getColorDepth,
2641
+ deviceMemory: getDeviceMemory,
2642
+ screenResolution: getScreenResolution,
2643
+ hardwareConcurrency: getHardwareConcurrency,
2644
+ timezone: getTimezone,
2645
+ sessionStorage: getSessionStorage,
2646
+ localStorage: getLocalStorage,
2647
+ indexedDB: getIndexedDB,
2648
+ openDatabase: getOpenDatabase,
2649
+ cpuClass: getCpuClass,
2650
+ platform: getPlatform,
2651
+ plugins: getPlugins,
2652
+ canvas: getCanvasFingerprint,
2653
+ touchSupport: getTouchSupport,
2654
+ vendor: getVendor,
2655
+ vendorFlavors: getVendorFlavors,
2656
+ cookiesEnabled: areCookiesEnabled,
2657
+ colorGamut: getColorGamut,
2658
+ invertedColors: areColorsInverted,
2659
+ forcedColors: areColorsForced,
2660
+ monochrome: getMonochromeDepth,
2661
+ contrast: getContrastPreference,
2662
+ reducedMotion: isMotionReduced,
2663
+ hdr: isHDR,
2664
+ math: getMathFingerprint,
2665
+ videoCard: getVideoCard,
2666
+ pdfViewerEnabled: isPdfViewerEnabled,
2667
+ architecture: getArchitecture,
2668
+ };
2669
+ /**
2670
+ * Loads the built-in entropy sources.
2671
+ * Returns a function that collects the entropy components to make the visitor identifier.
2672
+ */
2673
+ function loadBuiltinSources(options) {
2674
+ return loadSources(sources, options, []);
2675
+ }
2676
+
2677
+ var commentTemplate = "$ if upgrade to Pro: https://fpjs.dev/pro";
2678
+ function getConfidence(components) {
2679
+ var openConfidenceScore = getOpenConfidenceScore(components);
2680
+ var proConfidenceScore = deriveProConfidenceScore(openConfidenceScore);
2681
+ return { score: openConfidenceScore, comment: commentTemplate.replace(/\$/g, "".concat(proConfidenceScore)) };
2682
+ }
2683
+ function getOpenConfidenceScore(components) {
2684
+ // In order to calculate the true probability of the visitor identifier being correct, we need to know the number of
2685
+ // website visitors (the higher the number, the less the probability because the fingerprint entropy is limited).
2686
+ // JS agent doesn't know the number of visitors, so we can only do an approximate assessment.
2687
+ if (isAndroid()) {
2688
+ return 0.4;
2689
+ }
2690
+ // Safari (mobile and desktop)
2691
+ if (isWebKit()) {
2692
+ return isDesktopSafari() ? 0.5 : 0.3;
2693
+ }
2694
+ var platform = components.platform.value || "";
2695
+ // Windows
2696
+ if (/^Win/.test(platform)) {
2697
+ // The score is greater than on macOS because of the higher variety of devices running Windows.
2698
+ // Chrome provides more entropy than Firefox according too
2699
+ // https://netmarketshare.com/browser-market-share.aspx?options=%7B%22filter%22%3A%7B%22%24and%22%3A%5B%7B%22platform%22%3A%7B%22%24in%22%3A%5B%22Windows%22%5D%7D%7D%5D%7D%2C%22dateLabel%22%3A%22Trend%22%2C%22attributes%22%3A%22share%22%2C%22group%22%3A%22browser%22%2C%22sort%22%3A%7B%22share%22%3A-1%7D%2C%22id%22%3A%22browsersDesktop%22%2C%22dateInterval%22%3A%22Monthly%22%2C%22dateStart%22%3A%222019-11%22%2C%22dateEnd%22%3A%222020-10%22%2C%22segments%22%3A%22-1000%22%7D
2700
+ // So we assign the same score to them.
2701
+ return 0.6;
2702
+ }
2703
+ // macOS
2704
+ if (/^Mac/.test(platform)) {
2705
+ // Chrome provides more entropy than Safari and Safari provides more entropy than Firefox.
2706
+ // Chrome is more popular than Safari and Safari is more popular than Firefox according to
2707
+ // https://netmarketshare.com/browser-market-share.aspx?options=%7B%22filter%22%3A%7B%22%24and%22%3A%5B%7B%22platform%22%3A%7B%22%24in%22%3A%5B%22Mac%20OS%22%5D%7D%7D%5D%7D%2C%22dateLabel%22%3A%22Trend%22%2C%22attributes%22%3A%22share%22%2C%22group%22%3A%22browser%22%2C%22sort%22%3A%7B%22share%22%3A-1%7D%2C%22id%22%3A%22browsersDesktop%22%2C%22dateInterval%22%3A%22Monthly%22%2C%22dateStart%22%3A%222019-11%22%2C%22dateEnd%22%3A%222020-10%22%2C%22segments%22%3A%22-1000%22%7D
2708
+ // So we assign the same score to them.
2709
+ return 0.5;
2710
+ }
2711
+ // Another platform, e.g. a desktop Linux. It's rare, so it should be pretty unique.
2712
+ return 0.7;
2713
+ }
2714
+ function deriveProConfidenceScore(openConfidenceScore) {
2715
+ return round(0.99 + 0.01 * openConfidenceScore, 0.0001);
2716
+ }
2717
+
2718
+ function componentsToCanonicalString(components) {
2719
+ var result = "";
2720
+ for (var _i = 0, _a = Object.keys(components).sort(); _i < _a.length; _i++) {
2721
+ var componentKey = _a[_i];
2722
+ var component = components[componentKey];
2723
+ var value = component.error ? "error" : JSON.stringify(component.value);
2724
+ result += ""
2725
+ .concat(result ? "|" : "")
2726
+ .concat(componentKey.replace(/([:|\\])/g, "\\$1"), ":")
2727
+ .concat(value);
2728
+ }
2729
+ return result;
2730
+ }
2731
+ function componentsToDebugString(components) {
2732
+ return JSON.stringify(
2733
+ components,
2734
+ function (_key, value) {
2735
+ if (value instanceof Error) {
2736
+ return errorToObject(value);
2737
+ }
2738
+ return value;
2739
+ },
2740
+ 2,
2741
+ );
2742
+ }
2743
+ function hashComponents(components) {
2744
+ return x64hash128(componentsToCanonicalString(components));
2745
+ }
2746
+ /**
2747
+ * Makes a GetResult implementation that calculates the visitor id hash on demand.
2748
+ * Designed for optimisation.
2749
+ */
2750
+ function makeLazyGetResult(components) {
2751
+ var visitorIdCache;
2752
+ // This function runs very fast, so there is no need to make it lazy
2753
+ var confidence = getConfidence(components);
2754
+ // A plain class isn't used because its getters and setters aren't enumerable.
2755
+ return {
2756
+ get visitorId() {
2757
+ if (visitorIdCache === undefined) {
2758
+ visitorIdCache = hashComponents(this.components);
2759
+ }
2760
+ return visitorIdCache;
2761
+ },
2762
+ set visitorId(visitorId) {
2763
+ visitorIdCache = visitorId;
2764
+ },
2765
+ confidence: confidence,
2766
+ components: components,
2767
+ version: version,
2768
+ };
2769
+ }
2770
+ /**
2771
+ * A delay is required to ensure consistent entropy components.
2772
+ * See https://github.com/fingerprintjs/fingerprintjs/issues/254
2773
+ * and https://github.com/fingerprintjs/fingerprintjs/issues/307
2774
+ * and https://github.com/fingerprintjs/fingerprintjs/commit/945633e7c5f67ae38eb0fea37349712f0e669b18
2775
+ */
2776
+ function prepareForSources(delayFallback) {
2777
+ if (delayFallback === void 0) {
2778
+ delayFallback = 50;
2779
+ }
2780
+ // A proper deadline is unknown. Let it be twice the fallback timeout so that both cases have the same average time.
2781
+ return requestIdleCallbackIfAvailable(delayFallback, delayFallback * 2);
2782
+ }
2783
+ /**
2784
+ * The function isn't exported from the index file to not allow to call it without `load()`.
2785
+ * The hiding gives more freedom for future non-breaking updates.
2786
+ *
2787
+ * A factory function is used instead of a class to shorten the attribute names in the minified code.
2788
+ * Native private class fields could've been used, but TypeScript doesn't allow them with `"target": "es5"`.
2789
+ */
2790
+ function makeAgent(getComponents, debug) {
2791
+ var creationTime = Date.now();
2792
+ return {
2793
+ get: function (options) {
2794
+ return __awaiter(this, void 0, void 0, function () {
2795
+ var startTime, components, result;
2796
+ return __generator(this, function (_a) {
2797
+ switch (_a.label) {
2798
+ case 0:
2799
+ startTime = Date.now();
2800
+ return [4 /*yield*/, getComponents()];
2801
+ case 1:
2802
+ components = _a.sent();
2803
+ result = makeLazyGetResult(components);
2804
+ if (debug || (options === null || options === void 0 ? void 0 : options.debug)) {
2805
+ // console.log is ok here because it's under a debug clause
2806
+ // eslint-disable-next-line no-console
2807
+ console.log(
2808
+ "Copy the text below to get the debug data:\n\n```\nversion: "
2809
+ .concat(result.version, "\nuserAgent: ")
2810
+ .concat(navigator.userAgent, "\ntimeBetweenLoadAndGet: ")
2811
+ .concat(startTime - creationTime, "\nvisitorId: ")
2812
+ .concat(result.visitorId, "\ncomponents: ")
2813
+ .concat(componentsToDebugString(components), "\n```"),
2814
+ );
2815
+ }
2816
+ return [2 /*return*/, result];
2817
+ }
2818
+ });
2819
+ });
2820
+ },
2821
+ };
2822
+ }
2823
+ /**
2824
+ * Sends an unpersonalized AJAX request to collect installation statistics
2825
+ */
2826
+ function monitor() {
2827
+ // The FingerprintJS CDN (https://github.com/fingerprintjs/cdn) replaces `window.__fpjs_d_m` with `true`
2828
+ if (window.__fpjs_d_m || Math.random() >= 0.001) {
2829
+ return;
2830
+ }
2831
+ try {
2832
+ var request = new XMLHttpRequest();
2833
+ request.open("get", "https://m1.openfpcdn.io/fingerprintjs/v".concat(version, "/npm-monitoring"), true);
2834
+ request.send();
2835
+ }
2836
+ catch (error) {
2837
+ // console.error is ok here because it's an unexpected error handler
2838
+ // eslint-disable-next-line no-console
2839
+ console.error(error);
2840
+ }
2841
+ }
2842
+ /**
2843
+ * Builds an instance of Agent and waits a delay required for a proper operation.
2844
+ */
2845
+ function load(_a) {
2846
+ var _b = _a === void 0 ? {} : _a,
2847
+ delayFallback = _b.delayFallback,
2848
+ debug = _b.debug,
2849
+ _c = _b.monitoring,
2850
+ monitoring = _c === void 0 ? true : _c;
2851
+ return __awaiter(this, void 0, void 0, function () {
2852
+ var getComponents;
2853
+ return __generator(this, function (_d) {
2854
+ switch (_d.label) {
2855
+ case 0:
2856
+ if (monitoring) {
2857
+ monitor();
2858
+ }
2859
+ return [4 /*yield*/, prepareForSources(delayFallback)];
2860
+ case 1:
2861
+ _d.sent();
2862
+ getComponents = loadBuiltinSources({ debug: debug });
2863
+ return [2 /*return*/, makeAgent(getComponents, debug)];
2864
+ }
2865
+ });
2866
+ });
2867
+ }
2868
+
2869
+ // The default export is a syntax sugar (`import * as FP from '...' → import FP from '...'`).
2870
+ // It should contain all the public exported values.
2871
+ var index = { load: load, hashComponents: hashComponents, componentsToDebugString: componentsToDebugString };
2872
+ // The exports below are for private usage. They may change unexpectedly. Use them at your own risk.
2873
+ /** Not documented, out of Semantic Versioning, usage is at your own risk */
2874
+ var murmurX64Hash128 = x64hash128;
2875
+
2876
+ export {
2877
+ componentsToDebugString,
2878
+ index as default,
2879
+ getFullscreenElement,
2880
+ getScreenFrame,
2881
+ hashComponents,
2882
+ isAndroid,
2883
+ isChromium,
2884
+ isDesktopSafari,
2885
+ isEdgeHTML,
2886
+ isGecko,
2887
+ isTrident,
2888
+ isWebKit,
2889
+ load,
2890
+ loadSources,
2891
+ murmurX64Hash128,
2892
+ prepareForSources,
2893
+ sources,
2894
+ transformSource,
2895
+ withIframe,
2896
+ };