@theobourgeois/ytdb 0.2.19 → 0.2.20
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.
- package/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +8 -5
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +1 -1
- package/.next/routes-manifest.json +26 -0
- package/.next/server/app/[connectionId]/[schema]/[table]/page.js +1 -1
- package/.next/server/app/[connectionId]/[schema]/[table]/page.js.nft.json +1 -1
- package/.next/server/app/[connectionId]/[schema]/[table]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/[connectionId]/diff/page.js +2 -2
- package/.next/server/app/[connectionId]/diff/page.js.nft.json +1 -1
- package/.next/server/app/[connectionId]/diff/page_client-reference-manifest.js +1 -1
- package/.next/server/app/[connectionId]/migrations/(index)/page.js +1 -0
- package/.next/server/app/[connectionId]/migrations/(index)/page.js.nft.json +1 -0
- package/.next/server/app/[connectionId]/migrations/(index)/page_client-reference-manifest.js +1 -0
- package/.next/server/app/[connectionId]/migrations/(index)/timeline/page.js +1 -0
- package/.next/server/app/[connectionId]/migrations/(index)/timeline/page.js.nft.json +1 -0
- package/.next/server/app/[connectionId]/migrations/(index)/timeline/page_client-reference-manifest.js +1 -0
- package/.next/server/app/[connectionId]/migrations/[setId]/page.js +1 -1
- package/.next/server/app/[connectionId]/migrations/[setId]/page.js.nft.json +1 -1
- package/.next/server/app/[connectionId]/migrations/[setId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/[connectionId]/migrations/[setId]/schema/page.js +1 -0
- package/.next/server/app/[connectionId]/migrations/[setId]/schema/page.js.nft.json +1 -0
- package/.next/server/app/[connectionId]/migrations/[setId]/schema/page_client-reference-manifest.js +1 -0
- package/.next/server/app/[connectionId]/migrations/[setId]/timeline/page.js +1 -0
- package/.next/server/app/[connectionId]/migrations/[setId]/timeline/page.js.nft.json +1 -0
- package/.next/server/app/[connectionId]/migrations/[setId]/timeline/page_client-reference-manifest.js +1 -0
- package/.next/server/app/[connectionId]/page.js +1 -1
- package/.next/server/app/[connectionId]/page.js.nft.json +1 -1
- package/.next/server/app/[connectionId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/[connectionId]/query/page.js +1 -1
- package/.next/server/app/[connectionId]/query/page.js.nft.json +1 -1
- package/.next/server/app/[connectionId]/query/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error/page.js +2 -2
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page.js +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/api/activity/route.js +2 -2
- package/.next/server/app/api/adopt/route.js +1 -1
- package/.next/server/app/api/cell/route.js +3 -3
- package/.next/server/app/api/definition/route.js +2 -2
- package/.next/server/app/api/delete-rows/route.js +2 -2
- package/.next/server/app/api/detect/route.js +1 -1
- package/.next/server/app/api/health/route.js +1 -1
- package/.next/server/app/api/insert-row/route.js +3 -3
- package/.next/server/app/api/ledger/route.js +1 -1
- package/.next/server/app/api/lookup/route.js +2 -2
- package/.next/server/app/api/migrate/route.js +1 -1
- package/.next/server/app/api/note/route.js +1 -1
- package/.next/server/app/api/query/route.js +3 -3
- package/.next/server/app/api/reconcile/route.js +2 -2
- package/.next/server/app/api/rehearse/route.js +1 -1
- package/.next/server/app/api/related/route.js +2 -2
- package/.next/server/app/api/repo/route.js +1 -1
- package/.next/server/app/api/rows/route.js +1 -1
- package/.next/server/app/api/schema/route.js +1 -1
- package/.next/server/app/api/tables/route.js +2 -2
- package/.next/server/app/api/timeline/route.js +1 -1
- package/.next/server/app/api/update-row/route.js +1 -1
- package/.next/server/app/favicon.ico/route.js +1 -1
- package/.next/server/app/icon.svg/route.js +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +2 -2
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/index.segments/_full.segment.rsc +2 -2
- package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/page.js +2 -2
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +8 -5
- package/.next/server/chunks/4809.js +1 -0
- package/.next/server/chunks/535.js +1 -0
- package/.next/server/chunks/5529.js +1 -0
- package/.next/server/chunks/5816.js +1 -1
- package/.next/server/chunks/6729.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/static/{PPqM7ay-YN8BBp1e_HK15 → XOKG1sVlYC-O8M7Qf5aWE}/_buildManifest.js +1 -1
- package/.next/static/chunks/1413-1888e486022200cf.js +1 -0
- package/.next/static/chunks/228-e9e3a928efbebb89.js +1 -0
- package/.next/static/chunks/544-9e1c454c8313699f.js +1 -0
- package/.next/static/chunks/577-d6d889d30c9375d9.js +1 -0
- package/.next/static/chunks/6090-6764126dba5d4d96.js +1 -0
- package/.next/static/chunks/app/[connectionId]/[schema]/[table]/page-37b33d781877f0a5.js +1 -0
- package/.next/static/chunks/app/[connectionId]/diff/page-215e1f750956eecb.js +10 -0
- package/.next/static/chunks/app/[connectionId]/{layout-06d736d4773bd4a8.js → layout-b8ad40b3da6824ed.js} +1 -1
- package/.next/static/chunks/app/[connectionId]/migrations/(index)/layout-2635a5499e0b928c.js +1 -0
- package/.next/static/chunks/app/[connectionId]/migrations/(index)/page-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/[connectionId]/migrations/(index)/timeline/page-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/[connectionId]/migrations/[setId]/{page-86a263e7e4a08d61.js → layout-cdb8e5d125828828.js} +1 -1
- package/.next/static/chunks/app/[connectionId]/migrations/[setId]/page-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/[connectionId]/migrations/[setId]/schema/page-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/[connectionId]/migrations/[setId]/timeline/page-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/[connectionId]/page-188bdfaba4f04923.js +1 -0
- package/.next/static/chunks/app/[connectionId]/query/page-ef40d6213057d671.js +1 -0
- package/.next/static/chunks/app/_global-error/page-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/api/activity/route-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/api/adopt/route-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/api/cell/route-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/api/definition/route-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/api/delete-rows/route-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/api/detect/route-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/api/health/route-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/api/insert-row/route-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/api/ledger/route-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/api/lookup/route-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/api/migrate/route-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/api/note/route-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/api/query/route-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/api/reconcile/route-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/api/rehearse/route-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/api/related/route-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/api/repo/route-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/api/rows/route-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/api/schema/route-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/api/tables/route-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/api/timeline/route-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/api/update-row/route-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/app/page-52545dcc822c61da.js +2 -0
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-34cb852b3259a90b.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-34cb852b3259a90b.js +1 -0
- package/package.json +1 -1
- package/.next/server/app/[connectionId]/migrations/page.js +0 -1
- package/.next/server/app/[connectionId]/migrations/page.js.nft.json +0 -1
- package/.next/server/app/[connectionId]/migrations/page_client-reference-manifest.js +0 -1
- package/.next/server/chunks/7593.js +0 -1
- package/.next/static/chunks/1520-1d9fc8b9ea29f3aa.js +0 -1
- package/.next/static/chunks/1981-806ce42b1641772f.js +0 -1
- package/.next/static/chunks/6782-c8b44f7f0d19d8e4.js +0 -1
- package/.next/static/chunks/7709-b2eee040599bab79.js +0 -1
- package/.next/static/chunks/9243-585cdd3c297cf117.js +0 -1
- package/.next/static/chunks/9532-860dc97ac3c3ff31.js +0 -1
- package/.next/static/chunks/app/[connectionId]/[schema]/[table]/page-7bed5765c93ce736.js +0 -1
- package/.next/static/chunks/app/[connectionId]/diff/page-e3e50546820ed5d5.js +0 -10
- package/.next/static/chunks/app/[connectionId]/migrations/page-fc5dcf1404df5c65.js +0 -1
- package/.next/static/chunks/app/[connectionId]/page-8f68a2646e2f3eaa.js +0 -1
- package/.next/static/chunks/app/[connectionId]/query/page-55618bbb32f70fee.js +0 -1
- package/.next/static/chunks/app/_global-error/page-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/app/api/activity/route-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/app/api/adopt/route-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/app/api/cell/route-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/app/api/definition/route-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/app/api/delete-rows/route-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/app/api/detect/route-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/app/api/health/route-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/app/api/insert-row/route-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/app/api/ledger/route-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/app/api/lookup/route-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/app/api/migrate/route-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/app/api/note/route-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/app/api/query/route-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/app/api/reconcile/route-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/app/api/rehearse/route-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/app/api/related/route-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/app/api/repo/route-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/app/api/rows/route-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/app/api/schema/route-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/app/api/tables/route-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/app/api/timeline/route-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/app/api/update-row/route-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/app/page-957b7639b047ba08.js +0 -2
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-ad3ae203c81de67b.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-ad3ae203c81de67b.js +0 -1
- /package/.next/static/{PPqM7ay-YN8BBp1e_HK15 → XOKG1sVlYC-O8M7Qf5aWE}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2194],{6044:(e,t,n)=>{"use strict";n.d(t,{SchemaDiffView:()=>J});var s=n(95155),a=n(98500),r=n.n(a),l=n(73321),i=n(12115),o=n(13267),u=n(72194),c=n(36331),d=n(17491),m=n(23716),h=n(40891),g=n(89239),f=n(72264),p=n(30374),x=n(35942),$=n(7412),b=n(86846),E=n(87364),N=n(27529);function T(e){return`"${e.replace(/"/g,'""')}"`}function k(e){return`${T(e.schema)}.${T(e.name)}`}function v(e){return k({schema:e.schema,name:e.name})}let y={smallint:"smallserial",integer:"serial",bigint:"bigserial"};function j(e){return/^\s*FOREIGN KEY/i.test(e)}function A(e,t){let n=function(e,t){if(!t||e.nullable||e.identity||null!==e.generated)return null;let n=y[e.type];if(!n||null===e.default)return null;let s=/^nextval\('([^']+)'::regclass\)$/.exec(e.default);return s?.[1]?.split(".").pop()?.replace(/"/g,"")===`${t}_${e.name}_seq`?n:null}(e,t);if(n)return`${T(e.name)} ${n}`;let s=[T(e.name),e.type];return(e.collation&&s.push("COLLATE",T(e.collation)),null!==e.generated)?(s.push("GENERATED ALWAYS AS",`(${e.generated})`,"STORED"),e.nullable||s.push("NOT NULL")):(e.nullable||s.push("NOT NULL"),e.identity?s.push(`GENERATED ${e.identity} AS IDENTITY`):null!==e.default&&s.push("DEFAULT",e.default)),s.join(" ")}function S(e){let t=e.labels.map(e=>`'${e.replace(/'/g,"''")}'`).join(", ");return`CREATE TYPE ${v(e)} AS ENUM (${t});`}function I(e){var t,n;let s,a,r;if("view"===e.kind||"materialized view"===e.kind)return R(e);let l=[...e.columns.map(t=>A(t,e.name)),...e.constraints.filter(e=>!j(e.sql)).map(e=>`CONSTRAINT ${T(e.name)} ${e.sql}`)],i=(s=(t=e).unlogged?"UNLOGGED ":"",a=v(t),"foreign table"===t.kind?`CREATE FOREIGN TABLE ${a}`:t.partitionOf?`CREATE ${s}TABLE ${a} PARTITION OF ${k(t.partitionOf.parent)}`:`CREATE ${s}TABLE ${a}`),o=(r=[],(n=e).partitionOf&&r.push(` ${n.partitionOf.bound}`),n.partitionBy&&r.push(` PARTITION BY ${n.partitionBy}`),r.join(""));if(e.partitionOf||0===l.length)return`${i}${o};`;let u=l.map(e=>` ${e}`).join(",\n");return`${i} (
|
|
2
|
+
${u}
|
|
3
|
+
)${o};`}function R(e){let t="materialized view"===e.kind?"MATERIALIZED VIEW":"VIEW",n=e.viewSql?.trim()??"SELECT NULL";return`CREATE ${t} ${v(e)} AS
|
|
4
|
+
${n};`}function L(e,t){return w(e)===w(t)}function w(e){return(e??"").replace(/\s+/g," ").trim()}let O={extension:0,schema:1,enum:2,relation:3,function:4};function C(e,t,n){let s=new Map;for(let t of e)s.set(n(t),{key:n(t),source:t});for(let e of t){let t=s.get(n(e));t?t.target=e:s.set(n(e),{key:n(e),target:e})}return[...s.values()].sort((e,t)=>e.key.localeCompare(t.key))}function D(e,t,n){return{id:`${e}:value:${t}`,group:"value",name:t,status:n,source:"added"===n?t:null,target:"removed"===n?t:null}}function F(e,t,n,s){return C(n,s,e=>e.name).flatMap(n=>n.source&&n.target&&L(n.source.sql,n.target.sql)?[]:[{id:`${e}:${t}:${n.key}`,group:t,name:n.key,status:z(n),source:n.source?.sql??null,target:n.target?.sql??null}])}function M(e,t,n,s){return{id:`${e}:property:${t}`,group:"property",name:t,status:"modified",source:n,target:s}}function z(e){return e.source&&e.target?"modified":e.source?"added":"removed"}let q=[{id:"extension",title:"Extensions"},{id:"schema",title:"Schemas"},{id:"enum",title:"Types"},{id:"table",title:"New tables"},{id:"constraint",title:"Foreign keys"},{id:"alter",title:"Table changes"},{id:"view",title:"Views"},{id:"function",title:"Functions"},{id:"trigger",title:"Triggers"}];function P(e){return[`-- ${e.title}`,...e.lines].join("\n")}function B(e){let t=e.trim();return t.endsWith(";")?t:`${t};`}var U=n(40544),X=n(40980);let Y={extension:"Extensions",schema:"Schemas",enum:"Types",relation:"Tables & views",function:"Functions"},G={added:"+",removed:"−",modified:"~"},V={added:"bg-emerald-500/15 text-emerald-700 dark:text-emerald-400",removed:"bg-rose-500/15 text-rose-700 dark:text-rose-400",modified:"bg-amber-500/15 text-amber-700 dark:text-amber-400"},W={column:["column","columns"],constraint:["constraint","constraints"],index:["index","indexes"],trigger:["trigger","triggers"],definition:["body","body"],property:["property","properties"],value:["value","values"]};function _({objects:e,sourceName:t,targetName:n,expanded:a,onToggle:r,tableHref:l}){let i=function(e){let t=new Map;for(let n of e)t.set(n.category,[...t.get(n.category)??[],n]);return[...t.entries()]}(e);return(0,s.jsx)("div",{className:"pb-6",children:i.map(([e,i])=>(0,s.jsxs)("section",{children:[(0,s.jsxs)("h2",{className:"sticky top-0 z-10 flex items-center gap-2 border-b bg-background/95 px-4 py-1.5 text-xs font-medium text-muted-foreground backdrop-blur",children:[Y[e],(0,s.jsx)("span",{className:"tabular-nums opacity-60",children:i.length})]}),(0,s.jsx)("ul",{children:i.map(e=>(0,s.jsx)(H,{object:e,sourceName:t,targetName:n,open:a.includes(e.id),onToggle:()=>r(e.id),href:l(e)},e.id))})]},e))})}function H({object:e,sourceName:t,targetName:n,open:a,onToggle:l,href:i}){var u,c,d;let m=0===e.details.length?function(e){switch(e.category){case"relation":{let t=e.source??e.target;return t?I(t):null}case"enum":{let t=e.source??e.target;return t?S(t):null}case"function":{let t=e.source??e.target;return t?t.sql:null}case"extension":{let t=e.source??e.target;return t?`CREATE EXTENSION IF NOT EXISTS ${T(t.name)} WITH SCHEMA ${T(t.schema)};`:null}case"schema":return`CREATE SCHEMA ${T(e.name)};`;default:return e}}(e):null;return(0,s.jsxs)("li",{className:"group/diff-row border-b border-border/40 last:border-b-0",children:[(0,s.jsxs)("div",{className:"relative flex items-center",children:[(0,s.jsxs)("button",{type:"button","aria-expanded":a,onClick:l,className:"flex min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left outline-none hover:bg-muted/50 focus-visible:bg-muted/60",children:[(0,s.jsx)(o.nNJ,{className:(0,X.cn)("size-3.5 shrink-0 text-muted-foreground transition-transform",a&&"rotate-90")}),(0,s.jsx)("span",{"aria-hidden":!0,className:(0,X.cn)("flex size-4 shrink-0 items-center justify-center rounded-[4px] font-mono text-[11px] leading-none",V[e.status]),children:G[e.status]}),(0,s.jsx)("span",{className:"min-w-0 truncate font-mono text-[13px]",children:e.label}),(0,s.jsx)("span",{className:"ml-auto shrink-0 truncate pl-3 text-xs text-muted-foreground",children:(u=e,c=t,d=n,"added"===u.status?`Only in ${c}${Z(u)}`:"removed"===u.status?`Only in ${d}${Z(u)}`:function(e){let t=new Map;for(let n of e)t.set(n.group,(t.get(n.group)??0)+1);return[...t.entries()].map(([e,t])=>{let[n,s]=W[e];return`${t} ${1===t?n:s}`}).join(" \xb7 ")}(u.details))})]}),i?(0,s.jsx)(r(),{href:i,title:"Open this table","aria-label":`Open ${e.label}`,className:"mr-1.5 flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground opacity-0 outline-none hover:bg-muted hover:text-foreground focus-visible:opacity-100 group-hover/diff-row:opacity-100",children:(0,s.jsx)(o.qM8,{className:"size-3.5"})}):(0,s.jsx)("span",{className:"w-1.5 shrink-0"})]}),a?(0,s.jsx)("div",{className:"border-t border-border/40 bg-muted/25 py-1",children:m?(0,s.jsx)(h.os,{sql:m,className:"px-4 py-1.5"}):e.details.map(e=>(0,s.jsx)(Q,{detail:e},e.id))}):null]})}function Q({detail:e}){return(0,s.jsxs)("div",{className:"grid grid-cols-[6.5rem_minmax(0,1fr)] items-start gap-2 px-4 py-1",children:[(0,s.jsx)("span",{className:"truncate pt-0.5 text-[11px] text-muted-foreground",title:e.name,children:W[e.group][0]}),(0,s.jsxs)("div",{className:"min-w-0 font-mono text-xs leading-5",children:[null!==e.target?(0,s.jsxs)("div",{className:"text-rose-700 dark:text-rose-400",children:[(0,s.jsx)("span",{className:"select-none opacity-60",children:"− "}),(0,s.jsx)("span",{className:"break-all whitespace-pre-wrap",children:e.target})]}):null,null!==e.source?(0,s.jsxs)("div",{className:"text-emerald-700 dark:text-emerald-400",children:[(0,s.jsx)("span",{className:"select-none opacity-60",children:"+ "}),(0,s.jsx)("span",{className:"break-all whitespace-pre-wrap",children:e.source})]}):null]})]})}function Z(e){let t="relation"===e.category?e.source??e.target:null;if(t){let e=t.columns.length;return` \xb7 ${e} column${1===e?"":"s"}`}let n="enum"===e.category?e.source??e.target:null;return n?` \xb7 ${n.labels.length} values`:""}function J(){let e=(0,l.useRouter)(),{connection:t}=(0,c.k)(),{target:n,candidates:a,partnerIds:r,setTarget:f}=(0,U.y3)(t.id),[k,y]=(0,i.useState)("changes"),[w,Y]=(0,i.useState)(""),[G,V]=(0,i.useState)(null),[W,H]=(0,i.useState)(!1),[Q,Z]=(0,i.useState)([]),J=(0,E.Y)(`${t.url}:schema`,e=>N.F.schema(t.url,e)),en=n?.url,es=(0,E.Y)(en?`${en}:schema`:"no-target",e=>en?N.F.schema(en,e):Promise.resolve(null)),ea=(0,i.useMemo)(()=>J.data&&es.data?function(e,t){var n,s,a,r,l,i;let o=[...(n=e.extensions,C(n,t.extensions,e=>e.name).flatMap(e=>{let t=[];return e.source&&e.target&&(e.source.version!==e.target.version&&t.push({id:`${e.key}:version`,group:"property",name:"version",status:"modified",source:e.source.version,target:e.target.version}),e.source.schema!==e.target.schema&&t.push({id:`${e.key}:schema`,group:"property",name:"schema",status:"modified",source:e.source.schema,target:e.target.schema}),0===t.length)?[]:[{id:`extension:${e.key}`,category:"extension",schema:null,name:e.key,label:e.key,status:z(e),details:t,source:e.source,target:e.target}]})),...(s=e.schemas,a=t.schemas,C(s.map(e=>({name:e})),a.map(e=>({name:e})),e=>e.name).flatMap(e=>e.source&&e.target?[]:[{id:`schema:${e.key}`,category:"schema",schema:e.key,name:e.key,label:e.key,status:z(e),details:[]}])),...(r=e.enums,C(r,t.enums,e=>`${e.schema}.${e.name}`).flatMap(e=>{let t=[];if(e.source&&e.target){for(let n of e.source.labels)e.target.labels.includes(n)||t.push(D(e.key,n,"added"));for(let n of e.target.labels)e.source.labels.includes(n)||t.push(D(e.key,n,"removed"));if(0===t.length)return[]}let n=e.source??e.target;return n?[{id:`enum:${e.key}`,category:"enum",schema:n.schema,name:n.name,label:e.key,status:z(e),details:t,source:e.source,target:e.target}]:[]})),...(l=e.relations,C(l,t.relations,e=>`${e.schema}.${e.name}`).flatMap(e=>{let t=e.source&&e.target?function(e,t){let n=`${e.schema}.${e.name}`,s=[];for(let a of(e.kind!==t.kind&&s.push(M(n,"kind",e.kind,t.kind)),e.unlogged!==t.unlogged&&s.push(M(n,"persistence",e.unlogged?"unlogged":"logged",t.unlogged?"unlogged":"logged")),(e.partitionBy??"")!==(t.partitionBy??"")&&s.push(M(n,"partition by",e.partitionBy??"none",t.partitionBy??"none")),L(e.viewSql,t.viewSql)||s.push({id:`${n}:definition`,group:"definition",name:"materialized view"===e.kind?"materialized view body":"view body",status:"modified",source:e.viewSql??null,target:t.viewSql??null}),C(e.columns,t.columns,e=>e.name))){let r=function(e,t,n,s){let a=t.source?A(t.source,n):null,r=t.target?A(t.target,s):null;return null!==a&&null!==r&&a===r?null:{id:`${e}:column:${t.key}`,group:"column",name:t.key,status:z(t),source:a,target:r}}(n,a,e.name,t.name);r&&s.push(r)}return s.push(...F(n,"constraint",e.constraints,t.constraints)),s.push(...F(n,"index",e.indexes,t.indexes)),s.push(...F(n,"trigger",e.triggers,t.triggers)),s}(e.source,e.target):[];if(e.source&&e.target&&0===t.length)return[];let n=e.source??e.target;return n?[{id:`relation:${e.key}`,category:"relation",kind:n.kind,schema:n.schema,name:n.name,label:e.key,status:z(e),details:t,source:e.source,target:e.target}]:[]})),...(i=e.functions,C(i,t.functions,e=>`${e.schema}.${e.name}(${e.args})`).flatMap(e=>{let t=[];if(e.source&&e.target){if(L(e.source.sql,e.target.sql))return[];t.push({id:`${e.key}:definition`,group:"definition",name:"body",status:"modified",source:e.source.sql,target:e.target.sql})}let n=e.source??e.target;return n?[{id:`function:${e.key}`,category:"function",schema:n.schema,name:`${n.name}(${n.args})`,label:e.key,status:z(e),details:t,source:e.source,target:e.target}]:[]}))];o.sort((e,t)=>O[e.category]-O[t.category]||(e.schema??"").localeCompare(t.schema??"")||e.name.localeCompare(t.name));let u={added:0,removed:0,modified:0,total:o.length};for(let e of o)u[e.status]+=1;return{objects:o,counts:u}}(J.data,es.data):null,[J.data,es.data]),er=(0,i.useMemo)(()=>ea?function(e){let t=new Set;for(let n of e.objects)n.schema&&t.add(n.schema);return[...t].sort((e,t)=>e.localeCompare(t))}(ea):[],[ea]),el=(0,i.useMemo)(()=>ea?function(e,{search:t,schemas:n}){let s=t.trim().toLocaleLowerCase();return e.objects.filter(e=>(null===n||null===e.schema||!!n.includes(e.schema))&&(!!(!s||e.label.toLocaleLowerCase().includes(s))||e.details.some(e=>e.name.toLocaleLowerCase().includes(s))))}(ea,{search:w,schemas:G}):[],[ea,w,G]),ei=(0,i.useMemo)(()=>ea?function(e,t){let n={blocks:[],drops:[],manual:0};for(let s of e.objects)!function(e,t,n){switch(e.category){case"extension":return function(e,t,n){if("added"===e.status)return t.blocks.push({bucket:"extension",title:`${e.name} — only in ${n.sourceName}`,lines:[`CREATE EXTENSION IF NOT EXISTS ${T(e.name)};`]});if("removed"===e.status)return t.drops.push({bucket:"extension",title:e.name,lines:[`DROP EXTENSION IF EXISTS ${T(e.name)};`]});let s=e.details.find(e=>"version"===e.name);s?.source&&t.blocks.push({bucket:"extension",title:`${e.name} — ${s.target} → ${s.source}`,lines:[`ALTER EXTENSION ${T(e.name)} UPDATE TO '${s.source}';`]})}(e,t,n);case"schema":var s,a;return s=e,a=t,"added"===s.status?a.blocks.push({bucket:"schema",title:s.name,lines:[`CREATE SCHEMA IF NOT EXISTS ${T(s.name)};`]}):"removed"===s.status&&a.drops.push({bucket:"schema",title:s.name,lines:[`DROP SCHEMA IF EXISTS ${T(s.name)};`]});case"enum":return function(e,t,n){if("added"===e.status&&e.source)return t.blocks.push({bucket:"enum",title:`${e.label} — only in ${n.sourceName}`,lines:[S(e.source)]});if("removed"===e.status&&e.target)return t.drops.push({bucket:"enum",title:e.label,lines:[`DROP TYPE IF EXISTS ${v(e.target)};`]});let s=[],a=e.source??e.target;if(a){for(let r of e.details)"added"===r.status?s.push(`ALTER TYPE ${v(a)} ADD VALUE IF NOT EXISTS '${r.name.replace(/'/g,"''")}';`):(t.manual+=1,s.push(`-- '${r.name}' exists only in ${n.targetName}; removing an enum value means recreating the type.`));s.length>0&&t.blocks.push({bucket:"enum",title:e.label,lines:s})}}(e,t,n);case"relation":return function(e,t,n){if("added"===e.status&&e.source)return function(e,t,n){let s="view"===e.kind||"materialized view"===e.kind;t.blocks.push({bucket:s?"view":"table",title:`${e.schema}.${e.name} — only in ${n.sourceName}`,lines:[I(e),...e.indexes.map(e=>B(e.sql))]});let a=e.constraints.filter(e=>j(e.sql));a.length>0&&t.blocks.push({bucket:"constraint",title:`${e.schema}.${e.name}`,lines:a.map(t=>`ALTER TABLE ${v(e)} ADD CONSTRAINT ${T(t.name)} ${t.sql};`)}),e.triggers.length>0&&t.blocks.push({bucket:"trigger",title:`${e.schema}.${e.name}`,lines:e.triggers.map(e=>B(e.sql))})}(e.source,t,n);if("removed"===e.status&&e.target)return function(e,t){let n="materialized view"===e.kind?"MATERIALIZED VIEW":"view"===e.kind?"VIEW":"foreign table"===e.kind?"FOREIGN TABLE":"TABLE";t.drops.push({bucket:"table",title:`${e.schema}.${e.name}`,lines:[`DROP ${n} IF EXISTS ${v(e)};`]})}(e.target,t);let s=e.source,a=e.target;if(!s||!a)return;if(s.kind!==a.kind){t.manual+=1,t.blocks.push({bucket:"alter",title:e.label,lines:[`-- ${e.label} is a ${a.kind} in ${n.targetName} and a ${s.kind} in ${n.sourceName}; recreate it by hand.`]});return}if("view"===s.kind||"materialized view"===s.kind)return function(e,t,n,s){if("view"===t.kind){let s;return n.blocks.push({bucket:"view",title:e,lines:[(s=t.viewSql?.trim()??"SELECT NULL",`CREATE OR REPLACE VIEW ${v(t)} AS
|
|
5
|
+
${s};`)]})}s.includeDrops?n.blocks.push({bucket:"view",title:`${e} — recreated, which discards its stored rows`,lines:[`DROP MATERIALIZED VIEW IF EXISTS ${v(t)};`,R(t)]}):(n.manual+=1,n.blocks.push({bucket:"view",title:e,lines:["-- The materialized view differs. Recreating it discards its stored rows,",'-- so turn on "Include drops" to generate the DROP and CREATE.']}))}(e.label,s,t,n);let r=v(s),l=[],i=[],o=[],u=[],c=[],d=[],m=[];for(let n of e.details){let e=s.columns.find(e=>e.name===n.name),h=a.columns.find(e=>e.name===n.name);switch(n.group){case"column":if("added"===n.status&&e)l.push(`ALTER TABLE ${r} ADD COLUMN ${A(e,s.name)};`);else if("removed"===n.status)m.push(`ALTER TABLE ${r} DROP COLUMN IF EXISTS ${T(n.name)};`);else if(e&&h){let n=function(e,t,n){let s=T(t.name),a=[],r=0;if(t.generated!==n.generated)return r+=1,a.push(`-- ${t.name}: a generated column cannot be altered in place; drop and re-add it.`),{lines:a,manual:r};if(t.type!==n.type||t.collation!==n.collation){let n=t.collation?` COLLATE ${T(t.collation)}`:"";a.push(`ALTER TABLE ${e} ALTER COLUMN ${s} TYPE ${t.type}${n} USING ${s}::${t.type};`)}return t.nullable!==n.nullable&&a.push(`ALTER TABLE ${e} ALTER COLUMN ${s} ${t.nullable?"DROP":"SET"} NOT NULL;`),t.identity!==n.identity&&(null===t.identity?a.push(`ALTER TABLE ${e} ALTER COLUMN ${s} DROP IDENTITY IF EXISTS;`):null===n.identity?a.push(`ALTER TABLE ${e} ALTER COLUMN ${s} ADD GENERATED ${t.identity} AS IDENTITY;`):a.push(`ALTER TABLE ${e} ALTER COLUMN ${s} SET GENERATED ${t.identity};`)),t.default!==n.default&&a.push(null===t.default?`ALTER TABLE ${e} ALTER COLUMN ${s} DROP DEFAULT;`:`ALTER TABLE ${e} ALTER COLUMN ${s} SET DEFAULT ${t.default};`),{lines:a,manual:r}}(r,e,h);t.manual+=n.manual,l.push(...n.lines)}break;case"constraint":"removed"===n.status?d.push(`ALTER TABLE ${r} DROP CONSTRAINT IF EXISTS ${T(n.name)};`):("modified"===n.status&&l.push(`ALTER TABLE ${r} DROP CONSTRAINT IF EXISTS ${T(n.name)};`),l.push(`ALTER TABLE ${r} ADD CONSTRAINT ${T(n.name)} ${n.source};`));break;case"index":"removed"===n.status?c.push(`DROP INDEX IF EXISTS ${T(s.schema)}.${T(n.name)};`):("modified"===n.status&&i.push(`DROP INDEX IF EXISTS ${T(s.schema)}.${T(n.name)};`),i.push(B(n.source??"")));break;case"trigger":"removed"===n.status?u.push(`DROP TRIGGER IF EXISTS ${T(n.name)} ON ${r};`):("modified"===n.status&&o.push(`DROP TRIGGER IF EXISTS ${T(n.name)} ON ${r};`),o.push(B(n.source??"")));break;default:t.manual+=1,l.push(`-- ${n.name}: ${n.target??"none"} → ${n.source??"none"} (change it by hand).`)}}(l.length>0||i.length>0)&&t.blocks.push({bucket:"alter",title:e.label,lines:[...l,...i]}),o.length>0&&t.blocks.push({bucket:"trigger",title:e.label,lines:o});let h=[...u,...c,...d,...m];h.length>0&&t.drops.push({bucket:"alter",title:e.label,lines:h})}(e,t,n);case"function":return function(e,t){if("removed"===e.status&&e.target){var n;let s="procedure"===e.target.kind?"PROCEDURE":"FUNCTION";t.drops.push({bucket:"function",title:e.label,lines:[`DROP ${s} IF EXISTS ${(n=e.target,`${v(n)}(${n.args})`)};`]});return}e.source&&t.blocks.push({bucket:"function",title:e.label,lines:[B(e.source.sql)]})}(e,t);default:return}}(s,n,t);let s=[];for(let e of q){let t=n.blocks.filter(t=>t.bucket===e.id);0!==t.length&&s.push([`-- ${e.title}`,...t.map(P)].join("\n\n"))}if(n.drops.length>0)if(t.includeDrops)s.push([`-- Drops — objects only in ${t.targetName}`,...n.drops.map(P)].join("\n\n"));else{let e=n.drops.length;s.push(`-- ${e} object${1===e?"":"s"} exist only in ${t.targetName}.
|
|
6
|
+
-- Turn on "Include drops" to generate the DROP statements for them.`)}let a=s.join("\n\n"),r=a.split("\n").filter(e=>!e.trimStart().startsWith("--")).join("\n").split(";").filter(e=>e.trim().length>0).length,l=["-- Schema migration generated by YTDB",`-- Apply to ${t.targetName} so it matches ${t.sourceName}`,0===r?"-- Nothing to apply":`-- ${r} statement${1===r?"":"s"} — review before running`].join("\n");return{sql:a?`${l}
|
|
7
|
+
|
|
8
|
+
${a}
|
|
9
|
+
`:`${l}
|
|
10
|
+
`,statements:r,manual:n.manual}}(ea,{sourceName:t.name,targetName:n?.name??"the other database",includeDrops:W}):null,[ea,t.name,n?.name,W]);if(0===a.length||!n)return(0,s.jsx)(et,{});let eo=J.loading||es.loading,eu=J.error?`${t.name}: ${J.error}`:es.error?`${n.name}: ${es.error}`:null,ec=el.length>0&&el.every(e=>Q.includes(e.id));return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(d.X,{children:[(0,s.jsx)(u.F,{connection:t}),(0,s.jsx)("span",{className:"max-w-40 truncate font-medium",children:t.name}),(0,s.jsx)(o.juJ,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,s.jsx)(K,{target:n,candidates:a,partnerIds:r,onSelect:f}),(0,s.jsx)(g.$,{variant:"ghost",size:"icon-sm",title:`Compare ${n.name} against ${t.name} instead`,"aria-label":"Swap comparison direction",onClick:function(){n&&(U.lz.getState().setCompareTarget(n.id,t.id),e.push(`/${encodeURIComponent(n.id)}/diff`))},children:(0,s.jsx)(o.vhS,{})}),(0,s.jsx)(g.$,{variant:"ghost",size:"icon-sm",className:"ml-auto",disabled:eo,"aria-label":"Refresh",title:"Re-read both schemas",onClick:()=>{J.reload(),es.reload()},children:(0,s.jsx)(o.oS8,{className:(0,X.cn)(eo&&"animate-spin")})})]}),"changes"===k?(0,s.jsxs)("div",{className:"flex items-center gap-1 border-b px-2 py-1",children:[(0,s.jsx)($.L,{value:w,onChange:e=>Y(e.target.value),placeholder:"Filter differences","aria-label":"Filter differences",className:"min-w-0 flex-1",trailing:(0,s.jsx)(m.V,{compact:!0,schemas:er,selected:G,onChange:V})}),(0,s.jsx)(g.$,{variant:"ghost",size:"sm",className:"text-muted-foreground",disabled:0===el.length,onClick:()=>Z(ec?[]:el.map(e=>e.id)),children:ec?"Collapse all":"Expand all"})]}):null,(0,s.jsx)("div",{className:"relative flex min-h-0 flex-1 flex-col",children:eu?(0,s.jsx)("p",{className:"flex-1 px-4 py-6 font-mono text-xs text-destructive",children:eu}):ea?"sql"===k?(0,s.jsx)(h.iX,{sql:ei?.sql,error:null,loading:eo,actions:(0,s.jsxs)(g.$,{variant:W?"secondary":"ghost",size:"sm","aria-pressed":W,title:`DROP statements for objects that exist only in ${n.name}`,onClick:()=>H(e=>!e),children:[(0,s.jsx)(o.mYx,{"data-icon":"inline-start"}),"Include drops"]})}):0===ea.counts.total?(0,s.jsx)(ee,{sourceName:t.name,targetName:n.name}):0===el.length?(0,s.jsx)("p",{className:"flex-1 px-4 py-6 text-sm text-muted-foreground",children:"No differences match this filter."}):(0,s.jsx)(x.F,{className:(0,X.cn)("min-h-0 flex-1",eo&&"opacity-60"),children:(0,s.jsx)(_,{objects:el,sourceName:t.name,targetName:n.name,expanded:Q,onToggle:function(e){Z(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},tableHref:function(e){if("relation"!==e.category||!e.schema)return null;let s="removed"===e.status?n:t;if(!s)return null;let a=e.name;return`/${encodeURIComponent(s.id)}/${encodeURIComponent(e.schema)}/${encodeURIComponent(a)}`}})}):(0,s.jsx)("div",{className:"flex flex-col gap-2 p-4",children:Array.from({length:10},(e,t)=>(0,s.jsx)(b.E,{className:"h-6 w-full"},t))})}),(0,s.jsxs)("div",{className:"flex items-center gap-2 border-t px-4 py-1.5 text-xs text-muted-foreground",children:[(0,s.jsx)("span",{className:"min-w-0 truncate",children:"sql"===k?function(e){if(!e)return"Reading both schemas…";if(0===e.statements)return"Nothing to apply";let t=e.manual>0?` \xb7 ${e.manual} change${1===e.manual?"":"s"} need editing by hand`:"";return`${e.statements} statement${1===e.statements?"":"s"}${t}`}(ei):function(e,t,n,s){if(!e)return"Reading both schemas…";if(0===e.counts.total)return"No differences";let a=[`${e.counts.added} only in ${n}`,`${e.counts.removed} only in ${s}`,`${e.counts.modified} changed`],r=t===e.counts.total?"":` \xb7 showing ${t}`;return`${e.counts.total} differences \xb7 ${a.join(" \xb7 ")}${r}`}(ea,el.length,t.name,n.name)}),(0,s.jsx)("div",{className:"ml-auto",children:(0,s.jsx)(p.x,{label:"Comparison pane",value:k,onChange:y,options:[{value:"changes",label:"Changes"},{value:"sql",label:"Migration SQL"}]})})]})]})}function K({target:e,candidates:t,partnerIds:n,onSelect:a}){return(0,s.jsxs)(f.rI,{children:[(0,s.jsxs)(f.ty,{className:"flex h-8 min-w-0 items-center 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,s.jsx)(u.F,{connection:e}),(0,s.jsx)("span",{className:"max-w-40 truncate",children:e.name}),t.length>1&&(0,s.jsx)(o.klM,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),(0,s.jsx)(f.SQ,{align:"start",className:"min-w-52",children:t.map(t=>(0,s.jsxs)(f._2,{onClick:()=>a(t.id),className:t.id===e.id?"font-medium":void 0,children:[(0,s.jsx)(u.F,{connection:t}),(0,s.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t.name}),n.includes(t.id)&&(0,s.jsx)(o.WnQ,{className:"size-3.5 shrink-0 text-muted-foreground"})]},t.id))})]})}function ee({sourceName:e,targetName:t}){return(0,s.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 text-muted-foreground",children:[(0,s.jsx)(o.Ykz,{className:"size-5 text-emerald-600 dark:text-emerald-400"}),(0,s.jsxs)("p",{className:"text-sm",children:[e," and ",t," have the same schema"]})]})}function et(){return(0,s.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center text-muted-foreground",children:[(0,s.jsx)("p",{className:"text-sm",children:"Comparing needs a second connection."}),(0,s.jsx)(r(),{href:"/",className:"text-foreground underline underline-offset-4",children:"Add one"})]})}},7412:(e,t,n)=>{"use strict";n.d(t,{L:()=>l});var s=n(95155),a=n(13267),r=n(40980);function l({trailing:e,className:t,...n}){return(0,s.jsxs)("div",{className:(0,r.cn)("flex h-8 items-center gap-1.5 rounded-lg px-2 text-muted-foreground transition-colors focus-within:bg-muted/60 hover:bg-muted/60",t),children:[(0,s.jsx)(a.TfF,{className:"size-3.5 shrink-0"}),(0,s.jsx)("input",{type:"text",spellCheck:!1,autoComplete:"off",...n,className:"h-full min-w-0 flex-1 bg-transparent text-[0.8rem] text-foreground outline-none placeholder:text-muted-foreground"}),e]})}},19645:(e,t,n)=>{Promise.resolve().then(n.bind(n,6044))},23716:(e,t,n)=>{"use strict";n.d(t,{V:()=>i});var s=n(95155),a=n(13267),r=n(72264),l=n(40980);function i({schemas:e,selected:t,onChange:n,compact:o=!1}){let u=null===t||t.length===e.length,c=null===t||t.length===e.length?"All schemas":0===t.length?"No schemas":1===t.length?t[0]:`${t.length} of ${e.length} schemas`;return(0,s.jsxs)(r.rI,{children:[o?(0,s.jsxs)(r.ty,{"aria-label":`Schemas: ${c}`,title:c,className:(0,l.cn)("flex h-6 shrink-0 cursor-pointer items-center gap-1 rounded-md px-1 text-[11px] tabular-nums outline-none transition-colors hover:bg-foreground/10 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60 data-open:bg-foreground/10 data-open:text-foreground",u?"text-muted-foreground":"text-foreground"),children:[(0,s.jsx)(a.olY,{className:"size-3.5"}),!u&&(0,s.jsx)("span",{children:t.length})]}):(0,s.jsxs)(r.ty,{className:"group flex h-8 w-full cursor-pointer items-center gap-2 rounded-lg px-2 text-left text-[0.8rem] outline-none transition-colors hover:bg-muted/60 focus-visible:ring-2 focus-visible:ring-ring/60 data-open:bg-muted/60",children:[(0,s.jsx)(a.olY,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,s.jsx)("span",{className:"min-w-0 flex-1 truncate",children:c}),(0,s.jsx)(a.RQe,{className:"size-3.5 shrink-0 text-muted-foreground transition-transform group-data-open:rotate-180"})]}),(0,s.jsx)(r.SQ,{align:o?"end":"start",sideOffset:6,className:(0,l.cn)("max-h-80 min-w-52",!o&&"w-(--anchor-width)"),children:(0,s.jsxs)(r.I,{children:[(0,s.jsx)(r.hO,{checked:u,onCheckedChange:e=>n(e?null:[]),children:"All schemas"}),(0,s.jsx)(r.mB,{}),e.map(a=>(0,s.jsx)(r.hO,{checked:u||(t?.includes(a)??!1),onCheckedChange:s=>{let r,l;return r=t??e,void n((l=s?[...new Set([...r,a])]:r.filter(e=>e!==a)).length===e.length?null:l)},children:(0,s.jsx)("span",{className:"truncate",children:a})},a))]})})]})}},35942:(e,t,n)=>{"use strict";n.d(t,{F:()=>c});var s=n(95155);n(12115);var a=n(76166),r=n(90839),l=n(84588),i=n(66784),o=n(64084),u=n(40980);function c({className:e,children:t,...n}){return(0,s.jsxs)(a.V,{"data-slot":"scroll-area",className:(0,u.cn)("relative",e),...n,children:[(0,s.jsx)(r.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:t}),(0,s.jsx)(d,{}),(0,s.jsx)(l.I,{})]})}function d({className:e,orientation:t="vertical",...n}){return(0,s.jsx)(i.V,{"data-slot":"scroll-area-scrollbar","data-orientation":t,orientation:t,className:(0,u.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",e),...n,children:(0,s.jsx)(o.l,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}},72194:(e,t,n)=>{"use strict";n.d(t,{F:()=>l});var s=n(95155),a=n(40980),r=n(32538);function l({connection:e,className:t}){return(0,s.jsx)("span",{"aria-hidden":!0,className:(0,a.cn)("size-2.5 shrink-0 rounded-full",t),style:{background:(0,r.Mq)(e)}})}}},e=>{e.O(0,[4506,1731,8026,2435,8322,544,6090,1413,8441,3794,7358],()=>e(e.s=19645)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7123],{7412:(e,t,n)=>{"use strict";n.d(t,{L:()=>s});var r=n(95155),a=n(13267),l=n(40980);function s({trailing:e,className:t,...n}){return(0,r.jsxs)("div",{className:(0,l.cn)("flex h-8 items-center gap-1.5 rounded-lg px-2 text-muted-foreground transition-colors focus-within:bg-muted/60 hover:bg-muted/60",t),children:[(0,r.jsx)(a.TfF,{className:"size-3.5 shrink-0"}),(0,r.jsx)("input",{type:"text",spellCheck:!1,autoComplete:"off",...n,className:"h-full min-w-0 flex-1 bg-transparent text-[0.8rem] text-foreground outline-none placeholder:text-muted-foreground"}),e]})}},12860:(e,t,n)=>{Promise.resolve().then(n.bind(n,37875))},15923:(e,t,n)=>{"use strict";n.d(t,{T:()=>a,r:()=>l});let r=new Set;function a(e){return r.add(e),()=>{r.delete(e)}}function l(){for(let e of r)e()}},19065:(e,t,n)=>{"use strict";function r(e,t){if(0===t)return!0;let n=e[t-1];return"_"===n||"-"===n||" "===n||"."===n}function a(e,t,n){return l(e,t,e=>[n(e)])}function l(e,t,n){if(!e.trim())return[];let a=[];for(let l of t){let t=n(l),s=null;for(let n of t){let t=function(e,t){let n=e.trim().toLocaleLowerCase(),a=t.toLocaleLowerCase();if(!n)return 0;if(0===a.length)return null;if(a===n)return 1e4;if(a.startsWith(n))return 5e3-a.length;let l=a.indexOf(n);if(-1!==l)return 2400+1200*!!r(t,l)-l-a.length;let s=0,o=0,i=0;for(let e=0;e<a.length&&s<n.length;e+=1){if(a[e]!==n[s]){i=0;continue}o+=12,(i+=1)>1&&(o+=18*i),r(t,e)&&(o+=40),s+=1}if(s<n.length)return null;let c=t.split(/[_\-\s.]+/).map(e=>e[0]??"").join("").toLocaleLowerCase();return c.startsWith(n)?o+=2200:c.includes(n)&&(o+=700),o-(a.length-n.length)}(e,n);null!==t&&(null===s||t>s)&&(s=t)}null!==s&&a.push({item:l,score:s})}return a.sort((e,t)=>t.score!==e.score?t.score-e.score:n(e.item)[0]?.localeCompare(n(t.item)[0]??"")??0)}n.d(t,{R6:()=>a,UO:()=>l})},23716:(e,t,n)=>{"use strict";n.d(t,{V:()=>o});var r=n(95155),a=n(13267),l=n(72264),s=n(40980);function o({schemas:e,selected:t,onChange:n,compact:i=!1}){let c=null===t||t.length===e.length,u=null===t||t.length===e.length?"All schemas":0===t.length?"No schemas":1===t.length?t[0]:`${t.length} of ${e.length} schemas`;return(0,r.jsxs)(l.rI,{children:[i?(0,r.jsxs)(l.ty,{"aria-label":`Schemas: ${u}`,title:u,className:(0,s.cn)("flex h-6 shrink-0 cursor-pointer items-center gap-1 rounded-md px-1 text-[11px] tabular-nums outline-none transition-colors hover:bg-foreground/10 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60 data-open:bg-foreground/10 data-open:text-foreground",c?"text-muted-foreground":"text-foreground"),children:[(0,r.jsx)(a.olY,{className:"size-3.5"}),!c&&(0,r.jsx)("span",{children:t.length})]}):(0,r.jsxs)(l.ty,{className:"group flex h-8 w-full cursor-pointer items-center gap-2 rounded-lg px-2 text-left text-[0.8rem] outline-none transition-colors hover:bg-muted/60 focus-visible:ring-2 focus-visible:ring-ring/60 data-open:bg-muted/60",children:[(0,r.jsx)(a.olY,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:u}),(0,r.jsx)(a.RQe,{className:"size-3.5 shrink-0 text-muted-foreground transition-transform group-data-open:rotate-180"})]}),(0,r.jsx)(l.SQ,{align:i?"end":"start",sideOffset:6,className:(0,s.cn)("max-h-80 min-w-52",!i&&"w-(--anchor-width)"),children:(0,r.jsxs)(l.I,{children:[(0,r.jsx)(l.hO,{checked:c,onCheckedChange:e=>n(e?null:[]),children:"All schemas"}),(0,r.jsx)(l.mB,{}),e.map(a=>(0,r.jsx)(l.hO,{checked:c||(t?.includes(a)??!1),onCheckedChange:r=>{let l,s;return l=t??e,void n((s=r?[...new Set([...l,a])]:l.filter(e=>e!==a)).length===e.length?null:s)},children:(0,r.jsx)("span",{className:"truncate",children:a})},a))]})})]})}},35942:(e,t,n)=>{"use strict";n.d(t,{F:()=>u});var r=n(95155);n(12115);var a=n(76166),l=n(90839),s=n(84588),o=n(66784),i=n(64084),c=n(40980);function u({className:e,children:t,...n}){return(0,r.jsxs)(a.V,{"data-slot":"scroll-area",className:(0,c.cn)("relative",e),...n,children:[(0,r.jsx)(l.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:t}),(0,r.jsx)(d,{}),(0,r.jsx)(s.I,{})]})}function d({className:e,orientation:t="vertical",...n}){return(0,r.jsx)(o.V,{"data-slot":"scroll-area-scrollbar","data-orientation":t,orientation:t,className:(0,c.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",e),...n,children:(0,r.jsx)(i.l,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}},37875:(e,t,n)=>{"use strict";n.d(t,{ExplorerShell:()=>ea});var r=n(95155),a=n(98500),l=n.n(a),s=n(13267),o=n(89239),i=n(95377),c=n(69586),u=n(74590),d=n(32538),m=n(36331),f=n(73321),h=n(12115),p=n(35942),x=n(7412),g=n(86846),b=n(43262),w=n(95848),v=n(40980),y=n(72264),j=n(72194),k=n(79781);function N({current:e}){let t=(0,c.Z)(e=>e.connections),n=(0,k.$C)();return(0,r.jsxs)(y.rI,{children:[(0,r.jsxs)(y.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,r.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,r.jsx)(j.F,{connection:e}),(0,r.jsx)("span",{className:"truncate",children:e.name}),e.layoutGroup&&(0,r.jsx)(s.WnQ,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),(0,r.jsx)(s.klM,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),(0,r.jsxs)(y.SQ,{align:"start",className:"w-(--anchor-width)",children:[t.map(t=>(0,r.jsxs)(y._2,{onClick:()=>void n(t.id),className:t.id===e.id?"font-medium":void 0,children:[(0,r.jsx)(j.F,{connection:t}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t.name}),t.layoutGroup&&t.layoutGroup===e.layoutGroup&&(0,r.jsx)(s.WnQ,{className:"size-3.5 shrink-0 text-muted-foreground"})]},t.id)),(0,r.jsx)(y.mB,{}),(0,r.jsx)(y._2,{render:(0,r.jsx)(l(),{href:"/"}),children:"Manage connections"})]})]})}var C=n(23716);function S(e,t){let n=e.trim(),r=n.lastIndexOf(".");return -1===r?n:"schema"===t?n.slice(0,r):n.slice(r+1)}function T({text:e,query:t}){if(!t)return e;let n=[],a=e.toLocaleLowerCase(),l=t.toLocaleLowerCase(),s=0,o=a.indexOf(l);if(-1===o)return e;for(;-1!==o;)o>s&&n.push(e.slice(s,o)),n.push((0,r.jsx)("mark",{className:"rounded-[3px] bg-yellow-300/90 px-px text-yellow-950 dark:bg-yellow-400/85 dark:text-yellow-950",children:e.slice(o,o+t.length)},o)),s=o+t.length,o=a.indexOf(l,s);return s<e.length&&n.push(e.slice(s)),n}function E({connectionId:e,table:t,search:n,pinned:a,showSchema:o,active:i,reorderable:c,dragging:u,dropEdge:d,onTogglePin:m,onDragStart:f,onDragOver:h,onDrop:p,onDragEnd:x,onMove:g}){return(0,r.jsxs)("li",{onDragOver:h,onDrop:p,className:(0,v.cn)("group/table-row relative flex h-7 items-center rounded-md text-[13px] transition-[color,background-color,opacity] hover:bg-muted/60",i&&"bg-muted text-foreground",!i&&"text-foreground/80",u&&"opacity-45","before"===d&&"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"===d&&"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:[c&&(0,r.jsx)("button",{type:"button",draggable:!0,"aria-label":`Reorder ${t.schema}.${t.name}`,title:"Drag to reorder; use Up and Down arrow keys",onDragStart:f,onDragEnd:x,onKeyDown:e=>{("ArrowUp"===e.key||"ArrowDown"===e.key)&&(e.preventDefault(),g?.("ArrowUp"===e.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,r.jsx)(s.Mvf,{className:"size-3.5"})}),(0,r.jsxs)(l(),{href:`/${e}/${encodeURIComponent(t.schema)}/${encodeURIComponent(t.name)}`,className:(0,v.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",c?"pl-1":"pl-6"),children:[(0,r.jsx)("span",{className:"truncate",children:(0,r.jsx)(T,{text:t.name,query:S(n,"table")})}),o?(0,r.jsx)("span",{className:"ml-auto max-w-20 truncate text-[10px] text-muted-foreground",children:t.schema}):"view"===t.kind&&(0,r.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"view"})]}),(0,r.jsx)("button",{type:"button","aria-label":`${a?"Unpin":"Pin"} ${t.schema}.${t.name}`,"aria-pressed":a,title:a?"Unpin table":"Pin table",onClick:()=>m(t),className:(0,v.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",a&&"text-foreground"),children:a?(0,r.jsx)(s.M0d,{className:"size-3.5"}):(0,r.jsx)(s.rq5,{className:"size-3.5"})})]})}function $({label:e,count:t,collapsed:n,pinned:a,search:l,onToggle:o}){return(0,r.jsxs)("button",{type:"button","aria-expanded":!n,onClick:o,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,r.jsx)(s.nNJ,{className:(0,v.cn)("size-3.5 transition-transform",!n&&"rotate-90")}),a&&(0,r.jsx)(s.M0d,{className:"mr-0.5 size-3"}),(0,r.jsx)("span",{className:"truncate",children:a?e:(0,r.jsx)(T,{text:e,query:S(l,"schema")})}),(0,r.jsx)("span",{className:"ml-auto pr-1 tabular-nums opacity-60",children:t})]})}function L({connectionId:e,tables:t,search:n,collapsedSchemas:a,pinnedTables:l,onToggleSchema:s,onTogglePin:o,onReorderPinned:i}){let c=(0,f.useParams)(),[u,d]=(0,h.useState)(!1),[m,p]=(0,h.useState)(null),[x,g]=(0,h.useState)(null),b=new Map(t.map(e=>[(0,w.i)(e),e])),v=l.flatMap(e=>{let t=b.get(e);return t?[t]:[]});function y(){p(null),g(null)}return 0===t.length?(0,r.jsx)("p",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:n.trim()?"No tables match your search":"No tables in these schemas"}):(0,r.jsxs)("div",{className:"flex flex-col gap-1 px-2 pb-4",children:[v.length>0&&(0,r.jsxs)("div",{className:"mb-1 border-b border-border/60 pb-1",children:[(0,r.jsx)($,{label:"Pinned tables",count:v.length,collapsed:u,pinned:!0,search:n,onToggle:()=>d(e=>!e)}),!u&&(0,r.jsx)("ul",{children:v.map(t=>{let a=(0,w.i)(t);return(0,r.jsx)(E,{connectionId:e,table:t,search:n,pinned:!0,showSchema:!0,active:c.schema===t.schema&&c.table===t.name,reorderable:!0,dragging:m===a,dropEdge:x?.key===a?x.edge:null,onTogglePin:o,onDragStart:e=>{e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",a),p(a),g(null)},onDragOver:e=>(function(e,t){if(!m||m===t)return;e.preventDefault(),e.dataTransfer.dropEffect="move";let n=e.currentTarget.getBoundingClientRect(),r=e.clientY<n.top+n.height/2?"before":"after";g(e=>e?.key===t&&e.edge===r?e:{key:t,edge:r})})(e,a),onDrop:e=>{let t,n;return e.preventDefault(),t=m??e.dataTransfer.getData("text/plain"),n=x?.key===a?x.edge:"before",void(t&&i(t,a,n),y())},onDragEnd:y,onMove:e=>{let t,n;return t=v.findIndex(e=>(0,w.i)(e)===a),void((n=v[t+e])&&i(a,(0,w.i)(n),-1===e?"before":"after"))}},a)})})]}),(function(e){let t=new Map;for(let n of e)t.set(n.schema,[...t.get(n.schema)??[],n]);return[...t.entries()].sort(([e],[t])=>{let n;return((n=new Map([["public",0],["auth",1]])).get(e)??2)-(n.get(t)??2)||e.localeCompare(t)})})(t).map(([t,i])=>{let u=a.includes(t);return(0,r.jsxs)("div",{children:[(0,r.jsx)($,{label:t,count:i.length,collapsed:u,search:n,onToggle:()=>s(t)}),!u&&(0,r.jsx)("ul",{children:i.map(t=>(0,r.jsx)(E,{connectionId:e,table:t,search:n,pinned:l.includes((0,w.i)(t)),active:c.schema===t.schema&&c.table===t.name,onTogglePin:o},(0,w.i)(t)))})]},t)})]})}function z(e){return Math.min(480,Math.max(180,Math.round(e)))}function D(e,t){let n=new Map([["public",0],["auth",1]]);return(n.get(e)??2)-(n.get(t)??2)||e.localeCompare(t)}function R(e,t,n){let r=t.trim().toLocaleLowerCase();return e.filter(e=>(null===n||!!n.includes(e.schema))&&(!r||e.name.toLocaleLowerCase().includes(r)||`${e.schema}.${e.name}`.toLocaleLowerCase().includes(r)))}function I({href:e,active:t,shortcut:n,children:a}){return(0,r.jsxs)(l(),{href:e,"aria-current":t?"page":void 0,className:(0,v.cn)((0,o.r)({variant:t?"secondary":"ghost",size:"sm"}),"h-8 w-full justify-start px-2"),children:[a,(0,r.jsx)("kbd",{className:"ml-auto font-mono text-[10px] text-muted-foreground/55",children:n})]})}function A({width:e,onWidthChange:t,onCollapse:n}){let a=(0,f.usePathname)(),{connection:l,tables:i}=(0,m.k)(),[d,v]=(0,u.DE)(l.id),y=(0,c.Z)(e=>e.connections.length>1),[j,k]=(0,h.useState)(()=>z(e)),S=(0,h.useRef)(null),T=(0,h.useMemo)(()=>[...new Set((i.data??[]).map(e=>e.schema))].sort(D),[i.data]),E=(0,h.useMemo)(()=>null===d.selectedSchemas?null:d.selectedSchemas.filter(e=>T.includes(e)),[d.selectedSchemas,T]),$=(0,h.useMemo)(()=>R(i.data??[],d.search,E),[i.data,d.search,E]),M=`/${encodeURIComponent(l.id)}`,U=`${M}/query`,P=`${M}/diff`,F=`${M}/migrations`;function q(e,t){let n=new Set(R(i.data??[],e,t).map(e=>e.schema));return d.collapsedSchemas.filter(e=>!n.has(e))}return(0,r.jsxs)("aside",{id:"database-explorer-sidebar",style:{width:j},className:"relative flex h-full shrink-0 flex-col border-r bg-sidebar",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-0.5 border-b border-sidebar-border/60 p-2",children:[(0,r.jsxs)("div",{className:"mb-1 flex items-center gap-1",children:[(0,r.jsx)("div",{className:"min-w-0 flex-1",children:(0,r.jsx)(N,{current:l})}),(0,r.jsx)(o.$,{variant:"ghost",size:"icon-sm","aria-label":"Collapse database sidebar",title:"Collapse sidebar",onClick:n,children:(0,r.jsx)(s.cFu,{})})]}),(0,r.jsxs)(I,{href:U,active:a===U,shortcut:b.Ar.sqlEditor,children:[(0,r.jsx)(s.Uoo,{"data-icon":"inline-start"}),"SQL query"]}),(0,r.jsxs)(I,{href:F,active:a===F||a.startsWith(`${F}/`),shortcut:b.Ar.migrations,children:[(0,r.jsx)(s.olY,{"data-icon":"inline-start"}),"Migrations"]}),y&&(0,r.jsxs)(I,{href:P,active:a===P,shortcut:b.Ar.compareSchema,children:[(0,r.jsx)(s.R4X,{"data-icon":"inline-start"}),"Compare schema"]}),(0,r.jsx)(x.L,{value:d.search,onChange:e=>{var t;v({search:t=e.target.value,collapsedSchemas:t.trim()?q(t,E):d.collapsedSchemas})},placeholder:"Search tables","aria-label":"Search tables",className:"mt-1",trailing:(0,r.jsxs)(r.Fragment,{children:[!d.search&&(0,r.jsx)("kbd",{className:"font-mono text-[10px] text-muted-foreground/55",children:b.Ar.tableSearch}),(0,r.jsx)(C.V,{compact:!0,schemas:T,selected:E,onChange:function(e){v({selectedSchemas:e,collapsedSchemas:d.search.trim()?q(d.search,e):d.collapsedSchemas})}})]})})]}),(0,r.jsx)(p.F,{className:"min-h-0 flex-1 pt-1.5",children:i.error?(0,r.jsx)("p",{className:"px-3 py-4 text-xs text-destructive",children:i.error}):i.data?(0,r.jsx)(L,{connectionId:l.id,tables:$,search:d.search,collapsedSchemas:d.collapsedSchemas,pinnedTables:d.pinnedTables,onToggleSchema:function(e){v({collapsedSchemas:d.collapsedSchemas.includes(e)?d.collapsedSchemas.filter(t=>t!==e):[...d.collapsedSchemas,e]})},onTogglePin:function(e){let t=(0,w.i)(e);v({pinnedTables:d.pinnedTables.includes(t)?d.pinnedTables.filter(e=>e!==t):[...d.pinnedTables,t]})},onReorderPinned:function(e,t,n){if(e===t)return;let r=d.pinnedTables.filter(t=>t!==e),a=r.indexOf(t);-1!==a&&(r.splice(a+ +("after"===n),0,e),v({pinnedTables:r}))}}):(0,r.jsx)("div",{className:"flex flex-col gap-2 px-3 py-2",children:Array.from({length:8},(e,t)=>(0,r.jsx)(g.E,{className:"h-5 w-full"},t))})}),(0,r.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize database sidebar","aria-valuemin":180,"aria-valuemax":480,"aria-valuenow":j,tabIndex:0,title:"Drag to resize; double-click to reset",onPointerDown:function(e){e.preventDefault(),S.current={pointerId:e.pointerId,startX:e.clientX,startWidth:j},e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:function(e){let t=S.current;t&&t.pointerId===e.pointerId&&(e.preventDefault(),k(z(t.startWidth+e.clientX-t.startX)))},onPointerUp:function(e){let n=S.current;if(!n||n.pointerId!==e.pointerId)return;let r=z(n.startWidth+e.clientX-n.startX);S.current=null,k(r),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),t(r)},onPointerCancel:function(e){let n=S.current;n&&n.pointerId===e.pointerId&&(S.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),t(j))},onKeyDown:function(e){if("ArrowLeft"!==e.key&&"ArrowRight"!==e.key)return;e.preventDefault();let n=z(j+("ArrowLeft"===e.key?-1:1)*16);k(n),t(n)},onDoubleClick:function(e){e.preventDefault(),k(256),t(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 M=n(67385),U=n(88406),P=n(86989),F=n(15923),q=n(19065);function O(e,{nested:t=!1}={}){let n=(0,f.useRouter)(),r=(0,f.usePathname)(),{connection:a,tables:l}=(0,m.k)(),[s]=(0,u.DE)(a.id),o=`/${encodeURIComponent(a.id)}`,i=`${o}/${e}`,c=t?r===i||r.startsWith(`${i}/`):r===i;return{open:c,href:i,toggle:()=>n.push(c?function(){for(let e of s.recentTables){let t=(l.data??[]).find(t=>(0,w.i)(t)===e);if(t)return`${o}/${encodeURIComponent(t.schema)}/${encodeURIComponent(t.name)}`}return o}():i)}}function G(){let e=O("migrations",{nested:!0});return{open:e.open,migrationsHref:e.href,toggle:e.toggle}}var K=n(48861);function Z(){let e=O("diff");return{open:e.open,diffHref:e.href,toggle:e.toggle}}function W(){let e=O("query");return{open:e.open,queryHref:e.href,toggle:e.toggle}}function B({text:e,query:t}){if(!t)return e;let n=e.toLocaleLowerCase(),a=t.toLocaleLowerCase(),l=n.indexOf(a);return -1===l?e:(0,r.jsxs)(r.Fragment,{children:[e.slice(0,l),(0,r.jsx)("mark",{className:"rounded-[3px] bg-yellow-300/90 px-px text-yellow-950 dark:bg-yellow-400/85 dark:text-yellow-950",children:e.slice(l,l+t.length)}),e.slice(l+t.length)]})}async function Q(e){try{await navigator.clipboard.writeText(e)}catch{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select(),document.execCommand("copy"),t.remove()}}function _(){let e=(0,f.useRouter)(),t=(0,f.useParams)(),{connection:n,tables:a}=(0,m.k)(),l=W(),o=Z(),i=G(),d=(0,u.y3)(n.id),p=(0,k.yG)(),x=(0,K.Q)(n.id),g=(0,c.Z)(e=>e.add),[y,j]=(0,u.DE)(n.id),[N,C]=(0,h.useState)(!1),[S,T]=(0,h.useState)("commands"),[E,$]=(0,h.useState)(""),[L,z]=(0,h.useState)(0),[D,R]=(0,h.useState)(!1),I=(0,h.useRef)(null),A=(0,h.useRef)(null),O=(0,h.useRef)(null),_=(0,h.useRef)(S),X=(0,U.C)(e=>e.theme),V=t.schema&&t.table?{schema:decodeURIComponent(t.schema),name:decodeURIComponent(t.table)}:null,H=!!V&&y.pinnedTables.includes((0,w.i)(V)),Y=(0,u.lz)(e=>V?e.tables[`${n.id}:${(0,w.i)(V)}`]:void 0),J=(0,h.useMemo)(()=>[{id:"sql-editor",title:l.open?"Back to Table":"Open SQL Query",keywords:["new","query","sql","console","editor","close","back","table"],enabled:!0,shortcut:b.Ar.sqlEditor,run:()=>l.toggle()},{id:"go-back",title:x.back?`Back to ${x.back.label}`:"Back",keywords:["back","previous","return","history","undo"],enabled:null!==x.back,shortcut:b.Ar.back,run:()=>x.goBack()},{id:"go-forward",title:x.forward?`Forward to ${x.forward.label}`:"Forward",keywords:["forward","next","history","redo"],enabled:null!==x.forward,shortcut:b.Ar.forward,run:()=>x.goForward()},{id:"switch-connection",title:p.next?`Switch Connection (${p.next.name})`:"Switch Connection",keywords:["database","env","environment","next","cycle","other"],enabled:p.enabled,shortcut:b.Ar.switchConnection,run:()=>void p.run()},{id:"migrations",title:i.open?"Back to Table":"Open Migrations",keywords:["migration","migrate","apply","revert","rollback","ledger","schema","run"],enabled:!0,shortcut:b.Ar.migrations,run:()=>i.toggle()},{id:"compare-schema",title:d.target?`Compare Schema with ${d.target.name}`:"Compare Schema",keywords:["diff","difference","migration","drift","prod","dev","schema","compare"],enabled:null!==d.target,shortcut:b.Ar.compareSchema,run:()=>o.toggle()},{id:"search-tables",title:"Search Tables",keywords:["find","jump","open","goto","table"],enabled:!0,shortcut:b.Ar.tableSearch,run:()=>window.requestAnimationFrame(()=>(0,b.tT)())},{id:"search-columns",title:"Search Columns",keywords:["find","jump","goto","column","field"],enabled:null!==V,shortcut:b.Ar.columnSearch,run:()=>window.requestAnimationFrame(()=>(0,b.vI)())},{id:"reload-tables",title:"Reload Tables",keywords:["refresh","reload","tables","sync"],enabled:!0,run:()=>a.reload()},{id:"pin-table",title:H?"Unpin Table":"Pin Table",keywords:["pin","unpin","favorite","star"],enabled:null!==V,run:()=>{if(!V)return;let e=(0,w.i)(V);j({pinnedTables:y.pinnedTables.includes(e)?y.pinnedTables.filter(t=>t!==e):[...y.pinnedTables,e]})}},{id:"clear-filters",title:"Clear Filters",keywords:["filter","reset","remove"],enabled:null!==V,run:()=>{V&&u.lz.getState().setTable(n.id,V,{filters:[],page:0})}},{id:"clear-search",title:"Clear Search",keywords:["find","search","reset"],enabled:null!==V&&!!Y?.search,run:()=>{V&&u.lz.getState().setTable(n.id,V,{search:"",page:0})}},{id:"reset-columns",title:"Reset Columns",keywords:["pin","hide","frozen","layout","show"],enabled:null!==V,run:()=>{V&&u.lz.getState().setTable(n.id,V,{pinnedColumns:void 0,hiddenColumns:[]})}},{id:"copy-table",title:"Copy Schema.Table",keywords:["copy","name","qualified"],enabled:null!==V,run:()=>{V&&Q((0,w.i)(V))}},{id:"color-theme",title:"Color Theme",keywords:["theme","appearance","dark","light","color","set","preferences"],enabled:!0,keepOpen:!0,run:()=>{let e=U.C.getState().theme,t=P.zG.findIndex(t=>t.id===e);T("themes"),$(""),z(-1===t?0:t)}},{id:"add-connection",title:"Add Connection",keywords:["new","database","postgres"],enabled:!0,run:()=>R(!0)}],[y.pinnedTables,d.target,n.id,x,i,H,o,j,l,p,V,Y?.search,a]),ee=(0,h.useMemo)(()=>E.trim()?(0,q.R6)(E,J,e=>[e.title,...e.keywords].join(" ")).map(e=>e.item):J,[J,E]),et=(0,h.useMemo)(()=>E.trim()?(0,q.R6)(E,[...P.zG],e=>[e.name,...e.keywords].join(" ")).map(e=>e.item):[...P.zG],[E]),en="themes"===S?et:ee,er="commands"===S?ee[L]??null:null,ea="themes"===S?et[L]??null:null;function el(e){e?.revertTheme&&"themes"===_.current&&(0,P.AZ)(U.C.getState().theme),C(!1),$(""),z(0),T("commands")}function es(){el({revertTheme:!0})}function eo(){"themes"===_.current&&(0,P.AZ)(U.C.getState().theme),T("commands"),$(""),z(0)}function ei(e){e.enabled&&(e.keepOpen||es(),e.run())}function ec(e){U.C.getState().setTheme(e.id),(0,P.AZ)(e.id),el({revertTheme:!1})}return(0,h.useEffect)(()=>{_.current=S},[S]),(0,h.useEffect)(()=>{if("themes"===S&&!E.trim()){let e=P.zG.findIndex(e=>e.id===U.C.getState().theme);z(-1===e?0:e);return}z(0)},[E,N,S]),(0,h.useEffect)(()=>{let e=O.current?.querySelector("[data-active=true]");e?.scrollIntoView({block:"nearest"})},[L,en]),(0,h.useEffect)(()=>{if(!N)return;let e=window.requestAnimationFrame(()=>I.current?.focus());return()=>window.cancelAnimationFrame(e)},[N,S]),(0,h.useEffect)(()=>{if(!N||"themes"!==S)return;let e=et[L];e&&(0,P.AZ)(e.id)},[N,S,L,et]),(0,h.useEffect)(()=>(0,F.T)(es),[]),(0,h.useEffect)(()=>{function e(e){if((e.metaKey||e.ctrlKey)&&e.shiftKey&&"p"===e.key.toLowerCase()){if(e.preventDefault(),N){"themes"===_.current&&eo(),I.current?.select();return}(0,F.r)(),$(""),z(0),T("commands"),C(!0);return}if(N&&"Escape"===e.key){if(e.preventDefault(),"themes"===_.current)return void eo();es()}}function t(e){!N||A.current?.contains(e.target)||es()}return window.addEventListener("keydown",e,!0),window.addEventListener("pointerdown",t),()=>{window.removeEventListener("keydown",e,!0),window.removeEventListener("pointerdown",t)}},[N]),(0,r.jsxs)(r.Fragment,{children:[N&&(0,r.jsxs)("div",{ref:A,"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,r.jsxs)("div",{className:"flex items-center gap-2 border-b px-3",children:[(0,r.jsx)("span",{className:"font-mono text-sm text-muted-foreground",children:">"}),(0,r.jsx)("input",{ref:I,value:E,onChange:e=>$(e.target.value),onKeyDown:function(e){if("ArrowDown"===e.key){if(e.preventDefault(),0===en.length)return;z(e=>(e+1)%en.length);return}if("ArrowUp"===e.key){if(e.preventDefault(),0===en.length)return;z(e=>(e-1+en.length)%en.length);return}if("Enter"===e.key){if(e.preventDefault(),"themes"===S){ea&&ec(ea);return}er&&ei(er)}},spellCheck:!1,autoComplete:"off",autoCorrect:"off",placeholder:"themes"===S?"Select color theme":"Type a command","aria-label":"themes"===S?"Color theme":"Command palette",className:"h-11 min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),(0,r.jsx)("div",{ref:O,role:"listbox","aria-label":"themes"===S?"Color themes":"Commands",className:"max-h-[min(24rem,50vh)] overflow-auto py-1",children:0===en.length?(0,r.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"themes"===S?"No matching themes":"No matching commands"}):"themes"===S?et.map((e,t)=>{let n=t===L,a=e.id===X;return(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":n,"data-active":n||void 0,onMouseEnter:()=>z(t),onClick:()=>ec(e),className:(0,v.cn)("flex h-8 w-full cursor-pointer items-center gap-2 px-3 text-left text-[13px] outline-none",n&&"bg-primary/10"),children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"size-3.5 shrink-0 rounded-sm border",style:{background:e.swatch}}),(0,r.jsx)("span",{className:"min-w-0 truncate",children:(0,r.jsx)(B,{text:e.name,query:E.trim()})}),a&&(0,r.jsx)(s.wiW,{className:"ml-auto size-3.5 shrink-0 text-muted-foreground"})]},e.id)}):ee.map((e,t)=>{let n=t===L;return(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":n,"aria-disabled":!e.enabled,"data-active":n||void 0,onMouseEnter:()=>z(t),onClick:()=>ei(e),className:(0,v.cn)("flex h-8 w-full cursor-pointer items-center px-3 text-left text-[13px] outline-none",n&&"bg-primary/10",!e.enabled&&"cursor-default opacity-40"),children:[(0,r.jsx)("span",{className:"min-w-0 truncate",children:(0,r.jsx)(B,{text:e.title,query:E.trim()})}),e.shortcut&&(0,r.jsx)("kbd",{className:"ml-auto shrink-0 pl-3 font-mono text-[11px] text-muted-foreground/70",children:e.shortcut})]},e.id)})})]}),(0,r.jsx)(M.f,{open:D,onOpenChange:R,onSubmit:t=>{let{shareWith:n,...r}=t,a=g(r);(0,u.mQ)(a.id,n),e.push(`/${a.id}`)}})]})}function X(){let{toggle:e}=W(),{toggle:t}=Z(),{toggle:n}=G(),{run:r}=(0,k.yG)(),a=(0,K.Q)(),l=(0,c.Z)(e=>e.connections.length>1),s=(0,h.useRef)(e),o=(0,h.useRef)(t),i=(0,h.useRef)(n),u=(0,h.useRef)(r),d=(0,h.useRef)(a),m=(0,h.useRef)(l);return(0,h.useEffect)(()=>{s.current=e},[e]),(0,h.useEffect)(()=>{o.current=t},[t]),(0,h.useEffect)(()=>{i.current=n},[n]),(0,h.useEffect)(()=>{u.current=r},[r]),(0,h.useEffect)(()=>{m.current=l},[l]),(0,h.useEffect)(()=>{d.current=a},[a]),(0,h.useEffect)(()=>{function e(e){if(!(e.metaKey||e.ctrlKey)||e.altKey||e.repeat)return;let t=e.key.toLowerCase();if("["===t||"]"===t){if(e.shiftKey||function(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;let t=e.tagName;return"INPUT"===t||"TEXTAREA"===t||"SELECT"===t}(e.target))return;e.preventDefault(),(0,F.r)(),"["===t?d.current.goBack():d.current.goForward();return}if("m"===t&&e.shiftKey){e.preventDefault(),(0,F.r)(),i.current();return}if("d"===t&&e.shiftKey){if(!m.current)return;e.preventDefault(),(0,F.r)(),o.current();return}if("e"===t){if(e.preventDefault(),(0,F.r)(),e.shiftKey)return void u.current();s.current()}}return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[]),null}var V=n(27529);let H={pinned:"Pinned",recent:"Recent",tables:"Tables",connections:"Connections"};function Y({text:e,query:t}){if(!t)return e;let n=e.toLocaleLowerCase(),a=t.toLocaleLowerCase(),l=n.indexOf(a);return -1===l?e:(0,r.jsxs)(r.Fragment,{children:[e.slice(0,l),(0,r.jsx)("mark",{className:"rounded-[3px] bg-yellow-300/90 px-px text-yellow-950 dark:bg-yellow-400/85 dark:text-yellow-950",children:e.slice(l,l+t.length)}),e.slice(l+t.length)]})}function J(e){try{return new URL(e).hostname}catch{return""}}function ee(e){return[e.name,J(e.url)].filter(Boolean)}function et(e,t){let n=new Map([["public",0],["auth",1]]);return(n.get(e.schema)??2)-(n.get(t.schema)??2)||e.schema.localeCompare(t.schema)||e.name.localeCompare(t.name)}function en(e,t){return e.map((e,n)=>0===n?{...e,section:t}:e)}function er(){let e=(0,f.useRouter)(),t=(0,k.$C)(),n=(0,f.useParams)(),{connection:a,tables:l}=(0,m.k)(),o=(0,c.Z)(e=>e.connections),[i,d]=(0,h.useState)(!1),[p,x]=(0,h.useState)(""),[g,y]=(0,h.useState)(0),[N,C]=(0,h.useState)(null),S=(0,h.useRef)(null),T=(0,h.useRef)(null),E=(0,h.useRef)(null),$=o.find(e=>e.id===N)??null,L=$??a,z=$&&$.id!==a.id?$.url:null,D=function(e){let[t]=(0,h.useState)(()=>new Map),[n,r]=(0,h.useState)({url:"",error:null});if((0,h.useEffect)(()=>{if(!e)return;let n=new AbortController;return V.F.tables(e,n.signal).then(n=>{t.set(e,n),r({url:e,data:n,error:null})}).catch(a=>{if(n.signal.aborted)return;let l=a instanceof Error?a.message:String(a);r(n=>({url:e,data:n.url===e?n.data:t.get(e),error:l}))}),()=>n.abort()},[t,e]),!e)return{data:void 0,error:null,loading:!1};let a=n.url===e?n.data:t.get(e);return{data:a,error:n.url===e?n.error:null,loading:void 0===a}}(z),[R,I]=(0,u.DE)(a.id),[A,M]=(0,u.DE)(L.id),U=L.id===a.id?R:A,P=(0,h.useMemo)(()=>z?D.data??[]:l.data??[],[D.data,z,l.data]),O=z?D.loading:l.loading,G=z?D.error:null,K=(0,h.useMemo)(()=>[...new Set(P.map(e=>e.schema))],[P]),Z=null===U.selectedSchemas?null:U.selectedSchemas.filter(e=>K.includes(e)),W=(0,h.useMemo)(()=>null===Z?P:P.filter(e=>Z.includes(e.schema)),[P,Z]),B=U.pinnedTables,Q=U.recentTables,_=(0,h.useMemo)(()=>{let e,t;return -1===(t=(e=p.trim()).indexOf(":"))?{schema:null,table:e}:{schema:e.slice(0,t).trim(),table:e.slice(t+1).trim()}},[p]),X=_.table||(_.schema?"":p.trim()),er=(0,h.useMemo)(()=>{let e=new Set(B),t=new Set(Q),n=null===_.schema?null:function(e,t){if(!e)return t;let n=e.toLocaleLowerCase(),r=t.filter(e=>e.toLocaleLowerCase()===n);if(r.length>0)return r;let a=t.filter(e=>e.toLocaleLowerCase().startsWith(n));return a.length>0?a:(0,q.R6)(e,t,e=>e).map(e=>e.item)}(_.schema,K),r=null===n?W:P.filter(e=>n.includes(e.schema)),l=new Map(r.map(e=>[(0,w.i)(e),e])),s=B.flatMap(e=>{let t=l.get(e);return t?[t]:[]}),i=Q.flatMap(t=>{let n=l.get(t);return!n||e.has(t)?[]:[n]}),c=(e,t)=>({type:"table",key:`table:${(0,w.i)(e)}`,table:e,...t}),u=e=>({type:"connection",key:`connection:${e.id}`,connection:e,current:e.id===a.id}),d=null===_.schema?p.trim():_.table,m=null===$&&null===_.schema;if(!d){let e=new Set([...s.map(e=>(0,w.i)(e)),...i.map(e=>(0,w.i)(e))]),n=r.filter(t=>!e.has((0,w.i)(t))).sort(et),l=m?o.filter(e=>e.id!==a.id):[];return[...en(s.map(e=>c(e,{pinned:!0})),"pinned"),...en(i.map(e=>c(e,{pinned:!1,recent:!0})),"recent"),...en(n.map(e=>c(e,{pinned:!1,recent:t.has((0,w.i)(e))})),"tables"),...en(l.map(u),"connections")]}let f=(0,q.UO)(d,r,e=>null===_.schema?[e.name,`${e.schema}.${e.name}`,e.schema]:[e.name]).map(n=>({...n,score:n.score+80*!!e.has((0,w.i)(n.item))+40*!!t.has((0,w.i)(n.item))})).sort((e,t)=>t.score-e.score).map(n=>c(n.item,{pinned:e.has((0,w.i)(n.item)),recent:t.has((0,w.i)(n.item))}));return[...en(m?(0,q.UO)(p,o,ee).map(e=>u(e.item)):[],"connections"),...en(f,"tables")]},[P,a.id,o,$,_.schema,_.table,B,p,Q,K,W]),ea=er[g]??null;function el(){d(!1),x(""),y(0),C(null)}function es(){C(null),y(0),S.current?.focus()}function eo(n){var r,a;(el(),"connection"===n.type)?t(n.connection.id):e.push((r=L.id,a=n.table,`/${r}/${encodeURIComponent(a.schema)}/${encodeURIComponent(a.name)}`))}function ei(e){let t=(0,w.i)(e),n=U.pinnedTables.includes(t)?U.pinnedTables.filter(e=>e!==t):[...U.pinnedTables,t];(L.id===a.id?I:M)({pinnedTables:n})}(0,h.useEffect)(()=>{y(0)},[p,i,N]),(0,h.useEffect)(()=>{let e=E.current?.querySelector("[data-active=true]");e?.scrollIntoView({block:"nearest"})},[g,er]),(0,h.useEffect)(()=>{if(!i)return;let e=window.requestAnimationFrame(()=>S.current?.focus());return()=>window.cancelAnimationFrame(e)},[i]),(0,h.useEffect)(()=>{if(!n.schema||!n.table)return;let e=`${decodeURIComponent(n.schema)}.${decodeURIComponent(n.table)}`,t=u.lz.getState().browse[a.id]?.recentTables??[];t[0]!==e&&I({recentTables:[e,...t.filter(t=>t!==e)].slice(0,12)})},[a.id,n.schema,n.table,I]),(0,h.useEffect)(()=>{function e(){i?S.current?.select():((0,F.r)(),x(""),y(0),C(null),d(!0))}function t(t){if((t.metaKey||t.ctrlKey)&&"p"===t.key.toLowerCase()){if(t.shiftKey)return;t.preventDefault(),e();return}i&&"Escape"===t.key&&(t.preventDefault(),el())}function n(e){!i||T.current?.contains(e.target)||el()}window.addEventListener("keydown",t,!0),window.addEventListener("pointerdown",n);let r=(0,b.s5)(e);return()=>{window.removeEventListener("keydown",t,!0),window.removeEventListener("pointerdown",n),r()}},[i]),(0,h.useEffect)(()=>(0,F.T)(el),[]);let ec=L.id===a.id&&n.schema&&n.table?`${decodeURIComponent(n.schema)}.${decodeURIComponent(n.table)}`:null;return i?(0,r.jsxs)("div",{ref:T,"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,r.jsxs)("div",{className:"flex items-center gap-2 border-b px-3",children:[(0,r.jsx)(s.TfF,{className:"size-4 shrink-0 text-muted-foreground"}),$&&(0,r.jsxs)("button",{type:"button",onClick:es,"aria-label":`Stop searching ${$.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,r.jsx)(j.F,{connection:$,className:"size-2"}),(0,r.jsx)("span",{className:"truncate",children:$.name})]}),(0,r.jsx)("input",{ref:S,value:p,onChange:e=>x(e.target.value),onKeyDown:function(e){if("ArrowDown"===e.key){if(e.preventDefault(),0===er.length)return;y(e=>(e+1)%er.length);return}if("ArrowUp"===e.key){if(e.preventDefault(),0===er.length)return;y(e=>(e-1+er.length)%er.length);return}if("Tab"===e.key){if(e.preventDefault(),$||e.shiftKey)return;ea?.type==="connection"&&(C(ea.connection.id),x(""),y(0));return}if("Backspace"===e.key&&""===p&&$){e.preventDefault(),es();return}"Enter"===e.key&&(e.preventDefault(),e.shiftKey&&ea?.type==="table"?ei(ea.table):ea&&eo(ea))},spellCheck:!1,autoComplete:"off",autoCorrect:"off",placeholder:$?`Search tables in ${$.name}`:"Go to table (schema:name)","aria-label":$?`Go to table in ${$.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,r.jsx)("div",{ref:E,role:"listbox","aria-label":$?`Tables in ${$.name}`:"Tables and connections",className:"max-h-[min(24rem,50vh)] overflow-auto py-1",children:O&&0===P.length&&0===er.length?(0,r.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"Loading tables…"}):G&&0===P.length?(0,r.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:G}):0===er.length?(0,r.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:p.trim()?"No matches":"No tables"}):er.map((e,t)=>{let n=t===g;if("connection"===e.type){let a=J(e.connection.url);return(0,r.jsxs)("div",{children:[e.section&&(0,r.jsx)("p",{className:"px-3 pt-2 pb-1 text-[10px] font-medium tracking-wide text-muted-foreground uppercase",children:H[e.section]}),(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":n,"data-active":n||void 0,onMouseEnter:()=>y(t),onClick:()=>eo(e),className:(0,v.cn)("flex h-8 w-full cursor-pointer items-center gap-2 px-3 text-left text-[13px] outline-none",n&&"bg-primary/10"),children:[(0,r.jsx)(s.bkQ,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)(j.F,{connection:e.connection,className:"size-2"}),(0,r.jsx)("span",{className:(0,v.cn)("min-w-0 truncate",e.current&&"font-medium"),children:(0,r.jsx)(Y,{text:e.connection.name,query:X})}),(0,r.jsx)("span",{className:"ml-auto flex min-w-0 shrink-0 items-center gap-2 text-[11px] text-muted-foreground",children:n?(0,r.jsx)("span",{children:"Tab to search"}):(0,r.jsx)("span",{className:"max-w-36 truncate",children:e.current?"current":a||"connection"})})]})]},e.key)}let a=(0,w.i)(e.table)===ec;return(0,r.jsxs)("div",{children:[e.section&&(0,r.jsx)("p",{className:"px-3 pt-2 pb-1 text-[10px] font-medium tracking-wide text-muted-foreground uppercase",children:H[e.section]}),(0,r.jsxs)("div",{onMouseEnter:()=>y(t),className:(0,v.cn)("group/table-result flex items-center",n&&"bg-primary/10"),children:[(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":n,"data-active":n||void 0,onClick:()=>eo(e),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:[e.recent&&!e.pinned?(0,r.jsx)(s.A01,{className:"size-3.5 shrink-0 text-muted-foreground"}):(0,r.jsx)(s.ooN,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:(0,v.cn)("min-w-0 truncate",a&&"font-medium"),children:(0,r.jsx)(Y,{text:e.table.name,query:X})}),(0,r.jsxs)("span",{className:"ml-auto flex min-w-0 shrink-0 items-center gap-2 text-[11px] text-muted-foreground",children:["view"===e.table.kind&&(0,r.jsx)("span",{children:"view"}),(0,r.jsx)("span",{className:"max-w-36 truncate",children:e.table.schema})]})]}),(0,r.jsx)("button",{type:"button","aria-label":`${e.pinned?"Unpin":"Pin"} ${(0,w.i)(e.table)}`,"aria-pressed":e.pinned,title:e.pinned?"Unpin table":"Pin table",onClick:()=>ei(e.table),className:(0,v.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",(e.pinned||n)&&"opacity-100",e.pinned&&"text-foreground"),children:e.pinned?(0,r.jsx)(s.M0d,{className:"size-3.5"}):(0,r.jsx)(s.rq5,{className:"size-3.5"})})]})]},e.key)})}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-3 border-t px-3 py-1.5 text-[10px] text-muted-foreground",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("kbd",{className:"font-mono text-foreground/70",children:"↑↓"}),"Navigate"]}),(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("kbd",{className:"font-mono text-foreground/70",children:"↵"}),"Open"]}),ea?.type==="table"&&(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("kbd",{className:"font-mono text-foreground/70",children:"⇧↵"}),ea.pinned?"Unpin":"Pin"]})]})]}):null}function ea({connectionId:e,children:t}){let n=(0,i.p)(),a=(0,c.w)(e),[f,h]=(0,u.DE)(e);if(!n)return null;if(!a)return(0,r.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 text-muted-foreground",children:[(0,r.jsx)("p",{children:"Connection not found"}),(0,r.jsx)(l(),{href:"/",className:"text-foreground underline underline-offset-4",children:"Connections"})]});let p=(0,d.Mq)(a);return(0,r.jsxs)(m.Z,{connection:a,children:[(0,r.jsxs)("div",{className:"flex h-dvh flex-col overflow-hidden",children:[(0,r.jsx)("div",{"aria-hidden":!0,title:a.name,className:"h-1.5 w-full shrink-0",style:{background:p}}),(0,r.jsxs)("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[f.sidebarCollapsed?(0,r.jsxs)("aside",{className:"relative flex h-full w-10 shrink-0 justify-center border-r bg-sidebar pt-2",children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-1",style:{background:p}}),(0,r.jsx)(o.$,{variant:"ghost",size:"icon-sm","aria-label":"Show database sidebar",title:"Show sidebar",onClick:()=>h({sidebarCollapsed:!1}),children:(0,r.jsx)(s.cFu,{})})]}):(0,r.jsx)(A,{width:f.sidebarWidth,onWidthChange:e=>h({sidebarWidth:e}),onCollapse:()=>h({sidebarCollapsed:!0})},a.id),(0,r.jsx)("main",{className:"flex min-w-0 flex-1 flex-col",children:t})]})]}),(0,r.jsx)(er,{}),(0,r.jsx)(_,{}),(0,r.jsx)(X,{})]})}},79781:(e,t,n)=>{"use strict";n.d(t,{$C:()=>u,yG:()=>d});var r=n(73321),a=n(12115),l=n(27529),s=n(15923),o=n(20185),i=n(69586),c=n(36331);function u(){let e=(0,r.useRouter)(),t=(0,r.usePathname)(),{connection:n}=(0,c.k)(),u=(0,i.Z)(e=>e.connections);return(0,a.useCallback)(async r=>{if(r===n.id)return;let a=u.find(e=>e.id===r);if(!a)return;(0,s.r)();let i=(0,o.ZG)(t),c=!!n.layoutGroup&&n.layoutGroup===a.layoutGroup,d=!0;if("table"===i.kind&&!c)try{var m,f;m=await l.F.tables(a.url),f=i.table,d=m.some(e=>e.schema===f.schema&&e.name===f.name)}catch{d=!1}e.push((0,o.gZ)(t,r,{tableExists:d}))},[n.id,n.layoutGroup,u,t,e])}function d(){let{connection:e}=(0,c.k)(),t=(0,i.Z)(e=>e.connections),n=u(),r=function(e,t){let n=e.findIndex(e=>e.id===t);if(!(e.length<2)&&-1!==n)return e[(n+1)%e.length]}(t,e.id);return{run:()=>r?n(r.id):Promise.resolve(),enabled:void 0!==r,next:r}}},86846:(e,t,n)=>{"use strict";n.d(t,{E:()=>l});var r=n(95155),a=n(40980);function l({className:e,...t}){return(0,r.jsx)("div",{"data-slot":"skeleton",className:(0,a.cn)("animate-pulse rounded-md bg-muted",e),...t})}}},e=>{e.O(0,[4506,1731,8026,2435,8361,8322,1981,9243,7709,6782,8441,3794,7358],()=>e(e.s=12860)),_N_E=e.O()}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7123],{7412:(e,t,n)=>{"use strict";n.d(t,{L:()=>s});var r=n(95155),a=n(13267),l=n(40980);function s({trailing:e,className:t,...n}){return(0,r.jsxs)("div",{className:(0,l.cn)("flex h-8 items-center gap-1.5 rounded-lg px-2 text-muted-foreground transition-colors focus-within:bg-muted/60 hover:bg-muted/60",t),children:[(0,r.jsx)(a.TfF,{className:"size-3.5 shrink-0"}),(0,r.jsx)("input",{type:"text",spellCheck:!1,autoComplete:"off",...n,className:"h-full min-w-0 flex-1 bg-transparent text-[0.8rem] text-foreground outline-none placeholder:text-muted-foreground"}),e]})}},12860:(e,t,n)=>{Promise.resolve().then(n.bind(n,37875))},15923:(e,t,n)=>{"use strict";n.d(t,{T:()=>a,r:()=>l});let r=new Set;function a(e){return r.add(e),()=>{r.delete(e)}}function l(){for(let e of r)e()}},19065:(e,t,n)=>{"use strict";function r(e,t){if(0===t)return!0;let n=e[t-1];return"_"===n||"-"===n||" "===n||"."===n}function a(e,t,n){return l(e,t,e=>[n(e)])}function l(e,t,n){if(!e.trim())return[];let a=[];for(let l of t){let t=n(l),s=null;for(let n of t){let t=function(e,t){let n=e.trim().toLocaleLowerCase(),a=t.toLocaleLowerCase();if(!n)return 0;if(0===a.length)return null;if(a===n)return 1e4;if(a.startsWith(n))return 5e3-a.length;let l=a.indexOf(n);if(-1!==l)return 2400+1200*!!r(t,l)-l-a.length;let s=0,o=0,i=0;for(let e=0;e<a.length&&s<n.length;e+=1){if(a[e]!==n[s]){i=0;continue}o+=12,(i+=1)>1&&(o+=18*i),r(t,e)&&(o+=40),s+=1}if(s<n.length)return null;let c=t.split(/[_\-\s.]+/).map(e=>e[0]??"").join("").toLocaleLowerCase();return c.startsWith(n)?o+=2200:c.includes(n)&&(o+=700),o-(a.length-n.length)}(e,n);null!==t&&(null===s||t>s)&&(s=t)}null!==s&&a.push({item:l,score:s})}return a.sort((e,t)=>t.score!==e.score?t.score-e.score:n(e.item)[0]?.localeCompare(n(t.item)[0]??"")??0)}n.d(t,{R6:()=>a,UO:()=>l})},23716:(e,t,n)=>{"use strict";n.d(t,{V:()=>o});var r=n(95155),a=n(13267),l=n(72264),s=n(40980);function o({schemas:e,selected:t,onChange:n,compact:i=!1}){let c=null===t||t.length===e.length,u=null===t||t.length===e.length?"All schemas":0===t.length?"No schemas":1===t.length?t[0]:`${t.length} of ${e.length} schemas`;return(0,r.jsxs)(l.rI,{children:[i?(0,r.jsxs)(l.ty,{"aria-label":`Schemas: ${u}`,title:u,className:(0,s.cn)("flex h-6 shrink-0 cursor-pointer items-center gap-1 rounded-md px-1 text-[11px] tabular-nums outline-none transition-colors hover:bg-foreground/10 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60 data-open:bg-foreground/10 data-open:text-foreground",c?"text-muted-foreground":"text-foreground"),children:[(0,r.jsx)(a.olY,{className:"size-3.5"}),!c&&(0,r.jsx)("span",{children:t.length})]}):(0,r.jsxs)(l.ty,{className:"group flex h-8 w-full cursor-pointer items-center gap-2 rounded-lg px-2 text-left text-[0.8rem] outline-none transition-colors hover:bg-muted/60 focus-visible:ring-2 focus-visible:ring-ring/60 data-open:bg-muted/60",children:[(0,r.jsx)(a.olY,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:u}),(0,r.jsx)(a.RQe,{className:"size-3.5 shrink-0 text-muted-foreground transition-transform group-data-open:rotate-180"})]}),(0,r.jsx)(l.SQ,{align:i?"end":"start",sideOffset:6,className:(0,s.cn)("max-h-80 min-w-52",!i&&"w-(--anchor-width)"),children:(0,r.jsxs)(l.I,{children:[(0,r.jsx)(l.hO,{checked:c,onCheckedChange:e=>n(e?null:[]),children:"All schemas"}),(0,r.jsx)(l.mB,{}),e.map(a=>(0,r.jsx)(l.hO,{checked:c||(t?.includes(a)??!1),onCheckedChange:r=>{let l,s;return l=t??e,void n((s=r?[...new Set([...l,a])]:l.filter(e=>e!==a)).length===e.length?null:s)},children:(0,r.jsx)("span",{className:"truncate",children:a})},a))]})})]})}},35942:(e,t,n)=>{"use strict";n.d(t,{F:()=>u});var r=n(95155);n(12115);var a=n(76166),l=n(90839),s=n(84588),o=n(66784),i=n(64084),c=n(40980);function u({className:e,children:t,...n}){return(0,r.jsxs)(a.V,{"data-slot":"scroll-area",className:(0,c.cn)("relative",e),...n,children:[(0,r.jsx)(l.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:t}),(0,r.jsx)(d,{}),(0,r.jsx)(s.I,{})]})}function d({className:e,orientation:t="vertical",...n}){return(0,r.jsx)(o.V,{"data-slot":"scroll-area-scrollbar","data-orientation":t,orientation:t,className:(0,c.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",e),...n,children:(0,r.jsx)(i.l,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}},37875:(e,t,n)=>{"use strict";n.d(t,{ExplorerShell:()=>ea});var r=n(95155),a=n(98500),l=n.n(a),s=n(13267),o=n(89239),i=n(95377),c=n(69586),u=n(40544),d=n(32538),m=n(36331),f=n(73321),h=n(12115),p=n(35942),x=n(7412),g=n(86846),b=n(43262),w=n(95848),v=n(40980),y=n(72264),j=n(72194),k=n(79781);function N({current:e}){let t=(0,c.Z)(e=>e.connections),n=(0,k.$C)();return(0,r.jsxs)(y.rI,{children:[(0,r.jsxs)(y.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,r.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,r.jsx)(j.F,{connection:e}),(0,r.jsx)("span",{className:"truncate",children:e.name}),e.layoutGroup&&(0,r.jsx)(s.WnQ,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),(0,r.jsx)(s.klM,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),(0,r.jsxs)(y.SQ,{align:"start",className:"w-(--anchor-width)",children:[t.map(t=>(0,r.jsxs)(y._2,{onClick:()=>void n(t.id),className:t.id===e.id?"font-medium":void 0,children:[(0,r.jsx)(j.F,{connection:t}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t.name}),t.layoutGroup&&t.layoutGroup===e.layoutGroup&&(0,r.jsx)(s.WnQ,{className:"size-3.5 shrink-0 text-muted-foreground"})]},t.id)),(0,r.jsx)(y.mB,{}),(0,r.jsx)(y._2,{render:(0,r.jsx)(l(),{href:"/"}),children:"Manage connections"})]})]})}var C=n(23716);function S(e,t){let n=e.trim(),r=n.lastIndexOf(".");return -1===r?n:"schema"===t?n.slice(0,r):n.slice(r+1)}function T({text:e,query:t}){if(!t)return e;let n=[],a=e.toLocaleLowerCase(),l=t.toLocaleLowerCase(),s=0,o=a.indexOf(l);if(-1===o)return e;for(;-1!==o;)o>s&&n.push(e.slice(s,o)),n.push((0,r.jsx)("mark",{className:"rounded-[3px] bg-yellow-300/90 px-px text-yellow-950 dark:bg-yellow-400/85 dark:text-yellow-950",children:e.slice(o,o+t.length)},o)),s=o+t.length,o=a.indexOf(l,s);return s<e.length&&n.push(e.slice(s)),n}function E({connectionId:e,table:t,search:n,pinned:a,showSchema:o,active:i,reorderable:c,dragging:u,dropEdge:d,onTogglePin:m,onDragStart:f,onDragOver:h,onDrop:p,onDragEnd:x,onMove:g}){return(0,r.jsxs)("li",{onDragOver:h,onDrop:p,className:(0,v.cn)("group/table-row relative flex h-7 items-center rounded-md text-[13px] transition-[color,background-color,opacity] hover:bg-muted/60",i&&"bg-muted text-foreground",!i&&"text-foreground/80",u&&"opacity-45","before"===d&&"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"===d&&"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:[c&&(0,r.jsx)("button",{type:"button",draggable:!0,"aria-label":`Reorder ${t.schema}.${t.name}`,title:"Drag to reorder; use Up and Down arrow keys",onDragStart:f,onDragEnd:x,onKeyDown:e=>{("ArrowUp"===e.key||"ArrowDown"===e.key)&&(e.preventDefault(),g?.("ArrowUp"===e.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,r.jsx)(s.Mvf,{className:"size-3.5"})}),(0,r.jsxs)(l(),{href:`/${e}/${encodeURIComponent(t.schema)}/${encodeURIComponent(t.name)}`,className:(0,v.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",c?"pl-1":"pl-6"),children:[(0,r.jsx)("span",{className:"truncate",children:(0,r.jsx)(T,{text:t.name,query:S(n,"table")})}),o?(0,r.jsx)("span",{className:"ml-auto max-w-20 truncate text-[10px] text-muted-foreground",children:t.schema}):"view"===t.kind&&(0,r.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"view"})]}),(0,r.jsx)("button",{type:"button","aria-label":`${a?"Unpin":"Pin"} ${t.schema}.${t.name}`,"aria-pressed":a,title:a?"Unpin table":"Pin table",onClick:()=>m(t),className:(0,v.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",a&&"text-foreground"),children:a?(0,r.jsx)(s.M0d,{className:"size-3.5"}):(0,r.jsx)(s.rq5,{className:"size-3.5"})})]})}function $({label:e,count:t,collapsed:n,pinned:a,search:l,onToggle:o}){return(0,r.jsxs)("button",{type:"button","aria-expanded":!n,onClick:o,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,r.jsx)(s.nNJ,{className:(0,v.cn)("size-3.5 transition-transform",!n&&"rotate-90")}),a&&(0,r.jsx)(s.M0d,{className:"mr-0.5 size-3"}),(0,r.jsx)("span",{className:"truncate",children:a?e:(0,r.jsx)(T,{text:e,query:S(l,"schema")})}),(0,r.jsx)("span",{className:"ml-auto pr-1 tabular-nums opacity-60",children:t})]})}function L({connectionId:e,tables:t,search:n,collapsedSchemas:a,pinnedTables:l,onToggleSchema:s,onTogglePin:o,onReorderPinned:i}){let c=(0,f.useParams)(),[u,d]=(0,h.useState)(!1),[m,p]=(0,h.useState)(null),[x,g]=(0,h.useState)(null),b=new Map(t.map(e=>[(0,w.i)(e),e])),v=l.flatMap(e=>{let t=b.get(e);return t?[t]:[]});function y(){p(null),g(null)}return 0===t.length?(0,r.jsx)("p",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:n.trim()?"No tables match your search":"No tables in these schemas"}):(0,r.jsxs)("div",{className:"flex flex-col gap-1 px-2 pb-4",children:[v.length>0&&(0,r.jsxs)("div",{className:"mb-1 border-b border-border/60 pb-1",children:[(0,r.jsx)($,{label:"Pinned tables",count:v.length,collapsed:u,pinned:!0,search:n,onToggle:()=>d(e=>!e)}),!u&&(0,r.jsx)("ul",{children:v.map(t=>{let a=(0,w.i)(t);return(0,r.jsx)(E,{connectionId:e,table:t,search:n,pinned:!0,showSchema:!0,active:c.schema===t.schema&&c.table===t.name,reorderable:!0,dragging:m===a,dropEdge:x?.key===a?x.edge:null,onTogglePin:o,onDragStart:e=>{e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",a),p(a),g(null)},onDragOver:e=>(function(e,t){if(!m||m===t)return;e.preventDefault(),e.dataTransfer.dropEffect="move";let n=e.currentTarget.getBoundingClientRect(),r=e.clientY<n.top+n.height/2?"before":"after";g(e=>e?.key===t&&e.edge===r?e:{key:t,edge:r})})(e,a),onDrop:e=>{let t,n;return e.preventDefault(),t=m??e.dataTransfer.getData("text/plain"),n=x?.key===a?x.edge:"before",void(t&&i(t,a,n),y())},onDragEnd:y,onMove:e=>{let t,n;return t=v.findIndex(e=>(0,w.i)(e)===a),void((n=v[t+e])&&i(a,(0,w.i)(n),-1===e?"before":"after"))}},a)})})]}),(function(e){let t=new Map;for(let n of e)t.set(n.schema,[...t.get(n.schema)??[],n]);return[...t.entries()].sort(([e],[t])=>{let n;return((n=new Map([["public",0],["auth",1]])).get(e)??2)-(n.get(t)??2)||e.localeCompare(t)})})(t).map(([t,i])=>{let u=a.includes(t);return(0,r.jsxs)("div",{children:[(0,r.jsx)($,{label:t,count:i.length,collapsed:u,search:n,onToggle:()=>s(t)}),!u&&(0,r.jsx)("ul",{children:i.map(t=>(0,r.jsx)(E,{connectionId:e,table:t,search:n,pinned:l.includes((0,w.i)(t)),active:c.schema===t.schema&&c.table===t.name,onTogglePin:o},(0,w.i)(t)))})]},t)})]})}function z(e){return Math.min(480,Math.max(180,Math.round(e)))}function D(e,t){let n=new Map([["public",0],["auth",1]]);return(n.get(e)??2)-(n.get(t)??2)||e.localeCompare(t)}function R(e,t,n){let r=t.trim().toLocaleLowerCase();return e.filter(e=>(null===n||!!n.includes(e.schema))&&(!r||e.name.toLocaleLowerCase().includes(r)||`${e.schema}.${e.name}`.toLocaleLowerCase().includes(r)))}function I({href:e,active:t,shortcut:n,children:a}){return(0,r.jsxs)(l(),{href:e,"aria-current":t?"page":void 0,className:(0,v.cn)((0,o.r)({variant:t?"secondary":"ghost",size:"sm"}),"h-8 w-full justify-start px-2"),children:[a,(0,r.jsx)("kbd",{className:"ml-auto font-mono text-[10px] text-muted-foreground/55",children:n})]})}function A({width:e,onWidthChange:t,onCollapse:n}){let a=(0,f.usePathname)(),{connection:l,tables:i}=(0,m.k)(),[d,v]=(0,u.DE)(l.id),y=(0,c.Z)(e=>e.connections.length>1),[j,k]=(0,h.useState)(()=>z(e)),S=(0,h.useRef)(null),T=(0,h.useMemo)(()=>[...new Set((i.data??[]).map(e=>e.schema))].sort(D),[i.data]),E=(0,h.useMemo)(()=>null===d.selectedSchemas?null:d.selectedSchemas.filter(e=>T.includes(e)),[d.selectedSchemas,T]),$=(0,h.useMemo)(()=>R(i.data??[],d.search,E),[i.data,d.search,E]),M=`/${encodeURIComponent(l.id)}`,U=`${M}/query`,P=`${M}/diff`,F=`${M}/migrations`;function q(e,t){let n=new Set(R(i.data??[],e,t).map(e=>e.schema));return d.collapsedSchemas.filter(e=>!n.has(e))}return(0,r.jsxs)("aside",{id:"database-explorer-sidebar",style:{width:j},className:"relative flex h-full shrink-0 flex-col border-r bg-sidebar",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-0.5 border-b border-sidebar-border/60 p-2",children:[(0,r.jsxs)("div",{className:"mb-1 flex items-center gap-1",children:[(0,r.jsx)("div",{className:"min-w-0 flex-1",children:(0,r.jsx)(N,{current:l})}),(0,r.jsx)(o.$,{variant:"ghost",size:"icon-sm","aria-label":"Collapse database sidebar",title:"Collapse sidebar",onClick:n,children:(0,r.jsx)(s.cFu,{})})]}),(0,r.jsxs)(I,{href:U,active:a===U,shortcut:b.Ar.sqlEditor,children:[(0,r.jsx)(s.Uoo,{"data-icon":"inline-start"}),"SQL query"]}),(0,r.jsxs)(I,{href:F,active:a===F||a.startsWith(`${F}/`),shortcut:b.Ar.migrations,children:[(0,r.jsx)(s.olY,{"data-icon":"inline-start"}),"Migrations"]}),y&&(0,r.jsxs)(I,{href:P,active:a===P,shortcut:b.Ar.compareSchema,children:[(0,r.jsx)(s.R4X,{"data-icon":"inline-start"}),"Compare schema"]}),(0,r.jsx)(x.L,{value:d.search,onChange:e=>{var t;v({search:t=e.target.value,collapsedSchemas:t.trim()?q(t,E):d.collapsedSchemas})},placeholder:"Search tables","aria-label":"Search tables",className:"mt-1",trailing:(0,r.jsxs)(r.Fragment,{children:[!d.search&&(0,r.jsx)("kbd",{className:"font-mono text-[10px] text-muted-foreground/55",children:b.Ar.tableSearch}),(0,r.jsx)(C.V,{compact:!0,schemas:T,selected:E,onChange:function(e){v({selectedSchemas:e,collapsedSchemas:d.search.trim()?q(d.search,e):d.collapsedSchemas})}})]})})]}),(0,r.jsx)(p.F,{className:"min-h-0 flex-1 pt-1.5",children:i.error?(0,r.jsx)("p",{className:"px-3 py-4 text-xs text-destructive",children:i.error}):i.data?(0,r.jsx)(L,{connectionId:l.id,tables:$,search:d.search,collapsedSchemas:d.collapsedSchemas,pinnedTables:d.pinnedTables,onToggleSchema:function(e){v({collapsedSchemas:d.collapsedSchemas.includes(e)?d.collapsedSchemas.filter(t=>t!==e):[...d.collapsedSchemas,e]})},onTogglePin:function(e){let t=(0,w.i)(e);v({pinnedTables:d.pinnedTables.includes(t)?d.pinnedTables.filter(e=>e!==t):[...d.pinnedTables,t]})},onReorderPinned:function(e,t,n){if(e===t)return;let r=d.pinnedTables.filter(t=>t!==e),a=r.indexOf(t);-1!==a&&(r.splice(a+ +("after"===n),0,e),v({pinnedTables:r}))}}):(0,r.jsx)("div",{className:"flex flex-col gap-2 px-3 py-2",children:Array.from({length:8},(e,t)=>(0,r.jsx)(g.E,{className:"h-5 w-full"},t))})}),(0,r.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize database sidebar","aria-valuemin":180,"aria-valuemax":480,"aria-valuenow":j,tabIndex:0,title:"Drag to resize; double-click to reset",onPointerDown:function(e){e.preventDefault(),S.current={pointerId:e.pointerId,startX:e.clientX,startWidth:j},e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:function(e){let t=S.current;t&&t.pointerId===e.pointerId&&(e.preventDefault(),k(z(t.startWidth+e.clientX-t.startX)))},onPointerUp:function(e){let n=S.current;if(!n||n.pointerId!==e.pointerId)return;let r=z(n.startWidth+e.clientX-n.startX);S.current=null,k(r),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),t(r)},onPointerCancel:function(e){let n=S.current;n&&n.pointerId===e.pointerId&&(S.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),t(j))},onKeyDown:function(e){if("ArrowLeft"!==e.key&&"ArrowRight"!==e.key)return;e.preventDefault();let n=z(j+("ArrowLeft"===e.key?-1:1)*16);k(n),t(n)},onDoubleClick:function(e){e.preventDefault(),k(256),t(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 M=n(67385),U=n(88406),P=n(86989),F=n(15923),q=n(19065);function O(e,{nested:t=!1}={}){let n=(0,f.useRouter)(),r=(0,f.usePathname)(),{connection:a,tables:l}=(0,m.k)(),[s]=(0,u.DE)(a.id),o=`/${encodeURIComponent(a.id)}`,i=`${o}/${e}`,c=t?r===i||r.startsWith(`${i}/`):r===i;return{open:c,href:i,toggle:()=>n.push(c?function(){for(let e of s.recentTables){let t=(l.data??[]).find(t=>(0,w.i)(t)===e);if(t)return`${o}/${encodeURIComponent(t.schema)}/${encodeURIComponent(t.name)}`}return o}():i)}}function G(){let e=O("migrations",{nested:!0});return{open:e.open,migrationsHref:e.href,toggle:e.toggle}}var K=n(48861);function Z(){let e=O("diff");return{open:e.open,diffHref:e.href,toggle:e.toggle}}function W(){let e=O("query");return{open:e.open,queryHref:e.href,toggle:e.toggle}}function B({text:e,query:t}){if(!t)return e;let n=e.toLocaleLowerCase(),a=t.toLocaleLowerCase(),l=n.indexOf(a);return -1===l?e:(0,r.jsxs)(r.Fragment,{children:[e.slice(0,l),(0,r.jsx)("mark",{className:"rounded-[3px] bg-yellow-300/90 px-px text-yellow-950 dark:bg-yellow-400/85 dark:text-yellow-950",children:e.slice(l,l+t.length)}),e.slice(l+t.length)]})}async function Q(e){try{await navigator.clipboard.writeText(e)}catch{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select(),document.execCommand("copy"),t.remove()}}function _(){let e=(0,f.useRouter)(),t=(0,f.useParams)(),{connection:n,tables:a}=(0,m.k)(),l=W(),o=Z(),i=G(),d=(0,u.y3)(n.id),p=(0,k.yG)(),x=(0,K.Q)(n.id),g=(0,c.Z)(e=>e.add),[y,j]=(0,u.DE)(n.id),[N,C]=(0,h.useState)(!1),[S,T]=(0,h.useState)("commands"),[E,$]=(0,h.useState)(""),[L,z]=(0,h.useState)(0),[D,R]=(0,h.useState)(!1),I=(0,h.useRef)(null),A=(0,h.useRef)(null),O=(0,h.useRef)(null),_=(0,h.useRef)(S),X=(0,U.C)(e=>e.theme),V=t.schema&&t.table?{schema:decodeURIComponent(t.schema),name:decodeURIComponent(t.table)}:null,H=!!V&&y.pinnedTables.includes((0,w.i)(V)),Y=(0,u.lz)(e=>V?e.tables[`${n.id}:${(0,w.i)(V)}`]:void 0),J=(0,h.useMemo)(()=>[{id:"sql-editor",title:l.open?"Back to Table":"Open SQL Query",keywords:["new","query","sql","console","editor","close","back","table"],enabled:!0,shortcut:b.Ar.sqlEditor,run:()=>l.toggle()},{id:"go-back",title:x.back?`Back to ${x.back.label}`:"Back",keywords:["back","previous","return","history","undo"],enabled:null!==x.back,shortcut:b.Ar.back,run:()=>x.goBack()},{id:"go-forward",title:x.forward?`Forward to ${x.forward.label}`:"Forward",keywords:["forward","next","history","redo"],enabled:null!==x.forward,shortcut:b.Ar.forward,run:()=>x.goForward()},{id:"switch-connection",title:p.next?`Switch Connection (${p.next.name})`:"Switch Connection",keywords:["database","env","environment","next","cycle","other"],enabled:p.enabled,shortcut:b.Ar.switchConnection,run:()=>void p.run()},{id:"migrations",title:i.open?"Back to Table":"Open Migrations",keywords:["migration","migrate","apply","revert","rollback","ledger","schema","run"],enabled:!0,shortcut:b.Ar.migrations,run:()=>i.toggle()},{id:"compare-schema",title:d.target?`Compare Schema with ${d.target.name}`:"Compare Schema",keywords:["diff","difference","migration","drift","prod","dev","schema","compare"],enabled:null!==d.target,shortcut:b.Ar.compareSchema,run:()=>o.toggle()},{id:"search-tables",title:"Search Tables",keywords:["find","jump","open","goto","table"],enabled:!0,shortcut:b.Ar.tableSearch,run:()=>window.requestAnimationFrame(()=>(0,b.tT)())},{id:"search-columns",title:"Search Columns",keywords:["find","jump","goto","column","field"],enabled:null!==V,shortcut:b.Ar.columnSearch,run:()=>window.requestAnimationFrame(()=>(0,b.vI)())},{id:"reload-tables",title:"Reload Tables",keywords:["refresh","reload","tables","sync"],enabled:!0,run:()=>a.reload()},{id:"pin-table",title:H?"Unpin Table":"Pin Table",keywords:["pin","unpin","favorite","star"],enabled:null!==V,run:()=>{if(!V)return;let e=(0,w.i)(V);j({pinnedTables:y.pinnedTables.includes(e)?y.pinnedTables.filter(t=>t!==e):[...y.pinnedTables,e]})}},{id:"clear-filters",title:"Clear Filters",keywords:["filter","reset","remove"],enabled:null!==V,run:()=>{V&&u.lz.getState().setTable(n.id,V,{filters:[],page:0})}},{id:"clear-search",title:"Clear Search",keywords:["find","search","reset"],enabled:null!==V&&!!Y?.search,run:()=>{V&&u.lz.getState().setTable(n.id,V,{search:"",page:0})}},{id:"reset-columns",title:"Reset Columns",keywords:["pin","hide","frozen","layout","show"],enabled:null!==V,run:()=>{V&&u.lz.getState().setTable(n.id,V,{pinnedColumns:void 0,hiddenColumns:[]})}},{id:"copy-table",title:"Copy Schema.Table",keywords:["copy","name","qualified"],enabled:null!==V,run:()=>{V&&Q((0,w.i)(V))}},{id:"color-theme",title:"Color Theme",keywords:["theme","appearance","dark","light","color","set","preferences"],enabled:!0,keepOpen:!0,run:()=>{let e=U.C.getState().theme,t=P.zG.findIndex(t=>t.id===e);T("themes"),$(""),z(-1===t?0:t)}},{id:"add-connection",title:"Add Connection",keywords:["new","database","postgres"],enabled:!0,run:()=>R(!0)}],[y.pinnedTables,d.target,n.id,x,i,H,o,j,l,p,V,Y?.search,a]),ee=(0,h.useMemo)(()=>E.trim()?(0,q.R6)(E,J,e=>[e.title,...e.keywords].join(" ")).map(e=>e.item):J,[J,E]),et=(0,h.useMemo)(()=>E.trim()?(0,q.R6)(E,[...P.zG],e=>[e.name,...e.keywords].join(" ")).map(e=>e.item):[...P.zG],[E]),en="themes"===S?et:ee,er="commands"===S?ee[L]??null:null,ea="themes"===S?et[L]??null:null;function el(e){e?.revertTheme&&"themes"===_.current&&(0,P.AZ)(U.C.getState().theme),C(!1),$(""),z(0),T("commands")}function es(){el({revertTheme:!0})}function eo(){"themes"===_.current&&(0,P.AZ)(U.C.getState().theme),T("commands"),$(""),z(0)}function ei(e){e.enabled&&(e.keepOpen||es(),e.run())}function ec(e){U.C.getState().setTheme(e.id),(0,P.AZ)(e.id),el({revertTheme:!1})}return(0,h.useEffect)(()=>{_.current=S},[S]),(0,h.useEffect)(()=>{if("themes"===S&&!E.trim()){let e=P.zG.findIndex(e=>e.id===U.C.getState().theme);z(-1===e?0:e);return}z(0)},[E,N,S]),(0,h.useEffect)(()=>{let e=O.current?.querySelector("[data-active=true]");e?.scrollIntoView({block:"nearest"})},[L,en]),(0,h.useEffect)(()=>{if(!N)return;let e=window.requestAnimationFrame(()=>I.current?.focus());return()=>window.cancelAnimationFrame(e)},[N,S]),(0,h.useEffect)(()=>{if(!N||"themes"!==S)return;let e=et[L];e&&(0,P.AZ)(e.id)},[N,S,L,et]),(0,h.useEffect)(()=>(0,F.T)(es),[]),(0,h.useEffect)(()=>{function e(e){if((e.metaKey||e.ctrlKey)&&e.shiftKey&&"p"===e.key.toLowerCase()){if(e.preventDefault(),N){"themes"===_.current&&eo(),I.current?.select();return}(0,F.r)(),$(""),z(0),T("commands"),C(!0);return}if(N&&"Escape"===e.key){if(e.preventDefault(),"themes"===_.current)return void eo();es()}}function t(e){!N||A.current?.contains(e.target)||es()}return window.addEventListener("keydown",e,!0),window.addEventListener("pointerdown",t),()=>{window.removeEventListener("keydown",e,!0),window.removeEventListener("pointerdown",t)}},[N]),(0,r.jsxs)(r.Fragment,{children:[N&&(0,r.jsxs)("div",{ref:A,"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,r.jsxs)("div",{className:"flex items-center gap-2 border-b px-3",children:[(0,r.jsx)("span",{className:"font-mono text-sm text-muted-foreground",children:">"}),(0,r.jsx)("input",{ref:I,value:E,onChange:e=>$(e.target.value),onKeyDown:function(e){if("ArrowDown"===e.key){if(e.preventDefault(),0===en.length)return;z(e=>(e+1)%en.length);return}if("ArrowUp"===e.key){if(e.preventDefault(),0===en.length)return;z(e=>(e-1+en.length)%en.length);return}if("Enter"===e.key){if(e.preventDefault(),"themes"===S){ea&&ec(ea);return}er&&ei(er)}},spellCheck:!1,autoComplete:"off",autoCorrect:"off",placeholder:"themes"===S?"Select color theme":"Type a command","aria-label":"themes"===S?"Color theme":"Command palette",className:"h-11 min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),(0,r.jsx)("div",{ref:O,role:"listbox","aria-label":"themes"===S?"Color themes":"Commands",className:"max-h-[min(24rem,50vh)] overflow-auto py-1",children:0===en.length?(0,r.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"themes"===S?"No matching themes":"No matching commands"}):"themes"===S?et.map((e,t)=>{let n=t===L,a=e.id===X;return(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":n,"data-active":n||void 0,onMouseEnter:()=>z(t),onClick:()=>ec(e),className:(0,v.cn)("flex h-8 w-full cursor-pointer items-center gap-2 px-3 text-left text-[13px] outline-none",n&&"bg-primary/10"),children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"size-3.5 shrink-0 rounded-sm border",style:{background:e.swatch}}),(0,r.jsx)("span",{className:"min-w-0 truncate",children:(0,r.jsx)(B,{text:e.name,query:E.trim()})}),a&&(0,r.jsx)(s.wiW,{className:"ml-auto size-3.5 shrink-0 text-muted-foreground"})]},e.id)}):ee.map((e,t)=>{let n=t===L;return(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":n,"aria-disabled":!e.enabled,"data-active":n||void 0,onMouseEnter:()=>z(t),onClick:()=>ei(e),className:(0,v.cn)("flex h-8 w-full cursor-pointer items-center px-3 text-left text-[13px] outline-none",n&&"bg-primary/10",!e.enabled&&"cursor-default opacity-40"),children:[(0,r.jsx)("span",{className:"min-w-0 truncate",children:(0,r.jsx)(B,{text:e.title,query:E.trim()})}),e.shortcut&&(0,r.jsx)("kbd",{className:"ml-auto shrink-0 pl-3 font-mono text-[11px] text-muted-foreground/70",children:e.shortcut})]},e.id)})})]}),(0,r.jsx)(M.f,{open:D,onOpenChange:R,onSubmit:t=>{let{shareWith:n,...r}=t,a=g(r);(0,u.mQ)(a.id,n),e.push(`/${a.id}`)}})]})}function X(){let{toggle:e}=W(),{toggle:t}=Z(),{toggle:n}=G(),{run:r}=(0,k.yG)(),a=(0,K.Q)(),l=(0,c.Z)(e=>e.connections.length>1),s=(0,h.useRef)(e),o=(0,h.useRef)(t),i=(0,h.useRef)(n),u=(0,h.useRef)(r),d=(0,h.useRef)(a),m=(0,h.useRef)(l);return(0,h.useEffect)(()=>{s.current=e},[e]),(0,h.useEffect)(()=>{o.current=t},[t]),(0,h.useEffect)(()=>{i.current=n},[n]),(0,h.useEffect)(()=>{u.current=r},[r]),(0,h.useEffect)(()=>{m.current=l},[l]),(0,h.useEffect)(()=>{d.current=a},[a]),(0,h.useEffect)(()=>{function e(e){if(!(e.metaKey||e.ctrlKey)||e.altKey||e.repeat)return;let t=e.key.toLowerCase();if("["===t||"]"===t){if(e.shiftKey||function(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;let t=e.tagName;return"INPUT"===t||"TEXTAREA"===t||"SELECT"===t}(e.target))return;e.preventDefault(),(0,F.r)(),"["===t?d.current.goBack():d.current.goForward();return}if("m"===t&&e.shiftKey){e.preventDefault(),(0,F.r)(),i.current();return}if("d"===t&&e.shiftKey){if(!m.current)return;e.preventDefault(),(0,F.r)(),o.current();return}if("e"===t){if(e.preventDefault(),(0,F.r)(),e.shiftKey)return void u.current();s.current()}}return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[]),null}var V=n(27529);let H={pinned:"Pinned",recent:"Recent",tables:"Tables",connections:"Connections"};function Y({text:e,query:t}){if(!t)return e;let n=e.toLocaleLowerCase(),a=t.toLocaleLowerCase(),l=n.indexOf(a);return -1===l?e:(0,r.jsxs)(r.Fragment,{children:[e.slice(0,l),(0,r.jsx)("mark",{className:"rounded-[3px] bg-yellow-300/90 px-px text-yellow-950 dark:bg-yellow-400/85 dark:text-yellow-950",children:e.slice(l,l+t.length)}),e.slice(l+t.length)]})}function J(e){try{return new URL(e).hostname}catch{return""}}function ee(e){return[e.name,J(e.url)].filter(Boolean)}function et(e,t){let n=new Map([["public",0],["auth",1]]);return(n.get(e.schema)??2)-(n.get(t.schema)??2)||e.schema.localeCompare(t.schema)||e.name.localeCompare(t.name)}function en(e,t){return e.map((e,n)=>0===n?{...e,section:t}:e)}function er(){let e=(0,f.useRouter)(),t=(0,k.$C)(),n=(0,f.useParams)(),{connection:a,tables:l}=(0,m.k)(),o=(0,c.Z)(e=>e.connections),[i,d]=(0,h.useState)(!1),[p,x]=(0,h.useState)(""),[g,y]=(0,h.useState)(0),[N,C]=(0,h.useState)(null),S=(0,h.useRef)(null),T=(0,h.useRef)(null),E=(0,h.useRef)(null),$=o.find(e=>e.id===N)??null,L=$??a,z=$&&$.id!==a.id?$.url:null,D=function(e){let[t]=(0,h.useState)(()=>new Map),[n,r]=(0,h.useState)({url:"",error:null});if((0,h.useEffect)(()=>{if(!e)return;let n=new AbortController;return V.F.tables(e,n.signal).then(n=>{t.set(e,n),r({url:e,data:n,error:null})}).catch(a=>{if(n.signal.aborted)return;let l=a instanceof Error?a.message:String(a);r(n=>({url:e,data:n.url===e?n.data:t.get(e),error:l}))}),()=>n.abort()},[t,e]),!e)return{data:void 0,error:null,loading:!1};let a=n.url===e?n.data:t.get(e);return{data:a,error:n.url===e?n.error:null,loading:void 0===a}}(z),[R,I]=(0,u.DE)(a.id),[A,M]=(0,u.DE)(L.id),U=L.id===a.id?R:A,P=(0,h.useMemo)(()=>z?D.data??[]:l.data??[],[D.data,z,l.data]),O=z?D.loading:l.loading,G=z?D.error:null,K=(0,h.useMemo)(()=>[...new Set(P.map(e=>e.schema))],[P]),Z=null===U.selectedSchemas?null:U.selectedSchemas.filter(e=>K.includes(e)),W=(0,h.useMemo)(()=>null===Z?P:P.filter(e=>Z.includes(e.schema)),[P,Z]),B=U.pinnedTables,Q=U.recentTables,_=(0,h.useMemo)(()=>{let e,t;return -1===(t=(e=p.trim()).indexOf(":"))?{schema:null,table:e}:{schema:e.slice(0,t).trim(),table:e.slice(t+1).trim()}},[p]),X=_.table||(_.schema?"":p.trim()),er=(0,h.useMemo)(()=>{let e=new Set(B),t=new Set(Q),n=null===_.schema?null:function(e,t){if(!e)return t;let n=e.toLocaleLowerCase(),r=t.filter(e=>e.toLocaleLowerCase()===n);if(r.length>0)return r;let a=t.filter(e=>e.toLocaleLowerCase().startsWith(n));return a.length>0?a:(0,q.R6)(e,t,e=>e).map(e=>e.item)}(_.schema,K),r=null===n?W:P.filter(e=>n.includes(e.schema)),l=new Map(r.map(e=>[(0,w.i)(e),e])),s=B.flatMap(e=>{let t=l.get(e);return t?[t]:[]}),i=Q.flatMap(t=>{let n=l.get(t);return!n||e.has(t)?[]:[n]}),c=(e,t)=>({type:"table",key:`table:${(0,w.i)(e)}`,table:e,...t}),u=e=>({type:"connection",key:`connection:${e.id}`,connection:e,current:e.id===a.id}),d=null===_.schema?p.trim():_.table,m=null===$&&null===_.schema;if(!d){let e=new Set([...s.map(e=>(0,w.i)(e)),...i.map(e=>(0,w.i)(e))]),n=r.filter(t=>!e.has((0,w.i)(t))).sort(et),l=m?o.filter(e=>e.id!==a.id):[];return[...en(s.map(e=>c(e,{pinned:!0})),"pinned"),...en(i.map(e=>c(e,{pinned:!1,recent:!0})),"recent"),...en(n.map(e=>c(e,{pinned:!1,recent:t.has((0,w.i)(e))})),"tables"),...en(l.map(u),"connections")]}let f=(0,q.UO)(d,r,e=>null===_.schema?[e.name,`${e.schema}.${e.name}`,e.schema]:[e.name]).map(n=>({...n,score:n.score+80*!!e.has((0,w.i)(n.item))+40*!!t.has((0,w.i)(n.item))})).sort((e,t)=>t.score-e.score).map(n=>c(n.item,{pinned:e.has((0,w.i)(n.item)),recent:t.has((0,w.i)(n.item))}));return[...en(m?(0,q.UO)(p,o,ee).map(e=>u(e.item)):[],"connections"),...en(f,"tables")]},[P,a.id,o,$,_.schema,_.table,B,p,Q,K,W]),ea=er[g]??null;function el(){d(!1),x(""),y(0),C(null)}function es(){C(null),y(0),S.current?.focus()}function eo(n){var r,a;(el(),"connection"===n.type)?t(n.connection.id):e.push((r=L.id,a=n.table,`/${r}/${encodeURIComponent(a.schema)}/${encodeURIComponent(a.name)}`))}function ei(e){let t=(0,w.i)(e),n=U.pinnedTables.includes(t)?U.pinnedTables.filter(e=>e!==t):[...U.pinnedTables,t];(L.id===a.id?I:M)({pinnedTables:n})}(0,h.useEffect)(()=>{y(0)},[p,i,N]),(0,h.useEffect)(()=>{let e=E.current?.querySelector("[data-active=true]");e?.scrollIntoView({block:"nearest"})},[g,er]),(0,h.useEffect)(()=>{if(!i)return;let e=window.requestAnimationFrame(()=>S.current?.focus());return()=>window.cancelAnimationFrame(e)},[i]),(0,h.useEffect)(()=>{if(!n.schema||!n.table)return;let e=`${decodeURIComponent(n.schema)}.${decodeURIComponent(n.table)}`,t=u.lz.getState().browse[a.id]?.recentTables??[];t[0]!==e&&I({recentTables:[e,...t.filter(t=>t!==e)].slice(0,12)})},[a.id,n.schema,n.table,I]),(0,h.useEffect)(()=>{function e(){i?S.current?.select():((0,F.r)(),x(""),y(0),C(null),d(!0))}function t(t){if((t.metaKey||t.ctrlKey)&&"p"===t.key.toLowerCase()){if(t.shiftKey)return;t.preventDefault(),e();return}i&&"Escape"===t.key&&(t.preventDefault(),el())}function n(e){!i||T.current?.contains(e.target)||el()}window.addEventListener("keydown",t,!0),window.addEventListener("pointerdown",n);let r=(0,b.s5)(e);return()=>{window.removeEventListener("keydown",t,!0),window.removeEventListener("pointerdown",n),r()}},[i]),(0,h.useEffect)(()=>(0,F.T)(el),[]);let ec=L.id===a.id&&n.schema&&n.table?`${decodeURIComponent(n.schema)}.${decodeURIComponent(n.table)}`:null;return i?(0,r.jsxs)("div",{ref:T,"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,r.jsxs)("div",{className:"flex items-center gap-2 border-b px-3",children:[(0,r.jsx)(s.TfF,{className:"size-4 shrink-0 text-muted-foreground"}),$&&(0,r.jsxs)("button",{type:"button",onClick:es,"aria-label":`Stop searching ${$.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,r.jsx)(j.F,{connection:$,className:"size-2"}),(0,r.jsx)("span",{className:"truncate",children:$.name})]}),(0,r.jsx)("input",{ref:S,value:p,onChange:e=>x(e.target.value),onKeyDown:function(e){if("ArrowDown"===e.key){if(e.preventDefault(),0===er.length)return;y(e=>(e+1)%er.length);return}if("ArrowUp"===e.key){if(e.preventDefault(),0===er.length)return;y(e=>(e-1+er.length)%er.length);return}if("Tab"===e.key){if(e.preventDefault(),$||e.shiftKey)return;ea?.type==="connection"&&(C(ea.connection.id),x(""),y(0));return}if("Backspace"===e.key&&""===p&&$){e.preventDefault(),es();return}"Enter"===e.key&&(e.preventDefault(),e.shiftKey&&ea?.type==="table"?ei(ea.table):ea&&eo(ea))},spellCheck:!1,autoComplete:"off",autoCorrect:"off",placeholder:$?`Search tables in ${$.name}`:"Go to table (schema:name)","aria-label":$?`Go to table in ${$.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,r.jsx)("div",{ref:E,role:"listbox","aria-label":$?`Tables in ${$.name}`:"Tables and connections",className:"max-h-[min(24rem,50vh)] overflow-auto py-1",children:O&&0===P.length&&0===er.length?(0,r.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"Loading tables…"}):G&&0===P.length?(0,r.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:G}):0===er.length?(0,r.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:p.trim()?"No matches":"No tables"}):er.map((e,t)=>{let n=t===g;if("connection"===e.type){let a=J(e.connection.url);return(0,r.jsxs)("div",{children:[e.section&&(0,r.jsx)("p",{className:"px-3 pt-2 pb-1 text-[10px] font-medium tracking-wide text-muted-foreground uppercase",children:H[e.section]}),(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":n,"data-active":n||void 0,onMouseEnter:()=>y(t),onClick:()=>eo(e),className:(0,v.cn)("flex h-8 w-full cursor-pointer items-center gap-2 px-3 text-left text-[13px] outline-none",n&&"bg-primary/10"),children:[(0,r.jsx)(s.bkQ,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)(j.F,{connection:e.connection,className:"size-2"}),(0,r.jsx)("span",{className:(0,v.cn)("min-w-0 truncate",e.current&&"font-medium"),children:(0,r.jsx)(Y,{text:e.connection.name,query:X})}),(0,r.jsx)("span",{className:"ml-auto flex min-w-0 shrink-0 items-center gap-2 text-[11px] text-muted-foreground",children:n?(0,r.jsx)("span",{children:"Tab to search"}):(0,r.jsx)("span",{className:"max-w-36 truncate",children:e.current?"current":a||"connection"})})]})]},e.key)}let a=(0,w.i)(e.table)===ec;return(0,r.jsxs)("div",{children:[e.section&&(0,r.jsx)("p",{className:"px-3 pt-2 pb-1 text-[10px] font-medium tracking-wide text-muted-foreground uppercase",children:H[e.section]}),(0,r.jsxs)("div",{onMouseEnter:()=>y(t),className:(0,v.cn)("group/table-result flex items-center",n&&"bg-primary/10"),children:[(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":n,"data-active":n||void 0,onClick:()=>eo(e),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:[e.recent&&!e.pinned?(0,r.jsx)(s.A01,{className:"size-3.5 shrink-0 text-muted-foreground"}):(0,r.jsx)(s.ooN,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:(0,v.cn)("min-w-0 truncate",a&&"font-medium"),children:(0,r.jsx)(Y,{text:e.table.name,query:X})}),(0,r.jsxs)("span",{className:"ml-auto flex min-w-0 shrink-0 items-center gap-2 text-[11px] text-muted-foreground",children:["view"===e.table.kind&&(0,r.jsx)("span",{children:"view"}),(0,r.jsx)("span",{className:"max-w-36 truncate",children:e.table.schema})]})]}),(0,r.jsx)("button",{type:"button","aria-label":`${e.pinned?"Unpin":"Pin"} ${(0,w.i)(e.table)}`,"aria-pressed":e.pinned,title:e.pinned?"Unpin table":"Pin table",onClick:()=>ei(e.table),className:(0,v.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",(e.pinned||n)&&"opacity-100",e.pinned&&"text-foreground"),children:e.pinned?(0,r.jsx)(s.M0d,{className:"size-3.5"}):(0,r.jsx)(s.rq5,{className:"size-3.5"})})]})]},e.key)})}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-3 border-t px-3 py-1.5 text-[10px] text-muted-foreground",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("kbd",{className:"font-mono text-foreground/70",children:"↑↓"}),"Navigate"]}),(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("kbd",{className:"font-mono text-foreground/70",children:"↵"}),"Open"]}),ea?.type==="table"&&(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("kbd",{className:"font-mono text-foreground/70",children:"⇧↵"}),ea.pinned?"Unpin":"Pin"]})]})]}):null}function ea({connectionId:e,children:t}){let n=(0,i.p)(),a=(0,c.w)(e),[f,h]=(0,u.DE)(e);if(!n)return null;if(!a)return(0,r.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 text-muted-foreground",children:[(0,r.jsx)("p",{children:"Connection not found"}),(0,r.jsx)(l(),{href:"/",className:"text-foreground underline underline-offset-4",children:"Connections"})]});let p=(0,d.Mq)(a);return(0,r.jsxs)(m.Z,{connection:a,children:[(0,r.jsxs)("div",{className:"flex h-dvh flex-col overflow-hidden",children:[(0,r.jsx)("div",{"aria-hidden":!0,title:a.name,className:"h-1.5 w-full shrink-0",style:{background:p}}),(0,r.jsxs)("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[f.sidebarCollapsed?(0,r.jsxs)("aside",{className:"relative flex h-full w-10 shrink-0 justify-center border-r bg-sidebar pt-2",children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-1",style:{background:p}}),(0,r.jsx)(o.$,{variant:"ghost",size:"icon-sm","aria-label":"Show database sidebar",title:"Show sidebar",onClick:()=>h({sidebarCollapsed:!1}),children:(0,r.jsx)(s.cFu,{})})]}):(0,r.jsx)(A,{width:f.sidebarWidth,onWidthChange:e=>h({sidebarWidth:e}),onCollapse:()=>h({sidebarCollapsed:!0})},a.id),(0,r.jsx)("main",{className:"flex min-w-0 flex-1 flex-col",children:t})]})]}),(0,r.jsx)(er,{}),(0,r.jsx)(_,{}),(0,r.jsx)(X,{})]})}},79781:(e,t,n)=>{"use strict";n.d(t,{$C:()=>u,yG:()=>d});var r=n(73321),a=n(12115),l=n(27529),s=n(15923),o=n(20185),i=n(69586),c=n(36331);function u(){let e=(0,r.useRouter)(),t=(0,r.usePathname)(),{connection:n}=(0,c.k)(),u=(0,i.Z)(e=>e.connections);return(0,a.useCallback)(async r=>{if(r===n.id)return;let a=u.find(e=>e.id===r);if(!a)return;(0,s.r)();let i=(0,o.ZG)(t),c=!!n.layoutGroup&&n.layoutGroup===a.layoutGroup,d=!0;if("table"===i.kind&&!c)try{var m,f;m=await l.F.tables(a.url),f=i.table,d=m.some(e=>e.schema===f.schema&&e.name===f.name)}catch{d=!1}e.push((0,o.gZ)(t,r,{tableExists:d}))},[n.id,n.layoutGroup,u,t,e])}function d(){let{connection:e}=(0,c.k)(),t=(0,i.Z)(e=>e.connections),n=u(),r=function(e,t){let n=e.findIndex(e=>e.id===t);if(!(e.length<2)&&-1!==n)return e[(n+1)%e.length]}(t,e.id);return{run:()=>r?n(r.id):Promise.resolve(),enabled:void 0!==r,next:r}}},86846:(e,t,n)=>{"use strict";n.d(t,{E:()=>l});var r=n(95155),a=n(40980);function l({className:e,...t}){return(0,r.jsx)("div",{"data-slot":"skeleton",className:(0,a.cn)("animate-pulse rounded-md bg-muted",e),...t})}}},e=>{e.O(0,[4506,1731,8026,2435,8361,8322,544,6090,577,8441,3794,7358],()=>e(e.s=12860)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8755],{28330:(e,t,n)=>{Promise.resolve().then(n.bind(n,69063))},69063:(e,t,n)=>{"use strict";n.d(t,{MigrationsIndex:()=>T});var s=n(95155),a=n(98500),r=n.n(a),i=n(73321),l=n(20185),o=n(12115),d=n(13267),c=n(72194),u=n(36331),m=n(17491),h=n(89239),p=n(72264),x=n(66289),g=n(91075),f=n(85488),j=n(35942),b=n(7412),v=n(87364),N=n(27529),k=n(9385),y=n(62417),w=n(40544),$=n(79668),C=n(40980),S=n(17021),z=n(20642),M=n(77649),F=n(27013),R=n(41069),E=n(42763),I=n(83504);let q=[{verdict:"applied",title:"Already there",hint:"Everything these create or change is in the database.",preselected:!0},{verdict:"partial",title:"Partly there",hint:"Some of what these do is in the database and some is not — often a later migration changed it again.",preselected:!1},{verdict:"unknown",title:"Leaves no trace",hint:"Data changes, seeds, and grants cannot be seen in the schema. Include them if you know they ran.",preselected:!1},{verdict:"pending",title:"Not there",hint:"Nothing these do is in the database. Marking these hides work that still needs to run.",preselected:!1}];function O(e){return`${e.setName}\0${e.version}`}function V({connection:e,ledgerSchema:t,plan:n,onDone:a,onOpenChange:r}){let[i,l]=(0,o.useState)(null),[u,m]=(0,o.useState)(null),[p,x]=(0,o.useState)(new Set),[g,f]=(0,o.useState)([]),[j,b]=(0,o.useState)(!1),[v,k]=(0,o.useState)(null),[y,w]=(0,o.useState)(null);(0,o.useEffect)(()=>{let t=new AbortController;return N.F.detect(e.url,n.entries.map(e=>({setName:e.setName,version:e.version,sql:e.applySql})),t.signal).then(({results:e})=>{l(e);let t=new Set;for(let n of e)q.find(e=>e.verdict===n.verdict)?.preselected&&t.add(O(n));x(t)}).catch(e=>{t.signal.aborted||m(e instanceof Error?e.message:String(e))}),()=>t.abort()},[e.url,n.entries]);let $=(0,o.useMemo)(()=>{if(!i)return[];let e=new Map(n.entries.map(e=>[O(e),e]));return q.map(t=>({verdict:t.verdict,title:t.title,hint:t.hint,entries:i.filter(e=>e.verdict===t.verdict).flatMap(t=>{let n=e.get(O(t));return n?[{entry:n,result:t}]:[]})})).filter(e=>e.entries.length>0)},[i,n.entries]),S=n.entries.filter(e=>p.has(O(e)));async function z(n){b(!0),w(null);try{k(await N.F.adopt(e.url,{ledgerSchema:t,entries:n})),a()}catch(e){w(e instanceof Error?e.message:String(e))}finally{b(!1)}}let M=!i&&!u;return(0,s.jsx)(E.lG,{open:!0,onOpenChange:e=>!j&&r(e),children:(0,s.jsxs)(E.Cf,{className:"sm:max-w-xl",children:[(0,s.jsxs)(E.c7,{children:[(0,s.jsx)(E.L3,{children:v?`Marked ${v.recorded} as applied`:M?`Checking ${e.name}…`:`Mark as already applied on ${e.name}`}),(0,s.jsx)(E.rr,{children:(0,s.jsxs)("span",{className:"flex flex-wrap items-center gap-1.5",children:[(0,s.jsx)("span",{children:v?"Recorded on":"Records on"}),(0,s.jsx)(c.F,{connection:e}),(0,s.jsx)("span",{className:"font-medium text-foreground",children:e.name}),(0,s.jsx)("span",{className:"font-mono text-[11px]",children:(0,I.p)(e.url)})]})})]}),v?(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:v.existing>0?`${v.existing} were already in the ledger and were left as they were.`:"Every one of them was new to the ledger."}):M?(0,s.jsxs)("p",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,s.jsx)(d.gnh,{className:"size-3.5 animate-spin"}),"Reading the schema to see which of the ",n.entries.length," have already run…"]}):u?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"max-h-32 overflow-auto rounded-md border border-destructive/25 bg-destructive/5 px-3 py-2 font-mono text-[11px] whitespace-pre-wrap text-destructive",children:u}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["The check could not run. You can still mark all ",n.entries.length," as applied if you know the database already has these changes."]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"max-h-80 overflow-y-auto rounded-md border",children:$.map(e=>{let t=e.entries.filter(({entry:e})=>p.has(O(e))).length,n=g.includes(e.verdict);return(0,s.jsxs)("div",{className:"border-b last:border-b-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2",children:[(0,s.jsx)("input",{type:"checkbox","aria-label":`Include ${e.title}`,className:"size-3.5 cursor-pointer accent-primary",checked:t===e.entries.length,ref:n=>{n&&(n.indeterminate=t>0&&t<e.entries.length)},onChange:t=>{var n;return n=t.target.checked,void x(t=>{let s=new Set(t);for(let{entry:t}of e.entries)n?s.add(O(t)):s.delete(O(t));return s})}}),(0,s.jsxs)("button",{type:"button","aria-expanded":n,onClick:()=>{var t;return t=e.verdict,void f(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-left",children:[(0,s.jsx)(d.nNJ,{className:(0,C.cn)("size-3.5 shrink-0 text-muted-foreground/70 transition-transform",n&&"rotate-90")}),(0,s.jsx)("span",{className:"text-sm",children:e.title}),(0,s.jsxs)("span",{className:"tabular-nums text-xs text-muted-foreground",children:[t,"/",e.entries.length]})]}),(0,s.jsx)(L,{verdict:e.verdict})]}),!n&&(0,s.jsx)("p",{className:"px-9 pb-2 text-[11px] text-muted-foreground",children:e.hint}),n&&(0,s.jsxs)("div",{className:"bg-muted/25",children:[(0,s.jsx)("p",{className:"px-9 py-1.5 text-[11px] text-muted-foreground",children:e.hint}),e.entries.map(({entry:e,result:t})=>{let n=t.evidence.filter(e=>!e.satisfied),a=t.evidence.find(e=>e.note)?.note;return(0,s.jsxs)("label",{className:"flex cursor-pointer items-start gap-2 border-t px-3 py-1.5 text-xs hover:bg-muted/40",children:[(0,s.jsx)("input",{type:"checkbox",className:"mt-0.5 size-3.5 cursor-pointer accent-primary",checked:p.has(O(e)),onChange:()=>{x(t=>{let n=new Set(t),s=O(e);return n.has(s)?n.delete(s):n.add(s),n})}}),(0,s.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"shrink-0 text-muted-foreground",children:e.setName}),(0,s.jsx)("span",{className:"shrink-0 font-mono text-muted-foreground",children:e.version}),(0,s.jsx)("span",{className:"min-w-0 truncate",children:e.name})]}),(n.length>0||a)&&(0,s.jsxs)("span",{className:"mt-0.5 block truncate text-[11px] text-muted-foreground",children:[n.length>0&&(0,s.jsxs)(s.Fragment,{children:["Missing: ",n.slice(0,2).map(e=>e.description).join(", "),n.length>2&&` and ${n.length-2} more`]}),n.length>0&&a&&" \xb7 ",a]})]})]},O(e))})]})]},e.verdict)})}),(0,s.jsxs)("p",{className:"rounded-md border border-amber-600/25 bg-amber-500/8 px-3 py-2 text-xs",children:[(0,s.jsx)("span",{className:"font-medium",children:"No SQL runs."})," Only the ledger on"," ",e.name," changes, in one transaction. Rows already there are not touched."]})]}),y&&(0,s.jsx)("p",{className:"max-h-32 overflow-auto rounded-md border border-destructive/25 bg-destructive/5 px-3 py-2 font-mono text-[11px] whitespace-pre-wrap text-destructive",children:y}),(0,s.jsx)(E.Es,{children:v?(0,s.jsx)(h.$,{onClick:()=>r(!1),children:"Close"}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(h.$,{variant:"outline",disabled:j,onClick:()=>r(!1),children:"Cancel"}),u?(0,s.jsx)(h.$,{disabled:j,onClick:()=>void z(n.entries),children:j?"Marking…":`Mark all ${n.entries.length} as applied`}):(0,s.jsx)(h.$,{disabled:j||M||0===S.length,onClick:()=>void z(S),children:j?"Marking…":`Mark as applied (${S.length})`})]})})]})})}function L({verdict:e}){return"applied"===e?(0,s.jsx)(d.wiW,{className:"size-4 shrink-0 text-emerald-600 dark:text-emerald-400"}):"partial"===e?(0,s.jsx)(d.e5t,{className:"size-3.5 shrink-0 text-amber-600 dark:text-amber-400"}):"pending"===e?(0,s.jsx)(d.e5t,{className:"size-3.5 shrink-0 text-destructive"}):(0,s.jsx)("span",{className:"size-1.5 shrink-0 rounded-full bg-muted-foreground/40"})}var _=n(60529),A=n(33807);function Q({root:e,environmentNames:t,onOpenChange:n,onSave:a}){let[r,i]=(0,o.useState)(e??""),l=r.trim(),d=l.startsWith("/")||l.startsWith("~")||/^[A-Za-z]:[\\/]/.test(l);function c(){l&&d&&(a(l),n(!1))}return(0,s.jsx)(E.lG,{open:!0,onOpenChange:n,children:(0,s.jsxs)(E.Cf,{className:"sm:max-w-lg",children:[(0,s.jsxs)(E.c7,{children:[(0,s.jsx)(E.L3,{children:"Migrations folder"}),(0,s.jsxs)(E.rr,{children:["A folder on this computer. Each folder inside it that holds .sql files is one migration, read fresh from disk every time — whatever branch is checked out is what shows. ",t.join(", ")," will all read from it."]})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsx)(A.J,{htmlFor:"repo-root",children:"Path"}),(0,s.jsx)(_.p,{id:"repo-root",value:r,placeholder:"~/code/app/src/lib/supabase/migrations",spellCheck:!1,autoComplete:"off",autoFocus:!0,"aria-invalid":l.length>0&&!d,onChange:e=>i(e.target.value),onKeyDown:e=>"Enter"===e.key&&c()}),l.length>0&&!d&&(0,s.jsx)("p",{className:"text-xs text-destructive",children:"An absolute path, or one starting with ~."})]}),(0,s.jsxs)(E.Es,{children:[e&&(0,s.jsx)(h.$,{variant:"ghost",className:"mr-auto",onClick:function(){a(null),n(!1)},children:"Stop reading from disk"}),(0,s.jsx)(h.$,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),(0,s.jsx)(h.$,{disabled:!l||!d,onClick:c,children:"Save"})]})]})})}var P=n(71612);function T(){let e=(0,i.useRouter)(),{connection:t}=(0,u.k)(),n=(0,$.jV)(e=>e.sets),a=(0,$.jV)(e=>e.createSet),r=(0,$.jV)(e=>e.adoptSet),c=(0,$.jV)(e=>e.addFiles),x=(0,$.jV)(e=>e.removeSet),g=(0,$.jV)(e=>e.ledgerSchema),f=(0,$.jV)(e=>e.history),b=(0,w.gz)(t.id),E=(0,l.ZG)((0,i.usePathname)()),I="migrations"===E.kind&&"timeline"===E.view?"history":"migrations",[q,O]=(0,o.useState)(null),[L,_]=(0,o.useState)(null),[A,T]=(0,o.useState)(!1),[U,K]=(0,o.useState)(!1),[D,H]=(0,o.useState)(null),J=(0,o.useMemo)(()=>[t,...b],[t,b]),X=J.map(e=>e.url).join("|"),{scope:Z,root:ee,checkout:et}=(0,$.ox)(t.id),en=(0,$.jV)(e=>e.setRepoRoot),es=(0,$.jV)(e=>e.setRepoCheckout),ea=(0,$.ec)(),er=(0,$.kG)(Z),ei=(0,$.jV)(e=>e.setListFilter),el=(0,P.y)(ee,et),eo=(0,o.useMemo)(()=>[...el.data?.sets??[]].sort((e,t)=>t.importedAt-e.importedAt),[el.data]),ed=(0,v.Y)(`ledgers:${g}:${X}`,async e=>Object.fromEntries(await Promise.all(J.map(async t=>{try{return[t.id,{ledger:await N.F.ledger(t.url,g,e),error:null}]}catch(n){if(e.aborted)throw n;return[t.id,{ledger:null,error:n instanceof Error?n.message:String(n)}]}})))),ec=(0,o.useCallback)((e,t)=>[...eo,...n].find(t=>t.name===e)?.steps.find(e=>e.version===t)??null,[eo,n]),eu=(0,o.useMemo)(()=>(0,k.x)(J.map(e=>({connection:e,ledger:ed.data?.[e.id]?.ledger??null})),f),[J,ed.data,f]),em=`/${encodeURIComponent(t.id)}/migrations`,eh=(0,o.useCallback)(t=>{let n=a(t.name);c(n,t.files),e.push(`${em}/${encodeURIComponent(n)}`)},[a,c,e,em]);async function ep(t){O(t),_(null);try{let n=await Promise.all(J.map(async e=>{try{return{read:await N.F.ledger(e.url,g,void 0,!0),error:null}}catch(e){return{read:null,error:e instanceof Error?e.message:String(e)}}})),s=n.find(e=>e.error);if(s?.error)return void _(s.error);let a=n.some(e=>e.read&&void 0===e.read.withSql),i=new Map;for(let{read:e}of n)for(let n of e?.entries??[]){if(n.setName.trim()!==t)continue;let e=i.get(n.version);e?.applySql||i.set(n.version,n)}let{set:l,missing:o}=(0,z.wQ)(t,[...i.values()]);if(0===l.steps.length)return void _(a?"The YTDB running on your machine is older than this page and cannot send stored SQL. Restart it with `npx @theobourgeois/ytdb@latest`.":`${t} was applied before YTDB stored SQL, so it cannot be rebuilt. Drop its folder instead.`);r(l),o.length>0&&_(`Rebuilt ${l.steps.length} of ${l.steps.length+o.length}. No SQL was stored for ${o.join(", ")}.`),e.push(`${em}/${encodeURIComponent(l.id)}`)}catch(e){_(e instanceof Error?e.message:String(e))}finally{O(null)}}let ex=(0,o.useMemo)(()=>[...n].sort((e,t)=>t.importedAt-e.importedAt),[n]),eg=(0,o.useMemo)(()=>(0,y.lF)(J.map(e=>({connection:e,ledger:ed.data?.[e.id]?.ledger??null})),[...eo,...n].map(e=>e.name)),[J,ed.data,eo,n]),ef=(0,o.useMemo)(()=>{let e=ed.data?.[t.id]?.ledger??null,n=[],s=0;if(!e)return{sets:0,entries:n};for(let t of eo){let a=(0,y.gj)(t,(0,y.Gf)(e,t.name));if(0!==a.steps.length)for(let e of(s+=1,a.steps))n.push({setName:t.name,version:e.version,name:e.name,checksum:e.checksum,applySql:e.applySql,revertSql:e.revertSql})}return{sets:s,entries:n}},[ed.data,t.id,eo]),ej=ed.loading||el.loading,eb=0===eo.length&&0===n.length&&0===eg.length,ev=(0,o.useCallback)(e=>J.map(t=>({connection:t,summary:(0,y.eh)(e,ed.data?.[t.id]?.ledger??null),read:!!ed.data?.[t.id]?.ledger,error:ed.data?.[t.id]?.error??null})),[J,ed.data]),eN=(0,o.useCallback)(e=>(0,y.yy)(e,ev(e).map(e=>({connectionId:e.connection.id,summary:e.summary,read:e.read})),er),[ev,er]),ek=(0,o.useMemo)(()=>eo.filter(eN),[eo,eN]),ey=(0,o.useMemo)(()=>ex.filter(eN),[ex,eN]),ew=""!==er.query.trim()||"all"!==er.status,e$="all"!==er.status&&void 0===ed.data,eC=e$?0:eo.length+ex.length-ek.length-ey.length;return(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,s.jsxs)(m.X,{children:[(0,s.jsx)(d.olY,{className:"size-4 shrink-0 text-muted-foreground"}),(0,s.jsx)("span",{className:"font-medium",children:"Migrations"}),ee&&(0,s.jsx)(B,{root:el.data?.root??ee,git:el.data?.git??null,checkouts:el.data?.checkouts??[],checkout:el.data?.checkout??null,onEdit:()=>K(!0),onPick:e=>es(Z,e)}),(0,s.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,s.jsx)(h.$,{size:"icon-sm",variant:"ghost",disabled:ej,"aria-label":"Refresh",title:ee?"Re-read the folder and every environment's ledger":"Re-read every environment's ledger",onClick:function(){ed.reload(),el.reload()},children:(0,s.jsx)(d.oS8,{className:(0,C.cn)(ej&&"animate-spin")})}),!ee&&(0,s.jsxs)(h.$,{size:"sm",variant:"ghost",onClick:()=>K(!0),children:[(0,s.jsx)(d.WzY,{"data-icon":"inline-start"}),"Read from a folder"]}),(0,s.jsxs)(h.$,{size:"sm",variant:"ghost",onClick:()=>T(!0),children:[(0,s.jsx)(d.enO,{"data-icon":"inline-start"}),"New migration"]}),(ee||n.length>0)&&(0,s.jsxs)(p.rI,{children:[(0,s.jsx)(p.ty,{render:(0,s.jsx)(h.$,{size:"icon-sm",variant:"ghost","aria-label":"More migration actions"}),className:"cursor-pointer",children:(0,s.jsx)(d.YKd,{})}),(0,s.jsxs)(p.SQ,{align:"end",className:"min-w-72",children:[ee&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(p._2,{disabled:ej||0===ef.entries.length,onClick:()=>H(ef),children:[(0,s.jsx)(d.nXx,{}),"Mark everything as applied on ",t.name,(0,s.jsx)("span",{className:"ml-auto pl-3 font-mono text-[11px] text-muted-foreground",children:ef.entries.length})]}),(0,s.jsx)(p.mB,{}),(0,s.jsxs)(p._2,{onClick:()=>K(!0),children:[(0,s.jsx)(d.WzY,{}),"Change folder…"]})]}),n.length>0&&(0,s.jsxs)(s.Fragment,{children:[ee&&(0,s.jsx)(p.mB,{}),(0,s.jsxs)(p._2,{variant:"destructive",onClick:function(){for(let e of n)x(e.id)},children:["Forget ",n.length," imported migration",1===n.length?"":"s"]})]})]})]})]})]}),el.error&&(0,s.jsxs)("p",{className:"flex items-start gap-2 border-b bg-destructive/5 px-4 py-1.5 text-xs text-destructive",children:[(0,s.jsx)(d.e5t,{className:"mt-px size-3.5 shrink-0"}),(0,s.jsx)("span",{className:"min-w-0 flex-1",children:el.error}),(0,s.jsx)(h.$,{size:"xs",variant:"ghost",onClick:()=>K(!0),children:"Change folder"})]}),"history"===I?(0,s.jsx)(j.F,{className:"min-h-0 flex-1",children:(0,s.jsx)(S.H,{events:eu,connections:J,loading:ed.loading,ledgerSchema:g,findStep:ec,onLedgerChange:ed.reload})}):ea?eb&&ee&&el.loading?(0,s.jsxs)("p",{className:"px-4 py-6 text-sm text-muted-foreground",children:["Reading ",ee,"…"]}):eb&&ee?(0,s.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 p-6 text-center",children:[(0,s.jsxs)("p",{className:"text-sm",children:["Nothing in ",ee," yet."]}),(0,s.jsx)("p",{className:"max-w-md text-xs text-muted-foreground",children:"Each folder inside it that holds .sql files becomes a migration here, the moment it exists on the branch you have checked out."})]}):eb?(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-4 p-6",children:[(0,s.jsx)(M.k,{onFiles:eh,className:"w-full max-w-xl"}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Or"," ",(0,s.jsx)("button",{type:"button",className:"cursor-pointer underline underline-offset-4 hover:text-foreground",onClick:()=>K(!0),children:"read straight from a folder on this computer"}),", so nothing has to be imported."]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Y,{filter:er,environments:J,hidden:eC,onChange:e=>ei(Z,e)}),(0,s.jsx)(j.F,{className:"min-h-0 flex-1",children:e$?(0,s.jsx)("p",{className:"px-4 py-6 text-sm text-muted-foreground",children:"Reading ledgers…"}):(0,s.jsxs)(s.Fragment,{children:[ek.map(e=>(0,s.jsx)(W,{set:e,href:`${em}/${encodeURIComponent(e.id)}`,environments:ev(e)},e.id)),ey.length>0&&ee&&(0,s.jsx)("p",{className:"border-b px-4 pt-2.5 pb-1 text-[11px] font-medium tracking-wide text-muted-foreground uppercase",title:"Imported into this browser rather than read from the folder.",children:"Imported"}),ey.map(e=>(0,s.jsx)(W,{set:e,href:`${em}/${encodeURIComponent(e.id)}`,environments:ev(e)},e.id)),ew&&0===ek.length&&0===ey.length&&(0,s.jsxs)("p",{className:"px-4 py-6 text-sm text-muted-foreground",children:["Nothing matches."," ",(0,s.jsx)("button",{type:"button",className:"cursor-pointer underline underline-offset-4 hover:text-foreground",onClick:()=>ei(Z,{query:"",status:"all"}),children:"Clear the filter"})]}),eg.length>0&&(0,s.jsxs)("div",{className:"border-b bg-muted/20",children:[(0,s.jsx)("p",{className:"px-4 pt-2.5 pb-1 text-[11px] font-medium tracking-wide text-muted-foreground uppercase",title:"Applied to a database from elsewhere. The SQL is kept in its ledger, so it opens without the folder.",children:"In the ledger only"}),eg.map(e=>(0,s.jsx)(G,{migration:e,busy:q===e.name,onOpen:()=>void ep(e.name)},e.name)),L&&(0,s.jsx)("p",{className:"px-4 pt-1 pb-2 text-xs text-destructive",children:L})]}),!ee&&(0,s.jsx)("div",{className:"p-4",children:(0,s.jsx)(M.k,{onFiles:eh,compact:!0,className:"w-full"})})]})})]}):(0,s.jsx)("div",{className:"min-h-0 flex-1"}),(0,s.jsx)(R.lj,{caption:function(e,t,n,s){if(s&&0===e)return"Reading folder…";if(0===e&&0===t&&0===n)return"No migrations yet";let a=[];return e>0&&a.push(`${e} migration${1===e?"":"s"} on disk`),t>0&&a.push(`${t} imported`),n>0&&a.push(`${n} in the ledger only`),a.join(" \xb7 ")}(eo.length,n.length,eg.length,null!==ee&&el.loading),pane:I,onPaneChange:n=>{n!==I&&e.push((0,l.Jn)({kind:"migrations",connectionId:t.id,view:"history"===n?"timeline":void 0}),{scroll:!1})},historyCount:eu.length}),U&&(0,s.jsx)(Q,{root:ee,environmentNames:J.map(e=>e.name),onOpenChange:K,onSave:e=>en(Z,e)}),D&&(0,s.jsx)(V,{connection:t,ledgerSchema:g,plan:D,onDone:()=>ed.reload(),onOpenChange:e=>!e&&H(null)}),(0,s.jsx)(F.K,{open:A,title:"New migration",submitLabel:"Create",onOpenChange:T,onSubmit:function(t){let n=a(t);e.push(`${em}/${encodeURIComponent(n)}`)}})]})}let U={all:"All",pending:"Not fully applied",untouched:"Not started anywhere",complete:"Applied everywhere"};function Y({filter:e,environments:t,hidden:n,onChange:a}){let r="all"!==e.status;return(0,s.jsxs)("div",{className:"flex items-center gap-1 border-b px-2 py-1",children:[(0,s.jsx)(b.L,{value:e.query,onChange:e=>a({query:e.target.value}),placeholder:"Search migrations","aria-label":"Search migrations",className:"min-w-0 flex-1",trailing:e.query?(0,s.jsx)("button",{type:"button","aria-label":"Clear search",className:"cursor-pointer rounded p-0.5 hover:text-foreground",onClick:()=>a({query:""}),children:(0,s.jsx)(d.yBK,{className:"size-3.5"})}):null}),(0,s.jsxs)(p.rI,{children:[(0,s.jsxs)(p.ty,{render:(0,s.jsx)(h.$,{size:"sm",variant:r?"outline":"ghost"}),className:"cursor-pointer",children:[function(e,t){if(e.startsWith("pending:")){let n=t.find(t=>t.id===e.slice(8));return n?`Pending on ${n.name}`:U.pending}return U[e]}(e.status,t),(0,s.jsx)(d.RQe,{"data-icon":"inline-end"})]}),(0,s.jsx)(p.SQ,{align:"end",className:"min-w-56",children:(0,s.jsxs)(p.Hr,{value:e.status,onValueChange:e=>a({status:e}),children:[Object.keys(U).map(e=>(0,s.jsx)(p.Ht,{value:e,children:U[e]},e)),t.length>1&&(0,s.jsx)(p.mB,{}),t.length>1&&t.map(e=>(0,s.jsxs)(p.Ht,{value:`pending:${e.id}`,children:[(0,s.jsx)(c.F,{connection:e,className:"size-1.5"}),"Pending on ",e.name]},e.id))]})})]}),n>0&&(0,s.jsxs)("span",{className:"shrink-0 pr-1 text-[11px] tabular-nums text-muted-foreground",children:[n," hidden"]})]})}function B({root:e,git:t,checkouts:n,checkout:a,onEdit:r,onPick:i}){var l;let c,[u,m]=(0,o.useState)(""),h=(0,o.useMemo)(()=>{let e=u.trim().toLowerCase();return e?n.filter(t=>t.branch.toLowerCase().includes(e)||t.path.toLowerCase().includes(e)):n},[n,u]),p="cursor-pointer rounded-md outline-none hover:bg-muted/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60",j=t&&(0,s.jsxs)("span",{className:"shrink-0 rounded border px-1.5 font-mono text-[10px]",children:[t.branch,t.dirty&&"*"]});return(0,s.jsxs)("div",{className:"flex min-w-0 items-center text-xs text-muted-foreground",children:[(0,s.jsxs)("button",{type:"button",title:`Reading from ${e}. Click to change.`,onClick:r,className:(0,C.cn)("flex min-w-0 items-center gap-1.5 px-1.5 py-0.5",p),children:[(0,s.jsx)(d.WzY,{className:"size-3.5 shrink-0"}),(0,s.jsx)("span",{className:"max-w-64 truncate font-mono text-[11px]",children:(c=(l=e).split(/[\/]/).filter(Boolean)).length>2?`…/${c.slice(-2).join("/")}`:l})]}),t&&n.length>1?(0,s.jsxs)(f.G3,{items:h,filter:null,value:n.find(e=>e.path===a)??null,inputValue:u,onInputValueChange:e=>m(e),onOpenChange:e=>e&&m(""),itemToStringLabel:e=>e.branch,isItemEqualToValue:(e,t)=>e.path===t.path,onValueChange:e=>e&&i(e.path),children:[(0,s.jsxs)(x.M,{title:`${t.branch} (${t.commit}${t.dirty?", uncommitted changes":""}). Read from another worktree.`,className:(0,C.cn)("flex shrink-0 items-center gap-0.5 px-1 py-0.5",p),children:[j,(0,s.jsx)(d.klM,{className:"size-3"})]}),(0,s.jsxs)(f.h5,{className:"w-max min-w-56",children:[(0,s.jsxs)("div",{className:"m-1 mb-0 flex h-8 items-center gap-1.5 rounded-lg px-2 text-muted-foreground focus-within:bg-muted/60",children:[(0,s.jsx)(d.TfF,{className:"size-3.5 shrink-0"}),(0,s.jsx)(g.o,{placeholder:"Search worktrees",spellCheck:!1,autoComplete:"off",className:"h-full min-w-0 flex-1 bg-transparent text-[0.8rem] text-foreground outline-none placeholder:text-muted-foreground"})]}),(0,s.jsx)(f.$U,{children:"No matching worktrees"}),(0,s.jsx)(f.ex,{children:e=>(0,s.jsx)(f.x4,{value:e,title:e.path,children:(0,s.jsx)("span",{className:"font-mono text-xs",children:e.branch})},e.path)})]})]}):t&&(0,s.jsx)("span",{className:"px-1",title:`${t.branch} (${t.commit}${t.dirty?", uncommitted changes":""})`,children:j})]})}function W({set:e,href:t,environments:n}){return(0,s.jsxs)(r(),{href:t,className:"flex items-center gap-3 border-b px-4 py-3 outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("p",{className:"flex min-w-0 items-center gap-1.5 text-sm font-medium",children:[(0,s.jsx)("span",{className:"truncate",children:e.name}),e.note&&(0,s.jsx)("span",{title:e.note,className:"shrink-0 text-muted-foreground",children:(0,s.jsx)(d.UA_,{className:"size-3.5"})})]}),(0,s.jsxs)("p",{className:"truncate text-xs text-muted-foreground",children:[0===e.steps.length?"No files yet":`${e.steps.length} migration${1===e.steps.length?"":"s"}`,e.steps.length>0&&` \xb7 ${e.steps[0].version}–${e.steps.at(-1)?.version}`,e.skipped.length>0&&` \xb7 ${e.skipped.length} skipped`]})]}),(0,s.jsx)("div",{className:"flex shrink-0 items-center gap-1.5",children:n.map(e=>(0,s.jsx)(K,{environment:e},e.connection.id))}),(0,s.jsx)(d.nNJ,{className:"size-4 shrink-0 text-muted-foreground/60"})]})}function G({migration:e,busy:t,onOpen:n}){return(0,s.jsxs)("div",{className:"flex items-center gap-3 border-t px-4 py-2.5 first:border-t-0",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"truncate text-sm",children:e.name}),(0,s.jsxs)("p",{className:"truncate text-xs text-muted-foreground",children:[e.total," migration",1===e.total?"":"s",e.versions.length>0&&` \xb7 ${e.versions[0]}–${e.versions.at(-1)}`]})]}),(0,s.jsx)("div",{className:"flex shrink-0 items-center gap-1.5",children:e.applied.map(t=>(0,s.jsxs)("span",{className:"flex h-6 items-center gap-1.5 rounded-lg border border-dashed px-2 text-[11px] text-muted-foreground",children:[(0,s.jsx)("span",{className:"max-w-24 truncate",children:t.connectionName}),(0,s.jsxs)("span",{className:"tabular-nums",children:[t.count,"/",e.total]})]},t.connectionId))}),(0,s.jsx)(h.$,{size:"xs",variant:"outline",disabled:t,onClick:n,children:t?"Opening…":"Open"})]})}function K({environment:e}){let{connection:t,summary:n,read:a,error:r}=e,i=a&&n.total>0&&0===n.pending&&0===n.drifted,l=a&&0===n.applied&&0===n.drifted;return(0,s.jsxs)("span",{title:r?`${t.name}: ${r}`:a?`${t.name}: ${n.applied} of ${n.total} applied`:`${t.name}: reading…`,className:(0,C.cn)("flex h-6 items-center gap-1.5 rounded-lg border px-2 text-[11px]",r&&"border-destructive/30 text-destructive",i&&"border-emerald-600/30 bg-emerald-500/10",!r&&!i&&!l&&"border-amber-600/30 bg-amber-500/10",l&&"text-muted-foreground"),children:[(0,s.jsx)(c.F,{connection:t,className:"size-1.5"}),(0,s.jsx)("span",{className:"max-w-24 truncate",children:t.name}),(0,s.jsx)("span",{className:"tabular-nums",children:r?"—":a?`${n.applied}/${n.total}`:"…"})]})}},85488:(e,t,n)=>{"use strict";n.d(t,{G3:()=>C,h5:()=>F,$U:()=>I,oK:()=>M,x4:()=>E,ex:()=>R});var s=n(95155);n(12115);var a=n(92953),r=n(66289),i=n(58565),l=n(91075),o=n(2385),d=n(19001),c=n(93313),u=n(29432),m=n(56758),h=n(47028),p=n(63205),x=n(40980),g=n(89239),f=n(18460),j=n(60529);function b({className:e,...t}){return(0,s.jsx)("div",{"data-slot":"input-group",role:"group",className:(0,x.cn)("group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",e),...t})}n(18349);let v=(0,f.F)("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]","inline-end":"order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]","block-start":"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2","block-end":"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"}},defaultVariants:{align:"inline-start"}});function N({className:e,align:t="inline-start",...n}){return(0,s.jsx)("div",{role:"group","data-slot":"input-group-addon","data-align":t,className:(0,x.cn)(v({align:t}),e),onClick:e=>{e.target.closest("button")||e.currentTarget.parentElement?.querySelector("input")?.focus()},...n})}let k=(0,f.F)("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",sm:"","icon-xs":"size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function y({className:e,type:t="button",variant:n="ghost",size:a="xs",...r}){return(0,s.jsx)(g.$,{type:t,"data-size":a,variant:n,className:(0,x.cn)(k({size:a}),e),...r})}function w({className:e,...t}){return(0,s.jsx)(j.p,{"data-slot":"input-group-control",className:(0,x.cn)("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",e),...t})}var $=n(13267);let C=a.i;function S({className:e,children:t,...n}){return(0,s.jsxs)(r.M,{"data-slot":"combobox-trigger",className:(0,x.cn)("[&_svg:not([class*='size-'])]:size-4",e),...n,children:[t,(0,s.jsx)($.RQe,{className:"pointer-events-none size-4 text-muted-foreground"})]})}function z({className:e,...t}){return(0,s.jsx)(i.V,{"data-slot":"combobox-clear",render:(0,s.jsx)(y,{variant:"ghost",size:"icon-xs"}),className:(0,x.cn)(e),...t,children:(0,s.jsx)($.yBK,{className:"pointer-events-none"})})}function M({className:e,children:t,disabled:n=!1,showTrigger:a=!0,showClear:r=!1,inputRef:i,...o}){return(0,s.jsxs)(b,{className:(0,x.cn)("w-auto",e),children:[(0,s.jsx)(l.o,{ref:i,render:(0,s.jsx)(w,{disabled:n}),...o}),(0,s.jsxs)(N,{align:"inline-end",children:[a&&(0,s.jsx)(y,{size:"icon-xs",variant:"ghost",render:(0,s.jsx)(S,{}),"data-slot":"input-group-button",className:"group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent",disabled:n}),r&&(0,s.jsx)(z,{disabled:n})]}),t]})}function F({className:e,side:t="bottom",sideOffset:n=6,align:a="start",alignOffset:r=0,anchor:i,...l}){return(0,s.jsx)(o.K,{children:(0,s.jsx)(d.o,{side:t,sideOffset:n,align:a,alignOffset:r,anchor:i,className:"isolate z-80",children:(0,s.jsx)(c.I,{"data-slot":"combobox-content","data-chips":!!i,className:(0,x.cn)("group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[chips=true]:min-w-(--anchor-width) data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-8 *:data-[slot=input-group]:border-input/30 *:data-[slot=input-group]:bg-input/30 *:data-[slot=input-group]:shadow-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...l})})})}function R({className:e,...t}){return(0,s.jsx)(u.e,{"data-slot":"combobox-list",className:(0,x.cn)("no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0",e),...t})}function E({className:e,children:t,...n}){return(0,s.jsxs)(m.x,{"data-slot":"combobox-item",className:(0,x.cn)("relative flex h-8 w-full cursor-pointer items-center gap-2 rounded-lg pr-8 pl-2 text-sm outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...n,children:[t,(0,s.jsx)(h.Q,{render:(0,s.jsx)("span",{className:"pointer-events-none absolute right-2 flex size-4 items-center justify-center"}),children:(0,s.jsx)($.wiW,{className:"pointer-events-none"})})]})}function I({className:e,...t}){return(0,s.jsx)(p.$,{"data-slot":"combobox-empty",className:(0,x.cn)("hidden w-full justify-center py-2 text-center text-sm text-muted-foreground group-data-empty/combobox-content:flex",e),...t})}}},e=>{e.O(0,[4506,1731,8026,2435,8361,8322,3960,544,6090,1413,228,8441,3794,7358],()=>e(e.s=28330)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[106,828,831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4909,4956,5047,5374,5721,5794,5838,6053,6258,6306,6636,6819,6986,6988,7761,7851,7981,8167,8464,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|
package/.next/static/chunks/app/[connectionId]/migrations/(index)/timeline/page-34cb852b3259a90b.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[106,828,831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4909,4956,5047,5374,5721,5794,5838,6053,6258,6306,6636,6819,6986,6988,7761,7851,7981,8167,8464,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|