trybeacon 0.1.68 → 0.1.69
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/.claude-plugin/plugin.json +1 -1
- package/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +17 -17
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +3 -3
- 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/_global-error.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +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 +11 -11
- package/.next/server/app/_not-found.segments/_full.segment.rsc +11 -11
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +11 -11
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/docs.html +1 -1
- package/.next/server/app/docs.rsc +11 -11
- package/.next/server/app/docs.segments/_full.segment.rsc +11 -11
- package/.next/server/app/docs.segments/_head.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_index.segment.rsc +11 -11
- package/.next/server/app/docs.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/docs.segments/docs.segment.rsc +1 -1
- package/.next/server/app/help/page_client-reference-manifest.js +1 -1
- package/.next/server/app/help.html +1 -1
- package/.next/server/app/help.rsc +11 -11
- package/.next/server/app/help.segments/_full.segment.rsc +11 -11
- package/.next/server/app/help.segments/_head.segment.rsc +1 -1
- package/.next/server/app/help.segments/_index.segment.rsc +11 -11
- package/.next/server/app/help.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/help.segments/help/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/help.segments/help.segment.rsc +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +11 -11
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/index.segments/_full.segment.rsc +11 -11
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +11 -11
- package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/learn/page.js +2 -2
- package/.next/server/app/learn/page.js.nft.json +1 -1
- package/.next/server/app/learn/page_client-reference-manifest.js +1 -1
- package/.next/server/app/map/page.js +1 -1
- package/.next/server/app/map/page.js.nft.json +1 -1
- package/.next/server/app/map/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/plan/page.js +2 -2
- package/.next/server/app/plan/page.js.nft.json +1 -1
- package/.next/server/app/plan/page_client-reference-manifest.js +1 -1
- package/.next/server/app/s/[token]/page.js +1 -1
- package/.next/server/app/s/[token]/page.js.nft.json +1 -1
- package/.next/server/app/s/[token]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +17 -17
- package/.next/server/chunks/2025.js +1 -1
- package/.next/server/chunks/4307.js +1 -1
- package/.next/server/chunks/9113.js +1 -0
- 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/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/471-714d0bdb155d49f1.js +1 -0
- package/.next/static/chunks/{4853-6dc402b4ce452fa5.js → 4853-946597034e74be36.js} +1 -1
- package/.next/static/chunks/app/layout-d3b7276f116dce46.js +1 -0
- package/.next/static/chunks/app/learn/page-f6a8683aa37b3913.js +7 -0
- package/.next/static/chunks/app/map/page-8aa811a0fa1d0733.js +1 -0
- package/.next/static/chunks/app/plan/page-633c2fe6cc10ca69.js +1 -0
- package/.next/static/chunks/app/s/[token]/page-aa6650d3a259d00f.js +1 -0
- package/.next/static/css/b51708465127fded.css +1 -0
- package/.next/trace +43 -43
- package/.next/trace-build +1 -1
- package/package.json +1 -1
- package/.next/server/chunks/6709.js +0 -1
- package/.next/static/chunks/6371-9ebaddaf512402a4.js +0 -1
- package/.next/static/chunks/app/layout-e46e1337e196e904.js +0 -1
- package/.next/static/chunks/app/learn/page-4193bf2f60c4f812.js +0 -7
- package/.next/static/chunks/app/map/page-6f0139228ec52538.js +0 -1
- package/.next/static/chunks/app/plan/page-5addc50440c40167.js +0 -1
- package/.next/static/chunks/app/s/[token]/page-13976553e707cad8.js +0 -1
- package/.next/static/css/ac0b6ff5058ccc12.css +0 -1
- /package/.next/static/{ZEJwYPSMMES2UlUBBgBmw → kE60KTZ3HV1PLiD-qqEBH}/_buildManifest.js +0 -0
- /package/.next/static/{ZEJwYPSMMES2UlUBBgBmw → kE60KTZ3HV1PLiD-qqEBH}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4853],{44853:(e,t,n)=>{n.d(t,{DbMapClient:()=>ek});var a=n(95155),s=n(12115),o=n(80277),l=n(73321),i=n(81750),r=n(6266);n(53255);var d=n(32133),c=n(81499),m=n(51128),u=n(65738),p=n(9005),h=n(2125),f=n(91337),x=n(18874);let b=(0,s.createContext)(null);function g(){let e=(0,s.useContext)(b);if(!e)throw Error("useDbEdit must be used inside DbEditContext");return e}var y=n(29523),j=n(70221),k=n(95635),w=n(17918);let N={danger:"bg-red-500/15 text-red-300",warn:"bg-amber-500/15 text-amber-300"};function v({badges:e,className:t}){return e.length?(0,a.jsx)("span",{className:(0,f.cn)("flex shrink-0 items-center gap-0.5",t),children:e.map(e=>(0,a.jsx)("span",{title:e.title,className:(0,f.cn)("rounded px-1 text-[8px] font-semibold uppercase tracking-wide",N[e.tone]),children:e.label},e.label))}):null}let C=/pass(word)?|token|secret|api[_-]?key|credential|priv(ate)?[_-]?key|hash|salt/i,T=/auth|login|logout|session|token|password|oauth|sso|credential/i,M="nodrag nopan",S=k.x;function E({onClick:e,title:t}){return(0,a.jsx)("button",{type:"button",title:t,onClick:t=>{t.stopPropagation(),e()},className:(0,f.cn)(M,"absolute -right-3 top-1/2 z-10 flex size-6 -translate-y-1/2 items-center justify-center rounded-full border border-white/15 bg-[#242428] text-muted-foreground opacity-0 shadow-md transition-all group-hover/row:opacity-100 hover:border-[#ff7a45]/50 hover:text-[#ff7a45]"),children:(0,a.jsx)(d.A,{className:"size-3"})})}function I({c:e,fkTargets:t}){let n=t?.[e.name];return(0,a.jsx)("span",{title:n?`→ ${n}`:e.type,className:"ml-auto min-w-0 truncate font-mono text-[11px] text-muted-foreground/80",children:n?(0,a.jsxs)(a.Fragment,{children:["→\xa0",n]}):e.type})}let $=(0,s.memo)(function({id:e,data:t,selected:n}){var o;let l,i,r="DRAFT"===t.source,d="added"===t.diffStatus?"#7bd389":"modified"===t.diffStatus?"#ffb86b":"#4ea1ff",b="added"===t.diffStatus||"modified"===t.diffStatus,N="added"===t.diffStatus?"new":"modified"===t.diffStatus?"modify":"in plan",T=t.diffChanges?.length?t.diffChanges.join("\n"):"in this plan — no column change",$=r?d:(0,x.qA)(t.domain),A=(o={domain:t.domain,columns:t.columns},l=[],(i=o.columns.filter(e=>C.test(e.name)).map(e=>e.name)).length&&l.push({label:"secrets",tone:"danger",title:`stores credentials: ${i.join(", ")}`}),o.domain&&/auth/i.test(o.domain)&&l.push({label:"auth",tone:"warn",title:"auth-domain table"}),l),P=g(),[z,D]=(0,s.useState)(t.name),[F,R]=(0,s.useState)(t.columns),[O,L]=(0,s.useState)(!1);(0,s.useEffect)(()=>{D(t.name),R(t.columns)},[t.rev]);let K=e=>e.stopPropagation(),B=t=>{R(t),P.patchTable(e,{columns:t})},H=(t.pins??[]).filter(e=>null===e.column),_=e=>(t.pins??[]).filter(t=>t.column===e),Z=function(e,t,n,a=!1,s){return Math.min(312,Math.max(240,Math.round(8*e.length)+90,...t.map(e=>{if(a){let t=s?.[e.name];return Math.round(7.3*Math.max(6,e.name.length+1)+(t?.kind==="modified"?8*t.detail.length:64))+94}let t=n?.[e.name]?n[e.name].length+2:e.type.length;return Math.round(7.3*e.name.length+6.7*t)+64})))}(t.name,r?F:t.columns,t.fkTargets,r,t.diffColumns),U=(0,f.cn)("relative rounded-xl border bg-[#161618]/95 text-card-foreground shadow-[0_18px_50px_-22px_rgba(0,0,0,0.9)] backdrop-blur",n&&"ring-2 ring-[var(--accent,#f5b942)]"),q=(0,y.k)(j.fE);return"full"!==q?(0,a.jsxs)("div",{className:(0,f.cn)(U,"border-white/10 px-3 py-2.5","far"===q&&!P.readOnly&&"!opacity-0"),style:{width:Z},children:[(0,a.jsx)(k.x,{}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block size-2 shrink-0 rounded-full",style:{background:$}}),(0,a.jsx)("span",{className:"truncate font-mono text-[15px] font-semibold",children:t.name})]})]}):r?(0,a.jsxs)("div",{className:(0,f.cn)(U,"group/card"),style:{width:Z,borderColor:`${d}59`},children:[(0,a.jsx)(S,{}),(0,a.jsxs)("div",{className:"group/row relative flex items-center gap-1.5 rounded-t-[11px] px-3 py-2",style:{background:`${d}14`},children:[(0,a.jsx)("input",{value:z,onChange:e=>D(e.target.value),onBlur:()=>{let n=z.trim();n&&n!==t.name&&P.patchTable(e,{name:n})},onKeyDown:e=>{K(e),"Enter"===e.key&&e.currentTarget.blur()},placeholder:"table",className:(0,f.cn)(M,"min-w-0 flex-1 bg-transparent font-mono text-[13px] font-semibold tracking-tight outline-none")}),(0,a.jsx)(v,{badges:A}),(0,a.jsx)("span",{title:T,className:(0,f.cn)("shrink-0 rounded-md border px-1.5 py-px font-mono text-[9px] font-semibold uppercase tracking-[0.14em]",!b&&"border-white/15 bg-white/5 text-muted-foreground"),style:b?{background:`${d}1f`,borderColor:`${d}55`,color:d}:void 0,children:N}),(0,a.jsx)("button",{type:"button",onClick:t=>{K(t),O?P.deleteTable(e):L(!0)},onBlur:()=>L(!1),title:"Delete table",className:(0,f.cn)(M,"shrink-0 transition-all",O?"text-red-300":"text-muted-foreground opacity-0 hover:text-red-300 group-hover/card:opacity-100"),children:(0,a.jsx)(u.A,{className:"size-3"})}),H.length>0?(0,a.jsx)(w.e0,{pins:H,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)(E,{title:`Comment on ${t.name}`,onClick:()=>t.onComment?.(t.name)})]}),(0,a.jsxs)("div",{className:"divide-y divide-white/[0.05]",children:[F.map((e,n)=>{let s=_(e.name),o=t.diffColumns?.[e.name],l=o?.kind==="added"?{background:"#7bd38914",boxShadow:"inset 2px 0 0 #7bd389"}:o?.kind==="modified"?{background:"#ffb86b14",boxShadow:"inset 2px 0 0 #ffb86b"}:void 0;return(0,a.jsxs)("div",{style:l,className:"group/row relative flex items-center gap-1.5 px-3 py-[5px] text-[12px]",children:[(0,a.jsx)("button",{type:"button",onClick:e=>{K(e),B(F.map((e,t)=>t===n?{...e,isPk:!e.isPk}:e))},title:"Primary key",className:(0,f.cn)(M,"shrink-0",e.isPk?"text-amber-300/90":"text-muted-foreground/40 hover:text-amber-300"),children:(0,a.jsx)(c.A,{className:"size-3"})}),(0,a.jsx)("button",{type:"button",onClick:e=>{K(e),B(F.map((e,t)=>t===n?{...e,isFk:!e.isFk}:e))},title:"Foreign key",className:(0,f.cn)(M,"shrink-0",e.isFk?"text-sky-400/80":"text-muted-foreground/40 hover:text-sky-400"),children:(0,a.jsx)(m.A,{className:"size-3"})}),(0,a.jsx)("input",{value:e.name,onChange:e=>R(t=>t.map((t,a)=>a===n?{...t,name:e.target.value}:t)),onBlur:()=>B(F),onKeyDown:K,placeholder:"column",style:{width:`${Math.max(6,e.name.length+1)}ch`},className:(0,f.cn)(M,"shrink-0 bg-transparent font-mono outline-none")}),(0,a.jsx)("span",{"aria-hidden":!0,className:"flex-1"}),t.fkTargets?.[e.name]?(0,a.jsxs)("span",{title:`→ ${t.fkTargets[e.name]}`,className:"min-w-0 shrink truncate text-right font-mono text-[11px] text-muted-foreground/80",children:["→\xa0",t.fkTargets[e.name]]}):o?.kind==="modified"?(0,a.jsx)("span",{title:`was changed — ${o.detail}`,className:(0,f.cn)(M,"min-w-0 shrink truncate text-right font-mono text-[11px] font-medium text-[#ffb86b]"),children:o.detail}):(0,a.jsx)("input",{value:e.type,onChange:e=>R(t=>t.map((t,a)=>a===n?{...t,type:e.target.value}:t)),onBlur:()=>B(F),onKeyDown:K,placeholder:"type",title:e.type,className:(0,f.cn)(M,"w-16 min-w-0 shrink bg-transparent text-right font-mono text-[11px] outline-none",o?.kind==="added"?"text-[#7bd389]":"text-muted-foreground/80")}),(0,a.jsx)("button",{type:"button",onClick:e=>{K(e),B(F.filter((e,t)=>t!==n))},title:"Remove column",className:(0,f.cn)(M,"shrink-0 text-muted-foreground/40 opacity-0 transition-opacity hover:text-red-300 group-hover/card:opacity-100"),children:(0,a.jsx)(p.A,{className:"size-3"})}),s.length>0?(0,a.jsx)(w.e0,{pins:s,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)(E,{title:`Comment on ${t.name}.${e.name}`,onClick:()=>t.onComment?.(`${t.name}.${e.name}`)})]},n)}),(0,a.jsxs)("button",{type:"button",onClick:e=>{K(e),B([...F,{name:"",type:"text",isPk:!1,isFk:!1,nullable:!0,note:null}])},className:(0,f.cn)(M,"flex w-full items-center gap-1 px-3 py-1.5 text-[10px] text-muted-foreground hover:text-foreground"),children:[(0,a.jsx)(h.A,{className:"size-3"})," column"]})]})]}):(0,a.jsxs)("div",{className:U,style:{width:Z,borderColor:`${$}3d`},children:[(0,a.jsx)(S,{}),(0,a.jsxs)("div",{className:"group/row relative flex items-center justify-between rounded-t-[11px] px-3 py-2",style:{background:`${$}14`},children:[(0,a.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-1.5 font-mono text-[13px] font-semibold tracking-tight",children:["INTROSPECTION"===t.source&&(0,a.jsx)("span",{title:"live — derived from your code",className:"inline-block size-1.5 shrink-0 rounded-full bg-emerald-400"}),(0,a.jsx)("span",{className:"truncate",title:t.name,children:t.name})]}),(0,a.jsxs)("span",{className:"flex shrink-0 items-center gap-1.5",children:["INTROSPECTION"!==t.source&&(0,a.jsx)("span",{title:"planned — not yet detected in code",className:"shrink-0 rounded-md border border-[#f5b942]/35 bg-[#f5b942]/10 px-1.5 py-px font-mono text-[9px] font-semibold uppercase tracking-[0.14em] text-[#f5b942]",children:"planned"}),(0,a.jsx)(v,{badges:A}),t.domain&&(0,a.jsx)("span",{className:"text-[9px] uppercase tracking-[0.14em]",style:{color:$},children:t.domain})]}),H.length>0?(0,a.jsx)(w.e0,{pins:H,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)(E,{title:`Comment on ${t.name}`,onClick:()=>t.onComment?.(t.name)})]}),(0,a.jsx)("div",{className:"divide-y divide-white/[0.05]",children:t.columns.map(e=>{let n=_(e.name);return(0,a.jsxs)("div",{className:"group/row relative flex items-center gap-2 px-3 py-[7px] text-[12px]",children:[e.isPk?(0,a.jsx)(c.A,{className:"size-3 shrink-0 text-amber-300/90"}):e.isFk?(0,a.jsx)(m.A,{className:"size-3 shrink-0 text-sky-400/80"}):(0,a.jsx)("span",{className:"size-3 shrink-0"}),(0,a.jsx)("span",{className:"shrink-0 whitespace-nowrap font-mono",children:e.name}),(0,a.jsx)(I,{c:e,fkTargets:t.fkTargets}),n.length>0?(0,a.jsx)(w.e0,{pins:n,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)(E,{title:`Comment on ${t.name}.${e.name}`,onClick:()=>t.onComment?.(`${t.name}.${e.name}`)})]},e.name)})})]})}),A="nodrag nopan",P=["GET","POST","PUT","PATCH","DELETE"],z=(0,s.memo)(function({id:e,data:t,selected:n}){var o;let l,i=x.e6[t.method]??"#8a8a8a",r="DRAFT"===t.source,c="added"===t.diffStatus?"#7bd389":"modified"===t.diffStatus?"#ffb86b":"#4ea1ff",m="added"===t.diffStatus?"new":"modified"===t.diffStatus?"changed":"draft",p=t.diffChanges?.length?t.diffChanges.join("\n"):"draft",h=(o={method:t.method,domain:t.domain,path:t.path},l=[],/^delete$/i.test(o.method.trim())&&l.push({label:"DELETE",tone:"danger",title:"destructive: deletes data"}),(o.domain&&/auth/i.test(o.domain)||T.test(o.path))&&l.push({label:"auth",tone:"warn",title:"auth-related endpoint"}),l),b=g(),[N,C]=(0,s.useState)(t.path),[M,S]=(0,s.useState)(!1);(0,s.useEffect)(()=>{C(t.path)},[t.rev]);let E=e=>e.stopPropagation(),I=(0,y.k)(j.fE);return"full"!==I?(0,a.jsxs)("div",{className:(0,f.cn)("relative flex w-[300px] items-center gap-2 rounded-lg border border-white/10 bg-[#161618]/95 px-2.5 py-2 text-card-foreground backdrop-blur",n&&"ring-2 ring-[var(--accent,#f5b942)]","far"===I&&!b.readOnly&&"!opacity-0"),children:[(0,a.jsx)(k.x,{}),(0,a.jsx)("span",{className:"shrink-0 font-mono text-[12px] font-bold",style:{color:i},children:t.method}),(0,a.jsx)("span",{title:t.path,className:"truncate font-mono text-[13px]",children:t.path})]}):(0,a.jsxs)("div",{className:(0,f.cn)("group relative flex w-[300px] items-center gap-2 rounded-lg border bg-[#161618]/95 px-2.5 py-1.5 text-card-foreground shadow-[0_12px_36px_-18px_rgba(0,0,0,0.9)] backdrop-blur",r?"border-dashed":"border-white/10",n&&"ring-2 ring-[var(--accent,#f5b942)]"),style:r?{borderColor:`${c}66`,background:`${c}0f`}:void 0,children:[(0,a.jsx)(k.x,{}),"INTROSPECTION"===t.source&&(0,a.jsx)("span",{title:"live — derived from your code",className:"inline-block size-1.5 shrink-0 rounded-full bg-emerald-400"}),r?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("select",{value:t.method,onChange:t=>b.patchEndpoint(e,{method:t.target.value}),onPointerDown:E,className:(0,f.cn)(A,"shrink-0 rounded bg-transparent text-[10px] font-bold outline-none"),style:{color:i},title:"Method",children:P.map(e=>(0,a.jsx)("option",{value:e,className:"bg-card text-foreground",children:e},e))}),(0,a.jsx)("input",{value:N,title:N,onChange:e=>C(e.target.value),onBlur:()=>{let n=N.trim();n&&n!==t.path&&b.patchEndpoint(e,{path:n})},onKeyDown:e=>{E(e),"Enter"===e.key&&e.currentTarget.blur()},className:(0,f.cn)(A,"min-w-0 flex-1 bg-transparent font-mono text-[11px] outline-none")}),(0,a.jsx)(v,{badges:h}),(0,a.jsx)("span",{title:p,className:"shrink-0 rounded px-1 py-0.5 text-[8px] font-semibold uppercase",style:{background:`${c}26`,color:c},children:m}),(0,a.jsx)("button",{type:"button",onClick:t=>{E(t),M?b.deleteEndpoint(e):S(!0)},onBlur:()=>S(!1),title:"Delete",className:(0,f.cn)(A,"shrink-0 transition-colors",M?"text-red-300":"text-muted-foreground hover:text-red-300"),children:(0,a.jsx)(u.A,{className:"size-3"})})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"rounded px-1.5 py-0.5 text-[10px] font-bold",style:{background:`${i}22`,color:i},children:t.method}),(0,a.jsx)("span",{title:t.path,className:"min-w-0 flex-1 break-all font-mono text-[11px] leading-tight [-webkit-box-orient:vertical] [-webkit-line-clamp:2] [display:-webkit-box] overflow-hidden",children:t.path}),"INTROSPECTION"!==t.source&&(0,a.jsx)("span",{title:"planned — not yet detected in code",className:"shrink-0 rounded-md border border-[#f5b942]/35 bg-[#f5b942]/10 px-1.5 py-px font-mono text-[8px] font-semibold uppercase tracking-[0.14em] text-[#f5b942]",children:"planned"}),(0,a.jsx)(v,{badges:h}),(0,a.jsx)("button",{type:"button",onClick:t=>{E(t),M?b.deleteRealEndpoint(e):S(!0)},onBlur:()=>S(!1),title:M?"Click again to delete":"Delete endpoint",className:(0,f.cn)(A,"shrink-0 opacity-0 transition-opacity group-hover:opacity-100",M?"text-red-300 opacity-100":"text-muted-foreground hover:text-red-300"),children:(0,a.jsx)(u.A,{className:"size-3"})})]}),(t.pins?.length??0)>0?(0,a.jsx)(w.e0,{pins:t.pins,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)("button",{type:"button",title:`Comment on ${t.method} ${t.path}`,onClick:e=>{E(e),t.onComment?.(`${t.method} ${t.path}`)},className:(0,f.cn)(A,"absolute -right-3 top-1/2 z-10 flex size-6 -translate-y-1/2 items-center justify-center rounded-full border border-white/15 bg-[#242428] text-muted-foreground opacity-0 shadow-md transition-all group-hover:opacity-100 hover:border-[#ff7a45]/50 hover:text-[#ff7a45]"),children:(0,a.jsx)(d.A,{className:"size-3"})})]})});var D=n(54698),F=n(82099),R=n(4474);let O=[{id:"claude",label:"Prompt p/ Claude Code",fn:function(e){let t=["Implement this database schema in this project, following its existing stack and conventions:",""];for(let n of e.tables){let e=`Table \`${n.name}\``+(n.domain?` (domain: ${n.domain})`:"")+(n.description?` — ${n.description}`:"");for(let a of(t.push(e),n.columns)){let e=[a.isPk&&"PK",a.isFk&&"FK",!1===a.nullable&&"NOT NULL"].filter(Boolean).join(", ");t.push(` - ${a.name}: ${a.type}`+(e?` [${e}]`:"")+(a.note?` — ${a.note}`:""))}t.push("")}if(e.relations.length){for(let n of(t.push("Foreign keys:"),e.relations))t.push(` - ${n.fromTable}.${n.fromColumn} -> ${n.toTable}.${n.toColumn}`);t.push("")}return t.push("Create the models/migrations using the project's existing ORM and patterns, wire the relationships, and keep table and column names exactly as given."),t.join("\n")}},{id:"dbml",label:"DBML",fn:function(e){let t=[];for(let n of e.tables){for(let e of(t.push(`Table ${n.name} {`),n.columns)){let n=[e.isPk&&"pk",!1===e.nullable&&!e.isPk&&"not null",e.note&&`note: '${e.note.replace(/'/g,"")}'`].filter(Boolean).join(", ");t.push(` ${e.name} ${e.type}`+(n?` [${n}]`:""))}t.push("}","")}for(let n of e.relations)t.push(`Ref: ${n.fromTable}.${n.fromColumn} > ${n.toTable}.${n.toColumn}`);return t.join("\n").trim()}},{id:"sql",label:"SQL DDL",fn:function(e){let t=[];for(let n of e.tables){t.push(`CREATE TABLE ${n.name} (`);let a=n.columns.map(e=>{let t=[` ${e.name} ${e.type}`];return e.isPk?t.push("PRIMARY KEY"):!1===e.nullable&&t.push("NOT NULL"),t.join(" ")}),s=e.relations.filter(e=>e.fromTable===n.name).map(e=>` FOREIGN KEY (${e.fromColumn}) REFERENCES ${e.toTable}(${e.toColumn})`);t.push([...a,...s].join(",\n")),t.push(");","")}return t.join("\n").trim()}}];function L({draftGraph:e}){let[t,n]=(0,s.useState)(null);if(0===e.tables.length)return null;async function o(t){await navigator.clipboard.writeText(t.fn(e)).catch(()=>{}),n(t.id),setTimeout(()=>n(null),1500)}return(0,a.jsxs)("div",{className:"space-y-2 rounded-xl border border-sky-400/20 bg-sky-500/[0.04] p-3",children:[(0,a.jsxs)("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-sky-300",children:["Rascunho \xb7 ",e.tables.length," tabelas"]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"copiar:"}),O.map(e=>(0,a.jsx)(R.$,{size:"sm",variant:"outline",className:"h-6 px-2 text-[11px]",onClick:()=>o(e),children:t===e.id?"✓":e.label},e.id))]})]})}function K({selected:e,tables:t,relations:n,endpoints:s,draftGraph:o,onClose:l,commentsContent:i,commentsCount:r=0,activeTab:c,onTabChange:m,onAddComment:u,topOffset:h}){let f,x,b=new Map(t.map(e=>[e.id,e.name])),g=!!i,y=c??"details",j=e?.kind==="table"?t.find(t=>t.id===e.id)?.name??null:e?.kind==="endpoint"&&(x=s.find(t=>t.id===e.id))?`${x.method} ${x.path}`:null;if(e?.kind==="table"){let o=t.find(t=>t.id===e.id);f=o?(0,a.jsx)(H,{table:o,relations:n,endpoints:s,nameById:b}):null}else if(e?.kind==="endpoint"){let t=s.find(t=>t.id===e.id);f=t?(0,a.jsx)(_,{ep:t,nameById:b}):null}else f=(0,a.jsx)(Z,{tables:t,relations:n,endpoints:s});return(0,a.jsxs)(F.b,{className:"absolute right-3 z-10 flex w-80 flex-col rounded-2xl",style:{top:h??12,maxHeight:`calc(100% - ${(h??12)+12}px)`},children:[g?(0,a.jsxs)("div",{className:"flex items-center justify-between border-b border-white/10 px-1 py-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,a.jsx)(B,{active:"details"===y,onClick:()=>m?.("details"),children:"Details"}),(0,a.jsxs)(B,{active:"comments"===y,onClick:()=>m?.("comments"),children:["Comments",r>0&&(0,a.jsx)("span",{className:"ml-1 rounded-full bg-white/10 px-1 text-[9px] font-semibold leading-4",children:r})]})]}),(0,a.jsx)("button",{onClick:l,title:"Close panel",className:"mr-1 rounded-md p-1 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,a.jsx)(p.A,{className:"size-4"})})]}):(0,a.jsxs)("div",{className:"flex items-center justify-between border-b border-white/10 px-3.5 py-2.5",children:[(0,a.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Panel"}),(0,a.jsx)("button",{onClick:l,title:"Close panel",className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,a.jsx)(p.A,{className:"size-4"})})]}),(0,a.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:"comments"===y&&g?(0,a.jsx)("div",{className:"p-3",children:i}):(0,a.jsxs)(a.Fragment,{children:[o.tables.length>0&&(0,a.jsx)("div",{className:"border-b border-white/10 p-3.5",children:(0,a.jsx)(L,{draftGraph:o})}),(0,a.jsxs)("div",{className:"p-4",children:[u&&j&&(0,a.jsxs)("button",{type:"button",onClick:()=>u(j),className:"mb-3 flex w-full items-center justify-center gap-1.5 rounded-lg border border-white/10 bg-white/[0.03] px-3 py-1.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:[(0,a.jsx)(d.A,{className:"size-3.5"}),"Comment on this ",e?.kind==="endpoint"?"endpoint":"table"]}),f]})]})})]})}function B({active:e,onClick:t,children:n}){return(0,a.jsx)("button",{type:"button",onClick:t,className:(0,f.cn)("flex items-center gap-1 rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors",e?"bg-white/10 text-foreground":"text-muted-foreground hover:text-foreground"),children:n})}function H({table:e,relations:t,endpoints:n,nameById:s}){let o=t.filter(t=>t.fromTableId===e.id),l=t.filter(t=>t.toTableId===e.id),i=n.map(t=>({e:t,u:t.tables.find(t=>t.tableId===e.id)})).filter(e=>e.u);return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-xs uppercase tracking-wide",style:{color:(0,x.qA)(e.domain)},children:e.domain??"table"}),(0,a.jsx)("h2",{className:"font-mono text-lg font-semibold",children:e.name}),e.description&&(0,a.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:e.description})]}),(0,a.jsx)(U,{title:`Columns (${e.columns.length})`,children:(0,a.jsx)("ul",{className:"space-y-0.5",children:e.columns.map(e=>(0,a.jsxs)("li",{className:"flex items-center gap-1.5 text-xs",children:[e.isPk?(0,a.jsx)(c.A,{className:"size-3 text-amber-400"}):e.isFk?(0,a.jsx)(m.A,{className:"size-3 text-sky-400"}):(0,a.jsx)("span",{className:"size-3"}),(0,a.jsx)("span",{className:"font-mono",children:e.name}),(0,a.jsxs)("span",{className:"ml-auto font-mono text-[10px] text-muted-foreground",children:[e.type,!e.nullable&&" \xb7NN"]})]},e.name))})}),o.length>0&&(0,a.jsx)(U,{title:"References (FK out)",children:(0,a.jsx)("ul",{className:"space-y-1 text-xs",children:o.map(e=>(0,a.jsxs)("li",{className:"font-mono text-muted-foreground",children:[e.fromColumn," → ",s.get(e.toTableId),".",e.toColumn]},e.id))})}),l.length>0&&(0,a.jsx)(U,{title:"Referenced by (FK in)",children:(0,a.jsx)("ul",{className:"space-y-1 text-xs",children:l.map(e=>(0,a.jsxs)("li",{className:"font-mono text-muted-foreground",children:[s.get(e.fromTableId),".",e.fromColumn]},e.id))})}),i.length>0&&(0,a.jsx)(U,{title:`Used by endpoints (${i.length})`,children:(0,a.jsx)("ul",{className:"space-y-1 text-xs",children:i.map(({e,u:t})=>(0,a.jsxs)("li",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{style:{color:x.e6[e.method]},className:"font-bold",children:e.method}),(0,a.jsx)("span",{className:"truncate font-mono",children:e.path}),(0,a.jsx)("span",{className:"ml-auto",style:{color:x.ru[t.access]},children:t.access})]},e.id))})})]})}function _({ep:e,nameById:t}){return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"rounded px-1.5 py-0.5 text-[11px] font-bold",style:{background:`${x.e6[e.method]}22`,color:x.e6[e.method]},children:e.method}),(0,a.jsx)("h2",{className:"mt-2 font-mono text-base font-semibold",children:e.path}),e.description&&(0,a.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:e.description})]}),(0,a.jsx)(U,{title:`Tables used (${e.tables.length})`,children:(0,a.jsx)("ul",{className:"space-y-1 text-xs",children:e.tables.map(e=>(0,a.jsxs)("li",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"font-mono",children:t.get(e.tableId)}),(0,a.jsx)("span",{className:"ml-auto",style:{color:x.ru[e.access]},children:e.access})]},e.tableId))})})]})}function Z({tables:e,relations:t,endpoints:n}){return(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-sm font-semibold",children:"Database"}),(0,a.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Live schema derived from your code. Click a table or endpoint to see details. Drag to rearrange — positions are saved."})]}),(0,a.jsxs)("dl",{className:"grid grid-cols-3 gap-2 text-center",children:[(0,a.jsx)(q,{label:"tables",value:e.length}),(0,a.jsx)(q,{label:"FKs",value:t.length}),(0,a.jsx)(q,{label:"endpoints",value:n.length})]}),(0,a.jsx)(U,{title:"Legend",children:(0,a.jsxs)("ul",{className:"space-y-1 text-xs text-muted-foreground",children:[(0,a.jsxs)("li",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(c.A,{className:"size-3 text-amber-400"})," primary key"]}),(0,a.jsxs)("li",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(m.A,{className:"size-3 text-sky-400"})," foreign key"]}),(0,a.jsx)("li",{children:"— gray line: FK relation between tables"}),(0,a.jsx)("li",{children:"– – dashed line: endpoint uses table (read/write)"})]})})]})}function U({title:e,children:t}){return(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e}),t]})}function q({label:e,value:t}){return(0,a.jsxs)("div",{className:"rounded-lg border border-white/10 bg-white/[0.03] py-2",children:[(0,a.jsx)("div",{className:"text-lg font-semibold",children:t}),(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:e})]})}var W=n(56614),G=n(9991),J=n(40654),Q=n(14983),V=n(62311);let X=new Set(["GET","HEAD","OPTIONS"]);var Y=n(44267),ee=n(94014);function et(e){return 36+30*Math.max(0,e)+16}let en="Unattached",ea=e=>(e??"").trim()||"—";function es(e,t){let n=new Map(e.map(e=>[e.id,e.name])),a=new Map;for(let e of t)for(let t of e.uses)n.has(t.tableId)&&a.set(t.tableId,(a.get(t.tableId)??0)+1);return new Map(t.map(e=>[e.id,function(e,t,n){let a=new Map;for(let n of e.uses)t.has(n.tableId)&&a.set(n.tableId,(a.get(n.tableId)??0)+1);let s=null;for(let[e,o]of a){if(null===s){s=e;continue}let l=a.get(s);if(o>l){s=e;continue}if(o<l)continue;let i=n?.get(e)??0,r=n?.get(s)??0;i<r?s=e:i===r&&0>t.get(e).localeCompare(t.get(s))&&(s=e)}return s}(e,n,a)]))}let eo=(e,t)=>e.path.localeCompare(t.path)||e.method.localeCompare(t.method)||e.id.localeCompare(t.id);var el=n(70947);let ei=e=>e.trim().toLowerCase();var er=n(85618),ed=n(80846),ec=n(17356),em=n(45486),eu=n(15330),ep=n(60976),eh=n(64577),ef=n(24692),ex=n(45437);let eb={dbTable:$,endpoint:z,annotation:w.Sh},eg={deletable:ef.I,annotation:ex.L},ey="beacon:db-draft",ej={proposedAt:0,status:"pending",tables:[],relations:[],endpoints:[]};function ek({tables:e,relations:t,endpoints:n,draft:d,workspaceId:c,embedded:m=!1,diffBase:p,draftRef:h,onEdit:g,controlRef:k,commentsContent:N,commentsCount:v=0,onAddComment:C,annotations:T,onPinClick:M,onUpdateComment:S,onRemoveComment:E,boardAnnotations:I,readOnly:$=!1}){let A=(0,l.useRouter)(),P=e.length+(d?.tables.length??0),z=n.length+(d?.endpoints.length??0),[F,R]=(0,s.useState)(z>0&&(m||0===P)),[O,L]=(0,s.useState)(null),[B,H]=(0,s.useState)(null),[_,Z]=(0,s.useState)(null),[U,q]=(0,s.useState)(!1),[ef,ex]=(0,s.useState)(!1),[ew,eN]=(0,s.useState)("details"),[ev,eC]=(0,s.useState)(!1),[eT,eM]=(0,s.useState)(""),eS=(0,s.useRef)(null),{tool:eE,setTool:eI,flowProps:e$}=(0,o.e)();(0,s.useEffect)(()=>{if(!$)return;let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>eS.current?.fitView({padding:.2,duration:0}))});return()=>{cancelAnimationFrame(t),cancelAnimationFrame(e)}},[$,d,F]),(0,s.useEffect)(()=>{if(k)return k.current={open:()=>{q(!0),eN("details")},close:()=>{q(!1),eN("details")},openComments:()=>{q(!0),eN("comments")}},()=>{k&&(k.current=null)}},[k]);let[eA,eP]=(0,s.useState)(new Set),[ez,eD]=(0,s.useState)("full"),[eF,eR]=(0,s.useState)(new Set),[eO,eL]=(0,s.useState)(new Set),[eK,eB]=(0,s.useState)(()=>({past:[],present:d??ej,future:[],rev:0,edited:!1})),eH=eK.present,e_=(0,s.useCallback)(e=>{eB(t=>{let n=e(t.present);return n===t.present?t:{past:[...t.past,t.present].slice(-100),present:n,future:[],rev:t.rev+1,edited:!0}})},[]),eZ=(0,s.useCallback)(e=>{eB(t=>{let n=e(t.present);return n===t.present?t:{...t,present:n}})},[]),eU=(0,s.useCallback)(()=>eB(e=>e.past.length?{past:e.past.slice(0,-1),present:e.past[e.past.length-1],future:[e.present,...e.future],rev:e.rev+1,edited:!0}:e),[]),eq=(0,s.useCallback)(()=>eB(e=>e.future.length?{past:[...e.past,e.present],present:e.future[0],future:e.future.slice(1),rev:e.rev+1,edited:!0}:e),[]),eW=(0,s.useCallback)(e=>eB(t=>({past:[],present:e,future:[],rev:t.rev+1,edited:!1})),[]),eG=(0,s.useRef)(!1),eJ=d?.proposedAt??0;(0,s.useEffect)(()=>{let e=null;if(eG.current)d&&d.proposedAt!==eH.proposedAt?e=d:!d&&(eH.tables.length>0||eH.endpoints.length>0)&&(e=ej);else{eG.current=!0;let t=null;try{let e=localStorage.getItem(ey);if(e){let n=JSON.parse(e);n.workspaceId===c&&n.doc&&d&&n.doc.proposedAt===d.proposedAt&&(t=n.doc)}}catch{}e=t??d??null}e&&eW(e)},[eJ]),(0,s.useEffect)(()=>{try{eH.tables.length>0||eH.endpoints.length>0?localStorage.setItem(ey,JSON.stringify({workspaceId:c,doc:eH})):localStorage.removeItem(ey)}catch{}},[eH,c]),(0,s.useEffect)(()=>{h&&(h.current=eH)},[h,eH]);let eQ=(0,s.useRef)(!1);(0,s.useEffect)(()=>{eK.edited&&!eQ.current&&(eQ.current=!0,g?.())},[eK.edited,g]);let eV=(0,s.useMemo)(()=>eH.tables.map(e=>({id:e.id,name:e.name,domain:e.domain,description:e.description,source:"DRAFT",x:e.x,y:e.y,columns:e.columns})),[eH]),eX=(0,s.useMemo)(()=>eH.endpoints.map(e=>({id:e.id,method:e.method,path:e.path,domain:e.domain,description:e.description,source:"DRAFT",x:e.x,y:e.y,tables:e.links.map(e=>({tableId:e.tableId,access:e.access}))})),[eH]),eY=(0,s.useMemo)(()=>[...e,...eV],[e,eV]),e0=(0,s.useMemo)(()=>[...n,...eX],[n,eX]),e1=(0,s.useMemo)(()=>(function(e,t,n={}){let a=es(e,t),s=new Map,o=[];for(let e of[...t].sort(eo)){let t=a.get(e.id)??null;if(t){let n=s.get(t);n?n.push(e):s.set(t,[e])}else o.push(e)}let l=e=>{let t=s.get(e.id)?.length??0;return et(e.columnCount)+(t?10+60*t:0)+30},i=Array.from(new Set(e.map(e=>ea(e.domain)))),r=i.filter(e=>"—"!==e).sort(),d=i.includes("—")?[...r,"—"]:r,c=[];for(let t of d){let n=e.filter(e=>ea(e.domain)===t).sort((e,t)=>e.name.localeCompare(t.name)),a=n.reduce((e,t)=>e+l(t),0),s=Math.max(1,Math.min(12,n.length,Math.round(Math.sqrt(a/320)))),o=Array(s).fill(0),i=new Map;for(let e of n){let t=0;for(let e=1;e<s;e++)o[e]<o[t]&&(t=e);i.set(e.id,{x:320*t,y:o[t]}),o[t]+=l(e)}c.push({d:t,w:320*s,h:Math.max(...o,0),tableLocal:i})}let m=(0,ee.Xi)(c.map(e=>({id:e.d,w:e.w,h:e.h})),{gapX:84,gapY:72,viewportAspect:n.viewportAspect,minBandW:960,aspectSlack:1.7}),u=new Map,p=new Map,h=0;for(let t of c){let n=m.get(t.d);for(let a of e.filter(e=>t.tableLocal.has(e.id))){let e=t.tableLocal.get(a.id),o=n.x+e.x,l=n.y+e.y;u.set(a.id,{x:o,y:l}),(s.get(a.id)??[]).forEach((e,t)=>{p.set(e.id,{x:o,y:l+et(a.columnCount)+10+60*t})})}h=Math.max(h,n.y+t.h)}if(o.length){let e=h+72,t=Math.max(1,Math.min(4,Math.ceil(Math.sqrt(o.length/2))));o.forEach((n,a)=>{p.set(n.id,{x:a%t*300,y:e+60*Math.floor(a/t)})})}return{tables:u,endpoints:p}})(eY.map(e=>({id:e.id,name:e.name,domain:e.domain,columnCount:e.columns.length})),[]).tables,[eY]),e5=(0,s.useMemo)(()=>new Map,[]),e2=(0,s.useMemo)(()=>m?function(e,t){let n=new Map(e.map(e=>[ei(e.name),e])),a=new Map;for(let e of t){let t=n.get(ei(e.name));if(!t){a.set(e.id,{status:"added",changes:["new table"],columns:{}});continue}let{changes:s,columns:o}=function(e,t){let n=new Map(e.map(e=>[ei(e.name),e])),a=new Set(t.map(e=>ei(e.name))),s=[],o={};for(let e of t){let t=n.get(ei(e.name));if(!t){s.push(`+ column ${e.name} (${e.type})`),o[e.name]={kind:"added",detail:"new column"};continue}let a=[],l=[];if(ei(t.type)!==ei(e.type)&&(a.push(`type ${t.type}→${e.type}`),l.push(`${t.type}→${e.type}`)),t.isPk!==e.isPk){let t=e.isPk?"now PK":"no longer PK";a.push(t),l.push(t)}if(t.isFk!==e.isFk){let t=e.isFk?"now FK":"no longer FK";a.push(t),l.push(t)}if(t.nullable!==e.nullable){let t=e.nullable?"now nullable":"now required";a.push(t),l.push(t)}a.length&&(s.push(`~ column ${e.name}: ${a.join(", ")}`),o[e.name]={kind:"modified",detail:l.join(" \xb7 ")})}for(let t of e)a.has(ei(t.name))||s.push(`- column ${t.name}`);return{changes:s,columns:o}}(t.columns,e.columns);a.set(e.id,{status:s.length?"modified":"unchanged",changes:s,columns:o})}return a}(p?.tables??e,eV):e5,[m,p,e,eV,e5]),e3=(0,s.useMemo)(()=>m?function(e,t){let n=e=>`${ei(e.method)} ${ei(e.path)}`,a=new Set(e.map(n)),s=new Map;for(let e of t)s.set(e.id,a.has(n(e))?{status:"unchanged",changes:[],columns:{}}:{status:"added",changes:["new endpoint"],columns:{}});return s}(p?.endpoints??n,eX):e5,[m,p,n,eX,e5]),e4=(0,s.useMemo)(()=>[...t,...eH.relations.map(e=>({id:e.id,fromTableId:e.fromTableId,toTableId:e.toTableId,fromColumn:e.fromColumn,toColumn:e.toColumn,label:e.label}))],[t,eH.relations]),e6=(0,s.useMemo)(()=>{let e=new Map;for(let t of e0)for(let n of t.tables)e.set(n.tableId,(e.get(n.tableId)??0)+1);return e},[e0]),e8=(0,s.useMemo)(()=>{let e=new Map;return eY.forEach(t=>e.set(t.id,t.x)),e0.forEach(t=>e.set(t.id,t.x)),e},[eY,e0]),e9=(0,s.useMemo)(()=>{let e=new Map;return eY.forEach(t=>e.set(t.id,t.y)),e0.forEach(t=>e.set(t.id,t.y)),e},[eY,e0]),e7=(0,s.useMemo)(()=>{let e=new Map(eY.map(e=>[e.id,e.name])),t=new Map;for(let n of e4){let a=e.get(n.toTableId);if(!a)continue;let s=t.get(n.fromTableId)??{};s[n.fromColumn]=a,t.set(n.fromTableId,s)}return t},[e4,eY]),te=void 0!==I,[tt,tn]=(0,s.useState)(I??[]);(0,s.useEffect)(()=>{I&&tn(I)},[I]);let ta=(0,s.useMemo)(()=>({tables:eY.map(e=>({id:e.id,name:e.name,columns:e.columns.map(e=>e.name)})),endpoints:e0.map(e=>({id:e.id,method:e.method,path:e.path}))}),[eY,e0]),ts=(0,s.useMemo)(()=>{if(te){let e=new Set([...eY.map(e=>e.id),...e0.map(e=>e.id)]);return tt.filter(t=>e.has(t.targetId)).map((e,t)=>({id:e.id,n:t+1,targetId:e.targetId,column:e.columnName,text:e.body,x:e.x,y:e.y}))}let e=new Map((T??[]).map(e=>[e.id,e.comment]));return(0,D.m)(T??[],ta).map(t=>({id:t.annotationId,n:t.n,targetId:t.targetId,column:t.column,text:e.get(t.annotationId)??"",x:null,y:null}))},[te,tt,T,ta,eY,e0]),to=(0,s.useMemo)(()=>{let e=new Map;for(let t of ts){let n=e.get(t.targetId)??[];n.push({id:t.id,n:t.n,column:t.column}),e.set(t.targetId,n)}return e},[ts]),tl=(0,s.useMemo)(()=>new Map(ts.map(e=>[`anno-${e.id}`,e.targetId])),[ts]),ti=(0,s.useCallback)(async e=>{let t=(0,D.m)([{id:"_",excerpt:e}],ta)[0];if(!t)return;let n=await fetch("/api/board-annotations",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({targetKind:t.kind,targetId:t.targetId,columnName:t.column??void 0})});if(n.ok){let e=await n.json();tn(t=>[...t,e])}},[ta]),tr=(0,s.useCallback)((e,t)=>{tn(n=>n.map(n=>n.id===e?{...n,...t}:n)),fetch(`/api/board-annotations/${e}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(t)})},[]),td=(0,s.useCallback)(e=>{tn(t=>t.filter(t=>t.id!==e)),fetch(`/api/board-annotations/${e}`,{method:"DELETE"})},[]),tc=te?ti:C,tm=(0,s.useCallback)((e,t)=>{let n=(e8.get(t)??0)-(e8.get(e)??0),a=(e9.get(t)??0)-(e9.get(e)??0);return Math.abs(n)>=Math.abs(a)?n>=0?{sourceHandle:"sr",targetHandle:"tl"}:{sourceHandle:"sl",targetHandle:"tr"}:a>=0?{sourceHandle:"sb",targetHandle:"tt"}:{sourceHandle:"st",targetHandle:"tb"}},[e8,e9]),tu=(0,s.useMemo)(()=>new Set([...eH.tables.map(e=>e.id),...eH.endpoints.map(e=>e.id)]),[eH]),tp=(0,s.useMemo)(()=>new Set(e.map(e=>e.id)),[e]),th=(0,s.useCallback)(()=>{let e=eY.map(e=>({id:e.id,type:"dbTable",position:F?{x:e.x,y:e.y}:e1.get(e.id)??{x:e.x,y:e.y},data:{name:e.name,domain:e.domain,columns:e.columns,usageCount:e6.get(e.id)??0,source:e.source,rev:eK.rev,diffStatus:e2.get(e.id)?.status,diffChanges:e2.get(e.id)?.changes,diffColumns:e2.get(e.id)?.columns,fkTargets:e7.get(e.id),pins:to.get(e.id),onPinClick:M,onComment:tc}})),t=e0.map(e=>({id:e.id,type:"endpoint",position:{x:e.x,y:e.y},data:{method:e.method,path:e.path,domain:e.domain,source:e.source,rev:eK.rev,diffStatus:e3.get(e.id)?.status,diffChanges:e3.get(e.id)?.changes,pins:to.get(e.id),onPinClick:M,onComment:tc}})),n=new Map,a=new Map(eY.map(e=>[e.id,e])),s=new Map(e0.map(e=>[e.id,e]));return[...e,...t,...ts.map(e=>{let t=a.get(e.targetId),o=s.get(e.targetId),l=t?.x??o?.x??0,i=t?.y??o?.y??0,r=t?38+28*t.columns.length:42,d=n.get(e.targetId)??0;return n.set(e.targetId,d+1),{id:`anno-${e.id}`,type:"annotation",position:{x:e.x??l+26,y:e.y??i+r+64+112*d},data:{n:e.n,text:e.text,annotationId:e.id,onClick:te||S?void 0:M,editable:te||!!S,onChangeText:te?(e,t)=>tr(e,{body:t}):S,onDelete:te?td:E}}})]},[eY,e0,F,e1,e6,eK.rev,e2,e3,e7,to,ts,te,M,S,E,tc,tr,td]),[tf,tx,tb]=(0,i.ck)(th()),tg=(0,s.useRef)(F);(0,s.useEffect)(()=>{let e=tg.current!==F;tg.current=F,tx(t=>{let n=new Map(t.map(e=>[e.id,e.position]));return th().map(t=>e&&"dbTable"===t.type?t:{...t,position:n.get(t.id)??t.position})}),e&&requestAnimationFrame(()=>eS.current?.fitView({duration:500,padding:.15,minZoom:.2,maxZoom:.9}))},[th,tx,F]);let ty=(0,s.useCallback)((e,t,n,a)=>{fetch("/api/db/position",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({kind:e,id:t,x:n,y:a})})},[]),tj=(0,s.useCallback)((e,t)=>{var n;let{x:a,y:s}=t.position,o=(n={readOnly:$,nodeId:t.id,isDraft:tu.has(t.id),boardMode:te}).readOnly?"none":n.nodeId.startsWith("anno-")?n.boardMode?"annotation":"none":n.isDraft?"draft":"real";"annotation"===o?tr(t.id.slice(5),{x:a,y:s}):"draft"===o?eZ(e=>e.tables.some(e=>e.id===t.id)?{...e,tables:e.tables.map(e=>e.id===t.id?{...e,x:a,y:s}:e)}:e.endpoints.some(e=>e.id===t.id)?{...e,endpoints:e.endpoints.map(e=>e.id===t.id?{...e,x:a,y:s}:e)}:e):"real"===o&&ty("endpoint"===t.type?"endpoint":"table",t.id,a,s)},[$,tu,eZ,ty,te,tr]),tk=(0,s.useMemo)(()=>e4.map(e=>({id:`fk-${e.id}`,source:e.fromTableId,target:e.toTableId,...tm(e.fromTableId,e.toTableId),type:"deletable",label:e.label??void 0,markerEnd:{type:r.TG.ArrowClosed,color:"#6b6b6b"},style:{stroke:"#6b6b6b"}})),[e4,tm]),tw=(0,s.useMemo)(()=>e0.flatMap(e=>e.tables.map(t=>{let n=x.ru[t.access]??"#5a5a5a";return{id:`u-${e.id}-${t.tableId}`,source:e.id,target:t.tableId,...tm(e.id,t.tableId),type:"default",markerEnd:{type:r.TG.ArrowClosed,color:n},style:{stroke:n,strokeDasharray:"4 4",opacity:.7}}})),[e0,tm]),tN=(0,s.useMemo)(()=>F?[...tk,...tw]:tk,[tk,tw,F]),tv=(0,s.useMemo)(()=>ts.map(e=>({id:`annoe-${e.id}`,source:e.targetId,sourceHandle:`pin-${e.id}`,target:`anno-${e.id}`,targetHandle:"in",type:"annotation",selectable:!1,zIndex:30,style:{stroke:w.V5,strokeWidth:1.5,opacity:.9}})),[ts]),tC=O?.id??_,tT=(0,s.useMemo)(()=>{if(B){let e=tN.find(e=>e.id===B);return e?new Set([e.source,e.target]):null}return tC?(0,x.F1)(tC,tN):null},[tC,B,tN]),tM=(0,s.useMemo)(()=>new Map(eY.map(e=>[e.id,{domain:e.domain,source:e.source}])),[eY]),tS=(0,s.useMemo)(()=>new Map(e0.map(e=>[e.id,{method:e.method,source:e.source}])),[e0]),tE=(0,s.useMemo)(()=>{let e=new Set;if(!F)for(let t of tS.keys())e.add(t);for(let[t,n]of tM)!eA.size||n.domain&&eA.has(n.domain)||e.add(t),eF.size&&!eF.has(n.source)&&e.add(t);for(let[t,n]of tS)eO.size&&!eO.has(n.method)&&e.add(t),eF.size&&!eF.has(n.source)&&e.add(t);return e},[F,tM,tS,eA,eF,eO]),tI=eT.trim().length>0,t$=(0,s.useMemo)(()=>{if(!tI)return null;let e=new Set;for(let t of eY)!tE.has(t.id)&&(0,Q.Qk)((0,Q.jF)(t),eT)&&e.add(t.id);for(let t of e0)!tE.has(t.id)&&(0,Q.Qk)((0,Q.sQ)(t),eT)&&e.add(t.id);return e},[eY,e0,tE,eT,tI]),tA=(0,s.useMemo)(()=>tI?[...(0,Q.r2)(eY.filter(e=>!tE.has(e.id)),eT,e=>(0,Q.jF)(e),e=>({id:e.id,label:e.name,sublabel:e.domain??"table",kind:"table"})),...(0,Q.r2)(e0.filter(e=>!tE.has(e.id)),eT,e=>(0,Q.sQ)(e),e=>({id:e.id,label:e.path,sublabel:e.method,kind:"endpoint"}))].slice(0,12):[],[eY,e0,tE,eT,tI]),tP=(0,s.useCallback)(e=>{eM(""),L(tS.has(e)?{id:e,kind:"endpoint"}:{id:e,kind:"table"}),H(null),q(!0),eN("details");let t=eS.current?.getNode(e);if(!t||!eS.current)return;let n=t.measured?.width??220,a=t.measured?.height??80;eS.current.setCenter(t.position.x+n/2,t.position.y+a/2,{zoom:.9,duration:600})},[tS]),tz=t$??tT,tD=(0,s.useMemo)(()=>tf.map(e=>{if(e.id.startsWith("anno-")){let t=tl.get(e.id),n=!!t&&tE.has(t);return!!e.hidden!==n?{...e,hidden:n}:e}let t=tE.has(e.id);if(!tz)return t?{...e,hidden:t}:e;let n=tz.has(e.id),a=t$?Q.Uy:.45;return{...e,hidden:t,style:{...e.style,opacity:n?1:a,boxShadow:n&&t$?Q.RU:e.style?.boxShadow,borderRadius:n&&t$?12:e.style?.borderRadius,transition:"opacity 120ms, box-shadow 120ms"}}}),[tf,tE,tz,t$,tl]),tF=(0,s.useMemo)(()=>{let e=new Map(eY.map(e=>[e.id,(e.domain??"").trim()||"—"])),t=es(eY,e0.map(e=>({id:e.id,method:e.method,path:e.path,uses:e.tables.map(e=>({tableId:e.tableId}))})));return new Map(e0.map(n=>{let a=t.get(n.id);return[n.id,a?e.get(a):en]}))},[eY,e0]),tR=(0,s.useMemo)(()=>{let e=[];for(let t of tf)if(!tE.has(t.id))if("dbTable"===t.type){let n=t.data;e.push({id:t.id,group:(n.domain??"").trim()||"—",x:t.position.x,y:t.position.y,w:t.measured?.width??280,h:t.measured?.height??38+28*n.columns.length})}else"endpoint"===t.type&&e.push({id:t.id,group:tF.get(t.id)??en,x:t.position.x,y:t.position.y,w:t.measured?.width??240,h:t.measured?.height??50});return(0,Y.S)(e)},[tf,tE,tF]),tO=(0,s.useMemo)(()=>t$?tN.map(e=>{let t=tE.has(e.source)||tE.has(e.target);return t$.has(e.source)&&t$.has(e.target)?{...e,hidden:t,style:{...e.style,opacity:1}}:{...e,hidden:t,label:void 0,style:{...e.style,opacity:.08}}}):tN.map(e=>{let t=tE.has(e.source)||tE.has(e.target);return tC||B?(B?e.id===B:tC&&(e.source===tC||e.target===tC))?{...e,hidden:t,zIndex:20,style:{...e.style,opacity:1,strokeWidth:2.5}}:{...e,hidden:t,selectable:!1,label:void 0,markerEnd:void 0,style:{...e.style,opacity:.08}}:{...e,hidden:t,label:void 0}}),[tN,tC,B,tE,t$]),tL=(0,s.useMemo)(()=>Array.from(new Set(eY.map(e=>e.domain).filter(e=>!!e))).sort(),[eY]),tK=(0,s.useMemo)(()=>Array.from(new Set([...eY.map(e=>e.source),...e0.map(e=>e.source)])).sort(),[eY,e0]),tB=(0,s.useMemo)(()=>Array.from(new Set(e0.map(e=>e.method))).sort(),[e0]);function tH(e,t){t(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}let t_=+!F+eA.size+eF.size+eO.size,tZ=(0,s.useCallback)(()=>{R(!0),eP(new Set),eR(new Set),eL(new Set)},[]),tU=(0,s.useCallback)(e=>{let{source:t,target:n}=e;t&&n&&t!==n&&e_(e=>{if(!(e.tables.some(e=>e.id===n)||tp.has(n)))return e;let a=e.endpoints.find(e=>e.id===t);return a?a.links.some(e=>e.tableId===n)?e:{...e,endpoints:e.endpoints.map(e=>{var a;return e.id===t?{...e,links:[...e.links,{tableId:n,access:(a=e.method,X.has(a.trim().toUpperCase())?"read":"write")}]}:e})}:e.tables.find(e=>e.id===t)?e.relations.some(e=>e.fromTableId===t&&e.toTableId===n)?e:{...e,relations:[...e.relations,{id:crypto.randomUUID(),fromTableId:t,toTableId:n,fromColumn:"fk",toColumn:"id",label:null}]}:e})},[e_,tp]),tq=(0,s.useMemo)(()=>({readOnly:$,patchEndpoint:(e,t)=>e_(n=>({...n,endpoints:n.endpoints.map(n=>n.id===e?{...n,...t}:n)})),deleteEndpoint:e=>e_(t=>({...t,endpoints:t.endpoints.filter(t=>t.id!==e)})),patchTable:(e,t)=>e_(n=>({...n,tables:n.tables.map(n=>n.id===e?{...n,...t}:n)})),deleteTable:e=>e_(t=>({...t,tables:t.tables.filter(t=>t.id!==e),relations:t.relations.filter(t=>t.fromTableId!==e&&t.toTableId!==e),endpoints:t.endpoints.map(t=>({...t,links:t.links.filter(t=>t.tableId!==e)}))})),deleteRealEndpoint:e=>{fetch(`/api/endpoints/${e}`,{method:"DELETE"}).then(e=>{e.ok&&A.refresh()})}}),[$,e_,A]);(0,s.useEffect)(()=>{let e=e=>{if(!(e.metaKey||e.ctrlKey))return;let t=e.target;if(t&&/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))return;let n=e.key.toLowerCase();"z"===n?(e.preventDefault(),e.shiftKey?eq():eU()):"y"===n&&(e.preventDefault(),eq())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[eU,eq]);let tW=(0,s.useCallback)(async()=>{eC(!0);try{if((await fetch("/api/draft/approve",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(eH)})).ok){try{localStorage.removeItem(ey)}catch{}eW(ej),A.refresh()}}finally{eC(!1)}},[eH,eW,A]),tG=(0,s.useCallback)(async()=>{eC(!0);try{await fetch("/api/draft",{method:"DELETE"})}catch{}try{localStorage.removeItem(ey)}catch{}eW(ej),A.refresh(),eC(!1)},[eW,A]),tJ=(0,s.useMemo)(()=>{let e;return e=new Map(eH.tables.map(e=>[e.id,e.name])),{tables:eH.tables.map(e=>({name:e.name,domain:e.domain,description:e.description,columns:e.columns.map(e=>({name:e.name,type:e.type,isPk:e.isPk,isFk:e.isFk,nullable:e.nullable,note:e.note}))})),relations:eH.relations.flatMap(t=>{let n=e.get(t.fromTableId),a=e.get(t.toTableId);return n&&a?[{fromTable:n,fromColumn:t.fromColumn,toTable:a,toColumn:t.toColumn,label:t.label}]:[]}),endpoints:eH.endpoints.map(t=>({method:t.method,path:t.path,domain:t.domain,description:t.description,uses:t.links.flatMap(t=>{let n=e.get(t.tableId);return n?[{table:n,access:t.access}]:[]})}))}},[eH]),tQ=eH.tables.length>0||eH.endpoints.length>0,tV=eK.past.length>0,tX=eK.future.length>0;return(0,a.jsx)(b.Provider,{value:tq,children:(0,a.jsxs)("div",{className:(0,f.cn)("canvas-dots relative w-full",m?"h-full":"h-screen",ef&&"rf-panning"),children:[(0,a.jsxs)(i.Gc,{...e$,nodes:tD,edges:"far"===ez?[...tO,...tv].map(e=>({...e,hidden:!0})):[...tO,...tv.map(e=>({...e,hidden:tE.has(e.source)}))],nodeTypes:eb,edgeTypes:eg,nodesConnectable:!$,connectionMode:r.WZ.Loose,connectionLineStyle:{stroke:"var(--accent-2,#ff7a45)",strokeWidth:1.5,strokeDasharray:"4 4"},onInit:e=>{eS.current=e},onNodesChange:tb,onMoveStart:()=>ex(!0),onMoveEnd:()=>ex(!1),onConnect:tU,onNodeMouseEnter:(e,t)=>{"annotation"!==t.type&&Z(t.id)},onNodeMouseLeave:()=>Z(null),onNodeClick:(e,t)=>{if("annotation"===t.type){let e=t.data;e.editable||M?.(e.annotationId);return}let n="endpoint"===t.type?"endpoint":"table";L({id:t.id,kind:n}),H(null),q(!0),eN("details")},onEdgeClick:(e,t)=>{H(t.id),L(null)},onPaneClick:()=>{L(null),H(null),q(!1)},onNodeDragStop:tj,onEdgesDelete:e=>{for(let t of e)if(t.id.startsWith("fk-")){let e=t.id.slice(3);fetch(`/api/db/relations/${e}`,{method:"DELETE"})}},onNodesDelete:e=>{for(let t of e)t.id.startsWith("anno-")||tu.has(t.id)||("endpoint"===t.type?fetch(`/api/endpoints/${t.id}`,{method:"DELETE"}):"dbTable"===t.type&&fetch(`/api/db/tables/${t.id}`,{method:"DELETE"}))},deleteKeyCode:$?null:["Backspace","Delete"],colorMode:"dark",fitView:!0,fitViewOptions:{padding:.15,minZoom:.38,maxZoom:.9},minZoom:.15,panOnScroll:!0,zoomActivationKeyCode:["Meta","Control"],proOptions:{hideAttribution:!0},children:[(0,a.jsx)(el.Z,{regions:tR,tone:"category",lod:ez}),(0,a.jsx)(y.J,{onLod:eD,thresholds:j.fE}),(0,a.jsx)(i.H2,{position:"bottom-right",className:"!overflow-hidden !rounded-xl !border !border-white/10 [&_button]:!border-white/10 [&_button]:!bg-card/70 [&_button]:!text-foreground [&_button]:!backdrop-blur"}),!m&&(0,a.jsx)(i.of,{pannable:!0,zoomable:!0,position:"bottom-left",style:{width:140,height:90},className:"!overflow-hidden !rounded-xl !border !border-white/10 !bg-card/50 !backdrop-blur",nodeColor:"#555"}),(0,a.jsx)(i.Zk,{position:"bottom-left",style:{marginBottom:118},children:(0,a.jsx)(o.H,{tool:eE,onChange:eI})}),!m&&(0,a.jsx)(i.Zk,{position:"bottom-center",className:"!mb-4",children:(0,a.jsx)("div",{className:"glass flex items-center rounded-full p-0.5",children:(0,a.jsxs)("button",{type:"button",disabled:ev,title:"Re-arrange the board — domain clusters with endpoints docked under their tables",onClick:async()=>{eC(!0);try{let e=window.innerWidth/window.innerHeight;await fetch("/api/db/arrange",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({viewportAspect:e})}),A.refresh()}finally{eC(!1)}},className:"flex h-6 items-center gap-1.5 rounded-full px-3 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground disabled:opacity-40",children:[(0,a.jsx)(er.A,{className:"size-3"}),ev?"Arranging…":"Arrange"]})})}),!m&&(0,a.jsx)(i.Zk,{position:"top-center",className:"glass rounded-full px-1 py-0.5",children:(0,a.jsx)(V.Z,{active:"DATABASE",tabs:[{value:"ROADMAP",label:"Roadmap",href:"/map?view=ROADMAP"},{value:"ARCHITECTURE",label:"Architecture",href:"/map?view=ARCHITECTURE"},{value:"DATABASE",label:"Database",href:"/map?view=DATABASE"},{value:"FILES",label:"Files",href:"/map?view=FILES"}]})}),(0,a.jsxs)(i.Zk,{position:"top-right",className:(0,f.cn)("flex items-center gap-1 transition-[margin] duration-200",U&&"!mr-[332px]",m&&"hidden"),children:[(0,a.jsx)(G.X,{query:eT,onQuery:eM,hits:tA,placeholder:"Find a table, column, endpoint…",onPick:tP,onZoomToMatches:()=>{t$?.size&&eS.current?.fitView({nodes:[...t$].map(e=>({id:e})),duration:600,padding:.2})}}),(0,a.jsx)(J.e,{defaultSelection:"DATABASE"}),(0,a.jsxs)(W.er,{title:"Filters",trigger:(e,t)=>(0,a.jsxs)("button",{type:"button",onClick:t,title:"Filters",className:(0,f.cn)("glass relative flex size-8 items-center justify-center rounded-lg transition-colors",e||t_>0?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[(0,a.jsx)(ed.A,{className:"size-4"}),t_>0&&(0,a.jsx)("span",{className:"absolute -right-1 -top-1 flex h-4 min-w-4 items-center justify-center rounded-full bg-[var(--accent-2,#ff7a45)] px-1 text-[9px] font-semibold text-white",children:t_})]}),children:[(0,a.jsx)(W.r1,{title:"Show",children:(0,a.jsx)(W.vu,{tone:"accent",on:F,onClick:()=>R(e=>!e),children:"endpoints"})}),tL.length>0&&(0,a.jsx)(W.r1,{title:"Domain",children:tL.map(e=>(0,a.jsx)(W.vu,{on:eA.has(e),onClick:()=>tH(e,eP),children:e},e))}),tB.length>0&&(0,a.jsx)(W.r1,{title:"Method",children:tB.map(e=>(0,a.jsx)(W.vu,{on:eO.has(e),onClick:()=>tH(e,eL),children:e},e))}),tK.length>0&&(0,a.jsx)(W.r1,{title:"Source",children:tK.map(e=>(0,a.jsx)(W.vu,{on:eF.has(e),onClick:()=>tH(e,eR),children:e.toLowerCase()},e))}),t_>0&&(0,a.jsx)("button",{type:"button",onClick:tZ,className:"mt-1 w-full rounded-md border border-white/10 px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/5 hover:text-foreground",children:"clear filters"})]}),(0,a.jsx)(W.er,{title:"Legend",trigger:(e,t)=>(0,a.jsx)("button",{type:"button",onClick:t,title:"Legend",className:(0,f.cn)("glass flex size-8 items-center justify-center rounded-lg transition-colors",e?"text-foreground":"text-muted-foreground hover:text-foreground"),children:(0,a.jsx)(ec.A,{className:"size-4"})}),children:(0,a.jsxs)("ul",{className:"space-y-1.5 text-[10.5px] text-muted-foreground",children:[(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded border border-white/15 bg-white/[0.06] px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-foreground/80",children:"table"}),(0,a.jsx)("span",{children:"a database table \xb7 its columns"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded border border-white/15 bg-white/[0.06] px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-foreground/80",children:"endpoint"}),(0,a.jsx)("span",{children:"an API route \xb7 reads / writes tables"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"inline-block h-px w-6 bg-[#6b6b6b]"}),(0,a.jsx)("span",{children:"foreign key \xb7 drag from a table handle"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"inline-block h-0 w-6 border-t border-dashed",style:{borderColor:"#4ea1ff"}}),(0,a.jsx)("span",{children:"endpoint read \xb7 GET / POST / etc"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"inline-block h-0 w-6 border-t border-dashed",style:{borderColor:"#ffb86b"}}),(0,a.jsx)("span",{children:"endpoint write"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded border border-dashed border-sky-400/50 px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-sky-300",children:"draft"}),(0,a.jsx)("span",{children:"agent-proposed \xb7 approve to persist"})]})]})}),!U&&(0,a.jsx)("button",{onClick:()=>q(!0),title:"Show panel",className:"glass flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:text-foreground",children:(0,a.jsx)(em.A,{className:"size-4"})})]}),tQ&&(0,a.jsxs)(i.Zk,{position:"bottom-center",className:"glass flex items-center gap-1 rounded-xl p-1.5",children:[(0,a.jsxs)("button",{onClick:eU,disabled:!tV,title:"Undo (⌘Z)",className:"flex items-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground disabled:opacity-30 disabled:hover:bg-transparent",children:[(0,a.jsx)(eu.A,{className:"size-3.5"})," undo"]}),(0,a.jsxs)("button",{onClick:eq,disabled:!tX,title:"Redo (⇧⌘Z)",className:"flex items-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground disabled:opacity-30 disabled:hover:bg-transparent",children:[(0,a.jsx)(ep.A,{className:"size-3.5"})," redo"]}),!m&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"mx-1 h-4 w-px bg-white/10"}),(0,a.jsxs)("button",{onClick:tG,disabled:ev,title:"Discard draft",className:"flex items-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-red-500/15 hover:text-red-300 disabled:opacity-40",children:[(0,a.jsx)(u.A,{className:"size-3.5"})," discard"]}),(0,a.jsxs)("button",{onClick:tW,disabled:ev,title:"Approve and persist to the schema",className:"flex items-center gap-1 rounded-md border border-emerald-500/40 bg-emerald-500/15 px-2.5 py-1 text-[11px] font-semibold text-emerald-300 transition-colors hover:bg-emerald-500/25 disabled:opacity-40",children:[(0,a.jsx)(eh.A,{className:"size-3.5"})," approve draft"]})]})]})]}),U&&(0,a.jsx)(K,{selected:O,tables:eY,relations:e4,endpoints:e0,draftGraph:tJ,onClose:()=>{q(!1),eN("details")},commentsContent:N,commentsCount:v,activeTab:ew,onTabChange:eN,onAddComment:tc,topOffset:m?64:void 0})]})})}}}]);
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4853],{44853:(e,t,n)=>{n.d(t,{DbMapClient:()=>ek});var a=n(95155),s=n(12115),o=n(80277),l=n(73321),i=n(81750),r=n(6266);n(53255);var d=n(32133),c=n(81499),m=n(51128),u=n(65738),p=n(9005),h=n(2125),f=n(91337),x=n(18874);let b=(0,s.createContext)(null);function g(){let e=(0,s.useContext)(b);if(!e)throw Error("useDbEdit must be used inside DbEditContext");return e}var y=n(29523),j=n(70221),k=n(95635),w=n(17918);let N={danger:"bg-red-500/15 text-red-300",warn:"bg-amber-500/15 text-amber-300"};function v({badges:e,className:t}){return e.length?(0,a.jsx)("span",{className:(0,f.cn)("flex shrink-0 items-center gap-0.5",t),children:e.map(e=>(0,a.jsx)("span",{title:e.title,className:(0,f.cn)("rounded px-1 text-[8px] font-semibold uppercase tracking-wide",N[e.tone]),children:e.label},e.label))}):null}let C=/pass(word)?|token|secret|api[_-]?key|credential|priv(ate)?[_-]?key|hash|salt/i,T=/auth|login|logout|session|token|password|oauth|sso|credential/i,M="nodrag nopan",S=k.x;function E({onClick:e,title:t}){return(0,a.jsx)("button",{type:"button",title:t,onClick:t=>{t.stopPropagation(),e()},className:(0,f.cn)(M,"absolute -right-3 top-1/2 z-10 flex size-6 -translate-y-1/2 items-center justify-center rounded-full border border-white/15 bg-[#242428] text-muted-foreground opacity-0 shadow-md transition-all group-hover/row:opacity-100 hover:border-[#ff7a45]/50 hover:text-[#ff7a45]"),children:(0,a.jsx)(d.A,{className:"size-3"})})}function I({c:e,fkTargets:t}){let n=t?.[e.name];return(0,a.jsx)("span",{title:n?`→ ${n}`:e.type,className:"ml-auto min-w-0 truncate font-mono text-[11px] text-muted-foreground/80",children:n?(0,a.jsxs)(a.Fragment,{children:["→\xa0",n]}):e.type})}let $=(0,s.memo)(function({id:e,data:t,selected:n}){var o;let l,i,r="DRAFT"===t.source,d="added"===t.diffStatus?"#7bd389":"modified"===t.diffStatus?"#ffb86b":"#4ea1ff",b="added"===t.diffStatus||"modified"===t.diffStatus,N="added"===t.diffStatus?"new":"modified"===t.diffStatus?"modify":"in plan",T=t.diffChanges?.length?t.diffChanges.join("\n"):"in this plan — no column change",$=r?d:(0,x.qA)(t.domain),A=(o={domain:t.domain,columns:t.columns},l=[],(i=o.columns.filter(e=>C.test(e.name)).map(e=>e.name)).length&&l.push({label:"secrets",tone:"danger",title:`stores credentials: ${i.join(", ")}`}),o.domain&&/auth/i.test(o.domain)&&l.push({label:"auth",tone:"warn",title:"auth-domain table"}),l),P=g(),[z,D]=(0,s.useState)(t.name),[F,R]=(0,s.useState)(t.columns),[O,L]=(0,s.useState)(!1);(0,s.useEffect)(()=>{D(t.name),R(t.columns)},[t.rev]);let K=e=>e.stopPropagation(),B=t=>{R(t),P.patchTable(e,{columns:t})},H=(t.pins??[]).filter(e=>null===e.column),_=e=>(t.pins??[]).filter(t=>t.column===e),Z=function(e,t,n,a=!1,s){return Math.min(312,Math.max(240,Math.round(8*e.length)+90,...t.map(e=>{if(a){let t=s?.[e.name];return Math.round(7.3*Math.max(6,e.name.length+1)+(t?.kind==="modified"?8*t.detail.length:64))+94}let t=n?.[e.name]?n[e.name].length+2:e.type.length;return Math.round(7.3*e.name.length+6.7*t)+64})))}(t.name,r?F:t.columns,t.fkTargets,r,t.diffColumns),U=(0,f.cn)("relative rounded-xl border bg-[#161618]/95 text-card-foreground shadow-[0_18px_50px_-22px_rgba(0,0,0,0.9)] backdrop-blur",n&&"ring-2 ring-[var(--accent,#f5b942)]"),q=(0,y.k)(j.fE);return"full"!==q?(0,a.jsxs)("div",{className:(0,f.cn)(U,"border-white/10 px-3 py-2.5","far"===q&&!P.readOnly&&"!opacity-0"),style:{width:Z},children:[(0,a.jsx)(k.x,{}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block size-2 shrink-0 rounded-full",style:{background:$}}),(0,a.jsx)("span",{className:"truncate font-mono text-[15px] font-semibold",children:t.name})]})]}):r?(0,a.jsxs)("div",{className:(0,f.cn)(U,"group/card"),style:{width:Z,borderColor:`${d}59`},children:[(0,a.jsx)(S,{}),(0,a.jsxs)("div",{className:"group/row relative flex items-center gap-1.5 rounded-t-[11px] px-3 py-2",style:{background:`${d}14`},children:[(0,a.jsx)("input",{value:z,onChange:e=>D(e.target.value),onBlur:()=>{let n=z.trim();n&&n!==t.name&&P.patchTable(e,{name:n})},onKeyDown:e=>{K(e),"Enter"===e.key&&e.currentTarget.blur()},placeholder:"table",className:(0,f.cn)(M,"min-w-0 flex-1 bg-transparent font-mono text-[13px] font-semibold tracking-tight outline-none")}),(0,a.jsx)(v,{badges:A}),(0,a.jsx)("span",{title:T,className:(0,f.cn)("shrink-0 rounded-md border px-1.5 py-px font-mono text-[9px] font-semibold uppercase tracking-[0.14em]",!b&&"border-white/15 bg-white/5 text-muted-foreground"),style:b?{background:`${d}1f`,borderColor:`${d}55`,color:d}:void 0,children:N}),(0,a.jsx)("button",{type:"button",onClick:t=>{K(t),O?P.deleteTable(e):L(!0)},onBlur:()=>L(!1),title:"Delete table",className:(0,f.cn)(M,"shrink-0 transition-all",O?"text-red-300":"text-muted-foreground opacity-0 hover:text-red-300 group-hover/card:opacity-100"),children:(0,a.jsx)(u.A,{className:"size-3"})}),H.length>0?(0,a.jsx)(w.e0,{pins:H,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)(E,{title:`Comment on ${t.name}`,onClick:()=>t.onComment?.(t.name)})]}),(0,a.jsxs)("div",{className:"divide-y divide-white/[0.05]",children:[F.map((e,n)=>{let s=_(e.name),o=t.diffColumns?.[e.name],l=o?.kind==="added"?{background:"#7bd38914",boxShadow:"inset 2px 0 0 #7bd389"}:o?.kind==="modified"?{background:"#ffb86b14",boxShadow:"inset 2px 0 0 #ffb86b"}:void 0;return(0,a.jsxs)("div",{style:l,className:"group/row relative flex items-center gap-1.5 px-3 py-[5px] text-[12px]",children:[(0,a.jsx)("button",{type:"button",onClick:e=>{K(e),B(F.map((e,t)=>t===n?{...e,isPk:!e.isPk}:e))},title:"Primary key",className:(0,f.cn)(M,"shrink-0",e.isPk?"text-amber-300/90":"text-muted-foreground/40 hover:text-amber-300"),children:(0,a.jsx)(c.A,{className:"size-3"})}),(0,a.jsx)("button",{type:"button",onClick:e=>{K(e),B(F.map((e,t)=>t===n?{...e,isFk:!e.isFk}:e))},title:"Foreign key",className:(0,f.cn)(M,"shrink-0",e.isFk?"text-sky-400/80":"text-muted-foreground/40 hover:text-sky-400"),children:(0,a.jsx)(m.A,{className:"size-3"})}),(0,a.jsx)("input",{value:e.name,onChange:e=>R(t=>t.map((t,a)=>a===n?{...t,name:e.target.value}:t)),onBlur:()=>B(F),onKeyDown:K,placeholder:"column",style:{width:`${Math.max(6,e.name.length+1)}ch`},className:(0,f.cn)(M,"shrink-0 bg-transparent font-mono outline-none")}),(0,a.jsx)("span",{"aria-hidden":!0,className:"flex-1"}),t.fkTargets?.[e.name]?(0,a.jsxs)("span",{title:`→ ${t.fkTargets[e.name]}`,className:"min-w-0 shrink truncate text-right font-mono text-[11px] text-muted-foreground/80",children:["→\xa0",t.fkTargets[e.name]]}):o?.kind==="modified"?(0,a.jsx)("span",{title:`was changed — ${o.detail}`,className:(0,f.cn)(M,"min-w-0 shrink truncate text-right font-mono text-[11px] font-medium text-[#ffb86b]"),children:o.detail}):(0,a.jsx)("input",{value:e.type,onChange:e=>R(t=>t.map((t,a)=>a===n?{...t,type:e.target.value}:t)),onBlur:()=>B(F),onKeyDown:K,placeholder:"type",title:e.type,className:(0,f.cn)(M,"w-16 min-w-0 shrink bg-transparent text-right font-mono text-[11px] outline-none",o?.kind==="added"?"text-[#7bd389]":"text-muted-foreground/80")}),(0,a.jsx)("button",{type:"button",onClick:e=>{K(e),B(F.filter((e,t)=>t!==n))},title:"Remove column",className:(0,f.cn)(M,"shrink-0 text-muted-foreground/40 opacity-0 transition-opacity hover:text-red-300 group-hover/card:opacity-100"),children:(0,a.jsx)(p.A,{className:"size-3"})}),s.length>0?(0,a.jsx)(w.e0,{pins:s,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)(E,{title:`Comment on ${t.name}.${e.name}`,onClick:()=>t.onComment?.(`${t.name}.${e.name}`)})]},n)}),(0,a.jsxs)("button",{type:"button",onClick:e=>{K(e),B([...F,{name:"",type:"text",isPk:!1,isFk:!1,nullable:!0,note:null}])},className:(0,f.cn)(M,"flex w-full items-center gap-1 px-3 py-1.5 text-[10px] text-muted-foreground hover:text-foreground"),children:[(0,a.jsx)(h.A,{className:"size-3"})," column"]})]})]}):(0,a.jsxs)("div",{className:U,style:{width:Z,borderColor:`${$}3d`},children:[(0,a.jsx)(S,{}),(0,a.jsxs)("div",{className:"group/row relative flex items-center justify-between rounded-t-[11px] px-3 py-2",style:{background:`${$}14`},children:[(0,a.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-1.5 font-mono text-[13px] font-semibold tracking-tight",children:["INTROSPECTION"===t.source&&(0,a.jsx)("span",{title:"live — derived from your code",className:"inline-block size-1.5 shrink-0 rounded-full bg-emerald-400"}),(0,a.jsx)("span",{className:"truncate",title:t.name,children:t.name})]}),(0,a.jsxs)("span",{className:"flex shrink-0 items-center gap-1.5",children:["INTROSPECTION"!==t.source&&(0,a.jsx)("span",{title:"planned — not yet detected in code",className:"shrink-0 rounded-md border border-[#f5b942]/35 bg-[#f5b942]/10 px-1.5 py-px font-mono text-[9px] font-semibold uppercase tracking-[0.14em] text-[#f5b942]",children:"planned"}),(0,a.jsx)(v,{badges:A}),t.domain&&(0,a.jsx)("span",{className:"text-[9px] uppercase tracking-[0.14em]",style:{color:$},children:t.domain})]}),H.length>0?(0,a.jsx)(w.e0,{pins:H,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)(E,{title:`Comment on ${t.name}`,onClick:()=>t.onComment?.(t.name)})]}),(0,a.jsx)("div",{className:"divide-y divide-white/[0.05]",children:t.columns.map(e=>{let n=_(e.name);return(0,a.jsxs)("div",{className:"group/row relative flex items-center gap-2 px-3 py-[7px] text-[12px]",children:[e.isPk?(0,a.jsx)(c.A,{className:"size-3 shrink-0 text-amber-300/90"}):e.isFk?(0,a.jsx)(m.A,{className:"size-3 shrink-0 text-sky-400/80"}):(0,a.jsx)("span",{className:"size-3 shrink-0"}),(0,a.jsx)("span",{className:"shrink-0 whitespace-nowrap font-mono",children:e.name}),(0,a.jsx)(I,{c:e,fkTargets:t.fkTargets}),n.length>0?(0,a.jsx)(w.e0,{pins:n,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)(E,{title:`Comment on ${t.name}.${e.name}`,onClick:()=>t.onComment?.(`${t.name}.${e.name}`)})]},e.name)})})]})}),A="nodrag nopan",P=["GET","POST","PUT","PATCH","DELETE"],z=(0,s.memo)(function({id:e,data:t,selected:n}){var o;let l,i=x.e6[t.method]??"#8a8a8a",r="DRAFT"===t.source,c="added"===t.diffStatus?"#7bd389":"modified"===t.diffStatus?"#ffb86b":"#4ea1ff",m="added"===t.diffStatus?"new":"modified"===t.diffStatus?"changed":"draft",p=t.diffChanges?.length?t.diffChanges.join("\n"):"draft",h=(o={method:t.method,domain:t.domain,path:t.path},l=[],/^delete$/i.test(o.method.trim())&&l.push({label:"DELETE",tone:"danger",title:"destructive: deletes data"}),(o.domain&&/auth/i.test(o.domain)||T.test(o.path))&&l.push({label:"auth",tone:"warn",title:"auth-related endpoint"}),l),b=g(),[N,C]=(0,s.useState)(t.path),[M,S]=(0,s.useState)(!1);(0,s.useEffect)(()=>{C(t.path)},[t.rev]);let E=e=>e.stopPropagation(),I=(0,y.k)(j.fE);return"full"!==I?(0,a.jsxs)("div",{className:(0,f.cn)("relative flex w-[300px] items-center gap-2 rounded-lg border border-white/10 bg-[#161618]/95 px-2.5 py-2 text-card-foreground backdrop-blur",n&&"ring-2 ring-[var(--accent,#f5b942)]","far"===I&&!b.readOnly&&"!opacity-0"),children:[(0,a.jsx)(k.x,{}),(0,a.jsx)("span",{className:"shrink-0 font-mono text-[12px] font-bold",style:{color:i},children:t.method}),(0,a.jsx)("span",{title:t.path,className:"truncate font-mono text-[13px]",children:t.path})]}):(0,a.jsxs)("div",{className:(0,f.cn)("group relative flex w-[300px] items-center gap-2 rounded-lg border bg-[#161618]/95 px-2.5 py-1.5 text-card-foreground shadow-[0_12px_36px_-18px_rgba(0,0,0,0.9)] backdrop-blur",r?"border-dashed":"border-white/10",n&&"ring-2 ring-[var(--accent,#f5b942)]"),style:r?{borderColor:`${c}66`,background:`${c}0f`}:void 0,children:[(0,a.jsx)(k.x,{}),"INTROSPECTION"===t.source&&(0,a.jsx)("span",{title:"live — derived from your code",className:"inline-block size-1.5 shrink-0 rounded-full bg-emerald-400"}),r?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("select",{value:t.method,onChange:t=>b.patchEndpoint(e,{method:t.target.value}),onPointerDown:E,className:(0,f.cn)(A,"shrink-0 rounded bg-transparent text-[10px] font-bold outline-none"),style:{color:i},title:"Method",children:P.map(e=>(0,a.jsx)("option",{value:e,className:"bg-card text-foreground",children:e},e))}),(0,a.jsx)("input",{value:N,title:N,onChange:e=>C(e.target.value),onBlur:()=>{let n=N.trim();n&&n!==t.path&&b.patchEndpoint(e,{path:n})},onKeyDown:e=>{E(e),"Enter"===e.key&&e.currentTarget.blur()},className:(0,f.cn)(A,"min-w-0 flex-1 bg-transparent font-mono text-[11px] outline-none")}),(0,a.jsx)(v,{badges:h}),(0,a.jsx)("span",{title:p,className:"shrink-0 rounded px-1 py-0.5 text-[8px] font-semibold uppercase",style:{background:`${c}26`,color:c},children:m}),(0,a.jsx)("button",{type:"button",onClick:t=>{E(t),M?b.deleteEndpoint(e):S(!0)},onBlur:()=>S(!1),title:"Delete",className:(0,f.cn)(A,"shrink-0 transition-colors",M?"text-red-300":"text-muted-foreground hover:text-red-300"),children:(0,a.jsx)(u.A,{className:"size-3"})})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"rounded px-1.5 py-0.5 text-[10px] font-bold",style:{background:`${i}22`,color:i},children:t.method}),(0,a.jsx)("span",{title:t.path,className:"min-w-0 flex-1 break-all font-mono text-[11px] leading-tight [-webkit-box-orient:vertical] [-webkit-line-clamp:2] [display:-webkit-box] overflow-hidden",children:t.path}),"INTROSPECTION"!==t.source&&(0,a.jsx)("span",{title:"planned — not yet detected in code",className:"shrink-0 rounded-md border border-[#f5b942]/35 bg-[#f5b942]/10 px-1.5 py-px font-mono text-[8px] font-semibold uppercase tracking-[0.14em] text-[#f5b942]",children:"planned"}),(0,a.jsx)(v,{badges:h}),(0,a.jsx)("button",{type:"button",onClick:t=>{E(t),M?b.deleteRealEndpoint(e):S(!0)},onBlur:()=>S(!1),title:M?"Click again to delete":"Delete endpoint",className:(0,f.cn)(A,"shrink-0 opacity-0 transition-opacity group-hover:opacity-100",M?"text-red-300 opacity-100":"text-muted-foreground hover:text-red-300"),children:(0,a.jsx)(u.A,{className:"size-3"})})]}),(t.pins?.length??0)>0?(0,a.jsx)(w.e0,{pins:t.pins,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)("button",{type:"button",title:`Comment on ${t.method} ${t.path}`,onClick:e=>{E(e),t.onComment?.(`${t.method} ${t.path}`)},className:(0,f.cn)(A,"absolute -right-3 top-1/2 z-10 flex size-6 -translate-y-1/2 items-center justify-center rounded-full border border-white/15 bg-[#242428] text-muted-foreground opacity-0 shadow-md transition-all group-hover:opacity-100 hover:border-[#ff7a45]/50 hover:text-[#ff7a45]"),children:(0,a.jsx)(d.A,{className:"size-3"})})]})});var D=n(54698),F=n(82099),R=n(4474);let O=[{id:"claude",label:"Prompt p/ Claude Code",fn:function(e){let t=["Implement this database schema in this project, following its existing stack and conventions:",""];for(let n of e.tables){let e=`Table \`${n.name}\``+(n.domain?` (domain: ${n.domain})`:"")+(n.description?` — ${n.description}`:"");for(let a of(t.push(e),n.columns)){let e=[a.isPk&&"PK",a.isFk&&"FK",!1===a.nullable&&"NOT NULL"].filter(Boolean).join(", ");t.push(` - ${a.name}: ${a.type}`+(e?` [${e}]`:"")+(a.note?` — ${a.note}`:""))}t.push("")}if(e.relations.length){for(let n of(t.push("Foreign keys:"),e.relations))t.push(` - ${n.fromTable}.${n.fromColumn} -> ${n.toTable}.${n.toColumn}`);t.push("")}return t.push("Create the models/migrations using the project's existing ORM and patterns, wire the relationships, and keep table and column names exactly as given."),t.join("\n")}},{id:"dbml",label:"DBML",fn:function(e){let t=[];for(let n of e.tables){for(let e of(t.push(`Table ${n.name} {`),n.columns)){let n=[e.isPk&&"pk",!1===e.nullable&&!e.isPk&&"not null",e.note&&`note: '${e.note.replace(/'/g,"")}'`].filter(Boolean).join(", ");t.push(` ${e.name} ${e.type}`+(n?` [${n}]`:""))}t.push("}","")}for(let n of e.relations)t.push(`Ref: ${n.fromTable}.${n.fromColumn} > ${n.toTable}.${n.toColumn}`);return t.join("\n").trim()}},{id:"sql",label:"SQL DDL",fn:function(e){let t=[];for(let n of e.tables){t.push(`CREATE TABLE ${n.name} (`);let a=n.columns.map(e=>{let t=[` ${e.name} ${e.type}`];return e.isPk?t.push("PRIMARY KEY"):!1===e.nullable&&t.push("NOT NULL"),t.join(" ")}),s=e.relations.filter(e=>e.fromTable===n.name).map(e=>` FOREIGN KEY (${e.fromColumn}) REFERENCES ${e.toTable}(${e.toColumn})`);t.push([...a,...s].join(",\n")),t.push(");","")}return t.join("\n").trim()}}];function L({draftGraph:e}){let[t,n]=(0,s.useState)(null);if(0===e.tables.length)return null;async function o(t){await navigator.clipboard.writeText(t.fn(e)).catch(()=>{}),n(t.id),setTimeout(()=>n(null),1500)}return(0,a.jsxs)("div",{className:"space-y-2 rounded-xl border border-sky-400/20 bg-sky-500/[0.04] p-3",children:[(0,a.jsxs)("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-sky-300",children:["Rascunho \xb7 ",e.tables.length," tabelas"]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"copiar:"}),O.map(e=>(0,a.jsx)(R.$,{size:"sm",variant:"outline",className:"h-6 px-2 text-[11px]",onClick:()=>o(e),children:t===e.id?"✓":e.label},e.id))]})]})}function K({selected:e,tables:t,relations:n,endpoints:s,draftGraph:o,onClose:l,commentsContent:i,commentsCount:r=0,activeTab:c,onTabChange:m,onAddComment:u,topOffset:h}){let f,x,b=new Map(t.map(e=>[e.id,e.name])),g=!!i,y=c??"details",j=e?.kind==="table"?t.find(t=>t.id===e.id)?.name??null:e?.kind==="endpoint"&&(x=s.find(t=>t.id===e.id))?`${x.method} ${x.path}`:null;if(e?.kind==="table"){let o=t.find(t=>t.id===e.id);f=o?(0,a.jsx)(H,{table:o,relations:n,endpoints:s,nameById:b}):null}else if(e?.kind==="endpoint"){let t=s.find(t=>t.id===e.id);f=t?(0,a.jsx)(_,{ep:t,nameById:b}):null}else f=(0,a.jsx)(Z,{tables:t,relations:n,endpoints:s});return(0,a.jsxs)(F.b,{className:"absolute right-3 z-10 flex w-80 flex-col rounded-2xl",style:{top:h??12,maxHeight:`calc(100% - ${(h??12)+12}px)`},children:[g?(0,a.jsxs)("div",{className:"flex items-center justify-between border-b border-white/10 px-1 py-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,a.jsx)(B,{active:"details"===y,onClick:()=>m?.("details"),children:"Details"}),(0,a.jsxs)(B,{active:"comments"===y,onClick:()=>m?.("comments"),children:["Comments",r>0&&(0,a.jsx)("span",{className:"ml-1 rounded-full bg-white/10 px-1 text-[9px] font-semibold leading-4",children:r})]})]}),(0,a.jsx)("button",{onClick:l,title:"Close panel",className:"mr-1 rounded-md p-1 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,a.jsx)(p.A,{className:"size-4"})})]}):(0,a.jsxs)("div",{className:"flex items-center justify-between border-b border-white/10 px-3.5 py-2.5",children:[(0,a.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Panel"}),(0,a.jsx)("button",{onClick:l,title:"Close panel",className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,a.jsx)(p.A,{className:"size-4"})})]}),(0,a.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:"comments"===y&&g?(0,a.jsx)("div",{className:"p-3",children:i}):(0,a.jsxs)(a.Fragment,{children:[o.tables.length>0&&(0,a.jsx)("div",{className:"border-b border-white/10 p-3.5",children:(0,a.jsx)(L,{draftGraph:o})}),(0,a.jsxs)("div",{className:"p-4",children:[u&&j&&(0,a.jsxs)("button",{type:"button",onClick:()=>u(j),className:"mb-3 flex w-full items-center justify-center gap-1.5 rounded-lg border border-white/10 bg-white/[0.03] px-3 py-1.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:[(0,a.jsx)(d.A,{className:"size-3.5"}),"Comment on this ",e?.kind==="endpoint"?"endpoint":"table"]}),f]})]})})]})}function B({active:e,onClick:t,children:n}){return(0,a.jsx)("button",{type:"button",onClick:t,className:(0,f.cn)("flex items-center gap-1 rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors",e?"bg-white/10 text-foreground":"text-muted-foreground hover:text-foreground"),children:n})}function H({table:e,relations:t,endpoints:n,nameById:s}){let o=t.filter(t=>t.fromTableId===e.id),l=t.filter(t=>t.toTableId===e.id),i=n.map(t=>({e:t,u:t.tables.find(t=>t.tableId===e.id)})).filter(e=>e.u);return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-xs uppercase tracking-wide",style:{color:(0,x.qA)(e.domain)},children:e.domain??"table"}),(0,a.jsx)("h2",{className:"font-mono text-lg font-semibold",children:e.name}),e.description&&(0,a.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:e.description})]}),(0,a.jsx)(U,{title:`Columns (${e.columns.length})`,children:(0,a.jsx)("ul",{className:"space-y-0.5",children:e.columns.map(e=>(0,a.jsxs)("li",{className:"flex items-center gap-1.5 text-xs",children:[e.isPk?(0,a.jsx)(c.A,{className:"size-3 text-amber-400"}):e.isFk?(0,a.jsx)(m.A,{className:"size-3 text-sky-400"}):(0,a.jsx)("span",{className:"size-3"}),(0,a.jsx)("span",{className:"font-mono",children:e.name}),(0,a.jsxs)("span",{className:"ml-auto font-mono text-[10px] text-muted-foreground",children:[e.type,!e.nullable&&" \xb7NN"]})]},e.name))})}),o.length>0&&(0,a.jsx)(U,{title:"References (FK out)",children:(0,a.jsx)("ul",{className:"space-y-1 text-xs",children:o.map(e=>(0,a.jsxs)("li",{className:"font-mono text-muted-foreground",children:[e.fromColumn," → ",s.get(e.toTableId),".",e.toColumn]},e.id))})}),l.length>0&&(0,a.jsx)(U,{title:"Referenced by (FK in)",children:(0,a.jsx)("ul",{className:"space-y-1 text-xs",children:l.map(e=>(0,a.jsxs)("li",{className:"font-mono text-muted-foreground",children:[s.get(e.fromTableId),".",e.fromColumn]},e.id))})}),i.length>0&&(0,a.jsx)(U,{title:`Used by endpoints (${i.length})`,children:(0,a.jsx)("ul",{className:"space-y-1 text-xs",children:i.map(({e,u:t})=>(0,a.jsxs)("li",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{style:{color:x.e6[e.method]},className:"font-bold",children:e.method}),(0,a.jsx)("span",{className:"truncate font-mono",children:e.path}),(0,a.jsx)("span",{className:"ml-auto",style:{color:x.ru[t.access]},children:t.access})]},e.id))})})]})}function _({ep:e,nameById:t}){return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"rounded px-1.5 py-0.5 text-[11px] font-bold",style:{background:`${x.e6[e.method]}22`,color:x.e6[e.method]},children:e.method}),(0,a.jsx)("h2",{className:"mt-2 font-mono text-base font-semibold",children:e.path}),e.description&&(0,a.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:e.description})]}),(0,a.jsx)(U,{title:`Tables used (${e.tables.length})`,children:(0,a.jsx)("ul",{className:"space-y-1 text-xs",children:e.tables.map(e=>(0,a.jsxs)("li",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"font-mono",children:t.get(e.tableId)}),(0,a.jsx)("span",{className:"ml-auto",style:{color:x.ru[e.access]},children:e.access})]},e.tableId))})})]})}function Z({tables:e,relations:t,endpoints:n}){return(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-sm font-semibold",children:"Database"}),(0,a.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Live schema derived from your code. Click a table or endpoint to see details. Drag to rearrange — positions are saved."})]}),(0,a.jsxs)("dl",{className:"grid grid-cols-3 gap-2 text-center",children:[(0,a.jsx)(q,{label:"tables",value:e.length}),(0,a.jsx)(q,{label:"FKs",value:t.length}),(0,a.jsx)(q,{label:"endpoints",value:n.length})]}),(0,a.jsx)(U,{title:"Legend",children:(0,a.jsxs)("ul",{className:"space-y-1 text-xs text-muted-foreground",children:[(0,a.jsxs)("li",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(c.A,{className:"size-3 text-amber-400"})," primary key"]}),(0,a.jsxs)("li",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(m.A,{className:"size-3 text-sky-400"})," foreign key"]}),(0,a.jsx)("li",{children:"— gray line: FK relation between tables"}),(0,a.jsx)("li",{children:"– – dashed line: endpoint uses table (read/write)"})]})})]})}function U({title:e,children:t}){return(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e}),t]})}function q({label:e,value:t}){return(0,a.jsxs)("div",{className:"rounded-lg border border-white/10 bg-white/[0.03] py-2",children:[(0,a.jsx)("div",{className:"text-lg font-semibold",children:t}),(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:e})]})}var W=n(56614),G=n(9991),J=n(40654),Q=n(14983),V=n(62311);let X=new Set(["GET","HEAD","OPTIONS"]);var Y=n(44267),ee=n(94014);function et(e){return 36+30*Math.max(0,e)+16}let en="Unattached",ea=e=>(e??"").trim()||"—";function es(e,t){let n=new Map(e.map(e=>[e.id,e.name])),a=new Map;for(let e of t)for(let t of e.uses)n.has(t.tableId)&&a.set(t.tableId,(a.get(t.tableId)??0)+1);return new Map(t.map(e=>[e.id,function(e,t,n){let a=new Map;for(let n of e.uses)t.has(n.tableId)&&a.set(n.tableId,(a.get(n.tableId)??0)+1);let s=null;for(let[e,o]of a){if(null===s){s=e;continue}let l=a.get(s);if(o>l){s=e;continue}if(o<l)continue;let i=n?.get(e)??0,r=n?.get(s)??0;i<r?s=e:i===r&&0>t.get(e).localeCompare(t.get(s))&&(s=e)}return s}(e,n,a)]))}let eo=(e,t)=>e.path.localeCompare(t.path)||e.method.localeCompare(t.method)||e.id.localeCompare(t.id);var el=n(70947);let ei=e=>e.trim().toLowerCase();var er=n(85618),ed=n(80846),ec=n(17356),em=n(45486),eu=n(15330),ep=n(60976),eh=n(64577),ef=n(24692),ex=n(45437);let eb={dbTable:$,endpoint:z,annotation:w.Sh},eg={deletable:ef.I,annotation:ex.L},ey="beacon:db-draft",ej={proposedAt:0,status:"pending",tables:[],relations:[],endpoints:[]};function ek({tables:e,relations:t,endpoints:n,draft:d,workspaceId:c,embedded:m=!1,diffBase:p,draftRef:h,onEdit:g,controlRef:k,commentsContent:N,commentsCount:v=0,onAddComment:C,annotations:T,onPinClick:M,onUpdateComment:S,onRemoveComment:E,boardAnnotations:I,readOnly:$=!1}){let A=(0,l.useRouter)(),P=e.length+(d?.tables.length??0),z=n.length+(d?.endpoints.length??0),[F,R]=(0,s.useState)(z>0&&(m||0===P)),[O,L]=(0,s.useState)(null),[B,H]=(0,s.useState)(null),[_,Z]=(0,s.useState)(null),[U,q]=(0,s.useState)(!1),[ef,ex]=(0,s.useState)(!1),[ew,eN]=(0,s.useState)("details"),[ev,eC]=(0,s.useState)(!1),[eT,eM]=(0,s.useState)(""),eS=(0,s.useRef)(null),{tool:eE,setTool:eI,flowProps:e$}=(0,o.e)();(0,s.useEffect)(()=>{if(!$)return;let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>eS.current?.fitView({padding:.2,duration:0}))});return()=>{cancelAnimationFrame(t),cancelAnimationFrame(e)}},[$,d,F]),(0,s.useEffect)(()=>{if(k)return k.current={open:()=>{q(!0),eN("details")},close:()=>{q(!1),eN("details")},openComments:()=>{q(!0),eN("comments")}},()=>{k&&(k.current=null)}},[k]);let[eA,eP]=(0,s.useState)(new Set),[ez,eD]=(0,s.useState)("full"),[eF,eR]=(0,s.useState)(new Set),[eO,eL]=(0,s.useState)(new Set),[eK,eB]=(0,s.useState)(()=>({past:[],present:d??ej,future:[],rev:0,edited:!1})),eH=eK.present,e_=(0,s.useCallback)(e=>{eB(t=>{let n=e(t.present);return n===t.present?t:{past:[...t.past,t.present].slice(-100),present:n,future:[],rev:t.rev+1,edited:!0}})},[]),eZ=(0,s.useCallback)(e=>{eB(t=>{let n=e(t.present);return n===t.present?t:{...t,present:n}})},[]),eU=(0,s.useCallback)(()=>eB(e=>e.past.length?{past:e.past.slice(0,-1),present:e.past[e.past.length-1],future:[e.present,...e.future],rev:e.rev+1,edited:!0}:e),[]),eq=(0,s.useCallback)(()=>eB(e=>e.future.length?{past:[...e.past,e.present],present:e.future[0],future:e.future.slice(1),rev:e.rev+1,edited:!0}:e),[]),eW=(0,s.useCallback)(e=>eB(t=>({past:[],present:e,future:[],rev:t.rev+1,edited:!1})),[]),eG=(0,s.useRef)(!1),eJ=d?.proposedAt??0;(0,s.useEffect)(()=>{let e=null;if(eG.current)d&&d.proposedAt!==eH.proposedAt?e=d:!d&&(eH.tables.length>0||eH.endpoints.length>0)&&(e=ej);else{eG.current=!0;let t=null;try{let e=localStorage.getItem(ey);if(e){let n=JSON.parse(e);n.workspaceId===c&&n.doc&&d&&n.doc.proposedAt===d.proposedAt&&(t=n.doc)}}catch{}e=t??d??null}e&&eW(e)},[eJ]),(0,s.useEffect)(()=>{try{eH.tables.length>0||eH.endpoints.length>0?localStorage.setItem(ey,JSON.stringify({workspaceId:c,doc:eH})):localStorage.removeItem(ey)}catch{}},[eH,c]),(0,s.useEffect)(()=>{h&&(h.current=eH)},[h,eH]);let eQ=(0,s.useRef)(!1);(0,s.useEffect)(()=>{eK.edited&&!eQ.current&&(eQ.current=!0,g?.())},[eK.edited,g]);let eV=(0,s.useMemo)(()=>eH.tables.map(e=>({id:e.id,name:e.name,domain:e.domain,description:e.description,source:"DRAFT",x:e.x,y:e.y,columns:e.columns})),[eH]),eX=(0,s.useMemo)(()=>eH.endpoints.map(e=>({id:e.id,method:e.method,path:e.path,domain:e.domain,description:e.description,source:"DRAFT",x:e.x,y:e.y,tables:e.links.map(e=>({tableId:e.tableId,access:e.access}))})),[eH]),eY=(0,s.useMemo)(()=>[...e,...eV],[e,eV]),e0=(0,s.useMemo)(()=>[...n,...eX],[n,eX]),e1=(0,s.useMemo)(()=>(function(e,t,n={}){let a=es(e,t),s=new Map,o=[];for(let e of[...t].sort(eo)){let t=a.get(e.id)??null;if(t){let n=s.get(t);n?n.push(e):s.set(t,[e])}else o.push(e)}let l=e=>{let t=s.get(e.id)?.length??0;return et(e.columnCount)+(t?10+60*t:0)+30},i=Array.from(new Set(e.map(e=>ea(e.domain)))),r=i.filter(e=>"—"!==e).sort(),d=i.includes("—")?[...r,"—"]:r,c=[];for(let t of d){let n=e.filter(e=>ea(e.domain)===t).sort((e,t)=>e.name.localeCompare(t.name)),a=n.reduce((e,t)=>e+l(t),0),s=Math.max(1,Math.min(12,n.length,Math.round(Math.sqrt(a/320)))),o=Array(s).fill(0),i=new Map;for(let e of n){let t=0;for(let e=1;e<s;e++)o[e]<o[t]&&(t=e);i.set(e.id,{x:320*t,y:o[t]}),o[t]+=l(e)}c.push({d:t,w:320*s,h:Math.max(...o,0),tableLocal:i})}let m=(0,ee.Xi)(c.map(e=>({id:e.d,w:e.w,h:e.h})),{gapX:84,gapY:72,viewportAspect:n.viewportAspect,minBandW:960,aspectSlack:1.7}),u=new Map,p=new Map,h=0;for(let t of c){let n=m.get(t.d);for(let a of e.filter(e=>t.tableLocal.has(e.id))){let e=t.tableLocal.get(a.id),o=n.x+e.x,l=n.y+e.y;u.set(a.id,{x:o,y:l}),(s.get(a.id)??[]).forEach((e,t)=>{p.set(e.id,{x:o,y:l+et(a.columnCount)+10+60*t})})}h=Math.max(h,n.y+t.h)}if(o.length){let e=h+72,t=Math.max(1,Math.min(4,Math.ceil(Math.sqrt(o.length/2))));o.forEach((n,a)=>{p.set(n.id,{x:a%t*300,y:e+60*Math.floor(a/t)})})}return{tables:u,endpoints:p}})(eY.map(e=>({id:e.id,name:e.name,domain:e.domain,columnCount:e.columns.length})),[]).tables,[eY]),e5=(0,s.useMemo)(()=>new Map,[]),e2=(0,s.useMemo)(()=>m?function(e,t){let n=new Map(e.map(e=>[ei(e.name),e])),a=new Map;for(let e of t){let t=n.get(ei(e.name));if(!t){a.set(e.id,{status:"added",changes:["new table"],columns:{}});continue}let{changes:s,columns:o}=function(e,t){let n=new Map(e.map(e=>[ei(e.name),e])),a=new Set(t.map(e=>ei(e.name))),s=[],o={};for(let e of t){let t=n.get(ei(e.name));if(!t){s.push(`+ column ${e.name} (${e.type})`),o[e.name]={kind:"added",detail:"new column"};continue}let a=[],l=[];if(ei(t.type)!==ei(e.type)&&(a.push(`type ${t.type}→${e.type}`),l.push(`${t.type}→${e.type}`)),t.isPk!==e.isPk){let t=e.isPk?"now PK":"no longer PK";a.push(t),l.push(t)}if(t.isFk!==e.isFk){let t=e.isFk?"now FK":"no longer FK";a.push(t),l.push(t)}if(t.nullable!==e.nullable){let t=e.nullable?"now nullable":"now required";a.push(t),l.push(t)}a.length&&(s.push(`~ column ${e.name}: ${a.join(", ")}`),o[e.name]={kind:"modified",detail:l.join(" \xb7 ")})}for(let t of e)a.has(ei(t.name))||s.push(`- column ${t.name}`);return{changes:s,columns:o}}(t.columns,e.columns);a.set(e.id,{status:s.length?"modified":"unchanged",changes:s,columns:o})}return a}(p?.tables??e,eV):e5,[m,p,e,eV,e5]),e3=(0,s.useMemo)(()=>m?function(e,t){let n=e=>`${ei(e.method)} ${ei(e.path)}`,a=new Set(e.map(n)),s=new Map;for(let e of t)s.set(e.id,a.has(n(e))?{status:"unchanged",changes:[],columns:{}}:{status:"added",changes:["new endpoint"],columns:{}});return s}(p?.endpoints??n,eX):e5,[m,p,n,eX,e5]),e4=(0,s.useMemo)(()=>[...t,...eH.relations.map(e=>({id:e.id,fromTableId:e.fromTableId,toTableId:e.toTableId,fromColumn:e.fromColumn,toColumn:e.toColumn,label:e.label}))],[t,eH.relations]),e6=(0,s.useMemo)(()=>{let e=new Map;for(let t of e0)for(let n of t.tables)e.set(n.tableId,(e.get(n.tableId)??0)+1);return e},[e0]),e8=(0,s.useMemo)(()=>{let e=new Map;return eY.forEach(t=>e.set(t.id,t.x)),e0.forEach(t=>e.set(t.id,t.x)),e},[eY,e0]),e9=(0,s.useMemo)(()=>{let e=new Map;return eY.forEach(t=>e.set(t.id,t.y)),e0.forEach(t=>e.set(t.id,t.y)),e},[eY,e0]),e7=(0,s.useMemo)(()=>{let e=new Map(eY.map(e=>[e.id,e.name])),t=new Map;for(let n of e4){let a=e.get(n.toTableId);if(!a)continue;let s=t.get(n.fromTableId)??{};s[n.fromColumn]=a,t.set(n.fromTableId,s)}return t},[e4,eY]),te=void 0!==I,[tt,tn]=(0,s.useState)(I??[]);(0,s.useEffect)(()=>{I&&tn(I)},[I]);let ta=(0,s.useMemo)(()=>({tables:eY.map(e=>({id:e.id,name:e.name,columns:e.columns.map(e=>e.name)})),endpoints:e0.map(e=>({id:e.id,method:e.method,path:e.path}))}),[eY,e0]),ts=(0,s.useMemo)(()=>{if(te){let e=new Set([...eY.map(e=>e.id),...e0.map(e=>e.id)]);return tt.filter(t=>e.has(t.targetId)).map((e,t)=>({id:e.id,n:t+1,targetId:e.targetId,column:e.columnName,text:e.body,x:e.x,y:e.y}))}let e=new Map((T??[]).map(e=>[e.id,e.comment]));return(0,D.m)(T??[],ta).map(t=>({id:t.annotationId,n:t.n,targetId:t.targetId,column:t.column,text:e.get(t.annotationId)??"",x:null,y:null}))},[te,tt,T,ta,eY,e0]),to=(0,s.useMemo)(()=>{let e=new Map;for(let t of ts){let n=e.get(t.targetId)??[];n.push({id:t.id,n:t.n,column:t.column}),e.set(t.targetId,n)}return e},[ts]),tl=(0,s.useMemo)(()=>new Map(ts.map(e=>[`anno-${e.id}`,e.targetId])),[ts]),ti=(0,s.useCallback)(async e=>{let t=(0,D.m)([{id:"_",excerpt:e}],ta)[0];if(!t)return;let n=await fetch("/api/board-annotations",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({targetKind:t.kind,targetId:t.targetId,columnName:t.column??void 0})});if(n.ok){let e=await n.json();tn(t=>[...t,e])}},[ta]),tr=(0,s.useCallback)((e,t)=>{tn(n=>n.map(n=>n.id===e?{...n,...t}:n)),fetch(`/api/board-annotations/${e}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(t)})},[]),td=(0,s.useCallback)(e=>{tn(t=>t.filter(t=>t.id!==e)),fetch(`/api/board-annotations/${e}`,{method:"DELETE"})},[]),tc=te?ti:C,tm=(0,s.useCallback)((e,t)=>{let n=(e8.get(t)??0)-(e8.get(e)??0),a=(e9.get(t)??0)-(e9.get(e)??0);return Math.abs(n)>=Math.abs(a)?n>=0?{sourceHandle:"sr",targetHandle:"tl"}:{sourceHandle:"sl",targetHandle:"tr"}:a>=0?{sourceHandle:"sb",targetHandle:"tt"}:{sourceHandle:"st",targetHandle:"tb"}},[e8,e9]),tu=(0,s.useMemo)(()=>new Set([...eH.tables.map(e=>e.id),...eH.endpoints.map(e=>e.id)]),[eH]),tp=(0,s.useMemo)(()=>new Set(e.map(e=>e.id)),[e]),th=(0,s.useCallback)(()=>{let e=eY.map(e=>({id:e.id,type:"dbTable",position:F?{x:e.x,y:e.y}:e1.get(e.id)??{x:e.x,y:e.y},data:{name:e.name,domain:e.domain,columns:e.columns,usageCount:e6.get(e.id)??0,source:e.source,rev:eK.rev,diffStatus:e2.get(e.id)?.status,diffChanges:e2.get(e.id)?.changes,diffColumns:e2.get(e.id)?.columns,fkTargets:e7.get(e.id),pins:to.get(e.id),onPinClick:M,onComment:tc}})),t=e0.map(e=>({id:e.id,type:"endpoint",position:{x:e.x,y:e.y},data:{method:e.method,path:e.path,domain:e.domain,source:e.source,rev:eK.rev,diffStatus:e3.get(e.id)?.status,diffChanges:e3.get(e.id)?.changes,pins:to.get(e.id),onPinClick:M,onComment:tc}})),n=new Map,a=new Map(eY.map(e=>[e.id,e])),s=new Map(e0.map(e=>[e.id,e]));return[...e,...t,...ts.map(e=>{let t=a.get(e.targetId),o=s.get(e.targetId),l=t?.x??o?.x??0,i=t?.y??o?.y??0,r=t?38+28*t.columns.length:42,d=n.get(e.targetId)??0;return n.set(e.targetId,d+1),{id:`anno-${e.id}`,type:"annotation",position:{x:e.x??l+26,y:e.y??i+r+64+112*d},data:{n:e.n,text:e.text,annotationId:e.id,onClick:te||S?void 0:M,editable:te||!!S,onChangeText:te?(e,t)=>tr(e,{body:t}):S,onDelete:te?td:E}}})]},[eY,e0,F,e1,e6,eK.rev,e2,e3,e7,to,ts,te,M,S,E,tc,tr,td]),[tf,tx,tb]=(0,i.ck)(th()),tg=(0,s.useRef)(F);(0,s.useEffect)(()=>{let e=tg.current!==F;tg.current=F,tx(t=>{let n=new Map(t.map(e=>[e.id,e.position]));return th().map(t=>e&&"dbTable"===t.type?t:{...t,position:n.get(t.id)??t.position})}),e&&requestAnimationFrame(()=>eS.current?.fitView({duration:500,padding:.15,minZoom:.2,maxZoom:.9}))},[th,tx,F]);let ty=(0,s.useCallback)((e,t,n,a)=>{fetch("/api/db/position",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({kind:e,id:t,x:n,y:a})})},[]),tj=(0,s.useCallback)((e,t)=>{var n;let{x:a,y:s}=t.position,o=(n={readOnly:$,nodeId:t.id,isDraft:tu.has(t.id),boardMode:te}).readOnly?"none":n.nodeId.startsWith("anno-")?n.boardMode?"annotation":"none":n.isDraft?"draft":"real";"annotation"===o?tr(t.id.slice(5),{x:a,y:s}):"draft"===o?eZ(e=>e.tables.some(e=>e.id===t.id)?{...e,tables:e.tables.map(e=>e.id===t.id?{...e,x:a,y:s}:e)}:e.endpoints.some(e=>e.id===t.id)?{...e,endpoints:e.endpoints.map(e=>e.id===t.id?{...e,x:a,y:s}:e)}:e):"real"===o&&ty("endpoint"===t.type?"endpoint":"table",t.id,a,s)},[$,tu,eZ,ty,te,tr]),tk=(0,s.useMemo)(()=>e4.map(e=>({id:`fk-${e.id}`,source:e.fromTableId,target:e.toTableId,...tm(e.fromTableId,e.toTableId),type:"deletable",label:e.label??void 0,markerEnd:{type:r.TG.ArrowClosed,color:"#6b6b6b"},style:{stroke:"#6b6b6b"}})),[e4,tm]),tw=(0,s.useMemo)(()=>e0.flatMap(e=>e.tables.map(t=>{let n=x.ru[t.access]??"#5a5a5a";return{id:`u-${e.id}-${t.tableId}`,source:e.id,target:t.tableId,...tm(e.id,t.tableId),type:"default",markerEnd:{type:r.TG.ArrowClosed,color:n},style:{stroke:n,strokeDasharray:"4 4",opacity:.7}}})),[e0,tm]),tN=(0,s.useMemo)(()=>F?[...tk,...tw]:tk,[tk,tw,F]),tv=(0,s.useMemo)(()=>ts.map(e=>({id:`annoe-${e.id}`,source:e.targetId,sourceHandle:`pin-${e.id}`,target:`anno-${e.id}`,targetHandle:"in",type:"annotation",selectable:!1,zIndex:30,style:{stroke:w.V5,strokeWidth:1.5,opacity:.9}})),[ts]),tC=O?.id??_,tT=(0,s.useMemo)(()=>{if(B){let e=tN.find(e=>e.id===B);return e?new Set([e.source,e.target]):null}return tC?(0,x.F1)(tC,tN):null},[tC,B,tN]),tM=(0,s.useMemo)(()=>new Map(eY.map(e=>[e.id,{domain:e.domain,source:e.source}])),[eY]),tS=(0,s.useMemo)(()=>new Map(e0.map(e=>[e.id,{method:e.method,source:e.source}])),[e0]),tE=(0,s.useMemo)(()=>{let e=new Set;if(!F)for(let t of tS.keys())e.add(t);for(let[t,n]of tM)!eA.size||n.domain&&eA.has(n.domain)||e.add(t),eF.size&&!eF.has(n.source)&&e.add(t);for(let[t,n]of tS)eO.size&&!eO.has(n.method)&&e.add(t),eF.size&&!eF.has(n.source)&&e.add(t);return e},[F,tM,tS,eA,eF,eO]),tI=eT.trim().length>0,t$=(0,s.useMemo)(()=>{if(!tI)return null;let e=new Set;for(let t of eY)!tE.has(t.id)&&(0,Q.Qk)((0,Q.jF)(t),eT)&&e.add(t.id);for(let t of e0)!tE.has(t.id)&&(0,Q.Qk)((0,Q.sQ)(t),eT)&&e.add(t.id);return e},[eY,e0,tE,eT,tI]),tA=(0,s.useMemo)(()=>tI?[...(0,Q.r2)(eY.filter(e=>!tE.has(e.id)),eT,e=>(0,Q.jF)(e),e=>({id:e.id,label:e.name,sublabel:e.domain??"table",kind:"table"})),...(0,Q.r2)(e0.filter(e=>!tE.has(e.id)),eT,e=>(0,Q.sQ)(e),e=>({id:e.id,label:e.path,sublabel:e.method,kind:"endpoint"}))].slice(0,12):[],[eY,e0,tE,eT,tI]),tP=(0,s.useCallback)(e=>{eM(""),L(tS.has(e)?{id:e,kind:"endpoint"}:{id:e,kind:"table"}),H(null),q(!0),eN("details");let t=eS.current?.getNode(e);if(!t||!eS.current)return;let n=t.measured?.width??220,a=t.measured?.height??80;eS.current.setCenter(t.position.x+n/2,t.position.y+a/2,{zoom:.9,duration:600})},[tS]),tz=t$??tT,tD=(0,s.useMemo)(()=>tf.map(e=>{if(e.id.startsWith("anno-")){let t=tl.get(e.id),n=!!t&&tE.has(t);return!!e.hidden!==n?{...e,hidden:n}:e}let t=tE.has(e.id);if(!tz)return t?{...e,hidden:t}:e;let n=tz.has(e.id),a=t$?Q.Uy:.45;return{...e,hidden:t,style:{...e.style,opacity:n?1:a,boxShadow:n&&t$?Q.RU:e.style?.boxShadow,borderRadius:n&&t$?12:e.style?.borderRadius,transition:"opacity 120ms, box-shadow 120ms"}}}),[tf,tE,tz,t$,tl]),tF=(0,s.useMemo)(()=>{let e=new Map(eY.map(e=>[e.id,(e.domain??"").trim()||"—"])),t=es(eY,e0.map(e=>({id:e.id,method:e.method,path:e.path,uses:e.tables.map(e=>({tableId:e.tableId}))})));return new Map(e0.map(n=>{let a=t.get(n.id);return[n.id,a?e.get(a):en]}))},[eY,e0]),tR=(0,s.useMemo)(()=>{let e=[];for(let t of tf)if(!tE.has(t.id))if("dbTable"===t.type){let n=t.data;e.push({id:t.id,group:(n.domain??"").trim()||"—",x:t.position.x,y:t.position.y,w:t.measured?.width??280,h:t.measured?.height??38+28*n.columns.length})}else"endpoint"===t.type&&e.push({id:t.id,group:tF.get(t.id)??en,x:t.position.x,y:t.position.y,w:t.measured?.width??240,h:t.measured?.height??50});return(0,Y.S)(e)},[tf,tE,tF]),tO=(0,s.useMemo)(()=>t$?tN.map(e=>{let t=tE.has(e.source)||tE.has(e.target);return t$.has(e.source)&&t$.has(e.target)?{...e,hidden:t,style:{...e.style,opacity:1}}:{...e,hidden:t,label:void 0,style:{...e.style,opacity:.08}}}):tN.map(e=>{let t=tE.has(e.source)||tE.has(e.target);return tC||B?(B?e.id===B:tC&&(e.source===tC||e.target===tC))?{...e,hidden:t,zIndex:20,style:{...e.style,opacity:1,strokeWidth:2.5}}:{...e,hidden:t,selectable:!1,label:void 0,markerEnd:void 0,style:{...e.style,opacity:.08}}:{...e,hidden:t,label:void 0}}),[tN,tC,B,tE,t$]),tL=(0,s.useMemo)(()=>Array.from(new Set(eY.map(e=>e.domain).filter(e=>!!e))).sort(),[eY]),tK=(0,s.useMemo)(()=>Array.from(new Set([...eY.map(e=>e.source),...e0.map(e=>e.source)])).sort(),[eY,e0]),tB=(0,s.useMemo)(()=>Array.from(new Set(e0.map(e=>e.method))).sort(),[e0]);function tH(e,t){t(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}let t_=+!F+eA.size+eF.size+eO.size,tZ=(0,s.useCallback)(()=>{R(!0),eP(new Set),eR(new Set),eL(new Set)},[]),tU=(0,s.useCallback)(e=>{let{source:t,target:n}=e;t&&n&&t!==n&&e_(e=>{if(!(e.tables.some(e=>e.id===n)||tp.has(n)))return e;let a=e.endpoints.find(e=>e.id===t);return a?a.links.some(e=>e.tableId===n)?e:{...e,endpoints:e.endpoints.map(e=>{var a;return e.id===t?{...e,links:[...e.links,{tableId:n,access:(a=e.method,X.has(a.trim().toUpperCase())?"read":"write")}]}:e})}:e.tables.find(e=>e.id===t)?e.relations.some(e=>e.fromTableId===t&&e.toTableId===n)?e:{...e,relations:[...e.relations,{id:crypto.randomUUID(),fromTableId:t,toTableId:n,fromColumn:"fk",toColumn:"id",label:null}]}:e})},[e_,tp]),tq=(0,s.useMemo)(()=>({readOnly:$,patchEndpoint:(e,t)=>e_(n=>({...n,endpoints:n.endpoints.map(n=>n.id===e?{...n,...t}:n)})),deleteEndpoint:e=>e_(t=>({...t,endpoints:t.endpoints.filter(t=>t.id!==e)})),patchTable:(e,t)=>e_(n=>({...n,tables:n.tables.map(n=>n.id===e?{...n,...t}:n)})),deleteTable:e=>e_(t=>({...t,tables:t.tables.filter(t=>t.id!==e),relations:t.relations.filter(t=>t.fromTableId!==e&&t.toTableId!==e),endpoints:t.endpoints.map(t=>({...t,links:t.links.filter(t=>t.tableId!==e)}))})),deleteRealEndpoint:e=>{fetch(`/api/endpoints/${e}`,{method:"DELETE"}).then(e=>{e.ok&&A.refresh()})}}),[$,e_,A]);(0,s.useEffect)(()=>{let e=e=>{if(!(e.metaKey||e.ctrlKey))return;let t=e.target;if(t&&/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))return;let n=e.key.toLowerCase();"z"===n?(e.preventDefault(),e.shiftKey?eq():eU()):"y"===n&&(e.preventDefault(),eq())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[eU,eq]);let tW=(0,s.useCallback)(async()=>{eC(!0);try{if((await fetch("/api/draft/approve",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(eH)})).ok){try{localStorage.removeItem(ey)}catch{}eW(ej),A.refresh()}}finally{eC(!1)}},[eH,eW,A]),tG=(0,s.useCallback)(async()=>{eC(!0);try{await fetch("/api/draft",{method:"DELETE"})}catch{}try{localStorage.removeItem(ey)}catch{}eW(ej),A.refresh(),eC(!1)},[eW,A]),tJ=(0,s.useMemo)(()=>{let e;return e=new Map(eH.tables.map(e=>[e.id,e.name])),{tables:eH.tables.map(e=>({name:e.name,domain:e.domain,description:e.description,columns:e.columns.map(e=>({name:e.name,type:e.type,isPk:e.isPk,isFk:e.isFk,nullable:e.nullable,note:e.note}))})),relations:eH.relations.flatMap(t=>{let n=e.get(t.fromTableId),a=e.get(t.toTableId);return n&&a?[{fromTable:n,fromColumn:t.fromColumn,toTable:a,toColumn:t.toColumn,label:t.label}]:[]}),endpoints:eH.endpoints.map(t=>({method:t.method,path:t.path,domain:t.domain,description:t.description,uses:t.links.flatMap(t=>{let n=e.get(t.tableId);return n?[{table:n,access:t.access}]:[]})}))}},[eH]),tQ=eH.tables.length>0||eH.endpoints.length>0,tV=eK.past.length>0,tX=eK.future.length>0;return(0,a.jsx)(b.Provider,{value:tq,children:(0,a.jsxs)("div",{className:(0,f.cn)("canvas-dots relative w-full",m?"h-full":"h-screen",ef&&"rf-panning"),children:[(0,a.jsxs)(i.Gc,{...e$,nodes:tD,edges:"far"===ez?[...tO,...tv].map(e=>({...e,hidden:!0})):[...tO,...tv.map(e=>({...e,hidden:tE.has(e.source)}))],nodeTypes:eb,edgeTypes:eg,nodesConnectable:!$,connectionMode:r.WZ.Loose,connectionLineStyle:{stroke:"var(--accent-2,#ff7a45)",strokeWidth:1.5,strokeDasharray:"4 4"},onInit:e=>{eS.current=e},onNodesChange:tb,onMoveStart:()=>ex(!0),onMoveEnd:()=>ex(!1),onConnect:tU,onNodeMouseEnter:(e,t)=>{"annotation"!==t.type&&Z(t.id)},onNodeMouseLeave:()=>Z(null),onNodeClick:(e,t)=>{if("annotation"===t.type){let e=t.data;e.editable||M?.(e.annotationId);return}let n="endpoint"===t.type?"endpoint":"table";L({id:t.id,kind:n}),H(null),q(!0),eN("details")},onEdgeClick:(e,t)=>{H(t.id),L(null)},onPaneClick:()=>{L(null),H(null),q(!1)},onNodeDragStop:tj,onEdgesDelete:e=>{for(let t of e)if(t.id.startsWith("fk-")){let e=t.id.slice(3);fetch(`/api/db/relations/${e}`,{method:"DELETE"})}},onNodesDelete:e=>{for(let t of e)t.id.startsWith("anno-")||tu.has(t.id)||("endpoint"===t.type?fetch(`/api/endpoints/${t.id}`,{method:"DELETE"}):"dbTable"===t.type&&fetch(`/api/db/tables/${t.id}`,{method:"DELETE"}))},deleteKeyCode:$?null:["Backspace","Delete"],colorMode:"dark",fitView:!0,fitViewOptions:{padding:.15,minZoom:.38,maxZoom:.9},minZoom:.15,panOnScroll:!0,zoomActivationKeyCode:["Meta","Control"],proOptions:{hideAttribution:!0},children:[(0,a.jsx)(el.Z,{regions:tR,tone:"category",lod:ez}),(0,a.jsx)(y.J,{onLod:eD,thresholds:j.fE}),(0,a.jsx)(i.H2,{position:"bottom-right",className:"!overflow-hidden !rounded-xl !border !border-white/10 [&_button]:!border-white/10 [&_button]:!bg-card/70 [&_button]:!text-foreground [&_button]:!backdrop-blur"}),!m&&(0,a.jsx)(i.of,{pannable:!0,zoomable:!0,position:"bottom-left",style:{width:140,height:90},className:"!overflow-hidden !rounded-xl !border !border-white/10 !bg-card/50 !backdrop-blur",nodeColor:"#555"}),(0,a.jsx)(i.Zk,{position:"bottom-left",style:{marginBottom:118},children:(0,a.jsx)(o.H,{tool:eE,onChange:eI})}),!m&&(0,a.jsx)(i.Zk,{position:"bottom-center",className:"!mb-4",children:(0,a.jsx)("div",{className:"glass flex items-center rounded-full p-0.5",children:(0,a.jsxs)("button",{type:"button",disabled:ev,title:"Re-arrange the board — domain clusters with endpoints docked under their tables",onClick:async()=>{eC(!0);try{let e=window.innerWidth/window.innerHeight;await fetch("/api/db/arrange",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({viewportAspect:e})}),A.refresh()}finally{eC(!1)}},className:"flex h-6 items-center gap-1.5 rounded-full px-3 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground disabled:opacity-40",children:[(0,a.jsx)(er.A,{className:"size-3"}),ev?"Arranging…":"Arrange"]})})}),!m&&(0,a.jsx)(i.Zk,{position:"top-right",className:(0,f.cn)("glass rounded-full px-1 py-0.5 transition-[margin] duration-200",U&&"!mr-[332px]"),children:(0,a.jsx)(V.Z,{active:"DATABASE",tabs:[{value:"ROADMAP",label:"Roadmap",href:"/map?view=ROADMAP"},{value:"ARCHITECTURE",label:"Architecture",href:"/map?view=ARCHITECTURE"},{value:"DATABASE",label:"Database",href:"/map?view=DATABASE"},{value:"FILES",label:"Files",href:"/map?view=FILES"}]})}),(0,a.jsxs)(i.Zk,{position:"top-right",className:(0,f.cn)("!mt-14 flex items-center gap-1 transition-[margin] duration-200",U&&"!mr-[332px]",m&&"hidden"),children:[(0,a.jsx)(G.X,{query:eT,onQuery:eM,hits:tA,placeholder:"Find a table, column, endpoint…",onPick:tP,onZoomToMatches:()=>{t$?.size&&eS.current?.fitView({nodes:[...t$].map(e=>({id:e})),duration:600,padding:.2})}}),(0,a.jsx)(J.e,{defaultSelection:"DATABASE"}),(0,a.jsxs)(W.er,{title:"Filters",trigger:(e,t)=>(0,a.jsxs)("button",{type:"button",onClick:t,title:"Filters",className:(0,f.cn)("glass relative flex size-8 items-center justify-center rounded-lg transition-colors",e||t_>0?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[(0,a.jsx)(ed.A,{className:"size-4"}),t_>0&&(0,a.jsx)("span",{className:"absolute -right-1 -top-1 flex h-4 min-w-4 items-center justify-center rounded-full bg-[var(--accent-2,#ff7a45)] px-1 text-[9px] font-semibold text-white",children:t_})]}),children:[(0,a.jsx)(W.r1,{title:"Show",children:(0,a.jsx)(W.vu,{tone:"accent",on:F,onClick:()=>R(e=>!e),children:"endpoints"})}),tL.length>0&&(0,a.jsx)(W.r1,{title:"Domain",children:tL.map(e=>(0,a.jsx)(W.vu,{on:eA.has(e),onClick:()=>tH(e,eP),children:e},e))}),tB.length>0&&(0,a.jsx)(W.r1,{title:"Method",children:tB.map(e=>(0,a.jsx)(W.vu,{on:eO.has(e),onClick:()=>tH(e,eL),children:e},e))}),tK.length>0&&(0,a.jsx)(W.r1,{title:"Source",children:tK.map(e=>(0,a.jsx)(W.vu,{on:eF.has(e),onClick:()=>tH(e,eR),children:e.toLowerCase()},e))}),t_>0&&(0,a.jsx)("button",{type:"button",onClick:tZ,className:"mt-1 w-full rounded-md border border-white/10 px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/5 hover:text-foreground",children:"clear filters"})]}),(0,a.jsx)(W.er,{title:"Legend",trigger:(e,t)=>(0,a.jsx)("button",{type:"button",onClick:t,title:"Legend",className:(0,f.cn)("glass flex size-8 items-center justify-center rounded-lg transition-colors",e?"text-foreground":"text-muted-foreground hover:text-foreground"),children:(0,a.jsx)(ec.A,{className:"size-4"})}),children:(0,a.jsxs)("ul",{className:"space-y-1.5 text-[10.5px] text-muted-foreground",children:[(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded border border-white/15 bg-white/[0.06] px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-foreground/80",children:"table"}),(0,a.jsx)("span",{children:"a database table \xb7 its columns"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded border border-white/15 bg-white/[0.06] px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-foreground/80",children:"endpoint"}),(0,a.jsx)("span",{children:"an API route \xb7 reads / writes tables"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"inline-block h-px w-6 bg-[#6b6b6b]"}),(0,a.jsx)("span",{children:"foreign key \xb7 drag from a table handle"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"inline-block h-0 w-6 border-t border-dashed",style:{borderColor:"#4ea1ff"}}),(0,a.jsx)("span",{children:"endpoint read \xb7 GET / POST / etc"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"inline-block h-0 w-6 border-t border-dashed",style:{borderColor:"#ffb86b"}}),(0,a.jsx)("span",{children:"endpoint write"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded border border-dashed border-sky-400/50 px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-sky-300",children:"draft"}),(0,a.jsx)("span",{children:"agent-proposed \xb7 approve to persist"})]})]})}),!U&&(0,a.jsx)("button",{onClick:()=>q(!0),title:"Show panel",className:"glass flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:text-foreground",children:(0,a.jsx)(em.A,{className:"size-4"})})]}),tQ&&(0,a.jsxs)(i.Zk,{position:"bottom-center",className:"glass flex items-center gap-1 rounded-xl p-1.5",children:[(0,a.jsxs)("button",{onClick:eU,disabled:!tV,title:"Undo (⌘Z)",className:"flex items-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground disabled:opacity-30 disabled:hover:bg-transparent",children:[(0,a.jsx)(eu.A,{className:"size-3.5"})," undo"]}),(0,a.jsxs)("button",{onClick:eq,disabled:!tX,title:"Redo (⇧⌘Z)",className:"flex items-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground disabled:opacity-30 disabled:hover:bg-transparent",children:[(0,a.jsx)(ep.A,{className:"size-3.5"})," redo"]}),!m&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"mx-1 h-4 w-px bg-white/10"}),(0,a.jsxs)("button",{onClick:tG,disabled:ev,title:"Discard draft",className:"flex items-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-red-500/15 hover:text-red-300 disabled:opacity-40",children:[(0,a.jsx)(u.A,{className:"size-3.5"})," discard"]}),(0,a.jsxs)("button",{onClick:tW,disabled:ev,title:"Approve and persist to the schema",className:"flex items-center gap-1 rounded-md border border-emerald-500/40 bg-emerald-500/15 px-2.5 py-1 text-[11px] font-semibold text-emerald-300 transition-colors hover:bg-emerald-500/25 disabled:opacity-40",children:[(0,a.jsx)(eh.A,{className:"size-3.5"})," approve draft"]})]})]})]}),U&&(0,a.jsx)(K,{selected:O,tables:eY,relations:e4,endpoints:e0,draftGraph:tJ,onClose:()=>{q(!1),eN("details")},commentsContent:N,commentsCount:v,activeTab:ew,onTabChange:eN,onAddComment:tc,topOffset:m?64:void 0})]})})}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7177],{434:(e,t,s)=>{"use strict";s.d(t,{PlanBar:()=>u});var a=s(95155),n=s(98500),r=s.n(n),i=s(73321),l=s(86272),o=s(32133),c=s(65738),d=s(48484);function u(){let{status:e,discard:t}=(0,d.j)(),s=(0,i.usePathname)();return e.pending&&"/plan"!==s?(0,a.jsx)("div",{className:"pointer-events-none fixed inset-x-0 top-14 z-40 flex justify-center px-2",children:(0,a.jsxs)("div",{className:"pointer-events-auto flex max-w-3xl items-center gap-2 rounded-xl border border-emerald-500/30 bg-card/85 px-3 py-1.5 shadow-lg backdrop-blur supports-[backdrop-filter]:bg-card/70",children:[(0,a.jsx)(l.A,{className:"size-3.5 shrink-0 text-emerald-300"}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"truncate text-[12px] leading-tight text-foreground",children:[(0,a.jsx)("span",{className:"text-emerald-300/80",children:"Plan ready \xb7 "}),e.description||"(no description)"]}),(0,a.jsxs)("div",{className:"text-[10px] leading-tight text-muted-foreground",children:[e.features," feature(s) \xb7 ",e.tables," table(s) \xb7 ",e.endpoints," ","endpoint(s)"]})]}),(0,a.jsxs)(r(),{href:"/plan",className:"flex shrink-0 items-center gap-1 rounded-md border border-emerald-500/40 bg-emerald-500/15 px-2 py-1 text-[11px] font-semibold text-emerald-300 transition-colors hover:bg-emerald-500/25",title:"Open Plannotator + canvases side by side",children:[(0,a.jsx)(o.A,{className:"size-3"})," Open plan"]}),(0,a.jsxs)("button",{onClick:t,className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-red-500/15 hover:text-red-300",title:"Discard the plan",children:[(0,a.jsx)(c.A,{className:"size-3"})," Discard"]})]})}):null}},10436:(e,t,s)=>{"use strict";s.d(t,{TopNav:()=>b});var a=s(95155),n=s(12115),r=s(98500),i=s.n(r),l=s(73321),o=s(82879),c=s(52965);let d=(0,s(30772).A)("folder-git-2",[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]);var u=s(26518),h=s(91337),x=s(60292);function p({fallback:e}){let[t,s]=(0,n.useState)([]),[r,i]=(0,n.useState)(null);if((0,n.useEffect)(()=>{let e=!0,t=()=>fetch("/api/workspace").then(e=>e.ok?e.json():null).then(t=>{e&&t&&(s(t.workspaces??[]),i((0,x.fk)()??t.active??null))}).catch(()=>{});t();let a=setInterval(t,5e3);return()=>{e=!1,clearInterval(a)}},[]),0===t.length)return e?(0,a.jsxs)("span",{className:"font-mono text-xs text-muted-foreground",children:["\xb7 ",e]}):null;async function l(e){i(e),(0,x.aE)(e),await Promise.race([fetch("/api/workspace",{method:"POST",headers:{"content-type":"application/json","x-beacon-workspace":e},body:JSON.stringify({id:e}),signal:AbortSignal.timeout(8e3)}).catch(()=>{}),new Promise(e=>setTimeout(e,2500))]);let t=new URLSearchParams(window.location.search);t.set("ws",e),window.location.href=`${window.location.pathname}?${t.toString()}`}let o=t.find(e=>e.id===r);return(0,a.jsxs)(u.l6,{value:r??"",onValueChange:e=>e&&l(e),children:[(0,a.jsxs)(u.bq,{title:o?.name,className:"h-7 max-w-[180px] gap-1.5 rounded-lg border-white/12 bg-white/[0.04] px-2 text-xs font-medium transition-colors hover:bg-white/[0.07]",children:[(0,a.jsx)(d,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,a.jsx)(u.yv,{children:()=>o?.name??"Project"})]}),(0,a.jsxs)(u.gC,{align:"start",alignItemWithTrigger:!1,sideOffset:6,className:"min-w-[250px] border border-white/10 bg-popover/95 p-1.5 backdrop-blur-xl",children:[(0,a.jsx)("p",{className:"px-2 pt-1 pb-1.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Workspace"}),t.map(e=>{var t,s;let n,i=e.id===r;return(0,a.jsx)(u.eb,{value:e.id,className:(0,h.cn)("gap-2.5 rounded-lg py-1.5 pr-8 pl-1.5 transition-colors",i&&"bg-white/[0.05]"),children:(0,a.jsxs)("span",{className:"flex items-center gap-2.5",children:[(0,a.jsx)("span",{className:(0,h.cn)("flex size-7 shrink-0 items-center justify-center rounded-md border",i?"border-sky-400/30 bg-sky-400/10 text-sky-300":"border-white/10 bg-white/[0.03] text-muted-foreground"),children:(0,a.jsx)(d,{className:"size-3.5"})}),(0,a.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,a.jsx)("span",{className:"truncate text-[13px] font-medium leading-tight text-foreground",children:e.name}),(0,a.jsx)("span",{className:"truncate font-mono text-[10px] leading-tight text-muted-foreground",children:(t=e.path,s=e.name,(n=t.replace(/^\/(Users|home)\/[^/]+/,"~").split("/").filter(Boolean))[n.length-1]===s&&n.pop(),(n.length>3?[n[0],"…",n[n.length-1]]:n).join("/")||"~")})]})]})},e.id)})]})]})}var m=s(81984);let f=[{href:"/plan",label:"Plans"},{href:"/map",label:"Map"},{href:"/learn",label:"Learn"},{href:"/settings",label:"Settings"}];function b({repo:e}){let t=(0,l.usePathname)(),{toggle:s,open:r}=(0,m.b)(),[d,u]=(0,n.useState)(null);return(0,n.useEffect)(()=>{u((0,x.fk)())},[t]),(0,a.jsx)("header",{className:"pointer-events-none fixed left-3 top-3 z-30",children:(0,a.jsxs)("div",{className:"glass pointer-events-auto flex h-10 items-center gap-1 rounded-full pl-3 pr-1.5",children:[(0,a.jsxs)(i(),{href:"/",className:"mr-1 flex items-center gap-2 text-sm font-semibold tracking-tight",children:[(0,a.jsx)(c._,{size:18,className:"text-foreground"}),(0,a.jsx)("span",{className:"hidden lg:inline",children:"Beacon"})]}),(0,a.jsx)("span",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-white/10"}),(0,a.jsx)(p,{fallback:e}),(0,a.jsx)("span",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-white/10"}),(0,a.jsx)("nav",{className:"flex items-center gap-0.5 text-sm",children:f.map(e=>{let s=t===e.href||t.startsWith(e.href+"/");return(0,a.jsx)(i(),{href:(0,x.Fj)(e.href,d),className:(0,h.cn)("rounded-full px-3 py-1 text-[13px] tracking-tight transition-colors",s?"bg-white/[0.09] text-foreground shadow-[inset_0_1px_0_rgba(255,255,255,0.06)]":"text-muted-foreground hover:bg-white/[0.04] hover:text-foreground"),children:e.label},e.href)})}),(0,a.jsx)("span",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-white/10"}),(0,a.jsx)("button",{type:"button",onClick:s,"aria-pressed":r,"aria-label":"Notes",title:"Notes",className:(0,h.cn)("flex items-center justify-center rounded-full p-1.5 transition-colors",r?"bg-white/[0.09] text-foreground shadow-[inset_0_1px_0_rgba(255,255,255,0.06)]":"text-muted-foreground hover:bg-white/[0.04] hover:text-foreground"),children:(0,a.jsx)(o.A,{className:"size-4"})})]})})}},15053:(e,t,s)=>{Promise.resolve().then(s.t.bind(s,66872,23)),Promise.resolve().then(s.bind(s,52174)),Promise.resolve().then(s.bind(s,81998)),Promise.resolve().then(s.bind(s,81984)),Promise.resolve().then(s.bind(s,71886)),Promise.resolve().then(s.bind(s,434)),Promise.resolve().then(s.bind(s,48484)),Promise.resolve().then(s.bind(s,77242)),Promise.resolve().then(s.bind(s,10436)),Promise.resolve().then(s.bind(s,29510)),Promise.resolve().then(s.t.bind(s,35353,23)),Promise.resolve().then(s.t.bind(s,63494,23))},29510:(e,t,s)=>{"use strict";s.d(t,{UpdateBanner:()=>h});var a=s(95155),n=s(12115);let r=(0,s(30772).A)("circle-arrow-up",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);var i=s(9005),l=s(64577),o=s(99314),c=s(39593);function d(e){if("string"!=typeof e)return null;let t=e.trim().replace(/^v/i,"").match(/^(\d+)(?:\.(\d+))?(?:\.(\d+))?/);return t?[Number(t[1]),Number(t[2]??0),Number(t[3]??0)]:null}let u="beacon:update-dismissed";function h({currentVersion:e}){let[t,s]=(0,n.useState)(null),[x,p]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{let t=!1;return(async()=>{try{let a=await fetch(c.kw);if(!a.ok)return;let n=await a.json(),r="string"==typeof n?.version?n.version:"";if(t||!function(e,t){let s=d(e),a=d(t);if(!s||!a)return!1;for(let e=0;e<3;e++){if(s[e]>a[e])return!0;if(s[e]<a[e])break}return!1}(r,e)||localStorage.getItem(u)===r)return;s(r)}catch{}})(),()=>{t=!0}},[e]),!t)return null;let m=async()=>{try{await navigator.clipboard?.writeText(c.EO),p(!0),setTimeout(()=>p(!1),1600)}catch{}};return(0,a.jsx)("div",{className:"pointer-events-none fixed bottom-4 right-4 z-50 flex justify-end",children:(0,a.jsx)("div",{className:"glass pointer-events-auto w-[320px] rounded-xl p-3.5 shadow-xl",children:(0,a.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,a.jsx)(r,{className:"mt-0.5 size-4 shrink-0 text-[#ff7a45]"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsx)("p",{className:"text-[13px] font-semibold tracking-tight text-foreground",children:"New version available"}),(0,a.jsx)("button",{type:"button",onClick:()=>{try{localStorage.setItem(u,t)}catch{}s(null)},"aria-label":"Dismiss",className:"shrink-0 rounded-md p-0.5 text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:(0,a.jsx)(i.A,{className:"size-3.5"})})]}),(0,a.jsxs)("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:[e," →"," ",(0,a.jsx)("span",{className:"text-foreground",children:t.replace(/^v/i,"")})," \xb7 update Beacon"]}),(0,a.jsxs)("button",{type:"button",onClick:m,title:"Copy the update command",className:"mt-2.5 flex w-full items-center justify-between gap-2 rounded-lg border border-white/10 bg-black/30 px-2.5 py-1.5 text-left font-mono text-[11px] text-muted-foreground transition-colors hover:border-white/20 hover:text-foreground",children:[(0,a.jsx)("span",{className:"truncate",children:c.EO}),x?(0,a.jsx)(l.A,{className:"size-3.5 shrink-0 text-[#ff7a45]"}):(0,a.jsx)(o.A,{className:"size-3.5 shrink-0"})]})]})]})})})}},35353:e=>{e.exports={style:{fontFamily:"'Geist', 'Geist Fallback'",fontStyle:"normal"},className:"__className_246ccd",variable:"__variable_246ccd"}},38332:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(30772).A)("strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]])},39593:(e,t,s)=>{"use strict";s.d(t,{EO:()=>i,kw:()=>n});var a=s(41463);let n="https://registry.npmjs.org/trybeacon/latest",r=(a.env.NEXT_PUBLIC_BEACON_SITE_URL??"https://www.trybeacon.sh").replace(/\/$/,""),i=`curl -fsSL ${r}/install.sh | sh`},48484:(e,t,s)=>{"use strict";s.d(t,{PlanProvider:()=>d,j:()=>u});var a=s(95155),n=s(12115),r=s(73321),i=s(60292),l=s(99979);let o={pending:!1,proposedAt:0,tables:0,endpoints:0,features:0},c=(0,n.createContext)(null);function d({children:e}){let t=(0,r.useRouter)(),[s,u]=(0,n.useState)(o),h=(0,n.useCallback)(async()=>{try{let e=await fetch("/api/plan",{method:"GET",cache:"no-store",headers:(0,i.dh)((0,l.X0)())});if(!e.ok)return;let t=await e.json();u(t)}catch{}},[]);(0,n.useEffect)(()=>{h();let e=setInterval(()=>void h(),4e3);return()=>clearInterval(e)},[h]);let x=(0,n.useCallback)(async()=>{await fetch("/api/plan",{method:"DELETE",headers:(0,i.dh)((0,l.X0)())}).catch(()=>{}),u(o),t.refresh()},[t]),p=(0,n.useCallback)(async()=>{await fetch("/api/plan/approve",{method:"POST",headers:(0,i.dh)((0,l.X0)())}).catch(()=>{}),u(o),t.refresh()},[t]);return(0,a.jsx)(c.Provider,{value:{status:s,discard:x,approvePlan:p,refresh:h},children:e})}function u(){let e=(0,n.useContext)(c);if(!e)throw Error("usePlan must be used inside PlanProvider");return e}},52174:(e,t,s)=>{"use strict";s.d(t,{MainRegion:()=>n});var a=s(95155);function n({children:e}){return(0,a.jsx)("main",{className:"flex flex-1 flex-col",children:e})}},52965:(e,t,s)=>{"use strict";s.d(t,{_:()=>n});var a=s(95155);function n({size:e=18,className:t}){return(0,a.jsxs)("svg",{width:e,height:e,viewBox:"20 22 56 56",fill:"none",className:t,"aria-hidden":"true",children:[(0,a.jsx)("path",{d:"M48 33 L72.5 73 L23.5 73 Z",fill:"none",stroke:"var(--accent-2, #ff7a45)",strokeWidth:7,strokeLinejoin:"round",strokeLinecap:"round"}),(0,a.jsx)("circle",{cx:"48",cy:"29.5",r:"7",fill:"var(--accent-2, #ff7a45)"})]})}},63494:e=>{e.exports={style:{fontFamily:"'Geist Mono', 'Geist Mono Fallback'",fontStyle:"normal"},className:"__className_c29908",variable:"__variable_c29908"}},66872:()=>{},71886:(e,t,s)=>{"use strict";s.d(t,{NotesDrawer:()=>A});var a=s(95155),n=s(12115),r=s(82879),i=s(2125),l=s(9005),o=s(30772);let c=(0,o.A)("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]),d=(0,o.A)("pin-off",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);var u=s(65738),h=s(82099),x=s(13439),p=s(95112),m=s(67357);let f=(0,o.A)("underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]);var b=s(38332),g=s(8143),v=s(58309),j=s(5497),w=s(54682),k=s(93492);function N({value:e,onChange:t}){let s=(0,x.hG)({extensions:w.II,content:e?(0,w.Gd)(e):void 0,immediatelyRender:!1,editorProps:{attributes:{class:"note-prose focus:outline-none"}},onUpdate:({editor:e})=>t((0,w.Z2)(e.getJSON()))});return s?(0,a.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,a.jsx)(y,{editor:s}),(0,a.jsx)(x.$Z,{editor:s,className:"min-h-0 flex-1 overflow-y-auto px-1 py-2 text-[14px] leading-relaxed"})]}):null}function y({editor:e}){(0,k.U)(e);let t=()=>e.chain().focus();return(0,a.jsxs)("div",{className:"flex items-center gap-0.5 border-b border-white/10 pb-2",children:[(0,a.jsx)(k.I,{label:"Bold",active:e.isActive("bold"),onClick:()=>t().toggleBold().run(),children:(0,a.jsx)(p.A,{className:"size-4"})}),(0,a.jsx)(k.I,{label:"Italic",active:e.isActive("italic"),onClick:()=>t().toggleItalic().run(),children:(0,a.jsx)(m.A,{className:"size-4"})}),(0,a.jsx)(k.I,{label:"Underline",active:e.isActive("underline"),onClick:()=>t().toggleUnderline().run(),children:(0,a.jsx)(f,{className:"size-4"})}),(0,a.jsx)(k.I,{label:"Strikethrough",active:e.isActive("strike"),onClick:()=>t().toggleStrike().run(),children:(0,a.jsx)(b.A,{className:"size-4"})}),(0,a.jsx)("span",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-white/10"}),(0,a.jsx)(k.I,{label:"Checklist",active:e.isActive("taskList"),onClick:()=>t().toggleTaskList().run(),children:(0,a.jsx)(g.A,{className:"size-4"})}),(0,a.jsx)(k.I,{label:"Bullet list",active:e.isActive("bulletList"),onClick:()=>t().toggleBulletList().run(),children:(0,a.jsx)(v.A,{className:"size-4"})}),(0,a.jsx)(k.I,{label:"Numbered list",active:e.isActive("orderedList"),onClick:()=>t().toggleOrderedList().run(),children:(0,a.jsx)(j.A,{className:"size-4"})})]})}var C=s(81984),P=s(91337);function S(e){return[...e].sort((e,t)=>e.pinned!==t.pinned?Number(t.pinned)-Number(e.pinned):t.updatedAt.localeCompare(e.updatedAt))}function A(){let{open:e,close:t}=(0,C.b)(),[s,o]=(0,n.useState)([]),[x,p]=(0,n.useState)(null),m=(0,n.useRef)({}),f=(0,n.useRef)({}),b=(0,n.useCallback)(e=>{clearTimeout(m.current[e]);let t=f.current[e];t&&(delete f.current[e],fetch(`/api/notes/${e}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(t)}).catch(()=>{}))},[]),g=(0,n.useCallback)((e,t)=>{f.current[e]={...f.current[e],...t},clearTimeout(m.current[e]),m.current[e]=setTimeout(()=>b(e),500)},[b]),v=(0,n.useCallback)(async()=>{try{let e=await fetch("/api/notes",{cache:"no-store"});if(!e.ok)return;let t=await e.json();o(S(t)),p(e=>e??t[0]?.id??null)}catch{}},[]);(0,n.useEffect)(()=>{e?v():Object.keys(f.current).forEach(b)},[e,v,b]);let j=(0,n.useCallback)(async()=>{let e=await fetch("/api/notes",{method:"POST"}).catch(()=>null);if(!e?.ok)return;let t=await e.json();o(e=>S([t,...e])),p(t.id)},[]),w=(0,n.useCallback)(async e=>{clearTimeout(m.current[e]),delete f.current[e],o(t=>{let s=t.filter(t=>t.id!==e);return p(t=>t===e?s[0]?.id??null:t),s}),await fetch(`/api/notes/${e}`,{method:"DELETE"}).catch(()=>{})},[]),k=(0,n.useCallback)((e,t)=>{o(s=>S(s.map(s=>s.id===e?{...s,...t,updatedAt:new Date().toISOString()}:s))),g(e,t)},[g]),y=(0,n.useCallback)(e=>k(e.id,{pinned:!e.pinned}),[k]),A=s.find(e=>e.id===x)??null;return(0,a.jsx)("div",{"aria-hidden":!e,className:(0,P.cn)("fixed inset-y-0 right-0 z-40 flex transition-transform duration-300 ease-out",e?"translate-x-0":"pointer-events-none translate-x-full"),children:(0,a.jsxs)(h.b,{className:"flex h-full w-[420px] flex-col rounded-l-2xl border-l border-white/10",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 border-b border-white/10 px-3 py-2.5",children:[(0,a.jsx)(r.A,{className:"size-4 text-[var(--accent-2,#ff7a45)]"}),(0,a.jsx)("span",{className:"text-sm font-semibold tracking-tight",children:"Notes"}),(0,a.jsx)("span",{className:"ml-auto"}),(0,a.jsx)("button",{type:"button",onClick:j,"aria-label":"New note",title:"New note",className:"rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:(0,a.jsx)(i.A,{className:"size-4"})}),(0,a.jsx)("button",{type:"button",onClick:t,"aria-label":"Close notes",title:"Close",className:"rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:(0,a.jsx)(l.A,{className:"size-4"})})]}),(0,a.jsx)("div",{className:"max-h-44 shrink-0 overflow-y-auto border-b border-white/10 p-1.5",children:0===s.length?(0,a.jsxs)("p",{className:"px-2 py-3 text-[13px] text-muted-foreground",children:["No notes yet. Hit ",(0,a.jsx)("span",{className:"text-foreground",children:"+"})," to start one."]}):s.map(e=>(0,a.jsxs)("div",{className:(0,P.cn)("group flex items-center gap-1 rounded-md px-2 py-1.5 text-[13px]",e.id===x?"bg-white/[0.09] text-foreground":"text-muted-foreground hover:bg-white/[0.04]"),children:[(0,a.jsxs)("button",{type:"button",onClick:()=>p(e.id),className:"min-w-0 flex-1 truncate text-left",children:[e.pinned&&(0,a.jsx)(c,{className:"mr-1 inline size-3 -translate-y-px"}),e.title||"Untitled"]}),(0,a.jsx)("button",{type:"button",onClick:()=>y(e),"aria-label":e.pinned?"Unpin":"Pin",title:e.pinned?"Unpin":"Pin",className:"rounded p-1 opacity-0 transition hover:bg-white/[0.08] hover:text-foreground group-hover:opacity-100",children:e.pinned?(0,a.jsx)(d,{className:"size-3.5"}):(0,a.jsx)(c,{className:"size-3.5"})}),(0,a.jsx)("button",{type:"button",onClick:()=>w(e.id),"aria-label":"Delete note",title:"Delete",className:"rounded p-1 opacity-0 transition hover:bg-white/[0.08] hover:text-red-300 group-hover:opacity-100",children:(0,a.jsx)(u.A,{className:"size-3.5"})})]},e.id))}),A?(0,a.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-2 p-3",children:[(0,a.jsx)("input",{value:A.title,onChange:e=>k(A.id,{title:e.target.value}),placeholder:"Untitled",className:"w-full bg-transparent text-base font-semibold tracking-tight text-foreground placeholder:text-muted-foreground/60 focus:outline-none"}),(0,a.jsx)(N,{value:A.body,onChange:e=>k(A.id,{body:e})},A.id)]}):(0,a.jsxs)("div",{className:"flex flex-1 items-center justify-center p-6 text-center text-[13px] text-muted-foreground",children:["Select a note, or create one. Then ",(0,a.jsx)("span",{className:"px-1 text-foreground",children:"@"}),"-mention it in your terminal to turn it into features."]})]})})}},77242:(e,t,s)=>{"use strict";s.d(t,{TabWorkspace:()=>i});var a=s(12115),n=s(73321),r=s(60292);function i(){let e=(0,n.useRouter)(),t=(0,n.usePathname)();return(0,a.useEffect)(()=>{let e=window.fetch;if(e.__beaconPinned)return;let t=(t,s)=>{try{let a=(0,r.fk)();if(a){let n=window.location.origin;if(t instanceof Request){if((0,r.q0)(t.url,n)&&!t.headers.has("x-beacon-workspace")){let n=new Headers(t.headers);return n.set("x-beacon-workspace",a),e(new Request(t,{headers:n}),s)}}else{let i="string"==typeof t?t:t.href;if((0,r.q0)(i,n)){let n=new Headers(s?.headers);if(!n.has("x-beacon-workspace"))return n.set("x-beacon-workspace",a),e(t,{...s,headers:n})}}}}catch{}return e(t,s)};return t.__beaconPinned=!0,window.fetch=t,()=>{window.fetch=e}},[]),(0,a.useEffect)(()=>{let s=new URLSearchParams(window.location.search).get("ws");if(s){try{sessionStorage.setItem(r.Bz,s)}catch{}return}let a=null;try{a=sessionStorage.getItem(r.Bz)}catch{}if(!a)return;let n=new URLSearchParams(window.location.search);n.set("ws",a),e.replace(`${t}?${n.toString()}`)},[t,e]),null}},81984:(e,t,s)=>{"use strict";s.d(t,{NotesProvider:()=>i,b:()=>l});var a=s(95155),n=s(12115);let r=(0,n.createContext)(null);function i({children:e}){let[t,s]=(0,n.useState)(!1),l=(0,n.useCallback)(()=>s(!0),[]),o=(0,n.useCallback)(()=>s(!1),[]),c=(0,n.useCallback)(()=>s(e=>!e),[]),d=(0,n.useMemo)(()=>({open:t,openDrawer:l,close:o,toggle:c}),[t,l,o,c]);return(0,a.jsx)(r.Provider,{value:d,children:e})}function l(){let e=(0,n.useContext)(r);if(!e)throw Error("useNotes must be used inside NotesProvider");return e}},81998:(e,t,s)=>{"use strict";s.d(t,{LiveRefresh:()=>l});var a=s(12115),n=s(73321);let r={primed:!1,lastV:-1,lastNavSeq:-1};var i=s(60292);function l(){let e=(0,n.useRouter)();return(0,a.useEffect)(()=>{let t=(0,i.fk)(),s=new EventSource(t?`/api/stream?ws=${encodeURIComponent(t)}`:"/api/stream"),a=r;return s.onopen=()=>{a=r},s.onmessage=t=>{var s,n;let r;try{r=JSON.parse(t.data)}catch{e.refresh();return}let{state:i,action:l}=(s=a,n={v:"number"==typeof r.v?r.v:0,navSeq:r.nav?.seq??0,navPath:r.nav?.path??""},s.primed?n.navSeq!==s.lastNavSeq?{state:{primed:!0,lastV:n.v,lastNavSeq:n.navSeq},action:{kind:"push",path:n.navPath}}:n.v!==s.lastV?{state:{...s,lastV:n.v},action:{kind:"refresh"}}:{state:s,action:{kind:"none"}}:{state:{primed:!0,lastV:n.v,lastNavSeq:n.navSeq},action:{kind:"none"}});if(a=i,"refresh"===l.kind)e.refresh();else if("push"===l.kind&&l.path){e.push(l.path);try{window.focus()}catch{}}},()=>s.close()},[e]),null}},82879:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(30772).A)("sticky-note",[["path",{d:"M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z",key:"1dfntj"}],["path",{d:"M15 3v5a1 1 0 0 0 1 1h5",key:"6s6qgf"}]])},99979:(e,t,s)=>{"use strict";function a(){return new URLSearchParams(window.location.search).get("ws")}function n(e){let t=new URLSearchParams,s=a();for(let[a,n]of(s&&t.set("ws",s),Object.entries(e??{})))t.set(a,n);let n=t.toString();return n?`/plan?${n}`:"/plan"}s.d(t,{X0:()=>a,rc:()=>n})}},e=>{e.O(0,[7513,7352,5004,277,8500,4888,8997,9887,2231,8441,3794,7358],()=>e(e.s=15053)),_N_E=e.O()}]);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[459],{9383:(e,t,s)=>{"use strict";s.d(t,{A:()=>n});let n=(0,s(30772).A)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]])},25494:(e,t,s)=>{"use strict";s.d(t,{A:()=>n});let n=(0,s(30772).A)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]])},31966:(e,t,s)=>{"use strict";s.d(t,{A:()=>n});let n=(0,s(30772).A)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]])},36925:(e,t,s)=>{"use strict";s.d(t,{I:()=>r});var n=s(29813);function r(e){let t=e.tables??[],s=new Map(t.map(e=>[e.id,e.name])),r=t.flatMap(e=>e.columns.filter(e=>e.fkTo&&s.has(e.fkTo)).map(t=>({id:`fk-${e.id}-${t.name}`,fromId:e.id,toId:t.fkTo}))),a=(0,n.to)([...e.nodes.map(e=>({id:e.id,group:e.group??"—"})),...t.map(e=>({id:e.id,group:e.group??e.domain??"—"}))],[...e.edges.map(e=>({fromId:e.toId,toId:e.fromId})),...r.map(e=>({fromId:e.toId,toId:e.fromId}))]),l=new Map;for(let t of e.questions)if("node"===t.anchor.kind){let e=l.get(t.anchor.nodeId)??[];e.push(t),l.set(t.anchor.nodeId,e)}let o=e.nodes.map(e=>{let t=a.get(e.id)??{x:e.x,y:e.y},s=l.get(e.id)??[],n=s.length?"\n\n**Q&A**\n"+s.map(e=>`
|
|
2
|
+
_${e.question}_
|
|
3
|
+
${e.answer??"_(waiting for the agent…)_"}`).join("\n"):"",r=`${e.detail||""}${n}`.trim();return{id:e.id,view:"ARCHITECTURE",kind:"FEATURE",cluster:e.group??null,layer:null,title:e.title,role:e.summary||null,plain:r||null,status:"KEEP",priority:2,x:t.x,y:t.y,source:"MANUAL",sourceRef:null,parentId:null,isCriterion:!1,files:e.files,bugFlags:[]}}),i=t.map(e=>{let t=a.get(e.id)??{x:0,y:0};return{id:e.id,x:t.x,y:t.y,data:{name:e.name,domain:e.domain??null,note:e.note,columns:e.columns.map(e=>({name:e.name,type:e.type,isPk:e.isPk,isFk:e.isFk,note:e.note,fkTo:e.fkTo?s.get(e.fkTo)??e.fkTo:void 0})),sample:e.sample}}});return{nodes:o,edges:[...e.edges.map(e=>({id:e.id,fromId:e.fromId,toId:e.toId,kind:"RELATES",label:e.verb,sourceHandle:null,targetHandle:null})),...r.map(e=>({id:e.id,fromId:e.fromId,toId:e.toId,kind:"RELATES",label:"FK",sourceHandle:null,targetHandle:null}))],tableNodes:i}}},37665:(e,t,s)=>{"use strict";s.d(t,{LearnWorkspace:()=>z});var n=s(95155),r=s(12115),a=s(73321),l=s(38096),o=s(25494),i=s(9383);let d=(0,s(30772).A)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);var c=s(9005),u=s(92571),x=s(40557),m=s(64577),f=s(91337),h=s(60292),p=s(51909),g=s(17356);let b="u">typeof CSS&&"highlights"in CSS&&"u">typeof Highlight,v="lesson-pending",j="lesson-ask",k="lesson-answered";function w(){return b?CSS.highlights:null}function y(...e){return new globalThis.Highlight(...e)}function N(e,t){if(!t)return null;let s=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:e=>e.parentElement?.closest("pre, table")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}),n=[],r="";for(let e=s.nextNode();e;e=s.nextNode())n.push({node:e,start:r.length}),r+=e.nodeValue??"";let a=r.indexOf(t);if(a<0)return null;let l=e=>{for(let t=n.length-1;t>=0;t--)if(n[t].start<=e)return{node:n[t].node,offset:e-n[t].start};return null},o=l(a),i=l(a+t.length);if(!o||!i)return null;let d=document.createRange();return d.setStart(o.node,o.offset),d.setEnd(i.node,i.offset),d}function A({narrative:e,round:t,answered:s=[],onApi:a}){let[l,o]=(0,r.useState)([]),[i,d]=(0,r.useState)(null),[c,u]=(0,r.useState)(null),x=(0,r.useRef)(null),m=(0,r.useRef)(null);(0,r.useEffect)(()=>{o([])},[t]);let f=(0,r.useCallback)(()=>{let e=window.getSelection();if(!e||e.isCollapsed)return d(null);let t=e.toString().trim();if(!t||!x.current?.contains(e.anchorNode))return d(null);let s=e.getRangeAt(0).getBoundingClientRect();d({x:s.right+window.scrollX,y:s.top+window.scrollY,excerpt:t})},[]);(0,r.useEffect)(()=>{let e=()=>setTimeout(f,0);return document.addEventListener("mouseup",e),document.addEventListener("selectionchange",e),()=>{document.removeEventListener("mouseup",e),document.removeEventListener("selectionchange",e)}},[f]);let h=(0,r.useCallback)((e,t)=>{o(s=>[...s,{id:`tq-${Date.now()}-${Math.floor(1e6*Math.random())}`,excerpt:e,question:t}])},[]),p=(0,r.useCallback)(e=>o(t=>t.filter(t=>t.id!==e)),[]),b=(0,r.useCallback)(()=>o([]),[]);(0,r.useEffect)(()=>{let e=w();if(!c||!e)return;let t=m.current;if(t)return e.set(v,y(t)),()=>{e.delete(v)}},[c]),(0,r.useEffect)(()=>{let e=w();if(!e||!x.current)return;let t=[],n=[];for(let e of l){let s=N(x.current,e.excerpt);s&&t.push(s)}for(let e of s){let t=N(x.current,e.excerpt);t&&n.push(t)}let r=(t,s)=>s.length?e.set(t,y(...s)):e.delete(t);return r(j,t),r(k,n),()=>{e.delete(j),e.delete(k)}},[l,s,e]);let S=(0,r.useMemo)(()=>l.filter(e=>e.question.trim()).length,[l]);return(0,r.useEffect)(()=>{a?.({textQuestions:l,count:S,removeQuestion:p,clearAll:b})},[l,S,p,b,a]),(0,n.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,n.jsx)("div",{ref:x,className:"min-h-0 flex-1 overflow-y-auto px-5 pb-5 pt-16 text-[15px] leading-[1.6] selection:bg-[var(--accent-2,#ff7a45)]/30",children:(0,n.jsx)(E,{markdown:e})}),i&&(0,n.jsx)("div",{style:{position:"fixed",left:i.x+4,top:i.y-34,zIndex:60},className:"rounded-md border border-white/15 bg-card/95 p-0.5 shadow-lg backdrop-blur",children:(0,n.jsxs)("button",{onClick:()=>{let e=window.getSelection();m.current=e&&e.rangeCount?e.getRangeAt(0).cloneRange():null,u({...i}),d(null),e?.removeAllRanges()},title:"Ask the agent about this",className:"flex items-center gap-1 rounded px-2 py-1 text-[11px] font-semibold text-[var(--accent-2,#ff7a45)] hover:bg-[var(--accent-2,#ff7a45)]/15",children:[(0,n.jsx)(g.A,{className:"size-3.5"})," Ask"]})}),c&&(0,n.jsx)(C,{excerpt:c.excerpt,x:c.x,y:c.y,onConfirm:e=>{h(c.excerpt,e),u(null)},onCancel:()=>u(null)})]})}function C({excerpt:e,x:t,y:s,onConfirm:a,onCancel:l}){let[o,i]=(0,r.useState)(""),d=(0,r.useRef)(null),u=()=>o.trim()?a(o.trim()):l();return(0,n.jsxs)("div",{ref:d,style:{position:"fixed",left:t+4,top:s-6,zIndex:60},className:"w-72 rounded-md border border-white/15 bg-card/95 p-1.5 shadow-xl backdrop-blur",onBlur:e=>{d.current?.contains(e.relatedTarget)||u()},children:[(0,n.jsxs)("div",{className:"mb-1 line-clamp-1 text-[10px] text-muted-foreground",children:["“",e,"”"]}),(0,n.jsx)("textarea",{autoFocus:!0,value:o,onChange:e=>i(e.target.value),placeholder:"Ask the agent… (Enter to ask \xb7 Esc to discard)",onKeyDown:e=>{e.stopPropagation(),"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&(e.preventDefault(),l()):(e.preventDefault(),u())},className:"h-16 w-full resize-none rounded bg-white/[0.05] px-1.5 py-1 text-xs outline-none placeholder:text-muted-foreground/50 focus:bg-white/[0.08]"}),(0,n.jsxs)("div",{className:"mt-1 flex items-center justify-end gap-1",children:[(0,n.jsxs)("button",{type:"button",onClick:l,className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground hover:bg-red-500/15 hover:text-red-300",children:[(0,n.jsx)(c.A,{className:"size-3"})," Discard"]}),(0,n.jsxs)("button",{type:"button",onClick:u,disabled:!o.trim(),className:"flex items-center gap-1 rounded bg-[var(--accent-2,#ff7a45)]/15 px-1.5 py-0.5 text-[10px] font-semibold text-[var(--accent-2,#ff7a45)] hover:bg-[var(--accent-2,#ff7a45)]/25 disabled:opacity-40",children:[(0,n.jsx)(m.A,{className:"size-3"})," Ask"]})]})]})}function E({markdown:e}){let t=(0,r.useMemo)(()=>(0,p.n$)(e),[e]);return(0,n.jsxs)("div",{className:"mx-auto w-full max-w-[66ch] space-y-4",children:[(0,n.jsx)("style",{children:`
|
|
4
|
+
::highlight(${v}) { background: color-mix(in srgb, var(--accent-2,#ff7a45) 30%, transparent); }
|
|
5
|
+
::highlight(${j}) { background: color-mix(in srgb, var(--accent-2,#ff7a45) 18%, transparent); }
|
|
6
|
+
::highlight(${k}) { background: color-mix(in srgb, #34d399 16%, transparent); }
|
|
7
|
+
`}),t.map((e,t)=>(0,n.jsx)(S,{block:e,index:t},t))]})}function S({block:e,index:t}){if("code"===e.kind)return(0,n.jsx)(p.NG,{text:e.text});if("table"===e.kind)return(0,n.jsx)(p.QH,{block:e});let s=(0,p.Vq)(e.kind)?`lesson-h-${t}`:void 0;return(0,n.jsx)(n.Fragment,{children:(0,p.aM)(e,(0,n.jsx)(p.cV,{text:e.text}),"reading",s)})}var I=s(471),q=s(36925);function z({initialLesson:e,repoFiles:t=[]}){let s=(0,a.useRouter)(),[u,x]=(0,r.useState)(e),[m,g]=(0,r.useState)(null),[b,v]=(0,r.useState)([]),[j,k]=(0,r.useState)(null),[w,y]=(0,r.useState)(""),[N,C]=(0,r.useState)(!1),[E,S]=(0,r.useState)(!1),[$,F]=(0,r.useState)(!1),[H,P]=(0,r.useState)(null),[_,D]=(0,r.useState)(null),U=u?.updatedAt??0,V=(0,r.useRef)(U);(0,r.useEffect)(()=>{V.current=U},[U]),(0,r.useEffect)(()=>{let e=()=>void fetch("/api/lesson/presence",{method:"POST",cache:"no-store",headers:(0,h.dh)((0,h.fk)())}).catch(()=>{});e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[]),(0,r.useEffect)(()=>{if(H)return;let e=async()=>{try{let e=await fetch("/api/lesson",{cache:"no-store",headers:(0,h.dh)((0,h.fk)())});if(!e.ok)return;let t=(await e.json()).lesson;t&&t.updatedAt>V.current?(x(t),v([]),k(null),y(""),F(!1)):!t&&V.current>0&&x(null)}catch{}},t=setInterval(()=>void e(),3e3);return()=>clearInterval(t)},[H]);let Q=(0,r.useCallback)(()=>{let e=Date.now(),t=(m?.textQuestions??[]).filter(e=>e.question.trim()).map(t=>({id:t.id,anchor:{kind:"text",excerpt:t.excerpt},question:t.question,askedAt:e})),s=b.filter(e=>e.question.trim()).map(t=>({id:t.id,anchor:{kind:"node",nodeId:t.nodeId},question:t.question,askedAt:e}));return[...w.trim()?[{id:`oq-${e}`,anchor:{kind:"overall"},question:w.trim(),askedAt:e}]:[],...s,...t]},[m,b,w]),K=(m?.count??0)+b.filter(e=>e.question.trim()).length+ +!!w.trim();(0,r.useEffect)(()=>{if($||H)return;let e=setTimeout(()=>{fetch("/api/lesson/questions",{method:"PUT",headers:{"content-type":"application/json",...(0,h.dh)((0,h.fk)())},body:JSON.stringify({questions:Q()})}).catch(()=>{})},500);return()=>clearTimeout(e)},[Q,$,H]);let B=(0,r.useCallback)(async()=>{if(!E&&0!==K){S(!0);try{(await fetch("/api/lesson/questions",{method:"POST",headers:{"content-type":"application/json",...(0,h.dh)((0,h.fk)())},body:JSON.stringify({questions:Q()})})).ok&&(F(!0),C(!1),k(null))}finally{S(!1)}}},[E,K,Q]),Y=(0,r.useCallback)(async()=>{let e=await fetch("/api/lesson/save",{method:"POST",headers:(0,h.dh)((0,h.fk)())});e.ok&&(D((await e.json()).lessonId??u?.id??null),P("saved"))},[u]),J=(0,r.useCallback)(async()=>{await fetch("/api/lesson/close",{method:"POST",headers:(0,h.dh)((0,h.fk)())}).catch(()=>{}),P("closed")},[]),W=(0,r.useCallback)((e,t)=>{v(s=>[...s,{id:`nq-${Date.now()}-${Math.floor(1e6*Math.random())}`,nodeId:e,question:t}])},[]),X=(0,r.useCallback)(e=>{let t=e.replace(/^[^:]+:\s*/,"").trim(),s=u?.nodes.find(e=>e.title===t);s&&k(s.id)},[u]),G=(0,r.useMemo)(()=>(u?.questions??[]).filter(e=>"text"===e.anchor.kind&&e.answer).map(e=>({excerpt:"text"===e.anchor.kind?e.anchor.excerpt:"",answer:e.answer??""})),[u]),Z=(0,r.useMemo)(()=>(u?.questions??[]).filter(e=>"overall"===e.anchor.kind),[u]),ee=(0,r.useMemo)(()=>u?(0,q.I)(u):{nodes:[],edges:[],tableNodes:[]},[u]);if(H)return(0,n.jsx)(O,{ended:H,savedId:_,onBrowse:()=>s.push("/learn?view=library")});if(!u)return(0,n.jsx)(L,{});let et=j?u.nodes.find(e=>e.id===j)?.title??"":"";return(0,n.jsx)(p.Ue,{files:t,children:(0,n.jsxs)("div",{className:"relative flex h-screen flex-col",children:[$&&(0,n.jsx)(R,{}),(0,n.jsx)("div",{className:"pointer-events-none fixed right-3 top-3 z-30 flex items-center gap-2",children:(0,n.jsxs)("div",{className:"glass pointer-events-auto flex h-10 items-center gap-0.5 rounded-full px-1",children:[(0,n.jsx)("button",{onClick:()=>s.push("/learn?view=library"),title:"Saved lessons",className:"flex size-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:(0,n.jsx)(l.A,{className:"size-3.5"})}),(0,n.jsx)("span",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-white/10"}),(0,n.jsxs)("button",{onClick:()=>C(e=>!e),title:"Ask an overall question",className:(0,f.cn)("relative flex size-8 items-center justify-center rounded-full transition-colors",N?"bg-white/10 text-foreground":w.trim()?"text-[var(--accent-2,#ff7a45)]":"text-muted-foreground hover:bg-white/[0.06] hover:text-foreground"),children:[(0,n.jsx)(o.A,{className:"size-3.5"}),w.trim()&&(0,n.jsx)("span",{className:"absolute -right-0.5 -top-0.5 size-2 rounded-full bg-[var(--accent-2,#ff7a45)]"})]}),(0,n.jsx)("span",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-white/10"}),(0,n.jsxs)("button",{onClick:()=>void B(),disabled:E||0===K,title:0===K?"Highlight text or a node to ask, then send":"Send your questions to the agent",className:(0,f.cn)("flex items-center gap-1 rounded-full px-2.5 py-1 text-[11px] font-semibold transition-colors",0===K?"text-muted-foreground opacity-50":"text-[var(--accent-2,#ff7a45)] hover:bg-[var(--accent-2,#ff7a45)]/15"),children:[(0,n.jsx)(i.A,{className:"size-3"})," Send",K>0?` (${K})`:""]}),(0,n.jsxs)("button",{onClick:()=>void Y(),title:"Save this lesson to your library",className:"flex items-center gap-1 rounded-full border border-emerald-500/40 bg-emerald-500/15 px-2.5 py-1 text-[11px] font-semibold text-emerald-300 transition-colors hover:bg-emerald-500/25",children:[(0,n.jsx)(d,{className:"size-3"})," Save"]}),(0,n.jsxs)("button",{onClick:()=>void J(),title:"Close without saving",className:"flex items-center gap-1 rounded-full px-2.5 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-red-500/15 hover:text-red-300",children:[(0,n.jsx)(c.A,{className:"size-3"})," Close"]})]})}),N&&(0,n.jsx)(T,{label:"Overall question",placeholder:"A question about the whole topic…",value:w,onChange:y,onClose:()=>C(!1)}),j&&(0,n.jsx)(T,{label:`Ask about “${et}”`,placeholder:"Your question about this node…",value:"",submitLabel:"Add question",onSubmit:e=>{W(j,e),k(null)},onClose:()=>k(null)}),(0,n.jsxs)("div",{className:"flex min-h-0 flex-1",children:[(0,n.jsxs)("div",{className:"relative flex min-w-0 flex-1 flex-col bg-background",style:{width:"50%"},children:[(0,n.jsx)("div",{className:"min-h-0 flex-1",children:(0,n.jsx)(A,{narrative:u.narrative,round:U,answered:G,onApi:g})}),Z.length>0&&(0,n.jsx)(M,{questions:Z})]}),(0,n.jsx)("div",{className:"w-px shrink-0 bg-white/5"}),(0,n.jsx)("div",{className:"relative min-w-0 flex-1 bg-background",style:{width:"50%"},children:(0,n.jsx)(I.MapClient,{view:"ARCHITECTURE",nodes:ee.nodes,edges:ee.edges,tableNodes:ee.tableNodes,embedded:!0,readOnly:!0,minimap:!0,staticEdgeLabels:!0,hasFrontend:!1,onAskAgent:X})})]})]})})}function T({label:e,placeholder:t,value:s,submitLabel:a,onChange:l,onSubmit:o,onClose:i}){let[d,u]=(0,r.useState)(s),x=l?s:d;return(0,n.jsxs)("div",{className:"fixed right-3 top-16 z-30 w-80 rounded-xl border border-white/10 bg-card p-3 shadow-xl",children:[(0,n.jsxs)("div",{className:"mb-1 flex items-center justify-between",children:[(0,n.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground [overflow-wrap:anywhere]",children:e}),(0,n.jsx)("button",{onClick:i,title:"Close",className:"rounded p-0.5 text-muted-foreground hover:text-foreground",children:(0,n.jsx)(c.A,{className:"size-3.5"})})]}),(0,n.jsx)("textarea",{autoFocus:!0,value:x,onChange:e=>{let t;return t=e.target.value,l?l(t):u(t)},onKeyDown:e=>{o&&"Enter"===e.key&&!e.shiftKey&&(e.preventDefault(),x.trim()&&o(x.trim()))},placeholder:t,rows:3,className:"w-full resize-y rounded border border-white/5 bg-background px-2 py-1.5 text-[12px] leading-snug outline-none focus:border-[var(--accent-2,#ff7a45)]/40"}),o&&(0,n.jsx)("button",{onClick:()=>x.trim()&&o(x.trim()),disabled:!x.trim(),className:"mt-1.5 w-full rounded-md bg-[var(--accent-2,#ff7a45)]/15 px-2 py-1 text-[11px] font-semibold text-[var(--accent-2,#ff7a45)] transition-colors hover:bg-[var(--accent-2,#ff7a45)]/25 disabled:opacity-40",children:a??"Add"})]})}function M({questions:e}){return(0,n.jsxs)("div",{className:"max-h-44 shrink-0 space-y-1.5 overflow-y-auto border-t border-white/10 bg-background/60 px-5 py-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:[(0,n.jsx)(o.A,{className:"size-3"}),"Overall Q&A"]}),e.map(e=>(0,n.jsxs)("div",{className:"rounded-md border border-white/10 bg-background/40 p-2",children:[(0,n.jsx)("div",{className:"text-[12px] font-medium text-foreground",children:e.question}),e.answer?(0,n.jsx)("div",{className:"mt-1 text-[12px] leading-relaxed text-foreground/85",children:(0,n.jsx)(p.pO,{markdown:e.answer,variant:"compact"})}):(0,n.jsxs)("div",{className:"mt-1 flex items-center gap-1 text-[11px] text-muted-foreground/70",children:[(0,n.jsx)(u.A,{className:"size-3 animate-spin"})," waiting for the agent…"]})]},e.id))]})}function R(){return(0,n.jsxs)("div",{className:"absolute inset-0 z-40 flex flex-col items-center justify-center gap-4 bg-background/95 px-6 text-center backdrop-blur-sm",children:[(0,n.jsx)("div",{className:"flex size-12 items-center justify-center rounded-full bg-[var(--accent-2,#ff7a45)]/15",children:(0,n.jsx)(u.A,{className:"size-6 animate-spin text-[var(--accent-2,#ff7a45)]"})}),(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Questions sent"}),(0,n.jsx)("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Your terminal session is answering. The updated lesson will appear here automatically."})]})]})}function L(){return(0,n.jsxs)("div",{className:"flex h-screen flex-col items-center justify-center gap-3 px-6 text-center",children:[(0,n.jsx)(x.A,{className:"size-8 text-muted-foreground/60"}),(0,n.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"No lesson open"}),(0,n.jsxs)("p",{className:"max-w-md text-sm text-muted-foreground",children:["Ask your terminal session to ",(0,n.jsx)("em",{children:"explain"})," or ",(0,n.jsx)("em",{children:"teach"})," you part of the codebase — it opens an interactive lesson here. You highlight text to ask questions; it answers on the board."]})]})}function O({ended:e,savedId:t,onBrowse:s}){return(0,n.jsxs)("div",{className:"flex h-screen flex-col items-center justify-center gap-5 px-6 text-center",children:[(0,n.jsx)("div",{className:(0,f.cn)("flex size-12 items-center justify-center rounded-full","saved"===e?"bg-emerald-500/15":"bg-white/10"),children:"saved"===e?(0,n.jsx)(m.A,{className:"size-6 text-emerald-300"}):(0,n.jsx)(c.A,{className:"size-6 text-muted-foreground"})}),(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"saved"===e?"Lesson saved":"Lesson closed"}),(0,n.jsx)("p",{className:"max-w-sm text-sm text-muted-foreground",children:"saved"===e?"It's in your library — reopen it anytime.":"Closed without saving."})]}),(0,n.jsxs)("button",{onClick:s,className:"rounded-full border border-white/12 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:[(0,n.jsx)(l.A,{className:"mr-1 inline size-3.5"})," ",t?"Browse the library":"Open the library"]})]})}},38096:(e,t,s)=>{"use strict";s.d(t,{A:()=>n});let n=(0,s(30772).A)("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]])},38464:(e,t,s)=>{"use strict";s.d(t,{LessonLibraryView:()=>f});var n=s(95155),r=s(12115),a=s(73321),l=s(38096),o=s(40557),i=s(31966),d=s(60292),c=s(51909),u=s(471),x=s(36925);function m(e){let t=new URLSearchParams,s=(0,d.fk)();for(let[n,r]of(s&&t.set("ws",s),Object.entries(e)))t.set(n,r);return`/learn?${t.toString()}`}function f({lessons:e,selected:t,repoFiles:s=[]}){return t?(0,n.jsx)(p,{lesson:t,repoFiles:s}):(0,n.jsx)(h,{lessons:e})}function h({lessons:e}){let t=(0,a.useRouter)();return(0,n.jsxs)("div",{className:"mx-auto flex h-screen w-full max-w-3xl flex-col px-6 pt-20",children:[(0,n.jsxs)("div",{className:"mb-5 flex items-center justify-between",children:[(0,n.jsxs)("h1",{className:"flex items-center gap-2 text-lg font-semibold text-foreground",children:[(0,n.jsx)(l.A,{className:"size-5 text-[var(--accent-2,#ff7a45)]"})," Lessons"]}),(0,n.jsx)("button",{onClick:()=>t.push(m({})),className:"rounded-full border border-white/12 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:"Back to current lesson"})]}),0===e.length?(0,n.jsxs)("div",{className:"rounded-lg border border-dashed border-white/10 px-4 py-12 text-center text-sm text-muted-foreground",children:["No saved lessons yet. Ask your terminal session to explain something, then click ",(0,n.jsx)("b",{children:"Save"}),"."]}):(0,n.jsx)("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto pb-6",children:e.map(e=>(0,n.jsxs)("button",{onClick:()=>t.push(m({view:"library",id:e.id})),className:"block w-full rounded-lg border border-white/10 bg-white/[0.02] p-3 text-left transition-colors hover:border-white/20 hover:bg-white/[0.04]",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 text-[14px] font-semibold text-foreground",children:[(0,n.jsx)(o.A,{className:"size-4 text-[var(--accent-2,#ff7a45)]"})," ",e.title]}),e.topic&&e.topic!==e.title&&(0,n.jsx)("div",{className:"mt-0.5 truncate text-[12px] text-muted-foreground",children:e.topic}),(0,n.jsxs)("div",{className:"mt-1 text-[11px] text-muted-foreground/70",children:[e.nodeCount," node",1===e.nodeCount?"":"s"," \xb7 ",e.questionCount," question",1===e.questionCount?"":"s"," \xb7 saved ",new Date(e.updatedAt).toLocaleDateString()]})]},e.id))})]})}function p({lesson:e,repoFiles:t}){let s=(0,a.useRouter)(),l=(0,r.useMemo)(()=>new Map(e.nodes.map(e=>[e.id,e.title])),[e.nodes]),o=(0,r.useMemo)(()=>(0,x.I)(e),[e]);return(0,n.jsx)(c.Ue,{files:t,children:(0,n.jsxs)("div",{className:"relative flex h-screen flex-col",children:[(0,n.jsx)("div",{className:"pointer-events-none fixed right-3 top-3 z-30",children:(0,n.jsxs)("button",{onClick:()=>s.push(m({view:"library"})),className:"glass pointer-events-auto flex h-10 items-center gap-1.5 rounded-full px-3 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:[(0,n.jsx)(i.A,{className:"size-3.5"})," Library"]})}),(0,n.jsxs)("div",{className:"flex min-h-0 flex-1",children:[(0,n.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col overflow-y-auto bg-background px-5 pb-6 pt-16",style:{width:"50%"},children:[(0,n.jsx)(c.pO,{markdown:e.narrative,variant:"reading"}),e.questions.length>0&&(0,n.jsxs)("div",{className:"mx-auto mt-6 w-full max-w-[66ch] space-y-2",children:[(0,n.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Q&A"}),e.questions.map(e=>(0,n.jsx)(g,{q:e,nodeTitle:"node"===e.anchor.kind?l.get(e.anchor.nodeId):void 0},e.id))]})]}),(0,n.jsx)("div",{className:"w-px shrink-0 bg-white/5"}),(0,n.jsx)("div",{className:"min-w-0 flex-1 bg-background",style:{width:"50%"},children:(0,n.jsx)(u.MapClient,{view:"ARCHITECTURE",nodes:o.nodes,edges:o.edges,tableNodes:o.tableNodes,embedded:!0,readOnly:!0,minimap:!0,staticEdgeLabels:!0,hasFrontend:!1})})]})]})})}function g({q:e,nodeTitle:t}){let s="overall"===e.anchor.kind?"Overall":"node"===e.anchor.kind?t??"Node":`“${e.anchor.excerpt.slice(0,48)}…”`;return(0,n.jsxs)("div",{className:"rounded-md border border-white/10 bg-background/40 p-2",children:[(0,n.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground/80",children:s}),(0,n.jsx)("div",{className:"mt-0.5 text-[12px] font-medium text-foreground",children:e.question}),e.answer&&(0,n.jsx)("div",{className:"mt-1 text-[12px] leading-relaxed text-foreground/85",children:(0,n.jsx)(c.pO,{markdown:e.answer,variant:"compact"})})]})}},40557:(e,t,s)=>{"use strict";s.d(t,{A:()=>n});let n=(0,s(30772).A)("book-open",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]])},73206:(e,t,s)=>{Promise.resolve().then(s.bind(s,37665)),Promise.resolve().then(s.bind(s,38464))}},e=>{e.O(0,[2574,3862,5004,277,8500,4888,8997,9887,5957,766,2059,2231,471,1909,8441,3794,7358],()=>e(e.s=73206)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5823],{27950:(e,t,o)=>{Promise.resolve().then(o.bind(o,44853)),Promise.resolve().then(o.bind(o,62079)),Promise.resolve().then(o.bind(o,471)),Promise.resolve().then(o.bind(o,77260))},62079:(e,t,o)=>{"use strict";o.d(t,{FilesMapClient:()=>U});var s=o(95155),n=o(12115),r=o(80277),l=o(81750),a=o(6266),i=o(7679),d=o(98766),c=o(15629),u=o(79176),p=o(2982),h=o(64385);o(53255);var f=o(17356),m=o(24413),x=o(18986),g=o(9005),b=o(25583),y=o(82099),w=o(62311),j=o(9991),k=o(47409),N=o(91157),v=o(56895),M=o(16607),S=o(14983);let C=/(^|\/)tests?\/|\.(test|spec)\.[jt]sx?$/i;var A=o(44267),$=o(70947),z=o(98238),E=o(56614),D=o(28161);let I=/\.(py|go|rb|rs|java|php|ex|exs)$/i,R=/(^|\/)(app\/api|pages\/api|migrations|bin)\/|(^|\/)instrumentation\.[^/]+$/,O=e=>e.includes("/")?e.slice(0,e.indexOf("/")):"(root)";function T(e){let t=Math.max(14,.35*e.length),o=new Map;for(let t of e)o.set(t,O(t));for(let e=0;e<6;e++){let e=new Map;for(let t of o.values())e.set(t,(e.get(t)??0)+1);let s=!1;for(let[n,r]of o){if((e.get(r)??0)<=t||!n.startsWith(`${r}/`))continue;let l=n.slice(r.length+1);l.includes("/")&&(o.set(n,`${r}/${l.slice(0,l.indexOf("/"))}`),s=!0)}if(!s)break}return o}var P=o(29523),Z=o(70221),F=o(12410),L=o(91337);function _(e){return 5+.5*Math.min(e,26)}let W={file:(0,n.memo)(function({data:e}){let t=(0,P.k)(Z.kz),o=!!e.touched,n=e.recency??0,r=e.inDegree??0,i=_(r),d=e.layer??null,c=2*!!d,u=r>0?` \xb7 imported by ${r}`:"",p=d?` \xb7 ${"fullstack"===d?"shared (used by frontend + backend)":D.YG[d].label.toLowerCase()}`:"",h=o?`${e.tooltip} \xb7 edited ${e.count??0}\xd7 this session${u}${p}`:e.untested?`${e.tooltip} \xb7 no test imports this file${u}${p}`:`${e.tooltip}${u}${p}`;return(0,s.jsxs)("div",{title:h,className:"relative flex flex-col items-center",children:[(0,s.jsx)(l.h7,{type:"target",position:a.yX.Top,isConnectable:!1,className:"!h-0 !w-0 !min-w-0 !border-0 !bg-transparent",style:{top:i+c,left:"50%"}}),(0,s.jsx)("span",{"aria-hidden":!0,className:(0,L.cn)("rounded-full",e.isNewest&&"animate-touch-pulse"),style:{padding:c,background:d?(0,D.A6)(d):void 0,boxShadow:o?`0 0 ${8+Math.round(14*n)}px ${2+Math.round(3*n)}px rgba(45,212,191,${(.35+.45*n).toFixed(2)})`:e.untested?"0 0 0 2px rgba(251,191,36,0.65)":"none"},children:(0,s.jsx)("span",{"aria-hidden":!0,className:"block rounded-full",style:{width:2*i,height:2*i,backgroundColor:e.dirColor}})}),o&&(e.count??0)>0&&(0,s.jsx)("span",{"aria-hidden":!0,className:"absolute -right-2 -top-2 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-teal-400 px-0.5 text-[8px] font-bold text-background ring-1 ring-background",children:e.count}),("full"===t||"mid"===t&&r>=4)&&(0,s.jsx)("span",{className:(0,L.cn)("pointer-events-none mt-1 max-w-44 truncate text-[10px] leading-tight",o?"font-semibold text-teal-100":"text-foreground/75"),children:e.label}),(0,s.jsx)(l.h7,{type:"source",position:a.yX.Bottom,isConnectable:!1,className:"!h-0 !w-0 !min-w-0 !border-0 !bg-transparent",style:{top:i+c,bottom:"auto",left:"50%"}})]})})};function B({regions:e,dominant:t}){return(0,s.jsx)(l.DX,{children:e.map(e=>{let o=t.get(e.key);return o&&"fullstack"!==o?(0,s.jsx)("div",{style:{position:"absolute",transform:`translate(${e.x-.15*e.w}px, ${e.y-.15*e.h}px)`,width:1.3*e.w,height:1.3*e.h,pointerEvents:"none",zIndex:0,background:`radial-gradient(closest-side, ${D.ZD[o]} 0%, transparent 72%)`,opacity:.1}},e.key):null})})}function U({files:e,edges:t,touched:o,hasFrontend:a=!1,classificationRoots:O=[]}){let H,X=(0,n.useMemo)(()=>(function(e,t){let o=function(e){if(!e?.length)return[];let t=new Set;for(let o of e){let e=o.trim().replace(/^\/+|\/+$/g,"");e&&t.add(e)}return[...t]}(t);if(!o.length)return T(e);let s=new Map,n=[];for(let t of e){let e=function(e,t){let o=null;for(let s of t)(e===s||e.startsWith(`${s}/`))&&(!o||s.length>o.length)&&(o=s);return o}(t,o);e?s.set(t,function(e,t){if(e===t||!e.startsWith(`${t}/`))return t;let o=e.slice(t.length+1);return o.includes("/")?`${t}/${o.slice(0,o.indexOf("/"))}`:t}(t,e)):n.push(t)}for(let[e,t]of T(n))s.set(e,t);return s})(e.map(e=>e.path),O),[e,O]),G=(0,n.useMemo)(()=>(function(e,t,o){let s=function(e){let t=new Map;for(let o of e.values())t.set(o,(t.get(o)??0)+1);let o=Array.from(t.entries()).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])),s=Math.max(1,Math.ceil(Math.sqrt(2.5*o.length))),n=new Map;return o.forEach(([e],t)=>{n.set(e,{x:t%s*1250,y:950*Math.floor(t/s)})}),n}(o),n=e=>s.get(o.get(e)??"(root)"),r=e.map(e=>{let t=function(e){let t=0x811c9dc5;for(let o=0;o<e.length;o++)t=(t^e.charCodeAt(o))*0x1000193>>>0;return{x:(t%10007/10007-.5)*900,y:((t>>>13)%10007/10007-.5)*900}}(e.path),o=n(e.path);return{id:e.path,x:o.x+.5*t.x,y:o.y+.5*t.y,pinned:!1,radius:_(e.inDegree??0)+22}}),l=t.filter(e=>e.from!==e.to).map(e=>({source:e.from,target:e.to})),a=(0,i.A)(r).force("link",(0,d.A)(l).id(e=>e.id).distance(100).strength(e=>{let t="object"==typeof e.source?e.source.id:String(e.source),s="object"==typeof e.target?e.target.id:String(e.target);return o.get(t)===o.get(s)?.5:.02})).force("charge",(0,c.A)().strength(-260).distanceMax(800)).force("collide",(0,u.A)().radius(e=>e.radius).strength(.6)).force("clusterX",(0,p.A)(e=>n(e.id).x).strength(.1)).force("clusterY",(0,h.A)(e=>n(e.id).y).strength(.115)).stop();for(let e=0;e<500;e++)a.tick();let f=new Map;for(let e of r)f.set(e.id,{x:e.x??0,y:e.y??0});return f})(e,t,X),[e,t,X]),q=(0,n.useMemo)(()=>(function(e,t){var o;let s=new Set;for(let e of t)o=e.from,C.test(o)&&s.add(e.to);let n=new Set;for(let t of e)C.test(t)||s.has(t)||n.add(t);return n})(e.map(e=>e.path),t),[e,t]),J=(0,n.useMemo)(()=>a?function(e,t){let o=new Map,s=new Map;for(let e of t){let t=s.get(e.from);t?t.push(e.to):s.set(e.from,[e.to])}let n=new Map;for(let t of e){let e=R.test(t)?"backend":D.An.test(t)?"frontend":I.test(t)?"backend":null;o.set(t,e),e&&n.set(t,e)}let r=e=>{let t=new Set,o=[];for(let[t,s]of n)s===e&&o.push(t);for(;o.length;){let e=o.pop();for(let n of s.get(e)??[])t.has(n)||(t.add(n),o.push(n))}return t},l=r("frontend"),a=r("backend");for(let t of e){if(o.get(t))continue;let e=l.has(t),s=a.has(t);e&&s?o.set(t,"fullstack"):e?o.set(t,"frontend"):s&&o.set(t,"backend")}return o}(e.map(e=>e.path),t):null,[a,e,t]),K=(0,n.useMemo)(()=>{let e=new Map,t=Object.entries(o??{});if(!t.length)return e;let s=t.map(([,e])=>e.lastAt),n=Math.max(...s),r=Math.min(...s),l=n-r||1,a=t[0][0],i=t[0][1].lastAt;for(let[e,o]of t)o.lastAt>=i&&(a=e,i=o.lastAt);for(let[o,s]of t)e.set(o,{count:s.count,recency:(s.lastAt-r)/l,isNewest:o===a});return e},[o]),Q=K.size>0,Y=(0,n.useMemo)(()=>Array.from(K.entries()).map(([e,t])=>({path:e,count:t.count})),[K]),ee=(0,n.useMemo)(()=>e.map(e=>{let t=G.get(e.path)??{x:e.x,y:e.y},o=e.path.lastIndexOf("/"),s=o>=0?e.path.slice(o+1):e.path,n=K.get(e.path);return{id:e.path,type:"file",position:t,data:{label:s,tooltip:e.path,untested:q.has(e.path),inDegree:e.inDegree??0,dirColor:(0,F.i3)(X.get(e.path)??"(root)"),layer:J?.get(e.path)??null,touched:!!n,count:n?.count??0,recency:n?.recency??0,isNewest:n?.isNewest??!1}}}),[e,G,q,K,J,X]),et=(0,n.useMemo)(()=>t.map(e=>({id:`${e.from}|${e.to}`,source:e.from,target:e.to,type:"straight",selectable:!1,focusable:!1,style:{pointerEvents:"none",...e.circular?{stroke:"#f87171",strokeDasharray:"5 3",strokeWidth:1.5,opacity:.6}:{stroke:"#8b8b94",strokeWidth:1,opacity:.3}}})),[t]),[eo,es]=(0,n.useState)(ee),[en,er]=(0,n.useState)(et),[el,ea]=(0,n.useState)(null),[ei,ed]=(0,n.useState)(null),[ec,eu]=(0,n.useState)(null),[ep,eh]=(0,n.useState)(!1),[ef,em]=(0,n.useState)(!1),[ex,eg]=(0,n.useState)(null),[eb,ey]=(0,n.useState)(!1),[ew,ej]=(0,n.useState)(""),[ek,eN]=(0,n.useState)(!1),[ev,eM]=(0,n.useState)("full"),eS=(0,n.useRef)(null),{tool:eC,setTool:eA,flowProps:e$}=(0,r.e)(),ez=(0,n.useCallback)(e=>{ea(e),eu(null);let t=eS.current?.getNode(e);t&&eS.current&&eS.current.setCenter(t.position.x+40,t.position.y+12,{zoom:1.4,duration:600})},[]),eE=(0,n.useCallback)(()=>{ea(null),eu(null);let e=!ef;if(em(e),ey(e),e&&eS.current){let e=Array.from(K.keys()).map(e=>({id:e}));e.length&&eS.current.fitView({nodes:e,duration:600,padding:.4})}},[ef,K]),eD=(0,n.useMemo)(()=>(0,N.b)(e,t,X),[e,t,X]),eI=(0,n.useCallback)(e=>{eS.current&&(e.focusIds.length?eS.current.fitView({nodes:e.focusIds.map(e=>({id:e})),duration:700,padding:.3,maxZoom:1.1}):eS.current.fitView({duration:700,padding:.1}))},[]),eR=(0,v.W)(eD,eI);(0,n.useEffect)(()=>eN(!0),[]),(0,n.useEffect)(()=>es(ee),[ee]),(0,n.useEffect)(()=>er(et),[et]);let eO=(0,n.useCallback)(e=>es(t=>(0,l._0)(e,t)),[]),eT=(0,n.useCallback)(e=>er(t=>(0,l.zW)(e,t)),[]),eP=(0,n.useCallback)((e,t,o)=>{fetch("/api/code-graph/position",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:e,x:t,y:o})})},[]),eZ=(0,n.useMemo)(()=>new Set(t.filter(e=>e.circular).map(e=>`${e.from}|${e.to}`)),[t]),eF=(0,n.useMemo)(()=>{let e=new Set;for(let o of t)o.circular&&(e.add(o.from),e.add(o.to));return e},[t]),eL=el??ei,e_=ew.trim().length>0,eW=(0,n.useMemo)(()=>{if(!e_)return null;let t=new Set;for(let o of e)(0,S.Qk)((0,S.zn)(o),ew)&&t.add(o.path);return t},[e,ew,e_]),eB=(0,n.useMemo)(()=>e_?(0,S.r2)(e,ew,e=>(0,S.zn)(e),e=>({id:e.path,label:e.path,sublabel:e.lang??void 0,kind:"file"})):[],[e,ew,e_]),eU=(0,n.useMemo)(()=>{if(ec){let e=en.find(e=>e.id===ec);return e?new Set([e.source,e.target]):null}if(eL){let e=new Set([eL]);for(let o of t)o.from===eL&&e.add(o.to),o.to===eL&&e.add(o.from);return e}return ep?eF:ef&&Q?new Set(K.keys()):null},[eL,ec,ep,eF,t,en,ef,Q,K]),eV=eR.focusIds,eH=eV??eW??eU,eX=eW??eV,eG=(0,n.useMemo)(()=>{if(!ex||!J)return null;let t=new Set;for(let o of e)(0,z.F)(ex,J.get(o.path)??null)||t.add(o.path);return t},[ex,J,e]),eq=(0,n.useMemo)(()=>eH?eo.map(e=>{let t=eH.has(e.id);return{...e,zIndex:t&&eX?10:e.zIndex,style:{...e.style,opacity:t?1:.15,boxShadow:t&&eX?S.RU:e.style?.boxShadow,borderRadius:t&&eX?9999:e.style?.borderRadius,transition:"opacity 120ms, box-shadow 120ms"}}}):eG?eo.map(e=>eG.has(e.id)?{...e,style:{...e.style,opacity:.15,transition:"opacity 120ms"}}:e):eo,[eo,eH,eX,eG]),eJ=(0,n.useMemo)(()=>eV?en.map(e=>eV.has(e.source)&&eV.has(e.target)?{...e,style:{...e.style,stroke:"#e4e4e7",opacity:.9,strokeWidth:1.4}}:{...e,style:{...e.style,opacity:.05}}):eW?en.map(e=>eW.has(e.source)&&eW.has(e.target)?{...e,style:{...e.style,stroke:"#e4e4e7",opacity:.95,strokeWidth:1.6}}:{...e,style:{...e.style,opacity:.05}}):eL||ec||ep||ef?en.map(e=>{let t=!1;return ec?t=e.id===ec:eL?t=e.source===eL||e.target===eL:ep?t=eZ.has(e.id):ef&&(t=K.has(e.source)&&K.has(e.target)),t?{...e,style:{...e.style,stroke:"#e4e4e7",opacity:.95,strokeWidth:1.6}}:{...e,style:{...e.style,opacity:.05}}}):eG?en.map(e=>eG.has(e.source)||eG.has(e.target)?{...e,style:{...e.style,opacity:.05}}:e):en,[en,eL,ec,ep,eZ,ef,K,eW,eG,eV]),eK=(0,n.useMemo)(()=>{let e=eo.map(e=>{let t=_(e.data.inDegree??0);return{id:e.id,group:X.get(e.id)??"(root)",x:e.position.x,y:e.position.y,w:2*t,h:2*t}});return(0,A.S)(e,{pad:60})},[eo,X]),eQ=(0,n.useMemo)(()=>{let t=new Map;if(!J)return t;let o=new Map;for(let t of e){let e=J.get(t.path);if(!e)continue;let s=X.get(t.path)??"(root)",n=o.get(s)??new Map;n.set(e,(n.get(e)??0)+1),o.set(s,n)}for(let[e,s]of o){let o=null,n=0,r=!1;for(let[e,t]of s)t>n?(o=e,n=t,r=!1):t===n&&(r=!0);t.set(e,r?null:o)}return t},[J,e,X]),eY=(0,n.useMemo)(()=>{let e=new Map;for(let t of X.values())e.set(t,(e.get(t)??0)+1);return Array.from(e.entries()).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).map(([e,t])=>({group:e,count:t,color:(0,F.i3)(e)}))},[X]),e0=t.filter(e=>e.circular).length,e1=(0,n.useMemo)(()=>el?t.filter(e=>e.from===el).map(e=>e.to):[],[el,t]),e5=(0,n.useMemo)(()=>el?t.filter(e=>e.to===el).map(e=>e.from):[],[el,t]),e2=null!==el||eb&&Q,e4=(0,n.useCallback)(()=>{ea(null),ey(!1),em(!1)},[]);return ek?(0,s.jsxs)("div",{className:"canvas-dots relative h-screen w-full",children:[(0,s.jsxs)(l.Gc,{...e$,nodes:eq,edges:eJ,nodeTypes:W,onNodesChange:eO,onEdgesChange:eT,onNodeClick:(e,t)=>{ea(t.id),eu(null)},onEdgeClick:(e,t)=>{eu(t.id),ea(null)},onPaneClick:()=>{ea(null),eu(null)},onNodeMouseEnter:(e,t)=>ed(t.id),onNodeMouseLeave:()=>ed(null),onInit:e=>{eS.current=e},onNodeDragStop:(e,t)=>eP(t.id,t.position.x,t.position.y),deleteKeyCode:null,colorMode:"dark",fitView:!0,fitViewOptions:{padding:.1,minZoom:.18,maxZoom:.9},minZoom:.05,panOnScroll:!0,zoomActivationKeyCode:["Meta","Control"],proOptions:{hideAttribution:!0},children:[(0,s.jsx)($.Z,{regions:"far"===ev?eK:[],tone:"category",lod:ev}),a&&(0,s.jsx)(B,{regions:"far"===ev?[]:eK,dominant:eQ}),(0,s.jsx)(P.J,{onLod:eM,thresholds:Z.kz}),(0,s.jsx)(l.H2,{position:"bottom-right",className:"!overflow-hidden !rounded-xl !border !border-white/10 [&_button]:!border-white/10 [&_button]:!bg-card/70 [&_button]:!text-foreground [&_button]:!backdrop-blur"}),(0,s.jsx)(l.Zk,{position:"bottom-left",style:{marginBottom:118},children:(0,s.jsx)(r.H,{tool:eC,onChange:eA})}),(0,s.jsx)(l.Zk,{position:"bottom-right",style:{marginBottom:152},children:(0,s.jsx)(E.er,{title:"Legend",trigger:(e,t)=>(0,s.jsx)("button",{type:"button",onClick:t,title:"Legend",className:(0,L.cn)("glass flex size-8 items-center justify-center rounded-lg transition-colors",e?"text-foreground":"text-muted-foreground hover:text-foreground"),children:(0,s.jsx)(f.A,{className:"size-4"})}),children:(0,s.jsxs)("ul",{className:"space-y-1.5 text-[10.5px] text-muted-foreground",children:[(0,s.jsxs)("li",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{"aria-hidden":!0,className:"inline-block size-2.5 shrink-0 rounded-full bg-zinc-400"}),(0,s.jsx)("span",{children:"a file \xb7 bigger dot = more files import it"})]}),a&&(0,s.jsxs)("li",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{"aria-hidden":!0,className:"inline-block size-2.5 shrink-0 rounded-full",style:{boxShadow:`inset 0 0 0 2px ${D.ZD.frontend}`}}),(0,s.jsx)("span",{children:"colored ring \xb7 frontend / backend layer"})]}),(0,s.jsxs)("li",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{"aria-hidden":!0,className:"inline-block h-px w-6 bg-[#4a4a52]"}),(0,s.jsx)("span",{children:"line \xb7 imports another file"})]}),(0,s.jsxs)("li",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{"aria-hidden":!0,className:"inline-block h-px w-6 bg-red-400"}),(0,s.jsx)("span",{children:"red \xb7 part of an import cycle"})]}),(0,s.jsxs)("li",{className:"flex items-center gap-2",children:[(0,s.jsxs)("span",{"aria-hidden":!0,className:"inline-flex shrink-0 gap-0.5",children:[(0,s.jsx)("span",{className:"inline-block size-2 rounded-full bg-violet-400"}),(0,s.jsx)("span",{className:"inline-block size-2 rounded-full bg-amber-400"})]}),(0,s.jsx)("span",{children:"dot color \xb7 its directory (chips, top-right)"})]})]})})}),(0,s.jsx)(l.of,{pannable:!0,zoomable:!0,position:"bottom-left",style:{width:140,height:90},className:"!overflow-hidden !rounded-xl !border !border-white/10 !bg-card/50 !backdrop-blur",nodeColor:()=>"#555"}),eD.length>0&&!eR.active&&(0,s.jsx)(l.Zk,{position:"top-left",className:"!mt-14",children:(0,s.jsxs)("button",{type:"button",onClick:eR.start,title:"Guided, dependency-ordered walkthrough of the codebase",className:"glass flex items-center gap-1.5 rounded-xl px-3 py-1.5 text-[11px] text-muted-foreground transition-colors hover:text-foreground",children:[(0,s.jsx)(m.A,{className:"size-3.5"}),"Start tour"]})}),(0,s.jsx)(l.Zk,{position:"top-right",className:(0,L.cn)("glass rounded-full px-1 py-0.5 transition-[margin] duration-200",e2&&"!mr-[300px]"),children:(0,s.jsx)(w.Z,{active:"FILES",tabs:[{value:"ROADMAP",label:"Roadmap",href:"/map?view=ROADMAP"},{value:"ARCHITECTURE",label:"Architecture",href:"/map?view=ARCHITECTURE"},{value:"DATABASE",label:"Database",href:"/map?view=DATABASE"},{value:"FILES",label:"Files",href:"/map?view=FILES"}]})}),(0,s.jsx)(l.Zk,{position:"top-right",className:(0,L.cn)("glass !mt-24 flex max-w-[300px] flex-wrap items-center justify-end gap-x-2.5 gap-y-1 rounded-xl px-3 py-1.5 transition-[margin] duration-200",e2&&"!mr-[300px]"),children:eY.map(t=>(0,s.jsxs)("button",{type:"button",onClick:()=>{let o=e.filter(e=>(X.get(e.path)??"(root)")===t.group).map(e=>({id:e.path}));o.length&&eS.current?.fitView({nodes:o,duration:600,padding:.3,maxZoom:1})},title:`${t.count} files — click to zoom to ${t.group}`,className:"flex items-center gap-1.5 rounded px-1 py-0.5 text-[10px] text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:[(0,s.jsx)("span",{"aria-hidden":!0,className:"size-2 shrink-0 rounded-full",style:{backgroundColor:t.color}}),t.group]},t.group))}),(0,s.jsxs)(l.Zk,{position:"top-right",className:(0,L.cn)("!mt-14 flex items-center gap-2 transition-[margin] duration-200",e2&&"!mr-[300px]"),children:[(0,s.jsx)(j.X,{query:ew,onQuery:ej,hits:eB,placeholder:"Find a file…",onPick:e=>{ej(""),ez(e)},onZoomToMatches:()=>{eW?.size&&eS.current?.fitView({nodes:[...eW].map(e=>({id:e})),duration:600,padding:.3})}}),a&&(0,s.jsx)(z.o,{value:ex,onChange:eg,options:["frontend","backend"]}),(0,s.jsxs)("div",{className:"glass flex items-center gap-3 rounded-xl px-3 py-1.5 text-[11px]",children:[(0,s.jsxs)("span",{className:"text-muted-foreground",children:[e.length," files \xb7 ",t.length," imports"]}),e0>0&&(0,s.jsxs)("button",{type:"button",onClick:()=>{eh(e=>!e),ea(null),eu(null)},title:ep?"Show all imports":"Show only files involved in import cycles",className:(0,L.cn)("flex items-center gap-1.5 rounded-md px-1.5 py-0.5 transition-colors",ep?"bg-red-500/15 text-red-200 ring-1 ring-red-400/40":"text-red-300 hover:bg-red-500/10"),children:[(0,s.jsx)("span",{"aria-hidden":!0,className:"inline-block h-0 w-5 border-t border-dashed",style:{borderColor:"#ef4444"}}),e0," circular"]}),Q&&(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)("button",{type:"button",onClick:eE,title:ef?"Show all files again":"Focus + zoom to the files edited this session",className:(0,L.cn)("flex items-center gap-1.5 rounded-md px-1.5 py-0.5 transition-colors",ef?"bg-teal-500/15 text-teal-200 ring-1 ring-teal-400/40":"text-teal-300 hover:bg-teal-500/10"),children:[(0,s.jsx)(x.A,{className:"size-3"}),K.size," edited"]})})]})]})]}),e2&&(0,s.jsxs)(y.b,{className:"absolute bottom-3 right-3 top-16 z-10 flex w-72 flex-col rounded-2xl",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between border-b border-white/10 px-3.5 py-2.5",children:[(0,s.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:el?"File":"Edited this session"}),(0,s.jsx)("button",{onClick:e4,title:"Close panel",className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,s.jsx)(g.A,{className:"size-4"})})]}),(0,s.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-3",children:el?(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-start gap-1.5",children:[(0,s.jsx)(b.A,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),(0,s.jsx)("h2",{className:"break-all text-sm font-semibold leading-tight",children:el.slice(el.lastIndexOf("/")+1)})]}),(0,s.jsx)("div",{className:"mt-0.5 break-all font-mono text-[10px] text-muted-foreground",children:el})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-1",children:[(H=K.get(el))?(0,s.jsxs)("span",{className:"rounded bg-teal-500/15 px-1.5 py-0.5 text-[10px] font-semibold text-teal-300",children:["edited ",H.count,"\xd7"]}):null,q.has(el)&&(0,s.jsx)("span",{className:"rounded bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-semibold text-amber-300",children:"untested"})]}),(0,s.jsx)("button",{onClick:()=>fetch(`/api/open?path=${encodeURIComponent(el)}`).catch(()=>{}),className:"w-full rounded-md border border-white/10 px-2 py-1.5 text-[11px] text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:"Open in editor"}),(0,s.jsx)(V,{label:"Imports",paths:e1,onPick:ez}),(0,s.jsx)(V,{label:"Imported by",paths:e5,onPick:ez})]}):(0,s.jsx)(k.h,{files:Y.map(e=>({path:e.path,meta:`${e.count}\xd7`})),emptyLabel:"No files edited this session yet."})})]}),eR.active&&eR.step&&(0,s.jsx)(M.d,{steps:eD,index:eR.index,onPrev:eR.prev,onNext:eR.next,onExit:eR.stop,onGoto:eR.goto})]}):(0,s.jsx)("div",{className:"flex h-screen w-full items-center justify-center text-sm text-muted-foreground",children:"Loading graph…"})}function V({label:e,paths:t,onPick:o}){return t.length?(0,s.jsxs)("div",{children:[(0,s.jsxs)("h3",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:[e," (",t.length,")"]}),(0,s.jsx)(k.h,{files:t.map(e=>({path:e})),onSelect:o})]}):null}},77260:(e,t,o)=>{"use strict";o.d(t,{MapTabsShell:()=>a});var s=o(95155),n=o(12115),r=o(75514);let l=["ROADMAP","ARCHITECTURE","DATABASE"];function a({initialView:e,roadmap:t,architecture:o,database:i}){let[d,c]=(0,n.useState)(e),[u,p]=(0,n.useState)(()=>new Set([e])),h=(0,n.useCallback)(e=>{c(e),p(t=>t.has(e)?t:new Set(t).add(e));try{let t=new URL(window.location.href);t.searchParams.set("view",e),window.history.replaceState(window.history.state,"",t)}catch{}},[]),f={ROADMAP:t,ARCHITECTURE:o,DATABASE:i};return(0,s.jsx)(r.no.Provider,{value:{views:r.a4,switchTo:h},children:l.map(e=>u.has(e)?(0,s.jsx)("div",{className:d===e?"contents":"hidden",children:f[e]},e):null)})}}},e=>{e.O(0,[2574,3862,5004,277,8500,4888,8997,9887,5957,766,2059,4607,2231,471,4853,8441,3794,7358],()=>e(e.s=27950)),_N_E=e.O()}]);
|