@sentry/replay 7.32.0 → 7.33.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/cjs/index.js +992 -980
- package/cjs/index.js.map +1 -1
- package/esm/index.js +994 -982
- package/esm/index.js.map +1 -1
- package/package.json +4 -4
- package/types/constants.d.ts +0 -5
- package/types/constants.d.ts.map +1 -1
- package/types/coreHandlers/addBreadcrumbEvent.d.ts +7 -0
- package/types/coreHandlers/addBreadcrumbEvent.d.ts.map +1 -0
- package/types/coreHandlers/handleDom.d.ts +4 -6
- package/types/coreHandlers/handleDom.d.ts.map +1 -1
- package/types/coreHandlers/handleScope.d.ts +2 -0
- package/types/coreHandlers/handleScope.d.ts.map +1 -1
- package/types/integration.d.ts.map +1 -1
- package/types/replay.d.ts +11 -14
- package/types/replay.d.ts.map +1 -1
- package/types/types.d.ts +1 -1
- package/types/types.d.ts.map +1 -1
- package/types/util/addGlobalListeners.d.ts +6 -0
- package/types/util/addGlobalListeners.d.ts.map +1 -0
- package/types/coreHandlers/breadcrumbHandler.d.ts +0 -7
- package/types/coreHandlers/breadcrumbHandler.d.ts.map +0 -1
package/cjs/index.js
CHANGED
|
@@ -22,12 +22,6 @@ const VISIBILITY_CHANGE_TIMEOUT = SESSION_IDLE_DURATION;
|
|
|
22
22
|
// The maximum length of a session
|
|
23
23
|
const MAX_SESSION_LIFE = 3600000; // 60 minutes
|
|
24
24
|
|
|
25
|
-
/**
|
|
26
|
-
* Defaults for sampling rates
|
|
27
|
-
*/
|
|
28
|
-
const DEFAULT_SESSION_SAMPLE_RATE = 0.1;
|
|
29
|
-
const DEFAULT_ERROR_SAMPLE_RATE = 1.0;
|
|
30
|
-
|
|
31
25
|
/** The select to use for the `maskAllText` option */
|
|
32
26
|
const MASK_ALL_TEXT_SELECTOR = 'body *:not(style), body *:not(script)';
|
|
33
27
|
|
|
@@ -3288,1087 +3282,1158 @@ record.takeFullSnapshot = function (isCheckout) {
|
|
|
3288
3282
|
};
|
|
3289
3283
|
record.mirror = mirror;
|
|
3290
3284
|
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3285
|
+
const NAVIGATION_ENTRY_KEYS = [
|
|
3286
|
+
'name',
|
|
3287
|
+
'type',
|
|
3288
|
+
'startTime',
|
|
3289
|
+
'transferSize',
|
|
3290
|
+
'duration',
|
|
3291
|
+
];
|
|
3292
|
+
|
|
3293
|
+
function isNavigationEntryEqual(a) {
|
|
3294
|
+
return function (b) {
|
|
3295
|
+
return NAVIGATION_ENTRY_KEYS.every(key => a[key] === b[key]);
|
|
3301
3296
|
};
|
|
3302
3297
|
}
|
|
3303
3298
|
|
|
3304
3299
|
/**
|
|
3305
|
-
*
|
|
3300
|
+
* There are some difficulties diagnosing why there are duplicate navigation
|
|
3301
|
+
* entries. We've witnessed several intermittent results:
|
|
3302
|
+
* - duplicate entries have duration = 0
|
|
3303
|
+
* - duplicate entries are the same object reference
|
|
3304
|
+
* - none of the above
|
|
3305
|
+
*
|
|
3306
|
+
* Compare the values of several keys to determine if the entries are duplicates or not.
|
|
3306
3307
|
*/
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3308
|
+
// TODO (high-prio): Figure out wth is returned here
|
|
3309
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
3310
|
+
function dedupePerformanceEntries(
|
|
3311
|
+
currentList,
|
|
3312
|
+
newList,
|
|
3313
|
+
) {
|
|
3314
|
+
// Partition `currentList` into 3 different lists based on entryType
|
|
3315
|
+
const [existingNavigationEntries, existingLcpEntries, existingEntries] = currentList.reduce(
|
|
3316
|
+
(acc, entry) => {
|
|
3317
|
+
if (entry.entryType === 'navigation') {
|
|
3318
|
+
acc[0].push(entry );
|
|
3319
|
+
} else if (entry.entryType === 'largest-contentful-paint') {
|
|
3320
|
+
acc[1].push(entry );
|
|
3321
|
+
} else {
|
|
3322
|
+
acc[2].push(entry);
|
|
3323
|
+
}
|
|
3324
|
+
return acc;
|
|
3325
|
+
},
|
|
3326
|
+
[[], [], []],
|
|
3327
|
+
);
|
|
3311
3328
|
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
target = '<unknown>';
|
|
3318
|
-
}
|
|
3329
|
+
const newEntries = [];
|
|
3330
|
+
const newNavigationEntries = [];
|
|
3331
|
+
let newLcpEntry = existingLcpEntries.length
|
|
3332
|
+
? existingLcpEntries[existingLcpEntries.length - 1] // Take the last element as list is sorted
|
|
3333
|
+
: undefined;
|
|
3319
3334
|
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3335
|
+
newList.forEach(entry => {
|
|
3336
|
+
if (entry.entryType === 'largest-contentful-paint') {
|
|
3337
|
+
// We want the latest LCP event only
|
|
3338
|
+
if (!newLcpEntry || newLcpEntry.startTime < entry.startTime) {
|
|
3339
|
+
newLcpEntry = entry;
|
|
3340
|
+
}
|
|
3341
|
+
return;
|
|
3342
|
+
}
|
|
3323
3343
|
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
message: target,
|
|
3327
|
-
data: {
|
|
3328
|
-
// Not sure why this errors, Node should be correct (Argument of type 'Node' is not assignable to parameter of type 'INode')
|
|
3329
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3330
|
-
...(targetNode ? { nodeId: record.mirror.getId(targetNode ) } : {}),
|
|
3331
|
-
},
|
|
3332
|
-
});
|
|
3333
|
-
}
|
|
3344
|
+
if (entry.entryType === 'navigation') {
|
|
3345
|
+
const navigationEntry = entry ;
|
|
3334
3346
|
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3347
|
+
// Check if the navigation entry is contained in currentList or newList
|
|
3348
|
+
if (
|
|
3349
|
+
// Ignore any navigation entries with duration 0, as they are likely duplicates
|
|
3350
|
+
entry.duration > 0 &&
|
|
3351
|
+
// Ensure new entry does not already exist in existing entries
|
|
3352
|
+
!existingNavigationEntries.find(isNavigationEntryEqual(navigationEntry)) &&
|
|
3353
|
+
// Ensure new entry does not already exist in new list of navigation entries
|
|
3354
|
+
!newNavigationEntries.find(isNavigationEntryEqual(navigationEntry))
|
|
3355
|
+
) {
|
|
3356
|
+
newNavigationEntries.push(navigationEntry);
|
|
3357
|
+
}
|
|
3339
3358
|
|
|
3340
|
-
|
|
3341
|
-
|
|
3359
|
+
// Otherwise this navigation entry is considered a duplicate and is thrown away
|
|
3360
|
+
return;
|
|
3361
|
+
}
|
|
3342
3362
|
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
}
|
|
3363
|
+
newEntries.push(entry);
|
|
3364
|
+
});
|
|
3346
3365
|
|
|
3347
|
-
|
|
3366
|
+
// Re-combine and sort by startTime
|
|
3367
|
+
return [
|
|
3368
|
+
...(newLcpEntry ? [newLcpEntry] : []),
|
|
3369
|
+
...existingNavigationEntries,
|
|
3370
|
+
...existingEntries,
|
|
3371
|
+
...newEntries,
|
|
3372
|
+
...newNavigationEntries,
|
|
3373
|
+
].sort((a, b) => a.startTime - b.startTime);
|
|
3374
|
+
}
|
|
3348
3375
|
|
|
3349
3376
|
/**
|
|
3350
|
-
*
|
|
3377
|
+
* Sets up a PerformanceObserver to listen to all performance entry types.
|
|
3351
3378
|
*/
|
|
3352
|
-
function
|
|
3353
|
-
const
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3379
|
+
function setupPerformanceObserver(replay) {
|
|
3380
|
+
const performanceObserverHandler = (list) => {
|
|
3381
|
+
// For whatever reason the observer was returning duplicate navigation
|
|
3382
|
+
// entries (the other entry types were not duplicated).
|
|
3383
|
+
const newPerformanceEntries = dedupePerformanceEntries(
|
|
3384
|
+
replay.performanceEvents,
|
|
3385
|
+
list.getEntries() ,
|
|
3386
|
+
);
|
|
3387
|
+
replay.performanceEvents = newPerformanceEntries;
|
|
3388
|
+
};
|
|
3360
3389
|
|
|
3361
|
-
|
|
3390
|
+
const performanceObserver = new PerformanceObserver(performanceObserverHandler);
|
|
3362
3391
|
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3392
|
+
[
|
|
3393
|
+
'element',
|
|
3394
|
+
'event',
|
|
3395
|
+
'first-input',
|
|
3396
|
+
'largest-contentful-paint',
|
|
3397
|
+
'layout-shift',
|
|
3398
|
+
'longtask',
|
|
3399
|
+
'navigation',
|
|
3400
|
+
'paint',
|
|
3401
|
+
'resource',
|
|
3402
|
+
].forEach(type => {
|
|
3403
|
+
try {
|
|
3404
|
+
performanceObserver.observe({
|
|
3405
|
+
type,
|
|
3406
|
+
buffered: true,
|
|
3407
|
+
});
|
|
3408
|
+
} catch (e) {
|
|
3409
|
+
// This can throw if an entry type is not supported in the browser.
|
|
3410
|
+
// Ignore these errors.
|
|
3411
|
+
}
|
|
3412
|
+
});
|
|
3370
3413
|
|
|
3371
|
-
return
|
|
3414
|
+
return performanceObserver;
|
|
3372
3415
|
}
|
|
3373
3416
|
|
|
3417
|
+
const workerString = `/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */
|
|
3418
|
+
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 m=t=>t<256?o[t]:o[256+(t>>>7)],b=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},g=(t,e,a)=>{t.bi_valid>16-a?(t.bi_buf|=e<<t.bi_valid&65535,b(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)},p=(t,e,a)=>{g(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++)r=r+a[n-1]<<1,i[n]=r;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.sym_next=t.matches=0},x=t=>{t.bi_valid>8?b(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.sym_next)do{s=255&t.pending_buf[t.sym_buf+f++],s+=(255&t.pending_buf[t.sym_buf+f++])<<8,r=t.pending_buf[t.sym_buf+f++],0===s?p(t,r,i):(o=l[r],p(t,o+256+1,i),_=e[o],0!==_&&(r-=h[o],g(t,r,_)),s--,o=m(s),p(t,o,n),_=a[o],0!==_&&(s-=d[o],g(t,s,_)))}while(f<t.sym_next);p(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{p(t,n,t.bl_tree)}while(0!=--o);else 0!==n?(n!==s&&(p(t,n,t.bl_tree),o--),p(t,16,t.bl_tree),g(t,o-3,2)):o<=10?(p(t,17,t.bl_tree),g(t,o-3,3)):(p(t,18,t.bl_tree),g(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)=>{g(t,0+(i?1:0),3),x(t),b(t,a),b(t,~a),a&&t.pending_buf.set(t.window.subarray(e,e+a),t.pending),t.pending+=a};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?(g(t,2+(i?1:0),3),E(t,s,r)):(g(t,4+(i?1:0),3),((t,e,a,i)=>{let s;for(g(t,e-257,5),g(t,a-1,5),g(t,i-4,4),s=0;s<i;s++)g(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,m,b;const g=new Array(16);for(w=0,m=0;m<28;m++)for(h[m]=w,t=0;t<1<<e[m];t++)l[w++]=m;for(l[w-1]=m,b=0,m=0;m<16;m++)for(d[m]=b,t=0;t<1<<a[m];t++)o[b++]=m;for(b>>=7;m<30;m++)for(d[m]=b<<7,t=0;t<1<<a[m]-7;t++)o[256+b++]=m;for(n=0;n<=15;n++)g[n]=0;for(t=0;t<=143;)s[2*t+1]=8,t++,g[8]++;for(;t<=255;)s[2*t+1]=9,t++,g[9]++;for(;t<=279;)s[2*t+1]=7,t++,g[7]++;for(;t<=287;)s[2*t+1]=8,t++,g[8]++;for(v(s,287,g),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.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=a,0===e?t.dyn_ltree[2*a]++:(t.matches++,e--,t.dyn_ltree[2*(l[a]+256+1)]++,t.dyn_dtree[2*m(e)]++),t.sym_next===t.sym_end),_tr_align:t=>{g(t,2,3),p(t,256,s),(t=>{16===t.bi_valid?(b(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 N=(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 F=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 L=(t,e,a,i)=>{const n=F,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:J,Z_OK:W,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=>2*t-(t>4?9:0),dt=t=>{let e=t.length;for(;--e>=0;)t[e]=0},_t=t=>{let e,a,i,n=t.w_size;e=t.hash_size,i=e;do{a=t.head[--i],t.head[i]=a>=n?a-n:0}while(--e);e=n,i=e;do{a=t.prev[--i],t.prev[i]=a>=n?a-n:0}while(--e)};let ft=(t,e,a)=>(e<<t.hash_shift^a)&t.hash_mask;const ct=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))},ut=(t,e)=>{M(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,ct(t.strm)},wt=(t,e)=>{t.pending_buf[t.pending++]=e},mt=(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=N(t.adler,e,n,a):2===t.state.wrap&&(t.adler=L(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;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-262)&&(t.window.set(t.window.subarray(e,e+e-i),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),_t(t),i+=e),0===t.strm.avail_in)break;if(a=bt(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=a,t.lookahead+t.insert>=3)for(n=t.strstart-t.insert,t.ins_h=t.window[n],t.ins_h=ft(t,t.ins_h,t.window[n+1]);t.insert&&(t.ins_h=ft(t,t.ins_h,t.window[n+3-1]),t.prev[n&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=n,n++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<262&&0!==t.strm.avail_in)},kt=(t,e)=>{let a,i,n,s=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,r=0,o=t.strm.avail_in;do{if(a=65535,n=t.bi_valid+42>>3,t.strm.avail_out<n)break;if(n=t.strm.avail_out-n,i=t.strstart-t.block_start,a>i+t.strm.avail_in&&(a=i+t.strm.avail_in),a>n&&(a=n),a<s&&(0===a&&e!==X||e===P||a!==i+t.strm.avail_in))break;r=e===X&&a===i+t.strm.avail_in?1:0,H(t,0,0,r),t.pending_buf[t.pending-4]=a,t.pending_buf[t.pending-3]=a>>8,t.pending_buf[t.pending-2]=~a,t.pending_buf[t.pending-1]=~a>>8,ct(t.strm),i&&(i>a&&(i=a),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+i),t.strm.next_out),t.strm.next_out+=i,t.strm.avail_out-=i,t.strm.total_out+=i,t.block_start+=i,a-=i),a&&(bt(t.strm,t.strm.output,t.strm.next_out,a),t.strm.next_out+=a,t.strm.avail_out-=a,t.strm.total_out+=a)}while(0===r);return o-=t.strm.avail_in,o&&(o>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=o&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-o,t.strm.next_in),t.strstart),t.strstart+=o,t.insert+=o>t.w_size-t.insert?t.w_size-t.insert:o),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),r?4:e!==P&&e!==X&&0===t.strm.avail_in&&t.strstart===t.block_start?2:(n=t.window_size-t.strstart,t.strm.avail_in>n&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,n+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),n>t.strm.avail_in&&(n=t.strm.avail_in),n&&(bt(t.strm,t.window,t.strstart,n),t.strstart+=n,t.insert+=n>t.w_size-t.insert?t.w_size-t.insert:n),t.high_water<t.strstart&&(t.high_water=t.strstart),n=t.bi_valid+42>>3,n=t.pending_buf_size-n>65535?65535:t.pending_buf_size-n,s=n>t.w_size?t.w_size:n,i=t.strstart-t.block_start,(i>=s||(i||e===X)&&e!==P&&0===t.strm.avail_in&&i<=n)&&(a=i>n?n:i,r=e===X&&0===t.strm.avail_in&&a===i?1:0,H(t,t.block_start,a,r),t.block_start+=a,ct(t.strm)),r?3:1)},vt=(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=ft(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=ft(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=ft(t,t.ins_h,t.window[t.strstart+1]);else i=j(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(ut(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===X?(ut(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ut(t,!1),0===t.strm.avail_out)?1:2},yt=(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=ft(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=ft(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&&(ut(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&&ut(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?(ut(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ut(t,!1),0===t.strm.avail_out)?1:2};function xt(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 zt=[new xt(0,0,0,0,kt),new xt(4,4,8,4,vt),new xt(4,5,16,8,vt),new xt(4,6,32,32,vt),new xt(4,4,16,16,yt),new xt(8,16,32,32,yt),new xt(8,16,128,128,yt),new xt(8,32,128,256,yt),new xt(32,128,258,1024,yt),new xt(32,258,258,4096,yt)];function At(){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.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Et=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||42!==e.status&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&113!==e.status&&666!==e.status?1:0},Rt=t=>{if(Et(t))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=2===e.wrap?57:e.wrap?42:113,t.adler=2===e.wrap?0:1,e.last_flush=-2,C(e),W},Zt=t=>{const e=Rt(t);var a;return e===W&&((a=t.state).window_size=2*a.w_size,dt(a.head),a.max_lazy_match=zt[a.level].max_lazy,a.good_match=zt[a.level].good_length,a.nice_match=zt[a.level].nice_length,a.max_chain_length=zt[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},St=(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||8===i&&1!==r)return lt(t,Q);8===i&&(i=9);const o=new At;return t.state=o,o.strm=t,o.status=42,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.sym_buf=o.lit_bufsize,o.sym_end=3*(o.lit_bufsize-1),o.level=e,o.strategy=s,o.method=a,Zt(t)};var Ut={deflateInit:(t,e)=>St(t,e,ot,15,8,st),deflateInit2:St,deflateReset:Zt,deflateResetKeep:Rt,deflateSetHeader:(t,e)=>Et(t)||2!==t.state.wrap?Q:(t.state.gzhead=e,W),deflate:(t,e)=>{if(Et(t)||e>J||e<0)return t?lt(t,Q):Q;const a=t.state;if(!t.output||0!==t.avail_in&&!t.input||666===a.status&&e!==X)return lt(t,0===t.avail_out?$:Q);const i=a.last_flush;if(a.last_flush=e,0!==a.pending){if(ct(t),0===t.avail_out)return a.last_flush=-1,W}else if(0===t.avail_in&&ht(e)<=ht(i)&&e!==X)return lt(t,$);if(666===a.status&&0!==t.avail_in)return lt(t,$);if(42===a.status&&0===a.wrap&&(a.status=113),42===a.status){let e=ot+(a.w_bits-8<<4)<<8,i=-1;if(i=a.strategy>=at||a.level<2?0:a.level<6?1:6===a.level?2:3,e|=i<<6,0!==a.strstart&&(e|=32),e+=31-e%31,mt(a,e),0!==a.strstart&&(mt(a,t.adler>>>16),mt(a,65535&t.adler)),t.adler=1,a.status=113,ct(t),0!==a.pending)return a.last_flush=-1,W}if(57===a.status)if(t.adler=0,wt(a,31),wt(a,139),wt(a,8),a.gzhead)wt(a,(a.gzhead.text?1:0)+(a.gzhead.hcrc?2:0)+(a.gzhead.extra?4:0)+(a.gzhead.name?8:0)+(a.gzhead.comment?16:0)),wt(a,255&a.gzhead.time),wt(a,a.gzhead.time>>8&255),wt(a,a.gzhead.time>>16&255),wt(a,a.gzhead.time>>24&255),wt(a,9===a.level?2:a.strategy>=at||a.level<2?4:0),wt(a,255&a.gzhead.os),a.gzhead.extra&&a.gzhead.extra.length&&(wt(a,255&a.gzhead.extra.length),wt(a,a.gzhead.extra.length>>8&255)),a.gzhead.hcrc&&(t.adler=L(t.adler,a.pending_buf,a.pending,0)),a.gzindex=0,a.status=69;else if(wt(a,0),wt(a,0),wt(a,0),wt(a,0),wt(a,0),wt(a,9===a.level?2:a.strategy>=at||a.level<2?4:0),wt(a,3),a.status=113,ct(t),0!==a.pending)return a.last_flush=-1,W;if(69===a.status){if(a.gzhead.extra){let e=a.pending,i=(65535&a.gzhead.extra.length)-a.gzindex;for(;a.pending+i>a.pending_buf_size;){let n=a.pending_buf_size-a.pending;if(a.pending_buf.set(a.gzhead.extra.subarray(a.gzindex,a.gzindex+n),a.pending),a.pending=a.pending_buf_size,a.gzhead.hcrc&&a.pending>e&&(t.adler=L(t.adler,a.pending_buf,a.pending-e,e)),a.gzindex+=n,ct(t),0!==a.pending)return a.last_flush=-1,W;e=0,i-=n}let n=new Uint8Array(a.gzhead.extra);a.pending_buf.set(n.subarray(a.gzindex,a.gzindex+i),a.pending),a.pending+=i,a.gzhead.hcrc&&a.pending>e&&(t.adler=L(t.adler,a.pending_buf,a.pending-e,e)),a.gzindex=0}a.status=73}if(73===a.status){if(a.gzhead.name){let e,i=a.pending;do{if(a.pending===a.pending_buf_size){if(a.gzhead.hcrc&&a.pending>i&&(t.adler=L(t.adler,a.pending_buf,a.pending-i,i)),ct(t),0!==a.pending)return a.last_flush=-1,W;i=0}e=a.gzindex<a.gzhead.name.length?255&a.gzhead.name.charCodeAt(a.gzindex++):0,wt(a,e)}while(0!==e);a.gzhead.hcrc&&a.pending>i&&(t.adler=L(t.adler,a.pending_buf,a.pending-i,i)),a.gzindex=0}a.status=91}if(91===a.status){if(a.gzhead.comment){let e,i=a.pending;do{if(a.pending===a.pending_buf_size){if(a.gzhead.hcrc&&a.pending>i&&(t.adler=L(t.adler,a.pending_buf,a.pending-i,i)),ct(t),0!==a.pending)return a.last_flush=-1,W;i=0}e=a.gzindex<a.gzhead.comment.length?255&a.gzhead.comment.charCodeAt(a.gzindex++):0,wt(a,e)}while(0!==e);a.gzhead.hcrc&&a.pending>i&&(t.adler=L(t.adler,a.pending_buf,a.pending-i,i))}a.status=103}if(103===a.status){if(a.gzhead.hcrc){if(a.pending+2>a.pending_buf_size&&(ct(t),0!==a.pending))return a.last_flush=-1,W;wt(a,255&t.adler),wt(a,t.adler>>8&255),t.adler=0}if(a.status=113,ct(t),0!==a.pending)return a.last_flush=-1,W}if(0!==t.avail_in||0!==a.lookahead||e!==P&&666!==a.status){let i=0===a.level?kt(a,e):a.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&&(ut(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===X?(ut(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ut(t,!1),0===t.strm.avail_out)?1:2})(a,e):a.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&&(ut(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===X?(ut(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ut(t,!1),0===t.strm.avail_out)?1:2})(a,e):zt[a.level].func(a,e);if(3!==i&&4!==i||(a.status=666),1===i||3===i)return 0===t.avail_out&&(a.last_flush=-1),W;if(2===i&&(e===Y?K(a):e!==J&&(H(a,0,0,!1),e===G&&(dt(a.head),0===a.lookahead&&(a.strstart=0,a.block_start=0,a.insert=0))),ct(t),0===t.avail_out))return a.last_flush=-1,W}return e!==X?W:a.wrap<=0?q:(2===a.wrap?(wt(a,255&t.adler),wt(a,t.adler>>8&255),wt(a,t.adler>>16&255),wt(a,t.adler>>24&255),wt(a,255&t.total_in),wt(a,t.total_in>>8&255),wt(a,t.total_in>>16&255),wt(a,t.total_in>>24&255)):(mt(a,t.adler>>>16),mt(a,65535&t.adler)),ct(t),a.wrap>0&&(a.wrap=-a.wrap),0!==a.pending?W:q)},deflateEnd:t=>{if(Et(t))return Q;const e=t.state.status;return t.state=null,113===e?lt(t,V):W},deflateSetDictionary:(t,e)=>{let a=e.length;if(Et(t))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=N(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=ft(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,W},deflateInfo:"pako deflate (from Nodeca project)"};const Dt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Ot=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)Dt(a,e)&&(t[e]=a[e])}}return t},Tt=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 Nt=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Nt=!1}const Ft=new Uint8Array(256);for(let t=0;t<256;t++)Ft[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Ft[254]=Ft[254]=1;var Lt=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},It=(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=Ft[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&&Nt)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)},Bt=(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+Ft[t[a]]>e?a:e};var Ct=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 Ht=Object.prototype.toString,{Z_NO_FLUSH:Mt,Z_SYNC_FLUSH:jt,Z_FULL_FLUSH:Kt,Z_FINISH:Pt,Z_OK:Yt,Z_STREAM_END:Gt,Z_DEFAULT_COMPRESSION:Xt,Z_DEFAULT_STRATEGY:Jt,Z_DEFLATED:Wt}=B;function qt(t){this.options=Ot({level:Xt,method:Wt,chunkSize:16384,windowBits:15,memLevel:8,strategy:Jt},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 Ct,this.strm.avail_out=0;let a=Ut.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(a!==Yt)throw new Error(I[a]);if(e.header&&Ut.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Lt(e.dictionary):"[object ArrayBuffer]"===Ht.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,a=Ut.deflateSetDictionary(this.strm,t),a!==Yt)throw new Error(I[a]);this._dict_set=!0}}function Qt(t,e){const a=new qt(e);if(a.push(t,!0),a.err)throw a.msg||I[a.err];return a.result}qt.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?Pt:Mt,"string"==typeof t?a.input=Lt(t):"[object ArrayBuffer]"===Ht.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===jt||s===Kt)&&a.avail_out<=6)this.onData(a.output.subarray(0,a.next_out)),a.avail_out=0;else{if(n=Ut.deflate(a,s),n===Gt)return a.next_out>0&&this.onData(a.output.subarray(0,a.next_out)),n=Ut.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Yt;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},qt.prototype.onData=function(t){this.chunks.push(t)},qt.prototype.onEnd=function(t){t===Yt&&(this.result=Tt(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Vt={Deflate:qt,deflate:Qt,deflateRaw:function(t,e){return(e=e||{}).raw=!0,Qt(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,Qt(t,e)},constants:B};var $t=function(t,e){let a,i,n,s,r,o,l,h,d,_,f,c,u,w,m,b,g,p,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,m=(1<<E.lenbits)-1,b=(1<<E.distbits)-1;t:do{c<15&&(f+=z[a++]<<c,c+=8,f+=z[a++]<<c,c+=8),g=u[f&m];e:for(;;){if(p=g>>>24,f>>>=p,c-=p,p=g>>>16&255,0===p)A[n++]=65535&g;else{if(!(16&p)){if(0==(64&p)){g=u[(65535&g)+(f&(1<<p)-1)];continue e}if(32&p){E.mode=16191;break t}t.msg="invalid literal/length code",E.mode=16209;break t}k=65535&g,p&=15,p&&(c<p&&(f+=z[a++]<<c,c+=8),k+=f&(1<<p)-1,f>>>=p,c-=p),c<15&&(f+=z[a++]<<c,c+=8,f+=z[a++]<<c,c+=8),g=w[f&b];a:for(;;){if(p=g>>>24,f>>>=p,c-=p,p=g>>>16&255,!(16&p)){if(0==(64&p)){g=w[(65535&g)+(f&(1<<p)-1)];continue a}t.msg="invalid distance code",E.mode=16209;break t}if(v=65535&g,p&=15,c<p&&(f+=z[a++]<<c,c+=8,c<p&&(f+=z[a++]<<c,c+=8)),v+=f&(1<<p)-1,v>o){t.msg="invalid distance too far back",E.mode=16209;break t}if(f>>>=p,c-=p,p=n-s,v>p){if(p=v-p,p>h&&E.sane){t.msg="invalid distance too far back",E.mode=16209;break t}if(y=0,x=_,0===d){if(y+=l-p,p<k){k-=p;do{A[n++]=_[y++]}while(--p);y=n-v,x=A}}else if(d<p){if(y+=l+d-p,p-=d,p<k){k-=p;do{A[n++]=_[y++]}while(--p);if(y=0,d<k){p=d,k-=p;do{A[n++]=_[y++]}while(--p);y=n-v,x=A}}}else if(y+=d-p,p<k){k-=p;do{A[n++]=_[y++]}while(--p);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 te=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]),ee=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]),ae=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]),ie=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 ne=(t,e,a,i,n,s,r,o)=>{const l=o.bits;let h,d,_,f,c,u,w=0,m=0,b=0,g=0,p=0,k=0,v=0,y=0,x=0,z=0,A=null;const E=new Uint16Array(16),R=new Uint16Array(16);let Z,S,U,D=null;for(w=0;w<=15;w++)E[w]=0;for(m=0;m<i;m++)E[e[a+m]]++;for(p=l,g=15;g>=1&&0===E[g];g--);if(p>g&&(p=g),0===g)return n[s++]=20971520,n[s++]=20971520,o.bits=1,0;for(b=1;b<g&&0===E[b];b++);for(p<b&&(p=b),y=1,w=1;w<=15;w++)if(y<<=1,y-=E[w],y<0)return-1;if(y>0&&(0===t||1!==g))return-1;for(R[1]=0,w=1;w<15;w++)R[w+1]=R[w]+E[w];for(m=0;m<i;m++)0!==e[a+m]&&(r[R[e[a+m]]++]=m);if(0===t?(A=D=r,u=20):1===t?(A=te,D=ee,u=257):(A=ae,D=ie,u=0),z=0,m=0,w=b,c=s,k=p,v=0,_=-1,x=1<<p,f=x-1,1===t&&x>852||2===t&&x>592)return 1;for(;;){Z=w-v,r[m]+1<u?(S=0,U=r[m]):r[m]>=u?(S=D[r[m]-u],U=A[r[m]-u]):(S=96,U=0),h=1<<w-v,d=1<<k,b=d;do{d-=h,n[c+(z>>v)+d]=Z<<24|S<<16|U|0}while(0!==d);for(h=1<<w-1;z&h;)h>>=1;if(0!==h?(z&=h-1,z+=h):z=0,m++,0==--E[w]){if(w===g)break;w=e[a+r[m]]}if(w>p&&(z&f)!==_){for(0===v&&(v=p),c+=b,k=w-v,y=1<<k;k+v<g&&(y-=E[k+v],!(y<=0));)k++,y<<=1;if(x+=1<<k,1===t&&x>852||2===t&&x>592)return 1;_=z&f,n[_]=p<<24|k<<16|c-s|0}}return 0!==z&&(n[c+z]=w-v<<24|64<<16|0),o.bits=p,0};const{Z_FINISH:se,Z_BLOCK:re,Z_TREES:oe,Z_OK:le,Z_STREAM_END:he,Z_NEED_DICT:de,Z_STREAM_ERROR:_e,Z_DATA_ERROR:fe,Z_MEM_ERROR:ce,Z_BUF_ERROR:ue,Z_DEFLATED:we}=B,me=16209,be=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function ge(){this.strm=null,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 pe=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<16180||e.mode>16211?1:0},ke=t=>{if(pe(t))return _e;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=16180,e.last=0,e.havedict=0,e.flags=-1,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,le},ve=t=>{if(pe(t))return _e;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,ke(t)},ye=(t,e)=>{let a;if(pe(t))return _e;const i=t.state;return e<0?(a=0,e=-e):(a=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?_e:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=a,i.wbits=e,ve(t))},xe=(t,e)=>{if(!t)return _e;const a=new ge;t.state=a,a.strm=t,a.window=null,a.mode=16180;const i=ye(t,e);return i!==le&&(t.state=null),i};let ze,Ae,Ee=!0;const Re=t=>{if(Ee){ze=new Int32Array(512),Ae=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(ne(1,t.lens,0,288,ze,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;ne(2,t.lens,0,32,Ae,0,t.work,{bits:5}),Ee=!1}t.lencode=ze,t.lenbits=9,t.distcode=Ae,t.distbits=5},Ze=(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 Se={inflateReset:ve,inflateReset2:ye,inflateResetKeep:ke,inflateInit:t=>xe(t,15),inflateInit2:xe,inflate:(t,e)=>{let a,i,n,s,r,o,l,h,d,_,f,c,u,w,m,b,g,p,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(pe(t)||!t.output||!t.input&&0!==t.avail_in)return _e;a=t.state,16191===a.mode&&(a.mode=16192),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=le;t:for(;;)switch(a.mode){case 16180:if(0===a.wrap){a.mode=16192;break}for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(2&a.wrap&&35615===h){0===a.wbits&&(a.wbits=15),a.check=0,A[0]=255&h,A[1]=h>>>8&255,a.check=L(a.check,A,2,0),h=0,d=0,a.mode=16181;break}if(a.head&&(a.head.done=!1),!(1&a.wrap)||(((255&h)<<8)+(h>>8))%31){t.msg="incorrect header check",a.mode=me;break}if((15&h)!==we){t.msg="unknown compression method",a.mode=me;break}if(h>>>=4,d-=4,y=8+(15&h),0===a.wbits&&(a.wbits=y),y>15||y>a.wbits){t.msg="invalid window size",a.mode=me;break}a.dmax=1<<a.wbits,a.flags=0,t.adler=a.check=1,a.mode=512&h?16189:16191,h=0,d=0;break;case 16181:for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(a.flags=h,(255&a.flags)!==we){t.msg="unknown compression method",a.mode=me;break}if(57344&a.flags){t.msg="unknown header flags set",a.mode=me;break}a.head&&(a.head.text=h>>8&1),512&a.flags&&4&a.wrap&&(A[0]=255&h,A[1]=h>>>8&255,a.check=L(a.check,A,2,0)),h=0,d=0,a.mode=16182;case 16182:for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.head&&(a.head.time=h),512&a.flags&&4&a.wrap&&(A[0]=255&h,A[1]=h>>>8&255,A[2]=h>>>16&255,A[3]=h>>>24&255,a.check=L(a.check,A,4,0)),h=0,d=0,a.mode=16183;case 16183: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&&4&a.wrap&&(A[0]=255&h,A[1]=h>>>8&255,a.check=L(a.check,A,2,0)),h=0,d=0,a.mode=16184;case 16184: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&&4&a.wrap&&(A[0]=255&h,A[1]=h>>>8&255,a.check=L(a.check,A,2,0)),h=0,d=0}else a.head&&(a.head.extra=null);a.mode=16185;case 16185: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&&4&a.wrap&&(a.check=L(a.check,i,c,s)),o-=c,s+=c,a.length-=c),a.length))break t;a.length=0,a.mode=16186;case 16186: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&&4&a.wrap&&(a.check=L(a.check,i,c,s)),o-=c,s+=c,y)break t}else a.head&&(a.head.name=null);a.length=0,a.mode=16187;case 16187: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&&4&a.wrap&&(a.check=L(a.check,i,c,s)),o-=c,s+=c,y)break t}else a.head&&(a.head.comment=null);a.mode=16188;case 16188:if(512&a.flags){for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(4&a.wrap&&h!==(65535&a.check)){t.msg="header crc mismatch",a.mode=me;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=16191;break;case 16189:for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}t.adler=a.check=be(h),h=0,d=0,a.mode=16190;case 16190: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,de;t.adler=a.check=1,a.mode=16191;case 16191:if(e===re||e===oe)break t;case 16192:if(a.last){h>>>=7&d,d-=7&d,a.mode=16206;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=16193;break;case 1:if(Re(a),a.mode=16199,e===oe){h>>>=2,d-=2;break t}break;case 2:a.mode=16196;break;case 3:t.msg="invalid block type",a.mode=me}h>>>=2,d-=2;break;case 16193: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=me;break}if(a.length=65535&h,h=0,d=0,a.mode=16194,e===oe)break t;case 16194:a.mode=16195;case 16195: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=16191;break;case 16196: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=me;break}a.have=0,a.mode=16197;case 16197: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=ne(0,a.lens,0,19,a.lencode,0,a.work,E),a.lenbits=E.bits,x){t.msg="invalid code lengths set",a.mode=me;break}a.have=0,a.mode=16198;case 16198:for(;a.have<a.nlen+a.ndist;){for(;z=a.lencode[h&(1<<a.lenbits)-1],m=z>>>24,b=z>>>16&255,g=65535&z,!(m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(g<16)h>>>=m,d-=m,a.lens[a.have++]=g;else{if(16===g){for(R=m+2;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(h>>>=m,d-=m,0===a.have){t.msg="invalid bit length repeat",a.mode=me;break}y=a.lens[a.have-1],c=3+(3&h),h>>>=2,d-=2}else if(17===g){for(R=m+3;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=m,d-=m,y=0,c=3+(7&h),h>>>=3,d-=3}else{for(R=m+7;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=m,d-=m,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=me;break}for(;c--;)a.lens[a.have++]=y}}if(a.mode===me)break;if(0===a.lens[256]){t.msg="invalid code -- missing end-of-block",a.mode=me;break}if(a.lenbits=9,E={bits:a.lenbits},x=ne(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=me;break}if(a.distbits=6,a.distcode=a.distdyn,E={bits:a.distbits},x=ne(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=me;break}if(a.mode=16199,e===oe)break t;case 16199:a.mode=16200;case 16200: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,$t(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,16191===a.mode&&(a.back=-1);break}for(a.back=0;z=a.lencode[h&(1<<a.lenbits)-1],m=z>>>24,b=z>>>16&255,g=65535&z,!(m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(b&&0==(240&b)){for(p=m,k=b,v=g;z=a.lencode[v+((h&(1<<p+k)-1)>>p)],m=z>>>24,b=z>>>16&255,g=65535&z,!(p+m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=p,d-=p,a.back+=p}if(h>>>=m,d-=m,a.back+=m,a.length=g,0===b){a.mode=16205;break}if(32&b){a.back=-1,a.mode=16191;break}if(64&b){t.msg="invalid literal/length code",a.mode=me;break}a.extra=15&b,a.mode=16201;case 16201: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=16202;case 16202:for(;z=a.distcode[h&(1<<a.distbits)-1],m=z>>>24,b=z>>>16&255,g=65535&z,!(m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(0==(240&b)){for(p=m,k=b,v=g;z=a.distcode[v+((h&(1<<p+k)-1)>>p)],m=z>>>24,b=z>>>16&255,g=65535&z,!(p+m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=p,d-=p,a.back+=p}if(h>>>=m,d-=m,a.back+=m,64&b){t.msg="invalid distance code",a.mode=me;break}a.offset=g,a.extra=15&b,a.mode=16203;case 16203: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=me;break}a.mode=16204;case 16204: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=me;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=16200);break;case 16205:if(0===l)break t;n[r++]=a.length,l--,a.mode=16200;break;case 16206: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,4&a.wrap&&f&&(t.adler=a.check=a.flags?L(a.check,n,f,r-f):N(a.check,n,f,r-f)),f=l,4&a.wrap&&(a.flags?h:be(h))!==a.check){t.msg="incorrect data check",a.mode=me;break}h=0,d=0}a.mode=16207;case 16207:if(a.wrap&&a.flags){for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(4&a.wrap&&h!==(4294967295&a.total)){t.msg="incorrect length check",a.mode=me;break}h=0,d=0}a.mode=16208;case 16208:x=he;break t;case me:x=fe;break t;case 16210:return ce;default:return _e}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<me&&(a.mode<16206||e!==se))&&Ze(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,4&a.wrap&&f&&(t.adler=a.check=a.flags?L(a.check,n,f,t.next_out-f):N(a.check,n,f,t.next_out-f)),t.data_type=a.bits+(a.last?64:0)+(16191===a.mode?128:0)+(16199===a.mode||16194===a.mode?256:0),(0===_&&0===f||e===se)&&x===le&&(x=ue),x},inflateEnd:t=>{if(pe(t))return _e;let e=t.state;return e.window&&(e.window=null),t.state=null,le},inflateGetHeader:(t,e)=>{if(pe(t))return _e;const a=t.state;return 0==(2&a.wrap)?_e:(a.head=e,e.done=!1,le)},inflateSetDictionary:(t,e)=>{const a=e.length;let i,n,s;return pe(t)?_e:(i=t.state,0!==i.wrap&&16190!==i.mode?_e:16190===i.mode&&(n=1,n=N(n,e,a,0),n!==i.check)?fe:(s=Ze(t,e,a,a),s?(i.mode=16210,ce):(i.havedict=1,le)))},inflateInfo:"pako inflate (from Nodeca project)"};var Ue=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 De=Object.prototype.toString,{Z_NO_FLUSH:Oe,Z_FINISH:Te,Z_OK:Ne,Z_STREAM_END:Fe,Z_NEED_DICT:Le,Z_STREAM_ERROR:Ie,Z_DATA_ERROR:Be,Z_MEM_ERROR:Ce}=B;function He(t){this.options=Ot({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 Ct,this.strm.avail_out=0;let a=Se.inflateInit2(this.strm,e.windowBits);if(a!==Ne)throw new Error(I[a]);if(this.header=new Ue,Se.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Lt(e.dictionary):"[object ArrayBuffer]"===De.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(a=Se.inflateSetDictionary(this.strm,e.dictionary),a!==Ne)))throw new Error(I[a])}He.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?Te:Oe,"[object ArrayBuffer]"===De.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=Se.inflate(a,r),s===Le&&n&&(s=Se.inflateSetDictionary(a,n),s===Ne?s=Se.inflate(a,r):s===Be&&(s=Le));a.avail_in>0&&s===Fe&&a.state.wrap>0&&0!==t[a.next_in];)Se.inflateReset(a),s=Se.inflate(a,r);switch(s){case Ie:case Be:case Le:case Ce:return this.onEnd(s),this.ended=!0,!1}if(o=a.avail_out,a.next_out&&(0===a.avail_out||s===Fe))if("string"===this.options.to){let t=Bt(a.output,a.next_out),e=a.next_out-t,n=It(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!==Ne||0!==o){if(s===Fe)return s=Se.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===a.avail_in)break}}return!0},He.prototype.onData=function(t){this.chunks.push(t)},He.prototype.onEnd=function(t){t===Ne&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Tt(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};const{Deflate:Me,deflate:je,deflateRaw:Ke,gzip:Pe}=Vt;var Ye=Me,Ge=B;const Xe=new class{constructor(){this.added=0,this.init()}init(){this.added=0,this.deflate=new Ye,this.deflate.push("[",Ge.Z_NO_FLUSH)}addEvent(t){if(!t)throw new Error("Adding invalid event");const e=this.added>0?",":"";this.deflate.push(e+JSON.stringify(t),Ge.Z_SYNC_FLUSH),this.added++}finish(){if(this.deflate.push("]",Ge.Z_FINISH),this.deflate.err)throw this.deflate.err;const t=this.deflate.result;return this.init(),t}},Je={init:()=>(Xe.init(),""),addEvent:t=>Xe.addEvent(t),finish:()=>Xe.finish()};addEventListener("message",(function(t){const e=t.data.method,a=t.data.id,[i]=t.data.args?JSON.parse(t.data.args):[];if(e in Je&&"function"==typeof Je[e])try{const t=Je[e](i);postMessage({id:a,method:e,success:!0,response:t})}catch(t){postMessage({id:a,method:e,success:!1,response:t.message}),console.error(t)}})),postMessage({id:void 0,method:"init",success:!0,response:void 0});`;
|
|
3419
|
+
|
|
3374
3420
|
/**
|
|
3375
|
-
*
|
|
3421
|
+
* Create an event buffer for replays.
|
|
3376
3422
|
*/
|
|
3377
|
-
function
|
|
3378
|
-
|
|
3379
|
-
|
|
3423
|
+
function createEventBuffer({ useCompression }) {
|
|
3424
|
+
// eslint-disable-next-line no-restricted-globals
|
|
3425
|
+
if (useCompression && window.Worker) {
|
|
3426
|
+
const workerBlob = new Blob([workerString]);
|
|
3427
|
+
const workerUrl = URL.createObjectURL(workerBlob);
|
|
3428
|
+
|
|
3429
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.log('[Replay] Using compression worker');
|
|
3430
|
+
const worker = new Worker(workerUrl);
|
|
3431
|
+
return new EventBufferProxy(worker);
|
|
3380
3432
|
}
|
|
3381
3433
|
|
|
3382
|
-
|
|
3434
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.log('[Replay] Using simple buffer');
|
|
3435
|
+
return new EventBufferArray();
|
|
3383
3436
|
}
|
|
3384
3437
|
|
|
3385
3438
|
/**
|
|
3386
|
-
*
|
|
3439
|
+
* This proxy will try to use the compression worker, and fall back to use the simple buffer if an error occurs there.
|
|
3440
|
+
* This can happen e.g. if the worker cannot be loaded.
|
|
3441
|
+
* Exported only for testing.
|
|
3387
3442
|
*/
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
)
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3443
|
+
class EventBufferProxy {
|
|
3444
|
+
|
|
3445
|
+
constructor(worker) {
|
|
3446
|
+
this._fallback = new EventBufferArray();
|
|
3447
|
+
this._compression = new EventBufferCompressionWorker(worker);
|
|
3448
|
+
this._used = this._fallback;
|
|
3449
|
+
|
|
3450
|
+
void this._ensureWorkerIsLoaded();
|
|
3396
3451
|
}
|
|
3397
3452
|
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
return
|
|
3453
|
+
/** @inheritDoc */
|
|
3454
|
+
get pendingLength() {
|
|
3455
|
+
return this._used.pendingLength;
|
|
3401
3456
|
}
|
|
3402
3457
|
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3458
|
+
/** @inheritDoc */
|
|
3459
|
+
get pendingEvents() {
|
|
3460
|
+
return this._used.pendingEvents;
|
|
3461
|
+
}
|
|
3407
3462
|
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
if (timestampInMs + SESSION_IDLE_DURATION < new Date().getTime()) {
|
|
3413
|
-
return null;
|
|
3463
|
+
/** @inheritDoc */
|
|
3464
|
+
destroy() {
|
|
3465
|
+
this._fallback.destroy();
|
|
3466
|
+
this._compression.destroy();
|
|
3414
3467
|
}
|
|
3415
3468
|
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3469
|
+
/**
|
|
3470
|
+
* Add an event to the event buffer.
|
|
3471
|
+
*
|
|
3472
|
+
* Returns true if event was successfully added.
|
|
3473
|
+
*/
|
|
3474
|
+
addEvent(event, isCheckout) {
|
|
3475
|
+
return this._used.addEvent(event, isCheckout);
|
|
3421
3476
|
}
|
|
3422
3477
|
|
|
3423
|
-
|
|
3424
|
-
|
|
3478
|
+
/** @inheritDoc */
|
|
3479
|
+
finish() {
|
|
3480
|
+
return this._used.finish();
|
|
3481
|
+
}
|
|
3425
3482
|
|
|
3426
|
-
/**
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
timestamp: start,
|
|
3437
|
-
data: {
|
|
3438
|
-
tag: 'performanceSpan',
|
|
3439
|
-
payload: {
|
|
3440
|
-
op: type,
|
|
3441
|
-
description: name,
|
|
3442
|
-
startTimestamp: start,
|
|
3443
|
-
endTimestamp: end,
|
|
3444
|
-
data,
|
|
3445
|
-
},
|
|
3446
|
-
},
|
|
3447
|
-
}),
|
|
3448
|
-
);
|
|
3449
|
-
}
|
|
3483
|
+
/** Ensure the worker has loaded. */
|
|
3484
|
+
async _ensureWorkerIsLoaded() {
|
|
3485
|
+
try {
|
|
3486
|
+
await this._compression.ensureReady();
|
|
3487
|
+
} catch (error) {
|
|
3488
|
+
// If the worker fails to load, we fall back to the simple buffer.
|
|
3489
|
+
// Nothing more to do from our side here
|
|
3490
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.log('[Replay] Failed to load the compression worker, falling back to simple buffer');
|
|
3491
|
+
return;
|
|
3492
|
+
}
|
|
3450
3493
|
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
return false;
|
|
3458
|
-
}
|
|
3494
|
+
// Compression worker is ready, we can use it
|
|
3495
|
+
// Now we need to switch over the array buffer to the compression worker
|
|
3496
|
+
const addEventPromises = [];
|
|
3497
|
+
for (const event of this._fallback.pendingEvents) {
|
|
3498
|
+
addEventPromises.push(this._compression.addEvent(event));
|
|
3499
|
+
}
|
|
3459
3500
|
|
|
3460
|
-
|
|
3461
|
-
|
|
3501
|
+
// We switch over to the compression buffer immediately - any further events will be added
|
|
3502
|
+
// after the previously buffered ones
|
|
3503
|
+
this._used = this._compression;
|
|
3462
3504
|
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
function _isSentryRequest(url) {
|
|
3467
|
-
const client = core.getCurrentHub().getClient();
|
|
3468
|
-
const dsn = client && client.getDsn();
|
|
3469
|
-
return dsn ? url.includes(dsn.host) : false;
|
|
3505
|
+
// Wait for original events to be re-added before resolving
|
|
3506
|
+
await Promise.all(addEventPromises);
|
|
3507
|
+
}
|
|
3470
3508
|
}
|
|
3471
3509
|
|
|
3472
|
-
|
|
3473
|
-
function handleFetch(handlerData) {
|
|
3474
|
-
if (!handlerData.endTimestamp) {
|
|
3475
|
-
return null;
|
|
3476
|
-
}
|
|
3510
|
+
class EventBufferArray {
|
|
3477
3511
|
|
|
3478
|
-
|
|
3512
|
+
constructor() {
|
|
3513
|
+
this._events = [];
|
|
3514
|
+
}
|
|
3479
3515
|
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
end: endTimestamp / 1000,
|
|
3484
|
-
name: fetchData.url,
|
|
3485
|
-
data: {
|
|
3486
|
-
method: fetchData.method,
|
|
3487
|
-
statusCode: response.status,
|
|
3488
|
-
},
|
|
3489
|
-
};
|
|
3490
|
-
}
|
|
3516
|
+
get pendingLength() {
|
|
3517
|
+
return this._events.length;
|
|
3518
|
+
}
|
|
3491
3519
|
|
|
3492
|
-
/**
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
}
|
|
3520
|
+
/**
|
|
3521
|
+
* Returns the raw events that are buffered. In `EventBufferArray`, this is the
|
|
3522
|
+
* same as `this._events`.
|
|
3523
|
+
*/
|
|
3524
|
+
get pendingEvents() {
|
|
3525
|
+
return this._events;
|
|
3526
|
+
}
|
|
3500
3527
|
|
|
3501
|
-
|
|
3528
|
+
destroy() {
|
|
3529
|
+
this._events = [];
|
|
3530
|
+
}
|
|
3502
3531
|
|
|
3503
|
-
|
|
3532
|
+
async addEvent(event, isCheckout) {
|
|
3533
|
+
if (isCheckout) {
|
|
3534
|
+
this._events = [event];
|
|
3504
3535
|
return;
|
|
3505
3536
|
}
|
|
3506
3537
|
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3538
|
+
this._events.push(event);
|
|
3539
|
+
return;
|
|
3540
|
+
}
|
|
3510
3541
|
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
//
|
|
3514
|
-
//
|
|
3515
|
-
//
|
|
3516
|
-
|
|
3542
|
+
finish() {
|
|
3543
|
+
return new Promise(resolve => {
|
|
3544
|
+
// Make a copy of the events array reference and immediately clear the
|
|
3545
|
+
// events member so that we do not lose new events while uploading
|
|
3546
|
+
// attachment.
|
|
3547
|
+
const eventsRet = this._events;
|
|
3548
|
+
this._events = [];
|
|
3549
|
+
resolve(JSON.stringify(eventsRet));
|
|
3517
3550
|
});
|
|
3518
|
-
};
|
|
3519
|
-
}
|
|
3520
|
-
|
|
3521
|
-
/**
|
|
3522
|
-
* Returns true if we think the given event is an error originating inside of rrweb.
|
|
3523
|
-
*/
|
|
3524
|
-
function isRrwebError(event) {
|
|
3525
|
-
if (event.type || !event.exception || !event.exception.values || !event.exception.values.length) {
|
|
3526
|
-
return false;
|
|
3527
3551
|
}
|
|
3528
|
-
|
|
3529
|
-
// Check if any exception originates from rrweb
|
|
3530
|
-
return event.exception.values.some(exception => {
|
|
3531
|
-
if (!exception.stacktrace || !exception.stacktrace.frames || !exception.stacktrace.frames.length) {
|
|
3532
|
-
return false;
|
|
3533
|
-
}
|
|
3534
|
-
|
|
3535
|
-
return exception.stacktrace.frames.some(frame => frame.filename && frame.filename.includes('/rrweb/src/'));
|
|
3536
|
-
});
|
|
3537
3552
|
}
|
|
3538
3553
|
|
|
3539
3554
|
/**
|
|
3540
|
-
*
|
|
3555
|
+
* Event buffer that uses a web worker to compress events.
|
|
3556
|
+
* Exported only for testing.
|
|
3541
3557
|
*/
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
return event;
|
|
3550
|
-
}
|
|
3551
|
-
|
|
3552
|
-
// Unless `captureExceptions` is enabled, we want to ignore errors coming from rrweb
|
|
3553
|
-
// As there can be a bunch of stuff going wrong in internals there, that we don't want to bubble up to users
|
|
3554
|
-
if (isRrwebError(event) && !replay.getOptions()._experiments.captureExceptions) {
|
|
3555
|
-
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.log('[Replay] Ignoring error from rrweb internals', event);
|
|
3556
|
-
return null;
|
|
3557
|
-
}
|
|
3558
|
-
|
|
3559
|
-
// Only tag transactions with replayId if not waiting for an error
|
|
3560
|
-
// @ts-ignore private
|
|
3561
|
-
if (!event.type || replay.recordingMode === 'session') {
|
|
3562
|
-
event.tags = { ...event.tags, replayId: replay.getSessionId() };
|
|
3563
|
-
}
|
|
3564
|
-
|
|
3565
|
-
// Collect traceIds in _context regardless of `recordingMode` - if it's true,
|
|
3566
|
-
// _context gets cleared on every checkout
|
|
3567
|
-
if (event.type === 'transaction' && event.contexts && event.contexts.trace && event.contexts.trace.trace_id) {
|
|
3568
|
-
replay.getContext().traceIds.add(event.contexts.trace.trace_id );
|
|
3569
|
-
return event;
|
|
3570
|
-
}
|
|
3571
|
-
|
|
3572
|
-
// no event type means error
|
|
3573
|
-
if (!event.type) {
|
|
3574
|
-
replay.getContext().errorIds.add(event.event_id );
|
|
3575
|
-
}
|
|
3576
|
-
|
|
3577
|
-
if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && replay.getOptions()._experiments.traceInternals) {
|
|
3578
|
-
const exc = getEventExceptionValues(event);
|
|
3579
|
-
addInternalBreadcrumb({
|
|
3580
|
-
message: `Tagging event (${event.event_id}) - ${event.message} - ${exc.type}: ${exc.value}`,
|
|
3581
|
-
});
|
|
3582
|
-
}
|
|
3583
|
-
|
|
3584
|
-
// Need to be very careful that this does not cause an infinite loop
|
|
3585
|
-
if (
|
|
3586
|
-
replay.recordingMode === 'error' &&
|
|
3587
|
-
event.exception &&
|
|
3588
|
-
event.message !== UNABLE_TO_SEND_REPLAY // ignore this error because otherwise we could loop indefinitely with trying to capture replay and failing
|
|
3589
|
-
) {
|
|
3590
|
-
setTimeout(async () => {
|
|
3591
|
-
// Allow flush to complete before resuming as a session recording, otherwise
|
|
3592
|
-
// the checkout from `startRecording` may be included in the payload.
|
|
3593
|
-
// Prefer to keep the error replay as a separate (and smaller) segment
|
|
3594
|
-
// than the session replay.
|
|
3595
|
-
await replay.flushImmediate();
|
|
3596
|
-
|
|
3597
|
-
if (replay.stopRecording()) {
|
|
3598
|
-
// Reset all "capture on error" configuration before
|
|
3599
|
-
// starting a new recording
|
|
3600
|
-
replay.recordingMode = 'session';
|
|
3601
|
-
replay.startRecording();
|
|
3602
|
-
}
|
|
3603
|
-
});
|
|
3604
|
-
}
|
|
3558
|
+
class EventBufferCompressionWorker {
|
|
3559
|
+
/**
|
|
3560
|
+
* Keeps track of the list of events since the last flush that have not been compressed.
|
|
3561
|
+
* For example, page is reloaded and a flush attempt is made, but
|
|
3562
|
+
* `finish()` (and thus the flush), does not complete.
|
|
3563
|
+
*/
|
|
3564
|
+
__init() {this._pendingEvents = [];}
|
|
3605
3565
|
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
}
|
|
3566
|
+
__init2() {this._eventBufferItemLength = 0;}
|
|
3567
|
+
__init3() {this._id = 0;}
|
|
3609
3568
|
|
|
3610
|
-
|
|
3611
|
-
|
|
3569
|
+
constructor(worker) {EventBufferCompressionWorker.prototype.__init.call(this);EventBufferCompressionWorker.prototype.__init2.call(this);EventBufferCompressionWorker.prototype.__init3.call(this);
|
|
3570
|
+
this._worker = worker;
|
|
3571
|
+
}
|
|
3612
3572
|
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3573
|
+
/**
|
|
3574
|
+
* The number of raw events that are buffered. This may not be the same as
|
|
3575
|
+
* the number of events that have been compresed in the worker because
|
|
3576
|
+
* `addEvent` is async.
|
|
3577
|
+
*/
|
|
3578
|
+
get pendingLength() {
|
|
3579
|
+
return this._eventBufferItemLength;
|
|
3580
|
+
}
|
|
3620
3581
|
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
}
|
|
3627
|
-
}
|
|
3582
|
+
/**
|
|
3583
|
+
* Returns a list of the raw recording events that are being compressed.
|
|
3584
|
+
*/
|
|
3585
|
+
get pendingEvents() {
|
|
3586
|
+
return this._pendingEvents;
|
|
3587
|
+
}
|
|
3628
3588
|
|
|
3629
|
-
|
|
3630
|
-
|
|
3589
|
+
/**
|
|
3590
|
+
* Ensure the worker is ready (or not).
|
|
3591
|
+
* This will either resolve when the worker is ready, or reject if an error occured.
|
|
3592
|
+
*/
|
|
3593
|
+
ensureReady() {
|
|
3594
|
+
return new Promise((resolve, reject) => {
|
|
3595
|
+
this._worker.addEventListener(
|
|
3596
|
+
'message',
|
|
3597
|
+
({ data }) => {
|
|
3598
|
+
if (data.success) {
|
|
3599
|
+
resolve();
|
|
3600
|
+
} else {
|
|
3601
|
+
reject();
|
|
3602
|
+
}
|
|
3603
|
+
},
|
|
3604
|
+
{ once: true },
|
|
3605
|
+
);
|
|
3631
3606
|
|
|
3632
|
-
|
|
3607
|
+
this._worker.addEventListener(
|
|
3608
|
+
'error',
|
|
3609
|
+
error => {
|
|
3610
|
+
reject(error);
|
|
3611
|
+
},
|
|
3612
|
+
{ once: true },
|
|
3613
|
+
);
|
|
3614
|
+
});
|
|
3615
|
+
}
|
|
3633
3616
|
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
},
|
|
3642
|
-
};
|
|
3643
|
-
}
|
|
3617
|
+
/**
|
|
3618
|
+
* Destroy the event buffer.
|
|
3619
|
+
*/
|
|
3620
|
+
destroy() {
|
|
3621
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.log('[Replay] Destroying compression worker');
|
|
3622
|
+
this._worker.terminate();
|
|
3623
|
+
}
|
|
3644
3624
|
|
|
3645
|
-
/**
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3625
|
+
/**
|
|
3626
|
+
* Add an event to the event buffer.
|
|
3627
|
+
*
|
|
3628
|
+
* Returns true if event was successfuly received and processed by worker.
|
|
3629
|
+
*/
|
|
3630
|
+
async addEvent(event, isCheckout) {
|
|
3631
|
+
if (isCheckout) {
|
|
3632
|
+
// This event is a checkout, make sure worker buffer is cleared before
|
|
3633
|
+
// proceeding.
|
|
3634
|
+
await this._postMessage({
|
|
3635
|
+
id: this._getAndIncrementId(),
|
|
3636
|
+
method: 'init',
|
|
3637
|
+
args: [],
|
|
3638
|
+
});
|
|
3652
3639
|
}
|
|
3653
3640
|
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
return;
|
|
3641
|
+
// Don't store checkout events in `_pendingEvents` because they are too large
|
|
3642
|
+
if (!isCheckout) {
|
|
3643
|
+
this._pendingEvents.push(event);
|
|
3658
3644
|
}
|
|
3659
3645
|
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
replay.triggerUserActivity();
|
|
3646
|
+
return this._sendEventToWorker(event);
|
|
3647
|
+
}
|
|
3663
3648
|
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
}
|
|
3670
|
-
}
|
|
3649
|
+
/**
|
|
3650
|
+
* Finish the event buffer and return the compressed data.
|
|
3651
|
+
*/
|
|
3652
|
+
finish() {
|
|
3653
|
+
return this._finishRequest(this._getAndIncrementId());
|
|
3654
|
+
}
|
|
3671
3655
|
|
|
3672
|
-
|
|
3673
|
-
|
|
3656
|
+
/**
|
|
3657
|
+
* Post message to worker and wait for response before resolving promise.
|
|
3658
|
+
*/
|
|
3659
|
+
_postMessage({ id, method, args }) {
|
|
3660
|
+
return new Promise((resolve, reject) => {
|
|
3661
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
3662
|
+
const listener = ({ data }) => {
|
|
3663
|
+
if (data.method !== method) {
|
|
3664
|
+
return;
|
|
3665
|
+
}
|
|
3674
3666
|
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
}
|
|
3667
|
+
// There can be multiple listeners for a single method, the id ensures
|
|
3668
|
+
// that the response matches the caller.
|
|
3669
|
+
if (data.id !== id) {
|
|
3670
|
+
return;
|
|
3671
|
+
}
|
|
3681
3672
|
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
handlerData.xhr.__sentry_xhr__ = handlerData.xhr.__sentry_xhr__ || {};
|
|
3685
|
-
handlerData.xhr.__sentry_xhr__.startTimestamp = handlerData.startTimestamp;
|
|
3686
|
-
}
|
|
3673
|
+
// At this point, we'll always want to remove listener regardless of result status
|
|
3674
|
+
this._worker.removeEventListener('message', listener);
|
|
3687
3675
|
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3676
|
+
if (!data.success) {
|
|
3677
|
+
// TODO: Do some error handling, not sure what
|
|
3678
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.error('[Replay]', data.response);
|
|
3691
3679
|
|
|
3692
|
-
|
|
3680
|
+
reject(new Error('Error in compression worker'));
|
|
3681
|
+
return;
|
|
3682
|
+
}
|
|
3693
3683
|
|
|
3694
|
-
|
|
3695
|
-
|
|
3684
|
+
resolve(data.response);
|
|
3685
|
+
};
|
|
3686
|
+
|
|
3687
|
+
let stringifiedArgs;
|
|
3688
|
+
try {
|
|
3689
|
+
stringifiedArgs = JSON.stringify(args);
|
|
3690
|
+
} catch (err) {
|
|
3691
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.error('[Replay] Error when trying to stringify args', err);
|
|
3692
|
+
stringifiedArgs = '[]';
|
|
3693
|
+
}
|
|
3694
|
+
|
|
3695
|
+
// Note: we can't use `once` option because it's possible it needs to
|
|
3696
|
+
// listen to multiple messages
|
|
3697
|
+
this._worker.addEventListener('message', listener);
|
|
3698
|
+
this._worker.postMessage({ id, method, args: stringifiedArgs });
|
|
3699
|
+
});
|
|
3696
3700
|
}
|
|
3697
3701
|
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3702
|
+
/**
|
|
3703
|
+
* Send the event to the worker.
|
|
3704
|
+
*/
|
|
3705
|
+
async _sendEventToWorker(event) {
|
|
3706
|
+
const promise = this._postMessage({
|
|
3707
|
+
id: this._getAndIncrementId(),
|
|
3708
|
+
method: 'addEvent',
|
|
3709
|
+
args: [event],
|
|
3710
|
+
});
|
|
3701
3711
|
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
name: url,
|
|
3705
|
-
start: timestamp / 1000,
|
|
3706
|
-
end: handlerData.endTimestamp / 1000,
|
|
3707
|
-
data: {
|
|
3708
|
-
method,
|
|
3709
|
-
statusCode,
|
|
3710
|
-
},
|
|
3711
|
-
};
|
|
3712
|
-
}
|
|
3712
|
+
// XXX: See note in `get length()`
|
|
3713
|
+
this._eventBufferItemLength++;
|
|
3713
3714
|
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
*/
|
|
3717
|
-
function handleXhrSpanListener(replay) {
|
|
3718
|
-
return (handlerData) => {
|
|
3719
|
-
if (!replay.isEnabled()) {
|
|
3720
|
-
return;
|
|
3721
|
-
}
|
|
3715
|
+
return promise;
|
|
3716
|
+
}
|
|
3722
3717
|
|
|
3723
|
-
|
|
3718
|
+
/**
|
|
3719
|
+
* Finish the request and return the compressed data from the worker.
|
|
3720
|
+
*/
|
|
3721
|
+
async _finishRequest(id) {
|
|
3722
|
+
const promise = this._postMessage({ id, method: 'finish', args: [] });
|
|
3724
3723
|
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
}
|
|
3724
|
+
// XXX: See note in `get length()`
|
|
3725
|
+
this._eventBufferItemLength = 0;
|
|
3728
3726
|
|
|
3729
|
-
|
|
3730
|
-
return;
|
|
3731
|
-
}
|
|
3727
|
+
await promise;
|
|
3732
3728
|
|
|
3733
|
-
|
|
3734
|
-
createPerformanceSpans(replay, [result]);
|
|
3735
|
-
// Returning true will cause `addUpdate` to not flush
|
|
3736
|
-
// We do not want network requests to cause a flush. This will prevent
|
|
3737
|
-
// recurring/polling requests from keeping the replay session alive.
|
|
3738
|
-
return true;
|
|
3739
|
-
});
|
|
3740
|
-
};
|
|
3741
|
-
}
|
|
3729
|
+
this._pendingEvents = [];
|
|
3742
3730
|
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
'type',
|
|
3746
|
-
'startTime',
|
|
3747
|
-
'transferSize',
|
|
3748
|
-
'duration',
|
|
3749
|
-
];
|
|
3731
|
+
return promise;
|
|
3732
|
+
}
|
|
3750
3733
|
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
return
|
|
3754
|
-
}
|
|
3734
|
+
/** Get the current ID and increment it for the next call. */
|
|
3735
|
+
_getAndIncrementId() {
|
|
3736
|
+
return this._id++;
|
|
3737
|
+
}
|
|
3755
3738
|
}
|
|
3756
3739
|
|
|
3757
3740
|
/**
|
|
3758
|
-
*
|
|
3759
|
-
*
|
|
3760
|
-
* - duplicate entries have duration = 0
|
|
3761
|
-
* - duplicate entries are the same object reference
|
|
3762
|
-
* - none of the above
|
|
3763
|
-
*
|
|
3764
|
-
* Compare the values of several keys to determine if the entries are duplicates or not.
|
|
3741
|
+
* Given an initial timestamp and an expiry duration, checks to see if current
|
|
3742
|
+
* time should be considered as expired.
|
|
3765
3743
|
*/
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
newList,
|
|
3744
|
+
function isExpired(
|
|
3745
|
+
initialTime,
|
|
3746
|
+
expiry,
|
|
3747
|
+
targetTime = +new Date(),
|
|
3771
3748
|
) {
|
|
3772
|
-
//
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
acc[0].push(entry );
|
|
3777
|
-
} else if (entry.entryType === 'largest-contentful-paint') {
|
|
3778
|
-
acc[1].push(entry );
|
|
3779
|
-
} else {
|
|
3780
|
-
acc[2].push(entry);
|
|
3781
|
-
}
|
|
3782
|
-
return acc;
|
|
3783
|
-
},
|
|
3784
|
-
[[], [], []],
|
|
3785
|
-
);
|
|
3749
|
+
// Always expired if < 0
|
|
3750
|
+
if (initialTime === null || expiry === undefined || expiry < 0) {
|
|
3751
|
+
return true;
|
|
3752
|
+
}
|
|
3786
3753
|
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
: undefined;
|
|
3754
|
+
// Never expires if == 0
|
|
3755
|
+
if (expiry === 0) {
|
|
3756
|
+
return false;
|
|
3757
|
+
}
|
|
3792
3758
|
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
// We want the latest LCP event only
|
|
3796
|
-
if (!newLcpEntry || newLcpEntry.startTime < entry.startTime) {
|
|
3797
|
-
newLcpEntry = entry;
|
|
3798
|
-
}
|
|
3799
|
-
return;
|
|
3800
|
-
}
|
|
3759
|
+
return initialTime + expiry <= targetTime;
|
|
3760
|
+
}
|
|
3801
3761
|
|
|
3802
|
-
|
|
3803
|
-
|
|
3762
|
+
/**
|
|
3763
|
+
* Checks to see if session is expired
|
|
3764
|
+
*/
|
|
3765
|
+
function isSessionExpired(session, idleTimeout, targetTime = +new Date()) {
|
|
3766
|
+
return (
|
|
3767
|
+
// First, check that maximum session length has not been exceeded
|
|
3768
|
+
isExpired(session.started, MAX_SESSION_LIFE, targetTime) ||
|
|
3769
|
+
// check that the idle timeout has not been exceeded (i.e. user has
|
|
3770
|
+
// performed an action within the last `idleTimeout` ms)
|
|
3771
|
+
isExpired(session.lastActivity, idleTimeout, targetTime)
|
|
3772
|
+
);
|
|
3773
|
+
}
|
|
3804
3774
|
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
) {
|
|
3814
|
-
newNavigationEntries.push(navigationEntry);
|
|
3815
|
-
}
|
|
3775
|
+
/**
|
|
3776
|
+
* Save a session to session storage.
|
|
3777
|
+
*/
|
|
3778
|
+
function saveSession(session) {
|
|
3779
|
+
const hasSessionStorage = 'sessionStorage' in WINDOW;
|
|
3780
|
+
if (!hasSessionStorage) {
|
|
3781
|
+
return;
|
|
3782
|
+
}
|
|
3816
3783
|
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3784
|
+
try {
|
|
3785
|
+
WINDOW.sessionStorage.setItem(REPLAY_SESSION_KEY, JSON.stringify(session));
|
|
3786
|
+
} catch (e) {
|
|
3787
|
+
// Ignore potential SecurityError exceptions
|
|
3788
|
+
}
|
|
3789
|
+
}
|
|
3820
3790
|
|
|
3821
|
-
|
|
3822
|
-
|
|
3791
|
+
/**
|
|
3792
|
+
* Given a sample rate, returns true if replay should be sampled.
|
|
3793
|
+
*
|
|
3794
|
+
* 1.0 = 100% sampling
|
|
3795
|
+
* 0.0 = 0% sampling
|
|
3796
|
+
*/
|
|
3797
|
+
function isSampled(sampleRate) {
|
|
3798
|
+
if (sampleRate === undefined) {
|
|
3799
|
+
return false;
|
|
3800
|
+
}
|
|
3823
3801
|
|
|
3824
|
-
//
|
|
3825
|
-
return
|
|
3826
|
-
...(newLcpEntry ? [newLcpEntry] : []),
|
|
3827
|
-
...existingNavigationEntries,
|
|
3828
|
-
...existingEntries,
|
|
3829
|
-
...newEntries,
|
|
3830
|
-
...newNavigationEntries,
|
|
3831
|
-
].sort((a, b) => a.startTime - b.startTime);
|
|
3802
|
+
// Math.random() returns a number in range of 0 to 1 (inclusive of 0, but not 1)
|
|
3803
|
+
return Math.random() < sampleRate;
|
|
3832
3804
|
}
|
|
3833
3805
|
|
|
3834
3806
|
/**
|
|
3835
|
-
*
|
|
3807
|
+
* Get a session with defaults & applied sampling.
|
|
3836
3808
|
*/
|
|
3837
|
-
function
|
|
3838
|
-
const
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3809
|
+
function makeSession(session) {
|
|
3810
|
+
const now = new Date().getTime();
|
|
3811
|
+
const id = session.id || utils.uuid4();
|
|
3812
|
+
// Note that this means we cannot set a started/lastActivity of `0`, but this should not be relevant outside of tests.
|
|
3813
|
+
const started = session.started || now;
|
|
3814
|
+
const lastActivity = session.lastActivity || now;
|
|
3815
|
+
const segmentId = session.segmentId || 0;
|
|
3816
|
+
const sampled = session.sampled;
|
|
3817
|
+
|
|
3818
|
+
return {
|
|
3819
|
+
id,
|
|
3820
|
+
started,
|
|
3821
|
+
lastActivity,
|
|
3822
|
+
segmentId,
|
|
3823
|
+
sampled,
|
|
3846
3824
|
};
|
|
3825
|
+
}
|
|
3847
3826
|
|
|
3848
|
-
|
|
3827
|
+
/**
|
|
3828
|
+
* Get the sampled status for a session based on sample rates & current sampled status.
|
|
3829
|
+
*/
|
|
3830
|
+
function getSessionSampleType(sessionSampleRate, errorSampleRate) {
|
|
3831
|
+
return isSampled(sessionSampleRate) ? 'session' : isSampled(errorSampleRate) ? 'error' : false;
|
|
3832
|
+
}
|
|
3849
3833
|
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
'resource',
|
|
3860
|
-
].forEach(type => {
|
|
3861
|
-
try {
|
|
3862
|
-
performanceObserver.observe({
|
|
3863
|
-
type,
|
|
3864
|
-
buffered: true,
|
|
3865
|
-
});
|
|
3866
|
-
} catch (e) {
|
|
3867
|
-
// This can throw if an entry type is not supported in the browser.
|
|
3868
|
-
// Ignore these errors.
|
|
3869
|
-
}
|
|
3834
|
+
/**
|
|
3835
|
+
* Create a new session, which in its current implementation is a Sentry event
|
|
3836
|
+
* that all replays will be saved to as attachments. Currently, we only expect
|
|
3837
|
+
* one of these Sentry events per "replay session".
|
|
3838
|
+
*/
|
|
3839
|
+
function createSession({ sessionSampleRate, errorSampleRate, stickySession = false }) {
|
|
3840
|
+
const sampled = getSessionSampleType(sessionSampleRate, errorSampleRate);
|
|
3841
|
+
const session = makeSession({
|
|
3842
|
+
sampled,
|
|
3870
3843
|
});
|
|
3871
3844
|
|
|
3872
|
-
|
|
3873
|
-
}
|
|
3845
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.log(`[Replay] Creating new session: ${session.id}`);
|
|
3874
3846
|
|
|
3875
|
-
|
|
3876
|
-
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 m=t=>t<256?o[t]:o[256+(t>>>7)],b=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},g=(t,e,a)=>{t.bi_valid>16-a?(t.bi_buf|=e<<t.bi_valid&65535,b(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)},p=(t,e,a)=>{g(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++)r=r+a[n-1]<<1,i[n]=r;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.sym_next=t.matches=0},x=t=>{t.bi_valid>8?b(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.sym_next)do{s=255&t.pending_buf[t.sym_buf+f++],s+=(255&t.pending_buf[t.sym_buf+f++])<<8,r=t.pending_buf[t.sym_buf+f++],0===s?p(t,r,i):(o=l[r],p(t,o+256+1,i),_=e[o],0!==_&&(r-=h[o],g(t,r,_)),s--,o=m(s),p(t,o,n),_=a[o],0!==_&&(s-=d[o],g(t,s,_)))}while(f<t.sym_next);p(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{p(t,n,t.bl_tree)}while(0!=--o);else 0!==n?(n!==s&&(p(t,n,t.bl_tree),o--),p(t,16,t.bl_tree),g(t,o-3,2)):o<=10?(p(t,17,t.bl_tree),g(t,o-3,3)):(p(t,18,t.bl_tree),g(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)=>{g(t,0+(i?1:0),3),x(t),b(t,a),b(t,~a),a&&t.pending_buf.set(t.window.subarray(e,e+a),t.pending),t.pending+=a};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?(g(t,2+(i?1:0),3),E(t,s,r)):(g(t,4+(i?1:0),3),((t,e,a,i)=>{let s;for(g(t,e-257,5),g(t,a-1,5),g(t,i-4,4),s=0;s<i;s++)g(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,m,b;const g=new Array(16);for(w=0,m=0;m<28;m++)for(h[m]=w,t=0;t<1<<e[m];t++)l[w++]=m;for(l[w-1]=m,b=0,m=0;m<16;m++)for(d[m]=b,t=0;t<1<<a[m];t++)o[b++]=m;for(b>>=7;m<30;m++)for(d[m]=b<<7,t=0;t<1<<a[m]-7;t++)o[256+b++]=m;for(n=0;n<=15;n++)g[n]=0;for(t=0;t<=143;)s[2*t+1]=8,t++,g[8]++;for(;t<=255;)s[2*t+1]=9,t++,g[9]++;for(;t<=279;)s[2*t+1]=7,t++,g[7]++;for(;t<=287;)s[2*t+1]=8,t++,g[8]++;for(v(s,287,g),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.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=a,0===e?t.dyn_ltree[2*a]++:(t.matches++,e--,t.dyn_ltree[2*(l[a]+256+1)]++,t.dyn_dtree[2*m(e)]++),t.sym_next===t.sym_end),_tr_align:t=>{g(t,2,3),p(t,256,s),(t=>{16===t.bi_valid?(b(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 N=(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 F=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 L=(t,e,a,i)=>{const n=F,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:J,Z_OK:W,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=>2*t-(t>4?9:0),dt=t=>{let e=t.length;for(;--e>=0;)t[e]=0},_t=t=>{let e,a,i,n=t.w_size;e=t.hash_size,i=e;do{a=t.head[--i],t.head[i]=a>=n?a-n:0}while(--e);e=n,i=e;do{a=t.prev[--i],t.prev[i]=a>=n?a-n:0}while(--e)};let ft=(t,e,a)=>(e<<t.hash_shift^a)&t.hash_mask;const ct=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))},ut=(t,e)=>{M(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,ct(t.strm)},wt=(t,e)=>{t.pending_buf[t.pending++]=e},mt=(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=N(t.adler,e,n,a):2===t.state.wrap&&(t.adler=L(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;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-262)&&(t.window.set(t.window.subarray(e,e+e-i),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),_t(t),i+=e),0===t.strm.avail_in)break;if(a=bt(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=a,t.lookahead+t.insert>=3)for(n=t.strstart-t.insert,t.ins_h=t.window[n],t.ins_h=ft(t,t.ins_h,t.window[n+1]);t.insert&&(t.ins_h=ft(t,t.ins_h,t.window[n+3-1]),t.prev[n&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=n,n++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<262&&0!==t.strm.avail_in)},kt=(t,e)=>{let a,i,n,s=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,r=0,o=t.strm.avail_in;do{if(a=65535,n=t.bi_valid+42>>3,t.strm.avail_out<n)break;if(n=t.strm.avail_out-n,i=t.strstart-t.block_start,a>i+t.strm.avail_in&&(a=i+t.strm.avail_in),a>n&&(a=n),a<s&&(0===a&&e!==X||e===P||a!==i+t.strm.avail_in))break;r=e===X&&a===i+t.strm.avail_in?1:0,H(t,0,0,r),t.pending_buf[t.pending-4]=a,t.pending_buf[t.pending-3]=a>>8,t.pending_buf[t.pending-2]=~a,t.pending_buf[t.pending-1]=~a>>8,ct(t.strm),i&&(i>a&&(i=a),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+i),t.strm.next_out),t.strm.next_out+=i,t.strm.avail_out-=i,t.strm.total_out+=i,t.block_start+=i,a-=i),a&&(bt(t.strm,t.strm.output,t.strm.next_out,a),t.strm.next_out+=a,t.strm.avail_out-=a,t.strm.total_out+=a)}while(0===r);return o-=t.strm.avail_in,o&&(o>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=o&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-o,t.strm.next_in),t.strstart),t.strstart+=o,t.insert+=o>t.w_size-t.insert?t.w_size-t.insert:o),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),r?4:e!==P&&e!==X&&0===t.strm.avail_in&&t.strstart===t.block_start?2:(n=t.window_size-t.strstart,t.strm.avail_in>n&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,n+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),n>t.strm.avail_in&&(n=t.strm.avail_in),n&&(bt(t.strm,t.window,t.strstart,n),t.strstart+=n,t.insert+=n>t.w_size-t.insert?t.w_size-t.insert:n),t.high_water<t.strstart&&(t.high_water=t.strstart),n=t.bi_valid+42>>3,n=t.pending_buf_size-n>65535?65535:t.pending_buf_size-n,s=n>t.w_size?t.w_size:n,i=t.strstart-t.block_start,(i>=s||(i||e===X)&&e!==P&&0===t.strm.avail_in&&i<=n)&&(a=i>n?n:i,r=e===X&&0===t.strm.avail_in&&a===i?1:0,H(t,t.block_start,a,r),t.block_start+=a,ct(t.strm)),r?3:1)},vt=(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=ft(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=ft(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=ft(t,t.ins_h,t.window[t.strstart+1]);else i=j(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(ut(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===X?(ut(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ut(t,!1),0===t.strm.avail_out)?1:2},yt=(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=ft(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=ft(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&&(ut(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&&ut(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?(ut(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ut(t,!1),0===t.strm.avail_out)?1:2};function xt(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 zt=[new xt(0,0,0,0,kt),new xt(4,4,8,4,vt),new xt(4,5,16,8,vt),new xt(4,6,32,32,vt),new xt(4,4,16,16,yt),new xt(8,16,32,32,yt),new xt(8,16,128,128,yt),new xt(8,32,128,256,yt),new xt(32,128,258,1024,yt),new xt(32,258,258,4096,yt)];function At(){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.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Et=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||42!==e.status&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&113!==e.status&&666!==e.status?1:0},Rt=t=>{if(Et(t))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=2===e.wrap?57:e.wrap?42:113,t.adler=2===e.wrap?0:1,e.last_flush=-2,C(e),W},Zt=t=>{const e=Rt(t);var a;return e===W&&((a=t.state).window_size=2*a.w_size,dt(a.head),a.max_lazy_match=zt[a.level].max_lazy,a.good_match=zt[a.level].good_length,a.nice_match=zt[a.level].nice_length,a.max_chain_length=zt[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},St=(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||8===i&&1!==r)return lt(t,Q);8===i&&(i=9);const o=new At;return t.state=o,o.strm=t,o.status=42,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.sym_buf=o.lit_bufsize,o.sym_end=3*(o.lit_bufsize-1),o.level=e,o.strategy=s,o.method=a,Zt(t)};var Ut={deflateInit:(t,e)=>St(t,e,ot,15,8,st),deflateInit2:St,deflateReset:Zt,deflateResetKeep:Rt,deflateSetHeader:(t,e)=>Et(t)||2!==t.state.wrap?Q:(t.state.gzhead=e,W),deflate:(t,e)=>{if(Et(t)||e>J||e<0)return t?lt(t,Q):Q;const a=t.state;if(!t.output||0!==t.avail_in&&!t.input||666===a.status&&e!==X)return lt(t,0===t.avail_out?$:Q);const i=a.last_flush;if(a.last_flush=e,0!==a.pending){if(ct(t),0===t.avail_out)return a.last_flush=-1,W}else if(0===t.avail_in&&ht(e)<=ht(i)&&e!==X)return lt(t,$);if(666===a.status&&0!==t.avail_in)return lt(t,$);if(42===a.status&&0===a.wrap&&(a.status=113),42===a.status){let e=ot+(a.w_bits-8<<4)<<8,i=-1;if(i=a.strategy>=at||a.level<2?0:a.level<6?1:6===a.level?2:3,e|=i<<6,0!==a.strstart&&(e|=32),e+=31-e%31,mt(a,e),0!==a.strstart&&(mt(a,t.adler>>>16),mt(a,65535&t.adler)),t.adler=1,a.status=113,ct(t),0!==a.pending)return a.last_flush=-1,W}if(57===a.status)if(t.adler=0,wt(a,31),wt(a,139),wt(a,8),a.gzhead)wt(a,(a.gzhead.text?1:0)+(a.gzhead.hcrc?2:0)+(a.gzhead.extra?4:0)+(a.gzhead.name?8:0)+(a.gzhead.comment?16:0)),wt(a,255&a.gzhead.time),wt(a,a.gzhead.time>>8&255),wt(a,a.gzhead.time>>16&255),wt(a,a.gzhead.time>>24&255),wt(a,9===a.level?2:a.strategy>=at||a.level<2?4:0),wt(a,255&a.gzhead.os),a.gzhead.extra&&a.gzhead.extra.length&&(wt(a,255&a.gzhead.extra.length),wt(a,a.gzhead.extra.length>>8&255)),a.gzhead.hcrc&&(t.adler=L(t.adler,a.pending_buf,a.pending,0)),a.gzindex=0,a.status=69;else if(wt(a,0),wt(a,0),wt(a,0),wt(a,0),wt(a,0),wt(a,9===a.level?2:a.strategy>=at||a.level<2?4:0),wt(a,3),a.status=113,ct(t),0!==a.pending)return a.last_flush=-1,W;if(69===a.status){if(a.gzhead.extra){let e=a.pending,i=(65535&a.gzhead.extra.length)-a.gzindex;for(;a.pending+i>a.pending_buf_size;){let n=a.pending_buf_size-a.pending;if(a.pending_buf.set(a.gzhead.extra.subarray(a.gzindex,a.gzindex+n),a.pending),a.pending=a.pending_buf_size,a.gzhead.hcrc&&a.pending>e&&(t.adler=L(t.adler,a.pending_buf,a.pending-e,e)),a.gzindex+=n,ct(t),0!==a.pending)return a.last_flush=-1,W;e=0,i-=n}let n=new Uint8Array(a.gzhead.extra);a.pending_buf.set(n.subarray(a.gzindex,a.gzindex+i),a.pending),a.pending+=i,a.gzhead.hcrc&&a.pending>e&&(t.adler=L(t.adler,a.pending_buf,a.pending-e,e)),a.gzindex=0}a.status=73}if(73===a.status){if(a.gzhead.name){let e,i=a.pending;do{if(a.pending===a.pending_buf_size){if(a.gzhead.hcrc&&a.pending>i&&(t.adler=L(t.adler,a.pending_buf,a.pending-i,i)),ct(t),0!==a.pending)return a.last_flush=-1,W;i=0}e=a.gzindex<a.gzhead.name.length?255&a.gzhead.name.charCodeAt(a.gzindex++):0,wt(a,e)}while(0!==e);a.gzhead.hcrc&&a.pending>i&&(t.adler=L(t.adler,a.pending_buf,a.pending-i,i)),a.gzindex=0}a.status=91}if(91===a.status){if(a.gzhead.comment){let e,i=a.pending;do{if(a.pending===a.pending_buf_size){if(a.gzhead.hcrc&&a.pending>i&&(t.adler=L(t.adler,a.pending_buf,a.pending-i,i)),ct(t),0!==a.pending)return a.last_flush=-1,W;i=0}e=a.gzindex<a.gzhead.comment.length?255&a.gzhead.comment.charCodeAt(a.gzindex++):0,wt(a,e)}while(0!==e);a.gzhead.hcrc&&a.pending>i&&(t.adler=L(t.adler,a.pending_buf,a.pending-i,i))}a.status=103}if(103===a.status){if(a.gzhead.hcrc){if(a.pending+2>a.pending_buf_size&&(ct(t),0!==a.pending))return a.last_flush=-1,W;wt(a,255&t.adler),wt(a,t.adler>>8&255),t.adler=0}if(a.status=113,ct(t),0!==a.pending)return a.last_flush=-1,W}if(0!==t.avail_in||0!==a.lookahead||e!==P&&666!==a.status){let i=0===a.level?kt(a,e):a.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&&(ut(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===X?(ut(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ut(t,!1),0===t.strm.avail_out)?1:2})(a,e):a.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&&(ut(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===X?(ut(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ut(t,!1),0===t.strm.avail_out)?1:2})(a,e):zt[a.level].func(a,e);if(3!==i&&4!==i||(a.status=666),1===i||3===i)return 0===t.avail_out&&(a.last_flush=-1),W;if(2===i&&(e===Y?K(a):e!==J&&(H(a,0,0,!1),e===G&&(dt(a.head),0===a.lookahead&&(a.strstart=0,a.block_start=0,a.insert=0))),ct(t),0===t.avail_out))return a.last_flush=-1,W}return e!==X?W:a.wrap<=0?q:(2===a.wrap?(wt(a,255&t.adler),wt(a,t.adler>>8&255),wt(a,t.adler>>16&255),wt(a,t.adler>>24&255),wt(a,255&t.total_in),wt(a,t.total_in>>8&255),wt(a,t.total_in>>16&255),wt(a,t.total_in>>24&255)):(mt(a,t.adler>>>16),mt(a,65535&t.adler)),ct(t),a.wrap>0&&(a.wrap=-a.wrap),0!==a.pending?W:q)},deflateEnd:t=>{if(Et(t))return Q;const e=t.state.status;return t.state=null,113===e?lt(t,V):W},deflateSetDictionary:(t,e)=>{let a=e.length;if(Et(t))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=N(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=ft(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,W},deflateInfo:"pako deflate (from Nodeca project)"};const Dt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Ot=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)Dt(a,e)&&(t[e]=a[e])}}return t},Tt=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 Nt=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Nt=!1}const Ft=new Uint8Array(256);for(let t=0;t<256;t++)Ft[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Ft[254]=Ft[254]=1;var Lt=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},It=(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=Ft[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&&Nt)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)},Bt=(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+Ft[t[a]]>e?a:e};var Ct=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 Ht=Object.prototype.toString,{Z_NO_FLUSH:Mt,Z_SYNC_FLUSH:jt,Z_FULL_FLUSH:Kt,Z_FINISH:Pt,Z_OK:Yt,Z_STREAM_END:Gt,Z_DEFAULT_COMPRESSION:Xt,Z_DEFAULT_STRATEGY:Jt,Z_DEFLATED:Wt}=B;function qt(t){this.options=Ot({level:Xt,method:Wt,chunkSize:16384,windowBits:15,memLevel:8,strategy:Jt},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 Ct,this.strm.avail_out=0;let a=Ut.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(a!==Yt)throw new Error(I[a]);if(e.header&&Ut.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Lt(e.dictionary):"[object ArrayBuffer]"===Ht.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,a=Ut.deflateSetDictionary(this.strm,t),a!==Yt)throw new Error(I[a]);this._dict_set=!0}}function Qt(t,e){const a=new qt(e);if(a.push(t,!0),a.err)throw a.msg||I[a.err];return a.result}qt.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?Pt:Mt,"string"==typeof t?a.input=Lt(t):"[object ArrayBuffer]"===Ht.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===jt||s===Kt)&&a.avail_out<=6)this.onData(a.output.subarray(0,a.next_out)),a.avail_out=0;else{if(n=Ut.deflate(a,s),n===Gt)return a.next_out>0&&this.onData(a.output.subarray(0,a.next_out)),n=Ut.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Yt;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},qt.prototype.onData=function(t){this.chunks.push(t)},qt.prototype.onEnd=function(t){t===Yt&&(this.result=Tt(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Vt={Deflate:qt,deflate:Qt,deflateRaw:function(t,e){return(e=e||{}).raw=!0,Qt(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,Qt(t,e)},constants:B};var $t=function(t,e){let a,i,n,s,r,o,l,h,d,_,f,c,u,w,m,b,g,p,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,m=(1<<E.lenbits)-1,b=(1<<E.distbits)-1;t:do{c<15&&(f+=z[a++]<<c,c+=8,f+=z[a++]<<c,c+=8),g=u[f&m];e:for(;;){if(p=g>>>24,f>>>=p,c-=p,p=g>>>16&255,0===p)A[n++]=65535&g;else{if(!(16&p)){if(0==(64&p)){g=u[(65535&g)+(f&(1<<p)-1)];continue e}if(32&p){E.mode=16191;break t}t.msg="invalid literal/length code",E.mode=16209;break t}k=65535&g,p&=15,p&&(c<p&&(f+=z[a++]<<c,c+=8),k+=f&(1<<p)-1,f>>>=p,c-=p),c<15&&(f+=z[a++]<<c,c+=8,f+=z[a++]<<c,c+=8),g=w[f&b];a:for(;;){if(p=g>>>24,f>>>=p,c-=p,p=g>>>16&255,!(16&p)){if(0==(64&p)){g=w[(65535&g)+(f&(1<<p)-1)];continue a}t.msg="invalid distance code",E.mode=16209;break t}if(v=65535&g,p&=15,c<p&&(f+=z[a++]<<c,c+=8,c<p&&(f+=z[a++]<<c,c+=8)),v+=f&(1<<p)-1,v>o){t.msg="invalid distance too far back",E.mode=16209;break t}if(f>>>=p,c-=p,p=n-s,v>p){if(p=v-p,p>h&&E.sane){t.msg="invalid distance too far back",E.mode=16209;break t}if(y=0,x=_,0===d){if(y+=l-p,p<k){k-=p;do{A[n++]=_[y++]}while(--p);y=n-v,x=A}}else if(d<p){if(y+=l+d-p,p-=d,p<k){k-=p;do{A[n++]=_[y++]}while(--p);if(y=0,d<k){p=d,k-=p;do{A[n++]=_[y++]}while(--p);y=n-v,x=A}}}else if(y+=d-p,p<k){k-=p;do{A[n++]=_[y++]}while(--p);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 te=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]),ee=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]),ae=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]),ie=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 ne=(t,e,a,i,n,s,r,o)=>{const l=o.bits;let h,d,_,f,c,u,w=0,m=0,b=0,g=0,p=0,k=0,v=0,y=0,x=0,z=0,A=null;const E=new Uint16Array(16),R=new Uint16Array(16);let Z,S,U,D=null;for(w=0;w<=15;w++)E[w]=0;for(m=0;m<i;m++)E[e[a+m]]++;for(p=l,g=15;g>=1&&0===E[g];g--);if(p>g&&(p=g),0===g)return n[s++]=20971520,n[s++]=20971520,o.bits=1,0;for(b=1;b<g&&0===E[b];b++);for(p<b&&(p=b),y=1,w=1;w<=15;w++)if(y<<=1,y-=E[w],y<0)return-1;if(y>0&&(0===t||1!==g))return-1;for(R[1]=0,w=1;w<15;w++)R[w+1]=R[w]+E[w];for(m=0;m<i;m++)0!==e[a+m]&&(r[R[e[a+m]]++]=m);if(0===t?(A=D=r,u=20):1===t?(A=te,D=ee,u=257):(A=ae,D=ie,u=0),z=0,m=0,w=b,c=s,k=p,v=0,_=-1,x=1<<p,f=x-1,1===t&&x>852||2===t&&x>592)return 1;for(;;){Z=w-v,r[m]+1<u?(S=0,U=r[m]):r[m]>=u?(S=D[r[m]-u],U=A[r[m]-u]):(S=96,U=0),h=1<<w-v,d=1<<k,b=d;do{d-=h,n[c+(z>>v)+d]=Z<<24|S<<16|U|0}while(0!==d);for(h=1<<w-1;z&h;)h>>=1;if(0!==h?(z&=h-1,z+=h):z=0,m++,0==--E[w]){if(w===g)break;w=e[a+r[m]]}if(w>p&&(z&f)!==_){for(0===v&&(v=p),c+=b,k=w-v,y=1<<k;k+v<g&&(y-=E[k+v],!(y<=0));)k++,y<<=1;if(x+=1<<k,1===t&&x>852||2===t&&x>592)return 1;_=z&f,n[_]=p<<24|k<<16|c-s|0}}return 0!==z&&(n[c+z]=w-v<<24|64<<16|0),o.bits=p,0};const{Z_FINISH:se,Z_BLOCK:re,Z_TREES:oe,Z_OK:le,Z_STREAM_END:he,Z_NEED_DICT:de,Z_STREAM_ERROR:_e,Z_DATA_ERROR:fe,Z_MEM_ERROR:ce,Z_BUF_ERROR:ue,Z_DEFLATED:we}=B,me=16209,be=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function ge(){this.strm=null,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 pe=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<16180||e.mode>16211?1:0},ke=t=>{if(pe(t))return _e;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=16180,e.last=0,e.havedict=0,e.flags=-1,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,le},ve=t=>{if(pe(t))return _e;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,ke(t)},ye=(t,e)=>{let a;if(pe(t))return _e;const i=t.state;return e<0?(a=0,e=-e):(a=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?_e:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=a,i.wbits=e,ve(t))},xe=(t,e)=>{if(!t)return _e;const a=new ge;t.state=a,a.strm=t,a.window=null,a.mode=16180;const i=ye(t,e);return i!==le&&(t.state=null),i};let ze,Ae,Ee=!0;const Re=t=>{if(Ee){ze=new Int32Array(512),Ae=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(ne(1,t.lens,0,288,ze,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;ne(2,t.lens,0,32,Ae,0,t.work,{bits:5}),Ee=!1}t.lencode=ze,t.lenbits=9,t.distcode=Ae,t.distbits=5},Ze=(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 Se={inflateReset:ve,inflateReset2:ye,inflateResetKeep:ke,inflateInit:t=>xe(t,15),inflateInit2:xe,inflate:(t,e)=>{let a,i,n,s,r,o,l,h,d,_,f,c,u,w,m,b,g,p,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(pe(t)||!t.output||!t.input&&0!==t.avail_in)return _e;a=t.state,16191===a.mode&&(a.mode=16192),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=le;t:for(;;)switch(a.mode){case 16180:if(0===a.wrap){a.mode=16192;break}for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(2&a.wrap&&35615===h){0===a.wbits&&(a.wbits=15),a.check=0,A[0]=255&h,A[1]=h>>>8&255,a.check=L(a.check,A,2,0),h=0,d=0,a.mode=16181;break}if(a.head&&(a.head.done=!1),!(1&a.wrap)||(((255&h)<<8)+(h>>8))%31){t.msg="incorrect header check",a.mode=me;break}if((15&h)!==we){t.msg="unknown compression method",a.mode=me;break}if(h>>>=4,d-=4,y=8+(15&h),0===a.wbits&&(a.wbits=y),y>15||y>a.wbits){t.msg="invalid window size",a.mode=me;break}a.dmax=1<<a.wbits,a.flags=0,t.adler=a.check=1,a.mode=512&h?16189:16191,h=0,d=0;break;case 16181:for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(a.flags=h,(255&a.flags)!==we){t.msg="unknown compression method",a.mode=me;break}if(57344&a.flags){t.msg="unknown header flags set",a.mode=me;break}a.head&&(a.head.text=h>>8&1),512&a.flags&&4&a.wrap&&(A[0]=255&h,A[1]=h>>>8&255,a.check=L(a.check,A,2,0)),h=0,d=0,a.mode=16182;case 16182:for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.head&&(a.head.time=h),512&a.flags&&4&a.wrap&&(A[0]=255&h,A[1]=h>>>8&255,A[2]=h>>>16&255,A[3]=h>>>24&255,a.check=L(a.check,A,4,0)),h=0,d=0,a.mode=16183;case 16183: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&&4&a.wrap&&(A[0]=255&h,A[1]=h>>>8&255,a.check=L(a.check,A,2,0)),h=0,d=0,a.mode=16184;case 16184: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&&4&a.wrap&&(A[0]=255&h,A[1]=h>>>8&255,a.check=L(a.check,A,2,0)),h=0,d=0}else a.head&&(a.head.extra=null);a.mode=16185;case 16185: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&&4&a.wrap&&(a.check=L(a.check,i,c,s)),o-=c,s+=c,a.length-=c),a.length))break t;a.length=0,a.mode=16186;case 16186: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&&4&a.wrap&&(a.check=L(a.check,i,c,s)),o-=c,s+=c,y)break t}else a.head&&(a.head.name=null);a.length=0,a.mode=16187;case 16187: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&&4&a.wrap&&(a.check=L(a.check,i,c,s)),o-=c,s+=c,y)break t}else a.head&&(a.head.comment=null);a.mode=16188;case 16188:if(512&a.flags){for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(4&a.wrap&&h!==(65535&a.check)){t.msg="header crc mismatch",a.mode=me;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=16191;break;case 16189:for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}t.adler=a.check=be(h),h=0,d=0,a.mode=16190;case 16190: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,de;t.adler=a.check=1,a.mode=16191;case 16191:if(e===re||e===oe)break t;case 16192:if(a.last){h>>>=7&d,d-=7&d,a.mode=16206;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=16193;break;case 1:if(Re(a),a.mode=16199,e===oe){h>>>=2,d-=2;break t}break;case 2:a.mode=16196;break;case 3:t.msg="invalid block type",a.mode=me}h>>>=2,d-=2;break;case 16193: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=me;break}if(a.length=65535&h,h=0,d=0,a.mode=16194,e===oe)break t;case 16194:a.mode=16195;case 16195: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=16191;break;case 16196: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=me;break}a.have=0,a.mode=16197;case 16197: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=ne(0,a.lens,0,19,a.lencode,0,a.work,E),a.lenbits=E.bits,x){t.msg="invalid code lengths set",a.mode=me;break}a.have=0,a.mode=16198;case 16198:for(;a.have<a.nlen+a.ndist;){for(;z=a.lencode[h&(1<<a.lenbits)-1],m=z>>>24,b=z>>>16&255,g=65535&z,!(m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(g<16)h>>>=m,d-=m,a.lens[a.have++]=g;else{if(16===g){for(R=m+2;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(h>>>=m,d-=m,0===a.have){t.msg="invalid bit length repeat",a.mode=me;break}y=a.lens[a.have-1],c=3+(3&h),h>>>=2,d-=2}else if(17===g){for(R=m+3;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=m,d-=m,y=0,c=3+(7&h),h>>>=3,d-=3}else{for(R=m+7;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=m,d-=m,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=me;break}for(;c--;)a.lens[a.have++]=y}}if(a.mode===me)break;if(0===a.lens[256]){t.msg="invalid code -- missing end-of-block",a.mode=me;break}if(a.lenbits=9,E={bits:a.lenbits},x=ne(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=me;break}if(a.distbits=6,a.distcode=a.distdyn,E={bits:a.distbits},x=ne(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=me;break}if(a.mode=16199,e===oe)break t;case 16199:a.mode=16200;case 16200: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,$t(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,16191===a.mode&&(a.back=-1);break}for(a.back=0;z=a.lencode[h&(1<<a.lenbits)-1],m=z>>>24,b=z>>>16&255,g=65535&z,!(m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(b&&0==(240&b)){for(p=m,k=b,v=g;z=a.lencode[v+((h&(1<<p+k)-1)>>p)],m=z>>>24,b=z>>>16&255,g=65535&z,!(p+m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=p,d-=p,a.back+=p}if(h>>>=m,d-=m,a.back+=m,a.length=g,0===b){a.mode=16205;break}if(32&b){a.back=-1,a.mode=16191;break}if(64&b){t.msg="invalid literal/length code",a.mode=me;break}a.extra=15&b,a.mode=16201;case 16201: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=16202;case 16202:for(;z=a.distcode[h&(1<<a.distbits)-1],m=z>>>24,b=z>>>16&255,g=65535&z,!(m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(0==(240&b)){for(p=m,k=b,v=g;z=a.distcode[v+((h&(1<<p+k)-1)>>p)],m=z>>>24,b=z>>>16&255,g=65535&z,!(p+m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=p,d-=p,a.back+=p}if(h>>>=m,d-=m,a.back+=m,64&b){t.msg="invalid distance code",a.mode=me;break}a.offset=g,a.extra=15&b,a.mode=16203;case 16203: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=me;break}a.mode=16204;case 16204: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=me;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=16200);break;case 16205:if(0===l)break t;n[r++]=a.length,l--,a.mode=16200;break;case 16206: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,4&a.wrap&&f&&(t.adler=a.check=a.flags?L(a.check,n,f,r-f):N(a.check,n,f,r-f)),f=l,4&a.wrap&&(a.flags?h:be(h))!==a.check){t.msg="incorrect data check",a.mode=me;break}h=0,d=0}a.mode=16207;case 16207:if(a.wrap&&a.flags){for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(4&a.wrap&&h!==(4294967295&a.total)){t.msg="incorrect length check",a.mode=me;break}h=0,d=0}a.mode=16208;case 16208:x=he;break t;case me:x=fe;break t;case 16210:return ce;default:return _e}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<me&&(a.mode<16206||e!==se))&&Ze(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,4&a.wrap&&f&&(t.adler=a.check=a.flags?L(a.check,n,f,t.next_out-f):N(a.check,n,f,t.next_out-f)),t.data_type=a.bits+(a.last?64:0)+(16191===a.mode?128:0)+(16199===a.mode||16194===a.mode?256:0),(0===_&&0===f||e===se)&&x===le&&(x=ue),x},inflateEnd:t=>{if(pe(t))return _e;let e=t.state;return e.window&&(e.window=null),t.state=null,le},inflateGetHeader:(t,e)=>{if(pe(t))return _e;const a=t.state;return 0==(2&a.wrap)?_e:(a.head=e,e.done=!1,le)},inflateSetDictionary:(t,e)=>{const a=e.length;let i,n,s;return pe(t)?_e:(i=t.state,0!==i.wrap&&16190!==i.mode?_e:16190===i.mode&&(n=1,n=N(n,e,a,0),n!==i.check)?fe:(s=Ze(t,e,a,a),s?(i.mode=16210,ce):(i.havedict=1,le)))},inflateInfo:"pako inflate (from Nodeca project)"};var Ue=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 De=Object.prototype.toString,{Z_NO_FLUSH:Oe,Z_FINISH:Te,Z_OK:Ne,Z_STREAM_END:Fe,Z_NEED_DICT:Le,Z_STREAM_ERROR:Ie,Z_DATA_ERROR:Be,Z_MEM_ERROR:Ce}=B;function He(t){this.options=Ot({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 Ct,this.strm.avail_out=0;let a=Se.inflateInit2(this.strm,e.windowBits);if(a!==Ne)throw new Error(I[a]);if(this.header=new Ue,Se.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Lt(e.dictionary):"[object ArrayBuffer]"===De.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(a=Se.inflateSetDictionary(this.strm,e.dictionary),a!==Ne)))throw new Error(I[a])}He.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?Te:Oe,"[object ArrayBuffer]"===De.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=Se.inflate(a,r),s===Le&&n&&(s=Se.inflateSetDictionary(a,n),s===Ne?s=Se.inflate(a,r):s===Be&&(s=Le));a.avail_in>0&&s===Fe&&a.state.wrap>0&&0!==t[a.next_in];)Se.inflateReset(a),s=Se.inflate(a,r);switch(s){case Ie:case Be:case Le:case Ce:return this.onEnd(s),this.ended=!0,!1}if(o=a.avail_out,a.next_out&&(0===a.avail_out||s===Fe))if("string"===this.options.to){let t=Bt(a.output,a.next_out),e=a.next_out-t,n=It(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!==Ne||0!==o){if(s===Fe)return s=Se.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===a.avail_in)break}}return!0},He.prototype.onData=function(t){this.chunks.push(t)},He.prototype.onEnd=function(t){t===Ne&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Tt(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};const{Deflate:Me,deflate:je,deflateRaw:Ke,gzip:Pe}=Vt;var Ye=Me,Ge=B;const Xe=new class{constructor(){this.added=0,this.init()}init(){this.added=0,this.deflate=new Ye,this.deflate.push("[",Ge.Z_NO_FLUSH)}addEvent(t){if(!t)throw new Error("Adding invalid event");const e=this.added>0?",":"";this.deflate.push(e+JSON.stringify(t),Ge.Z_SYNC_FLUSH),this.added++}finish(){if(this.deflate.push("]",Ge.Z_FINISH),this.deflate.err)throw this.deflate.err;const t=this.deflate.result;return this.init(),t}},Je={init:()=>(Xe.init(),""),addEvent:t=>Xe.addEvent(t),finish:()=>Xe.finish()};addEventListener("message",(function(t){const e=t.data.method,a=t.data.id,[i]=t.data.args?JSON.parse(t.data.args):[];if(e in Je&&"function"==typeof Je[e])try{const t=Je[e](i);postMessage({id:a,method:e,success:!0,response:t})}catch(t){postMessage({id:a,method:e,success:!1,response:t.message}),console.error(t)}})),postMessage({id:void 0,method:"init",success:!0,response:void 0});`;
|
|
3847
|
+
if (stickySession) {
|
|
3848
|
+
saveSession(session);
|
|
3849
|
+
}
|
|
3850
|
+
|
|
3851
|
+
return session;
|
|
3852
|
+
}
|
|
3877
3853
|
|
|
3878
3854
|
/**
|
|
3879
|
-
*
|
|
3855
|
+
* Fetches a session from storage
|
|
3880
3856
|
*/
|
|
3881
|
-
function
|
|
3882
|
-
|
|
3883
|
-
if (useCompression && window.Worker) {
|
|
3884
|
-
const workerBlob = new Blob([workerString]);
|
|
3885
|
-
const workerUrl = URL.createObjectURL(workerBlob);
|
|
3857
|
+
function fetchSession() {
|
|
3858
|
+
const hasSessionStorage = 'sessionStorage' in WINDOW;
|
|
3886
3859
|
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
return new EventBufferProxy(worker);
|
|
3860
|
+
if (!hasSessionStorage) {
|
|
3861
|
+
return null;
|
|
3890
3862
|
}
|
|
3891
3863
|
|
|
3892
|
-
|
|
3893
|
-
|
|
3864
|
+
try {
|
|
3865
|
+
// This can throw if cookies are disabled
|
|
3866
|
+
const sessionStringFromStorage = WINDOW.sessionStorage.getItem(REPLAY_SESSION_KEY);
|
|
3867
|
+
|
|
3868
|
+
if (!sessionStringFromStorage) {
|
|
3869
|
+
return null;
|
|
3870
|
+
}
|
|
3871
|
+
|
|
3872
|
+
const sessionObj = JSON.parse(sessionStringFromStorage) ;
|
|
3873
|
+
|
|
3874
|
+
return makeSession(sessionObj);
|
|
3875
|
+
} catch (e) {
|
|
3876
|
+
return null;
|
|
3877
|
+
}
|
|
3894
3878
|
}
|
|
3895
3879
|
|
|
3896
3880
|
/**
|
|
3897
|
-
*
|
|
3898
|
-
* This can happen e.g. if the worker cannot be loaded.
|
|
3899
|
-
* Exported only for testing.
|
|
3881
|
+
* Get or create a session
|
|
3900
3882
|
*/
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3883
|
+
function getSession({
|
|
3884
|
+
expiry,
|
|
3885
|
+
currentSession,
|
|
3886
|
+
stickySession,
|
|
3887
|
+
sessionSampleRate,
|
|
3888
|
+
errorSampleRate,
|
|
3889
|
+
}) {
|
|
3890
|
+
// If session exists and is passed, use it instead of always hitting session storage
|
|
3891
|
+
const session = currentSession || (stickySession && fetchSession());
|
|
3907
3892
|
|
|
3908
|
-
|
|
3909
|
-
|
|
3893
|
+
if (session) {
|
|
3894
|
+
// If there is a session, check if it is valid (e.g. "last activity" time
|
|
3895
|
+
// should be within the "session idle time", and "session started" time is
|
|
3896
|
+
// within "max session time").
|
|
3897
|
+
const isExpired = isSessionExpired(session, expiry);
|
|
3910
3898
|
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3899
|
+
if (!isExpired) {
|
|
3900
|
+
return { type: 'saved', session };
|
|
3901
|
+
} else {
|
|
3902
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.log('[Replay] Session has expired');
|
|
3903
|
+
}
|
|
3904
|
+
// Otherwise continue to create a new session
|
|
3914
3905
|
}
|
|
3915
3906
|
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3907
|
+
const newSession = createSession({
|
|
3908
|
+
stickySession,
|
|
3909
|
+
sessionSampleRate,
|
|
3910
|
+
errorSampleRate,
|
|
3911
|
+
});
|
|
3920
3912
|
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
this._fallback.destroy();
|
|
3924
|
-
this._compression.destroy();
|
|
3925
|
-
}
|
|
3913
|
+
return { type: 'new', session: newSession };
|
|
3914
|
+
}
|
|
3926
3915
|
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3916
|
+
/**
|
|
3917
|
+
* Add an event to the event buffer
|
|
3918
|
+
*/
|
|
3919
|
+
async function addEvent(
|
|
3920
|
+
replay,
|
|
3921
|
+
event,
|
|
3922
|
+
isCheckout,
|
|
3923
|
+
) {
|
|
3924
|
+
if (!replay.eventBuffer) {
|
|
3925
|
+
// This implies that `_isEnabled` is false
|
|
3926
|
+
return null;
|
|
3934
3927
|
}
|
|
3935
3928
|
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
return
|
|
3929
|
+
if (replay.isPaused()) {
|
|
3930
|
+
// Do not add to event buffer when recording is paused
|
|
3931
|
+
return null;
|
|
3939
3932
|
}
|
|
3940
3933
|
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
} catch (error) {
|
|
3946
|
-
// If the worker fails to load, we fall back to the simple buffer.
|
|
3947
|
-
// Nothing more to do from our side here
|
|
3948
|
-
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.log('[Replay] Failed to load the compression worker, falling back to simple buffer');
|
|
3949
|
-
return;
|
|
3950
|
-
}
|
|
3951
|
-
|
|
3952
|
-
// Compression worker is ready, we can use it
|
|
3953
|
-
// Now we need to switch over the array buffer to the compression worker
|
|
3954
|
-
const addEventPromises = [];
|
|
3955
|
-
for (const event of this._fallback.pendingEvents) {
|
|
3956
|
-
addEventPromises.push(this._compression.addEvent(event));
|
|
3957
|
-
}
|
|
3934
|
+
// TODO: sadness -- we will want to normalize timestamps to be in ms -
|
|
3935
|
+
// requires coordination with frontend
|
|
3936
|
+
const isMs = event.timestamp > 9999999999;
|
|
3937
|
+
const timestampInMs = isMs ? event.timestamp : event.timestamp * 1000;
|
|
3958
3938
|
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3939
|
+
// Throw out events that happen more than 5 minutes ago. This can happen if
|
|
3940
|
+
// page has been left open and idle for a long period of time and user
|
|
3941
|
+
// comes back to trigger a new session. The performance entries rely on
|
|
3942
|
+
// `performance.timeOrigin`, which is when the page first opened.
|
|
3943
|
+
if (timestampInMs + SESSION_IDLE_DURATION < new Date().getTime()) {
|
|
3944
|
+
return null;
|
|
3945
|
+
}
|
|
3962
3946
|
|
|
3963
|
-
|
|
3964
|
-
|
|
3947
|
+
// Only record earliest event if a new session was created, otherwise it
|
|
3948
|
+
// shouldn't be relevant
|
|
3949
|
+
const earliestEvent = replay.getContext().earliestEvent;
|
|
3950
|
+
if (replay.session && replay.session.segmentId === 0 && (!earliestEvent || timestampInMs < earliestEvent)) {
|
|
3951
|
+
replay.getContext().earliestEvent = timestampInMs;
|
|
3965
3952
|
}
|
|
3953
|
+
|
|
3954
|
+
return replay.eventBuffer.addEvent(event, isCheckout);
|
|
3966
3955
|
}
|
|
3967
3956
|
|
|
3968
|
-
|
|
3957
|
+
/**
|
|
3958
|
+
* Create a breadcrumb for a replay.
|
|
3959
|
+
*/
|
|
3960
|
+
function createBreadcrumb(
|
|
3961
|
+
breadcrumb,
|
|
3962
|
+
) {
|
|
3963
|
+
return {
|
|
3964
|
+
timestamp: new Date().getTime() / 1000,
|
|
3965
|
+
type: 'default',
|
|
3966
|
+
...breadcrumb,
|
|
3967
|
+
};
|
|
3968
|
+
}
|
|
3969
3969
|
|
|
3970
|
-
|
|
3971
|
-
|
|
3970
|
+
/**
|
|
3971
|
+
* Add a breadcrumb event to replay.
|
|
3972
|
+
*/
|
|
3973
|
+
function addBreadcrumbEvent(replay, breadcrumb) {
|
|
3974
|
+
if (breadcrumb.category === 'sentry.transaction') {
|
|
3975
|
+
return;
|
|
3972
3976
|
}
|
|
3973
3977
|
|
|
3974
|
-
|
|
3975
|
-
|
|
3978
|
+
if (breadcrumb.category === 'ui.click') {
|
|
3979
|
+
replay.triggerUserActivity();
|
|
3980
|
+
} else {
|
|
3981
|
+
replay.checkAndHandleExpiredSession();
|
|
3976
3982
|
}
|
|
3977
3983
|
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3984
|
+
replay.addUpdate(() => {
|
|
3985
|
+
void addEvent(replay, {
|
|
3986
|
+
type: EventType.Custom,
|
|
3987
|
+
// TODO: We were converting from ms to seconds for breadcrumbs, spans,
|
|
3988
|
+
// but maybe we should just keep them as milliseconds
|
|
3989
|
+
timestamp: (breadcrumb.timestamp || 0) * 1000,
|
|
3990
|
+
data: {
|
|
3991
|
+
tag: 'breadcrumb',
|
|
3992
|
+
payload: breadcrumb,
|
|
3993
|
+
},
|
|
3994
|
+
});
|
|
3985
3995
|
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
}
|
|
3996
|
+
// Do not flush after console log messages
|
|
3997
|
+
return breadcrumb.category === 'console';
|
|
3998
|
+
});
|
|
3999
|
+
}
|
|
3989
4000
|
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
4001
|
+
const handleDomListener =
|
|
4002
|
+
(replay) =>
|
|
4003
|
+
(handlerData) => {
|
|
4004
|
+
if (!replay.isEnabled()) {
|
|
3993
4005
|
return;
|
|
3994
4006
|
}
|
|
3995
4007
|
|
|
3996
|
-
|
|
3997
|
-
return;
|
|
3998
|
-
}
|
|
4008
|
+
const result = handleDom(handlerData);
|
|
3999
4009
|
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
this._events = [];
|
|
4007
|
-
resolve(JSON.stringify(eventsRet));
|
|
4008
|
-
});
|
|
4009
|
-
}
|
|
4010
|
-
}
|
|
4010
|
+
if (!result) {
|
|
4011
|
+
return;
|
|
4012
|
+
}
|
|
4013
|
+
|
|
4014
|
+
addBreadcrumbEvent(replay, result);
|
|
4015
|
+
};
|
|
4011
4016
|
|
|
4012
4017
|
/**
|
|
4013
|
-
*
|
|
4014
|
-
* Exported only for testing.
|
|
4018
|
+
* An event handler to react to DOM events.
|
|
4015
4019
|
*/
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
* `finish()` (and thus the flush), does not complete.
|
|
4021
|
-
*/
|
|
4022
|
-
__init() {this._pendingEvents = [];}
|
|
4023
|
-
|
|
4024
|
-
__init2() {this._eventBufferItemLength = 0;}
|
|
4025
|
-
__init3() {this._id = 0;}
|
|
4020
|
+
function handleDom(handlerData) {
|
|
4021
|
+
// Taken from https://github.com/getsentry/sentry-javascript/blob/master/packages/browser/src/integrations/breadcrumbs.ts#L112
|
|
4022
|
+
let target;
|
|
4023
|
+
let targetNode;
|
|
4026
4024
|
|
|
4027
|
-
|
|
4028
|
-
|
|
4025
|
+
// Accessing event.target can throw (see getsentry/raven-js#838, #768)
|
|
4026
|
+
try {
|
|
4027
|
+
targetNode = getTargetNode(handlerData);
|
|
4028
|
+
target = utils.htmlTreeAsString(targetNode);
|
|
4029
|
+
} catch (e) {
|
|
4030
|
+
target = '<unknown>';
|
|
4029
4031
|
}
|
|
4030
4032
|
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
* the number of events that have been compresed in the worker because
|
|
4034
|
-
* `addEvent` is async.
|
|
4035
|
-
*/
|
|
4036
|
-
get pendingLength() {
|
|
4037
|
-
return this._eventBufferItemLength;
|
|
4033
|
+
if (target.length === 0) {
|
|
4034
|
+
return null;
|
|
4038
4035
|
}
|
|
4039
4036
|
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4037
|
+
return createBreadcrumb({
|
|
4038
|
+
category: `ui.${handlerData.name}`,
|
|
4039
|
+
message: target,
|
|
4040
|
+
data: {
|
|
4041
|
+
// Not sure why this errors, Node should be correct (Argument of type 'Node' is not assignable to parameter of type 'INode')
|
|
4042
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4043
|
+
...(targetNode ? { nodeId: record.mirror.getId(targetNode ) } : {}),
|
|
4044
|
+
},
|
|
4045
|
+
});
|
|
4046
|
+
}
|
|
4047
|
+
|
|
4048
|
+
function getTargetNode(handlerData) {
|
|
4049
|
+
if (isEventWithTarget(handlerData.event)) {
|
|
4050
|
+
return handlerData.event.target;
|
|
4045
4051
|
}
|
|
4046
4052
|
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
* This will either resolve when the worker is ready, or reject if an error occured.
|
|
4050
|
-
*/
|
|
4051
|
-
ensureReady() {
|
|
4052
|
-
return new Promise((resolve, reject) => {
|
|
4053
|
-
this._worker.addEventListener(
|
|
4054
|
-
'message',
|
|
4055
|
-
({ data }) => {
|
|
4056
|
-
if (data.success) {
|
|
4057
|
-
resolve();
|
|
4058
|
-
} else {
|
|
4059
|
-
reject();
|
|
4060
|
-
}
|
|
4061
|
-
},
|
|
4062
|
-
{ once: true },
|
|
4063
|
-
);
|
|
4053
|
+
return handlerData.event;
|
|
4054
|
+
}
|
|
4064
4055
|
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4056
|
+
function isEventWithTarget(event) {
|
|
4057
|
+
return !!(event ).target;
|
|
4058
|
+
}
|
|
4059
|
+
|
|
4060
|
+
/**
|
|
4061
|
+
* Create a "span" for each performance entry. The parent transaction is `this.replayEvent`.
|
|
4062
|
+
*/
|
|
4063
|
+
function createPerformanceSpans(
|
|
4064
|
+
replay,
|
|
4065
|
+
entries,
|
|
4066
|
+
) {
|
|
4067
|
+
return entries.map(({ type, start, end, name, data }) =>
|
|
4068
|
+
addEvent(replay, {
|
|
4069
|
+
type: EventType.Custom,
|
|
4070
|
+
timestamp: start,
|
|
4071
|
+
data: {
|
|
4072
|
+
tag: 'performanceSpan',
|
|
4073
|
+
payload: {
|
|
4074
|
+
op: type,
|
|
4075
|
+
description: name,
|
|
4076
|
+
startTimestamp: start,
|
|
4077
|
+
endTimestamp: end,
|
|
4078
|
+
data,
|
|
4069
4079
|
},
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4080
|
+
},
|
|
4081
|
+
}),
|
|
4082
|
+
);
|
|
4083
|
+
}
|
|
4084
|
+
|
|
4085
|
+
/**
|
|
4086
|
+
* Check whether a given request URL should be filtered out.
|
|
4087
|
+
*/
|
|
4088
|
+
function shouldFilterRequest(replay, url) {
|
|
4089
|
+
// If we enabled the `traceInternals` experiment, we want to trace everything
|
|
4090
|
+
if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && replay.getOptions()._experiments.traceInternals) {
|
|
4091
|
+
return false;
|
|
4073
4092
|
}
|
|
4074
4093
|
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4094
|
+
return !_isSentryRequest(url);
|
|
4095
|
+
}
|
|
4096
|
+
|
|
4097
|
+
/**
|
|
4098
|
+
* Checks wether a given URL belongs to the configured Sentry DSN.
|
|
4099
|
+
*/
|
|
4100
|
+
function _isSentryRequest(url) {
|
|
4101
|
+
const client = core.getCurrentHub().getClient();
|
|
4102
|
+
const dsn = client && client.getDsn();
|
|
4103
|
+
return dsn ? url.includes(dsn.host) : false;
|
|
4104
|
+
}
|
|
4105
|
+
|
|
4106
|
+
/** only exported for tests */
|
|
4107
|
+
function handleFetch(handlerData) {
|
|
4108
|
+
if (!handlerData.endTimestamp) {
|
|
4109
|
+
return null;
|
|
4081
4110
|
}
|
|
4082
4111
|
|
|
4083
|
-
|
|
4084
|
-
* Add an event to the event buffer.
|
|
4085
|
-
*
|
|
4086
|
-
* Returns true if event was successfuly received and processed by worker.
|
|
4087
|
-
*/
|
|
4088
|
-
async addEvent(event, isCheckout) {
|
|
4089
|
-
if (isCheckout) {
|
|
4090
|
-
// This event is a checkout, make sure worker buffer is cleared before
|
|
4091
|
-
// proceeding.
|
|
4092
|
-
await this._postMessage({
|
|
4093
|
-
id: this._getAndIncrementId(),
|
|
4094
|
-
method: 'init',
|
|
4095
|
-
args: [],
|
|
4096
|
-
});
|
|
4097
|
-
}
|
|
4112
|
+
const { startTimestamp, endTimestamp, fetchData, response } = handlerData;
|
|
4098
4113
|
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4114
|
+
return {
|
|
4115
|
+
type: 'resource.fetch',
|
|
4116
|
+
start: startTimestamp / 1000,
|
|
4117
|
+
end: endTimestamp / 1000,
|
|
4118
|
+
name: fetchData.url,
|
|
4119
|
+
data: {
|
|
4120
|
+
method: fetchData.method,
|
|
4121
|
+
statusCode: response.status,
|
|
4122
|
+
},
|
|
4123
|
+
};
|
|
4124
|
+
}
|
|
4125
|
+
|
|
4126
|
+
/**
|
|
4127
|
+
* Returns a listener to be added to `addInstrumentationHandler('fetch', listener)`.
|
|
4128
|
+
*/
|
|
4129
|
+
function handleFetchSpanListener(replay) {
|
|
4130
|
+
return (handlerData) => {
|
|
4131
|
+
if (!replay.isEnabled()) {
|
|
4132
|
+
return;
|
|
4102
4133
|
}
|
|
4103
4134
|
|
|
4104
|
-
|
|
4105
|
-
}
|
|
4135
|
+
const result = handleFetch(handlerData);
|
|
4106
4136
|
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
finish() {
|
|
4111
|
-
return this._finishRequest(this._getAndIncrementId());
|
|
4112
|
-
}
|
|
4137
|
+
if (result === null) {
|
|
4138
|
+
return;
|
|
4139
|
+
}
|
|
4113
4140
|
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
_postMessage({ id, method, args }) {
|
|
4118
|
-
return new Promise((resolve, reject) => {
|
|
4119
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
4120
|
-
const listener = ({ data }) => {
|
|
4121
|
-
if (data.method !== method) {
|
|
4122
|
-
return;
|
|
4123
|
-
}
|
|
4141
|
+
if (shouldFilterRequest(replay, result.name)) {
|
|
4142
|
+
return;
|
|
4143
|
+
}
|
|
4124
4144
|
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4145
|
+
replay.addUpdate(() => {
|
|
4146
|
+
createPerformanceSpans(replay, [result]);
|
|
4147
|
+
// Returning true will cause `addUpdate` to not flush
|
|
4148
|
+
// We do not want network requests to cause a flush. This will prevent
|
|
4149
|
+
// recurring/polling requests from keeping the replay session alive.
|
|
4150
|
+
return true;
|
|
4151
|
+
});
|
|
4152
|
+
};
|
|
4153
|
+
}
|
|
4130
4154
|
|
|
4131
|
-
|
|
4132
|
-
|
|
4155
|
+
/**
|
|
4156
|
+
* Returns true if we think the given event is an error originating inside of rrweb.
|
|
4157
|
+
*/
|
|
4158
|
+
function isRrwebError(event) {
|
|
4159
|
+
if (event.type || !event.exception || !event.exception.values || !event.exception.values.length) {
|
|
4160
|
+
return false;
|
|
4161
|
+
}
|
|
4133
4162
|
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4163
|
+
// Check if any exception originates from rrweb
|
|
4164
|
+
return event.exception.values.some(exception => {
|
|
4165
|
+
if (!exception.stacktrace || !exception.stacktrace.frames || !exception.stacktrace.frames.length) {
|
|
4166
|
+
return false;
|
|
4167
|
+
}
|
|
4137
4168
|
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4169
|
+
return exception.stacktrace.frames.some(frame => frame.filename && frame.filename.includes('/rrweb/src/'));
|
|
4170
|
+
});
|
|
4171
|
+
}
|
|
4141
4172
|
|
|
4142
|
-
|
|
4143
|
-
|
|
4173
|
+
/**
|
|
4174
|
+
* Returns a listener to be added to `addGlobalEventProcessor(listener)`.
|
|
4175
|
+
*/
|
|
4176
|
+
function handleGlobalEventListener(replay) {
|
|
4177
|
+
return (event) => {
|
|
4178
|
+
// Do not apply replayId to the root event
|
|
4179
|
+
if (event.type === REPLAY_EVENT_NAME) {
|
|
4180
|
+
// Replays have separate set of breadcrumbs, do not include breadcrumbs
|
|
4181
|
+
// from core SDK
|
|
4182
|
+
delete event.breadcrumbs;
|
|
4183
|
+
return event;
|
|
4184
|
+
}
|
|
4144
4185
|
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
}
|
|
4186
|
+
// Unless `captureExceptions` is enabled, we want to ignore errors coming from rrweb
|
|
4187
|
+
// As there can be a bunch of stuff going wrong in internals there, that we don't want to bubble up to users
|
|
4188
|
+
if (isRrwebError(event) && !replay.getOptions()._experiments.captureExceptions) {
|
|
4189
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.log('[Replay] Ignoring error from rrweb internals', event);
|
|
4190
|
+
return null;
|
|
4191
|
+
}
|
|
4152
4192
|
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
}
|
|
4158
|
-
}
|
|
4193
|
+
// Only tag transactions with replayId if not waiting for an error
|
|
4194
|
+
// @ts-ignore private
|
|
4195
|
+
if (!event.type || replay.recordingMode === 'session') {
|
|
4196
|
+
event.tags = { ...event.tags, replayId: replay.getSessionId() };
|
|
4197
|
+
}
|
|
4159
4198
|
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
method: 'addEvent',
|
|
4167
|
-
args: [event],
|
|
4168
|
-
});
|
|
4199
|
+
// Collect traceIds in _context regardless of `recordingMode` - if it's true,
|
|
4200
|
+
// _context gets cleared on every checkout
|
|
4201
|
+
if (event.type === 'transaction' && event.contexts && event.contexts.trace && event.contexts.trace.trace_id) {
|
|
4202
|
+
replay.getContext().traceIds.add(event.contexts.trace.trace_id );
|
|
4203
|
+
return event;
|
|
4204
|
+
}
|
|
4169
4205
|
|
|
4170
|
-
//
|
|
4171
|
-
|
|
4206
|
+
// no event type means error
|
|
4207
|
+
if (!event.type) {
|
|
4208
|
+
replay.getContext().errorIds.add(event.event_id );
|
|
4209
|
+
}
|
|
4172
4210
|
|
|
4173
|
-
|
|
4174
|
-
|
|
4211
|
+
if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && replay.getOptions()._experiments.traceInternals) {
|
|
4212
|
+
const exc = getEventExceptionValues(event);
|
|
4213
|
+
addInternalBreadcrumb({
|
|
4214
|
+
message: `Tagging event (${event.event_id}) - ${event.message} - ${exc.type}: ${exc.value}`,
|
|
4215
|
+
});
|
|
4216
|
+
}
|
|
4175
4217
|
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4218
|
+
// Need to be very careful that this does not cause an infinite loop
|
|
4219
|
+
if (
|
|
4220
|
+
replay.recordingMode === 'error' &&
|
|
4221
|
+
event.exception &&
|
|
4222
|
+
event.message !== UNABLE_TO_SEND_REPLAY // ignore this error because otherwise we could loop indefinitely with trying to capture replay and failing
|
|
4223
|
+
) {
|
|
4224
|
+
setTimeout(async () => {
|
|
4225
|
+
// Allow flush to complete before resuming as a session recording, otherwise
|
|
4226
|
+
// the checkout from `startRecording` may be included in the payload.
|
|
4227
|
+
// Prefer to keep the error replay as a separate (and smaller) segment
|
|
4228
|
+
// than the session replay.
|
|
4229
|
+
await replay.flushImmediate();
|
|
4181
4230
|
|
|
4182
|
-
|
|
4183
|
-
|
|
4231
|
+
if (replay.stopRecording()) {
|
|
4232
|
+
// Reset all "capture on error" configuration before
|
|
4233
|
+
// starting a new recording
|
|
4234
|
+
replay.recordingMode = 'session';
|
|
4235
|
+
replay.startRecording();
|
|
4236
|
+
}
|
|
4237
|
+
});
|
|
4238
|
+
}
|
|
4184
4239
|
|
|
4185
|
-
|
|
4240
|
+
return event;
|
|
4241
|
+
};
|
|
4242
|
+
}
|
|
4186
4243
|
|
|
4187
|
-
|
|
4244
|
+
function addInternalBreadcrumb(arg) {
|
|
4245
|
+
const { category, level, message, ...rest } = arg;
|
|
4188
4246
|
|
|
4189
|
-
|
|
4190
|
-
|
|
4247
|
+
core.addBreadcrumb({
|
|
4248
|
+
category: category || 'console',
|
|
4249
|
+
level: level || 'debug',
|
|
4250
|
+
message: `[debug]: ${message}`,
|
|
4251
|
+
...rest,
|
|
4252
|
+
});
|
|
4253
|
+
}
|
|
4191
4254
|
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4255
|
+
function getEventExceptionValues(event) {
|
|
4256
|
+
return {
|
|
4257
|
+
type: 'Unknown',
|
|
4258
|
+
value: 'n/a',
|
|
4259
|
+
...(event.exception && event.exception.values && event.exception.values[0]),
|
|
4260
|
+
};
|
|
4196
4261
|
}
|
|
4197
4262
|
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
* time should be considered as expired.
|
|
4201
|
-
*/
|
|
4202
|
-
function isExpired(
|
|
4203
|
-
initialTime,
|
|
4204
|
-
expiry,
|
|
4205
|
-
targetTime = +new Date(),
|
|
4206
|
-
) {
|
|
4207
|
-
// Always expired if < 0
|
|
4208
|
-
if (initialTime === null || expiry === undefined || expiry < 0) {
|
|
4209
|
-
return true;
|
|
4210
|
-
}
|
|
4263
|
+
function handleHistory(handlerData) {
|
|
4264
|
+
const { from, to } = handlerData;
|
|
4211
4265
|
|
|
4212
|
-
|
|
4213
|
-
if (expiry === 0) {
|
|
4214
|
-
return false;
|
|
4215
|
-
}
|
|
4266
|
+
const now = new Date().getTime() / 1000;
|
|
4216
4267
|
|
|
4217
|
-
return
|
|
4268
|
+
return {
|
|
4269
|
+
type: 'navigation.push',
|
|
4270
|
+
start: now,
|
|
4271
|
+
end: now,
|
|
4272
|
+
name: to,
|
|
4273
|
+
data: {
|
|
4274
|
+
previous: from,
|
|
4275
|
+
},
|
|
4276
|
+
};
|
|
4218
4277
|
}
|
|
4219
4278
|
|
|
4220
4279
|
/**
|
|
4221
|
-
*
|
|
4280
|
+
* Returns a listener to be added to `addInstrumentationHandler('history', listener)`.
|
|
4222
4281
|
*/
|
|
4223
|
-
function
|
|
4224
|
-
return (
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
// performed an action within the last `idleTimeout` ms)
|
|
4229
|
-
isExpired(session.lastActivity, idleTimeout, targetTime)
|
|
4230
|
-
);
|
|
4231
|
-
}
|
|
4282
|
+
function handleHistorySpanListener(replay) {
|
|
4283
|
+
return (handlerData) => {
|
|
4284
|
+
if (!replay.isEnabled()) {
|
|
4285
|
+
return;
|
|
4286
|
+
}
|
|
4232
4287
|
|
|
4233
|
-
|
|
4234
|
-
* Save a session to session storage.
|
|
4235
|
-
*/
|
|
4236
|
-
function saveSession(session) {
|
|
4237
|
-
const hasSessionStorage = 'sessionStorage' in WINDOW;
|
|
4238
|
-
if (!hasSessionStorage) {
|
|
4239
|
-
return;
|
|
4240
|
-
}
|
|
4288
|
+
const result = handleHistory(handlerData);
|
|
4241
4289
|
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
// Ignore potential SecurityError exceptions
|
|
4246
|
-
}
|
|
4247
|
-
}
|
|
4290
|
+
if (result === null) {
|
|
4291
|
+
return;
|
|
4292
|
+
}
|
|
4248
4293
|
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
* 1.0 = 100% sampling
|
|
4253
|
-
* 0.0 = 0% sampling
|
|
4254
|
-
*/
|
|
4255
|
-
function isSampled(sampleRate) {
|
|
4256
|
-
if (sampleRate === undefined) {
|
|
4257
|
-
return false;
|
|
4258
|
-
}
|
|
4294
|
+
// Need to collect visited URLs
|
|
4295
|
+
replay.getContext().urls.push(result.name);
|
|
4296
|
+
replay.triggerUserActivity();
|
|
4259
4297
|
|
|
4260
|
-
|
|
4261
|
-
|
|
4298
|
+
replay.addUpdate(() => {
|
|
4299
|
+
createPerformanceSpans(replay, [result]);
|
|
4300
|
+
// Returning false to flush
|
|
4301
|
+
return false;
|
|
4302
|
+
});
|
|
4303
|
+
};
|
|
4262
4304
|
}
|
|
4263
4305
|
|
|
4264
|
-
|
|
4265
|
-
* Get a session with defaults & applied sampling.
|
|
4266
|
-
*/
|
|
4267
|
-
function makeSession(session) {
|
|
4268
|
-
const now = new Date().getTime();
|
|
4269
|
-
const id = session.id || utils.uuid4();
|
|
4270
|
-
// Note that this means we cannot set a started/lastActivity of `0`, but this should not be relevant outside of tests.
|
|
4271
|
-
const started = session.started || now;
|
|
4272
|
-
const lastActivity = session.lastActivity || now;
|
|
4273
|
-
const segmentId = session.segmentId || 0;
|
|
4274
|
-
const sampled = session.sampled;
|
|
4306
|
+
let _LAST_BREADCRUMB = null;
|
|
4275
4307
|
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4308
|
+
const handleScopeListener =
|
|
4309
|
+
(replay) =>
|
|
4310
|
+
(scope) => {
|
|
4311
|
+
if (!replay.isEnabled()) {
|
|
4312
|
+
return;
|
|
4313
|
+
}
|
|
4314
|
+
|
|
4315
|
+
const result = handleScope(scope);
|
|
4316
|
+
|
|
4317
|
+
if (!result) {
|
|
4318
|
+
return;
|
|
4319
|
+
}
|
|
4320
|
+
|
|
4321
|
+
addBreadcrumbEvent(replay, result);
|
|
4282
4322
|
};
|
|
4283
|
-
}
|
|
4284
4323
|
|
|
4285
4324
|
/**
|
|
4286
|
-
*
|
|
4325
|
+
* An event handler to handle scope changes.
|
|
4287
4326
|
*/
|
|
4288
|
-
function
|
|
4289
|
-
|
|
4290
|
-
}
|
|
4327
|
+
function handleScope(scope) {
|
|
4328
|
+
const newBreadcrumb = scope.getLastBreadcrumb();
|
|
4291
4329
|
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
function createSession({ sessionSampleRate, errorSampleRate, stickySession = false }) {
|
|
4298
|
-
const sampled = getSessionSampleType(sessionSampleRate, errorSampleRate);
|
|
4299
|
-
const session = makeSession({
|
|
4300
|
-
sampled,
|
|
4301
|
-
});
|
|
4330
|
+
// Listener can be called when breadcrumbs have not changed, so we store the
|
|
4331
|
+
// reference to the last crumb and only return a crumb if it has changed
|
|
4332
|
+
if (_LAST_BREADCRUMB === newBreadcrumb || !newBreadcrumb) {
|
|
4333
|
+
return null;
|
|
4334
|
+
}
|
|
4302
4335
|
|
|
4303
|
-
|
|
4336
|
+
_LAST_BREADCRUMB = newBreadcrumb;
|
|
4304
4337
|
|
|
4305
|
-
if (
|
|
4306
|
-
|
|
4338
|
+
if (
|
|
4339
|
+
newBreadcrumb.category &&
|
|
4340
|
+
(['fetch', 'xhr', 'sentry.event', 'sentry.transaction'].includes(newBreadcrumb.category) ||
|
|
4341
|
+
newBreadcrumb.category.startsWith('ui.'))
|
|
4342
|
+
) {
|
|
4343
|
+
return null;
|
|
4307
4344
|
}
|
|
4308
4345
|
|
|
4309
|
-
return
|
|
4346
|
+
return createBreadcrumb(newBreadcrumb);
|
|
4310
4347
|
}
|
|
4311
4348
|
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
*/
|
|
4315
|
-
function fetchSession() {
|
|
4316
|
-
const hasSessionStorage = 'sessionStorage' in WINDOW;
|
|
4349
|
+
// From sentry-javascript
|
|
4350
|
+
// e.g. https://github.com/getsentry/sentry-javascript/blob/c7fc025bf9fa8c073fdb56351808ce53909fbe45/packages/utils/src/instrument.ts#L180
|
|
4317
4351
|
|
|
4318
|
-
|
|
4352
|
+
function handleXhr(handlerData) {
|
|
4353
|
+
if (handlerData.xhr.__sentry_own_request__) {
|
|
4354
|
+
// Taken from sentry-javascript
|
|
4355
|
+
// Only capture non-sentry requests
|
|
4319
4356
|
return null;
|
|
4320
4357
|
}
|
|
4321
4358
|
|
|
4322
|
-
|
|
4323
|
-
//
|
|
4324
|
-
|
|
4359
|
+
if (handlerData.startTimestamp) {
|
|
4360
|
+
// TODO: See if this is still needed
|
|
4361
|
+
handlerData.xhr.__sentry_xhr__ = handlerData.xhr.__sentry_xhr__ || {};
|
|
4362
|
+
handlerData.xhr.__sentry_xhr__.startTimestamp = handlerData.startTimestamp;
|
|
4363
|
+
}
|
|
4325
4364
|
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4365
|
+
if (!handlerData.endTimestamp) {
|
|
4366
|
+
return null;
|
|
4367
|
+
}
|
|
4329
4368
|
|
|
4330
|
-
|
|
4369
|
+
const { method, url, status_code: statusCode } = handlerData.xhr.__sentry_xhr__ || {};
|
|
4331
4370
|
|
|
4332
|
-
|
|
4333
|
-
} catch (e) {
|
|
4371
|
+
if (url === undefined) {
|
|
4334
4372
|
return null;
|
|
4335
4373
|
}
|
|
4374
|
+
|
|
4375
|
+
const timestamp = handlerData.xhr.__sentry_xhr__
|
|
4376
|
+
? handlerData.xhr.__sentry_xhr__.startTimestamp || 0
|
|
4377
|
+
: handlerData.endTimestamp;
|
|
4378
|
+
|
|
4379
|
+
return {
|
|
4380
|
+
type: 'resource.xhr',
|
|
4381
|
+
name: url,
|
|
4382
|
+
start: timestamp / 1000,
|
|
4383
|
+
end: handlerData.endTimestamp / 1000,
|
|
4384
|
+
data: {
|
|
4385
|
+
method,
|
|
4386
|
+
statusCode,
|
|
4387
|
+
},
|
|
4388
|
+
};
|
|
4336
4389
|
}
|
|
4337
4390
|
|
|
4338
4391
|
/**
|
|
4339
|
-
*
|
|
4392
|
+
* Returns a listener to be added to `addInstrumentationHandler('xhr', listener)`.
|
|
4340
4393
|
*/
|
|
4341
|
-
function
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
errorSampleRate,
|
|
4347
|
-
}) {
|
|
4348
|
-
// If session exists and is passed, use it instead of always hitting session storage
|
|
4349
|
-
const session = currentSession || (stickySession && fetchSession());
|
|
4394
|
+
function handleXhrSpanListener(replay) {
|
|
4395
|
+
return (handlerData) => {
|
|
4396
|
+
if (!replay.isEnabled()) {
|
|
4397
|
+
return;
|
|
4398
|
+
}
|
|
4350
4399
|
|
|
4351
|
-
|
|
4352
|
-
// If there is a session, check if it is valid (e.g. "last activity" time
|
|
4353
|
-
// should be within the "session idle time", and "session started" time is
|
|
4354
|
-
// within "max session time").
|
|
4355
|
-
const isExpired = isSessionExpired(session, expiry);
|
|
4400
|
+
const result = handleXhr(handlerData);
|
|
4356
4401
|
|
|
4357
|
-
if (
|
|
4358
|
-
return
|
|
4359
|
-
} else {
|
|
4360
|
-
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.log('[Replay] Session has expired');
|
|
4402
|
+
if (result === null) {
|
|
4403
|
+
return;
|
|
4361
4404
|
}
|
|
4362
|
-
// Otherwise continue to create a new session
|
|
4363
|
-
}
|
|
4364
4405
|
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
errorSampleRate,
|
|
4369
|
-
});
|
|
4406
|
+
if (shouldFilterRequest(replay, result.name)) {
|
|
4407
|
+
return;
|
|
4408
|
+
}
|
|
4370
4409
|
|
|
4371
|
-
|
|
4410
|
+
replay.addUpdate(() => {
|
|
4411
|
+
createPerformanceSpans(replay, [result]);
|
|
4412
|
+
// Returning true will cause `addUpdate` to not flush
|
|
4413
|
+
// We do not want network requests to cause a flush. This will prevent
|
|
4414
|
+
// recurring/polling requests from keeping the replay session alive.
|
|
4415
|
+
return true;
|
|
4416
|
+
});
|
|
4417
|
+
};
|
|
4418
|
+
}
|
|
4419
|
+
|
|
4420
|
+
/**
|
|
4421
|
+
* Add global listeners that cannot be removed.
|
|
4422
|
+
*/
|
|
4423
|
+
function addGlobalListeners(replay) {
|
|
4424
|
+
// Listeners from core SDK //
|
|
4425
|
+
const scope = core.getCurrentHub().getScope();
|
|
4426
|
+
if (scope) {
|
|
4427
|
+
scope.addScopeListener(handleScopeListener(replay));
|
|
4428
|
+
}
|
|
4429
|
+
utils.addInstrumentationHandler('dom', handleDomListener(replay));
|
|
4430
|
+
utils.addInstrumentationHandler('fetch', handleFetchSpanListener(replay));
|
|
4431
|
+
utils.addInstrumentationHandler('xhr', handleXhrSpanListener(replay));
|
|
4432
|
+
utils.addInstrumentationHandler('history', handleHistorySpanListener(replay));
|
|
4433
|
+
|
|
4434
|
+
// Tag all (non replay) events that get sent to Sentry with the current
|
|
4435
|
+
// replay ID so that we can reference them later in the UI
|
|
4436
|
+
core.addGlobalEventProcessor(handleGlobalEventListener(replay));
|
|
4372
4437
|
}
|
|
4373
4438
|
|
|
4374
4439
|
/**
|
|
@@ -4995,7 +5060,7 @@ class ReplayContainer {
|
|
|
4995
5060
|
recordingOptions,
|
|
4996
5061
|
}
|
|
4997
5062
|
|
|
4998
|
-
) {ReplayContainer.prototype.__init.call(this);ReplayContainer.prototype.__init2.call(this);ReplayContainer.prototype.__init3.call(this);ReplayContainer.prototype.__init4.call(this);ReplayContainer.prototype.__init5.call(this);ReplayContainer.prototype.__init6.call(this);ReplayContainer.prototype.__init7.call(this);ReplayContainer.prototype.__init8.call(this);ReplayContainer.prototype.__init9.call(this);ReplayContainer.prototype.__init10.call(this);ReplayContainer.prototype.__init11.call(this);ReplayContainer.prototype.__init12.call(this);ReplayContainer.prototype.__init13.call(this);ReplayContainer.prototype.__init14.call(this);ReplayContainer.prototype.__init15.call(this);ReplayContainer.prototype.__init16.call(this);
|
|
5063
|
+
) {ReplayContainer.prototype.__init.call(this);ReplayContainer.prototype.__init2.call(this);ReplayContainer.prototype.__init3.call(this);ReplayContainer.prototype.__init4.call(this);ReplayContainer.prototype.__init5.call(this);ReplayContainer.prototype.__init6.call(this);ReplayContainer.prototype.__init7.call(this);ReplayContainer.prototype.__init8.call(this);ReplayContainer.prototype.__init9.call(this);ReplayContainer.prototype.__init10.call(this);ReplayContainer.prototype.__init11.call(this);ReplayContainer.prototype.__init12.call(this);ReplayContainer.prototype.__init13.call(this);ReplayContainer.prototype.__init14.call(this);ReplayContainer.prototype.__init15.call(this);ReplayContainer.prototype.__init16.call(this);
|
|
4999
5064
|
this._recordingOptions = recordingOptions;
|
|
5000
5065
|
this._options = options;
|
|
5001
5066
|
|
|
@@ -5093,12 +5158,18 @@ class ReplayContainer {
|
|
|
5093
5158
|
* Returns true if it was stopped, else false.
|
|
5094
5159
|
*/
|
|
5095
5160
|
stopRecording() {
|
|
5096
|
-
|
|
5097
|
-
this._stopRecording
|
|
5098
|
-
|
|
5099
|
-
|
|
5161
|
+
try {
|
|
5162
|
+
if (this._stopRecording) {
|
|
5163
|
+
this._stopRecording();
|
|
5164
|
+
this._stopRecording = undefined;
|
|
5165
|
+
return true;
|
|
5166
|
+
}
|
|
5100
5167
|
|
|
5101
|
-
|
|
5168
|
+
return false;
|
|
5169
|
+
} catch (err) {
|
|
5170
|
+
this._handleException(err);
|
|
5171
|
+
return false;
|
|
5172
|
+
}
|
|
5102
5173
|
}
|
|
5103
5174
|
|
|
5104
5175
|
/**
|
|
@@ -5110,7 +5181,7 @@ class ReplayContainer {
|
|
|
5110
5181
|
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.log('[Replay] Stopping Replays');
|
|
5111
5182
|
this._isEnabled = false;
|
|
5112
5183
|
this._removeListeners();
|
|
5113
|
-
this.
|
|
5184
|
+
this.stopRecording();
|
|
5114
5185
|
this.eventBuffer && this.eventBuffer.destroy();
|
|
5115
5186
|
this.eventBuffer = null;
|
|
5116
5187
|
this._debouncedFlush.cancel();
|
|
@@ -5126,14 +5197,7 @@ class ReplayContainer {
|
|
|
5126
5197
|
*/
|
|
5127
5198
|
pause() {
|
|
5128
5199
|
this._isPaused = true;
|
|
5129
|
-
|
|
5130
|
-
if (this._stopRecording) {
|
|
5131
|
-
this._stopRecording();
|
|
5132
|
-
this._stopRecording = undefined;
|
|
5133
|
-
}
|
|
5134
|
-
} catch (err) {
|
|
5135
|
-
this._handleException(err);
|
|
5136
|
-
}
|
|
5200
|
+
this.stopRecording();
|
|
5137
5201
|
}
|
|
5138
5202
|
|
|
5139
5203
|
/**
|
|
@@ -5197,7 +5261,7 @@ class ReplayContainer {
|
|
|
5197
5261
|
}
|
|
5198
5262
|
|
|
5199
5263
|
// Otherwise... recording was never suspended, continue as normalish
|
|
5200
|
-
this.
|
|
5264
|
+
this.checkAndHandleExpiredSession();
|
|
5201
5265
|
|
|
5202
5266
|
this._updateSessionActivity();
|
|
5203
5267
|
}
|
|
@@ -5219,6 +5283,44 @@ class ReplayContainer {
|
|
|
5219
5283
|
return this.session && this.session.id;
|
|
5220
5284
|
}
|
|
5221
5285
|
|
|
5286
|
+
/**
|
|
5287
|
+
* Checks if recording should be stopped due to user inactivity. Otherwise
|
|
5288
|
+
* check if session is expired and create a new session if so. Triggers a new
|
|
5289
|
+
* full snapshot on new session.
|
|
5290
|
+
*
|
|
5291
|
+
* Returns true if session is not expired, false otherwise.
|
|
5292
|
+
* @hidden
|
|
5293
|
+
*/
|
|
5294
|
+
checkAndHandleExpiredSession({ expiry = SESSION_IDLE_DURATION } = {}) {
|
|
5295
|
+
const oldSessionId = this.getSessionId();
|
|
5296
|
+
|
|
5297
|
+
// Prevent starting a new session if the last user activity is older than
|
|
5298
|
+
// MAX_SESSION_LIFE. Otherwise non-user activity can trigger a new
|
|
5299
|
+
// session+recording. This creates noisy replays that do not have much
|
|
5300
|
+
// content in them.
|
|
5301
|
+
if (this._lastActivity && isExpired(this._lastActivity, MAX_SESSION_LIFE)) {
|
|
5302
|
+
// Pause recording
|
|
5303
|
+
this.pause();
|
|
5304
|
+
return;
|
|
5305
|
+
}
|
|
5306
|
+
|
|
5307
|
+
// --- There is recent user activity --- //
|
|
5308
|
+
// This will create a new session if expired, based on expiry length
|
|
5309
|
+
this._loadSession({ expiry });
|
|
5310
|
+
|
|
5311
|
+
// Session was expired if session ids do not match
|
|
5312
|
+
const expired = oldSessionId !== this.getSessionId();
|
|
5313
|
+
|
|
5314
|
+
if (!expired) {
|
|
5315
|
+
return true;
|
|
5316
|
+
}
|
|
5317
|
+
|
|
5318
|
+
// Session is expired, trigger a full snapshot (which will create a new session)
|
|
5319
|
+
this._triggerFullSnapshot();
|
|
5320
|
+
|
|
5321
|
+
return false;
|
|
5322
|
+
}
|
|
5323
|
+
|
|
5222
5324
|
/** A wrapper to conditionally capture exceptions. */
|
|
5223
5325
|
_handleException(error) {
|
|
5224
5326
|
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.error('[Replay]', error);
|
|
@@ -5288,19 +5390,7 @@ class ReplayContainer {
|
|
|
5288
5390
|
|
|
5289
5391
|
// There is no way to remove these listeners, so ensure they are only added once
|
|
5290
5392
|
if (!this._hasInitializedCoreListeners) {
|
|
5291
|
-
|
|
5292
|
-
const scope = core.getCurrentHub().getScope();
|
|
5293
|
-
if (scope) {
|
|
5294
|
-
scope.addScopeListener(this._handleCoreBreadcrumbListener('scope'));
|
|
5295
|
-
}
|
|
5296
|
-
utils.addInstrumentationHandler('dom', this._handleCoreBreadcrumbListener('dom'));
|
|
5297
|
-
utils.addInstrumentationHandler('fetch', handleFetchSpanListener(this));
|
|
5298
|
-
utils.addInstrumentationHandler('xhr', handleXhrSpanListener(this));
|
|
5299
|
-
utils.addInstrumentationHandler('history', handleHistorySpanListener(this));
|
|
5300
|
-
|
|
5301
|
-
// Tag all (non replay) events that get sent to Sentry with the current
|
|
5302
|
-
// replay ID so that we can reference them later in the UI
|
|
5303
|
-
core.addGlobalEventProcessor(handleGlobalEventListener(this));
|
|
5393
|
+
addGlobalListeners(this);
|
|
5304
5394
|
|
|
5305
5395
|
this._hasInitializedCoreListeners = true;
|
|
5306
5396
|
}
|
|
@@ -5347,7 +5437,7 @@ class ReplayContainer {
|
|
|
5347
5437
|
isCheckout,
|
|
5348
5438
|
) => {
|
|
5349
5439
|
// If this is false, it means session is expired, create and a new session and wait for checkout
|
|
5350
|
-
if (!this.
|
|
5440
|
+
if (!this.checkAndHandleExpiredSession()) {
|
|
5351
5441
|
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.error('[Replay] Received replay event after session expired.');
|
|
5352
5442
|
|
|
5353
5443
|
return;
|
|
@@ -5442,51 +5532,6 @@ class ReplayContainer {
|
|
|
5442
5532
|
this._doChangeToForegroundTasks(breadcrumb);
|
|
5443
5533
|
};}
|
|
5444
5534
|
|
|
5445
|
-
/**
|
|
5446
|
-
* Handler for Sentry Core SDK events.
|
|
5447
|
-
*
|
|
5448
|
-
* These events will create breadcrumb-like objects in the recording.
|
|
5449
|
-
*/
|
|
5450
|
-
__init16() {this._handleCoreBreadcrumbListener =
|
|
5451
|
-
(type) =>
|
|
5452
|
-
(handlerData) => {
|
|
5453
|
-
if (!this._isEnabled) {
|
|
5454
|
-
return;
|
|
5455
|
-
}
|
|
5456
|
-
|
|
5457
|
-
const result = breadcrumbHandler(type, handlerData);
|
|
5458
|
-
|
|
5459
|
-
if (result === null) {
|
|
5460
|
-
return;
|
|
5461
|
-
}
|
|
5462
|
-
|
|
5463
|
-
if (result.category === 'sentry.transaction') {
|
|
5464
|
-
return;
|
|
5465
|
-
}
|
|
5466
|
-
|
|
5467
|
-
if (result.category === 'ui.click') {
|
|
5468
|
-
this.triggerUserActivity();
|
|
5469
|
-
} else {
|
|
5470
|
-
this._checkAndHandleExpiredSession();
|
|
5471
|
-
}
|
|
5472
|
-
|
|
5473
|
-
this.addUpdate(() => {
|
|
5474
|
-
void addEvent(this, {
|
|
5475
|
-
type: EventType.Custom,
|
|
5476
|
-
// TODO: We were converting from ms to seconds for breadcrumbs, spans,
|
|
5477
|
-
// but maybe we should just keep them as milliseconds
|
|
5478
|
-
timestamp: (result.timestamp || 0) * 1000,
|
|
5479
|
-
data: {
|
|
5480
|
-
tag: 'breadcrumb',
|
|
5481
|
-
payload: result,
|
|
5482
|
-
},
|
|
5483
|
-
});
|
|
5484
|
-
|
|
5485
|
-
// Do not flush after console log messages
|
|
5486
|
-
return result.category === 'console';
|
|
5487
|
-
});
|
|
5488
|
-
};}
|
|
5489
|
-
|
|
5490
5535
|
/**
|
|
5491
5536
|
* Tasks to run when we consider a page to be hidden (via blurring and/or visibility)
|
|
5492
5537
|
*/
|
|
@@ -5515,7 +5560,7 @@ class ReplayContainer {
|
|
|
5515
5560
|
return;
|
|
5516
5561
|
}
|
|
5517
5562
|
|
|
5518
|
-
const isSessionActive = this.
|
|
5563
|
+
const isSessionActive = this.checkAndHandleExpiredSession({
|
|
5519
5564
|
expiry: VISIBILITY_CHANGE_TIMEOUT,
|
|
5520
5565
|
});
|
|
5521
5566
|
|
|
@@ -5537,8 +5582,12 @@ class ReplayContainer {
|
|
|
5537
5582
|
* create a new Replay event.
|
|
5538
5583
|
*/
|
|
5539
5584
|
_triggerFullSnapshot() {
|
|
5540
|
-
|
|
5541
|
-
|
|
5585
|
+
try {
|
|
5586
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.log('[Replay] Taking full rrweb snapshot');
|
|
5587
|
+
record.takeFullSnapshot(true);
|
|
5588
|
+
} catch (err) {
|
|
5589
|
+
this._handleException(err);
|
|
5590
|
+
}
|
|
5542
5591
|
}
|
|
5543
5592
|
|
|
5544
5593
|
/**
|
|
@@ -5586,43 +5635,6 @@ class ReplayContainer {
|
|
|
5586
5635
|
return Promise.all(createPerformanceSpans(this, createPerformanceEntries(entries)));
|
|
5587
5636
|
}
|
|
5588
5637
|
|
|
5589
|
-
/**
|
|
5590
|
-
* Checks if recording should be stopped due to user inactivity. Otherwise
|
|
5591
|
-
* check if session is expired and create a new session if so. Triggers a new
|
|
5592
|
-
* full snapshot on new session.
|
|
5593
|
-
*
|
|
5594
|
-
* Returns true if session is not expired, false otherwise.
|
|
5595
|
-
*/
|
|
5596
|
-
_checkAndHandleExpiredSession({ expiry = SESSION_IDLE_DURATION } = {}) {
|
|
5597
|
-
const oldSessionId = this.getSessionId();
|
|
5598
|
-
|
|
5599
|
-
// Prevent starting a new session if the last user activity is older than
|
|
5600
|
-
// MAX_SESSION_LIFE. Otherwise non-user activity can trigger a new
|
|
5601
|
-
// session+recording. This creates noisy replays that do not have much
|
|
5602
|
-
// content in them.
|
|
5603
|
-
if (this._lastActivity && isExpired(this._lastActivity, MAX_SESSION_LIFE)) {
|
|
5604
|
-
// Pause recording
|
|
5605
|
-
this.pause();
|
|
5606
|
-
return;
|
|
5607
|
-
}
|
|
5608
|
-
|
|
5609
|
-
// --- There is recent user activity --- //
|
|
5610
|
-
// This will create a new session if expired, based on expiry length
|
|
5611
|
-
this._loadSession({ expiry });
|
|
5612
|
-
|
|
5613
|
-
// Session was expired if session ids do not match
|
|
5614
|
-
const expired = oldSessionId !== this.getSessionId();
|
|
5615
|
-
|
|
5616
|
-
if (!expired) {
|
|
5617
|
-
return true;
|
|
5618
|
-
}
|
|
5619
|
-
|
|
5620
|
-
// Session is expired, trigger a full snapshot (which will create a new session)
|
|
5621
|
-
this._triggerFullSnapshot();
|
|
5622
|
-
|
|
5623
|
-
return false;
|
|
5624
|
-
}
|
|
5625
|
-
|
|
5626
5638
|
/**
|
|
5627
5639
|
* Only flush if `this.recordingMode === 'session'`
|
|
5628
5640
|
*/
|
|
@@ -5735,13 +5747,13 @@ class ReplayContainer {
|
|
|
5735
5747
|
* Flush recording data to Sentry. Creates a lock so that only a single flush
|
|
5736
5748
|
* can be active at a time. Do not call this directly.
|
|
5737
5749
|
*/
|
|
5738
|
-
|
|
5750
|
+
__init16() {this._flush = async () => {
|
|
5739
5751
|
if (!this._isEnabled) {
|
|
5740
5752
|
// This can happen if e.g. the replay was stopped because of exceeding the retry limit
|
|
5741
5753
|
return;
|
|
5742
5754
|
}
|
|
5743
5755
|
|
|
5744
|
-
if (!this.
|
|
5756
|
+
if (!this.checkAndHandleExpiredSession()) {
|
|
5745
5757
|
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.error('[Replay] Attempting to finish replay event after session expired.');
|
|
5746
5758
|
return;
|
|
5747
5759
|
}
|
|
@@ -5878,8 +5890,8 @@ class Replay {
|
|
|
5878
5890
|
flushMinDelay,
|
|
5879
5891
|
flushMaxDelay,
|
|
5880
5892
|
stickySession,
|
|
5881
|
-
sessionSampleRate:
|
|
5882
|
-
errorSampleRate:
|
|
5893
|
+
sessionSampleRate: 0,
|
|
5894
|
+
errorSampleRate: 0,
|
|
5883
5895
|
useCompression,
|
|
5884
5896
|
maskAllText: typeof maskAllText === 'boolean' ? maskAllText : !maskTextSelector,
|
|
5885
5897
|
blockAllMedia,
|