@nypl/web-reader 0.2.0-alpha.8 → 0.2.0-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- var S=Object.defineProperty,pe=Object.defineProperties;var le=Object.getOwnPropertyDescriptors;var G=Object.getOwnPropertySymbols;var ue=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable;var H=(t,e,r)=>e in t?S(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,K=(t,e)=>{for(var r in e||(e={}))ue.call(e,r)&&H(t,r,e[r]);if(G)for(var r of G(e))me.call(e,r)&&H(t,r,e[r]);return t},Q=(t,e)=>pe(t,le(e)),he=t=>S(t,"__esModule",{value:!0});var $e=typeof require!="undefined"?require:t=>{throw new Error('Dynamic require of "'+t+'" is not supported')};var de=(t,e)=>{he(t);for(var r in e)S(t,r,{get:e[r],enumerable:!0})};var i=(t,e,r)=>new Promise((o,s)=>{var a=c=>{try{p(r.next(c))}catch(u){s(u)}},n=c=>{try{p(r.throw(c))}catch(u){s(u)}},p=c=>c.done?o(c.value):Promise.resolve(c.value).then(a,n);p((r=r.apply(t,e)).next())});de(exports,{default:()=>ce});"use strict";try{self["workbox:core:6.2.4"]&&_()}catch(t){}var fe=(t,...e)=>{let r=t;return e.length>0&&(r+=` :: ${JSON.stringify(e)}`),r};var J=fe;var l=class extends Error{constructor(e,r){let o=J(e,r);super(o);this.name=e,this.details=r}};var E=new Set;function T(t){E.add(t)}var h={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:typeof registration!="undefined"?registration.scope:""},$=t=>[h.prefix,t,h.suffix].filter(e=>e&&e.length>0).join("-"),ge=t=>{for(let e of Object.keys(h))t(e)},f={updateDetails:t=>{ge(e=>{typeof t[e]=="string"&&(h[e]=t[e])})},getGoogleAnalyticsName:t=>t||$(h.googleAnalytics),getPrecacheName:t=>t||$(h.precache),getPrefix:()=>h.prefix,getRuntimeName:t=>t||$(h.runtime),getSuffix:()=>h.suffix};function Y(t,e){let r=new URL(t);for(let o of e)r.searchParams.delete(o);return r.href}function O(t,e,r,o){return i(this,null,function*(){let s=Y(e.url,r);if(e.url===s)return t.match(e,o);let a=Object.assign(Object.assign({},o),{ignoreSearch:!0}),n=yield t.keys(e,a);for(let p of n){let c=Y(p.url,r);if(s===c)return t.match(p,o)}})}function w(t){t.then(()=>{})}var y=class{constructor(){this.promise=new Promise((e,r)=>{this.resolve=e,this.reject=r})}};function q(){return i(this,null,function*(){for(let t of E)yield t()})}var v=t=>new URL(String(t),location.href).href.replace(new RegExp(`^${location.origin}`),"");function x(t){return new Promise(e=>setTimeout(e,t))}function W(){self.addEventListener("activate",()=>self.clients.claim())}var Ee=(t,e)=>e.some(r=>t instanceof r),X,Z;function _e(){return X||(X=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function ye(){return Z||(Z=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var z=new WeakMap,U=new WeakMap,ee=new WeakMap,A=new WeakMap,P=new WeakMap;function ve(t){let e=new Promise((r,o)=>{let s=()=>{t.removeEventListener("success",a),t.removeEventListener("error",n)},a=()=>{r(m(t.result)),s()},n=()=>{o(t.error),s()};t.addEventListener("success",a),t.addEventListener("error",n)});return e.then(r=>{r instanceof IDBCursor&&z.set(r,t)}).catch(()=>{}),P.set(e,t),e}function Ne(t){if(U.has(t))return;let e=new Promise((r,o)=>{let s=()=>{t.removeEventListener("complete",a),t.removeEventListener("error",n),t.removeEventListener("abort",n)},a=()=>{r(),s()},n=()=>{o(t.error||new DOMException("AbortError","AbortError")),s()};t.addEventListener("complete",a),t.addEventListener("error",n),t.addEventListener("abort",n)});U.set(t,e)}var L={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return U.get(t);if(e==="objectStoreNames")return t.objectStoreNames||ee.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return m(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function re(t){L=t(L)}function ke(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let o=t.call(N(this),e,...r);return ee.set(o,e.sort?e.sort():[e]),m(o)}:ye().includes(t)?function(...e){return t.apply(N(this),e),m(z.get(this))}:function(...e){return m(t.apply(N(this),e))}}function je(t){return typeof t=="function"?ke(t):(t instanceof IDBTransaction&&Ne(t),Ee(t,_e())?new Proxy(t,L):t)}function m(t){if(t instanceof IDBRequest)return ve(t);if(A.has(t))return A.get(t);let e=je(t);return e!==t&&(A.set(t,e),P.set(e,t)),e}var N=t=>P.get(t);function te(t,e,{blocked:r,upgrade:o,blocking:s,terminated:a}={}){let n=indexedDB.open(t,e),p=m(n);return o&&n.addEventListener("upgradeneeded",c=>{o(m(n.result),c.oldVersion,c.newVersion,m(n.transaction))}),r&&n.addEventListener("blocked",()=>r()),p.then(c=>{a&&c.addEventListener("close",()=>a()),s&&c.addEventListener("versionchange",()=>s())}).catch(()=>{}),p}function oe(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",()=>e()),m(r).then(()=>{})}var Re=["get","getKey","getAll","getAllKeys","count"],Ce=["put","add","delete","clear"],I=new Map;function se(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(I.get(e))return I.get(e);let r=e.replace(/FromIndex$/,""),o=e!==r,s=Ce.includes(r);if(!(r in(o?IDBIndex:IDBObjectStore).prototype)||!(s||Re.includes(r)))return;let a=function(n,...p){return i(this,null,function*(){let c=this.transaction(n,s?"readwrite":"readonly"),u=c.store;return o&&(u=u.index(p.shift())),(yield Promise.all([u[r](...p),s&&c.done]))[0]})};return I.set(e,a),a}re(t=>Q(K({},t),{get:(e,r,o)=>se(e,r)||t.get(e,r,o),has:(e,r)=>!!se(e,r)||t.has(e,r)}));"use strict";try{self["workbox:expiration:6.2.4"]&&_()}catch(t){}var De="workbox-expiration",b="cache-entries",ne=t=>{let e=new URL(t,location.href);return e.hash="",e.href},F=class{constructor(e){this._db=null,this._cacheName=e}_upgradeDb(e){let r=e.createObjectStore(b,{keyPath:"id"});r.createIndex("cacheName","cacheName",{unique:!1}),r.createIndex("timestamp","timestamp",{unique:!1})}_upgradeDbAndDeleteOldDbs(e){this._upgradeDb(e),this._cacheName&&oe(this._cacheName)}setTimestamp(e,r){return i(this,null,function*(){e=ne(e);let o={url:e,timestamp:r,cacheName:this._cacheName,id:this._getId(e)},a=(yield this.getDb()).transaction(b,"readwrite",{durability:"relaxed"});yield a.store.put(o),yield a.done})}getTimestamp(e){return i(this,null,function*(){let o=yield(yield this.getDb()).get(b,this._getId(e));return o==null?void 0:o.timestamp})}expireEntries(e,r){return i(this,null,function*(){let o=yield this.getDb(),s=yield o.transaction(b).store.index("timestamp").openCursor(null,"prev"),a=[],n=0;for(;s;){let c=s.value;c.cacheName===this._cacheName&&(e&&c.timestamp<e||r&&n>=r?a.push(s.value):n++),s=yield s.continue()}let p=[];for(let c of a)yield o.delete(b,c.id),p.push(c.url);return p})}_getId(e){return this._cacheName+"|"+ne(e)}getDb(){return i(this,null,function*(){return this._db||(this._db=yield te(De,1,{upgrade:this._upgradeDbAndDeleteOldDbs.bind(this)})),this._db})}};var k=class{constructor(e,r={}){this._isRunning=!1,this._rerunRequested=!1,this._maxEntries=r.maxEntries,this._maxAgeSeconds=r.maxAgeSeconds,this._matchOptions=r.matchOptions,this._cacheName=e,this._timestampModel=new F(e)}expireEntries(){return i(this,null,function*(){if(this._isRunning){this._rerunRequested=!0;return}this._isRunning=!0;let e=this._maxAgeSeconds?Date.now()-this._maxAgeSeconds*1e3:0,r=yield this._timestampModel.expireEntries(e,this._maxEntries),o=yield self.caches.open(this._cacheName);for(let s of r)yield o.delete(s,this._matchOptions);this._isRunning=!1,this._rerunRequested&&(this._rerunRequested=!1,w(this.expireEntries()))})}updateTimestamp(e){return i(this,null,function*(){yield this._timestampModel.setTimestamp(e,Date.now())})}isURLExpired(e){return i(this,null,function*(){if(this._maxAgeSeconds){let r=yield this._timestampModel.getTimestamp(e),o=Date.now()-this._maxAgeSeconds*1e3;return r!==void 0?r<o:!0}else return!1})}delete(){return i(this,null,function*(){this._rerunRequested=!1,yield this._timestampModel.expireEntries(1/0)})}};var j=class{constructor(e={}){this.cachedResponseWillBeUsed=n=>i(this,[n],function*({event:r,request:o,cacheName:s,cachedResponse:a}){if(!a)return null;let p=this._isResponseDateFresh(a),c=this._getCacheExpiration(s);w(c.expireEntries());let u=c.updateTimestamp(o.url);if(r)try{r.waitUntil(u)}catch(B){}return p?a:null}),this.cacheDidUpdate=s=>i(this,[s],function*({cacheName:r,request:o}){let a=this._getCacheExpiration(r);yield a.updateTimestamp(o.url),yield a.expireEntries()}),this._config=e,this._maxAgeSeconds=e.maxAgeSeconds,this._cacheExpirations=new Map,e.purgeOnQuotaError&&T(()=>this.deleteCacheAndMetadata())}_getCacheExpiration(e){if(e===f.getRuntimeName())throw new l("expire-custom-caches-only");let r=this._cacheExpirations.get(e);return r||(r=new k(e,this._config),this._cacheExpirations.set(e,r)),r}_isResponseDateFresh(e){if(!this._maxAgeSeconds)return!0;let r=this._getDateHeaderTimestamp(e);if(r===null)return!0;let o=Date.now();return r>=o-this._maxAgeSeconds*1e3}_getDateHeaderTimestamp(e){if(!e.headers.has("date"))return null;let r=e.headers.get("date"),s=new Date(r).getTime();return isNaN(s)?null:s}deleteCacheAndMetadata(){return i(this,null,function*(){for(let[e,r]of this._cacheExpirations)yield self.caches.delete(e),yield r.delete();this._cacheExpirations=new Map})}};"use strict";try{self["workbox:strategies:6.2.4"]&&_()}catch(t){}function R(t){return typeof t=="string"?new Request(t):t}var C=class{constructor(e,r){this._cacheKeys={},Object.assign(this,r),this.event=r.event,this._strategy=e,this._handlerDeferred=new y,this._extendLifetimePromises=[],this._plugins=[...e.plugins],this._pluginStateMap=new Map;for(let o of this._plugins)this._pluginStateMap.set(o,{});this.event.waitUntil(this._handlerDeferred.promise)}fetch(e){return i(this,null,function*(){let{event:r}=this,o=R(e);if(o.mode==="navigate"&&r instanceof FetchEvent&&r.preloadResponse){let n=yield r.preloadResponse;if(n)return n}let s=this.hasCallback("fetchDidFail")?o.clone():null;try{for(let n of this.iterateCallbacks("requestWillFetch"))o=yield n({request:o.clone(),event:r})}catch(n){if(n instanceof Error)throw new l("plugin-error-request-will-fetch",{thrownErrorMessage:n.message})}let a=o.clone();try{let n;n=yield fetch(o,o.mode==="navigate"?void 0:this._strategy.fetchOptions);for(let p of this.iterateCallbacks("fetchDidSucceed"))n=yield p({event:r,request:a,response:n});return n}catch(n){throw s&&(yield this.runCallbacks("fetchDidFail",{error:n,event:r,originalRequest:s.clone(),request:a.clone()})),n}})}fetchAndCachePut(e){return i(this,null,function*(){let r=yield this.fetch(e),o=r.clone();return this.waitUntil(this.cachePut(e,o)),r})}cacheMatch(e){return i(this,null,function*(){let r=R(e),o,{cacheName:s,matchOptions:a}=this._strategy,n=yield this.getCacheKey(r,"read"),p=Object.assign(Object.assign({},a),{cacheName:s});o=yield caches.match(n,p);for(let c of this.iterateCallbacks("cachedResponseWillBeUsed"))o=(yield c({cacheName:s,matchOptions:a,cachedResponse:o,request:n,event:this.event}))||void 0;return o})}cachePut(e,r){return i(this,null,function*(){let o=R(e);yield x(0);let s=yield this.getCacheKey(o,"write");if(!r)throw new l("cache-put-with-no-response",{url:v(s.url)});let a=yield this._ensureResponseSafeToCache(r);if(!a)return!1;let{cacheName:n,matchOptions:p}=this._strategy,c=yield self.caches.open(n),u=this.hasCallback("cacheDidUpdate"),B=u?yield O(c,s.clone(),["__WB_REVISION__"],p):null;try{yield c.put(s,u?a.clone():a)}catch(g){if(g instanceof Error)throw g.name==="QuotaExceededError"&&(yield q()),g}for(let g of this.iterateCallbacks("cacheDidUpdate"))yield g({cacheName:n,oldResponse:B,newResponse:a.clone(),request:s,event:this.event});return!0})}getCacheKey(e,r){return i(this,null,function*(){if(!this._cacheKeys[r]){let o=e;for(let s of this.iterateCallbacks("cacheKeyWillBeUsed"))o=R(yield s({mode:r,request:o,event:this.event,params:this.params}));this._cacheKeys[r]=o}return this._cacheKeys[r]})}hasCallback(e){for(let r of this._strategy.plugins)if(e in r)return!0;return!1}runCallbacks(e,r){return i(this,null,function*(){for(let o of this.iterateCallbacks(e))yield o(r)})}*iterateCallbacks(e){for(let r of this._strategy.plugins)if(typeof r[e]=="function"){let o=this._pluginStateMap.get(r);yield a=>{let n=Object.assign(Object.assign({},a),{state:o});return r[e](n)}}}waitUntil(e){return this._extendLifetimePromises.push(e),e}doneWaiting(){return i(this,null,function*(){let e;for(;e=this._extendLifetimePromises.shift();)yield e})}destroy(){this._handlerDeferred.resolve(null)}_ensureResponseSafeToCache(e){return i(this,null,function*(){let r=e,o=!1;for(let s of this.iterateCallbacks("cacheWillUpdate"))if(r=(yield s({request:this.request,response:r,event:this.event}))||void 0,o=!0,!r)break;return o||r&&r.status!==200&&(r=void 0),r})}};var d=class{constructor(e={}){this.cacheName=f.getRuntimeName(e.cacheName),this.plugins=e.plugins||[],this.fetchOptions=e.fetchOptions,this.matchOptions=e.matchOptions}handle(e){let[r]=this.handleAll(e);return r}handleAll(e){e instanceof FetchEvent&&(e={event:e,request:e.request});let r=e.event,o=typeof e.request=="string"?new Request(e.request):e.request,s="params"in e?e.params:void 0,a=new C(this,{event:r,request:o,params:s}),n=this._getResponse(a,o,r),p=this._awaitComplete(n,a,o,r);return[n,p]}_getResponse(e,r,o){return i(this,null,function*(){yield e.runCallbacks("handlerWillStart",{event:o,request:r});let s;try{if(s=yield this._handle(r,e),!s||s.type==="error")throw new l("no-response",{url:r.url})}catch(a){if(a instanceof Error){for(let n of e.iterateCallbacks("handlerDidError"))if(s=yield n({error:a,event:o,request:r}),s)break}if(!s)throw a}for(let a of e.iterateCallbacks("handlerWillRespond"))s=yield a({event:o,request:r,response:s});return s})}_awaitComplete(e,r,o,s){return i(this,null,function*(){let a,n;try{a=yield e}catch(p){}try{yield r.runCallbacks("handlerDidRespond",{event:s,request:o,response:a}),yield r.doneWaiting()}catch(p){p instanceof Error&&(n=p)}if(yield r.runCallbacks("handlerDidComplete",{event:s,request:o,response:a,error:n}),r.destroy(),n)throw n})}};var D=class extends d{_handle(e,r){return i(this,null,function*(){let o=[],s=yield r.cacheMatch(e),a;if(!s)try{s=yield r.fetchAndCachePut(e)}catch(n){n instanceof Error&&(a=n)}if(!s)throw new l("no-response",{url:e.url,error:a});return s})}};var ae=!1;var V="webpub-cache";var ie=7*24*60*60;var Te="v1";W();function ce({cacheExpirationSeconds:t=ie}={}){M("INITIALIZING"),self.addEventListener("install",e=>{M("INSTALLING ");function r(){return i(this,null,function*(){self.skipWaiting(),M("INSTALLED")})}e.waitUntil(r)}),self.addEventListener("fetch",e=>{if(e.request.method!=="GET")return;function r(){return i(this,null,function*(){return(yield(yield caches.open(V)).match(e.request))?new D({cacheName:V,plugins:[new j({maxAgeSeconds:t})]}).handle(e):fetch(e.request)})}e.respondWith(r())})}function M(t){ae&&console.log(`SW (${Te}) -`,t)}
1
+ var W=Object.defineProperty,de=Object.defineProperties;var fe=Object.getOwnPropertyDescriptors;var Q=Object.getOwnPropertySymbols;var ge=Object.prototype.hasOwnProperty,we=Object.prototype.propertyIsEnumerable;var J=(t,e,r)=>e in t?W(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,x=(t,e)=>{for(var r in e||(e={}))ge.call(e,r)&&J(t,r,e[r]);if(Q)for(var r of Q(e))we.call(e,r)&&J(t,r,e[r]);return t},E=(t,e)=>de(t,fe(e)),be=t=>W(t,"__esModule",{value:!0});var Fe=typeof require!="undefined"?require:t=>{throw new Error('Dynamic require of "'+t+'" is not supported')};var xe=(t,e)=>{be(t);for(var r in e)W(t,r,{get:e[r],enumerable:!0})};var i=(t,e,r)=>new Promise((o,s)=>{var n=c=>{try{p(r.next(c))}catch(u){s(u)}},a=c=>{try{p(r.throw(c))}catch(u){s(u)}},p=c=>c.done?o(c.value):Promise.resolve(c.value).then(n,a);p((r=r.apply(t,e)).next())});xe(exports,{default:()=>ue});"use strict";try{self["workbox:core:6.2.4"]&&_()}catch(t){}var Ee=(t,...e)=>{let r=t;return e.length>0&&(r+=` :: ${JSON.stringify(e)}`),r};var Y=Ee;var l=class extends Error{constructor(e,r){let o=Y(e,r);super(o);this.name=e,this.details=r}};var k=new Set;function P(t){k.add(t)}var d={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:typeof registration!="undefined"?registration.scope:""},A=t=>[d.prefix,t,d.suffix].filter(e=>e&&e.length>0).join("-"),_e=t=>{for(let e of Object.keys(d))t(e)},g={updateDetails:t=>{_e(e=>{typeof t[e]=="string"&&(d[e]=t[e])})},getGoogleAnalyticsName:t=>t||A(d.googleAnalytics),getPrecacheName:t=>t||A(d.precache),getPrefix:()=>d.prefix,getRuntimeName:t=>t||A(d.runtime),getSuffix:()=>d.suffix};function X(t,e){let r=new URL(t);for(let o of e)r.searchParams.delete(o);return r.href}function q(t,e,r,o){return i(this,null,function*(){let s=X(e.url,r);if(e.url===s)return t.match(e,o);let n=Object.assign(Object.assign({},o),{ignoreSearch:!0}),a=yield t.keys(e,n);for(let p of a){let c=X(p.url,r);if(s===c)return t.match(p,o)}})}function y(t){t.then(()=>{})}var j=class{constructor(){this.promise=new Promise((e,r)=>{this.resolve=e,this.reject=r})}};function L(){return i(this,null,function*(){for(let t of k)yield t()})}var R=t=>new URL(String(t),location.href).href.replace(new RegExp(`^${location.origin}`),"");function v(t){return new Promise(e=>setTimeout(e,t))}function I(){self.addEventListener("activate",()=>self.clients.claim())}var ke=(t,e)=>e.some(r=>t instanceof r),Z,z;function je(){return Z||(Z=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Re(){return z||(z=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var ee=new WeakMap,F=new WeakMap,re=new WeakMap,M=new WeakMap,V=new WeakMap;function Ce(t){let e=new Promise((r,o)=>{let s=()=>{t.removeEventListener("success",n),t.removeEventListener("error",a)},n=()=>{r(h(t.result)),s()},a=()=>{o(t.error),s()};t.addEventListener("success",n),t.addEventListener("error",a)});return e.then(r=>{r instanceof IDBCursor&&ee.set(r,t)}).catch(()=>{}),V.set(e,t),e}function De(t){if(F.has(t))return;let e=new Promise((r,o)=>{let s=()=>{t.removeEventListener("complete",n),t.removeEventListener("error",a),t.removeEventListener("abort",a)},n=()=>{r(),s()},a=()=>{o(t.error||new DOMException("AbortError","AbortError")),s()};t.addEventListener("complete",n),t.addEventListener("error",a),t.addEventListener("abort",a)});F.set(t,e)}var B={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return F.get(t);if(e==="objectStoreNames")return t.objectStoreNames||re.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return h(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function te(t){B=t(B)}function Se(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let o=t.call(C(this),e,...r);return re.set(o,e.sort?e.sort():[e]),h(o)}:Re().includes(t)?function(...e){return t.apply(C(this),e),h(ee.get(this))}:function(...e){return h(t.apply(C(this),e))}}function Te(t){return typeof t=="function"?Se(t):(t instanceof IDBTransaction&&De(t),ke(t,je())?new Proxy(t,B):t)}function h(t){if(t instanceof IDBRequest)return Ce(t);if(M.has(t))return M.get(t);let e=Te(t);return e!==t&&(M.set(t,e),V.set(e,t)),e}var C=t=>V.get(t);function oe(t,e,{blocked:r,upgrade:o,blocking:s,terminated:n}={}){let a=indexedDB.open(t,e),p=h(a);return o&&a.addEventListener("upgradeneeded",c=>{o(h(a.result),c.oldVersion,c.newVersion,h(a.transaction))}),r&&a.addEventListener("blocked",()=>r()),p.then(c=>{n&&c.addEventListener("close",()=>n()),s&&c.addEventListener("versionchange",()=>s())}).catch(()=>{}),p}function se(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",()=>e()),h(r).then(()=>{})}var $e=["get","getKey","getAll","getAllKeys","count"],Oe=["put","add","delete","clear"],G=new Map;function ne(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(G.get(e))return G.get(e);let r=e.replace(/FromIndex$/,""),o=e!==r,s=Oe.includes(r);if(!(r in(o?IDBIndex:IDBObjectStore).prototype)||!(s||$e.includes(r)))return;let n=function(a,...p){return i(this,null,function*(){let c=this.transaction(a,s?"readwrite":"readonly"),u=c.store;return o&&(u=u.index(p.shift())),(yield Promise.all([u[r](...p),s&&c.done]))[0]})};return G.set(e,n),n}te(t=>E(x({},t),{get:(e,r,o)=>ne(e,r)||t.get(e,r,o),has:(e,r)=>!!ne(e,r)||t.has(e,r)}));"use strict";try{self["workbox:expiration:6.2.4"]&&_()}catch(t){}var Ue="workbox-expiration",N="cache-entries",ae=t=>{let e=new URL(t,location.href);return e.hash="",e.href},H=class{constructor(e){this._db=null,this._cacheName=e}_upgradeDb(e){let r=e.createObjectStore(N,{keyPath:"id"});r.createIndex("cacheName","cacheName",{unique:!1}),r.createIndex("timestamp","timestamp",{unique:!1})}_upgradeDbAndDeleteOldDbs(e){this._upgradeDb(e),this._cacheName&&se(this._cacheName)}setTimestamp(e,r){return i(this,null,function*(){e=ae(e);let o={url:e,timestamp:r,cacheName:this._cacheName,id:this._getId(e)},n=(yield this.getDb()).transaction(N,"readwrite",{durability:"relaxed"});yield n.store.put(o),yield n.done})}getTimestamp(e){return i(this,null,function*(){let o=yield(yield this.getDb()).get(N,this._getId(e));return o==null?void 0:o.timestamp})}expireEntries(e,r){return i(this,null,function*(){let o=yield this.getDb(),s=yield o.transaction(N).store.index("timestamp").openCursor(null,"prev"),n=[],a=0;for(;s;){let c=s.value;c.cacheName===this._cacheName&&(e&&c.timestamp<e||r&&a>=r?n.push(s.value):a++),s=yield s.continue()}let p=[];for(let c of n)yield o.delete(N,c.id),p.push(c.url);return p})}_getId(e){return this._cacheName+"|"+ae(e)}getDb(){return i(this,null,function*(){return this._db||(this._db=yield oe(Ue,1,{upgrade:this._upgradeDbAndDeleteOldDbs.bind(this)})),this._db})}};var D=class{constructor(e,r={}){this._isRunning=!1,this._rerunRequested=!1,this._maxEntries=r.maxEntries,this._maxAgeSeconds=r.maxAgeSeconds,this._matchOptions=r.matchOptions,this._cacheName=e,this._timestampModel=new H(e)}expireEntries(){return i(this,null,function*(){if(this._isRunning){this._rerunRequested=!0;return}this._isRunning=!0;let e=this._maxAgeSeconds?Date.now()-this._maxAgeSeconds*1e3:0,r=yield this._timestampModel.expireEntries(e,this._maxEntries),o=yield self.caches.open(this._cacheName);for(let s of r)yield o.delete(s,this._matchOptions);this._isRunning=!1,this._rerunRequested&&(this._rerunRequested=!1,y(this.expireEntries()))})}updateTimestamp(e){return i(this,null,function*(){yield this._timestampModel.setTimestamp(e,Date.now())})}isURLExpired(e){return i(this,null,function*(){if(this._maxAgeSeconds){let r=yield this._timestampModel.getTimestamp(e),o=Date.now()-this._maxAgeSeconds*1e3;return r!==void 0?r<o:!0}else return!1})}delete(){return i(this,null,function*(){this._rerunRequested=!1,yield this._timestampModel.expireEntries(1/0)})}};var S=class{constructor(e={}){this.cachedResponseWillBeUsed=a=>i(this,[a],function*({event:r,request:o,cacheName:s,cachedResponse:n}){if(!n)return null;let p=this._isResponseDateFresh(n),c=this._getCacheExpiration(s);y(c.expireEntries());let u=c.updateTimestamp(o.url);if(r)try{r.waitUntil(u)}catch(b){}return p?n:null}),this.cacheDidUpdate=s=>i(this,[s],function*({cacheName:r,request:o}){let n=this._getCacheExpiration(r);yield n.updateTimestamp(o.url),yield n.expireEntries()}),this._config=e,this._maxAgeSeconds=e.maxAgeSeconds,this._cacheExpirations=new Map,e.purgeOnQuotaError&&P(()=>this.deleteCacheAndMetadata())}_getCacheExpiration(e){if(e===g.getRuntimeName())throw new l("expire-custom-caches-only");let r=this._cacheExpirations.get(e);return r||(r=new D(e,this._config),this._cacheExpirations.set(e,r)),r}_isResponseDateFresh(e){if(!this._maxAgeSeconds)return!0;let r=this._getDateHeaderTimestamp(e);if(r===null)return!0;let o=Date.now();return r>=o-this._maxAgeSeconds*1e3}_getDateHeaderTimestamp(e){if(!e.headers.has("date"))return null;let r=e.headers.get("date"),s=new Date(r).getTime();return isNaN(s)?null:s}deleteCacheAndMetadata(){return i(this,null,function*(){for(let[e,r]of this._cacheExpirations)yield self.caches.delete(e),yield r.delete();this._cacheExpirations=new Map})}};"use strict";try{self["workbox:strategies:6.2.4"]&&_()}catch(t){}function T(t){return typeof t=="string"?new Request(t):t}var $=class{constructor(e,r){this._cacheKeys={},Object.assign(this,r),this.event=r.event,this._strategy=e,this._handlerDeferred=new j,this._extendLifetimePromises=[],this._plugins=[...e.plugins],this._pluginStateMap=new Map;for(let o of this._plugins)this._pluginStateMap.set(o,{});this.event.waitUntil(this._handlerDeferred.promise)}fetch(e){return i(this,null,function*(){let{event:r}=this,o=T(e);if(o.mode==="navigate"&&r instanceof FetchEvent&&r.preloadResponse){let a=yield r.preloadResponse;if(a)return a}let s=this.hasCallback("fetchDidFail")?o.clone():null;try{for(let a of this.iterateCallbacks("requestWillFetch"))o=yield a({request:o.clone(),event:r})}catch(a){if(a instanceof Error)throw new l("plugin-error-request-will-fetch",{thrownErrorMessage:a.message})}let n=o.clone();try{let a;a=yield fetch(o,o.mode==="navigate"?void 0:this._strategy.fetchOptions);for(let p of this.iterateCallbacks("fetchDidSucceed"))a=yield p({event:r,request:n,response:a});return a}catch(a){throw s&&(yield this.runCallbacks("fetchDidFail",{error:a,event:r,originalRequest:s.clone(),request:n.clone()})),a}})}fetchAndCachePut(e){return i(this,null,function*(){let r=yield this.fetch(e),o=r.clone();return this.waitUntil(this.cachePut(e,o)),r})}cacheMatch(e){return i(this,null,function*(){let r=T(e),o,{cacheName:s,matchOptions:n}=this._strategy,a=yield this.getCacheKey(r,"read"),p=Object.assign(Object.assign({},n),{cacheName:s});o=yield caches.match(a,p);for(let c of this.iterateCallbacks("cachedResponseWillBeUsed"))o=(yield c({cacheName:s,matchOptions:n,cachedResponse:o,request:a,event:this.event}))||void 0;return o})}cachePut(e,r){return i(this,null,function*(){let o=T(e);yield v(0);let s=yield this.getCacheKey(o,"write");if(!r)throw new l("cache-put-with-no-response",{url:R(s.url)});let n=yield this._ensureResponseSafeToCache(r);if(!n)return!1;let{cacheName:a,matchOptions:p}=this._strategy,c=yield self.caches.open(a),u=this.hasCallback("cacheDidUpdate"),b=u?yield q(c,s.clone(),["__WB_REVISION__"],p):null;try{yield c.put(s,u?n.clone():n)}catch(m){if(m instanceof Error)throw m.name==="QuotaExceededError"&&(yield L()),m}for(let m of this.iterateCallbacks("cacheDidUpdate"))yield m({cacheName:a,oldResponse:b,newResponse:n.clone(),request:s,event:this.event});return!0})}getCacheKey(e,r){return i(this,null,function*(){if(!this._cacheKeys[r]){let o=e;for(let s of this.iterateCallbacks("cacheKeyWillBeUsed"))o=T(yield s({mode:r,request:o,event:this.event,params:this.params}));this._cacheKeys[r]=o}return this._cacheKeys[r]})}hasCallback(e){for(let r of this._strategy.plugins)if(e in r)return!0;return!1}runCallbacks(e,r){return i(this,null,function*(){for(let o of this.iterateCallbacks(e))yield o(r)})}*iterateCallbacks(e){for(let r of this._strategy.plugins)if(typeof r[e]=="function"){let o=this._pluginStateMap.get(r);yield n=>{let a=Object.assign(Object.assign({},n),{state:o});return r[e](a)}}}waitUntil(e){return this._extendLifetimePromises.push(e),e}doneWaiting(){return i(this,null,function*(){let e;for(;e=this._extendLifetimePromises.shift();)yield e})}destroy(){this._handlerDeferred.resolve(null)}_ensureResponseSafeToCache(e){return i(this,null,function*(){let r=e,o=!1;for(let s of this.iterateCallbacks("cacheWillUpdate"))if(r=(yield s({request:this.request,response:r,event:this.event}))||void 0,o=!0,!r)break;return o||r&&r.status!==200&&(r=void 0),r})}};var f=class{constructor(e={}){this.cacheName=g.getRuntimeName(e.cacheName),this.plugins=e.plugins||[],this.fetchOptions=e.fetchOptions,this.matchOptions=e.matchOptions}handle(e){let[r]=this.handleAll(e);return r}handleAll(e){e instanceof FetchEvent&&(e={event:e,request:e.request});let r=e.event,o=typeof e.request=="string"?new Request(e.request):e.request,s="params"in e?e.params:void 0,n=new $(this,{event:r,request:o,params:s}),a=this._getResponse(n,o,r),p=this._awaitComplete(a,n,o,r);return[a,p]}_getResponse(e,r,o){return i(this,null,function*(){yield e.runCallbacks("handlerWillStart",{event:o,request:r});let s;try{if(s=yield this._handle(r,e),!s||s.type==="error")throw new l("no-response",{url:r.url})}catch(n){if(n instanceof Error){for(let a of e.iterateCallbacks("handlerDidError"))if(s=yield a({error:n,event:o,request:r}),s)break}if(!s)throw n}for(let n of e.iterateCallbacks("handlerWillRespond"))s=yield n({event:o,request:r,response:s});return s})}_awaitComplete(e,r,o,s){return i(this,null,function*(){let n,a;try{n=yield e}catch(p){}try{yield r.runCallbacks("handlerDidRespond",{event:s,request:o,response:n}),yield r.doneWaiting()}catch(p){p instanceof Error&&(a=p)}if(yield r.runCallbacks("handlerDidComplete",{event:s,request:o,response:n,error:a}),r.destroy(),a)throw a})}};var O=class extends f{_handle(e,r){return i(this,null,function*(){let o=[],s=yield r.cacheMatch(e),n;if(!s)try{s=yield r.fetchAndCachePut(e)}catch(a){a instanceof Error&&(n=a)}if(!s)throw new l("no-response",{url:e.url,error:n});return s})}};var ie=!1;var U="webpub-cache";var ce="PRECACHE_PUBLICATIONS",pe=7*24*60*60;var Pe="v1";I();function ue({cacheExpirationSeconds:t=pe}={}){w("INITIALIZING"),self.addEventListener("install",e=>{w("INSTALLING ");function r(){return i(this,null,function*(){self.skipWaiting(),w("INSTALLED")})}e.waitUntil(r)}),self.addEventListener("message",e=>i(this,null,function*(){if(e.data.type===ce){if(w("Precaching publications"),typeof e.data.publications!="object"){console.error("Precache event missing publications");return}yield Ae(e.data.publications)}})),self.addEventListener("fetch",e=>{if(e.request.method!=="GET")return;function r(){return i(this,null,function*(){return(yield(yield caches.open(U)).match(e.request))?new O({cacheName:U,plugins:[new S({maxAgeSeconds:t})]}).handle(e):fetch(e.request)})}e.respondWith(r())})}function Ae(t){return i(this,null,function*(){let e=yield caches.open(U),s=(yield Promise.allSettled(t.map(n=>i(this,null,function*(){let a=me(n.manifestUrl,n.proxyUrl),p=yield e.match(a);if(p)return w(`Manifest match found for ${a}`),E(x({},n),{manifest:yield p.json()});let c=yield fetch(a);le(a,c),yield e.put(a,c.clone());let u=yield c.json();return E(x({},n),{manifest:u})})))).map(n=>n.status==="fulfilled"?n.value:void 0).filter(qe).map(n=>i(this,null,function*(){var u,b;let a=he((u=n.manifest.resources)!=null?u:[],n.manifestUrl,n.proxyUrl),p=he((b=n.manifest.readingOrder)!=null?b:[],n.manifestUrl,n.proxyUrl),c=Array.from(new Set([...a,...p]));yield Promise.all(c.map(m=>i(this,null,function*(){if(yield e.match(m)){w(`Resource match found for ${m}`);return}let K=yield fetch(m);return le(m,K),yield e.put(m,K)})))}));return yield Promise.allSettled(s)})}function qe(t){return!!t}function le(t,e){if(!e.ok){let r=`Bad response status for: ${t}. Status: ${e.status}`;throw console.warn(r),new Error(r)}}function me(t,e){return e?`${e}${encodeURIComponent(t)}`:t}function Le(t,e,r){return me(new URL(t,e).toString(),r)}function he(t,e,r){return t.map(o=>Le(o.href,e,r))}function w(t){ie&&console.log(`SW (${Pe}) -`,t)}
2
2
  //# sourceMappingURL=sw.js.map