severo HF Staff commited on
Commit
969d910
·
verified ·
1 Parent(s): d8f9b91

Upload folder using huggingface_hub

Browse files
assets/{index-C5iognDl.js → index-CniqBhKv.js} RENAMED
@@ -45,5 +45,5 @@ ${e.map(t=>Op(Gi(t),2)).join(`,
45
  `)}function Mp(e){return(e==null?void 0:e.fileSize)!==void 0?Dp(e.fileSize):""}function Dp(e){const t=["b","kb","mb","gb","tb"];if(e===0)return"0 b";const n=Math.floor(Math.log2(e)/10);if(n===0)return e.toLocaleString("en-US")+" b";const r=e/Math.pow(1024,n);return(r<10?r.toFixed(1):Math.round(r)).toLocaleString("en-US")+" "+t[n]}function Up(e){const t=e.get("content-length");return t?Number(t):void 0}const $p={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",svg:"image/svg+xml"},Ap=[".png",".jpg",".jpeg",".gif",".svg"];function Rl({content:e,headers:t,children:n}){return E.jsxs("div",{className:"viewer",children:[E.jsxs("div",{className:"view-header",children:[(e==null?void 0:e.fileSize)&&E.jsx("span",{title:e.fileSize.toLocaleString("en-US")+" bytes",children:Mp(e)}),t]}),n]})}function Fp({file:e,setError:t}){const[n,r]=I.useState(0),[l,i]=I.useState();return I.useEffect(()=>{const u=e.startsWith("http://")||e.startsWith("https://")?e:"/api/store/get?key="+e;async function s(){try{const a=await fetch(u),m=await a.arrayBuffer(),h=Bp(m),p=`data:${Wp(u)};base64,${h}`,v=Up(a.headers);i({dataUri:p,fileSize:v})}catch(a){t(a)}finally{r(2)}}r(a=>a!==0?a:(s().catch(()=>{}),1))},[e,n,t]),E.jsx(Rl,{content:l,children:(l==null?void 0:l.dataUri)&&E.jsx("img",{alt:e,className:"image",src:l.dataUri})})}function Bp(e){let t="";const n=new Uint8Array(e);for(let r=0;r<n.byteLength;r++)t+=String.fromCharCode(n[r]);return btoa(t)}function Wp(e){const t=e.split(".").pop()??"";return $p[t]||"image/png"}function Vp({text:e,className:t}){function n(r){const l=[],i=r.split(`
46
  `);let o=!1,u=[],s=!1,a=[];for(let m=0;m<i.length;m++){const h=i[m];if(h.startsWith("```")){o?(l.push(E.jsx("pre",{children:u.join(`
47
  `)},`code-${m.toLocaleString("en-US")}`)),o=!1,u=[]):o=!0;continue}if(o){u.push(h);continue}if(h.includes("**")){const v=h.split("**");l.push(E.jsx("p",{children:v.map((y,w)=>w%2?E.jsx("strong",{children:y},w):y)},m));continue}if(h.includes("*")){const v=h.split("*");l.push(E.jsx("p",{children:v.map((y,w)=>w%2?E.jsx("em",{children:y},w):y)},m));continue}if(h.startsWith("#")){const v=h.split(" ")[0].length,y=h.slice(v+1),w=`h${v.toLocaleString("en-US")}`;l.push(E.jsx(w,{children:y},m));continue}const p=/!\[(.*?)\]\((.*?)\)/.exec(h);if(p){const[,v,y]=p;l.push(E.jsx("img",{src:y,alt:v},m));continue}if(h.includes("[")&&h.includes("]")&&h.includes("(")&&h.includes(")")){const v=h.replace(/\[(.*?)\]\((.*?)\)/g,(y,w,j)=>`<a href="${j}" target="_blank" rel="noreferrer">${w}</a>`);l.push(E.jsx("p",{dangerouslySetInnerHTML:{__html:v}},m));continue}if(h.startsWith("-")||h.startsWith("*")||h.startsWith("+")){const v=h.slice(1).trim();a.push(E.jsx("li",{children:v},`list-item-${m.toLocaleString("en-US")}`)),s=!0;continue}s&&a.length>0&&(l.push(E.jsx("ul",{children:a},`list-${m.toLocaleString("en-US")}`)),a=[],s=!1),l.push(E.jsx("p",{children:h},m))}return o&&u.length>0&&l.push(E.jsx("pre",{children:u.join(`
48
- `)},`code-${i.length.toLocaleString("en-US")}`)),s&&a.length>0&&l.push(E.jsx("ul",{children:a},`list-${i.length.toLocaleString("en-US")}`)),E.jsx("div",{className:t,children:l})}return n(e)}function Hp({file:e,setError:t}){const[n,r]=I.useState(0),[l,i]=I.useState();return I.useEffect(()=>{const u=e.startsWith("http://")||e.startsWith("https://")?e:"/api/store/get?key="+e;async function s(){try{const m=await(await fetch(u)).text();i(m)}catch(a){t(a)}finally{r(2)}}r(a=>a!==0?a:(s().catch(()=>{}),1))},[e,n,t]),E.jsx(Rl,{content:{fileSize:l==null?void 0:l.length},children:E.jsx(Vp,{className:"markdown",text:l??""})})}var cs,fs,ds={exports:{}},Pn={},K=(fs||(fs=1,ds.exports=function(){if(cs)return Pn;cs=1;var e=bc,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,l=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(u,s,a){var m,h={},p=null,v=null;for(m in a!==void 0&&(p=""+a),s.key!==void 0&&(p=""+s.key),s.ref!==void 0&&(v=s.ref),s)r.call(s,m)&&!i.hasOwnProperty(m)&&(h[m]=s[m]);if(u&&u.defaultProps)for(m in s=u.defaultProps)h[m]===void 0&&(h[m]=s[m]);return{$$typeof:t,type:u,key:p,ref:v,props:h,_owner:l.current}}return Pn.Fragment=n,Pn.jsx=o,Pn.jsxs=o,Pn}()),ds.exports);function Zi(e,t,n){if(Array.isArray(e))return e;const r=new Array(t).fill(null).map(l=>Object.fromEntries(n.map(i=>[i,Yp()])));return(e instanceof Promise?e:Promise.resolve(e)).then(l=>{l.length!==t&&console.warn(`Expected ${t} rows, got ${l.length}`);for(let i=0;i<l.length;i++){const o=l[i];for(const u of n)r[i][u].resolve(o[u])}}).catch(l=>{for(let i=0;i<t;i++)for(const o of n)r[i][o].reject(l)}),r}function Qp(e){e instanceof Promise||(e=Promise.resolve(e));const t=e.then(n=>(t.resolved=n,n)).catch(n=>{throw t.rejected=n,n});return t}function Yp(){let e,t;const n=Qp(new Promise((r,l)=>{e=r,t=l}));return n.resolve=e,n.reject=t,n}const Kp=10;function Xp({header:e,columnWidths:t,orderBy:n,setColumnWidth:r,setColumnWidths:l,setOrderBy:i,dataReady:o}){const[u,s]=I.useState(),a=I.useRef(e.map(()=>I.createRef()));function m(p){return p.current?p.current.offsetWidth-2*Kp:void 0}I.useEffect(()=>{if(o){const p=a.current.map(m);l(p)}},[o,e]),I.useEffect(()=>{function p(){u&&s(void 0)}function v({clientX:y}){u&&r(u.columnIndex,Math.max(1,y-u.clientX))}return u&&(window.addEventListener("mousemove",v),window.addEventListener("mouseup",p)),()=>{window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",p)}},[e,u,l]);const h=I.useMemo(()=>t.map(Ji),[t]);return K.jsx("thead",{children:K.jsxs("tr",{children:[K.jsx("th",{children:K.jsx("span",{})}),e.map((p,v)=>K.jsxs("th",{className:n===p?"orderby":void 0,onClick:()=>function(y){i==null||i(n===y?void 0:y)}(p),ref:a.current[v],style:h[v],title:p,children:[p,K.jsx("span",{onDoubleClick:()=>function(y){Cc.flushSync(()=>{r(y,void 0)});const w=m(a.current[y]);r(y,w)}(v),onMouseDown:y=>function(w,j){j.stopPropagation(),s({columnIndex:w,clientX:j.clientX-(t[w]||0)})}(v,y)})]},v))]})})}function Ji(e){const t=e?`${e}px`:void 0;return{minWidth:t,maxWidth:t}}function Gp(e){const t={};return{...e,rows(n,r,l){var u;const i=t[u=l||""]||(t[u]=new Array(e.numRows));let o;for(let s=n;s<r;s++)if(i[s]){if(o!==void 0){const a=s,m=a-o,h=Zi(e.rows(o,a,l),m,e.header);for(let p=0;p<a-o;p++)i[o+p]=h[p];o=void 0}}else o===void 0&&(o=s);if(o!==void 0){const s=r,a=s-o,m=Zi(e.rows(o,s,l),a,e.header);for(let h=0;h<s-o;h++)i[o+h]=m[h]}return i.slice(n,r)}}}function Zp(e,t){switch(t.type){case"SET_ROWS":return{...e,startIndex:t.start,rows:t.rows,dataReady:e.dataReady||t.hasCompleteRow};case"SET_COLUMN_WIDTH":{const n=[...e.columnWidths];return n[t.columnIndex]=t.columnWidth,{...e,columnWidths:n}}case"SET_COLUMN_WIDTHS":return{...e,columnWidths:t.columnWidths};case"SET_ORDER":return{...e,orderBy:t.orderBy};case"SET_PENDING":return{...e,pending:t.pending};case"DATA_CHANGED":return{...e,dataReady:!1};default:return e}}const Jp={columnWidths:[],startIndex:0,rows:[],dataReady:!1,pending:!1};function qp({data:e,overscan:t=20,onDoubleClickCell:n,onError:r=console.error}){const[l,i]=I.useReducer(Zp,Jp),{columnWidths:o,startIndex:u,rows:s,orderBy:a,dataReady:m,pending:h}=l,p=I.useRef(0),v=I.useRef(null),y=I.useRef(null),w=I.useRef(!1),j=I.useRef(!1);if(!e)throw new Error("HighTable: data is required");const c=33*(e.numRows+1);function f(T,P){if(T.length>0&&T.length!==e.header.length)return`Row ${P+1} length ${T.length} does not match header length ${e.header.length}`}I.useEffect(()=>{async function T(){var k,R,z;const le=((k=v.current)==null?void 0:k.clientHeight)||100,we=((R=v.current)==null?void 0:R.scrollTop)||0,Oe=((z=y.current)==null?void 0:z.clientHeight)||0;let pe=Math.floor(e.numRows*we/c),Se=Math.ceil(e.numRows*(we+le)/c);if(pe=Math.max(0,pe-t),Se=Math.min(e.numRows,Se+t),isNaN(pe))throw new Error("invalid start row "+pe);if(isNaN(Se))throw new Error("invalid end row "+Se);const Ve=Math.max(0,we-660);if((!(c-Ve-Oe<33*t)&&Ve+Oe-le<we||we<Ve)&&i({type:"SET_ROWS",start:pe,rows:Array.from({length:Se-pe},()=>({})),hasCompleteRow:!1}),w.current)j.current=!0;else try{let Y=function(){const Me=[];let _e=!1;for(const Nt of U){const He={};let Lt=!0;for(const[Dc,Zo]of Object.entries(Nt))"resolved"in Zo?He[Dc]=Zo.resolved:Lt=!1;Lt&&(_e=!0),Me.push(He)}p.current=Ve,i({type:"SET_ROWS",start:pe,rows:Me,hasCompleteRow:_e})};var Wt=Y;w.current=!0;const U=Zi(e.rows(pe,Se,a),Se-pe,e.header);for(const Me of U)for(const[_e,Nt]of Object.entries(Me))Nt.then(Y).catch(()=>{});for(const Me of U)for(const _e of Object.values(Me))await _e;w.current=!1,j.current&&(j.current=!1,T())}catch(U){i({type:"SET_PENDING",pending:!1}),w.current=!1,r(U)}}T();const P=v.current;return P==null||P.addEventListener("scroll",T),window.addEventListener("resize",T),()=>{P==null||P.removeEventListener("scroll",T),window.removeEventListener("resize",T)}},[e,a,c,r]);const d=I.useMemo(()=>o.map(Ji),[o]);I.useEffect(()=>{var T;(T=y.current)==null||T.focus()},[]),I.useEffect(()=>{i({type:"DATA_CHANGED"})},[e]);const g=I.useCallback(T=>s[T].__index__??T+u+1,[s,u]);if(!e.header.length)return;const _=Array.from({length:Math.min(20,u)},()=>[]),N=Array.from({length:Math.min(20,e.numRows-u-s.length)},()=>[]),x=4*Math.ceil(Math.log10(e.numRows+1))+22,L=I.useMemo(()=>Ji(x),[x]);return K.jsxs("div",{className:h?"table-container pending":"table-container",children:[K.jsx("div",{className:"table-scroll",ref:v,children:K.jsx("div",{style:{height:`${c}px`},children:K.jsxs("table",{"aria-colcount":e.header.length,"aria-rowcount":e.numRows,className:e.sortable?"table sortable":"table",ref:y,role:"grid",style:{top:`${p.current}px`},tabIndex:0,children:[K.jsx(Xp,{columnWidths:o,orderBy:a,setColumnWidth:(T,P)=>i({type:"SET_COLUMN_WIDTH",columnIndex:T,columnWidth:P}),setColumnWidths:T=>i({type:"SET_COLUMN_WIDTHS",columnWidths:T}),setOrderBy:T=>e.sortable&&i({type:"SET_ORDER",orderBy:T}),dataReady:m,header:e.header}),K.jsxs("tbody",{children:[_.map((T,P)=>K.jsx("tr",{children:K.jsx("td",{style:L,children:(u-_.length+P+1).toLocaleString()})},u-_.length+P)),s.map((T,P)=>K.jsxs("tr",{title:f(T,P),children:[K.jsx("td",{style:L,children:g(P).toLocaleString()}),e.header.map((le,we)=>{var Oe;return function(pe,Se,Ve,Wt){let k,R=qi(pe);return typeof R=="string"&&(R.length>400&&(R=`${R.slice(0,397)}…`),R.length>100&&(k=R)),K.jsx("td",{onDoubleClick:()=>n==null?void 0:n(Se,Wt??Ve),style:d[Se],title:k,children:R},Se)}(T[le],we,u+P,(Oe=T.__index__)==null?void 0:Oe.resolved)})]},u+P)),N.map((T,P)=>K.jsx("tr",{children:K.jsx("td",{style:L,children:(u+s.length+P+1).toLocaleString()})},u+s.length+P))]})]})})}),K.jsx("div",{className:"table-corner",style:L,children:" "}),K.jsx("div",{className:"mock-row-label",style:L,children:" "})]})}function qi(e){return typeof e=="string"?e:typeof e=="number"?e.toLocaleString():Array.isArray(e)?`[${e.map(qi).join(", ")}]`:e==null?JSON.stringify(e):e instanceof Date?e.toISOString():typeof e=="object"?`{${Object.entries(e).map(([t,n])=>`${t}: ${qi(n)}`).join(", ")}}`:e.toString()}function bp({file:e,setProgress:t,setError:n}){const[r,l]=I.useState(0),[i,o]=I.useState();I.useEffect(()=>{const m=e.startsWith("http://")||e.startsWith("https://")?e:"/api/store/get?key="+e;async function h(){try{t(.33);const p=await Ic(m),v={url:m,byteLength:p.byteLength};t(.66);const y=await Tc(p);let w=zc(v,y);w=Gp(w);const j=p.byteLength;o({dataframe:w,fileSize:j})}catch(p){n(p)}finally{l(2),t(1)}}r===0&&(l(1),h().catch(()=>{}))},[r,e,n,t]);const u=(a,m)=>{Oc(`?key=${e}&row=${m.toString()}&col=${a.toString()}`)},s=E.jsx(E.Fragment,{children:(i==null?void 0:i.dataframe)&&E.jsxs("span",{children:[i.dataframe.numRows.toLocaleString("en-US")," rows"]})});return E.jsxs(Rl,{content:i,headers:s,children:[(i==null?void 0:i.dataframe)&&E.jsx(qp,{data:i.dataframe,onDoubleClickCell:u,onError:n}),r&&E.jsx(jc,{className:"center"})]})}function eh({file:e,setError:t}){const[n,r]=I.useState(0),[l,i]=I.useState(),o=I.useRef(null);I.useEffect(()=>{const a=e.startsWith("http://")||e.startsWith("https://")?e:"/api/store/get?key="+e;async function m(){try{const p=await(await fetch(a)).text();i(p)}catch(h){t(h)}finally{r(2)}}r(h=>h!==0?h:(m().catch(()=>{}),1))},[e,n,t]);const u=E.jsx(E.Fragment,{children:E.jsxs("span",{children:[l?th(l):0," lines"]})});return E.jsxs(Rl,{content:{fileSize:l==null?void 0:l.length},headers:u,children:[E.jsx("code",{className:"text",ref:o,children:l}),n&&E.jsx(jc,{className:"center"})]})}function th(e){let t=0;for(const n of e)n===`
49
  `&&t++;return t.toLocaleString("en-US")}function nh({file:e,setError:t,setProgress:n}){const r=e.replace(/\?.*$/,"");return r.endsWith(".md")?E.jsx(Hp,{file:e,setError:t}):r.endsWith(".parquet")?E.jsx(bp,{file:e,setError:t,setProgress:n}):Ap.some(l=>r.endsWith(l))?E.jsx(Fp,{file:e,setError:t}):E.jsx(eh,{file:e,setError:t,setProgress:n})}function rh({url:e}){const[t,n]=I.useState(),[r,l]=I.useState(),i=e.kind==="file"?e.resolveUrl:e.raw,o=i.split("/");if(o.length<1)throw new Error("Invalid URL path");const u=o.at(-1);return E.jsxs(dl,{progress:t,error:r,title:u,children:[E.jsx(Go,{url:e}),E.jsx(nh,{file:i,setProgress:n,setError:l})]})}function lh(){const e=new URLSearchParams(location.search),t=e.get("url")??"https://huggingface.co/datasets/codeparrot/github-code/resolve/main/data/train-00000-of-01126.parquet";if(Array.isArray(t))throw new Error("url must be a string");try{const n=Tp(t);return n.kind==="base"||n.kind==="repo"||n.kind==="folder"?E.jsxs(dl,{title:n.kind,children:[E.jsx(Go,{url:n}),E.jsx("div",{className:"error",children:"Not implemented yet"}),E.jsx("pre",{children:JSON.stringify(n,null,2)})]}):e.has("col")&&e.has("row")?E.jsx(jp,{url:n,row:Number(e.get("row")),col:Number(e.get("col"))}):E.jsx(rh,{url:n})}catch(n){return E.jsx(dl,{error:n,title:"Error",children:E.jsx("div",{className:"error",children:n.message})})}}const Mc=document.getElementById("app");if(!Mc)throw new Error("No root element");Nc(Mc).render(E.jsx(I.StrictMode,{children:E.jsx(lh,{})}));
 
45
  `)}function Mp(e){return(e==null?void 0:e.fileSize)!==void 0?Dp(e.fileSize):""}function Dp(e){const t=["b","kb","mb","gb","tb"];if(e===0)return"0 b";const n=Math.floor(Math.log2(e)/10);if(n===0)return e.toLocaleString("en-US")+" b";const r=e/Math.pow(1024,n);return(r<10?r.toFixed(1):Math.round(r)).toLocaleString("en-US")+" "+t[n]}function Up(e){const t=e.get("content-length");return t?Number(t):void 0}const $p={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",svg:"image/svg+xml"},Ap=[".png",".jpg",".jpeg",".gif",".svg"];function Rl({content:e,headers:t,children:n}){return E.jsxs("div",{className:"viewer",children:[E.jsxs("div",{className:"view-header",children:[(e==null?void 0:e.fileSize)&&E.jsx("span",{title:e.fileSize.toLocaleString("en-US")+" bytes",children:Mp(e)}),t]}),n]})}function Fp({file:e,setError:t}){const[n,r]=I.useState(0),[l,i]=I.useState();return I.useEffect(()=>{const u=e.startsWith("http://")||e.startsWith("https://")?e:"/api/store/get?key="+e;async function s(){try{const a=await fetch(u),m=await a.arrayBuffer(),h=Bp(m),p=`data:${Wp(u)};base64,${h}`,v=Up(a.headers);i({dataUri:p,fileSize:v})}catch(a){t(a)}finally{r(2)}}r(a=>a!==0?a:(s().catch(()=>{}),1))},[e,n,t]),E.jsx(Rl,{content:l,children:(l==null?void 0:l.dataUri)&&E.jsx("img",{alt:e,className:"image",src:l.dataUri})})}function Bp(e){let t="";const n=new Uint8Array(e);for(let r=0;r<n.byteLength;r++)t+=String.fromCharCode(n[r]);return btoa(t)}function Wp(e){const t=e.split(".").pop()??"";return $p[t]||"image/png"}function Vp({text:e,className:t}){function n(r){const l=[],i=r.split(`
46
  `);let o=!1,u=[],s=!1,a=[];for(let m=0;m<i.length;m++){const h=i[m];if(h.startsWith("```")){o?(l.push(E.jsx("pre",{children:u.join(`
47
  `)},`code-${m.toLocaleString("en-US")}`)),o=!1,u=[]):o=!0;continue}if(o){u.push(h);continue}if(h.includes("**")){const v=h.split("**");l.push(E.jsx("p",{children:v.map((y,w)=>w%2?E.jsx("strong",{children:y},w):y)},m));continue}if(h.includes("*")){const v=h.split("*");l.push(E.jsx("p",{children:v.map((y,w)=>w%2?E.jsx("em",{children:y},w):y)},m));continue}if(h.startsWith("#")){const v=h.split(" ")[0].length,y=h.slice(v+1),w=`h${v.toLocaleString("en-US")}`;l.push(E.jsx(w,{children:y},m));continue}const p=/!\[(.*?)\]\((.*?)\)/.exec(h);if(p){const[,v,y]=p;l.push(E.jsx("img",{src:y,alt:v},m));continue}if(h.includes("[")&&h.includes("]")&&h.includes("(")&&h.includes(")")){const v=h.replace(/\[(.*?)\]\((.*?)\)/g,(y,w,j)=>`<a href="${j}" target="_blank" rel="noreferrer">${w}</a>`);l.push(E.jsx("p",{dangerouslySetInnerHTML:{__html:v}},m));continue}if(h.startsWith("-")||h.startsWith("*")||h.startsWith("+")){const v=h.slice(1).trim();a.push(E.jsx("li",{children:v},`list-item-${m.toLocaleString("en-US")}`)),s=!0;continue}s&&a.length>0&&(l.push(E.jsx("ul",{children:a},`list-${m.toLocaleString("en-US")}`)),a=[],s=!1),l.push(E.jsx("p",{children:h},m))}return o&&u.length>0&&l.push(E.jsx("pre",{children:u.join(`
48
+ `)},`code-${i.length.toLocaleString("en-US")}`)),s&&a.length>0&&l.push(E.jsx("ul",{children:a},`list-${i.length.toLocaleString("en-US")}`)),E.jsx("div",{className:t,children:l})}return n(e)}function Hp({file:e,setError:t}){const[n,r]=I.useState(0),[l,i]=I.useState();return I.useEffect(()=>{const u=e.startsWith("http://")||e.startsWith("https://")?e:"/api/store/get?key="+e;async function s(){try{const m=await(await fetch(u)).text();i(m)}catch(a){t(a)}finally{r(2)}}r(a=>a!==0?a:(s().catch(()=>{}),1))},[e,n,t]),E.jsx(Rl,{content:{fileSize:l==null?void 0:l.length},children:E.jsx(Vp,{className:"markdown",text:l??""})})}var cs,fs,ds={exports:{}},Pn={},K=(fs||(fs=1,ds.exports=function(){if(cs)return Pn;cs=1;var e=bc,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,l=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(u,s,a){var m,h={},p=null,v=null;for(m in a!==void 0&&(p=""+a),s.key!==void 0&&(p=""+s.key),s.ref!==void 0&&(v=s.ref),s)r.call(s,m)&&!i.hasOwnProperty(m)&&(h[m]=s[m]);if(u&&u.defaultProps)for(m in s=u.defaultProps)h[m]===void 0&&(h[m]=s[m]);return{$$typeof:t,type:u,key:p,ref:v,props:h,_owner:l.current}}return Pn.Fragment=n,Pn.jsx=o,Pn.jsxs=o,Pn}()),ds.exports);function Zi(e,t,n){if(Array.isArray(e))return e;const r=new Array(t).fill(null).map(l=>Object.fromEntries(n.map(i=>[i,Yp()])));return(e instanceof Promise?e:Promise.resolve(e)).then(l=>{l.length!==t&&console.warn(`Expected ${t} rows, got ${l.length}`);for(let i=0;i<l.length;i++){const o=l[i];for(const u of n)r[i][u].resolve(o[u])}}).catch(l=>{for(let i=0;i<t;i++)for(const o of n)r[i][o].reject(l)}),r}function Qp(e){e instanceof Promise||(e=Promise.resolve(e));const t=e.then(n=>(t.resolved=n,n)).catch(n=>{throw t.rejected=n,n});return t}function Yp(){let e,t;const n=Qp(new Promise((r,l)=>{e=r,t=l}));return n.resolve=e,n.reject=t,n}const Kp=10;function Xp({header:e,columnWidths:t,orderBy:n,setColumnWidth:r,setColumnWidths:l,setOrderBy:i,dataReady:o}){const[u,s]=I.useState(),a=I.useRef(e.map(()=>I.createRef()));function m(p){return p.current?p.current.offsetWidth-2*Kp:void 0}I.useEffect(()=>{if(o){const p=a.current.map(m);l(p)}},[o,e]),I.useEffect(()=>{function p(){u&&s(void 0)}function v({clientX:y}){u&&r(u.columnIndex,Math.max(1,y-u.clientX))}return u&&(window.addEventListener("mousemove",v),window.addEventListener("mouseup",p)),()=>{window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",p)}},[e,u,l]);const h=I.useMemo(()=>t.map(Ji),[t]);return K.jsx("thead",{children:K.jsxs("tr",{children:[K.jsx("th",{children:K.jsx("span",{})}),e.map((p,v)=>K.jsxs("th",{className:n===p?"orderby":void 0,onClick:()=>function(y){i==null||i(n===y?void 0:y)}(p),ref:a.current[v],style:h[v],title:p,children:[p,K.jsx("span",{onDoubleClick:()=>function(y){Cc.flushSync(()=>{r(y,void 0)});const w=m(a.current[y]);r(y,w)}(v),onMouseDown:y=>function(w,j){j.stopPropagation(),s({columnIndex:w,clientX:j.clientX-(t[w]||0)})}(v,y)})]},v))]})})}function Ji(e){const t=e?`${e}px`:void 0;return{minWidth:t,maxWidth:t}}function Gp(e){const t={};return{...e,rows(n,r,l){var u;const i=t[u=l||""]||(t[u]=new Array(e.numRows));let o;for(let s=n;s<r;s++)if(i[s]){if(o!==void 0){const a=s,m=a-o,h=Zi(e.rows(o,a,l),m,e.header);for(let p=0;p<a-o;p++)i[o+p]=h[p];o=void 0}}else o===void 0&&(o=s);if(o!==void 0){const s=r,a=s-o,m=Zi(e.rows(o,s,l),a,e.header);for(let h=0;h<s-o;h++)i[o+h]=m[h]}return i.slice(n,r)}}}function Zp(e,t){switch(t.type){case"SET_ROWS":return{...e,startIndex:t.start,rows:t.rows,dataReady:e.dataReady||t.hasCompleteRow};case"SET_COLUMN_WIDTH":{const n=[...e.columnWidths];return n[t.columnIndex]=t.columnWidth,{...e,columnWidths:n}}case"SET_COLUMN_WIDTHS":return{...e,columnWidths:t.columnWidths};case"SET_ORDER":return{...e,orderBy:t.orderBy};case"SET_PENDING":return{...e,pending:t.pending};case"DATA_CHANGED":return{...e,dataReady:!1};default:return e}}const Jp={columnWidths:[],startIndex:0,rows:[],dataReady:!1,pending:!1};function qp({data:e,overscan:t=20,onDoubleClickCell:n,onError:r=console.error}){const[l,i]=I.useReducer(Zp,Jp),{columnWidths:o,startIndex:u,rows:s,orderBy:a,dataReady:m,pending:h}=l,p=I.useRef(0),v=I.useRef(null),y=I.useRef(null),w=I.useRef(!1),j=I.useRef(!1);if(!e)throw new Error("HighTable: data is required");const c=33*(e.numRows+1);function f(T,P){if(T.length>0&&T.length!==e.header.length)return`Row ${P+1} length ${T.length} does not match header length ${e.header.length}`}I.useEffect(()=>{async function T(){var k,R,z;const le=((k=v.current)==null?void 0:k.clientHeight)||100,we=((R=v.current)==null?void 0:R.scrollTop)||0,Oe=((z=y.current)==null?void 0:z.clientHeight)||0;let pe=Math.floor(e.numRows*we/c),Se=Math.ceil(e.numRows*(we+le)/c);if(pe=Math.max(0,pe-t),Se=Math.min(e.numRows,Se+t),isNaN(pe))throw new Error("invalid start row "+pe);if(isNaN(Se))throw new Error("invalid end row "+Se);const Ve=Math.max(0,we-660);if((!(c-Ve-Oe<33*t)&&Ve+Oe-le<we||we<Ve)&&i({type:"SET_ROWS",start:pe,rows:Array.from({length:Se-pe},()=>({})),hasCompleteRow:!1}),w.current)j.current=!0;else try{let Y=function(){const Me=[];let _e=!1;for(const Nt of U){const He={};let Lt=!0;for(const[Dc,Zo]of Object.entries(Nt))"resolved"in Zo?He[Dc]=Zo.resolved:Lt=!1;Lt&&(_e=!0),Me.push(He)}p.current=Ve,i({type:"SET_ROWS",start:pe,rows:Me,hasCompleteRow:_e})};var Wt=Y;w.current=!0;const U=Zi(e.rows(pe,Se,a),Se-pe,e.header);for(const Me of U)for(const[_e,Nt]of Object.entries(Me))Nt.then(Y).catch(()=>{});for(const Me of U)for(const _e of Object.values(Me))await _e;w.current=!1,j.current&&(j.current=!1,T())}catch(U){i({type:"SET_PENDING",pending:!1}),w.current=!1,r(U)}}T();const P=v.current;return P==null||P.addEventListener("scroll",T),window.addEventListener("resize",T),()=>{P==null||P.removeEventListener("scroll",T),window.removeEventListener("resize",T)}},[e,a,c,r]);const d=I.useMemo(()=>o.map(Ji),[o]);I.useEffect(()=>{var T;(T=y.current)==null||T.focus()},[]),I.useEffect(()=>{i({type:"DATA_CHANGED"})},[e]);const g=I.useCallback(T=>s[T].__index__??T+u+1,[s,u]);if(!e.header.length)return;const _=Array.from({length:Math.min(20,u)},()=>[]),N=Array.from({length:Math.min(20,e.numRows-u-s.length)},()=>[]),x=4*Math.ceil(Math.log10(e.numRows+1))+22,L=I.useMemo(()=>Ji(x),[x]);return K.jsxs("div",{className:h?"table-container pending":"table-container",children:[K.jsx("div",{className:"table-scroll",ref:v,children:K.jsx("div",{style:{height:`${c}px`},children:K.jsxs("table",{"aria-colcount":e.header.length,"aria-rowcount":e.numRows,className:e.sortable?"table sortable":"table",ref:y,role:"grid",style:{top:`${p.current}px`},tabIndex:0,children:[K.jsx(Xp,{columnWidths:o,orderBy:a,setColumnWidth:(T,P)=>i({type:"SET_COLUMN_WIDTH",columnIndex:T,columnWidth:P}),setColumnWidths:T=>i({type:"SET_COLUMN_WIDTHS",columnWidths:T}),setOrderBy:T=>e.sortable&&i({type:"SET_ORDER",orderBy:T}),dataReady:m,header:e.header}),K.jsxs("tbody",{children:[_.map((T,P)=>K.jsx("tr",{children:K.jsx("td",{style:L,children:(u-_.length+P+1).toLocaleString()})},u-_.length+P)),s.map((T,P)=>K.jsxs("tr",{title:f(T,P),children:[K.jsx("td",{style:L,children:g(P).toLocaleString()}),e.header.map((le,we)=>{var Oe;return function(pe,Se,Ve,Wt){let k,R=qi(pe);return typeof R=="string"&&(R.length>400&&(R=`${R.slice(0,397)}…`),R.length>100&&(k=R)),K.jsx("td",{onDoubleClick:()=>n==null?void 0:n(Se,Wt??Ve),style:d[Se],title:k,children:R},Se)}(T[le],we,u+P,(Oe=T.__index__)==null?void 0:Oe.resolved)})]},u+P)),N.map((T,P)=>K.jsx("tr",{children:K.jsx("td",{style:L,children:(u+s.length+P+1).toLocaleString()})},u+s.length+P))]})]})})}),K.jsx("div",{className:"table-corner",style:L,children:" "}),K.jsx("div",{className:"mock-row-label",style:L,children:" "})]})}function qi(e){return typeof e=="string"?e:typeof e=="number"?e.toLocaleString():Array.isArray(e)?`[${e.map(qi).join(", ")}]`:e==null?JSON.stringify(e):e instanceof Date?e.toISOString():typeof e=="object"?`{${Object.entries(e).map(([t,n])=>`${t}: ${qi(n)}`).join(", ")}}`:e.toString()}function bp({file:e,setProgress:t,setError:n}){const[r,l]=I.useState(0),[i,o]=I.useState();I.useEffect(()=>{const m=e.startsWith("http://")||e.startsWith("https://")?e:"/api/store/get?key="+e;async function h(){try{t(.33);const p=await Ic(m),v={url:m,byteLength:p.byteLength};t(.66);const y=await Tc(p);let w=zc(v,y);w=Gp(w);const j=p.byteLength;o({dataframe:w,fileSize:j})}catch(p){n(p)}finally{l(2),t(1)}}r===0&&(l(1),h().catch(()=>{}))},[r,e,n,t]);const u=(a,m)=>{Oc(`?url=${e}&row=${m.toString()}&col=${a.toString()}`)},s=E.jsx(E.Fragment,{children:(i==null?void 0:i.dataframe)&&E.jsxs("span",{children:[i.dataframe.numRows.toLocaleString("en-US")," rows"]})});return E.jsxs(Rl,{content:i,headers:s,children:[(i==null?void 0:i.dataframe)&&E.jsx(qp,{data:i.dataframe,onDoubleClickCell:u,onError:n}),r&&E.jsx(jc,{className:"center"})]})}function eh({file:e,setError:t}){const[n,r]=I.useState(0),[l,i]=I.useState(),o=I.useRef(null);I.useEffect(()=>{const a=e.startsWith("http://")||e.startsWith("https://")?e:"/api/store/get?key="+e;async function m(){try{const p=await(await fetch(a)).text();i(p)}catch(h){t(h)}finally{r(2)}}r(h=>h!==0?h:(m().catch(()=>{}),1))},[e,n,t]);const u=E.jsx(E.Fragment,{children:E.jsxs("span",{children:[l?th(l):0," lines"]})});return E.jsxs(Rl,{content:{fileSize:l==null?void 0:l.length},headers:u,children:[E.jsx("code",{className:"text",ref:o,children:l}),n&&E.jsx(jc,{className:"center"})]})}function th(e){let t=0;for(const n of e)n===`
49
  `&&t++;return t.toLocaleString("en-US")}function nh({file:e,setError:t,setProgress:n}){const r=e.replace(/\?.*$/,"");return r.endsWith(".md")?E.jsx(Hp,{file:e,setError:t}):r.endsWith(".parquet")?E.jsx(bp,{file:e,setError:t,setProgress:n}):Ap.some(l=>r.endsWith(l))?E.jsx(Fp,{file:e,setError:t}):E.jsx(eh,{file:e,setError:t,setProgress:n})}function rh({url:e}){const[t,n]=I.useState(),[r,l]=I.useState(),i=e.kind==="file"?e.resolveUrl:e.raw,o=i.split("/");if(o.length<1)throw new Error("Invalid URL path");const u=o.at(-1);return E.jsxs(dl,{progress:t,error:r,title:u,children:[E.jsx(Go,{url:e}),E.jsx(nh,{file:i,setProgress:n,setError:l})]})}function lh(){const e=new URLSearchParams(location.search),t=e.get("url")??"https://huggingface.co/datasets/codeparrot/github-code/resolve/main/data/train-00000-of-01126.parquet";if(Array.isArray(t))throw new Error("url must be a string");try{const n=Tp(t);return n.kind==="base"||n.kind==="repo"||n.kind==="folder"?E.jsxs(dl,{title:n.kind,children:[E.jsx(Go,{url:n}),E.jsx("div",{className:"error",children:"Not implemented yet"}),E.jsx("pre",{children:JSON.stringify(n,null,2)})]}):e.has("col")&&e.has("row")?E.jsx(jp,{url:n,row:Number(e.get("row")),col:Number(e.get("col"))}):E.jsx(rh,{url:n})}catch(n){return E.jsx(dl,{error:n,title:"Error",children:E.jsx("div",{className:"error",children:n.message})})}}const Mc=document.getElementById("app");if(!Mc)throw new Error("No root element");Nc(Mc).render(E.jsx(I.StrictMode,{children:E.jsx(lh,{})}));
index.html CHANGED
@@ -9,7 +9,7 @@
9
  <link rel="icon" type="image/svg+xml" href="/assets/logo.svg" />
10
  <meta name="theme-color" content="#6b00ff">
11
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
12
- <script type="module" crossorigin src="/assets/index-C5iognDl.js"></script>
13
  <link rel="stylesheet" crossorigin href="/assets/index-DEFzzeYi.css">
14
  </head>
15
  <body>
 
9
  <link rel="icon" type="image/svg+xml" href="/assets/logo.svg" />
10
  <meta name="theme-color" content="#6b00ff">
11
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
12
+ <script type="module" crossorigin src="/assets/index-CniqBhKv.js"></script>
13
  <link rel="stylesheet" crossorigin href="/assets/index-DEFzzeYi.css">
14
  </head>
15
  <body>