@lunora/studio 1.0.0-alpha.382 → 1.0.0-alpha.383

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 (106) hide show
  1. package/dist/index.d.mts +2 -2
  2. package/dist/index.d.ts +2 -2
  3. package/dist/mount.d.mts +1 -1
  4. package/dist/mount.d.ts +1 -1
  5. package/dist/packem_chunks/privacy-requests-panel.mjs +1 -1
  6. package/dist/packem_shared/{app.d-DpxFQ0qO.d.mts → app.d-QqDN78r1.d.mts} +1 -1
  7. package/dist/packem_shared/{app.d-DpxFQ0qO.d.ts → app.d-QqDN78r1.d.ts} +1 -1
  8. package/dist/standalone/{chunk-WUK2O2KI.js → chunk-2IYIVCPN.js} +1 -1
  9. package/dist/standalone/{chunk-LAQNOLYC.js → chunk-2LKJSQKF.js} +1 -1
  10. package/dist/standalone/{chunk-Z7HICJ3Z.js → chunk-4AGOKKRZ.js} +1 -1
  11. package/dist/standalone/{chunk-CLZSERWW.js → chunk-4KVCH3A4.js} +1 -1
  12. package/dist/standalone/{chunk-QKWIY6JW.js → chunk-54X7HWI6.js} +1 -1
  13. package/dist/standalone/{chunk-RY6I3E2K.js → chunk-5CHKXJYN.js} +1 -1
  14. package/dist/standalone/{chunk-M2X2UFAA.js → chunk-5IOQXXYH.js} +1 -1
  15. package/dist/standalone/{chunk-F4ZN2DRL.js → chunk-5KQSRLQP.js} +2 -2
  16. package/dist/standalone/{chunk-75LZZADZ.js → chunk-5LJYJ5SF.js} +1 -1
  17. package/dist/standalone/{chunk-ZBXY4FVL.js → chunk-6NZOJI3N.js} +1 -1
  18. package/dist/standalone/{chunk-2BX4MJK6.js → chunk-6OIS24US.js} +1 -1
  19. package/dist/standalone/{chunk-S63YTOR5.js → chunk-76CCNRPQ.js} +1 -1
  20. package/dist/standalone/{chunk-TMIYU26C.js → chunk-7HIZZYHW.js} +1 -1
  21. package/dist/standalone/{chunk-2YQF4QCI.js → chunk-7JIVSWQM.js} +1 -1
  22. package/dist/standalone/{chunk-XEZ7LEII.js → chunk-7O6F7GJ2.js} +1 -1
  23. package/dist/standalone/{chunk-F7SJ4DOF.js → chunk-7OMB6F3L.js} +1 -1
  24. package/dist/standalone/{chunk-RQHLJCG7.js → chunk-7YHT6DLF.js} +1 -1
  25. package/dist/standalone/{chunk-6HVMODID.js → chunk-ABY6J4SX.js} +1 -1
  26. package/dist/standalone/{chunk-6XU2QUI3.js → chunk-APYV4J3H.js} +1 -1
  27. package/dist/standalone/{chunk-57JJA4FO.js → chunk-B2QIV4WC.js} +1 -1
  28. package/dist/standalone/{chunk-N36AT4CI.js → chunk-BCD7WQYW.js} +1 -1
  29. package/dist/standalone/{chunk-AMX5BC24.js → chunk-BIEYPLQZ.js} +1 -1
  30. package/dist/standalone/{chunk-NX6JHCY5.js → chunk-BWS7JUQV.js} +1 -1
  31. package/dist/standalone/{chunk-VTAHI7AZ.js → chunk-C6NIFA7C.js} +1 -1
  32. package/dist/standalone/{chunk-A27GQYC7.js → chunk-CJ2V577P.js} +1 -1
  33. package/dist/standalone/{chunk-HVKGOO4E.js → chunk-CNALVIPZ.js} +1 -1
  34. package/dist/standalone/{chunk-VX6ZBLXB.js → chunk-D3MLU3PX.js} +1 -1
  35. package/dist/standalone/{chunk-OKDHAG2Y.js → chunk-DKTTK2SX.js} +1 -1
  36. package/dist/standalone/{chunk-2AKEF2E6.js → chunk-DWNWEMQK.js} +1 -1
  37. package/dist/standalone/{chunk-EFJ5SREG.js → chunk-E52THCJJ.js} +1 -1
  38. package/dist/standalone/{chunk-NCDS5OJ4.js → chunk-EU3IVSBQ.js} +1 -1
  39. package/dist/standalone/{chunk-QLMDHJMC.js → chunk-FFECJKHB.js} +1 -1
  40. package/dist/standalone/{chunk-KS2ZCKZ2.js → chunk-FKY2ID3J.js} +1 -1
  41. package/dist/standalone/{chunk-YIVDW4BV.js → chunk-FYSSF7AJ.js} +1 -1
  42. package/dist/standalone/{chunk-WHIWJD5H.js → chunk-G7GMOSDG.js} +1 -1
  43. package/dist/standalone/{chunk-WD6TOMHJ.js → chunk-G7KYDZGL.js} +1 -1
  44. package/dist/standalone/{chunk-73WXN7SZ.js → chunk-GB7MHA6L.js} +1 -1
  45. package/dist/standalone/{chunk-SGIW3B4R.js → chunk-HB2FLDDU.js} +1 -1
  46. package/dist/standalone/{chunk-4UDH2YI4.js → chunk-HFPX37U7.js} +1 -1
  47. package/dist/standalone/{chunk-L645XKP6.js → chunk-HI3U4W6T.js} +1 -1
  48. package/dist/standalone/{chunk-HFDKQBIZ.js → chunk-HPTF52JF.js} +1 -1
  49. package/dist/standalone/{chunk-NLRCYQUM.js → chunk-I33WWIBV.js} +1 -1
  50. package/dist/standalone/{chunk-CCJUOPWR.js → chunk-IEOOQ2NW.js} +1 -1
  51. package/dist/standalone/{chunk-PSPK6BZ2.js → chunk-ILPLYMU4.js} +1 -1
  52. package/dist/standalone/{chunk-3CHHMX6A.js → chunk-IPRJMLLL.js} +1 -1
  53. package/dist/standalone/{chunk-S3LW4HCF.js → chunk-IW5TW36H.js} +1 -1
  54. package/dist/standalone/{chunk-7MM2SI65.js → chunk-J3ZEO3PJ.js} +1 -1
  55. package/dist/standalone/{chunk-YFZFL4XI.js → chunk-J5SYXVIK.js} +1 -1
  56. package/dist/standalone/{chunk-3JLFCEXX.js → chunk-JPBTM43K.js} +1 -1
  57. package/dist/standalone/{chunk-4NRWZ3IK.js → chunk-LFVPR2JB.js} +1 -1
  58. package/dist/standalone/{chunk-QQ4LEH7V.js → chunk-MMRSSV2C.js} +1 -1
  59. package/dist/standalone/{chunk-JNB2EV3N.js → chunk-MT3K66QU.js} +1 -1
  60. package/dist/standalone/{chunk-QTG3KGNJ.js → chunk-MVRBX7HB.js} +1 -1
  61. package/dist/standalone/{chunk-SOTNC2VE.js → chunk-N2XUTYZJ.js} +1 -1
  62. package/dist/standalone/{chunk-DLF6VPZK.js → chunk-NIIWN6ZY.js} +1 -1
  63. package/dist/standalone/{chunk-EG45XFL3.js → chunk-NVMQPIRS.js} +1 -1
  64. package/dist/standalone/{chunk-KNZGU3CE.js → chunk-OEHBCBV4.js} +1 -1
  65. package/dist/standalone/{chunk-GTW3JPQQ.js → chunk-OKZINWBB.js} +1 -1
  66. package/dist/standalone/{chunk-3CDQYHJX.js → chunk-OVMZ7DXR.js} +1 -1
  67. package/dist/standalone/{chunk-EI2FSTI3.js → chunk-PAFHBQFL.js} +1 -1
  68. package/dist/standalone/{chunk-MSW4QPCU.js → chunk-PAGLAE5H.js} +1 -1
  69. package/dist/standalone/{chunk-ITS5LMYJ.js → chunk-PN7JHEYW.js} +1 -1
  70. package/dist/standalone/{chunk-CAEQ6OOD.js → chunk-PQB2QX4Q.js} +1 -1
  71. package/dist/standalone/chunk-PUQ3LURH.js +1 -0
  72. package/dist/standalone/{chunk-OYO74NM4.js → chunk-PXDQGWZR.js} +1 -1
  73. package/dist/standalone/{chunk-GWJ57WD2.js → chunk-Q4SE33KY.js} +1 -1
  74. package/dist/standalone/{chunk-NIHVUGDE.js → chunk-Q6MWEK4M.js} +1 -1
  75. package/dist/standalone/{chunk-PFIATRRO.js → chunk-QAETUNZX.js} +1 -1
  76. package/dist/standalone/{chunk-TY5MXKUY.js → chunk-QK4NIT57.js} +1 -1
  77. package/dist/standalone/{chunk-GMKV6EAQ.js → chunk-RAJO2KOX.js} +1 -1
  78. package/dist/standalone/{chunk-RWEEBORY.js → chunk-RDYGUTWW.js} +1 -1
  79. package/dist/standalone/{chunk-FOXLEMWC.js → chunk-S3TDGFRE.js} +1 -1
  80. package/dist/standalone/{chunk-CHYLD556.js → chunk-S7NFUY75.js} +1 -1
  81. package/dist/standalone/{chunk-JR66YIA4.js → chunk-SBJ4LWXW.js} +1 -1
  82. package/dist/standalone/{chunk-SOKPPTFJ.js → chunk-SFZ6IAL2.js} +1 -1
  83. package/dist/standalone/{chunk-JI4WZ5K5.js → chunk-SI5L5HDG.js} +1 -1
  84. package/dist/standalone/{chunk-CNPADLAP.js → chunk-SNJ3ZOV2.js} +1 -1
  85. package/dist/standalone/{chunk-RRDXY56O.js → chunk-SRNRWSMY.js} +1 -1
  86. package/dist/standalone/{chunk-3DIKPPNZ.js → chunk-THRRRMIZ.js} +1 -1
  87. package/dist/standalone/{chunk-QQENKHRS.js → chunk-TN4Z3P6S.js} +1 -1
  88. package/dist/standalone/{chunk-D3YEERHT.js → chunk-TQH2BN2P.js} +1 -1
  89. package/dist/standalone/{chunk-I4AZTCAA.js → chunk-U5YP7MSK.js} +1 -1
  90. package/dist/standalone/{chunk-ROHVLVGW.js → chunk-UDBPUH63.js} +1 -1
  91. package/dist/standalone/{chunk-KB75JASP.js → chunk-UHF224OV.js} +1 -1
  92. package/dist/standalone/{chunk-3CUQWI5A.js → chunk-UN3QTZ6X.js} +1 -1
  93. package/dist/standalone/{chunk-26XOFIV4.js → chunk-UV6GPH2E.js} +1 -1
  94. package/dist/standalone/{chunk-QT3W5POL.js → chunk-V3A3775O.js} +1 -1
  95. package/dist/standalone/{chunk-PBHKQULL.js → chunk-VKX7HSAS.js} +1 -1
  96. package/dist/standalone/{chunk-I4EVK4EW.js → chunk-WDQDRE4G.js} +1 -1
  97. package/dist/standalone/{chunk-4EZ3YMBU.js → chunk-WEZRVKSV.js} +1 -1
  98. package/dist/standalone/{chunk-FNWWGQVC.js → chunk-WKRUXQXB.js} +1 -1
  99. package/dist/standalone/{chunk-JEYIP5MS.js → chunk-WSJTPPUQ.js} +1 -1
  100. package/dist/standalone/{chunk-D57SW6H5.js → chunk-XUSA5BXI.js} +1 -1
  101. package/dist/standalone/{chunk-3SRQFKDT.js → chunk-YDDMKWPI.js} +1 -1
  102. package/dist/standalone/{chunk-2DDDI4IG.js → chunk-YNYH4P7E.js} +1 -1
  103. package/dist/standalone/{chunk-G62WODKV.js → chunk-ZO6OZV4D.js} +1 -1
  104. package/dist/standalone/studio.js +1 -1
  105. package/package.json +2 -2
  106. package/dist/standalone/chunk-AE4LQOKG.js +0 -1
