diff --git a/package.json b/package.json index 25ab486..4441084 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "replaywebpage", "productName": "ReplayWeb.page", - "version": "1.2.0-beta.0", + "version": "1.2.0-beta.1", "description": "Serverless Web Archive Replay", "repository": "https://github.com/webrecorder/replayweb.page", "homepage": "https://replayweb.page/", @@ -9,7 +9,7 @@ "license": "AGPL-3.0-or-later", "dependencies": { "@fortawesome/fontawesome-free": "^5.13.0", - "@webrecorder/wabac": "github:webrecorder/wabac.js#develop", + "@webrecorder/wabac": "github:webrecorder/wabac.js", "bulma": "^0.9.0", "fetch-ndjson": "^1.1.0", "flexsearch": "^0.6.32", diff --git a/src/coll.js b/src/coll.js index ef9728c..33e48ee 100644 --- a/src/coll.js +++ b/src/coll.js @@ -1,4 +1,4 @@ -import { LitElement, html, css, query } from 'lit-element'; +import { LitElement, html, css } from 'lit-element'; import { wrapCss, rwpLogo, IS_APP, clickOnSpacebarPress } from './misc'; import { sourceToId, tsToDate, getPageDateTS } from './pageutils'; @@ -317,7 +317,7 @@ class Coll extends LitElement } onCollTabNav(event) { - if (event.target.id === this.tabData.view) { + if (event.target.id === this.tabData.view || event.target.id === "replay" && this.tabData.url) { this.updateTabData(event.detail.data, event.detail.replaceLoc, false); } else if (this.showSidebar && this.tabData.url) { this.updateTabData(event.detail.data, event.detail.replaceLoc, true); @@ -705,7 +705,7 @@ class Coll extends LitElement
- + ${isReplay ? html`

${dateStr}

` : html``} ${showFavIcon ? html` @@ -851,7 +851,8 @@ class Coll extends LitElement onKeyDown(event) { if (event.key === "Esc" || event.key === "Escape") { - event.target.value = this.url; + event.preventDefault(); + event.currentTarget.value = this.url; } } @@ -952,16 +953,35 @@ class Coll extends LitElement onSubmit(event) { event.preventDefault(); - const value = this.renderRoot.querySelector("input").value; - this.navigateTo(value); + const input = this.renderRoot.querySelector("input"); + if (input.value) { + this.navigateTo(input.value); + } else { + input.value = this.url; + } return false; } + onLostFocus(event) { + if (!event.currentTarget.value) { + event.currentTarget.value = this.url; + } + } + navigateTo(value) { let data; if (value.startsWith("http://") || value.startsWith("https://")) { data = {url: value}; + + if (value === this.tabData.url) { + const replay = this.renderRoot.querySelector("wr-coll-replay"); + if (replay) { + replay.refresh(); + } + return; + } + } else { if (!value.startsWith(RWP_SCHEME)) { data = {query: value, view: "pages"}; diff --git a/sw.js b/sw.js index e6880da..0367b50 100644 --- a/sw.js +++ b/sw.js @@ -30,4 +30,4 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */var P=function(){return(P=Object.assign||function(t){for(var e,r=1,i=arguments.length;r$)/g,""):"[a-zA-Z0-9-_.~%':|=+\\*@$]+")+")"},K=[{name:"url-parameter",pattern:/^:([a-zA-Z0-9-_]*[a-zA-Z0-9]{1})(<(.+?)>)?/,regex:function(t){return new RegExp(V(t[2]))}},{name:"url-parameter-splat",pattern:/^\*([a-zA-Z0-9-_]*[a-zA-Z0-9]{1})/,regex:/([^?]*)/},{name:"url-parameter-matrix",pattern:/^;([a-zA-Z0-9-_]*[a-zA-Z0-9]{1})(<(.+?)>)?/,regex:function(t){return new RegExp(";"+t[1]+"="+V(t[2]))}},{name:"query-parameter",pattern:/^(?:\?|&)(?::)?([a-zA-Z0-9-_]*[a-zA-Z0-9]{1})/},{name:"delimiter",pattern:/^(\/|\?)/,regex:function(t){return new RegExp("\\"+t[0])}},{name:"sub-delimiter",pattern:/^(!|&|-|_|\.|;)/,regex:function(t){return new RegExp(t[0])}},{name:"fragment",pattern:/^([0-9a-zA-Z]+)/,regex:function(t){return new RegExp(t[0])}}],J=function(t){return null!=t},Z={urlParamsEncoding:"default"},Q=function(){function t(t,e){if(!t)throw new Error("Missing path in Path constructor");this.path=t,this.options=P(P({},Z),e),this.tokens=function t(e,r){if(void 0===r&&(r=[]),!K.some((function(i){var n=e.match(i.pattern);return!!n&&(r.push({type:i.name,match:n[0],val:n.slice(1,2),otherVal:n.slice(2),regex:i.regex instanceof Function?i.regex(n):i.regex}),n[0].length0,this.hasSpatParam=this.tokens.filter((function(t){return/splat$/.test(t.type)})).length>0,this.hasMatrixParams=this.tokens.filter((function(t){return/matrix$/.test(t.type)})).length>0,this.hasQueryParams=this.tokens.filter((function(t){return/^query-parameter/.test(t.type)})).length>0,this.spatParams=this.getParams("url-parameter-splat"),this.urlParams=this.getParams(/^url-parameter/),this.queryParams=this.getParams("query-parameter"),this.params=this.urlParams.concat(this.queryParams),this.source=this.tokens.filter((function(t){return void 0!==t.regex})).map((function(t){return t.regex.source})).join("")}return t.createPath=function(e,r){return new t(e,r)},t.prototype.isQueryParam=function(t){return-1!==this.queryParams.indexOf(t)},t.prototype.isSpatParam=function(t){return-1!==this.spatParams.indexOf(t)},t.prototype.test=function(t,e){var r=this,i=P(P({caseSensitive:!1,strictTrailingSlash:!1},this.options),e),n=function(t,e){return e||"\\/"===t?t:t.replace(/\\\/$/,"")+"(?:\\/)?"}(this.source,i.strictTrailingSlash),s=this.urlTest(t,n+(this.hasQueryParams?"(\\?.*$|$)":"$"),i.caseSensitive,i.urlParamsEncoding);if(!s||!this.hasQueryParams)return s;var o=H(t,i.queryParams);return 0===Object.keys(o).filter((function(t){return!r.isQueryParam(t)})).length?(Object.keys(o).forEach((function(t){return s[t]=o[t]})),s):null},t.prototype.partialTest=function(t,e){var r=this,i=P(P({caseSensitive:!1,delimited:!0},this.options),e),n=function(t,e){return e?/(\/)$/.test(t)?t:t+"(\\/|\\?|\\.|;|$)":t}(this.source,i.delimited),s=this.urlTest(t,n,i.caseSensitive,i.urlParamsEncoding);if(!s)return s;if(!this.hasQueryParams)return s;var o=H(t,i.queryParams);return Object.keys(o).filter((function(t){return r.isQueryParam(t)})).forEach((function(t){return function(t,e,r){void 0===r&&(r="");var i=t[e];return t[e]=void 0===i?r:Array.isArray(i)?i.concat(r):[i,r],t}(s,t,o[t])})),s},t.prototype.build=function(t,e){var r=this;void 0===t&&(t={});var i=P(P({ignoreConstraints:!1,ignoreSearch:!1,queryParams:{}},this.options),e),n=Object.keys(t).filter((function(t){return!r.isQueryParam(t)})).reduce((function(e,n){if(!J(t[n]))return e;var s=t[n],o=r.isSpatParam(n);return"boolean"==typeof s?e[n]=s:Array.isArray(s)?e[n]=s.map((function(t){return Y(t,i.urlParamsEncoding,o)})):e[n]=Y(s,i.urlParamsEncoding,o),e}),{});if(this.urlParams.some((function(e){return!J(t[e])}))){var s=this.urlParams.filter((function(e){return!J(t[e])}));throw new Error("Cannot build path: '"+this.path+"' requires missing parameters { "+s.join(", ")+" }")}if(!i.ignoreConstraints&&!this.tokens.filter((function(t){return/^url-parameter/.test(t.type)&&!/-splat$/.test(t.type)})).every((function(t){return new RegExp("^"+V(t.otherVal[0])+"$").test(n[t.val])})))throw new Error("Some parameters of '"+this.path+"' are of invalid format");var o=this.tokens.filter((function(t){return!1===/^query-parameter/.test(t.type)})).map((function(t){return"url-parameter-matrix"===t.type?";"+t.val+"="+n[t.val[0]]:/^url-parameter/.test(t.type)?n[t.val[0]]:t.match})).join("");if(i.ignoreSearch)return o;var a=function(t,e){var r=B(e);return Object.keys(t).filter((function(e){return void 0!==t[e]})).map((function(e){return M(e,t[e],r)})).filter(Boolean).join("&")}(this.queryParams.filter((function(e){return-1!==Object.keys(t).indexOf(e)})).reduce((function(e,r){return e[r]=t[r],e}),{}),i.queryParams);return a?o+"?"+a:o},t.prototype.getParams=function(t){var e=t instanceof RegExp?function(e){return t.test(e.type)}:function(e){return e.type===t};return this.tokens.filter(e).map((function(t){return t.val[0]}))},t.prototype.urlTest=function(t,e,r,i){var n=this,s=new RegExp("^"+e,r?"":"i"),o=t.match(s);return o?this.urlParams.length?o.slice(1,this.urlParams.length+1).reduce((function(t,e,r){return t[n.urlParams[r]]=(X[i]||decodeURIComponent)(e),t}),{}):{}:null},t}(),$=r(120),tt=r.n($),et=r(31),rt=r.n(et),it=r(38),nt=r(40),st=r(1),ot=r(39);const at=new TextEncoder,ut=new Uint8Array([]);async function*ht(t){yield t}class ct extends i.PassThrough{constructor(t){super(),this.gen=t}resume(){super.resume(),this._started||(this.start(),this._started=!0)}async start(){for await(const t of this.gen)this.push(t);this.push(null)}}class lt{constructor(t,e,r,i){this.db=t,this.pageList=e,this.collId=r,this.metadata=i,this.offset=0,this.resources=[],this.textResources=[],this.indexLines=[],this.linesPerBlock=2048,this.digestsVisted={}}downloadWARC(t){const e=this;t=(t||"webarchive").split(".")[0]+".warc";const r=new ReadableStream({start(r){e.queueWARC(r,t)}});return new Response(r,{headers:{"Content-Disposition":`attachment; filename="${t}"`,"Content-Type":"application/octet-stream"}})}async queueWARC(t,e){const r=await this.getMetadata();for await(const i of this.generateWARC(e,r))t.enqueue(i);for await(const r of this.generateTextWARC(e))t.enqueue(r);t.close()}addFile(t,e,r,i=!1){const n="string"==typeof r?r:new ct(r);t.file(e,n,{compression:i?"DEFLATE":"STORE",binary:!i})}async downloadWACZ(t){const e=new tt.a;t=(t||"webarchive").split(".")[0]+".wacz";const r=await this.getMetadata(),i=r.pages;delete r.pages,this.addFile(e,"pages.csv",await Object(nt.json2csvAsync)(i),!0),this.addFile(e,"webarchive.yaml",rt.a.safeDump(r,{skipInvalid:!0}),!0),this.addFile(e,"archive/data.warc",this.generateWARC(t+"#/archive/data.warc"),!1),this.addFile(e,"archive/text.warc",this.generateTextWARC(t+"#/archive/text.warc"),!1),this.resources.length<=this.linesPerBlock?this.addFile(e,"indexes/index.cdx",this.generateCDX(),!0):(this.addFile(e,"indexes/index.cdx.gz",this.generateCompressedCDX("index.cdx.gz"),!1),this.addFile(e,"indexes/index.idx",this.generateIDX(),!0));const n=new ReadableStream({start(t){e.generateInternalStream({type:"uint8array"}).on("data",(e,r)=>{t.enqueue(e)}).on("error",e=>{console.log(e),t.close()}).on("end",()=>{t.close()}).resume()}});return new Response(n,{headers:{"Content-Disposition":`attachment; filename="${t}"`,"Content-Type":"application/zip"}})}async*generateWARC(t,e){try{let r=0;if(t){const i=await this.createWARCInfo(t,e);yield i,r+=i.length}for(const t of this.resources){t.offset=r;const e=await this.createWARCRecord(t);e?(yield e[0],r+=e[0].length,t.length=r,e.length>1&&(yield e[1],r+=e[1].length)):t.skipped=!0}}catch(t){console.warn(t)}}async*generateTextWARC(t){try{let e=0;if(t){const r=await this.createWARCInfo(t);yield r,e+=r.length}for(const t of this.textResources){t.offset=e;const r=await this.createTextWARCRecord(t);yield r,e+=r.length,t.length=e}}catch(t){console.warn(t)}}async*generateCDX(t=!1){function e(t,e,r){const i={digest:t.digest,mime:t.mime,offset:t.offset,length:t.length,filename:e,status:t.status},n=`${t.url} ${t.timestamp} ${JSON.stringify(i)}\n`;return r?[t,n]:n}try{for await(const r of this.resources)r.skipped||(yield e(r,"data.warc",t));for await(const r of this.textResources)r.mime="text/plain",r.status=200,yield e(r,"text.warc",t)}catch(t){console.warn(t)}}async*generateCompressedCDX(t){let e=0,r=null,i=0,n=null;const s=this;function o(){const o=r.result,a=o.length,u=n+" "+JSON.stringify({offset:e,length:a,filename:t});return s.indexLines.push(u),e+=a,r=null,i=0,n=null,o}for await(const[t,e]of this.generateCDX(!0))r||(r=new it.Deflate({gzip:!0})),n||(n=t.url+" "+t.timestamp),++i===this.linesPerBlock?(r.push(e,!0),yield o()):r.push(e);r&&(r.push(ut,!0),yield o())}async getMetadata(){if(this.pageList)for await(const t of this.db.resourcesByPages(this.pageList))this.resources.push(t);else this.resources=await this.db.db.getAll("resources");const t={...this.metadata};t.pages=[];const e=this.pageList?await this.db.getPages(this.pageList):await this.db.getAllPages();for(const r of e){const{url:e,ts:i,title:n,id:s,text:o,favIconUrl:a}=r,u={title:n,url:e,date:new Date(i).toISOString(),id:s};a&&(u.favIconUrl=a),t.pages.push(u),r.text&&this.textResources.push({url:e,ts:i,text:o})}return t.pageLists=await this.db.getAllCuratedByList(),t.config={useSurt:!1,decodeResponses:!1},t}async getLists(){try{const t=await this.db.getAllCuratedByList();return console.log(t),rt.a.safeDump(t,{skipInvalid:!0})}catch(t){console.log(t)}}async*generateIDX(){yield this.indexLines.join("\n")}async createWARCInfo(t,e){const r={software:"Webrecorder wabac.js/warcio.js",format:"WARC File Format 1.1",isPartOf:this.metadata.title||this.collId};e&&(r["json-metadata"]=JSON.stringify(e));const i=await st.e.createWARCInfo({filename:t,type:"warcinfo",warcVersion:"WARC/1.1"},r);return await st.f.serialize(i,{gzip:!0})}async createWARCRecord(t){const e=t.url,r=new Date(t.ts).toISOString();t.timestamp=Object(o.g)(r);const i=t.respHeaders,n=t.pageId,s={"WARC-Page-ID":n};t.extraOpts&&Object.keys(t.extraOpts).length&&(s["WARC-JSON-Metadata"]=JSON.stringify(t.extraOpts)),t.digest&&(s["WARC-Payload-Digest"]=t.digest);let a,u,h=t.payload,c=null;const l=this.digestsVisted[t.digest];if(t.digest&&l){if(e===this.lastUrl&&n===this.lastPageId)return null;c="revisit",t.mime="warc/revisit",h=ut,a=l.url,u=l.date}else if(t.origURL&&t.origTS){if(!t.digest)return null;c="revisit",t.mime="warc/revisit",h=ut,a=t.origURL,u=t.origTS}else{if(c="response",h||(h=await this.db.loadPayload(t)),!h)return null;this.digestsVisted[t.digest]={url:e,date:r}}const d=t.status||200,f=`HTTP/1.1 ${d} ${t.statusText||Object(ot.getStatusText)(d)}`,p=await st.e.create({url:e,date:r,type:c,warcVersion:"WARC/1.1",warcHeaders:s,statusline:f,httpHeaders:i,refersToUrl:a,refersToDate:u},ht(h)),m=await st.f.serialize(p,{gzip:!0});t.digest||(t.digest=p.warcPayloadDigest),this.lastPageId=n,this.lastUrl=e;const w=[m];if(t.reqHeaders){const i={"WARC-Page-ID":n,"WARC-Concurrent-To":p.warcHeader("WARC-Record-ID")},s=t.method||"GET",o=new URL(e),a=s+" "+e.slice(o.origin.length),u=await st.e.create({url:e,date:r,warcVersion:"WARC/1.1",type:"request",warcHeaders:i,httpHeaders:t.reqHeaders,statusline:a},ht(new Uint8Array([])));w.push(await st.f.serialize(u,{gzip:!0}))}return w}async createTextWARCRecord(t){const e=new Date(t.ts).toISOString(),r=Object(o.g)(e);t.timestamp=r;const i=`urn:text:${r}/${t.url}`;t.url=i;const n=ht(at.encode(t.text)),s=await st.e.create({url:i,date:e,warcHeaders:{"Content-Type":'text/plain; charset="UTF-8"'},warcVersion:"WARC/1.1",type:"resource"},n),a=await st.f.serialize(s,{gzip:!0});return t.digest||(t.digest=s.warcPayloadDigest),a}}class dt{constructor(t){this.routes={};for(const[e,r]of Object.entries(t)){let t,i;r instanceof Array?(t=r[0],i=r[1]||"GET"):(t=r,i="GET"),this.routes[i]=this.routes[i]||{},this.routes[i][e]=new Q(t)}}match(t,e="GET"){for(const[r,i]of Object.entries(this.routes[e]||[])){const e=t.split("?",2),n=e[0],s=i.test(n);if(s)return s._route=r,s._query=new URLSearchParams(2===e.length?e[1]:""),s}return{_route:null}}}class ft{constructor(t){this.router=new dt({index:"index",coll:":coll",urls:":coll/urls",deleteColl:[":coll","DELETE"],updateAuth:[":coll/updateAuth","POST"],updateMetadata:[":coll/metadata","POST"],curated:":coll/curated/:list",pages:":coll/pages",textIndex:":coll/textIndex",deletePage:[":coll/page/:page","DELETE"],downloadPages:":coll/dl"}),this.collections=t}async apiResponse(t,e,r){const i=await this.handleApi(t,e,r);if(i instanceof Response)return i;const n=i.error?404:200;return this.makeResponse(i,n)}getCollData(t){const e=t.config.metadata?t.config.metadata:{};return{title:e.title||"",desc:e.desc||"",size:e.size||0,filename:t.config.sourceName,sourceUrl:t.config.sourceUrl,id:t.name,ctime:t.config.ctime,onDemand:t.config.onDemand}}async handleApi(t,e,r){let i,n,s,o,a=this.router.match(t,e);switch(a._route){case"index":return await this.listAll();case"coll":if(i=await this.collections.getColl(a.coll),!i)return{error:"collection_not_found"};const t=this.getCollData(i);return"1"===a._query.get("all")?(t.pages=await i.store.getAllPages(),i.store.db?(t.lists=await i.store.db.getAll("pageLists"),t.curatedPages=await i.store.db.getAll("curatedPages")):(t.lists=[],t.curatedPages=[])):(t.numLists=await i.store.db.count("pageLists"),t.numPages=await i.store.db.count("pages")),t;case"deleteColl":return await this.collections.deleteColl(a.coll)?await this.listAll():{error:"collection_not_found"};case"updateAuth":return o=await r.json(),{success:await this.collections.updateAuth(a.coll,o.headers)};case"updateMetadata":return o=await r.json(),{metadata:await this.collections.updateMetadata(a.coll,o)};case"urls":if(i=await this.collections.getColl(a.coll),!i)return{error:"collection_not_found"};const e=a._query.get("url");n=Number(a._query.get("count")||100);const u=a._query.get("mime"),h="1"===a._query.get("prefix"),c=a._query.get("fromUrl"),l=a._query.get("fromTs"),d=a._query.get("fromMime"),f=Number(a._query.get("fromStatus")||0);return i.store.resourcesByMime?(s=e?await i.store.resourcesByUrlAndMime(e,u,n,h,c,l):await i.store.resourcesByMime(u,n,d,c,f),{urls:s}):{urls:[]};case"pages":if(i=await this.collections.getColl(a.coll),!i)return{error:"collection_not_found"};return{pages:await i.store.getAllPages()};case"textIndex":return i=await this.collections.getColl(a.coll),i?i.store.getTextIndex?await i.store.getTextIndex():{}:{error:"collection_not_found"};case"curated":if(i=await this.collections.getColl(a.coll),!i)return{error:"collection_not_found"};const p=Number(a.list);return{curated:await i.store.db.getAllFromIndex("curatedPages","listPages",IDBKeyRange.bound([p],[p+1]))};case"deletePage":if(i=await this.collections.getColl(a.coll),!i)return{error:"collection_not_found"};const{pageSize:m,deleteSize:w}=i.store.deletePage(a.page);return this.collections.updateSize(a.coll,m,w),{pageSize:m,deleteSize:w};case"downloadPages":if(i=await this.collections.getColl(a.coll),!i)return{error:"collection_not_found"};const g=a._query.get("pages"),y="all"===g?null:g.split(","),_=new lt(i.store,y,a.coll,i.config.metadata),b=a._query.get("format")||"wacz";let E=a._query.get("filename");return!E&&i.config.metadata.title&&(E=i.config.metadata.title.toLowerCase().replace(/\s/g,"-")),E||(E="webarchive"),"wacz"===b?_.downloadWACZ(E):"warc"===b?_.downloadWARC(E):{error:"invalid 'format': must be wacz or warc"};default:return{error:"not_found"}}}async listAll(){const t=await this.collections.listAll(),e=[];return t.forEach(t=>{"live"!==t.type&&"remoteproxy"!==t.type&&e.push(this.getCollData(t))}),{colls:e}}makeResponse(t,e=200){return new Response(JSON.stringify(t),{status:e,headers:{"Content-Type":"application/json"}})}}class pt extends O.CollectionLoader{constructor(t,e=null){super(),this.prefixes=t,this.colls=null,this.inited=null,this.root=e}_createCollection(t){return new N(t,this.prefixes)}loadAll(t){return this.colls={},this.inited=super.loadAll(t),this.inited}async getColl(t){return this.colls[t]||(this.colls[t]=await this.loadColl(t)),this.colls[t]}async deleteColl(t){return this.colls[t]&&await this.colls[t].store.delete(),await super.deleteColl(t),delete this.colls[t],!0}async updateAuth(t,e){this.colls[t]&&this.colls[t].store.updateHeaders&&this.colls[t].store.updateHeaders(e),await super.updateAuth(t,e)}async updateMetadata(t,e){const r=await super.updateMetadata(t,e);return this.colls[t]&&r&&(this.colls[t].config.metadata=r,this.colls[t].metadata=r),r}}class mt{constructor(t=null){this.prefix=self.registration?self.registration.scope:"",this.replayPrefix=this.prefix;const e=new URLSearchParams(self.location.search);let r="wabac";e.has("replayPrefix")&&(r=e.get("replayPrefix")),r&&(this.replayPrefix+=r+"/"),this.staticPrefix=this.prefix+"static/",this.distPrefix=this.prefix+"dist/";const i={static:this.staticPrefix,root:this.prefix,main:this.replayPrefix};this.staticData=t||new Map,this.staticData.set(this.staticPrefix+"wombat.js",{type:"application/javascript",content:'/*! wombat.js is part of Webrecorder project. Copyright (C) 2020, Webrecorder Software. Licensed under the Affero General Public License v3. */\n!function(t,e){for(var r in e)t[r]=e[r]}(self,function(t){var e={};function r(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(i,o,function(e){return t[e]}.bind(null,o));return i},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="/dist/",r(r.s=183)}({183:function(module,__webpack_exports__,__webpack_require__){"use strict";function FuncMap(){this._map=[]}function ensureNumber(t){try{switch(typeof t){case"number":case"bigint":return t}var e=Number(t);return isNaN(e)?null:e}catch(t){}return null}function addToStringTagToClass(t,e){void 0!==self.Symbol&&void 0!==self.Symbol.toStringTag&&Object.defineProperty(t.prototype,self.Symbol.toStringTag,{value:e,enumerable:!1})}function autobind(t){for(var e,r,i=t.__proto__||t.constructor.prototype||t.prototype,o=Object.getOwnPropertyNames(i),n=o.length,s=0;s=0?this._map.splice(e,1)[0][1]:null},FuncMap.prototype.map=function(t){for(var e=0;e0&&e.preserveMedia(r)}))},AutoFetcher.prototype.terminate=function(){this.worker.terminate()},AutoFetcher.prototype.justFetch=function(t){this.worker.postMessage({type:"fetch-all",values:t})},AutoFetcher.prototype.fetchAsPage=function(t,e,r){if(t){var i={"X-Wombat-History-Page":e};if(r){var o=encodeURIComponent(r.trim());r&&(i["X-Wombat-History-Title"]=o)}var n={url:t,options:{headers:i,cache:"no-store"}};this.justFetch([n])}},AutoFetcher.prototype.postMessage=function(t,e){if(e){var r=this;Promise.resolve().then((function(){r.worker.postMessage(t)}))}else this.worker.postMessage(t)},AutoFetcher.prototype.preserveSrcset=function(t,e){this.postMessage({type:"values",srcset:{value:t,mod:e,presplit:!0}},!0)},AutoFetcher.prototype.preserveDataSrcset=function(t){this.postMessage({type:"values",srcset:{value:t.dataset.srcset,mod:this.rwMod(t),presplit:!1}},!0)},AutoFetcher.prototype.preserveMedia=function(t){this.postMessage({type:"values",media:t},!0)},AutoFetcher.prototype.getSrcset=function(t){return this.wombat.wb_getAttribute?this.wombat.wb_getAttribute.call(t,"srcset"):t.getAttribute("srcset")},AutoFetcher.prototype.rwMod=function(t){switch(t.tagName){case"SOURCE":return t.parentElement&&"PICTURE"===t.parentElement.tagName?"im_":"oe_";case"IMG":return"im_"}return"oe_"},AutoFetcher.prototype.extractFromLocalDoc=function(){var t=this;Promise.resolve().then((function(){for(var e={type:"values",context:{docBaseURI:document.baseURI}},r=[],i=0,o=document.styleSheets;i=0},Wombat.prototype.isString=function(t){return null!=t&&Object.getPrototypeOf(t)===String.prototype},Wombat.prototype.isSavedSrcSrcset=function(t){switch(t.tagName){case"IMG":case"VIDEO":case"AUDIO":return!0;case"SOURCE":if(!t.parentElement)return!1;switch(t.parentElement.tagName){case"PICTURE":case"VIDEO":case"AUDIO":return!0;default:return!1}default:return!1}},Wombat.prototype.isSavedDataSrcSrcset=function(t){return!(!t.dataset||null==t.dataset.srcset)&&this.isSavedSrcSrcset(t)},Wombat.prototype.isHostUrl=function(t){if(0===t.indexOf("www."))return!0;var e=t.match(this.hostnamePortRe);return!!(e&&e[0].length<64)||!!(e=t.match(this.ipPortRe))&&e[0].length<64},Wombat.prototype.isArgumentsObj=function(t){if(!t||"function"!=typeof t.toString)return!1;try{return"[object Arguments]"===this.utilFns.objToString.call(t)}catch(t){return!1}},Wombat.prototype.deproxyArrayHandlingArgumentsObj=function(t){if(!t||t instanceof NodeList||!t.length)return t;for(var e=this.isArgumentsObj(t)?new Array(t.length):t,r=0;r=0||t.indexOf("text/template")>=0)},Wombat.prototype.skipWrapScriptTextBasedOnText=function(t){if(!t||t.indexOf(this.WB_ASSIGN_FUNC)>=0||0===t.indexOf("<"))return!0;for(var e=["window","self","document","location","top","parent","frames","opener"],r=0;r=0)return!1;return!0},Wombat.prototype.nodeHasChildren=function(t){if(!t)return!1;if("function"==typeof t.hasChildNodes)return t.hasChildNodes();var e=t.children||t.childNodes;return!!e&&e.length>0},Wombat.prototype.rwModForElement=function(t,e){if(t){var r="mp_";if("LINK"===t.tagName&&"href"===e){if(t.rel){var i=t.rel.trim().toLowerCase(),o=this.wb_getAttribute.call(t,"as");if(o&&null!=this.linkTagMods.linkRelToAs[i])r=this.linkTagMods.linkRelToAs[i][o.toLowerCase()];else null!=this.linkTagMods[i]&&(r=this.linkTagMods[i])}}else{var n=this.tagToMod[t.tagName];null!=n&&(r=n[e])}return r}},Wombat.prototype.removeWBOSRC=function(t){"SCRIPT"!==t.tagName||t.__$removedWBOSRC$__||(t.hasAttribute("__wb_orig_src")&&t.removeAttribute("__wb_orig_src"),t.__$removedWBOSRC$__=!0)},Wombat.prototype.retrieveWBOSRC=function(t){var e;if("SCRIPT"===t.tagName&&!t.__$removedWBOSRC$__)return null==(e=this.wb_getAttribute?this.wb_getAttribute.call(t,"__wb_orig_src"):t.getAttribute("__wb_orig_src"))&&(t.__$removedWBOSRC$__=!0),e},Wombat.prototype.wrapScriptTextJsProxy=function(t){return\'var _____WB$wombat$assign$function_____ = function(name) {return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name)) || self[name]; };\\nif (!self.__WB_pmw) { self.__WB_pmw = function(obj) { this.__WB_source = obj; return this; } }\\n{\\nlet window = _____WB$wombat$assign$function_____("window");\\nlet self = _____WB$wombat$assign$function_____("self");\\nlet document = _____WB$wombat$assign$function_____("document");\\nlet location = _____WB$wombat$assign$function_____("location");\\nlet top = _____WB$wombat$assign$function_____("top");\\nlet parent = _____WB$wombat$assign$function_____("parent");\\nlet frames = _____WB$wombat$assign$function_____("frames");\\nlet opener = _____WB$wombat$assign$function_____("opener");\\n\'+t.replace(this.DotPostMessageRe,".__WB_pmw(self.window)$1")+"\\n\\n}"},Wombat.prototype.watchElem=function(t,e){if(!this.$wbwindow.MutationObserver)return!1;new this.$wbwindow.MutationObserver((function(t,r){for(var i=0;i"},Wombat.prototype.getFinalUrl=function(t,e,r){var i=t?this.wb_rel_prefix:this.wb_abs_prefix;return null==e&&(e=this.wb_info.mod),this.wb_info.is_live||(i+=this.wb_info.wombat_ts),"/"!==(i+=e)[i.length-1]&&(i+="/"),i+r},Wombat.prototype.resolveRelUrl=function(t,e){var r=e||this.$wbwindow.document,i=this.makeParser(r.baseURI,r),o=i.href.lastIndexOf("#"),n=o>=0?i.href.substring(0,o):i.href,s=n.lastIndexOf("/");return s>=0&&s!==n.length-1?i.href=n.substring(0,s+1)+t:i.href=n+t,i.href},Wombat.prototype.extractOriginalURL=function(t){if(!t)return"";if(this.wb_is_proxy)return t;var e,r=t.toString(),i=r;if(this.startsWithOneOf(i,this.IGNORE_PREFIXES))return i;e=this.startsWith(i,this.wb_abs_prefix)?this.wb_abs_prefix.length:this.wb_rel_prefix&&this.startsWith(i,this.wb_rel_prefix)?this.wb_rel_prefix.length:this.wb_rel_prefix?1:0;var o=i.indexOf("/http",e);return o<0&&(o=i.indexOf("///",e)),o<0&&(o=i.indexOf("/blob:",e)),o<0&&(o=i.indexOf("/about:blank",e)),o>=0?i=i.substr(o+1):((o=i.indexOf(this.wb_replay_prefix))>=0&&(i=i.substr(o+this.wb_replay_prefix.length)),i.length>4&&"_"===i.charAt(2)&&"/"===i.charAt(3)&&(i=i.substr(4)),i===r||this.startsWithOneOf(i,this.VALID_PREFIXES)||this.startsWith(i,"blob:")||(i=this.wb_orig_scheme+i)),"/"===r.charAt(0)&&"/"!==r.charAt(1)&&this.startsWith(i,this.wb_orig_origin)&&(i=i.substr(this.wb_orig_origin.length)),this.startsWith(i,this.REL_PREFIX)?this.wb_info.wombat_scheme+":"+i:i},Wombat.prototype.makeParser=function(t,e){var r=this.extractOriginalURL(t),i=e;return e||(i="about:blank"===this.$wbwindow.location.href&&this.$wbwindow.opener?this.$wbwindow.opener.document:this.$wbwindow.document),this._makeURLParser(r,i)},Wombat.prototype._makeURLParser=function(t,e){try{return new this.$wbwindow.URL(t,e.baseURI)}catch(t){}var r=e.createElement("a");return r._no_rewrite=!0,r.href=t,r},Wombat.prototype.defProp=function(t,e,r,i,o){var n=Object.getOwnPropertyDescriptor(t,e);if(n&&!n.configurable)return!1;if(!i)return!1;var s={configurable:!0,enumerable:o||!1,get:i};r&&(s.set=r);try{return Object.defineProperty(t,e,s),!0}catch(t){return console.warn("Failed to redefine property %s",e,t.message),!1}},Wombat.prototype.defGetterProp=function(t,e,r,i){var o=Object.getOwnPropertyDescriptor(t,e);if(o&&!o.configurable)return!1;if(!r)return!1;try{return Object.defineProperty(t,e,{configurable:!0,enumerable:i||!1,get:r}),!0}catch(t){return console.warn("Failed to redefine property %s",e,t.message),!1}},Wombat.prototype.getOrigGetter=function(t,e){var r;if(t.__lookupGetter__&&(r=t.__lookupGetter__(e)),!r&&Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(t,e);i&&(r=i.get)}return r},Wombat.prototype.getOrigSetter=function(t,e){var r;if(t.__lookupSetter__&&(r=t.__lookupSetter__(e)),!r&&Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(t,e);i&&(r=i.set)}return r},Wombat.prototype.getAllOwnProps=function(t){for(var e=[],r=Object.getOwnPropertyNames(t),i=0;i "+n),r.href=n}}},Wombat.prototype.checkLocationChange=function(t,e){var r=typeof t,i=e?this.$wbwindow.__WB_replay_top.location:this.$wbwindow.location;"string"===r?this.updateLocation(t,i.href,i):"object"===r&&this.updateLocation(t.href,t._orig_href,i)},Wombat.prototype.checkAllLocations=function(){if(this.wb_wombat_updating)return!1;this.wb_wombat_updating=!0,this.checkLocationChange(this.$wbwindow.WB_wombat_location,!1),this.$wbwindow.WB_wombat_location!=this.$wbwindow.__WB_replay_top.WB_wombat_location&&this.checkLocationChange(this.$wbwindow.__WB_replay_top.WB_wombat_location,!0),this.wb_wombat_updating=!1},Wombat.prototype.proxyToObj=function(t){if(t)try{var e=t.__WBProxyRealObj__;if(e)return e}catch(t){}return t},Wombat.prototype.objToProxy=function(t){if(t)try{var e=t._WB_wombat_obj_proxy;if(e)return e}catch(t){}return t},Wombat.prototype.defaultProxyGet=function(t,e,r,i){switch(e){case"__WBProxyRealObj__":return t;case"location":case"WB_wombat_location":return t.WB_wombat_location;case"_WB_wombat_obj_proxy":return t._WB_wombat_obj_proxy;case"__WB_pmw":case"WB_wombat_eval":case this.WB_ASSIGN_FUNC:case this.WB_CHECK_THIS_FUNC:return t[e];case"origin":return t.WB_wombat_location.origin;case"constructor":if(t.constructor===Window)return t.constructor}var o=t[e],n=typeof o;if("function"===n&&-1!==r.indexOf(e)){switch(e){case"requestAnimationFrame":case"cancelAnimationFrame":if(!this.isNativeFunction(o))return o}var s=i[e];return s&&s.original===o||(s={original:o,boundFn:o.bind(t)},i[e]=s),s.boundFn}return"object"===n&&o&&o._WB_wombat_obj_proxy?(o instanceof Window&&this.initNewWindowWombat(o),o._WB_wombat_obj_proxy):o},Wombat.prototype.setLoc=function(t,e){var r=this.makeParser(e,t.ownerDocument);t._orig_href=e,t._parser=r;var i=r.href;t._hash=r.hash,t._href=i,t._host=r.host,t._hostname=r.hostname,r.origin?t._origin=r.host?r.origin:"null":t._origin=r.protocol+"//"+r.hostname+(r.port?":"+r.port:""),t._pathname=r.pathname,t._port=r.port,t._protocol=r.protocol,t._search=r.search,Object.defineProperty||(t.href=i,t.hash=r.hash,t.host=t._host,t.hostname=t._hostname,t.origin=t._origin,t.pathname=t._pathname,t.port=t._port,t.protocol=t._protocol,t.search=t._search)},Wombat.prototype.makeGetLocProp=function(t,e){var r=this;return function(){if(this._no_rewrite)return e.call(this,t);var i=e.call(this,"href");return"href"===t?r.extractOriginalURL(i):"ancestorOrigins"===t?[]:(this._orig_href!==i&&r.setLoc(this,i),this["_"+t])}},Wombat.prototype.makeSetLocProp=function(t,e,r){var i=this;return function(o){if(this._no_rewrite)return e.call(this,t,o);if(this["_"+t]!==o){if(this["_"+t]=o,!this._parser){var n=r.call(this);this._parser=i.makeParser(n,this.ownerDocument)}var s=!1;"href"===t&&"string"==typeof o&&o&&("."===o[0]?o=i.resolveRelUrl(o,this.ownerDocument):"/"===o[0]&&(o.length<=1||"/"!==o[1])&&(s=!0,o=WB_wombat_location.origin+o));try{this._parser[t]=o}catch(e){console.log("Error setting "+t+" = "+o)}"hash"===t?(o=this._parser[t],e.call(this,"hash",o)):(s=s||o===this._parser.pathname,o=i.rewriteUrl(this._parser.href,s),e.call(this,"href",o))}}},Wombat.prototype.styleReplacer=function(t,e,r,i,o,n){return e+this.rewriteUrl(r)+i},Wombat.prototype.domConstructorErrorChecker=function(t,e,r,i){var o,n="number"==typeof i?i:1;if(t instanceof Window?o="Failed to construct \'"+e+"\': Please use the \'new\' operator, this DOM object constructor cannot be called as a function.":r&&r.length=0)return o;if(0===o.indexOf(this.wb_rel_prefix)&&o.indexOf("http")>1){var w=o.indexOf(":/");return w>0&&"/"!==o[w+2]?o.substring(0,w+2)+"/"+o.substring(w+2):o}return this.getFinalUrl(!0,r,this.wb_orig_origin+o)}"."===o.charAt(0)&&(o=this.resolveRelUrl(o,i));var h=this.startsWithOneOf(o.toLowerCase(),this.VALID_PREFIXES);if(h){var p=this.$wbwindow.__WB_replay_top.location.host,c=this.$wbwindow.__WB_replay_top.location.protocol,l=h+p+"/";if(this.startsWith(o,l)){if(this.startsWith(o,this.wb_replay_prefix))return o;var _=c+"//",u=o.substring(l.length),d=!1;return u.indexOf(this.wb_rel_prefix)<0&&o.indexOf("/static/")<0&&(u=this.getFinalUrl(!0,r,WB_wombat_location.origin+"/"+u),d=!0),h!==_&&h!==this.REL_PREFIX&&(d=!0),d&&(o=e?"":_+p,u&&"/"!==u[0]&&(o+="/"),o+=u),o}return this.getFinalUrl(e,r,o)}return(h=this.startsWithOneOf(o,this.BAD_PREFIXES))?this.getFinalUrl(e,r,this.extractOriginalURL(o)):this.isHostUrl(o)&&!this.startsWith(o,a.host+"/")?this.getFinalUrl(e,r,this.wb_orig_scheme+o):o},Wombat.prototype.rewriteUrl=function(t,e,r,i){var o=this.rewriteUrl_(t,e,r,i);return this.debug_rw&&(t!==o?console.log("REWRITE: "+t+" -> "+o):console.log("NOT REWRITTEN "+t)),o},Wombat.prototype.performAttributeRewrite=function(t,e,r,i){switch(e){case"innerHTML":case"outerHTML":return this.rewriteHtml(r);case"filter":return this.rewriteInlineStyle(r);case"style":return this.rewriteStyle(r);case"srcset":return this.rewriteSrcset(r,t)}if(i&&!this.startsWithOneOf(r,this.VALID_PREFIXES))return r;var o=this.rwModForElement(t,e);return this.wbUseAFWorker&&this.WBAutoFetchWorker&&this.isSavedDataSrcSrcset(t)&&this.WBAutoFetchWorker.preserveDataSrcset(t),this.rewriteUrl(r,!1,o,t.ownerDocument)},Wombat.prototype.rewriteAttr=function(t,e,r){var i=!1;if(!t||!t.getAttribute||t._no_rewrite||t["_"+e])return i;var o=this.wb_getAttribute.call(t,e);if(!o||this.startsWith(o,"javascript:"))return i;var n=this.performAttributeRewrite(t,e,o,r);return n!==o&&(this.removeWBOSRC(t),this.wb_setAttribute.call(t,e,n),i=!0),i},Wombat.prototype.noExceptRewriteStyle=function(t){try{return this.rewriteStyle(t)}catch(e){return t}},Wombat.prototype.rewriteStyle=function(t){if(!t)return t;var e=t;return"object"==typeof t&&(e=t.toString()),"string"==typeof e?e.replace(this.STYLE_REGEX,this.styleReplacer).replace(this.IMPORT_REGEX,this.styleReplacer).replace(this.no_wombatRe,""):e},Wombat.prototype.rewriteSrcset=function(t,e){if(!t)return"";for(var r=t.split(this.srcsetRe),i=[],o=this.rwModForElement(e,"srcset"),n=0;n=0){var o="javascript:";r=o+"window.parent._wb_wombat.initNewWindowWombat(window);"+i.substr(o.length)}return r||(r=this.rewriteUrl(i,!1,this.rwModForElement(t,e))),r!==i&&(this.wb_setAttribute.call(t,e,r),!0)},Wombat.prototype.rewriteScript=function(t){if(t.hasAttribute("src")||!t.textContent||!this.$wbwindow.Proxy)return this.rewriteAttr(t,"src");if(this.skipWrapScriptBasedOnType(t.type))return!1;var e=t.textContent.trim();return!this.skipWrapScriptTextBasedOnText(e)&&(t.textContent=this.wrapScriptTextJsProxy(e),!0)},Wombat.prototype.rewriteSVGElem=function(t){var e=this.rewriteAttr(t,"filter");return e=this.rewriteAttr(t,"style")||e,e=this.rewriteAttr(t,"xlink:href")||e,e=this.rewriteAttr(t,"href")||e,e=this.rewriteAttr(t,"src")||e},Wombat.prototype.rewriteElem=function(t){var e=!1;if(!t)return e;if(t instanceof SVGElement)e=this.rewriteSVGElem(t);else switch(t.tagName){case"META":var r=this.wb_getAttribute.call(t,"http-equiv");r&&"content-security-policy"===r.toLowerCase()&&(this.wb_setAttribute.call(t,"http-equiv","_"+r),e=!0);break;case"STYLE":var i=this.rewriteStyle(t.textContent);t.textContent!==i&&(t.textContent=i,e=!0,this.wbUseAFWorker&&this.WBAutoFetchWorker&&null!=t.sheet&&this.WBAutoFetchWorker.deferredSheetExtraction(t.sheet));break;case"LINK":e=this.rewriteAttr(t,"href"),this.wbUseAFWorker&&"stylesheet"===t.rel&&this._addEventListener(t,"load",this.utilFns.wbSheetMediaQChecker);break;case"IMG":e=this.rewriteAttr(t,"src"),e=this.rewriteAttr(t,"srcset")||e,e=this.rewriteAttr(t,"style")||e,this.wbUseAFWorker&&this.WBAutoFetchWorker&&t.dataset.srcset&&this.WBAutoFetchWorker.preserveDataSrcset(t);break;case"OBJECT":if(this.wb_info.isSW&&t.parentElement&&"application/pdf"===t.getAttribute("type")){for(var o=this.$wbwindow.document.createElement("IFRAME"),n=0;n0;)for(var i=r.shift(),o=0;o"+r+"","text/html");if(!i||!this.nodeHasChildren(i.head)||!i.head.children[0].content)return r;var o=i.head.children[0];if(o._no_rewrite=!0,this.recurseRewriteElem(o.content)){var n=o.innerHTML;if(e){var s=o.content.children&&o.content.children[0];if(s){var a="";this.endsWith(n,a)&&!this.endsWith(r.toLowerCase(),a)&&(n=n.substring(0,n.length-a.length))}else if("<"!==r[0]||">"!==r[r.length-1])return void(this.write_buff+=r)}return n}return r},Wombat.prototype.rewriteHtmlFull=function(t,e){var r=(new DOMParser).parseFromString(t,"text/html");if(!r)return t;for(var i=!1,o=0;o=0)r.documentElement._no_rewrite=!0,n=this.reconstructDocType(r.doctype)+r.documentElement.outerHTML;else{r.head._no_rewrite=!0,r.body._no_rewrite=!0;var s=this.nodeHasChildren(r.head),a=this.nodeHasChildren(r.body);if(n=(s?r.head.outerHTML:"")+(a?r.body.outerHTML:""),e)if(r.all.length>3){var w="";this.endsWith(n,w)&&!this.endsWith(t.toLowerCase(),w)&&(n=n.substring(0,n.length-w.length))}else if("<"!==t[0]||">"!==t[t.length-1])return void(this.write_buff+=t);n=this.reconstructDocType(r.doctype)+n}return n}return t},Wombat.prototype.rewriteInlineStyle=function(t){var e;try{e=decodeURIComponent(t)}catch(r){e=t}if(e!==t){var r=this.rewriteStyle(e).split(",",2);return r[0]+","+encodeURIComponent(r[1])}return this.rewriteStyle(t)},Wombat.prototype.rewriteCookie=function(t){var e=this,r=t.replace(this.wb_abs_prefix,"").replace(this.wb_rel_prefix,"");return r=r.replace(this.cookie_domain_regex,(function(t,i){var o={domain:i,cookie:r,wb_type:"cookie"};return e.sendTopMessage(o,!0),e.$wbwindow.location.hostname.indexOf(".")>=0&&!e.IP_RX.test(e.$wbwindow.location.hostname)?"Domain=."+e.$wbwindow.location.hostname:""})).replace(this.cookie_path_regex,(function(t,r){var i=e.rewriteUrl(r);return 0===i.indexOf(e.wb_curr_host)&&(i=i.substring(e.wb_curr_host.length)),"Path="+i})),"https:"!==e.$wbwindow.location.protocol&&(r=r.replace("secure","")),r.replace(",|",",")},Wombat.prototype.rewriteWorker=function(t){if(!t)return t;var e=0===t.indexOf("blob:"),r=0===t.indexOf("javascript:");if(!e&&!r){if(!this.startsWithOneOf(t,this.VALID_PREFIXES)&&!this.startsWith(t,"/")&&!this.startsWithOneOf(t,this.BAD_PREFIXES)){var i=this.resolveRelUrl(t,this.$wbwindow.document);return this.rewriteUrl(i,!1,"wkr_",this.$wbwindow.document)}return this.rewriteUrl(t,!1,"wkr_",this.$wbwindow.document)}var o=r?t.replace("javascript:",""):null;if(e){var n=new XMLHttpRequest;this.utilFns.XHRopen.call(n,"GET",t,!1),this.utilFns.XHRsend.call(n),o=n.responseText.replace(this.workerBlobRe,"").replace(this.rmCheckThisInjectRe,"this")}if(this.wb_info.static_prefix||this.wb_info.ww_rw_script){var s=this.$wbwindow.document.baseURI;o="(function() { self.importScripts(\'"+(this.wb_info.ww_rw_script||this.wb_info.static_prefix+"wombatWorkers.js")+"\'); new WBWombat({\'prefix\': \'"+this.wb_abs_prefix+"\', \'prefixMod\': \'"+this.wb_abs_prefix+"wkrf_/\', \'originalURL\': \'"+s+"\'}); })();"+o}var a=new Blob([o],{type:"application/javascript"});return URL.createObjectURL(a)},Wombat.prototype.rewriteTextNodeFn=function(t,e,r){var i,o=this.proxyToObj(t);if(r.length>0&&o.parentElement&&"STYLE"===o.parentElement.tagName){i=new Array(r.length);var n=r.length-1;2===n?(i[0]=r[0],i[1]=r[1]):1===n&&(i[0]=r[0]),i[n]=this.rewriteStyle(r[n])}else i=r;return e.__WB_orig_apply?e.__WB_orig_apply(o,i):e.apply(o,i)},Wombat.prototype.rewriteDocWriteWriteln=function(t,e,r){var i,o=this.proxyToObj(t),n=r.length;if(0===n)return e.call(o);i=1===n?r[0]:Array.prototype.join.call(r,"");var s=this.rewriteHtml(i,!0),a=e.call(o,s);return this.initNewWindowWombat(o.defaultView),a},Wombat.prototype.rewriteChildNodeFn=function(t,e,r){var i=this.proxyToObj(t);if(0===r.length)return e.call(i);var o=this.rewriteElementsInArguments(r);return e.__WB_orig_apply?e.__WB_orig_apply(i,o):e.apply(i,o)},Wombat.prototype.rewriteInsertAdjHTMLOrElemArgs=function(t,e,r,i,o){var n=this.proxyToObj(t);return n._no_rewrite?e.call(n,r,i):o?e.call(n,r,this.rewriteHtml(i)):(this.rewriteElemComplete(i),e.call(n,r,i))},Wombat.prototype.rewriteSetTimeoutInterval=function(t,e,r){var i=this.isString(r[0]),o=i?new Array(r.length):r;if(i){this.$wbwindow.Proxy?o[0]=this.wrapScriptTextJsProxy(r[0]):o[0]=r[0].replace(/\\blocation\\b/g,"WB_wombat_$&");for(var n=1;n0&&r(this.$wbwindow.CSSStyleValue,"parse"),this.$wbwindow.CSSStyleValue.parseAll&&this.$wbwindow.CSSStyleValue.parseAll.toString().indexOf("[native code]")>0&&r(this.$wbwindow.CSSStyleValue,"parseAll")}if(this.$wbwindow.CSSKeywordValue&&this.$wbwindow.CSSKeywordValue.prototype){var i=this.$wbwindow.CSSKeywordValue;this.$wbwindow.CSSKeywordValue=(t=this.$wbwindow.CSSKeywordValue,function(r){return e.domConstructorErrorChecker(this,"CSSKeywordValue",arguments),new t(e.rewriteStyle(r))}),this.$wbwindow.CSSKeywordValue.prototype=i.prototype,Object.defineProperty(this.$wbwindow.CSSKeywordValue.prototype,"constructor",{value:this.$wbwindow.CSSKeywordValue}),addToStringTagToClass(this.$wbwindow.CSSKeywordValue,"CSSKeywordValue")}if(this.$wbwindow.StylePropertyMap&&this.$wbwindow.StylePropertyMap.prototype){var o=this.$wbwindow.StylePropertyMap.prototype.set;this.$wbwindow.StylePropertyMap.prototype.set=function(){if(arguments.length<=1)return o.__WB_orig_apply?o.__WB_orig_apply(this,arguments):o.apply(this,arguments);var t=new Array(arguments.length);t[0]=arguments[0];for(var r=1;r")&&(e[0]=r.rewriteHtml(e[0]),i.type="text/html"),new t(e,i)}),this.$wbwindow.Blob.prototype=e.prototype}},Wombat.prototype.initDocTitleOverride=function(){var t=this.getOrigGetter(this.$wbwindow.document,"title"),e=this.getOrigSetter(this.$wbwindow.document,"title"),r=this;this.defProp(this.$wbwindow.document,"title",(function(t){var i=e.call(this,t),o={wb_type:"title",title:t};return r.sendTopMessage(o),i}),t)},Wombat.prototype.initFontFaceOverride=function(){if(this.$wbwindow.FontFace&&!this.$wbwindow.FontFace.__wboverriden__){var t,e=this,r=this.$wbwindow.FontFace;this.$wbwindow.FontFace=(t=this.$wbwindow.FontFace,function(r,i,o){e.domConstructorErrorChecker(this,"FontFace",arguments,2);var n=i;return null!=i&&(n="string"!=typeof i?e.rewriteInlineStyle(i.toString()):e.rewriteInlineStyle(i)),new t(r,n,o)}),this.$wbwindow.FontFace.prototype=r.prototype,Object.defineProperty(this.$wbwindow.FontFace.prototype,"constructor",{value:this.$wbwindow.FontFace}),this.$wbwindow.FontFace.__wboverriden__=!0,addToStringTagToClass(this.$wbwindow.FontFace,"FontFace")}},Wombat.prototype.initFixedRatio=function(){try{this.$wbwindow.devicePixelRatio=1}catch(t){}if(Object.defineProperty)try{Object.defineProperty(this.$wbwindow,"devicePixelRatio",{value:1,writable:!1})}catch(t){}},Wombat.prototype.initPaths=function(t){t.wombat_opts=t.wombat_opts||{},this.wb_info=t,this.wb_opts=t.wombat_opts,this.wb_replay_prefix=t.prefix,this.wb_is_proxy=t.proxy_magic||!this.wb_replay_prefix,this.wb_info.top_host=this.wb_info.top_host||"*",this.wb_curr_host=this.$wbwindow.location.protocol+"//"+this.$wbwindow.location.host,this.wb_orig_scheme=t.wombat_scheme+"://",this.wb_orig_origin=this.wb_orig_scheme+t.wombat_host,this.wb_abs_prefix=this.wb_replay_prefix,!t.is_live&&t.wombat_ts?this.wb_capture_date_part="/"+t.wombat_ts+"/":this.wb_capture_date_part="",this.initBadPrefixes(this.wb_replay_prefix)},Wombat.prototype.initSeededRandom=function(t){this.$wbwindow.Math.seed=parseInt(t);var e=this;this.$wbwindow.Math.random=function(){return e.$wbwindow.Math.seed=(9301*e.$wbwindow.Math.seed+49297)%233280,e.$wbwindow.Math.seed/233280}},Wombat.prototype.initHistoryOverrides=function(){this.overrideHistoryFunc("pushState"),this.overrideHistoryFunc("replaceState");var t=this;this.$wbwindow.addEventListener("popstate",(function(e){t.sendHistoryUpdate(t.$wbwindow.WB_wombat_location.href,t.$wbwindow.document.title)}))},Wombat.prototype.initHTTPOverrides=function(){var t,e,r,i=this;if(!this.wb_info.isSW&&this.$wbwindow.XMLHttpRequest.prototype.open){var o=this.$wbwindow.XMLHttpRequest.prototype.open;this.utilFns.XHRopen=o,this.utilFns.XHRsend=this.$wbwindow.XMLHttpRequest.prototype.send,this.$wbwindow.XMLHttpRequest.prototype.open=function(t,e,r,n,s){var a=this._no_rewrite?e:i.rewriteUrl(e),w=!0;null==r||r||(w=!1),o.call(this,t,a,w,n,s),i.startsWith(a,"data:")||this.setRequestHeader("X-Pywb-Requested-With","XMLHttpRequest")}}if(this.overridePropExtract(this.$wbwindow.XMLHttpRequest.prototype,"responseURL"),this.wb_info.isSW){var n=this.$wbwindow.XMLHttpRequest.prototype.open,s=this.$wbwindow.XMLHttpRequest.prototype.setRequestHeader,a=this.$wbwindow.XMLHttpRequest.prototype.send;this.utilFns.XHRopen=n,this.utilFns.XHRsend=a,this.$wbwindow.XMLHttpRequest.prototype.open=function(){this.__WB_xhr_open_arguments=arguments,this.__WB_xhr_headers=new Headers},this.$wbwindow.XMLHttpRequest.prototype.setRequestHeader=function(t,e){this.__WB_xhr_headers.set(t,e)};i=this;this.$wbwindow.XMLHttpRequest.prototype.send=function(t){if("POST"===this.__WB_xhr_open_arguments[0]&&("string"==typeof t&&"application/x-www-form-urlencoded"===this.__WB_xhr_headers.get("Content-Type")||t instanceof URLSearchParams)&&(this.__WB_xhr_open_arguments[0]="GET",this.__WB_xhr_open_arguments[1]+=(this.__WB_xhr_open_arguments[1].indexOf("?")>0?"&":"?")+t.toString(),t=null),this.__WB_xhr_open_arguments.length>2&&(this.__WB_xhr_open_arguments[2]=!0),this._no_rewrite||(this.__WB_xhr_open_arguments[1]=i.rewriteUrl(this.__WB_xhr_open_arguments[1])),n.apply(this,this.__WB_xhr_open_arguments),!i.startsWith(this.__WB_xhr_open_arguments[1],"data:")){for(const[t,e]of this.__WB_xhr_headers.entries())s.call(this,t,e);s.call(this,"X-Pywb-Requested-With","XMLHttpRequest")}a.call(this,t)}}if(this.$wbwindow.fetch){var w=this.$wbwindow.fetch;this.$wbwindow.fetch=function(t,e){var r=t,o=typeof t;if("string"===o)r=i.rewriteUrl(t);else if("object"===o&&t.url){var n=i.rewriteUrl(t.url);n!==t.url&&(r=new Request(n,t))}else"object"===o&&t.href&&(r=i.rewriteUrl(t.href));return(e=e||{}).credentials="include",w.call(i.proxyToObj(this),r,e)}}if(this.$wbwindow.Request&&this.$wbwindow.Request.prototype){var h=this.$wbwindow.Request;this.$wbwindow.Request=(t=this.$wbwindow.Request,function(e,r){i.domConstructorErrorChecker(this,"Request",arguments);var o=r||{},n=e,s=typeof e;switch(s){case"string":n=i.rewriteUrl(e);break;case"object":if(n=e,e.url){var a=i.rewriteUrl(e.url);a!==e.url&&(n=new t(a,e))}else e.href&&(n=i.rewriteUrl(e.toString(),!0))}return o.credentials="include",new t(n,o)}),this.$wbwindow.Request.prototype=h.prototype,Object.defineProperty(this.$wbwindow.Request.prototype,"constructor",{value:this.$wbwindow.Request})}if(this.$wbwindow.Response&&this.$wbwindow.Response.prototype){var p=this.$wbwindow.Response.prototype.redirect;this.$wbwindow.Response.prototype.redirect=function(t,e){var r=i.rewriteUrl(t,!0,null,i.$wbwindow.document);return p.call(this,r,e)}}if(this.$wbwindow.EventSource&&this.$wbwindow.EventSource.prototype){var c=this.$wbwindow.EventSource;this.$wbwindow.EventSource=(e=this.$wbwindow.EventSource,function(t,r){i.domConstructorErrorChecker(this,"EventSource",arguments);var o=t;return null!=t&&(o=i.rewriteUrl(t)),new e(o,r)}),this.$wbwindow.EventSource.prototype=c.prototype,Object.defineProperty(this.$wbwindow.EventSource.prototype,"constructor",{value:this.$wbwindow.EventSource}),addToStringTagToClass(this.$wbwindow.EventSource,"EventSource")}if(this.$wbwindow.WebSocket&&this.$wbwindow.WebSocket.prototype){var l=this.$wbwindow.WebSocket;this.$wbwindow.WebSocket=(r=this.$wbwindow.WebSocket,function(t,e){i.domConstructorErrorChecker(this,"WebSocket",arguments);var o=t;return null!=t&&(o=i.rewriteWSURL(t)),new r(o,e)}),this.$wbwindow.WebSocket.prototype=l.prototype,Object.defineProperty(this.$wbwindow.WebSocket.prototype,"constructor",{value:this.$wbwindow.WebSocket}),addToStringTagToClass(this.$wbwindow.WebSocket,"WebSocket")}},Wombat.prototype.initElementGetSetAttributeOverride=function(){if(!this.wb_opts.skip_setAttribute&&this.$wbwindow.Element&&this.$wbwindow.Element.prototype){var t=this,e=this.$wbwindow.Element.prototype;if(e.setAttribute){var r=e.setAttribute;e._orig_setAttribute=r,e.setAttribute=function(e,i){var o=i;if(e&&"string"==typeof o){var n=e.toLowerCase();if("LINK"===this.tagName&&"href"===n&&0===o.indexOf("data:text/css"))o=t.rewriteInlineStyle(i);else if("style"===n)o=t.rewriteStyle(i);else if("srcset"===n)o=t.rewriteSrcset(i,this);else{t.shouldRewriteAttr(this.tagName,n)&&(t.removeWBOSRC(this),this._no_rewrite||(o=t.rewriteUrl(i,!1,t.rwModForElement(this,n))))}}return r.call(this,e,o)}}if(e.getAttribute){var i=e.getAttribute;this.wb_getAttribute=i,e.getAttribute=function(e){var r=i.call(this,e),o=e;if(e&&(o=e.toLowerCase()),t.shouldRewriteAttr(this.tagName,o)){var n=t.retrieveWBOSRC(this);return n||t.extractOriginalURL(r)}return t.startsWith(o,"data-")&&t.startsWithOneOf(r,t.VALID_PREFIXES)?t.extractOriginalURL(r):r}}}},Wombat.prototype.initSvgImageOverrides=function(){if(this.$wbwindow.SVGImageElement){var t=this.$wbwindow.SVGImageElement.prototype,e=t.getAttribute,r=t.getAttributeNS,i=t.setAttribute,o=t.setAttributeNS,n=this;t.getAttribute=function(t){var r=e.call(this,t);return t.indexOf("xlink:href")>=0||"href"===t?n.extractOriginalURL(r):r},t.getAttributeNS=function(t,e){var i=r.call(this,t,e);return e.indexOf("xlink:href")>=0||"href"===e?n.extractOriginalURL(i):i},t.setAttribute=function(t,e){var r=e;return(t.indexOf("xlink:href")>=0||"href"===t)&&(r=n.rewriteUrl(e)),i.call(this,t,r)},t.setAttributeNS=function(t,e,r){var i=r;return(e.indexOf("xlink:href")>=0||"href"===e)&&(i=n.rewriteUrl(r)),o.call(this,t,e,i)}}},Wombat.prototype.initCreateElementNSFix=function(){if(this.$wbwindow.document.createElementNS&&this.$wbwindow.Document.prototype.createElementNS){var t=this.$wbwindow.document.createElementNS,e=this,r=function(r,i){return t.call(e.proxyToObj(this),e.extractOriginalURL(r),i)};this.$wbwindow.Document.prototype.createElementNS=r,this.$wbwindow.document.createElementNS=r}},Wombat.prototype.initInsertAdjacentElementHTMLOverrides=function(){var t=this.$wbwindow.Element;if(t&&t.prototype){var e=t.prototype,r=this.rewriteInsertAdjHTMLOrElemArgs;if(e.insertAdjacentHTML){var i=e.insertAdjacentHTML;e.insertAdjacentHTML=function(t,e){return r(this,i,t,e,!0)}}if(e.insertAdjacentElement){var o=e.insertAdjacentElement;e.insertAdjacentElement=function(t,e){return r(this,o,t,e,!1)}}}},Wombat.prototype.initDomOverride=function(){var t=this.$wbwindow.Node;if(t&&t.prototype){var e=this.rewriteNodeFuncArgs;if(t.prototype.appendChild){var r=t.prototype.appendChild;t.prototype.appendChild=function(t,i){return e(this,r,t,i)}}if(t.prototype.insertBefore){var i=t.prototype.insertBefore;t.prototype.insertBefore=function(t,r){return e(this,i,t,r)}}if(t.prototype.replaceChild){var o=t.prototype.replaceChild;t.prototype.replaceChild=function(t,r){return e(this,o,t,r)}}this.overridePropToProxy(t.prototype,"ownerDocument"),this.overridePropToProxy(this.$wbwindow.HTMLHtmlElement.prototype,"parentNode"),this.overridePropToProxy(this.$wbwindow.Event.prototype,"target")}this.$wbwindow.Element&&this.$wbwindow.Element.prototype&&(this.overrideParentNodeAppendPrepend(this.$wbwindow.Element),this.overrideChildNodeInterface(this.$wbwindow.Element,!1)),this.$wbwindow.DocumentFragment&&this.$wbwindow.DocumentFragment.prototype&&this.overrideParentNodeAppendPrepend(this.$wbwindow.DocumentFragment)},Wombat.prototype.initDocOverrides=function(t){if(Object.defineProperty){this.overrideReferrer(t),this.defGetterProp(t,"origin",(function(){return this.WB_wombat_location.origin})),this.defGetterProp(this.$wbwindow,"origin",(function(){return this.WB_wombat_location.origin}));var e=this;this.defProp(t,"domain",(function(t){var r=this.WB_wombat_location;r&&e.endsWith(r.hostname,t)&&(this.__wb_domain=t)}),(function(){return this.__wb_domain||this.WB_wombat_location.hostname}))}},Wombat.prototype.initDocWriteOpenCloseOverride=function(){if(this.$wbwindow.DOMParser){var t=this.$wbwindow.Document.prototype,e=this.$wbwindow.document,r=this.rewriteDocWriteWriteln,i=e.write,o=function(){return r(this,i,arguments)};e.write=o,t.write=o;var n=e.writeln,s=function(){return r(this,n,arguments)};e.writeln=s,t.writeln=s;var a=this,w=e.open,h=function(){var t,e=a.proxyToObj(this);if(3===arguments.length){var r=a.rewriteUrl(arguments[0],!1,"mp_");t=w.call(e,r,arguments[1],arguments[2]),a.initNewWindowWombat(t,r)}else t=w.call(e),a.initNewWindowWombat(e.defaultView);return t};e.open=h,t.open=h;var p=e.close,c=function(){var t=a.proxyToObj(this);return a.initNewWindowWombat(t.defaultView),p.__WB_orig_apply?p.__WB_orig_apply(t,arguments):p.apply(t,arguments)};e.close=c,t.close=c;var l=this.getOrigGetter(t,"body"),_=this.getOrigSetter(t,"body");l&&_&&this.defProp(t,"body",(function(t){return t&&(t instanceof HTMLBodyElement||t instanceof HTMLFrameSetElement)&&a.rewriteElemComplete(t),_.call(a.proxyToObj(this),t)}),l)}},Wombat.prototype.initIframeWombat=function(t){var e;e=t._get_contentWindow?t._get_contentWindow.call(t):t.contentWindow;try{if(!e||e===this.$wbwindow||e._skip_wombat||e._wb_wombat)return}catch(t){return}var r=this.wb_getAttribute.call(t,"src");this.initNewWindowWombat(e,r)},Wombat.prototype.initNewWindowWombat=function(t,e){var r=!1;if(t&&!t._wb_wombat){if((!e||""===e||this.startsWith(e,"about:")||e.indexOf("javascript:")>=0)&&(r=!0),this.wb_info.isSW){var i=this.extractOriginalURL(e);("about:blank"===i||i.startsWith("srcdoc:")||i.startsWith("blob:"))&&(r=!0)}if(r){var o=new Wombat(t,this.wb_info);t._wb_wombat=o.wombatInit()}else this.initProtoPmOrigin(t),this.initPostMessageOverride(t),this.initMessageEventOverride(t),this.initCheckThisFunc(t)}},Wombat.prototype.initTimeoutIntervalOverrides=function(){var t=this.rewriteSetTimeoutInterval;if(this.$wbwindow.setTimeout&&!this.$wbwindow.setTimeout.__$wbpatched$__){var e=this.$wbwindow.setTimeout;this.$wbwindow.setTimeout=function(){return t(this,e,arguments)},this.$wbwindow.setTimeout.__$wbpatched$__=!0}if(this.$wbwindow.setInterval&&!this.$wbwindow.setInterval.__$wbpatched$__){var r=this.$wbwindow.setInterval;this.$wbwindow.setInterval=function(){return t(this,r,arguments)},this.$wbwindow.setInterval.__$wbpatched$__=!0}},Wombat.prototype.initWorkerOverrides=function(){var t,e,r=this;if(this.$wbwindow.Worker&&!this.$wbwindow.Worker._wb_worker_overriden){var i=this.$wbwindow.Worker;this.$wbwindow.Worker=(t=i,function(e,i){return r.domConstructorErrorChecker(this,"Worker",arguments),new t(r.rewriteWorker(e),i)}),this.$wbwindow.Worker.prototype=i.prototype,Object.defineProperty(this.$wbwindow.Worker.prototype,"constructor",{value:this.$wbwindow.Worker}),this.$wbwindow.Worker._wb_worker_overriden=!0}if(this.$wbwindow.SharedWorker&&!this.$wbwindow.SharedWorker.__wb_sharedWorker_overriden){var o=this.$wbwindow.SharedWorker;this.$wbwindow.SharedWorker=(e=o,function(t,i){return r.domConstructorErrorChecker(this,"SharedWorker",arguments),new e(r.rewriteWorker(t),i)}),this.$wbwindow.SharedWorker.prototype=o.prototype,Object.defineProperty(this.$wbwindow.SharedWorker.prototype,"constructor",{value:this.$wbwindow.SharedWorker}),this.$wbwindow.SharedWorker.__wb_sharedWorker_overriden=!0}if(this.$wbwindow.ServiceWorkerContainer&&this.$wbwindow.ServiceWorkerContainer.prototype&&this.$wbwindow.ServiceWorkerContainer.prototype.register){var n=this.$wbwindow.ServiceWorkerContainer.prototype.register;this.$wbwindow.ServiceWorkerContainer.prototype.register=function(t,e){var i=new URL(t,r.$wbwindow.document.baseURI).href,o=r.getPageUnderModifier();return e&&e.scope?e.scope=r.rewriteUrl(e.scope,!1,o):e={scope:r.rewriteUrl("/",!1,o)},n.call(this,r.rewriteUrl(i,!1,"sw_"),e)}}if(this.$wbwindow.Worklet&&this.$wbwindow.Worklet.prototype&&this.$wbwindow.Worklet.prototype.addModule&&!this.$wbwindow.Worklet.__wb_workerlet_overriden){var s=this.$wbwindow.Worklet.prototype.addModule;this.$wbwindow.Worklet.prototype.addModule=function(t,e){var i=r.rewriteUrl(t,!1,"js_");return s.call(this,i,e)},this.$wbwindow.Worklet.__wb_workerlet_overriden=!0}},Wombat.prototype.initLocOverride=function(t,e,r){if(Object.defineProperty)for(var i=0;i=0&&i.splice(n,1)}return i}})}catch(t){console.log(t)}},Wombat.prototype.initHashChange=function(){if(this.$wbwindow.__WB_top_frame){var t=this;this.$wbwindow.addEventListener("message",(function(e){if(e.data&&e.data.from_top){var r=e.data.message;r.wb_type&&"outer_hashchange"===r.wb_type&&t.$wbwindow.location.hash!=r.hash&&(t.$wbwindow.location.hash=r.hash)}})),this.$wbwindow.addEventListener("hashchange",(function(){var e={wb_type:"hashchange",hash:t.$wbwindow.location.hash};t.sendTopMessage(e)}))}},Wombat.prototype.initPostMessageOverride=function(t){if(t.postMessage&&!t.__orig_postMessage){var e=t.postMessage,r=this;t.__orig_postMessage=e;var i=function(t,i,o,n){var s,a,w=r.proxyToObj(this);if(w.__WB_source&&w.__WB_source.WB_wombat_location){var h=w.__WB_source;if(s=h.WB_wombat_location.origin,w.__WB_win_id||(w.__WB_win_id={},w.__WB_counter=0),!h.__WB_id){var p=w.__WB_counter;h.__WB_id=p+h.WB_wombat_location.href,w.__WB_counter+=1}w.__WB_win_id[h.__WB_id]=h,a=h.__WB_id,w.__WB_source=void 0}else s=window.WB_wombat_location.origin;var c=i;c===w.location.origin&&(c=s);var l={from:s,to_origin:c,src_id:a,message:t,from_top:n};if("*"!==i){if("null"===w.location.origin||""===w.location.origin)return;i=w.location.origin}return e.call(w,l,i,o)};t.postMessage=i,t.Window.prototype.postMessage=i;var o=null,n=(o=t.EventTarget&&t.EventTarget.prototype?t.EventTarget.prototype:t).addEventListener;o.addEventListener=function(t,e,i){var o,s=r.proxyToObj(this);if("message"===t?o=r.message_listeners.add_or_get(e,(function(){return wrapEventListener(e,s,r)})):"storage"===t?r.storage_listeners.add_or_get(e,(function(){return wrapSameOriginEventListener(e,s)})):o=e,o)return n.call(s,t,o,i)};var s=o.removeEventListener;o.removeEventListener=function(t,e,i){var o,n=r.proxyToObj(this);if("message"===t?o=r.message_listeners.remove(e):"storage"===t?r.storage_listeners.remove(e):o=e,o)return s.call(n,t,o,i)};var a=function(e,i){var o=r.getOrigSetter(t,e);r.defProp(t,e,(function(t){this["__orig_"+e]=t;var n=r.proxyToObj(this),s=t?i(t,n,r):t;return o.call(n,s)}),(function(){return this["__orig_"+e]}))};a("onmessage",wrapEventListener),a("onstorage",wrapSameOriginEventListener)}},Wombat.prototype.initMessageEventOverride=function(t){t.MessageEvent&&!t.MessageEvent.prototype.__extended&&(this.addEventOverride("target"),this.addEventOverride("srcElement"),this.addEventOverride("currentTarget"),this.addEventOverride("eventPhase"),this.addEventOverride("path"),this.overridePropToProxy(t.MessageEvent.prototype,"source"),t.MessageEvent.prototype.__extended=!0)},Wombat.prototype.initUIEventsOverrides=function(){this.overrideAnUIEvent("UIEvent"),this.overrideAnUIEvent("MouseEvent"),this.overrideAnUIEvent("TouchEvent"),this.overrideAnUIEvent("FocusEvent"),this.overrideAnUIEvent("KeyboardEvent"),this.overrideAnUIEvent("WheelEvent"),this.overrideAnUIEvent("InputEvent"),this.overrideAnUIEvent("CompositionEvent")},Wombat.prototype.initOpenOverride=function(){var t=this.$wbwindow.open;this.$wbwindow.Window.prototype.open&&(t=this.$wbwindow.Window.prototype.open);var e=this,r=function(r,i,o){var n=e.rewriteUrl(r,!1,""),s=t.call(e.proxyToObj(this),n,i,o);return e.initNewWindowWombat(s,n),s};this.$wbwindow.open=r,this.$wbwindow.Window.prototype.open&&(this.$wbwindow.Window.prototype.open=r);for(var i=0;i}\n */\nWBWombat.prototype.rewriteArgs = function(argsObj) {\n // recreate the original arguments object just with URLs rewritten\n var newArgObj = new Array(argsObj.length);\n for (var i = 0; i < newArgObj.length; i++) {\n newArgObj[i] = this.rewriteURL(argsObj[i]);\n }\n return newArgObj;\n};\n\n/**\n * Rewrites the input to one of the Fetch APIs\n * @param {*|string|Request} input\n * @return {*|string|Request}\n */\nWBWombat.prototype.rewriteFetchApi = function(input) {\n var rwInput = input;\n switch (typeof input) {\n case 'string':\n rwInput = this.rewriteURL(input);\n break;\n case 'object':\n if (input.url) {\n var new_url = this.rewriteURL(input.url);\n if (new_url !== input.url) {\n // not much we can do here Request.url is read only\n // https://developer.mozilla.org/en-US/docs/Web/API/Request/url\n rwInput = new Request(new_url, input);\n }\n } else if (input.href) {\n // it is likely that input is either self.location or self.URL\n // we cant do anything here so just let it go\n rwInput = input.href;\n }\n break;\n }\n return rwInput;\n};\n\n/**\n * Rewrites the input to one of the Cache APIs\n * @param {*|string|Request} request\n * @return {*|string|Request}\n */\nWBWombat.prototype.rewriteCacheApi = function(request) {\n var rwRequest = request;\n if (typeof request === 'string') {\n rwRequest = this.rewriteURL(request);\n }\n return rwRequest;\n};\n\n/**\n * Applies an override to the importScripts function\n * @see https://html.spec.whatwg.org/multipage/workers.html#dom-workerglobalscope-importscripts\n */\nWBWombat.prototype.initImportScriptsRewrite = function() {\n if (!self.importScripts) return;\n var wombat = this;\n var origImportScripts = self.importScripts;\n self.importScripts = function importScripts() {\n // rewrite the arguments object and call original function via fn.apply\n var rwArgs = wombat.rewriteArgs(arguments);\n return origImportScripts.apply(this, rwArgs);\n };\n};\n\n/**\n * Applies overrides to the XMLHttpRequest.open and XMLHttpRequest.responseURL\n * in order to ensure URLs are rewritten.\n *\n * Applies an override to window.fetch in order to rewrite URLs and URLs of\n * the supplied Request objects used as arguments to fetch.\n *\n * Applies overrides to window.Request, window.Response, window.EventSource,\n * and window.WebSocket in order to ensure URLs they operate on are rewritten.\n *\n * @see https://xhr.spec.whatwg.org/\n * @see https://fetch.spec.whatwg.org/\n * @see https://html.spec.whatwg.org/multipage/web-sockets.html#websocket\n * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#the-eventsource-interface\n */\nWBWombat.prototype.initHTTPOverrides = function() {\n var wombat = this;\n if (\n self.XMLHttpRequest &&\n self.XMLHttpRequest.prototype &&\n self.XMLHttpRequest.prototype.open\n ) {\n var oXHROpen = self.XMLHttpRequest.prototype.open;\n self.XMLHttpRequest.prototype.open = function open(\n method,\n url,\n async,\n user,\n password\n ) {\n var rwURL = wombat.rewriteURL(url);\n var openAsync = true;\n if (async != null && !async) openAsync = false;\n oXHROpen.call(this, method, rwURL, openAsync, user, password);\n if (rwURL.indexOf('data:') === -1) {\n this.setRequestHeader('X-Pywb-Requested-With', 'XMLHttpRequest');\n }\n };\n }\n\n if (self.fetch != null) {\n // this fetch is Worker.fetch\n var orig_fetch = self.fetch;\n self.fetch = function fetch(input, init_opts) {\n var rwInput = wombat.rewriteFetchApi(input);\n var newInitOpts = init_opts || {};\n newInitOpts['credentials'] = 'include';\n return orig_fetch.call(this, rwInput, newInitOpts);\n };\n }\n\n if (self.Request && self.Request.prototype) {\n var orig_request = self.Request;\n self.Request = (function(Request_) {\n return function Request(input, init_opts) {\n var newInitOpts = init_opts || {};\n var newInput = wombat.rewriteFetchApi(input);\n newInitOpts['credentials'] = 'include';\n return new Request_(newInput, newInitOpts);\n };\n })(self.Request);\n self.Request.prototype = orig_request.prototype;\n }\n\n if (self.Response && self.Response.prototype) {\n var originalRedirect = self.Response.prototype.redirect;\n self.Response.prototype.redirect = function redirect(url, status) {\n var rwURL = wombat.rewriteUrl(url);\n return originalRedirect.call(this, rwURL, status);\n };\n }\n\n if (self.EventSource && self.EventSource.prototype) {\n var origEventSource = self.EventSource;\n self.EventSource = (function(EventSource_) {\n return function EventSource(url, configuration) {\n var rwURL = url;\n if (url != null) {\n rwURL = wombat.rewriteUrl(url);\n }\n return new EventSource_(rwURL, configuration);\n };\n })(self.EventSource);\n self.EventSource.prototype = origEventSource.prototype;\n Object.defineProperty(self.EventSource.prototype, 'constructor', {\n value: self.EventSource\n });\n }\n\n if (self.WebSocket && self.WebSocket.prototype) {\n var origWebSocket = self.WebSocket;\n self.WebSocket = (function(WebSocket_) {\n return function WebSocket(url, configuration) {\n var rwURL = url;\n if (url != null) {\n rwURL = wombat.rewriteWSURL(url);\n }\n return new WebSocket_(rwURL, configuration);\n };\n })(self.WebSocket);\n self.WebSocket.prototype = origWebSocket.prototype;\n Object.defineProperty(self.WebSocket.prototype, 'constructor', {\n value: self.WebSocket\n });\n }\n};\n\n/**\n * Applies an override to Clients.openWindow and WindowClient.navigate that rewrites\n * the supplied URL that represents a controlled window\n * @see https://w3c.github.io/ServiceWorker/#window-client-interface\n * @see https://w3c.github.io/ServiceWorker/#clients-interface\n */\nWBWombat.prototype.initClientApisOverride = function() {\n var wombat = this;\n if (\n self.Clients &&\n self.Clients.prototype &&\n self.Clients.prototype.openWindow\n ) {\n var oClientsOpenWindow = self.Clients.prototype.openWindow;\n self.Clients.prototype.openWindow = function openWindow(url) {\n var rwURL = wombat.rewriteClientWindowURL(url);\n return oClientsOpenWindow.call(this, rwURL);\n };\n }\n\n if (\n self.WindowClient &&\n self.WindowClient.prototype &&\n self.WindowClient.prototype.navigate\n ) {\n var oWinClientNavigate = self.WindowClient.prototype.navigate;\n self.WindowClient.prototype.navigate = function navigate(url) {\n var rwURL = wombat.rewriteClientWindowURL(url, this);\n return oWinClientNavigate.call(this, rwURL);\n };\n }\n};\n\n/**\n * Applies overrides to the CachStorage and Cache interfaces in order\n * to rewrite the URLs they operate on\n * @see https://w3c.github.io/ServiceWorker/#cachestorage\n * @see https://w3c.github.io/ServiceWorker/#cache-interface\n */\nWBWombat.prototype.initCacheApisOverride = function() {\n var wombat = this;\n if (\n self.CacheStorage &&\n self.CacheStorage.prototype &&\n self.CacheStorage.prototype.match\n ) {\n var oCacheStorageMatch = self.CacheStorage.prototype.match;\n self.CacheStorage.prototype.match = function match(request, options) {\n var rwRequest = wombat.rewriteCacheApi(request);\n return oCacheStorageMatch.call(this, rwRequest, options);\n };\n }\n\n if (self.Cache && self.Cache.prototype) {\n if (self.Cache.prototype.match) {\n var oCacheMatch = self.Cache.prototype.match;\n self.Cache.prototype.match = function match(request, options) {\n var rwRequest = wombat.rewriteCacheApi(request);\n return oCacheMatch.call(this, rwRequest, options);\n };\n }\n\n if (self.Cache.prototype.matchAll) {\n var oCacheMatchAll = self.Cache.prototype.matchAll;\n self.Cache.prototype.matchAll = function matchAll(request, options) {\n var rwRequest = wombat.rewriteCacheApi(request);\n return oCacheMatchAll.call(this, rwRequest, options);\n };\n }\n\n if (self.Cache.prototype.add) {\n var oCacheAdd = self.Cache.prototype.add;\n self.Cache.prototype.add = function add(request, options) {\n var rwRequest = wombat.rewriteCacheApi(request);\n return oCacheAdd.call(this, rwRequest, options);\n };\n }\n\n if (self.Cache.prototype.addAll) {\n var oCacheAddAll = self.Cache.prototype.addAll;\n self.Cache.prototype.addAll = function addAll(requests) {\n var rwRequests = requests;\n if (Array.isArray(requests)) {\n rwRequests = new Array(requests.length);\n for (var i = 0; i < requests.length; i++) {\n rwRequests[i] = wombat.rewriteCacheApi(requests[i]);\n }\n }\n return oCacheAddAll.call(this, rwRequests);\n };\n }\n\n if (self.Cache.prototype.put) {\n var oCachePut = self.Cache.prototype.put;\n self.Cache.prototype.put = function put(request, response) {\n var rwRequest = wombat.rewriteCacheApi(request);\n return oCachePut.call(this, rwRequest, response);\n };\n }\n\n if (self.Cache.prototype.delete) {\n var oCacheDelete = self.Cache.prototype.delete;\n self.Cache.prototype.delete = function newCacheDelete(request, options) {\n var rwRequest = wombat.rewriteCacheApi(request);\n return oCacheDelete.call(this, rwRequest, options);\n };\n }\n\n if (self.Cache.prototype.keys) {\n var oCacheKeys = self.Cache.prototype.keys;\n self.Cache.prototype.keys = function keys(request, options) {\n var rwRequest = wombat.rewriteCacheApi(request);\n return oCacheKeys.call(this, rwRequest, options);\n };\n }\n }\n};\n\nself.WBWombat = WBWombat;\n"}),this.collections=new pt(i,e.get("root")),this.collections.loadAll(e.get("dbColl")),this.api=new ft(this.collections),this.apiPrefix=this.replayPrefix+"api/",this.allowRewrittenCache=!!e.get("allowCache"),this.stats=e.get("stats")?new F:null,self.addEventListener("install",t=>{self.skipWaiting()}),self.addEventListener("activate",t=>{t.waitUntil(self.clients.claim()),console.log("Activate!")}),self.addEventListener("fetch",t=>{t.respondWith(this.handleFetch(t))}),self.addEventListener("message",t=>{"reload_all"===t.data.msg_type&&this.collections.loadAll()})}handleFetch(t){const e=t.request.url;if(!e.startsWith(this.prefix))return this.defaultFetch(t.request);if(this.collections.root&&e.slice(this.prefix.length).indexOf("/")<0)return this.defaultFetch(t.request);if(e.startsWith(this.replayPrefix)&&!e.startsWith(this.staticPrefix))return this.getResponseFor(t.request,t);const r=new URL(e);r.search="",r.hash="";const i=r.href;for(const t of this.staticData.keys())if(t===i){const{content:e,type:r}=this.staticData.get(t);return new Response(e,{headers:{"Content-Type":r}})}return("http:"==r.protocol||"https:"==r.protocol)&&r.pathname.indexOf("/",1)<0?this.handleOffline(t.request):this.defaultFetch(t.request)}defaultFetch(t){const e={};return"only-if-cached"===t.cache&&"same-origin"!==t.mode&&(e.cache="default"),self.fetch(t,e)}async ensureCached(t){const e=await caches.open("wabac-offline");for(let r of t){r=new URL(r,self.location.href).href;let t=await e.match(r,{ignoreSearch:!0});if(!t)try{t=await this.defaultFetch(r),await e.put(r,t)}catch(t){console.warn("Failed to Auto Cache: "+r,t)}}}async handleOffline(t){let e=null;const r=await caches.open("wabac-offline");try{e=await this.defaultFetch(t)}catch(i){return e=await r.match(t,{ignoreSearch:!0}),e||(e=Object(o.k)(t,"Sorry, this url was not cached for offline use")),e}if(t.url.startsWith(this.prefix+"?"))return e;if(200===e.status){const i=e.clone();await r.put(t,i)}else console.warn(`Not Cacheing ${t.url} - Status ${e.status}`);return e}async getResponseFor(t,e){if(t.url.startsWith(this.apiPrefix))return this.stats&&t.url.startsWith(this.apiPrefix+"stats.json")?await this.stats.getStats(e):await this.api.apiResponse(t.url.slice(this.apiPrefix.length),t.method,t);"POST"===t.method&&(t=await this.toGetRequest(t)),await this.collections.inited;let r=null;const i=Object(o.h)(t),n=t.headers.get("range");try{if(this.allowRewrittenCache&&!n&&(r=await self.caches.match(t),r&&!!r.headers.get("x-wabac-is-ajax-req")===i))return r}catch(t){r=null}let s=this.collections.root;s||(s=t.url.slice(this.replayPrefix.length).split("/",1)[0]);const a=await this.collections.getColl(s);if(a&&(r=await a.handleRequest(t,e))){if(this.stats&&this.stats.updateStats(r.date,r.status,t,e),this.allowRewrittenCache&&200===r.status)try{const t=await self.caches.open("wabac-"+a.name);i&&r.headers.set("x-wabac-is-ajax-req","true");const e=r.clone();await t.put(getRequest,e)}catch(t){console.warn(t)}return r}return n&&console.log("Not Found Range!: "+n),Object(o.k)(t)}async toGetRequest(t){let e=null;const r=t.headers.get("Content-Type");if("POST"===t.method||"PUT"===t.method)switch(r){case"application/x-www-form-urlencoded":e=await t.text()}const i=t.url+(t.url.indexOf("?")>=0?"&":"?")+e,n={method:"GET",headers:t.headers,mode:"navigate"===t.mode?"same-origin":t.mode,credentials:t.credentials,cache:t.cache,redirect:t.redirect,referrer:t.referrer,integrity:t.integrity};return new Request(i,n)}}},function(t,e,r){"use strict";r.r(e);var i='\n\n\n\n\nReplayWeb.page\n\n