@lunora/studio 1.0.0-alpha.32 → 1.0.0-alpha.34

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.
@@ -1 +1 @@
1
- import{a as be,b as ge,c as xe,d as Ne,e as Ce}from"./chunk-LI43EKM6.js";import"./chunk-DWDILV2E.js";import{a as ue}from"./chunk-BACPICH6.js";import"./chunk-QBAT52GB.js";import"./chunk-QAFAJBAW.js";import{g as me,h as ve,i as fe,j as pe}from"./chunk-OV2WFAJX.js";import"./chunk-ZPUO7FNI.js";import"./chunk-764T6X6X.js";import"./chunk-XUGSA2NG.js";import"./chunk-5OIBXYZM.js";import"./chunk-UII66UVF.js";import"./chunk-7TJJXVSE.js";import"./chunk-SVR644RF.js";import"./chunk-KEGAWN6Y.js";import{a as de,b as ne,c as oe,d as q,e as Q,f as X}from"./chunk-GTM65MVX.js";import{a as ce}from"./chunk-VLXV72QE.js";import{a as W}from"./chunk-JSEXCW5Q.js";import"./chunk-KZ6INM5M.js";import"./chunk-4QHKBC77.js";import{R as le}from"./chunk-3CJW6NWG.js";import{c as $}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import"./chunk-AQGOX5DK.js";import{a as ye}from"./chunk-TAD43CG5.js";import"./chunk-DVKPRFIJ.js";import{a as re,e as se}from"./chunk-SEU5V7I6.js";import{b as he}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as Y}from"./chunk-X7MMBSNW.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as U,g as z,k as H,l as ie,m as ke}from"./chunk-PVZI3CXP.js";import"./chunk-GMSGZDDH.js";import{a as n,e as ae,f as Me,g as Le,h as Be}from"./chunk-RRCPZMC2.js";var J=ae(Me(),1);var ee=ae(Le(),1);var l=ae(Be(),1);var De=n(r=>{let e=r.trim();if(e==="")return;let s=Number(e);return Number.isFinite(s)&&s>0?Math.floor(s):void 0},"parseTtl"),Oe=n(r=>r===void 0?"\u2014":new Date(r*1e3).toISOString(),"formatExpiration"),Ae=n(r=>new TextEncoder().encode(r).length,"byteLength"),Te=n(r=>{if(r.trim()!=="")try{return JSON.stringify(JSON.parse(r),void 0,2)}catch{return}},"tryFormatJson"),Ee=n(r=>{if(r.trim()==="")return!0;try{return JSON.parse(r),!0}catch{return!1}},"isJsonOrEmpty"),Fe=[{key:"seconds",seconds:1},{key:"minutes",seconds:60},{key:"hours",seconds:3600},{key:"days",seconds:86400}],Se=n((r,e)=>{let s=r.trim();if(s==="")return"";let u=Number(s),d=Fe.find(f=>f.key===e)?.seconds??1;return Number.isFinite(u)&&u>0?String(Math.round(u*d)):s},"ttlToSeconds"),Ke=n(r=>{let e=r.trim();if(e==="")return!0;let s=Number(e);return Number.isInteger(s)&&s>=60},"isTtlValid"),Ve=n((r,e,s,u)=>{let d=De(r.ttl);return{expiration:d===void 0?u:void 0,expirationTtl:d,key:e,metadata:r.metadata.trim()===""?void 0:JSON.parse(r.metadata),namespace:s,value:r.value}},"buildKvPutOptions"),Ie=n(r=>{let e=(0,ee.c)(60),{helper:s,id:u,invalid:d,onChange:f,testId:o}=r,t=U(),[a,p]=(0,J.useState)(""),[c,x]=(0,J.useState)("seconds"),b;e[0]!==f||e[1]!==c?(b=n(g=>{p(g.target.value),f(Se(g.target.value,c))},"t1"),e[0]=f,e[1]=c,e[2]=b):b=e[2];let M=b,V;e[3]!==a||e[4]!==f?(V=n(g=>{g!==null&&(x(g),f(Se(a,g)))},"t2"),e[3]=a,e[4]=f,e[5]=V):V=e[5];let L=V,h;e[6]!==t?(h=t("days"),e[6]=t,e[7]=h):h=e[7];let v;e[8]!==t?(v=t("hours"),e[8]=t,e[9]=v):v=e[9];let y;e[10]!==t?(y=t("minutes"),e[10]=t,e[11]=y):y=e[11];let N;e[12]!==t?(N=t("seconds"),e[12]=t,e[13]=N):N=e[13];let C;e[14]!==h||e[15]!==v||e[16]!==y||e[17]!==N?(C={days:h,hours:v,minutes:y,seconds:N},e[14]=h,e[15]=v,e[16]=y,e[17]=N,e[18]=C):C=e[18];let S=C,k;e[19]!==t?(k=t("Expires after"),e[19]=t,e[20]=k):k=e[20];let w;e[21]!==u||e[22]!==k?(w=(0,l.jsxDEV)(W,{className:"text-xs",htmlFor:u,children:k},void 0,!1),e[21]=u,e[22]=k,e[23]=w):w=e[23];let E;e[24]!==t?(E=t("No expiration"),e[24]=t,e[25]=E):E=e[25];let B;e[26]!==a||e[27]!==u||e[28]!==d||e[29]!==M||e[30]!==E||e[31]!==o?(B=(0,l.jsxDEV)(le,{"aria-invalid":d,className:"flex-1","data-testid":o,id:u,inputMode:"numeric",onChange:M,placeholder:E,value:a},void 0,!1),e[26]=a,e[27]=u,e[28]=d,e[29]=M,e[30]=E,e[31]=o,e[32]=B):B=e[32];let I;e[33]!==t?(I=t("TTL unit"),e[33]=t,e[34]=I):I=e[34];let O=`${o}-unit`,D;e[35]===Symbol.for("react.memo_cache_sentinel")?(D=(0,l.jsxDEV)(ge,{},void 0,!1),e[35]=D):D=e[35];let i;e[36]!==I||e[37]!==O?(i=(0,l.jsxDEV)(xe,{"aria-label":I,className:"w-[7.5rem]","data-testid":O,children:D},void 0,!1),e[36]=I,e[37]=O,e[38]=i):i=e[38];let m;e[39]!==S?(m=Fe.map(g=>(0,l.jsxDEV)(Ce,{value:g.key,children:S[g.key]},g.key,!1)),e[39]=S,e[40]=m):m=e[40];let K;e[41]!==m?(K=(0,l.jsxDEV)(Ne,{children:m},void 0,!1),e[41]=m,e[42]=K):K=e[42];let T;e[43]!==L||e[44]!==i||e[45]!==K||e[46]!==c?(T=(0,l.jsxDEV)(be,{onValueChange:L,value:c,children:[i,K]},void 0,!0),e[43]=L,e[44]=i,e[45]=K,e[46]=c,e[47]=T):T=e[47];let _;e[48]!==B||e[49]!==T?(_=(0,l.jsxDEV)("div",{className:"flex gap-2",children:[B,T]},void 0,!0),e[48]=B,e[49]=T,e[50]=_):_=e[50];let F;e[51]!==s||e[52]!==d||e[53]!==t||e[54]!==o?(F=d?(0,l.jsxDEV)("p",{className:"text-xs text-destructive","data-testid":`${o}-invalid`,children:t("TTL must be at least 60 seconds.")},void 0,!1):s!==void 0&&(0,l.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:s},void 0,!1),e[51]=s,e[52]=d,e[53]=t,e[54]=o,e[55]=F):F=e[55];let A;return e[56]!==_||e[57]!==F||e[58]!==w?(A=(0,l.jsxDEV)("div",{className:"mb-3 grid gap-1",children:[w,_,F]},void 0,!0),e[56]=_,e[57]=F,e[58]=w,e[59]=A):A=e[59],A},"TtlField"),_e=n(r=>{let e=(0,ee.c)(36),{id:s,invalidTestId:u,onChange:d,testId:f,valid:o,value:t}=r,a=U(),p;e[0]!==t?(p=Te(t),e[0]=t,e[1]=p):p=e[1];let c=p,x;e[2]!==a?(x=a("Metadata (JSON)"),e[2]=a,e[3]=x):x=e[3];let b;e[4]!==s||e[5]!==x?(b=(0,l.jsxDEV)(W,{className:"text-xs",htmlFor:s,children:x},void 0,!1),e[4]=s,e[5]=x,e[6]=b):b=e[6];let M=`${f}-format`,V=c===void 0,L;e[7]!==c||e[8]!==d?(L=n(()=>{c!==void 0&&d(c)},"t6"),e[7]=c,e[8]=d,e[9]=L):L=e[9];let h;e[10]!==a?(h=a("Format JSON"),e[10]=a,e[11]=h):h=e[11];let v;e[12]!==M||e[13]!==V||e[14]!==L||e[15]!==h?(v=(0,l.jsxDEV)($,{"data-testid":M,disabled:V,onClick:L,size:"sm",variant:"outline",children:h},void 0,!1),e[12]=M,e[13]=V,e[14]=L,e[15]=h,e[16]=v):v=e[16];let y;e[17]!==b||e[18]!==v?(y=(0,l.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[b,v]},void 0,!0),e[17]=b,e[18]=v,e[19]=y):y=e[19];let N=!o,C;e[20]!==d?(C=n(E=>{d(E.target.value)},"t11"),e[20]=d,e[21]=C):C=e[21];let S;e[22]!==s||e[23]!==N||e[24]!==C||e[25]!==f||e[26]!==t?(S=(0,l.jsxDEV)(ce,{"aria-invalid":N,className:"min-h-[4rem] font-mono text-xs","data-testid":f,id:s,onChange:C,value:t},void 0,!1),e[22]=s,e[23]=N,e[24]=C,e[25]=f,e[26]=t,e[27]=S):S=e[27];let k;e[28]!==u||e[29]!==a||e[30]!==o?(k=!o&&(0,l.jsxDEV)("p",{className:"text-xs text-destructive","data-testid":u,children:a("Metadata must be valid JSON.")},void 0,!1),e[28]=u,e[29]=a,e[30]=o,e[31]=k):k=e[31];let w;return e[32]!==S||e[33]!==k||e[34]!==y?(w=(0,l.jsxDEV)("div",{className:"mb-3 grid gap-1",children:[y,S,k]},void 0,!0),e[32]=S,e[33]=k,e[34]=y,e[35]=w):w=e[35],w},"MetadataField"),Je={busy:!1,error:null,metadata:"",name:"",ttl:"",value:""},Pe=n((r,e)=>{switch(e.type){case"setField":return{...r,[e.field]:e.value};case"submitFailed":return{...r,busy:!1,error:e.error};case"submitStart":return{...r,busy:!0,error:null};default:return r}},"createReducer"),$e=n(r=>{let e=(0,ee.c)(73),{namespace:s,onCancel:u,onCreated:d}=r,f=Y(),o=U(),[t,a]=(0,J.useReducer)(Pe,Je),p;e[0]!==t.metadata?(p=Ee(t.metadata),e[0]=t.metadata,e[1]=p):p=e[1];let c=p,x;e[2]!==t.ttl?(x=Ke(t.ttl),e[2]=t.ttl,e[3]=x):x=e[3];let b=x,M;e[4]!==c||e[5]!==t.busy||e[6]!==t.name||e[7]!==b?(M=t.name.trim()!==""&&c&&b&&!t.busy,e[4]=c,e[5]=t.busy,e[6]=t.name,e[7]=b,e[8]=M):M=e[8];let V=M,L;e[9]!==V||e[10]!==f||e[11]!==s||e[12]!==d||e[13]!==t.metadata||e[14]!==t.name||e[15]!==t.ttl||e[16]!==t.value?(L=n(()=>{V&&(a({type:"submitStart"}),H((async()=>{try{await f.putKvValue(Ve({metadata:t.metadata,ttl:t.ttl,value:t.value},t.name,s)),d()}catch(j){a({error:z(j),type:"submitFailed"})}})()))},"t4"),e[9]=V,e[10]=f,e[11]=s,e[12]=d,e[13]=t.metadata,e[14]=t.name,e[15]=t.ttl,e[16]=t.value,e[17]=L):L=e[17];let h=L,v;e[18]!==o?(v=o("Key name"),e[18]=o,e[19]=v):v=e[19];let y;e[20]!==v?(y=(0,l.jsxDEV)(W,{className:"text-xs",htmlFor:"kv-create-name",children:v},void 0,!1),e[20]=v,e[21]=y):y=e[21];let N;e[22]===Symbol.for("react.memo_cache_sentinel")?(N=n(j=>{a({field:"name",type:"setField",value:j.target.value})},"t7"),e[22]=N):N=e[22];let C;e[23]!==o?(C=o("Key name"),e[23]=o,e[24]=C):C=e[24];let S;e[25]!==t.name||e[26]!==C?(S=(0,l.jsxDEV)(le,{autoFocus:!0,"data-testid":"kv-create-name",id:"kv-create-name",onChange:N,placeholder:C,value:t.name},void 0,!1),e[25]=t.name,e[26]=C,e[27]=S):S=e[27];let k;e[28]!==y||e[29]!==S?(k=(0,l.jsxDEV)("div",{className:"grid gap-1",children:[y,S]},void 0,!0),e[28]=y,e[29]=S,e[30]=k):k=e[30];let w;e[31]!==o?(w=o("Value"),e[31]=o,e[32]=w):w=e[32];let E;e[33]!==w?(E=(0,l.jsxDEV)(W,{className:"text-xs",htmlFor:"kv-create-value",children:w},void 0,!1),e[33]=w,e[34]=E):E=e[34];let B;e[35]===Symbol.for("react.memo_cache_sentinel")?(B=n(j=>{a({field:"value",type:"setField",value:j.target.value})},"t13"),e[35]=B):B=e[35];let I;e[36]!==t.value?(I=(0,l.jsxDEV)(ce,{className:"min-h-[6rem] font-mono text-xs","data-testid":"kv-create-value",id:"kv-create-value",onChange:B,value:t.value},void 0,!1),e[36]=t.value,e[37]=I):I=e[37];let O;e[38]!==E||e[39]!==I?(O=(0,l.jsxDEV)("div",{className:"grid gap-1",children:[E,I]},void 0,!0),e[38]=E,e[39]=I,e[40]=O):O=e[40];let D=!b,i;e[41]===Symbol.for("react.memo_cache_sentinel")?(i=n(j=>{a({field:"ttl",type:"setField",value:j})},"t17"),e[41]=i):i=e[41];let m;e[42]!==D?(m=(0,l.jsxDEV)(Ie,{id:"kv-create-ttl",invalid:D,onChange:i,testId:"kv-create-ttl"},void 0,!1),e[42]=D,e[43]=m):m=e[43];let K;e[44]===Symbol.for("react.memo_cache_sentinel")?(K=n(j=>{a({field:"metadata",type:"setField",value:j})},"t19"),e[44]=K):K=e[44];let T;e[45]!==c||e[46]!==t.metadata?(T=(0,l.jsxDEV)(_e,{id:"kv-create-metadata",invalidTestId:"kv-create-metadata-invalid",onChange:K,testId:"kv-create-metadata",valid:c,value:t.metadata},void 0,!1),e[45]=c,e[46]=t.metadata,e[47]=T):T=e[47];let _=!V,F;e[48]!==t.busy||e[49]!==o?(F=t.busy?o("Creating\u2026"):o("Create key"),e[48]=t.busy,e[49]=o,e[50]=F):F=e[50];let A;e[51]!==h||e[52]!==_||e[53]!==F?(A=(0,l.jsxDEV)($,{"data-testid":"kv-create-submit",disabled:_,onClick:h,children:F},void 0,!1),e[51]=h,e[52]=_,e[53]=F,e[54]=A):A=e[54];let g=t.busy,P;e[55]!==o?(P=o("Cancel"),e[55]=o,e[56]=P):P=e[56];let R;e[57]!==u||e[58]!==t.busy||e[59]!==P?(R=(0,l.jsxDEV)($,{"data-testid":"kv-create-cancel",disabled:g,onClick:u,variant:"outline",children:P},void 0,!1),e[57]=u,e[58]=t.busy,e[59]=P,e[60]=R):R=e[60];let Z;e[61]!==A||e[62]!==R?(Z=(0,l.jsxDEV)("div",{className:"flex flex-wrap gap-2",children:[A,R]},void 0,!0),e[61]=A,e[62]=R,e[63]=Z):Z=e[63];let G;e[64]!==t.error?(G=t.error!==null&&(0,l.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"kv-create-error",role:"alert",children:t.error},void 0,!1),e[64]=t.error,e[65]=G):G=e[65];let te;return e[66]!==k||e[67]!==O||e[68]!==m||e[69]!==T||e[70]!==Z||e[71]!==G?(te=(0,l.jsxDEV)("div",{className:"grid gap-3 px-4 pb-4","data-testid":"kv-create-form",children:[k,O,m,T,Z,G]},void 0,!0),e[66]=k,e[67]=O,e[68]=m,e[69]=T,e[70]=Z,e[71]=G,e[72]=te):te=e[72],te},"KvCreateForm"),je={busy:"",editedMetadata:"",editedTtl:"",editedValue:"",loadError:null,loading:!0,value:null,writeError:null},He=n((r,e)=>{switch(e.type){case"deleteStart":return{...r,busy:"deleting",writeError:null};case"editMetadata":return{...r,editedMetadata:e.value};case"editTtl":return{...r,editedTtl:e.value};case"editValue":return{...r,editedValue:e.value};case"loaded":return{...r,editedMetadata:e.metadata===null||e.metadata===void 0?"":JSON.stringify(e.metadata,null,2),editedValue:e.value??"",loading:!1,value:e.value};case"loadFailed":return{...r,loadError:e.error,loading:!1};case"saveOk":return{...r,busy:"",value:r.editedValue};case"saveStart":return{...r,busy:"saving",writeError:null};case"writeFailed":return{...r,busy:"",writeError:e.error};default:return r}},"valueReducer"),Re=n(r=>{let e=(0,ee.c)(67),{expiration:s,keyName:u,namespace:d,onDeleted:f}=r,o=Y(),t=U(),[a,p]=(0,J.useReducer)(He,je),c,x;e[0]!==o||e[1]!==u||e[2]!==d?(c=n(()=>{let g={cancelled:!1};return H((async()=>{try{let P=await o.getKvValue({key:u,namespace:d});g.cancelled||p({metadata:P.metadata,type:"loaded",value:P.value})}catch(P){let R=P;g.cancelled||p({error:z(R),type:"loadFailed"})}})()),()=>{g.cancelled=!0}},"t1"),x=[o,d,u],e[0]=o,e[1]=u,e[2]=d,e[3]=c,e[4]=x):(c=e[3],x=e[4]),(0,J.useEffect)(c,x);let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=n(g=>{p({type:"editValue",value:g.target.value})},"t3"),e[5]=b):b=e[5];let M=b,V;e[6]===Symbol.for("react.memo_cache_sentinel")?(V=n(g=>{p({type:"editMetadata",value:g})},"t4"),e[6]=V):V=e[6];let L=V,h;e[7]!==a.editedValue?(h=Te(a.editedValue),e[7]=a.editedValue,e[8]=h):h=e[8];let v=h,y;e[9]!==a.editedMetadata?(y=Ee(a.editedMetadata),e[9]=a.editedMetadata,e[10]=y):y=e[10];let N=y,C;e[11]!==a.editedTtl?(C=Ke(a.editedTtl),e[11]=a.editedTtl,e[12]=C):C=e[12];let S=C,k;e[13]!==v?(k=n(()=>{v!==void 0&&p({type:"editValue",value:v})},"t8"),e[13]=v,e[14]=k):k=e[14];let w=k,E;e[15]!==o||e[16]!==s||e[17]!==u||e[18]!==N||e[19]!==d||e[20]!==a.editedMetadata||e[21]!==a.editedTtl||e[22]!==a.editedValue||e[23]!==t?(E=n(()=>{if(!N){p({error:t("Metadata must be valid JSON."),type:"writeFailed"});return}p({type:"saveStart"}),H((async()=>{try{await o.putKvValue(Ve({metadata:a.editedMetadata,ttl:a.editedTtl,value:a.editedValue},u,d,s)),p({type:"saveOk"})}catch(g){p({error:z(g),type:"writeFailed"})}})())},"t9"),e[15]=o,e[16]=s,e[17]=u,e[18]=N,e[19]=d,e[20]=a.editedMetadata,e[21]=a.editedTtl,e[22]=a.editedValue,e[23]=t,e[24]=E):E=e[24];let B=E,I;e[25]!==o||e[26]!==u||e[27]!==d||e[28]!==f?(I=n(()=>{p({type:"deleteStart"}),H((async()=>{try{await o.deleteKvKey({key:u,namespace:d}),f(u)}catch(g){p({error:z(g),type:"writeFailed"})}})())},"t10"),e[25]=o,e[26]=u,e[27]=d,e[28]=f,e[29]=I):I=e[29];let O=I,D;e[30]!==u?(D=n(()=>{ie(u)},"t11"),e[30]=u,e[31]=D):D=e[31];let i;e[32]!==t?(i=t("Copy key"),e[32]=t,e[33]=i):i=e[33];let m;e[34]!==D||e[35]!==i?(m=(0,l.jsxDEV)("div",{className:"mb-2 flex justify-end",children:(0,l.jsxDEV)($,{"data-testid":"kv-copy-key-btn",onClick:D,size:"sm",variant:"outline",children:i},void 0,!1)},void 0,!1),e[34]=D,e[35]=i,e[36]=m):m=e[36];let K;e[37]!==a.loadError?(K=a.loadError!==null&&(0,l.jsxDEV)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-value-error",role:"alert",children:a.loadError},void 0,!1),e[37]=a.loadError,e[38]=K):K=e[38];let T;e[39]!==a.loading||e[40]!==t?(T=a.loading&&(0,l.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-value-loading",children:t("Loading\u2026")},void 0,!1),e[39]=a.loading,e[40]=t,e[41]=T):T=e[41];let _;e[42]!==v||e[43]!==N||e[44]!==O||e[45]!==w||e[46]!==B||e[47]!==a.busy||e[48]!==a.editedMetadata||e[49]!==a.editedValue||e[50]!==a.loading||e[51]!==a.value||e[52]!==a.writeError||e[53]!==t||e[54]!==S?(_=!a.loading&&a.value!==null&&(0,l.jsxDEV)(l.Fragment,{children:[(0,l.jsxDEV)("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[(0,l.jsxDEV)(W,{className:"text-xs",htmlFor:"kv-value-editor",children:t("Value")},void 0,!1),v!==void 0&&(0,l.jsxDEV)(he,{variant:"secondary",children:t("JSON")},void 0,!1),(0,l.jsxDEV)("span",{className:"ml-auto text-xs tabular-nums text-muted-foreground","data-testid":"kv-value-size",children:ke(Ae(a.editedValue))},void 0,!1)]},void 0,!0),(0,l.jsxDEV)("textarea",{"aria-label":t("KV value"),className:"mb-2 min-h-[8rem] w-full rounded border border-border bg-muted/30 p-2 font-mono text-xs","data-testid":"kv-value-editor",id:"kv-value-editor",onChange:M,value:a.editedValue},void 0,!1),(0,l.jsxDEV)("div",{className:"mb-3 flex flex-wrap gap-2",children:[(0,l.jsxDEV)($,{"data-testid":"kv-format-btn",disabled:v===void 0,onClick:w,size:"sm",variant:"outline",children:t("Format JSON")},void 0,!1),(0,l.jsxDEV)($,{"data-testid":"kv-copy-value-btn",onClick:n(()=>{ie(a.editedValue)},"onClick"),size:"sm",variant:"outline",children:t("Copy value")},void 0,!1)]},void 0,!0),(0,l.jsxDEV)(Ie,{helper:t("Leave blank to keep the current expiration."),id:"kv-ttl-input",invalid:!S,onChange:n(g=>{p({type:"editTtl",value:g})},"onChange"),testId:"kv-ttl-input"},void 0,!1),(0,l.jsxDEV)(_e,{id:"kv-metadata-editor",invalidTestId:"kv-metadata-invalid",onChange:L,testId:"kv-metadata-editor",valid:N,value:a.editedMetadata},void 0,!1),(0,l.jsxDEV)("div",{className:"flex flex-wrap gap-2",children:[(0,l.jsxDEV)($,{"data-testid":"kv-save-btn",disabled:a.busy!==""||!N||!S,onClick:B,children:a.busy==="saving"?t("Saving\u2026"):t("Save")},void 0,!1),(0,l.jsxDEV)($,{"data-testid":"kv-delete-btn",disabled:a.busy!=="",onClick:O,variant:"destructive",children:a.busy==="deleting"?t("Deleting\u2026"):t("Delete")},void 0,!1)]},void 0,!0),a.writeError!==null&&(0,l.jsxDEV)("p",{className:"mt-2 text-sm text-destructive","data-testid":"kv-save-error",role:"alert",children:a.writeError},void 0,!1)]},void 0,!0),e[42]=v,e[43]=N,e[44]=O,e[45]=w,e[46]=B,e[47]=a.busy,e[48]=a.editedMetadata,e[49]=a.editedValue,e[50]=a.loading,e[51]=a.value,e[52]=a.writeError,e[53]=t,e[54]=S,e[55]=_):_=e[55];let F;e[56]!==a.loadError||e[57]!==a.loading||e[58]!==a.value||e[59]!==t?(F=!a.loading&&a.value===null&&a.loadError===null&&(0,l.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-absent",children:t("Key is absent or has no value.")},void 0,!1),e[56]=a.loadError,e[57]=a.loading,e[58]=a.value,e[59]=t,e[60]=F):F=e[60];let A;return e[61]!==m||e[62]!==K||e[63]!==T||e[64]!==_||e[65]!==F?(A=(0,l.jsxDEV)("div",{className:"px-4 pb-4","data-testid":"kv-value-section",children:[m,K,T,_,F]},void 0,!0),e[61]=m,e[62]=K,e[63]=T,e[64]=_,e[65]=F,e[66]=A):A=e[66],A},"KvValueEditor"),we=100,ze={appliedPrefix:"",bulk:[],bulkBusy:!1,bulkError:null,cursor:null,keys:null,listComplete:!1,loadError:null,loading:!1,prefixInput:"",reloadNonce:0,selectedKey:null},Ue=n((r,e)=>{switch(e.type){case"appendPage":return{...r,cursor:e.cursor,keys:[...r.keys??[],...e.keys],listComplete:e.listComplete,loading:!1};case"applyFilter":return{...r,appliedPrefix:r.prefixInput,bulk:[],bulkError:null,cursor:null,keys:null,listComplete:!1,selectedKey:null};case"bulkDeleted":{let s=new Set(e.deleted);return{...r,bulk:r.bulk.filter(u=>!s.has(u)),bulkBusy:!1,bulkError:e.error,keys:r.keys===null?null:r.keys.filter(u=>!s.has(u.name)),selectedKey:r.selectedKey!==null&&s.has(r.selectedKey)?null:r.selectedKey}}case"bulkDeleteStart":return{...r,bulkBusy:!0,bulkError:null};case"firstPage":return{...r,cursor:e.cursor,keys:e.keys,listComplete:e.listComplete,loading:!1};case"keyDeleted":return{...r,bulk:r.bulk.filter(s=>s!==e.name),keys:r.keys===null?null:r.keys.filter(s=>s.name!==e.name),selectedKey:null};case"loadFailed":return{...r,loadError:e.error,loading:!1};case"loadStart":return{...r,loadError:null,loading:!0};case"prefixInput":return{...r,prefixInput:e.value};case"reload":return{...r,bulk:[],bulkError:null,reloadNonce:r.reloadNonce+1,selectedKey:null};case"selectKey":return{...r,selectedKey:e.name};case"toggleAllBulk":return{...r,bulk:e.names};case"toggleBulk":return{...r,bulk:r.bulk.includes(e.name)?r.bulk.filter(s=>s!==e.name):[...r.bulk,e.name]};default:return r}},"keyListReducer"),Ze=n(({namespace:r})=>{let e=Y(),s=U(),[u,d]=(0,J.useReducer)(Ue,ze),{appliedPrefix:f,bulk:o,bulkBusy:t,bulkError:a,cursor:p,keys:c,listComplete:x,loadError:b,loading:M,prefixInput:V,reloadNonce:L,selectedKey:h}=u,[v,y]=(0,J.useState)(!1);(0,J.useEffect)(()=>{let i={cancelled:!1};return H((async()=>{d({type:"loadStart"});try{let m=await e.listKvKeys({limit:we,namespace:r,prefix:f===""?void 0:f});i.cancelled||d({cursor:m.cursor??null,keys:m.keys,listComplete:m.listComplete,type:"firstPage"})}catch(m){i.cancelled||d({error:z(m),type:"loadFailed"})}})()),()=>{i.cancelled=!0}},[e,r,f,L]);let N=n(i=>{d({type:"prefixInput",value:i.target.value})},"onPrefixChange"),C=n(()=>{d({type:"applyFilter"})},"onFilter"),S=n(i=>{d({name:i.currentTarget.dataset.key??null,type:"selectKey"})},"onSelectKey"),k=n(()=>{p!==null&&(d({type:"loadStart"}),H((async()=>{try{let i=await e.listKvKeys({cursor:p,limit:we,namespace:r,prefix:f===""?void 0:f});d({cursor:i.cursor??null,keys:i.keys,listComplete:i.listComplete,type:"appendPage"})}catch(i){d({error:z(i),type:"loadFailed"})}})()))},"onLoadMore"),w=n(i=>{d({name:i,type:"keyDeleted"})},"onKeyDeleted"),E=n(i=>{d({name:i,type:"toggleBulk"})},"onToggleBulk"),B=n(i=>{d({names:i&&c!==null?c.map(m=>m.name):[],type:"toggleAllBulk"})},"onToggleAll"),I=n(()=>{if(o.length===0)return;let i=[...o];d({type:"bulkDeleteStart"}),H((async()=>{let m=await Promise.allSettled(i.map(_=>e.deleteKvKey({key:_,namespace:r}))),K=i.filter((_,F)=>m[F]?.status==="fulfilled"),T=i.length-K.length;d({deleted:K,error:T>0?s("Failed to delete {count} keys.",{count:T}):null,type:"bulkDeleted"})})())},"onBulkDelete"),O=n(()=>{y(!1),d({type:"reload"})},"onCreated"),D=c!==null&&c.length>0&&o.length===c.length;return(0,l.jsxDEV)(l.Fragment,{children:[(0,l.jsxDEV)("section",{className:"border border-border bg-card p-3","data-testid":"kv-keys-section",children:[(0,l.jsxDEV)("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[(0,l.jsxDEV)(le,{"aria-label":s("Filter keys by prefix"),className:"min-w-[16rem] flex-1","data-testid":"kv-prefix-input",onChange:N,placeholder:s("Filter by prefix\u2026"),value:V},void 0,!1),(0,l.jsxDEV)($,{"data-testid":"kv-filter-btn",disabled:M,onClick:C,children:s("Filter")},void 0,!1),(0,l.jsxDEV)($,{"data-testid":"kv-new-key-btn",onClick:n(()=>{y(i=>!i)},"onClick"),variant:"outline",children:s("New key")},void 0,!1),o.length>0&&(0,l.jsxDEV)($,{"data-testid":"kv-bulk-delete-btn",disabled:t,onClick:I,variant:"destructive",children:t?s("Deleting\u2026"):s("Delete {count}",{count:o.length})},void 0,!1)]},void 0,!0),a!==null&&(0,l.jsxDEV)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-bulk-error",role:"alert",children:a},void 0,!1),b!==null&&(0,l.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"kv-keys-error",role:"alert",children:b},void 0,!1),c!==null&&c.length===0&&!M&&(0,l.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-no-keys",children:s("No keys.")},void 0,!1),c!==null&&c.length>0&&(0,l.jsxDEV)(re,{className:"overflow-hidden py-0",children:(0,l.jsxDEV)(se,{className:"px-0",children:(0,l.jsxDEV)(de,{"data-testid":"kv-key-table",children:[(0,l.jsxDEV)(ne,{children:(0,l.jsxDEV)(q,{children:[(0,l.jsxDEV)(Q,{className:"w-10",children:(0,l.jsxDEV)(ue,{"aria-label":s("Select all"),checked:D,"data-testid":"kv-select-all",onCheckedChange:B},void 0,!1)},void 0,!1),(0,l.jsxDEV)(Q,{children:s("Key")},void 0,!1),(0,l.jsxDEV)(Q,{children:s("Expiration")},void 0,!1)]},void 0,!0)},void 0,!1),(0,l.jsxDEV)(oe,{children:c.map(i=>(0,l.jsxDEV)(q,{className:i.name===h?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-key":i.name,"data-testid":`kv-key-row-${i.name}`,onClick:S,children:[(0,l.jsxDEV)(X,{onClick:n(m=>{m.stopPropagation()},"onClick"),children:(0,l.jsxDEV)(ue,{"aria-label":s("Select {name}",{name:i.name}),checked:o.includes(i.name),"data-testid":`kv-select-${i.name}`,onCheckedChange:n(()=>{E(i.name)},"onCheckedChange")},void 0,!1)},void 0,!1),(0,l.jsxDEV)(X,{className:"font-mono text-xs",children:i.name},void 0,!1),(0,l.jsxDEV)(X,{className:"tabular-nums text-xs",children:Oe(i.expiration)},void 0,!1)]},i.name,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),!x&&p!==null&&(0,l.jsxDEV)("div",{className:"mt-2",children:(0,l.jsxDEV)($,{"data-testid":"kv-load-more",disabled:M,onClick:k,variant:"outline",children:s(M?"Loading\u2026":"Load more")},void 0,!1)},void 0,!1)]},void 0,!0),(0,l.jsxDEV)(me,{onOpenChange:n(i=>{i||y(!1)},"onOpenChange"),open:v,children:(0,l.jsxDEV)(ve,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-create-sheet",side:"right",children:[(0,l.jsxDEV)(fe,{children:(0,l.jsxDEV)(pe,{children:s("New key")},void 0,!1)},void 0,!1),(0,l.jsxDEV)($e,{namespace:r,onCancel:n(()=>{y(!1)},"onCancel"),onCreated:O},void 0,!1)]},void 0,!0)},void 0,!1),(0,l.jsxDEV)(me,{onOpenChange:n(i=>{i||d({name:null,type:"selectKey"})},"onOpenChange"),open:h!==null,children:(0,l.jsxDEV)(ve,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-editor-sheet",side:"right",children:[(0,l.jsxDEV)(fe,{children:(0,l.jsxDEV)(pe,{className:"truncate font-mono text-xs",children:h},void 0,!1)},void 0,!1),h!==null&&(0,l.jsxDEV)(Re,{expiration:c?.find(i=>i.name===h)?.expiration,keyName:h,namespace:r,onDeleted:w},`${r}:${h}`,!1)]},void 0,!0)},void 0,!1)]},void 0,!0)},"KvKeyList"),ot=n(({loadNamespaces:r}={})=>{let e=Y(),s=U(),[u,d]=(0,J.useState)(null),[f,o]=(0,J.useState)(null),[t,a]=(0,J.useState)(null);(0,J.useEffect)(()=>{let c={cancelled:!1};return H((async()=>{try{let x=await(r??(()=>e.listKvNamespaces()))();c.cancelled||(d(x),o(null),a(b=>b??x[0]?.binding??null))}catch(x){c.cancelled||(d(null),o(z(x)))}})()),()=>{c.cancelled=!0}},[e,r]);let p=n(c=>{a(c.currentTarget.dataset.ns??null)},"onSelectNs");return(0,l.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-kv-browser",children:[f!==null&&(0,l.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"kv-ns-error",role:"alert",children:f},void 0,!1),u!==null&&u.length===0&&(0,l.jsxDEV)(ye,{description:s("Add a kv_namespaces binding to wrangler.jsonc \u2014 it appears here automatically, no wiring needed."),icon:(0,l.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,l.jsxDEV)("path",{d:"M5 5h14v4H5V5Zm0 5h14v4H5v-4Zm0 5h14v4H5v-4Z"},void 0,!1)},void 0,!1),testId:"kv-empty",title:s("No KV namespaces.")},void 0,!1),u!==null&&u.length>0&&(0,l.jsxDEV)(re,{className:"overflow-hidden py-0",children:(0,l.jsxDEV)(se,{className:"px-0",children:(0,l.jsxDEV)(de,{"data-testid":"kv-namespace-table",children:[(0,l.jsxDEV)(ne,{children:(0,l.jsxDEV)(q,{children:(0,l.jsxDEV)(Q,{children:s("Namespace")},void 0,!1)},void 0,!1)},void 0,!1),(0,l.jsxDEV)(oe,{children:u.map(c=>(0,l.jsxDEV)(q,{className:c.binding===t?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-ns":c.binding,"data-testid":`kv-ns-row-${c.binding}`,onClick:p,children:(0,l.jsxDEV)(X,{className:"font-mono text-xs",children:c.binding},void 0,!1)},c.binding,!1))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),t!==null&&(0,l.jsxDEV)(Ze,{namespace:t},t,!1)]},void 0,!0)},"KvBrowser");export{ot as KvBrowser};
1
+ import{a as be,b as ge,c as xe,d as Ne,e as Ce}from"./chunk-LI43EKM6.js";import"./chunk-DWDILV2E.js";import{a as ue}from"./chunk-BACPICH6.js";import"./chunk-QBAT52GB.js";import"./chunk-QAFAJBAW.js";import{g as me,h as ve,i as fe,j as pe}from"./chunk-KTK3V4DC.js";import"./chunk-ZPUO7FNI.js";import"./chunk-764T6X6X.js";import"./chunk-XUGSA2NG.js";import"./chunk-5OIBXYZM.js";import"./chunk-UII66UVF.js";import"./chunk-7TJJXVSE.js";import"./chunk-SVR644RF.js";import"./chunk-KEGAWN6Y.js";import{a as de,b as ne,c as oe,d as q,e as Q,f as X}from"./chunk-GTM65MVX.js";import{a as ce}from"./chunk-VLXV72QE.js";import{a as W}from"./chunk-JSEXCW5Q.js";import"./chunk-KZ6INM5M.js";import"./chunk-4QHKBC77.js";import{R as le}from"./chunk-3CJW6NWG.js";import{c as $}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import"./chunk-AQGOX5DK.js";import{a as ye}from"./chunk-TAD43CG5.js";import"./chunk-DVKPRFIJ.js";import{a as re,e as se}from"./chunk-SEU5V7I6.js";import{b as he}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as Y}from"./chunk-X7MMBSNW.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as U,g as z,k as H,l as ie,m as ke}from"./chunk-PVZI3CXP.js";import"./chunk-GMSGZDDH.js";import{a as n,e as ae,f as Me,g as Le,h as Be}from"./chunk-RRCPZMC2.js";var J=ae(Me(),1);var ee=ae(Le(),1);var l=ae(Be(),1);var De=n(r=>{let e=r.trim();if(e==="")return;let s=Number(e);return Number.isFinite(s)&&s>0?Math.floor(s):void 0},"parseTtl"),Oe=n(r=>r===void 0?"\u2014":new Date(r*1e3).toISOString(),"formatExpiration"),Ae=n(r=>new TextEncoder().encode(r).length,"byteLength"),Te=n(r=>{if(r.trim()!=="")try{return JSON.stringify(JSON.parse(r),void 0,2)}catch{return}},"tryFormatJson"),Ee=n(r=>{if(r.trim()==="")return!0;try{return JSON.parse(r),!0}catch{return!1}},"isJsonOrEmpty"),Fe=[{key:"seconds",seconds:1},{key:"minutes",seconds:60},{key:"hours",seconds:3600},{key:"days",seconds:86400}],Se=n((r,e)=>{let s=r.trim();if(s==="")return"";let u=Number(s),d=Fe.find(f=>f.key===e)?.seconds??1;return Number.isFinite(u)&&u>0?String(Math.round(u*d)):s},"ttlToSeconds"),Ke=n(r=>{let e=r.trim();if(e==="")return!0;let s=Number(e);return Number.isInteger(s)&&s>=60},"isTtlValid"),Ve=n((r,e,s,u)=>{let d=De(r.ttl);return{expiration:d===void 0?u:void 0,expirationTtl:d,key:e,metadata:r.metadata.trim()===""?void 0:JSON.parse(r.metadata),namespace:s,value:r.value}},"buildKvPutOptions"),Ie=n(r=>{let e=(0,ee.c)(60),{helper:s,id:u,invalid:d,onChange:f,testId:o}=r,t=U(),[a,p]=(0,J.useState)(""),[c,x]=(0,J.useState)("seconds"),b;e[0]!==f||e[1]!==c?(b=n(g=>{p(g.target.value),f(Se(g.target.value,c))},"t1"),e[0]=f,e[1]=c,e[2]=b):b=e[2];let M=b,V;e[3]!==a||e[4]!==f?(V=n(g=>{g!==null&&(x(g),f(Se(a,g)))},"t2"),e[3]=a,e[4]=f,e[5]=V):V=e[5];let L=V,h;e[6]!==t?(h=t("days"),e[6]=t,e[7]=h):h=e[7];let v;e[8]!==t?(v=t("hours"),e[8]=t,e[9]=v):v=e[9];let y;e[10]!==t?(y=t("minutes"),e[10]=t,e[11]=y):y=e[11];let N;e[12]!==t?(N=t("seconds"),e[12]=t,e[13]=N):N=e[13];let C;e[14]!==h||e[15]!==v||e[16]!==y||e[17]!==N?(C={days:h,hours:v,minutes:y,seconds:N},e[14]=h,e[15]=v,e[16]=y,e[17]=N,e[18]=C):C=e[18];let S=C,k;e[19]!==t?(k=t("Expires after"),e[19]=t,e[20]=k):k=e[20];let w;e[21]!==u||e[22]!==k?(w=(0,l.jsxDEV)(W,{className:"text-xs",htmlFor:u,children:k},void 0,!1),e[21]=u,e[22]=k,e[23]=w):w=e[23];let E;e[24]!==t?(E=t("No expiration"),e[24]=t,e[25]=E):E=e[25];let B;e[26]!==a||e[27]!==u||e[28]!==d||e[29]!==M||e[30]!==E||e[31]!==o?(B=(0,l.jsxDEV)(le,{"aria-invalid":d,className:"flex-1","data-testid":o,id:u,inputMode:"numeric",onChange:M,placeholder:E,value:a},void 0,!1),e[26]=a,e[27]=u,e[28]=d,e[29]=M,e[30]=E,e[31]=o,e[32]=B):B=e[32];let I;e[33]!==t?(I=t("TTL unit"),e[33]=t,e[34]=I):I=e[34];let O=`${o}-unit`,D;e[35]===Symbol.for("react.memo_cache_sentinel")?(D=(0,l.jsxDEV)(ge,{},void 0,!1),e[35]=D):D=e[35];let i;e[36]!==I||e[37]!==O?(i=(0,l.jsxDEV)(xe,{"aria-label":I,className:"w-[7.5rem]","data-testid":O,children:D},void 0,!1),e[36]=I,e[37]=O,e[38]=i):i=e[38];let m;e[39]!==S?(m=Fe.map(g=>(0,l.jsxDEV)(Ce,{value:g.key,children:S[g.key]},g.key,!1)),e[39]=S,e[40]=m):m=e[40];let K;e[41]!==m?(K=(0,l.jsxDEV)(Ne,{children:m},void 0,!1),e[41]=m,e[42]=K):K=e[42];let T;e[43]!==L||e[44]!==i||e[45]!==K||e[46]!==c?(T=(0,l.jsxDEV)(be,{onValueChange:L,value:c,children:[i,K]},void 0,!0),e[43]=L,e[44]=i,e[45]=K,e[46]=c,e[47]=T):T=e[47];let _;e[48]!==B||e[49]!==T?(_=(0,l.jsxDEV)("div",{className:"flex gap-2",children:[B,T]},void 0,!0),e[48]=B,e[49]=T,e[50]=_):_=e[50];let F;e[51]!==s||e[52]!==d||e[53]!==t||e[54]!==o?(F=d?(0,l.jsxDEV)("p",{className:"text-xs text-destructive","data-testid":`${o}-invalid`,children:t("TTL must be at least 60 seconds.")},void 0,!1):s!==void 0&&(0,l.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:s},void 0,!1),e[51]=s,e[52]=d,e[53]=t,e[54]=o,e[55]=F):F=e[55];let A;return e[56]!==_||e[57]!==F||e[58]!==w?(A=(0,l.jsxDEV)("div",{className:"mb-3 grid gap-1",children:[w,_,F]},void 0,!0),e[56]=_,e[57]=F,e[58]=w,e[59]=A):A=e[59],A},"TtlField"),_e=n(r=>{let e=(0,ee.c)(36),{id:s,invalidTestId:u,onChange:d,testId:f,valid:o,value:t}=r,a=U(),p;e[0]!==t?(p=Te(t),e[0]=t,e[1]=p):p=e[1];let c=p,x;e[2]!==a?(x=a("Metadata (JSON)"),e[2]=a,e[3]=x):x=e[3];let b;e[4]!==s||e[5]!==x?(b=(0,l.jsxDEV)(W,{className:"text-xs",htmlFor:s,children:x},void 0,!1),e[4]=s,e[5]=x,e[6]=b):b=e[6];let M=`${f}-format`,V=c===void 0,L;e[7]!==c||e[8]!==d?(L=n(()=>{c!==void 0&&d(c)},"t6"),e[7]=c,e[8]=d,e[9]=L):L=e[9];let h;e[10]!==a?(h=a("Format JSON"),e[10]=a,e[11]=h):h=e[11];let v;e[12]!==M||e[13]!==V||e[14]!==L||e[15]!==h?(v=(0,l.jsxDEV)($,{"data-testid":M,disabled:V,onClick:L,size:"sm",variant:"outline",children:h},void 0,!1),e[12]=M,e[13]=V,e[14]=L,e[15]=h,e[16]=v):v=e[16];let y;e[17]!==b||e[18]!==v?(y=(0,l.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[b,v]},void 0,!0),e[17]=b,e[18]=v,e[19]=y):y=e[19];let N=!o,C;e[20]!==d?(C=n(E=>{d(E.target.value)},"t11"),e[20]=d,e[21]=C):C=e[21];let S;e[22]!==s||e[23]!==N||e[24]!==C||e[25]!==f||e[26]!==t?(S=(0,l.jsxDEV)(ce,{"aria-invalid":N,className:"min-h-[4rem] font-mono text-xs","data-testid":f,id:s,onChange:C,value:t},void 0,!1),e[22]=s,e[23]=N,e[24]=C,e[25]=f,e[26]=t,e[27]=S):S=e[27];let k;e[28]!==u||e[29]!==a||e[30]!==o?(k=!o&&(0,l.jsxDEV)("p",{className:"text-xs text-destructive","data-testid":u,children:a("Metadata must be valid JSON.")},void 0,!1),e[28]=u,e[29]=a,e[30]=o,e[31]=k):k=e[31];let w;return e[32]!==S||e[33]!==k||e[34]!==y?(w=(0,l.jsxDEV)("div",{className:"mb-3 grid gap-1",children:[y,S,k]},void 0,!0),e[32]=S,e[33]=k,e[34]=y,e[35]=w):w=e[35],w},"MetadataField"),Je={busy:!1,error:null,metadata:"",name:"",ttl:"",value:""},Pe=n((r,e)=>{switch(e.type){case"setField":return{...r,[e.field]:e.value};case"submitFailed":return{...r,busy:!1,error:e.error};case"submitStart":return{...r,busy:!0,error:null};default:return r}},"createReducer"),$e=n(r=>{let e=(0,ee.c)(73),{namespace:s,onCancel:u,onCreated:d}=r,f=Y(),o=U(),[t,a]=(0,J.useReducer)(Pe,Je),p;e[0]!==t.metadata?(p=Ee(t.metadata),e[0]=t.metadata,e[1]=p):p=e[1];let c=p,x;e[2]!==t.ttl?(x=Ke(t.ttl),e[2]=t.ttl,e[3]=x):x=e[3];let b=x,M;e[4]!==c||e[5]!==t.busy||e[6]!==t.name||e[7]!==b?(M=t.name.trim()!==""&&c&&b&&!t.busy,e[4]=c,e[5]=t.busy,e[6]=t.name,e[7]=b,e[8]=M):M=e[8];let V=M,L;e[9]!==V||e[10]!==f||e[11]!==s||e[12]!==d||e[13]!==t.metadata||e[14]!==t.name||e[15]!==t.ttl||e[16]!==t.value?(L=n(()=>{V&&(a({type:"submitStart"}),H((async()=>{try{await f.putKvValue(Ve({metadata:t.metadata,ttl:t.ttl,value:t.value},t.name,s)),d()}catch(j){a({error:z(j),type:"submitFailed"})}})()))},"t4"),e[9]=V,e[10]=f,e[11]=s,e[12]=d,e[13]=t.metadata,e[14]=t.name,e[15]=t.ttl,e[16]=t.value,e[17]=L):L=e[17];let h=L,v;e[18]!==o?(v=o("Key name"),e[18]=o,e[19]=v):v=e[19];let y;e[20]!==v?(y=(0,l.jsxDEV)(W,{className:"text-xs",htmlFor:"kv-create-name",children:v},void 0,!1),e[20]=v,e[21]=y):y=e[21];let N;e[22]===Symbol.for("react.memo_cache_sentinel")?(N=n(j=>{a({field:"name",type:"setField",value:j.target.value})},"t7"),e[22]=N):N=e[22];let C;e[23]!==o?(C=o("Key name"),e[23]=o,e[24]=C):C=e[24];let S;e[25]!==t.name||e[26]!==C?(S=(0,l.jsxDEV)(le,{autoFocus:!0,"data-testid":"kv-create-name",id:"kv-create-name",onChange:N,placeholder:C,value:t.name},void 0,!1),e[25]=t.name,e[26]=C,e[27]=S):S=e[27];let k;e[28]!==y||e[29]!==S?(k=(0,l.jsxDEV)("div",{className:"grid gap-1",children:[y,S]},void 0,!0),e[28]=y,e[29]=S,e[30]=k):k=e[30];let w;e[31]!==o?(w=o("Value"),e[31]=o,e[32]=w):w=e[32];let E;e[33]!==w?(E=(0,l.jsxDEV)(W,{className:"text-xs",htmlFor:"kv-create-value",children:w},void 0,!1),e[33]=w,e[34]=E):E=e[34];let B;e[35]===Symbol.for("react.memo_cache_sentinel")?(B=n(j=>{a({field:"value",type:"setField",value:j.target.value})},"t13"),e[35]=B):B=e[35];let I;e[36]!==t.value?(I=(0,l.jsxDEV)(ce,{className:"min-h-[6rem] font-mono text-xs","data-testid":"kv-create-value",id:"kv-create-value",onChange:B,value:t.value},void 0,!1),e[36]=t.value,e[37]=I):I=e[37];let O;e[38]!==E||e[39]!==I?(O=(0,l.jsxDEV)("div",{className:"grid gap-1",children:[E,I]},void 0,!0),e[38]=E,e[39]=I,e[40]=O):O=e[40];let D=!b,i;e[41]===Symbol.for("react.memo_cache_sentinel")?(i=n(j=>{a({field:"ttl",type:"setField",value:j})},"t17"),e[41]=i):i=e[41];let m;e[42]!==D?(m=(0,l.jsxDEV)(Ie,{id:"kv-create-ttl",invalid:D,onChange:i,testId:"kv-create-ttl"},void 0,!1),e[42]=D,e[43]=m):m=e[43];let K;e[44]===Symbol.for("react.memo_cache_sentinel")?(K=n(j=>{a({field:"metadata",type:"setField",value:j})},"t19"),e[44]=K):K=e[44];let T;e[45]!==c||e[46]!==t.metadata?(T=(0,l.jsxDEV)(_e,{id:"kv-create-metadata",invalidTestId:"kv-create-metadata-invalid",onChange:K,testId:"kv-create-metadata",valid:c,value:t.metadata},void 0,!1),e[45]=c,e[46]=t.metadata,e[47]=T):T=e[47];let _=!V,F;e[48]!==t.busy||e[49]!==o?(F=t.busy?o("Creating\u2026"):o("Create key"),e[48]=t.busy,e[49]=o,e[50]=F):F=e[50];let A;e[51]!==h||e[52]!==_||e[53]!==F?(A=(0,l.jsxDEV)($,{"data-testid":"kv-create-submit",disabled:_,onClick:h,children:F},void 0,!1),e[51]=h,e[52]=_,e[53]=F,e[54]=A):A=e[54];let g=t.busy,P;e[55]!==o?(P=o("Cancel"),e[55]=o,e[56]=P):P=e[56];let R;e[57]!==u||e[58]!==t.busy||e[59]!==P?(R=(0,l.jsxDEV)($,{"data-testid":"kv-create-cancel",disabled:g,onClick:u,variant:"outline",children:P},void 0,!1),e[57]=u,e[58]=t.busy,e[59]=P,e[60]=R):R=e[60];let Z;e[61]!==A||e[62]!==R?(Z=(0,l.jsxDEV)("div",{className:"flex flex-wrap gap-2",children:[A,R]},void 0,!0),e[61]=A,e[62]=R,e[63]=Z):Z=e[63];let G;e[64]!==t.error?(G=t.error!==null&&(0,l.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"kv-create-error",role:"alert",children:t.error},void 0,!1),e[64]=t.error,e[65]=G):G=e[65];let te;return e[66]!==k||e[67]!==O||e[68]!==m||e[69]!==T||e[70]!==Z||e[71]!==G?(te=(0,l.jsxDEV)("div",{className:"grid gap-3 px-4 pb-4","data-testid":"kv-create-form",children:[k,O,m,T,Z,G]},void 0,!0),e[66]=k,e[67]=O,e[68]=m,e[69]=T,e[70]=Z,e[71]=G,e[72]=te):te=e[72],te},"KvCreateForm"),je={busy:"",editedMetadata:"",editedTtl:"",editedValue:"",loadError:null,loading:!0,value:null,writeError:null},He=n((r,e)=>{switch(e.type){case"deleteStart":return{...r,busy:"deleting",writeError:null};case"editMetadata":return{...r,editedMetadata:e.value};case"editTtl":return{...r,editedTtl:e.value};case"editValue":return{...r,editedValue:e.value};case"loaded":return{...r,editedMetadata:e.metadata===null||e.metadata===void 0?"":JSON.stringify(e.metadata,null,2),editedValue:e.value??"",loading:!1,value:e.value};case"loadFailed":return{...r,loadError:e.error,loading:!1};case"saveOk":return{...r,busy:"",value:r.editedValue};case"saveStart":return{...r,busy:"saving",writeError:null};case"writeFailed":return{...r,busy:"",writeError:e.error};default:return r}},"valueReducer"),Re=n(r=>{let e=(0,ee.c)(67),{expiration:s,keyName:u,namespace:d,onDeleted:f}=r,o=Y(),t=U(),[a,p]=(0,J.useReducer)(He,je),c,x;e[0]!==o||e[1]!==u||e[2]!==d?(c=n(()=>{let g={cancelled:!1};return H((async()=>{try{let P=await o.getKvValue({key:u,namespace:d});g.cancelled||p({metadata:P.metadata,type:"loaded",value:P.value})}catch(P){let R=P;g.cancelled||p({error:z(R),type:"loadFailed"})}})()),()=>{g.cancelled=!0}},"t1"),x=[o,d,u],e[0]=o,e[1]=u,e[2]=d,e[3]=c,e[4]=x):(c=e[3],x=e[4]),(0,J.useEffect)(c,x);let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=n(g=>{p({type:"editValue",value:g.target.value})},"t3"),e[5]=b):b=e[5];let M=b,V;e[6]===Symbol.for("react.memo_cache_sentinel")?(V=n(g=>{p({type:"editMetadata",value:g})},"t4"),e[6]=V):V=e[6];let L=V,h;e[7]!==a.editedValue?(h=Te(a.editedValue),e[7]=a.editedValue,e[8]=h):h=e[8];let v=h,y;e[9]!==a.editedMetadata?(y=Ee(a.editedMetadata),e[9]=a.editedMetadata,e[10]=y):y=e[10];let N=y,C;e[11]!==a.editedTtl?(C=Ke(a.editedTtl),e[11]=a.editedTtl,e[12]=C):C=e[12];let S=C,k;e[13]!==v?(k=n(()=>{v!==void 0&&p({type:"editValue",value:v})},"t8"),e[13]=v,e[14]=k):k=e[14];let w=k,E;e[15]!==o||e[16]!==s||e[17]!==u||e[18]!==N||e[19]!==d||e[20]!==a.editedMetadata||e[21]!==a.editedTtl||e[22]!==a.editedValue||e[23]!==t?(E=n(()=>{if(!N){p({error:t("Metadata must be valid JSON."),type:"writeFailed"});return}p({type:"saveStart"}),H((async()=>{try{await o.putKvValue(Ve({metadata:a.editedMetadata,ttl:a.editedTtl,value:a.editedValue},u,d,s)),p({type:"saveOk"})}catch(g){p({error:z(g),type:"writeFailed"})}})())},"t9"),e[15]=o,e[16]=s,e[17]=u,e[18]=N,e[19]=d,e[20]=a.editedMetadata,e[21]=a.editedTtl,e[22]=a.editedValue,e[23]=t,e[24]=E):E=e[24];let B=E,I;e[25]!==o||e[26]!==u||e[27]!==d||e[28]!==f?(I=n(()=>{p({type:"deleteStart"}),H((async()=>{try{await o.deleteKvKey({key:u,namespace:d}),f(u)}catch(g){p({error:z(g),type:"writeFailed"})}})())},"t10"),e[25]=o,e[26]=u,e[27]=d,e[28]=f,e[29]=I):I=e[29];let O=I,D;e[30]!==u?(D=n(()=>{ie(u)},"t11"),e[30]=u,e[31]=D):D=e[31];let i;e[32]!==t?(i=t("Copy key"),e[32]=t,e[33]=i):i=e[33];let m;e[34]!==D||e[35]!==i?(m=(0,l.jsxDEV)("div",{className:"mb-2 flex justify-end",children:(0,l.jsxDEV)($,{"data-testid":"kv-copy-key-btn",onClick:D,size:"sm",variant:"outline",children:i},void 0,!1)},void 0,!1),e[34]=D,e[35]=i,e[36]=m):m=e[36];let K;e[37]!==a.loadError?(K=a.loadError!==null&&(0,l.jsxDEV)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-value-error",role:"alert",children:a.loadError},void 0,!1),e[37]=a.loadError,e[38]=K):K=e[38];let T;e[39]!==a.loading||e[40]!==t?(T=a.loading&&(0,l.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-value-loading",children:t("Loading\u2026")},void 0,!1),e[39]=a.loading,e[40]=t,e[41]=T):T=e[41];let _;e[42]!==v||e[43]!==N||e[44]!==O||e[45]!==w||e[46]!==B||e[47]!==a.busy||e[48]!==a.editedMetadata||e[49]!==a.editedValue||e[50]!==a.loading||e[51]!==a.value||e[52]!==a.writeError||e[53]!==t||e[54]!==S?(_=!a.loading&&a.value!==null&&(0,l.jsxDEV)(l.Fragment,{children:[(0,l.jsxDEV)("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[(0,l.jsxDEV)(W,{className:"text-xs",htmlFor:"kv-value-editor",children:t("Value")},void 0,!1),v!==void 0&&(0,l.jsxDEV)(he,{variant:"secondary",children:t("JSON")},void 0,!1),(0,l.jsxDEV)("span",{className:"ml-auto text-xs tabular-nums text-muted-foreground","data-testid":"kv-value-size",children:ke(Ae(a.editedValue))},void 0,!1)]},void 0,!0),(0,l.jsxDEV)("textarea",{"aria-label":t("KV value"),className:"mb-2 min-h-[8rem] w-full rounded border border-border bg-muted/30 p-2 font-mono text-xs","data-testid":"kv-value-editor",id:"kv-value-editor",onChange:M,value:a.editedValue},void 0,!1),(0,l.jsxDEV)("div",{className:"mb-3 flex flex-wrap gap-2",children:[(0,l.jsxDEV)($,{"data-testid":"kv-format-btn",disabled:v===void 0,onClick:w,size:"sm",variant:"outline",children:t("Format JSON")},void 0,!1),(0,l.jsxDEV)($,{"data-testid":"kv-copy-value-btn",onClick:n(()=>{ie(a.editedValue)},"onClick"),size:"sm",variant:"outline",children:t("Copy value")},void 0,!1)]},void 0,!0),(0,l.jsxDEV)(Ie,{helper:t("Leave blank to keep the current expiration."),id:"kv-ttl-input",invalid:!S,onChange:n(g=>{p({type:"editTtl",value:g})},"onChange"),testId:"kv-ttl-input"},void 0,!1),(0,l.jsxDEV)(_e,{id:"kv-metadata-editor",invalidTestId:"kv-metadata-invalid",onChange:L,testId:"kv-metadata-editor",valid:N,value:a.editedMetadata},void 0,!1),(0,l.jsxDEV)("div",{className:"flex flex-wrap gap-2",children:[(0,l.jsxDEV)($,{"data-testid":"kv-save-btn",disabled:a.busy!==""||!N||!S,onClick:B,children:a.busy==="saving"?t("Saving\u2026"):t("Save")},void 0,!1),(0,l.jsxDEV)($,{"data-testid":"kv-delete-btn",disabled:a.busy!=="",onClick:O,variant:"destructive",children:a.busy==="deleting"?t("Deleting\u2026"):t("Delete")},void 0,!1)]},void 0,!0),a.writeError!==null&&(0,l.jsxDEV)("p",{className:"mt-2 text-sm text-destructive","data-testid":"kv-save-error",role:"alert",children:a.writeError},void 0,!1)]},void 0,!0),e[42]=v,e[43]=N,e[44]=O,e[45]=w,e[46]=B,e[47]=a.busy,e[48]=a.editedMetadata,e[49]=a.editedValue,e[50]=a.loading,e[51]=a.value,e[52]=a.writeError,e[53]=t,e[54]=S,e[55]=_):_=e[55];let F;e[56]!==a.loadError||e[57]!==a.loading||e[58]!==a.value||e[59]!==t?(F=!a.loading&&a.value===null&&a.loadError===null&&(0,l.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-absent",children:t("Key is absent or has no value.")},void 0,!1),e[56]=a.loadError,e[57]=a.loading,e[58]=a.value,e[59]=t,e[60]=F):F=e[60];let A;return e[61]!==m||e[62]!==K||e[63]!==T||e[64]!==_||e[65]!==F?(A=(0,l.jsxDEV)("div",{className:"px-4 pb-4","data-testid":"kv-value-section",children:[m,K,T,_,F]},void 0,!0),e[61]=m,e[62]=K,e[63]=T,e[64]=_,e[65]=F,e[66]=A):A=e[66],A},"KvValueEditor"),we=100,ze={appliedPrefix:"",bulk:[],bulkBusy:!1,bulkError:null,cursor:null,keys:null,listComplete:!1,loadError:null,loading:!1,prefixInput:"",reloadNonce:0,selectedKey:null},Ue=n((r,e)=>{switch(e.type){case"appendPage":return{...r,cursor:e.cursor,keys:[...r.keys??[],...e.keys],listComplete:e.listComplete,loading:!1};case"applyFilter":return{...r,appliedPrefix:r.prefixInput,bulk:[],bulkError:null,cursor:null,keys:null,listComplete:!1,selectedKey:null};case"bulkDeleted":{let s=new Set(e.deleted);return{...r,bulk:r.bulk.filter(u=>!s.has(u)),bulkBusy:!1,bulkError:e.error,keys:r.keys===null?null:r.keys.filter(u=>!s.has(u.name)),selectedKey:r.selectedKey!==null&&s.has(r.selectedKey)?null:r.selectedKey}}case"bulkDeleteStart":return{...r,bulkBusy:!0,bulkError:null};case"firstPage":return{...r,cursor:e.cursor,keys:e.keys,listComplete:e.listComplete,loading:!1};case"keyDeleted":return{...r,bulk:r.bulk.filter(s=>s!==e.name),keys:r.keys===null?null:r.keys.filter(s=>s.name!==e.name),selectedKey:null};case"loadFailed":return{...r,loadError:e.error,loading:!1};case"loadStart":return{...r,loadError:null,loading:!0};case"prefixInput":return{...r,prefixInput:e.value};case"reload":return{...r,bulk:[],bulkError:null,reloadNonce:r.reloadNonce+1,selectedKey:null};case"selectKey":return{...r,selectedKey:e.name};case"toggleAllBulk":return{...r,bulk:e.names};case"toggleBulk":return{...r,bulk:r.bulk.includes(e.name)?r.bulk.filter(s=>s!==e.name):[...r.bulk,e.name]};default:return r}},"keyListReducer"),Ze=n(({namespace:r})=>{let e=Y(),s=U(),[u,d]=(0,J.useReducer)(Ue,ze),{appliedPrefix:f,bulk:o,bulkBusy:t,bulkError:a,cursor:p,keys:c,listComplete:x,loadError:b,loading:M,prefixInput:V,reloadNonce:L,selectedKey:h}=u,[v,y]=(0,J.useState)(!1);(0,J.useEffect)(()=>{let i={cancelled:!1};return H((async()=>{d({type:"loadStart"});try{let m=await e.listKvKeys({limit:we,namespace:r,prefix:f===""?void 0:f});i.cancelled||d({cursor:m.cursor??null,keys:m.keys,listComplete:m.listComplete,type:"firstPage"})}catch(m){i.cancelled||d({error:z(m),type:"loadFailed"})}})()),()=>{i.cancelled=!0}},[e,r,f,L]);let N=n(i=>{d({type:"prefixInput",value:i.target.value})},"onPrefixChange"),C=n(()=>{d({type:"applyFilter"})},"onFilter"),S=n(i=>{d({name:i.currentTarget.dataset.key??null,type:"selectKey"})},"onSelectKey"),k=n(()=>{p!==null&&(d({type:"loadStart"}),H((async()=>{try{let i=await e.listKvKeys({cursor:p,limit:we,namespace:r,prefix:f===""?void 0:f});d({cursor:i.cursor??null,keys:i.keys,listComplete:i.listComplete,type:"appendPage"})}catch(i){d({error:z(i),type:"loadFailed"})}})()))},"onLoadMore"),w=n(i=>{d({name:i,type:"keyDeleted"})},"onKeyDeleted"),E=n(i=>{d({name:i,type:"toggleBulk"})},"onToggleBulk"),B=n(i=>{d({names:i&&c!==null?c.map(m=>m.name):[],type:"toggleAllBulk"})},"onToggleAll"),I=n(()=>{if(o.length===0)return;let i=[...o];d({type:"bulkDeleteStart"}),H((async()=>{let m=await Promise.allSettled(i.map(_=>e.deleteKvKey({key:_,namespace:r}))),K=i.filter((_,F)=>m[F]?.status==="fulfilled"),T=i.length-K.length;d({deleted:K,error:T>0?s("Failed to delete {count} keys.",{count:T}):null,type:"bulkDeleted"})})())},"onBulkDelete"),O=n(()=>{y(!1),d({type:"reload"})},"onCreated"),D=c!==null&&c.length>0&&o.length===c.length;return(0,l.jsxDEV)(l.Fragment,{children:[(0,l.jsxDEV)("section",{className:"border border-border bg-card p-3","data-testid":"kv-keys-section",children:[(0,l.jsxDEV)("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[(0,l.jsxDEV)(le,{"aria-label":s("Filter keys by prefix"),className:"min-w-[16rem] flex-1","data-testid":"kv-prefix-input",onChange:N,placeholder:s("Filter by prefix\u2026"),value:V},void 0,!1),(0,l.jsxDEV)($,{"data-testid":"kv-filter-btn",disabled:M,onClick:C,children:s("Filter")},void 0,!1),(0,l.jsxDEV)($,{"data-testid":"kv-new-key-btn",onClick:n(()=>{y(i=>!i)},"onClick"),variant:"outline",children:s("New key")},void 0,!1),o.length>0&&(0,l.jsxDEV)($,{"data-testid":"kv-bulk-delete-btn",disabled:t,onClick:I,variant:"destructive",children:t?s("Deleting\u2026"):s("Delete {count}",{count:o.length})},void 0,!1)]},void 0,!0),a!==null&&(0,l.jsxDEV)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-bulk-error",role:"alert",children:a},void 0,!1),b!==null&&(0,l.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"kv-keys-error",role:"alert",children:b},void 0,!1),c!==null&&c.length===0&&!M&&(0,l.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-no-keys",children:s("No keys.")},void 0,!1),c!==null&&c.length>0&&(0,l.jsxDEV)(re,{className:"overflow-hidden py-0",children:(0,l.jsxDEV)(se,{className:"px-0",children:(0,l.jsxDEV)(de,{"data-testid":"kv-key-table",children:[(0,l.jsxDEV)(ne,{children:(0,l.jsxDEV)(q,{children:[(0,l.jsxDEV)(Q,{className:"w-10",children:(0,l.jsxDEV)(ue,{"aria-label":s("Select all"),checked:D,"data-testid":"kv-select-all",onCheckedChange:B},void 0,!1)},void 0,!1),(0,l.jsxDEV)(Q,{children:s("Key")},void 0,!1),(0,l.jsxDEV)(Q,{children:s("Expiration")},void 0,!1)]},void 0,!0)},void 0,!1),(0,l.jsxDEV)(oe,{children:c.map(i=>(0,l.jsxDEV)(q,{className:i.name===h?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-key":i.name,"data-testid":`kv-key-row-${i.name}`,onClick:S,children:[(0,l.jsxDEV)(X,{onClick:n(m=>{m.stopPropagation()},"onClick"),children:(0,l.jsxDEV)(ue,{"aria-label":s("Select {name}",{name:i.name}),checked:o.includes(i.name),"data-testid":`kv-select-${i.name}`,onCheckedChange:n(()=>{E(i.name)},"onCheckedChange")},void 0,!1)},void 0,!1),(0,l.jsxDEV)(X,{className:"font-mono text-xs",children:i.name},void 0,!1),(0,l.jsxDEV)(X,{className:"tabular-nums text-xs",children:Oe(i.expiration)},void 0,!1)]},i.name,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),!x&&p!==null&&(0,l.jsxDEV)("div",{className:"mt-2",children:(0,l.jsxDEV)($,{"data-testid":"kv-load-more",disabled:M,onClick:k,variant:"outline",children:s(M?"Loading\u2026":"Load more")},void 0,!1)},void 0,!1)]},void 0,!0),(0,l.jsxDEV)(me,{onOpenChange:n(i=>{i||y(!1)},"onOpenChange"),open:v,children:(0,l.jsxDEV)(ve,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-create-sheet",side:"right",children:[(0,l.jsxDEV)(fe,{children:(0,l.jsxDEV)(pe,{children:s("New key")},void 0,!1)},void 0,!1),(0,l.jsxDEV)($e,{namespace:r,onCancel:n(()=>{y(!1)},"onCancel"),onCreated:O},void 0,!1)]},void 0,!0)},void 0,!1),(0,l.jsxDEV)(me,{onOpenChange:n(i=>{i||d({name:null,type:"selectKey"})},"onOpenChange"),open:h!==null,children:(0,l.jsxDEV)(ve,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-editor-sheet",side:"right",children:[(0,l.jsxDEV)(fe,{children:(0,l.jsxDEV)(pe,{className:"truncate font-mono text-xs",children:h},void 0,!1)},void 0,!1),h!==null&&(0,l.jsxDEV)(Re,{expiration:c?.find(i=>i.name===h)?.expiration,keyName:h,namespace:r,onDeleted:w},`${r}:${h}`,!1)]},void 0,!0)},void 0,!1)]},void 0,!0)},"KvKeyList"),ot=n(({loadNamespaces:r}={})=>{let e=Y(),s=U(),[u,d]=(0,J.useState)(null),[f,o]=(0,J.useState)(null),[t,a]=(0,J.useState)(null);(0,J.useEffect)(()=>{let c={cancelled:!1};return H((async()=>{try{let x=await(r??(()=>e.listKvNamespaces()))();c.cancelled||(d(x),o(null),a(b=>b??x[0]?.binding??null))}catch(x){c.cancelled||(d(null),o(z(x)))}})()),()=>{c.cancelled=!0}},[e,r]);let p=n(c=>{a(c.currentTarget.dataset.ns??null)},"onSelectNs");return(0,l.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-kv-browser",children:[f!==null&&(0,l.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"kv-ns-error",role:"alert",children:f},void 0,!1),u!==null&&u.length===0&&(0,l.jsxDEV)(ye,{description:s("Add a kv_namespaces binding to wrangler.jsonc \u2014 it appears here automatically, no wiring needed."),icon:(0,l.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,l.jsxDEV)("path",{d:"M5 5h14v4H5V5Zm0 5h14v4H5v-4Zm0 5h14v4H5v-4Z"},void 0,!1)},void 0,!1),testId:"kv-empty",title:s("No KV namespaces.")},void 0,!1),u!==null&&u.length>0&&(0,l.jsxDEV)(re,{className:"overflow-hidden py-0",children:(0,l.jsxDEV)(se,{className:"px-0",children:(0,l.jsxDEV)(de,{"data-testid":"kv-namespace-table",children:[(0,l.jsxDEV)(ne,{children:(0,l.jsxDEV)(q,{children:(0,l.jsxDEV)(Q,{children:s("Namespace")},void 0,!1)},void 0,!1)},void 0,!1),(0,l.jsxDEV)(oe,{children:u.map(c=>(0,l.jsxDEV)(q,{className:c.binding===t?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-ns":c.binding,"data-testid":`kv-ns-row-${c.binding}`,onClick:p,children:(0,l.jsxDEV)(X,{className:"font-mono text-xs",children:c.binding},void 0,!1)},c.binding,!1))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),t!==null&&(0,l.jsxDEV)(Ze,{namespace:t},t,!1)]},void 0,!0)},"KvBrowser");export{ot as KvBrowser};
@@ -1,4 +1,4 @@
1
- import{a as hS,b as rp,c as vS,d as dp,e as SS,f as bS,k as ES}from"./chunk-OV2WFAJX.js";import"./chunk-ZPUO7FNI.js";import"./chunk-764T6X6X.js";import"./chunk-XUGSA2NG.js";import"./chunk-5OIBXYZM.js";import"./chunk-UII66UVF.js";import"./chunk-7TJJXVSE.js";import"./chunk-SVR644RF.js";import{a as gS}from"./chunk-2K47A3P6.js";import"./chunk-KEGAWN6Y.js";import"./chunk-KZ6INM5M.js";import"./chunk-4QHKBC77.js";import{R as mS}from"./chunk-3CJW6NWG.js";import{c as yS}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{a as bT}from"./chunk-HV7G6DFP.js";import"./chunk-AQGOX5DK.js";import"./chunk-TAD43CG5.js";import"./chunk-DVKPRFIJ.js";import"./chunk-SEU5V7I6.js";import"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as fS,e as dS}from"./chunk-X7MMBSNW.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as pS,d as fp}from"./chunk-PVZI3CXP.js";import{b as cS}from"./chunk-GMSGZDDH.js";import{a as o,c as gf,e as Wi,f as sS,g as ET,h as rS,j as sp}from"./chunk-RRCPZMC2.js";var TS=gf(Ye=>{"use strict";(function(){function ge(){if(ot=!1,K){var z=Ye.unstable_now();De=z;var j=!0;try{e:{he=!1,Ue&&(Ue=!1,pt(Ke),Ke=-1),oe=!0;var q=V;try{t:{for(se(z),I=J(L);I!==null&&!(I.expirationTime>z&&A());){var xe=I.callback;if(typeof xe=="function"){I.callback=null,V=I.priorityLevel;var Ge=xe(I.expirationTime<=z);if(z=Ye.unstable_now(),typeof Ge=="function"){I.callback=Ge,se(z),j=!0;break t}I===J(L)&&G(L),se(z)}else G(L);I=J(L)}if(I!==null)j=!0;else{var ba=J(de);ba!==null&&ce(ae,ba.startTime-z),j=!1}}break e}finally{I=null,V=q,oe=!1}j=void 0}}finally{j?_e():K=!1}}}o(ge,"performWorkUntilDeadline");function r(z,j){var q=z.length;z.push(j);e:for(;0<q;){var xe=q-1>>>1,Ge=z[xe];if(0<ee(Ge,j))z[xe]=j,z[q]=Ge,q=xe;else break e}}o(r,"push");function J(z){return z.length===0?null:z[0]}o(J,"peek");function G(z){if(z.length===0)return null;var j=z[0],q=z.pop();if(q!==j){z[0]=q;e:for(var xe=0,Ge=z.length,ba=Ge>>>1;xe<ba;){var iu=2*(xe+1)-1,yo=z[iu],Sn=iu+1,it=z[Sn];if(0>ee(yo,q))Sn<Ge&&0>ee(it,yo)?(z[xe]=it,z[Sn]=q,xe=Sn):(z[xe]=yo,z[iu]=q,xe=iu);else if(Sn<Ge&&0>ee(it,q))z[xe]=it,z[Sn]=q,xe=Sn;else break e}}return j}o(G,"pop");function ee(z,j){var q=z.sortIndex-j.sortIndex;return q!==0?q:z.id-j.id}o(ee,"compare");function se(z){for(var j=J(de);j!==null;){if(j.callback===null)G(de);else if(j.startTime<=z)G(de),j.sortIndex=j.expirationTime,r(L,j);else break;j=J(de)}}o(se,"advanceTimers");function ae(z){if(Ue=!1,se(z),!he)if(J(L)!==null)he=!0,K||(K=!0,_e());else{var j=J(de);j!==null&&ce(ae,j.startTime-z)}}o(ae,"handleTimeout");function A(){return ot?!0:!(Ye.unstable_now()-De<U)}o(A,"shouldYieldToHost");function ce(z,j){Ke=Gt(function(){z(Ye.unstable_now())},j)}if(o(ce,"requestHostTimeout"),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()),Ye.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var Be=performance;Ye.unstable_now=function(){return Be.now()}}else{var Ze=Date,ue=Ze.now();Ye.unstable_now=function(){return Ze.now()-ue}}var L=[],de=[],Ae=1,I=null,V=3,oe=!1,he=!1,Ue=!1,ot=!1,Gt=typeof setTimeout=="function"?setTimeout:null,pt=typeof clearTimeout=="function"?clearTimeout:null,bt=typeof setImmediate<"u"?setImmediate:null,K=!1,Ke=-1,U=5,De=-1;if(typeof bt=="function")var _e=o(function(){bt(ge)},"schedulePerformWorkUntilDeadline");else if(typeof MessageChannel<"u"){var pe=new MessageChannel,ul=pe.port2;pe.port1.onmessage=ge,_e=o(function(){ul.postMessage(null)},"schedulePerformWorkUntilDeadline")}else _e=o(function(){Gt(ge,0)},"schedulePerformWorkUntilDeadline");Ye.unstable_IdlePriority=5,Ye.unstable_ImmediatePriority=1,Ye.unstable_LowPriority=4,Ye.unstable_NormalPriority=3,Ye.unstable_Profiling=null,Ye.unstable_UserBlockingPriority=2,Ye.unstable_cancelCallback=function(z){z.callback=null},Ye.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):U=0<z?Math.floor(1e3/z):5},Ye.unstable_getCurrentPriorityLevel=function(){return V},Ye.unstable_next=function(z){switch(V){case 1:case 2:case 3:var j=3;break;default:j=V}var q=V;V=j;try{return z()}finally{V=q}},Ye.unstable_requestPaint=function(){ot=!0},Ye.unstable_runWithPriority=function(z,j){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var q=V;V=z;try{return j()}finally{V=q}},Ye.unstable_scheduleCallback=function(z,j,q){var xe=Ye.unstable_now();switch(typeof q=="object"&&q!==null?(q=q.delay,q=typeof q=="number"&&0<q?xe+q:xe):q=xe,z){case 1:var Ge=-1;break;case 2:Ge=250;break;case 5:Ge=1073741823;break;case 4:Ge=1e4;break;default:Ge=5e3}return Ge=q+Ge,z={id:Ae++,callback:j,priorityLevel:z,startTime:q,expirationTime:Ge,sortIndex:-1},q>xe?(z.sortIndex=q,r(de,z),J(L)===null&&z===J(de)&&(Ue?(pt(Ke),Ke=-1):Ue=!0,ce(ae,q-xe))):(z.sortIndex=Ge,r(L,z),he||oe||(he=!0,K||(K=!0,_e()))),z},Ye.unstable_shouldYield=A,Ye.unstable_wrapCallback=function(z){var j=V;return function(){var q=V;V=j;try{return z.apply(this,arguments)}finally{V=q}}},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()});var DS=gf((_T,AS)=>{"use strict";AS.exports=TS()});var RS=gf(vf=>{"use strict";(function(){function ge(e,t){for(e=e.memoizedState;e!==null&&0<t;)e=e.next,t--;return e}o(ge,"findHook");function r(e,t,n,l){if(n>=t.length)return l;var a=t[n],u=lt(e)?e.slice():F({},e);return u[a]=r(e[a],t,n+1,l),u}o(r,"copyWithSetImpl");function J(e,t,n){if(t.length!==n.length)console.warn("copyWithRename() expects paths of the same length");else{for(var l=0;l<n.length-1;l++)if(t[l]!==n[l]){console.warn("copyWithRename() expects paths to be the same except for the deepest key");return}return G(e,t,n,0)}}o(J,"copyWithRename");function G(e,t,n,l){var a=t[l],u=lt(e)?e.slice():F({},e);return l+1===t.length?(u[n[l]]=u[a],lt(u)?u.splice(a,1):delete u[a]):u[a]=G(e[a],t,n,l+1),u}o(G,"copyWithRenameImpl");function ee(e,t,n){var l=t[n],a=lt(e)?e.slice():F({},e);return n+1===t.length?(lt(a)?a.splice(l,1):delete a[l],a):(a[l]=ee(e[l],t,n+1),a)}o(ee,"copyWithDeleteImpl");function se(){return!1}o(se,"shouldSuspendImpl");function ae(){return null}o(ae,"shouldErrorImpl");function A(){console.error("Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. You can only call Hooks at the top level of your React function. For more information, see https://react.dev/link/rules-of-hooks")}o(A,"warnInvalidHookAccess");function ce(){console.error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().")}o(ce,"warnInvalidContextAccess");function Be(){}o(Be,"noop");function Ze(){}o(Ze,"warnForMissingKey");function ue(e){var t=[];return e.forEach(function(n){t.push(n)}),t.sort().join(", ")}o(ue,"setToSortedString");function L(e,t,n,l){return new cb(e,t,n,l)}o(L,"createFiber");function de(e,t){e.context===Pl&&(Cd(e.current,2,t,e,null,null),Du())}o(de,"scheduleRoot");function Ae(e,t){if(sn!==null){var n=t.staleFamilies;t=t.updatedFamilies,Jo(),pm(e.current,t,n),Du()}}o(Ae,"scheduleRefresh");function I(e){sn=e}o(I,"setRefreshHandler");function V(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}o(V,"isValidContainer");function oe(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}o(oe,"getNearestMountedFiber");function he(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}o(he,"getSuspenseInstanceFromFiber");function Ue(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}o(Ue,"getActivityInstanceFromFiber");function ot(e){if(oe(e)!==e)throw Error("Unable to find node on an unmounted component.")}o(ot,"assertIsMounted");function Gt(e){var t=e.alternate;if(!t){if(t=oe(e),t===null)throw Error("Unable to find node on an unmounted component.");return t!==e?null:e}for(var n=e,l=t;;){var a=n.return;if(a===null)break;var u=a.alternate;if(u===null){if(l=a.return,l!==null){n=l;continue}break}if(a.child===u.child){for(u=a.child;u;){if(u===n)return ot(a),e;if(u===l)return ot(a),t;u=u.sibling}throw Error("Unable to find node on an unmounted component.")}if(n.return!==l.return)n=a,l=u;else{for(var i=!1,c=a.child;c;){if(c===n){i=!0,n=a,l=u;break}if(c===l){i=!0,l=a,n=u;break}c=c.sibling}if(!i){for(c=u.child;c;){if(c===n){i=!0,n=u,l=a;break}if(c===l){i=!0,l=u,n=a;break}c=c.sibling}if(!i)throw Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.")}}if(n.alternate!==l)throw Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.")}if(n.tag!==3)throw Error("Unable to find node on an unmounted component.");return n.stateNode.current===n?e:t}o(Gt,"findCurrentFiberUsingSlowPath");function pt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=pt(e),t!==null)return t;e=e.sibling}return null}o(pt,"findCurrentHostFiberImpl");function bt(e){return e===null||typeof e!="object"?null:(e=Eg&&e[Eg]||e["@@iterator"],typeof e=="function"?e:null)}o(bt,"getIteratorFn");function K(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===U2?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case _u:return"Fragment";case Bd:return"Profiler";case fs:return"StrictMode";case qd:return"Suspense";case jd:return"SuspenseList";case Yd:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case Uu:return"Portal";case Kn:return e.displayName||"Context";case Nd:return(e._context.displayName||"Context")+".Consumer";case ni:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case rs:return t=e.displayName||null,t!==null?t:K(e.type)||"Memo";case kt:t=e._payload,e=e._init;try{return K(e(t))}catch{}}return null}o(K,"getComponentNameFromType");function Ke(e){return typeof e.tag=="number"?U(e):typeof e.name=="string"?e.name:null}o(Ke,"getComponentNameFromOwner");function U(e){var t=e.type;switch(e.tag){case 31:return"Activity";case 24:return"Cache";case 9:return(t._context.displayName||"Context")+".Consumer";case 10:return t.displayName||"Context";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 26:case 27:case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return K(t);case 8:return t===fs?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;break;case 29:if(t=e._debugInfo,t!=null){for(var n=t.length-1;0<=n;n--)if(typeof t[n].name=="string")return t[n].name}if(e.return!==null)return U(e.return)}return null}o(U,"getComponentNameFromFiber");function De(e){return{current:e}}o(De,"createCursor");function _e(e,t){0>ml?console.error("Unexpected pop."):(t!==Ld[ml]&&console.error("Unexpected Fiber popped."),e.current=Gd[ml],Gd[ml]=null,Ld[ml]=null,ml--)}o(_e,"pop");function pe(e,t,n){ml++,Gd[ml]=e.current,Ld[ml]=n,e.current=t}o(pe,"push");function ul(e){return e===null&&console.error("Expected host context to exist. This error is likely caused by a bug in React. Please file an issue."),e}o(ul,"requiredContext");function z(e,t){pe($l,t,e),pe(li,e,e),pe(Jl,null,e);var n=t.nodeType;switch(n){case 9:case 11:n=n===9?"#document":"#fragment",t=(t=t.documentElement)&&(t=t.namespaceURI)?Zy(t):Ml;break;default:if(n=t.tagName,t=t.namespaceURI)t=Zy(t),t=Jy(t,n);else switch(n){case"svg":t=ro;break;case"math":t=ff;break;default:t=Ml}}n=n.toLowerCase(),n=Yp(null,n),n={context:t,ancestorInfo:n},_e(Jl,e),pe(Jl,n,e)}o(z,"pushHostContainer");function j(e){_e(Jl,e),_e(li,e),_e($l,e)}o(j,"popHostContainer");function q(){return ul(Jl.current)}o(q,"getHostContext");function xe(e){e.memoizedState!==null&&pe(ds,e,e);var t=ul(Jl.current),n=e.type,l=Jy(t.context,n);n=Yp(t.ancestorInfo,n),l={context:l,ancestorInfo:n},t!==l&&(pe(li,e,e),pe(Jl,l,e))}o(xe,"pushHostContext");function Ge(e){li.current===e&&(_e(Jl,e),_e(li,e)),ds.current===e&&(_e(ds,e),Ki._currentValue=ou)}o(Ge,"popHostContext");function ba(){}o(ba,"disabledLog");function iu(){if(ai===0){Tg=console.log,Ag=console.info,Dg=console.warn,Rg=console.error,Og=console.group,zg=console.groupCollapsed,Cg=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ba,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}ai++}o(iu,"disableLogs");function yo(){if(ai--,ai===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:F({},e,{value:Tg}),info:F({},e,{value:Ag}),warn:F({},e,{value:Dg}),error:F({},e,{value:Rg}),group:F({},e,{value:Og}),groupCollapsed:F({},e,{value:zg}),groupEnd:F({},e,{value:Cg})})}0>ai&&console.error("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}o(yo,"reenableLogs");function Sn(e){var t=Error.prepareStackTrace;if(Error.prepareStackTrace=void 0,e=e.stack,Error.prepareStackTrace=t,e.startsWith(`Error: react-stack-top-frame
1
+ import{a as hS,b as rp,c as vS,d as dp,e as SS,f as bS,k as ES}from"./chunk-KTK3V4DC.js";import"./chunk-ZPUO7FNI.js";import"./chunk-764T6X6X.js";import"./chunk-XUGSA2NG.js";import"./chunk-5OIBXYZM.js";import"./chunk-UII66UVF.js";import"./chunk-7TJJXVSE.js";import"./chunk-SVR644RF.js";import{a as gS}from"./chunk-2K47A3P6.js";import"./chunk-KEGAWN6Y.js";import"./chunk-KZ6INM5M.js";import"./chunk-4QHKBC77.js";import{R as mS}from"./chunk-3CJW6NWG.js";import{c as yS}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{a as bT}from"./chunk-HV7G6DFP.js";import"./chunk-AQGOX5DK.js";import"./chunk-TAD43CG5.js";import"./chunk-DVKPRFIJ.js";import"./chunk-SEU5V7I6.js";import"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as fS,e as dS}from"./chunk-X7MMBSNW.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as pS,d as fp}from"./chunk-PVZI3CXP.js";import{b as cS}from"./chunk-GMSGZDDH.js";import{a as o,c as gf,e as Wi,f as sS,g as ET,h as rS,j as sp}from"./chunk-RRCPZMC2.js";var TS=gf(Ye=>{"use strict";(function(){function ge(){if(ot=!1,K){var z=Ye.unstable_now();De=z;var j=!0;try{e:{he=!1,Ue&&(Ue=!1,pt(Ke),Ke=-1),oe=!0;var q=V;try{t:{for(se(z),I=J(L);I!==null&&!(I.expirationTime>z&&A());){var xe=I.callback;if(typeof xe=="function"){I.callback=null,V=I.priorityLevel;var Ge=xe(I.expirationTime<=z);if(z=Ye.unstable_now(),typeof Ge=="function"){I.callback=Ge,se(z),j=!0;break t}I===J(L)&&G(L),se(z)}else G(L);I=J(L)}if(I!==null)j=!0;else{var ba=J(de);ba!==null&&ce(ae,ba.startTime-z),j=!1}}break e}finally{I=null,V=q,oe=!1}j=void 0}}finally{j?_e():K=!1}}}o(ge,"performWorkUntilDeadline");function r(z,j){var q=z.length;z.push(j);e:for(;0<q;){var xe=q-1>>>1,Ge=z[xe];if(0<ee(Ge,j))z[xe]=j,z[q]=Ge,q=xe;else break e}}o(r,"push");function J(z){return z.length===0?null:z[0]}o(J,"peek");function G(z){if(z.length===0)return null;var j=z[0],q=z.pop();if(q!==j){z[0]=q;e:for(var xe=0,Ge=z.length,ba=Ge>>>1;xe<ba;){var iu=2*(xe+1)-1,yo=z[iu],Sn=iu+1,it=z[Sn];if(0>ee(yo,q))Sn<Ge&&0>ee(it,yo)?(z[xe]=it,z[Sn]=q,xe=Sn):(z[xe]=yo,z[iu]=q,xe=iu);else if(Sn<Ge&&0>ee(it,q))z[xe]=it,z[Sn]=q,xe=Sn;else break e}}return j}o(G,"pop");function ee(z,j){var q=z.sortIndex-j.sortIndex;return q!==0?q:z.id-j.id}o(ee,"compare");function se(z){for(var j=J(de);j!==null;){if(j.callback===null)G(de);else if(j.startTime<=z)G(de),j.sortIndex=j.expirationTime,r(L,j);else break;j=J(de)}}o(se,"advanceTimers");function ae(z){if(Ue=!1,se(z),!he)if(J(L)!==null)he=!0,K||(K=!0,_e());else{var j=J(de);j!==null&&ce(ae,j.startTime-z)}}o(ae,"handleTimeout");function A(){return ot?!0:!(Ye.unstable_now()-De<U)}o(A,"shouldYieldToHost");function ce(z,j){Ke=Gt(function(){z(Ye.unstable_now())},j)}if(o(ce,"requestHostTimeout"),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()),Ye.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var Be=performance;Ye.unstable_now=function(){return Be.now()}}else{var Ze=Date,ue=Ze.now();Ye.unstable_now=function(){return Ze.now()-ue}}var L=[],de=[],Ae=1,I=null,V=3,oe=!1,he=!1,Ue=!1,ot=!1,Gt=typeof setTimeout=="function"?setTimeout:null,pt=typeof clearTimeout=="function"?clearTimeout:null,bt=typeof setImmediate<"u"?setImmediate:null,K=!1,Ke=-1,U=5,De=-1;if(typeof bt=="function")var _e=o(function(){bt(ge)},"schedulePerformWorkUntilDeadline");else if(typeof MessageChannel<"u"){var pe=new MessageChannel,ul=pe.port2;pe.port1.onmessage=ge,_e=o(function(){ul.postMessage(null)},"schedulePerformWorkUntilDeadline")}else _e=o(function(){Gt(ge,0)},"schedulePerformWorkUntilDeadline");Ye.unstable_IdlePriority=5,Ye.unstable_ImmediatePriority=1,Ye.unstable_LowPriority=4,Ye.unstable_NormalPriority=3,Ye.unstable_Profiling=null,Ye.unstable_UserBlockingPriority=2,Ye.unstable_cancelCallback=function(z){z.callback=null},Ye.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):U=0<z?Math.floor(1e3/z):5},Ye.unstable_getCurrentPriorityLevel=function(){return V},Ye.unstable_next=function(z){switch(V){case 1:case 2:case 3:var j=3;break;default:j=V}var q=V;V=j;try{return z()}finally{V=q}},Ye.unstable_requestPaint=function(){ot=!0},Ye.unstable_runWithPriority=function(z,j){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var q=V;V=z;try{return j()}finally{V=q}},Ye.unstable_scheduleCallback=function(z,j,q){var xe=Ye.unstable_now();switch(typeof q=="object"&&q!==null?(q=q.delay,q=typeof q=="number"&&0<q?xe+q:xe):q=xe,z){case 1:var Ge=-1;break;case 2:Ge=250;break;case 5:Ge=1073741823;break;case 4:Ge=1e4;break;default:Ge=5e3}return Ge=q+Ge,z={id:Ae++,callback:j,priorityLevel:z,startTime:q,expirationTime:Ge,sortIndex:-1},q>xe?(z.sortIndex=q,r(de,z),J(L)===null&&z===J(de)&&(Ue?(pt(Ke),Ke=-1):Ue=!0,ce(ae,q-xe))):(z.sortIndex=Ge,r(L,z),he||oe||(he=!0,K||(K=!0,_e()))),z},Ye.unstable_shouldYield=A,Ye.unstable_wrapCallback=function(z){var j=V;return function(){var q=V;V=j;try{return z.apply(this,arguments)}finally{V=q}}},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()});var DS=gf((_T,AS)=>{"use strict";AS.exports=TS()});var RS=gf(vf=>{"use strict";(function(){function ge(e,t){for(e=e.memoizedState;e!==null&&0<t;)e=e.next,t--;return e}o(ge,"findHook");function r(e,t,n,l){if(n>=t.length)return l;var a=t[n],u=lt(e)?e.slice():F({},e);return u[a]=r(e[a],t,n+1,l),u}o(r,"copyWithSetImpl");function J(e,t,n){if(t.length!==n.length)console.warn("copyWithRename() expects paths of the same length");else{for(var l=0;l<n.length-1;l++)if(t[l]!==n[l]){console.warn("copyWithRename() expects paths to be the same except for the deepest key");return}return G(e,t,n,0)}}o(J,"copyWithRename");function G(e,t,n,l){var a=t[l],u=lt(e)?e.slice():F({},e);return l+1===t.length?(u[n[l]]=u[a],lt(u)?u.splice(a,1):delete u[a]):u[a]=G(e[a],t,n,l+1),u}o(G,"copyWithRenameImpl");function ee(e,t,n){var l=t[n],a=lt(e)?e.slice():F({},e);return n+1===t.length?(lt(a)?a.splice(l,1):delete a[l],a):(a[l]=ee(e[l],t,n+1),a)}o(ee,"copyWithDeleteImpl");function se(){return!1}o(se,"shouldSuspendImpl");function ae(){return null}o(ae,"shouldErrorImpl");function A(){console.error("Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. You can only call Hooks at the top level of your React function. For more information, see https://react.dev/link/rules-of-hooks")}o(A,"warnInvalidHookAccess");function ce(){console.error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().")}o(ce,"warnInvalidContextAccess");function Be(){}o(Be,"noop");function Ze(){}o(Ze,"warnForMissingKey");function ue(e){var t=[];return e.forEach(function(n){t.push(n)}),t.sort().join(", ")}o(ue,"setToSortedString");function L(e,t,n,l){return new cb(e,t,n,l)}o(L,"createFiber");function de(e,t){e.context===Pl&&(Cd(e.current,2,t,e,null,null),Du())}o(de,"scheduleRoot");function Ae(e,t){if(sn!==null){var n=t.staleFamilies;t=t.updatedFamilies,Jo(),pm(e.current,t,n),Du()}}o(Ae,"scheduleRefresh");function I(e){sn=e}o(I,"setRefreshHandler");function V(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}o(V,"isValidContainer");function oe(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}o(oe,"getNearestMountedFiber");function he(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}o(he,"getSuspenseInstanceFromFiber");function Ue(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}o(Ue,"getActivityInstanceFromFiber");function ot(e){if(oe(e)!==e)throw Error("Unable to find node on an unmounted component.")}o(ot,"assertIsMounted");function Gt(e){var t=e.alternate;if(!t){if(t=oe(e),t===null)throw Error("Unable to find node on an unmounted component.");return t!==e?null:e}for(var n=e,l=t;;){var a=n.return;if(a===null)break;var u=a.alternate;if(u===null){if(l=a.return,l!==null){n=l;continue}break}if(a.child===u.child){for(u=a.child;u;){if(u===n)return ot(a),e;if(u===l)return ot(a),t;u=u.sibling}throw Error("Unable to find node on an unmounted component.")}if(n.return!==l.return)n=a,l=u;else{for(var i=!1,c=a.child;c;){if(c===n){i=!0,n=a,l=u;break}if(c===l){i=!0,l=a,n=u;break}c=c.sibling}if(!i){for(c=u.child;c;){if(c===n){i=!0,n=u,l=a;break}if(c===l){i=!0,l=u,n=a;break}c=c.sibling}if(!i)throw Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.")}}if(n.alternate!==l)throw Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.")}if(n.tag!==3)throw Error("Unable to find node on an unmounted component.");return n.stateNode.current===n?e:t}o(Gt,"findCurrentFiberUsingSlowPath");function pt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=pt(e),t!==null)return t;e=e.sibling}return null}o(pt,"findCurrentHostFiberImpl");function bt(e){return e===null||typeof e!="object"?null:(e=Eg&&e[Eg]||e["@@iterator"],typeof e=="function"?e:null)}o(bt,"getIteratorFn");function K(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===U2?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case _u:return"Fragment";case Bd:return"Profiler";case fs:return"StrictMode";case qd:return"Suspense";case jd:return"SuspenseList";case Yd:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case Uu:return"Portal";case Kn:return e.displayName||"Context";case Nd:return(e._context.displayName||"Context")+".Consumer";case ni:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case rs:return t=e.displayName||null,t!==null?t:K(e.type)||"Memo";case kt:t=e._payload,e=e._init;try{return K(e(t))}catch{}}return null}o(K,"getComponentNameFromType");function Ke(e){return typeof e.tag=="number"?U(e):typeof e.name=="string"?e.name:null}o(Ke,"getComponentNameFromOwner");function U(e){var t=e.type;switch(e.tag){case 31:return"Activity";case 24:return"Cache";case 9:return(t._context.displayName||"Context")+".Consumer";case 10:return t.displayName||"Context";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 26:case 27:case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return K(t);case 8:return t===fs?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;break;case 29:if(t=e._debugInfo,t!=null){for(var n=t.length-1;0<=n;n--)if(typeof t[n].name=="string")return t[n].name}if(e.return!==null)return U(e.return)}return null}o(U,"getComponentNameFromFiber");function De(e){return{current:e}}o(De,"createCursor");function _e(e,t){0>ml?console.error("Unexpected pop."):(t!==Ld[ml]&&console.error("Unexpected Fiber popped."),e.current=Gd[ml],Gd[ml]=null,Ld[ml]=null,ml--)}o(_e,"pop");function pe(e,t,n){ml++,Gd[ml]=e.current,Ld[ml]=n,e.current=t}o(pe,"push");function ul(e){return e===null&&console.error("Expected host context to exist. This error is likely caused by a bug in React. Please file an issue."),e}o(ul,"requiredContext");function z(e,t){pe($l,t,e),pe(li,e,e),pe(Jl,null,e);var n=t.nodeType;switch(n){case 9:case 11:n=n===9?"#document":"#fragment",t=(t=t.documentElement)&&(t=t.namespaceURI)?Zy(t):Ml;break;default:if(n=t.tagName,t=t.namespaceURI)t=Zy(t),t=Jy(t,n);else switch(n){case"svg":t=ro;break;case"math":t=ff;break;default:t=Ml}}n=n.toLowerCase(),n=Yp(null,n),n={context:t,ancestorInfo:n},_e(Jl,e),pe(Jl,n,e)}o(z,"pushHostContainer");function j(e){_e(Jl,e),_e(li,e),_e($l,e)}o(j,"popHostContainer");function q(){return ul(Jl.current)}o(q,"getHostContext");function xe(e){e.memoizedState!==null&&pe(ds,e,e);var t=ul(Jl.current),n=e.type,l=Jy(t.context,n);n=Yp(t.ancestorInfo,n),l={context:l,ancestorInfo:n},t!==l&&(pe(li,e,e),pe(Jl,l,e))}o(xe,"pushHostContext");function Ge(e){li.current===e&&(_e(Jl,e),_e(li,e)),ds.current===e&&(_e(ds,e),Ki._currentValue=ou)}o(Ge,"popHostContext");function ba(){}o(ba,"disabledLog");function iu(){if(ai===0){Tg=console.log,Ag=console.info,Dg=console.warn,Rg=console.error,Og=console.group,zg=console.groupCollapsed,Cg=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ba,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}ai++}o(iu,"disableLogs");function yo(){if(ai--,ai===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:F({},e,{value:Tg}),info:F({},e,{value:Ag}),warn:F({},e,{value:Dg}),error:F({},e,{value:Rg}),group:F({},e,{value:Og}),groupCollapsed:F({},e,{value:zg}),groupEnd:F({},e,{value:Cg})})}0>ai&&console.error("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}o(yo,"reenableLogs");function Sn(e){var t=Error.prepareStackTrace;if(Error.prepareStackTrace=void 0,e=e.stack,Error.prepareStackTrace=t,e.startsWith(`Error: react-stack-top-frame
2
2
  `)&&(e=e.slice(29)),t=e.indexOf(`
3
3
  `),t!==-1&&(e=e.slice(t+1)),t=e.indexOf("react_stack_bottom_frame"),t!==-1&&(t=e.lastIndexOf(`
4
4
  `,t)),t!==-1)e=e.slice(0,t);else return"";return e}o(Sn,"formatOwnerStack");function it(e){if(Vd===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Vd=t&&t[1]||"",Mg=-1<n.stack.indexOf(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/studio",
3
- "version": "1.0.0-alpha.32",
3
+ "version": "1.0.0-alpha.34",
4
4
  "description": "The Lunora Studio: a local admin UI for your schema, data, logs, and advisors",
5
5
  "keywords": [
6
6
  "admin-ui",
@@ -58,7 +58,7 @@
58
58
  "@hugeicons/react": "^1.1.9",
59
59
  "@lingui/core": "^6.4.0",
60
60
  "@lingui/message-utils": "^6.4.0",
61
- "@lunora/advisor": "1.0.0-alpha.16",
61
+ "@lunora/advisor": "1.0.0-alpha.17",
62
62
  "@lunora/bindings": "1.0.0-alpha.4",
63
63
  "@lunora/client": "1.0.0-alpha.17",
64
64
  "@lunora/errors": "1.0.0-alpha.1",
@@ -1 +0,0 @@
1
- import{a as je}from"./chunk-TDL7NEWA.js";import{a as Oe}from"./chunk-7TJJXVSE.js";import{e as Pe}from"./chunk-SVR644RF.js";import{a as We}from"./chunk-2K47A3P6.js";import"./chunk-KEGAWN6Y.js";import{a as D,b as De}from"./chunk-PZ7HD5T2.js";import"./chunk-AJIUI7DD.js";import"./chunk-XNJNSCLM.js";import"./chunk-GTM65MVX.js";import{a as He}from"./chunk-K3GNLVYK.js";import{b as Ue}from"./chunk-TBMYIZIO.js";import"./chunk-3CJW6NWG.js";import{c as Fe}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as R}from"./chunk-AQGOX5DK.js";import{b as C}from"./chunk-DVKPRFIJ.js";import"./chunk-SEU5V7I6.js";import"./chunk-CKSHCYGC.js";import{f as Ke}from"./chunk-X7MMBSNW.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as I,e as H,f as W,k as T}from"./chunk-PVZI3CXP.js";import"./chunk-GMSGZDDH.js";import{a as r,e as U,f as et,g as tt,h as nt}from"./chunk-RRCPZMC2.js";var Ee=U(tt(),1);var y=U(et(),1);var A=U(nt(),1);var l=r((a,t)=>({cacheKey:t.cacheKey,categories:t.categories??a.categories,description:a.description,detail:t.detail,facing:t.facing??a.facing,level:t.level??a.level,metadata:t.metadata,name:a.name,remediation:a.remediation,title:a.title}),"emit");var L=5,j=r(a=>typeof a._id=="string"?a._id:"?","rowId"),z=r((a,t,e)=>a?` (sample capped at ${t.toString()} rows \u2014 ${e})`:"","truncatedSuffix"),X=r((a,t)=>{let e=a.slice(0,L),n=t-e.length,i=e.map(o=>`"${o}"`).join(", ");return n>0?`${i} (+${n.toString()} more)`:i},"formatExamples"),at=r((a,t,e,n)=>{if(e.kind!=="one")return;let i=e.field,o=[];for(let u of t.rows){let g=u[i];if(g==null)continue;let m=String(g);n.existingIds.has(m)||o.push(j(u))}if(o.length===0)return;let s=t.truncated||n.truncated,c=Math.min(t.cap,n.cap),d=`Table "${t.table}": ${o.length.toString()} sampled row(s) have a dangling FK value in column "${i}" \u2014 the referenced "${e.table}" row does not exist. Row ids: ${X(o,o.length)}${z(s,c,"more rows may exist beyond the window")}.`;return l(a,{cacheKey:`constraint_validator:fk:${t.table}:${i}`,detail:d,metadata:{cap:c,column:i,count:o.length,examples:o.slice(0,L),kind:"fk",referencesTable:e.table,table:t.table,truncated:s}})},"checkFkRelation"),it=r((a,t,e,n)=>{if(!n)return;let i=[];for(let s of t.rows){let c=s[e];c==null&&i.push(j(s))}if(i.length===0)return;let o=`Table "${t.table}": ${i.length.toString()} sampled row(s) have a null/missing value in column "${e}", which is declared as non-optional. Row ids: ${X(i,i.length)}${z(t.truncated,t.cap,"more rows may exist beyond the window")}.`;return l(a,{cacheKey:`constraint_validator:null:${t.table}:${e}`,detail:o,metadata:{cap:t.cap,column:e,count:i.length,examples:i.slice(0,L),kind:"null",table:t.table,truncated:t.truncated}})},"checkNullField"),ot=r((a,t)=>{let e=[];for(let n of t){let i=a[n];if(i==null)return;e.push(JSON.stringify(i))}return e.join("|")},"compositeKey"),rt=r((a,t,e)=>{e.includes(t)||e.push(t),e.push(a)},"recordDuplicate"),st=r((a,t,e)=>{if(e.kind!=="index"||e.unique!==!0)return;let n=new Map,i=[];for(let s of t.rows){let c=j(s),d=ot(s,e.fields);if(d===void 0)continue;let u=n.get(d);u===void 0?n.set(d,c):rt(c,u,i)}if(i.length===0)return;let o=`Table "${t.table}": ${i.length.toString()} sampled row(s) share duplicate values on unique index "${e.name}" (${e.fields.join(", ")}). Row ids: ${X(i,i.length)}${z(t.truncated,t.cap,"duplicates beyond the window may exist")}.`;return l(a,{cacheKey:`constraint_validator:unique:${t.table}:${e.name}`,detail:o,metadata:{cap:t.cap,count:i.length,examples:i.slice(0,L),fields:e.fields,index:e.name,kind:"unique",table:t.table,truncated:t.truncated}})},"checkUniqueIndex"),lt=r((a,t,e,n)=>{let i=n.get(t.table);if(!i)return[];let o=[];for(let s of i.relations){let c=e.get(s.table);if(!c)continue;let d=at(a,t,s,c);d&&o.push(d)}for(let s of i.fields){let c=!i.optionalFields?.has(s),d=it(a,t,s,c);d&&o.push(d)}for(let s of i.indexes){let c=st(a,t,s);c&&o.push(c)}return o},"checkTable"),B={categories:["SCHEMA"],description:"Sampled rows violate one or more declared constraints: a foreign-key column references a non-existent row, a non-optional column contains null, or a unique-indexed column has duplicate values. These violations indicate data inserted before a constraint was enforced (e.g. a schema migration, a raw import, or a bug in a past data-migration transform).",facing:"INTERNAL",level:"WARN",name:"constraint_validator",remediation:"Inspect the listed rows and correct or remove the violating values. Run a data migration to backfill nulls, dedup unique violations, or re-link dangling FK references. For FK violations, confirm the target table rows exist before fixing the referencing rows.",run:r(a=>{if(!a.tableSamples||a.tableSamples.length===0)return[];let t=new Map;for(let n of a.tableSamples)t.set(n.table,n);let e=new Map(a.schema.tables.map(n=>[n.name,n]));return a.tableSamples.flatMap(n=>lt(B,n,t,e))},"run"),source:"runtime",title:"Constraint violation"};var ct=.5,dt=50,Q={categories:["PERFORMANCE"],description:"One shard is taking a disproportionate share of a sharded function's traffic, so the busy shard becomes a single-DO bottleneck while its siblings sit idle \u2014 the hot-key skew sharding is meant to avoid.",facing:"EXTERNAL",level:"WARN",name:"hot_shard",remediation:"Re-shard on a higher-cardinality / more evenly-distributed key, or split the hot entity's state, so request volume spreads across shards instead of concentrating on one.",run:r(a=>{let t=(a.shardTraffic??[]).filter(i=>i.requests>0),e=t.reduce((i,o)=>i+o.requests,0);if(t.length<2||e<dt)return[];let n=[];for(let i of t){let o=i.requests/e;if(o<ct)continue;let s=i.group!==void 0&&i.group!==""?`"${i.group}" `:"",c=i.shardKey===""?"the root shard":`shard "${i.shardKey}"`,d=Math.round(o*100);n.push(l(Q,{cacheKey:`hot_shard:${i.group??""}:${i.shardKey}`,detail:`${s}${c} handled ${i.requests.toString()} of ${e.toString()} requests (${d.toString()}%) across ${t.length.toString()} shards \u2014 a hot-key skew. Re-shard on a more evenly-distributed key.`,metadata:{group:i.group,requests:i.requests,shardCount:t.length,shardKey:i.shardKey,share:o,totalRequests:e}}))}return n},"run"),source:"runtime",title:"Hot shard"};var ut=25,M={categories:["PERFORMANCE"],description:"Recorded reads show an index the workload doesn't pay for: either a declared index no read ever used (dead overhead on every write) or a table read hot with no index at all (a repeated full scan that degrades as it grows).",facing:"INTERNAL",level:"INFO",name:"index_utilization",remediation:"Drop a dead index so writes stop maintaining it; add an index covering the hot full-scanned table's read predicate so the read stops scanning every row.",run:r(a=>{let t=[];for(let e of a.indexHits??[])e.reads>0||t.push(l(M,{cacheKey:`index_utilization:dead_index:${e.table}:${e.index}`,detail:`Index "${e.index}" on table "${e.table}" has recorded no reads since its counter was created \u2014 it's dead overhead: every write maintains it and nothing reads through it.`,metadata:{index:e.index,kind:"dead_index",reads:e.reads,table:e.table}}));for(let e of a.tableScans??[])e.scans<ut||t.push(l(M,{cacheKey:`index_utilization:hot_scan:${e.table}`,detail:`Table "${e.table}" has been full-scanned ${e.scans.toString()} times (cumulative) with no index \u2014 a repeated full scan that degrades linearly as "${e.table}" grows. Add an index covering the read predicate.`,facing:"EXTERNAL",level:"WARN",metadata:{kind:"hot_scan",scans:e.scans,table:e.table}}));return t},"run"),source:"runtime",title:"Index utilization"};var Y={categories:["SECURITY"],description:"An `httpRoute` on an admin/privileged path has no visible auth/admin guard. REST routes aren't covered by RLS, so an unguarded `/admin/*` route is callable by anyone who reaches the URL.",facing:"EXTERNAL",level:"WARN",name:"admin_route_without_guard",remediation:"Assert an authenticated, authorized caller at the top of the handler \u2014 check `ctx.auth` / `getSession(...)`, or a `requireAdmin`-style guard \u2014 and reject (401/403) before doing privileged work. For machine callers, verify a secret with a timing-safe compare.",run:r(a=>{if(a.adminRoutes===void 0)return[];let t=[];for(let e of a.adminRoutes)e.usesGuard||t.push(l(Y,{cacheKey:`admin_route_without_guard:${e.file}:${e.method}:${e.path}`,detail:`Route \`${e.method} ${e.path}\` (\`${e.exportName}\` in ${e.file}) is on an admin/privileged path but its handler shows no auth/admin guard. Assert an authorized caller before doing privileged work.`,metadata:{exportName:e.exportName,file:e.file,method:e.method,path:e.path}}));return t},"run"),source:"static",title:"Admin route without an auth guard"};var V={categories:["SECURITY"],description:"A `ctx.authApi.<method>(...)` call omits `headers` \u2014 better-auth skips session authorization and runs the call with full server-to-server privileges, regardless of the caller's identity.",facing:"EXTERNAL",level:"WARN",name:"auth_api_call_without_headers",remediation:"Pass the inbound `headers` from the incoming request into every `ctx.authApi.*` call: `ctx.authApi.<method>({ body, headers: request.headers })`. See the `withAuthPlugins` middleware doc for details.",run:r(a=>{if(a.authApiCalls===void 0)return[];let t=[],e=new Map;for(let n of a.authApiCalls){if(n.hasHeaders)continue;let i=`${n.file}:${n.line.toString()}:${n.method}`,o=(e.get(i)??0)+1;e.set(i,o);let s=o>1?`:${o.toString()}`:"";t.push(l(V,{cacheKey:`auth_api_call_without_headers:${i}${s}`,detail:`\`ctx.authApi.${n.method||"<method>"}(\u2026)\` in ${n.exportName} (${n.file}:${n.line.toString()}) is called without \`headers\` \u2014 better-auth skips session authorization, so this runs with full privileges. Pass the inbound \`headers\`.`,metadata:{exportName:n.exportName,file:n.file,line:n.line,method:n.method}}))}return t},"run"),source:"static",title:"Privileged ctx.authApi call missing headers"};var G={categories:["SCHEMA"],description:"A chain of foreign-key relations forms a cycle (e.g. A \u2192 B \u2192 C \u2192 A). Circular FK dependencies can cause unexpected behavior during DELETE operations \u2014 a CASCADE chain may loop indefinitely, and even a RESTRICT cycle prevents deletion of any row in the loop without temporarily disabling constraints.",facing:"INTERNAL",level:"WARN",name:"circular_fk",remediation:"Remove or break the cycle by dropping at least one FK relation from the loop. Consider replacing the circular dependency with a nullable FK and explicit application logic, or restructure the schema using a junction table.",run:r(a=>{let t=[],e=new Map;for(let c of a.schema.tables)for(let d of c.relations){if(d.kind!=="one")continue;let u=e.get(c.name);u===void 0&&(u=new Set,e.set(c.name,u)),u.add(d.table)}let n=new Set,i=new Set,o=r((c,d)=>{let u=d.indexOf(c);if(u===-1)return;let g=d.slice(u);if(g.length<2)return;let m=0;for(let w=1;w<g.length;w+=1)g[w]<g[m]&&(m=w);let h=[...g.slice(m),...g.slice(0,m)],v=h.join("\u2192");if(i.has(v))return;i.add(v);let x=[...h,h[0]].join(" \u2192 ");t.push(l(G,{cacheKey:`circular_fk:${v}`,detail:`Circular foreign-key dependency detected: ${x}. This cycle can cause unexpected behavior during DELETE operations.`,metadata:{cycle:h,path:x,tables:h}}))},"reportBackEdge"),s=r((c,d)=>{n.add(c),d.push(c);for(let u of e.get(c)??[])n.has(u)?o(u,d):s(u,d);d.pop(),n.delete(c)},"dfs");for(let c of a.schema.tables)s(c.name,[]);return t},"run"),source:"static",title:"Circular foreign-key dependency"};var mt=new Set(["standard-3","standard-4"]),ft=2,ht=4096,pt=r(a=>typeof a=="string"?mt.has(a):(a.vcpu??0)>ft||(a.memoryMib??0)>ht,"isOversized"),J={categories:["PERFORMANCE"],description:"A container is declared on a large instance type, whose provisioned memory and disk are billed for the lifetime of every running instance.",facing:"INTERNAL",level:"INFO",name:"container_oversized_instance",remediation:"Confirm the workload needs this size; a smaller instanceType (lite/basic/standard-1) costs less while idle-but-running.",run:r(a=>{let t=[];for(let e of a.containers??[]){let{instanceType:n}=e;if(n===void 0||!pt(n))continue;let i=typeof n=="string"?n:JSON.stringify(n);t.push(l(J,{cacheKey:`container_oversized_instance:${e.exportName}`,detail:`Container "${e.exportName}" uses a large instance type (${i}); its memory + disk are billed while any instance runs.`,metadata:{container:e.exportName,instanceType:n}}))}return t},"run"),source:"static",title:"Oversized container instance"};var Z={categories:["SECURITY"],description:"A container leaves outbound internet access at the default (enabled), which is billed per GB of egress and widens the attack surface.",facing:"INTERNAL",level:"INFO",name:"container_public_internet",remediation:"Set `enableInternet: false` on the container if it doesn't call external services, or `true` to opt in deliberately.",run:r(a=>{let t=[];for(let e of a.containers??[])e.enableInternet===void 0&&t.push(l(Z,{cacheKey:`container_public_internet:${e.exportName}`,detail:`Container "${e.exportName}" doesn't set enableInternet, so outbound internet is on by default (egress is billed).`,metadata:{container:e.exportName}}));return t},"run"),source:"static",title:"Container egress enabled by default"};var gt=r((a,t)=>a.length>t.length?!1:a.every((e,n)=>e===t[n]),"isLeadingPrefix"),ee={categories:["PERFORMANCE"],description:"A secondary index is redundant because another index already covers every lookup it serves (its columns are a leading prefix of the other's). The redundant index costs storage and is maintained on every write for no read benefit.",facing:"INTERNAL",level:"INFO",name:"duplicate_index",remediation:"Drop the redundant index; the covering index already serves its lookups.",run:r(a=>{let t=[];for(let e of a.schema.tables){let n=e.indexes.filter(i=>i.kind==="index");for(let i of n){if(i.unique===!0)continue;let o=n.find(s=>s===i||!gt(i.fields,s.fields)?!1:i.fields.length===s.fields.length?i.name>s.name:!0);o&&t.push(l(ee,{cacheKey:`duplicate_index:${e.name}:${i.name}`,detail:`Index "${i.name}" on table "${e.name}" (${i.fields.join(", ")}) is redundant \u2014 index "${o.name}" (${o.fields.join(", ")}) already covers its lookups.`,metadata:{coveredBy:{fields:o.fields,name:o.name},fields:i.fields,index:i.name,table:e.name}}))}}return t},"run"),source:"static",title:"Duplicate / redundant index"};var te={categories:["SCHEMA"],description:"An index declares no columns, so it indexes nothing and can never narrow a read.",facing:"INTERNAL",level:"WARN",name:"empty_index",remediation:"Give the index its columns, or remove it.",run:r(a=>{let t=[];for(let e of a.schema.tables)for(let n of e.indexes)n.kind!=="index"||n.fields.length>0||t.push(l(te,{cacheKey:`empty_index:${e.name}:${n.name}`,detail:`Index "${n.name}" on table "${e.name}" declares no columns.`,metadata:{index:n.name,table:e.name}}));return t},"run"),source:"static",title:"Empty index"};var ne={categories:["PERFORMANCE"],description:"A query calls `.filter()` without a `.withIndex()` / `.withSearchIndex()`, so it loads every row in the table and filters in memory \u2014 a full table scan that gets linearly slower as the table grows.",facing:"EXTERNAL",level:"WARN",name:"filter_without_index",remediation:'Narrow the read with `.withIndex("name", (q) => q.eq(...))` first, then `.filter()` only for what the index cannot express.',run:r(a=>{let t=[];for(let e of a.queries??[]){if(!e.hasFilter||e.hasIndex||e.table==="")continue;let n=e.line>0?`${e.file}:${e.line.toString()}`:e.file;t.push(l(ne,{cacheKey:`filter_without_index:${e.file}:${e.line.toString()}:${e.table}`,detail:`Query on "${e.table}" at ${n} calls .filter() without an index \u2014 it loads every row of "${e.table}" and filters in memory.`,metadata:{file:e.file,line:e.line,table:e.table}}))}return t},"run"),source:"static",title:"Filter without index"};var ae={categories:["SECURITY"],description:"A secret-shaped string literal (live API key, access key, private key, or high-entropy token) is hard-coded in the source. Committed secrets leak via clone/fork/history and force a redeploy to rotate.",facing:"INTERNAL",level:"ERROR",name:"hardcoded_secret",remediation:'Move the secret out of source: set it locally in `.dev.vars` (`lunora env set <NAME> "<value>"`) and in production with `wrangler secret put <NAME>`, then read it at runtime from `env.<NAME>`. Rotate the exposed value \u2014 assume it is already compromised.',run:r(a=>{if(a.secretLiterals===void 0)return[];let t=[],e=new Map;for(let n of a.secretLiterals){let i=`${n.file}:${n.line.toString()}:${n.kind}`,o=(e.get(i)??0)+1;e.set(i,o);let s=o>1?`:${o.toString()}`:"";t.push(l(ae,{cacheKey:`hardcoded_secret:${i}${s}`,detail:`A ${n.kind.replaceAll("_"," ")} (${n.preview}) is hard-coded at ${n.file}:${n.line.toString()}. Move it to \`.dev.vars\` / \`wrangler secret put\` and read it from \`env\`. Rotate the exposed value.`,metadata:{file:n.file,kind:n.kind,line:n.line,preview:n.preview}}))}return t},"run"),source:"static",title:"Hard-coded secret in source"};var ie={categories:["SCHEMA"],description:"A `query`/`mutation` handler accesses Hyperdrive via `ctx.sql`. Hyperdrive hits an external database Lunora does not own: queries are non-deterministic (like `fetch`) and external writes are invisible to live queries. `ctx.sql` is available on `ActionCtx` only and must be confined to `action` handlers.",facing:"EXTERNAL",level:"WARN",name:"hyperdrive_outside_action",remediation:"Move the `ctx.sql` access into an `action(...)` (the only context where it is typed), where external I/O is allowed. If a query/mutation needs the data, have the action read it via `ctx.sql` and write a projection into a `defineSchema` DO/D1 table \u2014 that write is tracked by live queries, whereas the external DB is not.",run:r(a=>{if(a.hyperdriveCalls===void 0)return[];let t=[];for(let e of a.hyperdriveCalls)t.push(l(ie,{cacheKey:`hyperdrive_outside_action:${e.file}:${e.line.toString()}:${e.callee}`,detail:`\`${e.callee}(\u2026)\` in ${e.exportName} (${e.file}:${e.line.toString()}) runs inside a ${e.kind} handler \u2014 Hyperdrive's \`ctx.sql\` is non-deterministic and non-reactive, so it is available only in actions. Move the external SQL into an \`action\` and project the result into a Lunora table if a query/mutation needs it.`,metadata:{callee:e.callee,exportName:e.exportName,file:e.file,kind:e.kind,line:e.line}}));return t},"run"),source:"static",title:"Hyperdrive `ctx.sql` used outside an action"};var bt=new Set(["_creationTime","_id"]),q=r(a=>new Set([...bt,...a.fields]),"tableColumnSet");var oe={categories:["SCHEMA"],description:"An index references a column that is not declared on its table. The index can never match, and the typo would otherwise surface only at runtime.",facing:"INTERNAL",level:"ERROR",name:"index_references_unknown_field",remediation:"Fix the column name in the index declaration, or add the column to the table.",run:r(a=>{let t=[];for(let e of a.schema.tables){let n=q(e);for(let i of e.indexes)for(let o of i.fields)n.has(o)||t.push(l(oe,{cacheKey:`index_references_unknown_field:${e.name}:${i.name}:${o}`,detail:`Index "${i.name}" on table "${e.name}" references column "${o}", which is not declared on the table.`,metadata:{field:o,index:i.name,indexKind:i.kind,table:e.name}}))}return t},"run"),source:"static",title:"Index references unknown field"};var re={categories:["SECURITY"],description:"A public procedure reads a table whose columns are masked by `.use(mask(...))` elsewhere in the app, but this procedure's builder chain does not include `.use(mask(...))`. It returns those columns in the clear while a sibling procedure redacts them.",facing:"EXTERNAL",level:"WARN",name:"mask_uncovered_pii_column",remediation:"Add `.use(mask(policies))` to the procedure's builder chain \u2014 e.g. `c.use(mask(myMasks)).query(...)` \u2014 so its returned rows redact the same columns as the rest of the app. If this procedure is intentionally privileged (e.g. an admin export), declare it with `internalQuery` / `internalMutation` / `internalAction` instead of the public builder so the intent is explicit.",run:r(a=>{if(a.maskProcedures===void 0)return[];let t=new Map;for(let n of a.maskProcedures)for(let{column:i,table:o}of n.maskColumns){if(o===""||i==="")continue;let s=t.get(o)??new Set;s.add(i),t.set(o,s)}if(t.size===0)return[];let e=[];for(let n of a.maskProcedures){if(n.usesMask||n.visibility==="internal")continue;let i=new Set;for(let o of n.tablesRead)o!==""&&t.has(o)&&i.add(o);for(let o of i){let s=[...t.get(o)??new Set].toSorted((d,u)=>d.localeCompare(u)),c=s.map(d=>`\`${d}\``).join(", ");e.push(l(re,{cacheKey:`mask_uncovered_pii_column:${n.file}:${n.exportName}:${o}`,detail:`\`${n.exportName}\` in ${n.file} reads table \`${o}\` without \`.use(mask(...))\` \u2014 its column${s.length===1?"":"s"} ${c} ${s.length===1?"is":"are"} masked elsewhere in the app but returned in the clear here.`,metadata:{columns:s,exportName:n.exportName,file:n.file,table:o}}))}}return e},"run"),source:"static",title:"Maskable column returned without mask() middleware"};var se={categories:["SCHEMA"],description:"A custom mutator's `server` impl writes with `ctx.db.replace(id, document)` \u2014 a whole-row overwrite. On a synced table this clobbers a concurrent edit to a different column; `ctx.db.patch(id, { field })` merges at the column level so independent field edits coexist.",facing:"EXTERNAL",level:"WARN",name:"mutator_full_row_replace",remediation:"Prefer `ctx.db.patch(id, { onlyTheChangedField })` so a concurrent edit to another column isn't lost. Keep `replace` only when the mutator genuinely owns the entire row (e.g. a full-form save).",run:r(a=>a.mutatorWrites===void 0?[]:a.mutatorWrites.map(t=>l(se,{cacheKey:`mutator_full_row_replace:${t.exportName}:${String(t.line)}`,detail:`Mutator \`${t.exportName}\` (${t.file}:${String(t.line)}) writes with \`ctx.db.replace(...)\`, overwriting the whole row. A concurrent edit to a different column is clobbered \u2014 use \`ctx.db.patch(id, { field })\` to merge at the column level.`,metadata:{exportName:t.exportName,file:t.file,line:t.line}})),"run"),source:"static",title:"Mutator overwrites the whole row (clobbers concurrent column edits)"};var le={categories:["SCHEMA"],description:"A `query`/`mutation` handler calls a non-deterministic API (`Date.now`, `Math.random`, `crypto.randomUUID`, `crypto.getRandomValues`, or `fetch`). These handlers may be re-run on OCC retry / subscription re-evaluation, so they must be deterministic \u2014 time, randomness, and network belong in an `action`.",facing:"EXTERNAL",level:"WARN",name:"nondeterministic_query_mutation",remediation:"Move the non-deterministic call into an `action(...)` (which runs once and may use ambient APIs), then pass the computed value into the mutation as an argument \u2014 e.g. compute `Date.now()` in the action and call `ctx.runMutation(api.\u2026, { now })`. Take generated ids/timestamps as args instead of producing them in the handler.",run:r(a=>{if(a.nondeterministicCalls===void 0)return[];let t=[],e=new Map;for(let n of a.nondeterministicCalls){let i=`${n.file}:${n.line.toString()}:${n.callee}`,o=(e.get(i)??0)+1;e.set(i,o);let s=o>1?`:${o.toString()}`:"";t.push(l(le,{cacheKey:`nondeterministic_query_mutation:${i}${s}`,detail:`\`${n.callee}(\u2026)\` in ${n.exportName} (${n.file}:${n.line.toString()}) runs inside a ${n.kind} handler \u2014 query/mutation handlers must be deterministic. Compute it in an \`action\` and pass the value into the mutation as an argument.`,metadata:{callee:n.callee,exportName:n.exportName,file:n.file,kind:n.kind,line:n.line}}))}return t},"run"),source:"static",title:"Non-deterministic call in query/mutation handler"};var ce={categories:["SECURITY"],description:"An RLS policy is bound to a `table` name that does not exist in the schema. The `rls()` middleware never matches it, so the table the policy was meant to protect is left ungated \u2014 reads return unrestricted rows and writes are allowed.",facing:"EXTERNAL",level:"WARN",name:"policy_references_unknown_table",remediation:"Fix the policy's `table` to a real table name (check for a typo or a table that was renamed/removed). If the table is gone, delete the dead policy.",run:r(a=>{if(a.rlsProcedures===void 0)return[];let t=new Set(a.schema.tables.map(i=>i.name)),e=new Set,n=[];for(let i of a.rlsProcedures)for(let o of i.rlsTables)o===""||t.has(o)||e.has(o)||(e.add(o),n.push(l(ce,{cacheKey:`policy_references_unknown_table:${o}`,detail:`An RLS policy in \`${i.exportName}\` (${i.file}) is bound to table \`${o}\`, which is not declared in the schema. The policy never matches, so \`${o}\` \u2014 if it exists under another name \u2014 is left ungated.`,metadata:{exportName:i.exportName,file:i.file,table:o}})));return n},"run"),source:"static",title:"RLS policy bound to an unknown table"};var de={categories:["SECURITY"],description:"A public procedure declares a `v.any()` argument. `v.any()` accepts arbitrary untyped input from an untrusted client \u2014 defeating validation and opening injection / oversized-payload abuse.",facing:"EXTERNAL",level:"WARN",name:"public_arg_uses_any",remediation:"Replace `v.any()` with a precise validator \u2014 `v.object({...})`, `v.string()`, `v.union(...)`, etc. If the shape is genuinely dynamic, model the known variants with `v.union` rather than accepting anything.",run:r(a=>{if(a.argValidators===void 0)return[];let t=[];for(let e of a.argValidators)for(let n of e.anyArgs)t.push(l(de,{cacheKey:`public_arg_uses_any:${e.file}:${e.exportName}:${n}`,detail:`Arg \`${n}\` of public procedure \`${e.exportName}\` (${e.file}:${e.line.toString()}) is \`v.any()\` \u2014 untrusted input with no validation. Give it a precise validator.`,metadata:{argument:n,exportName:e.exportName,file:e.file,line:e.line}}));return t},"run"),source:"static",title:"Public argument uses v.any()"};var wt=/contact|forgot|login|magic|otp|register|reset|signin|signup|subscribe|verify/iu,ue={categories:["SECURITY"],description:"A public `mutation`/`action` has no `rateLimit` middleware. Publicly-callable writes are flood and brute-force targets \u2014 an attacker can exhaust writes, mail quota, or credits, or guess credentials on auth-shaped endpoints.",facing:"EXTERNAL",level:"WARN",name:"public_mutation_without_ratelimit",remediation:'Attach a rate limit: `.use(rateLimit(limiter, "<bucket>"))` from `@lunora/ratelimit`, or wrap the recommended public-procedure guards with `.use(protectPublic({ rateLimit, captcha }))` from `@lunora/server`. Genuinely-open writes can be acknowledged by adding a permissive limiter.',run:r(a=>{if(a.procedureProtections===void 0)return[];let t=[];for(let e of a.procedureProtections){if(!(e.visibility==="public"&&(e.kind==="mutation"||e.kind==="action"))||e.usesRateLimit)continue;let i=wt.test(e.exportName);t.push(l(ue,{cacheKey:`public_mutation_without_ratelimit:${e.file}:${e.exportName}`,detail:`Public ${e.kind} \`${e.exportName}\` (${e.file}) has no rate limit${i?" \u2014 its name suggests an auth/abuse-sensitive endpoint, so this is high-risk":""}. Add \`.use(rateLimit(...))\` or \`.use(protectPublic({ rateLimit }))\`.`,metadata:{exportName:e.exportName,file:e.file,kind:e.kind,sensitive:i}}))}return t},"run"),source:"static",title:"Public write without a rate limit"};var me={categories:["SCHEMA"],description:"A `query`/`mutation` handler accesses R2 SQL via `ctx.r2sql`. R2 SQL queries external Apache Iceberg tables over REST (no Workers binding): queries are non-deterministic (like `fetch`) and the reads are invisible to live queries. `ctx.r2sql` is available on `ActionCtx` only and must be confined to `action` handlers.",facing:"EXTERNAL",level:"WARN",name:"r2sql_outside_action",remediation:"Move the `ctx.r2sql` access into an `action(...)` (the only context where it is typed), where external I/O is allowed. If a query/mutation needs the data, have the action read it via `ctx.r2sql` and write a projection into a `defineSchema` DO/D1 table \u2014 that write is tracked by live queries, whereas R2 SQL is not.",run:r(a=>{if(a.r2sqlCalls===void 0)return[];let t=[];for(let e of a.r2sqlCalls)t.push(l(me,{cacheKey:`r2sql_outside_action:${e.file}:${e.line.toString()}:${e.callee}`,detail:`\`${e.callee}(\u2026)\` in ${e.exportName} (${e.file}:${e.line.toString()}) runs inside a ${e.kind} handler \u2014 R2 SQL's \`ctx.r2sql\` is non-deterministic and non-reactive, so it is available only in actions. Move the external query into an \`action\` and project the result into a Lunora table if a query/mutation needs it.`,metadata:{callee:e.callee,exportName:e.exportName,file:e.file,kind:e.kind,line:e.line}}));return t},"run"),source:"static",title:"R2 SQL `ctx.r2sql` used outside an action"};var vt=r((a,t,e,n)=>{let i=a.get(n.table);if(!i)return[];let o=n.kind==="one"?e:i,s=n.kind==="one"?i:e,c=[];return t(o).has(n.field)||c.push({column:n.field,owner:o.name,side:"field"}),t(s).has(n.references)||c.push({column:n.references,owner:s.name,side:"references"}),c},"missingColumns"),fe={categories:["SCHEMA"],description:"A relation references a foreign-key or referenced column that is not declared on its table, so the join can never resolve.",facing:"INTERNAL",level:"ERROR",name:"relation_references_unknown_field",remediation:"Fix the `field` / `references` column name in the relation, or add the missing column.",run:r(a=>{let t=new Map(a.schema.tables.map(i=>[i.name,i])),e=new Map,n=r(i=>{let o=e.get(i);return o||(o=q(i),e.set(i,o)),o},"columnsOf");return a.schema.tables.flatMap(i=>i.relations.flatMap(o=>vt(t,n,i,o).map(s=>l(fe,{cacheKey:`relation_references_unknown_field:${i.name}:${o.name}:${s.side}`,detail:`Relation "${o.name}" on table "${i.name}" uses ${s.side} "${s.column}", which is not declared on table "${s.owner}".`,metadata:{column:s.column,owner:s.owner,relation:o.name,side:s.side,table:i.name}}))))},"run"),source:"static",title:"Relation references unknown field"};var he={categories:["SCHEMA"],description:"A relation targets a table that does not exist in the schema. The relation can never load \u2014 the target is a typo or a removed/renamed table.",facing:"INTERNAL",level:"ERROR",name:"relation_references_unknown_table",remediation:"Fix the target table name in the relation, or add the missing table to the schema.",run:r(a=>{let t=[],e=new Set(a.schema.tables.map(n=>n.name));for(let n of a.schema.tables)for(let i of n.relations)e.has(i.table)||t.push(l(he,{cacheKey:`relation_references_unknown_table:${n.name}:${i.name}`,detail:`Relation "${i.name}" on table "${n.name}" targets table "${i.table}", which does not exist in the schema.`,metadata:{relation:i.name,table:n.name,target:i.table}}));return t},"run"),source:"static",title:"Relation references unknown table"};var pe={categories:["SECURITY"],description:"A public procedure reads or writes a table that is covered by an RLS policy elsewhere in the app, but this procedure's builder chain does not include `.use(rls(...))`. The raw, unwrapped `ctx.db` silently bypasses every policy in the list.",facing:"EXTERNAL",level:"WARN",name:"rls_uncovered_table",remediation:"Add `.use(rls(policies))` to the procedure's builder chain \u2014 e.g. `c.use(rls(myPolicies)).query(...)` \u2014 so its `ctx.db` is wrapped by the same policy evaluator as the rest of the app. If this procedure is intentionally privileged (e.g. a background job), declare it with `internalQuery` / `internalMutation` / `internalAction` instead of the public builder so the intent is explicit.",run:r(a=>{if(a.rlsProcedures===void 0)return[];let t=new Set;for(let n of a.rlsProcedures)for(let i of n.rlsTables)i!==""&&t.add(i);if(t.size===0)return[];let e=[];for(let n of a.rlsProcedures){if(n.usesRls||n.visibility==="internal")continue;let i=new Set;for(let o of[...n.tablesRead,...n.tablesWritten])o!==""&&t.has(o)&&i.add(o);for(let o of i)e.push(l(pe,{cacheKey:`rls_uncovered_table:${n.file}:${n.exportName}:${o}`,detail:`\`${n.exportName}\` in ${n.file} accesses table \`${o}\` without \`.use(rls(...))\` \u2014 the table is policy-gated elsewhere in the app but this procedure bypasses those policies entirely.`,metadata:{exportName:n.exportName,file:n.file,table:o}}))}return e},"run"),source:"static",title:"RLS-gated table accessed without rls() middleware"};var ge={categories:["PERFORMANCE"],description:"A `defineShape` replicates from a `.global()` table. Global tables live outside the shard DO's SQLite op-log, so the shape is served through the cross-shard tier \u2014 coordinator/poll-refreshed and latency-tiered, not poke-live like a sharded shape.",facing:"EXTERNAL",level:"WARN",name:"shape_targets_global_table",remediation:"Expected if you want the cross-shard tier \u2014 just don't assume poke-live freshness; global shapes refresh on a poll. For live updates, replicate from a sharded table instead (denormalize the columns you need into the shard).",run:r(a=>{if(a.shapes===void 0)return[];let t=new Set(a.schema.tables.filter(n=>n.shardKind==="global").map(n=>n.name)),e=[];for(let n of a.shapes)n.table===void 0||!t.has(n.table)||e.push(l(ge,{cacheKey:`shape_targets_global_table:${n.exportName}`,detail:`Shape \`${n.exportName}\` (${n.file}) replicates from the \`.global()\` table \`${n.table}\`. It is served through the cross-shard global tier \u2014 poll-refreshed and latency-tiered, not poke-live.`,metadata:{exportName:n.exportName,file:n.file,table:n.table}}));return e},"run"),source:"static",title:"Shape replicates from a global (cross-shard) table"};var be={categories:["SCHEMA"],description:"A `defineShape` is bound to a `table` name that does not exist in the schema. The shape can never resolve a rowset \u2014 its subscription seeds empty and errors at the first flush.",facing:"INTERNAL",level:"ERROR",name:"shape_unknown_table",remediation:"Fix the shape's `table` to a real table name (check for a typo or a table that was renamed/removed).",run:r(a=>{if(a.shapes===void 0)return[];let t=new Set(a.schema.tables.map(n=>n.name)),e=[];for(let n of a.shapes)n.table===void 0||t.has(n.table)||e.push(l(be,{cacheKey:`shape_unknown_table:${n.exportName}`,detail:`Shape \`${n.exportName}\` (${n.file}) replicates from table \`${n.table}\`, which is not declared in the schema. The shape can never resolve a rowset.`,metadata:{exportName:n.exportName,file:n.file,table:n.table}}));return e},"run"),source:"static",title:"Shape bound to an unknown table"};var we={categories:["SECURITY"],description:"A `ctx.sql` tagged-template interpolates an unparameterized string-building expression (concatenation or nested template) instead of a bound value \u2014 splicing raw text into the query and reopening SQL injection.",facing:"EXTERNAL",level:"ERROR",name:"sql_injection_risk",remediation:"Pass the value through a bound placeholder so the driver parameterizes it \u2014 keep request input inside a `ctx.sql` placeholder instead of concatenating it into the query string. Never build SQL text from request input by hand.",run:r(a=>a.sqlInterpolations===void 0?[]:a.sqlInterpolations.map(t=>l(we,{cacheKey:`sql_injection_risk:${t.file}:${t.line.toString()}`,detail:`\`ctx.sql\` in \`${t.exportName}\` (${t.file}:${t.line.toString()}) interpolates a string-building expression instead of a bound value \u2014 a SQL-injection vector. Pass the value through a bound placeholder so the driver parameterizes it.`,metadata:{exportName:t.exportName,file:t.file,line:t.line}})),"run"),source:"static",title:"Possible SQL injection in ctx.sql interpolation"};var ve={categories:["SCHEMA"],description:'No function inserts into this table via `ctx.db.insert("<table>", \u2026)`. It may be read-only by design (seeded by a migration, replicated, or written through a path the advisor can\'t see) \u2014 or it may be dead schema.',facing:"INTERNAL",level:"INFO",name:"table_without_insert",remediation:'If the table should be writable, add a mutation that calls `ctx.db.insert("<table>", \u2026)`. If it is read-only or seeded elsewhere, this advisory can be ignored.',run:r(a=>{if(a.inserts===void 0)return[];let t=new Set(a.inserts.filter(n=>n.table!=="").map(n=>n.table)),e=[];for(let n of a.schema.tables)t.has(n.name)||n.externallyManaged===!0||e.push(l(ve,{cacheKey:`table_without_insert:${n.name}`,detail:`No function calls \`ctx.db.insert("${n.name}", \u2026)\` \u2014 table "${n.name}" has no discovered insert path.`,metadata:{table:n.name}}));return e},"run"),source:"static",title:"Table has no insert path"};var ye={categories:["SECURITY"],description:"A public `v.string()` argument has no maximum-length bound. An unbounded string lets a client submit arbitrarily large input \u2014 abusing storage and CPU on every request that processes it.",facing:"EXTERNAL",level:"INFO",name:"unbounded_string_arg",remediation:"Add a max-length bound via `.check(...)` / `.meta({ maxLength })` on the string validator (e.g. cap a name at 256, a body at a few KB). Size the cap to the field's real-world maximum.",run:r(a=>{if(a.argValidators===void 0)return[];let t=[];for(let e of a.argValidators)for(let n of e.unboundedStringArgs)t.push(l(ye,{cacheKey:`unbounded_string_arg:${e.file}:${e.exportName}:${n}`,detail:`Arg \`${n}\` of public procedure \`${e.exportName}\` (${e.file}:${e.line.toString()}) is an unbounded \`v.string()\`. Add a max-length bound to cap payload size.`,metadata:{argument:n,exportName:e.exportName,file:e.file,line:e.line}}));return t},"run"),source:"static",title:"Public string argument has no length bound"};var K=r(a=>`by${a.charAt(0).toUpperCase()}${a.slice(1)}`,"suggestIndexName"),P=r(a=>new Set(a.indexes.filter(t=>t.kind==="index").map(t=>t.fields[0]).filter(t=>t!==void 0)),"leadingIndexedColumns");var $e={categories:["PERFORMANCE"],description:"A foreign-key column declared by a `one` relation has no index leading with it. Reads that filter or join on the column full-scan the table, which gets linearly slower as rows accumulate.",facing:"EXTERNAL",level:"INFO",name:"unindexed_foreign_key",remediation:'Add a secondary index leading with the FK column, e.g. `.index("byAuthorId", ["authorId"])`.',run:r(a=>{let t=[];for(let e of a.schema.tables){let n=P(e);for(let i of e.relations){if(i.kind!=="one")continue;let o=i.field;if(o==="_id"||n.has(o))continue;let s=K(o);t.push(l($e,{cacheKey:`unindexed_foreign_key:${e.name}:${o}`,detail:`Relation "${i.name}" on table "${e.name}" references "${i.table}" via column "${o}", which is not the leading column of any index. Reads filtering or joining on "${o}" full-scan "${e.name}".`,metadata:{fkColumn:o,references:{column:i.references,table:i.table},relation:i.name,suggestedIndex:{fields:[o],name:s},table:e.name}}))}}return t},"run"),source:"static",title:"Unindexed foreign key"};var ke={categories:["PERFORMANCE"],description:"A `many` relation's foreign-key column on the target table has no index leading with it. Relation predicates (`some`/`none`/`every`) and `with:` child reads filter the target on that column, full-scanning it as rows accumulate.",facing:"EXTERNAL",level:"INFO",name:"unindexed_relation_target",remediation:'Add a secondary index on the target table leading with the FK column, e.g. `.index("byAuthorId", ["authorId"])`.',run:r(a=>{let t=[],e=new Map(a.schema.tables.map(n=>[n.name,n]));for(let n of a.schema.tables)for(let i of n.relations){if(i.kind!=="many")continue;let o=e.get(i.table);if(o===void 0)continue;let s=i.field;if(s==="_id"||o.relations.some(u=>u.kind==="one"&&u.field===s)||P(o).has(s))continue;let d=K(s);t.push(l(ke,{cacheKey:`unindexed_relation_target:${i.table}:${s}`,detail:`Relation "${i.name}" on table "${n.name}" is a to-many over "${i.table}" via its column "${s}", which is not the leading column of any index on "${i.table}". Relation predicates (\`some\`/\`none\`/\`every\`) and \`with:\` reads of "${i.name}" full-scan "${i.table}".`,metadata:{fkColumn:s,references:{column:i.references,table:n.name},relation:i.name,suggestedIndex:{fields:[s],name:d},table:i.table}}))}return t},"run"),source:"static",title:"Unindexed relation target"};var Ae={categories:["SECURITY"],description:"A public `mutation`/`action` that creates a user/session or sends mail has no CAPTCHA / bot check. Account-creating and mail-sending endpoints are prime automated-abuse targets (credential stuffing, mailbox flooding, disposable-account farming).",facing:"EXTERNAL",level:"WARN",name:"user_creating_mutation_without_captcha",remediation:"Add a server-verified human check: `.use(verifyTurnstile({ secret, token }))` from `@lunora/auth`, or wrap it with `.use(protectPublic({ rateLimit, captcha }))` from `@lunora/server`. Pair with a rate limit for defense in depth.",run:r(a=>{if(a.procedureProtections===void 0)return[];let t=[];for(let e of a.procedureProtections){let n=e.visibility==="public"&&(e.kind==="mutation"||e.kind==="action"),i=e.writesUserTable||e.callsMail;if(!n||!i||e.usesCaptcha)continue;let o=e.writesUserTable?"writes a user/session table":"sends mail";t.push(l(Ae,{cacheKey:`user_creating_mutation_without_captcha:${e.file}:${e.exportName}`,detail:`Public ${e.kind} \`${e.exportName}\` (${e.file}) ${o} but has no CAPTCHA check. Add \`.use(verifyTurnstile(...))\` or \`.use(protectPublic({ captcha }))\`.`,metadata:{callsMail:e.callsMail,exportName:e.exportName,file:e.file,kind:e.kind,writesUserTable:e.writesUserTable}}))}return t},"run"),source:"static",title:"Account-creating / mail-sending write without a CAPTCHA"};var Ne={categories:["SCHEMA"],description:"Two durable steps in this workflow share a name. Cloudflare memoizes a step by its name, so on replay the second call returns the first step's cached result instead of running its body \u2014 silently skipping the work without an error.",facing:"INTERNAL",level:"ERROR",name:"workflow_duplicate_step_name",remediation:"Give every `step.do` / `step.sleep` / `step.sleepUntil` / `step.waitForEvent` call in the workflow a unique name. If a step legitimately repeats (e.g. a loop), make the name distinct per iteration by interpolating the item id into the step name.",run:r(a=>{if(a.workflows===void 0)return[];let t=[];for(let e of a.workflows){let{steps:n}=e;if(n===void 0||n.length===0)continue;let i=new Map,o=new Set;for(let s of n){let c=i.get(s.name);if(c===void 0){i.set(s.name,s.line);continue}o.has(s.name)||(o.add(s.name),t.push(l(Ne,{cacheKey:`workflow_duplicate_step_name:${e.exportName}:${s.name}`,detail:`Workflow "${e.exportName}" reuses the durable step name "${s.name}" (first at line ${String(c)}, again at line ${String(s.line)}). The second call returns the first's cached result instead of running.`,metadata:{firstLine:c,line:s.line,stepName:s.name,workflow:e.exportName}})))}}return t},"run"),source:"static",title:"Duplicate durable step name in workflow"};var Se={categories:["SCHEMA"],description:'A `ctx.workflows.get("<name>")` call references a workflow that is not declared by any `defineWorkflow` export in `lunora/workflows.ts`. The name is a typo or points at a removed/renamed workflow \u2014 the call throws at runtime.',facing:"INTERNAL",level:"ERROR",name:"workflow_unknown_target",remediation:'Fix the workflow name in the `ctx.workflows.get("\u2026")` call, or add the missing `defineWorkflow` export to `lunora/workflows.ts`.',run:r(a=>{if(a.workflows===void 0||a.workflowCalls===void 0)return[];let t=new Set(a.workflows.map(n=>n.exportName)),e=[];for(let n of a.workflowCalls)n.workflow===""||t.has(n.workflow)||e.push(l(Se,{cacheKey:`workflow_unknown_target:${n.file}:${n.exportName}:${n.workflow}`,detail:`\`ctx.workflows.get("${n.workflow}")\` in "${n.exportName}" (${n.file}) references workflow "${n.workflow}", which is not declared in lunora/workflows.ts.`,metadata:{exportName:n.exportName,file:n.file,line:n.line,workflow:n.workflow}}));return e},"run"),source:"static",title:"Workflow call references unknown workflow"};var Re={categories:["SCHEMA"],description:'No function starts this workflow via `ctx.workflows.get("<name>")`. It may be triggered through a path the advisor can\'t see (the Cloudflare API, a wrangler invocation, a cross-service binding) \u2014 or it may be dead code that still deploys as a billable WorkflowEntrypoint.',facing:"INTERNAL",level:"INFO",name:"workflow_unused",remediation:'If the workflow should be triggered in-app, start it from a mutation/action with `ctx.workflows.get("<name>").create({ params })`. If it is started externally or is no longer needed, this advisory can be ignored (or remove the `defineWorkflow` export).',run:r(a=>{if(a.workflows===void 0)return[];let t=a.workflowCalls??[];if(t.some(i=>i.workflow===""))return[];let e=new Set(t.map(i=>i.workflow)),n=[];for(let i of a.workflows)e.has(i.exportName)||n.push(l(Re,{cacheKey:`workflow_unused:${i.exportName}`,detail:`No function calls \`ctx.workflows.get("${i.exportName}")\` \u2014 workflow "${i.exportName}" is declared but never started in app code.`,metadata:{workflow:i.exportName}}));return n},"run"),source:"static",title:"Workflow is never started"};var yt=[oe,he,fe,Se,Ne,be,te,G,$e,ke,ee,ve,Re,ne,ge,se,le,ie,me,V,ce,pe,re,J,Z,ue,Ae,de,ye,ae,we,Y],_e=[Q,M,B],xt=[...yt,..._e],ze=r((a,t={})=>{let e=t.lints??xt,n=[];for(let i of e)t.source!==void 0&&i.source!==t.source||n.push(...i.run(a));return n},"runAdvisor");var $t=r(a=>{let{suggestedIndex:t,table:e}=a;return!(typeof e!="string"||e.length===0||typeof t!="object"||t===null||!Array.isArray(t.fields)||t.fields.length===0)},"hasIndexMetadata"),kt=r((a,t,e)=>{let n=`"${a}"`,i=`"${t}"`,o=e.map(s=>`"${s}"`).join(", ");return`CREATE INDEX IF NOT EXISTS ${i} ON ${n} (${o});`},"composeCreateIndex"),At=r(a=>{let t=(0,Ee.c)(19),{fields:e,indexName:n,table:i,testId:o}=a,s=I(),[c,d]=(0,y.useState)(!1),u;t[0]!==e||t[1]!==n||t[2]!==i?(u=r(()=>{let x="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if(x===void 0)return;let w=kt(i,n,e);T(x.writeText(w)),d(!0)},"t1"),t[0]=e,t[1]=n,t[2]=i,t[3]=u):u=t[3];let g=u;if(c){let x=`${o}-applied`,w;t[4]!==s?(w=s("CREATE INDEX SQL copied to clipboard."),t[4]=s,t[5]=w):w=t[5];let S;return t[6]!==x||t[7]!==w?(S=(0,A.jsxDEV)("span",{className:"text-xs text-muted-foreground","data-testid":x,children:w},void 0,!1),t[6]=x,t[7]=w,t[8]=S):S=t[8],S}let m;t[9]!==s?(m=s("Apply?"),t[9]=s,t[10]=m):m=t[10];let h;t[11]!==s||t[12]!==i?(h=s("Apply index on {table}",{table:i}),t[11]=s,t[12]=i,t[13]=h):h=t[13];let v;return t[14]!==g||t[15]!==m||t[16]!==h||t[17]!==o?(v=(0,A.jsxDEV)(je,{confirmLabel:m,onConfirm:g,testId:o,children:h},void 0,!1),t[14]=g,t[15]=m,t[16]=h,t[17]=o,t[18]=v):v=t[18],v},"ApplyIndexButton"),Nt=r((a,t)=>{let e=new Map;for(let n of t){let i=`${n.table} ${n.index}`;e.set(i,(e.get(i)??0)+n.reads)}return a.map(n=>({index:n.index,reads:e.get(`${n.table} ${n.index}`)??0,table:n.table}))},"reconcileIndexHits"),St=r(a=>{let t=new Map;for(let e of a)for(let n of e.scannedTables??[])t.set(n.table,(t.get(n.table)??0)+n.scans);return[...t].map(([e,n])=>({scans:n,table:e}))},"aggregateTableScans"),Rt=r((a,t)=>t.map(e=>({index:e.name,table:a})),"declaredIndexesFor"),_t=r(a=>{let t=Nt(a.declaredIndexes??[],a.indexHits??[]),e=St(a.functions??[]),n=a.shardTraffic??[],i=a.analyticsMetrics,o=i&&i.indexHits.length>0?i.indexHits:t,s=i&&i.tableScans.length>0?i.tableScans:e,c=i&&i.shardTraffic.length>0?i.shardTraffic:n,d=ze({indexHits:o,schema:{tables:[]},shardTraffic:c,tableScans:s},{lints:_e,source:"runtime"}),u=a.suppressHotScanTables;return(u===void 0?d:d.filter(m=>!(m.metadata.kind==="hot_scan"&&typeof m.metadata.table=="string"&&u.has(m.metadata.table)))).map(m=>D(m))},"deriveRuntimeAdvisories"),Tt=H(R.listTables),Et=H(R.listTableIndexes),Te=r(a=>`${(a*100).toFixed(1)}%`,"percent"),Xe=r(a=>`${(a/1e3).toFixed(2)}s`,"seconds"),It=r(a=>{if(a.length<=1)return a[0]??"";let t=a[a.length-1]??"";return`${a.slice(0,-1).join(", ")} and ${t}`},"tableList"),Ct=r((a,t)=>({"high-error-rate":a("High error rate"),"high-evictions":a("High cache eviction rate"),"high-write-contention":a("High write contention"),"low-cache-hit-rate":a("Low cache hit rate"),"missing-index":a("Missing index"),"slow-function":a("Slow function")})[t.kind],"insightTitle"),Be=r((a,t)=>({"high-error-rate":a("{rate} of calls failed.",{rate:Te(t.value)}),"high-evictions":a("{count} entries evicted recently.",{count:t.value}),"high-write-contention":a("{rate} of calls hit a write conflict \u2014 consider sharding to cut contention.",{rate:Te(t.value)}),"low-cache-hit-rate":a("{rate} hit rate over recent traffic.",{rate:Te(t.value)}),"missing-index":a("Slowest call took {duration} \u2014 it full-scanned {tables} with no index.",{duration:Xe(t.value),tables:It(t.tables??[])}),"slow-function":a("Slowest call took {duration}.",{duration:Xe(t.value)})})[t.kind],"insightDetail"),Lt=r(a=>{let t=(0,Ee.c)(10),{onJump:e,table:n}=a,i=I(),o;t[0]!==e||t[1]!==n?(o=r(()=>{e(n)},"t1"),t[0]=e,t[1]=n,t[2]=o):o=t[2];let s=o,c=`in-add-index-${n}`,d;t[3]!==i||t[4]!==n?(d=i("Add index on {table}",{table:n}),t[3]=i,t[4]=n,t[5]=d):d=t[5];let u;return t[6]!==s||t[7]!==c||t[8]!==d?(u=(0,A.jsxDEV)(Fe,{"data-testid":c,onClick:s,size:"sm",type:"button",variant:"outline",children:d},void 0,!1),t[6]=s,t[7]=c,t[8]=d,t[9]=u):u=t[9],u},"AddIndexButton"),Oi=r(({initialShardKey:a,loadShardTraffic:t})=>{let e=Ke(),n=Pe(),i=I(),[o,s]=(0,y.useState)(a??""),[c,d]=(0,y.useState)(null),[u,g]=(0,y.useState)(null),m=We(o.trim(),400),h=(0,y.useRef)(""),v=C(R.getMetrics,{},{live:!0,shardKey:m}),x=C(R.getFunctionStats,{},{live:!0,shardKey:m}),w=C(R.getAdvisories,{},{live:!0,shardKey:m}),S=v.data??null,Ie=x.data?.functions??null,Ce=w.data?.advisories??null,Qe=v.data?.indexHits??null,Le=v.error!==null&&x.error!==null?v.error:null,Ye=t??(f=>e.shardTraffic(f)),Ve=r(async(f,k)=>{let N=f[0];if(N===void 0||N===""){h.current===k&&g(null);return}try{let p=await Ye(N);if(h.current!==k)return;let $=new Map;for(let b of p.shards)$.has(b.shardKey)||$.set(b.shardKey,{requests:b.requests,shardKey:b.shardKey});g([...$.values()])}catch{h.current===k&&g(null)}},"loadShardTrafficFeed"),E=(0,y.useCallback)(async f=>{h.current=f;let k=[];try{let N=await e.query(Tt,{},W(f));if(h.current!==f)return;Ue(f),k=N.map(b=>b.name);let p=await Promise.allSettled(N.map(async b=>[b.name,await e.query(Et,{table:b.name},W(f))]));if(h.current!==f)return;let $=[];for(let b of p)if(b.status==="fulfilled"){let[_,O]=b.value;$.push(...Rt(_,O.indexes))}d($)}catch{h.current===f&&d(null)}await Ve(k,f)},[e]);(0,y.useEffect)(()=>{T(E(m))},[m,E]),(0,y.useEffect)(()=>{let f=r(()=>{document.visibilityState==="visible"&&(v.refetch(),x.refetch(),w.refetch(),T(E(m)))},"onVisible");return document.addEventListener("visibilitychange",f),()=>{document.removeEventListener("visibilitychange",f)}},[w,m,E,x,v]);let Me=(0,y.useCallback)(f=>{T(n({search:{table:f},to:"/schema"}))},[n]),F=Oe(S,Ie),Ge=new Set(F.filter(f=>f.kind==="missing-index").flatMap(f=>f.tables??[])),qe=_t({declaredIndexes:c??[],functions:Ie,indexHits:Qe,shardTraffic:u,suppressHotScanTables:Ge}),Je=(0,y.useMemo)(()=>{let f=F.map(p=>{let $=p.kind==="missing-index"?p.tables??[]:[];return{action:$.length>0?$.map(b=>(0,A.jsxDEV)(Lt,{onJump:Me,table:b},b,!1)):void 0,description:p.message===void 0?Be(i,p):`${Be(i,p)} \u2014 ${p.message}`,entity:p.fn,issueType:Ct(i,p),key:`${p.kind}:${p.fn??""}`,level:p.severity}}),k=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(Ce??[]).map(p=>{let $=D(p);if(k.has(p.name)&&$t(p.metadata)){let{table:b,suggestedIndex:_}=p.metadata,O=`in-apply-index-${b}-${_.name}`;return{...$,action:(0,A.jsxDEV)(At,{fields:_.fields,indexName:_.name,table:b,testId:O},void 0,!1)}}return $}),...qe,...f]},[Ce,F,Me,qe,i]),Ze=(0,A.jsxDEV)(He,{onChange:s,testId:"in-shard-input",value:o},void 0,!1);return(0,A.jsxDEV)(De,{error:Le,errorSource:Le===null?void 0:v.errorSource,rows:Je,testId:"lunora-insights",toolbar:Ze},void 0,!1)},"InsightsPanel");export{Oi as InsightsPanel};