@dudousxd/nestjs-media-dashboard 0.16.0 → 0.16.2

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 +1 @@
1
- import{r as ve,u as me,j as p,N as J,F as xe,g as re,e as O,f as z,D as ze,I as Ze,B as we,m as Fe}from"./styles-CuahvDe0.js";var x=Uint8Array,C=Uint16Array,$e=Int32Array,ke=new x([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]),Te=new x([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]),Me=new x([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ee=function(e,t){for(var r=new C(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];for(var i=new $e(r[30]),n=1;n<30;++n)for(var s=r[n];s<r[n+1];++s)i[s]=s-r[n]<<5|n;return{b:r,r:i}},Se=Ee(ke,2),Le=Se.b,Be=Se.r;Le[28]=258,Be[258]=28;var He=Ee(Te,0),Ge=He.b,ne=new C(32768);for(var g=0;g<32768;++g){var E=(g&43690)>>1|(g&21845)<<1;E=(E&52428)>>2|(E&13107)<<2,E=(E&61680)>>4|(E&3855)<<4,ne[g]=((E&65280)>>8|(E&255)<<8)>>1}var P=function(e,t,r){for(var n=e.length,i=0,s=new C(t);i<n;++i)e[i]&&++s[e[i]-1];var a=new C(t);for(i=1;i<t;++i)a[i]=a[i-1]+s[i-1]<<1;var o;if(r){o=new C(1<<t);var f=15-t;for(i=0;i<n;++i)if(e[i])for(var l=i<<4|e[i],d=t-e[i],c=a[e[i]-1]++<<d,h=c|(1<<d)-1;c<=h;++c)o[ne[c]>>f]=l}else for(o=new C(n),i=0;i<n;++i)e[i]&&(o[i]=ne[a[e[i]-1]++]>>15-e[i]);return o},F=new x(288);for(var g=0;g<144;++g)F[g]=8;for(var g=144;g<256;++g)F[g]=9;for(var g=256;g<280;++g)F[g]=7;for(var g=280;g<288;++g)F[g]=8;var Re=new x(32);for(var g=0;g<32;++g)Re[g]=5;var Ye=P(F,9,1),qe=P(Re,5,1),ee=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},y=function(e,t,r){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(t&7)&r},te=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(t&7)},Ne=function(e){return(e+7)/8|0},B=function(e,t,r){return(t==null||t<0)&&(t=0),(r==null||r>e.length)&&(r=e.length),new x(e.subarray(t,r))},Ke=["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"],b=function(e,t,r){var n=new Error(t||Ke[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,b),!r)throw n;return n},je=function(e,t,r,n){var i=e.length,s=0;if(!i||t.f&&!t.l)return r||new x(0);var a=!r,o=a||t.i!=2,f=t.i;a&&(r=new x(i*3));var l=function(de){var pe=r.length;if(de>pe){var ge=new x(Math.max(pe*2,de));ge.set(r),r=ge}},d=t.f||0,c=t.p||0,h=t.b||0,v=t.l,m=t.d,u=t.m,S=t.n,H=i*8;do{if(!v){d=y(e,c,1);var G=y(e,c+1,3);if(c+=3,G)if(G==1)v=Ye,m=qe,u=9,S=5;else if(G==2){var K=y(e,c,31)+257,ae=y(e,c+10,15)+4,se=K+y(e,c+5,31)+1;c+=14;for(var I=new x(se),X=new x(19),w=0;w<ae;++w)X[Me[w]]=y(e,c+w*3,7);c+=ae*3;for(var oe=ee(X),_e=(1<<oe)-1,Ie=P(X,oe,1),w=0;w<se;){var ce=Ie[y(e,c,_e)];c+=ce&15;var k=ce>>4;if(k<16)I[w++]=k;else{var j=0,$=0;for(k==16?($=3+y(e,c,3),c+=2,j=I[w-1]):k==17?($=3+y(e,c,7),c+=3):k==18&&($=11+y(e,c,127),c+=7);$--;)I[w++]=j}}var le=I.subarray(0,K),T=I.subarray(K);u=ee(le),S=ee(T),v=P(le,u,1),m=P(T,S,1)}else b(1);else{var k=Ne(c)+4,Y=e[k-4]|e[k-3]<<8,q=k+Y;if(q>i){f&&b(0);break}o&&l(h+Y),r.set(e.subarray(k,q),h),t.b=h+=Y,t.p=c=q*8,t.f=d;continue}if(c>H){f&&b(0);break}}o&&l(h+131072);for(var De=(1<<u)-1,Oe=(1<<S)-1,W=c;;W=c){var j=v[te(e,c)&De],A=j>>4;if(c+=j&15,c>H){f&&b(0);break}if(j||b(2),A<256)r[h++]=A;else if(A==256){W=c,v=null;break}else{var fe=A-254;if(A>264){var w=A-257,D=ke[w];fe=y(e,c,(1<<D)-1)+Le[w],c+=D}var V=m[te(e,c)&Oe],Q=V>>4;V||b(3),c+=V&15;var T=Ge[Q];if(Q>3){var D=Te[Q];T+=te(e,c)&(1<<D)-1,c+=D}if(c>H){f&&b(0);break}o&&l(h+131072);var he=h+fe;if(h<T){var ue=s-T,Pe=Math.min(T,he);for(ue+h<0&&b(3);h<Pe;++h)r[h]=n[ue+h]}for(;h<he;++h)r[h]=r[h-T]}}t.l=v,t.p=W,t.b=h,t.f=d,v&&(d=1,t.m=u,t.d=m,t.n=S)}while(!d);return h!=r.length&&a?B(r,0,h):r.subarray(0,h)},Xe=new x(0),We=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&b(6,"invalid gzip data");var t=e[3],r=10;t&4&&(r+=(e[10]|e[11]<<8)+2);for(var n=(t>>3&1)+(t>>4&1);n>0;n-=!e[r++]);return r+(t&2)},M=function(){function e(t,r){typeof t=="function"&&(r=t,t={}),this.ondata=r;var n=t&&t.dictionary&&t.dictionary.subarray(-32768);this.s={i:0,b:n?n.length:0},this.o=new x(32768),this.p=new x(0),n&&this.o.set(n)}return e.prototype.e=function(t){if(this.ondata||b(5),this.d&&b(4),!this.p.length)this.p=t;else if(t.length){var r=new x(this.p.length+t.length);r.set(this.p),r.set(t,this.p.length),this.p=r}},e.prototype.c=function(t){this.s.i=+(this.d=t||!1);var r=this.s.b,n=je(this.p,this.s,this.o);this.ondata(B(n,r,this.s.b),this.d),this.o=B(n,this.s.b-32768),this.s.b=this.o.length,this.p=B(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(t,r){this.e(t),this.c(r)},e}();function Ve(e,t){return je(e,{i:2},t,t)}var Qe=function(){function e(t,r){this.v=1,this.r=0,M.call(this,t,r)}return e.prototype.push=function(t,r){if(M.prototype.e.call(this,t),this.r+=t.length,this.v){var n=this.p.subarray(this.v-1),i=n.length>3?We(n):4;if(i>n.length){if(!r)return}else this.v>1&&this.onmember&&this.onmember(this.r-n.length);this.p=n.subarray(i),this.v=0}M.prototype.c.call(this,0),this.s.f&&!this.s.l?(this.v=Ne(this.s.p)+9,this.s={i:0},this.o=new x(0),this.push(new x(0),r)):r&&M.prototype.c.call(this,r)},e}(),Je=typeof TextDecoder<"u"&&new TextDecoder,et=0;try{Je.decode(Xe,{stream:!0}),et=1}catch{}const tt=65577,rt=16*1024*1024,ie=2*1024*1024,nt=256*1024,be=64*1024,Ae=512*1024,it=101010256,at=117853008,st=101075792,ot=33639248,ct=67324752,Z=4294967295,lt=65535;function _(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function R(e,t){return Number(e.getBigUint64(t,!0))}const ft={0:"stored",1:"shrunk",6:"imploded",8:"deflate",9:"deflate64",12:"bzip2",14:"lzma",93:"zstd",95:"xz",96:"jpeg",97:"wavpack",98:"ppmd",99:"aes"};function Ue(e){return ft[e]??`method ${e}`}function ht(e,t){const r=1980+(e>>9&127),n=e>>5&15,i=e&31;if(n===0||i===0)return"—";const s=t>>11&31,a=t>>5&63,o=(t&31)*2,f=l=>String(l).padStart(2,"0");return`${r}-${f(n)}-${f(i)} ${f(s)}:${f(a)}:${f(o)}`}function ut(e){if(!Number.isFinite(e)||e<=0)return"—";const t=new Date(e*1e3);return Number.isNaN(t.getTime())?"—":t.toISOString().slice(0,19).replace("T"," ")}function dt(e,t){return e<=0?"—":`${Math.round((1-t/e)*100)}%`}function pt(e){const t=_(e);let r=null,n=null;for(let d=e.byteLength-22;d>=0;d--){if(t.getUint32(d,!0)!==it)continue;const c=t.getUint16(d+20,!0);if(d+22+c===e.byteLength){n=d;break}r===null&&(r=d)}const i=n??r;if(i===null)throw new Error("No end-of-central-directory record in the last 64 KB — this is not a ZIP archive, or it is truncated.");const s=t.getUint16(i+10,!0),a=t.getUint32(i+12,!0),o=t.getUint32(i+16,!0),f=s===lt||a===Z||o===Z;let l=null;return i>=20&&t.getUint32(i-20,!0)===at&&(l=R(t,i-20+8)),{centralDirectoryOffset:o,centralDirectorySize:a,entryCount:s,zip64RecordOffset:l,needsZip64:f}}function gt(e){if(e.byteLength<56)throw new Error("The ZIP64 end record is truncated.");const t=_(e);if(t.getUint32(0,!0)!==st)throw new Error("The ZIP64 locator points at something that is not a ZIP64 end record.");return{entryCount:R(t,32),centralDirectorySize:R(t,40),centralDirectoryOffset:R(t,48)}}function vt(e,t){const r=_(e);for(let n=0;n+4<=e.byteLength;){const i=r.getUint16(n,!0),s=r.getUint16(n+2,!0),a=n+4;if(a+s>e.byteLength)break;if(i!==1){n=a+s;continue}let o=a;const f={...t};return f.uncompressedSize===Z&&o+8<=a+s&&(f.uncompressedSize=R(r,o),o+=8),f.compressedSize===Z&&o+8<=a+s&&(f.compressedSize=R(r,o),o+=8),f.localHeaderOffset===Z&&o+8<=a+s&&(f.localHeaderOffset=R(r,o)),f}return{...t}}function mt(e){return new TextDecoder().decode(e)}function xt(e){const t=_(e),r=[];let n=0,i=!1;for(;n+46<=e.byteLength;){if(t.getUint32(n,!0)!==ot){i=!0;break}const s=t.getUint16(n+8,!0),a=t.getUint16(n+10,!0),o=t.getUint16(n+12,!0),f=t.getUint16(n+14,!0),l=t.getUint16(n+28,!0),d=t.getUint16(n+30,!0),c=t.getUint16(n+32,!0),h=t.getUint32(n+38,!0),v=46+l+d+c;if(n+v>e.byteLength){i=!0;break}const m=vt(e.subarray(n+46+l,n+46+l+d),{uncompressedSize:t.getUint32(n+24,!0),compressedSize:t.getUint32(n+20,!0),localHeaderOffset:t.getUint32(n+42,!0)}),u=mt(e.subarray(n+46,n+46+l)),S=h>>>16&65535;r.push({path:u,directory:u.endsWith("/")||(S&61440)===16384,encrypted:(s&1)!==0,method:a,uncompressedSize:m.uncompressedSize,compressedSize:m.compressedSize,modified:ht(f,o),localHeaderOffset:m.localHeaderOffset}),n+=v}if(r.length===0)throw new Error("The central directory holds no readable entries — the archive looks corrupt.");return{entries:r,truncated:i||n<e.byteLength}}function L(e,t,r){const n=e.subarray(t,t+r),i=n.indexOf(0);return new TextDecoder().decode(i<0?n:n.subarray(0,i))}function U(e,t,r){const n=e[t];if(n===void 0)return null;if(n&128){let a=0;for(let o=1;o<r;o++)a=a*256+(e[t+o]??0);return a}let i="";for(let a=0;a<r;a++)i+=String.fromCharCode(e[t+a]??0);const s=i.replace(/\0/g," ").trim();return s===""?0:/^[0-7]+$/.test(s)?Number.parseInt(s,8):null}function zt(e,t){const r=U(e,t+148,8);if(r===null)return!1;let n=0,i=0;for(let s=0;s<512;s++){const a=s>=148&&s<156?32:e[t+s]??0;n+=a,i+=a>127?a-256:a}return r===n||r===i}function wt(e,t){for(let r=0;r<512;r++)if((e[t+r]??0)!==0)return!1;return!0}function bt(e,t){return e==="5"?"dir":e==="2"?"symlink":e==="1"?"hardlink":e==="0"||e==="\0"||e==="7"?t.endsWith("/")?"dir":"file":"other"}function yt(e){const t=new TextDecoder().decode(e),r=/(?:^|\n)\d+ path=([^\n]*)\n/.exec(t);return(r==null?void 0:r[1])??null}function Ce(e){const t=[];let r=0,n=null;for(;r+512<=e.byteLength;){if(wt(e,r))return{entries:t,truncated:!1};if(!zt(e,r)){if(t.length===0)throw new Error("This is not a TAR archive — the first block has no valid header checksum.");return{entries:t,truncated:!0}}const i=U(e,r+124,12)??0,s=U(e,r+136,12)??0,a=String.fromCharCode(e[r+156]??0),o=r+512,f=Math.ceil(i/512)*512,l=o+i<=e.byteLength;if(a==="L"||a==="x"||a==="g"){if(!l)return{entries:t,truncated:!0};const u=e.subarray(o,o+i);a==="L"?n=L(u,0,i):a==="x"&&(n=yt(u)),r=o+f;continue}const d=L(e,r,100),c=L(e,r+257,6).startsWith("ustar")?L(e,r+345,155):"",h=n??(c?`${c}/${d}`:d);n=null;const v=L(e,r+265,32)||String(U(e,r+108,8)??0),m=L(e,r+297,32)||String(U(e,r+116,8)??0);t.push({path:h,kind:bt(a,h),size:i,mode:(U(e,r+100,8)??0).toString(8).padStart(4,"0"),owner:`${v}/${m}`,modified:ut(s)}),r=o+f}return{entries:t,truncated:!0}}function kt(e,t){var n;if(/\.(tar\.bz2|tbz2?|bz2)$/i.test(e))return"bzip2";if(/\.(tar\.xz|txz|xz)$/i.test(e))return"xz";if(/\.(tar\.gz|tgz|gz)$/i.test(e))return"tar.gz";if(/\.tar$/i.test(e))return"tar";if(/\.(zip|jar|war|whl|xpi)$/i.test(e))return"zip";const r=((n=t==null?void 0:t.toLowerCase().split(";")[0])==null?void 0:n.trim())??"";return r==="application/zip"||r==="application/x-zip-compressed"?"zip":r==="application/x-tar"?"tar":r==="application/gzip"||r==="application/x-gzip"?"tar.gz":r==="application/x-bzip2"?"bzip2":r==="application/x-xz"?"xz":"unknown"}function Tt(e){const t=(...r)=>r.every((n,i)=>e[i]===n);return t(80,75)?"zip":t(31,139)?"tar.gz":t(66,90,104)?"bzip2":t(253,55,122,88,90)?"xz":e.byteLength>=512&&L(e,257,6).startsWith("ustar")?"tar":"unknown"}const Et=/\.(txt|md|markdown|json|ndjson|jsonl|csv|tsv|xml|ya?ml|toml|ini|cfg|conf|properties|log|sql|html?|css|scss|jsx?|mjs|cjs|tsx?|sh|bash|py|rb|go|rs|java|kt|kts|c|h|cpp|hpp|cs|php|pl|lua|gradle|env|lock|gitignore|dockerfile|mf|classpath|project)$/i,St=/^(readme|license|licence|notice|changelog|authors|copying|makefile|dockerfile|\.gitignore|\.npmrc|\.editorconfig)$/i;function Lt(e){const t=e.split("/").pop()??"";return Et.test(t)||St.test(t)}function Rt(e){return!e.directory&&!e.encrypted&&(e.method===0||e.method===8)&&e.uncompressedSize>0&&e.uncompressedSize<=Ae&&Lt(e.path)}async function N(e,t,r){if(e.size<=0)throw new Error("This object is empty.");const n=Math.max(0,Math.min(t,e.size-1)),i=Math.min(e.size-1,n+Math.max(1,r)-1);return Fe.objectRange(e.disk,e.key,n,i)}async function Nt(e){if(e.size<22)throw new Error("This file is too small to be a ZIP archive.");const t=Math.min(tt,e.size),r=e.size-t,n=await N(e,r,t);let i=n.byteLength;const s=pt(n);let{centralDirectoryOffset:a,centralDirectorySize:o,entryCount:f}=s,l=!1;if(s.zip64RecordOffset!==null){const v=s.zip64RecordOffset-r;let m;v>=0&&v+56<=n.byteLength?m=n.subarray(v,v+56):(m=await N(e,s.zip64RecordOffset,56),i+=m.byteLength);const u=gt(m);a=u.centralDirectoryOffset,o=u.centralDirectorySize,f=u.entryCount,l=!0}else if(s.needsZip64)throw new Error("This is a ZIP64 archive (over 4 GB or over 65,535 entries) whose ZIP64 locator is missing, so its central directory cannot be found.");if(a+o>e.size)throw new Error("The central directory points outside the file — the archive is truncated.");const d=Math.min(o,rt),c=await N(e,a,d);i+=c.byteLength;const h=xt(c);return{kind:"zip",entries:h.entries,declaredCount:f,zip64:l,truncated:h.truncated||d<o,bytesRead:i}}function jt(e){const t=[];let r=0;const n=new Qe(a=>{r>=ie||(t.push(a),r+=a.byteLength)});try{for(let a=0;a<e.byteLength&&r<ie;a+=be)n.push(e.subarray(a,a+be),!1)}catch(a){if(r===0)throw new Error(re(a,"Could not decompress this gzip stream."))}const i=new Uint8Array(r);let s=0;for(const a of t)i.set(a,s),s+=a.byteLength;return i}function At(e,t){try{return Ce(e)}catch{throw new Error(t)}}async function ye(e,t){const n=Math.min(t?nt:ie,e.size),i=await N(e,0,n),s=t?jt(i):i,a=t?At(s,"This gzip stream does not contain a TAR archive."):Ce(s);return{kind:"tar",entries:a.entries,compression:t?"gzip":"none",sampled:a.truncated||i.byteLength<e.size,bytesRead:i.byteLength}}async function Ut(e){let t=kt(e.name,e.contentType);switch(t==="unknown"&&(t=Tt(await N(e,0,512))),t){case"zip":return Nt(e);case"tar":return ye(e,!1);case"tar.gz":return ye(e,!0);case"bzip2":case"xz":return{kind:"unsupported",message:`This is a ${t==="bzip2"?"bzip2":"xz"}-compressed archive. Only its compressed bytes are here, and ${t==="bzip2"?"bzip2":"xz"} cannot be decompressed in the browser, so its contents cannot be listed inline.`};case"unknown":return{kind:"unsupported",message:"This file is not a ZIP, TAR or gzip archive."}}}async function Ct(e,t){const r=await N(e,t.localHeaderOffset,30);if(r.byteLength<30||_(r).getUint32(0,!0)!==ct)throw new Error("This entry does not start with a local file header — the archive is corrupt.");if(t.compressedSize<=0)return{text:"",binary:!1,bytesRead:r.byteLength};const n=_(r),i=t.localHeaderOffset+30+n.getUint16(26,!0)+n.getUint16(28,!0),s=await N(e,i,t.compressedSize),a=t.method===0?s:Ve(s),o=new TextDecoder().decode(a.subarray(0,Ae));return{text:o,binary:o.includes("\0"),bytesRead:r.byteLength+s.byteLength}}function _t(e){return{header:["path","kind","size","compressed","ratio","method","modified"],body:e.map(t=>[t.path,t.directory?"dir":t.encrypted?"file (encrypted)":"file",t.directory?"—":z(t.uncompressedSize),t.directory?"—":z(t.compressedSize),t.directory?"—":dt(t.uncompressedSize,t.compressedSize),t.directory?"—":Ue(t.method),t.modified])}}function It(e){return{header:["path","kind","size","mode","owner","modified"],body:e.map(t=>[t.path,t.kind,t.kind==="dir"?"—":z(t.size),t.mode,t.owner,t.modified])}}function Ot({item:e}){var m;const[t,r]=ve.useState(null),[n,i]=ve.useState(""),s=me({queryKey:["archive-listing",e.disk,e.key],queryFn:()=>Ut(e),retry:!1,staleTime:6e4}),o=(((m=s.data)==null?void 0:m.kind)==="zip"?s.data.entries:[]).find(u=>u.path===t)??null,f=me({queryKey:["archive-entry",e.disk,e.key,t],queryFn:()=>{if(!o)throw new Error("No entry selected.");return Ct(e,o)},enabled:o!==null,retry:!1,staleTime:6e4});if(s.isLoading)return p.jsx(J,{children:"Reading archive…"});if(s.isError||!s.data)return p.jsx(xe,{item:e,message:re(s.error,"Could not read this archive.")});const l=s.data;if(l.kind==="unsupported")return p.jsx(xe,{item:e,message:l.message});if(l.kind==="tar"){const u=It(l.entries);return p.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2",children:[l.sampled&&p.jsxs(O,{variant:"warn",className:"shrink-0",children:["Sample — a TAR has no index, so this is what fits in the first"," ",z(l.bytesRead)," of ",z(e.size),l.compression==="gzip"?", gunzipped from the start of the stream":"",". Filters and sort apply to these ",l.entries.length," ",l.entries.length===1?"entry":"entries","; open the original ↗ for the whole archive."]}),l.entries.length===0?p.jsx(J,{children:"No entries in the sample."}):p.jsx(ze,{header:u.header,body:u.body}),p.jsxs("div",{className:"mono tnum shrink-0 text-[10px] text-zinc-600",children:[l.entries.length," ",l.entries.length===1?"entry":"entries"," · read"," ",z(l.bytesRead)," of ",z(e.size),l.compression==="gzip"&&" · gunzipped"]})]})}const d=l.entries.filter(Rt),c=n.trim().toLowerCase(),h=(c?d.filter(u=>u.path.toLowerCase().includes(c)):d).slice(0,300),v=_t(l.entries);return p.jsxs("div",{className:"flex min-h-0 flex-1 gap-3",children:[d.length>0&&p.jsxs("div",{className:"flex w-56 shrink-0 flex-col gap-1 overflow-auto",children:[p.jsx("div",{className:"shrink-0 text-[10px] uppercase tracking-wide text-zinc-500",children:"Readable entries"}),p.jsx(Ze,{value:n,onChange:u=>i(u.target.value),placeholder:"find an entry…",className:"shrink-0"}),h.map(u=>p.jsx(we,{tone:u.path===t?"selected":"quiet",title:`${u.path} · ${z(u.uncompressedSize)}`,className:"justify-start px-2 py-0.5 text-left",onClick:()=>r(u.path===t?null:u.path),children:p.jsx("span",{className:"truncate",children:u.path.split("/").pop()||u.path})},u.path)),h.length<d.length&&p.jsxs("div",{className:"mono shrink-0 px-2 text-[10px] text-zinc-600",children:[d.length-h.length," more — narrow the filter"]})]}),p.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-2",children:[l.zip64&&p.jsx(O,{variant:"warn",className:"shrink-0",children:"ZIP64 archive — over 4 GB or over 65,535 entries. Its 64-bit directory was read in full."}),l.truncated&&p.jsxs(O,{variant:"warn",className:"shrink-0",children:["Partial listing — the central directory was cut short after ",l.entries.length," of"," ",l.declaredCount," entries."]}),o?p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[p.jsx(we,{tone:"ghost",onClick:()=>r(null),children:"← Listing"}),p.jsx("span",{className:"mono truncate text-[11px] text-zinc-400",children:o.path})]}),f.isLoading&&p.jsx(J,{children:"Extracting…"}),f.isError&&p.jsx(O,{variant:"error",children:re(f.error,"Could not extract this entry.")}),f.data&&(f.data.binary?p.jsx(O,{variant:"warn",children:"This entry is binary despite its name — showing it as text would be noise."}):p.jsx("pre",{className:"mono min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-words rounded-md border border-border bg-black/30 p-3 text-xs text-zinc-300",children:f.data.text})),f.data&&p.jsxs("div",{className:"mono tnum shrink-0 text-[10px] text-zinc-600",children:["read ",z(f.data.bytesRead)," of ",z(e.size)," ·"," ",Ue(o.method)," ·"," ",z(o.uncompressedSize)," uncompressed"]})]}):p.jsxs(p.Fragment,{children:[p.jsx(ze,{header:v.header,body:v.body}),p.jsxs("div",{className:"mono tnum shrink-0 text-[10px] text-zinc-600",children:[l.entries.length," ",l.entries.length===1?"entry":"entries"," · read"," ",z(l.bytesRead)," of ",z(e.size),d.length>0&&" · pick an entry on the left to read it"]})]})]})]})}export{Ot as ArchivePreview,kt as archiveFormat,Ct as extractZipEntry,ht as formatDosDateTime,ut as formatEpochSeconds,dt as formatRatio,jt as gunzipSample,Rt as isExtractable,Lt as isTextEntryPath,Ce as parseTarEntries,gt as parseZip64EndRecord,xt as parseZipCentralDirectory,pt as scanZipTail,Tt as sniffArchiveFormat,Ue as zipMethodName};
1
+ import{r as ve,u as me,j as p,N as J,F as xe,g as re,e as O,f as z,D as ze,I as Ze,B as we,m as Fe}from"./styles-Cui6Yy9Y.js";var x=Uint8Array,C=Uint16Array,$e=Int32Array,ke=new x([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]),Te=new x([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]),Me=new x([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ee=function(e,t){for(var r=new C(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];for(var i=new $e(r[30]),n=1;n<30;++n)for(var s=r[n];s<r[n+1];++s)i[s]=s-r[n]<<5|n;return{b:r,r:i}},Se=Ee(ke,2),Le=Se.b,Be=Se.r;Le[28]=258,Be[258]=28;var He=Ee(Te,0),Ge=He.b,ne=new C(32768);for(var g=0;g<32768;++g){var E=(g&43690)>>1|(g&21845)<<1;E=(E&52428)>>2|(E&13107)<<2,E=(E&61680)>>4|(E&3855)<<4,ne[g]=((E&65280)>>8|(E&255)<<8)>>1}var P=function(e,t,r){for(var n=e.length,i=0,s=new C(t);i<n;++i)e[i]&&++s[e[i]-1];var a=new C(t);for(i=1;i<t;++i)a[i]=a[i-1]+s[i-1]<<1;var o;if(r){o=new C(1<<t);var f=15-t;for(i=0;i<n;++i)if(e[i])for(var l=i<<4|e[i],d=t-e[i],c=a[e[i]-1]++<<d,h=c|(1<<d)-1;c<=h;++c)o[ne[c]>>f]=l}else for(o=new C(n),i=0;i<n;++i)e[i]&&(o[i]=ne[a[e[i]-1]++]>>15-e[i]);return o},F=new x(288);for(var g=0;g<144;++g)F[g]=8;for(var g=144;g<256;++g)F[g]=9;for(var g=256;g<280;++g)F[g]=7;for(var g=280;g<288;++g)F[g]=8;var Re=new x(32);for(var g=0;g<32;++g)Re[g]=5;var Ye=P(F,9,1),qe=P(Re,5,1),ee=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},y=function(e,t,r){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(t&7)&r},te=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(t&7)},Ne=function(e){return(e+7)/8|0},B=function(e,t,r){return(t==null||t<0)&&(t=0),(r==null||r>e.length)&&(r=e.length),new x(e.subarray(t,r))},Ke=["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"],b=function(e,t,r){var n=new Error(t||Ke[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,b),!r)throw n;return n},je=function(e,t,r,n){var i=e.length,s=0;if(!i||t.f&&!t.l)return r||new x(0);var a=!r,o=a||t.i!=2,f=t.i;a&&(r=new x(i*3));var l=function(de){var pe=r.length;if(de>pe){var ge=new x(Math.max(pe*2,de));ge.set(r),r=ge}},d=t.f||0,c=t.p||0,h=t.b||0,v=t.l,m=t.d,u=t.m,S=t.n,H=i*8;do{if(!v){d=y(e,c,1);var G=y(e,c+1,3);if(c+=3,G)if(G==1)v=Ye,m=qe,u=9,S=5;else if(G==2){var K=y(e,c,31)+257,ae=y(e,c+10,15)+4,se=K+y(e,c+5,31)+1;c+=14;for(var I=new x(se),X=new x(19),w=0;w<ae;++w)X[Me[w]]=y(e,c+w*3,7);c+=ae*3;for(var oe=ee(X),_e=(1<<oe)-1,Ie=P(X,oe,1),w=0;w<se;){var ce=Ie[y(e,c,_e)];c+=ce&15;var k=ce>>4;if(k<16)I[w++]=k;else{var j=0,$=0;for(k==16?($=3+y(e,c,3),c+=2,j=I[w-1]):k==17?($=3+y(e,c,7),c+=3):k==18&&($=11+y(e,c,127),c+=7);$--;)I[w++]=j}}var le=I.subarray(0,K),T=I.subarray(K);u=ee(le),S=ee(T),v=P(le,u,1),m=P(T,S,1)}else b(1);else{var k=Ne(c)+4,Y=e[k-4]|e[k-3]<<8,q=k+Y;if(q>i){f&&b(0);break}o&&l(h+Y),r.set(e.subarray(k,q),h),t.b=h+=Y,t.p=c=q*8,t.f=d;continue}if(c>H){f&&b(0);break}}o&&l(h+131072);for(var De=(1<<u)-1,Oe=(1<<S)-1,W=c;;W=c){var j=v[te(e,c)&De],A=j>>4;if(c+=j&15,c>H){f&&b(0);break}if(j||b(2),A<256)r[h++]=A;else if(A==256){W=c,v=null;break}else{var fe=A-254;if(A>264){var w=A-257,D=ke[w];fe=y(e,c,(1<<D)-1)+Le[w],c+=D}var V=m[te(e,c)&Oe],Q=V>>4;V||b(3),c+=V&15;var T=Ge[Q];if(Q>3){var D=Te[Q];T+=te(e,c)&(1<<D)-1,c+=D}if(c>H){f&&b(0);break}o&&l(h+131072);var he=h+fe;if(h<T){var ue=s-T,Pe=Math.min(T,he);for(ue+h<0&&b(3);h<Pe;++h)r[h]=n[ue+h]}for(;h<he;++h)r[h]=r[h-T]}}t.l=v,t.p=W,t.b=h,t.f=d,v&&(d=1,t.m=u,t.d=m,t.n=S)}while(!d);return h!=r.length&&a?B(r,0,h):r.subarray(0,h)},Xe=new x(0),We=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&b(6,"invalid gzip data");var t=e[3],r=10;t&4&&(r+=(e[10]|e[11]<<8)+2);for(var n=(t>>3&1)+(t>>4&1);n>0;n-=!e[r++]);return r+(t&2)},M=function(){function e(t,r){typeof t=="function"&&(r=t,t={}),this.ondata=r;var n=t&&t.dictionary&&t.dictionary.subarray(-32768);this.s={i:0,b:n?n.length:0},this.o=new x(32768),this.p=new x(0),n&&this.o.set(n)}return e.prototype.e=function(t){if(this.ondata||b(5),this.d&&b(4),!this.p.length)this.p=t;else if(t.length){var r=new x(this.p.length+t.length);r.set(this.p),r.set(t,this.p.length),this.p=r}},e.prototype.c=function(t){this.s.i=+(this.d=t||!1);var r=this.s.b,n=je(this.p,this.s,this.o);this.ondata(B(n,r,this.s.b),this.d),this.o=B(n,this.s.b-32768),this.s.b=this.o.length,this.p=B(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(t,r){this.e(t),this.c(r)},e}();function Ve(e,t){return je(e,{i:2},t,t)}var Qe=function(){function e(t,r){this.v=1,this.r=0,M.call(this,t,r)}return e.prototype.push=function(t,r){if(M.prototype.e.call(this,t),this.r+=t.length,this.v){var n=this.p.subarray(this.v-1),i=n.length>3?We(n):4;if(i>n.length){if(!r)return}else this.v>1&&this.onmember&&this.onmember(this.r-n.length);this.p=n.subarray(i),this.v=0}M.prototype.c.call(this,0),this.s.f&&!this.s.l?(this.v=Ne(this.s.p)+9,this.s={i:0},this.o=new x(0),this.push(new x(0),r)):r&&M.prototype.c.call(this,r)},e}(),Je=typeof TextDecoder<"u"&&new TextDecoder,et=0;try{Je.decode(Xe,{stream:!0}),et=1}catch{}const tt=65577,rt=16*1024*1024,ie=2*1024*1024,nt=256*1024,be=64*1024,Ae=512*1024,it=101010256,at=117853008,st=101075792,ot=33639248,ct=67324752,Z=4294967295,lt=65535;function _(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function R(e,t){return Number(e.getBigUint64(t,!0))}const ft={0:"stored",1:"shrunk",6:"imploded",8:"deflate",9:"deflate64",12:"bzip2",14:"lzma",93:"zstd",95:"xz",96:"jpeg",97:"wavpack",98:"ppmd",99:"aes"};function Ue(e){return ft[e]??`method ${e}`}function ht(e,t){const r=1980+(e>>9&127),n=e>>5&15,i=e&31;if(n===0||i===0)return"—";const s=t>>11&31,a=t>>5&63,o=(t&31)*2,f=l=>String(l).padStart(2,"0");return`${r}-${f(n)}-${f(i)} ${f(s)}:${f(a)}:${f(o)}`}function ut(e){if(!Number.isFinite(e)||e<=0)return"—";const t=new Date(e*1e3);return Number.isNaN(t.getTime())?"—":t.toISOString().slice(0,19).replace("T"," ")}function dt(e,t){return e<=0?"—":`${Math.round((1-t/e)*100)}%`}function pt(e){const t=_(e);let r=null,n=null;for(let d=e.byteLength-22;d>=0;d--){if(t.getUint32(d,!0)!==it)continue;const c=t.getUint16(d+20,!0);if(d+22+c===e.byteLength){n=d;break}r===null&&(r=d)}const i=n??r;if(i===null)throw new Error("No end-of-central-directory record in the last 64 KB — this is not a ZIP archive, or it is truncated.");const s=t.getUint16(i+10,!0),a=t.getUint32(i+12,!0),o=t.getUint32(i+16,!0),f=s===lt||a===Z||o===Z;let l=null;return i>=20&&t.getUint32(i-20,!0)===at&&(l=R(t,i-20+8)),{centralDirectoryOffset:o,centralDirectorySize:a,entryCount:s,zip64RecordOffset:l,needsZip64:f}}function gt(e){if(e.byteLength<56)throw new Error("The ZIP64 end record is truncated.");const t=_(e);if(t.getUint32(0,!0)!==st)throw new Error("The ZIP64 locator points at something that is not a ZIP64 end record.");return{entryCount:R(t,32),centralDirectorySize:R(t,40),centralDirectoryOffset:R(t,48)}}function vt(e,t){const r=_(e);for(let n=0;n+4<=e.byteLength;){const i=r.getUint16(n,!0),s=r.getUint16(n+2,!0),a=n+4;if(a+s>e.byteLength)break;if(i!==1){n=a+s;continue}let o=a;const f={...t};return f.uncompressedSize===Z&&o+8<=a+s&&(f.uncompressedSize=R(r,o),o+=8),f.compressedSize===Z&&o+8<=a+s&&(f.compressedSize=R(r,o),o+=8),f.localHeaderOffset===Z&&o+8<=a+s&&(f.localHeaderOffset=R(r,o)),f}return{...t}}function mt(e){return new TextDecoder().decode(e)}function xt(e){const t=_(e),r=[];let n=0,i=!1;for(;n+46<=e.byteLength;){if(t.getUint32(n,!0)!==ot){i=!0;break}const s=t.getUint16(n+8,!0),a=t.getUint16(n+10,!0),o=t.getUint16(n+12,!0),f=t.getUint16(n+14,!0),l=t.getUint16(n+28,!0),d=t.getUint16(n+30,!0),c=t.getUint16(n+32,!0),h=t.getUint32(n+38,!0),v=46+l+d+c;if(n+v>e.byteLength){i=!0;break}const m=vt(e.subarray(n+46+l,n+46+l+d),{uncompressedSize:t.getUint32(n+24,!0),compressedSize:t.getUint32(n+20,!0),localHeaderOffset:t.getUint32(n+42,!0)}),u=mt(e.subarray(n+46,n+46+l)),S=h>>>16&65535;r.push({path:u,directory:u.endsWith("/")||(S&61440)===16384,encrypted:(s&1)!==0,method:a,uncompressedSize:m.uncompressedSize,compressedSize:m.compressedSize,modified:ht(f,o),localHeaderOffset:m.localHeaderOffset}),n+=v}if(r.length===0)throw new Error("The central directory holds no readable entries — the archive looks corrupt.");return{entries:r,truncated:i||n<e.byteLength}}function L(e,t,r){const n=e.subarray(t,t+r),i=n.indexOf(0);return new TextDecoder().decode(i<0?n:n.subarray(0,i))}function U(e,t,r){const n=e[t];if(n===void 0)return null;if(n&128){let a=0;for(let o=1;o<r;o++)a=a*256+(e[t+o]??0);return a}let i="";for(let a=0;a<r;a++)i+=String.fromCharCode(e[t+a]??0);const s=i.replace(/\0/g," ").trim();return s===""?0:/^[0-7]+$/.test(s)?Number.parseInt(s,8):null}function zt(e,t){const r=U(e,t+148,8);if(r===null)return!1;let n=0,i=0;for(let s=0;s<512;s++){const a=s>=148&&s<156?32:e[t+s]??0;n+=a,i+=a>127?a-256:a}return r===n||r===i}function wt(e,t){for(let r=0;r<512;r++)if((e[t+r]??0)!==0)return!1;return!0}function bt(e,t){return e==="5"?"dir":e==="2"?"symlink":e==="1"?"hardlink":e==="0"||e==="\0"||e==="7"?t.endsWith("/")?"dir":"file":"other"}function yt(e){const t=new TextDecoder().decode(e),r=/(?:^|\n)\d+ path=([^\n]*)\n/.exec(t);return(r==null?void 0:r[1])??null}function Ce(e){const t=[];let r=0,n=null;for(;r+512<=e.byteLength;){if(wt(e,r))return{entries:t,truncated:!1};if(!zt(e,r)){if(t.length===0)throw new Error("This is not a TAR archive — the first block has no valid header checksum.");return{entries:t,truncated:!0}}const i=U(e,r+124,12)??0,s=U(e,r+136,12)??0,a=String.fromCharCode(e[r+156]??0),o=r+512,f=Math.ceil(i/512)*512,l=o+i<=e.byteLength;if(a==="L"||a==="x"||a==="g"){if(!l)return{entries:t,truncated:!0};const u=e.subarray(o,o+i);a==="L"?n=L(u,0,i):a==="x"&&(n=yt(u)),r=o+f;continue}const d=L(e,r,100),c=L(e,r+257,6).startsWith("ustar")?L(e,r+345,155):"",h=n??(c?`${c}/${d}`:d);n=null;const v=L(e,r+265,32)||String(U(e,r+108,8)??0),m=L(e,r+297,32)||String(U(e,r+116,8)??0);t.push({path:h,kind:bt(a,h),size:i,mode:(U(e,r+100,8)??0).toString(8).padStart(4,"0"),owner:`${v}/${m}`,modified:ut(s)}),r=o+f}return{entries:t,truncated:!0}}function kt(e,t){var n;if(/\.(tar\.bz2|tbz2?|bz2)$/i.test(e))return"bzip2";if(/\.(tar\.xz|txz|xz)$/i.test(e))return"xz";if(/\.(tar\.gz|tgz|gz)$/i.test(e))return"tar.gz";if(/\.tar$/i.test(e))return"tar";if(/\.(zip|jar|war|whl|xpi)$/i.test(e))return"zip";const r=((n=t==null?void 0:t.toLowerCase().split(";")[0])==null?void 0:n.trim())??"";return r==="application/zip"||r==="application/x-zip-compressed"?"zip":r==="application/x-tar"?"tar":r==="application/gzip"||r==="application/x-gzip"?"tar.gz":r==="application/x-bzip2"?"bzip2":r==="application/x-xz"?"xz":"unknown"}function Tt(e){const t=(...r)=>r.every((n,i)=>e[i]===n);return t(80,75)?"zip":t(31,139)?"tar.gz":t(66,90,104)?"bzip2":t(253,55,122,88,90)?"xz":e.byteLength>=512&&L(e,257,6).startsWith("ustar")?"tar":"unknown"}const Et=/\.(txt|md|markdown|json|ndjson|jsonl|csv|tsv|xml|ya?ml|toml|ini|cfg|conf|properties|log|sql|html?|css|scss|jsx?|mjs|cjs|tsx?|sh|bash|py|rb|go|rs|java|kt|kts|c|h|cpp|hpp|cs|php|pl|lua|gradle|env|lock|gitignore|dockerfile|mf|classpath|project)$/i,St=/^(readme|license|licence|notice|changelog|authors|copying|makefile|dockerfile|\.gitignore|\.npmrc|\.editorconfig)$/i;function Lt(e){const t=e.split("/").pop()??"";return Et.test(t)||St.test(t)}function Rt(e){return!e.directory&&!e.encrypted&&(e.method===0||e.method===8)&&e.uncompressedSize>0&&e.uncompressedSize<=Ae&&Lt(e.path)}async function N(e,t,r){if(e.size<=0)throw new Error("This object is empty.");const n=Math.max(0,Math.min(t,e.size-1)),i=Math.min(e.size-1,n+Math.max(1,r)-1);return Fe.objectRange(e.disk,e.key,n,i)}async function Nt(e){if(e.size<22)throw new Error("This file is too small to be a ZIP archive.");const t=Math.min(tt,e.size),r=e.size-t,n=await N(e,r,t);let i=n.byteLength;const s=pt(n);let{centralDirectoryOffset:a,centralDirectorySize:o,entryCount:f}=s,l=!1;if(s.zip64RecordOffset!==null){const v=s.zip64RecordOffset-r;let m;v>=0&&v+56<=n.byteLength?m=n.subarray(v,v+56):(m=await N(e,s.zip64RecordOffset,56),i+=m.byteLength);const u=gt(m);a=u.centralDirectoryOffset,o=u.centralDirectorySize,f=u.entryCount,l=!0}else if(s.needsZip64)throw new Error("This is a ZIP64 archive (over 4 GB or over 65,535 entries) whose ZIP64 locator is missing, so its central directory cannot be found.");if(a+o>e.size)throw new Error("The central directory points outside the file — the archive is truncated.");const d=Math.min(o,rt),c=await N(e,a,d);i+=c.byteLength;const h=xt(c);return{kind:"zip",entries:h.entries,declaredCount:f,zip64:l,truncated:h.truncated||d<o,bytesRead:i}}function jt(e){const t=[];let r=0;const n=new Qe(a=>{r>=ie||(t.push(a),r+=a.byteLength)});try{for(let a=0;a<e.byteLength&&r<ie;a+=be)n.push(e.subarray(a,a+be),!1)}catch(a){if(r===0)throw new Error(re(a,"Could not decompress this gzip stream."))}const i=new Uint8Array(r);let s=0;for(const a of t)i.set(a,s),s+=a.byteLength;return i}function At(e,t){try{return Ce(e)}catch{throw new Error(t)}}async function ye(e,t){const n=Math.min(t?nt:ie,e.size),i=await N(e,0,n),s=t?jt(i):i,a=t?At(s,"This gzip stream does not contain a TAR archive."):Ce(s);return{kind:"tar",entries:a.entries,compression:t?"gzip":"none",sampled:a.truncated||i.byteLength<e.size,bytesRead:i.byteLength}}async function Ut(e){let t=kt(e.name,e.contentType);switch(t==="unknown"&&(t=Tt(await N(e,0,512))),t){case"zip":return Nt(e);case"tar":return ye(e,!1);case"tar.gz":return ye(e,!0);case"bzip2":case"xz":return{kind:"unsupported",message:`This is a ${t==="bzip2"?"bzip2":"xz"}-compressed archive. Only its compressed bytes are here, and ${t==="bzip2"?"bzip2":"xz"} cannot be decompressed in the browser, so its contents cannot be listed inline.`};case"unknown":return{kind:"unsupported",message:"This file is not a ZIP, TAR or gzip archive."}}}async function Ct(e,t){const r=await N(e,t.localHeaderOffset,30);if(r.byteLength<30||_(r).getUint32(0,!0)!==ct)throw new Error("This entry does not start with a local file header — the archive is corrupt.");if(t.compressedSize<=0)return{text:"",binary:!1,bytesRead:r.byteLength};const n=_(r),i=t.localHeaderOffset+30+n.getUint16(26,!0)+n.getUint16(28,!0),s=await N(e,i,t.compressedSize),a=t.method===0?s:Ve(s),o=new TextDecoder().decode(a.subarray(0,Ae));return{text:o,binary:o.includes("\0"),bytesRead:r.byteLength+s.byteLength}}function _t(e){return{header:["path","kind","size","compressed","ratio","method","modified"],body:e.map(t=>[t.path,t.directory?"dir":t.encrypted?"file (encrypted)":"file",t.directory?"—":z(t.uncompressedSize),t.directory?"—":z(t.compressedSize),t.directory?"—":dt(t.uncompressedSize,t.compressedSize),t.directory?"—":Ue(t.method),t.modified])}}function It(e){return{header:["path","kind","size","mode","owner","modified"],body:e.map(t=>[t.path,t.kind,t.kind==="dir"?"—":z(t.size),t.mode,t.owner,t.modified])}}function Ot({item:e}){var m;const[t,r]=ve.useState(null),[n,i]=ve.useState(""),s=me({queryKey:["archive-listing",e.disk,e.key],queryFn:()=>Ut(e),retry:!1,staleTime:6e4}),o=(((m=s.data)==null?void 0:m.kind)==="zip"?s.data.entries:[]).find(u=>u.path===t)??null,f=me({queryKey:["archive-entry",e.disk,e.key,t],queryFn:()=>{if(!o)throw new Error("No entry selected.");return Ct(e,o)},enabled:o!==null,retry:!1,staleTime:6e4});if(s.isLoading)return p.jsx(J,{children:"Reading archive…"});if(s.isError||!s.data)return p.jsx(xe,{item:e,message:re(s.error,"Could not read this archive.")});const l=s.data;if(l.kind==="unsupported")return p.jsx(xe,{item:e,message:l.message});if(l.kind==="tar"){const u=It(l.entries);return p.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2",children:[l.sampled&&p.jsxs(O,{variant:"warn",className:"shrink-0",children:["Sample — a TAR has no index, so this is what fits in the first"," ",z(l.bytesRead)," of ",z(e.size),l.compression==="gzip"?", gunzipped from the start of the stream":"",". Filters and sort apply to these ",l.entries.length," ",l.entries.length===1?"entry":"entries","; open the original ↗ for the whole archive."]}),l.entries.length===0?p.jsx(J,{children:"No entries in the sample."}):p.jsx(ze,{header:u.header,body:u.body}),p.jsxs("div",{className:"mono tnum shrink-0 text-[10px] text-zinc-600",children:[l.entries.length," ",l.entries.length===1?"entry":"entries"," · read"," ",z(l.bytesRead)," of ",z(e.size),l.compression==="gzip"&&" · gunzipped"]})]})}const d=l.entries.filter(Rt),c=n.trim().toLowerCase(),h=(c?d.filter(u=>u.path.toLowerCase().includes(c)):d).slice(0,300),v=_t(l.entries);return p.jsxs("div",{className:"flex min-h-0 flex-1 gap-3",children:[d.length>0&&p.jsxs("div",{className:"flex w-56 shrink-0 flex-col gap-1 overflow-auto",children:[p.jsx("div",{className:"shrink-0 text-[10px] uppercase tracking-wide text-zinc-500",children:"Readable entries"}),p.jsx(Ze,{value:n,onChange:u=>i(u.target.value),placeholder:"find an entry…",className:"shrink-0"}),h.map(u=>p.jsx(we,{tone:u.path===t?"selected":"quiet",title:`${u.path} · ${z(u.uncompressedSize)}`,className:"justify-start px-2 py-0.5 text-left",onClick:()=>r(u.path===t?null:u.path),children:p.jsx("span",{className:"truncate",children:u.path.split("/").pop()||u.path})},u.path)),h.length<d.length&&p.jsxs("div",{className:"mono shrink-0 px-2 text-[10px] text-zinc-600",children:[d.length-h.length," more — narrow the filter"]})]}),p.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-2",children:[l.zip64&&p.jsx(O,{variant:"warn",className:"shrink-0",children:"ZIP64 archive — over 4 GB or over 65,535 entries. Its 64-bit directory was read in full."}),l.truncated&&p.jsxs(O,{variant:"warn",className:"shrink-0",children:["Partial listing — the central directory was cut short after ",l.entries.length," of"," ",l.declaredCount," entries."]}),o?p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[p.jsx(we,{tone:"ghost",onClick:()=>r(null),children:"← Listing"}),p.jsx("span",{className:"mono truncate text-[11px] text-zinc-400",children:o.path})]}),f.isLoading&&p.jsx(J,{children:"Extracting…"}),f.isError&&p.jsx(O,{variant:"error",children:re(f.error,"Could not extract this entry.")}),f.data&&(f.data.binary?p.jsx(O,{variant:"warn",children:"This entry is binary despite its name — showing it as text would be noise."}):p.jsx("pre",{className:"mono min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-words rounded-md border border-border bg-black/30 p-3 text-xs text-zinc-300",children:f.data.text})),f.data&&p.jsxs("div",{className:"mono tnum shrink-0 text-[10px] text-zinc-600",children:["read ",z(f.data.bytesRead)," of ",z(e.size)," ·"," ",Ue(o.method)," ·"," ",z(o.uncompressedSize)," uncompressed"]})]}):p.jsxs(p.Fragment,{children:[p.jsx(ze,{header:v.header,body:v.body}),p.jsxs("div",{className:"mono tnum shrink-0 text-[10px] text-zinc-600",children:[l.entries.length," ",l.entries.length===1?"entry":"entries"," · read"," ",z(l.bytesRead)," of ",z(e.size),d.length>0&&" · pick an entry on the left to read it"]})]})]})]})}export{Ot as ArchivePreview,kt as archiveFormat,Ct as extractZipEntry,ht as formatDosDateTime,ut as formatEpochSeconds,dt as formatRatio,jt as gunzipSample,Rt as isExtractable,Lt as isTextEntryPath,Ce as parseTarEntries,gt as parseZip64EndRecord,xt as parseZipCentralDirectory,pt as scanZipTail,Tt as sniffArchiveFormat,Ue as zipMethodName};