@theobourgeois/ytdb 0.2.9 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +3 -3
  3. package/.next/build-manifest.json +2 -2
  4. package/.next/server/app/[connectionId]/[schema]/[table]/page_client-reference-manifest.js +1 -1
  5. package/.next/server/app/[connectionId]/diff/page_client-reference-manifest.js +1 -1
  6. package/.next/server/app/[connectionId]/migrations/[setId]/page.js +1 -1
  7. package/.next/server/app/[connectionId]/migrations/[setId]/page_client-reference-manifest.js +1 -1
  8. package/.next/server/app/[connectionId]/migrations/page.js +1 -1
  9. package/.next/server/app/[connectionId]/migrations/page_client-reference-manifest.js +1 -1
  10. package/.next/server/app/[connectionId]/page_client-reference-manifest.js +1 -1
  11. package/.next/server/app/[connectionId]/query/page_client-reference-manifest.js +1 -1
  12. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  13. package/.next/server/app/_global-error.html +1 -1
  14. package/.next/server/app/_global-error.rsc +1 -1
  15. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  16. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  17. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  18. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  19. package/.next/server/app/_not-found.html +1 -1
  20. package/.next/server/app/_not-found.rsc +2 -2
  21. package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  22. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  23. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  24. package/.next/server/app/api/ledger/route.js +1 -1
  25. package/.next/server/app/api/migrate/route.js +1 -1
  26. package/.next/server/app/index.html +1 -1
  27. package/.next/server/app/index.rsc +2 -2
  28. package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  29. package/.next/server/app/index.segments/_full.segment.rsc +2 -2
  30. package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  31. package/.next/server/app/page_client-reference-manifest.js +1 -1
  32. package/.next/server/app-paths-manifest.json +3 -3
  33. package/.next/server/chunks/702.js +1 -1
  34. package/.next/server/chunks/729.js +1 -1
  35. package/.next/server/chunks/907.js +15 -10
  36. package/.next/server/middleware-build-manifest.js +1 -1
  37. package/.next/server/pages/404.html +1 -1
  38. package/.next/server/pages/500.html +1 -1
  39. package/.next/static/chunks/3123-5b058e55010e138a.js +1 -0
  40. package/.next/static/chunks/7449-d0483bbc0f0fec63.js +1 -0
  41. package/.next/static/chunks/app/[connectionId]/{layout-18239a50b43285f6.js → layout-237a770e53d2a6ef.js} +1 -1
  42. package/.next/static/chunks/app/[connectionId]/migrations/[setId]/{page-20581d3ca2f1c5b3.js → page-483afd7dc1a64119.js} +1 -1
  43. package/.next/static/chunks/app/[connectionId]/migrations/page-95a09bbb4f26ebb2.js +1 -0
  44. package/.next/static/chunks/app/[connectionId]/query/page-a0a9cc495d3aa710.js +1 -0
  45. package/.next/static/css/7bb8868c12384025.css +1 -0
  46. package/README.md +8 -0
  47. package/package.json +1 -1
  48. package/.next/static/chunks/3123-9d121152b53da311.js +0 -1
  49. package/.next/static/chunks/7449-2b9bc65afb482d61.js +0 -1
  50. package/.next/static/chunks/app/[connectionId]/migrations/page-20f40d5f232b4607.js +0 -1
  51. package/.next/static/chunks/app/[connectionId]/query/page-46af4cc6f90448f5.js +0 -1
  52. package/.next/static/css/993f480f9e0f3e74.css +0 -1
  53. /package/.next/static/{4qs91o-9uIcy_ViXwFMl1 → _G44c2d2nyq6S1KEvNgOB}/_buildManifest.js +0 -0
  54. /package/.next/static/{4qs91o-9uIcy_ViXwFMl1 → _G44c2d2nyq6S1KEvNgOB}/_ssgManifest.js +0 -0
@@ -6,15 +6,15 @@
6
6
  "/favicon.ico/route": "app/favicon.ico/route.js",
7
7
  "/icon.svg/route": "app/icon.svg/route.js",
8
8
  "/api/cell/route": "app/api/cell/route.js",
9
- "/api/delete-rows/route": "app/api/delete-rows/route.js",
10
9
  "/api/definition/route": "app/api/definition/route.js",
10
+ "/api/delete-rows/route": "app/api/delete-rows/route.js",
11
11
  "/api/insert-row/route": "app/api/insert-row/route.js",
12
12
  "/api/ledger/route": "app/api/ledger/route.js",
13
13
  "/api/lookup/route": "app/api/lookup/route.js",
14
- "/api/query/route": "app/api/query/route.js",
15
14
  "/api/migrate/route": "app/api/migrate/route.js",
16
- "/api/rows/route": "app/api/rows/route.js",
15
+ "/api/query/route": "app/api/query/route.js",
17
16
  "/api/related/route": "app/api/related/route.js",
17
+ "/api/rows/route": "app/api/rows/route.js",
18
18
  "/api/schema/route": "app/api/schema/route.js",
19
19
  "/api/tables/route": "app/api/tables/route.js",
20
20
  "/api/update-row/route": "app/api/update-row/route.js",
