@lunora/studio 1.0.0-alpha.63 → 1.0.0-alpha.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/packem_chunks/MetricsPanel.js +1 -1
  3. package/dist/packem_chunks/issues-panel.js +1 -1
  4. package/dist/packem_chunks/payments-panel.js +1 -1
  5. package/dist/standalone/{chunk-SM67QXQI.js → chunk-2F7G7IWQ.js} +1 -1
  6. package/dist/standalone/chunk-34UVAASH.js +1 -0
  7. package/dist/standalone/chunk-35II7U25.js +11 -0
  8. package/dist/standalone/{chunk-UVDPQU7J.js → chunk-3FUFEZ65.js} +1 -1
  9. package/dist/standalone/{chunk-VSS7NFZJ.js → chunk-3QRTYSSX.js} +1 -1
  10. package/dist/standalone/{chunk-PZPFWABF.js → chunk-4WLYA3XE.js} +1 -1
  11. package/dist/standalone/{chunk-TDE4AR5O.js → chunk-5OWIOACV.js} +1 -1
  12. package/dist/standalone/{chunk-ZSWWTXVW.js → chunk-5U2THBI7.js} +1 -1
  13. package/dist/standalone/{chunk-DY7CLL2H.js → chunk-65OTWFS3.js} +1 -1
  14. package/dist/standalone/chunk-6DWCIIHE.js +1 -0
  15. package/dist/standalone/{chunk-IJFCOWEQ.js → chunk-7J5N6DGQ.js} +1 -1
  16. package/dist/standalone/{chunk-M7QCL3ZP.js → chunk-B43FTQJ7.js} +1 -1
  17. package/dist/standalone/{chunk-TCQEDMAQ.js → chunk-BNUJ7QMG.js} +1 -1
  18. package/dist/standalone/{chunk-RLEENOIX.js → chunk-C43X4M5U.js} +1 -1
  19. package/dist/standalone/{chunk-JGY4NGFW.js → chunk-D7XXWV4E.js} +1 -1
  20. package/dist/standalone/{chunk-4MSKCWUL.js → chunk-DVOBKIUX.js} +1 -1
  21. package/dist/standalone/{chunk-K7M4SMQ7.js → chunk-EKRN4ZQM.js} +1 -1
  22. package/dist/standalone/{chunk-IGBEXNXY.js → chunk-EVN46TVV.js} +1 -1
  23. package/dist/standalone/{chunk-NPIULIRO.js → chunk-EXFBIISG.js} +1 -1
  24. package/dist/standalone/{chunk-OZGWNJXD.js → chunk-F5QWLENA.js} +1 -1
  25. package/dist/standalone/chunk-F6GOKFMU.js +3 -0
  26. package/dist/standalone/{chunk-PYXZLNG2.js → chunk-FGTK44LR.js} +1 -1
  27. package/dist/standalone/{chunk-XBGJVK32.js → chunk-GSPTEMYN.js} +1 -1
  28. package/dist/standalone/{chunk-XITDHIVL.js → chunk-HP2UCWND.js} +1 -1
  29. package/dist/standalone/{chunk-WQTUQZUM.js → chunk-IDNNI63H.js} +1 -1
  30. package/dist/standalone/{chunk-ZKEVSU66.js → chunk-KDOC2DP5.js} +1 -1
  31. package/dist/standalone/{chunk-P4J3Z3SA.js → chunk-L7N7F3DA.js} +1 -1
  32. package/dist/standalone/{chunk-IPHXIGYP.js → chunk-LJDP7NRB.js} +1 -1
  33. package/dist/standalone/{chunk-GBQHGYGH.js → chunk-OHKRN65U.js} +1 -1
  34. package/dist/standalone/{chunk-LA3HEESS.js → chunk-P24JBHEZ.js} +1 -1
  35. package/dist/standalone/chunk-PWWHP76O.js +1 -0
  36. package/dist/standalone/{chunk-IUW24D4X.js → chunk-QGKAJTQQ.js} +1 -1
  37. package/dist/standalone/{chunk-AX4PAEGP.js → chunk-QVEHPYA5.js} +1 -1
  38. package/dist/standalone/{chunk-7YAUSG6S.js → chunk-QWJ3NPE3.js} +1 -1
  39. package/dist/standalone/{chunk-H3V2QQ4K.js → chunk-RAA2RGG6.js} +1 -1
  40. package/dist/standalone/chunk-RBU52M5T.js +1 -0
  41. package/dist/standalone/{chunk-RWZKO2P6.js → chunk-SA3MDZC3.js} +1 -1
  42. package/dist/standalone/{chunk-66TS6K5F.js → chunk-T2JIUFOD.js} +1 -1
  43. package/dist/standalone/chunk-TJ2WZ5OP.js +1 -0
  44. package/dist/standalone/{chunk-37RIZFJ4.js → chunk-TLHJRWNK.js} +1 -1
  45. package/dist/standalone/{chunk-YQP2EYOC.js → chunk-UIS34ZPB.js} +1 -1
  46. package/dist/standalone/{chunk-P4DHFWH7.js → chunk-VPAXCQ2Y.js} +1 -1
  47. package/dist/standalone/{chunk-V4RWA7QI.js → chunk-XEDU5FO4.js} +1 -1
  48. package/dist/standalone/{chunk-M2B3MDFJ.js → chunk-XQBTNJUQ.js} +1 -1
  49. package/dist/standalone/{chunk-OWADN6BI.js → chunk-XSD4Y6SQ.js} +1 -1
  50. package/dist/standalone/{chunk-BY4QROKU.js → chunk-YD5NF6UT.js} +1 -1
  51. package/dist/standalone/{chunk-DCJKCERP.js → chunk-YI3WYUXK.js} +1 -1
  52. package/dist/standalone/{chunk-26TQSVUV.js → chunk-ZNNAGR6N.js} +1 -1
  53. package/dist/standalone/studio.js +1 -1
  54. package/package.json +4 -4
  55. package/dist/standalone/chunk-3NHORZCK.js +0 -1
  56. package/dist/standalone/chunk-B5E7GQHG.js +0 -1
  57. package/dist/standalone/chunk-F6LUZVVI.js +0 -1
  58. package/dist/standalone/chunk-GHUPW2Y5.js +0 -1
  59. package/dist/standalone/chunk-LWECXQWP.js +0 -11
  60. package/dist/standalone/chunk-TRHTFGFW.js +0 -3
