diff --git a/assets/index-B79UIr58.js.gz b/assets/index-B79UIr58.js.gz deleted file mode 100644 index 08bd782..0000000 Binary files a/assets/index-B79UIr58.js.gz and /dev/null differ diff --git a/assets/index-B79UIr58.js b/assets/index-CdfIWGO4.js similarity index 62% rename from assets/index-B79UIr58.js rename to assets/index-CdfIWGO4.js index f91d15e..49d873c 100644 --- a/assets/index-B79UIr58.js +++ b/assets/index-CdfIWGO4.js @@ -1,5 +1,5 @@ -import{r as n,j as e,R as k}from"./react-DmpIMwDM.js";import{c as Ct}from"./react-dom-tIxIBQuZ.js";import{c as Et}from"./zustand-BpWCCnYR.js";import{i as vt}from"./sql.js-Ch_tM77n.js";import{F as ce}from"./file-saver-DhbZvGod.js";import{S as Rt,c as de,I as Tt,d as me,e as ue,f as St,g as fe,V as At,L as xe,h as pe,i as Dt,j as Lt,k as he,l as It,G as Ft,m as kt,n as ge,o as Ot,p as Pt,q as Mt,r as be,s as Bt,t as Ut,u as ye,v as Qt,w as $t,x as je,y as Ht,z as Ne,A as we,B as Ce,E as Ee,F as qt,H as ve,J as Re,K as Te,M as Se,N as Ae,Q as De,U as Vt,W as zt}from"./@radix-ui-E10elJI3.js";import{c as Y}from"./class-variance-authority-Bb4qSo10.js";import{c as Gt}from"./clsx-B-dksMZM.js";import{t as _t}from"./tailwind-merge-BkWO730n.js";import{C as Wt,a as Kt,b as Le,c as Yt,d as Xt,A as Jt,e as Zt,f as es,K as ts,g as ss,h as as,i as Ie,T as rs,H as os,j as ns,k as ls,I as is,l as cs,L as ds,m as ms,F as us,P as fs,n as xs,o as ps,M as hs,p as gs,q as bs,R as ys,r as js,s as Ns,S as Fe,t as ws,u as Cs,G as Es,v as vs,Z as Rs,w as Ts,x as Ss,y as As}from"./lucide-react-C1VID-M1.js";import{f as Ds,a as X}from"./date-fns-fqmN70Xj.js";import{f as Ls}from"./sql-formatter-BoZ82dp4.js";import{G as Is,I as Fs,t as ks}from"./@codemirror-CCjSF3Vf.js";import{R as Os,n as Ps}from"./@uiw-CvcbIrPa.js";import{u as Ms}from"./react-dropzone-D-IBOhIS.js";import{J as $,T as Bs}from"./sonner-BJG0sXho.js";import{D as v}from"./vaul-LE4MEETp.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-DdUjdMBw.js";import"./nearley-CG12bGQB.js";import"./@lezer-DgLl1T_N.js";import"./crelt-C8TCjufn.js";import"./style-mod-Bc2inJdb.js";import"./w3c-keyname-Vcq4gwWv.js";import"./@babel-BjXSgPXB.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 Us="/sql.wasm",Qs=async t=>{try{const[s,a]=await Promise.all([t.arrayBuffer(),vt({locateFile:()=>Us})]);return new a.Database(new Uint8Array(s))}catch(s){throw console.error("Failed to load database:",s),s}},J=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),[]}},$s=async(t,s)=>{try{const[a,r]=t.exec(` +import{r as n,j as e,R as k}from"./react-DmpIMwDM.js";import{c as Ct}from"./react-dom-tIxIBQuZ.js";import{c as Et}from"./zustand-BpWCCnYR.js";import{i as vt}from"./sql.js-Ch_tM77n.js";import{F as ce}from"./file-saver-DhbZvGod.js";import{S as Rt,c as de,I as Tt,d as me,e as ue,f as St,g as fe,V as At,L as xe,h as pe,i as Dt,j as Lt,k as he,l as It,G as Ft,m as kt,n as ge,o as Ot,p as Pt,q as Mt,r as be,s as Bt,t as Ut,u as ye,v as Qt,w as $t,x as je,y as Ht,z as Ne,A as we,B as Ce,E as Ee,F as qt,H as ve,J as Re,K as Te,M as Se,N as Ae,Q as De,U as Vt,W as zt}from"./@radix-ui-E10elJI3.js";import{c as Y}from"./class-variance-authority-Bb4qSo10.js";import{c as Gt}from"./clsx-B-dksMZM.js";import{t as _t}from"./tailwind-merge-BkWO730n.js";import{C as Wt,a as Kt,b as Le,c as Yt,d as Xt,A as Jt,e as Zt,f as es,K as ts,g as ss,h as as,i as Ie,T as rs,H as os,j as ns,k as ls,I as is,l as cs,L as ds,m as ms,F as us,P as fs,n as xs,o as ps,M as hs,p as gs,q as bs,R as ys,r as js,s as Ns,S as Fe,t as ws,u as Cs,G as Es,v as vs,Z as Rs,w as Ts,x as Ss,y as As}from"./lucide-react-C1VID-M1.js";import{f as Ds,a as X}from"./date-fns-fqmN70Xj.js";import{f as Ls}from"./sql-formatter-BoZ82dp4.js";import{G as Is,I as Fs,t as ks}from"./@codemirror-CCjSF3Vf.js";import{R as Os,n as Ps}from"./@uiw-CvcbIrPa.js";import{u as Ms}from"./react-dropzone-D-IBOhIS.js";import{J as $,T as Bs}from"./sonner-BJG0sXho.js";import{D as T}from"./vaul-LE4MEETp.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-DdUjdMBw.js";import"./nearley-CG12bGQB.js";import"./@lezer-DgLl1T_N.js";import"./crelt-C8TCjufn.js";import"./style-mod-Bc2inJdb.js";import"./w3c-keyname-Vcq4gwWv.js";import"./@babel-BjXSgPXB.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 Us="/sql.wasm",Qs=async t=>{try{const[s,a]=await Promise.all([t.arrayBuffer(),vt({locateFile:()=>Us})]);return new a.Database(new Uint8Array(s))}catch(s){throw console.error("Failed to load database:",s),s}},J=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),[]}},$s=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]?i[2].toUpperCase():i[2],isPrimaryKey:i[5]===1,isForeignKey:!1,nullable:i[3]===0},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}},_=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}},Hs=t=>{try{const s=t.export(),a=new Blob([s],{type:"application/x-sqlite3"});ce.saveAs(a,"database.sqlite")}catch(s){throw console.error("Failed to export database:",s),s}},qs=(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}=_(r),i=qs(l,o),c=new Blob([i],{type:"text/csv;charset=utf-8;"});ce.saveAs(c,`${a}.csv`)}catch(r){throw console.error(`Failed to get CSV for query "${t}":`,r),r}},Vs=(t,s)=>{const r=J(t)[s],o=`SELECT * FROM "${r}"`;Z(o,t,r)},zs=t=>{J(t).forEach(s=>{const a=`SELECT * FROM "${s}"`;Z(a,t,s)})},Gs=(t,s)=>{Z(s,t,"custom_query")},j=Et((t,s)=>({db:null,isLoading:!1,loadDatabase:async a=>{t({isLoading:!0,queryError:null});try{const r=await Qs(a),o=J(r),l=await Promise.all(o.map(async d=>{const u=r.exec(`SELECT COUNT(*) FROM "${d}"`),f=parseInt(u[0].values[0][0],10),p=await $s(r,d);return{name:d,count:f,schema:p}})),i=l.map(({name:d,count:u})=>({name:d,count:u})),c=l.reduce((d,{name:u,schema:f})=>(d[u]=f,d),{});t({db:r,tables:i,tableSchemas:c,isLoading:!1})}catch(r){throw console.error("Failed to load database:",r),t({isLoading:!1,queryError:"Failed to load database"}),r}},tables:[],setTables:a=>t({tables:a}),selectedTable:"0",setSelectedTable:a=>t({selectedTable:a}),tableSchemas:{},customQuery:"",setIsCustomQuery:a=>t({isCustomQuery:a}),setCustomQuery:a=>t({customQuery:a}),isCustomQuery:!1,queryError:null,setQueryError:a=>t({queryError:a}),query:a=>{const{db:r}=s();return r?r.exec(a):(console.warn("Database is not loaded."),[])},rowPerPageOrAuto:"auto",setRowPerPageOrAuto:a=>t({rowPerPageOrAuto:a}),queryHistory:[],unShiftToQueryHistory:a=>t(r=>({queryHistory:[a,...r.queryHistory]})),expandPage:!1,setExpandPage:a=>t({expandPage:a}),dateFormatValue:"formatDateFormatted",setDateFormatValue:a=>t({dateFormatValue:a}),filters:{},setFilters:a=>t({filters:a}),appendToFilters:(a,r)=>t(o=>({filters:{...o.filters,[a]:r}})),filtersNeedClear:!1,setFiltersNeedClear:a=>t({filtersNeedClear:a}),totalRows:0,setTotalRows:a=>t({totalRows:a}),orderBy:null,setOrderBy:a=>t({orderBy:a}),orderByDirection:"ASC",setOrderByDirection:a=>t({orderByDirection:a})}));function _s(t,s,a){const{db:r,setQueryError:o,setIsCustomQuery:l,query:i,unShiftToQueryHistory:c,customQuery:d,setCustomQuery:u,filters:f,totalRows:p,setTotalRows:h,orderBy:x,orderByDirection:g,selectedTable:D,tables:S}=j(),[N,w]=n.useState([]),[L,C]=n.useState([]),[R,A]=n.useState(!0),I=n.useMemo(()=>Object.fromEntries(Object.entries(f).filter(([,b])=>b!=="")),[f]),T=n.useMemo(()=>Object.entries(I).map(([b,E])=>`LOWER(${b}) LIKE LOWER('%${E}%')`).join(" AND "),[I]);n.useEffect(()=>{if(!r||!t)return;(async()=>{A(!0);try{const E=`PRAGMA table_info("${t}");`,U=i(E)[0].values.map(F=>({name:F[1],type:F[2]})).map(F=>F.type.toUpperCase()==="BLOB"?`hex(${F.name}) as ${F.name}`:F.name).join(", "),bt=`SELECT COUNT(*) as count FROM "${t}"${T?` WHERE ${T}`:""}`,yt=i(bt)[0].values[0][0];h(yt);let O=`SELECT ${U} FROM "${t}"`;T&&(O+=` WHERE ${T}`),x&&(O+=` ORDER BY "${x}" ${g}`),O+=` LIMIT ${s} OFFSET ${a};`;const jt=i(O),{data:Nt,columns:wt}=_(jt);C(wt),w(Nt),o(null),u(O),c(O)}catch(E){E instanceof Error&&o(E.message)}finally{A(!1)}})()},[r,t,a,s,T,g]);const z=n.useCallback(()=>{if(d.trim()===""){o(null);return}A(!0);try{const b=S[parseInt(D)].name,E=i(d.replace("@",`"${b}"`)),{data:M,columns:B}=_(E);C(B),w(M),l(!0),o(null)}catch(b){b instanceof Error&&o(b.message)}finally{A(!1)}},[d,i,o,l,S,D]);return{data:N,columns:L,customQuery:d,setCustomQuery:u,isQueryLoading:R,handleCustomQuery:z,totalRows:p}}function Ws(t){const{setIsCustomQuery:s}=j(),[a,r]=n.useState(0);n.useEffect(()=>{r(0),s(!1)},[s]);const o=n.useMemo(()=>{if(t!=="auto")return t;const l=window.innerHeight,u=Math.min(2e3,40+l*.03),f=Math.max(1,Math.floor(l/u));return Math.min(Math.max(f,5),50)},[t]);return{page:a,setPage:r,rowsPerPage:o}}const ee=Y("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"}});function m(...t){return _t(Gt(t))}const y=n.forwardRef(({className:t,variant:s,size:a,asChild:r=!1,...o},l)=>{const i=r?Rt:"button";return e.jsx(i,{className:m(ee({variant:s,size:a,className:t})),ref:l,...o})});y.displayName="Button";function Ks({page:t,setPage:s,rowsPerPage:a}){const{totalRows:r}=j(),o=n.useMemo(()=>Math.ceil(r/a),[r,a]),l=n.useMemo(()=>Math.ceil(t/a)+1,[t,a]),i=l1,d=n.useCallback(()=>{i&&s(f=>f+a)},[i,a,s]),u=n.useCallback(()=>{c&&s(f=>f-a)},[c,a,s]);return e.jsx("section",{className:"fixed bottom-2 left-1/2 z-10 w-[270px] -translate-x-1/2 transform",children:e.jsxs("div",{className:"flex justify-between gap-2 rounded border bg-secondary p-[6px]",children:[e.jsx(y,{onClick:u,title:"Previous page",disabled:!c,children:e.jsx(Wt,{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:d,title:"Next page",disabled:!i,children:e.jsx(Kt,{className:"h-4 w-4"})})]})})}const Ys=It,Xs=Ft,Js=kt,ke=n.forwardRef(({className:t,children:s,...a},r)=>e.jsxs(de,{ref:r,className:m("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(Tt,{asChild:!0,children:e.jsx(Le,{className:"h-4 w-4 opacity-50"})})]}));ke.displayName=de.displayName;const Oe=n.forwardRef(({className:t,...s},a)=>e.jsx(me,{ref:a,className:m("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Yt,{className:"h-4 w-4"})}));Oe.displayName=me.displayName;const Pe=n.forwardRef(({className:t,...s},a)=>e.jsx(ue,{ref:a,className:m("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Le,{className:"h-4 w-4"})}));Pe.displayName=ue.displayName;const Me=n.forwardRef(({className:t,children:s,position:a="popper",...r},o)=>e.jsx(St,{children:e.jsxs(fe,{ref:o,className:m("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(Oe,{}),e.jsx(At,{className:m("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(Pe,{})]})}));Me.displayName=fe.displayName;const Be=n.forwardRef(({className:t,...s},a)=>e.jsx(xe,{ref:a,className:m("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));Be.displayName=xe.displayName;const Ue=n.forwardRef(({className:t,children:s,...a},r)=>e.jsxs(pe,{ref:r,className:m("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(Dt,{children:e.jsx(Xt,{className:"h-4 w-4"})})}),e.jsx(Lt,{children:s})]}));Ue.displayName=pe.displayName;const Zs=n.forwardRef(({className:t,...s},a)=>e.jsx(he,{ref:a,className:m("-mx-1 my-1 h-px bg-muted",t),...s}));Zs.displayName=he.displayName;const ea=Y("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 H({className:t,variant:s,...a}){return e.jsx("div",{className:m(ea({variant:s}),t),...a,children:e.jsx("span",{className:"w-full",children:a.children})})}function ta(){const{tables:t,selectedTable:s,setSelectedTable:a,setIsCustomQuery:r}=j(),o=n.useMemo(()=>{var d;const c=parseInt(s);return isNaN(c)?0:((d=t[c])==null?void 0:d.count)||0},[t,s]),l=n.useMemo(()=>t.map((c,d)=>e.jsx(Ue,{value:`${d}`,children:c.name[0].toUpperCase()+c.name.slice(1)},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(Ys,{value:s,onValueChange:i,children:[e.jsx(ke,{className:"grow",children:e.jsx(Js,{placeholder:"Select a table"})}),e.jsx(Me,{children:e.jsxs(Xs,{children:[e.jsx(Be,{children:"Tables"}),l]})})]}),e.jsx(H,{title:"Rows",className:"hidden min-w-[100px] grow bg-background py-2 text-center text-sm md:block md:min-w-[200px]",variant:"outline",children:e.jsx("span",{className:"w-full text-center",children:o})})]})}const V=t=>t instanceof Date&&!isNaN(t.getTime()),sa=t=>{const s=new Date(t);return V(s)?Ds(s,{addSuffix:!0}):t},aa=t=>{const s=new Date(t);return V(s)?X(s,"MMMM do, yyyy"):t},ra=t=>{const s=new Date(t);return V(s)?X(s,"MM/dd/yyyy"):t},oa=t=>{const s=new Date(t);return V(s)?X(s,"yyyy/dd/MM"):t},W={formatDateRelative:{label:"Over 56 years ago",func:sa},formatDateFormatted:{label:"January 9th, 1968",func:aa},formatDateLong:{label:"1968/09/01",func:oa},formatDateShort:{label:"01/09/1968",func:ra}},Qe=t=>t.includes("DATE")||t==="TIMESTAMP",na=t=>t==="BLOB",la=t=>t.includes("CHAR")||t.includes("TEXT")||t==="CLOB"||t.includes("VARCHAR"),ia=t=>t.includes("INT"),ca=t=>t.includes("REAL")||t.includes("FLOAT")||t.includes("DOUBLE")||t.includes("DECIMAL"),da=t=>t.includes("NUMERIC"),ma=t=>ia(t)||ca(t)||da(t),ua=t=>t.includes("BOOL"),$e=Ot,He=Pt,te=n.forwardRef(({className:t,align:s="start",side:a="bottom",sideOffset:r=4,...o},l)=>e.jsx(ge,{ref:l,align:s,side:a,sideOffset:r,className:m("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}));te.displayName=ge.displayName;const qe=n.forwardRef(({className:t,...s},a)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:a,className:m("w-full caption-bottom text-sm",t),...s})}));qe.displayName="Table";const Ve=n.forwardRef(({className:t,...s},a)=>e.jsx("thead",{ref:a,className:m("[&_tr]:border-b",t),...s}));Ve.displayName="TableHeader";const ze=n.forwardRef(({className:t,...s},a)=>e.jsx("tbody",{ref:a,className:m("[&_tr:last-child]:border-0",t),...s}));ze.displayName="TableBody";const fa=n.forwardRef(({className:t,...s},a)=>e.jsx("tfoot",{ref:a,className:m("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...s}));fa.displayName="TableFooter";const K=n.forwardRef(({className:t,...s},a)=>e.jsx("tr",{ref:a,className:m("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...s}));K.displayName="TableRow";const Ge=n.forwardRef(({className:t,...s},a)=>e.jsx("th",{ref:a,className:m("h-12 min-w-[150px] px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...s}));Ge.displayName="TableHead";const xa=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)},_e=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:m("max-w-[200px] overflow-hidden truncate text-ellipsis whitespace-nowrap p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...r,children:e.jsxs($e,{children:[e.jsx(He,{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(te,{side:"bottom",align:"start",children:e.jsxs("div",{className:"flex flex-col justify-center gap-1",children:[l&&typeof s=="string"?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:xa(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}),e.jsx(H,{className:"w-full self-start text-center text-xs font-semibold",children:a||"Unknown"})]})})]})})});_e.displayName="TableCell";const pa=n.forwardRef(({className:t,...s},a)=>e.jsx("caption",{ref:a,className:m("mt-4 text-sm text-muted-foreground",t),...s}));pa.displayName="TableCaption";const se=n.forwardRef(({className:t,type:s,...a},r)=>e.jsx("input",{type:s,className:m("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}));se.displayName="Input";function ha({columnName:t}){const{appendToFilters:s,selectedTable:a,filtersNeedClear:r,setFiltersNeedClear:o}=j(),[l,i]=n.useState("");n.useEffect(()=>{i("")},[a]),n.useEffect(()=>{r&&(i(""),o(!1))},[r]);const c=n.useCallback(d=>{const u=d.target.value;i(u),s(t,u)},[s,t]);return e.jsx(se,{value:l,onChange:c,className:"mt-[2px] max-h-7 w-full text-xs",placeholder:"Filter"})}function ga({columnName:t}){const{orderBy:s,setOrderBy:a,orderByDirection:r,setOrderByDirection:o}=j(),l=n.useCallback(()=>{s===t?r==="ASC"?o("DESC"):r==="DESC"?(a(null),o("ASC")):(a(t),o("ASC")):(a(t),o("ASC"))},[s,r,t,a,o]);return e.jsx("div",{onClick:l,className:"flex items-center",children:s===t?r==="ASC"?e.jsx("button",{title:"Descending",children:e.jsx(Jt,{className:"h-4 w-4"})}):e.jsx("button",{title:"Ascending",children:e.jsx(Zt,{className:"h-4 w-4"})}):e.jsx("button",{title:"Sort column",children:e.jsx(es,{className:"h-4 w-4"})})})}const ba=k.memo(({columnSchema:t})=>e.jsxs(e.Fragment,{children:[(t==null?void 0:t.isPrimaryKey)&&e.jsx("p",{className:"text-sm font-semibold text-yellow-600",children:"(Primary)"}),(t==null?void 0:t.isForeignKey)&&e.jsx("p",{className:"text-sm font-semibold text-purple-600",children:"(Foreign)"})]})),ya=k.memo(({columnSchema:t})=>{const{type:s,isPrimaryKey:a,isForeignKey:r}=t;if(a)return e.jsx(ts,{className:"h-4 w-4 text-yellow-500"});if(r)return e.jsx(ss,{className:"h-4 w-4 text-purple-500"});if(s){if(na(s))return e.jsx(as,{className:"h-4 w-4 text-green-500"});if(Qe(s))return e.jsx(Ie,{className:"h-4 w-4 text-blue-500"});if(la(s))return e.jsx(rs,{className:"h-4 w-4 text-indigo-500"});if(ma(s))return e.jsx(os,{className:"h-4 w-4 text-red-500"});if(ua(s))return e.jsx(ns,{className:"h-4 w-4 text-pink-500"})}return e.jsx(ls,{className:"h-4 w-4 text-gray-500"})}),ja=k.memo(({columnName:t,columnSchema:s})=>e.jsxs(Ge,{className:"bg-gray-100 py-2 dark:bg-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ga,{columnName:t}),e.jsxs($e,{children:[e.jsx(He,{asChild:!0,children:e.jsxs("div",{className:"flex cursor-pointer items-center space-x-1",children:[e.jsx("span",{className:"max-w-[200px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:t}),s&&e.jsx(ya,{columnSchema:s})]})}),e.jsxs(te,{className:"w-64",children:[e.jsxs("div",{className:"mb-1 flex items-center space-x-1",children:[e.jsx("p",{className:"text-sm font-medium",children:t}),e.jsx(ba,{columnSchema:s})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(H,{className:"w-full self-start text-center text-xs font-semibold",children:(s==null?void 0:s.type)||"Unknown"}),(s==null?void 0:s.nullable)&&e.jsx(H,{className:"w-full self-start text-center text-xs font-semibold",children:"NULLABLE"})]})]})]})]}),e.jsx(ha,{columnName:t})]})),Na=k.memo(({value:t,dataType:s})=>{const{dateFormatValue:a}=j(),r=()=>t?s&&Qe(s)&&W[a]?W[a].func(t):t:e.jsx("span",{className:"italic text-gray-400",children:"NULL"});return e.jsx(_e,{dataType:s,className:"px-5 py-[11px] text-sm",children:r()})});function wa({data:t,columns:s,tableName:a,tableSchemas:r}){const{filters:o,setFiltersNeedClear:l,setFilters:i}=j(),c=n.useMemo(()=>e.jsx(Ve,{children:e.jsx(K,{children:s.map((f,p)=>e.jsx(ja,{columnName:f,columnSchema:r[a][f]},p))})}),[s,r,a]),d=n.useMemo(()=>e.jsx(ze,{children:t.map((f,p)=>e.jsx(K,{children:s.map((h,x)=>{var g;return e.jsx(Na,{value:f[h],dataType:(g=r[a][h])==null?void 0:g.type},x)})},p))}),[t,s,r,a]),u=n.useCallback(()=>{l(!0),i({})},[l,i]);return e.jsxs("div",{className:"overflow-x-auto",children:[e.jsxs(qe,{children:[c,t.length>0&&d]}),t.length===0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"w-full p-4 text-center font-medium",children:["No data available for ",a]}),Object.keys(o).length>0&&e.jsx(y,{className:"w-full rounded-none",variant:"outline",onClick:u,children:"Clear filters"})]})]})}function Q({type:t,children:s,className:a=""}){const r="flex items-center p-4 rounded-lg shadow-md";let o,l;switch(t){case"error":o=e.jsx(ms,{className:"mr-3 h-6 w-6 text-red-500"}),l="bg-red-100 text-red-800 border-l-4 border-red-500";break;case"loading":o=e.jsx(ds,{className:"mr-3 h-6 w-6 animate-spin text-blue-500"}),l="bg-blue-100 text-blue-800 border-l-4 border-blue-500";break;case"success":o=e.jsx(cs,{className:"mr-3 h-6 w-6 text-green-500"}),l="bg-green-100 text-green-800 border-l-4 border-green-500";break;case"info":o=e.jsx(is,{className:"mr-3 h-6 w-6 text-yellow-500"}),l="bg-yellow-100 text-yellow-800 border-l-4 border-yellow-500";break;default:o=null,l=""}return e.jsxs("div",{className:`${r} ${l} ${a}`,children:[o,e.jsx("span",{className:"font-medium",children:s})]})}const Ca=Bt,Ea=Ut,We=n.forwardRef(({className:t,align:s="center",sideOffset:a=4,...r},o)=>e.jsx(Mt,{children:e.jsx(be,{ref:o,align:s,sideOffset:a,className:m("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})}));We.displayName=be.displayName;function va(){const{selectedTable:t,tables:s,customQuery:a,db:r}=j(),o=n.useCallback((i,c,d,u)=>e.jsx(y,{className:u,onClick:i,title:d,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(()=>Hs(r),"Export as SQLite","Download database as SQLite"),o(()=>Vs(r,parseInt(t)),`Export ${((i=s[parseInt(t)])==null?void 0:i.name)||"selected"} table as CSV`,"Export selected table as CSV"),o(()=>zs(r),"Export all tables as CSV","Export all tables as CSV"),o(()=>Gs(r,a),"Export custom query as CSV","Export the result of the custom query as CSV")]})},[r,o,t,s,a]);return e.jsxs(Ca,{children:[e.jsx(Ea,{asChild:!0,children:e.jsx(y,{title:"Open export options",children:e.jsx(us,{className:"h-5 w-5"})})}),e.jsx(We,{align:"end",className:"w-80",children:l})]})}function Ra(){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}const Ta=["ABORT","ACTION","ADD","AFTER","ALL","ALTER","ANALYZE","AND","AS","ASC","ATTACH","AUTOINCREMENT","BEFORE","BEGIN","BETWEEN","BY","CASCADE","CASE","CAST","CHECK","COLLATE","COLUMN","COMMIT","CONFLICT","CONSTRAINT","CREATE","CROSS","CURRENT_DATE","CURRENT_TIME","CURRENT_TIMESTAMP","DATABASE","DEFAULT","DEFERRABLE","DEFERRED","DELETE","DESC","DETACH","DISTINCT","DROP","EACH","ELSE","END","ESCAPE","EXCEPT","EXCLUSIVE","EXISTS","EXPLAIN","FAIL","FOR","FOREIGN","FROM","FULL","GLOB","GROUP","HAVING","IF","IGNORE","IMMEDIATE","IN","INDEX","INDEXED","INITIALLY","INNER","INSERT","INSTEAD","INTERSECT","INTO","IS","ISNULL","JOIN","KEY","LEFT","LIKE","LIMIT","MATCH","NATURAL","NO","NOT","NOTNULL","NULL","OF","OFFSET","ON","OR","ORDER","OUTER","PLAN","PRAGMA","PRIMARY","QUERY","RAISE","RECURSIVE","REFERENCES","REGEXP","REINDEX","RELEASE","RENAME","REPLACE","RESTRICT","RIGHT","ROLLBACK","ROW","SAVEPOINT","SELECT","SET","TABLE","TEMP","TEMPORARY","THEN","TO","TRANSACTION","TRIGGER","UNION","UNIQUE","UPDATE","USING","VACUUM","VALUES","VIEW","VIRTUAL","WHEN","WHERE","WITH","WITHOUT"];function Sa({columnNames:t}){const{customQuery:s,setCustomQuery:a,queryHistory:r,tables:o}=j(),l=Ra();n.useEffect(()=>{a(re(s))},[r]);const i=n.useCallback(f=>{const p=f.matchBefore(/\w*/);if(!p||p.from===p.to&&!f.explicit)return null;const h=[...Ta.map(x=>({label:x,type:"keyword"})),...o.map(x=>({label:x.name,type:"table"})),...t.map(x=>({label:x,type:"column"}))];return{from:p.from,to:p.to,options:h}},[o,t]),c=n.useCallback(()=>{a(re(s))},[s,a]),d=n.useCallback(f=>{a(f)},[a]),u=n.useMemo(()=>[Is,Fs(),ks({override:[i]})],[i]);return e.jsx(Os,{value:s,height:"126px",extensions:u,onChange:d,onBlur:c,className:"rounded-md border",theme:l?Ps:"light"})}function re(t){return Ls(t,{language:"sqlite",useTabs:!1,keywordCase:"upper",tabWidth:2,expressionWidth:100,linesBetweenQueries:1})}function Aa(){const{tables:t,selectedTable:s,tableSchemas:a,queryError:r,setQueryError:o,rowPerPageOrAuto:l,isCustomQuery:i,setIsCustomQuery:c,customQuery:d,setCustomQuery:u,expandPage:f,setExpandPage:p,filters:h,setFilters:x,setOrderBy:g,setFiltersNeedClear:D}=j(),{page:S,setPage:N,rowsPerPage:w}=Ws(l),L=n.useMemo(()=>{var U;return(U=t[parseInt(s)])==null?void 0:U.name},[t,s]),{data:C,columns:R,isQueryLoading:A,handleCustomQuery:I}=_s(L,w,S),[T,z]=n.useState([]);n.useEffect(()=>{R.length>0&&z(R)},[L,R]);const b=n.useCallback(()=>{o(null),u(""),c(!1),x({}),D(!0)},[c,o,u]),E=n.useCallback(()=>{N(0),b()},[b,N]);n.useEffect(()=>{N(0),x({}),g(null)},[s]),n.useEffect(()=>{N(0)},[h]);const M=n.useMemo(()=>e.jsxs("div",{className:"flex flex-col gap-1 md:flex-row",children:[e.jsx("div",{className:"flex-grow",children:e.jsx(Sa,{columnNames:T})}),e.jsxs("div",{className:"flex flex-row gap-1 md:flex-col",children:[e.jsx(y,{className:"grow",onClick:I,title:"Run custom query",children:e.jsx(fs,{className:"h-5 w-5"})}),e.jsx(y,{className:"grow",onClick:b,title:"Remove query",children:e.jsx(xs,{className:"h-5 w-5"})}),e.jsx(y,{className:"grow",onClick:E,title:"Reset to first page",disabled:S===0,children:e.jsx(ps,{className:"h-5 w-5"})})]})]}),[d,I,b,E,S]),B=n.useMemo(()=>A?e.jsxs(Q,{type:"loading",children:["Loading ",L]}):e.jsx("div",{className:"mb-[40px] overflow-hidden rounded-lg border border-gray-200 dark:border dark:border-gray-700",children:e.jsx(wa,{data:C,columns:T.length>0?T:R,tableName:L,tableSchemas:a})}),[A,C,R,L,a,h,T]);return e.jsxs("div",{className:"flex flex-col gap-3 pb-8",children:[e.jsxs("section",{className:"rounded-lg bg-gray-100 p-4 shadow-sm dark:bg-gray-700",children:[e.jsxs("div",{className:"mb-[5px] flex items-center justify-between gap-1",children:[e.jsx(ta,{}),e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(va,{}),e.jsx(y,{className:"hidden expand:block",onClick:()=>p(!f),title:"Toggle page size",children:f?e.jsx(hs,{className:"h-5 w-5"}):e.jsx(gs,{className:"h-5 w-5"})})]})]}),M,r&&e.jsx("p",{className:"mt-2 text-center text-sm text-red-500 dark:text-red-400",children:r})]}),B,!i&&e.jsx(Ks,{page:S,setPage:N,rowsPerPage:w})]})}const Ke=(t,s)=>localStorage.getItem(t)||s,Ye=(t,s)=>localStorage.setItem(t,s),oe=(t,s)=>{const[a,r]=n.useState(()=>Ke(t,s));return n.useEffect(()=>{Ye(t,a)},[t,a]),[a,r]},Xe=({shouldScaleBackground:t=!0,...s})=>e.jsx(v.Root,{shouldScaleBackground:t,...s});Xe.displayName="Drawer";const Da=v.Trigger,La=v.Portal,Ia=v.Close,Je=n.forwardRef(({className:t,...s},a)=>e.jsx(v.Overlay,{ref:a,className:m("fixed inset-0 z-50 bg-black/80",t),...s}));Je.displayName=v.Overlay.displayName;const Ze=n.forwardRef(({className:t,children:s,...a},r)=>e.jsxs(La,{children:[e.jsx(Je,{}),e.jsxs(v.Content,{ref:r,className:m("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]})]}));Ze.displayName="DrawerContent";const et=({className:t,...s})=>e.jsx("div",{className:m("grid gap-1.5 p-4 text-center sm:text-left",t),...s});et.displayName="DrawerHeader";const tt=({className:t,...s})=>e.jsx("div",{className:m("mt-auto flex flex-col gap-2 pb-4",t),...s});tt.displayName="DrawerFooter";const st=n.forwardRef(({className:t,...s},a)=>e.jsx(v.Title,{ref:a,className:m("text-lg font-semibold leading-none tracking-tight",t),...s}));st.displayName=v.Title.displayName;const at=n.forwardRef(({className:t,...s},a)=>e.jsx(v.Description,{ref:a,className:m("text-sm text-muted-foreground",t),...s}));at.displayName=v.Description.displayName;const rt=n.forwardRef(({className:t,children:s,...a},r)=>e.jsxs(ye,{ref:r,className:m("relative overflow-hidden",t),...a,children:[e.jsx(Qt,{className:"h-full w-full rounded-[inherit]",children:s}),e.jsx(ot,{}),e.jsx($t,{})]}));rt.displayName=ye.displayName;const ot=n.forwardRef(({className:t,orientation:s="vertical",...a},r)=>e.jsx(je,{ref:r,orientation:s,className:m("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(Ht,{className:"relative flex-1 rounded-full bg-border"})}));ot.displayName=je.displayName;const nt=n.forwardRef(({className:t,orientation:s="horizontal",decorative:a=!0,...r},o)=>e.jsx(Ne,{ref:o,decorative:a,orientation:s,className:m("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...r}));nt.displayName=Ne.displayName;const Fa=Y("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),lt=n.forwardRef(({className:t,...s},a)=>e.jsx(we,{ref:a,className:m(Fa(),t),...s}));lt.displayName=we.displayName;const ae=n.forwardRef(({className:t,...s},a)=>e.jsx(Ce,{className:m("grid gap-2",t),...s,ref:a}));ae.displayName=Ce.displayName;const it=n.forwardRef(({className:t,...s},a)=>e.jsx(Ee,{ref:a,className:m("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(qt,{className:"flex items-center justify-center",children:e.jsx(bs,{className:"h-2.5 w-2.5 fill-current text-current"})})}));it.displayName=Ee.displayName;const q=({value:t,label:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(it,{value:t,id:`r-${t}`}),e.jsx(lt,{htmlFor:`r-${t}`,children:s})]}),ka=({rowsPerPage:t,onRowsPerPageChange:s})=>{const a=t==="auto";return e.jsxs("div",{className:"flex h-full grow flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ys,{className:"h-4 w-4"}),e.jsx("p",{className:"text-sm font-medium",children:"Rows Per Page"})]}),e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1 rounded border p-2",children:[e.jsx(se,{id:"rowsPerPage",value:a?"":t,onChange:r=>s(r.target.value),placeholder:"Number of rows",type:"number",className:"w-full",autoFocus:!1}),e.jsx(y,{variant:a?"secondary":"outline",onClick:()=>s("auto"),className:"w-full whitespace-nowrap",children:"Auto Calculate"})]})]})},Oa=({dateFormatValue:t,onDateFormatChange:s})=>e.jsxs("div",{className:"flex h-full grow flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ie,{className:"h-4 w-4"}),e.jsx("p",{className:"text-sm font-medium",children:"Date Format"})]}),e.jsx("div",{className:"h-full rounded border p-2",children:e.jsxs(ae,{className:"flex h-full flex-col gap-2",name:"dateType",value:t,onValueChange:s,children:[e.jsx(q,{value:"default",label:"Default"}),Object.entries(W).map(([a,{label:r}])=>e.jsx(q,{value:a,label:r},a))]})})]}),Pa=({themeColor:t,onThemeColorChange:s,themeColors:a})=>e.jsxs("div",{className:"flex grow flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(js,{className:"h-4 w-4"}),e.jsx("p",{className:"text-sm font-medium",children:"Theme Color"})]}),e.jsxs(ae,{className:"flex flex-col gap-2 rounded border p-2",name:"themeColor",value:t,onValueChange:s,children:[e.jsx(q,{value:"default",label:"Default"}),a.map(r=>e.jsx(q,{value:r,label:r[0].toUpperCase()+r.slice(1)},r))]})]}),Ma=({queryHistory:t})=>e.jsxs("div",{className:"flex grow flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ns,{className:"h-4 w-4"}),e.jsxs("p",{className:"text-sm font-medium",children:["Query History (",t.length,")"]})]}),e.jsx(rt,{className:"h-[155px] rounded-md border font-medium",children:e.jsx("div",{className:"p-4",children:t.map((s,a)=>e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-normal",children:s}),e.jsx(nt,{className:"my-2"})]},a))})})]}),Ba="rowsPerPage",ne="dateFormat",Ua="theme-color",le=["nord","zinc"];function Qa(){const{setRowPerPageOrAuto:t,setIsCustomQuery:s,queryHistory:a,dateFormatValue:r,setDateFormatValue:o}=j(),[l,i]=oe(Ba,"auto"),[c,d]=oe(Ua,"default"),u=l==="auto";n.useEffect(()=>{t(u?"auto":Number(l))},[l,t]),n.useEffect(()=>{o(Ke(ne,"default"))},[o]),n.useEffect(()=>{le.forEach(x=>{var g;return(g=document.body)==null?void 0:g.classList.toggle(x,x===c)})},[c]);const f=n.useCallback(x=>{s(!1),x==="auto"||Number(x)>0?i(x):$.error("Please provide a positive number of rows per page or set it to auto.")},[s,i]),p=n.useCallback(x=>{o(x),Ye(ne,x)},[o]),h=n.useCallback(x=>{d(x)},[d]);return e.jsxs(Xe,{children:[e.jsx(Da,{asChild:!0,children:e.jsx(y,{className:"grow",title:"Open settings drawer",children:e.jsx(Fe,{className:"h-5 w-5"})})}),e.jsxs(Ze,{children:[e.jsxs(et,{className:"hidden",children:[e.jsx(st,{children:"Settings"}),e.jsx(at,{children:"Change settings."})]}),e.jsxs("div",{className:"mx-auto flex w-full max-w-sm flex-col gap-3",children:[e.jsx(ka,{rowsPerPage:l,onRowsPerPageChange:f}),e.jsx(Pa,{themeColor:c,onThemeColorChange:h,themeColors:le}),e.jsx(Oa,{dateFormatValue:r,onDateFormatChange:p}),e.jsx(Ma,{queryHistory:a}),e.jsx(tt,{children:e.jsx(Ia,{asChild:!0,children:e.jsx(y,{variant:"outline",children:"Cancel"})})})]})]})]})}const G="theme-mode",ie="animate-circular-reveal";function ct(){const[t,s]=n.useState(()=>{const o=localStorage.getItem(G),l=window.matchMedia("(prefers-color-scheme: dark)").matches;return o||(l?"dark":"light")}),a=n.useCallback(o=>{s(o),document.body.classList.remove("light","dark"),document.body.classList.add(o),localStorage.setItem(G,o),document.body.classList.add(ie),setTimeout(()=>{document.body.classList.remove(ie)},500)},[]);n.useEffect(()=>{const o=i=>{localStorage.getItem(G)||a(i.matches?"dark":"light")},l=window.matchMedia("(prefers-color-scheme: dark)");return l.addEventListener("change",o),a(t),()=>{l.removeEventListener("change",o)}},[a,t]);const r=n.useCallback(()=>{a(t==="light"?"dark":"light")},[t,a]);return e.jsx(y,{className:"relative grow",onClick:r,title:t==="dark"?"Enable light mode":"Enable dark mode",children:t==="dark"?e.jsx(ws,{className:"h-5 w-5"}):e.jsx(Cs,{className:"h-5 w-5"})})}const $a={"application/vnd.sqlite3":[".sqlite",".sqlite3"],"application/x-sqlite3":[".sqlite",".sqlite3"],"application/octet-stream":[".db"],"application/sql":[".sql"]};function Ha(){const{loadDatabase:t,setTables:s,setSelectedTable:a,db:r}=j(),[o,l]=n.useState([]),i=n.useCallback(async(h,x)=>{if(x.length>0){const g=x.flatMap(D=>D.errors);l(g);return}if(l([]),s([]),a("0"),h.length>0)try{await t(h[0])}catch(g){return g instanceof Error?$(g.message,{position:"bottom-right"}):$("Failed to load database",{position:"bottom-right"})}},[t,s,a]),{getRootProps:c,getInputProps:d,isDragActive:u}=Ms({onDrop:i,multiple:!1,accept:$a}),f=n.useCallback(h=>e.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[e.jsxs("div",{...c(),className:`flex w-full grow transform cursor-pointer flex-col items-center justify-center rounded-lg border-2 border-dashed p-6 transition-colors duration-300 ease-in-out hover:bg-secondary ${u?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-primary dark:border-gray-700"} ${h?"py-7":"py-12"}`,children:[e.jsx("input",{id:"file-upload",...d()}),e.jsx("label",{htmlFor:"file-upload",className:"sr-only",children:"Upload SQLite File"}),e.jsxs("div",{className:"text-center text-sm md:text-base",children:[e.jsx("span",{className:"hidden sm:block lg:text-lg",children:"Drag and drop file here, or click to select one"}),e.jsx("div",{className:"block sm:hidden",children:h?e.jsx("span",{className:"font-medium",children:"Click to select a file"}):e.jsx("span",{className:"font-medium",children:"Click to select a SQLite file"})})]})]}),h&&e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(ct,{}),e.jsx(Qa,{})]})]}),[c,d,u,r]),p=n.useMemo(()=>f(!!r),[f,r]);return e.jsxs("section",{className:"mx-auto w-full",children:[p,e.jsx(qa,{errors:o})]})}const qa=k.memo(({errors:t})=>(k.useEffect(()=>{t==null||t.forEach(s=>$(s.message,{position:"bottom-right"}))},[t]),null));function Va(){return e.jsx("header",{className:"rounded bg-gradient-to-r shadow-md dark:from-gray-800 dark:to-indigo-900",children:e.jsx("div",{className:"mx-auto max-w-4xl px-4 py-8 sm:py-12",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("h1",{className:"mb-2 text-2xl font-bold sm:text-3xl",children:"SQLite Viewer"}),e.jsx("p",{className:"max-w-md text-sm sm:text-base",children:"Explore and analyze your SQLite databases directly in your browser"})]})})})}const za=zt,Ga=Vt,dt=n.forwardRef(({className:t,...s},a)=>e.jsx(ve,{className:m("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}));dt.displayName=ve.displayName;const mt=n.forwardRef(({className:t,...s},a)=>e.jsxs(Ga,{children:[e.jsx(dt,{}),e.jsx(Re,{ref:a,className:m("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})]}));mt.displayName=Re.displayName;const ut=({className:t,...s})=>e.jsx("div",{className:m("flex flex-col space-y-2 text-center sm:text-left",t),...s});ut.displayName="AlertDialogHeader";const ft=({className:t,...s})=>e.jsx("div",{className:m("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});ft.displayName="AlertDialogFooter";const xt=n.forwardRef(({className:t,...s},a)=>e.jsx(Te,{ref:a,className:m("text-lg font-semibold",t),...s}));xt.displayName=Te.displayName;const pt=n.forwardRef(({className:t,...s},a)=>e.jsx(Se,{ref:a,className:m("text-sm text-muted-foreground",t),...s}));pt.displayName=Se.displayName;const ht=n.forwardRef(({className:t,...s},a)=>e.jsx(Ae,{ref:a,className:m(ee(),t),...s}));ht.displayName=Ae.displayName;const gt=n.forwardRef(({className:t,...s},a)=>e.jsx(De,{ref:a,className:m(ee({variant:"outline"}),"mt-2 sm:mt-0",t),...s}));gt.displayName=De.displayName;function _a({showDialog:t,setShowDialog:s,fn:a}){const r=n.useCallback(()=>{s(!1)},[s]);return e.jsx(za,{open:t,onOpenChange:s,children:e.jsxs(mt,{children:[e.jsxs(ut,{children:[e.jsx(xt,{children:"Retry using a proxy?"}),e.jsx(pt,{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(ft,{children:[e.jsx(gt,{onClick:r,children:"Cancel"}),e.jsx(ht,{onClick:a,children:"Confirm"})]})]})})}function Wa(){return e.jsx("footer",{className:"fixed bottom-0 left-0 right-0 border-t bg-background shadow-md",children:e.jsx("div",{className:"mx-auto max-w-7xl px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"flex items-center justify-between py-4 md:py-6",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sms hidden sm:block",children:"No file will be uploaded to server. Using JavaScript, sql.js"}),e.jsx("p",{className:"text-sm sm:hidden",children:"No file uploads to server."})]}),e.jsxs("a",{href:"https://github.com/vwh/sqlite-viewer",target:"_blank",rel:"noopener noreferrer",className:"flex items-center space-x-2 text-blue-500",title:"Star on GitHub",children:[e.jsx(Es,{className:"h-5 w-5"}),e.jsx("span",{className:"text-sm font-medium hover:underline",children:"Star us on GitHub"})]})]}),e.jsx("div",{className:"flex items-center space-x-4",children:e.jsx(ct,{})})]})})})}function P({icon:t,title:s,description:a}){return e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(t,{className:"h-6 w-6 text-blue-500"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-medium",children:s}),e.jsx("p",{className:"mt-1 text-sm",children:a})]})]})}function Ka(){return e.jsxs(e.Fragment,{children:[e.jsx("section",{className:"rounded bg-gradient-to-r py-6 shadow-md dark:from-gray-800 dark:to-indigo-900 md:py-10",children:e.jsx("div",{className:"mx-auto max-w-7xl px-4 sm:px-6 lg:px-8",children:e.jsx("div",{children:e.jsxs("div",{className:"grid grid-cols-1 gap-8 sm:grid-cols-2 lg:grid-cols-3",children:[e.jsx(P,{icon:vs,title:"Browser Based",description:"No installation required. Access and analyze your SQLite databases directly in your web browser."}),e.jsx(P,{icon:Rs,title:"Lightning Fast",description:"Powered by WebAssembly (WASM) for near-native performance, even with large databases."}),e.jsx(P,{icon:Ts,title:"100% Secure",description:"Your data never leaves your device. All processing happens client-side, ensuring complete privacy."}),e.jsx(P,{icon:Fe,title:"Customizable Interface",description:"Different themes and settings. Adjust the look and feel of your interface to suit your preferences and workflow."}),e.jsx(P,{icon:Ss,title:"Offline Capable",description:"Work on your databases without an internet connection. Perfect for sensitive data or remote work."}),e.jsx(P,{icon:As,title:"PWA Support",description:"Install the app on your desktop or mobile device for a genuine native experience. Enjoy robust offline functionality."})]})})})}),e.jsx("div",{className:"pb-[72px] md:pb-0"})]})}function Ya(){const{db:t,tables:s,isLoading:a,loadDatabase:r,expandPage:o}=j(),[l,i]=n.useState(null),[c,d]=n.useState(!1),[u,f]=n.useState(null),[p,h]=n.useState(!1),x=n.useRef(!1),g=n.useCallback(async(N,w=!1)=>{if(!/^(https?:\/\/(?:www\.)?[a-zA-Z0-9-]{1,256}\.[a-zA-Z]{2,6}(?:\/[^\s]*)?)$/i.test(N)){i("Invalid URL");return}try{h(!0);const C=w?`https://cors.eu.org/${encodeURIComponent(N)}`:N,R=await fetch(C);if(!R.ok)throw new Error("URL not found or invalid");const A=await R.blob(),I=new File([A],"database.sqlite");await r(I),i(null)}catch(C){w?i(`Error whilefetching, ${C instanceof Error?C.message:String(C)}`):(f(N),d(!0))}finally{h(!1)}},[r]);n.useEffect(()=>{if(x.current)return;const w=new URLSearchParams(window.location.search).get("url");w&&(g(decodeURIComponent(w)),x.current=!0)},[g]);const D=n.useCallback(()=>{u&&(g(u,!0),d(!1))},[u,g]),S=()=>a||p?e.jsxs(Q,{type:"loading",children:[p?"Fetching":"Loading"," SQLite file"]}):l&&!t?e.jsx(Q,{type:"error",children:l}):t?s.length>0?e.jsx(Aa,{}):e.jsx(Q,{type:"info",children:"Your database is empty, no tables found"}):null;return e.jsxs("main",{id:"main",className:`mx-auto flex h-screen flex-col ${t?"gap-3":"gap-4"} p-4 ${o?"w-full":"container"}`,children:[!t&&e.jsx(Va,{}),e.jsx(Ha,{}),S(),!t&&e.jsxs(e.Fragment,{children:[e.jsx(Ka,{})," ",e.jsx(Wa,{})]}),e.jsx(_a,{showDialog:c,setShowDialog:d,fn:D})]})}const Xa=({...t})=>e.jsx(Bs,{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});Ct.createRoot(document.getElementById("root")).render(e.jsxs(k.StrictMode,{children:[e.jsx(Ya,{}),e.jsx(Xa,{})]})); +`)},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}=_(r),i=qs(l,o),m=new Blob([i],{type:"text/csv;charset=utf-8;"});ce.saveAs(m,`${a}.csv`)}catch(r){throw console.error(`Failed to get CSV for query "${t}":`,r),r}},Vs=(t,s)=>{const r=J(t)[s],o=`SELECT * FROM "${r}"`;Z(o,t,r)},zs=t=>{J(t).forEach(s=>{const a=`SELECT * FROM "${s}"`;Z(a,t,s)})},Gs=(t,s)=>{Z(s,t,"custom_query")},j=Et((t,s)=>({db:null,isLoading:!1,loadDatabase:async a=>{t({isLoading:!0,queryError:null});try{const r=await Qs(a),o=J(r),l=await Promise.all(o.map(async c=>{const f=r.exec(`SELECT COUNT(*) FROM "${c}"`),x=parseInt(f[0].values[0][0],10),p=await $s(r,c);return{name:c,count:x,schema:p}})),i=l.map(({name:c,count:f})=>({name:c,count:f})),m=l.reduce((c,{name:f,schema:x})=>(c[f]=x,c),{});t({db:r,tables:i,tableSchemas:m,isLoading:!1})}catch(r){throw console.error("Failed to load database:",r),t({isLoading:!1,queryError:"Failed to load database"}),r}},tables:[],setTables:a=>t({tables:a}),selectedTable:"0",setSelectedTable:a=>t({selectedTable:a}),tableSchemas:{},customQuery:"",setIsCustomQuery:a=>t({isCustomQuery:a}),setCustomQuery:a=>t({customQuery:a}),isCustomQuery:!1,queryError:null,setQueryError:a=>t({queryError:a}),query:a=>{const{db:r}=s();return r?r.exec(a):(console.warn("Database is not loaded."),[])},rowPerPageOrAuto:"auto",setRowPerPageOrAuto:a=>t({rowPerPageOrAuto:a}),queryHistory:[],unShiftToQueryHistory:a=>t(r=>({queryHistory:[a,...r.queryHistory]})),expandPage:!1,setExpandPage:a=>t({expandPage:a}),dateFormatValue:"formatDateFormatted",setDateFormatValue:a=>t({dateFormatValue:a}),filters:{},setFilters:a=>t({filters:a}),appendToFilters:(a,r)=>t(o=>({filters:{...o.filters,[a]:r}})),filtersNeedClear:!1,setFiltersNeedClear:a=>t({filtersNeedClear:a}),totalRows:0,setTotalRows:a=>t({totalRows:a}),orderBy:null,setOrderBy:a=>t({orderBy:a}),orderByDirection:"ASC",setOrderByDirection:a=>t({orderByDirection:a})}));function _s(t,s,a){const{db:r,setQueryError:o,setIsCustomQuery:l,query:i,unShiftToQueryHistory:m,customQuery:c,setCustomQuery:f,filters:x,totalRows:p,setTotalRows:g,orderBy:u,orderByDirection:h,selectedTable:w,tables:C}=j(),[N,E]=n.useState([]),[L,v]=n.useState([]),[S,D]=n.useState(!0),I=n.useMemo(()=>Object.fromEntries(Object.entries(x).filter(([,b])=>b!=="")),[x]),A=n.useMemo(()=>Object.entries(I).map(([b,R])=>`LOWER(${b}) LIKE LOWER('%${R}%')`).join(" AND "),[I]);n.useEffect(()=>{if(!r||!t)return;(async()=>{D(!0);try{const R=`PRAGMA table_info("${t}");`,U=i(R)[0].values.map(F=>({name:F[1],type:F[2]})).map(F=>F.type.toUpperCase()==="BLOB"?`hex(${F.name}) as ${F.name}`:F.name).join(", "),bt=`SELECT COUNT(*) as count FROM "${t}"${A?` WHERE ${A}`:""}`,yt=i(bt)[0].values[0][0];g(yt);let O=`SELECT ${U} FROM "${t}"`;A&&(O+=` WHERE ${A}`),u&&(O+=` ORDER BY "${u}" ${h}`),O+=` LIMIT ${s} OFFSET ${a};`;const jt=i(O),{data:Nt,columns:wt}=_(jt);v(wt),E(Nt),o(null),f(O),m(O)}catch(R){R instanceof Error&&o(R.message)}finally{D(!1)}})()},[r,t,a,s,A,h]);const z=n.useCallback(()=>{if(c.trim()===""){o(null);return}D(!0);try{const b=C[parseInt(w)].name,R=i(c.replace("@",`"${b}"`)),{data:M,columns:B}=_(R);v(B),E(M),l(!0),o(null)}catch(b){b instanceof Error&&o(b.message)}finally{D(!1)}},[c,i,o,l,C,w]);return{data:N,columns:L,customQuery:c,setCustomQuery:f,isQueryLoading:S,handleCustomQuery:z,totalRows:p}}function Ws(t){const{setIsCustomQuery:s}=j(),[a,r]=n.useState(0);n.useEffect(()=>{r(0),s(!1)},[s]);const o=n.useMemo(()=>{if(t!=="auto")return t;const l=window.innerHeight,f=Math.min(2e3,40+l*.03),x=Math.max(1,Math.floor(l/f));return Math.min(Math.max(x,5),50)},[t]);return{page:a,setPage:r,rowsPerPage:o}}const ee=Y("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"}});function d(...t){return _t(Gt(t))}const y=n.forwardRef(({className:t,variant:s,size:a,asChild:r=!1,...o},l)=>{const i=r?Rt:"button";return e.jsx(i,{className:d(ee({variant:s,size:a,className:t})),ref:l,...o})});y.displayName="Button";function Ks({page:t,setPage:s,rowsPerPage:a}){const{totalRows:r}=j(),o=n.useMemo(()=>Math.ceil(r/a),[r,a]),l=n.useMemo(()=>Math.ceil(t/a)+1,[t,a]),i=l1,c=n.useCallback(()=>{i&&s(x=>x+a)},[i,a,s]),f=n.useCallback(()=>{m&&s(x=>x-a)},[m,a,s]);return e.jsx("section",{className:"fixed bottom-2 left-1/2 z-10 w-[270px] -translate-x-1/2 transform",children:e.jsxs("div",{className:"flex justify-between gap-2 rounded border bg-secondary p-[6px]",children:[e.jsx(y,{onClick:f,title:"Previous page",disabled:!m,children:e.jsx(Wt,{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:c,title:"Next page",disabled:!i,children:e.jsx(Kt,{className:"h-4 w-4"})})]})})}const Ys=It,Xs=Ft,Js=kt,ke=n.forwardRef(({className:t,children:s,...a},r)=>e.jsxs(de,{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(Tt,{asChild:!0,children:e.jsx(Le,{className:"h-4 w-4 opacity-50"})})]}));ke.displayName=de.displayName;const Oe=n.forwardRef(({className:t,...s},a)=>e.jsx(me,{ref:a,className:d("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Yt,{className:"h-4 w-4"})}));Oe.displayName=me.displayName;const Pe=n.forwardRef(({className:t,...s},a)=>e.jsx(ue,{ref:a,className:d("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Le,{className:"h-4 w-4"})}));Pe.displayName=ue.displayName;const Me=n.forwardRef(({className:t,children:s,position:a="popper",...r},o)=>e.jsx(St,{children:e.jsxs(fe,{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(Oe,{}),e.jsx(At,{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(Pe,{})]})}));Me.displayName=fe.displayName;const Be=n.forwardRef(({className:t,...s},a)=>e.jsx(xe,{ref:a,className:d("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));Be.displayName=xe.displayName;const Ue=n.forwardRef(({className:t,children:s,...a},r)=>e.jsxs(pe,{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(Dt,{children:e.jsx(Xt,{className:"h-4 w-4"})})}),e.jsx(Lt,{children:s})]}));Ue.displayName=pe.displayName;const Zs=n.forwardRef(({className:t,...s},a)=>e.jsx(he,{ref:a,className:d("-mx-1 my-1 h-px bg-muted",t),...s}));Zs.displayName=he.displayName;const ea=Y("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 H({className:t,variant:s,...a}){return e.jsx("div",{className:d(ea({variant:s}),t),...a,children:e.jsx("span",{className:"w-full",children:a.children})})}function ta(){const{tables:t,selectedTable:s,setSelectedTable:a,setIsCustomQuery:r}=j(),o=n.useMemo(()=>{var c;const m=parseInt(s);return isNaN(m)?0:((c=t[m])==null?void 0:c.count)||0},[t,s]),l=n.useMemo(()=>t.map((m,c)=>e.jsx(Ue,{value:`${c}`,children:m.name[0].toUpperCase()+m.name.slice(1)},m.name)),[t]);function i(m){r(!1),a(m)}return e.jsxs("section",{className:"flex grow items-center justify-center gap-1",children:[e.jsxs(Ys,{value:s,onValueChange:i,children:[e.jsx(ke,{className:"grow",children:e.jsx(Js,{placeholder:"Select a table"})}),e.jsx(Me,{children:e.jsxs(Xs,{children:[e.jsx(Be,{children:"Tables"}),l]})})]}),e.jsx(H,{title:"Rows",className:"hidden min-w-[100px] grow bg-background py-2 text-center text-sm md:block md:min-w-[200px]",variant:"outline",children:e.jsx("span",{className:"w-full text-center",children:o})})]})}const V=t=>t instanceof Date&&!isNaN(t.getTime()),sa=t=>{const s=new Date(t);return V(s)?Ds(s,{addSuffix:!0}):t},aa=t=>{const s=new Date(t);return V(s)?X(s,"MMMM do, yyyy"):t},ra=t=>{const s=new Date(t);return V(s)?X(s,"MM/dd/yyyy"):t},oa=t=>{const s=new Date(t);return V(s)?X(s,"yyyy/dd/MM"):t},W={formatDateRelative:{label:"Over 56 years ago",func:sa},formatDateFormatted:{label:"January 9th, 1968",func:aa},formatDateLong:{label:"1968/09/01",func:oa},formatDateShort:{label:"01/09/1968",func:ra}},Qe=t=>t.includes("DATE")||t==="TIMESTAMP",na=t=>t==="BLOB",la=t=>t.includes("CHAR")||t.includes("TEXT")||t==="CLOB"||t.includes("VARCHAR"),ia=t=>t.includes("INT"),ca=t=>t.includes("REAL")||t.includes("FLOAT")||t.includes("DOUBLE")||t.includes("DECIMAL"),da=t=>t.includes("NUMERIC"),ma=t=>ia(t)||ca(t)||da(t),ua=t=>t.includes("BOOL"),$e=Ot,He=Pt,te=n.forwardRef(({className:t,align:s="start",side:a="bottom",sideOffset:r=4,...o},l)=>e.jsx(ge,{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}));te.displayName=ge.displayName;const qe=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})}));qe.displayName="Table";const Ve=n.forwardRef(({className:t,...s},a)=>e.jsx("thead",{ref:a,className:d("[&_tr]:border-b",t),...s}));Ve.displayName="TableHeader";const ze=n.forwardRef(({className:t,...s},a)=>e.jsx("tbody",{ref:a,className:d("[&_tr:last-child]:border-0",t),...s}));ze.displayName="TableBody";const fa=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}));fa.displayName="TableFooter";const K=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}));K.displayName="TableRow";const Ge=n.forwardRef(({className:t,...s},a)=>e.jsx("th",{ref:a,className:d("h-12 min-w-[150px] px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...s}));Ge.displayName="TableHead";const xa=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)},_e=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($e,{children:[e.jsx(He,{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(te,{side:"bottom",align:"start",children:e.jsxs("div",{className:"flex flex-col justify-center gap-1",children:[l&&typeof s=="string"?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:xa(s),alt:"BLOB content",className:"flex max-h-40 flex-col items-center justify-center gap-2 rounded object-contain",onError:m=>{m.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}),e.jsx(H,{className:"w-full self-start text-center text-xs font-semibold",children:a||"Unknown"})]})})]})})});_e.displayName="TableCell";const pa=n.forwardRef(({className:t,...s},a)=>e.jsx("caption",{ref:a,className:d("mt-4 text-sm text-muted-foreground",t),...s}));pa.displayName="TableCaption";const se=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}));se.displayName="Input";function ha({columnName:t}){const{appendToFilters:s,selectedTable:a,filtersNeedClear:r,setFiltersNeedClear:o}=j(),[l,i]=n.useState("");n.useEffect(()=>{i("")},[a]),n.useEffect(()=>{r&&(i(""),o(!1))},[r]);const m=n.useCallback(c=>{const f=c.target.value;i(f),s(t,f)},[s,t]);return e.jsx(se,{value:l,onChange:m,className:"mt-[2px] max-h-7 w-full text-xs",placeholder:"Filter"})}function ga({columnName:t}){const{orderBy:s,setOrderBy:a,orderByDirection:r,setOrderByDirection:o}=j(),l=n.useCallback(()=>{s===t?r==="ASC"?o("DESC"):r==="DESC"?(a(null),o("ASC")):(a(t),o("ASC")):(a(t),o("ASC"))},[s,r,t,a,o]);return e.jsx("div",{onClick:l,className:"flex items-center",children:s===t?r==="ASC"?e.jsx("button",{title:"Descending",children:e.jsx(Jt,{className:"h-4 w-4"})}):e.jsx("button",{title:"Ascending",children:e.jsx(Zt,{className:"h-4 w-4"})}):e.jsx("button",{title:"Sort column",children:e.jsx(es,{className:"h-4 w-4"})})})}const ba=k.memo(({columnSchema:t})=>e.jsxs(e.Fragment,{children:[(t==null?void 0:t.isPrimaryKey)&&e.jsx("p",{className:"text-sm font-semibold text-yellow-600",children:"(Primary)"}),(t==null?void 0:t.isForeignKey)&&e.jsx("p",{className:"text-sm font-semibold text-purple-600",children:"(Foreign)"})]})),ya=k.memo(({columnSchema:t})=>{const{type:s,isPrimaryKey:a,isForeignKey:r}=t;if(a)return e.jsx(ts,{className:"h-4 w-4 text-yellow-500"});if(r)return e.jsx(ss,{className:"h-4 w-4 text-purple-500"});if(s){if(na(s))return e.jsx(as,{className:"h-4 w-4 text-green-500"});if(Qe(s))return e.jsx(Ie,{className:"h-4 w-4 text-blue-500"});if(la(s))return e.jsx(rs,{className:"h-4 w-4 text-indigo-500"});if(ma(s))return e.jsx(os,{className:"h-4 w-4 text-red-500"});if(ua(s))return e.jsx(ns,{className:"h-4 w-4 text-pink-500"})}return e.jsx(ls,{className:"h-4 w-4 text-gray-500"})}),ja=k.memo(({columnName:t,columnSchema:s})=>e.jsxs(Ge,{className:"bg-gray-100 py-2 dark:bg-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ga,{columnName:t}),e.jsxs($e,{children:[e.jsx(He,{asChild:!0,children:e.jsxs("div",{className:"flex cursor-pointer items-center space-x-1",children:[e.jsx("span",{className:"max-w-[200px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:t}),s&&e.jsx(ya,{columnSchema:s})]})}),e.jsxs(te,{className:"w-64",children:[e.jsxs("div",{className:"mb-1 flex items-center space-x-1",children:[e.jsx("p",{className:"text-sm font-medium",children:t}),e.jsx(ba,{columnSchema:s})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(H,{className:"w-full self-start text-center text-xs font-semibold",children:(s==null?void 0:s.type)||"Unknown"}),(s==null?void 0:s.nullable)&&e.jsx(H,{className:"w-full self-start text-center text-xs font-semibold",children:"NULLABLE"})]})]})]})]}),e.jsx(ha,{columnName:t})]})),Na=k.memo(({value:t,dataType:s})=>{const{dateFormatValue:a}=j(),r=()=>t?s&&Qe(s)&&W[a]?W[a].func(t):t:e.jsx("span",{className:"italic text-gray-400",children:"NULL"});return e.jsx(_e,{dataType:s,className:"px-5 py-[11px] text-sm",children:r()})});function wa({data:t,columns:s,tableName:a,tableSchemas:r}){const{filters:o,setFiltersNeedClear:l,setFilters:i}=j(),m=n.useMemo(()=>e.jsx(Ve,{children:e.jsx(K,{children:s.map((x,p)=>e.jsx(ja,{columnName:x,columnSchema:r[a][x]},p))})}),[s,r,a]),c=n.useMemo(()=>e.jsx(ze,{children:t.map((x,p)=>e.jsx(K,{children:s.map((g,u)=>{var h;return e.jsx(Na,{value:x[g],dataType:(h=r[a][g])==null?void 0:h.type},u)})},p))}),[t,s,r,a]),f=n.useCallback(()=>{l(!0),i({})},[l,i]);return e.jsxs("div",{className:"overflow-x-auto",children:[e.jsxs(qe,{children:[m,t.length>0&&c]}),t.length===0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"w-full p-4 text-center font-medium",children:["No data available for ",a]}),Object.keys(o).length>0&&e.jsx(y,{className:"w-full rounded-none",variant:"outline",onClick:f,children:"Clear filters"})]})]})}function Q({type:t,children:s,className:a=""}){const r="flex items-center p-4 rounded-lg shadow-md";let o,l;switch(t){case"error":o=e.jsx(ms,{className:"mr-3 h-6 w-6 text-red-500"}),l="bg-red-100 text-red-800 border-l-4 border-red-500";break;case"loading":o=e.jsx(ds,{className:"mr-3 h-6 w-6 animate-spin text-blue-500"}),l="bg-blue-100 text-blue-800 border-l-4 border-blue-500";break;case"success":o=e.jsx(cs,{className:"mr-3 h-6 w-6 text-green-500"}),l="bg-green-100 text-green-800 border-l-4 border-green-500";break;case"info":o=e.jsx(is,{className:"mr-3 h-6 w-6 text-yellow-500"}),l="bg-yellow-100 text-yellow-800 border-l-4 border-yellow-500";break;default:o=null,l=""}return e.jsxs("div",{className:`${r} ${l} ${a}`,children:[o,e.jsx("span",{className:"font-medium",children:s})]})}const Ca=Bt,Ea=Ut,We=n.forwardRef(({className:t,align:s="center",sideOffset:a=4,...r},o)=>e.jsx(Mt,{children:e.jsx(be,{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})}));We.displayName=be.displayName;function va(){const{selectedTable:t,tables:s,customQuery:a,db:r}=j(),o=n.useCallback((i,m,c,f)=>e.jsx(y,{className:f,onClick:i,title:c,children:e.jsx("span",{className:"ml-2",children:m})}),[]),l=n.useMemo(()=>{var i;return r&&e.jsxs("div",{className:"flex flex-col gap-1",children:[o(()=>Hs(r),"Export as SQLite","Download database as SQLite"),o(()=>Vs(r,parseInt(t)),`Export ${((i=s[parseInt(t)])==null?void 0:i.name)||"selected"} table as CSV`,"Export selected table as CSV"),o(()=>zs(r),"Export all tables as CSV","Export all tables as CSV"),o(()=>Gs(r,a),"Export custom query as CSV","Export the result of the custom query as CSV")]})},[r,o,t,s,a]);return e.jsxs(Ca,{children:[e.jsx(Ea,{asChild:!0,children:e.jsx(y,{title:"Open export options",children:e.jsx(us,{className:"h-5 w-5"})})}),e.jsx(We,{align:"end",className:"w-80",children:l})]})}function Ra(){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}const Ta=["ABORT","ACTION","ADD","AFTER","ALL","ALTER","ANALYZE","AND","AS","ASC","ATTACH","AUTOINCREMENT","BEFORE","BEGIN","BETWEEN","BY","CASCADE","CASE","CAST","CHECK","COLLATE","COLUMN","COMMIT","CONFLICT","CONSTRAINT","CREATE","CROSS","CURRENT_DATE","CURRENT_TIME","CURRENT_TIMESTAMP","DATABASE","DEFAULT","DEFERRABLE","DEFERRED","DELETE","DESC","DETACH","DISTINCT","DROP","EACH","ELSE","END","ESCAPE","EXCEPT","EXCLUSIVE","EXISTS","EXPLAIN","FAIL","FOR","FOREIGN","FROM","FULL","GLOB","GROUP","HAVING","IF","IGNORE","IMMEDIATE","IN","INDEX","INDEXED","INITIALLY","INNER","INSERT","INSTEAD","INTERSECT","INTO","IS","ISNULL","JOIN","KEY","LEFT","LIKE","LIMIT","MATCH","NATURAL","NO","NOT","NOTNULL","NULL","OF","OFFSET","ON","OR","ORDER","OUTER","PLAN","PRAGMA","PRIMARY","QUERY","RAISE","RECURSIVE","REFERENCES","REGEXP","REINDEX","RELEASE","RENAME","REPLACE","RESTRICT","RIGHT","ROLLBACK","ROW","SAVEPOINT","SELECT","SET","TABLE","TEMP","TEMPORARY","THEN","TO","TRANSACTION","TRIGGER","UNION","UNIQUE","UPDATE","USING","VACUUM","VALUES","VIEW","VIRTUAL","WHEN","WHERE","WITH","WITHOUT"];function Sa({columnNames:t}){const{customQuery:s,setCustomQuery:a,queryHistory:r,tables:o}=j(),l=Ra();n.useEffect(()=>{a(re(s))},[r]);const i=n.useCallback(x=>{const p=x.matchBefore(/\w*/);if(!p||p.from===p.to&&!x.explicit)return null;const g=[...Ta.map(u=>({label:u,type:"keyword"})),...o.map(u=>({label:u.name,type:"table"})),...t.map(u=>({label:u,type:"column"}))];return{from:p.from,to:p.to,options:g}},[o,t]),m=n.useCallback(()=>{a(re(s))},[s,a]),c=n.useCallback(x=>{a(x)},[a]),f=n.useMemo(()=>[Is,Fs(),ks({override:[i]})],[i]);return e.jsx(Os,{value:s,height:"126px",extensions:f,onChange:c,onBlur:m,className:"rounded-md border",theme:l?Ps:"light"})}function re(t){return Ls(t,{language:"sqlite",useTabs:!1,keywordCase:"upper",tabWidth:2,expressionWidth:100,linesBetweenQueries:1})}function Aa(){const{tables:t,selectedTable:s,tableSchemas:a,queryError:r,setQueryError:o,rowPerPageOrAuto:l,isCustomQuery:i,setIsCustomQuery:m,customQuery:c,setCustomQuery:f,expandPage:x,setExpandPage:p,filters:g,setFilters:u,setOrderBy:h,setFiltersNeedClear:w}=j(),{page:C,setPage:N,rowsPerPage:E}=Ws(l),L=n.useMemo(()=>{var U;return(U=t[parseInt(s)])==null?void 0:U.name},[t,s]),{data:v,columns:S,isQueryLoading:D,handleCustomQuery:I}=_s(L,E,C),[A,z]=n.useState([]);n.useEffect(()=>{S.length>0&&z(S)},[L,S]);const b=n.useCallback(()=>{o(null),f(""),m(!1),u({}),w(!0)},[m,o,f]),R=n.useCallback(()=>{N(0),b()},[b,N]);n.useEffect(()=>{N(0),u({}),h(null)},[s]),n.useEffect(()=>{N(0)},[g]);const M=n.useMemo(()=>e.jsxs("div",{className:"flex flex-col gap-1 md:flex-row",children:[e.jsx("div",{className:"flex-grow",children:e.jsx(Sa,{columnNames:A})}),e.jsxs("div",{className:"flex flex-row gap-1 md:flex-col",children:[e.jsx(y,{className:"grow",onClick:I,title:"Run custom query",children:e.jsx(fs,{className:"h-5 w-5"})}),e.jsx(y,{className:"grow",onClick:b,title:"Remove query",children:e.jsx(xs,{className:"h-5 w-5"})}),e.jsx(y,{className:"grow",onClick:R,title:"Reset to first page",disabled:C===0,children:e.jsx(ps,{className:"h-5 w-5"})})]})]}),[c,I,b,R,C]),B=n.useMemo(()=>D?e.jsxs(Q,{type:"loading",children:["Loading ",L]}):e.jsx("div",{className:"mb-[40px] overflow-hidden rounded-lg border border-gray-200 dark:border dark:border-gray-700",children:e.jsx(wa,{data:v,columns:A.length>0?A:S,tableName:L,tableSchemas:a})}),[D,v,S,L,a,g,A]);return e.jsxs("div",{className:"flex flex-col gap-3 pb-8",children:[e.jsxs("section",{className:"rounded-lg bg-gray-100 p-4 shadow-sm dark:bg-gray-700",children:[e.jsxs("div",{className:"mb-[5px] flex items-center justify-between gap-1",children:[e.jsx(ta,{}),e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(va,{}),e.jsx(y,{className:"hidden expand:block",onClick:()=>p(!x),title:"Toggle page size",children:x?e.jsx(hs,{className:"h-5 w-5"}):e.jsx(gs,{className:"h-5 w-5"})})]})]}),M,r&&e.jsx("p",{className:"mt-2 text-center text-sm text-red-500 dark:text-red-400",children:r})]}),B,!i&&e.jsx(Ks,{page:C,setPage:N,rowsPerPage:E})]})}const Ke=(t,s)=>localStorage.getItem(t)||s,Ye=(t,s)=>localStorage.setItem(t,s),oe=(t,s)=>{const[a,r]=n.useState(()=>Ke(t,s));return n.useEffect(()=>{Ye(t,a)},[t,a]),[a,r]},Xe=({shouldScaleBackground:t=!0,...s})=>e.jsx(T.Root,{shouldScaleBackground:t,...s});Xe.displayName="Drawer";const Da=T.Trigger,La=T.Portal,Ia=T.Close,Je=n.forwardRef(({className:t,...s},a)=>e.jsx(T.Overlay,{ref:a,className:d("fixed inset-0 z-50 bg-black/80",t),...s}));Je.displayName=T.Overlay.displayName;const Ze=n.forwardRef(({className:t,children:s,...a},r)=>e.jsxs(La,{children:[e.jsx(Je,{}),e.jsxs(T.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]})]}));Ze.displayName="DrawerContent";const et=({className:t,...s})=>e.jsx("div",{className:d("grid gap-1.5 p-4 text-center sm:text-left",t),...s});et.displayName="DrawerHeader";const tt=({className:t,...s})=>e.jsx("div",{className:d("mt-auto flex flex-col gap-2 pb-4",t),...s});tt.displayName="DrawerFooter";const st=n.forwardRef(({className:t,...s},a)=>e.jsx(T.Title,{ref:a,className:d("text-lg font-semibold leading-none tracking-tight",t),...s}));st.displayName=T.Title.displayName;const at=n.forwardRef(({className:t,...s},a)=>e.jsx(T.Description,{ref:a,className:d("text-sm text-muted-foreground",t),...s}));at.displayName=T.Description.displayName;const rt=n.forwardRef(({className:t,children:s,...a},r)=>e.jsxs(ye,{ref:r,className:d("relative overflow-hidden",t),...a,children:[e.jsx(Qt,{className:"h-full w-full rounded-[inherit]",children:s}),e.jsx(ot,{}),e.jsx($t,{})]}));rt.displayName=ye.displayName;const ot=n.forwardRef(({className:t,orientation:s="vertical",...a},r)=>e.jsx(je,{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(Ht,{className:"relative flex-1 rounded-full bg-border"})}));ot.displayName=je.displayName;const nt=n.forwardRef(({className:t,orientation:s="horizontal",decorative:a=!0,...r},o)=>e.jsx(Ne,{ref:o,decorative:a,orientation:s,className:d("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...r}));nt.displayName=Ne.displayName;const Fa=Y("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),lt=n.forwardRef(({className:t,...s},a)=>e.jsx(we,{ref:a,className:d(Fa(),t),...s}));lt.displayName=we.displayName;const ae=n.forwardRef(({className:t,...s},a)=>e.jsx(Ce,{className:d("grid gap-2",t),...s,ref:a}));ae.displayName=Ce.displayName;const it=n.forwardRef(({className:t,...s},a)=>e.jsx(Ee,{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(qt,{className:"flex items-center justify-center",children:e.jsx(bs,{className:"h-2.5 w-2.5 fill-current text-current"})})}));it.displayName=Ee.displayName;const q=({value:t,label:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(it,{value:t,id:`r-${t}`}),e.jsx(lt,{htmlFor:`r-${t}`,children:s})]}),ka=({rowsPerPage:t,onRowsPerPageChange:s})=>{const a=t==="auto";return e.jsxs("div",{className:"flex h-full grow flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ys,{className:"h-4 w-4"}),e.jsx("p",{className:"text-sm font-medium",children:"Rows Per Page"})]}),e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1 rounded border p-2",children:[e.jsx(se,{id:"rowsPerPage",value:a?"":t,onChange:r=>s(r.target.value),placeholder:"Number of rows",type:"number",className:"w-full",autoFocus:!1}),e.jsx(y,{variant:a?"secondary":"outline",onClick:()=>s("auto"),className:"w-full whitespace-nowrap",children:"Auto Calculate"})]})]})},Oa=({dateFormatValue:t,onDateFormatChange:s})=>e.jsxs("div",{className:"flex h-full grow flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ie,{className:"h-4 w-4"}),e.jsx("p",{className:"text-sm font-medium",children:"Date Format"})]}),e.jsx("div",{className:"h-full rounded border p-2",children:e.jsxs(ae,{className:"flex h-full flex-col gap-2",name:"dateType",value:t,onValueChange:s,children:[e.jsx(q,{value:"default",label:"Default"}),Object.entries(W).map(([a,{label:r}])=>e.jsx(q,{value:a,label:r},a))]})})]}),Pa=({themeColor:t,onThemeColorChange:s,themeColors:a})=>e.jsxs("div",{className:"flex grow flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(js,{className:"h-4 w-4"}),e.jsx("p",{className:"text-sm font-medium",children:"Theme Color"})]}),e.jsxs(ae,{className:"flex flex-col gap-2 rounded border p-2",name:"themeColor",value:t,onValueChange:s,children:[e.jsx(q,{value:"default",label:"Default"}),a.map(r=>e.jsx(q,{value:r,label:r[0].toUpperCase()+r.slice(1)},r))]})]}),Ma=({queryHistory:t})=>e.jsxs("div",{className:"flex grow flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ns,{className:"h-4 w-4"}),e.jsxs("p",{className:"text-sm font-medium",children:["Query History (",t.length,")"]})]}),e.jsx(rt,{className:"h-[155px] rounded-md border font-medium",children:e.jsx("div",{className:"p-4",children:t.map((s,a)=>e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-normal",children:s}),e.jsx(nt,{className:"my-2"})]},a))})})]}),Ba="rowsPerPage",ne="dateFormat",Ua="theme-color",le=["nord","zinc"];function Qa(){const{setRowPerPageOrAuto:t,setIsCustomQuery:s,queryHistory:a,dateFormatValue:r,setDateFormatValue:o}=j(),[l,i]=oe(Ba,"auto"),[m,c]=oe(Ua,"default"),f=l==="auto";n.useEffect(()=>{t(f?"auto":Number(l))},[l,t]),n.useEffect(()=>{o(Ke(ne,"default"))},[o]),n.useEffect(()=>{le.forEach(u=>{var h;return(h=document.body)==null?void 0:h.classList.toggle(u,u===m)})},[m]);const x=n.useCallback(u=>{s(!1),u==="auto"||Number(u)>0?i(u):$.error("Please provide a positive number of rows per page or set it to auto.")},[s,i]),p=n.useCallback(u=>{o(u),Ye(ne,u)},[o]),g=n.useCallback(u=>{c(u)},[c]);return e.jsxs(Xe,{children:[e.jsx(Da,{asChild:!0,children:e.jsx(y,{className:"grow",title:"Open settings drawer",children:e.jsx(Fe,{className:"h-5 w-5"})})}),e.jsxs(Ze,{children:[e.jsxs(et,{className:"hidden",children:[e.jsx(st,{children:"Settings"}),e.jsx(at,{children:"Change settings."})]}),e.jsxs("div",{className:"mx-auto flex w-full max-w-sm flex-col gap-3",children:[e.jsx(ka,{rowsPerPage:l,onRowsPerPageChange:x}),e.jsx(Pa,{themeColor:m,onThemeColorChange:g,themeColors:le}),e.jsx(Oa,{dateFormatValue:r,onDateFormatChange:p}),e.jsx(Ma,{queryHistory:a}),e.jsx(tt,{children:e.jsx(Ia,{asChild:!0,children:e.jsx(y,{variant:"outline",children:"Cancel"})})})]})]})]})}const G="theme-mode",ie="animate-circular-reveal";function ct(){const[t,s]=n.useState(()=>{const o=localStorage.getItem(G),l=window.matchMedia("(prefers-color-scheme: dark)").matches;return o||(l?"dark":"light")}),a=n.useCallback(o=>{s(o),document.body.classList.remove("light","dark"),document.body.classList.add(o),localStorage.setItem(G,o),document.body.classList.add(ie),setTimeout(()=>{document.body.classList.remove(ie)},500)},[]);n.useEffect(()=>{const o=i=>{localStorage.getItem(G)||a(i.matches?"dark":"light")},l=window.matchMedia("(prefers-color-scheme: dark)");return l.addEventListener("change",o),a(t),()=>{l.removeEventListener("change",o)}},[a,t]);const r=n.useCallback(()=>{a(t==="light"?"dark":"light")},[t,a]);return e.jsx(y,{className:"relative grow",onClick:r,title:t==="dark"?"Enable light mode":"Enable dark mode",children:t==="dark"?e.jsx(ws,{className:"h-5 w-5"}):e.jsx(Cs,{className:"h-5 w-5"})})}const $a={"application/vnd.sqlite3":[".sqlite",".sqlite3"],"application/x-sqlite3":[".sqlite",".sqlite3"],"application/octet-stream":[".db"],"application/sql":[".sql"]};function Ha(){const{loadDatabase:t,setTables:s,setSelectedTable:a,db:r,setCustomQuery:o}=j(),[l,i]=n.useState([]),m=n.useCallback(async(u,h)=>{if(h.length>0){const w=h.flatMap(C=>C.errors);i(w);return}if(i([]),s([]),o(""),a("0"),u.length>0)try{await t(u[0])}catch(w){return w instanceof Error?$(w.message,{position:"bottom-right"}):$("Failed to load database",{position:"bottom-right"})}},[t,s,a]),{getRootProps:c,getInputProps:f,isDragActive:x}=Ms({onDrop:m,multiple:!1,accept:$a}),p=n.useCallback(u=>e.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[e.jsxs("div",{...c(),className:`flex w-full grow transform cursor-pointer flex-col items-center justify-center rounded-lg border-2 border-dashed p-6 transition-colors duration-300 ease-in-out hover:bg-secondary ${x?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-primary dark:border-gray-700"} ${u?"py-7":"py-12"}`,children:[e.jsx("input",{id:"file-upload",...f()}),e.jsx("label",{htmlFor:"file-upload",className:"sr-only",children:"Upload SQLite File"}),e.jsxs("div",{className:"text-center text-sm md:text-base",children:[e.jsx("span",{className:"hidden sm:block lg:text-lg",children:"Drag and drop file here, or click to select one"}),e.jsx("div",{className:"block sm:hidden",children:u?e.jsx("span",{className:"font-medium",children:"Click to select a file"}):e.jsx("span",{className:"font-medium",children:"Click to select a SQLite file"})})]})]}),u&&e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(ct,{}),e.jsx(Qa,{})]})]}),[c,f,x,r]),g=n.useMemo(()=>p(!!r),[p,r]);return e.jsxs("section",{className:"mx-auto w-full",children:[g,e.jsx(qa,{errors:l})]})}const qa=k.memo(({errors:t})=>(k.useEffect(()=>{t==null||t.forEach(s=>$(s.message,{position:"bottom-right"}))},[t]),null));function Va(){return e.jsx("header",{className:"rounded bg-gradient-to-r shadow-md dark:from-gray-800 dark:to-indigo-900",children:e.jsx("div",{className:"mx-auto max-w-4xl px-4 py-8 sm:py-12",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("h1",{className:"mb-2 text-2xl font-bold sm:text-3xl",children:"SQLite Viewer"}),e.jsx("p",{className:"max-w-md text-sm sm:text-base",children:"Explore and analyze your SQLite databases directly in your browser"})]})})})}const za=zt,Ga=Vt,dt=n.forwardRef(({className:t,...s},a)=>e.jsx(ve,{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}));dt.displayName=ve.displayName;const mt=n.forwardRef(({className:t,...s},a)=>e.jsxs(Ga,{children:[e.jsx(dt,{}),e.jsx(Re,{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})]}));mt.displayName=Re.displayName;const ut=({className:t,...s})=>e.jsx("div",{className:d("flex flex-col space-y-2 text-center sm:text-left",t),...s});ut.displayName="AlertDialogHeader";const ft=({className:t,...s})=>e.jsx("div",{className:d("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});ft.displayName="AlertDialogFooter";const xt=n.forwardRef(({className:t,...s},a)=>e.jsx(Te,{ref:a,className:d("text-lg font-semibold",t),...s}));xt.displayName=Te.displayName;const pt=n.forwardRef(({className:t,...s},a)=>e.jsx(Se,{ref:a,className:d("text-sm text-muted-foreground",t),...s}));pt.displayName=Se.displayName;const ht=n.forwardRef(({className:t,...s},a)=>e.jsx(Ae,{ref:a,className:d(ee(),t),...s}));ht.displayName=Ae.displayName;const gt=n.forwardRef(({className:t,...s},a)=>e.jsx(De,{ref:a,className:d(ee({variant:"outline"}),"mt-2 sm:mt-0",t),...s}));gt.displayName=De.displayName;function _a({showDialog:t,setShowDialog:s,fn:a}){const r=n.useCallback(()=>{s(!1)},[s]);return e.jsx(za,{open:t,onOpenChange:s,children:e.jsxs(mt,{children:[e.jsxs(ut,{children:[e.jsx(xt,{children:"Retry using a proxy?"}),e.jsx(pt,{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(ft,{children:[e.jsx(gt,{onClick:r,children:"Cancel"}),e.jsx(ht,{onClick:a,children:"Confirm"})]})]})})}function Wa(){return e.jsx("footer",{className:"fixed bottom-0 left-0 right-0 border-t bg-background shadow-md",children:e.jsx("div",{className:"mx-auto max-w-7xl px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"flex items-center justify-between py-4 md:py-6",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sms hidden sm:block",children:"No file will be uploaded to server. Using JavaScript, sql.js"}),e.jsx("p",{className:"text-sm sm:hidden",children:"No file uploads to server."})]}),e.jsxs("a",{href:"https://github.com/vwh/sqlite-viewer",target:"_blank",rel:"noopener noreferrer",className:"flex items-center space-x-2 text-blue-500",title:"Star on GitHub",children:[e.jsx(Es,{className:"h-5 w-5"}),e.jsx("span",{className:"text-sm font-medium hover:underline",children:"Star us on GitHub"})]})]}),e.jsx("div",{className:"flex items-center space-x-4",children:e.jsx(ct,{})})]})})})}function P({icon:t,title:s,description:a}){return e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(t,{className:"h-6 w-6 text-blue-500"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-medium",children:s}),e.jsx("p",{className:"mt-1 text-sm",children:a})]})]})}function Ka(){return e.jsxs(e.Fragment,{children:[e.jsx("section",{className:"rounded bg-gradient-to-r py-6 shadow-md dark:from-gray-800 dark:to-indigo-900 md:py-10",children:e.jsx("div",{className:"mx-auto max-w-7xl px-4 sm:px-6 lg:px-8",children:e.jsx("div",{children:e.jsxs("div",{className:"grid grid-cols-1 gap-8 sm:grid-cols-2 lg:grid-cols-3",children:[e.jsx(P,{icon:vs,title:"Browser Based",description:"No installation required. Access and analyze your SQLite databases directly in your web browser."}),e.jsx(P,{icon:Rs,title:"Lightning Fast",description:"Powered by WebAssembly (WASM) for near-native performance, even with large databases."}),e.jsx(P,{icon:Ts,title:"100% Secure",description:"Your data never leaves your device. All processing happens client-side, ensuring complete privacy."}),e.jsx(P,{icon:Fe,title:"Customizable Interface",description:"Different themes and settings. Adjust the look and feel of your interface to suit your preferences and workflow."}),e.jsx(P,{icon:Ss,title:"Offline Capable",description:"Work on your databases without an internet connection. Perfect for sensitive data or remote work."}),e.jsx(P,{icon:As,title:"PWA Support",description:"Install the app on your desktop or mobile device for a genuine native experience. Enjoy robust offline functionality."})]})})})}),e.jsx("div",{className:"pb-[72px] md:pb-0"})]})}function Ya(){const{db:t,tables:s,isLoading:a,loadDatabase:r,expandPage:o}=j(),[l,i]=n.useState(null),[m,c]=n.useState(!1),[f,x]=n.useState(null),[p,g]=n.useState(!1),u=n.useRef(!1),h=n.useCallback(async(N,E=!1)=>{if(!/^(https?:\/\/(?:www\.)?[a-zA-Z0-9-]{1,256}\.[a-zA-Z]{2,6}(?:\/[^\s]*)?)$/i.test(N)){i("Invalid URL");return}try{g(!0);const v=E?`https://cors.eu.org/${encodeURIComponent(N)}`:N,S=await fetch(v);if(!S.ok)throw new Error("URL not found or invalid");const D=await S.blob(),I=new File([D],"database.sqlite");await r(I),i(null)}catch(v){E?i(`Error whilefetching, ${v instanceof Error?v.message:String(v)}`):(x(N),c(!0))}finally{g(!1)}},[r]);n.useEffect(()=>{if(u.current)return;const E=new URLSearchParams(window.location.search).get("url");E&&(h(decodeURIComponent(E)),u.current=!0)},[h]);const w=n.useCallback(()=>{f&&(h(f,!0),c(!1))},[f,h]),C=()=>a||p?e.jsxs(Q,{type:"loading",children:[p?"Fetching":"Loading"," SQLite file"]}):l&&!t?e.jsx(Q,{type:"error",children:l}):t?s.length>0?e.jsx(Aa,{}):e.jsx(Q,{type:"info",children:"Your database is empty, no tables found"}):null;return e.jsxs("main",{id:"main",className:`mx-auto flex h-screen flex-col ${t?"gap-3":"gap-4"} p-4 ${o?"w-full":"container"}`,children:[!t&&e.jsx(Va,{}),e.jsx(Ha,{}),C(),!t&&e.jsxs(e.Fragment,{children:[e.jsx(Ka,{})," ",e.jsx(Wa,{})]}),e.jsx(_a,{showDialog:m,setShowDialog:c,fn:w})]})}const Xa=({...t})=>e.jsx(Bs,{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});Ct.createRoot(document.getElementById("root")).render(e.jsxs(k.StrictMode,{children:[e.jsx(Ya,{}),e.jsx(Xa,{})]})); diff --git a/assets/index-CdfIWGO4.js.gz b/assets/index-CdfIWGO4.js.gz new file mode 100644 index 0000000..3c485e7 Binary files /dev/null and b/assets/index-CdfIWGO4.js.gz differ diff --git a/index.html b/index.html index bd84362..91c0ff2 100644 --- a/index.html +++ b/index.html @@ -93,7 +93,7 @@ font-size: 2rem; } - + diff --git a/index.html.gz b/index.html.gz index f69e5f0..0390049 100644 Binary files a/index.html.gz and b/index.html.gz differ diff --git a/preview.png b/preview.png index b95e00d..5596377 100644 Binary files a/preview.png and b/preview.png differ diff --git a/sw.js b/sw.js index fb7cabc..eb20380 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-3e911b1d"],(function(s){"use strict";self.skipWaiting(),s.clientsClaim(),s.precacheAndRoute([{url:"assets/@babel-BjXSgPXB.js",revision:null},{url:"assets/@codemirror-CCjSF3Vf.js",revision:null},{url:"assets/@floating-ui-DdUjdMBw.js",revision:null},{url:"assets/@lezer-DgLl1T_N.js",revision:null},{url:"assets/@radix-ui-E10elJI3.js",revision:null},{url:"assets/@uiw-CvcbIrPa.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/crelt-C8TCjufn.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-3WB_jjc1.css",revision:null},{url:"assets/index-B79UIr58.js",revision:null},{url:"assets/lucide-react-C1VID-M1.js",revision:null},{url:"assets/nearley-CG12bGQB.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-formatter-BoZ82dp4.js",revision:null},{url:"assets/sql.js-Ch_tM77n.js",revision:null},{url:"assets/style-mod-Bc2inJdb.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-LE4MEETp.js",revision:null},{url:"assets/w3c-keyname-Vcq4gwWv.js",revision:null},{url:"assets/zustand-BpWCCnYR.js",revision:null},{url:"index.html",revision:"d2d970ba216c602980a99d4baf9fc80c"},{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"sql.wasm",revision:"f6ad6454f4630b310eb8473858eb33bb"},{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-3e911b1d"],(function(s){"use strict";self.skipWaiting(),s.clientsClaim(),s.precacheAndRoute([{url:"assets/@babel-BjXSgPXB.js",revision:null},{url:"assets/@codemirror-CCjSF3Vf.js",revision:null},{url:"assets/@floating-ui-DdUjdMBw.js",revision:null},{url:"assets/@lezer-DgLl1T_N.js",revision:null},{url:"assets/@radix-ui-E10elJI3.js",revision:null},{url:"assets/@uiw-CvcbIrPa.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/crelt-C8TCjufn.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-3WB_jjc1.css",revision:null},{url:"assets/index-CdfIWGO4.js",revision:null},{url:"assets/lucide-react-C1VID-M1.js",revision:null},{url:"assets/nearley-CG12bGQB.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-formatter-BoZ82dp4.js",revision:null},{url:"assets/sql.js-Ch_tM77n.js",revision:null},{url:"assets/style-mod-Bc2inJdb.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-LE4MEETp.js",revision:null},{url:"assets/w3c-keyname-Vcq4gwWv.js",revision:null},{url:"assets/zustand-BpWCCnYR.js",revision:null},{url:"index.html",revision:"251220cf68196e42073ab407ba510e72"},{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"sql.wasm",revision:"f6ad6454f4630b310eb8473858eb33bb"},{url:"manifest.webmanifest",revision:"662c9ac5fe5300a257a596b0ad6130ea"}],{}),s.cleanupOutdatedCaches(),s.registerRoute(new s.NavigationRoute(s.createHandlerBoundToURL("index.html")))}));