@lunora/studio 1.0.0-alpha.95 → 1.0.0-alpha.97
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/dist/index.js +1 -1
- package/dist/mount.js +1 -1
- package/dist/packem_chunks/AdvisorHealthPanel.js +1 -1
- package/dist/packem_chunks/AuditPanel.js +1 -1
- package/dist/packem_chunks/DeploymentHealthPanel.js +1 -1
- package/dist/packem_chunks/ExportImportPanel.js +1 -1
- package/dist/packem_chunks/FileBrowser.js +1 -1
- package/dist/packem_chunks/FunctionStatsPanel.js +1 -1
- package/dist/packem_chunks/HealthPanel.js +1 -1
- package/dist/packem_chunks/InsightsPanel.js +1 -1
- package/dist/packem_chunks/LogsPanel.js +1 -1
- package/dist/packem_chunks/MailPanel.js +1 -1
- package/dist/packem_chunks/MetricsPanel.js +1 -1
- package/dist/packem_chunks/NotificationsPanel.js +1 -1
- package/dist/packem_chunks/SchemaViewer.js +1 -1
- package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -1
- package/dist/packem_chunks/SettingsPanel.js +1 -1
- package/dist/packem_chunks/SqlEditorPanel.js +6 -6
- package/dist/packem_chunks/TableEditor.js +1 -1
- package/dist/packem_chunks/agents-panel.js +1 -1
- package/dist/packem_chunks/analytics-panel.js +1 -1
- package/dist/packem_chunks/auth-audit-panel.js +1 -1
- package/dist/packem_chunks/auth-config-panel.js +1 -1
- package/dist/packem_chunks/auth-sessions-panel.js +1 -1
- package/dist/packem_chunks/containers-panel.js +1 -1
- package/dist/packem_chunks/dashboards-panel.js +1 -1
- package/dist/packem_chunks/fanout-panel.js +1 -1
- package/dist/packem_chunks/flags-panel.js +1 -1
- package/dist/packem_chunks/issues-panel.js +1 -1
- package/dist/packem_chunks/kv-browser.js +1 -1
- package/dist/packem_chunks/log-drains-panel.js +2 -2
- package/dist/packem_chunks/migrations-route.js +1 -1
- package/dist/packem_chunks/organizations-panel.js +1 -1
- package/dist/packem_chunks/payments-panel.js +1 -1
- package/dist/packem_chunks/permissions-panel.js +1 -1
- package/dist/packem_chunks/queues-panel.js +1 -1
- package/dist/packem_chunks/rls-panel.js +1 -1
- package/dist/packem_chunks/schedule-panel.js +1 -1
- package/dist/packem_chunks/sparkline.js +1 -1
- package/dist/packem_chunks/storage-rules-panel.js +1 -1
- package/dist/packem_chunks/subscriptions-panel.js +1 -1
- package/dist/packem_chunks/sync-client-panel.js +1 -1
- package/dist/packem_chunks/traces-panel.js +1 -1
- package/dist/packem_chunks/users-panel.js +1 -1
- package/dist/packem_chunks/vector-browser.js +1 -1
- package/dist/packem_chunks/workflows-panel.js +1 -1
- package/dist/packem_shared/{DataBrowser-H4oUFkPJ.js → DataBrowser-CPNKM0KZ.js} +1 -1
- package/dist/packem_shared/{GlobalDataBrowser-CeA8bDjX.js → GlobalDataBrowser-BSmyOO0n.js} +1 -1
- package/dist/packem_shared/{HomePanel-DLP1nQdC.js → HomePanel-BUO6BcYQ.js} +1 -1
- package/dist/packem_shared/{MigrationsPanel-dm_M75mR.js → MigrationsPanel-BAnvY79E.js} +1 -1
- package/dist/packem_shared/{ScheduledJobs-DDJG9Je7.js → ScheduledJobs-pHVlh2xU.js} +1 -1
- package/dist/packem_shared/{Studio-BYg65qWq.js → Studio-DG_n-8Pc.js} +1 -1
- package/dist/packem_shared/{StudioApp-D0UOg0a_.js → StudioApp-bavavhpe.js} +1 -1
- package/dist/packem_shared/advisor-view-CGcwvlMo.js +1 -0
- package/dist/packem_shared/bar-chart-B8oDHgnw.js +6 -0
- package/dist/packem_shared/{card-CIDGUN6K.js → card-BMKx5UdA.js} +1 -1
- package/dist/packem_shared/{dropdown-menu-C3RQ_HlW.js → dropdown-menu-BgS2zw1i.js} +1 -1
- package/dist/packem_shared/error-alert-_2q2VtVG.js +1 -0
- package/dist/packem_shared/{grid-features-Db_BNYRo.js → grid-features-Y2YSjhCf.js} +2 -2
- package/dist/packem_shared/home-panel-Ir3YHReO.js +3 -0
- package/dist/packem_shared/result-chart-0VgP_3FP.js +1 -0
- package/dist/packem_shared/schema-diagram-GVgnLWTf.js +2 -0
- package/dist/packem_shared/{select-Bul-DeII.js → select-BssZMiFY.js} +1 -1
- package/dist/packem_shared/{sparkline-CgjeUU2I.js → sparkline-BNvxiJj_.js} +1 -1
- package/dist/packem_shared/{stat-card-fm_TF1mo.js → stat-card-BGJdhfm6.js} +1 -1
- package/dist/packem_shared/studio-C9Qvg13j.js +2 -0
- package/dist/packem_shared/{table-DdJBrClo.js → table-DZAB8cs3.js} +1 -1
- package/dist/packem_shared/{trace-handoff-Dw7mwjxu.js → trace-handoff-CuZ6WGgo.js} +1 -1
- package/dist/packem_shared/use-async-submit-B32whHJO.js +1 -0
- package/dist/standalone/{chunk-BN4CIAXU.js → chunk-2KRXOCZ2.js} +1 -1
- package/dist/standalone/{chunk-D62SDRMM.js → chunk-3626PHEZ.js} +1 -1
- package/dist/standalone/{chunk-TITX6XEA.js → chunk-3IF75YS7.js} +1 -1
- package/dist/standalone/chunk-3SCGCJYS.js +1 -0
- package/dist/standalone/{chunk-2OUIHY7G.js → chunk-3SGYSFRC.js} +1 -1
- package/dist/standalone/{chunk-7YJNH3RB.js → chunk-4EHNOASW.js} +1 -1
- package/dist/standalone/{chunk-YD5O2NWK.js → chunk-5A7NIX77.js} +1 -1
- package/dist/standalone/{chunk-UIGAA3GV.js → chunk-5L2VKBAJ.js} +1 -1
- package/dist/standalone/{chunk-NNKN2XEZ.js → chunk-5L63KFHD.js} +1 -1
- package/dist/standalone/{chunk-ZNAGZU6H.js → chunk-6F7KP54M.js} +1 -1
- package/dist/standalone/{chunk-3FIN5PH4.js → chunk-6V27P65N.js} +2 -2
- package/dist/standalone/{chunk-2T22UR7E.js → chunk-73B3T2SA.js} +1 -1
- package/dist/standalone/chunk-7CWPU3LW.js +1 -0
- package/dist/standalone/{chunk-PE7TI4TQ.js → chunk-A6NAMYVS.js} +1 -1
- package/dist/standalone/{chunk-RNOSWEMO.js → chunk-AB5WGAX6.js} +2 -2
- package/dist/standalone/{chunk-IBVBIKUI.js → chunk-ATLV7KWK.js} +1 -1
- package/dist/standalone/{chunk-IUUSMC2R.js → chunk-BLHSTFG3.js} +1 -1
- package/dist/standalone/chunk-C2ZFQARQ.js +11 -0
- package/dist/standalone/chunk-CXBXUT5A.js +3 -0
- package/dist/standalone/chunk-CZZWYUTR.js +1 -0
- package/dist/standalone/{chunk-LZKU262J.js → chunk-D264UAKY.js} +1 -1
- package/dist/standalone/{chunk-VVNQP4CI.js → chunk-DDO5EGID.js} +1 -1
- package/dist/standalone/{chunk-DMJDUC4L.js → chunk-E3Z4QXAD.js} +1 -1
- package/dist/standalone/{chunk-WI4XINU2.js → chunk-EZKBI7SZ.js} +1 -1
- package/dist/standalone/{chunk-BNAMPDZ2.js → chunk-FHZ5WDTU.js} +1 -1
- package/dist/standalone/{chunk-TMNKNTC4.js → chunk-FXBBFE7Y.js} +1 -1
- package/dist/standalone/{chunk-JYLYJT27.js → chunk-G2O3XP7Y.js} +5 -5
- package/dist/standalone/{chunk-SCKKQIAE.js → chunk-H5ZYPSLB.js} +1 -1
- package/dist/standalone/{chunk-Z4AX76YZ.js → chunk-HH5CZ6KD.js} +1 -1
- package/dist/standalone/{chunk-UGU5GYDV.js → chunk-I7V54EDS.js} +1 -1
- package/dist/standalone/{chunk-6K46XGR5.js → chunk-II64XEZV.js} +1 -1
- package/dist/standalone/{chunk-U6KDYJJC.js → chunk-IZFPJXB3.js} +1 -1
- package/dist/standalone/{chunk-QNHU4SKL.js → chunk-J4UYSDWF.js} +1 -1
- package/dist/standalone/{chunk-JWXKUXYA.js → chunk-JNY7CFF4.js} +1 -1
- package/dist/standalone/{chunk-DYMO6MDG.js → chunk-KP6VHTO4.js} +1 -1
- package/dist/standalone/{chunk-SKYFKPJC.js → chunk-LAEO6D34.js} +1 -1
- package/dist/standalone/{chunk-VNQB6HY4.js → chunk-LHAHIDNT.js} +1 -1
- package/dist/standalone/{chunk-4LCY5XUR.js → chunk-M2M3RYJU.js} +1 -1
- package/dist/standalone/{chunk-3KXDX76D.js → chunk-M3Z2YAHD.js} +1 -1
- package/dist/standalone/{chunk-YTWBHPAT.js → chunk-MW5YIENZ.js} +1 -1
- package/dist/standalone/chunk-NBANYYGB.js +1 -0
- package/dist/standalone/{chunk-465RIA2L.js → chunk-NCKRVNF2.js} +1 -1
- package/dist/standalone/{chunk-A3DBEJLO.js → chunk-NDO6YSEG.js} +1 -1
- package/dist/standalone/{chunk-O3UMJLO3.js → chunk-NJRW66LJ.js} +1 -1
- package/dist/standalone/{chunk-AQ4JNJF3.js → chunk-OKZP3YY3.js} +1 -1
- package/dist/standalone/{chunk-2O65JEMI.js → chunk-ON2FIVI2.js} +1 -1
- package/dist/standalone/chunk-OQIGV6FX.js +59 -0
- package/dist/standalone/{chunk-QXECM52Z.js → chunk-OZA2RA45.js} +1 -1
- package/dist/standalone/{chunk-XNGYYOLS.js → chunk-P33WK7YI.js} +4 -4
- package/dist/standalone/{chunk-KEVIGWKP.js → chunk-PKWJ7UOG.js} +1 -1
- package/dist/standalone/chunk-PLFTCTMX.js +1 -0
- package/dist/standalone/{chunk-7ONX5YGW.js → chunk-PMGTIUU2.js} +1 -1
- package/dist/standalone/{chunk-ABYJC3LS.js → chunk-QC4T2L6I.js} +1 -1
- package/dist/standalone/{chunk-3DJ3IUUG.js → chunk-QEVFPILV.js} +1 -1
- package/dist/standalone/{chunk-PGVJE5F5.js → chunk-QQYX5WN4.js} +1 -1
- package/dist/standalone/{chunk-G6GX5TVB.js → chunk-S7ZOM3NK.js} +1 -1
- package/dist/standalone/{chunk-M7AWSDGY.js → chunk-SPE3AB54.js} +1 -1
- package/dist/standalone/{chunk-OM36OEHZ.js → chunk-STESBRLN.js} +1 -1
- package/dist/standalone/{chunk-QM4EXWKF.js → chunk-SZXVX6PY.js} +1 -1
- package/dist/standalone/{chunk-EQZTSISX.js → chunk-TMGHRD6W.js} +1 -1
- package/dist/standalone/{chunk-ZA5YIHZM.js → chunk-UYPXC3OO.js} +1 -1
- package/dist/standalone/{chunk-ZVAGD3FT.js → chunk-VH2IO643.js} +1 -1
- package/dist/standalone/{chunk-5TDGHWYU.js → chunk-WLXH4ECM.js} +1 -1
- package/dist/standalone/{chunk-UZERI5YC.js → chunk-WQH3LT2P.js} +1 -1
- package/dist/standalone/{chunk-DBMFI2HC.js → chunk-XPOUF2XH.js} +1 -1
- package/dist/standalone/{chunk-JEZDJ7D6.js → chunk-YP7WZ6YM.js} +1 -1
- package/dist/standalone/chunk-YZIR7PL5.js +1 -0
- package/dist/standalone/studio.js +1 -1
- package/dist/styles.css +1 -1
- package/package.json +6 -6
- package/dist/packem_shared/advisor-view-Coipc04R.js +0 -1
- package/dist/packem_shared/bar-chart-DraN_srt.js +0 -9
- package/dist/packem_shared/error-alert--Ie7ofJ0.js +0 -1
- package/dist/packem_shared/home-panel-BtxdqXDe.js +0 -3
- package/dist/packem_shared/result-chart-Gywg9DOk.js +0 -1
- package/dist/packem_shared/schema-diagram-DTRaCp6Y.js +0 -2
- package/dist/packem_shared/studio-Drf4en3j.js +0 -2
- package/dist/packem_shared/use-async-submit-BFIMhRqh.js +0 -1
- package/dist/standalone/chunk-5KCULF7S.js +0 -11
- package/dist/standalone/chunk-GZMKPBTJ.js +0 -1
- package/dist/standalone/chunk-ILNELDFC.js +0 -1
- package/dist/standalone/chunk-MV4A2PAK.js +0 -1
- package/dist/standalone/chunk-Q2Q7FR3R.js +0 -1
- package/dist/standalone/chunk-S3DWUXGY.js +0 -62
- package/dist/standalone/chunk-UBIPFCOZ.js +0 -1
- package/dist/standalone/chunk-ZQPWVALL.js +0 -3
- package/dist/standalone/chunk-ZZJ7VUVZ.js +0 -1
- /package/dist/standalone/{chunk-7H7LZRLP.js → chunk-4KIQ5RLS.js} +0 -0
- /package/dist/standalone/{chunk-UU2QJMGJ.js → chunk-MKYEFQCA.js} +0 -0
- /package/dist/standalone/{chunk-KUVMORDQ.js → chunk-PKSAWP56.js} +0 -0
- /package/dist/standalone/{chunk-MIQTKZAR.js → chunk-WJQLNYGX.js} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{U as ie}from"../packem_shared/error-alert-_2q2VtVG.js";import{g as le}from"../packem_shared/badge-BbuuAio7.js";import{u as v}from"../packem_shared/button-BkCrNcAs.js";import{E as oe}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as se}from"../packem_shared/input-JHu63lTv.js";import{p as ne}from"../packem_shared/scroll-area-DTEq6Jec.js";import{Separator as de}from"@base-ui/react/separator";import{c as ce}from"../packem_shared/utils-bhneXptQ.js";import{jsx as t,jsxs as s,Fragment as me}from"react/jsx-runtime";import{useT as ue}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{d as Y,b as Z,f as ee,c as he,g as re,i as te}from"../packem_shared/internal-zkEvTqy8.js";import{c as pe}from"react/compiler-runtime";import{useLunora as fe}from"@lunora/react";import{useState as H}from"react";import{N as be}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{useAutoRefresh as ge}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{ADMIN_FUNCTIONS as Q}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";function xe({className:a,orientation:e="horizontal",...l}){return t(de,{"data-slot":"separator",orientation:e,className:ce("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",a),...l})}const ve=/https?:\/\/[^\s"'<>)]+/i,ae=a=>a===void 0?void 0:ve.exec(a)?.[0],N=a=>a===void 0?"":Array.isArray(a)?a.join(", "):a,Ne=a=>{if(a!==void 0)return ae(a.html)??ae(a.text)},ye=(a,e)=>{const l=e.trim().toLowerCase();return l===""?a:a.filter(o=>`${o.subject} ${N(o.to)} ${N(o.cc)}`.toLowerCase().includes(l))},we=(a,e)=>{if(a.length!==0)return a.find(l=>l.id===e)??a[0]},Ce=re(Q.clearCapturedMail),ke=re(Q.sendTestMail),Se=a=>{const e=pe(38),{limit:l}=a,o=fe();let p;e[0]!==l?(p={limit:l},e[0]=l,e[1]=p):p=e[1];const{data:P,error:y,errorSource:w,isLoading:g,refetch:n}=be(Q.getCapturedMail,p),[C,f]=H(null),[q,k]=H(null),[x,i]=H("html"),[c,D]=H(""),b=P?.entries??[],r=y??C,u=y===null?C:w;let S;e[2]!==o||e[3]!==n?(S=async()=>{f(null);try{await o.query(Ce,{},Y("")),k(null),n()}catch(m){f(Z(m))}},e[2]=o,e[3]=n,e[4]=S):S=e[4];const R=S;let $;e[5]!==o||e[6]!==n?($=async()=>{f(null);try{await o.query(ke,{},Y("")),n()}catch(m){f(Z(m))}},e[5]=o,e[6]=n,e[7]=$):$=e[7];const U=$;let T;e[8]!==n?(T=()=>{n()},e[8]=n,e[9]=T):T=e[9],ge(T,!0);let L;e[10]!==R?(L=()=>{ee(R())},e[10]=R,e[11]=L):L=e[11];const B=L;let j;e[12]!==U?(j=()=>{ee(U())},e[12]=U,e[13]=j):j=e[13];const W=j;let M;e[14]===Symbol.for("react.memo_cache_sentinel")?(M=m=>{D(m.currentTarget.value)},e[14]=M):M=e[14];const J=M;let _;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=m=>{const{id:h}=m.currentTarget.dataset;h!==void 0&&k(h)},e[15]=_):_=e[15];const K=_;let z;e[16]===Symbol.for("react.memo_cache_sentinel")?(z=m=>{const h=m.currentTarget.dataset.tab;(h==="headers"||h==="html"||h==="text")&&i(h)},e[16]=z):z=e[16];const V=z,F=ye(b,c),A=we(F,q),d=Ne(A);let O;e[17]!==d?(O=()=>{d!==void 0&&he(d)},e[17]=d,e[18]=O):O=e[18];const X=O;let I;e[19]!==d?(I=()=>{d!==void 0&&"window"in globalThis&&globalThis.window.open(d,"_blank","noopener")},e[19]=d,e[20]=I):I=e[20];const G=I;let E;return e[21]!==b||e[22]!==r||e[23]!==u||e[24]!==c||e[25]!==g||e[26]!==d||e[27]!==B||e[28]!==X||e[29]!==J||e[30]!==G||e[31]!==K||e[32]!==V||e[33]!==W||e[34]!==A||e[35]!==x||e[36]!==F?(E={entries:b,error:r,errorSource:u,filter:c,isLoading:g,link:d,onClear:B,onCopyLink:X,onFilterChange:J,onOpenLink:G,onSelectMessage:K,onSelectTab:V,onSendTest:W,selected:A,tab:x,visible:F},e[21]=b,e[22]=r,e[23]=u,e[24]=c,e[25]=g,e[26]=d,e[27]=B,e[28]=X,e[29]=J,e[30]=G,e[31]=K,e[32]=V,e[33]=W,e[34]=A,e[35]=x,e[36]=F,e[37]=E):E=e[37],E},$e=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,Te=a=>`${$e}${a}`,We=({limit:a=100})=>{const e=ue(),{entries:l,error:o,errorSource:p,filter:P,isLoading:y,link:w,onClear:g,onCopyLink:n,onFilterChange:C,onOpenLink:f,onSelectMessage:q,onSelectTab:k,onSendTest:x,selected:i,tab:c,visible:D}=Se({limit:a}),b=r=>e(r==="html"?"HTML":r==="text"?"Plain text":"Headers");return s("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[s("div",{className:"flex flex-wrap items-center gap-2",children:[t(v,{"data-testid":"mail-send-test",onClick:x,size:"sm",type:"button",variant:"outline",children:e("Send test")}),t(v,{"data-testid":"mail-clear",disabled:l.length===0,onClick:g,size:"sm",type:"button",variant:"outline",children:e("Clear inbox")}),l.length>0&&t(le,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:e("{count} messages",{count:l.length})})]}),o!==null&&t(ie,{error:p,testId:"mail-error"}),o===null&&!y&&l.length===0&&t(oe,{description:e("Email your app sends in dev is captured here — nothing is delivered."),icon:s("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[t("path",{d:"M4 5h16v14H4z"}),t("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:e("No captured email.")}),l.length>0&&s("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[s("div",{className:"flex flex-col gap-2",children:[t(se,{"aria-label":e("Search messages"),"data-testid":"mail-search",onChange:C,placeholder:e("Filter messages"),type:"search",value:P}),t(ne,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:t("ul",{className:"divide-y",children:D.map(r=>{const u=r.id===i?.id;return t("li",{children:s("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${u?"bg-muted":""}`,"data-active":u,"data-id":r.id,"data-testid":"mail-list-item",onClick:q,type:"button",children:[t("span",{className:"w-full truncate font-medium",children:r.subject||e("(no subject)")}),t("span",{className:"w-full truncate text-xs text-muted-foreground",children:N(r.to)}),t("span",{className:"text-xs text-muted-foreground tabular-nums",children:te(r.capturedAt,"—")})]})},r.id)})})})]}),i!==void 0&&s("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[s("div",{className:"flex flex-col gap-1",children:[t("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:i.subject||e("(no subject)")}),s("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[t("dt",{children:e("From")}),t("dd",{className:"truncate font-mono",children:i.from??"—"}),t("dt",{children:e("To")}),t("dd",{className:"truncate font-mono",children:N(i.to)}),i.cc!==void 0&&i.cc.length>0&&s(me,{children:[t("dt",{children:e("Cc")}),t("dd",{className:"truncate font-mono",children:N(i.cc)})]}),t("dt",{children:e("Sent")}),t("dd",{className:"tabular-nums",children:te(i.capturedAt,"—")})]})]}),s("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[t(v,{"data-testid":"mail-copy-link",disabled:w===void 0,onClick:n,size:"sm",type:"button",variant:"outline",children:e("Copy link")}),t(v,{"data-testid":"mail-open-link",disabled:w===void 0,onClick:f,size:"sm",type:"button",variant:"outline",children:e("Open in new tab")})]}),t(xe,{}),t("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(r=>t(v,{"aria-selected":c===r,"data-tab":r,"data-testid":`mail-tab-${r}`,onClick:k,role:"tab",size:"sm",type:"button",variant:c===r?"secondary":"ghost",children:b(r)},r))}),s("div",{className:"min-h-[12rem]",children:[c==="html"&&(i.html===void 0?t("p",{className:"text-sm text-muted-foreground",children:e("No HTML body.")}):t("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:Te(i.html),title:e("Email preview")})),c==="text"&&(i.text===void 0?t("p",{className:"text-sm text-muted-foreground",children:e("No text body.")}):t("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:i.text})),c==="headers"&&(i.headers===void 0||Object.keys(i.headers).length===0?t("p",{className:"text-sm text-muted-foreground",children:e("No headers.")}):t("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(i.headers).map(([r,u])=>`${r}: ${u}`).join(`
|
|
2
2
|
`)}))]})]})]})]})};export{We as MailPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useLunora as pt}from"@lunora/react";import{useNavigate as xt}from"@tanstack/react-router";import{useState as fe,useRef as We,useEffect as tt,useMemo as bt}from"react";import{L as vt}from"../packem_shared/live-status-CmuRLFKf.js";import{ShardInput as yt}from"../packem_shared/ShardInput-BVn2iCU0.js";import{u as rt}from"../packem_shared/button-BkCrNcAs.js";import{N as Je}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{S as Nt}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{useT as pe}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as ze}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{c as St}from"../packem_shared/cf-links-Dmg86v1D.js";import{m as $t,l as Ye,f as at,d as wt,b as qt,g as kt}from"../packem_shared/internal-zkEvTqy8.js";import{r as Mt,l as _t}from"../packem_shared/shard-history-DMEW5VBE.js";import{w as It}from"../packem_shared/trace-handoff-Dw7mwjxu.js";import{c as Le}from"react/compiler-runtime";import{f as Ct}from"../packem_shared/log-fields-CoL3hsIQ.js";import{g as et}from"../packem_shared/badge-BbuuAio7.js";import{c as he,u as ge,n as Pe,f as Qe,m as Rt}from"../packem_shared/card-CIDGUN6K.js";import{p as de,d as dt,m as He,u as oe,n as mt,f as ut}from"../packem_shared/table-DdJBrClo.js";import{S as ht}from"../packem_shared/sparkline-CgjeUU2I.js";import{jsx as r,jsxs as o,Fragment as Ve}from"react/jsx-runtime";import{aggregateMetrics as Dt,computeLatencyPercentiles as Ft,enrichQueryStats as Tt,shardsToAggregate as Lt}from"../packem_shared/aggregateMetrics-BNfajLa2.js";import{g as me}from"../packem_shared/stat-card-fm_TF1mo.js";import{ResponsiveContainer as lt,AreaChart as Ot,CartesianGrid as st,XAxis as nt,YAxis as it,Tooltip as ot,Area as zt,LineChart as At,Line as Kt}from"recharts";import{E as Et}from"../packem_shared/empty-state-Cg7t_8qu.js";import{c as jt}from"../packem_shared/utils-bhneXptQ.js";import{N as Pt,y as Qt,k as Ue,_ as Ut,w as Bt}from"../packem_shared/select-Bul-DeII.js";const Jt=(l,e)=>l<e?-1:l>e?1:0,Ze=l=>{if(l===void 0)return"null";if(typeof l=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(l===null||typeof l!="object")return JSON.stringify(l);if(Array.isArray(l))return`[${l.map(d=>Ze(d)).join(",")}]`;const e=Object.getPrototypeOf(l);if(e!==null&&e!==Object.prototype){const d=l.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${d} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const s=l,a=Object.keys(s).toSorted(Jt),t=[];for(const d of a){const i=s[d];i!==void 0&&t.push(`${JSON.stringify(d)}:${Ze(i)}`)}return`{${t.join(",")}}`},gt=(l,e,s)=>`${l}:${e}:${Ze(s??{})}`,ft=(l,e)=>l==="gauge"?e.last:l==="histogram"?e.sum/Math.max(1,e.count):e.sum,Ht=(l,e)=>ft(l,e),Gt=l=>ft(l.kind,l),Xe=l=>Number.isInteger(l)?l.toLocaleString():l.toLocaleString(void 0,{maximumFractionDigits:2}),Wt=l=>Array.isArray(l?.series)?l.series:[],Xt="FUNCTION_NOT_FOUND",Yt=l=>{const e=new Map;if(!Array.isArray(l?.series))return e;for(const s of l.series)e.set(gt(s.kind,s.name,s.attributes),s.points);return e},Vt={counter:"secondary",gauge:"default",histogram:"outline"},Zt=l=>{const e=Le(18),{name:s,onOpenTrace:a,traceId:t}=l,d=pe();if(t===void 0){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=r("span",{className:"text-muted-foreground",children:"—"}),e[0]=u):u=e[0],u}let i;e[1]!==t?(i=t.slice(0,8),e[1]=t,e[2]=i):i=e[2];const n=i;if(a===void 0){const u=`mt-instrument-trace-${s}`;let h;return e[3]!==n||e[4]!==u||e[5]!==t?(h=r("span",{className:"text-muted-foreground","data-testid":u,title:t,children:n}),e[3]=n,e[4]=u,e[5]=t,e[6]=h):h=e[6],h}const k=`mt-instrument-trace-${s}`;let f;e[7]!==a||e[8]!==t?(f=()=>{a(t)},e[7]=a,e[8]=t,e[9]=f):f=e[9];let S;e[10]!==d||e[11]!==t?(S=d("Open the exemplar trace {trace}",{trace:t}),e[10]=d,e[11]=t,e[12]=S):S=e[12];let p;return e[13]!==n||e[14]!==k||e[15]!==f||e[16]!==S?(p=r("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":k,onClick:f,title:S,type:"button",children:n}),e[13]=n,e[14]=k,e[15]=f,e[16]=S,e[17]=p):p=e[17],p},er=l=>{const e=Le(105),{onOpenTrace:s,shardKey:a}=l,t=pe();let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];let i;e[1]!==a?(i={live:!0,shardKey:a},e[1]=a,e[2]=i):i=e[2];const{data:n,error:k,errorSource:f}=Je(ze.getMetricSeries,d,i);let S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S={},e[3]=S):S=e[3];let p;e[4]!==a?(p={live:!0,shardKey:a},e[4]=a,e[5]=p):p=e[5];const{data:u}=Je(ze.getMetricHistory,S,p);let h,M,b,$,_,c,g,x,w,q,y,I,C;if(e[6]!==n||e[7]!==k||e[8]!==f||e[9]!==u||e[10]!==s||e[11]!==t){x=Symbol.for("react.early_return_sentinel");e:{const z=Wt(n),K=$t(f)===Xt;if(k!==null&&!K){let m;e[25]!==t?(m=t("Instruments"),e[25]=t,e[26]=m):m=e[26];let E;e[27]!==m?(E=r("h3",{className:"text-sm font-semibold text-foreground",children:m}),e[27]=m,e[28]=E):E=e[28];let j;e[29]!==k||e[30]!==t?(j=t("Instruments unavailable: {error}",{error:k}),e[29]=k,e[30]=t,e[31]=j):j=e[31];let P;e[32]!==j?(P=r("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:j}),e[32]=j,e[33]=P):P=e[33];let ie;e[34]!==E||e[35]!==P?(ie=o("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[E,P]}),e[34]=E,e[35]=P,e[36]=ie):ie=e[36],x=ie;break e}if(z.length===0){x=null;break e}const Q=Yt(u);let L;e[37]!==t?(L=m=>t(m==="counter"?"Counter":m==="gauge"?"Gauge":"Histogram"),e[37]=t,e[38]=L):L=e[38];const U=L;_="flex flex-col gap-2",c="mt-instruments";let O;e[39]!==t?(O=t("Instruments"),e[39]=t,e[40]=O):O=e[40],e[41]!==O?(g=r("h3",{className:"text-sm font-semibold text-foreground",children:O}),e[41]=O,e[42]=g):g=e[42],$=he,C="overflow-hidden py-0",b=ge,I="px-0",M=mt,q="mt-instruments-table";let A;e[43]!==t?(A=t("name"),e[43]=t,e[44]=A):A=e[44];let J;e[45]!==A?(J=r(de,{children:A}),e[45]=A,e[46]=J):J=e[46];let H;e[47]!==t?(H=t("kind"),e[47]=t,e[48]=H):H=e[48];let G;e[49]!==H?(G=r(de,{children:H}),e[49]=H,e[50]=G):G=e[50];let W;e[51]!==t?(W=t("value"),e[51]=t,e[52]=W):W=e[52];let X;e[53]!==W?(X=r(de,{className:"text-right",children:W}),e[53]=W,e[54]=X):X=e[54];let Y;e[55]!==t?(Y=t("count"),e[55]=t,e[56]=Y):Y=e[56];let V;e[57]!==Y?(V=r(de,{className:"text-right",children:Y}),e[57]=Y,e[58]=V):V=e[58];let Z;e[59]!==t?(Z=t("range"),e[59]=t,e[60]=Z):Z=e[60];let ee;e[61]!==Z?(ee=r(de,{className:"text-right",children:Z}),e[61]=Z,e[62]=ee):ee=e[62];let te;e[63]!==t?(te=t("trend"),e[63]=t,e[64]=te):te=e[64];let re;e[65]!==te?(re=r(de,{children:te}),e[65]=te,e[66]=re):re=e[66];let ae;e[67]!==t?(ae=t("trace"),e[67]=t,e[68]=ae):ae=e[68];let le;e[69]!==ae?(le=r(de,{children:ae}),e[69]=ae,e[70]=le):le=e[70];let se;e[71]!==t?(se=t("dimensions"),e[71]=t,e[72]=se):se=e[72];let ne;e[73]!==se?(ne=r(de,{children:se}),e[73]=se,e[74]=ne):ne=e[74],e[75]!==J||e[76]!==G||e[77]!==X||e[78]!==V||e[79]!==ee||e[80]!==re||e[81]!==le||e[82]!==ne?(y=r(dt,{children:o(He,{children:[J,G,X,V,ee,re,le,ne]})}),e[75]=J,e[76]=G,e[77]=X,e[78]=V,e[79]=ee,e[80]=re,e[81]=le,e[82]=ne,e[83]=y):y=e[83],h=ut,w=z.map(m=>{const E=Ct(m.attributes),j=gt(m.kind,m.name,m.attributes),P=(Q.get(j)??[]).map(ie=>Ht(m.kind,ie));return o(He,{"data-testid":`mt-instrument-${m.name}`,children:[r(oe,{className:"font-mono text-xs",title:m.functionPath,children:m.name}),r(oe,{children:r(et,{variant:Vt[m.kind],children:U(m.kind)})}),r(oe,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${m.name}`,children:Xe(Gt(m))}),r(oe,{className:"text-right tabular-nums text-muted-foreground",children:m.count.toLocaleString()}),r(oe,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:m.min===m.max?"—":`${Xe(m.min)}–${Xe(m.max)}`}),r(oe,{children:P.length>=2?r(ht,{ariaLabel:t("{name} trend",{name:m.name}),className:"h-6 w-24 text-foreground",series:P,testId:`mt-instrument-trend-${m.name}`}):r("span",{className:"text-xs text-muted-foreground",children:"—"})}),r(oe,{className:"font-mono text-xs",children:r(Zt,{name:m.name,onOpenTrace:s,traceId:m.exemplarTraceId})}),r(oe,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:E,children:E===""?"—":E})]},j)})}e[6]=n,e[7]=k,e[8]=f,e[9]=u,e[10]=s,e[11]=t,e[12]=h,e[13]=M,e[14]=b,e[15]=$,e[16]=_,e[17]=c,e[18]=g,e[19]=x,e[20]=w,e[21]=q,e[22]=y,e[23]=I,e[24]=C}else h=e[12],M=e[13],b=e[14],$=e[15],_=e[16],c=e[17],g=e[18],x=e[19],w=e[20],q=e[21],y=e[22],I=e[23],C=e[24];if(x!==Symbol.for("react.early_return_sentinel"))return x;let R;e[84]!==h||e[85]!==w?(R=r(h,{children:w}),e[84]=h,e[85]=w,e[86]=R):R=e[86];let D;e[87]!==M||e[88]!==R||e[89]!==q||e[90]!==y?(D=o(M,{"data-testid":q,children:[y,R]}),e[87]=M,e[88]=R,e[89]=q,e[90]=y,e[91]=D):D=e[91];let N;e[92]!==b||e[93]!==D||e[94]!==I?(N=r(b,{className:I,children:D}),e[92]=b,e[93]=D,e[94]=I,e[95]=N):N=e[95];let v;e[96]!==$||e[97]!==N||e[98]!==C?(v=r($,{className:C,children:N}),e[96]=$,e[97]=N,e[98]=C,e[99]=v):v=e[99];let T;return e[100]!==_||e[101]!==c||e[102]!==g||e[103]!==v?(T=o("section",{className:_,"data-testid":c,children:[g,v]}),e[100]=_,e[101]=c,e[102]=g,e[103]=v,e[104]=T):T=e[104],T},tr=l=>{const e=Le(74),{aggregate:s,shardResults:a}=l,t=pe();let d;e[0]!==t?(d=t("Shards"),e[0]=t,e[1]=d):d=e[1];let i;e[2]!==s.failed||e[3]!==s.reachable||e[4]!==t?(i=s.failed>0?t("{reachable} reachable, {failed} unreachable",{failed:s.failed,reachable:s.reachable}):t("{reachable} reachable",{reachable:s.reachable}),e[2]=s.failed,e[3]=s.reachable,e[4]=t,e[5]=i):i=e[5];let n;e[6]!==d||e[7]!==i?(n=r(me,{label:d,testId:"mt-agg-shards",value:i}),e[6]=d,e[7]=i,e[8]=n):n=e[8];let k;e[9]!==t?(k=t("Total requests"),e[9]=t,e[10]=k):k=e[10];let f;e[11]!==s.totalRequests||e[12]!==k?(f=r(me,{label:k,testId:"mt-agg-requests",value:s.totalRequests}),e[11]=s.totalRequests,e[12]=k,e[13]=f):f=e[13];let S;e[14]!==t?(S=t("Total errors"),e[14]=t,e[15]=S):S=e[15];let p;e[16]!==s.totalErrors||e[17]!==S?(p=r(me,{label:S,testId:"mt-agg-errors",value:s.totalErrors}),e[16]=s.totalErrors,e[17]=S,e[18]=p):p=e[18];let u;e[19]!==t?(u=t("Total database size"),e[19]=t,e[20]=u):u=e[20];let h;e[21]!==s.totalDatabaseSize?(h=Ye(s.totalDatabaseSize),e[21]=s.totalDatabaseSize,e[22]=h):h=e[22];let M;e[23]!==u||e[24]!==h?(M=r(me,{label:u,testId:"mt-agg-db-size",value:h}),e[23]=u,e[24]=h,e[25]=M):M=e[25];let b;e[26]!==t?(b=t("Combined cache hit rate"),e[26]=t,e[27]=b):b=e[27];let $;e[28]!==s.hitRate||e[29]!==t?($=s.hitRate===null?t("no cache configured"):`${(s.hitRate*100).toFixed(1)}%`,e[28]=s.hitRate,e[29]=t,e[30]=$):$=e[30];let _;e[31]!==b||e[32]!==$?(_=r(me,{label:b,testId:"mt-agg-cache",value:$}),e[31]=b,e[32]=$,e[33]=_):_=e[33];let c;e[34]!==M||e[35]!==_||e[36]!==n||e[37]!==f||e[38]!==p?(c=o("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[n,f,p,M,_]}),e[34]=M,e[35]=_,e[36]=n,e[37]=f,e[38]=p,e[39]=c):c=e[39];let g;e[40]!==t?(g=t("shard"),e[40]=t,e[41]=g):g=e[41];let x;e[42]!==g?(x=r(de,{children:g}),e[42]=g,e[43]=x):x=e[43];let w;e[44]!==t?(w=t("requests"),e[44]=t,e[45]=w):w=e[45];let q;e[46]!==w?(q=r(de,{children:w}),e[46]=w,e[47]=q):q=e[47];let y;e[48]!==t?(y=t("errors"),e[48]=t,e[49]=y):y=e[49];let I;e[50]!==y?(I=r(de,{children:y}),e[50]=y,e[51]=I):I=e[51];let C;e[52]!==t?(C=t("db size"),e[52]=t,e[53]=C):C=e[53];let R;e[54]!==C?(R=r(de,{children:C}),e[54]=C,e[55]=R):R=e[55];let D;e[56]!==x||e[57]!==q||e[58]!==I||e[59]!==R?(D=r(dt,{children:o(He,{children:[x,q,I,R]})}),e[56]=x,e[57]=q,e[58]=I,e[59]=R,e[60]=D):D=e[60];let N;if(e[61]!==a||e[62]!==t){let K;e[64]!==t?(K=Q=>o(He,{"data-testid":`mt-agg-row-${Q.shard}`,children:[r(oe,{children:Q.shard}),Q.metrics===null?r(oe,{className:"text-destructive",colSpan:3,children:Q.error??t("unreachable")}):o(Ve,{children:[r(oe,{className:"tabular-nums",children:Q.metrics.requests}),r(oe,{className:"tabular-nums",children:Q.metrics.errors}),r(oe,{className:"tabular-nums",children:Ye(Q.metrics.databaseSize)})]})]},Q.shard),e[64]=t,e[65]=K):K=e[65],N=a.map(K),e[61]=a,e[62]=t,e[63]=N}else N=e[63];let v;e[66]!==N?(v=r(ut,{children:N}),e[66]=N,e[67]=v):v=e[67];let T;e[68]!==D||e[69]!==v?(T=r(he,{className:"overflow-hidden py-0",children:r(ge,{className:"px-0",children:o(mt,{"data-testid":"mt-agg-table",children:[D,v]})})}),e[68]=D,e[69]=v,e[70]=T):T=e[70];let z;return e[71]!==c||e[72]!==T?(z=o("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[c,T]}),e[71]=c,e[72]=T,e[73]=z):z=e[73],z},rr=l=>{const e=Math.floor(l/1e3),s=Math.floor(e/3600),a=Math.floor(e%3600/60),t=e%60;return s>0?`${s.toString()}h ${a.toString()}m`:a>0?`${a.toString()}m ${t.toString()}s`:`${t.toString()}s`},ar=(l,e)=>{const s=l+e;return s===0?"—":`${(l/s*100).toFixed(1)}%`},ct=l=>l<=0?"—":l<1?`${(l*1e3).toFixed(0)}μs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,lr=l=>{const e=Le(75),{currentDelta:s,errorRate:a,history:t,latencyPercentiles:d,metrics:i}=l,n=pe();let k;e[0]!==t||e[1]!==n?(k=t.length>=2?r(ht,{ariaLabel:n("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:t,testId:"mt-sparkline"}):void 0,e[0]=t,e[1]=n,e[2]=k):k=e[2];let f;e[3]!==s||e[4]!==t.length||e[5]!==n?(f=t.length>=2?o(Ve,{children:[r("span",{className:"font-semibold text-foreground",children:`+${s.toLocaleString()}`})," ",n("last interval")]}):r("span",{"data-testid":"mt-sparkline-empty",children:n("collecting samples…")}),e[3]=s,e[4]=t.length,e[5]=n,e[6]=f):f=e[6];let S;e[7]!==n?(S=n("Requests"),e[7]=n,e[8]=S):S=e[8];let p;e[9]!==i.requests||e[10]!==k||e[11]!==f||e[12]!==S?(p=r(me,{chart:k,footer:f,label:S,testId:"mt-requests",value:i.requests}),e[9]=i.requests,e[10]=k,e[11]=f,e[12]=S,e[13]=p):p=e[13];let u;e[14]!==a||e[15]!==n?(u=n("{rate} error rate",{rate:a}),e[14]=a,e[15]=n,e[16]=u):u=e[16];let h;e[17]!==n?(h=n("Errors"),e[17]=n,e[18]=h):h=e[18];let M;e[19]!==a||e[20]!==i.errors?(M=o(Ve,{children:[i.errors," (",a,")"]}),e[19]=a,e[20]=i.errors,e[21]=M):M=e[21];let b;e[22]!==u||e[23]!==h||e[24]!==M?(b=r(me,{footer:u,label:h,testId:"mt-errors",value:M}),e[22]=u,e[23]=h,e[24]=M,e[25]=b):b=e[25];let $;e[26]!==d.p90?($=d.p90>0?`P90 ${ct(d.p90)}`:void 0,e[26]=d.p90,e[27]=$):$=e[27];let _;e[28]!==n?(_=n("P95 latency"),e[28]=n,e[29]=_):_=e[29];let c;e[30]!==d.p95?(c=d.p95>0?ct(d.p95):"—",e[30]=d.p95,e[31]=c):c=e[31];let g;e[32]!==_||e[33]!==c||e[34]!==$?(g=r(me,{footer:$,label:_,testId:"mt-p95",value:c}),e[32]=_,e[33]=c,e[34]=$,e[35]=g):g=e[35];let x;e[36]!==i.cache||e[37]!==n?(x=i.cache===null?void 0:`${i.cache.entries.toLocaleString()} ${n("cache entries")}`,e[36]=i.cache,e[37]=n,e[38]=x):x=e[38];let w;e[39]!==n?(w=n("Database size"),e[39]=n,e[40]=w):w=e[40];let q;e[41]!==i.databaseSize?(q=Ye(i.databaseSize),e[41]=i.databaseSize,e[42]=q):q=e[42];let y;e[43]!==x||e[44]!==w||e[45]!==q?(y=r(me,{footer:x,label:w,testId:"mt-db-size",value:q}),e[43]=x,e[44]=w,e[45]=q,e[46]=y):y=e[46];let I;e[47]!==n?(I=n("Shard"),e[47]=n,e[48]=I):I=e[48];let C;e[49]!==i.shard||e[50]!==I?(C=r(me,{label:I,testId:"mt-shard",value:i.shard}),e[49]=i.shard,e[50]=I,e[51]=C):C=e[51];let R;e[52]!==n?(R=n("Uptime"),e[52]=n,e[53]=R):R=e[53];let D;e[54]!==i.uptimeMs?(D=rr(i.uptimeMs),e[54]=i.uptimeMs,e[55]=D):D=e[55];let N;e[56]!==R||e[57]!==D?(N=r(me,{label:R,testId:"mt-uptime",value:D}),e[56]=R,e[57]=D,e[58]=N):N=e[58];let v;e[59]!==n?(v=n("Cache hit rate"),e[59]=n,e[60]=v):v=e[60];let T;e[61]!==i.cache||e[62]!==n?(T=i.cache===null?n("no cache configured"):n("{rate} ({count} entries)",{count:i.cache.entries,rate:ar(i.cache.hits,i.cache.misses)}),e[61]=i.cache,e[62]=n,e[63]=T):T=e[63];let z;e[64]!==v||e[65]!==T?(z=r(me,{label:v,testId:"mt-cache",value:T}),e[64]=v,e[65]=T,e[66]=z):z=e[66];let K;return e[67]!==g||e[68]!==y||e[69]!==C||e[70]!==N||e[71]!==z||e[72]!==p||e[73]!==b?(K=o("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[p,b,g,y,C,N,z]}),e[67]=g,e[68]=y,e[69]=C,e[70]=N,e[71]=z,e[72]=p,e[73]=b,e[74]=K):K=e[74],K},Ge=l=>l>=100?"critical":l>=50?"warning":"good",Oe=l=>l<1?`${(l*1e3).toFixed(0)}μs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,Be=l=>l>=1e9?`${(l/1e9).toFixed(1)}B`:l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(1)}K`:l.toLocaleString(),sr=l=>{const e=Le(3),{level:s}=l;if(s==="critical"){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=r(et,{variant:"destructive",children:"Slow"}),e[0]=t):t=e[0],t}if(s==="warning"){let t;return e[1]===Symbol.for("react.memo_cache_sentinel")?(t=r("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"}),e[1]=t):t=e[1],t}let a;return e[2]===Symbol.for("react.memo_cache_sentinel")?(a=r("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",children:"Fast"}),e[2]=a):a=e[2],a},nr=(l,e)=>{const s=[...l];return s.sort((a,t)=>{switch(e){case"avgTime":return t.avgDurationMs-a.avgDurationMs;case"execCount":return t.execCount-a.execCount;case"rowsRead":return t.rowsRead-a.rowsRead;default:return t.totalDurationMs-a.totalDurationMs}}),s},ir=l=>{const e=Le(161),{queryStats:s}=l,a=pe(),[t,d]=fe("totalTime");let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[0]=i):i=e[0];const[n,k]=fe(i);let f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=C=>{C!==null&&d(C)},e[1]=f):f=e[1];const S=f;let p,u,h,M,b,$,_,c,g,x;if(e[2]!==n||e[3]!==s||e[4]!==t||e[5]!==a){h=Symbol.for("react.early_return_sentinel");e:{const C=nr(s,t);let R;e[16]!==s?(R=s.filter(or),e[16]=s,e[17]=R):R=e[17];const D=R.length;let N;e[18]!==s?(N=s.filter(cr),e[18]=s,e[19]=N):N=e[19];const v=N.length;let T;e[20]!==s?(T=s.filter(dr),e[20]=s,e[21]=T):T=e[21];const z=T.length;let K;e[22]===Symbol.for("react.memo_cache_sentinel")?(K=F=>{k(ce=>{const B=new Set(ce);return B.has(F)?B.delete(F):B.add(F),B})},e[22]=K):K=e[22];const Q=K;if(s.length===0){let F;e[23]!==a?(F=a("No query insights yet"),e[23]=a,e[24]=F):F=e[24];let ce;e[25]!==F?(ce=r("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:F}),e[25]=F,e[26]=ce):ce=e[26];let B;e[27]!==a?(B=a("Query insights appear once statements are executed against this shard."),e[27]=a,e[28]=B):B=e[28];let ue;e[29]!==B?(ue=r("p",{className:"mt-1 text-sm",children:B}),e[29]=B,e[30]=ue):ue=e[30];let je;e[31]!==ce||e[32]!==ue?(je=r(he,{children:r(ge,{className:"py-12",children:o("div",{className:"text-center text-muted-foreground",children:[ce,ue]})})}),e[31]=ce,e[32]=ue,e[33]=je):je=e[33],h=je;break e}_="space-y-4",c="qi-root";let L;e[34]!==a?(L=a("Critical queries"),e[34]=a,e[35]=L):L=e[35];let U;e[36]!==L?(U=r(Pe,{className:"pb-2",children:r(Qe,{className:"text-sm font-medium",children:L})}),e[36]=L,e[37]=U):U=e[37];let O;e[38]!==D?(O=r("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:D}),e[38]=D,e[39]=O):O=e[39];let A;e[40]!==a?(A=a(">100ms avg execution"),e[40]=a,e[41]=A):A=e[41];let J;e[42]!==A?(J=r("p",{className:"text-xs text-muted-foreground",children:A}),e[42]=A,e[43]=J):J=e[43];let H;e[44]!==O||e[45]!==J?(H=o(ge,{children:[O,J]}),e[44]=O,e[45]=J,e[46]=H):H=e[46];let G;e[47]!==U||e[48]!==H?(G=o(he,{children:[U,H]}),e[47]=U,e[48]=H,e[49]=G):G=e[49];let W;e[50]!==a?(W=a("Moderate queries"),e[50]=a,e[51]=W):W=e[51];let X;e[52]!==W?(X=r(Pe,{className:"pb-2",children:r(Qe,{className:"text-sm font-medium",children:W})}),e[52]=W,e[53]=X):X=e[53];let Y;e[54]!==v?(Y=r("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:v}),e[54]=v,e[55]=Y):Y=e[55];let V;e[56]!==a?(V=a("50–100ms avg execution"),e[56]=a,e[57]=V):V=e[57];let Z;e[58]!==V?(Z=r("p",{className:"text-xs text-muted-foreground",children:V}),e[58]=V,e[59]=Z):Z=e[59];let ee;e[60]!==Y||e[61]!==Z?(ee=o(ge,{children:[Y,Z]}),e[60]=Y,e[61]=Z,e[62]=ee):ee=e[62];let te;e[63]!==X||e[64]!==ee?(te=o(he,{children:[X,ee]}),e[63]=X,e[64]=ee,e[65]=te):te=e[65];let re;e[66]!==a?(re=a("Fast queries"),e[66]=a,e[67]=re):re=e[67];let ae;e[68]!==re?(ae=r(Pe,{className:"pb-2",children:r(Qe,{className:"text-sm font-medium",children:re})}),e[68]=re,e[69]=ae):ae=e[69];let le;e[70]!==z?(le=r("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:z}),e[70]=z,e[71]=le):le=e[71];let se;e[72]!==a?(se=a("<50ms avg execution"),e[72]=a,e[73]=se):se=e[73];let ne;e[74]!==se?(ne=r("p",{className:"text-xs text-muted-foreground",children:se}),e[74]=se,e[75]=ne):ne=e[75];let m;e[76]!==le||e[77]!==ne?(m=o(ge,{children:[le,ne]}),e[76]=le,e[77]=ne,e[78]=m):m=e[78];let E;e[79]!==ae||e[80]!==m?(E=o(he,{children:[ae,m]}),e[79]=ae,e[80]=m,e[81]=E):E=e[81],e[82]!==G||e[83]!==te||e[84]!==E?(g=o("div",{className:"grid gap-4 md:grid-cols-3",children:[G,te,E]}),e[82]=G,e[83]=te,e[84]=E,e[85]=g):g=e[85];let j;e[86]!==a?(j=a("Query leaderboard"),e[86]=a,e[87]=j):j=e[87];let P;e[88]!==j?(P=r("h3",{className:"text-lg font-semibold",children:j}),e[88]=j,e[89]=P):P=e[89];let ie;e[90]!==t||e[91]!==a?(ie=a("Slow queries sorted by {sortField}",{sortField:a(t)}),e[90]=t,e[91]=a,e[92]=ie):ie=e[92];let xe;e[93]!==ie?(xe=r("p",{className:"text-sm text-muted-foreground",children:ie}),e[93]=ie,e[94]=xe):xe=e[94];let be;e[95]!==P||e[96]!==xe?(be=o("div",{children:[P,xe]}),e[95]=P,e[96]=xe,e[97]=be):be=e[97];let ve;e[98]!==a?(ve=a("Sort by"),e[98]=a,e[99]=ve):ve=e[99];let ye;e[100]!==ve?(ye=r("span",{className:"text-sm text-muted-foreground",children:ve}),e[100]=ve,e[101]=ye):ye=e[101];let Ne;e[102]!==a?(Ne=a("Sort queries by"),e[102]=a,e[103]=Ne):Ne=e[103];let Ae;e[104]===Symbol.for("react.memo_cache_sentinel")?(Ae=r(Pt,{}),e[104]=Ae):Ae=e[104];let Se;e[105]!==Ne?(Se=r(Qt,{"aria-label":Ne,className:"w-[140px]","data-testid":"qi-sort",children:Ae}),e[105]=Ne,e[106]=Se):Se=e[106];let $e;e[107]!==a?($e=a("Total time"),e[107]=a,e[108]=$e):$e=e[108];let we;e[109]!==$e?(we=r(Ue,{value:"totalTime",children:$e}),e[109]=$e,e[110]=we):we=e[110];let qe;e[111]!==a?(qe=a("Avg time"),e[111]=a,e[112]=qe):qe=e[112];let ke;e[113]!==qe?(ke=r(Ue,{value:"avgTime",children:qe}),e[113]=qe,e[114]=ke):ke=e[114];let Me;e[115]!==a?(Me=a("Execution count"),e[115]=a,e[116]=Me):Me=e[116];let _e;e[117]!==Me?(_e=r(Ue,{value:"execCount",children:Me}),e[117]=Me,e[118]=_e):_e=e[118];let Ie;e[119]!==a?(Ie=a("Rows read"),e[119]=a,e[120]=Ie):Ie=e[120];let Ce;e[121]!==Ie?(Ce=r(Ue,{value:"rowsRead",children:Ie}),e[121]=Ie,e[122]=Ce):Ce=e[122];let Re;e[123]!==we||e[124]!==ke||e[125]!==_e||e[126]!==Ce?(Re=o(Ut,{children:[we,ke,_e,Ce]}),e[123]=we,e[124]=ke,e[125]=_e,e[126]=Ce,e[127]=Re):Re=e[127];let De;e[128]!==t||e[129]!==Se||e[130]!==Re?(De=o(Bt,{onValueChange:S,value:t,children:[Se,Re]}),e[128]=t,e[129]=Se,e[130]=Re,e[131]=De):De=e[131];let Fe;e[132]!==ye||e[133]!==De?(Fe=o("div",{className:"flex items-center gap-2",children:[ye,De]}),e[132]=ye,e[133]=De,e[134]=Fe):Fe=e[134],e[135]!==be||e[136]!==Fe?(x=o("div",{className:"flex items-center justify-between",children:[be,Fe]}),e[135]=be,e[136]=Fe,e[137]=x):x=e[137],u=he;let Te;e[138]!==a?(Te=a("Statements"),e[138]=a,e[139]=Te):Te=e[139];let Ke;e[140]!==Te?(Ke=r(Qe,{children:Te}),e[140]=Te,e[141]=Ke):Ke=e[141],$=o(Pe,{children:[Ke,r(Rt,{children:a("{count} tracked statements",{count:C.length})})]}),p=ge,M="space-y-2";let Ee;e[142]!==n||e[143]!==a?(Ee=F=>{const ce=F.normalizedSql,B=n.has(ce),ue=Ge(F.avgDurationMs);return o("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[o("button",{"aria-expanded":B,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:()=>{Q(ce)},type:"button",children:[o("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[r(sr,{level:ue}),r("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:F.normalizedSql})]}),o("div",{className:"flex shrink-0 items-center gap-4",children:[o("div",{className:"text-right",children:[r("div",{className:"text-sm font-medium",children:Oe(F.totalDurationMs)}),r("div",{className:"text-xs text-muted-foreground",children:a("total")})]}),o("div",{className:"text-right",children:[r("div",{className:"text-sm font-medium",children:Oe(F.avgDurationMs)}),r("div",{className:"text-xs text-muted-foreground",children:a("avg")})]}),F.p95DurationMs!==void 0&&o("div",{className:"text-right",children:[r("div",{className:"text-sm font-medium",children:Oe(F.p95DurationMs)}),r("div",{className:"text-xs text-muted-foreground",children:a("p95")})]}),o("div",{className:"text-right",children:[r("div",{className:"text-sm font-medium",children:Be(F.execCount)}),r("div",{className:"text-xs text-muted-foreground",children:a("calls")})]})]})]}),B&&o("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[o("div",{children:[r("p",{className:"mb-2 text-sm font-medium",children:a("Full statement")}),r("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:F.normalizedSql})]}),o("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[F.p50DurationMs!==void 0&&o("div",{children:[r("span",{className:"text-muted-foreground",children:a("p50")}),r("span",{className:"block font-medium tabular-nums",children:Oe(F.p50DurationMs)})]}),o("div",{children:[r("span",{className:"text-muted-foreground",children:a("Exec count")}),r("span",{className:"block font-medium tabular-nums",children:Be(F.execCount)})]}),o("div",{children:[r("span",{className:"text-muted-foreground",children:a("Total time")}),r("span",{className:"block font-medium tabular-nums",children:Oe(F.totalDurationMs)})]}),o("div",{children:[r("span",{className:"text-muted-foreground",children:a("Rows read")}),r("span",{className:"block font-medium tabular-nums",children:Be(F.rowsRead)})]}),o("div",{children:[r("span",{className:"text-muted-foreground",children:a("Rows written")}),r("span",{className:"block font-medium tabular-nums",children:Be(F.rowsWritten)})]})]})]})]},ce)},e[142]=n,e[143]=a,e[144]=Ee):Ee=e[144],b=C.map(Ee)}e[2]=n,e[3]=s,e[4]=t,e[5]=a,e[6]=p,e[7]=u,e[8]=h,e[9]=M,e[10]=b,e[11]=$,e[12]=_,e[13]=c,e[14]=g,e[15]=x}else p=e[6],u=e[7],h=e[8],M=e[9],b=e[10],$=e[11],_=e[12],c=e[13],g=e[14],x=e[15];if(h!==Symbol.for("react.early_return_sentinel"))return h;let w;e[145]!==M||e[146]!==b?(w=r("div",{className:M,children:b}),e[145]=M,e[146]=b,e[147]=w):w=e[147];let q;e[148]!==p||e[149]!==w?(q=r(p,{children:w}),e[148]=p,e[149]=w,e[150]=q):q=e[150];let y;e[151]!==u||e[152]!==q||e[153]!==$?(y=o(u,{children:[$,q]}),e[151]=u,e[152]=q,e[153]=$,e[154]=y):y=e[154];let I;return e[155]!==y||e[156]!==_||e[157]!==c||e[158]!==g||e[159]!==x?(I=o("div",{className:_,"data-testid":c,children:[g,x,y]}),e[155]=y,e[156]=_,e[157]=c,e[158]=g,e[159]=x,e[160]=I):I=e[160],I};function or(l){return Ge(l.avgDurationMs)==="critical"}function cr(l){return Ge(l.avgDurationMs)==="warning"}function dr(l){return Ge(l.avgDurationMs)==="good"}const mr=["1m","5m","15m","1h"],ur=l=>new Date(l).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),hr=l=>l.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:ur(e.bucketMs)})),gr=({shardKey:l=""})=>{const e=pe(),[s,a]=fe("15m"),t=Je(ze.getQueryInsights,{range:s},{live:!0,shardKey:l}).data,d=hr(t?.buckets??[]);return o("div",{className:"flex flex-col gap-4","data-testid":"qi-range",children:[o("div",{className:"flex flex-wrap items-center gap-2",children:[r("div",{className:"flex gap-1 rounded-lg border border-border p-0.5","data-testid":"qi-ranges",role:"group",children:mr.map(i=>r("button",{"aria-pressed":i===s,className:jt("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",i===s&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${i}`,onClick:()=>{a(i)},type:"button",children:i},i))}),t?.capped===!0&&r(et,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),d.length===0?r(Et,{description:e("Statements executed in the selected window appear here, with throughput and latency over time."),testId:"qi-empty",title:e("No queries in this window.")}):o("div",{className:"grid gap-4 lg:grid-cols-2",children:[o("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-throughput",children:[r("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Throughput")}),r(lt,{height:140,width:"100%",children:o(Ot,{data:d,children:[r(st,{strokeDasharray:"3 3",vertical:!1}),r(nt,{dataKey:"label",fontSize:10,tickLine:!1}),r(it,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),r(ot,{}),r(zt,{dataKey:"execs",fill:"var(--color-primary)",fillOpacity:.15,stroke:"var(--color-primary)",type:"monotone"})]})})]}),o("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-latency",children:[r("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Mean latency (ms)")}),r(lt,{height:140,width:"100%",children:o(At,{data:d,children:[r(st,{strokeDasharray:"3 3",vertical:!1}),r(nt,{dataKey:"label",fontSize:10,tickLine:!1}),r(it,{fontSize:10,tickLine:!1,width:32}),r(ot,{}),r(Kt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),r(ir,{queryStats:t?.entries??[]})]})},fr=kt(ze.getMetrics),pr=(l,e)=>l?e:"overview",Ur=({initialShardKey:l})=>{const e=pt(),s=pe(),a=xt(),{queryShardKey:t,setShardKey:d,shardKey:i}=Nt(l),[n,k]=fe("overview"),[f,S]=fe([]),p=We(null),u=We(null),h=We(!0);tt(()=>(h.current=!0,()=>{h.current=!1}),[]);const M=L=>{It({shardKey:t,traceId:L}),at(a({to:"/traces"}))},{data:b,error:$,liveError:_}=Je(ze.getMetrics,{},{live:!0,shardKey:t}),c=b??null;tt(()=>{if(b===void 0)return;Mt(t);const L=b,U=p.current,O=u.current!==null&&u.current!==L.shard;if(u.current=L.shard,p.current=L.requests,O){S([]);return}U!==null&&L.requests>=U&&S(A=>[...A,L.requests-U].slice(-30))},[b,t]);const[g,x]=fe(null),[w,q]=fe(!1),y=async()=>{q(!0);const L=Lt(i,_t());try{const U=await Promise.all(L.map(async O=>{try{const A=await e.query(fr,{},wt(O));return{error:null,metrics:A,shard:O===""?A.shard:O}}catch(A){return{error:qt(A),metrics:null,shard:O===""?"__root__":O}}}));h.current&&x(U)}finally{h.current&&q(!1)}},I=g===null?null:Dt(g),C=c===null||c.requests===0?"—":`${(c.errors/c.requests*100).toFixed(1)}%`,R=f.length>0?f.at(-1):0,D=c?Ft(c):{p90:0,p95:0},N=bt(()=>{if(!c||!("queryStats"in c))return;const L=c.queryStats;if(!(!L||!Array.isArray(L)))return Tt(L)},[c]),v=pr(N!==void 0,n),T=()=>{at(y())},z=()=>{x(null)},K=()=>{k("overview")},Q=()=>{k("query-insights")};return o("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[o("div",{className:"flex flex-wrap items-center gap-2",children:[r(yt,{onChange:d,testId:"mt-shard-input",value:i}),r(vt,{message:_,prefix:"mt"}),r(rt,{"data-testid":"mt-aggregate",disabled:w,onClick:T,size:"sm",type:"button",variant:"secondary",children:s(w?"Aggregating…":"All shards")}),g!==null&&r(rt,{"data-testid":"mt-aggregate-clear",onClick:z,size:"sm",type:"button",variant:"ghost",children:s("Hide")}),r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:St,rel:"noreferrer",target:"_blank",children:s("Open in Cloudflare")})]}),$!==null&&r("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:$}),N!==void 0&&o("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[r("button",{className:`pb-2 text-sm font-medium transition-colors ${v==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:K,type:"button",children:s("Overview")}),o("button",{className:`pb-2 text-sm font-medium transition-colors ${v==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:Q,type:"button",children:[s("Query insights"),N.length>0&&r("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:N.length})]})]}),v==="query-insights"&&N!==void 0&&r(gr,{shardKey:t}),v==="overview"&&c!==null&&r(lr,{currentDelta:R,errorRate:C,history:f,latencyPercentiles:D,metrics:c}),v==="overview"&&c===null&&null,v==="overview"&&r(er,{onOpenTrace:M,shardKey:t}),v==="overview"&&I!==null&&g!==null&&r(tr,{aggregate:I,shardResults:g})]})};export{Ur as MetricsPanel};
|
|
1
|
+
import{useLunora as pt}from"@lunora/react";import{useNavigate as xt}from"@tanstack/react-router";import{useState as fe,useRef as We,useEffect as tt,useMemo as bt}from"react";import{L as vt}from"../packem_shared/live-status-CmuRLFKf.js";import{ShardInput as yt}from"../packem_shared/ShardInput-BVn2iCU0.js";import{u as rt}from"../packem_shared/button-BkCrNcAs.js";import{N as Je}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{S as Nt}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{useT as pe}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as ze}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{c as St}from"../packem_shared/cf-links-Dmg86v1D.js";import{m as $t,l as Ye,f as at,d as wt,b as qt,g as kt}from"../packem_shared/internal-zkEvTqy8.js";import{r as Mt,l as _t}from"../packem_shared/shard-history-DMEW5VBE.js";import{w as It}from"../packem_shared/trace-handoff-CuZ6WGgo.js";import{c as Le}from"react/compiler-runtime";import{f as Ct}from"../packem_shared/log-fields-CoL3hsIQ.js";import{g as et}from"../packem_shared/badge-BbuuAio7.js";import{c as he,f as ge,n as Pe,m as Ue,p as Rt}from"../packem_shared/card-BMKx5UdA.js";import{m as de,n as dt,f as He,p as oe,d as mt,b as ut}from"../packem_shared/table-DZAB8cs3.js";import{S as ht}from"../packem_shared/sparkline-BNvxiJj_.js";import{jsx as r,jsxs as o,Fragment as Ve}from"react/jsx-runtime";import{aggregateMetrics as Dt,computeLatencyPercentiles as Ft,enrichQueryStats as Tt,shardsToAggregate as Lt}from"../packem_shared/aggregateMetrics-BNfajLa2.js";import{g as me}from"../packem_shared/stat-card-BGJdhfm6.js";import{ResponsiveContainer as lt,AreaChart as Ot,CartesianGrid as st,XAxis as nt,YAxis as it,Tooltip as ot,Area as zt,LineChart as At,Line as Kt}from"recharts";import{E as Et}from"../packem_shared/empty-state-Cg7t_8qu.js";import{c as jt}from"../packem_shared/utils-bhneXptQ.js";import{w as Pt,z as Ut,_ as Qe,S as Qt,x as Bt}from"../packem_shared/select-BssZMiFY.js";const Jt=(l,e)=>l<e?-1:l>e?1:0,Ze=l=>{if(l===void 0)return"null";if(typeof l=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(l===null||typeof l!="object")return JSON.stringify(l);if(Array.isArray(l))return`[${l.map(d=>Ze(d)).join(",")}]`;const e=Object.getPrototypeOf(l);if(e!==null&&e!==Object.prototype){const d=l.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${d} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const s=l,a=Object.keys(s).toSorted(Jt),t=[];for(const d of a){const i=s[d];i!==void 0&&t.push(`${JSON.stringify(d)}:${Ze(i)}`)}return`{${t.join(",")}}`},gt=(l,e,s)=>`${l}:${e}:${Ze(s??{})}`,ft=(l,e)=>l==="gauge"?e.last:l==="histogram"?e.sum/Math.max(1,e.count):e.sum,Ht=(l,e)=>ft(l,e),Gt=l=>ft(l.kind,l),Xe=l=>Number.isInteger(l)?l.toLocaleString():l.toLocaleString(void 0,{maximumFractionDigits:2}),Wt=l=>Array.isArray(l?.series)?l.series:[],Xt="FUNCTION_NOT_FOUND",Yt=l=>{const e=new Map;if(!Array.isArray(l?.series))return e;for(const s of l.series)e.set(gt(s.kind,s.name,s.attributes),s.points);return e},Vt={counter:"secondary",gauge:"default",histogram:"outline"},Zt=l=>{const e=Le(18),{name:s,onOpenTrace:a,traceId:t}=l,d=pe();if(t===void 0){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=r("span",{className:"text-muted-foreground",children:"—"}),e[0]=u):u=e[0],u}let i;e[1]!==t?(i=t.slice(0,8),e[1]=t,e[2]=i):i=e[2];const n=i;if(a===void 0){const u=`mt-instrument-trace-${s}`;let h;return e[3]!==n||e[4]!==u||e[5]!==t?(h=r("span",{className:"text-muted-foreground","data-testid":u,title:t,children:n}),e[3]=n,e[4]=u,e[5]=t,e[6]=h):h=e[6],h}const k=`mt-instrument-trace-${s}`;let f;e[7]!==a||e[8]!==t?(f=()=>{a(t)},e[7]=a,e[8]=t,e[9]=f):f=e[9];let S;e[10]!==d||e[11]!==t?(S=d("Open the exemplar trace {trace}",{trace:t}),e[10]=d,e[11]=t,e[12]=S):S=e[12];let p;return e[13]!==n||e[14]!==k||e[15]!==f||e[16]!==S?(p=r("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":k,onClick:f,title:S,type:"button",children:n}),e[13]=n,e[14]=k,e[15]=f,e[16]=S,e[17]=p):p=e[17],p},er=l=>{const e=Le(105),{onOpenTrace:s,shardKey:a}=l,t=pe();let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];let i;e[1]!==a?(i={live:!0,shardKey:a},e[1]=a,e[2]=i):i=e[2];const{data:n,error:k,errorSource:f}=Je(ze.getMetricSeries,d,i);let S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S={},e[3]=S):S=e[3];let p;e[4]!==a?(p={live:!0,shardKey:a},e[4]=a,e[5]=p):p=e[5];const{data:u}=Je(ze.getMetricHistory,S,p);let h,M,b,$,_,c,g,x,w,q,y,I,C;if(e[6]!==n||e[7]!==k||e[8]!==f||e[9]!==u||e[10]!==s||e[11]!==t){x=Symbol.for("react.early_return_sentinel");e:{const z=Wt(n),K=$t(f)===Xt;if(k!==null&&!K){let m;e[25]!==t?(m=t("Instruments"),e[25]=t,e[26]=m):m=e[26];let E;e[27]!==m?(E=r("h3",{className:"text-sm font-semibold text-foreground",children:m}),e[27]=m,e[28]=E):E=e[28];let j;e[29]!==k||e[30]!==t?(j=t("Instruments unavailable: {error}",{error:k}),e[29]=k,e[30]=t,e[31]=j):j=e[31];let P;e[32]!==j?(P=r("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:j}),e[32]=j,e[33]=P):P=e[33];let ie;e[34]!==E||e[35]!==P?(ie=o("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[E,P]}),e[34]=E,e[35]=P,e[36]=ie):ie=e[36],x=ie;break e}if(z.length===0){x=null;break e}const U=Yt(u);let L;e[37]!==t?(L=m=>t(m==="counter"?"Counter":m==="gauge"?"Gauge":"Histogram"),e[37]=t,e[38]=L):L=e[38];const Q=L;_="flex flex-col gap-2",c="mt-instruments";let O;e[39]!==t?(O=t("Instruments"),e[39]=t,e[40]=O):O=e[40],e[41]!==O?(g=r("h3",{className:"text-sm font-semibold text-foreground",children:O}),e[41]=O,e[42]=g):g=e[42],$=he,C="overflow-hidden py-0",b=ge,I="px-0",M=mt,q="mt-instruments-table";let A;e[43]!==t?(A=t("name"),e[43]=t,e[44]=A):A=e[44];let J;e[45]!==A?(J=r(de,{children:A}),e[45]=A,e[46]=J):J=e[46];let H;e[47]!==t?(H=t("kind"),e[47]=t,e[48]=H):H=e[48];let G;e[49]!==H?(G=r(de,{children:H}),e[49]=H,e[50]=G):G=e[50];let W;e[51]!==t?(W=t("value"),e[51]=t,e[52]=W):W=e[52];let X;e[53]!==W?(X=r(de,{className:"text-right",children:W}),e[53]=W,e[54]=X):X=e[54];let Y;e[55]!==t?(Y=t("count"),e[55]=t,e[56]=Y):Y=e[56];let V;e[57]!==Y?(V=r(de,{className:"text-right",children:Y}),e[57]=Y,e[58]=V):V=e[58];let Z;e[59]!==t?(Z=t("range"),e[59]=t,e[60]=Z):Z=e[60];let ee;e[61]!==Z?(ee=r(de,{className:"text-right",children:Z}),e[61]=Z,e[62]=ee):ee=e[62];let te;e[63]!==t?(te=t("trend"),e[63]=t,e[64]=te):te=e[64];let re;e[65]!==te?(re=r(de,{children:te}),e[65]=te,e[66]=re):re=e[66];let ae;e[67]!==t?(ae=t("trace"),e[67]=t,e[68]=ae):ae=e[68];let le;e[69]!==ae?(le=r(de,{children:ae}),e[69]=ae,e[70]=le):le=e[70];let se;e[71]!==t?(se=t("dimensions"),e[71]=t,e[72]=se):se=e[72];let ne;e[73]!==se?(ne=r(de,{children:se}),e[73]=se,e[74]=ne):ne=e[74],e[75]!==J||e[76]!==G||e[77]!==X||e[78]!==V||e[79]!==ee||e[80]!==re||e[81]!==le||e[82]!==ne?(y=r(dt,{children:o(He,{children:[J,G,X,V,ee,re,le,ne]})}),e[75]=J,e[76]=G,e[77]=X,e[78]=V,e[79]=ee,e[80]=re,e[81]=le,e[82]=ne,e[83]=y):y=e[83],h=ut,w=z.map(m=>{const E=Ct(m.attributes),j=gt(m.kind,m.name,m.attributes),P=(U.get(j)??[]).map(ie=>Ht(m.kind,ie));return o(He,{"data-testid":`mt-instrument-${m.name}`,children:[r(oe,{className:"font-mono text-xs",title:m.functionPath,children:m.name}),r(oe,{children:r(et,{variant:Vt[m.kind],children:Q(m.kind)})}),r(oe,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${m.name}`,children:Xe(Gt(m))}),r(oe,{className:"text-right tabular-nums text-muted-foreground",children:m.count.toLocaleString()}),r(oe,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:m.min===m.max?"—":`${Xe(m.min)}–${Xe(m.max)}`}),r(oe,{children:P.length>=2?r(ht,{ariaLabel:t("{name} trend",{name:m.name}),className:"h-6 w-24 text-foreground",series:P,testId:`mt-instrument-trend-${m.name}`}):r("span",{className:"text-xs text-muted-foreground",children:"—"})}),r(oe,{className:"font-mono text-xs",children:r(Zt,{name:m.name,onOpenTrace:s,traceId:m.exemplarTraceId})}),r(oe,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:E,children:E===""?"—":E})]},j)})}e[6]=n,e[7]=k,e[8]=f,e[9]=u,e[10]=s,e[11]=t,e[12]=h,e[13]=M,e[14]=b,e[15]=$,e[16]=_,e[17]=c,e[18]=g,e[19]=x,e[20]=w,e[21]=q,e[22]=y,e[23]=I,e[24]=C}else h=e[12],M=e[13],b=e[14],$=e[15],_=e[16],c=e[17],g=e[18],x=e[19],w=e[20],q=e[21],y=e[22],I=e[23],C=e[24];if(x!==Symbol.for("react.early_return_sentinel"))return x;let R;e[84]!==h||e[85]!==w?(R=r(h,{children:w}),e[84]=h,e[85]=w,e[86]=R):R=e[86];let D;e[87]!==M||e[88]!==R||e[89]!==q||e[90]!==y?(D=o(M,{"data-testid":q,children:[y,R]}),e[87]=M,e[88]=R,e[89]=q,e[90]=y,e[91]=D):D=e[91];let N;e[92]!==b||e[93]!==D||e[94]!==I?(N=r(b,{className:I,children:D}),e[92]=b,e[93]=D,e[94]=I,e[95]=N):N=e[95];let v;e[96]!==$||e[97]!==N||e[98]!==C?(v=r($,{className:C,children:N}),e[96]=$,e[97]=N,e[98]=C,e[99]=v):v=e[99];let T;return e[100]!==_||e[101]!==c||e[102]!==g||e[103]!==v?(T=o("section",{className:_,"data-testid":c,children:[g,v]}),e[100]=_,e[101]=c,e[102]=g,e[103]=v,e[104]=T):T=e[104],T},tr=l=>{const e=Le(74),{aggregate:s,shardResults:a}=l,t=pe();let d;e[0]!==t?(d=t("Shards"),e[0]=t,e[1]=d):d=e[1];let i;e[2]!==s.failed||e[3]!==s.reachable||e[4]!==t?(i=s.failed>0?t("{reachable} reachable, {failed} unreachable",{failed:s.failed,reachable:s.reachable}):t("{reachable} reachable",{reachable:s.reachable}),e[2]=s.failed,e[3]=s.reachable,e[4]=t,e[5]=i):i=e[5];let n;e[6]!==d||e[7]!==i?(n=r(me,{label:d,testId:"mt-agg-shards",value:i}),e[6]=d,e[7]=i,e[8]=n):n=e[8];let k;e[9]!==t?(k=t("Total requests"),e[9]=t,e[10]=k):k=e[10];let f;e[11]!==s.totalRequests||e[12]!==k?(f=r(me,{label:k,testId:"mt-agg-requests",value:s.totalRequests}),e[11]=s.totalRequests,e[12]=k,e[13]=f):f=e[13];let S;e[14]!==t?(S=t("Total errors"),e[14]=t,e[15]=S):S=e[15];let p;e[16]!==s.totalErrors||e[17]!==S?(p=r(me,{label:S,testId:"mt-agg-errors",value:s.totalErrors}),e[16]=s.totalErrors,e[17]=S,e[18]=p):p=e[18];let u;e[19]!==t?(u=t("Total database size"),e[19]=t,e[20]=u):u=e[20];let h;e[21]!==s.totalDatabaseSize?(h=Ye(s.totalDatabaseSize),e[21]=s.totalDatabaseSize,e[22]=h):h=e[22];let M;e[23]!==u||e[24]!==h?(M=r(me,{label:u,testId:"mt-agg-db-size",value:h}),e[23]=u,e[24]=h,e[25]=M):M=e[25];let b;e[26]!==t?(b=t("Combined cache hit rate"),e[26]=t,e[27]=b):b=e[27];let $;e[28]!==s.hitRate||e[29]!==t?($=s.hitRate===null?t("no cache configured"):`${(s.hitRate*100).toFixed(1)}%`,e[28]=s.hitRate,e[29]=t,e[30]=$):$=e[30];let _;e[31]!==b||e[32]!==$?(_=r(me,{label:b,testId:"mt-agg-cache",value:$}),e[31]=b,e[32]=$,e[33]=_):_=e[33];let c;e[34]!==M||e[35]!==_||e[36]!==n||e[37]!==f||e[38]!==p?(c=o("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[n,f,p,M,_]}),e[34]=M,e[35]=_,e[36]=n,e[37]=f,e[38]=p,e[39]=c):c=e[39];let g;e[40]!==t?(g=t("shard"),e[40]=t,e[41]=g):g=e[41];let x;e[42]!==g?(x=r(de,{children:g}),e[42]=g,e[43]=x):x=e[43];let w;e[44]!==t?(w=t("requests"),e[44]=t,e[45]=w):w=e[45];let q;e[46]!==w?(q=r(de,{children:w}),e[46]=w,e[47]=q):q=e[47];let y;e[48]!==t?(y=t("errors"),e[48]=t,e[49]=y):y=e[49];let I;e[50]!==y?(I=r(de,{children:y}),e[50]=y,e[51]=I):I=e[51];let C;e[52]!==t?(C=t("db size"),e[52]=t,e[53]=C):C=e[53];let R;e[54]!==C?(R=r(de,{children:C}),e[54]=C,e[55]=R):R=e[55];let D;e[56]!==x||e[57]!==q||e[58]!==I||e[59]!==R?(D=r(dt,{children:o(He,{children:[x,q,I,R]})}),e[56]=x,e[57]=q,e[58]=I,e[59]=R,e[60]=D):D=e[60];let N;if(e[61]!==a||e[62]!==t){let K;e[64]!==t?(K=U=>o(He,{"data-testid":`mt-agg-row-${U.shard}`,children:[r(oe,{children:U.shard}),U.metrics===null?r(oe,{className:"text-destructive",colSpan:3,children:U.error??t("unreachable")}):o(Ve,{children:[r(oe,{className:"tabular-nums",children:U.metrics.requests}),r(oe,{className:"tabular-nums",children:U.metrics.errors}),r(oe,{className:"tabular-nums",children:Ye(U.metrics.databaseSize)})]})]},U.shard),e[64]=t,e[65]=K):K=e[65],N=a.map(K),e[61]=a,e[62]=t,e[63]=N}else N=e[63];let v;e[66]!==N?(v=r(ut,{children:N}),e[66]=N,e[67]=v):v=e[67];let T;e[68]!==D||e[69]!==v?(T=r(he,{className:"overflow-hidden py-0",children:r(ge,{className:"px-0",children:o(mt,{"data-testid":"mt-agg-table",children:[D,v]})})}),e[68]=D,e[69]=v,e[70]=T):T=e[70];let z;return e[71]!==c||e[72]!==T?(z=o("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[c,T]}),e[71]=c,e[72]=T,e[73]=z):z=e[73],z},rr=l=>{const e=Math.floor(l/1e3),s=Math.floor(e/3600),a=Math.floor(e%3600/60),t=e%60;return s>0?`${s.toString()}h ${a.toString()}m`:a>0?`${a.toString()}m ${t.toString()}s`:`${t.toString()}s`},ar=(l,e)=>{const s=l+e;return s===0?"—":`${(l/s*100).toFixed(1)}%`},ct=l=>l<=0?"—":l<1?`${(l*1e3).toFixed(0)}μs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,lr=l=>{const e=Le(75),{currentDelta:s,errorRate:a,history:t,latencyPercentiles:d,metrics:i}=l,n=pe();let k;e[0]!==t||e[1]!==n?(k=t.length>=2?r(ht,{ariaLabel:n("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:t,testId:"mt-sparkline"}):void 0,e[0]=t,e[1]=n,e[2]=k):k=e[2];let f;e[3]!==s||e[4]!==t.length||e[5]!==n?(f=t.length>=2?o(Ve,{children:[r("span",{className:"font-semibold text-foreground",children:`+${s.toLocaleString()}`})," ",n("last interval")]}):r("span",{"data-testid":"mt-sparkline-empty",children:n("collecting samples…")}),e[3]=s,e[4]=t.length,e[5]=n,e[6]=f):f=e[6];let S;e[7]!==n?(S=n("Requests"),e[7]=n,e[8]=S):S=e[8];let p;e[9]!==i.requests||e[10]!==k||e[11]!==f||e[12]!==S?(p=r(me,{chart:k,footer:f,label:S,testId:"mt-requests",value:i.requests}),e[9]=i.requests,e[10]=k,e[11]=f,e[12]=S,e[13]=p):p=e[13];let u;e[14]!==a||e[15]!==n?(u=n("{rate} error rate",{rate:a}),e[14]=a,e[15]=n,e[16]=u):u=e[16];let h;e[17]!==n?(h=n("Errors"),e[17]=n,e[18]=h):h=e[18];let M;e[19]!==a||e[20]!==i.errors?(M=o(Ve,{children:[i.errors," (",a,")"]}),e[19]=a,e[20]=i.errors,e[21]=M):M=e[21];let b;e[22]!==u||e[23]!==h||e[24]!==M?(b=r(me,{footer:u,label:h,testId:"mt-errors",value:M}),e[22]=u,e[23]=h,e[24]=M,e[25]=b):b=e[25];let $;e[26]!==d.p90?($=d.p90>0?`P90 ${ct(d.p90)}`:void 0,e[26]=d.p90,e[27]=$):$=e[27];let _;e[28]!==n?(_=n("P95 latency"),e[28]=n,e[29]=_):_=e[29];let c;e[30]!==d.p95?(c=d.p95>0?ct(d.p95):"—",e[30]=d.p95,e[31]=c):c=e[31];let g;e[32]!==_||e[33]!==c||e[34]!==$?(g=r(me,{footer:$,label:_,testId:"mt-p95",value:c}),e[32]=_,e[33]=c,e[34]=$,e[35]=g):g=e[35];let x;e[36]!==i.cache||e[37]!==n?(x=i.cache===null?void 0:`${i.cache.entries.toLocaleString()} ${n("cache entries")}`,e[36]=i.cache,e[37]=n,e[38]=x):x=e[38];let w;e[39]!==n?(w=n("Database size"),e[39]=n,e[40]=w):w=e[40];let q;e[41]!==i.databaseSize?(q=Ye(i.databaseSize),e[41]=i.databaseSize,e[42]=q):q=e[42];let y;e[43]!==x||e[44]!==w||e[45]!==q?(y=r(me,{footer:x,label:w,testId:"mt-db-size",value:q}),e[43]=x,e[44]=w,e[45]=q,e[46]=y):y=e[46];let I;e[47]!==n?(I=n("Shard"),e[47]=n,e[48]=I):I=e[48];let C;e[49]!==i.shard||e[50]!==I?(C=r(me,{label:I,testId:"mt-shard",value:i.shard}),e[49]=i.shard,e[50]=I,e[51]=C):C=e[51];let R;e[52]!==n?(R=n("Uptime"),e[52]=n,e[53]=R):R=e[53];let D;e[54]!==i.uptimeMs?(D=rr(i.uptimeMs),e[54]=i.uptimeMs,e[55]=D):D=e[55];let N;e[56]!==R||e[57]!==D?(N=r(me,{label:R,testId:"mt-uptime",value:D}),e[56]=R,e[57]=D,e[58]=N):N=e[58];let v;e[59]!==n?(v=n("Cache hit rate"),e[59]=n,e[60]=v):v=e[60];let T;e[61]!==i.cache||e[62]!==n?(T=i.cache===null?n("no cache configured"):n("{rate} ({count} entries)",{count:i.cache.entries,rate:ar(i.cache.hits,i.cache.misses)}),e[61]=i.cache,e[62]=n,e[63]=T):T=e[63];let z;e[64]!==v||e[65]!==T?(z=r(me,{label:v,testId:"mt-cache",value:T}),e[64]=v,e[65]=T,e[66]=z):z=e[66];let K;return e[67]!==g||e[68]!==y||e[69]!==C||e[70]!==N||e[71]!==z||e[72]!==p||e[73]!==b?(K=o("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[p,b,g,y,C,N,z]}),e[67]=g,e[68]=y,e[69]=C,e[70]=N,e[71]=z,e[72]=p,e[73]=b,e[74]=K):K=e[74],K},Ge=l=>l>=100?"critical":l>=50?"warning":"good",Oe=l=>l<1?`${(l*1e3).toFixed(0)}μs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,Be=l=>l>=1e9?`${(l/1e9).toFixed(1)}B`:l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(1)}K`:l.toLocaleString(),sr=l=>{const e=Le(3),{level:s}=l;if(s==="critical"){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=r(et,{variant:"destructive",children:"Slow"}),e[0]=t):t=e[0],t}if(s==="warning"){let t;return e[1]===Symbol.for("react.memo_cache_sentinel")?(t=r("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"}),e[1]=t):t=e[1],t}let a;return e[2]===Symbol.for("react.memo_cache_sentinel")?(a=r("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",children:"Fast"}),e[2]=a):a=e[2],a},nr=(l,e)=>{const s=[...l];return s.sort((a,t)=>{switch(e){case"avgTime":return t.avgDurationMs-a.avgDurationMs;case"execCount":return t.execCount-a.execCount;case"rowsRead":return t.rowsRead-a.rowsRead;default:return t.totalDurationMs-a.totalDurationMs}}),s},ir=l=>{const e=Le(161),{queryStats:s}=l,a=pe(),[t,d]=fe("totalTime");let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[0]=i):i=e[0];const[n,k]=fe(i);let f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=C=>{C!==null&&d(C)},e[1]=f):f=e[1];const S=f;let p,u,h,M,b,$,_,c,g,x;if(e[2]!==n||e[3]!==s||e[4]!==t||e[5]!==a){h=Symbol.for("react.early_return_sentinel");e:{const C=nr(s,t);let R;e[16]!==s?(R=s.filter(or),e[16]=s,e[17]=R):R=e[17];const D=R.length;let N;e[18]!==s?(N=s.filter(cr),e[18]=s,e[19]=N):N=e[19];const v=N.length;let T;e[20]!==s?(T=s.filter(dr),e[20]=s,e[21]=T):T=e[21];const z=T.length;let K;e[22]===Symbol.for("react.memo_cache_sentinel")?(K=F=>{k(ce=>{const B=new Set(ce);return B.has(F)?B.delete(F):B.add(F),B})},e[22]=K):K=e[22];const U=K;if(s.length===0){let F;e[23]!==a?(F=a("No query insights yet"),e[23]=a,e[24]=F):F=e[24];let ce;e[25]!==F?(ce=r("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:F}),e[25]=F,e[26]=ce):ce=e[26];let B;e[27]!==a?(B=a("Query insights appear once statements are executed against this shard."),e[27]=a,e[28]=B):B=e[28];let ue;e[29]!==B?(ue=r("p",{className:"mt-1 text-sm",children:B}),e[29]=B,e[30]=ue):ue=e[30];let je;e[31]!==ce||e[32]!==ue?(je=r(he,{children:r(ge,{className:"py-12",children:o("div",{className:"text-center text-muted-foreground",children:[ce,ue]})})}),e[31]=ce,e[32]=ue,e[33]=je):je=e[33],h=je;break e}_="space-y-4",c="qi-root";let L;e[34]!==a?(L=a("Critical queries"),e[34]=a,e[35]=L):L=e[35];let Q;e[36]!==L?(Q=r(Pe,{className:"pb-2",children:r(Ue,{className:"text-sm font-medium",children:L})}),e[36]=L,e[37]=Q):Q=e[37];let O;e[38]!==D?(O=r("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:D}),e[38]=D,e[39]=O):O=e[39];let A;e[40]!==a?(A=a(">100ms avg execution"),e[40]=a,e[41]=A):A=e[41];let J;e[42]!==A?(J=r("p",{className:"text-xs text-muted-foreground",children:A}),e[42]=A,e[43]=J):J=e[43];let H;e[44]!==O||e[45]!==J?(H=o(ge,{children:[O,J]}),e[44]=O,e[45]=J,e[46]=H):H=e[46];let G;e[47]!==Q||e[48]!==H?(G=o(he,{children:[Q,H]}),e[47]=Q,e[48]=H,e[49]=G):G=e[49];let W;e[50]!==a?(W=a("Moderate queries"),e[50]=a,e[51]=W):W=e[51];let X;e[52]!==W?(X=r(Pe,{className:"pb-2",children:r(Ue,{className:"text-sm font-medium",children:W})}),e[52]=W,e[53]=X):X=e[53];let Y;e[54]!==v?(Y=r("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:v}),e[54]=v,e[55]=Y):Y=e[55];let V;e[56]!==a?(V=a("50–100ms avg execution"),e[56]=a,e[57]=V):V=e[57];let Z;e[58]!==V?(Z=r("p",{className:"text-xs text-muted-foreground",children:V}),e[58]=V,e[59]=Z):Z=e[59];let ee;e[60]!==Y||e[61]!==Z?(ee=o(ge,{children:[Y,Z]}),e[60]=Y,e[61]=Z,e[62]=ee):ee=e[62];let te;e[63]!==X||e[64]!==ee?(te=o(he,{children:[X,ee]}),e[63]=X,e[64]=ee,e[65]=te):te=e[65];let re;e[66]!==a?(re=a("Fast queries"),e[66]=a,e[67]=re):re=e[67];let ae;e[68]!==re?(ae=r(Pe,{className:"pb-2",children:r(Ue,{className:"text-sm font-medium",children:re})}),e[68]=re,e[69]=ae):ae=e[69];let le;e[70]!==z?(le=r("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:z}),e[70]=z,e[71]=le):le=e[71];let se;e[72]!==a?(se=a("<50ms avg execution"),e[72]=a,e[73]=se):se=e[73];let ne;e[74]!==se?(ne=r("p",{className:"text-xs text-muted-foreground",children:se}),e[74]=se,e[75]=ne):ne=e[75];let m;e[76]!==le||e[77]!==ne?(m=o(ge,{children:[le,ne]}),e[76]=le,e[77]=ne,e[78]=m):m=e[78];let E;e[79]!==ae||e[80]!==m?(E=o(he,{children:[ae,m]}),e[79]=ae,e[80]=m,e[81]=E):E=e[81],e[82]!==G||e[83]!==te||e[84]!==E?(g=o("div",{className:"grid gap-4 md:grid-cols-3",children:[G,te,E]}),e[82]=G,e[83]=te,e[84]=E,e[85]=g):g=e[85];let j;e[86]!==a?(j=a("Query leaderboard"),e[86]=a,e[87]=j):j=e[87];let P;e[88]!==j?(P=r("h3",{className:"text-lg font-semibold",children:j}),e[88]=j,e[89]=P):P=e[89];let ie;e[90]!==t||e[91]!==a?(ie=a("Slow queries sorted by {sortField}",{sortField:a(t)}),e[90]=t,e[91]=a,e[92]=ie):ie=e[92];let xe;e[93]!==ie?(xe=r("p",{className:"text-sm text-muted-foreground",children:ie}),e[93]=ie,e[94]=xe):xe=e[94];let be;e[95]!==P||e[96]!==xe?(be=o("div",{children:[P,xe]}),e[95]=P,e[96]=xe,e[97]=be):be=e[97];let ve;e[98]!==a?(ve=a("Sort by"),e[98]=a,e[99]=ve):ve=e[99];let ye;e[100]!==ve?(ye=r("span",{className:"text-sm text-muted-foreground",children:ve}),e[100]=ve,e[101]=ye):ye=e[101];let Ne;e[102]!==a?(Ne=a("Sort queries by"),e[102]=a,e[103]=Ne):Ne=e[103];let Ae;e[104]===Symbol.for("react.memo_cache_sentinel")?(Ae=r(Pt,{}),e[104]=Ae):Ae=e[104];let Se;e[105]!==Ne?(Se=r(Ut,{"aria-label":Ne,className:"w-[140px]","data-testid":"qi-sort",children:Ae}),e[105]=Ne,e[106]=Se):Se=e[106];let $e;e[107]!==a?($e=a("Total time"),e[107]=a,e[108]=$e):$e=e[108];let we;e[109]!==$e?(we=r(Qe,{value:"totalTime",children:$e}),e[109]=$e,e[110]=we):we=e[110];let qe;e[111]!==a?(qe=a("Avg time"),e[111]=a,e[112]=qe):qe=e[112];let ke;e[113]!==qe?(ke=r(Qe,{value:"avgTime",children:qe}),e[113]=qe,e[114]=ke):ke=e[114];let Me;e[115]!==a?(Me=a("Execution count"),e[115]=a,e[116]=Me):Me=e[116];let _e;e[117]!==Me?(_e=r(Qe,{value:"execCount",children:Me}),e[117]=Me,e[118]=_e):_e=e[118];let Ie;e[119]!==a?(Ie=a("Rows read"),e[119]=a,e[120]=Ie):Ie=e[120];let Ce;e[121]!==Ie?(Ce=r(Qe,{value:"rowsRead",children:Ie}),e[121]=Ie,e[122]=Ce):Ce=e[122];let Re;e[123]!==we||e[124]!==ke||e[125]!==_e||e[126]!==Ce?(Re=o(Qt,{children:[we,ke,_e,Ce]}),e[123]=we,e[124]=ke,e[125]=_e,e[126]=Ce,e[127]=Re):Re=e[127];let De;e[128]!==t||e[129]!==Se||e[130]!==Re?(De=o(Bt,{onValueChange:S,value:t,children:[Se,Re]}),e[128]=t,e[129]=Se,e[130]=Re,e[131]=De):De=e[131];let Fe;e[132]!==ye||e[133]!==De?(Fe=o("div",{className:"flex items-center gap-2",children:[ye,De]}),e[132]=ye,e[133]=De,e[134]=Fe):Fe=e[134],e[135]!==be||e[136]!==Fe?(x=o("div",{className:"flex items-center justify-between",children:[be,Fe]}),e[135]=be,e[136]=Fe,e[137]=x):x=e[137],u=he;let Te;e[138]!==a?(Te=a("Statements"),e[138]=a,e[139]=Te):Te=e[139];let Ke;e[140]!==Te?(Ke=r(Ue,{children:Te}),e[140]=Te,e[141]=Ke):Ke=e[141],$=o(Pe,{children:[Ke,r(Rt,{children:a("{count} tracked statements",{count:C.length})})]}),p=ge,M="space-y-2";let Ee;e[142]!==n||e[143]!==a?(Ee=F=>{const ce=F.normalizedSql,B=n.has(ce),ue=Ge(F.avgDurationMs);return o("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[o("button",{"aria-expanded":B,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:()=>{U(ce)},type:"button",children:[o("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[r(sr,{level:ue}),r("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:F.normalizedSql})]}),o("div",{className:"flex shrink-0 items-center gap-4",children:[o("div",{className:"text-right",children:[r("div",{className:"text-sm font-medium",children:Oe(F.totalDurationMs)}),r("div",{className:"text-xs text-muted-foreground",children:a("total")})]}),o("div",{className:"text-right",children:[r("div",{className:"text-sm font-medium",children:Oe(F.avgDurationMs)}),r("div",{className:"text-xs text-muted-foreground",children:a("avg")})]}),F.p95DurationMs!==void 0&&o("div",{className:"text-right",children:[r("div",{className:"text-sm font-medium",children:Oe(F.p95DurationMs)}),r("div",{className:"text-xs text-muted-foreground",children:a("p95")})]}),o("div",{className:"text-right",children:[r("div",{className:"text-sm font-medium",children:Be(F.execCount)}),r("div",{className:"text-xs text-muted-foreground",children:a("calls")})]})]})]}),B&&o("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[o("div",{children:[r("p",{className:"mb-2 text-sm font-medium",children:a("Full statement")}),r("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:F.normalizedSql})]}),o("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[F.p50DurationMs!==void 0&&o("div",{children:[r("span",{className:"text-muted-foreground",children:a("p50")}),r("span",{className:"block font-medium tabular-nums",children:Oe(F.p50DurationMs)})]}),o("div",{children:[r("span",{className:"text-muted-foreground",children:a("Exec count")}),r("span",{className:"block font-medium tabular-nums",children:Be(F.execCount)})]}),o("div",{children:[r("span",{className:"text-muted-foreground",children:a("Total time")}),r("span",{className:"block font-medium tabular-nums",children:Oe(F.totalDurationMs)})]}),o("div",{children:[r("span",{className:"text-muted-foreground",children:a("Rows read")}),r("span",{className:"block font-medium tabular-nums",children:Be(F.rowsRead)})]}),o("div",{children:[r("span",{className:"text-muted-foreground",children:a("Rows written")}),r("span",{className:"block font-medium tabular-nums",children:Be(F.rowsWritten)})]})]})]})]},ce)},e[142]=n,e[143]=a,e[144]=Ee):Ee=e[144],b=C.map(Ee)}e[2]=n,e[3]=s,e[4]=t,e[5]=a,e[6]=p,e[7]=u,e[8]=h,e[9]=M,e[10]=b,e[11]=$,e[12]=_,e[13]=c,e[14]=g,e[15]=x}else p=e[6],u=e[7],h=e[8],M=e[9],b=e[10],$=e[11],_=e[12],c=e[13],g=e[14],x=e[15];if(h!==Symbol.for("react.early_return_sentinel"))return h;let w;e[145]!==M||e[146]!==b?(w=r("div",{className:M,children:b}),e[145]=M,e[146]=b,e[147]=w):w=e[147];let q;e[148]!==p||e[149]!==w?(q=r(p,{children:w}),e[148]=p,e[149]=w,e[150]=q):q=e[150];let y;e[151]!==u||e[152]!==q||e[153]!==$?(y=o(u,{children:[$,q]}),e[151]=u,e[152]=q,e[153]=$,e[154]=y):y=e[154];let I;return e[155]!==y||e[156]!==_||e[157]!==c||e[158]!==g||e[159]!==x?(I=o("div",{className:_,"data-testid":c,children:[g,x,y]}),e[155]=y,e[156]=_,e[157]=c,e[158]=g,e[159]=x,e[160]=I):I=e[160],I};function or(l){return Ge(l.avgDurationMs)==="critical"}function cr(l){return Ge(l.avgDurationMs)==="warning"}function dr(l){return Ge(l.avgDurationMs)==="good"}const mr=["1m","5m","15m","1h"],ur=l=>new Date(l).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),hr=l=>l.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:ur(e.bucketMs)})),gr=({shardKey:l=""})=>{const e=pe(),[s,a]=fe("15m"),t=Je(ze.getQueryInsights,{range:s},{live:!0,shardKey:l}).data,d=hr(t?.buckets??[]);return o("div",{className:"flex flex-col gap-4","data-testid":"qi-range",children:[o("div",{className:"flex flex-wrap items-center gap-2",children:[r("div",{className:"flex gap-1 rounded-lg border border-border p-0.5","data-testid":"qi-ranges",role:"group",children:mr.map(i=>r("button",{"aria-pressed":i===s,className:jt("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",i===s&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${i}`,onClick:()=>{a(i)},type:"button",children:i},i))}),t?.capped===!0&&r(et,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),d.length===0?r(Et,{description:e("Statements executed in the selected window appear here, with throughput and latency over time."),testId:"qi-empty",title:e("No queries in this window.")}):o("div",{className:"grid gap-4 lg:grid-cols-2",children:[o("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-throughput",children:[r("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Throughput")}),r(lt,{height:140,width:"100%",children:o(Ot,{data:d,children:[r(st,{strokeDasharray:"3 3",vertical:!1}),r(nt,{dataKey:"label",fontSize:10,tickLine:!1}),r(it,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),r(ot,{}),r(zt,{dataKey:"execs",fill:"var(--color-primary)",fillOpacity:.15,stroke:"var(--color-primary)",type:"monotone"})]})})]}),o("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-latency",children:[r("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Mean latency (ms)")}),r(lt,{height:140,width:"100%",children:o(At,{data:d,children:[r(st,{strokeDasharray:"3 3",vertical:!1}),r(nt,{dataKey:"label",fontSize:10,tickLine:!1}),r(it,{fontSize:10,tickLine:!1,width:32}),r(ot,{}),r(Kt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),r(ir,{queryStats:t?.entries??[]})]})},fr=kt(ze.getMetrics),pr=(l,e)=>l?e:"overview",Qr=({initialShardKey:l})=>{const e=pt(),s=pe(),a=xt(),{queryShardKey:t,setShardKey:d,shardKey:i}=Nt(l),[n,k]=fe("overview"),[f,S]=fe([]),p=We(null),u=We(null),h=We(!0);tt(()=>(h.current=!0,()=>{h.current=!1}),[]);const M=L=>{It({shardKey:t,traceId:L}),at(a({to:"/traces"}))},{data:b,error:$,liveError:_}=Je(ze.getMetrics,{},{live:!0,shardKey:t}),c=b??null;tt(()=>{if(b===void 0)return;Mt(t);const L=b,Q=p.current,O=u.current!==null&&u.current!==L.shard;if(u.current=L.shard,p.current=L.requests,O){S([]);return}Q!==null&&L.requests>=Q&&S(A=>[...A,L.requests-Q].slice(-30))},[b,t]);const[g,x]=fe(null),[w,q]=fe(!1),y=async()=>{q(!0);const L=Lt(i,_t());try{const Q=await Promise.all(L.map(async O=>{try{const A=await e.query(fr,{},wt(O));return{error:null,metrics:A,shard:O===""?A.shard:O}}catch(A){return{error:qt(A),metrics:null,shard:O===""?"__root__":O}}}));h.current&&x(Q)}finally{h.current&&q(!1)}},I=g===null?null:Dt(g),C=c===null||c.requests===0?"—":`${(c.errors/c.requests*100).toFixed(1)}%`,R=f.length>0?f.at(-1):0,D=c?Ft(c):{p90:0,p95:0},N=bt(()=>{if(!c||!("queryStats"in c))return;const L=c.queryStats;if(!(!L||!Array.isArray(L)))return Tt(L)},[c]),v=pr(N!==void 0,n),T=()=>{at(y())},z=()=>{x(null)},K=()=>{k("overview")},U=()=>{k("query-insights")};return o("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[o("div",{className:"flex flex-wrap items-center gap-2",children:[r(yt,{onChange:d,testId:"mt-shard-input",value:i}),r(vt,{message:_,prefix:"mt"}),r(rt,{"data-testid":"mt-aggregate",disabled:w,onClick:T,size:"sm",type:"button",variant:"secondary",children:s(w?"Aggregating…":"All shards")}),g!==null&&r(rt,{"data-testid":"mt-aggregate-clear",onClick:z,size:"sm",type:"button",variant:"ghost",children:s("Hide")}),r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:St,rel:"noreferrer",target:"_blank",children:s("Open in Cloudflare")})]}),$!==null&&r("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:$}),N!==void 0&&o("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[r("button",{className:`pb-2 text-sm font-medium transition-colors ${v==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:K,type:"button",children:s("Overview")}),o("button",{className:`pb-2 text-sm font-medium transition-colors ${v==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:U,type:"button",children:[s("Query insights"),N.length>0&&r("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:N.length})]})]}),v==="query-insights"&&N!==void 0&&r(gr,{shardKey:t}),v==="overview"&&c!==null&&r(lr,{currentDelta:R,errorRate:C,history:f,latencyPercentiles:D,metrics:c}),v==="overview"&&c===null&&null,v==="overview"&&r(er,{onOpenTrace:M,shardKey:t}),v==="overview"&&I!==null&&g!==null&&r(tr,{aggregate:I,shardResults:g})]})};export{Qr as MetricsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as
|
|
1
|
+
import{c as U}from"react/compiler-runtime";import{useState as T}from"react";import{U as W}from"../packem_shared/error-alert-_2q2VtVG.js";import{g as E}from"../packem_shared/badge-BbuuAio7.js";import{u as z}from"../packem_shared/button-BkCrNcAs.js";import{c as B,f as O}from"../packem_shared/card-BMKx5UdA.js";import{E as q}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as G}from"../packem_shared/input-JHu63lTv.js";import{d as J,n as K,f as F,m as h,b as Q,p as f}from"../packem_shared/table-DZAB8cs3.js";import{N as X}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{useT as Y}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as Z}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as ee}from"../packem_shared/internal-zkEvTqy8.js";import{jsx as t,jsxs as x}from"react/jsx-runtime";const te=e=>e==="ok"?"success":e==="failed"?"destructive":e==="expired"?"warning":"secondary",R=e=>e.endpoint??e.id,ve=()=>{const e=U(38),r=Y(),[i,V]=T("all"),[s,D]=T("");let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];const{data:S,error:o,errorSource:p,isLoading:C,refetch:v}=X(Z.listPushSubscriptions,g);let N;if(e[1]!==S?.subscriptions||e[2]!==o||e[3]!==p||e[4]!==C||e[5]!==i||e[6]!==v||e[7]!==s||e[8]!==r){const I=S?.subscriptions??[],j=s.trim().toLowerCase(),L=I.filter(a=>i!=="all"&&a.kind!==i?!1:j===""?!0:`${R(a)} ${a.userId??""}`.toLowerCase().includes(j));let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=a=>{D(a.target.value)},e[10]=b):b=e[10];const H=b;let w;e[11]!==v?(w=()=>{v()},e[11]=v,e[12]=w):w=e[12];const _=w;let y;e[13]===Symbol.for("react.memo_cache_sentinel")?(y=["all","web-push","fcm"],e[13]=y):y=e[13];const P=y;let l;e[14]!==i||e[15]!==r?(l=t("div",{className:"flex items-center gap-1","data-testid":"nt-kind-filter",role:"tablist",children:P.map(a=>t(z,{"aria-selected":i===a,"data-testid":`nt-kind-${a}`,onClick:()=>{V(a)},role:"tab",size:"sm",type:"button",variant:i===a?"secondary":"ghost",children:a==="all"?r("All"):a},a))}),e[14]=i,e[15]=r,e[16]=l):l=e[16];let n;e[17]!==r?(n=r("Filter devices"),e[17]=r,e[18]=n):n=e[18];let c;e[19]!==r?(c=r("filter endpoint, user"),e[19]=r,e[20]=c):c=e[20];let d;e[21]!==s||e[22]!==n||e[23]!==c?(d=t(G,{"aria-label":n,className:"h-8 w-56","data-testid":"nt-search",onChange:H,placeholder:c,value:s}),e[21]=s,e[22]=n,e[23]=c,e[24]=d):d=e[24];let m;e[25]!==r?(m=r("Refresh"),e[25]=r,e[26]=m):m=e[26];let u;e[27]!==_||e[28]!==m?(u=t(z,{className:"ml-auto","data-testid":"nt-refresh",onClick:_,size:"sm",type:"button",variant:"outline",children:m}),e[27]=_,e[28]=m,e[29]=u):u=e[29];const A=I.length>0&&t(E,{"data-testid":"nt-count",variant:"secondary",children:r("{count} devices",{count:I.length})});let $;e[30]!==u||e[31]!==A||e[32]!==l||e[33]!==d?($=x("div",{className:"flex flex-wrap items-center gap-2",children:[l,d,u,A]}),e[30]=u,e[31]=A,e[32]=l,e[33]=d,e[34]=$):$=e[34];let k;e[35]!==o||e[36]!==p?(k=o!==null&&t(W,{error:p,testId:"nt-error"}),e[35]=o,e[36]=p,e[37]=k):k=e[37],N=x("div",{className:"flex flex-col gap-4","data-testid":"lunora-notifications",children:[$,k,o===null&&!C&&L.length===0&&t(q,{description:r("Registered Web Push / FCM devices appear here. Configure lunora/notify.ts with defineNotify({ store }) and register a device with ctx.push.register(...)."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M15 17h5l-1.4-1.4A2 2 0 0 1 18 14.2V11a6 6 0 0 0-4-5.7V5a2 2 0 1 0-4 0v.3A6 6 0 0 0 6 11v3.2a2 2 0 0 1-.6 1.4L4 17h5m6 0v1a3 3 0 1 1-6 0v-1m6 0H9"})}),testId:"nt-empty",title:r("No registered devices.")}),L.length>0&&t(B,{className:"overflow-hidden py-0",children:t(O,{className:"max-h-[30rem] overflow-auto px-0",children:x(J,{"data-testid":"nt-table",children:[t(K,{children:x(F,{children:[t(h,{children:r("kind")}),t(h,{children:r("endpoint")}),t(h,{children:r("user")}),t(h,{children:r("last seen")}),t(h,{children:r("status")}),t(h,{children:r("error")})]})}),t(Q,{children:L.map(a=>{const M=R(a);return x(F,{"data-testid":"nt-row",children:[t(f,{children:t(E,{variant:"outline",children:a.kind})}),t(f,{className:"max-w-[28ch] truncate font-mono text-xs",title:M,children:M}),t(f,{className:"max-w-[16ch] truncate font-mono text-xs",children:a.userId??t("span",{className:"text-muted-foreground",children:"—"})}),t(f,{className:"text-muted-foreground tabular-nums",children:ee(a.lastSeenAt,"—")}),t(f,{children:t(E,{"data-testid":`nt-status-${a.id}`,variant:te(a.lastStatus),children:a.lastStatus??r("n/a")})}),t(f,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",title:a.lastError??void 0,children:a.lastError??t("span",{className:"text-muted-foreground",children:"—"})})]},a.id)})})]})})})]}),e[1]=S?.subscriptions,e[2]=o,e[3]=p,e[4]=C,e[5]=i,e[6]=v,e[7]=s,e[8]=r,e[9]=N}else N=e[9];return N};export{ve as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as Ce}from"react/compiler-runtime";import{ShardInput as Ze}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as Re,d as Oe}from"../packem_shared/storage-tier-DznqOf-q.js";import{g as Fe}from"../packem_shared/badge-BbuuAio7.js";import{f as Ke,m as Ge,n as Le,u as Me,c as De}from"../packem_shared/card-CIDGUN6K.js";import{E as He}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as Ie}from"../packem_shared/input-JHu63lTv.js";import{useT as je}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{d as Ae,b as Ee,f as fe,g as qe}from"../packem_shared/internal-zkEvTqy8.js";import{c as We}from"../packem_shared/utils-bhneXptQ.js";import{useLunora as Qe}from"@lunora/react";import{useState as $,useEffect as Pe,useRef as et}from"react";import{S as tt}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{ADMIN_FUNCTIONS as ze}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{r as lt}from"../packem_shared/shard-history-DMEW5VBE.js";import{S as at}from"../packem_shared/schema-diagram-DTRaCp6Y.js";import{useNavigate as nt}from"@tanstack/react-router";import{u as be}from"../packem_shared/button-BkCrNcAs.js";import{p as _e}from"../packem_shared/label-6uP1obNF.js";import{jsx as l,jsxs as g,Fragment as Ve}from"react/jsx-runtime";const st=qe(ze.listTables),rt=qe(ze.listTableIndexes),ot=qe(ze.readTablePage),it=qe(ze.describeTables),dt={},Be=[],ct=s=>{const e=Ce(74),{initialShardKey:m,initialTable:n}=s,t=Qe(),[a,c]=$("graph"),{queryShardKey:d,setShardKey:i,shardKey:f}=tt(m),[r,h]=$(""),[o,x]=$(null),[p,P]=$(null);let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S={},e[0]=S):S=e[0];const[L,v]=$(S);let K;e[1]===Symbol.for("react.memo_cache_sentinel")?(K={},e[1]=K):K=e[1];const[F,M]=$(K),[w,N]=$(null);let A;e[2]===Symbol.for("react.memo_cache_sentinel")?(A={},e[2]=A):A=e[2];const[j,me]=$(A);let Z;e[3]===Symbol.for("react.memo_cache_sentinel")?(Z={},e[3]=Z):Z=e[3];const[k,G]=$(Z),[_,ue]=$(null),[D,oe]=$(null);let H;e[4]===Symbol.for("react.memo_cache_sentinel")?(H={},e[4]=H):H=e[4];const[X,xe]=$(H),[Y,ie]=$(null);let ve;e[5]!==t?(ve=async u=>{P(null);try{const C=await t.query(st,{},Ae(u));lt(u),x(C),v({}),M({}),N(null),me(y=>Object.fromEntries(Object.entries(y).filter(O=>{const[I]=O;return I!==u}))),G(y=>Object.fromEntries(Object.entries(y).filter(O=>{const[I]=O;return I!==u})))}catch(C){const y=C;x(null),P(Ee(y))}},e[5]=t,e[6]=ve):ve=e[6];const q=ve;let Q;e[7]!==t?(Q=async()=>{oe(null);try{ue(await t.listGlobalTables())}catch(u){const C=u;ue(null),oe(Ee(C))}},e[7]=t,e[8]=Q):Q=e[8];const ee=Q;let de,R;e[9]!==d||e[10]!==q||e[11]!==ee?(de=()=>{fe(q(d)),fe(ee())},R=[q,ee,d],e[9]=d,e[10]=q,e[11]=ee,e[12]=de,e[13]=R):(de=e[12],R=e[13]),Pe(de,R);let te;e[14]!==t||e[15]!==L||e[16]!==w||e[17]!==d?(te=async u=>{if(w===u){N(null);return}N(u);const C=`${d}:${u}`;if(L[C]!==void 0)return;const[y,O]=await Promise.allSettled([t.query(ot,{limit:1,offset:0,table:u},Ae(d)),t.query(rt,{table:u},Ae(d))]);y.status==="fulfilled"?v(I=>({...I,[C]:y.value.columns})):P(Ee(y.reason)),O.status==="fulfilled"&&M(I=>({...I,[C]:O.value.indexes}))},e[14]=t,e[15]=L,e[16]=w,e[17]=d,e[18]=te):te=e[18];const z=te;let ye;e[19]!==t||e[20]!==X||e[21]!==Y?(ye=async u=>{if(Y===u){ie(null);return}if(ie(u),X[u]===void 0)try{const C=await t.readGlobalTablePage({limit:1,offset:0,table:u});xe(y=>({...y,[u]:C.columns}))}catch(C){oe(Ee(C))}},e[19]=t,e[20]=X,e[21]=Y,e[22]=ye):ye=e[22];const ce=ye,he=et(void 0);let V,J;e[23]!==n||e[24]!==o||e[25]!==z?(V=()=>{n===void 0||o===null||he.current===n||o.some(u=>u.name===n)&&(he.current=n,fe(z(n)))},J=[n,o,z],e[23]=n,e[24]=o,e[25]=z,e[26]=V,e[27]=J):(V=e[26],J=e[27]),Pe(V,J);let B;e[28]!==t?(B=async(u,C,y)=>{const[O,I]=await Promise.all([Promise.allSettled([t.query(it,{tables:[...C,...y]},Ae(u))]),Promise.all(y.map(async T=>{const ge=await Promise.allSettled([t.readGlobalTablePage({limit:1,offset:0,table:T})]),ke=ge[0].status==="fulfilled"?ge[0].value:void 0;return{columns:ke?.columns??[],refs:ke?.refs??{},table:T}}))]),Te=O[0].status==="fulfilled"?O[0].value?.columnsByTable??{}:{},we=O[0].status==="rejected",Se=new Map(I.map(mt)),$e=[...C,...y].map(T=>{const ge=Te[T]??[];return[T,ge.length>0?ge:Se.get(T)??[]]});me(T=>({...T,[u]:Object.fromEntries($e)})),G(T=>({...T,[u]:we}))},e[28]=t,e[29]=B):B=e[29];const le=B;let U,ae;e[30]!==D||e[31]!==_||e[32]!==le||e[33]!==d||e[34]!==j||e[35]!==o||e[36]!==a?(U=()=>{a!=="graph"||o===null||_===null&&D===null||j[d]!==void 0||fe(le(d,o.map(ut),(_??[]).map(ht)))},ae=[a,o,_,D,d,j,le],e[30]=D,e[31]=_,e[32]=le,e[33]=d,e[34]=j,e[35]=o,e[36]=a,e[37]=U,e[38]=ae):(U=e[37],ae=e[38]),Pe(U,ae);const E=j[d]??dt;let ne;if(e[39]!==E||e[40]!==_||e[41]!==o){let u;e[43]!==E?(u=I=>({columns:E[I.name]??Be,name:I.name,tier:"shard"}),e[43]=E,e[44]=u):u=e[44];const C=(o??[]).map(u);let y;e[45]!==E?(y=I=>({columns:E[I.name]??Be,name:I.name,tier:"global"}),e[45]=E,e[46]=y):y=e[46];const O=(_??[]).map(y);ne=[...C,...O],e[39]=E,e[40]=_,e[41]=o,e[42]=ne}else ne=e[42];const se=ne;let b;if(e[47]!==r||e[48]!==o){const u=r.trim().toLowerCase();b=(o??[]).filter(C=>C.name.toLowerCase().includes(u)),e[47]=r,e[48]=o,e[49]=b}else b=e[49];const re=b;let W;if(e[50]!==_||e[51]!==r){const u=r.trim().toLowerCase();W=(_??[]).filter(C=>C.name.toLowerCase().includes(u)),e[50]=_,e[51]=r,e[52]=W}else W=e[52];const Ne=W;let pe;return e[53]!==L||e[54]!==se||e[55]!==p||e[56]!==w||e[57]!==Ne||e[58]!==re||e[59]!==X||e[60]!==D||e[61]!==Y||e[62]!==_||e[63]!==F||e[64]!==q||e[65]!==i||e[66]!==k||e[67]!==f||e[68]!==r||e[69]!==o||e[70]!==z||e[71]!==ce||e[72]!==a?(pe={columns:L,diagramTables:se,error:p,expanded:w,filteredGlobalTables:Ne,filteredTables:re,globalColumns:X,globalError:D,globalExpanded:Y,globalTables:_,indexes:F,refresh:q,setShardKey:i,setTableFilter:h,setView:c,shardColumnsError:k,shardKey:f,tableFilter:r,tables:o,toggle:z,toggleGlobal:ce,view:a},e[53]=L,e[54]=se,e[55]=p,e[56]=w,e[57]=Ne,e[58]=re,e[59]=X,e[60]=D,e[61]=Y,e[62]=_,e[63]=F,e[64]=q,e[65]=i,e[66]=k,e[67]=f,e[68]=r,e[69]=o,e[70]=z,e[71]=ce,e[72]=a,e[73]=pe):pe=e[73],pe};function mt(s){const{columns:e,refs:m,table:n}=s;return[n,e.map(t=>{const a=m[t];return a===void 0?{name:t,optional:!1,type:""}:{name:t,optional:!1,ref:a,type:"id"}})]}function ut(s){return s.name}function ht(s){return s.name}const pt="/__lunora/schema-edit",gt=async s=>{const e=await fetch(pt,{body:JSON.stringify(s),headers:{"Content-Type":"application/json","X-Lunora-Studio":"1"},method:"POST"}),m=await e.json();return m.needsMigration===!0?{kind:"needs-migration",message:m.message??"This edit needs a migration."}:e.ok&&m.tables!==void 0?{diagnostics:m.diagnostics??[],kind:"ok",tables:m.tables}:{kind:"error",message:m.error??`schema edit failed (${String(e.status)})`}},bt=s=>{const e=Ce(32),{hasTables:m,mode:n,onAddColumn:t,onAddIndex:a,onAddTable:c,onDestructive:d}=s,i=je(),f=n==="addTable"?"default":"outline";let r;e[0]!==i?(r=i("Add table"),e[0]=i,e[1]=r):r=e[1];let h;e[2]!==c||e[3]!==f||e[4]!==r?(h=l(be,{"data-testid":"sc-editor-add-table",onClick:c,size:"xs",type:"button",variant:f,children:r}),e[2]=c,e[3]=f,e[4]=r,e[5]=h):h=e[5];const o=!m,x=n==="addColumn"?"default":"outline";let p;e[6]!==i?(p=i("Add column"),e[6]=i,e[7]=p):p=e[7];let P;e[8]!==t||e[9]!==o||e[10]!==x||e[11]!==p?(P=l(be,{"data-testid":"sc-editor-add-column",disabled:o,onClick:t,size:"xs",type:"button",variant:x,children:p}),e[8]=t,e[9]=o,e[10]=x,e[11]=p,e[12]=P):P=e[12];const S=!m,L=n==="addIndex"?"default":"outline";let v;e[13]!==i?(v=i("Add index"),e[13]=i,e[14]=v):v=e[14];let K;e[15]!==a||e[16]!==v||e[17]!==S||e[18]!==L?(K=l(be,{"data-testid":"sc-editor-add-index",disabled:S,onClick:a,size:"xs",type:"button",variant:L,children:v}),e[15]=a,e[16]=v,e[17]=S,e[18]=L,e[19]=K):K=e[19];const F=!m,M=n==="destructive"?"default":"ghost";let w;e[20]!==i?(w=i("Rename / drop / change type…"),e[20]=i,e[21]=w):w=e[21];let N;e[22]!==d||e[23]!==F||e[24]!==M||e[25]!==w?(N=l(be,{"data-testid":"sc-editor-destructive",disabled:F,onClick:d,size:"xs",type:"button",variant:M,children:w}),e[22]=d,e[23]=F,e[24]=M,e[25]=w,e[26]=N):N=e[26];let A;return e[27]!==K||e[28]!==N||e[29]!==h||e[30]!==P?(A=g("div",{className:"flex flex-wrap gap-2",children:[h,P,K,N]}),e[27]=K,e[28]=N,e[29]=h,e[30]=P,e[31]=A):A=e[31],A},ft=s=>{const e=Ce(28),{onOpenMigrations:m,result:n}=s,t=je();if(n===null){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=l(Ve,{}),e[0]=r):r=e[0],r}if(n.kind==="error"){let r;return e[1]!==n.message?(r=l("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:n.message}),e[1]=n.message,e[2]=r):r=e[2],r}if(n.kind==="needs-migration"){let r;e[3]!==n.message||e[4]!==t?(r=n.message===""?t("This edit changes stored data and must go through a migration. Review the migration before applying."):n.message,e[3]=n.message,e[4]=t,e[5]=r):r=e[5];let h;e[6]!==r?(h=l("p",{className:"text-sm text-warning",role:"alert",children:r}),e[6]=r,e[7]=h):h=e[7];let o;e[8]!==t?(o=t("Open Migrations"),e[8]=t,e[9]=o):o=e[9];let x;e[10]!==m||e[11]!==o?(x=l(be,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:m,size:"xs",type:"button",variant:"outline",children:o}),e[10]=m,e[11]=o,e[12]=x):x=e[12];let p;return e[13]!==h||e[14]!==x?(p=g("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[h,x]}),e[13]=h,e[14]=x,e[15]=p):p=e[15],p}if(n.diagnostics.length===0){let r;return e[16]===Symbol.for("react.memo_cache_sentinel")?(r=l(Ve,{}),e[16]=r):r=e[16],r}let a;e[17]!==t?(a=t("Codegen reported diagnostics:"),e[17]=t,e[18]=a):a=e[18];let c;e[19]!==a?(c=l("p",{className:"text-sm text-destructive",role:"alert",children:a}),e[19]=a,e[20]=c):c=e[20];let d;e[21]!==n.diagnostics?(d=n.diagnostics.map(xt),e[21]=n.diagnostics,e[22]=d):d=e[22];let i;e[23]!==d?(i=l("ul",{className:"flex flex-col gap-0.5",children:d}),e[23]=d,e[24]=i):i=e[24];let f;return e[25]!==c||e[26]!==i?(f=g("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[c,i]}),e[25]=c,e[26]=i,e[27]=f):f=e[27],f};function xt(s){return l("li",{className:"font-mono text-[11px] text-destructive",children:s},s)}const vt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.int64()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],yt="v.string()",Nt=s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),Ct=s=>{const e=Ce(83),{onApplied:m,tableNames:n}=s,t=je(),a=nt(),[c,d]=$(null),[i,f]=$(!1),[r,h]=$(null),[o,x]=$(""),[p,P]=$(""),[S,L]=$(yt),[v,K]=$(n[0]??""),[F,M]=$(""),[w,N]=$(""),[A,j]=$(!1);let me;e[0]===Symbol.for("react.memo_cache_sentinel")?(me=()=>{d(null),x(""),P(""),M(""),N(""),j(!1)},e[0]=me):me=e[0];const Z=me;let k;e[1]!==m?(k=async T=>{f(!0),h(null);try{const ge=await gt(T);h(ge),ge.kind==="ok"&&(m(ge.tables),Z())}catch(ge){const ke=ge;h({kind:"error",message:ke instanceof Error?ke.message:String(ke)})}f(!1)},e[1]=m,e[2]=k):k=e[2];const G=k;let _;e[3]!==G||e[4]!==o?(_=()=>{fe(G({kind:"addTable",table:o.trim()}))},e[3]=G,e[4]=o,e[5]=_):_=e[5];const ue=_;let D;e[6]!==p||e[7]!==G||e[8]!==v||e[9]!==S?(D=()=>{fe(G({column:p.trim(),kind:"addOptionalColumn",table:v,validator:S}))},e[6]=p,e[7]=G,e[8]=v,e[9]=S,e[10]=D):D=e[10];const oe=D;let H;e[11]!==w||e[12]!==F||e[13]!==G||e[14]!==v||e[15]!==A?(H=()=>{fe(G({fields:Nt(w),kind:"addIndex",name:F.trim(),table:v,unique:A}))},e[11]=w,e[12]=F,e[13]=G,e[14]=v,e[15]=A,e[16]=H):H=e[16];const X=H;let xe;e[17]===Symbol.for("react.memo_cache_sentinel")?(xe=()=>{h(null),d("addTable")},e[17]=xe):xe=e[17];const Y=xe;let ie;e[18]===Symbol.for("react.memo_cache_sentinel")?(ie=()=>{h(null),d("addColumn")},e[18]=ie):ie=e[18];const ve=ie;let q;e[19]===Symbol.for("react.memo_cache_sentinel")?(q=()=>{h(null),d("addIndex")},e[19]=q):q=e[19];const Q=q;let ee;e[20]!==t?(ee=()=>{d("destructive"),h({kind:"needs-migration",message:t("This edit changes stored data and must go through a migration. Review the migration before applying.")})},e[20]=t,e[21]=ee):ee=e[21];const de=ee;let R;e[22]===Symbol.for("react.memo_cache_sentinel")?(R=T=>{x(T.target.value)},e[22]=R):R=e[22];const te=R;let z;e[23]===Symbol.for("react.memo_cache_sentinel")?(z=T=>{P(T.target.value)},e[23]=z):z=e[23];const ye=z;let ce;e[24]===Symbol.for("react.memo_cache_sentinel")?(ce=T=>{L(T.target.value)},e[24]=ce):ce=e[24];const he=ce;let V;e[25]===Symbol.for("react.memo_cache_sentinel")?(V=T=>{K(T.target.value)},e[25]=V):V=e[25];const J=V;let B;e[26]===Symbol.for("react.memo_cache_sentinel")?(B=T=>{M(T.target.value)},e[26]=B):B=e[26];const le=B;let U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=T=>{N(T.target.value)},e[27]=U):U=e[27];const ae=U;let E;e[28]===Symbol.for("react.memo_cache_sentinel")?(E=T=>{j(T.target.checked)},e[28]=E):E=e[28];const ne=E;let se;e[29]!==a?(se=()=>{fe(a({to:"/migrations"}))},e[29]=a,e[30]=se):se=e[30];const b=se;let re;e[31]!==t?(re=t("Edit schema"),e[31]=t,e[32]=re):re=e[32];let W;e[33]!==re?(W=l(Ke,{children:re}),e[33]=re,e[34]=W):W=e[34];let Ne;e[35]!==t?(Ne=t("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=t,e[36]=Ne):Ne=e[36];let pe;e[37]!==Ne?(pe=l(Ge,{children:Ne}),e[37]=Ne,e[38]=pe):pe=e[38];let u;e[39]!==W||e[40]!==pe?(u=g(Le,{children:[W,pe]}),e[39]=W,e[40]=pe,e[41]=u):u=e[41];const C=n.length>0;let y;e[42]!==c||e[43]!==de||e[44]!==C?(y=l(bt,{hasTables:C,mode:c,onAddColumn:ve,onAddIndex:Q,onAddTable:Y,onDestructive:de}),e[42]=c,e[43]=de,e[44]=C,e[45]=y):y=e[45];let O;e[46]!==i||e[47]!==c||e[48]!==ue||e[49]!==t||e[50]!==o?(O=c==="addTable"&&g("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[g("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-table-name",children:t("Table name")}),l(Ie,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:te,value:o})]}),l(be,{"data-testid":"sc-editor-table-apply",disabled:i||o.trim()==="",onClick:ue,size:"xs",type:"button",children:t(i?"Applying…":"Apply")}),l(be,{onClick:Z,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[46]=i,e[47]=c,e[48]=ue,e[49]=t,e[50]=o,e[51]=O):O=e[51];let I;e[52]!==i||e[53]!==p||e[54]!==c||e[55]!==oe||e[56]!==t||e[57]!==n||e[58]!==v||e[59]!==S?(I=c==="addColumn"&&g("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[g("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-column-table",children:t("Table name")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:J,value:v,children:n.map(Tt)})]}),g("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-column-name",children:t("Column name")}),l(Ie,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:ye,value:p})]}),g("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-column-type",children:t("Column type")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:he,value:S,children:vt.map(wt)})]}),l("span",{className:"text-[11px] text-muted-foreground",children:t("Optional")}),l(be,{"data-testid":"sc-editor-column-apply",disabled:i||p.trim()===""||v==="",onClick:oe,size:"xs",type:"button",children:t(i?"Applying…":"Apply")}),l(be,{onClick:Z,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[52]=i,e[53]=p,e[54]=c,e[55]=oe,e[56]=t,e[57]=n,e[58]=v,e[59]=S,e[60]=I):I=e[60];let Te;e[61]!==i||e[62]!==w||e[63]!==F||e[64]!==c||e[65]!==X||e[66]!==t||e[67]!==n||e[68]!==v||e[69]!==A?(Te=c==="addIndex"&&g("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[g("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-index-table",children:t("Table name")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:J,value:v,children:n.map(St)})]}),g("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-index-name",children:t("Index name")}),l(Ie,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:le,value:F})]}),g("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-index-fields",children:t("Index fields (comma-separated)")}),l(Ie,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:ae,value:w})]}),g(_e,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[l("input",{checked:A,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:ne,type:"checkbox"}),l("span",{className:"text-muted-foreground",children:t("Unique")})]}),l(be,{"data-testid":"sc-editor-index-apply",disabled:i||F.trim()===""||w.trim()==="",onClick:X,size:"xs",type:"button",children:t(i?"Applying…":"Apply")}),l(be,{onClick:Z,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[61]=i,e[62]=w,e[63]=F,e[64]=c,e[65]=X,e[66]=t,e[67]=n,e[68]=v,e[69]=A,e[70]=Te):Te=e[70];let we;e[71]!==b||e[72]!==r?(we=l(ft,{onOpenMigrations:b,result:r}),e[71]=b,e[72]=r,e[73]=we):we=e[73];let Se;e[74]!==y||e[75]!==O||e[76]!==I||e[77]!==Te||e[78]!==we?(Se=g(Me,{children:[y,O,I,Te,we]}),e[74]=y,e[75]=O,e[76]=I,e[77]=Te,e[78]=we,e[79]=Se):Se=e[79];let $e;return e[80]!==u||e[81]!==Se?($e=g(De,{"data-testid":"sc-editor",size:"sm",children:[u,Se]}),e[80]=u,e[81]=Se,e[82]=$e):$e=e[82],$e};function Tt(s){return l("option",{value:s,children:s},s)}function wt(s){return l("option",{value:s.validator,children:s.label},s.validator)}function St(s){return l("option",{value:s,children:s},s)}const Ue=[],_t=s=>{const e=Ce(5),{open:m}=s,n=m&&"rotate-90";let t;e[0]!==n?(t=We("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",n),e[0]=n,e[1]=t):t=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=l("path",{d:"m9 6 6 6-6 6"}),e[2]=a):a=e[2];let c;return e[3]!==t?(c=l("svg",{"aria-hidden":"true",className:t,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:a}),e[3]=t,e[4]=c):c=e[4],c},Xe=s=>{const e=Ce(20),{children:m,expanded:n,name:t,onToggle:a,rowCount:c,rowTestId:d,toggleTestId:i}=s;let f;e[0]!==n?(f=l(_t,{open:n}),e[0]=n,e[1]=f):f=e[1];let r;e[2]!==t?(r=l("span",{className:"truncate font-mono text-xs text-foreground",title:t,children:t}),e[2]=t,e[3]=r):r=e[3];let h;e[4]!==c?(h=g("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",c,")"]}),e[4]=c,e[5]=h):h=e[5];let o;e[6]!==n||e[7]!==a||e[8]!==f||e[9]!==r||e[10]!==h||e[11]!==i?(o=g("button",{"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":i,onClick:a,type:"button",children:[f,r," ",h]}),e[6]=n,e[7]=a,e[8]=f,e[9]=r,e[10]=h,e[11]=i,e[12]=o):o=e[12];let x;e[13]!==m||e[14]!==n?(x=n&&l("div",{className:"px-3 pb-3 ps-8",children:m}),e[13]=m,e[14]=n,e[15]=x):x=e[15];let p;return e[16]!==d||e[17]!==o||e[18]!==x?(p=g("li",{className:"border-t border-border/60 first:border-t-0","data-testid":d,children:[o,x]}),e[16]=d,e[17]=o,e[18]=x,e[19]=p):p=e[19],p},Ye=s=>{const e=Ce(5),{columns:m,testId:n}=s;let t;e[0]!==m?(t=m.map(kt),e[0]=m,e[1]=t):t=e[1];let a;return e[2]!==t||e[3]!==n?(a=l("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":n,children:t}),e[2]=t,e[3]=n,e[4]=a):a=e[4],a},$t=s=>{const e=Ce(10),{heading:m,indexes:n,testId:t}=s;let a;e[0]!==m?(a=l("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:m}),e[0]=m,e[1]=a):a=e[1];let c;e[2]!==n?(c=n.map(It),e[2]=n,e[3]=c):c=e[3];let d;e[4]!==c||e[5]!==t?(d=l("ul",{className:"flex flex-col gap-1","data-testid":t,children:c}),e[4]=c,e[5]=t,e[6]=d):d=e[6];let i;return e[7]!==a||e[8]!==d?(i=g("div",{className:"pt-3",children:[a,d]}),e[7]=a,e[8]=d,e[9]=i):i=e[9],i},Je=s=>We("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",s?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),Zt=s=>{const e=Ce(85),{initialShardKey:m,initialTable:n,schemaEditable:t}=s,a=je();let c;e[0]!==m||e[1]!==n?(c={initialShardKey:m,initialTable:n},e[0]=m,e[1]=n,e[2]=c):c=e[2];const{columns:d,diagramTables:i,error:f,expanded:r,filteredGlobalTables:h,filteredTables:o,globalColumns:x,globalError:p,globalExpanded:P,globalTables:S,indexes:L,refresh:v,setShardKey:K,setTableFilter:F,setView:M,shardColumnsError:w,shardKey:N,tableFilter:A,tables:j,toggle:me,toggleGlobal:Z,view:k}=ct(c);let G;e[3]!==M?(G=()=>{M("list")},e[3]=M,e[4]=G):G=e[4];const _=G;let ue;e[5]!==M?(ue=()=>{M("graph")},e[5]=M,e[6]=ue):ue=e[6];const D=ue;let oe;e[7]!==F?(oe=b=>{F(b.target.value)},e[7]=F,e[8]=oe):oe=e[8];const H=oe;let X;e[9]!==v||e[10]!==N?(X=b=>{fe(v(N))},e[9]=v,e[10]=N,e[11]=X):X=e[11];const xe=X;let Y;e[12]!==j?(Y=j??[],e[12]=j,e[13]=Y):Y=e[13];let ie;e[14]!==Y?(ie=Y.map(At),e[14]=Y,e[15]=ie):ie=e[15];const ve=ie;let q;e[16]!==K||e[17]!==N?(q=l(Ze,{onChange:K,testId:"sc-shard-input",value:N}),e[16]=K,e[17]=N,e[18]=q):q=e[18];let Q;e[19]!==a?(Q=a("Schema view"),e[19]=a,e[20]=Q):Q=e[20];const ee=k==="graph",de=k==="graph";let R;e[21]!==de?(R=Je(de),e[21]=de,e[22]=R):R=e[22];let te;e[23]!==a?(te=a("Graph"),e[23]=a,e[24]=te):te=e[24];let z;e[25]!==D||e[26]!==ee||e[27]!==R||e[28]!==te?(z=l("button",{"aria-selected":ee,className:R,"data-testid":"sc-view-graph",onClick:D,role:"tab",type:"button",children:te}),e[25]=D,e[26]=ee,e[27]=R,e[28]=te,e[29]=z):z=e[29];const ye=k==="list",ce=k==="list";let he;e[30]!==ce?(he=Je(ce),e[30]=ce,e[31]=he):he=e[31];let V;e[32]!==a?(V=a("Table list"),e[32]=a,e[33]=V):V=e[33];let J;e[34]!==_||e[35]!==ye||e[36]!==he||e[37]!==V?(J=l("button",{"aria-selected":ye,className:he,"data-testid":"sc-view-list",onClick:_,role:"tab",type:"button",children:V}),e[34]=_,e[35]=ye,e[36]=he,e[37]=V,e[38]=J):J=e[38];let B;e[39]!==z||e[40]!==J||e[41]!==Q?(B=g("div",{"aria-label":Q,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[z,J]}),e[39]=z,e[40]=J,e[41]=Q,e[42]=B):B=e[42];let le;e[43]!==B||e[44]!==q?(le=g("div",{className:"flex flex-wrap items-center gap-3",children:[q,B]}),e[43]=B,e[44]=q,e[45]=le):le=e[45];let U;e[46]!==xe||e[47]!==t||e[48]!==ve?(U=t===!0&&l(Ct,{onApplied:xe,tableNames:ve}),e[46]=xe,e[47]=t,e[48]=ve,e[49]=U):U=e[49];let ae;e[50]!==H||e[51]!==a||e[52]!==A||e[53]!==k?(ae=k==="list"&&l(Ie,{"aria-label":a("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:H,placeholder:a("Filter tables"),value:A}),e[50]=H,e[51]=a,e[52]=A,e[53]=k,e[54]=ae):ae=e[54];let E;e[55]!==i||e[56]!==f||e[57]!==p||e[58]!==w||e[59]!==N||e[60]!==k?(E=k==="graph"&&g("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[f!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:f}),p!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),l(at,{columnsError:w[N]===!0,tables:i,testIdPrefix:"sc-graph"})]}),e[55]=i,e[56]=f,e[57]=p,e[58]=w,e[59]=N,e[60]=k,e[61]=E):E=e[61];let ne;e[62]!==d||e[63]!==f||e[64]!==r||e[65]!==h||e[66]!==o||e[67]!==x||e[68]!==p||e[69]!==P||e[70]!==S||e[71]!==L||e[72]!==N||e[73]!==a||e[74]!==j||e[75]!==me||e[76]!==Z||e[77]!==k?(ne=k==="list"&&g("div",{className:"flex flex-col gap-4",children:[g(De,{"data-testid":"sc-shard-section",size:"sm",children:[g(Le,{children:[g("div",{className:"flex items-center gap-2",children:[l(Re,{tier:"shard"}),l(Ke,{children:a("Shard tables")}),j!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:o.length})]}),l(Ge,{children:Oe.shard.hint})]}),g(Me,{children:[f!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:f}),j!==null&&j.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:a("No tables in this shard.")}),j!==null&&j.length>0&&o.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:a("No tables match your filter.")}),o.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:o.map(b=>{const re=`${N}:${b.name}`,W=L[re]??[];return g(Xe,{expanded:r===b.name,name:b.name,onToggle:()=>{fe(me(b.name))},rowCount:b.rowCount,rowTestId:`sc-table-${b.name}`,toggleTestId:`sc-toggle-${b.name}`,children:[l(Ye,{columns:d[re]??Ue,testId:`sc-columns-${b.name}`}),W.length>0&&l($t,{heading:a("Indexes"),indexes:W,testId:`sc-indexes-${b.name}`})]},b.name)})})]})]}),g(De,{"data-testid":"sc-global-section",size:"sm",children:[g(Le,{children:[g("div",{className:"flex items-center gap-2",children:[l(Re,{tier:"global"}),l(Ke,{children:a("Global tables (D1)")}),S!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:h.length})]}),l(Ge,{children:Oe.global.hint})]}),g(Me,{children:[p!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),S!==null&&S.length===0&&l(He,{description:Oe.global.hint,testId:"sc-global-empty",title:a("No global tables.")}),S!==null&&S.length>0&&h.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:a("No tables match your filter.")}),h.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:h.map(b=>l(Xe,{expanded:P===b.name,name:b.name,onToggle:()=>{fe(Z(b.name))},rowCount:b.rowCount,rowTestId:`sc-global-table-${b.name}`,toggleTestId:`sc-global-toggle-${b.name}`,children:l(Ye,{columns:x[b.name]??Ue,testId:`sc-global-columns-${b.name}`})},b.name))})]})]})]}),e[62]=d,e[63]=f,e[64]=r,e[65]=h,e[66]=o,e[67]=x,e[68]=p,e[69]=P,e[70]=S,e[71]=L,e[72]=N,e[73]=a,e[74]=j,e[75]=me,e[76]=Z,e[77]=k,e[78]=ne):ne=e[78];let se;return e[79]!==le||e[80]!==U||e[81]!==ae||e[82]!==E||e[83]!==ne?(se=g("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[le,U,ae,E,ne]}),e[79]=le,e[80]=U,e[81]=ae,e[82]=E,e[83]=ne,e[84]=se):se=e[84],se};function kt(s){return l("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:s},s)}function It(s){return g("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[l("span",{className:"font-mono",children:s.name}),l(Fe,{variant:"outline",children:s.type}),s.unique===!0&&l(Fe,{variant:"secondary",children:"unique"}),l("span",{className:"text-muted-foreground",children:s.fields.join(", ")})]},`${s.type}:${s.name}`)}function At(s){return s.name}export{Zt as SchemaViewer};
|
|
1
|
+
import{c as Ce}from"react/compiler-runtime";import{ShardInput as Ze}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as Re,d as Oe}from"../packem_shared/storage-tier-DznqOf-q.js";import{g as Fe}from"../packem_shared/badge-BbuuAio7.js";import{m as Ke,p as Ge,n as Le,f as Me,c as De}from"../packem_shared/card-BMKx5UdA.js";import{E as He}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as Ie}from"../packem_shared/input-JHu63lTv.js";import{useT as je}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{d as Ae,b as Ee,f as fe,g as qe}from"../packem_shared/internal-zkEvTqy8.js";import{c as We}from"../packem_shared/utils-bhneXptQ.js";import{useLunora as Qe}from"@lunora/react";import{useState as _,useEffect as Pe,useRef as et}from"react";import{S as tt}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{ADMIN_FUNCTIONS as ze}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{r as lt}from"../packem_shared/shard-history-DMEW5VBE.js";import{S as at}from"../packem_shared/schema-diagram-GVgnLWTf.js";import{useNavigate as nt}from"@tanstack/react-router";import{u as be}from"../packem_shared/button-BkCrNcAs.js";import{p as $e}from"../packem_shared/label-6uP1obNF.js";import{jsx as l,jsxs as g,Fragment as Ve}from"react/jsx-runtime";const st=qe(ze.listTables),rt=qe(ze.listTableIndexes),ot=qe(ze.readTablePage),it=qe(ze.describeTables),dt={},Be=[],ct=s=>{const e=Ce(74),{initialShardKey:m,initialTable:n}=s,t=Qe(),[a,c]=_("graph"),{queryShardKey:d,setShardKey:i,shardKey:f}=tt(m),[r,h]=_(""),[o,x]=_(null),[p,P]=_(null);let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S={},e[0]=S):S=e[0];const[L,v]=_(S);let K;e[1]===Symbol.for("react.memo_cache_sentinel")?(K={},e[1]=K):K=e[1];const[F,M]=_(K),[w,N]=_(null);let A;e[2]===Symbol.for("react.memo_cache_sentinel")?(A={},e[2]=A):A=e[2];const[j,me]=_(A);let Z;e[3]===Symbol.for("react.memo_cache_sentinel")?(Z={},e[3]=Z):Z=e[3];const[k,G]=_(Z),[$,ue]=_(null),[D,oe]=_(null);let H;e[4]===Symbol.for("react.memo_cache_sentinel")?(H={},e[4]=H):H=e[4];const[X,xe]=_(H),[Y,ie]=_(null);let ve;e[5]!==t?(ve=async u=>{P(null);try{const C=await t.query(st,{},Ae(u));lt(u),x(C),v({}),M({}),N(null),me(y=>Object.fromEntries(Object.entries(y).filter(O=>{const[I]=O;return I!==u}))),G(y=>Object.fromEntries(Object.entries(y).filter(O=>{const[I]=O;return I!==u})))}catch(C){const y=C;x(null),P(Ee(y))}},e[5]=t,e[6]=ve):ve=e[6];const q=ve;let Q;e[7]!==t?(Q=async()=>{oe(null);try{ue(await t.listGlobalTables())}catch(u){const C=u;ue(null),oe(Ee(C))}},e[7]=t,e[8]=Q):Q=e[8];const ee=Q;let de,R;e[9]!==d||e[10]!==q||e[11]!==ee?(de=()=>{fe(q(d)),fe(ee())},R=[q,ee,d],e[9]=d,e[10]=q,e[11]=ee,e[12]=de,e[13]=R):(de=e[12],R=e[13]),Pe(de,R);let te;e[14]!==t||e[15]!==L||e[16]!==w||e[17]!==d?(te=async u=>{if(w===u){N(null);return}N(u);const C=`${d}:${u}`;if(L[C]!==void 0)return;const[y,O]=await Promise.allSettled([t.query(ot,{limit:1,offset:0,table:u},Ae(d)),t.query(rt,{table:u},Ae(d))]);y.status==="fulfilled"?v(I=>({...I,[C]:y.value.columns})):P(Ee(y.reason)),O.status==="fulfilled"&&M(I=>({...I,[C]:O.value.indexes}))},e[14]=t,e[15]=L,e[16]=w,e[17]=d,e[18]=te):te=e[18];const z=te;let ye;e[19]!==t||e[20]!==X||e[21]!==Y?(ye=async u=>{if(Y===u){ie(null);return}if(ie(u),X[u]===void 0)try{const C=await t.readGlobalTablePage({limit:1,offset:0,table:u});xe(y=>({...y,[u]:C.columns}))}catch(C){oe(Ee(C))}},e[19]=t,e[20]=X,e[21]=Y,e[22]=ye):ye=e[22];const ce=ye,he=et(void 0);let V,J;e[23]!==n||e[24]!==o||e[25]!==z?(V=()=>{n===void 0||o===null||he.current===n||o.some(u=>u.name===n)&&(he.current=n,fe(z(n)))},J=[n,o,z],e[23]=n,e[24]=o,e[25]=z,e[26]=V,e[27]=J):(V=e[26],J=e[27]),Pe(V,J);let B;e[28]!==t?(B=async(u,C,y)=>{const[O,I]=await Promise.all([Promise.allSettled([t.query(it,{tables:[...C,...y]},Ae(u))]),Promise.all(y.map(async T=>{const ge=await Promise.allSettled([t.readGlobalTablePage({limit:1,offset:0,table:T})]),ke=ge[0].status==="fulfilled"?ge[0].value:void 0;return{columns:ke?.columns??[],refs:ke?.refs??{},table:T}}))]),Te=O[0].status==="fulfilled"?O[0].value?.columnsByTable??{}:{},we=O[0].status==="rejected",Se=new Map(I.map(mt)),_e=[...C,...y].map(T=>{const ge=Te[T]??[];return[T,ge.length>0?ge:Se.get(T)??[]]});me(T=>({...T,[u]:Object.fromEntries(_e)})),G(T=>({...T,[u]:we}))},e[28]=t,e[29]=B):B=e[29];const le=B;let U,ae;e[30]!==D||e[31]!==$||e[32]!==le||e[33]!==d||e[34]!==j||e[35]!==o||e[36]!==a?(U=()=>{a!=="graph"||o===null||$===null&&D===null||j[d]!==void 0||fe(le(d,o.map(ut),($??[]).map(ht)))},ae=[a,o,$,D,d,j,le],e[30]=D,e[31]=$,e[32]=le,e[33]=d,e[34]=j,e[35]=o,e[36]=a,e[37]=U,e[38]=ae):(U=e[37],ae=e[38]),Pe(U,ae);const E=j[d]??dt;let ne;if(e[39]!==E||e[40]!==$||e[41]!==o){let u;e[43]!==E?(u=I=>({columns:E[I.name]??Be,name:I.name,tier:"shard"}),e[43]=E,e[44]=u):u=e[44];const C=(o??[]).map(u);let y;e[45]!==E?(y=I=>({columns:E[I.name]??Be,name:I.name,tier:"global"}),e[45]=E,e[46]=y):y=e[46];const O=($??[]).map(y);ne=[...C,...O],e[39]=E,e[40]=$,e[41]=o,e[42]=ne}else ne=e[42];const se=ne;let b;if(e[47]!==r||e[48]!==o){const u=r.trim().toLowerCase();b=(o??[]).filter(C=>C.name.toLowerCase().includes(u)),e[47]=r,e[48]=o,e[49]=b}else b=e[49];const re=b;let W;if(e[50]!==$||e[51]!==r){const u=r.trim().toLowerCase();W=($??[]).filter(C=>C.name.toLowerCase().includes(u)),e[50]=$,e[51]=r,e[52]=W}else W=e[52];const Ne=W;let pe;return e[53]!==L||e[54]!==se||e[55]!==p||e[56]!==w||e[57]!==Ne||e[58]!==re||e[59]!==X||e[60]!==D||e[61]!==Y||e[62]!==$||e[63]!==F||e[64]!==q||e[65]!==i||e[66]!==k||e[67]!==f||e[68]!==r||e[69]!==o||e[70]!==z||e[71]!==ce||e[72]!==a?(pe={columns:L,diagramTables:se,error:p,expanded:w,filteredGlobalTables:Ne,filteredTables:re,globalColumns:X,globalError:D,globalExpanded:Y,globalTables:$,indexes:F,refresh:q,setShardKey:i,setTableFilter:h,setView:c,shardColumnsError:k,shardKey:f,tableFilter:r,tables:o,toggle:z,toggleGlobal:ce,view:a},e[53]=L,e[54]=se,e[55]=p,e[56]=w,e[57]=Ne,e[58]=re,e[59]=X,e[60]=D,e[61]=Y,e[62]=$,e[63]=F,e[64]=q,e[65]=i,e[66]=k,e[67]=f,e[68]=r,e[69]=o,e[70]=z,e[71]=ce,e[72]=a,e[73]=pe):pe=e[73],pe};function mt(s){const{columns:e,refs:m,table:n}=s;return[n,e.map(t=>{const a=m[t];return a===void 0?{name:t,optional:!1,type:""}:{name:t,optional:!1,ref:a,type:"id"}})]}function ut(s){return s.name}function ht(s){return s.name}const pt="/__lunora/schema-edit",gt=async s=>{const e=await fetch(pt,{body:JSON.stringify(s),headers:{"Content-Type":"application/json","X-Lunora-Studio":"1"},method:"POST"}),m=await e.json();return m.needsMigration===!0?{kind:"needs-migration",message:m.message??"This edit needs a migration."}:e.ok&&m.tables!==void 0?{diagnostics:m.diagnostics??[],kind:"ok",tables:m.tables}:{kind:"error",message:m.error??`schema edit failed (${String(e.status)})`}},bt=s=>{const e=Ce(32),{hasTables:m,mode:n,onAddColumn:t,onAddIndex:a,onAddTable:c,onDestructive:d}=s,i=je(),f=n==="addTable"?"default":"outline";let r;e[0]!==i?(r=i("Add table"),e[0]=i,e[1]=r):r=e[1];let h;e[2]!==c||e[3]!==f||e[4]!==r?(h=l(be,{"data-testid":"sc-editor-add-table",onClick:c,size:"xs",type:"button",variant:f,children:r}),e[2]=c,e[3]=f,e[4]=r,e[5]=h):h=e[5];const o=!m,x=n==="addColumn"?"default":"outline";let p;e[6]!==i?(p=i("Add column"),e[6]=i,e[7]=p):p=e[7];let P;e[8]!==t||e[9]!==o||e[10]!==x||e[11]!==p?(P=l(be,{"data-testid":"sc-editor-add-column",disabled:o,onClick:t,size:"xs",type:"button",variant:x,children:p}),e[8]=t,e[9]=o,e[10]=x,e[11]=p,e[12]=P):P=e[12];const S=!m,L=n==="addIndex"?"default":"outline";let v;e[13]!==i?(v=i("Add index"),e[13]=i,e[14]=v):v=e[14];let K;e[15]!==a||e[16]!==v||e[17]!==S||e[18]!==L?(K=l(be,{"data-testid":"sc-editor-add-index",disabled:S,onClick:a,size:"xs",type:"button",variant:L,children:v}),e[15]=a,e[16]=v,e[17]=S,e[18]=L,e[19]=K):K=e[19];const F=!m,M=n==="destructive"?"default":"ghost";let w;e[20]!==i?(w=i("Rename / drop / change type…"),e[20]=i,e[21]=w):w=e[21];let N;e[22]!==d||e[23]!==F||e[24]!==M||e[25]!==w?(N=l(be,{"data-testid":"sc-editor-destructive",disabled:F,onClick:d,size:"xs",type:"button",variant:M,children:w}),e[22]=d,e[23]=F,e[24]=M,e[25]=w,e[26]=N):N=e[26];let A;return e[27]!==K||e[28]!==N||e[29]!==h||e[30]!==P?(A=g("div",{className:"flex flex-wrap gap-2",children:[h,P,K,N]}),e[27]=K,e[28]=N,e[29]=h,e[30]=P,e[31]=A):A=e[31],A},ft=s=>{const e=Ce(28),{onOpenMigrations:m,result:n}=s,t=je();if(n===null){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=l(Ve,{}),e[0]=r):r=e[0],r}if(n.kind==="error"){let r;return e[1]!==n.message?(r=l("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:n.message}),e[1]=n.message,e[2]=r):r=e[2],r}if(n.kind==="needs-migration"){let r;e[3]!==n.message||e[4]!==t?(r=n.message===""?t("This edit changes stored data and must go through a migration. Review the migration before applying."):n.message,e[3]=n.message,e[4]=t,e[5]=r):r=e[5];let h;e[6]!==r?(h=l("p",{className:"text-sm text-warning",role:"alert",children:r}),e[6]=r,e[7]=h):h=e[7];let o;e[8]!==t?(o=t("Open Migrations"),e[8]=t,e[9]=o):o=e[9];let x;e[10]!==m||e[11]!==o?(x=l(be,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:m,size:"xs",type:"button",variant:"outline",children:o}),e[10]=m,e[11]=o,e[12]=x):x=e[12];let p;return e[13]!==h||e[14]!==x?(p=g("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[h,x]}),e[13]=h,e[14]=x,e[15]=p):p=e[15],p}if(n.diagnostics.length===0){let r;return e[16]===Symbol.for("react.memo_cache_sentinel")?(r=l(Ve,{}),e[16]=r):r=e[16],r}let a;e[17]!==t?(a=t("Codegen reported diagnostics:"),e[17]=t,e[18]=a):a=e[18];let c;e[19]!==a?(c=l("p",{className:"text-sm text-destructive",role:"alert",children:a}),e[19]=a,e[20]=c):c=e[20];let d;e[21]!==n.diagnostics?(d=n.diagnostics.map(xt),e[21]=n.diagnostics,e[22]=d):d=e[22];let i;e[23]!==d?(i=l("ul",{className:"flex flex-col gap-0.5",children:d}),e[23]=d,e[24]=i):i=e[24];let f;return e[25]!==c||e[26]!==i?(f=g("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[c,i]}),e[25]=c,e[26]=i,e[27]=f):f=e[27],f};function xt(s){return l("li",{className:"font-mono text-[11px] text-destructive",children:s},s)}const vt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.int64()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],yt="v.string()",Nt=s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),Ct=s=>{const e=Ce(83),{onApplied:m,tableNames:n}=s,t=je(),a=nt(),[c,d]=_(null),[i,f]=_(!1),[r,h]=_(null),[o,x]=_(""),[p,P]=_(""),[S,L]=_(yt),[v,K]=_(n[0]??""),[F,M]=_(""),[w,N]=_(""),[A,j]=_(!1);let me;e[0]===Symbol.for("react.memo_cache_sentinel")?(me=()=>{d(null),x(""),P(""),M(""),N(""),j(!1)},e[0]=me):me=e[0];const Z=me;let k;e[1]!==m?(k=async T=>{f(!0),h(null);try{const ge=await gt(T);h(ge),ge.kind==="ok"&&(m(ge.tables),Z())}catch(ge){const ke=ge;h({kind:"error",message:ke instanceof Error?ke.message:String(ke)})}f(!1)},e[1]=m,e[2]=k):k=e[2];const G=k;let $;e[3]!==G||e[4]!==o?($=()=>{fe(G({kind:"addTable",table:o.trim()}))},e[3]=G,e[4]=o,e[5]=$):$=e[5];const ue=$;let D;e[6]!==p||e[7]!==G||e[8]!==v||e[9]!==S?(D=()=>{fe(G({column:p.trim(),kind:"addOptionalColumn",table:v,validator:S}))},e[6]=p,e[7]=G,e[8]=v,e[9]=S,e[10]=D):D=e[10];const oe=D;let H;e[11]!==w||e[12]!==F||e[13]!==G||e[14]!==v||e[15]!==A?(H=()=>{fe(G({fields:Nt(w),kind:"addIndex",name:F.trim(),table:v,unique:A}))},e[11]=w,e[12]=F,e[13]=G,e[14]=v,e[15]=A,e[16]=H):H=e[16];const X=H;let xe;e[17]===Symbol.for("react.memo_cache_sentinel")?(xe=()=>{h(null),d("addTable")},e[17]=xe):xe=e[17];const Y=xe;let ie;e[18]===Symbol.for("react.memo_cache_sentinel")?(ie=()=>{h(null),d("addColumn")},e[18]=ie):ie=e[18];const ve=ie;let q;e[19]===Symbol.for("react.memo_cache_sentinel")?(q=()=>{h(null),d("addIndex")},e[19]=q):q=e[19];const Q=q;let ee;e[20]!==t?(ee=()=>{d("destructive"),h({kind:"needs-migration",message:t("This edit changes stored data and must go through a migration. Review the migration before applying.")})},e[20]=t,e[21]=ee):ee=e[21];const de=ee;let R;e[22]===Symbol.for("react.memo_cache_sentinel")?(R=T=>{x(T.target.value)},e[22]=R):R=e[22];const te=R;let z;e[23]===Symbol.for("react.memo_cache_sentinel")?(z=T=>{P(T.target.value)},e[23]=z):z=e[23];const ye=z;let ce;e[24]===Symbol.for("react.memo_cache_sentinel")?(ce=T=>{L(T.target.value)},e[24]=ce):ce=e[24];const he=ce;let V;e[25]===Symbol.for("react.memo_cache_sentinel")?(V=T=>{K(T.target.value)},e[25]=V):V=e[25];const J=V;let B;e[26]===Symbol.for("react.memo_cache_sentinel")?(B=T=>{M(T.target.value)},e[26]=B):B=e[26];const le=B;let U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=T=>{N(T.target.value)},e[27]=U):U=e[27];const ae=U;let E;e[28]===Symbol.for("react.memo_cache_sentinel")?(E=T=>{j(T.target.checked)},e[28]=E):E=e[28];const ne=E;let se;e[29]!==a?(se=()=>{fe(a({to:"/migrations"}))},e[29]=a,e[30]=se):se=e[30];const b=se;let re;e[31]!==t?(re=t("Edit schema"),e[31]=t,e[32]=re):re=e[32];let W;e[33]!==re?(W=l(Ke,{children:re}),e[33]=re,e[34]=W):W=e[34];let Ne;e[35]!==t?(Ne=t("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=t,e[36]=Ne):Ne=e[36];let pe;e[37]!==Ne?(pe=l(Ge,{children:Ne}),e[37]=Ne,e[38]=pe):pe=e[38];let u;e[39]!==W||e[40]!==pe?(u=g(Le,{children:[W,pe]}),e[39]=W,e[40]=pe,e[41]=u):u=e[41];const C=n.length>0;let y;e[42]!==c||e[43]!==de||e[44]!==C?(y=l(bt,{hasTables:C,mode:c,onAddColumn:ve,onAddIndex:Q,onAddTable:Y,onDestructive:de}),e[42]=c,e[43]=de,e[44]=C,e[45]=y):y=e[45];let O;e[46]!==i||e[47]!==c||e[48]!==ue||e[49]!==t||e[50]!==o?(O=c==="addTable"&&g("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[g("div",{className:"flex flex-col gap-1 text-xs",children:[l($e,{htmlFor:"sc-editor-table-name",children:t("Table name")}),l(Ie,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:te,value:o})]}),l(be,{"data-testid":"sc-editor-table-apply",disabled:i||o.trim()==="",onClick:ue,size:"xs",type:"button",children:t(i?"Applying…":"Apply")}),l(be,{onClick:Z,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[46]=i,e[47]=c,e[48]=ue,e[49]=t,e[50]=o,e[51]=O):O=e[51];let I;e[52]!==i||e[53]!==p||e[54]!==c||e[55]!==oe||e[56]!==t||e[57]!==n||e[58]!==v||e[59]!==S?(I=c==="addColumn"&&g("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[g("div",{className:"flex flex-col gap-1 text-xs",children:[l($e,{htmlFor:"sc-editor-column-table",children:t("Table name")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:J,value:v,children:n.map(Tt)})]}),g("div",{className:"flex flex-col gap-1 text-xs",children:[l($e,{htmlFor:"sc-editor-column-name",children:t("Column name")}),l(Ie,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:ye,value:p})]}),g("div",{className:"flex flex-col gap-1 text-xs",children:[l($e,{htmlFor:"sc-editor-column-type",children:t("Column type")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:he,value:S,children:vt.map(wt)})]}),l("span",{className:"text-[11px] text-muted-foreground",children:t("Optional")}),l(be,{"data-testid":"sc-editor-column-apply",disabled:i||p.trim()===""||v==="",onClick:oe,size:"xs",type:"button",children:t(i?"Applying…":"Apply")}),l(be,{onClick:Z,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[52]=i,e[53]=p,e[54]=c,e[55]=oe,e[56]=t,e[57]=n,e[58]=v,e[59]=S,e[60]=I):I=e[60];let Te;e[61]!==i||e[62]!==w||e[63]!==F||e[64]!==c||e[65]!==X||e[66]!==t||e[67]!==n||e[68]!==v||e[69]!==A?(Te=c==="addIndex"&&g("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[g("div",{className:"flex flex-col gap-1 text-xs",children:[l($e,{htmlFor:"sc-editor-index-table",children:t("Table name")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:J,value:v,children:n.map(St)})]}),g("div",{className:"flex flex-col gap-1 text-xs",children:[l($e,{htmlFor:"sc-editor-index-name",children:t("Index name")}),l(Ie,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:le,value:F})]}),g("div",{className:"flex flex-col gap-1 text-xs",children:[l($e,{htmlFor:"sc-editor-index-fields",children:t("Index fields (comma-separated)")}),l(Ie,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:ae,value:w})]}),g($e,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[l("input",{checked:A,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:ne,type:"checkbox"}),l("span",{className:"text-muted-foreground",children:t("Unique")})]}),l(be,{"data-testid":"sc-editor-index-apply",disabled:i||F.trim()===""||w.trim()==="",onClick:X,size:"xs",type:"button",children:t(i?"Applying…":"Apply")}),l(be,{onClick:Z,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[61]=i,e[62]=w,e[63]=F,e[64]=c,e[65]=X,e[66]=t,e[67]=n,e[68]=v,e[69]=A,e[70]=Te):Te=e[70];let we;e[71]!==b||e[72]!==r?(we=l(ft,{onOpenMigrations:b,result:r}),e[71]=b,e[72]=r,e[73]=we):we=e[73];let Se;e[74]!==y||e[75]!==O||e[76]!==I||e[77]!==Te||e[78]!==we?(Se=g(Me,{children:[y,O,I,Te,we]}),e[74]=y,e[75]=O,e[76]=I,e[77]=Te,e[78]=we,e[79]=Se):Se=e[79];let _e;return e[80]!==u||e[81]!==Se?(_e=g(De,{"data-testid":"sc-editor",size:"sm",children:[u,Se]}),e[80]=u,e[81]=Se,e[82]=_e):_e=e[82],_e};function Tt(s){return l("option",{value:s,children:s},s)}function wt(s){return l("option",{value:s.validator,children:s.label},s.validator)}function St(s){return l("option",{value:s,children:s},s)}const Ue=[],$t=s=>{const e=Ce(5),{open:m}=s,n=m&&"rotate-90";let t;e[0]!==n?(t=We("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",n),e[0]=n,e[1]=t):t=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=l("path",{d:"m9 6 6 6-6 6"}),e[2]=a):a=e[2];let c;return e[3]!==t?(c=l("svg",{"aria-hidden":"true",className:t,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:a}),e[3]=t,e[4]=c):c=e[4],c},Xe=s=>{const e=Ce(20),{children:m,expanded:n,name:t,onToggle:a,rowCount:c,rowTestId:d,toggleTestId:i}=s;let f;e[0]!==n?(f=l($t,{open:n}),e[0]=n,e[1]=f):f=e[1];let r;e[2]!==t?(r=l("span",{className:"truncate font-mono text-xs text-foreground",title:t,children:t}),e[2]=t,e[3]=r):r=e[3];let h;e[4]!==c?(h=g("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",c,")"]}),e[4]=c,e[5]=h):h=e[5];let o;e[6]!==n||e[7]!==a||e[8]!==f||e[9]!==r||e[10]!==h||e[11]!==i?(o=g("button",{"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":i,onClick:a,type:"button",children:[f,r," ",h]}),e[6]=n,e[7]=a,e[8]=f,e[9]=r,e[10]=h,e[11]=i,e[12]=o):o=e[12];let x;e[13]!==m||e[14]!==n?(x=n&&l("div",{className:"px-3 pb-3 ps-8",children:m}),e[13]=m,e[14]=n,e[15]=x):x=e[15];let p;return e[16]!==d||e[17]!==o||e[18]!==x?(p=g("li",{className:"border-t border-border/60 first:border-t-0","data-testid":d,children:[o,x]}),e[16]=d,e[17]=o,e[18]=x,e[19]=p):p=e[19],p},Ye=s=>{const e=Ce(5),{columns:m,testId:n}=s;let t;e[0]!==m?(t=m.map(kt),e[0]=m,e[1]=t):t=e[1];let a;return e[2]!==t||e[3]!==n?(a=l("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":n,children:t}),e[2]=t,e[3]=n,e[4]=a):a=e[4],a},_t=s=>{const e=Ce(10),{heading:m,indexes:n,testId:t}=s;let a;e[0]!==m?(a=l("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:m}),e[0]=m,e[1]=a):a=e[1];let c;e[2]!==n?(c=n.map(It),e[2]=n,e[3]=c):c=e[3];let d;e[4]!==c||e[5]!==t?(d=l("ul",{className:"flex flex-col gap-1","data-testid":t,children:c}),e[4]=c,e[5]=t,e[6]=d):d=e[6];let i;return e[7]!==a||e[8]!==d?(i=g("div",{className:"pt-3",children:[a,d]}),e[7]=a,e[8]=d,e[9]=i):i=e[9],i},Je=s=>We("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",s?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),Zt=s=>{const e=Ce(85),{initialShardKey:m,initialTable:n,schemaEditable:t}=s,a=je();let c;e[0]!==m||e[1]!==n?(c={initialShardKey:m,initialTable:n},e[0]=m,e[1]=n,e[2]=c):c=e[2];const{columns:d,diagramTables:i,error:f,expanded:r,filteredGlobalTables:h,filteredTables:o,globalColumns:x,globalError:p,globalExpanded:P,globalTables:S,indexes:L,refresh:v,setShardKey:K,setTableFilter:F,setView:M,shardColumnsError:w,shardKey:N,tableFilter:A,tables:j,toggle:me,toggleGlobal:Z,view:k}=ct(c);let G;e[3]!==M?(G=()=>{M("list")},e[3]=M,e[4]=G):G=e[4];const $=G;let ue;e[5]!==M?(ue=()=>{M("graph")},e[5]=M,e[6]=ue):ue=e[6];const D=ue;let oe;e[7]!==F?(oe=b=>{F(b.target.value)},e[7]=F,e[8]=oe):oe=e[8];const H=oe;let X;e[9]!==v||e[10]!==N?(X=b=>{fe(v(N))},e[9]=v,e[10]=N,e[11]=X):X=e[11];const xe=X;let Y;e[12]!==j?(Y=j??[],e[12]=j,e[13]=Y):Y=e[13];let ie;e[14]!==Y?(ie=Y.map(At),e[14]=Y,e[15]=ie):ie=e[15];const ve=ie;let q;e[16]!==K||e[17]!==N?(q=l(Ze,{onChange:K,testId:"sc-shard-input",value:N}),e[16]=K,e[17]=N,e[18]=q):q=e[18];let Q;e[19]!==a?(Q=a("Schema view"),e[19]=a,e[20]=Q):Q=e[20];const ee=k==="graph",de=k==="graph";let R;e[21]!==de?(R=Je(de),e[21]=de,e[22]=R):R=e[22];let te;e[23]!==a?(te=a("Graph"),e[23]=a,e[24]=te):te=e[24];let z;e[25]!==D||e[26]!==ee||e[27]!==R||e[28]!==te?(z=l("button",{"aria-selected":ee,className:R,"data-testid":"sc-view-graph",onClick:D,role:"tab",type:"button",children:te}),e[25]=D,e[26]=ee,e[27]=R,e[28]=te,e[29]=z):z=e[29];const ye=k==="list",ce=k==="list";let he;e[30]!==ce?(he=Je(ce),e[30]=ce,e[31]=he):he=e[31];let V;e[32]!==a?(V=a("Table list"),e[32]=a,e[33]=V):V=e[33];let J;e[34]!==$||e[35]!==ye||e[36]!==he||e[37]!==V?(J=l("button",{"aria-selected":ye,className:he,"data-testid":"sc-view-list",onClick:$,role:"tab",type:"button",children:V}),e[34]=$,e[35]=ye,e[36]=he,e[37]=V,e[38]=J):J=e[38];let B;e[39]!==z||e[40]!==J||e[41]!==Q?(B=g("div",{"aria-label":Q,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[z,J]}),e[39]=z,e[40]=J,e[41]=Q,e[42]=B):B=e[42];let le;e[43]!==B||e[44]!==q?(le=g("div",{className:"flex flex-wrap items-center gap-3",children:[q,B]}),e[43]=B,e[44]=q,e[45]=le):le=e[45];let U;e[46]!==xe||e[47]!==t||e[48]!==ve?(U=t===!0&&l(Ct,{onApplied:xe,tableNames:ve}),e[46]=xe,e[47]=t,e[48]=ve,e[49]=U):U=e[49];let ae;e[50]!==H||e[51]!==a||e[52]!==A||e[53]!==k?(ae=k==="list"&&l(Ie,{"aria-label":a("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:H,placeholder:a("Filter tables"),value:A}),e[50]=H,e[51]=a,e[52]=A,e[53]=k,e[54]=ae):ae=e[54];let E;e[55]!==i||e[56]!==f||e[57]!==p||e[58]!==w||e[59]!==N||e[60]!==k?(E=k==="graph"&&g("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[f!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:f}),p!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),l(at,{columnsError:w[N]===!0,tables:i,testIdPrefix:"sc-graph"})]}),e[55]=i,e[56]=f,e[57]=p,e[58]=w,e[59]=N,e[60]=k,e[61]=E):E=e[61];let ne;e[62]!==d||e[63]!==f||e[64]!==r||e[65]!==h||e[66]!==o||e[67]!==x||e[68]!==p||e[69]!==P||e[70]!==S||e[71]!==L||e[72]!==N||e[73]!==a||e[74]!==j||e[75]!==me||e[76]!==Z||e[77]!==k?(ne=k==="list"&&g("div",{className:"flex flex-col gap-4",children:[g(De,{"data-testid":"sc-shard-section",size:"sm",children:[g(Le,{children:[g("div",{className:"flex items-center gap-2",children:[l(Re,{tier:"shard"}),l(Ke,{children:a("Shard tables")}),j!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:o.length})]}),l(Ge,{children:Oe.shard.hint})]}),g(Me,{children:[f!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:f}),j!==null&&j.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:a("No tables in this shard.")}),j!==null&&j.length>0&&o.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:a("No tables match your filter.")}),o.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:o.map(b=>{const re=`${N}:${b.name}`,W=L[re]??[];return g(Xe,{expanded:r===b.name,name:b.name,onToggle:()=>{fe(me(b.name))},rowCount:b.rowCount,rowTestId:`sc-table-${b.name}`,toggleTestId:`sc-toggle-${b.name}`,children:[l(Ye,{columns:d[re]??Ue,testId:`sc-columns-${b.name}`}),W.length>0&&l(_t,{heading:a("Indexes"),indexes:W,testId:`sc-indexes-${b.name}`})]},b.name)})})]})]}),g(De,{"data-testid":"sc-global-section",size:"sm",children:[g(Le,{children:[g("div",{className:"flex items-center gap-2",children:[l(Re,{tier:"global"}),l(Ke,{children:a("Global tables (D1)")}),S!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:h.length})]}),l(Ge,{children:Oe.global.hint})]}),g(Me,{children:[p!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),S!==null&&S.length===0&&l(He,{description:Oe.global.hint,testId:"sc-global-empty",title:a("No global tables.")}),S!==null&&S.length>0&&h.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:a("No tables match your filter.")}),h.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:h.map(b=>l(Xe,{expanded:P===b.name,name:b.name,onToggle:()=>{fe(Z(b.name))},rowCount:b.rowCount,rowTestId:`sc-global-table-${b.name}`,toggleTestId:`sc-global-toggle-${b.name}`,children:l(Ye,{columns:x[b.name]??Ue,testId:`sc-global-columns-${b.name}`})},b.name))})]})]})]}),e[62]=d,e[63]=f,e[64]=r,e[65]=h,e[66]=o,e[67]=x,e[68]=p,e[69]=P,e[70]=S,e[71]=L,e[72]=N,e[73]=a,e[74]=j,e[75]=me,e[76]=Z,e[77]=k,e[78]=ne):ne=e[78];let se;return e[79]!==le||e[80]!==U||e[81]!==ae||e[82]!==E||e[83]!==ne?(se=g("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[le,U,ae,E,ne]}),e[79]=le,e[80]=U,e[81]=ae,e[82]=E,e[83]=ne,e[84]=se):se=e[84],se};function kt(s){return l("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:s},s)}function It(s){return g("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[l("span",{className:"font-mono",children:s.name}),l(Fe,{variant:"outline",children:s.type}),s.unique===!0&&l(Fe,{variant:"secondary",children:"unique"}),l("span",{className:"text-muted-foreground",children:s.fields.join(", ")})]},`${s.type}:${s.name}`)}function At(s){return s.name}export{Zt as SchemaViewer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as u}from"react/compiler-runtime";import{N as m}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{useT as h}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as f}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{A as g}from"../packem_shared/advisor-view-
|
|
1
|
+
import{c as u}from"react/compiler-runtime";import{N as m}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{useT as h}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as f}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{A as g}from"../packem_shared/advisor-view-CGcwvlMo.js";import{jsx as p}from"react/jsx-runtime";const R=(e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("Live admin subscriptions are ungated")})[s.kind],k=e=>Array.isArray(e.findings)?e.findings:[],S=e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],A=(e,s)=>({"admin-token-weak":e("Your admin token is {length} characters — use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters — use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed — browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: live admin subscriptions need no credential. Set it to gate them like the HTTP admin RPCs.")})[s.kind],N=()=>{const e=u(8),s=h();let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={},e[0]=t):t=e[0];const{data:i,error:n,errorSource:d}=m(f.getSecurityAudit,t);let a;if(e[1]!==i||e[2]!==s){const l=i===void 0?null:k(i);a=l===null?null:l.map(r=>({description:A(s,r),entity:S(r),issueType:R(s,r),key:r.kind,level:r.level})),e[1]=i,e[2]=s,e[3]=a}else a=e[3];const c=a;let o;return e[4]!==n||e[5]!==d||e[6]!==c?(o=p(g,{error:n,errorSource:d,rows:c,testId:"lunora-security-advisor"}),e[4]=n,e[5]=d,e[6]=c,e[7]=o):o=e[7],o};export{N as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as O}from"react/compiler-runtime";import{
|
|
1
|
+
import{c as O}from"react/compiler-runtime";import{U as K}from"../packem_shared/error-alert-_2q2VtVG.js";import{g as j}from"../packem_shared/badge-BbuuAio7.js";import{c as D,f as I}from"../packem_shared/card-BMKx5UdA.js";import{d as A,n as F,f as L,m as R,b as V,p as T}from"../packem_shared/table-DZAB8cs3.js";import{N as W}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{useT as q}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as z}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{C as M}from"../packem_shared/cf-links-Dmg86v1D.js";import{jsx as t,jsxs as m}from"react/jsx-runtime";const P={binding:"outline",secret:"destructive",var:"secondary"},B=(r,e)=>{if(r===void 0)return[];const c=[];return r.workerUrl!==void 0&&c.push({label:e("URL"),value:r.workerUrl}),r.environment!==void 0&&c.push({label:e("Environment"),value:r.environment}),r.deploymentId!==void 0&&c.push({label:e("Deployment"),value:r.deploymentId}),r.versionTag!==void 0&&c.push({label:e("Version"),value:r.versionTag}),c},le=r=>{const e=O(52),{initialShardKey:c}=r,n=q();let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={},e[0]=w):w=e[0];const U=c??"";let S;e[1]!==U?(S={shardKey:U},e[1]=U,e[2]=S):S=e[2];const{data:l,error:s,errorSource:k,isLoading:E}=W(z.getSettings,w,S);let a,p,u,d,o,i,h;if(e[3]!==s||e[4]!==k||e[5]!==l?.deploy||e[6]!==l?.settings||e[7]!==n){const C=B(l?.deploy,n);let $;e[15]!==l?.settings?($=l?.settings??[],e[15]=l?.settings,e[16]=$):$=e[16],a=$,p="flex flex-col gap-4",u="lunora-settings";let b;e[17]!==n?(b=n("Open in Cloudflare"),e[17]=n,e[18]=b):b=e[18],e[19]!==b?(d=t("div",{className:"flex flex-wrap items-center gap-3",children:t("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:M,rel:"noreferrer",target:"_blank",children:b})}),e[19]=b,e[20]=d):d=e[20];let N;e[21]!==n?(N=n("View-only — values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=n,e[22]=N):N=e[22],e[23]!==N?(o=t("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:N}),e[23]=N,e[24]=o):o=e[24],e[25]!==s||e[26]!==k?(i=s!==null&&t(K,{error:k,testId:"set-error"}),e[25]=s,e[26]=k,e[27]=i):i=e[27],h=C.length>0&&m(D,{className:"py-0","data-testid":"set-deploy",children:[t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Deployment")})}),t(I,{className:"py-3",children:t("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:C.map(G)})})]}),e[3]=s,e[4]=k,e[5]=l?.deploy,e[6]=l?.settings,e[7]=n,e[8]=a,e[9]=p,e[10]=u,e[11]=d,e[12]=o,e[13]=i,e[14]=h}else a=e[8],p=e[9],u=e[10],d=e[11],o=e[12],i=e[13],h=e[14];let f;e[28]!==n?(f=n("Environment & bindings"),e[28]=n,e[29]=f):f=e[29];let g;e[30]!==f?(g=t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:f})}),e[30]=f,e[31]=g):g=e[31];let x;e[32]!==s||e[33]!==E||e[34]!==a.length||e[35]!==n?(x=s===null&&!E&&a.length===0&&t("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:n("No environment variables or bindings.")}),e[32]=s,e[33]=E,e[34]=a.length,e[35]=n,e[36]=x):x=e[36];let v;e[37]!==a||e[38]!==n?(v=a.length>0&&t(I,{className:"px-0 py-0",children:m(A,{"data-testid":"set-table",children:[t(F,{children:m(L,{children:[t(R,{children:n("name")}),t(R,{children:n("kind")}),t(R,{children:n("value")})]})}),t(V,{children:a.map(H)})]})}),e[37]=a,e[38]=n,e[39]=v):v=e[39];let y;e[40]!==g||e[41]!==x||e[42]!==v?(y=m(D,{className:"py-0",children:[g,x,v]}),e[40]=g,e[41]=x,e[42]=v,e[43]=y):y=e[43];let _;return e[44]!==y||e[45]!==p||e[46]!==u||e[47]!==d||e[48]!==o||e[49]!==i||e[50]!==h?(_=m("div",{className:p,"data-testid":u,children:[d,o,i,h,y]}),e[44]=y,e[45]=p,e[46]=u,e[47]=d,e[48]=o,e[49]=i,e[50]=h,e[51]=_):_=e[51],_};function G(r){return m("div",{className:"contents","data-testid":"set-deploy-row",children:[t("dt",{className:"text-muted-foreground",children:r.label}),t("dd",{className:"truncate font-mono text-xs",title:r.value,children:r.value})]},r.label)}function H(r){return m(L,{"data-testid":"set-row",children:[t(T,{className:"font-mono text-xs font-medium",children:r.name}),t(T,{children:t(j,{variant:P[r.kind],children:r.bindingType??r.kind})}),t(T,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:r.value??t("span",{className:"text-muted-foreground",children:"—"})})]},r.name)}export{le as SettingsPanel};
|