@@ -1,4 +1,4 @@
1
- import{a as nt,b as ot}from"./chunk-57JJA4FO.js";import"./chunk-ROHVLVGW.js";import"./chunk-QTG3KGNJ.js";import{d as tt}from"./chunk-NX6JHCY5.js";import"./chunk-CNPADLAP.js";import{a as Ae}from"./chunk-CVSIFPI5.js";import{a as Ze}from"./chunk-SOTNC2VE.js";import"./chunk-Y2YLTUMD.js";import"./chunk-PFIATRRO.js";import"./chunk-LMCBMC2V.js";import"./chunk-QF743FSL.js";import{a as et}from"./chunk-DRHZZ7IN.js";import"./chunk-IQ5CIBXJ.js";import"./chunk-YNCZVYCO.js";import"./chunk-OWRWDDJT.js";import"./chunk-QHVUXMRV.js";import"./chunk-2NUCBQFU.js";import"./chunk-R3RIZDUS.js";import{a as Ye}from"./chunk-EI2FSTI3.js";import{b as Ve}from"./chunk-EDL46BPM.js";import"./chunk-2AKEF2E6.js";import{c as Xe,d as we,e as Ne,f as Ee,g as Me}from"./chunk-4KPATTV6.js";import"./chunk-N7FOBAV3.js";import{i as ye}from"./chunk-GTW3JPQQ.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import"./chunk-EG45XFL3.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import"./chunk-L27FKJTG.js";import{a as Je}from"./chunk-CHYLD556.js";import"./chunk-7MM2SI65.js";import{b as Ge}from"./chunk-RY6I3E2K.js";import{a as ve}from"./chunk-LYVYUTQY.js";import"./chunk-3CUQWI5A.js";import{n as Ce}from"./chunk-F4ZN2DRL.js";import"./chunk-ZPQBVYNN.js";import{B as J,h as ge,i as xe,j as Ke,r as Ue,s as le,x as ie}from"./chunk-ITS5LMYJ.js";import"./chunk-PDBW6GTJ.js";import{a as Et}from"./chunk-A6TVTNKO.js";import{a as Nt,b as Lt}from"./chunk-ADABTCDI.js";import{a as d,d as De}from"./chunk-5PEAXTYQ.js";var V=De(Et(),1),j=De(Nt(),1);var u=De(Lt(),1);var Se=class{static{d(this,"Diff")}diff(e,n,t={}){let o;typeof t=="function"?(o=t,t={}):"callback"in t&&(o=t.callback);let r=this.castInput(e,t),l=this.castInput(n,t),i=this.removeEmpty(this.tokenize(r,t)),a=this.removeEmpty(this.tokenize(l,t));return this.diffWithOptionsObj(i,a,t,o)}diffWithOptionsObj(e,n,t,o){var r;let l=d(h=>{if(h=this.postProcess(h,t),o){setTimeout(function(){o(h)},0);return}else return h},"done"),i=n.length,a=e.length,c=1,m=i+a;t.maxEditLength!=null&&(m=Math.min(m,t.maxEditLength));let p=(r=t.timeout)!==null&&r!==void 0?r:1/0,f=Date.now()+p,b=[{oldPos:-1,lastComponent:void 0}],g=this.extractCommon(b[0],n,e,0,t);if(b[0].oldPos+1>=a&&g+1>=i)return l(this.buildValues(b[0].lastComponent,n,e));let k=-1/0,q=1/0,N=d(()=>{for(let h=Math.max(k,-c);h<=Math.min(q,c);h+=2){let S,x=b[h-1],v=b[h+1];x&&(b[h-1]=void 0);let y=!1;if(v){let E=v.oldPos-h;y=v&&0<=E&&E<i}let w=x&&x.oldPos+1<a;if(!y&&!w){b[h]=void 0;continue}if(!w||y&&x.oldPos<v.oldPos?S=this.addToPath(v,!0,!1,0,t):S=this.addToPath(x,!1,!0,1,t),g=this.extractCommon(S,n,e,h,t),S.oldPos+1>=a&&g+1>=i)return l(this.buildValues(S.lastComponent,n,e))||!0;b[h]=S,S.oldPos+1>=a&&(q=Math.min(q,h-1)),g+1>=i&&(k=Math.max(k,h+1))}c++},"execEditLength");if(o)d(function h(){setTimeout(function(){if(c>m||Date.now()>f)return o(void 0);N()||h()},0)},"exec")();else for(;c<=m&&Date.now()<=f;){let h=N();if(h)return h}}addToPath(e,n,t,o,r){let l=e.lastComponent;return l&&!r.oneChangePerToken&&l.added===n&&l.removed===t?{oldPos:e.oldPos+o,lastComponent:{count:l.count+1,added:n,removed:t,previousComponent:l.previousComponent}}:{oldPos:e.oldPos+o,lastComponent:{count:1,added:n,removed:t,previousComponent:l}}}extractCommon(e,n,t,o,r){let l=n.length,i=t.length,a=e.oldPos,c=a-o,m=0;for(;c+1<l&&a+1<i&&this.equals(t[a+1],n[c+1],r);)c++,a++,m++,r.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return m&&!r.oneChangePerToken&&(e.lastComponent={count:m,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=a,c}equals(e,n,t){return t.comparator?t.comparator(e,n):e===n||!!t.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){let n=[];for(let t=0;t<e.length;t++)e[t]&&n.push(e[t]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,t){let o=[],r;for(;e;)o.push(e),r=e.previousComponent,delete e.previousComponent,e=r;o.reverse();let l=o.length,i=0,a=0,c=0;for(;i<l;i++){let m=o[i];if(m.removed)m.value=this.join(t.slice(c,c+m.count)),c+=m.count;else{if(!m.added&&this.useLongestToken){let p=n.slice(a,a+m.count);p=p.map(function(f,b){let g=t[c+b];return g.length>f.length?g:f}),m.value=this.join(p)}else m.value=this.join(n.slice(a,a+m.count));a+=m.count,m.added||(c+=m.count)}}return o}};var $e=class extends Se{static{d(this,"LineDiff")}constructor(){super(...arguments),this.tokenize=_t}equals(e,n,t){return t.ignoreWhitespace?((!t.newlineIsToken||!e.includes(`
1
+ import{a as nt,b as ot}from"./chunk-B2QIV4WC.js";import"./chunk-UDBPUH63.js";import"./chunk-MVRBX7HB.js";import{d as tt}from"./chunk-BWS7JUQV.js";import"./chunk-SNJ3ZOV2.js";import{a as Ae}from"./chunk-CVSIFPI5.js";import{a as Ze}from"./chunk-N2XUTYZJ.js";import"./chunk-Y2YLTUMD.js";import"./chunk-QAETUNZX.js";import"./chunk-LMCBMC2V.js";import"./chunk-QF743FSL.js";import{a as et}from"./chunk-DRHZZ7IN.js";import"./chunk-IQ5CIBXJ.js";import"./chunk-YNCZVYCO.js";import"./chunk-OWRWDDJT.js";import"./chunk-QHVUXMRV.js";import"./chunk-2NUCBQFU.js";import"./chunk-R3RIZDUS.js";import{a as Ye}from"./chunk-PAFHBQFL.js";import{b as Ve}from"./chunk-EDL46BPM.js";import"./chunk-DWNWEMQK.js";import{c as Xe,d as we,e as Ne,f as Ee,g as Me}from"./chunk-4KPATTV6.js";import"./chunk-N7FOBAV3.js";import{i as ye}from"./chunk-OKZINWBB.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import"./chunk-NVMQPIRS.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import"./chunk-L27FKJTG.js";import{a as Je}from"./chunk-S7NFUY75.js";import"./chunk-J3ZEO3PJ.js";import{b as Ge}from"./chunk-5CHKXJYN.js";import{a as ve}from"./chunk-LYVYUTQY.js";import"./chunk-UN3QTZ6X.js";import{n as Ce}from"./chunk-5KQSRLQP.js";import"./chunk-ZPQBVYNN.js";import{B as J,h as ge,i as xe,j as Ke,r as Ue,s as le,x as ie}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import{a as Et}from"./chunk-A6TVTNKO.js";import{a as Nt,b as Lt}from"./chunk-ADABTCDI.js";import{a as d,d as De}from"./chunk-5PEAXTYQ.js";var V=De(Et(),1),j=De(Nt(),1);var u=De(Lt(),1);var Se=class{static{d(this,"Diff")}diff(e,n,t={}){let o;typeof t=="function"?(o=t,t={}):"callback"in t&&(o=t.callback);let r=this.castInput(e,t),l=this.castInput(n,t),i=this.removeEmpty(this.tokenize(r,t)),a=this.removeEmpty(this.tokenize(l,t));return this.diffWithOptionsObj(i,a,t,o)}diffWithOptionsObj(e,n,t,o){var r;let l=d(h=>{if(h=this.postProcess(h,t),o){setTimeout(function(){o(h)},0);return}else return h},"done"),i=n.length,a=e.length,c=1,m=i+a;t.maxEditLength!=null&&(m=Math.min(m,t.maxEditLength));let p=(r=t.timeout)!==null&&r!==void 0?r:1/0,f=Date.now()+p,b=[{oldPos:-1,lastComponent:void 0}],g=this.extractCommon(b[0],n,e,0,t);if(b[0].oldPos+1>=a&&g+1>=i)return l(this.buildValues(b[0].lastComponent,n,e));let k=-1/0,q=1/0,N=d(()=>{for(let h=Math.max(k,-c);h<=Math.min(q,c);h+=2){let S,x=b[h-1],v=b[h+1];x&&(b[h-1]=void 0);let y=!1;if(v){let E=v.oldPos-h;y=v&&0<=E&&E<i}let w=x&&x.oldPos+1<a;if(!y&&!w){b[h]=void 0;continue}if(!w||y&&x.oldPos<v.oldPos?S=this.addToPath(v,!0,!1,0,t):S=this.addToPath(x,!1,!0,1,t),g=this.extractCommon(S,n,e,h,t),S.oldPos+1>=a&&g+1>=i)return l(this.buildValues(S.lastComponent,n,e))||!0;b[h]=S,S.oldPos+1>=a&&(q=Math.min(q,h-1)),g+1>=i&&(k=Math.max(k,h+1))}c++},"execEditLength");if(o)d(function h(){setTimeout(function(){if(c>m||Date.now()>f)return o(void 0);N()||h()},0)},"exec")();else for(;c<=m&&Date.now()<=f;){let h=N();if(h)return h}}addToPath(e,n,t,o,r){let l=e.lastComponent;return l&&!r.oneChangePerToken&&l.added===n&&l.removed===t?{oldPos:e.oldPos+o,lastComponent:{count:l.count+1,added:n,removed:t,previousComponent:l.previousComponent}}:{oldPos:e.oldPos+o,lastComponent:{count:1,added:n,removed:t,previousComponent:l}}}extractCommon(e,n,t,o,r){let l=n.length,i=t.length,a=e.oldPos,c=a-o,m=0;for(;c+1<l&&a+1<i&&this.equals(t[a+1],n[c+1],r);)c++,a++,m++,r.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return m&&!r.oneChangePerToken&&(e.lastComponent={count:m,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=a,c}equals(e,n,t){return t.comparator?t.comparator(e,n):e===n||!!t.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){let n=[];for(let t=0;t<e.length;t++)e[t]&&n.push(e[t]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,t){let o=[],r;for(;e;)o.push(e),r=e.previousComponent,delete e.previousComponent,e=r;o.reverse();let l=o.length,i=0,a=0,c=0;for(;i<l;i++){let m=o[i];if(m.removed)m.value=this.join(t.slice(c,c+m.count)),c+=m.count;else{if(!m.added&&this.useLongestToken){let p=n.slice(a,a+m.count);p=p.map(function(f,b){let g=t[c+b];return g.length>f.length?g:f}),m.value=this.join(p)}else m.value=this.join(n.slice(a,a+m.count));a+=m.count,m.added||(c+=m.count)}}return o}};var $e=class extends Se{static{d(this,"LineDiff")}constructor(){super(...arguments),this.tokenize=_t}equals(e,n,t){return t.ignoreWhitespace?((!t.newlineIsToken||!e.includes(`
2
2
  `))&&(e=e.trim()),(!t.newlineIsToken||!n.includes(`
3
3
  `))&&(n=n.trim())):t.ignoreNewlineAtEof&&!t.newlineIsToken&&(e.endsWith(`
4
4
  `)&&(e=e.slice(0,-1)),n.endsWith(`
@@ -1 +1 @@
1
- import{a as y,b as D}from"./chunk-JNWK5MJC.js";import{a as _,b as z,c as j,d as E,e as B,f as H,g as L,h as V,i as O,j as T,k as Z,l as q}from"./chunk-I4AZTCAA.js";import{i as I}from"./chunk-GTW3JPQQ.js";import{a as k}from"./chunk-EG45XFL3.js";import{b as w}from"./chunk-26XOFIV4.js";import{B as $,s as P,x as N}from"./chunk-ITS5LMYJ.js";import{a as se}from"./chunk-A6TVTNKO.js";import{a as le,b as de}from"./chunk-ADABTCDI.js";import{a as u,d as S}from"./chunk-5PEAXTYQ.js";var v=S(se(),1);var b=S(le(),1);var s=S(de(),1);function ie(a){let e=(0,v.c)(10),t,n,r;e[0]!==a?({className:t,selected:r,...n}=a,e[0]=a,e[1]=t,e[2]=n,e[3]=r):(t=e[1],n=e[2],r=e[3]);let l=r===!0?"":void 0,o;e[4]!==t?(o=N("rounded-md border border-border bg-card text-card-foreground shadow-sm transition-colors","data-[selected]:border-ring data-[selected]:ring-[3px] data-[selected]:ring-ring/30",t),e[4]=t,e[5]=o):o=e[5];let d;return e[6]!==n||e[7]!==l||e[8]!==o?(d=(0,s.jsx)("div",{"data-slot":"base-node","data-selected":l,className:o,...n}),e[6]=n,e[7]=l,e[8]=o,e[9]=d):d=e[9],d}u(ie,"ie");function ce(a){let e=(0,v.c)(8),t,n;e[0]!==a?({className:t,...n}=a,e[0]=a,e[1]=t,e[2]=n):(t=e[1],n=e[2]);let r;e[3]!==t?(r=N("flex items-center gap-2 rounded-t-md bg-muted/50 px-3 py-1.5",t),e[3]=t,e[4]=r):r=e[4];let l;return e[5]!==n||e[6]!==r?(l=(0,s.jsx)("div",{"data-slot":"base-node-header",className:r,...n}),e[5]=n,e[6]=r,e[7]=l):l=e[7],l}u(ce,"ce");function me(a){let e=(0,v.c)(8),t,n;e[0]!==a?({className:t,...n}=a,e[0]=a,e[1]=t,e[2]=n):(t=e[1],n=e[2]);let r;e[3]!==t?(r=N("flex flex-col",t),e[3]=t,e[4]=r):r=e[4];let l;return e[5]!==n||e[6]!==r?(l=(0,s.jsx)("div",{"data-slot":"base-node-content",className:r,...n}),e[5]=n,e[6]=r,e[7]=l):l=e[7],l}u(me,"de");var ue=3,fe=u((a,e,t)=>{let n=e?a:a.slice(0,ue),r=n.map(o=>JSON.stringify(o)).join(" | "),l=a.length-n.length;return l>0?`${r} ${t("+{count} more",{count:l})}`:r},"fe"),J=u((a,e,t)=>{let n=a.enumValues??[],r=n.length===0?a.type:fe(n,e,t),l=a.ref===void 0?r:`${r} \u2192 ${a.ref}`;return a.optional===!0?`${l}?`:l},"H"),pe=u(a=>{let e=(0,v.c)(23),{data:t,selected:n}=a,r=$(),l;e[0]!==t.label||e[1]!==t.loadError||e[2]!==r?(l=t.loadError===!0?(0,s.jsx)("span",{className:"px-3 py-1.5 text-xs text-destructive","data-testid":`sd-node-${t.label}-error`,children:r("Columns unavailable")}):(0,s.jsx)("span",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"\u2014"}),e[0]=t.label,e[1]=t.loadError,e[2]=r,e[3]=l):l=e[3];let o=l,d=`sd-node-${t.label}`,c;e[4]!==t.label?(c=(0,s.jsx)("span",{className:"truncate font-mono text-xs font-semibold",title:t.label,children:t.label}),e[4]=t.label,e[5]=c):c=e[5];let m;e[6]!==t.tier?(m=(0,s.jsx)("span",{className:"ms-auto",children:(0,s.jsx)(D,{tier:t.tier})}),e[6]=t.tier,e[7]=m):m=e[7];let i;e[8]!==c||e[9]!==m?(i=(0,s.jsxs)(ce,{children:[c,m]}),e[8]=c,e[9]=m,e[10]=i):i=e[10];let f;e[11]!==t.columns||e[12]!==t.label||e[13]!==o||e[14]!==r?(f=t.columns.length===0?o:t.columns.map(h=>(0,s.jsxs)("div",{className:N("relative flex items-center gap-2 border-t border-border px-3 py-1.5 text-xs first:border-t-0",h.pk===!0&&"bg-muted/30"),"data-testid":`sd-col-${t.label}-${h.name}`,children:[(0,s.jsx)(E,{className:"!h-2 !w-2 !-left-1 !border-border !bg-muted-foreground/70",id:h.name,isConnectable:!1,position:_.Left,type:"target"}),(0,s.jsx)("span",{className:"truncate font-mono",title:h.name,children:h.name}),h.pk===!0&&(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"secondary",children:"PK"}),h.ref!==void 0&&(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"outline",children:"FK"}),(0,s.jsx)("span",{className:"ms-auto truncate text-muted-foreground",title:J(h,!0,r),children:J(h,!1,r)}),(0,s.jsx)(E,{className:"!h-2 !w-2 !-right-1 !border-border !bg-muted-foreground/70",id:h.name,isConnectable:!1,position:_.Right,type:"source"})]},h.name)),e[11]=t.columns,e[12]=t.label,e[13]=o,e[14]=r,e[15]=f):f=e[15];let p;e[16]!==f?(p=(0,s.jsx)(me,{children:f}),e[16]=f,e[17]=p):p=e[17];let x;return e[18]!==n||e[19]!==d||e[20]!==i||e[21]!==p?(x=(0,s.jsxs)(ie,{className:"w-64 overflow-hidden","data-testid":d,selected:n,children:[i,p]}),e[18]=n,e[19]=d,e[20]=i,e[21]=p,e[22]=x):x=e[22],x},"ue"),G=256,Q=112,W=36,M=24,he=480,be=1.4,ge=u(a=>{let e=Math.max(1,Math.round(Math.sqrt(be*a/(G+Q))));return Math.max(he,a/e)},"ge"),xe=38,Ne=28,A=u(a=>xe+Math.max(1,a)*Ne,"B"),ye=u((a,e)=>{let t=new Map;for(let o of a)t.set(o,[]);for(let o of e)o.to!==o.from&&t.has(o.from)&&t.has(o.to)&&t.get(o.from)?.push(o.to);let n=new Map,r=new Set,l=u(o=>{let d=n.get(o);if(d!==void 0)return d;if(r.has(o))return 0;r.add(o);let c=0;for(let m of t.get(o)??[])c=Math.max(c,l(m)+1);return r.delete(o),n.set(o,c),c},"r");for(let o of a)l(o);return n},"Ne"),ve=u((a,e,t)=>{let n=ye(a,e),r=new Map;for(let m of a){let i=n.get(m)??0,f=r.get(i);f===void 0?r.set(i,[m]):f.push(m)}let l=a.reduce((m,i)=>m+A(t.get(i)??0)+W,0),o=ge(l),d=[],c=0;for(let m of[...r.keys()].toSorted((i,f)=>i-f)){let i=0,f=M;for(let p of r.get(m)??[]){let x=A(t.get(p)??0);f>M&&f+x>o&&(i+=1,f=M),d.push({name:p,x:M+(c+i)*(G+Q),y:f}),f+=x+W}c+=i+1}return d},"ye"),we={databaseSchema:pe},U={backgroundColor:y.shard.color},X={backgroundColor:y.global.color},$e={global:!0,shard:!0},Me={},Ce=u(a=>{let e=a.find(t=>t.pk===!0)?.name;return e!==void 0?e:a.some(t=>t.name==="_id")?"_id":a.some(t=>t.name==="id")?"id":a[0]?.name??"_id"},"_e"),Y=u(a=>a.flatMap(e=>e.columns.filter(t=>t.ref!==void 0).map(t=>({column:t.name,from:e.name,to:t.ref}))),"K"),Se=u((a,e,t)=>{let n=a.map(d=>d.name),r=new Map(a.map(d=>[d.name,d.columns.length])),l=ve(n,Y(a),r),o=new Map(a.map(d=>[d.name,d]));return l.flatMap(({name:d,x:c,y:m})=>{let i=o.get(d);return i===void 0?[]:[{className:t[d],data:{columns:i.columns,label:d,loadError:e,tier:i.tier},id:d,position:{x:c,y:m},type:"databaseSchema"}]})},"we"),ke=u(a=>{let e=new Map(a.map(t=>[t.name,t.columns]));return Y(a).flatMap(t=>{let n=e.get(t.to)??[],r=e.get(t.from)??[],l=Ce(n);return!n.some(o=>o.name===l)||!r.some(o=>o.name===t.column)?[]:[{id:`${t.from}.${t.column}->${t.to}`,source:t.to,sourceHandle:l,target:t.from,targetHandle:t.column}]})},"Me"),_e=u(()=>{let a=(0,v.c)(15),e=$(),t;a[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:U}),y.shard.label]}),a[0]=t):t=a[0];let n;a[1]===Symbol.for("react.memo_cache_sentinel")?(n=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:X}),y.global.label]}),a[1]=n):n=a[1];let r;a[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"secondary",children:"PK"}),a[2]=r):r=a[2];let l;a[3]!==e?(l=e("Primary key"),a[3]=e,a[4]=l):l=a[4];let o;a[5]!==l?(o=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[r,l]}),a[5]=l,a[6]=o):o=a[6];let d;a[7]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"outline",children:"FK"}),a[7]=d):d=a[7];let c;a[8]!==e?(c=e("Foreign key"),a[8]=e,a[9]=c):c=a[9];let m;a[10]!==c?(m=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[d,c]}),a[10]=c,a[11]=m):m=a[11];let i;return a[12]!==o||a[13]!==m?(i=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 rounded-xl border border-border bg-card/95 px-2.5 py-1.5 text-[11px] text-muted-foreground shadow-xs",children:[t,n,o,m]}),a[12]=o,a[13]=m,a[14]=i):i=a[14],i},"Ce"),ze=12,Ee=u(a=>{let e=(0,v.c)(9),{containerRef:t,seedKey:n}=a,r=V(),{fitView:l}=j(),o;e[0]!==t||e[1]!==l||e[2]!==r?(o=u(()=>{if(!r)return;let c=u(()=>{P(l({duration:0,maxZoom:1.6,padding:.14}))},"d");c();let m=t.current;if(m===null)return;let i=new ResizeObserver(()=>{c()});return i.observe(m),()=>{i.disconnect()}},"a"),e[0]=t,e[1]=l,e[2]=r,e[3]=o):o=e[3];let d;return e[4]!==t||e[5]!==l||e[6]!==r||e[7]!==n?(d=[t,l,r,n],e[4]=t,e[5]=l,e[6]=r,e[7]=n,e[8]=d):d=e[8],(0,b.useEffect)(o,d),null},"Te"),Ve=u(({columnsError:a,fill:e=!1,nodeClasses:t,tables:n,testIdPrefix:r})=>{let l=$(),[o,d]=(0,b.useState)($e),[c,m]=(0,b.useState)(""),i=(0,b.useMemo)(()=>{let g=c.trim().toLowerCase();return n.filter(K=>o[K.tier]&&K.name.toLowerCase().includes(g))},[n,o,c]),f=(0,b.useMemo)(()=>Se(i,a??!1,t??Me),[i,a,t]),p=(0,b.useMemo)(()=>ke(i),[i]),x=i.map(g=>g.name).join(","),[h,R,ee]=H(f),[te,F,ae]=L(p),C=(0,b.useRef)(null);(0,b.useEffect)(()=>{R(f)},[f,R]),(0,b.useEffect)(()=>{F(p)},[p,F]);let re=u(g=>{m(g.target.value)},"V"),oe=u(()=>{d(g=>({...g,shard:!g.shard}))},"W"),ne=u(()=>{d(g=>({...g,global:!g.global}))},"Y");return n.length===0?(0,s.jsx)("section",{className:"flex flex-col gap-2","data-testid":`${r}-section`,children:(0,s.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":`${r}-empty`,children:l("No tables to graph.")})}):(0,s.jsx)("section",{className:N("flex flex-col",e&&"min-h-0 flex-1"),"data-testid":`${r}-section`,children:(0,s.jsx)("div",{className:N("w-full overflow-hidden border border-border bg-muted/20",e?"min-h-0 flex-1":"h-[560px]"),"data-testid":`${r}-canvas`,ref:C,children:(0,s.jsxs)(B,{edges:te,elementsSelectable:!0,fitView:!0,minZoom:.2,nodes:h,nodesConnectable:!1,nodeTypes:we,onEdgesChange:ae,onNodesChange:ee,children:[(0,s.jsx)(O,{}),(0,s.jsx)(z,{position:"top-left",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card/95 p-2 shadow-xs",children:[(0,s.jsx)(I,{"aria-label":l("Find table\u2026"),className:"h-7 w-44 text-xs","data-testid":`${r}-find`,onChange:re,placeholder:l("Find table\u2026"),value:c}),(0,s.jsxs)("div",{"aria-label":l("Storage tiers"),className:"flex items-center gap-1.5",role:"group",children:[(0,s.jsxs)(k,{"aria-pressed":o.shard,className:"gap-1.5","data-testid":`${r}-tier-shard`,onClick:oe,size:"xs",type:"button",variant:o.shard?"default":"outline",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:U}),y.shard.label]}),(0,s.jsxs)(k,{"aria-pressed":o.global,className:"gap-1.5","data-testid":`${r}-tier-global`,onClick:ne,size:"xs",type:"button",variant:o.global?"default":"outline",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:X}),y.global.label]})]})]})}),(0,s.jsx)(z,{position:"bottom-center",children:(0,s.jsx)(_e,{})}),(0,s.jsx)(T,{showInteractive:!1}),i.length>ze&&(0,s.jsx)(Z,{className:"!border !border-border !bg-card",maskColor:"var(--color-muted)",nodeColor:"var(--color-muted-foreground)",nodeStrokeWidth:0,pannable:!0,zoomable:!0}),(0,s.jsx)(q,{containerRef:C,filenameBase:`${r}-schema-diagram`,testIdPrefix:r}),(0,s.jsx)(Ee,{containerRef:C,seedKey:x})]})})})},"Ke");export{Ve as a};
1
+ import{a as y,b as D}from"./chunk-JNWK5MJC.js";import{a as _,b as z,c as j,d as E,e as B,f as H,g as L,h as V,i as O,j as T,k as Z,l as q}from"./chunk-U5YP7MSK.js";import{i as I}from"./chunk-OKZINWBB.js";import{a as k}from"./chunk-NVMQPIRS.js";import{b as w}from"./chunk-UV6GPH2E.js";import{B as $,s as P,x as N}from"./chunk-PN7JHEYW.js";import{a as se}from"./chunk-A6TVTNKO.js";import{a as le,b as de}from"./chunk-ADABTCDI.js";import{a as u,d as S}from"./chunk-5PEAXTYQ.js";var v=S(se(),1);var b=S(le(),1);var s=S(de(),1);function ie(a){let e=(0,v.c)(10),t,n,r;e[0]!==a?({className:t,selected:r,...n}=a,e[0]=a,e[1]=t,e[2]=n,e[3]=r):(t=e[1],n=e[2],r=e[3]);let l=r===!0?"":void 0,o;e[4]!==t?(o=N("rounded-md border border-border bg-card text-card-foreground shadow-sm transition-colors","data-[selected]:border-ring data-[selected]:ring-[3px] data-[selected]:ring-ring/30",t),e[4]=t,e[5]=o):o=e[5];let d;return e[6]!==n||e[7]!==l||e[8]!==o?(d=(0,s.jsx)("div",{"data-slot":"base-node","data-selected":l,className:o,...n}),e[6]=n,e[7]=l,e[8]=o,e[9]=d):d=e[9],d}u(ie,"ie");function ce(a){let e=(0,v.c)(8),t,n;e[0]!==a?({className:t,...n}=a,e[0]=a,e[1]=t,e[2]=n):(t=e[1],n=e[2]);let r;e[3]!==t?(r=N("flex items-center gap-2 rounded-t-md bg-muted/50 px-3 py-1.5",t),e[3]=t,e[4]=r):r=e[4];let l;return e[5]!==n||e[6]!==r?(l=(0,s.jsx)("div",{"data-slot":"base-node-header",className:r,...n}),e[5]=n,e[6]=r,e[7]=l):l=e[7],l}u(ce,"ce");function me(a){let e=(0,v.c)(8),t,n;e[0]!==a?({className:t,...n}=a,e[0]=a,e[1]=t,e[2]=n):(t=e[1],n=e[2]);let r;e[3]!==t?(r=N("flex flex-col",t),e[3]=t,e[4]=r):r=e[4];let l;return e[5]!==n||e[6]!==r?(l=(0,s.jsx)("div",{"data-slot":"base-node-content",className:r,...n}),e[5]=n,e[6]=r,e[7]=l):l=e[7],l}u(me,"de");var ue=3,fe=u((a,e,t)=>{let n=e?a:a.slice(0,ue),r=n.map(o=>JSON.stringify(o)).join(" | "),l=a.length-n.length;return l>0?`${r} ${t("+{count} more",{count:l})}`:r},"fe"),J=u((a,e,t)=>{let n=a.enumValues??[],r=n.length===0?a.type:fe(n,e,t),l=a.ref===void 0?r:`${r} \u2192 ${a.ref}`;return a.optional===!0?`${l}?`:l},"H"),pe=u(a=>{let e=(0,v.c)(23),{data:t,selected:n}=a,r=$(),l;e[0]!==t.label||e[1]!==t.loadError||e[2]!==r?(l=t.loadError===!0?(0,s.jsx)("span",{className:"px-3 py-1.5 text-xs text-destructive","data-testid":`sd-node-${t.label}-error`,children:r("Columns unavailable")}):(0,s.jsx)("span",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"\u2014"}),e[0]=t.label,e[1]=t.loadError,e[2]=r,e[3]=l):l=e[3];let o=l,d=`sd-node-${t.label}`,c;e[4]!==t.label?(c=(0,s.jsx)("span",{className:"truncate font-mono text-xs font-semibold",title:t.label,children:t.label}),e[4]=t.label,e[5]=c):c=e[5];let m;e[6]!==t.tier?(m=(0,s.jsx)("span",{className:"ms-auto",children:(0,s.jsx)(D,{tier:t.tier})}),e[6]=t.tier,e[7]=m):m=e[7];let i;e[8]!==c||e[9]!==m?(i=(0,s.jsxs)(ce,{children:[c,m]}),e[8]=c,e[9]=m,e[10]=i):i=e[10];let f;e[11]!==t.columns||e[12]!==t.label||e[13]!==o||e[14]!==r?(f=t.columns.length===0?o:t.columns.map(h=>(0,s.jsxs)("div",{className:N("relative flex items-center gap-2 border-t border-border px-3 py-1.5 text-xs first:border-t-0",h.pk===!0&&"bg-muted/30"),"data-testid":`sd-col-${t.label}-${h.name}`,children:[(0,s.jsx)(E,{className:"!h-2 !w-2 !-left-1 !border-border !bg-muted-foreground/70",id:h.name,isConnectable:!1,position:_.Left,type:"target"}),(0,s.jsx)("span",{className:"truncate font-mono",title:h.name,children:h.name}),h.pk===!0&&(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"secondary",children:"PK"}),h.ref!==void 0&&(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"outline",children:"FK"}),(0,s.jsx)("span",{className:"ms-auto truncate text-muted-foreground",title:J(h,!0,r),children:J(h,!1,r)}),(0,s.jsx)(E,{className:"!h-2 !w-2 !-right-1 !border-border !bg-muted-foreground/70",id:h.name,isConnectable:!1,position:_.Right,type:"source"})]},h.name)),e[11]=t.columns,e[12]=t.label,e[13]=o,e[14]=r,e[15]=f):f=e[15];let p;e[16]!==f?(p=(0,s.jsx)(me,{children:f}),e[16]=f,e[17]=p):p=e[17];let x;return e[18]!==n||e[19]!==d||e[20]!==i||e[21]!==p?(x=(0,s.jsxs)(ie,{className:"w-64 overflow-hidden","data-testid":d,selected:n,children:[i,p]}),e[18]=n,e[19]=d,e[20]=i,e[21]=p,e[22]=x):x=e[22],x},"ue"),G=256,Q=112,W=36,M=24,he=480,be=1.4,ge=u(a=>{let e=Math.max(1,Math.round(Math.sqrt(be*a/(G+Q))));return Math.max(he,a/e)},"ge"),xe=38,Ne=28,A=u(a=>xe+Math.max(1,a)*Ne,"B"),ye=u((a,e)=>{let t=new Map;for(let o of a)t.set(o,[]);for(let o of e)o.to!==o.from&&t.has(o.from)&&t.has(o.to)&&t.get(o.from)?.push(o.to);let n=new Map,r=new Set,l=u(o=>{let d=n.get(o);if(d!==void 0)return d;if(r.has(o))return 0;r.add(o);let c=0;for(let m of t.get(o)??[])c=Math.max(c,l(m)+1);return r.delete(o),n.set(o,c),c},"r");for(let o of a)l(o);return n},"Ne"),ve=u((a,e,t)=>{let n=ye(a,e),r=new Map;for(let m of a){let i=n.get(m)??0,f=r.get(i);f===void 0?r.set(i,[m]):f.push(m)}let l=a.reduce((m,i)=>m+A(t.get(i)??0)+W,0),o=ge(l),d=[],c=0;for(let m of[...r.keys()].toSorted((i,f)=>i-f)){let i=0,f=M;for(let p of r.get(m)??[]){let x=A(t.get(p)??0);f>M&&f+x>o&&(i+=1,f=M),d.push({name:p,x:M+(c+i)*(G+Q),y:f}),f+=x+W}c+=i+1}return d},"ye"),we={databaseSchema:pe},U={backgroundColor:y.shard.color},X={backgroundColor:y.global.color},$e={global:!0,shard:!0},Me={},Ce=u(a=>{let e=a.find(t=>t.pk===!0)?.name;return e!==void 0?e:a.some(t=>t.name==="_id")?"_id":a.some(t=>t.name==="id")?"id":a[0]?.name??"_id"},"_e"),Y=u(a=>a.flatMap(e=>e.columns.filter(t=>t.ref!==void 0).map(t=>({column:t.name,from:e.name,to:t.ref}))),"K"),Se=u((a,e,t)=>{let n=a.map(d=>d.name),r=new Map(a.map(d=>[d.name,d.columns.length])),l=ve(n,Y(a),r),o=new Map(a.map(d=>[d.name,d]));return l.flatMap(({name:d,x:c,y:m})=>{let i=o.get(d);return i===void 0?[]:[{className:t[d],data:{columns:i.columns,label:d,loadError:e,tier:i.tier},id:d,position:{x:c,y:m},type:"databaseSchema"}]})},"we"),ke=u(a=>{let e=new Map(a.map(t=>[t.name,t.columns]));return Y(a).flatMap(t=>{let n=e.get(t.to)??[],r=e.get(t.from)??[],l=Ce(n);return!n.some(o=>o.name===l)||!r.some(o=>o.name===t.column)?[]:[{id:`${t.from}.${t.column}->${t.to}`,source:t.to,sourceHandle:l,target:t.from,targetHandle:t.column}]})},"Me"),_e=u(()=>{let a=(0,v.c)(15),e=$(),t;a[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:U}),y.shard.label]}),a[0]=t):t=a[0];let n;a[1]===Symbol.for("react.memo_cache_sentinel")?(n=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:X}),y.global.label]}),a[1]=n):n=a[1];let r;a[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"secondary",children:"PK"}),a[2]=r):r=a[2];let l;a[3]!==e?(l=e("Primary key"),a[3]=e,a[4]=l):l=a[4];let o;a[5]!==l?(o=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[r,l]}),a[5]=l,a[6]=o):o=a[6];let d;a[7]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"outline",children:"FK"}),a[7]=d):d=a[7];let c;a[8]!==e?(c=e("Foreign key"),a[8]=e,a[9]=c):c=a[9];let m;a[10]!==c?(m=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[d,c]}),a[10]=c,a[11]=m):m=a[11];let i;return a[12]!==o||a[13]!==m?(i=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 rounded-xl border border-border bg-card/95 px-2.5 py-1.5 text-[11px] text-muted-foreground shadow-xs",children:[t,n,o,m]}),a[12]=o,a[13]=m,a[14]=i):i=a[14],i},"Ce"),ze=12,Ee=u(a=>{let e=(0,v.c)(9),{containerRef:t,seedKey:n}=a,r=V(),{fitView:l}=j(),o;e[0]!==t||e[1]!==l||e[2]!==r?(o=u(()=>{if(!r)return;let c=u(()=>{P(l({duration:0,maxZoom:1.6,padding:.14}))},"d");c();let m=t.current;if(m===null)return;let i=new ResizeObserver(()=>{c()});return i.observe(m),()=>{i.disconnect()}},"a"),e[0]=t,e[1]=l,e[2]=r,e[3]=o):o=e[3];let d;return e[4]!==t||e[5]!==l||e[6]!==r||e[7]!==n?(d=[t,l,r,n],e[4]=t,e[5]=l,e[6]=r,e[7]=n,e[8]=d):d=e[8],(0,b.useEffect)(o,d),null},"Te"),Ve=u(({columnsError:a,fill:e=!1,nodeClasses:t,tables:n,testIdPrefix:r})=>{let l=$(),[o,d]=(0,b.useState)($e),[c,m]=(0,b.useState)(""),i=(0,b.useMemo)(()=>{let g=c.trim().toLowerCase();return n.filter(K=>o[K.tier]&&K.name.toLowerCase().includes(g))},[n,o,c]),f=(0,b.useMemo)(()=>Se(i,a??!1,t??Me),[i,a,t]),p=(0,b.useMemo)(()=>ke(i),[i]),x=i.map(g=>g.name).join(","),[h,R,ee]=H(f),[te,F,ae]=L(p),C=(0,b.useRef)(null);(0,b.useEffect)(()=>{R(f)},[f,R]),(0,b.useEffect)(()=>{F(p)},[p,F]);let re=u(g=>{m(g.target.value)},"V"),oe=u(()=>{d(g=>({...g,shard:!g.shard}))},"W"),ne=u(()=>{d(g=>({...g,global:!g.global}))},"Y");return n.length===0?(0,s.jsx)("section",{className:"flex flex-col gap-2","data-testid":`${r}-section`,children:(0,s.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":`${r}-empty`,children:l("No tables to graph.")})}):(0,s.jsx)("section",{className:N("flex flex-col",e&&"min-h-0 flex-1"),"data-testid":`${r}-section`,children:(0,s.jsx)("div",{className:N("w-full overflow-hidden border border-border bg-muted/20",e?"min-h-0 flex-1":"h-[560px]"),"data-testid":`${r}-canvas`,ref:C,children:(0,s.jsxs)(B,{edges:te,elementsSelectable:!0,fitView:!0,minZoom:.2,nodes:h,nodesConnectable:!1,nodeTypes:we,onEdgesChange:ae,onNodesChange:ee,children:[(0,s.jsx)(O,{}),(0,s.jsx)(z,{position:"top-left",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card/95 p-2 shadow-xs",children:[(0,s.jsx)(I,{"aria-label":l("Find table\u2026"),className:"h-7 w-44 text-xs","data-testid":`${r}-find`,onChange:re,placeholder:l("Find table\u2026"),value:c}),(0,s.jsxs)("div",{"aria-label":l("Storage tiers"),className:"flex items-center gap-1.5",role:"group",children:[(0,s.jsxs)(k,{"aria-pressed":o.shard,className:"gap-1.5","data-testid":`${r}-tier-shard`,onClick:oe,size:"xs",type:"button",variant:o.shard?"default":"outline",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:U}),y.shard.label]}),(0,s.jsxs)(k,{"aria-pressed":o.global,className:"gap-1.5","data-testid":`${r}-tier-global`,onClick:ne,size:"xs",type:"button",variant:o.global?"default":"outline",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:X}),y.global.label]})]})]})}),(0,s.jsx)(z,{position:"bottom-center",children:(0,s.jsx)(_e,{})}),(0,s.jsx)(T,{showInteractive:!1}),i.length>ze&&(0,s.jsx)(Z,{className:"!border !border-border !bg-card",maskColor:"var(--color-muted)",nodeColor:"var(--color-muted-foreground)",nodeStrokeWidth:0,pannable:!0,zoomable:!0}),(0,s.jsx)(q,{containerRef:C,filenameBase:`${r}-schema-diagram`,testIdPrefix:r}),(0,s.jsx)(Ee,{containerRef:C,seedKey:x})]})})})},"Ke");export{Ve as a};
@@ -1 +1 @@
1
- import{b as c}from"./chunk-3CUQWI5A.js";import{n as l}from"./chunk-F4ZN2DRL.js";import{a as g}from"./chunk-A6TVTNKO.js";import{a as r,d as f}from"./chunk-5PEAXTYQ.js";var m=f(g(),1);var p={capabilities:{accounts:!0,apiKey:!1,admin:!0,inviteOnly:!1,organization:!1,passkey:!1,twoFactor:!1},emailAndPassword:!1,organization:{enabled:!1,roles:!1,teams:!1},plugins:[],rateLimit:{enabled:!1},session:{},socialProviders:[],userFields:[]},h=r(()=>{let a=(0,m.c)(6),t=l(),o;a[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-auth-config"],a[0]=o):o=a[0];let e;a[1]!==t?(e=r(()=>t.getAuthConfig(),"t"),a[1]=t,a[2]=e):e=a[2];let{data:d,isLoading:u}=c(o,e),n=d??p,s=!u,i;return a[3]!==n||a[4]!==s?(i={config:n,ready:s},a[3]=n,a[4]=s,a[5]=i):i=a[5],i},"y");export{h as a};
1
+ import{b as c}from"./chunk-UN3QTZ6X.js";import{n as l}from"./chunk-5KQSRLQP.js";import{a as g}from"./chunk-A6TVTNKO.js";import{a as r,d as f}from"./chunk-5PEAXTYQ.js";var m=f(g(),1);var p={capabilities:{accounts:!0,apiKey:!1,admin:!0,inviteOnly:!1,organization:!1,passkey:!1,twoFactor:!1},emailAndPassword:!1,organization:{enabled:!1,roles:!1,teams:!1},plugins:[],rateLimit:{enabled:!1},session:{},socialProviders:[],userFields:[]},h=r(()=>{let a=(0,m.c)(6),t=l(),o;a[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-auth-config"],a[0]=o):o=a[0];let e;a[1]!==t?(e=r(()=>t.getAuthConfig(),"t"),a[1]=t,a[2]=e):e=a[2];let{data:d,isLoading:u}=c(o,e),n=d??p,s=!u,i;return a[3]!==n||a[4]!==s?(i={config:n,ready:s},a[3]=n,a[4]=s,a[5]=i):i=a[5],i},"y");export{h as a};
@@ -1 +1 @@
1
- import{a as O}from"./chunk-Z7HICJ3Z.js";import{a as C}from"./chunk-A27GQYC7.js";import{a as c}from"./chunk-FOXLEMWC.js";import{b as N}from"./chunk-26XOFIV4.js";import"./chunk-L27FKJTG.js";import{a as k}from"./chunk-VX6ZBLXB.js";import"./chunk-CHYLD556.js";import{a as w,b as T,c as A,d as f,e as s,f as l}from"./chunk-7MM2SI65.js";import"./chunk-3SRQFKDT.js";import"./chunk-RY6I3E2K.js";import"./chunk-EOFWXI3T.js";import{a as v}from"./chunk-LYVYUTQY.js";import{c as p}from"./chunk-3CUQWI5A.js";import{a as b,e as S}from"./chunk-QQENKHRS.js";import"./chunk-F4ZN2DRL.js";import"./chunk-ZPQBVYNN.js";import{B as y}from"./chunk-ITS5LMYJ.js";import"./chunk-PDBW6GTJ.js";import"./chunk-A6TVTNKO.js";import{a as R,b as V}from"./chunk-ADABTCDI.js";import{a as n,d as x}from"./chunk-5PEAXTYQ.js";var F=x(R(),1);var e=x(V(),1);var $=n(a=>{let t=a.trim();if(t.length===0)return{context:void 0,error:null};try{let o=JSON.parse(t);return o===null||typeof o!="object"||Array.isArray(o)?{context:void 0,error:"Targeting context must be a JSON object."}:{context:o,error:null}}catch{return{context:void 0,error:"Targeting context is not valid JSON."}}},"H"),q='{ "targetingKey": "user-123", "plan": "premium" }',D=n(a=>a.type==="object"?JSON.stringify(a.value):String(a.value),"R"),Y=n(({initialShardKey:a=""})=>{let t=y(),[o,j]=(0,F.useState)(""),{context:g,error:m}=$(o),I=g===void 0?{}:{context:g},{data:i,error:J,errorSource:K,liveError:E}=p(v.listFlags,I,{live:!0,shardKey:a}),u=i!==void 0,L=i?.configured??!1,h=Array.isArray(i?.flags)?[...i.flags].toSorted((r,B)=>r.key.localeCompare(B.key)):[],d;return u&&!L?d=(0,e.jsx)(c,{description:t("No @lunora/flags provider is wired in this deployment. Add lunora/flags.ts with defineFlags({ provider }) to gate code paths on feature flags."),testId:"flags-unconfigured",title:t("No flags provider configured")}):u&&h.length===0?d=(0,e.jsx)(c,{description:t('A flags provider is configured, but no handler reads a flag yet. Call ctx.flags.boolean("key", false) in a query, mutation, or action.'),testId:"flags-empty",title:t("No flags read")}):d=(0,e.jsx)(b,{className:"overflow-hidden py-0",children:(0,e.jsx)(S,{className:"px-0",children:(0,e.jsxs)(w,{"data-testid":"flags-table",children:[(0,e.jsx)(T,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(s,{children:t("Key")}),(0,e.jsx)(s,{children:t("Type")}),(0,e.jsx)(s,{children:t("Value")}),(0,e.jsx)(s,{children:t("Reason")}),(0,e.jsx)(s,{children:t("Variant")})]})}),(0,e.jsx)(A,{children:h.map(r=>(0,e.jsxs)(f,{"data-testid":`flags-row-${r.key}`,children:[(0,e.jsx)(l,{className:"font-mono text-xs",children:r.key}),(0,e.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:r.type}),(0,e.jsx)(l,{className:"font-mono text-xs",children:D(r)}),(0,e.jsx)(l,{children:r.errorCode===void 0?(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:r.reason??"\u2014"}):(0,e.jsx)(N,{"data-testid":`flags-error-${r.key}`,variant:"destructive",children:r.errorCode})}),(0,e.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:r.variant??"\u2014"})]},r.key))})]})})}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-flags-panel",children:[J!==null&&(0,e.jsx)(k,{error:K,shardKey:a,testId:"flags-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t('Feature flags are read in code with ctx.flags.<type>("key", default). They evaluate through the OpenFeature provider configured in lunora/flags.ts; edit the targeting context below to see how each flag resolves for a given audience.')}),(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,e.jsx)(C,{htmlFor:"flags-targeting-context",children:t("Targeting context (JSON)")}),(0,e.jsx)(O,{className:"font-mono text-xs","data-testid":"flags-context-input",id:"flags-targeting-context",onChange:n(r=>{j(r.target.value)},"onChange"),placeholder:q,rows:3,value:o}),m!==null&&(0,e.jsx)("p",{className:"text-xs text-destructive","data-testid":"flags-context-error",role:"alert",children:t(m)}),E!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"flags-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")})]}),d]})},"W");export{Y as default};
1
+ import{a as O}from"./chunk-4AGOKKRZ.js";import{a as C}from"./chunk-CJ2V577P.js";import{a as c}from"./chunk-S3TDGFRE.js";import{b as N}from"./chunk-UV6GPH2E.js";import"./chunk-L27FKJTG.js";import{a as k}from"./chunk-D3MLU3PX.js";import"./chunk-S7NFUY75.js";import{a as w,b as T,c as A,d as f,e as s,f as l}from"./chunk-J3ZEO3PJ.js";import"./chunk-YDDMKWPI.js";import"./chunk-5CHKXJYN.js";import"./chunk-EOFWXI3T.js";import{a as v}from"./chunk-LYVYUTQY.js";import{c as p}from"./chunk-UN3QTZ6X.js";import{a as b,e as S}from"./chunk-TN4Z3P6S.js";import"./chunk-5KQSRLQP.js";import"./chunk-ZPQBVYNN.js";import{B as y}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import"./chunk-A6TVTNKO.js";import{a as R,b as V}from"./chunk-ADABTCDI.js";import{a as n,d as x}from"./chunk-5PEAXTYQ.js";var F=x(R(),1);var e=x(V(),1);var $=n(a=>{let t=a.trim();if(t.length===0)return{context:void 0,error:null};try{let o=JSON.parse(t);return o===null||typeof o!="object"||Array.isArray(o)?{context:void 0,error:"Targeting context must be a JSON object."}:{context:o,error:null}}catch{return{context:void 0,error:"Targeting context is not valid JSON."}}},"H"),q='{ "targetingKey": "user-123", "plan": "premium" }',D=n(a=>a.type==="object"?JSON.stringify(a.value):String(a.value),"R"),Y=n(({initialShardKey:a=""})=>{let t=y(),[o,j]=(0,F.useState)(""),{context:g,error:m}=$(o),I=g===void 0?{}:{context:g},{data:i,error:J,errorSource:K,liveError:E}=p(v.listFlags,I,{live:!0,shardKey:a}),u=i!==void 0,L=i?.configured??!1,h=Array.isArray(i?.flags)?[...i.flags].toSorted((r,B)=>r.key.localeCompare(B.key)):[],d;return u&&!L?d=(0,e.jsx)(c,{description:t("No @lunora/flags provider is wired in this deployment. Add lunora/flags.ts with defineFlags({ provider }) to gate code paths on feature flags."),testId:"flags-unconfigured",title:t("No flags provider configured")}):u&&h.length===0?d=(0,e.jsx)(c,{description:t('A flags provider is configured, but no handler reads a flag yet. Call ctx.flags.boolean("key", false) in a query, mutation, or action.'),testId:"flags-empty",title:t("No flags read")}):d=(0,e.jsx)(b,{className:"overflow-hidden py-0",children:(0,e.jsx)(S,{className:"px-0",children:(0,e.jsxs)(w,{"data-testid":"flags-table",children:[(0,e.jsx)(T,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(s,{children:t("Key")}),(0,e.jsx)(s,{children:t("Type")}),(0,e.jsx)(s,{children:t("Value")}),(0,e.jsx)(s,{children:t("Reason")}),(0,e.jsx)(s,{children:t("Variant")})]})}),(0,e.jsx)(A,{children:h.map(r=>(0,e.jsxs)(f,{"data-testid":`flags-row-${r.key}`,children:[(0,e.jsx)(l,{className:"font-mono text-xs",children:r.key}),(0,e.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:r.type}),(0,e.jsx)(l,{className:"font-mono text-xs",children:D(r)}),(0,e.jsx)(l,{children:r.errorCode===void 0?(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:r.reason??"\u2014"}):(0,e.jsx)(N,{"data-testid":`flags-error-${r.key}`,variant:"destructive",children:r.errorCode})}),(0,e.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:r.variant??"\u2014"})]},r.key))})]})})}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-flags-panel",children:[J!==null&&(0,e.jsx)(k,{error:K,shardKey:a,testId:"flags-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t('Feature flags are read in code with ctx.flags.<type>("key", default). They evaluate through the OpenFeature provider configured in lunora/flags.ts; edit the targeting context below to see how each flag resolves for a given audience.')}),(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,e.jsx)(C,{htmlFor:"flags-targeting-context",children:t("Targeting context (JSON)")}),(0,e.jsx)(O,{className:"font-mono text-xs","data-testid":"flags-context-input",id:"flags-targeting-context",onChange:n(r=>{j(r.target.value)},"onChange"),placeholder:q,rows:3,value:o}),m!==null&&(0,e.jsx)("p",{className:"text-xs text-destructive","data-testid":"flags-context-error",role:"alert",children:t(m)}),E!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"flags-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")})]}),d]})},"W");export{Y as default};
@@ -1 +1 @@
1
- import{x as d}from"./chunk-ITS5LMYJ.js";import{a as m}from"./chunk-A6TVTNKO.js";import{b as i}from"./chunk-ADABTCDI.js";import{a as c,d as b}from"./chunk-5PEAXTYQ.js";var n=b(m(),1);var o=b(i(),1);function p(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("w-full caption-bottom text-xs",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto overflow-y-clip",children:(0,o.jsx)("table",{"data-slot":"table",className:l,...a})}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(p,"f");function f(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("bg-muted/50 [&_tr]:border-b",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("thead",{"data-slot":"table-header",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(f,"p");function h(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("[&_tr:last-child]:border-0",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("tbody",{"data-slot":"table-body",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(h,"m");function x(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("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 s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("tr",{"data-slot":"table-row",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(x,"u");function N(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("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 s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("th",{"data-slot":"table-head",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(N,"h");function w(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("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 s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("td",{"data-slot":"table-cell",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(w,"x");export{p as a,f as b,h as c,x as d,N as e,w as f};
1
+ import{x as d}from"./chunk-PN7JHEYW.js";import{a as m}from"./chunk-A6TVTNKO.js";import{b as i}from"./chunk-ADABTCDI.js";import{a as c,d as b}from"./chunk-5PEAXTYQ.js";var n=b(m(),1);var o=b(i(),1);function p(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("w-full caption-bottom text-xs",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto overflow-y-clip",children:(0,o.jsx)("table",{"data-slot":"table",className:l,...a})}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(p,"f");function f(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("bg-muted/50 [&_tr]:border-b",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("thead",{"data-slot":"table-header",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(f,"p");function h(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("[&_tr:last-child]:border-0",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("tbody",{"data-slot":"table-body",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(h,"m");function x(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("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 s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("tr",{"data-slot":"table-row",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(x,"u");function N(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("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 s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("th",{"data-slot":"table-head",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(N,"h");function w(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("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 s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("td",{"data-slot":"table-cell",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(w,"x");export{p as a,f as b,h as c,x as d,N as e,w as f};
@@ -1 +1 @@
1
- import{d as E,e as _}from"./chunk-FWM5Z6CH.js";import{a as $}from"./chunk-4UDH2YI4.js";import{a as de}from"./chunk-RWEEBORY.js";import"./chunk-ROHVLVGW.js";import{a as ce}from"./chunk-RRDXY56O.js";import"./chunk-QLZGKBOW.js";import"./chunk-Y2YLTUMD.js";import"./chunk-R3RIZDUS.js";import{a as le}from"./chunk-2KTN53PK.js";import{a as re}from"./chunk-EI2FSTI3.js";import"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import"./chunk-GTW3JPQQ.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import"./chunk-OZID3UYF.js";import{a as ae}from"./chunk-FOXLEMWC.js";import{b as K}from"./chunk-26XOFIV4.js";import"./chunk-L27FKJTG.js";import{a as ie}from"./chunk-VX6ZBLXB.js";import"./chunk-CHYLD556.js";import{a as R,b as W,c as Z,d as A,e as M,f as S}from"./chunk-7MM2SI65.js";import"./chunk-3SRQFKDT.js";import"./chunk-RY6I3E2K.js";import"./chunk-EOFWXI3T.js";import{a as U}from"./chunk-LYVYUTQY.js";import{c as D}from"./chunk-3CUQWI5A.js";import{a as q,b as H,c as J,e as ne}from"./chunk-QQENKHRS.js";import"./chunk-F4ZN2DRL.js";import"./chunk-ZPQBVYNN.js";import{B as F,w as oe}from"./chunk-ITS5LMYJ.js";import"./chunk-PDBW6GTJ.js";import{a as be}from"./chunk-A6TVTNKO.js";import{b as ge}from"./chunk-ADABTCDI.js";import{a as p,d as se}from"./chunk-5PEAXTYQ.js";var O=se(be(),1);var o=se(ge(),1);var G="gen_ai.usage.input_tokens",Q="gen_ai.usage.output_tokens",V="gen_ai.usage.cost",fe="gen_ai.request.model",Te="lunora.usage.cost.source",xe=new Set(["ai.embed","ai.generate","ai.stream"]),ue=6e4,Ce=1440,ve="unknown",X=p(()=>({calls:0,estimatedCost:0,inputTokens:0,outputTokens:0,providerCost:0}),"q"),Y=p((n,e)=>{let s=n?.[e];return typeof s=="string"&&s!==""?s:void 0},"J"),z=p((n,e)=>{let s=n?.[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0},"L"),ee=p(n=>Y(n,Te)==="provider"?"provider":"estimated","Q"),me=p((n,e)=>n.reduce((s,a)=>s+e(a),0),"Y"),B=p(n=>n.providerCost+n.estimatedCost,"F"),ke=p(n=>n.estimatedCost>0?n.providerCost>0?"mixed":"estimated":n.providerCost>0?"provider":"none","ae"),ye=p((n,e)=>({calls:n.calls+e.calls,estimatedCost:n.estimatedCost+e.estimatedCost,inputTokens:n.inputTokens+e.inputTokens,outputTokens:n.outputTokens+e.outputTokens,providerCost:n.providerCost+e.providerCost}),"ce"),Ie=p(n=>{let e=X(),s=0,a=0,t=0;for(let c of n){let l=me(c.points,i=>i.sum),r=me(c.points,i=>i.count);c.name===G?(e.inputTokens+=l,s+=r):c.name===Q?(e.outputTokens+=l,a+=r):(t+=r,ee(c.attributes)==="provider"?e.providerCost+=l:e.estimatedCost+=l)}return e.calls=Math.max(s,a,t),e},"ge"),Ne=p((n,e)=>B(e)-B(n)||e.inputTokens+e.outputTokens-(n.inputTokens+n.outputTokens)||n.key.localeCompare(e.key),"Ne"),pe=p((n,e)=>{let s=new Map;for(let a of n){let t=e(a);s.set(t,{key:t,...ye(s.get(t)??X(),a)})}return[...s.values()].toSorted(Ne)},"Z"),we=p(n=>(n?.series??[]).filter(e=>e.name===G||e.name===Q||e.name===V),"xe"),Me=p(n=>Y(n.attributes,fe)??ve,"Se"),Se=p(n=>{let e=new Map;for(let s of n){let a=Me(s),t=JSON.stringify([s.functionPath,a]),c=e.get(t)??{functionPath:s.functionPath,model:a,series:[]};c.series.push(s),e.set(t,c)}return[...e.values()].map(({functionPath:s,model:a,series:t})=>({functionPath:s,model:a,...Ie(t)}))},"Ie"),_e=p(n=>{let e=new Map;for(let r of n){if(r.name!==V)continue;let i=ee(r.attributes)==="provider";for(let u of r.points){let m=e.get(u.bucketMs)??{bucketMs:u.bucketMs,estimatedCost:0,providerCost:0};i?m.providerCost+=u.sum:m.estimatedCost+=u.sum,e.set(u.bucketMs,m)}}let s=[...e.keys()].toSorted((r,i)=>r-i),a=s[0],t=s.at(-1);if(a===void 0||t===void 0)return[];let c=Math.max(a,t-(Ce-1)*ue),l=[];for(let r=c;r<=t;r+=ue)l.push(e.get(r)??{bucketMs:r,estimatedCost:0,providerCost:0});return l},"_e"),Pe=p(n=>{let e=[];for(let s of n)for(let a of s.spans){if(!xe.has(a.name))continue;let{attributes:t}=a,c=z(t,V),l=z(t,G),r=z(t,Q);e.push({...c===void 0?{}:{cost:c,costSource:ee(t)},functionPath:s.functionPath,...l===void 0?{}:{inputTokens:l},model:Y(t,fe)??ve,ok:a.ok,...r===void 0?{}:{outputTokens:r},startTs:s.startTs+a.offsetMs,streaming:a.name==="ai.stream",traceId:s.traceId})}return e.toSorted((s,a)=>a.startTs-s.startTs)},"Me"),Fe=p(n=>n.map(e=>{let s=e.cost??0;return{calls:1,estimatedCost:e.costSource==="provider"?0:s,functionPath:e.functionPath,inputTokens:e.inputTokens??0,model:e.model,outputTokens:e.outputTokens??0,providerCost:e.costSource==="provider"?s:0}}),"Oe"),Oe=p((n,e)=>{let s=we(n),a=Pe(e),t=s.length>0,c=t?Se(s):Fe(a),l=X(),r="none";for(let i of c)l=ye(l,i);return t?r="history":a.length>0&&(r="live"),{byFunction:pe(c,i=>i.functionPath),byModel:pe(c,i=>i.model),calls:a,source:r,totals:l,trend:t?_e(s):[]}},"Ae"),Ke=p(n=>Array.isArray(n?.traces)?n.traces:[],"Ee"),Ae=25,te=p(n=>{let e=(0,O.c)(16),{provenance:s,value:a}=n,t=F();if(s==="none"){let m;return e[0]===Symbol.for("react.memo_cache_sentinel")?(m=(0,o.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),e[0]=m):m=e[0],m}let c;e[1]!==s||e[2]!==a?(c=s==="provider"?E(a):`~${E(a)}`,e[1]=s,e[2]=a,e[3]=c):c=e[3];let l;e[4]!==c?(l=(0,o.jsx)("span",{className:"tabular-nums",children:c}),e[4]=c,e[5]=l):l=e[5];let r;e[6]!==s||e[7]!==t?(r=s==="estimated"?(0,o.jsx)(K,{title:t("Derived from a price table, not reported by the provider."),variant:"warning",children:t("Estimated")}):null,e[6]=s,e[7]=t,e[8]=r):r=e[8];let i;e[9]!==s||e[10]!==t?(i=s==="mixed"?(0,o.jsx)(K,{title:t("Includes cost derived from a price table, not reported by the provider."),variant:"warning",children:t("Partly estimated")}):null,e[9]=s,e[10]=t,e[11]=i):i=e[11];let u;return e[12]!==l||e[13]!==r||e[14]!==i?(u=(0,o.jsxs)("span",{className:"inline-flex items-center gap-2",children:[l,r,i]}),e[12]=l,e[13]=r,e[14]=i,e[15]=u):u=e[15],u},"V"),he=p(n=>{let e=(0,O.c)(40),{keyLabel:s,rows:a,testId:t,title:c}=n,l=F(),r;e[0]!==c?(r=(0,o.jsx)(H,{className:"px-4 py-3",children:(0,o.jsx)(J,{children:c})}),e[0]=c,e[1]=r):r=e[1];let i;e[2]!==s?(i=(0,o.jsx)(M,{children:s}),e[2]=s,e[3]=i):i=e[3];let u;e[4]!==l?(u=l("Calls"),e[4]=l,e[5]=u):u=e[5];let m;e[6]!==u?(m=(0,o.jsx)(M,{className:"text-end",children:u}),e[6]=u,e[7]=m):m=e[7];let k;e[8]!==l?(k=l("Input tokens"),e[8]=l,e[9]=k):k=e[9];let y;e[10]!==k?(y=(0,o.jsx)(M,{className:"text-end",children:k}),e[10]=k,e[11]=y):y=e[11];let b;e[12]!==l?(b=l("Output tokens"),e[12]=l,e[13]=b):b=e[13];let T;e[14]!==b?(T=(0,o.jsx)(M,{className:"text-end",children:b}),e[14]=b,e[15]=T):T=e[15];let g;e[16]!==l?(g=l("Cost"),e[16]=l,e[17]=g):g=e[17];let d;e[18]!==g?(d=(0,o.jsx)(M,{className:"text-end",children:g}),e[18]=g,e[19]=d):d=e[19];let x;e[20]!==d||e[21]!==i||e[22]!==m||e[23]!==y||e[24]!==T?(x=(0,o.jsx)(W,{children:(0,o.jsxs)(A,{children:[i,m,y,T,d]})}),e[20]=d,e[21]=i,e[22]=m,e[23]=y,e[24]=T,e[25]=x):x=e[25];let h;if(e[26]!==a||e[27]!==t){let N;e[29]!==t?(N=p(w=>(0,o.jsxs)(A,{"data-testid":`${t}-row`,children:[(0,o.jsx)(S,{className:"max-w-[280px] truncate font-mono",title:w.key,children:w.key}),(0,o.jsx)(S,{className:"text-end tabular-nums",children:_(w.calls)}),(0,o.jsx)(S,{className:"text-end tabular-nums",children:_(w.inputTokens)}),(0,o.jsx)(S,{className:"text-end tabular-nums",children:_(w.outputTokens)}),(0,o.jsx)(S,{className:"text-end",children:(0,o.jsx)(te,{provenance:ke(w),value:B(w)})})]},w.key),"x"),e[29]=t,e[30]=N):N=e[30],h=a.map(N),e[26]=a,e[27]=t,e[28]=h}else h=e[28];let f;e[31]!==h?(f=(0,o.jsx)(Z,{children:h}),e[31]=h,e[32]=f):f=e[32];let v;e[33]!==x||e[34]!==f?(v=(0,o.jsxs)(R,{children:[x,f]}),e[33]=x,e[34]=f,e[35]=v):v=e[35];let C;return e[36]!==r||e[37]!==v||e[38]!==t?(C=(0,o.jsxs)(q,{className:"gap-0 py-0","data-testid":t,children:[r,v]}),e[36]=r,e[37]=v,e[38]=t,e[39]=C):C=e[39],C},"ee"),$e=p(n=>{let e=(0,O.c)(55),{calls:s,onOpenTrace:a}=n,t=F(),c;e[0]!==t?(c=t("Recent calls"),e[0]=t,e[1]=c):c=e[1];let l;e[2]!==c?(l=(0,o.jsx)(H,{className:"px-4 py-3",children:(0,o.jsx)(J,{children:c})}),e[2]=c,e[3]=l):l=e[3];let r;e[4]!==t?(r=t("When"),e[4]=t,e[5]=r):r=e[5];let i;e[6]!==r?(i=(0,o.jsx)(M,{children:r}),e[6]=r,e[7]=i):i=e[7];let u;e[8]!==t?(u=t("Function"),e[8]=t,e[9]=u):u=e[9];let m;e[10]!==u?(m=(0,o.jsx)(M,{children:u}),e[10]=u,e[11]=m):m=e[11];let k;e[12]!==t?(k=t("Model"),e[12]=t,e[13]=k):k=e[13];let y;e[14]!==k?(y=(0,o.jsx)(M,{children:k}),e[14]=k,e[15]=y):y=e[15];let b;e[16]!==t?(b=t("Input tokens"),e[16]=t,e[17]=b):b=e[17];let T;e[18]!==b?(T=(0,o.jsx)(M,{className:"text-end",children:b}),e[18]=b,e[19]=T):T=e[19];let g;e[20]!==t?(g=t("Output tokens"),e[20]=t,e[21]=g):g=e[21];let d;e[22]!==g?(d=(0,o.jsx)(M,{className:"text-end",children:g}),e[22]=g,e[23]=d):d=e[23];let x;e[24]!==t?(x=t("Cost"),e[24]=t,e[25]=x):x=e[25];let h;e[26]!==x?(h=(0,o.jsx)(M,{className:"text-end",children:x}),e[26]=x,e[27]=h):h=e[27];let f;e[28]!==t?(f=t("Trace"),e[28]=t,e[29]=f):f=e[29];let v;e[30]!==f?(v=(0,o.jsx)(M,{children:f}),e[30]=f,e[31]=v):v=e[31];let C;e[32]!==T||e[33]!==d||e[34]!==h||e[35]!==v||e[36]!==i||e[37]!==m||e[38]!==y?(C=(0,o.jsx)(W,{children:(0,o.jsxs)(A,{children:[i,m,y,T,d,h,v]})}),e[32]=T,e[33]=d,e[34]=h,e[35]=v,e[36]=i,e[37]=m,e[38]=y,e[39]=C):C=e[39];let N;if(e[40]!==s||e[41]!==a||e[42]!==t){let j;e[44]!==a||e[45]!==t?(j=p(I=>(0,o.jsxs)(A,{"data-testid":"ai-call",children:[(0,o.jsx)(S,{className:"font-mono text-muted-foreground",children:oe(I.startTs)}),(0,o.jsx)(S,{className:"font-mono",children:(0,o.jsxs)("span",{className:"inline-flex items-center gap-2",children:[I.functionPath,I.streaming?(0,o.jsx)(K,{variant:"outline",children:t("stream")}):null,I.ok?null:(0,o.jsx)(K,{variant:"destructive",children:t("failed")})]})}),(0,o.jsx)(S,{className:"max-w-[240px] truncate font-mono",title:I.model,children:I.model}),(0,o.jsx)(S,{className:"text-end tabular-nums",children:I.inputTokens===void 0?"\u2014":_(I.inputTokens)}),(0,o.jsx)(S,{className:"text-end tabular-nums",children:I.outputTokens===void 0?"\u2014":_(I.outputTokens)}),(0,o.jsx)(S,{className:"text-end",children:(0,o.jsx)(te,{provenance:I.cost===void 0?"none":I.costSource??"estimated",value:I.cost??0})}),(0,o.jsx)(S,{children:(0,o.jsx)("button",{className:"font-mono text-muted-foreground underline-offset-2 hover:underline",onClick:p(()=>{a(I.traceId)},"onClick"),title:t("Open the trace {trace}",{trace:I.traceId}),type:"button",children:I.traceId.slice(0,8)})})]},`${I.traceId}:${I.startTs.toString()}:${I.model}`),"K"),e[44]=a,e[45]=t,e[46]=j):j=e[46],N=s.slice(0,Ae).map(j),e[40]=s,e[41]=a,e[42]=t,e[43]=N}else N=e[43];let w;e[47]!==N?(w=(0,o.jsx)(Z,{children:N}),e[47]=N,e[48]=w):w=e[48];let P;e[49]!==C||e[50]!==w?(P=(0,o.jsxs)(R,{children:[C,w]}),e[49]=C,e[50]=w,e[51]=P):P=e[51];let L;return e[52]!==l||e[53]!==P?(L=(0,o.jsxs)(q,{className:"gap-0 py-0","data-testid":"ai-calls",children:[l,P]}),e[52]=l,e[53]=P,e[54]=L):L=e[54],L},"Pe"),Ee=p(n=>{let e=(0,O.c)(48),{totals:s,trend:a}=n,t=F(),c;e[0]!==s?(c=ke(s),e[0]=s,e[1]=c):c=e[1];let l=c,r;e[2]!==t||e[3]!==a?(r=a.length>=2?(0,o.jsx)(de,{ariaLabel:t("Cost per minute"),className:"h-7 w-24",series:a,testId:"ai-trend"}):void 0,e[2]=t,e[3]=a,e[4]=r):r=e[4];let i;e[5]!==l||e[6]!==t||e[7]!==s.estimatedCost||e[8]!==s.providerCost?(i=l==="none"?t("No cost reported"):(0,o.jsx)("span",{"data-testid":"ai-cost-split",children:t("{provider} provider-reported \xB7 {estimated} estimated",{estimated:E(s.estimatedCost),provider:E(s.providerCost)})}),e[5]=l,e[6]=t,e[7]=s.estimatedCost,e[8]=s.providerCost,e[9]=i):i=e[9];let u;e[10]!==t?(u=t("Total cost"),e[10]=t,e[11]=u):u=e[11];let m;e[12]!==s?(m=B(s),e[12]=s,e[13]=m):m=e[13];let k;e[14]!==l||e[15]!==m?(k=(0,o.jsx)(te,{provenance:l,value:m}),e[14]=l,e[15]=m,e[16]=k):k=e[16];let y;e[17]!==r||e[18]!==i||e[19]!==u||e[20]!==k?(y=(0,o.jsx)($,{chart:r,footer:i,label:u,testId:"ai-total-cost",value:k}),e[17]=r,e[18]=i,e[19]=u,e[20]=k,e[21]=y):y=e[21];let b;e[22]!==t?(b=t("Input tokens"),e[22]=t,e[23]=b):b=e[23];let T;e[24]!==s.inputTokens?(T=_(s.inputTokens),e[24]=s.inputTokens,e[25]=T):T=e[25];let g;e[26]!==b||e[27]!==T?(g=(0,o.jsx)($,{label:b,testId:"ai-input-tokens",value:T}),e[26]=b,e[27]=T,e[28]=g):g=e[28];let d;e[29]!==t?(d=t("Output tokens"),e[29]=t,e[30]=d):d=e[30];let x;e[31]!==s.outputTokens?(x=_(s.outputTokens),e[31]=s.outputTokens,e[32]=x):x=e[32];let h;e[33]!==d||e[34]!==x?(h=(0,o.jsx)($,{label:d,testId:"ai-output-tokens",value:x}),e[33]=d,e[34]=x,e[35]=h):h=e[35];let f;e[36]!==t?(f=t("Calls"),e[36]=t,e[37]=f):f=e[37];let v;e[38]!==s.calls?(v=_(s.calls),e[38]=s.calls,e[39]=v):v=e[39];let C;e[40]!==f||e[41]!==v?(C=(0,o.jsx)($,{label:f,testId:"ai-calls-total",value:v}),e[40]=f,e[41]=v,e[42]=C):C=e[42];let N;return e[43]!==g||e[44]!==h||e[45]!==C||e[46]!==y?(N=(0,o.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"ai-totals",children:[y,g,h,C]}),e[43]=g,e[44]=h,e[45]=C,e[46]=y,e[47]=N):N=e[47],N},"Ke"),Ye=p(n=>{let e=(0,O.c)(29),{initialShardKey:s}=n,a=F(),{queryShardKey:t,setShardKey:c,shardKey:l}=le(s),r=ce(t),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];let u;e[1]!==t?(u={live:!0,shardKey:t},e[1]=t,e[2]=u):u=e[2];let{data:m,error:k}=D(U.getTraces,i,u),y;e[3]===Symbol.for("react.memo_cache_sentinel")?(y={},e[3]=y):y=e[3];let b;e[4]!==t?(b={live:!0,shardKey:t},e[4]=t,e[5]=b):b=e[5];let{data:T}=D(U.getMetricHistory,y,b),g,d;e[6]!==m||e[7]!==T?(d=Oe(T,Ke(m)),g=d.trend.map(Le),e[6]=m,e[7]=T,e[8]=g,e[9]=d):(g=e[8],d=e[9]);let x=g,h;e[10]!==c||e[11]!==l?(h=(0,o.jsx)(re,{onChange:c,testId:"ai-shard-input",value:l}),e[10]=c,e[11]=l,e[12]=h):h=e[12];let f;e[13]!==k||e[14]!==t?(f=k===null?null:(0,o.jsx)(ie,{error:k,shardKey:t,testId:"ai-error"}),e[13]=k,e[14]=t,e[15]=f):f=e[15];let v;e[16]!==r||e[17]!==a||e[18]!==x||e[19]!==d.byFunction||e[20]!==d.byModel||e[21]!==d.calls||e[22]!==d.source||e[23]!==d.totals?(v=d.source==="none"?(0,o.jsx)(ae,{description:a("Spend shows up here once an action calls ctx.ai.model(...) \u2014 tokens and cost per function and per model."),testId:"ai-empty",title:a("No AI usage recorded")}):(0,o.jsxs)(o.Fragment,{children:[d.source==="live"?(0,o.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"ai-live-only",children:a("No durable history yet \u2014 these totals come from the live trace ring and reset when the shard hibernates.")}):(0,o.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"ai-window",children:a("Totals cover the retained metric history (up to the last 24 hours).")}),(0,o.jsx)(Ee,{totals:d.totals,trend:x}),(0,o.jsxs)("div",{className:"grid gap-3 xl:grid-cols-2",children:[(0,o.jsx)(he,{keyLabel:a("Function"),rows:d.byFunction,testId:"ai-by-function",title:a("By function")}),(0,o.jsx)(he,{keyLabel:a("Model"),rows:d.byModel,testId:"ai-by-model",title:a("By model")})]}),d.calls.length===0?(0,o.jsx)(q,{children:(0,o.jsx)(ne,{className:"p-4 text-xs text-muted-foreground","data-testid":"ai-no-calls",children:a("No recent calls in the live trace ring \u2014 it empties when the shard hibernates.")})}):(0,o.jsx)($e,{calls:d.calls,onOpenTrace:r})]}),e[16]=r,e[17]=a,e[18]=x,e[19]=d.byFunction,e[20]=d.byModel,e[21]=d.calls,e[22]=d.source,e[23]=d.totals,e[24]=v):v=e[24];let C;return e[25]!==h||e[26]!==f||e[27]!==v?(C=(0,o.jsxs)("section",{className:"flex flex-col gap-4","data-testid":"ai-panel",children:[h,f,v]}),e[25]=h,e[26]=f,e[27]=v,e[28]=C):C=e[28],C},"Ze");function Le(n){return n.providerCost+n.estimatedCost}p(Le,"Ue");export{Ye as default};
1
+ import{d as E,e as _}from"./chunk-FWM5Z6CH.js";import{a as $}from"./chunk-HFPX37U7.js";import{a as de}from"./chunk-RDYGUTWW.js";import"./chunk-UDBPUH63.js";import{a as ce}from"./chunk-SRNRWSMY.js";import"./chunk-QLZGKBOW.js";import"./chunk-Y2YLTUMD.js";import"./chunk-R3RIZDUS.js";import{a as le}from"./chunk-2KTN53PK.js";import{a as re}from"./chunk-PAFHBQFL.js";import"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import"./chunk-OKZINWBB.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import"./chunk-OZID3UYF.js";import{a as ae}from"./chunk-S3TDGFRE.js";import{b as K}from"./chunk-UV6GPH2E.js";import"./chunk-L27FKJTG.js";import{a as ie}from"./chunk-D3MLU3PX.js";import"./chunk-S7NFUY75.js";import{a as R,b as W,c as Z,d as A,e as M,f as S}from"./chunk-J3ZEO3PJ.js";import"./chunk-YDDMKWPI.js";import"./chunk-5CHKXJYN.js";import"./chunk-EOFWXI3T.js";import{a as U}from"./chunk-LYVYUTQY.js";import{c as D}from"./chunk-UN3QTZ6X.js";import{a as q,b as H,c as J,e as ne}from"./chunk-TN4Z3P6S.js";import"./chunk-5KQSRLQP.js";import"./chunk-ZPQBVYNN.js";import{B as F,w as oe}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import{a as be}from"./chunk-A6TVTNKO.js";import{b as ge}from"./chunk-ADABTCDI.js";import{a as p,d as se}from"./chunk-5PEAXTYQ.js";var O=se(be(),1);var o=se(ge(),1);var G="gen_ai.usage.input_tokens",Q="gen_ai.usage.output_tokens",V="gen_ai.usage.cost",fe="gen_ai.request.model",Te="lunora.usage.cost.source",xe=new Set(["ai.embed","ai.generate","ai.stream"]),ue=6e4,Ce=1440,ve="unknown",X=p(()=>({calls:0,estimatedCost:0,inputTokens:0,outputTokens:0,providerCost:0}),"q"),Y=p((n,e)=>{let s=n?.[e];return typeof s=="string"&&s!==""?s:void 0},"J"),z=p((n,e)=>{let s=n?.[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0},"L"),ee=p(n=>Y(n,Te)==="provider"?"provider":"estimated","Q"),me=p((n,e)=>n.reduce((s,a)=>s+e(a),0),"Y"),B=p(n=>n.providerCost+n.estimatedCost,"F"),ke=p(n=>n.estimatedCost>0?n.providerCost>0?"mixed":"estimated":n.providerCost>0?"provider":"none","ae"),ye=p((n,e)=>({calls:n.calls+e.calls,estimatedCost:n.estimatedCost+e.estimatedCost,inputTokens:n.inputTokens+e.inputTokens,outputTokens:n.outputTokens+e.outputTokens,providerCost:n.providerCost+e.providerCost}),"ce"),Ie=p(n=>{let e=X(),s=0,a=0,t=0;for(let c of n){let l=me(c.points,i=>i.sum),r=me(c.points,i=>i.count);c.name===G?(e.inputTokens+=l,s+=r):c.name===Q?(e.outputTokens+=l,a+=r):(t+=r,ee(c.attributes)==="provider"?e.providerCost+=l:e.estimatedCost+=l)}return e.calls=Math.max(s,a,t),e},"ge"),Ne=p((n,e)=>B(e)-B(n)||e.inputTokens+e.outputTokens-(n.inputTokens+n.outputTokens)||n.key.localeCompare(e.key),"Ne"),pe=p((n,e)=>{let s=new Map;for(let a of n){let t=e(a);s.set(t,{key:t,...ye(s.get(t)??X(),a)})}return[...s.values()].toSorted(Ne)},"Z"),we=p(n=>(n?.series??[]).filter(e=>e.name===G||e.name===Q||e.name===V),"xe"),Me=p(n=>Y(n.attributes,fe)??ve,"Se"),Se=p(n=>{let e=new Map;for(let s of n){let a=Me(s),t=JSON.stringify([s.functionPath,a]),c=e.get(t)??{functionPath:s.functionPath,model:a,series:[]};c.series.push(s),e.set(t,c)}return[...e.values()].map(({functionPath:s,model:a,series:t})=>({functionPath:s,model:a,...Ie(t)}))},"Ie"),_e=p(n=>{let e=new Map;for(let r of n){if(r.name!==V)continue;let i=ee(r.attributes)==="provider";for(let u of r.points){let m=e.get(u.bucketMs)??{bucketMs:u.bucketMs,estimatedCost:0,providerCost:0};i?m.providerCost+=u.sum:m.estimatedCost+=u.sum,e.set(u.bucketMs,m)}}let s=[...e.keys()].toSorted((r,i)=>r-i),a=s[0],t=s.at(-1);if(a===void 0||t===void 0)return[];let c=Math.max(a,t-(Ce-1)*ue),l=[];for(let r=c;r<=t;r+=ue)l.push(e.get(r)??{bucketMs:r,estimatedCost:0,providerCost:0});return l},"_e"),Pe=p(n=>{let e=[];for(let s of n)for(let a of s.spans){if(!xe.has(a.name))continue;let{attributes:t}=a,c=z(t,V),l=z(t,G),r=z(t,Q);e.push({...c===void 0?{}:{cost:c,costSource:ee(t)},functionPath:s.functionPath,...l===void 0?{}:{inputTokens:l},model:Y(t,fe)??ve,ok:a.ok,...r===void 0?{}:{outputTokens:r},startTs:s.startTs+a.offsetMs,streaming:a.name==="ai.stream",traceId:s.traceId})}return e.toSorted((s,a)=>a.startTs-s.startTs)},"Me"),Fe=p(n=>n.map(e=>{let s=e.cost??0;return{calls:1,estimatedCost:e.costSource==="provider"?0:s,functionPath:e.functionPath,inputTokens:e.inputTokens??0,model:e.model,outputTokens:e.outputTokens??0,providerCost:e.costSource==="provider"?s:0}}),"Oe"),Oe=p((n,e)=>{let s=we(n),a=Pe(e),t=s.length>0,c=t?Se(s):Fe(a),l=X(),r="none";for(let i of c)l=ye(l,i);return t?r="history":a.length>0&&(r="live"),{byFunction:pe(c,i=>i.functionPath),byModel:pe(c,i=>i.model),calls:a,source:r,totals:l,trend:t?_e(s):[]}},"Ae"),Ke=p(n=>Array.isArray(n?.traces)?n.traces:[],"Ee"),Ae=25,te=p(n=>{let e=(0,O.c)(16),{provenance:s,value:a}=n,t=F();if(s==="none"){let m;return e[0]===Symbol.for("react.memo_cache_sentinel")?(m=(0,o.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),e[0]=m):m=e[0],m}let c;e[1]!==s||e[2]!==a?(c=s==="provider"?E(a):`~${E(a)}`,e[1]=s,e[2]=a,e[3]=c):c=e[3];let l;e[4]!==c?(l=(0,o.jsx)("span",{className:"tabular-nums",children:c}),e[4]=c,e[5]=l):l=e[5];let r;e[6]!==s||e[7]!==t?(r=s==="estimated"?(0,o.jsx)(K,{title:t("Derived from a price table, not reported by the provider."),variant:"warning",children:t("Estimated")}):null,e[6]=s,e[7]=t,e[8]=r):r=e[8];let i;e[9]!==s||e[10]!==t?(i=s==="mixed"?(0,o.jsx)(K,{title:t("Includes cost derived from a price table, not reported by the provider."),variant:"warning",children:t("Partly estimated")}):null,e[9]=s,e[10]=t,e[11]=i):i=e[11];let u;return e[12]!==l||e[13]!==r||e[14]!==i?(u=(0,o.jsxs)("span",{className:"inline-flex items-center gap-2",children:[l,r,i]}),e[12]=l,e[13]=r,e[14]=i,e[15]=u):u=e[15],u},"V"),he=p(n=>{let e=(0,O.c)(40),{keyLabel:s,rows:a,testId:t,title:c}=n,l=F(),r;e[0]!==c?(r=(0,o.jsx)(H,{className:"px-4 py-3",children:(0,o.jsx)(J,{children:c})}),e[0]=c,e[1]=r):r=e[1];let i;e[2]!==s?(i=(0,o.jsx)(M,{children:s}),e[2]=s,e[3]=i):i=e[3];let u;e[4]!==l?(u=l("Calls"),e[4]=l,e[5]=u):u=e[5];let m;e[6]!==u?(m=(0,o.jsx)(M,{className:"text-end",children:u}),e[6]=u,e[7]=m):m=e[7];let k;e[8]!==l?(k=l("Input tokens"),e[8]=l,e[9]=k):k=e[9];let y;e[10]!==k?(y=(0,o.jsx)(M,{className:"text-end",children:k}),e[10]=k,e[11]=y):y=e[11];let b;e[12]!==l?(b=l("Output tokens"),e[12]=l,e[13]=b):b=e[13];let T;e[14]!==b?(T=(0,o.jsx)(M,{className:"text-end",children:b}),e[14]=b,e[15]=T):T=e[15];let g;e[16]!==l?(g=l("Cost"),e[16]=l,e[17]=g):g=e[17];let d;e[18]!==g?(d=(0,o.jsx)(M,{className:"text-end",children:g}),e[18]=g,e[19]=d):d=e[19];let x;e[20]!==d||e[21]!==i||e[22]!==m||e[23]!==y||e[24]!==T?(x=(0,o.jsx)(W,{children:(0,o.jsxs)(A,{children:[i,m,y,T,d]})}),e[20]=d,e[21]=i,e[22]=m,e[23]=y,e[24]=T,e[25]=x):x=e[25];let h;if(e[26]!==a||e[27]!==t){let N;e[29]!==t?(N=p(w=>(0,o.jsxs)(A,{"data-testid":`${t}-row`,children:[(0,o.jsx)(S,{className:"max-w-[280px] truncate font-mono",title:w.key,children:w.key}),(0,o.jsx)(S,{className:"text-end tabular-nums",children:_(w.calls)}),(0,o.jsx)(S,{className:"text-end tabular-nums",children:_(w.inputTokens)}),(0,o.jsx)(S,{className:"text-end tabular-nums",children:_(w.outputTokens)}),(0,o.jsx)(S,{className:"text-end",children:(0,o.jsx)(te,{provenance:ke(w),value:B(w)})})]},w.key),"x"),e[29]=t,e[30]=N):N=e[30],h=a.map(N),e[26]=a,e[27]=t,e[28]=h}else h=e[28];let f;e[31]!==h?(f=(0,o.jsx)(Z,{children:h}),e[31]=h,e[32]=f):f=e[32];let v;e[33]!==x||e[34]!==f?(v=(0,o.jsxs)(R,{children:[x,f]}),e[33]=x,e[34]=f,e[35]=v):v=e[35];let C;return e[36]!==r||e[37]!==v||e[38]!==t?(C=(0,o.jsxs)(q,{className:"gap-0 py-0","data-testid":t,children:[r,v]}),e[36]=r,e[37]=v,e[38]=t,e[39]=C):C=e[39],C},"ee"),$e=p(n=>{let e=(0,O.c)(55),{calls:s,onOpenTrace:a}=n,t=F(),c;e[0]!==t?(c=t("Recent calls"),e[0]=t,e[1]=c):c=e[1];let l;e[2]!==c?(l=(0,o.jsx)(H,{className:"px-4 py-3",children:(0,o.jsx)(J,{children:c})}),e[2]=c,e[3]=l):l=e[3];let r;e[4]!==t?(r=t("When"),e[4]=t,e[5]=r):r=e[5];let i;e[6]!==r?(i=(0,o.jsx)(M,{children:r}),e[6]=r,e[7]=i):i=e[7];let u;e[8]!==t?(u=t("Function"),e[8]=t,e[9]=u):u=e[9];let m;e[10]!==u?(m=(0,o.jsx)(M,{children:u}),e[10]=u,e[11]=m):m=e[11];let k;e[12]!==t?(k=t("Model"),e[12]=t,e[13]=k):k=e[13];let y;e[14]!==k?(y=(0,o.jsx)(M,{children:k}),e[14]=k,e[15]=y):y=e[15];let b;e[16]!==t?(b=t("Input tokens"),e[16]=t,e[17]=b):b=e[17];let T;e[18]!==b?(T=(0,o.jsx)(M,{className:"text-end",children:b}),e[18]=b,e[19]=T):T=e[19];let g;e[20]!==t?(g=t("Output tokens"),e[20]=t,e[21]=g):g=e[21];let d;e[22]!==g?(d=(0,o.jsx)(M,{className:"text-end",children:g}),e[22]=g,e[23]=d):d=e[23];let x;e[24]!==t?(x=t("Cost"),e[24]=t,e[25]=x):x=e[25];let h;e[26]!==x?(h=(0,o.jsx)(M,{className:"text-end",children:x}),e[26]=x,e[27]=h):h=e[27];let f;e[28]!==t?(f=t("Trace"),e[28]=t,e[29]=f):f=e[29];let v;e[30]!==f?(v=(0,o.jsx)(M,{children:f}),e[30]=f,e[31]=v):v=e[31];let C;e[32]!==T||e[33]!==d||e[34]!==h||e[35]!==v||e[36]!==i||e[37]!==m||e[38]!==y?(C=(0,o.jsx)(W,{children:(0,o.jsxs)(A,{children:[i,m,y,T,d,h,v]})}),e[32]=T,e[33]=d,e[34]=h,e[35]=v,e[36]=i,e[37]=m,e[38]=y,e[39]=C):C=e[39];let N;if(e[40]!==s||e[41]!==a||e[42]!==t){let j;e[44]!==a||e[45]!==t?(j=p(I=>(0,o.jsxs)(A,{"data-testid":"ai-call",children:[(0,o.jsx)(S,{className:"font-mono text-muted-foreground",children:oe(I.startTs)}),(0,o.jsx)(S,{className:"font-mono",children:(0,o.jsxs)("span",{className:"inline-flex items-center gap-2",children:[I.functionPath,I.streaming?(0,o.jsx)(K,{variant:"outline",children:t("stream")}):null,I.ok?null:(0,o.jsx)(K,{variant:"destructive",children:t("failed")})]})}),(0,o.jsx)(S,{className:"max-w-[240px] truncate font-mono",title:I.model,children:I.model}),(0,o.jsx)(S,{className:"text-end tabular-nums",children:I.inputTokens===void 0?"\u2014":_(I.inputTokens)}),(0,o.jsx)(S,{className:"text-end tabular-nums",children:I.outputTokens===void 0?"\u2014":_(I.outputTokens)}),(0,o.jsx)(S,{className:"text-end",children:(0,o.jsx)(te,{provenance:I.cost===void 0?"none":I.costSource??"estimated",value:I.cost??0})}),(0,o.jsx)(S,{children:(0,o.jsx)("button",{className:"font-mono text-muted-foreground underline-offset-2 hover:underline",onClick:p(()=>{a(I.traceId)},"onClick"),title:t("Open the trace {trace}",{trace:I.traceId}),type:"button",children:I.traceId.slice(0,8)})})]},`${I.traceId}:${I.startTs.toString()}:${I.model}`),"K"),e[44]=a,e[45]=t,e[46]=j):j=e[46],N=s.slice(0,Ae).map(j),e[40]=s,e[41]=a,e[42]=t,e[43]=N}else N=e[43];let w;e[47]!==N?(w=(0,o.jsx)(Z,{children:N}),e[47]=N,e[48]=w):w=e[48];let P;e[49]!==C||e[50]!==w?(P=(0,o.jsxs)(R,{children:[C,w]}),e[49]=C,e[50]=w,e[51]=P):P=e[51];let L;return e[52]!==l||e[53]!==P?(L=(0,o.jsxs)(q,{className:"gap-0 py-0","data-testid":"ai-calls",children:[l,P]}),e[52]=l,e[53]=P,e[54]=L):L=e[54],L},"Pe"),Ee=p(n=>{let e=(0,O.c)(48),{totals:s,trend:a}=n,t=F(),c;e[0]!==s?(c=ke(s),e[0]=s,e[1]=c):c=e[1];let l=c,r;e[2]!==t||e[3]!==a?(r=a.length>=2?(0,o.jsx)(de,{ariaLabel:t("Cost per minute"),className:"h-7 w-24",series:a,testId:"ai-trend"}):void 0,e[2]=t,e[3]=a,e[4]=r):r=e[4];let i;e[5]!==l||e[6]!==t||e[7]!==s.estimatedCost||e[8]!==s.providerCost?(i=l==="none"?t("No cost reported"):(0,o.jsx)("span",{"data-testid":"ai-cost-split",children:t("{provider} provider-reported \xB7 {estimated} estimated",{estimated:E(s.estimatedCost),provider:E(s.providerCost)})}),e[5]=l,e[6]=t,e[7]=s.estimatedCost,e[8]=s.providerCost,e[9]=i):i=e[9];let u;e[10]!==t?(u=t("Total cost"),e[10]=t,e[11]=u):u=e[11];let m;e[12]!==s?(m=B(s),e[12]=s,e[13]=m):m=e[13];let k;e[14]!==l||e[15]!==m?(k=(0,o.jsx)(te,{provenance:l,value:m}),e[14]=l,e[15]=m,e[16]=k):k=e[16];let y;e[17]!==r||e[18]!==i||e[19]!==u||e[20]!==k?(y=(0,o.jsx)($,{chart:r,footer:i,label:u,testId:"ai-total-cost",value:k}),e[17]=r,e[18]=i,e[19]=u,e[20]=k,e[21]=y):y=e[21];let b;e[22]!==t?(b=t("Input tokens"),e[22]=t,e[23]=b):b=e[23];let T;e[24]!==s.inputTokens?(T=_(s.inputTokens),e[24]=s.inputTokens,e[25]=T):T=e[25];let g;e[26]!==b||e[27]!==T?(g=(0,o.jsx)($,{label:b,testId:"ai-input-tokens",value:T}),e[26]=b,e[27]=T,e[28]=g):g=e[28];let d;e[29]!==t?(d=t("Output tokens"),e[29]=t,e[30]=d):d=e[30];let x;e[31]!==s.outputTokens?(x=_(s.outputTokens),e[31]=s.outputTokens,e[32]=x):x=e[32];let h;e[33]!==d||e[34]!==x?(h=(0,o.jsx)($,{label:d,testId:"ai-output-tokens",value:x}),e[33]=d,e[34]=x,e[35]=h):h=e[35];let f;e[36]!==t?(f=t("Calls"),e[36]=t,e[37]=f):f=e[37];let v;e[38]!==s.calls?(v=_(s.calls),e[38]=s.calls,e[39]=v):v=e[39];let C;e[40]!==f||e[41]!==v?(C=(0,o.jsx)($,{label:f,testId:"ai-calls-total",value:v}),e[40]=f,e[41]=v,e[42]=C):C=e[42];let N;return e[43]!==g||e[44]!==h||e[45]!==C||e[46]!==y?(N=(0,o.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"ai-totals",children:[y,g,h,C]}),e[43]=g,e[44]=h,e[45]=C,e[46]=y,e[47]=N):N=e[47],N},"Ke"),Ye=p(n=>{let e=(0,O.c)(29),{initialShardKey:s}=n,a=F(),{queryShardKey:t,setShardKey:c,shardKey:l}=le(s),r=ce(t),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];let u;e[1]!==t?(u={live:!0,shardKey:t},e[1]=t,e[2]=u):u=e[2];let{data:m,error:k}=D(U.getTraces,i,u),y;e[3]===Symbol.for("react.memo_cache_sentinel")?(y={},e[3]=y):y=e[3];let b;e[4]!==t?(b={live:!0,shardKey:t},e[4]=t,e[5]=b):b=e[5];let{data:T}=D(U.getMetricHistory,y,b),g,d;e[6]!==m||e[7]!==T?(d=Oe(T,Ke(m)),g=d.trend.map(Le),e[6]=m,e[7]=T,e[8]=g,e[9]=d):(g=e[8],d=e[9]);let x=g,h;e[10]!==c||e[11]!==l?(h=(0,o.jsx)(re,{onChange:c,testId:"ai-shard-input",value:l}),e[10]=c,e[11]=l,e[12]=h):h=e[12];let f;e[13]!==k||e[14]!==t?(f=k===null?null:(0,o.jsx)(ie,{error:k,shardKey:t,testId:"ai-error"}),e[13]=k,e[14]=t,e[15]=f):f=e[15];let v;e[16]!==r||e[17]!==a||e[18]!==x||e[19]!==d.byFunction||e[20]!==d.byModel||e[21]!==d.calls||e[22]!==d.source||e[23]!==d.totals?(v=d.source==="none"?(0,o.jsx)(ae,{description:a("Spend shows up here once an action calls ctx.ai.model(...) \u2014 tokens and cost per function and per model."),testId:"ai-empty",title:a("No AI usage recorded")}):(0,o.jsxs)(o.Fragment,{children:[d.source==="live"?(0,o.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"ai-live-only",children:a("No durable history yet \u2014 these totals come from the live trace ring and reset when the shard hibernates.")}):(0,o.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"ai-window",children:a("Totals cover the retained metric history (up to the last 24 hours).")}),(0,o.jsx)(Ee,{totals:d.totals,trend:x}),(0,o.jsxs)("div",{className:"grid gap-3 xl:grid-cols-2",children:[(0,o.jsx)(he,{keyLabel:a("Function"),rows:d.byFunction,testId:"ai-by-function",title:a("By function")}),(0,o.jsx)(he,{keyLabel:a("Model"),rows:d.byModel,testId:"ai-by-model",title:a("By model")})]}),d.calls.length===0?(0,o.jsx)(q,{children:(0,o.jsx)(ne,{className:"p-4 text-xs text-muted-foreground","data-testid":"ai-no-calls",children:a("No recent calls in the live trace ring \u2014 it empties when the shard hibernates.")})}):(0,o.jsx)($e,{calls:d.calls,onOpenTrace:r})]}),e[16]=r,e[17]=a,e[18]=x,e[19]=d.byFunction,e[20]=d.byModel,e[21]=d.calls,e[22]=d.source,e[23]=d.totals,e[24]=v):v=e[24];let C;return e[25]!==h||e[26]!==f||e[27]!==v?(C=(0,o.jsxs)("section",{className:"flex flex-col gap-4","data-testid":"ai-panel",children:[h,f,v]}),e[25]=h,e[26]=f,e[27]=v,e[28]=C):C=e[28],C},"Ze");function Le(n){return n.providerCost+n.estimatedCost}p(Le,"Ue");export{Ye as default};
@@ -1 +1 @@
1
- import{a as B}from"./chunk-HVKGOO4E.js";import{a as j}from"./chunk-HFDKQBIZ.js";import"./chunk-DA2CAFXI.js";import"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import"./chunk-EG45XFL3.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as I}from"./chunk-FOXLEMWC.js";import{b as w}from"./chunk-26XOFIV4.js";import"./chunk-L27FKJTG.js";import{a as C}from"./chunk-VX6ZBLXB.js";import"./chunk-CHYLD556.js";import{a as A,b as D,c as P,d as b,e as l,f as n}from"./chunk-7MM2SI65.js";import"./chunk-3SRQFKDT.js";import"./chunk-RY6I3E2K.js";import"./chunk-EOFWXI3T.js";import{a as u}from"./chunk-LYVYUTQY.js";import{c as p}from"./chunk-3CUQWI5A.js";import{a as v,e as S}from"./chunk-QQENKHRS.js";import{e as R}from"./chunk-F4ZN2DRL.js";import"./chunk-ZPQBVYNN.js";import{B as k,w as N}from"./chunk-ITS5LMYJ.js";import"./chunk-PDBW6GTJ.js";import"./chunk-A6TVTNKO.js";import{b as Q}from"./chunk-ADABTCDI.js";import{a as m,d as H}from"./chunk-5PEAXTYQ.js";var e=H(Q(),1);var _="payment_subscriptions",O="payment_events",V=[_,O],Y={},E=new Set(["active","trialing"]),z=new Set(["past_due","unpaid"]),s=m((a,t)=>{if(a[t]!==void 0)return a[t];let f=a.__doc__;return typeof f=="string"?R(f)?.[t]:void 0},"a"),o=m(a=>typeof a=="string"?a:typeof a=="number"||typeof a=="bigint"||typeof a=="boolean"?String(a):"","s"),J=m(a=>E.has(a)?"default":z.has(a)?"destructive":"outline","q"),ie=m(({limit:a=100})=>{let t=k(),f=B(),{data:x}=p(u.listTables,Y,{live:!0}),F=x!==void 0,L=Array.isArray(x)&&V.every(r=>x.some(d=>d.name===r)),c=f.payments&&L,i=p(u.readTablePage,{filters:[],limit:a,offset:0,orderBy:{column:"updatedAt",direction:"desc"},search:"",table:_},{enabled:c}),h=p(u.readTablePage,{filters:[],limit:25,offset:0,orderBy:{column:"processedAt",direction:"desc"},search:"",table:O},{enabled:c}),g=p(u.facetColumn,{column:"state",table:_},{enabled:c});j(()=>{if(c)return Promise.all([i.poll(),h.poll(),g.poll()])},!0);let y=i.data?.rows??[],M=h.data?.rows??[],U=i.error??h.error,q=i.error===null?h.errorSource:i.errorSource,G=i.data?.total??y.length,T=g.data?.values===void 0?y.filter(r=>E.has(o(s(r,"state")))).length:g.data.values.reduce((r,d)=>r+(E.has(o(d.value))?d.count:0),0);return F&&!c?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(I,{description:t("No @lunora/payment tables found in this deployment. Add `.extend(paymentExtension)` to lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsx)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxs)(v,{className:"justify-between gap-0 py-0",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:T}),(0,e.jsx)(w,{variant:"default",children:t("{count} active",{count:T})})]})]}),(0,e.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:G})})]})}),U===null?void 0:(0,e.jsx)(C,{error:q}),y.length===0&&!i.isLoading?(0,e.jsx)(I,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(v,{className:"overflow-hidden py-0",children:(0,e.jsx)(S,{className:"px-0",children:(0,e.jsxs)(A,{children:[(0,e.jsx)(D,{children:(0,e.jsxs)(b,{children:[(0,e.jsx)(l,{children:t("Provider")}),(0,e.jsx)(l,{children:t("Reference")}),(0,e.jsx)(l,{children:t("Plan")}),(0,e.jsx)(l,{children:t("State")}),(0,e.jsx)(l,{children:t("Renews")})]})}),(0,e.jsx)(P,{children:y.map(r=>{let d=o(s(r,"state"));return(0,e.jsxs)(b,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(n,{children:o(s(r,"provider"))}),(0,e.jsx)(n,{children:o(s(r,"referenceId"))}),(0,e.jsx)(n,{children:o(s(r,"priceId"))}),(0,e.jsx)(n,{children:(0,e.jsx)(w,{variant:J(d),children:d})}),(0,e.jsx)(n,{children:N(s(r,"currentPeriodEnd"))})]},o(s(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(v,{className:"overflow-hidden py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),(0,e.jsx)(S,{className:"px-0",children:(0,e.jsx)(A,{children:(0,e.jsx)(P,{children:M.map(r=>(0,e.jsxs)(b,{"data-testid":"payment-event-row",children:[(0,e.jsx)(n,{children:o(s(r,"provider"))}),(0,e.jsx)(n,{className:"font-medium",children:o(s(r,"type"))}),(0,e.jsx)(n,{className:"text-muted-foreground",children:o(s(r,"providerEventId"))}),(0,e.jsx)(n,{children:N(s(r,"processedAt"))})]},o(s(r,"providerEventId"))))})})})]})]})},"oe");export{ie as PaymentsPanel};
1
+ import{a as B}from"./chunk-CNALVIPZ.js";import{a as j}from"./chunk-HPTF52JF.js";import"./chunk-DA2CAFXI.js";import"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import"./chunk-NVMQPIRS.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as I}from"./chunk-S3TDGFRE.js";import{b as w}from"./chunk-UV6GPH2E.js";import"./chunk-L27FKJTG.js";import{a as C}from"./chunk-D3MLU3PX.js";import"./chunk-S7NFUY75.js";import{a as A,b as D,c as P,d as b,e as l,f as n}from"./chunk-J3ZEO3PJ.js";import"./chunk-YDDMKWPI.js";import"./chunk-5CHKXJYN.js";import"./chunk-EOFWXI3T.js";import{a as u}from"./chunk-LYVYUTQY.js";import{c as p}from"./chunk-UN3QTZ6X.js";import{a as v,e as S}from"./chunk-TN4Z3P6S.js";import{e as R}from"./chunk-5KQSRLQP.js";import"./chunk-ZPQBVYNN.js";import{B as k,w as N}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import"./chunk-A6TVTNKO.js";import{b as Q}from"./chunk-ADABTCDI.js";import{a as m,d as H}from"./chunk-5PEAXTYQ.js";var e=H(Q(),1);var _="payment_subscriptions",O="payment_events",V=[_,O],Y={},E=new Set(["active","trialing"]),z=new Set(["past_due","unpaid"]),s=m((a,t)=>{if(a[t]!==void 0)return a[t];let f=a.__doc__;return typeof f=="string"?R(f)?.[t]:void 0},"a"),o=m(a=>typeof a=="string"?a:typeof a=="number"||typeof a=="bigint"||typeof a=="boolean"?String(a):"","s"),J=m(a=>E.has(a)?"default":z.has(a)?"destructive":"outline","q"),ie=m(({limit:a=100})=>{let t=k(),f=B(),{data:x}=p(u.listTables,Y,{live:!0}),F=x!==void 0,L=Array.isArray(x)&&V.every(r=>x.some(d=>d.name===r)),c=f.payments&&L,i=p(u.readTablePage,{filters:[],limit:a,offset:0,orderBy:{column:"updatedAt",direction:"desc"},search:"",table:_},{enabled:c}),h=p(u.readTablePage,{filters:[],limit:25,offset:0,orderBy:{column:"processedAt",direction:"desc"},search:"",table:O},{enabled:c}),g=p(u.facetColumn,{column:"state",table:_},{enabled:c});j(()=>{if(c)return Promise.all([i.poll(),h.poll(),g.poll()])},!0);let y=i.data?.rows??[],M=h.data?.rows??[],U=i.error??h.error,q=i.error===null?h.errorSource:i.errorSource,G=i.data?.total??y.length,T=g.data?.values===void 0?y.filter(r=>E.has(o(s(r,"state")))).length:g.data.values.reduce((r,d)=>r+(E.has(o(d.value))?d.count:0),0);return F&&!c?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(I,{description:t("No @lunora/payment tables found in this deployment. Add `.extend(paymentExtension)` to lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsx)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxs)(v,{className:"justify-between gap-0 py-0",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:T}),(0,e.jsx)(w,{variant:"default",children:t("{count} active",{count:T})})]})]}),(0,e.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:G})})]})}),U===null?void 0:(0,e.jsx)(C,{error:q}),y.length===0&&!i.isLoading?(0,e.jsx)(I,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(v,{className:"overflow-hidden py-0",children:(0,e.jsx)(S,{className:"px-0",children:(0,e.jsxs)(A,{children:[(0,e.jsx)(D,{children:(0,e.jsxs)(b,{children:[(0,e.jsx)(l,{children:t("Provider")}),(0,e.jsx)(l,{children:t("Reference")}),(0,e.jsx)(l,{children:t("Plan")}),(0,e.jsx)(l,{children:t("State")}),(0,e.jsx)(l,{children:t("Renews")})]})}),(0,e.jsx)(P,{children:y.map(r=>{let d=o(s(r,"state"));return(0,e.jsxs)(b,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(n,{children:o(s(r,"provider"))}),(0,e.jsx)(n,{children:o(s(r,"referenceId"))}),(0,e.jsx)(n,{children:o(s(r,"priceId"))}),(0,e.jsx)(n,{children:(0,e.jsx)(w,{variant:J(d),children:d})}),(0,e.jsx)(n,{children:N(s(r,"currentPeriodEnd"))})]},o(s(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(v,{className:"overflow-hidden py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),(0,e.jsx)(S,{className:"px-0",children:(0,e.jsx)(A,{children:(0,e.jsx)(P,{children:M.map(r=>(0,e.jsxs)(b,{"data-testid":"payment-event-row",children:[(0,e.jsx)(n,{children:o(s(r,"provider"))}),(0,e.jsx)(n,{className:"font-medium",children:o(s(r,"type"))}),(0,e.jsx)(n,{className:"text-muted-foreground",children:o(s(r,"providerEventId"))}),(0,e.jsx)(n,{children:N(s(r,"processedAt"))})]},o(s(r,"providerEventId"))))})})})]})]})},"oe");export{ie as PaymentsPanel};
@@ -1,4 +1,4 @@
1
- import{a as T}from"./chunk-VX6ZBLXB.js";import{a as k,b as I,c as $,d as l,e as c,f as a}from"./chunk-7MM2SI65.js";import{b}from"./chunk-RY6I3E2K.js";import{a as N,e as w}from"./chunk-QQENKHRS.js";import{B as v,x as y}from"./chunk-ITS5LMYJ.js";import{a as C,b as S}from"./chunk-ADABTCDI.js";import{a as i,d as x}from"./chunk-5PEAXTYQ.js";var A=x(C(),1);var e=x(S(),1);var O={ERROR:"error",INFO:"info",WARN:"warning"},M=i(t=>{let s=typeof t.metadata.table=="string"?t.metadata.table:void 0;return{description:`${t.detail} ${t.remediation}`,entity:s,issueType:t.title,key:t.cacheKey,level:O[t.level]}},"J"),W=["error","warning","info"],j={error:"bg-destructive",info:"bg-info",warning:"bg-warning"},D=i((t,s)=>({error:t("Errors"),info:t("Info"),warning:t("Warnings")})[s],"O"),H=i((t,s,o)=>({error:t("{count} errors",{count:o}),info:t("{count} suggestions",{count:o}),warning:t("{count} warnings",{count:o})})[s],"S"),L=i((t,s)=>({error:t("No errors detected"),info:t("No suggestions"),warning:t("No warnings detected")})[s],"D"),z=i(t=>{let s={error:0,info:0,warning:0};for(let o of t??[])s[o.level]+=1;return s},"H"),P=i(({error:t=null,errorSource:s,rows:o,shardKey:p,testId:d,toolbar:f})=>{let n=v(),m=b(),g=m!==void 0&&!m.unavailable,[u,E]=(0,A.useState)("error"),K=z(o),h=(o??[]).filter(r=>r.level===u),R=i(r=>{E(r.currentTarget.dataset.level)},"y");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":d,children:[(0,e.jsx)("div",{className:"flex border-b border-border",role:"tablist",children:W.map(r=>(0,e.jsxs)("button",{"aria-selected":u===r,className:"flex min-w-32 flex-col gap-0.5 border-b-2 border-transparent px-4 py-2 text-start outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 aria-selected:border-foreground","data-level":r,"data-testid":`${d}-tab-${r}`,onClick:R,role:"tab",type:"button",children:[(0,e.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[(0,e.jsx)("span",{"aria-hidden":"true",className:y("size-2 rounded-sm",j[r])}),D(n,r)]}),(0,e.jsx)("span",{className:"ps-4 text-xs text-muted-foreground",children:H(n,r,K[r])})]},r))}),f!==void 0&&(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:f}),t!==null&&(0,e.jsx)(T,{error:s??t,shardKey:p,testId:`${d}-error`}),(0,e.jsx)(N,{className:"overflow-hidden py-0",children:(0,e.jsx)(w,{className:"px-0",children:(0,e.jsxs)(k,{children:[(0,e.jsx)(I,{children:(0,e.jsxs)(l,{children:[(0,e.jsx)(c,{children:n("Issue type")}),(0,e.jsx)(c,{children:n("Entity/item")}),(0,e.jsx)(c,{children:n("Description")})]})}),(0,e.jsx)($,{children:h.length===0?(0,e.jsx)(l,{children:(0,e.jsxs)(a,{className:"h-40 text-center align-middle text-muted-foreground",colSpan:3,"data-testid":`${d}-empty`,children:[(0,e.jsx)("span",{className:"block text-sm font-medium text-foreground",children:L(n,u)}),(0,e.jsx)("span",{className:"block text-sm",children:n("Nothing to report for this deployment.")})]})}):h.map(r=>(0,e.jsxs)(l,{children:[(0,e.jsx)(a,{className:"font-medium text-foreground",children:r.issueType}),(0,e.jsx)(a,{className:"font-mono text-xs text-muted-foreground",children:r.entity??"\u2014"}),(0,e.jsxs)(a,{className:"text-muted-foreground",children:[(0,e.jsx)("span",{children:r.description}),(r.action!==void 0||g)&&(0,e.jsxs)("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.action,g&&(0,e.jsx)("button",{className:"text-xs underline outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":"advisor-ask-assistant",onClick:i(()=>{m.openAssistant({ask:n(`The Lunora advisor reported: {finding}.
1
+ import{a as T}from"./chunk-D3MLU3PX.js";import{a as k,b as I,c as $,d as l,e as c,f as a}from"./chunk-J3ZEO3PJ.js";import{b}from"./chunk-5CHKXJYN.js";import{a as N,e as w}from"./chunk-TN4Z3P6S.js";import{B as v,x as y}from"./chunk-PN7JHEYW.js";import{a as C,b as S}from"./chunk-ADABTCDI.js";import{a as i,d as x}from"./chunk-5PEAXTYQ.js";var A=x(C(),1);var e=x(S(),1);var O={ERROR:"error",INFO:"info",WARN:"warning"},M=i(t=>{let s=typeof t.metadata.table=="string"?t.metadata.table:void 0;return{description:`${t.detail} ${t.remediation}`,entity:s,issueType:t.title,key:t.cacheKey,level:O[t.level]}},"J"),W=["error","warning","info"],j={error:"bg-destructive",info:"bg-info",warning:"bg-warning"},D=i((t,s)=>({error:t("Errors"),info:t("Info"),warning:t("Warnings")})[s],"O"),H=i((t,s,o)=>({error:t("{count} errors",{count:o}),info:t("{count} suggestions",{count:o}),warning:t("{count} warnings",{count:o})})[s],"S"),L=i((t,s)=>({error:t("No errors detected"),info:t("No suggestions"),warning:t("No warnings detected")})[s],"D"),z=i(t=>{let s={error:0,info:0,warning:0};for(let o of t??[])s[o.level]+=1;return s},"H"),P=i(({error:t=null,errorSource:s,rows:o,shardKey:p,testId:d,toolbar:f})=>{let n=v(),m=b(),g=m!==void 0&&!m.unavailable,[u,E]=(0,A.useState)("error"),K=z(o),h=(o??[]).filter(r=>r.level===u),R=i(r=>{E(r.currentTarget.dataset.level)},"y");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":d,children:[(0,e.jsx)("div",{className:"flex border-b border-border",role:"tablist",children:W.map(r=>(0,e.jsxs)("button",{"aria-selected":u===r,className:"flex min-w-32 flex-col gap-0.5 border-b-2 border-transparent px-4 py-2 text-start outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 aria-selected:border-foreground","data-level":r,"data-testid":`${d}-tab-${r}`,onClick:R,role:"tab",type:"button",children:[(0,e.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[(0,e.jsx)("span",{"aria-hidden":"true",className:y("size-2 rounded-sm",j[r])}),D(n,r)]}),(0,e.jsx)("span",{className:"ps-4 text-xs text-muted-foreground",children:H(n,r,K[r])})]},r))}),f!==void 0&&(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:f}),t!==null&&(0,e.jsx)(T,{error:s??t,shardKey:p,testId:`${d}-error`}),(0,e.jsx)(N,{className:"overflow-hidden py-0",children:(0,e.jsx)(w,{className:"px-0",children:(0,e.jsxs)(k,{children:[(0,e.jsx)(I,{children:(0,e.jsxs)(l,{children:[(0,e.jsx)(c,{children:n("Issue type")}),(0,e.jsx)(c,{children:n("Entity/item")}),(0,e.jsx)(c,{children:n("Description")})]})}),(0,e.jsx)($,{children:h.length===0?(0,e.jsx)(l,{children:(0,e.jsxs)(a,{className:"h-40 text-center align-middle text-muted-foreground",colSpan:3,"data-testid":`${d}-empty`,children:[(0,e.jsx)("span",{className:"block text-sm font-medium text-foreground",children:L(n,u)}),(0,e.jsx)("span",{className:"block text-sm",children:n("Nothing to report for this deployment.")})]})}):h.map(r=>(0,e.jsxs)(l,{children:[(0,e.jsx)(a,{className:"font-medium text-foreground",children:r.issueType}),(0,e.jsx)(a,{className:"font-mono text-xs text-muted-foreground",children:r.entity??"\u2014"}),(0,e.jsxs)(a,{className:"text-muted-foreground",children:[(0,e.jsx)("span",{children:r.description}),(r.action!==void 0||g)&&(0,e.jsxs)("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.action,g&&(0,e.jsx)("button",{className:"text-xs underline outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":"advisor-ask-assistant",onClick:i(()=>{m.openAssistant({ask:n(`The Lunora advisor reported: {finding}.
2
2
 
3
3
  {description}
4
4
 
@@ -1 +1 @@
1
- import{a as we,b as Ge}from"./chunk-QHVUXMRV.js";import{i as je,k as He}from"./chunk-2NUCBQFU.js";import{a as Ee,b as Pe,c as Ne,d as De,e as Be,g as Me,h as Fe}from"./chunk-GTW3JPQQ.js";import{I as Se,J as Ve,K as Le,L as Te,M as Oe,N as _e,b as U,l as Ae}from"./chunk-4SY2N2RS.js";import{b as ve,c as Re}from"./chunk-SCTYLLJT.js";import{b as Ce,v as M}from"./chunk-OZID3UYF.js";import{b as ke,d as ge,e as ye,i as Ie,j as H}from"./chunk-L27FKJTG.js";import{x as he}from"./chunk-ITS5LMYJ.js";import{a as Et}from"./chunk-A6TVTNKO.js";import{a as A,b as xe}from"./chunk-ADABTCDI.js";import{a as i,c as It,d as C}from"./chunk-5PEAXTYQ.js";var Qe=C(Et(),1);var V={};It(V,{Indicator:()=>$e,Root:()=>Ye});var l=C(A(),1);function Ue(o){if(!o)return null;for(let e of o.elements){let r=e.tagName;if(r==="BUTTON"||r==="INPUT"){let a=e;if(a.type==="submit")return a}}return null}i(Ue,"getDefaultFormSubmitter");var qe="data-checked",We="data-unchecked";function q(o){return{checked(e){return o.indeterminate?{}:e?{[qe]:""}:{[We]:""}},...Ee}}i(q,"getCheckboxStateAttributesMapping");var ze=C(A(),1);function Ke(o,e,r,a=!0,s){let[f,p]=ze.useState(),P=U(s?`${s}-label`:void 0),b=o??e??f;return M(()=>{let x=o||e||!a?void 0:Nt(r.current,P);f!==x&&p(x)}),b}i(Ke,"useAriaLabelledBy");function Nt(o,e){let r=Dt(o);if(r)return!r.id&&e&&(r.id=e),r.id||void 0}i(Nt,"getAriaLabelledBy");function Dt(o){if(!o)return;let e=o.parentElement;if(e&&e.tagName==="LABEL")return e;let r=o.id;if(r){let s=o.nextElementSibling;if(s&&s.htmlFor===r)return s}let a=o.labels;return a&&a[0]}i(Dt,"findAssociatedLabel");var W=C(A(),1);var Bt=W.createContext(void 0);function Je(){return W.useContext(Bt)}i(Je,"useCheckboxGroupContext");var z=C(A(),1);var ie=z.createContext(void 0);function Xe(){let o=z.useContext(ie);if(o===void 0)throw new Error(ge(14));return o}i(Xe,"useCheckboxRootContext");var S=C(xe(),1);var At="data-parent",Ye=l.forwardRef(i(function(e,r){let{checked:a,className:s,defaultChecked:f=!1,"aria-labelledby":p,disabled:P=!1,form:b,id:x,indeterminate:N=!1,inputRef:X,name:L,onCheckedChange:F,parent:u=!1,readOnly:y=!1,render:ae,required:I=!1,uncheckedValue:T,value:O,nativeButton:_=!1,style:Mt,...Ze}=e,{clearErrors:et}=Ne(),{disabled:tt,name:ot,setDirty:rt,setFilled:se,setFocused:de,setTouched:nt,state:ce,validationMode:it,validityData:at,validation:st}=Pe(),dt=Me(),{labelId:ct,registerControlId:ut,getDescriptionProps:ue}=De(),n=Je(),k=n?.allValues===void 0?void 0:n.parent,w=k!==void 0,c=tt||dt.disabled||n?.disabled||P,E=ot??L,d=O??E,le=U(),lt=n?.registerControlId!==ut,Y=Be({id:x||void 0,enabled:lt}),ft=_?Y:le,$={};w&&(u?$=k.getParentProps():d!==void 0&&($=k.getChildProps(d)));let{checked:fe=a,indeterminate:pt=N,onCheckedChange:mt,...bt}=$,Q=n?.value,G=l.useRef(null),{getButtonProps:xt,buttonRef:ht}=Re({disabled:c,native:_}),D=n?.validation??st,[m,Ct]=Le({controlled:d!==void 0&&Q!==void 0&&!u?Q.includes(d):fe,default:f,name:"Checkbox",state:"checked"}),Z=w?!!fe:m,B=w&&pt||N;Fe(G,le,m,void 0,!n&&!c,L);let ee=k?.registerChildId,g=l.useRef(null),pe=D.registerInput,me=n?d:void 0,kt=l.useCallback(t=>pe(t,{controlRef:G,value:me}),[pe,me]),gt=ye(X,g,u?void 0:kt),vt=Ke(p,ct,g,!_,Y);M(()=>{g.current&&(g.current.indeterminate=B),n||se(m)},[m,B,n,se]),Te(m,()=>{n||(et(E),rt(m!==at.initialValue),D.change(m))});let Rt=ke({checked:m,disabled:c,form:b,name:u?void 0:E,id:_?void 0:Y,required:I,ref:gt,style:E?Ge:we,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(t){if(t.nativeEvent.defaultPrevented)return;if(y){t.preventDefault();return}let h=t.currentTarget.checked,v=_e(Oe.none,t.nativeEvent);if(F?.(h,v),!v.isCanceled&&(mt?.(h,v),!v.isCanceled&&(Ct(h),d!==void 0&&n!==void 0&&!u&&!w))){let R=h?[...n.value,d]:n.value.filter(j=>j!==d);n.setValue(R,v)}},onClick(t){t.stopPropagation()},onFocus(){G.current?.focus()}},O!==void 0?{value:(n?m&&O:O)||""}:Ie,ue,t=>D.getValidationProps(c,t));l.useEffect(()=>{if(!k||d===void 0)return;let t=k.disabledStatesRef.current;return t.set(d,c),()=>{t.delete(d)}},[k,c,d]);let te=l.useMemo(()=>({...ce,checked:Z,disabled:c,readOnly:y,required:I,indeterminate:B}),[ce,Z,c,y,I,B]),yt=q(te),be=H("span",e,{state:te,ref:[ht,G,r],props:[{id:ft,role:"checkbox","aria-checked":B?"mixed":Z,"aria-readonly":y||void 0,"aria-required":I||void 0,"aria-labelledby":vt,[At]:u?"":void 0,onFocus(){c||de(!0)},onBlur(){let t=g.current;t&&(nt(!0),de(!1),it==="onBlur"&&D.commit(n?Q:t.checked))},onKeyDown(t){if(t.key!=="Enter"||(t.preventBaseUIHandler(),t.defaultPrevented))return;let h=g.current?.form??null,v=t.currentTarget,R=t.nativeEvent,j=t.preventDefault,re=R.preventDefault,ne=!1;t.preventDefault=()=>{ne=!0,j.call(t)},R.preventDefault=()=>{ne=!0,re.call(R)},re.call(R),Ce(v).queueMicrotask(()=>{t.preventDefault=j,R.preventDefault=re,ne||Ue(h)?.click()})},onClick(t){if(y||c)return;t.preventDefault();let h=g.current;h&&ve(h,t)}},Ze,bt,xt,ue,t=>D.getValidationProps(c,t)],stateAttributesMapping:yt}),oe=be.props.id;return M(()=>{if(!(!ee||u||d===void 0||oe===void 0))return ee(d,oe)},[ee,u,d,oe]),(0,S.jsxs)(ie.Provider,{value:te,children:[be,!m&&!n&&E&&!u&&T!==void 0&&(0,S.jsx)("input",{type:"hidden",form:b,name:E,value:T,disabled:c}),(0,S.jsx)("input",{...Rt,suppressHydrationWarning:!0})]})},"CheckboxRoot"));var K=C(A(),1);var $e=K.forwardRef(i(function(e,r){let{render:a,className:s,style:f,keepMounted:p=!1,...P}=e,b=Xe(),x=b.checked||b.indeterminate,{mounted:N,transitionStatus:X,setMounted:L}=Ve(x),F=K.useRef(null),u={...b,transitionStatus:X};Se({batch:!0,enabled:!x,open:x,ref:F,onComplete(){x||L(!1)}});let ae={...q(b),...Ae},I=p||N,T=H("span",e,{ref:[r,F],state:u,stateAttributesMapping:ae,props:P});return I?T:null},"CheckboxIndicator"));var J=C(xe(),1);function Fo(o){let e=(0,Qe.c)(9),r,a;e[0]!==o?({className:r,...a}=o,e[0]=o,e[1]=r,e[2]=a):(r=e[1],a=e[2]);let s;e[3]!==r?(s=he("peer relative flex size-4 shrink-0 items-center justify-center rounded-md border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary",r),e[3]=r,e[4]=s):s=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=(0,J.jsx)(V.Indicator,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none [&>svg]:size-3.5",children:(0,J.jsx)(He,{icon:je,strokeWidth:2})}),e[5]=f):f=e[5];let p;return e[6]!==a||e[7]!==s?(p=(0,J.jsx)(V.Root,{"data-slot":"checkbox",className:s,...a,children:f}),e[6]=a,e[7]=s,e[8]=p):p=e[8],p}i(Fo,"v");export{Fo as a};
1
+ import{a as we,b as Ge}from"./chunk-QHVUXMRV.js";import{i as je,k as He}from"./chunk-2NUCBQFU.js";import{a as Ee,b as Pe,c as Ne,d as De,e as Be,g as Me,h as Fe}from"./chunk-OKZINWBB.js";import{I as Se,J as Ve,K as Le,L as Te,M as Oe,N as _e,b as U,l as Ae}from"./chunk-4SY2N2RS.js";import{b as ve,c as Re}from"./chunk-SCTYLLJT.js";import{b as Ce,v as M}from"./chunk-OZID3UYF.js";import{b as ke,d as ge,e as ye,i as Ie,j as H}from"./chunk-L27FKJTG.js";import{x as he}from"./chunk-PN7JHEYW.js";import{a as Et}from"./chunk-A6TVTNKO.js";import{a as A,b as xe}from"./chunk-ADABTCDI.js";import{a as i,c as It,d as C}from"./chunk-5PEAXTYQ.js";var Qe=C(Et(),1);var V={};It(V,{Indicator:()=>$e,Root:()=>Ye});var l=C(A(),1);function Ue(o){if(!o)return null;for(let e of o.elements){let r=e.tagName;if(r==="BUTTON"||r==="INPUT"){let a=e;if(a.type==="submit")return a}}return null}i(Ue,"getDefaultFormSubmitter");var qe="data-checked",We="data-unchecked";function q(o){return{checked(e){return o.indeterminate?{}:e?{[qe]:""}:{[We]:""}},...Ee}}i(q,"getCheckboxStateAttributesMapping");var ze=C(A(),1);function Ke(o,e,r,a=!0,s){let[f,p]=ze.useState(),P=U(s?`${s}-label`:void 0),b=o??e??f;return M(()=>{let x=o||e||!a?void 0:Nt(r.current,P);f!==x&&p(x)}),b}i(Ke,"useAriaLabelledBy");function Nt(o,e){let r=Dt(o);if(r)return!r.id&&e&&(r.id=e),r.id||void 0}i(Nt,"getAriaLabelledBy");function Dt(o){if(!o)return;let e=o.parentElement;if(e&&e.tagName==="LABEL")return e;let r=o.id;if(r){let s=o.nextElementSibling;if(s&&s.htmlFor===r)return s}let a=o.labels;return a&&a[0]}i(Dt,"findAssociatedLabel");var W=C(A(),1);var Bt=W.createContext(void 0);function Je(){return W.useContext(Bt)}i(Je,"useCheckboxGroupContext");var z=C(A(),1);var ie=z.createContext(void 0);function Xe(){let o=z.useContext(ie);if(o===void 0)throw new Error(ge(14));return o}i(Xe,"useCheckboxRootContext");var S=C(xe(),1);var At="data-parent",Ye=l.forwardRef(i(function(e,r){let{checked:a,className:s,defaultChecked:f=!1,"aria-labelledby":p,disabled:P=!1,form:b,id:x,indeterminate:N=!1,inputRef:X,name:L,onCheckedChange:F,parent:u=!1,readOnly:y=!1,render:ae,required:I=!1,uncheckedValue:T,value:O,nativeButton:_=!1,style:Mt,...Ze}=e,{clearErrors:et}=Ne(),{disabled:tt,name:ot,setDirty:rt,setFilled:se,setFocused:de,setTouched:nt,state:ce,validationMode:it,validityData:at,validation:st}=Pe(),dt=Me(),{labelId:ct,registerControlId:ut,getDescriptionProps:ue}=De(),n=Je(),k=n?.allValues===void 0?void 0:n.parent,w=k!==void 0,c=tt||dt.disabled||n?.disabled||P,E=ot??L,d=O??E,le=U(),lt=n?.registerControlId!==ut,Y=Be({id:x||void 0,enabled:lt}),ft=_?Y:le,$={};w&&(u?$=k.getParentProps():d!==void 0&&($=k.getChildProps(d)));let{checked:fe=a,indeterminate:pt=N,onCheckedChange:mt,...bt}=$,Q=n?.value,G=l.useRef(null),{getButtonProps:xt,buttonRef:ht}=Re({disabled:c,native:_}),D=n?.validation??st,[m,Ct]=Le({controlled:d!==void 0&&Q!==void 0&&!u?Q.includes(d):fe,default:f,name:"Checkbox",state:"checked"}),Z=w?!!fe:m,B=w&&pt||N;Fe(G,le,m,void 0,!n&&!c,L);let ee=k?.registerChildId,g=l.useRef(null),pe=D.registerInput,me=n?d:void 0,kt=l.useCallback(t=>pe(t,{controlRef:G,value:me}),[pe,me]),gt=ye(X,g,u?void 0:kt),vt=Ke(p,ct,g,!_,Y);M(()=>{g.current&&(g.current.indeterminate=B),n||se(m)},[m,B,n,se]),Te(m,()=>{n||(et(E),rt(m!==at.initialValue),D.change(m))});let Rt=ke({checked:m,disabled:c,form:b,name:u?void 0:E,id:_?void 0:Y,required:I,ref:gt,style:E?Ge:we,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(t){if(t.nativeEvent.defaultPrevented)return;if(y){t.preventDefault();return}let h=t.currentTarget.checked,v=_e(Oe.none,t.nativeEvent);if(F?.(h,v),!v.isCanceled&&(mt?.(h,v),!v.isCanceled&&(Ct(h),d!==void 0&&n!==void 0&&!u&&!w))){let R=h?[...n.value,d]:n.value.filter(j=>j!==d);n.setValue(R,v)}},onClick(t){t.stopPropagation()},onFocus(){G.current?.focus()}},O!==void 0?{value:(n?m&&O:O)||""}:Ie,ue,t=>D.getValidationProps(c,t));l.useEffect(()=>{if(!k||d===void 0)return;let t=k.disabledStatesRef.current;return t.set(d,c),()=>{t.delete(d)}},[k,c,d]);let te=l.useMemo(()=>({...ce,checked:Z,disabled:c,readOnly:y,required:I,indeterminate:B}),[ce,Z,c,y,I,B]),yt=q(te),be=H("span",e,{state:te,ref:[ht,G,r],props:[{id:ft,role:"checkbox","aria-checked":B?"mixed":Z,"aria-readonly":y||void 0,"aria-required":I||void 0,"aria-labelledby":vt,[At]:u?"":void 0,onFocus(){c||de(!0)},onBlur(){let t=g.current;t&&(nt(!0),de(!1),it==="onBlur"&&D.commit(n?Q:t.checked))},onKeyDown(t){if(t.key!=="Enter"||(t.preventBaseUIHandler(),t.defaultPrevented))return;let h=g.current?.form??null,v=t.currentTarget,R=t.nativeEvent,j=t.preventDefault,re=R.preventDefault,ne=!1;t.preventDefault=()=>{ne=!0,j.call(t)},R.preventDefault=()=>{ne=!0,re.call(R)},re.call(R),Ce(v).queueMicrotask(()=>{t.preventDefault=j,R.preventDefault=re,ne||Ue(h)?.click()})},onClick(t){if(y||c)return;t.preventDefault();let h=g.current;h&&ve(h,t)}},Ze,bt,xt,ue,t=>D.getValidationProps(c,t)],stateAttributesMapping:yt}),oe=be.props.id;return M(()=>{if(!(!ee||u||d===void 0||oe===void 0))return ee(d,oe)},[ee,u,d,oe]),(0,S.jsxs)(ie.Provider,{value:te,children:[be,!m&&!n&&E&&!u&&T!==void 0&&(0,S.jsx)("input",{type:"hidden",form:b,name:E,value:T,disabled:c}),(0,S.jsx)("input",{...Rt,suppressHydrationWarning:!0})]})},"CheckboxRoot"));var K=C(A(),1);var $e=K.forwardRef(i(function(e,r){let{render:a,className:s,style:f,keepMounted:p=!1,...P}=e,b=Xe(),x=b.checked||b.indeterminate,{mounted:N,transitionStatus:X,setMounted:L}=Ve(x),F=K.useRef(null),u={...b,transitionStatus:X};Se({batch:!0,enabled:!x,open:x,ref:F,onComplete(){x||L(!1)}});let ae={...q(b),...Ae},I=p||N,T=H("span",e,{ref:[r,F],state:u,stateAttributesMapping:ae,props:P});return I?T:null},"CheckboxIndicator"));var J=C(xe(),1);function Fo(o){let e=(0,Qe.c)(9),r,a;e[0]!==o?({className:r,...a}=o,e[0]=o,e[1]=r,e[2]=a):(r=e[1],a=e[2]);let s;e[3]!==r?(s=he("peer relative flex size-4 shrink-0 items-center justify-center rounded-md border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary",r),e[3]=r,e[4]=s):s=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=(0,J.jsx)(V.Indicator,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none [&>svg]:size-3.5",children:(0,J.jsx)(He,{icon:je,strokeWidth:2})}),e[5]=f):f=e[5];let p;return e[6]!==a||e[7]!==s?(p=(0,J.jsx)(V.Root,{"data-slot":"checkbox",className:s,...a,children:f}),e[6]=a,e[7]=s,e[8]=p):p=e[8],p}i(Fo,"v");export{Fo as a};
@@ -1 +1 @@
1
- import{a as q}from"./chunk-7VZFX5O4.js";import{a as D}from"./chunk-VX6ZBLXB.js";import"./chunk-CHYLD556.js";import{a as O,b as K,c as M,d as A,e as b,f as w}from"./chunk-7MM2SI65.js";import"./chunk-3SRQFKDT.js";import"./chunk-RY6I3E2K.js";import"./chunk-EOFWXI3T.js";import{a as U}from"./chunk-LYVYUTQY.js";import{c as R}from"./chunk-3CUQWI5A.js";import{a as x,e as v}from"./chunk-QQENKHRS.js";import{i as I,n as P}from"./chunk-F4ZN2DRL.js";import"./chunk-ZPQBVYNN.js";import{B as _,j as C,u as E,x as T}from"./chunk-ITS5LMYJ.js";import"./chunk-PDBW6GTJ.js";import{a as B}from"./chunk-A6TVTNKO.js";import{a as z,b as H}from"./chunk-ADABTCDI.js";import{a as l,d as S}from"./chunk-5PEAXTYQ.js";var k=S(z(),1);var V=S(B(),1);var r=S(H(),1);var F="/__lunora/advisor-procedures",Q=6e4,G=l(t=>{if(t.localProcedures)return{kind:"local"};if(t.advisorCompanion){let e=t.token===null||t.token===""?void 0:t.token;return{kind:"remote",remote:{baseUrl:E(t.workerUrl),token:e}}}return{kind:"none"}},"F"),$=class extends Error{static{l(this,"$")}constructor(){super("companion not deployed"),this.name="CompanionNotDeployedError"}},J=l(async t=>{let e=t===void 0?await fetch(F):await fetch(`${t.baseUrl}${F}`,{credentials:"include",headers:t.token===void 0?{}:{authorization:`Bearer ${t.token}`}});if(t!==void 0&&e.status===404)throw new $;if(e.ok&&!(e.headers.get("content-type")??"").includes("application/json"))throw new Error("The advisor procedure route is not available on this host.");if(!e.ok){let a=await e.json().catch(()=>{}),n=typeof a=="object"&&a&&"error"in a?String(a.error):`HTTP ${String(e.status)}`;throw new Error(n)}let o=await e.json();if(typeof o!="object"||o===null||!Array.isArray(o.procedures))throw new Error("The advisor procedure route answered without a procedure list.");return o},"G"),Y=l(t=>{let e=(0,V.c)(16),{enabled:o,refreshKey:a,remote:n}=t,[c,y]=(0,k.useState)(a),[m,p]=(0,k.useState)(0);c!==a&&(y(a),c!==void 0&&p(W));let h;e[0]!==n?(h=l(()=>J(n),"p"),e[0]=n,e[1]=h):h=e[1];let i;e[2]!==n||e[3]!==m?(i=["studio","advisor-procedures",n,m],e[2]=n,e[3]=m,e[4]=i):i=e[4];let f;e[5]!==o||e[6]!==h||e[7]!==i?(f={enabled:o,queryFn:h,queryKey:i,refetchInterval:Q,retry:!1,staleTime:0},e[5]=o,e[6]=h,e[7]=i,e[8]=f):f=e[8];let s=I(f),u;e[9]!==s.error?(u=s.error?C(s.error):void 0,e[9]=s.error,e[10]=u):u=e[10];let N=s.error instanceof $,d=c!==a,g;return e[11]!==s.data||e[12]!==u||e[13]!==N||e[14]!==d?(g={data:s.data,error:u,notDeployed:N,stale:d},e[11]=s.data,e[12]=u,e[13]=N,e[14]=d,e[15]=g):g=e[15],g},"Y");function W(t){return t+1}l(W,"z");var j={clean:"text-emerald-600 dark:text-emerald-400",exempt:"text-muted-foreground",failing:"text-red-600 dark:text-red-400",warned:"text-amber-600 dark:text-amber-400"},L={"at-risk":"text-red-600 dark:text-red-400",excellent:"text-emerald-600 dark:text-emerald-400",good:"text-emerald-600 dark:text-emerald-400","needs-work":"text-amber-600 dark:text-amber-400"},X=l((t,e)=>`exempt: ${t.exemptReason===void 0||t.exemptReason===""?e:t.exemptReason}`,"I"),Z=l(t=>t.toSorted((e,o)=>e.coverage==="clean"&&o.coverage!=="clean"?1:o.coverage==="clean"&&e.coverage!=="clean"?-1:e.score-o.score),"J"),me=l(({advisorCompanion:t=!1,localProcedures:e=!1,testId:o="advisor-health"})=>{let a=_(),n=P(),c=G({advisorCompanion:t,localProcedures:e,token:n.getAuthToken(),workerUrl:n.url}),y=R(U.getAdvisories,{},{enabled:c.kind!=="none",live:!0}),m=Y({enabled:c.kind!=="none",refreshKey:y.data,remote:c.kind==="remote"?c.remote:void 0}),[p,h]=(0,k.useState)(),i=y.data?.advisories,f=m.stale?void 0:m.data?.procedures;i!==void 0&&f!==void 0&&(p?.advisories!==i||p.procedures!==f)&&h({advisories:i,procedures:f});let s=(0,k.useMemo)(()=>p===void 0?null:q(p.procedures,p.advisories),[p]);if(c.kind==="none")return(0,r.jsx)(x,{children:(0,r.jsx)(v,{className:"py-8 text-center text-muted-foreground","data-testid":`${o}-local-only`,children:a("The health score needs `lunora dev`, or a Studio build with VITE_LUNORA_ADVISOR_COMPANION set to true.")})});if(m.notDeployed)return(0,r.jsx)(x,{children:(0,r.jsx)(v,{className:"py-8 text-center text-muted-foreground","data-testid":`${o}-companion-missing`,children:a("The health score needs the companion worker: it is not deployed for this Studio, so the advisor procedure list is unavailable.")})});if(m.data?.analysis==="disabled")return(0,r.jsx)(x,{children:(0,r.jsx)(v,{className:"py-8 text-center text-muted-foreground","data-testid":`${o}-lint-disabled`,children:a("The advisor analysis is disabled for this build: `lunora codegen` ran with `lint: false`, so there is no procedure list to score.")})});let u=m.error??y.error??null;if(u!==null)return(0,r.jsx)(D,{error:u,testId:`${o}-error`});if(s===null)return(0,r.jsx)(x,{children:(0,r.jsx)(v,{className:"py-8 text-center text-muted-foreground","data-testid":`${o}-loading`,children:a("Loading\u2026")})});let N=Z(s.procedures);return(0,r.jsxs)("div",{className:"space-y-4","data-testid":o,children:[(0,r.jsx)(x,{children:(0,r.jsxs)(v,{className:"flex flex-wrap items-baseline gap-x-6 gap-y-2 py-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:T("text-4xl font-semibold tabular-nums",L[s.grade]),"data-testid":`${o}-score`,children:s.score}),(0,r.jsx)("span",{className:"text-muted-foreground text-lg",children:"/100"})]}),(0,r.jsx)("span",{className:T("text-sm font-medium uppercase tracking-wide",L[s.grade]),"data-testid":`${o}-grade`,children:s.grade}),(0,r.jsxs)("div",{className:"text-muted-foreground flex gap-4 text-sm tabular-nums","data-testid":`${o}-summary`,children:[(0,r.jsxs)("span",{className:j.clean,children:[s.summary.clean," ",a("clean")]}),(0,r.jsxs)("span",{className:j.warned,children:[s.summary.warned," ",a("warned")]}),(0,r.jsxs)("span",{className:j.failing,children:[s.summary.failing," ",a("failing")]}),(0,r.jsxs)("span",{className:j.exempt,children:[s.summary.exempt," ",a("exempt")]})]})]})}),s.project.checks.length>0&&(0,r.jsx)(x,{children:(0,r.jsxs)(v,{className:"py-4 text-sm","data-testid":`${o}-project`,children:[(0,r.jsxs)("span",{className:"font-medium",children:[a("Schema & config")," ",s.project.score,"/100"]}),(0,r.jsxs)("span",{className:"text-muted-foreground",children:[" \u2014 ",s.project.checks.map(d=>d.name).join(", ")]})]})}),(0,r.jsx)(x,{children:(0,r.jsx)(v,{className:"p-0",children:(0,r.jsxs)(O,{children:[(0,r.jsx)(K,{children:(0,r.jsxs)(A,{children:[(0,r.jsx)(b,{className:"w-20",children:a("Score")}),(0,r.jsx)(b,{children:a("Procedure")}),(0,r.jsx)(b,{className:"w-32",children:a("Kind")}),(0,r.jsx)(b,{children:a("Rules fired")})]})}),(0,r.jsx)(M,{children:N.map(d=>(0,r.jsxs)(A,{"data-testid":`${o}-row`,children:[(0,r.jsx)(w,{className:T("tabular-nums font-medium",j[d.coverage]),children:d.coverage==="exempt"?"\u2014":d.score}),(0,r.jsx)(w,{className:"font-mono text-xs",children:d.id}),(0,r.jsxs)(w,{className:"text-muted-foreground text-xs",children:[d.visibility," ",d.kind,d.sensitivity.level==="high"&&(0,r.jsx)("span",{className:"ml-1 text-amber-600 dark:text-amber-400",children:a("sensitive")})]}),(0,r.jsx)(w,{className:"text-muted-foreground text-xs",children:d.coverage==="exempt"?X(d,a("no reason given")):d.checks.map(g=>g.name).join(", ")})]},d.id))})]})})})]})},"me");export{me as default};
1
+ import{a as q}from"./chunk-7VZFX5O4.js";import{a as D}from"./chunk-D3MLU3PX.js";import"./chunk-S7NFUY75.js";import{a as O,b as K,c as M,d as A,e as b,f as w}from"./chunk-J3ZEO3PJ.js";import"./chunk-YDDMKWPI.js";import"./chunk-5CHKXJYN.js";import"./chunk-EOFWXI3T.js";import{a as U}from"./chunk-LYVYUTQY.js";import{c as R}from"./chunk-UN3QTZ6X.js";import{a as x,e as v}from"./chunk-TN4Z3P6S.js";import{i as I,n as P}from"./chunk-5KQSRLQP.js";import"./chunk-ZPQBVYNN.js";import{B as _,j as C,u as E,x as T}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import{a as B}from"./chunk-A6TVTNKO.js";import{a as z,b as H}from"./chunk-ADABTCDI.js";import{a as l,d as S}from"./chunk-5PEAXTYQ.js";var k=S(z(),1);var V=S(B(),1);var r=S(H(),1);var F="/__lunora/advisor-procedures",Q=6e4,G=l(t=>{if(t.localProcedures)return{kind:"local"};if(t.advisorCompanion){let e=t.token===null||t.token===""?void 0:t.token;return{kind:"remote",remote:{baseUrl:E(t.workerUrl),token:e}}}return{kind:"none"}},"F"),$=class extends Error{static{l(this,"$")}constructor(){super("companion not deployed"),this.name="CompanionNotDeployedError"}},J=l(async t=>{let e=t===void 0?await fetch(F):await fetch(`${t.baseUrl}${F}`,{credentials:"include",headers:t.token===void 0?{}:{authorization:`Bearer ${t.token}`}});if(t!==void 0&&e.status===404)throw new $;if(e.ok&&!(e.headers.get("content-type")??"").includes("application/json"))throw new Error("The advisor procedure route is not available on this host.");if(!e.ok){let a=await e.json().catch(()=>{}),n=typeof a=="object"&&a&&"error"in a?String(a.error):`HTTP ${String(e.status)}`;throw new Error(n)}let o=await e.json();if(typeof o!="object"||o===null||!Array.isArray(o.procedures))throw new Error("The advisor procedure route answered without a procedure list.");return o},"G"),Y=l(t=>{let e=(0,V.c)(16),{enabled:o,refreshKey:a,remote:n}=t,[c,y]=(0,k.useState)(a),[m,p]=(0,k.useState)(0);c!==a&&(y(a),c!==void 0&&p(W));let h;e[0]!==n?(h=l(()=>J(n),"p"),e[0]=n,e[1]=h):h=e[1];let i;e[2]!==n||e[3]!==m?(i=["studio","advisor-procedures",n,m],e[2]=n,e[3]=m,e[4]=i):i=e[4];let f;e[5]!==o||e[6]!==h||e[7]!==i?(f={enabled:o,queryFn:h,queryKey:i,refetchInterval:Q,retry:!1,staleTime:0},e[5]=o,e[6]=h,e[7]=i,e[8]=f):f=e[8];let s=I(f),u;e[9]!==s.error?(u=s.error?C(s.error):void 0,e[9]=s.error,e[10]=u):u=e[10];let N=s.error instanceof $,d=c!==a,g;return e[11]!==s.data||e[12]!==u||e[13]!==N||e[14]!==d?(g={data:s.data,error:u,notDeployed:N,stale:d},e[11]=s.data,e[12]=u,e[13]=N,e[14]=d,e[15]=g):g=e[15],g},"Y");function W(t){return t+1}l(W,"z");var j={clean:"text-emerald-600 dark:text-emerald-400",exempt:"text-muted-foreground",failing:"text-red-600 dark:text-red-400",warned:"text-amber-600 dark:text-amber-400"},L={"at-risk":"text-red-600 dark:text-red-400",excellent:"text-emerald-600 dark:text-emerald-400",good:"text-emerald-600 dark:text-emerald-400","needs-work":"text-amber-600 dark:text-amber-400"},X=l((t,e)=>`exempt: ${t.exemptReason===void 0||t.exemptReason===""?e:t.exemptReason}`,"I"),Z=l(t=>t.toSorted((e,o)=>e.coverage==="clean"&&o.coverage!=="clean"?1:o.coverage==="clean"&&e.coverage!=="clean"?-1:e.score-o.score),"J"),me=l(({advisorCompanion:t=!1,localProcedures:e=!1,testId:o="advisor-health"})=>{let a=_(),n=P(),c=G({advisorCompanion:t,localProcedures:e,token:n.getAuthToken(),workerUrl:n.url}),y=R(U.getAdvisories,{},{enabled:c.kind!=="none",live:!0}),m=Y({enabled:c.kind!=="none",refreshKey:y.data,remote:c.kind==="remote"?c.remote:void 0}),[p,h]=(0,k.useState)(),i=y.data?.advisories,f=m.stale?void 0:m.data?.procedures;i!==void 0&&f!==void 0&&(p?.advisories!==i||p.procedures!==f)&&h({advisories:i,procedures:f});let s=(0,k.useMemo)(()=>p===void 0?null:q(p.procedures,p.advisories),[p]);if(c.kind==="none")return(0,r.jsx)(x,{children:(0,r.jsx)(v,{className:"py-8 text-center text-muted-foreground","data-testid":`${o}-local-only`,children:a("The health score needs `lunora dev`, or a Studio build with VITE_LUNORA_ADVISOR_COMPANION set to true.")})});if(m.notDeployed)return(0,r.jsx)(x,{children:(0,r.jsx)(v,{className:"py-8 text-center text-muted-foreground","data-testid":`${o}-companion-missing`,children:a("The health score needs the companion worker: it is not deployed for this Studio, so the advisor procedure list is unavailable.")})});if(m.data?.analysis==="disabled")return(0,r.jsx)(x,{children:(0,r.jsx)(v,{className:"py-8 text-center text-muted-foreground","data-testid":`${o}-lint-disabled`,children:a("The advisor analysis is disabled for this build: `lunora codegen` ran with `lint: false`, so there is no procedure list to score.")})});let u=m.error??y.error??null;if(u!==null)return(0,r.jsx)(D,{error:u,testId:`${o}-error`});if(s===null)return(0,r.jsx)(x,{children:(0,r.jsx)(v,{className:"py-8 text-center text-muted-foreground","data-testid":`${o}-loading`,children:a("Loading\u2026")})});let N=Z(s.procedures);return(0,r.jsxs)("div",{className:"space-y-4","data-testid":o,children:[(0,r.jsx)(x,{children:(0,r.jsxs)(v,{className:"flex flex-wrap items-baseline gap-x-6 gap-y-2 py-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:T("text-4xl font-semibold tabular-nums",L[s.grade]),"data-testid":`${o}-score`,children:s.score}),(0,r.jsx)("span",{className:"text-muted-foreground text-lg",children:"/100"})]}),(0,r.jsx)("span",{className:T("text-sm font-medium uppercase tracking-wide",L[s.grade]),"data-testid":`${o}-grade`,children:s.grade}),(0,r.jsxs)("div",{className:"text-muted-foreground flex gap-4 text-sm tabular-nums","data-testid":`${o}-summary`,children:[(0,r.jsxs)("span",{className:j.clean,children:[s.summary.clean," ",a("clean")]}),(0,r.jsxs)("span",{className:j.warned,children:[s.summary.warned," ",a("warned")]}),(0,r.jsxs)("span",{className:j.failing,children:[s.summary.failing," ",a("failing")]}),(0,r.jsxs)("span",{className:j.exempt,children:[s.summary.exempt," ",a("exempt")]})]})]})}),s.project.checks.length>0&&(0,r.jsx)(x,{children:(0,r.jsxs)(v,{className:"py-4 text-sm","data-testid":`${o}-project`,children:[(0,r.jsxs)("span",{className:"font-medium",children:[a("Schema & config")," ",s.project.score,"/100"]}),(0,r.jsxs)("span",{className:"text-muted-foreground",children:[" \u2014 ",s.project.checks.map(d=>d.name).join(", ")]})]})}),(0,r.jsx)(x,{children:(0,r.jsx)(v,{className:"p-0",children:(0,r.jsxs)(O,{children:[(0,r.jsx)(K,{children:(0,r.jsxs)(A,{children:[(0,r.jsx)(b,{className:"w-20",children:a("Score")}),(0,r.jsx)(b,{children:a("Procedure")}),(0,r.jsx)(b,{className:"w-32",children:a("Kind")}),(0,r.jsx)(b,{children:a("Rules fired")})]})}),(0,r.jsx)(M,{children:N.map(d=>(0,r.jsxs)(A,{"data-testid":`${o}-row`,children:[(0,r.jsx)(w,{className:T("tabular-nums font-medium",j[d.coverage]),children:d.coverage==="exempt"?"\u2014":d.score}),(0,r.jsx)(w,{className:"font-mono text-xs",children:d.id}),(0,r.jsxs)(w,{className:"text-muted-foreground text-xs",children:[d.visibility," ",d.kind,d.sensitivity.level==="high"&&(0,r.jsx)("span",{className:"ml-1 text-amber-600 dark:text-amber-400",children:a("sensitive")})]}),(0,r.jsx)(w,{className:"text-muted-foreground text-xs",children:d.coverage==="exempt"?X(d,a("no reason given")):d.checks.map(g=>g.name).join(", ")})]},d.id))})]})})})]})},"me");export{me as default};
@@ -1 +1 @@
1
- import{B as y,r as w}from"./chunk-ITS5LMYJ.js";import{a as v}from"./chunk-A6TVTNKO.js";import{b as _}from"./chunk-ADABTCDI.js";import{a as m,d as g}from"./chunk-5PEAXTYQ.js";var x=g(v(),1);var a=g(_(),1);var k=m((s,e)=>{if(e==="")return[{match:!1,offset:0,text:s}];let n=[],l=s.toLowerCase(),o=e.toLowerCase(),t=0;for(let r=l.indexOf(o);r!==-1;r=l.indexOf(o,t))r>t&&n.push({match:!1,offset:t,text:s.slice(t,r)}),n.push({match:!0,offset:r,text:s.slice(r,r+e.length)}),t=r+e.length;return t<s.length&&n.push({match:!1,offset:t,text:s.slice(t)}),n},"N"),L=m(s=>{let e=(0,x.c)(9),{highlight:n,value:l}=s;if(l==null){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=(0,a.jsx)("span",{className:"text-muted-foreground/50 italic",children:"NULL"}),e[0]=d):d=e[0],d}let o,t,r;if(e[1]!==n||e[2]!==l){r=Symbol.for("react.early_return_sentinel");e:{let d=w(l);if(n===void 0||n===""){r=(0,a.jsx)("span",{title:d,children:d});break e}o=d,t=k(d,n).map(j)}e[1]=n,e[2]=l,e[3]=o,e[4]=t,e[5]=r}else o=e[3],t=e[4],r=e[5];if(r!==Symbol.for("react.early_return_sentinel"))return r;let c;return e[6]!==o||e[7]!==t?(c=(0,a.jsx)("span",{title:o,children:t}),e[6]=o,e[7]=t,e[8]=c):c=e[8],c},"v"),O=m(s=>{let e=(0,x.c)(22),{columns:n,rows:l}=s,o=y(),t;e[0]!==o?(t=o("Field"),e[0]=o,e[1]=t):t=e[1];let r;e[2]!==t?(r=(0,a.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:t}),e[2]=t,e[3]=r):r=e[3];let c;if(e[4]!==l||e[5]!==o){let i;e[7]!==o?(i=m((b,p)=>(0,a.jsx)("th",{className:"border-b border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase tabular-nums text-muted-foreground",children:o("Row {n}",{n:p+1})},p),"c"),e[7]=o,e[8]=i):i=e[8],c=l.map(i),e[4]=l,e[5]=o,e[6]=c}else c=e[6];let d;e[9]!==r||e[10]!==c?(d=(0,a.jsx)("thead",{className:"sticky top-0 z-10 bg-muted",children:(0,a.jsxs)("tr",{children:[r,c]})}),e[9]=r,e[10]=c,e[11]=d):d=e[11];let f;if(e[12]!==n||e[13]!==l){let i;e[15]!==l?(i=m(b=>(0,a.jsxs)("tr",{className:"hover:bg-muted/40",children:[(0,a.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono font-medium whitespace-nowrap",scope:"row",children:b}),l.map((p,N)=>(0,a.jsx)("td",{className:"max-w-md truncate border-b border-border px-3 py-1.5 font-mono",children:(0,a.jsx)(L,{value:p[b]})},N))]},b),"c"),e[15]=l,e[16]=i):i=e[16],f=n.map(i),e[12]=n,e[13]=l,e[14]=f}else f=e[14];let h;e[17]!==f?(h=(0,a.jsx)("tbody",{children:f}),e[17]=f,e[18]=h):h=e[18];let u;return e[19]!==d||e[20]!==h?(u=(0,a.jsx)("div",{className:"min-h-0 flex-1 overflow-auto","data-testid":"db-transposed",children:(0,a.jsxs)("table",{className:"border-collapse text-xs",children:[d,h]})}),e[19]=d,e[20]=h,e[21]=u):u=e[21],u},"T"),T=m(({children:s,layout:e="card",testId:n})=>(0,a.jsx)("div",{className:e==="fill"?"flex min-h-0 flex-1 flex-col overflow-hidden border-t border-border":"overflow-x-auto border border-border bg-card","data-testid":n,children:s}),"j");function j(s){return(0,a.jsx)("mark",{className:s.match?"rounded-sm bg-warning/40 text-foreground":"bg-transparent text-inherit",children:s.text},s.offset)}m(j,"_");export{L as a,O as b,T as c};
1
+ import{B as y,r as w}from"./chunk-PN7JHEYW.js";import{a as v}from"./chunk-A6TVTNKO.js";import{b as _}from"./chunk-ADABTCDI.js";import{a as m,d as g}from"./chunk-5PEAXTYQ.js";var x=g(v(),1);var a=g(_(),1);var k=m((s,e)=>{if(e==="")return[{match:!1,offset:0,text:s}];let n=[],l=s.toLowerCase(),o=e.toLowerCase(),t=0;for(let r=l.indexOf(o);r!==-1;r=l.indexOf(o,t))r>t&&n.push({match:!1,offset:t,text:s.slice(t,r)}),n.push({match:!0,offset:r,text:s.slice(r,r+e.length)}),t=r+e.length;return t<s.length&&n.push({match:!1,offset:t,text:s.slice(t)}),n},"N"),L=m(s=>{let e=(0,x.c)(9),{highlight:n,value:l}=s;if(l==null){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=(0,a.jsx)("span",{className:"text-muted-foreground/50 italic",children:"NULL"}),e[0]=d):d=e[0],d}let o,t,r;if(e[1]!==n||e[2]!==l){r=Symbol.for("react.early_return_sentinel");e:{let d=w(l);if(n===void 0||n===""){r=(0,a.jsx)("span",{title:d,children:d});break e}o=d,t=k(d,n).map(j)}e[1]=n,e[2]=l,e[3]=o,e[4]=t,e[5]=r}else o=e[3],t=e[4],r=e[5];if(r!==Symbol.for("react.early_return_sentinel"))return r;let c;return e[6]!==o||e[7]!==t?(c=(0,a.jsx)("span",{title:o,children:t}),e[6]=o,e[7]=t,e[8]=c):c=e[8],c},"v"),O=m(s=>{let e=(0,x.c)(22),{columns:n,rows:l}=s,o=y(),t;e[0]!==o?(t=o("Field"),e[0]=o,e[1]=t):t=e[1];let r;e[2]!==t?(r=(0,a.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:t}),e[2]=t,e[3]=r):r=e[3];let c;if(e[4]!==l||e[5]!==o){let i;e[7]!==o?(i=m((b,p)=>(0,a.jsx)("th",{className:"border-b border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase tabular-nums text-muted-foreground",children:o("Row {n}",{n:p+1})},p),"c"),e[7]=o,e[8]=i):i=e[8],c=l.map(i),e[4]=l,e[5]=o,e[6]=c}else c=e[6];let d;e[9]!==r||e[10]!==c?(d=(0,a.jsx)("thead",{className:"sticky top-0 z-10 bg-muted",children:(0,a.jsxs)("tr",{children:[r,c]})}),e[9]=r,e[10]=c,e[11]=d):d=e[11];let f;if(e[12]!==n||e[13]!==l){let i;e[15]!==l?(i=m(b=>(0,a.jsxs)("tr",{className:"hover:bg-muted/40",children:[(0,a.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono font-medium whitespace-nowrap",scope:"row",children:b}),l.map((p,N)=>(0,a.jsx)("td",{className:"max-w-md truncate border-b border-border px-3 py-1.5 font-mono",children:(0,a.jsx)(L,{value:p[b]})},N))]},b),"c"),e[15]=l,e[16]=i):i=e[16],f=n.map(i),e[12]=n,e[13]=l,e[14]=f}else f=e[14];let h;e[17]!==f?(h=(0,a.jsx)("tbody",{children:f}),e[17]=f,e[18]=h):h=e[18];let u;return e[19]!==d||e[20]!==h?(u=(0,a.jsx)("div",{className:"min-h-0 flex-1 overflow-auto","data-testid":"db-transposed",children:(0,a.jsxs)("table",{className:"border-collapse text-xs",children:[d,h]})}),e[19]=d,e[20]=h,e[21]=u):u=e[21],u},"T"),T=m(({children:s,layout:e="card",testId:n})=>(0,a.jsx)("div",{className:e==="fill"?"flex min-h-0 flex-1 flex-col overflow-hidden border-t border-border":"overflow-x-auto border border-border bg-card","data-testid":n,children:s}),"j");function j(s){return(0,a.jsx)("mark",{className:s.match?"rounded-sm bg-warning/40 text-foreground":"bg-transparent text-inherit",children:s.text},s.offset)}m(j,"_");export{L as a,O as b,T as c};
@@ -1 +1 @@
1
- import{a as n}from"./chunk-LYVYUTQY.js";import{c as f}from"./chunk-3CUQWI5A.js";import{n as q}from"./chunk-F4ZN2DRL.js";import{h as s,i as l}from"./chunk-ITS5LMYJ.js";import{a as U}from"./chunk-ADABTCDI.js";import{a as e,d as R}from"./chunk-5PEAXTYQ.js";var p=R(U(),1);var _=e(async i=>{try{let{knowledgeExcerpts:d}=await import("./chunk-UAXX2RXT.js");return d(i)}catch{return[]}},"x"),B={},H=s(n.aiGenerateSql),L=s(n.aiTableFilter),O=s(n.aiChartConfig),P=s(n.aiChat),V=s(n.aiNameQuery),j=s(n.aiCronExpression),Y=e(i=>{let d=q(),[w,g]=(0,p.useState)({}),[b,m]=(0,p.useState)({}),y=f(n.aiAvailable,B,{shardKey:i}),[C,S]=(0,p.useState)(!1),N=C||y.data?.available===!1,c=e(a=>{g(r=>({...r,[a]:!0})),m(r=>({...r,[a]:void 0}))},"i"),t=e((a,r)=>{g(o=>({...o,[a]:!1})),r!==void 0&&m(o=>({...o,[a]:r})),(r==="ai-disabled"||r==="no-ai-binding")&&S(!0)},"e"),h=e(async a=>{c("sql");try{let r=await d.query(H,a,l(i));return t("sql",r.degraded?r.reason:void 0),r.degraded?void 0:r.sql}catch{t("sql","ai-error");return}},"p"),x=e(async(a,r)=>h({failedError:r?.error,failedSql:r?.sql,prompt:a}),"E"),E=e(async(a,r)=>h({editSql:r,prompt:a}),"w"),F=e(async(a,r,o,G,K,v)=>{c("chat");try{let u=await d.streamRpc(P,{approval:G,knowledge:await _(a),prompt:a,schema:o,shardKey:i,transcript:r},{onFrame:e(M=>{K?.(M)},"onFrame"),...v===void 0?{}:{signal:v}});return t("chat",u.degraded?u.reason:void 0),u.degraded?void 0:u}catch{t("chat","ai-error");return}},"C"),A=e(async(a,r)=>{c("filter");try{let o=await d.query(L,{prompt:a,table:r},l(i));return t("filter",o.degraded?o.reason:void 0),o.degraded?void 0:o.clauses}catch{t("filter","ai-error");return}},"I"),I=e(async a=>{c("chart");try{let r=await d.query(O,a,l(i));return t("chart",r.degraded?r.reason:void 0),r.degraded?void 0:r.chart}catch{t("chart","ai-error");return}},"R"),Q=e(async a=>{c("name");try{let r=await d.query(V,{sql:a},l(i));return t("name",r.degraded?r.reason:void 0),r.degraded?void 0:{description:r.description,title:r.title}}catch{t("name","ai-error");return}},"S"),T=e(async a=>{c("cron");try{let r=await d.query(j,{prompt:a},l(i));return t("cron",r.degraded?r.reason:void 0),r.degraded?void 0:r.cron}catch{t("cron","ai-error");return}},"T"),k=e(a=>w[a]===!0,"N"),D=e(a=>b[a],"b");return{chat:F,generate:x,inferChart:I,level:y.data?.level,nameQuery:Q,pending:k,reason:D,rewrite:E,suggestCron:T,suggestFilter:A,unavailable:N}},"V");export{Y as a};
1
+ import{a as n}from"./chunk-LYVYUTQY.js";import{c as f}from"./chunk-UN3QTZ6X.js";import{n as q}from"./chunk-5KQSRLQP.js";import{h as s,i as l}from"./chunk-PN7JHEYW.js";import{a as U}from"./chunk-ADABTCDI.js";import{a as e,d as R}from"./chunk-5PEAXTYQ.js";var p=R(U(),1);var _=e(async i=>{try{let{knowledgeExcerpts:d}=await import("./chunk-UAXX2RXT.js");return d(i)}catch{return[]}},"x"),B={},H=s(n.aiGenerateSql),L=s(n.aiTableFilter),O=s(n.aiChartConfig),P=s(n.aiChat),V=s(n.aiNameQuery),j=s(n.aiCronExpression),Y=e(i=>{let d=q(),[w,g]=(0,p.useState)({}),[b,m]=(0,p.useState)({}),y=f(n.aiAvailable,B,{shardKey:i}),[C,S]=(0,p.useState)(!1),N=C||y.data?.available===!1,c=e(a=>{g(r=>({...r,[a]:!0})),m(r=>({...r,[a]:void 0}))},"i"),t=e((a,r)=>{g(o=>({...o,[a]:!1})),r!==void 0&&m(o=>({...o,[a]:r})),(r==="ai-disabled"||r==="no-ai-binding")&&S(!0)},"e"),h=e(async a=>{c("sql");try{let r=await d.query(H,a,l(i));return t("sql",r.degraded?r.reason:void 0),r.degraded?void 0:r.sql}catch{t("sql","ai-error");return}},"p"),x=e(async(a,r)=>h({failedError:r?.error,failedSql:r?.sql,prompt:a}),"E"),E=e(async(a,r)=>h({editSql:r,prompt:a}),"w"),F=e(async(a,r,o,G,K,v)=>{c("chat");try{let u=await d.streamRpc(P,{approval:G,knowledge:await _(a),prompt:a,schema:o,shardKey:i,transcript:r},{onFrame:e(M=>{K?.(M)},"onFrame"),...v===void 0?{}:{signal:v}});return t("chat",u.degraded?u.reason:void 0),u.degraded?void 0:u}catch{t("chat","ai-error");return}},"C"),A=e(async(a,r)=>{c("filter");try{let o=await d.query(L,{prompt:a,table:r},l(i));return t("filter",o.degraded?o.reason:void 0),o.degraded?void 0:o.clauses}catch{t("filter","ai-error");return}},"I"),I=e(async a=>{c("chart");try{let r=await d.query(O,a,l(i));return t("chart",r.degraded?r.reason:void 0),r.degraded?void 0:r.chart}catch{t("chart","ai-error");return}},"R"),Q=e(async a=>{c("name");try{let r=await d.query(V,{sql:a},l(i));return t("name",r.degraded?r.reason:void 0),r.degraded?void 0:{description:r.description,title:r.title}}catch{t("name","ai-error");return}},"S"),T=e(async a=>{c("cron");try{let r=await d.query(j,{prompt:a},l(i));return t("cron",r.degraded?r.reason:void 0),r.degraded?void 0:r.cron}catch{t("cron","ai-error");return}},"T"),k=e(a=>w[a]===!0,"N"),D=e(a=>b[a],"b");return{chat:F,generate:x,inferChart:I,level:y.data?.level,nameQuery:Q,pending:k,reason:D,rewrite:E,suggestCron:T,suggestFilter:A,unavailable:N}},"V");export{Y as a};
@@ -1 +1 @@
1
- import{b as Ke}from"./chunk-R6NJ4ER6.js";import{a as Ie,b as De,c as Oe}from"./chunk-AFLNQEZ5.js";import{a as Ee}from"./chunk-2AKEF2E6.js";import"./chunk-4KPATTV6.js";import{i as we}from"./chunk-GTW3JPQQ.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as ke}from"./chunk-EG45XFL3.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{b as _e}from"./chunk-26XOFIV4.js";import"./chunk-L27FKJTG.js";import{a as je}from"./chunk-VX6ZBLXB.js";import"./chunk-CHYLD556.js";import{a as Se,b as Te,c as Ce,d as ie,e as M,f as W}from"./chunk-7MM2SI65.js";import"./chunk-3SRQFKDT.js";import"./chunk-RY6I3E2K.js";import"./chunk-EOFWXI3T.js";import{a as ve}from"./chunk-LYVYUTQY.js";import{c as ye}from"./chunk-3CUQWI5A.js";import{a as le,e as oe}from"./chunk-QQENKHRS.js";import{n as Ae}from"./chunk-F4ZN2DRL.js";import"./chunk-ZPQBVYNN.js";import{B as xe,j as pe,s as he,w as fe}from"./chunk-ITS5LMYJ.js";import"./chunk-PDBW6GTJ.js";import{a as ze}from"./chunk-A6TVTNKO.js";import{a as Ue,b as Pe}from"./chunk-ADABTCDI.js";import{a as b,d as Ne}from"./chunk-5PEAXTYQ.js";var ce=Ne(ze(),1);var I=Ne(Ue(),1);var a=Ne(Pe(),1);var Le=["disabled","schema","schema_and_log","schema_and_log_and_data"],$e={describeTables:"schema",readAdvisors:"schema",readLogs:"schema_and_log",readPolicies:"schema",runSql:"schema_and_log_and_data"},Be=864e5,qe=b(()=>{let t=(0,ce.c)(67),e=Ae(),r=xe(),n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],t[0]=n):n=t[0];let g;t[1]!==e?(g={owner:e,tokens:n},t[1]=e,t[2]=g):g=t[2];let[h,N]=(0,I.useState)(g),x=h.owner===e?h.tokens:[],[c,m]=(0,I.useState)(null),[p,o]=(0,I.useState)(null);p!==null&&p.owner!==e&&o(null);let d=p?.owner===e?p.token:null,[l,i]=(0,I.useState)(""),[s,u]=(0,I.useState)(""),[_,k]=(0,I.useState)(null),D=_===e,v=(0,I.useRef)(0),w=(0,I.useRef)(e),O,j;t[3]!==e?(O=b(()=>{w.current=e},"D"),j=[e],t[3]=e,t[4]=O,t[5]=j):(O=t[4],j=t[5]),(0,I.useEffect)(O,j);let K;t[6]!==e?(K=b(async()=>{if(w.current!==e)return;v.current=v.current+1;let f=v.current;try{let E=await e.listAdminTokens();f===v.current&&(N({owner:e,tokens:E}),m(null))}catch(E){let de=E;f===v.current&&m(pe(de))}},"L"),t[6]=e,t[7]=K):K=t[7];let y=K,L,R;t[8]!==y?(L=b(()=>{he(y())},"O"),R=[y],t[8]=y,t[9]=L,t[10]=R):(L=t[9],R=t[10]),(0,I.useEffect)(L,R);let U;t[11]!==e||t[12]!==d||t[13]!==D||t[14]!==s||t[15]!==l||t[16]!==y?(U=b(f=>{if(f.preventDefault(),D||d!==null)return;k(e);let E=e,de=s===""?void 0:Date.now()+Number(s)*Be;he((async()=>{try{let se=await E.createAdminToken({expiresAt:de,name:l.trim()});w.current===E&&(o({owner:E,token:se}),i(""),u(""),await y())}catch(se){m(pe(se))}k(se=>se===E?null:se)})())},"K"),t[11]=e,t[12]=d,t[13]=D,t[14]=s,t[15]=l,t[16]=y,t[17]=U):U=t[17];let B=U,H=b(f=>{he((async()=>{try{await e.revokeAdminToken(f),o(E=>E?.token.name===f?null:E),await y()}catch(E){let de=E;await y(),w.current===e&&m(pe(de))}})())},"q"),q=le,G="py-0",J="set-admin-tokens",S;t[18]!==r?(S=r("Admin tokens"),t[18]=r,t[19]=S):S=t[19];let T;t[20]!==S?(T=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:S})}),t[20]=S,t[21]=T):T=t[21];let F=oe,Q="flex flex-col gap-3 py-3",C;t[22]!==r?(C=r("Named tokens use the admin API but cannot manage tokens or open admin WebSockets. A revoked token is refused within 30 seconds."),t[22]=r,t[23]=C):C=t[23];let z;t[24]!==C?(z=(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:C}),t[24]=C,t[25]=z):z=t[25];let V;t[26]!==c?(V=c!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"set-admin-tokens-error",role:"alert",children:c}),t[26]=c,t[27]=V):V=t[27];let P;t[28]!==d||t[29]!==r?(P=d!==null&&(0,a.jsxs)("div",{className:"rounded-md border border-border p-3 text-xs","data-testid":"set-admin-token-created",role:"status",children:[(0,a.jsx)("p",{className:"pb-1 text-muted-foreground",children:r("Copy this token now. It is not shown again.")}),(0,a.jsx)("code",{className:"font-mono break-all select-all",children:d.token}),(0,a.jsx)("div",{className:"pt-2",children:(0,a.jsx)(ke,{"data-testid":"set-admin-token-dismiss",onClick:b(()=>{o(null)},"onClick"),size:"xs",variant:"outline",children:r("Dismiss")})})]}),t[28]=d,t[29]=r,t[30]=P):P=t[30];let A;t[31]!==r?(A=r("Token name"),t[31]=r,t[32]=A):A=t[32];let $;t[33]===Symbol.for("react.memo_cache_sentinel")?($=b(f=>{i(f.target.value)},"B"),t[33]=$):$=t[33];let X;t[34]!==l||t[35]!==A?(X=(0,a.jsx)(we,{"aria-label":A,className:"w-48","data-testid":"set-admin-token-name",onChange:$,pattern:"[a-z0-9][a-z0-9_\\-]{0,63}",placeholder:"ci-deploy",required:!0,value:l}),t[34]=l,t[35]=A,t[36]=X):X=t[36];let Y;t[37]!==r?(Y=r("Expires in days (optional)"),t[37]=r,t[38]=Y):Y=t[38];let me;t[39]===Symbol.for("react.memo_cache_sentinel")?(me=b(f=>{u(f.target.value)},"de"),t[39]=me):me=t[39];let Z;t[40]!==r?(Z=r("Expires in days (optional)"),t[40]=r,t[41]=Z):Z=t[41];let ee;t[42]!==s||t[43]!==Y||t[44]!==Z?(ee=(0,a.jsx)(we,{"aria-label":Y,className:"w-40",min:1,onChange:me,placeholder:Z,type:"number",value:s}),t[42]=s,t[43]=Y,t[44]=Z,t[45]=ee):ee=t[45];let be=D||d!==null,te;t[46]!==r?(te=r("Create token"),t[46]=r,t[47]=te):te=t[47];let ae;t[48]!==be||t[49]!==te?(ae=(0,a.jsx)(ke,{"data-testid":"set-admin-token-create",disabled:be,size:"sm",type:"submit",children:te}),t[48]=be,t[49]=te,t[50]=ae):ae=t[50];let ne;t[51]!==B||t[52]!==X||t[53]!==ee||t[54]!==ae?(ne=(0,a.jsxs)("form",{className:"flex flex-wrap items-end gap-2",onSubmit:B,children:[X,ee,ae]}),t[51]=B,t[52]=X,t[53]=ee,t[54]=ae,t[55]=ne):ne=t[55];let ge=x.length>0&&(0,a.jsxs)(Se,{"data-testid":"set-admin-tokens-table",children:[(0,a.jsx)(Te,{children:(0,a.jsxs)(ie,{children:[(0,a.jsx)(M,{children:r("name")}),(0,a.jsx)(M,{children:r("Created")}),(0,a.jsx)(M,{children:r("Last used")}),(0,a.jsx)(M,{children:r("Expires")}),(0,a.jsx)(M,{})]})}),(0,a.jsx)(Ce,{children:x.map(f=>(0,a.jsxs)(ie,{"data-testid":"set-admin-token-row",children:[(0,a.jsxs)(W,{className:"font-mono text-xs",children:[f.name,f.revoked===!0&&(0,a.jsx)("span",{className:"pl-2 text-destructive",children:r("Revoked")})]}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.createdAt)}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.lastUsedAt,"\u2014")}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.expiresAt,r("Never"))}),(0,a.jsx)(W,{children:(0,a.jsx)(Ee,{onConfirm:b(()=>{H(f.name)},"onConfirm"),testId:`set-admin-token-revoke-${f.name}`,children:r("Revoke")})})]},f.name))})]}),re;t[56]!==F||t[57]!==z||t[58]!==V||t[59]!==P||t[60]!==ne||t[61]!==ge?(re=(0,a.jsxs)(F,{className:Q,children:[z,V,P,ne,ge]}),t[56]=F,t[57]=z,t[58]=V,t[59]=P,t[60]=ne,t[61]=ge,t[62]=re):re=t[62];let ue;return t[63]!==q||t[64]!==T||t[65]!==re?(ue=(0,a.jsxs)(q,{className:G,"data-testid":J,children:[T,re]}),t[63]=q,t[64]=T,t[65]=re,t[66]=ue):ue=t[66],ue},"Fe"),Fe={binding:"outline",secret:"destructive",var:"secondary"},Ve=b((t,e)=>{if(t===void 0)return[];let r=[];return t.workerUrl!==void 0&&r.push({label:e("URL"),value:t.workerUrl}),t.environment!==void 0&&r.push({label:e("Environment"),value:t.environment}),t.deploymentId!==void 0&&r.push({label:e("Deployment"),value:t.deploymentId}),t.versionTag!==void 0&&r.push({label:e("Version"),value:t.versionTag}),r},"Pe"),Me={disabled:"The assistant is off. Nothing about this deployment is sent to a model.",schema:"Table and column names.",schema_and_log:"Table and column names, plus recent log lines.",schema_and_log_and_data:"Table and column names, log lines, and rows read with SELECT."},We=b(t=>{let e=[];for(let[r,n]of Object.entries($e))n===t&&e.push(r);return e},"qe"),He=b(()=>{let t=(0,ce.c)(29),e=xe(),r,n;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},n={shardKey:""},t[0]=r,t[1]=n):(r=t[0],n=t[1]);let{data:g}=ye(ve.aiAvailable,r,n),h=g?.level,N;t[2]!==h?(N=h===void 0?-1:Le.indexOf(h),t[2]=h,t[3]=N):N=t[3];let x=N,c;t[4]!==e?(c=e("AI assistant data sharing"),t[4]=e,t[5]=c):c=t[5];let m;t[6]!==c?(m=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c}),t[6]=c,t[7]=m):m=t[7];let p;t[8]!==h?(p=h!==void 0&&(0,a.jsx)(_e,{"data-testid":"set-ai-level",variant:h==="disabled"?"outline":"secondary",children:h}),t[8]=h,t[9]=p):p=t[9];let o;t[10]!==m||t[11]!==p?(o=(0,a.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[m,p]}),t[10]=m,t[11]=p,t[12]=o):o=t[12];let d;t[13]!==x||t[14]!==h||t[15]!==e?(d=Le.map((k,D)=>{let v=x>=D,w=We(k);return(0,a.jsxs)("li",{className:v?"flex flex-col gap-0.5":"flex flex-col gap-0.5 opacity-50","data-granted":String(v),"data-testid":`set-ai-tier-${k}`,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"font-mono text-xs",children:k}),k===h&&(0,a.jsx)("span",{className:"text-[11px] text-primary",children:e("current")})]}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:e(Me[k])}),w.length>0&&(0,a.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:w.join(", ")})]},k)}),t[13]=x,t[14]=h,t[15]=e,t[16]=d):d=t[16];let l;t[17]!==d?(l=(0,a.jsx)("ul",{className:"flex flex-col gap-1.5 text-sm",children:d}),t[17]=d,t[18]=l):l=t[18];let i;t[19]!==e?(i=e("Set LUNORA_AI_OPT_IN in wrangler.jsonc and redeploy to change this. The Studio can read this level but never raise it."),t[19]=e,t[20]=i):i=t[20];let s;t[21]!==i?(s=(0,a.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"set-ai-howto",children:i}),t[21]=i,t[22]=s):s=t[22];let u;t[23]!==s||t[24]!==l?(u=(0,a.jsxs)(oe,{className:"flex flex-col gap-3 py-3",children:[l,s]}),t[23]=s,t[24]=l,t[25]=u):u=t[25];let _;return t[26]!==u||t[27]!==o?(_=(0,a.jsxs)(le,{className:"py-0","data-testid":"set-ai-sharing",children:[o,u]}),t[26]=u,t[27]=o,t[28]=_):_=t[28],_},"ze"),Re=b(t=>{let e=(0,ce.c)(18),{modifier:r,name:n,label:g}=t,h=Ie(),N;e[0]!==n?(N=b(u=>{if(!["Escape","Tab"].includes(u.key)){if(u.shiftKey){u.preventDefault();return}u.preventDefault(),De(n,u.key)}},"N"),e[0]=n,e[1]=N):N=e[1];let x=N,c=`set-shortcut-${n}`,m;e[2]!==g?(m=(0,a.jsx)("dt",{className:"text-muted-foreground",children:g}),e[2]=g,e[3]=m):m=e[3];let p;e[4]!==r?(p=(0,a.jsx)("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:r}),e[4]=r,e[5]=p):p=e[5];let o=`set-shortcut-input-${n}`,d=h[n],l;e[6]!==g||e[7]!==x||e[8]!==o||e[9]!==d?(l=(0,a.jsx)("input",{"aria-label":g,className:"h-7 w-12 rounded-md border border-border bg-background text-center font-mono text-xs uppercase outline-none focus-visible:border-ring","data-testid":o,onKeyDown:x,readOnly:!0,value:d}),e[6]=g,e[7]=x,e[8]=o,e[9]=d,e[10]=l):l=e[10];let i;e[11]!==p||e[12]!==l?(i=(0,a.jsxs)("dd",{className:"flex items-center gap-1.5",children:[p,l]}),e[11]=p,e[12]=l,e[13]=i):i=e[13];let s;return e[14]!==c||e[15]!==m||e[16]!==i?(s=(0,a.jsxs)("div",{className:"contents","data-testid":c,children:[m,i]}),e[14]=c,e[15]=m,e[16]=i,e[17]=s):s=e[17],s},"we"),ct=b(t=>{let e=(0,ce.c)(87),{initialShardKey:r}=t,n=xe(),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];let h=r??"",N;e[1]!==h?(N={shardKey:h},e[1]=h,e[2]=N):N=e[2];let{data:x,error:c,errorSource:m,isLoading:p}=ye(ve.getSettings,g,N),o,d,l,i,s,u,_;if(e[3]!==c||e[4]!==m||e[5]!==x?.deploy||e[6]!==x?.settings||e[7]!==n){let V=Ve(x?.deploy,n),P;e[15]!==x?.settings?(P=x?.settings??[],e[15]=x?.settings,e[16]=P):P=e[16],o=P,d="flex flex-col gap-4",l="lunora-settings";let A;e[17]!==n?(A=n("Open in Cloudflare"),e[17]=n,e[18]=A):A=e[18],e[19]!==A?(i=(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,a.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:Ke,rel:"noreferrer",target:"_blank",children:A})}),e[19]=A,e[20]=i):i=e[20];let $;e[21]!==n?($=n("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=n,e[22]=$):$=e[22],e[23]!==$?(s=(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:$}),e[23]=$,e[24]=s):s=e[24],e[25]!==c||e[26]!==m?(u=c!==null&&(0,a.jsx)(je,{error:m,testId:"set-error"}),e[25]=c,e[26]=m,e[27]=u):u=e[27],_=V.length>0&&(0,a.jsxs)(le,{className:"py-0","data-testid":"set-deploy",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Deployment")})}),(0,a.jsx)(oe,{className:"py-3",children:(0,a.jsx)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:V.map(Ge)})})]}),e[3]=c,e[4]=m,e[5]=x?.deploy,e[6]=x?.settings,e[7]=n,e[8]=o,e[9]=d,e[10]=l,e[11]=i,e[12]=s,e[13]=u,e[14]=_}else o=e[8],d=e[9],l=e[10],i=e[11],s=e[12],u=e[13],_=e[14];let k,D;e[28]===Symbol.for("react.memo_cache_sentinel")?(k=(0,a.jsx)(He,{}),D=(0,a.jsx)(qe,{}),e[28]=k,e[29]=D):(k=e[28],D=e[29]);let v;e[30]!==n?(v=n("Keyboard shortcuts"),e[30]=n,e[31]=v):v=e[31];let w;e[32]!==v?(w=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[32]=v,e[33]=w):w=e[33];let O;e[34]!==n?(O=n("Reset"),e[34]=n,e[35]=O):O=e[35];let j;e[36]!==O?(j=(0,a.jsx)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"set-shortcut-reset",onClick:Oe,type:"button",children:O}),e[36]=O,e[37]=j):j=e[37];let K;e[38]!==w||e[39]!==j?(K=(0,a.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[w,j]}),e[38]=w,e[39]=j,e[40]=K):K=e[40];let y;e[41]!==n?(y=n("Command palette"),e[41]=n,e[42]=y):y=e[42];let L;e[43]!==y?(L=(0,a.jsx)(Re,{label:y,modifier:"\u2318/Ctrl",name:"palette"}),e[43]=y,e[44]=L):L=e[44];let R;e[45]!==n?(R=n("Operation console"),e[45]=n,e[46]=R):R=e[46];let U;e[47]!==R?(U=(0,a.jsx)(Re,{label:R,modifier:"Ctrl",name:"console"}),e[47]=R,e[48]=U):U=e[48];let B;e[49]!==L||e[50]!==U?(B=(0,a.jsxs)("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[L,U]}),e[49]=L,e[50]=U,e[51]=B):B=e[51];let H;e[52]!==n?(H=n("Stored in this browser. Focus a box and press a key to rebind it."),e[52]=n,e[53]=H):H=e[53];let q;e[54]!==H?(q=(0,a.jsx)("p",{className:"pt-3 text-xs text-muted-foreground",children:H}),e[54]=H,e[55]=q):q=e[55];let G;e[56]!==B||e[57]!==q?(G=(0,a.jsxs)(oe,{className:"py-3",children:[B,q]}),e[56]=B,e[57]=q,e[58]=G):G=e[58];let J;e[59]!==K||e[60]!==G?(J=(0,a.jsxs)(le,{className:"py-0","data-testid":"set-preferences",children:[K,G]}),e[59]=K,e[60]=G,e[61]=J):J=e[61];let S;e[62]!==n?(S=n("Environment & bindings"),e[62]=n,e[63]=S):S=e[63];let T;e[64]!==S?(T=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:S})}),e[64]=S,e[65]=T):T=e[65];let F;e[66]!==c||e[67]!==p||e[68]!==o.length||e[69]!==n?(F=c===null&&!p&&o.length===0&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:n("No environment variables or bindings.")}),e[66]=c,e[67]=p,e[68]=o.length,e[69]=n,e[70]=F):F=e[70];let Q;e[71]!==o||e[72]!==n?(Q=o.length>0&&(0,a.jsx)(oe,{className:"px-0 py-0",children:(0,a.jsxs)(Se,{"data-testid":"set-table",children:[(0,a.jsx)(Te,{children:(0,a.jsxs)(ie,{children:[(0,a.jsx)(M,{children:n("name")}),(0,a.jsx)(M,{children:n("kind")}),(0,a.jsx)(M,{children:n("value")})]})}),(0,a.jsx)(Ce,{children:o.map(Je)})]})}),e[71]=o,e[72]=n,e[73]=Q):Q=e[73];let C;e[74]!==T||e[75]!==F||e[76]!==Q?(C=(0,a.jsxs)(le,{className:"py-0",children:[T,F,Q]}),e[74]=T,e[75]=F,e[76]=Q,e[77]=C):C=e[77];let z;return e[78]!==J||e[79]!==C||e[80]!==d||e[81]!==l||e[82]!==i||e[83]!==s||e[84]!==u||e[85]!==_?(z=(0,a.jsxs)("div",{className:d,"data-testid":l,children:[i,s,u,_,k,D,J,C]}),e[78]=J,e[79]=C,e[80]=d,e[81]=l,e[82]=i,e[83]=s,e[84]=u,e[85]=_,e[86]=z):z=e[86],z},"ft");function Ge(t){return(0,a.jsxs)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,a.jsx)("dt",{className:"text-muted-foreground",children:t.label}),(0,a.jsx)("dd",{className:"truncate font-mono text-xs",title:t.value,children:t.value})]},t.label)}b(Ge,"He");function Je(t){return(0,a.jsxs)(ie,{"data-testid":"set-row",children:[(0,a.jsx)(W,{className:"font-mono text-xs font-medium",children:t.name}),(0,a.jsx)(W,{children:(0,a.jsx)(_e,{variant:Fe[t.kind],children:t.bindingType??t.kind})}),(0,a.jsx)(W,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:t.value??(0,a.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},t.name)}b(Je,"We");export{ct as SettingsPanel};
1
+ import{b as Ke}from"./chunk-R6NJ4ER6.js";import{a as Ie,b as De,c as Oe}from"./chunk-AFLNQEZ5.js";import{a as Ee}from"./chunk-DWNWEMQK.js";import"./chunk-4KPATTV6.js";import{i as we}from"./chunk-OKZINWBB.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as ke}from"./chunk-NVMQPIRS.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{b as _e}from"./chunk-UV6GPH2E.js";import"./chunk-L27FKJTG.js";import{a as je}from"./chunk-D3MLU3PX.js";import"./chunk-S7NFUY75.js";import{a as Se,b as Te,c as Ce,d as ie,e as M,f as W}from"./chunk-J3ZEO3PJ.js";import"./chunk-YDDMKWPI.js";import"./chunk-5CHKXJYN.js";import"./chunk-EOFWXI3T.js";import{a as ve}from"./chunk-LYVYUTQY.js";import{c as ye}from"./chunk-UN3QTZ6X.js";import{a as le,e as oe}from"./chunk-TN4Z3P6S.js";import{n as Ae}from"./chunk-5KQSRLQP.js";import"./chunk-ZPQBVYNN.js";import{B as xe,j as pe,s as he,w as fe}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import{a as ze}from"./chunk-A6TVTNKO.js";import{a as Ue,b as Pe}from"./chunk-ADABTCDI.js";import{a as b,d as Ne}from"./chunk-5PEAXTYQ.js";var ce=Ne(ze(),1);var I=Ne(Ue(),1);var a=Ne(Pe(),1);var Le=["disabled","schema","schema_and_log","schema_and_log_and_data"],$e={describeTables:"schema",readAdvisors:"schema",readLogs:"schema_and_log",readPolicies:"schema",runSql:"schema_and_log_and_data"},Be=864e5,qe=b(()=>{let t=(0,ce.c)(67),e=Ae(),r=xe(),n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],t[0]=n):n=t[0];let g;t[1]!==e?(g={owner:e,tokens:n},t[1]=e,t[2]=g):g=t[2];let[h,N]=(0,I.useState)(g),x=h.owner===e?h.tokens:[],[c,m]=(0,I.useState)(null),[p,o]=(0,I.useState)(null);p!==null&&p.owner!==e&&o(null);let d=p?.owner===e?p.token:null,[l,i]=(0,I.useState)(""),[s,u]=(0,I.useState)(""),[_,k]=(0,I.useState)(null),D=_===e,v=(0,I.useRef)(0),w=(0,I.useRef)(e),O,j;t[3]!==e?(O=b(()=>{w.current=e},"D"),j=[e],t[3]=e,t[4]=O,t[5]=j):(O=t[4],j=t[5]),(0,I.useEffect)(O,j);let K;t[6]!==e?(K=b(async()=>{if(w.current!==e)return;v.current=v.current+1;let f=v.current;try{let E=await e.listAdminTokens();f===v.current&&(N({owner:e,tokens:E}),m(null))}catch(E){let de=E;f===v.current&&m(pe(de))}},"L"),t[6]=e,t[7]=K):K=t[7];let y=K,L,R;t[8]!==y?(L=b(()=>{he(y())},"O"),R=[y],t[8]=y,t[9]=L,t[10]=R):(L=t[9],R=t[10]),(0,I.useEffect)(L,R);let U;t[11]!==e||t[12]!==d||t[13]!==D||t[14]!==s||t[15]!==l||t[16]!==y?(U=b(f=>{if(f.preventDefault(),D||d!==null)return;k(e);let E=e,de=s===""?void 0:Date.now()+Number(s)*Be;he((async()=>{try{let se=await E.createAdminToken({expiresAt:de,name:l.trim()});w.current===E&&(o({owner:E,token:se}),i(""),u(""),await y())}catch(se){m(pe(se))}k(se=>se===E?null:se)})())},"K"),t[11]=e,t[12]=d,t[13]=D,t[14]=s,t[15]=l,t[16]=y,t[17]=U):U=t[17];let B=U,H=b(f=>{he((async()=>{try{await e.revokeAdminToken(f),o(E=>E?.token.name===f?null:E),await y()}catch(E){let de=E;await y(),w.current===e&&m(pe(de))}})())},"q"),q=le,G="py-0",J="set-admin-tokens",S;t[18]!==r?(S=r("Admin tokens"),t[18]=r,t[19]=S):S=t[19];let T;t[20]!==S?(T=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:S})}),t[20]=S,t[21]=T):T=t[21];let F=oe,Q="flex flex-col gap-3 py-3",C;t[22]!==r?(C=r("Named tokens use the admin API but cannot manage tokens or open admin WebSockets. A revoked token is refused within 30 seconds."),t[22]=r,t[23]=C):C=t[23];let z;t[24]!==C?(z=(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:C}),t[24]=C,t[25]=z):z=t[25];let V;t[26]!==c?(V=c!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"set-admin-tokens-error",role:"alert",children:c}),t[26]=c,t[27]=V):V=t[27];let P;t[28]!==d||t[29]!==r?(P=d!==null&&(0,a.jsxs)("div",{className:"rounded-md border border-border p-3 text-xs","data-testid":"set-admin-token-created",role:"status",children:[(0,a.jsx)("p",{className:"pb-1 text-muted-foreground",children:r("Copy this token now. It is not shown again.")}),(0,a.jsx)("code",{className:"font-mono break-all select-all",children:d.token}),(0,a.jsx)("div",{className:"pt-2",children:(0,a.jsx)(ke,{"data-testid":"set-admin-token-dismiss",onClick:b(()=>{o(null)},"onClick"),size:"xs",variant:"outline",children:r("Dismiss")})})]}),t[28]=d,t[29]=r,t[30]=P):P=t[30];let A;t[31]!==r?(A=r("Token name"),t[31]=r,t[32]=A):A=t[32];let $;t[33]===Symbol.for("react.memo_cache_sentinel")?($=b(f=>{i(f.target.value)},"B"),t[33]=$):$=t[33];let X;t[34]!==l||t[35]!==A?(X=(0,a.jsx)(we,{"aria-label":A,className:"w-48","data-testid":"set-admin-token-name",onChange:$,pattern:"[a-z0-9][a-z0-9_\\-]{0,63}",placeholder:"ci-deploy",required:!0,value:l}),t[34]=l,t[35]=A,t[36]=X):X=t[36];let Y;t[37]!==r?(Y=r("Expires in days (optional)"),t[37]=r,t[38]=Y):Y=t[38];let me;t[39]===Symbol.for("react.memo_cache_sentinel")?(me=b(f=>{u(f.target.value)},"de"),t[39]=me):me=t[39];let Z;t[40]!==r?(Z=r("Expires in days (optional)"),t[40]=r,t[41]=Z):Z=t[41];let ee;t[42]!==s||t[43]!==Y||t[44]!==Z?(ee=(0,a.jsx)(we,{"aria-label":Y,className:"w-40",min:1,onChange:me,placeholder:Z,type:"number",value:s}),t[42]=s,t[43]=Y,t[44]=Z,t[45]=ee):ee=t[45];let be=D||d!==null,te;t[46]!==r?(te=r("Create token"),t[46]=r,t[47]=te):te=t[47];let ae;t[48]!==be||t[49]!==te?(ae=(0,a.jsx)(ke,{"data-testid":"set-admin-token-create",disabled:be,size:"sm",type:"submit",children:te}),t[48]=be,t[49]=te,t[50]=ae):ae=t[50];let ne;t[51]!==B||t[52]!==X||t[53]!==ee||t[54]!==ae?(ne=(0,a.jsxs)("form",{className:"flex flex-wrap items-end gap-2",onSubmit:B,children:[X,ee,ae]}),t[51]=B,t[52]=X,t[53]=ee,t[54]=ae,t[55]=ne):ne=t[55];let ge=x.length>0&&(0,a.jsxs)(Se,{"data-testid":"set-admin-tokens-table",children:[(0,a.jsx)(Te,{children:(0,a.jsxs)(ie,{children:[(0,a.jsx)(M,{children:r("name")}),(0,a.jsx)(M,{children:r("Created")}),(0,a.jsx)(M,{children:r("Last used")}),(0,a.jsx)(M,{children:r("Expires")}),(0,a.jsx)(M,{})]})}),(0,a.jsx)(Ce,{children:x.map(f=>(0,a.jsxs)(ie,{"data-testid":"set-admin-token-row",children:[(0,a.jsxs)(W,{className:"font-mono text-xs",children:[f.name,f.revoked===!0&&(0,a.jsx)("span",{className:"pl-2 text-destructive",children:r("Revoked")})]}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.createdAt)}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.lastUsedAt,"\u2014")}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.expiresAt,r("Never"))}),(0,a.jsx)(W,{children:(0,a.jsx)(Ee,{onConfirm:b(()=>{H(f.name)},"onConfirm"),testId:`set-admin-token-revoke-${f.name}`,children:r("Revoke")})})]},f.name))})]}),re;t[56]!==F||t[57]!==z||t[58]!==V||t[59]!==P||t[60]!==ne||t[61]!==ge?(re=(0,a.jsxs)(F,{className:Q,children:[z,V,P,ne,ge]}),t[56]=F,t[57]=z,t[58]=V,t[59]=P,t[60]=ne,t[61]=ge,t[62]=re):re=t[62];let ue;return t[63]!==q||t[64]!==T||t[65]!==re?(ue=(0,a.jsxs)(q,{className:G,"data-testid":J,children:[T,re]}),t[63]=q,t[64]=T,t[65]=re,t[66]=ue):ue=t[66],ue},"Fe"),Fe={binding:"outline",secret:"destructive",var:"secondary"},Ve=b((t,e)=>{if(t===void 0)return[];let r=[];return t.workerUrl!==void 0&&r.push({label:e("URL"),value:t.workerUrl}),t.environment!==void 0&&r.push({label:e("Environment"),value:t.environment}),t.deploymentId!==void 0&&r.push({label:e("Deployment"),value:t.deploymentId}),t.versionTag!==void 0&&r.push({label:e("Version"),value:t.versionTag}),r},"Pe"),Me={disabled:"The assistant is off. Nothing about this deployment is sent to a model.",schema:"Table and column names.",schema_and_log:"Table and column names, plus recent log lines.",schema_and_log_and_data:"Table and column names, log lines, and rows read with SELECT."},We=b(t=>{let e=[];for(let[r,n]of Object.entries($e))n===t&&e.push(r);return e},"qe"),He=b(()=>{let t=(0,ce.c)(29),e=xe(),r,n;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},n={shardKey:""},t[0]=r,t[1]=n):(r=t[0],n=t[1]);let{data:g}=ye(ve.aiAvailable,r,n),h=g?.level,N;t[2]!==h?(N=h===void 0?-1:Le.indexOf(h),t[2]=h,t[3]=N):N=t[3];let x=N,c;t[4]!==e?(c=e("AI assistant data sharing"),t[4]=e,t[5]=c):c=t[5];let m;t[6]!==c?(m=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c}),t[6]=c,t[7]=m):m=t[7];let p;t[8]!==h?(p=h!==void 0&&(0,a.jsx)(_e,{"data-testid":"set-ai-level",variant:h==="disabled"?"outline":"secondary",children:h}),t[8]=h,t[9]=p):p=t[9];let o;t[10]!==m||t[11]!==p?(o=(0,a.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[m,p]}),t[10]=m,t[11]=p,t[12]=o):o=t[12];let d;t[13]!==x||t[14]!==h||t[15]!==e?(d=Le.map((k,D)=>{let v=x>=D,w=We(k);return(0,a.jsxs)("li",{className:v?"flex flex-col gap-0.5":"flex flex-col gap-0.5 opacity-50","data-granted":String(v),"data-testid":`set-ai-tier-${k}`,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"font-mono text-xs",children:k}),k===h&&(0,a.jsx)("span",{className:"text-[11px] text-primary",children:e("current")})]}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:e(Me[k])}),w.length>0&&(0,a.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:w.join(", ")})]},k)}),t[13]=x,t[14]=h,t[15]=e,t[16]=d):d=t[16];let l;t[17]!==d?(l=(0,a.jsx)("ul",{className:"flex flex-col gap-1.5 text-sm",children:d}),t[17]=d,t[18]=l):l=t[18];let i;t[19]!==e?(i=e("Set LUNORA_AI_OPT_IN in wrangler.jsonc and redeploy to change this. The Studio can read this level but never raise it."),t[19]=e,t[20]=i):i=t[20];let s;t[21]!==i?(s=(0,a.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"set-ai-howto",children:i}),t[21]=i,t[22]=s):s=t[22];let u;t[23]!==s||t[24]!==l?(u=(0,a.jsxs)(oe,{className:"flex flex-col gap-3 py-3",children:[l,s]}),t[23]=s,t[24]=l,t[25]=u):u=t[25];let _;return t[26]!==u||t[27]!==o?(_=(0,a.jsxs)(le,{className:"py-0","data-testid":"set-ai-sharing",children:[o,u]}),t[26]=u,t[27]=o,t[28]=_):_=t[28],_},"ze"),Re=b(t=>{let e=(0,ce.c)(18),{modifier:r,name:n,label:g}=t,h=Ie(),N;e[0]!==n?(N=b(u=>{if(!["Escape","Tab"].includes(u.key)){if(u.shiftKey){u.preventDefault();return}u.preventDefault(),De(n,u.key)}},"N"),e[0]=n,e[1]=N):N=e[1];let x=N,c=`set-shortcut-${n}`,m;e[2]!==g?(m=(0,a.jsx)("dt",{className:"text-muted-foreground",children:g}),e[2]=g,e[3]=m):m=e[3];let p;e[4]!==r?(p=(0,a.jsx)("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:r}),e[4]=r,e[5]=p):p=e[5];let o=`set-shortcut-input-${n}`,d=h[n],l;e[6]!==g||e[7]!==x||e[8]!==o||e[9]!==d?(l=(0,a.jsx)("input",{"aria-label":g,className:"h-7 w-12 rounded-md border border-border bg-background text-center font-mono text-xs uppercase outline-none focus-visible:border-ring","data-testid":o,onKeyDown:x,readOnly:!0,value:d}),e[6]=g,e[7]=x,e[8]=o,e[9]=d,e[10]=l):l=e[10];let i;e[11]!==p||e[12]!==l?(i=(0,a.jsxs)("dd",{className:"flex items-center gap-1.5",children:[p,l]}),e[11]=p,e[12]=l,e[13]=i):i=e[13];let s;return e[14]!==c||e[15]!==m||e[16]!==i?(s=(0,a.jsxs)("div",{className:"contents","data-testid":c,children:[m,i]}),e[14]=c,e[15]=m,e[16]=i,e[17]=s):s=e[17],s},"we"),ct=b(t=>{let e=(0,ce.c)(87),{initialShardKey:r}=t,n=xe(),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];let h=r??"",N;e[1]!==h?(N={shardKey:h},e[1]=h,e[2]=N):N=e[2];let{data:x,error:c,errorSource:m,isLoading:p}=ye(ve.getSettings,g,N),o,d,l,i,s,u,_;if(e[3]!==c||e[4]!==m||e[5]!==x?.deploy||e[6]!==x?.settings||e[7]!==n){let V=Ve(x?.deploy,n),P;e[15]!==x?.settings?(P=x?.settings??[],e[15]=x?.settings,e[16]=P):P=e[16],o=P,d="flex flex-col gap-4",l="lunora-settings";let A;e[17]!==n?(A=n("Open in Cloudflare"),e[17]=n,e[18]=A):A=e[18],e[19]!==A?(i=(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,a.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:Ke,rel:"noreferrer",target:"_blank",children:A})}),e[19]=A,e[20]=i):i=e[20];let $;e[21]!==n?($=n("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=n,e[22]=$):$=e[22],e[23]!==$?(s=(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:$}),e[23]=$,e[24]=s):s=e[24],e[25]!==c||e[26]!==m?(u=c!==null&&(0,a.jsx)(je,{error:m,testId:"set-error"}),e[25]=c,e[26]=m,e[27]=u):u=e[27],_=V.length>0&&(0,a.jsxs)(le,{className:"py-0","data-testid":"set-deploy",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Deployment")})}),(0,a.jsx)(oe,{className:"py-3",children:(0,a.jsx)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:V.map(Ge)})})]}),e[3]=c,e[4]=m,e[5]=x?.deploy,e[6]=x?.settings,e[7]=n,e[8]=o,e[9]=d,e[10]=l,e[11]=i,e[12]=s,e[13]=u,e[14]=_}else o=e[8],d=e[9],l=e[10],i=e[11],s=e[12],u=e[13],_=e[14];let k,D;e[28]===Symbol.for("react.memo_cache_sentinel")?(k=(0,a.jsx)(He,{}),D=(0,a.jsx)(qe,{}),e[28]=k,e[29]=D):(k=e[28],D=e[29]);let v;e[30]!==n?(v=n("Keyboard shortcuts"),e[30]=n,e[31]=v):v=e[31];let w;e[32]!==v?(w=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[32]=v,e[33]=w):w=e[33];let O;e[34]!==n?(O=n("Reset"),e[34]=n,e[35]=O):O=e[35];let j;e[36]!==O?(j=(0,a.jsx)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"set-shortcut-reset",onClick:Oe,type:"button",children:O}),e[36]=O,e[37]=j):j=e[37];let K;e[38]!==w||e[39]!==j?(K=(0,a.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[w,j]}),e[38]=w,e[39]=j,e[40]=K):K=e[40];let y;e[41]!==n?(y=n("Command palette"),e[41]=n,e[42]=y):y=e[42];let L;e[43]!==y?(L=(0,a.jsx)(Re,{label:y,modifier:"\u2318/Ctrl",name:"palette"}),e[43]=y,e[44]=L):L=e[44];let R;e[45]!==n?(R=n("Operation console"),e[45]=n,e[46]=R):R=e[46];let U;e[47]!==R?(U=(0,a.jsx)(Re,{label:R,modifier:"Ctrl",name:"console"}),e[47]=R,e[48]=U):U=e[48];let B;e[49]!==L||e[50]!==U?(B=(0,a.jsxs)("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[L,U]}),e[49]=L,e[50]=U,e[51]=B):B=e[51];let H;e[52]!==n?(H=n("Stored in this browser. Focus a box and press a key to rebind it."),e[52]=n,e[53]=H):H=e[53];let q;e[54]!==H?(q=(0,a.jsx)("p",{className:"pt-3 text-xs text-muted-foreground",children:H}),e[54]=H,e[55]=q):q=e[55];let G;e[56]!==B||e[57]!==q?(G=(0,a.jsxs)(oe,{className:"py-3",children:[B,q]}),e[56]=B,e[57]=q,e[58]=G):G=e[58];let J;e[59]!==K||e[60]!==G?(J=(0,a.jsxs)(le,{className:"py-0","data-testid":"set-preferences",children:[K,G]}),e[59]=K,e[60]=G,e[61]=J):J=e[61];let S;e[62]!==n?(S=n("Environment & bindings"),e[62]=n,e[63]=S):S=e[63];let T;e[64]!==S?(T=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:S})}),e[64]=S,e[65]=T):T=e[65];let F;e[66]!==c||e[67]!==p||e[68]!==o.length||e[69]!==n?(F=c===null&&!p&&o.length===0&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:n("No environment variables or bindings.")}),e[66]=c,e[67]=p,e[68]=o.length,e[69]=n,e[70]=F):F=e[70];let Q;e[71]!==o||e[72]!==n?(Q=o.length>0&&(0,a.jsx)(oe,{className:"px-0 py-0",children:(0,a.jsxs)(Se,{"data-testid":"set-table",children:[(0,a.jsx)(Te,{children:(0,a.jsxs)(ie,{children:[(0,a.jsx)(M,{children:n("name")}),(0,a.jsx)(M,{children:n("kind")}),(0,a.jsx)(M,{children:n("value")})]})}),(0,a.jsx)(Ce,{children:o.map(Je)})]})}),e[71]=o,e[72]=n,e[73]=Q):Q=e[73];let C;e[74]!==T||e[75]!==F||e[76]!==Q?(C=(0,a.jsxs)(le,{className:"py-0",children:[T,F,Q]}),e[74]=T,e[75]=F,e[76]=Q,e[77]=C):C=e[77];let z;return e[78]!==J||e[79]!==C||e[80]!==d||e[81]!==l||e[82]!==i||e[83]!==s||e[84]!==u||e[85]!==_?(z=(0,a.jsxs)("div",{className:d,"data-testid":l,children:[i,s,u,_,k,D,J,C]}),e[78]=J,e[79]=C,e[80]=d,e[81]=l,e[82]=i,e[83]=s,e[84]=u,e[85]=_,e[86]=z):z=e[86],z},"ft");function Ge(t){return(0,a.jsxs)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,a.jsx)("dt",{className:"text-muted-foreground",children:t.label}),(0,a.jsx)("dd",{className:"truncate font-mono text-xs",title:t.value,children:t.value})]},t.label)}b(Ge,"He");function Je(t){return(0,a.jsxs)(ie,{"data-testid":"set-row",children:[(0,a.jsx)(W,{className:"font-mono text-xs font-medium",children:t.name}),(0,a.jsx)(W,{children:(0,a.jsx)(_e,{variant:Fe[t.kind],children:t.bindingType??t.kind})}),(0,a.jsx)(W,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:t.value??(0,a.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},t.name)}b(Je,"We");export{ct as SettingsPanel};
@@ -1 +1 @@
1
- import{c as u}from"./chunk-SCTYLLJT.js";import{j as c}from"./chunk-L27FKJTG.js";import{a as l}from"./chunk-ZPQBVYNN.js";import{x as d}from"./chunk-ITS5LMYJ.js";import{a as h,b as z}from"./chunk-ADABTCDI.js";import{a as t,d as o}from"./chunk-5PEAXTYQ.js";var p=o(h(),1);var a=p.forwardRef(t(function(e,r){let{render:n,className:k,disabled:s=!1,focusableWhenDisabled:g=!1,nativeButton:f=!0,style:B,...b}=e,{getButtonProps:m,buttonRef:x}=u({disabled:s,focusableWhenDisabled:g,native:f});return c("button",e,{state:{disabled:s},ref:[r,x],props:[b,m]})},"Button"));var v=o(z(),1);var y=l("group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-xs font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2",xs:"h-6 gap-1 rounded-md px-2 text-xs has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-md px-2.5 has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2",icon:"size-8","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-md","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function W({className:i,variant:e="default",size:r="default",...n}){return(0,v.jsx)(a,{"data-slot":"button",className:d(y({variant:e,size:r,className:i})),...n})}t(W,"v");export{W as a};
1
+ import{c as u}from"./chunk-SCTYLLJT.js";import{j as c}from"./chunk-L27FKJTG.js";import{a as l}from"./chunk-ZPQBVYNN.js";import{x as d}from"./chunk-PN7JHEYW.js";import{a as h,b as z}from"./chunk-ADABTCDI.js";import{a as t,d as o}from"./chunk-5PEAXTYQ.js";var p=o(h(),1);var a=p.forwardRef(t(function(e,r){let{render:n,className:k,disabled:s=!1,focusableWhenDisabled:g=!1,nativeButton:f=!0,style:B,...b}=e,{getButtonProps:m,buttonRef:x}=u({disabled:s,focusableWhenDisabled:g,native:f});return c("button",e,{state:{disabled:s},ref:[r,x],props:[b,m]})},"Button"));var v=o(z(),1);var y=l("group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-xs font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2",xs:"h-6 gap-1 rounded-md px-2 text-xs has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-md px-2.5 has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2",icon:"size-8","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-md","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function W({className:i,variant:e="default",size:r="default",...n}){return(0,v.jsx)(a,{"data-slot":"button",className:d(y({variant:e,size:r,className:i})),...n})}t(W,"v");export{W as a};
@@ -1 +1 @@
1
- import{a as ee}from"./chunk-2KTN53PK.js";import{a as Z}from"./chunk-EI2FSTI3.js";import{b as Y}from"./chunk-EDL46BPM.js";import{a as X}from"./chunk-DA2CAFXI.js";import{a as W}from"./chunk-2AKEF2E6.js";import"./chunk-4KPATTV6.js";import{i as D}from"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import"./chunk-GTW3JPQQ.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{b as ae,c as ne}from"./chunk-7VZFX5O4.js";import{a as q,b as te}from"./chunk-4NRWZ3IK.js";import{a as V}from"./chunk-EG45XFL3.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import"./chunk-L27FKJTG.js";import"./chunk-VX6ZBLXB.js";import"./chunk-CHYLD556.js";import"./chunk-7MM2SI65.js";import"./chunk-3SRQFKDT.js";import"./chunk-RY6I3E2K.js";import"./chunk-EOFWXI3T.js";import{a as I}from"./chunk-LYVYUTQY.js";import{c as A}from"./chunk-3CUQWI5A.js";import"./chunk-QQENKHRS.js";import{n as Q}from"./chunk-F4ZN2DRL.js";import"./chunk-ZPQBVYNN.js";import{B as _,h as M,i as C,o as G,s as N}from"./chunk-ITS5LMYJ.js";import"./chunk-PDBW6GTJ.js";import{a as me}from"./chunk-A6TVTNKO.js";import{a as he,b as pe}from"./chunk-ADABTCDI.js";import{a as l,d as j}from"./chunk-5PEAXTYQ.js";var E=j(me(),1);var c=j(he(),1);var S=j(pe(),1);var ge=l(t=>{let{suggestedIndex:e,table:r}=t;if(typeof r!="string"||r.length===0||typeof e!="object"||e===null)return!1;let{fields:a,name:n}=e;return!Array.isArray(a)||a.length===0||a.some(i=>typeof i!="string"||i.length===0)?!1:typeof n=="string"&&n.length>0},"xe"),be=l((t,e)=>`.index(${JSON.stringify(t)}, [${e.map(r=>JSON.stringify(r)).join(", ")}])`,"ge"),xe=l(t=>{let e=(0,E.c)(19),{fields:r,indexName:a,table:n,testId:i}=t,u=_(),[h,f]=(0,c.useState)(null),m;e[0]!==r||e[1]!==a?(m=l(()=>{let b=be(a,r),$="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if($===void 0){f({copied:!1,declaration:b});return}N($.writeText(b).then(()=>(f({copied:!0,declaration:b}),!0)),()=>{f({copied:!1,declaration:b})})},"m"),e[0]=r,e[1]=a,e[2]=m):m=e[2];let y=m;if(h!==null){let b;return e[3]!==h.copied||e[4]!==h.declaration||e[5]!==u||e[6]!==n||e[7]!==i?(b=h.copied?(0,S.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`${i}-applied`,children:u("Index declaration copied \u2014 add it to {table} in lunora/schema.ts.",{table:n})}):(0,S.jsxs)("span",{className:"flex flex-col gap-1 text-xs text-muted-foreground","data-testid":`${i}-manual`,children:[u("Could not reach the clipboard \u2014 add this to {table} in lunora/schema.ts:",{table:n}),(0,S.jsx)("code",{className:"font-mono break-all select-all",children:h.declaration})]}),e[3]=h.copied,e[4]=h.declaration,e[5]=u,e[6]=n,e[7]=i,e[8]=b):b=e[8],b}let T;e[9]!==u?(T=u("Copy?"),e[9]=u,e[10]=T):T=e[10];let p;e[11]!==u||e[12]!==n?(p=u("Copy index declaration for {table}",{table:n}),e[11]=u,e[12]=n,e[13]=p):p=e[13];let w;return e[14]!==y||e[15]!==T||e[16]!==p||e[17]!==i?(w=(0,S.jsx)(W,{confirmLabel:T,onConfirm:y,testId:i,children:p}),e[14]=y,e[15]=T,e[16]=p,e[17]=i,e[18]=w):w=e[18],w},"ve"),ye=l((t,e)=>{let r=new Map;for(let a of e){let n=`${a.table} ${a.index}`;r.set(n,(r.get(n)??0)+a.reads)}return t.map(a=>({index:a.index,reads:r.get(`${a.table} ${a.index}`)??0,table:a.table}))},"Se"),ve=l(t=>{let e=new Map;for(let r of t)for(let a of r.scannedTables??[])e.set(a.table,(e.get(a.table)??0)+a.scans);return[...e].map(([r,a])=>({scans:a,table:r}))},"Te"),re=l((t,e)=>e.map(r=>({index:r.name,table:t})),"P"),we=l(t=>{let e=ye(t.declaredIndexes??[],t.indexHits??[]),r=ve(t.functions??[]),a=t.shardTraffic??[],n=t.analyticsMetrics,i=n&&n.indexHits.length>0?n.indexHits:e,u=n&&n.tableScans.length>0?n.tableScans:r,h=n&&n.shardTraffic.length>0?n.shardTraffic:a,f=ne({indexHits:i,schema:{tables:[]},shardTraffic:h,tableScans:u},{lints:ae,source:"runtime"}),m=t.suppressHotScanTables;return(m===void 0?f:f.filter(y=>!(y.metadata.kind==="hot_scan"&&typeof y.metadata.table=="string"&&m.has(y.metadata.table)))).map(y=>q(y))},"we"),Se=M(I.listTables),Te=M(I.listTableIndexes),Ie=M(I.listTablesIndexes),B=l(t=>`${(t*100).toFixed(1)}%`,"H"),se=l(t=>`${(t/1e3).toFixed(2)}s`,"V"),$e=l(t=>{if(t.length<=1)return t[0]??"";let e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},"Ne"),ke=l((t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function"),"storage-headroom":t("Storage headroom")})[e.kind],"ke"),ie=l((t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:B(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict \u2014 consider sharding to cut contention.",{rate:B(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:B(e.value)}),"missing-index":t("Slowest call took {duration} \u2014 it full-scanned {tables} with no index.",{duration:se(e.value),tables:$e(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:se(e.value)}),"storage-headroom":t("{size} of the 10 GiB per-shard ceiling \u2014 plan a .shardBy() migration while it still has runway.",{size:G(e.value)})})[e.kind],"U"),Ne=l(t=>{let e=(0,E.c)(10),{onJump:r,table:a}=t,n=_(),i;e[0]!==r||e[1]!==a?(i=l(()=>{r(a)},"o"),e[0]=r,e[1]=a,e[2]=i):i=e[2];let u=i,h=`in-add-index-${a}`,f;e[3]!==n||e[4]!==a?(f=n("Add index on {table}",{table:a}),e[3]=n,e[4]=a,e[5]=f):f=e[5];let m;return e[6]!==u||e[7]!==h||e[8]!==f?(m=(0,S.jsx)(V,{"data-testid":h,onClick:u,size:"sm",type:"button",variant:"outline",children:f}),e[6]=u,e[7]=h,e[8]=f,e[9]=m):m=e[9],m},"Be"),ze=l(({initialShardKey:t,loadShardTraffic:e})=>{let r=Q(),a=D(),n=_(),{queryShardKey:i,setShardKey:u,shardKey:h}=ee(t),[f,m]=(0,c.useState)(null),[y,T]=(0,c.useState)(null),p=(0,c.useRef)(""),w=A(I.getMetrics,{},{live:!0,shardKey:i}),b=A(I.getFunctionStats,{},{live:!0,shardKey:i}),$=A(I.getAdvisories,{},{live:!0,shardKey:i}),L=w.data??null,K=b.data?.functions??null,F=$.data?.advisories??null,J=w.data?.indexHits??null,O=w.error!==null&&b.error!==null?w.error:null,oe=e??(s=>r.shardTraffic(s)),le=l(async(s,x)=>{let o=s[0];if(o===void 0||o===""){p.current===x&&T(null);return}try{let g=await oe(o);if(p.current!==x)return;let d=new Map;for(let v of g.shards)d.has(v.shardKey)||d.set(v.shardKey,{requests:v.requests,shardKey:v.shardKey});T([...d.values()])}catch{p.current===x&&T(null)}},"Y"),de=l(async(s,x)=>{let o=await Promise.allSettled(s.map(async d=>[d,await r.query(Te,{table:d},C(x))])),g=[];for(let d of o)if(d.status==="fulfilled"){let[v,k]=d.value;g.push(...re(v,k.indexes))}return g},"Z"),z=(0,c.useEffectEvent)(async s=>{p.current=s;let x=[];try{let o=await r.query(Se,{},C(s));if(p.current!==s)return;Y(s),x=o.map(d=>d.name);let g=[];if(x.length>0)try{let d=await r.query(Ie,{tables:x},C(s));if(p.current!==s)return;for(let[v,k]of Object.entries(d.indexesByTable))g.push(...re(v,k))}catch{if(g=await de(x,s),p.current!==s)return}m(g)}catch{p.current===s&&m(null)}await le(x,s)});(0,c.useEffect)(()=>{N(z(i))},[i]);let ce=(0,c.useEffectEvent)(()=>{w.refetch(),b.refetch(),$.refetch(),N(z(i))});(0,c.useEffect)(()=>{let s=l(()=>{document.visibilityState==="visible"&&ce()},"r");return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s)}},[]);let U=(0,c.useCallback)(s=>{N(a({search:{table:s},to:"/schema"}))},[a]),H=(0,c.useMemo)(()=>X(L,K),[K,L]),P=(0,c.useMemo)(()=>new Set(H.filter(s=>s.kind==="missing-index").flatMap(s=>s.tables??[])),[H]),R=(0,c.useMemo)(()=>we({declaredIndexes:f??[],functions:K,indexHits:J,shardTraffic:y,suppressHotScanTables:P}),[f,K,J,P,y]),ue=(0,c.useMemo)(()=>{let s=H.map(o=>{let g=o.kind==="missing-index"?o.tables??[]:[];return{action:g.length>0?g.map(d=>(0,S.jsx)(Ne,{onJump:U,table:d},d)):void 0,description:o.message===void 0?ie(n,o):`${ie(n,o)} \u2014 ${o.message}`,entity:o.fn,issueType:ke(n,o),key:`${o.kind}:${o.fn??""}`,level:o.severity}}),x=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(F??[]).map(o=>{let g=q(o);if(x.has(o.name)&&ge(o.metadata)){let{table:d,suggestedIndex:v}=o.metadata,k=`in-apply-index-${d}-${v.name}`;return{...g,action:(0,S.jsx)(xe,{fields:v.fields,indexName:v.name,table:d,testId:k})}}return g}),...R,...s]},[F,H,U,R,n]),fe=(0,S.jsx)(Z,{onChange:u,testId:"in-shard-input",value:h});return(0,S.jsx)(te,{error:O,errorSource:O===null?void 0:w.errorSource,rows:ue,shardKey:i,testId:"lunora-insights",toolbar:fe})},"Ue");export{ze as InsightsPanel};
1
+ import{a as ee}from"./chunk-2KTN53PK.js";import{a as Z}from"./chunk-PAFHBQFL.js";import{b as Y}from"./chunk-EDL46BPM.js";import{a as X}from"./chunk-DA2CAFXI.js";import{a as W}from"./chunk-DWNWEMQK.js";import"./chunk-4KPATTV6.js";import{i as D}from"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import"./chunk-OKZINWBB.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{b as ae,c as ne}from"./chunk-7VZFX5O4.js";import{a as q,b as te}from"./chunk-LFVPR2JB.js";import{a as V}from"./chunk-NVMQPIRS.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import"./chunk-L27FKJTG.js";import"./chunk-D3MLU3PX.js";import"./chunk-S7NFUY75.js";import"./chunk-J3ZEO3PJ.js";import"./chunk-YDDMKWPI.js";import"./chunk-5CHKXJYN.js";import"./chunk-EOFWXI3T.js";import{a as I}from"./chunk-LYVYUTQY.js";import{c as A}from"./chunk-UN3QTZ6X.js";import"./chunk-TN4Z3P6S.js";import{n as Q}from"./chunk-5KQSRLQP.js";import"./chunk-ZPQBVYNN.js";import{B as _,h as M,i as C,o as G,s as N}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import{a as me}from"./chunk-A6TVTNKO.js";import{a as he,b as pe}from"./chunk-ADABTCDI.js";import{a as l,d as j}from"./chunk-5PEAXTYQ.js";var E=j(me(),1);var c=j(he(),1);var S=j(pe(),1);var ge=l(t=>{let{suggestedIndex:e,table:r}=t;if(typeof r!="string"||r.length===0||typeof e!="object"||e===null)return!1;let{fields:a,name:n}=e;return!Array.isArray(a)||a.length===0||a.some(i=>typeof i!="string"||i.length===0)?!1:typeof n=="string"&&n.length>0},"xe"),be=l((t,e)=>`.index(${JSON.stringify(t)}, [${e.map(r=>JSON.stringify(r)).join(", ")}])`,"ge"),xe=l(t=>{let e=(0,E.c)(19),{fields:r,indexName:a,table:n,testId:i}=t,u=_(),[h,f]=(0,c.useState)(null),m;e[0]!==r||e[1]!==a?(m=l(()=>{let b=be(a,r),$="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if($===void 0){f({copied:!1,declaration:b});return}N($.writeText(b).then(()=>(f({copied:!0,declaration:b}),!0)),()=>{f({copied:!1,declaration:b})})},"m"),e[0]=r,e[1]=a,e[2]=m):m=e[2];let y=m;if(h!==null){let b;return e[3]!==h.copied||e[4]!==h.declaration||e[5]!==u||e[6]!==n||e[7]!==i?(b=h.copied?(0,S.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`${i}-applied`,children:u("Index declaration copied \u2014 add it to {table} in lunora/schema.ts.",{table:n})}):(0,S.jsxs)("span",{className:"flex flex-col gap-1 text-xs text-muted-foreground","data-testid":`${i}-manual`,children:[u("Could not reach the clipboard \u2014 add this to {table} in lunora/schema.ts:",{table:n}),(0,S.jsx)("code",{className:"font-mono break-all select-all",children:h.declaration})]}),e[3]=h.copied,e[4]=h.declaration,e[5]=u,e[6]=n,e[7]=i,e[8]=b):b=e[8],b}let T;e[9]!==u?(T=u("Copy?"),e[9]=u,e[10]=T):T=e[10];let p;e[11]!==u||e[12]!==n?(p=u("Copy index declaration for {table}",{table:n}),e[11]=u,e[12]=n,e[13]=p):p=e[13];let w;return e[14]!==y||e[15]!==T||e[16]!==p||e[17]!==i?(w=(0,S.jsx)(W,{confirmLabel:T,onConfirm:y,testId:i,children:p}),e[14]=y,e[15]=T,e[16]=p,e[17]=i,e[18]=w):w=e[18],w},"ve"),ye=l((t,e)=>{let r=new Map;for(let a of e){let n=`${a.table} ${a.index}`;r.set(n,(r.get(n)??0)+a.reads)}return t.map(a=>({index:a.index,reads:r.get(`${a.table} ${a.index}`)??0,table:a.table}))},"Se"),ve=l(t=>{let e=new Map;for(let r of t)for(let a of r.scannedTables??[])e.set(a.table,(e.get(a.table)??0)+a.scans);return[...e].map(([r,a])=>({scans:a,table:r}))},"Te"),re=l((t,e)=>e.map(r=>({index:r.name,table:t})),"P"),we=l(t=>{let e=ye(t.declaredIndexes??[],t.indexHits??[]),r=ve(t.functions??[]),a=t.shardTraffic??[],n=t.analyticsMetrics,i=n&&n.indexHits.length>0?n.indexHits:e,u=n&&n.tableScans.length>0?n.tableScans:r,h=n&&n.shardTraffic.length>0?n.shardTraffic:a,f=ne({indexHits:i,schema:{tables:[]},shardTraffic:h,tableScans:u},{lints:ae,source:"runtime"}),m=t.suppressHotScanTables;return(m===void 0?f:f.filter(y=>!(y.metadata.kind==="hot_scan"&&typeof y.metadata.table=="string"&&m.has(y.metadata.table)))).map(y=>q(y))},"we"),Se=M(I.listTables),Te=M(I.listTableIndexes),Ie=M(I.listTablesIndexes),B=l(t=>`${(t*100).toFixed(1)}%`,"H"),se=l(t=>`${(t/1e3).toFixed(2)}s`,"V"),$e=l(t=>{if(t.length<=1)return t[0]??"";let e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},"Ne"),ke=l((t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function"),"storage-headroom":t("Storage headroom")})[e.kind],"ke"),ie=l((t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:B(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict \u2014 consider sharding to cut contention.",{rate:B(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:B(e.value)}),"missing-index":t("Slowest call took {duration} \u2014 it full-scanned {tables} with no index.",{duration:se(e.value),tables:$e(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:se(e.value)}),"storage-headroom":t("{size} of the 10 GiB per-shard ceiling \u2014 plan a .shardBy() migration while it still has runway.",{size:G(e.value)})})[e.kind],"U"),Ne=l(t=>{let e=(0,E.c)(10),{onJump:r,table:a}=t,n=_(),i;e[0]!==r||e[1]!==a?(i=l(()=>{r(a)},"o"),e[0]=r,e[1]=a,e[2]=i):i=e[2];let u=i,h=`in-add-index-${a}`,f;e[3]!==n||e[4]!==a?(f=n("Add index on {table}",{table:a}),e[3]=n,e[4]=a,e[5]=f):f=e[5];let m;return e[6]!==u||e[7]!==h||e[8]!==f?(m=(0,S.jsx)(V,{"data-testid":h,onClick:u,size:"sm",type:"button",variant:"outline",children:f}),e[6]=u,e[7]=h,e[8]=f,e[9]=m):m=e[9],m},"Be"),ze=l(({initialShardKey:t,loadShardTraffic:e})=>{let r=Q(),a=D(),n=_(),{queryShardKey:i,setShardKey:u,shardKey:h}=ee(t),[f,m]=(0,c.useState)(null),[y,T]=(0,c.useState)(null),p=(0,c.useRef)(""),w=A(I.getMetrics,{},{live:!0,shardKey:i}),b=A(I.getFunctionStats,{},{live:!0,shardKey:i}),$=A(I.getAdvisories,{},{live:!0,shardKey:i}),L=w.data??null,K=b.data?.functions??null,F=$.data?.advisories??null,J=w.data?.indexHits??null,O=w.error!==null&&b.error!==null?w.error:null,oe=e??(s=>r.shardTraffic(s)),le=l(async(s,x)=>{let o=s[0];if(o===void 0||o===""){p.current===x&&T(null);return}try{let g=await oe(o);if(p.current!==x)return;let d=new Map;for(let v of g.shards)d.has(v.shardKey)||d.set(v.shardKey,{requests:v.requests,shardKey:v.shardKey});T([...d.values()])}catch{p.current===x&&T(null)}},"Y"),de=l(async(s,x)=>{let o=await Promise.allSettled(s.map(async d=>[d,await r.query(Te,{table:d},C(x))])),g=[];for(let d of o)if(d.status==="fulfilled"){let[v,k]=d.value;g.push(...re(v,k.indexes))}return g},"Z"),z=(0,c.useEffectEvent)(async s=>{p.current=s;let x=[];try{let o=await r.query(Se,{},C(s));if(p.current!==s)return;Y(s),x=o.map(d=>d.name);let g=[];if(x.length>0)try{let d=await r.query(Ie,{tables:x},C(s));if(p.current!==s)return;for(let[v,k]of Object.entries(d.indexesByTable))g.push(...re(v,k))}catch{if(g=await de(x,s),p.current!==s)return}m(g)}catch{p.current===s&&m(null)}await le(x,s)});(0,c.useEffect)(()=>{N(z(i))},[i]);let ce=(0,c.useEffectEvent)(()=>{w.refetch(),b.refetch(),$.refetch(),N(z(i))});(0,c.useEffect)(()=>{let s=l(()=>{document.visibilityState==="visible"&&ce()},"r");return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s)}},[]);let U=(0,c.useCallback)(s=>{N(a({search:{table:s},to:"/schema"}))},[a]),H=(0,c.useMemo)(()=>X(L,K),[K,L]),P=(0,c.useMemo)(()=>new Set(H.filter(s=>s.kind==="missing-index").flatMap(s=>s.tables??[])),[H]),R=(0,c.useMemo)(()=>we({declaredIndexes:f??[],functions:K,indexHits:J,shardTraffic:y,suppressHotScanTables:P}),[f,K,J,P,y]),ue=(0,c.useMemo)(()=>{let s=H.map(o=>{let g=o.kind==="missing-index"?o.tables??[]:[];return{action:g.length>0?g.map(d=>(0,S.jsx)(Ne,{onJump:U,table:d},d)):void 0,description:o.message===void 0?ie(n,o):`${ie(n,o)} \u2014 ${o.message}`,entity:o.fn,issueType:ke(n,o),key:`${o.kind}:${o.fn??""}`,level:o.severity}}),x=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(F??[]).map(o=>{let g=q(o);if(x.has(o.name)&&ge(o.metadata)){let{table:d,suggestedIndex:v}=o.metadata,k=`in-apply-index-${d}-${v.name}`;return{...g,action:(0,S.jsx)(xe,{fields:v.fields,indexName:v.name,table:d,testId:k})}}return g}),...R,...s]},[F,H,U,R,n]),fe=(0,S.jsx)(Z,{onChange:u,testId:"in-shard-input",value:h});return(0,S.jsx)(te,{error:O,errorSource:O===null?void 0:w.errorSource,rows:ue,shardKey:i,testId:"lunora-insights",toolbar:fe})},"Ue");export{ze as InsightsPanel};