zip-peek 0.6.5 → 0.6.6-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -28,7 +28,7 @@ function zipPackagePathname(zipUrl) {
28
28
  try {
29
29
  return new URL(zipUrl).pathname;
30
30
  }
31
- catch {
31
+ catch (_a) {
32
32
  return zipUrl.split("?")[0].split("#")[0];
33
33
  }
34
34
  }
@@ -49,21 +49,22 @@ function zipServiceWorkerScriptMatches(scriptURL, expectedWorkerUrl) {
49
49
  const resolved = new URL(scriptURL, window.location.href).href;
50
50
  return resolved === expected;
51
51
  }
52
- catch {
52
+ catch (_a) {
53
53
  try {
54
54
  return /\/zipServiceWorker(\.[0-9a-f]{8})?\.js(\?|$)/.test(new URL(scriptURL).pathname);
55
55
  }
56
- catch {
56
+ catch (_b) {
57
57
  return false;
58
58
  }
59
59
  }
60
60
  }
61
61
  async function unregisterMismatchedScopeZipServiceWorkerIfNeeded(expectedWorkerUrl, expectedScopeUrl) {
62
+ var _a, _b, _c, _d, _e;
62
63
  const expectedWorkerHref = new URL(expectedWorkerUrl, window.location.href).href;
63
64
  const wantScopePath = normalizeScopePath(expectedScopeUrl);
64
65
  const registrations = await navigator.serviceWorker.getRegistrations();
65
66
  for (const reg of registrations) {
66
- const scriptURL = reg.installing?.scriptURL ?? reg.waiting?.scriptURL ?? reg.active?.scriptURL;
67
+ const scriptURL = (_d = (_b = (_a = reg.installing) === null || _a === void 0 ? void 0 : _a.scriptURL) !== null && _b !== void 0 ? _b : (_c = reg.waiting) === null || _c === void 0 ? void 0 : _c.scriptURL) !== null && _d !== void 0 ? _d : (_e = reg.active) === null || _e === void 0 ? void 0 : _e.scriptURL;
67
68
  if (!scriptURL) {
68
69
  continue;
69
70
  }
@@ -71,7 +72,7 @@ async function unregisterMismatchedScopeZipServiceWorkerIfNeeded(expectedWorkerU
71
72
  try {
72
73
  scriptHref = new URL(scriptURL, window.location.href).href;
73
74
  }
74
- catch {
75
+ catch (_f) {
75
76
  continue;
76
77
  }
77
78
  if (scriptHref !== expectedWorkerHref) {
@@ -85,18 +86,26 @@ async function unregisterMismatchedScopeZipServiceWorkerIfNeeded(expectedWorkerU
85
86
  }
86
87
  }
87
88
  async function ensureZipServiceWorkerRegistered({ workerUrl, scopeUrl, reloadOnFirstInstall = true, }) {
89
+ var _a, _b, _c;
88
90
  if (!("serviceWorker" in navigator)) {
89
91
  return false;
90
92
  }
91
93
  await unregisterMismatchedScopeZipServiceWorkerIfNeeded(workerUrl, scopeUrl);
92
94
  const existing = await navigator.serviceWorker.getRegistration(scopeUrl);
93
95
  const alreadyRegistered = existing &&
94
- (zipServiceWorkerScriptMatches(existing.active?.scriptURL, workerUrl) ||
95
- zipServiceWorkerScriptMatches(existing.waiting?.scriptURL, workerUrl) ||
96
- zipServiceWorkerScriptMatches(existing.installing?.scriptURL, workerUrl));
96
+ (zipServiceWorkerScriptMatches((_a = existing.active) === null || _a === void 0 ? void 0 : _a.scriptURL, workerUrl) ||
97
+ zipServiceWorkerScriptMatches((_b = existing.waiting) === null || _b === void 0 ? void 0 : _b.scriptURL, workerUrl) ||
98
+ zipServiceWorkerScriptMatches((_c = existing.installing) === null || _c === void 0 ? void 0 : _c.scriptURL, workerUrl));
97
99
  if (!alreadyRegistered) {
98
- await navigator.serviceWorker.register(workerUrl, { scope: scopeUrl });
99
- console.log("Zip service worker registered successfully");
100
+ try {
101
+ await navigator.serviceWorker.register(workerUrl, { scope: scopeUrl });
102
+ console.log("Zip service worker registered successfully");
103
+ }
104
+ catch (error) {
105
+ const context = describeRegistrationFailureContext();
106
+ console.error("zip-peek: service worker registration failed", context, error);
107
+ throw attachZipPeekInfo(error, `Service worker registration failed (${context})`);
108
+ }
100
109
  }
101
110
  else {
102
111
  console.log("Zip service worker already registered; skipping register().");
@@ -108,8 +117,9 @@ async function ensureZipServiceWorkerRegistered({ workerUrl, scopeUrl, reloadOnF
108
117
  }
109
118
  return false;
110
119
  }
111
- /** Probe cookie / localStorage so registration failures can explain blocked storage. */
112
- function describeClientStorageAccess() {
120
+ /** Context attached when service worker registration fails. */
121
+ function describeRegistrationFailureContext() {
122
+ var _a;
113
123
  const cookieEnabled = typeof navigator !== "undefined" ? navigator.cookieEnabled : false;
114
124
  let localStorageAccess = "ok";
115
125
  try {
@@ -119,7 +129,14 @@ function describeClientStorageAccess() {
119
129
  catch (error) {
120
130
  localStorageAccess = error instanceof Error ? error.message : String(error);
121
131
  }
122
- return `cookieEnabled=${cookieEnabled}; localStorage=${localStorageAccess}`;
132
+ return [
133
+ `visibility=${document.visibilityState}`,
134
+ `hidden=${document.hidden}`,
135
+ `online=${navigator.onLine}`,
136
+ `hasController=${Boolean((_a = navigator.serviceWorker) === null || _a === void 0 ? void 0 : _a.controller)}`,
137
+ `cookieEnabled=${cookieEnabled}`,
138
+ `localStorage=${localStorageAccess}`,
139
+ ].join("; ");
123
140
  }
124
141
  function attachZipPeekInfo(error, info) {
125
142
  const err = (0, types_1.toZipPeekError)(error);
@@ -130,10 +147,11 @@ function attachZipPeekInfo(error, info) {
130
147
  }
131
148
  function reportZipPeekError(onError, error, info) {
132
149
  const err = (0, types_1.toZipPeekError)(error);
133
- onError?.(err, info ?? err.zipPeekInfo);
150
+ onError === null || onError === void 0 ? void 0 : onError(err, info !== null && info !== void 0 ? info : err.zipPeekInfo);
134
151
  }
135
152
  function errorFromWorkerResponse(response) {
136
- const error = new Error(response.error ?? (0, types_1.formatZipPeekError)("Service worker did not acknowledge the message."));
153
+ var _a;
154
+ const error = new Error((_a = response.error) !== null && _a !== void 0 ? _a : (0, types_1.formatZipPeekError)("Service worker did not acknowledge the message."));
137
155
  if (response.errorStack) {
138
156
  error.stack = response.errorStack;
139
157
  }
@@ -217,13 +235,14 @@ function rearmExpiryIfStillTracked(normalizedZipUrl) {
217
235
  urlExpiryTimers.set(normalizedZipUrl, timerId);
218
236
  }
219
237
  async function invokeUrlExpiry(normalizedZipUrl) {
238
+ var _a;
220
239
  if (!currentOnUrlExpiry || urlExpiryInFlight.has(normalizedZipUrl)) {
221
240
  return;
222
241
  }
223
242
  urlExpiryInFlight.add(normalizedZipUrl);
224
243
  try {
225
244
  await currentOnUrlExpiry({
226
- expiredZipURL: trackedZipUrls.get(normalizedZipUrl) ?? "",
245
+ expiredZipURL: (_a = trackedZipUrls.get(normalizedZipUrl)) !== null && _a !== void 0 ? _a : "",
227
246
  normalizedExpiredZipURL: normalizedZipUrl,
228
247
  });
229
248
  }
@@ -241,6 +260,7 @@ function ensureClientMessageListener() {
241
260
  }
242
261
  clientMessageListenerInstalled = true;
243
262
  navigator.serviceWorker.addEventListener("message", (event) => {
263
+ var _a, _b, _c;
244
264
  const data = event.data;
245
265
  if (!data) {
246
266
  return;
@@ -263,8 +283,8 @@ function ensureClientMessageListener() {
263
283
  if (data.type !== "ZIP_SW_ERROR" || !currentOnError) {
264
284
  return;
265
285
  }
266
- const error = new Error(data.error?.message ?? (0, types_1.formatZipPeekError)("Service worker reported an error."));
267
- if (data.error?.stack) {
286
+ const error = new Error((_b = (_a = data.error) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : (0, types_1.formatZipPeekError)("Service worker reported an error."));
287
+ if ((_c = data.error) === null || _c === void 0 ? void 0 : _c.stack) {
268
288
  error.stack = data.error.stack;
269
289
  }
270
290
  currentOnError(error, data.info ? (0, types_1.formatZipPeekError)(data.info) : undefined);
@@ -359,7 +379,11 @@ async function initZipPeek({ workerUrl, scopeUrl, reloadOnFirstInstall = true, c
359
379
  });
360
380
  }
361
381
  catch (error) {
362
- throw attachZipPeekInfo(error, `Service worker registration failed (${describeClientStorageAccess()})`);
382
+ const err = error;
383
+ if (!err.zipPeekInfo) {
384
+ throw attachZipPeekInfo(error, `Service worker registration failed (${describeRegistrationFailureContext()})`);
385
+ }
386
+ throw error;
363
387
  }
364
388
  if (reloaded) {
365
389
  return { reloaded: true, initialized: false };
@@ -370,7 +394,7 @@ async function initZipPeek({ workerUrl, scopeUrl, reloadOnFirstInstall = true, c
370
394
  zipAssetCacheName,
371
395
  assetCacheTtlMs,
372
396
  logPrefix,
373
- allowedZipUrls: normalizedAllowedZipUrls ?? null,
397
+ allowedZipUrls: normalizedAllowedZipUrls !== null && normalizedAllowedZipUrls !== void 0 ? normalizedAllowedZipUrls : null,
374
398
  requireExactManifestPath,
375
399
  },
376
400
  }, "Failed to configure service worker");
@@ -384,7 +408,7 @@ async function initZipPeek({ workerUrl, scopeUrl, reloadOnFirstInstall = true, c
384
408
  zipAssetCacheName,
385
409
  assetCacheTtlMs,
386
410
  logPrefix,
387
- allowedZipUrls: normalizedAllowedZipUrls ?? null,
411
+ allowedZipUrls: normalizedAllowedZipUrls !== null && normalizedAllowedZipUrls !== void 0 ? normalizedAllowedZipUrls : null,
388
412
  requireExactManifestPath,
389
413
  },
390
414
  }, "Failed to reconfigure service worker after cache clear");
package/dist/zip-utils.js CHANGED
@@ -13,7 +13,7 @@ function isZipPackage(url) {
13
13
  const u = new URL(url);
14
14
  return u.pathname.endsWith(".zip");
15
15
  }
16
- catch {
16
+ catch (_a) {
17
17
  return url.split("?")[0].endsWith(".zip");
18
18
  }
19
19
  }
@@ -48,14 +48,15 @@ function normalizeZipUrl(urlString, options = {}) {
48
48
  }
49
49
  /** Basename of the ZIP file from a package URL, without the `.zip` extension. */
50
50
  function zipBasenameWithoutExtension(zipUrl) {
51
+ var _a, _b;
51
52
  try {
52
53
  const pathname = new URL(zipUrl, "http://local").pathname;
53
- const file = pathname.split("/").pop() ?? "";
54
+ const file = (_a = pathname.split("/").pop()) !== null && _a !== void 0 ? _a : "";
54
55
  return file.endsWith(".zip") ? file.slice(0, -4) : file;
55
56
  }
56
- catch {
57
+ catch (_c) {
57
58
  const path = zipUrl.split("?")[0].split("#")[0];
58
- const file = path.split("/").pop() ?? "";
59
+ const file = (_b = path.split("/").pop()) !== null && _b !== void 0 ? _b : "";
59
60
  return file.endsWith(".zip") ? file.slice(0, -4) : file;
60
61
  }
61
62
  }
@@ -70,7 +71,7 @@ function safeDecodeSegment(s) {
70
71
  try {
71
72
  return decodeURIComponent(s);
72
73
  }
73
- catch {
74
+ catch (_a) {
74
75
  return s;
75
76
  }
76
77
  }
@@ -1,2 +1,2 @@
1
- (()=>{"use strict";var e={553(e,t){function n(e){const n=e.trim();return n.startsWith(t.ZIP_PEEK_ERROR_PREFIX)?n:`${t.ZIP_PEEK_ERROR_PREFIX} ${n}`}t.ZIP_PEEK_ERROR_PREFIX=void 0,t.formatZipPeekError=n,t.createZipPeekError=function(e){return new Error(n(e))},t.toZipPeekError=function(e){const r=e instanceof Error?e:new Error(String(e));return r.message.startsWith(t.ZIP_PEEK_ERROR_PREFIX)||(r.message=n(r.message)),r},t.errorMessage=function(e){return e instanceof Error?e.message:String(e)},t.ZIP_PEEK_ERROR_PREFIX="[zip-peek-error]"},314(e,t,n){t.persistAllowedZipUrlsConfig=a,t.ensureAllowedZipUrlsLoaded=async function(){if(s.allowedZipUrlsLoaded)return s.allowedZipUrlsLoaded;const e=(async()=>{try{const e=await caches.open(s.CONFIG_CACHE_NAME),t=await e.match(s.CONFIG_CACHE_KEY);if(!t)return;const n=await t.json();Array.isArray(n.allowedZipUrls)?(0,s.setAllowedZipUrls)(new Set(n.allowedZipUrls.filter(e=>"string"==typeof e).map(e=>(0,r.normalizeZipUrl)(e)))):(0,s.setAllowedZipUrls)(null)}catch(e){(0,i.warn)("failed to load runtime config",e)}})();return(0,s.setAllowedZipUrlsLoaded)(e),e},t.applyRuntimeConfig=async function(e){if(!e)return;let t={...s.runtimeConfig},n=!1;if("string"==typeof e.zipAssetCacheName&&e.zipAssetCacheName.trim()&&(t.zipAssetCacheName=e.zipAssetCacheName,n=!0),"number"==typeof e.assetCacheTtlMs&&Number.isFinite(e.assetCacheTtlMs)&&(t.assetCacheTtlMs=e.assetCacheTtlMs,n=!0),"string"==typeof e.logPrefix&&e.logPrefix.trim()&&(t.logPrefix=e.logPrefix,n=!0),"boolean"==typeof e.requireExactManifestPath&&(t.requireExactManifestPath=e.requireExactManifestPath,n=!0),n&&(0,s.setRuntimeConfig)(t),"allowedZipUrls"in e){const t=Array.isArray(e.allowedZipUrls)?e.allowedZipUrls.map(e=>(0,r.normalizeZipUrl)(e)):null;(0,s.setAllowedZipUrls)(t?new Set(t):null),(0,s.setAllowedZipUrlsLoaded)(Promise.resolve()),await a(t)}},t.isZipUrlAllowed=function(e){return null===s.allowedZipUrls||s.allowedZipUrls.has(e)};const r=n(343),s=n(262),i=n(266);async function a(e){try{const t=await caches.open(s.CONFIG_CACHE_NAME);await t.put(new Request(s.CONFIG_CACHE_KEY),new Response(JSON.stringify({allowedZipUrls:e}),{headers:{"Content-Type":"application/json"}}))}catch(e){(0,i.warn)("failed to persist runtime config",e)}}},800(e,t,n){t.canonicalAssetRequest=function(e,t){return new Request((0,s.canonicalZipAssetRequestUrl)(e,t),{method:"GET"})},t.clearAllZipAssets=async function(){const e=await caches.open(a.runtimeConfig.zipAssetCacheName),t=await e.keys();await Promise.all(t.map(t=>e.delete(t))),await caches.delete(a.CONFIG_CACHE_NAME),a.zipManifests.clear(),a.pendingManifestLoads.clear(),(0,a.setAllowedZipUrlsLoaded)(Promise.resolve())},t.clearZipAssetsExceptAllowed=async function(e){try{const t=new Set(e),n=await caches.open(a.runtimeConfig.zipAssetCacheName),r=await n.keys();for(const e of r){const r=e.url,i=(0,s.parseZipAssetRequest)(r);i&&!t.has(i.zipUrl)&&await n.delete(e)}for(const e of a.zipManifests.keys())t.has(e)||a.zipManifests.delete(e)}catch(e){throw(0,r.createZipPeekError)(`Failed to clear zip assets except allowed URLs: ${(0,r.errorMessage)(e)}`)}},t.putCachedFullAssetIfAbsent=async function(e,t){try{const n=await caches.open(a.runtimeConfig.zipAssetCacheName),r=await n.match(e);if(r&&!l(r))return void await(t.body?.cancel());const s=new Headers(t.headers);s.set(a.ASSET_CACHED_AT_HEADER,String(Date.now())),s.set("Access-Control-Allow-Origin","*"),await n.put(e,new Response(t.body,{status:t.status,statusText:t.statusText,headers:s}))}catch(e){t.body&&!t.body.locked&&await t.body.cancel(e),(0,o.warn)("asset cache put failed",e)}},t.readCachedZipAssetIfFresh=async function(e){let t=null,n="network";try{const r=await caches.open(a.runtimeConfig.zipAssetCacheName),s=await r.match(e);if(s)if(l(s))try{await r.delete(e)}catch(e){(0,o.warn)("asset cache delete expired failed",e)}else t=s,n="cache-api"}catch(e){(0,o.warn)("asset cache read failed",e)}return{response:t,assetSource:n}},t.renewZipUrl=async function(e,t){const n=(0,s.normalizeZipUrl)(e),o=(0,s.normalizeZipUrl)(t);if(n===o)return;if(a.allowedZipUrls){const e=new Set(a.allowedZipUrls);e.delete(n),e.add(o),(0,a.setAllowedZipUrls)(e),(0,a.setAllowedZipUrlsLoaded)(Promise.resolve()),await(0,i.persistAllowedZipUrlsConfig)(Array.from(e))}const l=a.zipManifests.get(n);l&&(a.zipManifests.set(o,l),a.zipManifests.delete(n));const c=a.pendingManifestLoads.get(n);c&&(a.pendingManifestLoads.set(o,c),a.pendingManifestLoads.delete(n));try{const e=await caches.open(a.runtimeConfig.zipAssetCacheName),t=await e.keys();for(const r of t){const t=r.url,i=(0,s.parseZipAssetRequest)(t);i&&(0,s.normalizeZipUrl)(i.zipUrl)===n&&await e.delete(r)}}catch(e){throw(0,r.createZipPeekError)(`Failed to clear cached assets for renewed ZIP URL: ${(0,r.errorMessage)(e)}`)}};const r=n(553),s=n(343),i=n(314),a=n(262),o=n(266);function l(e){const t=e.headers.get(a.ASSET_CACHED_AT_HEADER);if(!t)return!0;const n=parseInt(t,10);return!Number.isFinite(n)||Date.now()-n>a.runtimeConfig.assetCacheTtlMs}},982(e,t,n){t.installFetchHandler=function(){self.addEventListener("fetch",e=>{const t=e.request.method;if("GET"!==t&&"HEAD"!==t)return;if(!(0,s.parseZipAssetRequest)(e.request.url))return;const n=async function(e,t){const n="HEAD"===e.method,u=(0,s.parseZipAssetRequest)(e.url),h=(0,s.normalizeZipUrl)(u.zipUrl),g=u.internalPath,m=(0,s.normalizeZipEntryPath)(g);try{if(await(0,i.ensureAllowedZipUrlsLoaded)(),!(0,i.isZipUrlAllowed)(h))return(0,l.warn)("zip URL not allowed",{requestedZipUrl:h}),{response:(0,f.corsErrorResponse)(`ZIP URL not allowed (not in allowedZipUrls): ${h}`,403)};let s=o.zipManifests.get(h);if(s||(s=await(0,c.ensureManifestAvailable)(h,t)??void 0),!s){const e=Array.from(o.zipManifests.keys());return(0,l.warn)("manifest missing for zipUrl",{requestedZipUrl:h,knownZipUrls:e}),{response:(0,f.corsErrorResponse)(`ZIP manifest not loaded for ${h}. Ensure the ZIP is reachable and supports byte-range requests.`,404)}}const u=(0,c.resolveManifestEntry)(s,m,h,o.runtimeConfig.requireExactManifestPath);if(!u){const e=Array.from(s.keys()).slice(0,50);return(0,l.warn)("file not in manifest",{zipUrl:h,internalPathRaw:g,internalPathNormalized:m,requireExactManifestPath:o.runtimeConfig.requireExactManifestPath,manifestSize:s.size,sampleKeys:e}),{response:(0,f.corsErrorResponse)(`File "${g}" not found in ZIP manifest for ${h}`,404)}}const{key:w,info:E,matchKind:y}=u;if("zipBasenameFallback"===y&&((0,l.log)("resolved via zip-basename folder fallback",{requested:m,manifestKey:w}),(0,l.reportClientError)(new Error((0,r.formatZipPeekError)("Exact manifest path not found; resolved via zip-basename folder fallback")),`Exact manifest key "${m}" not found in ${h}; resolved using "${w}"`)),n)return{response:d(e,w,E)};const A=(0,a.canonicalAssetRequest)(h,w),U=await(0,a.readCachedZipAssetIfFresh)(A),S=(0,c.entryUncompressedSize)(E),C=(0,f.getMimeType)(w);if(U.response)return{response:p(U.response.body,C,S,U.assetSource,e.headers.get("range"))};const R=await(0,f.fetchUncompressedZipEntryFromNetwork)(h,w,E);if(!R.ok)return{response:R.response};const[_,Z]=R.stream.tee(),z={"Content-Type":R.contentType};null!==R.contentLength&&(z["Content-Length"]=String(R.contentLength));const v=(0,a.putCachedFullAssetIfAbsent)(A,new Response(Z,{status:200,headers:z}));return{response:p(_,R.contentType,R.contentLength,"network",e.headers.get("range")),background:v}}catch(e){return(0,l.error)("fetch handler failed",{zipUrl:h,internalPath:g,message:(0,r.errorMessage)(e)}),{response:(0,f.corsErrorResponse)(`Failed to serve "${g}" from ${h}: ${(0,r.errorMessage)(e)}`,500)}}}(e.request,e.clientId||void 0);e.respondWith(n.then(({response:e})=>e)),e.waitUntil(n.then(({background:e})=>e).catch(e=>{(0,l.warn)("background asset cache failed",(0,r.errorMessage)(e))}))})};const r=n(553),s=n(343),i=n(314),a=n(800),o=n(262),l=n(266),c=n(346),f=n(254);function u(e){return{"Access-Control-Allow-Origin":"*","Access-Control-Expose-Headers":o.ASSET_SOURCE_HEADER,[o.ASSET_SOURCE_HEADER]:e}}function p(e,t,n,r,s){if(s){if(null===n)return e?.cancel(),new Response(null,{status:416,headers:u(r)});const i=s.replace(/^bytes=/,"");if(i.includes(","))return e?.cancel(),new Response(null,{status:416,headers:{"Content-Range":`bytes */${n}`,...u(r)}});const[a,o]=i.split("-"),l=""!==a?parseInt(a,10):NaN,c=""!==o?parseInt(o,10):n-1;if(isNaN(l)||isNaN(c)||l<0||c<l||l>=n)return e?.cancel(),new Response(null,{status:416,headers:{"Content-Range":`bytes */${n}`,...u(r)}});const f=Math.min(c,n-1),p=f-l+1,d=null===e?null:function(e,t,n){let r=0;return e.pipeThrough(new TransformStream({transform(e,s){const i=r,a=r+e.byteLength-1;if(r+=e.byteLength,a<t)return;if(i>n)return void s.terminate();const o=Math.max(0,t-i),l=Math.min(e.byteLength,n-i+1);l>o&&s.enqueue(e.subarray(o,l)),a>=n&&s.terminate()}}))}(e,l,f);return new Response(d,{status:206,headers:{"Content-Type":t,"Content-Range":`bytes ${l}-${f}/${n}`,"Content-Length":p.toString(),"Accept-Ranges":"bytes",...u(r)}})}const i={"Content-Type":t,...u(r)};return null!==n&&(i["Content-Length"]=n.toString()),new Response(e,{status:200,headers:i})}function d(e,t,n){const r=(0,f.getMimeType)(t),s=(0,c.entryUncompressedSize)(n),i=e.headers.get("range");if(null!==s&&i)return p(null,r,s,"manifest",i);const a={"Content-Type":r,...u("manifest")};return null!==s&&(a["Content-Length"]=s.toString()),new Response(null,{status:200,headers:a})}},262(e,t){t.CONFIG_CACHE_KEY=t.allowedZipUrlsLoaded=t.allowedZipUrls=t.runtimeConfig=t.pendingManifestLoads=t.zipManifests=t.LOCAL_FILE_HEADER_SIG=t.MIME_TYPES=t.ASSET_UPSTREAM_STATUS_HEADER=t.ASSET_ERROR_HEADER=t.ASSET_SOURCE_HEADER=t.ASSET_CACHED_AT_HEADER=t.CONFIG_CACHE_NAME=t.kF=t.o2=void 0,t.setRuntimeConfig=function(e){t.runtimeConfig=e},t.setAllowedZipUrls=function(e){t.allowedZipUrls=e},t.setAllowedZipUrlsLoaded=function(e){t.allowedZipUrlsLoaded=e},t.o2="zip-cache-v1",t.kF=72e5,t.CONFIG_CACHE_NAME="zip-peek-config-v1",t.o2,t.CONFIG_CACHE_NAME,t.ASSET_CACHED_AT_HEADER="X-ZipSW-Cached-At",t.ASSET_SOURCE_HEADER="X-ZipSW-Asset-Source",t.ASSET_ERROR_HEADER="X-ZipSW-Error",t.ASSET_UPSTREAM_STATUS_HEADER="X-ZipSW-Upstream-Status",t.MIME_TYPES={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",json:"application/json",js:"application/javascript",css:"text/css; charset=utf-8",html:"text/html; charset=utf-8",txt:"text/plain; charset=utf-8",mp4:"video/mp4",webm:"video/webm",mp3:"audio/mpeg",wav:"audio/wav",oga:"audio/ogg",ogg:"audio/ogg",xml:"application/xml",wasm:"application/wasm"},t.LOCAL_FILE_HEADER_SIG=67324752,t.zipManifests=new Map,t.pendingManifestLoads=new Map,t.runtimeConfig={zipAssetCacheName:t.o2,assetCacheTtlMs:t.kF,logPrefix:"[zipSW]",requireExactManifestPath:!1},t.allowedZipUrls=null,t.allowedZipUrlsLoaded=null,t.CONFIG_CACHE_KEY=new URL("__zip_peek_runtime_config__",self.registration.scope).href},266(e,t,n){t.log=function(...e){console.log(s.runtimeConfig.logPrefix,...e)},t.warn=function(...e){console.warn(s.runtimeConfig.logPrefix,...e)},t.error=function(...e){console.error(s.runtimeConfig.logPrefix,r.ZIP_PEEK_ERROR_PREFIX,...e)},t.reportClientError=i,t.installClientErrorReporting=function(){self.addEventListener("error",e=>{i(e.error??e.message,"Service worker uncaught error")}),self.addEventListener("unhandledrejection",e=>{i(e.reason,"Service worker unhandled promise rejection")})};const r=n(553),s=n(262);function i(e,t){const n=(0,r.toZipPeekError)(e);self.clients.matchAll({type:"window",includeUncontrolled:!0}).then(e=>{const s={type:"ZIP_SW_ERROR",error:{message:n.message,stack:n.stack},info:t?(0,r.formatZipPeekError)(t):void 0};for(const t of e)t.postMessage(s)})}},346(e,t,n){t.manifestFilesToMap=a,t.sendManifestToClientId=l,t.ensureManifestAvailable=function(e,t){const n=s.zipManifests.get(e);if(n)return Promise.resolve(n);let c=s.pendingManifestLoads.get(e);return c||(c=(async()=>{const n=await async function(e,t){const n=await o(t);return n?function(e,t){return new Promise(n=>{const r=new MessageChannel,s=setTimeout(()=>{r.port1.close(),n(null)},500);r.port1.onmessage=e=>{clearTimeout(s),r.port1.close();const t=e.data;t?.ok&&Array.isArray(t.files)?n(a(t.files)):n(null)},r.port1.onmessageerror=()=>{clearTimeout(s),r.port1.close(),n(null)};try{e.postMessage({type:"ZIP_SW_MANIFEST_REQUEST",zipUrl:t},[r.port2])}catch(e){clearTimeout(s),r.port1.close(),(0,i.warn)("failed to request manifest from client",e),n(null)}})}(n,e):null}(e,t);if(n)return s.zipManifests.set(e,n),(0,i.log)("restored manifest from client memory",{zipUrl:e,entryCount:n.size}),n;const c=await async function(e){const t=await fetch(e,{headers:{Range:"bytes=-65536"}});if(206!==t.status)return(0,i.error)("range requests not supported for ZIP manifest",{zipUrl:e,status:t.status}),null;const n=await t.arrayBuffer(),s=new DataView(n);let a=-1;for(let e=n.byteLength-22;e>=0;e--)if(101010256===s.getUint32(e,!0)){a=e;break}if(-1===a)return(0,i.error)("EOCD not found in last 64KB of ZIP file",e),null;const o=s.getUint32(a+16,!0),l=s.getUint32(a+12,!0);let c=n,f=-1;const u=t.headers.get("Content-Range");let p=0;if(u){const e=u.match(/\/(\d+)$/);e&&(p=parseInt(e[1],10))}if(p<=0)return(0,i.error)("could not determine ZIP file size from Content-Range header",{zipUrl:e,contentRange:u}),null;const d=p-n.byteLength;if(o>=d)f=o-d;else{const t=await fetch(e,{headers:{Range:`bytes=${o}-${o+l-1}`}});if(206!==t.status)return(0,i.error)("failed to fetch ZIP central directory",{zipUrl:e,status:t.status,cdOffset:o,cdSize:l}),null;c=await t.arrayBuffer(),f=0}return function(e,t,n,s){const a=new DataView(e);let o=t;const l=[];for(;o+46<=e.byteLength&&33639248===a.getUint32(o,!0);){const t=a.getUint16(o+10,!0),n=a.getUint32(o+20,!0),s=a.getUint32(o+24,!0),i=a.getUint16(o+28,!0),c=a.getUint16(o+30,!0),f=a.getUint16(o+32,!0),u=a.getUint32(o+42,!0),p=new TextDecoder;if(o+46+i>e.byteLength)break;const d=new Uint8Array(e,o+46,i),h=p.decode(d),g=(0,r.normalizeZipEntryPath)(h);""!==g&&l.push({filename:g,offset:u,compressedSize:n,uncompressedSize:s,compression:t}),o+=46+i+c+f}if(0===l.length)return(0,i.error)("no files parsed from central directory",s),null;l.sort((e,t)=>e.offset-t.offset);const c=new Map;for(let e=0;e<l.length;e++){const t=l[e],s=(0,r.normalizeZipEntryPath)(t.filename);""!==s&&(c.has(s)&&(0,i.warn)("duplicate manifest key after normalize; overwriting",s),c.set(s,{filename:t.filename,offset:t.offset,compressedSize:t.compressedSize,uncompressedSize:t.uncompressedSize,compression:t.compression,nextOffset:e<l.length-1?l[e+1].offset:n}))}return c.size>0?c:null}(c,f,o,e)}(e);return c&&(s.zipManifests.set(e,c),await l(e,c,t),(0,i.log)("manifest fetched and stored in memory",{zipUrl:e,entryCount:c.size})),c})().finally(()=>{s.pendingManifestLoads.delete(e)}),s.pendingManifestLoads.set(e,c),c)},t.entryUncompressedSize=function(e){return void 0!==e.uncompressedSize?e.uncompressedSize:0===e.compression?e.compressedSize:null},t.resolveManifestEntry=function(e,t,n,s){if(e.has(t))return{key:t,info:e.get(t),matchKind:"exact"};if(s)return null;const i=(0,r.zipBasenameWithoutExtension)(n);if(!i)return null;const a=`${i}/${t}`;return e.has(a)?{key:a,info:e.get(a),matchKind:"zipBasenameFallback"}:null};const r=n(343),s=n(262),i=n(266);function a(e){const t=new Map;for(const n of e){const e=(0,r.normalizeZipEntryPath)(n.filename);""!==e&&(t.has(e)&&(0,i.warn)("duplicate manifest key after normalize; overwriting",e),t.set(e,n))}return t.size>0?t:null}async function o(e){if(!e)return null;const t=await self.clients.get(e);return"window"===t?.type?t:null}async function l(e,t,n){const r=await o(n);if(!r)return;const s=Array.from(t.values());try{r.postMessage({type:"ZIP_SW_MANIFEST_CREATED",zipUrl:e,files:s})}catch(e){(0,i.warn)("failed to send manifest to client",e)}}},993(e,t,n){t.installMessageHandler=function(){self.addEventListener("message",e=>{if(!e.data)return;const{type:t,zipUrl:n,files:p,config:d,allowedZipUrls:h,previousUrl:g,nextUrl:m}=e.data,w=function(e){if(!e||!("id"in e))return;const t=e.id;return"string"==typeof t?t:void 0}(e.source);if("ZIP_SW_CONFIG"===t){const t=(0,i.applyRuntimeConfig)(d).then(()=>u(e,{ok:!0})).catch(t=>u(e,f(t)));return void e.waitUntil(t)}if("ZIP_MANIFEST"===t){if(n&&p){const t=(0,s.normalizeZipUrl)(n),r=(0,c.manifestFilesToMap)(p),i=o.zipManifests.get(t);if(!r)return void(0,l.warn)("rejecting empty manifest; keeping existing",{zipUrl:t,existingSize:i?i.size:0});if(i&&i.size>r.size)return void(0,l.warn)("rejecting smaller manifest; keeping existing",{zipUrl:t,incomingSize:r.size,existingSize:i.size});o.zipManifests.set(t,r),e.waitUntil((0,c.sendManifestToClientId)(t,r,w));const a=Array.from(r.keys()).slice(0,40);(0,l.log)("ZIP_MANIFEST loaded",{zipUrl:t,entryCount:r.size,sampleKeys:a,replacedExistingSize:i?i.size:0})}}else if("CLEAR_ZIP_ASSETS_EXCEPT_ALLOWED"===t&&h){const t=(0,a.clearZipAssetsExceptAllowed)(h).then(()=>u(e,{ok:!0})).catch(t=>u(e,f(t)));e.waitUntil(t)}else if("CLEAR_ALL_ZIP_ASSETS"===t){const t=(0,a.clearAllZipAssets)().then(()=>u(e,{ok:!0})).catch(t=>u(e,f(t)));e.waitUntil(t)}else if("PRELOAD_ZIP_MANIFESTS"===t&&h){const t=async function(e,t){const n=await Promise.all(e.map(async e=>({zipUrl:e,manifest:await(0,c.ensureManifestAvailable)(e,t)}))),s=n.filter(e=>!e.manifest).map(e=>e.zipUrl);if(s.length>0)throw(0,r.createZipPeekError)(`Failed to preload ZIP manifest(s): ${s.join(", ")}`)}(h,w).then(()=>u(e,{ok:!0})).catch(t=>u(e,f(t)));e.waitUntil(t)}else if("RENEW_ZIP_URL"===t&&g&&m){const t=(0,a.renewZipUrl)(g,m).then(()=>u(e,{ok:!0})).catch(t=>u(e,f(t)));e.waitUntil(t)}})};const r=n(553),s=n(343),i=n(314),a=n(800),o=n(262),l=n(266),c=n(346);function f(e){const t=(0,r.toZipPeekError)(e);return{ok:!1,error:t.message,errorStack:t.stack}}function u(e,t){e.ports[0]?.postMessage(t)}},254(e,t,n){t.corsErrorResponse=c,t.getMimeType=f,t.fetchUncompressedZipEntryFromNetwork=async function(e,t,n){const s=n.offset,o=n.nextOffset-1;(0,a.log)("fetching zip chunk from",{zipUrl:e,rangeStart:s,rangeEnd:o});const l=await fetch(e,{headers:{Range:`bytes=${s}-${o}`}});if(206!==l.status){const n=l.status>=400?l.status:502;return{ok:!1,response:c(`ZIP entry fetch for "${t}" expected HTTP 206 Partial Content from ${e}, got ${l.status}`,n,{upstreamStatus:l.status})}}if(!l.body)return{ok:!1,response:c(`ZIP entry fetch for "${t}" in ${e} returned no response body`,502)};const p=l.body.getReader();let d,h;try{({headerAndPayload:d,dataStart:h}=await async function(e){let t=new Uint8Array(0);for(;t.byteLength<30;){const{done:n,value:r}=await e.read();if(n)throw new Error("ZIP entry ended before its local file header was complete");t=u(t,r)}const n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0,!0)!==i.LOCAL_FILE_HEADER_SIG)throw new Error("Invalid local file header (expected ZIP signature 0x04034b50)");const r=30+n.getUint16(26,!0)+n.getUint16(28,!0);for(;t.byteLength<r;){const{done:n,value:r}=await e.read();if(n)throw new Error("ZIP entry ended before its local file header fields were complete");t=u(t,r)}return{headerAndPayload:t,dataStart:r}}(p))}catch(n){return await p.cancel(n),{ok:!1,response:c(`Invalid local file header for "${t}" in ${e}: ${n instanceof Error?n.message:String(n)}`,500)}}const g=function(e,t,n){let r=t,s=0;return new ReadableStream({async pull(t){if(s>=n)return await e.cancel(),void t.close();let i;if(r.byteLength>0)i=r,r=new Uint8Array(0);else{const{done:r,value:a}=await e.read();if(r)return void t.error(new Error(`ZIP entry ended after ${s} of ${n} compressed bytes`));i=a}const a=n-s,o=i.byteLength>a?i.subarray(0,a):i;s+=o.byteLength,t.enqueue(o),s>=n&&(await e.cancel(),t.close())},cancel:t=>e.cancel(t)})}(p,d.subarray(h),n.compressedSize),m=n.uncompressedSize??(0===n.compression?n.compressedSize:null);let w;if(8===n.compression)w=function(e,t){let n,s=0;const i=new TransformStream({start(e){n=new r.Inflate(t=>{s+=t.byteLength,e.enqueue(t)})},transform(e){n.push(e)},flush(){if(n.push(new Uint8Array(0),!0),null!==t&&s!==t)throw new Error(`Inflated ZIP entry size mismatch: expected ${t}, received ${s}`)}});return e.pipeThrough(i)}(g,m);else{if(0!==n.compression)return await p.cancel(),{ok:!1,response:c(`Unsupported compression method ${n.compression} for "${t}" in ${e} (only stored/0 and DEFLATE/8 are supported)`,500)};w=g}return{ok:!0,stream:w,contentLength:m,contentType:f(t)}};const r=n(612),s=n(553),i=n(262),a=n(266);function o(e){return e.replace(/[\r\n]+/g," ").trim()}function l(e,t){const n=[i.ASSET_ERROR_HEADER],r={"Access-Control-Allow-Origin":"*",[i.ASSET_ERROR_HEADER]:o(e)},s=t?.upstreamStatus;return void 0!==s&&(r[i.ASSET_UPSTREAM_STATUS_HEADER]=String(s),n.push(i.ASSET_UPSTREAM_STATUS_HEADER)),r["Access-Control-Expose-Headers"]=n.join(", "),r}function c(e,t,n){const r=(0,s.formatZipPeekError)(e);return new Response(r,{status:t,headers:l(r,n)})}function f(e){const t=e.split(".").pop()?.toLowerCase();return t?i.MIME_TYPES[t]??"application/octet-stream":"application/octet-stream"}function u(e,t){const n=new Uint8Array(e.byteLength+t.byteLength);return n.set(e),n.set(t,e.byteLength),n}},343(e,t){function n(e){try{return decodeURIComponent(e)}catch{return e}}t.normalizeZipUrl=function(e,t={}){const{stripCacheBuster:n=!0,stripHash:r=!0}=t,s=e=>r?e.split("#")[0]:e;if(!n)return s(e);const i=e.indexOf("?");if(-1===i)return s(e);const a=e.indexOf("#",i),o=e.substring(0,i),l=-1===a?e.substring(i+1):e.substring(i+1,a),c=r||-1===a?"":e.substring(a),f=l.split("&").filter(e=>{const t=e.indexOf("=");return"t"!==(-1===t?e:e.substring(0,t))});return 0===f.length?o+c:o+"?"+f.join("&")+c},t.zipBasenameWithoutExtension=function(e){try{const t=new URL(e,"http://local").pathname.split("/").pop()??"";return t.endsWith(".zip")?t.slice(0,-4):t}catch{const t=e.split("?")[0].split("#")[0].split("/").pop()??"";return t.endsWith(".zip")?t.slice(0,-4):t}},t.normalizeZipEntryPath=function(e){let t=e.replace(/\\/g,"/");for(;t.startsWith("/");)t=t.slice(1);return t},t.parseZipAssetRequest=function(e){const t=/\.zip([/?])/.exec(e);if(!t)return null;const r=t.index+4,s=t[1],i=e.substring(0,r);if("/"===s){const t=e.substring(r+1),s=t.indexOf("?"),a=-1===s?t:t.substring(0,s);return""===a?null:{zipUrl:i,internalPath:n(a)}}const a=e.substring(r),o=a.indexOf("/");if(-1===o)return null;const l=a.substring(0,o),c=a.substring(o+1),f=c.indexOf("?"),u=-1===f?c:c.substring(0,f);return""===u?null:{zipUrl:i+l,internalPath:n(u)}},t.canonicalZipAssetRequestUrl=function(e,t){return e+"/"+encodeURIComponent(t)}},612(e,t){var n=Uint8Array,r=Uint16Array,s=Int32Array,i=new n([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),a=new n([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),o=new n([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),l=function(e,t){for(var n=new r(31),i=0;i<31;++i)n[i]=t+=1<<e[i-1];var a=new s(n[30]);for(i=1;i<30;++i)for(var o=n[i];o<n[i+1];++o)a[o]=o-n[i]<<5|i;return{b:n,r:a}},c=l(i,2),f=c.b,u=c.r;f[28]=258,u[258]=28;for(var p=l(a,0),d=p.b,h=(p.r,new r(32768)),g=0;g<32768;++g){var m=(43690&g)>>1|(21845&g)<<1;m=(61680&(m=(52428&m)>>2|(13107&m)<<2))>>4|(3855&m)<<4,h[g]=((65280&m)>>8|(255&m)<<8)>>1}var w=function(e,t,n){for(var s=e.length,i=0,a=new r(t);i<s;++i)e[i]&&++a[e[i]-1];var o,l=new r(t);for(i=1;i<t;++i)l[i]=l[i-1]+a[i-1]<<1;if(n){o=new r(1<<t);var c=15-t;for(i=0;i<s;++i)if(e[i])for(var f=i<<4|e[i],u=t-e[i],p=l[e[i]-1]++<<u,d=p|(1<<u)-1;p<=d;++p)o[h[p]>>c]=f}else for(o=new r(s),i=0;i<s;++i)e[i]&&(o[i]=h[l[e[i]-1]++]>>15-e[i]);return o},E=new n(288);for(g=0;g<144;++g)E[g]=8;for(g=144;g<256;++g)E[g]=9;for(g=256;g<280;++g)E[g]=7;for(g=280;g<288;++g)E[g]=8;var y=new n(32);for(g=0;g<32;++g)y[g]=5;var A=w(E,9,1),U=w(y,5,1),S=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},C=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},R=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},_=function(e){return(e+7)/8|0},Z=function(e,t,r){return(null==t||t<0)&&(t=0),(null==r||r>e.length)&&(r=e.length),new n(e.subarray(t,r))},z=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],v=function(e,t,n){var r=new Error(t||z[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,v),!n)throw r;return r},b=function(e,t,r,s){var l=e.length,c=s?s.length:0;if(!l||t.f&&!t.l)return r||new n(0);var u=!r,p=u||2!=t.i,h=t.i;u&&(r=new n(3*l));var g=function(e){var t=r.length;if(e>t){var s=new n(Math.max(2*t,e));s.set(r),r=s}},m=t.f||0,E=t.p||0,y=t.b||0,z=t.l,b=t.d,P=t.m,M=t.n,T=8*l;do{if(!z){m=C(e,E,1);var I=C(e,E+1,3);if(E+=3,!I){var k=e[(j=_(E)+4)-4]|e[j-3]<<8,L=j+k;if(L>l){h&&v(0);break}p&&g(y+k),r.set(e.subarray(j,L),y),t.b=y+=k,t.p=E=8*L,t.f=m;continue}if(1==I)z=A,b=U,P=9,M=5;else if(2==I){var x=C(e,E,31)+257,F=C(e,E+10,15)+4,O=x+C(e,E+5,31)+1;E+=14;for(var N=new n(O),H=new n(19),$=0;$<F;++$)H[o[$]]=C(e,E+3*$,7);E+=3*F;var D=S(H),q=(1<<D)-1,W=w(H,D,1);for($=0;$<O;){var j,K=W[C(e,E,q)];if(E+=15&K,(j=K>>4)<16)N[$++]=j;else{var G=0,X=0;for(16==j?(X=3+C(e,E,3),E+=2,G=N[$-1]):17==j?(X=3+C(e,E,7),E+=3):18==j&&(X=11+C(e,E,127),E+=7);X--;)N[$++]=G}}var B=N.subarray(0,x),Y=N.subarray(x);P=S(B),M=S(Y),z=w(B,P,1),b=w(Y,M,1)}else v(1);if(E>T){h&&v(0);break}}p&&g(y+131072);for(var V=(1<<P)-1,J=(1<<M)-1,Q=E;;Q=E){var ee=(G=z[R(e,E)&V])>>4;if((E+=15&G)>T){h&&v(0);break}if(G||v(2),ee<256)r[y++]=ee;else{if(256==ee){Q=E,z=null;break}var te=ee-254;if(ee>264){var ne=i[$=ee-257];te=C(e,E,(1<<ne)-1)+f[$],E+=ne}var re=b[R(e,E)&J],se=re>>4;if(re||v(3),E+=15&re,Y=d[se],se>3&&(ne=a[se],Y+=R(e,E)&(1<<ne)-1,E+=ne),E>T){h&&v(0);break}p&&g(y+131072);var ie=y+te;if(y<Y){var ae=c-Y,oe=Math.min(Y,ie);for(ae+y<0&&v(3);y<oe;++y)r[y]=s[ae+y]}for(;y<ie;++y)r[y]=r[y-Y]}}t.l=z,t.p=Q,t.b=y,t.f=m,z&&(m=1,t.m=P,t.d=b,t.n=M)}while(!m);return y!=r.length&&u?Z(r,0,y):r.subarray(0,y)},P=new n(0);var M=function(){function e(e,t){"function"==typeof e&&(t=e,e={}),this.ondata=t;var r=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:r?r.length:0},this.o=new n(32768),this.p=new n(0),r&&this.o.set(r)}return e.prototype.e=function(e){if(this.ondata||v(5),this.d&&v(4),this.p.length){if(e.length){var t=new n(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}}else this.p=e},e.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,n=b(this.p,this.s,this.o);this.ondata(Z(n,t,this.s.b),this.d),this.o=Z(n,this.s.b-32768),this.s.b=this.o.length,this.p=Z(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}();t.Inflate=M;var T="undefined"!=typeof TextDecoder&&new TextDecoder;try{T.decode(P,{stream:!0})}catch(e){}"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout}};const t={};function n(r){const s=t[r];if(void 0!==s)return s.exports;const i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}(()=>{const e=n(266),t=n(982),r=n(993);self.addEventListener("install",()=>{self.skipWaiting()}),self.addEventListener("activate",e=>{e.waitUntil(self.clients.claim())}),(0,e.installClientErrorReporting)(),(0,r.installMessageHandler)(),(0,t.installFetchHandler)()})()})();
1
+ (()=>{"use strict";var e={553(e,t){function n(e){const n=e.trim();return n.startsWith(t.ZIP_PEEK_ERROR_PREFIX)?n:`${t.ZIP_PEEK_ERROR_PREFIX} ${n}`}t.ZIP_PEEK_ERROR_PREFIX=void 0,t.formatZipPeekError=n,t.createZipPeekError=function(e){return new Error(n(e))},t.toZipPeekError=function(e){const r=e instanceof Error?e:new Error(String(e));return r.message.startsWith(t.ZIP_PEEK_ERROR_PREFIX)||(r.message=n(r.message)),r},t.errorMessage=function(e){return e instanceof Error?e.message:String(e)},t.ZIP_PEEK_ERROR_PREFIX="[zip-peek-error]"},314(e,t,n){t.persistAllowedZipUrlsConfig=a,t.ensureAllowedZipUrlsLoaded=async function(){if(s.allowedZipUrlsLoaded)return s.allowedZipUrlsLoaded;const e=(async()=>{try{const e=await caches.open(s.CONFIG_CACHE_NAME),t=await e.match(s.CONFIG_CACHE_KEY);if(!t)return;const n=await t.json();Array.isArray(n.allowedZipUrls)?(0,s.setAllowedZipUrls)(new Set(n.allowedZipUrls.filter(e=>"string"==typeof e).map(e=>(0,r.normalizeZipUrl)(e)))):(0,s.setAllowedZipUrls)(null)}catch(e){(0,i.warn)("failed to load runtime config",e)}})();return(0,s.setAllowedZipUrlsLoaded)(e),e},t.applyRuntimeConfig=async function(e){if(!e)return;let t=Object.assign({},s.runtimeConfig),n=!1;if("string"==typeof e.zipAssetCacheName&&e.zipAssetCacheName.trim()&&(t.zipAssetCacheName=e.zipAssetCacheName,n=!0),"number"==typeof e.assetCacheTtlMs&&Number.isFinite(e.assetCacheTtlMs)&&(t.assetCacheTtlMs=e.assetCacheTtlMs,n=!0),"string"==typeof e.logPrefix&&e.logPrefix.trim()&&(t.logPrefix=e.logPrefix,n=!0),"boolean"==typeof e.requireExactManifestPath&&(t.requireExactManifestPath=e.requireExactManifestPath,n=!0),n&&(0,s.setRuntimeConfig)(t),"allowedZipUrls"in e){const t=Array.isArray(e.allowedZipUrls)?e.allowedZipUrls.map(e=>(0,r.normalizeZipUrl)(e)):null;(0,s.setAllowedZipUrls)(t?new Set(t):null),(0,s.setAllowedZipUrlsLoaded)(Promise.resolve()),await a(t)}},t.isZipUrlAllowed=function(e){return null===s.allowedZipUrls||s.allowedZipUrls.has(e)};const r=n(343),s=n(262),i=n(266);async function a(e){try{const t=await caches.open(s.CONFIG_CACHE_NAME);await t.put(new Request(s.CONFIG_CACHE_KEY),new Response(JSON.stringify({allowedZipUrls:e}),{headers:{"Content-Type":"application/json"}}))}catch(e){(0,i.warn)("failed to persist runtime config",e)}}},800(e,t,n){t.canonicalAssetRequest=function(e,t){return new Request((0,s.canonicalZipAssetRequestUrl)(e,t),{method:"GET"})},t.clearAllZipAssets=async function(){const e=await caches.open(o.runtimeConfig.zipAssetCacheName),t=await e.keys();await Promise.all(t.map(t=>e.delete(t))),await caches.delete(o.CONFIG_CACHE_NAME),o.zipManifests.clear(),o.pendingManifestLoads.clear(),o.inFlightZipAssets.clear(),(0,o.setAllowedZipUrlsLoaded)(Promise.resolve())},t.clearZipAssetsExceptAllowed=async function(e){try{const t=new Set(e),n=await caches.open(o.runtimeConfig.zipAssetCacheName),r=await n.keys();for(const e of r){const r=e.url,i=(0,s.parseZipAssetRequest)(r);i&&!t.has(i.zipUrl)&&await n.delete(e)}for(const e of o.zipManifests.keys())t.has(e)||o.zipManifests.delete(e)}catch(e){throw(0,r.createZipPeekError)(`Failed to clear zip assets except allowed URLs: ${(0,r.errorMessage)(e)}`)}},t.putCachedFullAssetIfAbsent=async function(e,t){var n;try{const r=await caches.open(o.runtimeConfig.zipAssetCacheName),s=await r.match(e);if(s&&!c(s))return void await(null===(n=t.body)||void 0===n?void 0:n.cancel());const i=new Headers(t.headers);i.set(o.ASSET_CACHED_AT_HEADER,String(Date.now())),i.set("Access-Control-Allow-Origin","*"),await r.put(e,new Response(t.body,{status:t.status,statusText:t.statusText,headers:i}))}catch(e){t.body&&!t.body.locked&&await t.body.cancel(e),(0,l.warn)("asset cache put failed",e)}},t.readCachedZipAssetIfFresh=async function(e){let t=null,n="network";try{const r=await caches.open(o.runtimeConfig.zipAssetCacheName),s=await r.match(e);if(s)if(c(s))try{await r.delete(e)}catch(e){(0,l.warn)("asset cache delete expired failed",e)}else t=s,n="cache-api"}catch(e){(0,l.warn)("asset cache read failed",e)}return{response:t,assetSource:n}},t.renewZipUrl=async function(e,t){const n=(0,s.normalizeZipUrl)(e),l=(0,s.normalizeZipUrl)(t);if(n===l)return;if(o.allowedZipUrls){const e=new Set(o.allowedZipUrls);e.delete(n),e.add(l),(0,o.setAllowedZipUrls)(e),(0,o.setAllowedZipUrlsLoaded)(Promise.resolve()),await(0,i.persistAllowedZipUrlsConfig)(Array.from(e))}const c=o.zipManifests.get(n);c&&(o.zipManifests.set(l,c),o.zipManifests.delete(n));const f=o.pendingManifestLoads.get(n);f&&(o.pendingManifestLoads.set(l,f),o.pendingManifestLoads.delete(n)),(0,a.remapInFlightZipAssetsForRenewal)(n,l);try{const e=await caches.open(o.runtimeConfig.zipAssetCacheName),t=await e.keys();for(const r of t){const t=r.url,i=(0,s.parseZipAssetRequest)(t);i&&(0,s.normalizeZipUrl)(i.zipUrl)===n&&await e.delete(r)}}catch(e){throw(0,r.createZipPeekError)(`Failed to clear cached assets for renewed ZIP URL: ${(0,r.errorMessage)(e)}`)}};const r=n(553),s=n(343),i=n(314),a=n(30),o=n(262),l=n(266);function c(e){const t=e.headers.get(o.ASSET_CACHED_AT_HEADER);if(!t)return!0;const n=parseInt(t,10);return!Number.isFinite(n)||Date.now()-n>o.runtimeConfig.assetCacheTtlMs}},30(e,t,n){t.getOrStartInFlightAsset=function(e,t){const n=e.url,r=s.inFlightZipAssets.get(n);if(r)return r;let i,a;const o=new Promise((e,t)=>{i=e,a=t}),l={resultPromise:t(),cacheFillPromise:o,leaderClaimed:!1,resolveCacheFill:i,rejectCacheFill:a};return o.finally(()=>{s.inFlightZipAssets.delete(n)}),s.inFlightZipAssets.set(n,l),l},t.completeInFlightAssetLoad=function(e,t){const n=s.inFlightZipAssets.get(e);n&&(void 0!==t?n.rejectCacheFill(t):n.resolveCacheFill())},t.remapInFlightZipAssetsForRenewal=function(e,t){const n=(0,r.normalizeZipUrl)(e),i=(0,r.normalizeZipUrl)(t);for(const[e,t]of[...s.inFlightZipAssets]){const a=(0,r.parseZipAssetRequest)(e);if(a&&(0,r.normalizeZipUrl)(a.zipUrl)===n){const n=(0,r.canonicalZipAssetRequestUrl)(i,a.internalPath);s.inFlightZipAssets.delete(e),s.inFlightZipAssets.set(n,t)}}};const r=n(343),s=n(262)},982(e,t,n){t.installFetchHandler=function(){self.addEventListener("fetch",e=>{const t=e.request.method;if("GET"!==t&&"HEAD"!==t)return;if(!(0,s.parseZipAssetRequest)(e.request.url))return;const n=async function(e,t){var n;const p="HEAD"===e.method,g=(0,s.parseZipAssetRequest)(e.url),m=(0,s.normalizeZipUrl)(g.zipUrl),w=g.internalPath,E=(0,s.normalizeZipEntryPath)(w);try{if(await(0,i.ensureAllowedZipUrlsLoaded)(),!(0,i.isZipUrlAllowed)(m))return(0,c.warn)("zip URL not allowed",{requestedZipUrl:m}),{response:(0,u.corsErrorResponse)(`ZIP URL not allowed (not in allowedZipUrls): ${m}`,403)};let s=l.zipManifests.get(m);if(s||(s=null!==(n=await(0,f.ensureManifestAvailable)(m,t))&&void 0!==n?n:void 0),!s){const e=Array.from(l.zipManifests.keys());return(0,c.warn)("manifest missing for zipUrl",{requestedZipUrl:m,knownZipUrls:e}),{response:(0,u.corsErrorResponse)(`ZIP manifest not loaded for ${m}. Ensure the ZIP is reachable and supports byte-range requests.`,404)}}const g=(0,f.resolveManifestEntry)(s,E,m,l.runtimeConfig.requireExactManifestPath);if(!g){const e=Array.from(s.keys()).slice(0,50);return(0,c.warn)("file not in manifest",{zipUrl:m,internalPathRaw:w,internalPathNormalized:E,requireExactManifestPath:l.runtimeConfig.requireExactManifestPath,manifestSize:s.size,sampleKeys:e}),{response:(0,u.corsErrorResponse)(`File "${w}" not found in ZIP manifest for ${m}`,404)}}const{key:A,info:y,matchKind:U}=g;if("zipBasenameFallback"===U&&((0,c.log)("resolved via zip-basename folder fallback",{requested:E,manifestKey:A}),(0,c.reportClientError)(new Error((0,r.formatZipPeekError)("Exact manifest path not found; resolved via zip-basename folder fallback")),`Exact manifest key "${E}" not found in ${m}; resolved using "${A}"`)),p)return{response:h(e,A,y)};const v=(0,a.canonicalAssetRequest)(m,A),R=await(0,a.readCachedZipAssetIfFresh)(v),C=(0,f.entryUncompressedSize)(y),Z=(0,u.getMimeType)(A);if(R.response)return{response:d(R.response.body,Z,C,R.assetSource,e.headers.get("range"))};const S=(0,o.getOrStartInFlightAsset)(v,()=>(0,u.fetchUncompressedZipEntryFromNetwork)(m,A,y)),z=await S.resultPromise;if(!z.ok)return(0,o.completeInFlightAssetLoad)(v.url),{response:z.response};const _=!S.leaderClaimed&&(S.leaderClaimed=!0),b=8===y.compression?null:e.headers.get("range");if(!_){await S.cacheFillPromise;const t=await(0,a.readCachedZipAssetIfFresh)(v);return t.response?{response:d(t.response.body,Z,C,t.assetSource,e.headers.get("range"))}:{response:(0,u.corsErrorResponse)(`Failed to serve "${A}" from ${m}: asset cache was not ready after in-flight load`,500)}}const[P,M]=z.stream.tee(),I={"Content-Type":z.contentType};null!==z.contentLength&&(I["Content-Length"]=String(z.contentLength));const T=v.url,L=(0,a.putCachedFullAssetIfAbsent)(v,new Response(M,{status:200,headers:I})).then(()=>{(0,o.completeInFlightAssetLoad)(T)}).catch(e=>{throw(0,o.completeInFlightAssetLoad)(T,e),e});return{response:d(P,z.contentType,z.contentLength,"network",b),background:L}}catch(e){return(0,c.error)("fetch handler failed",{zipUrl:m,internalPath:w,message:(0,r.errorMessage)(e)}),{response:(0,u.corsErrorResponse)(`Failed to serve "${w}" from ${m}: ${(0,r.errorMessage)(e)}`,500)}}}(e.request,e.clientId||void 0);e.respondWith(n.then(({response:e})=>e)),e.waitUntil(n.then(({background:e})=>e).catch(e=>{(0,c.warn)("background asset cache failed",(0,r.errorMessage)(e))}))})};const r=n(553),s=n(343),i=n(314),a=n(800),o=n(30),l=n(262),c=n(266),f=n(346),u=n(254);function p(e){return{"Access-Control-Allow-Origin":"*","Access-Control-Expose-Headers":l.ASSET_SOURCE_HEADER,[l.ASSET_SOURCE_HEADER]:e}}function d(e,t,n,r,s){if(s){if(null===n)return null==e||e.cancel(),new Response(null,{status:416,headers:p(r)});const i=s.replace(/^bytes=/,"");if(i.includes(","))return null==e||e.cancel(),new Response(null,{status:416,headers:Object.assign({"Content-Range":`bytes */${n}`},p(r))});const[a,o]=i.split("-"),l=""!==a?parseInt(a,10):NaN,c=""!==o?parseInt(o,10):n-1;if(isNaN(l)||isNaN(c)||l<0||c<l||l>=n)return null==e||e.cancel(),new Response(null,{status:416,headers:Object.assign({"Content-Range":`bytes */${n}`},p(r))});const f=Math.min(c,n-1),u=f-l+1,d=null===e?null:function(e,t,n){const r=e.getReader();let s=0,i=!1;return new ReadableStream({async pull(e){for(;!i;){const{done:a,value:o}=await r.read();if(a)return i=!0,void e.close();const l=o,c=s,f=s+l.byteLength-1;if(s+=l.byteLength,f<t)continue;if(c>n)return i=!0,void e.close();const u=Math.max(0,t-c),p=Math.min(l.byteLength,n-c+1);if(p>u&&e.enqueue(l.subarray(u,p)),f>=n)return i=!0,void e.close()}},cancel:e=>r.cancel(e)})}(e,l,f);return new Response(d,{status:206,headers:Object.assign({"Content-Type":t,"Content-Range":`bytes ${l}-${f}/${n}`,"Content-Length":u.toString(),"Accept-Ranges":"bytes"},p(r))})}const i=Object.assign({"Content-Type":t},p(r));return null!==n&&(i["Content-Length"]=n.toString(),i["Accept-Ranges"]="bytes"),new Response(e,{status:200,headers:i})}function h(e,t,n){const r=(0,u.getMimeType)(t),s=(0,f.entryUncompressedSize)(n),i=e.headers.get("range");if(null!==s&&i)return d(null,r,s,"manifest",i);const a=Object.assign({"Content-Type":r},p("manifest"));return null!==s&&(a["Content-Length"]=s.toString(),a["Accept-Ranges"]="bytes"),new Response(null,{status:200,headers:a})}},262(e,t){t.CONFIG_CACHE_KEY=t.allowedZipUrlsLoaded=t.allowedZipUrls=t.runtimeConfig=t.inFlightZipAssets=t.pendingManifestLoads=t.zipManifests=t.LOCAL_FILE_HEADER_SIG=t.MIME_TYPES=t.ASSET_UPSTREAM_STATUS_HEADER=t.ASSET_ERROR_HEADER=t.ASSET_SOURCE_HEADER=t.ASSET_CACHED_AT_HEADER=t.CONFIG_CACHE_NAME=t.kF=t.o2=void 0,t.setRuntimeConfig=function(e){t.runtimeConfig=e},t.setAllowedZipUrls=function(e){t.allowedZipUrls=e},t.setAllowedZipUrlsLoaded=function(e){t.allowedZipUrlsLoaded=e},t.o2="zip-cache-v1",t.kF=72e5,t.CONFIG_CACHE_NAME="zip-peek-config-v1",t.o2,t.CONFIG_CACHE_NAME,t.ASSET_CACHED_AT_HEADER="X-ZipSW-Cached-At",t.ASSET_SOURCE_HEADER="X-ZipSW-Asset-Source",t.ASSET_ERROR_HEADER="X-ZipSW-Error",t.ASSET_UPSTREAM_STATUS_HEADER="X-ZipSW-Upstream-Status",t.MIME_TYPES={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",json:"application/json",js:"application/javascript",css:"text/css; charset=utf-8",html:"text/html; charset=utf-8",txt:"text/plain; charset=utf-8",mp4:"video/mp4",webm:"video/webm",mp3:"audio/mpeg",wav:"audio/wav",oga:"audio/ogg",ogg:"audio/ogg",xml:"application/xml",wasm:"application/wasm"},t.LOCAL_FILE_HEADER_SIG=67324752,t.zipManifests=new Map,t.pendingManifestLoads=new Map,t.inFlightZipAssets=new Map,t.runtimeConfig={zipAssetCacheName:t.o2,assetCacheTtlMs:t.kF,logPrefix:"[zipSW]",requireExactManifestPath:!1},t.allowedZipUrls=null,t.allowedZipUrlsLoaded=null,t.CONFIG_CACHE_KEY=new URL("__zip_peek_runtime_config__",self.registration.scope).href},266(e,t,n){t.log=function(...e){console.log(s.runtimeConfig.logPrefix,...e)},t.warn=function(...e){console.warn(s.runtimeConfig.logPrefix,...e)},t.error=function(...e){console.error(s.runtimeConfig.logPrefix,r.ZIP_PEEK_ERROR_PREFIX,...e)},t.reportClientError=i,t.installClientErrorReporting=function(){self.addEventListener("error",e=>{var t;i(null!==(t=e.error)&&void 0!==t?t:e.message,"Service worker uncaught error")}),self.addEventListener("unhandledrejection",e=>{i(e.reason,"Service worker unhandled promise rejection")})};const r=n(553),s=n(262);function i(e,t){const n=(0,r.toZipPeekError)(e);self.clients.matchAll({type:"window",includeUncontrolled:!0}).then(e=>{const s={type:"ZIP_SW_ERROR",error:{message:n.message,stack:n.stack},info:t?(0,r.formatZipPeekError)(t):void 0};for(const t of e)t.postMessage(s)})}},346(e,t,n){t.manifestFilesToMap=a,t.sendManifestToClientId=l,t.ensureManifestAvailable=function(e,t){const n=s.zipManifests.get(e);if(n)return Promise.resolve(n);let c=s.pendingManifestLoads.get(e);return c||(c=(async()=>{const n=await async function(e,t){const n=await o(t);return n?function(e,t){return new Promise(n=>{const r=new MessageChannel,s=setTimeout(()=>{r.port1.close(),n(null)},500);r.port1.onmessage=e=>{clearTimeout(s),r.port1.close();const t=e.data;(null==t?void 0:t.ok)&&Array.isArray(t.files)?n(a(t.files)):n(null)},r.port1.onmessageerror=()=>{clearTimeout(s),r.port1.close(),n(null)};try{e.postMessage({type:"ZIP_SW_MANIFEST_REQUEST",zipUrl:t},[r.port2])}catch(e){clearTimeout(s),r.port1.close(),(0,i.warn)("failed to request manifest from client",e),n(null)}})}(n,e):null}(e,t);if(n)return s.zipManifests.set(e,n),(0,i.log)("restored manifest from client memory",{zipUrl:e,entryCount:n.size}),n;const c=await async function(e){const t=await fetch(e,{headers:{Range:"bytes=-65536"}});if(206!==t.status)return(0,i.error)("range requests not supported for ZIP manifest",{zipUrl:e,status:t.status}),null;const n=await t.arrayBuffer(),s=new DataView(n);let a=-1;for(let e=n.byteLength-22;e>=0;e--)if(101010256===s.getUint32(e,!0)){a=e;break}if(-1===a)return(0,i.error)("EOCD not found in last 64KB of ZIP file",e),null;const o=s.getUint32(a+16,!0),l=s.getUint32(a+12,!0);let c=n,f=-1;const u=t.headers.get("Content-Range");let p=0;if(u){const e=u.match(/\/(\d+)$/);e&&(p=parseInt(e[1],10))}if(p<=0)return(0,i.error)("could not determine ZIP file size from Content-Range header",{zipUrl:e,contentRange:u}),null;const d=p-n.byteLength;if(o>=d)f=o-d;else{const t=await fetch(e,{headers:{Range:`bytes=${o}-${o+l-1}`}});if(206!==t.status)return(0,i.error)("failed to fetch ZIP central directory",{zipUrl:e,status:t.status,cdOffset:o,cdSize:l}),null;c=await t.arrayBuffer(),f=0}return function(e,t,n,s){const a=new DataView(e);let o=t;const l=[];for(;o+46<=e.byteLength&&33639248===a.getUint32(o,!0);){const t=a.getUint16(o+10,!0),n=a.getUint32(o+20,!0),s=a.getUint32(o+24,!0),i=a.getUint16(o+28,!0),c=a.getUint16(o+30,!0),f=a.getUint16(o+32,!0),u=a.getUint32(o+42,!0),p=new TextDecoder;if(o+46+i>e.byteLength)break;const d=new Uint8Array(e,o+46,i),h=p.decode(d),g=(0,r.normalizeZipEntryPath)(h);""!==g&&l.push({filename:g,offset:u,compressedSize:n,uncompressedSize:s,compression:t}),o+=46+i+c+f}if(0===l.length)return(0,i.error)("no files parsed from central directory",s),null;l.sort((e,t)=>e.offset-t.offset);const c=new Map;for(let e=0;e<l.length;e++){const t=l[e],s=(0,r.normalizeZipEntryPath)(t.filename);""!==s&&(c.has(s)&&(0,i.warn)("duplicate manifest key after normalize; overwriting",s),c.set(s,{filename:t.filename,offset:t.offset,compressedSize:t.compressedSize,uncompressedSize:t.uncompressedSize,compression:t.compression,nextOffset:e<l.length-1?l[e+1].offset:n}))}return c.size>0?c:null}(c,f,o,e)}(e);return c&&(s.zipManifests.set(e,c),await l(e,c,t),(0,i.log)("manifest fetched and stored in memory",{zipUrl:e,entryCount:c.size})),c})().finally(()=>{s.pendingManifestLoads.delete(e)}),s.pendingManifestLoads.set(e,c),c)},t.entryUncompressedSize=function(e){return void 0!==e.uncompressedSize?e.uncompressedSize:0===e.compression?e.compressedSize:null},t.resolveManifestEntry=function(e,t,n,s){if(e.has(t))return{key:t,info:e.get(t),matchKind:"exact"};if(s)return null;const i=(0,r.zipBasenameWithoutExtension)(n);if(!i)return null;const a=`${i}/${t}`;return e.has(a)?{key:a,info:e.get(a),matchKind:"zipBasenameFallback"}:null};const r=n(343),s=n(262),i=n(266);function a(e){const t=new Map;for(const n of e){const e=(0,r.normalizeZipEntryPath)(n.filename);""!==e&&(t.has(e)&&(0,i.warn)("duplicate manifest key after normalize; overwriting",e),t.set(e,n))}return t.size>0?t:null}async function o(e){if(!e)return null;const t=await self.clients.get(e);return"window"===(null==t?void 0:t.type)?t:null}async function l(e,t,n){const r=await o(n);if(!r)return;const s=Array.from(t.values());try{r.postMessage({type:"ZIP_SW_MANIFEST_CREATED",zipUrl:e,files:s})}catch(e){(0,i.warn)("failed to send manifest to client",e)}}},993(e,t,n){t.installMessageHandler=function(){self.addEventListener("message",e=>{if(!e.data)return;const{type:t,zipUrl:n,files:p,config:d,allowedZipUrls:h,previousUrl:g,nextUrl:m}=e.data,w=function(e){if(!e||!("id"in e))return;const t=e.id;return"string"==typeof t?t:void 0}(e.source);if("ZIP_SW_CONFIG"===t){const t=(0,i.applyRuntimeConfig)(d).then(()=>u(e,{ok:!0})).catch(t=>u(e,f(t)));return void e.waitUntil(t)}if("ZIP_MANIFEST"===t){if(n&&p){const t=(0,s.normalizeZipUrl)(n),r=(0,c.manifestFilesToMap)(p),i=o.zipManifests.get(t);if(!r)return void(0,l.warn)("rejecting empty manifest; keeping existing",{zipUrl:t,existingSize:i?i.size:0});if(i&&i.size>r.size)return void(0,l.warn)("rejecting smaller manifest; keeping existing",{zipUrl:t,incomingSize:r.size,existingSize:i.size});o.zipManifests.set(t,r),e.waitUntil((0,c.sendManifestToClientId)(t,r,w));const a=Array.from(r.keys()).slice(0,40);(0,l.log)("ZIP_MANIFEST loaded",{zipUrl:t,entryCount:r.size,sampleKeys:a,replacedExistingSize:i?i.size:0})}}else if("CLEAR_ZIP_ASSETS_EXCEPT_ALLOWED"===t&&h){const t=(0,a.clearZipAssetsExceptAllowed)(h).then(()=>u(e,{ok:!0})).catch(t=>u(e,f(t)));e.waitUntil(t)}else if("CLEAR_ALL_ZIP_ASSETS"===t){const t=(0,a.clearAllZipAssets)().then(()=>u(e,{ok:!0})).catch(t=>u(e,f(t)));e.waitUntil(t)}else if("PRELOAD_ZIP_MANIFESTS"===t&&h){const t=async function(e,t){const n=await Promise.all(e.map(async e=>({zipUrl:e,manifest:await(0,c.ensureManifestAvailable)(e,t)}))),s=n.filter(e=>!e.manifest).map(e=>e.zipUrl);if(s.length>0)throw(0,r.createZipPeekError)(`Failed to preload ZIP manifest(s): ${s.join(", ")}`)}(h,w).then(()=>u(e,{ok:!0})).catch(t=>u(e,f(t)));e.waitUntil(t)}else if("RENEW_ZIP_URL"===t&&g&&m){const t=(0,a.renewZipUrl)(g,m).then(()=>u(e,{ok:!0})).catch(t=>u(e,f(t)));e.waitUntil(t)}})};const r=n(553),s=n(343),i=n(314),a=n(800),o=n(262),l=n(266),c=n(346);function f(e){const t=(0,r.toZipPeekError)(e);return{ok:!1,error:t.message,errorStack:t.stack}}function u(e,t){var n;null===(n=e.ports[0])||void 0===n||n.postMessage(t)}},254(e,t,n){t.corsErrorResponse=c,t.getMimeType=f,t.fetchUncompressedZipEntryFromNetwork=async function(e,t,n){var s;const o=n.offset,l=n.nextOffset-1;(0,a.log)("fetching zip chunk from",{zipUrl:e,rangeStart:o,rangeEnd:l});const p=await fetch(e,{headers:{Range:`bytes=${o}-${l}`}});if(206!==p.status){const n=p.status>=400?p.status:502;return{ok:!1,response:c(`ZIP entry fetch for "${t}" expected HTTP 206 Partial Content from ${e}, got ${p.status}`,n,{upstreamStatus:p.status})}}if(!p.body)return{ok:!1,response:c(`ZIP entry fetch for "${t}" in ${e} returned no response body`,502)};const d=p.body.getReader();let h,g;try{({headerAndPayload:h,dataStart:g}=await async function(e){let t=new Uint8Array(0);for(;t.byteLength<30;){const{done:n,value:r}=await e.read();if(n)throw new Error("ZIP entry ended before its local file header was complete");t=u(t,r)}const n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0,!0)!==i.LOCAL_FILE_HEADER_SIG)throw new Error("Invalid local file header (expected ZIP signature 0x04034b50)");const r=30+n.getUint16(26,!0)+n.getUint16(28,!0);for(;t.byteLength<r;){const{done:n,value:r}=await e.read();if(n)throw new Error("ZIP entry ended before its local file header fields were complete");t=u(t,r)}return{headerAndPayload:t,dataStart:r}}(d))}catch(n){return await d.cancel(n),{ok:!1,response:c(`Invalid local file header for "${t}" in ${e}: ${n instanceof Error?n.message:String(n)}`,500)}}const m=function(e,t,n){let r=t,s=0;return new ReadableStream({async pull(t){if(s>=n)return await e.cancel(),void t.close();let i;if(r.byteLength>0)i=r,r=new Uint8Array(0);else{const{done:r,value:a}=await e.read();if(r)return void t.error(new Error(`ZIP entry ended after ${s} of ${n} compressed bytes`));i=a}const a=n-s,o=i.byteLength>a?i.subarray(0,a):i;s+=o.byteLength,t.enqueue(o),s>=n&&(await e.cancel(),t.close())},cancel:t=>e.cancel(t)})}(d,h.subarray(g),n.compressedSize),w=null!==(s=n.uncompressedSize)&&void 0!==s?s:0===n.compression?n.compressedSize:null;let E;if(8===n.compression)E=function(e,t){const n=e.getReader();let s,i=0,a=!1;return new ReadableStream({start(e){s=new r.Inflate(t=>{i+=t.byteLength,e.enqueue(t)})},async pull(e){for(;!a;){const{done:r,value:o}=await n.read();if(r)return a=!0,s.push(new Uint8Array(0),!0),null!==t&&i!==t?void e.error(new Error(`Inflated ZIP entry size mismatch: expected ${t}, received ${i}`)):void e.close();s.push(o)}},cancel:e=>n.cancel(e)})}(m,w);else{if(0!==n.compression)return await d.cancel(),{ok:!1,response:c(`Unsupported compression method ${n.compression} for "${t}" in ${e} (only stored/0 and DEFLATE/8 are supported)`,500)};E=m}return{ok:!0,stream:E,contentLength:w,contentType:f(t)}};const r=n(612),s=n(553),i=n(262),a=n(266);function o(e){return e.replace(/[\r\n]+/g," ").trim()}function l(e,t){const n=[i.ASSET_ERROR_HEADER],r={"Access-Control-Allow-Origin":"*",[i.ASSET_ERROR_HEADER]:o(e)},s=null==t?void 0:t.upstreamStatus;return void 0!==s&&(r[i.ASSET_UPSTREAM_STATUS_HEADER]=String(s),n.push(i.ASSET_UPSTREAM_STATUS_HEADER)),r["Access-Control-Expose-Headers"]=n.join(", "),r}function c(e,t,n){const r=(0,s.formatZipPeekError)(e);return new Response(r,{status:t,headers:l(r,n)})}function f(e){var t,n;const r=null===(t=e.split(".").pop())||void 0===t?void 0:t.toLowerCase();return r&&null!==(n=i.MIME_TYPES[r])&&void 0!==n?n:"application/octet-stream"}function u(e,t){const n=new Uint8Array(e.byteLength+t.byteLength);return n.set(e),n.set(t,e.byteLength),n}},343(e,t){function n(e){try{return decodeURIComponent(e)}catch(t){return e}}t.normalizeZipUrl=function(e,t={}){const{stripCacheBuster:n=!0,stripHash:r=!0}=t,s=e=>r?e.split("#")[0]:e;if(!n)return s(e);const i=e.indexOf("?");if(-1===i)return s(e);const a=e.indexOf("#",i),o=e.substring(0,i),l=-1===a?e.substring(i+1):e.substring(i+1,a),c=r||-1===a?"":e.substring(a),f=l.split("&").filter(e=>{const t=e.indexOf("=");return"t"!==(-1===t?e:e.substring(0,t))});return 0===f.length?o+c:o+"?"+f.join("&")+c},t.zipBasenameWithoutExtension=function(e){var t,n;try{const n=null!==(t=new URL(e,"http://local").pathname.split("/").pop())&&void 0!==t?t:"";return n.endsWith(".zip")?n.slice(0,-4):n}catch(t){const r=null!==(n=e.split("?")[0].split("#")[0].split("/").pop())&&void 0!==n?n:"";return r.endsWith(".zip")?r.slice(0,-4):r}},t.normalizeZipEntryPath=function(e){let t=e.replace(/\\/g,"/");for(;t.startsWith("/");)t=t.slice(1);return t},t.parseZipAssetRequest=function(e){const t=/\.zip([/?])/.exec(e);if(!t)return null;const r=t.index+4,s=t[1],i=e.substring(0,r);if("/"===s){const t=e.substring(r+1),s=t.indexOf("?"),a=-1===s?t:t.substring(0,s);return""===a?null:{zipUrl:i,internalPath:n(a)}}const a=e.substring(r),o=a.indexOf("/");if(-1===o)return null;const l=a.substring(0,o),c=a.substring(o+1),f=c.indexOf("?"),u=-1===f?c:c.substring(0,f);return""===u?null:{zipUrl:i+l,internalPath:n(u)}},t.canonicalZipAssetRequestUrl=function(e,t){return e+"/"+encodeURIComponent(t)}},612(e,t){var n=Uint8Array,r=Uint16Array,s=Int32Array,i=new n([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),a=new n([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),o=new n([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),l=function(e,t){for(var n=new r(31),i=0;i<31;++i)n[i]=t+=1<<e[i-1];var a=new s(n[30]);for(i=1;i<30;++i)for(var o=n[i];o<n[i+1];++o)a[o]=o-n[i]<<5|i;return{b:n,r:a}},c=l(i,2),f=c.b,u=c.r;f[28]=258,u[258]=28;for(var p=l(a,0),d=p.b,h=(p.r,new r(32768)),g=0;g<32768;++g){var m=(43690&g)>>1|(21845&g)<<1;m=(61680&(m=(52428&m)>>2|(13107&m)<<2))>>4|(3855&m)<<4,h[g]=((65280&m)>>8|(255&m)<<8)>>1}var w=function(e,t,n){for(var s=e.length,i=0,a=new r(t);i<s;++i)e[i]&&++a[e[i]-1];var o,l=new r(t);for(i=1;i<t;++i)l[i]=l[i-1]+a[i-1]<<1;if(n){o=new r(1<<t);var c=15-t;for(i=0;i<s;++i)if(e[i])for(var f=i<<4|e[i],u=t-e[i],p=l[e[i]-1]++<<u,d=p|(1<<u)-1;p<=d;++p)o[h[p]>>c]=f}else for(o=new r(s),i=0;i<s;++i)e[i]&&(o[i]=h[l[e[i]-1]++]>>15-e[i]);return o},E=new n(288);for(g=0;g<144;++g)E[g]=8;for(g=144;g<256;++g)E[g]=9;for(g=256;g<280;++g)E[g]=7;for(g=280;g<288;++g)E[g]=8;var A=new n(32);for(g=0;g<32;++g)A[g]=5;var y=w(E,9,1),U=w(A,5,1),v=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},R=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},C=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},Z=function(e){return(e+7)/8|0},S=function(e,t,r){return(null==t||t<0)&&(t=0),(null==r||r>e.length)&&(r=e.length),new n(e.subarray(t,r))},z=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],_=function(e,t,n){var r=new Error(t||z[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,_),!n)throw r;return r},b=function(e,t,r,s){var l=e.length,c=s?s.length:0;if(!l||t.f&&!t.l)return r||new n(0);var u=!r,p=u||2!=t.i,h=t.i;u&&(r=new n(3*l));var g=function(e){var t=r.length;if(e>t){var s=new n(Math.max(2*t,e));s.set(r),r=s}},m=t.f||0,E=t.p||0,A=t.b||0,z=t.l,b=t.d,P=t.m,M=t.n,I=8*l;do{if(!z){m=R(e,E,1);var T=R(e,E+1,3);if(E+=3,!T){var L=e[(W=Z(E)+4)-4]|e[W-3]<<8,k=W+L;if(k>l){h&&_(0);break}p&&g(A+L),r.set(e.subarray(W,k),A),t.b=A+=L,t.p=E=8*k,t.f=m;continue}if(1==T)z=y,b=U,P=9,M=5;else if(2==T){var F=R(e,E,31)+257,x=R(e,E+10,15)+4,O=F+R(e,E+5,31)+1;E+=14;for(var N=new n(O),H=new n(19),$=0;$<x;++$)H[o[$]]=R(e,E+3*$,7);E+=3*x;var D=v(H),q=(1<<D)-1,j=w(H,D,1);for($=0;$<O;){var W,K=j[R(e,E,q)];if(E+=15&K,(W=K>>4)<16)N[$++]=W;else{var G=0,X=0;for(16==W?(X=3+R(e,E,3),E+=2,G=N[$-1]):17==W?(X=3+R(e,E,7),E+=3):18==W&&(X=11+R(e,E,127),E+=7);X--;)N[$++]=G}}var B=N.subarray(0,F),Y=N.subarray(F);P=v(B),M=v(Y),z=w(B,P,1),b=w(Y,M,1)}else _(1);if(E>I){h&&_(0);break}}p&&g(A+131072);for(var V=(1<<P)-1,J=(1<<M)-1,Q=E;;Q=E){var ee=(G=z[C(e,E)&V])>>4;if((E+=15&G)>I){h&&_(0);break}if(G||_(2),ee<256)r[A++]=ee;else{if(256==ee){Q=E,z=null;break}var te=ee-254;if(ee>264){var ne=i[$=ee-257];te=R(e,E,(1<<ne)-1)+f[$],E+=ne}var re=b[C(e,E)&J],se=re>>4;if(re||_(3),E+=15&re,Y=d[se],se>3&&(ne=a[se],Y+=C(e,E)&(1<<ne)-1,E+=ne),E>I){h&&_(0);break}p&&g(A+131072);var ie=A+te;if(A<Y){var ae=c-Y,oe=Math.min(Y,ie);for(ae+A<0&&_(3);A<oe;++A)r[A]=s[ae+A]}for(;A<ie;++A)r[A]=r[A-Y]}}t.l=z,t.p=Q,t.b=A,t.f=m,z&&(m=1,t.m=P,t.d=b,t.n=M)}while(!m);return A!=r.length&&u?S(r,0,A):r.subarray(0,A)},P=new n(0);var M=function(){function e(e,t){"function"==typeof e&&(t=e,e={}),this.ondata=t;var r=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:r?r.length:0},this.o=new n(32768),this.p=new n(0),r&&this.o.set(r)}return e.prototype.e=function(e){if(this.ondata||_(5),this.d&&_(4),this.p.length){if(e.length){var t=new n(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}}else this.p=e},e.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,n=b(this.p,this.s,this.o);this.ondata(S(n,t,this.s.b),this.d),this.o=S(n,this.s.b-32768),this.s.b=this.o.length,this.p=S(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}();t.Inflate=M;var I="undefined"!=typeof TextDecoder&&new TextDecoder;try{I.decode(P,{stream:!0})}catch(e){}"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout}};const t={};function n(r){const s=t[r];if(void 0!==s)return s.exports;const i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}(()=>{const e=n(266),t=n(982),r=n(993);self.addEventListener("install",()=>{self.skipWaiting()}),self.addEventListener("activate",e=>{e.waitUntil(self.clients.claim())}),(0,e.installClientErrorReporting)(),(0,r.installMessageHandler)(),(0,t.installFetchHandler)()})()})();
2
2
  //# sourceMappingURL=zipServiceWorker.js.map