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

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 (111) hide show
  1. package/dist/standalone/{chunk-JC6WYIHM.js → chunk-26TQSVUV.js} +1 -1
  2. package/dist/standalone/{chunk-ZFWEPGWG.js → chunk-2OUPA2WJ.js} +1 -1
  3. package/dist/standalone/{chunk-HA34GYEX.js → chunk-2PJNAWB3.js} +1 -1
  4. package/dist/standalone/{chunk-CVMRZUF5.js → chunk-2Y36BVVM.js} +1 -1
  5. package/dist/standalone/{chunk-KNN3ZEQ7.js → chunk-37RIZFJ4.js} +1 -1
  6. package/dist/standalone/{chunk-UNN4CESU.js → chunk-3NHORZCK.js} +1 -1
  7. package/dist/standalone/{chunk-UNDFOYRI.js → chunk-3RTTXLMU.js} +1 -1
  8. package/dist/standalone/{chunk-UHHTEBC3.js → chunk-3XIESWL4.js} +1 -1
  9. package/dist/standalone/{chunk-KLLYGWNF.js → chunk-4CGALXS3.js} +1 -1
  10. package/dist/standalone/{chunk-O62HJZV3.js → chunk-4MSKCWUL.js} +1 -1
  11. package/dist/standalone/{chunk-SEDZDNQF.js → chunk-4UOFSGUS.js} +1 -1
  12. package/dist/standalone/{chunk-SA6MBPBL.js → chunk-54MMVNPT.js} +1 -1
  13. package/dist/standalone/{chunk-RE6UWCMG.js → chunk-5L2MD6F6.js} +1 -1
  14. package/dist/standalone/{chunk-HY46NTNW.js → chunk-5RF4QDDA.js} +1 -1
  15. package/dist/standalone/{chunk-YT7VXQVX.js → chunk-5Y3QLNWX.js} +1 -1
  16. package/dist/standalone/{chunk-LPOKAJT4.js → chunk-66TS6K5F.js} +1 -1
  17. package/dist/standalone/{chunk-4FNHHFWR.js → chunk-6ST5ECQA.js} +1 -1
  18. package/dist/standalone/{chunk-C4VURT57.js → chunk-7LQWFOEU.js} +1 -1
  19. package/dist/standalone/{chunk-46IB4C4Q.js → chunk-7QIFDWQV.js} +1 -1
  20. package/dist/standalone/{chunk-AKTGRZXN.js → chunk-7RXOPYR5.js} +1 -1
  21. package/dist/standalone/{chunk-PTTDIYGP.js → chunk-7T7UOTYK.js} +1 -1
  22. package/dist/standalone/{chunk-XRKCGQM2.js → chunk-7YAUSG6S.js} +1 -1
  23. package/dist/standalone/{chunk-PWDMXMRD.js → chunk-7YEFOSPH.js} +1 -1
  24. package/dist/standalone/chunk-AVAC26HJ.js +1 -0
  25. package/dist/standalone/{chunk-VUJGR4PB.js → chunk-AX4PAEGP.js} +1 -1
  26. package/dist/standalone/{chunk-JRWBGR5B.js → chunk-B5E7GQHG.js} +1 -1
  27. package/dist/standalone/{chunk-3DTM4GI5.js → chunk-BEH5N5ZA.js} +1 -1
  28. package/dist/standalone/{chunk-YNBJ6ICE.js → chunk-BGBLQ563.js} +1 -1
  29. package/dist/standalone/{chunk-SZUHZ2OG.js → chunk-BY4QROKU.js} +1 -1
  30. package/dist/standalone/{chunk-7Z5QEFR4.js → chunk-CFPZYHPY.js} +1 -1
  31. package/dist/standalone/{chunk-BAIN7UJ4.js → chunk-DCJKCERP.js} +1 -1
  32. package/dist/standalone/{chunk-P4J6XNG3.js → chunk-DY7CLL2H.js} +1 -1
  33. package/dist/standalone/{chunk-VEFNSN7P.js → chunk-ESVP44Y3.js} +1 -1
  34. package/dist/standalone/{chunk-IE4ROTQD.js → chunk-F6LUZVVI.js} +1 -1
  35. package/dist/standalone/{chunk-UY2Y5CXB.js → chunk-FXCBF4XT.js} +1 -1
  36. package/dist/standalone/{chunk-BHWSIIDT.js → chunk-GBQHGYGH.js} +1 -1
  37. package/dist/standalone/{chunk-HMIOF5GV.js → chunk-GHUPW2Y5.js} +1 -1
  38. package/dist/standalone/{chunk-FXFK4M4E.js → chunk-GMR677FL.js} +1 -1
  39. package/dist/standalone/{chunk-UWF5DOGV.js → chunk-GRL5MG3Z.js} +1 -1
  40. package/dist/standalone/{chunk-GTXVH7I5.js → chunk-H3V2QQ4K.js} +1 -1
  41. package/dist/standalone/{chunk-KZ2YUNMR.js → chunk-H7NIIBHH.js} +1 -1
  42. package/dist/standalone/{chunk-H6SIM4BT.js → chunk-HPFLBYRI.js} +1 -1
  43. package/dist/standalone/{chunk-CZEUVNCQ.js → chunk-IC4L6G56.js} +1 -1
  44. package/dist/standalone/{chunk-PGDWFWH5.js → chunk-IGBEXNXY.js} +1 -1
  45. package/dist/standalone/{chunk-TEIBKU46.js → chunk-IJFCOWEQ.js} +1 -1
  46. package/dist/standalone/{chunk-TYTJDFX2.js → chunk-ILNELDFC.js} +1 -1
  47. package/dist/standalone/{chunk-AGVJJQFL.js → chunk-IPHXIGYP.js} +1 -1
  48. package/dist/standalone/{chunk-TAE2H7PU.js → chunk-IUW24D4X.js} +1 -1
  49. package/dist/standalone/{chunk-C4O5UR4Y.js → chunk-IVFHIQOT.js} +1 -1
  50. package/dist/standalone/{chunk-MZEK4SGD.js → chunk-JGY4NGFW.js} +1 -1
  51. package/dist/standalone/{chunk-JLFCXBNQ.js → chunk-JN2Y24PY.js} +1 -1
  52. package/dist/standalone/{chunk-CYET4BRZ.js → chunk-K7M4SMQ7.js} +1 -1
  53. package/dist/standalone/{chunk-6CLVIOCB.js → chunk-KUVMORDQ.js} +1 -1
  54. package/dist/standalone/{chunk-NCCUM26H.js → chunk-KYF2E5CJ.js} +1 -1
  55. package/dist/standalone/{chunk-QC5HCNJZ.js → chunk-LA3HEESS.js} +1 -1
  56. package/dist/standalone/{chunk-UDZY7MKE.js → chunk-LE56LPNH.js} +1 -1
  57. package/dist/standalone/{chunk-SNDYNCAA.js → chunk-LEDWUPXM.js} +1 -1
  58. package/dist/standalone/{chunk-YQ5PILIJ.js → chunk-LFKCLLPT.js} +1 -1
  59. package/dist/standalone/{chunk-V66TSUKV.js → chunk-LFXFP4IF.js} +1 -1
  60. package/dist/standalone/{chunk-VUXJER3D.js → chunk-LLXFYRGQ.js} +1 -1
  61. package/dist/standalone/{chunk-KJTLW5W2.js → chunk-LWECXQWP.js} +3 -3
  62. package/dist/standalone/{chunk-2A4RKII2.js → chunk-M2B3MDFJ.js} +1 -1
  63. package/dist/standalone/{chunk-ICKBVXPP.js → chunk-M536Y2KX.js} +1 -1
  64. package/dist/standalone/{chunk-LKHUVEHX.js → chunk-M7QCL3ZP.js} +1 -1
  65. package/dist/standalone/{chunk-Q5WXTZWX.js → chunk-MIQTKZAR.js} +1 -1
  66. package/dist/standalone/{chunk-IYYTWZ2E.js → chunk-NPIULIRO.js} +1 -1
  67. package/dist/standalone/{chunk-SKJZDOHG.js → chunk-OWADN6BI.js} +1 -1
  68. package/dist/standalone/{chunk-IBCKC2BO.js → chunk-OZGWNJXD.js} +1 -1
  69. package/dist/standalone/{chunk-CKO3F55C.js → chunk-P4DHFWH7.js} +1 -1
  70. package/dist/standalone/{chunk-3MHKT76P.js → chunk-P4J3Z3SA.js} +1 -1
  71. package/dist/standalone/chunk-PF7V3G2Z.js +62 -0
  72. package/dist/standalone/{chunk-W572365D.js → chunk-PYXZLNG2.js} +1 -1
  73. package/dist/standalone/{chunk-R43KHQDA.js → chunk-PZPFWABF.js} +1 -1
  74. package/dist/standalone/chunk-QBWRC5YX.js +1 -0
  75. package/dist/standalone/{chunk-GS7OBQO5.js → chunk-QLJJ5YYZ.js} +1 -1
  76. package/dist/standalone/{chunk-ZMFZRGAN.js → chunk-QWGT25SE.js} +1 -1
  77. package/dist/standalone/{chunk-RC2K5RBE.js → chunk-RLEENOIX.js} +1 -1
  78. package/dist/standalone/{chunk-Z7MUQMLE.js → chunk-RWZKO2P6.js} +1 -1
  79. package/dist/standalone/{chunk-PR2SE2MD.js → chunk-SD4BERSA.js} +1 -1
  80. package/dist/standalone/{chunk-KYCAYNXM.js → chunk-SFDOII3B.js} +1 -1
  81. package/dist/standalone/{chunk-UNXX5GQH.js → chunk-SM67QXQI.js} +1 -1
  82. package/dist/standalone/{chunk-6UYILUSX.js → chunk-SMIESS7P.js} +1 -1
  83. package/dist/standalone/{chunk-KSRXMTBV.js → chunk-T6VMSOBB.js} +1 -1
  84. package/dist/standalone/{chunk-WYFLGXZ3.js → chunk-TCQEDMAQ.js} +1 -1
  85. package/dist/standalone/{chunk-23HKRH5H.js → chunk-TDE4AR5O.js} +1 -1
  86. package/dist/standalone/{chunk-K5PFWU5J.js → chunk-THIXMMZD.js} +1 -1
  87. package/dist/standalone/{chunk-RUP3M2GF.js → chunk-TRHTFGFW.js} +2 -2
  88. package/dist/standalone/{chunk-Q34MSC2F.js → chunk-UNUU7CJJ.js} +1 -1
  89. package/dist/standalone/{chunk-FYAJPWE7.js → chunk-UVDPQU7J.js} +1 -1
  90. package/dist/standalone/{chunk-JKPK25JO.js → chunk-UZERI5YC.js} +1 -1
  91. package/dist/standalone/{chunk-P2NBOUGZ.js → chunk-V4RWA7QI.js} +1 -1
  92. package/dist/standalone/{chunk-UZYGEOWY.js → chunk-V53KNYRN.js} +1 -1
  93. package/dist/standalone/{chunk-7AZZ7OJO.js → chunk-VSS7NFZJ.js} +1 -1
  94. package/dist/standalone/{chunk-7CRLAMGB.js → chunk-WQTUQZUM.js} +1 -1
  95. package/dist/standalone/{chunk-6I62RSI5.js → chunk-X2FQ6B5V.js} +1 -1
  96. package/dist/standalone/{chunk-UREY4GLG.js → chunk-XBDKZZ67.js} +1 -1
  97. package/dist/standalone/{chunk-TO6NLVFD.js → chunk-XBGJVK32.js} +1 -1
  98. package/dist/standalone/{chunk-QJKRHZYV.js → chunk-XITDHIVL.js} +1 -1
  99. package/dist/standalone/{chunk-6OKDCV7J.js → chunk-XQCVZAGU.js} +1 -1
  100. package/dist/standalone/{chunk-6P7HIPUE.js → chunk-XQGANNLS.js} +1 -1
  101. package/dist/standalone/{chunk-4AYEV5UN.js → chunk-XXQUMVWH.js} +1 -1
  102. package/dist/standalone/{chunk-H6WOFY6A.js → chunk-YQP2EYOC.js} +1 -1
  103. package/dist/standalone/chunk-ZJGP6EKR.js +1 -0
  104. package/dist/standalone/{chunk-J2LMP2A7.js → chunk-ZKEVSU66.js} +1 -1
  105. package/dist/standalone/{chunk-CWWGDW4V.js → chunk-ZSWWTXVW.js} +1 -1
  106. package/dist/standalone/studio.js +2 -2
  107. package/package.json +10 -10
  108. package/dist/standalone/chunk-725RLB7D.js +0 -1
  109. package/dist/standalone/chunk-KOC5KV3E.js +0 -1
  110. package/dist/standalone/chunk-OTJOI23O.js +0 -62
  111. package/dist/standalone/chunk-XDKFPBIL.js +0 -1
