@cloudcare/browser-rum 3.1.19 → 3.1.21
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.
- package/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/boot/rum.js +11 -10
- package/cjs/boot/rum.js.map +1 -1
- package/cjs/domain/assembly.js.map +1 -1
- package/cjs/domain/contexts/pageStateHistory.js +4 -1
- package/cjs/domain/contexts/pageStateHistory.js.map +1 -1
- package/cjs/domain/contexts/urlContexts.js +3 -1
- package/cjs/domain/contexts/urlContexts.js.map +1 -1
- package/cjs/domain/contexts/viewContexts.js +9 -1
- package/cjs/domain/contexts/viewContexts.js.map +1 -1
- package/cjs/domain/locationChangeObservable.js +6 -4
- package/cjs/domain/locationChangeObservable.js.map +1 -1
- package/cjs/domain/performanceCollection.js +40 -90
- package/cjs/domain/performanceCollection.js.map +1 -1
- package/cjs/domain/performanceObservable.js +113 -0
- package/cjs/domain/performanceObservable.js.map +1 -0
- package/cjs/domain/performanceUtils.js +20 -0
- package/cjs/domain/performanceUtils.js.map +1 -0
- package/cjs/domain/replay/deflate/deflateWorker.js +1 -1
- package/cjs/domain/replay/record/observers.js +58 -54
- package/cjs/domain/replay/record/observers.js.map +1 -1
- package/cjs/domain/requestCollection.js +6 -2
- package/cjs/domain/requestCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/trackClickActions.js +3 -1
- package/cjs/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
- package/cjs/domain/rumEventsCollection/longTask/longTaskCollection.js +5 -7
- package/cjs/domain/rumEventsCollection/longTask/longTaskCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/{matchRequestTiming.js → matchRequestResourceEntry.js} +4 -4
- package/cjs/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -0
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +64 -66
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js +18 -14
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +41 -0
- package/cjs/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -0
- package/cjs/domain/rumEventsCollection/view/trackCommonViewMetrics.js +1 -1
- package/cjs/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +8 -5
- package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstContentfulPaint.js +2 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstContentfulPaint.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstHidden.js +1 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstHidden.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstInput.js +2 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstInput.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackInitialViewTimings.js +1 -1
- package/cjs/domain/rumEventsCollection/view/trackInitialViewTimings.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +3 -19
- package/cjs/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackLargestContentfulPaint.js +2 -1
- package/cjs/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackLoadingTime.js +7 -7
- package/cjs/domain/rumEventsCollection/view/trackLoadingTime.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackNavigationTimings.js +50 -25
- package/cjs/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackViewEventCounts.js +1 -22
- package/cjs/domain/rumEventsCollection/view/trackViewEventCounts.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackViews.js +1 -1
- package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/viewCollection.js +1 -0
- package/cjs/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
- package/cjs/domain/waitPageActivityEnd.js +6 -5
- package/cjs/domain/waitPageActivityEnd.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/rum.js +11 -10
- package/esm/boot/rum.js.map +1 -1
- package/esm/domain/assembly.js.map +1 -1
- package/esm/domain/contexts/pageStateHistory.js +5 -2
- package/esm/domain/contexts/pageStateHistory.js.map +1 -1
- package/esm/domain/contexts/urlContexts.js +4 -2
- package/esm/domain/contexts/urlContexts.js.map +1 -1
- package/esm/domain/contexts/viewContexts.js +10 -2
- package/esm/domain/contexts/viewContexts.js.map +1 -1
- package/esm/domain/locationChangeObservable.js +7 -5
- package/esm/domain/locationChangeObservable.js.map +1 -1
- package/esm/domain/performanceCollection.js +41 -89
- package/esm/domain/performanceCollection.js.map +1 -1
- package/esm/domain/performanceObservable.js +105 -0
- package/esm/domain/performanceObservable.js.map +1 -0
- package/esm/domain/performanceUtils.js +14 -0
- package/esm/domain/performanceUtils.js.map +1 -0
- package/esm/domain/replay/deflate/deflateWorker.js +1 -1
- package/esm/domain/replay/record/observers.js +59 -55
- package/esm/domain/replay/record/observers.js.map +1 -1
- package/esm/domain/requestCollection.js +6 -2
- package/esm/domain/requestCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/trackClickActions.js +4 -2
- package/esm/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
- package/esm/domain/rumEventsCollection/longTask/longTaskCollection.js +6 -8
- package/esm/domain/rumEventsCollection/longTask/longTaskCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/{matchRequestTiming.js → matchRequestResourceEntry.js} +5 -5
- package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -0
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js +66 -68
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js +12 -9
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +35 -0
- package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -0
- package/esm/domain/rumEventsCollection/view/trackCommonViewMetrics.js +1 -1
- package/esm/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +9 -7
- package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackFirstContentfulPaint.js +2 -1
- package/esm/domain/rumEventsCollection/view/trackFirstContentfulPaint.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackFirstHidden.js +1 -1
- package/esm/domain/rumEventsCollection/view/trackFirstHidden.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackFirstInput.js +2 -2
- package/esm/domain/rumEventsCollection/view/trackFirstInput.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackInitialViewTimings.js +1 -1
- package/esm/domain/rumEventsCollection/view/trackInitialViewTimings.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +2 -19
- package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackLargestContentfulPaint.js +2 -2
- package/esm/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackLoadingTime.js +7 -7
- package/esm/domain/rumEventsCollection/view/trackLoadingTime.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackNavigationTimings.js +51 -26
- package/esm/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackViewEventCounts.js +1 -21
- package/esm/domain/rumEventsCollection/view/trackViewEventCounts.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackViews.js +1 -1
- package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/viewCollection.js +1 -0
- package/esm/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
- package/esm/domain/waitPageActivityEnd.js +7 -7
- package/esm/domain/waitPageActivityEnd.js.map +1 -1
- package/package.json +4 -4
- package/src/boot/rum.js +18 -9
- package/src/domain/assembly.js +0 -1
- package/src/domain/contexts/pageStateHistory.js +5 -5
- package/src/domain/contexts/urlContexts.js +4 -2
- package/src/domain/contexts/viewContexts.js +10 -3
- package/src/domain/locationChangeObservable.js +17 -7
- package/src/domain/performanceCollection.js +55 -138
- package/src/domain/performanceObservable.js +148 -0
- package/src/domain/performanceUtils.js +16 -0
- package/src/domain/replay/record/observers.js +39 -35
- package/src/domain/requestCollection.js +6 -2
- package/src/domain/rumEventsCollection/actions/trackClickActions.js +4 -2
- package/src/domain/rumEventsCollection/longTask/longTaskCollection.js +7 -8
- package/src/domain/rumEventsCollection/resource/{matchRequestTiming.js → matchRequestResourceEntry.js} +10 -4
- package/src/domain/rumEventsCollection/resource/resourceCollection.js +74 -117
- package/src/domain/rumEventsCollection/resource/resourceUtils.js +13 -11
- package/src/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +45 -0
- package/src/domain/rumEventsCollection/view/trackCommonViewMetrics.js +2 -1
- package/src/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +24 -7
- package/src/domain/rumEventsCollection/view/trackFirstContentfulPaint.js +3 -2
- package/src/domain/rumEventsCollection/view/trackFirstHidden.js +1 -1
- package/src/domain/rumEventsCollection/view/trackFirstInput.js +3 -3
- package/src/domain/rumEventsCollection/view/trackInitialViewTimings.js +1 -1
- package/src/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +7 -19
- package/src/domain/rumEventsCollection/view/trackLargestContentfulPaint.js +4 -3
- package/src/domain/rumEventsCollection/view/trackLoadingTime.js +8 -8
- package/src/domain/rumEventsCollection/view/trackNavigationTimings.js +66 -32
- package/src/domain/rumEventsCollection/view/trackViewEventCounts.js +1 -24
- package/src/domain/rumEventsCollection/view/trackViews.js +1 -1
- package/src/domain/rumEventsCollection/view/viewCollection.js +4 -0
- package/src/domain/waitPageActivityEnd.js +16 -17
- package/cjs/domain/rumEventsCollection/resource/matchRequestTiming.js.map +0 -1
- package/esm/domain/rumEventsCollection/resource/matchRequestTiming.js.map +0 -1
|
@@ -3,41 +3,34 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.retrieveInitialDocumentResourceTiming = retrieveInitialDocumentResourceTiming;
|
|
7
6
|
exports.startPerformanceCollection = startPerformanceCollection;
|
|
8
|
-
exports.supportPerformanceTimingEvent = supportPerformanceTimingEvent;
|
|
9
7
|
var _browserCore = require("@cloudcare/browser-core");
|
|
10
|
-
var
|
|
8
|
+
var _performanceObservable = require("./performanceObservable");
|
|
11
9
|
function supportPerformanceObject() {
|
|
12
10
|
return window.performance !== undefined && 'getEntries' in performance;
|
|
13
11
|
}
|
|
14
|
-
function supportPerformanceTimingEvent(entryType) {
|
|
15
|
-
return window.PerformanceObserver && PerformanceObserver.supportedEntryTypes !== undefined && (0, _browserCore.includes)(PerformanceObserver.supportedEntryTypes, entryType);
|
|
16
|
-
}
|
|
17
12
|
function startPerformanceCollection(lifeCycle, configuration) {
|
|
18
|
-
|
|
19
|
-
handleRumPerformanceEntries(lifeCycle, configuration, [timing]);
|
|
20
|
-
});
|
|
13
|
+
var cleanupTasks = [];
|
|
21
14
|
if (supportPerformanceObject()) {
|
|
22
15
|
var performanceEntries = performance.getEntries();
|
|
23
16
|
// Because the performance entry list can be quite large
|
|
24
17
|
// delay the computation to prevent the SDK from blocking the main thread on init
|
|
25
18
|
(0, _browserCore.setTimeout)(function () {
|
|
26
|
-
handleRumPerformanceEntries(lifeCycle,
|
|
19
|
+
handleRumPerformanceEntries(lifeCycle, performanceEntries);
|
|
27
20
|
});
|
|
28
21
|
}
|
|
29
22
|
if (window.PerformanceObserver) {
|
|
30
23
|
var handlePerformanceEntryList = (0, _browserCore.monitor)(function (entries) {
|
|
31
|
-
handleRumPerformanceEntries(lifeCycle,
|
|
24
|
+
handleRumPerformanceEntries(lifeCycle, entries.getEntries());
|
|
32
25
|
});
|
|
33
|
-
var mainEntries = [
|
|
34
|
-
var experimentalEntries = [
|
|
26
|
+
var mainEntries = [_performanceObservable.RumPerformanceEntryType.LONG_TASK, _performanceObservable.RumPerformanceEntryType.PAINT];
|
|
27
|
+
var experimentalEntries = [_performanceObservable.RumPerformanceEntryType.LARGEST_CONTENTFUL_PAINT, _performanceObservable.RumPerformanceEntryType.FIRST_INPUT, _performanceObservable.RumPerformanceEntryType.LAYOUT_SHIFT, _performanceObservable.RumPerformanceEntryType.EVENT];
|
|
35
28
|
try {
|
|
36
29
|
// Experimental entries are not retrieved by performance.getEntries()
|
|
37
30
|
// use a single PerformanceObserver with buffered flag by type
|
|
38
31
|
// to get values that could happen before SDK init
|
|
39
32
|
(0, _browserCore.each)(experimentalEntries, function (type) {
|
|
40
|
-
var observer = new PerformanceObserver(handlePerformanceEntryList);
|
|
33
|
+
var observer = new window.PerformanceObserver(handlePerformanceEntryList);
|
|
41
34
|
observer.observe({
|
|
42
35
|
type: type,
|
|
43
36
|
buffered: true,
|
|
@@ -45,6 +38,9 @@ function startPerformanceCollection(lifeCycle, configuration) {
|
|
|
45
38
|
// cf: https://github.com/GoogleChrome/web-vitals/blob/3806160ffbc93c3c4abf210a167b81228172b31c/src/onINP.ts#L209
|
|
46
39
|
durationThreshold: 40
|
|
47
40
|
});
|
|
41
|
+
cleanupTasks.push(function () {
|
|
42
|
+
observer.disconnect();
|
|
43
|
+
});
|
|
48
44
|
});
|
|
49
45
|
} catch (e) {
|
|
50
46
|
// Some old browser versions (ex: chrome 67) don't support the PerformanceObserver type and buffered options
|
|
@@ -54,65 +50,36 @@ function startPerformanceCollection(lifeCycle, configuration) {
|
|
|
54
50
|
});
|
|
55
51
|
}
|
|
56
52
|
var mainObserver = new PerformanceObserver(handlePerformanceEntryList);
|
|
57
|
-
mainObserver.observe({
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
// mainObserver.observe({ entryTypes: mainEntries })
|
|
54
|
+
try {
|
|
55
|
+
mainObserver.observe({
|
|
56
|
+
entryTypes: mainEntries
|
|
57
|
+
});
|
|
58
|
+
cleanupTasks.push(function () {
|
|
59
|
+
mainObserver.disconnect();
|
|
60
|
+
});
|
|
61
|
+
} catch (_unused) {}
|
|
60
62
|
if (supportPerformanceObject() && 'addEventListener' in performance) {
|
|
61
63
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1559377
|
|
62
|
-
(0, _browserCore.addEventListener)(performance, 'resourcetimingbufferfull', function () {
|
|
64
|
+
var resourncetimingbufferfullListener = (0, _browserCore.addEventListener)(performance, 'resourcetimingbufferfull', function () {
|
|
63
65
|
performance.clearResourceTimings();
|
|
64
66
|
});
|
|
67
|
+
cleanupTasks.push(resourncetimingbufferfullListener.stop);
|
|
65
68
|
}
|
|
66
69
|
}
|
|
67
|
-
if (!supportPerformanceTimingEvent(
|
|
68
|
-
|
|
69
|
-
handleRumPerformanceEntries(lifeCycle,
|
|
70
|
+
if (!(0, _performanceObservable.supportPerformanceTimingEvent)(_performanceObservable.RumPerformanceEntryType.FIRST_INPUT)) {
|
|
71
|
+
var _retrieveFirstInputTiming = retrieveFirstInputTiming(function (timing) {
|
|
72
|
+
return handleRumPerformanceEntries(lifeCycle, [timing]);
|
|
70
73
|
});
|
|
74
|
+
cleanupTasks.push(_retrieveFirstInputTiming.stop);
|
|
71
75
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
function retrieveInitialDocumentResourceTiming(callback) {
|
|
79
|
-
(0, _browserCore.runOnReadyState)('interactive', function () {
|
|
80
|
-
var timing;
|
|
81
|
-
var forcedAttributes = {
|
|
82
|
-
entryType: 'resource',
|
|
83
|
-
initiatorType: _resourceUtils.FAKE_INITIAL_DOCUMENT,
|
|
84
|
-
traceId: '',
|
|
85
|
-
toJSON: function toJSON() {
|
|
86
|
-
return (0, _browserCore.assign)({}, timing, {
|
|
87
|
-
toJSON: undefined
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
if (supportPerformanceTimingEvent('navigation') && performance.getEntriesByType('navigation').length > 0) {
|
|
92
|
-
var navigationEntry = performance.getEntriesByType('navigation')[0];
|
|
93
|
-
timing = (0, _browserCore.extend)(navigationEntry.toJSON(), forcedAttributes);
|
|
94
|
-
} else {
|
|
95
|
-
var relativePerformanceTiming = computeRelativePerformanceTiming();
|
|
96
|
-
timing = (0, _browserCore.extend)(relativePerformanceTiming, {
|
|
97
|
-
decodedBodySize: 0,
|
|
98
|
-
duration: relativePerformanceTiming.responseEnd,
|
|
99
|
-
name: window.location.href,
|
|
100
|
-
startTime: 0
|
|
101
|
-
}, forcedAttributes);
|
|
76
|
+
return {
|
|
77
|
+
stop: function stop() {
|
|
78
|
+
(0, _browserCore.each)(cleanupTasks, function (task) {
|
|
79
|
+
return task();
|
|
80
|
+
});
|
|
102
81
|
}
|
|
103
|
-
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
function retrieveNavigationTiming(callback) {
|
|
107
|
-
function sendFakeTiming() {
|
|
108
|
-
callback((0, _browserCore.extend)(computeRelativePerformanceTiming(), {
|
|
109
|
-
entryType: 'navigation'
|
|
110
|
-
}));
|
|
111
|
-
}
|
|
112
|
-
(0, _browserCore.runOnReadyState)('complete', function () {
|
|
113
|
-
// Send it a bit after the actual load event, so the "loadEventEnd" timing is accurate
|
|
114
|
-
(0, _browserCore.setTimeout)(sendFakeTiming);
|
|
115
|
-
});
|
|
82
|
+
};
|
|
116
83
|
}
|
|
117
84
|
|
|
118
85
|
/**
|
|
@@ -132,7 +99,7 @@ function retrieveFirstInputTiming(callback) {
|
|
|
132
99
|
// when the system received the event (e.g. evt.timeStamp) and when it could run the callback
|
|
133
100
|
// (e.g. performance.now()).
|
|
134
101
|
var timing = {
|
|
135
|
-
entryType:
|
|
102
|
+
entryType: _performanceObservable.RumPerformanceEntryType.FIRST_INPUT,
|
|
136
103
|
processingStart: (0, _browserCore.relativeNow)(),
|
|
137
104
|
processingEnd: (0, _browserCore.relativeNow)(),
|
|
138
105
|
startTime: evt.timeStamp,
|
|
@@ -149,7 +116,6 @@ function retrieveFirstInputTiming(callback) {
|
|
|
149
116
|
capture: true
|
|
150
117
|
});
|
|
151
118
|
var removeEventListeners = listeners.stop;
|
|
152
|
-
|
|
153
119
|
/**
|
|
154
120
|
* Pointer events are a special case, because they can trigger main or compositor thread behavior.
|
|
155
121
|
* We differenciate these cases based on whether or not we see a pointercancel event, which are
|
|
@@ -180,32 +146,16 @@ function retrieveFirstInputTiming(callback) {
|
|
|
180
146
|
}
|
|
181
147
|
}
|
|
182
148
|
}
|
|
149
|
+
return {
|
|
150
|
+
stop: removeEventListeners
|
|
151
|
+
};
|
|
183
152
|
}
|
|
184
|
-
function
|
|
185
|
-
var
|
|
186
|
-
|
|
187
|
-
for (var key in timing) {
|
|
188
|
-
if ((0, _browserCore.isNumber)(timing[key])) {
|
|
189
|
-
result[key] = timing[key] === 0 ? 0 : (0, _browserCore.getRelativeTime)(timing[key]);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return result;
|
|
193
|
-
}
|
|
194
|
-
function handleRumPerformanceEntries(lifeCycle, configuration, entries) {
|
|
195
|
-
var rumPerformanceEntries = (0, _browserCore.filter)(entries, function (entry) {
|
|
196
|
-
return entry.entryType === 'resource' || entry.entryType === 'navigation' || entry.entryType === 'paint' || entry.entryType === 'longtask' || entry.entryType === 'largest-contentful-paint' || entry.entryType === 'first-input' || entry.entryType === 'layout-shift' || entry.entryType === 'event';
|
|
153
|
+
function handleRumPerformanceEntries(lifeCycle, entries) {
|
|
154
|
+
var rumPerformanceEntries = entries.filter(function (entry) {
|
|
155
|
+
return (0, _browserCore.objectHasValue)(_performanceObservable.RumPerformanceEntryType, entry.entryType);
|
|
197
156
|
});
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
});
|
|
201
|
-
if (rumAllowedPerformanceEntries.length) {
|
|
202
|
-
lifeCycle.notify(_browserCore.LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, rumAllowedPerformanceEntries);
|
|
157
|
+
if (rumPerformanceEntries.length) {
|
|
158
|
+
lifeCycle.notify(_browserCore.LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, rumPerformanceEntries);
|
|
203
159
|
}
|
|
204
160
|
}
|
|
205
|
-
function isIncompleteNavigation(entry) {
|
|
206
|
-
return entry.entryType === 'navigation' && entry.loadEventEnd <= 0;
|
|
207
|
-
}
|
|
208
|
-
function isForbiddenResource(configuration, entry) {
|
|
209
|
-
return entry.entryType === 'resource' && !(0, _resourceUtils.isAllowedRequestUrl)(configuration, entry.name);
|
|
210
|
-
}
|
|
211
161
|
//# sourceMappingURL=performanceCollection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"performanceCollection.js","names":["_browserCore","require","_resourceUtils","supportPerformanceObject","window","performance","undefined","supportPerformanceTimingEvent","entryType","PerformanceObserver","supportedEntryTypes","includes","startPerformanceCollection","lifeCycle","configuration","retrieveInitialDocumentResourceTiming","timing","handleRumPerformanceEntries","performanceEntries","getEntries","setTimeout","handlePerformanceEntryList","monitor","entries","mainEntries","experimentalEntries","each","type","observer","observe","buffered","durationThreshold","e","push","mainObserver","entryTypes","addEventListener","clearResourceTimings","retrieveNavigationTiming","retrieveFirstInputTiming","callback","runOnReadyState","forcedAttributes","initiatorType","FAKE_INITIAL_DOCUMENT","traceId","toJSON","assign","getEntriesByType","length","navigationEntry","extend","relativePerformanceTiming","computeRelativePerformanceTiming","decodedBodySize","duration","responseEnd","name","location","href","startTime","sendFakeTiming","startTimeStamp","dateNow","timingSent","listeners","addEventListeners","DOM_EVENT","CLICK","MOUSE_DOWN","KEY_DOWN","TOUCH_START","POINTER_DOWN","evt","cancelable","processingStart","relativeNow","processingEnd","timeStamp","sendTimingIfPointerIsNotCancelled","sendTiming","passive","capture","removeEventListeners","stop","POINTER_UP","POINTER_CANCEL","event","once","delay","result","key","isNumber","getRelativeTime","rumPerformanceEntries","filter","entry","rumAllowedPerformanceEntries","isIncompleteNavigation","isForbiddenResource","notify","LifeCycleEventType","PERFORMANCE_ENTRIES_COLLECTED","loadEventEnd","isAllowedRequestUrl"],"sources":["../../src/domain/performanceCollection.js"],"sourcesContent":["import {\n addEventListeners,\n getRelativeTime,\n isNumber,\n includes,\n each,\n extend,\n filter,\n dateNow,\n relativeNow,\n DOM_EVENT,\n LifeCycleEventType,\n runOnReadyState,\n setTimeout,\n addEventListener,\n monitor,\n assign\n} from '@cloudcare/browser-core'\nimport {\n FAKE_INITIAL_DOCUMENT,\n isAllowedRequestUrl\n} from './rumEventsCollection/resource/resourceUtils'\nfunction supportPerformanceObject() {\n return window.performance !== undefined && 'getEntries' in performance\n}\n\nexport function supportPerformanceTimingEvent(entryType) {\n return (\n window.PerformanceObserver &&\n PerformanceObserver.supportedEntryTypes !== undefined &&\n includes(PerformanceObserver.supportedEntryTypes, entryType)\n )\n}\nexport function startPerformanceCollection(lifeCycle, configuration) {\n retrieveInitialDocumentResourceTiming(function (timing) {\n handleRumPerformanceEntries(lifeCycle, configuration, [timing])\n })\n\n if (supportPerformanceObject()) {\n var performanceEntries = performance.getEntries()\n // Because the performance entry list can be quite large\n // delay the computation to prevent the SDK from blocking the main thread on init\n setTimeout(function () {\n handleRumPerformanceEntries(lifeCycle, configuration, performanceEntries)\n })\n }\n if (window.PerformanceObserver) {\n var handlePerformanceEntryList = monitor(function (entries) {\n handleRumPerformanceEntries(\n lifeCycle,\n configuration,\n entries.getEntries()\n )\n })\n var mainEntries = ['resource', 'navigation', 'longtask', 'paint']\n var experimentalEntries = [\n 'largest-contentful-paint',\n 'first-input',\n 'layout-shift',\n 'event'\n ]\n try {\n // Experimental entries are not retrieved by performance.getEntries()\n // use a single PerformanceObserver with buffered flag by type\n // to get values that could happen before SDK init\n each(experimentalEntries, function (type) {\n var observer = new PerformanceObserver(handlePerformanceEntryList)\n observer.observe({\n type: type,\n buffered: true,\n // durationThreshold only impact PerformanceEventTiming entries used for INP computation which requires a threshold at 40 (default is 104ms)\n // cf: https://github.com/GoogleChrome/web-vitals/blob/3806160ffbc93c3c4abf210a167b81228172b31c/src/onINP.ts#L209\n durationThreshold: 40\n })\n })\n } catch (e) {\n // Some old browser versions (ex: chrome 67) don't support the PerformanceObserver type and buffered options\n // In these cases, fallback to PerformanceObserver with entryTypes\n each(experimentalEntries, function (type) {\n mainEntries.push(type)\n })\n }\n var mainObserver = new PerformanceObserver(handlePerformanceEntryList)\n mainObserver.observe({ entryTypes: mainEntries })\n if (supportPerformanceObject() && 'addEventListener' in performance) {\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1559377\n addEventListener(performance, 'resourcetimingbufferfull', function () {\n performance.clearResourceTimings()\n })\n }\n }\n if (!supportPerformanceTimingEvent('navigation')) {\n retrieveNavigationTiming(function (timing) {\n handleRumPerformanceEntries(lifeCycle, configuration, [timing])\n })\n }\n if (!supportPerformanceTimingEvent('first-input')) {\n retrieveFirstInputTiming(function (timing) {\n return handleRumPerformanceEntries(lifeCycle, configuration, [timing])\n })\n }\n}\n\nexport function retrieveInitialDocumentResourceTiming(callback) {\n runOnReadyState('interactive', function () {\n var timing\n\n var forcedAttributes = {\n entryType: 'resource',\n initiatorType: FAKE_INITIAL_DOCUMENT,\n traceId: '',\n toJSON: function () {\n return assign({}, timing, { toJSON: undefined })\n }\n }\n if (\n supportPerformanceTimingEvent('navigation') &&\n performance.getEntriesByType('navigation').length > 0\n ) {\n var navigationEntry = performance.getEntriesByType('navigation')[0]\n timing = extend(navigationEntry.toJSON(), forcedAttributes)\n } else {\n var relativePerformanceTiming = computeRelativePerformanceTiming()\n timing = extend(\n relativePerformanceTiming,\n {\n decodedBodySize: 0,\n duration: relativePerformanceTiming.responseEnd,\n name: window.location.href,\n startTime: 0\n },\n forcedAttributes\n )\n }\n callback(timing)\n })\n}\n\nfunction retrieveNavigationTiming(callback) {\n function sendFakeTiming() {\n callback(\n extend(computeRelativePerformanceTiming(), { entryType: 'navigation' })\n )\n }\n\n runOnReadyState('complete', function () {\n // Send it a bit after the actual load event, so the \"loadEventEnd\" timing is accurate\n setTimeout(sendFakeTiming)\n })\n}\n\n/**\n * first-input timing entry polyfill based on\n * https://github.com/GoogleChrome/web-vitals/blob/master/src/lib/polyfills/firstInputPolyfill.ts\n */\nfunction retrieveFirstInputTiming(callback) {\n var startTimeStamp = dateNow()\n var timingSent = false\n\n var listeners = addEventListeners(\n window,\n [\n DOM_EVENT.CLICK,\n DOM_EVENT.MOUSE_DOWN,\n DOM_EVENT.KEY_DOWN,\n DOM_EVENT.TOUCH_START,\n DOM_EVENT.POINTER_DOWN\n ],\n function (evt) {\n // Only count cancelable events, which should trigger behavior important to the user.\n if (!evt.cancelable) {\n return\n }\n\n // This timing will be used to compute the \"first Input delay\", which is the delta between\n // when the system received the event (e.g. evt.timeStamp) and when it could run the callback\n // (e.g. performance.now()).\n var timing = {\n entryType: 'first-input',\n processingStart: relativeNow(),\n processingEnd: relativeNow(),\n startTime: evt.timeStamp,\n duration: 0,\n name: ''\n }\n\n if (evt.type === DOM_EVENT.POINTER_DOWN) {\n sendTimingIfPointerIsNotCancelled(timing)\n } else {\n sendTiming(timing)\n }\n },\n { passive: true, capture: true }\n )\n var removeEventListeners = listeners.stop\n\n /**\n * Pointer events are a special case, because they can trigger main or compositor thread behavior.\n * We differenciate these cases based on whether or not we see a pointercancel event, which are\n * fired when we scroll. If we're scrolling we don't need to report input delay since FID excludes\n * scrolling and pinch/zooming.\n */\n function sendTimingIfPointerIsNotCancelled(timing) {\n addEventListeners(\n window,\n [DOM_EVENT.POINTER_UP, DOM_EVENT.POINTER_CANCEL],\n function (event) {\n if (event.type === DOM_EVENT.POINTER_UP) {\n sendTiming(timing)\n }\n },\n { once: true }\n )\n }\n\n function sendTiming(timing) {\n if (!timingSent) {\n timingSent = true\n removeEventListeners()\n // In some cases the recorded delay is clearly wrong, e.g. it's negative or it's larger than\n // the time between now and when the page was loaded.\n // - https://github.com/GoogleChromeLabs/first-input-delay/issues/4\n // - https://github.com/GoogleChromeLabs/first-input-delay/issues/6\n // - https://github.com/GoogleChromeLabs/first-input-delay/issues/7\n var delay = timing.processingStart - timing.startTime\n if (delay >= 0 && delay < dateNow() - startTimeStamp) {\n callback(timing)\n }\n }\n }\n}\n\nfunction computeRelativePerformanceTiming() {\n var result = {}\n var timing = performance.timing\n for (var key in timing) {\n if (isNumber(timing[key])) {\n result[key] = timing[key] === 0 ? 0 : getRelativeTime(timing[key])\n }\n }\n return result\n}\n\nfunction handleRumPerformanceEntries(lifeCycle, configuration, entries) {\n var rumPerformanceEntries = filter(entries, function (entry) {\n return (\n entry.entryType === 'resource' ||\n entry.entryType === 'navigation' ||\n entry.entryType === 'paint' ||\n entry.entryType === 'longtask' ||\n entry.entryType === 'largest-contentful-paint' ||\n entry.entryType === 'first-input' ||\n entry.entryType === 'layout-shift' ||\n entry.entryType === 'event'\n )\n })\n\n var rumAllowedPerformanceEntries = filter(\n rumPerformanceEntries,\n function (entry) {\n return (\n !isIncompleteNavigation(entry) &&\n !isForbiddenResource(configuration, entry)\n )\n }\n )\n\n if (rumAllowedPerformanceEntries.length) {\n lifeCycle.notify(\n LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED,\n rumAllowedPerformanceEntries\n )\n }\n}\n\nfunction isIncompleteNavigation(entry) {\n return entry.entryType === 'navigation' && entry.loadEventEnd <= 0\n}\n\nfunction isForbiddenResource(configuration, entry) {\n return (\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,KAAK,CAACxF,SAAS,KAAK,OAAO,IAC3BwF,KAAK,CAACxF,SAAS,KAAK,UAAU,IAC9BwF,KAAK,CAACxF,SAAS,KAAK,0BAA0B,IAC9CwF,KAAK,CAACxF,SAAS,KAAK,aAAa,IACjCwF,KAAK,CAACxF,SAAS,KAAK,cAAc,IAClCwF,KAAK,CAACxF,SAAS,KAAK,OAAO;EAE/B,CAAC,CAAC;EAEF,IAAIyF,4BAA4B,GAAG,IAAAF,mBAAM,EACvCD,qBAAqB,EACrB,UAAUE,KAAK,EAAE;IACf,OACE,CAACE,sBAAsB,CAACF,KAAK,CAAC,IAC9B,CAACG,mBAAmB,CAACrF,aAAa,EAAEkF,KAAK,CAAC;EAE9C,CACF,CAAC;EAED,IAAIC,4BAA4B,CAAChD,MAAM,EAAE;IACvCpC,SAAS,CAACuF,MAAM,CACdC,+BAAkB,CAACC,6BAA6B,EAChDL,4BACF,CAAC;EACH;AACF;AAEA,SAASC,sBAAsBA,CAACF,KAAK,EAAE;EACrC,OAAOA,KAAK,CAACxF,SAAS,KAAK,YAAY,IAAIwF,KAAK,CAACO,YAAY,IAAI,CAAC;AACpE;AAEA,SAASJ,mBAAmBA,CAACrF,aAAa,EAAEkF,KAAK,EAAE;EACjD,OACEA,KAAK,CAACxF,SAAS,KAAK,UAAU,IAC9B,CAAC,IAAAgG,kCAAmB,EAAC1F,aAAa,EAAEkF,KAAK,CAACvC,IAAI,CAAC;AAEnD","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"performanceCollection.js","names":["_browserCore","require","_performanceObservable","supportPerformanceObject","window","performance","undefined","startPerformanceCollection","lifeCycle","configuration","cleanupTasks","performanceEntries","getEntries","setTimeout","handleRumPerformanceEntries","PerformanceObserver","handlePerformanceEntryList","monitor","entries","mainEntries","RumPerformanceEntryType","LONG_TASK","PAINT","experimentalEntries","LARGEST_CONTENTFUL_PAINT","FIRST_INPUT","LAYOUT_SHIFT","EVENT","each","type","observer","observe","buffered","durationThreshold","push","disconnect","e","mainObserver","entryTypes","_unused","resourncetimingbufferfullListener","addEventListener","clearResourceTimings","stop","supportPerformanceTimingEvent","_retrieveFirstInputTiming","retrieveFirstInputTiming","timing","task","callback","startTimeStamp","dateNow","timingSent","listeners","addEventListeners","DOM_EVENT","CLICK","MOUSE_DOWN","KEY_DOWN","TOUCH_START","POINTER_DOWN","evt","cancelable","entryType","processingStart","relativeNow","processingEnd","startTime","timeStamp","duration","name","sendTimingIfPointerIsNotCancelled","sendTiming","passive","capture","removeEventListeners","POINTER_UP","POINTER_CANCEL","event","once","delay","rumPerformanceEntries","filter","entry","objectHasValue","length","notify","LifeCycleEventType","PERFORMANCE_ENTRIES_COLLECTED"],"sources":["../../src/domain/performanceCollection.js"],"sourcesContent":["import {\n addEventListeners,\n each,\n dateNow,\n relativeNow,\n DOM_EVENT,\n LifeCycleEventType,\n setTimeout,\n addEventListener,\n monitor,\n objectHasValue\n} from '@cloudcare/browser-core'\n\nimport {\n RumPerformanceEntryType,\n supportPerformanceTimingEvent\n} from './performanceObservable'\nfunction supportPerformanceObject() {\n return window.performance !== undefined && 'getEntries' in performance\n}\n\nexport function startPerformanceCollection(lifeCycle, configuration) {\n var cleanupTasks = []\n if (supportPerformanceObject()) {\n var performanceEntries = performance.getEntries()\n // Because the performance entry list can be quite large\n // delay the computation to prevent the SDK from blocking the main thread on init\n setTimeout(function () {\n handleRumPerformanceEntries(lifeCycle, performanceEntries)\n })\n }\n if (window.PerformanceObserver) {\n var handlePerformanceEntryList = monitor(function (entries) {\n handleRumPerformanceEntries(lifeCycle, entries.getEntries())\n })\n var mainEntries = [\n RumPerformanceEntryType.LONG_TASK,\n RumPerformanceEntryType.PAINT\n ]\n var experimentalEntries = [\n RumPerformanceEntryType.LARGEST_CONTENTFUL_PAINT,\n RumPerformanceEntryType.FIRST_INPUT,\n RumPerformanceEntryType.LAYOUT_SHIFT,\n RumPerformanceEntryType.EVENT\n ]\n try {\n // Experimental entries are not retrieved by performance.getEntries()\n // use a single PerformanceObserver with buffered flag by type\n // to get values that could happen before SDK init\n each(experimentalEntries, function (type) {\n var observer = new window.PerformanceObserver(\n handlePerformanceEntryList\n )\n observer.observe({\n type: type,\n buffered: true,\n // durationThreshold only impact PerformanceEventTiming entries used for INP computation which requires a threshold at 40 (default is 104ms)\n // cf: https://github.com/GoogleChrome/web-vitals/blob/3806160ffbc93c3c4abf210a167b81228172b31c/src/onINP.ts#L209\n durationThreshold: 40\n })\n cleanupTasks.push(function () {\n observer.disconnect()\n })\n })\n } catch (e) {\n // Some old browser versions (ex: chrome 67) don't support the PerformanceObserver type and buffered options\n // In these cases, fallback to PerformanceObserver with entryTypes\n each(experimentalEntries, function (type) {\n mainEntries.push(type)\n })\n }\n var mainObserver = new PerformanceObserver(handlePerformanceEntryList)\n // mainObserver.observe({ entryTypes: mainEntries })\n try {\n mainObserver.observe({ entryTypes: mainEntries })\n cleanupTasks.push(function () {\n mainObserver.disconnect()\n })\n } catch {}\n if (supportPerformanceObject() && 'addEventListener' in performance) {\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1559377\n var resourncetimingbufferfullListener = addEventListener(\n performance,\n 'resourcetimingbufferfull',\n function () {\n performance.clearResourceTimings()\n }\n )\n cleanupTasks.push(resourncetimingbufferfullListener.stop)\n }\n }\n\n if (!supportPerformanceTimingEvent(RumPerformanceEntryType.FIRST_INPUT)) {\n var _retrieveFirstInputTiming = retrieveFirstInputTiming(function (timing) {\n return handleRumPerformanceEntries(lifeCycle, [timing])\n })\n cleanupTasks.push(_retrieveFirstInputTiming.stop)\n }\n return {\n stop: function () {\n each(cleanupTasks, function (task) {\n return task()\n })\n }\n }\n}\n\n/**\n * first-input timing entry polyfill based on\n * https://github.com/GoogleChrome/web-vitals/blob/master/src/lib/polyfills/firstInputPolyfill.ts\n */\nfunction retrieveFirstInputTiming(callback) {\n var startTimeStamp = dateNow()\n var timingSent = false\n\n var listeners = addEventListeners(\n window,\n [\n DOM_EVENT.CLICK,\n DOM_EVENT.MOUSE_DOWN,\n DOM_EVENT.KEY_DOWN,\n DOM_EVENT.TOUCH_START,\n DOM_EVENT.POINTER_DOWN\n ],\n function (evt) {\n // Only count cancelable events, which should trigger behavior important to the user.\n if (!evt.cancelable) {\n return\n }\n\n // This timing will be used to compute the \"first Input delay\", which is the delta between\n // when the system received the event (e.g. evt.timeStamp) and when it could run the callback\n // (e.g. performance.now()).\n var timing = {\n entryType: RumPerformanceEntryType.FIRST_INPUT,\n processingStart: relativeNow(),\n processingEnd: relativeNow(),\n startTime: evt.timeStamp,\n duration: 0,\n name: ''\n }\n\n if (evt.type === DOM_EVENT.POINTER_DOWN) {\n sendTimingIfPointerIsNotCancelled(timing)\n } else {\n sendTiming(timing)\n }\n },\n { passive: true, capture: true }\n )\n var removeEventListeners = listeners.stop\n /**\n * Pointer events are a special case, because they can trigger main or compositor thread behavior.\n * We differenciate these cases based on whether or not we see a pointercancel event, which are\n * fired when we scroll. If we're scrolling we don't need to report input delay since FID excludes\n * scrolling and pinch/zooming.\n */\n function sendTimingIfPointerIsNotCancelled(timing) {\n addEventListeners(\n window,\n [DOM_EVENT.POINTER_UP, DOM_EVENT.POINTER_CANCEL],\n function (event) {\n if (event.type === DOM_EVENT.POINTER_UP) {\n sendTiming(timing)\n }\n },\n { once: true }\n )\n }\n\n function sendTiming(timing) {\n if (!timingSent) {\n timingSent = true\n removeEventListeners()\n // In some cases the recorded delay is clearly wrong, e.g. it's negative or it's larger than\n // the time between now and when the page was loaded.\n // - https://github.com/GoogleChromeLabs/first-input-delay/issues/4\n // - https://github.com/GoogleChromeLabs/first-input-delay/issues/6\n // - https://github.com/GoogleChromeLabs/first-input-delay/issues/7\n var delay = timing.processingStart - timing.startTime\n if (delay >= 0 && delay < dateNow() - startTimeStamp) {\n callback(timing)\n }\n }\n }\n return {\n stop: removeEventListeners\n }\n}\n\nfunction handleRumPerformanceEntries(lifeCycle, entries) {\n var rumPerformanceEntries = entries.filter(function (entry) {\n return objectHasValue(RumPerformanceEntryType, entry.entryType)\n })\n\n if (rumPerformanceEntries.length) {\n lifeCycle.notify(\n LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED,\n rumPerformanceEntries\n )\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAaA,IAAAC,sBAAA,GAAAD,OAAA;AAIA,SAASE,wBAAwBA,CAAA,EAAG;EAClC,OAAOC,MAAM,CAACC,WAAW,KAAKC,SAAS,IAAI,YAAY,IAAID,WAAW;AACxE;AAEO,SAASE,0BAA0BA,CAACC,SAAS,EAAEC,aAAa,EAAE;EACnE,IAAIC,YAAY,GAAG,EAAE;EACrB,IAAIP,wBAAwB,CAAC,CAAC,EAAE;IAC9B,IAAIQ,kBAAkB,GAAGN,WAAW,CAACO,UAAU,CAAC,CAAC;IACjD;IACA;IACA,IAAAC,uBAAU,EAAC,YAAY;MACrBC,2BAA2B,CAACN,SAAS,EAAEG,kBAAkB,CAAC;IAC5D,CAAC,CAAC;EACJ;EACA,IAAIP,MAAM,CAACW,mBAAmB,EAAE;IAC9B,IAAIC,0BAA0B,GAAG,IAAAC,oBAAO,EAAC,UAAUC,OAAO,EAAE;MAC1DJ,2BAA2B,CAACN,SAAS,EAAEU,OAAO,CAACN,UAAU,CAAC,CAAC,CAAC;IAC9D,CAAC,CAAC;IACF,IAAIO,WAAW,GAAG,CAChBC,8CAAuB,CAACC,SAAS,EACjCD,8CAAuB,CAACE,KAAK,CAC9B;IACD,IAAIC,mBAAmB,GAAG,CACxBH,8CAAuB,CAACI,wBAAwB,EAChDJ,8CAAuB,CAACK,WAAW,EACnCL,8CAAuB,CAACM,YAAY,EACpCN,8CAAuB,CAACO,KAAK,CAC9B;IACD,IAAI;MACF;MACA;MACA;MACA,IAAAC,iBAAI,EAACL,mBAAmB,EAAE,UAAUM,IAAI,EAAE;QACxC,IAAIC,QAAQ,GAAG,IAAI1B,MAAM,CAACW,mBAAmB,CAC3CC,0BACF,CAAC;QACDc,QAAQ,CAACC,OAAO,CAAC;UACfF,IAA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AM,EAAE;IACjD,IAAAO,8BAAiB,EACflD,MAAM,EACN,CAACmD,sBAAS,CAACqB,UAAU,EAAErB,sBAAS,CAACsB,cAAc,CAAC,EAChD,UAAUC,KAAK,EAAE;MACf,IAAIA,KAAK,CAACjD,IAAI,KAAK0B,sBAAS,CAACqB,UAAU,EAAE;QACvCJ,UAAU,CAACzB,MAAM,CAAC;MACpB;IACF,CAAC,EACD;MAAEgC,IAAI,EAAE;IAAK,CACf,CAAC;EACH;EAEA,SAASP,UAAUA,CAACzB,MAAM,EAAE;IAC1B,IAAI,CAACK,UAAU,EAAE;MACfA,UAAU,GAAG,IAAI;MACjBuB,oBAAoB,CAAC,CAAC;MACtB;MACA;MACA;MACA;MACA;MACA,IAAIK,KAAK,GAAGjC,MAAM,CAACiB,eAAe,GAAGjB,MAAM,CAACoB,SAAS;MACrD,IAAIa,KAAK,IAAI,CAAC,IAAIA,KAAK,GAAG,IAAA7B,oBAAO,EAAC,CAAC,GAAGD,cAAc,EAAE;QACpDD,QAAQ,CAACF,MAAM,CAAC;MAClB;IACF;EACF;EACA,OAAO;IACLJ,IAAI,EAAEgC;EACR,CAAC;AACH;AAEA,SAAS7D,2BAA2BA,CAACN,SAAS,EAAEU,OAAO,EAAE;EACvD,IAAI+D,qBAAqB,GAAG/D,OAAO,CAACgE,MAAM,CAAC,UAAUC,KAAK,EAAE;IAC1D,OAAO,IAAAC,2BAAc,EAAChE,8CAAuB,EAAE+D,KAAK,CAACpB,SAAS,CAAC;EACjE,CAAC,CAAC;EAEF,IAAIkB,qBAAqB,CAACI,MAAM,EAAE;IAChC7E,SAAS,CAAC8E,MAAM,CACdC,+BAAkB,CAACC,6BAA6B,EAChDP,qBACF,CAAC;EACH;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RumPerformanceEntryType = void 0;
|
|
7
|
+
exports.createPerformanceObservable = createPerformanceObservable;
|
|
8
|
+
exports.supportPerformanceTimingEvent = supportPerformanceTimingEvent;
|
|
9
|
+
var _browserCore = require("@cloudcare/browser-core");
|
|
10
|
+
var _resourceUtils = require("./rumEventsCollection/resource/resourceUtils");
|
|
11
|
+
// We want to use a real enum (i.e. not a const enum) here, to be able to check whether an arbitrary
|
|
12
|
+
// string is an expected performance entry
|
|
13
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
14
|
+
var RumPerformanceEntryType = {
|
|
15
|
+
EVENT: 'event',
|
|
16
|
+
FIRST_INPUT: 'first-input',
|
|
17
|
+
LARGEST_CONTENTFUL_PAINT: 'largest-contentful-paint',
|
|
18
|
+
LAYOUT_SHIFT: 'layout-shift',
|
|
19
|
+
LONG_TASK: 'longtask',
|
|
20
|
+
LONG_ANIMATION_FRAME: 'long-animation-frame',
|
|
21
|
+
NAVIGATION: 'navigation',
|
|
22
|
+
PAINT: 'paint',
|
|
23
|
+
RESOURCE: 'resource'
|
|
24
|
+
};
|
|
25
|
+
exports.RumPerformanceEntryType = RumPerformanceEntryType;
|
|
26
|
+
function createPerformanceObservable(configuration, options) {
|
|
27
|
+
return new _browserCore.Observable(function (observable) {
|
|
28
|
+
if (!window.PerformanceObserver) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
var handlePerformanceEntries = function handlePerformanceEntries(entries) {
|
|
32
|
+
var rumPerformanceEntries = filterRumPerformanceEntries(configuration, entries);
|
|
33
|
+
if (rumPerformanceEntries.length > 0) {
|
|
34
|
+
observable.notify(rumPerformanceEntries);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var timeoutId;
|
|
38
|
+
var isObserverInitializing = true;
|
|
39
|
+
var observer = new PerformanceObserver((0, _browserCore.monitor)(function (entries) {
|
|
40
|
+
// In Safari the performance observer callback is synchronous.
|
|
41
|
+
// Because the buffered performance entry list can be quite large we delay the computation to prevent the SDK from blocking the main thread on init
|
|
42
|
+
if (isObserverInitializing) {
|
|
43
|
+
timeoutId = (0, _browserCore.setTimeout)(function () {
|
|
44
|
+
handlePerformanceEntries(entries.getEntries());
|
|
45
|
+
});
|
|
46
|
+
} else {
|
|
47
|
+
handlePerformanceEntries(entries.getEntries());
|
|
48
|
+
}
|
|
49
|
+
}));
|
|
50
|
+
try {
|
|
51
|
+
observer.observe(options);
|
|
52
|
+
} catch (_unused) {
|
|
53
|
+
// Some old browser versions (<= chrome 74 ) don't support the PerformanceObserver type and buffered options
|
|
54
|
+
// In these cases, fallback to getEntriesByType and PerformanceObserver with entryTypes
|
|
55
|
+
// TODO: remove this fallback in the next major version
|
|
56
|
+
var fallbackSupportedEntryTypes = [RumPerformanceEntryType.RESOURCE, RumPerformanceEntryType.NAVIGATION, RumPerformanceEntryType.LONG_TASK, RumPerformanceEntryType.PAINT];
|
|
57
|
+
if ((0, _browserCore.includes)(fallbackSupportedEntryTypes, options.type)) {
|
|
58
|
+
if (options.buffered) {
|
|
59
|
+
timeoutId = (0, _browserCore.setTimeout)(function () {
|
|
60
|
+
handlePerformanceEntries(performance.getEntriesByType(options.type));
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
observer.observe({
|
|
65
|
+
entryTypes: [options.type]
|
|
66
|
+
});
|
|
67
|
+
} catch (_unused2) {
|
|
68
|
+
// Old versions of Safari are throwing "entryTypes contained only unsupported types"
|
|
69
|
+
// errors when observing only unsupported entry types.
|
|
70
|
+
//
|
|
71
|
+
// We could use `supportPerformanceTimingEvent` to make sure we don't invoke
|
|
72
|
+
// `observer.observe` with an unsupported entry type, but Safari 11 and 12 don't support
|
|
73
|
+
// `Performance.supportedEntryTypes`, so doing so would lose support for these versions
|
|
74
|
+
// even if they do support the entry type.
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
isObserverInitializing = false;
|
|
80
|
+
manageResourceTimingBufferFull(configuration);
|
|
81
|
+
return function () {
|
|
82
|
+
observer.disconnect();
|
|
83
|
+
(0, _browserCore.clearTimeout)(timeoutId);
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
var resourceTimingBufferFullListener;
|
|
88
|
+
function manageResourceTimingBufferFull(configuration) {
|
|
89
|
+
if (!resourceTimingBufferFullListener && supportPerformanceObject() && 'addEventListener' in performance) {
|
|
90
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=1559377
|
|
91
|
+
resourceTimingBufferFullListener = (0, _browserCore.addEventListener)(performance, 'resourcetimingbufferfull', function () {
|
|
92
|
+
performance.clearResourceTimings();
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return function () {
|
|
96
|
+
resourceTimingBufferFullListener && resourceTimingBufferFullListener.stop();
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function supportPerformanceObject() {
|
|
100
|
+
return window.performance !== undefined && 'getEntries' in performance;
|
|
101
|
+
}
|
|
102
|
+
function supportPerformanceTimingEvent(entryType) {
|
|
103
|
+
return window.PerformanceObserver && PerformanceObserver.supportedEntryTypes !== undefined && PerformanceObserver.supportedEntryTypes.includes(entryType);
|
|
104
|
+
}
|
|
105
|
+
function filterRumPerformanceEntries(configuration, entries) {
|
|
106
|
+
return entries.filter(function (entry) {
|
|
107
|
+
return !isForbiddenResource(configuration, entry);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function isForbiddenResource(configuration, entry) {
|
|
111
|
+
return entry.entryType === RumPerformanceEntryType.RESOURCE && (!(0, _resourceUtils.isAllowedRequestUrl)(configuration, entry.name) || !(0, _resourceUtils.hasValidResourceEntryDuration)(entry));
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=performanceObservable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performanceObservable.js","names":["_browserCore","require","_resourceUtils","RumPerformanceEntryType","EVENT","FIRST_INPUT","LARGEST_CONTENTFUL_PAINT","LAYOUT_SHIFT","LONG_TASK","LONG_ANIMATION_FRAME","NAVIGATION","PAINT","RESOURCE","exports","createPerformanceObservable","configuration","options","Observable","observable","window","PerformanceObserver","handlePerformanceEntries","entries","rumPerformanceEntries","filterRumPerformanceEntries","length","notify","timeoutId","isObserverInitializing","observer","monitor","setTimeout","getEntries","observe","_unused","fallbackSupportedEntryTypes","includes","type","buffered","performance","getEntriesByType","entryTypes","_unused2","manageResourceTimingBufferFull","disconnect","clearTimeout","resourceTimingBufferFullListener","supportPerformanceObject","addEventListener","clearResourceTimings","stop","undefined","supportPerformanceTimingEvent","entryType","supportedEntryTypes","filter","entry","isForbiddenResource","isAllowedRequestUrl","name","hasValidResourceEntryDuration"],"sources":["../../src/domain/performanceObservable.js"],"sourcesContent":["import {\n addEventListener,\n Observable,\n setTimeout,\n clearTimeout,\n monitor,\n includes\n} from '@cloudcare/browser-core'\nimport {\n isAllowedRequestUrl,\n hasValidResourceEntryDuration\n} from './rumEventsCollection/resource/resourceUtils'\n\n// We want to use a real enum (i.e. not a const enum) here, to be able to check whether an arbitrary\n// string is an expected performance entry\n// eslint-disable-next-line no-restricted-syntax\nexport var RumPerformanceEntryType = {\n EVENT: 'event',\n FIRST_INPUT: 'first-input',\n LARGEST_CONTENTFUL_PAINT: 'largest-contentful-paint',\n LAYOUT_SHIFT: 'layout-shift',\n LONG_TASK: 'longtask',\n LONG_ANIMATION_FRAME: 'long-animation-frame',\n NAVIGATION: 'navigation',\n PAINT: 'paint',\n RESOURCE: 'resource'\n}\n\nexport function createPerformanceObservable(configuration, options) {\n return new Observable(function (observable) {\n if (!window.PerformanceObserver) {\n return\n }\n\n var handlePerformanceEntries = function (entries) {\n var rumPerformanceEntries = filterRumPerformanceEntries(\n configuration,\n entries\n )\n if (rumPerformanceEntries.length > 0) {\n observable.notify(rumPerformanceEntries)\n }\n }\n\n var timeoutId\n var isObserverInitializing = true\n const observer = new PerformanceObserver(\n monitor(function (entries) {\n // In Safari the performance observer callback is synchronous.\n // Because the buffered performance entry list can be quite large we delay the computation to prevent the SDK from blocking the main thread on init\n if (isObserverInitializing) {\n timeoutId = setTimeout(function () {\n handlePerformanceEntries(entries.getEntries())\n })\n } else {\n handlePerformanceEntries(entries.getEntries())\n }\n })\n )\n try {\n observer.observe(options)\n } catch {\n // Some old browser versions (<= chrome 74 ) don't support the PerformanceObserver type and buffered options\n // In these cases, fallback to getEntriesByType and PerformanceObserver with entryTypes\n // TODO: remove this fallback in the next major version\n var fallbackSupportedEntryTypes = [\n RumPerformanceEntryType.RESOURCE,\n RumPerformanceEntryType.NAVIGATION,\n RumPerformanceEntryType.LONG_TASK,\n RumPerformanceEntryType.PAINT\n ]\n if (includes(fallbackSupportedEntryTypes, options.type)) {\n if (options.buffered) {\n timeoutId = setTimeout(function () {\n handlePerformanceEntries(performance.getEntriesByType(options.type))\n })\n }\n try {\n observer.observe({ entryTypes: [options.type] })\n } catch {\n // Old versions of Safari are throwing \"entryTypes contained only unsupported types\"\n // errors when observing only unsupported entry types.\n //\n // We could use `supportPerformanceTimingEvent` to make sure we don't invoke\n // `observer.observe` with an unsupported entry type, but Safari 11 and 12 don't support\n // `Performance.supportedEntryTypes`, so doing so would lose support for these versions\n // even if they do support the entry type.\n return\n }\n }\n }\n isObserverInitializing = false\n\n manageResourceTimingBufferFull(configuration)\n\n return function () {\n observer.disconnect()\n clearTimeout(timeoutId)\n }\n })\n}\n\nvar resourceTimingBufferFullListener\nfunction manageResourceTimingBufferFull(configuration) {\n if (\n !resourceTimingBufferFullListener &&\n supportPerformanceObject() &&\n 'addEventListener' in performance\n ) {\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1559377\n resourceTimingBufferFullListener = addEventListener(\n performance,\n 'resourcetimingbufferfull',\n function () {\n performance.clearResourceTimings()\n }\n )\n }\n return function () {\n resourceTimingBufferFullListener && resourceTimingBufferFullListener.stop()\n }\n}\n\nfunction supportPerformanceObject() {\n return window.performance !== undefined && 'getEntries' in performance\n}\n\nexport function supportPerformanceTimingEvent(entryType) {\n return (\n window.PerformanceObserver &&\n PerformanceObserver.supportedEntryTypes !== undefined &&\n PerformanceObserver.supportedEntryTypes.includes(entryType)\n )\n}\n\nfunction filterRumPerformanceEntries(configuration, entries) {\n return entries.filter(function (entry) {\n return !isForbiddenResource(configuration, entry)\n })\n}\n\nfunction isForbiddenResource(configuration, entry) {\n return (\n entry.entryType === RumPerformanceEntryType.RESOURCE &&\n (!isAllowedRequestUrl(configuration, entry.name) ||\n !hasValidResourceEntryDuration(entry))\n )\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAQA,IAAAC,cAAA,GAAAD,OAAA;AAKA;AACA;AACA;AACO,IAAIE,uBAAuB,GAAG;EACnCC,KAAK,EAAE,OAAO;EACdC,WAAW,EAAE,aAAa;EAC1BC,wBAAwB,EAAE,0BAA0B;EACpDC,YAAY,EAAE,cAAc;EAC5BC,SAAS,EAAE,UAAU;EACrBC,oBAAoB,EAAE,sBAAsB;EAC5CC,UAAU,EAAE,YAAY;EACxBC,KAAK,EAAE,OAAO;EACdC,QAAQ,EAAE;AACZ,CAAC;AAAAC,OAAA,CAAAV,uBAAA,GAAAA,uBAAA;AAEM,SAASW,2BAA2BA,CAACC,aAAa,EAAEC,OAAO,EAAE;EAClE,OAAO,IAAIC,uBAAU,CAAC,UAAUC,UAAU,EAAE;IAC1C,IAAI,CAACC,MAAM,CAACC,mBAAmB,EAAE;MAC/B;IACF;IAEA,IAAIC,wBAAwB,GAAG,SAA3BA,wBAAwBA,CAAaC,OAAO,EAAE;MAChD,IAAIC,qBAAqB,GAAGC,2BAA2B,CACrDT,aAAa,EACbO,OACF,CAAC;MACD,IAAIC,qBAAqB,CAACE,MAAM,GAAG,CAAC,EAAE;QACpCP,UAAU,CAACQ,MAAM,CAACH,qBAAqB,CAAC;MAC1C;IACF,CAAC;IAED,IAAII,SAAS;IACb,IAAIC,sBAAsB,GAAG,IAAI;IACjC,IAAMC,QAAQ,GAAG,IAAIT,mBAAmB,C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ty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.computeRelativePerformanceTiming = computeRelativePerformanceTiming;
|
|
7
|
+
var _browserCore = require("@cloudcare/browser-core");
|
|
8
|
+
function computeRelativePerformanceTiming() {
|
|
9
|
+
var result = {};
|
|
10
|
+
var timing = performance.timing;
|
|
11
|
+
for (var key in timing) {
|
|
12
|
+
if ((0, _browserCore.isNumber)(timing[key])) {
|
|
13
|
+
var numberKey = key;
|
|
14
|
+
var timingElement = timing[numberKey];
|
|
15
|
+
result[numberKey] = timingElement === 0 ? 0 : (0, _browserCore.getRelativeTime)(timingElement);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=performanceUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performanceUtils.js","names":["_browserCore","require","computeRelativePerformanceTiming","result","timing","performance","key","isNumber","numberKey","timingElement","getRelativeTime"],"sources":["../../src/domain/performanceUtils.js"],"sourcesContent":["import { getRelativeTime, isNumber } from '@cloudcare/browser-core'\n\nexport function computeRelativePerformanceTiming() {\n var result = {}\n var timing = performance.timing\n\n for (var key in timing) {\n if (isNumber(timing[key])) {\n var numberKey = key\n var timingElement = timing[numberKey]\n result[numberKey] =\n timingElement === 0 ? 0 : getRelativeTime(timingElement)\n }\n }\n return result\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,SAASC,gCAAgCA,CAAA,EAAG;EACjD,IAAIC,MAAM,GAAG,CAAC,CAAC;EACf,IAAIC,MAAM,GAAGC,WAAW,CAACD,MAAM;EAE/B,KAAK,IAAIE,GAAG,IAAIF,MAAM,EAAE;IACtB,IAAI,IAAAG,qBAAQ,EAACH,MAAM,CAACE,GAAG,CAAC,CAAC,EAAE;MACzB,IAAIE,SAAS,GAAGF,GAAG;MACnB,IAAIG,aAAa,GAAGL,MAAM,CAACI,SAAS,CAAC;MACrCL,MAAM,CAACK,SAAS,CAAC,GACfC,aAAa,KAAK,CAAC,GAAG,CAAC,GAAG,IAAAC,4BAAe,EAACD,aAAa,CAAC;IAC5D;EACF;EACA,OAAON,MAAM;AACf","ignoreList":[]}
|
|
@@ -13,7 +13,7 @@ var _browserCore = require("@cloudcare/browser-core");
|
|
|
13
13
|
var INITIALIZATION_TIME_OUT_DELAY = 10 * _browserCore.ONE_SECOND;
|
|
14
14
|
exports.INITIALIZATION_TIME_OUT_DELAY = INITIALIZATION_TIME_OUT_DELAY;
|
|
15
15
|
function createDeflateWorker() {
|
|
16
|
-
return new Worker(URL.createObjectURL(new Blob(["!function(){\"use strict\";function t(t,a){var n=\"undefined\"!=typeof Symbol&&t[Symbol.iterator]||t[\"@@iterator\"];if(!n){if(Array.isArray(t)||(n=function(t,a){if(!t)return;if(\"string\"==typeof t)return e(t,a);var n=Object.prototype.toString.call(t).slice(8,-1);\"Object\"===n&&t.constructor&&(n=t.constructor.name);if(\"Map\"===n||\"Set\"===n)return Array.from(t);if(\"Arguments\"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(t,a)}(t))||a&&t&&\"number\"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")}var s,_=!0,h=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return _=t.done,t},e:function(t){h=!0,s=t},f:function(){try{_||null==n.return||n.return()}finally{if(h)throw s}}}}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var a=0,n=new Array(e);a<e;a++)n[a]=t[a];return n}function a(e){var a,n=e.reduce((function(t,e){return t+e.length}),0),r=new Uint8Array(n),i=0,s=t(e);try{for(s.s();!(a=s.n()).done;){var _=a.value;r.set(_,i),i+=_.length}}catch(t){s.e(t)}finally{s.f()}return r}function n(t){for(var e=t.length;--e>=0;)t[e]=0}var r=256,i=286,s=30,_=15,h=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),l=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),o=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),d=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),u=new Array(576);n(u);var f=new Array(60);n(f);var c=new Array(512);n(c);var p=new Array(256);n(p);var g=new Array(29);n(g);var v,w,b,m=new Array(s);function y(t,e,a,n,r){this.static_tree=t,this.extra_bits=e,this.extra_base=a,this.elems=n,this.max_length=r,this.has_stree=t&&t.length}function k(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}n(m);var z=function(t){return t<256?c[t]:c[256+(t>>>7)]},A=function(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},x=function(t,e,a){t.bi_valid>16-a?(t.bi_buf|=e<<t.bi_valid&65535,A(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=a-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=a)},E=function(t,e,a){x(t,a[2*e],a[2*e+1])},Z=function(t,e){var a=0;do{a|=1&t,t>>>=1,a<<=1}while(--e>0);return a>>>1},S=function(t,e,a){var n,r,i=new Array(16),s=0;for(n=1;n<=_;n++)i[n]=s=s+a[n-1]<<1;for(r=0;r<=e;r++){var h=t[2*r+1];0!==h&&(t[2*r]=Z(i[h]++,h))}},U=function(t){var e;for(e=0;e<i;e++)t.dyn_ltree[2*e]=0;for(e=0;e<s;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},R=function(t){t.bi_valid>8?A(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},L=function(t,e,a,n){var r=2*e,i=2*a;return t[r]<t[i]||t[r]===t[i]&&n[e]<=n[a]},F=function(t,e,a){for(var n=t.heap[a],r=a<<1;r<=t.heap_len&&(r<t.heap_len&&L(e,t.heap[r+1],t.heap[r],t.depth)&&r++,!L(e,n,t.heap[r],t.depth));)t.heap[a]=t.heap[r],a=r,r<<=1;t.heap[a]=n},T=function(t,e,a){var n,i,s,_,o=0;if(0!==t.last_lit)do{n=t.pending_buf[t.d_buf+2*o]<<8|t.pending_buf[t.d_buf+2*o+1],i=t.pending_buf[t.l_buf+o],o++,0===n?E(t,i,e):(s=p[i],E(t,s+r+1,e),0!==(_=h[s])&&(i-=g[s],x(t,i,_)),n--,s=z(n),E(t,s,a),0!==(_=l[s])&&(n-=m[s],x(t,n,_)))}while(o<t.last_lit);E(t,256,e)},I=function(t,e){var a,n,r,i=e.dyn_tree,s=e.stat_desc.static_tree,h=e.stat_desc.has_stree,l=e.stat_desc.elems,o=-1;for(t.heap_len=0,t.heap_max=573,a=0;a<l;a++)0!==i[2*a]?(t.heap[++t.heap_len]=o=a,t.depth[a]=0):i[2*a+1]=0;for(;t.heap_len<2;)i[2*(r=t.heap[++t.heap_len]=o<2?++o:0)]=1,t.depth[r]=0,t.opt_len--,h&&(t.static_len-=s[2*r+1]);for(e.max_code=o,a=t.heap_len>>1;a>=1;a--)F(t,i,a);r=l;do{a=t.heap[1],t.heap[1]=t.heap[t.heap_len--],F(t,i,1),n=t.heap[1],t.heap[--t.heap_max]=a,t.heap[--t.heap_max]=n,i[2*r]=i[2*a]+i[2*n],t.depth[r]=(t.depth[a]>=t.depth[n]?t.depth[a]:t.depth[n])+1,i[2*a+1]=i[2*n+1]=r,t.heap[1]=r++,F(t,i,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var a,n,r,i,s,h,l=e.dyn_tree,o=e.max_code,d=e.stat_desc.static_tree,u=e.stat_desc.has_stree,f=e.stat_desc.extra_bits,c=e.stat_desc.extra_base,p=e.stat_desc.max_length,g=0;for(i=0;i<=_;i++)t.bl_count[i]=0;for(l[2*t.heap[t.heap_max]+1]=0,a=t.heap_max+1;a<573;a++)(i=l[2*l[2*(n=t.heap[a])+1]+1]+1)>p&&(i=p,g++),l[2*n+1]=i,n>o||(t.bl_count[i]++,s=0,n>=c&&(s=f[n-c]),h=l[2*n],t.opt_len+=h*(i+s),u&&(t.static_len+=h*(d[2*n+1]+s)));if(0!==g){do{for(i=p-1;0===t.bl_count[i];)i--;t.bl_count[i]--,t.bl_count[i+1]+=2,t.bl_count[p]--,g-=2}while(g>0);for(i=p;0!==i;i--)for(n=t.bl_count[i];0!==n;)(r=t.heap[--a])>o||(l[2*r+1]!==i&&(t.opt_len+=(i-l[2*r+1])*l[2*r],l[2*r+1]=i),n--)}}(t,e),S(i,o,t.bl_count)},O=function(t,e,a){var n,r,i=-1,s=e[1],_=0,h=7,l=4;for(0===s&&(h=138,l=3),e[2*(a+1)+1]=65535,n=0;n<=a;n++)r=s,s=e[2*(n+1)+1],++_<h&&r===s||(_<l?t.bl_tree[2*r]+=_:0!==r?(r!==i&&t.bl_tree[2*r]++,t.bl_tree[32]++):_<=10?t.bl_tree[34]++:t.bl_tree[36]++,_=0,i=r,0===s?(h=138,l=3):r===s?(h=6,l=3):(h=7,l=4))},N=function(t,e,a){var n,r,i=-1,s=e[1],_=0,h=7,l=4;for(0===s&&(h=138,l=3),n=0;n<=a;n++)if(r=s,s=e[2*(n+1)+1],!(++_<h&&r===s)){if(_<l)do{E(t,r,t.bl_tree)}while(0!=--_);else 0!==r?(r!==i&&(E(t,r,t.bl_tree),_--),E(t,16,t.bl_tree),x(t,_-3,2)):_<=10?(E(t,17,t.bl_tree),x(t,_-3,3)):(E(t,18,t.bl_tree),x(t,_-11,7));_=0,i=r,0===s?(h=138,l=3):r===s?(h=6,l=3):(h=7,l=4)}},D=!1,C=function(t,e,a,n){x(t,0+(n?1:0),3),function(t,e,a,n){R(t),n&&(A(t,a),A(t,~a)),t.pending_buf.set(t.window.subarray(e,e+a),t.pending),t.pending+=a}(t,e,a,!0)},M=function(t,e,a,n){var i,s,_=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,a=4093624447;for(e=0;e<=31;e++,a>>>=1)if(1&a&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<r;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0}(t)),I(t,t.l_desc),I(t,t.d_desc),_=function(t){var e;for(O(t,t.dyn_ltree,t.l_desc.max_code),O(t,t.dyn_dtree,t.d_desc.max_code),I(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*d[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),i=t.opt_len+3+7>>>3,(s=t.static_len+3+7>>>3)<=i&&(i=s)):i=s=a+5,a+4<=i&&-1!==e?C(t,e,a,n):4===t.strategy||s===i?(x(t,2+(n?1:0),3),T(t,u,f)):(x(t,4+(n?1:0),3),function(t,e,a,n){var r;for(x(t,e-257,5),x(t,a-1,5),x(t,n-4,4),r=0;r<n;r++)x(t,t.bl_tree[2*d[r]+1],3);N(t,t.dyn_ltree,e-1),N(t,t.dyn_dtree,a-1)}(t,t.l_desc.max_code+1,t.d_desc.max_code+1,_+1),T(t,t.dyn_ltree,t.dyn_dtree)),U(t),n&&R(t)},B={_tr_init:function(t){D||(!function(){var t,e,a,n,r,d=new Array(16);for(a=0,n=0;n<28;n++)for(g[n]=a,t=0;t<1<<h[n];t++)p[a++]=n;for(p[a-1]=n,r=0,n=0;n<16;n++)for(m[n]=r,t=0;t<1<<l[n];t++)c[r++]=n;for(r>>=7;n<s;n++)for(m[n]=r<<7,t=0;t<1<<l[n]-7;t++)c[256+r++]=n;for(e=0;e<=_;e++)d[e]=0;for(t=0;t<=143;)u[2*t+1]=8,t++,d[8]++;for(;t<=255;)u[2*t+1]=9,t++,d[9]++;for(;t<=279;)u[2*t+1]=7,t++,d[7]++;for(;t<=287;)u[2*t+1]=8,t++,d[8]++;for(S(u,287,d),t=0;t<s;t++)f[2*t+1]=5,f[2*t]=Z(t,5);v=new y(u,h,257,i,_),w=new y(f,l,0,s,_),b=new y(new Array(0),o,0,19,7)}(),D=!0),t.l_desc=new k(t.dyn_ltree,v),t.d_desc=new k(t.dyn_dtree,w),t.bl_desc=new k(t.bl_tree,b),t.bi_buf=0,t.bi_valid=0,U(t)},_tr_stored_block:C,_tr_flush_block:M,_tr_tally:function(t,e,a){return t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&a,t.last_lit++,0===e?t.dyn_ltree[2*a]++:(t.matches++,e--,t.dyn_ltree[2*(p[a]+r+1)]++,t.dyn_dtree[2*z(e)]++),t.last_lit===t.lit_bufsize-1},_tr_align:function(t){x(t,2,3),E(t,256,u),function(t){16===t.bi_valid?(A(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}},H=function(t,e,a,n){for(var r=65535&t,i=t>>>16&65535,s=0;0!==a;){a-=s=a>2e3?2e3:a;do{i=i+(r=r+e[n++]|0)|0}while(--s);r%=65521,i%=65521}return r|i<<16},Y=new Uint32Array(function(){for(var t,e=[],a=0;a<256;a++){t=a;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[a]=t}return e}()),K=function(t,e,a,n){var r=Y,i=n+a;t^=-1;for(var s=n;s<i;s++)t=t>>>8^r[255&(t^e[s])];return~t},P={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"},j={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},G=B._tr_init,X=B._tr_stored_block,W=B._tr_flush_block,$=B._tr_tally,q=B._tr_align,J=j.Z_NO_FLUSH,Q=j.Z_PARTIAL_FLUSH,V=j.Z_FULL_FLUSH,tt=j.Z_FINISH,et=j.Z_BLOCK,at=j.Z_OK,nt=j.Z_STREAM_END,rt=j.Z_STREAM_ERROR,it=j.Z_DATA_ERROR,st=j.Z_BUF_ERROR,_t=j.Z_DEFAULT_COMPRESSION,ht=j.Z_FILTERED,lt=j.Z_HUFFMAN_ONLY,ot=j.Z_RLE,dt=j.Z_FIXED,ut=j.Z_DEFAULT_STRATEGY,ft=j.Z_UNKNOWN,ct=j.Z_DEFLATED,pt=258,gt=262,vt=103,wt=113,bt=666,mt=function(t,e){return t.msg=P[e],e},yt=function(t){return(t<<1)-(t>4?9:0)},kt=function(t){for(var e=t.length;--e>=0;)t[e]=0},zt=function(t,e,a){return(e<<t.hash_shift^a)&t.hash_mask},At=function(t){var e=t.state,a=e.pending;a>t.avail_out&&(a=t.avail_out),0!==a&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+a),t.next_out),t.next_out+=a,e.pending_out+=a,t.total_out+=a,t.avail_out-=a,e.pending-=a,0===e.pending&&(e.pending_out=0))},xt=function(t,e){W(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,At(t.strm)},Et=function(t,e){t.pending_buf[t.pending++]=e},Zt=function(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},St=function(t,e){var a,n,r=t.max_chain_length,i=t.strstart,s=t.prev_length,_=t.nice_match,h=t.strstart>t.w_size-gt?t.strstart-(t.w_size-gt):0,l=t.window,o=t.w_mask,d=t.prev,u=t.strstart+pt,f=l[i+s-1],c=l[i+s];t.prev_length>=t.good_match&&(r>>=2),_>t.lookahead&&(_=t.lookahead);do{if(l[(a=e)+s]===c&&l[a+s-1]===f&&l[a]===l[i]&&l[++a]===l[i+1]){i+=2,a++;do{}while(l[++i]===l[++a]&&l[++i]===l[++a]&&l[++i]===l[++a]&&l[++i]===l[++a]&&l[++i]===l[++a]&&l[++i]===l[++a]&&l[++i]===l[++a]&&l[++i]===l[++a]&&i<u);if(n=pt-(u-i),i=u-pt,n>s){if(t.match_start=e,s=n,n>=_)break;f=l[i+s-1],c=l[i+s]}}}while((e=d[e&o])>h&&0!=--r);return s<=t.lookahead?s:t.lookahead},Ut=function(t){var e,a,n,r,i,s,_,h,l,o,d=t.w_size;do{if(r=t.window_size-t.lookahead-t.strstart,t.strstart>=d+(d-gt)){t.window.set(t.window.subarray(d,d+d),0),t.match_start-=d,t.strstart-=d,t.block_start-=d,e=a=t.hash_size;do{n=t.head[--e],t.head[e]=n>=d?n-d:0}while(--a);e=a=d;do{n=t.prev[--e],t.prev[e]=n>=d?n-d:0}while(--a);r+=d}if(0===t.strm.avail_in)break;if(s=t.strm,_=t.window,h=t.strstart+t.lookahead,l=r,o=void 0,(o=s.avail_in)>l&&(o=l),a=0===o?0:(s.avail_in-=o,_.set(s.input.subarray(s.next_in,s.next_in+o),h),1===s.state.wrap?s.adler=H(s.adler,_,o,h):2===s.state.wrap&&(s.adler=K(s.adler,_,o,h)),s.next_in+=o,s.total_in+=o,o),t.lookahead+=a,t.lookahead+t.insert>=3)for(i=t.strstart-t.insert,t.ins_h=t.window[i],t.ins_h=zt(t,t.ins_h,t.window[i+1]);t.insert&&(t.ins_h=zt(t,t.ins_h,t.window[i+3-1]),t.prev[i&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=i,i++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<gt&&0!==t.strm.avail_in)},Rt=function(t,e){for(var a,n;;){if(t.lookahead<gt){if(Ut(t),t.lookahead<gt&&e===J)return 1;if(0===t.lookahead)break}if(a=0,t.lookahead>=3&&(t.ins_h=zt(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==a&&t.strstart-a<=t.w_size-gt&&(t.match_length=St(t,a)),t.match_length>=3)if(n=$(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=zt(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=zt(t,t.ins_h,t.window[t.strstart+1]);else n=$(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===tt?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2},Lt=function(t,e){for(var a,n,r;;){if(t.lookahead<gt){if(Ut(t),t.lookahead<gt&&e===J)return 1;if(0===t.lookahead)break}if(a=0,t.lookahead>=3&&(t.ins_h=zt(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==a&&t.prev_length<t.max_lazy_match&&t.strstart-a<=t.w_size-gt&&(t.match_length=St(t,a),t.match_length<=5&&(t.strategy===ht||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){r=t.strstart+t.lookahead-3,n=$(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=r&&(t.ins_h=zt(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(xt(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if((n=$(t,0,t.window[t.strstart-1]))&&xt(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=$(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===tt?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2};function Ft(t,e,a,n,r){this.good_length=t,this.max_lazy=e,this.nice_length=a,this.max_chain=n,this.func=r}var Tt=[new Ft(0,0,0,0,(function(t,e){var a=65535;for(a>t.pending_buf_size-5&&(a=t.pending_buf_size-5);;){if(t.lookahead<=1){if(Ut(t),0===t.lookahead&&e===J)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var n=t.block_start+a;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,xt(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-gt&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===tt?(xt(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(xt(t,!1),t.strm.avail_out),1)})),new Ft(4,4,8,4,Rt),new Ft(4,5,16,8,Rt),new Ft(4,6,32,32,Rt),new Ft(4,4,16,16,Lt),new Ft(8,16,32,32,Lt),new Ft(8,16,128,128,Lt),new Ft(8,32,128,256,Lt),new Ft(32,128,258,1024,Lt),new Ft(32,258,258,4096,Lt)];function It(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ct,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),kt(this.dyn_ltree),kt(this.dyn_dtree),kt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),kt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),kt(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var Ot=function(t){if(!t||!t.state)return mt(t,rt);t.total_in=t.total_out=0,t.data_type=ft;var e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:wt,t.adler=2===e.wrap?0:1,e.last_flush=J,G(e),at},Nt=function(t){var e,a=Ot(t);return a===at&&((e=t.state).window_size=2*e.w_size,kt(e.head),e.max_lazy_match=Tt[e.level].max_lazy,e.good_match=Tt[e.level].good_length,e.nice_match=Tt[e.level].nice_length,e.max_chain_length=Tt[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0),a},Dt=function(t,e,a,n,r,i){if(!t)return rt;var s=1;if(e===_t&&(e=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),r<1||r>9||a!==ct||n<8||n>15||e<0||e>9||i<0||i>dt)return mt(t,rt);8===n&&(n=9);var _=new It;return t.state=_,_.strm=t,_.wrap=s,_.gzhead=null,_.w_bits=n,_.w_size=1<<_.w_bits,_.w_mask=_.w_size-1,_.hash_bits=r+7,_.hash_size=1<<_.hash_bits,_.hash_mask=_.hash_size-1,_.hash_shift=~~((_.hash_bits+3-1)/3),_.window=new Uint8Array(2*_.w_size),_.head=new Uint16Array(_.hash_size),_.prev=new Uint16Array(_.w_size),_.lit_bufsize=1<<r+6,_.pending_buf_size=4*_.lit_bufsize,_.pending_buf=new Uint8Array(_.pending_buf_size),_.d_buf=1*_.lit_bufsize,_.l_buf=3*_.lit_bufsize,_.level=e,_.strategy=i,_.method=a,Nt(t)},Ct={deflateInit:function(t,e){return Dt(t,e,ct,15,8,ut)},deflateInit2:Dt,deflateReset:Nt,deflateResetKeep:Ot,deflateSetHeader:function(t,e){return t&&t.state?2!==t.state.wrap?rt:(t.state.gzhead=e,at):rt},deflate:function(t,e){var a,n;if(!t||!t.state||e>et||e<0)return t?mt(t,rt):rt;var r=t.state;if(!t.output||!t.input&&0!==t.avail_in||r.status===bt&&e!==tt)return mt(t,0===t.avail_out?st:rt);r.strm=t;var i=r.last_flush;if(r.last_flush=e,42===r.status)if(2===r.wrap)t.adler=0,Et(r,31),Et(r,139),Et(r,8),r.gzhead?(Et(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),Et(r,255&r.gzhead.time),Et(r,r.gzhead.time>>8&255),Et(r,r.gzhead.time>>16&255),Et(r,r.gzhead.time>>24&255),Et(r,9===r.level?2:r.strategy>=lt||r.level<2?4:0),Et(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(Et(r,255&r.gzhead.extra.length),Et(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=K(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69):(Et(r,0),Et(r,0),Et(r,0),Et(r,0),Et(r,0),Et(r,9===r.level?2:r.strategy>=lt||r.level<2?4:0),Et(r,3),r.status=wt);else{var s=ct+(r.w_bits-8<<4)<<8;s|=(r.strategy>=lt||r.level<2?0:r.level<6?1:6===r.level?2:3)<<6,0!==r.strstart&&(s|=32),s+=31-s%31,r.status=wt,Zt(r,s),0!==r.strstart&&(Zt(r,t.adler>>>16),Zt(r,65535&t.adler)),t.adler=1}if(69===r.status)if(r.gzhead.extra){for(a=r.pending;r.gzindex<(65535&r.gzhead.extra.length)&&(r.pending!==r.pending_buf_size||(r.gzhead.hcrc&&r.pending>a&&(t.adler=K(t.adler,r.pending_buf,r.pending-a,a)),At(t),a=r.pending,r.pending!==r.pending_buf_size));)Et(r,255&r.gzhead.extra[r.gzindex]),r.gzindex++;r.gzhead.hcrc&&r.pending>a&&(t.adler=K(t.adler,r.pending_buf,r.pending-a,a)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=73)}else r.status=73;if(73===r.status)if(r.gzhead.name){a=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>a&&(t.adler=K(t.adler,r.pending_buf,r.pending-a,a)),At(t),a=r.pending,r.pending===r.pending_buf_size)){n=1;break}n=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,Et(r,n)}while(0!==n);r.gzhead.hcrc&&r.pending>a&&(t.adler=K(t.adler,r.pending_buf,r.pending-a,a)),0===n&&(r.gzindex=0,r.status=91)}else r.status=91;if(91===r.status)if(r.gzhead.comment){a=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>a&&(t.adler=K(t.adler,r.pending_buf,r.pending-a,a)),At(t),a=r.pending,r.pending===r.pending_buf_size)){n=1;break}n=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,Et(r,n)}while(0!==n);r.gzhead.hcrc&&r.pending>a&&(t.adler=K(t.adler,r.pending_buf,r.pending-a,a)),0===n&&(r.status=vt)}else r.status=vt;if(r.status===vt&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&At(t),r.pending+2<=r.pending_buf_size&&(Et(r,255&t.adler),Et(r,t.adler>>8&255),t.adler=0,r.status=wt)):r.status=wt),0!==r.pending){if(At(t),0===t.avail_out)return r.last_flush=-1,at}else if(0===t.avail_in&&yt(e)<=yt(i)&&e!==tt)return mt(t,st);if(r.status===bt&&0!==t.avail_in)return mt(t,st);if(0!==t.avail_in||0!==r.lookahead||e!==J&&r.status!==bt){var _=r.strategy===lt?function(t,e){for(var a;;){if(0===t.lookahead&&(Ut(t),0===t.lookahead)){if(e===J)return 1;break}if(t.match_length=0,a=$(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,a&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===tt?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2}(r,e):r.strategy===ot?function(t,e){for(var a,n,r,i,s=t.window;;){if(t.lookahead<=pt){if(Ut(t),t.lookahead<=pt&&e===J)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=s[r=t.strstart-1])===s[++r]&&n===s[++r]&&n===s[++r]){i=t.strstart+pt;do{}while(n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&r<i);t.match_length=pt-(i-r),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(a=$(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(a=$(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),a&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===tt?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2}(r,e):Tt[r.level].func(r,e);if(3!==_&&4!==_||(r.status=bt),1===_||3===_)return 0===t.avail_out&&(r.last_flush=-1),at;if(2===_&&(e===Q?q(r):e!==et&&(X(r,0,0,!1),e===V&&(kt(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),At(t),0===t.avail_out))return r.last_flush=-1,at}return e!==tt?at:r.wrap<=0?nt:(2===r.wrap?(Et(r,255&t.adler),Et(r,t.adler>>8&255),Et(r,t.adler>>16&255),Et(r,t.adler>>24&255),Et(r,255&t.total_in),Et(r,t.total_in>>8&255),Et(r,t.total_in>>16&255),Et(r,t.total_in>>24&255)):(Zt(r,t.adler>>>16),Zt(r,65535&t.adler)),At(t),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?at:nt)},deflateEnd:function(t){if(!t||!t.state)return rt;var e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&e!==vt&&e!==wt&&e!==bt?mt(t,rt):(t.state=null,e===wt?mt(t,it):at)},deflateSetDictionary:function(t,e){var a=e.length;if(!t||!t.state)return rt;var n=t.state,r=n.wrap;if(2===r||1===r&&42!==n.status||n.lookahead)return rt;if(1===r&&(t.adler=H(t.adler,e,a,0)),n.wrap=0,a>=n.w_size){0===r&&(kt(n.head),n.strstart=0,n.block_start=0,n.insert=0);var i=new Uint8Array(n.w_size);i.set(e.subarray(a-n.w_size,a),0),e=i,a=n.w_size}var s=t.avail_in,_=t.next_in,h=t.input;for(t.avail_in=a,t.next_in=0,t.input=e,Ut(n);n.lookahead>=3;){var l=n.strstart,o=n.lookahead-2;do{n.ins_h=zt(n,n.ins_h,n.window[l+3-1]),n.prev[l&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=l,l++}while(--o);n.strstart=l,n.lookahead=2,Ut(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=_,t.input=h,t.avail_in=s,n.wrap=r,at},deflateInfo:\"pako deflate (from Nodeca project)\"};for(var Mt=new Uint8Array(256),Bt=0;Bt<256;Bt++)Mt[Bt]=Bt>=252?6:Bt>=248?5:Bt>=240?4:Bt>=224?3:Bt>=192?2:1;Mt[254]=Mt[254]=1;var Ht=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0},Yt=Object.prototype.toString,Kt=j.Z_NO_FLUSH,Pt=j.Z_SYNC_FLUSH,jt=j.Z_FULL_FLUSH,Gt=j.Z_FINISH,Xt=j.Z_OK,Wt=j.Z_STREAM_END,$t=j.Z_DEFAULT_COMPRESSION,qt=j.Z_DEFAULT_STRATEGY,Jt=j.Z_DEFLATED;function Qt(){this.options={level:$t,method:Jt,chunkSize:16384,windowBits:15,memLevel:8,strategy:qt};var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new Ht,this.strm.avail_out=0;var e=Ct.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(e!==Xt)throw new Error(P[e]);if(t.header&&Ct.deflateSetHeader(this.strm,t.header),t.dictionary){var a;if(a=\"[object ArrayBuffer]\"===Yt.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(e=Ct.deflateSetDictionary(this.strm,a))!==Xt)throw new Error(P[e]);this._dict_set=!0}}function Vt(t,e,a){try{t.postMessage({type:\"errored\",error:e,streamId:a})}catch(n){t.postMessage({type:\"errored\",error:String(e),streamId:a})}}function te(t){var e=t.strm.adler;return new Uint8Array([3,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e])}Qt.prototype.push=function(t,e){var a,n,r=this.strm,i=this.options.chunkSize;if(this.ended)return!1;for(n=e===~~e?e:!0===e?Gt:Kt,\"[object ArrayBuffer]\"===Yt.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(i),r.next_out=0,r.avail_out=i),(n===Pt||n===jt)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if((a=Ct.deflate(r,n))===Wt)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),a=Ct.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===Xt;if(0!==r.avail_out){if(n>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},Qt.prototype.onData=function(t){this.chunks.push(t)},Qt.prototype.onEnd=function(t){t===Xt&&(this.result=function(t){for(var e=0,a=0,n=t.length;a<n;a++)e+=t[a].length;for(var r=new Uint8Array(e),i=0,s=0,_=t.length;i<_;i++){var h=t[i];r.set(h,s),s+=h.length}return r}(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},function(t){void 0===t&&(t=self);try{var e=new Map;t.addEventListener(\"message\",(function(n){try{var r=function(t,e){switch(e.action){case\"init\":return{type:\"initialized\",version:\"3.1.19\"};case\"write\":var n=t.get(e.streamId);n||(n=new Qt,t.set(e.streamId,n));var r=n.chunks.length,i=function(t){if(\"function\"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,a,n,r,i,s=t.length,_=0;for(r=0;r<s;r++)a=t.charCodeAt(r),55296==(64512&a)&&r+1<s&&(n=t.charCodeAt(r+1),56320==(64512&n)&&(a=65536+(a-55296<<10)+(n-56320),r++)),_+=a<128?1:a<2048?2:a<65536?3:4;for(e=new Uint8Array(_),i=0,r=0;i<_;r++)a=t.charCodeAt(r),55296==(64512&a)&&r+1<s&&(n=t.charCodeAt(r+1),56320==(64512&n)&&(a=65536+(a-55296<<10)+(n-56320),r++)),a<128?e[i++]=a:a<2048?(e[i++]=192|a>>>6,e[i++]=128|63&a):a<65536?(e[i++]=224|a>>>12,e[i++]=128|a>>>6&63,e[i++]=128|63&a):(e[i++]=240|a>>>18,e[i++]=128|a>>>12&63,e[i++]=128|a>>>6&63,e[i++]=128|63&a);return e}(e.data);return n.push(i,j.Z_SYNC_FLUSH),{type:\"wrote\",id:e.id,streamId:e.streamId,result:a(n.chunks.slice(r)),trailer:te(n),additionalBytesCount:i.length};case\"reset\":t.delete(e.streamId)}}(e,n.data);r&&t.postMessage(r)}catch(e){Vt(t,e,n.data&&\"streamId\"in n.data?n.data.streamId:void 0)}}))}catch(e){Vt(t,e)}}()}();"])));
|
|
16
|
+
return new Worker(URL.createObjectURL(new Blob(["!function(){\"use strict\";function t(t,a){var n=\"undefined\"!=typeof Symbol&&t[Symbol.iterator]||t[\"@@iterator\"];if(!n){if(Array.isArray(t)||(n=function(t,a){if(!t)return;if(\"string\"==typeof t)return e(t,a);var n=Object.prototype.toString.call(t).slice(8,-1);\"Object\"===n&&t.constructor&&(n=t.constructor.name);if(\"Map\"===n||\"Set\"===n)return Array.from(t);if(\"Arguments\"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(t,a)}(t))||a&&t&&\"number\"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")}var s,_=!0,h=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return _=t.done,t},e:function(t){h=!0,s=t},f:function(){try{_||null==n.return||n.return()}finally{if(h)throw s}}}}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var a=0,n=new Array(e);a<e;a++)n[a]=t[a];return n}function a(e){var a,n=e.reduce((function(t,e){return t+e.length}),0),r=new Uint8Array(n),i=0,s=t(e);try{for(s.s();!(a=s.n()).done;){var _=a.value;r.set(_,i),i+=_.length}}catch(t){s.e(t)}finally{s.f()}return r}function n(t){for(var e=t.length;--e>=0;)t[e]=0}var r=256,i=286,s=30,_=15,h=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),l=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),o=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),d=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),u=new Array(576);n(u);var f=new Array(60);n(f);var c=new Array(512);n(c);var p=new Array(256);n(p);var g=new Array(29);n(g);var v,w,b,m=new Array(s);function y(t,e,a,n,r){this.static_tree=t,this.extra_bits=e,this.extra_base=a,this.elems=n,this.max_length=r,this.has_stree=t&&t.length}function k(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}n(m);var z=function(t){return t<256?c[t]:c[256+(t>>>7)]},A=function(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},x=function(t,e,a){t.bi_valid>16-a?(t.bi_buf|=e<<t.bi_valid&65535,A(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=a-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=a)},E=function(t,e,a){x(t,a[2*e],a[2*e+1])},Z=function(t,e){var a=0;do{a|=1&t,t>>>=1,a<<=1}while(--e>0);return a>>>1},S=function(t,e,a){var n,r,i=new Array(16),s=0;for(n=1;n<=_;n++)i[n]=s=s+a[n-1]<<1;for(r=0;r<=e;r++){var h=t[2*r+1];0!==h&&(t[2*r]=Z(i[h]++,h))}},U=function(t){var e;for(e=0;e<i;e++)t.dyn_ltree[2*e]=0;for(e=0;e<s;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},R=function(t){t.bi_valid>8?A(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},L=function(t,e,a,n){var r=2*e,i=2*a;return t[r]<t[i]||t[r]===t[i]&&n[e]<=n[a]},F=function(t,e,a){for(var n=t.heap[a],r=a<<1;r<=t.heap_len&&(r<t.heap_len&&L(e,t.heap[r+1],t.heap[r],t.depth)&&r++,!L(e,n,t.heap[r],t.depth));)t.heap[a]=t.heap[r],a=r,r<<=1;t.heap[a]=n},T=function(t,e,a){var n,i,s,_,o=0;if(0!==t.last_lit)do{n=t.pending_buf[t.d_buf+2*o]<<8|t.pending_buf[t.d_buf+2*o+1],i=t.pending_buf[t.l_buf+o],o++,0===n?E(t,i,e):(s=p[i],E(t,s+r+1,e),0!==(_=h[s])&&(i-=g[s],x(t,i,_)),n--,s=z(n),E(t,s,a),0!==(_=l[s])&&(n-=m[s],x(t,n,_)))}while(o<t.last_lit);E(t,256,e)},I=function(t,e){var a,n,r,i=e.dyn_tree,s=e.stat_desc.static_tree,h=e.stat_desc.has_stree,l=e.stat_desc.elems,o=-1;for(t.heap_len=0,t.heap_max=573,a=0;a<l;a++)0!==i[2*a]?(t.heap[++t.heap_len]=o=a,t.depth[a]=0):i[2*a+1]=0;for(;t.heap_len<2;)i[2*(r=t.heap[++t.heap_len]=o<2?++o:0)]=1,t.depth[r]=0,t.opt_len--,h&&(t.static_len-=s[2*r+1]);for(e.max_code=o,a=t.heap_len>>1;a>=1;a--)F(t,i,a);r=l;do{a=t.heap[1],t.heap[1]=t.heap[t.heap_len--],F(t,i,1),n=t.heap[1],t.heap[--t.heap_max]=a,t.heap[--t.heap_max]=n,i[2*r]=i[2*a]+i[2*n],t.depth[r]=(t.depth[a]>=t.depth[n]?t.depth[a]:t.depth[n])+1,i[2*a+1]=i[2*n+1]=r,t.heap[1]=r++,F(t,i,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var a,n,r,i,s,h,l=e.dyn_tree,o=e.max_code,d=e.stat_desc.static_tree,u=e.stat_desc.has_stree,f=e.stat_desc.extra_bits,c=e.stat_desc.extra_base,p=e.stat_desc.max_length,g=0;for(i=0;i<=_;i++)t.bl_count[i]=0;for(l[2*t.heap[t.heap_max]+1]=0,a=t.heap_max+1;a<573;a++)(i=l[2*l[2*(n=t.heap[a])+1]+1]+1)>p&&(i=p,g++),l[2*n+1]=i,n>o||(t.bl_count[i]++,s=0,n>=c&&(s=f[n-c]),h=l[2*n],t.opt_len+=h*(i+s),u&&(t.static_len+=h*(d[2*n+1]+s)));if(0!==g){do{for(i=p-1;0===t.bl_count[i];)i--;t.bl_count[i]--,t.bl_count[i+1]+=2,t.bl_count[p]--,g-=2}while(g>0);for(i=p;0!==i;i--)for(n=t.bl_count[i];0!==n;)(r=t.heap[--a])>o||(l[2*r+1]!==i&&(t.opt_len+=(i-l[2*r+1])*l[2*r],l[2*r+1]=i),n--)}}(t,e),S(i,o,t.bl_count)},O=function(t,e,a){var n,r,i=-1,s=e[1],_=0,h=7,l=4;for(0===s&&(h=138,l=3),e[2*(a+1)+1]=65535,n=0;n<=a;n++)r=s,s=e[2*(n+1)+1],++_<h&&r===s||(_<l?t.bl_tree[2*r]+=_:0!==r?(r!==i&&t.bl_tree[2*r]++,t.bl_tree[32]++):_<=10?t.bl_tree[34]++:t.bl_tree[36]++,_=0,i=r,0===s?(h=138,l=3):r===s?(h=6,l=3):(h=7,l=4))},N=function(t,e,a){var n,r,i=-1,s=e[1],_=0,h=7,l=4;for(0===s&&(h=138,l=3),n=0;n<=a;n++)if(r=s,s=e[2*(n+1)+1],!(++_<h&&r===s)){if(_<l)do{E(t,r,t.bl_tree)}while(0!=--_);else 0!==r?(r!==i&&(E(t,r,t.bl_tree),_--),E(t,16,t.bl_tree),x(t,_-3,2)):_<=10?(E(t,17,t.bl_tree),x(t,_-3,3)):(E(t,18,t.bl_tree),x(t,_-11,7));_=0,i=r,0===s?(h=138,l=3):r===s?(h=6,l=3):(h=7,l=4)}},D=!1,C=function(t,e,a,n){x(t,0+(n?1:0),3),function(t,e,a,n){R(t),n&&(A(t,a),A(t,~a)),t.pending_buf.set(t.window.subarray(e,e+a),t.pending),t.pending+=a}(t,e,a,!0)},M=function(t,e,a,n){var i,s,_=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,a=4093624447;for(e=0;e<=31;e++,a>>>=1)if(1&a&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<r;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0}(t)),I(t,t.l_desc),I(t,t.d_desc),_=function(t){var e;for(O(t,t.dyn_ltree,t.l_desc.max_code),O(t,t.dyn_dtree,t.d_desc.max_code),I(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*d[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),i=t.opt_len+3+7>>>3,(s=t.static_len+3+7>>>3)<=i&&(i=s)):i=s=a+5,a+4<=i&&-1!==e?C(t,e,a,n):4===t.strategy||s===i?(x(t,2+(n?1:0),3),T(t,u,f)):(x(t,4+(n?1:0),3),function(t,e,a,n){var r;for(x(t,e-257,5),x(t,a-1,5),x(t,n-4,4),r=0;r<n;r++)x(t,t.bl_tree[2*d[r]+1],3);N(t,t.dyn_ltree,e-1),N(t,t.dyn_dtree,a-1)}(t,t.l_desc.max_code+1,t.d_desc.max_code+1,_+1),T(t,t.dyn_ltree,t.dyn_dtree)),U(t),n&&R(t)},B={_tr_init:function(t){D||(!function(){var t,e,a,n,r,d=new Array(16);for(a=0,n=0;n<28;n++)for(g[n]=a,t=0;t<1<<h[n];t++)p[a++]=n;for(p[a-1]=n,r=0,n=0;n<16;n++)for(m[n]=r,t=0;t<1<<l[n];t++)c[r++]=n;for(r>>=7;n<s;n++)for(m[n]=r<<7,t=0;t<1<<l[n]-7;t++)c[256+r++]=n;for(e=0;e<=_;e++)d[e]=0;for(t=0;t<=143;)u[2*t+1]=8,t++,d[8]++;for(;t<=255;)u[2*t+1]=9,t++,d[9]++;for(;t<=279;)u[2*t+1]=7,t++,d[7]++;for(;t<=287;)u[2*t+1]=8,t++,d[8]++;for(S(u,287,d),t=0;t<s;t++)f[2*t+1]=5,f[2*t]=Z(t,5);v=new y(u,h,257,i,_),w=new y(f,l,0,s,_),b=new y(new Array(0),o,0,19,7)}(),D=!0),t.l_desc=new k(t.dyn_ltree,v),t.d_desc=new k(t.dyn_dtree,w),t.bl_desc=new k(t.bl_tree,b),t.bi_buf=0,t.bi_valid=0,U(t)},_tr_stored_block:C,_tr_flush_block:M,_tr_tally:function(t,e,a){return t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&a,t.last_lit++,0===e?t.dyn_ltree[2*a]++:(t.matches++,e--,t.dyn_ltree[2*(p[a]+r+1)]++,t.dyn_dtree[2*z(e)]++),t.last_lit===t.lit_bufsize-1},_tr_align:function(t){x(t,2,3),E(t,256,u),function(t){16===t.bi_valid?(A(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}},H=function(t,e,a,n){for(var r=65535&t,i=t>>>16&65535,s=0;0!==a;){a-=s=a>2e3?2e3:a;do{i=i+(r=r+e[n++]|0)|0}while(--s);r%=65521,i%=65521}return r|i<<16},Y=new Uint32Array(function(){for(var t,e=[],a=0;a<256;a++){t=a;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[a]=t}return e}()),K=function(t,e,a,n){var r=Y,i=n+a;t^=-1;for(var s=n;s<i;s++)t=t>>>8^r[255&(t^e[s])];return~t},P={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"},j={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},G=B._tr_init,X=B._tr_stored_block,W=B._tr_flush_block,$=B._tr_tally,q=B._tr_align,J=j.Z_NO_FLUSH,Q=j.Z_PARTIAL_FLUSH,V=j.Z_FULL_FLUSH,tt=j.Z_FINISH,et=j.Z_BLOCK,at=j.Z_OK,nt=j.Z_STREAM_END,rt=j.Z_STREAM_ERROR,it=j.Z_DATA_ERROR,st=j.Z_BUF_ERROR,_t=j.Z_DEFAULT_COMPRESSION,ht=j.Z_FILTERED,lt=j.Z_HUFFMAN_ONLY,ot=j.Z_RLE,dt=j.Z_FIXED,ut=j.Z_DEFAULT_STRATEGY,ft=j.Z_UNKNOWN,ct=j.Z_DEFLATED,pt=258,gt=262,vt=103,wt=113,bt=666,mt=function(t,e){return t.msg=P[e],e},yt=function(t){return(t<<1)-(t>4?9:0)},kt=function(t){for(var e=t.length;--e>=0;)t[e]=0},zt=function(t,e,a){return(e<<t.hash_shift^a)&t.hash_mask},At=function(t){var e=t.state,a=e.pending;a>t.avail_out&&(a=t.avail_out),0!==a&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+a),t.next_out),t.next_out+=a,e.pending_out+=a,t.total_out+=a,t.avail_out-=a,e.pending-=a,0===e.pending&&(e.pending_out=0))},xt=function(t,e){W(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,At(t.strm)},Et=function(t,e){t.pending_buf[t.pending++]=e},Zt=function(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},St=function(t,e){var a,n,r=t.max_chain_length,i=t.strstart,s=t.prev_length,_=t.nice_match,h=t.strstart>t.w_size-gt?t.strstart-(t.w_size-gt):0,l=t.window,o=t.w_mask,d=t.prev,u=t.strstart+pt,f=l[i+s-1],c=l[i+s];t.prev_length>=t.good_match&&(r>>=2),_>t.lookahead&&(_=t.lookahead);do{if(l[(a=e)+s]===c&&l[a+s-1]===f&&l[a]===l[i]&&l[++a]===l[i+1]){i+=2,a++;do{}while(l[++i]===l[++a]&&l[++i]===l[++a]&&l[++i]===l[++a]&&l[++i]===l[++a]&&l[++i]===l[++a]&&l[++i]===l[++a]&&l[++i]===l[++a]&&l[++i]===l[++a]&&i<u);if(n=pt-(u-i),i=u-pt,n>s){if(t.match_start=e,s=n,n>=_)break;f=l[i+s-1],c=l[i+s]}}}while((e=d[e&o])>h&&0!=--r);return s<=t.lookahead?s:t.lookahead},Ut=function(t){var e,a,n,r,i,s,_,h,l,o,d=t.w_size;do{if(r=t.window_size-t.lookahead-t.strstart,t.strstart>=d+(d-gt)){t.window.set(t.window.subarray(d,d+d),0),t.match_start-=d,t.strstart-=d,t.block_start-=d,e=a=t.hash_size;do{n=t.head[--e],t.head[e]=n>=d?n-d:0}while(--a);e=a=d;do{n=t.prev[--e],t.prev[e]=n>=d?n-d:0}while(--a);r+=d}if(0===t.strm.avail_in)break;if(s=t.strm,_=t.window,h=t.strstart+t.lookahead,l=r,o=void 0,(o=s.avail_in)>l&&(o=l),a=0===o?0:(s.avail_in-=o,_.set(s.input.subarray(s.next_in,s.next_in+o),h),1===s.state.wrap?s.adler=H(s.adler,_,o,h):2===s.state.wrap&&(s.adler=K(s.adler,_,o,h)),s.next_in+=o,s.total_in+=o,o),t.lookahead+=a,t.lookahead+t.insert>=3)for(i=t.strstart-t.insert,t.ins_h=t.window[i],t.ins_h=zt(t,t.ins_h,t.window[i+1]);t.insert&&(t.ins_h=zt(t,t.ins_h,t.window[i+3-1]),t.prev[i&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=i,i++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<gt&&0!==t.strm.avail_in)},Rt=function(t,e){for(var a,n;;){if(t.lookahead<gt){if(Ut(t),t.lookahead<gt&&e===J)return 1;if(0===t.lookahead)break}if(a=0,t.lookahead>=3&&(t.ins_h=zt(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==a&&t.strstart-a<=t.w_size-gt&&(t.match_length=St(t,a)),t.match_length>=3)if(n=$(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=zt(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=zt(t,t.ins_h,t.window[t.strstart+1]);else n=$(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===tt?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2},Lt=function(t,e){for(var a,n,r;;){if(t.lookahead<gt){if(Ut(t),t.lookahead<gt&&e===J)return 1;if(0===t.lookahead)break}if(a=0,t.lookahead>=3&&(t.ins_h=zt(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==a&&t.prev_length<t.max_lazy_match&&t.strstart-a<=t.w_size-gt&&(t.match_length=St(t,a),t.match_length<=5&&(t.strategy===ht||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){r=t.strstart+t.lookahead-3,n=$(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=r&&(t.ins_h=zt(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(xt(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if((n=$(t,0,t.window[t.strstart-1]))&&xt(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=$(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===tt?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2};function Ft(t,e,a,n,r){this.good_length=t,this.max_lazy=e,this.nice_length=a,this.max_chain=n,this.func=r}var Tt=[new Ft(0,0,0,0,(function(t,e){var a=65535;for(a>t.pending_buf_size-5&&(a=t.pending_buf_size-5);;){if(t.lookahead<=1){if(Ut(t),0===t.lookahead&&e===J)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var n=t.block_start+a;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,xt(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-gt&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===tt?(xt(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(xt(t,!1),t.strm.avail_out),1)})),new Ft(4,4,8,4,Rt),new Ft(4,5,16,8,Rt),new Ft(4,6,32,32,Rt),new Ft(4,4,16,16,Lt),new Ft(8,16,32,32,Lt),new Ft(8,16,128,128,Lt),new Ft(8,32,128,256,Lt),new Ft(32,128,258,1024,Lt),new Ft(32,258,258,4096,Lt)];function It(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ct,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),kt(this.dyn_ltree),kt(this.dyn_dtree),kt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),kt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),kt(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var Ot=function(t){if(!t||!t.state)return mt(t,rt);t.total_in=t.total_out=0,t.data_type=ft;var e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:wt,t.adler=2===e.wrap?0:1,e.last_flush=J,G(e),at},Nt=function(t){var e,a=Ot(t);return a===at&&((e=t.state).window_size=2*e.w_size,kt(e.head),e.max_lazy_match=Tt[e.level].max_lazy,e.good_match=Tt[e.level].good_length,e.nice_match=Tt[e.level].nice_length,e.max_chain_length=Tt[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0),a},Dt=function(t,e,a,n,r,i){if(!t)return rt;var s=1;if(e===_t&&(e=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),r<1||r>9||a!==ct||n<8||n>15||e<0||e>9||i<0||i>dt)return mt(t,rt);8===n&&(n=9);var _=new It;return t.state=_,_.strm=t,_.wrap=s,_.gzhead=null,_.w_bits=n,_.w_size=1<<_.w_bits,_.w_mask=_.w_size-1,_.hash_bits=r+7,_.hash_size=1<<_.hash_bits,_.hash_mask=_.hash_size-1,_.hash_shift=~~((_.hash_bits+3-1)/3),_.window=new Uint8Array(2*_.w_size),_.head=new Uint16Array(_.hash_size),_.prev=new Uint16Array(_.w_size),_.lit_bufsize=1<<r+6,_.pending_buf_size=4*_.lit_bufsize,_.pending_buf=new Uint8Array(_.pending_buf_size),_.d_buf=1*_.lit_bufsize,_.l_buf=3*_.lit_bufsize,_.level=e,_.strategy=i,_.method=a,Nt(t)},Ct={deflateInit:function(t,e){return Dt(t,e,ct,15,8,ut)},deflateInit2:Dt,deflateReset:Nt,deflateResetKeep:Ot,deflateSetHeader:function(t,e){return t&&t.state?2!==t.state.wrap?rt:(t.state.gzhead=e,at):rt},deflate:function(t,e){var a,n;if(!t||!t.state||e>et||e<0)return t?mt(t,rt):rt;var r=t.state;if(!t.output||!t.input&&0!==t.avail_in||r.status===bt&&e!==tt)return mt(t,0===t.avail_out?st:rt);r.strm=t;var i=r.last_flush;if(r.last_flush=e,42===r.status)if(2===r.wrap)t.adler=0,Et(r,31),Et(r,139),Et(r,8),r.gzhead?(Et(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),Et(r,255&r.gzhead.time),Et(r,r.gzhead.time>>8&255),Et(r,r.gzhead.time>>16&255),Et(r,r.gzhead.time>>24&255),Et(r,9===r.level?2:r.strategy>=lt||r.level<2?4:0),Et(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(Et(r,255&r.gzhead.extra.length),Et(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=K(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69):(Et(r,0),Et(r,0),Et(r,0),Et(r,0),Et(r,0),Et(r,9===r.level?2:r.strategy>=lt||r.level<2?4:0),Et(r,3),r.status=wt);else{var s=ct+(r.w_bits-8<<4)<<8;s|=(r.strategy>=lt||r.level<2?0:r.level<6?1:6===r.level?2:3)<<6,0!==r.strstart&&(s|=32),s+=31-s%31,r.status=wt,Zt(r,s),0!==r.strstart&&(Zt(r,t.adler>>>16),Zt(r,65535&t.adler)),t.adler=1}if(69===r.status)if(r.gzhead.extra){for(a=r.pending;r.gzindex<(65535&r.gzhead.extra.length)&&(r.pending!==r.pending_buf_size||(r.gzhead.hcrc&&r.pending>a&&(t.adler=K(t.adler,r.pending_buf,r.pending-a,a)),At(t),a=r.pending,r.pending!==r.pending_buf_size));)Et(r,255&r.gzhead.extra[r.gzindex]),r.gzindex++;r.gzhead.hcrc&&r.pending>a&&(t.adler=K(t.adler,r.pending_buf,r.pending-a,a)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=73)}else r.status=73;if(73===r.status)if(r.gzhead.name){a=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>a&&(t.adler=K(t.adler,r.pending_buf,r.pending-a,a)),At(t),a=r.pending,r.pending===r.pending_buf_size)){n=1;break}n=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,Et(r,n)}while(0!==n);r.gzhead.hcrc&&r.pending>a&&(t.adler=K(t.adler,r.pending_buf,r.pending-a,a)),0===n&&(r.gzindex=0,r.status=91)}else r.status=91;if(91===r.status)if(r.gzhead.comment){a=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>a&&(t.adler=K(t.adler,r.pending_buf,r.pending-a,a)),At(t),a=r.pending,r.pending===r.pending_buf_size)){n=1;break}n=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,Et(r,n)}while(0!==n);r.gzhead.hcrc&&r.pending>a&&(t.adler=K(t.adler,r.pending_buf,r.pending-a,a)),0===n&&(r.status=vt)}else r.status=vt;if(r.status===vt&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&At(t),r.pending+2<=r.pending_buf_size&&(Et(r,255&t.adler),Et(r,t.adler>>8&255),t.adler=0,r.status=wt)):r.status=wt),0!==r.pending){if(At(t),0===t.avail_out)return r.last_flush=-1,at}else if(0===t.avail_in&&yt(e)<=yt(i)&&e!==tt)return mt(t,st);if(r.status===bt&&0!==t.avail_in)return mt(t,st);if(0!==t.avail_in||0!==r.lookahead||e!==J&&r.status!==bt){var _=r.strategy===lt?function(t,e){for(var a;;){if(0===t.lookahead&&(Ut(t),0===t.lookahead)){if(e===J)return 1;break}if(t.match_length=0,a=$(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,a&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===tt?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2}(r,e):r.strategy===ot?function(t,e){for(var a,n,r,i,s=t.window;;){if(t.lookahead<=pt){if(Ut(t),t.lookahead<=pt&&e===J)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=s[r=t.strstart-1])===s[++r]&&n===s[++r]&&n===s[++r]){i=t.strstart+pt;do{}while(n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&r<i);t.match_length=pt-(i-r),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(a=$(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(a=$(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),a&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===tt?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2}(r,e):Tt[r.level].func(r,e);if(3!==_&&4!==_||(r.status=bt),1===_||3===_)return 0===t.avail_out&&(r.last_flush=-1),at;if(2===_&&(e===Q?q(r):e!==et&&(X(r,0,0,!1),e===V&&(kt(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),At(t),0===t.avail_out))return r.last_flush=-1,at}return e!==tt?at:r.wrap<=0?nt:(2===r.wrap?(Et(r,255&t.adler),Et(r,t.adler>>8&255),Et(r,t.adler>>16&255),Et(r,t.adler>>24&255),Et(r,255&t.total_in),Et(r,t.total_in>>8&255),Et(r,t.total_in>>16&255),Et(r,t.total_in>>24&255)):(Zt(r,t.adler>>>16),Zt(r,65535&t.adler)),At(t),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?at:nt)},deflateEnd:function(t){if(!t||!t.state)return rt;var e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&e!==vt&&e!==wt&&e!==bt?mt(t,rt):(t.state=null,e===wt?mt(t,it):at)},deflateSetDictionary:function(t,e){var a=e.length;if(!t||!t.state)return rt;var n=t.state,r=n.wrap;if(2===r||1===r&&42!==n.status||n.lookahead)return rt;if(1===r&&(t.adler=H(t.adler,e,a,0)),n.wrap=0,a>=n.w_size){0===r&&(kt(n.head),n.strstart=0,n.block_start=0,n.insert=0);var i=new Uint8Array(n.w_size);i.set(e.subarray(a-n.w_size,a),0),e=i,a=n.w_size}var s=t.avail_in,_=t.next_in,h=t.input;for(t.avail_in=a,t.next_in=0,t.input=e,Ut(n);n.lookahead>=3;){var l=n.strstart,o=n.lookahead-2;do{n.ins_h=zt(n,n.ins_h,n.window[l+3-1]),n.prev[l&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=l,l++}while(--o);n.strstart=l,n.lookahead=2,Ut(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=_,t.input=h,t.avail_in=s,n.wrap=r,at},deflateInfo:\"pako deflate (from Nodeca project)\"};for(var Mt=new Uint8Array(256),Bt=0;Bt<256;Bt++)Mt[Bt]=Bt>=252?6:Bt>=248?5:Bt>=240?4:Bt>=224?3:Bt>=192?2:1;Mt[254]=Mt[254]=1;var Ht=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0},Yt=Object.prototype.toString,Kt=j.Z_NO_FLUSH,Pt=j.Z_SYNC_FLUSH,jt=j.Z_FULL_FLUSH,Gt=j.Z_FINISH,Xt=j.Z_OK,Wt=j.Z_STREAM_END,$t=j.Z_DEFAULT_COMPRESSION,qt=j.Z_DEFAULT_STRATEGY,Jt=j.Z_DEFLATED;function Qt(){this.options={level:$t,method:Jt,chunkSize:16384,windowBits:15,memLevel:8,strategy:qt};var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new Ht,this.strm.avail_out=0;var e=Ct.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(e!==Xt)throw new Error(P[e]);if(t.header&&Ct.deflateSetHeader(this.strm,t.header),t.dictionary){var a;if(a=\"[object ArrayBuffer]\"===Yt.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(e=Ct.deflateSetDictionary(this.strm,a))!==Xt)throw new Error(P[e]);this._dict_set=!0}}function Vt(t,e,a){try{t.postMessage({type:\"errored\",error:e,streamId:a})}catch(n){t.postMessage({type:\"errored\",error:String(e),streamId:a})}}function te(t){var e=t.strm.adler;return new Uint8Array([3,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e])}Qt.prototype.push=function(t,e){var a,n,r=this.strm,i=this.options.chunkSize;if(this.ended)return!1;for(n=e===~~e?e:!0===e?Gt:Kt,\"[object ArrayBuffer]\"===Yt.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(i),r.next_out=0,r.avail_out=i),(n===Pt||n===jt)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if((a=Ct.deflate(r,n))===Wt)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),a=Ct.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===Xt;if(0!==r.avail_out){if(n>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},Qt.prototype.onData=function(t){this.chunks.push(t)},Qt.prototype.onEnd=function(t){t===Xt&&(this.result=function(t){for(var e=0,a=0,n=t.length;a<n;a++)e+=t[a].length;for(var r=new Uint8Array(e),i=0,s=0,_=t.length;i<_;i++){var h=t[i];r.set(h,s),s+=h.length}return r}(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},function(t){void 0===t&&(t=self);try{var e=new Map;t.addEventListener(\"message\",(function(n){try{var r=function(t,e){switch(e.action){case\"init\":return{type:\"initialized\",version:\"3.1.21\"};case\"write\":var n=t.get(e.streamId);n||(n=new Qt,t.set(e.streamId,n));var r=n.chunks.length,i=function(t){if(\"function\"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,a,n,r,i,s=t.length,_=0;for(r=0;r<s;r++)a=t.charCodeAt(r),55296==(64512&a)&&r+1<s&&(n=t.charCodeAt(r+1),56320==(64512&n)&&(a=65536+(a-55296<<10)+(n-56320),r++)),_+=a<128?1:a<2048?2:a<65536?3:4;for(e=new Uint8Array(_),i=0,r=0;i<_;r++)a=t.charCodeAt(r),55296==(64512&a)&&r+1<s&&(n=t.charCodeAt(r+1),56320==(64512&n)&&(a=65536+(a-55296<<10)+(n-56320),r++)),a<128?e[i++]=a:a<2048?(e[i++]=192|a>>>6,e[i++]=128|63&a):a<65536?(e[i++]=224|a>>>12,e[i++]=128|a>>>6&63,e[i++]=128|63&a):(e[i++]=240|a>>>18,e[i++]=128|a>>>12&63,e[i++]=128|a>>>6&63,e[i++]=128|63&a);return e}(e.data);return n.push(i,j.Z_SYNC_FLUSH),{type:\"wrote\",id:e.id,streamId:e.streamId,result:a(n.chunks.slice(r)),trailer:te(n),additionalBytesCount:i.length};case\"reset\":t.delete(e.streamId)}}(e,n.data);r&&t.postMessage(r)}catch(e){Vt(t,e,n.data&&\"streamId\"in n.data?n.data.streamId:void 0)}}))}catch(e){Vt(t,e)}}()}();"])));
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* In order to be sure that the worker is correctly working, we need a round trip of
|