rebrowser-playwright-core
Version:
A drop-in replacement for playwright-core patched with rebrowser-patches. It allows to pass modern automation detection tests.
3 lines • 88.7 kB
JavaScript
var Ns=Object.defineProperty;var Ls=(n,t,e)=>t in n?Ns(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var L=(n,t,e)=>Ls(n,typeof t!="symbol"?t+"":t,e);function Us(n,t){const e=new Array(t.length).fill(0);return new Array(t.length).fill(0).map((s,r)=>(i,a)=>{e[r]=i/a*t[r]*1e3,n(e.reduce((l,u)=>l+u,0),1e3)})}const Tn={"&":"&","<":"<",">":">",'"':""","'":"'"};function vs(n){return n.replace(/[&<>"']/ug,t=>Tn[t])}function Fs(n){return n.replace(/[&<]/ug,t=>Tn[t])}function Ot(n,t,e){return n.find((s,r)=>{if(r===n.length-1)return!0;const i=n[r+1];return Math.abs(t(s)-e)<Math.abs(t(i)-e)})}function Sn(n){return Array.isArray(n)&&typeof n[0]=="string"}function Ms(n){return Array.isArray(n)&&Array.isArray(n[0])}class Hs{constructor(t,e,s,r,i){L(this,"_htmlCache");L(this,"_snapshots");L(this,"_index");L(this,"snapshotName");L(this,"_resources");L(this,"_snapshot");L(this,"_callId");L(this,"_screencastFrames");this._htmlCache=t,this._resources=e,this._snapshots=s,this._index=i,this._snapshot=s[i],this._callId=s[i].callId,this._screencastFrames=r,this.snapshotName=s[i].snapshotName}snapshot(){return this._snapshots[this._index]}viewport(){return this._snapshots[this._index].viewport}closestScreenshot(){var r;const{wallTime:t,timestamp:e}=this.snapshot(),s=t&&((r=this._screencastFrames[0])!=null&&r.frameSwapWallTime)?Ot(this._screencastFrames,i=>i.frameSwapWallTime,t):Ot(this._screencastFrames,i=>i.timestamp,e);return s==null?void 0:s.sha1}render(){const t=[],e=(i,a,l,u)=>{if(typeof i=="string"){l==="STYLE"||l==="style"?t.push(Gs(i)):t.push(Fs(i));return}if(Ms(i)){const d=a-i[0][0];if(d>=0&&d<=a){const h=Bs(this._snapshots[d]),p=i[0][1];if(p>=0&&p<h.length)return e(h[p],d,l,u)}}else if(Sn(i)){const[d,h,...p]=i,b=d==="NOSCRIPT"?"X-NOSCRIPT":d,y=Object.entries(h||{});t.push("<",b);const x="__playwright_current_src__",c=b==="IFRAME"||b==="FRAME",o=b==="A",f=b==="IMG",_=f&&y.some(m=>m[0]===x),g=b==="SOURCE"&&l==="PICTURE"&&(u==null?void 0:u.some(m=>m[0]===x));for(const[m,E]of y){let w=m;c&&m.toLowerCase()==="src"&&(w="__playwright_src__"),f&&m===x&&(w="src"),["src","srcset"].includes(m.toLowerCase())&&(_||g)&&(w="_"+w);let T=E;o&&m.toLowerCase()==="href"?T="link://"+E:(m.toLowerCase()==="href"||m.toLowerCase()==="src"||m===x)&&(T=Qe(E)),t.push(" ",w,'="',vs(T),'"')}t.push(">");for(const m of p)e(m,a,b,y);Ws.has(b)||t.push("</",b,">");return}else return},s=this._snapshot;return{html:this._htmlCache.getOrCompute(this,()=>{e(s.html,this._index,void 0,void 0);const a=(s.doctype?`<!DOCTYPE ${s.doctype}>`:"")+["<style>*,*::before,*::after { visibility: hidden }</style>",`<script>${js(this._callId,this.snapshotName)}<\/script>`].join("")+t.join("");return{value:a,size:a.length}}),pageId:s.pageId,frameId:s.frameId,index:this._index}}resourceByUrl(t,e){const s=this._snapshot;let r,i;for(const l of this._resources){if(typeof l._monotonicTime=="number"&&l._monotonicTime>=s.timestamp)break;l.response.status!==304&&l.request.url===t&&l.request.method===e&&(l._frameref===s.frameId?r=l:i=l)}let a=r??i;if(a&&e.toUpperCase()==="GET"){for(const l of s.resourceOverrides)if(t===l.url&&l.sha1){a={...a,response:{...a.response,content:{...a.response.content,_sha1:l.sha1}}};break}}return a}}const Ws=new Set(["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","MENUITEM","META","PARAM","SOURCE","TRACK","WBR"]);function Bs(n){if(!n._nodes){const t=[],e=s=>{if(typeof s=="string")t.push(s);else if(Sn(s)){const[,,...r]=s;for(const i of r)e(i);t.push(s)}};e(n.html),n._nodes=t}return n._nodes}function js(...n){function t(e,...s){const r=new URLSearchParams(location.search).has("isUnderTest"),i="Recorded click position in absolute coordinates did not match the center of the clicked element. This is likely due to a difference between the test runner and the trace viewer operating systems.",a=[],l=[],u=[],d=[],h=y=>{for(const x of y.querySelectorAll("[__playwright_scroll_top_]"))a.push(x);for(const x of y.querySelectorAll("[__playwright_scroll_left_]"))l.push(x);for(const x of y.querySelectorAll("[__playwright_value_]")){const c=x;c.type!=="file"&&(c.value=c.getAttribute("__playwright_value_")),x.removeAttribute("__playwright_value_")}for(const x of y.querySelectorAll("[__playwright_checked_]"))x.checked=x.getAttribute("__playwright_checked_")==="true",x.removeAttribute("__playwright_checked_");for(const x of y.querySelectorAll("[__playwright_selected_]"))x.selected=x.getAttribute("__playwright_selected_")==="true",x.removeAttribute("__playwright_selected_");for(const x of s)for(const c of y.querySelectorAll(`[__playwright_target__="${x}"]`)){const o=c.style;o.outline="2px solid #006ab1",o.backgroundColor="#6fa8dc7f",u.push(c)}for(const x of y.querySelectorAll("iframe, frame")){const c=x.getAttribute("__playwright_src__");if(!c)x.setAttribute("src",'data:text/html,<body style="background: #ddd"></body>');else{const o=new URL(e(window.location.href)),f=o.pathname.lastIndexOf("/snapshot/");f!==-1&&(o.pathname=o.pathname.substring(0,f+1)),o.pathname+=c.substring(1),x.setAttribute("src",o.toString())}}{const x=y.querySelector("body[__playwright_custom_elements__]");if(x&&window.customElements){const c=(x.getAttribute("__playwright_custom_elements__")||"").split(",");for(const o of c)window.customElements.define(o,class extends HTMLElement{})}}for(const x of y.querySelectorAll("template[__playwright_shadow_root_]")){const c=x,o=c.parentElement.attachShadow({mode:"open"});o.appendChild(c.content),c.remove(),h(o)}if("adoptedStyleSheets"in y){const x=[...y.adoptedStyleSheets];for(const c of y.querySelectorAll("template[__playwright_style_sheet_]")){const o=c,f=new CSSStyleSheet;f.replaceSync(o.getAttribute("__playwright_style_sheet_")),x.push(f)}y.adoptedStyleSheets=x}d.push(...y.querySelectorAll("canvas"))},p=()=>{window.removeEventListener("load",p);for(const c of a)c.scrollTop=+c.getAttribute("__playwright_scroll_top_"),c.removeAttribute("__playwright_scroll_top_");for(const c of l)c.scrollLeft=+c.getAttribute("__playwright_scroll_left_"),c.removeAttribute("__playwright_scroll_left_");document.styleSheets[0].disabled=!0;const y=new URL(window.location.href).searchParams,x=window.location.pathname.match(/\/page@[a-z0-9]+$/);if(y.get("pointX")&&y.get("pointY")){const c=+y.get("pointX"),o=+y.get("pointY"),f=y.has("hasInputTarget"),_=u.length>0,g=document.documentElement?[document.documentElement]:[];for(const m of _?u:g){const E=document.createElement("x-pw-pointer");if(E.style.position="fixed",E.style.backgroundColor="#f44336",E.style.width="20px",E.style.height="20px",E.style.borderRadius="10px",E.style.margin="-10px 0 0 -10px",E.style.zIndex="2147483646",E.style.display="flex",E.style.alignItems="center",E.style.justifyContent="center",_){const w=m.getBoundingClientRect(),T=w.left+w.width/2,R=w.top+w.height/2;if(E.style.left=T+"px",E.style.top=R+"px",x&&(Math.abs(T-c)>=10||Math.abs(R-o)>=10)){const A=document.createElement("x-pw-pointer-warning");A.textContent="⚠",A.style.fontSize="19px",A.style.color="white",A.style.marginTop="-3.5px",A.style.userSelect="none",E.appendChild(A),E.setAttribute("title",i)}document.documentElement.appendChild(E)}else x&&!f&&(E.style.left=c+"px",E.style.top=o+"px",document.documentElement.appendChild(E))}}if(d.length>0){let c=function(f,_){function g(){const m=document.createElement("canvas");m.width=m.width/Math.floor(m.width/24),m.height=m.height/Math.floor(m.height/24);const E=m.getContext("2d");return E.fillStyle="lightgray",E.fillRect(0,0,m.width,m.height),E.fillStyle="white",E.fillRect(0,0,m.width/2,m.height/2),E.fillRect(m.width/2,m.height/2,m.width,m.height),E.createPattern(m,"repeat")}f.fillStyle=g(),f.fillRect(0,0,_.width,_.height)};if(!x){for(const f of d){const _=f.getContext("2d");c(_,f),f.title="Playwright displays canvas contents on a best-effort basis. It doesn't support canvas elements inside an iframe yet. If this impacts your workflow, please open an issue so we can prioritize."}return}const o=new Image;o.onload=()=>{for(const f of d){const _=f.getContext("2d"),g=f.getAttribute("__playwright_bounding_rect__");if(f.removeAttribute("__playwright_bounding_rect__"),!g)continue;let m;try{m=JSON.parse(g)}catch{continue}const E=m.right>1||m.bottom>1;if(m.left>1||m.top>1){f.title="Playwright couldn't capture canvas contents because it's located outside the viewport.";continue}c(_,f),_.drawImage(o,m.left*o.width,m.top*o.height,(m.right-m.left)*o.width,(m.bottom-m.top)*o.height,0,0,f.width,f.height),r&&console.log("canvas drawn:",JSON.stringify([m.left,m.top,m.right-m.left,m.bottom-m.top].map(T=>Math.floor(T*100)))),E?f.title="Playwright couldn't capture full canvas contents because it's located partially outside the viewport.":f.title="Canvas contents are displayed on a best-effort basis based on viewport screenshots taken during test execution."}},o.onerror=()=>{for(const f of d){const _=f.getContext("2d");c(_,f),f.title="Playwright couldn't show canvas contents because the screenshot failed to load."}},o.src=location.href.replace("/snapshot","/closest-screenshot")}},b=()=>h(document);window.addEventListener("load",p),window.addEventListener("DOMContentLoaded",b)}return`
(${t.toString()})(${ze.toString()}${n.map(e=>`, "${e}"`).join("")})`}const Rn=["about:","blob:","data:","file:","ftp:","http:","https:","mailto:","sftp:","ws:","wss:"],kt="http://playwright.bloburl/#";function Qe(n){n.startsWith(kt)&&(n=n.substring(kt.length));try{const t=new URL(n);if(t.protocol==="javascript:"||t.protocol==="vbscript:")return"javascript:void(0)";const e=t.protocol==="blob:",s=t.protocol==="file:";if(!e&&!s&&Rn.includes(t.protocol))return n;const r="pw-"+t.protocol.slice(0,t.protocol.length-1);return s||(t.protocol="https:"),t.hostname=t.hostname?`${r}--${t.hostname}`:r,s&&(t.protocol="https:"),t.toString()}catch{return n}}const qs=/url\(['"]?([\w-]+:)\/\//ig;function Gs(n){return n.replace(qs,(t,e)=>!(e==="blob:")&&!(e==="file:")&&Rn.includes(e)?t:t.replace(e+"//",`https://pw-${e.slice(0,-1)}--`))}function ze(n){const t=new URL(n);return t.pathname.endsWith("/snapshot.html")?t.searchParams.get("r"):n}class Ys{constructor(t,e){L(this,"_snapshotStorage");L(this,"_resourceLoader");L(this,"_snapshotIds",new Map);this._snapshotStorage=t,this._resourceLoader=e}serveSnapshot(t,e,s){const r=this._snapshot(t.substring(9),e);if(!r)return new Response(null,{status:404});const i=r.render();return this._snapshotIds.set(s,r),new Response(i.html,{status:200,headers:{"Content-Type":"text/html; charset=utf-8"}})}async serveClosestScreenshot(t,e){const s=this._snapshot(t.substring(19),e),r=s==null?void 0:s.closestScreenshot();return r?new Response(await this._resourceLoader(r)):new Response(null,{status:404})}serveSnapshotInfo(t,e){const s=this._snapshot(t.substring(13),e);return this._respondWithJson(s?{viewport:s.viewport(),url:s.snapshot().frameUrl,timestamp:s.snapshot().timestamp,wallTime:s.snapshot().wallTime}:{error:"No snapshot found"})}_snapshot(t,e){const s=e.get("name");return this._snapshotStorage.snapshotByName(t.slice(1),s)}_respondWithJson(t){return new Response(JSON.stringify(t),{status:200,headers:{"Cache-Control":"public, max-age=31536000","Content-Type":"application/json"}})}async serveResource(t,e,s){let r;const i=this._snapshotIds.get(s);for(const y of t)if(r=i==null?void 0:i.resourceByUrl(Vs(y),e),r)break;if(!r)return new Response(null,{status:404});const a=r.response.content._sha1,l=a?await this._resourceLoader(a)||new Blob([]):new Blob([]);let u=r.response.content.mimeType;/^text\/|^application\/(javascript|json)/.test(u)&&!u.includes("charset")&&(u=`${u}; charset=utf-8`);const h=new Headers;u!=="x-unknown"&&h.set("Content-Type",u);for(const{name:y,value:x}of r.response.headers)h.set(y,x);h.delete("Content-Encoding"),h.delete("Access-Control-Allow-Origin"),h.set("Access-Control-Allow-Origin","*"),h.delete("Content-Length"),h.set("Content-Length",String(l.size)),h.set("Cache-Control","public, max-age=31536000");const{status:p}=r.response,b=p===101||p===204||p===205||p===304;return new Response(b?null:l,{headers:h,status:r.response.status,statusText:r.response.statusText})}}function Vs(n){try{const t=new URL(n);return t.hash="",t.toString()}catch{return n}}function Zs(n){const t=new Map,{files:e,stacks:s}=n;for(const r of s){const[i,a]=r;t.set(`call@${i}`,a.map(l=>({file:e[l[0]],line:l[1],column:l[2],function:l[3]})))}return t}class Ks{constructor(t){L(this,"_maxSize");L(this,"_map");L(this,"_size");this._maxSize=t,this._map=new Map,this._size=0}getOrCompute(t,e){if(this._map.has(t)){const r=this._map.get(t);return this._map.delete(t),this._map.set(t,r),r.value}const s=e();for(;this._map.size&&this._size+s.size>this._maxSize;){const[r,i]=this._map.entries().next().value;this._size-=i.size,this._map.delete(r)}return this._map.set(t,s),this._size+=s.size,s.value}}class Xs{constructor(){L(this,"_resources",[]);L(this,"_frameSnapshots",new Map);L(this,"_cache",new Ks(1e8))}addResource(t){t.request.url=Qe(t.request.url),this._resources.push(t)}addFrameSnapshot(t,e){for(const i of t.resourceOverrides)i.url=Qe(i.url);let s=this._frameSnapshots.get(t.frameId);s||(s={raw:[],renderers:[]},this._frameSnapshots.set(t.frameId,s),t.isMainFrame&&this._frameSnapshots.set(t.pageId,s)),s.raw.push(t);const r=new Hs(this._cache,this._resources,s.raw,e,s.raw.length-1);return s.renderers.push(r),r}snapshotByName(t,e){const s=this._frameSnapshots.get(t);return s==null?void 0:s.renderers.find(r=>r.snapshotName===e)}snapshotsForTest(){return[...this._frameSnapshots.keys()]}finalize(){this._resources.sort((t,e)=>(t._monotonicTime||0)-(e._monotonicTime||0))}}class An extends Error{constructor(t){super(t),this.name="TraceVersionError"}}const It=7;class $s{constructor(t,e){L(this,"_contextEntry");L(this,"_snapshotStorage");L(this,"_actionMap",new Map);L(this,"_version");L(this,"_pageEntries",new Map);L(this,"_jsHandles",new Map);L(this,"_consoleObjects",new Map);this._contextEntry=t,this._snapshotStorage=e}appendTrace(t){for(const e of t.split(`
`))this._appendEvent(e)}actions(){return[...this._actionMap.values()]}_pageEntry(t){let e=this._pageEntries.get(t);return e||(e={pageId:t,screencastFrames:[]},this._pageEntries.set(t,e),this._contextEntry.pages.push(e)),e}_appendEvent(t){if(!t)return;const e=this._modernize(JSON.parse(t));for(const s of e)this._innerAppendEvent(s)}_innerAppendEvent(t){const e=this._contextEntry;switch(t.type){case"context-options":{if(t.version>It)throw new An("The trace was created by a newer version of Playwright and is not supported by this version of the viewer. Please use latest Playwright to open the trace.");this._version=t.version,e.origin=t.origin,e.browserName=t.browserName,e.channel=t.channel,e.title=t.title,e.platform=t.platform,e.wallTime=t.wallTime,e.startTime=t.monotonicTime,e.sdkLanguage=t.sdkLanguage,e.options=t.options,e.testIdAttributeName=t.testIdAttributeName;break}case"screencast-frame":{this._pageEntry(t.pageId).screencastFrames.push(t);break}case"before":{this._actionMap.set(t.callId,{...t,type:"action",endTime:0,log:[]});break}case"input":{const s=this._actionMap.get(t.callId);s.inputSnapshot=t.inputSnapshot,s.point=t.point;break}case"log":{const s=this._actionMap.get(t.callId);if(!s)return;s.log.push({time:t.time,message:t.message});break}case"after":{const s=this._actionMap.get(t.callId);s.afterSnapshot=t.afterSnapshot,s.endTime=t.endTime,s.result=t.result,s.error=t.error,s.attachments=t.attachments,t.point&&(s.point=t.point);break}case"action":{this._actionMap.set(t.callId,{...t,log:[]});break}case"event":{e.events.push(t);break}case"stdout":{e.stdio.push(t);break}case"stderr":{e.stdio.push(t);break}case"error":{e.errors.push(t);break}case"console":{e.events.push(t);break}case"resource-snapshot":this._snapshotStorage.addResource(t.snapshot),e.resources.push(t.snapshot);break;case"frame-snapshot":this._snapshotStorage.addFrameSnapshot(t.snapshot,this._pageEntry(t.snapshot.pageId).screencastFrames);break}"pageId"in t&&t.pageId&&this._pageEntry(t.pageId),(t.type==="action"||t.type==="before")&&(e.startTime=Math.min(e.startTime,t.startTime)),(t.type==="action"||t.type==="after")&&(e.endTime=Math.max(e.endTime,t.endTime)),t.type==="event"&&(e.startTime=Math.min(e.startTime,t.time),e.endTime=Math.max(e.endTime,t.time)),t.type==="screencast-frame"&&(e.startTime=Math.min(e.startTime,t.timestamp),e.endTime=Math.max(e.endTime,t.timestamp))}_processedContextCreatedEvent(){return this._version!==void 0}_modernize(t){let e=this._version||t.version;if(e===void 0)return[t];let s=[t];for(;e<It;++e)s=this[`_modernize_${e}_to_${e+1}`].call(this,s);return s}_modernize_0_to_1(t){for(const e of t)e.type==="action"&&typeof e.metadata.error=="string"&&(e.metadata.error={error:{name:"Error",message:e.metadata.error}});return t}_modernize_1_to_2(t){var e;for(const s of t)s.type!=="frame-snapshot"||!s.snapshot.isMainFrame||(s.snapshot.viewport=((e=this._contextEntry.options)==null?void 0:e.viewport)||{width:1280,height:720});return t}_modernize_2_to_3(t){for(const e of t){if(e.type!=="resource-snapshot"||e.snapshot.request)continue;const s=e.snapshot;e.snapshot={_frameref:s.frameId,request:{url:s.url,method:s.method,headers:s.requestHeaders,postData:s.requestSha1?{_sha1:s.requestSha1}:void 0},response:{status:s.status,headers:s.responseHeaders,content:{mimeType:s.contentType,_sha1:s.responseSha1}},_monotonicTime:s.timestamp}}return t}_modernize_3_to_4(t){const e=[];for(const s of t){const r=this._modernize_event_3_to_4(s);r&&e.push(r)}return e}_modernize_event_3_to_4(t){var s,r,i,a;if(t.type!=="action"&&t.type!=="event")return t;const e=t.metadata;return e.internal||e.method.startsWith("tracing")?null:t.type==="event"?e.method==="__create__"&&e.type==="ConsoleMessage"?{type:"object",class:e.type,guid:e.params.guid,initializer:e.params.initializer}:{type:"event",time:e.startTime,class:e.type,method:e.method,params:e.params,pageId:e.pageId}:{type:"action",callId:e.id,startTime:e.startTime,endTime:e.endTime,apiName:e.apiName||e.type+"."+e.method,class:e.type,method:e.method,params:e.params,wallTime:e.wallTime||Date.now(),log:e.log,beforeSnapshot:(s=e.snapshots.find(l=>l.title==="before"))==null?void 0:s.snapshotName,inputSnapshot:(r=e.snapshots.find(l=>l.title==="input"))==null?void 0:r.snapshotName,afterSnapshot:(i=e.snapshots.find(l=>l.title==="after"))==null?void 0:i.snapshotName,error:(a=e.error)==null?void 0:a.error,result:e.result,point:e.point,pageId:e.pageId}}_modernize_4_to_5(t){const e=[];for(const s of t){const r=this._modernize_event_4_to_5(s);r&&e.push(r)}return e}_modernize_event_4_to_5(t){var e,s;if(t.type==="event"&&t.method==="__create__"&&t.class==="JSHandle"&&this._jsHandles.set(t.params.guid,t.params.initializer),t.type==="object"){if(t.class!=="ConsoleMessage")return null;const r=(e=t.initializer.args)==null?void 0:e.map(i=>{if(i.guid){const a=this._jsHandles.get(i.guid);return{preview:(a==null?void 0:a.preview)||"",value:""}}return{preview:i.preview||"",value:i.value||""}});return this._consoleObjects.set(t.guid,{type:t.initializer.type,text:t.initializer.text,location:t.initializer.location,args:r}),null}if(t.type==="event"&&t.method==="console"){const r=this._consoleObjects.get(((s=t.params.message)==null?void 0:s.guid)||"");return r?{type:"console",time:t.time,pageId:t.pageId,messageType:r.type,text:r.text,args:r.args,location:r.location}:null}return t}_modernize_5_to_6(t){const e=[];for(const s of t)if(e.push(s),!(s.type!=="after"||!s.log.length))for(const r of s.log)e.push({type:"log",callId:s.callId,message:r,time:-1});return e}_modernize_6_to_7(t){const e=[];if(!this._processedContextCreatedEvent()&&t[0].type!=="context-options"){const s={type:"context-options",origin:"testRunner",version:7,browserName:"",options:{},platform:process.platform,wallTime:0,monotonicTime:0,sdkLanguage:"javascript"};e.push(s)}for(const s of t){if(s.type==="context-options"){e.push({...s,monotonicTime:0,origin:"library"});continue}!this._contextEntry.wallTime&&s.type==="before"&&(this._contextEntry.wallTime=s.wallTime),!this._contextEntry.startTime&&s.type==="before"&&(this._contextEntry.startTime=s.startTime),e.push(s)}return e}}class Js{constructor(){L(this,"contextEntries",[]);L(this,"_snapshotStorage");L(this,"_backend");L(this,"_resourceToContentType",new Map)}async load(t,e){var l,u;this._backend=t;const s=[];let r=!1;for(const d of await this._backend.entryNames()){const h=d.match(/(.+)\.trace/);h&&s.push(h[1]||""),d.includes("src@")&&(r=!0)}if(!s.length)throw new Error("Cannot find .trace file");this._snapshotStorage=new Xs;const i=s.length*3;let a=0;for(const d of s){const h=Qs();h.traceUrl=t.traceURL(),h.hasSource=r;const p=new $s(h,this._snapshotStorage),b=await this._backend.readText(d+".trace")||"";p.appendTrace(b),e(++a,i);const y=await this._backend.readText(d+".network")||"";if(p.appendTrace(y),e(++a,i),h.actions=p.actions().sort((c,o)=>c.startTime-o.startTime),!t.isLive()){for(const c of h.actions.slice().reverse())if(!c.endTime&&!c.error)for(const o of h.actions)o.parentId===c.callId&&c.endTime<o.endTime&&(c.endTime=o.endTime)}const x=await this._backend.readText(d+".stacks");if(x){const c=Zs(JSON.parse(x));for(const o of h.actions)o.stack=o.stack||c.get(o.callId)}e(++a,i);for(const c of h.resources)(l=c.request.postData)!=null&&l._sha1&&this._resourceToContentType.set(c.request.postData._sha1,Dt(c.request.postData.mimeType)),(u=c.response.content)!=null&&u._sha1&&this._resourceToContentType.set(c.response.content._sha1,Dt(c.response.content.mimeType));this.contextEntries.push(h)}this._snapshotStorage.finalize()}async hasEntry(t){return this._backend.hasEntry(t)}async resourceForSha1(t){const e=await this._backend.readBlob("resources/"+t),s=this._resourceToContentType.get(t);return!e||s===void 0||s==="x-unknown"?e:new Blob([e],{type:s})}storage(){return this._snapshotStorage}}function Dt(n){const t=n.match(/^(.*);\s*charset=.*$/);return t?t[1]:n}function Qs(){return{origin:"testRunner",traceUrl:"",startTime:Number.MAX_SAFE_INTEGER,wallTime:Number.MAX_SAFE_INTEGER,endTime:0,browserName:"",options:{deviceScaleFactor:1,isMobile:!1,viewport:{width:1280,height:800}},pages:[],resources:[],actions:[],events:[],errors:[],stdio:[],hasSource:!1}}const zs=15,U=0,z=1,er=2,V=-2,W=-3,Pt=-4,ee=-5,Z=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],Cn=1440,tr=0,nr=4,sr=9,rr=5,ir=[96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,192,80,7,10,0,8,96,0,8,32,0,9,160,0,8,0,0,8,128,0,8,64,0,9,224,80,7,6,0,8,88,0,8,24,0,9,144,83,7,59,0,8,120,0,8,56,0,9,208,81,7,17,0,8,104,0,8,40,0,9,176,0,8,8,0,8,136,0,8,72,0,9,240,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,200,81,7,13,0,8,100,0,8,36,0,9,168,0,8,4,0,8,132,0,8,68,0,9,232,80,7,8,0,8,92,0,8,28,0,9,152,84,7,83,0,8,124,0,8,60,0,9,216,82,7,23,0,8,108,0,8,44,0,9,184,0,8,12,0,8,140,0,8,76,0,9,248,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,196,81,7,11,0,8,98,0,8,34,0,9,164,0,8,2,0,8,130,0,8,66,0,9,228,80,7,7,0,8,90,0,8,26,0,9,148,84,7,67,0,8,122,0,8,58,0,9,212,82,7,19,0,8,106,0,8,42,0,9,180,0,8,10,0,8,138,0,8,74,0,9,244,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,204,81,7,15,0,8,102,0,8,38,0,9,172,0,8,6,0,8,134,0,8,70,0,9,236,80,7,9,0,8,94,0,8,30,0,9,156,84,7,99,0,8,126,0,8,62,0,9,220,82,7,27,0,8,110,0,8,46,0,9,188,0,8,14,0,8,142,0,8,78,0,9,252,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,194,80,7,10,0,8,97,0,8,33,0,9,162,0,8,1,0,8,129,0,8,65,0,9,226,80,7,6,0,8,89,0,8,25,0,9,146,83,7,59,0,8,121,0,8,57,0,9,210,81,7,17,0,8,105,0,8,41,0,9,178,0,8,9,0,8,137,0,8,73,0,9,242,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,202,81,7,13,0,8,101,0,8,37,0,9,170,0,8,5,0,8,133,0,8,69,0,9,234,80,7,8,0,8,93,0,8,29,0,9,154,84,7,83,0,8,125,0,8,61,0,9,218,82,7,23,0,8,109,0,8,45,0,9,186,0,8,13,0,8,141,0,8,77,0,9,250,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,198,81,7,11,0,8,99,0,8,35,0,9,166,0,8,3,0,8,131,0,8,67,0,9,230,80,7,7,0,8,91,0,8,27,0,9,150,84,7,67,0,8,123,0,8,59,0,9,214,82,7,19,0,8,107,0,8,43,0,9,182,0,8,11,0,8,139,0,8,75,0,9,246,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,206,81,7,15,0,8,103,0,8,39,0,9,174,0,8,7,0,8,135,0,8,71,0,9,238,80,7,9,0,8,95,0,8,31,0,9,158,84,7,99,0,8,127,0,8,63,0,9,222,82,7,27,0,8,111,0,8,47,0,9,190,0,8,15,0,8,143,0,8,79,0,9,254,96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,193,80,7,10,0,8,96,0,8,32,0,9,161,0,8,0,0,8,128,0,8,64,0,9,225,80,7,6,0,8,88,0,8,24,0,9,145,83,7,59,0,8,120,0,8,56,0,9,209,81,7,17,0,8,104,0,8,40,0,9,177,0,8,8,0,8,136,0,8,72,0,9,241,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,201,81,7,13,0,8,100,0,8,36,0,9,169,0,8,4,0,8,132,0,8,68,0,9,233,80,7,8,0,8,92,0,8,28,0,9,153,84,7,83,0,8,124,0,8,60,0,9,217,82,7,23,0,8,108,0,8,44,0,9,185,0,8,12,0,8,140,0,8,76,0,9,249,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,197,81,7,11,0,8,98,0,8,34,0,9,165,0,8,2,0,8,130,0,8,66,0,9,229,80,7,7,0,8,90,0,8,26,0,9,149,84,7,67,0,8,122,0,8,58,0,9,213,82,7,19,0,8,106,0,8,42,0,9,181,0,8,10,0,8,138,0,8,74,0,9,245,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,205,81,7,15,0,8,102,0,8,38,0,9,173,0,8,6,0,8,134,0,8,70,0,9,237,80,7,9,0,8,94,0,8,30,0,9,157,84,7,99,0,8,126,0,8,62,0,9,221,82,7,27,0,8,110,0,8,46,0,9,189,0,8,14,0,8,142,0,8,78,0,9,253,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,195,80,7,10,0,8,97,0,8,33,0,9,163,0,8,1,0,8,129,0,8,65,0,9,227,80,7,6,0,8,89,0,8,25,0,9,147,83,7,59,0,8,121,0,8,57,0,9,211,81,7,17,0,8,105,0,8,41,0,9,179,0,8,9,0,8,137,0,8,73,0,9,243,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,203,81,7,13,0,8,101,0,8,37,0,9,171,0,8,5,0,8,133,0,8,69,0,9,235,80,7,8,0,8,93,0,8,29,0,9,155,84,7,83,0,8,125,0,8,61,0,9,219,82,7,23,0,8,109,0,8,45,0,9,187,0,8,13,0,8,141,0,8,77,0,9,251,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,199,81,7,11,0,8,99,0,8,35,0,9,167,0,8,3,0,8,131,0,8,67,0,9,231,80,7,7,0,8,91,0,8,27,0,9,151,84,7,67,0,8,123,0,8,59,0,9,215,82,7,19,0,8,107,0,8,43,0,9,183,0,8,11,0,8,139,0,8,75,0,9,247,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,207,81,7,15,0,8,103,0,8,39,0,9,175,0,8,7,0,8,135,0,8,71,0,9,239,80,7,9,0,8,95,0,8,31,0,9,159,84,7,99,0,8,127,0,8,63,0,9,223,82,7,27,0,8,111,0,8,47,0,9,191,0,8,15,0,8,143,0,8,79,0,9,255],ar=[80,5,1,87,5,257,83,5,17,91,5,4097,81,5,5,89,5,1025,85,5,65,93,5,16385,80,5,3,88,5,513,84,5,33,92,5,8193,82,5,9,90,5,2049,86,5,129,192,5,24577,80,5,2,87,5,385,83,5,25,91,5,6145,81,5,7,89,5,1537,85,5,97,93,5,24577,80,5,4,88,5,769,84,5,49,92,5,12289,82,5,13,90,5,3073,86,5,193,192,5,24577],or=[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],cr=[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,112,112],lr=[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],fr=[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],te=15;function et(){const n=this;let t,e,s,r,i,a;function l(d,h,p,b,y,x,c,o,f,_,g){let m,E,w,T,R,A,S,C,I,O,N,P,k,M,v;O=0,R=p;do s[d[h+O]]++,O++,R--;while(R!==0);if(s[0]==p)return c[0]=-1,o[0]=0,U;for(C=o[0],A=1;A<=te&&s[A]===0;A++);for(S=A,C<A&&(C=A),R=te;R!==0&&s[R]===0;R--);for(w=R,C>R&&(C=R),o[0]=C,M=1<<A;A<R;A++,M<<=1)if((M-=s[A])<0)return W;if((M-=s[R])<0)return W;for(s[R]+=M,a[1]=A=0,O=1,k=2;--R!==0;)a[k]=A+=s[O],k++,O++;R=0,O=0;do(A=d[h+O])!==0&&(g[a[A]++]=R),O++;while(++R<p);for(p=a[w],a[0]=R=0,O=0,T=-1,P=-C,i[0]=0,N=0,v=0;S<=w;S++)for(m=s[S];m--!==0;){for(;S>P+C;){if(T++,P+=C,v=w-P,v=v>C?C:v,(E=1<<(A=S-P))>m+1&&(E-=m+1,k=S,A<v))for(;++A<v&&!((E<<=1)<=s[++k]);)E-=s[k];if(v=1<<A,_[0]+v>Cn)return W;i[T]=N=_[0],_[0]+=v,T!==0?(a[T]=R,r[0]=A,r[1]=C,A=R>>>P-C,r[2]=N-i[T-1]-A,f.set(r,(i[T-1]+A)*3)):c[0]=N}for(r[1]=S-P,O>=p?r[0]=192:g[O]<b?(r[0]=g[O]<256?0:96,r[2]=g[O++]):(r[0]=x[g[O]-b]+16+64,r[2]=y[g[O++]-b]),E=1<<S-P,A=R>>>P;A<v;A+=E)f.set(r,(N+A)*3);for(A=1<<S-1;R&A;A>>>=1)R^=A;for(R^=A,I=(1<<P)-1;(R&I)!=a[T];)T--,P-=C,I=(1<<P)-1}return M!==0&&w!=1?ee:U}function u(d){let h;for(t||(t=[],e=[],s=new Int32Array(te+1),r=[],i=new Int32Array(te),a=new Int32Array(te+1)),e.length<d&&(e=[]),h=0;h<d;h++)e[h]=0;for(h=0;h<te+1;h++)s[h]=0;for(h=0;h<3;h++)r[h]=0;i.set(s.subarray(0,te),0),a.set(s.subarray(0,te+1),0)}n.inflate_trees_bits=function(d,h,p,b,y){let x;return u(19),t[0]=0,x=l(d,0,19,19,null,null,p,h,b,t,e),x==W?y.msg="oversubscribed dynamic bit lengths tree":(x==ee||h[0]===0)&&(y.msg="incomplete dynamic bit lengths tree",x=W),x},n.inflate_trees_dynamic=function(d,h,p,b,y,x,c,o,f){let _;return u(288),t[0]=0,_=l(p,0,d,257,or,cr,x,b,o,t,e),_!=U||b[0]===0?(_==W?f.msg="oversubscribed literal/length tree":_!=Pt&&(f.msg="incomplete literal/length tree",_=W),_):(u(288),_=l(p,d,h,0,lr,fr,c,y,o,t,e),_!=U||y[0]===0&&d>257?(_==W?f.msg="oversubscribed distance tree":_==ee?(f.msg="incomplete distance tree",_=W):_!=Pt&&(f.msg="empty distance tree with lengths",_=W),_):U)}}et.inflate_trees_fixed=function(n,t,e,s){return n[0]=sr,t[0]=rr,e[0]=ir,s[0]=ar,U};const ke=0,Nt=1,Lt=2,Ut=3,vt=4,Ft=5,Mt=6,qe=7,Ht=8,Ie=9;function ur(){const n=this;let t,e=0,s,r=0,i=0,a=0,l=0,u=0,d=0,h=0,p,b=0,y,x=0;function c(o,f,_,g,m,E,w,T){let R,A,S,C,I,O,N,P,k,M,v,be,D,fe,F,H;N=T.next_in_index,P=T.avail_in,I=w.bitb,O=w.bitk,k=w.write,M=k<w.read?w.read-k-1:w.end-k,v=Z[o],be=Z[f];do{for(;O<20;)P--,I|=(T.read_byte(N++)&255)<<O,O+=8;if(R=I&v,A=_,S=g,H=(S+R)*3,(C=A[H])===0){I>>=A[H+1],O-=A[H+1],w.win[k++]=A[H+2],M--;continue}do{if(I>>=A[H+1],O-=A[H+1],C&16){for(C&=15,D=A[H+2]+(I&Z[C]),I>>=C,O-=C;O<15;)P--,I|=(T.read_byte(N++)&255)<<O,O+=8;R=I&be,A=m,S=E,H=(S+R)*3,C=A[H];do if(I>>=A[H+1],O-=A[H+1],C&16){for(C&=15;O<C;)P--,I|=(T.read_byte(N++)&255)<<O,O+=8;if(fe=A[H+2]+(I&Z[C]),I>>=C,O-=C,M-=D,k>=fe)F=k-fe,k-F>0&&2>k-F?(w.win[k++]=w.win[F++],w.win[k++]=w.win[F++],D-=2):(w.win.set(w.win.subarray(F,F+2),k),k+=2,F+=2,D-=2);else{F=k-fe;do F+=w.end;while(F<0);if(C=w.end-F,D>C){if(D-=C,k-F>0&&C>k-F)do w.win[k++]=w.win[F++];while(--C!==0);else w.win.set(w.win.subarray(F,F+C),k),k+=C,F+=C,C=0;F=0}}if(k-F>0&&D>k-F)do w.win[k++]=w.win[F++];while(--D!==0);else w.win.set(w.win.subarray(F,F+D),k),k+=D,F+=D,D=0;break}else if(!(C&64))R+=A[H+2],R+=I&Z[C],H=(S+R)*3,C=A[H];else return T.msg="invalid distance code",D=T.avail_in-P,D=O>>3<D?O>>3:D,P+=D,N-=D,O-=D<<3,w.bitb=I,w.bitk=O,T.avail_in=P,T.total_in+=N-T.next_in_index,T.next_in_index=N,w.write=k,W;while(!0);break}if(C&64)return C&32?(D=T.avail_in-P,D=O>>3<D?O>>3:D,P+=D,N-=D,O-=D<<3,w.bitb=I,w.bitk=O,T.avail_in=P,T.total_in+=N-T.next_in_index,T.next_in_index=N,w.write=k,z):(T.msg="invalid literal/length code",D=T.avail_in-P,D=O>>3<D?O>>3:D,P+=D,N-=D,O-=D<<3,w.bitb=I,w.bitk=O,T.avail_in=P,T.total_in+=N-T.next_in_index,T.next_in_index=N,w.write=k,W);if(R+=A[H+2],R+=I&Z[C],H=(S+R)*3,(C=A[H])===0){I>>=A[H+1],O-=A[H+1],w.win[k++]=A[H+2],M--;break}}while(!0)}while(M>=258&&P>=10);return D=T.avail_in-P,D=O>>3<D?O>>3:D,P+=D,N-=D,O-=D<<3,w.bitb=I,w.bitk=O,T.avail_in=P,T.total_in+=N-T.next_in_index,T.next_in_index=N,w.write=k,U}n.init=function(o,f,_,g,m,E){t=ke,d=o,h=f,p=_,b=g,y=m,x=E,s=null},n.proc=function(o,f,_){let g,m,E,w=0,T=0,R=0,A,S,C,I;for(R=f.next_in_index,A=f.avail_in,w=o.bitb,T=o.bitk,S=o.write,C=S<o.read?o.read-S-1:o.end-S;;)switch(t){case ke:if(C>=258&&A>=10&&(o.bitb=w,o.bitk=T,f.avail_in=A,f.total_in+=R-f.next_in_index,f.next_in_index=R,o.write=S,_=c(d,h,p,b,y,x,o,f),R=f.next_in_index,A=f.avail_in,w=o.bitb,T=o.bitk,S=o.write,C=S<o.read?o.read-S-1:o.end-S,_!=U)){t=_==z?qe:Ie;break}i=d,s=p,r=b,t=Nt;case Nt:for(g=i;T<g;){if(A!==0)_=U;else return o.bitb=w,o.bitk=T,f.avail_in=A,f.total_in+=R-f.next_in_index,f.next_in_index=R,o.write=S,o.inflate_flush(f,_);A--,w|=(f.read_byte(R++)&255)<<T,T+=8}if(m=(r+(w&Z[g]))*3,w>>>=s[m+1],T-=s[m+1],E=s[m],E===0){a=s[m+2],t=Mt;break}if(E&16){l=E&15,e=s[m+2],t=Lt;break}if(!(E&64)){i=E,r=m/3+s[m+2];break}if(E&32){t=qe;break}return t=Ie,f.msg="invalid literal/length code",_=W,o.bitb=w,o.bitk=T,f.avail_in=A,f.total_in+=R-f.next_in_index,f.next_in_index=R,o.write=S,o.inflate_flush(f,_);case Lt:for(g=l;T<g;){if(A!==0)_=U;else return o.bitb=w,o.bitk=T,f.avail_in=A,f.total_in+=R-f.next_in_index,f.next_in_index=R,o.write=S,o.inflate_flush(f,_);A--,w|=(f.read_byte(R++)&255)<<T,T+=8}e+=w&Z[g],w>>=g,T-=g,i=h,s=y,r=x,t=Ut;case Ut:for(g=i;T<g;){if(A!==0)_=U;else return o.bitb=w,o.bitk=T,f.avail_in=A,f.total_in+=R-f.next_in_index,f.next_in_index=R,o.write=S,o.inflate_flush(f,_);A--,w|=(f.read_byte(R++)&255)<<T,T+=8}if(m=(r+(w&Z[g]))*3,w>>=s[m+1],T-=s[m+1],E=s[m],E&16){l=E&15,u=s[m+2],t=vt;break}if(!(E&64)){i=E,r=m/3+s[m+2];break}return t=Ie,f.msg="invalid distance code",_=W,o.bitb=w,o.bitk=T,f.avail_in=A,f.total_in+=R-f.next_in_index,f.next_in_index=R,o.write=S,o.inflate_flush(f,_);case vt:for(g=l;T<g;){if(A!==0)_=U;else return o.bitb=w,o.bitk=T,f.avail_in=A,f.total_in+=R-f.next_in_index,f.next_in_index=R,o.write=S,o.inflate_flush(f,_);A--,w|=(f.read_byte(R++)&255)<<T,T+=8}u+=w&Z[g],w>>=g,T-=g,t=Ft;case Ft:for(I=S-u;I<0;)I+=o.end;for(;e!==0;){if(C===0&&(S==o.end&&o.read!==0&&(S=0,C=S<o.read?o.read-S-1:o.end-S),C===0&&(o.write=S,_=o.inflate_flush(f,_),S=o.write,C=S<o.read?o.read-S-1:o.end-S,S==o.end&&o.read!==0&&(S=0,C=S<o.read?o.read-S-1:o.end-S),C===0)))return o.bitb=w,o.bitk=T,f.avail_in=A,f.total_in+=R-f.next_in_index,f.next_in_index=R,o.write=S,o.inflate_flush(f,_);o.win[S++]=o.win[I++],C--,I==o.end&&(I=0),e--}t=ke;break;case Mt:if(C===0&&(S==o.end&&o.read!==0&&(S=0,C=S<o.read?o.read-S-1:o.end-S),C===0&&(o.write=S,_=o.inflate_flush(f,_),S=o.write,C=S<o.read?o.read-S-1:o.end-S,S==o.end&&o.read!==0&&(S=0,C=S<o.read?o.read-S-1:o.end-S),C===0)))return o.bitb=w,o.bitk=T,f.avail_in=A,f.total_in+=R-f.next_in_index,f.next_in_index=R,o.write=S,o.inflate_flush(f,_);_=U,o.win[S++]=a,C--,t=ke;break;case qe:if(T>7&&(T-=8,A++,R--),o.write=S,_=o.inflate_flush(f,_),S=o.write,C=S<o.read?o.read-S-1:o.end-S,o.read!=o.write)return o.bitb=w,o.bitk=T,f.avail_in=A,f.total_in+=R-f.next_in_index,f.next_in_index=R,o.write=S,o.inflate_flush(f,_);t=Ht;case Ht:return _=z,o.bitb=w,o.bitk=T,f.avail_in=A,f.total_in+=R-f.next_in_index,f.next_in_index=R,o.write=S,o.inflate_flush(f,_);case Ie:return _=W,o.bitb=w,o.bitk=T,f.avail_in=A,f.total_in+=R-f.next_in_index,f.next_in_index=R,o.write=S,o.inflate_flush(f,_);default:return _=V,o.bitb=w,o.bitk=T,f.avail_in=A,f.total_in+=R-f.next_in_index,f.next_in_index=R,o.write=S,o.inflate_flush(f,_)}},n.free=function(){}}const Wt=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],_e=0,Ge=1,Bt=2,jt=3,qt=4,Gt=5,De=6,Pe=7,Yt=8,ue=9;function dr(n,t){const e=this;let s=_e,r=0,i=0,a=0,l;const u=[0],d=[0],h=new ur;let p=0,b=new Int32Array(Cn*3);const y=0,x=new et;e.bitk=0,e.bitb=0,e.win=new Uint8Array(t),e.end=t,e.read=0,e.write=0,e.reset=function(c,o){o&&(o[0]=y),s==De&&h.free(c),s=_e,e.bitk=0,e.bitb=0,e.read=e.write=0},e.reset(n,null),e.inflate_flush=function(c,o){let f,_,g;return _=c.next_out_index,g=e.read,f=(g<=e.write?e.write:e.end)-g,f>c.avail_out&&(f=c.avail_out),f!==0&&o==ee&&(o=U),c.avail_out-=f,c.total_out+=f,c.next_out.set(e.win.subarray(g,g+f),_),_+=f,g+=f,g==e.end&&(g=0,e.write==e.end&&(e.write=0),f=e.write-g,f>c.avail_out&&(f=c.avail_out),f!==0&&o==ee&&(o=U),c.avail_out-=f,c.total_out+=f,c.next_out.set(e.win.subarray(g,g+f),_),_+=f,g+=f),c.next_out_index=_,e.read=g,o},e.proc=function(c,o){let f,_,g,m,E,w,T,R;for(m=c.next_in_index,E=c.avail_in,_=e.bitb,g=e.bitk,w=e.write,T=w<e.read?e.read-w-1:e.end-w;;){let A,S,C,I,O,N,P,k;switch(s){case _e:for(;g<3;){if(E!==0)o=U;else return e.bitb=_,e.bitk=g,c.avail_in=E,c.total_in+=m-c.next_in_index,c.next_in_index=m,e.write=w,e.inflate_flush(c,o);E--,_|=(c.read_byte(m++)&255)<<g,g+=8}switch(f=_&7,p=f&1,f>>>1){case 0:_>>>=3,g-=3,f=g&7,_>>>=f,g-=f,s=Ge;break;case 1:A=[],S=[],C=[[]],I=[[]],et.inflate_trees_fixed(A,S,C,I),h.init(A[0],S[0],C[0],0,I[0],0),_>>>=3,g-=3,s=De;break;case 2:_>>>=3,g-=3,s=jt;break;case 3:return _>>>=3,g-=3,s=ue,c.msg="invalid block type",o=W,e.bitb=_,e.bitk=g,c.avail_in=E,c.total_in+=m-c.next_in_index,c.next_in_index=m,e.write=w,e.inflate_flush(c,o)}break;case Ge:for(;g<32;){if(E!==0)o=U;else return e.bitb=_,e.bitk=g,c.avail_in=E,c.total_in+=m-c.next_in_index,c.next_in_index=m,e.write=w,e.inflate_flush(c,o);E--,_|=(c.read_byte(m++)&255)<<g,g+=8}if((~_>>>16&65535)!=(_&65535))return s=ue,c.msg="invalid stored block lengths",o=W,e.bitb=_,e.bitk=g,c.avail_in=E,c.total_in+=m-c.next_in_index,c.next_in_index=m,e.write=w,e.inflate_flush(c,o);r=_&65535,_=g=0,s=r!==0?Bt:p!==0?Pe:_e;break;case Bt:if(E===0||T===0&&(w==e.end&&e.read!==0&&(w=0,T=w<e.read?e.read-w-1:e.end-w),T===0&&(e.write=w,o=e.inflate_flush(c,o),w=e.write,T=w<e.read?e.read-w-1:e.end-w,w==e.end&&e.read!==0&&(w=0,T=w<e.read?e.read-w-1:e.end-w),T===0)))return e.bitb=_,e.bitk=g,c.avail_in=E,c.total_in+=m-c.next_in_index,c.next_in_index=m,e.write=w,e.inflate_flush(c,o);if(o=U,f=r,f>E&&(f=E),f>T&&(f=T),e.win.set(c.read_buf(m,f),w),m+=f,E-=f,w+=f,T-=f,(r-=f)!==0)break;s=p!==0?Pe:_e;break;case jt:for(;g<14;){if(E!==0)o=U;else return e.bitb=_,e.bitk=g,c.avail_in=E,c.total_in+=m-c.next_in_index,c.next_in_index=m,e.write=w,e.inflate_flush(c,o);E--,_|=(c.read_byte(m++)&255)<<g,g+=8}if(i=f=_&16383,(f&31)>29||(f>>5&31)>29)return s=ue,c.msg="too many length or distance symbols",o=W,e.bitb=_,e.bitk=g,c.avail_in=E,c.total_in+=m-c.next_in_index,c.next_in_index=m,e.write=w,e.inflate_flush(c,o);if(f=258+(f&31)+(f>>5&31),!l||l.length<f)l=[];else for(R=0;R<f;R++)l[R]=0;_>>>=14,g-=14,a=0,s=qt;case qt:for(;a<4+(i>>>10);){for(;g<3;){if(E!==0)o=U;else return e.bitb=_,e.bitk=g,c.avail_in=E,c.total_in+=m-c.next_in_index,c.next_in_index=m,e.write=w,e.inflate_flush(c,o);E--,_|=(c.read_byte(m++)&255)<<g,g+=8}l[Wt[a++]]=_&7,_>>>=3,g-=3}for(;a<19;)l[Wt[a++]]=0;if(u[0]=7,f=x.inflate_trees_bits(l,u,d,b,c),f!=U)return o=f,o==W&&(l=null,s=ue),e.bitb=_,e.bitk=g,c.avail_in=E,c.total_in+=m-c.next_in_index,c.next_in_index=m,e.write=w,e.inflate_flush(c,o);a=0,s=Gt;case Gt:for(;f=i,!(a>=258+(f&31)+(f>>5&31));){let M,v;for(f=u[0];g<f;){if(E!==0)o=U;else return e.bitb=_,e.bitk=g,c.avail_in=E,c.total_in+=m-c.next_in_index,c.next_in_index=m,e.write=w,e.inflate_flush(c,o);E--,_|=(c.read_byte(m++)&255)<<g,g+=8}if(f=b[(d[0]+(_&Z[f]))*3+1],v=b[(d[0]+(_&Z[f]))*3+2],v<16)_>>>=f,g-=f,l[a++]=v;else{for(R=v==18?7:v-14,M=v==18?11:3;g<f+R;){if(E!==0)o=U;else return e.bitb=_,e.bitk=g,c.avail_in=E,c.total_in+=m-c.next_in_index,c.next_in_index=m,e.write=w,e.inflate_flush(c,o);E--,_|=(c.read_byte(m++)&255)<<g,g+=8}if(_>>>=f,g-=f,M+=_&Z[R],_>>>=R,g-=R,R=a,f=i,R+M>258+(f&31)+(f>>5&31)||v==16&&R<1)return l=null,s=ue,c.msg="invalid bit length repeat",o=W,e.bitb=_,e.bitk=g,c.avail_in=E,c.total_in+=m-c.next_in_index,c.next_in_index=m,e.write=w,e.inflate_flush(c,o);v=v==16?l[R-1]:0;do l[R++]=v;while(--M!==0);a=R}}if(d[0]=-1,O=[],N=[],P=[],k=[],O[0]=9,N[0]=6,f=i,f=x.inflate_trees_dynamic(257+(f&31),1+(f>>5&31),l,O,N,P,k,b,c),f!=U)return f==W&&(l=null,s=ue),o=f,e.bitb=_,e.bitk=g,c.avail_in=E,c.total_in+=m-c.next_in_index,c.next_in_index=m,e.write=w,e.inflate_flush(c,o);h.init(O[0],N[0],b,P[0],b,k[0]),s=De;case De:if(e.bitb=_,e.bitk=g,c.avail_in=E,c.total_in+=m-c.next_in_index,c.next_in_index=m,e.write=w,(o=h.proc(e,c,o))!=z)return e.inflate_flush(c,o);if(o=U,h.free(c),m=c.next_in_index,E=c.avail_in,_=e.bitb,g=e.bitk,w=e.write,T=w<e.read?e.read-w-1:e.end-w,p===0){s=_e;break}s=Pe;case Pe:if(e.write=w,o=e.inflate_flush(c,o),w=e.write,T=w<e.read?e.read-w-1:e.end-w,e.read!=e.write)return e.bitb=_,e.bitk=g,c.avail_in=E,c.total_in+=m-c.next_in_index,c.next_in_index=m,e.write=w,e.inflate_flush(c,o);s=Yt;case Yt:return o=z,e.bitb=_,e.bitk=g,c.avail_in=E,c.total_in+=m-c.next_in_index,c.next_in_index=m,e.write=w,e.inflate_flush(c,o);case ue:return o=W,e.bitb=_,e.bitk=g,c.avail_in=E,c.total_in+=m-c.next_in_index,c.next_in_index=m,e.write=w,e.inflate_flush(c,o);default:return o=V,e.bitb=_,e.bitk=g,c.avail_in=E,c.total_in+=m-c.next_in_index,c.next_in_index=m,e.write=w,e.inflate_flush(c,o)}}},e.free=function(c){e.reset(c,null),e.win=null,b=null},e.set_dictionary=function(c,o,f){e.win.set(c.subarray(o,o+f),0),e.read=e.write=f},e.sync_point=function(){return s==Ge?1:0}}const hr=32,_r=8,pr=0,Vt=1,Zt=2,Kt=3,Xt=4,$t=5,Ye=6,ye=7,Jt=12,ne=13,mr=[0,0,255,255];function wr(){const n=this;n.mode=0,n.method=0,n.was=[0],n.need=0,n.marker=0,n.wbits=0;function t(e){return!e||!e.istate?V:(e.total_in=e.total_out=0,e.msg=null,e.istate.mode=ye,e.istate.blocks.reset(e,null),U)}n.inflateEnd=function(e){return n.blocks&&n.blocks.free(e),n.blocks=null,U},n.inflateInit=function(e,s){return e.msg=null,n.blocks=null,s<8||s>15?(n.inflateEnd(e),V):(n.wbits=s,e.istate.blocks=new dr(e,1<<s),t(e),U)},n.inflate=function(e,s){let r,i;if(!e||!e.istate||!e.next_in)return V;const a=e.istate;for(s=s==nr?ee:U,r=ee;;)switch(a.mode){case pr:if(e.avail_in===0)return r;if(r=s,e.avail_in--,e.total_in++,((a.method=e.read_byte(e.next_in_index++))&15)!=_r){a.mode=ne,e.msg="unknown compression method",a.marker=5;break}if((a.method>>4)+8>a.wbits){a.mode=ne,e.msg="invalid win size",a.marker=5;break}a.mode=Vt;case Vt:if(e.avail_in===0)return r;if(r=s,e.avail_in--,e.total_in++,i=e.read_byte(e.next_in_index++)&255,((a.method<<8)+i)%31!==0){a.mode=ne,e.msg="incorrect header check",a.marker=5;break}if(!(i&hr)){a.mode=ye;break}a.mode=Zt;case Zt:if(e.avail_in===0)return r;r=s,e.avail_in--,e.total_in++,a.need=(e.read_byte(e.next_in_index++)&255)<<24&4278190080,a.mode=Kt;case Kt:if(e.avail_in===0)return r;r=s,e.avail_in--,e.total_in++,a.need+=(e.read_byte(e.next_in_index++)&255)<<16&16711680,a.mode=Xt;case Xt:if(e.avail_in===0)return r;r=s,e.avail_in--,e.total_in++,a.need+=(e.read_byte(e.next_in_index++)&255)<<8&65280,a.mode=$t;case $t:return e.avail_in===0?r:(r=s,e.avail_in--,e.total_in++,a.need+=e.read_byte(e.next_in_index++)&255,a.mode=Ye,er);case Ye:return a.mode=ne,e.msg="need dictionary",a.marker=0,V;case ye:if(r=a.blocks.proc(e,r),r==W){a.mode=ne,a.marker=0;break}if(r==U&&(r=s),r!=z)return r;r=s,a.blocks.reset(e,a.was),a.mode=Jt;case Jt:return e.avail_in=0,z;case ne:return W;default:return V}},n.inflateSetDictionary=function(e,s,r){let i=0,a=r;if(!e||!e.istate||e.istate.mode!=Ye)return V;const l=e.istate;return a>=1<<l.wbits&&(a=(1<<l.wbits)-1,i=r-a),l.blocks.set_dictionary(s,i,a),l.mode=ye,U},n.inflateSync=function(e){let s,r,i,a,l;if(!e||!e.istate)return V;const u=e.istate;if(u.mode!=ne&&(u.mode=ne,u.marker=0),(s=e.avail_in)===0)return ee;for(r=e.next_in_index,i=u.marker;s!==0&&i<4;)e.read_byte(r)==mr[i]?i++:e.read_byte(r)!==0?i=0:i=4-i,r++,s--;return e.total_in+=r-e.next_in_index,e.next_in_index=r,e.avail_in=s,u.marker=i,i!=4?W:(a=e.total_in,l=e.total_out,t(e),e.total_in=a,e.total_out=l,u.mode=ye,U)},n.inflateSyncPoint=function(e){return!e||!e.istate||!e.istate.blocks?V:e.istate.blocks.sync_point()}}function On(){}On.prototype={inflateInit(n){const t=this;return t.istate=new wr,n||(n=zs),t.istate.inflateInit(t,n)},inflate(n){const t=this;return t.istate?t.istate.inflate(t,n):V},inflateEnd(){const n=this;if(!n.istate)return V;const t=n.istate.inflateEnd(n);return n.istate=null,t},inflateSync(){const n=this;return n.istate?n.istate.inflateSync(n):V},inflateSetDictionary(n,t){const e=this;return e.istate?e.istate.inflateSetDictionary(e,n,t):V},read_byte(n){return this.next_in[n]},read_buf(n,t){return this.next_in.subarray(n,n+t)}};function gr(n){const t=this,e=new On,s=n&&n.chunkSize?Math.floor(n.chunkSize*2):128*1024,r=tr,i=new Uint8Array(s);let a=!1;e.inflateInit(),e.next_out=i,t.append=function(l,u){const d=[];let h,p,b=0,y=0,x=0;if(l.length!==0){e.next_in_index=0,e.next_in=l,e.avail_in=l.length;do{if(e.next_out_index=0,e.avail_out=s,e.avail_in===0&&!a&&(e.next_in_index=0,a=!0),h=e.inflate(r),a&&h===ee){if(e.avail_in!==0)throw new Error("inflating: bad input")}else if(h!==U&&h!==z)throw new Error("inflating: "+e.msg);if((a||h===z)&&e.avail_in===l.length)throw new Error("inflating: bad input");e.next_out_index&&(e.next_out_index===s?d.push(new Uint8Array(i)):d.push(i.subarray(0,e.next_out_index))),x+=e.next_out_index,u&&e.next_in_index>0&&e.next_in_index!=b&&(u(e.next_in_index),b=e.next_in_index)}while(e.avail_in>0||e.avail_out===0);return d.length>1?(p=new Uint8Array(x),d.forEach(function(c){p.set(c,y),y+=c.length})):p=d[0]?new Uint8Array(d[0]):new Uint8Array,p}},t.flush=function(){e.inflateEnd()}}const de=4294967295,ae=65535,br=8,yr=0,xr=99,Er=67324752,Tr=134695760,Qt=33639248,Sr=101010256,zt=101075792,Rr=117853008,pe=22,Ve=20,Ze=56,Ar=1,Cr=39169,Or=10,kr=1,Ir=21589,Dr=28789,Pr=25461,Nr=6534,en=1,Lr=6,tn=8,nn=2048,sn=16,Ur="/",$=void 0,Ue="undefined",kn="function";class rn{constructor(t){return class extends TransformStream{constructor(e,s){const r=new t(s);super({transform(i,a){a.enqueue(r.append(i))},flush(i){const a=r.flush();a&&i.enqueue(a)}})}}}}const vr=64;let In=2;try{typeof navigator!=Ue&&navigator.hardwareConcurrency&&(In=navigator.hardwareConcurrency)}catch{}const Fr={chunkSize:512*1024,maxWorkers:In,terminateWorkerTimeout:5e3,useWebWorkers:!0,useCompressionStream:!0,workerScripts:$,CompressionStreamNative:typeof CompressionStream!=Ue&&CompressionStream,DecompressionStreamNative:typeof DecompressionStream!=Ue&&DecompressionStream},oe=Object.assign({},Fr);function Dn(){return oe}function Mr(n){return Math.max(n.chunkSize,vr)}function Pn(n){const{baseURL:t,chunkSize:e,maxWorkers:s,terminateWorkerTimeout:r,useCompressionStream:i,useWebWorkers:a,Deflate:l,Inflate:u,CompressionStream:d,DecompressionStream:h,workerScripts:p}=n;if(se("baseURL",t),se("chunkSize",e),se("maxWorkers",s),se("terminateWorkerTimeout",r),se("useCompressionStream",i),se("useWebWorkers",a),l&&(oe.CompressionStream=new rn(l)),u&&(oe.DecompressionStream=new rn(u)),se("CompressionStream",d),se("DecompressionStream",h),p!==$){const{deflate:b,inflate:y}=p;if((b||y)&&(oe.workerScripts||(oe.workerScripts={})),b){if(!Array.isArray(b))throw new Error("workerScripts.deflate must be an array");oe.workerScripts.deflate=b}if(y){if(!Array.isArray(y))throw new Error("workerScripts.inflate must be an array");oe.workerScripts.inflate=y}}}function se(n,t){t!==$&&(oe[n]=t)}function Hr(){return"application/octet-stream"}const Nn=[];for(let n=0;n<256;n++){let t=n;for(let e=0;e<8;e++)t&1?t=t>>>1^3988292384:t=t>>>1;Nn[n]=t}class ve{constructor(t){this.crc=t||-1}append(t){let e=this.crc|0;for(let s=0,r=t.length|0;s<r;s++)e=e>>>8^Nn[(e^t[s])&255];this.crc=e}get(){return~this.crc}}class Ln extends TransformStream{constructor(){let t;const e=new ve;super({transform(s,r){e.append(s),r.enqueue(s)},flush(){const s=new Uint8Array(4);new DataView(s.buffer).setUint32(0,e.get()),t.value=s}}),t=this}}function Wr(n){if(typeof TextEncoder>"u"){n=unescape(encodeURIComponent(n));const t=new Uint8Array(n.length);for(let e=0;e<t.length;e++)t[e]=n.charCodeAt(e);return t}else return new TextEncoder().encode(n)}const Y={concat(n,t){if(n.length===0||t.length===0)return n.concat(t);const e=n[n.length-1],s=Y.getPartial(e);return s===32?n.concat(t):Y._shiftRight(t,s,e|0,n.slice(0,n.length-1))},bitLength(n){const t=n.length;if(t===0)return 0;const e=n[t-1];return(t-1)*32+Y.getPartial(e)},clamp(n,t){if(n.length*32<t)return n;n=n.slice(0,Math.ceil(t/32));const e=n.length;return t=t&31,e>0&&t&&(n[e-1]=Y.partial(t,n[e-1]&2147483648>>t-1,1)),n},partial(n,t,e){return n===32?t:(e?t|0:t<<32-n)+n*1099511627776},getPartial(n){return Math.round(n/1099511627776)||32},_shiftRight(n,t,e,s){for(s===void 0&&(s=[]);t>=32;t-=32)s.push(e),e=0;if(t===0)return s.concat(n);for(let a=0;a<n.length;a++)s.push(e|n[a]>>>t),e=n[a]<<32-t;const r=n.length?n[n.length-1]:0,i=Y.getPartial(r);return s.push(Y.partial(t+i&31,t+i>32?e:s.pop(),1)),s}},Fe={bytes:{fromBits(n){const e=Y.bitLength(n)/8,s=new Uint8Array(e);let r;for(let i=0;i<e;i++)i&3||(r=n[i/4]),s[i]=r>>>24,r<<=8;return s},toBits(n){const t=[];let e,s=0;for(e=0;e<n.length;e++)s=s<<8|n[e],(e&3)===3&&(t.push(s),s=0);return e&3&&t.push(Y.partial(8*(e&3),s)),t}}},Un={};Un.sha1=class{constructor(n){const t=this;t.blockSize=512,t._init=[1732584193,4023233417,2562383102,271733878,3285377520],t._key=[1518500249,1859775393,2400959708,3395469782],n?(t._h=n._h.slice(0),t._buffer=n._buffer.slice(0),t._length=n._length):t.reset()}reset(){const n=this;return n._h=n._init.slice(0),n._buffer=[],n._length=0,n}update(n){const t=this;typeof n=="string"&&(n=Fe.utf8String.toBits(n));const e=t._buffer=Y.concat(t._buffer,n),s=t._length,r=t._length=s+Y.bitLength(n);if(r>9007199254740991)throw new Error("Cannot hash more than 2^53 - 1 bits");const i=new Uint32Array(e);let a=0;for(let l=t.blockSize+s-(t.blockSize+s&t.blockSize-1);l<=r;l+=t.blockSize)t._block(i.subarray(16*a,16*(a+1))),a+=1;return e.splice(0,16*a),t}finalize(){const n=this;let t=n._buffer;const e=n._h;t=Y.concat(t,[Y.partial(1,1)]);for(let s=t.length+2;s&15;s++)t.push(0);for(t.push(Math.floor(n._length/4294967296)),t.push(n._length|0);t.length;)n._block(t.splice(0,16));return n.reset(),e}_f(n,t,e,s){if(n<=19)return t&e|~t&s;if(n<=39)return t^e^s;if(n<=59)return t&e|t&s|e&s;if(n<=79)return t^e^s}_S(n,t){return t<<n|t>>>32-n}_block(n){const t=this,e=t._h,s=Array(80);for(let d=0;d<16;d++)s[d]=n[d];let r=e[0],i=e[1],a=e[2],l=e[3],u=e[4];for(let d=0;d<=79;d++){d>=16&&(s[d]=t._S(1,s[d-3]^s[d-8]^s[d-14]^s[d-16]));const h=t._S(5,r)+t._f(d,i,a,l)+u+s[d]+t._key[Math.floor(d/20)]|0;u=l,l=a,a=t._S(30,i),i=r,r=h}e[0]=e[0]+r|0,e[1]=e[1]+i|0,e[2]=e[2]+a|0,e[3]=e[3]+l|0,e[4]=e[4]+u|0}};const vn={};vn.aes=class{constructor(n){const t=this;t._tables=[[[],[],[],[],[]],[[],[],[],[],[]]],t._tables[0][0][0]||t._precompute();const e=t._tables[0][4],s=t._tables[1],r=n.length;let i,a,l,u=1;if(r!==4&&r!==6&&r!==8)throw new Error("invalid aes key size");for(t._key=[a=n.slice(0),l=[]],i=r;i<4*r+28;i++){let d=a[i-1];(i%r===0||r===8&&i%r===4)&&(d=e[d>>>24]<<24^e[d>>16&255]<<16^e[d>>8&255]<<8^e[d&255],i%r===0&&(d=d<<8^d>>>24^u<<24,u=u<<1^(u>>7)*283)),a[i]=a[i-r]^d}for(let d=0;i;d++,i--){const h=a[d&3?i:i-4];i<=4||d<4?l[d]=h:l[d]=s[0][e[h>>>24]]^s[1][e[h>>16&255]]^s[2][e[h>>8&255]]^s[3][e[h&255]]}}encrypt(n){return this._crypt(n,0)}decrypt(n){return this._crypt(n,1)}_precompute(){const n=this._tables[0],t=t