@sentry/replay 0.4.5 → 0.4.8-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -1
- package/dist/dist/api/captureReplay.d.ts +7 -1
- package/dist/dist/api/captureReplayUpdate.d.ts +10 -0
- package/dist/dist/coreHandlers/handleScope.d.ts +1 -1
- package/dist/dist/eventBuffer.d.ts +13 -6
- package/dist/dist/index.d.ts +65 -8
- package/dist/dist/session/Session.d.ts +18 -7
- package/dist/dist/session/createSession.d.ts +6 -1
- package/dist/dist/session/getSession.d.ts +6 -1
- package/dist/dist/types.d.ts +22 -5
- package/dist/dist/util/isSampled.d.ts +7 -0
- package/dist/dist/util/supportsSendBeacon.d.ts +4 -0
- package/dist/esm/index.js +1454 -0
- package/dist/esm/worker-aa3eb59a.js +4 -0
- package/dist/index.es.js +551 -383
- package/dist/index.js +549 -381
- package/dist/index.js.map +1 -1
- package/dist/{config/dist/jest.config.d.ts → jest.config.d.ts} +0 -0
- package/dist/{config/dist/jest.setup.d.ts → jest.setup.d.ts} +0 -0
- package/dist/src/api/captureReplay.d.ts +3 -0
- package/dist/src/api/captureReplayUpdate.d.ts +2 -0
- package/dist/{config/dist/src → src}/coreHandlers/handleDom.d.ts +0 -0
- package/dist/{config/dist/src → src}/coreHandlers/handleFetch.d.ts +0 -0
- package/dist/{config/dist/src → src}/coreHandlers/handleFetch.test.d.ts +0 -0
- package/dist/{config/dist/src → src}/coreHandlers/handleScope-unit.test.d.ts +0 -0
- package/dist/{config/dist/src → src}/coreHandlers/handleScope.d.ts +1 -1
- package/dist/{config/dist/src → src}/coreHandlers/handleScope.test.d.ts +0 -0
- package/dist/{config/dist/src → src}/coreHandlers/handleXhr.d.ts +0 -0
- package/dist/{config/dist/src → src}/coreHandlers/index.d.ts +0 -0
- package/dist/{config/dist/src → src}/createPerformanceEntry.d.ts +0 -0
- package/dist/{config/dist/src → src}/createPerformanceEntry.test.d.ts +0 -0
- package/dist/{config/dist/src → src}/eventBuffer.d.ts +6 -6
- package/dist/{config/dist/src → src}/eventBuffer.test.d.ts +0 -0
- package/dist/{config/dist/src → src}/flags.d.ts +0 -0
- package/dist/{config/dist/src → src}/index-captureOnlyOnError.test.d.ts +0 -0
- package/dist/{config/dist/src → src}/index-noSticky.test.d.ts +0 -0
- package/dist/{config/dist/src/index.test.d.ts → src/index-sampling.test.d.ts} +0 -0
- package/dist/{config/dist/src → src}/index.d.ts +69 -8
- package/dist/{config/dist/src/session/Session.test.d.ts → src/index.test.d.ts} +0 -0
- package/dist/{config/dist/src → src}/session/Session.d.ts +18 -7
- package/dist/{config/dist/src/session/createSession.test.d.ts → src/session/Session.test.d.ts} +0 -0
- package/dist/{config/dist/src → src}/session/constants.d.ts +0 -0
- package/dist/{config/dist/src → src}/session/createSession.d.ts +6 -1
- package/dist/{config/dist/src/session/fetchSession.test.d.ts → src/session/createSession.test.d.ts} +0 -0
- package/dist/{config/dist/src → src}/session/fetchSession.d.ts +0 -0
- package/dist/{config/dist/src/session/getSession.test.d.ts → src/session/fetchSession.test.d.ts} +0 -0
- package/dist/{config/dist/src → src}/session/getSession.d.ts +6 -1
- package/dist/{config/dist/src/session/saveSession.test.d.ts → src/session/getSession.test.d.ts} +0 -0
- package/dist/{config/dist/src → src}/session/index.d.ts +0 -0
- package/dist/{config/dist/src → src}/session/saveSession.d.ts +0 -0
- package/dist/{config/dist/src/util/isExpired.test.d.ts → src/session/saveSession.test.d.ts} +0 -0
- package/dist/{config/dist/src → src}/types.d.ts +20 -5
- package/dist/{config/dist/src → src}/util/createBreadcrumb.d.ts +0 -0
- package/dist/{config/dist/src → src}/util/isExpired.d.ts +0 -0
- package/dist/{config/dist/src/util/isSessionExpired.test.d.ts → src/util/isExpired.test.d.ts} +0 -0
- package/dist/{config/dist/src → src}/util/isIngestHost.d.ts +0 -0
- package/dist/src/util/isSampled.d.ts +7 -0
- package/dist/src/util/isSampled.test.d.ts +1 -0
- package/dist/{config/dist/src → src}/util/isSessionExpired.d.ts +0 -0
- package/dist/src/util/isSessionExpired.test.d.ts +1 -0
- package/dist/{config/dist/src → src}/util/logger.d.ts +0 -0
- package/dist/src/util/supportsSendBeacon.d.ts +4 -0
- package/dist/{config/dist/test → test}/index.d.ts +0 -0
- package/dist/{config/dist/test → test}/mocks/mockRrweb.d.ts +2 -2
- package/dist/{config/dist/test → test}/mocks/mockSdk.d.ts +1 -1
- package/dist/types/jest.config.d.ts +3 -0
- package/dist/types/jest.setup.d.ts +10 -0
- package/dist/types/src/api/captureReplay.d.ts +3 -0
- package/dist/types/src/api/captureReplayUpdate.d.ts +2 -0
- package/dist/types/src/coreHandlers/handleDom.d.ts +1 -0
- package/dist/types/src/coreHandlers/handleFetch.d.ts +2 -0
- package/dist/types/src/coreHandlers/handleFetch.test.d.ts +1 -0
- package/dist/types/src/coreHandlers/handleScope-unit.test.d.ts +1 -0
- package/dist/types/src/coreHandlers/handleScope.d.ts +2 -0
- package/dist/types/src/coreHandlers/handleScope.test.d.ts +1 -0
- package/dist/types/src/coreHandlers/handleXhr.d.ts +2 -0
- package/dist/types/src/coreHandlers/index.d.ts +4 -0
- package/dist/types/src/createPerformanceEntry.d.ts +42 -0
- package/dist/types/src/createPerformanceEntry.test.d.ts +1 -0
- package/dist/types/src/eventBuffer.d.ts +31 -0
- package/dist/types/src/eventBuffer.test.d.ts +1 -0
- package/dist/types/src/flags.d.ts +2 -0
- package/dist/types/src/index-captureOnlyOnError.test.d.ts +1 -0
- package/dist/types/src/index-noSticky.test.d.ts +1 -0
- package/dist/types/src/index-sampling.test.d.ts +1 -0
- package/dist/types/src/index.d.ts +209 -0
- package/dist/types/src/index.test.d.ts +1 -0
- package/dist/types/src/session/Session.d.ts +63 -0
- package/dist/types/src/session/Session.test.d.ts +1 -0
- package/dist/types/src/session/constants.d.ts +5 -0
- package/dist/types/src/session/createSession.d.ts +19 -0
- package/dist/types/src/session/createSession.test.d.ts +1 -0
- package/dist/types/src/session/fetchSession.d.ts +5 -0
- package/dist/types/src/session/fetchSession.test.d.ts +1 -0
- package/dist/types/src/session/getSession.d.ts +28 -0
- package/dist/types/src/session/getSession.test.d.ts +1 -0
- package/dist/types/src/session/index.d.ts +1 -0
- package/dist/types/src/session/saveSession.d.ts +2 -0
- package/dist/types/src/session/saveSession.test.d.ts +1 -0
- package/dist/types/src/session/types.d.ts +0 -0
- package/dist/types/src/types.d.ts +76 -0
- package/dist/types/src/util/createBreadcrumb.d.ts +4 -0
- package/dist/types/src/util/isExpired.d.ts +5 -0
- package/dist/types/src/util/isExpired.test.d.ts +1 -0
- package/dist/types/src/util/isIngestHost.d.ts +4 -0
- package/dist/types/src/util/isSampled.d.ts +7 -0
- package/dist/types/src/util/isSampled.test.d.ts +1 -0
- package/dist/types/src/util/isSessionExpired.d.ts +5 -0
- package/dist/types/src/util/isSessionExpired.test.d.ts +1 -0
- package/dist/types/src/util/logger.d.ts +12 -0
- package/dist/types/src/util/supportsSendBeacon.d.ts +4 -0
- package/dist/types/test/index.d.ts +3 -0
- package/dist/types/test/mocks/mockRrweb.d.ts +15 -0
- package/dist/types/test/mocks/mockSdk.d.ts +11 -0
- package/dist/types/worker/src/Compressor.d.ts +15 -0
- package/dist/types/worker/src/handleMessage.d.ts +2 -0
- package/dist/worker-aa3eb59a.js +4 -0
- package/dist/worker-f4750cfb.js +7 -0
- package/dist/worker-f4750cfb.js.map +1 -0
- package/package.json +18 -6
- package/dist/config/dist/src/api/captureReplay.d.ts +0 -2
- package/dist/config/dist/src/api/captureReplayUpdate.d.ts +0 -2
- package/dist/config/dist/src/util/createPayload.d.ts +0 -5
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getCurrentHub,
|
|
2
|
-
import { logger as logger$1,
|
|
1
|
+
import { captureEvent, getCurrentHub, captureException, addGlobalEventProcessor } from '@sentry/core';
|
|
2
|
+
import { uuid4, logger as logger$1, htmlTreeAsString, addInstrumentationHandler } from '@sentry/utils';
|
|
3
3
|
import { record, EventType } from 'rrweb';
|
|
4
4
|
|
|
5
5
|
/******************************************************************************
|
|
@@ -88,250 +88,6 @@ function __spreadArray(to, from, pack) {
|
|
|
88
88
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
/**
|
|
92
|
-
* Checks is `targetHost` is a Sentry ingestion host
|
|
93
|
-
*/
|
|
94
|
-
function isIngestHost(targetHost) {
|
|
95
|
-
var _a = getCurrentHub().getClient().getDsn(), protocol = _a.protocol, host = _a.host;
|
|
96
|
-
return targetHost.startsWith("".concat(protocol, "://").concat(host));
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
var _a;
|
|
100
|
-
// Map entryType -> function to normalize data for event
|
|
101
|
-
var ENTRY_TYPES = (_a = {
|
|
102
|
-
resource: createResourceEntry,
|
|
103
|
-
paint: createPaintEntry,
|
|
104
|
-
navigation: createNavigationEntry
|
|
105
|
-
},
|
|
106
|
-
_a['largest-contentful-paint'] = createLargestContentfulPaint,
|
|
107
|
-
_a);
|
|
108
|
-
function createPerformanceEntries(entries) {
|
|
109
|
-
return entries.map(createPerformanceEntry).filter(Boolean);
|
|
110
|
-
}
|
|
111
|
-
function createPerformanceEntry(entry) {
|
|
112
|
-
if (ENTRY_TYPES[entry.entryType] === undefined) {
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
return ENTRY_TYPES[entry.entryType](entry);
|
|
116
|
-
}
|
|
117
|
-
function getAbsoluteTime(time) {
|
|
118
|
-
return (window.performance.timeOrigin + time) / 1000;
|
|
119
|
-
}
|
|
120
|
-
function createPaintEntry(entry) {
|
|
121
|
-
var duration = entry.duration, entryType = entry.entryType, name = entry.name, startTime = entry.startTime;
|
|
122
|
-
var start = getAbsoluteTime(startTime);
|
|
123
|
-
return {
|
|
124
|
-
type: entryType,
|
|
125
|
-
name: name,
|
|
126
|
-
start: start,
|
|
127
|
-
end: start + duration,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
function createNavigationEntry(entry) {
|
|
131
|
-
// TODO: There looks to be some more interesting bits in here (domComplete, domContentLoaded)
|
|
132
|
-
var entryType = entry.entryType, name = entry.name, domComplete = entry.domComplete, startTime = entry.startTime, transferSize = entry.transferSize, type = entry.type;
|
|
133
|
-
return {
|
|
134
|
-
type: "".concat(entryType, ".").concat(type),
|
|
135
|
-
start: getAbsoluteTime(startTime),
|
|
136
|
-
end: getAbsoluteTime(domComplete),
|
|
137
|
-
name: name,
|
|
138
|
-
data: {
|
|
139
|
-
size: transferSize,
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
function createResourceEntry(entry) {
|
|
144
|
-
var entryType = entry.entryType, initiatorType = entry.initiatorType, name = entry.name, responseEnd = entry.responseEnd, startTime = entry.startTime, transferSize = entry.transferSize;
|
|
145
|
-
// Do not capture fetches to Sentry ingestion endpoint
|
|
146
|
-
if (isIngestHost(name)) {
|
|
147
|
-
return null;
|
|
148
|
-
}
|
|
149
|
-
return {
|
|
150
|
-
type: "".concat(entryType, ".").concat(initiatorType),
|
|
151
|
-
start: getAbsoluteTime(startTime),
|
|
152
|
-
end: getAbsoluteTime(responseEnd),
|
|
153
|
-
name: name,
|
|
154
|
-
data: {
|
|
155
|
-
size: transferSize,
|
|
156
|
-
},
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
function createLargestContentfulPaint(entry) {
|
|
160
|
-
var duration = entry.duration, entryType = entry.entryType, startTime = entry.startTime, size = entry.size;
|
|
161
|
-
var start = getAbsoluteTime(startTime);
|
|
162
|
-
return {
|
|
163
|
-
type: entryType,
|
|
164
|
-
name: entryType,
|
|
165
|
-
start: start,
|
|
166
|
-
end: start + duration,
|
|
167
|
-
data: {
|
|
168
|
-
size: size,
|
|
169
|
-
// Not sure why this errors, Node should be correct (Argument of type 'Node' is not assignable to parameter of type 'INode')
|
|
170
|
-
nodeId: record.mirror.getId(entry.element),
|
|
171
|
-
},
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
function createMemoryEntry(memoryEntry) {
|
|
175
|
-
var jsHeapSizeLimit = memoryEntry.jsHeapSizeLimit, totalJSHeapSize = memoryEntry.totalJSHeapSize, usedJSHeapSize = memoryEntry.usedJSHeapSize;
|
|
176
|
-
// we can't use getAbsoluteTime because it adds the event time to
|
|
177
|
-
// window.performance.timeOrigin, so we get right now instead.
|
|
178
|
-
var time = new Date().getTime() / 1000;
|
|
179
|
-
return {
|
|
180
|
-
type: 'memory',
|
|
181
|
-
name: 'memory',
|
|
182
|
-
start: time,
|
|
183
|
-
end: time,
|
|
184
|
-
data: {
|
|
185
|
-
memory: {
|
|
186
|
-
jsHeapSizeLimit: jsHeapSizeLimit,
|
|
187
|
-
totalJSHeapSize: totalJSHeapSize,
|
|
188
|
-
usedJSHeapSize: usedJSHeapSize,
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function wrapLogger(logFn) {
|
|
195
|
-
return function wrappedLog() {
|
|
196
|
-
{
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
var logger = __assign(__assign({}, logger$1), { error: wrapLogger(logger$1.error), warn: wrapLogger(logger$1.warn), log: wrapLogger(logger$1.log) });
|
|
202
|
-
|
|
203
|
-
var workerString = `/*! pako 2.0.4 https://github.com/nodeca/pako @license (MIT AND Zlib) */
|
|
204
|
-
function t(t){let e=t.length;for(;--e>=0;)t[e]=0}const e=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]),a=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]),i=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),n=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),s=new Array(576);t(s);const r=new Array(60);t(r);const o=new Array(512);t(o);const l=new Array(256);t(l);const h=new Array(29);t(h);const d=new Array(30);function _(t,e,a,i,n){this.static_tree=t,this.extra_bits=e,this.extra_base=a,this.elems=i,this.max_length=n,this.has_stree=t&&t.length}let f,c,u;function w(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}t(d);const b=t=>t<256?o[t]:o[256+(t>>>7)],g=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},p=(t,e,a)=>{t.bi_valid>16-a?(t.bi_buf|=e<<t.bi_valid&65535,g(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)},m=(t,e,a)=>{p(t,a[2*e],a[2*e+1])},k=(t,e)=>{let a=0;do{a|=1&t,t>>>=1,a<<=1}while(--e>0);return a>>>1},v=(t,e,a)=>{const i=new Array(16);let n,s,r=0;for(n=1;n<=15;n++)i[n]=r=r+a[n-1]<<1;for(s=0;s<=e;s++){let e=t[2*s+1];0!==e&&(t[2*s]=k(i[e]++,e))}},y=t=>{let e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;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},x=t=>{t.bi_valid>8?g(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},z=(t,e,a,i)=>{const n=2*e,s=2*a;return t[n]<t[s]||t[n]===t[s]&&i[e]<=i[a]},A=(t,e,a)=>{const i=t.heap[a];let n=a<<1;for(;n<=t.heap_len&&(n<t.heap_len&&z(e,t.heap[n+1],t.heap[n],t.depth)&&n++,!z(e,i,t.heap[n],t.depth));)t.heap[a]=t.heap[n],a=n,n<<=1;t.heap[a]=i},E=(t,i,n)=>{let s,r,o,_,f=0;if(0!==t.last_lit)do{s=t.pending_buf[t.d_buf+2*f]<<8|t.pending_buf[t.d_buf+2*f+1],r=t.pending_buf[t.l_buf+f],f++,0===s?m(t,r,i):(o=l[r],m(t,o+256+1,i),_=e[o],0!==_&&(r-=h[o],p(t,r,_)),s--,o=b(s),m(t,o,n),_=a[o],0!==_&&(s-=d[o],p(t,s,_)))}while(f<t.last_lit);m(t,256,i)},R=(t,e)=>{const a=e.dyn_tree,i=e.stat_desc.static_tree,n=e.stat_desc.has_stree,s=e.stat_desc.elems;let r,o,l,h=-1;for(t.heap_len=0,t.heap_max=573,r=0;r<s;r++)0!==a[2*r]?(t.heap[++t.heap_len]=h=r,t.depth[r]=0):a[2*r+1]=0;for(;t.heap_len<2;)l=t.heap[++t.heap_len]=h<2?++h:0,a[2*l]=1,t.depth[l]=0,t.opt_len--,n&&(t.static_len-=i[2*l+1]);for(e.max_code=h,r=t.heap_len>>1;r>=1;r--)A(t,a,r);l=s;do{r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],A(t,a,1),o=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=o,a[2*l]=a[2*r]+a[2*o],t.depth[l]=(t.depth[r]>=t.depth[o]?t.depth[r]:t.depth[o])+1,a[2*r+1]=a[2*o+1]=l,t.heap[1]=l++,A(t,a,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const a=e.dyn_tree,i=e.max_code,n=e.stat_desc.static_tree,s=e.stat_desc.has_stree,r=e.stat_desc.extra_bits,o=e.stat_desc.extra_base,l=e.stat_desc.max_length;let h,d,_,f,c,u,w=0;for(f=0;f<=15;f++)t.bl_count[f]=0;for(a[2*t.heap[t.heap_max]+1]=0,h=t.heap_max+1;h<573;h++)d=t.heap[h],f=a[2*a[2*d+1]+1]+1,f>l&&(f=l,w++),a[2*d+1]=f,d>i||(t.bl_count[f]++,c=0,d>=o&&(c=r[d-o]),u=a[2*d],t.opt_len+=u*(f+c),s&&(t.static_len+=u*(n[2*d+1]+c)));if(0!==w){do{for(f=l-1;0===t.bl_count[f];)f--;t.bl_count[f]--,t.bl_count[f+1]+=2,t.bl_count[l]--,w-=2}while(w>0);for(f=l;0!==f;f--)for(d=t.bl_count[f];0!==d;)_=t.heap[--h],_>i||(a[2*_+1]!==f&&(t.opt_len+=(f-a[2*_+1])*a[2*_],a[2*_+1]=f),d--)}})(t,e),v(a,h,t.bl_count)},Z=(t,e,a)=>{let i,n,s=-1,r=e[1],o=0,l=7,h=4;for(0===r&&(l=138,h=3),e[2*(a+1)+1]=65535,i=0;i<=a;i++)n=r,r=e[2*(i+1)+1],++o<l&&n===r||(o<h?t.bl_tree[2*n]+=o:0!==n?(n!==s&&t.bl_tree[2*n]++,t.bl_tree[32]++):o<=10?t.bl_tree[34]++:t.bl_tree[36]++,o=0,s=n,0===r?(l=138,h=3):n===r?(l=6,h=3):(l=7,h=4))},S=(t,e,a)=>{let i,n,s=-1,r=e[1],o=0,l=7,h=4;for(0===r&&(l=138,h=3),i=0;i<=a;i++)if(n=r,r=e[2*(i+1)+1],!(++o<l&&n===r)){if(o<h)do{m(t,n,t.bl_tree)}while(0!=--o);else 0!==n?(n!==s&&(m(t,n,t.bl_tree),o--),m(t,16,t.bl_tree),p(t,o-3,2)):o<=10?(m(t,17,t.bl_tree),p(t,o-3,3)):(m(t,18,t.bl_tree),p(t,o-11,7));o=0,s=n,0===r?(l=138,h=3):n===r?(l=6,h=3):(l=7,h=4)}};let U=!1;const D=(t,e,a,i)=>{p(t,0+(i?1:0),3),((t,e,a,i)=>{x(t),i&&(g(t,a),g(t,~a)),t.pending_buf.set(t.window.subarray(e,e+a),t.pending),t.pending+=a})(t,e,a,!0)};var O=(t,e,a,i)=>{let o,l,h=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let 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<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),R(t,t.l_desc),R(t,t.d_desc),h=(t=>{let e;for(Z(t,t.dyn_ltree,t.l_desc.max_code),Z(t,t.dyn_dtree,t.d_desc.max_code),R(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*n[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),o=t.opt_len+3+7>>>3,l=t.static_len+3+7>>>3,l<=o&&(o=l)):o=l=a+5,a+4<=o&&-1!==e?D(t,e,a,i):4===t.strategy||l===o?(p(t,2+(i?1:0),3),E(t,s,r)):(p(t,4+(i?1:0),3),((t,e,a,i)=>{let s;for(p(t,e-257,5),p(t,a-1,5),p(t,i-4,4),s=0;s<i;s++)p(t,t.bl_tree[2*n[s]+1],3);S(t,t.dyn_ltree,e-1),S(t,t.dyn_dtree,a-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,h+1),E(t,t.dyn_ltree,t.dyn_dtree)),y(t),i&&x(t)},T={_tr_init:t=>{U||((()=>{let t,n,w,b,g;const p=new Array(16);for(w=0,b=0;b<28;b++)for(h[b]=w,t=0;t<1<<e[b];t++)l[w++]=b;for(l[w-1]=b,g=0,b=0;b<16;b++)for(d[b]=g,t=0;t<1<<a[b];t++)o[g++]=b;for(g>>=7;b<30;b++)for(d[b]=g<<7,t=0;t<1<<a[b]-7;t++)o[256+g++]=b;for(n=0;n<=15;n++)p[n]=0;for(t=0;t<=143;)s[2*t+1]=8,t++,p[8]++;for(;t<=255;)s[2*t+1]=9,t++,p[9]++;for(;t<=279;)s[2*t+1]=7,t++,p[7]++;for(;t<=287;)s[2*t+1]=8,t++,p[8]++;for(v(s,287,p),t=0;t<30;t++)r[2*t+1]=5,r[2*t]=k(t,5);f=new _(s,e,257,286,15),c=new _(r,a,0,30,15),u=new _(new Array(0),i,0,19,7)})(),U=!0),t.l_desc=new w(t.dyn_ltree,f),t.d_desc=new w(t.dyn_dtree,c),t.bl_desc=new w(t.bl_tree,u),t.bi_buf=0,t.bi_valid=0,y(t)},_tr_stored_block:D,_tr_flush_block:O,_tr_tally:(t,e,a)=>(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*(l[a]+256+1)]++,t.dyn_dtree[2*b(e)]++),t.last_lit===t.lit_bufsize-1),_tr_align:t=>{p(t,2,3),m(t,256,s),(t=>{16===t.bi_valid?(g(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)}};var F=(t,e,a,i)=>{let n=65535&t|0,s=t>>>16&65535|0,r=0;for(;0!==a;){r=a>2e3?2e3:a,a-=r;do{n=n+e[i++]|0,s=s+n|0}while(--r);n%=65521,s%=65521}return n|s<<16|0};const L=new Uint32Array((()=>{let t,e=[];for(var a=0;a<256;a++){t=a;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[a]=t}return e})());var N=(t,e,a,i)=>{const n=L,s=i+a;t^=-1;for(let a=i;a<s;a++)t=t>>>8^n[255&(t^e[a])];return-1^t},I={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"},B={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};const{_tr_init:C,_tr_stored_block:H,_tr_flush_block:M,_tr_tally:j,_tr_align:K}=T,{Z_NO_FLUSH:P,Z_PARTIAL_FLUSH:Y,Z_FULL_FLUSH:G,Z_FINISH:X,Z_BLOCK:W,Z_OK:J,Z_STREAM_END:q,Z_STREAM_ERROR:Q,Z_DATA_ERROR:V,Z_BUF_ERROR:$,Z_DEFAULT_COMPRESSION:tt,Z_FILTERED:et,Z_HUFFMAN_ONLY:at,Z_RLE:it,Z_FIXED:nt,Z_DEFAULT_STRATEGY:st,Z_UNKNOWN:rt,Z_DEFLATED:ot}=B,lt=(t,e)=>(t.msg=I[e],e),ht=t=>(t<<1)-(t>4?9:0),dt=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let _t=(t,e,a)=>(e<<t.hash_shift^a)&t.hash_mask;const ft=t=>{const e=t.state;let 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))},ct=(t,e)=>{M(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,ft(t.strm)},ut=(t,e)=>{t.pending_buf[t.pending++]=e},wt=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},bt=(t,e,a,i)=>{let n=t.avail_in;return n>i&&(n=i),0===n?0:(t.avail_in-=n,e.set(t.input.subarray(t.next_in,t.next_in+n),a),1===t.state.wrap?t.adler=F(t.adler,e,n,a):2===t.state.wrap&&(t.adler=N(t.adler,e,n,a)),t.next_in+=n,t.total_in+=n,n)},gt=(t,e)=>{let a,i,n=t.max_chain_length,s=t.strstart,r=t.prev_length,o=t.nice_match;const l=t.strstart>t.w_size-262?t.strstart-(t.w_size-262):0,h=t.window,d=t.w_mask,_=t.prev,f=t.strstart+258;let c=h[s+r-1],u=h[s+r];t.prev_length>=t.good_match&&(n>>=2),o>t.lookahead&&(o=t.lookahead);do{if(a=e,h[a+r]===u&&h[a+r-1]===c&&h[a]===h[s]&&h[++a]===h[s+1]){s+=2,a++;do{}while(h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&s<f);if(i=258-(f-s),s=f-258,i>r){if(t.match_start=e,r=i,i>=o)break;c=h[s+r-1],u=h[s+r]}}}while((e=_[e&d])>l&&0!=--n);return r<=t.lookahead?r:t.lookahead},pt=t=>{const e=t.w_size;let a,i,n,s,r;do{if(s=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-262)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,i=t.hash_size,a=i;do{n=t.head[--a],t.head[a]=n>=e?n-e:0}while(--i);i=e,a=i;do{n=t.prev[--a],t.prev[a]=n>=e?n-e:0}while(--i);s+=e}if(0===t.strm.avail_in)break;if(i=bt(t.strm,t.window,t.strstart+t.lookahead,s),t.lookahead+=i,t.lookahead+t.insert>=3)for(r=t.strstart-t.insert,t.ins_h=t.window[r],t.ins_h=_t(t,t.ins_h,t.window[r+1]);t.insert&&(t.ins_h=_t(t,t.ins_h,t.window[r+3-1]),t.prev[r&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=r,r++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<262&&0!==t.strm.avail_in)},mt=(t,e)=>{let a,i;for(;;){if(t.lookahead<262){if(pt(t),t.lookahead<262&&e===P)return 1;if(0===t.lookahead)break}if(a=0,t.lookahead>=3&&(t.ins_h=_t(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-262&&(t.match_length=gt(t,a)),t.match_length>=3)if(i=j(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=_t(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=_t(t,t.ins_h,t.window[t.strstart+1]);else i=j(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(ct(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===X?(ct(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(ct(t,!1),0===t.strm.avail_out)?1:2},kt=(t,e)=>{let a,i,n;for(;;){if(t.lookahead<262){if(pt(t),t.lookahead<262&&e===P)return 1;if(0===t.lookahead)break}if(a=0,t.lookahead>=3&&(t.ins_h=_t(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-262&&(t.match_length=gt(t,a),t.match_length<=5&&(t.strategy===et||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){n=t.strstart+t.lookahead-3,i=j(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=n&&(t.ins_h=_t(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++,i&&(ct(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(i=j(t,0,t.window[t.strstart-1]),i&&ct(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&&(i=j(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===X?(ct(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(ct(t,!1),0===t.strm.avail_out)?1:2};function vt(t,e,a,i,n){this.good_length=t,this.max_lazy=e,this.nice_length=a,this.max_chain=i,this.func=n}const yt=[new vt(0,0,0,0,((t,e)=>{let a=65535;for(a>t.pending_buf_size-5&&(a=t.pending_buf_size-5);;){if(t.lookahead<=1){if(pt(t),0===t.lookahead&&e===P)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;const i=t.block_start+a;if((0===t.strstart||t.strstart>=i)&&(t.lookahead=t.strstart-i,t.strstart=i,ct(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-262&&(ct(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===X?(ct(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(ct(t,!1),t.strm.avail_out),1)})),new vt(4,4,8,4,mt),new vt(4,5,16,8,mt),new vt(4,6,32,32,mt),new vt(4,4,16,16,kt),new vt(8,16,32,32,kt),new vt(8,16,128,128,kt),new vt(8,32,128,256,kt),new vt(32,128,258,1024,kt),new vt(32,258,258,4096,kt)];function xt(){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=ot,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),dt(this.dyn_ltree),dt(this.dyn_dtree),dt(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),dt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),dt(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}const zt=t=>{if(!t||!t.state)return lt(t,Q);t.total_in=t.total_out=0,t.data_type=rt;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:113,t.adler=2===e.wrap?0:1,e.last_flush=P,C(e),J},At=t=>{const e=zt(t);var a;return e===J&&((a=t.state).window_size=2*a.w_size,dt(a.head),a.max_lazy_match=yt[a.level].max_lazy,a.good_match=yt[a.level].good_length,a.nice_match=yt[a.level].nice_length,a.max_chain_length=yt[a.level].max_chain,a.strstart=0,a.block_start=0,a.lookahead=0,a.insert=0,a.match_length=a.prev_length=2,a.match_available=0,a.ins_h=0),e},Et=(t,e,a,i,n,s)=>{if(!t)return Q;let r=1;if(e===tt&&(e=6),i<0?(r=0,i=-i):i>15&&(r=2,i-=16),n<1||n>9||a!==ot||i<8||i>15||e<0||e>9||s<0||s>nt)return lt(t,Q);8===i&&(i=9);const o=new xt;return t.state=o,o.strm=t,o.wrap=r,o.gzhead=null,o.w_bits=i,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=n+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new Uint8Array(2*o.w_size),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<n+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new Uint8Array(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=3*o.lit_bufsize,o.level=e,o.strategy=s,o.method=a,At(t)};var Rt={deflateInit:(t,e)=>Et(t,e,ot,15,8,st),deflateInit2:Et,deflateReset:At,deflateResetKeep:zt,deflateSetHeader:(t,e)=>t&&t.state?2!==t.state.wrap?Q:(t.state.gzhead=e,J):Q,deflate:(t,e)=>{let a,i;if(!t||!t.state||e>W||e<0)return t?lt(t,Q):Q;const n=t.state;if(!t.output||!t.input&&0!==t.avail_in||666===n.status&&e!==X)return lt(t,0===t.avail_out?$:Q);n.strm=t;const s=n.last_flush;if(n.last_flush=e,42===n.status)if(2===n.wrap)t.adler=0,ut(n,31),ut(n,139),ut(n,8),n.gzhead?(ut(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),ut(n,255&n.gzhead.time),ut(n,n.gzhead.time>>8&255),ut(n,n.gzhead.time>>16&255),ut(n,n.gzhead.time>>24&255),ut(n,9===n.level?2:n.strategy>=at||n.level<2?4:0),ut(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(ut(n,255&n.gzhead.extra.length),ut(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=N(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(ut(n,0),ut(n,0),ut(n,0),ut(n,0),ut(n,0),ut(n,9===n.level?2:n.strategy>=at||n.level<2?4:0),ut(n,3),n.status=113);else{let e=ot+(n.w_bits-8<<4)<<8,a=-1;a=n.strategy>=at||n.level<2?0:n.level<6?1:6===n.level?2:3,e|=a<<6,0!==n.strstart&&(e|=32),e+=31-e%31,n.status=113,wt(n,e),0!==n.strstart&&(wt(n,t.adler>>>16),wt(n,65535&t.adler)),t.adler=1}if(69===n.status)if(n.gzhead.extra){for(a=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>a&&(t.adler=N(t.adler,n.pending_buf,n.pending-a,a)),ft(t),a=n.pending,n.pending!==n.pending_buf_size));)ut(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>a&&(t.adler=N(t.adler,n.pending_buf,n.pending-a,a)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){a=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>a&&(t.adler=N(t.adler,n.pending_buf,n.pending-a,a)),ft(t),a=n.pending,n.pending===n.pending_buf_size)){i=1;break}i=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,ut(n,i)}while(0!==i);n.gzhead.hcrc&&n.pending>a&&(t.adler=N(t.adler,n.pending_buf,n.pending-a,a)),0===i&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){a=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>a&&(t.adler=N(t.adler,n.pending_buf,n.pending-a,a)),ft(t),a=n.pending,n.pending===n.pending_buf_size)){i=1;break}i=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,ut(n,i)}while(0!==i);n.gzhead.hcrc&&n.pending>a&&(t.adler=N(t.adler,n.pending_buf,n.pending-a,a)),0===i&&(n.status=103)}else n.status=103;if(103===n.status&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&ft(t),n.pending+2<=n.pending_buf_size&&(ut(n,255&t.adler),ut(n,t.adler>>8&255),t.adler=0,n.status=113)):n.status=113),0!==n.pending){if(ft(t),0===t.avail_out)return n.last_flush=-1,J}else if(0===t.avail_in&&ht(e)<=ht(s)&&e!==X)return lt(t,$);if(666===n.status&&0!==t.avail_in)return lt(t,$);if(0!==t.avail_in||0!==n.lookahead||e!==P&&666!==n.status){let a=n.strategy===at?((t,e)=>{let a;for(;;){if(0===t.lookahead&&(pt(t),0===t.lookahead)){if(e===P)return 1;break}if(t.match_length=0,a=j(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,a&&(ct(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===X?(ct(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(ct(t,!1),0===t.strm.avail_out)?1:2})(n,e):n.strategy===it?((t,e)=>{let a,i,n,s;const r=t.window;for(;;){if(t.lookahead<=258){if(pt(t),t.lookahead<=258&&e===P)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=t.strstart-1,i=r[n],i===r[++n]&&i===r[++n]&&i===r[++n])){s=t.strstart+258;do{}while(i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&n<s);t.match_length=258-(s-n),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(a=j(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(a=j(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),a&&(ct(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===X?(ct(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(ct(t,!1),0===t.strm.avail_out)?1:2})(n,e):yt[n.level].func(n,e);if(3!==a&&4!==a||(n.status=666),1===a||3===a)return 0===t.avail_out&&(n.last_flush=-1),J;if(2===a&&(e===Y?K(n):e!==W&&(H(n,0,0,!1),e===G&&(dt(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),ft(t),0===t.avail_out))return n.last_flush=-1,J}return e!==X?J:n.wrap<=0?q:(2===n.wrap?(ut(n,255&t.adler),ut(n,t.adler>>8&255),ut(n,t.adler>>16&255),ut(n,t.adler>>24&255),ut(n,255&t.total_in),ut(n,t.total_in>>8&255),ut(n,t.total_in>>16&255),ut(n,t.total_in>>24&255)):(wt(n,t.adler>>>16),wt(n,65535&t.adler)),ft(t),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?J:q)},deflateEnd:t=>{if(!t||!t.state)return Q;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&103!==e&&113!==e&&666!==e?lt(t,Q):(t.state=null,113===e?lt(t,V):J)},deflateSetDictionary:(t,e)=>{let a=e.length;if(!t||!t.state)return Q;const i=t.state,n=i.wrap;if(2===n||1===n&&42!==i.status||i.lookahead)return Q;if(1===n&&(t.adler=F(t.adler,e,a,0)),i.wrap=0,a>=i.w_size){0===n&&(dt(i.head),i.strstart=0,i.block_start=0,i.insert=0);let t=new Uint8Array(i.w_size);t.set(e.subarray(a-i.w_size,a),0),e=t,a=i.w_size}const s=t.avail_in,r=t.next_in,o=t.input;for(t.avail_in=a,t.next_in=0,t.input=e,pt(i);i.lookahead>=3;){let t=i.strstart,e=i.lookahead-2;do{i.ins_h=_t(i,i.ins_h,i.window[t+3-1]),i.prev[t&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=t,t++}while(--e);i.strstart=t,i.lookahead=2,pt(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,t.next_in=r,t.input=o,t.avail_in=s,i.wrap=n,J},deflateInfo:"pako deflate (from Nodeca project)"};const Zt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var St=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const a=e.shift();if(a){if("object"!=typeof a)throw new TypeError(a+"must be non-object");for(const e in a)Zt(a,e)&&(t[e]=a[e])}}return t},Ut=t=>{let e=0;for(let a=0,i=t.length;a<i;a++)e+=t[a].length;const a=new Uint8Array(e);for(let e=0,i=0,n=t.length;e<n;e++){let n=t[e];a.set(n,i),i+=n.length}return a};let Dt=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Dt=!1}const Ot=new Uint8Array(256);for(let t=0;t<256;t++)Ot[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Ot[254]=Ot[254]=1;var Tt=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,a,i,n,s,r=t.length,o=0;for(n=0;n<r;n++)a=t.charCodeAt(n),55296==(64512&a)&&n+1<r&&(i=t.charCodeAt(n+1),56320==(64512&i)&&(a=65536+(a-55296<<10)+(i-56320),n++)),o+=a<128?1:a<2048?2:a<65536?3:4;for(e=new Uint8Array(o),s=0,n=0;s<o;n++)a=t.charCodeAt(n),55296==(64512&a)&&n+1<r&&(i=t.charCodeAt(n+1),56320==(64512&i)&&(a=65536+(a-55296<<10)+(i-56320),n++)),a<128?e[s++]=a:a<2048?(e[s++]=192|a>>>6,e[s++]=128|63&a):a<65536?(e[s++]=224|a>>>12,e[s++]=128|a>>>6&63,e[s++]=128|63&a):(e[s++]=240|a>>>18,e[s++]=128|a>>>12&63,e[s++]=128|a>>>6&63,e[s++]=128|63&a);return e},Ft=(t,e)=>{const a=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let i,n;const s=new Array(2*a);for(n=0,i=0;i<a;){let e=t[i++];if(e<128){s[n++]=e;continue}let r=Ot[e];if(r>4)s[n++]=65533,i+=r-1;else{for(e&=2===r?31:3===r?15:7;r>1&&i<a;)e=e<<6|63&t[i++],r--;r>1?s[n++]=65533:e<65536?s[n++]=e:(e-=65536,s[n++]=55296|e>>10&1023,s[n++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Dt)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let a="";for(let i=0;i<e;i++)a+=String.fromCharCode(t[i]);return a})(s,n)},Lt=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let a=e-1;for(;a>=0&&128==(192&t[a]);)a--;return a<0||0===a?e:a+Ot[t[a]]>e?a:e};var Nt=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};const It=Object.prototype.toString,{Z_NO_FLUSH:Bt,Z_SYNC_FLUSH:Ct,Z_FULL_FLUSH:Ht,Z_FINISH:Mt,Z_OK:jt,Z_STREAM_END:Kt,Z_DEFAULT_COMPRESSION:Pt,Z_DEFAULT_STRATEGY:Yt,Z_DEFLATED:Gt}=B;function Xt(t){this.options=St({level:Pt,method:Gt,chunkSize:16384,windowBits:15,memLevel:8,strategy:Yt},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Nt,this.strm.avail_out=0;let a=Rt.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(a!==jt)throw new Error(I[a]);if(e.header&&Rt.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Tt(e.dictionary):"[object ArrayBuffer]"===It.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,a=Rt.deflateSetDictionary(this.strm,t),a!==jt)throw new Error(I[a]);this._dict_set=!0}}function Wt(t,e){const a=new Xt(e);if(a.push(t,!0),a.err)throw a.msg||I[a.err];return a.result}Xt.prototype.push=function(t,e){const a=this.strm,i=this.options.chunkSize;let n,s;if(this.ended)return!1;for(s=e===~~e?e:!0===e?Mt:Bt,"string"==typeof t?a.input=Tt(t):"[object ArrayBuffer]"===It.call(t)?a.input=new Uint8Array(t):a.input=t,a.next_in=0,a.avail_in=a.input.length;;)if(0===a.avail_out&&(a.output=new Uint8Array(i),a.next_out=0,a.avail_out=i),(s===Ct||s===Ht)&&a.avail_out<=6)this.onData(a.output.subarray(0,a.next_out)),a.avail_out=0;else{if(n=Rt.deflate(a,s),n===Kt)return a.next_out>0&&this.onData(a.output.subarray(0,a.next_out)),n=Rt.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===jt;if(0!==a.avail_out){if(s>0&&a.next_out>0)this.onData(a.output.subarray(0,a.next_out)),a.avail_out=0;else if(0===a.avail_in)break}else this.onData(a.output)}return!0},Xt.prototype.onData=function(t){this.chunks.push(t)},Xt.prototype.onEnd=function(t){t===jt&&(this.result=Ut(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Jt={Deflate:Xt,deflate:Wt,deflateRaw:function(t,e){return(e=e||{}).raw=!0,Wt(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,Wt(t,e)},constants:B};var qt=function(t,e){let a,i,n,s,r,o,l,h,d,_,f,c,u,w,b,g,p,m,k,v,y,x,z,A;const E=t.state;a=t.next_in,z=t.input,i=a+(t.avail_in-5),n=t.next_out,A=t.output,s=n-(e-t.avail_out),r=n+(t.avail_out-257),o=E.dmax,l=E.wsize,h=E.whave,d=E.wnext,_=E.window,f=E.hold,c=E.bits,u=E.lencode,w=E.distcode,b=(1<<E.lenbits)-1,g=(1<<E.distbits)-1;t:do{c<15&&(f+=z[a++]<<c,c+=8,f+=z[a++]<<c,c+=8),p=u[f&b];e:for(;;){if(m=p>>>24,f>>>=m,c-=m,m=p>>>16&255,0===m)A[n++]=65535&p;else{if(!(16&m)){if(0==(64&m)){p=u[(65535&p)+(f&(1<<m)-1)];continue e}if(32&m){E.mode=12;break t}t.msg="invalid literal/length code",E.mode=30;break t}k=65535&p,m&=15,m&&(c<m&&(f+=z[a++]<<c,c+=8),k+=f&(1<<m)-1,f>>>=m,c-=m),c<15&&(f+=z[a++]<<c,c+=8,f+=z[a++]<<c,c+=8),p=w[f&g];a:for(;;){if(m=p>>>24,f>>>=m,c-=m,m=p>>>16&255,!(16&m)){if(0==(64&m)){p=w[(65535&p)+(f&(1<<m)-1)];continue a}t.msg="invalid distance code",E.mode=30;break t}if(v=65535&p,m&=15,c<m&&(f+=z[a++]<<c,c+=8,c<m&&(f+=z[a++]<<c,c+=8)),v+=f&(1<<m)-1,v>o){t.msg="invalid distance too far back",E.mode=30;break t}if(f>>>=m,c-=m,m=n-s,v>m){if(m=v-m,m>h&&E.sane){t.msg="invalid distance too far back",E.mode=30;break t}if(y=0,x=_,0===d){if(y+=l-m,m<k){k-=m;do{A[n++]=_[y++]}while(--m);y=n-v,x=A}}else if(d<m){if(y+=l+d-m,m-=d,m<k){k-=m;do{A[n++]=_[y++]}while(--m);if(y=0,d<k){m=d,k-=m;do{A[n++]=_[y++]}while(--m);y=n-v,x=A}}}else if(y+=d-m,m<k){k-=m;do{A[n++]=_[y++]}while(--m);y=n-v,x=A}for(;k>2;)A[n++]=x[y++],A[n++]=x[y++],A[n++]=x[y++],k-=3;k&&(A[n++]=x[y++],k>1&&(A[n++]=x[y++]))}else{y=n-v;do{A[n++]=A[y++],A[n++]=A[y++],A[n++]=A[y++],k-=3}while(k>2);k&&(A[n++]=A[y++],k>1&&(A[n++]=A[y++]))}break}}break}}while(a<i&&n<r);k=c>>3,a-=k,c-=k<<3,f&=(1<<c)-1,t.next_in=a,t.next_out=n,t.avail_in=a<i?i-a+5:5-(a-i),t.avail_out=n<r?r-n+257:257-(n-r),E.hold=f,E.bits=c};const Qt=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Vt=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),$t=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),te=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var ee=(t,e,a,i,n,s,r,o)=>{const l=o.bits;let h,d,_,f,c,u,w=0,b=0,g=0,p=0,m=0,k=0,v=0,y=0,x=0,z=0,A=null,E=0;const R=new Uint16Array(16),Z=new Uint16Array(16);let S,U,D,O=null,T=0;for(w=0;w<=15;w++)R[w]=0;for(b=0;b<i;b++)R[e[a+b]]++;for(m=l,p=15;p>=1&&0===R[p];p--);if(m>p&&(m=p),0===p)return n[s++]=20971520,n[s++]=20971520,o.bits=1,0;for(g=1;g<p&&0===R[g];g++);for(m<g&&(m=g),y=1,w=1;w<=15;w++)if(y<<=1,y-=R[w],y<0)return-1;if(y>0&&(0===t||1!==p))return-1;for(Z[1]=0,w=1;w<15;w++)Z[w+1]=Z[w]+R[w];for(b=0;b<i;b++)0!==e[a+b]&&(r[Z[e[a+b]]++]=b);if(0===t?(A=O=r,u=19):1===t?(A=Qt,E-=257,O=Vt,T-=257,u=256):(A=$t,O=te,u=-1),z=0,b=0,w=g,c=s,k=m,v=0,_=-1,x=1<<m,f=x-1,1===t&&x>852||2===t&&x>592)return 1;for(;;){S=w-v,r[b]<u?(U=0,D=r[b]):r[b]>u?(U=O[T+r[b]],D=A[E+r[b]]):(U=96,D=0),h=1<<w-v,d=1<<k,g=d;do{d-=h,n[c+(z>>v)+d]=S<<24|U<<16|D|0}while(0!==d);for(h=1<<w-1;z&h;)h>>=1;if(0!==h?(z&=h-1,z+=h):z=0,b++,0==--R[w]){if(w===p)break;w=e[a+r[b]]}if(w>m&&(z&f)!==_){for(0===v&&(v=m),c+=g,k=w-v,y=1<<k;k+v<p&&(y-=R[k+v],!(y<=0));)k++,y<<=1;if(x+=1<<k,1===t&&x>852||2===t&&x>592)return 1;_=z&f,n[_]=m<<24|k<<16|c-s|0}}return 0!==z&&(n[c+z]=w-v<<24|64<<16|0),o.bits=m,0};const{Z_FINISH:ae,Z_BLOCK:ie,Z_TREES:ne,Z_OK:se,Z_STREAM_END:re,Z_NEED_DICT:oe,Z_STREAM_ERROR:le,Z_DATA_ERROR:he,Z_MEM_ERROR:de,Z_BUF_ERROR:_e,Z_DEFLATED:fe}=B,ce=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function ue(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const we=t=>{if(!t||!t.state)return le;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,se},be=t=>{if(!t||!t.state)return le;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,we(t)},ge=(t,e)=>{let a;if(!t||!t.state)return le;const i=t.state;return e<0?(a=0,e=-e):(a=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?le:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=a,i.wbits=e,be(t))},pe=(t,e)=>{if(!t)return le;const a=new ue;t.state=a,a.window=null;const i=ge(t,e);return i!==se&&(t.state=null),i};let me,ke,ve=!0;const ye=t=>{if(ve){me=new Int32Array(512),ke=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(ee(1,t.lens,0,288,me,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;ee(2,t.lens,0,32,ke,0,t.work,{bits:5}),ve=!1}t.lencode=me,t.lenbits=9,t.distcode=ke,t.distbits=5},xe=(t,e,a,i)=>{let n;const s=t.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),i>=s.wsize?(s.window.set(e.subarray(a-s.wsize,a),0),s.wnext=0,s.whave=s.wsize):(n=s.wsize-s.wnext,n>i&&(n=i),s.window.set(e.subarray(a-i,a-i+n),s.wnext),(i-=n)?(s.window.set(e.subarray(a-i,a),0),s.wnext=i,s.whave=s.wsize):(s.wnext+=n,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=n))),0};var ze={inflateReset:be,inflateReset2:ge,inflateResetKeep:we,inflateInit:t=>pe(t,15),inflateInit2:pe,inflate:(t,e)=>{let a,i,n,s,r,o,l,h,d,_,f,c,u,w,b,g,p,m,k,v,y,x,z=0;const A=new Uint8Array(4);let E,R;const Z=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return le;a=t.state,12===a.mode&&(a.mode=13),r=t.next_out,n=t.output,l=t.avail_out,s=t.next_in,i=t.input,o=t.avail_in,h=a.hold,d=a.bits,_=o,f=l,x=se;t:for(;;)switch(a.mode){case 1:if(0===a.wrap){a.mode=13;break}for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(2&a.wrap&&35615===h){a.check=0,A[0]=255&h,A[1]=h>>>8&255,a.check=N(a.check,A,2,0),h=0,d=0,a.mode=2;break}if(a.flags=0,a.head&&(a.head.done=!1),!(1&a.wrap)||(((255&h)<<8)+(h>>8))%31){t.msg="incorrect header check",a.mode=30;break}if((15&h)!==fe){t.msg="unknown compression method",a.mode=30;break}if(h>>>=4,d-=4,y=8+(15&h),0===a.wbits)a.wbits=y;else if(y>a.wbits){t.msg="invalid window size",a.mode=30;break}a.dmax=1<<a.wbits,t.adler=a.check=1,a.mode=512&h?10:12,h=0,d=0;break;case 2:for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(a.flags=h,(255&a.flags)!==fe){t.msg="unknown compression method",a.mode=30;break}if(57344&a.flags){t.msg="unknown header flags set",a.mode=30;break}a.head&&(a.head.text=h>>8&1),512&a.flags&&(A[0]=255&h,A[1]=h>>>8&255,a.check=N(a.check,A,2,0)),h=0,d=0,a.mode=3;case 3:for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.head&&(a.head.time=h),512&a.flags&&(A[0]=255&h,A[1]=h>>>8&255,A[2]=h>>>16&255,A[3]=h>>>24&255,a.check=N(a.check,A,4,0)),h=0,d=0,a.mode=4;case 4:for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.head&&(a.head.xflags=255&h,a.head.os=h>>8),512&a.flags&&(A[0]=255&h,A[1]=h>>>8&255,a.check=N(a.check,A,2,0)),h=0,d=0,a.mode=5;case 5:if(1024&a.flags){for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.length=h,a.head&&(a.head.extra_len=h),512&a.flags&&(A[0]=255&h,A[1]=h>>>8&255,a.check=N(a.check,A,2,0)),h=0,d=0}else a.head&&(a.head.extra=null);a.mode=6;case 6:if(1024&a.flags&&(c=a.length,c>o&&(c=o),c&&(a.head&&(y=a.head.extra_len-a.length,a.head.extra||(a.head.extra=new Uint8Array(a.head.extra_len)),a.head.extra.set(i.subarray(s,s+c),y)),512&a.flags&&(a.check=N(a.check,i,c,s)),o-=c,s+=c,a.length-=c),a.length))break t;a.length=0,a.mode=7;case 7:if(2048&a.flags){if(0===o)break t;c=0;do{y=i[s+c++],a.head&&y&&a.length<65536&&(a.head.name+=String.fromCharCode(y))}while(y&&c<o);if(512&a.flags&&(a.check=N(a.check,i,c,s)),o-=c,s+=c,y)break t}else a.head&&(a.head.name=null);a.length=0,a.mode=8;case 8:if(4096&a.flags){if(0===o)break t;c=0;do{y=i[s+c++],a.head&&y&&a.length<65536&&(a.head.comment+=String.fromCharCode(y))}while(y&&c<o);if(512&a.flags&&(a.check=N(a.check,i,c,s)),o-=c,s+=c,y)break t}else a.head&&(a.head.comment=null);a.mode=9;case 9:if(512&a.flags){for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(h!==(65535&a.check)){t.msg="header crc mismatch",a.mode=30;break}h=0,d=0}a.head&&(a.head.hcrc=a.flags>>9&1,a.head.done=!0),t.adler=a.check=0,a.mode=12;break;case 10:for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}t.adler=a.check=ce(h),h=0,d=0,a.mode=11;case 11:if(0===a.havedict)return t.next_out=r,t.avail_out=l,t.next_in=s,t.avail_in=o,a.hold=h,a.bits=d,oe;t.adler=a.check=1,a.mode=12;case 12:if(e===ie||e===ne)break t;case 13:if(a.last){h>>>=7&d,d-=7&d,a.mode=27;break}for(;d<3;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}switch(a.last=1&h,h>>>=1,d-=1,3&h){case 0:a.mode=14;break;case 1:if(ye(a),a.mode=20,e===ne){h>>>=2,d-=2;break t}break;case 2:a.mode=17;break;case 3:t.msg="invalid block type",a.mode=30}h>>>=2,d-=2;break;case 14:for(h>>>=7&d,d-=7&d;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if((65535&h)!=(h>>>16^65535)){t.msg="invalid stored block lengths",a.mode=30;break}if(a.length=65535&h,h=0,d=0,a.mode=15,e===ne)break t;case 15:a.mode=16;case 16:if(c=a.length,c){if(c>o&&(c=o),c>l&&(c=l),0===c)break t;n.set(i.subarray(s,s+c),r),o-=c,s+=c,l-=c,r+=c,a.length-=c;break}a.mode=12;break;case 17:for(;d<14;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(a.nlen=257+(31&h),h>>>=5,d-=5,a.ndist=1+(31&h),h>>>=5,d-=5,a.ncode=4+(15&h),h>>>=4,d-=4,a.nlen>286||a.ndist>30){t.msg="too many length or distance symbols",a.mode=30;break}a.have=0,a.mode=18;case 18:for(;a.have<a.ncode;){for(;d<3;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.lens[Z[a.have++]]=7&h,h>>>=3,d-=3}for(;a.have<19;)a.lens[Z[a.have++]]=0;if(a.lencode=a.lendyn,a.lenbits=7,E={bits:a.lenbits},x=ee(0,a.lens,0,19,a.lencode,0,a.work,E),a.lenbits=E.bits,x){t.msg="invalid code lengths set",a.mode=30;break}a.have=0,a.mode=19;case 19:for(;a.have<a.nlen+a.ndist;){for(;z=a.lencode[h&(1<<a.lenbits)-1],b=z>>>24,g=z>>>16&255,p=65535&z,!(b<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(p<16)h>>>=b,d-=b,a.lens[a.have++]=p;else{if(16===p){for(R=b+2;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(h>>>=b,d-=b,0===a.have){t.msg="invalid bit length repeat",a.mode=30;break}y=a.lens[a.have-1],c=3+(3&h),h>>>=2,d-=2}else if(17===p){for(R=b+3;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=b,d-=b,y=0,c=3+(7&h),h>>>=3,d-=3}else{for(R=b+7;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=b,d-=b,y=0,c=11+(127&h),h>>>=7,d-=7}if(a.have+c>a.nlen+a.ndist){t.msg="invalid bit length repeat",a.mode=30;break}for(;c--;)a.lens[a.have++]=y}}if(30===a.mode)break;if(0===a.lens[256]){t.msg="invalid code -- missing end-of-block",a.mode=30;break}if(a.lenbits=9,E={bits:a.lenbits},x=ee(1,a.lens,0,a.nlen,a.lencode,0,a.work,E),a.lenbits=E.bits,x){t.msg="invalid literal/lengths set",a.mode=30;break}if(a.distbits=6,a.distcode=a.distdyn,E={bits:a.distbits},x=ee(2,a.lens,a.nlen,a.ndist,a.distcode,0,a.work,E),a.distbits=E.bits,x){t.msg="invalid distances set",a.mode=30;break}if(a.mode=20,e===ne)break t;case 20:a.mode=21;case 21:if(o>=6&&l>=258){t.next_out=r,t.avail_out=l,t.next_in=s,t.avail_in=o,a.hold=h,a.bits=d,qt(t,f),r=t.next_out,n=t.output,l=t.avail_out,s=t.next_in,i=t.input,o=t.avail_in,h=a.hold,d=a.bits,12===a.mode&&(a.back=-1);break}for(a.back=0;z=a.lencode[h&(1<<a.lenbits)-1],b=z>>>24,g=z>>>16&255,p=65535&z,!(b<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(g&&0==(240&g)){for(m=b,k=g,v=p;z=a.lencode[v+((h&(1<<m+k)-1)>>m)],b=z>>>24,g=z>>>16&255,p=65535&z,!(m+b<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=m,d-=m,a.back+=m}if(h>>>=b,d-=b,a.back+=b,a.length=p,0===g){a.mode=26;break}if(32&g){a.back=-1,a.mode=12;break}if(64&g){t.msg="invalid literal/length code",a.mode=30;break}a.extra=15&g,a.mode=22;case 22:if(a.extra){for(R=a.extra;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.length+=h&(1<<a.extra)-1,h>>>=a.extra,d-=a.extra,a.back+=a.extra}a.was=a.length,a.mode=23;case 23:for(;z=a.distcode[h&(1<<a.distbits)-1],b=z>>>24,g=z>>>16&255,p=65535&z,!(b<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(0==(240&g)){for(m=b,k=g,v=p;z=a.distcode[v+((h&(1<<m+k)-1)>>m)],b=z>>>24,g=z>>>16&255,p=65535&z,!(m+b<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=m,d-=m,a.back+=m}if(h>>>=b,d-=b,a.back+=b,64&g){t.msg="invalid distance code",a.mode=30;break}a.offset=p,a.extra=15&g,a.mode=24;case 24:if(a.extra){for(R=a.extra;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.offset+=h&(1<<a.extra)-1,h>>>=a.extra,d-=a.extra,a.back+=a.extra}if(a.offset>a.dmax){t.msg="invalid distance too far back",a.mode=30;break}a.mode=25;case 25:if(0===l)break t;if(c=f-l,a.offset>c){if(c=a.offset-c,c>a.whave&&a.sane){t.msg="invalid distance too far back",a.mode=30;break}c>a.wnext?(c-=a.wnext,u=a.wsize-c):u=a.wnext-c,c>a.length&&(c=a.length),w=a.window}else w=n,u=r-a.offset,c=a.length;c>l&&(c=l),l-=c,a.length-=c;do{n[r++]=w[u++]}while(--c);0===a.length&&(a.mode=21);break;case 26:if(0===l)break t;n[r++]=a.length,l--,a.mode=21;break;case 27:if(a.wrap){for(;d<32;){if(0===o)break t;o--,h|=i[s++]<<d,d+=8}if(f-=l,t.total_out+=f,a.total+=f,f&&(t.adler=a.check=a.flags?N(a.check,n,f,r-f):F(a.check,n,f,r-f)),f=l,(a.flags?h:ce(h))!==a.check){t.msg="incorrect data check",a.mode=30;break}h=0,d=0}a.mode=28;case 28:if(a.wrap&&a.flags){for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(h!==(4294967295&a.total)){t.msg="incorrect length check",a.mode=30;break}h=0,d=0}a.mode=29;case 29:x=re;break t;case 30:x=he;break t;case 31:return de;default:return le}return t.next_out=r,t.avail_out=l,t.next_in=s,t.avail_in=o,a.hold=h,a.bits=d,(a.wsize||f!==t.avail_out&&a.mode<30&&(a.mode<27||e!==ae))&&xe(t,t.output,t.next_out,f-t.avail_out),_-=t.avail_in,f-=t.avail_out,t.total_in+=_,t.total_out+=f,a.total+=f,a.wrap&&f&&(t.adler=a.check=a.flags?N(a.check,n,f,t.next_out-f):F(a.check,n,f,t.next_out-f)),t.data_type=a.bits+(a.last?64:0)+(12===a.mode?128:0)+(20===a.mode||15===a.mode?256:0),(0===_&&0===f||e===ae)&&x===se&&(x=_e),x},inflateEnd:t=>{if(!t||!t.state)return le;let e=t.state;return e.window&&(e.window=null),t.state=null,se},inflateGetHeader:(t,e)=>{if(!t||!t.state)return le;const a=t.state;return 0==(2&a.wrap)?le:(a.head=e,e.done=!1,se)},inflateSetDictionary:(t,e)=>{const a=e.length;let i,n,s;return t&&t.state?(i=t.state,0!==i.wrap&&11!==i.mode?le:11===i.mode&&(n=1,n=F(n,e,a,0),n!==i.check)?he:(s=xe(t,e,a,a),s?(i.mode=31,de):(i.havedict=1,se))):le},inflateInfo:"pako inflate (from Nodeca project)"};var Ae=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Ee=Object.prototype.toString,{Z_NO_FLUSH:Re,Z_FINISH:Ze,Z_OK:Se,Z_STREAM_END:Ue,Z_NEED_DICT:De,Z_STREAM_ERROR:Oe,Z_DATA_ERROR:Te,Z_MEM_ERROR:Fe}=B;function Le(t){this.options=St({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Nt,this.strm.avail_out=0;let a=ze.inflateInit2(this.strm,e.windowBits);if(a!==Se)throw new Error(I[a]);if(this.header=new Ae,ze.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Tt(e.dictionary):"[object ArrayBuffer]"===Ee.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(a=ze.inflateSetDictionary(this.strm,e.dictionary),a!==Se)))throw new Error(I[a])}Le.prototype.push=function(t,e){const a=this.strm,i=this.options.chunkSize,n=this.options.dictionary;let s,r,o;if(this.ended)return!1;for(r=e===~~e?e:!0===e?Ze:Re,"[object ArrayBuffer]"===Ee.call(t)?a.input=new Uint8Array(t):a.input=t,a.next_in=0,a.avail_in=a.input.length;;){for(0===a.avail_out&&(a.output=new Uint8Array(i),a.next_out=0,a.avail_out=i),s=ze.inflate(a,r),s===De&&n&&(s=ze.inflateSetDictionary(a,n),s===Se?s=ze.inflate(a,r):s===Te&&(s=De));a.avail_in>0&&s===Ue&&a.state.wrap>0&&0!==t[a.next_in];)ze.inflateReset(a),s=ze.inflate(a,r);switch(s){case Oe:case Te:case De:case Fe:return this.onEnd(s),this.ended=!0,!1}if(o=a.avail_out,a.next_out&&(0===a.avail_out||s===Ue))if("string"===this.options.to){let t=Lt(a.output,a.next_out),e=a.next_out-t,n=Ft(a.output,t);a.next_out=e,a.avail_out=i-e,e&&a.output.set(a.output.subarray(t,t+e),0),this.onData(n)}else this.onData(a.output.length===a.next_out?a.output:a.output.subarray(0,a.next_out));if(s!==Se||0!==o){if(s===Ue)return s=ze.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===a.avail_in)break}}return!0},Le.prototype.onData=function(t){this.chunks.push(t)},Le.prototype.onEnd=function(t){t===Se&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Ut(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};const{Deflate:Ne,deflate:Ie,deflateRaw:Be,gzip:Ce}=Jt;var He=Ne,Me=B,je=new(function(){function t(){this.init()}return t.prototype.init=function(){return this.added=0,this.deflate=new He,this.deflate.push("[",Me.Z_NO_FLUSH),!0},t.prototype.addEvent=function(t){var e=this.added>0?",":"";return this.deflate.push(e+JSON.stringify(t),Me.Z_NO_FLUSH),this.added++,!0},t.prototype.finish=function(){if(this.deflate.push("]",Me.Z_FINISH),this.deflate.err)throw this.deflate.err;var t=this.deflate.result;return this.init(),t},t}()),Ke={init:function(){return je.init(),""},addEvent:function(t){return je.addEvent(t),""},finish:function(){return je.finish()}};addEventListener("message",(function(t){var e=t.data.method,a=(t.data.args||[])[0];if(e in Ke&&"function"==typeof Ke[e])try{var i=Ke[e](a);postMessage({method:e,success:!0,response:i})}catch(t){postMessage({method:e,success:!1,response:t}),console.error(t)}}));`;
|
|
205
|
-
|
|
206
|
-
function createEventBuffer(_a) {
|
|
207
|
-
var useCompression = _a.useCompression;
|
|
208
|
-
if (useCompression && window.Worker) {
|
|
209
|
-
var workerBlob = new Blob([workerString]);
|
|
210
|
-
var workerUrl = URL.createObjectURL(workerBlob);
|
|
211
|
-
try {
|
|
212
|
-
logger.log('using compression worker');
|
|
213
|
-
return new EventBufferCompressionWorker(new Worker(workerUrl));
|
|
214
|
-
}
|
|
215
|
-
catch (_b) {
|
|
216
|
-
// catch and ignore, fallback to simple event buffer
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
logger.log('falling back to simple event buffer');
|
|
220
|
-
return new EventBufferArray();
|
|
221
|
-
}
|
|
222
|
-
var EventBufferArray = /** @class */ (function () {
|
|
223
|
-
function EventBufferArray() {
|
|
224
|
-
this.events = [];
|
|
225
|
-
}
|
|
226
|
-
EventBufferArray.prototype.destroy = function () {
|
|
227
|
-
this.events = [];
|
|
228
|
-
};
|
|
229
|
-
Object.defineProperty(EventBufferArray.prototype, "length", {
|
|
230
|
-
get: function () {
|
|
231
|
-
return this.events.length;
|
|
232
|
-
},
|
|
233
|
-
enumerable: false,
|
|
234
|
-
configurable: true
|
|
235
|
-
});
|
|
236
|
-
EventBufferArray.prototype.addEvent = function (event, isCheckout) {
|
|
237
|
-
if (isCheckout) {
|
|
238
|
-
this.events = [event];
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
this.events.push(event);
|
|
242
|
-
};
|
|
243
|
-
EventBufferArray.prototype.finish = function () {
|
|
244
|
-
var _this = this;
|
|
245
|
-
return new Promise(function (resolve) {
|
|
246
|
-
// Make a copy of the events array reference and immediately clear the
|
|
247
|
-
// events member so that we do not lose new events while uploading
|
|
248
|
-
// attachment.
|
|
249
|
-
var eventsRet = _this.events;
|
|
250
|
-
_this.events = [];
|
|
251
|
-
resolve(JSON.stringify(eventsRet));
|
|
252
|
-
});
|
|
253
|
-
};
|
|
254
|
-
return EventBufferArray;
|
|
255
|
-
}());
|
|
256
|
-
// exporting for testing
|
|
257
|
-
var EventBufferCompressionWorker = /** @class */ (function () {
|
|
258
|
-
function EventBufferCompressionWorker(worker) {
|
|
259
|
-
this.eventBufferItemLength = 0;
|
|
260
|
-
this.worker = worker;
|
|
261
|
-
}
|
|
262
|
-
EventBufferCompressionWorker.prototype.init = function () {
|
|
263
|
-
this.worker.postMessage({ method: 'init', args: [] });
|
|
264
|
-
logger.log('Message posted to worker');
|
|
265
|
-
};
|
|
266
|
-
EventBufferCompressionWorker.prototype.destroy = function () {
|
|
267
|
-
this.worker.terminate();
|
|
268
|
-
this.worker = null;
|
|
269
|
-
};
|
|
270
|
-
Object.defineProperty(EventBufferCompressionWorker.prototype, "length", {
|
|
271
|
-
get: function () {
|
|
272
|
-
return this.eventBufferItemLength;
|
|
273
|
-
},
|
|
274
|
-
enumerable: false,
|
|
275
|
-
configurable: true
|
|
276
|
-
});
|
|
277
|
-
EventBufferCompressionWorker.prototype.addEvent = function (event, isCheckout) {
|
|
278
|
-
var _this = this;
|
|
279
|
-
// If it is a checkout we should make sure worker buffer is cleared before proceeding
|
|
280
|
-
if (!isCheckout) {
|
|
281
|
-
this.sendEventToWorker(event);
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
var initListener = function (_a) {
|
|
285
|
-
var data = _a.data;
|
|
286
|
-
if (data.method !== 'init') {
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
if (!data.success) {
|
|
290
|
-
// TODO: Do some error handling, not sure what
|
|
291
|
-
logger.error(data.response);
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
// Worker has been re-initialized, can add event now
|
|
295
|
-
_this.sendEventToWorker(event);
|
|
296
|
-
_this.worker.removeEventListener('message', initListener);
|
|
297
|
-
};
|
|
298
|
-
this.worker.addEventListener('message', initListener);
|
|
299
|
-
this.worker.postMessage({ method: 'init', args: [] });
|
|
300
|
-
};
|
|
301
|
-
EventBufferCompressionWorker.prototype.sendEventToWorker = function (event) {
|
|
302
|
-
this.worker.postMessage({
|
|
303
|
-
method: 'addEvent',
|
|
304
|
-
args: [event],
|
|
305
|
-
});
|
|
306
|
-
logger.log('Message posted to worker');
|
|
307
|
-
this.eventBufferItemLength++;
|
|
308
|
-
};
|
|
309
|
-
EventBufferCompressionWorker.prototype.finish = function () {
|
|
310
|
-
var _this = this;
|
|
311
|
-
return new Promise(function (resolve) {
|
|
312
|
-
var finishListener = function (_a) {
|
|
313
|
-
var data = _a.data;
|
|
314
|
-
if (data.method !== 'finish') {
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
if (!data.success) {
|
|
318
|
-
// TODO: Do some error handling, not sure what
|
|
319
|
-
logger.error(data.response);
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
logger.log('sending compressed');
|
|
323
|
-
resolve(data.response);
|
|
324
|
-
_this.eventBufferItemLength = 0;
|
|
325
|
-
_this.worker.removeEventListener('message', finishListener);
|
|
326
|
-
};
|
|
327
|
-
_this.worker.addEventListener('message', finishListener);
|
|
328
|
-
_this.worker.postMessage({ method: 'finish', args: [] });
|
|
329
|
-
logger.log('Message posted to worker');
|
|
330
|
-
});
|
|
331
|
-
};
|
|
332
|
-
return EventBufferCompressionWorker;
|
|
333
|
-
}());
|
|
334
|
-
|
|
335
91
|
var REPLAY_SESSION_KEY = 'sentryReplaySession';
|
|
336
92
|
var ROOT_REPLAY_NAME = 'sentry-replay';
|
|
337
93
|
var REPLAY_EVENT_NAME = 'sentry-replay-event';
|
|
@@ -340,6 +96,27 @@ var SESSION_IDLE_DURATION = 900000; // 15 minutes
|
|
|
340
96
|
// Grace period to keep a session when a user changes tabs or hides window
|
|
341
97
|
var VISIBILITY_CHANGE_TIMEOUT = SESSION_IDLE_DURATION;
|
|
342
98
|
|
|
99
|
+
function captureReplay(_a) {
|
|
100
|
+
var session = _a.session, initialState = _a.initialState;
|
|
101
|
+
captureEvent({
|
|
102
|
+
message: ROOT_REPLAY_NAME,
|
|
103
|
+
tags: { segmentId: session.segmentId, url: initialState.url },
|
|
104
|
+
timestamp: initialState.timestamp / 1000,
|
|
105
|
+
}, { event_id: session.id });
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function captureReplayUpdate(_a) {
|
|
109
|
+
var session = _a.session, timestamp = _a.timestamp;
|
|
110
|
+
captureEvent({
|
|
111
|
+
timestamp: timestamp / 1000,
|
|
112
|
+
message: "".concat(REPLAY_EVENT_NAME, "-").concat(uuid4().substring(16)),
|
|
113
|
+
tags: {
|
|
114
|
+
replayId: session.id,
|
|
115
|
+
segmentId: session.segmentId++,
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
343
120
|
/**
|
|
344
121
|
* Given an initial timestamp and an expiry duration, checks to see if current
|
|
345
122
|
* time should be considered as expired.
|
|
@@ -365,6 +142,15 @@ function isSessionExpired(session, expiry, targetTime) {
|
|
|
365
142
|
return isExpired(session.lastActivity, expiry, targetTime);
|
|
366
143
|
}
|
|
367
144
|
|
|
145
|
+
function wrapLogger(logFn) {
|
|
146
|
+
return function wrappedLog() {
|
|
147
|
+
{
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
var logger = __assign(__assign({}, logger$1), { error: wrapLogger(logger$1.error), warn: wrapLogger(logger$1.warn), log: wrapLogger(logger$1.log) });
|
|
153
|
+
|
|
368
154
|
function saveSession(session) {
|
|
369
155
|
var hasSessionStorage = 'sessionStorage' in window;
|
|
370
156
|
if (!hasSessionStorage) {
|
|
@@ -378,16 +164,28 @@ function saveSession(session) {
|
|
|
378
164
|
}
|
|
379
165
|
}
|
|
380
166
|
|
|
167
|
+
/**
|
|
168
|
+
* Given a sample rate, returns true if replay should be sampled.
|
|
169
|
+
*
|
|
170
|
+
* 1.0 = 100% sampling
|
|
171
|
+
* 0.0 = 0% sampling
|
|
172
|
+
*/
|
|
173
|
+
function isSampled(sampleRate) {
|
|
174
|
+
// Math.random() returns a number in range of 0 to 1 (inclusive of 0, but not 1)
|
|
175
|
+
return Math.random() < sampleRate;
|
|
176
|
+
}
|
|
177
|
+
|
|
381
178
|
var Session = /** @class */ (function () {
|
|
382
179
|
function Session(session, _a) {
|
|
383
180
|
if (session === void 0) { session = {}; }
|
|
384
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.stickySession, stickySession = _c === void 0 ? false : _c;
|
|
385
|
-
var
|
|
181
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.stickySession, stickySession = _c === void 0 ? false : _c, _d = _b.samplingRate, samplingRate = _d === void 0 ? 1.0 : _d;
|
|
182
|
+
var _e, _f, _g, _h;
|
|
386
183
|
var now = new Date().getTime();
|
|
387
184
|
this._id = session.id || uuid4();
|
|
388
|
-
this._started = (
|
|
389
|
-
this._lastActivity = (
|
|
390
|
-
this.
|
|
185
|
+
this._started = (_e = session.started) !== null && _e !== void 0 ? _e : now;
|
|
186
|
+
this._lastActivity = (_f = session.lastActivity) !== null && _f !== void 0 ? _f : now;
|
|
187
|
+
this._segmentId = (_g = session.segmentId) !== null && _g !== void 0 ? _g : 0;
|
|
188
|
+
this._sampled = (_h = session.sampled) !== null && _h !== void 0 ? _h : isSampled(samplingRate);
|
|
391
189
|
this.options = {
|
|
392
190
|
stickySession: stickySession,
|
|
393
191
|
};
|
|
@@ -419,12 +217,12 @@ var Session = /** @class */ (function () {
|
|
|
419
217
|
enumerable: false,
|
|
420
218
|
configurable: true
|
|
421
219
|
});
|
|
422
|
-
Object.defineProperty(Session.prototype, "
|
|
220
|
+
Object.defineProperty(Session.prototype, "segmentId", {
|
|
423
221
|
get: function () {
|
|
424
|
-
return this.
|
|
222
|
+
return this._segmentId;
|
|
425
223
|
},
|
|
426
224
|
set: function (id) {
|
|
427
|
-
this.
|
|
225
|
+
this._segmentId = id;
|
|
428
226
|
if (this.options.stickySession) {
|
|
429
227
|
saveSession(this);
|
|
430
228
|
}
|
|
@@ -442,12 +240,23 @@ var Session = /** @class */ (function () {
|
|
|
442
240
|
enumerable: false,
|
|
443
241
|
configurable: true
|
|
444
242
|
});
|
|
243
|
+
Object.defineProperty(Session.prototype, "sampled", {
|
|
244
|
+
get: function () {
|
|
245
|
+
return this._sampled;
|
|
246
|
+
},
|
|
247
|
+
set: function (_isSampled) {
|
|
248
|
+
throw new Error('Unable to change sampled value');
|
|
249
|
+
},
|
|
250
|
+
enumerable: false,
|
|
251
|
+
configurable: true
|
|
252
|
+
});
|
|
445
253
|
Session.prototype.toJSON = function () {
|
|
446
254
|
return {
|
|
447
255
|
id: this.id,
|
|
448
256
|
started: this.started,
|
|
449
257
|
lastActivity: this.lastActivity,
|
|
450
|
-
|
|
258
|
+
segmentId: this._segmentId,
|
|
259
|
+
sampled: this._sampled,
|
|
451
260
|
};
|
|
452
261
|
};
|
|
453
262
|
return Session;
|
|
@@ -459,8 +268,8 @@ var Session = /** @class */ (function () {
|
|
|
459
268
|
* one of these Sentry events per "replay session".
|
|
460
269
|
*/
|
|
461
270
|
function createSession(_a) {
|
|
462
|
-
var _b = _a.stickySession, stickySession = _b === void 0 ? false : _b;
|
|
463
|
-
var session = new Session(undefined, { stickySession: stickySession });
|
|
271
|
+
var _b = _a.stickySession, stickySession = _b === void 0 ? false : _b, _c = _a.samplingRate, samplingRate = _c === void 0 ? 1.0 : _c;
|
|
272
|
+
var session = new Session(undefined, { stickySession: stickySession, samplingRate: samplingRate });
|
|
464
273
|
logger.log("Creating new session: ".concat(session.id));
|
|
465
274
|
if (stickySession) {
|
|
466
275
|
saveSession(session);
|
|
@@ -491,7 +300,7 @@ function fetchSession() {
|
|
|
491
300
|
* Get or create a session
|
|
492
301
|
*/
|
|
493
302
|
function getSession(_a) {
|
|
494
|
-
var expiry = _a.expiry, currentSession = _a.currentSession, stickySession = _a.stickySession;
|
|
303
|
+
var expiry = _a.expiry, currentSession = _a.currentSession, stickySession = _a.stickySession, samplingRate = _a.samplingRate;
|
|
495
304
|
var session = stickySession ? fetchSession() : currentSession;
|
|
496
305
|
if (session) {
|
|
497
306
|
// If there is a session, check if it is valid (e.g. "last activity" time should be within the "session idle time")
|
|
@@ -506,7 +315,7 @@ function getSession(_a) {
|
|
|
506
315
|
}
|
|
507
316
|
// Otherwise continue to create a new session
|
|
508
317
|
}
|
|
509
|
-
var newSession = createSession({ stickySession: stickySession });
|
|
318
|
+
var newSession = createSession({ stickySession: stickySession, samplingRate: samplingRate });
|
|
510
319
|
return { type: 'new', session: newSession };
|
|
511
320
|
}
|
|
512
321
|
|
|
@@ -514,6 +323,13 @@ function createBreadcrumb(breadcrumb) {
|
|
|
514
323
|
return __assign({ timestamp: new Date().getTime() / 1000, type: 'default' }, breadcrumb);
|
|
515
324
|
}
|
|
516
325
|
|
|
326
|
+
/**
|
|
327
|
+
* Determine if there is browser support for `navigator.sendBeacon`
|
|
328
|
+
*/
|
|
329
|
+
function supportsSendBeacon() {
|
|
330
|
+
return 'navigator' in window && 'sendBeacon' in window.navigator;
|
|
331
|
+
}
|
|
332
|
+
|
|
517
333
|
function handleDom(handlerData) {
|
|
518
334
|
// Taken from https://github.com/getsentry/sentry-javascript/blob/master/packages/browser/src/integrations/breadcrumbs.ts#L112
|
|
519
335
|
var target;
|
|
@@ -537,68 +353,332 @@ function handleDom(handlerData) {
|
|
|
537
353
|
data: __assign({}, (targetNode ? { nodeId: record.mirror.getId(targetNode) } : {})),
|
|
538
354
|
});
|
|
539
355
|
}
|
|
540
|
-
|
|
541
|
-
function handleFetch(handlerData) {
|
|
542
|
-
if (!handlerData.endTimestamp) {
|
|
543
|
-
return null;
|
|
544
|
-
}
|
|
545
|
-
var _a = handlerData.args, op = _a[0], description = _a[1];
|
|
356
|
+
|
|
357
|
+
function handleFetch(handlerData) {
|
|
358
|
+
if (!handlerData.endTimestamp) {
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
var _a = handlerData.args, op = _a[0], description = _a[1];
|
|
362
|
+
return {
|
|
363
|
+
description: description,
|
|
364
|
+
op: op,
|
|
365
|
+
startTimestamp: handlerData.startTimestamp / 1000,
|
|
366
|
+
endTimestamp: handlerData.endTimestamp / 1000,
|
|
367
|
+
data: {
|
|
368
|
+
statusCode: handlerData.response.status,
|
|
369
|
+
},
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
var _LAST_BREADCRUMB = null;
|
|
374
|
+
function handleScope(scope) {
|
|
375
|
+
var _a;
|
|
376
|
+
//@ts-expect-error using private val
|
|
377
|
+
var newBreadcrumb = scope._breadcrumbs[scope._breadcrumbs.length - 1];
|
|
378
|
+
// Listener can be called when breadcrumbs have not changed, so we store the
|
|
379
|
+
// reference to the last crumb and only return a crumb if it has changed
|
|
380
|
+
if (_LAST_BREADCRUMB === newBreadcrumb || !newBreadcrumb) {
|
|
381
|
+
return null;
|
|
382
|
+
}
|
|
383
|
+
_LAST_BREADCRUMB = newBreadcrumb;
|
|
384
|
+
if (['fetch', 'xhr', 'sentry.event', 'sentry.transaction'].includes(newBreadcrumb.category) ||
|
|
385
|
+
((_a = newBreadcrumb.category) === null || _a === void 0 ? void 0 : _a.startsWith('ui.'))) {
|
|
386
|
+
return null;
|
|
387
|
+
}
|
|
388
|
+
return createBreadcrumb(newBreadcrumb);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function handleXhr(handlerData) {
|
|
392
|
+
if (handlerData.startTimestamp) {
|
|
393
|
+
handlerData.xhr.__sentry_xhr__.startTimestamp = handlerData.startTimestamp;
|
|
394
|
+
}
|
|
395
|
+
if (!handlerData.endTimestamp) {
|
|
396
|
+
return null;
|
|
397
|
+
}
|
|
398
|
+
var _a = handlerData.args, op = _a[0], description = _a[1];
|
|
399
|
+
return {
|
|
400
|
+
description: description,
|
|
401
|
+
op: op,
|
|
402
|
+
startTimestamp: handlerData.xhr.__sentry_xhr__.startTimestamp / 1000 ||
|
|
403
|
+
handlerData.endTimestamp / 1000.0,
|
|
404
|
+
endTimestamp: handlerData.endTimestamp / 1000.0,
|
|
405
|
+
data: {
|
|
406
|
+
statusCode: handlerData.response.status,
|
|
407
|
+
},
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Checks is `targetHost` is a Sentry ingestion host
|
|
413
|
+
*/
|
|
414
|
+
function isIngestHost(targetHost) {
|
|
415
|
+
var _a = getCurrentHub().getClient().getDsn(), protocol = _a.protocol, host = _a.host;
|
|
416
|
+
return targetHost.startsWith("".concat(protocol, "://").concat(host));
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
var _a;
|
|
420
|
+
// Map entryType -> function to normalize data for event
|
|
421
|
+
var ENTRY_TYPES = (_a = {
|
|
422
|
+
resource: createResourceEntry,
|
|
423
|
+
paint: createPaintEntry,
|
|
424
|
+
navigation: createNavigationEntry
|
|
425
|
+
},
|
|
426
|
+
_a['largest-contentful-paint'] = createLargestContentfulPaint,
|
|
427
|
+
_a);
|
|
428
|
+
function createPerformanceEntries(entries) {
|
|
429
|
+
return entries.map(createPerformanceEntry).filter(Boolean);
|
|
430
|
+
}
|
|
431
|
+
function createPerformanceEntry(entry) {
|
|
432
|
+
if (ENTRY_TYPES[entry.entryType] === undefined) {
|
|
433
|
+
return null;
|
|
434
|
+
}
|
|
435
|
+
return ENTRY_TYPES[entry.entryType](entry);
|
|
436
|
+
}
|
|
437
|
+
function getAbsoluteTime(time) {
|
|
438
|
+
return (window.performance.timeOrigin + time) / 1000;
|
|
439
|
+
}
|
|
440
|
+
function createPaintEntry(entry) {
|
|
441
|
+
var duration = entry.duration, entryType = entry.entryType, name = entry.name, startTime = entry.startTime;
|
|
442
|
+
var start = getAbsoluteTime(startTime);
|
|
443
|
+
return {
|
|
444
|
+
type: entryType,
|
|
445
|
+
name: name,
|
|
446
|
+
start: start,
|
|
447
|
+
end: start + duration,
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
function createNavigationEntry(entry) {
|
|
451
|
+
// TODO: There looks to be some more interesting bits in here (domComplete, domContentLoaded)
|
|
452
|
+
var entryType = entry.entryType, name = entry.name, domComplete = entry.domComplete, startTime = entry.startTime, transferSize = entry.transferSize, type = entry.type;
|
|
453
|
+
return {
|
|
454
|
+
type: "".concat(entryType, ".").concat(type),
|
|
455
|
+
start: getAbsoluteTime(startTime),
|
|
456
|
+
end: getAbsoluteTime(domComplete),
|
|
457
|
+
name: name,
|
|
458
|
+
data: {
|
|
459
|
+
size: transferSize,
|
|
460
|
+
},
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
function createResourceEntry(entry) {
|
|
464
|
+
var entryType = entry.entryType, initiatorType = entry.initiatorType, name = entry.name, responseEnd = entry.responseEnd, startTime = entry.startTime, transferSize = entry.transferSize;
|
|
465
|
+
// Do not capture fetches to Sentry ingestion endpoint
|
|
466
|
+
if (isIngestHost(name)) {
|
|
467
|
+
return null;
|
|
468
|
+
}
|
|
469
|
+
return {
|
|
470
|
+
type: "".concat(entryType, ".").concat(initiatorType),
|
|
471
|
+
start: getAbsoluteTime(startTime),
|
|
472
|
+
end: getAbsoluteTime(responseEnd),
|
|
473
|
+
name: name,
|
|
474
|
+
data: {
|
|
475
|
+
size: transferSize,
|
|
476
|
+
},
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
function createLargestContentfulPaint(entry) {
|
|
480
|
+
var duration = entry.duration, entryType = entry.entryType, startTime = entry.startTime, size = entry.size;
|
|
481
|
+
var start = getAbsoluteTime(startTime);
|
|
482
|
+
return {
|
|
483
|
+
type: entryType,
|
|
484
|
+
name: entryType,
|
|
485
|
+
start: start,
|
|
486
|
+
end: start + duration,
|
|
487
|
+
data: {
|
|
488
|
+
size: size,
|
|
489
|
+
// Not sure why this errors, Node should be correct (Argument of type 'Node' is not assignable to parameter of type 'INode')
|
|
490
|
+
nodeId: record.mirror.getId(entry.element),
|
|
491
|
+
},
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
function createMemoryEntry(memoryEntry) {
|
|
495
|
+
var jsHeapSizeLimit = memoryEntry.jsHeapSizeLimit, totalJSHeapSize = memoryEntry.totalJSHeapSize, usedJSHeapSize = memoryEntry.usedJSHeapSize;
|
|
496
|
+
// we can't use getAbsoluteTime because it adds the event time to
|
|
497
|
+
// window.performance.timeOrigin, so we get right now instead.
|
|
498
|
+
var time = new Date().getTime() / 1000;
|
|
546
499
|
return {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
500
|
+
type: 'memory',
|
|
501
|
+
name: 'memory',
|
|
502
|
+
start: time,
|
|
503
|
+
end: time,
|
|
551
504
|
data: {
|
|
552
|
-
|
|
505
|
+
memory: {
|
|
506
|
+
jsHeapSizeLimit: jsHeapSizeLimit,
|
|
507
|
+
totalJSHeapSize: totalJSHeapSize,
|
|
508
|
+
usedJSHeapSize: usedJSHeapSize,
|
|
509
|
+
},
|
|
553
510
|
},
|
|
554
511
|
};
|
|
555
512
|
}
|
|
556
513
|
|
|
557
|
-
var
|
|
558
|
-
function handleScope(scope) {
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
var
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
514
|
+
var workerString = `/*! pako 2.0.4 https://github.com/nodeca/pako @license (MIT AND Zlib) */
|
|
515
|
+
function t(t){let e=t.length;for(;--e>=0;)t[e]=0}const e=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]),a=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]),i=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),n=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),s=new Array(576);t(s);const r=new Array(60);t(r);const o=new Array(512);t(o);const l=new Array(256);t(l);const h=new Array(29);t(h);const d=new Array(30);function _(t,e,a,i,n){this.static_tree=t,this.extra_bits=e,this.extra_base=a,this.elems=i,this.max_length=n,this.has_stree=t&&t.length}let f,c,u;function w(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}t(d);const b=t=>t<256?o[t]:o[256+(t>>>7)],g=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},p=(t,e,a)=>{t.bi_valid>16-a?(t.bi_buf|=e<<t.bi_valid&65535,g(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)},m=(t,e,a)=>{p(t,a[2*e],a[2*e+1])},k=(t,e)=>{let a=0;do{a|=1&t,t>>>=1,a<<=1}while(--e>0);return a>>>1},v=(t,e,a)=>{const i=new Array(16);let n,s,r=0;for(n=1;n<=15;n++)i[n]=r=r+a[n-1]<<1;for(s=0;s<=e;s++){let e=t[2*s+1];0!==e&&(t[2*s]=k(i[e]++,e))}},y=t=>{let e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;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},x=t=>{t.bi_valid>8?g(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},z=(t,e,a,i)=>{const n=2*e,s=2*a;return t[n]<t[s]||t[n]===t[s]&&i[e]<=i[a]},A=(t,e,a)=>{const i=t.heap[a];let n=a<<1;for(;n<=t.heap_len&&(n<t.heap_len&&z(e,t.heap[n+1],t.heap[n],t.depth)&&n++,!z(e,i,t.heap[n],t.depth));)t.heap[a]=t.heap[n],a=n,n<<=1;t.heap[a]=i},E=(t,i,n)=>{let s,r,o,_,f=0;if(0!==t.last_lit)do{s=t.pending_buf[t.d_buf+2*f]<<8|t.pending_buf[t.d_buf+2*f+1],r=t.pending_buf[t.l_buf+f],f++,0===s?m(t,r,i):(o=l[r],m(t,o+256+1,i),_=e[o],0!==_&&(r-=h[o],p(t,r,_)),s--,o=b(s),m(t,o,n),_=a[o],0!==_&&(s-=d[o],p(t,s,_)))}while(f<t.last_lit);m(t,256,i)},R=(t,e)=>{const a=e.dyn_tree,i=e.stat_desc.static_tree,n=e.stat_desc.has_stree,s=e.stat_desc.elems;let r,o,l,h=-1;for(t.heap_len=0,t.heap_max=573,r=0;r<s;r++)0!==a[2*r]?(t.heap[++t.heap_len]=h=r,t.depth[r]=0):a[2*r+1]=0;for(;t.heap_len<2;)l=t.heap[++t.heap_len]=h<2?++h:0,a[2*l]=1,t.depth[l]=0,t.opt_len--,n&&(t.static_len-=i[2*l+1]);for(e.max_code=h,r=t.heap_len>>1;r>=1;r--)A(t,a,r);l=s;do{r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],A(t,a,1),o=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=o,a[2*l]=a[2*r]+a[2*o],t.depth[l]=(t.depth[r]>=t.depth[o]?t.depth[r]:t.depth[o])+1,a[2*r+1]=a[2*o+1]=l,t.heap[1]=l++,A(t,a,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const a=e.dyn_tree,i=e.max_code,n=e.stat_desc.static_tree,s=e.stat_desc.has_stree,r=e.stat_desc.extra_bits,o=e.stat_desc.extra_base,l=e.stat_desc.max_length;let h,d,_,f,c,u,w=0;for(f=0;f<=15;f++)t.bl_count[f]=0;for(a[2*t.heap[t.heap_max]+1]=0,h=t.heap_max+1;h<573;h++)d=t.heap[h],f=a[2*a[2*d+1]+1]+1,f>l&&(f=l,w++),a[2*d+1]=f,d>i||(t.bl_count[f]++,c=0,d>=o&&(c=r[d-o]),u=a[2*d],t.opt_len+=u*(f+c),s&&(t.static_len+=u*(n[2*d+1]+c)));if(0!==w){do{for(f=l-1;0===t.bl_count[f];)f--;t.bl_count[f]--,t.bl_count[f+1]+=2,t.bl_count[l]--,w-=2}while(w>0);for(f=l;0!==f;f--)for(d=t.bl_count[f];0!==d;)_=t.heap[--h],_>i||(a[2*_+1]!==f&&(t.opt_len+=(f-a[2*_+1])*a[2*_],a[2*_+1]=f),d--)}})(t,e),v(a,h,t.bl_count)},Z=(t,e,a)=>{let i,n,s=-1,r=e[1],o=0,l=7,h=4;for(0===r&&(l=138,h=3),e[2*(a+1)+1]=65535,i=0;i<=a;i++)n=r,r=e[2*(i+1)+1],++o<l&&n===r||(o<h?t.bl_tree[2*n]+=o:0!==n?(n!==s&&t.bl_tree[2*n]++,t.bl_tree[32]++):o<=10?t.bl_tree[34]++:t.bl_tree[36]++,o=0,s=n,0===r?(l=138,h=3):n===r?(l=6,h=3):(l=7,h=4))},S=(t,e,a)=>{let i,n,s=-1,r=e[1],o=0,l=7,h=4;for(0===r&&(l=138,h=3),i=0;i<=a;i++)if(n=r,r=e[2*(i+1)+1],!(++o<l&&n===r)){if(o<h)do{m(t,n,t.bl_tree)}while(0!=--o);else 0!==n?(n!==s&&(m(t,n,t.bl_tree),o--),m(t,16,t.bl_tree),p(t,o-3,2)):o<=10?(m(t,17,t.bl_tree),p(t,o-3,3)):(m(t,18,t.bl_tree),p(t,o-11,7));o=0,s=n,0===r?(l=138,h=3):n===r?(l=6,h=3):(l=7,h=4)}};let U=!1;const D=(t,e,a,i)=>{p(t,0+(i?1:0),3),((t,e,a,i)=>{x(t),i&&(g(t,a),g(t,~a)),t.pending_buf.set(t.window.subarray(e,e+a),t.pending),t.pending+=a})(t,e,a,!0)};var O=(t,e,a,i)=>{let o,l,h=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let 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<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),R(t,t.l_desc),R(t,t.d_desc),h=(t=>{let e;for(Z(t,t.dyn_ltree,t.l_desc.max_code),Z(t,t.dyn_dtree,t.d_desc.max_code),R(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*n[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),o=t.opt_len+3+7>>>3,l=t.static_len+3+7>>>3,l<=o&&(o=l)):o=l=a+5,a+4<=o&&-1!==e?D(t,e,a,i):4===t.strategy||l===o?(p(t,2+(i?1:0),3),E(t,s,r)):(p(t,4+(i?1:0),3),((t,e,a,i)=>{let s;for(p(t,e-257,5),p(t,a-1,5),p(t,i-4,4),s=0;s<i;s++)p(t,t.bl_tree[2*n[s]+1],3);S(t,t.dyn_ltree,e-1),S(t,t.dyn_dtree,a-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,h+1),E(t,t.dyn_ltree,t.dyn_dtree)),y(t),i&&x(t)},T={_tr_init:t=>{U||((()=>{let t,n,w,b,g;const p=new Array(16);for(w=0,b=0;b<28;b++)for(h[b]=w,t=0;t<1<<e[b];t++)l[w++]=b;for(l[w-1]=b,g=0,b=0;b<16;b++)for(d[b]=g,t=0;t<1<<a[b];t++)o[g++]=b;for(g>>=7;b<30;b++)for(d[b]=g<<7,t=0;t<1<<a[b]-7;t++)o[256+g++]=b;for(n=0;n<=15;n++)p[n]=0;for(t=0;t<=143;)s[2*t+1]=8,t++,p[8]++;for(;t<=255;)s[2*t+1]=9,t++,p[9]++;for(;t<=279;)s[2*t+1]=7,t++,p[7]++;for(;t<=287;)s[2*t+1]=8,t++,p[8]++;for(v(s,287,p),t=0;t<30;t++)r[2*t+1]=5,r[2*t]=k(t,5);f=new _(s,e,257,286,15),c=new _(r,a,0,30,15),u=new _(new Array(0),i,0,19,7)})(),U=!0),t.l_desc=new w(t.dyn_ltree,f),t.d_desc=new w(t.dyn_dtree,c),t.bl_desc=new w(t.bl_tree,u),t.bi_buf=0,t.bi_valid=0,y(t)},_tr_stored_block:D,_tr_flush_block:O,_tr_tally:(t,e,a)=>(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*(l[a]+256+1)]++,t.dyn_dtree[2*b(e)]++),t.last_lit===t.lit_bufsize-1),_tr_align:t=>{p(t,2,3),m(t,256,s),(t=>{16===t.bi_valid?(g(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)}};var F=(t,e,a,i)=>{let n=65535&t|0,s=t>>>16&65535|0,r=0;for(;0!==a;){r=a>2e3?2e3:a,a-=r;do{n=n+e[i++]|0,s=s+n|0}while(--r);n%=65521,s%=65521}return n|s<<16|0};const L=new Uint32Array((()=>{let t,e=[];for(var a=0;a<256;a++){t=a;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[a]=t}return e})());var N=(t,e,a,i)=>{const n=L,s=i+a;t^=-1;for(let a=i;a<s;a++)t=t>>>8^n[255&(t^e[a])];return-1^t},I={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"},B={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};const{_tr_init:C,_tr_stored_block:H,_tr_flush_block:M,_tr_tally:j,_tr_align:K}=T,{Z_NO_FLUSH:P,Z_PARTIAL_FLUSH:Y,Z_FULL_FLUSH:G,Z_FINISH:X,Z_BLOCK:W,Z_OK:J,Z_STREAM_END:q,Z_STREAM_ERROR:Q,Z_DATA_ERROR:V,Z_BUF_ERROR:$,Z_DEFAULT_COMPRESSION:tt,Z_FILTERED:et,Z_HUFFMAN_ONLY:at,Z_RLE:it,Z_FIXED:nt,Z_DEFAULT_STRATEGY:st,Z_UNKNOWN:rt,Z_DEFLATED:ot}=B,lt=(t,e)=>(t.msg=I[e],e),ht=t=>(t<<1)-(t>4?9:0),dt=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let _t=(t,e,a)=>(e<<t.hash_shift^a)&t.hash_mask;const ft=t=>{const e=t.state;let 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))},ct=(t,e)=>{M(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,ft(t.strm)},ut=(t,e)=>{t.pending_buf[t.pending++]=e},wt=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},bt=(t,e,a,i)=>{let n=t.avail_in;return n>i&&(n=i),0===n?0:(t.avail_in-=n,e.set(t.input.subarray(t.next_in,t.next_in+n),a),1===t.state.wrap?t.adler=F(t.adler,e,n,a):2===t.state.wrap&&(t.adler=N(t.adler,e,n,a)),t.next_in+=n,t.total_in+=n,n)},gt=(t,e)=>{let a,i,n=t.max_chain_length,s=t.strstart,r=t.prev_length,o=t.nice_match;const l=t.strstart>t.w_size-262?t.strstart-(t.w_size-262):0,h=t.window,d=t.w_mask,_=t.prev,f=t.strstart+258;let c=h[s+r-1],u=h[s+r];t.prev_length>=t.good_match&&(n>>=2),o>t.lookahead&&(o=t.lookahead);do{if(a=e,h[a+r]===u&&h[a+r-1]===c&&h[a]===h[s]&&h[++a]===h[s+1]){s+=2,a++;do{}while(h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&s<f);if(i=258-(f-s),s=f-258,i>r){if(t.match_start=e,r=i,i>=o)break;c=h[s+r-1],u=h[s+r]}}}while((e=_[e&d])>l&&0!=--n);return r<=t.lookahead?r:t.lookahead},pt=t=>{const e=t.w_size;let a,i,n,s,r;do{if(s=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-262)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,i=t.hash_size,a=i;do{n=t.head[--a],t.head[a]=n>=e?n-e:0}while(--i);i=e,a=i;do{n=t.prev[--a],t.prev[a]=n>=e?n-e:0}while(--i);s+=e}if(0===t.strm.avail_in)break;if(i=bt(t.strm,t.window,t.strstart+t.lookahead,s),t.lookahead+=i,t.lookahead+t.insert>=3)for(r=t.strstart-t.insert,t.ins_h=t.window[r],t.ins_h=_t(t,t.ins_h,t.window[r+1]);t.insert&&(t.ins_h=_t(t,t.ins_h,t.window[r+3-1]),t.prev[r&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=r,r++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<262&&0!==t.strm.avail_in)},mt=(t,e)=>{let a,i;for(;;){if(t.lookahead<262){if(pt(t),t.lookahead<262&&e===P)return 1;if(0===t.lookahead)break}if(a=0,t.lookahead>=3&&(t.ins_h=_t(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-262&&(t.match_length=gt(t,a)),t.match_length>=3)if(i=j(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=_t(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=_t(t,t.ins_h,t.window[t.strstart+1]);else i=j(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(ct(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===X?(ct(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(ct(t,!1),0===t.strm.avail_out)?1:2},kt=(t,e)=>{let a,i,n;for(;;){if(t.lookahead<262){if(pt(t),t.lookahead<262&&e===P)return 1;if(0===t.lookahead)break}if(a=0,t.lookahead>=3&&(t.ins_h=_t(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-262&&(t.match_length=gt(t,a),t.match_length<=5&&(t.strategy===et||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){n=t.strstart+t.lookahead-3,i=j(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=n&&(t.ins_h=_t(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++,i&&(ct(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(i=j(t,0,t.window[t.strstart-1]),i&&ct(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&&(i=j(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===X?(ct(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(ct(t,!1),0===t.strm.avail_out)?1:2};function vt(t,e,a,i,n){this.good_length=t,this.max_lazy=e,this.nice_length=a,this.max_chain=i,this.func=n}const yt=[new vt(0,0,0,0,((t,e)=>{let a=65535;for(a>t.pending_buf_size-5&&(a=t.pending_buf_size-5);;){if(t.lookahead<=1){if(pt(t),0===t.lookahead&&e===P)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;const i=t.block_start+a;if((0===t.strstart||t.strstart>=i)&&(t.lookahead=t.strstart-i,t.strstart=i,ct(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-262&&(ct(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===X?(ct(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(ct(t,!1),t.strm.avail_out),1)})),new vt(4,4,8,4,mt),new vt(4,5,16,8,mt),new vt(4,6,32,32,mt),new vt(4,4,16,16,kt),new vt(8,16,32,32,kt),new vt(8,16,128,128,kt),new vt(8,32,128,256,kt),new vt(32,128,258,1024,kt),new vt(32,258,258,4096,kt)];function xt(){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=ot,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),dt(this.dyn_ltree),dt(this.dyn_dtree),dt(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),dt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),dt(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}const zt=t=>{if(!t||!t.state)return lt(t,Q);t.total_in=t.total_out=0,t.data_type=rt;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:113,t.adler=2===e.wrap?0:1,e.last_flush=P,C(e),J},At=t=>{const e=zt(t);var a;return e===J&&((a=t.state).window_size=2*a.w_size,dt(a.head),a.max_lazy_match=yt[a.level].max_lazy,a.good_match=yt[a.level].good_length,a.nice_match=yt[a.level].nice_length,a.max_chain_length=yt[a.level].max_chain,a.strstart=0,a.block_start=0,a.lookahead=0,a.insert=0,a.match_length=a.prev_length=2,a.match_available=0,a.ins_h=0),e},Et=(t,e,a,i,n,s)=>{if(!t)return Q;let r=1;if(e===tt&&(e=6),i<0?(r=0,i=-i):i>15&&(r=2,i-=16),n<1||n>9||a!==ot||i<8||i>15||e<0||e>9||s<0||s>nt)return lt(t,Q);8===i&&(i=9);const o=new xt;return t.state=o,o.strm=t,o.wrap=r,o.gzhead=null,o.w_bits=i,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=n+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new Uint8Array(2*o.w_size),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<n+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new Uint8Array(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=3*o.lit_bufsize,o.level=e,o.strategy=s,o.method=a,At(t)};var Rt={deflateInit:(t,e)=>Et(t,e,ot,15,8,st),deflateInit2:Et,deflateReset:At,deflateResetKeep:zt,deflateSetHeader:(t,e)=>t&&t.state?2!==t.state.wrap?Q:(t.state.gzhead=e,J):Q,deflate:(t,e)=>{let a,i;if(!t||!t.state||e>W||e<0)return t?lt(t,Q):Q;const n=t.state;if(!t.output||!t.input&&0!==t.avail_in||666===n.status&&e!==X)return lt(t,0===t.avail_out?$:Q);n.strm=t;const s=n.last_flush;if(n.last_flush=e,42===n.status)if(2===n.wrap)t.adler=0,ut(n,31),ut(n,139),ut(n,8),n.gzhead?(ut(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),ut(n,255&n.gzhead.time),ut(n,n.gzhead.time>>8&255),ut(n,n.gzhead.time>>16&255),ut(n,n.gzhead.time>>24&255),ut(n,9===n.level?2:n.strategy>=at||n.level<2?4:0),ut(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(ut(n,255&n.gzhead.extra.length),ut(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=N(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(ut(n,0),ut(n,0),ut(n,0),ut(n,0),ut(n,0),ut(n,9===n.level?2:n.strategy>=at||n.level<2?4:0),ut(n,3),n.status=113);else{let e=ot+(n.w_bits-8<<4)<<8,a=-1;a=n.strategy>=at||n.level<2?0:n.level<6?1:6===n.level?2:3,e|=a<<6,0!==n.strstart&&(e|=32),e+=31-e%31,n.status=113,wt(n,e),0!==n.strstart&&(wt(n,t.adler>>>16),wt(n,65535&t.adler)),t.adler=1}if(69===n.status)if(n.gzhead.extra){for(a=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>a&&(t.adler=N(t.adler,n.pending_buf,n.pending-a,a)),ft(t),a=n.pending,n.pending!==n.pending_buf_size));)ut(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>a&&(t.adler=N(t.adler,n.pending_buf,n.pending-a,a)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){a=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>a&&(t.adler=N(t.adler,n.pending_buf,n.pending-a,a)),ft(t),a=n.pending,n.pending===n.pending_buf_size)){i=1;break}i=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,ut(n,i)}while(0!==i);n.gzhead.hcrc&&n.pending>a&&(t.adler=N(t.adler,n.pending_buf,n.pending-a,a)),0===i&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){a=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>a&&(t.adler=N(t.adler,n.pending_buf,n.pending-a,a)),ft(t),a=n.pending,n.pending===n.pending_buf_size)){i=1;break}i=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,ut(n,i)}while(0!==i);n.gzhead.hcrc&&n.pending>a&&(t.adler=N(t.adler,n.pending_buf,n.pending-a,a)),0===i&&(n.status=103)}else n.status=103;if(103===n.status&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&ft(t),n.pending+2<=n.pending_buf_size&&(ut(n,255&t.adler),ut(n,t.adler>>8&255),t.adler=0,n.status=113)):n.status=113),0!==n.pending){if(ft(t),0===t.avail_out)return n.last_flush=-1,J}else if(0===t.avail_in&&ht(e)<=ht(s)&&e!==X)return lt(t,$);if(666===n.status&&0!==t.avail_in)return lt(t,$);if(0!==t.avail_in||0!==n.lookahead||e!==P&&666!==n.status){let a=n.strategy===at?((t,e)=>{let a;for(;;){if(0===t.lookahead&&(pt(t),0===t.lookahead)){if(e===P)return 1;break}if(t.match_length=0,a=j(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,a&&(ct(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===X?(ct(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(ct(t,!1),0===t.strm.avail_out)?1:2})(n,e):n.strategy===it?((t,e)=>{let a,i,n,s;const r=t.window;for(;;){if(t.lookahead<=258){if(pt(t),t.lookahead<=258&&e===P)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=t.strstart-1,i=r[n],i===r[++n]&&i===r[++n]&&i===r[++n])){s=t.strstart+258;do{}while(i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&n<s);t.match_length=258-(s-n),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(a=j(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(a=j(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),a&&(ct(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===X?(ct(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(ct(t,!1),0===t.strm.avail_out)?1:2})(n,e):yt[n.level].func(n,e);if(3!==a&&4!==a||(n.status=666),1===a||3===a)return 0===t.avail_out&&(n.last_flush=-1),J;if(2===a&&(e===Y?K(n):e!==W&&(H(n,0,0,!1),e===G&&(dt(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),ft(t),0===t.avail_out))return n.last_flush=-1,J}return e!==X?J:n.wrap<=0?q:(2===n.wrap?(ut(n,255&t.adler),ut(n,t.adler>>8&255),ut(n,t.adler>>16&255),ut(n,t.adler>>24&255),ut(n,255&t.total_in),ut(n,t.total_in>>8&255),ut(n,t.total_in>>16&255),ut(n,t.total_in>>24&255)):(wt(n,t.adler>>>16),wt(n,65535&t.adler)),ft(t),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?J:q)},deflateEnd:t=>{if(!t||!t.state)return Q;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&103!==e&&113!==e&&666!==e?lt(t,Q):(t.state=null,113===e?lt(t,V):J)},deflateSetDictionary:(t,e)=>{let a=e.length;if(!t||!t.state)return Q;const i=t.state,n=i.wrap;if(2===n||1===n&&42!==i.status||i.lookahead)return Q;if(1===n&&(t.adler=F(t.adler,e,a,0)),i.wrap=0,a>=i.w_size){0===n&&(dt(i.head),i.strstart=0,i.block_start=0,i.insert=0);let t=new Uint8Array(i.w_size);t.set(e.subarray(a-i.w_size,a),0),e=t,a=i.w_size}const s=t.avail_in,r=t.next_in,o=t.input;for(t.avail_in=a,t.next_in=0,t.input=e,pt(i);i.lookahead>=3;){let t=i.strstart,e=i.lookahead-2;do{i.ins_h=_t(i,i.ins_h,i.window[t+3-1]),i.prev[t&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=t,t++}while(--e);i.strstart=t,i.lookahead=2,pt(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,t.next_in=r,t.input=o,t.avail_in=s,i.wrap=n,J},deflateInfo:"pako deflate (from Nodeca project)"};const Zt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var St=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const a=e.shift();if(a){if("object"!=typeof a)throw new TypeError(a+"must be non-object");for(const e in a)Zt(a,e)&&(t[e]=a[e])}}return t},Ut=t=>{let e=0;for(let a=0,i=t.length;a<i;a++)e+=t[a].length;const a=new Uint8Array(e);for(let e=0,i=0,n=t.length;e<n;e++){let n=t[e];a.set(n,i),i+=n.length}return a};let Dt=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Dt=!1}const Ot=new Uint8Array(256);for(let t=0;t<256;t++)Ot[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Ot[254]=Ot[254]=1;var Tt=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,a,i,n,s,r=t.length,o=0;for(n=0;n<r;n++)a=t.charCodeAt(n),55296==(64512&a)&&n+1<r&&(i=t.charCodeAt(n+1),56320==(64512&i)&&(a=65536+(a-55296<<10)+(i-56320),n++)),o+=a<128?1:a<2048?2:a<65536?3:4;for(e=new Uint8Array(o),s=0,n=0;s<o;n++)a=t.charCodeAt(n),55296==(64512&a)&&n+1<r&&(i=t.charCodeAt(n+1),56320==(64512&i)&&(a=65536+(a-55296<<10)+(i-56320),n++)),a<128?e[s++]=a:a<2048?(e[s++]=192|a>>>6,e[s++]=128|63&a):a<65536?(e[s++]=224|a>>>12,e[s++]=128|a>>>6&63,e[s++]=128|63&a):(e[s++]=240|a>>>18,e[s++]=128|a>>>12&63,e[s++]=128|a>>>6&63,e[s++]=128|63&a);return e},Ft=(t,e)=>{const a=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let i,n;const s=new Array(2*a);for(n=0,i=0;i<a;){let e=t[i++];if(e<128){s[n++]=e;continue}let r=Ot[e];if(r>4)s[n++]=65533,i+=r-1;else{for(e&=2===r?31:3===r?15:7;r>1&&i<a;)e=e<<6|63&t[i++],r--;r>1?s[n++]=65533:e<65536?s[n++]=e:(e-=65536,s[n++]=55296|e>>10&1023,s[n++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Dt)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let a="";for(let i=0;i<e;i++)a+=String.fromCharCode(t[i]);return a})(s,n)},Lt=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let a=e-1;for(;a>=0&&128==(192&t[a]);)a--;return a<0||0===a?e:a+Ot[t[a]]>e?a:e};var Nt=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};const It=Object.prototype.toString,{Z_NO_FLUSH:Bt,Z_SYNC_FLUSH:Ct,Z_FULL_FLUSH:Ht,Z_FINISH:Mt,Z_OK:jt,Z_STREAM_END:Kt,Z_DEFAULT_COMPRESSION:Pt,Z_DEFAULT_STRATEGY:Yt,Z_DEFLATED:Gt}=B;function Xt(t){this.options=St({level:Pt,method:Gt,chunkSize:16384,windowBits:15,memLevel:8,strategy:Yt},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Nt,this.strm.avail_out=0;let a=Rt.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(a!==jt)throw new Error(I[a]);if(e.header&&Rt.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Tt(e.dictionary):"[object ArrayBuffer]"===It.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,a=Rt.deflateSetDictionary(this.strm,t),a!==jt)throw new Error(I[a]);this._dict_set=!0}}function Wt(t,e){const a=new Xt(e);if(a.push(t,!0),a.err)throw a.msg||I[a.err];return a.result}Xt.prototype.push=function(t,e){const a=this.strm,i=this.options.chunkSize;let n,s;if(this.ended)return!1;for(s=e===~~e?e:!0===e?Mt:Bt,"string"==typeof t?a.input=Tt(t):"[object ArrayBuffer]"===It.call(t)?a.input=new Uint8Array(t):a.input=t,a.next_in=0,a.avail_in=a.input.length;;)if(0===a.avail_out&&(a.output=new Uint8Array(i),a.next_out=0,a.avail_out=i),(s===Ct||s===Ht)&&a.avail_out<=6)this.onData(a.output.subarray(0,a.next_out)),a.avail_out=0;else{if(n=Rt.deflate(a,s),n===Kt)return a.next_out>0&&this.onData(a.output.subarray(0,a.next_out)),n=Rt.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===jt;if(0!==a.avail_out){if(s>0&&a.next_out>0)this.onData(a.output.subarray(0,a.next_out)),a.avail_out=0;else if(0===a.avail_in)break}else this.onData(a.output)}return!0},Xt.prototype.onData=function(t){this.chunks.push(t)},Xt.prototype.onEnd=function(t){t===jt&&(this.result=Ut(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Jt={Deflate:Xt,deflate:Wt,deflateRaw:function(t,e){return(e=e||{}).raw=!0,Wt(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,Wt(t,e)},constants:B};var qt=function(t,e){let a,i,n,s,r,o,l,h,d,_,f,c,u,w,b,g,p,m,k,v,y,x,z,A;const E=t.state;a=t.next_in,z=t.input,i=a+(t.avail_in-5),n=t.next_out,A=t.output,s=n-(e-t.avail_out),r=n+(t.avail_out-257),o=E.dmax,l=E.wsize,h=E.whave,d=E.wnext,_=E.window,f=E.hold,c=E.bits,u=E.lencode,w=E.distcode,b=(1<<E.lenbits)-1,g=(1<<E.distbits)-1;t:do{c<15&&(f+=z[a++]<<c,c+=8,f+=z[a++]<<c,c+=8),p=u[f&b];e:for(;;){if(m=p>>>24,f>>>=m,c-=m,m=p>>>16&255,0===m)A[n++]=65535&p;else{if(!(16&m)){if(0==(64&m)){p=u[(65535&p)+(f&(1<<m)-1)];continue e}if(32&m){E.mode=12;break t}t.msg="invalid literal/length code",E.mode=30;break t}k=65535&p,m&=15,m&&(c<m&&(f+=z[a++]<<c,c+=8),k+=f&(1<<m)-1,f>>>=m,c-=m),c<15&&(f+=z[a++]<<c,c+=8,f+=z[a++]<<c,c+=8),p=w[f&g];a:for(;;){if(m=p>>>24,f>>>=m,c-=m,m=p>>>16&255,!(16&m)){if(0==(64&m)){p=w[(65535&p)+(f&(1<<m)-1)];continue a}t.msg="invalid distance code",E.mode=30;break t}if(v=65535&p,m&=15,c<m&&(f+=z[a++]<<c,c+=8,c<m&&(f+=z[a++]<<c,c+=8)),v+=f&(1<<m)-1,v>o){t.msg="invalid distance too far back",E.mode=30;break t}if(f>>>=m,c-=m,m=n-s,v>m){if(m=v-m,m>h&&E.sane){t.msg="invalid distance too far back",E.mode=30;break t}if(y=0,x=_,0===d){if(y+=l-m,m<k){k-=m;do{A[n++]=_[y++]}while(--m);y=n-v,x=A}}else if(d<m){if(y+=l+d-m,m-=d,m<k){k-=m;do{A[n++]=_[y++]}while(--m);if(y=0,d<k){m=d,k-=m;do{A[n++]=_[y++]}while(--m);y=n-v,x=A}}}else if(y+=d-m,m<k){k-=m;do{A[n++]=_[y++]}while(--m);y=n-v,x=A}for(;k>2;)A[n++]=x[y++],A[n++]=x[y++],A[n++]=x[y++],k-=3;k&&(A[n++]=x[y++],k>1&&(A[n++]=x[y++]))}else{y=n-v;do{A[n++]=A[y++],A[n++]=A[y++],A[n++]=A[y++],k-=3}while(k>2);k&&(A[n++]=A[y++],k>1&&(A[n++]=A[y++]))}break}}break}}while(a<i&&n<r);k=c>>3,a-=k,c-=k<<3,f&=(1<<c)-1,t.next_in=a,t.next_out=n,t.avail_in=a<i?i-a+5:5-(a-i),t.avail_out=n<r?r-n+257:257-(n-r),E.hold=f,E.bits=c};const Qt=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Vt=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),$t=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),te=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var ee=(t,e,a,i,n,s,r,o)=>{const l=o.bits;let h,d,_,f,c,u,w=0,b=0,g=0,p=0,m=0,k=0,v=0,y=0,x=0,z=0,A=null,E=0;const R=new Uint16Array(16),Z=new Uint16Array(16);let S,U,D,O=null,T=0;for(w=0;w<=15;w++)R[w]=0;for(b=0;b<i;b++)R[e[a+b]]++;for(m=l,p=15;p>=1&&0===R[p];p--);if(m>p&&(m=p),0===p)return n[s++]=20971520,n[s++]=20971520,o.bits=1,0;for(g=1;g<p&&0===R[g];g++);for(m<g&&(m=g),y=1,w=1;w<=15;w++)if(y<<=1,y-=R[w],y<0)return-1;if(y>0&&(0===t||1!==p))return-1;for(Z[1]=0,w=1;w<15;w++)Z[w+1]=Z[w]+R[w];for(b=0;b<i;b++)0!==e[a+b]&&(r[Z[e[a+b]]++]=b);if(0===t?(A=O=r,u=19):1===t?(A=Qt,E-=257,O=Vt,T-=257,u=256):(A=$t,O=te,u=-1),z=0,b=0,w=g,c=s,k=m,v=0,_=-1,x=1<<m,f=x-1,1===t&&x>852||2===t&&x>592)return 1;for(;;){S=w-v,r[b]<u?(U=0,D=r[b]):r[b]>u?(U=O[T+r[b]],D=A[E+r[b]]):(U=96,D=0),h=1<<w-v,d=1<<k,g=d;do{d-=h,n[c+(z>>v)+d]=S<<24|U<<16|D|0}while(0!==d);for(h=1<<w-1;z&h;)h>>=1;if(0!==h?(z&=h-1,z+=h):z=0,b++,0==--R[w]){if(w===p)break;w=e[a+r[b]]}if(w>m&&(z&f)!==_){for(0===v&&(v=m),c+=g,k=w-v,y=1<<k;k+v<p&&(y-=R[k+v],!(y<=0));)k++,y<<=1;if(x+=1<<k,1===t&&x>852||2===t&&x>592)return 1;_=z&f,n[_]=m<<24|k<<16|c-s|0}}return 0!==z&&(n[c+z]=w-v<<24|64<<16|0),o.bits=m,0};const{Z_FINISH:ae,Z_BLOCK:ie,Z_TREES:ne,Z_OK:se,Z_STREAM_END:re,Z_NEED_DICT:oe,Z_STREAM_ERROR:le,Z_DATA_ERROR:he,Z_MEM_ERROR:de,Z_BUF_ERROR:_e,Z_DEFLATED:fe}=B,ce=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function ue(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const we=t=>{if(!t||!t.state)return le;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,se},be=t=>{if(!t||!t.state)return le;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,we(t)},ge=(t,e)=>{let a;if(!t||!t.state)return le;const i=t.state;return e<0?(a=0,e=-e):(a=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?le:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=a,i.wbits=e,be(t))},pe=(t,e)=>{if(!t)return le;const a=new ue;t.state=a,a.window=null;const i=ge(t,e);return i!==se&&(t.state=null),i};let me,ke,ve=!0;const ye=t=>{if(ve){me=new Int32Array(512),ke=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(ee(1,t.lens,0,288,me,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;ee(2,t.lens,0,32,ke,0,t.work,{bits:5}),ve=!1}t.lencode=me,t.lenbits=9,t.distcode=ke,t.distbits=5},xe=(t,e,a,i)=>{let n;const s=t.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),i>=s.wsize?(s.window.set(e.subarray(a-s.wsize,a),0),s.wnext=0,s.whave=s.wsize):(n=s.wsize-s.wnext,n>i&&(n=i),s.window.set(e.subarray(a-i,a-i+n),s.wnext),(i-=n)?(s.window.set(e.subarray(a-i,a),0),s.wnext=i,s.whave=s.wsize):(s.wnext+=n,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=n))),0};var ze={inflateReset:be,inflateReset2:ge,inflateResetKeep:we,inflateInit:t=>pe(t,15),inflateInit2:pe,inflate:(t,e)=>{let a,i,n,s,r,o,l,h,d,_,f,c,u,w,b,g,p,m,k,v,y,x,z=0;const A=new Uint8Array(4);let E,R;const Z=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return le;a=t.state,12===a.mode&&(a.mode=13),r=t.next_out,n=t.output,l=t.avail_out,s=t.next_in,i=t.input,o=t.avail_in,h=a.hold,d=a.bits,_=o,f=l,x=se;t:for(;;)switch(a.mode){case 1:if(0===a.wrap){a.mode=13;break}for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(2&a.wrap&&35615===h){a.check=0,A[0]=255&h,A[1]=h>>>8&255,a.check=N(a.check,A,2,0),h=0,d=0,a.mode=2;break}if(a.flags=0,a.head&&(a.head.done=!1),!(1&a.wrap)||(((255&h)<<8)+(h>>8))%31){t.msg="incorrect header check",a.mode=30;break}if((15&h)!==fe){t.msg="unknown compression method",a.mode=30;break}if(h>>>=4,d-=4,y=8+(15&h),0===a.wbits)a.wbits=y;else if(y>a.wbits){t.msg="invalid window size",a.mode=30;break}a.dmax=1<<a.wbits,t.adler=a.check=1,a.mode=512&h?10:12,h=0,d=0;break;case 2:for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(a.flags=h,(255&a.flags)!==fe){t.msg="unknown compression method",a.mode=30;break}if(57344&a.flags){t.msg="unknown header flags set",a.mode=30;break}a.head&&(a.head.text=h>>8&1),512&a.flags&&(A[0]=255&h,A[1]=h>>>8&255,a.check=N(a.check,A,2,0)),h=0,d=0,a.mode=3;case 3:for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.head&&(a.head.time=h),512&a.flags&&(A[0]=255&h,A[1]=h>>>8&255,A[2]=h>>>16&255,A[3]=h>>>24&255,a.check=N(a.check,A,4,0)),h=0,d=0,a.mode=4;case 4:for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.head&&(a.head.xflags=255&h,a.head.os=h>>8),512&a.flags&&(A[0]=255&h,A[1]=h>>>8&255,a.check=N(a.check,A,2,0)),h=0,d=0,a.mode=5;case 5:if(1024&a.flags){for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.length=h,a.head&&(a.head.extra_len=h),512&a.flags&&(A[0]=255&h,A[1]=h>>>8&255,a.check=N(a.check,A,2,0)),h=0,d=0}else a.head&&(a.head.extra=null);a.mode=6;case 6:if(1024&a.flags&&(c=a.length,c>o&&(c=o),c&&(a.head&&(y=a.head.extra_len-a.length,a.head.extra||(a.head.extra=new Uint8Array(a.head.extra_len)),a.head.extra.set(i.subarray(s,s+c),y)),512&a.flags&&(a.check=N(a.check,i,c,s)),o-=c,s+=c,a.length-=c),a.length))break t;a.length=0,a.mode=7;case 7:if(2048&a.flags){if(0===o)break t;c=0;do{y=i[s+c++],a.head&&y&&a.length<65536&&(a.head.name+=String.fromCharCode(y))}while(y&&c<o);if(512&a.flags&&(a.check=N(a.check,i,c,s)),o-=c,s+=c,y)break t}else a.head&&(a.head.name=null);a.length=0,a.mode=8;case 8:if(4096&a.flags){if(0===o)break t;c=0;do{y=i[s+c++],a.head&&y&&a.length<65536&&(a.head.comment+=String.fromCharCode(y))}while(y&&c<o);if(512&a.flags&&(a.check=N(a.check,i,c,s)),o-=c,s+=c,y)break t}else a.head&&(a.head.comment=null);a.mode=9;case 9:if(512&a.flags){for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(h!==(65535&a.check)){t.msg="header crc mismatch",a.mode=30;break}h=0,d=0}a.head&&(a.head.hcrc=a.flags>>9&1,a.head.done=!0),t.adler=a.check=0,a.mode=12;break;case 10:for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}t.adler=a.check=ce(h),h=0,d=0,a.mode=11;case 11:if(0===a.havedict)return t.next_out=r,t.avail_out=l,t.next_in=s,t.avail_in=o,a.hold=h,a.bits=d,oe;t.adler=a.check=1,a.mode=12;case 12:if(e===ie||e===ne)break t;case 13:if(a.last){h>>>=7&d,d-=7&d,a.mode=27;break}for(;d<3;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}switch(a.last=1&h,h>>>=1,d-=1,3&h){case 0:a.mode=14;break;case 1:if(ye(a),a.mode=20,e===ne){h>>>=2,d-=2;break t}break;case 2:a.mode=17;break;case 3:t.msg="invalid block type",a.mode=30}h>>>=2,d-=2;break;case 14:for(h>>>=7&d,d-=7&d;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if((65535&h)!=(h>>>16^65535)){t.msg="invalid stored block lengths",a.mode=30;break}if(a.length=65535&h,h=0,d=0,a.mode=15,e===ne)break t;case 15:a.mode=16;case 16:if(c=a.length,c){if(c>o&&(c=o),c>l&&(c=l),0===c)break t;n.set(i.subarray(s,s+c),r),o-=c,s+=c,l-=c,r+=c,a.length-=c;break}a.mode=12;break;case 17:for(;d<14;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(a.nlen=257+(31&h),h>>>=5,d-=5,a.ndist=1+(31&h),h>>>=5,d-=5,a.ncode=4+(15&h),h>>>=4,d-=4,a.nlen>286||a.ndist>30){t.msg="too many length or distance symbols",a.mode=30;break}a.have=0,a.mode=18;case 18:for(;a.have<a.ncode;){for(;d<3;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.lens[Z[a.have++]]=7&h,h>>>=3,d-=3}for(;a.have<19;)a.lens[Z[a.have++]]=0;if(a.lencode=a.lendyn,a.lenbits=7,E={bits:a.lenbits},x=ee(0,a.lens,0,19,a.lencode,0,a.work,E),a.lenbits=E.bits,x){t.msg="invalid code lengths set",a.mode=30;break}a.have=0,a.mode=19;case 19:for(;a.have<a.nlen+a.ndist;){for(;z=a.lencode[h&(1<<a.lenbits)-1],b=z>>>24,g=z>>>16&255,p=65535&z,!(b<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(p<16)h>>>=b,d-=b,a.lens[a.have++]=p;else{if(16===p){for(R=b+2;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(h>>>=b,d-=b,0===a.have){t.msg="invalid bit length repeat",a.mode=30;break}y=a.lens[a.have-1],c=3+(3&h),h>>>=2,d-=2}else if(17===p){for(R=b+3;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=b,d-=b,y=0,c=3+(7&h),h>>>=3,d-=3}else{for(R=b+7;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=b,d-=b,y=0,c=11+(127&h),h>>>=7,d-=7}if(a.have+c>a.nlen+a.ndist){t.msg="invalid bit length repeat",a.mode=30;break}for(;c--;)a.lens[a.have++]=y}}if(30===a.mode)break;if(0===a.lens[256]){t.msg="invalid code -- missing end-of-block",a.mode=30;break}if(a.lenbits=9,E={bits:a.lenbits},x=ee(1,a.lens,0,a.nlen,a.lencode,0,a.work,E),a.lenbits=E.bits,x){t.msg="invalid literal/lengths set",a.mode=30;break}if(a.distbits=6,a.distcode=a.distdyn,E={bits:a.distbits},x=ee(2,a.lens,a.nlen,a.ndist,a.distcode,0,a.work,E),a.distbits=E.bits,x){t.msg="invalid distances set",a.mode=30;break}if(a.mode=20,e===ne)break t;case 20:a.mode=21;case 21:if(o>=6&&l>=258){t.next_out=r,t.avail_out=l,t.next_in=s,t.avail_in=o,a.hold=h,a.bits=d,qt(t,f),r=t.next_out,n=t.output,l=t.avail_out,s=t.next_in,i=t.input,o=t.avail_in,h=a.hold,d=a.bits,12===a.mode&&(a.back=-1);break}for(a.back=0;z=a.lencode[h&(1<<a.lenbits)-1],b=z>>>24,g=z>>>16&255,p=65535&z,!(b<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(g&&0==(240&g)){for(m=b,k=g,v=p;z=a.lencode[v+((h&(1<<m+k)-1)>>m)],b=z>>>24,g=z>>>16&255,p=65535&z,!(m+b<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=m,d-=m,a.back+=m}if(h>>>=b,d-=b,a.back+=b,a.length=p,0===g){a.mode=26;break}if(32&g){a.back=-1,a.mode=12;break}if(64&g){t.msg="invalid literal/length code",a.mode=30;break}a.extra=15&g,a.mode=22;case 22:if(a.extra){for(R=a.extra;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.length+=h&(1<<a.extra)-1,h>>>=a.extra,d-=a.extra,a.back+=a.extra}a.was=a.length,a.mode=23;case 23:for(;z=a.distcode[h&(1<<a.distbits)-1],b=z>>>24,g=z>>>16&255,p=65535&z,!(b<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(0==(240&g)){for(m=b,k=g,v=p;z=a.distcode[v+((h&(1<<m+k)-1)>>m)],b=z>>>24,g=z>>>16&255,p=65535&z,!(m+b<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=m,d-=m,a.back+=m}if(h>>>=b,d-=b,a.back+=b,64&g){t.msg="invalid distance code",a.mode=30;break}a.offset=p,a.extra=15&g,a.mode=24;case 24:if(a.extra){for(R=a.extra;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.offset+=h&(1<<a.extra)-1,h>>>=a.extra,d-=a.extra,a.back+=a.extra}if(a.offset>a.dmax){t.msg="invalid distance too far back",a.mode=30;break}a.mode=25;case 25:if(0===l)break t;if(c=f-l,a.offset>c){if(c=a.offset-c,c>a.whave&&a.sane){t.msg="invalid distance too far back",a.mode=30;break}c>a.wnext?(c-=a.wnext,u=a.wsize-c):u=a.wnext-c,c>a.length&&(c=a.length),w=a.window}else w=n,u=r-a.offset,c=a.length;c>l&&(c=l),l-=c,a.length-=c;do{n[r++]=w[u++]}while(--c);0===a.length&&(a.mode=21);break;case 26:if(0===l)break t;n[r++]=a.length,l--,a.mode=21;break;case 27:if(a.wrap){for(;d<32;){if(0===o)break t;o--,h|=i[s++]<<d,d+=8}if(f-=l,t.total_out+=f,a.total+=f,f&&(t.adler=a.check=a.flags?N(a.check,n,f,r-f):F(a.check,n,f,r-f)),f=l,(a.flags?h:ce(h))!==a.check){t.msg="incorrect data check",a.mode=30;break}h=0,d=0}a.mode=28;case 28:if(a.wrap&&a.flags){for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(h!==(4294967295&a.total)){t.msg="incorrect length check",a.mode=30;break}h=0,d=0}a.mode=29;case 29:x=re;break t;case 30:x=he;break t;case 31:return de;default:return le}return t.next_out=r,t.avail_out=l,t.next_in=s,t.avail_in=o,a.hold=h,a.bits=d,(a.wsize||f!==t.avail_out&&a.mode<30&&(a.mode<27||e!==ae))&&xe(t,t.output,t.next_out,f-t.avail_out),_-=t.avail_in,f-=t.avail_out,t.total_in+=_,t.total_out+=f,a.total+=f,a.wrap&&f&&(t.adler=a.check=a.flags?N(a.check,n,f,t.next_out-f):F(a.check,n,f,t.next_out-f)),t.data_type=a.bits+(a.last?64:0)+(12===a.mode?128:0)+(20===a.mode||15===a.mode?256:0),(0===_&&0===f||e===ae)&&x===se&&(x=_e),x},inflateEnd:t=>{if(!t||!t.state)return le;let e=t.state;return e.window&&(e.window=null),t.state=null,se},inflateGetHeader:(t,e)=>{if(!t||!t.state)return le;const a=t.state;return 0==(2&a.wrap)?le:(a.head=e,e.done=!1,se)},inflateSetDictionary:(t,e)=>{const a=e.length;let i,n,s;return t&&t.state?(i=t.state,0!==i.wrap&&11!==i.mode?le:11===i.mode&&(n=1,n=F(n,e,a,0),n!==i.check)?he:(s=xe(t,e,a,a),s?(i.mode=31,de):(i.havedict=1,se))):le},inflateInfo:"pako inflate (from Nodeca project)"};var Ae=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Ee=Object.prototype.toString,{Z_NO_FLUSH:Re,Z_FINISH:Ze,Z_OK:Se,Z_STREAM_END:Ue,Z_NEED_DICT:De,Z_STREAM_ERROR:Oe,Z_DATA_ERROR:Te,Z_MEM_ERROR:Fe}=B;function Le(t){this.options=St({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Nt,this.strm.avail_out=0;let a=ze.inflateInit2(this.strm,e.windowBits);if(a!==Se)throw new Error(I[a]);if(this.header=new Ae,ze.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Tt(e.dictionary):"[object ArrayBuffer]"===Ee.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(a=ze.inflateSetDictionary(this.strm,e.dictionary),a!==Se)))throw new Error(I[a])}Le.prototype.push=function(t,e){const a=this.strm,i=this.options.chunkSize,n=this.options.dictionary;let s,r,o;if(this.ended)return!1;for(r=e===~~e?e:!0===e?Ze:Re,"[object ArrayBuffer]"===Ee.call(t)?a.input=new Uint8Array(t):a.input=t,a.next_in=0,a.avail_in=a.input.length;;){for(0===a.avail_out&&(a.output=new Uint8Array(i),a.next_out=0,a.avail_out=i),s=ze.inflate(a,r),s===De&&n&&(s=ze.inflateSetDictionary(a,n),s===Se?s=ze.inflate(a,r):s===Te&&(s=De));a.avail_in>0&&s===Ue&&a.state.wrap>0&&0!==t[a.next_in];)ze.inflateReset(a),s=ze.inflate(a,r);switch(s){case Oe:case Te:case De:case Fe:return this.onEnd(s),this.ended=!0,!1}if(o=a.avail_out,a.next_out&&(0===a.avail_out||s===Ue))if("string"===this.options.to){let t=Lt(a.output,a.next_out),e=a.next_out-t,n=Ft(a.output,t);a.next_out=e,a.avail_out=i-e,e&&a.output.set(a.output.subarray(t,t+e),0),this.onData(n)}else this.onData(a.output.length===a.next_out?a.output:a.output.subarray(0,a.next_out));if(s!==Se||0!==o){if(s===Ue)return s=ze.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===a.avail_in)break}}return!0},Le.prototype.onData=function(t){this.chunks.push(t)},Le.prototype.onEnd=function(t){t===Se&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Ut(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};const{Deflate:Ne,deflate:Ie,deflateRaw:Be,gzip:Ce}=Jt;var He=Ne,Me=B,je=new(function(){function t(){this.init()}return t.prototype.init=function(){return this.added=0,this.deflate=new He,this.deflate.push("[",Me.Z_NO_FLUSH),!0},t.prototype.addEvent=function(t){var e=this.added>0?",":"";return this.deflate.push(e+JSON.stringify(t),Me.Z_NO_FLUSH),this.added++,!0},t.prototype.finish=function(){if(this.deflate.push("]",Me.Z_FINISH),this.deflate.err)throw this.deflate.err;var t=this.deflate.result;return this.init(),t},t}()),Ke={init:function(){return je.init(),""},addEvent:function(t){return je.addEvent(t),""},finish:function(){return je.finish()}};addEventListener("message",(function(t){var e=t.data.method,a=t.data.id,i=(t.data.args||[])[0];if(e in Ke&&"function"==typeof Ke[e])try{var n=Ke[e](i);postMessage({id:a,method:e,success:!0,response:n})}catch(t){postMessage({id:a,method:e,success:!1,response:t}),console.error(t)}}));`;
|
|
516
|
+
|
|
517
|
+
function createEventBuffer(_a) {
|
|
518
|
+
var useCompression = _a.useCompression;
|
|
519
|
+
if (useCompression && window.Worker) {
|
|
520
|
+
var workerBlob = new Blob([workerString]);
|
|
521
|
+
var workerUrl = URL.createObjectURL(workerBlob);
|
|
522
|
+
try {
|
|
523
|
+
logger.log('Using compression worker');
|
|
524
|
+
var worker = new Worker(workerUrl);
|
|
525
|
+
if (worker) {
|
|
526
|
+
return new EventBufferCompressionWorker(worker);
|
|
527
|
+
}
|
|
528
|
+
else {
|
|
529
|
+
// TODO: Debugging
|
|
530
|
+
captureException(new Error('Unable to create compression worker'));
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
catch (_b) {
|
|
534
|
+
// catch and ignore, fallback to simple event buffer
|
|
535
|
+
}
|
|
536
|
+
logger.log('Falling back to simple event buffer');
|
|
571
537
|
}
|
|
572
|
-
|
|
538
|
+
logger.log('Using simple buffer');
|
|
539
|
+
return new EventBufferArray();
|
|
573
540
|
}
|
|
574
|
-
|
|
575
|
-
function
|
|
576
|
-
|
|
577
|
-
handlerData.xhr.__sentry_xhr__.startTimestamp = handlerData.startTimestamp;
|
|
541
|
+
var EventBufferArray = /** @class */ (function () {
|
|
542
|
+
function EventBufferArray() {
|
|
543
|
+
this.events = [];
|
|
578
544
|
}
|
|
579
|
-
|
|
580
|
-
|
|
545
|
+
EventBufferArray.prototype.destroy = function () {
|
|
546
|
+
this.events = [];
|
|
547
|
+
};
|
|
548
|
+
Object.defineProperty(EventBufferArray.prototype, "length", {
|
|
549
|
+
get: function () {
|
|
550
|
+
return this.events.length;
|
|
551
|
+
},
|
|
552
|
+
enumerable: false,
|
|
553
|
+
configurable: true
|
|
554
|
+
});
|
|
555
|
+
EventBufferArray.prototype.addEvent = function (event, isCheckout) {
|
|
556
|
+
if (isCheckout) {
|
|
557
|
+
this.events = [event];
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
this.events.push(event);
|
|
561
|
+
};
|
|
562
|
+
EventBufferArray.prototype.finish = function () {
|
|
563
|
+
var _this = this;
|
|
564
|
+
return new Promise(function (resolve) {
|
|
565
|
+
// Make a copy of the events array reference and immediately clear the
|
|
566
|
+
// events member so that we do not lose new events while uploading
|
|
567
|
+
// attachment.
|
|
568
|
+
var eventsRet = _this.events;
|
|
569
|
+
_this.events = [];
|
|
570
|
+
resolve(JSON.stringify(eventsRet));
|
|
571
|
+
});
|
|
572
|
+
};
|
|
573
|
+
return EventBufferArray;
|
|
574
|
+
}());
|
|
575
|
+
// exporting for testing
|
|
576
|
+
var EventBufferCompressionWorker = /** @class */ (function () {
|
|
577
|
+
function EventBufferCompressionWorker(worker) {
|
|
578
|
+
var _this = this;
|
|
579
|
+
this.eventBufferItemLength = 0;
|
|
580
|
+
this._id = 0;
|
|
581
|
+
this.sendEventToWorker = function (event) {
|
|
582
|
+
_this.postMessage({
|
|
583
|
+
id: _this.id,
|
|
584
|
+
method: 'addEvent',
|
|
585
|
+
args: [event],
|
|
586
|
+
});
|
|
587
|
+
logger.log('Message posted to compression worker');
|
|
588
|
+
_this.eventBufferItemLength++;
|
|
589
|
+
};
|
|
590
|
+
this.finishRequest = function (id) {
|
|
591
|
+
return new Promise(function (resolve, reject) {
|
|
592
|
+
var finishListener = function (_a) {
|
|
593
|
+
var data = _a.data;
|
|
594
|
+
if (data.method !== 'finish') {
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
if (data.id !== id) {
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
if (!data.success) {
|
|
601
|
+
// TODO: Do some error handling, not sure what
|
|
602
|
+
logger.error(data.response);
|
|
603
|
+
reject(new Error('Error in compression worker'));
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
resolve(data.response);
|
|
607
|
+
logger.log('Worker responded with compressed payload');
|
|
608
|
+
_this.eventBufferItemLength = 0;
|
|
609
|
+
_this.worker.removeEventListener('message', finishListener);
|
|
610
|
+
};
|
|
611
|
+
_this.worker.addEventListener('message', finishListener);
|
|
612
|
+
_this.postMessage({ id: id, method: 'finish', args: [] });
|
|
613
|
+
});
|
|
614
|
+
};
|
|
615
|
+
this.worker = worker;
|
|
581
616
|
}
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
endTimestamp: handlerData.endTimestamp / 1000.0,
|
|
589
|
-
data: {
|
|
590
|
-
statusCode: handlerData.response.status,
|
|
617
|
+
Object.defineProperty(EventBufferCompressionWorker.prototype, "id", {
|
|
618
|
+
/**
|
|
619
|
+
* Read-only incrementing counter
|
|
620
|
+
*/
|
|
621
|
+
get: function () {
|
|
622
|
+
return this._id++;
|
|
591
623
|
},
|
|
624
|
+
enumerable: false,
|
|
625
|
+
configurable: true
|
|
626
|
+
});
|
|
627
|
+
EventBufferCompressionWorker.prototype.postMessage = function (args) {
|
|
628
|
+
this.worker.postMessage(args);
|
|
592
629
|
};
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
}
|
|
630
|
+
EventBufferCompressionWorker.prototype.init = function () {
|
|
631
|
+
this.postMessage({ id: this.id, method: 'init', args: [] });
|
|
632
|
+
logger.log('Initialized compression worker');
|
|
633
|
+
};
|
|
634
|
+
EventBufferCompressionWorker.prototype.destroy = function () {
|
|
635
|
+
logger.log('Destroying compression worker');
|
|
636
|
+
this.worker.terminate();
|
|
637
|
+
this.worker = null;
|
|
638
|
+
};
|
|
639
|
+
Object.defineProperty(EventBufferCompressionWorker.prototype, "length", {
|
|
640
|
+
get: function () {
|
|
641
|
+
return this.eventBufferItemLength;
|
|
642
|
+
},
|
|
643
|
+
enumerable: false,
|
|
644
|
+
configurable: true
|
|
645
|
+
});
|
|
646
|
+
EventBufferCompressionWorker.prototype.addEvent = function (event, isCheckout) {
|
|
647
|
+
var _this = this;
|
|
648
|
+
// If it is a checkout we should make sure worker buffer is cleared before proceeding
|
|
649
|
+
if (!isCheckout) {
|
|
650
|
+
this.sendEventToWorker(event);
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
var initListener = function (_a) {
|
|
654
|
+
var data = _a.data;
|
|
655
|
+
if (data.method !== 'init') {
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
if (!data.success) {
|
|
659
|
+
// TODO: Do some error handling, not sure what
|
|
660
|
+
logger.error(data.response);
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
// Worker has been re-initialized, can add event now
|
|
664
|
+
_this.sendEventToWorker(event);
|
|
665
|
+
_this.worker.removeEventListener('message', initListener);
|
|
666
|
+
};
|
|
667
|
+
this.worker.addEventListener('message', initListener);
|
|
668
|
+
this.postMessage({ id: this.id, method: 'init', args: [] });
|
|
669
|
+
};
|
|
670
|
+
EventBufferCompressionWorker.prototype.finish = function () {
|
|
671
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
672
|
+
return __generator(this, function (_a) {
|
|
673
|
+
switch (_a.label) {
|
|
674
|
+
case 0: return [4 /*yield*/, this.finishRequest(this.id)];
|
|
675
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
676
|
+
}
|
|
677
|
+
});
|
|
678
|
+
});
|
|
679
|
+
};
|
|
680
|
+
return EventBufferCompressionWorker;
|
|
681
|
+
}());
|
|
602
682
|
|
|
603
683
|
var BASE_RETRY_INTERVAL = 5000;
|
|
604
684
|
var MAX_RETRY_COUNT = 5;
|
|
@@ -608,7 +688,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
608
688
|
var _this = this;
|
|
609
689
|
var _b = _a.flushMinDelay, flushMinDelay = _b === void 0 ? 5000 : _b, _c = _a.flushMaxDelay, flushMaxDelay = _c === void 0 ? 15000 : _c, _d = _a.initialFlushDelay, initialFlushDelay = _d === void 0 ? 5000 : _d, _e = _a.stickySession, stickySession = _e === void 0 ? false : _e, // TBD: Making this opt-in for now
|
|
610
690
|
_f = _a.useCompression, // TBD: Making this opt-in for now
|
|
611
|
-
useCompression = _f === void 0 ? true : _f, _g = _a.
|
|
691
|
+
useCompression = _f === void 0 ? true : _f, _g = _a.captureOnlyOnError, captureOnlyOnError = _g === void 0 ? false : _g, _h = _a.replaysSamplingRate, replaysSamplingRate = _h === void 0 ? 1.0 : _h, _j = _a.recordingConfig, _k = _j === void 0 ? {} : _j, _l = _k.maskAllInputs, maskAllInputs = _l === void 0 ? true : _l, _m = _k.blockClass, blockClass = _m === void 0 ? 'sr-block' : _m, _o = _k.ignoreClass, ignoreClass = _o === void 0 ? 'sr-ignore' : _o, _p = _k.maskTextClass, maskTextClass = _p === void 0 ? 'sr-mask' : _p, recordingOptions = __rest(_k, ["maskAllInputs", "blockClass", "ignoreClass", "maskTextClass"]);
|
|
612
692
|
/**
|
|
613
693
|
* @inheritDoc
|
|
614
694
|
*/
|
|
@@ -641,6 +721,65 @@ var SentryReplay = /** @class */ (function () {
|
|
|
641
721
|
* immediately before sending recording)
|
|
642
722
|
*/
|
|
643
723
|
this.needsCaptureReplay = false;
|
|
724
|
+
/**
|
|
725
|
+
* Core Sentry SDK global event handler. Attaches `replayId` to all [non-replay]
|
|
726
|
+
* events as a tag. Also handles the case where we only want to capture a reply
|
|
727
|
+
* when an error occurs.
|
|
728
|
+
**/
|
|
729
|
+
this.handleGlobalEvent = function (event) {
|
|
730
|
+
var _a;
|
|
731
|
+
// Do not apply replayId to the root event
|
|
732
|
+
if (event.message === ROOT_REPLAY_NAME ||
|
|
733
|
+
((_a = event.message) === null || _a === void 0 ? void 0 : _a.startsWith(REPLAY_EVENT_NAME))) {
|
|
734
|
+
return event;
|
|
735
|
+
}
|
|
736
|
+
event.tags = __assign(__assign({}, event.tags), { replayId: _this.session.id });
|
|
737
|
+
// Need to be very careful that this does not cause an infinite loop
|
|
738
|
+
if (_this.options.captureOnlyOnError && event.exception) {
|
|
739
|
+
// TODO: Do we continue to record after?
|
|
740
|
+
// TODO: What happens if another error happens? Do we record in the same session?
|
|
741
|
+
setTimeout(function () { return _this.flushUpdate(); });
|
|
742
|
+
}
|
|
743
|
+
return event;
|
|
744
|
+
};
|
|
745
|
+
/**
|
|
746
|
+
* Handler for recording events.
|
|
747
|
+
*
|
|
748
|
+
* Adds to event buffer, and has varying flushing behaviors if the event was a checkout.
|
|
749
|
+
*/
|
|
750
|
+
this.handleRecordingEmit = function (event, isCheckout) {
|
|
751
|
+
// If this is false, it means session is expired, create and a new session and wait for checkout
|
|
752
|
+
if (!_this.checkAndHandleExpiredSession()) {
|
|
753
|
+
logger.error(new Error('Received replay event after session expired.'));
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
_this.addUpdate(function () {
|
|
757
|
+
// We need to clear existing events on a checkout, otherwise they are
|
|
758
|
+
// incremental event updates and should be appended
|
|
759
|
+
_this.eventBuffer.addEvent(event, isCheckout);
|
|
760
|
+
// Different behavior for full snapshots (type=2), ignore other event types
|
|
761
|
+
// See https://github.com/rrweb-io/rrweb/blob/d8f9290ca496712aa1e7d472549480c4e7876594/packages/rrweb/src/types.ts#L16
|
|
762
|
+
if (event.type !== 2) {
|
|
763
|
+
return false;
|
|
764
|
+
}
|
|
765
|
+
// If there is a previousSessionId after a full snapshot occurs, then
|
|
766
|
+
// the replay session was started due to session expiration. The new session
|
|
767
|
+
// is started before triggering a new checkout and contains the id
|
|
768
|
+
// of the previous session. Do not immediately flush in this case
|
|
769
|
+
// to avoid capturing only the checkout and instead the replay will
|
|
770
|
+
// be captured if they perform any follow-up actions.
|
|
771
|
+
if (_this.session.previousSessionId) {
|
|
772
|
+
return true;
|
|
773
|
+
}
|
|
774
|
+
// If the full snapshot is due to an initial load, we will not have
|
|
775
|
+
// a previous session ID. In this case, we want to buffer events
|
|
776
|
+
// for a set amount of time before flushing. This can help avoid
|
|
777
|
+
// capturing replays of users that immediately close the window.
|
|
778
|
+
var now = new Date().getTime();
|
|
779
|
+
setTimeout(function () { return _this.conditionalFlush(now); }, _this.options.initialFlushDelay);
|
|
780
|
+
return true;
|
|
781
|
+
});
|
|
782
|
+
};
|
|
644
783
|
/**
|
|
645
784
|
* Handle when visibility of the page content changes. Opening a new tab will
|
|
646
785
|
* cause the state to change to hidden because of content of current page will
|
|
@@ -673,11 +812,21 @@ var SentryReplay = /** @class */ (function () {
|
|
|
673
812
|
});
|
|
674
813
|
_this.doChangeToForegroundTasks(breadcrumb);
|
|
675
814
|
};
|
|
815
|
+
/**
|
|
816
|
+
* Handle when page is closed
|
|
817
|
+
*/
|
|
676
818
|
this.handleWindowUnload = function () {
|
|
677
819
|
_this.createCustomBreadcrumb(createBreadcrumb({
|
|
678
820
|
category: 'ui.exit',
|
|
679
821
|
}));
|
|
822
|
+
_this.destroy();
|
|
680
823
|
};
|
|
824
|
+
/**
|
|
825
|
+
* Handler for Sentry Core SDK events.
|
|
826
|
+
*
|
|
827
|
+
* Transforms core SDK events into replay events.
|
|
828
|
+
*
|
|
829
|
+
*/
|
|
681
830
|
this.handleCoreListener = function (type) { return function (handlerData) {
|
|
682
831
|
var handlerMap = {
|
|
683
832
|
scope: [handleScope, 'breadcrumb'],
|
|
@@ -716,16 +865,24 @@ var SentryReplay = /** @class */ (function () {
|
|
|
716
865
|
this.handlePerformanceObserver = function (list
|
|
717
866
|
// observer: PerformanceObserver
|
|
718
867
|
) {
|
|
719
|
-
|
|
868
|
+
var newEntries = list.getEntries();
|
|
869
|
+
_this.performanceEvents = __spreadArray(__spreadArray([], _this.performanceEvents, true), newEntries, true);
|
|
720
870
|
};
|
|
721
|
-
this.
|
|
871
|
+
this.recordingOptions = __assign({ maskAllInputs: maskAllInputs, blockClass: blockClass, ignoreClass: ignoreClass, maskTextClass: maskTextClass }, recordingOptions);
|
|
722
872
|
this.options = {
|
|
723
873
|
flushMinDelay: flushMinDelay,
|
|
724
874
|
flushMaxDelay: flushMaxDelay,
|
|
725
875
|
stickySession: stickySession,
|
|
726
876
|
initialFlushDelay: initialFlushDelay,
|
|
877
|
+
captureOnlyOnError: captureOnlyOnError,
|
|
878
|
+
replaysSamplingRate: replaysSamplingRate,
|
|
879
|
+
useCompression: useCompression,
|
|
727
880
|
};
|
|
728
|
-
this
|
|
881
|
+
// Modify rrweb options to checkoutEveryNthSecond if this is defined, as we don't know when an error occurs, so we want to try to minimize the number of events captured.
|
|
882
|
+
if (this.options.captureOnlyOnError) {
|
|
883
|
+
// Checkout every minute, meaning we only get up-to one minute of events before the error happens
|
|
884
|
+
this.recordingOptions.checkoutEveryNms = 60000;
|
|
885
|
+
}
|
|
729
886
|
}
|
|
730
887
|
SentryReplay.attachmentUrlFromDsn = function (dsn, eventId) {
|
|
731
888
|
var host = dsn.host, projectId = dsn.projectId, protocol = dsn.protocol, publicKey = dsn.publicKey;
|
|
@@ -733,68 +890,49 @@ var SentryReplay = /** @class */ (function () {
|
|
|
733
890
|
var path = dsn.path !== '' ? "/".concat(dsn.path) : '';
|
|
734
891
|
return "".concat(protocol, "://").concat(host).concat(port).concat(path, "/api/").concat(projectId, "/events/").concat(eventId, "/attachments/?sentry_key=").concat(publicKey, "&sentry_version=7&sentry_client=replay");
|
|
735
892
|
};
|
|
893
|
+
/**
|
|
894
|
+
* Because we create a transaction in `setupOnce`, we can potentially create a
|
|
895
|
+
* transaction before some native SDK integrations have run and applied their
|
|
896
|
+
* own global event processor. An example is:
|
|
897
|
+
* https://github.com/getsentry/sentry-javascript/blob/b47ceafbdac7f8b99093ce6023726ad4687edc48/packages/browser/src/integrations/useragent.ts
|
|
898
|
+
*
|
|
899
|
+
* So we call `this.setup` in next event loop as a workaround to wait for
|
|
900
|
+
* other global event processors to finish
|
|
901
|
+
*/
|
|
736
902
|
SentryReplay.prototype.setupOnce = function () {
|
|
737
903
|
var _this = this;
|
|
738
|
-
|
|
739
|
-
* Because we create a transaction in `setupOnce`, we can potentially create a
|
|
740
|
-
* transaction before some native SDK integrations have run and applied their
|
|
741
|
-
* own global event processor. An example is:
|
|
742
|
-
* https://github.com/getsentry/sentry-javascript/blob/b47ceafbdac7f8b99093ce6023726ad4687edc48/packages/browser/src/integrations/useragent.ts
|
|
743
|
-
*
|
|
744
|
-
* So we do this as a workaround to wait for other global event processors to finish
|
|
745
|
-
*/
|
|
904
|
+
// XXX: See method comments above
|
|
746
905
|
window.setTimeout(function () { return _this.setup(); });
|
|
747
906
|
};
|
|
907
|
+
/**
|
|
908
|
+
* Initializes the plugin.
|
|
909
|
+
*
|
|
910
|
+
* Creates or loads a session, attaches listeners to varying events (DOM, PerformanceObserver, Recording, Sentry SDK, etc)
|
|
911
|
+
*/
|
|
748
912
|
SentryReplay.prototype.setup = function () {
|
|
749
|
-
var _this = this;
|
|
750
913
|
this.loadSession({ expiry: SESSION_IDLE_DURATION });
|
|
751
914
|
// If there is no session, then something bad has happened - can't continue
|
|
752
915
|
if (!this.session) {
|
|
753
916
|
throw new Error('Invalid session');
|
|
754
917
|
}
|
|
918
|
+
if (!this.session.sampled) {
|
|
919
|
+
// If session was not sampled, then we do not initialize the integration at all.
|
|
920
|
+
return;
|
|
921
|
+
}
|
|
922
|
+
this.eventBuffer = createEventBuffer({
|
|
923
|
+
useCompression: this.options.useCompression,
|
|
924
|
+
});
|
|
755
925
|
this.addListeners();
|
|
756
926
|
// Tag all (non replay) events that get sent to Sentry with the current
|
|
757
927
|
// replay ID so that we can reference them later in the UI
|
|
758
|
-
addGlobalEventProcessor(
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
}
|
|
766
|
-
record(__assign(__assign({}, this.rrwebRecordOptions), { emit: function (event, isCheckout) {
|
|
767
|
-
// If this is false, it means session is expired, create and a new session and wait for checkout
|
|
768
|
-
if (!_this.checkAndHandleExpiredSession()) {
|
|
769
|
-
logger.error(new Error('Received replay event after session expired.'));
|
|
770
|
-
return;
|
|
771
|
-
}
|
|
772
|
-
_this.addUpdate(function () {
|
|
773
|
-
// We need to clear existing events on a checkout, otherwise they are
|
|
774
|
-
// incremental event updates and should be appended
|
|
775
|
-
_this.eventBuffer.addEvent(event, isCheckout);
|
|
776
|
-
// This event type is a fullsnapshot
|
|
777
|
-
// See https://github.com/rrweb-io/rrweb/blob/d8f9290ca496712aa1e7d472549480c4e7876594/packages/rrweb/src/types.ts#L16
|
|
778
|
-
if (event.type === 2) {
|
|
779
|
-
// If the full snapshot is due to an initial load, we will not have
|
|
780
|
-
// a previous session ID. In this case, we want to buffer events
|
|
781
|
-
// for a set amount of time before flushing. This can help avoid
|
|
782
|
-
// capturing replays of users that immediately close the window.
|
|
783
|
-
if (!_this.session.previousSessionId) {
|
|
784
|
-
var now_1 = new Date().getTime();
|
|
785
|
-
setTimeout(function () { return _this.flushUpdate(now_1); }, _this.options.initialFlushDelay);
|
|
786
|
-
return true;
|
|
787
|
-
}
|
|
788
|
-
// The other case where a full snapshot occurs is when a new replay
|
|
789
|
-
// needs to be started due to session expiration. The new session
|
|
790
|
-
// is started before triggering a new checkout and contains the id
|
|
791
|
-
// of the previous session. Do not immediately flush in this case
|
|
792
|
-
// to avoid capturing only the checkout and instead the replay will
|
|
793
|
-
// be captured if they perform any follow-up actions.
|
|
794
|
-
return true;
|
|
795
|
-
}
|
|
796
|
-
});
|
|
797
|
-
} }));
|
|
928
|
+
addGlobalEventProcessor(this.handleGlobalEvent);
|
|
929
|
+
record(__assign(__assign({}, this.recordingOptions), { emit: this.handleRecordingEmit }));
|
|
930
|
+
// Otherwise, these will be captured after the first flush, which means the
|
|
931
|
+
// URL and timestamps could be incorrect
|
|
932
|
+
this.initialState = {
|
|
933
|
+
timestamp: new Date().getTime(),
|
|
934
|
+
url: "".concat(window.location.origin).concat(window.location.pathname),
|
|
935
|
+
};
|
|
798
936
|
};
|
|
799
937
|
/**
|
|
800
938
|
* We want to batch uploads of replay events. Save events only if
|
|
@@ -809,16 +947,24 @@ var SentryReplay = /** @class */ (function () {
|
|
|
809
947
|
var now = new Date().getTime();
|
|
810
948
|
// Timestamp of the first replay event since the last flush, this gets
|
|
811
949
|
// reset when we finish the replay event
|
|
812
|
-
if (!this.initialEventTimestampSinceFlush
|
|
950
|
+
if (!this.initialEventTimestampSinceFlush &&
|
|
951
|
+
!this.options.captureOnlyOnError) {
|
|
813
952
|
this.initialEventTimestampSinceFlush = now;
|
|
814
953
|
}
|
|
815
954
|
// Do not finish the replay event if we receive a new replay event
|
|
816
955
|
if (this.timeout) {
|
|
817
956
|
window.clearTimeout(this.timeout);
|
|
818
957
|
}
|
|
958
|
+
// We need to always run `cb` (e.g. in the case of captureOnlyOnError == true)
|
|
959
|
+
var cbResult = cb === null || cb === void 0 ? void 0 : cb();
|
|
960
|
+
// If this option is turned on then we will only want to call `flushUpdate`
|
|
961
|
+
// explicitly
|
|
962
|
+
if (this.options.captureOnlyOnError) {
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
819
965
|
// If callback is true, we do not want to continue with flushing -- the
|
|
820
966
|
// caller will need to handle it.
|
|
821
|
-
if (
|
|
967
|
+
if (cbResult === true) {
|
|
822
968
|
return;
|
|
823
969
|
}
|
|
824
970
|
var flushMaxDelayExceeded = isExpired(this.initialEventTimestampSinceFlush, this.options.flushMaxDelay, now);
|
|
@@ -858,6 +1004,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
858
1004
|
expiry: expiry,
|
|
859
1005
|
stickySession: this.options.stickySession,
|
|
860
1006
|
currentSession: this.session,
|
|
1007
|
+
samplingRate: this.options.replaysSamplingRate,
|
|
861
1008
|
}), type = _d.type, session = _d.session;
|
|
862
1009
|
// If session was newly created (i.e. was not loaded from storage), then
|
|
863
1010
|
// enable flag to create the root replay
|
|
@@ -869,6 +1016,9 @@ var SentryReplay = /** @class */ (function () {
|
|
|
869
1016
|
}
|
|
870
1017
|
this.session = session;
|
|
871
1018
|
};
|
|
1019
|
+
/**
|
|
1020
|
+
* Adds listeners to record events for the replay
|
|
1021
|
+
*/
|
|
872
1022
|
SentryReplay.prototype.addListeners = function () {
|
|
873
1023
|
var _this = this;
|
|
874
1024
|
document.addEventListener('visibilitychange', this.handleVisibilityChange);
|
|
@@ -902,9 +1052,14 @@ var SentryReplay = /** @class */ (function () {
|
|
|
902
1052
|
});
|
|
903
1053
|
});
|
|
904
1054
|
};
|
|
1055
|
+
/**
|
|
1056
|
+
* Cleans up listeners that were created in `addListeners`
|
|
1057
|
+
*/
|
|
905
1058
|
SentryReplay.prototype.removeListeners = function () {
|
|
906
1059
|
document.removeEventListener('visibilitychange', this.handleVisibilityChange);
|
|
907
|
-
|
|
1060
|
+
window.removeEventListener('blur', this.handleWindowBlur);
|
|
1061
|
+
window.removeEventListener('focus', this.handleWindowFocus);
|
|
1062
|
+
window.removeEventListener('beforeunload', this.handleWindowUnload);
|
|
908
1063
|
if (this.performanceObserver) {
|
|
909
1064
|
this.performanceObserver.disconnect();
|
|
910
1065
|
this.performanceObserver = null;
|
|
@@ -925,7 +1080,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
925
1080
|
// Send replay when the page/tab becomes hidden. There is no reason to send
|
|
926
1081
|
// replay if it becomes visible, since no actions we care about were done
|
|
927
1082
|
// while it was hidden
|
|
928
|
-
this.
|
|
1083
|
+
this.conditionalFlush();
|
|
929
1084
|
};
|
|
930
1085
|
/**
|
|
931
1086
|
* Tasks to run when we consider a page to be visible (via focus and/or visibility)
|
|
@@ -960,10 +1115,16 @@ var SentryReplay = /** @class */ (function () {
|
|
|
960
1115
|
logger.log('Taking full rrweb snapshot');
|
|
961
1116
|
record.takeFullSnapshot(true);
|
|
962
1117
|
};
|
|
1118
|
+
/**
|
|
1119
|
+
* Updates the session's last activity timestamp
|
|
1120
|
+
*/
|
|
963
1121
|
SentryReplay.prototype.updateLastActivity = function (lastActivity) {
|
|
964
1122
|
if (lastActivity === void 0) { lastActivity = new Date().getTime(); }
|
|
965
1123
|
this.session.lastActivity = lastActivity;
|
|
966
1124
|
};
|
|
1125
|
+
/**
|
|
1126
|
+
* Helper to create (and buffer) a replay breadcrumb from a core SDK breadcrumb
|
|
1127
|
+
*/
|
|
967
1128
|
SentryReplay.prototype.createCustomBreadcrumb = function (breadcrumb) {
|
|
968
1129
|
var _this = this;
|
|
969
1130
|
this.addUpdate(function () {
|
|
@@ -1041,9 +1202,24 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1041
1202
|
this.triggerFullSnapshot();
|
|
1042
1203
|
return false;
|
|
1043
1204
|
};
|
|
1205
|
+
/**
|
|
1206
|
+
* Only flush if `captureOnlyOnError` is false.
|
|
1207
|
+
*/
|
|
1208
|
+
SentryReplay.prototype.conditionalFlush = function (lastActivity) {
|
|
1209
|
+
if (this.options.captureOnlyOnError) {
|
|
1210
|
+
return;
|
|
1211
|
+
}
|
|
1212
|
+
return this.flushUpdate(lastActivity);
|
|
1213
|
+
};
|
|
1214
|
+
/**
|
|
1215
|
+
* Flushes replay event buffer to Sentry.
|
|
1216
|
+
*
|
|
1217
|
+
* Performance events are only added right before flushing - this is probably
|
|
1218
|
+
* due to the buffered performance observer events.
|
|
1219
|
+
*/
|
|
1044
1220
|
SentryReplay.prototype.flushUpdate = function (lastActivity) {
|
|
1045
1221
|
return __awaiter(this, void 0, void 0, function () {
|
|
1046
|
-
var recordingData, err_1;
|
|
1222
|
+
var timestamp, recordingData, err_1;
|
|
1047
1223
|
return __generator(this, function (_a) {
|
|
1048
1224
|
switch (_a.label) {
|
|
1049
1225
|
case 0:
|
|
@@ -1062,7 +1238,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1062
1238
|
// Only want to create replay event if session is new
|
|
1063
1239
|
if (this.needsCaptureReplay) {
|
|
1064
1240
|
// This event needs to exist before calling `sendReplay`
|
|
1065
|
-
captureReplay(this.session);
|
|
1241
|
+
captureReplay({ session: this.session, initialState: this.initialState });
|
|
1066
1242
|
this.needsCaptureReplay = false;
|
|
1067
1243
|
}
|
|
1068
1244
|
// Reset this to null regardless of `sendReplay` result so that future
|
|
@@ -1071,6 +1247,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1071
1247
|
_a.label = 1;
|
|
1072
1248
|
case 1:
|
|
1073
1249
|
_a.trys.push([1, 4, , 5]);
|
|
1250
|
+
timestamp = lastActivity !== null && lastActivity !== void 0 ? lastActivity : new Date().getTime();
|
|
1074
1251
|
return [4 /*yield*/, this.eventBuffer.finish()];
|
|
1075
1252
|
case 2:
|
|
1076
1253
|
recordingData = _a.sent();
|
|
@@ -1079,14 +1256,11 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1079
1256
|
_a.sent();
|
|
1080
1257
|
// The below will only happen after successfully sending replay //
|
|
1081
1258
|
// TBD: Alternatively we could update this after every rrweb event
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
sequenceId: this.session.sequenceId++,
|
|
1088
|
-
},
|
|
1089
|
-
});
|
|
1259
|
+
// `timestamp` should reflect when the event happens. e.g. the timestamp
|
|
1260
|
+
// of the event is passed as an argument in the case where a timeout
|
|
1261
|
+
// occurs.
|
|
1262
|
+
this.updateLastActivity(timestamp);
|
|
1263
|
+
captureReplayUpdate({ session: this.session, timestamp: timestamp });
|
|
1090
1264
|
return [3 /*break*/, 5];
|
|
1091
1265
|
case 4:
|
|
1092
1266
|
err_1 = _a.sent();
|
|
@@ -1097,12 +1271,6 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1097
1271
|
});
|
|
1098
1272
|
});
|
|
1099
1273
|
};
|
|
1100
|
-
/**
|
|
1101
|
-
* Determine if there is browser support for `navigator.sendBeacon`
|
|
1102
|
-
*/
|
|
1103
|
-
SentryReplay.prototype.hasSendBeacon = function () {
|
|
1104
|
-
return 'navigator' in window && 'sendBeacon' in window.navigator;
|
|
1105
|
-
};
|
|
1106
1274
|
/**
|
|
1107
1275
|
* Send replay attachment using either `sendBeacon()` or `fetch()`
|
|
1108
1276
|
*/
|
|
@@ -1120,7 +1288,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1120
1288
|
logger.log('blob size in bytes: ', payloadBlob.size);
|
|
1121
1289
|
formData.append('rrweb', payloadBlob, "rrweb-".concat(new Date().getTime(), ".json"));
|
|
1122
1290
|
// If sendBeacon is supported and payload is smol enough...
|
|
1123
|
-
if (
|
|
1291
|
+
if (supportsSendBeacon() && payloadBlob.size <= 65535) {
|
|
1124
1292
|
logger.log("uploading attachment via sendBeacon()");
|
|
1125
1293
|
window.navigator.sendBeacon(endpoint, formData);
|
|
1126
1294
|
return [2 /*return*/];
|