@@ -1 +1 @@
1
- "use strict";exports.id=702,exports.ids=[702],exports.modules={453:(a,b,c)=>{c.d(b,{x:()=>d});function d(a,b){let c=new Map(a.map(a=>[a.connection.id,a])),d=b.filter(a=>c.has(a.connectionId)).map(a=>({id:a.id,connectionId:a.connectionId,connectionName:a.connectionName,version:a.version,name:a.name,at:a.ranAt,kind:"failed"===a.status?"failed":a.recorded?"apply"===a.direction?"marked":"unmarked":"apply"===a.direction?"applied":"reverted",durationMs:a.durationMs,error:a.error,setName:a.setName,fromLedger:!1})),e=new Map;for(let a of d){let b=`${a.connectionId}:${a.version}`,c=e.get(b);(!c||a.at>c.at)&&e.set(b,a)}let f=[...d];for(let b of a)for(let a of b.ledger?.entries??[]){let c=`${b.connection.id}:${a.version}`,d=e.get(c);if(d&&("applied"===d.kind||"marked"===d.kind)){d.appliedBy=a.appliedBy;continue}f.push({id:`ledger:${b.connection.id}:${a.version}`,connectionId:b.connection.id,connectionName:b.connection.name,version:a.version,name:a.name||a.version,at:function(a){let b=Date.parse(a);return Number.isNaN(b)?0:b}(a.appliedAt),kind:"applied",durationMs:a.durationMs,setName:a.setName,appliedBy:a.appliedBy,fromLedger:!0})}return f.sort((a,b)=>b.at-a.at)}},14807:(a,b,c)=>{c.d(b,{A:()=>d});let d=(0,c(41926).A)("undo",[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]])},29774:(a,b,c)=>{c.d(b,{A:()=>d});let d=(0,c(41926).A)("clipboard-x",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m14.5 11.5-5 5",key:"1eaq8h"}],["path",{d:"m9.5 11.5 5 5",key:"1exjew"}]])},32278:(a,b,c)=>{c.d(b,{k:()=>p,$:()=>o});var d=c(48249),e=c(67484),f=c(69357),g=c(41577);let h=(0,c(41926).A)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);var i=c(25297);function j(a){let b=a.createReader?.();return b?new Promise((a,c)=>{let d=[],e=()=>{b.readEntries(b=>{0===b.length||d.length>=2e3?a(d):(d.push(...b),e())},c)};e()}):Promise.resolve([])}async function k(a,b,c,d){if(d.length>=2e3||c>6||a.name.startsWith("."))return;let e=b?`${b}/${a.name}`:a.name;if(a.isFile){if(!/\.sql$/i.test(a.name))return;let b=await new Promise((b,c)=>{a.file?a.file(b,c):c(Error(`Could not read ${a.name}`))});d.push({path:e,text:await b.text()});return}if(a.isDirectory)for(let b of(await j(a)))await k(b,e,c+1,d)}async function l(a){let b=[];for(let c of Array.from(a.items)){if("file"!==c.kind)continue;let a=c.webkitGetAsEntry?.();a&&b.push(a)}if(0===b.length){let b=Array.from(a.files).filter(a=>/\.sql$/i.test(a.name));return 0===b.length?null:{name:"Migrations",files:await Promise.all(b.map(async a=>({path:a.name,text:await a.text()})))}}let c=1===b.length&&b[0].isDirectory?b[0]:null,d=[];if(c){for(let a of(await j(c)))await k(a,"",1,d);return{name:c.name,files:d}}for(let a of b)await k(a,"",0,d);return d.length>0?{name:"Migrations",files:d}:null}async function m(a){let b,c=Array.from(a).filter(a=>/\.sql$/i.test(a.name));if(0===c.length)return null;let d=new Set(c.map(a=>(a.webkitRelativePath||a.name).split("/")[0])),e=1===d.size&&((b=c[0]).webkitRelativePath||b.name).includes("/")?[...d][0]:null;return{name:e??"Migrations",files:await Promise.all(c.slice(0,2e3).map(async a=>{let b=a.webkitRelativePath||a.name;return{path:e?b.slice(e.length+1):b,text:await a.text()}}))}}var n=c(14490);function o(a){let[b,c]=(0,e.useState)(!1),[d,f]=(0,e.useState)(null);return{importFrom:(0,e.useCallback)(async b=>{c(!0),f(null);try{let c=b instanceof FileList?await m(b):await l(b);if(!c||0===c.files.length)return void f("No .sql files in there.");a(c)}catch(a){f(a instanceof Error?a.message:"Couldn’t read that folder.")}finally{c(!1)}},[a]),busy:b,error:d,clearError:()=>f(null)}}function p({onFiles:a,hint:b,className:c,compact:j=!1}){let{importFrom:k,busy:l,error:m}=o(a),[q,r]=(0,e.useState)(!1),s=(0,e.useRef)(null),t=(0,e.useRef)(null);return(0,d.jsxs)("div",{onDragOver:a=>{a.preventDefault(),r(!0)},onDragLeave:()=>r(!1),onDrop:a=>{a.preventDefault(),r(!1),k(a.dataTransfer)},className:(0,n.cn)("flex flex-col items-center justify-center gap-3 rounded-lg border border-dashed text-center transition-colors",j?"gap-2 px-4 py-6":"px-6 py-10",q?"border-primary bg-primary/5":"border-border",c),children:[l?(0,d.jsx)(f.A,{className:"size-5 animate-spin text-muted-foreground"}):(0,d.jsx)(g.A,{className:"size-5 text-muted-foreground"}),(0,d.jsxs)("div",{className:"space-y-1",children:[(0,d.jsx)("p",{className:"text-sm font-medium",children:"Drop migrations here"}),(0,d.jsx)("p",{className:"max-w-md text-xs text-muted-foreground",children:b??"A folder of .sql files, or one split into apply/ and revert/ (or up/ and down/). Revert files are optional, and you can add more files later."})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)(i.$,{size:"sm",variant:"outline",disabled:l,onClick:()=>s.current?.click(),children:[(0,d.jsx)(h,{"data-icon":"inline-start"}),"Choose folder"]}),(0,d.jsx)(i.$,{size:"sm",variant:"ghost",disabled:l,onClick:()=>t.current?.click(),children:"Choose files"})]}),m&&(0,d.jsx)("p",{className:"max-w-sm text-xs text-destructive",children:m}),(0,d.jsx)("input",{ref:s,type:"file",multiple:!0,className:"sr-only",onChange:a=>{let{files:b}=a.target;b&&b.length>0&&k(b),a.target.value=""}}),(0,d.jsx)("input",{ref:t,type:"file",multiple:!0,accept:".sql",className:"sr-only",onChange:a=>{let{files:b}=a.target;b&&b.length>0&&k(b),a.target.value=""}})]})}},37654:(a,b,c)=>{c.d(b,{x:()=>f});var d=c(48249),e=c(14490);function f({value:a,options:b,onChange:c,label:g}){return(0,d.jsx)("div",{role:"group","aria-label":g,className:"flex h-7 items-center rounded-md border bg-muted/50 p-0.5",children:b.map(b=>(0,d.jsx)("button",{type:"button","aria-pressed":b.value===a,onClick:()=>c(b.value),className:(0,e.cn)("h-full rounded-sm px-2 text-xs transition-colors",b.value===a?"bg-background text-foreground shadow-xs":"text-muted-foreground hover:text-foreground"),children:b.label},b.value))})}},41577:(a,b,c)=>{c.d(b,{A:()=>d});let d=(0,c(41926).A)("folder-up",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m9 13 3-3 3 3",key:"1pxg3c"}]])},45414:(a,b,c)=>{c.d(b,{A:()=>d});let d=(0,c(41926).A)("clipboard-check",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]])},56918:(a,b,c)=>{c.d(b,{Ai:()=>o,Nz:()=>n,Zy:()=>l,mj:()=>p});var d=c(14490),e=c(67657);let f=new Set(["apply","up","forward"]),g=new Set(["revert","down","rollback","undo"]),h=[".up",".apply",".forward"],i=[".down",".revert",".rollback",".undo"];function j(a){return a.split("/").filter(a=>a.length>0)}function k(a){return a.replace(/[-_]+/g," ").trim()}function l(a,b){let c=/(\d+)|(\D+)/g,d=a.match(c)??[],e=b.match(c)??[],f=Math.min(d.length,e.length);for(let a=0;a<f;a+=1){let b=d[a],c=e[a],f=/^\d+$/.test(b)&&/^\d+$/.test(c)?Number(b)-Number(c):b.localeCompare(c);if(0!==f)return f}return d.length-e.length}function m(a){let b=a.replace(/\r\n/g,"\n").trim(),c=0x811c9dc5,d=0x1000193;for(let a=0;a<b.length;a+=1){let e=b.charCodeAt(a);c=Math.imul(c^e,0x1000193)>>>0,d=Math.imul(d+e,0x85ebca6b)>>>0}return`${c.toString(16).padStart(8,"0")}${d.toString(16).padStart(8,"0")}`}function n(a){let b={applies:new Map,reverts:new Map,skipped:[],errors:[]},c=a.filter(a=>{var b;let c=j(b=a.path).at(-1)??b;return!c.startsWith(".")&&/\.sql$/i.test(c)});if(0===c.length)return b.errors.push("No .sql files in there."),b;let d=c.reduce((a,b)=>a+b.text.length,0);if(d>4e6)return b.errors.push(`That is ${q(d)} of SQL, over the ${q(4e6)} limit.`),b;for(let a of c){if(a.text.length>5e5){b.skipped.push(`${a.path} — over ${q(5e5)}`);continue}if(a.text.includes("\0")){b.skipped.push(`${a.path} — not text`);continue}if(!a.text.trim()){b.skipped.push(`${a.path} — empty`);continue}let{direction:c,stem:d}=function(a){let b=j(a),c=(b.at(-1)??a).replace(/\.sql$/i,"");for(let a of b.slice(0,-1)){let b=a.toLowerCase();if(g.has(b))return{direction:"revert",stem:c};if(f.has(b))return{direction:"apply",stem:c}}let d=c.toLowerCase();for(let a of i)if(d.endsWith(a))return{direction:"revert",stem:c.slice(0,-a.length)};for(let a of h)if(d.endsWith(a))return{direction:"apply",stem:c.slice(0,-a.length)};return{direction:"apply",stem:c}}(a.path),{version:e,name:l}=function(a){let b=/^[Vv](\d+(?:[._]\d+)*)__(.*)$/.exec(a);if(b)return{version:b[1].replace(/_/g,"."),name:k(b[2])};let c=/^(\d+)(?:[-_.\s]+(.*))?$/.exec(a);return c?{version:c[1],name:k(c[2]??"")}:{version:a,name:k(a)}}(d),m=("apply"===c?b.applies:b.reverts).get(e);if(m){b.skipped.push(`${a.path} — ${m.path} is already version ${e}`);continue}"apply"===c?b.applies.set(e,{path:a.path,sql:a.text,name:l}):b.reverts.set(e,{path:a.path,sql:a.text})}return 0===b.applies.size&&0===b.reverts.size&&b.errors.push("None of those .sql files could be read as a migration."),b}function o(a,b){let c=new Map(a.map(a=>[a.version,{...a}])),d=[...b.skipped],f=0,g=0,h=0;for(let[a,h]of b.applies){let b=c.get(a);if(b){b.applySql!==h.sql&&(g+=1),b.name=h.name||b.name,b.applyPath=h.path,b.applySql=h.sql,b.checksum=m(h.sql),b.transaction=(0,e.Ol)(h.sql).mode;continue}if(c.size>=500){d.push(`${h.path} — over 500 migrations`);continue}c.set(a,{version:a,name:h.name||a,applyPath:h.path,applySql:h.sql,checksum:m(h.sql),transaction:(0,e.Ol)(h.sql).mode}),f+=1}for(let[a,e]of b.reverts){let b=c.get(a);if(!b){d.push(`${e.path} — no migration ${a} to revert`);continue}b.revertPath=e.path,b.revertSql=e.sql,h+=1}return{steps:[...c.values()].sort((a,b)=>l(a.version,b.version)),added:f,updated:g,reverts:h,skipped:d}}function p(a){return{id:(0,d.z)(),name:a.trim().replace(/\s+/g," ").slice(0,80)||"Migrations",importedAt:Date.now(),steps:[],skipped:[]}}function q(a){return a<1024?`${a} B`:a<1048576?`${Math.round(a/1024)} KB`:`${(a/1048576).toFixed(1)} MB`}},66280:(a,b,c)=>{c.d(b,{S:()=>k,j:()=>j});var d=c(31417),e=c(300),f=c(4106),g=c(56918),h=c(72428),i=c(14490);let j=(0,d.v)()((0,e.Zr)((a,b)=>({sets:[],history:[],ledgerSchema:h.aC,setLedgerSchema:b=>{(0,h.hD)(b)&&a({ledgerSchema:b})},createSet:b=>{let c=(0,g.mj)(b);return a(a=>({sets:[...a.sets,c]})),c.id},addFiles:(c,d)=>{let e=b().sets.find(a=>a.id===c),h=(0,g.Nz)(d),i=(0,g.Ai)(e?.steps??[],h);return e&&a(a=>({sets:a.sets.map(a=>a.id===c?{...a,steps:i.steps,skipped:i.skipped,importedAt:Date.now()}:a)})),(0,f.L)("migrations.import",{name:e?.name,added:i.added,updated:i.updated,reverts:i.reverts,skipped:i.skipped.length}),i},renameSet:(b,c)=>{let d=c.trim().replace(/\s+/g," ").slice(0,80);d&&a(a=>({sets:a.sets.map(a=>a.id===b?{...a,name:d}:a)}))},removeStep:(b,c)=>a(a=>({sets:a.sets.map(a=>a.id===b?{...a,steps:a.steps.filter(a=>a.version!==c)}:a)})),removeSet:c=>{let d=b().sets.find(a=>a.id===c);a(a=>({sets:a.sets.filter(a=>a.id!==c)})),(0,f.L)("migrations.remove",{name:d?.name})},record:b=>a(a=>({history:[{...b,id:(0,i.z)(),ranAt:Date.now()},...a.history].slice(0,300)})),clearHistory:b=>a(a=>({history:b?a.history.filter(a=>a.setId!==b):[]}))}),{name:"ytdb:migrations"}));function k(a){return j(b=>b.sets.find(b=>b.id===a)??null)}},67657:(a,b,c)=>{c.d(b,{Ol:()=>i,TA:()=>j,qb:()=>k});let d=/^[ \t]*--+[ \t]*ytdb:[ \t]*no-?transaction\b/im,e=new Set(["begin","start"]),f=new Set(["commit","end"]),g=new Set(["rollback"]);function h(a){return void 0!==a&&(a>="A"&&a<="Z"||a>="a"&&a<="z"||"_"===a)||void 0!==a&&a>="0"&&a<="9"}function i(a){if(d.test(a))return{mode:"unwrapped",sql:a,atomic:!1};let b=function(a){let b=[],c=0,d=0,e=d=>{let e=function(a,b){let c=b;for(;c<a.length;){let b=a[c];if(" "===b||" "===b||"\n"===b||"\r"===b){c+=1;continue}if("-"===b&&"-"===a[c+1]){for(;c<a.length&&"\n"!==a[c];)c+=1;continue}if("/"===b&&"*"===a[c+1]){let b=a.indexOf("*/",c+2);c=-1===b?a.length:b+2;continue}break}return c}(a,c);if(e>=d)return;let f=e;for(;f<a.length&&h(a[f]);)f+=1;b.push({at:e,end:d,keyword:a.slice(e,f).toLowerCase()})};for(;d<a.length;){let b=a[d];if("-"===b&&"-"===a[d+1]){for(;d<a.length&&"\n"!==a[d];)d+=1;continue}if("/"===b&&"*"===a[d+1]){let b=a.indexOf("*/",d+2);d=-1===b?a.length:b+2;continue}if("'"===b||'"'===b){d=function(a,b,c){let d=b+1;for(;d<a.length;){if(a[d]===c){if(a[d+1]===c){d+=2;continue}return d+1}d+=1}return d}(a,d,b);continue}if("$"===b){let b=function(a,b){if("$"!==a[b])return null;let c=b+1;for(;c<a.length&&h(a[c]);)c+=1;return"$"!==a[c]?null:a.slice(b,c+1)}(a,d);if(b){let c=a.indexOf(b,d+b.length);d=-1===c?a.length:c+b.length;continue}}if(";"===b){e(d+1),d+=1,c=d;continue}d+=1}return e(a.length),b}(a),c=b.filter(a=>e.has(a.keyword)||f.has(a.keyword)||g.has(a.keyword));if(0===c.length)return{mode:"wrapped-by-ytdb",sql:a,atomic:!0};let i=b[0],j=b[b.length-1];return 2===c.length&&c[0]===i&&c[1]===j&&e.has(i.keyword)&&f.has(j.keyword)?{mode:"self-wrapped",sql:a.slice(0,i.at)+a.slice(i.end,j.at)+a.slice(j.end),atomic:!0}:{mode:"self-managed",sql:a,atomic:!1}}function j(a){switch(a){case"unwrapped":return"Marked `-- ytdb:no-transaction`, so it runs with no transaction. A failure partway leaves the statements before it applied.";case"self-managed":return"This file commits more than once, so YTDB runs it as written and records it afterwards. A failure partway can leave it half applied and unrecorded.";default:return null}}function k(a){return"unwrapped"===a?"no transaction":"self-managed"===a?"self-managed":null}},69357:(a,b,c)=>{c.d(b,{A:()=>d});let d=(0,c(41926).A)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},72428:(a,b,c)=>{c.d(b,{R9:()=>e,aC:()=>d,hD:()=>f});let d="maintenance",e="ytdb_migrations";function f(a){return"string"==typeof a&&a.length>0&&a.length<=63&&/^[A-Za-z_][A-Za-z0-9_$]*$/.test(a)}},76829:(a,b,c)=>{c.d(b,{l:()=>f});var d=c(48249),e=c(37654);function f({caption:a,pane:b,onPaneChange:c,historyCount:g,migrationsLabel:h="Migrations"}){return(0,d.jsxs)("footer",{className:"flex shrink-0 items-center gap-2 border-t px-4 py-1.5 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{className:"min-w-0 truncate",children:a}),(0,d.jsx)("div",{className:"ml-auto",children:(0,d.jsx)(e.x,{label:"Migrations pane",value:b,onChange:c,options:[{value:"migrations",label:h},{value:"history",label:g>0?`History (${g})`:"History"}]})})]})}},77963:(a,b,c)=>{c.d(b,{H:()=>q});var d=c(48249),e=c(45535),f=c(14807),g=c(45414),h=c(29774),i=c(35471),j=c(30770),k=c(25297),l=c(66280),m=c(14490);let n={applied:"applied",reverted:"reverted",marked:"marked",unmarked:"unmarked",failed:"failed"};function o({kind:a}){switch(a){case"failed":return(0,d.jsx)(e.A,{className:"size-3.5 shrink-0 text-destructive"});case"reverted":return(0,d.jsx)(f.A,{className:"size-3.5 shrink-0 text-amber-600 dark:text-amber-400"});case"marked":return(0,d.jsx)(g.A,{className:"size-3.5 shrink-0 text-muted-foreground"});case"unmarked":return(0,d.jsx)(h.A,{className:"size-3.5 shrink-0 text-muted-foreground"});default:return(0,d.jsx)(i.A,{className:"size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400"})}}function p({event:a,connection:b}){return(0,d.jsxs)("div",{className:"flex items-start gap-2 border-b px-4 py-2 text-xs last:border-b-0",children:[(0,d.jsx)("span",{className:"mt-0.5",children:(0,d.jsx)(o,{kind:a.kind})}),(0,d.jsx)("span",{className:(0,m.cn)("mt-px shrink-0 rounded-md px-1.5 text-[11px]","failed"===a.kind?"bg-destructive/10 text-destructive":"reverted"===a.kind?"bg-amber-500/15 text-amber-700 dark:text-amber-400":"bg-muted text-muted-foreground"),children:n[a.kind]}),(0,d.jsx)("span",{className:"shrink-0 font-mono text-muted-foreground",children:a.version}),(0,d.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,d.jsx)("span",{className:"truncate",children:a.name}),a.error&&(0,d.jsx)("span",{className:"mt-1 block font-mono text-[11px] whitespace-pre-wrap text-destructive",children:a.error})]}),a.setName&&(0,d.jsx)("span",{className:"hidden max-w-32 shrink-0 truncate text-muted-foreground/60 lg:inline",children:a.setName}),(0,d.jsxs)("span",{className:"flex shrink-0 items-center gap-1 text-muted-foreground",children:[b&&(0,d.jsx)(j.F,{connection:b,className:"size-1.5"}),a.connectionName]}),a.appliedBy&&(0,d.jsx)("span",{className:"hidden shrink-0 text-muted-foreground/60 xl:inline",children:a.appliedBy}),(0,d.jsx)("span",{className:"shrink-0 tabular-nums text-muted-foreground/70",children:null===a.durationMs?"":`${a.durationMs} ms`}),(0,d.jsx)("span",{className:"shrink-0 text-muted-foreground/70",title:a.fromLedger?"Read from the database's own ledger":"Run from this browser",children:new Date(a.at).toLocaleString()})]})}function q({events:a,connections:b,loading:c}){let e=(0,l.j)(a=>a.clearHistory),f=new Map(b.map(a=>[a.id,a])),g=a.filter(a=>!a.fromLedger).length;return 0===a.length?(0,d.jsx)("p",{className:"px-4 py-6 text-sm text-muted-foreground",children:c?"Reading ledgers…":"Nothing has been applied to these databases yet. Every run shows up here, along with what each database's own ledger already records."}):(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2 px-4 py-1.5",children:[(0,d.jsxs)("span",{className:"min-w-0 truncate text-xs text-muted-foreground",children:[a.length," event",1===a.length?"":"s",", newest first \xb7 from each database’s ledger and this browser’s own log"]}),g>0&&(0,d.jsx)(k.$,{size:"xs",variant:"ghost",title:"Clears this browser's log. The databases' ledgers are untouched.",onClick:()=>e(),children:"Clear local log"})]}),(0,d.jsx)("div",{className:"border-t",children:a.map(a=>(0,d.jsx)(p,{event:a,connection:f.get(a.connectionId)},a.id))})]})}},78931:(a,b,c)=>{c.d(b,{FY:()=>h,ay:()=>g,e:()=>l,eh:()=>i,gj:()=>k,kB:()=>m,nb:()=>j});var d=c(56918);let e={steps:[],blockedBy:null};function f(a){let b=new Map;for(let c of a?.entries??[])b.set(c.version,c);return b}function g(a,b){return b?b.entries.find(b=>b.version===a.version)??null:null}function h(a,b){if(!b)return"unknown";let c=g(a,b);return c?c.checksum&&c.checksum!==a.checksum?"drifted":"applied":"pending"}function i(a,b){let c={total:a?.steps.length??0,applied:0,drifted:0,pending:0,foreign:0};if(!a)return c;for(let d of a.steps){let a=h(d,b);"applied"===a?c.applied+=1:"drifted"===a?c.drifted+=1:"pending"===a&&(c.pending+=1)}return c.foreign=j(a,b).length,c}function j(a,b){if(!b)return[];let c=new Set((a?.steps??[]).map(a=>a.version));return b.entries.filter(a=>!c.has(a.version)).sort((a,b)=>(0,d.Zy)(a.version,b.version))}function k(a,b,c){if(!a||!b)return e;let d=[];for(let e of a.steps)if("pending"===h(e,b)&&d.push(e),void 0!==c&&e.version===c)break;return{steps:d,blockedBy:null}}function l(a,b,c){if(!a||!b)return e;let g=f(b),h=[];for(let b of[...a.steps].reverse()){if(void 0!==c&&0>(0,d.Zy)(b.version,c))break;if(g.has(b.version)){if(!b.revertSql)return{steps:h,blockedBy:b};h.push(b)}}return{steps:h,blockedBy:null}}function m(a,b){if(!a||!b)return null;let c=f(b);for(let b of[...a.steps].reverse())if(c.has(b.version))return b;return null}}};
1
+ "use strict";exports.id=702,exports.ids=[702],exports.modules={453:(a,b,c)=>{c.d(b,{x:()=>d});function d(a,b){let c=new Map(a.map(a=>[a.connection.id,a])),d=b.filter(a=>c.has(a.connectionId)).map(a=>({id:a.id,connectionId:a.connectionId,connectionName:a.connectionName,version:a.version,name:a.name,at:a.ranAt,kind:"failed"===a.status?"failed":a.recorded?"apply"===a.direction?"marked":"unmarked":"apply"===a.direction?"applied":"reverted",durationMs:a.durationMs,error:a.error,setName:a.setName,fromLedger:!1})),e=new Map;for(let a of d){let b=`${a.connectionId}:${a.version}`,c=e.get(b);(!c||a.at>c.at)&&e.set(b,a)}let f=[...d];for(let b of a)for(let a of b.ledger?.entries??[]){let c=`${b.connection.id}:${a.version}`,d=e.get(c);if(d&&("applied"===d.kind||"marked"===d.kind)){d.appliedBy=a.appliedBy;continue}f.push({id:`ledger:${b.connection.id}:${a.version}`,connectionId:b.connection.id,connectionName:b.connection.name,version:a.version,name:a.name||a.version,at:function(a){let b=Date.parse(a);return Number.isNaN(b)?0:b}(a.appliedAt),kind:"applied",durationMs:a.durationMs,setName:a.setName,appliedBy:a.appliedBy,fromLedger:!0})}return f.sort((a,b)=>b.at-a.at)}},14807:(a,b,c)=>{c.d(b,{A:()=>d});let d=(0,c(41926).A)("undo",[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]])},29774:(a,b,c)=>{c.d(b,{A:()=>d});let d=(0,c(41926).A)("clipboard-x",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m14.5 11.5-5 5",key:"1eaq8h"}],["path",{d:"m9.5 11.5 5 5",key:"1exjew"}]])},32278:(a,b,c)=>{c.d(b,{k:()=>p,$:()=>o});var d=c(48249),e=c(67484),f=c(69357),g=c(41577);let h=(0,c(41926).A)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);var i=c(25297);function j(a){let b=a.createReader?.();return b?new Promise((a,c)=>{let d=[],e=()=>{b.readEntries(b=>{0===b.length||d.length>=2e3?a(d):(d.push(...b),e())},c)};e()}):Promise.resolve([])}async function k(a,b,c,d){if(d.length>=2e3||c>6||a.name.startsWith("."))return;let e=b?`${b}/${a.name}`:a.name;if(a.isFile){if(!/\.sql$/i.test(a.name))return;let b=await new Promise((b,c)=>{a.file?a.file(b,c):c(Error(`Could not read ${a.name}`))});d.push({path:e,text:await b.text()});return}if(a.isDirectory)for(let b of(await j(a)))await k(b,e,c+1,d)}async function l(a){let b=[];for(let c of Array.from(a.items)){if("file"!==c.kind)continue;let a=c.webkitGetAsEntry?.();a&&b.push(a)}if(0===b.length){let b=Array.from(a.files).filter(a=>/\.sql$/i.test(a.name));return 0===b.length?null:{name:"Migrations",files:await Promise.all(b.map(async a=>({path:a.name,text:await a.text()})))}}let c=1===b.length&&b[0].isDirectory?b[0]:null,d=[];if(c){for(let a of(await j(c)))await k(a,"",1,d);return{name:c.name,files:d}}for(let a of b)await k(a,"",0,d);return d.length>0?{name:"Migrations",files:d}:null}async function m(a){let b,c=Array.from(a).filter(a=>/\.sql$/i.test(a.name));if(0===c.length)return null;let d=new Set(c.map(a=>(a.webkitRelativePath||a.name).split("/")[0])),e=1===d.size&&((b=c[0]).webkitRelativePath||b.name).includes("/")?[...d][0]:null;return{name:e??"Migrations",files:await Promise.all(c.slice(0,2e3).map(async a=>{let b=a.webkitRelativePath||a.name;return{path:e?b.slice(e.length+1):b,text:await a.text()}}))}}var n=c(14490);function o(a){let[b,c]=(0,e.useState)(!1),[d,f]=(0,e.useState)(null);return{importFrom:(0,e.useCallback)(async b=>{c(!0),f(null);try{let c=b instanceof FileList?await m(b):await l(b);if(!c||0===c.files.length)return void f("No .sql files in there.");a(c)}catch(a){f(a instanceof Error?a.message:"Couldn’t read that folder.")}finally{c(!1)}},[a]),busy:b,error:d,clearError:()=>f(null)}}function p({onFiles:a,hint:b,className:c,compact:j=!1}){let{importFrom:k,busy:l,error:m}=o(a),[q,r]=(0,e.useState)(!1),s=(0,e.useRef)(null),t=(0,e.useRef)(null);return(0,d.jsxs)("div",{onDragOver:a=>{a.preventDefault(),r(!0)},onDragLeave:()=>r(!1),onDrop:a=>{a.preventDefault(),r(!1),k(a.dataTransfer)},className:(0,n.cn)("flex flex-col items-center justify-center gap-3 rounded-lg border border-dashed text-center transition-colors",j?"gap-2 px-4 py-6":"px-6 py-10",q?"border-primary bg-primary/5":"border-border",c),children:[l?(0,d.jsx)(f.A,{className:"size-5 animate-spin text-muted-foreground"}):(0,d.jsx)(g.A,{className:"size-5 text-muted-foreground"}),(0,d.jsxs)("div",{className:"space-y-1",children:[(0,d.jsx)("p",{className:"text-sm font-medium",children:"Drop migrations here"}),(0,d.jsx)("p",{className:"max-w-md text-xs text-muted-foreground",children:b??"A folder of .sql files, or one split into apply/ and revert/ (or up/ and down/). Revert files are optional, and you can add more files later."})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)(i.$,{size:"sm",variant:"outline",disabled:l,onClick:()=>s.current?.click(),children:[(0,d.jsx)(h,{"data-icon":"inline-start"}),"Choose folder"]}),(0,d.jsx)(i.$,{size:"sm",variant:"ghost",disabled:l,onClick:()=>t.current?.click(),children:"Choose files"})]}),m&&(0,d.jsx)("p",{className:"max-w-sm text-xs text-destructive",children:m}),(0,d.jsx)("input",{ref:s,type:"file",multiple:!0,className:"sr-only",onChange:a=>{let{files:b}=a.target;b&&b.length>0&&k(b),a.target.value=""}}),(0,d.jsx)("input",{ref:t,type:"file",multiple:!0,accept:".sql",className:"sr-only",onChange:a=>{let{files:b}=a.target;b&&b.length>0&&k(b),a.target.value=""}})]})}},37654:(a,b,c)=>{c.d(b,{x:()=>f});var d=c(48249),e=c(14490);function f({value:a,options:b,onChange:c,label:g}){return(0,d.jsx)("div",{role:"group","aria-label":g,className:"flex h-7 items-center rounded-md border bg-muted/50 p-0.5",children:b.map(b=>(0,d.jsx)("button",{type:"button","aria-pressed":b.value===a,onClick:()=>c(b.value),className:(0,e.cn)("h-full rounded-sm px-2 text-xs transition-colors",b.value===a?"bg-background text-foreground shadow-xs":"text-muted-foreground hover:text-foreground"),children:b.label},b.value))})}},41577:(a,b,c)=>{c.d(b,{A:()=>d});let d=(0,c(41926).A)("folder-up",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m9 13 3-3 3 3",key:"1pxg3c"}]])},45414:(a,b,c)=>{c.d(b,{A:()=>d});let d=(0,c(41926).A)("clipboard-check",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]])},56918:(a,b,c)=>{c.d(b,{Ai:()=>o,Nz:()=>n,Zy:()=>l,mj:()=>p,wQ:()=>s});var d=c(14490),e=c(67657);let f=new Set(["apply","up","forward"]),g=new Set(["revert","down","rollback","undo"]),h=[".up",".apply",".forward"],i=[".down",".revert",".rollback",".undo"];function j(a){return a.split("/").filter(a=>a.length>0)}function k(a){return a.replace(/[-_]+/g," ").trim()}function l(a,b){let c=/(\d+)|(\D+)/g,d=a.match(c)??[],e=b.match(c)??[],f=Math.min(d.length,e.length);for(let a=0;a<f;a+=1){let b=d[a],c=e[a],f=/^\d+$/.test(b)&&/^\d+$/.test(c)?Number(b)-Number(c):b.localeCompare(c);if(0!==f)return f}return d.length-e.length}function m(a){let b=a.replace(/\r\n/g,"\n").trim(),c=0x811c9dc5,d=0x1000193;for(let a=0;a<b.length;a+=1){let e=b.charCodeAt(a);c=Math.imul(c^e,0x1000193)>>>0,d=Math.imul(d+e,0x85ebca6b)>>>0}return`${c.toString(16).padStart(8,"0")}${d.toString(16).padStart(8,"0")}`}function n(a){let b={applies:new Map,reverts:new Map,skipped:[],errors:[]},c=a.filter(a=>{var b;let c=j(b=a.path).at(-1)??b;return!c.startsWith(".")&&/\.sql$/i.test(c)});if(0===c.length)return b.errors.push("No .sql files in there."),b;let d=c.reduce((a,b)=>a+b.text.length,0);if(d>4e6)return b.errors.push(`That is ${r(d)} of SQL, over the ${r(4e6)} limit.`),b;for(let a of c){if(a.text.length>5e5){b.skipped.push(`${a.path} — over ${r(5e5)}`);continue}if(a.text.includes("\0")){b.skipped.push(`${a.path} — not text`);continue}if(!a.text.trim()){b.skipped.push(`${a.path} — empty`);continue}let{direction:c,stem:d}=function(a){let b=j(a),c=(b.at(-1)??a).replace(/\.sql$/i,"");for(let a of b.slice(0,-1)){let b=a.toLowerCase();if(g.has(b))return{direction:"revert",stem:c};if(f.has(b))return{direction:"apply",stem:c}}let d=c.toLowerCase();for(let a of i)if(d.endsWith(a))return{direction:"revert",stem:c.slice(0,-a.length)};for(let a of h)if(d.endsWith(a))return{direction:"apply",stem:c.slice(0,-a.length)};return{direction:"apply",stem:c}}(a.path),{version:e,name:l}=function(a){let b=/^[Vv](\d+(?:[._]\d+)*)__(.*)$/.exec(a);if(b)return{version:b[1].replace(/_/g,"."),name:k(b[2])};let c=/^(\d+)(?:[-_.\s]+(.*))?$/.exec(a);return c?{version:c[1],name:k(c[2]??"")}:{version:a,name:k(a)}}(d),m=("apply"===c?b.applies:b.reverts).get(e);if(m){b.skipped.push(`${a.path} — ${m.path} is already version ${e}`);continue}"apply"===c?b.applies.set(e,{path:a.path,sql:a.text,name:l}):b.reverts.set(e,{path:a.path,sql:a.text})}return 0===b.applies.size&&0===b.reverts.size&&b.errors.push("None of those .sql files could be read as a migration."),b}function o(a,b){let c=new Map(a.map(a=>[a.version,{...a}])),d=[...b.skipped],f=0,g=0,h=0;for(let[a,h]of b.applies){let b=c.get(a);if(b){b.applySql!==h.sql&&(g+=1),b.name=h.name||b.name,b.applyPath=h.path,b.applySql=h.sql,b.checksum=m(h.sql),b.transaction=(0,e.Ol)(h.sql).mode;continue}if(c.size>=500){d.push(`${h.path} — over 500 migrations`);continue}c.set(a,{version:a,name:h.name||a,applyPath:h.path,applySql:h.sql,checksum:m(h.sql),transaction:(0,e.Ol)(h.sql).mode}),f+=1}for(let[a,e]of b.reverts){let b=c.get(a);if(!b){d.push(`${e.path} — no migration ${a} to revert`);continue}b.revertPath=e.path,b.revertSql=e.sql,h+=1}return{steps:[...c.values()].sort((a,b)=>l(a.version,b.version)),added:f,updated:g,reverts:h,skipped:d}}function p(a){return{id:(0,d.z)(),name:q(a),importedAt:Date.now(),steps:[],skipped:[]}}function q(a){return a.trim().replace(/\s+/g," ").slice(0,80)||"Migrations"}function r(a){return a<1024?`${a} B`:a<1048576?`${Math.round(a/1024)} KB`:`${(a/1048576).toFixed(1)} MB`}function s(a,b){let c=[],f=[];for(let a of[...b].sort((a,b)=>l(a.version,b.version))){if(!a.applySql){c.push(a.version);continue}f.push({version:a.version,name:a.name||a.version,applyPath:`${a.version} (from the ledger)`,applySql:a.applySql,checksum:m(a.applySql),revertPath:a.revertSql?`${a.version} revert (from the ledger)`:void 0,revertSql:a.revertSql,transaction:(0,e.Ol)(a.applySql).mode})}return{set:{id:(0,d.z)(),name:q(a),importedAt:Date.now(),steps:f,skipped:[]},missing:c}}},66280:(a,b,c)=>{c.d(b,{S:()=>k,j:()=>j});var d=c(31417),e=c(300),f=c(4106),g=c(56918),h=c(72428),i=c(14490);let j=(0,d.v)()((0,e.Zr)((a,b)=>({sets:[],history:[],ledgerSchema:h.aC,setLedgerSchema:b=>{(0,h.hD)(b)&&a({ledgerSchema:b})},createSet:b=>{let c=(0,g.mj)(b);return a(a=>({sets:[...a.sets,c]})),c.id},addFiles:(c,d)=>{let e=b().sets.find(a=>a.id===c),h=(0,g.Nz)(d),i=(0,g.Ai)(e?.steps??[],h);return e&&a(a=>({sets:a.sets.map(a=>a.id===c?{...a,steps:i.steps,skipped:i.skipped,importedAt:Date.now()}:a)})),(0,f.L)("migrations.import",{name:e?.name,added:i.added,updated:i.updated,reverts:i.reverts,skipped:i.skipped.length}),i},adoptSet:b=>(a(a=>({sets:[...a.sets,b]})),(0,f.L)("migrations.import",{name:b.name,migrations:b.steps.length,source:"ledger"}),b.id),renameSet:(b,c)=>{let d=c.trim().replace(/\s+/g," ").slice(0,80);d&&a(a=>({sets:a.sets.map(a=>a.id===b?{...a,name:d}:a)}))},removeStep:(b,c)=>a(a=>({sets:a.sets.map(a=>a.id===b?{...a,steps:a.steps.filter(a=>a.version!==c)}:a)})),removeSet:c=>{let d=b().sets.find(a=>a.id===c);a(a=>({sets:a.sets.filter(a=>a.id!==c)})),(0,f.L)("migrations.remove",{name:d?.name})},record:b=>a(a=>({history:[{...b,id:(0,i.z)(),ranAt:Date.now()},...a.history].slice(0,300)})),clearHistory:b=>a(a=>({history:b?a.history.filter(a=>a.setId!==b):[]}))}),{name:"ytdb:migrations"}));function k(a){return j(b=>b.sets.find(b=>b.id===a)??null)}},67657:(a,b,c)=>{c.d(b,{Ol:()=>i,TA:()=>j,qb:()=>k});let d=/^[ \t]*--+[ \t]*ytdb:[ \t]*no-?transaction\b/im,e=new Set(["begin","start"]),f=new Set(["commit","end"]),g=new Set(["rollback"]);function h(a){return void 0!==a&&(a>="A"&&a<="Z"||a>="a"&&a<="z"||"_"===a)||void 0!==a&&a>="0"&&a<="9"}function i(a){if(d.test(a))return{mode:"unwrapped",sql:a,atomic:!1};let b=function(a){let b=[],c=0,d=0,e=d=>{let e=function(a,b){let c=b;for(;c<a.length;){let b=a[c];if(" "===b||" "===b||"\n"===b||"\r"===b){c+=1;continue}if("-"===b&&"-"===a[c+1]){for(;c<a.length&&"\n"!==a[c];)c+=1;continue}if("/"===b&&"*"===a[c+1]){let b=a.indexOf("*/",c+2);c=-1===b?a.length:b+2;continue}break}return c}(a,c);if(e>=d)return;let f=e;for(;f<a.length&&h(a[f]);)f+=1;b.push({at:e,end:d,keyword:a.slice(e,f).toLowerCase()})};for(;d<a.length;){let b=a[d];if("-"===b&&"-"===a[d+1]){for(;d<a.length&&"\n"!==a[d];)d+=1;continue}if("/"===b&&"*"===a[d+1]){let b=a.indexOf("*/",d+2);d=-1===b?a.length:b+2;continue}if("'"===b||'"'===b){d=function(a,b,c){let d=b+1;for(;d<a.length;){if(a[d]===c){if(a[d+1]===c){d+=2;continue}return d+1}d+=1}return d}(a,d,b);continue}if("$"===b){let b=function(a,b){if("$"!==a[b])return null;let c=b+1;for(;c<a.length&&h(a[c]);)c+=1;return"$"!==a[c]?null:a.slice(b,c+1)}(a,d);if(b){let c=a.indexOf(b,d+b.length);d=-1===c?a.length:c+b.length;continue}}if(";"===b){e(d+1),d+=1,c=d;continue}d+=1}return e(a.length),b}(a),c=b.filter(a=>e.has(a.keyword)||f.has(a.keyword)||g.has(a.keyword));if(0===c.length)return{mode:"wrapped-by-ytdb",sql:a,atomic:!0};let i=b[0],j=b[b.length-1];return 2===c.length&&c[0]===i&&c[1]===j&&e.has(i.keyword)&&f.has(j.keyword)?{mode:"self-wrapped",sql:a.slice(0,i.at)+a.slice(i.end,j.at)+a.slice(j.end),atomic:!0}:{mode:"self-managed",sql:a,atomic:!1}}function j(a){switch(a){case"unwrapped":return"Marked `-- ytdb:no-transaction`, so it runs with no transaction. A failure partway leaves the statements before it applied.";case"self-managed":return"This file commits more than once, so YTDB runs it as written and records it afterwards. A failure partway can leave it half applied and unrecorded.";default:return null}}function k(a){return"unwrapped"===a?"no transaction":"self-managed"===a?"self-managed":null}},69357:(a,b,c)=>{c.d(b,{A:()=>d});let d=(0,c(41926).A)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},72428:(a,b,c)=>{c.d(b,{R9:()=>e,aC:()=>d,hD:()=>f});let d="maintenance",e="ytdb_migrations";function f(a){return"string"==typeof a&&a.length>0&&a.length<=63&&/^[A-Za-z_][A-Za-z0-9_$]*$/.test(a)}},76829:(a,b,c)=>{c.d(b,{l:()=>f});var d=c(48249),e=c(37654);function f({caption:a,pane:b,onPaneChange:c,historyCount:g,migrationsLabel:h="Migrations"}){return(0,d.jsxs)("footer",{className:"flex shrink-0 items-center gap-2 border-t px-4 py-1.5 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{className:"min-w-0 truncate",children:a}),(0,d.jsx)("div",{className:"ml-auto",children:(0,d.jsx)(e.x,{label:"Migrations pane",value:b,onChange:c,options:[{value:"migrations",label:h},{value:"history",label:g>0?`History (${g})`:"History"}]})})]})}},77963:(a,b,c)=>{c.d(b,{H:()=>q});var d=c(48249),e=c(45535),f=c(14807),g=c(45414),h=c(29774),i=c(35471),j=c(30770),k=c(25297),l=c(66280),m=c(14490);let n={applied:"applied",reverted:"reverted",marked:"marked",unmarked:"unmarked",failed:"failed"};function o({kind:a}){switch(a){case"failed":return(0,d.jsx)(e.A,{className:"size-3.5 shrink-0 text-destructive"});case"reverted":return(0,d.jsx)(f.A,{className:"size-3.5 shrink-0 text-amber-600 dark:text-amber-400"});case"marked":return(0,d.jsx)(g.A,{className:"size-3.5 shrink-0 text-muted-foreground"});case"unmarked":return(0,d.jsx)(h.A,{className:"size-3.5 shrink-0 text-muted-foreground"});default:return(0,d.jsx)(i.A,{className:"size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400"})}}function p({event:a,connection:b}){return(0,d.jsxs)("div",{className:"flex items-start gap-2 border-b px-4 py-2 text-xs last:border-b-0",children:[(0,d.jsx)("span",{className:"mt-0.5",children:(0,d.jsx)(o,{kind:a.kind})}),(0,d.jsx)("span",{className:(0,m.cn)("mt-px shrink-0 rounded-md px-1.5 text-[11px]","failed"===a.kind?"bg-destructive/10 text-destructive":"reverted"===a.kind?"bg-amber-500/15 text-amber-700 dark:text-amber-400":"bg-muted text-muted-foreground"),children:n[a.kind]}),(0,d.jsx)("span",{className:"shrink-0 font-mono text-muted-foreground",children:a.version}),(0,d.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,d.jsx)("span",{className:"truncate",children:a.name}),a.error&&(0,d.jsx)("span",{className:"mt-1 block font-mono text-[11px] whitespace-pre-wrap text-destructive",children:a.error})]}),a.setName&&(0,d.jsx)("span",{className:"hidden max-w-32 shrink-0 truncate text-muted-foreground/60 lg:inline",children:a.setName}),(0,d.jsxs)("span",{className:"flex shrink-0 items-center gap-1 text-muted-foreground",children:[b&&(0,d.jsx)(j.F,{connection:b,className:"size-1.5"}),a.connectionName]}),a.appliedBy&&(0,d.jsx)("span",{className:"hidden shrink-0 text-muted-foreground/60 xl:inline",children:a.appliedBy}),(0,d.jsx)("span",{className:"shrink-0 tabular-nums text-muted-foreground/70",children:null===a.durationMs?"":`${a.durationMs} ms`}),(0,d.jsx)("span",{className:"shrink-0 text-muted-foreground/70",title:a.fromLedger?"Read from the database's own ledger":"Run from this browser",children:new Date(a.at).toLocaleString()})]})}function q({events:a,connections:b,loading:c}){let e=(0,l.j)(a=>a.clearHistory),f=new Map(b.map(a=>[a.id,a])),g=a.filter(a=>!a.fromLedger).length;return 0===a.length?(0,d.jsx)("p",{className:"px-4 py-6 text-sm text-muted-foreground",children:c?"Reading ledgers…":"Nothing has been applied to these databases yet. Every run shows up here, along with what each database's own ledger already records."}):(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2 px-4 py-1.5",children:[(0,d.jsxs)("span",{className:"min-w-0 truncate text-xs text-muted-foreground",children:[a.length," event",1===a.length?"":"s",", newest first \xb7 from each database’s ledger and this browser’s own log"]}),g>0&&(0,d.jsx)(k.$,{size:"xs",variant:"ghost",title:"Clears this browser's log. The databases' ledgers are untouched.",onClick:()=>e(),children:"Clear local log"})]}),(0,d.jsx)("div",{className:"border-t",children:a.map(a=>(0,d.jsx)(p,{event:a,connection:f.get(a.connectionId)},a.id))})]})}},78931:(a,b,c)=>{c.d(b,{FY:()=>h,ay:()=>g,e:()=>l,eh:()=>i,gj:()=>k,kB:()=>m,lF:()=>n,nb:()=>j});var d=c(56918);let e={steps:[],blockedBy:null};function f(a){let b=new Map;for(let c of a?.entries??[])b.set(c.version,c);return b}function g(a,b){return b?b.entries.find(b=>b.version===a.version)??null:null}function h(a,b){if(!b)return"unknown";let c=g(a,b);return c?c.checksum&&c.checksum!==a.checksum?"drifted":"applied":"pending"}function i(a,b){let c={total:a?.steps.length??0,applied:0,drifted:0,pending:0,foreign:0};if(!a)return c;for(let d of a.steps){let a=h(d,b);"applied"===a?c.applied+=1:"drifted"===a?c.drifted+=1:"pending"===a&&(c.pending+=1)}return c.foreign=j(a,b).length,c}function j(a,b){if(!b)return[];let c=new Set((a?.steps??[]).map(a=>a.version));return b.entries.filter(a=>!c.has(a.version)).sort((a,b)=>(0,d.Zy)(a.version,b.version))}function k(a,b,c){if(!a||!b)return e;let d=[];for(let e of a.steps)if("pending"===h(e,b)&&d.push(e),void 0!==c&&e.version===c)break;return{steps:d,blockedBy:null}}function l(a,b,c){if(!a||!b)return e;let g=f(b),h=[];for(let b of[...a.steps].reverse()){if(void 0!==c&&0>(0,d.Zy)(b.version,c))break;if(g.has(b.version)){if(!b.revertSql)return{steps:h,blockedBy:b};h.push(b)}}return{steps:h,blockedBy:null}}function m(a,b){if(!a||!b)return null;let c=f(b);for(let b of[...a.steps].reverse())if(c.has(b.version))return b;return null}function n(a,b){let c=new Set(b.map(a=>a.toLowerCase())),e=new Map;for(let b of a)for(let a of b.ledger?.entries??[]){let d=a.setName?.trim();if(!d||c.has(d.toLowerCase()))continue;let f=e.get(d)??new Map,g=f.get(b.connection.id)??new Set;g.add(a.version),f.set(b.connection.id,g),e.set(d,f)}return[...e.entries()].map(([b,c])=>{let e=new Set;for(let a of c.values())for(let b of a)e.add(b);return{name:b,versions:[...e].sort(d.Zy),total:e.size,applied:a.map(a=>({connectionId:a.connection.id,connectionName:a.connection.name,count:c.get(a.connection.id)?.size??0}))}}).sort((a,b)=>a.name.localeCompare(b.name))}}};
@@ -1 +1 @@
1
- exports.id=729,exports.ids=[729],exports.modules={1777:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>f});var d=c(5735),e=c(34766);async function f({children:a,params:b}){let{connectionId:c}=await b;return(0,d.jsx)(e.ExplorerShell,{connectionId:c,children:a})}},8508:(a,b,c)=>{"use strict";c.d(b,{Ar:()=>d,US:()=>h,s5:()=>j,tT:()=>k,vI:()=>i});let d={commandPalette:"⌘⇧P",tableSearch:"⌘P",columnSearch:"⌘/",sqlEditor:"⌘E",switchConnection:"⌘⇧E",compareSchema:"⌘⇧D",migrations:"⌘⇧M"};function e(){let a=new Set;return{register:b=>(a.add(b),()=>{a.delete(b)}),open(){for(let b of a)b()}}}let f=e(),g=e(),h=f.register,i=f.open,j=g.register,k=g.open},13656:(a,b,c)=>{"use strict";c.d(b,{E:()=>f});var d=c(48249),e=c(14490);function f({className:a,...b}){return(0,d.jsx)("div",{"data-slot":"skeleton",className:(0,e.cn)("animate-pulse rounded-md bg-muted",a),...b})}},20886:(a,b,c)=>{"use strict";c.d(b,{Y:()=>e});var d=c(67484);function e(a,b){let[c,e]=(0,d.useState)(0),[f,g]=(0,d.useState)({key:"",error:null}),h=`${c}:${a}`,i=(0,d.useCallback)(()=>e(a=>a+1),[]),j=f.key!==h;return{data:f.data,error:j?null:f.error,loading:j,reload:i}}},21883:(a,b,c)=>{"use strict";c.d(b,{F:()=>f});var d=c(16950);async function e(a,b,c){let e,f=await (0,d.Qv)(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b),signal:c}),g=await f.text();if(!g)throw Error(`YTDB bridge returned an empty response (HTTP ${f.status}). Restart YTDB to update the local bridge.`);try{e=JSON.parse(g)}catch{throw Error(`YTDB bridge returned an invalid response (HTTP ${f.status}).`)}if(!f.ok)throw Error((e&&"object"==typeof e&&"error"in e&&"string"==typeof e.error?e.error:f.statusText)||`YTDB bridge request failed with HTTP ${f.status}.`);return e}let f={tables:(a,b)=>e("/api/tables",{connectionUrl:a},b),rows:(a,b,c)=>e("/api/rows",{connectionUrl:a,query:b},c),query:(a,b,c)=>e("/api/query",{connectionUrl:a,sql:b},c),updateCell:(a,b,c)=>e("/api/cell",{connectionUrl:a,update:b},c),insertRow:(a,b,c)=>e("/api/insert-row",{connectionUrl:a,insertion:b},c),updateRow:(a,b,c)=>e("/api/update-row",{connectionUrl:a,update:b},c),deleteRows:(a,b,c)=>e("/api/delete-rows",{connectionUrl:a,deletion:b},c),related:(a,b,c)=>e("/api/related",{connectionUrl:a,lookups:b},c),lookup:(a,b,c)=>e("/api/lookup",{connectionUrl:a,query:b},c),definition:(a,b,c)=>e("/api/definition",{connectionUrl:a,table:b},c),schema:(a,b)=>e("/api/schema",{connectionUrl:a},b),ledger:(a,b,c)=>e("/api/ledger",{connectionUrl:a,ledgerSchema:b},c),migrate:(a,b,c)=>e("/api/migrate",{connectionUrl:a,migration:b},c)}},34766:(a,b,c)=>{"use strict";c.d(b,{ExplorerShell:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call ExplorerShell() from the server but ExplorerShell is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Users/theobourgeois/code/db-studio/src/components/explorer/explorer-shell.tsx","ExplorerShell")},35412:(a,b,c)=>{Promise.resolve().then(c.bind(c,59809))},44231:(a,b,c)=>{"use strict";c.d(b,{Z:()=>i,k:()=>j});var d=c(48249),e=c(67484),f=c(21883),g=c(20886);let h=(0,e.createContext)(null);function i({connection:a,children:b}){let c=(0,g.Y)(a.url,b=>f.F.tables(a.url,b));return(0,d.jsx)(h.Provider,{value:{connection:a,tables:c},children:b})}function j(){let a=(0,e.useContext)(h);if(!a)throw Error("useExplorerContext must be used inside ExplorerProvider");return a}},53286:(a,b,c)=>{"use strict";c.d(b,{F:()=>k});var d=c(48249);c(67484);var e=c(99058),f=c(40336),g=c(69856),h=c(18656),i=c(41764),j=c(14490);function k({className:a,children:b,...c}){return(0,d.jsxs)(e.V,{"data-slot":"scroll-area",className:(0,j.cn)("relative",a),...c,children:[(0,d.jsx)(f.B,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:b}),(0,d.jsx)(l,{}),(0,d.jsx)(g.I,{})]})}function l({className:a,orientation:b="vertical",...c}){return(0,d.jsx)(h.V,{"data-slot":"scroll-area-scrollbar","data-orientation":b,orientation:b,className:(0,j.cn)("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",a),...c,children:(0,d.jsx)(i.l,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}},59809:(a,b,c)=>{"use strict";c.d(b,{ExplorerShell:()=>as});var d=c(48249),e=c(2116),f=c.n(e),g=c(96006),h=c(25297),i=c(98609),j=c(91732),k=c(99598),l=c(78260),m=c(44231),n=c(19099),o=c(67484),p=c(7178),q=c(93217),r=c(1206),s=c(24277),t=c(29813),u=c(88877),v=c(53286),w=c(13656),x=c(8508),y=c(89366),z=c(14490),A=c(89216),B=c(15386),C=c(82244),D=c(30770);function E({current:a}){let b=(0,n.useRouter)(),c=(0,j.Z)(a=>a.connections);return(0,d.jsxs)(C.rI,{children:[(0,d.jsxs)(C.ty,{className:"flex h-8 w-full items-center justify-between gap-2 rounded-lg px-2 text-left font-medium outline-none hover:bg-muted/60 focus-visible:ring-3 focus-visible:ring-ring/50 data-open:bg-muted/60",children:[(0,d.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,d.jsx)(D.F,{connection:a}),(0,d.jsx)("span",{className:"truncate",children:a.name}),a.layoutGroup&&(0,d.jsx)(A.A,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),(0,d.jsx)(B.A,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),(0,d.jsxs)(C.SQ,{align:"start",className:"w-(--anchor-width)",children:[c.map(c=>(0,d.jsxs)(C._2,{onClick:()=>b.push(`/${c.id}`),className:c.id===a.id?"font-medium":void 0,children:[(0,d.jsx)(D.F,{connection:c}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate",children:c.name}),c.layoutGroup&&c.layoutGroup===a.layoutGroup&&(0,d.jsx)(A.A,{className:"size-3.5 shrink-0 text-muted-foreground"})]},c.id)),(0,d.jsx)(C.mB,{}),(0,d.jsx)(C._2,{render:(0,d.jsx)(f(),{href:"/"}),children:"Manage connections"})]})]})}var F=c(79820),G=c(9008),H=c(39470),I=c(91995);function J(a,b){let c=a.trim(),d=c.lastIndexOf(".");return -1===d?c:"schema"===b?c.slice(0,d):c.slice(d+1)}function K({text:a,query:b}){if(!b)return a;let c=[],e=a.toLocaleLowerCase(),f=b.toLocaleLowerCase(),g=0,h=e.indexOf(f);if(-1===h)return a;for(;-1!==h;)h>g&&c.push(a.slice(g,h)),c.push((0,d.jsx)("mark",{className:"rounded-[3px] bg-yellow-300/90 px-px text-yellow-950 dark:bg-yellow-400/85 dark:text-yellow-950",children:a.slice(h,h+b.length)},h)),g=h+b.length,h=e.indexOf(f,g);return g<a.length&&c.push(a.slice(g)),c}function L({connectionId:a,table:b,search:c,pinned:e,showSchema:g,active:h,reorderable:i,dragging:j,dropEdge:k,onTogglePin:l,onDragStart:m,onDragOver:n,onDrop:o,onDragEnd:p,onMove:q}){return(0,d.jsxs)("li",{onDragOver:n,onDrop:o,className:(0,z.cn)("group/table-row relative flex h-7 items-center rounded-md text-[13px] transition-[color,background-color,opacity] hover:bg-muted/60",h&&"bg-muted text-foreground",!h&&"text-foreground/80",j&&"opacity-45","before"===k&&"before:absolute before:inset-x-1 before:top-0 before:z-10 before:h-0.5 before:-translate-y-1/2 before:rounded-full before:bg-primary","after"===k&&"after:absolute after:inset-x-1 after:bottom-0 after:z-10 after:h-0.5 after:translate-y-1/2 after:rounded-full after:bg-primary"),children:[i&&(0,d.jsx)("button",{type:"button",draggable:!0,"aria-label":`Reorder ${b.schema}.${b.name}`,title:"Drag to reorder; use Up and Down arrow keys",onDragStart:m,onDragEnd:p,onKeyDown:a=>{("ArrowUp"===a.key||"ArrowDown"===a.key)&&(a.preventDefault(),q?.("ArrowUp"===a.key?-1:1))},className:"ml-1.5 flex size-5 shrink-0 cursor-grab touch-none items-center justify-center rounded text-muted-foreground opacity-50 outline-none transition-[color,background-color,opacity] hover:bg-foreground/10 hover:text-foreground hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:opacity-100 active:cursor-grabbing",children:(0,d.jsx)(G.A,{className:"size-3.5"})}),(0,d.jsxs)(f(),{href:`/${a}/${encodeURIComponent(b.schema)}/${encodeURIComponent(b.name)}`,className:(0,z.cn)("flex h-full min-w-0 flex-1 items-center gap-1.5 rounded-md outline-none focus-visible:ring-2 focus-visible:ring-ring/60",i?"pl-1":"pl-6"),children:[(0,d.jsx)("span",{className:"truncate",children:(0,d.jsx)(K,{text:b.name,query:J(c,"table")})}),g?(0,d.jsx)("span",{className:"ml-auto max-w-20 truncate text-[10px] text-muted-foreground",children:b.schema}):"view"===b.kind&&(0,d.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"view"})]}),(0,d.jsx)("button",{type:"button","aria-label":`${e?"Unpin":"Pin"} ${b.schema}.${b.name}`,"aria-pressed":e,title:e?"Unpin table":"Pin table",onClick:()=>l(b),className:(0,z.cn)("mr-0.5 flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground opacity-0 outline-none transition-[color,background-color,opacity] hover:bg-foreground/10 hover:text-foreground hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:opacity-100 group-hover/table-row:opacity-100",e&&"text-foreground"),children:(0,d.jsx)(H.A,{className:(0,z.cn)("size-3.5",e&&"fill-current")})})]})}function M({label:a,count:b,collapsed:c,pinned:e,search:f,onToggle:g}){return(0,d.jsxs)("button",{type:"button","aria-expanded":!c,onClick:g,className:"flex h-7 w-full cursor-pointer items-center gap-1 rounded-md px-1 text-xs font-medium text-muted-foreground outline-none transition-colors hover:bg-muted/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60",children:[(0,d.jsx)(I.A,{className:(0,z.cn)("size-3.5 transition-transform",!c&&"rotate-90")}),e&&(0,d.jsx)(H.A,{className:"mr-0.5 size-3 fill-current"}),(0,d.jsx)("span",{className:"truncate",children:e?a:(0,d.jsx)(K,{text:a,query:J(f,"schema")})}),(0,d.jsx)("span",{className:"ml-auto pr-1 tabular-nums opacity-60",children:b})]})}function N({connectionId:a,tables:b,search:c,collapsedSchemas:e,pinnedTables:f,onToggleSchema:g,onTogglePin:h,onReorderPinned:i}){let j=(0,n.useParams)(),[k,l]=(0,o.useState)(!1),[m,p]=(0,o.useState)(null),[q,r]=(0,o.useState)(null),s=new Map(b.map(a=>[(0,y.i)(a),a])),t=f.flatMap(a=>{let b=s.get(a);return b?[b]:[]});function u(){p(null),r(null)}return 0===b.length?(0,d.jsx)("p",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:c.trim()?"No tables match your search":"No tables in these schemas"}):(0,d.jsxs)("div",{className:"flex flex-col gap-1 px-2 pb-4",children:[t.length>0&&(0,d.jsxs)("div",{className:"mb-1 border-b border-border/60 pb-1",children:[(0,d.jsx)(M,{label:"Pinned tables",count:t.length,collapsed:k,pinned:!0,search:c,onToggle:()=>l(a=>!a)}),!k&&(0,d.jsx)("ul",{children:t.map(b=>{let e=(0,y.i)(b);return(0,d.jsx)(L,{connectionId:a,table:b,search:c,pinned:!0,showSchema:!0,active:j.schema===b.schema&&j.table===b.name,reorderable:!0,dragging:m===e,dropEdge:q?.key===e?q.edge:null,onTogglePin:h,onDragStart:a=>{a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",e),p(e),r(null)},onDragOver:a=>(function(a,b){if(!m||m===b)return;a.preventDefault(),a.dataTransfer.dropEffect="move";let c=a.currentTarget.getBoundingClientRect(),d=a.clientY<c.top+c.height/2?"before":"after";r(a=>a?.key===b&&a.edge===d?a:{key:b,edge:d})})(a,e),onDrop:a=>{let b,c;return a.preventDefault(),b=m??a.dataTransfer.getData("text/plain"),c=q?.key===e?q.edge:"before",void(b&&i(b,e,c),u())},onDragEnd:u,onMove:a=>{let b,c;return b=t.findIndex(a=>(0,y.i)(a)===e),void((c=t[b+a])&&i(e,(0,y.i)(c),-1===a?"before":"after"))}},e)})})]}),(function(a){let b=new Map;for(let c of a)b.set(c.schema,[...b.get(c.schema)??[],c]);return[...b.entries()].sort(([a],[b])=>{let c;return((c=new Map([["public",0],["auth",1]])).get(a)??2)-(c.get(b)??2)||a.localeCompare(b)})})(b).map(([b,i])=>{let k=e.includes(b);return(0,d.jsxs)("div",{children:[(0,d.jsx)(M,{label:b,count:i.length,collapsed:k,search:c,onToggle:()=>g(b)}),!k&&(0,d.jsx)("ul",{children:i.map(b=>(0,d.jsx)(L,{connectionId:a,table:b,search:c,pinned:f.includes((0,y.i)(b)),active:j.schema===b.schema&&j.table===b.name,onTogglePin:h},(0,y.i)(b)))})]},b)})]})}function O(a){return Math.min(480,Math.max(180,Math.round(a)))}function P(a,b){let c=new Map([["public",0],["auth",1]]);return(c.get(a)??2)-(c.get(b)??2)||a.localeCompare(b)}function Q(a,b,c){let d=b.trim().toLocaleLowerCase();return a.filter(a=>(null===c||!!c.includes(a.schema))&&(!d||a.name.toLocaleLowerCase().includes(d)||`${a.schema}.${a.name}`.toLocaleLowerCase().includes(d)))}function R({href:a,active:b,shortcut:c,children:e}){return(0,d.jsxs)(f(),{href:a,"aria-current":b?"page":void 0,className:(0,z.cn)((0,h.r)({variant:b?"secondary":"ghost",size:"sm"}),"h-8 w-full justify-start px-2"),children:[e,(0,d.jsx)("kbd",{className:"ml-auto font-mono text-[10px] text-muted-foreground/55",children:c})]})}function S({width:a,onWidthChange:b,onCollapse:c}){let e=(0,n.usePathname)(),{connection:f,tables:g}=(0,m.k)(),[i,l]=(0,k.DE)(f.id),z=(0,j.Z)(a=>a.connections.length>1),[A,B]=(0,o.useState)(()=>O(a)),C=(0,o.useRef)(null),D=(0,o.useMemo)(()=>[...new Set((g.data??[]).map(a=>a.schema))].sort(P),[g.data]),G=(0,o.useMemo)(()=>null===i.selectedSchemas?null:i.selectedSchemas.filter(a=>D.includes(a)),[i.selectedSchemas,D]),H=(0,o.useMemo)(()=>Q(g.data??[],i.search,G),[g.data,i.search,G]),I=`/${encodeURIComponent(f.id)}`,J=`${I}/query`,K=`${I}/diff`,L=`${I}/migrations`;function M(a,b){let c=new Set(Q(g.data??[],a,b).map(a=>a.schema));return i.collapsedSchemas.filter(a=>!c.has(a))}return(0,d.jsxs)("aside",{id:"database-explorer-sidebar",style:{width:A},className:"relative flex h-full shrink-0 flex-col border-r bg-sidebar",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2 border-b border-sidebar-border/60 p-2 pb-2.5",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1",children:[(0,d.jsx)("div",{className:"min-w-0 flex-1",children:(0,d.jsx)(E,{current:f})}),(0,d.jsx)(h.$,{variant:"ghost",size:"icon-sm","aria-label":"Collapse database sidebar",title:"Collapse sidebar",onClick:c,children:(0,d.jsx)(p.A,{})})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,d.jsxs)(R,{href:J,active:e===J,shortcut:x.Ar.sqlEditor,children:[(0,d.jsx)(q.A,{"data-icon":"inline-start"}),"SQL query"]}),(0,d.jsxs)(R,{href:L,active:e===L||e.startsWith(`${L}/`),shortcut:x.Ar.migrations,children:[(0,d.jsx)(r.A,{"data-icon":"inline-start"}),"Migrations"]}),z&&(0,d.jsxs)(R,{href:K,active:e===K,shortcut:x.Ar.compareSchema,children:[(0,d.jsx)(s.A,{"data-icon":"inline-start"}),"Compare schema"]})]}),(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)(t.A,{className:"pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted-foreground"}),(0,d.jsx)(u.p,{value:i.search,onChange:a=>{var b;l({search:b=a.target.value,collapsedSchemas:b.trim()?M(b,G):i.collapsedSchemas})},placeholder:"Search tables","aria-label":"Search tables",className:"h-9 bg-background/60 pr-9 pl-8"}),(0,d.jsx)("kbd",{className:"pointer-events-none absolute top-1/2 right-2.5 -translate-y-1/2 font-mono text-[10px] text-muted-foreground/55",children:x.Ar.tableSearch})]}),(0,d.jsx)(F.V,{schemas:D,selected:G,onChange:function(a){l({selectedSchemas:a,collapsedSchemas:i.search.trim()?M(i.search,a):i.collapsedSchemas})}})]}),(0,d.jsx)(v.F,{className:"min-h-0 flex-1 pt-1.5",children:g.error?(0,d.jsx)("p",{className:"px-3 py-4 text-xs text-destructive",children:g.error}):g.data?(0,d.jsx)(N,{connectionId:f.id,tables:H,search:i.search,collapsedSchemas:i.collapsedSchemas,pinnedTables:i.pinnedTables,onToggleSchema:function(a){l({collapsedSchemas:i.collapsedSchemas.includes(a)?i.collapsedSchemas.filter(b=>b!==a):[...i.collapsedSchemas,a]})},onTogglePin:function(a){let b=(0,y.i)(a);l({pinnedTables:i.pinnedTables.includes(b)?i.pinnedTables.filter(a=>a!==b):[...i.pinnedTables,b]})},onReorderPinned:function(a,b,c){if(a===b)return;let d=i.pinnedTables.filter(b=>b!==a),e=d.indexOf(b);-1!==e&&(d.splice(e+ +("after"===c),0,a),l({pinnedTables:d}))}}):(0,d.jsx)("div",{className:"flex flex-col gap-2 px-3 py-2",children:Array.from({length:8},(a,b)=>(0,d.jsx)(w.E,{className:"h-5 w-full"},b))})}),(0,d.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize database sidebar","aria-valuemin":180,"aria-valuemax":480,"aria-valuenow":A,tabIndex:0,title:"Drag to resize; double-click to reset",onPointerDown:function(a){a.preventDefault(),C.current={pointerId:a.pointerId,startX:a.clientX,startWidth:A},a.currentTarget.setPointerCapture(a.pointerId)},onPointerMove:function(a){let b=C.current;b&&b.pointerId===a.pointerId&&(a.preventDefault(),B(O(b.startWidth+a.clientX-b.startX)))},onPointerUp:function(a){let c=C.current;if(!c||c.pointerId!==a.pointerId)return;let d=O(c.startWidth+a.clientX-c.startX);C.current=null,B(d),a.currentTarget.hasPointerCapture(a.pointerId)&&a.currentTarget.releasePointerCapture(a.pointerId),b(d)},onPointerCancel:function(a){let c=C.current;c&&c.pointerId===a.pointerId&&(C.current=null,a.currentTarget.hasPointerCapture(a.pointerId)&&a.currentTarget.releasePointerCapture(a.pointerId),b(A))},onKeyDown:function(a){if("ArrowLeft"!==a.key&&"ArrowRight"!==a.key)return;a.preventDefault();let c=O(A+("ArrowLeft"===a.key?-1:1)*16);B(c),b(c)},onDoubleClick:function(a){a.preventDefault(),B(256),b(256)},className:"group/resize absolute inset-y-0 -right-1 z-30 w-2 cursor-col-resize touch-none outline-none after:absolute after:inset-y-0 after:left-1/2 after:w-px after:-translate-x-1/2 after:bg-transparent after:transition-colors hover:after:bg-primary focus-visible:after:bg-primary"})]})}var T=c(35471),U=c(89267),V=c(16280),W=c(61561);let X=new Set;var Y=c(93291);function Z(a,{nested:b=!1}={}){let c=(0,n.useRouter)(),d=(0,n.usePathname)(),{connection:e,tables:f}=(0,m.k)(),[g]=(0,k.DE)(e.id),h=`/${encodeURIComponent(e.id)}`,i=`${h}/${a}`,j=b?d===i||d.startsWith(`${i}/`):d===i;return{open:j,href:i,toggle:()=>c.push(j?function(){for(let a of g.recentTables){let b=(f.data??[]).find(b=>(0,y.i)(b)===a);if(b)return`${h}/${encodeURIComponent(b.schema)}/${encodeURIComponent(b.name)}`}return h}():i)}}function $(){let a=Z("migrations",{nested:!0});return{open:a.open,migrationsHref:a.href,toggle:a.toggle}}function _(){let a=Z("diff");return{open:a.open,diffHref:a.href,toggle:a.toggle}}function aa(){let a=Z("query");return{open:a.open,queryHref:a.href,toggle:a.toggle}}var ab=c(21883);function ac(a,b=""){return`/${encodeURIComponent(a)}${b}`}function ad(){let a=(0,n.useRouter)(),b=(0,n.useParams)(),{connection:c}=(0,m.k)(),d=(0,j.Z)(a=>a.connections),e=aa(),f=_(),g=e.open?"query":f.open?"diff":null,h=function(a,b){let c=a.findIndex(a=>a.id===b);if(!(a.length<2)&&-1!==c)return a[(c+1)%a.length]}(d,c.id);return{run:async function(){var c;if(!h)return;for(let a of X)a();let d=b.schema&&b.table?{schema:decodeURIComponent(b.schema),name:decodeURIComponent(b.table)}:null,e=!1;if(!g&&d)try{c=await ab.F.tables(h.url),e=c.some(a=>a.schema===d.schema&&a.name===d.name)}catch{}a.push(function(a,{pane:b,table:c,tableExists:d}){if(b)return ac(a,`/${b}`);if(c&&d)return ac(a,`/${encodeURIComponent(c.schema)}/${encodeURIComponent(c.name)}`);return ac(a)}(h.id,{pane:g,table:d,tableExists:e}))},enabled:void 0!==h,next:h}}function ae({text:a,query:b}){if(!b)return a;let c=a.toLocaleLowerCase(),e=b.toLocaleLowerCase(),f=c.indexOf(e);return -1===f?a:(0,d.jsxs)(d.Fragment,{children:[a.slice(0,f),(0,d.jsx)("mark",{className:"rounded-[3px] bg-yellow-300/90 px-px text-yellow-950 dark:bg-yellow-400/85 dark:text-yellow-950",children:a.slice(f,f+b.length)}),a.slice(f+b.length)]})}async function af(a){try{await navigator.clipboard.writeText(a)}catch{let b=document.createElement("textarea");b.value=a,b.style.position="fixed",b.style.opacity="0",document.body.appendChild(b),b.select(),document.execCommand("copy"),b.remove()}}function ag(){let a=(0,n.useRouter)(),b=(0,n.useParams)(),{connection:c,tables:e}=(0,m.k)(),f=aa(),g=_(),h=$(),i=(0,k.y3)(c.id),l=ad(),p=(0,j.Z)(a=>a.add),[q,r]=(0,k.DE)(c.id),[s,t]=(0,o.useState)(!1),[u,v]=(0,o.useState)("commands"),[w,A]=(0,o.useState)(""),[B,C]=(0,o.useState)(0),[D,E]=(0,o.useState)(!1),F=(0,o.useRef)(null),G=(0,o.useRef)(null),H=(0,o.useRef)(null),I=(0,o.useRef)(u),J=(0,V.C)(a=>a.theme),K=b.schema&&b.table?{schema:decodeURIComponent(b.schema),name:decodeURIComponent(b.table)}:null,L=!!K&&q.pinnedTables.includes((0,y.i)(K)),M=(0,k.lz)(a=>K?a.tables[`${c.id}:${(0,y.i)(K)}`]:void 0),N=(0,o.useMemo)(()=>[{id:"sql-editor",title:f.open?"Back to Table":"Open SQL Query",keywords:["new","query","sql","console","editor","close","back","table"],enabled:!0,shortcut:x.Ar.sqlEditor,run:()=>f.toggle()},{id:"switch-connection",title:l.next?`Switch Connection (${l.next.name})`:"Switch Connection",keywords:["database","env","environment","next","cycle","other"],enabled:l.enabled,shortcut:x.Ar.switchConnection,run:()=>void l.run()},{id:"migrations",title:h.open?"Back to Table":"Open Migrations",keywords:["migration","migrate","apply","revert","rollback","ledger","schema","run"],enabled:!0,shortcut:x.Ar.migrations,run:()=>h.toggle()},{id:"compare-schema",title:i.target?`Compare Schema with ${i.target.name}`:"Compare Schema",keywords:["diff","difference","migration","drift","prod","dev","schema","compare"],enabled:null!==i.target,shortcut:x.Ar.compareSchema,run:()=>g.toggle()},{id:"search-tables",title:"Search Tables",keywords:["find","jump","open","goto","table"],enabled:!0,shortcut:x.Ar.tableSearch,run:()=>window.requestAnimationFrame(()=>(0,x.tT)())},{id:"search-columns",title:"Search Columns",keywords:["find","jump","goto","column","field"],enabled:null!==K,shortcut:x.Ar.columnSearch,run:()=>window.requestAnimationFrame(()=>(0,x.vI)())},{id:"reload-tables",title:"Reload Tables",keywords:["refresh","reload","tables","sync"],enabled:!0,run:()=>e.reload()},{id:"pin-table",title:L?"Unpin Table":"Pin Table",keywords:["pin","unpin","favorite","star"],enabled:null!==K,run:()=>{if(!K)return;let a=(0,y.i)(K);r({pinnedTables:q.pinnedTables.includes(a)?q.pinnedTables.filter(b=>b!==a):[...q.pinnedTables,a]})}},{id:"clear-filters",title:"Clear Filters",keywords:["filter","reset","remove"],enabled:null!==K,run:()=>{K&&k.lz.getState().setTable(c.id,K,{filters:[],page:0})}},{id:"clear-search",title:"Clear Search",keywords:["find","search","reset"],enabled:null!==K&&!!M?.search,run:()=>{K&&k.lz.getState().setTable(c.id,K,{search:"",page:0})}},{id:"reset-columns",title:"Reset Columns",keywords:["pin","hide","frozen","layout","show"],enabled:null!==K,run:()=>{K&&k.lz.getState().setTable(c.id,K,{pinnedColumns:void 0,hiddenColumns:[]})}},{id:"copy-table",title:"Copy Schema.Table",keywords:["copy","name","qualified"],enabled:null!==K,run:()=>{K&&af((0,y.i)(K))}},{id:"color-theme",title:"Color Theme",keywords:["theme","appearance","dark","light","color","set","preferences"],enabled:!0,keepOpen:!0,run:()=>{let a=V.C.getState().theme,b=W.zG.findIndex(b=>b.id===a);v("themes"),A(""),C(-1===b?0:b)}},{id:"add-connection",title:"Add Connection",keywords:["new","database","postgres"],enabled:!0,run:()=>E(!0)}],[q.pinnedTables,i.target,c.id,h,L,g,r,f,l,K,M?.search,e]),O=(0,o.useMemo)(()=>w.trim()?(0,Y.R6)(w,N,a=>[a.title,...a.keywords].join(" ")).map(a=>a.item):N,[N,w]),P=(0,o.useMemo)(()=>w.trim()?(0,Y.R6)(w,[...W.zG],a=>[a.name,...a.keywords].join(" ")).map(a=>a.item):[...W.zG],[w]),Q="themes"===u?P:O,R="commands"===u?O[B]??null:null,S="themes"===u?P[B]??null:null;function X(a){a?.revertTheme&&"themes"===I.current&&(0,W.AZ)(V.C.getState().theme),t(!1),A(""),C(0),v("commands")}function Z(a){a.enabled&&(a.keepOpen||X({revertTheme:!0}),a.run())}function ab(a){V.C.getState().setTheme(a.id),(0,W.AZ)(a.id),X({revertTheme:!1})}return(0,d.jsxs)(d.Fragment,{children:[s&&(0,d.jsxs)("div",{ref:G,"data-command-palette":"",className:"fixed top-3 left-1/2 z-50 flex w-[min(36rem,calc(100%-1.5rem))] -translate-x-1/2 flex-col overflow-hidden rounded-lg border bg-popover text-popover-foreground shadow-lg ring-1 ring-foreground/10",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 border-b px-3",children:[(0,d.jsx)("span",{className:"font-mono text-sm text-muted-foreground",children:">"}),(0,d.jsx)("input",{ref:F,value:w,onChange:a=>A(a.target.value),onKeyDown:function(a){if("ArrowDown"===a.key){if(a.preventDefault(),0===Q.length)return;C(a=>(a+1)%Q.length);return}if("ArrowUp"===a.key){if(a.preventDefault(),0===Q.length)return;C(a=>(a-1+Q.length)%Q.length);return}if("Enter"===a.key){if(a.preventDefault(),"themes"===u){S&&ab(S);return}R&&Z(R)}},spellCheck:!1,autoComplete:"off",autoCorrect:"off",placeholder:"themes"===u?"Select color theme":"Type a command","aria-label":"themes"===u?"Color theme":"Command palette",className:"h-11 min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),(0,d.jsx)("div",{ref:H,role:"listbox","aria-label":"themes"===u?"Color themes":"Commands",className:"max-h-[min(24rem,50vh)] overflow-auto py-1",children:0===Q.length?(0,d.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"themes"===u?"No matching themes":"No matching commands"}):"themes"===u?P.map((a,b)=>{let c=b===B,e=a.id===J;return(0,d.jsxs)("button",{type:"button",role:"option","aria-selected":c,"data-active":c||void 0,onMouseEnter:()=>C(b),onClick:()=>ab(a),className:(0,z.cn)("flex h-8 w-full cursor-pointer items-center gap-2 px-3 text-left text-[13px] outline-none",c&&"bg-primary/10"),children:[(0,d.jsx)("span",{"aria-hidden":!0,className:"size-3.5 shrink-0 rounded-sm border",style:{background:a.swatch}}),(0,d.jsx)("span",{className:"min-w-0 truncate",children:(0,d.jsx)(ae,{text:a.name,query:w.trim()})}),e&&(0,d.jsx)(T.A,{className:"ml-auto size-3.5 shrink-0 text-muted-foreground"})]},a.id)}):O.map((a,b)=>{let c=b===B;return(0,d.jsxs)("button",{type:"button",role:"option","aria-selected":c,"aria-disabled":!a.enabled,"data-active":c||void 0,onMouseEnter:()=>C(b),onClick:()=>Z(a),className:(0,z.cn)("flex h-8 w-full cursor-pointer items-center px-3 text-left text-[13px] outline-none",c&&"bg-primary/10",!a.enabled&&"cursor-default opacity-40"),children:[(0,d.jsx)("span",{className:"min-w-0 truncate",children:(0,d.jsx)(ae,{text:a.title,query:w.trim()})}),a.shortcut&&(0,d.jsx)("kbd",{className:"ml-auto shrink-0 pl-3 font-mono text-[11px] text-muted-foreground/70",children:a.shortcut})]},a.id)})})]}),(0,d.jsx)(U.f,{open:D,onOpenChange:E,onSubmit:b=>{let{shareWith:c,...d}=b,e=p(d);(0,k.mQ)(e.id,c),a.push(`/${e.id}`)}})]})}function ah(){let{toggle:a}=aa(),{toggle:b}=_(),{toggle:c}=$(),{run:d}=ad(),e=(0,j.Z)(a=>a.connections.length>1);return(0,o.useRef)(a),(0,o.useRef)(b),(0,o.useRef)(c),(0,o.useRef)(d),(0,o.useRef)(e),null}var ai=c(36274),aj=c(21215),ak=c(83254);let al={pinned:"Pinned",recent:"Recent",tables:"Tables",connections:"Connections"};function am({text:a,query:b}){if(!b)return a;let c=a.toLocaleLowerCase(),e=b.toLocaleLowerCase(),f=c.indexOf(e);return -1===f?a:(0,d.jsxs)(d.Fragment,{children:[a.slice(0,f),(0,d.jsx)("mark",{className:"rounded-[3px] bg-yellow-300/90 px-px text-yellow-950 dark:bg-yellow-400/85 dark:text-yellow-950",children:a.slice(f,f+b.length)}),a.slice(f+b.length)]})}function an(a){try{return new URL(a).hostname}catch{return""}}function ao(a){return[a.name,an(a.url)].filter(Boolean)}function ap(a,b){let c=new Map([["public",0],["auth",1]]);return(c.get(a.schema)??2)-(c.get(b.schema)??2)||a.schema.localeCompare(b.schema)||a.name.localeCompare(b.name)}function aq(a,b){return a.map((a,c)=>0===c?{...a,section:b}:a)}function ar(){let a=(0,n.useRouter)(),b=(0,n.useParams)(),{connection:c,tables:e}=(0,m.k)(),f=(0,j.Z)(a=>a.connections),[g,h]=(0,o.useState)(!1),[i,l]=(0,o.useState)(""),[p,q]=(0,o.useState)(0),[r,s]=(0,o.useState)(null),u=(0,o.useRef)(null),v=(0,o.useRef)(null),w=(0,o.useRef)(null),x=f.find(a=>a.id===r)??null,A=x??c,B=x&&x.id!==c.id?x.url:null,C=function(a){let[b]=(0,o.useState)(()=>new Map),[c,d]=(0,o.useState)({url:"",error:null});if(!a)return{data:void 0,error:null,loading:!1};let e=c.url===a?c.data:b.get(a);return{data:e,error:c.url===a?c.error:null,loading:void 0===e}}(B),[E,F]=(0,k.DE)(c.id),[G,I]=(0,k.DE)(A.id),J=A.id===c.id?E:G,K=(0,o.useMemo)(()=>B?C.data??[]:e.data??[],[C.data,B,e.data]),L=B?C.loading:e.loading,M=B?C.error:null,N=(0,o.useMemo)(()=>[...new Set(K.map(a=>a.schema))],[K]),O=null===J.selectedSchemas?null:J.selectedSchemas.filter(a=>N.includes(a)),P=(0,o.useMemo)(()=>null===O?K:K.filter(a=>O.includes(a.schema)),[K,O]),Q=J.pinnedTables,R=J.recentTables,S=(0,o.useMemo)(()=>{let a,b;return -1===(b=(a=i.trim()).indexOf(":"))?{schema:null,table:a}:{schema:a.slice(0,b).trim(),table:a.slice(b+1).trim()}},[i]),T=S.table||(S.schema?"":i.trim()),U=(0,o.useMemo)(()=>{let a=new Set(Q),b=new Set(R),d=null===S.schema?null:function(a,b){if(!a)return b;let c=a.toLocaleLowerCase(),d=b.filter(a=>a.toLocaleLowerCase()===c);if(d.length>0)return d;let e=b.filter(a=>a.toLocaleLowerCase().startsWith(c));return e.length>0?e:(0,Y.R6)(a,b,a=>a).map(a=>a.item)}(S.schema,N),e=null===d?P:K.filter(a=>d.includes(a.schema)),g=new Map(e.map(a=>[(0,y.i)(a),a])),h=Q.flatMap(a=>{let b=g.get(a);return b?[b]:[]}),j=R.flatMap(b=>{let c=g.get(b);return!c||a.has(b)?[]:[c]}),k=(a,b)=>({type:"table",key:`table:${(0,y.i)(a)}`,table:a,...b}),l=a=>({type:"connection",key:`connection:${a.id}`,connection:a,current:a.id===c.id}),m=null===S.schema?i.trim():S.table,n=null===x&&null===S.schema;if(!m){let a=new Set([...h.map(a=>(0,y.i)(a)),...j.map(a=>(0,y.i)(a))]),d=e.filter(b=>!a.has((0,y.i)(b))).sort(ap),g=n?f.filter(a=>a.id!==c.id):[];return[...aq(h.map(a=>k(a,{pinned:!0})),"pinned"),...aq(j.map(a=>k(a,{pinned:!1,recent:!0})),"recent"),...aq(d.map(a=>k(a,{pinned:!1,recent:b.has((0,y.i)(a))})),"tables"),...aq(g.map(l),"connections")]}let o=(0,Y.UO)(m,e,a=>null===S.schema?[a.name,`${a.schema}.${a.name}`,a.schema]:[a.name]).map(c=>({...c,score:c.score+80*!!a.has((0,y.i)(c.item))+40*!!b.has((0,y.i)(c.item))})).sort((a,b)=>b.score-a.score).map(c=>k(c.item,{pinned:a.has((0,y.i)(c.item)),recent:b.has((0,y.i)(c.item))}));return[...aq(n?(0,Y.UO)(i,f,ao).map(a=>l(a.item)):[],"connections"),...aq(o,"tables")]},[K,c.id,f,x,S.schema,S.table,Q,i,R,N,P]),V=U[p]??null;function W(){s(null),q(0),u.current?.focus()}function X(b){var d,e;if(h(!1),l(""),q(0),s(null),"connection"===b.type){b.connection.id!==c.id&&a.push(`/${b.connection.id}`);return}a.push((d=A.id,e=b.table,`/${d}/${encodeURIComponent(e.schema)}/${encodeURIComponent(e.name)}`))}function Z(a){let b=(0,y.i)(a),d=J.pinnedTables.includes(b)?J.pinnedTables.filter(a=>a!==b):[...J.pinnedTables,b];(A.id===c.id?F:I)({pinnedTables:d})}let $=A.id===c.id&&b.schema&&b.table?`${decodeURIComponent(b.schema)}.${decodeURIComponent(b.table)}`:null;return g?(0,d.jsxs)("div",{ref:v,"data-table-palette":"",className:"fixed top-3 left-1/2 z-50 flex w-[min(36rem,calc(100%-1.5rem))] -translate-x-1/2 flex-col overflow-hidden rounded-lg border bg-popover text-popover-foreground shadow-lg ring-1 ring-foreground/10",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 border-b px-3",children:[(0,d.jsx)(t.A,{className:"size-4 shrink-0 text-muted-foreground"}),x&&(0,d.jsxs)("button",{type:"button",onClick:W,"aria-label":`Stop searching ${x.name}`,className:"flex h-6 max-w-40 shrink-0 items-center gap-1.5 rounded-md bg-muted px-1.5 text-xs outline-none hover:bg-muted/80",children:[(0,d.jsx)(D.F,{connection:x,className:"size-2"}),(0,d.jsx)("span",{className:"truncate",children:x.name})]}),(0,d.jsx)("input",{ref:u,value:i,onChange:a=>l(a.target.value),onKeyDown:function(a){if("ArrowDown"===a.key){if(a.preventDefault(),0===U.length)return;q(a=>(a+1)%U.length);return}if("ArrowUp"===a.key){if(a.preventDefault(),0===U.length)return;q(a=>(a-1+U.length)%U.length);return}if("Tab"===a.key){if(a.preventDefault(),x||a.shiftKey)return;V?.type==="connection"&&(s(V.connection.id),l(""),q(0));return}if("Backspace"===a.key&&""===i&&x){a.preventDefault(),W();return}"Enter"===a.key&&(a.preventDefault(),a.shiftKey&&V?.type==="table"?Z(V.table):V&&X(V))},spellCheck:!1,autoComplete:"off",autoCorrect:"off",placeholder:x?`Search tables in ${x.name}`:"Go to table (schema:name)","aria-label":x?`Go to table in ${x.name}`:"Go to table or connection",className:"h-11 min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),(0,d.jsx)("div",{ref:w,role:"listbox","aria-label":x?`Tables in ${x.name}`:"Tables and connections",className:"max-h-[min(24rem,50vh)] overflow-auto py-1",children:L&&0===K.length&&0===U.length?(0,d.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"Loading tables…"}):M&&0===K.length?(0,d.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:M}):0===U.length?(0,d.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:i.trim()?"No matches":"No tables"}):U.map((a,b)=>{let c=b===p;if("connection"===a.type){let e=an(a.connection.url);return(0,d.jsxs)("div",{children:[a.section&&(0,d.jsx)("p",{className:"px-3 pt-2 pb-1 text-[10px] font-medium tracking-wide text-muted-foreground uppercase",children:al[a.section]}),(0,d.jsxs)("button",{type:"button",role:"option","aria-selected":c,"data-active":c||void 0,onMouseEnter:()=>q(b),onClick:()=>X(a),className:(0,z.cn)("flex h-8 w-full cursor-pointer items-center gap-2 px-3 text-left text-[13px] outline-none",c&&"bg-primary/10"),children:[(0,d.jsx)(ai.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,d.jsx)(D.F,{connection:a.connection,className:"size-2"}),(0,d.jsx)("span",{className:(0,z.cn)("min-w-0 truncate",a.current&&"font-medium"),children:(0,d.jsx)(am,{text:a.connection.name,query:T})}),(0,d.jsx)("span",{className:"ml-auto flex min-w-0 shrink-0 items-center gap-2 text-[11px] text-muted-foreground",children:c?(0,d.jsx)("span",{children:"Tab to search"}):(0,d.jsx)("span",{className:"max-w-36 truncate",children:a.current?"current":e||"connection"})})]})]},a.key)}let e=(0,y.i)(a.table)===$;return(0,d.jsxs)("div",{children:[a.section&&(0,d.jsx)("p",{className:"px-3 pt-2 pb-1 text-[10px] font-medium tracking-wide text-muted-foreground uppercase",children:al[a.section]}),(0,d.jsxs)("div",{onMouseEnter:()=>q(b),className:(0,z.cn)("group/table-result flex items-center",c&&"bg-primary/10"),children:[(0,d.jsxs)("button",{type:"button",role:"option","aria-selected":c,"data-active":c||void 0,onClick:()=>X(a),className:"flex h-8 min-w-0 flex-1 cursor-pointer items-center gap-2 pl-3 text-left text-[13px] outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/60",children:[a.recent&&!a.pinned?(0,d.jsx)(aj.A,{className:"size-3.5 shrink-0 text-muted-foreground"}):(0,d.jsx)(ak.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,d.jsx)("span",{className:(0,z.cn)("min-w-0 truncate",e&&"font-medium"),children:(0,d.jsx)(am,{text:a.table.name,query:T})}),(0,d.jsxs)("span",{className:"ml-auto flex min-w-0 shrink-0 items-center gap-2 text-[11px] text-muted-foreground",children:["view"===a.table.kind&&(0,d.jsx)("span",{children:"view"}),(0,d.jsx)("span",{className:"max-w-36 truncate",children:a.table.schema})]})]}),(0,d.jsx)("button",{type:"button","aria-label":`${a.pinned?"Unpin":"Pin"} ${(0,y.i)(a.table)}`,"aria-pressed":a.pinned,title:a.pinned?"Unpin table":"Pin table",onClick:()=>Z(a.table),className:(0,z.cn)("mr-2 flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground opacity-0 outline-none transition-[color,background-color,opacity] hover:bg-foreground/10 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:opacity-100 group-hover/table-result:opacity-100",(a.pinned||c)&&"opacity-100",a.pinned&&"text-foreground"),children:(0,d.jsx)(H.A,{className:(0,z.cn)("size-3.5",a.pinned&&"fill-current")})})]})]},a.key)})}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-3 border-t px-3 py-1.5 text-[10px] text-muted-foreground",children:[(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"font-mono text-foreground/70",children:"↑↓"}),"Navigate"]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"font-mono text-foreground/70",children:"↵"}),"Open"]}),V?.type==="table"&&(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"font-mono text-foreground/70",children:"⇧↵"}),V.pinned?"Unpin":"Pin"]})]})]}):null}function as({connectionId:a,children:b}){let c=(0,i.p)(),e=(0,j.w)(a),[n,o]=(0,k.DE)(a);if(!c)return null;if(!e)return(0,d.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 text-muted-foreground",children:[(0,d.jsx)("p",{children:"Connection not found"}),(0,d.jsx)(f(),{href:"/",className:"text-foreground underline underline-offset-4",children:"Connections"})]});let p=(0,l.Mq)(e);return(0,d.jsxs)(m.Z,{connection:e,children:[(0,d.jsxs)("div",{className:"flex h-dvh flex-col overflow-hidden",children:[(0,d.jsx)("div",{"aria-hidden":!0,title:e.name,className:"h-1.5 w-full shrink-0",style:{background:p}}),(0,d.jsxs)("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[n.sidebarCollapsed?(0,d.jsxs)("aside",{className:"relative flex h-full w-10 shrink-0 justify-center border-r bg-sidebar pt-2",children:[(0,d.jsx)("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-1",style:{background:p}}),(0,d.jsx)(h.$,{variant:"ghost",size:"icon-sm","aria-label":"Show database sidebar",title:"Show sidebar",onClick:()=>o({sidebarCollapsed:!1}),children:(0,d.jsx)(g.A,{})})]}):(0,d.jsx)(S,{width:n.sidebarWidth,onWidthChange:a=>o({sidebarWidth:a}),onCollapse:()=>o({sidebarCollapsed:!0})},e.id),(0,d.jsx)("main",{className:"flex min-w-0 flex-1 flex-col",children:b})]})]}),(0,d.jsx)(ar,{}),(0,d.jsx)(ag,{}),(0,d.jsx)(ah,{})]})}},79820:(a,b,c)=>{"use strict";c.d(b,{V:()=>h});var d=c(48249),e=c(54183),f=c(69627),g=c(82244);function h({schemas:a,selected:b,onChange:c}){let i=null===b||b.length===a.length;return(0,d.jsxs)(g.rI,{children:[(0,d.jsxs)(g.ty,{className:"group flex h-9 w-full cursor-pointer items-center gap-2 rounded-lg border border-input bg-background/60 px-2.5 text-left text-sm outline-none transition-[border-color,background-color,box-shadow] hover:border-foreground/20 hover:bg-muted/50 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 data-open:border-foreground/20 data-open:bg-muted/60",children:[(0,d.jsx)(e.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium",children:null===b||b.length===a.length?"All schemas":0===b.length?"No schemas":1===b.length?b[0]:`${b.length} schemas`}),!i&&(0,d.jsxs)("span",{className:"rounded-md bg-muted px-1.5 py-0.5 text-[10px] tabular-nums text-muted-foreground",children:[b.length,"/",a.length]}),(0,d.jsx)(f.A,{className:"size-3.5 shrink-0 text-muted-foreground transition-transform group-data-open:rotate-180"})]}),(0,d.jsx)(g.SQ,{align:"start",sideOffset:6,className:"max-h-80 w-(--anchor-width) min-w-52",children:(0,d.jsxs)(g.I,{children:[(0,d.jsxs)(g.lp,{className:"flex items-center justify-between px-2 py-1.5",children:[(0,d.jsx)("span",{children:"Visible schemas"}),(0,d.jsx)("span",{className:"font-normal tabular-nums opacity-70",children:a.length})]}),(0,d.jsx)(g.hO,{checked:i,onCheckedChange:a=>c(a?null:[]),children:(0,d.jsx)("span",{className:"font-medium",children:"Show all schemas"})}),(0,d.jsx)(g.mB,{}),a.map(e=>(0,d.jsx)(g.hO,{checked:i||(b?.includes(e)??!1),onCheckedChange:d=>{let f,g;return f=b??a,void c((g=d?[...new Set([...f,e])]:f.filter(a=>a!==e)).length===a.length?null:g)},children:(0,d.jsx)("span",{className:"truncate",children:e})},e))]})})]})}},82676:(a,b,c)=>{Promise.resolve().then(c.bind(c,34766))},93291:(a,b,c)=>{"use strict";function d(a,b){if(0===b)return!0;let c=a[b-1];return"_"===c||"-"===c||" "===c||"."===c}function e(a,b,c){return f(a,b,a=>[c(a)])}function f(a,b,c){if(!a.trim())return[];let e=[];for(let f of b){let b=c(f),g=null;for(let c of b){let b=function(a,b){let c=a.trim().toLocaleLowerCase(),e=b.toLocaleLowerCase();if(!c)return 0;if(0===e.length)return null;if(e===c)return 1e4;if(e.startsWith(c))return 5e3-e.length;let f=e.indexOf(c);if(-1!==f)return 2400+1200*!!d(b,f)-f-e.length;let g=0,h=0,i=0;for(let a=0;a<e.length&&g<c.length;a+=1){if(e[a]!==c[g]){i=0;continue}h+=12,(i+=1)>1&&(h+=18*i),d(b,a)&&(h+=40),g+=1}if(g<c.length)return null;let j=b.split(/[_\-\s.]+/).map(a=>a[0]??"").join("").toLocaleLowerCase();return j.startsWith(c)?h+=2200:j.includes(c)&&(h+=700),h-(e.length-c.length)}(a,c);null!==b&&(null===g||b>g)&&(g=b)}null!==g&&e.push({item:f,score:g})}return e.sort((a,b)=>b.score!==a.score?b.score-a.score:c(a.item)[0]?.localeCompare(c(b.item)[0]??"")??0)}c.d(b,{R6:()=>e,UO:()=>f})}};
1
+ exports.id=729,exports.ids=[729],exports.modules={1777:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>f});var d=c(5735),e=c(34766);async function f({children:a,params:b}){let{connectionId:c}=await b;return(0,d.jsx)(e.ExplorerShell,{connectionId:c,children:a})}},8508:(a,b,c)=>{"use strict";c.d(b,{Ar:()=>d,US:()=>h,s5:()=>j,tT:()=>k,vI:()=>i});let d={commandPalette:"⌘⇧P",tableSearch:"⌘P",columnSearch:"⌘/",sqlEditor:"⌘E",switchConnection:"⌘⇧E",compareSchema:"⌘⇧D",migrations:"⌘⇧M"};function e(){let a=new Set;return{register:b=>(a.add(b),()=>{a.delete(b)}),open(){for(let b of a)b()}}}let f=e(),g=e(),h=f.register,i=f.open,j=g.register,k=g.open},13656:(a,b,c)=>{"use strict";c.d(b,{E:()=>f});var d=c(48249),e=c(14490);function f({className:a,...b}){return(0,d.jsx)("div",{"data-slot":"skeleton",className:(0,e.cn)("animate-pulse rounded-md bg-muted",a),...b})}},20886:(a,b,c)=>{"use strict";c.d(b,{Y:()=>e});var d=c(67484);function e(a,b){let[c,e]=(0,d.useState)(0),[f,g]=(0,d.useState)({key:"",error:null}),h=`${c}:${a}`,i=(0,d.useCallback)(()=>e(a=>a+1),[]),j=f.key!==h;return{data:f.data,error:j?null:f.error,loading:j,reload:i}}},21883:(a,b,c)=>{"use strict";c.d(b,{F:()=>f});var d=c(16950);async function e(a,b,c){let e,f=await (0,d.Qv)(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b),signal:c}),g=await f.text();if(!g)throw Error(`YTDB bridge returned an empty response (HTTP ${f.status}). Restart YTDB to update the local bridge.`);try{e=JSON.parse(g)}catch{throw Error(`YTDB bridge returned an invalid response (HTTP ${f.status}).`)}if(!f.ok)throw Error((e&&"object"==typeof e&&"error"in e&&"string"==typeof e.error?e.error:f.statusText)||`YTDB bridge request failed with HTTP ${f.status}.`);return e}let f={tables:(a,b)=>e("/api/tables",{connectionUrl:a},b),rows:(a,b,c)=>e("/api/rows",{connectionUrl:a,query:b},c),query:(a,b,c)=>e("/api/query",{connectionUrl:a,sql:b},c),updateCell:(a,b,c)=>e("/api/cell",{connectionUrl:a,update:b},c),insertRow:(a,b,c)=>e("/api/insert-row",{connectionUrl:a,insertion:b},c),updateRow:(a,b,c)=>e("/api/update-row",{connectionUrl:a,update:b},c),deleteRows:(a,b,c)=>e("/api/delete-rows",{connectionUrl:a,deletion:b},c),related:(a,b,c)=>e("/api/related",{connectionUrl:a,lookups:b},c),lookup:(a,b,c)=>e("/api/lookup",{connectionUrl:a,query:b},c),definition:(a,b,c)=>e("/api/definition",{connectionUrl:a,table:b},c),schema:(a,b)=>e("/api/schema",{connectionUrl:a},b),ledger:(a,b,c,d=!1)=>e("/api/ledger",{connectionUrl:a,ledgerSchema:b,withSql:d},c),migrate:(a,b,c)=>e("/api/migrate",{connectionUrl:a,migration:b},c)}},34766:(a,b,c)=>{"use strict";c.d(b,{ExplorerShell:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call ExplorerShell() from the server but ExplorerShell is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Users/theobourgeois/code/db-studio/src/components/explorer/explorer-shell.tsx","ExplorerShell")},35412:(a,b,c)=>{Promise.resolve().then(c.bind(c,59809))},44231:(a,b,c)=>{"use strict";c.d(b,{Z:()=>i,k:()=>j});var d=c(48249),e=c(67484),f=c(21883),g=c(20886);let h=(0,e.createContext)(null);function i({connection:a,children:b}){let c=(0,g.Y)(a.url,b=>f.F.tables(a.url,b));return(0,d.jsx)(h.Provider,{value:{connection:a,tables:c},children:b})}function j(){let a=(0,e.useContext)(h);if(!a)throw Error("useExplorerContext must be used inside ExplorerProvider");return a}},53286:(a,b,c)=>{"use strict";c.d(b,{F:()=>k});var d=c(48249);c(67484);var e=c(99058),f=c(40336),g=c(69856),h=c(18656),i=c(41764),j=c(14490);function k({className:a,children:b,...c}){return(0,d.jsxs)(e.V,{"data-slot":"scroll-area",className:(0,j.cn)("relative",a),...c,children:[(0,d.jsx)(f.B,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:b}),(0,d.jsx)(l,{}),(0,d.jsx)(g.I,{})]})}function l({className:a,orientation:b="vertical",...c}){return(0,d.jsx)(h.V,{"data-slot":"scroll-area-scrollbar","data-orientation":b,orientation:b,className:(0,j.cn)("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",a),...c,children:(0,d.jsx)(i.l,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}},59809:(a,b,c)=>{"use strict";c.d(b,{ExplorerShell:()=>as});var d=c(48249),e=c(2116),f=c.n(e),g=c(96006),h=c(25297),i=c(98609),j=c(91732),k=c(99598),l=c(78260),m=c(44231),n=c(19099),o=c(67484),p=c(7178),q=c(93217),r=c(1206),s=c(24277),t=c(29813),u=c(88877),v=c(53286),w=c(13656),x=c(8508),y=c(89366),z=c(14490),A=c(89216),B=c(15386),C=c(82244),D=c(30770);function E({current:a}){let b=(0,n.useRouter)(),c=(0,j.Z)(a=>a.connections);return(0,d.jsxs)(C.rI,{children:[(0,d.jsxs)(C.ty,{className:"flex h-8 w-full items-center justify-between gap-2 rounded-lg px-2 text-left font-medium outline-none hover:bg-muted/60 focus-visible:ring-3 focus-visible:ring-ring/50 data-open:bg-muted/60",children:[(0,d.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,d.jsx)(D.F,{connection:a}),(0,d.jsx)("span",{className:"truncate",children:a.name}),a.layoutGroup&&(0,d.jsx)(A.A,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),(0,d.jsx)(B.A,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),(0,d.jsxs)(C.SQ,{align:"start",className:"w-(--anchor-width)",children:[c.map(c=>(0,d.jsxs)(C._2,{onClick:()=>b.push(`/${c.id}`),className:c.id===a.id?"font-medium":void 0,children:[(0,d.jsx)(D.F,{connection:c}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate",children:c.name}),c.layoutGroup&&c.layoutGroup===a.layoutGroup&&(0,d.jsx)(A.A,{className:"size-3.5 shrink-0 text-muted-foreground"})]},c.id)),(0,d.jsx)(C.mB,{}),(0,d.jsx)(C._2,{render:(0,d.jsx)(f(),{href:"/"}),children:"Manage connections"})]})]})}var F=c(79820),G=c(9008),H=c(39470),I=c(91995);function J(a,b){let c=a.trim(),d=c.lastIndexOf(".");return -1===d?c:"schema"===b?c.slice(0,d):c.slice(d+1)}function K({text:a,query:b}){if(!b)return a;let c=[],e=a.toLocaleLowerCase(),f=b.toLocaleLowerCase(),g=0,h=e.indexOf(f);if(-1===h)return a;for(;-1!==h;)h>g&&c.push(a.slice(g,h)),c.push((0,d.jsx)("mark",{className:"rounded-[3px] bg-yellow-300/90 px-px text-yellow-950 dark:bg-yellow-400/85 dark:text-yellow-950",children:a.slice(h,h+b.length)},h)),g=h+b.length,h=e.indexOf(f,g);return g<a.length&&c.push(a.slice(g)),c}function L({connectionId:a,table:b,search:c,pinned:e,showSchema:g,active:h,reorderable:i,dragging:j,dropEdge:k,onTogglePin:l,onDragStart:m,onDragOver:n,onDrop:o,onDragEnd:p,onMove:q}){return(0,d.jsxs)("li",{onDragOver:n,onDrop:o,className:(0,z.cn)("group/table-row relative flex h-7 items-center rounded-md text-[13px] transition-[color,background-color,opacity] hover:bg-muted/60",h&&"bg-muted text-foreground",!h&&"text-foreground/80",j&&"opacity-45","before"===k&&"before:absolute before:inset-x-1 before:top-0 before:z-10 before:h-0.5 before:-translate-y-1/2 before:rounded-full before:bg-primary","after"===k&&"after:absolute after:inset-x-1 after:bottom-0 after:z-10 after:h-0.5 after:translate-y-1/2 after:rounded-full after:bg-primary"),children:[i&&(0,d.jsx)("button",{type:"button",draggable:!0,"aria-label":`Reorder ${b.schema}.${b.name}`,title:"Drag to reorder; use Up and Down arrow keys",onDragStart:m,onDragEnd:p,onKeyDown:a=>{("ArrowUp"===a.key||"ArrowDown"===a.key)&&(a.preventDefault(),q?.("ArrowUp"===a.key?-1:1))},className:"ml-1.5 flex size-5 shrink-0 cursor-grab touch-none items-center justify-center rounded text-muted-foreground opacity-50 outline-none transition-[color,background-color,opacity] hover:bg-foreground/10 hover:text-foreground hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:opacity-100 active:cursor-grabbing",children:(0,d.jsx)(G.A,{className:"size-3.5"})}),(0,d.jsxs)(f(),{href:`/${a}/${encodeURIComponent(b.schema)}/${encodeURIComponent(b.name)}`,className:(0,z.cn)("flex h-full min-w-0 flex-1 items-center gap-1.5 rounded-md outline-none focus-visible:ring-2 focus-visible:ring-ring/60",i?"pl-1":"pl-6"),children:[(0,d.jsx)("span",{className:"truncate",children:(0,d.jsx)(K,{text:b.name,query:J(c,"table")})}),g?(0,d.jsx)("span",{className:"ml-auto max-w-20 truncate text-[10px] text-muted-foreground",children:b.schema}):"view"===b.kind&&(0,d.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"view"})]}),(0,d.jsx)("button",{type:"button","aria-label":`${e?"Unpin":"Pin"} ${b.schema}.${b.name}`,"aria-pressed":e,title:e?"Unpin table":"Pin table",onClick:()=>l(b),className:(0,z.cn)("mr-0.5 flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground opacity-0 outline-none transition-[color,background-color,opacity] hover:bg-foreground/10 hover:text-foreground hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:opacity-100 group-hover/table-row:opacity-100",e&&"text-foreground"),children:(0,d.jsx)(H.A,{className:(0,z.cn)("size-3.5",e&&"fill-current")})})]})}function M({label:a,count:b,collapsed:c,pinned:e,search:f,onToggle:g}){return(0,d.jsxs)("button",{type:"button","aria-expanded":!c,onClick:g,className:"flex h-7 w-full cursor-pointer items-center gap-1 rounded-md px-1 text-xs font-medium text-muted-foreground outline-none transition-colors hover:bg-muted/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60",children:[(0,d.jsx)(I.A,{className:(0,z.cn)("size-3.5 transition-transform",!c&&"rotate-90")}),e&&(0,d.jsx)(H.A,{className:"mr-0.5 size-3 fill-current"}),(0,d.jsx)("span",{className:"truncate",children:e?a:(0,d.jsx)(K,{text:a,query:J(f,"schema")})}),(0,d.jsx)("span",{className:"ml-auto pr-1 tabular-nums opacity-60",children:b})]})}function N({connectionId:a,tables:b,search:c,collapsedSchemas:e,pinnedTables:f,onToggleSchema:g,onTogglePin:h,onReorderPinned:i}){let j=(0,n.useParams)(),[k,l]=(0,o.useState)(!1),[m,p]=(0,o.useState)(null),[q,r]=(0,o.useState)(null),s=new Map(b.map(a=>[(0,y.i)(a),a])),t=f.flatMap(a=>{let b=s.get(a);return b?[b]:[]});function u(){p(null),r(null)}return 0===b.length?(0,d.jsx)("p",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:c.trim()?"No tables match your search":"No tables in these schemas"}):(0,d.jsxs)("div",{className:"flex flex-col gap-1 px-2 pb-4",children:[t.length>0&&(0,d.jsxs)("div",{className:"mb-1 border-b border-border/60 pb-1",children:[(0,d.jsx)(M,{label:"Pinned tables",count:t.length,collapsed:k,pinned:!0,search:c,onToggle:()=>l(a=>!a)}),!k&&(0,d.jsx)("ul",{children:t.map(b=>{let e=(0,y.i)(b);return(0,d.jsx)(L,{connectionId:a,table:b,search:c,pinned:!0,showSchema:!0,active:j.schema===b.schema&&j.table===b.name,reorderable:!0,dragging:m===e,dropEdge:q?.key===e?q.edge:null,onTogglePin:h,onDragStart:a=>{a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",e),p(e),r(null)},onDragOver:a=>(function(a,b){if(!m||m===b)return;a.preventDefault(),a.dataTransfer.dropEffect="move";let c=a.currentTarget.getBoundingClientRect(),d=a.clientY<c.top+c.height/2?"before":"after";r(a=>a?.key===b&&a.edge===d?a:{key:b,edge:d})})(a,e),onDrop:a=>{let b,c;return a.preventDefault(),b=m??a.dataTransfer.getData("text/plain"),c=q?.key===e?q.edge:"before",void(b&&i(b,e,c),u())},onDragEnd:u,onMove:a=>{let b,c;return b=t.findIndex(a=>(0,y.i)(a)===e),void((c=t[b+a])&&i(e,(0,y.i)(c),-1===a?"before":"after"))}},e)})})]}),(function(a){let b=new Map;for(let c of a)b.set(c.schema,[...b.get(c.schema)??[],c]);return[...b.entries()].sort(([a],[b])=>{let c;return((c=new Map([["public",0],["auth",1]])).get(a)??2)-(c.get(b)??2)||a.localeCompare(b)})})(b).map(([b,i])=>{let k=e.includes(b);return(0,d.jsxs)("div",{children:[(0,d.jsx)(M,{label:b,count:i.length,collapsed:k,search:c,onToggle:()=>g(b)}),!k&&(0,d.jsx)("ul",{children:i.map(b=>(0,d.jsx)(L,{connectionId:a,table:b,search:c,pinned:f.includes((0,y.i)(b)),active:j.schema===b.schema&&j.table===b.name,onTogglePin:h},(0,y.i)(b)))})]},b)})]})}function O(a){return Math.min(480,Math.max(180,Math.round(a)))}function P(a,b){let c=new Map([["public",0],["auth",1]]);return(c.get(a)??2)-(c.get(b)??2)||a.localeCompare(b)}function Q(a,b,c){let d=b.trim().toLocaleLowerCase();return a.filter(a=>(null===c||!!c.includes(a.schema))&&(!d||a.name.toLocaleLowerCase().includes(d)||`${a.schema}.${a.name}`.toLocaleLowerCase().includes(d)))}function R({href:a,active:b,shortcut:c,children:e}){return(0,d.jsxs)(f(),{href:a,"aria-current":b?"page":void 0,className:(0,z.cn)((0,h.r)({variant:b?"secondary":"ghost",size:"sm"}),"h-8 w-full justify-start px-2"),children:[e,(0,d.jsx)("kbd",{className:"ml-auto font-mono text-[10px] text-muted-foreground/55",children:c})]})}function S({width:a,onWidthChange:b,onCollapse:c}){let e=(0,n.usePathname)(),{connection:f,tables:g}=(0,m.k)(),[i,l]=(0,k.DE)(f.id),z=(0,j.Z)(a=>a.connections.length>1),[A,B]=(0,o.useState)(()=>O(a)),C=(0,o.useRef)(null),D=(0,o.useMemo)(()=>[...new Set((g.data??[]).map(a=>a.schema))].sort(P),[g.data]),G=(0,o.useMemo)(()=>null===i.selectedSchemas?null:i.selectedSchemas.filter(a=>D.includes(a)),[i.selectedSchemas,D]),H=(0,o.useMemo)(()=>Q(g.data??[],i.search,G),[g.data,i.search,G]),I=`/${encodeURIComponent(f.id)}`,J=`${I}/query`,K=`${I}/diff`,L=`${I}/migrations`;function M(a,b){let c=new Set(Q(g.data??[],a,b).map(a=>a.schema));return i.collapsedSchemas.filter(a=>!c.has(a))}return(0,d.jsxs)("aside",{id:"database-explorer-sidebar",style:{width:A},className:"relative flex h-full shrink-0 flex-col border-r bg-sidebar",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2 border-b border-sidebar-border/60 p-2 pb-2.5",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1",children:[(0,d.jsx)("div",{className:"min-w-0 flex-1",children:(0,d.jsx)(E,{current:f})}),(0,d.jsx)(h.$,{variant:"ghost",size:"icon-sm","aria-label":"Collapse database sidebar",title:"Collapse sidebar",onClick:c,children:(0,d.jsx)(p.A,{})})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,d.jsxs)(R,{href:J,active:e===J,shortcut:x.Ar.sqlEditor,children:[(0,d.jsx)(q.A,{"data-icon":"inline-start"}),"SQL query"]}),(0,d.jsxs)(R,{href:L,active:e===L||e.startsWith(`${L}/`),shortcut:x.Ar.migrations,children:[(0,d.jsx)(r.A,{"data-icon":"inline-start"}),"Migrations"]}),z&&(0,d.jsxs)(R,{href:K,active:e===K,shortcut:x.Ar.compareSchema,children:[(0,d.jsx)(s.A,{"data-icon":"inline-start"}),"Compare schema"]})]}),(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)(t.A,{className:"pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted-foreground"}),(0,d.jsx)(u.p,{value:i.search,onChange:a=>{var b;l({search:b=a.target.value,collapsedSchemas:b.trim()?M(b,G):i.collapsedSchemas})},placeholder:"Search tables","aria-label":"Search tables",className:"h-9 bg-background/60 pr-9 pl-8"}),(0,d.jsx)("kbd",{className:"pointer-events-none absolute top-1/2 right-2.5 -translate-y-1/2 font-mono text-[10px] text-muted-foreground/55",children:x.Ar.tableSearch})]}),(0,d.jsx)(F.V,{schemas:D,selected:G,onChange:function(a){l({selectedSchemas:a,collapsedSchemas:i.search.trim()?M(i.search,a):i.collapsedSchemas})}})]}),(0,d.jsx)(v.F,{className:"min-h-0 flex-1 pt-1.5",children:g.error?(0,d.jsx)("p",{className:"px-3 py-4 text-xs text-destructive",children:g.error}):g.data?(0,d.jsx)(N,{connectionId:f.id,tables:H,search:i.search,collapsedSchemas:i.collapsedSchemas,pinnedTables:i.pinnedTables,onToggleSchema:function(a){l({collapsedSchemas:i.collapsedSchemas.includes(a)?i.collapsedSchemas.filter(b=>b!==a):[...i.collapsedSchemas,a]})},onTogglePin:function(a){let b=(0,y.i)(a);l({pinnedTables:i.pinnedTables.includes(b)?i.pinnedTables.filter(a=>a!==b):[...i.pinnedTables,b]})},onReorderPinned:function(a,b,c){if(a===b)return;let d=i.pinnedTables.filter(b=>b!==a),e=d.indexOf(b);-1!==e&&(d.splice(e+ +("after"===c),0,a),l({pinnedTables:d}))}}):(0,d.jsx)("div",{className:"flex flex-col gap-2 px-3 py-2",children:Array.from({length:8},(a,b)=>(0,d.jsx)(w.E,{className:"h-5 w-full"},b))})}),(0,d.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize database sidebar","aria-valuemin":180,"aria-valuemax":480,"aria-valuenow":A,tabIndex:0,title:"Drag to resize; double-click to reset",onPointerDown:function(a){a.preventDefault(),C.current={pointerId:a.pointerId,startX:a.clientX,startWidth:A},a.currentTarget.setPointerCapture(a.pointerId)},onPointerMove:function(a){let b=C.current;b&&b.pointerId===a.pointerId&&(a.preventDefault(),B(O(b.startWidth+a.clientX-b.startX)))},onPointerUp:function(a){let c=C.current;if(!c||c.pointerId!==a.pointerId)return;let d=O(c.startWidth+a.clientX-c.startX);C.current=null,B(d),a.currentTarget.hasPointerCapture(a.pointerId)&&a.currentTarget.releasePointerCapture(a.pointerId),b(d)},onPointerCancel:function(a){let c=C.current;c&&c.pointerId===a.pointerId&&(C.current=null,a.currentTarget.hasPointerCapture(a.pointerId)&&a.currentTarget.releasePointerCapture(a.pointerId),b(A))},onKeyDown:function(a){if("ArrowLeft"!==a.key&&"ArrowRight"!==a.key)return;a.preventDefault();let c=O(A+("ArrowLeft"===a.key?-1:1)*16);B(c),b(c)},onDoubleClick:function(a){a.preventDefault(),B(256),b(256)},className:"group/resize absolute inset-y-0 -right-1 z-30 w-2 cursor-col-resize touch-none outline-none after:absolute after:inset-y-0 after:left-1/2 after:w-px after:-translate-x-1/2 after:bg-transparent after:transition-colors hover:after:bg-primary focus-visible:after:bg-primary"})]})}var T=c(35471),U=c(89267),V=c(16280),W=c(61561);let X=new Set;var Y=c(93291);function Z(a,{nested:b=!1}={}){let c=(0,n.useRouter)(),d=(0,n.usePathname)(),{connection:e,tables:f}=(0,m.k)(),[g]=(0,k.DE)(e.id),h=`/${encodeURIComponent(e.id)}`,i=`${h}/${a}`,j=b?d===i||d.startsWith(`${i}/`):d===i;return{open:j,href:i,toggle:()=>c.push(j?function(){for(let a of g.recentTables){let b=(f.data??[]).find(b=>(0,y.i)(b)===a);if(b)return`${h}/${encodeURIComponent(b.schema)}/${encodeURIComponent(b.name)}`}return h}():i)}}function $(){let a=Z("migrations",{nested:!0});return{open:a.open,migrationsHref:a.href,toggle:a.toggle}}function _(){let a=Z("diff");return{open:a.open,diffHref:a.href,toggle:a.toggle}}function aa(){let a=Z("query");return{open:a.open,queryHref:a.href,toggle:a.toggle}}var ab=c(21883);function ac(a,b=""){return`/${encodeURIComponent(a)}${b}`}function ad(){let a=(0,n.useRouter)(),b=(0,n.useParams)(),{connection:c}=(0,m.k)(),d=(0,j.Z)(a=>a.connections),e=aa(),f=_(),g=e.open?"query":f.open?"diff":null,h=function(a,b){let c=a.findIndex(a=>a.id===b);if(!(a.length<2)&&-1!==c)return a[(c+1)%a.length]}(d,c.id);return{run:async function(){var c;if(!h)return;for(let a of X)a();let d=b.schema&&b.table?{schema:decodeURIComponent(b.schema),name:decodeURIComponent(b.table)}:null,e=!1;if(!g&&d)try{c=await ab.F.tables(h.url),e=c.some(a=>a.schema===d.schema&&a.name===d.name)}catch{}a.push(function(a,{pane:b,table:c,tableExists:d}){if(b)return ac(a,`/${b}`);if(c&&d)return ac(a,`/${encodeURIComponent(c.schema)}/${encodeURIComponent(c.name)}`);return ac(a)}(h.id,{pane:g,table:d,tableExists:e}))},enabled:void 0!==h,next:h}}function ae({text:a,query:b}){if(!b)return a;let c=a.toLocaleLowerCase(),e=b.toLocaleLowerCase(),f=c.indexOf(e);return -1===f?a:(0,d.jsxs)(d.Fragment,{children:[a.slice(0,f),(0,d.jsx)("mark",{className:"rounded-[3px] bg-yellow-300/90 px-px text-yellow-950 dark:bg-yellow-400/85 dark:text-yellow-950",children:a.slice(f,f+b.length)}),a.slice(f+b.length)]})}async function af(a){try{await navigator.clipboard.writeText(a)}catch{let b=document.createElement("textarea");b.value=a,b.style.position="fixed",b.style.opacity="0",document.body.appendChild(b),b.select(),document.execCommand("copy"),b.remove()}}function ag(){let a=(0,n.useRouter)(),b=(0,n.useParams)(),{connection:c,tables:e}=(0,m.k)(),f=aa(),g=_(),h=$(),i=(0,k.y3)(c.id),l=ad(),p=(0,j.Z)(a=>a.add),[q,r]=(0,k.DE)(c.id),[s,t]=(0,o.useState)(!1),[u,v]=(0,o.useState)("commands"),[w,A]=(0,o.useState)(""),[B,C]=(0,o.useState)(0),[D,E]=(0,o.useState)(!1),F=(0,o.useRef)(null),G=(0,o.useRef)(null),H=(0,o.useRef)(null),I=(0,o.useRef)(u),J=(0,V.C)(a=>a.theme),K=b.schema&&b.table?{schema:decodeURIComponent(b.schema),name:decodeURIComponent(b.table)}:null,L=!!K&&q.pinnedTables.includes((0,y.i)(K)),M=(0,k.lz)(a=>K?a.tables[`${c.id}:${(0,y.i)(K)}`]:void 0),N=(0,o.useMemo)(()=>[{id:"sql-editor",title:f.open?"Back to Table":"Open SQL Query",keywords:["new","query","sql","console","editor","close","back","table"],enabled:!0,shortcut:x.Ar.sqlEditor,run:()=>f.toggle()},{id:"switch-connection",title:l.next?`Switch Connection (${l.next.name})`:"Switch Connection",keywords:["database","env","environment","next","cycle","other"],enabled:l.enabled,shortcut:x.Ar.switchConnection,run:()=>void l.run()},{id:"migrations",title:h.open?"Back to Table":"Open Migrations",keywords:["migration","migrate","apply","revert","rollback","ledger","schema","run"],enabled:!0,shortcut:x.Ar.migrations,run:()=>h.toggle()},{id:"compare-schema",title:i.target?`Compare Schema with ${i.target.name}`:"Compare Schema",keywords:["diff","difference","migration","drift","prod","dev","schema","compare"],enabled:null!==i.target,shortcut:x.Ar.compareSchema,run:()=>g.toggle()},{id:"search-tables",title:"Search Tables",keywords:["find","jump","open","goto","table"],enabled:!0,shortcut:x.Ar.tableSearch,run:()=>window.requestAnimationFrame(()=>(0,x.tT)())},{id:"search-columns",title:"Search Columns",keywords:["find","jump","goto","column","field"],enabled:null!==K,shortcut:x.Ar.columnSearch,run:()=>window.requestAnimationFrame(()=>(0,x.vI)())},{id:"reload-tables",title:"Reload Tables",keywords:["refresh","reload","tables","sync"],enabled:!0,run:()=>e.reload()},{id:"pin-table",title:L?"Unpin Table":"Pin Table",keywords:["pin","unpin","favorite","star"],enabled:null!==K,run:()=>{if(!K)return;let a=(0,y.i)(K);r({pinnedTables:q.pinnedTables.includes(a)?q.pinnedTables.filter(b=>b!==a):[...q.pinnedTables,a]})}},{id:"clear-filters",title:"Clear Filters",keywords:["filter","reset","remove"],enabled:null!==K,run:()=>{K&&k.lz.getState().setTable(c.id,K,{filters:[],page:0})}},{id:"clear-search",title:"Clear Search",keywords:["find","search","reset"],enabled:null!==K&&!!M?.search,run:()=>{K&&k.lz.getState().setTable(c.id,K,{search:"",page:0})}},{id:"reset-columns",title:"Reset Columns",keywords:["pin","hide","frozen","layout","show"],enabled:null!==K,run:()=>{K&&k.lz.getState().setTable(c.id,K,{pinnedColumns:void 0,hiddenColumns:[]})}},{id:"copy-table",title:"Copy Schema.Table",keywords:["copy","name","qualified"],enabled:null!==K,run:()=>{K&&af((0,y.i)(K))}},{id:"color-theme",title:"Color Theme",keywords:["theme","appearance","dark","light","color","set","preferences"],enabled:!0,keepOpen:!0,run:()=>{let a=V.C.getState().theme,b=W.zG.findIndex(b=>b.id===a);v("themes"),A(""),C(-1===b?0:b)}},{id:"add-connection",title:"Add Connection",keywords:["new","database","postgres"],enabled:!0,run:()=>E(!0)}],[q.pinnedTables,i.target,c.id,h,L,g,r,f,l,K,M?.search,e]),O=(0,o.useMemo)(()=>w.trim()?(0,Y.R6)(w,N,a=>[a.title,...a.keywords].join(" ")).map(a=>a.item):N,[N,w]),P=(0,o.useMemo)(()=>w.trim()?(0,Y.R6)(w,[...W.zG],a=>[a.name,...a.keywords].join(" ")).map(a=>a.item):[...W.zG],[w]),Q="themes"===u?P:O,R="commands"===u?O[B]??null:null,S="themes"===u?P[B]??null:null;function X(a){a?.revertTheme&&"themes"===I.current&&(0,W.AZ)(V.C.getState().theme),t(!1),A(""),C(0),v("commands")}function Z(a){a.enabled&&(a.keepOpen||X({revertTheme:!0}),a.run())}function ab(a){V.C.getState().setTheme(a.id),(0,W.AZ)(a.id),X({revertTheme:!1})}return(0,d.jsxs)(d.Fragment,{children:[s&&(0,d.jsxs)("div",{ref:G,"data-command-palette":"",className:"fixed top-3 left-1/2 z-50 flex w-[min(36rem,calc(100%-1.5rem))] -translate-x-1/2 flex-col overflow-hidden rounded-lg border bg-popover text-popover-foreground shadow-lg ring-1 ring-foreground/10",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 border-b px-3",children:[(0,d.jsx)("span",{className:"font-mono text-sm text-muted-foreground",children:">"}),(0,d.jsx)("input",{ref:F,value:w,onChange:a=>A(a.target.value),onKeyDown:function(a){if("ArrowDown"===a.key){if(a.preventDefault(),0===Q.length)return;C(a=>(a+1)%Q.length);return}if("ArrowUp"===a.key){if(a.preventDefault(),0===Q.length)return;C(a=>(a-1+Q.length)%Q.length);return}if("Enter"===a.key){if(a.preventDefault(),"themes"===u){S&&ab(S);return}R&&Z(R)}},spellCheck:!1,autoComplete:"off",autoCorrect:"off",placeholder:"themes"===u?"Select color theme":"Type a command","aria-label":"themes"===u?"Color theme":"Command palette",className:"h-11 min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),(0,d.jsx)("div",{ref:H,role:"listbox","aria-label":"themes"===u?"Color themes":"Commands",className:"max-h-[min(24rem,50vh)] overflow-auto py-1",children:0===Q.length?(0,d.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"themes"===u?"No matching themes":"No matching commands"}):"themes"===u?P.map((a,b)=>{let c=b===B,e=a.id===J;return(0,d.jsxs)("button",{type:"button",role:"option","aria-selected":c,"data-active":c||void 0,onMouseEnter:()=>C(b),onClick:()=>ab(a),className:(0,z.cn)("flex h-8 w-full cursor-pointer items-center gap-2 px-3 text-left text-[13px] outline-none",c&&"bg-primary/10"),children:[(0,d.jsx)("span",{"aria-hidden":!0,className:"size-3.5 shrink-0 rounded-sm border",style:{background:a.swatch}}),(0,d.jsx)("span",{className:"min-w-0 truncate",children:(0,d.jsx)(ae,{text:a.name,query:w.trim()})}),e&&(0,d.jsx)(T.A,{className:"ml-auto size-3.5 shrink-0 text-muted-foreground"})]},a.id)}):O.map((a,b)=>{let c=b===B;return(0,d.jsxs)("button",{type:"button",role:"option","aria-selected":c,"aria-disabled":!a.enabled,"data-active":c||void 0,onMouseEnter:()=>C(b),onClick:()=>Z(a),className:(0,z.cn)("flex h-8 w-full cursor-pointer items-center px-3 text-left text-[13px] outline-none",c&&"bg-primary/10",!a.enabled&&"cursor-default opacity-40"),children:[(0,d.jsx)("span",{className:"min-w-0 truncate",children:(0,d.jsx)(ae,{text:a.title,query:w.trim()})}),a.shortcut&&(0,d.jsx)("kbd",{className:"ml-auto shrink-0 pl-3 font-mono text-[11px] text-muted-foreground/70",children:a.shortcut})]},a.id)})})]}),(0,d.jsx)(U.f,{open:D,onOpenChange:E,onSubmit:b=>{let{shareWith:c,...d}=b,e=p(d);(0,k.mQ)(e.id,c),a.push(`/${e.id}`)}})]})}function ah(){let{toggle:a}=aa(),{toggle:b}=_(),{toggle:c}=$(),{run:d}=ad(),e=(0,j.Z)(a=>a.connections.length>1);return(0,o.useRef)(a),(0,o.useRef)(b),(0,o.useRef)(c),(0,o.useRef)(d),(0,o.useRef)(e),null}var ai=c(36274),aj=c(21215),ak=c(83254);let al={pinned:"Pinned",recent:"Recent",tables:"Tables",connections:"Connections"};function am({text:a,query:b}){if(!b)return a;let c=a.toLocaleLowerCase(),e=b.toLocaleLowerCase(),f=c.indexOf(e);return -1===f?a:(0,d.jsxs)(d.Fragment,{children:[a.slice(0,f),(0,d.jsx)("mark",{className:"rounded-[3px] bg-yellow-300/90 px-px text-yellow-950 dark:bg-yellow-400/85 dark:text-yellow-950",children:a.slice(f,f+b.length)}),a.slice(f+b.length)]})}function an(a){try{return new URL(a).hostname}catch{return""}}function ao(a){return[a.name,an(a.url)].filter(Boolean)}function ap(a,b){let c=new Map([["public",0],["auth",1]]);return(c.get(a.schema)??2)-(c.get(b.schema)??2)||a.schema.localeCompare(b.schema)||a.name.localeCompare(b.name)}function aq(a,b){return a.map((a,c)=>0===c?{...a,section:b}:a)}function ar(){let a=(0,n.useRouter)(),b=(0,n.useParams)(),{connection:c,tables:e}=(0,m.k)(),f=(0,j.Z)(a=>a.connections),[g,h]=(0,o.useState)(!1),[i,l]=(0,o.useState)(""),[p,q]=(0,o.useState)(0),[r,s]=(0,o.useState)(null),u=(0,o.useRef)(null),v=(0,o.useRef)(null),w=(0,o.useRef)(null),x=f.find(a=>a.id===r)??null,A=x??c,B=x&&x.id!==c.id?x.url:null,C=function(a){let[b]=(0,o.useState)(()=>new Map),[c,d]=(0,o.useState)({url:"",error:null});if(!a)return{data:void 0,error:null,loading:!1};let e=c.url===a?c.data:b.get(a);return{data:e,error:c.url===a?c.error:null,loading:void 0===e}}(B),[E,F]=(0,k.DE)(c.id),[G,I]=(0,k.DE)(A.id),J=A.id===c.id?E:G,K=(0,o.useMemo)(()=>B?C.data??[]:e.data??[],[C.data,B,e.data]),L=B?C.loading:e.loading,M=B?C.error:null,N=(0,o.useMemo)(()=>[...new Set(K.map(a=>a.schema))],[K]),O=null===J.selectedSchemas?null:J.selectedSchemas.filter(a=>N.includes(a)),P=(0,o.useMemo)(()=>null===O?K:K.filter(a=>O.includes(a.schema)),[K,O]),Q=J.pinnedTables,R=J.recentTables,S=(0,o.useMemo)(()=>{let a,b;return -1===(b=(a=i.trim()).indexOf(":"))?{schema:null,table:a}:{schema:a.slice(0,b).trim(),table:a.slice(b+1).trim()}},[i]),T=S.table||(S.schema?"":i.trim()),U=(0,o.useMemo)(()=>{let a=new Set(Q),b=new Set(R),d=null===S.schema?null:function(a,b){if(!a)return b;let c=a.toLocaleLowerCase(),d=b.filter(a=>a.toLocaleLowerCase()===c);if(d.length>0)return d;let e=b.filter(a=>a.toLocaleLowerCase().startsWith(c));return e.length>0?e:(0,Y.R6)(a,b,a=>a).map(a=>a.item)}(S.schema,N),e=null===d?P:K.filter(a=>d.includes(a.schema)),g=new Map(e.map(a=>[(0,y.i)(a),a])),h=Q.flatMap(a=>{let b=g.get(a);return b?[b]:[]}),j=R.flatMap(b=>{let c=g.get(b);return!c||a.has(b)?[]:[c]}),k=(a,b)=>({type:"table",key:`table:${(0,y.i)(a)}`,table:a,...b}),l=a=>({type:"connection",key:`connection:${a.id}`,connection:a,current:a.id===c.id}),m=null===S.schema?i.trim():S.table,n=null===x&&null===S.schema;if(!m){let a=new Set([...h.map(a=>(0,y.i)(a)),...j.map(a=>(0,y.i)(a))]),d=e.filter(b=>!a.has((0,y.i)(b))).sort(ap),g=n?f.filter(a=>a.id!==c.id):[];return[...aq(h.map(a=>k(a,{pinned:!0})),"pinned"),...aq(j.map(a=>k(a,{pinned:!1,recent:!0})),"recent"),...aq(d.map(a=>k(a,{pinned:!1,recent:b.has((0,y.i)(a))})),"tables"),...aq(g.map(l),"connections")]}let o=(0,Y.UO)(m,e,a=>null===S.schema?[a.name,`${a.schema}.${a.name}`,a.schema]:[a.name]).map(c=>({...c,score:c.score+80*!!a.has((0,y.i)(c.item))+40*!!b.has((0,y.i)(c.item))})).sort((a,b)=>b.score-a.score).map(c=>k(c.item,{pinned:a.has((0,y.i)(c.item)),recent:b.has((0,y.i)(c.item))}));return[...aq(n?(0,Y.UO)(i,f,ao).map(a=>l(a.item)):[],"connections"),...aq(o,"tables")]},[K,c.id,f,x,S.schema,S.table,Q,i,R,N,P]),V=U[p]??null;function W(){s(null),q(0),u.current?.focus()}function X(b){var d,e;if(h(!1),l(""),q(0),s(null),"connection"===b.type){b.connection.id!==c.id&&a.push(`/${b.connection.id}`);return}a.push((d=A.id,e=b.table,`/${d}/${encodeURIComponent(e.schema)}/${encodeURIComponent(e.name)}`))}function Z(a){let b=(0,y.i)(a),d=J.pinnedTables.includes(b)?J.pinnedTables.filter(a=>a!==b):[...J.pinnedTables,b];(A.id===c.id?F:I)({pinnedTables:d})}let $=A.id===c.id&&b.schema&&b.table?`${decodeURIComponent(b.schema)}.${decodeURIComponent(b.table)}`:null;return g?(0,d.jsxs)("div",{ref:v,"data-table-palette":"",className:"fixed top-3 left-1/2 z-50 flex w-[min(36rem,calc(100%-1.5rem))] -translate-x-1/2 flex-col overflow-hidden rounded-lg border bg-popover text-popover-foreground shadow-lg ring-1 ring-foreground/10",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 border-b px-3",children:[(0,d.jsx)(t.A,{className:"size-4 shrink-0 text-muted-foreground"}),x&&(0,d.jsxs)("button",{type:"button",onClick:W,"aria-label":`Stop searching ${x.name}`,className:"flex h-6 max-w-40 shrink-0 items-center gap-1.5 rounded-md bg-muted px-1.5 text-xs outline-none hover:bg-muted/80",children:[(0,d.jsx)(D.F,{connection:x,className:"size-2"}),(0,d.jsx)("span",{className:"truncate",children:x.name})]}),(0,d.jsx)("input",{ref:u,value:i,onChange:a=>l(a.target.value),onKeyDown:function(a){if("ArrowDown"===a.key){if(a.preventDefault(),0===U.length)return;q(a=>(a+1)%U.length);return}if("ArrowUp"===a.key){if(a.preventDefault(),0===U.length)return;q(a=>(a-1+U.length)%U.length);return}if("Tab"===a.key){if(a.preventDefault(),x||a.shiftKey)return;V?.type==="connection"&&(s(V.connection.id),l(""),q(0));return}if("Backspace"===a.key&&""===i&&x){a.preventDefault(),W();return}"Enter"===a.key&&(a.preventDefault(),a.shiftKey&&V?.type==="table"?Z(V.table):V&&X(V))},spellCheck:!1,autoComplete:"off",autoCorrect:"off",placeholder:x?`Search tables in ${x.name}`:"Go to table (schema:name)","aria-label":x?`Go to table in ${x.name}`:"Go to table or connection",className:"h-11 min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),(0,d.jsx)("div",{ref:w,role:"listbox","aria-label":x?`Tables in ${x.name}`:"Tables and connections",className:"max-h-[min(24rem,50vh)] overflow-auto py-1",children:L&&0===K.length&&0===U.length?(0,d.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"Loading tables…"}):M&&0===K.length?(0,d.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:M}):0===U.length?(0,d.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:i.trim()?"No matches":"No tables"}):U.map((a,b)=>{let c=b===p;if("connection"===a.type){let e=an(a.connection.url);return(0,d.jsxs)("div",{children:[a.section&&(0,d.jsx)("p",{className:"px-3 pt-2 pb-1 text-[10px] font-medium tracking-wide text-muted-foreground uppercase",children:al[a.section]}),(0,d.jsxs)("button",{type:"button",role:"option","aria-selected":c,"data-active":c||void 0,onMouseEnter:()=>q(b),onClick:()=>X(a),className:(0,z.cn)("flex h-8 w-full cursor-pointer items-center gap-2 px-3 text-left text-[13px] outline-none",c&&"bg-primary/10"),children:[(0,d.jsx)(ai.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,d.jsx)(D.F,{connection:a.connection,className:"size-2"}),(0,d.jsx)("span",{className:(0,z.cn)("min-w-0 truncate",a.current&&"font-medium"),children:(0,d.jsx)(am,{text:a.connection.name,query:T})}),(0,d.jsx)("span",{className:"ml-auto flex min-w-0 shrink-0 items-center gap-2 text-[11px] text-muted-foreground",children:c?(0,d.jsx)("span",{children:"Tab to search"}):(0,d.jsx)("span",{className:"max-w-36 truncate",children:a.current?"current":e||"connection"})})]})]},a.key)}let e=(0,y.i)(a.table)===$;return(0,d.jsxs)("div",{children:[a.section&&(0,d.jsx)("p",{className:"px-3 pt-2 pb-1 text-[10px] font-medium tracking-wide text-muted-foreground uppercase",children:al[a.section]}),(0,d.jsxs)("div",{onMouseEnter:()=>q(b),className:(0,z.cn)("group/table-result flex items-center",c&&"bg-primary/10"),children:[(0,d.jsxs)("button",{type:"button",role:"option","aria-selected":c,"data-active":c||void 0,onClick:()=>X(a),className:"flex h-8 min-w-0 flex-1 cursor-pointer items-center gap-2 pl-3 text-left text-[13px] outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/60",children:[a.recent&&!a.pinned?(0,d.jsx)(aj.A,{className:"size-3.5 shrink-0 text-muted-foreground"}):(0,d.jsx)(ak.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,d.jsx)("span",{className:(0,z.cn)("min-w-0 truncate",e&&"font-medium"),children:(0,d.jsx)(am,{text:a.table.name,query:T})}),(0,d.jsxs)("span",{className:"ml-auto flex min-w-0 shrink-0 items-center gap-2 text-[11px] text-muted-foreground",children:["view"===a.table.kind&&(0,d.jsx)("span",{children:"view"}),(0,d.jsx)("span",{className:"max-w-36 truncate",children:a.table.schema})]})]}),(0,d.jsx)("button",{type:"button","aria-label":`${a.pinned?"Unpin":"Pin"} ${(0,y.i)(a.table)}`,"aria-pressed":a.pinned,title:a.pinned?"Unpin table":"Pin table",onClick:()=>Z(a.table),className:(0,z.cn)("mr-2 flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground opacity-0 outline-none transition-[color,background-color,opacity] hover:bg-foreground/10 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:opacity-100 group-hover/table-result:opacity-100",(a.pinned||c)&&"opacity-100",a.pinned&&"text-foreground"),children:(0,d.jsx)(H.A,{className:(0,z.cn)("size-3.5",a.pinned&&"fill-current")})})]})]},a.key)})}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-3 border-t px-3 py-1.5 text-[10px] text-muted-foreground",children:[(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"font-mono text-foreground/70",children:"↑↓"}),"Navigate"]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"font-mono text-foreground/70",children:"↵"}),"Open"]}),V?.type==="table"&&(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"font-mono text-foreground/70",children:"⇧↵"}),V.pinned?"Unpin":"Pin"]})]})]}):null}function as({connectionId:a,children:b}){let c=(0,i.p)(),e=(0,j.w)(a),[n,o]=(0,k.DE)(a);if(!c)return null;if(!e)return(0,d.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 text-muted-foreground",children:[(0,d.jsx)("p",{children:"Connection not found"}),(0,d.jsx)(f(),{href:"/",className:"text-foreground underline underline-offset-4",children:"Connections"})]});let p=(0,l.Mq)(e);return(0,d.jsxs)(m.Z,{connection:e,children:[(0,d.jsxs)("div",{className:"flex h-dvh flex-col overflow-hidden",children:[(0,d.jsx)("div",{"aria-hidden":!0,title:e.name,className:"h-1.5 w-full shrink-0",style:{background:p}}),(0,d.jsxs)("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[n.sidebarCollapsed?(0,d.jsxs)("aside",{className:"relative flex h-full w-10 shrink-0 justify-center border-r bg-sidebar pt-2",children:[(0,d.jsx)("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-1",style:{background:p}}),(0,d.jsx)(h.$,{variant:"ghost",size:"icon-sm","aria-label":"Show database sidebar",title:"Show sidebar",onClick:()=>o({sidebarCollapsed:!1}),children:(0,d.jsx)(g.A,{})})]}):(0,d.jsx)(S,{width:n.sidebarWidth,onWidthChange:a=>o({sidebarWidth:a}),onCollapse:()=>o({sidebarCollapsed:!0})},e.id),(0,d.jsx)("main",{className:"flex min-w-0 flex-1 flex-col",children:b})]})]}),(0,d.jsx)(ar,{}),(0,d.jsx)(ag,{}),(0,d.jsx)(ah,{})]})}},79820:(a,b,c)=>{"use strict";c.d(b,{V:()=>h});var d=c(48249),e=c(54183),f=c(69627),g=c(82244);function h({schemas:a,selected:b,onChange:c}){let i=null===b||b.length===a.length;return(0,d.jsxs)(g.rI,{children:[(0,d.jsxs)(g.ty,{className:"group flex h-9 w-full cursor-pointer items-center gap-2 rounded-lg border border-input bg-background/60 px-2.5 text-left text-sm outline-none transition-[border-color,background-color,box-shadow] hover:border-foreground/20 hover:bg-muted/50 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 data-open:border-foreground/20 data-open:bg-muted/60",children:[(0,d.jsx)(e.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium",children:null===b||b.length===a.length?"All schemas":0===b.length?"No schemas":1===b.length?b[0]:`${b.length} schemas`}),!i&&(0,d.jsxs)("span",{className:"rounded-md bg-muted px-1.5 py-0.5 text-[10px] tabular-nums text-muted-foreground",children:[b.length,"/",a.length]}),(0,d.jsx)(f.A,{className:"size-3.5 shrink-0 text-muted-foreground transition-transform group-data-open:rotate-180"})]}),(0,d.jsx)(g.SQ,{align:"start",sideOffset:6,className:"max-h-80 w-(--anchor-width) min-w-52",children:(0,d.jsxs)(g.I,{children:[(0,d.jsxs)(g.lp,{className:"flex items-center justify-between px-2 py-1.5",children:[(0,d.jsx)("span",{children:"Visible schemas"}),(0,d.jsx)("span",{className:"font-normal tabular-nums opacity-70",children:a.length})]}),(0,d.jsx)(g.hO,{checked:i,onCheckedChange:a=>c(a?null:[]),children:(0,d.jsx)("span",{className:"font-medium",children:"Show all schemas"})}),(0,d.jsx)(g.mB,{}),a.map(e=>(0,d.jsx)(g.hO,{checked:i||(b?.includes(e)??!1),onCheckedChange:d=>{let f,g;return f=b??a,void c((g=d?[...new Set([...f,e])]:f.filter(a=>a!==e)).length===a.length?null:g)},children:(0,d.jsx)("span",{className:"truncate",children:e})},e))]})})]})}},82676:(a,b,c)=>{Promise.resolve().then(c.bind(c,34766))},93291:(a,b,c)=>{"use strict";function d(a,b){if(0===b)return!0;let c=a[b-1];return"_"===c||"-"===c||" "===c||"."===c}function e(a,b,c){return f(a,b,a=>[c(a)])}function f(a,b,c){if(!a.trim())return[];let e=[];for(let f of b){let b=c(f),g=null;for(let c of b){let b=function(a,b){let c=a.trim().toLocaleLowerCase(),e=b.toLocaleLowerCase();if(!c)return 0;if(0===e.length)return null;if(e===c)return 1e4;if(e.startsWith(c))return 5e3-e.length;let f=e.indexOf(c);if(-1!==f)return 2400+1200*!!d(b,f)-f-e.length;let g=0,h=0,i=0;for(let a=0;a<e.length&&g<c.length;a+=1){if(e[a]!==c[g]){i=0;continue}h+=12,(i+=1)>1&&(h+=18*i),d(b,a)&&(h+=40),g+=1}if(g<c.length)return null;let j=b.split(/[_\-\s.]+/).map(a=>a[0]??"").join("").toLocaleLowerCase();return j.startsWith(c)?h+=2200:j.includes(c)&&(h+=700),h-(e.length-c.length)}(a,c);null!==b&&(null===g||b>g)&&(g=b)}null!==g&&e.push({item:f,score:g})}return e.sort((a,b)=>b.score!==a.score?b.score-a.score:c(a.item)[0]?.localeCompare(c(b.item)[0]??"")??0)}c.d(b,{R6:()=>e,UO:()=>f})}};
@@ -1,7 +1,7 @@
1
- exports.id=907,exports.ids=[907],exports.modules={19225:(a,b,c)=>{"use strict";a.exports=c(44870)},21010:(a,b,c)=>{"use strict";c.d(b,{Ab:()=>h,ZH:()=>g,aC:()=>e,hD:()=>f});var d=c(51473);let e="maintenance";function f(a){return"string"==typeof a&&a.length>0&&a.length<=63&&/^[A-Za-z_][A-Za-z0-9_$]*$/.test(a)}function g(a){return f(a)?a:e}function h(a){return`${(0,d.v)(a)}.${(0,d.v)("ytdb_migrations")}`}},41834:(a,b,c)=>{"use strict";c.d(b,{$F:()=>g,Be:()=>e,H4:()=>j,d6:()=>f,mb:()=>h,mf:()=>i,nc:()=>d,qX:()=>k});let d=8e3,e=8388608,f=1e4,g=500,h=6e4,i=6e5,j=5e5;function k(a){return!function(a){if("object"!=typeof a||null===a)return!1;if("57014"===("code"in a?a.code:void 0))return!0;let b="message"in a&&"string"==typeof a.message?a.message:"";return/timeout|cancell?ed|cancell?ing/i.test(b)}(a)?a instanceof Error?a.message:"Unknown error":"Query took too long and was cancelled. Add a filter or limit the result set."}},51473:(a,b,c)=>{"use strict";function d(a){return`"${a.replace(/"/g,'""')}"`}function e(a){return`${d(a.schema)}.${d(a.name)}`}c.d(b,{Z:()=>e,v:()=>d})},51975:(a,b,c)=>{"use strict";c.d(b,{Ol:()=>i});let d=/^[ \t]*--+[ \t]*ytdb:[ \t]*no-?transaction\b/im,e=new Set(["begin","start"]),f=new Set(["commit","end"]),g=new Set(["rollback"]);function h(a){return void 0!==a&&(a>="A"&&a<="Z"||a>="a"&&a<="z"||"_"===a)||void 0!==a&&a>="0"&&a<="9"}function i(a){if(d.test(a))return{mode:"unwrapped",sql:a,atomic:!1};let b=function(a){let b=[],c=0,d=0,e=d=>{let e=function(a,b){let c=b;for(;c<a.length;){let b=a[c];if(" "===b||" "===b||"\n"===b||"\r"===b){c+=1;continue}if("-"===b&&"-"===a[c+1]){for(;c<a.length&&"\n"!==a[c];)c+=1;continue}if("/"===b&&"*"===a[c+1]){let b=a.indexOf("*/",c+2);c=-1===b?a.length:b+2;continue}break}return c}(a,c);if(e>=d)return;let f=e;for(;f<a.length&&h(a[f]);)f+=1;b.push({at:e,end:d,keyword:a.slice(e,f).toLowerCase()})};for(;d<a.length;){let b=a[d];if("-"===b&&"-"===a[d+1]){for(;d<a.length&&"\n"!==a[d];)d+=1;continue}if("/"===b&&"*"===a[d+1]){let b=a.indexOf("*/",d+2);d=-1===b?a.length:b+2;continue}if("'"===b||'"'===b){d=function(a,b,c){let d=b+1;for(;d<a.length;){if(a[d]===c){if(a[d+1]===c){d+=2;continue}return d+1}d+=1}return d}(a,d,b);continue}if("$"===b){let b=function(a,b){if("$"!==a[b])return null;let c=b+1;for(;c<a.length&&h(a[c]);)c+=1;return"$"!==a[c]?null:a.slice(b,c+1)}(a,d);if(b){let c=a.indexOf(b,d+b.length);d=-1===c?a.length:c+b.length;continue}}if(";"===b){e(d+1),d+=1,c=d;continue}d+=1}return e(a.length),b}(a),c=b.filter(a=>e.has(a.keyword)||f.has(a.keyword)||g.has(a.keyword));if(0===c.length)return{mode:"wrapped-by-ytdb",sql:a,atomic:!0};let i=b[0],j=b[b.length-1];return 2===c.length&&c[0]===i&&c[1]===j&&e.has(i.keyword)&&f.has(j.keyword)?{mode:"self-wrapped",sql:a.slice(0,i.at)+a.slice(i.end,j.at)+a.slice(j.end),atomic:!0}:{mode:"self-managed",sql:a,atomic:!1}}},65125:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{GD:()=>s,SC:()=>o,yn:()=>u});var e=c(41834),f=c(51473),g=c(51975),h=c(21010),i=c(82428),j=a([i]);function k(a){return{version:a.version,name:a.name??"",checksum:a.checksum??"",setName:a.set_name,appliedAt:a.applied_at instanceof Date?a.applied_at.toISOString():String(a.applied_at),durationMs:a.duration_ms,appliedBy:a.applied_by}}function l(a,b){if("object"==typeof a&&null!==a&&"code"in a&&"42501"===a.code){let c=a instanceof Error?a.message:String(a);throw Error(`${c}. YTDB keeps its ledger in "${b}" and this role cannot use it. Either point the ledger at a schema this role owns, or have an admin run: CREATE SCHEMA IF NOT EXISTS ${(0,f.v)(b)}; GRANT USAGE, CREATE ON SCHEMA ${(0,f.v)(b)} TO CURRENT_USER;`)}throw a}async function m(a,b){let c=await a.query("SELECT to_regclass($1)::text AS table",[(0,h.Ab)(b)]).catch(a=>l(a,b));return!!c.rows[0]?.table}i=(j.then?(await j)():j)[0];let v=[h.aC,"public"];async function n(a,b){if(await m(a,b))return{schema:b,exists:!0};for(let c of v)if(c!==b&&await m(a,c))return{schema:c,exists:!0};return{schema:b,exists:!1}}async function o(a,b=h.aC){let c=(0,i.d)(a),{schema:d,exists:e}=await n(c,b);if(!e)return{initialized:!1,schema:d,entries:[]};let f=await c.query(`
2
- SELECT version, name, checksum, set_name, applied_at, duration_ms, applied_by
3
- FROM ${(0,h.Ab)(d)}
4
- ORDER BY version`);return{initialized:!0,schema:d,entries:f.rows.map(k)}}async function p(a){try{await a.query("ROLLBACK")}catch{}}async function q(a,b){let c=await a.query({text:b,rowMode:"array"});return Array.isArray(c)?c.length:1}async function r(a,b){try{await a.query(`CREATE SCHEMA IF NOT EXISTS ${(0,f.v)(b)}`),await a.query(`
1
+ exports.id=907,exports.ids=[907],exports.modules={19225:(a,b,c)=>{"use strict";a.exports=c(44870)},21010:(a,b,c)=>{"use strict";c.d(b,{Ab:()=>h,ZH:()=>g,aC:()=>e,hD:()=>f});var d=c(51473);let e="maintenance";function f(a){return"string"==typeof a&&a.length>0&&a.length<=63&&/^[A-Za-z_][A-Za-z0-9_$]*$/.test(a)}function g(a){return f(a)?a:e}function h(a){return`${(0,d.v)(a)}.${(0,d.v)("ytdb_migrations")}`}},41834:(a,b,c)=>{"use strict";c.d(b,{$F:()=>g,Be:()=>e,H4:()=>j,d6:()=>f,mb:()=>h,mf:()=>i,nc:()=>d,qX:()=>k});let d=8e3,e=8388608,f=1e4,g=500,h=6e4,i=6e5,j=5e5;function k(a){return!function(a){if("object"!=typeof a||null===a)return!1;if("57014"===("code"in a?a.code:void 0))return!0;let b="message"in a&&"string"==typeof a.message?a.message:"";return/timeout|cancell?ed|cancell?ing/i.test(b)}(a)?a instanceof Error?a.message:"Unknown error":"Query took too long and was cancelled. Add a filter or limit the result set."}},51473:(a,b,c)=>{"use strict";function d(a){return`"${a.replace(/"/g,'""')}"`}function e(a){return`${d(a.schema)}.${d(a.name)}`}c.d(b,{Z:()=>e,v:()=>d})},51975:(a,b,c)=>{"use strict";c.d(b,{Ol:()=>i});let d=/^[ \t]*--+[ \t]*ytdb:[ \t]*no-?transaction\b/im,e=new Set(["begin","start"]),f=new Set(["commit","end"]),g=new Set(["rollback"]);function h(a){return void 0!==a&&(a>="A"&&a<="Z"||a>="a"&&a<="z"||"_"===a)||void 0!==a&&a>="0"&&a<="9"}function i(a){if(d.test(a))return{mode:"unwrapped",sql:a,atomic:!1};let b=function(a){let b=[],c=0,d=0,e=d=>{let e=function(a,b){let c=b;for(;c<a.length;){let b=a[c];if(" "===b||" "===b||"\n"===b||"\r"===b){c+=1;continue}if("-"===b&&"-"===a[c+1]){for(;c<a.length&&"\n"!==a[c];)c+=1;continue}if("/"===b&&"*"===a[c+1]){let b=a.indexOf("*/",c+2);c=-1===b?a.length:b+2;continue}break}return c}(a,c);if(e>=d)return;let f=e;for(;f<a.length&&h(a[f]);)f+=1;b.push({at:e,end:d,keyword:a.slice(e,f).toLowerCase()})};for(;d<a.length;){let b=a[d];if("-"===b&&"-"===a[d+1]){for(;d<a.length&&"\n"!==a[d];)d+=1;continue}if("/"===b&&"*"===a[d+1]){let b=a.indexOf("*/",d+2);d=-1===b?a.length:b+2;continue}if("'"===b||'"'===b){d=function(a,b,c){let d=b+1;for(;d<a.length;){if(a[d]===c){if(a[d+1]===c){d+=2;continue}return d+1}d+=1}return d}(a,d,b);continue}if("$"===b){let b=function(a,b){if("$"!==a[b])return null;let c=b+1;for(;c<a.length&&h(a[c]);)c+=1;return"$"!==a[c]?null:a.slice(b,c+1)}(a,d);if(b){let c=a.indexOf(b,d+b.length);d=-1===c?a.length:c+b.length;continue}}if(";"===b){e(d+1),d+=1,c=d;continue}d+=1}return e(a.length),b}(a),c=b.filter(a=>e.has(a.keyword)||f.has(a.keyword)||g.has(a.keyword));if(0===c.length)return{mode:"wrapped-by-ytdb",sql:a,atomic:!0};let i=b[0],j=b[b.length-1];return 2===c.length&&c[0]===i&&c[1]===j&&e.has(i.keyword)&&f.has(j.keyword)?{mode:"self-wrapped",sql:a.slice(0,i.at)+a.slice(i.end,j.at)+a.slice(j.end),atomic:!0}:{mode:"self-managed",sql:a,atomic:!1}}},65125:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{GD:()=>t,SC:()=>p,yn:()=>v});var e=c(41834),f=c(51473),g=c(51975),h=c(21010),i=c(82428),j=a([i]);function k(a,b){return`
2
+ SELECT version, name, checksum, set_name, applied_at, duration_ms, applied_by${b?", apply_sql, revert_sql":""}
3
+ FROM ${(0,h.Ab)(a)}
4
+ ORDER BY version`}function l(a){return{version:a.version,name:a.name??"",checksum:a.checksum??"",setName:a.set_name,appliedAt:a.applied_at instanceof Date?a.applied_at.toISOString():String(a.applied_at),durationMs:a.duration_ms,appliedBy:a.applied_by,...a.apply_sql?{applySql:a.apply_sql}:{},...a.revert_sql?{revertSql:a.revert_sql}:{}}}function m(a,b){if("object"==typeof a&&null!==a&&"code"in a&&"42501"===a.code){let c=a instanceof Error?a.message:String(a);throw Error(`${c}. YTDB keeps its ledger in "${b}" and this role cannot use it. Either point the ledger at a schema this role owns, or have an admin run: CREATE SCHEMA IF NOT EXISTS ${(0,f.v)(b)}; GRANT USAGE, CREATE ON SCHEMA ${(0,f.v)(b)} TO CURRENT_USER;`)}throw a}async function n(a,b){let c=await a.query("SELECT to_regclass($1)::text AS table",[(0,h.Ab)(b)]).catch(a=>m(a,b));return!!c.rows[0]?.table}i=(j.then?(await j)():j)[0];let w=[h.aC,"public"];async function o(a,b){if(await n(a,b))return{schema:b,exists:!0};for(let c of w)if(c!==b&&await n(a,c))return{schema:c,exists:!0};return{schema:b,exists:!1}}async function p(a,b=h.aC,c=!1){let d=(0,i.d)(a),{schema:e,exists:f}=await o(d,b);if(!f)return{initialized:!1,schema:e,entries:[]};let g=await d.query(k(e,c)).catch(async a=>{if(!c)throw a;return d.query(k(e,!1))});return{initialized:!0,schema:e,entries:g.rows.map(l)}}async function q(a){try{await a.query("ROLLBACK")}catch{}}async function r(a,b){let c=await a.query({text:b,rowMode:"array"});return Array.isArray(c)?c.length:1}async function s(a,b){try{for(let c of(await a.query(`CREATE SCHEMA IF NOT EXISTS ${(0,f.v)(b)}`),await a.query(`
5
5
  CREATE TABLE IF NOT EXISTS ${(0,h.Ab)(b)} (
6
6
  version text PRIMARY KEY,
7
7
  name text NOT NULL DEFAULT '',
@@ -9,16 +9,21 @@ CREATE TABLE IF NOT EXISTS ${(0,h.Ab)(b)} (
9
9
  set_name text,
10
10
  applied_at timestamptz NOT NULL DEFAULT now(),
11
11
  duration_ms integer,
12
- applied_by text
13
- )`)}catch(a){l(a,b)}}async function s(a,b){!function(a){if(!a.version.trim())throw Error("Missing migration version");if(a.recordOnly)return;let b=a.sql.trim();if(!b)throw Error(`Migration ${a.version} has nothing to run`);if(b.length>e.H4)throw Error(`Migration ${a.version} is too long (maximum ${e.H4.toLocaleString()} characters)`);if(b.includes("\0"))throw Error(`Migration ${a.version} contains a null character`)}(b);let c=(0,g.Ol)(b.sql),d=(0,i.d)(a,"migration"),{schema:f}=await n(d,b.ledgerSchema),h=await d.connect(),j=performance.now();try{await h.query(`SET statement_timeout TO ${e.mf}`),await r(h,f);let a=()=>Math.max(0,Math.round(performance.now()-j));if(b.recordOnly){let c=await t(h,f,b,0);return{version:b.version,direction:b.direction,durationMs:a(),statements:0,appliedAt:c}}if(!c.atomic){let d=await q(h,c.sql),e=await t(h,f,b,a());return{version:b.version,direction:b.direction,durationMs:a(),statements:d,appliedAt:e}}await h.query("BEGIN");try{let d=await q(h,c.sql),e=await t(h,f,b,a());return await h.query("COMMIT"),{version:b.version,direction:b.direction,durationMs:a(),statements:d,appliedAt:e}}catch(a){throw await p(h),a}}finally{h.release(!0)}}async function t(a,b,c,d){if("revert"===c.direction)return await a.query(`DELETE FROM ${(0,h.Ab)(b)} WHERE version = $1`,[c.version]),null;let e=await a.query(`
14
- INSERT INTO ${(0,h.Ab)(b)} (version, name, checksum, set_name, duration_ms, applied_by)
15
- VALUES ($1, $2, $3, $4, $5, current_user)
12
+ applied_by text,
13
+ apply_sql text,
14
+ revert_sql text
15
+ )`),[`ALTER TABLE ${(0,h.Ab)(b)} ADD COLUMN IF NOT EXISTS apply_sql text`,`ALTER TABLE ${(0,h.Ab)(b)} ADD COLUMN IF NOT EXISTS revert_sql text`]))await a.query(c)}catch(a){m(a,b)}}async function t(a,b){!function(a){if(!a.version.trim())throw Error("Missing migration version");if(a.recordOnly)return;let b=a.sql.trim();if(!b)throw Error(`Migration ${a.version} has nothing to run`);if(b.length>e.H4)throw Error(`Migration ${a.version} is too long (maximum ${e.H4.toLocaleString()} characters)`);if(b.includes("\0"))throw Error(`Migration ${a.version} contains a null character`)}(b);let c=(0,g.Ol)(b.sql),d=(0,i.d)(a,"migration"),{schema:f}=await o(d,b.ledgerSchema),h=await d.connect(),j=performance.now();try{await h.query(`SET statement_timeout TO ${e.mf}`),await s(h,f);let a=()=>Math.max(0,Math.round(performance.now()-j));if(b.recordOnly){let c=await u(h,f,b,0);return{version:b.version,direction:b.direction,durationMs:a(),statements:0,appliedAt:c}}if(!c.atomic){let d=await r(h,c.sql),e=await u(h,f,b,a());return{version:b.version,direction:b.direction,durationMs:a(),statements:d,appliedAt:e}}await h.query("BEGIN");try{let d=await r(h,c.sql),e=await u(h,f,b,a());return await h.query("COMMIT"),{version:b.version,direction:b.direction,durationMs:a(),statements:d,appliedAt:e}}catch(a){throw await q(h),a}}finally{h.release(!0)}}async function u(a,b,c,d){if("revert"===c.direction)return await a.query(`DELETE FROM ${(0,h.Ab)(b)} WHERE version = $1`,[c.version]),null;let e=await a.query(`
16
+ INSERT INTO ${(0,h.Ab)(b)}
17
+ (version, name, checksum, set_name, duration_ms, applied_by, apply_sql, revert_sql)
18
+ VALUES ($1, $2, $3, $4, $5, current_user, $6, $7)
16
19
  ON CONFLICT (version) DO UPDATE SET
17
20
  name = EXCLUDED.name,
18
21
  checksum = EXCLUDED.checksum,
19
22
  set_name = EXCLUDED.set_name,
20
23
  applied_at = now(),
21
24
  duration_ms = EXCLUDED.duration_ms,
22
- applied_by = current_user
23
- RETURNING applied_at`,[c.version,c.name,c.checksum,c.setName,d]),f=e.rows[0]?.applied_at;return f?f instanceof Date?f.toISOString():String(f):null}async function u(a,b=h.aC){let c=(0,i.d)(a,"migration"),{schema:d}=await n(c,b),e=await c.connect();try{await r(e,d)}finally{e.release()}return o(a,b)}d()}catch(a){d(a)}})},70613:(a,b,c)=>{"use strict";c.d(b,{Ai:()=>o,EB:()=>n,L1:()=>m,v_:()=>q});var d=c(77598),e=c(51455),f=c(76760),g=c.n(f),h=c(89194);let i=process.env.YTDB_LOG_DIR??g().join(process.cwd(),".ytdb","activity"),j=null,k=Promise.resolve(),l=!1;function m(a){if(["0","off","false"].includes((process.env.YTDB_LOG??"").toLowerCase()))return;let b=`${JSON.stringify({v:h.aH,id:(0,d.randomUUID)(),ts:new Date().toISOString(),...a})}
25
+ applied_by = current_user,
26
+ apply_sql = EXCLUDED.apply_sql,
27
+ revert_sql = EXCLUDED.revert_sql
28
+ RETURNING applied_at`,[c.version,c.name,c.checksum,c.setName,d,c.sql||null,c.revertSql??null]),f=e.rows[0]?.applied_at;return f?f instanceof Date?f.toISOString():String(f):null}async function v(a,b=h.aC){let c=(0,i.d)(a,"migration"),{schema:d}=await o(c,b),e=await c.connect();try{await s(e,d)}finally{e.release()}return p(a,b)}d()}catch(a){d(a)}})},70613:(a,b,c)=>{"use strict";c.d(b,{Ai:()=>o,EB:()=>n,L1:()=>m,v_:()=>q});var d=c(77598),e=c(51455),f=c(76760),g=c.n(f),h=c(89194);let i=process.env.YTDB_LOG_DIR??g().join(process.cwd(),".ytdb","activity"),j=null,k=Promise.resolve(),l=!1;function m(a){if(["0","off","false"].includes((process.env.YTDB_LOG??"").toLowerCase()))return;let b=`${JSON.stringify({v:h.aH,id:(0,d.randomUUID)(),ts:new Date().toISOString(),...a})}
24
29
  `;k=k.then(async()=>{var a;j??=(0,e.mkdir)(i,{recursive:!0}).then(()=>void 0),await j,await (0,e.appendFile)((a=new Date,g().join(i,`${a.toISOString().slice(0,10)}.jsonl`)),b,"utf8")}).catch(a=>{j=null,l||(l=!0,console.warn("[activity-log] disabled for this run:",a))})}function n(a){if("string"!=typeof a||0===a.length)return null;try{let b=new URL(a),c=b.username?`${decodeURIComponent(b.username)}@`:"",d=b.port?`:${b.port}`:"";return`${b.protocol}//${c}${b.hostname}${d}${b.pathname}`}catch{return"invalid-url"}}function o(a){return!a||"object"!=typeof a||Array.isArray(a)?p(a):p(Object.fromEntries(Object.entries(a).filter(([a])=>"connectionUrl"!==a)))}function p(a){let b;try{b=JSON.stringify(a)??"null"}catch{return{unserializable:!0}}return b.length<=2e4?a:{truncated:!0,bytes:b.length,preview:b.slice(0,1e3)}}function q(a,b){switch(a){case"tables":return{tables:Array.isArray(b)?b.length:0};case"rows":case"lookup":return{rows:r(b?.rows),columns:r(b?.columns),total:b?.total??null,estimated:b?.estimated??!1,capped:b?.capped??!1};case"query":{let a=Array.isArray(b?.statements)?b.statements:[];return{statements:a.length,commands:a.map(a=>a.command),rows:a.reduce((a,b)=>a+r(b.rows),0),durationMs:b?.durationMs??null}}case"cell.update":return{updated:+!!b?.row};case"rows.insert":return{inserted:+!!b?.row};case"rows.update":return{updated:b?.updated??0};case"rows.delete":return{deleted:b?.deleted??0};case"related":{let a=Array.isArray(b)?b:[];return{lookups:a.length,matched:a.reduce((a,b)=>a+r(b.rows),0)}}case"definition":return{sqlLength:"string"==typeof b?.sql?b.sql.length:0};case"ledger":return{initialized:b?.initialized??!1,entries:r(b?.entries)};case"migrate":return{version:b?.version??null,direction:b?.direction??null,statements:b?.statements??0,durationMs:b?.durationMs??null};case"schema":return{relations:r(b?.relations),enums:r(b?.enums),functions:r(b?.functions),extensions:r(b?.extensions)};default:return}}function r(a){return Array.isArray(a)?a.length:0}},78335:()=>{},82428:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{d:()=>h});var e=c(64939),f=c(41834),g=a([e]);e=(g.then?(await g)():g)[0];let i=new Map,j={explorer:f.nc,migration:f.mf};function h(a,b="explorer"){let c=`${b}:${a}`,d=i.get(c);if(!d){let f=j[b];(d=new e.Pool({connectionString:a,max:"migration"===b?2:4,idleTimeoutMillis:3e4,application_name:"ytdb",statement_timeout:f,query_timeout:f,ssl:!function(a){try{let{hostname:b,searchParams:c}=new URL(a);if(c.has("sslmode"))return"disable"!==c.get("sslmode");return!["localhost","127.0.0.1","::1"].includes(b)}catch{return!1}}(a)?void 0:{rejectUnauthorized:!1}})).on("error",()=>i.delete(c)),i.set(c,d)}return d}d()}catch(a){d(a)}})},84152:(a,b,c)=>{"use strict";c.d(b,{VW:()=>g,fx:()=>f,ms:()=>h});var d=c(41834),e=c(70613);function f(a,b){return async c=>{let f;if("1"===process.env.VERCEL)return Response.json({error:"Database API is local-only"},{status:404});let g=performance.now();try{f=await c.json()}catch{return(0,e.L1)({source:"api",action:a,connection:null,status:"error",durationMs:Math.round(performance.now()-g),error:"Invalid JSON body"}),Response.json({error:"Invalid JSON body"},{status:400})}let h=(0,e.EB)(f?.connectionUrl),i=(0,e.Ai)(f);try{let c=await b(f);return(0,e.L1)({source:"api",action:a,connection:h,status:"ok",durationMs:Math.round(performance.now()-g),params:i,result:(0,e.v_)(a,c)}),Response.json(c)}catch(c){let b=(0,d.qX)(c);return(0,e.L1)({source:"api",action:a,connection:h,status:"error",durationMs:Math.round(performance.now()-g),params:i,error:b}),Response.json({error:b},{status:500})}}}function g(a,b){if("string"!=typeof a||0===a.length)throw Error(`Missing ${b}`);return a}function h(a,b="table"){if(!a||"object"!=typeof a)throw Error(`Missing ${b}`);return{schema:g(a.schema,`${b}.schema`),name:g(a.name,`${b}.name`)}}},89194:(a,b,c)=>{"use strict";c.d(b,{P7:()=>f,aH:()=>d});let d=1,e=["connection.add","connection.update","connection.remove","config.export","config.import","migrations.import","migrations.remove"];function f(a){return"string"==typeof a&&e.includes(a)}},92280:(a,b,c)=>{"use strict";Object.defineProperty(b,"I",{enumerable:!0,get:function(){return g}});let d=c(28208),e=c(47617),f=c(62018);async function g(a,b,c,g){if((0,d.isNodeNextResponse)(b)){var h;b.statusCode=c.status,b.statusMessage=c.statusText;let d=["set-cookie","www-authenticate","proxy-authenticate","vary"];null==(h=c.headers)||h.forEach((a,c)=>{if("x-middleware-set-cookie"!==c.toLowerCase())if("set-cookie"===c.toLowerCase())for(let d of(0,f.splitCookiesString)(a))b.appendHeader(c,d);else{let e=void 0!==b.getHeader(c);(d.includes(c.toLowerCase())||!e)&&b.appendHeader(c,a)}});let{originalResponse:i}=b;c.body&&"HEAD"!==a.method?await (0,e.pipeToNodeResponse)(c.body,i,g):i.end()}}},96487:()=>{}};
@@ -1 +1 @@
1
- globalThis.__BUILD_MANIFEST={polyfillFiles:["static/chunks/polyfills-42372ed130431b0a.js"],devFiles:[],lowPriorityFiles:["static/4qs91o-9uIcy_ViXwFMl1/_buildManifest.js","static/4qs91o-9uIcy_ViXwFMl1/_ssgManifest.js"],rootMainFiles:["static/chunks/webpack-34eb118f56295776.js","static/chunks/4bd1b696-8a4ab4fdf0ae305a.js","static/chunks/3794-d7cddff008311ab3.js","static/chunks/main-app-f73ec34e89cb8fdd.js"],rootMainFilesTree:{},pages:{"/_app":[]}};
1
+ globalThis.__BUILD_MANIFEST={polyfillFiles:["static/chunks/polyfills-42372ed130431b0a.js"],devFiles:[],lowPriorityFiles:["static/_G44c2d2nyq6S1KEvNgOB/_buildManifest.js","static/_G44c2d2nyq6S1KEvNgOB/_ssgManifest.js"],rootMainFiles:["static/chunks/webpack-34eb118f56295776.js","static/chunks/4bd1b696-8a4ab4fdf0ae305a.js","static/chunks/3794-d7cddff008311ab3.js","static/chunks/main-app-f73ec34e89cb8fdd.js"],rootMainFilesTree:{},pages:{"/_app":[]}};
@@ -1 +1 @@
1
- <!DOCTYPE html><html lang="en" class="__variable_246ccd __variable_c29908 dark h-full" data-theme="dark"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" href="/_next/static/media/22a5144ee8d83bca-s.p.woff2" as="font" crossorigin="" type="font/woff2"/><link rel="preload" href="/_next/static/media/7d4881bb7e1bf84d-s.p.woff2" as="font" crossorigin="" type="font/woff2"/><link rel="stylesheet" href="/_next/static/css/e02ab5db9ff2dca2.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/993f480f9e0f3e74.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-34eb118f56295776.js"/><script src="/_next/static/chunks/4bd1b696-8a4ab4fdf0ae305a.js" async=""></script><script src="/_next/static/chunks/3794-d7cddff008311ab3.js" async=""></script><script src="/_next/static/chunks/main-app-f73ec34e89cb8fdd.js" async=""></script><script src="/_next/static/chunks/6039-02dbcff4d4ccf559.js" async=""></script><script src="/_next/static/chunks/app/layout-dd332a9583f47cd6.js" async=""></script><meta name="robots" content="noindex"/><meta name="next-size-adjust" content=""/><title>YTDB</title><meta name="description" content="A database management UI"/><link rel="icon" href="/favicon.ico?603d046c9a6fdfbb" type="image/x-icon" sizes="16x16"/><link rel="icon" href="/icon.svg?38bdd49dcdf01715" type="image/svg+xml" sizes="any"/><script>(function(){try{var allowed=["dark","light","one-dark-pro","nord","dracula","tokyo-night"];var light=["light"];var id="dark";var raw=localStorage.getItem("ytdb:theme")||localStorage.getItem("db-studio:theme");if(raw){var parsed=JSON.parse(raw);var value=parsed&&parsed.state&&parsed.state.theme;if(typeof value==="string"&&allowed.indexOf(value)!==-1)id=value;}var root=document.documentElement;root.setAttribute("data-theme",id);root.classList.toggle("dark",light.indexOf(id)===-1);}catch(e){}})();</script><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body class="flex min-h-full flex-col"><div hidden=""><!--$--><!--/$--></div><main class="grid min-h-dvh place-items-center bg-background px-6 text-foreground"><div class="max-w-lg space-y-4"><p class="font-mono text-xs tracking-[0.22em] text-muted-foreground">YTDB</p><h1 class="text-2xl font-semibold tracking-tight">Connecting to YTDB…</h1></div></main><script src="/_next/static/chunks/webpack-34eb118f56295776.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[72737,[\"6039\",\"static/chunks/6039-02dbcff4d4ccf559.js\",\"7177\",\"static/chunks/app/layout-dd332a9583f47cd6.js\"],\"ThemeProvider\"]\n3:I[94821,[\"6039\",\"static/chunks/6039-02dbcff4d4ccf559.js\",\"7177\",\"static/chunks/app/layout-dd332a9583f47cd6.js\"],\"ConvexClientProvider\"]\n4:I[87758,[\"6039\",\"static/chunks/6039-02dbcff4d4ccf559.js\",\"7177\",\"static/chunks/app/layout-dd332a9583f47cd6.js\"],\"LocalBridgeGate\"]\n5:I[57121,[],\"\"]\n6:I[74581,[],\"\"]\n7:I[90484,[],\"OutletBoundary\"]\n8:\"$Sreact.suspense\"\nb:I[90484,[],\"ViewportBoundary\"]\nd:I[90484,[],\"MetadataBoundary\"]\nf:I[27123,[],\"default\",1]\n:HL[\"/_next/static/media/22a5144ee8d83bca-s.p.woff2\",\"font\",{\"crossOrigin\":\"\",\"type\":\"font/woff2\"}]\n:HL[\"/_next/static/media/7d4881bb7e1bf84d-s.p.woff2\",\"font\",{\"crossOrigin\":\"\",\"type\":\"font/woff2\"}]\n:HL[\"/_next/static/css/e02ab5db9ff2dca2.css\",\"style\"]\n:HL[\"/_next/static/css/993f480f9e0f3e74.css\",\"style\"]\na:X\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"c\":[\"\",\"_not-found\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"_not-found\",{\"children\":[\"__PAGE__\",{},\"$undefined\",\"$undefined\",4608]},\"$undefined\",\"$undefined\",4608]},\"$undefined\",\"$undefined\",4624],[[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/e02ab5db9ff2dca2.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\",\"nonce\":\"$undefined\"}],[\"$\",\"link\",\"1\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/993f480f9e0f3e74.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\",\"nonce\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"className\":\"__variable_246ccd __variable_c29908 dark h-full\",\"data-theme\":\"dark\",\"suppressHydrationWarning\":true,\"children\":[[\"$\",\"head\",null,{\"children\":[\"$\",\"script\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"(function(){try{var allowed=[\\\"dark\\\",\\\"light\\\",\\\"one-dark-pro\\\",\\\"nord\\\",\\\"dracula\\\",\\\"tokyo-night\\\"];var light=[\\\"light\\\"];var id=\\\"dark\\\";var raw=localStorage.getItem(\\\"ytdb:theme\\\")||localStorage.getItem(\\\"db-studio:theme\\\");if(raw){var parsed=JSON.parse(raw);var value=parsed\u0026\u0026parsed.state\u0026\u0026parsed.state.theme;if(typeof value===\\\"string\\\"\u0026\u0026allowed.indexOf(value)!==-1)id=value;}var root=document.documentElement;root.setAttribute(\\\"data-theme\\\",id);root.classList.toggle(\\\"dark\\\",light.indexOf(id)===-1);}catch(e){}})();\"}}]}],[\"$\",\"body\",null,{\"className\":\"flex min-h-full flex-col\",\"children\":[\"$\",\"$L2\",null,{\"children\":[\"$\",\"$L3\",null,{\"children\":[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$L5\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L6\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]}]}]}]}]]}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L5\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L6\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":404}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],null,[\"$\",\"$L7\",null,{\"children\":[\"$\",\"$8\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@9\"}]}]]}],{},null,false,null]},null,false,\"$a\"]},null,false,null],[\"$\",\"$1\",\"h\",{\"children\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],[\"$\",\"$Lb\",null,{\"children\":\"$Lc\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$Ld\",null,{\"children\":[\"$\",\"$8\",null,{\"name\":\"Next.Metadata\",\"children\":\"$Le\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$f\",[]],\"S\":true,\"h\":null,\"r\":\"$undefined\",\"s\":\"$undefined\",\"a\":\"$undefined\",\"l\":\"$undefined\",\"p\":\"$undefined\",\"d\":\"$undefined\",\"b\":\"4qs91o-9uIcy_ViXwFMl1\"}\n"])</script><script>self.__next_f.push([1,"a:C\nc:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"10:I[86869,[],\"IconMark\"]\n9:null\ne:[[\"$\",\"title\",\"0\",{\"children\":\"YTDB\"}],[\"$\",\"meta\",\"1\",{\"name\":\"description\",\"content\":\"A database management UI\"}],[\"$\",\"link\",\"2\",{\"rel\":\"icon\",\"href\":\"/favicon.ico?603d046c9a6fdfbb\",\"type\":\"image/x-icon\",\"sizes\":\"16x16\"}],[\"$\",\"link\",\"3\",{\"rel\":\"icon\",\"href\":\"/icon.svg?38bdd49dcdf01715\",\"type\":\"image/svg+xml\",\"sizes\":\"any\"}],[\"$\",\"$L10\",\"4\",{}]]\n"])</script></body></html>
1
+ <!DOCTYPE html><html lang="en" class="__variable_246ccd __variable_c29908 dark h-full" data-theme="dark"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" href="/_next/static/media/22a5144ee8d83bca-s.p.woff2" as="font" crossorigin="" type="font/woff2"/><link rel="preload" href="/_next/static/media/7d4881bb7e1bf84d-s.p.woff2" as="font" crossorigin="" type="font/woff2"/><link rel="stylesheet" href="/_next/static/css/e02ab5db9ff2dca2.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/7bb8868c12384025.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-34eb118f56295776.js"/><script src="/_next/static/chunks/4bd1b696-8a4ab4fdf0ae305a.js" async=""></script><script src="/_next/static/chunks/3794-d7cddff008311ab3.js" async=""></script><script src="/_next/static/chunks/main-app-f73ec34e89cb8fdd.js" async=""></script><script src="/_next/static/chunks/6039-02dbcff4d4ccf559.js" async=""></script><script src="/_next/static/chunks/app/layout-dd332a9583f47cd6.js" async=""></script><meta name="robots" content="noindex"/><meta name="next-size-adjust" content=""/><title>YTDB</title><meta name="description" content="A database management UI"/><link rel="icon" href="/favicon.ico?603d046c9a6fdfbb" type="image/x-icon" sizes="16x16"/><link rel="icon" href="/icon.svg?38bdd49dcdf01715" type="image/svg+xml" sizes="any"/><script>(function(){try{var allowed=["dark","light","one-dark-pro","nord","dracula","tokyo-night"];var light=["light"];var id="dark";var raw=localStorage.getItem("ytdb:theme")||localStorage.getItem("db-studio:theme");if(raw){var parsed=JSON.parse(raw);var value=parsed&&parsed.state&&parsed.state.theme;if(typeof value==="string"&&allowed.indexOf(value)!==-1)id=value;}var root=document.documentElement;root.setAttribute("data-theme",id);root.classList.toggle("dark",light.indexOf(id)===-1);}catch(e){}})();</script><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body class="flex min-h-full flex-col"><div hidden=""><!--$--><!--/$--></div><main class="grid min-h-dvh place-items-center bg-background px-6 text-foreground"><div class="max-w-lg space-y-4"><p class="font-mono text-xs tracking-[0.22em] text-muted-foreground">YTDB</p><h1 class="text-2xl font-semibold tracking-tight">Connecting to YTDB…</h1></div></main><script src="/_next/static/chunks/webpack-34eb118f56295776.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[72737,[\"6039\",\"static/chunks/6039-02dbcff4d4ccf559.js\",\"7177\",\"static/chunks/app/layout-dd332a9583f47cd6.js\"],\"ThemeProvider\"]\n3:I[94821,[\"6039\",\"static/chunks/6039-02dbcff4d4ccf559.js\",\"7177\",\"static/chunks/app/layout-dd332a9583f47cd6.js\"],\"ConvexClientProvider\"]\n4:I[87758,[\"6039\",\"static/chunks/6039-02dbcff4d4ccf559.js\",\"7177\",\"static/chunks/app/layout-dd332a9583f47cd6.js\"],\"LocalBridgeGate\"]\n5:I[57121,[],\"\"]\n6:I[74581,[],\"\"]\n7:I[90484,[],\"OutletBoundary\"]\n8:\"$Sreact.suspense\"\nb:I[90484,[],\"ViewportBoundary\"]\nd:I[90484,[],\"MetadataBoundary\"]\nf:I[27123,[],\"default\",1]\n:HL[\"/_next/static/media/22a5144ee8d83bca-s.p.woff2\",\"font\",{\"crossOrigin\":\"\",\"type\":\"font/woff2\"}]\n:HL[\"/_next/static/media/7d4881bb7e1bf84d-s.p.woff2\",\"font\",{\"crossOrigin\":\"\",\"type\":\"font/woff2\"}]\n:HL[\"/_next/static/css/e02ab5db9ff2dca2.css\",\"style\"]\n:HL[\"/_next/static/css/7bb8868c12384025.css\",\"style\"]\na:X\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"c\":[\"\",\"_not-found\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"_not-found\",{\"children\":[\"__PAGE__\",{},\"$undefined\",\"$undefined\",4608]},\"$undefined\",\"$undefined\",4608]},\"$undefined\",\"$undefined\",4624],[[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/e02ab5db9ff2dca2.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\",\"nonce\":\"$undefined\"}],[\"$\",\"link\",\"1\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/7bb8868c12384025.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\",\"nonce\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"className\":\"__variable_246ccd __variable_c29908 dark h-full\",\"data-theme\":\"dark\",\"suppressHydrationWarning\":true,\"children\":[[\"$\",\"head\",null,{\"children\":[\"$\",\"script\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"(function(){try{var allowed=[\\\"dark\\\",\\\"light\\\",\\\"one-dark-pro\\\",\\\"nord\\\",\\\"dracula\\\",\\\"tokyo-night\\\"];var light=[\\\"light\\\"];var id=\\\"dark\\\";var raw=localStorage.getItem(\\\"ytdb:theme\\\")||localStorage.getItem(\\\"db-studio:theme\\\");if(raw){var parsed=JSON.parse(raw);var value=parsed\u0026\u0026parsed.state\u0026\u0026parsed.state.theme;if(typeof value===\\\"string\\\"\u0026\u0026allowed.indexOf(value)!==-1)id=value;}var root=document.documentElement;root.setAttribute(\\\"data-theme\\\",id);root.classList.toggle(\\\"dark\\\",light.indexOf(id)===-1);}catch(e){}})();\"}}]}],[\"$\",\"body\",null,{\"className\":\"flex min-h-full flex-col\",\"children\":[\"$\",\"$L2\",null,{\"children\":[\"$\",\"$L3\",null,{\"children\":[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$L5\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L6\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]}]}]}]}]]}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L5\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L6\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":404}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],null,[\"$\",\"$L7\",null,{\"children\":[\"$\",\"$8\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@9\"}]}]]}],{},null,false,null]},null,false,\"$a\"]},null,false,null],[\"$\",\"$1\",\"h\",{\"children\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],[\"$\",\"$Lb\",null,{\"children\":\"$Lc\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$Ld\",null,{\"children\":[\"$\",\"$8\",null,{\"name\":\"Next.Metadata\",\"children\":\"$Le\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$f\",[]],\"S\":true,\"h\":null,\"r\":\"$undefined\",\"s\":\"$undefined\",\"a\":\"$undefined\",\"l\":\"$undefined\",\"p\":\"$undefined\",\"d\":\"$undefined\",\"b\":\"_G44c2d2nyq6S1KEvNgOB\"}\n"])</script><script>self.__next_f.push([1,"a:C\nc:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"10:I[86869,[],\"IconMark\"]\n9:null\ne:[[\"$\",\"title\",\"0\",{\"children\":\"YTDB\"}],[\"$\",\"meta\",\"1\",{\"name\":\"description\",\"content\":\"A database management UI\"}],[\"$\",\"link\",\"2\",{\"rel\":\"icon\",\"href\":\"/favicon.ico?603d046c9a6fdfbb\",\"type\":\"image/x-icon\",\"sizes\":\"16x16\"}],[\"$\",\"link\",\"3\",{\"rel\":\"icon\",\"href\":\"/icon.svg?38bdd49dcdf01715\",\"type\":\"image/svg+xml\",\"sizes\":\"any\"}],[\"$\",\"$L10\",\"4\",{}]]\n"])</script></body></html>
@@ -1 +1 @@
1
- <!DOCTYPE html><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-34eb118f56295776.js"/><script src="/_next/static/chunks/4bd1b696-8a4ab4fdf0ae305a.js" async=""></script><script src="/_next/static/chunks/3794-d7cddff008311ab3.js" async=""></script><script src="/_next/static/chunks/main-app-f73ec34e89cb8fdd.js" async=""></script><meta name="next-size-adjust" content=""/><title>500: This page couldn’t load</title><style>:root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }</style><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;display:flex;align-items:center;justify-content:center"><div style="margin-top:-32px;max-width:325px;padding:32px 28px;text-align:left"><svg width="32" height="32" viewBox="-0.2 -1.5 32 32" fill="none" style="margin-bottom:24px"><path d="M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z" fill="var(--next-error-title)"></path></svg><h1 style="font-size:24px;font-weight:500;letter-spacing:-0.02em;line-height:32px;margin:0 0 12px 0;color:var(--next-error-title)">This page couldn’t load</h1><p style="font-size:14px;font-weight:400;line-height:21px;margin:0 0 20px 0;color:var(--next-error-message)">A server error occurred. Reload to try again.</p><form style="margin:0"><button type="submit" style="display:inline-flex;align-items:center;justify-content:center;height:32px;padding:0 12px;font-size:14px;font-weight:500;line-height:20px;border-radius:6px;cursor:pointer;color:var(--next-error-btn-text);background:var(--next-error-btn-bg);border:var(--next-error-btn-border)">Reload</button></form></div></div><!--$--><!--/$--><script src="/_next/static/chunks/webpack-34eb118f56295776.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[57121,[],\"\"]\n3:I[74581,[],\"\"]\n4:I[90484,[],\"OutletBoundary\"]\n5:\"$Sreact.suspense\"\n8:I[90484,[],\"ViewportBoundary\"]\na:I[90484,[],\"MetadataBoundary\"]\nc:I[27123,[],\"default\",1]\n7:X\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"c\":[\"\",\"_global-error\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"_global-error\",{\"children\":[\"__PAGE__\",{},\"$undefined\",\"$undefined\",4624]},\"$undefined\",\"$undefined\",4624]},\"$undefined\",\"$undefined\",4624],[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"html\",null,{\"id\":\"__next_error__\",\"children\":[[\"$\",\"head\",null,{\"children\":[[\"$\",\"title\",null,{\"children\":\"500: This page couldn’t load\"}],[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\":root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }\"}}]]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"display\":\"flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"style\":{\"marginTop\":\"-32px\",\"maxWidth\":\"325px\",\"padding\":\"32px 28px\",\"textAlign\":\"left\"},\"children\":[[\"$\",\"svg\",null,{\"width\":\"32\",\"height\":\"32\",\"viewBox\":\"-0.2 -1.5 32 32\",\"fill\":\"none\",\"style\":{\"marginBottom\":\"24px\"},\"children\":[\"$\",\"path\",null,{\"d\":\"M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z\",\"fill\":\"var(--next-error-title)\"}]}],[\"$\",\"h1\",null,{\"style\":{\"fontSize\":\"24px\",\"fontWeight\":500,\"letterSpacing\":\"-0.02em\",\"lineHeight\":\"32px\",\"margin\":\"0 0 12px 0\",\"color\":\"var(--next-error-title)\"},\"children\":\"This page couldn’t load\"}],[\"$\",\"p\",null,{\"style\":{\"fontSize\":\"14px\",\"fontWeight\":400,\"lineHeight\":\"21px\",\"margin\":\"0 0 20px 0\",\"color\":\"var(--next-error-message)\"},\"children\":\"A server error occurred. Reload to try again.\"}],[\"$\",\"form\",null,{\"style\":{\"margin\":0},\"children\":[\"$\",\"button\",null,{\"type\":\"submit\",\"style\":{\"display\":\"inline-flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\",\"height\":\"32px\",\"padding\":\"0 12px\",\"fontSize\":\"14px\",\"fontWeight\":500,\"lineHeight\":\"20px\",\"borderRadius\":\"6px\",\"cursor\":\"pointer\",\"color\":\"var(--next-error-btn-text)\",\"background\":\"var(--next-error-btn-bg)\",\"border\":\"var(--next-error-btn-border)\"},\"children\":\"Reload\"}]}]]}]}]}]]}],null,[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@6\"}]}]]}],{},null,false,null]},null,false,\"$7\"]},null,false,\"$7\"],[\"$\",\"$1\",\"h\",{\"children\":[null,[\"$\",\"$L8\",null,{\"children\":\"$L9\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$La\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.Metadata\",\"children\":\"$Lb\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$c\",[]],\"S\":true,\"h\":null,\"r\":\"$undefined\",\"s\":\"$undefined\",\"a\":\"$undefined\",\"l\":\"$undefined\",\"p\":\"$undefined\",\"d\":\"$undefined\",\"b\":\"4qs91o-9uIcy_ViXwFMl1\"}\n"])</script><script>self.__next_f.push([1,"7:C\n9:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"6:null\nb:[]\n"])</script></body></html>
1
+ <!DOCTYPE html><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-34eb118f56295776.js"/><script src="/_next/static/chunks/4bd1b696-8a4ab4fdf0ae305a.js" async=""></script><script src="/_next/static/chunks/3794-d7cddff008311ab3.js" async=""></script><script src="/_next/static/chunks/main-app-f73ec34e89cb8fdd.js" async=""></script><meta name="next-size-adjust" content=""/><title>500: This page couldn’t load</title><style>:root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }</style><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;display:flex;align-items:center;justify-content:center"><div style="margin-top:-32px;max-width:325px;padding:32px 28px;text-align:left"><svg width="32" height="32" viewBox="-0.2 -1.5 32 32" fill="none" style="margin-bottom:24px"><path d="M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z" fill="var(--next-error-title)"></path></svg><h1 style="font-size:24px;font-weight:500;letter-spacing:-0.02em;line-height:32px;margin:0 0 12px 0;color:var(--next-error-title)">This page couldn’t load</h1><p style="font-size:14px;font-weight:400;line-height:21px;margin:0 0 20px 0;color:var(--next-error-message)">A server error occurred. Reload to try again.</p><form style="margin:0"><button type="submit" style="display:inline-flex;align-items:center;justify-content:center;height:32px;padding:0 12px;font-size:14px;font-weight:500;line-height:20px;border-radius:6px;cursor:pointer;color:var(--next-error-btn-text);background:var(--next-error-btn-bg);border:var(--next-error-btn-border)">Reload</button></form></div></div><!--$--><!--/$--><script src="/_next/static/chunks/webpack-34eb118f56295776.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[57121,[],\"\"]\n3:I[74581,[],\"\"]\n4:I[90484,[],\"OutletBoundary\"]\n5:\"$Sreact.suspense\"\n8:I[90484,[],\"ViewportBoundary\"]\na:I[90484,[],\"MetadataBoundary\"]\nc:I[27123,[],\"default\",1]\n7:X\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"c\":[\"\",\"_global-error\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"_global-error\",{\"children\":[\"__PAGE__\",{},\"$undefined\",\"$undefined\",4624]},\"$undefined\",\"$undefined\",4624]},\"$undefined\",\"$undefined\",4624],[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"html\",null,{\"id\":\"__next_error__\",\"children\":[[\"$\",\"head\",null,{\"children\":[[\"$\",\"title\",null,{\"children\":\"500: This page couldn’t load\"}],[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\":root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }\"}}]]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"display\":\"flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"style\":{\"marginTop\":\"-32px\",\"maxWidth\":\"325px\",\"padding\":\"32px 28px\",\"textAlign\":\"left\"},\"children\":[[\"$\",\"svg\",null,{\"width\":\"32\",\"height\":\"32\",\"viewBox\":\"-0.2 -1.5 32 32\",\"fill\":\"none\",\"style\":{\"marginBottom\":\"24px\"},\"children\":[\"$\",\"path\",null,{\"d\":\"M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z\",\"fill\":\"var(--next-error-title)\"}]}],[\"$\",\"h1\",null,{\"style\":{\"fontSize\":\"24px\",\"fontWeight\":500,\"letterSpacing\":\"-0.02em\",\"lineHeight\":\"32px\",\"margin\":\"0 0 12px 0\",\"color\":\"var(--next-error-title)\"},\"children\":\"This page couldn’t load\"}],[\"$\",\"p\",null,{\"style\":{\"fontSize\":\"14px\",\"fontWeight\":400,\"lineHeight\":\"21px\",\"margin\":\"0 0 20px 0\",\"color\":\"var(--next-error-message)\"},\"children\":\"A server error occurred. Reload to try again.\"}],[\"$\",\"form\",null,{\"style\":{\"margin\":0},\"children\":[\"$\",\"button\",null,{\"type\":\"submit\",\"style\":{\"display\":\"inline-flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\",\"height\":\"32px\",\"padding\":\"0 12px\",\"fontSize\":\"14px\",\"fontWeight\":500,\"lineHeight\":\"20px\",\"borderRadius\":\"6px\",\"cursor\":\"pointer\",\"color\":\"var(--next-error-btn-text)\",\"background\":\"var(--next-error-btn-bg)\",\"border\":\"var(--next-error-btn-border)\"},\"children\":\"Reload\"}]}]]}]}]}]]}],null,[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@6\"}]}]]}],{},null,false,null]},null,false,\"$7\"]},null,false,\"$7\"],[\"$\",\"$1\",\"h\",{\"children\":[null,[\"$\",\"$L8\",null,{\"children\":\"$L9\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$La\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.Metadata\",\"children\":\"$Lb\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$c\",[]],\"S\":true,\"h\":null,\"r\":\"$undefined\",\"s\":\"$undefined\",\"a\":\"$undefined\",\"l\":\"$undefined\",\"p\":\"$undefined\",\"d\":\"$undefined\",\"b\":\"_G44c2d2nyq6S1KEvNgOB\"}\n"])</script><script>self.__next_f.push([1,"7:C\n9:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"6:null\nb:[]\n"])</script></body></html>