@@ -1 +1 @@
1
- import{a as O}from"./chunk-6I62RSI5.js";import{a as q,b as B}from"./chunk-725RLB7D.js";import{a as z}from"./chunk-YQ5PILIJ.js";import{a as A}from"./chunk-Q34MSC2F.js";import"./chunk-4AYEV5UN.js";import{b as R}from"./chunk-SKJZDOHG.js";import{a as K,b as T,c as F,d as p,e as l,f as d}from"./chunk-Q5WXTZWX.js";import{a as I,e as E}from"./chunk-JKPK25JO.js";import{a as j}from"./chunk-V66TSUKV.js";import"./chunk-UWF5DOGV.js";import"./chunk-PTTDIYGP.js";import{R as C}from"./chunk-7Z5QEFR4.js";import"./chunk-46IB4C4Q.js";import"./chunk-ZFWEPGWG.js";import{b as y}from"./chunk-K5PFWU5J.js";import"./chunk-4FNHHFWR.js";import{a as V}from"./chunk-GXZAXNZI.js";import"./chunk-KJTLW5W2.js";import"./chunk-UREY4GLG.js";import{a as k}from"./chunk-6OKDCV7J.js";import{d as L,q as M}from"./chunk-KLLYGWNF.js";import"./chunk-UDZY7MKE.js";import{a as o,e as b,f as ee,h as te}from"./chunk-UHHTEBC3.js";var i=b(ee(),1);var e=b(te(),1);var D=80,re=o(s=>{if(s===void 0)return"";let t=JSON.stringify(s);return t.length>D?`${t.slice(0,D)}\u2026`:t},"te"),ae=41,J=480,H=5,ie=o((s,t)=>q(s,n=>{t(n.height>0?n:{height:J,width:n.width})}),"ae"),Ne=o(({initialShardKey:s})=>{let t=L(),[n,P]=(0,i.useState)(s??""),[c,U]=(0,i.useState)(""),W=z(n.trim(),400),{data:f,error:g,errorSource:Z,isLoading:_,liveError:$}=R(V.getAuditLog,{},{live:!0,shardKey:W}),h=(0,i.useMemo)(()=>f?.entries??[],[f]),m=(0,i.useMemo)(()=>{let a=c.trim().toLowerCase();return a===""?h:h.filter(r=>r.op.toLowerCase().includes(a)||(r.table??"").toLowerCase().includes(a)||(r.id??"").toLowerCase().includes(a))},[h,c]),x=(0,i.useRef)(null),v=B({count:m.length,estimateSize:o(()=>ae,"estimateSize"),getScrollElement:o(()=>x.current,"getScrollElement"),initialRect:{height:J,width:800},observeElementRect:ie,overscan:8}),u=v.getVirtualItems(),G=v.getTotalSize(),N=u[0]?.start??0,w=G-(u.at(-1)?.end??0),Q={height:N},X={height:w},Y=o(a=>{U(a.target.value)},"V");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(j,{onChange:P,testId:"au-shard-input",value:n}),(0,e.jsx)(O,{message:$,prefix:"au"}),(0,e.jsx)(C,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:Y,placeholder:t("filter op, table, id"),value:c})]}),g!==null&&(0,e.jsx)(A,{error:Z,testId:"au-error"}),g===null&&!_&&m.length===0&&(0,e.jsx)(k,{description:t("State-changing admin operations are recorded 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:"M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3Zm-1 9h8m-8 4h5"})}),testId:"au-empty",title:t("No audit entries.")}),m.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(E,{className:"max-h-[30rem] overflow-auto px-0",ref:x,children:(0,e.jsxs)(K,{"data-testid":"au-table",children:[(0,e.jsx)(T,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(l,{children:t("time")}),(0,e.jsx)(l,{children:t("op")}),(0,e.jsx)(l,{children:t("table")}),(0,e.jsx)(l,{children:t("id")}),(0,e.jsx)(l,{children:t("detail")})]})}),(0,e.jsxs)(F,{children:[N>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:Q})}),u.map(a=>{let r=m[a.index],S=re(r.detail);return(0,e.jsxs)(p,{"data-testid":"au-row",children:[(0,e.jsx)(d,{className:"text-muted-foreground tabular-nums",children:M(r.ts,"\u2014")}),(0,e.jsx)(d,{children:(0,e.jsx)(y,{variant:"secondary",children:r.op})}),(0,e.jsx)(d,{className:"font-medium",children:r.table??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(d,{className:"max-w-[20ch] truncate font-mono text-xs",children:r.id??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(d,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:S||void 0,children:S||(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},r.seq)}),w>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:X})})]})]})})})]})},"we");export{Ne as AuditPanel};
1
+ import{a as O}from"./chunk-X2FQ6B5V.js";import{a as q,b as B}from"./chunk-AVAC26HJ.js";import{a as z}from"./chunk-LFKCLLPT.js";import{a as A}from"./chunk-UNUU7CJJ.js";import"./chunk-XXQUMVWH.js";import{b as R}from"./chunk-OWADN6BI.js";import{a as K,b as T,c as F,d as p,e as l,f as d}from"./chunk-MIQTKZAR.js";import{a as I,e as E}from"./chunk-UZERI5YC.js";import{a as j}from"./chunk-LFXFP4IF.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as C}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as y}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as V}from"./chunk-GXZAXNZI.js";import"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{a as k}from"./chunk-XQCVZAGU.js";import{d as L,q as M}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as o,e as b,f as ee,h as te}from"./chunk-3XIESWL4.js";var i=b(ee(),1);var e=b(te(),1);var D=80,re=o(s=>{if(s===void 0)return"";let t=JSON.stringify(s);return t.length>D?`${t.slice(0,D)}\u2026`:t},"te"),ae=41,J=480,H=5,ie=o((s,t)=>q(s,n=>{t(n.height>0?n:{height:J,width:n.width})}),"ae"),Ne=o(({initialShardKey:s})=>{let t=L(),[n,P]=(0,i.useState)(s??""),[c,U]=(0,i.useState)(""),W=z(n.trim(),400),{data:f,error:g,errorSource:Z,isLoading:_,liveError:$}=R(V.getAuditLog,{},{live:!0,shardKey:W}),h=(0,i.useMemo)(()=>f?.entries??[],[f]),m=(0,i.useMemo)(()=>{let a=c.trim().toLowerCase();return a===""?h:h.filter(r=>r.op.toLowerCase().includes(a)||(r.table??"").toLowerCase().includes(a)||(r.id??"").toLowerCase().includes(a))},[h,c]),x=(0,i.useRef)(null),v=B({count:m.length,estimateSize:o(()=>ae,"estimateSize"),getScrollElement:o(()=>x.current,"getScrollElement"),initialRect:{height:J,width:800},observeElementRect:ie,overscan:8}),u=v.getVirtualItems(),G=v.getTotalSize(),N=u[0]?.start??0,w=G-(u.at(-1)?.end??0),Q={height:N},X={height:w},Y=o(a=>{U(a.target.value)},"V");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(j,{onChange:P,testId:"au-shard-input",value:n}),(0,e.jsx)(O,{message:$,prefix:"au"}),(0,e.jsx)(C,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:Y,placeholder:t("filter op, table, id"),value:c})]}),g!==null&&(0,e.jsx)(A,{error:Z,testId:"au-error"}),g===null&&!_&&m.length===0&&(0,e.jsx)(k,{description:t("State-changing admin operations are recorded 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:"M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3Zm-1 9h8m-8 4h5"})}),testId:"au-empty",title:t("No audit entries.")}),m.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(E,{className:"max-h-[30rem] overflow-auto px-0",ref:x,children:(0,e.jsxs)(K,{"data-testid":"au-table",children:[(0,e.jsx)(T,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(l,{children:t("time")}),(0,e.jsx)(l,{children:t("op")}),(0,e.jsx)(l,{children:t("table")}),(0,e.jsx)(l,{children:t("id")}),(0,e.jsx)(l,{children:t("detail")})]})}),(0,e.jsxs)(F,{children:[N>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:Q})}),u.map(a=>{let r=m[a.index],S=re(r.detail);return(0,e.jsxs)(p,{"data-testid":"au-row",children:[(0,e.jsx)(d,{className:"text-muted-foreground tabular-nums",children:M(r.ts,"\u2014")}),(0,e.jsx)(d,{children:(0,e.jsx)(y,{variant:"secondary",children:r.op})}),(0,e.jsx)(d,{className:"font-medium",children:r.table??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(d,{className:"max-w-[20ch] truncate font-mono text-xs",children:r.id??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(d,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:S||void 0,children:S||(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},r.seq)}),w>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:X})})]})]})})})]})},"we");export{Ne as AuditPanel};
@@ -1 +1 @@
1
- import{a as o}from"./chunk-UHHTEBC3.js";var h=new Set(["contains","eq","gt","gte","lt","lte","ne"]),i=o(t=>{if(typeof t!="string")return;let e=t.trim();return e===""?void 0:e},"a"),f=o(t=>{if(t===null||typeof t!="object")return!1;let e=t;return typeof e.column=="string"&&typeof e.operator=="string"&&h.has(e.operator)},"h"),l=o(t=>{if(typeof t!="string"||t==="")return[];try{let e=JSON.parse(t);return Array.isArray(e)?e.filter(f):[]}catch{return[]}},"d"),c=o(t=>{if(typeof t!="string"||t==="")return;let e=t.lastIndexOf(":");if(e<=0)return;let s=t.slice(0,e),r=t.slice(e+1);if(!(r!=="asc"&&r!=="desc"))return{column:s,direction:r}},"c"),v=o(t=>{let e={};t.schema==="global"&&(e.schema="global");let s=i(t.table);s!==void 0&&(e.table=s);let r=i(t.shard);r!==void 0&&(e.shard=r);let d=i(t.search);d!==void 0&&(e.search=d);let a=i(t.order);a!==void 0&&c(a)!==void 0&&(e.order=a);let n=i(t.filters);return n!==void 0&&l(n).length>0&&(e.filters=n),e},"f"),g=o(t=>{let e=l(t.filters),s=c(t.order);return{filters:e.length>0?e:void 0,orderBy:s,search:typeof t.search=="string"&&t.search!==""?t.search:void 0,shard:typeof t.shard=="string"&&t.shard!==""?t.shard:void 0,table:typeof t.table=="string"&&t.table!==""?t.table:void 0,tier:t.schema==="global"?"global":"shard"}},"v"),b=o(t=>{let e=t.filters??[];return{filters:e.length>0?JSON.stringify(e):void 0,order:t.orderBy===void 0?void 0:`${t.orderBy.column}:${t.orderBy.direction}`,schema:t.tier==="global"?"global":void 0,search:t.search!==void 0&&t.search!==""?t.search:void 0,shard:t.shard!==void 0&&t.shard!==""?t.shard:void 0,table:t.table!==void 0&&t.table!==""?t.table:void 0}},"g");export{v as a,g as b,b as c};
1
+ import{a as o}from"./chunk-3XIESWL4.js";var h=new Set(["contains","eq","gt","gte","lt","lte","ne"]),i=o(t=>{if(typeof t!="string")return;let e=t.trim();return e===""?void 0:e},"a"),f=o(t=>{if(t===null||typeof t!="object")return!1;let e=t;return typeof e.column=="string"&&typeof e.operator=="string"&&h.has(e.operator)},"h"),l=o(t=>{if(typeof t!="string"||t==="")return[];try{let e=JSON.parse(t);return Array.isArray(e)?e.filter(f):[]}catch{return[]}},"d"),c=o(t=>{if(typeof t!="string"||t==="")return;let e=t.lastIndexOf(":");if(e<=0)return;let s=t.slice(0,e),r=t.slice(e+1);if(!(r!=="asc"&&r!=="desc"))return{column:s,direction:r}},"c"),v=o(t=>{let e={};t.schema==="global"&&(e.schema="global");let s=i(t.table);s!==void 0&&(e.table=s);let r=i(t.shard);r!==void 0&&(e.shard=r);let d=i(t.search);d!==void 0&&(e.search=d);let a=i(t.order);a!==void 0&&c(a)!==void 0&&(e.order=a);let n=i(t.filters);return n!==void 0&&l(n).length>0&&(e.filters=n),e},"f"),g=o(t=>{let e=l(t.filters),s=c(t.order);return{filters:e.length>0?e:void 0,orderBy:s,search:typeof t.search=="string"&&t.search!==""?t.search:void 0,shard:typeof t.shard=="string"&&t.shard!==""?t.shard:void 0,table:typeof t.table=="string"&&t.table!==""?t.table:void 0,tier:t.schema==="global"?"global":"shard"}},"v"),b=o(t=>{let e=t.filters??[];return{filters:e.length>0?JSON.stringify(e):void 0,order:t.orderBy===void 0?void 0:`${t.orderBy.column}:${t.orderBy.direction}`,schema:t.tier==="global"?"global":void 0,search:t.search!==void 0&&t.search!==""?t.search:void 0,shard:t.shard!==void 0&&t.shard!==""?t.shard:void 0,table:t.table!==void 0&&t.table!==""?t.table:void 0}},"g");export{v as a,g as b,b as c};
@@ -1 +1 @@
1
- import{a as Ft,b as ie}from"./chunk-7AZZ7OJO.js";import{a as Mt}from"./chunk-VEFNSN7P.js";import{a as At}from"./chunk-SA6MBPBL.js";import{a as ue}from"./chunk-SKJZDOHG.js";import{a as zt,b as kt,c as Nt,d as tt,e as se,f as de}from"./chunk-Q5WXTZWX.js";import{a as xt,e as wt}from"./chunk-JKPK25JO.js";import{a as St}from"./chunk-UZYGEOWY.js";import{a as Rt}from"./chunk-YT7VXQVX.js";import{R as G}from"./chunk-7Z5QEFR4.js";import"./chunk-46IB4C4Q.js";import{c as P}from"./chunk-UY2Y5CXB.js";import"./chunk-ZFWEPGWG.js";import"./chunk-4FNHHFWR.js";import{f as re}from"./chunk-KJTLW5W2.js";import"./chunk-UREY4GLG.js";import{a as ce}from"./chunk-6OKDCV7J.js";import{d as Z,h as Ot,l as S,m as Dt,q as $t}from"./chunk-KLLYGWNF.js";import"./chunk-UDZY7MKE.js";import{a as i,e as Ct,f as qt,g as Bt,h as Ht}from"./chunk-UHHTEBC3.js";var Y=Ct(Bt(),1);var J=Ct(qt(),1);var a=Ct(Ht(),1);var Pt=i(t=>{let e=JSON.parse(t);if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("Expected a JSON object");return e},"Ft"),Kt=i(t=>{let e=Pt(t),r={};for(let[d,u]of Object.entries(e)){if(!Array.isArray(u)||u.some(l=>typeof l!="string"))throw new TypeError(`"${d}" must map to an array of action strings`);r[d]=u}return r},"Ut"),Jt=i(t=>t==null||t===""?"":typeof t=="string"?t:JSON.stringify(t,null,2),"Rt"),X=i(t=>{let e=(0,Y.c)(6),{children:r,htmlFor:d,label:u}=t,l;e[0]!==d||e[1]!==u?(l=(0,a.jsx)(Rt,{htmlFor:d,children:u}),e[0]=d,e[1]=u,e[2]=l):l=e[2];let o;return e[3]!==r||e[4]!==l?(o=(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[l,r]}),e[3]=r,e[4]=l,e[5]=o):o=e[5],o},"Q"),me=i(({busy:t,canSubmit:e,children:r,destructive:d=!1,error:u,onClose:l,onSubmit:o,submitLabel:n,testId:s,title:m})=>{let c=Z();return(0,a.jsxs)(Mt,{label:m,onClose:l,panelTestId:`${s}-panel`,testId:`${s}-overlay`,variant:"dialog",children:[(0,a.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:m}),r,u!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":`${s}-error`,role:"alert",children:u}),(0,a.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,a.jsx)(P,{"data-testid":`${s}-cancel`,onClick:l,size:"sm",type:"button",variant:"outline",children:c("Cancel")}),(0,a.jsx)(P,{"data-testid":`${s}-submit`,disabled:t||!e,onClick:o,size:"sm",type:"button",variant:d?"destructive":"default",children:t?c("Saving\u2026"):n})]})]})},"se"),Et=i(t=>{let e=(0,Y.c)(79),{mode:r,onClose:d,onDone:u,org:l}=t,o=re(),n=Z(),{busy:s,error:m,run:c}=ie(),v;e[0]!==l?(v=l?S(l.name):"",e[0]=l,e[1]=v):v=e[1];let[g,h]=(0,J.useState)(v),w;e[2]!==l?(w=l?S(l.slug):"",e[2]=l,e[3]=w):w=e[3];let[f,y]=(0,J.useState)(w),z;e[4]!==l?(z=l?S(l.logo):"",e[4]=l,e[5]=z):z=e[5];let[p,x]=(0,J.useState)(z),[b,k]=(0,J.useState)(""),I;e[6]!==r||e[7]!==l?.metadata?(I=r==="edit"?Jt(l?.metadata):"",e[6]=r,e[7]=l?.metadata,e[8]=I):I=e[8];let[C,N]=(0,J.useState)(I),D;e[9]!==o||e[10]!==p||e[11]!==C||e[12]!==r||e[13]!==g||e[14]!==d||e[15]!==u||e[16]!==l?.id||e[17]!==b||e[18]!==c||e[19]!==f?(D=i(()=>{c(async()=>{let L=C.trim()===""?void 0:Pt(C);r==="create"?await o.createAuthOrganization({logo:p.trim()===""?void 0:p.trim(),metadata:L,name:g.trim(),ownerId:b.trim()===""?void 0:b.trim(),slug:f.trim()===""?void 0:f.trim()}):await o.updateAuthOrganization({logo:p.trim()===""?void 0:p.trim(),metadata:L,name:g.trim()===""?void 0:g.trim(),organizationId:S(l?.id),slug:f.trim()===""?void 0:f.trim()}),u(),d()})},"O"),e[9]=o,e[10]=p,e[11]=C,e[12]=r,e[13]=g,e[14]=d,e[15]=u,e[16]=l?.id,e[17]=b,e[18]=c,e[19]=f,e[20]=D):D=e[20];let _=D,A;e[21]!==r||e[22]!==g?(A=g.trim()!==""||r==="edit",e[21]=r,e[22]=g,e[23]=A):A=e[23];let $;e[24]!==r||e[25]!==n?($=n(r==="create"?"Create":"Save"),e[24]=r,e[25]=n,e[26]=$):$=e[26];let R;e[27]!==r||e[28]!==n?(R=n(r==="create"?"New organization":"Edit organization"),e[27]=r,e[28]=n,e[29]=R):R=e[29];let U;e[30]!==n?(U=n("name"),e[30]=n,e[31]=U):U=e[31];let K;e[32]===Symbol.for("react.memo_cache_sentinel")?(K=i(L=>{h(L.target.value)},"q"),e[32]=K):K=e[32];let q;e[33]!==g?(q=(0,a.jsx)(G,{"data-testid":"org-form-name",id:"org-form-name",onChange:K,value:g}),e[33]=g,e[34]=q):q=e[34];let j;e[35]!==q||e[36]!==U?(j=(0,a.jsx)(X,{htmlFor:"org-form-name",label:U,children:q}),e[35]=q,e[36]=U,e[37]=j):j=e[37];let B;e[38]!==n?(B=n("Slug (optional \u2014 derived from name)"),e[38]=n,e[39]=B):B=e[39];let T;e[40]===Symbol.for("react.memo_cache_sentinel")?(T=i(L=>{y(L.target.value)},"K"),e[40]=T):T=e[40];let F;e[41]!==f?(F=(0,a.jsx)(G,{"data-testid":"org-form-slug",id:"org-form-slug",onChange:T,value:f}),e[41]=f,e[42]=F):F=e[42];let M;e[43]!==B||e[44]!==F?(M=(0,a.jsx)(X,{htmlFor:"org-form-slug",label:B,children:F}),e[43]=B,e[44]=F,e[45]=M):M=e[45];let H;e[46]!==n?(H=n("Logo URL (optional)"),e[46]=n,e[47]=H):H=e[47];let oe;e[48]===Symbol.for("react.memo_cache_sentinel")?(oe=i(L=>{x(L.target.value)},"re"),e[48]=oe):oe=e[48];let Q;e[49]!==p?(Q=(0,a.jsx)(G,{"data-testid":"org-form-logo",id:"org-form-logo",onChange:oe,value:p}),e[49]=p,e[50]=Q):Q=e[50];let V;e[51]!==H||e[52]!==Q?(V=(0,a.jsx)(X,{htmlFor:"org-form-logo",label:H,children:Q}),e[51]=H,e[52]=Q,e[53]=V):V=e[53];let W;e[54]!==r||e[55]!==b||e[56]!==n?(W=r==="create"&&(0,a.jsx)(X,{htmlFor:"org-form-owner",label:n("Owner user id (optional)"),children:(0,a.jsx)(G,{"data-testid":"org-form-owner",id:"org-form-owner",onChange:i(L=>{k(L.target.value)},"onChange"),value:b})}),e[54]=r,e[55]=b,e[56]=n,e[57]=W):W=e[57];let ee;e[58]!==n?(ee=n("Metadata (JSON, optional)"),e[58]=n,e[59]=ee):ee=e[59];let ae;e[60]===Symbol.for("react.memo_cache_sentinel")?(ae=i(L=>{N(L.target.value)},"oe"),e[60]=ae):ae=e[60];let te;e[61]!==C?(te=(0,a.jsx)(St,{"data-testid":"org-form-metadata",id:"org-form-metadata",onChange:ae,value:C}),e[61]=C,e[62]=te):te=e[62];let O;e[63]!==ee||e[64]!==te?(O=(0,a.jsx)(X,{htmlFor:"org-form-metadata",label:ee,children:te}),e[63]=ee,e[64]=te,e[65]=O):O=e[65];let ne;return e[66]!==s||e[67]!==m||e[68]!==d||e[69]!==_||e[70]!==j||e[71]!==M||e[72]!==V||e[73]!==W||e[74]!==O||e[75]!==A||e[76]!==$||e[77]!==R?(ne=(0,a.jsxs)(me,{busy:s,canSubmit:A,error:m,onClose:d,onSubmit:_,submitLabel:$,testId:"org-form",title:R,children:[j,M,V,W,O]}),e[66]=s,e[67]=m,e[68]=d,e[69]=_,e[70]=j,e[71]=M,e[72]=V,e[73]=W,e[74]=O,e[75]=A,e[76]=$,e[77]=R,e[78]=ne):ne=e[78],ne},"$t"),Tt=i(t=>{let e=(0,Y.c)(40),{onClose:r,onDone:d,organizationId:u}=t,l=re(),o=Z(),{busy:n,error:s,run:m}=ie(),[c,v]=(0,J.useState)(""),[g,h]=(0,J.useState)(""),w;e[0]!==l||e[1]!==r||e[2]!==d||e[3]!==u||e[4]!==g||e[5]!==m||e[6]!==c?(w=i(()=>{m(async()=>{await l.addAuthOrgMember({organizationId:u,role:g.trim()===""?void 0:g.trim(),userId:c.trim()}),d(),r()})},"C"),e[0]=l,e[1]=r,e[2]=d,e[3]=u,e[4]=g,e[5]=m,e[6]=c,e[7]=w):w=e[7];let f=w,y;e[8]!==c?(y=c.trim(),e[8]=c,e[9]=y):y=e[9];let z=y!=="",p;e[10]!==o?(p=o("Add member"),e[10]=o,e[11]=p):p=e[11];let x;e[12]!==o?(x=o("Add member"),e[12]=o,e[13]=x):x=e[13];let b;e[14]!==o?(b=o("User id"),e[14]=o,e[15]=b):b=e[15];let k;e[16]===Symbol.for("react.memo_cache_sentinel")?(k=i(R=>{v(R.target.value)},"x"),e[16]=k):k=e[16];let I;e[17]!==c?(I=(0,a.jsx)(G,{"data-testid":"org-add-member-user",id:"org-add-member-user",onChange:k,value:c}),e[17]=c,e[18]=I):I=e[18];let C;e[19]!==b||e[20]!==I?(C=(0,a.jsx)(X,{htmlFor:"org-add-member-user",label:b,children:I}),e[19]=b,e[20]=I,e[21]=C):C=e[21];let N;e[22]!==o?(N=o("Role (optional)"),e[22]=o,e[23]=N):N=e[23];let D;e[24]===Symbol.for("react.memo_cache_sentinel")?(D=i(R=>{h(R.target.value)},"O"),e[24]=D):D=e[24];let _;e[25]!==g?(_=(0,a.jsx)(G,{"data-testid":"org-add-member-role",id:"org-add-member-role",onChange:D,value:g}),e[25]=g,e[26]=_):_=e[26];let A;e[27]!==N||e[28]!==_?(A=(0,a.jsx)(X,{htmlFor:"org-add-member-role",label:N,children:_}),e[27]=N,e[28]=_,e[29]=A):A=e[29];let $;return e[30]!==n||e[31]!==s||e[32]!==r||e[33]!==f||e[34]!==A||e[35]!==z||e[36]!==p||e[37]!==x||e[38]!==C?($=(0,a.jsxs)(me,{busy:n,canSubmit:z,error:s,onClose:r,onSubmit:f,submitLabel:p,testId:"org-add-member",title:x,children:[C,A]}),e[30]=n,e[31]=s,e[32]=r,e[33]=f,e[34]=A,e[35]=z,e[36]=p,e[37]=x,e[38]=C,e[39]=$):$=e[39],$},"Bt"),Xt=i(t=>{let e=(0,Y.c)(40),{onClose:r,onDone:d,organizationId:u}=t,l=re(),o=Z(),{busy:n,error:s,run:m}=ie(),[c,v]=(0,J.useState)(""),[g,h]=(0,J.useState)(""),w;e[0]!==l||e[1]!==c||e[2]!==r||e[3]!==d||e[4]!==u||e[5]!==g||e[6]!==m?(w=i(()=>{m(async()=>{await l.inviteAuthOrgMember({email:c.trim(),organizationId:u,role:g.trim()===""?void 0:g.trim()}),d(),r()})},"C"),e[0]=l,e[1]=c,e[2]=r,e[3]=d,e[4]=u,e[5]=g,e[6]=m,e[7]=w):w=e[7];let f=w,y;e[8]!==c?(y=c.trim(),e[8]=c,e[9]=y):y=e[9];let z=y!=="",p;e[10]!==o?(p=o("Send invitation"),e[10]=o,e[11]=p):p=e[11];let x;e[12]!==o?(x=o("Invite member"),e[12]=o,e[13]=x):x=e[13];let b;e[14]!==o?(b=o("email"),e[14]=o,e[15]=b):b=e[15];let k;e[16]===Symbol.for("react.memo_cache_sentinel")?(k=i(R=>{v(R.target.value)},"x"),e[16]=k):k=e[16];let I;e[17]!==c?(I=(0,a.jsx)(G,{"data-testid":"org-invite-member-email",id:"org-invite-member-email",onChange:k,type:"email",value:c}),e[17]=c,e[18]=I):I=e[18];let C;e[19]!==b||e[20]!==I?(C=(0,a.jsx)(X,{htmlFor:"org-invite-member-email",label:b,children:I}),e[19]=b,e[20]=I,e[21]=C):C=e[21];let N;e[22]!==o?(N=o("Role (optional)"),e[22]=o,e[23]=N):N=e[23];let D;e[24]===Symbol.for("react.memo_cache_sentinel")?(D=i(R=>{h(R.target.value)},"O"),e[24]=D):D=e[24];let _;e[25]!==g?(_=(0,a.jsx)(G,{"data-testid":"org-invite-member-role",id:"org-invite-member-role",onChange:D,value:g}),e[25]=g,e[26]=_):_=e[26];let A;e[27]!==N||e[28]!==_?(A=(0,a.jsx)(X,{htmlFor:"org-invite-member-role",label:N,children:_}),e[27]=N,e[28]=_,e[29]=A):A=e[29];let $;return e[30]!==n||e[31]!==s||e[32]!==r||e[33]!==f||e[34]!==A||e[35]!==z||e[36]!==p||e[37]!==x||e[38]!==C?($=(0,a.jsxs)(me,{busy:n,canSubmit:z,error:s,onClose:r,onSubmit:f,submitLabel:p,testId:"org-invite-member",title:x,children:[C,A]}),e[30]=n,e[31]=s,e[32]=r,e[33]=f,e[34]=A,e[35]=z,e[36]=p,e[37]=x,e[38]=C,e[39]=$):$=e[39],$},"Ht"),Yt=i(t=>{let e=(0,Y.c)(32),{member:r,onClose:d,onDone:u}=t,l=re(),o=Z(),{busy:n,error:s,run:m}=ie(),c;e[0]!==r.role?(c=S(r.role),e[0]=r.role,e[1]=c):c=e[1];let[v,g]=(0,J.useState)(c),h;e[2]!==l||e[3]!==r.id||e[4]!==d||e[5]!==u||e[6]!==v||e[7]!==m?(h=i(()=>{m(async()=>{await l.setAuthOrgMemberRole({memberId:S(r.id),role:v.trim()}),u(),d()})},"g"),e[2]=l,e[3]=r.id,e[4]=d,e[5]=u,e[6]=v,e[7]=m,e[8]=h):h=e[8];let w=h,f;e[9]!==v?(f=v.trim(),e[9]=v,e[10]=f):f=e[10];let y=f!=="",z;e[11]!==o?(z=o("Save"),e[11]=o,e[12]=z):z=e[12];let p;e[13]!==o?(p=o("Change member role"),e[13]=o,e[14]=p):p=e[14];let x;e[15]!==o?(x=o("Role"),e[15]=o,e[16]=x):x=e[16];let b;e[17]===Symbol.for("react.memo_cache_sentinel")?(b=i(N=>{g(N.target.value)},"h"),e[17]=b):b=e[17];let k;e[18]!==v?(k=(0,a.jsx)(G,{"data-testid":"org-member-role-value",id:"org-member-role-value",onChange:b,value:v}),e[18]=v,e[19]=k):k=e[19];let I;e[20]!==x||e[21]!==k?(I=(0,a.jsx)(X,{htmlFor:"org-member-role-value",label:x,children:k}),e[20]=x,e[21]=k,e[22]=I):I=e[22];let C;return e[23]!==n||e[24]!==s||e[25]!==d||e[26]!==w||e[27]!==I||e[28]!==y||e[29]!==z||e[30]!==p?(C=(0,a.jsx)(me,{busy:n,canSubmit:y,error:s,onClose:d,onSubmit:w,submitLabel:z,testId:"org-member-role",title:p,children:I}),e[23]=n,e[24]=s,e[25]=d,e[26]=w,e[27]=I,e[28]=y,e[29]=z,e[30]=p,e[31]=C):C=e[31],C},"qt"),Lt=i(t=>{let e=(0,Y.c)(36),{mode:r,onClose:d,onDone:u,organizationId:l,team:o}=t,n=re(),s=Z(),{busy:m,error:c,run:v}=ie(),g;e[0]!==o?(g=o?S(o.name):"",e[0]=o,e[1]=g):g=e[1];let[h,w]=(0,J.useState)(g),f;e[2]!==n||e[3]!==r||e[4]!==h||e[5]!==d||e[6]!==u||e[7]!==l||e[8]!==v||e[9]!==o?.id?(f=i(()=>{v(async()=>{await(r==="create"?n.createAuthOrgTeam({name:h.trim(),organizationId:l}):n.updateAuthOrgTeam({name:h.trim(),teamId:S(o?.id)})),u(),d()})},"b"),e[2]=n,e[3]=r,e[4]=h,e[5]=d,e[6]=u,e[7]=l,e[8]=v,e[9]=o?.id,e[10]=f):f=e[10];let y=f,z;e[11]!==h?(z=h.trim(),e[11]=h,e[12]=z):z=e[12];let p=z!=="",x;e[13]!==r||e[14]!==s?(x=s(r==="create"?"Create":"Save"),e[13]=r,e[14]=s,e[15]=x):x=e[15];let b;e[16]!==r||e[17]!==s?(b=s(r==="create"?"New team":"Rename team"),e[16]=r,e[17]=s,e[18]=b):b=e[18];let k;e[19]!==s?(k=s("name"),e[19]=s,e[20]=k):k=e[20];let I;e[21]===Symbol.for("react.memo_cache_sentinel")?(I=i(_=>{w(_.target.value)},"y"),e[21]=I):I=e[21];let C;e[22]!==h?(C=(0,a.jsx)(G,{"data-testid":"org-team-form-name",id:"org-team-form-name",onChange:I,value:h}),e[22]=h,e[23]=C):C=e[23];let N;e[24]!==k||e[25]!==C?(N=(0,a.jsx)(X,{htmlFor:"org-team-form-name",label:k,children:C}),e[24]=k,e[25]=C,e[26]=N):N=e[26];let D;return e[27]!==m||e[28]!==c||e[29]!==d||e[30]!==y||e[31]!==N||e[32]!==p||e[33]!==x||e[34]!==b?(D=(0,a.jsx)(me,{busy:m,canSubmit:p,error:c,onClose:d,onSubmit:y,submitLabel:x,testId:"org-team-form",title:b,children:N}),e[27]=m,e[28]=c,e[29]=d,e[30]=y,e[31]=N,e[32]=p,e[33]=x,e[34]=b,e[35]=D):D=e[35],D},"xt"),Zt=i(t=>{let e=(0,Y.c)(30),{onClose:r,onDone:d,teamId:u}=t,l=re(),o=Z(),{busy:n,error:s,run:m}=ie(),[c,v]=(0,J.useState)(""),g;e[0]!==l||e[1]!==r||e[2]!==d||e[3]!==m||e[4]!==u||e[5]!==c?(g=i(()=>{m(async()=>{await l.addAuthOrgTeamMember({teamId:u,userId:c.trim()}),d(),r()})},"u"),e[0]=l,e[1]=r,e[2]=d,e[3]=m,e[4]=u,e[5]=c,e[6]=g):g=e[6];let h=g,w;e[7]!==c?(w=c.trim(),e[7]=c,e[8]=w):w=e[8];let f=w!=="",y;e[9]!==o?(y=o("Add member"),e[9]=o,e[10]=y):y=e[10];let z;e[11]!==o?(z=o("Add team member"),e[11]=o,e[12]=z):z=e[12];let p;e[13]!==o?(p=o("User id"),e[13]=o,e[14]=p):p=e[14];let x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=i(C=>{v(C.target.value)},"w"),e[15]=x):x=e[15];let b;e[16]!==c?(b=(0,a.jsx)(G,{"data-testid":"org-team-add-member-user",id:"org-team-add-member-user",onChange:x,value:c}),e[16]=c,e[17]=b):b=e[17];let k;e[18]!==p||e[19]!==b?(k=(0,a.jsx)(X,{htmlFor:"org-team-add-member-user",label:p,children:b}),e[18]=p,e[19]=b,e[20]=k):k=e[20];let I;return e[21]!==n||e[22]!==s||e[23]!==r||e[24]!==h||e[25]!==f||e[26]!==y||e[27]!==z||e[28]!==k?(I=(0,a.jsx)(me,{busy:n,canSubmit:f,error:s,onClose:r,onSubmit:h,submitLabel:y,testId:"org-team-add-member",title:z,children:k}),e[21]=n,e[22]=s,e[23]=r,e[24]=h,e[25]=f,e[26]=y,e[27]=z,e[28]=k,e[29]=I):I=e[29],I},"Kt"),jt=i(t=>{let e=(0,Y.c)(47),{mode:r,onClose:d,onDone:u,organizationId:l,role:o}=t,n=re(),s=Z(),{busy:m,error:c,run:v}=ie(),g;e[0]!==o?(g=o?S(o.role):"",e[0]=o,e[1]=g):g=e[1];let[h,w]=(0,J.useState)(g),f;e[2]!==r||e[3]!==o?.permission?(f=r==="edit"?Jt(o?.permission):"",e[2]=r,e[3]=o?.permission,e[4]=f):f=e[4];let[y,z]=(0,J.useState)(f),p;e[5]!==n||e[6]!==r||e[7]!==h||e[8]!==d||e[9]!==u||e[10]!==l||e[11]!==y||e[12]!==o?.id||e[13]!==v?(p=i(()=>{v(async()=>{let R=Kt(y);await(r==="create"?n.createAuthOrgRole({organizationId:l,permission:R,role:h.trim()}):n.updateAuthOrgRole({permission:R,roleId:S(o?.id)})),u(),d()})},"f"),e[5]=n,e[6]=r,e[7]=h,e[8]=d,e[9]=u,e[10]=l,e[11]=y,e[12]=o?.id,e[13]=v,e[14]=p):p=e[14];let x=p,b;e[15]!==r||e[16]!==h||e[17]!==y?(b=y.trim()!==""&&(r==="edit"||h.trim()!==""),e[15]=r,e[16]=h,e[17]=y,e[18]=b):b=e[18];let k;e[19]!==r||e[20]!==s?(k=s(r==="create"?"Create":"Save"),e[19]=r,e[20]=s,e[21]=k):k=e[21];let I;e[22]!==r||e[23]!==s?(I=s(r==="create"?"New role":"Edit role"),e[22]=r,e[23]=s,e[24]=I):I=e[24];let C;e[25]!==r||e[26]!==h||e[27]!==s?(C=r==="create"&&(0,a.jsx)(X,{htmlFor:"org-role-form-name",label:s("Role name"),children:(0,a.jsx)(G,{"data-testid":"org-role-form-name",id:"org-role-form-name",onChange:i(R=>{w(R.target.value)},"onChange"),value:h})}),e[25]=r,e[26]=h,e[27]=s,e[28]=C):C=e[28];let N;e[29]!==s?(N=s('Permission (JSON, e.g. {"project":["create","update"]})'),e[29]=s,e[30]=N):N=e[30];let D;e[31]===Symbol.for("react.memo_cache_sentinel")?(D=i(R=>{z(R.target.value)},"O"),e[31]=D):D=e[31];let _;e[32]!==y?(_=(0,a.jsx)(St,{"data-testid":"org-role-form-permission",id:"org-role-form-permission",onChange:D,value:y}),e[32]=y,e[33]=_):_=e[33];let A;e[34]!==_||e[35]!==N?(A=(0,a.jsx)(X,{htmlFor:"org-role-form-permission",label:N,children:_}),e[34]=_,e[35]=N,e[36]=A):A=e[36];let $;return e[37]!==m||e[38]!==c||e[39]!==d||e[40]!==x||e[41]!==A||e[42]!==b||e[43]!==k||e[44]!==I||e[45]!==C?($=(0,a.jsxs)(me,{busy:m,canSubmit:b,error:c,onClose:d,onSubmit:x,submitLabel:k,testId:"org-role-form",title:I,children:[C,A]}),e[37]=m,e[38]=c,e[39]=d,e[40]=x,e[41]=A,e[42]=b,e[43]=k,e[44]=I,e[45]=C,e[46]=$):$=e[46],$},"zt"),Ut=i(t=>{let e=(0,Y.c)(18),{action:r,message:d,onClose:u,onDone:l,testId:o,title:n}=t,s=Z(),{busy:m,error:c,run:v}=ie(),g;e[0]!==r||e[1]!==u||e[2]!==l||e[3]!==v?(g=i(()=>{v(async()=>{await r(),l(),u()})},"u"),e[0]=r,e[1]=u,e[2]=l,e[3]=v,e[4]=g):g=e[4];let h=g,w;e[5]!==s?(w=s("Delete"),e[5]=s,e[6]=w):w=e[6];let f;e[7]!==d?(f=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:d}),e[7]=d,e[8]=f):f=e[8];let y;return e[9]!==m||e[10]!==c||e[11]!==u||e[12]!==h||e[13]!==w||e[14]!==f||e[15]!==o||e[16]!==n?(y=(0,a.jsx)(me,{busy:m,canSubmit:!0,destructive:!0,error:c,onClose:u,onSubmit:h,submitLabel:w,testId:o,title:n,children:f}),e[9]=m,e[10]=c,e[11]=u,e[12]=h,e[13]=w,e[14]=f,e[15]=o,e[16]=n,e[17]=y):y=e[17],y},"Tt"),rt=i(t=>{let e=(0,Y.c)(13),{action:r,children:d,heading:u,testId:l}=t,o;e[0]!==u?(o=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:u}),e[0]=u,e[1]=o):o=e[1];let n;e[2]!==r?(n=r!==void 0&&(0,a.jsx)("div",{className:"flex items-center gap-2",children:r}),e[2]=r,e[3]=n):n=e[3];let s;e[4]!==o||e[5]!==n?(s=(0,a.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[o,n]}),e[4]=o,e[5]=n,e[6]=s):s=e[6];let m;e[7]!==d?(m=(0,a.jsx)(wt,{className:"px-0",children:d}),e[7]=d,e[8]=m):m=e[8];let c;return e[9]!==s||e[10]!==m||e[11]!==l?(c=(0,a.jsxs)(xt,{className:"overflow-hidden py-0","data-testid":l,children:[s,m]}),e[9]=s,e[10]=m,e[11]=l,e[12]=c):c=e[12],c},"tt"),ot=i(t=>{let e=(0,Y.c)(23),{columns:r,rowActions:d,rowPrefix:u,rows:l}=t,o=Z(),n;e[0]!==r?(n=r.map(Qt),e[0]=r,e[1]=n):n=e[1];let s;e[2]!==o?(s=o("Actions"),e[2]=o,e[3]=s):s=e[3];let m;e[4]!==s?(m=(0,a.jsx)(se,{"aria-label":s}),e[4]=s,e[5]=m):m=e[5];let c;e[6]!==n||e[7]!==m?(c=(0,a.jsx)(kt,{children:(0,a.jsxs)(tt,{children:[n,m]})}),e[6]=n,e[7]=m,e[8]=c):c=e[8];let v;if(e[9]!==r||e[10]!==d||e[11]!==u||e[12]!==l){let w;e[14]!==r||e[15]!==d||e[16]!==u?(w=i(f=>{let y=S(f.id);return(0,a.jsxs)(tt,{"data-testid":`${u}-${y}`,children:[r.map(z=>(0,a.jsx)(de,{className:z.className,children:z.render(f)},z.head)),(0,a.jsx)(de,{children:(0,a.jsx)("div",{className:"flex justify-end gap-1",children:d(f)})})]},y)},"C"),e[14]=r,e[15]=d,e[16]=u,e[17]=w):w=e[17],v=l.map(w),e[9]=r,e[10]=d,e[11]=u,e[12]=l,e[13]=v}else v=e[13];let g;e[18]!==v?(g=(0,a.jsx)(Nt,{children:v}),e[18]=v,e[19]=g):g=e[19];let h;return e[20]!==c||e[21]!==g?(h=(0,a.jsxs)(zt,{children:[c,g]}),e[20]=c,e[21]=g,e[22]=h):h=e[22],h},"rt"),Gt=i(t=>{let e=(0,Y.c)(219),{organizationId:r,rolesEnabled:d,teamsEnabled:u}=t,l=re(),o=Z(),[n,s]=(0,J.useState)(null),[m,c]=(0,J.useState)(null),[v,g]=(0,J.useState)(!1),[h,w]=(0,J.useState)(null),f;e[0]!==r?(f=["lunora-auth-org-members",r],e[0]=r,e[1]=f):f=e[1];let y;e[2]!==l||e[3]!==r?(y=i(()=>l.listAuthOrgMembers({limit:200,organizationId:r}),"v"),e[2]=l,e[3]=r,e[4]=y):y=e[4];let z=ue(f,y),p;e[5]!==r?(p=["lunora-auth-org-invitations",r],e[5]=r,e[6]=p):p=e[6];let x;e[7]!==l||e[8]!==r?(x=i(()=>l.listAuthOrgInvitations({limit:200,organizationId:r}),"w"),e[7]=l,e[8]=r,e[9]=x):x=e[9];let b=ue(p,x),k;e[10]!==r?(k=["lunora-auth-org-teams",r],e[10]=r,e[11]=k):k=e[11];let I;e[12]!==l||e[13]!==r?(I=i(()=>l.listAuthOrgTeams({limit:200,organizationId:r}),"y"),e[12]=l,e[13]=r,e[14]=I):I=e[14];let C;e[15]!==u?(C={enabled:u},e[15]=u,e[16]=C):C=e[16];let N=ue(k,I,C),D;e[17]!==r?(D=["lunora-auth-org-roles",r],e[17]=r,e[18]=D):D=e[18];let _;e[19]!==l||e[20]!==r?(_=i(()=>l.listAuthOrgRoles({limit:200,organizationId:r}),"N"),e[19]=l,e[20]=r,e[21]=_):_=e[21];let A;e[22]!==d?(A={enabled:d},e[22]=d,e[23]=A):A=e[23];let $=ue(D,_,A),R;e[24]!==m?(R=["lunora-auth-org-team-members",m],e[24]=m,e[25]=R):R=e[25];let U;e[26]!==l||e[27]!==m?(U=i(()=>l.listAuthOrgTeamMembers({limit:200,teamId:m??""}),"J"),e[26]=l,e[27]=m,e[28]=U):U=e[28];let K=m!==null,q;e[29]!==K?(q={enabled:K},e[29]=K,e[30]=q):q=e[30];let j=ue(R,U,q),B;e[31]!==z.data?.rows?(B=z.data?.rows??[],e[31]=z.data?.rows,e[32]=B):B=e[32];let T=B,F;e[33]!==b.data?.rows?(F=b.data?.rows??[],e[33]=b.data?.rows,e[34]=F):F=e[34];let M=F,H;e[35]!==N.data?.rows?(H=N.data?.rows??[],e[35]=N.data?.rows,e[36]=H):H=e[36];let oe=H,Q;e[37]!==$.data?.rows?(Q=$.data?.rows??[],e[37]=$.data?.rows,e[38]=Q):Q=e[38];let V=Q,W;e[39]!==m||e[40]!==j?(W=m===null?[]:j.data?.rows??[],e[39]=m,e[40]=j,e[41]=W):W=e[41];let ee=W,ae=z.error??b.error??N.error??$.error??j.error,te;e[42]!==b||e[43]!==z||e[44]!==d||e[45]!==$||e[46]!==m||e[47]!==j||e[48]!==u||e[49]!==N?(te=i(()=>{z.refetch(),b.refetch(),u&&N.refetch(),d&&$.refetch(),m!==null&&j.refetch()},"te"),e[42]=b,e[43]=z,e[44]=d,e[45]=$,e[46]=m,e[47]=j,e[48]=u,e[49]=N,e[50]=te):te=e[50];let O=te;At(O,!0);let ne;e[51]===Symbol.for("react.memo_cache_sentinel")?(ne=i(()=>{s(null)},"ne"),e[51]=ne):ne=e[51];let L=ne,at;e[52]!==O?(at=i(E=>{Dt((async()=>{g(!0),w(null);try{await E(),O(),g(!1)}catch(ht){w(Ot(ht)),g(!1)}})())},"ot"),e[52]=O,e[53]=at):at=e[53];let le=at,nt;e[54]!==l||e[55]!==o?(nt=i(E=>{let ht=S(E.id);s({action:i(async()=>{await l.removeAuthOrgTeam({teamId:ht}),c(_t=>_t===ht?null:_t)},"action"),kind:"confirm",message:o("Delete this team and its memberships? This cannot be undone."),testId:"org-team-delete",title:o("Delete team")})},"nt"),e[54]=l,e[55]=o,e[56]=nt):nt=e[56];let bt=nt,ge;e[57]!==o?(ge=o("userId"),e[57]=o,e[58]=ge):ge=e[58];let he;e[59]!==ge?(he={head:ge,render:Vt},e[59]=ge,e[60]=he):he=e[60];let be;e[61]!==o?(be=o("role"),e[61]=o,e[62]=be):be=e[62];let fe;e[63]!==be?(fe={head:be,render:Wt},e[63]=be,e[64]=fe):fe=e[64];let lt;e[65]!==he||e[66]!==fe?(lt=[he,fe],e[65]=he,e[66]=fe,e[67]=lt):lt=e[67];let ft=lt,pe;e[68]!==o?(pe=o("email"),e[68]=o,e[69]=pe):pe=e[69];let ve;e[70]!==pe?(ve={head:pe,render:er},e[70]=pe,e[71]=ve):ve=e[71];let ye;e[72]!==o?(ye=o("role"),e[72]=o,e[73]=ye):ye=e[73];let Ie;e[74]!==ye?(Ie={head:ye,render:tr},e[74]=ye,e[75]=Ie):Ie=e[75];let Ce;e[76]!==o?(Ce=o("status"),e[76]=o,e[77]=Ce):Ce=e[77];let xe;e[78]!==Ce?(xe={head:Ce,render:rr},e[78]=Ce,e[79]=xe):xe=e[79];let it;e[80]!==ve||e[81]!==Ie||e[82]!==xe?(it=[ve,Ie,xe],e[80]=ve,e[81]=Ie,e[82]=xe,e[83]=it):it=e[83];let pt=it,we;e[84]!==o?(we=o("id"),e[84]=o,e[85]=we):we=e[85];let ze;e[86]!==we?(ze={className:"font-mono text-xs",head:we,render:or},e[86]=we,e[87]=ze):ze=e[87];let ke;e[88]!==o?(ke=o("name"),e[88]=o,e[89]=ke):ke=e[89];let Ne;e[90]!==ke?(Ne={head:ke,render:ar},e[90]=ke,e[91]=Ne):Ne=e[91];let st;e[92]!==ze||e[93]!==Ne?(st=[ze,Ne],e[92]=ze,e[93]=Ne,e[94]=st):st=e[94];let vt=st,Se;e[95]!==o?(Se=o("userId"),e[95]=o,e[96]=Se):Se=e[96];let dt;e[97]!==Se?(dt=[{head:Se,render:nr}],e[97]=Se,e[98]=dt):dt=e[98];let yt=dt,Ae;e[99]!==o?(Ae=o("role"),e[99]=o,e[100]=Ae):Ae=e[100];let _e;e[101]!==Ae?(_e={head:Ae,render:lr},e[101]=Ae,e[102]=_e):_e=e[102];let Oe;e[103]!==o?(Oe=o("Permission"),e[103]=o,e[104]=Oe):Oe=e[104];let De;e[105]!==Oe?(De={className:"font-mono text-xs whitespace-pre-wrap",head:Oe,render:ir},e[105]=Oe,e[106]=De):De=e[106];let mt;e[107]!==_e||e[108]!==De?(mt=[_e,De],e[107]=_e,e[108]=De,e[109]=mt):mt=e[109];let It=mt,$e;e[110]!==ae?($e=ae!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-detail-error",role:"alert",children:ae}),e[110]=ae,e[111]=$e):$e=e[111];let Re;e[112]!==h?(Re=h!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-action-error",role:"alert",children:h}),e[112]=h,e[113]=Re):Re=e[113];let ct;e[114]===Symbol.for("react.memo_cache_sentinel")?(ct=i(()=>{s({kind:"add-member"})},"dt"),e[114]=ct):ct=e[114];let Fe;e[115]!==o?(Fe=o("Add member"),e[115]=o,e[116]=Fe):Fe=e[116];let Me;e[117]!==Fe?(Me=(0,a.jsx)(P,{"data-testid":"org-open-add-member",onClick:ct,size:"xs",type:"button",variant:"outline",children:Fe}),e[117]=Fe,e[118]=Me):Me=e[118];let ut;e[119]===Symbol.for("react.memo_cache_sentinel")?(ut=i(()=>{s({kind:"invite-member"})},"ct"),e[119]=ut):ut=e[119];let Ee;e[120]!==o?(Ee=o("Invite member"),e[120]=o,e[121]=Ee):Ee=e[121];let Le;e[122]!==Ee?(Le=(0,a.jsx)(P,{"data-testid":"org-open-invite-member",onClick:ut,size:"xs",type:"button",variant:"outline",children:Ee}),e[122]=Ee,e[123]=Le):Le=e[123];let je;e[124]!==Me||e[125]!==Le?(je=(0,a.jsxs)(a.Fragment,{children:[Me,Le]}),e[124]=Me,e[125]=Le,e[126]=je):je=e[126];let Pe;e[127]!==o?(Pe=o("Members"),e[127]=o,e[128]=Pe):Pe=e[128];let Je;e[129]!==v||e[130]!==l||e[131]!==ft||e[132]!==T||e[133]!==le||e[134]!==o?(Je=T.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ce,{testId:"org-members-empty",title:o("No members.")})}):(0,a.jsx)(ot,{columns:ft,rowActions:i(E=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(P,{"data-testid":`org-member-role-${S(E.id)}`,onClick:i(()=>{s({kind:"member-role",member:E})},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Change role")}),(0,a.jsx)(P,{"data-testid":`org-remove-member-${S(E.id)}`,disabled:v,onClick:i(()=>{le(()=>l.removeAuthOrgMember({memberId:S(E.id)}))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Remove")})]}),"rowActions"),rowPrefix:"org-member",rows:T}),e[129]=v,e[130]=l,e[131]=ft,e[132]=T,e[133]=le,e[134]=o,e[135]=Je):Je=e[135];let Ue;e[136]!==je||e[137]!==Pe||e[138]!==Je?(Ue=(0,a.jsx)(rt,{action:je,heading:Pe,testId:"org-members",children:Je}),e[136]=je,e[137]=Pe,e[138]=Je,e[139]=Ue):Ue=e[139];let qe;e[140]!==v||e[141]!==l||e[142]!==pt||e[143]!==M||e[144]!==le||e[145]!==o?(qe=M.length>0&&(0,a.jsx)(rt,{heading:o("Invitations"),testId:"org-invitations",children:(0,a.jsx)(ot,{columns:pt,rowActions:i(E=>(0,a.jsx)(P,{"data-testid":`org-cancel-invitation-${S(E.id)}`,disabled:v,onClick:i(()=>{le(()=>l.cancelAuthOrgInvitation({invitationId:S(E.id)}))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Cancel")}),"rowActions"),rowPrefix:"org-invitation",rows:M})}),e[140]=v,e[141]=l,e[142]=pt,e[143]=M,e[144]=le,e[145]=o,e[146]=qe):qe=e[146];let Be;e[147]!==bt||e[148]!==m||e[149]!==o||e[150]!==vt||e[151]!==oe||e[152]!==u?(Be=u&&(0,a.jsx)(rt,{action:(0,a.jsx)(P,{"data-testid":"org-open-create-team",onClick:i(()=>{s({kind:"team-create"})},"onClick"),size:"xs",type:"button",variant:"outline",children:o("New team")}),heading:o("Teams"),testId:"org-teams",children:oe.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ce,{testId:"org-teams-empty",title:o("No teams.")})}):(0,a.jsx)(ot,{columns:vt,rowActions:i(E=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(P,{"aria-pressed":m===S(E.id),"data-testid":`org-team-select-${S(E.id)}`,onClick:i(()=>{c(S(E.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Members")}),(0,a.jsx)(P,{"data-testid":`org-team-rename-${S(E.id)}`,onClick:i(()=>{s({kind:"team-rename",team:E})},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Rename")}),(0,a.jsx)(P,{"data-testid":`org-team-delete-${S(E.id)}`,onClick:i(()=>{bt(E)},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Delete")})]}),"rowActions"),rowPrefix:"org-team",rows:oe})}),e[147]=bt,e[148]=m,e[149]=o,e[150]=vt,e[151]=oe,e[152]=u,e[153]=Be):Be=e[153];let He;e[154]!==v||e[155]!==l||e[156]!==le||e[157]!==m||e[158]!==o||e[159]!==yt||e[160]!==ee||e[161]!==u?(He=u&&m!==null&&(0,a.jsx)(rt,{action:(0,a.jsx)(P,{"data-testid":"org-open-add-team-member",onClick:i(()=>{s({kind:"team-add-member",teamId:m})},"onClick"),size:"xs",type:"button",variant:"outline",children:o("Add member")}),heading:o("Team members"),testId:"org-team-members",children:ee.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ce,{testId:"org-team-members-empty",title:o("No team members.")})}):(0,a.jsx)(ot,{columns:yt,rowActions:i(E=>(0,a.jsx)(P,{"data-testid":`org-team-remove-member-${S(E.id)}`,disabled:v,onClick:i(()=>{le(()=>l.removeAuthOrgTeamMember({teamMemberId:S(E.id)}))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Remove")}),"rowActions"),rowPrefix:"org-team-member",rows:ee})}),e[154]=v,e[155]=l,e[156]=le,e[157]=m,e[158]=o,e[159]=yt,e[160]=ee,e[161]=u,e[162]=He):He=e[162];let Ke;e[163]!==l||e[164]!==It||e[165]!==V||e[166]!==d||e[167]!==o?(Ke=d&&(0,a.jsx)(rt,{action:(0,a.jsx)(P,{"data-testid":"org-open-create-role",onClick:i(()=>{s({kind:"role-create"})},"onClick"),size:"xs",type:"button",variant:"outline",children:o("New role")}),heading:o("Roles"),testId:"org-roles",children:V.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ce,{testId:"org-roles-empty",title:o("No custom roles.")})}):(0,a.jsx)(ot,{columns:It,rowActions:i(E=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(P,{"data-testid":`org-role-edit-${S(E.id)}`,onClick:i(()=>{s({kind:"role-edit",role:E})},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Edit")}),(0,a.jsx)(P,{"data-testid":`org-role-delete-${S(E.id)}`,onClick:i(()=>{s({action:i(()=>l.deleteAuthOrgRole({roleId:S(E.id)}),"action"),kind:"confirm",message:o("Delete this custom role? Members keeping it will lose its grants."),testId:"org-role-delete",title:o("Delete role")})},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Delete")})]}),"rowActions"),rowPrefix:"org-role",rows:V})}),e[163]=l,e[164]=It,e[165]=V,e[166]=d,e[167]=o,e[168]=Ke):Ke=e[168];let Te;e[169]!==n?.kind||e[170]!==r||e[171]!==O?(Te=n?.kind==="add-member"&&(0,a.jsx)(Tt,{onClose:L,onDone:O,organizationId:r}),e[169]=n?.kind,e[170]=r,e[171]=O,e[172]=Te):Te=e[172];let Xe;e[173]!==n?.kind||e[174]!==r||e[175]!==O?(Xe=n?.kind==="invite-member"&&(0,a.jsx)(Xt,{onClose:L,onDone:O,organizationId:r}),e[173]=n?.kind,e[174]=r,e[175]=O,e[176]=Xe):Xe=e[176];let Ye;e[177]!==n||e[178]!==O?(Ye=n?.kind==="member-role"&&(0,a.jsx)(Yt,{member:n.member,onClose:L,onDone:O}),e[177]=n,e[178]=O,e[179]=Ye):Ye=e[179];let Ze;e[180]!==n?.kind||e[181]!==r||e[182]!==O?(Ze=n?.kind==="team-create"&&(0,a.jsx)(Lt,{mode:"create",onClose:L,onDone:O,organizationId:r}),e[180]=n?.kind,e[181]=r,e[182]=O,e[183]=Ze):Ze=e[183];let Ge;e[184]!==n||e[185]!==r||e[186]!==O?(Ge=n?.kind==="team-rename"&&(0,a.jsx)(Lt,{mode:"edit",onClose:L,onDone:O,organizationId:r,team:n.team}),e[184]=n,e[185]=r,e[186]=O,e[187]=Ge):Ge=e[187];let Qe;e[188]!==n||e[189]!==O?(Qe=n?.kind==="team-add-member"&&(0,a.jsx)(Zt,{onClose:L,onDone:O,teamId:n.teamId}),e[188]=n,e[189]=O,e[190]=Qe):Qe=e[190];let Ve;e[191]!==n?.kind||e[192]!==r||e[193]!==O?(Ve=n?.kind==="role-create"&&(0,a.jsx)(jt,{mode:"create",onClose:L,onDone:O,organizationId:r}),e[191]=n?.kind,e[192]=r,e[193]=O,e[194]=Ve):Ve=e[194];let We;e[195]!==n||e[196]!==r||e[197]!==O?(We=n?.kind==="role-edit"&&(0,a.jsx)(jt,{mode:"edit",onClose:L,onDone:O,organizationId:r,role:n.role}),e[195]=n,e[196]=r,e[197]=O,e[198]=We):We=e[198];let et;e[199]!==n||e[200]!==O?(et=n?.kind==="confirm"&&(0,a.jsx)(Ut,{action:n.action,message:n.message,onClose:L,onDone:O,testId:n.testId,title:n.title}),e[199]=n,e[200]=O,e[201]=et):et=e[201];let gt;return e[202]!==$e||e[203]!==Re||e[204]!==Ue||e[205]!==qe||e[206]!==Be||e[207]!==He||e[208]!==Ke||e[209]!==Te||e[210]!==Xe||e[211]!==Ye||e[212]!==Ze||e[213]!==Ge||e[214]!==Qe||e[215]!==Ve||e[216]!==We||e[217]!==et?(gt=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"org-detail",children:[$e,Re,Ue,qe,Be,He,Ke,Te,Xe,Ye,Ze,Ge,Qe,Ve,We,et]}),e[202]=$e,e[203]=Re,e[204]=Ue,e[205]=qe,e[206]=Be,e[207]=He,e[208]=Ke,e[209]=Te,e[210]=Xe,e[211]=Ye,e[212]=Ze,e[213]=Ge,e[214]=Qe,e[215]=Ve,e[216]=We,e[217]=et,e[218]=gt):gt=e[218],gt},"Qt");function Qt(t){return(0,a.jsx)(se,{children:t.head},t.head)}i(Qt,"Gt");function Vt(t){return(0,a.jsx)("span",{className:"font-mono text-xs",children:S(t.userId)})}i(Vt,"Vt");function Wt(t){return S(t.role)}i(Wt,"Wt");function er(t){return S(t.email)}i(er,"Xt");function tr(t){return S(t.role)}i(tr,"Yt");function rr(t){return S(t.status)}i(rr,"Zt");function or(t){return S(t.id)}i(or,"er");function ar(t){return S(t.name)}i(ar,"tr");function nr(t){return(0,a.jsx)("span",{className:"font-mono text-xs",children:S(t.userId)})}i(nr,"rr");function lr(t){return S(t.role)}i(lr,"or");function ir(t){return S(t.permission)}i(ir,"nr");var xr=i(()=>{let t=(0,Y.c)(62),e=re(),r=Z(),{config:d,ready:u}=Ft(),l=d.capabilities.organization,[o,n]=(0,J.useState)(null),[s,m]=(0,J.useState)(null),c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=["lunora-auth-orgs"],t[0]=c):c=t[0];let v;t[1]!==e?(v=i(()=>e.listAuthOrganizations({limit:100}),"p"),t[1]=e,t[2]=v):v=t[2];let g;t[3]!==l?(g={enabled:l},t[3]=l,t[4]=g):g=t[4];let h=ue(c,v,g),w=h.data?.rows??null,f;t[5]!==h?(f=i(()=>{h.refetch()},"b"),t[5]=h,t[6]=f):f=t[6],At(f,l);let y;t[7]===Symbol.for("react.memo_cache_sentinel")?(y=i(()=>{m(null)},"v"),t[7]=y):y=t[7];let z=y,p;t[8]!==h?(p=i(()=>{h.refetch()},"f"),t[8]=h,t[9]=p):p=t[9];let x=p,b;t[10]===Symbol.for("react.memo_cache_sentinel")?(b=i(F=>{n(F)},"h"),t[10]=b):b=t[10];let k=b;if(u&&!l){let F;t[11]!==r?(F=r("Enable the organization() plugin in your auth config to manage organizations here."),t[11]=r,t[12]=F):F=t[12];let M;t[13]!==r?(M=r("Organizations are not enabled."),t[13]=r,t[14]=M):M=t[14];let H;return t[15]!==F||t[16]!==M?(H=(0,a.jsx)(ce,{description:F,testId:"org-disabled",title:M}),t[15]=F,t[16]=M,t[17]=H):H=t[17],H}let I;t[18]!==r?(I=r("Organizations"),t[18]=r,t[19]=I):I=t[19];let C;t[20]!==I?(C=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:I}),t[20]=I,t[21]=C):C=t[21];let N;t[22]===Symbol.for("react.memo_cache_sentinel")?(N=i(()=>{m({kind:"create"})},"z"),t[22]=N):N=t[22];let D;t[23]!==r?(D=r("New organization"),t[23]=r,t[24]=D):D=t[24];let _;t[25]!==D?(_=(0,a.jsx)(P,{"data-testid":"org-new",onClick:N,size:"sm",type:"button",children:D}),t[25]=D,t[26]=_):_=t[26];let A;t[27]!==_||t[28]!==C?(A=(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[C,_]}),t[27]=_,t[28]=C,t[29]=A):A=t[29];let $;t[30]!==h.error?($=h.error!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-error",role:"alert",children:h.error}),t[30]=h.error,t[31]=$):$=t[31];let R;t[32]!==w||t[33]!==r?(R=w!==null&&w.length===0&&(0,a.jsx)(ce,{testId:"org-empty",title:r("No organizations.")}),t[32]=w,t[33]=r,t[34]=R):R=t[34];let U;t[35]!==w||t[36]!==o||t[37]!==r?(U=w!==null&&w.length>0&&(0,a.jsx)(xt,{className:"overflow-hidden py-0",children:(0,a.jsx)(wt,{className:"px-0",children:(0,a.jsxs)(zt,{"data-testid":"org-table",children:[(0,a.jsx)(kt,{children:(0,a.jsxs)(tt,{children:[(0,a.jsx)(se,{children:r("id")}),(0,a.jsx)(se,{children:r("name")}),(0,a.jsx)(se,{children:r("slug")}),(0,a.jsx)(se,{children:r("created")}),(0,a.jsx)(se,{"aria-label":r("Actions")})]})}),(0,a.jsx)(Nt,{children:w.map(F=>{let M=S(F.id);return(0,a.jsxs)(tt,{"data-testid":`org-row-${M}`,children:[(0,a.jsx)(de,{className:"font-mono text-xs",children:M}),(0,a.jsx)(de,{children:S(F.name)}),(0,a.jsx)(de,{children:S(F.slug)}),(0,a.jsx)(de,{className:"text-muted-foreground tabular-nums",children:$t(F.createdAt)}),(0,a.jsx)(de,{children:(0,a.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,a.jsx)(P,{"aria-pressed":o===M,"data-testid":`org-select-${M}`,onClick:i(()=>{k(M)},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Manage")}),(0,a.jsx)(P,{"data-testid":`org-edit-${M}`,onClick:i(()=>{m({kind:"edit",org:F})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Edit")}),(0,a.jsx)(P,{"data-testid":`org-delete-${M}`,onClick:i(()=>{m({kind:"delete",org:F})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Delete")})]})})]},M)})})]})})}),t[35]=w,t[36]=o,t[37]=r,t[38]=U):U=t[38];let K;t[39]!==d.organization||t[40]!==o?(K=o!==null&&(0,a.jsx)(Gt,{organizationId:o,rolesEnabled:d.organization.roles,teamsEnabled:d.organization.teams}),t[39]=d.organization,t[40]=o,t[41]=K):K=t[41];let q;t[42]!==s?.kind||t[43]!==x?(q=s?.kind==="create"&&(0,a.jsx)(Et,{mode:"create",onClose:z,onDone:x}),t[42]=s?.kind,t[43]=x,t[44]=q):q=t[44];let j;t[45]!==s||t[46]!==x?(j=s?.kind==="edit"&&(0,a.jsx)(Et,{mode:"edit",onClose:z,onDone:x,org:s.org}),t[45]=s,t[46]=x,t[47]=j):j=t[47];let B;t[48]!==e||t[49]!==s||t[50]!==x||t[51]!==r?(B=s?.kind==="delete"&&(0,a.jsx)(Ut,{action:i(async()=>{let F=S(s.org.id);await e.deleteAuthOrganization({organizationId:F}),n(M=>M===F?null:M)},"action"),message:r("Delete this organization? Its members, invitations, teams, and custom roles are removed. This cannot be undone."),onClose:z,onDone:x,testId:"org-delete",title:r("Delete organization")}),t[48]=e,t[49]=s,t[50]=x,t[51]=r,t[52]=B):B=t[52];let T;return t[53]!==A||t[54]!==$||t[55]!==R||t[56]!==U||t[57]!==K||t[58]!==q||t[59]!==j||t[60]!==B?(T=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-organizations",children:[A,$,R,U,K,q,j,B]}),t[53]=A,t[54]=$,t[55]=R,t[56]=U,t[57]=K,t[58]=q,t[59]=j,t[60]=B,t[61]=T):T=t[61],T},"Cr");export{xr as OrganizationsPanel};
1
+ import{a as Ft,b as ie}from"./chunk-VSS7NFZJ.js";import{a as Mt}from"./chunk-ESVP44Y3.js";import{a as At}from"./chunk-54MMVNPT.js";import{a as ue}from"./chunk-OWADN6BI.js";import{a as zt,b as kt,c as Nt,d as tt,e as se,f as de}from"./chunk-MIQTKZAR.js";import{a as xt,e as wt}from"./chunk-UZERI5YC.js";import{a as St}from"./chunk-V53KNYRN.js";import{a as Rt}from"./chunk-5Y3QLNWX.js";import{R as G}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as P}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{f as re}from"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{a as ce}from"./chunk-XQCVZAGU.js";import{d as Z,h as Ot,l as S,m as Dt,q as $t}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as i,e as Ct,f as qt,g as Bt,h as Ht}from"./chunk-3XIESWL4.js";var Y=Ct(Bt(),1);var J=Ct(qt(),1);var a=Ct(Ht(),1);var Pt=i(t=>{let e=JSON.parse(t);if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("Expected a JSON object");return e},"Ft"),Kt=i(t=>{let e=Pt(t),r={};for(let[d,u]of Object.entries(e)){if(!Array.isArray(u)||u.some(l=>typeof l!="string"))throw new TypeError(`"${d}" must map to an array of action strings`);r[d]=u}return r},"Ut"),Jt=i(t=>t==null||t===""?"":typeof t=="string"?t:JSON.stringify(t,null,2),"Rt"),X=i(t=>{let e=(0,Y.c)(6),{children:r,htmlFor:d,label:u}=t,l;e[0]!==d||e[1]!==u?(l=(0,a.jsx)(Rt,{htmlFor:d,children:u}),e[0]=d,e[1]=u,e[2]=l):l=e[2];let o;return e[3]!==r||e[4]!==l?(o=(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[l,r]}),e[3]=r,e[4]=l,e[5]=o):o=e[5],o},"Q"),me=i(({busy:t,canSubmit:e,children:r,destructive:d=!1,error:u,onClose:l,onSubmit:o,submitLabel:n,testId:s,title:m})=>{let c=Z();return(0,a.jsxs)(Mt,{label:m,onClose:l,panelTestId:`${s}-panel`,testId:`${s}-overlay`,variant:"dialog",children:[(0,a.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:m}),r,u!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":`${s}-error`,role:"alert",children:u}),(0,a.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,a.jsx)(P,{"data-testid":`${s}-cancel`,onClick:l,size:"sm",type:"button",variant:"outline",children:c("Cancel")}),(0,a.jsx)(P,{"data-testid":`${s}-submit`,disabled:t||!e,onClick:o,size:"sm",type:"button",variant:d?"destructive":"default",children:t?c("Saving\u2026"):n})]})]})},"se"),Et=i(t=>{let e=(0,Y.c)(79),{mode:r,onClose:d,onDone:u,org:l}=t,o=re(),n=Z(),{busy:s,error:m,run:c}=ie(),v;e[0]!==l?(v=l?S(l.name):"",e[0]=l,e[1]=v):v=e[1];let[g,h]=(0,J.useState)(v),w;e[2]!==l?(w=l?S(l.slug):"",e[2]=l,e[3]=w):w=e[3];let[f,y]=(0,J.useState)(w),z;e[4]!==l?(z=l?S(l.logo):"",e[4]=l,e[5]=z):z=e[5];let[p,x]=(0,J.useState)(z),[b,k]=(0,J.useState)(""),I;e[6]!==r||e[7]!==l?.metadata?(I=r==="edit"?Jt(l?.metadata):"",e[6]=r,e[7]=l?.metadata,e[8]=I):I=e[8];let[C,N]=(0,J.useState)(I),D;e[9]!==o||e[10]!==p||e[11]!==C||e[12]!==r||e[13]!==g||e[14]!==d||e[15]!==u||e[16]!==l?.id||e[17]!==b||e[18]!==c||e[19]!==f?(D=i(()=>{c(async()=>{let L=C.trim()===""?void 0:Pt(C);r==="create"?await o.createAuthOrganization({logo:p.trim()===""?void 0:p.trim(),metadata:L,name:g.trim(),ownerId:b.trim()===""?void 0:b.trim(),slug:f.trim()===""?void 0:f.trim()}):await o.updateAuthOrganization({logo:p.trim()===""?void 0:p.trim(),metadata:L,name:g.trim()===""?void 0:g.trim(),organizationId:S(l?.id),slug:f.trim()===""?void 0:f.trim()}),u(),d()})},"O"),e[9]=o,e[10]=p,e[11]=C,e[12]=r,e[13]=g,e[14]=d,e[15]=u,e[16]=l?.id,e[17]=b,e[18]=c,e[19]=f,e[20]=D):D=e[20];let _=D,A;e[21]!==r||e[22]!==g?(A=g.trim()!==""||r==="edit",e[21]=r,e[22]=g,e[23]=A):A=e[23];let $;e[24]!==r||e[25]!==n?($=n(r==="create"?"Create":"Save"),e[24]=r,e[25]=n,e[26]=$):$=e[26];let R;e[27]!==r||e[28]!==n?(R=n(r==="create"?"New organization":"Edit organization"),e[27]=r,e[28]=n,e[29]=R):R=e[29];let U;e[30]!==n?(U=n("name"),e[30]=n,e[31]=U):U=e[31];let K;e[32]===Symbol.for("react.memo_cache_sentinel")?(K=i(L=>{h(L.target.value)},"q"),e[32]=K):K=e[32];let q;e[33]!==g?(q=(0,a.jsx)(G,{"data-testid":"org-form-name",id:"org-form-name",onChange:K,value:g}),e[33]=g,e[34]=q):q=e[34];let j;e[35]!==q||e[36]!==U?(j=(0,a.jsx)(X,{htmlFor:"org-form-name",label:U,children:q}),e[35]=q,e[36]=U,e[37]=j):j=e[37];let B;e[38]!==n?(B=n("Slug (optional \u2014 derived from name)"),e[38]=n,e[39]=B):B=e[39];let T;e[40]===Symbol.for("react.memo_cache_sentinel")?(T=i(L=>{y(L.target.value)},"K"),e[40]=T):T=e[40];let F;e[41]!==f?(F=(0,a.jsx)(G,{"data-testid":"org-form-slug",id:"org-form-slug",onChange:T,value:f}),e[41]=f,e[42]=F):F=e[42];let M;e[43]!==B||e[44]!==F?(M=(0,a.jsx)(X,{htmlFor:"org-form-slug",label:B,children:F}),e[43]=B,e[44]=F,e[45]=M):M=e[45];let H;e[46]!==n?(H=n("Logo URL (optional)"),e[46]=n,e[47]=H):H=e[47];let oe;e[48]===Symbol.for("react.memo_cache_sentinel")?(oe=i(L=>{x(L.target.value)},"re"),e[48]=oe):oe=e[48];let Q;e[49]!==p?(Q=(0,a.jsx)(G,{"data-testid":"org-form-logo",id:"org-form-logo",onChange:oe,value:p}),e[49]=p,e[50]=Q):Q=e[50];let V;e[51]!==H||e[52]!==Q?(V=(0,a.jsx)(X,{htmlFor:"org-form-logo",label:H,children:Q}),e[51]=H,e[52]=Q,e[53]=V):V=e[53];let W;e[54]!==r||e[55]!==b||e[56]!==n?(W=r==="create"&&(0,a.jsx)(X,{htmlFor:"org-form-owner",label:n("Owner user id (optional)"),children:(0,a.jsx)(G,{"data-testid":"org-form-owner",id:"org-form-owner",onChange:i(L=>{k(L.target.value)},"onChange"),value:b})}),e[54]=r,e[55]=b,e[56]=n,e[57]=W):W=e[57];let ee;e[58]!==n?(ee=n("Metadata (JSON, optional)"),e[58]=n,e[59]=ee):ee=e[59];let ae;e[60]===Symbol.for("react.memo_cache_sentinel")?(ae=i(L=>{N(L.target.value)},"oe"),e[60]=ae):ae=e[60];let te;e[61]!==C?(te=(0,a.jsx)(St,{"data-testid":"org-form-metadata",id:"org-form-metadata",onChange:ae,value:C}),e[61]=C,e[62]=te):te=e[62];let O;e[63]!==ee||e[64]!==te?(O=(0,a.jsx)(X,{htmlFor:"org-form-metadata",label:ee,children:te}),e[63]=ee,e[64]=te,e[65]=O):O=e[65];let ne;return e[66]!==s||e[67]!==m||e[68]!==d||e[69]!==_||e[70]!==j||e[71]!==M||e[72]!==V||e[73]!==W||e[74]!==O||e[75]!==A||e[76]!==$||e[77]!==R?(ne=(0,a.jsxs)(me,{busy:s,canSubmit:A,error:m,onClose:d,onSubmit:_,submitLabel:$,testId:"org-form",title:R,children:[j,M,V,W,O]}),e[66]=s,e[67]=m,e[68]=d,e[69]=_,e[70]=j,e[71]=M,e[72]=V,e[73]=W,e[74]=O,e[75]=A,e[76]=$,e[77]=R,e[78]=ne):ne=e[78],ne},"$t"),Tt=i(t=>{let e=(0,Y.c)(40),{onClose:r,onDone:d,organizationId:u}=t,l=re(),o=Z(),{busy:n,error:s,run:m}=ie(),[c,v]=(0,J.useState)(""),[g,h]=(0,J.useState)(""),w;e[0]!==l||e[1]!==r||e[2]!==d||e[3]!==u||e[4]!==g||e[5]!==m||e[6]!==c?(w=i(()=>{m(async()=>{await l.addAuthOrgMember({organizationId:u,role:g.trim()===""?void 0:g.trim(),userId:c.trim()}),d(),r()})},"C"),e[0]=l,e[1]=r,e[2]=d,e[3]=u,e[4]=g,e[5]=m,e[6]=c,e[7]=w):w=e[7];let f=w,y;e[8]!==c?(y=c.trim(),e[8]=c,e[9]=y):y=e[9];let z=y!=="",p;e[10]!==o?(p=o("Add member"),e[10]=o,e[11]=p):p=e[11];let x;e[12]!==o?(x=o("Add member"),e[12]=o,e[13]=x):x=e[13];let b;e[14]!==o?(b=o("User id"),e[14]=o,e[15]=b):b=e[15];let k;e[16]===Symbol.for("react.memo_cache_sentinel")?(k=i(R=>{v(R.target.value)},"x"),e[16]=k):k=e[16];let I;e[17]!==c?(I=(0,a.jsx)(G,{"data-testid":"org-add-member-user",id:"org-add-member-user",onChange:k,value:c}),e[17]=c,e[18]=I):I=e[18];let C;e[19]!==b||e[20]!==I?(C=(0,a.jsx)(X,{htmlFor:"org-add-member-user",label:b,children:I}),e[19]=b,e[20]=I,e[21]=C):C=e[21];let N;e[22]!==o?(N=o("Role (optional)"),e[22]=o,e[23]=N):N=e[23];let D;e[24]===Symbol.for("react.memo_cache_sentinel")?(D=i(R=>{h(R.target.value)},"O"),e[24]=D):D=e[24];let _;e[25]!==g?(_=(0,a.jsx)(G,{"data-testid":"org-add-member-role",id:"org-add-member-role",onChange:D,value:g}),e[25]=g,e[26]=_):_=e[26];let A;e[27]!==N||e[28]!==_?(A=(0,a.jsx)(X,{htmlFor:"org-add-member-role",label:N,children:_}),e[27]=N,e[28]=_,e[29]=A):A=e[29];let $;return e[30]!==n||e[31]!==s||e[32]!==r||e[33]!==f||e[34]!==A||e[35]!==z||e[36]!==p||e[37]!==x||e[38]!==C?($=(0,a.jsxs)(me,{busy:n,canSubmit:z,error:s,onClose:r,onSubmit:f,submitLabel:p,testId:"org-add-member",title:x,children:[C,A]}),e[30]=n,e[31]=s,e[32]=r,e[33]=f,e[34]=A,e[35]=z,e[36]=p,e[37]=x,e[38]=C,e[39]=$):$=e[39],$},"Bt"),Xt=i(t=>{let e=(0,Y.c)(40),{onClose:r,onDone:d,organizationId:u}=t,l=re(),o=Z(),{busy:n,error:s,run:m}=ie(),[c,v]=(0,J.useState)(""),[g,h]=(0,J.useState)(""),w;e[0]!==l||e[1]!==c||e[2]!==r||e[3]!==d||e[4]!==u||e[5]!==g||e[6]!==m?(w=i(()=>{m(async()=>{await l.inviteAuthOrgMember({email:c.trim(),organizationId:u,role:g.trim()===""?void 0:g.trim()}),d(),r()})},"C"),e[0]=l,e[1]=c,e[2]=r,e[3]=d,e[4]=u,e[5]=g,e[6]=m,e[7]=w):w=e[7];let f=w,y;e[8]!==c?(y=c.trim(),e[8]=c,e[9]=y):y=e[9];let z=y!=="",p;e[10]!==o?(p=o("Send invitation"),e[10]=o,e[11]=p):p=e[11];let x;e[12]!==o?(x=o("Invite member"),e[12]=o,e[13]=x):x=e[13];let b;e[14]!==o?(b=o("email"),e[14]=o,e[15]=b):b=e[15];let k;e[16]===Symbol.for("react.memo_cache_sentinel")?(k=i(R=>{v(R.target.value)},"x"),e[16]=k):k=e[16];let I;e[17]!==c?(I=(0,a.jsx)(G,{"data-testid":"org-invite-member-email",id:"org-invite-member-email",onChange:k,type:"email",value:c}),e[17]=c,e[18]=I):I=e[18];let C;e[19]!==b||e[20]!==I?(C=(0,a.jsx)(X,{htmlFor:"org-invite-member-email",label:b,children:I}),e[19]=b,e[20]=I,e[21]=C):C=e[21];let N;e[22]!==o?(N=o("Role (optional)"),e[22]=o,e[23]=N):N=e[23];let D;e[24]===Symbol.for("react.memo_cache_sentinel")?(D=i(R=>{h(R.target.value)},"O"),e[24]=D):D=e[24];let _;e[25]!==g?(_=(0,a.jsx)(G,{"data-testid":"org-invite-member-role",id:"org-invite-member-role",onChange:D,value:g}),e[25]=g,e[26]=_):_=e[26];let A;e[27]!==N||e[28]!==_?(A=(0,a.jsx)(X,{htmlFor:"org-invite-member-role",label:N,children:_}),e[27]=N,e[28]=_,e[29]=A):A=e[29];let $;return e[30]!==n||e[31]!==s||e[32]!==r||e[33]!==f||e[34]!==A||e[35]!==z||e[36]!==p||e[37]!==x||e[38]!==C?($=(0,a.jsxs)(me,{busy:n,canSubmit:z,error:s,onClose:r,onSubmit:f,submitLabel:p,testId:"org-invite-member",title:x,children:[C,A]}),e[30]=n,e[31]=s,e[32]=r,e[33]=f,e[34]=A,e[35]=z,e[36]=p,e[37]=x,e[38]=C,e[39]=$):$=e[39],$},"Ht"),Yt=i(t=>{let e=(0,Y.c)(32),{member:r,onClose:d,onDone:u}=t,l=re(),o=Z(),{busy:n,error:s,run:m}=ie(),c;e[0]!==r.role?(c=S(r.role),e[0]=r.role,e[1]=c):c=e[1];let[v,g]=(0,J.useState)(c),h;e[2]!==l||e[3]!==r.id||e[4]!==d||e[5]!==u||e[6]!==v||e[7]!==m?(h=i(()=>{m(async()=>{await l.setAuthOrgMemberRole({memberId:S(r.id),role:v.trim()}),u(),d()})},"g"),e[2]=l,e[3]=r.id,e[4]=d,e[5]=u,e[6]=v,e[7]=m,e[8]=h):h=e[8];let w=h,f;e[9]!==v?(f=v.trim(),e[9]=v,e[10]=f):f=e[10];let y=f!=="",z;e[11]!==o?(z=o("Save"),e[11]=o,e[12]=z):z=e[12];let p;e[13]!==o?(p=o("Change member role"),e[13]=o,e[14]=p):p=e[14];let x;e[15]!==o?(x=o("Role"),e[15]=o,e[16]=x):x=e[16];let b;e[17]===Symbol.for("react.memo_cache_sentinel")?(b=i(N=>{g(N.target.value)},"h"),e[17]=b):b=e[17];let k;e[18]!==v?(k=(0,a.jsx)(G,{"data-testid":"org-member-role-value",id:"org-member-role-value",onChange:b,value:v}),e[18]=v,e[19]=k):k=e[19];let I;e[20]!==x||e[21]!==k?(I=(0,a.jsx)(X,{htmlFor:"org-member-role-value",label:x,children:k}),e[20]=x,e[21]=k,e[22]=I):I=e[22];let C;return e[23]!==n||e[24]!==s||e[25]!==d||e[26]!==w||e[27]!==I||e[28]!==y||e[29]!==z||e[30]!==p?(C=(0,a.jsx)(me,{busy:n,canSubmit:y,error:s,onClose:d,onSubmit:w,submitLabel:z,testId:"org-member-role",title:p,children:I}),e[23]=n,e[24]=s,e[25]=d,e[26]=w,e[27]=I,e[28]=y,e[29]=z,e[30]=p,e[31]=C):C=e[31],C},"qt"),Lt=i(t=>{let e=(0,Y.c)(36),{mode:r,onClose:d,onDone:u,organizationId:l,team:o}=t,n=re(),s=Z(),{busy:m,error:c,run:v}=ie(),g;e[0]!==o?(g=o?S(o.name):"",e[0]=o,e[1]=g):g=e[1];let[h,w]=(0,J.useState)(g),f;e[2]!==n||e[3]!==r||e[4]!==h||e[5]!==d||e[6]!==u||e[7]!==l||e[8]!==v||e[9]!==o?.id?(f=i(()=>{v(async()=>{await(r==="create"?n.createAuthOrgTeam({name:h.trim(),organizationId:l}):n.updateAuthOrgTeam({name:h.trim(),teamId:S(o?.id)})),u(),d()})},"b"),e[2]=n,e[3]=r,e[4]=h,e[5]=d,e[6]=u,e[7]=l,e[8]=v,e[9]=o?.id,e[10]=f):f=e[10];let y=f,z;e[11]!==h?(z=h.trim(),e[11]=h,e[12]=z):z=e[12];let p=z!=="",x;e[13]!==r||e[14]!==s?(x=s(r==="create"?"Create":"Save"),e[13]=r,e[14]=s,e[15]=x):x=e[15];let b;e[16]!==r||e[17]!==s?(b=s(r==="create"?"New team":"Rename team"),e[16]=r,e[17]=s,e[18]=b):b=e[18];let k;e[19]!==s?(k=s("name"),e[19]=s,e[20]=k):k=e[20];let I;e[21]===Symbol.for("react.memo_cache_sentinel")?(I=i(_=>{w(_.target.value)},"y"),e[21]=I):I=e[21];let C;e[22]!==h?(C=(0,a.jsx)(G,{"data-testid":"org-team-form-name",id:"org-team-form-name",onChange:I,value:h}),e[22]=h,e[23]=C):C=e[23];let N;e[24]!==k||e[25]!==C?(N=(0,a.jsx)(X,{htmlFor:"org-team-form-name",label:k,children:C}),e[24]=k,e[25]=C,e[26]=N):N=e[26];let D;return e[27]!==m||e[28]!==c||e[29]!==d||e[30]!==y||e[31]!==N||e[32]!==p||e[33]!==x||e[34]!==b?(D=(0,a.jsx)(me,{busy:m,canSubmit:p,error:c,onClose:d,onSubmit:y,submitLabel:x,testId:"org-team-form",title:b,children:N}),e[27]=m,e[28]=c,e[29]=d,e[30]=y,e[31]=N,e[32]=p,e[33]=x,e[34]=b,e[35]=D):D=e[35],D},"xt"),Zt=i(t=>{let e=(0,Y.c)(30),{onClose:r,onDone:d,teamId:u}=t,l=re(),o=Z(),{busy:n,error:s,run:m}=ie(),[c,v]=(0,J.useState)(""),g;e[0]!==l||e[1]!==r||e[2]!==d||e[3]!==m||e[4]!==u||e[5]!==c?(g=i(()=>{m(async()=>{await l.addAuthOrgTeamMember({teamId:u,userId:c.trim()}),d(),r()})},"u"),e[0]=l,e[1]=r,e[2]=d,e[3]=m,e[4]=u,e[5]=c,e[6]=g):g=e[6];let h=g,w;e[7]!==c?(w=c.trim(),e[7]=c,e[8]=w):w=e[8];let f=w!=="",y;e[9]!==o?(y=o("Add member"),e[9]=o,e[10]=y):y=e[10];let z;e[11]!==o?(z=o("Add team member"),e[11]=o,e[12]=z):z=e[12];let p;e[13]!==o?(p=o("User id"),e[13]=o,e[14]=p):p=e[14];let x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=i(C=>{v(C.target.value)},"w"),e[15]=x):x=e[15];let b;e[16]!==c?(b=(0,a.jsx)(G,{"data-testid":"org-team-add-member-user",id:"org-team-add-member-user",onChange:x,value:c}),e[16]=c,e[17]=b):b=e[17];let k;e[18]!==p||e[19]!==b?(k=(0,a.jsx)(X,{htmlFor:"org-team-add-member-user",label:p,children:b}),e[18]=p,e[19]=b,e[20]=k):k=e[20];let I;return e[21]!==n||e[22]!==s||e[23]!==r||e[24]!==h||e[25]!==f||e[26]!==y||e[27]!==z||e[28]!==k?(I=(0,a.jsx)(me,{busy:n,canSubmit:f,error:s,onClose:r,onSubmit:h,submitLabel:y,testId:"org-team-add-member",title:z,children:k}),e[21]=n,e[22]=s,e[23]=r,e[24]=h,e[25]=f,e[26]=y,e[27]=z,e[28]=k,e[29]=I):I=e[29],I},"Kt"),jt=i(t=>{let e=(0,Y.c)(47),{mode:r,onClose:d,onDone:u,organizationId:l,role:o}=t,n=re(),s=Z(),{busy:m,error:c,run:v}=ie(),g;e[0]!==o?(g=o?S(o.role):"",e[0]=o,e[1]=g):g=e[1];let[h,w]=(0,J.useState)(g),f;e[2]!==r||e[3]!==o?.permission?(f=r==="edit"?Jt(o?.permission):"",e[2]=r,e[3]=o?.permission,e[4]=f):f=e[4];let[y,z]=(0,J.useState)(f),p;e[5]!==n||e[6]!==r||e[7]!==h||e[8]!==d||e[9]!==u||e[10]!==l||e[11]!==y||e[12]!==o?.id||e[13]!==v?(p=i(()=>{v(async()=>{let R=Kt(y);await(r==="create"?n.createAuthOrgRole({organizationId:l,permission:R,role:h.trim()}):n.updateAuthOrgRole({permission:R,roleId:S(o?.id)})),u(),d()})},"f"),e[5]=n,e[6]=r,e[7]=h,e[8]=d,e[9]=u,e[10]=l,e[11]=y,e[12]=o?.id,e[13]=v,e[14]=p):p=e[14];let x=p,b;e[15]!==r||e[16]!==h||e[17]!==y?(b=y.trim()!==""&&(r==="edit"||h.trim()!==""),e[15]=r,e[16]=h,e[17]=y,e[18]=b):b=e[18];let k;e[19]!==r||e[20]!==s?(k=s(r==="create"?"Create":"Save"),e[19]=r,e[20]=s,e[21]=k):k=e[21];let I;e[22]!==r||e[23]!==s?(I=s(r==="create"?"New role":"Edit role"),e[22]=r,e[23]=s,e[24]=I):I=e[24];let C;e[25]!==r||e[26]!==h||e[27]!==s?(C=r==="create"&&(0,a.jsx)(X,{htmlFor:"org-role-form-name",label:s("Role name"),children:(0,a.jsx)(G,{"data-testid":"org-role-form-name",id:"org-role-form-name",onChange:i(R=>{w(R.target.value)},"onChange"),value:h})}),e[25]=r,e[26]=h,e[27]=s,e[28]=C):C=e[28];let N;e[29]!==s?(N=s('Permission (JSON, e.g. {"project":["create","update"]})'),e[29]=s,e[30]=N):N=e[30];let D;e[31]===Symbol.for("react.memo_cache_sentinel")?(D=i(R=>{z(R.target.value)},"O"),e[31]=D):D=e[31];let _;e[32]!==y?(_=(0,a.jsx)(St,{"data-testid":"org-role-form-permission",id:"org-role-form-permission",onChange:D,value:y}),e[32]=y,e[33]=_):_=e[33];let A;e[34]!==_||e[35]!==N?(A=(0,a.jsx)(X,{htmlFor:"org-role-form-permission",label:N,children:_}),e[34]=_,e[35]=N,e[36]=A):A=e[36];let $;return e[37]!==m||e[38]!==c||e[39]!==d||e[40]!==x||e[41]!==A||e[42]!==b||e[43]!==k||e[44]!==I||e[45]!==C?($=(0,a.jsxs)(me,{busy:m,canSubmit:b,error:c,onClose:d,onSubmit:x,submitLabel:k,testId:"org-role-form",title:I,children:[C,A]}),e[37]=m,e[38]=c,e[39]=d,e[40]=x,e[41]=A,e[42]=b,e[43]=k,e[44]=I,e[45]=C,e[46]=$):$=e[46],$},"zt"),Ut=i(t=>{let e=(0,Y.c)(18),{action:r,message:d,onClose:u,onDone:l,testId:o,title:n}=t,s=Z(),{busy:m,error:c,run:v}=ie(),g;e[0]!==r||e[1]!==u||e[2]!==l||e[3]!==v?(g=i(()=>{v(async()=>{await r(),l(),u()})},"u"),e[0]=r,e[1]=u,e[2]=l,e[3]=v,e[4]=g):g=e[4];let h=g,w;e[5]!==s?(w=s("Delete"),e[5]=s,e[6]=w):w=e[6];let f;e[7]!==d?(f=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:d}),e[7]=d,e[8]=f):f=e[8];let y;return e[9]!==m||e[10]!==c||e[11]!==u||e[12]!==h||e[13]!==w||e[14]!==f||e[15]!==o||e[16]!==n?(y=(0,a.jsx)(me,{busy:m,canSubmit:!0,destructive:!0,error:c,onClose:u,onSubmit:h,submitLabel:w,testId:o,title:n,children:f}),e[9]=m,e[10]=c,e[11]=u,e[12]=h,e[13]=w,e[14]=f,e[15]=o,e[16]=n,e[17]=y):y=e[17],y},"Tt"),rt=i(t=>{let e=(0,Y.c)(13),{action:r,children:d,heading:u,testId:l}=t,o;e[0]!==u?(o=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:u}),e[0]=u,e[1]=o):o=e[1];let n;e[2]!==r?(n=r!==void 0&&(0,a.jsx)("div",{className:"flex items-center gap-2",children:r}),e[2]=r,e[3]=n):n=e[3];let s;e[4]!==o||e[5]!==n?(s=(0,a.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[o,n]}),e[4]=o,e[5]=n,e[6]=s):s=e[6];let m;e[7]!==d?(m=(0,a.jsx)(wt,{className:"px-0",children:d}),e[7]=d,e[8]=m):m=e[8];let c;return e[9]!==s||e[10]!==m||e[11]!==l?(c=(0,a.jsxs)(xt,{className:"overflow-hidden py-0","data-testid":l,children:[s,m]}),e[9]=s,e[10]=m,e[11]=l,e[12]=c):c=e[12],c},"tt"),ot=i(t=>{let e=(0,Y.c)(23),{columns:r,rowActions:d,rowPrefix:u,rows:l}=t,o=Z(),n;e[0]!==r?(n=r.map(Qt),e[0]=r,e[1]=n):n=e[1];let s;e[2]!==o?(s=o("Actions"),e[2]=o,e[3]=s):s=e[3];let m;e[4]!==s?(m=(0,a.jsx)(se,{"aria-label":s}),e[4]=s,e[5]=m):m=e[5];let c;e[6]!==n||e[7]!==m?(c=(0,a.jsx)(kt,{children:(0,a.jsxs)(tt,{children:[n,m]})}),e[6]=n,e[7]=m,e[8]=c):c=e[8];let v;if(e[9]!==r||e[10]!==d||e[11]!==u||e[12]!==l){let w;e[14]!==r||e[15]!==d||e[16]!==u?(w=i(f=>{let y=S(f.id);return(0,a.jsxs)(tt,{"data-testid":`${u}-${y}`,children:[r.map(z=>(0,a.jsx)(de,{className:z.className,children:z.render(f)},z.head)),(0,a.jsx)(de,{children:(0,a.jsx)("div",{className:"flex justify-end gap-1",children:d(f)})})]},y)},"C"),e[14]=r,e[15]=d,e[16]=u,e[17]=w):w=e[17],v=l.map(w),e[9]=r,e[10]=d,e[11]=u,e[12]=l,e[13]=v}else v=e[13];let g;e[18]!==v?(g=(0,a.jsx)(Nt,{children:v}),e[18]=v,e[19]=g):g=e[19];let h;return e[20]!==c||e[21]!==g?(h=(0,a.jsxs)(zt,{children:[c,g]}),e[20]=c,e[21]=g,e[22]=h):h=e[22],h},"rt"),Gt=i(t=>{let e=(0,Y.c)(219),{organizationId:r,rolesEnabled:d,teamsEnabled:u}=t,l=re(),o=Z(),[n,s]=(0,J.useState)(null),[m,c]=(0,J.useState)(null),[v,g]=(0,J.useState)(!1),[h,w]=(0,J.useState)(null),f;e[0]!==r?(f=["lunora-auth-org-members",r],e[0]=r,e[1]=f):f=e[1];let y;e[2]!==l||e[3]!==r?(y=i(()=>l.listAuthOrgMembers({limit:200,organizationId:r}),"v"),e[2]=l,e[3]=r,e[4]=y):y=e[4];let z=ue(f,y),p;e[5]!==r?(p=["lunora-auth-org-invitations",r],e[5]=r,e[6]=p):p=e[6];let x;e[7]!==l||e[8]!==r?(x=i(()=>l.listAuthOrgInvitations({limit:200,organizationId:r}),"w"),e[7]=l,e[8]=r,e[9]=x):x=e[9];let b=ue(p,x),k;e[10]!==r?(k=["lunora-auth-org-teams",r],e[10]=r,e[11]=k):k=e[11];let I;e[12]!==l||e[13]!==r?(I=i(()=>l.listAuthOrgTeams({limit:200,organizationId:r}),"y"),e[12]=l,e[13]=r,e[14]=I):I=e[14];let C;e[15]!==u?(C={enabled:u},e[15]=u,e[16]=C):C=e[16];let N=ue(k,I,C),D;e[17]!==r?(D=["lunora-auth-org-roles",r],e[17]=r,e[18]=D):D=e[18];let _;e[19]!==l||e[20]!==r?(_=i(()=>l.listAuthOrgRoles({limit:200,organizationId:r}),"N"),e[19]=l,e[20]=r,e[21]=_):_=e[21];let A;e[22]!==d?(A={enabled:d},e[22]=d,e[23]=A):A=e[23];let $=ue(D,_,A),R;e[24]!==m?(R=["lunora-auth-org-team-members",m],e[24]=m,e[25]=R):R=e[25];let U;e[26]!==l||e[27]!==m?(U=i(()=>l.listAuthOrgTeamMembers({limit:200,teamId:m??""}),"J"),e[26]=l,e[27]=m,e[28]=U):U=e[28];let K=m!==null,q;e[29]!==K?(q={enabled:K},e[29]=K,e[30]=q):q=e[30];let j=ue(R,U,q),B;e[31]!==z.data?.rows?(B=z.data?.rows??[],e[31]=z.data?.rows,e[32]=B):B=e[32];let T=B,F;e[33]!==b.data?.rows?(F=b.data?.rows??[],e[33]=b.data?.rows,e[34]=F):F=e[34];let M=F,H;e[35]!==N.data?.rows?(H=N.data?.rows??[],e[35]=N.data?.rows,e[36]=H):H=e[36];let oe=H,Q;e[37]!==$.data?.rows?(Q=$.data?.rows??[],e[37]=$.data?.rows,e[38]=Q):Q=e[38];let V=Q,W;e[39]!==m||e[40]!==j?(W=m===null?[]:j.data?.rows??[],e[39]=m,e[40]=j,e[41]=W):W=e[41];let ee=W,ae=z.error??b.error??N.error??$.error??j.error,te;e[42]!==b||e[43]!==z||e[44]!==d||e[45]!==$||e[46]!==m||e[47]!==j||e[48]!==u||e[49]!==N?(te=i(()=>{z.refetch(),b.refetch(),u&&N.refetch(),d&&$.refetch(),m!==null&&j.refetch()},"te"),e[42]=b,e[43]=z,e[44]=d,e[45]=$,e[46]=m,e[47]=j,e[48]=u,e[49]=N,e[50]=te):te=e[50];let O=te;At(O,!0);let ne;e[51]===Symbol.for("react.memo_cache_sentinel")?(ne=i(()=>{s(null)},"ne"),e[51]=ne):ne=e[51];let L=ne,at;e[52]!==O?(at=i(E=>{Dt((async()=>{g(!0),w(null);try{await E(),O(),g(!1)}catch(ht){w(Ot(ht)),g(!1)}})())},"ot"),e[52]=O,e[53]=at):at=e[53];let le=at,nt;e[54]!==l||e[55]!==o?(nt=i(E=>{let ht=S(E.id);s({action:i(async()=>{await l.removeAuthOrgTeam({teamId:ht}),c(_t=>_t===ht?null:_t)},"action"),kind:"confirm",message:o("Delete this team and its memberships? This cannot be undone."),testId:"org-team-delete",title:o("Delete team")})},"nt"),e[54]=l,e[55]=o,e[56]=nt):nt=e[56];let bt=nt,ge;e[57]!==o?(ge=o("userId"),e[57]=o,e[58]=ge):ge=e[58];let he;e[59]!==ge?(he={head:ge,render:Vt},e[59]=ge,e[60]=he):he=e[60];let be;e[61]!==o?(be=o("role"),e[61]=o,e[62]=be):be=e[62];let fe;e[63]!==be?(fe={head:be,render:Wt},e[63]=be,e[64]=fe):fe=e[64];let lt;e[65]!==he||e[66]!==fe?(lt=[he,fe],e[65]=he,e[66]=fe,e[67]=lt):lt=e[67];let ft=lt,pe;e[68]!==o?(pe=o("email"),e[68]=o,e[69]=pe):pe=e[69];let ve;e[70]!==pe?(ve={head:pe,render:er},e[70]=pe,e[71]=ve):ve=e[71];let ye;e[72]!==o?(ye=o("role"),e[72]=o,e[73]=ye):ye=e[73];let Ie;e[74]!==ye?(Ie={head:ye,render:tr},e[74]=ye,e[75]=Ie):Ie=e[75];let Ce;e[76]!==o?(Ce=o("status"),e[76]=o,e[77]=Ce):Ce=e[77];let xe;e[78]!==Ce?(xe={head:Ce,render:rr},e[78]=Ce,e[79]=xe):xe=e[79];let it;e[80]!==ve||e[81]!==Ie||e[82]!==xe?(it=[ve,Ie,xe],e[80]=ve,e[81]=Ie,e[82]=xe,e[83]=it):it=e[83];let pt=it,we;e[84]!==o?(we=o("id"),e[84]=o,e[85]=we):we=e[85];let ze;e[86]!==we?(ze={className:"font-mono text-xs",head:we,render:or},e[86]=we,e[87]=ze):ze=e[87];let ke;e[88]!==o?(ke=o("name"),e[88]=o,e[89]=ke):ke=e[89];let Ne;e[90]!==ke?(Ne={head:ke,render:ar},e[90]=ke,e[91]=Ne):Ne=e[91];let st;e[92]!==ze||e[93]!==Ne?(st=[ze,Ne],e[92]=ze,e[93]=Ne,e[94]=st):st=e[94];let vt=st,Se;e[95]!==o?(Se=o("userId"),e[95]=o,e[96]=Se):Se=e[96];let dt;e[97]!==Se?(dt=[{head:Se,render:nr}],e[97]=Se,e[98]=dt):dt=e[98];let yt=dt,Ae;e[99]!==o?(Ae=o("role"),e[99]=o,e[100]=Ae):Ae=e[100];let _e;e[101]!==Ae?(_e={head:Ae,render:lr},e[101]=Ae,e[102]=_e):_e=e[102];let Oe;e[103]!==o?(Oe=o("Permission"),e[103]=o,e[104]=Oe):Oe=e[104];let De;e[105]!==Oe?(De={className:"font-mono text-xs whitespace-pre-wrap",head:Oe,render:ir},e[105]=Oe,e[106]=De):De=e[106];let mt;e[107]!==_e||e[108]!==De?(mt=[_e,De],e[107]=_e,e[108]=De,e[109]=mt):mt=e[109];let It=mt,$e;e[110]!==ae?($e=ae!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-detail-error",role:"alert",children:ae}),e[110]=ae,e[111]=$e):$e=e[111];let Re;e[112]!==h?(Re=h!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-action-error",role:"alert",children:h}),e[112]=h,e[113]=Re):Re=e[113];let ct;e[114]===Symbol.for("react.memo_cache_sentinel")?(ct=i(()=>{s({kind:"add-member"})},"dt"),e[114]=ct):ct=e[114];let Fe;e[115]!==o?(Fe=o("Add member"),e[115]=o,e[116]=Fe):Fe=e[116];let Me;e[117]!==Fe?(Me=(0,a.jsx)(P,{"data-testid":"org-open-add-member",onClick:ct,size:"xs",type:"button",variant:"outline",children:Fe}),e[117]=Fe,e[118]=Me):Me=e[118];let ut;e[119]===Symbol.for("react.memo_cache_sentinel")?(ut=i(()=>{s({kind:"invite-member"})},"ct"),e[119]=ut):ut=e[119];let Ee;e[120]!==o?(Ee=o("Invite member"),e[120]=o,e[121]=Ee):Ee=e[121];let Le;e[122]!==Ee?(Le=(0,a.jsx)(P,{"data-testid":"org-open-invite-member",onClick:ut,size:"xs",type:"button",variant:"outline",children:Ee}),e[122]=Ee,e[123]=Le):Le=e[123];let je;e[124]!==Me||e[125]!==Le?(je=(0,a.jsxs)(a.Fragment,{children:[Me,Le]}),e[124]=Me,e[125]=Le,e[126]=je):je=e[126];let Pe;e[127]!==o?(Pe=o("Members"),e[127]=o,e[128]=Pe):Pe=e[128];let Je;e[129]!==v||e[130]!==l||e[131]!==ft||e[132]!==T||e[133]!==le||e[134]!==o?(Je=T.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ce,{testId:"org-members-empty",title:o("No members.")})}):(0,a.jsx)(ot,{columns:ft,rowActions:i(E=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(P,{"data-testid":`org-member-role-${S(E.id)}`,onClick:i(()=>{s({kind:"member-role",member:E})},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Change role")}),(0,a.jsx)(P,{"data-testid":`org-remove-member-${S(E.id)}`,disabled:v,onClick:i(()=>{le(()=>l.removeAuthOrgMember({memberId:S(E.id)}))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Remove")})]}),"rowActions"),rowPrefix:"org-member",rows:T}),e[129]=v,e[130]=l,e[131]=ft,e[132]=T,e[133]=le,e[134]=o,e[135]=Je):Je=e[135];let Ue;e[136]!==je||e[137]!==Pe||e[138]!==Je?(Ue=(0,a.jsx)(rt,{action:je,heading:Pe,testId:"org-members",children:Je}),e[136]=je,e[137]=Pe,e[138]=Je,e[139]=Ue):Ue=e[139];let qe;e[140]!==v||e[141]!==l||e[142]!==pt||e[143]!==M||e[144]!==le||e[145]!==o?(qe=M.length>0&&(0,a.jsx)(rt,{heading:o("Invitations"),testId:"org-invitations",children:(0,a.jsx)(ot,{columns:pt,rowActions:i(E=>(0,a.jsx)(P,{"data-testid":`org-cancel-invitation-${S(E.id)}`,disabled:v,onClick:i(()=>{le(()=>l.cancelAuthOrgInvitation({invitationId:S(E.id)}))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Cancel")}),"rowActions"),rowPrefix:"org-invitation",rows:M})}),e[140]=v,e[141]=l,e[142]=pt,e[143]=M,e[144]=le,e[145]=o,e[146]=qe):qe=e[146];let Be;e[147]!==bt||e[148]!==m||e[149]!==o||e[150]!==vt||e[151]!==oe||e[152]!==u?(Be=u&&(0,a.jsx)(rt,{action:(0,a.jsx)(P,{"data-testid":"org-open-create-team",onClick:i(()=>{s({kind:"team-create"})},"onClick"),size:"xs",type:"button",variant:"outline",children:o("New team")}),heading:o("Teams"),testId:"org-teams",children:oe.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ce,{testId:"org-teams-empty",title:o("No teams.")})}):(0,a.jsx)(ot,{columns:vt,rowActions:i(E=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(P,{"aria-pressed":m===S(E.id),"data-testid":`org-team-select-${S(E.id)}`,onClick:i(()=>{c(S(E.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Members")}),(0,a.jsx)(P,{"data-testid":`org-team-rename-${S(E.id)}`,onClick:i(()=>{s({kind:"team-rename",team:E})},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Rename")}),(0,a.jsx)(P,{"data-testid":`org-team-delete-${S(E.id)}`,onClick:i(()=>{bt(E)},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Delete")})]}),"rowActions"),rowPrefix:"org-team",rows:oe})}),e[147]=bt,e[148]=m,e[149]=o,e[150]=vt,e[151]=oe,e[152]=u,e[153]=Be):Be=e[153];let He;e[154]!==v||e[155]!==l||e[156]!==le||e[157]!==m||e[158]!==o||e[159]!==yt||e[160]!==ee||e[161]!==u?(He=u&&m!==null&&(0,a.jsx)(rt,{action:(0,a.jsx)(P,{"data-testid":"org-open-add-team-member",onClick:i(()=>{s({kind:"team-add-member",teamId:m})},"onClick"),size:"xs",type:"button",variant:"outline",children:o("Add member")}),heading:o("Team members"),testId:"org-team-members",children:ee.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ce,{testId:"org-team-members-empty",title:o("No team members.")})}):(0,a.jsx)(ot,{columns:yt,rowActions:i(E=>(0,a.jsx)(P,{"data-testid":`org-team-remove-member-${S(E.id)}`,disabled:v,onClick:i(()=>{le(()=>l.removeAuthOrgTeamMember({teamMemberId:S(E.id)}))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Remove")}),"rowActions"),rowPrefix:"org-team-member",rows:ee})}),e[154]=v,e[155]=l,e[156]=le,e[157]=m,e[158]=o,e[159]=yt,e[160]=ee,e[161]=u,e[162]=He):He=e[162];let Ke;e[163]!==l||e[164]!==It||e[165]!==V||e[166]!==d||e[167]!==o?(Ke=d&&(0,a.jsx)(rt,{action:(0,a.jsx)(P,{"data-testid":"org-open-create-role",onClick:i(()=>{s({kind:"role-create"})},"onClick"),size:"xs",type:"button",variant:"outline",children:o("New role")}),heading:o("Roles"),testId:"org-roles",children:V.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ce,{testId:"org-roles-empty",title:o("No custom roles.")})}):(0,a.jsx)(ot,{columns:It,rowActions:i(E=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(P,{"data-testid":`org-role-edit-${S(E.id)}`,onClick:i(()=>{s({kind:"role-edit",role:E})},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Edit")}),(0,a.jsx)(P,{"data-testid":`org-role-delete-${S(E.id)}`,onClick:i(()=>{s({action:i(()=>l.deleteAuthOrgRole({roleId:S(E.id)}),"action"),kind:"confirm",message:o("Delete this custom role? Members keeping it will lose its grants."),testId:"org-role-delete",title:o("Delete role")})},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Delete")})]}),"rowActions"),rowPrefix:"org-role",rows:V})}),e[163]=l,e[164]=It,e[165]=V,e[166]=d,e[167]=o,e[168]=Ke):Ke=e[168];let Te;e[169]!==n?.kind||e[170]!==r||e[171]!==O?(Te=n?.kind==="add-member"&&(0,a.jsx)(Tt,{onClose:L,onDone:O,organizationId:r}),e[169]=n?.kind,e[170]=r,e[171]=O,e[172]=Te):Te=e[172];let Xe;e[173]!==n?.kind||e[174]!==r||e[175]!==O?(Xe=n?.kind==="invite-member"&&(0,a.jsx)(Xt,{onClose:L,onDone:O,organizationId:r}),e[173]=n?.kind,e[174]=r,e[175]=O,e[176]=Xe):Xe=e[176];let Ye;e[177]!==n||e[178]!==O?(Ye=n?.kind==="member-role"&&(0,a.jsx)(Yt,{member:n.member,onClose:L,onDone:O}),e[177]=n,e[178]=O,e[179]=Ye):Ye=e[179];let Ze;e[180]!==n?.kind||e[181]!==r||e[182]!==O?(Ze=n?.kind==="team-create"&&(0,a.jsx)(Lt,{mode:"create",onClose:L,onDone:O,organizationId:r}),e[180]=n?.kind,e[181]=r,e[182]=O,e[183]=Ze):Ze=e[183];let Ge;e[184]!==n||e[185]!==r||e[186]!==O?(Ge=n?.kind==="team-rename"&&(0,a.jsx)(Lt,{mode:"edit",onClose:L,onDone:O,organizationId:r,team:n.team}),e[184]=n,e[185]=r,e[186]=O,e[187]=Ge):Ge=e[187];let Qe;e[188]!==n||e[189]!==O?(Qe=n?.kind==="team-add-member"&&(0,a.jsx)(Zt,{onClose:L,onDone:O,teamId:n.teamId}),e[188]=n,e[189]=O,e[190]=Qe):Qe=e[190];let Ve;e[191]!==n?.kind||e[192]!==r||e[193]!==O?(Ve=n?.kind==="role-create"&&(0,a.jsx)(jt,{mode:"create",onClose:L,onDone:O,organizationId:r}),e[191]=n?.kind,e[192]=r,e[193]=O,e[194]=Ve):Ve=e[194];let We;e[195]!==n||e[196]!==r||e[197]!==O?(We=n?.kind==="role-edit"&&(0,a.jsx)(jt,{mode:"edit",onClose:L,onDone:O,organizationId:r,role:n.role}),e[195]=n,e[196]=r,e[197]=O,e[198]=We):We=e[198];let et;e[199]!==n||e[200]!==O?(et=n?.kind==="confirm"&&(0,a.jsx)(Ut,{action:n.action,message:n.message,onClose:L,onDone:O,testId:n.testId,title:n.title}),e[199]=n,e[200]=O,e[201]=et):et=e[201];let gt;return e[202]!==$e||e[203]!==Re||e[204]!==Ue||e[205]!==qe||e[206]!==Be||e[207]!==He||e[208]!==Ke||e[209]!==Te||e[210]!==Xe||e[211]!==Ye||e[212]!==Ze||e[213]!==Ge||e[214]!==Qe||e[215]!==Ve||e[216]!==We||e[217]!==et?(gt=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"org-detail",children:[$e,Re,Ue,qe,Be,He,Ke,Te,Xe,Ye,Ze,Ge,Qe,Ve,We,et]}),e[202]=$e,e[203]=Re,e[204]=Ue,e[205]=qe,e[206]=Be,e[207]=He,e[208]=Ke,e[209]=Te,e[210]=Xe,e[211]=Ye,e[212]=Ze,e[213]=Ge,e[214]=Qe,e[215]=Ve,e[216]=We,e[217]=et,e[218]=gt):gt=e[218],gt},"Qt");function Qt(t){return(0,a.jsx)(se,{children:t.head},t.head)}i(Qt,"Gt");function Vt(t){return(0,a.jsx)("span",{className:"font-mono text-xs",children:S(t.userId)})}i(Vt,"Vt");function Wt(t){return S(t.role)}i(Wt,"Wt");function er(t){return S(t.email)}i(er,"Xt");function tr(t){return S(t.role)}i(tr,"Yt");function rr(t){return S(t.status)}i(rr,"Zt");function or(t){return S(t.id)}i(or,"er");function ar(t){return S(t.name)}i(ar,"tr");function nr(t){return(0,a.jsx)("span",{className:"font-mono text-xs",children:S(t.userId)})}i(nr,"rr");function lr(t){return S(t.role)}i(lr,"or");function ir(t){return S(t.permission)}i(ir,"nr");var xr=i(()=>{let t=(0,Y.c)(62),e=re(),r=Z(),{config:d,ready:u}=Ft(),l=d.capabilities.organization,[o,n]=(0,J.useState)(null),[s,m]=(0,J.useState)(null),c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=["lunora-auth-orgs"],t[0]=c):c=t[0];let v;t[1]!==e?(v=i(()=>e.listAuthOrganizations({limit:100}),"p"),t[1]=e,t[2]=v):v=t[2];let g;t[3]!==l?(g={enabled:l},t[3]=l,t[4]=g):g=t[4];let h=ue(c,v,g),w=h.data?.rows??null,f;t[5]!==h?(f=i(()=>{h.refetch()},"b"),t[5]=h,t[6]=f):f=t[6],At(f,l);let y;t[7]===Symbol.for("react.memo_cache_sentinel")?(y=i(()=>{m(null)},"v"),t[7]=y):y=t[7];let z=y,p;t[8]!==h?(p=i(()=>{h.refetch()},"f"),t[8]=h,t[9]=p):p=t[9];let x=p,b;t[10]===Symbol.for("react.memo_cache_sentinel")?(b=i(F=>{n(F)},"h"),t[10]=b):b=t[10];let k=b;if(u&&!l){let F;t[11]!==r?(F=r("Enable the organization() plugin in your auth config to manage organizations here."),t[11]=r,t[12]=F):F=t[12];let M;t[13]!==r?(M=r("Organizations are not enabled."),t[13]=r,t[14]=M):M=t[14];let H;return t[15]!==F||t[16]!==M?(H=(0,a.jsx)(ce,{description:F,testId:"org-disabled",title:M}),t[15]=F,t[16]=M,t[17]=H):H=t[17],H}let I;t[18]!==r?(I=r("Organizations"),t[18]=r,t[19]=I):I=t[19];let C;t[20]!==I?(C=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:I}),t[20]=I,t[21]=C):C=t[21];let N;t[22]===Symbol.for("react.memo_cache_sentinel")?(N=i(()=>{m({kind:"create"})},"z"),t[22]=N):N=t[22];let D;t[23]!==r?(D=r("New organization"),t[23]=r,t[24]=D):D=t[24];let _;t[25]!==D?(_=(0,a.jsx)(P,{"data-testid":"org-new",onClick:N,size:"sm",type:"button",children:D}),t[25]=D,t[26]=_):_=t[26];let A;t[27]!==_||t[28]!==C?(A=(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[C,_]}),t[27]=_,t[28]=C,t[29]=A):A=t[29];let $;t[30]!==h.error?($=h.error!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-error",role:"alert",children:h.error}),t[30]=h.error,t[31]=$):$=t[31];let R;t[32]!==w||t[33]!==r?(R=w!==null&&w.length===0&&(0,a.jsx)(ce,{testId:"org-empty",title:r("No organizations.")}),t[32]=w,t[33]=r,t[34]=R):R=t[34];let U;t[35]!==w||t[36]!==o||t[37]!==r?(U=w!==null&&w.length>0&&(0,a.jsx)(xt,{className:"overflow-hidden py-0",children:(0,a.jsx)(wt,{className:"px-0",children:(0,a.jsxs)(zt,{"data-testid":"org-table",children:[(0,a.jsx)(kt,{children:(0,a.jsxs)(tt,{children:[(0,a.jsx)(se,{children:r("id")}),(0,a.jsx)(se,{children:r("name")}),(0,a.jsx)(se,{children:r("slug")}),(0,a.jsx)(se,{children:r("created")}),(0,a.jsx)(se,{"aria-label":r("Actions")})]})}),(0,a.jsx)(Nt,{children:w.map(F=>{let M=S(F.id);return(0,a.jsxs)(tt,{"data-testid":`org-row-${M}`,children:[(0,a.jsx)(de,{className:"font-mono text-xs",children:M}),(0,a.jsx)(de,{children:S(F.name)}),(0,a.jsx)(de,{children:S(F.slug)}),(0,a.jsx)(de,{className:"text-muted-foreground tabular-nums",children:$t(F.createdAt)}),(0,a.jsx)(de,{children:(0,a.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,a.jsx)(P,{"aria-pressed":o===M,"data-testid":`org-select-${M}`,onClick:i(()=>{k(M)},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Manage")}),(0,a.jsx)(P,{"data-testid":`org-edit-${M}`,onClick:i(()=>{m({kind:"edit",org:F})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Edit")}),(0,a.jsx)(P,{"data-testid":`org-delete-${M}`,onClick:i(()=>{m({kind:"delete",org:F})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Delete")})]})})]},M)})})]})})}),t[35]=w,t[36]=o,t[37]=r,t[38]=U):U=t[38];let K;t[39]!==d.organization||t[40]!==o?(K=o!==null&&(0,a.jsx)(Gt,{organizationId:o,rolesEnabled:d.organization.roles,teamsEnabled:d.organization.teams}),t[39]=d.organization,t[40]=o,t[41]=K):K=t[41];let q;t[42]!==s?.kind||t[43]!==x?(q=s?.kind==="create"&&(0,a.jsx)(Et,{mode:"create",onClose:z,onDone:x}),t[42]=s?.kind,t[43]=x,t[44]=q):q=t[44];let j;t[45]!==s||t[46]!==x?(j=s?.kind==="edit"&&(0,a.jsx)(Et,{mode:"edit",onClose:z,onDone:x,org:s.org}),t[45]=s,t[46]=x,t[47]=j):j=t[47];let B;t[48]!==e||t[49]!==s||t[50]!==x||t[51]!==r?(B=s?.kind==="delete"&&(0,a.jsx)(Ut,{action:i(async()=>{let F=S(s.org.id);await e.deleteAuthOrganization({organizationId:F}),n(M=>M===F?null:M)},"action"),message:r("Delete this organization? Its members, invitations, teams, and custom roles are removed. This cannot be undone."),onClose:z,onDone:x,testId:"org-delete",title:r("Delete organization")}),t[48]=e,t[49]=s,t[50]=x,t[51]=r,t[52]=B):B=t[52];let T;return t[53]!==A||t[54]!==$||t[55]!==R||t[56]!==U||t[57]!==K||t[58]!==q||t[59]!==j||t[60]!==B?(T=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-organizations",children:[A,$,R,U,K,q,j,B]}),t[53]=A,t[54]=$,t[55]=R,t[56]=U,t[57]=K,t[58]=q,t[59]=j,t[60]=B,t[61]=T):T=t[61],T},"Cr");export{xr as OrganizationsPanel};
@@ -1 +1 @@
1
- import{a as d,e as m,f as b,g as i,h as u,j as c}from"./chunk-UHHTEBC3.js";var n=m(i(),1),p=m(b(),1);var s=m(u(),1);function h(o){let e=(0,n.c)(8),t,a;e[0]!==o?({className:t,...a}=o,e[0]=o,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=c("w-full caption-bottom text-xs",t),e[3]=t,e[4]=l):l=e[4];let r;return e[5]!==a||e[6]!==l?(r=(0,s.jsx)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto overflow-y-clip",children:(0,s.jsx)("table",{"data-slot":"table",className:l,...a})}),e[5]=a,e[6]=l,e[7]=r):r=e[7],r}d(h,"u");function x(o){let e=(0,n.c)(8),t,a;e[0]!==o?({className:t,...a}=o,e[0]=o,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=c("bg-muted/50 [&_tr]:border-b",t),e[3]=t,e[4]=l):l=e[4];let r;return e[5]!==a||e[6]!==l?(r=(0,s.jsx)("thead",{"data-slot":"table-header",className:l,...a}),e[5]=a,e[6]=l,e[7]=r):r=e[7],r}d(x,"p");function N(o){let e=(0,n.c)(8),t,a;e[0]!==o?({className:t,...a}=o,e[0]=o,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=c("[&_tr:last-child]:border-0",t),e[3]=t,e[4]=l):l=e[4];let r;return e[5]!==a||e[6]!==l?(r=(0,s.jsx)("tbody",{"data-slot":"table-body",className:l,...a}),e[5]=a,e[6]=l,e[7]=r):r=e[7],r}d(N,"f");function w(o){let e=(0,n.c)(8),t,a;e[0]!==o?({className:t,...a}=o,e[0]=o,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=c("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",t),e[3]=t,e[4]=l):l=e[4];let r;return e[5]!==a||e[6]!==l?(r=(0,s.jsx)("tr",{"data-slot":"table-row",className:l,...a}),e[5]=a,e[6]=l,e[7]=r):r=e[7],r}d(w,"h");function g(o){let e=(0,n.c)(8),t,a;e[0]!==o?({className:t,...a}=o,e[0]=o,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=c("h-9 border-e border-border px-3 text-start align-middle font-mono text-[11px] font-medium tracking-wide whitespace-nowrap text-muted-foreground uppercase last:border-e-0 [&:has([role=checkbox])]:pe-0",t),e[3]=t,e[4]=l):l=e[4];let r;return e[5]!==a||e[6]!==l?(r=(0,s.jsx)("th",{"data-slot":"table-head",className:l,...a}),e[5]=a,e[6]=l,e[7]=r):r=e[7],r}d(g,"x");function v(o){let e=(0,n.c)(8),t,a;e[0]!==o?({className:t,...a}=o,e[0]=o,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=c("border-e border-border px-3 py-1.5 align-middle whitespace-nowrap last:border-e-0 [&:has([role=checkbox])]:pe-0",t),e[3]=t,e[4]=l):l=e[4];let r;return e[5]!==a||e[6]!==l?(r=(0,s.jsx)("td",{"data-slot":"table-cell",className:l,...a}),e[5]=a,e[6]=l,e[7]=r):r=e[7],r}d(v,"N");export{h as a,x as b,N as c,w as d,g as e,v as f};
1
+ import{a as d,e as m,f as b,g as i,h as u,j as c}from"./chunk-3XIESWL4.js";var n=m(i(),1),p=m(b(),1);var s=m(u(),1);function h(o){let e=(0,n.c)(8),t,a;e[0]!==o?({className:t,...a}=o,e[0]=o,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=c("w-full caption-bottom text-xs",t),e[3]=t,e[4]=l):l=e[4];let r;return e[5]!==a||e[6]!==l?(r=(0,s.jsx)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto overflow-y-clip",children:(0,s.jsx)("table",{"data-slot":"table",className:l,...a})}),e[5]=a,e[6]=l,e[7]=r):r=e[7],r}d(h,"u");function x(o){let e=(0,n.c)(8),t,a;e[0]!==o?({className:t,...a}=o,e[0]=o,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=c("bg-muted/50 [&_tr]:border-b",t),e[3]=t,e[4]=l):l=e[4];let r;return e[5]!==a||e[6]!==l?(r=(0,s.jsx)("thead",{"data-slot":"table-header",className:l,...a}),e[5]=a,e[6]=l,e[7]=r):r=e[7],r}d(x,"p");function N(o){let e=(0,n.c)(8),t,a;e[0]!==o?({className:t,...a}=o,e[0]=o,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=c("[&_tr:last-child]:border-0",t),e[3]=t,e[4]=l):l=e[4];let r;return e[5]!==a||e[6]!==l?(r=(0,s.jsx)("tbody",{"data-slot":"table-body",className:l,...a}),e[5]=a,e[6]=l,e[7]=r):r=e[7],r}d(N,"f");function w(o){let e=(0,n.c)(8),t,a;e[0]!==o?({className:t,...a}=o,e[0]=o,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=c("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",t),e[3]=t,e[4]=l):l=e[4];let r;return e[5]!==a||e[6]!==l?(r=(0,s.jsx)("tr",{"data-slot":"table-row",className:l,...a}),e[5]=a,e[6]=l,e[7]=r):r=e[7],r}d(w,"h");function g(o){let e=(0,n.c)(8),t,a;e[0]!==o?({className:t,...a}=o,e[0]=o,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=c("h-9 border-e border-border px-3 text-start align-middle font-mono text-[11px] font-medium tracking-wide whitespace-nowrap text-muted-foreground uppercase last:border-e-0 [&:has([role=checkbox])]:pe-0",t),e[3]=t,e[4]=l):l=e[4];let r;return e[5]!==a||e[6]!==l?(r=(0,s.jsx)("th",{"data-slot":"table-head",className:l,...a}),e[5]=a,e[6]=l,e[7]=r):r=e[7],r}d(g,"x");function v(o){let e=(0,n.c)(8),t,a;e[0]!==o?({className:t,...a}=o,e[0]=o,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=c("border-e border-border px-3 py-1.5 align-middle whitespace-nowrap last:border-e-0 [&:has([role=checkbox])]:pe-0",t),e[3]=t,e[4]=l):l=e[4];let r;return e[5]!==a||e[6]!==l?(r=(0,s.jsx)("td",{"data-slot":"table-cell",className:l,...a}),e[5]=a,e[6]=l,e[7]=r):r=e[7],r}d(v,"N");export{h as a,x as b,N as c,w as d,g as e,v as f};
@@ -1,2 +1,2 @@
1
- import{a as B}from"./chunk-SNDYNCAA.js";import"./chunk-HA34GYEX.js";import{a as k}from"./chunk-CZEUVNCQ.js";import{a as D}from"./chunk-SA6MBPBL.js";import"./chunk-YNBJ6ICE.js";import{a as P}from"./chunk-Q34MSC2F.js";import"./chunk-4AYEV5UN.js";import{b as q}from"./chunk-SKJZDOHG.js";import{R as I}from"./chunk-7Z5QEFR4.js";import"./chunk-46IB4C4Q.js";import{c}from"./chunk-UY2Y5CXB.js";import"./chunk-ZFWEPGWG.js";import{b as H}from"./chunk-K5PFWU5J.js";import"./chunk-4FNHHFWR.js";import{a as f}from"./chunk-GXZAXNZI.js";import{f as A}from"./chunk-KJTLW5W2.js";import"./chunk-UREY4GLG.js";import{a as O}from"./chunk-6OKDCV7J.js";import{d as F,f as v,g as N,h as w,m as y,o as _,q as C}from"./chunk-KLLYGWNF.js";import"./chunk-UDZY7MKE.js";import{a as s,e as $,f as se,h as de,j as E}from"./chunk-UHHTEBC3.js";var l=$(se(),1);var e=$(de(),1);function le({className:r,orientation:h="horizontal",...a}){return(0,e.jsx)(k,{"data-slot":"separator",orientation:h,className:E("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",r),...a})}s(le,"de");var oe=v(f.clearCapturedMail),ne=v(f.sendTestMail),ce=/https?:\/\/[^\s"'<>)]+/i,K=s(r=>r===void 0?void 0:ce.exec(r)?.[0],"S"),me=s(r=>{if(r!==void 0)return K(r.html)??K(r.text)},"ce"),ue=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,he=s(r=>`${ue}${r}`,"ue"),x=s(r=>r===void 0?"":Array.isArray(r)?r.join(", "):r,"f"),Le=s(({limit:r=100})=>{let h=A(),a=F(),{data:j,error:T,errorSource:R,isLoading:U,refetch:g}=q(f.getCapturedMail,{limit:r}),[z,p]=(0,l.useState)(null),[M,S]=(0,l.useState)(null),[m,W]=(0,l.useState)("html"),[b,G]=(0,l.useState)(""),o=(0,l.useMemo)(()=>j?.entries??[],[j]),L=T??z,J=T===null?z:R,Q=s(async()=>{p(null);try{await h.query(oe,{},N("")),S(null),g()}catch(t){p(w(t))}},"I"),V=s(async()=>{p(null);try{await h.query(ne,{},N("")),g()}catch(t){p(w(t))}},"_");D(()=>{g()},!0);let X=s(()=>{y(Q())},"q"),Y=s(()=>{y(V())},"P"),Z=s(t=>{G(t.currentTarget.value)},"D"),ee=s(t=>{let{id:d}=t.currentTarget.dataset;d!==void 0&&S(d)},"R"),te=s(t=>{let d=t.currentTarget.dataset.tab;(d==="headers"||d==="html"||d==="text")&&W(d)},"B"),ae=s(t=>a(t==="html"?"HTML":t==="text"?"Plain text":"Headers"),"K"),u=(0,l.useMemo)(()=>{let t=b.trim().toLowerCase();return t===""?o:o.filter(d=>`${d.subject} ${x(d.to)}`.toLowerCase().includes(t))},[o,b]),i=(0,l.useMemo)(()=>{if(u.length!==0)return u.find(t=>t.id===M)??u[0]},[u,M]),n=me(i),re=s(()=>{n!==void 0&&_(n)},"U"),ie=s(()=>{n!==void 0&&"window"in globalThis&&globalThis.window.open(n,"_blank","noopener")},"W");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(c,{"data-testid":"mail-send-test",onClick:Y,size:"sm",type:"button",variant:"outline",children:a("Send test")}),(0,e.jsx)(c,{"data-testid":"mail-clear",disabled:o.length===0,onClick:X,size:"sm",type:"button",variant:"outline",children:a("Clear inbox")}),o.length>0&&(0,e.jsx)(H,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:a("{count} messages",{count:o.length})})]}),L!==null&&(0,e.jsx)(P,{error:J,testId:"mail-error"}),L===null&&!U&&o.length===0&&(0,e.jsx)(O,{description:a("Email your app sends in dev is captured here \u2014 nothing is delivered."),icon:(0,e.jsxs)("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 5h16v14H4z"}),(0,e.jsx)("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:a("No captured email.")}),o.length>0&&(0,e.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,e.jsx)(I,{"aria-label":a("Search messages"),"data-testid":"mail-search",onChange:Z,placeholder:a("Filter messages"),type:"search",value:b}),(0,e.jsx)(B,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:(0,e.jsx)("ul",{className:"divide-y",children:u.map(t=>{let d=t.id===i?.id;return(0,e.jsx)("li",{children:(0,e.jsxs)("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${d?"bg-muted":""}`,"data-active":d,"data-id":t.id,"data-testid":"mail-list-item",onClick:ee,type:"button",children:[(0,e.jsx)("span",{className:"w-full truncate font-medium",children:t.subject||a("(no subject)")}),(0,e.jsx)("span",{className:"w-full truncate text-xs text-muted-foreground",children:x(t.to)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground tabular-nums",children:C(t.capturedAt,"\u2014")})]})},t.id)})})})]}),i!==void 0&&(0,e.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:i.subject||a("(no subject)")}),(0,e.jsxs)("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[(0,e.jsx)("dt",{children:a("From")}),(0,e.jsx)("dd",{className:"truncate font-mono",children:i.from??"\u2014"}),(0,e.jsx)("dt",{children:a("To")}),(0,e.jsx)("dd",{className:"truncate font-mono",children:x(i.to)}),i.cc!==void 0&&i.cc.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("dt",{children:a("Cc")}),(0,e.jsx)("dd",{className:"truncate font-mono",children:x(i.cc)})]}),(0,e.jsx)("dt",{children:a("Sent")}),(0,e.jsx)("dd",{className:"tabular-nums",children:C(i.capturedAt,"\u2014")})]})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[(0,e.jsx)(c,{"data-testid":"mail-copy-link",disabled:n===void 0,onClick:re,size:"sm",type:"button",variant:"outline",children:a("Copy link")}),(0,e.jsx)(c,{"data-testid":"mail-open-link",disabled:n===void 0,onClick:ie,size:"sm",type:"button",variant:"outline",children:a("Open in new tab")})]}),(0,e.jsx)(le,{}),(0,e.jsx)("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(t=>(0,e.jsx)(c,{"aria-selected":m===t,"data-tab":t,"data-testid":`mail-tab-${t}`,onClick:te,role:"tab",size:"sm",type:"button",variant:m===t?"secondary":"ghost",children:ae(t)},t))}),(0,e.jsxs)("div",{className:"min-h-[12rem]",children:[m==="html"&&(i.html===void 0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:a("No HTML body.")}):(0,e.jsx)("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:he(i.html),title:a("Email preview")})),m==="text"&&(i.text===void 0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:a("No text body.")}):(0,e.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:i.text})),m==="headers"&&(i.headers===void 0||Object.keys(i.headers).length===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:a("No headers.")}):(0,e.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(i.headers).map(([t,d])=>`${t}: ${d}`).join(`
1
+ import{a as B}from"./chunk-LEDWUPXM.js";import"./chunk-2PJNAWB3.js";import{a as k}from"./chunk-IC4L6G56.js";import{a as D}from"./chunk-54MMVNPT.js";import"./chunk-BGBLQ563.js";import{a as P}from"./chunk-UNUU7CJJ.js";import"./chunk-XXQUMVWH.js";import{b as q}from"./chunk-OWADN6BI.js";import{R as I}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as H}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as f}from"./chunk-GXZAXNZI.js";import{f as A}from"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{a as O}from"./chunk-XQCVZAGU.js";import{d as F,f as v,g as N,h as w,m as y,o as _,q as C}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as s,e as $,f as se,h as de,j as E}from"./chunk-3XIESWL4.js";var l=$(se(),1);var e=$(de(),1);function le({className:r,orientation:h="horizontal",...a}){return(0,e.jsx)(k,{"data-slot":"separator",orientation:h,className:E("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",r),...a})}s(le,"de");var oe=v(f.clearCapturedMail),ne=v(f.sendTestMail),ce=/https?:\/\/[^\s"'<>)]+/i,K=s(r=>r===void 0?void 0:ce.exec(r)?.[0],"S"),me=s(r=>{if(r!==void 0)return K(r.html)??K(r.text)},"ce"),ue=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,he=s(r=>`${ue}${r}`,"ue"),x=s(r=>r===void 0?"":Array.isArray(r)?r.join(", "):r,"f"),Le=s(({limit:r=100})=>{let h=A(),a=F(),{data:j,error:T,errorSource:R,isLoading:U,refetch:g}=q(f.getCapturedMail,{limit:r}),[z,p]=(0,l.useState)(null),[M,S]=(0,l.useState)(null),[m,W]=(0,l.useState)("html"),[b,G]=(0,l.useState)(""),o=(0,l.useMemo)(()=>j?.entries??[],[j]),L=T??z,J=T===null?z:R,Q=s(async()=>{p(null);try{await h.query(oe,{},N("")),S(null),g()}catch(t){p(w(t))}},"I"),V=s(async()=>{p(null);try{await h.query(ne,{},N("")),g()}catch(t){p(w(t))}},"_");D(()=>{g()},!0);let X=s(()=>{y(Q())},"q"),Y=s(()=>{y(V())},"P"),Z=s(t=>{G(t.currentTarget.value)},"D"),ee=s(t=>{let{id:d}=t.currentTarget.dataset;d!==void 0&&S(d)},"R"),te=s(t=>{let d=t.currentTarget.dataset.tab;(d==="headers"||d==="html"||d==="text")&&W(d)},"B"),ae=s(t=>a(t==="html"?"HTML":t==="text"?"Plain text":"Headers"),"K"),u=(0,l.useMemo)(()=>{let t=b.trim().toLowerCase();return t===""?o:o.filter(d=>`${d.subject} ${x(d.to)}`.toLowerCase().includes(t))},[o,b]),i=(0,l.useMemo)(()=>{if(u.length!==0)return u.find(t=>t.id===M)??u[0]},[u,M]),n=me(i),re=s(()=>{n!==void 0&&_(n)},"U"),ie=s(()=>{n!==void 0&&"window"in globalThis&&globalThis.window.open(n,"_blank","noopener")},"W");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(c,{"data-testid":"mail-send-test",onClick:Y,size:"sm",type:"button",variant:"outline",children:a("Send test")}),(0,e.jsx)(c,{"data-testid":"mail-clear",disabled:o.length===0,onClick:X,size:"sm",type:"button",variant:"outline",children:a("Clear inbox")}),o.length>0&&(0,e.jsx)(H,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:a("{count} messages",{count:o.length})})]}),L!==null&&(0,e.jsx)(P,{error:J,testId:"mail-error"}),L===null&&!U&&o.length===0&&(0,e.jsx)(O,{description:a("Email your app sends in dev is captured here \u2014 nothing is delivered."),icon:(0,e.jsxs)("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 5h16v14H4z"}),(0,e.jsx)("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:a("No captured email.")}),o.length>0&&(0,e.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,e.jsx)(I,{"aria-label":a("Search messages"),"data-testid":"mail-search",onChange:Z,placeholder:a("Filter messages"),type:"search",value:b}),(0,e.jsx)(B,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:(0,e.jsx)("ul",{className:"divide-y",children:u.map(t=>{let d=t.id===i?.id;return(0,e.jsx)("li",{children:(0,e.jsxs)("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${d?"bg-muted":""}`,"data-active":d,"data-id":t.id,"data-testid":"mail-list-item",onClick:ee,type:"button",children:[(0,e.jsx)("span",{className:"w-full truncate font-medium",children:t.subject||a("(no subject)")}),(0,e.jsx)("span",{className:"w-full truncate text-xs text-muted-foreground",children:x(t.to)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground tabular-nums",children:C(t.capturedAt,"\u2014")})]})},t.id)})})})]}),i!==void 0&&(0,e.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:i.subject||a("(no subject)")}),(0,e.jsxs)("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[(0,e.jsx)("dt",{children:a("From")}),(0,e.jsx)("dd",{className:"truncate font-mono",children:i.from??"\u2014"}),(0,e.jsx)("dt",{children:a("To")}),(0,e.jsx)("dd",{className:"truncate font-mono",children:x(i.to)}),i.cc!==void 0&&i.cc.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("dt",{children:a("Cc")}),(0,e.jsx)("dd",{className:"truncate font-mono",children:x(i.cc)})]}),(0,e.jsx)("dt",{children:a("Sent")}),(0,e.jsx)("dd",{className:"tabular-nums",children:C(i.capturedAt,"\u2014")})]})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[(0,e.jsx)(c,{"data-testid":"mail-copy-link",disabled:n===void 0,onClick:re,size:"sm",type:"button",variant:"outline",children:a("Copy link")}),(0,e.jsx)(c,{"data-testid":"mail-open-link",disabled:n===void 0,onClick:ie,size:"sm",type:"button",variant:"outline",children:a("Open in new tab")})]}),(0,e.jsx)(le,{}),(0,e.jsx)("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(t=>(0,e.jsx)(c,{"aria-selected":m===t,"data-tab":t,"data-testid":`mail-tab-${t}`,onClick:te,role:"tab",size:"sm",type:"button",variant:m===t?"secondary":"ghost",children:ae(t)},t))}),(0,e.jsxs)("div",{className:"min-h-[12rem]",children:[m==="html"&&(i.html===void 0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:a("No HTML body.")}):(0,e.jsx)("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:he(i.html),title:a("Email preview")})),m==="text"&&(i.text===void 0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:a("No text body.")}):(0,e.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:i.text})),m==="headers"&&(i.headers===void 0||Object.keys(i.headers).length===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:a("No headers.")}):(0,e.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(i.headers).map(([t,d])=>`${t}: ${d}`).join(`
2
2
  `)}))]})]})]})]})},"ze");export{Le as MailPanel};
@@ -1 +1 @@
1
- import{b as D,c as f,d as E,f as I}from"./chunk-KJTLW5W2.js";import{f as p,g as y,h as P,m as b}from"./chunk-KLLYGWNF.js";import{a as s,e as T,f as Q,g as S}from"./chunk-UHHTEBC3.js";var g=T(S(),1);var d=T(Q(),1);var h=s((e,r,o)=>["lunora-admin",e,r,o.trim()],"y");function L(e,r,o={}){let{enabled:t=!0,keepPreviousData:n=!1,staleTime:i=0}=o,a=E({enabled:t,queryFn:r,placeholderData:n?D:void 0,queryKey:e,staleTime:i});return{data:a.data,error:a.error?P(a.error):a.error,errorSource:a.error??void 0,isLoading:a.isLoading,liveError:void 0,refetch:s(()=>{b(a.refetch())},"refetch")}}s(L,"N");function O(e,r,o={}){let t=I(),n=f(),{enabled:i=!0,keepPreviousData:a=!1,live:u=!1,shardKey:l="",staleTime:k}=o,m=h(e,r,l),q=L(m,()=>t.query(p(e),r,y(l)),{enabled:i,keepPreviousData:a,staleTime:k??(u?Number.POSITIVE_INFINITY:0)}),[K,v]=(0,d.useState)(void 0),N=JSON.stringify(m);return(0,d.useEffect)(()=>{if(!(!i||!u))return v(void 0),t.subscribe(p(e),r,c=>{v(void 0),n.setQueryData(m,c)},{...y(l),onError:s(c=>{v(c.message)},"onError")})},[N,i,u]),{...q,liveError:i&&u?K:void 0}}s(O,"_");var C=s(()=>{let e=(0,g.c)(2),r=f(),o;return e[0]!==r?(o=s((t,n,i)=>{let a=n===void 0?["lunora-admin",t]:h(t,n,i??"");b(r.invalidateQueries({queryKey:a}))},"a"),e[0]=r,e[1]=o):o=e[1],o},"x");export{L as a,O as b,C as c};
1
+ import{b as D,c as f,d as E,f as I}from"./chunk-LWECXQWP.js";import{f as p,g as y,h as P,m as b}from"./chunk-4CGALXS3.js";import{a as s,e as T,f as Q,g as S}from"./chunk-3XIESWL4.js";var g=T(S(),1);var d=T(Q(),1);var h=s((e,r,o)=>["lunora-admin",e,r,o.trim()],"y");function L(e,r,o={}){let{enabled:t=!0,keepPreviousData:n=!1,staleTime:i=0}=o,a=E({enabled:t,queryFn:r,placeholderData:n?D:void 0,queryKey:e,staleTime:i});return{data:a.data,error:a.error?P(a.error):a.error,errorSource:a.error??void 0,isLoading:a.isLoading,liveError:void 0,refetch:s(()=>{b(a.refetch())},"refetch")}}s(L,"N");function O(e,r,o={}){let t=I(),n=f(),{enabled:i=!0,keepPreviousData:a=!1,live:u=!1,shardKey:l="",staleTime:k}=o,m=h(e,r,l),q=L(m,()=>t.query(p(e),r,y(l)),{enabled:i,keepPreviousData:a,staleTime:k??(u?Number.POSITIVE_INFINITY:0)}),[K,v]=(0,d.useState)(void 0),N=JSON.stringify(m);return(0,d.useEffect)(()=>{if(!(!i||!u))return v(void 0),t.subscribe(p(e),r,c=>{v(void 0),n.setQueryData(m,c)},{...y(l),onError:s(c=>{v(c.message)},"onError")})},[N,i,u]),{...q,liveError:i&&u?K:void 0}}s(O,"_");var C=s(()=>{let e=(0,g.c)(2),r=f(),o;return e[0]!==r?(o=s((t,n,i)=>{let a=n===void 0?["lunora-admin",t]:h(t,n,i??"");b(r.invalidateQueries({queryKey:a}))},"a"),e[0]=r,e[1]=o):o=e[1],o},"x");export{L as a,O as b,C as c};
@@ -1 +1 @@
1
- import{a as D}from"./chunk-SA6MBPBL.js";import{a as B}from"./chunk-SKJZDOHG.js";import{a as q,b as E,c as M,d as S,e as r,f as s}from"./chunk-Q5WXTZWX.js";import{a as A,e as L}from"./chunk-JKPK25JO.js";import{b as x}from"./chunk-K5PFWU5J.js";import"./chunk-4FNHHFWR.js";import{f as W}from"./chunk-KJTLW5W2.js";import"./chunk-UREY4GLG.js";import{a as _}from"./chunk-6OKDCV7J.js";import{d as z}from"./chunk-KLLYGWNF.js";import"./chunk-UDZY7MKE.js";import{a as R,e as O,g as $,h as I}from"./chunk-UHHTEBC3.js";var F=O($(),1);var n=O(I(),1);var J=2e3,Q=new Set(["open"]),re=R(G=>{let e=(0,F.c)(41),{read:y}=G,t=z(),j=W(),v;e[0]!==j||e[1]!==y?(v=R(()=>Promise.resolve(y?y():j.debug()),"S"),e[0]=j,e[1]=y,e[2]=v):v=e[2];let H=v,K=y?"injected":"live",b;e[3]!==K?(b=["lunora-studio","sync-client-debug",K],e[3]=K,e[4]=b):b=e[4];let{data:c,refetch:Y}=B(b,H);if(D(Y,!0,J),!c){let i;e[5]!==t?(i=t("Reading the sync client's state\u2026"),e[5]=t,e[6]=i):i=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let T;return e[9]!==i||e[10]!==g?(T=(0,n.jsx)(A,{children:(0,n.jsx)(L,{children:(0,n.jsx)(_,{description:i,title:g})})}),e[9]=i,e[10]=g,e[11]=T):T=e[11],T}let{pendingWrites:k,shards:N,subscriptions:w}=c,l;e[12]!==t?(l=t("This Studio session's sync client"),e[12]=t,e[13]=l):l=e[13];let a;e[14]!==l?(a=(0,n.jsx)("span",{className:"text-sm font-medium",children:l}),e[14]=l,e[15]=a):a=e[15];let P=c.connectionStatus==="connected"?"default":"secondary",o;e[16]!==c.connectionStatus||e[17]!==P?(o=(0,n.jsx)(x,{variant:P,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=P,e[18]=o):o=e[18];let d;e[19]!==k||e[20]!==t?(d=k>0?(0,n.jsx)(x,{variant:"secondary",children:t("{count} pending writes",{count:k})}):null,e[19]=k,e[20]=t,e[21]=d):d=e[21];let h;e[22]!==a||e[23]!==o||e[24]!==d?(h=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[a,o,d]}),e[22]=a,e[23]=o,e[24]=d,e[25]=h):h=e[25];let u;e[26]!==t?(u=t("Reads client.debug() for the client running in this page \u2014 not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=u):u=e[27];let m;e[28]!==u?(m=(0,n.jsx)("p",{className:"text-muted-foreground text-xs",children:u}),e[28]=u,e[29]=m):m=e[29];let p;e[30]!==N||e[31]!==t?(p=N.length===0?(0,n.jsx)(_,{description:t("No shard connection has been opened yet."),title:t("No shards")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(E,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Shard")}),(0,n.jsx)(r,{children:t("Socket")}),(0,n.jsx)(r,{children:t("Confirmed watermark")})]})}),(0,n.jsx)(M,{children:N.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{children:i.shardKey??t("(default)")}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:Q.has(i.wsState)?"default":"secondary",children:i.wsState})}),(0,n.jsx)(s,{children:i.confirmedMutationWatermark})]},i.shardKey??"__default__"))})]}),e[30]=N,e[31]=t,e[32]=p):p=e[32];let f;e[33]!==w||e[34]!==t?(f=w.length===0?(0,n.jsx)(_,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(E,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Subscription")}),(0,n.jsx)(r,{children:t("Kind")}),(0,n.jsx)(r,{children:t("Acked")}),(0,n.jsx)(r,{children:t("Cursor")}),(0,n.jsx)(r,{children:t("Pending overlays")})]})}),(0,n.jsx)(M,{children:w.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{className:"font-mono text-xs",children:i.functionPath}),(0,n.jsx)(s,{children:i.kind}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:i.acked?"default":"secondary",children:i.acked?t("yes"):t("no")})}),(0,n.jsx)(s,{children:i.serverCursor??"\u2014"}),(0,n.jsx)(s,{children:i.pendingOptimisticLayers})]},i.id))})]}),e[33]=w,e[34]=t,e[35]=f):f=e[35];let C;return e[36]!==m||e[37]!==p||e[38]!==f||e[39]!==h?(C=(0,n.jsx)(A,{children:(0,n.jsxs)(L,{className:"flex flex-col gap-4",children:[h,m,p,f]})}),e[36]=m,e[37]=p,e[38]=f,e[39]=h,e[40]=C):C=e[40],C},"re");export{re as default};
1
+ import{a as D}from"./chunk-54MMVNPT.js";import{a as B}from"./chunk-OWADN6BI.js";import{a as q,b as E,c as M,d as S,e as r,f as s}from"./chunk-MIQTKZAR.js";import{a as A,e as L}from"./chunk-UZERI5YC.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{f as W}from"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{a as _}from"./chunk-XQCVZAGU.js";import{d as z}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as R,e as O,g as $,h as I}from"./chunk-3XIESWL4.js";var F=O($(),1);var n=O(I(),1);var J=2e3,Q=new Set(["open"]),re=R(G=>{let e=(0,F.c)(41),{read:y}=G,t=z(),j=W(),v;e[0]!==j||e[1]!==y?(v=R(()=>Promise.resolve(y?y():j.debug()),"S"),e[0]=j,e[1]=y,e[2]=v):v=e[2];let H=v,K=y?"injected":"live",b;e[3]!==K?(b=["lunora-studio","sync-client-debug",K],e[3]=K,e[4]=b):b=e[4];let{data:c,refetch:Y}=B(b,H);if(D(Y,!0,J),!c){let i;e[5]!==t?(i=t("Reading the sync client's state\u2026"),e[5]=t,e[6]=i):i=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let T;return e[9]!==i||e[10]!==g?(T=(0,n.jsx)(A,{children:(0,n.jsx)(L,{children:(0,n.jsx)(_,{description:i,title:g})})}),e[9]=i,e[10]=g,e[11]=T):T=e[11],T}let{pendingWrites:k,shards:N,subscriptions:w}=c,l;e[12]!==t?(l=t("This Studio session's sync client"),e[12]=t,e[13]=l):l=e[13];let a;e[14]!==l?(a=(0,n.jsx)("span",{className:"text-sm font-medium",children:l}),e[14]=l,e[15]=a):a=e[15];let P=c.connectionStatus==="connected"?"default":"secondary",o;e[16]!==c.connectionStatus||e[17]!==P?(o=(0,n.jsx)(x,{variant:P,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=P,e[18]=o):o=e[18];let d;e[19]!==k||e[20]!==t?(d=k>0?(0,n.jsx)(x,{variant:"secondary",children:t("{count} pending writes",{count:k})}):null,e[19]=k,e[20]=t,e[21]=d):d=e[21];let h;e[22]!==a||e[23]!==o||e[24]!==d?(h=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[a,o,d]}),e[22]=a,e[23]=o,e[24]=d,e[25]=h):h=e[25];let u;e[26]!==t?(u=t("Reads client.debug() for the client running in this page \u2014 not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=u):u=e[27];let m;e[28]!==u?(m=(0,n.jsx)("p",{className:"text-muted-foreground text-xs",children:u}),e[28]=u,e[29]=m):m=e[29];let p;e[30]!==N||e[31]!==t?(p=N.length===0?(0,n.jsx)(_,{description:t("No shard connection has been opened yet."),title:t("No shards")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(E,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Shard")}),(0,n.jsx)(r,{children:t("Socket")}),(0,n.jsx)(r,{children:t("Confirmed watermark")})]})}),(0,n.jsx)(M,{children:N.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{children:i.shardKey??t("(default)")}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:Q.has(i.wsState)?"default":"secondary",children:i.wsState})}),(0,n.jsx)(s,{children:i.confirmedMutationWatermark})]},i.shardKey??"__default__"))})]}),e[30]=N,e[31]=t,e[32]=p):p=e[32];let f;e[33]!==w||e[34]!==t?(f=w.length===0?(0,n.jsx)(_,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(E,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Subscription")}),(0,n.jsx)(r,{children:t("Kind")}),(0,n.jsx)(r,{children:t("Acked")}),(0,n.jsx)(r,{children:t("Cursor")}),(0,n.jsx)(r,{children:t("Pending overlays")})]})}),(0,n.jsx)(M,{children:w.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{className:"font-mono text-xs",children:i.functionPath}),(0,n.jsx)(s,{children:i.kind}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:i.acked?"default":"secondary",children:i.acked?t("yes"):t("no")})}),(0,n.jsx)(s,{children:i.serverCursor??"\u2014"}),(0,n.jsx)(s,{children:i.pendingOptimisticLayers})]},i.id))})]}),e[33]=w,e[34]=t,e[35]=f):f=e[35];let C;return e[36]!==m||e[37]!==p||e[38]!==f||e[39]!==h?(C=(0,n.jsx)(A,{children:(0,n.jsxs)(L,{className:"flex flex-col gap-4",children:[h,m,p,f]})}),e[36]=m,e[37]=p,e[38]=f,e[39]=h,e[40]=C):C=e[40],C},"re");export{re as default};
@@ -1,4 +1,4 @@
1
- import{a as ze}from"./chunk-AKTGRZXN.js";import{a as _e}from"./chunk-VUXJER3D.js";import{a as Ae}from"./chunk-HY46NTNW.js";import"./chunk-6P7HIPUE.js";import"./chunk-PR2SE2MD.js";import"./chunk-CZEUVNCQ.js";import"./chunk-VEFNSN7P.js";import"./chunk-NCCUM26H.js";import"./chunk-PWDMXMRD.js";import"./chunk-YNBJ6ICE.js";import"./chunk-C4O5UR4Y.js";import"./chunk-OTJOI23O.js";import"./chunk-SEDZDNQF.js";import"./chunk-TYTJDFX2.js";import"./chunk-C4VURT57.js";import"./chunk-KSRXMTBV.js";import{a as Le}from"./chunk-4AYEV5UN.js";import{a as Re,b as Te,c as Oe,d as xe,e as De,f as Me}from"./chunk-Q5WXTZWX.js";import"./chunk-KOC5KV3E.js";import{a as Ee}from"./chunk-V66TSUKV.js";import{b as Ie}from"./chunk-UWF5DOGV.js";import{d as oe,e as he,f as fe}from"./chunk-PTTDIYGP.js";import"./chunk-7Z5QEFR4.js";import"./chunk-46IB4C4Q.js";import"./chunk-UY2Y5CXB.js";import"./chunk-ZFWEPGWG.js";import"./chunk-4FNHHFWR.js";import{a as le}from"./chunk-GXZAXNZI.js";import{f as be}from"./chunk-KJTLW5W2.js";import"./chunk-UREY4GLG.js";import{d as K,f as ne,g as re,h as Se,m as X}from"./chunk-KLLYGWNF.js";import"./chunk-UDZY7MKE.js";import{a as s,e as pe,f as Et,g as Lt,h as Rt,j as te}from"./chunk-UHHTEBC3.js";var Y=pe(Lt(),1);var E=pe(Et(),1);var r=pe(Rt(),1);var Tt=["ORDER BY","GROUP BY","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN","EXPLAIN QUERY PLAN","SELECT","DISTINCT","FROM","WHERE","HAVING","LIMIT","OFFSET","JOIN","ON","AND","OR","AS","ASC","DESC","WITH","UNION","EXPLAIN"],Ot=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],se=String.fromCodePoint(0),Dt=new RegExp(`${se}${String.raw`(\d+)`}${se}`,"gu"),Mt=Tt.map(l=>({pattern:new RegExp(String.raw`\b${l.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:l})),_t=Ot.map(l=>({pattern:new RegExp(String.raw`\s+${l.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
1
+ import{a as ze}from"./chunk-7RXOPYR5.js";import{a as _e}from"./chunk-LLXFYRGQ.js";import{a as Ae}from"./chunk-5RF4QDDA.js";import"./chunk-XQGANNLS.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import"./chunk-ESVP44Y3.js";import"./chunk-KYF2E5CJ.js";import"./chunk-7YEFOSPH.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-PF7V3G2Z.js";import"./chunk-4UOFSGUS.js";import"./chunk-ILNELDFC.js";import"./chunk-7LQWFOEU.js";import"./chunk-T6VMSOBB.js";import{a as Le}from"./chunk-XXQUMVWH.js";import{a as Re,b as Te,c as Oe,d as xe,e as De,f as Me}from"./chunk-MIQTKZAR.js";import"./chunk-QBWRC5YX.js";import{a as Ee}from"./chunk-LFXFP4IF.js";import{b as Ie}from"./chunk-GRL5MG3Z.js";import{d as oe,e as he,f as fe}from"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as le}from"./chunk-GXZAXNZI.js";import{f as be}from"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{d as K,f as ne,g as re,h as Se,m as X}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as s,e as pe,f as Et,g as Lt,h as Rt,j as te}from"./chunk-3XIESWL4.js";var Y=pe(Lt(),1);var E=pe(Et(),1);var r=pe(Rt(),1);var Tt=["ORDER BY","GROUP BY","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN","EXPLAIN QUERY PLAN","SELECT","DISTINCT","FROM","WHERE","HAVING","LIMIT","OFFSET","JOIN","ON","AND","OR","AS","ASC","DESC","WITH","UNION","EXPLAIN"],Ot=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],se=String.fromCodePoint(0),Dt=new RegExp(`${se}${String.raw`(\d+)`}${se}`,"gu"),Mt=Tt.map(l=>({pattern:new RegExp(String.raw`\b${l.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:l})),_t=Ot.map(l=>({pattern:new RegExp(String.raw`\s+${l.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
2
2
  ${l}`})),At=s(l=>{let e=[],t=l.replaceAll(/'(?:[^']|'')*'/gu,n=>(e.push(n),`${se}${(e.length-1).toString()}${se}`)).replaceAll(/\s+/gu," ").trim();for(let{pattern:n,replacement:o}of Mt)t=t.replaceAll(n,o);for(let{pattern:n,replacement:o}of _t)t=t.replaceAll(n,o);return t=t.replaceAll(Dt,(n,o)=>e[Number(o)]??""),t},"_t"),zt=["AND","ASC","AS","BY","COUNT","DESC","DISTINCT","EXPLAIN","FROM","GROUP","HAVING","INNER","JOIN","LEFT","LIKE","LIMIT","NOT","NULL","OFFSET","ON","ORDER","OR","QUERY","SELECT","WHERE","WITH"],Wt=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),$t=/[\w$]/,Be=s(l=>l!==void 0&&$t.test(l),"Te"),je=s(l=>{let e=l.length;for(;e>0&&Be(l[e-1]);)e-=1;return l.slice(e)},"Le"),He=s((l,e)=>{let t=e;for(;t>0&&Be(l[t-1]);)t-=1;return{end:e,start:t,text:l.slice(t,e)}},"Re"),We=s((l,e)=>{let t=l.slice(0,e).trimEnd();return t.endsWith(".")||Wt.has(je(t).toUpperCase())},"Ce"),Bt=s((l,e)=>{let t=l.slice(0,e);if(!t.endsWith("."))return;let n=je(t.slice(0,-1));return n===""?void 0:n},"Bt"),Ne=s((l,e)=>l.toLowerCase().startsWith(e.toLowerCase()),"ge"),$e=s((l,e,t,n)=>{let o=[];for(let a of l)if(Ne(a,e)&&(o.push(n(a)),o.length>=t))break;return o},"Se"),jt=s((l,e,t)=>{let n=new Map;for(let[o,a]of Object.entries(l.columns))for(let d of a)if(Ne(d,e)&&!n.has(d)&&(n.set(d,o),n.size>=t))return[...n].map(([p,c])=>({detail:c,kind:"column",label:p}));return[...n].map(([o,a])=>({detail:a,kind:"column",label:o}))},"Wt"),Ht=s((l,e,t)=>{let n=He(l,e),o=Bt(l,n.start);if(o!==void 0){let c=t.columns[o]??t.columns[o.toLowerCase()]??[];return $e(c,n.text,8,m=>({detail:o,kind:"column",label:m}))}if(n.text===""&&!We(l,n.start))return[];let a=$e(t.tables,n.text,8,c=>({kind:"table",label:c})),d=jt(t,n.text,8),p=zt.filter(c=>n.text!==""&&Ne(c,n.text)&&c.toLowerCase()!==n.text.toLowerCase()).map(c=>({kind:"keyword",label:c}));return(We(l,n.start)?[...d,...a,...p]:[...a,...d,...p]).slice(0,8)},"Ft"),Ft=s((l,e,t)=>{let n=He(l,e),o=l.slice(0,n.start)+t.label+l.slice(n.end);return{caret:n.start+t.label.length,value:o}},"Ht"),Pt=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],Jt=s((l,e)=>{let t=globalThis.getComputedStyle(l),n=globalThis.document.createElement("div"),{style:o}=n;o.position="absolute",o.visibility="hidden",o.whiteSpace="pre-wrap",o.overflowWrap="break-word";for(let c of Pt)o[c]=t[c];n.textContent=l.value.slice(0,Math.max(0,e));let a=globalThis.document.createElement("span");a.textContent=l.value.slice(Math.max(0,e))||".",n.append(a),globalThis.document.body.append(n);let d=a.offsetLeft-l.scrollLeft,p=a.offsetTop-l.scrollTop;return n.remove(),{left:d,top:p}},"Ut"),Ut=s((l,e,t)=>{let n=(0,Y.c)(13),[o,a]=(0,E.useState)(null),d;n[0]!==l||n[1]!==e?(d=s((y,v)=>{let N=Ht(y,v,l);if(N.length===0){a(null);return}let f=e.current,{left:C,top:q}=f===null?{left:0,top:0}:Jt(f,v);a(L=>L!==null&&L.active===0&&L.left===C&&L.top===q&&L.suggestions.length===N.length&&L.suggestions.every((S,M)=>{let O=N.at(M);return S.kind===O?.kind&&S.label===O.label&&S.detail===O.detail})?L:{active:0,left:C,suggestions:N,top:q})},"c"),n[0]=l,n[1]=e,n[2]=d):d=n[2];let p=d,c;n[3]===Symbol.for("react.memo_cache_sentinel")?(c=s(()=>{a(null)},"i"),n[3]=c):c=n[3];let m=c,k;n[4]===Symbol.for("react.memo_cache_sentinel")?(k=s(y=>{a(v=>{if(v===null)return v;let N=v.suggestions.length,f=(v.active+y+N)%N;return{...v,active:f}})},"N"),n[4]=k):k=n[4];let g=k,x;n[5]!==t||n[6]!==o||n[7]!==e?(x=s(()=>{let y=e.current;if(o===null||y===null)return!1;let v=o.suggestions[o.active];if(v===void 0)return!1;let N=Ft(y.value,y.selectionStart,v);return t(N.value),a(null),requestAnimationFrame(()=>{let f=e.current;f!==null&&(f.focus(),f.setSelectionRange(N.caret,N.caret))}),!0},"h"),n[5]=t,n[6]=o,n[7]=e,n[8]=x):x=n[8];let b=x,u;return n[9]!==b||n[10]!==p||n[11]!==o?(u={close:m,commit:b,move:g,refresh:p,state:o},n[9]=b,n[10]=p,n[11]=o,n[12]=u):u=n[12],u},"Jt"),Yt={column:"column",keyword:"keyword",table:"table"},Kt=20,Gt=s(l=>{let e=(0,Y.c)(17),{listboxId:t,onPick:n,state:o}=l,a=K(),d;e[0]!==o?(d=o===null?void 0:{left:o.left,top:o.top+Kt},e[0]=o,e[1]=d):d=e[1];let p=d;if(o===null)return null;let c;if(e[2]!==t||e[3]!==n||e[4]!==o.active||e[5]!==o.suggestions||e[6]!==a){let k;e[8]!==t||e[9]!==n||e[10]!==o.active||e[11]!==a?(k=s((g,x)=>(0,r.jsxs)("li",{"aria-selected":x===o.active,className:te("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",x===o.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${t}-opt-${x.toString()}`,onMouseDown:s(b=>{b.preventDefault(),n(x)},"onMouseDown"),role:"option",children:[(0,r.jsx)("span",{className:"truncate font-mono",children:g.label}),g.detail!==void 0&&(0,r.jsx)("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:g.detail}),(0,r.jsx)("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:a(Yt[g.kind])})]},`${g.kind}:${g.label}`),"N"),e[8]=t,e[9]=n,e[10]=o.active,e[11]=a,e[12]=k):k=e[12],c=o.suggestions.map(k),e[2]=t,e[3]=n,e[4]=o.active,e[5]=o.suggestions,e[6]=a,e[7]=c}else c=e[7];let m;return e[13]!==t||e[14]!==p||e[15]!==c?(m=(0,r.jsx)("ul",{className:"absolute z-30 max-h-56 w-72 overflow-auto rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-autocomplete",id:t,role:"listbox",style:p,children:c}),e[13]=t,e[14]=p,e[15]=c,e[16]=m):m=e[16],m},"Vt"),Fe=[{label:"List tables",sql:"SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name;"},{label:"Table row count",sql:"SELECT COUNT(*) AS rows FROM messages;"},{label:"Recent rows",sql:"SELECT id, _creationTime, __doc__ FROM messages ORDER BY _creationTime DESC LIMIT 50;"},{label:"Index list",sql:"SELECT name, tbl_name FROM sqlite_master WHERE type = 'index' ORDER BY tbl_name;"}],Vt=s(l=>{let e=(0,Y.c)(29),{active:t,onDelete:n,onSelect:o,query:a}=l,d=K(),p;e[0]!==o||e[1]!==a.id?(p=s(()=>{o(a.id)},"m"),e[0]=o,e[1]=a.id,e[2]=p):p=e[2];let c=p,m;e[3]!==n||e[4]!==a.id?(m=s(S=>{S.stopPropagation(),n(a.id)},"u"),e[3]=n,e[4]=a.id,e[5]=m):m=e[5];let k=m,g=t?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground",x;e[6]!==g?(x=te("flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] outline-none transition-colors hover:bg-sidebar-accent focus-visible:bg-sidebar-accent",g),e[6]=g,e[7]=x):x=e[7];let b=`sql-query-${a.id}`,u;e[8]===Symbol.for("react.memo_cache_sentinel")?(u=(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M4 6h16M4 12h10M4 18h7"})}),e[8]=u):u=e[8];let y;e[9]!==a.name?(y=(0,r.jsx)("span",{className:"truncate",children:a.name}),e[9]=a.name,e[10]=y):y=e[10];let v;e[11]!==t||e[12]!==c||e[13]!==x||e[14]!==b||e[15]!==y?(v=(0,r.jsxs)("button",{"aria-pressed":t,className:x,"data-testid":b,onClick:c,type:"button",children:[u,y]}),e[11]=t,e[12]=c,e[13]=x,e[14]=b,e[15]=y,e[16]=v):v=e[16];let N;e[17]!==d?(N=d("Delete query"),e[17]=d,e[18]=N):N=e[18];let f;e[19]!==d?(f=d("Delete query"),e[19]=d,e[20]=f):f=e[20];let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[21]=C):C=e[21];let q;e[22]!==k||e[23]!==f||e[24]!==N?(q=(0,r.jsx)("button",{"aria-label":N,className:"me-1 hidden size-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive group-hover/q:flex",onClick:k,title:f,type:"button",children:C}),e[22]=k,e[23]=f,e[24]=N,e[25]=q):q=e[25];let L;return e[26]!==q||e[27]!==v?(L=(0,r.jsxs)("li",{className:"group/q flex items-center",children:[v,q]}),e[26]=q,e[27]=v,e[28]=L):L=e[28],L},"Gt"),Xt=s(l=>{let e=(0,Y.c)(58),{activeId:t,history:n,listRef:o,onClearHistory:a,onDelete:d,onLoadHistory:p,onLoadTemplate:c,onNew:m,onSearchChange:k,onSelect:g,queries:x,search:b}=l,u=K(),y;if(e[0]!==x||e[1]!==b){let I=b.trim().toLowerCase();y=I===""?[...x]:x.filter(T=>T.name.toLowerCase().includes(I)),e[0]=x,e[1]=b,e[2]=y}else y=e[2];let v=y,N;e[3]!==u?(N=u("Search queries\u2026"),e[3]=u,e[4]=N):N=e[4];let f;e[5]!==k||e[6]!==b||e[7]!==N?(f=(0,r.jsx)("input",{className:"h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"sql-search",onChange:k,placeholder:N,type:"text",value:b}),e[5]=k,e[6]=b,e[7]=N,e[8]=f):f=e[8];let C;e[9]!==u?(C=u("New query"),e[9]=u,e[10]=C):C=e[10];let q;e[11]!==u?(q=u("New query"),e[11]=u,e[12]=q):q=e[12];let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M12 5v14M5 12h14"})}),e[13]=L):L=e[13];let S;e[14]!==m||e[15]!==C||e[16]!==q?(S=(0,r.jsx)("button",{"aria-label":C,className:"flex size-8 shrink-0 items-center justify-center rounded-md border border-border text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-new",onClick:m,title:q,type:"button",children:L}),e[14]=m,e[15]=C,e[16]=q,e[17]=S):S=e[17];let M;e[18]!==f||e[19]!==S?(M=(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[f,S]}),e[18]=f,e[19]=S,e[20]=M):M=e[20];let O;e[21]!==u?(O=u("Private"),e[21]=u,e[22]=O):O=e[22];let _;e[23]!==O?(_=(0,r.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:O}),e[23]=O,e[24]=_):_=e[24];let A;e[25]!==t||e[26]!==v||e[27]!==o||e[28]!==d||e[29]!==g||e[30]!==u?(A=v.length===0?(0,r.jsx)("p",{className:"px-1 py-2 text-xs text-muted-foreground","data-testid":"sql-private-empty",children:u("No saved queries yet \u2014 they save to this browser as you type.")}):(0,r.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-private",ref:o,children:v.map(I=>(0,r.jsx)(Vt,{active:t===I.id,onDelete:d,onSelect:g,query:I},I.id))}),e[25]=t,e[26]=v,e[27]=o,e[28]=d,e[29]=g,e[30]=u,e[31]=A):A=e[31];let W;e[32]!==_||e[33]!==A?(W=(0,r.jsxs)("div",{children:[_,A]}),e[32]=_,e[33]=A,e[34]=W):W=e[34];let $;e[35]!==u?($=u("Reference"),e[35]=u,e[36]=$):$=e[36];let P;e[37]!==$?(P=(0,r.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:$}),e[37]=$,e[38]=P):P=e[38];let H;e[39]!==c?(H=Fe.map(I=>(0,r.jsx)("li",{children:(0,r.jsxs)("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":I.sql,onClick:c,type:"button",children:[(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M7 4h7l4 4v12H7zM14 4v4h4"})}),I.label]})},I.label)),e[39]=c,e[40]=H):H=e[40];let z;e[41]!==H?(z=(0,r.jsx)("ul",{className:"flex flex-col gap-px",children:H}),e[41]=H,e[42]=z):z=e[42];let R;e[43]!==P||e[44]!==z?(R=(0,r.jsxs)("div",{children:[P,z]}),e[43]=P,e[44]=z,e[45]=R):R=e[45];let D;e[46]!==n||e[47]!==a||e[48]!==p||e[49]!==u?(D=n.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-1 pb-1",children:[(0,r.jsx)("p",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:u("History")}),(0,r.jsx)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"sql-history-clear",onClick:a,type:"button",children:u("Clear history")})]}),(0,r.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:n.map(I=>(0,r.jsx)("li",{children:(0,r.jsxs)("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":I.sql,"data-testid":"sql-history-item",onClick:p,title:I.sql,type:"button",children:[(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M12 8v4l3 2M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"})}),(0,r.jsx)("span",{className:"truncate font-mono",children:I.sql})]})},`${I.at.toString()}:${I.sql}`))})]}),e[46]=n,e[47]=a,e[48]=p,e[49]=u,e[50]=D):D=e[50];let B;e[51]!==W||e[52]!==R||e[53]!==D?(B=(0,r.jsxs)("div",{className:"flex flex-1 flex-col gap-4 overflow-y-auto p-2",children:[W,R,D]}),e[51]=W,e[52]=R,e[53]=D,e[54]=B):B=e[54];let j;return e[55]!==B||e[56]!==M?(j=(0,r.jsxs)("aside",{className:"flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar",children:[M,B]}),e[55]=B,e[56]=M,e[57]=j):j=e[57],j},"Qt"),Qt=ne(le.listTables),Zt=ne(le.readTablePage),en=s(l=>{let e=(0,Y.c)(16),t=be(),n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],e[0]=n):n=e[0];let[o,a]=(0,E.useState)(n),d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={},e[1]=d):d=e[1];let[p,c]=(0,E.useState)(d),m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=new Set,e[2]=m):m=e[2];let k=(0,E.useRef)(m),g,x;e[3]!==t||e[4]!==l?(g=s(()=>{let f={cancelled:!1};return X((async()=>{try{let C=await t.query(Qt,{},re(l));f.cancelled||(a(C.map(nn)),c({}),k.current=new Set)}catch{f.cancelled||(a([]),c({}),k.current=new Set)}})()),()=>{f.cancelled=!0}},"x"),x=[t,l],e[3]=t,e[4]=l,e[5]=g,e[6]=x):(g=e[5],x=e[6]),(0,E.useEffect)(g,x);let b;e[7]!==t||e[8]!==l?(b=s(f=>{k.current.has(f)||(k.current.add(f),X((async()=>{try{let C=await t.query(Zt,{limit:1,offset:0,table:f},re(l));c(q=>({...q,[f]:C.columns}))}catch{k.current.delete(f)}})()))},"p"),e[7]=t,e[8]=l,e[9]=b):b=e[9];let u=b,y;e[10]!==p||e[11]!==o?(y={columns:p,tables:o},e[10]=p,e[11]=o,e[12]=y):y=e[12];let v=y,N;return e[13]!==u||e[14]!==v?(N={probe:u,schema:v},e[13]=u,e[14]=v,e[15]=N):N=e[15],N},"en"),ge=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,tn=s(l=>{let e=new Set;ge.lastIndex=0;let t=ge.exec(l);for(;t!==null;)e.add(t[1]??t[2]),t=ge.exec(l);return[...e]},"tn");function nn(l){return l.name}s(nn,"nn");var rn="lunora-studio-sql-tabs",ln="lunora-studio-sql-active-tab",ye=12,Q=s((l="",e="")=>({activeId:null,id:fe("tab"),name:e,sql:l}),"Q"),on=s(()=>he(ln,""),"on"),sn=s(l=>{let[e,t]=oe(rn),[n,o]=on(),a=(0,E.useRef)(null);e.length===0&&a.current===null&&(a.current=l()),(0,E.useEffect)(()=>{if(e.length===0&&a.current!==null){let p=a.current;t([p])}},[t,e.length]);let d=e.length===0&&a.current!==null?[a.current]:e;return{activeId:d.some(p=>p.id===n)?n:d[0]?.id??"",setActiveId:o,setTabs:t,tabs:d}},"sn"),Pe=s(l=>l.activeId===null&&l.sql.trim()!=="","De"),an=s((l,e)=>[...l,e].slice(-ye),"an"),cn=s((l,e,t)=>{let n=l.findIndex(a=>a.id===e);if(n===-1)return{activeId:l[0]?.id??"",tabs:[...l]};let o=l.filter(a=>a.id!==e);if(o.length===0){let a=t();return{activeId:a.id,tabs:[a]}}return{activeId:o[Math.min(n,o.length-1)].id,tabs:o}},"cn"),dn=s((l,e)=>{let t=l.filter(n=>n.id===e);return t.length===0?{activeId:l[0]?.id??"",tabs:[...l]}:{activeId:e,tabs:t}},"dn"),un=s((l,e,t)=>{let n=l.findIndex(a=>a.id===e);if(n===-1)return{activeId:t,tabs:[...l]};let o=l.slice(0,n+1);return{activeId:o.some(a=>a.id===t)?t:e,tabs:o}},"un"),mn=s(l=>{let e=l();return{activeId:e.id,tabs:[e]}},"mn"),pn=s((l,e,t)=>{if(l==="others")return e.filter(n=>n.id!==t);if(l==="right"){let n=e.findIndex(o=>o.id===t);return n===-1?[]:e.slice(n+1)}return[...e]},"pn"),bn=s((l,e)=>l.trim()===""?e:(l.split(`
3
3
  `)[0]??l).slice(0,24),"fn"),hn=s(l=>{let e=(0,Y.c)(14),{initial:t,onCancel:n,onCommit:o,placeholder:a,testId:d}=l,p=K(),c=gn,m;e[0]!==o?(m=s(y=>{o(y.currentTarget.value.trim())},"u"),e[0]=o,e[1]=m):m=e[1];let k=m,g;e[2]!==n||e[3]!==o?(g=s(y=>{y.key==="Enter"?o(y.currentTarget.value.trim()):y.key==="Escape"&&n()},"x"),e[2]=n,e[3]=o,e[4]=g):g=e[4];let x=g,b;e[5]!==p?(b=p("Tab title"),e[5]=p,e[6]=b):b=e[6];let u;return e[7]!==t||e[8]!==k||e[9]!==x||e[10]!==a||e[11]!==b||e[12]!==d?(u=(0,r.jsx)("input",{"aria-label":b,className:"w-40 rounded border border-ring bg-background px-1 py-0.5 text-xs outline-none","data-testid":d,defaultValue:t,onBlur:k,onKeyDown:x,placeholder:a,ref:c,type:"text"}),e[7]=t,e[8]=k,e[9]=x,e[10]=a,e[11]=b,e[12]=d,e[13]=u):u=e[13],u},"bn"),fn=s(l=>{let e=(0,Y.c)(29),{idBase:t,onDiscard:n,onKeep:o}=l,a=K(),d=`sql-tab-close-prompt-${t}`,p;e[0]!==a?(p=a("Discard?"),e[0]=a,e[1]=p):p=e[1];let c;e[2]!==p?(c=(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground",children:p}),e[2]=p,e[3]=c):c=e[3];let m;e[4]!==a?(m=a("Discard changes"),e[4]=a,e[5]=m):m=e[5];let k=`sql-tab-close-confirm-${t}`,g;e[6]!==a?(g=a("Discard changes"),e[6]=a,e[7]=g):g=e[7];let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M5 13l4 4L19 7"})}),e[8]=x):x=e[8];let b;e[9]!==n||e[10]!==m||e[11]!==k||e[12]!==g?(b=(0,r.jsx)("button",{"aria-label":m,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":k,onClick:n,title:g,type:"button",children:x}),e[9]=n,e[10]=m,e[11]=k,e[12]=g,e[13]=b):b=e[13];let u;e[14]!==a?(u=a("Keep editing"),e[14]=a,e[15]=u):u=e[15];let y=`sql-tab-close-cancel-${t}`,v;e[16]!==a?(v=a("Keep editing"),e[16]=a,e[17]=v):v=e[17];let N;e[18]===Symbol.for("react.memo_cache_sentinel")?(N=(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})}),e[18]=N):N=e[18];let f;e[19]!==o||e[20]!==y||e[21]!==v||e[22]!==u?(f=(0,r.jsx)("button",{"aria-label":u,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":y,onClick:o,title:v,type:"button",children:N}),e[19]=o,e[20]=y,e[21]=v,e[22]=u,e[23]=f):f=e[23];let C;return e[24]!==d||e[25]!==f||e[26]!==c||e[27]!==b?(C=(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-1","data-testid":d,role:"group",children:[c,b,f]}),e[24]=d,e[25]=f,e[26]=c,e[27]=b,e[28]=C):C=e[28],C},"hn"),xn=s(l=>{let e=(0,Y.c)(47),{active:t,canClose:n,onClose:o,onMenu:a,onRename:d,onSelect:p,tab:c}=l,m=K(),[k,g]=(0,E.useState)(!1),[x,b]=(0,E.useState)(!1),u;e[0]!==a||e[1]!==c.id?(u=s(F=>{a(c.id,F)},"d"),e[0]=a,e[1]=c.id,e[2]=u):u=e[2];let y=u,v;e[3]!==p||e[4]!==c.id?(v=s(()=>{p(c.id)},"g"),e[3]=p,e[4]=c.id,e[5]=v):v=e[5];let N=v,f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=s(()=>{g(!0)},"b"),e[6]=f):f=e[6];let C=f,q;e[7]!==o||e[8]!==c?(q=s(F=>{F.stopPropagation(),Pe(c)?b(!0):o(c.id)},"q"),e[7]=o,e[8]=c,e[9]=q):q=e[9];let L=q,S;e[10]!==o||e[11]!==c.id?(S=s(F=>{F.stopPropagation(),b(!1),o(c.id)},"S"),e[10]=o,e[11]=c.id,e[12]=S):S=e[12];let M=S,O;e[13]===Symbol.for("react.memo_cache_sentinel")?(O=s(F=>{F.stopPropagation(),b(!1)},"L"),e[13]=O):O=e[13];let _=O,A;e[14]!==d||e[15]!==c.id?(A=s(F=>{d(c.id,F),g(!1)},"M"),e[14]=d,e[15]=c.id,e[16]=A):A=e[16];let W=A,$;e[17]===Symbol.for("react.memo_cache_sentinel")?($=s(()=>{g(!1)},"z"),e[17]=$):$=e[17];let P=$,H;e[18]!==c.name?(H=c.name.trim(),e[18]=c.name,e[19]=H):H=e[19];let z=H,R;e[20]!==m||e[21]!==c.sql?(R=bn(c.sql,m("Untitled")),e[20]=m,e[21]=c.sql,e[22]=R):R=e[22];let D=R,B=t?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground",j;e[23]!==B?(j=te("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",B),e[23]=B,e[24]=j):j=e[24];let I=`sql-tab-${c.id}`,T;e[25]!==t||e[26]!==W||e[27]!==z||e[28]!==D||e[29]!==k||e[30]!==N||e[31]!==m||e[32]!==c.id?(T=k?(0,r.jsx)(hn,{initial:z,onCancel:P,onCommit:W,placeholder:D,testId:`sql-tab-rename-${c.id}`}):(0,r.jsx)("button",{"aria-pressed":t,className:"max-w-40 truncate py-1.5 outline-none","data-testid":`sql-tab-select-${c.id}`,onClick:N,onDoubleClick:C,title:m("Double-click to rename"),type:"button",children:z===""?D:z}),e[25]=t,e[26]=W,e[27]=z,e[28]=D,e[29]=k,e[30]=N,e[31]=m,e[32]=c.id,e[33]=T):T=e[33];let J;e[34]!==n||e[35]!==M||e[36]!==x||e[37]!==L||e[38]!==m||e[39]!==c.id?(J=n&&(x?(0,r.jsx)(fn,{idBase:c.id,onDiscard:M,onKeep:_}):(0,r.jsx)("button",{"aria-label":m("Close tab"),className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive","data-testid":`sql-tab-close-${c.id}`,onClick:L,title:m("Close tab"),type:"button",children:(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})})})),e[34]=n,e[35]=M,e[36]=x,e[37]=L,e[38]=m,e[39]=c.id,e[40]=J):J=e[40];let V;return e[41]!==y||e[42]!==j||e[43]!==I||e[44]!==T||e[45]!==J?(V=(0,r.jsxs)("div",{className:j,"data-testid":I,onContextMenu:y,children:[T,J]}),e[41]=y,e[42]=j,e[43]=I,e[44]=T,e[45]=J,e[46]=V):V=e[46],V},"xn");function gn(l){l?.focus(),l?.select()}s(gn,"gn");var vn=ne(le.runSql),yn="lunora-studio-sql-queries",Nn="lunora-studio-sql-history",kn="lunora-studio-sql-split-view",wn=25,qn={minWidth:"2.75rem",paddingInline:"0.5rem"},ve={error:null,pane:"results",result:null},Cn=s(l=>{let e=(0,Y.c)(16),{result:t}=l;if(t.columns.length===0){let c=t.rowCount===0?"0 rows":"",m;return e[0]!==c?(m=(0,r.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:c}),e[0]=c,e[1]=m):m=e[1],m}let n;e[2]!==t.columns?(n=t.columns.map(Sn),e[2]=t.columns,e[3]=n):n=e[3];let o;e[4]!==n?(o=(0,r.jsx)(Te,{className:"sticky top-0 z-10 bg-muted",children:(0,r.jsx)(xe,{children:n})}),e[4]=n,e[5]=o):o=e[5];let a;if(e[6]!==t.columns||e[7]!==t.rows){let c;e[9]!==t.columns?(c=s((m,k)=>(0,r.jsx)(xe,{"data-testid":"sql-row",children:t.columns.map(g=>(0,r.jsx)(Me,{className:"max-w-md truncate font-mono text-xs",children:(0,r.jsx)(_e,{value:m[g]})},g))},k),"i"),e[9]=t.columns,e[10]=c):c=e[10],a=t.rows.map(c),e[6]=t.columns,e[7]=t.rows,e[8]=a}else a=e[8];let d;e[11]!==a?(d=(0,r.jsx)(Oe,{children:a}),e[11]=a,e[12]=d):d=e[12];let p;return e[13]!==o||e[14]!==d?(p=(0,r.jsxs)(Re,{"data-testid":"sql-rows",children:[o,d]}),e[13]=o,e[14]=d,e[15]=p):p=e[15],p},"Cn"),Bn=s(({initialShardKey:l})=>{let e=be(),t=K(),[n,o]=oe(yn),[a,d]=oe(Nn),[p,c]=(0,E.useState)(""),m=s(()=>Q(Fe[0]?.sql??""),"u"),{activeId:k,setActiveId:g,setTabs:x,tabs:b}=sn(m),[u,y]=(0,E.useState)({}),[v,N]=(0,E.useState)(l??""),[f,C]=(0,E.useState)(!1),[q,L]=he(kn,!1),[S,M]=(0,E.useState)(null),[O,_]=(0,E.useState)(null),A=(0,E.useRef)(null),W=(0,E.useRef)(null),$=(0,E.useRef)(null),P=(0,E.useId)(),{probe:H,schema:z}=en(v),R=b.find(i=>i.id===k)??b[0]??Q(),D=R.sql,{activeId:B}=R,j=u[R.id]??ve,{error:I,result:T}=j,J=j.pane,V=s(i=>{x(h=>h.map(w=>w.id===R.id?{...w,...i}:w))},"G"),F=s(i=>{y(h=>{let w=h[R.id]??ve;return{...h,[R.id]:{error:i.error,pane:i.pane??w.pane,result:i.result}}})},"F"),ke=s(i=>{y(h=>{let w=h[R.id]??ve;return{...h,[R.id]:{...w,pane:i}}})},"ve"),ie=s(i=>{V({sql:i}),B!==null&&o(h=>h.map(w=>w.id===B?{...w,sql:i}:w))},"re"),Je=Ut(z,W,ie),{close:ae,commit:we,move:ce,refresh:Z,state:G}=Je,Ue=s(i=>{ce(i-(G?.active??0)),we()},"_e");(0,E.useEffect)(()=>{let i=W.current;i!==null&&i===document.activeElement&&Z(i.value,i.selectionStart)},[Z,z]);let Ye=s(i=>{d(h=>h[0]?.sql===i?h:[{at:Date.now(),sql:i},...h.filter(w=>w.sql!==i)].slice(0,wn))},"Ae"),de=s(async i=>{if(D.trim()==="")return;C(!0);let h=i==="explain"?`EXPLAIN QUERY PLAN ${D}`:D;try{let w=await e.query(vn,{sql:h},re(v));F({error:null,pane:i,result:w}),Ie(v),Ye(h)}catch(w){F({error:Se(w),pane:i,result:null})}finally{C(!1)}},"se"),Ke=s(()=>{X(de("results"))},"ze"),Ge=s(i=>{let{selectionStart:h,value:w}=i.target;ie(w);for(let U of tn(w))H(U);Z(w,h)},"je"),Ve=s(i=>{let h=i.currentTarget;Z(h.value,h.selectionStart)},"Be"),Xe=s(i=>{if(G!==null){if(i.key==="ArrowDown"){i.preventDefault(),ce(1);return}if(i.key==="ArrowUp"){i.preventDefault(),ce(-1);return}if(i.key==="Escape"){i.preventDefault(),ae();return}if((i.key==="Enter"||i.key==="Tab")&&!i.metaKey&&!i.ctrlKey&&we()){i.preventDefault();return}}(i.metaKey||i.ctrlKey)&&i.key==="Enter"&&(i.preventDefault(),X(de(J)))},"We"),Qe=s(()=>{requestAnimationFrame(()=>{ae()})},"Fe"),Ze=s(i=>{A.current!==null&&(A.current.scrollTop=i.currentTarget.scrollTop)},"He"),ee=s((i,h)=>{x(w=>w.map(U=>U.id===R.id?{...U,activeId:h,sql:i}:U)),F({error:null,result:null})},"te"),et=s(()=>{let i={id:fe("q"),name:t("Untitled query"),sql:""};o(h=>[i,...h]),ee("",i.id)},"Pe"),tt=s(i=>{let h=n.find(w=>w.id===i);h!==void 0&&(ee(h.sql,i),$.current?.querySelector(`[data-testid="sql-query-${i}"]`)?.scrollIntoView({block:"nearest"}))},"Ue"),nt=s(i=>{o(h=>h.filter(w=>w.id!==i)),x(h=>h.map(w=>w.activeId===i?{...w,activeId:null}:w))},"Je"),rt=s(i=>{ee(i.currentTarget.dataset.sql??"",null)},"Ke"),lt=s(i=>{ee(i.currentTarget.dataset.sql??"",null)},"Ye"),ot=s(()=>{d([])},"Ve"),st=s(()=>{ie(At(D))},"Ge"),it=s(()=>{if(b.length>=ye)return;let i=Q();x(h=>an(h,i)),g(i.id)},"Qe"),qe=s(i=>{M(null),_(null),x(i.tabs),g(i.activeId);let h=new Set(i.tabs.map(w=>w.id));y(w=>Object.fromEntries(Object.entries(w).filter(([U])=>h.has(U))))},"Ne"),at=s(i=>{qe(cn(b,i,Q))},"Xe"),Ce=s((i,h)=>{qe(i==="others"?dn(b,h):i==="right"?un(b,h,k):mn(Q))},"ke"),ue=s(i=>{S!==null&&(pn(i,b,S.id).some(h=>Pe(h))?_(i):Ce(i,S.id))},"ie"),ct=s((i,h)=>{h.preventDefault(),_(null),M({id:i,x:h.clientX,y:h.clientY})},"Ze"),dt=s(()=>{M(null),_(null)},"et"),ut=s(i=>{i.preventDefault(),M(null),_(null)},"tt"),mt=s(()=>{ue("others")},"nt"),pt=s(()=>{ue("right")},"rt"),bt=s(()=>{ue("all")},"lt"),ht=s(()=>{S!==null&&O!==null&&Ce(O,S.id),_(null)},"ot"),ft=s(()=>{_(null)},"st"),xt=S===null?void 0:{left:S.x,top:S.y},gt=s(i=>{ae(),g(i)},"at"),vt=s((i,h)=>{x(w=>w.map(U=>U.id===i?{...U,name:h}:U))},"ct"),yt=s(()=>{ke("results")},"dt"),Nt=s(()=>{X(de("explain"))},"ut"),kt=s(()=>{ke("chart")},"mt"),wt=s(()=>{L(!q)},"pt"),qt=D.split(`
4
4
  `).length,Ct=s(i=>{c(i.target.value)},"bt"),me=s(i=>`border-b-2 px-3 py-2 text-sm outline-none transition-colors ${i?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,"ae"),St=q?"flex min-h-0 flex-1 flex-row":"flex min-h-0 flex-1 flex-col",It=q?"flex w-2/5 min-h-0 min-w-0 shrink-0 flex-col border-s border-border":"flex h-2/5 min-h-0 shrink-0 flex-col border-t border-border";return(0,r.jsxs)("div",{className:"flex h-full min-w-0","data-testid":"lunora-sql-editor",children:[(0,r.jsx)(Xt,{activeId:B,history:a,listRef:$,onClearHistory:ot,onDelete:nt,onLoadHistory:lt,onLoadTemplate:rt,onNew:et,onSearchChange:Ct,onSelect:tt,queries:n,search:p}),(0,r.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col",children:[(0,r.jsxs)("div",{className:"flex shrink-0 items-stretch overflow-x-auto border-b border-border bg-muted/30","data-testid":"sql-tab-strip",role:"tablist",children:[b.map(i=>(0,r.jsx)(xn,{active:i.id===R.id,canClose:b.length>1,onClose:at,onMenu:ct,onRename:vt,onSelect:gt,tab:i},i.id)),(0,r.jsx)("button",{"aria-label":t("New tab"),className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-add",disabled:b.length>=ye,onClick:it,title:t("New tab"),type:"button",children:(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M12 5v14M5 12h14"})})})]}),S!==null&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:dt,onContextMenu:ut,role:"presentation"}),(0,r.jsx)("div",{className:"fixed z-50 min-w-44 rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-tab-menu",role:"menu",style:xt,children:O===null?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-others",disabled:b.length<=1,onClick:mt,role:"menuitem",type:"button",children:t("Close other tabs")}),(0,r.jsx)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-right",disabled:b.findIndex(i=>i.id===S.id)>=b.length-1,onClick:pt,role:"menuitem",type:"button",children:t("Close tabs to the right")}),(0,r.jsx)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-close-all",onClick:bt,role:"menuitem",type:"button",children:t("Close all tabs")})]}):(0,r.jsxs)("div",{className:"px-3 py-1.5","data-testid":"sql-tab-menu-confirm",children:[(0,r.jsx)("p",{className:"pb-1.5 text-xs text-muted-foreground",children:t("Discard unsaved tabs?")}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("button",{className:"rounded px-2 py-1 text-xs font-medium text-destructive outline-none hover:bg-destructive/10 focus-visible:bg-destructive/10","data-testid":"sql-tab-menu-confirm-discard",onClick:ht,type:"button",children:t("Discard")}),(0,r.jsx)("button",{className:"rounded px-2 py-1 text-xs text-muted-foreground outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-confirm-cancel",onClick:ft,type:"button",children:t("Cancel")})]})]})})]}),(0,r.jsxs)("div",{className:St,children:[(0,r.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1",children:[(0,r.jsx)("div",{"aria-hidden":"true",className:"shrink-0 select-none overflow-hidden border-e border-border bg-muted/30 py-3 text-end font-mono text-xs leading-5 text-muted-foreground/60",ref:A,style:qn,children:Array.from({length:qt},(i,h)=>(0,r.jsx)("div",{children:h+1},h))}),(0,r.jsxs)("div",{className:"relative min-w-0 flex-1",children:[(0,r.jsx)("textarea",{"aria-activedescendant":G===null?void 0:`${P}-opt-${G.active.toString()}`,"aria-autocomplete":"list","aria-controls":G===null?void 0:P,"aria-expanded":G!==null,"aria-label":t("SQL query"),className:"size-full resize-none bg-background p-3 font-mono text-xs leading-5 outline-none","data-testid":"sql-input",onBlur:Qe,onChange:Ge,onKeyDown:Xe,onScroll:Ze,onSelect:Ve,placeholder:"SELECT * FROM \u2026",ref:W,role:"combobox",spellCheck:!1,value:D}),(0,r.jsx)(Gt,{listboxId:P,onPick:Ue,state:G})]})]}),(0,r.jsxs)("div",{className:It,children:[(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[(0,r.jsx)("button",{className:me(J==="results"),"data-testid":"sql-tab-results",onClick:yt,type:"button",children:t("Results")}),(0,r.jsx)("button",{className:me(J==="chart"),"data-testid":"sql-tab-chart",onClick:kt,type:"button",children:t("Chart")}),(0,r.jsx)("button",{className:me(J==="explain"),"data-testid":"sql-tab-explain",onClick:Nt,type:"button",children:t("Explain")}),(0,r.jsxs)("div",{className:"ms-auto flex items-center gap-2",children:[(0,r.jsx)("button",{"aria-label":t("Split editor and results"),"aria-pressed":q,className:`inline-flex items-center rounded-md border border-border px-2 py-1.5 outline-none transition-colors hover:bg-accent focus-visible:bg-accent ${q?"bg-accent text-foreground":"text-muted-foreground"}`,"data-testid":"sql-split-toggle",onClick:wt,title:t("Split editor and results"),type:"button",children:(0,r.jsxs)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:[(0,r.jsx)("rect",{height:"16",rx:"2",width:"18",x:"3",y:"4"}),(0,r.jsx)("path",{d:"M12 4v16"})]})}),T!==null&&T.columns.length>0&&(0,r.jsx)(Ae,{columns:T.columns,name:"query-result",rows:T.rows}),(0,r.jsx)("button",{className:"inline-flex items-center rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-format",disabled:f,onClick:st,type:"button",children:t("Format")}),(0,r.jsx)(Ee,{onChange:N,testId:"sql-shard-input",value:v}),(0,r.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-run",disabled:f,onClick:Ke,type:"button",children:[t(f?"Running\u2026":"Run"),(0,r.jsx)("kbd",{className:"rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",children:"\u2318\u21B5"})]})]})]}),(0,r.jsxs)("div",{className:"min-h-0 flex-1 overflow-auto",children:[I!==null&&(0,r.jsx)(Le,{className:"m-3 font-mono text-xs",testId:"sql-error",variant:"destructive",children:I}),I===null&&T===null&&(0,r.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:t("Click Run to execute your query.")}),I===null&&T!==null&&(0,r.jsxs)("div",{"data-testid":"sql-result",children:[J==="chart"?(0,r.jsx)(ze,{result:T}):(0,r.jsx)(Cn,{result:T}),(0,r.jsx)("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:T.truncated?t("Showing the first {max} of {count} rows.",{count:T.rowCount,max:T.rows.length}):t("{count} rows",{count:T.rowCount})})]})]})]})]})]})]})},"Hn");function Sn(l){return(0,r.jsx)(De,{children:l},l)}s(Sn,"Sn");export{Bn as SqlEditorPanel};
@@ -1 +1 @@
1
- import{a as U}from"./chunk-SA6MBPBL.js";import{a as C}from"./chunk-C4VURT57.js";import{a as f}from"./chunk-YT7VXQVX.js";import{R as N}from"./chunk-7Z5QEFR4.js";import"./chunk-46IB4C4Q.js";import{c as O}from"./chunk-UY2Y5CXB.js";import"./chunk-ZFWEPGWG.js";import{b as L}from"./chunk-K5PFWU5J.js";import"./chunk-4FNHHFWR.js";import{a as w}from"./chunk-GXZAXNZI.js";import{f as P}from"./chunk-KJTLW5W2.js";import"./chunk-UREY4GLG.js";import{d as q,f as v,g as c,h,m as p}from"./chunk-KLLYGWNF.js";import"./chunk-UDZY7MKE.js";import{a as o,e as T,f as W,h as $}from"./chunk-UHHTEBC3.js";var a=T(W(),1);var e=T($(),1);var R=v(w.getPitrBookmark),V=v(w.pitrRestore),ne=o(({initialShardKey:j})=>{let m=P(),r=q(),i=j??"",[z,x]=(0,a.useState)(null),[l,A]=(0,a.useState)(""),[B,I]=(0,a.useState)(null),[u,D]=(0,a.useState)(""),[k,E]=(0,a.useState)(!1),[s,K]=(0,a.useState)(null),[F,n]=(0,a.useState)(null),[b,d]=(0,a.useState)(!1),g=(0,a.useCallback)(async()=>{d(!0),n(null);try{let t=await m.query(R,{},c(i));x(t.current)}catch(t){n(h(t))}finally{d(!1)}},[m,i]);(0,a.useEffect)(()=>{p(g())},[g]),U(()=>{p((async()=>{try{let t=await m.query(R,{},c(i));x(t.current)}catch{}})())},!0);let M=o(t=>{A(t.target.value)},"U"),Z=o(t=>{D(t.target.value)},"j"),_=o(t=>{E(t.target.checked)},"M"),G=o(()=>{l.trim()!==""&&p((async()=>{d(!0),n(null);try{let t=await m.query(R,{time:l.trim()},c(i));I(t.forTime??null),x(t.current)}catch(t){I(null),n(h(t))}finally{d(!1)}})())},"z"),S=o(t=>{p((async()=>{d(!0),n(null);try{let y=await m.mutation(V,t,c(i));K(y),await g()}catch(y){n(h(y))}finally{d(!1)}})())},"R"),H=u.trim()!==""||l.trim()!=="",J=o(()=>{let t=k?{restart:!0}:{};u.trim()===""?t.time=l.trim():t.bookmark=u.trim(),S(t)},"$"),Q=o(()=>{s!==null&&S(k?{bookmark:s.undoBookmark,restart:!0}:{bookmark:s.undoBookmark})},"D");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[r("Shard"),": ",(0,e.jsx)("span",{className:"font-mono",children:i===""?r("root"):i})]})}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:r("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier.")}),F!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:F}),(0,e.jsxs)("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsx)("h3",{className:"mb-2 text-sm font-semibold",children:r("Current bookmark")}),(0,e.jsx)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:z??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]}),(0,e.jsxs)("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:r("Restore")}),(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)(f,{htmlFor:"pitr-time",children:r("Time (ISO or epoch-ms, last 30 days)")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(N,{"data-testid":"pitr-time",id:"pitr-time",onChange:M,placeholder:"2026-06-01T00:00:00.000Z",value:l}),(0,e.jsx)(O,{"data-testid":"pitr-preview",disabled:b||l.trim()==="",onClick:G,size:"sm",type:"button",variant:"outline",children:r("Preview")})]}),B!==null&&(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[r("Bookmark for that time"),": ",B]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)(f,{htmlFor:"pitr-bookmark",children:r("Or an explicit bookmark (wins over time)")}),(0,e.jsx)(N,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:Z,placeholder:r("bookmark string"),value:u})]}),(0,e.jsxs)(f,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[(0,e.jsx)("input",{checked:k,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:_,type:"checkbox"}),r("Restart the shard now so recovery applies immediately")]}),(0,e.jsx)("div",{children:(0,e.jsx)(C,{confirmLabel:r("Confirm restore"),disabled:b||!H,onConfirm:J,testId:"pitr-restore",children:r("Restore")})})]}),s!==null&&(0,e.jsxs)("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs","data-testid":"pitr-result",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:r("Restore armed")}),(0,e.jsx)(L,{variant:s.restarted?"destructive":"secondary",children:s.restarted?r("restarted now"):r("on next restart")})]}),(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[r("Restored to"),": ",s.restoredTo]}),(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[r("Undo bookmark"),": ",s.undoBookmark]}),(0,e.jsx)("div",{children:(0,e.jsx)(C,{confirmLabel:r("Confirm undo"),disabled:b,onConfirm:Q,testId:"pitr-undo",children:r("Undo restore")})})]})]})},"de");export{ne as PitrPanel};
1
+ import{a as U}from"./chunk-54MMVNPT.js";import{a as C}from"./chunk-7LQWFOEU.js";import{a as f}from"./chunk-5Y3QLNWX.js";import{R as N}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as O}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as L}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as w}from"./chunk-GXZAXNZI.js";import{f as P}from"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{d as q,f as v,g as c,h,m as p}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as o,e as T,f as W,h as $}from"./chunk-3XIESWL4.js";var a=T(W(),1);var e=T($(),1);var R=v(w.getPitrBookmark),V=v(w.pitrRestore),ne=o(({initialShardKey:j})=>{let m=P(),r=q(),i=j??"",[z,x]=(0,a.useState)(null),[l,A]=(0,a.useState)(""),[B,I]=(0,a.useState)(null),[u,D]=(0,a.useState)(""),[k,E]=(0,a.useState)(!1),[s,K]=(0,a.useState)(null),[F,n]=(0,a.useState)(null),[b,d]=(0,a.useState)(!1),g=(0,a.useCallback)(async()=>{d(!0),n(null);try{let t=await m.query(R,{},c(i));x(t.current)}catch(t){n(h(t))}finally{d(!1)}},[m,i]);(0,a.useEffect)(()=>{p(g())},[g]),U(()=>{p((async()=>{try{let t=await m.query(R,{},c(i));x(t.current)}catch{}})())},!0);let M=o(t=>{A(t.target.value)},"U"),Z=o(t=>{D(t.target.value)},"j"),_=o(t=>{E(t.target.checked)},"M"),G=o(()=>{l.trim()!==""&&p((async()=>{d(!0),n(null);try{let t=await m.query(R,{time:l.trim()},c(i));I(t.forTime??null),x(t.current)}catch(t){I(null),n(h(t))}finally{d(!1)}})())},"z"),S=o(t=>{p((async()=>{d(!0),n(null);try{let y=await m.mutation(V,t,c(i));K(y),await g()}catch(y){n(h(y))}finally{d(!1)}})())},"R"),H=u.trim()!==""||l.trim()!=="",J=o(()=>{let t=k?{restart:!0}:{};u.trim()===""?t.time=l.trim():t.bookmark=u.trim(),S(t)},"$"),Q=o(()=>{s!==null&&S(k?{bookmark:s.undoBookmark,restart:!0}:{bookmark:s.undoBookmark})},"D");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[r("Shard"),": ",(0,e.jsx)("span",{className:"font-mono",children:i===""?r("root"):i})]})}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:r("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier.")}),F!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:F}),(0,e.jsxs)("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsx)("h3",{className:"mb-2 text-sm font-semibold",children:r("Current bookmark")}),(0,e.jsx)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:z??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]}),(0,e.jsxs)("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:r("Restore")}),(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)(f,{htmlFor:"pitr-time",children:r("Time (ISO or epoch-ms, last 30 days)")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(N,{"data-testid":"pitr-time",id:"pitr-time",onChange:M,placeholder:"2026-06-01T00:00:00.000Z",value:l}),(0,e.jsx)(O,{"data-testid":"pitr-preview",disabled:b||l.trim()==="",onClick:G,size:"sm",type:"button",variant:"outline",children:r("Preview")})]}),B!==null&&(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[r("Bookmark for that time"),": ",B]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)(f,{htmlFor:"pitr-bookmark",children:r("Or an explicit bookmark (wins over time)")}),(0,e.jsx)(N,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:Z,placeholder:r("bookmark string"),value:u})]}),(0,e.jsxs)(f,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[(0,e.jsx)("input",{checked:k,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:_,type:"checkbox"}),r("Restart the shard now so recovery applies immediately")]}),(0,e.jsx)("div",{children:(0,e.jsx)(C,{confirmLabel:r("Confirm restore"),disabled:b||!H,onConfirm:J,testId:"pitr-restore",children:r("Restore")})})]}),s!==null&&(0,e.jsxs)("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs","data-testid":"pitr-result",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:r("Restore armed")}),(0,e.jsx)(L,{variant:s.restarted?"destructive":"secondary",children:s.restarted?r("restarted now"):r("on next restart")})]}),(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[r("Restored to"),": ",s.restoredTo]}),(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[r("Undo bookmark"),": ",s.undoBookmark]}),(0,e.jsx)("div",{children:(0,e.jsx)(C,{confirmLabel:r("Confirm undo"),disabled:b,onConfirm:Q,testId:"pitr-undo",children:r("Undo restore")})})]})]})},"de");export{ne as PitrPanel};