@@ -1 +1 @@
1
- import{a as q,b as L,c as B,d as f,e as c,f as d}from"./chunk-MIQTKZAR.js";import{a as I,e as j}from"./chunk-UZERI5YC.js";import{R as Q}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as W}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{f as F}from"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{a as Z}from"./chunk-XQCVZAGU.js";import{d as K,h as S,l as $,m as V}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as h,e as C,f as R,g as P,h as U}from"./chunk-3XIESWL4.js";var A=C(P(),1);var n=C(R(),1);var e=C(U(),1);var X=10,g=h(v=>{let l=(0,A.c)(7),{label:m,value:t}=v,r;l[0]!==m?(r=(0,e.jsx)("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:m}),l[0]=m,l[1]=r):r=l[1];let p=t??"\u2014",s;l[2]!==p?(s=(0,e.jsx)("span",{className:"font-mono text-sm",children:p}),l[2]=p,l[3]=s):s=l[3];let u;return l[4]!==r||l[5]!==s?(u=(0,e.jsxs)("div",{className:"flex flex-col gap-0.5",children:[r,s]}),l[4]=r,l[5]=s,l[6]=u):u=l[6],u},"g"),se=h(({loadIndexes:v,runQuery:l}={})=>{let m=F(),t=K(),[r,p]=(0,n.useState)(null),[s,u]=(0,n.useState)(null),[N,E]=(0,n.useState)(null),[b,D]=(0,n.useState)(""),[x,y]=(0,n.useState)(null),[M,w]=(0,n.useState)(null),[T,z]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let a={cancelled:!1};return V((async()=>{try{let i=await(v??(()=>m.listVectorIndexes()))();a.cancelled||(p(i),u(null),E(k=>k??i[0]?.name??null))}catch(i){a.cancelled||(p(null),u(S(i)))}})()),()=>{a.cancelled=!0}},[m,v]);let o=r?.find(a=>a.name===N)??null,G=h(a=>{E(a.currentTarget.dataset.index??null),y(null),w(null)},"K"),H=h(a=>{D(a.target.value)},"T"),J=h(async()=>{let a=b.trim();if(!(N===null||a==="")){z(!0),w(null);try{let i=await(l??(k=>m.queryVectorIndex(k)))({name:N,text:a,topK:X});y(i)}catch(i){y(null),w(S(i))}finally{z(!1)}}},"Z"),O=h(()=>{V(J())},"z");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-vector-browser",children:[s!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"vector-error",role:"alert",children:s}),r!==null&&r.length===0&&(0,e.jsx)(Z,{description:t("Indexes declared with .vectorize() or defineVectorIndex() appear here."),icon:(0,e.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsx)("path",{d:"M4 7l8-4 8 4-8 4-8-4Zm0 5 8 4 8-4M4 17l8 4 8-4"})}),testId:"vector-empty",title:t("No vector indexes.")}),r!==null&&r.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(q,{"data-testid":"vector-table",children:[(0,e.jsx)(L,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(c,{children:t("name")}),(0,e.jsx)(c,{children:t("table")}),(0,e.jsx)(c,{children:t("dimensions")}),(0,e.jsx)(c,{children:t("metric")}),(0,e.jsx)(c,{children:t("vectors")})]})}),(0,e.jsx)(B,{children:r.map(a=>(0,e.jsxs)(f,{className:a.name===N?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":a.name,"data-testid":`vector-row-${a.name}`,onClick:G,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:a.name}),(0,e.jsx)(d,{className:"font-mono text-xs",children:a.table}),(0,e.jsx)(d,{className:"tabular-nums",children:a.dimensions??"\u2014"}),(0,e.jsx)(d,{children:a.metric??"\u2014"}),(0,e.jsx)(d,{className:"tabular-nums",children:a.vectorsCount??"\u2014"})]},a.name))})]})})}),o!==null&&(0,e.jsxs)("section",{className:"border border-border bg-card p-3","data-testid":"vector-detail",children:[(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[(0,e.jsx)(g,{label:t("field"),value:o.field}),(0,e.jsx)(g,{label:t("dimensions"),value:o.dimensions}),(0,e.jsx)(g,{label:t("metric"),value:o.metric}),(0,e.jsx)(g,{label:t("vectors"),value:o.vectorsCount})]}),o.metadata!==void 0&&o.metadata.length>0&&(0,e.jsxs)("p",{className:"mt-3 text-xs text-muted-foreground","data-testid":"vector-metadata",children:[t("metadata"),": ",(0,e.jsx)("span",{className:"font-mono",children:o.metadata.join(", ")})]}),(0,e.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,e.jsx)(Q,{className:"min-w-[18rem] flex-1","data-testid":"vector-query-input",onChange:H,placeholder:t("Search by similarity\u2026"),value:b}),(0,e.jsx)(W,{"data-testid":"vector-search",disabled:T||b.trim()==="",onClick:O,children:t(T?"Searching\u2026":"Search")})]}),M!==null&&(0,e.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"vector-query-error",role:"alert",children:M}),x!==null&&x.length===0&&(0,e.jsx)("p",{className:"mt-2 text-sm text-muted-foreground","data-testid":"vector-no-matches",children:t("No matches.")}),x!==null&&x.length>0&&(0,e.jsx)(I,{className:"mt-3 overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(q,{"data-testid":"vector-matches",children:[(0,e.jsx)(L,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(c,{children:t("id")}),(0,e.jsx)(c,{children:t("score")}),(0,e.jsx)(c,{children:t("metadata")})]})}),(0,e.jsx)(B,{children:x.map(a=>(0,e.jsxs)(f,{"data-testid":`vector-match-${a.id}`,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:a.id}),(0,e.jsx)(d,{className:"tabular-nums",children:a.score.toFixed(4)}),(0,e.jsx)(d,{className:"max-w-md truncate font-mono text-xs",children:a.metadata===void 0?"\u2014":$(a.metadata)})]},a.id))})]})})})]})]})},"ce");export{se as VectorBrowser};
1
+ import{a as q,b as L,c as B,d as f,e as c,f as d}from"./chunk-MIQTKZAR.js";import{a as I,e as j}from"./chunk-UZERI5YC.js";import{R as Q}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as W}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{f as F}from"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import{a as Z}from"./chunk-XQCVZAGU.js";import{d as K,h as S,l as $,m as V}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as h,e as C,f as R,g as P,h as U}from"./chunk-3XIESWL4.js";var A=C(P(),1);var n=C(R(),1);var e=C(U(),1);var X=10,g=h(v=>{let l=(0,A.c)(7),{label:m,value:t}=v,r;l[0]!==m?(r=(0,e.jsx)("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:m}),l[0]=m,l[1]=r):r=l[1];let p=t??"\u2014",s;l[2]!==p?(s=(0,e.jsx)("span",{className:"font-mono text-sm",children:p}),l[2]=p,l[3]=s):s=l[3];let u;return l[4]!==r||l[5]!==s?(u=(0,e.jsxs)("div",{className:"flex flex-col gap-0.5",children:[r,s]}),l[4]=r,l[5]=s,l[6]=u):u=l[6],u},"g"),se=h(({loadIndexes:v,runQuery:l}={})=>{let m=F(),t=K(),[r,p]=(0,n.useState)(null),[s,u]=(0,n.useState)(null),[N,E]=(0,n.useState)(null),[b,D]=(0,n.useState)(""),[x,y]=(0,n.useState)(null),[M,w]=(0,n.useState)(null),[T,z]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let a={cancelled:!1};return V((async()=>{try{let i=await(v??(()=>m.listVectorIndexes()))();a.cancelled||(p(i),u(null),E(k=>k??i[0]?.name??null))}catch(i){a.cancelled||(p(null),u(S(i)))}})()),()=>{a.cancelled=!0}},[m,v]);let o=r?.find(a=>a.name===N)??null,G=h(a=>{E(a.currentTarget.dataset.index??null),y(null),w(null)},"K"),H=h(a=>{D(a.target.value)},"T"),J=h(async()=>{let a=b.trim();if(!(N===null||a==="")){z(!0),w(null);try{let i=await(l??(k=>m.queryVectorIndex(k)))({name:N,text:a,topK:X});y(i)}catch(i){y(null),w(S(i))}finally{z(!1)}}},"Z"),O=h(()=>{V(J())},"z");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-vector-browser",children:[s!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"vector-error",role:"alert",children:s}),r!==null&&r.length===0&&(0,e.jsx)(Z,{description:t("Indexes declared with .vectorize() or defineVectorIndex() appear here."),icon:(0,e.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsx)("path",{d:"M4 7l8-4 8 4-8 4-8-4Zm0 5 8 4 8-4M4 17l8 4 8-4"})}),testId:"vector-empty",title:t("No vector indexes.")}),r!==null&&r.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(q,{"data-testid":"vector-table",children:[(0,e.jsx)(L,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(c,{children:t("name")}),(0,e.jsx)(c,{children:t("table")}),(0,e.jsx)(c,{children:t("dimensions")}),(0,e.jsx)(c,{children:t("metric")}),(0,e.jsx)(c,{children:t("vectors")})]})}),(0,e.jsx)(B,{children:r.map(a=>(0,e.jsxs)(f,{className:a.name===N?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":a.name,"data-testid":`vector-row-${a.name}`,onClick:G,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:a.name}),(0,e.jsx)(d,{className:"font-mono text-xs",children:a.table}),(0,e.jsx)(d,{className:"tabular-nums",children:a.dimensions??"\u2014"}),(0,e.jsx)(d,{children:a.metric??"\u2014"}),(0,e.jsx)(d,{className:"tabular-nums",children:a.vectorsCount??"\u2014"})]},a.name))})]})})}),o!==null&&(0,e.jsxs)("section",{className:"border border-border bg-card p-3","data-testid":"vector-detail",children:[(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[(0,e.jsx)(g,{label:t("field"),value:o.field}),(0,e.jsx)(g,{label:t("dimensions"),value:o.dimensions}),(0,e.jsx)(g,{label:t("metric"),value:o.metric}),(0,e.jsx)(g,{label:t("vectors"),value:o.vectorsCount})]}),o.metadata!==void 0&&o.metadata.length>0&&(0,e.jsxs)("p",{className:"mt-3 text-xs text-muted-foreground","data-testid":"vector-metadata",children:[t("metadata"),": ",(0,e.jsx)("span",{className:"font-mono",children:o.metadata.join(", ")})]}),(0,e.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,e.jsx)(Q,{className:"min-w-[18rem] flex-1","data-testid":"vector-query-input",onChange:H,placeholder:t("Search by similarity\u2026"),value:b}),(0,e.jsx)(W,{"data-testid":"vector-search",disabled:T||b.trim()==="",onClick:O,children:t(T?"Searching\u2026":"Search")})]}),M!==null&&(0,e.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"vector-query-error",role:"alert",children:M}),x!==null&&x.length===0&&(0,e.jsx)("p",{className:"mt-2 text-sm text-muted-foreground","data-testid":"vector-no-matches",children:t("No matches.")}),x!==null&&x.length>0&&(0,e.jsx)(I,{className:"mt-3 overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(q,{"data-testid":"vector-matches",children:[(0,e.jsx)(L,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(c,{children:t("id")}),(0,e.jsx)(c,{children:t("score")}),(0,e.jsx)(c,{children:t("metadata")})]})}),(0,e.jsx)(B,{children:x.map(a=>(0,e.jsxs)(f,{"data-testid":`vector-match-${a.id}`,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:a.id}),(0,e.jsx)(d,{className:"tabular-nums",children:a.score.toFixed(4)}),(0,e.jsx)(d,{className:"max-w-md truncate font-mono text-xs",children:a.metadata===void 0?"\u2014":$(a.metadata)})]},a.id))})]})})})]})]})},"ce");export{se as VectorBrowser};
@@ -1 +1 @@
1
- import{a as T}from"./chunk-X2FQ6B5V.js";import{b as k}from"./chunk-OWADN6BI.js";import{a as D,b as E,c as O,d as C,e as i,f as o}from"./chunk-MIQTKZAR.js";import{a as I,e as $}from"./chunk-UZERI5YC.js";import{b}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as A}from"./chunk-GXZAXNZI.js";import"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{a as L}from"./chunk-XQCVZAGU.js";import{d as S}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as v,e as w,f as K,g as M,h as P}from"./chunk-3XIESWL4.js";var j=w(M(),1),q=w(K(),1);var t=w(P(),1);var _="container:",W={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},B=v(e=>{let n=e.indexOf(":");if(n===-1)return{event:e.trim()};let r=e.slice(n+1).trim(),a=e.slice(0,n).trim();return r===""?{event:a}:{detail:r,event:a}},"j"),F=v(e=>{let n=new Map;for(let r of e){let a=r.functionPath??"";if(!a.startsWith(_))continue;let s=a.slice(_.length);if(s==="")continue;let c=JSON.stringify([s,r.instance??""]),m=n.get(c);if(m!==void 0&&m.timestamp>=r.timestamp)continue;let{detail:g,event:l}=B(r.message);n.set(c,{detail:g,event:l,exitCode:r.exitCode,instance:r.instance,level:r.level,name:s,state:W[l]??"unknown",timestamp:r.timestamp})}return[...n.values()].toSorted((r,a)=>r.name.localeCompare(a.name)||(r.instance??"").localeCompare(a.instance??""))},"K"),J={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},U=v(e=>{let{entries:n}=e??{};return Array.isArray(n)?n:[]},"W"),ee=v(()=>{let e=(0,j.c)(23),n=S(),r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},a={live:!0,shardKey:""},e[0]=r,e[1]=a):(r=e[0],a=e[1]);let{data:s,error:c,liveError:m}=k(A.getLogs,r,a),g=s!==void 0,l;e[2]!==s?(l=F(U(s)),e[2]=s,e[3]=l):l=e[3];let N=l,d;e[4]!==c?(d=c!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:c}),e[4]=c,e[5]=d):d=e[5];let h;e[6]!==n?(h=n("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance \u2014 ports and health checks aren't carried in that stream."),e[6]=n,e[7]=h):h=e[7];let p;e[8]!==h?(p=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:h}),e[8]=h,e[9]=p):p=e[9];let u;e[10]!==m?(u=(0,t.jsx)(T,{message:m,prefix:"containers"}),e[10]=m,e[11]=u):u=e[11];let f;e[12]!==p||e[13]!==u?(f=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[p,u]}),e[12]=p,e[13]=u,e[14]=f):f=e[14];let x;e[15]!==g||e[16]!==N||e[17]!==n?(x=g&&N.length===0?(0,t.jsx)(L,{description:n("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:n("No container activity")}):(0,t.jsx)(I,{className:"overflow-hidden py-0",children:(0,t.jsx)($,{className:"px-0",children:(0,t.jsxs)(D,{"data-testid":"containers-table",children:[(0,t.jsx)(E,{children:(0,t.jsxs)(C,{children:[(0,t.jsx)(i,{children:n("Container")}),(0,t.jsx)(i,{children:n("Instance")}),(0,t.jsx)(i,{children:n("State")}),(0,t.jsx)(i,{children:n("Last event")}),(0,t.jsx)(i,{children:n("Detail")}),(0,t.jsx)(i,{children:n("Exit")}),(0,t.jsx)(i,{children:n("When")})]})}),(0,t.jsx)(O,{children:N.map(Y)})]})})}),e[15]=g,e[16]=N,e[17]=n,e[18]=x):x=e[18];let y;return e[19]!==d||e[20]!==f||e[21]!==x?(y=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[d,f,x]}),e[19]=d,e[20]=f,e[21]=x,e[22]=y):y=e[22],y},"Y");function Y(e){return(0,t.jsxs)(C,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[(0,t.jsx)(o,{className:"font-mono text-xs",children:e.name}),(0,t.jsx)(o,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"\u2014"}),(0,t.jsx)(o,{children:(0,t.jsx)(b,{variant:J[e.state],children:e.state})}),(0,t.jsx)(o,{className:"font-mono text-xs text-muted-foreground",children:e.event}),(0,t.jsx)(o,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"\u2014"}),(0,t.jsx)(o,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"\u2014"}),(0,t.jsx)(o,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}v(Y,"B");export{ee as ContainersPanel};
1
+ import{a as T}from"./chunk-X2FQ6B5V.js";import{b as k}from"./chunk-XSD4Y6SQ.js";import{a as D,b as E,c as O,d as C,e as i,f as o}from"./chunk-MIQTKZAR.js";import{a as I,e as $}from"./chunk-UZERI5YC.js";import{b}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as A}from"./chunk-GXZAXNZI.js";import"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import{a as L}from"./chunk-XQCVZAGU.js";import{d as S}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as v,e as w,f as K,g as M,h as P}from"./chunk-3XIESWL4.js";var j=w(M(),1),q=w(K(),1);var t=w(P(),1);var _="container:",W={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},B=v(e=>{let n=e.indexOf(":");if(n===-1)return{event:e.trim()};let r=e.slice(n+1).trim(),a=e.slice(0,n).trim();return r===""?{event:a}:{detail:r,event:a}},"j"),F=v(e=>{let n=new Map;for(let r of e){let a=r.functionPath??"";if(!a.startsWith(_))continue;let s=a.slice(_.length);if(s==="")continue;let c=JSON.stringify([s,r.instance??""]),m=n.get(c);if(m!==void 0&&m.timestamp>=r.timestamp)continue;let{detail:g,event:l}=B(r.message);n.set(c,{detail:g,event:l,exitCode:r.exitCode,instance:r.instance,level:r.level,name:s,state:W[l]??"unknown",timestamp:r.timestamp})}return[...n.values()].toSorted((r,a)=>r.name.localeCompare(a.name)||(r.instance??"").localeCompare(a.instance??""))},"K"),J={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},U=v(e=>{let{entries:n}=e??{};return Array.isArray(n)?n:[]},"W"),ee=v(()=>{let e=(0,j.c)(23),n=S(),r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},a={live:!0,shardKey:""},e[0]=r,e[1]=a):(r=e[0],a=e[1]);let{data:s,error:c,liveError:m}=k(A.getLogs,r,a),g=s!==void 0,l;e[2]!==s?(l=F(U(s)),e[2]=s,e[3]=l):l=e[3];let N=l,d;e[4]!==c?(d=c!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:c}),e[4]=c,e[5]=d):d=e[5];let h;e[6]!==n?(h=n("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance \u2014 ports and health checks aren't carried in that stream."),e[6]=n,e[7]=h):h=e[7];let p;e[8]!==h?(p=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:h}),e[8]=h,e[9]=p):p=e[9];let u;e[10]!==m?(u=(0,t.jsx)(T,{message:m,prefix:"containers"}),e[10]=m,e[11]=u):u=e[11];let f;e[12]!==p||e[13]!==u?(f=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[p,u]}),e[12]=p,e[13]=u,e[14]=f):f=e[14];let x;e[15]!==g||e[16]!==N||e[17]!==n?(x=g&&N.length===0?(0,t.jsx)(L,{description:n("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:n("No container activity")}):(0,t.jsx)(I,{className:"overflow-hidden py-0",children:(0,t.jsx)($,{className:"px-0",children:(0,t.jsxs)(D,{"data-testid":"containers-table",children:[(0,t.jsx)(E,{children:(0,t.jsxs)(C,{children:[(0,t.jsx)(i,{children:n("Container")}),(0,t.jsx)(i,{children:n("Instance")}),(0,t.jsx)(i,{children:n("State")}),(0,t.jsx)(i,{children:n("Last event")}),(0,t.jsx)(i,{children:n("Detail")}),(0,t.jsx)(i,{children:n("Exit")}),(0,t.jsx)(i,{children:n("When")})]})}),(0,t.jsx)(O,{children:N.map(Y)})]})})}),e[15]=g,e[16]=N,e[17]=n,e[18]=x):x=e[18];let y;return e[19]!==d||e[20]!==f||e[21]!==x?(y=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[d,f,x]}),e[19]=d,e[20]=f,e[21]=x,e[22]=y):y=e[22],y},"Y");function Y(e){return(0,t.jsxs)(C,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[(0,t.jsx)(o,{className:"font-mono text-xs",children:e.name}),(0,t.jsx)(o,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"\u2014"}),(0,t.jsx)(o,{children:(0,t.jsx)(b,{variant:J[e.state],children:e.state})}),(0,t.jsx)(o,{className:"font-mono text-xs text-muted-foreground",children:e.event}),(0,t.jsx)(o,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"\u2014"}),(0,t.jsx)(o,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"\u2014"}),(0,t.jsx)(o,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}v(Y,"B");export{ee as ContainersPanel};
@@ -1,4 +1,4 @@
1
- import{b as Ee}from"./chunk-5RF4QDDA.js";import"./chunk-XQGANNLS.js";import{c as _e}from"./chunk-SKHEGARW.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as ye}from"./chunk-JN2Y24PY.js";import"./chunk-ESVP44Y3.js";import{a as Ue}from"./chunk-54MMVNPT.js";import"./chunk-KYF2E5CJ.js";import"./chunk-7YEFOSPH.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import{a as Re}from"./chunk-7LQWFOEU.js";import"./chunk-T6VMSOBB.js";import{a as $e,b as Te,c as Fe,d as ce,e as ne,f as ee}from"./chunk-MIQTKZAR.js";import{a as je,e as ze}from"./chunk-UZERI5YC.js";import"./chunk-QBWRC5YX.js";import{a as De}from"./chunk-LFXFP4IF.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as Ne}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as re}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as ae}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as be}from"./chunk-GXZAXNZI.js";import{f as Se}from"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{a as he}from"./chunk-XQCVZAGU.js";import{d as Ce,f as me,g as ge,h as Y,m as W,o as Ke,p as pe}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as g,e as fe,f as gt,g as pt,h as bt}from"./chunk-3XIESWL4.js";var M=fe(pt(),1),z=fe(gt(),1);var n=fe(bt(),1);var Me=g((c,e,r)=>{let t=(0,M.c)(21),{onCopy:s,onDelete:o,onDownload:u,onToggleSelect:i}=r,l;t[0]!==c.key||t[1]!==s?(l=g(()=>{s(c.key)},"l"),t[0]=c.key,t[1]=s,t[2]=l):l=t[2];let f=l,h;t[3]!==c.key||t[4]!==u?(h=g(()=>{u(c.key)},"h"),t[3]=c.key,t[4]=u,t[5]=h):h=t[5];let d=h,m;t[6]!==c.key||t[7]!==o?(m=g(()=>{o(c.key)},"m"),t[6]=c.key,t[7]=o,t[8]=m):m=t[8];let w=m,a;t[9]!==c.key||t[10]!==i?(a=g(()=>{i(c.key)},"s"),t[9]=c.key,t[10]=i,t[11]=a):a=t[11];let v=a,x;t[12]!==c.key||t[13]!==e.length?(x=c.key.slice(e.length),t[12]=c.key,t[13]=e.length,t[14]=x):x=t[14];let b;return t[15]!==f||t[16]!==d||t[17]!==w||t[18]!==x||t[19]!==v?(b={copy:f,download:d,name:x,remove:w,toggle:v},t[15]=f,t[16]=d,t[17]=w,t[18]=x,t[19]=v,t[20]=b):b=t[20],b},"Ke"),Be=g(c=>{let e=(0,M.c)(31),{busy:r,buttonClassName:t,copied:s,objectKey:o,onCopy:u,onDelete:i,onDownload:l,t:f}=c,h=`storage-copy-${o}`,d;e[0]!==s||e[1]!==f?(d=f(s?"Copied":"Copy URL"),e[0]=s,e[1]=f,e[2]=d):d=e[2];let m;e[3]!==r||e[4]!==t||e[5]!==u||e[6]!==h||e[7]!==d?(m=(0,n.jsx)(re,{className:t,"data-testid":h,disabled:r,onClick:u,size:"sm",type:"button",variant:"ghost",children:d}),e[3]=r,e[4]=t,e[5]=u,e[6]=h,e[7]=d,e[8]=m):m=e[8];let w=`storage-download-${o}`,a;e[9]!==f?(a=f("Download"),e[9]=f,e[10]=a):a=e[10];let v;e[11]!==r||e[12]!==t||e[13]!==l||e[14]!==w||e[15]!==a?(v=(0,n.jsx)(re,{className:t,"data-testid":w,disabled:r,onClick:l,size:"sm",type:"button",variant:"ghost",children:a}),e[11]=r,e[12]=t,e[13]=l,e[14]=w,e[15]=a,e[16]=v):v=e[16];let x;e[17]!==f?(x=f("Delete object?"),e[17]=f,e[18]=x):x=e[18];let b=`storage-delete-${o}`,y;e[19]!==f?(y=f("Delete"),e[19]=f,e[20]=y):y=e[20];let k;e[21]!==r||e[22]!==i||e[23]!==x||e[24]!==b||e[25]!==y?(k=(0,n.jsx)(Re,{confirmLabel:x,disabled:r,onConfirm:i,testId:b,children:y}),e[21]=r,e[22]=i,e[23]=x,e[24]=b,e[25]=y,e[26]=k):k=e[26];let S;return e[27]!==k||e[28]!==m||e[29]!==v?(S=(0,n.jsxs)(n.Fragment,{children:[m,v,k]}),e[27]=k,e[28]=m,e[29]=v,e[30]=S):S=e[30],S},"De"),Ae=g(c=>{let e=(0,M.c)(14),{objectKey:r,references:t,t:s}=c;if(t===void 0)return null;if(t.length===0){let h=`storage-orphan-${r}`,d;e[0]!==s?(d=s("Orphan"),e[0]=s,e[1]=d):d=e[1];let m;return e[2]!==h||e[3]!==d?(m=(0,n.jsx)(ae,{"data-testid":h,variant:"warning",children:d}),e[2]=h,e[3]=d,e[4]=m):m=e[4],m}let o;e[5]!==t?(o=t.map(yt).join(`
1
+ import{b as Ee}from"./chunk-5RF4QDDA.js";import"./chunk-XQGANNLS.js";import{c as _e}from"./chunk-SKHEGARW.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as ye}from"./chunk-JN2Y24PY.js";import"./chunk-ESVP44Y3.js";import{a as Ue}from"./chunk-54MMVNPT.js";import"./chunk-KYF2E5CJ.js";import"./chunk-7YEFOSPH.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import{a as Re}from"./chunk-7LQWFOEU.js";import"./chunk-T6VMSOBB.js";import{a as $e,b as Te,c as Fe,d as ce,e as ne,f as ee}from"./chunk-MIQTKZAR.js";import{a as je,e as ze}from"./chunk-UZERI5YC.js";import"./chunk-QBWRC5YX.js";import{a as De}from"./chunk-LFXFP4IF.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as Ne}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as re}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as ae}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as be}from"./chunk-GXZAXNZI.js";import{f as Se}from"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import{a as he}from"./chunk-XQCVZAGU.js";import{d as Ce,f as me,g as ge,h as Y,m as W,o as Ke,p as pe}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as g,e as fe,f as gt,g as pt,h as bt}from"./chunk-3XIESWL4.js";var M=fe(pt(),1),z=fe(gt(),1);var n=fe(bt(),1);var Me=g((c,e,r)=>{let t=(0,M.c)(21),{onCopy:s,onDelete:o,onDownload:u,onToggleSelect:i}=r,l;t[0]!==c.key||t[1]!==s?(l=g(()=>{s(c.key)},"l"),t[0]=c.key,t[1]=s,t[2]=l):l=t[2];let f=l,h;t[3]!==c.key||t[4]!==u?(h=g(()=>{u(c.key)},"h"),t[3]=c.key,t[4]=u,t[5]=h):h=t[5];let d=h,m;t[6]!==c.key||t[7]!==o?(m=g(()=>{o(c.key)},"m"),t[6]=c.key,t[7]=o,t[8]=m):m=t[8];let w=m,a;t[9]!==c.key||t[10]!==i?(a=g(()=>{i(c.key)},"s"),t[9]=c.key,t[10]=i,t[11]=a):a=t[11];let v=a,x;t[12]!==c.key||t[13]!==e.length?(x=c.key.slice(e.length),t[12]=c.key,t[13]=e.length,t[14]=x):x=t[14];let b;return t[15]!==f||t[16]!==d||t[17]!==w||t[18]!==x||t[19]!==v?(b={copy:f,download:d,name:x,remove:w,toggle:v},t[15]=f,t[16]=d,t[17]=w,t[18]=x,t[19]=v,t[20]=b):b=t[20],b},"Ke"),Be=g(c=>{let e=(0,M.c)(31),{busy:r,buttonClassName:t,copied:s,objectKey:o,onCopy:u,onDelete:i,onDownload:l,t:f}=c,h=`storage-copy-${o}`,d;e[0]!==s||e[1]!==f?(d=f(s?"Copied":"Copy URL"),e[0]=s,e[1]=f,e[2]=d):d=e[2];let m;e[3]!==r||e[4]!==t||e[5]!==u||e[6]!==h||e[7]!==d?(m=(0,n.jsx)(re,{className:t,"data-testid":h,disabled:r,onClick:u,size:"sm",type:"button",variant:"ghost",children:d}),e[3]=r,e[4]=t,e[5]=u,e[6]=h,e[7]=d,e[8]=m):m=e[8];let w=`storage-download-${o}`,a;e[9]!==f?(a=f("Download"),e[9]=f,e[10]=a):a=e[10];let v;e[11]!==r||e[12]!==t||e[13]!==l||e[14]!==w||e[15]!==a?(v=(0,n.jsx)(re,{className:t,"data-testid":w,disabled:r,onClick:l,size:"sm",type:"button",variant:"ghost",children:a}),e[11]=r,e[12]=t,e[13]=l,e[14]=w,e[15]=a,e[16]=v):v=e[16];let x;e[17]!==f?(x=f("Delete object?"),e[17]=f,e[18]=x):x=e[18];let b=`storage-delete-${o}`,y;e[19]!==f?(y=f("Delete"),e[19]=f,e[20]=y):y=e[20];let k;e[21]!==r||e[22]!==i||e[23]!==x||e[24]!==b||e[25]!==y?(k=(0,n.jsx)(Re,{confirmLabel:x,disabled:r,onConfirm:i,testId:b,children:y}),e[21]=r,e[22]=i,e[23]=x,e[24]=b,e[25]=y,e[26]=k):k=e[26];let S;return e[27]!==k||e[28]!==m||e[29]!==v?(S=(0,n.jsxs)(n.Fragment,{children:[m,v,k]}),e[27]=k,e[28]=m,e[29]=v,e[30]=S):S=e[30],S},"De"),Ae=g(c=>{let e=(0,M.c)(14),{objectKey:r,references:t,t:s}=c;if(t===void 0)return null;if(t.length===0){let h=`storage-orphan-${r}`,d;e[0]!==s?(d=s("Orphan"),e[0]=s,e[1]=d):d=e[1];let m;return e[2]!==h||e[3]!==d?(m=(0,n.jsx)(ae,{"data-testid":h,variant:"warning",children:d}),e[2]=h,e[3]=d,e[4]=m):m=e[4],m}let o;e[5]!==t?(o=t.map(yt).join(`
2
2
  `),e[5]=t,e[6]=o):o=e[6];let u=o,i=`storage-refs-${r}`,l;e[7]!==t.length||e[8]!==s?(l=t.length===1?s("1 record"):s("{count} records",{count:t.length}),e[7]=t.length,e[8]=s,e[9]=l):l=e[9];let f;return e[10]!==u||e[11]!==i||e[12]!==l?(f=(0,n.jsx)(ae,{"data-testid":i,title:u,variant:"secondary",children:l}),e[10]=u,e[11]=i,e[12]=l,e[13]=f):f=e[13],f},"Te"),Pe=g(c=>{let e=(0,M.c)(7),{objectKey:r,onToggle:t,selected:s,t:o}=c,u;e[0]!==o?(u=o("Select row"),e[0]=o,e[1]=u):u=e[1];let i=`storage-select-${r}`,l;return e[2]!==t||e[3]!==s||e[4]!==u||e[5]!==i?(l=(0,n.jsx)(ye,{"aria-label":u,checked:s,"data-testid":i,onCheckedChange:t}),e[2]=t,e[3]=s,e[4]=u,e[5]=i,e[6]=l):l=e[6],l},"Fe");function yt(c){return`${c.table}\xB7${c.id}`}g(yt,"xt");var xt=g(c=>{let e=(0,M.c)(10),{colSpan:r,name:t,onEnter:s}=c,o;e[0]!==t||e[1]!==s?(o=g(()=>{s(t)},"n"),e[0]=t,e[1]=s,e[2]=o):o=e[2];let u=o,i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=(0,n.jsx)("svg",{"aria-hidden":"true",className:"size-4 text-muted-foreground",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"})}),e[3]=i):i=e[3];let l;e[4]!==u||e[5]!==t?(l=(0,n.jsxs)("button",{className:"inline-flex items-center gap-2 font-mono text-xs outline-none hover:text-foreground focus-visible:text-foreground","data-testid":"fb-folder",onClick:u,type:"button",children:[i,t]}),e[4]=u,e[5]=t,e[6]=l):l=e[6];let f;return e[7]!==r||e[8]!==l?(f=(0,n.jsx)(ce,{children:(0,n.jsx)(ee,{colSpan:r,children:l})}),e[7]=r,e[8]=l,e[9]=f):f=e[9],f},"kt"),vt=g(c=>{let e=(0,M.c)(33),{busy:r,copiedKey:t,handlers:s,object:o,prefix:u,references:i,selected:l,showReferences:f,t:h}=c,{copy:d,download:m,name:w,remove:a,toggle:v}=Me(o,u,s),x;e[0]!==o.key||e[1]!==l||e[2]!==h||e[3]!==v?(x=(0,n.jsx)(ee,{className:"w-8",children:(0,n.jsx)(Pe,{objectKey:o.key,onToggle:v,selected:l,t:h})}),e[0]=o.key,e[1]=l,e[2]=h,e[3]=v,e[4]=x):x=e[4];let b;e[5]!==w?(b=(0,n.jsx)(ee,{className:"font-mono text-xs",children:w}),e[5]=w,e[6]=b):b=e[6];let y;e[7]!==o.size?(y=pe(o.size),e[7]=o.size,e[8]=y):y=e[8];let k;e[9]!==y?(k=(0,n.jsx)(ee,{className:"tabular-nums text-muted-foreground",children:y}),e[9]=y,e[10]=k):k=e[10];let S=o.httpMetadata?.contentType??"",j;e[11]!==S?(j=(0,n.jsx)(ee,{children:S}),e[11]=S,e[12]=j):j=e[12];let C;e[13]!==o.key||e[14]!==i||e[15]!==f||e[16]!==h?(C=f&&(0,n.jsx)(ee,{children:(0,n.jsx)(Ae,{objectKey:o.key,references:i,t:h})}),e[13]=o.key,e[14]=i,e[15]=f,e[16]=h,e[17]=C):C=e[17];let N=t===o.key,K;e[18]!==r||e[19]!==d||e[20]!==m||e[21]!==o.key||e[22]!==a||e[23]!==h||e[24]!==N?(K=(0,n.jsx)(ee,{className:"text-right",children:(0,n.jsx)("span",{className:"inline-flex items-center gap-1",children:(0,n.jsx)(Be,{busy:r,copied:N,objectKey:o.key,onCopy:d,onDelete:a,onDownload:m,t:h})})}),e[18]=r,e[19]=d,e[20]=m,e[21]=o.key,e[22]=a,e[23]=h,e[24]=N,e[25]=K):K=e[25];let $;return e[26]!==x||e[27]!==b||e[28]!==k||e[29]!==j||e[30]!==C||e[31]!==K?($=(0,n.jsxs)(ce,{"data-testid":"fb-row",children:[x,b,k,j,C,K]}),e[26]=x,e[27]=b,e[28]=k,e[29]=j,e[30]=C,e[31]=K,e[32]=$):$=e[32],$},"vt"),kt=g(c=>{let e=(0,M.c)(65),{allSelected:r,busy:t,copiedKey:s,files:o,folders:u,handlers:i,onEnterFolder:l,prefix:f,references:h,selected:d,showReferences:m,someSelected:w,t:a,toggleSelectAll:v}=c,x;e[0]!==a?(x=a("Select all rows"),e[0]=a,e[1]=x):x=e[1];let b;e[2]!==r||e[3]!==w||e[4]!==x||e[5]!==v?(b=(0,n.jsx)(ne,{className:"w-8",children:(0,n.jsx)(ye,{"aria-label":x,checked:r,"data-testid":"storage-select-all",indeterminate:w,onCheckedChange:v})}),e[2]=r,e[3]=w,e[4]=x,e[5]=v,e[6]=b):b=e[6];let y;e[7]!==a?(y=a("key"),e[7]=a,e[8]=y):y=e[8];let k;e[9]!==y?(k=(0,n.jsx)(ne,{children:y}),e[9]=y,e[10]=k):k=e[10];let S;e[11]!==a?(S=a("size"),e[11]=a,e[12]=S):S=e[12];let j;e[13]!==S?(j=(0,n.jsx)(ne,{children:S}),e[13]=S,e[14]=j):j=e[14];let C;e[15]!==a?(C=a("content-type"),e[15]=a,e[16]=C):C=e[16];let N;e[17]!==C?(N=(0,n.jsx)(ne,{children:C}),e[17]=C,e[18]=N):N=e[18];let K;e[19]!==m||e[20]!==a?(K=m&&(0,n.jsx)(ne,{children:a("used by")}),e[19]=m,e[20]=a,e[21]=K):K=e[21];let $;e[22]!==a?($=a("Actions"),e[22]=a,e[23]=$):$=e[23];let F;e[24]!==$?(F=(0,n.jsx)(ne,{"aria-label":$}),e[24]=$,e[25]=F):F=e[25];let T;e[26]!==F||e[27]!==b||e[28]!==k||e[29]!==j||e[30]!==N||e[31]!==K?(T=(0,n.jsx)(Te,{children:(0,n.jsxs)(ce,{children:[b,k,j,N,K,F]})}),e[26]=F,e[27]=b,e[28]=k,e[29]=j,e[30]=N,e[31]=K,e[32]=T):T=e[32];let _;if(e[33]!==u||e[34]!==l||e[35]!==m){let R;e[37]!==l||e[38]!==m?(R=g(E=>(0,n.jsx)(xt,{colSpan:m?6:5,name:E,onEnter:l},E),"F"),e[37]=l,e[38]=m,e[39]=R):R=e[39],_=u.map(R),e[33]=u,e[34]=l,e[35]=m,e[36]=_}else _=e[36];let O;if(e[40]!==t||e[41]!==s||e[42]!==o||e[43]!==i||e[44]!==f||e[45]!==h||e[46]!==d||e[47]!==m||e[48]!==a){let R;e[50]!==t||e[51]!==s||e[52]!==i||e[53]!==f||e[54]!==h||e[55]!==d||e[56]!==m||e[57]!==a?(R=g(E=>(0,n.jsx)(vt,{busy:t,copiedKey:s,handlers:i,object:E,prefix:f,references:h[E.key],selected:d.has(E.key),showReferences:m,t:a},E.key),"F"),e[50]=t,e[51]=s,e[52]=i,e[53]=f,e[54]=h,e[55]=d,e[56]=m,e[57]=a,e[58]=R):R=e[58],O=o.map(R),e[40]=t,e[41]=s,e[42]=o,e[43]=i,e[44]=f,e[45]=h,e[46]=d,e[47]=m,e[48]=a,e[49]=O}else O=e[49];let U;e[59]!==_||e[60]!==O?(U=(0,n.jsxs)(Fe,{children:[_,O]}),e[59]=_,e[60]=O,e[61]=U):U=e[61];let L;return e[62]!==T||e[63]!==U?(L=(0,n.jsx)(je,{className:"overflow-hidden py-0",children:(0,n.jsx)(ze,{className:"px-0",children:(0,n.jsxs)($e,{"data-testid":"fb-table",children:[T,U]})})}),e[62]=T,e[63]=U,e[64]=L):L=e[64],L},"wt"),wt=[{label:"15m",seconds:900},{label:"1h",seconds:3600},{label:"24h",seconds:86400},{label:"7d",seconds:604800}],St=3600,Oe=g((c,e)=>{if(e==="size")return c.size;if(e==="type")return c.httpMetadata?.contentType??"";if(e==="date"){if(c.uploaded===void 0)return 0;let r=new Date(c.uploaded).getTime();return Number.isNaN(r)?0:r}return e.startsWith("tag:")?c.customMetadata?.[e.slice(4)]??"":c.key},"ke"),Ct=g((c,e,r)=>{let t=r==="desc"?-1:1;return c.toSorted((s,o)=>{let u=Oe(s,e),i=Oe(o,e);return(typeof u=="number"&&typeof i=="number"?u-i:String(u).localeCompare(String(i)))*t})},"Ct"),Nt=g((c,e)=>{let r=new Set,t=[];for(let s of c){let o=s.key.slice(e.length),u=o.indexOf("/");u===-1?t.push(s):r.add(o.slice(0,u+1))}return{files:t,folders:[...r].toSorted((s,o)=>s.localeCompare(o))}},"$t"),jt=g(c=>{let e=(0,M.c)(59),{bucket:r,buckets:t,busy:s,draftPrefix:o,expiry:u,fileInputRef:i,onBucketChange:l,onExpiryChange:f,onFileChange:h,onList:d,onPrefixChange:m,onUploadClick:w,t:a}=c,v;e[0]!==m?(v=g(P=>{m(P.target.value)},"x"),e[0]=m,e[1]=v):v=e[1];let x=v,b;e[2]!==l?(b=g(P=>{l(P.target.value)},"g"),e[2]=l,e[3]=b):b=e[3];let y=b,k;e[4]!==f?(k=g(P=>{f(Number.parseInt(P.target.value,10))},"k"),e[4]=f,e[5]=k):k=e[5];let S=k,j;e[6]!==r||e[7]!==t||e[8]!==y||e[9]!==a?(j=t.length>0&&(0,n.jsx)("select",{"aria-label":a("Bucket"),className:"h-8 rounded-md border border-border bg-background px-1 outline-none focus-visible:border-ring","data-testid":"fb-bucket",onChange:y,value:r,children:t.map(Kt)}),e[6]=r,e[7]=t,e[8]=y,e[9]=a,e[10]=j):j=e[10];let C;e[11]!==a?(C=a("Key prefix"),e[11]=a,e[12]=C):C=e[12];let N;e[13]!==a?(N=a("key prefix (optional)"),e[13]=a,e[14]=N):N=e[14];let K;e[15]!==o||e[16]!==x||e[17]!==C||e[18]!==N?(K=(0,n.jsx)(Ne,{"aria-label":C,className:"h-8 w-64 max-w-full","data-testid":"fb-prefix-input",onChange:x,placeholder:N,value:o}),e[15]=o,e[16]=x,e[17]=C,e[18]=N,e[19]=K):K=e[19];let $;e[20]!==a?($=a("List"),e[20]=a,e[21]=$):$=e[21];let F;e[22]!==s||e[23]!==d||e[24]!==$?(F=(0,n.jsx)(re,{"data-testid":"fb-list",disabled:s,onClick:d,size:"sm",type:"button",children:$}),e[22]=s,e[23]=d,e[24]=$,e[25]=F):F=e[25];let T;e[26]!==s||e[27]!==a?(T=a(s?"Uploading\u2026":"Upload"),e[26]=s,e[27]=a,e[28]=T):T=e[28];let _;e[29]!==s||e[30]!==w||e[31]!==T?(_=(0,n.jsx)(re,{"data-testid":"storage-upload",disabled:s,onClick:w,size:"sm",type:"button",variant:"outline",children:T}),e[29]=s,e[30]=w,e[31]=T,e[32]=_):_=e[32];let O;e[33]!==i||e[34]!==h?(O=(0,n.jsx)("input",{className:"hidden","data-testid":"storage-file-input",onChange:h,ref:i,type:"file"}),e[33]=i,e[34]=h,e[35]=O):O=e[35];let U;e[36]!==a?(U=a("Link expiry"),e[36]=a,e[37]=U):U=e[37];let L;e[38]!==a?(L=wt.map(P=>(0,n.jsx)("option",{value:P.seconds,children:a(P.label)},P.seconds)),e[38]=a,e[39]=L):L=e[39];let R;e[40]!==u||e[41]!==S||e[42]!==L?(R=(0,n.jsx)("select",{className:"h-8 rounded-md border border-border bg-background px-1 tabular-nums outline-none focus-visible:border-ring","data-testid":"storage-expiry",id:"storage-expiry",onChange:S,value:u,children:L}),e[40]=u,e[41]=S,e[42]=L,e[43]=R):R=e[43];let E;e[44]!==U||e[45]!==R?(E=(0,n.jsxs)("label",{className:"ml-auto flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"storage-expiry",children:[U,R]}),e[44]=U,e[45]=R,e[46]=E):E=e[46];let B;e[47]!==a?(B=a("Open in Cloudflare"),e[47]=a,e[48]=B):B=e[48];let A;e[49]!==B?(A=(0,n.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"fb-cf-link",href:_e,rel:"noreferrer",target:"_blank",children:B}),e[49]=B,e[50]=A):A=e[50];let G;return e[51]!==_||e[52]!==O||e[53]!==E||e[54]!==A||e[55]!==j||e[56]!==K||e[57]!==F?(G=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[j,K,F,_,O,E,A]}),e[51]=_,e[52]=O,e[53]=E,e[54]=A,e[55]=j,e[56]=K,e[57]=F,e[58]=G):G=e[58],G},"jt"),zt=g(c=>{let e=(0,M.c)(66),{onSortKeyChange:r,onThumbSizeChange:t,showGrid:s,showList:o,sortDirection:u,sortKey:i,t:l,tagKeys:f,thumbSize:h,toggleSortDirection:d,view:m}=c,w;e[0]!==r?(w=g(q=>{r(q.target.value)},"v"),e[0]=r,e[1]=w):w=e[1];let a=w,v;e[2]!==t?(v=g(q=>{t(Number.parseInt(q.target.value,10))},"x"),e[2]=t,e[3]=v):v=e[3];let x=v,b=m==="list",y;e[4]!==l?(y=l("List"),e[4]=l,e[5]=y):y=e[5];let k;e[6]!==o||e[7]!==b||e[8]!==y?(k=(0,n.jsx)("button",{"aria-pressed":b,className:"px-2 py-1 outline-none transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-testid":"fb-view-list",onClick:o,type:"button",children:y}),e[6]=o,e[7]=b,e[8]=y,e[9]=k):k=e[9];let S=m==="grid",j;e[10]!==l?(j=l("Grid"),e[10]=l,e[11]=j):j=e[11];let C;e[12]!==s||e[13]!==S||e[14]!==j?(C=(0,n.jsx)("button",{"aria-pressed":S,className:"border-s border-border px-2 py-1 outline-none transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-testid":"fb-view-grid",onClick:s,type:"button",children:j}),e[12]=s,e[13]=S,e[14]=j,e[15]=C):C=e[15];let N;e[16]!==k||e[17]!==C?(N=(0,n.jsxs)("div",{className:"inline-flex overflow-hidden rounded-md border border-border",children:[k,C]}),e[16]=k,e[17]=C,e[18]=N):N=e[18];let K;e[19]!==l?(K=l("Sort"),e[19]=l,e[20]=K):K=e[20];let $;e[21]!==l?($=l("Name"),e[21]=l,e[22]=$):$=e[22];let F;e[23]!==$?(F=(0,n.jsx)("option",{value:"name",children:$}),e[23]=$,e[24]=F):F=e[24];let T;e[25]!==l?(T=l("size"),e[25]=l,e[26]=T):T=e[26];let _;e[27]!==T?(_=(0,n.jsx)("option",{value:"size",children:T}),e[27]=T,e[28]=_):_=e[28];let O;e[29]!==l?(O=l("Type"),e[29]=l,e[30]=O):O=e[30];let U;e[31]!==O?(U=(0,n.jsx)("option",{value:"type",children:O}),e[31]=O,e[32]=U):U=e[32];let L;e[33]!==l?(L=l("Modified"),e[33]=l,e[34]=L):L=e[34];let R;e[35]!==L?(R=(0,n.jsx)("option",{value:"date",children:L}),e[35]=L,e[36]=R):R=e[36];let E;e[37]!==f?(E=f.map(Dt),e[37]=f,e[38]=E):E=e[38];let B;e[39]!==a||e[40]!==i||e[41]!==F||e[42]!==_||e[43]!==U||e[44]!==R||e[45]!==E?(B=(0,n.jsxs)("select",{className:"h-8 rounded-md border border-border bg-background px-1 outline-none focus-visible:border-ring","data-testid":"fb-sort",id:"fb-sort",onChange:a,value:i,children:[F,_,U,R,E]}),e[39]=a,e[40]=i,e[41]=F,e[42]=_,e[43]=U,e[44]=R,e[45]=E,e[46]=B):B=e[46];let A;e[47]!==K||e[48]!==B?(A=(0,n.jsxs)("label",{className:"flex items-center gap-1.5 text-muted-foreground",htmlFor:"fb-sort",children:[K,B]}),e[47]=K,e[48]=B,e[49]=A):A=e[49];let G;e[50]!==l?(G=l("Toggle sort direction"),e[50]=l,e[51]=G):G=e[51];let P=u==="asc"?"\u2191":"\u2193",H;e[52]!==G||e[53]!==P||e[54]!==d?(H=(0,n.jsx)("button",{"aria-label":G,className:"flex size-8 items-center justify-center rounded-md border border-border tabular-nums outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"fb-sort-dir",onClick:d,type:"button",children:P}),e[52]=G,e[53]=P,e[54]=d,e[55]=H):H=e[55];let Q;e[56]!==x||e[57]!==l||e[58]!==h||e[59]!==m?(Q=m==="grid"&&(0,n.jsxs)("label",{className:"ml-auto flex items-center gap-1.5 text-muted-foreground",htmlFor:"fb-thumb-size",children:[l("Thumbnail size"),(0,n.jsx)("input",{className:"accent-primary","data-testid":"fb-thumb-size",id:"fb-thumb-size",max:240,min:80,onChange:x,step:8,type:"range",value:h})]}),e[56]=x,e[57]=l,e[58]=h,e[59]=m,e[60]=Q):Q=e[60];let oe;return e[61]!==A||e[62]!==H||e[63]!==Q||e[64]!==N?(oe=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs","data-testid":"fb-controls",children:[N,A,H,Q]}),e[61]=A,e[62]=H,e[63]=Q,e[64]=N,e[65]=oe):oe=e[65],oe},"zt");function Kt(c){return(0,n.jsx)("option",{value:c,children:c},c)}g(Kt,"Kt");function Dt(c){return(0,n.jsx)("option",{value:`tag:${c}`,children:c},c)}g(Dt,"Dt");var $t=/\.(?:avif|bmp|gif|ico|jpe?g|png|svg|webp)$/iu,Tt=g(c=>(c.httpMetadata?.contentType??"").startsWith("image/")||$t.test(c.key),"Ft"),Ft=g(()=>{let c=(0,M.c)(1),e;return c[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("svg",{"aria-hidden":"true",className:"size-8 text-muted-foreground/60",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.4,viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"M7 3h7l5 5v13a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Zm7 0v5h5"})}),c[0]=e):e=c[0],e},"Rt"),Rt=g(c=>{let e=(0,M.c)(13),{object:r,resolveUrl:t}=c,[s,o]=(0,z.useState)(null),[u,i]=(0,z.useState)(!1),l;e[0]!==r?(l=Tt(r),e[0]=r,e[1]=l):l=e[1];let f=l,h,d;e[2]!==f||e[3]!==r.key||e[4]!==t?(h=g(()=>{if(!f)return;let v={cancelled:!1};return W((async()=>{try{let x=await t(r.key);v.cancelled||o(x)}catch{v.cancelled||i(!0)}})()),()=>{v.cancelled=!0}},"h"),d=[f,r.key,t],e[2]=f,e[3]=r.key,e[4]=t,e[5]=h,e[6]=d):(h=e[5],d=e[6]),(0,z.useEffect)(h,d);let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=g(()=>{i(!0)},"m"),e[7]=m):m=e[7];let w=m,a;return e[8]!==u||e[9]!==f||e[10]!==r.key||e[11]!==s?(a=(0,n.jsx)("div",{className:"flex aspect-square w-full items-center justify-center overflow-hidden rounded-md border border-border bg-muted/30",children:f&&s!==null&&!u?(0,n.jsx)("img",{alt:r.key,className:"size-full object-cover",loading:"lazy",onError:w,src:s}):(0,n.jsx)(Ft,{})}),e[8]=u,e[9]=f,e[10]=r.key,e[11]=s,e[12]=a):a=e[12],a},"Lt"),Ut=g(c=>{let e=(0,M.c)(38),{busy:r,copiedKey:t,handlers:s,object:o,prefix:u,references:i,resolveUrl:l,selected:f,showReferences:h,t:d}=c,{copy:m,download:w,name:a,remove:v,toggle:x}=Me(o,u,s),b;e[0]!==o||e[1]!==l?(b=(0,n.jsx)(Rt,{object:o,resolveUrl:l}),e[0]=o,e[1]=l,e[2]=b):b=e[2];let y;e[3]!==o.key||e[4]!==f||e[5]!==d||e[6]!==x?(y=(0,n.jsx)("span",{className:"absolute left-1.5 top-1.5 rounded bg-background/80 p-0.5",children:(0,n.jsx)(Pe,{objectKey:o.key,onToggle:x,selected:f,t:d})}),e[3]=o.key,e[4]=f,e[5]=d,e[6]=x,e[7]=y):y=e[7];let k;e[8]!==b||e[9]!==y?(k=(0,n.jsxs)("div",{className:"relative",children:[b,y]}),e[8]=b,e[9]=y,e[10]=k):k=e[10];let S;e[11]!==a?(S=(0,n.jsx)("p",{className:"truncate font-mono text-xs",title:a,children:a}),e[11]=a,e[12]=S):S=e[12];let j;e[13]!==o.size?(j=pe(o.size),e[13]=o.size,e[14]=j):j=e[14];let C;e[15]!==j?(C=(0,n.jsx)("p",{className:"text-[11px] tabular-nums text-muted-foreground",children:j}),e[15]=j,e[16]=C):C=e[16];let N;e[17]!==o.key||e[18]!==i||e[19]!==h||e[20]!==d?(N=h&&(0,n.jsx)("div",{className:"mt-1",children:(0,n.jsx)(Ae,{objectKey:o.key,references:i,t:d})}),e[17]=o.key,e[18]=i,e[19]=h,e[20]=d,e[21]=N):N=e[21];let K;e[22]!==S||e[23]!==C||e[24]!==N?(K=(0,n.jsxs)("div",{className:"min-w-0",children:[S,C,N]}),e[22]=S,e[23]=C,e[24]=N,e[25]=K):K=e[25];let $=t===o.key,F;e[26]!==r||e[27]!==m||e[28]!==w||e[29]!==o.key||e[30]!==v||e[31]!==d||e[32]!==$?(F=(0,n.jsx)("div",{className:"flex items-center gap-1",children:(0,n.jsx)(Be,{busy:r,buttonClassName:"h-7 px-2 text-xs",copied:$,objectKey:o.key,onCopy:m,onDelete:v,onDownload:w,t:d})}),e[26]=r,e[27]=m,e[28]=w,e[29]=o.key,e[30]=v,e[31]=d,e[32]=$,e[33]=F):F=e[33];let T;return e[34]!==F||e[35]!==k||e[36]!==K?(T=(0,n.jsxs)("div",{className:"flex flex-col gap-1.5","data-testid":"fb-tile",children:[k,K,F]}),e[34]=F,e[35]=k,e[36]=K,e[37]=T):T=e[37],T},"Ot"),Et=g(c=>{let e=(0,M.c)(9),{name:r,onEnter:t}=c,s;e[0]!==r||e[1]!==t?(s=g(()=>{t(r)},"o"),e[0]=r,e[1]=t,e[2]=s):s=e[2];let o=s,u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=(0,n.jsx)("span",{className:"flex aspect-square w-full items-center justify-center rounded-md border border-border bg-muted/30 transition-colors hover:bg-accent",children:(0,n.jsx)("svg",{"aria-hidden":"true",className:"size-10 text-muted-foreground",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.4,viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"})})}),e[3]=u):u=e[3];let i;e[4]!==r?(i=(0,n.jsx)("span",{className:"truncate font-mono text-xs",title:r,children:r}),e[4]=r,e[5]=i):i=e[5];let l;return e[6]!==o||e[7]!==i?(l=(0,n.jsxs)("button",{className:"flex flex-col gap-1.5 text-left outline-none","data-testid":"fb-folder",onClick:o,type:"button",children:[u,i]}),e[6]=o,e[7]=i,e[8]=l):l=e[8],l},"Et"),_t=g(c=>{let e=(0,M.c)(34),{busy:r,copiedKey:t,files:s,folders:o,handlers:u,onEnterFolder:i,prefix:l,references:f,resolveUrl:h,selected:d,showReferences:m,size:w,t:a}=c,v;e[0]!==w?(v=w.toString(),e[0]=w,e[1]=v):v=e[1];let x=`repeat(auto-fill, minmax(${v}px, 1fr))`,b;e[2]!==x?(b={gridTemplateColumns:x},e[2]=x,e[3]=b):b=e[3];let y=b,k;if(e[4]!==o||e[5]!==i){let C;e[7]!==i?(C=g(N=>(0,n.jsx)(Et,{name:N,onEnter:i},N),"S"),e[7]=i,e[8]=C):C=e[8],k=o.map(C),e[4]=o,e[5]=i,e[6]=k}else k=e[6];let S;if(e[9]!==r||e[10]!==t||e[11]!==s||e[12]!==u||e[13]!==l||e[14]!==f||e[15]!==h||e[16]!==d||e[17]!==m||e[18]!==a){let C;e[20]!==r||e[21]!==t||e[22]!==u||e[23]!==l||e[24]!==f||e[25]!==h||e[26]!==d||e[27]!==m||e[28]!==a?(C=g(N=>(0,n.jsx)(Ut,{busy:r,copiedKey:t,handlers:u,object:N,prefix:l,references:f[N.key],resolveUrl:h,selected:d.has(N.key),showReferences:m,t:a},N.key),"S"),e[20]=r,e[21]=t,e[22]=u,e[23]=l,e[24]=f,e[25]=h,e[26]=d,e[27]=m,e[28]=a,e[29]=C):C=e[29],S=s.map(C),e[9]=r,e[10]=t,e[11]=s,e[12]=u,e[13]=l,e[14]=f,e[15]=h,e[16]=d,e[17]=m,e[18]=a,e[19]=S}else S=e[19];let j;return e[30]!==y||e[31]!==k||e[32]!==S?(j=(0,n.jsxs)("div",{className:"grid gap-4","data-testid":"fb-gallery",style:y,children:[k,S]}),e[30]=y,e[31]=k,e[32]=S,e[33]=j):j=e[33],j},"Ut"),Ot=g(c=>{let e=(0,M.c)(23),{reference:r,t}=c,s=`fb-dangling-${r.table}-${r.id}-${r.column}`,o=`${r.table}\xB7${r.id}`,u;e[0]!==o?(u=(0,n.jsx)(ae,{variant:"secondary",children:o}),e[0]=o,e[1]=u):u=e[1];let i;e[2]!==r.column?(i=(0,n.jsx)("span",{className:"text-muted-foreground",children:r.column}),e[2]=r.column,e[3]=i):i=e[3];let l;e[4]!==t?(l=t("\u2192"),e[4]=t,e[5]=l):l=e[5];let f;e[6]!==l?(f=(0,n.jsx)("span",{className:"text-muted-foreground/60",children:l}),e[6]=l,e[7]=f):f=e[7];let h;e[8]!==r.key?(h=(0,n.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-foreground",children:r.key}),e[8]=r.key,e[9]=h):h=e[9];let d;e[10]!==u||e[11]!==i||e[12]!==f||e[13]!==h?(d=(0,n.jsxs)("span",{className:"flex flex-wrap items-center gap-1.5",children:[u,i,f,h]}),e[10]=u,e[11]=i,e[12]=f,e[13]=h,e[14]=d):d=e[14];let m;e[15]!==t?(m=t("Missing object"),e[15]=t,e[16]=m):m=e[16];let w;e[17]!==m?(w=(0,n.jsx)(ae,{className:"border-destructive/40 text-destructive",variant:"outline",children:m}),e[17]=m,e[18]=w):w=e[18];let a;return e[19]!==s||e[20]!==w||e[21]!==d?(a=(0,n.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-border/60 px-3 py-2 text-xs","data-testid":s,children:[d,w]}),e[19]=s,e[20]=w,e[21]=d,e[22]=a):a=e[22],a},"_t"),It=g(c=>{let e=(0,M.c)(37),{busy:r,onCheck:t,references:s,t:o,truncated:u}=c,i;e[0]!==o?(i=o("Integrity"),e[0]=o,e[1]=i):i=e[1];let l;e[2]!==i?(l=(0,n.jsx)("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:i}),e[2]=i,e[3]=l):l=e[3];let f;e[4]!==o?(f=o("Orphaned objects"),e[4]=o,e[5]=f):f=e[5];let h;e[6]!==f?(h=(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:f}),e[6]=f,e[7]=h):h=e[7];let d;e[8]!==o?(d=o("Find records whose file reference points at an object the bucket no longer has."),e[8]=o,e[9]=d):d=e[9];let m;e[10]!==d?(m=(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:d}),e[10]=d,e[11]=m):m=e[11];let w;e[12]!==l||e[13]!==h||e[14]!==m?(w=(0,n.jsxs)("div",{className:"flex flex-col gap-1",children:[l,h,m]}),e[12]=l,e[13]=h,e[14]=m,e[15]=w):w=e[15];let a;e[16]!==r||e[17]!==o?(a=o(r?"Checking\u2026":"Check for orphans"),e[16]=r,e[17]=o,e[18]=a):a=e[18];let v;e[19]!==r||e[20]!==t||e[21]!==a?(v=(0,n.jsx)(re,{"data-testid":"fb-orphans-check",disabled:r,onClick:t,size:"sm",type:"button",variant:"outline",children:a}),e[19]=r,e[20]=t,e[21]=a,e[22]=v):v=e[22];let x;e[23]!==w||e[24]!==v?(x=(0,n.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[w,v]}),e[23]=w,e[24]=v,e[25]=x):x=e[25];let b;e[26]!==s?.length||e[27]!==o?(b=s?.length===0&&(0,n.jsx)(he,{description:o("Every record's file reference points at an object that exists in the bucket."),testId:"fb-orphans-empty",title:o("No dangling references.")}),e[26]=s?.length,e[27]=o,e[28]=b):b=e[28];let y;e[29]!==s||e[30]!==o||e[31]!==u?(y=s!==void 0&&s.length>0&&(0,n.jsxs)(n.Fragment,{children:[u&&(0,n.jsx)("p",{className:"text-xs text-warning","data-testid":"fb-orphans-truncated",children:o("Showing the first {count} dangling references \u2014 the scan was truncated.",{count:s.length})}),(0,n.jsx)("ul",{className:"flex flex-col gap-1.5","data-testid":"fb-orphans-list",children:s.map(S=>(0,n.jsx)(Ot,{reference:S,t:o},`${S.table}\xB7${S.id}\xB7${S.column}`))})]}),e[29]=s,e[30]=o,e[31]=u,e[32]=y):y=e[32];let k;return e[33]!==x||e[34]!==b||e[35]!==y?(k=(0,n.jsxs)("section",{className:"flex flex-col gap-2 rounded-lg border border-border/60 p-3","data-testid":"fb-orphans",children:[x,b,y]}),e[33]=x,e[34]=b,e[35]=y,e[36]=k):k=e[36],k},"It"),Lt=g(function(c,e){let r=(0,M.c)(18),t;r[0]===Symbol.for("react.memo_cache_sentinel")?(t=new Set,r[0]=t):t=r[0];let[s,o]=(0,z.useState)(t),u;r[1]===Symbol.for("react.memo_cache_sentinel")?(u=g(b=>{o(y=>{let k=new Set(y);return k.has(b)?k.delete(b):k.add(b),k})},"u"),r[1]=u):u=r[1];let i=u,l;r[2]===Symbol.for("react.memo_cache_sentinel")?(l=g(()=>{o(new Set)},"l"),r[2]=l):l=r[2];let f=l,h,d,m;if(r[3]!==c||r[4]!==e||r[5]!==s){let b;r[9]!==e?(b=g(y=>e(y),"g"),r[9]=e,r[10]=b):b=r[10],d=c.map(b),h=d.length>0&&d.every(y=>s.has(y)),m=!h&&d.some(y=>s.has(y)),r[3]=c,r[4]=e,r[5]=s,r[6]=h,r[7]=d,r[8]=m}else h=r[6],d=r[7],m=r[8];let w=m,a;r[11]!==d?(a=g(()=>{o(b=>d.every(y=>b.has(y))?new Set:new Set(d))},"s"),r[11]=d,r[12]=a):a=r[12];let v=a,x;return r[13]!==h||r[14]!==s||r[15]!==w||r[16]!==v?(x={allSelected:h,clear:f,selected:s,someSelected:w,toggle:i,toggleAll:v},r[13]=h,r[14]=s,r[15]=w,r[16]=v,r[17]=x):x=r[17],x},"Mt"),Mt=me(be.storageReferences),Bt=me(be.storageOrphans),Ie=1e4,At=1e3,Pt=3600,Wt=g((c,e)=>{if(!("document"in globalThis))return;let r=globalThis.document.createElement("a");r.href=c,r.download=e,r.rel="noopener",globalThis.document.body.append(r),r.click(),r.remove()},"Gt"),Gt=g(({initialPrefix:c,pageSize:e})=>{let r=Se(),[t,s]=(0,z.useState)(c??""),[o,u]=(0,z.useState)(c??""),[i,l]=(0,z.useState)(St),[f,h]=(0,z.useState)("list"),[d,m]=(0,z.useState)(128),[w,a]=(0,z.useState)("name"),[v,x]=(0,z.useState)("asc"),[b,y]=(0,z.useState)(void 0),[k,S]=(0,z.useState)(void 0),[j,C]=(0,z.useState)(!1),[N,K]=(0,z.useState)(void 0),[$,F]=(0,z.useState)(void 0),[T,_]=(0,z.useState)(""),[O,U]=(0,z.useState)({}),[L,R]=(0,z.useState)(!1),[E,B]=(0,z.useState)(void 0),[A,G]=(0,z.useState)(!1),[P,H]=(0,z.useState)(!1),[Q,oe]=(0,z.useState)([]),[q,xe]=(0,z.useState)(""),le=(0,z.useRef)(0),X=(0,z.useRef)(0);(0,z.useEffect)(()=>{let p={cancelled:!1};return W((async()=>{try{let D=await r.listStorageBuckets();if(!p.cancelled){oe(D);let[I]=D;I!==void 0&&xe(Z=>Z===""?I:Z)}}catch{}})()),()=>{p.cancelled=!0}},[r]);let V=(0,z.useMemo)(()=>({list:g(p=>r.listStorageObjects({...p,bucket:q}),"list"),remove:g(p=>r.deleteStorageObject(p,{bucket:q}),"remove"),signedUrl:g((p,D)=>r.signedStorageUrl(p,{...D,bucket:q}),"signedUrl"),upload:g(p=>r.uploadStorageObject({...p,bucket:q}),"upload")}),[q,r]),J=(0,z.useCallback)(async(p,D,I)=>{le.current+=1;let Z=le.current;S(void 0),C(!0);try{let te=await V.list({cursor:D,limit:e,prefix:p});if(Z!==le.current)return;y(we=>I&&we!==void 0?[...we,...te.objects]:te.objects),F(te.cursor)}catch(te){if(Z!==le.current)return;I||y(void 0),S(Y(te))}finally{Z===le.current&&C(!1)}},[e,V]);(0,z.useEffect)(()=>{W(J(c??"",void 0,!1))},[J,c]);let We=(b?.length??0)<=e;Ue(()=>{W(J(t,void 0,!1))},We);let{files:de,folders:Ge}=Nt(b??[],t),He=(0,z.useMemo)(()=>{let p=new Set;for(let D of de)for(let I of Object.keys(D.customMetadata??{}))p.add(I);return[...p].toSorted((D,I)=>D.localeCompare(I))},[de]),ie=Ct(de,w,v),ue=(0,z.useMemo)(()=>[...new Set(ie.map(p=>p.key))].toSorted((p,D)=>p.localeCompare(D)).join(`
3
3
  `),[ie]);(0,z.useEffect)(()=>{let p=ue===""?[]:ue.split(`
4
4
  `);if(p.length===0){U({});return}let D={current:!0};return W((async()=>{try{let I=await r.query(Mt,{keys:p},ge(T));D.current&&(U(I.references??{}),R(Object.keys(I.storageColumns??{}).length>0))}catch{D.current&&(U({}),R(!1))}})()),()=>{D.current=!1}},[r,ue,T]);let Ze=g(p=>p.key,"Ee"),{allSelected:qe,clear:se,selected:ve,someSelected:Ve,toggle:Je,toggleAll:Qe}=Lt(ie,Ze),Xe=g(()=>{s(o),se(),W(J(o,void 0,!1))},"Be"),Ye=g(()=>{W(J(t,$,!0))},"Ae"),ke=g(p=>{s(p),u(p),se(),W(J(p,void 0,!1))},"be"),et=g(p=>{ke(`${t}${p}`)},"Pe"),tt=g(p=>V.signedUrl(p,{expiresInSeconds:Pt}),"We"),rt=g(()=>{h("list")},"Ge"),nt=g(()=>{h("grid")},"He"),ot=g(p=>{a(p)},"Ze"),lt=g(()=>{x(p=>p==="asc"?"desc":"asc")},"qe"),st=g(p=>{m(p)},"Ve"),at=g(p=>{l(p)},"Xe"),it=g(()=>{S(void 0),C(!0),W((async()=>{try{for(let p of ve)await V.remove(p);await J(t,void 0,!1),se()}catch(p){S(Y(p))}finally{C(!1)}})())},"Qe"),ct=g(p=>{S(void 0),W((async()=>{try{let D=await V.signedUrl(p,{expiresInSeconds:i});Ke(D)&&K(p)}catch(D){S(Y(D))}})())},"Ye"),dt=g(p=>{S(void 0),W((async()=>{try{let D=await V.signedUrl(p,{expiresInSeconds:i}),I=p.slice(p.lastIndexOf("/")+1)||p;Wt(D,I)}catch(D){S(Y(D))}})())},"Je");(0,z.useEffect)(()=>{if(N===void 0)return;let p=globalThis.setTimeout(()=>{K(void 0)},2e3);return()=>{globalThis.clearTimeout(p)}},[N]);let ut=g(p=>{S(void 0),C(!0),W((async()=>{try{await V.remove(p),await J(t,void 0,!1)}catch(D){S(Y(D))}finally{C(!1)}})())},"et"),ft=g(p=>{let D=`${t}${p.name}`;S(void 0),C(!0),W((async()=>{try{let I=await p.arrayBuffer();await V.upload({body:I,contentType:p.type===""?void 0:p.type,key:D}),await J(t,void 0,!1)}catch(I){S(Y(I))}finally{C(!1)}})())},"tt");(0,z.useEffect)(()=>{X.current+=1,B(void 0),H(!1)},[T]);let ht=g(()=>{X.current+=1;let p=X.current;S(void 0),G(!0),W((async()=>{try{let D=[],I;do{let Z=await V.list({cursor:I,limit:At});for(let te of Z.objects)D.push(te.key);I=D.length>=Ie?void 0:Z.cursor}while(I!==void 0);if(D.length>=Ie)p===X.current&&(B([]),H(!0));else{let Z=await r.query(Bt,{liveKeys:D},ge(T));p===X.current&&(B(Z.references??[]),H(Z.truncated===!0))}}catch(D){p===X.current&&(B([]),H(!1),S(Y(D)))}finally{p===X.current&&G(!1)}})())},"rt"),mt=g(p=>{le.current+=1,X.current+=1,xe(p),s(c??""),u(c??""),y(void 0),B(void 0),H(!1),se()},"nt");return{allSelected:qe,bucket:q,buckets:Q,bulkDelete:it,busy:j,checkOrphans:ht,clearSelection:se,copiedKey:N,danglingBusy:A,danglingReferences:E,danglingTruncated:P,draftPrefix:o,enterFolder:et,error:k,expiry:i,files:ie,folders:Ge,hasObjects:b!==void 0&&b.length>0,hasStorageColumns:L,listFirst:Xe,loaded:b!==void 0,loadMore:Ye,navigate:ke,nextCursor:$,onCopy:ct,onDelete:ut,onDownload:dt,onExpiryChange:at,onFile:ft,onSortKeyChange:ot,onThumbSizeChange:st,prefix:t,referenceShard:T,references:O,resolveUrl:tt,selectBucket:mt,selected:ve,setDraftPrefix:u,setReferenceShard:_,showGrid:nt,showList:rt,someSelected:Ve,sortDirection:v,sortKey:w,tagKeys:He,thumbSize:d,toggleSelect:Je,toggleSelectAll:Qe,toggleSortDirection:lt,view:f}},"Ht"),Ht=100,Le=g(c=>{let e=(0,M.c)(6),{label:r,onNavigate:t,target:s}=c,o;e[0]!==t||e[1]!==s?(o=g(()=>{t(s)},"n"),e[0]=t,e[1]=s,e[2]=o):o=e[2];let u=o,i;return e[3]!==u||e[4]!==r?(i=(0,n.jsx)("button",{className:"rounded px-1 text-muted-foreground outline-none hover:text-foreground focus-visible:text-foreground",onClick:u,type:"button",children:r}),e[3]=u,e[4]=r,e[5]=i):i=e[5],i},"we"),Zt=g(c=>{let e=(0,M.c)(11),{onNavigate:r,prefix:t,t:s}=c,o;if(e[0]!==r||e[1]!==t||e[2]!==s){let u=t.split("/").filter(qt),i;e[4]!==s?(i=s("Folder path"),e[4]=s,e[5]=i):i=e[5];let l;e[6]!==s?(l=s("root"),e[6]=s,e[7]=l):l=e[7];let f;e[8]!==r||e[9]!==l?(f=(0,n.jsx)(Le,{label:l,onNavigate:r,target:""}),e[8]=r,e[9]=l,e[10]=f):f=e[10],o=(0,n.jsxs)("nav",{"aria-label":i,className:"flex flex-wrap items-center gap-0.5 text-xs","data-testid":"fb-breadcrumbs",children:[f,u.map((h,d)=>(0,n.jsxs)("span",{className:"flex items-center gap-0.5",children:[(0,n.jsx)("span",{className:"text-muted-foreground/50",children:"/"}),(0,n.jsx)(Le,{label:h,onNavigate:r,target:`${u.slice(0,d+1).join("/")}/`})]},`${h}-${d.toString()}`))]}),e[0]=r,e[1]=t,e[2]=s,e[3]=o}else o=e[3];return o},"qt"),ur=g(({initialPrefix:c,pageSize:e=Ht})=>{let r=Ce(),t=Gt({initialPrefix:c,pageSize:e}),s=(0,z.useRef)(null),{onCopy:o,onDelete:u,onDownload:i,onFile:l,toggleSelect:f}=t,h={onCopy:o,onDelete:u,onDownload:i,onToggleSelect:f},d=g(()=>{s.current?.click()},"d"),m=g(a=>{let v=a.target,x=v.files?.[0];v.value="",x&&l(x)},"m"),w=t.loaded&&!t.hasObjects;return(0,n.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-file-browser",children:[(0,n.jsx)(jt,{bucket:t.bucket,buckets:t.buckets,busy:t.busy,draftPrefix:t.draftPrefix,expiry:t.expiry,fileInputRef:s,onBucketChange:t.selectBucket,onExpiryChange:t.onExpiryChange,onFileChange:m,onList:t.listFirst,onPrefixChange:t.setDraftPrefix,onUploadClick:d,t:r}),t.loaded&&(0,n.jsx)(Zt,{onNavigate:t.navigate,prefix:t.prefix,t:r}),t.hasObjects&&(0,n.jsx)(zt,{onSortKeyChange:t.onSortKeyChange,onThumbSizeChange:t.onThumbSizeChange,showGrid:t.showGrid,showList:t.showList,sortDirection:t.sortDirection,sortKey:t.sortKey,t:r,tagKeys:t.tagKeys,thumbSize:t.thumbSize,toggleSortDirection:t.toggleSortDirection,view:t.view}),t.hasStorageColumns&&(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"fb-references-shard",children:[(0,n.jsx)("label",{className:"text-xs text-muted-foreground",htmlFor:"fb-reference-shard-input",children:r("References shard")}),(0,n.jsx)(De,{id:"fb-reference-shard-input",onChange:t.setReferenceShard,testId:"fb-reference-shard-input",value:t.referenceShard}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:r("Which shard's records are checked for references to these files. Empty = root shard.")})]}),t.hasStorageColumns&&(0,n.jsx)(It,{busy:t.danglingBusy,onCheck:t.checkOrphans,references:t.danglingReferences,t:r,truncated:t.danglingTruncated}),t.selected.size>0&&(0,n.jsx)(Ee,{count:t.selected.size,editable:!0,onClear:t.clearSelection,onDelete:t.bulkDelete}),t.error!==void 0&&(0,n.jsx)("p",{className:"text-sm text-destructive","data-testid":"storage-error",role:"alert",children:t.error}),w&&(0,n.jsx)(he,{description:r("Objects you upload to your R2 buckets will appear here."),icon:(0,n.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,n.jsx)("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"}),(0,n.jsx)("path",{d:"M12 11v5m-2.5-2.5h5"})]}),testId:"fb-empty",title:r("No objects.")}),t.hasObjects&&t.view==="list"&&(0,n.jsx)(kt,{allSelected:t.allSelected,busy:t.busy,copiedKey:t.copiedKey,files:t.files,folders:t.folders,handlers:h,onEnterFolder:t.enterFolder,prefix:t.prefix,references:t.references,selected:t.selected,showReferences:t.hasStorageColumns,someSelected:t.someSelected,t:r,toggleSelectAll:t.toggleSelectAll}),t.hasObjects&&t.view==="grid"&&(0,n.jsx)(_t,{busy:t.busy,copiedKey:t.copiedKey,files:t.files,folders:t.folders,handlers:h,onEnterFolder:t.enterFolder,prefix:t.prefix,references:t.references,resolveUrl:t.resolveUrl,selected:t.selected,showReferences:t.hasStorageColumns,size:t.thumbSize,t:r}),t.nextCursor!==void 0&&(0,n.jsx)("div",{children:(0,n.jsx)(re,{"data-testid":"fb-next",disabled:t.busy,onClick:t.loadMore,size:"sm",type:"button",variant:"outline",children:r("Load more")})})]})},"pr");function qt(c){return c!==""}g(qt,"Vt");export{ur as FileBrowser};
@@ -0,0 +1 @@
1
+ import{a as me,b as pe,c as fe,d as ve,e as W}from"./chunk-3RTTXLMU.js";import"./chunk-2PJNAWB3.js";import{a as ue}from"./chunk-X2FQ6B5V.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import"./chunk-7YEFOSPH.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import{a as oe}from"./chunk-LFKCLLPT.js";import"./chunk-T6VMSOBB.js";import{b as ne}from"./chunk-XSD4Y6SQ.js";import{a as de,b as ce,c as he,d as Q,e as m,f as p}from"./chunk-MIQTKZAR.js";import{a as ee,e as se}from"./chunk-UZERI5YC.js";import"./chunk-QBWRC5YX.js";import{a as le}from"./chunk-LFXFP4IF.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as Z}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as $}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as U}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as I}from"./chunk-GXZAXNZI.js";import{f as X}from"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import{a as te}from"./chunk-XQCVZAGU.js";import{d as Y,f as C,g as ae,h as re,m as w,q as ie}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as r,e as P,f as $e,g as Ce,h as Ae}from"./chunk-3XIESWL4.js";var xe=P(Ce(),1);var A=P($e(),1);var t=P(Ae(),1);var B="none",ke=["all","open","resolved","ignored"],ze=["critical","high","medium","low"],Ee=C(I.resolveIssue),Ke=C(I.ignoreIssue),ge=C(I.assignIssue),Me=C(I.setIssueSeverity),Re=r(i=>Array.isArray(i?.issues)?i.issues:[],"Ee"),Te=r(i=>i==="resolved"?"success":i==="ignored"?"secondary":"warning","Ke"),je=r(i=>i==="critical"?"destructive":i==="high"?"warning":i==="medium"?"info":"secondary","Me"),es=r(i=>{let e=(0,xe.c)(42),{initialShardKey:ye}=i,a=Y(),S=X(),[h,Ne]=(0,A.useState)(ye??""),[l,we]=(0,A.useState)("all"),[V,G]=(0,A.useState)(Le),[_,H]=(0,A.useState)(De),k;e[0]!==h?(k=h.trim(),e[0]=h,e[1]=k):k=e[1];let u=oe(k,400),z;e[2]!==l?(z=l==="all"?{}:{status:l},e[2]=l,e[3]=z):z=e[3];let E;e[4]!==u?(E={live:!0,shardKey:u},e[4]=u,e[5]=E):E=e[5];let{data:K,error:v,liveError:b}=ne(I.getIssues,z,E),q=K!==void 0,M;if(e[6]!==_||e[7]!==V||e[8]!==S||e[9]!==K||e[10]!==u||e[11]!==v||e[12]!==b||e[13]!==q||e[14]!==h||e[15]!==l||e[16]!==a){let J=Re(K),R;e[18]!==S||e[19]!==u?(R=r(async(s,n,d)=>{H(c=>{if(!c.has(s))return c;let f=new Map(c);return f.delete(s),f}),G(c=>new Set(c).add(s));try{await S.query(n,{...d,hash:s},ae(u))}catch(c){let f=re(c);H(be=>new Map(be).set(s,f))}G(c=>{let f=new Set(c);return f.delete(s),f})},"K"),e[18]=S,e[19]=u,e[20]=R):R=e[20];let o=R,T;e[21]!==o?(T=r(s=>n=>{if(n.key!=="Enter")return;let d=n.currentTarget.value.trim();w(o(s.hash,ge,{assignee:d===""?null:d}))},"M"),e[21]=o,e[22]=T):T=e[22];let Ie=T,j;e[23]!==o?(j=r(s=>n=>{let d=n===null||n===B?null:n;w(o(s.hash,Me,{severity:d}))},"R"),e[23]=o,e[24]=j):j=e[24];let Se=j,L;e[25]!==a?(L=r(s=>a(s==="all"?"All":s==="open"?"Open":s==="resolved"?"Resolved":"Ignored"),"T"),e[25]=a,e[26]=L):L=e[26];let F=L,D;e[27]!==v?(D=v!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:v}),e[27]=v,e[28]=D):D=e[28];let g;e[29]!==h?(g=(0,t.jsx)(le,{onChange:Ne,testId:"issues-shard-input",value:h}),e[29]=h,e[30]=g):g=e[30];let x;e[31]!==b?(x=(0,t.jsx)(ue,{message:b,prefix:"issues"}),e[31]=b,e[32]=x):x=e[32];let y;e[33]!==l||e[34]!==F?(y=ke.map(s=>(0,t.jsx)($,{"data-active":l===s?"":void 0,"data-testid":`issues-filter-${s}`,onClick:r(()=>{we(s)},"onClick"),size:"xs",variant:l===s?"default":"outline",children:F(s)},s)),e[33]=l,e[34]=F,e[35]=y):y=e[35];let N;e[36]!==y?(N=(0,t.jsx)("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:y}),e[36]=y,e[37]=N):N=e[37];let O;e[38]!==g||e[39]!==x||e[40]!==N?(O=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[g,x,N]}),e[38]=g,e[39]=x,e[40]=N,e[41]=O):O=e[41],M=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[D,O,q&&J.length===0?(0,t.jsx)(te,{description:a("No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here."),testId:"issues-empty",title:a("No issues")}):(0,t.jsx)(ee,{className:"overflow-hidden py-0",children:(0,t.jsx)(se,{className:"px-0",children:(0,t.jsxs)(de,{"data-testid":"issues-table",children:[(0,t.jsx)(ce,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(m,{children:a("Issue")}),(0,t.jsx)(m,{children:a("Status")}),(0,t.jsx)(m,{children:a("Severity")}),(0,t.jsx)(m,{children:a("Assignee")}),(0,t.jsx)(m,{className:"text-right",children:a("Events")}),(0,t.jsx)(m,{children:a("Last seen")}),(0,t.jsx)(m,{className:"text-right",children:a("Actions")})]})}),(0,t.jsx)(he,{children:J.map(s=>{let n=V.has(s.hash),d=_.get(s.hash);return(0,t.jsxs)(Q,{"data-testid":`issues-row-${s.hash}`,children:[(0,t.jsxs)(p,{className:"max-w-80",children:[(0,t.jsx)("div",{className:"truncate font-medium",title:s.title,children:s.title}),(0,t.jsx)("div",{className:"truncate font-mono text-xs text-muted-foreground",title:s.culprit,children:s.culprit}),d!==void 0&&(0,t.jsx)("p",{className:"text-xs text-destructive","data-testid":`issues-action-error-${s.hash}`,role:"alert",children:d})]}),(0,t.jsx)(p,{children:(0,t.jsx)(U,{"data-testid":`issues-status-${s.hash}`,variant:Te(s.status),children:s.status})}),(0,t.jsx)(p,{children:(0,t.jsxs)(me,{disabled:n,onValueChange:Se(s),value:s.severity??B,children:[(0,t.jsx)(fe,{"aria-label":a("Set severity"),className:"h-7 w-[110px]","data-testid":`issues-severity-${s.hash}`,children:(0,t.jsx)(pe,{placeholder:a("\u2014"),children:s.severity===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:a("\u2014")}):(0,t.jsx)(U,{variant:je(s.severity),children:s.severity})})}),(0,t.jsxs)(ve,{children:[ze.map(Oe),(0,t.jsx)(W,{value:B,children:a("Clear")})]})]})}),(0,t.jsx)(p,{children:(0,t.jsx)(Z,{"aria-label":a("Assignee"),className:"h-7 w-32","data-testid":`issues-assignee-${s.hash}`,defaultValue:s.assignee??"",disabled:n,onKeyDown:Ie(s),placeholder:a("Unassigned")},s.assignee??"")}),(0,t.jsx)(p,{className:"text-right",children:(0,t.jsx)(U,{variant:"secondary",children:s.count})}),(0,t.jsx)(p,{className:"text-xs tabular-nums text-muted-foreground",children:ie(s.lastSeen)}),(0,t.jsx)(p,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1",children:[s.status!=="resolved"&&(0,t.jsx)($,{"data-testid":`issues-resolve-${s.hash}`,disabled:n,onClick:r(()=>{w(o(s.hash,Ee,{}))},"onClick"),size:"xs",variant:"outline",children:a("Resolve")}),s.status!=="ignored"&&(0,t.jsx)($,{"data-testid":`issues-ignore-${s.hash}`,disabled:n,onClick:r(()=>{w(o(s.hash,Ke,{}))},"onClick"),size:"xs",variant:"ghost",children:a("Ignore")}),s.status!=="open"&&(0,t.jsx)($,{"data-testid":`issues-reopen-${s.hash}`,disabled:n,onClick:r(()=>{w(o(s.hash,ge,{assignee:s.assignee??null}))},"onClick"),size:"xs",variant:"ghost",children:a("Reopen")})]})})]},s.hash)})})]})})})]}),e[6]=_,e[7]=V,e[8]=S,e[9]=K,e[10]=u,e[11]=v,e[12]=b,e[13]=q,e[14]=h,e[15]=l,e[16]=a,e[17]=M}else M=e[17];return M},"Qe");function Le(){return new Set}r(Le,"Re");function De(){return new Map}r(De,"Te");function Oe(i){return(0,t.jsx)(W,{value:i,children:i},i)}r(Oe,"ze");export{es as IssuesPanel};
@@ -1 +1 @@
1
- import{b as H}from"./chunk-SKHEGARW.js";import{a as q}from"./chunk-UNUU7CJJ.js";import"./chunk-XXQUMVWH.js";import{b as P}from"./chunk-OWADN6BI.js";import{a as z,b as B,c as G,d as A,e as _,f as E}from"./chunk-MIQTKZAR.js";import{a as O,e as V}from"./chunk-UZERI5YC.js";import{b as M}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as R}from"./chunk-GXZAXNZI.js";import"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{d as F}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as S,e as L,f as W,g as $,h as X}from"./chunk-3XIESWL4.js";var J=L($(),1),te=L(W(),1);var r=L(X(),1);var Y={binding:"outline",secret:"destructive",var:"secondary"},me=S(s=>{let e=(0,J.c)(68),{initialShardKey:Q}=s,t=F(),N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N={},e[0]=N):N=e[0];let C=Q??"",k;e[1]!==C?(k={shardKey:C},e[1]=C,e[2]=k):k=e[2];let{data:w,error:d,errorSource:D,isLoading:K}=P(R.getSettings,N,k),j;e:{let a=w?.deploy;if(a===void 0){let n;e[3]===Symbol.for("react.memo_cache_sentinel")?(n=[],e[3]=n):n=e[3],j=n;break e}let i;if(e[4]!==a.deploymentId||e[5]!==a.environment||e[6]!==a.versionTag||e[7]!==a.workerUrl||e[8]!==t){if(i=[],a.workerUrl!==void 0){let n;e[10]!==t?(n=t("URL"),e[10]=t,e[11]=n):n=e[11];let l;e[12]!==a.workerUrl||e[13]!==n?(l={label:n,value:a.workerUrl},e[12]=a.workerUrl,e[13]=n,e[14]=l):l=e[14],i.push(l)}if(a.environment!==void 0){let n;e[15]!==t?(n=t("Environment"),e[15]=t,e[16]=n):n=e[16];let l;e[17]!==a.environment||e[18]!==n?(l={label:n,value:a.environment},e[17]=a.environment,e[18]=n,e[19]=l):l=e[19],i.push(l)}if(a.deploymentId!==void 0){let n;e[20]!==t?(n=t("Deployment"),e[20]=t,e[21]=n):n=e[21];let l;e[22]!==a.deploymentId||e[23]!==n?(l={label:n,value:a.deploymentId},e[22]=a.deploymentId,e[23]=n,e[24]=l):l=e[24],i.push(l)}if(a.versionTag!==void 0){let n;e[25]!==t?(n=t("Version"),e[25]=t,e[26]=n):n=e[26];let l;e[27]!==a.versionTag||e[28]!==n?(l={label:n,value:a.versionTag},e[27]=a.versionTag,e[28]=n,e[29]=l):l=e[29],i.push(l)}e[4]=a.deploymentId,e[5]=a.environment,e[6]=a.versionTag,e[7]=a.workerUrl,e[8]=t,e[9]=i}else i=e[9];j=i}let I=j,T;e[30]!==w?.settings?(T=w?.settings??[],e[30]=w?.settings,e[31]=T):T=e[31];let o=T,m;e[32]!==t?(m=t("Open in Cloudflare"),e[32]=t,e[33]=m):m=e[33];let c;e[34]!==m?(c=(0,r.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:H,rel:"noreferrer",target:"_blank",children:m})}),e[34]=m,e[35]=c):c=e[35];let p;e[36]!==t?(p=t("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[36]=t,e[37]=p):p=e[37];let h;e[38]!==p?(h=(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:p}),e[38]=p,e[39]=h):h=e[39];let u;e[40]!==d||e[41]!==D?(u=d!==null&&(0,r.jsx)(q,{error:D,testId:"set-error"}),e[40]=d,e[41]=D,e[42]=u):u=e[42];let f;e[43]!==I||e[44]!==t?(f=I.length>0&&(0,r.jsxs)(O,{className:"py-0","data-testid":"set-deploy",children:[(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Deployment")})}),(0,r.jsx)(V,{className:"py-3",children:(0,r.jsx)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:I.map(Z)})})]}),e[43]=I,e[44]=t,e[45]=f):f=e[45];let g;e[46]!==t?(g=t("Environment & bindings"),e[46]=t,e[47]=g):g=e[47];let v;e[48]!==g?(v=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:g})}),e[48]=g,e[49]=v):v=e[49];let x;e[50]!==d||e[51]!==K||e[52]!==o.length||e[53]!==t?(x=d===null&&!K&&o.length===0&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:t("No environment variables or bindings.")}),e[50]=d,e[51]=K,e[52]=o.length,e[53]=t,e[54]=x):x=e[54];let y;e[55]!==o||e[56]!==t?(y=o.length>0&&(0,r.jsx)(V,{className:"px-0 py-0",children:(0,r.jsxs)(z,{"data-testid":"set-table",children:[(0,r.jsx)(B,{children:(0,r.jsxs)(A,{children:[(0,r.jsx)(_,{children:t("name")}),(0,r.jsx)(_,{children:t("kind")}),(0,r.jsx)(_,{children:t("value")})]})}),(0,r.jsx)(G,{children:o.map(ee)})]})}),e[55]=o,e[56]=t,e[57]=y):y=e[57];let b;e[58]!==v||e[59]!==x||e[60]!==y?(b=(0,r.jsxs)(O,{className:"py-0",children:[v,x,y]}),e[58]=v,e[59]=x,e[60]=y,e[61]=b):b=e[61];let U;return e[62]!==u||e[63]!==f||e[64]!==b||e[65]!==c||e[66]!==h?(U=(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-settings",children:[c,h,u,f,b]}),e[62]=u,e[63]=f,e[64]=b,e[65]=c,e[66]=h,e[67]=U):U=e[67],U},"de");function Z(s){return(0,r.jsxs)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,r.jsx)("dt",{className:"text-muted-foreground",children:s.label}),(0,r.jsx)("dd",{className:"truncate font-mono text-xs",title:s.value,children:s.value})]},s.label)}S(Z,"H");function ee(s){return(0,r.jsxs)(A,{"data-testid":"set-row",children:[(0,r.jsx)(E,{className:"font-mono text-xs font-medium",children:s.name}),(0,r.jsx)(E,{children:(0,r.jsx)(M,{variant:Y[s.kind],children:s.bindingType??s.kind})}),(0,r.jsx)(E,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:s.value??(0,r.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},s.name)}S(ee,"Q");export{me as SettingsPanel};
1
+ import{b as H}from"./chunk-SKHEGARW.js";import{a as q}from"./chunk-UNUU7CJJ.js";import"./chunk-XXQUMVWH.js";import{b as P}from"./chunk-XSD4Y6SQ.js";import{a as z,b as B,c as G,d as A,e as _,f as E}from"./chunk-MIQTKZAR.js";import{a as O,e as V}from"./chunk-UZERI5YC.js";import{b as M}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as R}from"./chunk-GXZAXNZI.js";import"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import{d as F}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as S,e as L,f as W,g as $,h as X}from"./chunk-3XIESWL4.js";var J=L($(),1),te=L(W(),1);var r=L(X(),1);var Y={binding:"outline",secret:"destructive",var:"secondary"},me=S(s=>{let e=(0,J.c)(68),{initialShardKey:Q}=s,t=F(),N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N={},e[0]=N):N=e[0];let C=Q??"",k;e[1]!==C?(k={shardKey:C},e[1]=C,e[2]=k):k=e[2];let{data:w,error:d,errorSource:D,isLoading:K}=P(R.getSettings,N,k),j;e:{let a=w?.deploy;if(a===void 0){let n;e[3]===Symbol.for("react.memo_cache_sentinel")?(n=[],e[3]=n):n=e[3],j=n;break e}let i;if(e[4]!==a.deploymentId||e[5]!==a.environment||e[6]!==a.versionTag||e[7]!==a.workerUrl||e[8]!==t){if(i=[],a.workerUrl!==void 0){let n;e[10]!==t?(n=t("URL"),e[10]=t,e[11]=n):n=e[11];let l;e[12]!==a.workerUrl||e[13]!==n?(l={label:n,value:a.workerUrl},e[12]=a.workerUrl,e[13]=n,e[14]=l):l=e[14],i.push(l)}if(a.environment!==void 0){let n;e[15]!==t?(n=t("Environment"),e[15]=t,e[16]=n):n=e[16];let l;e[17]!==a.environment||e[18]!==n?(l={label:n,value:a.environment},e[17]=a.environment,e[18]=n,e[19]=l):l=e[19],i.push(l)}if(a.deploymentId!==void 0){let n;e[20]!==t?(n=t("Deployment"),e[20]=t,e[21]=n):n=e[21];let l;e[22]!==a.deploymentId||e[23]!==n?(l={label:n,value:a.deploymentId},e[22]=a.deploymentId,e[23]=n,e[24]=l):l=e[24],i.push(l)}if(a.versionTag!==void 0){let n;e[25]!==t?(n=t("Version"),e[25]=t,e[26]=n):n=e[26];let l;e[27]!==a.versionTag||e[28]!==n?(l={label:n,value:a.versionTag},e[27]=a.versionTag,e[28]=n,e[29]=l):l=e[29],i.push(l)}e[4]=a.deploymentId,e[5]=a.environment,e[6]=a.versionTag,e[7]=a.workerUrl,e[8]=t,e[9]=i}else i=e[9];j=i}let I=j,T;e[30]!==w?.settings?(T=w?.settings??[],e[30]=w?.settings,e[31]=T):T=e[31];let o=T,m;e[32]!==t?(m=t("Open in Cloudflare"),e[32]=t,e[33]=m):m=e[33];let c;e[34]!==m?(c=(0,r.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:H,rel:"noreferrer",target:"_blank",children:m})}),e[34]=m,e[35]=c):c=e[35];let p;e[36]!==t?(p=t("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[36]=t,e[37]=p):p=e[37];let h;e[38]!==p?(h=(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:p}),e[38]=p,e[39]=h):h=e[39];let u;e[40]!==d||e[41]!==D?(u=d!==null&&(0,r.jsx)(q,{error:D,testId:"set-error"}),e[40]=d,e[41]=D,e[42]=u):u=e[42];let f;e[43]!==I||e[44]!==t?(f=I.length>0&&(0,r.jsxs)(O,{className:"py-0","data-testid":"set-deploy",children:[(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Deployment")})}),(0,r.jsx)(V,{className:"py-3",children:(0,r.jsx)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:I.map(Z)})})]}),e[43]=I,e[44]=t,e[45]=f):f=e[45];let g;e[46]!==t?(g=t("Environment & bindings"),e[46]=t,e[47]=g):g=e[47];let v;e[48]!==g?(v=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:g})}),e[48]=g,e[49]=v):v=e[49];let x;e[50]!==d||e[51]!==K||e[52]!==o.length||e[53]!==t?(x=d===null&&!K&&o.length===0&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:t("No environment variables or bindings.")}),e[50]=d,e[51]=K,e[52]=o.length,e[53]=t,e[54]=x):x=e[54];let y;e[55]!==o||e[56]!==t?(y=o.length>0&&(0,r.jsx)(V,{className:"px-0 py-0",children:(0,r.jsxs)(z,{"data-testid":"set-table",children:[(0,r.jsx)(B,{children:(0,r.jsxs)(A,{children:[(0,r.jsx)(_,{children:t("name")}),(0,r.jsx)(_,{children:t("kind")}),(0,r.jsx)(_,{children:t("value")})]})}),(0,r.jsx)(G,{children:o.map(ee)})]})}),e[55]=o,e[56]=t,e[57]=y):y=e[57];let b;e[58]!==v||e[59]!==x||e[60]!==y?(b=(0,r.jsxs)(O,{className:"py-0",children:[v,x,y]}),e[58]=v,e[59]=x,e[60]=y,e[61]=b):b=e[61];let U;return e[62]!==u||e[63]!==f||e[64]!==b||e[65]!==c||e[66]!==h?(U=(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-settings",children:[c,h,u,f,b]}),e[62]=u,e[63]=f,e[64]=b,e[65]=c,e[66]=h,e[67]=U):U=e[67],U},"de");function Z(s){return(0,r.jsxs)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,r.jsx)("dt",{className:"text-muted-foreground",children:s.label}),(0,r.jsx)("dd",{className:"truncate font-mono text-xs",title:s.value,children:s.value})]},s.label)}S(Z,"H");function ee(s){return(0,r.jsxs)(A,{"data-testid":"set-row",children:[(0,r.jsx)(E,{className:"font-mono text-xs font-medium",children:s.name}),(0,r.jsx)(E,{children:(0,r.jsx)(M,{variant:Y[s.kind],children:s.bindingType??s.kind})}),(0,r.jsx)(E,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:s.value??(0,r.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},s.name)}S(ee,"Q");export{me as SettingsPanel};
@@ -1 +1 @@
1
- import{a as se}from"./chunk-X2FQ6B5V.js";import{a as te}from"./chunk-UNUU7CJJ.js";import"./chunk-XXQUMVWH.js";import{b as O}from"./chunk-OWADN6BI.js";import{a as ae,b as re,c as le,d as Y,e as M,f as q}from"./chunk-MIQTKZAR.js";import{a as U,b as G,c as H,d as Q,e as W}from"./chunk-UZERI5YC.js";import{a as ie}from"./chunk-V53KNYRN.js";import{a as w}from"./chunk-5Y3QLNWX.js";import{a as ee}from"./chunk-LFXFP4IF.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as _}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as k}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as F}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as R}from"./chunk-GXZAXNZI.js";import{f as J}from"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{a as K}from"./chunk-XQCVZAGU.js";import{d as z,f as V,g as X,h as Z,m as j}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as n,e as D,f as he,g as xe,h as ye}from"./chunk-3XIESWL4.js";var c=D(he(),1);var de=D(xe(),1);var e=D(ye(),1);var oe=["read","insert","update","delete"],ge=n((a,t)=>({delete:a("Delete"),insert:a("Insert"),read:a("Read"),update:a("Update")})[t],"xe"),be=n(a=>{let t=new Set;for(let s of a?.advisories??[])if(s.name==="rls_uncovered_table"){let{table:i}=s.metadata;typeof i=="string"&&i!==""&&t.add(i)}return t},"ye"),ve=n((a,t,s)=>{let i=new Map,r=n(l=>{let d=i.get(l);if(d!==void 0)return d;let o={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:[],table:l,uncovered:s.has(l)};return i.set(l,o),o},"r");for(let l of a)r(l.table).cells[l.on]={procedure:l.procedure};for(let l of t){let d=r(l.table);d.maskedColumns.includes(l.column)||d.maskedColumns.push(l.column)}for(let l of s)r(l);return[...i.values()].toSorted((l,d)=>l.table.localeCompare(d.table))},"ge"),Ne=n(a=>{let t=(0,de.c)(17),s;t[0]!==a?(s=a===void 0?{}:a,t[0]=a,t[1]=s):s=t[1];let{onProbe:i}=s,r=z(),l,d;t[2]===Symbol.for("react.memo_cache_sentinel")?(l={},d={live:!0},t[2]=l,t[3]=d):(l=t[2],d=t[3]);let o=O(R.rlsPolicies,l,d),y;t[4]===Symbol.for("react.memo_cache_sentinel")?(y={},t[4]=y):y=t[4];let u=O(R.maskPolicies,y),h;t[5]===Symbol.for("react.memo_cache_sentinel")?(h={},t[5]=h):h=t[5];let v=O(R.getAdvisories,h),N;if(t[6]!==v.data||t[7]!==u.data||t[8]!==i||t[9]!==o||t[10]!==r){let b=null;o.data!==void 0&&(b=Array.isArray(o.data.policies)?o.data.policies:[]);let E=Array.isArray(u.data?.columns)?u.data.columns:[],T=v.data??null,{error:x,errorSource:f,liveError:S}=o,I=b===null?[]:ve(b,E,be(T)),A;t[12]!==S?(A=(0,e.jsx)("div",{className:"flex items-center justify-end",children:(0,e.jsx)(se,{message:S,prefix:"pm"})}),t[12]=S,t[13]=A):A=t[13];let g;t[14]!==x||t[15]!==f?(g=x!==null&&(0,e.jsx)(te,{error:f,testId:"pm-error"}),t[14]=x,t[15]=f,t[16]=g):g=t[16],N=(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[A,g,b!==null&&I.length===0?(0,e.jsx)(K,{description:r("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:r("No policy")}):(0,e.jsxs)(ae,{"data-testid":"pm-table",children:[(0,e.jsx)(re,{children:(0,e.jsxs)(Y,{children:[(0,e.jsx)(M,{children:r("Table")}),oe.map(p=>(0,e.jsx)(M,{children:ge(r,p)},p)),(0,e.jsx)(M,{children:r("Masked columns")})]})}),(0,e.jsx)(le,{children:I.map(p=>(0,e.jsxs)(Y,{"data-testid":`pm-row-${p.table}`,children:[(0,e.jsx)(q,{className:"font-mono text-xs",children:(0,e.jsxs)("span",{className:"flex items-center gap-1.5",children:[p.table,p.uncovered&&(0,e.jsx)(F,{"data-testid":`pm-uncovered-${p.table}`,title:r("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:r("Uncovered \u2014 reachable without a policy")})]})}),oe.map(C=>{let $=p.cells[C];return(0,e.jsx)(q,{"data-testid":`pm-cell-${p.table}-${C}`,children:$.procedure===void 0?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:r("No policy")}):(0,e.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,e.jsx)(F,{variant:"secondary",children:r("Covered by {procedure}",{procedure:$.procedure})}),i!==void 0&&(0,e.jsx)(k,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${p.table}-${C}`,onClick:n(()=>{i(p.table,C,$.procedure??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Probe this")})]})},C)}),(0,e.jsx)(q,{children:p.maskedColumns.length===0?(0,e.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,e.jsx)("span",{className:"flex flex-wrap gap-1",children:p.maskedColumns.map(ke)})})]},p.table))})]})]}),t[6]=v.data,t[7]=u.data,t[8]=i,t[9]=o,t[10]=r,t[11]=N}else N=t[11];return N},"be");function ke(a){return(0,e.jsx)(F,{variant:"outline",children:a},a)}n(ke,"ve");var we=V(R.runAs),Ce=n(()=>{let a=J();return async({args:t,functionPath:s,shardKey:i="",userId:r})=>{let l=we;try{return{kind:"allowed",value:await a.query(l,{args:t,functionPath:s,userId:r},X(i))}}catch(d){return{kind:"denied",message:d instanceof Error?d.message:String(d)}}}},"we"),Pe=n(a=>a===void 0?"undefined":JSON.stringify(a,null,2),"ke"),Se=n(({functions:a,prefill:t,runAsIdentity:s=!1}={})=>{let i=J(),r=z(),l=Ce(),[d,o]=(0,c.useState)(null),[y,u]=(0,c.useState)(null),h=a??d??[],[v,N]=(0,c.useState)(""),[b,E]=(0,c.useState)("{}"),[T,x]=(0,c.useState)(""),[f,S]=(0,c.useState)(""),[I,A]=(0,c.useState)(!1),[g,p]=(0,c.useState)(null),[C,$]=(0,c.useState)(null),B=(0,c.useRef)(-1);(0,c.useEffect)(()=>{if(a!==void 0)return;let m=!1;return i.listFunctions().then(P=>(m||o(P),P)).catch(P=>{m||u(Z(P))}),()=>{m=!0}},[i,a]),(0,c.useEffect)(()=>{if(t===void 0||B.current===t.nonce)return;B.current=t.nonce;let m=t.functionPath;queueMicrotask(()=>{N(m),p(null)})},[t]);let L=v===""?h[0]?.path??"":v,ce=n(async()=>{if(L==="")return;let m;try{m=b.trim()===""?{}:JSON.parse(b)}catch(P){$(r("Invalid JSON args: {message}",{message:P.message})),p(null);return}$(null),A(!0);try{let P=await l({args:m,functionPath:L,shardKey:T.trim(),userId:f.trim()});p(P)}finally{A(!1)}},"Q"),me=n(()=>{j(ce())},"V"),pe=n(m=>{N(m.target.value)},"X"),fe=n(m=>{E(m.target.value)},"Z"),ue=n(m=>{S(m.target.value)},"ee");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[y!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:y}),!s&&(0,e.jsx)(K,{description:r("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:r("Set `runAsIdentity` to forge an identity and probe access.")}),(0,e.jsxs)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsx)(w,{htmlFor:"pp-function",children:r("Function")}),(0,e.jsx)("select",{"aria-label":r("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:pe,value:L,children:h.map(m=>(0,e.jsxs)("option",{value:m.path,children:[m.path," (",m.kind,")"]},m.path))})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsx)(w,{htmlFor:"pp-args",children:r("Arguments")}),(0,e.jsx)(ie,{"aria-label":r("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:fe,value:b})]}),(0,e.jsx)(ee,{onChange:x,testId:"pp-shard",value:T}),(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsx)(w,{htmlFor:"pp-user",children:r("Run as (userId)")}),(0,e.jsx)(_,{"aria-label":r("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:ue,placeholder:r("Leave empty to run as admin"),value:f})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(k,{"data-testid":"pp-run",disabled:!s||I||L==="",onClick:me,type:"button",children:r(I?"Probing\u2026":"Run probe")}),f.trim()!==""&&(0,e.jsx)(F,{"data-testid":"pp-as-badge",variant:"secondary",children:r("as {userId}",{userId:f.trim()})})]})]}),C!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:C}),g!==null&&g.kind==="allowed"&&(0,e.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[(0,e.jsx)(F,{variant:"secondary",children:r("Allowed")}),(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:Pe(g.value)})]}),g!==null&&g.kind==="denied"&&(0,e.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[(0,e.jsx)(F,{variant:"destructive",children:r("Denied")}),(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:g.message})]})]})},"Pe"),Ie="/__lunora/policy-scaffold",Ae={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists \u2014 pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({\u2026}) form \u2014 convert it to the builder form (c.use(\u2026).query(\u2026)) before wiring RLS."},Fe=n(async a=>{let t=await fetch(Ie,{body:JSON.stringify(a),headers:{"Content-Type":"application/json"},method:"POST"}),s=await t.json();if(s.needsManualEdit===!0)return{kind:"needs-manual-edit",message:s.message??"This change must be made by hand."};if(t.ok)return{diagnostics:s.diagnostics??[],kind:"ok",label:s.fileName??s.exportName??""};let i=s.error;return{kind:"error",message:i===void 0?`policy scaffold failed (${String(t.status)})`:Ae[i]??i}},"Ie"),ne={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},_e=n(()=>{let a=z(),[t,s]=(0,c.useState)(null),[i,r]=(0,c.useState)(!1),[l,d]=(0,c.useState)(null),[o,y]=(0,c.useState)(ne),u=n(x=>{let f=x.target.name,{value:S}=x.target;y(I=>({...I,[f]:S}))},"f"),h=n(()=>{s(null),y(ne)},"h"),v=n(async x=>{r(!0),d(null);try{let f=await Fe(x);d(f),f.kind==="ok"&&h()}catch(f){d({kind:"error",message:f instanceof Error?f.message:String(f)})}finally{r(!1)}},"v"),N=n(()=>{j(v({kind:"scaffoldPolicy",name:o.policyName.trim(),table:o.tableName.trim()}))},"N"),b=n(()=>{j(v({exportName:o.exportName.trim(),filePath:o.filePath.trim(),kind:"wireRls",policies:o.policies.trim()}))},"b"),E=n(()=>{d(null),s("scaffold")},"_"),T=n(()=>{d(null),s("wire")},"A");return(0,e.jsxs)(U,{"data-testid":"policy-scaffolder",size:"sm",children:[(0,e.jsxs)(G,{children:[(0,e.jsx)(H,{children:a("Scaffold access rules")}),(0,e.jsx)(Q,{children:a("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only.")})]}),(0,e.jsxs)(W,{children:[(0,e.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,e.jsx)(k,{"data-testid":"policy-scaffolder-new",onClick:E,size:"xs",type:"button",variant:t==="scaffold"?"default":"outline",children:a("New policy file")}),(0,e.jsx)(k,{"data-testid":"policy-scaffolder-wire",onClick:T,size:"xs",type:"button",variant:t==="wire"?"default":"outline",children:a("Wire into a procedure")})]}),t==="scaffold"&&(0,e.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsx)(w,{htmlFor:"policy-scaffolder-name",children:a("Policy name")}),(0,e.jsx)(_,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:u,value:o.policyName})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsx)(w,{htmlFor:"policy-scaffolder-table",children:a("Table name")}),(0,e.jsx)(_,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:u,value:o.tableName})]}),(0,e.jsx)(k,{"data-testid":"policy-scaffolder-create",disabled:i||o.policyName.trim()===""||o.tableName.trim()==="",onClick:N,size:"xs",type:"button",children:a(i?"Creating\u2026":"Create policy file")}),(0,e.jsx)(k,{onClick:h,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),t==="wire"&&(0,e.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsx)(w,{htmlFor:"policy-scaffolder-file",children:a("Procedure file path")}),(0,e.jsx)(_,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:u,value:o.filePath})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsx)(w,{htmlFor:"policy-scaffolder-export",children:a("Exported procedure")}),(0,e.jsx)(_,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:u,value:o.exportName})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsx)(w,{htmlFor:"policy-scaffolder-policies",children:a("Policy set identifier")}),(0,e.jsx)(_,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:u,value:o.policies})]}),(0,e.jsx)(k,{"data-testid":"policy-scaffolder-apply",disabled:i||o.filePath.trim()===""||o.exportName.trim()===""||o.policies.trim()==="",onClick:b,size:"xs",type:"button",children:a(i?"Wiring\u2026":"Wire RLS")}),(0,e.jsx)(k,{onClick:h,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),l?.kind==="error"&&(0,e.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:l.message}),l?.kind==="needs-manual-edit"&&(0,e.jsx)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:a("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")}),l?.kind==="ok"&&(0,e.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,e.jsx)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:a("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:l.label})}),l.diagnostics.length>0&&(0,e.jsx)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:l.diagnostics.map(x=>(0,e.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:x},x))})]})]})]})},"$e"),Be=n(({functions:a,runAsIdentity:t=!1,schemaEditable:s=!1}={})=>{let i=z(),[r,l]=(0,c.useState)(void 0),d=n((o,y,u)=>{u!==""&&l(h=>({functionPath:u,nonce:(h?.nonce??0)+1}))},"d");return(0,e.jsxs)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,e.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i("Permissions")})}),(0,e.jsx)(Ne,{onProbe:d})]}),(0,e.jsx)("section",{className:"flex flex-col gap-3",children:(0,e.jsxs)(U,{className:"gap-0 py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i("Probe")})}),(0,e.jsxs)(W,{className:"px-4 py-4",children:[(0,e.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:i("Pick a function and an identity, then run it to see the access outcome.")}),(0,e.jsx)(Se,{functions:a,prefill:r,runAsIdentity:t})]})]})}),s&&(0,e.jsx)("section",{className:"flex flex-col gap-2",children:(0,e.jsx)(_e,{})})]})},"Ye");export{Be as PermissionsPanel};
1
+ import{a as se}from"./chunk-X2FQ6B5V.js";import{a as te}from"./chunk-UNUU7CJJ.js";import"./chunk-XXQUMVWH.js";import{b as O}from"./chunk-XSD4Y6SQ.js";import{a as ae,b as re,c as le,d as Y,e as M,f as q}from"./chunk-MIQTKZAR.js";import{a as U,b as G,c as H,d as Q,e as W}from"./chunk-UZERI5YC.js";import{a as ie}from"./chunk-V53KNYRN.js";import{a as w}from"./chunk-5Y3QLNWX.js";import{a as ee}from"./chunk-LFXFP4IF.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as _}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as k}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as F}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as R}from"./chunk-GXZAXNZI.js";import{f as J}from"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import{a as K}from"./chunk-XQCVZAGU.js";import{d as z,f as V,g as X,h as Z,m as j}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as n,e as D,f as he,g as xe,h as ye}from"./chunk-3XIESWL4.js";var c=D(he(),1);var de=D(xe(),1);var e=D(ye(),1);var oe=["read","insert","update","delete"],ge=n((a,t)=>({delete:a("Delete"),insert:a("Insert"),read:a("Read"),update:a("Update")})[t],"xe"),be=n(a=>{let t=new Set;for(let s of a?.advisories??[])if(s.name==="rls_uncovered_table"){let{table:i}=s.metadata;typeof i=="string"&&i!==""&&t.add(i)}return t},"ye"),ve=n((a,t,s)=>{let i=new Map,r=n(l=>{let d=i.get(l);if(d!==void 0)return d;let o={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:[],table:l,uncovered:s.has(l)};return i.set(l,o),o},"r");for(let l of a)r(l.table).cells[l.on]={procedure:l.procedure};for(let l of t){let d=r(l.table);d.maskedColumns.includes(l.column)||d.maskedColumns.push(l.column)}for(let l of s)r(l);return[...i.values()].toSorted((l,d)=>l.table.localeCompare(d.table))},"ge"),Ne=n(a=>{let t=(0,de.c)(17),s;t[0]!==a?(s=a===void 0?{}:a,t[0]=a,t[1]=s):s=t[1];let{onProbe:i}=s,r=z(),l,d;t[2]===Symbol.for("react.memo_cache_sentinel")?(l={},d={live:!0},t[2]=l,t[3]=d):(l=t[2],d=t[3]);let o=O(R.rlsPolicies,l,d),y;t[4]===Symbol.for("react.memo_cache_sentinel")?(y={},t[4]=y):y=t[4];let u=O(R.maskPolicies,y),h;t[5]===Symbol.for("react.memo_cache_sentinel")?(h={},t[5]=h):h=t[5];let v=O(R.getAdvisories,h),N;if(t[6]!==v.data||t[7]!==u.data||t[8]!==i||t[9]!==o||t[10]!==r){let b=null;o.data!==void 0&&(b=Array.isArray(o.data.policies)?o.data.policies:[]);let E=Array.isArray(u.data?.columns)?u.data.columns:[],T=v.data??null,{error:x,errorSource:f,liveError:S}=o,I=b===null?[]:ve(b,E,be(T)),A;t[12]!==S?(A=(0,e.jsx)("div",{className:"flex items-center justify-end",children:(0,e.jsx)(se,{message:S,prefix:"pm"})}),t[12]=S,t[13]=A):A=t[13];let g;t[14]!==x||t[15]!==f?(g=x!==null&&(0,e.jsx)(te,{error:f,testId:"pm-error"}),t[14]=x,t[15]=f,t[16]=g):g=t[16],N=(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[A,g,b!==null&&I.length===0?(0,e.jsx)(K,{description:r("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:r("No policy")}):(0,e.jsxs)(ae,{"data-testid":"pm-table",children:[(0,e.jsx)(re,{children:(0,e.jsxs)(Y,{children:[(0,e.jsx)(M,{children:r("Table")}),oe.map(p=>(0,e.jsx)(M,{children:ge(r,p)},p)),(0,e.jsx)(M,{children:r("Masked columns")})]})}),(0,e.jsx)(le,{children:I.map(p=>(0,e.jsxs)(Y,{"data-testid":`pm-row-${p.table}`,children:[(0,e.jsx)(q,{className:"font-mono text-xs",children:(0,e.jsxs)("span",{className:"flex items-center gap-1.5",children:[p.table,p.uncovered&&(0,e.jsx)(F,{"data-testid":`pm-uncovered-${p.table}`,title:r("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:r("Uncovered \u2014 reachable without a policy")})]})}),oe.map(C=>{let $=p.cells[C];return(0,e.jsx)(q,{"data-testid":`pm-cell-${p.table}-${C}`,children:$.procedure===void 0?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:r("No policy")}):(0,e.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,e.jsx)(F,{variant:"secondary",children:r("Covered by {procedure}",{procedure:$.procedure})}),i!==void 0&&(0,e.jsx)(k,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${p.table}-${C}`,onClick:n(()=>{i(p.table,C,$.procedure??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Probe this")})]})},C)}),(0,e.jsx)(q,{children:p.maskedColumns.length===0?(0,e.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,e.jsx)("span",{className:"flex flex-wrap gap-1",children:p.maskedColumns.map(ke)})})]},p.table))})]})]}),t[6]=v.data,t[7]=u.data,t[8]=i,t[9]=o,t[10]=r,t[11]=N}else N=t[11];return N},"be");function ke(a){return(0,e.jsx)(F,{variant:"outline",children:a},a)}n(ke,"ve");var we=V(R.runAs),Ce=n(()=>{let a=J();return async({args:t,functionPath:s,shardKey:i="",userId:r})=>{let l=we;try{return{kind:"allowed",value:await a.query(l,{args:t,functionPath:s,userId:r},X(i))}}catch(d){return{kind:"denied",message:d instanceof Error?d.message:String(d)}}}},"we"),Pe=n(a=>a===void 0?"undefined":JSON.stringify(a,null,2),"ke"),Se=n(({functions:a,prefill:t,runAsIdentity:s=!1}={})=>{let i=J(),r=z(),l=Ce(),[d,o]=(0,c.useState)(null),[y,u]=(0,c.useState)(null),h=a??d??[],[v,N]=(0,c.useState)(""),[b,E]=(0,c.useState)("{}"),[T,x]=(0,c.useState)(""),[f,S]=(0,c.useState)(""),[I,A]=(0,c.useState)(!1),[g,p]=(0,c.useState)(null),[C,$]=(0,c.useState)(null),B=(0,c.useRef)(-1);(0,c.useEffect)(()=>{if(a!==void 0)return;let m=!1;return i.listFunctions().then(P=>(m||o(P),P)).catch(P=>{m||u(Z(P))}),()=>{m=!0}},[i,a]),(0,c.useEffect)(()=>{if(t===void 0||B.current===t.nonce)return;B.current=t.nonce;let m=t.functionPath;queueMicrotask(()=>{N(m),p(null)})},[t]);let L=v===""?h[0]?.path??"":v,ce=n(async()=>{if(L==="")return;let m;try{m=b.trim()===""?{}:JSON.parse(b)}catch(P){$(r("Invalid JSON args: {message}",{message:P.message})),p(null);return}$(null),A(!0);try{let P=await l({args:m,functionPath:L,shardKey:T.trim(),userId:f.trim()});p(P)}finally{A(!1)}},"Q"),me=n(()=>{j(ce())},"V"),pe=n(m=>{N(m.target.value)},"X"),fe=n(m=>{E(m.target.value)},"Z"),ue=n(m=>{S(m.target.value)},"ee");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[y!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:y}),!s&&(0,e.jsx)(K,{description:r("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:r("Set `runAsIdentity` to forge an identity and probe access.")}),(0,e.jsxs)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsx)(w,{htmlFor:"pp-function",children:r("Function")}),(0,e.jsx)("select",{"aria-label":r("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:pe,value:L,children:h.map(m=>(0,e.jsxs)("option",{value:m.path,children:[m.path," (",m.kind,")"]},m.path))})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsx)(w,{htmlFor:"pp-args",children:r("Arguments")}),(0,e.jsx)(ie,{"aria-label":r("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:fe,value:b})]}),(0,e.jsx)(ee,{onChange:x,testId:"pp-shard",value:T}),(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsx)(w,{htmlFor:"pp-user",children:r("Run as (userId)")}),(0,e.jsx)(_,{"aria-label":r("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:ue,placeholder:r("Leave empty to run as admin"),value:f})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(k,{"data-testid":"pp-run",disabled:!s||I||L==="",onClick:me,type:"button",children:r(I?"Probing\u2026":"Run probe")}),f.trim()!==""&&(0,e.jsx)(F,{"data-testid":"pp-as-badge",variant:"secondary",children:r("as {userId}",{userId:f.trim()})})]})]}),C!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:C}),g!==null&&g.kind==="allowed"&&(0,e.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[(0,e.jsx)(F,{variant:"secondary",children:r("Allowed")}),(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:Pe(g.value)})]}),g!==null&&g.kind==="denied"&&(0,e.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[(0,e.jsx)(F,{variant:"destructive",children:r("Denied")}),(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:g.message})]})]})},"Pe"),Ie="/__lunora/policy-scaffold",Ae={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists \u2014 pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({\u2026}) form \u2014 convert it to the builder form (c.use(\u2026).query(\u2026)) before wiring RLS."},Fe=n(async a=>{let t=await fetch(Ie,{body:JSON.stringify(a),headers:{"Content-Type":"application/json"},method:"POST"}),s=await t.json();if(s.needsManualEdit===!0)return{kind:"needs-manual-edit",message:s.message??"This change must be made by hand."};if(t.ok)return{diagnostics:s.diagnostics??[],kind:"ok",label:s.fileName??s.exportName??""};let i=s.error;return{kind:"error",message:i===void 0?`policy scaffold failed (${String(t.status)})`:Ae[i]??i}},"Ie"),ne={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},_e=n(()=>{let a=z(),[t,s]=(0,c.useState)(null),[i,r]=(0,c.useState)(!1),[l,d]=(0,c.useState)(null),[o,y]=(0,c.useState)(ne),u=n(x=>{let f=x.target.name,{value:S}=x.target;y(I=>({...I,[f]:S}))},"f"),h=n(()=>{s(null),y(ne)},"h"),v=n(async x=>{r(!0),d(null);try{let f=await Fe(x);d(f),f.kind==="ok"&&h()}catch(f){d({kind:"error",message:f instanceof Error?f.message:String(f)})}finally{r(!1)}},"v"),N=n(()=>{j(v({kind:"scaffoldPolicy",name:o.policyName.trim(),table:o.tableName.trim()}))},"N"),b=n(()=>{j(v({exportName:o.exportName.trim(),filePath:o.filePath.trim(),kind:"wireRls",policies:o.policies.trim()}))},"b"),E=n(()=>{d(null),s("scaffold")},"_"),T=n(()=>{d(null),s("wire")},"A");return(0,e.jsxs)(U,{"data-testid":"policy-scaffolder",size:"sm",children:[(0,e.jsxs)(G,{children:[(0,e.jsx)(H,{children:a("Scaffold access rules")}),(0,e.jsx)(Q,{children:a("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only.")})]}),(0,e.jsxs)(W,{children:[(0,e.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,e.jsx)(k,{"data-testid":"policy-scaffolder-new",onClick:E,size:"xs",type:"button",variant:t==="scaffold"?"default":"outline",children:a("New policy file")}),(0,e.jsx)(k,{"data-testid":"policy-scaffolder-wire",onClick:T,size:"xs",type:"button",variant:t==="wire"?"default":"outline",children:a("Wire into a procedure")})]}),t==="scaffold"&&(0,e.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsx)(w,{htmlFor:"policy-scaffolder-name",children:a("Policy name")}),(0,e.jsx)(_,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:u,value:o.policyName})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsx)(w,{htmlFor:"policy-scaffolder-table",children:a("Table name")}),(0,e.jsx)(_,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:u,value:o.tableName})]}),(0,e.jsx)(k,{"data-testid":"policy-scaffolder-create",disabled:i||o.policyName.trim()===""||o.tableName.trim()==="",onClick:N,size:"xs",type:"button",children:a(i?"Creating\u2026":"Create policy file")}),(0,e.jsx)(k,{onClick:h,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),t==="wire"&&(0,e.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsx)(w,{htmlFor:"policy-scaffolder-file",children:a("Procedure file path")}),(0,e.jsx)(_,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:u,value:o.filePath})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsx)(w,{htmlFor:"policy-scaffolder-export",children:a("Exported procedure")}),(0,e.jsx)(_,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:u,value:o.exportName})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsx)(w,{htmlFor:"policy-scaffolder-policies",children:a("Policy set identifier")}),(0,e.jsx)(_,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:u,value:o.policies})]}),(0,e.jsx)(k,{"data-testid":"policy-scaffolder-apply",disabled:i||o.filePath.trim()===""||o.exportName.trim()===""||o.policies.trim()==="",onClick:b,size:"xs",type:"button",children:a(i?"Wiring\u2026":"Wire RLS")}),(0,e.jsx)(k,{onClick:h,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),l?.kind==="error"&&(0,e.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:l.message}),l?.kind==="needs-manual-edit"&&(0,e.jsx)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:a("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")}),l?.kind==="ok"&&(0,e.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,e.jsx)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:a("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:l.label})}),l.diagnostics.length>0&&(0,e.jsx)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:l.diagnostics.map(x=>(0,e.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:x},x))})]})]})]})},"$e"),Be=n(({functions:a,runAsIdentity:t=!1,schemaEditable:s=!1}={})=>{let i=z(),[r,l]=(0,c.useState)(void 0),d=n((o,y,u)=>{u!==""&&l(h=>({functionPath:u,nonce:(h?.nonce??0)+1}))},"d");return(0,e.jsxs)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,e.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i("Permissions")})}),(0,e.jsx)(Ne,{onProbe:d})]}),(0,e.jsx)("section",{className:"flex flex-col gap-3",children:(0,e.jsxs)(U,{className:"gap-0 py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i("Probe")})}),(0,e.jsxs)(W,{className:"px-4 py-4",children:[(0,e.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:i("Pick a function and an identity, then run it to see the access outcome.")}),(0,e.jsx)(Se,{functions:a,prefill:r,runAsIdentity:t})]})]})}),s&&(0,e.jsx)("section",{className:"flex flex-col gap-2",children:(0,e.jsx)(_e,{})})]})},"Ye");export{Be as PermissionsPanel};