customer-chat-sdk 1.0.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.
@@ -0,0 +1,4236 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ // 图片会在运行时动态加载
6
+ class IconManager {
7
+ constructor() {
8
+ this.iconElement = null;
9
+ this.badgeElement = null;
10
+ this.onClickCallback = null;
11
+ this.notificationCallback = null;
12
+ }
13
+ /**
14
+ * 显示悬浮图标
15
+ */
16
+ async show() {
17
+ if (this.iconElement) {
18
+ return;
19
+ }
20
+ // 创建图标容器
21
+ this.iconElement = document.createElement('div');
22
+ this.iconElement.className = 'customer-sdk-icon';
23
+ // 直接设置样式 - 写死的蓝色圆形图标
24
+ Object.assign(this.iconElement.style, {
25
+ position: 'fixed',
26
+ width: '60px',
27
+ height: '60px',
28
+ backgroundColor: '#007bff',
29
+ borderRadius: '50%',
30
+ display: 'flex',
31
+ alignItems: 'center',
32
+ justifyContent: 'center',
33
+ cursor: 'pointer',
34
+ zIndex: '999999',
35
+ boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',
36
+ userSelect: 'none',
37
+ transition: 'transform 0.2s ease',
38
+ border: 'none',
39
+ outline: 'none',
40
+ bottom: '20px',
41
+ right: '20px'
42
+ });
43
+ // 添加聊天气泡图标 - 简单的文本图标
44
+ this.iconElement.textContent = '💬';
45
+ this.iconElement.style.fontSize = '24px';
46
+ this.iconElement.style.color = '#ffffff';
47
+ // 添加点击事件
48
+ this.iconElement.addEventListener('click', this.handleClick.bind(this));
49
+ // 添加到页面
50
+ document.body.appendChild(this.iconElement);
51
+ console.log('CustomerSDK icon displayed');
52
+ }
53
+ /**
54
+ * 隐藏悬浮图标
55
+ */
56
+ hide() {
57
+ if (this.iconElement) {
58
+ this.iconElement.remove();
59
+ this.iconElement = null;
60
+ this.onClickCallback = null;
61
+ console.log('CustomerSDK icon hidden');
62
+ }
63
+ }
64
+ /**
65
+ * setPosition(暂时保留接口兼容性)
66
+ */
67
+ setPosition(position) {
68
+ // 现在固定为右下角,不做处理
69
+ }
70
+ /**
71
+ * setStyle(暂时保留接口兼容性)
72
+ */
73
+ setStyle(style) {
74
+ // 现在样式写死,不做处理
75
+ }
76
+ /**
77
+ * 设置点击回调
78
+ */
79
+ onClick(callback) {
80
+ this.onClickCallback = callback;
81
+ }
82
+ /**
83
+ * 设置消息通知回调
84
+ */
85
+ onNotification(callback) {
86
+ this.notificationCallback = callback;
87
+ }
88
+ /**
89
+ * 显示消息订阅(红点、数字等)
90
+ */
91
+ showNotification(options) {
92
+ if (!this.iconElement) {
93
+ console.warn('Icon not displayed, cannot show notification');
94
+ return;
95
+ }
96
+ const { showBadge = true, badgeCount = 0, badgeText = '', pulse = false } = options;
97
+ // 显示红点
98
+ if (showBadge || badgeCount > 0) {
99
+ this.createBadge(badgeCount, badgeText, pulse);
100
+ }
101
+ // 触发通知回调
102
+ if (this.notificationCallback) {
103
+ this.notificationCallback({ badgeCount, badgeText, pulse });
104
+ }
105
+ console.log('Notification shown:', { badgeCount, badgeText });
106
+ }
107
+ /**
108
+ * 清除消息订阅
109
+ */
110
+ clearNotification() {
111
+ if (this.badgeElement) {
112
+ this.badgeElement.remove();
113
+ this.badgeElement = null;
114
+ }
115
+ console.log('Notification cleared');
116
+ }
117
+ /**
118
+ * 处理点击事件
119
+ */
120
+ handleClick() {
121
+ if (this.onClickCallback) {
122
+ this.onClickCallback();
123
+ }
124
+ }
125
+ /**
126
+ * 创建消息徽章(简化版)
127
+ */
128
+ createBadge(count, text = '', pulse = false) {
129
+ // 清除现有徽章
130
+ this.clearNotification();
131
+ this.badgeElement = document.createElement('div');
132
+ this.badgeElement.className = 'customer-sdk-icon-badge';
133
+ // 设置徽章内容
134
+ if (count > 0) {
135
+ this.badgeElement.textContent = count > 99 ? '99+' : count.toString();
136
+ }
137
+ else if (text) {
138
+ this.badgeElement.textContent = text;
139
+ }
140
+ else {
141
+ this.badgeElement.textContent = ''; // 纯红点
142
+ }
143
+ // 设置徽章样式
144
+ Object.assign(this.badgeElement.style, {
145
+ position: 'absolute',
146
+ top: '-2px',
147
+ right: '-2px',
148
+ minWidth: '18px',
149
+ height: '18px',
150
+ borderRadius: '50%',
151
+ backgroundColor: '#ff4444',
152
+ color: '#ffffff',
153
+ fontSize: '10px',
154
+ fontWeight: 'bold',
155
+ display: 'flex',
156
+ alignItems: 'center',
157
+ justifyContent: 'center',
158
+ zIndex: '1000001',
159
+ boxShadow: '0 -1px 4px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.15)',
160
+ ...(count === 0 && text === '' && {
161
+ width: '10px',
162
+ height: '10px',
163
+ minWidth: '10px'
164
+ }),
165
+ ...(pulse && {
166
+ animation: 'sdk-badge-pulse 1.5s infinite'
167
+ })
168
+ });
169
+ // 添加到图标容器
170
+ if (this.iconElement) {
171
+ this.iconElement.appendChild(this.badgeElement);
172
+ }
173
+ }
174
+ }
175
+
176
+ class IframeManager {
177
+ constructor(config = {}) {
178
+ this.iframeElement = null;
179
+ this.overlayElement = null;
180
+ this.containerElement = null; // 包装容器,包含iframe和关闭按钮
181
+ this.isOpen = false;
182
+ this.isCreated = false;
183
+ this.config = {
184
+ src: '',
185
+ mode: 'auto', // 默认自动检测设备类型
186
+ width: 400,
187
+ height: 600,
188
+ allowClose: true,
189
+ ...config
190
+ };
191
+ this.setupMessageListener();
192
+ }
193
+ /**
194
+ * 初始化iframe(隐藏状态)
195
+ * 预创建iframe并连接到SSE,但不显示
196
+ */
197
+ async init() {
198
+ try {
199
+ // 创建隐藏的iframe(预连接到SSE)
200
+ this.createIframe();
201
+ this.isCreated = true;
202
+ console.log('CustomerSDK iframe initialized (hidden, SSE connected)');
203
+ }
204
+ catch (error) {
205
+ console.error('Failed to initialize iframe:', error);
206
+ throw error;
207
+ }
208
+ }
209
+ /**
210
+ * 显示iframe聊天窗口
211
+ */
212
+ show() {
213
+ if (this.isOpen) {
214
+ return;
215
+ }
216
+ if (!this.isCreated) {
217
+ throw new Error('Iframe not initialized. Call init() first.');
218
+ }
219
+ try {
220
+ const actualMode = this.getActualMode();
221
+ const isPC = actualMode === 'popup';
222
+ // 只PC模式下创建遮罩层
223
+ if (isPC) {
224
+ this.createOverlay();
225
+ }
226
+ // 显示已创建的容器
227
+ if (this.containerElement) {
228
+ if (isPC) {
229
+ // PC模式:配置为居中弹窗样式
230
+ Object.assign(this.containerElement.style, {
231
+ position: 'fixed',
232
+ top: '50%',
233
+ left: '50%',
234
+ transform: 'translate(-50%, -50%)',
235
+ visibility: 'visible',
236
+ opacity: '1',
237
+ display: 'block'
238
+ });
239
+ // 将容器移到遮罩层内
240
+ this.overlayElement?.appendChild(this.containerElement);
241
+ }
242
+ else {
243
+ // 移动端模式:直接全屏显示,不需要遮罩层
244
+ Object.assign(this.containerElement.style, {
245
+ position: 'fixed',
246
+ visibility: 'visible',
247
+ opacity: '1',
248
+ display: 'block'
249
+ });
250
+ // 禁用body滚动,防止出现滚动条
251
+ this.preventBodyScroll(true);
252
+ }
253
+ // 添加关闭按钮(如果是首次显示)
254
+ if (this.config.allowClose && !this.containerElement.querySelector('.customer-sdk-close-btn')) {
255
+ this.addCloseButton();
256
+ }
257
+ }
258
+ this.isOpen = true;
259
+ console.log('CustomerSDK iframe shown');
260
+ }
261
+ catch (error) {
262
+ console.error('Failed to show iframe:', error);
263
+ }
264
+ }
265
+ /**
266
+ * 打开iframe聊天窗口(保持兼容性)
267
+ */
268
+ open() {
269
+ this.show();
270
+ }
271
+ /**
272
+ * 隐藏iframe聊天窗口(类似v-show)
273
+ */
274
+ hide() {
275
+ if (!this.isOpen) {
276
+ return;
277
+ }
278
+ // 隐藏容器但保留DOM元素
279
+ if (this.containerElement) {
280
+ Object.assign(this.containerElement.style, {
281
+ visibility: 'hidden',
282
+ opacity: '0',
283
+ display: 'none'
284
+ });
285
+ }
286
+ // 移除遮罩层(仅PC模式)
287
+ if (this.overlayElement) {
288
+ this.overlayElement.remove();
289
+ this.overlayElement = null;
290
+ }
291
+ // 恢复body滚动(移动端模式)
292
+ const actualMode = this.getActualMode();
293
+ if (actualMode === 'fullscreen') {
294
+ this.preventBodyScroll(false);
295
+ }
296
+ this.isOpen = false;
297
+ console.log('CustomerSDK iframe hidden (SSE still connected)');
298
+ }
299
+ /**
300
+ * 关闭iframe聊天窗口(完全销毁,保持兼容性)
301
+ */
302
+ close() {
303
+ this.hide(); // 默认只隐藏,不销毁
304
+ }
305
+ /**
306
+ * 完全销毁iframe(需要时才调用)
307
+ */
308
+ destroy() {
309
+ this.hide();
310
+ if (this.containerElement) {
311
+ this.containerElement.remove();
312
+ this.containerElement = null;
313
+ this.iframeElement = null;
314
+ }
315
+ this.isCreated = false;
316
+ console.log('CustomerSDK container destroyed');
317
+ }
318
+ /**
319
+ * 检查是否已打开
320
+ */
321
+ isIframeOpen() {
322
+ return this.isOpen;
323
+ }
324
+ /**
325
+ * 向iframe发送消息
326
+ */
327
+ sendToIframe(data) {
328
+ if (this.iframeElement && this.iframeElement.contentWindow) {
329
+ this.iframeElement.contentWindow.postMessage(data, '*');
330
+ }
331
+ }
332
+ /**
333
+ * 创建遮罩层
334
+ */
335
+ createOverlay() {
336
+ this.overlayElement = document.createElement('div');
337
+ this.overlayElement.className = 'customer-sdk-overlay';
338
+ Object.assign(this.overlayElement.style, {
339
+ position: 'fixed',
340
+ top: '0',
341
+ left: '0',
342
+ width: '100%',
343
+ height: '100%',
344
+ backgroundColor: 'rgba(0, 0, 0, 0.5)',
345
+ zIndex: '999998',
346
+ display: 'flex',
347
+ alignItems: 'center',
348
+ justifyContent: 'center',
349
+ cursor: this.config.allowClose ? 'pointer' : 'default'
350
+ });
351
+ // 点击遮罩层关闭
352
+ if (this.config.allowClose) {
353
+ this.overlayElement.addEventListener('click', (e) => {
354
+ if (e.target === this.overlayElement) {
355
+ this.close();
356
+ }
357
+ });
358
+ }
359
+ document.body.appendChild(this.overlayElement);
360
+ }
361
+ /**
362
+ * 创建iframe(默认隐藏状态,用于SSE连接)
363
+ */
364
+ createIframe() {
365
+ // 创建包装容器(包含iframe和关闭按钮)
366
+ this.containerElement = document.createElement('div');
367
+ this.containerElement.className = 'customer-sdk-container';
368
+ // 创建iframe元素
369
+ this.iframeElement = document.createElement('iframe');
370
+ this.iframeElement.className = 'customer-sdk-iframe';
371
+ // 设置iframe属性
372
+ this.iframeElement.src = this.config.src || '';
373
+ this.iframeElement.frameBorder = '0';
374
+ // 根据设备类型设置滚动行为
375
+ const actualMode = this.getActualMode();
376
+ const isPC = actualMode === 'popup';
377
+ this.iframeElement.scrolling = isPC ? 'auto' : 'no'; // PC显示滚动条,移动端禁用
378
+ const containerStyles = {
379
+ width: isPC ? `${this.config.width}px` : '100vw',
380
+ height: isPC ? `${this.config.height}px` : '100vh',
381
+ maxWidth: isPC ? '450px' : '100vw',
382
+ maxHeight: isPC ? '700px' : '100vh',
383
+ backgroundColor: '#ffffff',
384
+ borderRadius: isPC ? '12px' : '12px 12px 0 0',
385
+ boxShadow: isPC
386
+ ? '0 20px 40px rgba(0, 0, 0, 0.15)'
387
+ : '0 -4px 16px rgba(0, 0, 0, 0.25)',
388
+ border: 'none',
389
+ position: 'fixed',
390
+ zIndex: '999999',
391
+ // PC模式下的定位
392
+ ...(isPC ? {
393
+ top: '50%',
394
+ left: '50%',
395
+ transform: 'translate(-50%, -50%)'
396
+ } : {
397
+ // 移动端全屏模式 - 确保占满屏幕且不滚动
398
+ top: '0',
399
+ left: '0',
400
+ bottom: '0',
401
+ right: '0',
402
+ transform: 'none',
403
+ overflow: 'hidden' // 防止容器本身滚动
404
+ }),
405
+ // 初始隐藏的关键样式
406
+ visibility: 'hidden',
407
+ opacity: '0',
408
+ display: 'none'
409
+ };
410
+ Object.assign(this.containerElement.style, containerStyles);
411
+ // iframe填充整个容器,根据设备类型设置滚动样式
412
+ const iframeStyles = {
413
+ width: '100%',
414
+ height: '100%',
415
+ border: 'none',
416
+ borderRadius: 'inherit',
417
+ ...(isPC ? {} : {
418
+ // 移动端:彻底禁用滚动条
419
+ overflow: 'hidden',
420
+ scrollbarWidth: 'none', // Firefox
421
+ msOverflowStyle: 'none', // IE/Edge
422
+ WebkitScrollbar: 'none' // WebKit (Chrome/Safari)
423
+ })
424
+ };
425
+ Object.assign(this.iframeElement.style, iframeStyles);
426
+ // 将iframe放入容器
427
+ this.containerElement.appendChild(this.iframeElement);
428
+ // 添加iframe加载事件监听(移动端样式优化)
429
+ this.iframeElement.addEventListener('load', () => {
430
+ // 仅在移动端注入自定义样式
431
+ if (!isPC) {
432
+ this.injectMobileStyles();
433
+ }
434
+ });
435
+ // 添加到body(预连接SSE,但不显示)
436
+ document.body.appendChild(this.containerElement);
437
+ console.log('CustomerSDK container created (hidden, ready for SSE)');
438
+ }
439
+ /**
440
+ * 向iframe注入移动端优化样式(隐藏滚动条)
441
+ */
442
+ injectMobileStyles() {
443
+ if (!this.iframeElement)
444
+ return;
445
+ try {
446
+ const iframeDoc = this.iframeElement.contentDocument ||
447
+ this.iframeElement.contentWindow?.document;
448
+ if (iframeDoc) {
449
+ // 创建样式元素
450
+ const style = iframeDoc.createElement('style');
451
+ style.textContent = `
452
+ /* 移动端iframe全屏样式优化 */
453
+ * {
454
+ -webkit-overflow-scrolling: touch !important;
455
+ }
456
+
457
+ body, html, #app, .container {
458
+ overflow: auto !important;
459
+ -webkit-overflow-scrolling: touch !important;
460
+ }
461
+
462
+ /* 隐藏所有滚动条 */
463
+ ::-webkit-scrollbar {
464
+ width: 0px !important;
465
+ height: 0px !important;
466
+ background: transparent !important;
467
+ }
468
+
469
+ /* Firefox */
470
+ html {
471
+ scrollbar-width: none !important;
472
+ }
473
+
474
+ /* IE/Edge */
475
+ body {
476
+ -ms-overflow-style: none !important;
477
+ }
478
+
479
+ /* 确保内容可以滚动 */
480
+ body {
481
+ overflow: auto !important;
482
+ height: 100vh !important;
483
+ margin: 0 !important;
484
+ padding: 0 !important;
485
+ }
486
+ `;
487
+ // 注入样式
488
+ iframeDoc.head?.appendChild(style);
489
+ console.log('CustomerSDK mobile styles injected successfully');
490
+ }
491
+ }
492
+ catch (error) {
493
+ // 跨域限制时静默忽略
494
+ console.log('Cannot inject styles due to cross-origin restrictions:', error);
495
+ }
496
+ }
497
+ /**
498
+ * 控制页面滚动(移动端全屏模式使用)
499
+ */
500
+ preventBodyScroll(prevent) {
501
+ if (prevent) {
502
+ // 保存当前滚动位置
503
+ const scrollY = window.scrollY;
504
+ // 应用防止滚动的样式
505
+ Object.assign(document.body.style, {
506
+ position: 'fixed',
507
+ top: `-${scrollY}px`,
508
+ width: '100%',
509
+ overflow: 'hidden'
510
+ });
511
+ // 记录滚动位置以便恢复
512
+ document.body.setAttribute('data-scroll-position', scrollY.toString());
513
+ }
514
+ else {
515
+ // 获取保存的滚动位置
516
+ const scrollY = parseInt(document.body.getAttribute('data-scroll-position') || '0');
517
+ // 移除防止滚动的样式
518
+ Object.assign(document.body.style, {
519
+ position: '',
520
+ top: '',
521
+ width: '',
522
+ overflow: ''
523
+ });
524
+ // 移除记录的属性
525
+ document.body.removeAttribute('data-scroll-position');
526
+ // 恢复正常滚动位置
527
+ window.scrollTo(0, scrollY);
528
+ }
529
+ }
530
+ /**
531
+ * 添加关闭按钮(自适应设备)
532
+ */
533
+ addCloseButton() {
534
+ if (!this.iframeElement)
535
+ return;
536
+ const actualMode = this.getActualMode();
537
+ const isPC = actualMode === 'popup';
538
+ const closeButton = document.createElement('button');
539
+ closeButton.className = 'customer-sdk-close-btn';
540
+ closeButton.innerHTML = '×';
541
+ const buttonStyles = isPC ? {
542
+ // PC模式:现代半透明设计
543
+ position: 'absolute',
544
+ top: '8px',
545
+ right: '8px',
546
+ width: '28px',
547
+ height: '28px',
548
+ borderRadius: '50%',
549
+ backgroundColor: 'rgba(0, 0, 0, 0.6)',
550
+ color: '#ffffff',
551
+ border: 'none',
552
+ fontSize: '16px',
553
+ fontWeight: '300',
554
+ cursor: 'pointer',
555
+ zIndex: '1000000',
556
+ display: 'flex',
557
+ alignItems: 'center',
558
+ justifyContent: 'center',
559
+ transition: 'all 0.2s ease',
560
+ fontFamily: '-apple-system, BlinkMacSystemFont, sans-serif',
561
+ userSelect: 'none',
562
+ backdropFilter: 'blur(8px)',
563
+ boxShadow: '0 2px 12px rgba(0, 0, 0, 0.15)'
564
+ } : {
565
+ // 移动端模式:现代半透明设计
566
+ position: 'absolute',
567
+ top: '2px',
568
+ right: '2px',
569
+ width: '30px',
570
+ height: '30px',
571
+ borderRadius: '50%',
572
+ backgroundColor: 'rgba(0, 0, 0, 0.6)',
573
+ color: '#ffffff',
574
+ border: 'none',
575
+ fontSize: '18px',
576
+ fontWeight: '300',
577
+ cursor: 'pointer',
578
+ zIndex: '1000000',
579
+ display: 'flex',
580
+ alignItems: 'center',
581
+ justifyContent: 'center',
582
+ transition: 'all 0.2s ease',
583
+ fontFamily: '-apple-system, BlinkMacSystemFont, sans-serif',
584
+ userSelect: 'none',
585
+ backdropFilter: 'blur(8px)',
586
+ boxShadow: '0 4px 16px rgba(0, 0, 0, 0.2)'
587
+ };
588
+ Object.assign(closeButton.style, buttonStyles);
589
+ closeButton.addEventListener('click', () => {
590
+ this.close();
591
+ });
592
+ closeButton.addEventListener('mouseenter', () => {
593
+ Object.assign(closeButton.style, {
594
+ backgroundColor: 'rgba(0, 0, 0, 0.8)',
595
+ transform: 'scale(1.1)'
596
+ });
597
+ });
598
+ closeButton.addEventListener('mouseleave', () => {
599
+ Object.assign(closeButton.style, {
600
+ backgroundColor: 'rgba(0, 0, 0, 0.6)',
601
+ transform: 'scale(1)'
602
+ });
603
+ });
604
+ // 将 закрыть按钮添加到容器内
605
+ this.containerElement?.appendChild(closeButton);
606
+ }
607
+ /**
608
+ * 检测设备类型
609
+ */
610
+ isMobileDevice() {
611
+ return window.innerWidth <= 768 ||
612
+ /Android|iPhone|iPad|iPod|Opera Mini|IEMobile/i.test(navigator.userAgent);
613
+ }
614
+ /**
615
+ * 获取当前显示模式
616
+ */
617
+ getActualMode() {
618
+ if (this.config.mode === 'auto') {
619
+ return this.isMobileDevice() ? 'fullscreen' : 'popup';
620
+ }
621
+ return this.config.mode;
622
+ }
623
+ /**
624
+ * 设置消息监听
625
+ */
626
+ setupMessageListener() {
627
+ window.addEventListener('message', (event) => {
628
+ // 验证消息来源(可选的安全检查)
629
+ if (!this.config.src || event.origin === new URL(this.config.src).origin) {
630
+ this.handleIframeMessage(event.data);
631
+ }
632
+ }, false);
633
+ }
634
+ /**
635
+ * 处理来自iframe的消息
636
+ */
637
+ handleIframeMessage(data) {
638
+ console.log('Message from iframe:', data);
639
+ // 根据消息类型处理不同的操作
640
+ switch (data.type) {
641
+ case 'iframe_ready':
642
+ console.log('Iframe is ready');
643
+ break;
644
+ case 'close_iframe':
645
+ this.close();
646
+ break;
647
+ case 'resize_iframe':
648
+ if (data.width && data.height) {
649
+ this.resizeIframe(data.width, data.height);
650
+ }
651
+ break;
652
+ default:
653
+ // 可以在这里添加自定义消息处理
654
+ console.log('Custom message:', data);
655
+ }
656
+ }
657
+ /**
658
+ * 调整iframe大小
659
+ */
660
+ resizeIframe(width, height) {
661
+ if (this.iframeElement) {
662
+ this.iframeElement.style.width = `${width}px`;
663
+ this.iframeElement.style.height = `${height}px`;
664
+ }
665
+ }
666
+ }
667
+
668
+ /******************************************************************************
669
+ Copyright (c) Microsoft Corporation.
670
+
671
+ Permission to use, copy, modify, and/or distribute this software for any
672
+ purpose with or without fee is hereby granted.
673
+
674
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
675
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
676
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
677
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
678
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
679
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
680
+ PERFORMANCE OF THIS SOFTWARE.
681
+ ***************************************************************************** */
682
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
683
+
684
+
685
+ var __assign = function() {
686
+ __assign = Object.assign || function __assign(t) {
687
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
688
+ s = arguments[i];
689
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
690
+ }
691
+ return t;
692
+ };
693
+ return __assign.apply(this, arguments);
694
+ };
695
+
696
+ function __awaiter(thisArg, _arguments, P, generator) {
697
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
698
+ return new (P || (P = Promise))(function (resolve, reject) {
699
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
700
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
701
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
702
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
703
+ });
704
+ }
705
+
706
+ function __generator(thisArg, body) {
707
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
708
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
709
+ function verb(n) { return function (v) { return step([n, v]); }; }
710
+ function step(op) {
711
+ if (f) throw new TypeError("Generator is already executing.");
712
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
713
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
714
+ if (y = 0, t) op = [op[0] & 2, t.value];
715
+ switch (op[0]) {
716
+ case 0: case 1: t = op; break;
717
+ case 4: _.label++; return { value: op[1], done: false };
718
+ case 5: _.label++; y = op[1]; op = [0]; continue;
719
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
720
+ default:
721
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
722
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
723
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
724
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
725
+ if (t[2]) _.ops.pop();
726
+ _.trys.pop(); continue;
727
+ }
728
+ op = body.call(thisArg, _);
729
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
730
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
731
+ }
732
+ }
733
+
734
+ function __spreadArray(to, from, pack) {
735
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
736
+ if (ar || !(i in from)) {
737
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
738
+ ar[i] = from[i];
739
+ }
740
+ }
741
+ return to.concat(ar || Array.prototype.slice.call(from));
742
+ }
743
+
744
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
745
+ var e = new Error(message);
746
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
747
+ };
748
+
749
+ /**
750
+ * FingerprintJS v4.6.2 - Copyright (c) FingerprintJS, Inc, 2025 (https://fingerprint.com)
751
+ *
752
+ * Licensed under Business Source License 1.1 https://mariadb.com/bsl11/
753
+ * Licensor: FingerprintJS, Inc.
754
+ * Licensed Work: FingerprintJS browser fingerprinting library
755
+ * Additional Use Grant: None
756
+ * Change Date: Four years from first release for the specific version.
757
+ * Change License: MIT, text at https://opensource.org/license/mit/ with the following copyright notice:
758
+ * Copyright 2015-present FingerprintJS, Inc.
759
+ */
760
+
761
+
762
+ var version = "4.6.2";
763
+
764
+ function wait(durationMs, resolveWith) {
765
+ return new Promise(function (resolve) { return setTimeout(resolve, durationMs, resolveWith); });
766
+ }
767
+ /**
768
+ * Allows asynchronous actions and microtasks to happen.
769
+ */
770
+ function releaseEventLoop() {
771
+ // Don't use setTimeout because Chrome throttles it in some cases causing very long agent execution:
772
+ // https://stackoverflow.com/a/6032591/1118709
773
+ // https://github.com/chromium/chromium/commit/0295dd09496330f3a9103ef7e543fa9b6050409b
774
+ // Reusing a MessageChannel object gives no noticeable benefits
775
+ return new Promise(function (resolve) {
776
+ var channel = new MessageChannel();
777
+ channel.port1.onmessage = function () { return resolve(); };
778
+ channel.port2.postMessage(null);
779
+ });
780
+ }
781
+ function requestIdleCallbackIfAvailable(fallbackTimeout, deadlineTimeout) {
782
+ if (deadlineTimeout === void 0) { deadlineTimeout = Infinity; }
783
+ var requestIdleCallback = window.requestIdleCallback;
784
+ if (requestIdleCallback) {
785
+ // The function `requestIdleCallback` loses the binding to `window` here.
786
+ // `globalThis` isn't always equal `window` (see https://github.com/fingerprintjs/fingerprintjs/issues/683).
787
+ // Therefore, an error can occur. `call(window,` prevents the error.
788
+ return new Promise(function (resolve) { return requestIdleCallback.call(window, function () { return resolve(); }, { timeout: deadlineTimeout }); });
789
+ }
790
+ else {
791
+ return wait(Math.min(fallbackTimeout, deadlineTimeout));
792
+ }
793
+ }
794
+ function isPromise(value) {
795
+ return !!value && typeof value.then === 'function';
796
+ }
797
+ /**
798
+ * Calls a maybe asynchronous function without creating microtasks when the function is synchronous.
799
+ * Catches errors in both cases.
800
+ *
801
+ * If just you run a code like this:
802
+ * ```
803
+ * console.time('Action duration')
804
+ * await action()
805
+ * console.timeEnd('Action duration')
806
+ * ```
807
+ * The synchronous function time can be measured incorrectly because another microtask may run before the `await`
808
+ * returns the control back to the code.
809
+ */
810
+ function awaitIfAsync(action, callback) {
811
+ try {
812
+ var returnedValue = action();
813
+ if (isPromise(returnedValue)) {
814
+ returnedValue.then(function (result) { return callback(true, result); }, function (error) { return callback(false, error); });
815
+ }
816
+ else {
817
+ callback(true, returnedValue);
818
+ }
819
+ }
820
+ catch (error) {
821
+ callback(false, error);
822
+ }
823
+ }
824
+ /**
825
+ * If you run many synchronous tasks without using this function, the JS main loop will be busy and asynchronous tasks
826
+ * (e.g. completing a network request, rendering the page) won't be able to happen.
827
+ * This function allows running many synchronous tasks such way that asynchronous tasks can run too in background.
828
+ */
829
+ function mapWithBreaks(items, callback, loopReleaseInterval) {
830
+ if (loopReleaseInterval === void 0) { loopReleaseInterval = 16; }
831
+ return __awaiter(this, void 0, void 0, function () {
832
+ var results, lastLoopReleaseTime, i, now;
833
+ return __generator(this, function (_a) {
834
+ switch (_a.label) {
835
+ case 0:
836
+ results = Array(items.length);
837
+ lastLoopReleaseTime = Date.now();
838
+ i = 0;
839
+ _a.label = 1;
840
+ case 1:
841
+ if (!(i < items.length)) return [3 /*break*/, 4];
842
+ results[i] = callback(items[i], i);
843
+ now = Date.now();
844
+ if (!(now >= lastLoopReleaseTime + loopReleaseInterval)) return [3 /*break*/, 3];
845
+ lastLoopReleaseTime = now;
846
+ return [4 /*yield*/, releaseEventLoop()];
847
+ case 2:
848
+ _a.sent();
849
+ _a.label = 3;
850
+ case 3:
851
+ ++i;
852
+ return [3 /*break*/, 1];
853
+ case 4: return [2 /*return*/, results];
854
+ }
855
+ });
856
+ });
857
+ }
858
+ /**
859
+ * Makes the given promise never emit an unhandled promise rejection console warning.
860
+ * The promise will still pass errors to the next promises.
861
+ * Returns the input promise for convenience.
862
+ *
863
+ * Otherwise, promise emits a console warning unless it has a `catch` listener.
864
+ */
865
+ function suppressUnhandledRejectionWarning(promise) {
866
+ promise.then(undefined, function () { return undefined; });
867
+ return promise;
868
+ }
869
+
870
+ /*
871
+ * This file contains functions to work with pure data only (no browser features, DOM, side effects, etc).
872
+ */
873
+ /**
874
+ * Does the same as Array.prototype.includes but has better typing
875
+ */
876
+ function includes(haystack, needle) {
877
+ for (var i = 0, l = haystack.length; i < l; ++i) {
878
+ if (haystack[i] === needle) {
879
+ return true;
880
+ }
881
+ }
882
+ return false;
883
+ }
884
+ /**
885
+ * Like `!includes()` but with proper typing
886
+ */
887
+ function excludes(haystack, needle) {
888
+ return !includes(haystack, needle);
889
+ }
890
+ /**
891
+ * Be careful, NaN can return
892
+ */
893
+ function toInt(value) {
894
+ return parseInt(value);
895
+ }
896
+ /**
897
+ * Be careful, NaN can return
898
+ */
899
+ function toFloat(value) {
900
+ return parseFloat(value);
901
+ }
902
+ function replaceNaN(value, replacement) {
903
+ return typeof value === 'number' && isNaN(value) ? replacement : value;
904
+ }
905
+ function countTruthy(values) {
906
+ return values.reduce(function (sum, value) { return sum + (value ? 1 : 0); }, 0);
907
+ }
908
+ function round(value, base) {
909
+ if (base === void 0) { base = 1; }
910
+ if (Math.abs(base) >= 1) {
911
+ return Math.round(value / base) * base;
912
+ }
913
+ else {
914
+ // Sometimes when a number is multiplied by a small number, precision is lost,
915
+ // for example 1234 * 0.0001 === 0.12340000000000001, and it's more precise divide: 1234 / (1 / 0.0001) === 0.1234.
916
+ var counterBase = 1 / base;
917
+ return Math.round(value * counterBase) / counterBase;
918
+ }
919
+ }
920
+ /**
921
+ * Parses a CSS selector into tag name with HTML attributes.
922
+ * Only single element selector are supported (without operators like space, +, >, etc).
923
+ *
924
+ * Multiple values can be returned for each attribute. You decide how to handle them.
925
+ */
926
+ function parseSimpleCssSelector(selector) {
927
+ var _a, _b;
928
+ var errorMessage = "Unexpected syntax '".concat(selector, "'");
929
+ var tagMatch = /^\s*([a-z-]*)(.*)$/i.exec(selector);
930
+ var tag = tagMatch[1] || undefined;
931
+ var attributes = {};
932
+ var partsRegex = /([.:#][\w-]+|\[.+?\])/gi;
933
+ var addAttribute = function (name, value) {
934
+ attributes[name] = attributes[name] || [];
935
+ attributes[name].push(value);
936
+ };
937
+ for (;;) {
938
+ var match = partsRegex.exec(tagMatch[2]);
939
+ if (!match) {
940
+ break;
941
+ }
942
+ var part = match[0];
943
+ switch (part[0]) {
944
+ case '.':
945
+ addAttribute('class', part.slice(1));
946
+ break;
947
+ case '#':
948
+ addAttribute('id', part.slice(1));
949
+ break;
950
+ case '[': {
951
+ var attributeMatch = /^\[([\w-]+)([~|^$*]?=("(.*?)"|([\w-]+)))?(\s+[is])?\]$/.exec(part);
952
+ if (attributeMatch) {
953
+ addAttribute(attributeMatch[1], (_b = (_a = attributeMatch[4]) !== null && _a !== void 0 ? _a : attributeMatch[5]) !== null && _b !== void 0 ? _b : '');
954
+ }
955
+ else {
956
+ throw new Error(errorMessage);
957
+ }
958
+ break;
959
+ }
960
+ default:
961
+ throw new Error(errorMessage);
962
+ }
963
+ }
964
+ return [tag, attributes];
965
+ }
966
+ /**
967
+ * Converts a string to UTF8 bytes
968
+ */
969
+ function getUTF8Bytes(input) {
970
+ // Benchmark: https://jsbench.me/b6klaaxgwq/1
971
+ // If you want to just count bytes, see solutions at https://jsbench.me/ehklab415e/1
972
+ var result = new Uint8Array(input.length);
973
+ for (var i = 0; i < input.length; i++) {
974
+ // `charCode` is faster than encoding, so we prefer that when it's possible
975
+ var charCode = input.charCodeAt(i);
976
+ // In case of non-ASCII symbols we use proper encoding
977
+ if (charCode > 127) {
978
+ return new TextEncoder().encode(input);
979
+ }
980
+ result[i] = charCode;
981
+ }
982
+ return result;
983
+ }
984
+
985
+ /*
986
+ * Based on https://github.com/karanlyons/murmurHash3.js/blob/a33d0723127e2e5415056c455f8aed2451ace208/murmurHash3.js
987
+ */
988
+ /**
989
+ * Adds two 64-bit values (provided as tuples of 32-bit values)
990
+ * and updates (mutates) first value to write the result
991
+ */
992
+ function x64Add(m, n) {
993
+ var m0 = m[0] >>> 16, m1 = m[0] & 0xffff, m2 = m[1] >>> 16, m3 = m[1] & 0xffff;
994
+ var n0 = n[0] >>> 16, n1 = n[0] & 0xffff, n2 = n[1] >>> 16, n3 = n[1] & 0xffff;
995
+ var o0 = 0, o1 = 0, o2 = 0, o3 = 0;
996
+ o3 += m3 + n3;
997
+ o2 += o3 >>> 16;
998
+ o3 &= 0xffff;
999
+ o2 += m2 + n2;
1000
+ o1 += o2 >>> 16;
1001
+ o2 &= 0xffff;
1002
+ o1 += m1 + n1;
1003
+ o0 += o1 >>> 16;
1004
+ o1 &= 0xffff;
1005
+ o0 += m0 + n0;
1006
+ o0 &= 0xffff;
1007
+ m[0] = (o0 << 16) | o1;
1008
+ m[1] = (o2 << 16) | o3;
1009
+ }
1010
+ /**
1011
+ * Multiplies two 64-bit values (provided as tuples of 32-bit values)
1012
+ * and updates (mutates) first value to write the result
1013
+ */
1014
+ function x64Multiply(m, n) {
1015
+ var m0 = m[0] >>> 16, m1 = m[0] & 0xffff, m2 = m[1] >>> 16, m3 = m[1] & 0xffff;
1016
+ var n0 = n[0] >>> 16, n1 = n[0] & 0xffff, n2 = n[1] >>> 16, n3 = n[1] & 0xffff;
1017
+ var o0 = 0, o1 = 0, o2 = 0, o3 = 0;
1018
+ o3 += m3 * n3;
1019
+ o2 += o3 >>> 16;
1020
+ o3 &= 0xffff;
1021
+ o2 += m2 * n3;
1022
+ o1 += o2 >>> 16;
1023
+ o2 &= 0xffff;
1024
+ o2 += m3 * n2;
1025
+ o1 += o2 >>> 16;
1026
+ o2 &= 0xffff;
1027
+ o1 += m1 * n3;
1028
+ o0 += o1 >>> 16;
1029
+ o1 &= 0xffff;
1030
+ o1 += m2 * n2;
1031
+ o0 += o1 >>> 16;
1032
+ o1 &= 0xffff;
1033
+ o1 += m3 * n1;
1034
+ o0 += o1 >>> 16;
1035
+ o1 &= 0xffff;
1036
+ o0 += m0 * n3 + m1 * n2 + m2 * n1 + m3 * n0;
1037
+ o0 &= 0xffff;
1038
+ m[0] = (o0 << 16) | o1;
1039
+ m[1] = (o2 << 16) | o3;
1040
+ }
1041
+ /**
1042
+ * Provides left rotation of the given int64 value (provided as tuple of two int32)
1043
+ * by given number of bits. Result is written back to the value
1044
+ */
1045
+ function x64Rotl(m, bits) {
1046
+ var m0 = m[0];
1047
+ bits %= 64;
1048
+ if (bits === 32) {
1049
+ m[0] = m[1];
1050
+ m[1] = m0;
1051
+ }
1052
+ else if (bits < 32) {
1053
+ m[0] = (m0 << bits) | (m[1] >>> (32 - bits));
1054
+ m[1] = (m[1] << bits) | (m0 >>> (32 - bits));
1055
+ }
1056
+ else {
1057
+ bits -= 32;
1058
+ m[0] = (m[1] << bits) | (m0 >>> (32 - bits));
1059
+ m[1] = (m0 << bits) | (m[1] >>> (32 - bits));
1060
+ }
1061
+ }
1062
+ /**
1063
+ * Provides a left shift of the given int32 value (provided as tuple of [0, int32])
1064
+ * by given number of bits. Result is written back to the value
1065
+ */
1066
+ function x64LeftShift(m, bits) {
1067
+ bits %= 64;
1068
+ if (bits === 0) {
1069
+ return;
1070
+ }
1071
+ else if (bits < 32) {
1072
+ m[0] = m[1] >>> (32 - bits);
1073
+ m[1] = m[1] << bits;
1074
+ }
1075
+ else {
1076
+ m[0] = m[1] << (bits - 32);
1077
+ m[1] = 0;
1078
+ }
1079
+ }
1080
+ /**
1081
+ * Provides a XOR of the given int64 values(provided as tuple of two int32).
1082
+ * Result is written back to the first value
1083
+ */
1084
+ function x64Xor(m, n) {
1085
+ m[0] ^= n[0];
1086
+ m[1] ^= n[1];
1087
+ }
1088
+ var F1 = [0xff51afd7, 0xed558ccd];
1089
+ var F2 = [0xc4ceb9fe, 0x1a85ec53];
1090
+ /**
1091
+ * Calculates murmurHash3's final x64 mix of that block and writes result back to the input value.
1092
+ * (`[0, h[0] >>> 1]` is a 33 bit unsigned right shift. This is the
1093
+ * only place where we need to right shift 64bit ints.)
1094
+ */
1095
+ function x64Fmix(h) {
1096
+ var shifted = [0, h[0] >>> 1];
1097
+ x64Xor(h, shifted);
1098
+ x64Multiply(h, F1);
1099
+ shifted[1] = h[0] >>> 1;
1100
+ x64Xor(h, shifted);
1101
+ x64Multiply(h, F2);
1102
+ shifted[1] = h[0] >>> 1;
1103
+ x64Xor(h, shifted);
1104
+ }
1105
+ var C1 = [0x87c37b91, 0x114253d5];
1106
+ var C2 = [0x4cf5ad43, 0x2745937f];
1107
+ var M$1 = [0, 5];
1108
+ var N1 = [0, 0x52dce729];
1109
+ var N2 = [0, 0x38495ab5];
1110
+ /**
1111
+ * Given a string and an optional seed as an int, returns a 128 bit
1112
+ * hash using the x64 flavor of MurmurHash3, as an unsigned hex.
1113
+ * All internal functions mutates passed value to achieve minimal memory allocations and GC load
1114
+ *
1115
+ * Benchmark https://jsbench.me/p4lkpaoabi/1
1116
+ */
1117
+ function x64hash128(input, seed) {
1118
+ var key = getUTF8Bytes(input);
1119
+ seed = seed || 0;
1120
+ var length = [0, key.length];
1121
+ var remainder = length[1] % 16;
1122
+ var bytes = length[1] - remainder;
1123
+ var h1 = [0, seed];
1124
+ var h2 = [0, seed];
1125
+ var k1 = [0, 0];
1126
+ var k2 = [0, 0];
1127
+ var i;
1128
+ for (i = 0; i < bytes; i = i + 16) {
1129
+ k1[0] = key[i + 4] | (key[i + 5] << 8) | (key[i + 6] << 16) | (key[i + 7] << 24);
1130
+ k1[1] = key[i] | (key[i + 1] << 8) | (key[i + 2] << 16) | (key[i + 3] << 24);
1131
+ k2[0] = key[i + 12] | (key[i + 13] << 8) | (key[i + 14] << 16) | (key[i + 15] << 24);
1132
+ k2[1] = key[i + 8] | (key[i + 9] << 8) | (key[i + 10] << 16) | (key[i + 11] << 24);
1133
+ x64Multiply(k1, C1);
1134
+ x64Rotl(k1, 31);
1135
+ x64Multiply(k1, C2);
1136
+ x64Xor(h1, k1);
1137
+ x64Rotl(h1, 27);
1138
+ x64Add(h1, h2);
1139
+ x64Multiply(h1, M$1);
1140
+ x64Add(h1, N1);
1141
+ x64Multiply(k2, C2);
1142
+ x64Rotl(k2, 33);
1143
+ x64Multiply(k2, C1);
1144
+ x64Xor(h2, k2);
1145
+ x64Rotl(h2, 31);
1146
+ x64Add(h2, h1);
1147
+ x64Multiply(h2, M$1);
1148
+ x64Add(h2, N2);
1149
+ }
1150
+ k1[0] = 0;
1151
+ k1[1] = 0;
1152
+ k2[0] = 0;
1153
+ k2[1] = 0;
1154
+ var val = [0, 0];
1155
+ switch (remainder) {
1156
+ case 15:
1157
+ val[1] = key[i + 14];
1158
+ x64LeftShift(val, 48);
1159
+ x64Xor(k2, val);
1160
+ // fallthrough
1161
+ case 14:
1162
+ val[1] = key[i + 13];
1163
+ x64LeftShift(val, 40);
1164
+ x64Xor(k2, val);
1165
+ // fallthrough
1166
+ case 13:
1167
+ val[1] = key[i + 12];
1168
+ x64LeftShift(val, 32);
1169
+ x64Xor(k2, val);
1170
+ // fallthrough
1171
+ case 12:
1172
+ val[1] = key[i + 11];
1173
+ x64LeftShift(val, 24);
1174
+ x64Xor(k2, val);
1175
+ // fallthrough
1176
+ case 11:
1177
+ val[1] = key[i + 10];
1178
+ x64LeftShift(val, 16);
1179
+ x64Xor(k2, val);
1180
+ // fallthrough
1181
+ case 10:
1182
+ val[1] = key[i + 9];
1183
+ x64LeftShift(val, 8);
1184
+ x64Xor(k2, val);
1185
+ // fallthrough
1186
+ case 9:
1187
+ val[1] = key[i + 8];
1188
+ x64Xor(k2, val);
1189
+ x64Multiply(k2, C2);
1190
+ x64Rotl(k2, 33);
1191
+ x64Multiply(k2, C1);
1192
+ x64Xor(h2, k2);
1193
+ // fallthrough
1194
+ case 8:
1195
+ val[1] = key[i + 7];
1196
+ x64LeftShift(val, 56);
1197
+ x64Xor(k1, val);
1198
+ // fallthrough
1199
+ case 7:
1200
+ val[1] = key[i + 6];
1201
+ x64LeftShift(val, 48);
1202
+ x64Xor(k1, val);
1203
+ // fallthrough
1204
+ case 6:
1205
+ val[1] = key[i + 5];
1206
+ x64LeftShift(val, 40);
1207
+ x64Xor(k1, val);
1208
+ // fallthrough
1209
+ case 5:
1210
+ val[1] = key[i + 4];
1211
+ x64LeftShift(val, 32);
1212
+ x64Xor(k1, val);
1213
+ // fallthrough
1214
+ case 4:
1215
+ val[1] = key[i + 3];
1216
+ x64LeftShift(val, 24);
1217
+ x64Xor(k1, val);
1218
+ // fallthrough
1219
+ case 3:
1220
+ val[1] = key[i + 2];
1221
+ x64LeftShift(val, 16);
1222
+ x64Xor(k1, val);
1223
+ // fallthrough
1224
+ case 2:
1225
+ val[1] = key[i + 1];
1226
+ x64LeftShift(val, 8);
1227
+ x64Xor(k1, val);
1228
+ // fallthrough
1229
+ case 1:
1230
+ val[1] = key[i];
1231
+ x64Xor(k1, val);
1232
+ x64Multiply(k1, C1);
1233
+ x64Rotl(k1, 31);
1234
+ x64Multiply(k1, C2);
1235
+ x64Xor(h1, k1);
1236
+ // fallthrough
1237
+ }
1238
+ x64Xor(h1, length);
1239
+ x64Xor(h2, length);
1240
+ x64Add(h1, h2);
1241
+ x64Add(h2, h1);
1242
+ x64Fmix(h1);
1243
+ x64Fmix(h2);
1244
+ x64Add(h1, h2);
1245
+ x64Add(h2, h1);
1246
+ return (('00000000' + (h1[0] >>> 0).toString(16)).slice(-8) +
1247
+ ('00000000' + (h1[1] >>> 0).toString(16)).slice(-8) +
1248
+ ('00000000' + (h2[0] >>> 0).toString(16)).slice(-8) +
1249
+ ('00000000' + (h2[1] >>> 0).toString(16)).slice(-8));
1250
+ }
1251
+
1252
+ /**
1253
+ * Converts an error object to a plain object that can be used with `JSON.stringify`.
1254
+ * If you just run `JSON.stringify(error)`, you'll get `'{}'`.
1255
+ */
1256
+ function errorToObject(error) {
1257
+ var _a;
1258
+ return __assign({ name: error.name, message: error.message, stack: (_a = error.stack) === null || _a === void 0 ? void 0 : _a.split('\n') }, error);
1259
+ }
1260
+ function isFunctionNative(func) {
1261
+ return /^function\s.*?\{\s*\[native code]\s*}$/.test(String(func));
1262
+ }
1263
+
1264
+ function isFinalResultLoaded(loadResult) {
1265
+ return typeof loadResult !== 'function';
1266
+ }
1267
+ /**
1268
+ * Loads the given entropy source. Returns a function that gets an entropy component from the source.
1269
+ *
1270
+ * The result is returned synchronously to prevent `loadSources` from
1271
+ * waiting for one source to load before getting the components from the other sources.
1272
+ */
1273
+ function loadSource(source, sourceOptions) {
1274
+ var sourceLoadPromise = suppressUnhandledRejectionWarning(new Promise(function (resolveLoad) {
1275
+ var loadStartTime = Date.now();
1276
+ // `awaitIfAsync` is used instead of just `await` in order to measure the duration of synchronous sources
1277
+ // correctly (other microtasks won't affect the duration).
1278
+ awaitIfAsync(source.bind(null, sourceOptions), function () {
1279
+ var loadArgs = [];
1280
+ for (var _i = 0; _i < arguments.length; _i++) {
1281
+ loadArgs[_i] = arguments[_i];
1282
+ }
1283
+ var loadDuration = Date.now() - loadStartTime;
1284
+ // Source loading failed
1285
+ if (!loadArgs[0]) {
1286
+ return resolveLoad(function () { return ({ error: loadArgs[1], duration: loadDuration }); });
1287
+ }
1288
+ var loadResult = loadArgs[1];
1289
+ // Source loaded with the final result
1290
+ if (isFinalResultLoaded(loadResult)) {
1291
+ return resolveLoad(function () { return ({ value: loadResult, duration: loadDuration }); });
1292
+ }
1293
+ // Source loaded with "get" stage
1294
+ resolveLoad(function () {
1295
+ return new Promise(function (resolveGet) {
1296
+ var getStartTime = Date.now();
1297
+ awaitIfAsync(loadResult, function () {
1298
+ var getArgs = [];
1299
+ for (var _i = 0; _i < arguments.length; _i++) {
1300
+ getArgs[_i] = arguments[_i];
1301
+ }
1302
+ var duration = loadDuration + Date.now() - getStartTime;
1303
+ // Source getting failed
1304
+ if (!getArgs[0]) {
1305
+ return resolveGet({ error: getArgs[1], duration: duration });
1306
+ }
1307
+ // Source getting succeeded
1308
+ resolveGet({ value: getArgs[1], duration: duration });
1309
+ });
1310
+ });
1311
+ });
1312
+ });
1313
+ }));
1314
+ return function getComponent() {
1315
+ return sourceLoadPromise.then(function (finalizeSource) { return finalizeSource(); });
1316
+ };
1317
+ }
1318
+ /**
1319
+ * Loads the given entropy sources. Returns a function that collects the entropy components.
1320
+ *
1321
+ * The result is returned synchronously in order to allow start getting the components
1322
+ * before the sources are loaded completely.
1323
+ *
1324
+ * Warning for package users:
1325
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
1326
+ */
1327
+ function loadSources(sources, sourceOptions, excludeSources, loopReleaseInterval) {
1328
+ var includedSources = Object.keys(sources).filter(function (sourceKey) { return excludes(excludeSources, sourceKey); });
1329
+ // Using `mapWithBreaks` allows asynchronous sources to complete between synchronous sources
1330
+ // and measure the duration correctly
1331
+ var sourceGettersPromise = suppressUnhandledRejectionWarning(mapWithBreaks(includedSources, function (sourceKey) { return loadSource(sources[sourceKey], sourceOptions); }, loopReleaseInterval));
1332
+ return function getComponents() {
1333
+ return __awaiter(this, void 0, void 0, function () {
1334
+ var sourceGetters, componentPromises, componentArray, components, index;
1335
+ return __generator(this, function (_a) {
1336
+ switch (_a.label) {
1337
+ case 0: return [4 /*yield*/, sourceGettersPromise];
1338
+ case 1:
1339
+ sourceGetters = _a.sent();
1340
+ return [4 /*yield*/, mapWithBreaks(sourceGetters, function (sourceGetter) { return suppressUnhandledRejectionWarning(sourceGetter()); }, loopReleaseInterval)];
1341
+ case 2:
1342
+ componentPromises = _a.sent();
1343
+ return [4 /*yield*/, Promise.all(componentPromises)
1344
+ // Keeping the component keys order the same as the source keys order
1345
+ ];
1346
+ case 3:
1347
+ componentArray = _a.sent();
1348
+ components = {};
1349
+ for (index = 0; index < includedSources.length; ++index) {
1350
+ components[includedSources[index]] = componentArray[index];
1351
+ }
1352
+ return [2 /*return*/, components];
1353
+ }
1354
+ });
1355
+ });
1356
+ };
1357
+ }
1358
+
1359
+ /*
1360
+ * Functions to help with features that vary through browsers
1361
+ */
1362
+ /**
1363
+ * Checks whether the browser is based on Trident (the Internet Explorer engine) without using user-agent.
1364
+ *
1365
+ * Warning for package users:
1366
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
1367
+ */
1368
+ function isTrident() {
1369
+ var w = window;
1370
+ var n = navigator;
1371
+ // The properties are checked to be in IE 10, IE 11 and not to be in other browsers in October 2020
1372
+ return (countTruthy([
1373
+ 'MSCSSMatrix' in w,
1374
+ 'msSetImmediate' in w,
1375
+ 'msIndexedDB' in w,
1376
+ 'msMaxTouchPoints' in n,
1377
+ 'msPointerEnabled' in n,
1378
+ ]) >= 4);
1379
+ }
1380
+ /**
1381
+ * Checks whether the browser is based on EdgeHTML (the pre-Chromium Edge engine) without using user-agent.
1382
+ *
1383
+ * Warning for package users:
1384
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
1385
+ */
1386
+ function isEdgeHTML() {
1387
+ // Based on research in October 2020
1388
+ var w = window;
1389
+ var n = navigator;
1390
+ return (countTruthy(['msWriteProfilerMark' in w, 'MSStream' in w, 'msLaunchUri' in n, 'msSaveBlob' in n]) >= 3 &&
1391
+ !isTrident());
1392
+ }
1393
+ /**
1394
+ * Checks whether the browser is based on Chromium without using user-agent.
1395
+ *
1396
+ * Warning for package users:
1397
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
1398
+ */
1399
+ function isChromium() {
1400
+ // Based on research in October 2020. Tested to detect Chromium 42-86.
1401
+ var w = window;
1402
+ var n = navigator;
1403
+ return (countTruthy([
1404
+ 'webkitPersistentStorage' in n,
1405
+ 'webkitTemporaryStorage' in n,
1406
+ (n.vendor || '').indexOf('Google') === 0,
1407
+ 'webkitResolveLocalFileSystemURL' in w,
1408
+ 'BatteryManager' in w,
1409
+ 'webkitMediaStream' in w,
1410
+ 'webkitSpeechGrammar' in w,
1411
+ ]) >= 5);
1412
+ }
1413
+ /**
1414
+ * Checks whether the browser is based on mobile or desktop Safari without using user-agent.
1415
+ * All iOS browsers use WebKit (the Safari engine).
1416
+ *
1417
+ * Warning for package users:
1418
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
1419
+ */
1420
+ function isWebKit() {
1421
+ // Based on research in August 2024
1422
+ var w = window;
1423
+ var n = navigator;
1424
+ return (countTruthy([
1425
+ 'ApplePayError' in w,
1426
+ 'CSSPrimitiveValue' in w,
1427
+ 'Counter' in w,
1428
+ n.vendor.indexOf('Apple') === 0,
1429
+ 'RGBColor' in w,
1430
+ 'WebKitMediaKeys' in w,
1431
+ ]) >= 4);
1432
+ }
1433
+ /**
1434
+ * Checks whether this WebKit browser is a desktop browser.
1435
+ * It doesn't check that the browser is based on WebKit, there is a separate function for this.
1436
+ *
1437
+ * Warning for package users:
1438
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
1439
+ */
1440
+ function isDesktopWebKit() {
1441
+ // Checked in Safari and DuckDuckGo
1442
+ var w = window;
1443
+ var HTMLElement = w.HTMLElement, Document = w.Document;
1444
+ return (countTruthy([
1445
+ 'safari' in w,
1446
+ !('ongestureend' in w),
1447
+ !('TouchEvent' in w),
1448
+ !('orientation' in w),
1449
+ HTMLElement && !('autocapitalize' in HTMLElement.prototype),
1450
+ Document && 'pointerLockElement' in Document.prototype,
1451
+ ]) >= 4);
1452
+ }
1453
+ /**
1454
+ * Checks whether this WebKit browser is Safari.
1455
+ * It doesn't check that the browser is based on WebKit, there is a separate function for this.
1456
+ *
1457
+ * Warning! The function works properly only for Safari version 15.4 and newer.
1458
+ */
1459
+ function isSafariWebKit() {
1460
+ // Checked in Safari, Chrome, Firefox, Yandex, UC Browser, Opera, Edge and DuckDuckGo.
1461
+ // iOS Safari and Chrome were checked on iOS 11-18. DuckDuckGo was checked on iOS 17-18 and macOS 14-15.
1462
+ // Desktop Safari versions 12-18 were checked.
1463
+ // The other browsers were checked on iOS 17 and 18; there was no chance to check them on the other OS versions.
1464
+ var w = window;
1465
+ return (
1466
+ // Filters-out Chrome, Yandex, DuckDuckGo (macOS and iOS), Edge
1467
+ isFunctionNative(w.print) &&
1468
+ // Doesn't work in Safari < 15.4
1469
+ String(w.browser) === '[object WebPageNamespace]');
1470
+ }
1471
+ /**
1472
+ * Checks whether the browser is based on Gecko (Firefox engine) without using user-agent.
1473
+ *
1474
+ * Warning for package users:
1475
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
1476
+ */
1477
+ function isGecko() {
1478
+ var _a, _b;
1479
+ var w = window;
1480
+ // Based on research in September 2020
1481
+ return (countTruthy([
1482
+ 'buildID' in navigator,
1483
+ 'MozAppearance' in ((_b = (_a = document.documentElement) === null || _a === void 0 ? void 0 : _a.style) !== null && _b !== void 0 ? _b : {}),
1484
+ 'onmozfullscreenchange' in w,
1485
+ 'mozInnerScreenX' in w,
1486
+ 'CSSMozDocumentRule' in w,
1487
+ 'CanvasCaptureMediaStream' in w,
1488
+ ]) >= 4);
1489
+ }
1490
+ /**
1491
+ * Checks whether the browser is based on Chromium version ≥86 without using user-agent.
1492
+ * It doesn't check that the browser is based on Chromium, there is a separate function for this.
1493
+ */
1494
+ function isChromium86OrNewer() {
1495
+ // Checked in Chrome 85 vs Chrome 86 both on desktop and Android. Checked in macOS Chrome 128, Android Chrome 127.
1496
+ var w = window;
1497
+ return (countTruthy([
1498
+ !('MediaSettingsRange' in w),
1499
+ 'RTCEncodedAudioFrame' in w,
1500
+ '' + w.Intl === '[object Intl]',
1501
+ '' + w.Reflect === '[object Reflect]',
1502
+ ]) >= 3);
1503
+ }
1504
+ /**
1505
+ * Checks whether the browser is based on Chromium version ≥122 without using user-agent.
1506
+ * It doesn't check that the browser is based on Chromium, there is a separate function for this.
1507
+ */
1508
+ function isChromium122OrNewer() {
1509
+ // Checked in Chrome 121 vs Chrome 122 and 129 both on desktop and Android
1510
+ var w = window;
1511
+ var URLPattern = w.URLPattern;
1512
+ return (countTruthy([
1513
+ 'union' in Set.prototype,
1514
+ 'Iterator' in w,
1515
+ URLPattern && 'hasRegExpGroups' in URLPattern.prototype,
1516
+ 'RGB8' in WebGLRenderingContext.prototype,
1517
+ ]) >= 3);
1518
+ }
1519
+ /**
1520
+ * Checks whether the browser is based on WebKit version ≥606 (Safari ≥12) without using user-agent.
1521
+ * It doesn't check that the browser is based on WebKit, there is a separate function for this.
1522
+ *
1523
+ * @see https://en.wikipedia.org/wiki/Safari_version_history#Release_history Safari-WebKit versions map
1524
+ */
1525
+ function isWebKit606OrNewer() {
1526
+ // Checked in Safari 9–18
1527
+ var w = window;
1528
+ return (countTruthy([
1529
+ 'DOMRectList' in w,
1530
+ 'RTCPeerConnectionIceEvent' in w,
1531
+ 'SVGGeometryElement' in w,
1532
+ 'ontransitioncancel' in w,
1533
+ ]) >= 3);
1534
+ }
1535
+ /**
1536
+ * Checks whether the browser is based on WebKit version ≥616 (Safari ≥17) without using user-agent.
1537
+ * It doesn't check that the browser is based on WebKit, there is a separate function for this.
1538
+ *
1539
+ * @see https://developer.apple.com/documentation/safari-release-notes/safari-17-release-notes Safari 17 release notes
1540
+ * @see https://tauri.app/v1/references/webview-versions/#webkit-versions-in-safari Safari-WebKit versions map
1541
+ */
1542
+ function isWebKit616OrNewer() {
1543
+ var w = window;
1544
+ var n = navigator;
1545
+ var CSS = w.CSS, HTMLButtonElement = w.HTMLButtonElement;
1546
+ return (countTruthy([
1547
+ !('getStorageUpdates' in n),
1548
+ HTMLButtonElement && 'popover' in HTMLButtonElement.prototype,
1549
+ 'CSSCounterStyleRule' in w,
1550
+ CSS.supports('font-size-adjust: ex-height 0.5'),
1551
+ CSS.supports('text-transform: full-width'),
1552
+ ]) >= 4);
1553
+ }
1554
+ /**
1555
+ * Checks whether the device is an iPad.
1556
+ * It doesn't check that the engine is WebKit and that the WebKit isn't desktop.
1557
+ */
1558
+ function isIPad() {
1559
+ // Checked on:
1560
+ // Safari on iPadOS (both mobile and desktop modes): 8, 11-18
1561
+ // Chrome on iPadOS (both mobile and desktop modes): 11-18
1562
+ // Safari on iOS (both mobile and desktop modes): 9-18
1563
+ // Chrome on iOS (both mobile and desktop modes): 9-18
1564
+ // Before iOS 13. Safari tampers the value in "request desktop site" mode since iOS 13.
1565
+ if (navigator.platform === 'iPad') {
1566
+ return true;
1567
+ }
1568
+ var s = screen;
1569
+ var screenRatio = s.width / s.height;
1570
+ return (countTruthy([
1571
+ // Since iOS 13. Doesn't work in Chrome on iPadOS <15, but works in desktop mode.
1572
+ 'MediaSource' in window,
1573
+ // Since iOS 12. Doesn't work in Chrome on iPadOS.
1574
+ !!Element.prototype.webkitRequestFullscreen,
1575
+ // iPhone 4S that runs iOS 9 matches this, but it is not supported
1576
+ // Doesn't work in incognito mode of Safari ≥17 with split screen because of tracking prevention
1577
+ screenRatio > 0.65 && screenRatio < 1.53,
1578
+ ]) >= 2);
1579
+ }
1580
+ /**
1581
+ * Warning for package users:
1582
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
1583
+ */
1584
+ function getFullscreenElement() {
1585
+ var d = document;
1586
+ return d.fullscreenElement || d.msFullscreenElement || d.mozFullScreenElement || d.webkitFullscreenElement || null;
1587
+ }
1588
+ function exitFullscreen() {
1589
+ var d = document;
1590
+ // `call` is required because the function throws an error without a proper "this" context
1591
+ return (d.exitFullscreen || d.msExitFullscreen || d.mozCancelFullScreen || d.webkitExitFullscreen).call(d);
1592
+ }
1593
+ /**
1594
+ * Checks whether the device runs on Android without using user-agent.
1595
+ *
1596
+ * Warning for package users:
1597
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
1598
+ */
1599
+ function isAndroid() {
1600
+ var isItChromium = isChromium();
1601
+ var isItGecko = isGecko();
1602
+ var w = window;
1603
+ var n = navigator;
1604
+ var c = 'connection';
1605
+ // Chrome removes all words "Android" from `navigator` when desktop version is requested
1606
+ // Firefox keeps "Android" in `navigator.appVersion` when desktop version is requested
1607
+ if (isItChromium) {
1608
+ return (countTruthy([
1609
+ !('SharedWorker' in w),
1610
+ // `typechange` is deprecated, but it's still present on Android (tested on Chrome Mobile 117)
1611
+ // Removal proposal https://bugs.chromium.org/p/chromium/issues/detail?id=699892
1612
+ // Note: this expression returns true on ChromeOS, so additional detectors are required to avoid false-positives
1613
+ n[c] && 'ontypechange' in n[c],
1614
+ !('sinkId' in new Audio()),
1615
+ ]) >= 2);
1616
+ }
1617
+ else if (isItGecko) {
1618
+ return countTruthy(['onorientationchange' in w, 'orientation' in w, /android/i.test(n.appVersion)]) >= 2;
1619
+ }
1620
+ else {
1621
+ // Only 2 browser engines are presented on Android.
1622
+ // Actually, there is also Android 4.1 browser, but it's not worth detecting it at the moment.
1623
+ return false;
1624
+ }
1625
+ }
1626
+ /**
1627
+ * Checks whether the browser is Samsung Internet without using user-agent.
1628
+ * It doesn't check that the browser is based on Chromium, please use `isChromium` before using this function.
1629
+ *
1630
+ * Warning for package users:
1631
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
1632
+ */
1633
+ function isSamsungInternet() {
1634
+ // Checked in Samsung Internet 21, 25 and 27
1635
+ var n = navigator;
1636
+ var w = window;
1637
+ var audioPrototype = Audio.prototype;
1638
+ var visualViewport = w.visualViewport;
1639
+ return (countTruthy([
1640
+ 'srLatency' in audioPrototype,
1641
+ 'srChannelCount' in audioPrototype,
1642
+ 'devicePosture' in n,
1643
+ visualViewport && 'segments' in visualViewport,
1644
+ 'getTextInformation' in Image.prototype, // Not available in Samsung Internet 21
1645
+ ]) >= 3);
1646
+ }
1647
+
1648
+ /**
1649
+ * A deep description: https://fingerprint.com/blog/audio-fingerprinting/
1650
+ * Inspired by and based on https://github.com/cozylife/audio-fingerprint
1651
+ *
1652
+ * A version of the entropy source with stabilization to make it suitable for static fingerprinting.
1653
+ * Audio signal is noised in private mode of Safari 17, so audio fingerprinting is skipped in Safari 17.
1654
+ */
1655
+ function getAudioFingerprint() {
1656
+ if (doesBrowserPerformAntifingerprinting$1()) {
1657
+ return -4 /* SpecialFingerprint.KnownForAntifingerprinting */;
1658
+ }
1659
+ return getUnstableAudioFingerprint();
1660
+ }
1661
+ /**
1662
+ * A version of the entropy source without stabilization.
1663
+ *
1664
+ * Warning for package users:
1665
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
1666
+ */
1667
+ function getUnstableAudioFingerprint() {
1668
+ var w = window;
1669
+ var AudioContext = w.OfflineAudioContext || w.webkitOfflineAudioContext;
1670
+ if (!AudioContext) {
1671
+ return -2 /* SpecialFingerprint.NotSupported */;
1672
+ }
1673
+ // In some browsers, audio context always stays suspended unless the context is started in response to a user action
1674
+ // (e.g. a click or a tap). It prevents audio fingerprint from being taken at an arbitrary moment of time.
1675
+ // Such browsers are old and unpopular, so the audio fingerprinting is just skipped in them.
1676
+ // See a similar case explanation at https://stackoverflow.com/questions/46363048/onaudioprocess-not-called-on-ios11#46534088
1677
+ if (doesBrowserSuspendAudioContext()) {
1678
+ return -1 /* SpecialFingerprint.KnownForSuspending */;
1679
+ }
1680
+ var hashFromIndex = 4500;
1681
+ var hashToIndex = 5000;
1682
+ var context = new AudioContext(1, hashToIndex, 44100);
1683
+ var oscillator = context.createOscillator();
1684
+ oscillator.type = 'triangle';
1685
+ oscillator.frequency.value = 10000;
1686
+ var compressor = context.createDynamicsCompressor();
1687
+ compressor.threshold.value = -50;
1688
+ compressor.knee.value = 40;
1689
+ compressor.ratio.value = 12;
1690
+ compressor.attack.value = 0;
1691
+ compressor.release.value = 0.25;
1692
+ oscillator.connect(compressor);
1693
+ compressor.connect(context.destination);
1694
+ oscillator.start(0);
1695
+ var _a = startRenderingAudio(context), renderPromise = _a[0], finishRendering = _a[1];
1696
+ // Suppresses the console error message in case when the fingerprint fails before requested
1697
+ var fingerprintPromise = suppressUnhandledRejectionWarning(renderPromise.then(function (buffer) { return getHash(buffer.getChannelData(0).subarray(hashFromIndex)); }, function (error) {
1698
+ if (error.name === "timeout" /* InnerErrorName.Timeout */ || error.name === "suspended" /* InnerErrorName.Suspended */) {
1699
+ return -3 /* SpecialFingerprint.Timeout */;
1700
+ }
1701
+ throw error;
1702
+ }));
1703
+ return function () {
1704
+ finishRendering();
1705
+ return fingerprintPromise;
1706
+ };
1707
+ }
1708
+ /**
1709
+ * Checks if the current browser is known for always suspending audio context
1710
+ */
1711
+ function doesBrowserSuspendAudioContext() {
1712
+ // Mobile Safari 11 and older
1713
+ return isWebKit() && !isDesktopWebKit() && !isWebKit606OrNewer();
1714
+ }
1715
+ /**
1716
+ * Checks if the current browser is known for applying anti-fingerprinting measures in all or some critical modes
1717
+ */
1718
+ function doesBrowserPerformAntifingerprinting$1() {
1719
+ return (
1720
+ // Safari ≥17
1721
+ (isWebKit() && isWebKit616OrNewer() && isSafariWebKit()) ||
1722
+ // Samsung Internet ≥26
1723
+ (isChromium() && isSamsungInternet() && isChromium122OrNewer()));
1724
+ }
1725
+ /**
1726
+ * Starts rendering the audio context.
1727
+ * When the returned function is called, the render process starts finishing.
1728
+ */
1729
+ function startRenderingAudio(context) {
1730
+ var renderTryMaxCount = 3;
1731
+ var renderRetryDelay = 500;
1732
+ var runningMaxAwaitTime = 500;
1733
+ var runningSufficientTime = 5000;
1734
+ var finalize = function () { return undefined; };
1735
+ var resultPromise = new Promise(function (resolve, reject) {
1736
+ var isFinalized = false;
1737
+ var renderTryCount = 0;
1738
+ var startedRunningAt = 0;
1739
+ context.oncomplete = function (event) { return resolve(event.renderedBuffer); };
1740
+ var startRunningTimeout = function () {
1741
+ setTimeout(function () { return reject(makeInnerError("timeout" /* InnerErrorName.Timeout */)); }, Math.min(runningMaxAwaitTime, startedRunningAt + runningSufficientTime - Date.now()));
1742
+ };
1743
+ var tryRender = function () {
1744
+ try {
1745
+ var renderingPromise = context.startRendering();
1746
+ // `context.startRendering` has two APIs: Promise and callback, we check that it's really a promise just in case
1747
+ if (isPromise(renderingPromise)) {
1748
+ // Suppresses all unhandled rejections in case of scheduled redundant retries after successful rendering
1749
+ suppressUnhandledRejectionWarning(renderingPromise);
1750
+ }
1751
+ switch (context.state) {
1752
+ case 'running':
1753
+ startedRunningAt = Date.now();
1754
+ if (isFinalized) {
1755
+ startRunningTimeout();
1756
+ }
1757
+ break;
1758
+ // Sometimes the audio context doesn't start after calling `startRendering` (in addition to the cases where
1759
+ // audio context doesn't start at all). A known case is starting an audio context when the browser tab is in
1760
+ // background on iPhone. Retries usually help in this case.
1761
+ case 'suspended':
1762
+ // The audio context can reject starting until the tab is in foreground. Long fingerprint duration
1763
+ // in background isn't a problem, therefore the retry attempts don't count in background. It can lead to
1764
+ // a situation when a fingerprint takes very long time and finishes successfully. FYI, the audio context
1765
+ // can be suspended when `document.hidden === false` and start running after a retry.
1766
+ if (!document.hidden) {
1767
+ renderTryCount++;
1768
+ }
1769
+ if (isFinalized && renderTryCount >= renderTryMaxCount) {
1770
+ reject(makeInnerError("suspended" /* InnerErrorName.Suspended */));
1771
+ }
1772
+ else {
1773
+ setTimeout(tryRender, renderRetryDelay);
1774
+ }
1775
+ break;
1776
+ }
1777
+ }
1778
+ catch (error) {
1779
+ reject(error);
1780
+ }
1781
+ };
1782
+ tryRender();
1783
+ finalize = function () {
1784
+ if (!isFinalized) {
1785
+ isFinalized = true;
1786
+ if (startedRunningAt > 0) {
1787
+ startRunningTimeout();
1788
+ }
1789
+ }
1790
+ };
1791
+ });
1792
+ return [resultPromise, finalize];
1793
+ }
1794
+ function getHash(signal) {
1795
+ var hash = 0;
1796
+ for (var i = 0; i < signal.length; ++i) {
1797
+ hash += Math.abs(signal[i]);
1798
+ }
1799
+ return hash;
1800
+ }
1801
+ function makeInnerError(name) {
1802
+ var error = new Error(name);
1803
+ error.name = name;
1804
+ return error;
1805
+ }
1806
+
1807
+ /**
1808
+ * Creates and keeps an invisible iframe while the given function runs.
1809
+ * The given function is called when the iframe is loaded and has a body.
1810
+ * The iframe allows to measure DOM sizes inside itself.
1811
+ *
1812
+ * Notice: passing an initial HTML code doesn't work in IE.
1813
+ *
1814
+ * Warning for package users:
1815
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
1816
+ */
1817
+ function withIframe(action, initialHtml, domPollInterval) {
1818
+ var _a, _b, _c;
1819
+ if (domPollInterval === void 0) { domPollInterval = 50; }
1820
+ return __awaiter(this, void 0, void 0, function () {
1821
+ var d, iframe;
1822
+ return __generator(this, function (_d) {
1823
+ switch (_d.label) {
1824
+ case 0:
1825
+ d = document;
1826
+ _d.label = 1;
1827
+ case 1:
1828
+ if (!!d.body) return [3 /*break*/, 3];
1829
+ return [4 /*yield*/, wait(domPollInterval)];
1830
+ case 2:
1831
+ _d.sent();
1832
+ return [3 /*break*/, 1];
1833
+ case 3:
1834
+ iframe = d.createElement('iframe');
1835
+ _d.label = 4;
1836
+ case 4:
1837
+ _d.trys.push([4, , 10, 11]);
1838
+ return [4 /*yield*/, new Promise(function (_resolve, _reject) {
1839
+ var isComplete = false;
1840
+ var resolve = function () {
1841
+ isComplete = true;
1842
+ _resolve();
1843
+ };
1844
+ var reject = function (error) {
1845
+ isComplete = true;
1846
+ _reject(error);
1847
+ };
1848
+ iframe.onload = resolve;
1849
+ iframe.onerror = reject;
1850
+ var style = iframe.style;
1851
+ style.setProperty('display', 'block', 'important'); // Required for browsers to calculate the layout
1852
+ style.position = 'absolute';
1853
+ style.top = '0';
1854
+ style.left = '0';
1855
+ style.visibility = 'hidden';
1856
+ if (initialHtml && 'srcdoc' in iframe) {
1857
+ iframe.srcdoc = initialHtml;
1858
+ }
1859
+ else {
1860
+ iframe.src = 'about:blank';
1861
+ }
1862
+ d.body.appendChild(iframe);
1863
+ // WebKit in WeChat doesn't fire the iframe's `onload` for some reason.
1864
+ // This code checks for the loading state manually.
1865
+ // See https://github.com/fingerprintjs/fingerprintjs/issues/645
1866
+ var checkReadyState = function () {
1867
+ var _a, _b;
1868
+ // The ready state may never become 'complete' in Firefox despite the 'load' event being fired.
1869
+ // So an infinite setTimeout loop can happen without this check.
1870
+ // See https://github.com/fingerprintjs/fingerprintjs/pull/716#issuecomment-986898796
1871
+ if (isComplete) {
1872
+ return;
1873
+ }
1874
+ // Make sure iframe.contentWindow and iframe.contentWindow.document are both loaded
1875
+ // The contentWindow.document can miss in JSDOM (https://github.com/jsdom/jsdom).
1876
+ if (((_b = (_a = iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.document) === null || _b === void 0 ? void 0 : _b.readyState) === 'complete') {
1877
+ resolve();
1878
+ }
1879
+ else {
1880
+ setTimeout(checkReadyState, 10);
1881
+ }
1882
+ };
1883
+ checkReadyState();
1884
+ })];
1885
+ case 5:
1886
+ _d.sent();
1887
+ _d.label = 6;
1888
+ case 6:
1889
+ if (!!((_b = (_a = iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.document) === null || _b === void 0 ? void 0 : _b.body)) return [3 /*break*/, 8];
1890
+ return [4 /*yield*/, wait(domPollInterval)];
1891
+ case 7:
1892
+ _d.sent();
1893
+ return [3 /*break*/, 6];
1894
+ case 8: return [4 /*yield*/, action(iframe, iframe.contentWindow)];
1895
+ case 9: return [2 /*return*/, _d.sent()];
1896
+ case 10:
1897
+ (_c = iframe.parentNode) === null || _c === void 0 ? void 0 : _c.removeChild(iframe);
1898
+ return [7 /*endfinally*/];
1899
+ case 11: return [2 /*return*/];
1900
+ }
1901
+ });
1902
+ });
1903
+ }
1904
+ /**
1905
+ * Creates a DOM element that matches the given selector.
1906
+ * Only single element selector are supported (without operators like space, +, >, etc).
1907
+ */
1908
+ function selectorToElement(selector) {
1909
+ var _a = parseSimpleCssSelector(selector), tag = _a[0], attributes = _a[1];
1910
+ var element = document.createElement(tag !== null && tag !== void 0 ? tag : 'div');
1911
+ for (var _i = 0, _b = Object.keys(attributes); _i < _b.length; _i++) {
1912
+ var name_1 = _b[_i];
1913
+ var value = attributes[name_1].join(' ');
1914
+ // Changing the `style` attribute can cause a CSP error, therefore we change the `style.cssText` property.
1915
+ // https://github.com/fingerprintjs/fingerprintjs/issues/733
1916
+ if (name_1 === 'style') {
1917
+ addStyleString(element.style, value);
1918
+ }
1919
+ else {
1920
+ element.setAttribute(name_1, value);
1921
+ }
1922
+ }
1923
+ return element;
1924
+ }
1925
+ /**
1926
+ * Adds CSS styles from a string in such a way that doesn't trigger a CSP warning (unsafe-inline or unsafe-eval)
1927
+ */
1928
+ function addStyleString(style, source) {
1929
+ // We don't use `style.cssText` because browsers must block it when no `unsafe-eval` CSP is presented: https://csplite.com/csp145/#w3c_note
1930
+ // Even though the browsers ignore this standard, we don't use `cssText` just in case.
1931
+ for (var _i = 0, _a = source.split(';'); _i < _a.length; _i++) {
1932
+ var property = _a[_i];
1933
+ var match = /^\s*([\w-]+)\s*:\s*(.+?)(\s*!([\w-]+))?\s*$/.exec(property);
1934
+ if (match) {
1935
+ var name_2 = match[1], value = match[2], priority = match[4];
1936
+ style.setProperty(name_2, value, priority || ''); // The last argument can't be undefined in IE11
1937
+ }
1938
+ }
1939
+ }
1940
+ /**
1941
+ * Returns true if the code runs in an iframe, and any parent page's origin doesn't match the current origin
1942
+ */
1943
+ function isAnyParentCrossOrigin() {
1944
+ var currentWindow = window;
1945
+ for (;;) {
1946
+ var parentWindow = currentWindow.parent;
1947
+ if (!parentWindow || parentWindow === currentWindow) {
1948
+ return false; // The top page is reached
1949
+ }
1950
+ try {
1951
+ if (parentWindow.location.origin !== currentWindow.location.origin) {
1952
+ return true;
1953
+ }
1954
+ }
1955
+ catch (error) {
1956
+ // The error is thrown when `origin` is accessed on `parentWindow.location` when the parent is cross-origin
1957
+ if (error instanceof Error && error.name === 'SecurityError') {
1958
+ return true;
1959
+ }
1960
+ throw error;
1961
+ }
1962
+ currentWindow = parentWindow;
1963
+ }
1964
+ }
1965
+
1966
+ // We use m or w because these two characters take up the maximum width.
1967
+ // And we use a LLi so that the same matching fonts can get separated.
1968
+ var testString = 'mmMwWLliI0O&1';
1969
+ // We test using 48px font size, we may use any size. I guess larger the better.
1970
+ var textSize = '48px';
1971
+ // A font will be compared against all the three default fonts.
1972
+ // And if for any default fonts it doesn't match, then that font is available.
1973
+ var baseFonts = ['monospace', 'sans-serif', 'serif'];
1974
+ var fontList = [
1975
+ // This is android-specific font from "Roboto" family
1976
+ 'sans-serif-thin',
1977
+ 'ARNO PRO',
1978
+ 'Agency FB',
1979
+ 'Arabic Typesetting',
1980
+ 'Arial Unicode MS',
1981
+ 'AvantGarde Bk BT',
1982
+ 'BankGothic Md BT',
1983
+ 'Batang',
1984
+ 'Bitstream Vera Sans Mono',
1985
+ 'Calibri',
1986
+ 'Century',
1987
+ 'Century Gothic',
1988
+ 'Clarendon',
1989
+ 'EUROSTILE',
1990
+ 'Franklin Gothic',
1991
+ 'Futura Bk BT',
1992
+ 'Futura Md BT',
1993
+ 'GOTHAM',
1994
+ 'Gill Sans',
1995
+ 'HELV',
1996
+ 'Haettenschweiler',
1997
+ 'Helvetica Neue',
1998
+ 'Humanst521 BT',
1999
+ 'Leelawadee',
2000
+ 'Letter Gothic',
2001
+ 'Levenim MT',
2002
+ 'Lucida Bright',
2003
+ 'Lucida Sans',
2004
+ 'Menlo',
2005
+ 'MS Mincho',
2006
+ 'MS Outlook',
2007
+ 'MS Reference Specialty',
2008
+ 'MS UI Gothic',
2009
+ 'MT Extra',
2010
+ 'MYRIAD PRO',
2011
+ 'Marlett',
2012
+ 'Meiryo UI',
2013
+ 'Microsoft Uighur',
2014
+ 'Minion Pro',
2015
+ 'Monotype Corsiva',
2016
+ 'PMingLiU',
2017
+ 'Pristina',
2018
+ 'SCRIPTINA',
2019
+ 'Segoe UI Light',
2020
+ 'Serifa',
2021
+ 'SimHei',
2022
+ 'Small Fonts',
2023
+ 'Staccato222 BT',
2024
+ 'TRAJAN PRO',
2025
+ 'Univers CE 55 Medium',
2026
+ 'Vrinda',
2027
+ 'ZWAdobeF',
2028
+ ];
2029
+ // kudos to http://www.lalit.org/lab/javascript-css-font-detect/
2030
+ function getFonts() {
2031
+ var _this = this;
2032
+ // Running the script in an iframe makes it not affect the page look and not be affected by the page CSS. See:
2033
+ // https://github.com/fingerprintjs/fingerprintjs/issues/592
2034
+ // https://github.com/fingerprintjs/fingerprintjs/issues/628
2035
+ return withIframe(function (_, _a) {
2036
+ var document = _a.document;
2037
+ return __awaiter(_this, void 0, void 0, function () {
2038
+ var holder, spansContainer, defaultWidth, defaultHeight, createSpan, createSpanWithFonts, initializeBaseFontsSpans, initializeFontsSpans, isFontAvailable, baseFontsSpans, fontsSpans, index;
2039
+ return __generator(this, function (_b) {
2040
+ holder = document.body;
2041
+ holder.style.fontSize = textSize;
2042
+ spansContainer = document.createElement('div');
2043
+ spansContainer.style.setProperty('visibility', 'hidden', 'important');
2044
+ defaultWidth = {};
2045
+ defaultHeight = {};
2046
+ createSpan = function (fontFamily) {
2047
+ var span = document.createElement('span');
2048
+ var style = span.style;
2049
+ style.position = 'absolute';
2050
+ style.top = '0';
2051
+ style.left = '0';
2052
+ style.fontFamily = fontFamily;
2053
+ span.textContent = testString;
2054
+ spansContainer.appendChild(span);
2055
+ return span;
2056
+ };
2057
+ createSpanWithFonts = function (fontToDetect, baseFont) {
2058
+ return createSpan("'".concat(fontToDetect, "',").concat(baseFont));
2059
+ };
2060
+ initializeBaseFontsSpans = function () {
2061
+ return baseFonts.map(createSpan);
2062
+ };
2063
+ initializeFontsSpans = function () {
2064
+ // Stores {fontName : [spans for that font]}
2065
+ var spans = {};
2066
+ var _loop_1 = function (font) {
2067
+ spans[font] = baseFonts.map(function (baseFont) { return createSpanWithFonts(font, baseFont); });
2068
+ };
2069
+ for (var _i = 0, fontList_1 = fontList; _i < fontList_1.length; _i++) {
2070
+ var font = fontList_1[_i];
2071
+ _loop_1(font);
2072
+ }
2073
+ return spans;
2074
+ };
2075
+ isFontAvailable = function (fontSpans) {
2076
+ return baseFonts.some(function (baseFont, baseFontIndex) {
2077
+ return fontSpans[baseFontIndex].offsetWidth !== defaultWidth[baseFont] ||
2078
+ fontSpans[baseFontIndex].offsetHeight !== defaultHeight[baseFont];
2079
+ });
2080
+ };
2081
+ baseFontsSpans = initializeBaseFontsSpans();
2082
+ fontsSpans = initializeFontsSpans();
2083
+ // add all the spans to the DOM
2084
+ holder.appendChild(spansContainer);
2085
+ // get the default width for the three base fonts
2086
+ for (index = 0; index < baseFonts.length; index++) {
2087
+ defaultWidth[baseFonts[index]] = baseFontsSpans[index].offsetWidth; // width for the default font
2088
+ defaultHeight[baseFonts[index]] = baseFontsSpans[index].offsetHeight; // height for the default font
2089
+ }
2090
+ // check available fonts
2091
+ return [2 /*return*/, fontList.filter(function (font) { return isFontAvailable(fontsSpans[font]); })];
2092
+ });
2093
+ });
2094
+ });
2095
+ }
2096
+
2097
+ function getPlugins() {
2098
+ var rawPlugins = navigator.plugins;
2099
+ if (!rawPlugins) {
2100
+ return undefined;
2101
+ }
2102
+ var plugins = [];
2103
+ // Safari 10 doesn't support iterating navigator.plugins with for...of
2104
+ for (var i = 0; i < rawPlugins.length; ++i) {
2105
+ var plugin = rawPlugins[i];
2106
+ if (!plugin) {
2107
+ continue;
2108
+ }
2109
+ var mimeTypes = [];
2110
+ for (var j = 0; j < plugin.length; ++j) {
2111
+ var mimeType = plugin[j];
2112
+ mimeTypes.push({
2113
+ type: mimeType.type,
2114
+ suffixes: mimeType.suffixes,
2115
+ });
2116
+ }
2117
+ plugins.push({
2118
+ name: plugin.name,
2119
+ description: plugin.description,
2120
+ mimeTypes: mimeTypes,
2121
+ });
2122
+ }
2123
+ return plugins;
2124
+ }
2125
+
2126
+ /**
2127
+ * @see https://www.browserleaks.com/canvas#how-does-it-work
2128
+ *
2129
+ * A version of the entropy source with stabilization to make it suitable for static fingerprinting.
2130
+ * Canvas image is noised in private mode of Safari 17, so image rendering is skipped in Safari 17.
2131
+ */
2132
+ function getCanvasFingerprint() {
2133
+ return getUnstableCanvasFingerprint(doesBrowserPerformAntifingerprinting());
2134
+ }
2135
+ /**
2136
+ * A version of the entropy source without stabilization.
2137
+ *
2138
+ * Warning for package users:
2139
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
2140
+ */
2141
+ function getUnstableCanvasFingerprint(skipImages) {
2142
+ var _a;
2143
+ var winding = false;
2144
+ var geometry;
2145
+ var text;
2146
+ var _b = makeCanvasContext(), canvas = _b[0], context = _b[1];
2147
+ if (!isSupported(canvas, context)) {
2148
+ geometry = text = "unsupported" /* ImageStatus.Unsupported */;
2149
+ }
2150
+ else {
2151
+ winding = doesSupportWinding(context);
2152
+ if (skipImages) {
2153
+ geometry = text = "skipped" /* ImageStatus.Skipped */;
2154
+ }
2155
+ else {
2156
+ _a = renderImages(canvas, context), geometry = _a[0], text = _a[1];
2157
+ }
2158
+ }
2159
+ return { winding: winding, geometry: geometry, text: text };
2160
+ }
2161
+ function makeCanvasContext() {
2162
+ var canvas = document.createElement('canvas');
2163
+ canvas.width = 1;
2164
+ canvas.height = 1;
2165
+ return [canvas, canvas.getContext('2d')];
2166
+ }
2167
+ function isSupported(canvas, context) {
2168
+ return !!(context && canvas.toDataURL);
2169
+ }
2170
+ function doesSupportWinding(context) {
2171
+ // https://web.archive.org/web/20170825024655/http://blogs.adobe.com/webplatform/2013/01/30/winding-rules-in-canvas/
2172
+ // https://github.com/Modernizr/Modernizr/blob/master/feature-detects/canvas/winding.js
2173
+ context.rect(0, 0, 10, 10);
2174
+ context.rect(2, 2, 6, 6);
2175
+ return !context.isPointInPath(5, 5, 'evenodd');
2176
+ }
2177
+ function renderImages(canvas, context) {
2178
+ renderTextImage(canvas, context);
2179
+ var textImage1 = canvasToString(canvas);
2180
+ var textImage2 = canvasToString(canvas); // It's slightly faster to double-encode the text image
2181
+ // Some browsers add a noise to the canvas: https://github.com/fingerprintjs/fingerprintjs/issues/791
2182
+ // The canvas is excluded from the fingerprint in this case
2183
+ if (textImage1 !== textImage2) {
2184
+ return ["unstable" /* ImageStatus.Unstable */, "unstable" /* ImageStatus.Unstable */];
2185
+ }
2186
+ // Text is unstable:
2187
+ // https://github.com/fingerprintjs/fingerprintjs/issues/583
2188
+ // https://github.com/fingerprintjs/fingerprintjs/issues/103
2189
+ // Therefore it's extracted into a separate image.
2190
+ renderGeometryImage(canvas, context);
2191
+ var geometryImage = canvasToString(canvas);
2192
+ return [geometryImage, textImage1];
2193
+ }
2194
+ function renderTextImage(canvas, context) {
2195
+ // Resizing the canvas cleans it
2196
+ canvas.width = 240;
2197
+ canvas.height = 60;
2198
+ context.textBaseline = 'alphabetic';
2199
+ context.fillStyle = '#f60';
2200
+ context.fillRect(100, 1, 62, 20);
2201
+ context.fillStyle = '#069';
2202
+ // It's important to use explicit built-in fonts in order to exclude the affect of font preferences
2203
+ // (there is a separate entropy source for them).
2204
+ context.font = '11pt "Times New Roman"';
2205
+ // The choice of emojis has a gigantic impact on rendering performance (especially in FF).
2206
+ // Some newer emojis cause it to slow down 50-200 times.
2207
+ // There must be no text to the right of the emoji, see https://github.com/fingerprintjs/fingerprintjs/issues/574
2208
+ // A bare emoji shouldn't be used because the canvas will change depending on the script encoding:
2209
+ // https://github.com/fingerprintjs/fingerprintjs/issues/66
2210
+ // Escape sequence shouldn't be used too because Terser will turn it into a bare unicode.
2211
+ var printedText = "Cwm fjordbank gly ".concat(String.fromCharCode(55357, 56835) /* 😃 */);
2212
+ context.fillText(printedText, 2, 15);
2213
+ context.fillStyle = 'rgba(102, 204, 0, 0.2)';
2214
+ context.font = '18pt Arial';
2215
+ context.fillText(printedText, 4, 45);
2216
+ }
2217
+ function renderGeometryImage(canvas, context) {
2218
+ // Resizing the canvas cleans it
2219
+ canvas.width = 122;
2220
+ canvas.height = 110;
2221
+ // Canvas blending
2222
+ // https://web.archive.org/web/20170826194121/http://blogs.adobe.com/webplatform/2013/01/28/blending-features-in-canvas/
2223
+ // http://jsfiddle.net/NDYV8/16/
2224
+ context.globalCompositeOperation = 'multiply';
2225
+ for (var _i = 0, _a = [
2226
+ ['#f2f', 40, 40],
2227
+ ['#2ff', 80, 40],
2228
+ ['#ff2', 60, 80],
2229
+ ]; _i < _a.length; _i++) {
2230
+ var _b = _a[_i], color = _b[0], x = _b[1], y = _b[2];
2231
+ context.fillStyle = color;
2232
+ context.beginPath();
2233
+ context.arc(x, y, 40, 0, Math.PI * 2, true);
2234
+ context.closePath();
2235
+ context.fill();
2236
+ }
2237
+ // Canvas winding
2238
+ // https://web.archive.org/web/20130913061632/http://blogs.adobe.com/webplatform/2013/01/30/winding-rules-in-canvas/
2239
+ // http://jsfiddle.net/NDYV8/19/
2240
+ context.fillStyle = '#f9c';
2241
+ context.arc(60, 60, 60, 0, Math.PI * 2, true);
2242
+ context.arc(60, 60, 20, 0, Math.PI * 2, true);
2243
+ context.fill('evenodd');
2244
+ }
2245
+ function canvasToString(canvas) {
2246
+ return canvas.toDataURL();
2247
+ }
2248
+ /**
2249
+ * Checks if the current browser is known for applying anti-fingerprinting measures in all or some critical modes
2250
+ */
2251
+ function doesBrowserPerformAntifingerprinting() {
2252
+ // Safari 17
2253
+ return isWebKit() && isWebKit616OrNewer() && isSafariWebKit();
2254
+ }
2255
+
2256
+ /**
2257
+ * This is a crude and primitive touch screen detection. It's not possible to currently reliably detect the availability
2258
+ * of a touch screen with a JS, without actually subscribing to a touch event.
2259
+ *
2260
+ * @see http://www.stucox.com/blog/you-cant-detect-a-touchscreen/
2261
+ * @see https://github.com/Modernizr/Modernizr/issues/548
2262
+ */
2263
+ function getTouchSupport() {
2264
+ var n = navigator;
2265
+ var maxTouchPoints = 0;
2266
+ var touchEvent;
2267
+ if (n.maxTouchPoints !== undefined) {
2268
+ maxTouchPoints = toInt(n.maxTouchPoints);
2269
+ }
2270
+ else if (n.msMaxTouchPoints !== undefined) {
2271
+ maxTouchPoints = n.msMaxTouchPoints;
2272
+ }
2273
+ try {
2274
+ document.createEvent('TouchEvent');
2275
+ touchEvent = true;
2276
+ }
2277
+ catch (_a) {
2278
+ touchEvent = false;
2279
+ }
2280
+ var touchStart = 'ontouchstart' in window;
2281
+ return {
2282
+ maxTouchPoints: maxTouchPoints,
2283
+ touchEvent: touchEvent,
2284
+ touchStart: touchStart,
2285
+ };
2286
+ }
2287
+
2288
+ function getOsCpu() {
2289
+ return navigator.oscpu;
2290
+ }
2291
+
2292
+ function getLanguages() {
2293
+ var n = navigator;
2294
+ var result = [];
2295
+ var language = n.language || n.userLanguage || n.browserLanguage || n.systemLanguage;
2296
+ if (language !== undefined) {
2297
+ result.push([language]);
2298
+ }
2299
+ if (Array.isArray(n.languages)) {
2300
+ // Starting from Chromium 86, there is only a single value in `navigator.language` in Incognito mode:
2301
+ // the value of `navigator.language`. Therefore the value is ignored in this browser.
2302
+ if (!(isChromium() && isChromium86OrNewer())) {
2303
+ result.push(n.languages);
2304
+ }
2305
+ }
2306
+ else if (typeof n.languages === 'string') {
2307
+ var languages = n.languages;
2308
+ if (languages) {
2309
+ result.push(languages.split(','));
2310
+ }
2311
+ }
2312
+ return result;
2313
+ }
2314
+
2315
+ function getColorDepth() {
2316
+ return window.screen.colorDepth;
2317
+ }
2318
+
2319
+ function getDeviceMemory() {
2320
+ // `navigator.deviceMemory` is a string containing a number in some unidentified cases
2321
+ return replaceNaN(toFloat(navigator.deviceMemory), undefined);
2322
+ }
2323
+
2324
+ /**
2325
+ * A version of the entropy source with stabilization to make it suitable for static fingerprinting.
2326
+ * The window resolution is always the document size in private mode of Safari 17,
2327
+ * so the window resolution is not used in Safari 17.
2328
+ */
2329
+ function getScreenResolution() {
2330
+ if (isWebKit() && isWebKit616OrNewer() && isSafariWebKit()) {
2331
+ return undefined;
2332
+ }
2333
+ return getUnstableScreenResolution();
2334
+ }
2335
+ /**
2336
+ * A version of the entropy source without stabilization.
2337
+ *
2338
+ * Warning for package users:
2339
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
2340
+ */
2341
+ function getUnstableScreenResolution() {
2342
+ var s = screen;
2343
+ // Some browsers return screen resolution as strings, e.g. "1200", instead of a number, e.g. 1200.
2344
+ // I suspect it's done by certain plugins that randomize browser properties to prevent fingerprinting.
2345
+ // Some browsers even return screen resolution as not numbers.
2346
+ var parseDimension = function (value) { return replaceNaN(toInt(value), null); };
2347
+ var dimensions = [parseDimension(s.width), parseDimension(s.height)];
2348
+ dimensions.sort().reverse();
2349
+ return dimensions;
2350
+ }
2351
+
2352
+ var screenFrameCheckInterval = 2500;
2353
+ var roundingPrecision = 10;
2354
+ // The type is readonly to protect from unwanted mutations
2355
+ var screenFrameBackup;
2356
+ var screenFrameSizeTimeoutId;
2357
+ /**
2358
+ * Starts watching the screen frame size. When a non-zero size appears, the size is saved and the watch is stopped.
2359
+ * Later, when `getScreenFrame` runs, it will return the saved non-zero size if the current size is null.
2360
+ *
2361
+ * This trick is required to mitigate the fact that the screen frame turns null in some cases.
2362
+ * See more on this at https://github.com/fingerprintjs/fingerprintjs/issues/568
2363
+ */
2364
+ function watchScreenFrame() {
2365
+ if (screenFrameSizeTimeoutId !== undefined) {
2366
+ return;
2367
+ }
2368
+ var checkScreenFrame = function () {
2369
+ var frameSize = getCurrentScreenFrame();
2370
+ if (isFrameSizeNull(frameSize)) {
2371
+ screenFrameSizeTimeoutId = setTimeout(checkScreenFrame, screenFrameCheckInterval);
2372
+ }
2373
+ else {
2374
+ screenFrameBackup = frameSize;
2375
+ screenFrameSizeTimeoutId = undefined;
2376
+ }
2377
+ };
2378
+ checkScreenFrame();
2379
+ }
2380
+ /**
2381
+ * A version of the entropy source without stabilization.
2382
+ *
2383
+ * Warning for package users:
2384
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
2385
+ */
2386
+ function getUnstableScreenFrame() {
2387
+ var _this = this;
2388
+ watchScreenFrame();
2389
+ return function () { return __awaiter(_this, void 0, void 0, function () {
2390
+ var frameSize;
2391
+ return __generator(this, function (_a) {
2392
+ switch (_a.label) {
2393
+ case 0:
2394
+ frameSize = getCurrentScreenFrame();
2395
+ if (!isFrameSizeNull(frameSize)) return [3 /*break*/, 2];
2396
+ if (screenFrameBackup) {
2397
+ return [2 /*return*/, __spreadArray([], screenFrameBackup, true)];
2398
+ }
2399
+ if (!getFullscreenElement()) return [3 /*break*/, 2];
2400
+ // Some browsers set the screen frame to zero when programmatic fullscreen is on.
2401
+ // There is a chance of getting a non-zero frame after exiting the fullscreen.
2402
+ // See more on this at https://github.com/fingerprintjs/fingerprintjs/issues/568
2403
+ return [4 /*yield*/, exitFullscreen()];
2404
+ case 1:
2405
+ // Some browsers set the screen frame to zero when programmatic fullscreen is on.
2406
+ // There is a chance of getting a non-zero frame after exiting the fullscreen.
2407
+ // See more on this at https://github.com/fingerprintjs/fingerprintjs/issues/568
2408
+ _a.sent();
2409
+ frameSize = getCurrentScreenFrame();
2410
+ _a.label = 2;
2411
+ case 2:
2412
+ if (!isFrameSizeNull(frameSize)) {
2413
+ screenFrameBackup = frameSize;
2414
+ }
2415
+ return [2 /*return*/, frameSize];
2416
+ }
2417
+ });
2418
+ }); };
2419
+ }
2420
+ /**
2421
+ * A version of the entropy source with stabilization to make it suitable for static fingerprinting.
2422
+ *
2423
+ * Sometimes the available screen resolution changes a bit, e.g. 1900x1440 → 1900x1439. A possible reason: macOS Dock
2424
+ * shrinks to fit more icons when there is too little space. The rounding is used to mitigate the difference.
2425
+ *
2426
+ * The frame width is always 0 in private mode of Safari 17, so the frame is not used in Safari 17.
2427
+ */
2428
+ function getScreenFrame() {
2429
+ var _this = this;
2430
+ if (isWebKit() && isWebKit616OrNewer() && isSafariWebKit()) {
2431
+ return function () { return Promise.resolve(undefined); };
2432
+ }
2433
+ var screenFrameGetter = getUnstableScreenFrame();
2434
+ return function () { return __awaiter(_this, void 0, void 0, function () {
2435
+ var frameSize, processSize;
2436
+ return __generator(this, function (_a) {
2437
+ switch (_a.label) {
2438
+ case 0: return [4 /*yield*/, screenFrameGetter()];
2439
+ case 1:
2440
+ frameSize = _a.sent();
2441
+ processSize = function (sideSize) { return (sideSize === null ? null : round(sideSize, roundingPrecision)); };
2442
+ // It might look like I don't know about `for` and `map`.
2443
+ // In fact, such code is used to avoid TypeScript issues without using `as`.
2444
+ return [2 /*return*/, [processSize(frameSize[0]), processSize(frameSize[1]), processSize(frameSize[2]), processSize(frameSize[3])]];
2445
+ }
2446
+ });
2447
+ }); };
2448
+ }
2449
+ function getCurrentScreenFrame() {
2450
+ var s = screen;
2451
+ // Some browsers return screen resolution as strings, e.g. "1200", instead of a number, e.g. 1200.
2452
+ // I suspect it's done by certain plugins that randomize browser properties to prevent fingerprinting.
2453
+ //
2454
+ // Some browsers (IE, Edge ≤18) don't provide `screen.availLeft` and `screen.availTop`. The property values are
2455
+ // replaced with 0 in such cases to not lose the entropy from `screen.availWidth` and `screen.availHeight`.
2456
+ return [
2457
+ replaceNaN(toFloat(s.availTop), null),
2458
+ replaceNaN(toFloat(s.width) - toFloat(s.availWidth) - replaceNaN(toFloat(s.availLeft), 0), null),
2459
+ replaceNaN(toFloat(s.height) - toFloat(s.availHeight) - replaceNaN(toFloat(s.availTop), 0), null),
2460
+ replaceNaN(toFloat(s.availLeft), null),
2461
+ ];
2462
+ }
2463
+ function isFrameSizeNull(frameSize) {
2464
+ for (var i = 0; i < 4; ++i) {
2465
+ if (frameSize[i]) {
2466
+ return false;
2467
+ }
2468
+ }
2469
+ return true;
2470
+ }
2471
+
2472
+ function getHardwareConcurrency() {
2473
+ // sometimes hardware concurrency is a string
2474
+ return replaceNaN(toInt(navigator.hardwareConcurrency), undefined);
2475
+ }
2476
+
2477
+ function getTimezone() {
2478
+ var _a;
2479
+ var DateTimeFormat = (_a = window.Intl) === null || _a === void 0 ? void 0 : _a.DateTimeFormat;
2480
+ if (DateTimeFormat) {
2481
+ var timezone = new DateTimeFormat().resolvedOptions().timeZone;
2482
+ if (timezone) {
2483
+ return timezone;
2484
+ }
2485
+ }
2486
+ // For browsers that don't support timezone names
2487
+ // The minus is intentional because the JS offset is opposite to the real offset
2488
+ var offset = -getTimezoneOffset();
2489
+ return "UTC".concat(offset >= 0 ? '+' : '').concat(offset);
2490
+ }
2491
+ function getTimezoneOffset() {
2492
+ var currentYear = new Date().getFullYear();
2493
+ // The timezone offset may change over time due to daylight saving time (DST) shifts.
2494
+ // The non-DST timezone offset is used as the result timezone offset.
2495
+ // Since the DST season differs in the northern and the southern hemispheres,
2496
+ // both January and July timezones offsets are considered.
2497
+ return Math.max(
2498
+ // `getTimezoneOffset` returns a number as a string in some unidentified cases
2499
+ toFloat(new Date(currentYear, 0, 1).getTimezoneOffset()), toFloat(new Date(currentYear, 6, 1).getTimezoneOffset()));
2500
+ }
2501
+
2502
+ function getSessionStorage() {
2503
+ try {
2504
+ return !!window.sessionStorage;
2505
+ }
2506
+ catch (error) {
2507
+ /* SecurityError when referencing it means it exists */
2508
+ return true;
2509
+ }
2510
+ }
2511
+
2512
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=781447
2513
+ function getLocalStorage() {
2514
+ try {
2515
+ return !!window.localStorage;
2516
+ }
2517
+ catch (e) {
2518
+ /* SecurityError when referencing it means it exists */
2519
+ return true;
2520
+ }
2521
+ }
2522
+
2523
+ function getIndexedDB() {
2524
+ // IE and Edge don't allow accessing indexedDB in private mode, therefore IE and Edge will have different
2525
+ // visitor identifier in normal and private modes.
2526
+ if (isTrident() || isEdgeHTML()) {
2527
+ return undefined;
2528
+ }
2529
+ try {
2530
+ return !!window.indexedDB;
2531
+ }
2532
+ catch (e) {
2533
+ /* SecurityError when referencing it means it exists */
2534
+ return true;
2535
+ }
2536
+ }
2537
+
2538
+ function getOpenDatabase() {
2539
+ return !!window.openDatabase;
2540
+ }
2541
+
2542
+ function getCpuClass() {
2543
+ return navigator.cpuClass;
2544
+ }
2545
+
2546
+ function getPlatform() {
2547
+ // Android Chrome 86 and 87 and Android Firefox 80 and 84 don't mock the platform value when desktop mode is requested
2548
+ var platform = navigator.platform;
2549
+ // iOS mocks the platform value when desktop version is requested: https://github.com/fingerprintjs/fingerprintjs/issues/514
2550
+ // iPad uses desktop mode by default since iOS 13
2551
+ // The value is 'MacIntel' on M1 Macs
2552
+ // The value is 'iPhone' on iPod Touch
2553
+ if (platform === 'MacIntel') {
2554
+ if (isWebKit() && !isDesktopWebKit()) {
2555
+ return isIPad() ? 'iPad' : 'iPhone';
2556
+ }
2557
+ }
2558
+ return platform;
2559
+ }
2560
+
2561
+ function getVendor() {
2562
+ return navigator.vendor || '';
2563
+ }
2564
+
2565
+ /**
2566
+ * Checks for browser-specific (not engine specific) global variables to tell browsers with the same engine apart.
2567
+ * Only somewhat popular browsers are considered.
2568
+ */
2569
+ function getVendorFlavors() {
2570
+ var flavors = [];
2571
+ for (var _i = 0, _a = [
2572
+ // Blink and some browsers on iOS
2573
+ 'chrome',
2574
+ // Safari on macOS
2575
+ 'safari',
2576
+ // Chrome on iOS (checked in 85 on 13 and 87 on 14)
2577
+ '__crWeb',
2578
+ '__gCrWeb',
2579
+ // Yandex Browser on iOS, macOS and Android (checked in 21.2 on iOS 14, macOS and Android)
2580
+ 'yandex',
2581
+ // Yandex Browser on iOS (checked in 21.2 on 14)
2582
+ '__yb',
2583
+ '__ybro',
2584
+ // Firefox on iOS (checked in 32 on 14)
2585
+ '__firefox__',
2586
+ // Edge on iOS (checked in 46 on 14)
2587
+ '__edgeTrackingPreventionStatistics',
2588
+ 'webkit',
2589
+ // Opera Touch on iOS (checked in 2.6 on 14)
2590
+ 'oprt',
2591
+ // Samsung Internet on Android (checked in 11.1)
2592
+ 'samsungAr',
2593
+ // UC Browser on Android (checked in 12.10 and 13.0)
2594
+ 'ucweb',
2595
+ 'UCShellJava',
2596
+ // Puffin on Android (checked in 9.0)
2597
+ 'puffinDevice',
2598
+ // UC on iOS and Opera on Android have no specific global variables
2599
+ // Edge for Android isn't checked
2600
+ ]; _i < _a.length; _i++) {
2601
+ var key = _a[_i];
2602
+ var value = window[key];
2603
+ if (value && typeof value === 'object') {
2604
+ flavors.push(key);
2605
+ }
2606
+ }
2607
+ return flavors.sort();
2608
+ }
2609
+
2610
+ /**
2611
+ * navigator.cookieEnabled cannot detect custom or nuanced cookie blocking configurations. For example, when blocking
2612
+ * cookies via the Advanced Privacy Settings in IE9, it always returns true. And there have been issues in the past with
2613
+ * site-specific exceptions. Don't rely on it.
2614
+ *
2615
+ * @see https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cookies.js Taken from here
2616
+ */
2617
+ function areCookiesEnabled() {
2618
+ var d = document;
2619
+ // Taken from here: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cookies.js
2620
+ // navigator.cookieEnabled cannot detect custom or nuanced cookie blocking configurations. For example, when blocking
2621
+ // cookies via the Advanced Privacy Settings in IE9, it always returns true. And there have been issues in the past
2622
+ // with site-specific exceptions. Don't rely on it.
2623
+ // try..catch because some in situations `document.cookie` is exposed but throws a
2624
+ // SecurityError if you try to access it; e.g. documents created from data URIs
2625
+ // or in sandboxed iframes (depending on flags/context)
2626
+ try {
2627
+ // Create cookie
2628
+ d.cookie = 'cookietest=1; SameSite=Strict;';
2629
+ var result = d.cookie.indexOf('cookietest=') !== -1;
2630
+ // Delete cookie
2631
+ d.cookie = 'cookietest=1; SameSite=Strict; expires=Thu, 01-Jan-1970 00:00:01 GMT';
2632
+ return result;
2633
+ }
2634
+ catch (e) {
2635
+ return false;
2636
+ }
2637
+ }
2638
+
2639
+ /**
2640
+ * Only single element selector are supported (no operators like space, +, >, etc).
2641
+ * `embed` and `position: fixed;` will be considered as blocked anyway because it always has no offsetParent.
2642
+ * Avoid `iframe` and anything with `[src=]` because they produce excess HTTP requests.
2643
+ *
2644
+ * The "inappropriate" selectors are obfuscated. See https://github.com/fingerprintjs/fingerprintjs/issues/734.
2645
+ * A function is used instead of a plain object to help tree-shaking.
2646
+ *
2647
+ * The function code is generated automatically. See docs/content_blockers.md to learn how to make the list.
2648
+ */
2649
+ function getFilters() {
2650
+ var fromB64 = atob; // Just for better minification
2651
+ return {
2652
+ abpIndo: [
2653
+ '#Iklan-Melayang',
2654
+ '#Kolom-Iklan-728',
2655
+ '#SidebarIklan-wrapper',
2656
+ '[title="ALIENBOLA" i]',
2657
+ fromB64('I0JveC1CYW5uZXItYWRz'),
2658
+ ],
2659
+ abpvn: ['.quangcao', '#mobileCatfish', fromB64('LmNsb3NlLWFkcw=='), '[id^="bn_bottom_fixed_"]', '#pmadv'],
2660
+ adBlockFinland: [
2661
+ '.mainostila',
2662
+ fromB64('LnNwb25zb3JpdA=='),
2663
+ '.ylamainos',
2664
+ fromB64('YVtocmVmKj0iL2NsaWNrdGhyZ2guYXNwPyJd'),
2665
+ fromB64('YVtocmVmXj0iaHR0cHM6Ly9hcHAucmVhZHBlYWsuY29tL2FkcyJd'),
2666
+ ],
2667
+ adBlockPersian: [
2668
+ '#navbar_notice_50',
2669
+ '.kadr',
2670
+ 'TABLE[width="140px"]',
2671
+ '#divAgahi',
2672
+ fromB64('YVtocmVmXj0iaHR0cDovL2cxLnYuZndtcm0ubmV0L2FkLyJd'),
2673
+ ],
2674
+ adBlockWarningRemoval: [
2675
+ '#adblock-honeypot',
2676
+ '.adblocker-root',
2677
+ '.wp_adblock_detect',
2678
+ fromB64('LmhlYWRlci1ibG9ja2VkLWFk'),
2679
+ fromB64('I2FkX2Jsb2NrZXI='),
2680
+ ],
2681
+ adGuardAnnoyances: [
2682
+ '.hs-sosyal',
2683
+ '#cookieconsentdiv',
2684
+ 'div[class^="app_gdpr"]',
2685
+ '.as-oil',
2686
+ '[data-cypress="soft-push-notification-modal"]',
2687
+ ],
2688
+ adGuardBase: [
2689
+ '.BetterJsPopOverlay',
2690
+ fromB64('I2FkXzMwMFgyNTA='),
2691
+ fromB64('I2Jhbm5lcmZsb2F0MjI='),
2692
+ fromB64('I2NhbXBhaWduLWJhbm5lcg=='),
2693
+ fromB64('I0FkLUNvbnRlbnQ='),
2694
+ ],
2695
+ adGuardChinese: [
2696
+ fromB64('LlppX2FkX2FfSA=='),
2697
+ fromB64('YVtocmVmKj0iLmh0aGJldDM0LmNvbSJd'),
2698
+ '#widget-quan',
2699
+ fromB64('YVtocmVmKj0iLzg0OTkyMDIwLnh5eiJd'),
2700
+ fromB64('YVtocmVmKj0iLjE5NTZobC5jb20vIl0='),
2701
+ ],
2702
+ adGuardFrench: [
2703
+ '#pavePub',
2704
+ fromB64('LmFkLWRlc2t0b3AtcmVjdGFuZ2xl'),
2705
+ '.mobile_adhesion',
2706
+ '.widgetadv',
2707
+ fromB64('LmFkc19iYW4='),
2708
+ ],
2709
+ adGuardGerman: ['aside[data-portal-id="leaderboard"]'],
2710
+ adGuardJapanese: [
2711
+ '#kauli_yad_1',
2712
+ fromB64('YVtocmVmXj0iaHR0cDovL2FkMi50cmFmZmljZ2F0ZS5uZXQvIl0='),
2713
+ fromB64('Ll9wb3BJbl9pbmZpbml0ZV9hZA=='),
2714
+ fromB64('LmFkZ29vZ2xl'),
2715
+ fromB64('Ll9faXNib29zdFJldHVybkFk'),
2716
+ ],
2717
+ adGuardMobile: [
2718
+ fromB64('YW1wLWF1dG8tYWRz'),
2719
+ fromB64('LmFtcF9hZA=='),
2720
+ 'amp-embed[type="24smi"]',
2721
+ '#mgid_iframe1',
2722
+ fromB64('I2FkX2ludmlld19hcmVh'),
2723
+ ],
2724
+ adGuardRussian: [
2725
+ fromB64('YVtocmVmXj0iaHR0cHM6Ly9hZC5sZXRtZWFkcy5jb20vIl0='),
2726
+ fromB64('LnJlY2xhbWE='),
2727
+ 'div[id^="smi2adblock"]',
2728
+ fromB64('ZGl2W2lkXj0iQWRGb3hfYmFubmVyXyJd'),
2729
+ '#psyduckpockeball',
2730
+ ],
2731
+ adGuardSocial: [
2732
+ fromB64('YVtocmVmXj0iLy93d3cuc3R1bWJsZXVwb24uY29tL3N1Ym1pdD91cmw9Il0='),
2733
+ fromB64('YVtocmVmXj0iLy90ZWxlZ3JhbS5tZS9zaGFyZS91cmw/Il0='),
2734
+ '.etsy-tweet',
2735
+ '#inlineShare',
2736
+ '.popup-social',
2737
+ ],
2738
+ adGuardSpanishPortuguese: ['#barraPublicidade', '#Publicidade', '#publiEspecial', '#queTooltip', '.cnt-publi'],
2739
+ adGuardTrackingProtection: [
2740
+ '#qoo-counter',
2741
+ fromB64('YVtocmVmXj0iaHR0cDovL2NsaWNrLmhvdGxvZy5ydS8iXQ=='),
2742
+ fromB64('YVtocmVmXj0iaHR0cDovL2hpdGNvdW50ZXIucnUvdG9wL3N0YXQucGhwIl0='),
2743
+ fromB64('YVtocmVmXj0iaHR0cDovL3RvcC5tYWlsLnJ1L2p1bXAiXQ=='),
2744
+ '#top100counter',
2745
+ ],
2746
+ adGuardTurkish: [
2747
+ '#backkapat',
2748
+ fromB64('I3Jla2xhbWk='),
2749
+ fromB64('YVtocmVmXj0iaHR0cDovL2Fkc2Vydi5vbnRlay5jb20udHIvIl0='),
2750
+ fromB64('YVtocmVmXj0iaHR0cDovL2l6bGVuemkuY29tL2NhbXBhaWduLyJd'),
2751
+ fromB64('YVtocmVmXj0iaHR0cDovL3d3dy5pbnN0YWxsYWRzLm5ldC8iXQ=='),
2752
+ ],
2753
+ bulgarian: [fromB64('dGQjZnJlZW5ldF90YWJsZV9hZHM='), '#ea_intext_div', '.lapni-pop-over', '#xenium_hot_offers'],
2754
+ easyList: [
2755
+ '.yb-floorad',
2756
+ fromB64('LndpZGdldF9wb19hZHNfd2lkZ2V0'),
2757
+ fromB64('LnRyYWZmaWNqdW5reS1hZA=='),
2758
+ '.textad_headline',
2759
+ fromB64('LnNwb25zb3JlZC10ZXh0LWxpbmtz'),
2760
+ ],
2761
+ easyListChina: [
2762
+ fromB64('LmFwcGd1aWRlLXdyYXBbb25jbGljayo9ImJjZWJvcy5jb20iXQ=='),
2763
+ fromB64('LmZyb250cGFnZUFkdk0='),
2764
+ '#taotaole',
2765
+ '#aafoot.top_box',
2766
+ '.cfa_popup',
2767
+ ],
2768
+ easyListCookie: [
2769
+ '.ezmob-footer',
2770
+ '.cc-CookieWarning',
2771
+ '[data-cookie-number]',
2772
+ fromB64('LmF3LWNvb2tpZS1iYW5uZXI='),
2773
+ '.sygnal24-gdpr-modal-wrap',
2774
+ ],
2775
+ easyListCzechSlovak: [
2776
+ '#onlajny-stickers',
2777
+ fromB64('I3Jla2xhbW5pLWJveA=='),
2778
+ fromB64('LnJla2xhbWEtbWVnYWJvYXJk'),
2779
+ '.sklik',
2780
+ fromB64('W2lkXj0ic2tsaWtSZWtsYW1hIl0='),
2781
+ ],
2782
+ easyListDutch: [
2783
+ fromB64('I2FkdmVydGVudGll'),
2784
+ fromB64('I3ZpcEFkbWFya3RCYW5uZXJCbG9jaw=='),
2785
+ '.adstekst',
2786
+ fromB64('YVtocmVmXj0iaHR0cHM6Ly94bHR1YmUubmwvY2xpY2svIl0='),
2787
+ '#semilo-lrectangle',
2788
+ ],
2789
+ easyListGermany: [
2790
+ '#SSpotIMPopSlider',
2791
+ fromB64('LnNwb25zb3JsaW5rZ3J1ZW4='),
2792
+ fromB64('I3dlcmJ1bmdza3k='),
2793
+ fromB64('I3Jla2xhbWUtcmVjaHRzLW1pdHRl'),
2794
+ fromB64('YVtocmVmXj0iaHR0cHM6Ly9iZDc0Mi5jb20vIl0='),
2795
+ ],
2796
+ easyListItaly: [
2797
+ fromB64('LmJveF9hZHZfYW5udW5jaQ=='),
2798
+ '.sb-box-pubbliredazionale',
2799
+ fromB64('YVtocmVmXj0iaHR0cDovL2FmZmlsaWF6aW9uaWFkcy5zbmFpLml0LyJd'),
2800
+ fromB64('YVtocmVmXj0iaHR0cHM6Ly9hZHNlcnZlci5odG1sLml0LyJd'),
2801
+ fromB64('YVtocmVmXj0iaHR0cHM6Ly9hZmZpbGlhemlvbmlhZHMuc25haS5pdC8iXQ=='),
2802
+ ],
2803
+ easyListLithuania: [
2804
+ fromB64('LnJla2xhbW9zX3RhcnBhcw=='),
2805
+ fromB64('LnJla2xhbW9zX251b3JvZG9z'),
2806
+ fromB64('aW1nW2FsdD0iUmVrbGFtaW5pcyBza3lkZWxpcyJd'),
2807
+ fromB64('aW1nW2FsdD0iRGVkaWt1b3RpLmx0IHNlcnZlcmlhaSJd'),
2808
+ fromB64('aW1nW2FsdD0iSG9zdGluZ2FzIFNlcnZlcmlhaS5sdCJd'),
2809
+ ],
2810
+ estonian: [fromB64('QVtocmVmKj0iaHR0cDovL3BheTRyZXN1bHRzMjQuZXUiXQ==')],
2811
+ fanboyAnnoyances: ['#ac-lre-player', '.navigate-to-top', '#subscribe_popup', '.newsletter_holder', '#back-top'],
2812
+ fanboyAntiFacebook: ['.util-bar-module-firefly-visible'],
2813
+ fanboyEnhancedTrackers: [
2814
+ '.open.pushModal',
2815
+ '#issuem-leaky-paywall-articles-zero-remaining-nag',
2816
+ '#sovrn_container',
2817
+ 'div[class$="-hide"][zoompage-fontsize][style="display: block;"]',
2818
+ '.BlockNag__Card',
2819
+ ],
2820
+ fanboySocial: ['#FollowUs', '#meteored_share', '#social_follow', '.article-sharer', '.community__social-desc'],
2821
+ frellwitSwedish: [
2822
+ fromB64('YVtocmVmKj0iY2FzaW5vcHJvLnNlIl1bdGFyZ2V0PSJfYmxhbmsiXQ=='),
2823
+ fromB64('YVtocmVmKj0iZG9rdG9yLXNlLm9uZWxpbmsubWUiXQ=='),
2824
+ 'article.category-samarbete',
2825
+ fromB64('ZGl2LmhvbGlkQWRz'),
2826
+ 'ul.adsmodern',
2827
+ ],
2828
+ greekAdBlock: [
2829
+ fromB64('QVtocmVmKj0iYWRtYW4ub3RlbmV0LmdyL2NsaWNrPyJd'),
2830
+ fromB64('QVtocmVmKj0iaHR0cDovL2F4aWFiYW5uZXJzLmV4b2R1cy5nci8iXQ=='),
2831
+ fromB64('QVtocmVmKj0iaHR0cDovL2ludGVyYWN0aXZlLmZvcnRobmV0LmdyL2NsaWNrPyJd'),
2832
+ 'DIV.agores300',
2833
+ 'TABLE.advright',
2834
+ ],
2835
+ hungarian: [
2836
+ '#cemp_doboz',
2837
+ '.optimonk-iframe-container',
2838
+ fromB64('LmFkX19tYWlu'),
2839
+ fromB64('W2NsYXNzKj0iR29vZ2xlQWRzIl0='),
2840
+ '#hirdetesek_box',
2841
+ ],
2842
+ iDontCareAboutCookies: [
2843
+ '.alert-info[data-block-track*="CookieNotice"]',
2844
+ '.ModuleTemplateCookieIndicator',
2845
+ '.o--cookies--container',
2846
+ '#cookies-policy-sticky',
2847
+ '#stickyCookieBar',
2848
+ ],
2849
+ icelandicAbp: [fromB64('QVtocmVmXj0iL2ZyYW1ld29yay9yZXNvdXJjZXMvZm9ybXMvYWRzLmFzcHgiXQ==')],
2850
+ latvian: [
2851
+ fromB64('YVtocmVmPSJodHRwOi8vd3d3LnNhbGlkemluaS5sdi8iXVtzdHlsZT0iZGlzcGxheTogYmxvY2s7IHdpZHRoOiAxMjBweDsgaGVpZ2h0O' +
2852
+ 'iA0MHB4OyBvdmVyZmxvdzogaGlkZGVuOyBwb3NpdGlvbjogcmVsYXRpdmU7Il0='),
2853
+ fromB64('YVtocmVmPSJodHRwOi8vd3d3LnNhbGlkemluaS5sdi8iXVtzdHlsZT0iZGlzcGxheTogYmxvY2s7IHdpZHRoOiA4OHB4OyBoZWlnaHQ6I' +
2854
+ 'DMxcHg7IG92ZXJmbG93OiBoaWRkZW47IHBvc2l0aW9uOiByZWxhdGl2ZTsiXQ=='),
2855
+ ],
2856
+ listKr: [
2857
+ fromB64('YVtocmVmKj0iLy9hZC5wbGFuYnBsdXMuY28ua3IvIl0='),
2858
+ fromB64('I2xpdmVyZUFkV3JhcHBlcg=='),
2859
+ fromB64('YVtocmVmKj0iLy9hZHYuaW1hZHJlcC5jby5rci8iXQ=='),
2860
+ fromB64('aW5zLmZhc3R2aWV3LWFk'),
2861
+ '.revenue_unit_item.dable',
2862
+ ],
2863
+ listeAr: [
2864
+ fromB64('LmdlbWluaUxCMUFk'),
2865
+ '.right-and-left-sponsers',
2866
+ fromB64('YVtocmVmKj0iLmFmbGFtLmluZm8iXQ=='),
2867
+ fromB64('YVtocmVmKj0iYm9vcmFxLm9yZyJd'),
2868
+ fromB64('YVtocmVmKj0iZHViaXp6bGUuY29tL2FyLz91dG1fc291cmNlPSJd'),
2869
+ ],
2870
+ listeFr: [
2871
+ fromB64('YVtocmVmXj0iaHR0cDovL3Byb21vLnZhZG9yLmNvbS8iXQ=='),
2872
+ fromB64('I2FkY29udGFpbmVyX3JlY2hlcmNoZQ=='),
2873
+ fromB64('YVtocmVmKj0id2Vib3JhbWEuZnIvZmNnaS1iaW4vIl0='),
2874
+ '.site-pub-interstitiel',
2875
+ 'div[id^="crt-"][data-criteo-id]',
2876
+ ],
2877
+ officialPolish: [
2878
+ '#ceneo-placeholder-ceneo-12',
2879
+ fromB64('W2hyZWZePSJodHRwczovL2FmZi5zZW5kaHViLnBsLyJd'),
2880
+ fromB64('YVtocmVmXj0iaHR0cDovL2Fkdm1hbmFnZXIudGVjaGZ1bi5wbC9yZWRpcmVjdC8iXQ=='),
2881
+ fromB64('YVtocmVmXj0iaHR0cDovL3d3dy50cml6ZXIucGwvP3V0bV9zb3VyY2UiXQ=='),
2882
+ fromB64('ZGl2I3NrYXBpZWNfYWQ='),
2883
+ ],
2884
+ ro: [
2885
+ fromB64('YVtocmVmXj0iLy9hZmZ0cmsuYWx0ZXgucm8vQ291bnRlci9DbGljayJd'),
2886
+ fromB64('YVtocmVmXj0iaHR0cHM6Ly9ibGFja2ZyaWRheXNhbGVzLnJvL3Ryay9zaG9wLyJd'),
2887
+ fromB64('YVtocmVmXj0iaHR0cHM6Ly9ldmVudC4ycGVyZm9ybWFudC5jb20vZXZlbnRzL2NsaWNrIl0='),
2888
+ fromB64('YVtocmVmXj0iaHR0cHM6Ly9sLnByb2ZpdHNoYXJlLnJvLyJd'),
2889
+ 'a[href^="/url/"]',
2890
+ ],
2891
+ ruAd: [
2892
+ fromB64('YVtocmVmKj0iLy9mZWJyYXJlLnJ1LyJd'),
2893
+ fromB64('YVtocmVmKj0iLy91dGltZy5ydS8iXQ=='),
2894
+ fromB64('YVtocmVmKj0iOi8vY2hpa2lkaWtpLnJ1Il0='),
2895
+ '#pgeldiz',
2896
+ '.yandex-rtb-block',
2897
+ ],
2898
+ thaiAds: [
2899
+ 'a[href*=macau-uta-popup]',
2900
+ fromB64('I2Fkcy1nb29nbGUtbWlkZGxlX3JlY3RhbmdsZS1ncm91cA=='),
2901
+ fromB64('LmFkczMwMHM='),
2902
+ '.bumq',
2903
+ '.img-kosana',
2904
+ ],
2905
+ webAnnoyancesUltralist: [
2906
+ '#mod-social-share-2',
2907
+ '#social-tools',
2908
+ fromB64('LmN0cGwtZnVsbGJhbm5lcg=='),
2909
+ '.zergnet-recommend',
2910
+ '.yt.btn-link.btn-md.btn',
2911
+ ],
2912
+ };
2913
+ }
2914
+ /**
2915
+ * The order of the returned array means nothing (it's always sorted alphabetically).
2916
+ *
2917
+ * Notice that the source is slightly unstable.
2918
+ * Safari provides a 2-taps way to disable all content blockers on a page temporarily.
2919
+ * Also content blockers can be disabled permanently for a domain, but it requires 4 taps.
2920
+ * So empty array shouldn't be treated as "no blockers", it should be treated as "no signal".
2921
+ * If you are a website owner, don't make your visitors want to disable content blockers.
2922
+ */
2923
+ function getDomBlockers(_a) {
2924
+ var _b = _a === void 0 ? {} : _a, debug = _b.debug;
2925
+ return __awaiter(this, void 0, void 0, function () {
2926
+ var filters, filterNames, allSelectors, blockedSelectors, activeBlockers;
2927
+ var _c;
2928
+ return __generator(this, function (_d) {
2929
+ switch (_d.label) {
2930
+ case 0:
2931
+ if (!isApplicable()) {
2932
+ return [2 /*return*/, undefined];
2933
+ }
2934
+ filters = getFilters();
2935
+ filterNames = Object.keys(filters);
2936
+ allSelectors = (_c = []).concat.apply(_c, filterNames.map(function (filterName) { return filters[filterName]; }));
2937
+ return [4 /*yield*/, getBlockedSelectors(allSelectors)];
2938
+ case 1:
2939
+ blockedSelectors = _d.sent();
2940
+ if (debug) {
2941
+ printDebug(filters, blockedSelectors);
2942
+ }
2943
+ activeBlockers = filterNames.filter(function (filterName) {
2944
+ var selectors = filters[filterName];
2945
+ var blockedCount = countTruthy(selectors.map(function (selector) { return blockedSelectors[selector]; }));
2946
+ return blockedCount > selectors.length * 0.6;
2947
+ });
2948
+ activeBlockers.sort();
2949
+ return [2 /*return*/, activeBlockers];
2950
+ }
2951
+ });
2952
+ });
2953
+ }
2954
+ function isApplicable() {
2955
+ // Safari (desktop and mobile) and all Android browsers keep content blockers in both regular and private mode
2956
+ return isWebKit() || isAndroid();
2957
+ }
2958
+ function getBlockedSelectors(selectors) {
2959
+ var _a;
2960
+ return __awaiter(this, void 0, void 0, function () {
2961
+ var d, root, elements, blockedSelectors, i, element, holder, i;
2962
+ return __generator(this, function (_b) {
2963
+ switch (_b.label) {
2964
+ case 0:
2965
+ d = document;
2966
+ root = d.createElement('div');
2967
+ elements = new Array(selectors.length);
2968
+ blockedSelectors = {} // Set() isn't used just in case somebody need older browser support
2969
+ ;
2970
+ forceShow(root);
2971
+ // First create all elements that can be blocked. If the DOM steps below are done in a single cycle,
2972
+ // browser will alternate tree modification and layout reading, that is very slow.
2973
+ for (i = 0; i < selectors.length; ++i) {
2974
+ element = selectorToElement(selectors[i]);
2975
+ if (element.tagName === 'DIALOG') {
2976
+ element.show();
2977
+ }
2978
+ holder = d.createElement('div') // Protects from unwanted effects of `+` and `~` selectors of filters
2979
+ ;
2980
+ forceShow(holder);
2981
+ holder.appendChild(element);
2982
+ root.appendChild(holder);
2983
+ elements[i] = element;
2984
+ }
2985
+ _b.label = 1;
2986
+ case 1:
2987
+ if (!!d.body) return [3 /*break*/, 3];
2988
+ return [4 /*yield*/, wait(50)];
2989
+ case 2:
2990
+ _b.sent();
2991
+ return [3 /*break*/, 1];
2992
+ case 3:
2993
+ d.body.appendChild(root);
2994
+ try {
2995
+ // Then check which of the elements are blocked
2996
+ for (i = 0; i < selectors.length; ++i) {
2997
+ if (!elements[i].offsetParent) {
2998
+ blockedSelectors[selectors[i]] = true;
2999
+ }
3000
+ }
3001
+ }
3002
+ finally {
3003
+ // Then remove the elements
3004
+ (_a = root.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(root);
3005
+ }
3006
+ return [2 /*return*/, blockedSelectors];
3007
+ }
3008
+ });
3009
+ });
3010
+ }
3011
+ function forceShow(element) {
3012
+ element.style.setProperty('visibility', 'hidden', 'important');
3013
+ element.style.setProperty('display', 'block', 'important');
3014
+ }
3015
+ function printDebug(filters, blockedSelectors) {
3016
+ var message = 'DOM blockers debug:\n```';
3017
+ for (var _i = 0, _a = Object.keys(filters); _i < _a.length; _i++) {
3018
+ var filterName = _a[_i];
3019
+ message += "\n".concat(filterName, ":");
3020
+ for (var _b = 0, _c = filters[filterName]; _b < _c.length; _b++) {
3021
+ var selector = _c[_b];
3022
+ message += "\n ".concat(blockedSelectors[selector] ? '🚫' : '➡️', " ").concat(selector);
3023
+ }
3024
+ }
3025
+ // console.log is ok here because it's under a debug clause
3026
+ // eslint-disable-next-line no-console
3027
+ console.log("".concat(message, "\n```"));
3028
+ }
3029
+
3030
+ /**
3031
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/color-gamut
3032
+ */
3033
+ function getColorGamut() {
3034
+ // rec2020 includes p3 and p3 includes srgb
3035
+ for (var _i = 0, _a = ['rec2020', 'p3', 'srgb']; _i < _a.length; _i++) {
3036
+ var gamut = _a[_i];
3037
+ if (matchMedia("(color-gamut: ".concat(gamut, ")")).matches) {
3038
+ return gamut;
3039
+ }
3040
+ }
3041
+ return undefined;
3042
+ }
3043
+
3044
+ /**
3045
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/inverted-colors
3046
+ */
3047
+ function areColorsInverted() {
3048
+ if (doesMatch$5('inverted')) {
3049
+ return true;
3050
+ }
3051
+ if (doesMatch$5('none')) {
3052
+ return false;
3053
+ }
3054
+ return undefined;
3055
+ }
3056
+ function doesMatch$5(value) {
3057
+ return matchMedia("(inverted-colors: ".concat(value, ")")).matches;
3058
+ }
3059
+
3060
+ /**
3061
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/forced-colors
3062
+ */
3063
+ function areColorsForced() {
3064
+ if (doesMatch$4('active')) {
3065
+ return true;
3066
+ }
3067
+ if (doesMatch$4('none')) {
3068
+ return false;
3069
+ }
3070
+ return undefined;
3071
+ }
3072
+ function doesMatch$4(value) {
3073
+ return matchMedia("(forced-colors: ".concat(value, ")")).matches;
3074
+ }
3075
+
3076
+ var maxValueToCheck = 100;
3077
+ /**
3078
+ * If the display is monochrome (e.g. black&white), the value will be ≥0 and will mean the number of bits per pixel.
3079
+ * If the display is not monochrome, the returned value will be 0.
3080
+ * If the browser doesn't support this feature, the returned value will be undefined.
3081
+ *
3082
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/monochrome
3083
+ */
3084
+ function getMonochromeDepth() {
3085
+ if (!matchMedia('(min-monochrome: 0)').matches) {
3086
+ // The media feature isn't supported by the browser
3087
+ return undefined;
3088
+ }
3089
+ // A variation of binary search algorithm can be used here.
3090
+ // But since expected values are very small (≤10), there is no sense in adding the complexity.
3091
+ for (var i = 0; i <= maxValueToCheck; ++i) {
3092
+ if (matchMedia("(max-monochrome: ".concat(i, ")")).matches) {
3093
+ return i;
3094
+ }
3095
+ }
3096
+ throw new Error('Too high value');
3097
+ }
3098
+
3099
+ /**
3100
+ * @see https://www.w3.org/TR/mediaqueries-5/#prefers-contrast
3101
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-contrast
3102
+ */
3103
+ function getContrastPreference() {
3104
+ if (doesMatch$3('no-preference')) {
3105
+ return 0 /* ContrastPreference.None */;
3106
+ }
3107
+ // The sources contradict on the keywords. Probably 'high' and 'low' will never be implemented.
3108
+ // Need to check it when all browsers implement the feature.
3109
+ if (doesMatch$3('high') || doesMatch$3('more')) {
3110
+ return 1 /* ContrastPreference.More */;
3111
+ }
3112
+ if (doesMatch$3('low') || doesMatch$3('less')) {
3113
+ return -1 /* ContrastPreference.Less */;
3114
+ }
3115
+ if (doesMatch$3('forced')) {
3116
+ return 10 /* ContrastPreference.ForcedColors */;
3117
+ }
3118
+ return undefined;
3119
+ }
3120
+ function doesMatch$3(value) {
3121
+ return matchMedia("(prefers-contrast: ".concat(value, ")")).matches;
3122
+ }
3123
+
3124
+ /**
3125
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion
3126
+ */
3127
+ function isMotionReduced() {
3128
+ if (doesMatch$2('reduce')) {
3129
+ return true;
3130
+ }
3131
+ if (doesMatch$2('no-preference')) {
3132
+ return false;
3133
+ }
3134
+ return undefined;
3135
+ }
3136
+ function doesMatch$2(value) {
3137
+ return matchMedia("(prefers-reduced-motion: ".concat(value, ")")).matches;
3138
+ }
3139
+
3140
+ /**
3141
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-transparency
3142
+ */
3143
+ function isTransparencyReduced() {
3144
+ if (doesMatch$1('reduce')) {
3145
+ return true;
3146
+ }
3147
+ if (doesMatch$1('no-preference')) {
3148
+ return false;
3149
+ }
3150
+ return undefined;
3151
+ }
3152
+ function doesMatch$1(value) {
3153
+ return matchMedia("(prefers-reduced-transparency: ".concat(value, ")")).matches;
3154
+ }
3155
+
3156
+ /**
3157
+ * @see https://www.w3.org/TR/mediaqueries-5/#dynamic-range
3158
+ */
3159
+ function isHDR() {
3160
+ if (doesMatch('high')) {
3161
+ return true;
3162
+ }
3163
+ if (doesMatch('standard')) {
3164
+ return false;
3165
+ }
3166
+ return undefined;
3167
+ }
3168
+ function doesMatch(value) {
3169
+ return matchMedia("(dynamic-range: ".concat(value, ")")).matches;
3170
+ }
3171
+
3172
+ var M = Math; // To reduce the minified code size
3173
+ var fallbackFn = function () { return 0; };
3174
+ /**
3175
+ * @see https://gitlab.torproject.org/legacy/trac/-/issues/13018
3176
+ * @see https://bugzilla.mozilla.org/show_bug.cgi?id=531915
3177
+ */
3178
+ function getMathFingerprint() {
3179
+ // Native operations
3180
+ var acos = M.acos || fallbackFn;
3181
+ var acosh = M.acosh || fallbackFn;
3182
+ var asin = M.asin || fallbackFn;
3183
+ var asinh = M.asinh || fallbackFn;
3184
+ var atanh = M.atanh || fallbackFn;
3185
+ var atan = M.atan || fallbackFn;
3186
+ var sin = M.sin || fallbackFn;
3187
+ var sinh = M.sinh || fallbackFn;
3188
+ var cos = M.cos || fallbackFn;
3189
+ var cosh = M.cosh || fallbackFn;
3190
+ var tan = M.tan || fallbackFn;
3191
+ var tanh = M.tanh || fallbackFn;
3192
+ var exp = M.exp || fallbackFn;
3193
+ var expm1 = M.expm1 || fallbackFn;
3194
+ var log1p = M.log1p || fallbackFn;
3195
+ // Operation polyfills
3196
+ var powPI = function (value) { return M.pow(M.PI, value); };
3197
+ var acoshPf = function (value) { return M.log(value + M.sqrt(value * value - 1)); };
3198
+ var asinhPf = function (value) { return M.log(value + M.sqrt(value * value + 1)); };
3199
+ var atanhPf = function (value) { return M.log((1 + value) / (1 - value)) / 2; };
3200
+ var sinhPf = function (value) { return M.exp(value) - 1 / M.exp(value) / 2; };
3201
+ var coshPf = function (value) { return (M.exp(value) + 1 / M.exp(value)) / 2; };
3202
+ var expm1Pf = function (value) { return M.exp(value) - 1; };
3203
+ var tanhPf = function (value) { return (M.exp(2 * value) - 1) / (M.exp(2 * value) + 1); };
3204
+ var log1pPf = function (value) { return M.log(1 + value); };
3205
+ // Note: constant values are empirical
3206
+ return {
3207
+ acos: acos(0.123124234234234242),
3208
+ acosh: acosh(1e308),
3209
+ acoshPf: acoshPf(1e154),
3210
+ asin: asin(0.123124234234234242),
3211
+ asinh: asinh(1),
3212
+ asinhPf: asinhPf(1),
3213
+ atanh: atanh(0.5),
3214
+ atanhPf: atanhPf(0.5),
3215
+ atan: atan(0.5),
3216
+ sin: sin(-1e300),
3217
+ sinh: sinh(1),
3218
+ sinhPf: sinhPf(1),
3219
+ cos: cos(10.000000000123),
3220
+ cosh: cosh(1),
3221
+ coshPf: coshPf(1),
3222
+ tan: tan(-1e300),
3223
+ tanh: tanh(1),
3224
+ tanhPf: tanhPf(1),
3225
+ exp: exp(1),
3226
+ expm1: expm1(1),
3227
+ expm1Pf: expm1Pf(1),
3228
+ log1p: log1p(10),
3229
+ log1pPf: log1pPf(10),
3230
+ powPI: powPI(-100),
3231
+ };
3232
+ }
3233
+
3234
+ /**
3235
+ * We use m or w because these two characters take up the maximum width.
3236
+ * Also there are a couple of ligatures.
3237
+ */
3238
+ var defaultText = 'mmMwWLliI0fiflO&1';
3239
+ /**
3240
+ * Settings of text blocks to measure. The keys are random but persistent words.
3241
+ */
3242
+ var presets = {
3243
+ /**
3244
+ * The default font. User can change it in desktop Chrome, desktop Firefox, IE 11,
3245
+ * Android Chrome (but only when the size is ≥ than the default) and Android Firefox.
3246
+ */
3247
+ default: [],
3248
+ /** OS font on macOS. User can change its size and weight. Applies after Safari restart. */
3249
+ apple: [{ font: '-apple-system-body' }],
3250
+ /** User can change it in desktop Chrome and desktop Firefox. */
3251
+ serif: [{ fontFamily: 'serif' }],
3252
+ /** User can change it in desktop Chrome and desktop Firefox. */
3253
+ sans: [{ fontFamily: 'sans-serif' }],
3254
+ /** User can change it in desktop Chrome and desktop Firefox. */
3255
+ mono: [{ fontFamily: 'monospace' }],
3256
+ /**
3257
+ * Check the smallest allowed font size. User can change it in desktop Chrome, desktop Firefox and desktop Safari.
3258
+ * The height can be 0 in Chrome on a retina display.
3259
+ */
3260
+ min: [{ fontSize: '1px' }],
3261
+ /** Tells one OS from another in desktop Chrome. */
3262
+ system: [{ fontFamily: 'system-ui' }],
3263
+ };
3264
+ /**
3265
+ * The result is a dictionary of the width of the text samples.
3266
+ * Heights aren't included because they give no extra entropy and are unstable.
3267
+ *
3268
+ * The result is very stable in IE 11, Edge 18 and Safari 14.
3269
+ * The result changes when the OS pixel density changes in Chromium 87. The real pixel density is required to solve,
3270
+ * but seems like it's impossible: https://stackoverflow.com/q/1713771/1118709.
3271
+ * The "min" and the "mono" (only on Windows) value may change when the page is zoomed in Firefox 87.
3272
+ */
3273
+ function getFontPreferences() {
3274
+ return withNaturalFonts(function (document, container) {
3275
+ var elements = {};
3276
+ var sizes = {};
3277
+ // First create all elements to measure. If the DOM steps below are done in a single cycle,
3278
+ // browser will alternate tree modification and layout reading, that is very slow.
3279
+ for (var _i = 0, _a = Object.keys(presets); _i < _a.length; _i++) {
3280
+ var key = _a[_i];
3281
+ var _b = presets[key], _c = _b[0], style = _c === void 0 ? {} : _c, _d = _b[1], text = _d === void 0 ? defaultText : _d;
3282
+ var element = document.createElement('span');
3283
+ element.textContent = text;
3284
+ element.style.whiteSpace = 'nowrap';
3285
+ for (var _e = 0, _f = Object.keys(style); _e < _f.length; _e++) {
3286
+ var name_1 = _f[_e];
3287
+ var value = style[name_1];
3288
+ if (value !== undefined) {
3289
+ element.style[name_1] = value;
3290
+ }
3291
+ }
3292
+ elements[key] = element;
3293
+ container.append(document.createElement('br'), element);
3294
+ }
3295
+ // Then measure the created elements
3296
+ for (var _g = 0, _h = Object.keys(presets); _g < _h.length; _g++) {
3297
+ var key = _h[_g];
3298
+ sizes[key] = elements[key].getBoundingClientRect().width;
3299
+ }
3300
+ return sizes;
3301
+ });
3302
+ }
3303
+ /**
3304
+ * Creates a DOM environment that provides the most natural font available, including Android OS font.
3305
+ * Measurements of the elements are zoom-independent.
3306
+ * Don't put a content to measure inside an absolutely positioned element.
3307
+ */
3308
+ function withNaturalFonts(action, containerWidthPx) {
3309
+ if (containerWidthPx === void 0) { containerWidthPx = 4000; }
3310
+ /*
3311
+ * Requirements for Android Chrome to apply the system font size to a text inside an iframe:
3312
+ * - The iframe mustn't have a `display: none;` style;
3313
+ * - The text mustn't be positioned absolutely;
3314
+ * - The text block must be wide enough.
3315
+ * 2560px on some devices in portrait orientation for the biggest font size option (32px);
3316
+ * - There must be much enough text to form a few lines (I don't know the exact numbers);
3317
+ * - The text must have the `text-size-adjust: none` style. Otherwise the text will scale in "Desktop site" mode;
3318
+ *
3319
+ * Requirements for Android Firefox to apply the system font size to a text inside an iframe:
3320
+ * - The iframe document must have a header: `<meta name="viewport" content="width=device-width, initial-scale=1" />`.
3321
+ * The only way to set it is to use the `srcdoc` attribute of the iframe;
3322
+ * - The iframe content must get loaded before adding extra content with JavaScript;
3323
+ *
3324
+ * https://example.com as the iframe target always inherits Android font settings so it can be used as a reference.
3325
+ *
3326
+ * Observations on how page zoom affects the measurements:
3327
+ * - macOS Safari 11.1, 12.1, 13.1, 14.0: zoom reset + offsetWidth = 100% reliable;
3328
+ * - macOS Safari 11.1, 12.1, 13.1, 14.0: zoom reset + getBoundingClientRect = 100% reliable;
3329
+ * - macOS Safari 14.0: offsetWidth = 5% fluctuation;
3330
+ * - macOS Safari 14.0: getBoundingClientRect = 5% fluctuation;
3331
+ * - iOS Safari 9, 10, 11.0, 12.0: haven't found a way to zoom a page (pinch doesn't change layout);
3332
+ * - iOS Safari 13.1, 14.0: zoom reset + offsetWidth = 100% reliable;
3333
+ * - iOS Safari 13.1, 14.0: zoom reset + getBoundingClientRect = 100% reliable;
3334
+ * - iOS Safari 14.0: offsetWidth = 100% reliable;
3335
+ * - iOS Safari 14.0: getBoundingClientRect = 100% reliable;
3336
+ * - Chrome 42, 65, 80, 87: zoom 1/devicePixelRatio + offsetWidth = 1px fluctuation;
3337
+ * - Chrome 42, 65, 80, 87: zoom 1/devicePixelRatio + getBoundingClientRect = 100% reliable;
3338
+ * - Chrome 87: offsetWidth = 1px fluctuation;
3339
+ * - Chrome 87: getBoundingClientRect = 0.7px fluctuation;
3340
+ * - Firefox 48, 51: offsetWidth = 10% fluctuation;
3341
+ * - Firefox 48, 51: getBoundingClientRect = 10% fluctuation;
3342
+ * - Firefox 52, 53, 57, 62, 66, 67, 68, 71, 75, 80, 84: offsetWidth = width 100% reliable, height 10% fluctuation;
3343
+ * - Firefox 52, 53, 57, 62, 66, 67, 68, 71, 75, 80, 84: getBoundingClientRect = width 100% reliable, height 10%
3344
+ * fluctuation;
3345
+ * - Android Chrome 86: haven't found a way to zoom a page (pinch doesn't change layout);
3346
+ * - Android Firefox 84: font size in accessibility settings changes all the CSS sizes, but offsetWidth and
3347
+ * getBoundingClientRect keep measuring with regular units, so the size reflects the font size setting and doesn't
3348
+ * fluctuate;
3349
+ * - IE 11, Edge 18: zoom 1/devicePixelRatio + offsetWidth = 100% reliable;
3350
+ * - IE 11, Edge 18: zoom 1/devicePixelRatio + getBoundingClientRect = reflects the zoom level;
3351
+ * - IE 11, Edge 18: offsetWidth = 100% reliable;
3352
+ * - IE 11, Edge 18: getBoundingClientRect = 100% reliable;
3353
+ */
3354
+ return withIframe(function (_, iframeWindow) {
3355
+ var iframeDocument = iframeWindow.document;
3356
+ var iframeBody = iframeDocument.body;
3357
+ var bodyStyle = iframeBody.style;
3358
+ bodyStyle.width = "".concat(containerWidthPx, "px");
3359
+ bodyStyle.webkitTextSizeAdjust = bodyStyle.textSizeAdjust = 'none';
3360
+ // See the big comment above
3361
+ if (isChromium()) {
3362
+ iframeBody.style.zoom = "".concat(1 / iframeWindow.devicePixelRatio);
3363
+ }
3364
+ else if (isWebKit()) {
3365
+ iframeBody.style.zoom = 'reset';
3366
+ }
3367
+ // See the big comment above
3368
+ var linesOfText = iframeDocument.createElement('div');
3369
+ linesOfText.textContent = __spreadArray([], Array((containerWidthPx / 20) << 0), true).map(function () { return 'word'; }).join(' ');
3370
+ iframeBody.appendChild(linesOfText);
3371
+ return action(iframeDocument, iframeBody);
3372
+ }, '<!doctype html><html><head><meta name="viewport" content="width=device-width, initial-scale=1">');
3373
+ }
3374
+
3375
+ function isPdfViewerEnabled() {
3376
+ return navigator.pdfViewerEnabled;
3377
+ }
3378
+
3379
+ /**
3380
+ * Unlike most other architectures, on x86/x86-64 when floating-point instructions
3381
+ * have no NaN arguments, but produce NaN output, the output NaN has sign bit set.
3382
+ * We use it to distinguish x86/x86-64 from other architectures, by doing subtraction
3383
+ * of two infinities (must produce NaN per IEEE 754 standard).
3384
+ *
3385
+ * See https://codebrowser.bddppq.com/pytorch/pytorch/third_party/XNNPACK/src/init.c.html#79
3386
+ */
3387
+ function getArchitecture() {
3388
+ var f = new Float32Array(1);
3389
+ var u8 = new Uint8Array(f.buffer);
3390
+ f[0] = Infinity;
3391
+ f[0] = f[0] - f[0];
3392
+ return u8[3];
3393
+ }
3394
+
3395
+ /**
3396
+ * The return type is a union instead of the enum, because it's too challenging to embed the const enum into another
3397
+ * project. Turning it into a union is a simple and an elegant solution.
3398
+ */
3399
+ function getApplePayState() {
3400
+ var ApplePaySession = window.ApplePaySession;
3401
+ if (typeof (ApplePaySession === null || ApplePaySession === void 0 ? void 0 : ApplePaySession.canMakePayments) !== 'function') {
3402
+ return -1 /* ApplePayState.NoAPI */;
3403
+ }
3404
+ if (willPrintConsoleError()) {
3405
+ return -3 /* ApplePayState.NotAvailableInFrame */;
3406
+ }
3407
+ try {
3408
+ return ApplePaySession.canMakePayments() ? 1 /* ApplePayState.Enabled */ : 0 /* ApplePayState.Disabled */;
3409
+ }
3410
+ catch (error) {
3411
+ return getStateFromError(error);
3412
+ }
3413
+ }
3414
+ /**
3415
+ * Starting from Safari 15 calling `ApplePaySession.canMakePayments()` produces this error message when FingerprintJS
3416
+ * runs in an iframe with a cross-origin parent page, and the iframe on that page has no allow="payment *" attribute:
3417
+ * Feature policy 'Payment' check failed for element with origin 'https://example.com' and allow attribute ''.
3418
+ * This function checks whether the error message is expected.
3419
+ *
3420
+ * We check for cross-origin parents, which is prone to false-positive results. Instead, we should check for allowed
3421
+ * feature/permission, but we can't because none of these API works in Safari yet:
3422
+ * navigator.permissions.query({ name: ‘payment' })
3423
+ * navigator.permissions.query({ name: ‘payment-handler' })
3424
+ * document.featurePolicy
3425
+ */
3426
+ var willPrintConsoleError = isAnyParentCrossOrigin;
3427
+ function getStateFromError(error) {
3428
+ // See full expected error messages in the test
3429
+ if (error instanceof Error && error.name === 'InvalidAccessError' && /\bfrom\b.*\binsecure\b/i.test(error.message)) {
3430
+ return -2 /* ApplePayState.NotAvailableInInsecureContext */;
3431
+ }
3432
+ throw error;
3433
+ }
3434
+
3435
+ /**
3436
+ * Checks whether the Safari's Privacy Preserving Ad Measurement setting is on.
3437
+ * The setting is on when the value is not undefined.
3438
+ * A.k.a. private click measurement, privacy-preserving ad attribution.
3439
+ *
3440
+ * Unfortunately, it doesn't work in mobile Safari.
3441
+ * Probably, it will start working in mobile Safari or stop working in desktop Safari later.
3442
+ * We've found no way to detect the setting state in mobile Safari. Help wanted.
3443
+ *
3444
+ * @see https://webkit.org/blog/11529/introducing-private-click-measurement-pcm/
3445
+ * @see https://developer.apple.com/videos/play/wwdc2021/10033
3446
+ */
3447
+ function getPrivateClickMeasurement() {
3448
+ var _a;
3449
+ var link = document.createElement('a');
3450
+ var sourceId = (_a = link.attributionSourceId) !== null && _a !== void 0 ? _a : link.attributionsourceid;
3451
+ return sourceId === undefined ? undefined : String(sourceId);
3452
+ }
3453
+
3454
+ /** WebGl context is not available */
3455
+ var STATUS_NO_GL_CONTEXT = -1;
3456
+ /** WebGL context `getParameter` method is not a function */
3457
+ var STATUS_GET_PARAMETER_NOT_A_FUNCTION = -2;
3458
+ var validContextParameters = new Set([
3459
+ 10752, 2849, 2884, 2885, 2886, 2928, 2929, 2930, 2931, 2932, 2960, 2961, 2962, 2963, 2964, 2965, 2966, 2967, 2968,
3460
+ 2978, 3024, 3042, 3088, 3089, 3106, 3107, 32773, 32777, 32777, 32823, 32824, 32936, 32937, 32938, 32939, 32968, 32969,
3461
+ 32970, 32971, 3317, 33170, 3333, 3379, 3386, 33901, 33902, 34016, 34024, 34076, 3408, 3410, 3411, 3412, 3413, 3414,
3462
+ 3415, 34467, 34816, 34817, 34818, 34819, 34877, 34921, 34930, 35660, 35661, 35724, 35738, 35739, 36003, 36004, 36005,
3463
+ 36347, 36348, 36349, 37440, 37441, 37443, 7936, 7937, 7938,
3464
+ // SAMPLE_ALPHA_TO_COVERAGE (32926) and SAMPLE_COVERAGE (32928) are excluded because they trigger a console warning
3465
+ // in IE, Chrome ≤ 59 and Safari ≤ 13 and give no entropy.
3466
+ ]);
3467
+ var validExtensionParams = new Set([
3468
+ 34047,
3469
+ 35723,
3470
+ 36063,
3471
+ 34852,
3472
+ 34853,
3473
+ 34854,
3474
+ 34229,
3475
+ 36392,
3476
+ 36795,
3477
+ 38449, // MAX_VIEWS_OVR
3478
+ ]);
3479
+ var shaderTypes = ['FRAGMENT_SHADER', 'VERTEX_SHADER'];
3480
+ var precisionTypes = ['LOW_FLOAT', 'MEDIUM_FLOAT', 'HIGH_FLOAT', 'LOW_INT', 'MEDIUM_INT', 'HIGH_INT'];
3481
+ var rendererInfoExtensionName = 'WEBGL_debug_renderer_info';
3482
+ var polygonModeExtensionName = 'WEBGL_polygon_mode';
3483
+ /**
3484
+ * Gets the basic and simple WebGL parameters
3485
+ */
3486
+ function getWebGlBasics(_a) {
3487
+ var _b, _c, _d, _e, _f, _g;
3488
+ var cache = _a.cache;
3489
+ var gl = getWebGLContext(cache);
3490
+ if (!gl) {
3491
+ return STATUS_NO_GL_CONTEXT;
3492
+ }
3493
+ if (!isValidParameterGetter(gl)) {
3494
+ return STATUS_GET_PARAMETER_NOT_A_FUNCTION;
3495
+ }
3496
+ var debugExtension = shouldAvoidDebugRendererInfo() ? null : gl.getExtension(rendererInfoExtensionName);
3497
+ return {
3498
+ version: ((_b = gl.getParameter(gl.VERSION)) === null || _b === void 0 ? void 0 : _b.toString()) || '',
3499
+ vendor: ((_c = gl.getParameter(gl.VENDOR)) === null || _c === void 0 ? void 0 : _c.toString()) || '',
3500
+ vendorUnmasked: debugExtension ? (_d = gl.getParameter(debugExtension.UNMASKED_VENDOR_WEBGL)) === null || _d === void 0 ? void 0 : _d.toString() : '',
3501
+ renderer: ((_e = gl.getParameter(gl.RENDERER)) === null || _e === void 0 ? void 0 : _e.toString()) || '',
3502
+ rendererUnmasked: debugExtension ? (_f = gl.getParameter(debugExtension.UNMASKED_RENDERER_WEBGL)) === null || _f === void 0 ? void 0 : _f.toString() : '',
3503
+ shadingLanguageVersion: ((_g = gl.getParameter(gl.SHADING_LANGUAGE_VERSION)) === null || _g === void 0 ? void 0 : _g.toString()) || '',
3504
+ };
3505
+ }
3506
+ /**
3507
+ * Gets the advanced and massive WebGL parameters and extensions
3508
+ */
3509
+ function getWebGlExtensions(_a) {
3510
+ var cache = _a.cache;
3511
+ var gl = getWebGLContext(cache);
3512
+ if (!gl) {
3513
+ return STATUS_NO_GL_CONTEXT;
3514
+ }
3515
+ if (!isValidParameterGetter(gl)) {
3516
+ return STATUS_GET_PARAMETER_NOT_A_FUNCTION;
3517
+ }
3518
+ var extensions = gl.getSupportedExtensions();
3519
+ var contextAttributes = gl.getContextAttributes();
3520
+ var unsupportedExtensions = [];
3521
+ // Features
3522
+ var attributes = [];
3523
+ var parameters = [];
3524
+ var extensionParameters = [];
3525
+ var shaderPrecisions = [];
3526
+ // Context attributes
3527
+ if (contextAttributes) {
3528
+ for (var _i = 0, _b = Object.keys(contextAttributes); _i < _b.length; _i++) {
3529
+ var attributeName = _b[_i];
3530
+ attributes.push("".concat(attributeName, "=").concat(contextAttributes[attributeName]));
3531
+ }
3532
+ }
3533
+ // Context parameters
3534
+ var constants = getConstantsFromPrototype(gl);
3535
+ for (var _c = 0, constants_1 = constants; _c < constants_1.length; _c++) {
3536
+ var constant = constants_1[_c];
3537
+ var code = gl[constant];
3538
+ parameters.push("".concat(constant, "=").concat(code).concat(validContextParameters.has(code) ? "=".concat(gl.getParameter(code)) : ''));
3539
+ }
3540
+ // Extension parameters
3541
+ if (extensions) {
3542
+ for (var _d = 0, extensions_1 = extensions; _d < extensions_1.length; _d++) {
3543
+ var name_1 = extensions_1[_d];
3544
+ if ((name_1 === rendererInfoExtensionName && shouldAvoidDebugRendererInfo()) ||
3545
+ (name_1 === polygonModeExtensionName && shouldAvoidPolygonModeExtensions())) {
3546
+ continue;
3547
+ }
3548
+ var extension = gl.getExtension(name_1);
3549
+ if (!extension) {
3550
+ unsupportedExtensions.push(name_1);
3551
+ continue;
3552
+ }
3553
+ for (var _e = 0, _f = getConstantsFromPrototype(extension); _e < _f.length; _e++) {
3554
+ var constant = _f[_e];
3555
+ var code = extension[constant];
3556
+ extensionParameters.push("".concat(constant, "=").concat(code).concat(validExtensionParams.has(code) ? "=".concat(gl.getParameter(code)) : ''));
3557
+ }
3558
+ }
3559
+ }
3560
+ // Shader precision
3561
+ for (var _g = 0, shaderTypes_1 = shaderTypes; _g < shaderTypes_1.length; _g++) {
3562
+ var shaderType = shaderTypes_1[_g];
3563
+ for (var _h = 0, precisionTypes_1 = precisionTypes; _h < precisionTypes_1.length; _h++) {
3564
+ var precisionType = precisionTypes_1[_h];
3565
+ var shaderPrecision = getShaderPrecision(gl, shaderType, precisionType);
3566
+ shaderPrecisions.push("".concat(shaderType, ".").concat(precisionType, "=").concat(shaderPrecision.join(',')));
3567
+ }
3568
+ }
3569
+ // Postprocess
3570
+ extensionParameters.sort();
3571
+ parameters.sort();
3572
+ return {
3573
+ contextAttributes: attributes,
3574
+ parameters: parameters,
3575
+ shaderPrecisions: shaderPrecisions,
3576
+ extensions: extensions,
3577
+ extensionParameters: extensionParameters,
3578
+ unsupportedExtensions: unsupportedExtensions,
3579
+ };
3580
+ }
3581
+ /**
3582
+ * This function usually takes the most time to execute in all the sources, therefore we cache its result.
3583
+ *
3584
+ * Warning for package users:
3585
+ * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
3586
+ */
3587
+ function getWebGLContext(cache) {
3588
+ if (cache.webgl) {
3589
+ return cache.webgl.context;
3590
+ }
3591
+ var canvas = document.createElement('canvas');
3592
+ var context;
3593
+ canvas.addEventListener('webglCreateContextError', function () { return (context = undefined); });
3594
+ for (var _i = 0, _a = ['webgl', 'experimental-webgl']; _i < _a.length; _i++) {
3595
+ var type = _a[_i];
3596
+ try {
3597
+ context = canvas.getContext(type);
3598
+ }
3599
+ catch (_b) {
3600
+ // Ok, continue
3601
+ }
3602
+ if (context) {
3603
+ break;
3604
+ }
3605
+ }
3606
+ cache.webgl = { context: context };
3607
+ return context;
3608
+ }
3609
+ /**
3610
+ * https://developer.mozilla.org/en-US/docs/Web/API/WebGLShaderPrecisionFormat
3611
+ * https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getShaderPrecisionFormat
3612
+ * https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.12
3613
+ */
3614
+ function getShaderPrecision(gl, shaderType, precisionType) {
3615
+ var shaderPrecision = gl.getShaderPrecisionFormat(gl[shaderType], gl[precisionType]);
3616
+ return shaderPrecision ? [shaderPrecision.rangeMin, shaderPrecision.rangeMax, shaderPrecision.precision] : [];
3617
+ }
3618
+ function getConstantsFromPrototype(obj) {
3619
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3620
+ var keys = Object.keys(obj.__proto__);
3621
+ return keys.filter(isConstantLike);
3622
+ }
3623
+ function isConstantLike(key) {
3624
+ return typeof key === 'string' && !key.match(/[^A-Z0-9_x]/);
3625
+ }
3626
+ /**
3627
+ * Some browsers print a console warning when the WEBGL_debug_renderer_info extension is requested.
3628
+ * JS Agent aims to avoid printing messages to console, so we avoid this extension in that browsers.
3629
+ */
3630
+ function shouldAvoidDebugRendererInfo() {
3631
+ return isGecko();
3632
+ }
3633
+ /**
3634
+ * Some browsers print a console warning when the WEBGL_polygon_mode extension is requested.
3635
+ * JS Agent aims to avoid printing messages to console, so we avoid this extension in that browsers.
3636
+ */
3637
+ function shouldAvoidPolygonModeExtensions() {
3638
+ return isChromium() || isWebKit();
3639
+ }
3640
+ /**
3641
+ * Some unknown browsers have no `getParameter` method
3642
+ */
3643
+ function isValidParameterGetter(gl) {
3644
+ return typeof gl.getParameter === 'function';
3645
+ }
3646
+
3647
+ function getAudioContextBaseLatency() {
3648
+ // The signal emits warning in Chrome and Firefox, therefore it is enabled on Safari where it doesn't produce warning
3649
+ // and on Android where it's less visible
3650
+ var isAllowedPlatform = isAndroid() || isWebKit();
3651
+ if (!isAllowedPlatform) {
3652
+ return -2 /* SpecialFingerprint.Disabled */;
3653
+ }
3654
+ if (!window.AudioContext) {
3655
+ return -1 /* SpecialFingerprint.NotSupported */;
3656
+ }
3657
+ var latency = new AudioContext().baseLatency;
3658
+ if (latency === null || latency === undefined) {
3659
+ return -1 /* SpecialFingerprint.NotSupported */;
3660
+ }
3661
+ if (!isFinite(latency)) {
3662
+ return -3 /* SpecialFingerprint.NotFinite */;
3663
+ }
3664
+ return latency;
3665
+ }
3666
+
3667
+ /**
3668
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/resolvedOptions
3669
+ *
3670
+ * The return type is a union instead of a const enum due to the difficulty of embedding const enums in other projects.
3671
+ * This makes integration simpler and more elegant.
3672
+ */
3673
+ function getDateTimeLocale() {
3674
+ if (!window.Intl) {
3675
+ return -1 /* Status.IntlAPINotSupported */;
3676
+ }
3677
+ var DateTimeFormat = window.Intl.DateTimeFormat;
3678
+ if (!DateTimeFormat) {
3679
+ return -2 /* Status.DateTimeFormatNotSupported */;
3680
+ }
3681
+ var locale = DateTimeFormat().resolvedOptions().locale;
3682
+ if (!locale && locale !== '') {
3683
+ return -3 /* Status.LocaleNotAvailable */;
3684
+ }
3685
+ return locale;
3686
+ }
3687
+
3688
+ /**
3689
+ * The list of entropy sources used to make visitor identifiers.
3690
+ *
3691
+ * This value isn't restricted by Semantic Versioning, i.e. it may be changed without bumping minor or major version of
3692
+ * this package.
3693
+ *
3694
+ * Note: Rollup and Webpack are smart enough to remove unused properties of this object during tree-shaking, so there is
3695
+ * no need to export the sources individually.
3696
+ */
3697
+ var sources = {
3698
+ // READ FIRST:
3699
+ // See https://github.com/fingerprintjs/fingerprintjs/blob/master/contributing.md#how-to-add-an-entropy-source
3700
+ // to learn how entropy source works and how to make your own.
3701
+ // The sources run in this exact order.
3702
+ // The asynchronous sources are at the start to run in parallel with other sources.
3703
+ fonts: getFonts,
3704
+ domBlockers: getDomBlockers,
3705
+ fontPreferences: getFontPreferences,
3706
+ audio: getAudioFingerprint,
3707
+ screenFrame: getScreenFrame,
3708
+ canvas: getCanvasFingerprint,
3709
+ osCpu: getOsCpu,
3710
+ languages: getLanguages,
3711
+ colorDepth: getColorDepth,
3712
+ deviceMemory: getDeviceMemory,
3713
+ screenResolution: getScreenResolution,
3714
+ hardwareConcurrency: getHardwareConcurrency,
3715
+ timezone: getTimezone,
3716
+ sessionStorage: getSessionStorage,
3717
+ localStorage: getLocalStorage,
3718
+ indexedDB: getIndexedDB,
3719
+ openDatabase: getOpenDatabase,
3720
+ cpuClass: getCpuClass,
3721
+ platform: getPlatform,
3722
+ plugins: getPlugins,
3723
+ touchSupport: getTouchSupport,
3724
+ vendor: getVendor,
3725
+ vendorFlavors: getVendorFlavors,
3726
+ cookiesEnabled: areCookiesEnabled,
3727
+ colorGamut: getColorGamut,
3728
+ invertedColors: areColorsInverted,
3729
+ forcedColors: areColorsForced,
3730
+ monochrome: getMonochromeDepth,
3731
+ contrast: getContrastPreference,
3732
+ reducedMotion: isMotionReduced,
3733
+ reducedTransparency: isTransparencyReduced,
3734
+ hdr: isHDR,
3735
+ math: getMathFingerprint,
3736
+ pdfViewerEnabled: isPdfViewerEnabled,
3737
+ architecture: getArchitecture,
3738
+ applePay: getApplePayState,
3739
+ privateClickMeasurement: getPrivateClickMeasurement,
3740
+ audioBaseLatency: getAudioContextBaseLatency,
3741
+ dateTimeLocale: getDateTimeLocale,
3742
+ // Some sources can affect other sources (e.g. WebGL can affect canvas), so it's important to run these sources
3743
+ // after other sources.
3744
+ webGlBasics: getWebGlBasics,
3745
+ webGlExtensions: getWebGlExtensions,
3746
+ };
3747
+ /**
3748
+ * Loads the built-in entropy sources.
3749
+ * Returns a function that collects the entropy components to make the visitor identifier.
3750
+ */
3751
+ function loadBuiltinSources(options) {
3752
+ return loadSources(sources, options, []);
3753
+ }
3754
+
3755
+ var commentTemplate = '$ if upgrade to Pro: https://fpjs.dev/pro';
3756
+ function getConfidence(components) {
3757
+ var openConfidenceScore = getOpenConfidenceScore(components);
3758
+ var proConfidenceScore = deriveProConfidenceScore(openConfidenceScore);
3759
+ return { score: openConfidenceScore, comment: commentTemplate.replace(/\$/g, "".concat(proConfidenceScore)) };
3760
+ }
3761
+ function getOpenConfidenceScore(components) {
3762
+ // In order to calculate the true probability of the visitor identifier being correct, we need to know the number of
3763
+ // website visitors (the higher the number, the less the probability because the fingerprint entropy is limited).
3764
+ // JS agent doesn't know the number of visitors, so we can only do an approximate assessment.
3765
+ if (isAndroid()) {
3766
+ return 0.4;
3767
+ }
3768
+ // Safari (mobile and desktop)
3769
+ if (isWebKit()) {
3770
+ return isDesktopWebKit() && !(isWebKit616OrNewer() && isSafariWebKit()) ? 0.5 : 0.3;
3771
+ }
3772
+ var platform = 'value' in components.platform ? components.platform.value : '';
3773
+ // Windows
3774
+ if (/^Win/.test(platform)) {
3775
+ // The score is greater than on macOS because of the higher variety of devices running Windows.
3776
+ // Chrome provides more entropy than Firefox according too
3777
+ // 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
3778
+ // So we assign the same score to them.
3779
+ return 0.6;
3780
+ }
3781
+ // macOS
3782
+ if (/^Mac/.test(platform)) {
3783
+ // Chrome provides more entropy than Safari and Safari provides more entropy than Firefox.
3784
+ // Chrome is more popular than Safari and Safari is more popular than Firefox according to
3785
+ // 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
3786
+ // So we assign the same score to them.
3787
+ return 0.5;
3788
+ }
3789
+ // Another platform, e.g. a desktop Linux. It's rare, so it should be pretty unique.
3790
+ return 0.7;
3791
+ }
3792
+ function deriveProConfidenceScore(openConfidenceScore) {
3793
+ return round(0.99 + 0.01 * openConfidenceScore, 0.0001);
3794
+ }
3795
+
3796
+ function componentsToCanonicalString(components) {
3797
+ var result = '';
3798
+ for (var _i = 0, _a = Object.keys(components).sort(); _i < _a.length; _i++) {
3799
+ var componentKey = _a[_i];
3800
+ var component = components[componentKey];
3801
+ var value = 'error' in component ? 'error' : JSON.stringify(component.value);
3802
+ result += "".concat(result ? '|' : '').concat(componentKey.replace(/([:|\\])/g, '\\$1'), ":").concat(value);
3803
+ }
3804
+ return result;
3805
+ }
3806
+ function componentsToDebugString(components) {
3807
+ return JSON.stringify(components, function (_key, value) {
3808
+ if (value instanceof Error) {
3809
+ return errorToObject(value);
3810
+ }
3811
+ return value;
3812
+ }, 2);
3813
+ }
3814
+ function hashComponents(components) {
3815
+ return x64hash128(componentsToCanonicalString(components));
3816
+ }
3817
+ /**
3818
+ * Makes a GetResult implementation that calculates the visitor id hash on demand.
3819
+ * Designed for optimisation.
3820
+ */
3821
+ function makeLazyGetResult(components) {
3822
+ var visitorIdCache;
3823
+ // This function runs very fast, so there is no need to make it lazy
3824
+ var confidence = getConfidence(components);
3825
+ // A plain class isn't used because its getters and setters aren't enumerable.
3826
+ return {
3827
+ get visitorId() {
3828
+ if (visitorIdCache === undefined) {
3829
+ visitorIdCache = hashComponents(this.components);
3830
+ }
3831
+ return visitorIdCache;
3832
+ },
3833
+ set visitorId(visitorId) {
3834
+ visitorIdCache = visitorId;
3835
+ },
3836
+ confidence: confidence,
3837
+ components: components,
3838
+ version: version,
3839
+ };
3840
+ }
3841
+ /**
3842
+ * A delay is required to ensure consistent entropy components.
3843
+ * See https://github.com/fingerprintjs/fingerprintjs/issues/254
3844
+ * and https://github.com/fingerprintjs/fingerprintjs/issues/307
3845
+ * and https://github.com/fingerprintjs/fingerprintjs/commit/945633e7c5f67ae38eb0fea37349712f0e669b18
3846
+ */
3847
+ function prepareForSources(delayFallback) {
3848
+ if (delayFallback === void 0) { delayFallback = 50; }
3849
+ // A proper deadline is unknown. Let it be twice the fallback timeout so that both cases have the same average time.
3850
+ return requestIdleCallbackIfAvailable(delayFallback, delayFallback * 2);
3851
+ }
3852
+ /**
3853
+ * The function isn't exported from the index file to not allow to call it without `load()`.
3854
+ * The hiding gives more freedom for future non-breaking updates.
3855
+ *
3856
+ * A factory function is used instead of a class to shorten the attribute names in the minified code.
3857
+ * Native private class fields could've been used, but TypeScript doesn't allow them with `"target": "es5"`.
3858
+ */
3859
+ function makeAgent(getComponents, debug) {
3860
+ var creationTime = Date.now();
3861
+ return {
3862
+ get: function (options) {
3863
+ return __awaiter(this, void 0, void 0, function () {
3864
+ var startTime, components, result;
3865
+ return __generator(this, function (_a) {
3866
+ switch (_a.label) {
3867
+ case 0:
3868
+ startTime = Date.now();
3869
+ return [4 /*yield*/, getComponents()];
3870
+ case 1:
3871
+ components = _a.sent();
3872
+ result = makeLazyGetResult(components);
3873
+ if (debug || (options === null || options === void 0 ? void 0 : options.debug)) {
3874
+ // console.log is ok here because it's under a debug clause
3875
+ // eslint-disable-next-line no-console
3876
+ console.log("Copy the text below to get the debug data:\n\n```\nversion: ".concat(result.version, "\nuserAgent: ").concat(navigator.userAgent, "\ntimeBetweenLoadAndGet: ").concat(startTime - creationTime, "\nvisitorId: ").concat(result.visitorId, "\ncomponents: ").concat(componentsToDebugString(components), "\n```"));
3877
+ }
3878
+ return [2 /*return*/, result];
3879
+ }
3880
+ });
3881
+ });
3882
+ },
3883
+ };
3884
+ }
3885
+ /**
3886
+ * Sends an unpersonalized AJAX request to collect installation statistics
3887
+ */
3888
+ function monitor() {
3889
+ // The FingerprintJS CDN (https://github.com/fingerprintjs/cdn) replaces `window.__fpjs_d_m` with `true`
3890
+ if (window.__fpjs_d_m || Math.random() >= 0.001) {
3891
+ return;
3892
+ }
3893
+ try {
3894
+ var request = new XMLHttpRequest();
3895
+ request.open('get', "https://m1.openfpcdn.io/fingerprintjs/v".concat(version, "/npm-monitoring"), true);
3896
+ request.send();
3897
+ }
3898
+ catch (error) {
3899
+ // console.error is ok here because it's an unexpected error handler
3900
+ // eslint-disable-next-line no-console
3901
+ console.error(error);
3902
+ }
3903
+ }
3904
+ /**
3905
+ * Builds an instance of Agent and waits a delay required for a proper operation.
3906
+ */
3907
+ function load(options) {
3908
+ var _a;
3909
+ if (options === void 0) { options = {}; }
3910
+ return __awaiter(this, void 0, void 0, function () {
3911
+ var delayFallback, debug, getComponents;
3912
+ return __generator(this, function (_b) {
3913
+ switch (_b.label) {
3914
+ case 0:
3915
+ if ((_a = options.monitoring) !== null && _a !== void 0 ? _a : true) {
3916
+ monitor();
3917
+ }
3918
+ delayFallback = options.delayFallback, debug = options.debug;
3919
+ return [4 /*yield*/, prepareForSources(delayFallback)];
3920
+ case 1:
3921
+ _b.sent();
3922
+ getComponents = loadBuiltinSources({ cache: {}, debug: debug });
3923
+ return [2 /*return*/, makeAgent(getComponents, debug)];
3924
+ }
3925
+ });
3926
+ });
3927
+ }
3928
+
3929
+ // The default export is a syntax sugar (`import * as FP from '...' → import FP from '...'`).
3930
+ // It should contain all the public exported values.
3931
+ var index$1 = { load: load, hashComponents: hashComponents, componentsToDebugString: componentsToDebugString };
3932
+
3933
+ /**
3934
+ * Customer SDK 主类
3935
+ * 只负责悬浮图标和iframe管理,不处理WebSocket连接
3936
+ * 所有聊天逻辑都在iframe中处理
3937
+ */
3938
+ class CustomerServiceSDK {
3939
+ constructor() {
3940
+ this.iconManager = null;
3941
+ this.iframeManager = null;
3942
+ this.config = null;
3943
+ this.isInitialized = false;
3944
+ }
3945
+ /**
3946
+ * 初始化 SDK
3947
+ * @param config SDK配置
3948
+ * @param options UI选项(可选)
3949
+ */
3950
+ async init(config, options) {
3951
+ if (this.isInitialized) {
3952
+ console.warn('CustomerSDK already initialized');
3953
+ return;
3954
+ }
3955
+ this.config = config;
3956
+ try {
3957
+ // 获取设备指纹ID
3958
+ const deviceId = await this.getDeviceId();
3959
+ console.log('Device ID:', deviceId);
3960
+ // 构建iframe URL(带参数)
3961
+ const iframeUrl = this.buildIframeUrl(config, deviceId);
3962
+ // 创建悬浮图标管理器(IconManager现在是写死的)
3963
+ this.iconManager = new IconManager();
3964
+ await this.iconManager.show();
3965
+ // 创建iframe管理器(自动检测设备类型)
3966
+ this.iframeManager = new IframeManager({
3967
+ src: iframeUrl,
3968
+ mode: 'auto', // 自动根据设备类型选择模式
3969
+ width: 400,
3970
+ height: 600,
3971
+ allowClose: true,
3972
+ ...options
3973
+ });
3974
+ // 预初始化iframe(隐藏状态,连接SSE)
3975
+ await this.iframeManager.init();
3976
+ // 设置点击事件:图标 → iframe
3977
+ this.iconManager.onClick(() => {
3978
+ this.iframeManager?.show();
3979
+ });
3980
+ this.isInitialized = true;
3981
+ console.log('CustomerSDK initialized successfully (iframe pre-connected to SSE)');
3982
+ }
3983
+ catch (error) {
3984
+ console.error('Failed to initialize CustomerSDK:', error);
3985
+ throw error;
3986
+ }
3987
+ }
3988
+ /**
3989
+ * 显示/隐藏悬浮图标
3990
+ */
3991
+ showIcon() {
3992
+ this.iconManager?.show();
3993
+ }
3994
+ hideIcon() {
3995
+ this.iconManager?.hide();
3996
+ }
3997
+ /**
3998
+ * 设置图标位置
3999
+ */
4000
+ setIconPosition(position) {
4001
+ this.iconManager?.setPosition(position);
4002
+ }
4003
+ /**
4004
+ * 更新图标样式
4005
+ */
4006
+ setIconStyle(style) {
4007
+ this.iconManager?.setStyle(style);
4008
+ }
4009
+ /**
4010
+ * 打开/关闭聊天窗口
4011
+ */
4012
+ openChat() {
4013
+ this.iframeManager?.open();
4014
+ }
4015
+ closeChat() {
4016
+ this.iframeManager?.close();
4017
+ }
4018
+ /**
4019
+ * 检查聊天窗口是否打开
4020
+ */
4021
+ isChatOpen() {
4022
+ return this.iframeManager?.isIframeOpen() || false;
4023
+ }
4024
+ /**
4025
+ * 向iframe发送消息(传递用户数据等)
4026
+ */
4027
+ sendToIframe(data) {
4028
+ this.iframeManager?.sendToIframe(data);
4029
+ }
4030
+ /**
4031
+ * 获取连接状态
4032
+ * 注意:真正的连接状态保存在iframe中的SSE连接中
4033
+ */
4034
+ getConnectionStatus() {
4035
+ return this.isInitialized;
4036
+ }
4037
+ /**
4038
+ * 显示消息通知
4039
+ */
4040
+ showNotification(badgeCount = 1, options = {}) {
4041
+ if (!this.iconManager) {
4042
+ console.warn('SDK not initialized');
4043
+ return;
4044
+ }
4045
+ this.iconManager.showNotification({
4046
+ badgeCount: typeof badgeCount === 'string' ? 0 : badgeCount,
4047
+ badgeText: typeof badgeCount === 'string' ? badgeCount : '',
4048
+ pulse: options.pulse || false
4049
+ });
4050
+ // 自动隐藏通知
4051
+ if (options.autoHide && options.autoHide > 0) {
4052
+ setTimeout(() => {
4053
+ this.iconManager?.clearNotification();
4054
+ }, options.autoHide);
4055
+ }
4056
+ }
4057
+ /**
4058
+ * 清除消息通知
4059
+ */
4060
+ clearNotification() {
4061
+ this.iconManager?.clearNotification();
4062
+ }
4063
+ /**
4064
+ * 销毁 SDK
4065
+ */
4066
+ destroy() {
4067
+ this.iconManager?.hide();
4068
+ this.iframeManager?.close();
4069
+ this.iconManager = null;
4070
+ this.iframeManager = null;
4071
+ this.config = null;
4072
+ this.isInitialized = false;
4073
+ console.log('CustomerSDK destroyed');
4074
+ }
4075
+ /**
4076
+ * 获取设备指纹ID
4077
+ */
4078
+ async getDeviceId() {
4079
+ console.log('🔍 Starting to get device fingerprint...');
4080
+ try {
4081
+ console.log('📦 Loading FingerprintJS...');
4082
+ const fp = await index$1.load();
4083
+ console.log('🎯 Getting device fingerprint...');
4084
+ const result = await fp.get();
4085
+ console.log('✅ FingerprintJS result:', result);
4086
+ console.log('🆔 Device ID obtained:', result.visitorId);
4087
+ return result.visitorId;
4088
+ }
4089
+ catch (error) {
4090
+ console.warn('❌ Failed to get device fingerprint, using fallback:', error);
4091
+ const fallbackId = 'device_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);
4092
+ console.log('🆔 Fallback Device ID:', fallbackId);
4093
+ return fallbackId;
4094
+ }
4095
+ }
4096
+ /**
4097
+ * 构建iframe URL(带用户参数和设备ID)
4098
+ */
4099
+ buildIframeUrl(config, deviceId) {
4100
+ const baseUrl = config.chatUrl || config.apiBaseUrl;
4101
+ console.log('🌐 Building iframe URL with base:', baseUrl);
4102
+ console.log('🆔 Adding deviceId to URL:', deviceId);
4103
+ const url = `${baseUrl}`;
4104
+ // 添加用户参数
4105
+ const params = new URLSearchParams({
4106
+ agent: config.agent,
4107
+ userId: config.userId,
4108
+ token: config.token,
4109
+ deviceId: deviceId,
4110
+ debug: config.debug ? 'true' : 'false'
4111
+ });
4112
+ const finalUrl = `${url}?${params.toString()}`;
4113
+ console.log('🔗 Final iframe URL:', finalUrl);
4114
+ return finalUrl;
4115
+ }
4116
+ }
4117
+ // 创建全局实例
4118
+ let globalSDKInstance = null;
4119
+ /**
4120
+ * 初始化 Customer SDK
4121
+ * @param config SDK配置
4122
+ * @param options UI选项(可选)
4123
+ */
4124
+ const init = async (config, options) => {
4125
+ if (!globalSDKInstance) {
4126
+ globalSDKInstance = new CustomerServiceSDK();
4127
+ }
4128
+ await globalSDKInstance.init(config, options);
4129
+ };
4130
+ /**
4131
+ * 获取全局SDK实例
4132
+ */
4133
+ const getInstance = () => {
4134
+ if (!globalSDKInstance) {
4135
+ throw new Error('SDK not initialized. Call init() first.');
4136
+ }
4137
+ return globalSDKInstance;
4138
+ };
4139
+ /**
4140
+ * 图标控制API
4141
+ */
4142
+ const showIcon = () => {
4143
+ const sdk = getInstance();
4144
+ sdk.showIcon();
4145
+ };
4146
+ const hideIcon = () => {
4147
+ const sdk = getInstance();
4148
+ sdk.hideIcon();
4149
+ };
4150
+ const setIconPosition = (position) => {
4151
+ const sdk = getInstance();
4152
+ sdk.setIconPosition(position);
4153
+ };
4154
+ const setIconStyle = (style) => {
4155
+ const sdk = getInstance();
4156
+ sdk.setIconStyle(style);
4157
+ };
4158
+ /**
4159
+ * 聊天控制API
4160
+ */
4161
+ const openChat = () => {
4162
+ const sdk = getInstance();
4163
+ sdk.openChat();
4164
+ };
4165
+ const closeChat = () => {
4166
+ const sdk = getInstance();
4167
+ sdk.closeChat();
4168
+ };
4169
+ const isChatOpen = () => {
4170
+ const sdk = getInstance();
4171
+ return sdk.isChatOpen();
4172
+ };
4173
+ /**
4174
+ * iframe通信API
4175
+ */
4176
+ const sendToIframe = (data) => {
4177
+ const sdk = getInstance();
4178
+ sdk.sendToIframe(data);
4179
+ };
4180
+ /**
4181
+ * 其他API
4182
+ */
4183
+ const getConnectionStatus = () => {
4184
+ const sdk = getInstance();
4185
+ return sdk.getConnectionStatus();
4186
+ };
4187
+ /**
4188
+ * 消息通知API
4189
+ */
4190
+ const showNotification = (badgeCount = 1, options = {}) => {
4191
+ const sdk = getInstance();
4192
+ sdk.showNotification(badgeCount, options);
4193
+ };
4194
+ const clearNotification = () => {
4195
+ const sdk = getInstance();
4196
+ sdk.clearNotification();
4197
+ };
4198
+ const destroy = () => {
4199
+ const sdk = getInstance();
4200
+ sdk.destroy();
4201
+ globalSDKInstance = null;
4202
+ };
4203
+ // 默认导出
4204
+ var index = {
4205
+ init,
4206
+ getInstance,
4207
+ showIcon,
4208
+ hideIcon,
4209
+ setIconPosition,
4210
+ setIconStyle,
4211
+ openChat,
4212
+ closeChat,
4213
+ isChatOpen,
4214
+ sendToIframe,
4215
+ getConnectionStatus,
4216
+ showNotification,
4217
+ clearNotification,
4218
+ destroy
4219
+ };
4220
+
4221
+ exports.CustomerServiceSDK = CustomerServiceSDK;
4222
+ exports.clearNotification = clearNotification;
4223
+ exports.closeChat = closeChat;
4224
+ exports.default = index;
4225
+ exports.destroy = destroy;
4226
+ exports.getConnectionStatus = getConnectionStatus;
4227
+ exports.getInstance = getInstance;
4228
+ exports.hideIcon = hideIcon;
4229
+ exports.init = init;
4230
+ exports.isChatOpen = isChatOpen;
4231
+ exports.openChat = openChat;
4232
+ exports.sendToIframe = sendToIframe;
4233
+ exports.setIconPosition = setIconPosition;
4234
+ exports.setIconStyle = setIconStyle;
4235
+ exports.showIcon = showIcon;
4236
+ exports.showNotification = showNotification;