diff --git a/assets/index-D1aL-xAe.js b/assets/index-D1aL-xAe.js deleted file mode 100644 index 34be9ec..0000000 --- a/assets/index-D1aL-xAe.js +++ /dev/null @@ -1,5 +0,0 @@ -import{r as n,j as e,R as L}from"./react-DmpIMwDM.js";import{c as ot}from"./react-dom-tIxIBQuZ.js";import{c as nt}from"./zustand-oOA47TU4.js";import{i as lt}from"./sql.js-lzln2bbd.js";import{F as Z}from"./file-saver-DhbZvGod.js";import{c as it}from"./clsx-B-dksMZM.js";import{t as ct}from"./tailwind-merge-BkWO730n.js";import{S as dt,c as X,I as ut,d as ee,e as te,f as mt,g as se,V as ft,L as ae,h as re,i as pt,j as xt,k as oe,l as ht,G as gt,m as bt,n as ne,o as yt,p as jt,q as wt,r as le,s as Nt,t as vt,u as ie,v as Ct,w as Rt,x as ce,y as St,z as de,A as ue,B as me,E as fe,F as Dt,H as pe,J as xe,K as he,M as ge,N as be,Q as ye,U as Tt,W as Et}from"./@radix-ui-Dtk-Z1Mr.js";import{c as q}from"./class-variance-authority-Bb4qSo10.js";import{C as Pt,a as Lt,b as je,c as kt,d as Ft,K as At,e as Mt,f as It,g as Ht,T as Ot,L as Qt,D as $t,P as qt,h as Bt,i as zt,M as Ut,j as Vt,k as _t,S as Gt,l as Kt,m as Jt,G as Wt}from"./lucide-react-Ch2vEKIM.js";import{f as Yt,a as M}from"./date-fns-fqmN70Xj.js";import{u as Zt}from"./react-dropzone-D-IBOhIS.js";import{J as H,T as Xt}from"./sonner-BJG0sXho.js";import{D as v}from"./vaul-Bkmv171v.js";import"./attr-accept-BWI1aNlo.js";import"./scheduler-CzFDRTuY.js";import"./use-sync-external-store-ByYeed7R.js";import"./aria-hidden-DQ5UC2Eg.js";import"./react-remove-scroll-BOyN_WUU.js";import"./tslib-CuZy2iRz.js";import"./react-remove-scroll-bar-DZjhPxUV.js";import"./react-style-singleton-CpxBwIWS.js";import"./get-nonce-C-Z93AgS.js";import"./use-sidecar-D8_hMcUG.js";import"./use-callback-ref-DRzK4jWO.js";import"./@floating-ui-DGkE6due.js";import"./prop-types-psm7UO16.js";import"./file-selector-CBHVlu32.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const i of l.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function a(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(o){if(o.ep)return;o.ep=!0;const l=a(o);fetch(o.href,l)}})();const es="https://sql.js.org/dist/sql-wasm.wasm",ts=async t=>{try{const[s,a]=await Promise.all([t.arrayBuffer(),lt({locateFile:()=>es})]);return new a.Database(new Uint8Array(s))}catch(s){throw console.error("Failed to load database:",s),s}},B=t=>{var s;try{return((s=t.exec("SELECT name FROM sqlite_master WHERE type='table';")[0])==null?void 0:s.values.flat())||[]}catch(a){return console.error("Failed to get table names:",a),[]}},ss=async(t,s)=>{try{const[a,r]=t.exec(` - PRAGMA table_info("${s}"); - PRAGMA foreign_key_list("${s}"); - `),o=a.values.reduce((l,i)=>(l[i[1]]={type:i[2],isPrimaryKey:i[5]===1,isForeignKey:!1},l),{});return r==null||r.values.forEach(l=>{const i=l[3];o[i]&&(o[i].isForeignKey=!0)}),o}catch(a){throw console.error(`Failed to get schema for table "${s}":`,a),a}},O=t=>{if(t.length===0)return{data:[],columns:[]};const{columns:s,values:a}=t[0];return{data:a.map(o=>Object.fromEntries(s.map((l,i)=>[l,o[i]]))),columns:s}},as=t=>{try{const s=t.export(),a=new Blob([s],{type:"application/x-sqlite3"});Z.saveAs(a,"database.sqlite")}catch(s){throw console.error("Failed to export database:",s),s}},rs=(t,s)=>{const a=t.map(o=>`"${o}"`).join(","),r=s.map(o=>t.map(l=>`"${o[l]??""}"`).join(","));return[a,...r].join(` -`)},z=(t,s,a)=>{try{const r=s.exec(t);if(r.length===0)throw new Error(`Query "${t}" returned no results.`);const{data:o,columns:l}=O(r),i=rs(l,o),d=new Blob([i],{type:"text/csv;charset=utf-8;"});Z.saveAs(d,`${a}.csv`)}catch(r){throw console.error(`Failed to get CSV for query "${t}":`,r),r}},os=(t,s)=>{const r=B(t)[s],o=`SELECT * FROM "${r}"`;z(o,t,r)},ns=t=>{B(t).forEach(s=>{const a=`SELECT * FROM "${s}"`;z(a,t,s)})},ls=(t,s)=>{z(s,t,"custom_query")},R=nt((t,s)=>({db:null,isLoading:!1,queryError:null,tables:[],selectedTable:"0",tableSchemas:{},rowPerPageOrAuto:"auto",isCustomQuery:!1,loadDatabase:async a=>{t({isLoading:!0,queryError:null});try{const r=await ts(a),o=B(r),l=await Promise.all(o.map(async u=>{const m=r.exec(`SELECT COUNT(*) FROM "${u}"`),p=parseInt(m[0].values[0][0],10),x=await ss(r,u);return{name:u,count:p,schema:x}})),i=l.map(({name:u,count:m})=>({name:u,count:m})),d=l.reduce((u,{name:m,schema:p})=>(u[m]=p,u),{});t({db:r,tables:i,tableSchemas:d,isLoading:!1})}catch(r){console.error("Failed to load database:",r),t({isLoading:!1,queryError:"Failed to load database"})}},query:a=>{const{db:r}=s();return r?r.exec(a):(console.warn("Database is not loaded."),[])},setQueryError:a=>t({queryError:a}),setTables:a=>t({tables:a}),setSelectedTable:a=>t({selectedTable:a}),setTableSchemas:a=>t({tableSchemas:a}),setRowPerPageOrAuto:a=>t({rowPerPageOrAuto:a}),customQuery:"",setIsCustomQuery:a=>t({isCustomQuery:a}),setCustomQuery:a=>t({customQuery:a}),queryHestory:[],setQueryHestory:a=>t({queryHestory:a}),unShiftToQueryHestory:a=>t(r=>({queryHestory:[a,...r.queryHestory]})),expandPage:!1,setExpandPage:a=>t({expandPage:a}),dateFormatValue:"formatDateFormatted",setDateFormatValue:a=>t({dateFormatValue:a})}));function is(t,s,a,r){const{db:o,setQueryError:l,setIsCustomQuery:i,query:d,unShiftToQueryHestory:u,customQuery:m,setCustomQuery:p}=R(),[x,b]=n.useState([]),[f,h]=n.useState([]),[j,S]=n.useState(!0);n.useEffect(()=>{o&&t&&!r&&(S(!0),(async()=>{try{const g=`PRAGMA table_info("${t}");`,T=`SELECT ${d(g)[0].values.map(E=>({name:E[1],type:E[2]})).map(E=>E.type.toUpperCase()==="BLOB"?`hex(${E.name}) as ${E.name}`:E.name).join(", ")} FROM "${t}" LIMIT ${s} OFFSET ${a};`,k=d(T),{data:I,columns:C}=O(k);h(C),b(I),l(null),p(T),u(T)}catch(g){g instanceof Error&&l(g.message)}finally{S(!1)}})())},[o,t,a,s,r,l,d,p,u]);const w=n.useCallback(()=>{if(m.trim()===""){l(null);return}S(!0),(async()=>{try{const g=d(m),{data:P,columns:N}=O(g);h(N),b(P),i(!0),l(null)}catch(g){g instanceof Error&&l(g.message)}finally{S(!1)}})()},[m,d,l,i]);return{data:x,columns:f,customQuery:m,setCustomQuery:p,isQueryLoading:j,handleCustomQuery:w}}function cs(t){const{setIsCustomQuery:s}=R(),[a,r]=n.useState(0);n.useEffect(()=>{r(0),s(!1)},[s]);let o=30;if(t==="auto"){const l=window.innerHeight,i=[{height:1700,rowHeight:65},{height:1300,rowHeight:70},{height:1200,rowHeight:75},{height:1100,rowHeight:75},{height:1e3,rowHeight:80},{height:950,rowHeight:85},{height:900,rowHeight:90},{height:850,rowHeight:95},{height:800,rowHeight:100},{height:750,rowHeight:105},{height:700,rowHeight:110},{height:600,rowHeight:120},{height:550,rowHeight:150},{height:500,rowHeight:190},{height:0,rowHeight:280}];let u=120;for(const m of i)if(l>m.height){u=m.rowHeight;break}o=Math.max(1,Math.floor(l/u))}else o=t;return{page:a,setPage:r,rowsPerPage:o}}function c(...t){return ct(it(t))}const U=n.forwardRef(({className:t,type:s,...a},r)=>e.jsx("input",{type:s,className:c("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:r,...a}));U.displayName="Input";const V=q("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),y=n.forwardRef(({className:t,variant:s,size:a,asChild:r=!1,...o},l)=>{const i=r?dt:"button";return e.jsx(i,{className:c(V({variant:s,size:a,className:t})),ref:l,...o})});y.displayName="Button";function ds({page:t,setPage:s,rowsPerPage:a,rowCount:r}){const o=Math.ceil(r/a),l=Math.floor(t/a)+1,i=()=>{l{l>1&&s(t-a)};return e.jsx("section",{className:"fixed bottom-[8px] left-0 right-0 z-10 mx-auto w-[270px]",children:e.jsxs("div",{className:"flex justify-between gap-2 rounded border bg-secondary p-[6px]",children:[e.jsx(y,{onClick:d,title:"Previous page",disabled:l===1,children:e.jsx(Pt,{className:"h-4 w-4"})}),e.jsxs("span",{className:"flex items-center justify-center text-sm",children:["Page ",l," of ",o]}),e.jsx(y,{onClick:i,title:"Next page",disabled:l>=o,children:e.jsx(Lt,{className:"h-4 w-4"})})]})})}const us=ht,ms=gt,fs=bt,we=n.forwardRef(({className:t,children:s,...a},r)=>e.jsxs(X,{ref:r,className:c("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...a,children:[s,e.jsx(ut,{asChild:!0,children:e.jsx(je,{className:"h-4 w-4 opacity-50"})})]}));we.displayName=X.displayName;const Ne=n.forwardRef(({className:t,...s},a)=>e.jsx(ee,{ref:a,className:c("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(kt,{className:"h-4 w-4"})}));Ne.displayName=ee.displayName;const ve=n.forwardRef(({className:t,...s},a)=>e.jsx(te,{ref:a,className:c("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(je,{className:"h-4 w-4"})}));ve.displayName=te.displayName;const Ce=n.forwardRef(({className:t,children:s,position:a="popper",...r},o)=>e.jsx(mt,{children:e.jsxs(se,{ref:o,className:c("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:a,...r,children:[e.jsx(Ne,{}),e.jsx(ft,{className:c("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(ve,{})]})}));Ce.displayName=se.displayName;const Re=n.forwardRef(({className:t,...s},a)=>e.jsx(ae,{ref:a,className:c("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));Re.displayName=ae.displayName;const Se=n.forwardRef(({className:t,children:s,...a},r)=>e.jsxs(re,{ref:r,className:c("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(pt,{children:e.jsx(Ft,{className:"h-4 w-4"})})}),e.jsx(xt,{children:s})]}));Se.displayName=re.displayName;const ps=n.forwardRef(({className:t,...s},a)=>e.jsx(oe,{ref:a,className:c("-mx-1 my-1 h-px bg-muted",t),...s}));ps.displayName=oe.displayName;const xs=q("inline-flex items-center rounded border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function De({className:t,variant:s,...a}){return e.jsx("div",{className:c(xs({variant:s}),t),...a})}function hs(){const{tables:t,selectedTable:s,setSelectedTable:a}=R(),r=n.useMemo(()=>{var i;const l=parseInt(s);return isNaN(l)?0:((i=t[l])==null?void 0:i.count)||0},[t,s]),o=n.useMemo(()=>t.map((l,i)=>e.jsx(Se,{value:`${i}`,children:l.name},l.name)),[t]);return e.jsxs("section",{className:"flex grow items-center justify-center gap-1",children:[e.jsxs(us,{value:s,onValueChange:a,children:[e.jsx(we,{className:"grow",children:e.jsx(fs,{placeholder:"Select a table"})}),e.jsx(Ce,{children:e.jsxs(ms,{children:[e.jsx(Re,{children:"Tables"}),o]})})]}),e.jsx(De,{title:"Rows",className:"min-w-[100px] grow py-2 text-sm md:min-w-[200px]",variant:"outline",children:e.jsx("span",{className:"w-full text-center",children:r})})]})}const F=t=>t instanceof Date&&!isNaN(t.getTime()),gs=t=>{const s=new Date(t);return F(s)?Yt(s,{addSuffix:!0}):t},bs=t=>{const s=new Date(t);return F(s)?M(s,"MMMM do, yyyy"):t},ys=t=>{const s=new Date(t);return F(s)?M(s,"hh:mm a"):t},js=t=>{const s=new Date(t);return F(s)?M(s,"MM/dd/yyyy"):t},ws=t=>{const s=new Date(t);return F(s)?M(s,"EEEE, MMMM do, yyyy"):t},A={formatDateRelative:{label:"over 56 years ago",func:gs},formatDateFormatted:{label:"January 9th, 1968",func:bs},formatTime:{label:"12:00 am",func:ys},formatDateShort:{label:"01/09/1968",func:js},formatDateLong:{label:"Monday, January 9th, 1968",func:ws}},Te=yt,Ee=jt,_=n.forwardRef(({className:t,align:s="start",side:a="bottom",sideOffset:r=4,...o},l)=>e.jsx(ne,{ref:l,align:s,side:a,sideOffset:r,className:c("z-50 w-64 text-balance break-words rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...o}));_.displayName=ne.displayName;const Pe=n.forwardRef(({className:t,...s},a)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:a,className:c("w-full caption-bottom text-sm",t),...s})}));Pe.displayName="Table";const Le=n.forwardRef(({className:t,...s},a)=>e.jsx("thead",{ref:a,className:c("[&_tr]:border-b",t),...s}));Le.displayName="TableHeader";const ke=n.forwardRef(({className:t,...s},a)=>e.jsx("tbody",{ref:a,className:c("[&_tr:last-child]:border-0",t),...s}));ke.displayName="TableBody";const Ns=n.forwardRef(({className:t,...s},a)=>e.jsx("tfoot",{ref:a,className:c("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...s}));Ns.displayName="TableFooter";const Q=n.forwardRef(({className:t,...s},a)=>e.jsx("tr",{ref:a,className:c("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...s}));Q.displayName="TableRow";const Fe=n.forwardRef(({className:t,...s},a)=>e.jsx("th",{ref:a,className:c("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...s}));Fe.displayName="TableHead";const vs=t=>{const s=new Uint8Array(t.match(/.{1,2}/g).map(r=>parseInt(r,16))),a=new Blob([s],{type:"image/jpeg"});return URL.createObjectURL(a)},Ae=n.forwardRef(({className:t,children:s,dataType:a,...r},o)=>{const l=(a==null?void 0:a.toUpperCase())==="BLOB",i=n.useMemo(()=>typeof s=="string"&&s.length>40?s.slice(0,40)+"...":s,[s]);return e.jsx("td",{ref:o,className:c("max-w-[200px] overflow-hidden truncate text-ellipsis whitespace-nowrap p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...r,children:e.jsxs(Te,{children:[e.jsx(Ee,{asChild:!0,children:e.jsx("span",{className:"cursor-pointer hover:underline",children:l?e.jsx("span",{className:"italic opacity-40",children:"BLOB"}):i})}),e.jsx(_,{side:"bottom",align:"start",children:e.jsxs("div",{className:"flex flex-col justify-center gap-2",children:[l&&typeof s=="string"?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:vs(s),alt:"BLOB content",className:"flex max-h-40 flex-col items-center justify-center gap-2 rounded object-contain",onError:d=>{d.currentTarget.style.display="none"}}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Blob length: ",s.length]})]}):e.jsx("span",{className:"max-w-full break-words",children:s}),a&&e.jsx(De,{className:"w-full self-start text-xs font-semibold",children:a})]})})]})})});Ae.displayName="TableCell";const Cs=n.forwardRef(({className:t,...s},a)=>e.jsx("caption",{ref:a,className:c("mt-4 text-sm text-muted-foreground",t),...s}));Cs.displayName="TableCaption";const Rs=L.memo(({columnSchema:t})=>{var s;return t!=null&&t.isPrimaryKey?e.jsx(At,{className:"h-4 w-4"}):t!=null&&t.isForeignKey?e.jsx(Mt,{className:"h-4 w-4"}):(t==null?void 0:t.type)==="BLOB"?e.jsx(It,{className:"h-4 w-4"}):(s=t==null?void 0:t.type)!=null&&s.includes("DATE")?e.jsx(Ht,{className:"h-4 w-4"}):null}),Ss=L.memo(({col:t,columnSchema:s})=>e.jsx(Fe,{children:e.jsxs(Te,{children:[e.jsx(Ee,{asChild:!0,children:e.jsx("span",{className:"cursor-pointer hover:underline",children:e.jsxs("div",{className:"flex gap-1",children:[t,e.jsx(Rs,{columnSchema:s})]})})}),e.jsx(_,{side:"bottom",align:"start",children:(s==null?void 0:s.type)||"Unknown"})]})})),Ds=L.memo(({value:t,dataType:s})=>{const{dateFormatValue:a}=R(),r=s==="DATE"||s==="DATETIME",o=()=>t?r&&A[a]?A[a].func(t):t:e.jsx("span",{className:"italic opacity-40",children:"NULL"});return e.jsx(Ae,{dataType:s,children:o()})});function Ts({data:t,columns:s,tableName:a,tableSchemas:r}){const o=n.useMemo(()=>e.jsx(Le,{children:e.jsx(Q,{children:s.map((i,d)=>e.jsx(Ss,{col:i,columnSchema:r[a][i]},d))})}),[s,r,a]),l=n.useMemo(()=>e.jsx(ke,{children:t.map((i,d)=>e.jsx(Q,{children:s.map((u,m)=>{var p;return e.jsx(Ds,{value:i[u],dataType:(p=r[a][u])==null?void 0:p.type},m)})},d))}),[t,s,r,a]);return e.jsxs(Pe,{children:[o,l]})}function $({children:t}){return e.jsxs("div",{className:"flex items-center justify-center gap-4 rounded border p-4",children:[e.jsx(Ot,{className:"h-6 w-6"}),e.jsx("span",{className:"font-semibold",children:t})]})}function Me({children:t}){return e.jsxs("div",{className:"flex items-center justify-center gap-4 rounded border p-4",children:[e.jsx(Qt,{className:"h-6 w-6 animate-spin"}),e.jsx("span",{className:"font-semibold",children:t})]})}const Es=Nt,Ps=vt,Ie=n.forwardRef(({className:t,align:s="center",sideOffset:a=4,...r},o)=>e.jsx(wt,{children:e.jsx(le,{ref:o,align:s,sideOffset:a,className:c("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r})}));Ie.displayName=le.displayName;function Ls(){const{selectedTable:t,tables:s,customQuery:a,db:r}=R(),o=n.useCallback((i,d,u,m)=>e.jsx(y,{className:m,onClick:i,title:u,children:e.jsx("span",{className:"ml-2",children:d})}),[]),l=n.useMemo(()=>{var i;return r&&e.jsxs("div",{className:"flex flex-col gap-1",children:[o(()=>as(r),"Export as SQLite","Download database as SQLite"),o(()=>os(r,parseInt(t)),`Export ${((i=s[parseInt(t)])==null?void 0:i.name)||"selected"} table as CSV`,"Export selected table as CSV"),o(()=>ns(r),"Export all tables as CSV","Export all tables as CSV"),o(()=>ls(r,a),"Export custom query as CSV","Export the result of the custom query as CSV")]})},[r,o,t,s,a]);return e.jsxs(Es,{children:[e.jsx(Ps,{asChild:!0,children:e.jsx(y,{title:"Open export options",children:e.jsx($t,{className:"h-5 w-5"})})}),e.jsx(Ie,{align:"end",className:"w-80",children:l})]})}function ks(){const{tables:t,selectedTable:s,tableSchemas:a,queryError:r,setQueryError:o,rowPerPageOrAuto:l,isCustomQuery:i,setIsCustomQuery:d,customQuery:u,setCustomQuery:m,expandPage:p,setExpandPage:x}=R(),{page:b,setPage:f,rowsPerPage:h}=cs(l),j=n.useMemo(()=>{var C;return(C=t[parseInt(s)])==null?void 0:C.name},[t,s]),S=n.useMemo(()=>{var C;return((C=t[parseInt(s)])==null?void 0:C.count)||0},[t,s]),{data:w,columns:g,isQueryLoading:P,handleCustomQuery:N}=is(j,h,b,i),D=n.useCallback(()=>{o(null),m(""),d(!1)},[d,o,m]),T=n.useCallback(()=>{f(0),D()},[D,f]);n.useEffect(()=>{f(0)},[s]);const k=n.useMemo(()=>e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row",children:[e.jsx(U,{type:"text",value:u,onChange:C=>m(C.target.value),placeholder:"Enter your custom query",className:"w-full"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(y,{className:"w-full",onClick:N,title:"Run custom query",children:e.jsx(qt,{className:"h-5 w-5"})}),e.jsx(y,{className:"w-full",onClick:D,title:"Reset query",children:e.jsx(Bt,{className:"h-5 w-5"})}),e.jsx(y,{className:"w-full",onClick:T,title:"Reset to first page",disabled:b===0,children:e.jsx(zt,{className:"h-5 w-5"})})]})]}),[u,N,D,T,b]),I=n.useMemo(()=>P?e.jsxs(Me,{children:["Loading ",j]}):w.length>0?e.jsx("div",{className:"rounded border",children:e.jsx(Ts,{data:w,columns:g,tableName:j,tableSchemas:a})}):e.jsx($,{children:`Table ${j} is empty`}),[P,w,g,j,a]);return e.jsxs("div",{className:"flex flex-col gap-3 pb-8",children:[e.jsxs("section",{className:"flex flex-col gap-2 rounded border p-3 pb-2",children:[e.jsxs("div",{className:"flex h-full gap-1",children:[e.jsx(hs,{}),e.jsxs("div",{className:"ml-1 flex gap-1",children:[e.jsx(Ls,{}),e.jsx(y,{className:"hidden expand:block",onClick:()=>x(!p),title:"Toggle page size",children:p?e.jsx(Ut,{className:"h-5 w-5"}):e.jsx(Vt,{className:"h-5 w-5"})})]})]}),k,r&&e.jsx("p",{className:"text-center text-xs capitalize text-red-500",children:r})]}),I,!i&&e.jsx(ds,{page:b,setPage:f,rowsPerPage:h,rowCount:S})]})}const He=({shouldScaleBackground:t=!0,...s})=>e.jsx(v.Root,{shouldScaleBackground:t,...s});He.displayName="Drawer";const Fs=v.Trigger,As=v.Portal,Ms=v.Close,Oe=n.forwardRef(({className:t,...s},a)=>e.jsx(v.Overlay,{ref:a,className:c("fixed inset-0 z-50 bg-black/80",t),...s}));Oe.displayName=v.Overlay.displayName;const Qe=n.forwardRef(({className:t,children:s,...a},r)=>e.jsxs(As,{children:[e.jsx(Oe,{}),e.jsxs(v.Content,{ref:r,className:c("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",t),...a,children:[e.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),s]})]}));Qe.displayName="DrawerContent";const $e=({className:t,...s})=>e.jsx("div",{className:c("grid gap-1.5 p-4 text-center sm:text-left",t),...s});$e.displayName="DrawerHeader";const qe=({className:t,...s})=>e.jsx("div",{className:c("mt-auto flex flex-col gap-2 p-4",t),...s});qe.displayName="DrawerFooter";const Be=n.forwardRef(({className:t,...s},a)=>e.jsx(v.Title,{ref:a,className:c("text-lg font-semibold leading-none tracking-tight",t),...s}));Be.displayName=v.Title.displayName;const ze=n.forwardRef(({className:t,...s},a)=>e.jsx(v.Description,{ref:a,className:c("text-sm text-muted-foreground",t),...s}));ze.displayName=v.Description.displayName;const Ue=n.forwardRef(({className:t,children:s,...a},r)=>e.jsxs(ie,{ref:r,className:c("relative overflow-hidden",t),...a,children:[e.jsx(Ct,{className:"h-full w-full rounded-[inherit]",children:s}),e.jsx(Ve,{}),e.jsx(Rt,{})]}));Ue.displayName=ie.displayName;const Ve=n.forwardRef(({className:t,orientation:s="vertical",...a},r)=>e.jsx(ce,{ref:r,orientation:s,className:c("flex touch-none select-none transition-colors",s==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",s==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...a,children:e.jsx(St,{className:"relative flex-1 rounded-full bg-border"})}));Ve.displayName=ce.displayName;const _e=n.forwardRef(({className:t,orientation:s="horizontal",decorative:a=!0,...r},o)=>e.jsx(de,{ref:o,decorative:a,orientation:s,className:c("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...r}));_e.displayName=de.displayName;const Is=q("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ge=n.forwardRef(({className:t,...s},a)=>e.jsx(ue,{ref:a,className:c(Is(),t),...s}));Ge.displayName=ue.displayName;const Ke=n.forwardRef(({className:t,...s},a)=>e.jsx(me,{className:c("grid gap-2",t),...s,ref:a}));Ke.displayName=me.displayName;const Je=n.forwardRef(({className:t,...s},a)=>e.jsx(fe,{ref:a,className:c("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(Dt,{className:"flex items-center justify-center",children:e.jsx(_t,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Je.displayName=fe.displayName;const G="rowsPerPage",K="dateFormat";function Hs(){const{setRowPerPageOrAuto:t,setIsCustomQuery:s,queryHestory:a,dateFormatValue:r,setDateFormatValue:o}=R(),[l,i]=n.useState(null),[d,u]=n.useState(!1);n.useEffect(()=>{const f=localStorage.getItem(G),h=localStorage.getItem(K);if(f)if(f==="auto")u(!0);else{const j=Number(f);i(j),t(j)}h&&o(h)},[t,o]);const m=n.useCallback(f=>{const h=Number(f.target.value);isNaN(h)||(i(h),u(!1))},[]),p=n.useCallback(()=>{u(f=>!f)},[]),x=n.useCallback(()=>{if(s(!1),l===null){H.error("Please provide a number of rows per page or set it to auto.");return}if(l<1){H.error("Please provide a positive number of rows per page.");return}const f=d?"auto":l.toString();localStorage.setItem(G,f),t(d?"auto":l)},[l,d,s,t]),b=f=>{o(f),localStorage.setItem(K,f)};return e.jsxs(He,{children:[e.jsx(Fs,{asChild:!0,children:e.jsx(y,{className:"grow",title:"Open settings drawer",children:e.jsx(Gt,{className:"h-5 w-5"})})}),e.jsx(Qe,{children:e.jsxs("div",{className:"mx-auto w-full max-w-md",children:[e.jsxs($e,{children:[e.jsx(Be,{children:"Settings"}),e.jsx(ze,{children:"Personalize your site experience here."})]}),e.jsxs("div",{className:"flex flex-col gap-4 p-4 pb-0",children:[e.jsx(Os,{selectedRowsPerPage:l,isAutoRowsPerPage:d,handleInputChange:m,toggleAutoRowsPerPage:p,handleRowsPerPageSave:x}),e.jsx(Qs,{dateFormatValue:r,handleDateFormatChange:b}),e.jsx($s,{queryHestory:a})]}),e.jsx(qe,{children:e.jsx(Ms,{asChild:!0,children:e.jsx(y,{title:"Close settings drawer",variant:"outline",children:"Close"})})})]})})]})}function Os({selectedRowsPerPage:t,isAutoRowsPerPage:s,handleInputChange:a,toggleAutoRowsPerPage:r,handleRowsPerPageSave:o}){return e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-sm text-muted-foreground",children:"Rows Per Page"}),e.jsxs("div",{className:"flex items-center justify-center gap-1 rounded border p-2",children:[e.jsx(U,{value:t||"",onChange:a,disabled:s,placeholder:"Number of rows",type:"number",name:"rowsPerPage"}),e.jsx("span",{className:"h-full text-center text-sm text-muted-foreground",children:"OR"}),e.jsx(y,{className:s?"border border-primary":"",onClick:r,title:"Toggle auto rows per page",variant:"outline",children:"Auto Calculate"})]}),e.jsx(y,{className:"mt-2 w-full",onClick:o,title:"Save rows per page settings",variant:"outline",children:e.jsx("span",{children:"Save"})})]})}function Qs({dateFormatValue:t,handleDateFormatChange:s}){return e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-sm text-muted-foreground",children:"Date type format"}),e.jsxs(Ke,{className:"flex flex-col gap-2",name:"dateType",value:t,onValueChange:s,children:[e.jsx(J,{value:"default",label:"Default"}),Object.keys(A).map(a=>e.jsx(J,{value:a,label:A[a].label},a))]})]})}function J({value:t,label:s}){return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Je,{value:t,id:`r-${t}`}),e.jsx(Ge,{htmlFor:`r-${t}`,children:s})]})}function $s({queryHestory:t}){return e.jsxs("div",{children:[e.jsxs("p",{className:"mb-1 text-sm text-muted-foreground",children:["Query History (",t.length,")"]}),e.jsx(Ue,{className:"h-48 rounded-md border",children:e.jsx("div",{className:"p-4",children:t.map((s,a)=>e.jsxs("div",{children:[e.jsx("div",{className:"text-xs",children:s}),e.jsx(_e,{className:"my-2"})]},a))})})]})}const W="darkMode",Y="animate-circular-reveal";function We(){const[t,s]=n.useState(!1),a=n.useCallback(o=>{s(o),document.body.classList.toggle("dark",o),localStorage.setItem(W,o.toString()),document.body.classList.add(Y),setTimeout(()=>{document.body.classList.remove(Y)},500)},[]);n.useEffect(()=>{const o=localStorage.getItem(W),l=o!==null?o==="true":window.matchMedia("(prefers-color-scheme: dark)").matches;a(l);const i=u=>{a(u.matches)},d=window.matchMedia("(prefers-color-scheme: dark)");return d.addEventListener("change",i),()=>{d.removeEventListener("change",i)}},[a]);const r=n.useCallback(()=>{a(!t)},[t,a]);return e.jsx(y,{className:"relative grow",onClick:r,title:t?"Enable light mode":"Enable dark mode",children:t?e.jsx(Kt,{className:"h-5 w-5"}):e.jsx(Jt,{className:"h-5 w-5"})})}const qs={"application/vnd.sqlite3":[".sqlite",".sqlite3"],"application/x-sqlite3":[".sqlite",".sqlite3"],"application/octet-stream":[".db"],"application/sql":[".sql"]},Bs={CHINOOK:"https://github.com/vwh/sqlite-viewer/raw/main/db_examples/chinook.db"};function zs(){const{loadDatabase:t,setTables:s,setSelectedTable:a,db:r}=R(),[o,l]=n.useState([]),i=n.useCallback(async(x,b)=>{if(l([]),s([]),a("0"),x.length>0&&await t(x[0]),b.length>0){const f=b.flatMap(h=>h.errors);l(f)}},[t,s,a]),{getRootProps:d,getInputProps:u}=Zt({onDrop:i,multiple:!1,accept:qs}),m=n.useCallback(x=>e.jsxs("div",{className:`flex h-full items-center justify-center gap-2 ${x?"px-[10px]":"px-0"}`,children:[e.jsxs("div",{...d(),className:`flex h-full grow cursor-pointer flex-col items-center justify-center rounded border p-6 text-center ${x?"py-0":"py-32"}`,children:[e.jsx("input",{id:"file-upload",...u()}),e.jsx("label",{htmlFor:"file-upload",className:"sr-only",children:"Upload SQLite File"}),e.jsx("p",{className:"hidden sm:block",children:"Drag and drop a SQLite file here, or click to select one"}),e.jsx("p",{className:"block sm:hidden",children:x?"Click to select a file":"Click to select a SQLite file"}),!x&&e.jsx("a",{href:Bs.CHINOOK,className:"text-sm text-link hover:underline",title:"Download sample file",children:"Or download & try this sample file"})]}),x&&e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(We,{}),e.jsx(Hs,{})]})]}),[d,u]),p=n.useMemo(()=>m(!!r),[m,r]);return e.jsxs("section",{children:[p,e.jsx(Us,{errors:o})]})}const Us=L.memo(({errors:t})=>(L.useEffect(()=>{t==null||t.forEach(s=>H(s.message,{position:"bottom-right"}))},[t]),null));function Vs(){const[t,s]=n.useState(()=>document.body.classList.contains("dark"));return n.useEffect(()=>{const a=new MutationObserver(()=>{s(document.body.classList.contains("dark"))});return a.observe(document.body,{attributes:!0,attributeFilter:["class"]}),()=>a.disconnect()},[]),t}function _s(){const s=Vs()?"/sqlite-dark.webp":"/sqlite-light.webp";return e.jsx("section",{className:"flex justify-center rounded border py-3",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("img",{id:"logo",title:"SQLite Logo",src:s,alt:"SQLite Logo",width:"170",height:"80",draggable:"false"}),e.jsx("p",{className:"text-sm",children:"View SQLite files in the browser"})]})})}const Gs=Et,Ks=Tt,Ye=n.forwardRef(({className:t,...s},a)=>e.jsx(pe,{className:c("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s,ref:a}));Ye.displayName=pe.displayName;const Ze=n.forwardRef(({className:t,...s},a)=>e.jsxs(Ks,{children:[e.jsx(Ye,{}),e.jsx(xe,{ref:a,className:c("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...s})]}));Ze.displayName=xe.displayName;const Xe=({className:t,...s})=>e.jsx("div",{className:c("flex flex-col space-y-2 text-left",t),...s});Xe.displayName="AlertDialogHeader";const et=({className:t,...s})=>e.jsx("div",{className:c("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});et.displayName="AlertDialogFooter";const tt=n.forwardRef(({className:t,...s},a)=>e.jsx(he,{ref:a,className:c("text-lg font-semibold",t),...s}));tt.displayName=he.displayName;const st=n.forwardRef(({className:t,...s},a)=>e.jsx(ge,{ref:a,className:c("text-sm",t),...s}));st.displayName=ge.displayName;const at=n.forwardRef(({className:t,...s},a)=>e.jsx(be,{ref:a,className:c(V(),t),...s}));at.displayName=be.displayName;const rt=n.forwardRef(({className:t,...s},a)=>e.jsx(ye,{ref:a,className:c(V({variant:"outline"}),"mt-2 sm:mt-0",t),...s}));rt.displayName=ye.displayName;function Js({showDialog:t,setShowDialog:s,fn:a}){return e.jsx(Gs,{open:t,onOpenChange:s,children:e.jsxs(Ze,{children:[e.jsxs(Xe,{children:[e.jsx(tt,{children:"Retry using a proxy?"}),e.jsx(st,{children:"Failed to load the database from the provided URL due to possible CORS restrictions."})]}),e.jsx("div",{className:"text-sm font-semibold",children:"Using the proxy may expose your database to corsproxy.io services."}),e.jsxs(et,{children:[e.jsx(rt,{onClick:()=>s(!1),children:"Cancel"}),e.jsx(at,{onClick:a,children:"Confirm"})]})]})})}const Ws="https://github.com/vwh/sqlite-viewer";function Ys(){return e.jsxs("footer",{className:"flex items-center justify-between rounded border p-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"hidden text-xs sm:block",children:"No file will be uploaded to server. using JavaScript, sql.js"}),e.jsx("p",{className:"block text-xs sm:hidden",children:"No file uploads to server."}),e.jsxs("a",{href:Ws,target:"_blank",className:"flex items-center gap-1 text-sm text-link hover:underline",title:"Star on GitHub",children:[e.jsx(Wt,{className:"h-4 w-4"}),e.jsx("span",{children:"Star us on GitHub"})]})]}),e.jsx("div",{className:"flex gap-1",children:e.jsx(We,{})})]})}function Zs(){const{db:t,tables:s,isLoading:a,loadDatabase:r,expandPage:o}=R(),[l,i]=n.useState(null),[d,u]=n.useState(!1),[m,p]=n.useState(null),[x,b]=n.useState(!1),f=n.useRef(!1),h=n.useCallback(async(w,g=!1)=>{if(!/^(https?:\/\/(?:www\.)?[a-zA-Z0-9-]{1,256}\.[a-zA-Z]{2,6}(?:\/[^\s]*)?)$/i.test(w)){i("Invalid URL");return}try{b(!0);const N=g?`https://corsproxy.io/?${encodeURIComponent(w)}`:w,D=await fetch(N);if(!D.ok)throw new Error("URL not found or invalid");const T=await D.blob(),k=new File([T],"database.sqlite");await r(k),i(null)}catch(N){g?i(`Error whilefetching, ${N instanceof Error?N.message:String(N)}`):(p(w),u(!0))}finally{b(!1)}},[r]);n.useEffect(()=>{if(f.current)return;const g=new URLSearchParams(window.location.search).get("url");g&&(h(decodeURIComponent(g)),f.current=!0)},[h]);const j=n.useCallback(()=>{m&&(h(m,!0),u(!1))},[m,h]),S=()=>a||x?e.jsxs(Me,{children:[x?"Fetching":"Loading"," SQLite file"]}):l&&!t?e.jsx($,{children:l}):t?s.length>0?e.jsx(ks,{}):e.jsx($,{children:"Your database is empty, no tables found"}):null;return e.jsxs("main",{className:`mx-auto flex h-screen flex-col gap-3 p-4 ${o?"w-full":"container"}`,children:[!t&&e.jsx(_s,{}),e.jsx(zs,{}),S(),e.jsx(Js,{showDialog:d,setShowDialog:u,fn:j}),!t&&e.jsx(Ys,{})]})}const Xs=({...t})=>e.jsx(Xt,{className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-primary group-[.toaster]:text-background group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...t});ot.createRoot(document.getElementById("root")).render(e.jsxs(L.StrictMode,{children:[e.jsx(Zs,{}),e.jsx(Xs,{})]})); diff --git a/assets/index-D1aL-xAe.js.gz b/assets/index-D1aL-xAe.js.gz deleted file mode 100644 index 74c9f1b..0000000 Binary files a/assets/index-D1aL-xAe.js.gz and /dev/null differ diff --git a/assets/index-DKPTwSyp.js b/assets/index-DKPTwSyp.js new file mode 100644 index 0000000..a040fcf --- /dev/null +++ b/assets/index-DKPTwSyp.js @@ -0,0 +1,5 @@ +import{r as n,j as e,R as L}from"./react-DmpIMwDM.js";import{c as ot}from"./react-dom-tIxIBQuZ.js";import{c as nt}from"./zustand-oOA47TU4.js";import{i as lt}from"./sql.js-lzln2bbd.js";import{F as Z}from"./file-saver-DhbZvGod.js";import{c as it}from"./clsx-B-dksMZM.js";import{t as ct}from"./tailwind-merge-BkWO730n.js";import{S as dt,c as X,I as ut,d as ee,e as te,f as mt,g as se,V as ft,L as ae,h as re,i as pt,j as xt,k as oe,l as ht,G as gt,m as bt,n as ne,o as yt,p as jt,q as wt,r as le,s as Nt,t as vt,u as ie,v as Ct,w as Rt,x as ce,y as St,z as de,A as ue,B as me,E as fe,F as Tt,H as pe,J as xe,K as he,M as ge,N as be,Q as ye,U as Dt,W as Et}from"./@radix-ui-Dtk-Z1Mr.js";import{c as q}from"./class-variance-authority-Bb4qSo10.js";import{C as Pt,a as Lt,b as je,c as kt,d as Ft,K as At,e as Mt,f as It,g as Ht,T as Qt,L as Ot,D as $t,P as qt,h as Bt,i as zt,M as Ut,j as Vt,k as _t,S as Gt,l as Kt,m as Jt,G as Wt}from"./lucide-react-Ch2vEKIM.js";import{f as Yt,a as M}from"./date-fns-fqmN70Xj.js";import{u as Zt}from"./react-dropzone-D-IBOhIS.js";import{J as H,T as Xt}from"./sonner-BJG0sXho.js";import{D as v}from"./vaul-Bkmv171v.js";import"./attr-accept-BWI1aNlo.js";import"./scheduler-CzFDRTuY.js";import"./use-sync-external-store-ByYeed7R.js";import"./aria-hidden-DQ5UC2Eg.js";import"./react-remove-scroll-BOyN_WUU.js";import"./tslib-CuZy2iRz.js";import"./react-remove-scroll-bar-DZjhPxUV.js";import"./react-style-singleton-CpxBwIWS.js";import"./get-nonce-C-Z93AgS.js";import"./use-sidecar-D8_hMcUG.js";import"./use-callback-ref-DRzK4jWO.js";import"./@floating-ui-DGkE6due.js";import"./prop-types-psm7UO16.js";import"./file-selector-CBHVlu32.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const i of l.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function a(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(o){if(o.ep)return;o.ep=!0;const l=a(o);fetch(o.href,l)}})();const es="https://sql.js.org/dist/sql-wasm.wasm",ts=async t=>{try{const[s,a]=await Promise.all([t.arrayBuffer(),lt({locateFile:()=>es})]);return new a.Database(new Uint8Array(s))}catch(s){throw console.error("Failed to load database:",s),s}},B=t=>{var s;try{return((s=t.exec("SELECT name FROM sqlite_master WHERE type='table';")[0])==null?void 0:s.values.flat())||[]}catch(a){return console.error("Failed to get table names:",a),[]}},ss=async(t,s)=>{try{const[a,r]=t.exec(` + PRAGMA table_info("${s}"); + PRAGMA foreign_key_list("${s}"); + `),o=a.values.reduce((l,i)=>(l[i[1]]={type:i[2],isPrimaryKey:i[5]===1,isForeignKey:!1},l),{});return r==null||r.values.forEach(l=>{const i=l[3];o[i]&&(o[i].isForeignKey=!0)}),o}catch(a){throw console.error(`Failed to get schema for table "${s}":`,a),a}},Q=t=>{if(t.length===0)return{data:[],columns:[]};const{columns:s,values:a}=t[0];return{data:a.map(o=>Object.fromEntries(s.map((l,i)=>[l,o[i]]))),columns:s}},as=t=>{try{const s=t.export(),a=new Blob([s],{type:"application/x-sqlite3"});Z.saveAs(a,"database.sqlite")}catch(s){throw console.error("Failed to export database:",s),s}},rs=(t,s)=>{const a=t.map(o=>`"${o}"`).join(","),r=s.map(o=>t.map(l=>`"${o[l]??""}"`).join(","));return[a,...r].join(` +`)},z=(t,s,a)=>{try{const r=s.exec(t);if(r.length===0)throw new Error(`Query "${t}" returned no results.`);const{data:o,columns:l}=Q(r),i=rs(l,o),c=new Blob([i],{type:"text/csv;charset=utf-8;"});Z.saveAs(c,`${a}.csv`)}catch(r){throw console.error(`Failed to get CSV for query "${t}":`,r),r}},os=(t,s)=>{const r=B(t)[s],o=`SELECT * FROM "${r}"`;z(o,t,r)},ns=t=>{B(t).forEach(s=>{const a=`SELECT * FROM "${s}"`;z(a,t,s)})},ls=(t,s)=>{z(s,t,"custom_query")},R=nt((t,s)=>({db:null,isLoading:!1,queryError:null,tables:[],selectedTable:"0",tableSchemas:{},rowPerPageOrAuto:"auto",isCustomQuery:!1,loadDatabase:async a=>{t({isLoading:!0,queryError:null});try{const r=await ts(a),o=B(r),l=await Promise.all(o.map(async u=>{const m=r.exec(`SELECT COUNT(*) FROM "${u}"`),p=parseInt(m[0].values[0][0],10),x=await ss(r,u);return{name:u,count:p,schema:x}})),i=l.map(({name:u,count:m})=>({name:u,count:m})),c=l.reduce((u,{name:m,schema:p})=>(u[m]=p,u),{});t({db:r,tables:i,tableSchemas:c,isLoading:!1})}catch(r){console.error("Failed to load database:",r),t({isLoading:!1,queryError:"Failed to load database"})}},query:a=>{const{db:r}=s();return r?r.exec(a):(console.warn("Database is not loaded."),[])},setQueryError:a=>t({queryError:a}),setTables:a=>t({tables:a}),setSelectedTable:a=>t({selectedTable:a}),setTableSchemas:a=>t({tableSchemas:a}),setRowPerPageOrAuto:a=>t({rowPerPageOrAuto:a}),customQuery:"",setIsCustomQuery:a=>t({isCustomQuery:a}),setCustomQuery:a=>t({customQuery:a}),queryHestory:[],setQueryHestory:a=>t({queryHestory:a}),unShiftToQueryHestory:a=>t(r=>({queryHestory:[a,...r.queryHestory]})),expandPage:!1,setExpandPage:a=>t({expandPage:a}),dateFormatValue:"formatDateFormatted",setDateFormatValue:a=>t({dateFormatValue:a})}));function is(t,s,a,r){const{db:o,setQueryError:l,setIsCustomQuery:i,query:c,unShiftToQueryHestory:u,customQuery:m,setCustomQuery:p}=R(),[x,b]=n.useState([]),[f,h]=n.useState([]),[j,S]=n.useState(!0);n.useEffect(()=>{o&&t&&!r&&(S(!0),(async()=>{try{const g=`PRAGMA table_info("${t}");`,D=`SELECT ${c(g)[0].values.map(E=>({name:E[1],type:E[2]})).map(E=>E.type.toUpperCase()==="BLOB"?`hex(${E.name}) as ${E.name}`:E.name).join(", ")} FROM "${t}" LIMIT ${s} OFFSET ${a};`,k=c(D),{data:I,columns:C}=Q(k);h(C),b(I),l(null),p(D),u(D)}catch(g){g instanceof Error&&l(g.message)}finally{S(!1)}})())},[o,t,a,s,r,l,c,p,u]);const w=n.useCallback(()=>{if(m.trim()===""){l(null);return}S(!0),(async()=>{try{const g=c(m),{data:P,columns:N}=Q(g);h(N),b(P),i(!0),l(null)}catch(g){g instanceof Error&&l(g.message)}finally{S(!1)}})()},[m,c,l,i]);return{data:x,columns:f,customQuery:m,setCustomQuery:p,isQueryLoading:j,handleCustomQuery:w}}function cs(t){const{setIsCustomQuery:s}=R(),[a,r]=n.useState(0);n.useEffect(()=>{r(0),s(!1)},[s]);let o=30;if(t==="auto"){const l=window.innerHeight,i=[{height:1700,rowHeight:65},{height:1300,rowHeight:70},{height:1200,rowHeight:75},{height:1100,rowHeight:75},{height:1e3,rowHeight:80},{height:950,rowHeight:85},{height:900,rowHeight:90},{height:850,rowHeight:95},{height:800,rowHeight:100},{height:750,rowHeight:105},{height:700,rowHeight:110},{height:600,rowHeight:120},{height:550,rowHeight:150},{height:500,rowHeight:190},{height:0,rowHeight:280}];let u=120;for(const m of i)if(l>m.height){u=m.rowHeight;break}o=Math.max(1,Math.floor(l/u))}else o=t;return{page:a,setPage:r,rowsPerPage:o}}function d(...t){return ct(it(t))}const U=n.forwardRef(({className:t,type:s,...a},r)=>e.jsx("input",{type:s,className:d("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:r,...a}));U.displayName="Input";const V=q("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),y=n.forwardRef(({className:t,variant:s,size:a,asChild:r=!1,...o},l)=>{const i=r?dt:"button";return e.jsx(i,{className:d(V({variant:s,size:a,className:t})),ref:l,...o})});y.displayName="Button";function ds({page:t,setPage:s,rowsPerPage:a,rowCount:r}){const o=Math.ceil(r/a),l=Math.floor(t/a)+1,i=()=>{l{l>1&&s(t-a)};return e.jsx("section",{className:"fixed bottom-[8px] left-0 right-0 z-10 mx-auto w-[270px]",children:e.jsxs("div",{className:"flex justify-between gap-2 rounded border bg-secondary p-[6px]",children:[e.jsx(y,{onClick:c,title:"Previous page",disabled:l===1,children:e.jsx(Pt,{className:"h-4 w-4"})}),e.jsxs("span",{className:"flex items-center justify-center text-sm",children:["Page ",l," of ",o]}),e.jsx(y,{onClick:i,title:"Next page",disabled:l>=o,children:e.jsx(Lt,{className:"h-4 w-4"})})]})})}const us=ht,ms=gt,fs=bt,we=n.forwardRef(({className:t,children:s,...a},r)=>e.jsxs(X,{ref:r,className:d("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...a,children:[s,e.jsx(ut,{asChild:!0,children:e.jsx(je,{className:"h-4 w-4 opacity-50"})})]}));we.displayName=X.displayName;const Ne=n.forwardRef(({className:t,...s},a)=>e.jsx(ee,{ref:a,className:d("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(kt,{className:"h-4 w-4"})}));Ne.displayName=ee.displayName;const ve=n.forwardRef(({className:t,...s},a)=>e.jsx(te,{ref:a,className:d("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(je,{className:"h-4 w-4"})}));ve.displayName=te.displayName;const Ce=n.forwardRef(({className:t,children:s,position:a="popper",...r},o)=>e.jsx(mt,{children:e.jsxs(se,{ref:o,className:d("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:a,...r,children:[e.jsx(Ne,{}),e.jsx(ft,{className:d("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(ve,{})]})}));Ce.displayName=se.displayName;const Re=n.forwardRef(({className:t,...s},a)=>e.jsx(ae,{ref:a,className:d("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));Re.displayName=ae.displayName;const Se=n.forwardRef(({className:t,children:s,...a},r)=>e.jsxs(re,{ref:r,className:d("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(pt,{children:e.jsx(Ft,{className:"h-4 w-4"})})}),e.jsx(xt,{children:s})]}));Se.displayName=re.displayName;const ps=n.forwardRef(({className:t,...s},a)=>e.jsx(oe,{ref:a,className:d("-mx-1 my-1 h-px bg-muted",t),...s}));ps.displayName=oe.displayName;const xs=q("inline-flex items-center rounded border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Te({className:t,variant:s,...a}){return e.jsx("div",{className:d(xs({variant:s}),t),...a})}function hs(){const{tables:t,selectedTable:s,setSelectedTable:a,setIsCustomQuery:r}=R(),o=n.useMemo(()=>{var u;const c=parseInt(s);return isNaN(c)?0:((u=t[c])==null?void 0:u.count)||0},[t,s]),l=n.useMemo(()=>t.map((c,u)=>e.jsx(Se,{value:`${u}`,children:c.name},c.name)),[t]);function i(c){r(!1),a(c)}return e.jsxs("section",{className:"flex grow items-center justify-center gap-1",children:[e.jsxs(us,{value:s,onValueChange:i,children:[e.jsx(we,{className:"grow",children:e.jsx(fs,{placeholder:"Select a table"})}),e.jsx(Ce,{children:e.jsxs(ms,{children:[e.jsx(Re,{children:"Tables"}),l]})})]}),e.jsx(Te,{title:"Rows",className:"min-w-[100px] grow py-2 text-sm md:min-w-[200px]",variant:"outline",children:e.jsx("span",{className:"w-full text-center",children:o})})]})}const F=t=>t instanceof Date&&!isNaN(t.getTime()),gs=t=>{const s=new Date(t);return F(s)?Yt(s,{addSuffix:!0}):t},bs=t=>{const s=new Date(t);return F(s)?M(s,"MMMM do, yyyy"):t},ys=t=>{const s=new Date(t);return F(s)?M(s,"hh:mm a"):t},js=t=>{const s=new Date(t);return F(s)?M(s,"MM/dd/yyyy"):t},ws=t=>{const s=new Date(t);return F(s)?M(s,"EEEE, MMMM do, yyyy"):t},A={formatDateRelative:{label:"over 56 years ago",func:gs},formatDateFormatted:{label:"January 9th, 1968",func:bs},formatTime:{label:"12:00 am",func:ys},formatDateShort:{label:"01/09/1968",func:js},formatDateLong:{label:"Monday, January 9th, 1968",func:ws}},De=yt,Ee=jt,_=n.forwardRef(({className:t,align:s="start",side:a="bottom",sideOffset:r=4,...o},l)=>e.jsx(ne,{ref:l,align:s,side:a,sideOffset:r,className:d("z-50 w-64 text-balance break-words rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...o}));_.displayName=ne.displayName;const Pe=n.forwardRef(({className:t,...s},a)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:a,className:d("w-full caption-bottom text-sm",t),...s})}));Pe.displayName="Table";const Le=n.forwardRef(({className:t,...s},a)=>e.jsx("thead",{ref:a,className:d("[&_tr]:border-b",t),...s}));Le.displayName="TableHeader";const ke=n.forwardRef(({className:t,...s},a)=>e.jsx("tbody",{ref:a,className:d("[&_tr:last-child]:border-0",t),...s}));ke.displayName="TableBody";const Ns=n.forwardRef(({className:t,...s},a)=>e.jsx("tfoot",{ref:a,className:d("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...s}));Ns.displayName="TableFooter";const O=n.forwardRef(({className:t,...s},a)=>e.jsx("tr",{ref:a,className:d("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...s}));O.displayName="TableRow";const Fe=n.forwardRef(({className:t,...s},a)=>e.jsx("th",{ref:a,className:d("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...s}));Fe.displayName="TableHead";const vs=t=>{const s=new Uint8Array(t.match(/.{1,2}/g).map(r=>parseInt(r,16))),a=new Blob([s],{type:"image/jpeg"});return URL.createObjectURL(a)},Ae=n.forwardRef(({className:t,children:s,dataType:a,...r},o)=>{const l=(a==null?void 0:a.toUpperCase())==="BLOB",i=n.useMemo(()=>typeof s=="string"&&s.length>40?s.slice(0,40)+"...":s,[s]);return e.jsx("td",{ref:o,className:d("max-w-[200px] overflow-hidden truncate text-ellipsis whitespace-nowrap p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...r,children:e.jsxs(De,{children:[e.jsx(Ee,{asChild:!0,children:e.jsx("span",{className:"cursor-pointer hover:underline",children:l?e.jsx("span",{className:"italic opacity-40",children:"BLOB"}):i})}),e.jsx(_,{side:"bottom",align:"start",children:e.jsxs("div",{className:"flex flex-col justify-center gap-2",children:[l&&typeof s=="string"?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:vs(s),alt:"BLOB content",className:"flex max-h-40 flex-col items-center justify-center gap-2 rounded object-contain",onError:c=>{c.currentTarget.style.display="none"}}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Blob length: ",s.length]})]}):e.jsx("span",{className:"max-w-full break-words",children:s}),a&&e.jsx(Te,{className:"w-full self-start text-xs font-semibold",children:a})]})})]})})});Ae.displayName="TableCell";const Cs=n.forwardRef(({className:t,...s},a)=>e.jsx("caption",{ref:a,className:d("mt-4 text-sm text-muted-foreground",t),...s}));Cs.displayName="TableCaption";const Rs=L.memo(({columnSchema:t})=>{var s;return t!=null&&t.isPrimaryKey?e.jsx(At,{className:"h-4 w-4"}):t!=null&&t.isForeignKey?e.jsx(Mt,{className:"h-4 w-4"}):(t==null?void 0:t.type)==="BLOB"?e.jsx(It,{className:"h-4 w-4"}):(s=t==null?void 0:t.type)!=null&&s.includes("DATE")?e.jsx(Ht,{className:"h-4 w-4"}):null}),Ss=L.memo(({col:t,columnSchema:s})=>e.jsx(Fe,{children:e.jsxs(De,{children:[e.jsx(Ee,{asChild:!0,children:e.jsx("span",{className:"cursor-pointer hover:underline",children:e.jsxs("div",{className:"flex gap-1",children:[t,e.jsx(Rs,{columnSchema:s})]})})}),e.jsx(_,{side:"bottom",align:"start",children:(s==null?void 0:s.type)||"Unknown"})]})})),Ts=L.memo(({value:t,dataType:s})=>{const{dateFormatValue:a}=R(),r=s==="DATE"||s==="DATETIME",o=()=>t?r&&A[a]?A[a].func(t):t:e.jsx("span",{className:"italic opacity-40",children:"NULL"});return e.jsx(Ae,{dataType:s,children:o()})});function Ds({data:t,columns:s,tableName:a,tableSchemas:r}){const o=n.useMemo(()=>e.jsx(Le,{children:e.jsx(O,{children:s.map((i,c)=>e.jsx(Ss,{col:i,columnSchema:r[a][i]},c))})}),[s,r,a]),l=n.useMemo(()=>e.jsx(ke,{children:t.map((i,c)=>e.jsx(O,{children:s.map((u,m)=>{var p;return e.jsx(Ts,{value:i[u],dataType:(p=r[a][u])==null?void 0:p.type},m)})},c))}),[t,s,r,a]);return e.jsxs(Pe,{children:[o,l]})}function $({children:t}){return e.jsxs("div",{className:"flex items-center justify-center gap-4 rounded border p-4",children:[e.jsx(Qt,{className:"h-6 w-6"}),e.jsx("span",{className:"font-semibold",children:t})]})}function Me({children:t}){return e.jsxs("div",{className:"flex items-center justify-center gap-4 rounded border p-4",children:[e.jsx(Ot,{className:"h-6 w-6 animate-spin"}),e.jsx("span",{className:"font-semibold",children:t})]})}const Es=Nt,Ps=vt,Ie=n.forwardRef(({className:t,align:s="center",sideOffset:a=4,...r},o)=>e.jsx(wt,{children:e.jsx(le,{ref:o,align:s,sideOffset:a,className:d("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r})}));Ie.displayName=le.displayName;function Ls(){const{selectedTable:t,tables:s,customQuery:a,db:r}=R(),o=n.useCallback((i,c,u,m)=>e.jsx(y,{className:m,onClick:i,title:u,children:e.jsx("span",{className:"ml-2",children:c})}),[]),l=n.useMemo(()=>{var i;return r&&e.jsxs("div",{className:"flex flex-col gap-1",children:[o(()=>as(r),"Export as SQLite","Download database as SQLite"),o(()=>os(r,parseInt(t)),`Export ${((i=s[parseInt(t)])==null?void 0:i.name)||"selected"} table as CSV`,"Export selected table as CSV"),o(()=>ns(r),"Export all tables as CSV","Export all tables as CSV"),o(()=>ls(r,a),"Export custom query as CSV","Export the result of the custom query as CSV")]})},[r,o,t,s,a]);return e.jsxs(Es,{children:[e.jsx(Ps,{asChild:!0,children:e.jsx(y,{title:"Open export options",children:e.jsx($t,{className:"h-5 w-5"})})}),e.jsx(Ie,{align:"end",className:"w-80",children:l})]})}function ks(){const{tables:t,selectedTable:s,tableSchemas:a,queryError:r,setQueryError:o,rowPerPageOrAuto:l,isCustomQuery:i,setIsCustomQuery:c,customQuery:u,setCustomQuery:m,expandPage:p,setExpandPage:x}=R(),{page:b,setPage:f,rowsPerPage:h}=cs(l),j=n.useMemo(()=>{var C;return(C=t[parseInt(s)])==null?void 0:C.name},[t,s]),S=n.useMemo(()=>{var C;return((C=t[parseInt(s)])==null?void 0:C.count)||0},[t,s]),{data:w,columns:g,isQueryLoading:P,handleCustomQuery:N}=is(j,h,b,i),T=n.useCallback(()=>{o(null),m(""),c(!1)},[c,o,m]),D=n.useCallback(()=>{f(0),T()},[T,f]);n.useEffect(()=>{f(0)},[s]);const k=n.useMemo(()=>e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row",children:[e.jsx(U,{type:"text",value:u,onChange:C=>m(C.target.value),placeholder:"Enter your custom query",className:"w-full"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(y,{className:"w-full",onClick:N,title:"Run custom query",children:e.jsx(qt,{className:"h-5 w-5"})}),e.jsx(y,{className:"w-full",onClick:T,title:"Reset query",children:e.jsx(Bt,{className:"h-5 w-5"})}),e.jsx(y,{className:"w-full",onClick:D,title:"Reset to first page",disabled:b===0,children:e.jsx(zt,{className:"h-5 w-5"})})]})]}),[u,N,T,D,b]),I=n.useMemo(()=>P?e.jsxs(Me,{children:["Loading ",j]}):w.length>0?e.jsx("div",{className:"rounded border",children:e.jsx(Ds,{data:w,columns:g,tableName:j,tableSchemas:a})}):e.jsx($,{children:`Table ${j} is empty`}),[P,w,g,j,a]);return e.jsxs("div",{className:"flex flex-col gap-3 pb-8",children:[e.jsxs("section",{className:"flex flex-col gap-2 rounded border p-3 pb-2",children:[e.jsxs("div",{className:"flex h-full gap-1",children:[e.jsx(hs,{}),e.jsxs("div",{className:"ml-1 flex gap-1",children:[e.jsx(Ls,{}),e.jsx(y,{className:"hidden expand:block",onClick:()=>x(!p),title:"Toggle page size",children:p?e.jsx(Ut,{className:"h-5 w-5"}):e.jsx(Vt,{className:"h-5 w-5"})})]})]}),k,r&&e.jsx("p",{className:"text-center text-xs capitalize text-red-500",children:r})]}),I,!i&&e.jsx(ds,{page:b,setPage:f,rowsPerPage:h,rowCount:S})]})}const He=({shouldScaleBackground:t=!0,...s})=>e.jsx(v.Root,{shouldScaleBackground:t,...s});He.displayName="Drawer";const Fs=v.Trigger,As=v.Portal,Ms=v.Close,Qe=n.forwardRef(({className:t,...s},a)=>e.jsx(v.Overlay,{ref:a,className:d("fixed inset-0 z-50 bg-black/80",t),...s}));Qe.displayName=v.Overlay.displayName;const Oe=n.forwardRef(({className:t,children:s,...a},r)=>e.jsxs(As,{children:[e.jsx(Qe,{}),e.jsxs(v.Content,{ref:r,className:d("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",t),...a,children:[e.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),s]})]}));Oe.displayName="DrawerContent";const $e=({className:t,...s})=>e.jsx("div",{className:d("grid gap-1.5 p-4 text-center sm:text-left",t),...s});$e.displayName="DrawerHeader";const qe=({className:t,...s})=>e.jsx("div",{className:d("mt-auto flex flex-col gap-2 p-4",t),...s});qe.displayName="DrawerFooter";const Be=n.forwardRef(({className:t,...s},a)=>e.jsx(v.Title,{ref:a,className:d("text-lg font-semibold leading-none tracking-tight",t),...s}));Be.displayName=v.Title.displayName;const ze=n.forwardRef(({className:t,...s},a)=>e.jsx(v.Description,{ref:a,className:d("text-sm text-muted-foreground",t),...s}));ze.displayName=v.Description.displayName;const Ue=n.forwardRef(({className:t,children:s,...a},r)=>e.jsxs(ie,{ref:r,className:d("relative overflow-hidden",t),...a,children:[e.jsx(Ct,{className:"h-full w-full rounded-[inherit]",children:s}),e.jsx(Ve,{}),e.jsx(Rt,{})]}));Ue.displayName=ie.displayName;const Ve=n.forwardRef(({className:t,orientation:s="vertical",...a},r)=>e.jsx(ce,{ref:r,orientation:s,className:d("flex touch-none select-none transition-colors",s==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",s==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...a,children:e.jsx(St,{className:"relative flex-1 rounded-full bg-border"})}));Ve.displayName=ce.displayName;const _e=n.forwardRef(({className:t,orientation:s="horizontal",decorative:a=!0,...r},o)=>e.jsx(de,{ref:o,decorative:a,orientation:s,className:d("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...r}));_e.displayName=de.displayName;const Is=q("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ge=n.forwardRef(({className:t,...s},a)=>e.jsx(ue,{ref:a,className:d(Is(),t),...s}));Ge.displayName=ue.displayName;const Ke=n.forwardRef(({className:t,...s},a)=>e.jsx(me,{className:d("grid gap-2",t),...s,ref:a}));Ke.displayName=me.displayName;const Je=n.forwardRef(({className:t,...s},a)=>e.jsx(fe,{ref:a,className:d("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(Tt,{className:"flex items-center justify-center",children:e.jsx(_t,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Je.displayName=fe.displayName;const G="rowsPerPage",K="dateFormat";function Hs(){const{setRowPerPageOrAuto:t,setIsCustomQuery:s,queryHestory:a,dateFormatValue:r,setDateFormatValue:o}=R(),[l,i]=n.useState(null),[c,u]=n.useState(!1);n.useEffect(()=>{const f=localStorage.getItem(G),h=localStorage.getItem(K);if(f)if(f==="auto")u(!0);else{const j=Number(f);i(j),t(j)}h&&o(h)},[t,o]);const m=n.useCallback(f=>{const h=Number(f.target.value);isNaN(h)||(i(h),u(!1))},[]),p=n.useCallback(()=>{u(f=>!f)},[]),x=n.useCallback(()=>{if(s(!1),l===null){H.error("Please provide a number of rows per page or set it to auto.");return}if(l<1){H.error("Please provide a positive number of rows per page.");return}const f=c?"auto":l.toString();localStorage.setItem(G,f),t(c?"auto":l)},[l,c,s,t]),b=f=>{o(f),localStorage.setItem(K,f)};return e.jsxs(He,{children:[e.jsx(Fs,{asChild:!0,children:e.jsx(y,{className:"grow",title:"Open settings drawer",children:e.jsx(Gt,{className:"h-5 w-5"})})}),e.jsx(Oe,{children:e.jsxs("div",{className:"mx-auto w-full max-w-md",children:[e.jsxs($e,{children:[e.jsx(Be,{children:"Settings"}),e.jsx(ze,{children:"Personalize your site experience here."})]}),e.jsxs("div",{className:"flex flex-col gap-4 p-4 pb-0",children:[e.jsx(Qs,{selectedRowsPerPage:l,isAutoRowsPerPage:c,handleInputChange:m,toggleAutoRowsPerPage:p,handleRowsPerPageSave:x}),e.jsx(Os,{dateFormatValue:r,handleDateFormatChange:b}),e.jsx($s,{queryHestory:a})]}),e.jsx(qe,{children:e.jsx(Ms,{asChild:!0,children:e.jsx(y,{title:"Close settings drawer",variant:"outline",children:"Close"})})})]})})]})}function Qs({selectedRowsPerPage:t,isAutoRowsPerPage:s,handleInputChange:a,toggleAutoRowsPerPage:r,handleRowsPerPageSave:o}){return e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-sm text-muted-foreground",children:"Rows Per Page"}),e.jsxs("div",{className:"flex items-center justify-center gap-1 rounded border p-2",children:[e.jsx(U,{value:t||"",onChange:a,disabled:s,placeholder:"Number of rows",type:"number",name:"rowsPerPage"}),e.jsx("span",{className:"h-full text-center text-sm text-muted-foreground",children:"OR"}),e.jsx(y,{className:s?"border border-primary":"",onClick:r,title:"Toggle auto rows per page",variant:"outline",children:"Auto Calculate"})]}),e.jsx(y,{className:"mt-2 w-full",onClick:o,title:"Save rows per page settings",variant:"outline",children:e.jsx("span",{children:"Save"})})]})}function Os({dateFormatValue:t,handleDateFormatChange:s}){return e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-sm text-muted-foreground",children:"Date type format"}),e.jsxs(Ke,{className:"flex flex-col gap-2",name:"dateType",value:t,onValueChange:s,children:[e.jsx(J,{value:"default",label:"Default"}),Object.keys(A).map(a=>e.jsx(J,{value:a,label:A[a].label},a))]})]})}function J({value:t,label:s}){return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Je,{value:t,id:`r-${t}`}),e.jsx(Ge,{htmlFor:`r-${t}`,children:s})]})}function $s({queryHestory:t}){return e.jsxs("div",{children:[e.jsxs("p",{className:"mb-1 text-sm text-muted-foreground",children:["Query History (",t.length,")"]}),e.jsx(Ue,{className:"h-48 rounded-md border",children:e.jsx("div",{className:"p-4",children:t.map((s,a)=>e.jsxs("div",{children:[e.jsx("div",{className:"text-xs",children:s}),e.jsx(_e,{className:"my-2"})]},a))})})]})}const W="darkMode",Y="animate-circular-reveal";function We(){const[t,s]=n.useState(!1),a=n.useCallback(o=>{s(o),document.body.classList.toggle("dark",o),localStorage.setItem(W,o.toString()),document.body.classList.add(Y),setTimeout(()=>{document.body.classList.remove(Y)},500)},[]);n.useEffect(()=>{const o=localStorage.getItem(W),l=o!==null?o==="true":window.matchMedia("(prefers-color-scheme: dark)").matches;a(l);const i=u=>{a(u.matches)},c=window.matchMedia("(prefers-color-scheme: dark)");return c.addEventListener("change",i),()=>{c.removeEventListener("change",i)}},[a]);const r=n.useCallback(()=>{a(!t)},[t,a]);return e.jsx(y,{className:"relative grow",onClick:r,title:t?"Enable light mode":"Enable dark mode",children:t?e.jsx(Kt,{className:"h-5 w-5"}):e.jsx(Jt,{className:"h-5 w-5"})})}const qs={"application/vnd.sqlite3":[".sqlite",".sqlite3"],"application/x-sqlite3":[".sqlite",".sqlite3"],"application/octet-stream":[".db"],"application/sql":[".sql"]},Bs={CHINOOK:"https://github.com/vwh/sqlite-viewer/raw/main/db_examples/chinook.db"};function zs(){const{loadDatabase:t,setTables:s,setSelectedTable:a,db:r}=R(),[o,l]=n.useState([]),i=n.useCallback(async(x,b)=>{if(l([]),s([]),a("0"),x.length>0&&await t(x[0]),b.length>0){const f=b.flatMap(h=>h.errors);l(f)}},[t,s,a]),{getRootProps:c,getInputProps:u}=Zt({onDrop:i,multiple:!1,accept:qs}),m=n.useCallback(x=>e.jsxs("div",{className:`flex h-full items-center justify-center gap-2 ${x?"px-[10px]":"px-0"}`,children:[e.jsxs("div",{...c(),className:`flex h-full grow cursor-pointer flex-col items-center justify-center rounded border p-6 text-center ${x?"py-0":"py-32"}`,children:[e.jsx("input",{id:"file-upload",...u()}),e.jsx("label",{htmlFor:"file-upload",className:"sr-only",children:"Upload SQLite File"}),e.jsx("p",{className:"hidden sm:block",children:"Drag and drop a SQLite file here, or click to select one"}),e.jsx("p",{className:"block sm:hidden",children:x?"Click to select a file":"Click to select a SQLite file"}),!x&&e.jsx("a",{href:Bs.CHINOOK,className:"text-sm text-link hover:underline",title:"Download sample file",children:"Or download & try this sample file"})]}),x&&e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(We,{}),e.jsx(Hs,{})]})]}),[c,u]),p=n.useMemo(()=>m(!!r),[m,r]);return e.jsxs("section",{children:[p,e.jsx(Us,{errors:o})]})}const Us=L.memo(({errors:t})=>(L.useEffect(()=>{t==null||t.forEach(s=>H(s.message,{position:"bottom-right"}))},[t]),null));function Vs(){const[t,s]=n.useState(()=>document.body.classList.contains("dark"));return n.useEffect(()=>{const a=new MutationObserver(()=>{s(document.body.classList.contains("dark"))});return a.observe(document.body,{attributes:!0,attributeFilter:["class"]}),()=>a.disconnect()},[]),t}function _s(){const s=Vs()?"/sqlite-dark.webp":"/sqlite-light.webp";return e.jsx("section",{className:"flex justify-center rounded border py-3",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("img",{id:"logo",title:"SQLite Logo",src:s,alt:"SQLite Logo",width:"170",height:"80",draggable:"false"}),e.jsx("p",{className:"text-sm",children:"View SQLite files in the browser"})]})})}const Gs=Et,Ks=Dt,Ye=n.forwardRef(({className:t,...s},a)=>e.jsx(pe,{className:d("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s,ref:a}));Ye.displayName=pe.displayName;const Ze=n.forwardRef(({className:t,...s},a)=>e.jsxs(Ks,{children:[e.jsx(Ye,{}),e.jsx(xe,{ref:a,className:d("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...s})]}));Ze.displayName=xe.displayName;const Xe=({className:t,...s})=>e.jsx("div",{className:d("flex flex-col space-y-2 text-left",t),...s});Xe.displayName="AlertDialogHeader";const et=({className:t,...s})=>e.jsx("div",{className:d("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});et.displayName="AlertDialogFooter";const tt=n.forwardRef(({className:t,...s},a)=>e.jsx(he,{ref:a,className:d("text-lg font-semibold",t),...s}));tt.displayName=he.displayName;const st=n.forwardRef(({className:t,...s},a)=>e.jsx(ge,{ref:a,className:d("text-sm",t),...s}));st.displayName=ge.displayName;const at=n.forwardRef(({className:t,...s},a)=>e.jsx(be,{ref:a,className:d(V(),t),...s}));at.displayName=be.displayName;const rt=n.forwardRef(({className:t,...s},a)=>e.jsx(ye,{ref:a,className:d(V({variant:"outline"}),"mt-2 sm:mt-0",t),...s}));rt.displayName=ye.displayName;function Js({showDialog:t,setShowDialog:s,fn:a}){return e.jsx(Gs,{open:t,onOpenChange:s,children:e.jsxs(Ze,{children:[e.jsxs(Xe,{children:[e.jsx(tt,{children:"Retry using a proxy?"}),e.jsx(st,{children:"Failed to load the database from the provided URL due to possible CORS restrictions."})]}),e.jsx("div",{className:"text-sm font-semibold",children:"Using the proxy may expose your database to corsproxy.io services."}),e.jsxs(et,{children:[e.jsx(rt,{onClick:()=>s(!1),children:"Cancel"}),e.jsx(at,{onClick:a,children:"Confirm"})]})]})})}const Ws="https://github.com/vwh/sqlite-viewer";function Ys(){return e.jsxs("footer",{className:"flex items-center justify-between rounded border p-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"hidden text-xs sm:block",children:"No file will be uploaded to server. using JavaScript, sql.js"}),e.jsx("p",{className:"block text-xs sm:hidden",children:"No file uploads to server."}),e.jsxs("a",{href:Ws,target:"_blank",className:"flex items-center gap-1 text-sm text-link hover:underline",title:"Star on GitHub",children:[e.jsx(Wt,{className:"h-4 w-4"}),e.jsx("span",{children:"Star us on GitHub"})]})]}),e.jsx("div",{className:"flex gap-1",children:e.jsx(We,{})})]})}function Zs(){const{db:t,tables:s,isLoading:a,loadDatabase:r,expandPage:o}=R(),[l,i]=n.useState(null),[c,u]=n.useState(!1),[m,p]=n.useState(null),[x,b]=n.useState(!1),f=n.useRef(!1),h=n.useCallback(async(w,g=!1)=>{if(!/^(https?:\/\/(?:www\.)?[a-zA-Z0-9-]{1,256}\.[a-zA-Z]{2,6}(?:\/[^\s]*)?)$/i.test(w)){i("Invalid URL");return}try{b(!0);const N=g?`https://corsproxy.io/?${encodeURIComponent(w)}`:w,T=await fetch(N);if(!T.ok)throw new Error("URL not found or invalid");const D=await T.blob(),k=new File([D],"database.sqlite");await r(k),i(null)}catch(N){g?i(`Error whilefetching, ${N instanceof Error?N.message:String(N)}`):(p(w),u(!0))}finally{b(!1)}},[r]);n.useEffect(()=>{if(f.current)return;const g=new URLSearchParams(window.location.search).get("url");g&&(h(decodeURIComponent(g)),f.current=!0)},[h]);const j=n.useCallback(()=>{m&&(h(m,!0),u(!1))},[m,h]),S=()=>a||x?e.jsxs(Me,{children:[x?"Fetching":"Loading"," SQLite file"]}):l&&!t?e.jsx($,{children:l}):t?s.length>0?e.jsx(ks,{}):e.jsx($,{children:"Your database is empty, no tables found"}):null;return e.jsxs("main",{className:`mx-auto flex h-screen flex-col gap-3 p-4 ${o?"w-full":"container"}`,children:[!t&&e.jsx(_s,{}),e.jsx(zs,{}),S(),e.jsx(Js,{showDialog:c,setShowDialog:u,fn:j}),!t&&e.jsx(Ys,{})]})}const Xs=({...t})=>e.jsx(Xt,{className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-primary group-[.toaster]:text-background group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...t});ot.createRoot(document.getElementById("root")).render(e.jsxs(L.StrictMode,{children:[e.jsx(Zs,{}),e.jsx(Xs,{})]})); diff --git a/assets/index-DKPTwSyp.js.gz b/assets/index-DKPTwSyp.js.gz new file mode 100644 index 0000000..6136c22 Binary files /dev/null and b/assets/index-DKPTwSyp.js.gz differ diff --git a/index.html b/index.html index 58d25d6..6089a16 100644 --- a/index.html +++ b/index.html @@ -90,7 +90,7 @@ as="image" type="image/webp" /> - + diff --git a/index.html.gz b/index.html.gz index d6109a1..f8e4d1e 100644 Binary files a/index.html.gz and b/index.html.gz differ diff --git a/sw.js b/sw.js index d822501..5b7cccb 100644 --- a/sw.js +++ b/sw.js @@ -1 +1 @@ -if(!self.define){let s,e={};const l=(l,r)=>(l=new URL(l+".js",r).href,e[l]||new Promise((e=>{if("document"in self){const s=document.createElement("script");s.src=l,s.onload=e,document.head.appendChild(s)}else s=l,importScripts(l),e()})).then((()=>{let s=e[l];if(!s)throw new Error(`Module ${l} didn’t register its module`);return s})));self.define=(r,i)=>{const n=s||("document"in self?document.currentScript.src:"")||location.href;if(e[n])return;let u={};const t=s=>l(s,n),o={module:{uri:n},exports:u,require:t};e[n]=Promise.all(r.map((s=>o[s]||t(s)))).then((s=>(i(...s),u)))}}define(["./workbox-7cfec069"],(function(s){"use strict";self.addEventListener("message",(s=>{s.data&&"SKIP_WAITING"===s.data.type&&self.skipWaiting()})),s.precacheAndRoute([{url:"assets/@floating-ui-DGkE6due.js",revision:null},{url:"assets/@radix-ui-Dtk-Z1Mr.js",revision:null},{url:"assets/aria-hidden-DQ5UC2Eg.js",revision:null},{url:"assets/attr-accept-BWI1aNlo.js",revision:null},{url:"assets/class-variance-authority-Bb4qSo10.js",revision:null},{url:"assets/clsx-B-dksMZM.js",revision:null},{url:"assets/date-fns-fqmN70Xj.js",revision:null},{url:"assets/detect-node-es-l0sNRNKZ.js",revision:null},{url:"assets/file-saver-DhbZvGod.js",revision:null},{url:"assets/file-selector-CBHVlu32.js",revision:null},{url:"assets/get-nonce-C-Z93AgS.js",revision:null},{url:"assets/index-D1aL-xAe.js",revision:null},{url:"assets/index-DFpduaB_.css",revision:null},{url:"assets/lucide-react-Ch2vEKIM.js",revision:null},{url:"assets/prop-types-psm7UO16.js",revision:null},{url:"assets/react-DmpIMwDM.js",revision:null},{url:"assets/react-dom-tIxIBQuZ.js",revision:null},{url:"assets/react-dropzone-D-IBOhIS.js",revision:null},{url:"assets/react-remove-scroll-bar-DZjhPxUV.js",revision:null},{url:"assets/react-remove-scroll-BOyN_WUU.js",revision:null},{url:"assets/react-style-singleton-CpxBwIWS.js",revision:null},{url:"assets/scheduler-CzFDRTuY.js",revision:null},{url:"assets/sonner-BJG0sXho.js",revision:null},{url:"assets/sql.js-lzln2bbd.js",revision:null},{url:"assets/tailwind-merge-BkWO730n.js",revision:null},{url:"assets/tslib-CuZy2iRz.js",revision:null},{url:"assets/use-callback-ref-DRzK4jWO.js",revision:null},{url:"assets/use-sidecar-D8_hMcUG.js",revision:null},{url:"assets/use-sync-external-store-ByYeed7R.js",revision:null},{url:"assets/vaul-Bkmv171v.js",revision:null},{url:"assets/zustand-oOA47TU4.js",revision:null},{url:"index.html",revision:"790fe2b5dd425f60d9b867deb7819370"},{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"manifest.webmanifest",revision:"662c9ac5fe5300a257a596b0ad6130ea"}],{}),s.cleanupOutdatedCaches(),s.registerRoute(new s.NavigationRoute(s.createHandlerBoundToURL("index.html")))})); +if(!self.define){let s,e={};const l=(l,r)=>(l=new URL(l+".js",r).href,e[l]||new Promise((e=>{if("document"in self){const s=document.createElement("script");s.src=l,s.onload=e,document.head.appendChild(s)}else s=l,importScripts(l),e()})).then((()=>{let s=e[l];if(!s)throw new Error(`Module ${l} didn’t register its module`);return s})));self.define=(r,i)=>{const n=s||("document"in self?document.currentScript.src:"")||location.href;if(e[n])return;let u={};const t=s=>l(s,n),o={module:{uri:n},exports:u,require:t};e[n]=Promise.all(r.map((s=>o[s]||t(s)))).then((s=>(i(...s),u)))}}define(["./workbox-7cfec069"],(function(s){"use strict";self.addEventListener("message",(s=>{s.data&&"SKIP_WAITING"===s.data.type&&self.skipWaiting()})),s.precacheAndRoute([{url:"assets/@floating-ui-DGkE6due.js",revision:null},{url:"assets/@radix-ui-Dtk-Z1Mr.js",revision:null},{url:"assets/aria-hidden-DQ5UC2Eg.js",revision:null},{url:"assets/attr-accept-BWI1aNlo.js",revision:null},{url:"assets/class-variance-authority-Bb4qSo10.js",revision:null},{url:"assets/clsx-B-dksMZM.js",revision:null},{url:"assets/date-fns-fqmN70Xj.js",revision:null},{url:"assets/detect-node-es-l0sNRNKZ.js",revision:null},{url:"assets/file-saver-DhbZvGod.js",revision:null},{url:"assets/file-selector-CBHVlu32.js",revision:null},{url:"assets/get-nonce-C-Z93AgS.js",revision:null},{url:"assets/index-DFpduaB_.css",revision:null},{url:"assets/index-DKPTwSyp.js",revision:null},{url:"assets/lucide-react-Ch2vEKIM.js",revision:null},{url:"assets/prop-types-psm7UO16.js",revision:null},{url:"assets/react-DmpIMwDM.js",revision:null},{url:"assets/react-dom-tIxIBQuZ.js",revision:null},{url:"assets/react-dropzone-D-IBOhIS.js",revision:null},{url:"assets/react-remove-scroll-bar-DZjhPxUV.js",revision:null},{url:"assets/react-remove-scroll-BOyN_WUU.js",revision:null},{url:"assets/react-style-singleton-CpxBwIWS.js",revision:null},{url:"assets/scheduler-CzFDRTuY.js",revision:null},{url:"assets/sonner-BJG0sXho.js",revision:null},{url:"assets/sql.js-lzln2bbd.js",revision:null},{url:"assets/tailwind-merge-BkWO730n.js",revision:null},{url:"assets/tslib-CuZy2iRz.js",revision:null},{url:"assets/use-callback-ref-DRzK4jWO.js",revision:null},{url:"assets/use-sidecar-D8_hMcUG.js",revision:null},{url:"assets/use-sync-external-store-ByYeed7R.js",revision:null},{url:"assets/vaul-Bkmv171v.js",revision:null},{url:"assets/zustand-oOA47TU4.js",revision:null},{url:"index.html",revision:"0bef841db9b30127268e8d17f112eaca"},{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"manifest.webmanifest",revision:"662c9ac5fe5300a257a596b0ad6130ea"}],{}),s.cleanupOutdatedCaches(),s.registerRoute(new s.NavigationRoute(s.createHandlerBoundToURL("index.html")))}));