harper 5.3.3 → 5.3.4

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 (59) hide show
  1. package/dist/resources/DatabaseTransaction.d.ts +5 -1
  2. package/dist/resources/DatabaseTransaction.js +21 -5
  3. package/dist/resources/DatabaseTransaction.js.map +1 -1
  4. package/dist/resources/LMDBTransaction.d.ts +1 -1
  5. package/dist/resources/LMDBTransaction.js +4 -3
  6. package/dist/resources/LMDBTransaction.js.map +1 -1
  7. package/dist/resources/Table.js +85 -36
  8. package/dist/resources/Table.js.map +1 -1
  9. package/dist/server/DurableSubscriptionsSession.js +4 -7
  10. package/dist/server/DurableSubscriptionsSession.js.map +1 -1
  11. package/dist/server/mqtt.js +21 -9
  12. package/dist/server/mqtt.js.map +1 -1
  13. package/dist/server/serverHelpers/contentTypes.js +8 -2
  14. package/dist/server/serverHelpers/contentTypes.js.map +1 -1
  15. package/dist/server/serverHelpers/sharedMessageEncoding.js +3 -2
  16. package/dist/server/serverHelpers/sharedMessageEncoding.js.map +1 -1
  17. package/package.json +1 -1
  18. package/resources/DESIGN.md +6 -2
  19. package/resources/DatabaseTransaction.ts +25 -5
  20. package/resources/LMDBTransaction.ts +4 -3
  21. package/resources/Table.ts +99 -42
  22. package/server/DESIGN.md +7 -1
  23. package/server/DurableSubscriptionsSession.ts +4 -7
  24. package/server/mqtt.ts +18 -10
  25. package/server/serverHelpers/contentTypes.ts +8 -1
  26. package/server/serverHelpers/sharedMessageEncoding.ts +3 -2
  27. package/studio/web/assets/{Chat-B-Rd-ft9.js → Chat-DjZNWwwA.js} +1 -1
  28. package/studio/web/assets/{FloatingChat-CFypO7kh.js → FloatingChat-BWfKK_RX.js} +3 -3
  29. package/studio/web/assets/{SearchDialog-BRIyPiBl.js → SearchDialog-CdlNxWef.js} +1 -1
  30. package/studio/web/assets/{apiToken-BraYnzvC.js → apiToken-DyI8IwU3.js} +1 -1
  31. package/studio/web/assets/{applications-XCds8-ZP.js → applications-DgGopKJq.js} +1 -1
  32. package/studio/web/assets/{cssMode-BY1w91l8.js → cssMode-4ddO86ey.js} +1 -1
  33. package/studio/web/assets/{editor-D5mpVs1b.js → editor-DATuu7_v.js} +1 -1
  34. package/studio/web/assets/{html-DiXKiahz.js → html-c4OKnEF1.js} +1 -1
  35. package/studio/web/assets/{htmlMode-DitVJ707.js → htmlMode-yXjqUsW9.js} +1 -1
  36. package/studio/web/assets/{index-D8kyF6dt.js → index-CIK9Nhgo.js} +5 -5
  37. package/studio/web/assets/{index.lazy-DgbjUxLo.js → index.lazy-DQpKL_QQ.js} +1 -1
  38. package/studio/web/assets/{javascript-BBVXeMDm.js → javascript-CP1WPkLu.js} +1 -1
  39. package/studio/web/assets/{jsonMode-D85_j2oD.js → jsonMode-BWsIHqbb.js} +1 -1
  40. package/studio/web/assets/{languageServices-U3mWhpRL.js → languageServices-Ca72n4Ql.js} +1 -1
  41. package/studio/web/assets/{lspLanguageFeatures-CoymyM3c.js → lspLanguageFeatures-BQdsSDeh.js} +1 -1
  42. package/studio/web/assets/{notifications-CPgEC6ZP.js → notifications-BYgO5-yk.js} +1 -1
  43. package/studio/web/assets/{notifications-D_VqhHnx.js → notifications-DsGk-TnW.js} +1 -1
  44. package/studio/web/assets/{operations-D8aaKYty.js → operations-Dy69AlTr.js} +1 -1
  45. package/studio/web/assets/{profile-DM5E6Xls.js → profile-DzQvoYBF.js} +1 -1
  46. package/studio/web/assets/{regions-WFvXqryO.js → regions-Sv_IN7XA.js} +1 -1
  47. package/studio/web/assets/{register-B7DvfAGj.js → register-AM2_79FO.js} +2 -2
  48. package/studio/web/assets/{request-ChoMERRk.js → request-BJj8dbdU.js} +1 -1
  49. package/studio/web/assets/{setComponentFile-BHk22Rh6.js → setComponentFile-BCnAnxjR.js} +1 -1
  50. package/studio/web/assets/{setup-wNdpTrVH.js → setup-Ca4RpPzm.js} +2 -2
  51. package/studio/web/assets/{status-CYoonm9V.js → status-D05eZ5pQ.js} +1 -1
  52. package/studio/web/assets/{toggleHighContrast-CKEm-P4K.js → toggleHighContrast-JRkLfyfb.js} +1 -1
  53. package/studio/web/assets/{tsMode-Dv35qHmn.js → tsMode-C_-eSRVR.js} +1 -1
  54. package/studio/web/assets/{typescript-Bly1EW8o.js → typescript-BYXigM_n.js} +1 -1
  55. package/studio/web/assets/{useEntityRestURL-Cg3P0MOb.js → useEntityRestURL-HHmjsRm9.js} +1 -1
  56. package/studio/web/assets/{workers-DVtjrvUa.js → workers-DY0ka4Y7.js} +1 -1
  57. package/studio/web/assets/{xml-DjAPbgLN.js → xml-CdGINpmN.js} +1 -1
  58. package/studio/web/assets/{yaml-oTUyoJy1.js → yaml-DYeF07_w.js} +1 -1
  59. package/studio/web/index.html +1 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SearchDialog-BRIyPiBl.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/vendor-datadog-GjET_Cbn.js","assets/vendor-react-DSIx92Ld.js","assets/vendor-tanstack-C5Y-nrd2.js","assets/notifications-CPgEC6ZP.js","assets/cn-DpF1PxBT.js","assets/vendor-core-PejxhUWQ.js","assets/button-C37w80Uk.js","assets/vendor-ui-BBWHOEoQ.js","assets/regions-WFvXqryO.js","assets/chevron-up-DozwrIz-.js","assets/createLucideIcon-DLWRoWN-.js","assets/apiToken-BraYnzvC.js","assets/setup-wNdpTrVH.js","assets/dist-9lpzt2Hn.js","assets/register-B7DvfAGj.js","assets/register-DjpsE8to.css","assets/editor-D5mpVs1b.js","assets/toggleHighContrast-CKEm-P4K.js","assets/toggleHighContrast-n7clI0si.css","assets/index.lazy-DgbjUxLo.js","assets/authStore-DE1HFvVP.js","assets/restartGate-D_e93lFE.js","assets/setSessionStorage-B0bf71m4.js","assets/safeParse-DeaoCCWH.js","assets/localStorageKeys-etzFY_xV.js","assets/wasAReleasedBeforeB-D5grAaGM.js","assets/useEntityRestURL-Cg3P0MOb.js","assets/request-ChoMERRk.js","assets/applications-XCds8-ZP.js","assets/setComponentFile-BHk22Rh6.js","assets/errorText-8xV8WZBt.js","assets/restartUnconfirmed-BqcDZ__Y.js","assets/invalidateEntityQueries-BkWXiqjz.js","assets/languageServices-U3mWhpRL.js","assets/applications-DNZhsH95.css","assets/FloatingChat-CFypO7kh.js","assets/operations-D8aaKYty.js","assets/status-CYoonm9V.js","assets/linear-Ds1AeO4V.js","assets/step-vX8bovaY.js","assets/defaultLocale-BFoDCU3G.js","assets/init-ZlXS9mIS.js","assets/ordinal-CPleeUAT.js","assets/time-Ci1v4fvT.js","assets/band-DZ4Jagyz.js","assets/getAnalytics-B1xpd4kG.js","assets/notifications-D_VqhHnx.js","assets/profile-DM5E6Xls.js"])))=>i.map(i=>d[i]);
2
- import{i as e,t}from"./rolldown-runtime-Dd_uD5pT.js";import{_ as n,a as r,b as i,d as a,g as o,h as s,i as c,m as l,n as u,o as d,p as f,r as p,t as m,v as h,x as g,y as _}from"./authStore-DE1HFvVP.js";import{D as v,E as y,_ as b,b as x,d as S,g as C,i as w,j as T,k as E,o as D,p as O,r as k,s as A,t as j,u as M,v as ee,x as te,y as N}from"./vendor-core-PejxhUWQ.js";import{n as P,t as F}from"./cn-DpF1PxBT.js";import{a as ne,c as re,d as ie,f as ae,h as oe,i as se,l as ce,o as le,r as ue,s as de,u as fe}from"./restartGate-D_e93lFE.js";import{a as pe,n as me,o as he,t as ge}from"./vendor-datadog-GjET_Cbn.js";import{r as _e,t as ve}from"./vendor-react-DSIx92Ld.js";import{A as ye,B as be,C as xe,D as Se,F as Ce,G as we,H as I,J as Te,K as L,L as Ee,M as De,N as Oe,O as R,P as z,Q as ke,S as Ae,T as je,U as Me,V as Ne,W as B,X as Pe,Y as Fe,Z as Ie,_ as Le,a as Re,b as ze,c as Be,d as Ve,et as He,f as Ue,g as We,h as Ge,i as Ke,j as qe,k as V,l as Je,m as Ye,n as Xe,nt as Ze,o as Qe,p as $e,q as et,r as tt,s as nt,t as rt,tt as it,u as at,v as ot,w as st,x as ct,y as lt,z as ut}from"./vendor-tanstack-C5Y-nrd2.js";import{n as dt,t as ft}from"./setSessionStorage-B0bf71m4.js";import{n as pt,t as H}from"./button-C37w80Uk.js";import{$ as mt,A as ht,At as gt,B as _t,Bt as vt,C as yt,Ct as bt,D as xt,Dt as St,E as Ct,Et as wt,F as Tt,Ft as Et,G as Dt,H as Ot,I as kt,It as At,J as jt,K as Mt,L as Nt,Lt as Pt,M as Ft,Mt as It,N as Lt,Nt as Rt,O as zt,Ot as Bt,P as Vt,Pt as Ht,Q as Ut,R as Wt,Rt as Gt,S as Kt,St as qt,T as Jt,Tt as Yt,U as Xt,V as Zt,W as Qt,X as $t,Y as en,Z as tn,_ as nn,_t as rn,a as an,at as on,b as sn,bt as cn,c as ln,ct as un,d as dn,dt as fn,et as pn,f as mn,ft as hn,g as gn,gt as _n,h as vn,ht as yn,i as bn,it as xn,j as Sn,jt as Cn,k as wn,kt as Tn,l as En,lt as Dn,m as On,mt as kn,n as An,nt as jn,o as Mn,ot as Nn,p as Pn,pt as Fn,q as In,r as Ln,rt as Rn,s as zn,st as Bn,t as Vn,tt as Hn,u as Un,ut as Wn,v as Gn,vt as Kn,w as qn,wt as Jn,x as Yn,xt as Xn,y as Zn,yt as Qn,z as $n,zt as U}from"./vendor-ui-BBWHOEoQ.js";import{t as W}from"./createLucideIcon-DLWRoWN-.js";import{n as er,r as tr,t as nr}from"./chevron-up-DozwrIz-.js";import{a as rr,c as ir,i as ar,l as or,n as sr,o as cr,r as lr,s as ur,t as dr}from"./restartUnconfirmed-BqcDZ__Y.js";import{n as fr,t as pr}from"./errorText-8xV8WZBt.js";import{t as mr}from"./invalidateEntityQueries-BkWXiqjz.js";import{n as hr,r as gr,t as _r}from"./localStorageKeys-etzFY_xV.js";import{n as vr,t as yr}from"./wasAReleasedBeforeB-D5grAaGM.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var G=e(he(),1);function br(){let[e,t]=(0,G.useState)(()=>({...u.getAllConnections()}));return(0,G.useEffect)(()=>u.listenToAllEntities((e,n)=>{t(t=>({...t,[n]:e}))}),[]),e}function xr(){let e=u.calculateIdFromEntity(m),[t,n]=(0,G.useState)(u.getConnectionById(m));return(0,G.useEffect)(()=>u.listenToEntity(e,n),[e]),t}function Sr(){return xr()}function Cr(e,t){return!e||!(`fabricRole`in e)?!1:e.staffPermissions?e.staffPermissions.includes(t):e.fabricRole===`fabric_admin`||e.fabricRole===`super_user`}function wr(e){let{user:t}=Sr();return Cr(t,e)}function Tr(e){let{clusterId:t,instanceId:n}=z({strict:!1}),r=m,[i,a]=(0,G.useState)(()=>({key:r,connection:u.getConnectionById(r)}));return(0,G.useEffect)(()=>u.listenToEntity(r,e=>a({key:r,connection:e})),[r]),i.key===r?i.connection:u.getConnectionById(r)}var K=_e();function Er({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`card`,className:F(`bg-card text-card-foreground flex flex-col gap-4 rounded-2xl py-5 shadow-deep ring-1 ring-black/5 dark:ring-white/5`,e),...t})}function Dr({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`card-header`,className:F(`flex flex-col gap-1.5 px-6`,e),...t})}function Or({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`card-title`,className:F(`leading-none text-lg`,e),...t})}function kr({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`card-description`,className:F(`text-muted-foreground text-xs`,e),...t})}function Ar({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`card-content`,className:F(`px-6`,e),...t})}function jr(e){try{return e?.response?.status??e?.status}catch{return}}function Mr(e){return e!==null&&!!e.username}function Nr(e){if(!e||Mr(e))return[];let t=Cr(e,`org:read`);return Object.entries(e.roles??{}).map(([e,n])=>({id:e,name:n.organizationName||e,roleName:n.role??`fabric staff`,locked:`oauthProviders`in n&&!t,providers:n.oauthProviders??[]})).sort((e,t)=>e.name.localeCompare(t.name)||e.id.localeCompare(t.id))}function Pr(e){let t=Nr(e);return t.length===1&&!t[0].locked?`/${t[0].id}`:`/`}var Fr={name:`activity`,size:24,node:[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]};Fr.node;var Ir=W(Fr),Lr={name:`arrow-down-to-line`,size:24,node:[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]};Lr.node;var Rr=W(Lr),zr={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};zr.node;var Br=W(zr),Vr={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};Vr.node;var Hr=W(Vr),Ur={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};Ur.node;var Wr=W(Ur),Gr={name:`arrow-up-down`,size:24,node:[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]};Gr.node;var Kr=W(Gr),qr={name:`arrow-up-from-line`,size:24,node:[[`path`,{d:`m18 9-6-6-6 6`,key:`kcunyi`}],[`path`,{d:`M12 3v14`,key:`7cf3v8`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]};qr.node;var Jr=W(qr),Yr={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};Yr.node;var Xr=W(Yr),Zr={name:`badge-check`,size:24,node:[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`verified`]};Zr.node;var Qr=W(Zr),$r={name:`ban`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]};$r.node;var ei=W($r),ti={name:`bell`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]};ti.node;var ni=W(ti),ri={name:`book-open-text`,size:24,node:[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M16 13h2`,key:`weia3s`}],[`path`,{d:`M16 9h2`,key:`1n7gjm`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}],[`path`,{d:`M6 13h2`,key:`1cckiz`}],[`path`,{d:`M6 9h2`,key:`1k7j9f`}]]};ri.node;var ii=W(ri),ai={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};ai.node;var oi=W(ai),si={name:`brush-cleaning`,size:24,node:[[`path`,{d:`m16 22-1-4`,key:`1ow2iv`}],[`path`,{d:`M19 14a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2h-3a1 1 0 0 1-1-1V4a2 2 0 0 0-4 0v5a1 1 0 0 1-1 1H6a2 2 0 0 0-2 2v1a1 1 0 0 0 1 1`,key:`11gii7`}],[`path`,{d:`M19 14H5l-1.973 6.767A1 1 0 0 0 4 22h16a1 1 0 0 0 .973-1.233z`,key:`bju7h4`}],[`path`,{d:`m8 22 1-4`,key:`s3unb`}]]};si.node;var ci=W(si),li={name:`bug`,size:24,node:[[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`,key:`uouzyp`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M21 21a4 4 0 0 0-3.81-4`,key:`1b0z45`}],[`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`,key:`5cxbf6`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M3 21a4 4 0 0 1 3.81-4`,key:`1fjd4g`}],[`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`,key:`1d7oge`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`,key:`1vgav8`}]]};li.node;var ui=W(li),di={name:`building-complex`,size:24,node:[[`path`,{d:`M10 12h4`,key:`a56b0p`}],[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M14 21v-3a2 2 0 0 0-4 0v3`,key:`1rgiei`}],[`path`,{d:`M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2`,key:`secmi2`}],[`path`,{d:`M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16`,key:`16ra0t`}]],aliases:[`building-2`]};di.node;var fi=W(di),pi={name:`calendar-clock`,size:24,node:[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338`,key:`7hb8p4`}],[`path`,{d:`M3 9h5.859`,key:`numkqi`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]};pi.node;var mi=W(pi),hi={name:`chart-column-increasing`,size:24,node:[[`path`,{d:`M13 17V9`,key:`1fwyjl`}],[`path`,{d:`M18 17V5`,key:`sfb6ij`}],[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]],aliases:[`bar-chart-4`]};hi.node;var gi=W(hi),_i={name:`chart-pie`,size:24,node:[[`path`,{d:`M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z`,key:`pzmjnu`}],[`path`,{d:`M21.21 15.89A10 10 0 1 1 8 2.83`,key:`k2fpak`}]],aliases:[`pie-chart`]};_i.node;var vi=W(_i),yi={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};yi.node;var bi=W(yi),xi={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};xi.node;var Si=W(xi),Ci={name:`circle-alert`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]],aliases:[`alert-circle`]};Ci.node;var wi=W(Ci),Ti={name:`circle-check-big`,size:24,node:[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]],aliases:[`check-circle`]};Ti.node;var Ei=W(Ti),Di={name:`circle-check`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`check-circle-2`]};Di.node;var Oi=W(Di),ki={name:`circle-dashed`,size:24,node:[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]};ki.node;var Ai=W(ki),ji={name:`circle-minus`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]],aliases:[`minus-circle`]};ji.node;var Mi=W(ji),Ni={name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`help-circle`,`circle-help`]};Ni.node;var Pi=W(Ni),Fi={name:`circle`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};Fi.node;var Ii=W(Fi),Li={name:`clipboard-check`,size:24,node:[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`m9 14 2 2 4-4`,key:`df797q`}]]};Li.node;var Ri=W(Li),zi={name:`clipboard`,size:24,node:[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}]]};zi.node;var Bi=W(zi),Vi={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};Vi.node;var Hi=W(Vi),Ui={name:`cloud-alert`,size:24,node:[[`path`,{d:`M12 12v4`,key:`tww15h`}],[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.128 16.949A7 7 0 1 1 15.71 8h1.79a1 1 0 0 1 0 9h-1.642`,key:`1namsd`}]]};Ui.node;var Wi=W(Ui),Gi={name:`cloud-download`,size:24,node:[[`path`,{d:`M12 13v8l-4-4`,key:`1f5nwf`}],[`path`,{d:`m12 21 4-4`,key:`1lfcce`}],[`path`,{d:`M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284`,key:`ui1hmy`}]],aliases:[`download-cloud`]};Gi.node;var Ki=W(Gi),qi={name:`cloud-upload`,size:24,node:[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]],aliases:[`upload-cloud`]};qi.node;var Ji=W(qi),Yi={name:`code`,size:24,node:[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]};Yi.node;var Xi=W(Yi),Zi={name:`columns-3-cog`,size:24,node:[[`path`,{d:`M10.6 21H5a2 2 0 01-2-2V5a2 2 0 012-2h14a2 2 0 012 2v5.6`,key:`19s2bv`}],[`path`,{d:`m14.305 19.53.923-.382`,key:`3m78fa`}],[`path`,{d:`M15 3v7.6`,key:`mv9izd`}],[`path`,{d:`m15.229 16.852-.924-.383`,key:`qpfz85`}],[`path`,{d:`m16.852 15.228-.383-.923`,key:`5xggr7`}],[`path`,{d:`m16.852 20.772-.383.924`,key:`dpfhf9`}],[`path`,{d:`m19.148 15.228.383-.923`,key:`1reyyz`}],[`path`,{d:`m19.53 21.696-.382-.924`,key:`1goivc`}],[`path`,{d:`m20.773 16.852.922-.383`,key:`59dfo2`}],[`path`,{d:`m20.773 19.148.922.383`,key:`1lk755`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}]],aliases:[`columns-settings`,`table-config`]};Zi.node;var Qi=W(Zi),$i={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};$i.node;var ea=W($i),ta={name:`credit-card`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}],[`path`,{d:`M6 14h2`,key:`mk7k0u`}]]};ta.node;var na=W(ta),ra={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};ra.node;var ia=W(ra),aa={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]};aa.node;var oa=W(aa),sa={name:`earth`,size:24,node:[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]],aliases:[`globe-2`]};sa.node;var ca=W(sa),la={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};la.node;var ua=W(la),da={name:`external-link`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]};da.node;var fa=W(da),pa={name:`eye-off`,size:24,node:[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};pa.node;var ma=W(pa),ha={name:`eye`,size:24,node:[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};ha.node;var ga=W(ha),_a={name:`file-up`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]};_a.node;var va=W(_a),ya={name:`funnel-plus`,size:24,node:[[`path`,{d:`M13.354 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14v6a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341l1.218-1.348`,key:`8mvsmf`}],[`path`,{d:`M16 6h6`,key:`1dogtp`}],[`path`,{d:`M19 3v6`,key:`1ytpjt`}]]};ya.node;var ba=W(ya),xa={name:`funnel-x`,size:24,node:[[`path`,{d:`M12.531 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14v6a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341l.427-.473`,key:`ol2ft2`}],[`path`,{d:`m16.5 3.5 5 5`,key:`15e6fa`}],[`path`,{d:`m21.5 3.5-5 5`,key:`m0lwru`}]],aliases:[`filter-x`]};xa.node;var Sa=W(xa),Ca={name:`funnel`,size:24,node:[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]],aliases:[`filter`]};Ca.node;var wa=W(Ca),Ta={name:`gauge`,size:24,node:[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]};Ta.node;var Ea=W(Ta),Da={name:`git-graph`,size:24,node:[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M5 9v6`,key:`158jrl`}],[`circle`,{cx:`5`,cy:`18`,r:`3`,key:`104gr9`}],[`path`,{d:`M12 3v18`,key:`108xh3`}],[`circle`,{cx:`19`,cy:`6`,r:`3`,key:`108a5v`}],[`path`,{d:`M16 15.7A9 9 0 0 0 19 9`,key:`1e3vqb`}]]};Da.node;var Oa=W(Da),ka={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};ka.node;var Aa=W(ka),ja={name:`grip-horizontal`,size:24,node:[[`circle`,{cx:`12`,cy:`9`,r:`1`,key:`124mty`}],[`circle`,{cx:`19`,cy:`9`,r:`1`,key:`1ruzo2`}],[`circle`,{cx:`5`,cy:`9`,r:`1`,key:`1a8b28`}],[`circle`,{cx:`12`,cy:`15`,r:`1`,key:`1e56xg`}],[`circle`,{cx:`19`,cy:`15`,r:`1`,key:`1a92ep`}],[`circle`,{cx:`5`,cy:`15`,r:`1`,key:`5r1jwy`}]]};ja.node;var Ma=W(ja),Na={name:`grip-vertical`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]};Na.node;var Pa=W(Na),Fa={name:`handshake`,size:24,node:[[`path`,{d:`m11 17 2 2a1 1 0 1 0 3-3`,key:`efffak`}],[`path`,{d:`m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4`,key:`9pr0kb`}],[`path`,{d:`m21 3 1 11h-2`,key:`1tisrp`}],[`path`,{d:`M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3`,key:`1uvwmv`}],[`path`,{d:`M3 4h8`,key:`1ep09j`}]]};Fa.node;var Ia=W(Fa),La={name:`house`,size:24,node:[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]],aliases:[`home`]};La.node;var Ra=W(La),za={name:`info`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]};za.node;var Ba=W(za),Va={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};Va.node;var Ha=W(Va),Ua={name:`key`,size:24,node:[[`path`,{d:`m2 21 9.6-9.6`,key:`9l79m3`}],[`path`,{d:`m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19`,key:`fw8biw`}],[`circle`,{cx:`15.5`,cy:`7.5`,r:`5.5`,key:`4wxmhb`}]]};Ua.node;var Wa=W(Ua),Ga={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};Ga.node;var Ka=W(Ga),qa={name:`layout-dashboard`,size:24,node:[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]};qa.node;var Ja=W(qa),Ya={name:`life-buoy`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m4.93 4.93 4.24 4.24`,key:`1ymg45`}],[`path`,{d:`m14.83 9.17 4.24-4.24`,key:`1cb5xl`}],[`path`,{d:`m14.83 14.83 4.24 4.24`,key:`q42g0n`}],[`path`,{d:`m9.17 14.83-4.24 4.24`,key:`bqpfvv`}],[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}]]};Ya.node;var Xa=W(Ya),Za={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};Za.node;var Qa=W(Za),$a={name:`list-todo`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]};$a.node;var eo=W($a),to={name:`loader-circle`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]],aliases:[`loader-2`]};to.node;var no=W(to),ro={name:`lock-keyhole`,size:24,node:[[`circle`,{cx:`12`,cy:`16`,r:`1`,key:`1au0dj`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`,key:`6s8ecr`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`,key:`1pqi11`}]]};ro.node;var io=W(ro),ao={name:`lock`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]};ao.node;var oo=W(ao),so={name:`log-in`,size:24,node:[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]};so.node;var co=W(so),lo={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};lo.node;var uo=W(lo),fo={name:`mail-check`,size:24,node:[[`path`,{d:`M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8`,key:`12jkf8`}],[`path`,{d:`m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`,key:`1ocrg3`}],[`path`,{d:`m16 19 2 2 4-4`,key:`1b14m6`}]]};fo.node;var po=W(fo),mo={name:`mail-warning`,size:24,node:[[`path`,{d:`M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5`,key:`e61zoh`}],[`path`,{d:`m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`,key:`1ocrg3`}],[`path`,{d:`M20 14v4`,key:`1hm744`}],[`path`,{d:`M20 22v.01`,key:`12bgn6`}]]};mo.node;var ho=W(mo),go={name:`mail`,size:24,node:[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]};go.node;var _o=W(go),vo={name:`map-pin`,size:24,node:[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]};vo.node;var yo=W(vo),bo={name:`maximize`,size:24,node:[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]};bo.node;var xo=W(bo),So={name:`menu`,size:24,node:[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]};So.node;var Co=W(So),wo={name:`minimize`,size:24,node:[[`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3`,key:`hohbtr`}],[`path`,{d:`M21 8h-3a2 2 0 0 1-2-2V3`,key:`5jw1f3`}],[`path`,{d:`M3 16h3a2 2 0 0 1 2 2v3`,key:`198tvr`}],[`path`,{d:`M16 21v-3a2 2 0 0 1 2-2h3`,key:`ph8mxp`}]]};wo.node;var To=W(wo),Eo={name:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};Eo.node;var Do=W(Eo),Oo={name:`moon`,size:24,node:[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]};Oo.node;var ko=W(Oo),Ao={name:`notepad-text`,size:24,node:[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`16`,height:`18`,x:`4`,y:`4`,rx:`2`,key:`1u9h20`}],[`path`,{d:`M8 10h6`,key:`3oa6kw`}],[`path`,{d:`M8 14h8`,key:`1fgep2`}],[`path`,{d:`M8 18h5`,key:`17enja`}]]};Ao.node;var jo=W(Ao),Mo={name:`octagon-alert`,size:24,node:[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]],aliases:[`alert-octagon`]};Mo.node;var No=W(Mo),Po={name:`package`,size:24,node:[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]};Po.node;var Fo=W(Po),Io={name:`palette`,size:24,node:[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]};Io.node;var Lo=W(Io),Ro={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};Ro.node;var zo=W(Ro),Bo={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};Bo.node;var Vo=W(Bo),Ho={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};Ho.node;var Uo=W(Ho),Wo={name:`refresh-cw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]};Wo.node;var Go=W(Wo),Ko={name:`rocket`,size:24,node:[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]};Ko.node;var qo=W(Ko),Jo={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};Jo.node;var Yo=W(Jo),Xo={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};Xo.node;var Zo=W(Xo),Qo={name:`save`,size:24,node:[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]};Qo.node;var $o=W(Qo),es={name:`scale`,size:24,node:[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`m19 8 3 8a5 5 0 0 1-6 0zV7`,key:`zcdpyk`}],[`path`,{d:`M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1`,key:`1yorad`}],[`path`,{d:`m5 8 3 8a5 5 0 0 1-6 0zV7`,key:`eua70x`}],[`path`,{d:`M7 21h10`,key:`1b0cd5`}]]};es.node;var ts=W(es),ns={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};ns.node;var rs=W(ns),is={name:`server-off`,size:24,node:[[`path`,{d:`M7 2h13a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-5`,key:`bt2siv`}],[`path`,{d:`M10 10 2.5 2.5C2 2 2 2.5 2 5v3a2 2 0 0 0 2 2h6z`,key:`1hjrv1`}],[`path`,{d:`M22 17v-1a2 2 0 0 0-2-2h-1`,key:`1iynyr`}],[`path`,{d:`M4 14a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16.5l1-.5.5.5-8-8H4z`,key:`161ggg`}],[`path`,{d:`M6 18h.01`,key:`uhywen`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};is.node;var as=W(is),os={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};os.node;var ss=W(os),cs={name:`settings`,size:24,node:[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};cs.node;var ls=W(cs),us={name:`shield-check`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]};us.node;var ds=W(us),fs={name:`shield-x`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m14.5 9.5-5 5`,key:`17q4r4`}],[`path`,{d:`m9.5 9.5 5 5`,key:`18nt4w`}]],aliases:[`shield-close`]};fs.node;var ps=W(fs),ms={name:`shield`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]};ms.node,W(ms);var hs={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};hs.node;var gs=W(hs),_s={name:`square-pen`,size:24,node:[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]],aliases:[`pen-box`,`edit`,`pen-square`]};_s.node;var vs=W(_s),ys={name:`square-terminal`,size:24,node:[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]],aliases:[`terminal-square`]};ys.node;var bs=W(ys),xs={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};xs.node;var Ss=W(xs),Cs={name:`sun`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]};Cs.node;var ws=W(Cs),Ts={name:`table-2`,size:24,node:[[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]};Ts.node;var Es=W(Ts),Ds={name:`table`,size:24,node:[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}]]};Ds.node;var Os=W(Ds),ks={name:`tag`,size:24,node:[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]};ks.node;var As=W(ks),js={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};js.node;var Ms=W(js),Ns={name:`ticket`,size:24,node:[[`path`,{d:`M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z`,key:`qn84l0`}],[`path`,{d:`M13 5v2`,key:`dyzc3o`}],[`path`,{d:`M13 17v2`,key:`1ont0d`}],[`path`,{d:`M13 11v2`,key:`1wjjxi`}]]};Ns.node;var Ps=W(Ns),Fs={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};Fs.node;var Is=W(Fs),Ls={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};Ls.node;var Rs=W(Ls),zs={name:`user-minus`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]};zs.node;var Bs=W(zs),Vs={name:`user-round`,size:24,node:[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]],aliases:[`user-2`]};Vs.node;var Hs=W(Vs),Us={name:`users`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]};Us.node;var Ws=W(Us),Gs={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};Gs.node;var Ks=W(Gs),qs={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]};qs.node;var Js=W(qs),Ys=`An unexpected error occurred.`,Xs=`Something Went Wrong`,Zs={title:`Access Denied`,description:`Your account doesn't have permission to view this. If you think it should, ask an administrator for access.`},Qs={title:`Not Found`,description:`We couldn't find what you were looking for. It may have been deleted, or the link may be wrong.`},$s={title:`Couldn't Reach the Server`,description:`The request didn't get an answer. Check your connection, then try again.`,retryable:!0},ec=new Set([E.ERR_NETWORK,E.ECONNABORTED,E.ETIMEDOUT]);function tc(e){try{return e?.code}catch{return}}function nc(e){let t=jr(e);return t===403?Zs:t===404?Qs:typeof t==`number`?t>=500&&t<600?{title:Xs,description:`The server couldn't load this (error ${t}). Try again in a moment.`,retryable:!0}:void 0:ec.has(tc(e))?$s:void 0}function rc(){let e=Ee(),[t,n]=(0,G.useState)(!1);return(0,K.jsxs)(H,{type:`button`,variant:`outline`,disabled:t,onClick:()=>{n(!0),e.invalidate().finally(()=>n(!1))},children:[(0,K.jsx)(Zo,{className:t?`animate-spin`:void 0}),` `,t?`Trying Again…`:`Try Again`]})}function ic(e){return typeof e==`string`?e.length>0:typeof e==`number`||(0,G.isValidElement)(e)?!0:Array.isArray(e)?e.length>0&&e.every(ic):!1}function ac(e){try{if(e instanceof Error)return e.message.length>0?e.message:Ys;if(typeof e==`object`&&e&&`message`in e){let t=e.message;return ic(t)?t:Ys}if(ic(e))return e}catch{return Ys}return Ys}function oc({className:e,error:t,title:n,description:r,showReturnToHome:i,reset:a,children:o}){let{user:s,isLoading:c}=xr();Pr(s);let l=nc(t),u=a!==void 0&&l?.retryable===!0;return(0,K.jsxs)(Er,{"data-testid":`error-component`,className:F(`text-red p-5 border border-red rounded-md m-12 mt-36`,e),children:[(0,K.jsxs)(Dr,{children:[(0,K.jsx)(Or,{className:`text-2xl`,children:(0,K.jsx)(`h2`,{children:n??l?.title??Xs})}),(0,K.jsx)(kr,{children:r??l?.description??ac(t)})]}),(0,K.jsxs)(Ar,{children:[o,(u||i!==!1)&&(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[u&&(0,K.jsx)(rc,{}),i!==!1&&(s&&!c?(0,K.jsx)(V,{to:`/`,children:(0,K.jsxs)(H,{children:[` `,(0,K.jsx)(Hr,{}),` Return to Home`]})}):(0,K.jsx)(V,{to:`/sign-in`,children:(0,K.jsxs)(H,{children:[` `,(0,K.jsx)(Hr,{}),` Go to Sign In Page`]})}))]})]})]})}function sc(){let{user:e,isLoading:t}=xr();return Pr(e),(0,K.jsx)(`div`,{className:`flex items-center justify-center h-screen px-3`,children:(0,K.jsxs)(Er,{className:`text-red p-5 border border-red rounded-md w-full max-w-md`,children:[(0,K.jsx)(Dr,{children:(0,K.jsx)(Or,{className:`text-2xl`,children:(0,K.jsx)(`h2`,{children:`Sorry, Page Not Found`})})}),(0,K.jsx)(Ar,{children:e&&!t?(0,K.jsx)(V,{to:`/`,children:(0,K.jsxs)(H,{children:[` `,(0,K.jsx)(Hr,{}),` Return to Home`]})}):(0,K.jsx)(V,{to:`/sign-in`,children:(0,K.jsxs)(H,{children:[` `,(0,K.jsx)(Hr,{}),` Go Sign In Page`]})})})]})})}function cc(){return`ontouchstart`in window||navigator.maxTouchPoints>0}var lc=new WeakMap;function uc(e,t){if(t.aborted)return()=>void 0;lc.set(e,(lc.get(e)??0)+1);let n=!1,r=()=>{if(n)return;n=!0,t.removeEventListener(`abort`,r);let i=(lc.get(e)??1)-1;i>0?lc.set(e,i):lc.delete(e)};return t.addEventListener(`abort`,r),r}function dc(e){return lc.has(e)}function fc(e){if(or(e))return{title:cr,description:ur,message:ur};if(e instanceof lr)return{title:sr,description:dr,message:dr};let t=`Error`,n=`We had some trouble!`,r=!0,i=e,a=e;if(typeof e==`string`)n=e;else if(i?.response?.data){let e=i.response.data;if(typeof e==`string`)n=e;else if(typeof e.title==`string`&&e.title){typeof e.code==`string`&&e.code&&(t=e.code);let i=pr(e.detail);n=i?`${e.title}: ${i}`:e.title,r=!1}else n=pr(e.error)??pr(e.message)??n}else n=pr(a?.message)??n;let o=n;if(r&&n.includes(`:`)&&!n.startsWith(`{`)&&!n.startsWith(`[`)){let e=n.split(`:`);t=e.shift(),n=e.join(`:`)}return{title:t,description:n,message:o}}function pc(e){return!or(e)&&!(e instanceof lr)}function mc(e){console.error(e);let{title:t,description:n}=fc(e),r=e,i=r?.code===`ECONNABORTED`||r?.code===`ETIMEDOUT`,a=r?.response?.status===403,o=or(e)?void 0:i?`request-timeout`:a?`request-forbidden`:void 0;U.error(t,{id:o,description:n,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}var hc=new Te({queryCache:new Fe({onError:(e,t)=>{if(ue(e,t.queryKey)){console.debug(`Suppressed a failure from a restarting entity`,e);return}if(!dc(t)){if(t.meta?.inlineSearchError&&t.getObserversCount()===0){console.error(e);return}mc(e)}}}),mutationCache:new Pe({onError:(e,t,n,r)=>{r.meta?.skipGlobalErrorToast||mc(e)}})});fe(e=>void mr(hc,e,void 0,{cancelRefetch:!1}));function gc({...e}){return(0,K.jsx)(Jn,{"data-slot":`dropdown-menu`,...e})}function _c({...e}){return(0,K.jsx)(Pt,{"data-slot":`dropdown-menu-trigger`,...e})}function vc({className:e,sideOffset:t=4,...n}){return(0,K.jsx)(gt,{children:(0,K.jsx)(wt,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:F(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border p-1 shadow-md`,e),...n})})}function yc({className:e,inset:t,variant:n=`default`,...r}){return(0,K.jsx)(St,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:F(`focus:bg-accent focus:text-grey`,`data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10`,`dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive`,`data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground`,`relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm`,`outline-hidden select-none`,`data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r})}function bc({className:e,children:t,checked:n,...r}){return(0,K.jsxs)(Yt,{"data-slot":`dropdown-menu-checkbox-item`,className:F(`focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm`,`py-1.5 pr-2 pl-8`,`text-sm outline-hidden`,`select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),checked:n,...r,children:[(0,K.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,K.jsx)(Bt,{children:(0,K.jsx)(tr,{className:`size-4`})})}),t]})}function xc({...e}){return(0,K.jsx)(Cn,{"data-slot":`dropdown-menu-radio-group`,...e})}function Sc({className:e,children:t,...n}){return(0,K.jsxs)(It,{"data-slot":`dropdown-menu-radio-item`,className:F(`focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[(0,K.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,K.jsx)(Bt,{children:(0,K.jsx)(Ii,{className:`size-2 fill-current`})})}),t]})}function Cc({className:e,inset:t,...n}){return(0,K.jsx)(Tn,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:F(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function wc({className:e,...t}){return(0,K.jsx)(Rt,{"data-slot":`dropdown-menu-separator`,className:F(`bg-border -mx-1 my-1 h-px`,e),...t})}function Tc({className:e,...t}){return(0,K.jsx)(`span`,{"data-slot":`dropdown-menu-shortcut`,className:F(`text-muted-foreground ml-auto text-xs tracking-widest`,e),...t})}function Ec({...e}){return(0,K.jsx)(Ht,{"data-slot":`dropdown-menu-sub`,...e})}function Dc({className:e,inset:t,children:n,...r}){return(0,K.jsxs)(At,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:F(`focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground`,`flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none`,`data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0`,`[&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,K.jsx)(Si,{className:`ml-auto size-4`})]})}function Oc({className:e,...t}){return(0,K.jsx)(Et,{"data-slot":`dropdown-menu-sub-content`,className:F(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg`,e),...t})}var kc=`flex items-center gap-3 p-2 rounded-lg text-sm transition-colors`,Ac=`block p-2 rounded-lg text-sm transition-colors`,jc={className:`text-foreground hover:bg-accent dark:text-white dark:hover:bg-grey-700`},Mc={className:`font-medium text-primary bg-primary/10 dark:text-white dark:bg-white/10`};function Nc({items:e,ariaLabel:t}){let{pathname:n}=ze(),r=e=>e.exact?n===e.to:n.startsWith(e.to),i=e.find(r)??e[0],a=i.icon;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`nav`,{className:`studio-section-rail hidden md:flex flex-col gap-1`,"aria-label":t,children:e.map(e=>{let t=e.icon;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(V,{to:e.to,className:kc,activeOptions:{exact:!!e.exact},activeProps:Mc,inactiveProps:jc,children:[(0,K.jsx)(t,{className:`size-4 shrink-0`}),e.label]}),e.children&&r(e)&&(0,K.jsx)(`div`,{className:`mt-1 ml-4 flex flex-col gap-1 border-l border-border pl-3`,children:e.children.map(e=>(0,K.jsx)(V,{to:e.to,className:Ac,activeOptions:{exact:!!e.exact},activeProps:Mc,inactiveProps:jc,children:e.label},e.to))})]},e.to)})}),(0,K.jsx)(`div`,{className:`md:hidden`,children:(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsxs)(H,{variant:`outline`,className:`w-full justify-between`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(a,{className:`size-4`}),i.label]}),(0,K.jsx)(er,{className:`size-4`})]})}),(0,K.jsx)(vc,{align:`start`,className:`w-(--radix-dropdown-menu-trigger-width)`,children:e.map(e=>{let t=e.icon;return[(0,K.jsx)(yc,{asChild:!0,children:(0,K.jsxs)(V,{to:e.to,className:`flex items-center gap-2`,children:[(0,K.jsx)(t,{className:`size-4`}),e.label]})},e.to),...e.children&&r(e)?e.children.map(e=>(0,K.jsx)(yc,{asChild:!0,children:(0,K.jsx)(V,{to:e.to,className:`flex items-center gap-2 pl-8`,children:e.label})},e.to)):[]]})})]})})]})}var Pc=[{to:`/admin/notifications`,label:`Notifications`,icon:ni,permission:`systemStatus:write`},{to:`/admin/regions`,label:`Regions`,icon:Aa,permission:`region:read`},{to:`/admin/api-token`,label:`API Token`,icon:Ha,permission:`apiToken:create`,ssoAccountOnly:!0}];function Fc(e){let t=e!==null&&`fabricRole`in e&&e.fabricRole===`super_user`;return Pc.filter(n=>Cr(e,n.permission)&&!(n.ssoAccountOnly&&t))}function Ic(){let{isLoading:e,user:t}=Sr(),{pathname:n}=ze();if(e)return null;let r=Fc(t);if(!r.length)return(0,K.jsx)(qe,{to:`/`,replace:!0});let i=Pc.find(e=>n.startsWith(e.to));return i&&!r.includes(i)?(0,K.jsx)(qe,{to:r[0].to,replace:!0}):(0,K.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsxs)(`div`,{className:`md:grid gap-6 md:grid-cols-12`,children:[(0,K.jsx)(`aside`,{className:`md:col-span-3 lg:col-span-2 mb-4 md:mb-0`,children:(0,K.jsx)(Nc,{items:r,ariaLabel:`Admin sections`})}),(0,K.jsx)(`section`,{className:`md:col-span-9 lg:col-span-10 min-w-0`,children:(0,K.jsx)(st,{})})]})})}function Lc({className:e,text:t,centered:n,...r}){return(0,K.jsxs)(`div`,{className:`text-foreground h-full w-full ${e||``} ${n?`flex flex-col items-center justify-center`:``}`,...r,children:[(0,K.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`100px`,height:`100px`,alt:`HDB Dog Logo Loading`,className:`inline-block`}),(0,K.jsx)(`p`,{className:`pt-4`,children:t||`Loading...`})]})}function Rc(e){return jr(e)===403}function zc(e){let t=jr(e);return t===400||t===403}var Bc=3e5,Vc=6e4,Hc=new WeakMap;function Uc(e){return e!==void 0&&e>=500&&e<600}function Wc(e,t,n){let{errorUpdatedAt:r,dataUpdatedAt:i=0}=e.state;if(!Number.isFinite(r))return t;let a=Hc.get(e);(a===void 0||a<i)&&(a=r,Hc.set(e,a));let o=r-a-n;return Math.min(Math.max(t,o),Math.max(t,Bc))}function Gc(e){return t=>{let n=jr(t.state.error);return n===403?!1:e?n===400?Wc(t,e,0):Uc(n)?Wc(t,e,Vc):e:e??!1}}function Kc(e=3){return(t,n)=>!zc(n)&&t<e}function qc(e){return!!e&&e!==`undefined`&&e!==`null`}async function Jc(e){if(!qc(e))throw Error(`getOrganization called without a valid organization id (got: ${e})`);let{data:t}=await P.get(`/Organization/${e}`);return t}function Yc(e){return B({queryKey:[e],queryFn:()=>Jc(e),retry:!1,enabled:qc(e),refetchInterval:Gc(1e4)})}function Xc(){let{user:e}=Sr(),{organizationId:t}=z({strict:!1});(0,G.useMemo)(()=>Nr(e),[e]);let{data:n}=L({...Yc(t),enabled:!1});return null}function Zc(e,t){let n=(0,G.useState)(gr(e,t)),[r]=n;return(0,G.useEffect)(()=>hr(e,r),[e,r]),n}function Qc(){let[e,t]=(0,G.useState)(()=>window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`);return(0,G.useEffect)(()=>{let e=window.matchMedia(`(prefers-color-scheme: dark)`),n=e=>t(e.matches?`dark`:`light`);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var $c=(0,G.createContext)([`system`,()=>{}]);function el({children:e}){let[t,n]=Zc(_r.Theme,`system`),r=Qc();return(0,G.useEffect)(()=>{let e=t===`dark`||t===`system`&&r===`dark`;document.documentElement.classList.toggle(`dark`,e)},[t,r]),(0,K.jsx)($c.Provider,{value:[t,n],children:e})}function tl(){return(0,G.useContext)($c)}function nl({user:e,onSignOut:t,signingOut:n}){let[r,i]=tl(),{organizationId:a}=z({strict:!1}),o=Mr(e)?e.username:[e.firstname,e.lastname].filter(Boolean).join(` `)||e.email,s=o.trim().split(/\s+/).slice(0,2).map(e=>e[0]).join(``).toUpperCase();return(0,G.useMemo)(()=>Nr(e).some(e=>!e.locked&&e.id!==a),[e,a]),(0,K.jsxs)(gc,{children:[(0,K.jsxs)(_c,{"aria-label":`Account menu`,className:`ml-2 inline-flex items-center gap-2 rounded-full border border-primary/25 bg-card/50 p-1 pr-2 text-foreground hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,K.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full bg-primary/15 text-xs font-semibold text-primary dark:text-violet-200`,children:s||(0,K.jsx)(Hs,{className:`size-4`})}),(0,K.jsx)(er,{className:`size-3.5`,"aria-hidden":`true`})]}),(0,K.jsxs)(vc,{align:`end`,className:`w-64`,children:[(0,K.jsx)(Cc,{className:`truncate`,title:o,children:o}),!Mr(e)&&o!==e.email&&(0,K.jsx)(`p`,{className:`truncate px-2 pb-2 text-xs text-muted-foreground`,title:e.email,children:e.email}),(0,K.jsx)(wc,{}),!1,(0,K.jsxs)(Ec,{children:[(0,K.jsxs)(Dc,{children:[(0,K.jsx)(Lo,{className:`size-4`}),`Appearance`]}),(0,K.jsx)(Oc,{children:(0,K.jsxs)(xc,{value:r,onValueChange:e=>{(e===`light`||e===`dark`||e===`system`)&&i(e)},children:[(0,K.jsx)(Sc,{value:`light`,children:`Light`}),(0,K.jsx)(Sc,{value:`system`,children:`System`}),(0,K.jsx)(Sc,{value:`dark`,children:`Dark`})]})})]}),(0,K.jsx)(wc,{}),(0,K.jsxs)(yc,{disabled:n,onSelect:t,children:[(0,K.jsx)(uo,{className:`size-4`}),n?`Signing out…`:`Sign Out`]})]})]})}function rl(){return(0,K.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 126.644 96`,width:24,height:24,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M81.15,0c-1.2376,2.1973-2.3489,4.4704-3.3591,6.794-9.5975-1.4396-19.3718-1.4396-28.9945,0-.985-2.3236-2.1216-4.5967-3.3591-6.794-9.0166,1.5407-17.8059,4.2431-26.1405,8.0568C2.779,32.5304-1.6914,56.3725.5312,79.8863c9.6732,7.1476,20.5083,12.603,32.0505,16.0884,2.6014-3.4854,4.8998-7.1981,6.8698-11.0623-3.738-1.3891-7.3497-3.1318-10.8098-5.1523.9092-.6567,1.7932-1.3386,2.6519-1.9953,20.281,9.547,43.7696,9.547,64.0758,0,.8587.7072,1.7427,1.3891,2.6519,1.9953-3.4601,2.0457-7.0718,3.7632-10.835,5.1776,1.97,3.8642,4.2683,7.5769,6.8698,11.0623,11.5419-3.4854,22.3769-8.9156,32.0509-16.0631,2.626-27.2771-4.496-50.9172-18.817-71.8548C98.9811,4.2684,90.1918,1.5659,81.1752.0505l-.0252-.0505ZM42.2802,65.4144c-6.2383,0-11.4159-5.6575-11.4159-12.6535s4.9755-12.6788,11.3907-12.6788,11.5169,5.708,11.4159,12.6788c-.101,6.9708-5.026,12.6535-11.3907,12.6535ZM84.3576,65.4144c-6.2637,0-11.3907-5.6575-11.3907-12.6535s4.9755-12.6788,11.3907-12.6788,11.4917,5.708,11.3906,12.6788c-.101,6.9708-5.026,12.6535-11.3906,12.6535Z`})})}function il(){let e=`studio`,t=`Harper Studio`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`img`,{src:`/harper-${e}_black.png`,alt:t,className:`w-64 hidden md:inline-block dark:hidden`}),(0,K.jsx)(`img`,{src:`/harper-${e}_white.png`,alt:t,className:`w-64 hidden md:dark:inline-block`}),(0,K.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`50px`,height:`44px`,alt:`Harper`,className:`inline-block md:hidden`})]})}var al=y(`inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-auto`,{variants:{variant:{default:`border-primary bg-primary/40 text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`border-secondary bg-secondary/40 text-secondary-foreground [a&]:hover:bg-secondary/90`,warning:`border-yellow bg-yellow/40 text-foreground [a&]:hover:bg-yellow/90`,success:`border-green bg-green/40 text-foreground [a&]:hover:bg-green/90`,destructive:`border-transparent bg-red-600 text-white [a&]:hover:bg-red-700 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40`,outline:`text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`}},defaultVariants:{variant:`default`}});function ol({className:e,variant:t,asChild:n=!1,...r}){return(0,K.jsx)(n?vt:`span`,{"data-slot":`badge`,className:F(al({variant:t}),e),...r})}function sl({className:e,children:t,...n}){return(0,K.jsxs)(Qn,{"data-slot":`scroll-area`,className:F(`relative`,e),...n,children:[(0,K.jsx)(bt,{"data-slot":`scroll-area-viewport`,className:`focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1`,children:t}),(0,K.jsx)(cl,{}),(0,K.jsx)(cn,{})]})}function cl({className:e,orientation:t=`vertical`,...n}){return(0,K.jsx)(Xn,{"data-slot":`scroll-area-scrollbar`,orientation:t,className:F(`flex touch-none p-px transition-colors select-none`,t===`vertical`&&`h-full w-2.5 border-l border-l-transparent`,t===`horizontal`&&`h-2.5 flex-col border-t border-t-transparent`,e),...n,children:(0,K.jsx)(qt,{"data-slot":`scroll-area-thumb`,className:`bg-border relative flex-1 rounded-full`})})}var ll=[`notification-acks`];function ul(){let e=gr(_r.AckedNotificationIds,[]);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function dl(e){hc.setQueryData(ll,e);try{hr(_r.AckedNotificationIds,e)}catch(e){console.warn(`[notifications] could not persist acknowledgements`,e)}}function fl(){return B({queryKey:ll,queryFn:ul,staleTime:1/0,gcTime:1/0,initialData:ul})}function pl(e){dl(Array.from(new Set([...ul(),e])))}function ml(e){dl(ul().filter(t=>t!==e))}function hl(){let{data:e}=L(fl());return(0,G.useMemo)(()=>new Set(e??[]),[e])}var gl={critical:{severity:`critical`,label:`Critical`,Icon:No,badgeVariant:`destructive`,bannerClass:`bg-destructive/10 border-destructive/40 text-foreground`,iconClass:`text-destructive`},warning:{severity:`warning`,label:`Warning`,Icon:Rs,badgeVariant:`warning`,bannerClass:`bg-yellow/10 border-yellow/40 text-foreground`,iconClass:`text-yellow`},info:{severity:`info`,label:`Info`,Icon:Ba,badgeVariant:`secondary`,bannerClass:`bg-secondary/20 border-secondary/50 text-foreground`,iconClass:`text-secondary-foreground`}},_l=new Set([`critical`,`error`,`outage`,`incident`,`down`,`danger`]),vl=new Set([`warning`,`warn`,`maintenance`,`degraded`,`notice`]),yl=new Set([`info`,`information`,`informational`,`success`,`ok`]);function bl(e){let t=(e??``).trim().toLowerCase();return vl.has(t)?`warning`:yl.has(t)?`info`:(_l.has(t),`critical`)}function xl(e){return gl[bl(e)]}var Sl={critical:0,warning:1,info:2};function Cl(e){if(e==null)return{kind:`absent`};if(typeof e==`number`)return Number.isFinite(e)?{kind:`valid`,ms:e}:{kind:`invalid`};if(typeof e!=`string`)return{kind:`invalid`};let t=e.trim();if(!t)return{kind:`absent`};if(/^\d+$/.test(t))return{kind:`valid`,ms:Number(t)};let n=Date.parse(t);return Number.isNaN(n)?{kind:`invalid`}:{kind:`valid`,ms:n}}function wl(e){let t=Cl(e);return t.kind===`valid`?t.ms:null}function Tl(e){return new Date(e).toLocaleString()}function El(e,t){let n=Cl(e.startAt),r=Cl(e.endAt);return n.kind===`invalid`||r.kind===`invalid`?{state:`expired`,label:`Schedule unavailable`}:n.kind===`valid`&&t<n.ms?{state:`upcoming`,label:`Starts ${Tl(n.ms)}`}:r.kind===`valid`&&t>r.ms?{state:`expired`,label:`Ended ${Tl(r.ms)}`}:r.kind===`valid`?{state:`active`,label:`Active until ${Tl(r.ms)}`}:{state:`active`,label:`Active`}}var Dl=new Set([`http`,`https`,`mailto`]);function Ol(e){if(!e)return null;let t=e.trim();if(!t)return null;if(t.startsWith(`//`))return{kind:`external`,href:t};let n=t.match(/^([a-z][a-z0-9+.-]*):/i)?.[1]?.toLowerCase();return n?Dl.has(n)?{kind:`external`,href:t}:null:{kind:`internal`,href:t.startsWith(`/`)?t:`/${t}`}}function kl({url:e,className:t,children:n,onNavigate:r}){let i=Ol(e);return i?i.kind===`external`?(0,K.jsxs)(`a`,{href:i.href,target:`_blank`,rel:`noreferrer noopener`,className:t,children:[n??`Learn more`,(0,K.jsx)(fa,{className:`inline size-3 ml-1 align-[-1px]`})]}):(0,K.jsx)(V,{to:i.href,className:t,onClick:r,children:n??`View details`}):null}var Al=[`system-status`];async function jl(){let{data:e}=await P.get(`/SystemStatus/`);return Array.isArray(e)?e:[]}function Ml(){return B({queryKey:Al,queryFn:jl,refetchInterval:6e4,staleTime:3e4})}var Nl=3e4,Pl=new Set,Fl=Date.now(),Il=null;function Ll(e){return Pl.add(e),Il||=(Fl=Date.now(),setInterval(()=>{Fl=Date.now(),Pl.forEach(e=>e())},Nl)),()=>{Pl.delete(e),Pl.size===0&&Il&&(clearInterval(Il),Il=null)}}function Rl(){return(0,G.useSyncExternalStore)(Ll,()=>Fl,()=>Fl)}function zl(){return L(Ml())}var Bl=[{value:`light`,icon:(0,K.jsx)(ws,{className:`size-4`}),label:`Light`},{value:`system`,icon:(0,K.jsx)(Do,{className:`size-4`}),label:`System`},{value:`dark`,icon:(0,K.jsx)(ko,{className:`size-4`}),label:`Dark`}];function Vl(){let[e,t]=tl();return(0,K.jsx)(`div`,{className:`flex items-center bg-muted dark:bg-black rounded-xl p-0.5 gap-0.5`,children:Bl.map(({value:n,icon:r,label:i})=>(0,K.jsx)(`button`,{type:`button`,title:i,onClick:()=>t(n),className:`p-1.5 rounded-lg transition-colors ${e===n?`bg-background text-foreground shadow-xs`:`text-muted-foreground hover:text-foreground`}`,children:r},n))})}function Hl({className:e,...t}){return(0,K.jsx)(`div`,{className:F(`absolute top-full left-0 isolate z-50 flex justify-center`),children:(0,K.jsx)(Kn,{"data-slot":`navigation-menu-viewport`,className:F(`origin-top-center bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border shadow md:w-[var(--radix-navigation-menu-viewport-width)]`,e),...t})})}function Ul({className:e,children:t,viewport:n=!0,...r}){return(0,K.jsxs)(kn,{"data-slot":`navigation-menu`,"data-viewport":n,className:F(`group/navigation-menu relative flex max-w-max flex-1 items-center justify-center`,e),...r,children:[t,n&&(0,K.jsx)(Hl,{})]})}function Wl({className:e,...t}){return(0,K.jsx)(yn,{"data-slot":`navigation-menu-item`,className:F(`relative`,e),...t})}function Gl({className:e,...t}){return(0,K.jsx)(_n,{"data-slot":`navigation-menu-link`,className:F(`hover:text-foreground dark:hover:text-white ring-ring/10 dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 flex flex-col gap-1 rounded-sm p-2 text-sm transition-[color,box-shadow] focus-visible:ring-4 focus-visible:outline-1 [&_svg:not([class*='size-'])]:size-4`,e),...t})}function Kl({className:e,...t}){return(0,K.jsx)(rn,{"data-slot":`navigation-menu-list`,className:F(`group flex flex-1 list-none items-center justify-center gap-1`,e),...t})}function ql({delayDuration:e=0,...t}){return(0,K.jsx)(hn,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Jl({...e}){return(0,K.jsx)(ql,{children:(0,K.jsx)(un,{"data-slot":`tooltip`,...e})})}function Yl({...e}){return(0,K.jsx)(Fn,{"data-slot":`tooltip-trigger`,...e})}function Xl({className:e,sideOffset:t=0,arrowClassName:n,children:r,...i}){return(0,K.jsx)(fn,{children:(0,K.jsxs)(Wn,{"data-slot":`tooltip-content`,sideOffset:t,className:F(`bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance`,e),...i,children:[r,(0,K.jsx)(Dn,{className:F(`bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`,n)})]})})}function Zl(){let e=`v5.3.3`,t=e.startsWith(`v`)?`https://github.com/HarperFast/studio/releases/tag/${e}`:`https://github.com/HarperFast/studio/releases`;return(0,K.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,children:(0,K.jsxs)(`span`,{className:F(al({variant:`default`}),`text-xs inline-block ml-2 align-text-top`),children:[e,` BETA`]})})}function Ql(e={}){let{instanceId:t,clusterId:r}=z({strict:!1});return n({id:m,...e})}function $l(e={}){let{instanceId:t,clusterId:r}=z({strict:!1});return{instanceClient:n({id:m,...e}),entityType:`instance`}}function q(e={}){let{instanceId:t,clusterId:n}=z({strict:!1});return(0,G.useMemo)(()=>eu({instanceId:t,clusterId:n,...e}),[e.instanceId??t,e.clusterId??n,e.operationsUrl,e.port,e.secure,e.disableFabricConnect,e.forceFabricConnect])}function eu({instanceId:e,clusterId:t,...r}){let i=m;if(!i)throw Error(`id could not be automatically calculated in useInstanceClientIdParams`);return{instanceClient:n({id:i,...r}),entityId:i,entityType:`instance`}}function tu(){localStorage.clear()}var nu=new Map,ru=new Map;function iu(e){for(let t of ru.get(e)??[])t()}function au(e,t){let n=`stored`;try{ft(e,t)}catch(t){n=`refused`,nu.get(e)?.state!==`refused`&&console.warn(`sessionStorage refused a write; keeping the value in memory only`,t)}nu.set(e,{value:t,state:n})}function ou(e,t){let n=nu.get(e);if(!n||n.state==="default"&&!ru.has(e)){let r=dt(e,void 0);n={value:r===void 0?t:r,state:r===void 0?`default`:`stored`},nu.set(e,n)}return n}function su(){return[...nu].filter(([,e])=>e.state===`refused`).map(([e])=>e)}function cu(e,t){return ou(e,t).value}function lu(e,t,n){let r=cu(e,t),i=typeof n==`function`?n(r):n;Object.is(i,r)||(au(e,i),iu(e))}function uu(e,t,n){let r=ru.get(e);if(!r){let n=ou(e,t);n.state!==`stored`&&au(e,n.value),r=new Set,ru.set(e,r)}return r.add(n),()=>{r.delete(n),r.size||(ru.delete(e),nu.get(e)?.state!==`refused`&&nu.delete(e))}}function du(){nu.clear();for(let e of ru.keys())iu(e)}typeof window<`u`&&window.addEventListener(`storage`,e=>{e.storageArea===sessionStorage&&(e.key===null?du():nu.delete(e.key)&&iu(e.key))});function fu(){try{sessionStorage.clear()}finally{du()}}function pu(){hu([()=>u.signOutAllLocally(),()=>hc.getMutationCache().clear(),()=>hc.getQueryCache().clear(),tu,fu])}function mu(){hu([()=>u.forgetAppSignInEndedElsewhere(),()=>hc.getMutationCache().clear(),()=>hc.getQueryCache().clear(),fu])}function hu(e){for(let t of e)try{t()}catch(e){console.error(e)}}async function gu(){pu(),await hc.invalidateQueries({refetchType:`none`})}async function _u(e){await u.signOutFromPotentiallyAuthenticatedInstances(),await d({...e,entityId:m})}function vu(){let e=Ql();return I({mutationFn:()=>_u({instanceClient:e}),onSuccess:gu})}(0,G.lazy)(()=>pe(()=>import(`./SearchDialog-BRIyPiBl.js`).then(e=>({default:e.SearchDialog})),__vite__mapDeps([0,1,2,3,4])));var yu=(0,G.createContext)(null);function bu(){let e=(0,G.useContext)(yu);return e?(0,K.jsxs)(`button`,{type:`button`,onClick:e,"aria-label":`Search organizations and clusters`,className:`inline-flex cursor-pointer items-center gap-2 rounded-lg border border-primary/20 bg-card/30 p-2 text-sm text-muted-foreground hover:bg-primary/15 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,K.jsx)(rs,{className:`size-4`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`hidden lg:inline`,children:`Search`}),(0,K.jsx)(`kbd`,{className:`hidden xl:inline rounded border border-border px-1 text-xs`,children:`⌘ / Ctrl K`})]}):null}var xu={className:`text-foreground dark:text-white font-semibold`};function Su(){let{mutate:e,isPending:t}=vu(),n=De(),{user:r}=xr(),i=Ee(),a=(0,G.useCallback)(()=>{e(void 0,{onSuccess:async()=>{U.success(`Success`,{description:`You have been signed out successfully.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),n({to:`/sign-in`}),i.invalidate()}})},[e,i,n]),o=(0,G.useMemo)(()=>[{to:`https://docs.harperdb.io/docs`,target:`_blank`,icon:(0,K.jsx)(ii,{}),text:`Docs`,textBreakpoint:`md`},{to:`https://github.com/HarperFast/studio/issues`,target:`_blank`,icon:(0,K.jsx)(ui,{}),text:`Report an Issue`,textBreakpoint:`lg`},{to:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,icon:(0,K.jsx)(rl,{}),text:`Discord`,textBreakpoint:`lg`}],[]);return r?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Du,{menuItems:o,user:r,accountMenu:(0,K.jsx)(nl,{user:r,onSignOut:a,signingOut:t})}),(0,K.jsx)(Tu,{menuItems:o,user:r,accountMenu:(0,K.jsx)(nl,{user:r,onSignOut:a,signingOut:t})})]}):(0,K.jsx)(wu,{})}function Cu(e){return e.items!==void 0}function wu(){return(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`inline-block`,children:[(0,K.jsx)(V,{to:`/sign-in`,children:(0,K.jsx)(il,{})}),(0,K.jsx)(Zl,{})]}),(0,K.jsx)(Ul,{children:(0,K.jsxs)(Kl,{className:`text-muted-foreground dark:text-grey-400`,children:[(0,K.jsx)(Wl,{children:(0,K.jsx)(Gl,{asChild:!0,children:(0,K.jsxs)(V,{to:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noreferrer noopener`,className:`flex-row items-center`,children:[(0,K.jsx)(ii,{}),` `,(0,K.jsx)(`span`,{className:`hidden md:inline-block`,children:`Docs`})]})})}),(0,K.jsx)(Wl,{children:(0,K.jsx)(Vl,{})}),(0,K.jsx)(Wl,{children:(0,K.jsx)(Gl,{asChild:!0,children:(0,K.jsxs)(V,{to:`/sign-in`,className:`flex-row items-center`,activeProps:xu,children:[(0,K.jsx)(co,{}),` Sign In`]})})})]})})]})}function Tu({menuItems:e,accountMenu:t,user:n}){return(0,G.useMemo)(()=>Pr(n),[n]),(0,K.jsx)(`div`,{className:`hidden md:[@media(hover:hover)]:block xl:block`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`inline-block`,children:[(0,K.jsx)(V,{to:`/`,children:(0,K.jsx)(il,{})}),(0,K.jsx)(Zl,{})]}),(0,K.jsx)(Ul,{children:(0,K.jsxs)(Kl,{className:`text-muted-foreground dark:text-grey-400`,children:[!1,e.map(e=>Cu(e)?!!e.items.length&&(0,K.jsx)(`div`,{className:`bg-muted dark:bg-black rounded-2xl flex`,children:e.items.map(e=>(0,K.jsx)(Eu,{menuItem:e},e.text))},e.text):(0,K.jsx)(Eu,{menuItem:e},e.text)),!1,(0,K.jsx)(Wl,{children:t})]})})]})})}function Eu({menuItem:e}){return(0,K.jsx)(Wl,{className:`text-muted-foreground dark:text-gray-400 hover:text-foreground dark:hover:text-white`,children:(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(Gl,{asChild:!0,children:(0,K.jsxs)(V,{to:e.to,onClick:e.onClick,"aria-label":e.text,className:`flex-row items-center`,target:e.target,activeProps:e.to?xu:void 0,children:[e.icon,(0,K.jsx)(`span`,{className:`hidden ${e.textBreakpoint}:inline-block`,children:e.text}),(0,K.jsx)(`span`,{className:`${e.textBreakpoint}:hidden`,children:`\xA0`})]})})}),(0,K.jsx)(Xl,{side:`bottom`,className:`${e.textBreakpoint}:hidden`,children:e.text})]})})}function Du({menuItems:e,accountMenu:t,user:n}){(0,G.useMemo)(()=>Pr(n),[n]);let[r,i]=(0,G.useState)(!1),a=(0,G.useCallback)(()=>i(e=>!e),[]),o=(0,G.useCallback)(()=>i(!1),[]);return(0,K.jsxs)(`div`,{className:`md:[@media(hover:hover)]:hidden xl:hidden`,id:`mobile-menu`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(V,{to:`/`,children:(0,K.jsx)(il,{})}),(0,K.jsx)(Zl,{}),(0,K.jsxs)(`div`,{className:`flex items-center`,children:[(0,K.jsx)(bu,{}),!1,t,(0,K.jsxs)(`button`,{type:`button`,className:`shadow-xs text-muted-foreground dark:text-grey-400 hover:text-foreground dark:hover:text-white hover:bg-muted dark:hover:bg-black-dark`,onClick:a,children:[(0,K.jsx)(`span`,{className:`sr-only`,children:r?`Close menu`:`Open menu`}),r?(0,K.jsx)(Ks,{}):(0,K.jsx)(Co,{})]})]})]}),(0,K.jsx)(`div`,{className:`${r?`fixed`:`hidden`} top-40 bottom-0 left-0 right-0 bg-foreground/20 dark:bg-black-dark dark:opacity-70`,onClick:o}),(0,K.jsx)(`div`,{className:`${r?`block`:`hidden`} md:hidden z-50 space-y-1 pb-3 bg-card border-b border-border dark:bg-black-dark dark:border-none absolute left-0 top-full w-full rounded-b-md`,children:e.map(e=>Cu(e)?!!e.items.length&&(0,K.jsx)(`div`,{className:`bg-muted dark:bg-black pl-10 pr-2 py-2`,children:e.items.map(e=>(0,K.jsx)(Ou,{menuItem:e,onClick:o},e.text))},e.text):(0,K.jsx)(Ou,{menuItem:e,onClick:o},e.text))})]})}function Ou({menuItem:e,onClick:t}){let n=(0,G.useCallback)(()=>{e.onClick?.(),t()},[e,t]);return(0,K.jsxs)(V,{to:e.to,onClick:n,target:e.target,className:`flex flex-row px-3 py-2 text-base font-medium rounded-md text-muted-foreground dark:text-gray-400 hover:text-foreground dark:hover:text-white`,activeProps:e.to?xu:void 0,children:[e.icon,(0,K.jsx)(`span`,{className:`ml-4`,children:e.text})]})}function ku(){let{isLoading:e,user:t}=xr(),{createCluster:n}=Oe({strict:!1}),[,r]=Zc(_r.SavedClusterState,null);return(0,G.useEffect)(()=>{n&&r(n)},[n,r]),e||!t?(0,K.jsx)(Lc,{className:`fixed z-50 translate-1/2`}):(0,K.jsxs)(`div`,{className:`studio-shell`,children:[(0,K.jsx)(`header`,{className:`studio-shell-header fixed top-0 z-40 w-full h-20 p-4 md:px-12`,children:(0,K.jsx)(Su,{})}),(0,K.jsx)(`main`,{children:(0,K.jsx)(st,{})})]})}function Au(){let e=location.hash;return e?e.startsWith(`#/`)?e.slice(1):e:`/`}var ju=[`/`,`/forgot-password`,`/reset-password`,`/sign-in`,`/sign-up`,`/verify-email`];function Mu(){let e=Au();return!ju.includes(e)&&{redirect:e}}var Nu={isLoading:!1,user:null};function Pu(e){return u.isKnownSignedOut(`OverallAppSignIn`)?Nu:e.authentication[m]}var Fu=`me|email|token|access_token|id_token|refresh_token|code|secret|password|api[-_]?key`,Iu=String.raw`[^&#\s",<>[\]{}|\\]+`,Lu=String.raw`[\w.%+!~*'()-]+(?:@|%40)[\w-]+(?:\.[\w-]+)*\.\w{2,}`;new RegExp(String.raw`([?&](?:${Fu})=)${Iu}`,`gi`),new RegExp(String.raw`([?&](?:${Fu})=)${Iu}|${Lu}`,`gi`);var Ru=String.raw`[\w-]+-extension`;new RegExp(String.raw`^${Ru}://`),new RegExp(String.raw`^\s*at\s.* @ ((?:blob:)?(?:https?|${Ru})://\S*)\s*$`);var zu=!1;function Bu(){(0,G.useEffect)(()=>{zu||=!0},[])}function Vu(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(lt,{}),(0,K.jsx)(st,{})]})}var Hu=Se()({component:Vu}),Uu=R({getParentRoute:()=>Hu,id:`_dashboardLayout`,component:ku,beforeLoad:({context:e})=>{let t=Pu(e);if(t&&!t.isLoading&&!t.user)throw Ne({to:`/sign-in`,search:Mu()})}}),Wu=R({getParentRoute:()=>Uu,path:`admin`,component:Ic});R({getParentRoute:()=>Wu,path:`/`,beforeLoad:()=>{throw Ne({to:`/admin/notifications`})}}),R({getParentRoute:()=>Wu,path:`notifications`,head:()=>({meta:[{title:`Notifications — Harper Fabric`}]}),component:je(async()=>pe(()=>import(`./notifications-CPgEC6ZP.js`),__vite__mapDeps([5,1,6,7,2,3,4,8,9])),`NotificationsAdminIndex`)}),R({getParentRoute:()=>Wu,path:`regions`,head:()=>({meta:[{title:`Regions — Harper Fabric`}]}),component:je(async()=>pe(()=>import(`./regions-WFvXqryO.js`),__vite__mapDeps([10,1,7,6,2,3,4,8,9,11,12])),`RegionsIndex`)}),R({getParentRoute:()=>Wu,path:`api-token`,head:()=>({meta:[{title:`API Token — Harper Fabric`}]}),component:je(async()=>pe(()=>import(`./apiToken-BraYnzvC.js`),__vite__mapDeps([13,1,6,7,2,3,4,8,9])),`ApiTokenIndex`)});function Gu(){let[e,t]=(0,G.useState)(()=>typeof document<`u`&&document.documentElement.classList.contains(`dark`));return(0,G.useEffect)(()=>{let e=document.documentElement;t(e.classList.contains(`dark`));let n=new MutationObserver(()=>{t(e.classList.contains(`dark`))});return n.observe(e,{attributes:!0,attributeFilter:[`class`]}),()=>n.disconnect()},[]),e?`dark`:`light`}var Ku={dark:[`M 246 426 C 211 389 184 377 154 386 C 72 399 44 492 0 576`,`M 658 383 C 693 318 748 286 795 286 C 905 281 957 477 952 583`,`M 750 438 C 915 444 1083 562 1183 766`,`M 0 576 C 119 529 273 575 372 766`,`M 1196 766 C 1291 526 1514 442 1690 432 C 1844 430 1973 530 2054 651`],light:[`M 258 355 C 212 300 171 289 136 313 C 74 352 37 434 0 542`,`M 633 350 C 684 251 744 193 790 200 C 882 201 967 380 951 548`,`M 756 405 C 891 368 1055 510 1169 766`,`M 0 542 C 112 440 299 588 356 766`,`M 1285 766 C 1391 564 1556 518 1710 505 C 1840 504 1971 571 2054 668`]},qu={dark:[[246,426,0,576],[658,383,952,583],[750,438,1183,766],[0,576,372,766],[1196,766,2054,651]],light:[[258,355,0,542],[633,350,951,548],[756,405,1169,766],[0,542,356,766],[1285,766,2054,668]]},Ju=[{path:0,duration:12,phase:3},{path:1,duration:16,phase:6},{path:1,duration:16,phase:14},{path:2,duration:14,phase:4},{path:3,duration:18,phase:11},{path:4,duration:22,phase:5},{path:4,duration:22,phase:16}];function Yu({theme:e}){let t=(0,G.useId)();return(0,K.jsxs)(`svg`,{className:`auth-energy-particles`,viewBox:`0 0 2054 766`,"aria-hidden":`true`,focusable:`false`,children:[(0,K.jsxs)(`defs`,{children:[(0,K.jsxs)(`radialGradient`,{id:`${t}-fade`,children:[(0,K.jsx)(`stop`,{offset:`0`,stopColor:`black`}),(0,K.jsx)(`stop`,{offset:`1`,stopColor:`white`})]}),qu[e].map(([e,n,r,i],a)=>(0,K.jsxs)(`mask`,{id:`${t}-${a}`,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`2054`,height:`766`,children:[(0,K.jsx)(`rect`,{width:`2054`,height:`766`,fill:`white`}),(0,K.jsx)(`circle`,{cx:e,cy:n,r:`60`,fill:`url(#${t}-fade)`}),(0,K.jsx)(`circle`,{cx:r,cy:i,r:`60`,fill:`url(#${t}-fade)`})]},a))]}),Ku[e].map((e,n)=>(0,K.jsx)(`path`,{className:`auth-energy-line`,d:e,mask:`url(#${t}-${n})`},e)),Ju.map(({path:t,duration:n,phase:r},i)=>(0,K.jsxs)(`g`,{className:`auth-energy-particle`,opacity:`0`,children:[(0,K.jsx)(`circle`,{r:`12`,fill:`currentColor`,opacity:`0.06`}),(0,K.jsx)(`circle`,{r:`6`,fill:`currentColor`,opacity:`0.16`}),(0,K.jsx)(`circle`,{r:`2.2`,fill:`currentColor`}),(0,K.jsx)(`animateMotion`,{path:Ku[e][t],dur:`${n}s`,begin:`-${r}s`,repeatCount:`indefinite`}),(0,K.jsx)(`animate`,{attributeName:`opacity`,values:`0;0.85;0.85;0`,keyTimes:`0;0.12;0.82;1`,dur:`${n}s`,begin:`-${r}s`,repeatCount:`indefinite`})]},`${e}-${i}`))]})}var Xu=[{title:`App`,description:`Build faster`,Icon:oi},{title:`Database`,description:`Store smarter`,Icon:ia},{title:`Cache`,description:`Move quicker`,Icon:Js},{title:`Messaging`,description:`Stay connected`,Icon:_o}];function Zu(){let e=Gu();return(0,K.jsxs)(`div`,{className:`fabric-sign-in-page`,children:[(0,K.jsxs)(`header`,{className:`sign-in-header`,children:[(0,K.jsxs)(`div`,{className:`sign-in-brand`,children:[(0,K.jsx)(V,{to:`/`,"aria-label":`Harper Fabric home`,children:(0,K.jsx)(il,{})}),(0,K.jsx)(Zl,{})]}),(0,K.jsxs)(`nav`,{"aria-label":`Authentication navigation`,children:[(0,K.jsxs)(`a`,{className:`sign-in-docs`,href:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noreferrer noopener`,children:[(0,K.jsx)(ii,{"aria-hidden":`true`}),` `,(0,K.jsx)(`span`,{children:`Docs`})]}),(0,K.jsx)(Vl,{})]})]}),(0,K.jsxs)(`main`,{className:`sign-in-content`,children:[(0,K.jsxs)(`section`,{className:`sign-in-story`,"aria-labelledby":`sign-in-story-title`,children:[(0,K.jsxs)(`div`,{className:`sign-in-story-copy`,children:[(0,K.jsxs)(`h2`,{id:`sign-in-story-title`,children:[`One runtime.`,(0,K.jsx)(`br`,{}),(0,K.jsx)(`span`,{children:`Endless possibilities.`})]}),(0,K.jsxs)(`p`,{children:[`Build, deploy, and scale distributed applications`,(0,K.jsx)(`br`,{className:`sign-in-desktop-break`}),` `,`with built-in data, cache, and messaging.`]}),(0,K.jsx)(`ul`,{className:`sign-in-features`,children:Xu.map(({title:e,description:t,Icon:n})=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`sign-in-feature-icon`,children:(0,K.jsx)(n,{"aria-hidden":`true`})}),(0,K.jsx)(`strong`,{children:e}),(0,K.jsx)(`span`,{children:t})]},e))})]}),(0,K.jsx)(`div`,{className:`sign-in-artwork`,children:(0,K.jsxs)(`div`,{className:`auth-hero-panorama`,children:[(0,K.jsx)(`img`,{className:`auth-hero-globe`,src:`/auth/fabric-globe-${e}.png`,alt:``,"aria-hidden":`true`}),(0,K.jsx)(Yu,{theme:e}),(0,K.jsx)(`img`,{className:`auth-hero-platform`,src:`/auth/fabric-platform-${e}.png`,width:`2054`,height:`766`,alt:`App, database, cache, and messaging together on a globally distributed platform.`,fetchPriority:`high`})]})}),(0,K.jsxs)(`div`,{className:`sign-in-story-footer`,children:[(0,K.jsx)(`span`,{children:`Free to deploy`}),(0,K.jsx)(`span`,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:`Live in minutes`})]})]}),(0,K.jsx)(`section`,{className:`sign-in-card`,"aria-label":`Account access`,children:(0,K.jsx)(st,{})})]})]})}function Qu(){(0,G.useEffect)(()=>{},[])}var $u=[`gmail.com`,`yahoo.com`,`hotmail.com`,`outlook.com`,`icloud.com`,`aol.com`,`protonmail.com`,`mail.com`,`zoho.com`,`yandex.com`,`gmx.com`,`live.com`,`msn.com`,`me.com`,`inbox.com`];function ed(e){if(!e||!e.includes(`@`))return null;let t=e.split(`@`).pop()||``;if(!t)return null;for(let e of $u)if(t===e||t.endsWith(`.`+e))return null;return t}var td=[`error`,`reason`];function nd(e){let t=new URLSearchParams(e),n=td.filter(e=>t.has(e));if(n.length===0)return e;for(let e of n)t.delete(e);let r=t.toString();return r?`?${r}`:``}function rd(){if(typeof location>`u`||typeof history>`u`)return;let{search:e,pathname:t,hash:n,origin:r}=location,i=nd(e);i!==e&&history.replaceState(history.state,``,`${r}${t}${i}${n}`)}var id=`utm_`;function ad(e){let t=new URLSearchParams(e),n=Array.from(t.keys()).filter(e=>e.toLowerCase().startsWith(id));if(n.length===0)return e;for(let e of n)t.delete(e);let r=t.toString();return r?`?${r}`:``}function od(){if(typeof location>`u`||typeof history>`u`)return;let{search:e,pathname:t,hash:n,origin:r}=location,i=ad(e);i!==e&&history.replaceState(history.state,``,`${r}${t}${i}${n}`)}function sd({icon:e,title:t,subtitle:n,loading:r=!1}){return(0,K.jsxs)(`div`,{className:`auth-heading`,children:[(0,K.jsx)(`span`,{className:`auth-status-icon`,children:(0,K.jsx)(e,{"aria-hidden":`true`,className:r?`auth-loading-icon`:void 0})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{children:t}),n&&(0,K.jsx)(`p`,{className:`auth-heading-subtitle`,children:n})]})]})}var cd=`We were not able to verify your sign-in. Please try signing in again.`,ld=`Sign-in is temporarily unavailable. Please try again in a few minutes.`,ud=`This sign-in method isn't allowed for your account.`,dd={state_storage:ld,account_lookup_failed:ld,identity_resolution:ld,token_exchange:ld,user_mapping:ld,user_info:ld,login_hook:ld,internal_error:ld,unknown:ld,email_lookup_failed:ld,csrf:`Your sign-in session expired. Please try signing in again.`,email_not_verified:`Verify your email address before signing in with this provider.`,email_ambiguous:`More than one of your verified email addresses matches an existing account. Contact your administrator for help signing in.`,provider_not_authorized:ud,login_not_allowed:ud,denied:ud,login_denied:ud,confirmation_required:`Your sign-in needs an extra step that was not completed. Please contact your administrator.`,access_denied:`Sign-in was cancelled.`},fd={invalid_request:`Your sign-in link is invalid or has expired. Please try signing in again.`,server_error:ld,auth_failed:ld,oauth_failed:`The identity provider couldn't complete sign-in. Please try again.`,access_denied:ud};function pd(e,t){if(e)return t&&Object.hasOwn(dd,t)?dd[t]:Object.hasOwn(fd,e)?fd[e]:cd}var md=null;function hd(){let e=De(),t=Ee(),n=Ze(),{redirect:r}=Oe({strict:!1});return(0,G.useEffect)(()=>{md||=Promise.resolve().then(async()=>{try{let i=new URLSearchParams(window.location.search),a=pd(i.get(`error`),i.get(`reason`));try{rd()}catch(e){console.debug(`Failed to clear OAuth error params from the URL, carrying on:`,e)}if(a){U.error(a,{duration:1e4}),await e({to:`/sign-in`});return}let o=await l().catch(()=>null);if(!o)U.error(cd,{duration:1e4}),await e({to:`/sign-in`});else{u.setUserForEntity(m,o),od();let i=Pr(o);ed(o.email),await n.invalidateQueries({queryKey:f,refetchType:`none`}),await t.invalidate(),await e({to:r?.startsWith(`/`)?r:i})}}finally{md=null}}).catch(e=>{console.debug(`OAuth sign-in check failed, carrying on:`,e)})},[]),(0,K.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`auth-form flex flex-col gap-4`,children:[(0,K.jsx)(sd,{icon:no,title:`Checking...`,subtitle:`We’re confirming your sign-in.`,loading:!0}),(0,K.jsx)(`div`,{className:`auth-links`,children:(0,K.jsx)(V,{className:`text-sm`,to:`/sign-in`,children:`Try signing in again`})})]})}var gd=new Map;function _d(e){if(!e)return``;if(gd.has(e))return gd.get(e);let t=e.replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();if(!t)return gd.set(e,``),``;let n=t.match(/([A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|[0-9]+)/g);if(!n)return gd.set(e,``),``;let r=[];for(let e=0;e<n.length;e++){let t=n[e],i=e+1<n.length?n[e+1]:void 0;/^[A-Z]{2,}$/.test(t)&&i&&/[A-Z]*s$/.test(i)||/^[A-Z]$/.test(t)&&i!==void 0&&/^[A-Z]s$/.test(i)?(r.push(t+i),e++):r.push(t)}let i=r.map(vd).join(` `);return gd.set(e,i),i}function vd(e){return/^[A-Z]{2,3}s?$/.test(e)||/^[0-9]+$/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}var yd=new Set([`mode`]),bd=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,xd=/^\{-\$(\w+)\}$/,Sd=`_splat`;function Cd(e,t,n){let r=[],i=0;for(let a of(e??``).split(`/`).filter(Boolean)){if(i>=t)break;let e=xd.exec(a);if(e)n[e[1]]!==void 0&&(r[i++]=e[1]);else if(a===`$`)for(;i<t;)r[i++]=Sd;else r[i++]=a.startsWith(`$`)?a.slice(1):void 0}return r}function wd(e){try{return decodeURIComponent(e)}catch{return e}}function Td(e,t,n){switch(e){case`organizationId`:return{label:n.organization||`Org`};case`clusterId`:return{label:n.cluster||`Cluster`};case`instanceId`:return{label:n.instance?.split(`.`)?.shift()||`Instance`}}return yd.has(e)?{label:_d(t)}:bd.test(t)?{label:t.slice(0,8),title:t}:{label:t}}function Ed(e,t,n,r){let i=e.split(`/`).filter(Boolean),a=Cd(t,i.length,n),o=e=>{let t=a[e],r=t&&t!==Sd?n[t]:void 0;return typeof r==`string`?r:wd(i[e])},s=[];for(let e=0;e<i.length;e++){let t=i[e],n=a[e];if(!n&&t===`instance`)continue;let c=`/${i.slice(0,e+1).join(`/`)}`;if(n)n===`clusterId`&&i[e+1]===`instance`&&(c+=`/instances`),s.push({path:c,...Td(n,o(e),r)});else if(t===`databases`&&i.length===e+3)s.push({path:c,label:o(e+2)}),e+=2;else{let e=_d(t);s.push({path:c,label:e===`Apis`?`APIs`:e})}}return s}function Dd({restartRequired:e}){let t=ze(),{organization:n,instance:r,cluster:i}=ye({strict:!1}),a=xe({select:e=>e[e.length-1]}),o=a?.pathname??t.pathname,s=a?.fullPath,c=a?.params,l=(0,G.useMemo)(()=>{let e=[(0,K.jsxs)(V,{to:`/`,children:[(0,K.jsx)(Ra,{"aria-hidden":`true`,className:`size-5 shrink-0`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Home`})]},`home`)],t=Ed(o,s,c??{},{organization:n?.name,cluster:i?.name,instance:r?.name});for(let{path:n,label:r,title:i}of t)e.push((0,K.jsx)(`svg`,{fill:`currentColor`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`size-5 shrink-0 text-grey`,children:(0,K.jsx)(`path`,{d:`M5.555 17.776l8-16 .894.448-8 16-.894-.448z`})},e.length+`-dash`),(0,K.jsx)(V,{to:n,title:i,className:`text-xs md:text-sm font-medium hover:text-grey truncate max-w-48`,children:r},n));return e},[o,s,c,i?.name,r?.name,n?.name]);return(0,K.jsxs)(`div`,{role:`list`,className:`flex items-center space-x-2 xl:space-x-4 sm:max-w-9/10 max-w-[calc(100%-56px)]`,children:[...l,e&&(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsxs)(`div`,{className:`text-xs italic text-muted-foreground`,children:[`* Restart `,(0,K.jsx)(`span`,{className:`hidden lg:inline-block`,children:`Requested`})]})}),(0,K.jsxs)(Xl,{side:`bottom`,children:[`This `,`Instance`,` is requesting a restart, when convenient, to apply your latest changes.`,(0,K.jsx)(`br`,{}),`You can do this from the Apps or Config pages.`]})]})]})}var Od=jn,kd=(0,G.createContext)({}),Ad=(0,G.createContext)({});function jd(){let e=(0,G.useContext)(kd),t=(0,G.useContext)(Ad),{errors:n}=Nn({name:e.name}),r=Rn(n,e.name);if(!e)throw Error(`useFormField should be used within <FormField>`);let{id:i}=t;return{id:i,name:e.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,formLengthHintId:`${i}-form-item-length-hint`,error:r}}function J({"aria-describedby":e,...t}){let{error:n,formItemId:r,formDescriptionId:i,formMessageId:a}=jd();return(0,K.jsx)(vt,{"data-slot":`form-control`,id:r,"aria-describedby":[i,n&&a,e].filter(Boolean).join(` `),"aria-invalid":!!n,...t})}function Y({...e}){return(0,K.jsx)(kd,{value:{name:e.name},children:(0,K.jsx)(Hn,{...e})})}function X({className:e,...t}){let n=(0,G.useId)();return(0,K.jsx)(Ad,{value:{id:n},children:(0,K.jsx)(`div`,{"data-slot":`form-item`,className:F(`grid gap-2`,e),...t})})}function Md({className:e,...t}){return(0,K.jsx)(pn,{"data-slot":`label`,className:F(`text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function Z({className:e,...t}){let{error:n,formItemId:r}=jd();return(0,K.jsx)(Md,{"data-slot":`form-label`,"data-error":!!n,className:F(`data-[error=true]:text-destructive`,e),htmlFor:r,...t})}function Q({className:e,...t}){let{error:n,formMessageId:r}=jd(),i=n?String(n?.message):t.children;return i?(0,K.jsx)(`p`,{"data-slot":`form-message`,id:r,className:F(`text-destructive text-sm`,e),...t,children:i}):null}function $({className:e,type:t,...n}){return(0,K.jsx)(`input`,{type:t,"data-slot":`input`,className:F(`border-input file:text-foreground placeholder:text-muted-foreground selection:bg-purple
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SearchDialog-CdlNxWef.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/vendor-datadog-GjET_Cbn.js","assets/vendor-react-DSIx92Ld.js","assets/vendor-tanstack-C5Y-nrd2.js","assets/notifications-BYgO5-yk.js","assets/cn-DpF1PxBT.js","assets/vendor-core-PejxhUWQ.js","assets/button-C37w80Uk.js","assets/vendor-ui-BBWHOEoQ.js","assets/regions-Sv_IN7XA.js","assets/chevron-up-DozwrIz-.js","assets/createLucideIcon-DLWRoWN-.js","assets/apiToken-DyI8IwU3.js","assets/setup-Ca4RpPzm.js","assets/dist-9lpzt2Hn.js","assets/register-AM2_79FO.js","assets/register-DjpsE8to.css","assets/editor-DATuu7_v.js","assets/toggleHighContrast-JRkLfyfb.js","assets/toggleHighContrast-n7clI0si.css","assets/index.lazy-DQpKL_QQ.js","assets/authStore-DE1HFvVP.js","assets/restartGate-D_e93lFE.js","assets/setSessionStorage-B0bf71m4.js","assets/safeParse-DeaoCCWH.js","assets/localStorageKeys-etzFY_xV.js","assets/wasAReleasedBeforeB-D5grAaGM.js","assets/useEntityRestURL-HHmjsRm9.js","assets/request-BJj8dbdU.js","assets/applications-DgGopKJq.js","assets/setComponentFile-BCnAnxjR.js","assets/errorText-8xV8WZBt.js","assets/restartUnconfirmed-BqcDZ__Y.js","assets/invalidateEntityQueries-BkWXiqjz.js","assets/languageServices-Ca72n4Ql.js","assets/applications-DNZhsH95.css","assets/FloatingChat-BWfKK_RX.js","assets/operations-Dy69AlTr.js","assets/status-D05eZ5pQ.js","assets/linear-Ds1AeO4V.js","assets/step-vX8bovaY.js","assets/defaultLocale-BFoDCU3G.js","assets/init-ZlXS9mIS.js","assets/ordinal-CPleeUAT.js","assets/time-Ci1v4fvT.js","assets/band-DZ4Jagyz.js","assets/getAnalytics-B1xpd4kG.js","assets/notifications-DsGk-TnW.js","assets/profile-DzQvoYBF.js"])))=>i.map(i=>d[i]);
2
+ import{i as e,t}from"./rolldown-runtime-Dd_uD5pT.js";import{_ as n,a as r,b as i,d as a,g as o,h as s,i as c,m as l,n as u,o as d,p as f,r as p,t as m,v as h,x as g,y as _}from"./authStore-DE1HFvVP.js";import{D as v,E as y,_ as b,b as x,d as S,g as C,i as w,j as T,k as E,o as D,p as O,r as k,s as A,t as j,u as M,v as ee,x as te,y as N}from"./vendor-core-PejxhUWQ.js";import{n as P,t as F}from"./cn-DpF1PxBT.js";import{a as ne,c as re,d as ie,f as ae,h as oe,i as se,l as ce,o as le,r as ue,s as de,u as fe}from"./restartGate-D_e93lFE.js";import{a as pe,n as me,o as he,t as ge}from"./vendor-datadog-GjET_Cbn.js";import{r as _e,t as ve}from"./vendor-react-DSIx92Ld.js";import{A as ye,B as be,C as xe,D as Se,F as Ce,G as we,H as I,J as Te,K as L,L as Ee,M as De,N as Oe,O as R,P as z,Q as ke,S as Ae,T as je,U as Me,V as Ne,W as B,X as Pe,Y as Fe,Z as Ie,_ as Le,a as Re,b as ze,c as Be,d as Ve,et as He,f as Ue,g as We,h as Ge,i as Ke,j as qe,k as V,l as Je,m as Ye,n as Xe,nt as Ze,o as Qe,p as $e,q as et,r as tt,s as nt,t as rt,tt as it,u as at,v as ot,w as st,x as ct,y as lt,z as ut}from"./vendor-tanstack-C5Y-nrd2.js";import{n as dt,t as ft}from"./setSessionStorage-B0bf71m4.js";import{n as pt,t as H}from"./button-C37w80Uk.js";import{$ as mt,A as ht,At as gt,B as _t,Bt as vt,C as yt,Ct as bt,D as xt,Dt as St,E as Ct,Et as wt,F as Tt,Ft as Et,G as Dt,H as Ot,I as kt,It as At,J as jt,K as Mt,L as Nt,Lt as Pt,M as Ft,Mt as It,N as Lt,Nt as Rt,O as zt,Ot as Bt,P as Vt,Pt as Ht,Q as Ut,R as Wt,Rt as Gt,S as Kt,St as qt,T as Jt,Tt as Yt,U as Xt,V as Zt,W as Qt,X as $t,Y as en,Z as tn,_ as nn,_t as rn,a as an,at as on,b as sn,bt as cn,c as ln,ct as un,d as dn,dt as fn,et as pn,f as mn,ft as hn,g as gn,gt as _n,h as vn,ht as yn,i as bn,it as xn,j as Sn,jt as Cn,k as wn,kt as Tn,l as En,lt as Dn,m as On,mt as kn,n as An,nt as jn,o as Mn,ot as Nn,p as Pn,pt as Fn,q as In,r as Ln,rt as Rn,s as zn,st as Bn,t as Vn,tt as Hn,u as Un,ut as Wn,v as Gn,vt as Kn,w as qn,wt as Jn,x as Yn,xt as Xn,y as Zn,yt as Qn,z as $n,zt as U}from"./vendor-ui-BBWHOEoQ.js";import{t as W}from"./createLucideIcon-DLWRoWN-.js";import{n as er,r as tr,t as nr}from"./chevron-up-DozwrIz-.js";import{a as rr,c as ir,i as ar,l as or,n as sr,o as cr,r as lr,s as ur,t as dr}from"./restartUnconfirmed-BqcDZ__Y.js";import{n as fr,t as pr}from"./errorText-8xV8WZBt.js";import{t as mr}from"./invalidateEntityQueries-BkWXiqjz.js";import{n as hr,r as gr,t as _r}from"./localStorageKeys-etzFY_xV.js";import{n as vr,t as yr}from"./wasAReleasedBeforeB-D5grAaGM.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var G=e(he(),1);function br(){let[e,t]=(0,G.useState)(()=>({...u.getAllConnections()}));return(0,G.useEffect)(()=>u.listenToAllEntities((e,n)=>{t(t=>({...t,[n]:e}))}),[]),e}function xr(){let e=u.calculateIdFromEntity(m),[t,n]=(0,G.useState)(u.getConnectionById(m));return(0,G.useEffect)(()=>u.listenToEntity(e,n),[e]),t}function Sr(){return xr()}function Cr(e,t){return!e||!(`fabricRole`in e)?!1:e.staffPermissions?e.staffPermissions.includes(t):e.fabricRole===`fabric_admin`||e.fabricRole===`super_user`}function wr(e){let{user:t}=Sr();return Cr(t,e)}function Tr(e){let{clusterId:t,instanceId:n}=z({strict:!1}),r=m,[i,a]=(0,G.useState)(()=>({key:r,connection:u.getConnectionById(r)}));return(0,G.useEffect)(()=>u.listenToEntity(r,e=>a({key:r,connection:e})),[r]),i.key===r?i.connection:u.getConnectionById(r)}var K=_e();function Er({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`card`,className:F(`bg-card text-card-foreground flex flex-col gap-4 rounded-2xl py-5 shadow-deep ring-1 ring-black/5 dark:ring-white/5`,e),...t})}function Dr({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`card-header`,className:F(`flex flex-col gap-1.5 px-6`,e),...t})}function Or({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`card-title`,className:F(`leading-none text-lg`,e),...t})}function kr({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`card-description`,className:F(`text-muted-foreground text-xs`,e),...t})}function Ar({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`card-content`,className:F(`px-6`,e),...t})}function jr(e){try{return e?.response?.status??e?.status}catch{return}}function Mr(e){return e!==null&&!!e.username}function Nr(e){if(!e||Mr(e))return[];let t=Cr(e,`org:read`);return Object.entries(e.roles??{}).map(([e,n])=>({id:e,name:n.organizationName||e,roleName:n.role??`fabric staff`,locked:`oauthProviders`in n&&!t,providers:n.oauthProviders??[]})).sort((e,t)=>e.name.localeCompare(t.name)||e.id.localeCompare(t.id))}function Pr(e){let t=Nr(e);return t.length===1&&!t[0].locked?`/${t[0].id}`:`/`}var Fr={name:`activity`,size:24,node:[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]};Fr.node;var Ir=W(Fr),Lr={name:`arrow-down-to-line`,size:24,node:[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]};Lr.node;var Rr=W(Lr),zr={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};zr.node;var Br=W(zr),Vr={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};Vr.node;var Hr=W(Vr),Ur={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};Ur.node;var Wr=W(Ur),Gr={name:`arrow-up-down`,size:24,node:[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]};Gr.node;var Kr=W(Gr),qr={name:`arrow-up-from-line`,size:24,node:[[`path`,{d:`m18 9-6-6-6 6`,key:`kcunyi`}],[`path`,{d:`M12 3v14`,key:`7cf3v8`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]};qr.node;var Jr=W(qr),Yr={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};Yr.node;var Xr=W(Yr),Zr={name:`badge-check`,size:24,node:[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`verified`]};Zr.node;var Qr=W(Zr),$r={name:`ban`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]};$r.node;var ei=W($r),ti={name:`bell`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]};ti.node;var ni=W(ti),ri={name:`book-open-text`,size:24,node:[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M16 13h2`,key:`weia3s`}],[`path`,{d:`M16 9h2`,key:`1n7gjm`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}],[`path`,{d:`M6 13h2`,key:`1cckiz`}],[`path`,{d:`M6 9h2`,key:`1k7j9f`}]]};ri.node;var ii=W(ri),ai={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};ai.node;var oi=W(ai),si={name:`brush-cleaning`,size:24,node:[[`path`,{d:`m16 22-1-4`,key:`1ow2iv`}],[`path`,{d:`M19 14a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2h-3a1 1 0 0 1-1-1V4a2 2 0 0 0-4 0v5a1 1 0 0 1-1 1H6a2 2 0 0 0-2 2v1a1 1 0 0 0 1 1`,key:`11gii7`}],[`path`,{d:`M19 14H5l-1.973 6.767A1 1 0 0 0 4 22h16a1 1 0 0 0 .973-1.233z`,key:`bju7h4`}],[`path`,{d:`m8 22 1-4`,key:`s3unb`}]]};si.node;var ci=W(si),li={name:`bug`,size:24,node:[[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`,key:`uouzyp`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M21 21a4 4 0 0 0-3.81-4`,key:`1b0z45`}],[`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`,key:`5cxbf6`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M3 21a4 4 0 0 1 3.81-4`,key:`1fjd4g`}],[`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`,key:`1d7oge`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`,key:`1vgav8`}]]};li.node;var ui=W(li),di={name:`building-complex`,size:24,node:[[`path`,{d:`M10 12h4`,key:`a56b0p`}],[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M14 21v-3a2 2 0 0 0-4 0v3`,key:`1rgiei`}],[`path`,{d:`M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2`,key:`secmi2`}],[`path`,{d:`M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16`,key:`16ra0t`}]],aliases:[`building-2`]};di.node;var fi=W(di),pi={name:`calendar-clock`,size:24,node:[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338`,key:`7hb8p4`}],[`path`,{d:`M3 9h5.859`,key:`numkqi`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]};pi.node;var mi=W(pi),hi={name:`chart-column-increasing`,size:24,node:[[`path`,{d:`M13 17V9`,key:`1fwyjl`}],[`path`,{d:`M18 17V5`,key:`sfb6ij`}],[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]],aliases:[`bar-chart-4`]};hi.node;var gi=W(hi),_i={name:`chart-pie`,size:24,node:[[`path`,{d:`M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z`,key:`pzmjnu`}],[`path`,{d:`M21.21 15.89A10 10 0 1 1 8 2.83`,key:`k2fpak`}]],aliases:[`pie-chart`]};_i.node;var vi=W(_i),yi={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};yi.node;var bi=W(yi),xi={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};xi.node;var Si=W(xi),Ci={name:`circle-alert`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]],aliases:[`alert-circle`]};Ci.node;var wi=W(Ci),Ti={name:`circle-check-big`,size:24,node:[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]],aliases:[`check-circle`]};Ti.node;var Ei=W(Ti),Di={name:`circle-check`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`check-circle-2`]};Di.node;var Oi=W(Di),ki={name:`circle-dashed`,size:24,node:[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]};ki.node;var Ai=W(ki),ji={name:`circle-minus`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]],aliases:[`minus-circle`]};ji.node;var Mi=W(ji),Ni={name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`help-circle`,`circle-help`]};Ni.node;var Pi=W(Ni),Fi={name:`circle`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};Fi.node;var Ii=W(Fi),Li={name:`clipboard-check`,size:24,node:[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`m9 14 2 2 4-4`,key:`df797q`}]]};Li.node;var Ri=W(Li),zi={name:`clipboard`,size:24,node:[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}]]};zi.node;var Bi=W(zi),Vi={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};Vi.node;var Hi=W(Vi),Ui={name:`cloud-alert`,size:24,node:[[`path`,{d:`M12 12v4`,key:`tww15h`}],[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.128 16.949A7 7 0 1 1 15.71 8h1.79a1 1 0 0 1 0 9h-1.642`,key:`1namsd`}]]};Ui.node;var Wi=W(Ui),Gi={name:`cloud-download`,size:24,node:[[`path`,{d:`M12 13v8l-4-4`,key:`1f5nwf`}],[`path`,{d:`m12 21 4-4`,key:`1lfcce`}],[`path`,{d:`M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284`,key:`ui1hmy`}]],aliases:[`download-cloud`]};Gi.node;var Ki=W(Gi),qi={name:`cloud-upload`,size:24,node:[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]],aliases:[`upload-cloud`]};qi.node;var Ji=W(qi),Yi={name:`code`,size:24,node:[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]};Yi.node;var Xi=W(Yi),Zi={name:`columns-3-cog`,size:24,node:[[`path`,{d:`M10.6 21H5a2 2 0 01-2-2V5a2 2 0 012-2h14a2 2 0 012 2v5.6`,key:`19s2bv`}],[`path`,{d:`m14.305 19.53.923-.382`,key:`3m78fa`}],[`path`,{d:`M15 3v7.6`,key:`mv9izd`}],[`path`,{d:`m15.229 16.852-.924-.383`,key:`qpfz85`}],[`path`,{d:`m16.852 15.228-.383-.923`,key:`5xggr7`}],[`path`,{d:`m16.852 20.772-.383.924`,key:`dpfhf9`}],[`path`,{d:`m19.148 15.228.383-.923`,key:`1reyyz`}],[`path`,{d:`m19.53 21.696-.382-.924`,key:`1goivc`}],[`path`,{d:`m20.773 16.852.922-.383`,key:`59dfo2`}],[`path`,{d:`m20.773 19.148.922.383`,key:`1lk755`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}]],aliases:[`columns-settings`,`table-config`]};Zi.node;var Qi=W(Zi),$i={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};$i.node;var ea=W($i),ta={name:`credit-card`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}],[`path`,{d:`M6 14h2`,key:`mk7k0u`}]]};ta.node;var na=W(ta),ra={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};ra.node;var ia=W(ra),aa={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]};aa.node;var oa=W(aa),sa={name:`earth`,size:24,node:[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]],aliases:[`globe-2`]};sa.node;var ca=W(sa),la={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};la.node;var ua=W(la),da={name:`external-link`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]};da.node;var fa=W(da),pa={name:`eye-off`,size:24,node:[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};pa.node;var ma=W(pa),ha={name:`eye`,size:24,node:[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};ha.node;var ga=W(ha),_a={name:`file-up`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]};_a.node;var va=W(_a),ya={name:`funnel-plus`,size:24,node:[[`path`,{d:`M13.354 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14v6a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341l1.218-1.348`,key:`8mvsmf`}],[`path`,{d:`M16 6h6`,key:`1dogtp`}],[`path`,{d:`M19 3v6`,key:`1ytpjt`}]]};ya.node;var ba=W(ya),xa={name:`funnel-x`,size:24,node:[[`path`,{d:`M12.531 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14v6a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341l.427-.473`,key:`ol2ft2`}],[`path`,{d:`m16.5 3.5 5 5`,key:`15e6fa`}],[`path`,{d:`m21.5 3.5-5 5`,key:`m0lwru`}]],aliases:[`filter-x`]};xa.node;var Sa=W(xa),Ca={name:`funnel`,size:24,node:[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]],aliases:[`filter`]};Ca.node;var wa=W(Ca),Ta={name:`gauge`,size:24,node:[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]};Ta.node;var Ea=W(Ta),Da={name:`git-graph`,size:24,node:[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M5 9v6`,key:`158jrl`}],[`circle`,{cx:`5`,cy:`18`,r:`3`,key:`104gr9`}],[`path`,{d:`M12 3v18`,key:`108xh3`}],[`circle`,{cx:`19`,cy:`6`,r:`3`,key:`108a5v`}],[`path`,{d:`M16 15.7A9 9 0 0 0 19 9`,key:`1e3vqb`}]]};Da.node;var Oa=W(Da),ka={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};ka.node;var Aa=W(ka),ja={name:`grip-horizontal`,size:24,node:[[`circle`,{cx:`12`,cy:`9`,r:`1`,key:`124mty`}],[`circle`,{cx:`19`,cy:`9`,r:`1`,key:`1ruzo2`}],[`circle`,{cx:`5`,cy:`9`,r:`1`,key:`1a8b28`}],[`circle`,{cx:`12`,cy:`15`,r:`1`,key:`1e56xg`}],[`circle`,{cx:`19`,cy:`15`,r:`1`,key:`1a92ep`}],[`circle`,{cx:`5`,cy:`15`,r:`1`,key:`5r1jwy`}]]};ja.node;var Ma=W(ja),Na={name:`grip-vertical`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]};Na.node;var Pa=W(Na),Fa={name:`handshake`,size:24,node:[[`path`,{d:`m11 17 2 2a1 1 0 1 0 3-3`,key:`efffak`}],[`path`,{d:`m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4`,key:`9pr0kb`}],[`path`,{d:`m21 3 1 11h-2`,key:`1tisrp`}],[`path`,{d:`M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3`,key:`1uvwmv`}],[`path`,{d:`M3 4h8`,key:`1ep09j`}]]};Fa.node;var Ia=W(Fa),La={name:`house`,size:24,node:[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]],aliases:[`home`]};La.node;var Ra=W(La),za={name:`info`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]};za.node;var Ba=W(za),Va={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};Va.node;var Ha=W(Va),Ua={name:`key`,size:24,node:[[`path`,{d:`m2 21 9.6-9.6`,key:`9l79m3`}],[`path`,{d:`m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19`,key:`fw8biw`}],[`circle`,{cx:`15.5`,cy:`7.5`,r:`5.5`,key:`4wxmhb`}]]};Ua.node;var Wa=W(Ua),Ga={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};Ga.node;var Ka=W(Ga),qa={name:`layout-dashboard`,size:24,node:[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]};qa.node;var Ja=W(qa),Ya={name:`life-buoy`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m4.93 4.93 4.24 4.24`,key:`1ymg45`}],[`path`,{d:`m14.83 9.17 4.24-4.24`,key:`1cb5xl`}],[`path`,{d:`m14.83 14.83 4.24 4.24`,key:`q42g0n`}],[`path`,{d:`m9.17 14.83-4.24 4.24`,key:`bqpfvv`}],[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}]]};Ya.node;var Xa=W(Ya),Za={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};Za.node;var Qa=W(Za),$a={name:`list-todo`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]};$a.node;var eo=W($a),to={name:`loader-circle`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]],aliases:[`loader-2`]};to.node;var no=W(to),ro={name:`lock-keyhole`,size:24,node:[[`circle`,{cx:`12`,cy:`16`,r:`1`,key:`1au0dj`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`,key:`6s8ecr`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`,key:`1pqi11`}]]};ro.node;var io=W(ro),ao={name:`lock`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]};ao.node;var oo=W(ao),so={name:`log-in`,size:24,node:[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]};so.node;var co=W(so),lo={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};lo.node;var uo=W(lo),fo={name:`mail-check`,size:24,node:[[`path`,{d:`M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8`,key:`12jkf8`}],[`path`,{d:`m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`,key:`1ocrg3`}],[`path`,{d:`m16 19 2 2 4-4`,key:`1b14m6`}]]};fo.node;var po=W(fo),mo={name:`mail-warning`,size:24,node:[[`path`,{d:`M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5`,key:`e61zoh`}],[`path`,{d:`m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`,key:`1ocrg3`}],[`path`,{d:`M20 14v4`,key:`1hm744`}],[`path`,{d:`M20 22v.01`,key:`12bgn6`}]]};mo.node;var ho=W(mo),go={name:`mail`,size:24,node:[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]};go.node;var _o=W(go),vo={name:`map-pin`,size:24,node:[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]};vo.node;var yo=W(vo),bo={name:`maximize`,size:24,node:[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]};bo.node;var xo=W(bo),So={name:`menu`,size:24,node:[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]};So.node;var Co=W(So),wo={name:`minimize`,size:24,node:[[`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3`,key:`hohbtr`}],[`path`,{d:`M21 8h-3a2 2 0 0 1-2-2V3`,key:`5jw1f3`}],[`path`,{d:`M3 16h3a2 2 0 0 1 2 2v3`,key:`198tvr`}],[`path`,{d:`M16 21v-3a2 2 0 0 1 2-2h3`,key:`ph8mxp`}]]};wo.node;var To=W(wo),Eo={name:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};Eo.node;var Do=W(Eo),Oo={name:`moon`,size:24,node:[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]};Oo.node;var ko=W(Oo),Ao={name:`notepad-text`,size:24,node:[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`16`,height:`18`,x:`4`,y:`4`,rx:`2`,key:`1u9h20`}],[`path`,{d:`M8 10h6`,key:`3oa6kw`}],[`path`,{d:`M8 14h8`,key:`1fgep2`}],[`path`,{d:`M8 18h5`,key:`17enja`}]]};Ao.node;var jo=W(Ao),Mo={name:`octagon-alert`,size:24,node:[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]],aliases:[`alert-octagon`]};Mo.node;var No=W(Mo),Po={name:`package`,size:24,node:[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]};Po.node;var Fo=W(Po),Io={name:`palette`,size:24,node:[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]};Io.node;var Lo=W(Io),Ro={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};Ro.node;var zo=W(Ro),Bo={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};Bo.node;var Vo=W(Bo),Ho={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};Ho.node;var Uo=W(Ho),Wo={name:`refresh-cw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]};Wo.node;var Go=W(Wo),Ko={name:`rocket`,size:24,node:[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]};Ko.node;var qo=W(Ko),Jo={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};Jo.node;var Yo=W(Jo),Xo={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};Xo.node;var Zo=W(Xo),Qo={name:`save`,size:24,node:[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]};Qo.node;var $o=W(Qo),es={name:`scale`,size:24,node:[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`m19 8 3 8a5 5 0 0 1-6 0zV7`,key:`zcdpyk`}],[`path`,{d:`M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1`,key:`1yorad`}],[`path`,{d:`m5 8 3 8a5 5 0 0 1-6 0zV7`,key:`eua70x`}],[`path`,{d:`M7 21h10`,key:`1b0cd5`}]]};es.node;var ts=W(es),ns={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};ns.node;var rs=W(ns),is={name:`server-off`,size:24,node:[[`path`,{d:`M7 2h13a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-5`,key:`bt2siv`}],[`path`,{d:`M10 10 2.5 2.5C2 2 2 2.5 2 5v3a2 2 0 0 0 2 2h6z`,key:`1hjrv1`}],[`path`,{d:`M22 17v-1a2 2 0 0 0-2-2h-1`,key:`1iynyr`}],[`path`,{d:`M4 14a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16.5l1-.5.5.5-8-8H4z`,key:`161ggg`}],[`path`,{d:`M6 18h.01`,key:`uhywen`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};is.node;var as=W(is),os={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};os.node;var ss=W(os),cs={name:`settings`,size:24,node:[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};cs.node;var ls=W(cs),us={name:`shield-check`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]};us.node;var ds=W(us),fs={name:`shield-x`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m14.5 9.5-5 5`,key:`17q4r4`}],[`path`,{d:`m9.5 9.5 5 5`,key:`18nt4w`}]],aliases:[`shield-close`]};fs.node;var ps=W(fs),ms={name:`shield`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]};ms.node,W(ms);var hs={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};hs.node;var gs=W(hs),_s={name:`square-pen`,size:24,node:[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]],aliases:[`pen-box`,`edit`,`pen-square`]};_s.node;var vs=W(_s),ys={name:`square-terminal`,size:24,node:[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]],aliases:[`terminal-square`]};ys.node;var bs=W(ys),xs={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};xs.node;var Ss=W(xs),Cs={name:`sun`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]};Cs.node;var ws=W(Cs),Ts={name:`table-2`,size:24,node:[[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]};Ts.node;var Es=W(Ts),Ds={name:`table`,size:24,node:[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}]]};Ds.node;var Os=W(Ds),ks={name:`tag`,size:24,node:[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]};ks.node;var As=W(ks),js={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};js.node;var Ms=W(js),Ns={name:`ticket`,size:24,node:[[`path`,{d:`M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z`,key:`qn84l0`}],[`path`,{d:`M13 5v2`,key:`dyzc3o`}],[`path`,{d:`M13 17v2`,key:`1ont0d`}],[`path`,{d:`M13 11v2`,key:`1wjjxi`}]]};Ns.node;var Ps=W(Ns),Fs={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};Fs.node;var Is=W(Fs),Ls={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};Ls.node;var Rs=W(Ls),zs={name:`user-minus`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]};zs.node;var Bs=W(zs),Vs={name:`user-round`,size:24,node:[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]],aliases:[`user-2`]};Vs.node;var Hs=W(Vs),Us={name:`users`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]};Us.node;var Ws=W(Us),Gs={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};Gs.node;var Ks=W(Gs),qs={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]};qs.node;var Js=W(qs),Ys=`An unexpected error occurred.`,Xs=`Something Went Wrong`,Zs={title:`Access Denied`,description:`Your account doesn't have permission to view this. If you think it should, ask an administrator for access.`},Qs={title:`Not Found`,description:`We couldn't find what you were looking for. It may have been deleted, or the link may be wrong.`},$s={title:`Couldn't Reach the Server`,description:`The request didn't get an answer. Check your connection, then try again.`,retryable:!0},ec=new Set([E.ERR_NETWORK,E.ECONNABORTED,E.ETIMEDOUT]);function tc(e){try{return e?.code}catch{return}}function nc(e){let t=jr(e);return t===403?Zs:t===404?Qs:typeof t==`number`?t>=500&&t<600?{title:Xs,description:`The server couldn't load this (error ${t}). Try again in a moment.`,retryable:!0}:void 0:ec.has(tc(e))?$s:void 0}function rc(){let e=Ee(),[t,n]=(0,G.useState)(!1);return(0,K.jsxs)(H,{type:`button`,variant:`outline`,disabled:t,onClick:()=>{n(!0),e.invalidate().finally(()=>n(!1))},children:[(0,K.jsx)(Zo,{className:t?`animate-spin`:void 0}),` `,t?`Trying Again…`:`Try Again`]})}function ic(e){return typeof e==`string`?e.length>0:typeof e==`number`||(0,G.isValidElement)(e)?!0:Array.isArray(e)?e.length>0&&e.every(ic):!1}function ac(e){try{if(e instanceof Error)return e.message.length>0?e.message:Ys;if(typeof e==`object`&&e&&`message`in e){let t=e.message;return ic(t)?t:Ys}if(ic(e))return e}catch{return Ys}return Ys}function oc({className:e,error:t,title:n,description:r,showReturnToHome:i,reset:a,children:o}){let{user:s,isLoading:c}=xr();Pr(s);let l=nc(t),u=a!==void 0&&l?.retryable===!0;return(0,K.jsxs)(Er,{"data-testid":`error-component`,className:F(`text-red p-5 border border-red rounded-md m-12 mt-36`,e),children:[(0,K.jsxs)(Dr,{children:[(0,K.jsx)(Or,{className:`text-2xl`,children:(0,K.jsx)(`h2`,{children:n??l?.title??Xs})}),(0,K.jsx)(kr,{children:r??l?.description??ac(t)})]}),(0,K.jsxs)(Ar,{children:[o,(u||i!==!1)&&(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[u&&(0,K.jsx)(rc,{}),i!==!1&&(s&&!c?(0,K.jsx)(V,{to:`/`,children:(0,K.jsxs)(H,{children:[` `,(0,K.jsx)(Hr,{}),` Return to Home`]})}):(0,K.jsx)(V,{to:`/sign-in`,children:(0,K.jsxs)(H,{children:[` `,(0,K.jsx)(Hr,{}),` Go to Sign In Page`]})}))]})]})]})}function sc(){let{user:e,isLoading:t}=xr();return Pr(e),(0,K.jsx)(`div`,{className:`flex items-center justify-center h-screen px-3`,children:(0,K.jsxs)(Er,{className:`text-red p-5 border border-red rounded-md w-full max-w-md`,children:[(0,K.jsx)(Dr,{children:(0,K.jsx)(Or,{className:`text-2xl`,children:(0,K.jsx)(`h2`,{children:`Sorry, Page Not Found`})})}),(0,K.jsx)(Ar,{children:e&&!t?(0,K.jsx)(V,{to:`/`,children:(0,K.jsxs)(H,{children:[` `,(0,K.jsx)(Hr,{}),` Return to Home`]})}):(0,K.jsx)(V,{to:`/sign-in`,children:(0,K.jsxs)(H,{children:[` `,(0,K.jsx)(Hr,{}),` Go Sign In Page`]})})})]})})}function cc(){return`ontouchstart`in window||navigator.maxTouchPoints>0}var lc=new WeakMap;function uc(e,t){if(t.aborted)return()=>void 0;lc.set(e,(lc.get(e)??0)+1);let n=!1,r=()=>{if(n)return;n=!0,t.removeEventListener(`abort`,r);let i=(lc.get(e)??1)-1;i>0?lc.set(e,i):lc.delete(e)};return t.addEventListener(`abort`,r),r}function dc(e){return lc.has(e)}function fc(e){if(or(e))return{title:cr,description:ur,message:ur};if(e instanceof lr)return{title:sr,description:dr,message:dr};let t=`Error`,n=`We had some trouble!`,r=!0,i=e,a=e;if(typeof e==`string`)n=e;else if(i?.response?.data){let e=i.response.data;if(typeof e==`string`)n=e;else if(typeof e.title==`string`&&e.title){typeof e.code==`string`&&e.code&&(t=e.code);let i=pr(e.detail);n=i?`${e.title}: ${i}`:e.title,r=!1}else n=pr(e.error)??pr(e.message)??n}else n=pr(a?.message)??n;let o=n;if(r&&n.includes(`:`)&&!n.startsWith(`{`)&&!n.startsWith(`[`)){let e=n.split(`:`);t=e.shift(),n=e.join(`:`)}return{title:t,description:n,message:o}}function pc(e){return!or(e)&&!(e instanceof lr)}function mc(e){console.error(e);let{title:t,description:n}=fc(e),r=e,i=r?.code===`ECONNABORTED`||r?.code===`ETIMEDOUT`,a=r?.response?.status===403,o=or(e)?void 0:i?`request-timeout`:a?`request-forbidden`:void 0;U.error(t,{id:o,description:n,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}var hc=new Te({queryCache:new Fe({onError:(e,t)=>{if(ue(e,t.queryKey)){console.debug(`Suppressed a failure from a restarting entity`,e);return}if(!dc(t)){if(t.meta?.inlineSearchError&&t.getObserversCount()===0){console.error(e);return}mc(e)}}}),mutationCache:new Pe({onError:(e,t,n,r)=>{r.meta?.skipGlobalErrorToast||mc(e)}})});fe(e=>void mr(hc,e,void 0,{cancelRefetch:!1}));function gc({...e}){return(0,K.jsx)(Jn,{"data-slot":`dropdown-menu`,...e})}function _c({...e}){return(0,K.jsx)(Pt,{"data-slot":`dropdown-menu-trigger`,...e})}function vc({className:e,sideOffset:t=4,...n}){return(0,K.jsx)(gt,{children:(0,K.jsx)(wt,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:F(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border p-1 shadow-md`,e),...n})})}function yc({className:e,inset:t,variant:n=`default`,...r}){return(0,K.jsx)(St,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:F(`focus:bg-accent focus:text-grey`,`data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10`,`dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive`,`data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground`,`relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm`,`outline-hidden select-none`,`data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r})}function bc({className:e,children:t,checked:n,...r}){return(0,K.jsxs)(Yt,{"data-slot":`dropdown-menu-checkbox-item`,className:F(`focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm`,`py-1.5 pr-2 pl-8`,`text-sm outline-hidden`,`select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),checked:n,...r,children:[(0,K.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,K.jsx)(Bt,{children:(0,K.jsx)(tr,{className:`size-4`})})}),t]})}function xc({...e}){return(0,K.jsx)(Cn,{"data-slot":`dropdown-menu-radio-group`,...e})}function Sc({className:e,children:t,...n}){return(0,K.jsxs)(It,{"data-slot":`dropdown-menu-radio-item`,className:F(`focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[(0,K.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,K.jsx)(Bt,{children:(0,K.jsx)(Ii,{className:`size-2 fill-current`})})}),t]})}function Cc({className:e,inset:t,...n}){return(0,K.jsx)(Tn,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:F(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function wc({className:e,...t}){return(0,K.jsx)(Rt,{"data-slot":`dropdown-menu-separator`,className:F(`bg-border -mx-1 my-1 h-px`,e),...t})}function Tc({className:e,...t}){return(0,K.jsx)(`span`,{"data-slot":`dropdown-menu-shortcut`,className:F(`text-muted-foreground ml-auto text-xs tracking-widest`,e),...t})}function Ec({...e}){return(0,K.jsx)(Ht,{"data-slot":`dropdown-menu-sub`,...e})}function Dc({className:e,inset:t,children:n,...r}){return(0,K.jsxs)(At,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:F(`focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground`,`flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none`,`data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0`,`[&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,K.jsx)(Si,{className:`ml-auto size-4`})]})}function Oc({className:e,...t}){return(0,K.jsx)(Et,{"data-slot":`dropdown-menu-sub-content`,className:F(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg`,e),...t})}var kc=`flex items-center gap-3 p-2 rounded-lg text-sm transition-colors`,Ac=`block p-2 rounded-lg text-sm transition-colors`,jc={className:`text-foreground hover:bg-accent dark:text-white dark:hover:bg-grey-700`},Mc={className:`font-medium text-primary bg-primary/10 dark:text-white dark:bg-white/10`};function Nc({items:e,ariaLabel:t}){let{pathname:n}=ze(),r=e=>e.exact?n===e.to:n.startsWith(e.to),i=e.find(r)??e[0],a=i.icon;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`nav`,{className:`studio-section-rail hidden md:flex flex-col gap-1`,"aria-label":t,children:e.map(e=>{let t=e.icon;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(V,{to:e.to,className:kc,activeOptions:{exact:!!e.exact},activeProps:Mc,inactiveProps:jc,children:[(0,K.jsx)(t,{className:`size-4 shrink-0`}),e.label]}),e.children&&r(e)&&(0,K.jsx)(`div`,{className:`mt-1 ml-4 flex flex-col gap-1 border-l border-border pl-3`,children:e.children.map(e=>(0,K.jsx)(V,{to:e.to,className:Ac,activeOptions:{exact:!!e.exact},activeProps:Mc,inactiveProps:jc,children:e.label},e.to))})]},e.to)})}),(0,K.jsx)(`div`,{className:`md:hidden`,children:(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsxs)(H,{variant:`outline`,className:`w-full justify-between`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(a,{className:`size-4`}),i.label]}),(0,K.jsx)(er,{className:`size-4`})]})}),(0,K.jsx)(vc,{align:`start`,className:`w-(--radix-dropdown-menu-trigger-width)`,children:e.map(e=>{let t=e.icon;return[(0,K.jsx)(yc,{asChild:!0,children:(0,K.jsxs)(V,{to:e.to,className:`flex items-center gap-2`,children:[(0,K.jsx)(t,{className:`size-4`}),e.label]})},e.to),...e.children&&r(e)?e.children.map(e=>(0,K.jsx)(yc,{asChild:!0,children:(0,K.jsx)(V,{to:e.to,className:`flex items-center gap-2 pl-8`,children:e.label})},e.to)):[]]})})]})})]})}var Pc=[{to:`/admin/notifications`,label:`Notifications`,icon:ni,permission:`systemStatus:write`},{to:`/admin/regions`,label:`Regions`,icon:Aa,permission:`region:read`},{to:`/admin/api-token`,label:`API Token`,icon:Ha,permission:`apiToken:create`,ssoAccountOnly:!0}];function Fc(e){let t=e!==null&&`fabricRole`in e&&e.fabricRole===`super_user`;return Pc.filter(n=>Cr(e,n.permission)&&!(n.ssoAccountOnly&&t))}function Ic(){let{isLoading:e,user:t}=Sr(),{pathname:n}=ze();if(e)return null;let r=Fc(t);if(!r.length)return(0,K.jsx)(qe,{to:`/`,replace:!0});let i=Pc.find(e=>n.startsWith(e.to));return i&&!r.includes(i)?(0,K.jsx)(qe,{to:r[0].to,replace:!0}):(0,K.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsxs)(`div`,{className:`md:grid gap-6 md:grid-cols-12`,children:[(0,K.jsx)(`aside`,{className:`md:col-span-3 lg:col-span-2 mb-4 md:mb-0`,children:(0,K.jsx)(Nc,{items:r,ariaLabel:`Admin sections`})}),(0,K.jsx)(`section`,{className:`md:col-span-9 lg:col-span-10 min-w-0`,children:(0,K.jsx)(st,{})})]})})}function Lc({className:e,text:t,centered:n,...r}){return(0,K.jsxs)(`div`,{className:`text-foreground h-full w-full ${e||``} ${n?`flex flex-col items-center justify-center`:``}`,...r,children:[(0,K.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`100px`,height:`100px`,alt:`HDB Dog Logo Loading`,className:`inline-block`}),(0,K.jsx)(`p`,{className:`pt-4`,children:t||`Loading...`})]})}function Rc(e){return jr(e)===403}function zc(e){let t=jr(e);return t===400||t===403}var Bc=3e5,Vc=6e4,Hc=new WeakMap;function Uc(e){return e!==void 0&&e>=500&&e<600}function Wc(e,t,n){let{errorUpdatedAt:r,dataUpdatedAt:i=0}=e.state;if(!Number.isFinite(r))return t;let a=Hc.get(e);(a===void 0||a<i)&&(a=r,Hc.set(e,a));let o=r-a-n;return Math.min(Math.max(t,o),Math.max(t,Bc))}function Gc(e){return t=>{let n=jr(t.state.error);return n===403?!1:e?n===400?Wc(t,e,0):Uc(n)?Wc(t,e,Vc):e:e??!1}}function Kc(e=3){return(t,n)=>!zc(n)&&t<e}function qc(e){return!!e&&e!==`undefined`&&e!==`null`}async function Jc(e){if(!qc(e))throw Error(`getOrganization called without a valid organization id (got: ${e})`);let{data:t}=await P.get(`/Organization/${e}`);return t}function Yc(e){return B({queryKey:[e],queryFn:()=>Jc(e),retry:!1,enabled:qc(e),refetchInterval:Gc(1e4)})}function Xc(){let{user:e}=Sr(),{organizationId:t}=z({strict:!1});(0,G.useMemo)(()=>Nr(e),[e]);let{data:n}=L({...Yc(t),enabled:!1});return null}function Zc(e,t){let n=(0,G.useState)(gr(e,t)),[r]=n;return(0,G.useEffect)(()=>hr(e,r),[e,r]),n}function Qc(){let[e,t]=(0,G.useState)(()=>window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`);return(0,G.useEffect)(()=>{let e=window.matchMedia(`(prefers-color-scheme: dark)`),n=e=>t(e.matches?`dark`:`light`);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var $c=(0,G.createContext)([`system`,()=>{}]);function el({children:e}){let[t,n]=Zc(_r.Theme,`system`),r=Qc();return(0,G.useEffect)(()=>{let e=t===`dark`||t===`system`&&r===`dark`;document.documentElement.classList.toggle(`dark`,e)},[t,r]),(0,K.jsx)($c.Provider,{value:[t,n],children:e})}function tl(){return(0,G.useContext)($c)}function nl({user:e,onSignOut:t,signingOut:n}){let[r,i]=tl(),{organizationId:a}=z({strict:!1}),o=Mr(e)?e.username:[e.firstname,e.lastname].filter(Boolean).join(` `)||e.email,s=o.trim().split(/\s+/).slice(0,2).map(e=>e[0]).join(``).toUpperCase();return(0,G.useMemo)(()=>Nr(e).some(e=>!e.locked&&e.id!==a),[e,a]),(0,K.jsxs)(gc,{children:[(0,K.jsxs)(_c,{"aria-label":`Account menu`,className:`ml-2 inline-flex items-center gap-2 rounded-full border border-primary/25 bg-card/50 p-1 pr-2 text-foreground hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,K.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full bg-primary/15 text-xs font-semibold text-primary dark:text-violet-200`,children:s||(0,K.jsx)(Hs,{className:`size-4`})}),(0,K.jsx)(er,{className:`size-3.5`,"aria-hidden":`true`})]}),(0,K.jsxs)(vc,{align:`end`,className:`w-64`,children:[(0,K.jsx)(Cc,{className:`truncate`,title:o,children:o}),!Mr(e)&&o!==e.email&&(0,K.jsx)(`p`,{className:`truncate px-2 pb-2 text-xs text-muted-foreground`,title:e.email,children:e.email}),(0,K.jsx)(wc,{}),!1,(0,K.jsxs)(Ec,{children:[(0,K.jsxs)(Dc,{children:[(0,K.jsx)(Lo,{className:`size-4`}),`Appearance`]}),(0,K.jsx)(Oc,{children:(0,K.jsxs)(xc,{value:r,onValueChange:e=>{(e===`light`||e===`dark`||e===`system`)&&i(e)},children:[(0,K.jsx)(Sc,{value:`light`,children:`Light`}),(0,K.jsx)(Sc,{value:`system`,children:`System`}),(0,K.jsx)(Sc,{value:`dark`,children:`Dark`})]})})]}),(0,K.jsx)(wc,{}),(0,K.jsxs)(yc,{disabled:n,onSelect:t,children:[(0,K.jsx)(uo,{className:`size-4`}),n?`Signing out…`:`Sign Out`]})]})]})}function rl(){return(0,K.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 126.644 96`,width:24,height:24,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M81.15,0c-1.2376,2.1973-2.3489,4.4704-3.3591,6.794-9.5975-1.4396-19.3718-1.4396-28.9945,0-.985-2.3236-2.1216-4.5967-3.3591-6.794-9.0166,1.5407-17.8059,4.2431-26.1405,8.0568C2.779,32.5304-1.6914,56.3725.5312,79.8863c9.6732,7.1476,20.5083,12.603,32.0505,16.0884,2.6014-3.4854,4.8998-7.1981,6.8698-11.0623-3.738-1.3891-7.3497-3.1318-10.8098-5.1523.9092-.6567,1.7932-1.3386,2.6519-1.9953,20.281,9.547,43.7696,9.547,64.0758,0,.8587.7072,1.7427,1.3891,2.6519,1.9953-3.4601,2.0457-7.0718,3.7632-10.835,5.1776,1.97,3.8642,4.2683,7.5769,6.8698,11.0623,11.5419-3.4854,22.3769-8.9156,32.0509-16.0631,2.626-27.2771-4.496-50.9172-18.817-71.8548C98.9811,4.2684,90.1918,1.5659,81.1752.0505l-.0252-.0505ZM42.2802,65.4144c-6.2383,0-11.4159-5.6575-11.4159-12.6535s4.9755-12.6788,11.3907-12.6788,11.5169,5.708,11.4159,12.6788c-.101,6.9708-5.026,12.6535-11.3907,12.6535ZM84.3576,65.4144c-6.2637,0-11.3907-5.6575-11.3907-12.6535s4.9755-12.6788,11.3907-12.6788,11.4917,5.708,11.3906,12.6788c-.101,6.9708-5.026,12.6535-11.3906,12.6535Z`})})}function il(){let e=`studio`,t=`Harper Studio`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`img`,{src:`/harper-${e}_black.png`,alt:t,className:`w-64 hidden md:inline-block dark:hidden`}),(0,K.jsx)(`img`,{src:`/harper-${e}_white.png`,alt:t,className:`w-64 hidden md:dark:inline-block`}),(0,K.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`50px`,height:`44px`,alt:`Harper`,className:`inline-block md:hidden`})]})}var al=y(`inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-auto`,{variants:{variant:{default:`border-primary bg-primary/40 text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`border-secondary bg-secondary/40 text-secondary-foreground [a&]:hover:bg-secondary/90`,warning:`border-yellow bg-yellow/40 text-foreground [a&]:hover:bg-yellow/90`,success:`border-green bg-green/40 text-foreground [a&]:hover:bg-green/90`,destructive:`border-transparent bg-red-600 text-white [a&]:hover:bg-red-700 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40`,outline:`text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`}},defaultVariants:{variant:`default`}});function ol({className:e,variant:t,asChild:n=!1,...r}){return(0,K.jsx)(n?vt:`span`,{"data-slot":`badge`,className:F(al({variant:t}),e),...r})}function sl({className:e,children:t,...n}){return(0,K.jsxs)(Qn,{"data-slot":`scroll-area`,className:F(`relative`,e),...n,children:[(0,K.jsx)(bt,{"data-slot":`scroll-area-viewport`,className:`focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1`,children:t}),(0,K.jsx)(cl,{}),(0,K.jsx)(cn,{})]})}function cl({className:e,orientation:t=`vertical`,...n}){return(0,K.jsx)(Xn,{"data-slot":`scroll-area-scrollbar`,orientation:t,className:F(`flex touch-none p-px transition-colors select-none`,t===`vertical`&&`h-full w-2.5 border-l border-l-transparent`,t===`horizontal`&&`h-2.5 flex-col border-t border-t-transparent`,e),...n,children:(0,K.jsx)(qt,{"data-slot":`scroll-area-thumb`,className:`bg-border relative flex-1 rounded-full`})})}var ll=[`notification-acks`];function ul(){let e=gr(_r.AckedNotificationIds,[]);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function dl(e){hc.setQueryData(ll,e);try{hr(_r.AckedNotificationIds,e)}catch(e){console.warn(`[notifications] could not persist acknowledgements`,e)}}function fl(){return B({queryKey:ll,queryFn:ul,staleTime:1/0,gcTime:1/0,initialData:ul})}function pl(e){dl(Array.from(new Set([...ul(),e])))}function ml(e){dl(ul().filter(t=>t!==e))}function hl(){let{data:e}=L(fl());return(0,G.useMemo)(()=>new Set(e??[]),[e])}var gl={critical:{severity:`critical`,label:`Critical`,Icon:No,badgeVariant:`destructive`,bannerClass:`bg-destructive/10 border-destructive/40 text-foreground`,iconClass:`text-destructive`},warning:{severity:`warning`,label:`Warning`,Icon:Rs,badgeVariant:`warning`,bannerClass:`bg-yellow/10 border-yellow/40 text-foreground`,iconClass:`text-yellow`},info:{severity:`info`,label:`Info`,Icon:Ba,badgeVariant:`secondary`,bannerClass:`bg-secondary/20 border-secondary/50 text-foreground`,iconClass:`text-secondary-foreground`}},_l=new Set([`critical`,`error`,`outage`,`incident`,`down`,`danger`]),vl=new Set([`warning`,`warn`,`maintenance`,`degraded`,`notice`]),yl=new Set([`info`,`information`,`informational`,`success`,`ok`]);function bl(e){let t=(e??``).trim().toLowerCase();return vl.has(t)?`warning`:yl.has(t)?`info`:(_l.has(t),`critical`)}function xl(e){return gl[bl(e)]}var Sl={critical:0,warning:1,info:2};function Cl(e){if(e==null)return{kind:`absent`};if(typeof e==`number`)return Number.isFinite(e)?{kind:`valid`,ms:e}:{kind:`invalid`};if(typeof e!=`string`)return{kind:`invalid`};let t=e.trim();if(!t)return{kind:`absent`};if(/^\d+$/.test(t))return{kind:`valid`,ms:Number(t)};let n=Date.parse(t);return Number.isNaN(n)?{kind:`invalid`}:{kind:`valid`,ms:n}}function wl(e){let t=Cl(e);return t.kind===`valid`?t.ms:null}function Tl(e){return new Date(e).toLocaleString()}function El(e,t){let n=Cl(e.startAt),r=Cl(e.endAt);return n.kind===`invalid`||r.kind===`invalid`?{state:`expired`,label:`Schedule unavailable`}:n.kind===`valid`&&t<n.ms?{state:`upcoming`,label:`Starts ${Tl(n.ms)}`}:r.kind===`valid`&&t>r.ms?{state:`expired`,label:`Ended ${Tl(r.ms)}`}:r.kind===`valid`?{state:`active`,label:`Active until ${Tl(r.ms)}`}:{state:`active`,label:`Active`}}var Dl=new Set([`http`,`https`,`mailto`]);function Ol(e){if(!e)return null;let t=e.trim();if(!t)return null;if(t.startsWith(`//`))return{kind:`external`,href:t};let n=t.match(/^([a-z][a-z0-9+.-]*):/i)?.[1]?.toLowerCase();return n?Dl.has(n)?{kind:`external`,href:t}:null:{kind:`internal`,href:t.startsWith(`/`)?t:`/${t}`}}function kl({url:e,className:t,children:n,onNavigate:r}){let i=Ol(e);return i?i.kind===`external`?(0,K.jsxs)(`a`,{href:i.href,target:`_blank`,rel:`noreferrer noopener`,className:t,children:[n??`Learn more`,(0,K.jsx)(fa,{className:`inline size-3 ml-1 align-[-1px]`})]}):(0,K.jsx)(V,{to:i.href,className:t,onClick:r,children:n??`View details`}):null}var Al=[`system-status`];async function jl(){let{data:e}=await P.get(`/SystemStatus/`);return Array.isArray(e)?e:[]}function Ml(){return B({queryKey:Al,queryFn:jl,refetchInterval:6e4,staleTime:3e4})}var Nl=3e4,Pl=new Set,Fl=Date.now(),Il=null;function Ll(e){return Pl.add(e),Il||=(Fl=Date.now(),setInterval(()=>{Fl=Date.now(),Pl.forEach(e=>e())},Nl)),()=>{Pl.delete(e),Pl.size===0&&Il&&(clearInterval(Il),Il=null)}}function Rl(){return(0,G.useSyncExternalStore)(Ll,()=>Fl,()=>Fl)}function zl(){return L(Ml())}var Bl=[{value:`light`,icon:(0,K.jsx)(ws,{className:`size-4`}),label:`Light`},{value:`system`,icon:(0,K.jsx)(Do,{className:`size-4`}),label:`System`},{value:`dark`,icon:(0,K.jsx)(ko,{className:`size-4`}),label:`Dark`}];function Vl(){let[e,t]=tl();return(0,K.jsx)(`div`,{className:`flex items-center bg-muted dark:bg-black rounded-xl p-0.5 gap-0.5`,children:Bl.map(({value:n,icon:r,label:i})=>(0,K.jsx)(`button`,{type:`button`,title:i,onClick:()=>t(n),className:`p-1.5 rounded-lg transition-colors ${e===n?`bg-background text-foreground shadow-xs`:`text-muted-foreground hover:text-foreground`}`,children:r},n))})}function Hl({className:e,...t}){return(0,K.jsx)(`div`,{className:F(`absolute top-full left-0 isolate z-50 flex justify-center`),children:(0,K.jsx)(Kn,{"data-slot":`navigation-menu-viewport`,className:F(`origin-top-center bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border shadow md:w-[var(--radix-navigation-menu-viewport-width)]`,e),...t})})}function Ul({className:e,children:t,viewport:n=!0,...r}){return(0,K.jsxs)(kn,{"data-slot":`navigation-menu`,"data-viewport":n,className:F(`group/navigation-menu relative flex max-w-max flex-1 items-center justify-center`,e),...r,children:[t,n&&(0,K.jsx)(Hl,{})]})}function Wl({className:e,...t}){return(0,K.jsx)(yn,{"data-slot":`navigation-menu-item`,className:F(`relative`,e),...t})}function Gl({className:e,...t}){return(0,K.jsx)(_n,{"data-slot":`navigation-menu-link`,className:F(`hover:text-foreground dark:hover:text-white ring-ring/10 dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 flex flex-col gap-1 rounded-sm p-2 text-sm transition-[color,box-shadow] focus-visible:ring-4 focus-visible:outline-1 [&_svg:not([class*='size-'])]:size-4`,e),...t})}function Kl({className:e,...t}){return(0,K.jsx)(rn,{"data-slot":`navigation-menu-list`,className:F(`group flex flex-1 list-none items-center justify-center gap-1`,e),...t})}function ql({delayDuration:e=0,...t}){return(0,K.jsx)(hn,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Jl({...e}){return(0,K.jsx)(ql,{children:(0,K.jsx)(un,{"data-slot":`tooltip`,...e})})}function Yl({...e}){return(0,K.jsx)(Fn,{"data-slot":`tooltip-trigger`,...e})}function Xl({className:e,sideOffset:t=0,arrowClassName:n,children:r,...i}){return(0,K.jsx)(fn,{children:(0,K.jsxs)(Wn,{"data-slot":`tooltip-content`,sideOffset:t,className:F(`bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance`,e),...i,children:[r,(0,K.jsx)(Dn,{className:F(`bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`,n)})]})})}function Zl(){let e=`v5.3.4`,t=e.startsWith(`v`)?`https://github.com/HarperFast/studio/releases/tag/${e}`:`https://github.com/HarperFast/studio/releases`;return(0,K.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,children:(0,K.jsxs)(`span`,{className:F(al({variant:`default`}),`text-xs inline-block ml-2 align-text-top`),children:[e,` BETA`]})})}function Ql(e={}){let{instanceId:t,clusterId:r}=z({strict:!1});return n({id:m,...e})}function $l(e={}){let{instanceId:t,clusterId:r}=z({strict:!1});return{instanceClient:n({id:m,...e}),entityType:`instance`}}function q(e={}){let{instanceId:t,clusterId:n}=z({strict:!1});return(0,G.useMemo)(()=>eu({instanceId:t,clusterId:n,...e}),[e.instanceId??t,e.clusterId??n,e.operationsUrl,e.port,e.secure,e.disableFabricConnect,e.forceFabricConnect])}function eu({instanceId:e,clusterId:t,...r}){let i=m;if(!i)throw Error(`id could not be automatically calculated in useInstanceClientIdParams`);return{instanceClient:n({id:i,...r}),entityId:i,entityType:`instance`}}function tu(){localStorage.clear()}var nu=new Map,ru=new Map;function iu(e){for(let t of ru.get(e)??[])t()}function au(e,t){let n=`stored`;try{ft(e,t)}catch(t){n=`refused`,nu.get(e)?.state!==`refused`&&console.warn(`sessionStorage refused a write; keeping the value in memory only`,t)}nu.set(e,{value:t,state:n})}function ou(e,t){let n=nu.get(e);if(!n||n.state==="default"&&!ru.has(e)){let r=dt(e,void 0);n={value:r===void 0?t:r,state:r===void 0?`default`:`stored`},nu.set(e,n)}return n}function su(){return[...nu].filter(([,e])=>e.state===`refused`).map(([e])=>e)}function cu(e,t){return ou(e,t).value}function lu(e,t,n){let r=cu(e,t),i=typeof n==`function`?n(r):n;Object.is(i,r)||(au(e,i),iu(e))}function uu(e,t,n){let r=ru.get(e);if(!r){let n=ou(e,t);n.state!==`stored`&&au(e,n.value),r=new Set,ru.set(e,r)}return r.add(n),()=>{r.delete(n),r.size||(ru.delete(e),nu.get(e)?.state!==`refused`&&nu.delete(e))}}function du(){nu.clear();for(let e of ru.keys())iu(e)}typeof window<`u`&&window.addEventListener(`storage`,e=>{e.storageArea===sessionStorage&&(e.key===null?du():nu.delete(e.key)&&iu(e.key))});function fu(){try{sessionStorage.clear()}finally{du()}}function pu(){hu([()=>u.signOutAllLocally(),()=>hc.getMutationCache().clear(),()=>hc.getQueryCache().clear(),tu,fu])}function mu(){hu([()=>u.forgetAppSignInEndedElsewhere(),()=>hc.getMutationCache().clear(),()=>hc.getQueryCache().clear(),fu])}function hu(e){for(let t of e)try{t()}catch(e){console.error(e)}}async function gu(){pu(),await hc.invalidateQueries({refetchType:`none`})}async function _u(e){await u.signOutFromPotentiallyAuthenticatedInstances(),await d({...e,entityId:m})}function vu(){let e=Ql();return I({mutationFn:()=>_u({instanceClient:e}),onSuccess:gu})}(0,G.lazy)(()=>pe(()=>import(`./SearchDialog-CdlNxWef.js`).then(e=>({default:e.SearchDialog})),__vite__mapDeps([0,1,2,3,4])));var yu=(0,G.createContext)(null);function bu(){let e=(0,G.useContext)(yu);return e?(0,K.jsxs)(`button`,{type:`button`,onClick:e,"aria-label":`Search organizations and clusters`,className:`inline-flex cursor-pointer items-center gap-2 rounded-lg border border-primary/20 bg-card/30 p-2 text-sm text-muted-foreground hover:bg-primary/15 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,K.jsx)(rs,{className:`size-4`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`hidden lg:inline`,children:`Search`}),(0,K.jsx)(`kbd`,{className:`hidden xl:inline rounded border border-border px-1 text-xs`,children:`⌘ / Ctrl K`})]}):null}var xu={className:`text-foreground dark:text-white font-semibold`};function Su(){let{mutate:e,isPending:t}=vu(),n=De(),{user:r}=xr(),i=Ee(),a=(0,G.useCallback)(()=>{e(void 0,{onSuccess:async()=>{U.success(`Success`,{description:`You have been signed out successfully.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),n({to:`/sign-in`}),i.invalidate()}})},[e,i,n]),o=(0,G.useMemo)(()=>[{to:`https://docs.harperdb.io/docs`,target:`_blank`,icon:(0,K.jsx)(ii,{}),text:`Docs`,textBreakpoint:`md`},{to:`https://github.com/HarperFast/studio/issues`,target:`_blank`,icon:(0,K.jsx)(ui,{}),text:`Report an Issue`,textBreakpoint:`lg`},{to:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,icon:(0,K.jsx)(rl,{}),text:`Discord`,textBreakpoint:`lg`}],[]);return r?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Du,{menuItems:o,user:r,accountMenu:(0,K.jsx)(nl,{user:r,onSignOut:a,signingOut:t})}),(0,K.jsx)(Tu,{menuItems:o,user:r,accountMenu:(0,K.jsx)(nl,{user:r,onSignOut:a,signingOut:t})})]}):(0,K.jsx)(wu,{})}function Cu(e){return e.items!==void 0}function wu(){return(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`inline-block`,children:[(0,K.jsx)(V,{to:`/sign-in`,children:(0,K.jsx)(il,{})}),(0,K.jsx)(Zl,{})]}),(0,K.jsx)(Ul,{children:(0,K.jsxs)(Kl,{className:`text-muted-foreground dark:text-grey-400`,children:[(0,K.jsx)(Wl,{children:(0,K.jsx)(Gl,{asChild:!0,children:(0,K.jsxs)(V,{to:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noreferrer noopener`,className:`flex-row items-center`,children:[(0,K.jsx)(ii,{}),` `,(0,K.jsx)(`span`,{className:`hidden md:inline-block`,children:`Docs`})]})})}),(0,K.jsx)(Wl,{children:(0,K.jsx)(Vl,{})}),(0,K.jsx)(Wl,{children:(0,K.jsx)(Gl,{asChild:!0,children:(0,K.jsxs)(V,{to:`/sign-in`,className:`flex-row items-center`,activeProps:xu,children:[(0,K.jsx)(co,{}),` Sign In`]})})})]})})]})}function Tu({menuItems:e,accountMenu:t,user:n}){return(0,G.useMemo)(()=>Pr(n),[n]),(0,K.jsx)(`div`,{className:`hidden md:[@media(hover:hover)]:block xl:block`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`inline-block`,children:[(0,K.jsx)(V,{to:`/`,children:(0,K.jsx)(il,{})}),(0,K.jsx)(Zl,{})]}),(0,K.jsx)(Ul,{children:(0,K.jsxs)(Kl,{className:`text-muted-foreground dark:text-grey-400`,children:[!1,e.map(e=>Cu(e)?!!e.items.length&&(0,K.jsx)(`div`,{className:`bg-muted dark:bg-black rounded-2xl flex`,children:e.items.map(e=>(0,K.jsx)(Eu,{menuItem:e},e.text))},e.text):(0,K.jsx)(Eu,{menuItem:e},e.text)),!1,(0,K.jsx)(Wl,{children:t})]})})]})})}function Eu({menuItem:e}){return(0,K.jsx)(Wl,{className:`text-muted-foreground dark:text-gray-400 hover:text-foreground dark:hover:text-white`,children:(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(Gl,{asChild:!0,children:(0,K.jsxs)(V,{to:e.to,onClick:e.onClick,"aria-label":e.text,className:`flex-row items-center`,target:e.target,activeProps:e.to?xu:void 0,children:[e.icon,(0,K.jsx)(`span`,{className:`hidden ${e.textBreakpoint}:inline-block`,children:e.text}),(0,K.jsx)(`span`,{className:`${e.textBreakpoint}:hidden`,children:`\xA0`})]})})}),(0,K.jsx)(Xl,{side:`bottom`,className:`${e.textBreakpoint}:hidden`,children:e.text})]})})}function Du({menuItems:e,accountMenu:t,user:n}){(0,G.useMemo)(()=>Pr(n),[n]);let[r,i]=(0,G.useState)(!1),a=(0,G.useCallback)(()=>i(e=>!e),[]),o=(0,G.useCallback)(()=>i(!1),[]);return(0,K.jsxs)(`div`,{className:`md:[@media(hover:hover)]:hidden xl:hidden`,id:`mobile-menu`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(V,{to:`/`,children:(0,K.jsx)(il,{})}),(0,K.jsx)(Zl,{}),(0,K.jsxs)(`div`,{className:`flex items-center`,children:[(0,K.jsx)(bu,{}),!1,t,(0,K.jsxs)(`button`,{type:`button`,className:`shadow-xs text-muted-foreground dark:text-grey-400 hover:text-foreground dark:hover:text-white hover:bg-muted dark:hover:bg-black-dark`,onClick:a,children:[(0,K.jsx)(`span`,{className:`sr-only`,children:r?`Close menu`:`Open menu`}),r?(0,K.jsx)(Ks,{}):(0,K.jsx)(Co,{})]})]})]}),(0,K.jsx)(`div`,{className:`${r?`fixed`:`hidden`} top-40 bottom-0 left-0 right-0 bg-foreground/20 dark:bg-black-dark dark:opacity-70`,onClick:o}),(0,K.jsx)(`div`,{className:`${r?`block`:`hidden`} md:hidden z-50 space-y-1 pb-3 bg-card border-b border-border dark:bg-black-dark dark:border-none absolute left-0 top-full w-full rounded-b-md`,children:e.map(e=>Cu(e)?!!e.items.length&&(0,K.jsx)(`div`,{className:`bg-muted dark:bg-black pl-10 pr-2 py-2`,children:e.items.map(e=>(0,K.jsx)(Ou,{menuItem:e,onClick:o},e.text))},e.text):(0,K.jsx)(Ou,{menuItem:e,onClick:o},e.text))})]})}function Ou({menuItem:e,onClick:t}){let n=(0,G.useCallback)(()=>{e.onClick?.(),t()},[e,t]);return(0,K.jsxs)(V,{to:e.to,onClick:n,target:e.target,className:`flex flex-row px-3 py-2 text-base font-medium rounded-md text-muted-foreground dark:text-gray-400 hover:text-foreground dark:hover:text-white`,activeProps:e.to?xu:void 0,children:[e.icon,(0,K.jsx)(`span`,{className:`ml-4`,children:e.text})]})}function ku(){let{isLoading:e,user:t}=xr(),{createCluster:n}=Oe({strict:!1}),[,r]=Zc(_r.SavedClusterState,null);return(0,G.useEffect)(()=>{n&&r(n)},[n,r]),e||!t?(0,K.jsx)(Lc,{className:`fixed z-50 translate-1/2`}):(0,K.jsxs)(`div`,{className:`studio-shell`,children:[(0,K.jsx)(`header`,{className:`studio-shell-header fixed top-0 z-40 w-full h-20 p-4 md:px-12`,children:(0,K.jsx)(Su,{})}),(0,K.jsx)(`main`,{children:(0,K.jsx)(st,{})})]})}function Au(){let e=location.hash;return e?e.startsWith(`#/`)?e.slice(1):e:`/`}var ju=[`/`,`/forgot-password`,`/reset-password`,`/sign-in`,`/sign-up`,`/verify-email`];function Mu(){let e=Au();return!ju.includes(e)&&{redirect:e}}var Nu={isLoading:!1,user:null};function Pu(e){return u.isKnownSignedOut(`OverallAppSignIn`)?Nu:e.authentication[m]}var Fu=`me|email|token|access_token|id_token|refresh_token|code|secret|password|api[-_]?key`,Iu=String.raw`[^&#\s",<>[\]{}|\\]+`,Lu=String.raw`[\w.%+!~*'()-]+(?:@|%40)[\w-]+(?:\.[\w-]+)*\.\w{2,}`;new RegExp(String.raw`([?&](?:${Fu})=)${Iu}`,`gi`),new RegExp(String.raw`([?&](?:${Fu})=)${Iu}|${Lu}`,`gi`);var Ru=String.raw`[\w-]+-extension`;new RegExp(String.raw`^${Ru}://`),new RegExp(String.raw`^\s*at\s.* @ ((?:blob:)?(?:https?|${Ru})://\S*)\s*$`);var zu=!1;function Bu(){(0,G.useEffect)(()=>{zu||=!0},[])}function Vu(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(lt,{}),(0,K.jsx)(st,{})]})}var Hu=Se()({component:Vu}),Uu=R({getParentRoute:()=>Hu,id:`_dashboardLayout`,component:ku,beforeLoad:({context:e})=>{let t=Pu(e);if(t&&!t.isLoading&&!t.user)throw Ne({to:`/sign-in`,search:Mu()})}}),Wu=R({getParentRoute:()=>Uu,path:`admin`,component:Ic});R({getParentRoute:()=>Wu,path:`/`,beforeLoad:()=>{throw Ne({to:`/admin/notifications`})}}),R({getParentRoute:()=>Wu,path:`notifications`,head:()=>({meta:[{title:`Notifications — Harper Fabric`}]}),component:je(async()=>pe(()=>import(`./notifications-BYgO5-yk.js`),__vite__mapDeps([5,1,6,7,2,3,4,8,9])),`NotificationsAdminIndex`)}),R({getParentRoute:()=>Wu,path:`regions`,head:()=>({meta:[{title:`Regions — Harper Fabric`}]}),component:je(async()=>pe(()=>import(`./regions-Sv_IN7XA.js`),__vite__mapDeps([10,1,7,6,2,3,4,8,9,11,12])),`RegionsIndex`)}),R({getParentRoute:()=>Wu,path:`api-token`,head:()=>({meta:[{title:`API Token — Harper Fabric`}]}),component:je(async()=>pe(()=>import(`./apiToken-DyI8IwU3.js`),__vite__mapDeps([13,1,6,7,2,3,4,8,9])),`ApiTokenIndex`)});function Gu(){let[e,t]=(0,G.useState)(()=>typeof document<`u`&&document.documentElement.classList.contains(`dark`));return(0,G.useEffect)(()=>{let e=document.documentElement;t(e.classList.contains(`dark`));let n=new MutationObserver(()=>{t(e.classList.contains(`dark`))});return n.observe(e,{attributes:!0,attributeFilter:[`class`]}),()=>n.disconnect()},[]),e?`dark`:`light`}var Ku={dark:[`M 246 426 C 211 389 184 377 154 386 C 72 399 44 492 0 576`,`M 658 383 C 693 318 748 286 795 286 C 905 281 957 477 952 583`,`M 750 438 C 915 444 1083 562 1183 766`,`M 0 576 C 119 529 273 575 372 766`,`M 1196 766 C 1291 526 1514 442 1690 432 C 1844 430 1973 530 2054 651`],light:[`M 258 355 C 212 300 171 289 136 313 C 74 352 37 434 0 542`,`M 633 350 C 684 251 744 193 790 200 C 882 201 967 380 951 548`,`M 756 405 C 891 368 1055 510 1169 766`,`M 0 542 C 112 440 299 588 356 766`,`M 1285 766 C 1391 564 1556 518 1710 505 C 1840 504 1971 571 2054 668`]},qu={dark:[[246,426,0,576],[658,383,952,583],[750,438,1183,766],[0,576,372,766],[1196,766,2054,651]],light:[[258,355,0,542],[633,350,951,548],[756,405,1169,766],[0,542,356,766],[1285,766,2054,668]]},Ju=[{path:0,duration:12,phase:3},{path:1,duration:16,phase:6},{path:1,duration:16,phase:14},{path:2,duration:14,phase:4},{path:3,duration:18,phase:11},{path:4,duration:22,phase:5},{path:4,duration:22,phase:16}];function Yu({theme:e}){let t=(0,G.useId)();return(0,K.jsxs)(`svg`,{className:`auth-energy-particles`,viewBox:`0 0 2054 766`,"aria-hidden":`true`,focusable:`false`,children:[(0,K.jsxs)(`defs`,{children:[(0,K.jsxs)(`radialGradient`,{id:`${t}-fade`,children:[(0,K.jsx)(`stop`,{offset:`0`,stopColor:`black`}),(0,K.jsx)(`stop`,{offset:`1`,stopColor:`white`})]}),qu[e].map(([e,n,r,i],a)=>(0,K.jsxs)(`mask`,{id:`${t}-${a}`,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`2054`,height:`766`,children:[(0,K.jsx)(`rect`,{width:`2054`,height:`766`,fill:`white`}),(0,K.jsx)(`circle`,{cx:e,cy:n,r:`60`,fill:`url(#${t}-fade)`}),(0,K.jsx)(`circle`,{cx:r,cy:i,r:`60`,fill:`url(#${t}-fade)`})]},a))]}),Ku[e].map((e,n)=>(0,K.jsx)(`path`,{className:`auth-energy-line`,d:e,mask:`url(#${t}-${n})`},e)),Ju.map(({path:t,duration:n,phase:r},i)=>(0,K.jsxs)(`g`,{className:`auth-energy-particle`,opacity:`0`,children:[(0,K.jsx)(`circle`,{r:`12`,fill:`currentColor`,opacity:`0.06`}),(0,K.jsx)(`circle`,{r:`6`,fill:`currentColor`,opacity:`0.16`}),(0,K.jsx)(`circle`,{r:`2.2`,fill:`currentColor`}),(0,K.jsx)(`animateMotion`,{path:Ku[e][t],dur:`${n}s`,begin:`-${r}s`,repeatCount:`indefinite`}),(0,K.jsx)(`animate`,{attributeName:`opacity`,values:`0;0.85;0.85;0`,keyTimes:`0;0.12;0.82;1`,dur:`${n}s`,begin:`-${r}s`,repeatCount:`indefinite`})]},`${e}-${i}`))]})}var Xu=[{title:`App`,description:`Build faster`,Icon:oi},{title:`Database`,description:`Store smarter`,Icon:ia},{title:`Cache`,description:`Move quicker`,Icon:Js},{title:`Messaging`,description:`Stay connected`,Icon:_o}];function Zu(){let e=Gu();return(0,K.jsxs)(`div`,{className:`fabric-sign-in-page`,children:[(0,K.jsxs)(`header`,{className:`sign-in-header`,children:[(0,K.jsxs)(`div`,{className:`sign-in-brand`,children:[(0,K.jsx)(V,{to:`/`,"aria-label":`Harper Fabric home`,children:(0,K.jsx)(il,{})}),(0,K.jsx)(Zl,{})]}),(0,K.jsxs)(`nav`,{"aria-label":`Authentication navigation`,children:[(0,K.jsxs)(`a`,{className:`sign-in-docs`,href:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noreferrer noopener`,children:[(0,K.jsx)(ii,{"aria-hidden":`true`}),` `,(0,K.jsx)(`span`,{children:`Docs`})]}),(0,K.jsx)(Vl,{})]})]}),(0,K.jsxs)(`main`,{className:`sign-in-content`,children:[(0,K.jsxs)(`section`,{className:`sign-in-story`,"aria-labelledby":`sign-in-story-title`,children:[(0,K.jsxs)(`div`,{className:`sign-in-story-copy`,children:[(0,K.jsxs)(`h2`,{id:`sign-in-story-title`,children:[`One runtime.`,(0,K.jsx)(`br`,{}),(0,K.jsx)(`span`,{children:`Endless possibilities.`})]}),(0,K.jsxs)(`p`,{children:[`Build, deploy, and scale distributed applications`,(0,K.jsx)(`br`,{className:`sign-in-desktop-break`}),` `,`with built-in data, cache, and messaging.`]}),(0,K.jsx)(`ul`,{className:`sign-in-features`,children:Xu.map(({title:e,description:t,Icon:n})=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`sign-in-feature-icon`,children:(0,K.jsx)(n,{"aria-hidden":`true`})}),(0,K.jsx)(`strong`,{children:e}),(0,K.jsx)(`span`,{children:t})]},e))})]}),(0,K.jsx)(`div`,{className:`sign-in-artwork`,children:(0,K.jsxs)(`div`,{className:`auth-hero-panorama`,children:[(0,K.jsx)(`img`,{className:`auth-hero-globe`,src:`/auth/fabric-globe-${e}.png`,alt:``,"aria-hidden":`true`}),(0,K.jsx)(Yu,{theme:e}),(0,K.jsx)(`img`,{className:`auth-hero-platform`,src:`/auth/fabric-platform-${e}.png`,width:`2054`,height:`766`,alt:`App, database, cache, and messaging together on a globally distributed platform.`,fetchPriority:`high`})]})}),(0,K.jsxs)(`div`,{className:`sign-in-story-footer`,children:[(0,K.jsx)(`span`,{children:`Free to deploy`}),(0,K.jsx)(`span`,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:`Live in minutes`})]})]}),(0,K.jsx)(`section`,{className:`sign-in-card`,"aria-label":`Account access`,children:(0,K.jsx)(st,{})})]})]})}function Qu(){(0,G.useEffect)(()=>{},[])}var $u=[`gmail.com`,`yahoo.com`,`hotmail.com`,`outlook.com`,`icloud.com`,`aol.com`,`protonmail.com`,`mail.com`,`zoho.com`,`yandex.com`,`gmx.com`,`live.com`,`msn.com`,`me.com`,`inbox.com`];function ed(e){if(!e||!e.includes(`@`))return null;let t=e.split(`@`).pop()||``;if(!t)return null;for(let e of $u)if(t===e||t.endsWith(`.`+e))return null;return t}var td=[`error`,`reason`];function nd(e){let t=new URLSearchParams(e),n=td.filter(e=>t.has(e));if(n.length===0)return e;for(let e of n)t.delete(e);let r=t.toString();return r?`?${r}`:``}function rd(){if(typeof location>`u`||typeof history>`u`)return;let{search:e,pathname:t,hash:n,origin:r}=location,i=nd(e);i!==e&&history.replaceState(history.state,``,`${r}${t}${i}${n}`)}var id=`utm_`;function ad(e){let t=new URLSearchParams(e),n=Array.from(t.keys()).filter(e=>e.toLowerCase().startsWith(id));if(n.length===0)return e;for(let e of n)t.delete(e);let r=t.toString();return r?`?${r}`:``}function od(){if(typeof location>`u`||typeof history>`u`)return;let{search:e,pathname:t,hash:n,origin:r}=location,i=ad(e);i!==e&&history.replaceState(history.state,``,`${r}${t}${i}${n}`)}function sd({icon:e,title:t,subtitle:n,loading:r=!1}){return(0,K.jsxs)(`div`,{className:`auth-heading`,children:[(0,K.jsx)(`span`,{className:`auth-status-icon`,children:(0,K.jsx)(e,{"aria-hidden":`true`,className:r?`auth-loading-icon`:void 0})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{children:t}),n&&(0,K.jsx)(`p`,{className:`auth-heading-subtitle`,children:n})]})]})}var cd=`We were not able to verify your sign-in. Please try signing in again.`,ld=`Sign-in is temporarily unavailable. Please try again in a few minutes.`,ud=`This sign-in method isn't allowed for your account.`,dd={state_storage:ld,account_lookup_failed:ld,identity_resolution:ld,token_exchange:ld,user_mapping:ld,user_info:ld,login_hook:ld,internal_error:ld,unknown:ld,email_lookup_failed:ld,csrf:`Your sign-in session expired. Please try signing in again.`,email_not_verified:`Verify your email address before signing in with this provider.`,email_ambiguous:`More than one of your verified email addresses matches an existing account. Contact your administrator for help signing in.`,provider_not_authorized:ud,login_not_allowed:ud,denied:ud,login_denied:ud,confirmation_required:`Your sign-in needs an extra step that was not completed. Please contact your administrator.`,access_denied:`Sign-in was cancelled.`},fd={invalid_request:`Your sign-in link is invalid or has expired. Please try signing in again.`,server_error:ld,auth_failed:ld,oauth_failed:`The identity provider couldn't complete sign-in. Please try again.`,access_denied:ud};function pd(e,t){if(e)return t&&Object.hasOwn(dd,t)?dd[t]:Object.hasOwn(fd,e)?fd[e]:cd}var md=null;function hd(){let e=De(),t=Ee(),n=Ze(),{redirect:r}=Oe({strict:!1});return(0,G.useEffect)(()=>{md||=Promise.resolve().then(async()=>{try{let i=new URLSearchParams(window.location.search),a=pd(i.get(`error`),i.get(`reason`));try{rd()}catch(e){console.debug(`Failed to clear OAuth error params from the URL, carrying on:`,e)}if(a){U.error(a,{duration:1e4}),await e({to:`/sign-in`});return}let o=await l().catch(()=>null);if(!o)U.error(cd,{duration:1e4}),await e({to:`/sign-in`});else{u.setUserForEntity(m,o),od();let i=Pr(o);ed(o.email),await n.invalidateQueries({queryKey:f,refetchType:`none`}),await t.invalidate(),await e({to:r?.startsWith(`/`)?r:i})}}finally{md=null}}).catch(e=>{console.debug(`OAuth sign-in check failed, carrying on:`,e)})},[]),(0,K.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`auth-form flex flex-col gap-4`,children:[(0,K.jsx)(sd,{icon:no,title:`Checking...`,subtitle:`We’re confirming your sign-in.`,loading:!0}),(0,K.jsx)(`div`,{className:`auth-links`,children:(0,K.jsx)(V,{className:`text-sm`,to:`/sign-in`,children:`Try signing in again`})})]})}var gd=new Map;function _d(e){if(!e)return``;if(gd.has(e))return gd.get(e);let t=e.replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();if(!t)return gd.set(e,``),``;let n=t.match(/([A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|[0-9]+)/g);if(!n)return gd.set(e,``),``;let r=[];for(let e=0;e<n.length;e++){let t=n[e],i=e+1<n.length?n[e+1]:void 0;/^[A-Z]{2,}$/.test(t)&&i&&/[A-Z]*s$/.test(i)||/^[A-Z]$/.test(t)&&i!==void 0&&/^[A-Z]s$/.test(i)?(r.push(t+i),e++):r.push(t)}let i=r.map(vd).join(` `);return gd.set(e,i),i}function vd(e){return/^[A-Z]{2,3}s?$/.test(e)||/^[0-9]+$/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}var yd=new Set([`mode`]),bd=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,xd=/^\{-\$(\w+)\}$/,Sd=`_splat`;function Cd(e,t,n){let r=[],i=0;for(let a of(e??``).split(`/`).filter(Boolean)){if(i>=t)break;let e=xd.exec(a);if(e)n[e[1]]!==void 0&&(r[i++]=e[1]);else if(a===`$`)for(;i<t;)r[i++]=Sd;else r[i++]=a.startsWith(`$`)?a.slice(1):void 0}return r}function wd(e){try{return decodeURIComponent(e)}catch{return e}}function Td(e,t,n){switch(e){case`organizationId`:return{label:n.organization||`Org`};case`clusterId`:return{label:n.cluster||`Cluster`};case`instanceId`:return{label:n.instance?.split(`.`)?.shift()||`Instance`}}return yd.has(e)?{label:_d(t)}:bd.test(t)?{label:t.slice(0,8),title:t}:{label:t}}function Ed(e,t,n,r){let i=e.split(`/`).filter(Boolean),a=Cd(t,i.length,n),o=e=>{let t=a[e],r=t&&t!==Sd?n[t]:void 0;return typeof r==`string`?r:wd(i[e])},s=[];for(let e=0;e<i.length;e++){let t=i[e],n=a[e];if(!n&&t===`instance`)continue;let c=`/${i.slice(0,e+1).join(`/`)}`;if(n)n===`clusterId`&&i[e+1]===`instance`&&(c+=`/instances`),s.push({path:c,...Td(n,o(e),r)});else if(t===`databases`&&i.length===e+3)s.push({path:c,label:o(e+2)}),e+=2;else{let e=_d(t);s.push({path:c,label:e===`Apis`?`APIs`:e})}}return s}function Dd({restartRequired:e}){let t=ze(),{organization:n,instance:r,cluster:i}=ye({strict:!1}),a=xe({select:e=>e[e.length-1]}),o=a?.pathname??t.pathname,s=a?.fullPath,c=a?.params,l=(0,G.useMemo)(()=>{let e=[(0,K.jsxs)(V,{to:`/`,children:[(0,K.jsx)(Ra,{"aria-hidden":`true`,className:`size-5 shrink-0`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Home`})]},`home`)],t=Ed(o,s,c??{},{organization:n?.name,cluster:i?.name,instance:r?.name});for(let{path:n,label:r,title:i}of t)e.push((0,K.jsx)(`svg`,{fill:`currentColor`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`size-5 shrink-0 text-grey`,children:(0,K.jsx)(`path`,{d:`M5.555 17.776l8-16 .894.448-8 16-.894-.448z`})},e.length+`-dash`),(0,K.jsx)(V,{to:n,title:i,className:`text-xs md:text-sm font-medium hover:text-grey truncate max-w-48`,children:r},n));return e},[o,s,c,i?.name,r?.name,n?.name]);return(0,K.jsxs)(`div`,{role:`list`,className:`flex items-center space-x-2 xl:space-x-4 sm:max-w-9/10 max-w-[calc(100%-56px)]`,children:[...l,e&&(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsxs)(`div`,{className:`text-xs italic text-muted-foreground`,children:[`* Restart `,(0,K.jsx)(`span`,{className:`hidden lg:inline-block`,children:`Requested`})]})}),(0,K.jsxs)(Xl,{side:`bottom`,children:[`This `,`Instance`,` is requesting a restart, when convenient, to apply your latest changes.`,(0,K.jsx)(`br`,{}),`You can do this from the Apps or Config pages.`]})]})]})}var Od=jn,kd=(0,G.createContext)({}),Ad=(0,G.createContext)({});function jd(){let e=(0,G.useContext)(kd),t=(0,G.useContext)(Ad),{errors:n}=Nn({name:e.name}),r=Rn(n,e.name);if(!e)throw Error(`useFormField should be used within <FormField>`);let{id:i}=t;return{id:i,name:e.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,formLengthHintId:`${i}-form-item-length-hint`,error:r}}function J({"aria-describedby":e,...t}){let{error:n,formItemId:r,formDescriptionId:i,formMessageId:a}=jd();return(0,K.jsx)(vt,{"data-slot":`form-control`,id:r,"aria-describedby":[i,n&&a,e].filter(Boolean).join(` `),"aria-invalid":!!n,...t})}function Y({...e}){return(0,K.jsx)(kd,{value:{name:e.name},children:(0,K.jsx)(Hn,{...e})})}function X({className:e,...t}){let n=(0,G.useId)();return(0,K.jsx)(Ad,{value:{id:n},children:(0,K.jsx)(`div`,{"data-slot":`form-item`,className:F(`grid gap-2`,e),...t})})}function Md({className:e,...t}){return(0,K.jsx)(pn,{"data-slot":`label`,className:F(`text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function Z({className:e,...t}){let{error:n,formItemId:r}=jd();return(0,K.jsx)(Md,{"data-slot":`form-label`,"data-error":!!n,className:F(`data-[error=true]:text-destructive`,e),htmlFor:r,...t})}function Q({className:e,...t}){let{error:n,formMessageId:r}=jd(),i=n?String(n?.message):t.children;return i?(0,K.jsx)(`p`,{"data-slot":`form-message`,id:r,className:F(`text-destructive text-sm`,e),...t,children:i}):null}function $({className:e,type:t,...n}){return(0,K.jsx)(`input`,{type:t,"data-slot":`input`,className:F(`border-input file:text-foreground placeholder:text-muted-foreground selection:bg-purple
3
3
  selection:text-primary-foreground
4
4
  dark:aria-invalid:outline-destructive dark:aria-invalid:ring-destructive/50 ring-ring/10
5
5
  dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 aria-invalid:outline-destructive/60
@@ -16,7 +16,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
16
16
  [&_svg]:size-4 [&_svg]:shrink-0`,e&&`bg-muted font-semibold text-foreground`,t),...n})}function Nb({pageCount:e,disabled:t,onGo:n}){let[r,i]=(0,G.useState)(``);return(0,K.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let a=Number(r);Number.isFinite(a)&&a>=1&&n(Math.min(a,e)),i(``)},className:`hidden items-center gap-2 @min-[840px]:flex`,children:[(0,K.jsx)(`label`,{htmlFor:`pagination-go-to`,className:`text-sm whitespace-nowrap text-muted-foreground`,children:`Go to`}),(0,K.jsx)(`input`,{id:`pagination-go-to`,type:`number`,min:1,max:e,inputMode:`numeric`,placeholder:`Page`,disabled:t,value:r,onChange:e=>i(e.target.value),className:`h-9 w-20 rounded-md border border-input bg-white px-3 text-sm text-foreground
17
17
  placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-purple focus-visible:outline-none
18
18
  disabled:pointer-events-none disabled:opacity-50 dark:bg-grey-700 dark:text-white`})]})}function Pb({pageSize:e,onChange:t}){return(0,K.jsxs)(`div`,{className:`hidden items-center gap-2 @min-[960px]:flex`,children:[(0,K.jsx)(`span`,{className:`text-sm whitespace-nowrap text-muted-foreground`,children:`Rows`}),(0,K.jsxs)(hy,{value:String(e),onValueChange:e=>t(Number(e)),children:[(0,K.jsx)(vy,{"aria-label":`Rows per page`,className:`h-9 w-20`,children:(0,K.jsx)(_y,{})}),(0,K.jsx)(yy,{side:`top`,children:Db.map(e=>(0,K.jsx)(xy,{value:String(e),children:By(e)},e))})]})]})}function Fb(e,t,n=1){if(t<=n*2+5)return Ib(1,t);let r=Math.max(e-n,1),i=Math.min(e+n,t),a=r>2,o=i<t-1,s=3+2*n;return!a&&o?[...Ib(1,s),`ellipsis`,t]:a&&!o?[1,`ellipsis`,...Ib(t-s+1,t)]:[1,`ellipsis`,...Ib(r,i),`ellipsis`,t]}function Ib(e,t){return Array.from({length:t-e+1},(t,n)=>e+n)}var Lb=We({columnSizingFeature:$e,columnResizingFeature:Ye,columnVisibilityFeature:Ue,columnFilteringFeature:Ge,globalFilteringFeature:Ve,rowPaginationFeature:at,rowSelectionFeature:Je,rowSortingFeature:nt,sortedRowModel:Ke(),sortFns:Be}),Rb={filteredRowModel:Qe(),paginatedRowModel:Re()},zb={...Lb,...Rb};function Bb(){return Le()}var Vb=Db[0];function Hb({columns:e,data:t,isFetching:n,onRowClick:r,onColumnClick:i,sortingState:a,filter:o,paginated:s,children:c}){let[l,u]=(0,G.useState)(()=>a??[]),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)({pageIndex:0,pageSize:Vb}),h=()=>m(e=>({...e,pageIndex:0})),g=tt({features:zb,data:t,columns:e,manualFiltering:!o,manualPagination:!s,autoResetPageIndex:!1,state:{sorting:l,globalFilter:d,pagination:p},onSortingChange:e=>{u(e),h()},onGlobalFilterChange:e=>{f(e),h()},onPaginationChange:m}),_=g.getPrePaginatedRowModel().rows.length,v=s&&_>Vb,y=Math.max(g.getPageCount()-1,0);return(0,G.useLayoutEffect)(()=>{p.pageIndex>y&&m(e=>({...e,pageIndex:y}))},[p.pageIndex,y]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-end space-x-2 pb-4`,children:[o&&(0,K.jsxs)(`div`,{className:`relative mr-auto w-full max-w-xs`,children:[(0,K.jsx)(rs,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`,"aria-hidden":`true`}),(0,K.jsx)($,{type:`search`,"aria-label":o.label,placeholder:o.placeholder??o.label,className:`pl-9`,value:d,onChange:e=>g.setGlobalFilter(e.target.value)})]}),(0,K.jsx)(`div`,{className:`grow lg:hidden`}),c,(0,K.jsx)(`div`,{className:`grow hidden lg:visible`})]}),(0,K.jsxs)(bb,{containerClassName:`rounded-md border border-border dark:border-grey-700 bg-card dark:bg-black-dark`,children:[(0,K.jsx)(xb,{children:g.getHeaderGroups().map(e=>(0,K.jsx)(Cb,{className:`border-none`,children:e.headers.map(e=>(0,K.jsx)(Tb,{header:e,onColumnClick:i},e.id))},e.id))}),(0,K.jsx)(Sb,{className:`bg-background dark:bg-black`,children:g.getRowModel().rows?.length?g.getRowModel().rows.map(e=>(0,K.jsx)(Cb,{"data-state":e.getIsSelected()&&`selected`,onClick:()=>r?.(e),className:F(`hover:bg-muted/10 data-[state=selected]:bg-muted`,r&&`cursor-pointer`),children:e.getVisibleCells().map(e=>(0,K.jsx)(Eb,{className:`py-2 px-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,style:{width:`${e.column.getSize()}px`},children:ot(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,K.jsx)(Cb,{children:(0,K.jsx)(Eb,{colSpan:e.length,className:`h-24 text-center`,children:n?(0,K.jsx)(`div`,{children:(0,K.jsx)(Lc,{className:`p-12`})}):(0,K.jsx)(`span`,{children:`No results.`})})})})]}),v&&(0,K.jsx)(Ob,{pageIndex:p.pageIndex,pageSize:p.pageSize,totalPages:g.getPageCount(),totalRecords:_,setPageIndex:g.setPageIndex,setPageSize:g.setPageSize})]})}function Ub(e){switch(e){case`paid`:return`success`;case`void`:case`uncollectible`:return`destructive`;default:return`default`}}function Wb(e){return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).format(e)}var Gb=[{header:`Invoice Id`,accessorKey:`id`,enableSorting:!1},{header:`Status`,accessorKey:`status`,enableSorting:!1,cell:({cell:e})=>(0,K.jsx)(ol,{variant:Ub(e.getValue()),children:e.getValue()})},{header:`Date`,accessorKey:`periodStart`,enableSorting:!1,cell:({cell:e})=>{let t=e.row.original.periodStart*1e3,n=e.row.original.periodEnd*1e3,r=(Date.now()-t)/1e3,i=(Date.now()-n)/1e3;return Math.abs(r-i)<1e3?Bm(r,t):[t?Bm(r,t):`-`,n?Bm(i,n):`-`].join(` to `)}},{header:`Amount Due`,accessorKey:`amountDue`,enableSorting:!1,cell:({cell:e})=>Wb(e.getValue()?e.getValue()/100:0)},{header:`Amount Paid`,accessorKey:`amountPaid`,enableSorting:!1,cell:({cell:e})=>Wb(e.getValue()?e.getValue()/100:0)},{header:`Lines`,accessorKey:`lines`,enableSorting:!1,cell:({cell:e})=>{let t=e.getValue(),n=[];for(let e of t)n.push(`${e.quantity}x ${e.description} @ ${Wb(e.amount/100)}`);return n.join(`
19
- `)}}];function Kb(e){return(0,G.useCallback)(async()=>{U.loading(`Refreshing...`,{id:`refreshing`});let t=Date.now();await e(),Date.now()-t<500&&await h(500),U.success(`Refreshed!`,{id:`refreshing`})},[e])}async function qb(e){let{data:t}=await P.get(`/Invoice/${e}`);return t}function Jb(e,t){return B({queryKey:[e,`invoices`],queryFn:()=>qb(e),retry:!1,enabled:!!e,refetchInterval:t?1e4:void 0})}function Yb(){let{organizationId:e}=z({strict:!1}),{data:t}=L(Yc(e)),{data:n,refetch:r,isLoading:i,isFetching:a,isRefetching:o}=L(Jb(t?.type!==`ENTERPRISE`&&t?.id,!1)),s=Kb(r);return t?.type===`ENTERPRISE`?(0,K.jsxs)(`span`,{children:[`You are part of an enterprise organization! We don’t currently show your invoices on this page. Want to explore your solution with Harper more? `,(0,K.jsx)(Pf,{}),`, we would love to talk!`]}):i?(0,K.jsx)(Lc,{centered:!0}):!n||!n.length?(0,K.jsxs)(`span`,{children:[`Your invoices will be shown here once one is available! Want to explore your solution with Harper more?`,` `,(0,K.jsx)(Pf,{overEmail:!0}),`, we would love to talk!`]}):(0,K.jsx)(Hb,{data:n,columns:Gb,children:(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:s,accessKey:`r`,disabled:a||o,children:[(0,K.jsx)(Go,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]})})}function Xb(e){let t=R({getParentRoute:()=>e,path:`billing`,head:()=>({meta:[{title:`Billing — Harper Fabric`}]}),component:gb}),n=R({getParentRoute:()=>t,path:`/`,head:()=>({meta:[{title:`Payment Methods — Harper Fabric`}]}),component:ay}),r=R({getParentRoute:()=>t,path:`invoices`,head:()=>({meta:[{title:`Invoices — Harper Fabric`}]}),component:Yb}),i=R({getParentRoute:()=>t,path:`confirm`,head:()=>({meta:[{title:`Confirm Payment — Harper Fabric`}]}),component:hb});return t.addChildren([n,r,i])}function Zb({error:e,reset:t}){switch(jr(e)){case 403:return(0,K.jsx)(oc,{error:e,title:`No Access to This Organization`,description:`This organization doesn't exist, or your account isn't a member of it. To join it, ask one of its administrators to invite you.`});case 404:return(0,K.jsx)(oc,{error:e,title:`Organization Not Found`,description:`No organization has this ID. Check that the link is complete and correct.`});default:return(0,K.jsx)(oc,{error:e,reset:t})}}async function Qb(e){let{data:t}=await P.get(`/OrganizationRole/${e}`);return t}function $b(e){return B({queryKey:[e,`roles`],queryFn:()=>Qb(e),retry:!1,refetchInterval:Gc(1e4)})}function ex(e){return e.userIds?.length??0}var tx=[{header:`Role Name`,accessorKey:`roleName`,enableSorting:!0},{header:`ID`,accessorKey:`id`,enableSorting:!0,enableGlobalFilter:!1,cell:e=>(0,K.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,title:e.row.original.id,children:e.row.original.id})},{header:`Users Assigned`,id:`userIds`,accessorFn:ex,enableSorting:!0,enableGlobalFilter:!1,cell:e=>ex(e.row.original)||`No users assigned`}],nx=new Set([`checkbox`,`radio`,`file`,`submit`,`button`,`image`,`reset`]);function rx(e){return t=>{let n=t.target;if(t.key!==`Enter`||t.nativeEvent.isComposing||!(n instanceof HTMLInputElement)||nx.has(n.type)||!n.name)return;let r=n.name,i=e.getValues(r);i!==void 0&&e.setValue(r,i,{shouldTouch:!0,shouldValidate:!0})}}async function ix(e){let{data:t}=await P.post(`/Role/`,e);return t}function ax(){return I({mutationFn:ix})}var ox=b({name:x().nonempty({error:`Please enter a role name.`}).regex(/^[a-zA-Z_]*$/,{error:`Role must contain only letters and underscores.`}).max(30,{error:`Role name cannot be longer than 30 characters.`}),update:A(),delete:A()}).pick({name:!0});b({roles:b({create:A(),delete:A(),update:A(),view:A()}),clusters:b({create:A(),delete:A(),update:A(),view:A(),resources:D(b({id:x(),delete:A(),update:A(),view:A(),instances:b({create:A(),delete:A(),update:A(),view:A()})}))})});function sx({className:e,...t}){return(0,K.jsx)(sn,{"data-slot":`tabs`,className:F(`flex flex-col gap-2`,e),...t})}function cx({className:e,...t}){return(0,K.jsx)(Kt,{"data-slot":`tabs-list`,className:F(`text-muted-foreground inline-flex w-fit items-center justify-center rounded-full bg-muted dark:bg-gray-950 p-1`,e),...t})}function lx({className:e,...t}){return(0,K.jsx)(yt,{"data-slot":`tabs-trigger`,className:F(`data-[state=active]:text-foreground data-[state=active]:bg-card dark:data-[state=active]:bg-gray-600 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring focus-visible:ring-[3px] focus-visible:outline-1 text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 border rounded-full border-transparent px-2 py-1 font-medium whitespace-nowrap transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...t})}function ux({className:e,...t}){return(0,K.jsx)(Yn,{"data-slot":`tabs-content`,className:F(`flex-1 outline-none`,e),...t})}var dx=b({create:A(),view:A(),update:A(),delete:A()}),fx=b({id:x().min(1),view:A(),update:A(),delete:A(),instances:dx}),px=N({update:A(),delete:A(),roles:N(dx.shape),clusters:N({...dx.shape,resources:D(N(fx.shape))})}),mx={create:!0,view:!0,update:!0,delete:!0},hx={update:!1,delete:!1,roles:mx,clusters:{...mx,resources:[]}},gx=e=>({create:e?.create===!0,view:e?.view===!0,update:e?.update===!0,delete:e?.delete===!0});function _x({organization:e}){return{update:e.update===!0,delete:e.delete===!0,roles:gx(e.roles),clusters:{...gx(e.clusters),resources:(e.clusters?.resources??[]).map(e=>({id:e.id,view:e.view===!0,update:e.update===!0,delete:e.delete===!0,instances:gx(e.instances)}))}}}function vx(e,t,n){return{name:e,organizationId:t,...n}}function yx(e){return JSON.stringify(e,null,2)}function bx(e){let t;try{t=JSON.parse(e)}catch{return{ok:!1,error:`This isn’t valid JSON.`}}let n=px.safeParse(t);if(!n.success){let e=n.error.issues[0];return{ok:!1,error:`${e.path.length?e.path.join(`.`):`the permissions`}: ${e.message}`}}return{ok:!0,permissions:n.data}}var xx=(e,t)=>({create:e,view:t.view,update:t.update,delete:t.delete});function Sx({clusters:e}){if(e.resources.length===0)return{scope:`all`};let[t]=e.resources,n=e.resources.every(n=>n.view===t.view&&n.update===t.update&&n.delete===t.delete&&n.instances.create===e.create&&n.instances.view===n.view&&n.instances.update===n.update&&n.instances.delete===n.delete),r=!e.view&&!e.update&&!e.delete;return n&&r?{scope:`selected`,clusterIds:e.resources.map(e=>e.id)}:{scope:`custom`}}function Cx(e,t){let{clusters:n}=e;if(t.scope===`selected`&&n.resources.length>0){let[e]=n.resources;return{create:n.create,view:e.view,update:e.update,delete:e.delete}}return{create:n.create,view:n.view,update:n.update,delete:n.delete}}function wx(e,t,n){if(n.scope===`all`)return{...e,clusters:{...t,resources:[]}};let r={view:t.view,update:t.update,delete:t.delete};return{...e,clusters:{create:t.create,view:!1,update:!1,delete:!1,resources:n.clusterIds.map(e=>({id:e,...r,instances:xx(t.create,r)}))}}}function Tx(){let[e]=tl(),t=Qc();return e===`dark`||e===`system`&&t===`dark`?`vs-dark`:`light`}var Ex=(0,G.lazy)(async()=>(await pe(()=>import(`./setup-wNdpTrVH.js`),__vite__mapDeps([14,2,1,15,16,17,18,19,20])),{default:(await pe(()=>import(`./dist-9lpzt2Hn.js`).then(e=>e.t),__vite__mapDeps([15,1,2]))).default}));function Dx(e){return(0,K.jsx)(G.Suspense,{fallback:e.loading??null,children:(0,K.jsx)(Ex,{...e})})}var Ox=[`view`,`create`,`update`,`delete`],kx={view:`View`,create:`Create`,update:`Update`,delete:`Delete`};function Ax({checked:e,disabled:t,onChange:n,label:r,id:i,describedBy:a}){return(0,K.jsx)(`input`,{id:i,type:`checkbox`,"aria-label":r,"aria-describedby":a,className:`size-4 shrink-0 accent-primary dark:accent-violet-300 disabled:opacity-60`,checked:e,disabled:t,onChange:e=>n(e.target.checked)})}function jx({label:e,description:t,checked:n,disabled:r,onChange:i}){let a=(0,G.useId)();return(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(`div`,{className:`pt-0.5`,children:(0,K.jsx)(Ax,{id:a,describedBy:`${a}-description`,checked:n,disabled:r,onChange:i})}),(0,K.jsxs)(`div`,{className:`text-sm`,children:[(0,K.jsx)(`label`,{htmlFor:a,className:`text-foreground`,children:e}),(0,K.jsx)(`p`,{id:`${a}-description`,className:`text-xs text-muted-foreground`,children:t})]})]})}function Mx({value:e,onChange:t,clusters:n,disabled:r}){let[i,a]=(0,G.useState)(()=>Sx(e)),[o,s]=(0,G.useState)(()=>Cx(e,Sx(e))),c=i.scope===`custom`,l=r||c,u=i.scope===`selected`?i.clusterIds:[],d=n.filter(e=>!Pd.includes(e.status??``)||u.includes(e.id)),f=(n,r)=>{s(n),a(r),t(wx(e,n,r))};return(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(`section`,{"aria-labelledby":`role-organization-heading`,children:[(0,K.jsx)(`h3`,{id:`role-organization-heading`,className:`mb-3 font-medium text-foreground`,children:`Organization`}),(0,K.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,K.jsx)(jx,{label:`Update organization`,description:`Change the organization’s settings and billing.`,checked:e.update,disabled:r,onChange:n=>t({...e,update:n})}),(0,K.jsx)(jx,{label:`Delete organization`,description:`Permanently delete the organization.`,checked:e.delete,disabled:r,onChange:n=>t({...e,delete:n})})]})]}),(0,K.jsxs)(`section`,{"aria-labelledby":`role-resources-heading`,children:[(0,K.jsx)(`h3`,{id:`role-resources-heading`,className:`mb-3 font-medium text-foreground`,children:`Resource permissions`}),(0,K.jsxs)(bb,{containerClassName:`rounded-md border border-border dark:border-grey-700 bg-card dark:bg-black-dark`,children:[(0,K.jsx)(xb,{children:(0,K.jsxs)(Cb,{className:`border-none`,children:[(0,K.jsx)(wb,{className:`w-1/3 px-2`,children:`Resource`}),Ox.map(e=>(0,K.jsx)(wb,{className:`px-2 text-center`,children:kx[e]},e))]})}),(0,K.jsxs)(Sb,{className:`bg-background dark:bg-black`,children:[(0,K.jsxs)(Cb,{className:`border-border dark:border-grey-700`,children:[(0,K.jsx)(Eb,{className:`px-2 py-2.5 font-medium`,children:`Roles`}),Ox.map(n=>(0,K.jsx)(Eb,{className:`px-2 py-2.5 text-center`,children:(0,K.jsx)(Ax,{label:`Roles: ${kx[n]}`,checked:e.roles[n],disabled:r,onChange:r=>t({...e,roles:{...e.roles,[n]:r}})})},n))]}),(0,K.jsxs)(Cb,{className:`border-border dark:border-grey-700`,children:[(0,K.jsx)(Eb,{className:`px-2 py-2.5 font-medium`,children:`Clusters`}),Ox.map(e=>(0,K.jsx)(Eb,{className:`px-2 py-2.5 text-center`,children:(0,K.jsx)(Ax,{label:`Clusters: ${kx[e]}`,checked:o[e],disabled:l,onChange:t=>f({...o,[e]:t},i)})},e))]})]})]}),(0,K.jsxs)(`ul`,{className:`mt-2 space-y-1 text-xs text-muted-foreground`,children:[(0,K.jsx)(`li`,{children:`Role permissions also control membership: Create allows adding members and inviting people; Delete allows removing members.`}),(0,K.jsx)(`li`,{children:`Cluster Update also allows running operations.`})]})]}),(0,K.jsxs)(`section`,{"aria-labelledby":`role-cluster-access-heading`,className:`space-y-2`,children:[(0,K.jsx)(`h3`,{id:`role-cluster-access-heading`,className:`font-medium text-foreground`,children:`Cluster access`}),c?(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This role sets permissions cluster by cluster in a way this form can’t show. Edit them in Advanced JSON.`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`max-w-xs`,children:(0,K.jsxs)(hy,{value:i.scope,disabled:r,onValueChange:e=>f(o,e===`selected`?{scope:`selected`,clusterIds:[]}:{scope:`all`}),children:[(0,K.jsx)(vy,{className:`w-full`,"aria-labelledby":`role-cluster-access-heading`,children:(0,K.jsx)(_y,{})}),(0,K.jsxs)(yy,{children:[(0,K.jsx)(xy,{value:`all`,children:`All clusters`}),(0,K.jsx)(xy,{value:`selected`,children:`Selected clusters`})]})]})}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i.scope===`selected`?`View, Update and Delete apply only to the clusters chosen here. Create always applies to the whole organization.`:`The Clusters permissions apply to every cluster in the organization.`}),i.scope===`selected`&&(d.length===0?(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This organization has no clusters yet.`}):(0,K.jsx)(`ul`,{className:`grid gap-2 pt-1 sm:grid-cols-2`,children:d.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(Ax,{checked:u.includes(e.id),disabled:r,onChange:t=>f(o,{scope:`selected`,clusterIds:t?[...u,e.id]:u.filter(t=>t!==e.id)})}),e.name??e.id,Pd.includes(e.status??``)&&(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`(deleted)`})]})},e.id))}))]})]})]})}function Nx({value:e,onChange:t,clusters:n,disabled:r=!1,onValidChange:i}){let a=Tx(),[o,s]=(0,G.useState)(`form`),[c,l]=(0,G.useState)(()=>yx(e)),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(0),m=(0,G.useRef)(null),[h,g]=(0,G.useState)();return(0,K.jsxs)(sx,{value:o,onValueChange:t=>{t===`json`?(g(m.current?.offsetHeight),l(yx(e)),d(null),s(`json`)):u||(p(e=>e+1),s(`form`))},children:[(0,K.jsxs)(cx,{className:`p-0.5 text-sm dark:bg-gray-800`,children:[(0,K.jsx)(lx,{value:`form`,className:`px-3 py-0.5`,children:`Permissions`}),(0,K.jsx)(lx,{value:`json`,className:`px-3 py-0.5`,children:`Advanced JSON`})]}),(0,K.jsx)(ux,{value:`form`,ref:m,className:`pt-2`,children:(0,K.jsx)(Mx,{value:e,onChange:t,clusters:n,disabled:r},f)}),(0,K.jsxs)(ux,{value:`json`,style:{height:h},className:`flex min-h-80 flex-none flex-col pt-2`,children:[(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden rounded-lg border`,children:(0,K.jsx)(Dx,{className:`h-full w-full`,theme:a,defaultLanguage:`json`,value:c,onChange:e=>{let n=e??``;l(n);let r=bx(n);d(r.ok?null:r.error),i?.(r.ok),r.ok&&t(r.permissions)},options:{readOnly:r,automaticLayout:!0,minimap:{enabled:!1}}})}),u&&(0,K.jsxs)(`p`,{role:`alert`,className:`mt-2 text-sm text-red-500`,children:[u,` Fix it to save or to go back to Permissions.`]})]})]})}function Px({isModalOpen:e,setIsModalOpen:t}){let n=Ze(),{organizationId:r}=z({strict:!1}),{data:i}=L(Yc(r)),[a,o]=(0,G.useState)(hx),[s,c]=(0,G.useState)(!0),{mutate:l,isPending:u}=ax(),d=on({resolver:mt(ox),mode:`onTouched`,defaultValues:{name:``}}),f=()=>{t(!1),d.reset(),o(hx),c(!0)},p=({name:e})=>l(vx(e,r,a),{onSuccess:()=>{U.success(`Role "${e}" created.`),n.invalidateQueries({queryKey:[r,`roles`],refetchType:`active`}),f()},onError:e=>{pc(e)&&U.error(`Failed to create the role: ${e.message}`)}});return(0,K.jsx)(_m,{onOpenChange:e=>!e&&f(),open:e,children:(0,K.jsxs)(wm,{className:`max-h-[90vh] overflow-y-auto focus:outline-none sm:max-w-[760px]`,onOpenAutoFocus:e=>{e.preventDefault(),e.currentTarget.focus()},children:[(0,K.jsx)(Dm,{children:`Create role`}),(0,K.jsx)(Om,{children:`Choose what this role can access.`}),(0,K.jsx)(Od,{...d,children:(0,K.jsxs)(`form`,{id:`org-add-role-form`,name:`org-add-role-form`,className:`flex flex-col gap-4 my-2`,onSubmit:d.handleSubmit(p),onKeyDown:rx(d),children:[(0,K.jsx)(Y,{control:d.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Role name`}),(0,K.jsx)(cy,{type:`text`,placeholder:`e.g. deployment_operator`,maxLength:ox.shape.name.maxLength,...e}),(0,K.jsx)(ky,{children:`Letters and underscores, up to 30 characters.`}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Nx,{value:a,onChange:o,onValidChange:c,clusters:i?.clusters??[]}),(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(H,{variant:`outline`,type:`button`,onClick:f,disabled:u,children:`Cancel`}),(0,K.jsx)(H,{variant:`submit`,disabled:u||!s||!d.formState.isValid,children:u?`Creating…`:`Create role`})]})})]})})]})})}async function Fx({roleId:e}){let{data:t}=await P.delete(`/Role/${e}`,{id:e,deleted:!0});return t}function Ix(){return I({mutationFn:({roleId:e})=>Fx({roleId:e})})}async function Lx({roleId:e,updatedRoleInfo:t}){let{data:n}=await P.put(`/Role/${e}`,t);return n}function Rx(){return I({mutationFn:({roleId:e,updatedRoleInfo:t})=>Lx({roleId:e,updatedRoleInfo:t})})}function zx({organizationId:e,roleId:t}){return B({queryKey:[e,`roles`,t],queryFn:()=>Bx(t),refetchInterval:Gc(1e4),retry:Kc()})}async function Bx(e){let{data:t}=await P.get(`/Role/${e}`);return t}function Vx({onRoleDeleteClick:e,setIsConfirmingRoleDeletion:t,isRoleDeletionPending:n}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Dm,{children:`Confirm Role Deletion`}),(0,K.jsx)(Om,{children:`Are you sure you want to delete this role? This action cannot be undone.`}),(0,K.jsxs)(Em,{children:[(0,K.jsx)(H,{type:`button`,variant:`defaultOutline`,onClick:()=>t(!1),children:`Cancel`}),(0,K.jsx)(H,{variant:`destructiveOutline`,onClick:e,disabled:n,children:n?`Deleting...`:`Delete Role`})]})]})}function Hx({data:e,isModalOpen:t,closeModal:n}){let r=(0,G.useCallback)(()=>n(!1),[n]);return(0,K.jsx)(_m,{onOpenChange:r,open:t,children:(0,K.jsx)(wm,{className:`max-h-[90vh] overflow-y-auto sm:max-w-[760px]`,children:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(Ux,{roleName:e.roleName}),children:(0,K.jsx)(Wx,{data:e,closeModal:n})})})})}function Ux({roleName:e}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Dm,{children:[`Role "`,e,`"`]}),(0,K.jsx)(Lc,{centered:!0,text:`Loading role…`,className:`flex-1 min-h-0`})]})}function Wx({data:e,closeModal:t}){let n=Ze(),{data:r}=we(zx({roleId:e.id,organizationId:e.organizationId})),{data:i}=L(Yc(e.organizationId)),a=Sr().user?.roles?.[e.organizationId]?.id===e.id,o=e.roleName===`admin`,{update:s,remove:c}=fg(e.organizationId),l=s&&!a&&!o,u=c&&!a&&!o,{mutate:d,isPending:f}=Rx(),{mutate:p,isPending:m}=Ix(),[h,g]=(0,G.useState)(!1),[_]=(0,G.useState)(()=>_x(r)),[v,y]=(0,G.useState)(_),[b,x]=(0,G.useState)(!0),S=JSON.stringify(v)!==JSON.stringify(_),C=(0,G.useCallback)(()=>{p({roleId:e.id},{onSuccess:()=>{U.success(`Role deleted.`),t(!0)},onError:e=>{pc(e)&&U.error(`Failed to delete the role: ${e instanceof Error?e.message:String(e)}`)}})},[e.id,p,t]);return h?(0,K.jsx)(Vx,{onRoleDeleteClick:C,setIsConfirmingRoleDeletion:g,isRoleDeletionPending:m}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Dm,{children:[l?`Edit role`:`Role`,` "`,e.roleName,`"`]}),(0,K.jsx)(Om,{children:o?`The admin role is built in and can’t be edited.`:a?`This is your role. Another member who can update roles can change it.`:l?`Members and service accounts with this role get these permissions from their next request.`:`What members and service accounts with this role can do.`}),(0,K.jsx)(`div`,{className:`my-2`,children:(0,K.jsx)(Nx,{value:v,onChange:y,onValidChange:x,clusters:i?.clusters??[],disabled:!l})}),(l||u)&&(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[u?(0,K.jsx)(H,{type:`button`,variant:`destructiveOutline`,onClick:()=>{x(!0),g(!0)},disabled:f,children:`Delete role`}):(0,K.jsx)(`span`,{}),l&&(0,K.jsx)(H,{variant:`submit`,type:`button`,onClick:()=>d({roleId:e.id,updatedRoleInfo:vx(e.roleName,e.organizationId,v)},{onSuccess:async()=>{U.success(`Role updated. It applies to each member’s next request.`),await n.invalidateQueries({queryKey:[e.organizationId,`roles`,e.id]}),t(!1)},onError:e=>{pc(e)&&U.error(`Failed to update the role: ${e instanceof Error?e.message:String(e)}`)}}),disabled:f||!S||!b,children:f?`Saving…`:`Save changes`})]})})]})}function Gx(){let e=De(),t=Ze(),{organizationId:n,orgRoleId:r}=z({strict:!1}),{create:i}=fg(n),{data:a,refetch:o,isFetching:s,isRefetching:c}=we($b(n)),l=(0,G.useMemo)(()=>a&&a?.find(e=>e.id===r),[a,r]),u=!!r&&!!l,[d,f]=(0,G.useState)(!1),p=(0,G.useCallback)(async(i,a)=>{let o=[r?`..`:``,i].filter(Boolean);await e({to:o.join(`/`)}),a&&await t.invalidateQueries({queryKey:[n,`roles`],refetchType:`active`})},[r,e,t]),m=(0,G.useCallback)(()=>{f(!0)},[f]),h=(0,G.useCallback)(e=>p(e.original.id,!1),[p]),g=(0,G.useCallback)(e=>p(void 0,e),[p]),_=Kb(o);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsxs)(ub,{children:[(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsx)(`h2`,{className:`text-2xl text-foreground font-light`,children:`Roles`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Manage access to this organization and its clusters.`})]}),(0,K.jsxs)(G.Suspense,{fallback:(0,K.jsx)(Lc,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,K.jsxs)(Hb,{data:a,columns:tx,onRowClick:h,filter:{label:`Filter roles`,placeholder:`Filter by role name`},paginated:!0,children:[(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:_,accessKey:`r`,disabled:s||c,children:[(0,K.jsx)(Go,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),i&&(0,K.jsxs)(H,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:d,children:[(0,K.jsx)(Uo,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]}),i&&(0,K.jsx)(Px,{isModalOpen:d,setIsModalOpen:f}),u&&(0,K.jsx)(Hx,{data:l,isModalOpen:u,closeModal:g},l.id)]})]})]})}function Kx({className:e,...t}){return(0,K.jsx)(Gn,{"data-slot":`switch`,className:F(`peer data-[state=checked]:bg-green data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-grey-500 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,K.jsx)(Zn,{"data-slot":`switch-thumb`,className:F(`bg-white dark:data-[state=unchecked]:bg-white dark:data-[state=checked]:bg-white pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0`)})})}async function qx({tokenId:e}){let{data:t}=await P.delete(`/ApiToken/${encodeURIComponent(e)}`);return t}function Jx(e){let t=Ze();return I({mutationFn:qx,onSuccess:(n,{tokenId:r})=>{t.setQueriesData({queryKey:[e,`apiTokens`]},e=>e?.filter(e=>e.id!==r)),t.invalidateQueries({queryKey:[e,`apiTokens`],refetchType:`active`}),t.invalidateQueries({queryKey:[e,`serviceAccounts`],refetchType:`active`})}})}function Yx({token:e}){let[t,n]=(0,G.useState)(!1),{mutate:r,isPending:i}=Jx(e.organizationId),a=(0,G.useRef)(!1);return(0,K.jsx)(km,{typeOfThingBeingDeleted:`API token`,nameOfThingBeingDeleted:e.name,isModalOpen:t,setIsModalOpen:n,deletionConfirmed:()=>{a.current||(a.current=!0,r({tokenId:e.id},{onSuccess:()=>{U.success(`API token "${e.name}" revoked.`),n(!1)},onSettled:()=>{a.current=!1}}))},deletionPending:i,hideDataLossWarning:!0,transitiveVerb:`Revoke`,presentParticiple:`Revoking`,trigger:(0,K.jsxs)(H,{variant:`destructiveGhost`,size:`sm`,className:`text-destructive/75 hover:text-destructive focus-visible:text-destructive`,"aria-label":`Revoke ${e.name}`,children:[(0,K.jsx)(ei,{}),` Revoke`]})})}var Xx=6e4,Zx=60*Xx,Qx=24*Zx;function $x(e){return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function eS(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`long`})}function tS(e,t=Date.now()){let n=new Date(e).getTime()-t,r=Math.abs(n),[i,a]=r<Zx?[n/Xx,`minute`]:r<Qx?[n/Zx,`hour`]:[n/Qx,`day`],o=new Intl.RelativeTimeFormat(void 0,{numeric:`auto`}).format(Math.round(i),a);return o.charAt(0).toUpperCase()+o.slice(1)}function nS({value:e,format:t,className:n}){return(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(`time`,{dateTime:e,tabIndex:0,className:F(`rounded-sm focus-visible:outline-2 focus-visible:outline-ring`,n),children:t===`date`?$x(e):tS(e)})}),(0,K.jsx)(Xl,{children:eS(e)})]})}async function rS(e){let{data:t}=await P.post(`/ApiToken/`,e);return t}function iS(){return I({mutationFn:rS,gcTime:0})}var aS=30,oS=90,sS=b({name:x().trim().nonempty({error:`Please enter a name.`}).max(100,{error:`Name cannot be longer than 100 characters.`}),expiresInDays:C({error:`Enter a whole number of days.`}).int({error:`Enter a whole number of days.`}).min(1,{error:`Must be at least 1 day.`}).max(oS,{error:`Must be at most ${oS} days.`})});function cS({organizationId:e,serviceAccountId:t,onClose:n}){let r=Ze(),i=Kg(),{mutateAsync:a,isPending:o,reset:s}=iS(),[c,l]=(0,G.useState)(null),u=(0,G.useRef)(!1),d=(0,G.useRef)(!1),f=(0,G.useRef)(!1),p=(0,G.useRef)(null);(0,G.useEffect)(()=>(u.current=!0,()=>{u.current=!1,p.current&&_(p.current)}),[]),(0,G.useEffect)(()=>{c&&(p.current=null,d.current=!1,s())},[c,s]);let m=on({resolver:mt(sS),mode:`onTouched`,defaultValues:{name:``,expiresInDays:aS}}),{isValid:h}=m.formState,g=()=>Promise.all([r.invalidateQueries({queryKey:[e,`apiTokens`],refetchType:`active`}),r.invalidateQueries({queryKey:[e,`serviceAccounts`],refetchType:`active`})]),_=async e=>{try{await qx({tokenId:e.id}),U.warning(`An API token created after its dialog closed was revoked.`)}catch(e){console.error(`Failed to revoke an API token that was never shown`,e),U.error(`An API token created after its dialog closed could not be revoked. Revoke it from its service account’s API Tokens.`)}g()},v=async e=>{if(d.current||f.current||!u.current)return;d.current=!0;let n;try{n=await a({serviceAccountId:t,...e})}catch{d.current=!1;return}if(f.current=!0,!u.current){_(n);return}p.current=n,l(n),g()},y=()=>{d.current||n()};return(0,K.jsx)(_m,{open:!0,onOpenChange:e=>{e||y()},children:(0,K.jsx)(wm,{className:`sm:max-w-[600px]`,children:c?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Dm,{children:`Copy your API token`}),(0,K.jsxs)(Om,{children:[`It won't be shown again. Expires `,new Date(c.expiresAt).toLocaleString(),`.`]}),(0,K.jsxs)(`div`,{className:`my-4 flex items-center gap-2`,children:[(0,K.jsx)($,{readOnly:!0,"aria-label":`API token`,value:c.token,className:`font-mono text-xs`,onClick:()=>i(c.token)}),(0,K.jsx)(H,{type:`button`,size:`icon`,variant:`ghost`,className:`shrink-0`,"aria-label":`Copy token`,onClick:()=>i(c.token),children:(0,K.jsx)(ea,{})})]}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Send it as a bearer token:`,` `,(0,K.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 text-xs`,children:`Authorization: Bearer <token>`}),`. It acts as this service account, with its role, on this organization's clusters and their instances.`]}),(0,K.jsx)(Em,{children:(0,K.jsx)(H,{type:`button`,variant:`submit`,onClick:n,children:`Done`})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Dm,{children:`Create API Token`}),(0,K.jsx)(Om,{children:`For CI pipelines and scripts. The token acts as this service account, with its role.`}),(0,K.jsx)(Od,{...m,children:(0,K.jsxs)(`form`,{id:`create-api-token-form`,name:`create-api-token-form`,className:`flex flex-col gap-4 my-4`,onSubmit:m.handleSubmit(v),onKeyDown:rx(m),children:[(0,K.jsx)(Y,{control:m.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,K.jsx)(cy,{type:`text`,placeholder:`e.g. github-actions-deploy`,maxLength:sS.shape.name.maxLength,...e}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`expiresInDays`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Expires in (days)`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`number`,min:1,max:oS,step:1,name:e.name,ref:e.ref,onBlur:e.onBlur,value:Number.isFinite(e.value)?e.value:``,onChange:t=>e.onChange(t.target.valueAsNumber)})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(H,{variant:`destructiveOutline`,type:`button`,onClick:y,disabled:o,children:`Cancel`}),(0,K.jsx)(H,{variant:`submit`,type:`submit`,disabled:o||!h,children:o?`Creating…`:`Create Token`})]})})]})})]})})})}function lS(e){return B({queryKey:[e,`serviceAccounts`],queryFn:async()=>{let{data:t}=await P.get(`/ServiceAccount/`,{params:{organizationId:e}});return t},retry:!1})}function uS(e,t){return B({queryKey:[e,`apiTokens`,t],queryFn:async()=>{let{data:n}=await P.get(`/ApiToken/`,{params:{organizationId:e,serviceAccountId:t}});return n},retry:!1})}var dS=6048e5;function fS({token:e,now:t}){let n=new Date(e.expiresAt).getTime()-t;return n<=0?(0,K.jsxs)(`span`,{className:`text-red-500`,children:[`Expired `,(0,K.jsx)(nS,{value:e.expiresAt,format:`relative`,className:`lowercase`})]}):(0,K.jsx)(nS,{value:e.expiresAt,format:`relative`,className:F(n<dS&&`text-amber-600`)})}function pS({token:e}){return e.createdByUserId?e.createdByEmail?(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(`span`,{tabIndex:0,className:`rounded-sm focus-visible:outline-2 focus-visible:outline-ring`,children:e.createdByEmail})}),(0,K.jsx)(Xl,{children:e.createdByUserId})]}):(0,K.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.createdByUserId}):(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}function mS({organizationId:e,account:t,regionId:n}){let[r,i]=(0,G.useState)(!1),{data:a,isLoading:o,isError:s}=L(uS(e,t.id)),c=t.status===`ACTIVE`,l=Date.now();return(0,K.jsxs)(`section`,{id:n,"aria-label":`API tokens of ${t.name}`,className:`mt-4 rounded-lg border border-primary/30 bg-primary/5 dark:border-white/15 dark:bg-white/5`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 border-b px-4 py-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`h4`,{className:`font-medium text-foreground truncate`,children:t.name}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`API tokens`})]}),(0,K.jsxs)(H,{variant:`positiveOutline`,size:`sm`,onClick:()=>i(!0),disabled:!c,children:[(0,K.jsx)(Uo,{}),`Create token`]})]}),!t.roleName&&(0,K.jsx)(`p`,{className:`px-4 pt-3 text-sm text-red-500`,children:`Its role was deleted; change it from the account’s menu, or its tokens are refused.`}),!c&&(0,K.jsx)(`p`,{className:`px-4 pt-3 text-sm text-muted-foreground`,children:`While the account is disabled its tokens are refused; enabling it restores those not revoked or expired.`}),(0,K.jsx)(`div`,{className:`px-4 pb-2`,children:o?(0,K.jsx)(Lc,{className:`py-6`}):s&&!a?(0,K.jsx)(`p`,{className:`py-4 text-sm text-red-500`,children:`Couldn’t load this account’s tokens.`}):a?.length?(0,K.jsxs)(bb,{children:[(0,K.jsx)(xb,{children:(0,K.jsxs)(Cb,{className:`border-border`,children:[(0,K.jsx)(wb,{children:`Name`}),(0,K.jsx)(wb,{children:`Created by`}),(0,K.jsx)(wb,{children:`Created`}),(0,K.jsx)(wb,{children:`Expires`}),(0,K.jsx)(wb,{children:`Last used`}),(0,K.jsx)(wb,{children:(0,K.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,K.jsx)(Sb,{children:a.map(e=>(0,K.jsxs)(Cb,{className:`border-border`,children:[(0,K.jsx)(Eb,{className:`py-2.5 font-medium`,children:e.name}),(0,K.jsx)(Eb,{className:`py-2.5`,children:(0,K.jsx)(pS,{token:e})}),(0,K.jsx)(Eb,{className:`py-2.5 whitespace-nowrap`,children:(0,K.jsx)(nS,{value:e.createdAt,format:`date`})}),(0,K.jsx)(Eb,{className:`py-2.5 whitespace-nowrap`,children:(0,K.jsx)(fS,{token:e,now:l})}),(0,K.jsx)(Eb,{className:`py-2.5 whitespace-nowrap`,children:e.lastUsedAt?(0,K.jsx)(nS,{value:e.lastUsedAt,format:`relative`}):(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`Not used yet`})}),(0,K.jsx)(Eb,{className:`py-2.5 text-right`,children:(0,K.jsx)(Yx,{token:e})})]},e.id))})]}):(0,K.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No tokens yet.`})}),r&&(0,K.jsx)(cS,{organizationId:e,serviceAccountId:t.id,onClose:()=>i(!1)})]})}function hS({name:e,id:t}){return(0,K.jsxs)(`span`,{className:`flex items-baseline gap-2 truncate`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:e}),(0,K.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:t})]})}async function gS(e){let{data:t}=await P.post(`/ServiceAccount/`,e);return t}async function _S({id:e,...t}){let{data:n}=await P.patch(`/ServiceAccount/${encodeURIComponent(e)}`,t);return n}async function vS({id:e}){let{data:t}=await P.delete(`/ServiceAccount/${encodeURIComponent(e)}`);return t}function yS(e){let t=Ze();return I({mutationFn:gS,onSuccess:n=>{t.setQueryData([e,`serviceAccounts`],e=>e&&[...e.filter(e=>e.id!==n.id),n]),t.invalidateQueries({queryKey:[e,`serviceAccounts`],refetchType:`active`})}})}function bS(e){let t=Ze();return I({mutationFn:_S,onSuccess:n=>{t.setQueryData([e,`serviceAccounts`],e=>e?.map(e=>e.id===n.id?n:e)),t.invalidateQueries({queryKey:[e,`serviceAccounts`],exact:!0})}})}function xS(e){let t=Ze();return I({mutationFn:vS,onSuccess:(n,{id:r})=>{t.setQueryData([e,`serviceAccounts`],e=>e?.filter(e=>e.id!==r)),t.invalidateQueries({queryKey:[e,`serviceAccounts`],exact:!0})}})}function SS({organizationId:e,account:t,onClose:n}){let{data:r}=L($b(e)),{mutate:i,isPending:a}=bS(e),[o,s]=(0,G.useState)(t.roleName?t.roleId:``),c=!!t.roleName&&o===t.roleId;return(0,K.jsx)(_m,{open:!0,onOpenChange:e=>!e&&!a&&n(),children:(0,K.jsxs)(wm,{className:`sm:max-w-[480px]`,children:[(0,K.jsx)(Dm,{children:`Change role`}),(0,K.jsxs)(Om,{children:[t.name,`'s tokens act with this role from their next request.`]}),(0,K.jsxs)(hy,{value:o,onValueChange:s,disabled:a,children:[(0,K.jsx)(vy,{className:`w-full`,"aria-label":`Role`,children:(0,K.jsx)(_y,{placeholder:`Choose a role`})}),(0,K.jsx)(yy,{children:r?.map(e=>(0,K.jsx)(xy,{value:e.id,children:(0,K.jsx)(hS,{name:e.roleName,id:e.id})},e.id))})]}),(0,K.jsxs)(Em,{children:[(0,K.jsx)(H,{variant:`destructiveOutline`,type:`button`,onClick:n,disabled:a,children:`Cancel`}),(0,K.jsx)(H,{variant:`submit`,type:`button`,onClick:()=>i({id:t.id,roleId:o},{onSuccess:()=>{U.success(`Role changed. It applies to the account’s next request.`),n()}}),disabled:!o||c||a,children:a?`Saving…`:`Save`})]})]})})}var CS=b({name:x().trim().nonempty({error:`Please enter a name.`}).max(100,{error:`Name cannot be longer than 100 characters.`}),roleId:x().nonempty({error:`Please choose a role.`})});function wS({organizationId:e,onClose:t,onCreated:n}){let{mutate:r,isPending:i}=yS(e),a=(0,G.useRef)(!1),o=(0,G.useRef)(!1);(0,G.useEffect)(()=>(a.current=!0,()=>{a.current=!1}),[]);let{data:s,isLoading:c}=L($b(e)),l=on({resolver:mt(CS),mode:`onTouched`,defaultValues:{name:``,roleId:``}}),{isValid:u}=l.formState,d=t=>{!o.current&&a.current&&(o.current=!0,r({organizationId:e,...t},{onSuccess:e=>{U.success(`Service account "${e.name}" created.`),n(e)},onError:()=>{o.current=!1}}))},f=()=>{o.current||t()};return(0,K.jsx)(_m,{open:!0,onOpenChange:e=>!e&&f(),children:(0,K.jsxs)(wm,{className:`sm:max-w-[600px]`,children:[(0,K.jsx)(Dm,{children:`Create Service Account`}),(0,K.jsx)(Om,{children:`A non-human member of this organization for CI pipelines and scripts. It acts with the role you give it.`}),(0,K.jsx)(Od,{...l,children:(0,K.jsxs)(`form`,{id:`create-service-account-form`,name:`create-service-account-form`,className:`flex flex-col gap-4 my-4`,onSubmit:l.handleSubmit(d),onKeyDown:rx(l),children:[(0,K.jsx)(Y,{control:l.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,K.jsx)(cy,{type:`text`,placeholder:`e.g. github-actions`,maxLength:CS.shape.name.maxLength,...e}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:l.control,name:`roleId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Role`}),c?(0,K.jsx)(my,{}):(0,K.jsxs)(hy,{value:e.value,onValueChange:t=>e.onChange(t),children:[(0,K.jsx)(J,{children:(0,K.jsx)(vy,{className:`w-full`,"aria-label":`Role`,children:(0,K.jsx)(_y,{placeholder:`Choose a role`})})}),(0,K.jsx)(yy,{children:s?.map(e=>(0,K.jsx)(xy,{value:e.id,children:(0,K.jsx)(hS,{name:e.roleName,id:e.id})},e.id))})]}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(H,{variant:`destructiveOutline`,type:`button`,onClick:f,disabled:i,children:`Cancel`}),(0,K.jsx)(H,{variant:`submit`,type:`submit`,disabled:i||!u,children:i?`Creating…`:`Create Service Account`})]})})]})})]})})}function TS({status:e}){let t=e===`ACTIVE`;return(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:F(`size-2 rounded-full`,t?`bg-green`:`bg-amber-600`)}),(0,K.jsx)(`span`,{className:F(!t&&`text-amber-600`),children:t?`Enabled`:`Disabled`})]})}function ES({organizationId:e,account:t,onDeleted:n}){let[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(!1),{mutate:s,isPending:c}=bS(e),{mutate:l,isPending:u}=xS(e),d=(0,G.useRef)(!1),f=t.status===`ACTIVE`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Options for ${t.name}`,children:(0,K.jsx)(ua,{})})}),(0,K.jsxs)(vc,{align:`end`,className:`min-w-40`,children:[(0,K.jsxs)(yc,{onClick:()=>o(!0),children:[(0,K.jsx)(ds,{}),`Change role…`]}),(0,K.jsxs)(yc,{onClick:()=>s({id:t.id,status:f?`DISABLED`:`ACTIVE`},{onSuccess:()=>U.success(f?`Service account disabled.`:`Service account enabled.`)}),disabled:c,children:[f?(0,K.jsx)(ei,{}):(0,K.jsx)(Ei,{}),f?`Disable`:`Enable`]}),(0,K.jsxs)(yc,{variant:`destructive`,onClick:()=>i(!0),children:[(0,K.jsx)(Is,{}),`Delete`]})]})]}),a&&(0,K.jsx)(SS,{organizationId:e,account:t,onClose:()=>o(!1)}),(0,K.jsx)(km,{typeOfThingBeingDeleted:`service account`,nameOfThingBeingDeleted:t.name,isModalOpen:r,setIsModalOpen:i,deletionConfirmed:()=>{d.current||(d.current=!0,l({id:t.id},{onError:()=>{d.current=!1},onSuccess:()=>{U.success(`Service account "${t.name}" deleted; its tokens no longer work.`),i(!1),n()}}))},deletionPending:u,hideDataLossWarning:!0})]})}function DS({organizationId:e}){let t=(0,G.useId)(),[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(null),{data:o,isLoading:s,isError:c,refetch:l,isFetching:u}=L(lS(e)),d=Kb(l),f=o?.find(e=>e.id===i),p=e=>a(t=>t===e.id?null:e.id);return(0,K.jsxs)(`div`,{className:`px-4 py-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 mb-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`font-medium text-foreground`,children:`Service accounts`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Identities for CI pipelines and scripts, each acting with one of this organization’s roles.`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mr-[17px]`,children:[(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(H,{variant:`ghost`,size:`icon`,"aria-label":`Refresh service accounts`,onClick:d,disabled:u,children:(0,K.jsx)(Go,{})})}),(0,K.jsx)(Xl,{children:`Refresh`})]}),(0,K.jsxs)(H,{variant:`positive`,size:`sm`,onClick:()=>r(!0),disabled:n,children:[(0,K.jsx)(Uo,{}),`Create service account`]})]})]}),s?(0,K.jsx)(Lc,{className:`py-6`}):c&&!o?(0,K.jsx)(`p`,{className:`py-4 text-sm text-red-500`,children:`Couldn’t load service accounts.`}):o?.length?(0,K.jsxs)(bb,{children:[(0,K.jsx)(xb,{children:(0,K.jsxs)(Cb,{className:`border-border`,children:[(0,K.jsx)(wb,{children:`Name`}),(0,K.jsx)(wb,{children:`Role`}),(0,K.jsx)(wb,{children:`Status`}),(0,K.jsx)(wb,{children:`Active tokens`}),(0,K.jsx)(wb,{children:`Created`}),(0,K.jsx)(wb,{children:(0,K.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,K.jsx)(Sb,{children:o.map(n=>{let r=n.id===i;return(0,K.jsxs)(Cb,{"data-state":r?`selected`:void 0,onClick:()=>p(n),className:`cursor-pointer border-border hover:bg-muted/40 data-[state=selected]:bg-primary/10 dark:data-[state=selected]:bg-white/10`,children:[(0,K.jsx)(Eb,{className:`py-2.5`,children:(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":r,"aria-controls":r?t:void 0,onClick:e=>{e.stopPropagation(),p(n)},className:`group flex flex-col items-start text-left rounded-sm focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,K.jsx)(`span`,{className:`font-medium text-foreground group-hover:underline group-focus-visible:underline`,children:n.name}),(0,K.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:n.id})]})}),(0,K.jsx)(Eb,{className:`py-2.5`,children:n.roleName??(0,K.jsx)(`span`,{className:`text-red-500`,children:`Role deleted`})}),(0,K.jsx)(Eb,{className:`py-2.5`,children:(0,K.jsx)(TS,{status:n.status})}),(0,K.jsx)(Eb,{className:`py-2.5`,children:n.activeTokens}),(0,K.jsx)(Eb,{className:`py-2.5 whitespace-nowrap`,children:(0,K.jsx)(nS,{value:n.createdAt,format:`date`})}),(0,K.jsx)(Eb,{className:`py-2.5 text-right`,onClick:e=>e.stopPropagation(),children:(0,K.jsx)(ES,{organizationId:e,account:n,onDeleted:()=>a(e=>e===n.id?null:e)})})]},n.id)})})]}):(0,K.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No service accounts yet.`}),f&&(0,K.jsx)(mS,{organizationId:e,account:f,regionId:t}),n&&(0,K.jsx)(wS,{organizationId:e,onClose:()=>r(!1),onCreated:e=>{r(!1),a(e.id)}})]})}async function OS(e,t){let{data:n}=await P.patch(`/Organization/${e}/settings/apiTokens`,{enabled:t});return n}function kS({organizationId:e,enabled:t}){let n=Ze(),{mutate:r,isPending:i}=I({mutationFn:t=>OS(e,t),onSuccess:({apiTokensEnabled:t})=>{U.success(t?`API tokens are allowed.`:`API tokens are now refused.`),n.setQueryData([e],e=>e&&{...e,settings:{...e.settings,apiTokensEnabled:t}}),n.invalidateQueries({queryKey:[e]})}});return(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-6 border-b px-4 py-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`allow-api-tokens`,className:`font-medium text-foreground`,children:`Allow API tokens`}),(0,K.jsx)(`p`,{id:`allow-api-tokens-help`,className:`text-sm text-muted-foreground`,children:`Service account tokens work only while this is on.`})]}),(0,K.jsx)(Kx,{id:`allow-api-tokens`,"aria-describedby":`allow-api-tokens-help`,checked:t,disabled:i,onCheckedChange:r})]})}function AS({title:e,actions:t,children:n,bodyClassName:r}){let i=(0,G.useId)();return(0,K.jsxs)(`section`,{"aria-labelledby":i,className:`rounded-lg border bg-card text-foreground`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b px-4 py-3`,children:[(0,K.jsx)(`h3`,{id:i,className:`text-lg font-medium`,children:e}),t]}),(0,K.jsx)(`div`,{className:F(`p-4`,r),children:n})]})}function jS({organizationId:e,apiTokensEnabled:t}){return dg(e)?(0,K.jsxs)(AS,{title:`API access`,bodyClassName:`p-0`,children:[(0,K.jsx)(kS,{organizationId:e,enabled:t}),(0,K.jsx)(DS,{organizationId:e})]}):null}async function MS(e,t){let{data:n}=await P.patch(`/Organization/${e}/settings/oauth`,t);return n}var NS=`openid email profile`,PS=b({domain:x().min(1,`Domain is required`),clientId:x().min(1,`Client ID is required`),clientSecret:x().min(1,`Client secret is required`),scope:x().optional()}),FS=b({domain:x().min(1,`Domain is required`),clientId:x().optional(),clientSecret:x().optional(),scope:x().optional()});function IS(){let{organizationId:e}=z({strict:!1}),{user:t}=Sr(),{update:n}=cg(e),{data:r}=we(Yc(e)),i=Ze(),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(null),l=r.settings?.oauthConfigs??[],{mutate:u,isPending:d}=I({mutationFn:t=>MS(e,t),onSuccess:()=>void i.invalidateQueries({queryKey:[e]}),onError:e=>{pc(e)&&U.error(`Failed to update OAuth settings.`)}}),f=on({resolver:mt(PS),defaultValues:{domain:``,clientId:``,clientSecret:``,scope:NS}}),p=e=>{u({provider:`okta`,...e,scope:e.scope?.trim()||NS},{onSuccess:()=>{U.success(`OAuth provider added.`),f.reset(),o(!1)}})},m=on({resolver:mt(FS)}),h=e=>{c(e.id??null),m.reset({domain:e.domain,clientId:``,clientSecret:``,scope:e.scope??``})},g=(e,t)=>{let n={id:e.id,provider:e.provider,domain:t.domain,scope:t.scope?.trim()||NS};t.clientId&&(n.clientId=t.clientId),t.clientSecret&&(n.clientSecret=t.clientSecret),u(n,{onSuccess:()=>{U.success(`OAuth provider updated.`),c(null)}})},_=(e,t)=>{u({id:e.id,provider:e.provider,[t]:!e[t]})},v=e=>`//oauth/${e}/callback`,y=async e=>{await Ug(e)&&U.success(`Sign-in URL copied.`)},b=async e=>{await Ug(e)&&U.success(`Redirect URI copied.`)};return n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsx)(ub,{children:(0,K.jsxs)(`div`,{className:`max-w-5xl space-y-6 pb-12`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-2xl text-foreground font-light`,children:`Authentication`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Manage sign-in methods and API access for your organization.`})]}),(0,K.jsxs)(AS,{title:`OAuth providers`,actions:!a&&(0,K.jsxs)(H,{variant:`positiveOutline`,size:`sm`,onClick:()=>o(!0),children:[(0,K.jsx)(Uo,{}),`Add OAuth provider`]}),children:[l.length===0&&!a&&(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-4 text-center`,children:[(0,K.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-full bg-muted`,children:(0,K.jsx)(Qa,{"aria-hidden":!0,className:`size-5 text-muted-foreground`})}),(0,K.jsx)(`p`,{className:`font-medium`,children:`No OAuth providers configured`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Add your organization’s Okta so members can sign in with single sign-on.`})]}),l.map(e=>{let n=t?.oauthConfigId===e.id;return s===e.id?(0,K.jsxs)(`div`,{className:`border rounded-lg p-4 mb-3 text-foreground`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h4`,{className:`font-medium`,children:`Edit Provider`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(Ks,{className:`size-4`})})]}),(0,K.jsx)(Od,{...m,children:(0,K.jsxs)(`form`,{onSubmit:m.handleSubmit(t=>g(e,t)),className:`space-y-4`,children:[(0,K.jsx)(Y,{control:m.control,name:`domain`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Domain`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`e.g. company.okta.com`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`clientId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client ID`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`Leave blank to keep existing`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`clientSecret`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client Secret`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,placeholder:`Leave blank to keep existing`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`scope`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Scope`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:NS,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,K.jsx)(H,{type:`submit`,variant:`positive`,disabled:d,children:d?`Saving...`:`Save`}),(0,K.jsx)(H,{type:`button`,variant:`outline`,onClick:()=>c(null),children:`Cancel`})]})]})})]},e.id):(0,K.jsx)(`div`,{className:`border rounded-lg p-4 mb-3 text-foreground`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between sm:gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:e.domain}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground uppercase bg-muted px-2 py-0.5 rounded`,children:e.provider}),e.enabled===!1&&(0,K.jsx)(`span`,{className:`text-xs text-destructive bg-destructive/10 px-2 py-0.5 rounded`,children:`Disabled`})]}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground mb-2`,children:[`Client ID: `,(0,K.jsx)(`span`,{className:`text-foreground font-mono`,children:`****`})]}),e.id&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`mt-3 rounded-md bg-muted px-3 py-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Okta redirect URI`}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-1.5`,children:[`Add to `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Login redirect URIs`}),` `,`in your Okta app settings.`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-foreground font-mono truncate`,children:v(e.id)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>void b(v(e.id)),className:`hover:text-foreground shrink-0 text-muted-foreground`,title:`Copy redirect URI`,children:(0,K.jsx)(ea,{className:`size-3.5`})})]})]}),(0,K.jsxs)(`div`,{className:`mt-2 rounded-md bg-muted px-3 py-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`User login link`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`a`,{href:Tp(e.id),target:`_blank`,rel:`noreferrer`,className:`text-sm text-foreground truncate hover:underline`,children:Tp(e.id)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 text-muted-foreground`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>void y(Tp(e.id)),className:`hover:text-foreground`,title:`Copy login link`,children:(0,K.jsx)(ea,{className:`size-3.5`})}),(0,K.jsx)(`a`,{href:Tp(e.id),target:`_blank`,rel:`noreferrer`,className:`hover:text-foreground`,title:`Open login link`,children:(0,K.jsx)(fa,{className:`size-3.5`})})]})]})]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 sm:shrink-0`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-foreground cursor-pointer`,children:[(0,K.jsx)(Kx,{checked:e.enabled!==!1,onCheckedChange:()=>_(e,`enabled`),disabled:d}),`Enabled`]}),(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-sm text-foreground ${n?`cursor-pointer`:`cursor-not-allowed opacity-50`}`,children:[(0,K.jsx)(Kx,{checked:!!e.required,onCheckedChange:()=>_(e,`required`),disabled:d||!n}),`Required`]})}),!n&&(0,K.jsxs)(Xl,{children:[`Sign in via `,e.provider,` first to enable Required`]})]}),(0,K.jsx)(H,{variant:`outline`,size:`sm`,"aria-label":`Edit provider`,onClick:()=>h(e),disabled:d,children:(0,K.jsx)(zo,{className:`size-4`})})]})]})},e.id)}),a&&(0,K.jsxs)(`div`,{className:`border rounded-lg p-4 text-foreground`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h4`,{className:`font-medium`,children:`Add Okta Provider`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),f.reset()},className:`text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(Ks,{className:`size-4`})})]}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-4`,children:[`After saving, copy the `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Okta redirect URI`}),` `,`from the provider card and add it to your Okta app's`,` `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Login redirect URIs`}),`.`]}),(0,K.jsx)(Od,{...f,children:(0,K.jsxs)(`form`,{onSubmit:f.handleSubmit(p),className:`space-y-4`,children:[(0,K.jsx)(Y,{control:f.control,name:`domain`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Domain`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`e.g. company.okta.com`,autoFocus:!0,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:f.control,name:`clientId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client ID`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`Okta Client ID`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:f.control,name:`clientSecret`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client Secret`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,placeholder:`Okta Client Secret`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:f.control,name:`scope`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Scope`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:NS,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,K.jsx)(H,{type:`submit`,variant:`positive`,disabled:d,children:d?`Adding...`:`Add Provider`}),(0,K.jsx)(H,{type:`button`,variant:`outline`,onClick:()=>{o(!1),f.reset()},children:`Cancel`})]})]})})]})]}),(0,K.jsx)(jS,{organizationId:e,apiTokensEnabled:r.settings?.apiTokensEnabled===!0})]})})]}):(0,K.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))] text-foreground`,children:`You don't have permission to manage settings for this organization.`})}b({email:vf.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:x().nonempty({error:`Please select a role.`})});async function LS(e){let{data:t}=await P.post(`/UserInvite/`,e);return t}function RS(){return I({mutationFn:e=>LS(e)})}function zS({user:e}){let{update:t}=fg(),{mutate:n,isPending:r}=RS(),i=e.roles?.[0]?.id,a=(0,G.useCallback)(t=>{if(t.stopPropagation(),!e.email||!i){U.error(`Cannot resend invite: this user has no email or role.`);return}n({email:e.email,roleId:i},{onSuccess:()=>U.success(`Invitation resent to ${e.email}.`)})},[n,i,e.email]);return t?(0,K.jsxs)(H,{variant:`ghost`,size:`sm`,className:`h-auto px-2 py-0 align-middle text-sm`,onClick:a,disabled:r||!i,children:[(0,K.jsx)(_o,{}),` Resend invite`]}):null}var BS=[{header:`User Id`,accessorKey:`id`,enableSorting:!0,enableGlobalFilter:!1},{header:`Email`,accessorKey:`email`,enableSorting:!0},{header:`First Name`,accessorKey:`firstname`,enableSorting:!0},{header:`Last Name`,accessorKey:`lastname`,enableSorting:!0},{header:`Roles`,id:`roles`,accessorFn:e=>(e.roles??[]).map(e=>e.roleName).sort().join(`, `),enableSorting:!0},{header:`Status`,accessorKey:`status`,enableSorting:!0},{header:`Verified`,accessorKey:`isVerified`,enableSorting:!0},Bb().display({header:``,enableSorting:!1,id:`actions`,cell:e=>e.row.original.status===`PENDING`?(0,K.jsx)(zS,{user:e.row.original}):null})],VS=b({email:vf.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:x().nonempty({error:`Please select a role.`})});async function HS(e){let{data:t}=await P.post(`/OrganizationRole/`,e);return t}function US(){return I({mutationFn:e=>HS(e)})}function WS({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let{organizationId:r}=z({strict:!1}),{data:i,isLoading:a}=L({...$b(r),throwOnError:!0}),[o,s]=(0,G.useState)(!1),c=on({resolver:mt(VS),defaultValues:{email:``,roleId:``}}),{mutate:l,isPending:u}=US(),{mutate:d,isPending:f}=RS(),p=(0,G.useCallback)(async e=>{e&&(o?d:l)(e,{onSuccess:()=>{let r=e.roleId;c.reset(),c.setValue(`roleId`,r),t(),U.success(`User invited successfully!`),n(!1),s(!1)},onError:e=>{e?.status===404&&s(!0)}})},[l,c,d,t,n,o]);return(0,K.jsx)(_m,{onOpenChange:()=>{n(!1),s(!1),c.reset()},open:e,children:(0,K.jsx)(wm,{"aria-describedby":void 0,children:(0,K.jsx)(Od,{...c,children:(0,K.jsxs)(`form`,{id:`org-add-user-form`,name:`org-add-user-form`,onSubmit:c.handleSubmit(p),className:`grid gap-4 my-4`,children:[(0,K.jsx)(Tm,{children:(0,K.jsx)(Dm,{children:o?`Invite User`:`Add User`})}),(0,K.jsx)(Y,{control:c.control,name:`email`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Email`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`email`,enterKeyHint:`next`,autoComplete:`email`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:c.control,name:`roleId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Roles`}),a?(0,K.jsx)(my,{}):(0,K.jsx)(J,{children:(0,K.jsxs)(hy,{...e,onValueChange:t=>e.onChange(t),children:[(0,K.jsx)(vy,{className:`w-full`,children:(0,K.jsx)(_y,{placeholder:`Choose Role`})}),(0,K.jsx)(yy,{children:(0,K.jsxs)(gy,{children:[(0,K.jsx)(by,{children:`Role`}),i?.map(e=>(0,K.jsx)(xy,{value:e.id,children:(0,K.jsx)(hS,{name:e.roleName,id:e.id})},e.id))]})})]})}),(0,K.jsx)(Q,{})]})}),o&&(0,K.jsxs)(Om,{className:`p-3 my-5 rounded-md border border-amber-600 dark:border-amber-500 bg-amber-500/10 text-foreground flex`,children:[(0,K.jsx)(ho,{className:`inline-block size-12 pr-2 text-amber-700 dark:text-amber-400`}),(0,K.jsx)(`span`,{children:`This person doesn’t have a Fabric account. Do you want to invite them?`})]}),(0,K.jsx)(Em,{children:(0,K.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,K.jsxs)(H,{type:`submit`,variant:`submit`,disabled:u||f,children:[(0,K.jsx)($o,{}),` `,o?`Invite User`:`Add User`]})})})]})})})})}async function GS({roleId:e,userId:t}){let{data:n}=await P.delete(`/OrganizationRole/role/${e}/user/${t}`);return n}function KS(){return I({mutationFn:({roleId:e,userId:t})=>GS({roleId:e,userId:t})})}function qS(e){let[t,n]=(0,G.useState)(e||!1);return[t,(0,G.useCallback)(e=>{n(typeof e==`boolean`?e:e.target.checked)},[])]}function JS({data:e,readOnly:t,canRemove:n,orgRole:r,selectedRoles:i,setChangesMade:a}){let{mutate:o,isPending:s}=US(),{mutate:c,isPending:l}=KS(),u=!!i[r.id],[d,f]=(0,G.useState)(u),[p,m]=qS(u);return(0,G.useEffect)(()=>{p!==d&&(p?o({email:e.email,roleId:r.id},{onSuccess:()=>{f(p),a(!0),U.success(`Role added successfully`)}}):c({userId:e.id,roleId:r.id},{onSuccess:()=>{f(p),a(!0),U.success(`Role removed successfully`)}}))},[o,e.email,e.id,p,r.id,c,a,d]),(0,K.jsxs)(Md,{className:`flex`,children:[(0,K.jsx)($,{type:`checkbox`,className:`w-6`,disabled:t||s||l||!n&&p,checked:p,onChange:m}),(0,K.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:r.roleName})]},r.id)}function YS({isSelf:e,isPending:t,onConfirm:n}){let[r,i]=(0,G.useState)(!1),a=e?{idle:`Leave organization`,confirm:`Confirm leave`,busy:`Leaving…`,warning:`You’ll lose access to this organization and everything in it. You won’t be able to return unless another member invites you back.`}:{idle:`Remove from organization`,confirm:`Confirm removal`,busy:`Removing…`,warning:`This revokes their access to this organization and everything in it. Their Harper account isn’t deleted, and they can be added back later.`},o=e?uo:Bs;return r?(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`p`,{role:`alert`,className:`flex items-start gap-2 text-sm text-muted-foreground border border-amber-500/50 rounded-md p-3`,children:[(0,K.jsx)(Rs,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,K.jsx)(`span`,{children:a.warning})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(H,{type:`button`,variant:`ghostOutline`,disabled:t,onClick:()=>i(!1),children:`Cancel`}),(0,K.jsxs)(H,{type:`button`,variant:`destructive`,disabled:t,onClick:n,children:[(0,K.jsx)(o,{}),` `,t?a.busy:a.confirm]})]})]}):(0,K.jsx)(`div`,{className:`flex justify-start`,children:(0,K.jsxs)(H,{type:`button`,variant:`destructiveOutline`,disabled:t,onClick:()=>i(!0),children:[(0,K.jsx)(o,{}),` `,a.idle]})})}function XS(e){return e?.trim().toLowerCase()===`admin`}function ZS({canDelete:e,isSelf:t,orgUserCount:n,adminCount:r,isAdmin:i,roleCount:a}){let o=e?t&&n<=1?`sole-member`:t&&i&&r<=1?`last-admin`:null:null,s=e&&o===null;return{canRemoveRoles:s,showRemovalAction:s&&a>0,blockedReason:o}}function QS({closeModal:e,data:t,isModalOpen:n,onUserUpdated:r,orgUserCount:i,orgAdminCount:a}){let{organizationId:o}=z({strict:!1}),s=Sr(),{update:c,remove:l}=fg(o),u=s.user?.email===t.email,[d,f]=(0,G.useState)(!1),{canRemoveRoles:p,showRemovalAction:m,blockedReason:h}=ZS({canDelete:l,isSelf:u,orgUserCount:i,adminCount:a,isAdmin:(t.roles??[]).some(e=>XS(e.roleName)),roleCount:t.roles?.length??0}),{mutateAsync:g}=KS(),[_,v]=(0,G.useState)(!1),y=(0,G.useCallback)(async()=>{let e=t.roles??[];v(!0);let n=(await Promise.allSettled(e.map(e=>g({userId:t.id,roleId:e.id})))).flatMap(e=>e.status===`rejected`&&e.reason?.response?.status!==404?[e.reason]:[]);n.some(pc)?U.error(u?`Something went wrong leaving the organization. Please try again.`:`Couldn’t remove ${t.email} from the organization. Please try again.`):n.length===0&&U.success(u?`You’ve left the organization.`:`${t.email} was removed from the organization.`),v(!1),r()},[t.roles,t.id,t.email,u,g,r]);return(0,K.jsx)(_m,{onOpenChange:d?r:e,open:n,children:(0,K.jsxs)(wm,{resizable:!0,children:[(0,K.jsx)(Tm,{children:(0,K.jsxs)(Dm,{children:[c?`Edit `:`View `,` `,t.email,` `,u?`(yourself)`:``]})}),c&&(0,K.jsxs)(Om,{children:[`Use the checkboxes to change which roles `,u?`you have`:`this user has`,`.`,m&&(u?` To leave the organization entirely, use the button below.`:` To remove this user from the organization entirely, use the button below.`)]}),(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(Lc,{centered:!0,text:`Loading roles…`,className:`flex-1 min-h-0`}),children:(0,K.jsx)($S,{data:t,organizationId:o,update:c,canRemove:p,setChangesMade:f})}),t.status===`PENDING`&&(0,K.jsx)(`div`,{className:`border-t border-border pt-4`,children:(0,K.jsx)(zS,{user:t})}),m&&(0,K.jsx)(`div`,{className:`border-t border-border pt-4`,children:(0,K.jsx)(YS,{isSelf:u,isPending:_,onConfirm:y})}),h&&(0,K.jsxs)(`p`,{className:`flex items-start gap-2 text-sm text-muted-foreground border border-amber-500/50 rounded-md p-3`,children:[(0,K.jsx)(Rs,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,K.jsx)(`span`,{children:h===`sole-member`?`You’re the only member of this organization, so you can’t remove your roles or leave — it would be left with no one to manage it. If you no longer need this organization, terminate its clusters, then delete the organization from the ⋯ menu on the Organizations page.`:`You’re the only admin of this organization, so you can’t remove your roles or leave — it would be left with no one who can manage its members, roles, or clusters. Give another member the admin role first, then you can step back.`})]})]})})}function $S({data:e,organizationId:t,update:n,canRemove:r,setChangesMade:i}){let{data:a}=we($b(t)),o=(0,G.useMemo)(()=>e.roles?O_(e.roles,`id`):{},[e]);return(0,K.jsx)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 overflow-y-auto`,children:a.map(t=>(0,K.jsx)(JS,{readOnly:!n,canRemove:r,data:e,orgRole:t,selectedRoles:o,setChangesMade:i},t.id))})}function eC(e,t){return e.email>t.email?1:-1}function tC(e){return(e.users??[]).filter(e=>e!=null)}function nC(e){let t={};for(let n of e)for(let e of tC(n))t[e.id]||(t[e.id]={...e,roles:[]}),t[e.id].roles.push(n);return Object.values(t).sort(eC)}function rC(e){let t=new Set;for(let n of e)if(XS(n.roleName))for(let e of tC(n))t.add(e.id);return t.size}function iC(){let e=De(),{organizationId:t,orgUserId:n}=z({strict:!1}),{update:r}=fg(t),{data:i,refetch:a,isFetching:o,isRefetching:s}=we($b(t)),c=(0,G.useMemo)(()=>nC(i),[i]),l=(0,G.useMemo)(()=>rC(i),[i]),u=(0,G.useMemo)(()=>c?.find(e=>e.id===n),[c,n]),d=(0,G.useCallback)(t=>{let r=[n?`..`:``,t].filter(Boolean);e({to:r.join(`/`)})},[n,e]),f=!!n&&!!u,[p,m]=(0,G.useState)(!1),[h]=(0,G.useState)({attribute:`email`,descending:!1}),g=(0,G.useMemo)(()=>[{desc:h.descending,id:h.attribute}],[h]),_=(0,G.useCallback)(()=>{m(!0)},[m]),v=(0,G.useCallback)(()=>{a(),m(!1)},[a,m]),y=(0,G.useCallback)(e=>{d(e.original.id)},[d]),b=(0,G.useCallback)(()=>{d(void 0)},[d]),x=(0,G.useCallback)(()=>{a(),d(void 0)},[d,a]),S=Kb(a);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsx)(ub,{children:(0,K.jsxs)(G.Suspense,{fallback:(0,K.jsx)(Lc,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,K.jsxs)(Hb,{data:c,isFetching:o||s,columns:BS,onRowClick:y,sortingState:g,filter:{label:`Filter users`,placeholder:`Filter by email, name, role or status`},paginated:!0,children:[(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:S,accessKey:`r`,disabled:o||s,children:[(0,K.jsx)(Go,{}),` `,(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),r&&(0,K.jsxs)(H,{variant:`positiveOutline`,onClick:_,accessKey:`a`,disabled:p,children:[(0,K.jsx)(Uo,{}),` `,(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]}),r&&(0,K.jsx)(WS,{isModalOpen:p,onChangesSaved:v,setIsModalOpen:m}),f&&(0,K.jsx)(QS,{closeModal:b,data:u,isModalOpen:f,onUserUpdated:x,orgUserCount:c.length,orgAdminCount:l})]})})]})}function aC({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`skeleton`,className:F(`bg-primary/10 animate-pulse rounded-md`,e),...t})}function oC({organizationId:e,organizationName:t,providers:n}){return(0,K.jsxs)(Er,{className:`relative gap-0 py-0 h-full justify-between overflow-hidden border border-amber-500/30`,children:[(0,K.jsxs)(Dr,{className:`gap-4 py-5 border-b border-primary/10 bg-linear-to-br from-primary/5 to-primary/20 dark:from-primary/20 dark:to-primary/5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`rounded-lg border border-primary/20 bg-background/50 p-2 text-primary dark:text-violet-300`,children:(0,K.jsx)(fi,{className:`size-5`,"aria-hidden":`true`})}),(0,K.jsx)(`span`,{className:`rounded-full border border-amber-500/30 bg-amber-500/10 px-2 py-1 text-xs`,children:`Sign-in required`})]}),(0,K.jsx)(Or,{children:(0,K.jsx)(`h2`,{className:`truncate text-xl`,title:t||e,children:t||e})}),t&&t!==e&&(0,K.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,title:e,children:e})]}),(0,K.jsxs)(Ar,{className:`py-4 flex flex-col gap-2`,children:[(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-1.5 mb-1`,children:[(0,K.jsx)(Ha,{className:`size-3 shrink-0`}),`Sign in with an OAuth provider to access this organization.`]}),n.map(e=>(0,K.jsx)(`a`,{href:Tp(e.oauthConfigId),children:(0,K.jsxs)(H,{variant:`outline`,className:`w-full`,children:[`Sign in with `,e.name]})},e.oauthConfigId))]})]})}var sC=b({couponId:x().nonempty({message:`Please enter a coupon ID.`}).trim()});async function cC({organizationId:e,couponId:t}){let n=await P.post(`/Coupon`,{organizationId:e,couponId:t},{validateStatus:e=>e>=200&&e<400||e===400||e===409});if(n.status===400||n.status===409)return fc({response:n}).message}function lC(){return I({mutationFn:cC})}function uC({organizationId:e,organizationName:t,isOpen:n,onClose:r}){let{mutate:i,isPending:a}=lC(),o=on({resolver:mt(sC),defaultValues:{couponId:``}}),{handleSubmit:s,control:c,reset:l}=o;(0,G.useEffect)(()=>{n&&l({couponId:``})},[n,l]);let u=(0,G.useCallback)(n=>{i({organizationId:e,couponId:n.couponId},{onSuccess:i=>{i?U.error(`Error`,{description:i}):(U.success(`Success`,{description:`Coupon "${n.couponId}" added to ${t||e}.`}),r())}})},[i,e,t,r]);return(0,K.jsx)(_m,{open:n,onOpenChange:e=>!e&&r(),children:(0,K.jsxs)(wm,{children:[(0,K.jsxs)(Tm,{children:[(0,K.jsx)(Dm,{children:`Add Coupon`}),(0,K.jsxs)(Om,{children:[`Add a coupon code to`,` `,t||e,`. This coupon will be applied to the next billing cycle.`,(0,K.jsx)(`br`,{}),`Coupons can be created in our`,` `,(0,K.jsx)(`a`,{href:`https://dashboard.stripe.com/`,target:`_blank`,rel:`noreferrer`,className:`text-purple hover:underline`,children:`Stripe Dashboard`}),`.`]})]}),(0,K.jsx)(Od,{...o,children:(0,K.jsxs)(`form`,{onSubmit:s(u),children:[(0,K.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,K.jsx)(Y,{control:c,name:`couponId`,render:({field:e})=>(0,K.jsxs)(X,{className:`grid items-center gap-4`,children:[(0,K.jsx)(Z,{children:`Coupon ID`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{...e,placeholder:`e.g. 100OFF`,disabled:a})}),(0,K.jsx)(Q,{})]})})}),(0,K.jsxs)(Em,{children:[(0,K.jsx)(H,{type:`button`,variant:`ghost`,onClick:r,disabled:a,children:`Cancel`}),(0,K.jsx)(H,{type:`submit`,disabled:a,children:a?`Adding...`:`Add Coupon`})]})]})})]})})}function dC({organizationRole:e,onDeleteOrgModal:t}){let{organizationId:n,organizationName:r,roleName:i}=e,a=r||n,o={organizationId:n},s=qg(o),[c]=Gg(n),{remove:l,update:u}=cg(n),d=u,{view:f}=fg(n),p=wr(`billing:write`),[m,h]=(0,G.useState)(!1),g=(0,G.useCallback)(()=>{t(e)},[t,e]),_=[{type:`label`,key:`label`,className:`text-gray-600 text-xs`,label:`Options`},{type:`separator`,key:`sep-top`},{key:`clusters`,to:s,icon:(0,K.jsx)(ss,{className:`size-4 mr-2 text-blue-500`}),label:`Clusters`},f&&{key:`roles`,to:qg(o,`roles`),icon:(0,K.jsx)(ds,{className:`size-4 mr-2 text-purple`}),label:`Roles`},f&&{key:`users`,to:qg(o,`users`),icon:(0,K.jsx)(Ws,{className:`size-4 mr-2 text-orange-500`}),label:`Users`},d&&{key:`billing`,to:qg(o,`billing`),icon:(0,K.jsx)(na,{className:`size-4 mr-2 text-green-500`}),label:`Billing`},u&&{key:`settings`,to:qg(o,`settings`),icon:(0,K.jsx)(Ha,{className:`size-4 mr-2 text-yellow-500`}),label:`Settings`},p&&{key:`add-coupon`,onClick:()=>h(!0),icon:(0,K.jsx)(Ps,{className:`size-4 mr-2 text-pink-500`}),label:`Add Coupon`},l&&{type:`separator`,key:`sep-bottom`},l&&{key:`delete`,onClick:g,className:`focus:bg-red/70 focus:text-white`,icon:(0,K.jsx)(Is,{className:`size-4 mr-2 text-red-500`}),label:`Delete`}].filter(fr),v=l||p;return(0,K.jsx)(zm,{items:v?_:[],children:(0,K.jsxs)(Er,{className:`group relative gap-0 py-0 h-full cursor-pointer justify-between overflow-hidden border border-primary/15 transition-[border-color,box-shadow] duration-200 hover:border-primary/60 hover:shadow-lg hover:ring-2 hover:ring-primary/40 dark:hover:ring-violet-400/60`,children:[(0,K.jsx)(V,{to:s,"aria-label":`Open ${a}`,className:`absolute inset-0 z-10 cursor-pointer rounded-[inherit] focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring focus-visible:outline-none`}),(0,K.jsxs)(Dr,{className:`gap-4 py-5 border-b border-primary/10 bg-linear-to-br from-primary/5 to-primary/20 dark:from-primary/20 dark:to-primary/5`,children:[(0,K.jsxs)(kr,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,K.jsx)(`span`,{className:`rounded-lg border border-primary/20 bg-background/50 p-2 text-primary dark:text-violet-300`,children:(0,K.jsx)(fi,{className:`size-5`,"aria-hidden":`true`})}),v&&(0,K.jsxs)(gc,{children:[(0,K.jsxs)(_c,{"aria-label":`Options`,onClick:e=>e.stopPropagation(),className:`relative z-20 inline-flex cursor-pointer shrink-0 items-center gap-1.5 rounded-md border border-primary/25 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground shadow-sm transition-colors hover:border-primary/60 hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-ring`,children:[`Options `,(0,K.jsx)(er,{className:`size-3.5`,"aria-hidden":`true`})]}),(0,K.jsx)(vc,{align:`end`,children:Rm(_,`dropdown`)})]})]}),(0,K.jsx)(Or,{children:(0,K.jsx)(`h2`,{className:`truncate text-xl`,title:a,children:a})}),(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs text-muted-foreground`,children:[n!==a&&(0,K.jsx)(`span`,{className:`truncate`,title:n,children:n}),(0,K.jsx)(`button`,{type:`button`,onClick:c,"aria-label":`Copy ID for ${a}`,className:`relative z-20 shrink-0 cursor-pointer rounded p-1 hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-ring`,children:(0,K.jsx)(ea,{className:`size-3.5`,"aria-hidden":`true`})})]})]}),(0,K.jsxs)(Ar,{className:`py-4 flex items-center justify-between gap-2`,children:[(0,K.jsx)(ol,{variant:`outline`,className:`min-w-0 shrink border-primary/25 bg-primary/10 text-foreground`,title:_d(i),children:(0,K.jsx)(`span`,{className:`truncate`,children:_d(i)})}),(0,K.jsxs)(`span`,{className:`text-sm shrink-0 py-2 whitespace-nowrap ml-auto`,children:[`Open `,(0,K.jsx)(Wr,{className:`inline-block`})]})]}),(0,K.jsx)(uC,{organizationId:n,organizationName:r,isOpen:m,onClose:()=>h(!1)})]})})}function fC(e,t){let n=t.toLowerCase();return t=>{for(let r of e){let e=t[r];if(e!=null){if(typeof e==`string`){if(e.toLowerCase().includes(n))return!0}else if(typeof e==`boolean`){if(e&&(n===`yes`||n===`true`||n===`1`)||!e&&(n===`no`||n===`false`||n===`0`))return!0}else throw Error(`curryFilterByFuzzySearch has not implemented support for `+typeof e+` fields yet!`)}}return!1}}function pC(e){let t=e.filter(e=>e.locked).length;return{total:e.length,accessible:e.length-t,locked:t}}function mC(e,t,n,r,i){return e.filter(fC([`id`,`name`],t)).filter(e=>n===`all`||(n===`locked`?e.locked:!e.locked)).filter(e=>!r||!e.locked&&e.roleName===r).sort((e,t)=>(e.name.localeCompare(t.name)||e.id.localeCompare(t.id))*(i?-1:1))}async function hC(e){let{data:t}=await P.delete(`/Organization/${e}`);return t}function gC(){let e=Ze();return I({mutationFn:e=>hC(e),onSuccess:(t,n)=>{e.removeQueries({queryKey:[n]}),e.invalidateQueries({queryKey:[]})}})}async function _C(e){let{data:t}=await P.post(`/Organization/`,{...e});return t}function vC(){return I({mutationFn:e=>_C(e)})}var yC=x().max(62,{error:`Must be at most 62 characters long.`}).regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,{error:`Please only use lowercase letters, digits and dashes (-) in the subdomain. Must not start or end with a dash.`}),bC=b({name:x().max(255,{error:`Name cannot be longer than 255 characters.`}),subdomain:te([O(``),w(),yC]).optional()});function xC(){let{user:e}=Sr(),t=De(),n=on({resolver:mt(bC),defaultValues:{name:``,subdomain:``}}),{setFocus:r,watch:i}=n;(0,G.useEffect)(()=>{r(`name`)},[r]);let a=`${e?.firstname} ${e?.lastname} Org`,o=i(`name`)||a,s=i(`subdomain`),c=(0,G.useMemo)(()=>{let e=L_(z_(o),yC.maxLength);return{suggestedSubdomain:e,fullHostName:`future-cluster-names.${s||e}.harperfabric.com`}},[o,s]),{mutate:l,isPending:d}=vC(),p=Ze(),h=(0,G.useCallback)(async e=>{l({name:e.name||a,subdomain:e.subdomain||c.suggestedSubdomain},{onSuccess:e=>{p.invalidateQueries({queryKey:f,refetchType:`active`}),u.reloadUser(m),t({to:`/${e.id}`})}})},[c.suggestedSubdomain,p,l,a,t]);return(0,K.jsx)(K.Fragment,{children:(0,K.jsx)(Od,{...n,children:(0,K.jsxs)(`form`,{id:`org-add-form`,name:`org-add-form`,onSubmit:n.handleSubmit(h),className:`grid items-start gap-6 text-foreground lg:grid-cols-[1.2fr_1fr]`,children:[(0,K.jsxs)(Er,{className:`min-w-0 gap-0 overflow-hidden py-0`,children:[(0,K.jsxs)(Dr,{className:`border-b border-primary/10 bg-linear-to-br from-primary/5 to-primary/20 py-5 dark:from-primary/20 dark:to-primary/5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-primary dark:text-violet-300`,children:[(0,K.jsx)(fi,{className:`size-4`,"aria-hidden":`true`}),(0,K.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:`Organization details`})]}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Choose a name and an address for your organization.`})]}),(0,K.jsxs)(Ar,{className:`grid gap-6 py-6`,children:[(0,K.jsx)(Y,{control:n.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,K.jsx)(cy,{type:`text`,className:`bg-background/60`,maxLength:bC.shape.name.maxLength,autoCapitalize:`words`,placeholder:a,...e}),(0,K.jsx)(ky,{children:`Use a name your team will recognize.`}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:n.control,name:`subdomain`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Subdomain`}),(0,K.jsx)(cy,{type:`text`,className:`bg-background/60`,maxLength:yC.maxLength,autoCapitalize:`none`,placeholder:c.suggestedSubdomain,...e}),(0,K.jsx)(ky,{children:`Lowercase letters, numbers, and dashes. Leave blank to use the suggested subdomain.`}),(0,K.jsx)(Q,{})]})})]}),(0,K.jsx)(`div`,{className:`border-t border-border/60 bg-muted/20 px-6 py-5`,children:(0,K.jsxs)(H,{type:`submit`,variant:`submit`,disabled:d,className:`w-full sm:w-auto`,children:[d?`Creating organization…`:`Create organization`,` `,(0,K.jsx)(Wr,{"aria-hidden":`true`})]})})]}),(0,K.jsxs)(`aside`,{className:`min-w-0 rounded-2xl border border-primary/15 bg-primary/5 p-6`,"aria-labelledby":`org-address-heading`,children:[(0,K.jsxs)(`div`,{className:`mb-4 flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary dark:text-violet-300`,children:(0,K.jsx)(ca,{className:`size-5`,"aria-hidden":`true`})}),(0,K.jsx)(`h2`,{id:`org-address-heading`,className:`text-base font-semibold`,children:`Your cluster addresses`})]}),(0,K.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-muted-foreground`,children:`Your subdomain is part of the address for Harper-hosted clusters you create in this organization.`}),(0,K.jsxs)(`div`,{className:`my-5`,children:[(0,K.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:`Address preview`}),(0,K.jsx)(sy,{hostname:c.fullHostName,testId:`org-hostname-preview`})]}),(0,K.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`The cluster name here is a placeholder. After creating your organization, you’ll name your first cluster!`}),(0,K.jsxs)(`div`,{className:`mt-5 border-t border-primary/15 pt-5`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium`,children:`Prefer your own domain?`}),(0,K.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-muted-foreground`,children:`You can also bind a domain you own to a Harper-hosted cluster after creating it.`}),(0,K.jsxs)(`a`,{href:`https://docs.harperdb.io/fabric/custom-domains`,target:`_blank`,rel:`noopener noreferrer`,className:`mt-3 inline-flex items-center gap-1.5 rounded-sm text-sm font-medium text-primary underline underline-offset-4 hover:no-underline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring dark:text-violet-300`,children:[`Learn about custom domains`,(0,K.jsx)(fa,{className:`size-3.5`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`(opens in a new tab)`})]})]})]})]})})})}function SC(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsxs)(`section`,{className:`mx-auto mt-32 w-full max-w-6xl px-4 py-8 md:px-12 md:py-10`,children:[(0,K.jsxs)(`header`,{className:`mb-8 flex items-center gap-4`,children:[(0,K.jsx)(`div`,{className:`flex size-14 shrink-0 items-center justify-center rounded-2xl border border-primary/20 bg-primary/10 text-primary dark:text-violet-300`,children:(0,K.jsx)(fi,{className:`size-6`,"aria-hidden":`true`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`mb-1 text-xs font-medium uppercase tracking-widest text-muted-foreground`,children:`Your workspace`}),(0,K.jsx)(`h1`,{className:`text-3xl font-semibold tracking-tight`,children:`Create an organization`}),(0,K.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`A home for your team and clusters in Harper Fabric.`})]})]}),(0,K.jsx)(xC,{})]})]})}var CC={org:`organization`,clu:`cluster`,ins:`instance`},wC=/^(org|clu|ins)-[a-z0-9]+$/;function TC(e){if(typeof e!=`string`)return null;let t=e.trim(),n=wC.exec(t);return n?{kind:CC[n[1]],id:t}:null}function EC(e,t){let n=e*12,r=DC(t);return`/Admin/Organization/?${[...r?[`search=${encodeURIComponent(r)}`]:[],`status=ne=DELETED`,...r?[]:[`sort(name)`],`limit(${n},${n+12+1})`].join(`&`)}`}function DC(e){return typeof e==`string`?e.trim():``}async function OC(e,t){let{data:n}=await P.get(EC(e,t));return{organizations:n.slice(0,12),hasNextPage:n.length>12}}var kC={organizations:[],hasNextPage:!1};function AC(e){return e instanceof E&&(e.response?.status===404||e.status===404)}async function jC(e){try{let{data:t}=await P.get(`/Admin/Organization/${e}`);return t?{organizations:[t],hasNextPage:!1}:kC}catch(e){if(AC(e))return kC;throw e}}async function MC(e){try{let{data:t}=await P.get(`/Cluster/${e}`),n=t?.organizationId;return n?await jC(n):kC}catch(e){if(AC(e))return kC;throw e}}function NC(e,t){let n=DC(t),r=TC(n);return B({queryKey:[`admin-all-organizations`,n,e],queryFn:()=>r?.kind===`organization`?jC(r.id):r?.kind===`cluster`?MC(r.id):OC(e,n),placeholderData:He,retry:!1})}function PC(e,t=300,n){let[r,i]=(0,G.useState)(e),a=n?n(e):e;return(0,G.useEffect)(()=>{let n=setTimeout(()=>i(e),t);return()=>clearTimeout(n)},[a,t]),r}function FC(e,t){let n=(0,G.useRef)({key:e,defaultValue:t});(0,G.useInsertionEffect)(()=>{n.current={key:e,defaultValue:t}});let r=(0,G.useRef)(!0);(0,G.useLayoutEffect)(()=>(r.current=!0,()=>{r.current=!1}),[]);let i=(0,G.useCallback)(t=>uu(e,n.current.defaultValue,t),[e]);return[(0,G.useSyncExternalStore)(i,()=>cu(e,t)),(0,G.useCallback)(e=>{r.current&&lu(n.current.key,n.current.defaultValue,e)},[])]}function IC(){let{data:e}=we(s()),{mutate:t,isPending:n}=gC(),[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(null),[c,l]=(0,G.useState)(``),[u,d]=(0,G.useState)(`all`),[f,p]=(0,G.useState)(``),[m,h]=(0,G.useState)(!1),g=()=>{l(``),d(`all`),p(``),h(!1),x(0)},_=wr(`org:read`),[v,y]=FC(`ShowAllOrganizations`,!1),[b,x]=(0,G.useState)(0),S=_&&v,C=(0,G.useCallback)(e=>{y(e),x(0)},[y]),w=PC(c,300),T=(0,G.useMemo)(()=>{if(!_)return null;let e=TC(w);return e?.kind===`organization`||e?.kind===`cluster`?e:null},[_,w]),E=S||!!T,{data:D,isPending:O,isError:k,isFetching:A,refetch:j}=L({...NC(b,w),enabled:E}),M=(0,G.useMemo)(()=>Nr(e),[e]),ee=(0,G.useMemo)(()=>pC(M),[M]),te=(0,G.useMemo)(()=>[...new Set(M.filter(e=>!e.locked).map(e=>e.roleName))].sort(),[M]),N=te.includes(f)?f:``,P=(0,G.useMemo)(()=>E?[]:mC(M,c,u,N,m),[M,c,u,N,m,E]),F=!!c||u!==`all`||!!N||m,ne=(0,G.useMemo)(()=>{let t=e?.roles||{};return(D?.organizations||[]).map(e=>({organizationId:e.id,organizationName:e.name||e.id,roleName:t[e.id]?.role||`fabric staff`}))},[D?.organizations,e?.roles]),re=(0,G.useCallback)(e=>{l(e.currentTarget.value||``),x(0)},[]),ie=(0,G.useCallback)(e=>{e?.organizationId&&t(e.organizationId,{onSuccess:()=>{U.success(`Success`,{description:`Organization successfully deleted.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),i(!1)},onError:()=>i(!1)})},[t,i]),ae=(0,G.useCallback)(e=>{o(e),i(!0)},[]),{createCluster:oe}=Oe({strict:!1});return!E&&ee.accessible===1&&!F&&oe?(0,K.jsx)(qe,{to:`/${M.find(e=>!e.locked).id}/new-cluster`,replace:!0}):!E&&!M.length&&!F?(0,K.jsx)(SC,{}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsxs)(`section`,{className:`mt-32 px-4 pt-6 pb-10 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:[(0,K.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-4 pb-6`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-bold tracking-normal text-primary sm:text-3xl dark:text-violet-300`,children:`Organizations`}),(0,K.jsx)(H,{asChild:!0,variant:`positive`,accessKey:`n`,children:(0,K.jsxs)(V,{to:`/new-org`,children:[(0,K.jsx)(Uo,{}),`New Organization`]})})]}),!E&&(0,K.jsx)(`div`,{role:`group`,"aria-label":`Organization summary`,className:`mb-5 hidden grid-cols-3 gap-3 sm:grid`,children:[{value:`all`,label:`Total organizations`,count:ee.total},{value:`accessible`,label:`Accessible`,count:ee.accessible},{value:`locked`,label:`Sign-in required`,count:ee.locked}].map(e=>(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":u===e.value,onClick:()=>{d(e.value),p(``)},className:`flex cursor-pointer items-center justify-between rounded-xl border px-4 py-3 text-sm transition-colors hover:border-primary/60 focus-visible:outline-2 focus-visible:outline-ring ${u===e.value?`border-primary/40 bg-primary/10`:`border-border bg-card/60`}`,children:[(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,K.jsx)(`span`,{className:`text-xl font-semibold`,children:e.count})]},e.value))}),(0,K.jsxs)(`div`,{role:`search`,"aria-label":`Find organizations`,className:`mb-4 flex flex-wrap items-center gap-3 rounded-xl border border-border bg-card/60 p-3`,children:[(0,K.jsx)($,{"aria-label":`Search organizations`,placeholder:`Search name or ID…`,className:`min-w-0 flex-1 basis-56 dark:bg-background/60`,value:c,onChange:re}),!E&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`select`,{"aria-label":`Organization access`,value:u,onChange:e=>{d(e.target.value),p(``)},className:`max-w-full rounded-lg border border-border bg-background px-3 py-2 text-sm`,children:[(0,K.jsx)(`option`,{value:`all`,children:`All access`}),(0,K.jsx)(`option`,{value:`accessible`,children:`Accessible`}),(0,K.jsx)(`option`,{value:`locked`,children:`Sign-in required`})]}),u!==`locked`&&(te.length>1||!!N)&&(0,K.jsxs)(`select`,{"aria-label":`Organization role`,value:N,onChange:e=>p(e.target.value),className:`max-w-full rounded-lg border border-border bg-background px-3 py-2 text-sm`,children:[(0,K.jsx)(`option`,{value:``,children:`All roles`}),te.map(e=>(0,K.jsx)(`option`,{value:e,children:_d(e)},e))]}),(0,K.jsxs)(`select`,{"aria-label":`Sort organizations`,value:m?`desc`:`asc`,onChange:e=>h(e.target.value===`desc`),className:`max-w-full rounded-lg border border-border bg-background px-3 py-2 text-sm`,children:[(0,K.jsx)(`option`,{value:`asc`,children:`Name: A–Z`}),(0,K.jsx)(`option`,{value:`desc`,children:`Name: Z–A`})]})]}),_&&(0,K.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm`,children:[(0,K.jsx)(Kx,{checked:v,onCheckedChange:C,"aria-label":`Show all organizations`}),`All organizations`]})]}),(0,K.jsx)(`p`,{role:`status`,className:`mb-4 text-xs text-muted-foreground`,children:E?`Staff directory · Server search and pagination`:`Showing ${P.length} of ${ee.total} organizations`}),E&&k&&(0,K.jsxs)(`div`,{role:`alert`,className:`mb-4 rounded-xl border p-6`,children:[(0,K.jsx)(`p`,{children:D?`Organizations couldn’t be refreshed. Showing the last available results.`:`Organizations couldn’t be loaded.`}),(0,K.jsx)(H,{variant:`outline`,disabled:A,onClick:()=>void j(),children:A?`Retrying…`:`Retry`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-5 md:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4`,children:[E?O?Array.from({length:12},(e,t)=>(0,K.jsx)(aC,{className:`h-48`},t)):ne.map(e=>(0,K.jsx)(dC,{organizationRole:e,onDeleteOrgModal:ae},e.organizationId)):P.map(e=>e.locked?(0,K.jsx)(oC,{organizationId:e.id,organizationName:e.name,providers:e.providers},e.id):(0,K.jsx)(dC,{organizationRole:{organizationId:e.id,organizationName:e.name,roleName:e.roleName},onDeleteOrgModal:ae},e.id)),(E?!O&&!k&&!ne.length:!P.length)&&(0,K.jsxs)(`div`,{className:`col-span-full rounded-xl border border-dashed p-10 text-center`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-medium`,children:`No matching organizations`}),(0,K.jsx)(`p`,{className:`my-3 text-sm text-muted-foreground`,children:`Try another name or clear your filters.`}),(0,K.jsx)(H,{variant:`outline`,onClick:g,children:`Clear filters`})]})]}),E&&(b>0||D?.hasNextPage)&&(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-4 py-6`,children:[(0,K.jsxs)(H,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:b===0,onClick:()=>x(e=>e-1),children:[(0,K.jsx)(Hr,{}),`Previous`]}),(0,K.jsxs)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:[`Page `,b+1]}),(0,K.jsxs)(H,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:!D?.hasNextPage,onClick:()=>x(e=>e+1),children:[`Next`,(0,K.jsx)(Wr,{})]})]})]}),a&&(0,K.jsx)(km,{typeOfThingBeingDeleted:`organization`,nameOfThingBeingDeleted:a.organizationName,isModalOpen:r,setIsModalOpen:()=>i(!1),deletionConfirmed:()=>ie(a),deletionPending:n})]})}var LC=R({getParentRoute:()=>Uu,id:`_orgsLayout`});R({getParentRoute:()=>LC,path:`/`,head:()=>({meta:[{title:`Organizations — Harper Fabric`}]}),component:IC}),R({getParentRoute:()=>LC,path:`/new-org`,head:()=>({meta:[{title:`New Organization — Harper Fabric`}]}),component:SC});async function RC(e,t){let{queryClient:n}=e.context,r=u.getSignOutGeneration(m),i;if(!e.preload){let r=n.getQueryCache().build(n,n.defaultQueryOptions(t));r.state.data===void 0&&(i=uc(r,e.abortController.signal))}try{return await n.ensureQueryData(t)}catch(e){if(Ie(e)&&u.getSignOutGeneration(`OverallAppSignIn`)!==r)return new Promise(()=>void 0);throw e}finally{i?.()}}var zC=R({getParentRoute:()=>LC,path:`$organizationId`,errorComponent:Zb,beforeLoad:async e=>{let{organizationId:t}=e.params;if(!qc(t))throw Ne({to:`/`});return{organization:await RC(e,Yc(t))}}});R({getParentRoute:()=>zC,path:`/roles`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:Gx}),R({getParentRoute:()=>zC,path:`/roles/$orgRoleId`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:Gx}),R({getParentRoute:()=>zC,path:`/users`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:iC}),R({getParentRoute:()=>zC,path:`/users/$orgUserId`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:iC}),R({getParentRoute:()=>zC,path:`/settings`,component:IS}),Xb(zC);var BC=R({getParentRoute:()=>zC,id:`_clusterLayout`});R({getParentRoute:()=>BC,path:`/`,head:()=>({meta:[{title:`Clusters — Harper Fabric`}]}),component:fb}),R({getParentRoute:()=>zC,path:`/new-cluster`,head:()=>({meta:[{title:`New Cluster — Harper Fabric`}]}),component:lb}),R({getParentRoute:()=>WC,path:`/edit`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),beforeLoad:sm,component:lb}),R({getParentRoute:()=>WC,path:`/edit/$mode`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),beforeLoad:sm,component:lb});function VC(){return(0,K.jsx)(st,{})}function HC(){return(0,K.jsxs)(`div`,{className:`text-center py-12`,children:[(0,K.jsx)(ss,{className:`size-12 text-muted-foreground mx-auto mb-4`}),(0,K.jsx)(`h1`,{className:`text-xl font-medium mb-2 text-foreground`,children:`Pending Owner Setup`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-md mx-auto`,children:`This cluster needs an administrator to finish setup before it can be used.`})]})}function UC({error:e,reset:t}){let{organizationId:n}=z({strict:!1});return Rc(e)?(0,K.jsxs)(`div`,{className:`flex flex-col items-center mt-24`,children:[(0,K.jsx)(HC,{}),n&&(0,K.jsx)(V,{to:`/${n}`,children:(0,K.jsxs)(H,{variant:`outline`,children:[(0,K.jsx)(Hr,{}),` Back to clusters`]})})]}):(0,K.jsx)(oc,{error:e,reset:t})}var WC=R({getParentRoute:()=>BC,path:`$clusterId`,component:VC,errorComponent:UC,beforeLoad:async e=>({cluster:await RC(e,_f(e.params.clusterId))})}),GC=e=>new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e),KC=e=>`${new Intl.NumberFormat(void 0,{maximumFractionDigits:1}).format(e)} hr`,qC=e=>zy(e),JC={reads:`Reads`,readBytes:`Read data`,writes:`Writes`,writeBytes:`Write data`,realTimeMessages:`Real-time messages`,realTimeBytes:`Real-time data`,cpuTimeHours:`Compute`,storageBytes:`Storage`},YC={reads:GC,readBytes:qC,writes:GC,writeBytes:qC,realTimeMessages:GC,realTimeBytes:qC,cpuTimeHours:KC,storageBytes:qC},XC=[`reads`,`readBytes`,`writes`,`writeBytes`,`realTimeMessages`,`realTimeBytes`,`cpuTimeHours`,`storageBytes`];function ZC(e,t,n){return{label:n??JC[e],used:t.used,limit:t.limit,unlimited:t.unlimited,limitKnown:t.limitKnown,format:YC[e]}}function QC({label:e,used:t,limit:n,unlimited:r,limitKnown:i,format:a}){let o=r||n!=null&&n<0,s=i&&!o&&n!=null&&n>0,c=s?Math.min(100,Math.round(t/n*100)):0,l=c>=90;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-foreground`,children:e}),(0,K.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[(0,K.jsx)(`span`,{className:`text-foreground`,children:a(t)}),s?(0,K.jsxs)(K.Fragment,{children:[`/ `,a(n)]}):` used`]})]}),(0,K.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`h-2 flex-1 overflow-hidden rounded-full bg-muted`,children:s?(0,K.jsx)(`div`,{className:`h-full rounded-full ${l?`bg-yellow`:`bg-primary dark:bg-violet-400`}`,style:{width:`${c}%`}}):o?(0,K.jsx)(`div`,{className:`h-full w-full bg-[repeating-linear-gradient(-45deg,transparent,transparent_5px,var(--color-border)_5px,var(--color-border)_9px)] dark:bg-[repeating-linear-gradient(-45deg,transparent,transparent_5px,rgba(255,255,255,0.32)_5px,rgba(255,255,255,0.32)_9px)]`}):null}),(0,K.jsx)(`span`,{className:`w-16 shrink-0 text-right text-xs tabular-nums ${l?`text-amber-800 dark:text-yellow`:`text-muted-foreground`}`,children:s?`${c}%`:o?`Unlimited`:`—`})]})]})}function $C(e){return B({queryKey:[`clusterUsage`,e],queryFn:async()=>{let{data:t}=await P.get(`/Cluster/${e}/usage`);return t},enabled:!!e,staleTime:6e4})}function ew(e){return L($C(e))}function tw(e){let{regions:t}=e,n=t.every(e=>e.planName===t[0]?.planName)?t[0]?.planName:null,r=t.length>1?`next renewal`:`renews`;return[n?`${n} plan`:null,e.renewsAt?`${r} ${nw(e.renewsAt)}`:null].filter(Boolean).join(` · `)}function nw(e){return new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))}function rw({clusterId:e,base:t}){let{data:n}=ew(e);return!n||n.selfManaged||n.regions.length===0?null:(0,K.jsxs)(`section`,{className:`mt-6 rounded-2xl border border-border bg-card p-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Plan usage`}),(0,K.jsxs)(V,{to:`${t}/usage`,className:`inline-flex items-center gap-1 text-xs text-primary hover:underline dark:text-violet-300`,children:[`View all usage `,(0,K.jsx)(Wr,{className:`size-3`})]})]}),(0,K.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:tw(n)}),(0,K.jsx)(`div`,{className:`mt-4`,children:n.regions.length===1?(0,K.jsx)(iw,{data:n}):(0,K.jsx)(aw,{data:n})})]})}function iw({data:e}){let t=e.regions[0].metrics,n=[ZC(`reads`,t.reads),ZC(`writes`,t.writes),ZC(`storageBytes`,t.storageBytes),ZC(`cpuTimeHours`,t.cpuTimeHours)];return(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-x-8 gap-y-4 sm:grid-cols-2`,children:n.map(e=>(0,K.jsx)(QC,{...e},e.label))})}function aw({data:e}){let t=e.mostConstrained;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`p`,{className:`mb-1.5 text-xs text-muted-foreground`,children:[`Most constrained of `,e.regions.length,` regions`]}),t?(0,K.jsx)(QC,{...ZC(t.metric,{used:t.used,limit:t.limit,unlimited:!1,limitKnown:!0},`${t.region??`Region`} · ${JC[t.metric]}`)}):(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No metered limits on the current plan — see the breakdown for details.`})]})}function ow({cluster:e}){let t=Ee(),n=Ze(),{update:r,remove:i}=mg(e.organizationId,e.id),a=_g(e.organizationId),{run:o,isPending:s}=Hg(e),{mutate:c,isPending:l}=Rg(),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(null),v=e.status===`RUNNING`,y=e.status===`STOPPED`,b=e.status===`PARTIAL`,x=!a||s,S=(0,G.useCallback)(()=>{c(e.id,{onSuccess:async()=>{await n.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),h(!1),U.success(`Success`,{description:`Cluster successfully terminated.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),t.navigate({to:`/${e.organizationId}`})},onError:()=>{h(!1)}})},[e.id,e.organizationId,c,n,t]),C=(0,G.useCallback)(()=>{let e=g;_(null),e&&o(e,{safeMode:!0,strategy:`parallel`,label:e===`start`?`Starting in safe mode`:`Restarting in safe mode`})},[g,o]);return ff(e)||!r&&!i&&!a?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsxs)(H,{variant:`outline`,size:`sm`,disabled:s,className:`gap-1.5 hover:translate-y-0 data-[state=open]:[&>svg]:rotate-180`,children:[`Cluster actions`,(0,K.jsx)(er,{className:`size-4 transition-transform`})]})}),(0,K.jsxs)(vc,{align:`end`,className:`w-56`,children:[(0,K.jsxs)(Cc,{className:`text-gray-600 text-xs`,children:[`Container`,!a&&(0,K.jsx)(`span`,{className:`block font-normal`,children:`Requires an organization admin`})]}),(0,K.jsxs)(sw,{reason:a?void 0:`Only an organization administrator can start, stop, or restart this cluster.`,children:[(0,K.jsxs)(yc,{disabled:x||!(y||b),onClick:()=>void o(`start`,{safeMode:!1,strategy:`parallel`}),children:[(0,K.jsx)(Vo,{}),` Start`]}),(0,K.jsxs)(yc,{disabled:x||!y,onClick:()=>_(`start`),children:[(0,K.jsx)(Xa,{}),` Start in safe mode`]}),(0,K.jsxs)(yc,{disabled:x||!(v||b),onClick:()=>p(!0),children:[(0,K.jsx)(Zo,{}),` Restart`]}),(0,K.jsxs)(yc,{disabled:x||!v,onClick:()=>_(`restart`),children:[(0,K.jsx)(Xa,{}),` Restart in safe mode`]}),(0,K.jsxs)(yc,{variant:`destructive`,disabled:x||!(v||b),onClick:()=>d(!0),children:[(0,K.jsx)(Ss,{}),` Stop`]})]}),(0,K.jsx)(wc,{}),(0,K.jsxs)(yc,{variant:`destructive`,disabled:!i,onClick:()=>h(!0),children:[(0,K.jsx)(Is,{}),` Terminate`]})]})]}),(0,K.jsx)(Ng,{clusterName:e.name,isPending:s,stopOpen:u,setStopOpen:d,onConfirmStop:()=>{d(!1),o(`stop`,{strategy:`parallel`})},restartOpen:f,setRestartOpen:p,onConfirmRestart:e=>{p(!1),o(`restart`,{safeMode:!1,strategy:e})}}),(0,K.jsx)(Ig,{open:g!==null,setOpen:e=>{e||_(null)},action:g??`restart`,targetName:e.name,scope:`cluster`,isPending:s,onConfirm:C}),(0,K.jsx)(km,{typeOfThingBeingDeleted:`cluster`,transitiveVerb:`Terminate`,presentParticiple:`Terminating`,nameOfThingBeingDeleted:e.name,isModalOpen:m,setIsModalOpen:h,deletionConfirmed:S,deletionPending:l})]})}function sw({reason:e,children:t}){return e?(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(`div`,{role:`none`,children:t})}),(0,K.jsx)(Xl,{side:`left`,className:`max-w-60`,children:e})]}):(0,K.jsx)(K.Fragment,{children:t})}function cw(){let{clusterId:e}=z({strict:!1}),t=Ee(),r=De(),{data:i}=L(_f(e,!0)),{user:a,isLoading:o}=Tr(e),{view:s,update:l}=mg(i?.organizationId,i?.id),[f,p]=(0,G.useState)(!1),m=i?.domains?.[0]?.domain||i?.fqdn||``,[h,g]=Gg(m,m?`https://${m}`:``),_=i?`/${i.organizationId}/${i.id}`:``,v=(0,G.useCallback)(async()=>{if(i){p(!0);try{await u.establishFabricConnectAuth({id:i.id,operationsUrl:c(i)}),await t.invalidate()}catch{U.error(`Could not connect to this cluster through Fabric Connect.`)}finally{p(!1)}}},[i,t]),y=(0,G.useCallback)(()=>{i&&(u.setUserForEntity(i,null),u.flagForFabricConnect(i.id,!1)),r({to:`${_}/sign-in`})},[_,i,r]),b=(0,G.useCallback)(async()=>{if(i){try{await d({instanceClient:n({id:i.id}),entityId:i.id})}catch{}u.setUserForEntity(i,null),u.flagForFabricConnect(i.id,!1),u.flagForBasicAuth(i.id,null),await t.invalidate()}},[i,t]);if(!i)return(0,K.jsx)(uw,{children:(0,K.jsx)(dw,{})});if(!s)return(0,K.jsx)(qe,{to:`/${i.organizationId}`,replace:!0});if(Fd(i))return(0,K.jsx)(uw,{children:(0,K.jsx)(mf,{cluster:i})});if(ff(i))return(0,K.jsx)(lw,{cluster:i});if(!i.fqdn)return(0,K.jsx)(qe,{to:`${_}/instances`,replace:!0});if(i.resetPassword){if(!l)return(0,K.jsx)(uw,{children:(0,K.jsx)(HC,{})});let e=i.status&&Nd.includes(i.status)&&lf(i);return(0,K.jsx)(qe,{to:`${_}/${e?`finish-setup`:`starting-up`}`,replace:!0})}let x=u.checkForFabricConnect(i.id),S=!!a,C=u.getLastConnectMode(i.id),w=(i.instances??[]).filter(e=>e.status&&!Pd.includes(e.status)).length,T=i.instances??[],E=!!i.status&&Nd.includes(i.status)&&T.length>0&&T.every(e=>e.safeMode);return(0,K.jsxs)(uw,{children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-4 mb-6`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center size-12 rounded-xl bg-violet-50 text-primary dark:bg-grey-700 dark:text-violet-300 shrink-0`,children:(0,K.jsx)(ss,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:i.name}),(0,K.jsx)(fw,{status:i.status}),E&&(0,K.jsx)(pw,{})]}),(0,K.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,K.jsxs)(`span`,{children:[w,` `,w===1?`instance`:`instances`]}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsxs)(`a`,{href:`https://${m}`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 hover:text-foreground hover:underline`,children:[m,(0,K.jsx)(fa,{className:`size-3`})]}),(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{"aria-label":`Copy cluster URLs`,className:`rounded-md p-1 -m-1 hover:bg-accent/60 hover:text-foreground`,children:(0,K.jsx)(ea,{className:`size-3.5`})}),(0,K.jsxs)(vc,{align:`start`,children:[(0,K.jsx)(yc,{onClick:h,children:`Copy host name`}),(0,K.jsx)(yc,{onClick:g,children:`Copy API URL`})]})]})]})]}),(0,K.jsx)(ow,{cluster:i})]}),o?(0,K.jsx)(dw,{}):S?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-sm`,children:[(0,K.jsx)(Oi,{className:`size-4 text-green shrink-0`}),(0,K.jsx)(`span`,{className:`font-medium text-green`,children:x?`Connected via Fabric Connect`:`Signed in directly`}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,x?`through your Harper account`:`session cookie`]})]}),(0,K.jsxs)(V,{to:`${_}/apps`,className:`group flex items-center gap-4 rounded-2xl border-2 border-primary/30 bg-primary/5 p-6 transition-all hover:border-primary hover:bg-primary/10 dark:border-violet-400/30 dark:bg-violet-400/5 dark:hover:border-violet-400 dark:hover:bg-violet-400/10`,children:[(0,K.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-primary/10 text-primary shrink-0 dark:bg-violet-400/15 dark:text-violet-300`,children:(0,K.jsx)(qo,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-lg font-medium text-foreground`,children:`Enter cluster`}),(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Open the studio — apps, databases, APIs, logs, and config.`})]}),(0,K.jsx)(Wr,{className:`size-5 text-muted-foreground transition-transform group-hover:translate-x-1`})]}),(0,K.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-4 text-sm`,children:[x&&(0,K.jsx)(`button`,{type:`button`,onClick:y,className:`text-muted-foreground hover:text-foreground transition-colors`,children:`Switch to direct sign-in`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>void b(),className:`text-muted-foreground hover:text-destructive transition-colors`,children:x?`Disconnect`:`Direct sign out`})]})]}):(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-sm font-medium text-foreground mb-3`,children:`Connect to this cluster`}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3.5`,children:[l&&!ff(i)&&(0,K.jsx)(mw,{icon:Js,title:`Fabric Connect`,description:`Connect through your Harper account. No cluster credentials needed.`,pill:C===`fabric`?`last`:C?void 0:`recommended`,children:(0,K.jsx)(H,{className:`w-full`,disabled:f,onClick:()=>void v(),children:f?(0,K.jsx)(no,{className:`animate-spin`}):`Fabric Connect`})}),(0,K.jsx)(mw,{icon:Ha,title:`Direct sign-in`,description:`Sign in with this cluster's Harper username and password.`,pill:C===`direct`?`last`:void 0,children:(0,K.jsx)(H,{className:`w-full`,variant:`outline`,onClick:y,children:`Direct sign-in`})})]})]}),(0,K.jsx)(rw,{clusterId:i.id,base:_})]})}function lw({cluster:e}){let t=Ee(),r=De(),i=`/${e.organizationId}/${e.id}`,a=(0,G.useMemo)(()=>(e.instances??[]).filter(e=>e.status&&!Pd.includes(e.status)).sort(E_),[e.instances]),o=a.at(0),{user:s,isLoading:c}=Tr(o?.id),l=!!o&&!!s,f=(0,G.useCallback)(()=>{o&&r({to:`${i}/instance/${o.id}/sign-in`})},[i,o,r]),m=(0,G.useCallback)(async()=>{if(o){try{await d({instanceClient:n({id:o.id,operationsUrl:p(o)}),entityId:o.id})}catch{}u.setUserForEntity(o,null),u.flagForBasicAuth(o.id,null),await t.invalidate()}},[o,t]);return(0,K.jsxs)(uw,{children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-4 mb-6`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center size-12 rounded-xl bg-violet-50 text-primary dark:bg-grey-700 dark:text-violet-300 shrink-0`,children:(0,K.jsx)(ss,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:e.name}),(0,K.jsx)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full text-muted-foreground bg-muted`,children:`Self-Hosted`})]}),(0,K.jsx)(`div`,{className:`mt-1 text-sm text-muted-foreground`,children:(0,K.jsxs)(V,{to:`${i}/instances`,className:`hover:text-foreground hover:underline`,children:[a.length,` `,a.length===1?`instance`:`instances`]})})]})]}),o?c?(0,K.jsx)(dw,{}):l?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-sm`,children:[(0,K.jsx)(Oi,{className:`size-4 text-green shrink-0`}),(0,K.jsx)(`span`,{className:`font-medium text-green`,children:`Signed in directly`}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,o.name||o.instanceFqdn]})]}),(0,K.jsxs)(V,{to:`${i}/instance/${o.id}/`,className:`group flex items-center gap-4 rounded-2xl border-2 border-primary/30 bg-primary/5 p-6 transition-all hover:border-primary hover:bg-primary/10 dark:border-violet-400/30 dark:bg-violet-400/5 dark:hover:border-violet-400 dark:hover:bg-violet-400/10`,children:[(0,K.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-primary/10 text-primary shrink-0 dark:bg-violet-400/15 dark:text-violet-300`,children:(0,K.jsx)(qo,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-lg font-medium text-foreground`,children:`Enter cluster`}),(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Open the studio — apps, databases, APIs, logs, and config.`})]}),(0,K.jsx)(Wr,{className:`size-5 text-muted-foreground transition-transform group-hover:translate-x-1`})]}),(0,K.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-4 text-sm`,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>void m(),className:`text-muted-foreground hover:text-destructive transition-colors`,children:`Direct sign out`})})]}):(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-sm font-medium text-foreground mb-3`,children:`Connect to this cluster`}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3.5`,children:(0,K.jsx)(mw,{icon:Ha,title:`Direct sign-in`,description:`Sign in with this instance's Harper username and password.`,children:(0,K.jsx)(H,{className:`w-full`,variant:`outline`,onClick:f,children:`Direct sign-in`})})})]}):(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`This cluster has no instances yet. Register one from the`,` `,(0,K.jsx)(V,{to:`${i}/instances`,className:`underline hover:text-foreground`,children:`Instances`}),` page.`]})]})}function uw({children:e}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsx)(h_,{children:(0,K.jsx)(`div`,{className:`max-w-3xl`,children:e})})]})}function dw(){return(0,K.jsx)(`div`,{className:`flex justify-center py-10 text-muted-foreground`,children:(0,K.jsx)(no,{className:`size-6 animate-spin`})})}function fw({status:e}){let t=e&&Nd.includes(e)?`text-green bg-green/10`:e===`STOPPED`?`text-destructive bg-destructive/10`:e===`PARTIAL`?`text-amber-800 dark:text-yellow bg-yellow/10`:`text-muted-foreground bg-muted`;return(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full ${t}`,children:[(0,K.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e?e.charAt(0)+e.slice(1).toLowerCase():`Unknown`]})}function pw(){return(0,K.jsxs)(`span`,{title:`All instances running in safe mode — user apps/components are not loaded`,className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full text-amber-800 dark:text-yellow bg-yellow/10`,children:[(0,K.jsx)(Xa,{className:`size-3`}),`Safe mode`]})}function mw({icon:e,title:t,description:n,pill:r,children:i}){return(0,K.jsxs)(`div`,{className:`relative rounded-xl p-4.5 bg-card border ${r===`last`?`border-2 border-green`:r===`recommended`?`border-2 border-primary dark:border-violet-400`:`border-border`}`,children:[r&&(0,K.jsx)(`span`,{className:`absolute -top-2.5 left-4 rounded-full bg-card`,children:(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full ${r===`last`?`text-green bg-green/15`:`text-primary bg-violet-50 dark:text-violet-300 dark:bg-grey-700`}`,children:[r===`last`&&(0,K.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),r===`last`?`Last used`:`Recommended`]})}),(0,K.jsx)(e,{className:`size-6 text-primary dark:text-violet-300 mb-2`}),(0,K.jsx)(`div`,{className:`text-[15px] font-medium text-foreground mb-1`,children:t}),(0,K.jsx)(`p`,{className:`text-[13px] text-muted-foreground leading-normal mb-4`,children:n}),i]})}function hw({children:e,className:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsx)(h_,{children:(0,K.jsx)(`div`,{className:t,children:e})})]})}function gw(e){let t=jr(e);return t===void 0||t===408||t>=500}var _w=`Not attempted.`;function vw(e){return[...new Set(e.split(/[,\s]+/).map(e=>e.trim().toLowerCase()).filter(Boolean))]}function yw(e){let t=jr(e);return gw(e)||t===401||t===429}async function bw(e,t){let n=[],r=[];for(let i=0;i<e.length;i+=1){let a=e[i];try{await t(a),n.push(a)}catch(t){if(r.push({domain:a,message:fc(t).message,error:t,attempted:!0}),yw(t)){for(let t of e.slice(i+1))r.push({domain:t,message:_w,error:void 0,attempted:!1});break}}}return xw(r),{added:n,failures:r}}function xw(e){let t=new Set;for(let{error:n,attempted:r}of e){if(!r||jr(n)===409)continue;let e=jr(n);t.has(e)||(t.add(e),console.error(n))}}var Sw=4e3;async function Cw(e,t=Sw){let n;try{return await Promise.race([e,new Promise(e=>{n=setTimeout(()=>e(void 0),t)})])}finally{clearTimeout(n)}}function ww(e){let t=new Map;for(let n of e??[]){let e=String(n?.domain??``).toLowerCase();t.set(e,(t.get(e)??0)+1)}return t}function Tw(e,t){return e.filter(({domain:e,error:n,attempted:r})=>!r||!gw(n)||!t.has(e))}function Ew(e,t){if(!e)return new Set;let n=new Set;for(let[r,i]of t)i>(e.get(r)??0)&&n.add(r);return n}function Dw(e){return e.map(({domain:e,message:t})=>`${e} — ${t}`).join(`; `)}function Ow(e,t){return e.status===`ACTIVE`&&!e.clusterId&&!ff(t)}function kw(e,t,n){return e.filter(e=>t?.some(t=>t.id===e&&Ow(t,n)))}var Aw=new Set([`com`,`co`,`org`,`net`,`edu`,`gov`,`mil`,`me`,`biz`,`info`,`ac`,`or`,`ne`,`go`,`lg`,`asn`,`id`,`nom`,`sch`,`ltd`,`plc`]);function jw(e){let t=e.split(`.`);if(t.length<=2)return`@`;let n=t[t.length-1],r=t[t.length-2],i=n.length===2&&Aw.has(r)?3:2;return t.length<=i?`@`:t.slice(0,-i).join(`.`)}function Mw({cluster:{fqdn:e},domain:{domain:t,id:n}}){let r=jw(t),[i,a,o]=Gg(r,e||``,n);return(0,K.jsxs)(`div`,{className:`grid gap-4 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap`,children:`This domain has been verified! Now to associate it with this cluster, add the following to your DNS registrar:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordName`,value:r,onClick:i}),(0,K.jsx)(H,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:i,children:(0,K.jsx)(ea,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordTarget`,value:e,onClick:a}),(0,K.jsx)(H,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:a,children:(0,K.jsx)(ea,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`domainId`,value:n,onClick:o}),(0,K.jsx)(H,{type:`button`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:o,children:(0,K.jsx)(ea,{className:`w-3 h-3`})})]})}),(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap italic text-sm`,children:`Select this domain using the checkbox to the left, then click "Bind" in the top right to finish associating it with this cluster.`})]})}function Nw({certificate:e,domain:t,cluster:n}){let r=jw(t.domain),[i,a,o]=Gg(r,n.fqdn||``,t.id),s=(0,G.useMemo)(()=>e.issueDate&&!e.inProgress?{width:`100%`,color:`bg-green/80`,pulse:!1,text:`Certificate Issued`}:e.inProgress?{width:`100%`,color:`bg-yellow/80`,pulse:!0,text:`Generating Certificate...`}:{width:`100%`,color:`bg-gray-600`,pulse:!1,text:`Pending Certificate Generation...`},[e]);return(0,K.jsxs)(`div`,{className:`w-full max-w-2xl border border-border/50 rounded-md p-4 bg-gray-900/20`,children:[(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsx)(`div`,{className:`w-full h-1.5 rounded-full overflow-clip flex shadow-sm bg-gray-800`,children:(0,K.jsx)(`div`,{style:{width:s.width},className:`grow transition-[width] duration-1000 ease-in-out motion-reduce:transition-none ${s.color} ${s.pulse?`animate-pulse`:``}`})}),(0,K.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-light mt-1 italic`,children:s.text})]}),(0,K.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] text-sm`,children:[(0,K.jsx)(`div`,{className:`col-span-1 text-xs text-muted-foreground`,children:`CNAME:`}),(0,K.jsxs)(`div`,{className:`col-span-1 flex gap-2 items-center flex-wrap`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,K.jsx)(`span`,{className:`truncate max-w-[150px]`,title:r,children:r}),(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:i,title:`Copy Name`,children:(0,K.jsx)(ea,{className:`w-3 h-3`})})]}),(0,K.jsx)(Pw,{}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,K.jsx)(`span`,{className:`truncate max-w-[200px]`,title:n.fqdn||``,children:n.fqdn}),(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:a,title:`Copy Target`,children:(0,K.jsx)(ea,{className:`w-3 h-3`})})]})]}),(0,K.jsx)(`div`,{className:`col-span-1 text-[10px] text-muted-foreground`,children:`Domain ID:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-[10px] text-muted-foreground italic`,children:[(0,K.jsx)(`span`,{className:`truncate max-w-[200px]`,children:t.id}),(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,className:`h-3 w-3 p-0`,onClick:o,title:`Copy ID`,children:(0,K.jsx)(ea,{className:`w-2.5 h-2.5`})})]})})]})]})}function Pw(){return(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`w-3 h-3 text-muted-foreground`,children:[(0,K.jsx)(`path`,{d:`M5 12h14`}),(0,K.jsx)(`path`,{d:`m12 5 7 7-7 7`})]})}function Fw(e){let{enabled:t,entityId:n,databaseName:r,tableName:i,searchAttribute:a,sort:o,pageIndex:s,pageSize:c,onlyIfCached:l,getAttributes:u}=e;return B({enabled:t,queryKey:[n,r,i,`search_by_value`,a,o.attribute||`default`,o.descending||!1,s||0,c||0,l,u??null],retry:!1,staleTime:6e4,gcTime:5e3,queryFn:()=>Iw(e)})}async function Iw({instanceClient:e,databaseName:t,tableName:n,searchAttribute:r,sort:i,pageIndex:a,pageSize:o,onlyIfCached:s,getAttributes:c,responseType:l}){let u=i.attribute.length&&!(i.attribute===r&&!i.descending),d=await e.post(`/`,{operation:`search_by_value`,get_attributes:c??[`*`],database:t,table:n,search_attribute:r,search_value:`*`,sort:u?i:void 0,offset:a*o,limit:o,onlyIfCached:s,noCacheStore:s},{timeout:0,responseType:l,validateStatus:e=>e>=200&&e<400||e===404});return d.status===404?{data:[]}:d}var Lw=5e3,Rw=6e4,zw=18e4,Bw=new Map;function Vw(e){return!e.issueDate||e.inProgress}function Hw(e){return[e,`ChallengeCertificate`]}function Uw(e,t){return Bw.set(t,Date.now()+zw),e.invalidateQueries({queryKey:Hw(t)})}function Ww(e,t){return e&&(Bw.get(e)??0)>Date.now()||t?.some(Vw)?Lw:Rw}function Gw(e){return B({queryKey:Hw(e),queryFn:async()=>{if(!e)return[];let{data:t}=await Iw({searchAttribute:`domain`,entityId:e,databaseName:`data`,tableName:`ChallengeCertificate`,sort:{attribute:`domain`,descending:!0},instanceClient:n({id:e,forceFabricConnect:!0}),onlyIfCached:!1,pageIndex:0,pageSize:100});return t},enabled:!!e,refetchInterval:t=>Gc(Ww(e,t.state.data))(t),retry:Kc()})}function Kw(e){return L(Gw(e))}function qw({domain:{challengeToken:e,challengeTxtRecord:t,domain:n,id:r},cluster:{fqdn:i}}){let a=jw(n),[o,s,c,l,u]=Gg(t,e,a,i||``,r);return(0,K.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap`,children:`Prove that you own this domain by adding the following to your DNS registrar:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TXT`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`challengeName`,value:t,onClick:o}),(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:o,children:(0,K.jsx)(ea,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Content:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`challengeToken`,value:e,onClick:s}),(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:s,children:(0,K.jsx)(ea,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap mt-4`,children:`While you're at it, you should also add the CNAME record to point to this cluster:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordName`,value:a,onClick:c}),(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:c,children:(0,K.jsx)(ea,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordTarget`,value:i,onClick:l}),(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:l,children:(0,K.jsx)(ea,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`domainId`,value:r,onClick:u}),(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:u,children:(0,K.jsx)(ea,{className:`w-3 h-3`})})]})}),(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap mt-2`,children:`Then after your DNS TTL elapses, click the "Validate" button above.`})]})}var Jw=new Set([`PROVISIONING`,`PENDING_UPGRADE`,`DRAINING`,`UPDATING`,`UPDATED`,`CLONE_PENDING`,`CLONE_READY`,`CLONING`,`UPDATING_HDB_NODES`,`GENERATE_TOKEN`,`TOKEN_GENERATED`,`STOPPING`,`STOPPED`,`STARTING`,`RESTARTING`]);function Yw(e){if(e.status!==`RUNNING`)return{message:`This cluster is ${e.status??`not running`}. Its domains can change once it is running again.`,needsSupport:!1};for(let t of e.instances??[]){let e=t.instanceFqdn||t.id;if(t.status===`FAILED`)return{message:`Instance ${e} has failed, and this cluster's domains can't change until it is recovered.`,needsSupport:!0};if(t.status&&Jw.has(t.status))return{message:`Instance ${e} is ${t.status}. This cluster's domains can change once every instance is running.`,needsSupport:!1}}}function Xw(e,t){if(!t)return`isn't one of this organization's domains`;if(t.status!==`ACTIVE`)return`is not verified`;if(t.clusterId&&t.clusterId!==e)return`is bound to cluster ${t.clusterId}`}function Zw(e,{add:t,remove:n},r){if(ff(e))return{message:`Custom domains can't be bound to a self-managed cluster.`,needsSupport:!1};let i=new Map(r.map(e=>[e.id,e])),a=e.domainIds??[];for(let t of a){let n=Xw(e.id,i.get(t));if(n)return{message:`This cluster still lists ${i.get(t)?.domain??t}, which ${n}. Its domains can't change until that is cleared.`,needsSupport:!0}}for(let n of t){let t=a.includes(n)?void 0:Xw(e.id,i.get(n));if(t)return{message:`${i.get(n)?.domain??n} ${t}, so it can't be bound. The list has been refreshed.`,needsSupport:!1}}if(n&&!a.includes(n)){let t=i.get(n);return t?.clusterId===e.id?{message:`${t.domain} is bound to this cluster without the cluster listing it, so it can't be unbound here.`,needsSupport:!0}:{message:`${t?.domain??n} is no longer bound to this cluster. The list has been refreshed.`,needsSupport:!1}}}async function Qw(e){let{data:t}=await P.get(`/Domain/?organizationId=${e}`);return t}function $w(e){return B({queryKey:[e,`domains`],queryFn:()=>Qw(e)})}function eT(e){return[...new Set(e)]}var tT=class extends Error{needsSupport;constructor({message:e,needsSupport:t}){super(e),this.name=`DomainChangeRefusedError`,this.needsSupport=t}};async function nT(e,t,n){await P.put(`/Cluster/${e}`,{domainIds:t,generateDomainCerts:n},{timeout:0})}var rT=[`setDomainIdsOnCluster`];function iT(){let e=Ze(),t=I({mutationKey:rT,mutationFn:async({clusterId:t,organizationId:n,add:r=[],remove:i,generateDomainCerts:a})=>{let[o,s]=await Promise.all([hf(t),Qw(n)]);e.setQueryData(_f(t).queryKey,o),e.setQueryData($w(n).queryKey,s);let c=Yw(o)??Zw(o,{add:r,remove:i},s);if(c)throw new tT(c);await nT(t,eT((o.domainIds??[]).concat(r)).filter(e=>e!==i),a)},meta:{skipGlobalErrorToast:!0},onError:e=>{e instanceof tT||console.error(e)},onSuccess:(t,{clusterId:n})=>{e.invalidateQueries({queryKey:_f(n).queryKey,exact:!0}),Uw(e,n)}}),{mutate:n}=t,r=(0,G.useCallback)((t,r)=>{aT(e)||n(t,r)},[n,e]);return{...t,mutate:r}}function aT(e){return e.isMutating({mutationKey:rT})>0}function oT(){return Me({mutationKey:rT})>0}b({domainId:x(),organizationId:x()});async function sT(e){let{data:t}=await P.delete(`/Domain/${e.domainId}`);return t}var cT=[`deleteDomain`];function lT(){let e=Ze();return I({mutationKey:cT,mutationFn:e=>sT(e),onSuccess:(t,{domainId:n,organizationId:r})=>{e.setQueryData($w(r).queryKey,e=>e?.filter(e=>e.id!==n))}})}function uT(e){return e.isMutating({mutationKey:cT})>0}function dT(){return Me({mutationKey:cT})>0}var fT=Bb();function pT(e,t,n,r){let{data:i}=Kw(e.id),a=(0,G.useMemo)(()=>!!i?.some(Vw),[i]),o=oT(),{mutate:s,isPending:c}=lT(),l=o||c,u=Ze(),d=(0,G.useCallback)(t=>{aT(u)||s({domainId:t,organizationId:e.organizationId},{onSuccess:()=>{u.invalidateQueries({queryKey:[e.organizationId,`domains`],refetchType:`active`}),U.success(`Domain removed!`)}})},[u,s,e.organizationId]);return(0,G.useMemo)(()=>[fT.display({id:`select`,header:`Bind`,size:50,cell:r=>{let i=r.row.original;return Ow(i,e)?(0,K.jsx)(`label`,{className:`p-10 -m-10`,children:(0,K.jsx)(`input`,{type:`checkbox`,checked:t.includes(i.id),onChange:()=>n(i.id),disabled:l||a})}):null}}),fT.display({header:`Domains`,id:`domain`,enableSorting:!1,size:150,cell:e=>{let t=e.row.original,n=(0,K.jsx)(H,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l||!!t.clusterId,onClick:()=>d(t.id),children:`Remove Domain`});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{children:t.domain}),(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:t.clusterId?(0,K.jsx)(`div`,{className:`w-fit`,tabIndex:0,children:n}):n}),(0,K.jsx)(Xl,{side:`bottom`,align:`center`,children:t.clusterId?`To delete this domain, please unbind it from all clusters first.`:`Remember to clean up your DNS records!`})]})]})}}),fT.display({header:`Next Steps`,enableSorting:!1,size:500,id:`nextSteps`,cell:t=>{let n=t.row.original,a=i?.find(e=>e.domain===n.domain);return n.status===`ACTIVE`&&n.clusterId?e.id===n.clusterId?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{children:`Bound to this cluster`}),a&&Vw(a)&&(0,K.jsx)(`div`,{className:`py-2`,children:(0,K.jsx)(Nw,{certificate:a,domain:n,cluster:e})}),(0,K.jsx)(H,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l,onClick:()=>r(n.id),children:`Unbind Domain`})]}):`Bound to cluster ${n.clusterId}`:n.status===`PENDING_VALIDATION`?(0,K.jsx)(qw,{domain:n,cluster:e}):ff(e)?`Cannot be associated with this self-managed cluster.`:n.status===`ACTIVE`&&!n.clusterId?(0,K.jsx)(Mw,{cluster:e,domain:n}):n.status}})],[e,d,r,l,i,a,t,n])}var mT=`Enter a domain name.`,hT=b({domain:x().trim().min(1,mT),organizationId:x()});async function gT(e){let{data:t}=await P.post(`/Domain/`,e);return t}function _T(){return I({mutationFn:e=>gT(e),meta:{skipGlobalErrorToast:!0},networkMode:`always`})}async function vT(e){let{data:t}=await P.post(`/Domain/${e}/validate`);return t}function yT(e){return e instanceof tT?{message:e.message,needsSupport:e.needsSupport}:{message:`The domain change didn't go through: ${fc(e).message}`,needsSupport:!1}}function bT(){let{organizationId:e,clusterId:t}=z({strict:!1}),{data:n}=we(_f(t,!0)),{update:r}=fg(e),{data:i,refetch:a,isFetching:o,isPending:s,isRefetching:c}=L($w(e)),l=(0,G.useMemo)(()=>i?.filter(e=>e.status===`PENDING_VALIDATION`)||[],[i]),[u]=(0,G.useState)({attribute:`domain`,descending:!1}),d=(0,G.useMemo)(()=>[{desc:u.descending,id:u.attribute}],[u]),f=Kb(a),[p,m]=(0,G.useState)([]),h=(0,G.useCallback)(e=>{m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),g=(0,G.useMemo)(()=>kw(p,i,n),[n,i,p]),_=iT(),{mutate:v}=_,y=oT(),b=dT(),x=Ze(),S=(0,G.useCallback)(()=>{if(uT(x))return;let t=kw(p,x.getQueryData($w(e).queryKey),n);t.length!==0&&v({clusterId:n.id,organizationId:e,add:t,generateDomainCerts:!0},{onSuccess:()=>{x.invalidateQueries({queryKey:[n.organizationId],refetchType:`active`}),U.success(`Domain(s) bound! Certificates are being generated in the background now.`),m([])}})},[x,n,e,p,v]),C=(0,G.useCallback)(t=>{v({clusterId:n.id,organizationId:e,remove:t},{onSuccess:()=>{x.invalidateQueries({queryKey:[n.organizationId],refetchType:`active`}),U.success(`Domain unbound!`)}})},[x,n.id,n.organizationId,e,v]),w=_.error&&_.variables?.clusterId===n.id?yT(_.error):void 0,{mutateAsync:T}=_T(),E=on({resolver:mt(hT),defaultValues:{domain:``,organizationId:e}}),D=s||E.formState.isSubmitting,O=(0,G.useCallback)(async e=>{if(e.domain.length>5144){E.setError(`domain`,{type:`server`,message:`That is too much text to be domain names. Paste at most 20.`});return}let t=vw(e.domain);if(t.length===0){E.setError(`domain`,{type:`server`,message:mT});return}if(t.length>20){E.setError(`domain`,{type:`server`,message:`That is ${t.length} domains. Add at most 20 at a time.`});return}let n=i&&ww(i),{added:r,failures:o}=await bw(t,t=>T({...e,domain:t})),s=ke.isOnline()&&(r.length>0||o.some(({error:e,attempted:t})=>t&&gw(e)))?await Cw(a()):void 0,c=Tw(o,s?Ew(n,ww(s.data)):new Set),l=r.length+o.length-c.length;if(l>0&&U.success(`${oe(l,`Domain`,`Domains`)} added! Please add the txt record above to your domain registrar.`),c.length===0){E.reset();return}E.setValue(`domain`,c.map(({domain:e})=>e).join(`, `)),E.setError(`domain`,{type:`server`,message:Dw(c)})},[T,E,i,a]),k=(0,G.useCallback)(async()=>{let e=`Validating ${oe(l.length,`domain`,`domains`)}...`,t=`validatingDomains`,n=0,r=0,i=0;for(let a of l)try{U.loading(e,{description:`${n++} of ${l.length} checked`,id:t}),await vT(a.id)}catch(e){or(e)?i+=1:r+=1}i>0?(await a(),U.error(cr,{description:[ir(i),r>0&&`${oe(r,`other domain`,`other domains`)} failed to validate.`].filter(Boolean).join(` `),id:t})):r>0?U.error(`Validation failed!`,{description:`Please make sure the TXT record has been put in place. You may need to wait a bit for the DNS change to propagate.`,id:t}):(await a(),U.success(`Validation succeeded!`,{description:`Please take a look at the next steps for newly verified domains.`,id:t}))},[l]),A=pT(n,p,h,C),j=E.watch(`domain`),M=(0,G.useMemo)(()=>typeof j==`string`&&j.trim().split(`.`).length===2,[j]),ee=(0,G.useCallback)(()=>{typeof j==`string`&&E.setValue(`domain`,`${j.trim()}, www.${j.trim()}`)},[j,E]);return(0,K.jsx)(Hb,{data:i||[],isFetching:o||c,columns:A,sortingState:d,children:(0,K.jsxs)(`div`,{className:`w-full flex flex-col gap-2`,children:[(0,K.jsxs)(`div`,{className:`w-full flex flex-col md:flex-row items-center md:justify-between md:space-x-2 space-y-2 md:space-y-0`,children:[r&&(0,K.jsx)(Od,{...E,children:(0,K.jsxs)(`form`,{id:`cluster-add-domain-form`,name:`cluster-add-domain-form`,onSubmit:E.handleSubmit(O),className:`flex gap-1 flex-col md:flex-row`,children:[(0,K.jsx)(Y,{control:E.control,name:`domain`,render:({field:e})=>(0,K.jsxs)(X,{className:`flex-1`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`New Domain Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,enterKeyHint:`done`,autoComplete:`off`,disabled:D,...e})}),M&&(0,K.jsxs)(`div`,{className:`mt-1 flex gap-4`,children:[`Adding an apex domain?`,(0,K.jsx)(H,{variant:`positiveOutline`,type:`button`,disabled:D,onClick:ee,children:`Add www as well`})]}),(0,K.jsx)(Q,{children:(0,K.jsx)(`span`,{className:`text-muted-foreground italic`,children:`Type in a domain like example.com or your.example.com, and you'll be guided through validating and binding your cluster to it.`})})]})}),(0,K.jsxs)(`div`,{className:`flex-0 self-start flex gap-1 md:pt-6.5`,children:[(0,K.jsxs)(H,{type:`submit`,variant:`submit`,disabled:D,children:[(0,K.jsx)(Uo,{}),` Add`]}),l.length>0&&(0,K.jsxs)(H,{variant:`positiveOutline`,onClick:k,accessKey:`r`,type:`button`,disabled:o||c,children:[(0,K.jsx)(eo,{}),` `,(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`V`}),`alidate`]})]}),(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:f,accessKey:`r`,type:`button`,disabled:o||c,children:[(0,K.jsx)(Go,{}),` `,(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]})]})]})}),g.length>0&&(0,K.jsx)(`div`,{className:`flex-0 self-start md:pt-6.5`,children:(0,K.jsxs)(H,{variant:`submit`,onClick:S,disabled:y||b,children:[(0,K.jsx)($o,{}),` Bind `,oe(g.length,`Domain`,`Domains`)]})})]}),(0,K.jsx)(Kf,{message:w?.message,suggestSupport:w?.needsSupport})]})})}function xT(){return(0,K.jsx)(hw,{className:`flex flex-col justify-start max-w-4xl`,children:(0,K.jsx)(bT,{})})}var ST=b({username:xf,role:x().nonempty({error:`Please select a role.`}),password:yf.min(8,{error:`Password must be at least 8 characters long.`}),confirmPassword:x()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});async function CT(e){await P.patch(`/ResetPasswordUpdater/${e}`)}async function wT(e){let{instanceClient:t,...n}=e,{data:r}=await t.post(`/`,{operation:`add_user`,...n});return r}function TT(){return I({mutationFn:wT})}async function ET({username:e,password:t,role:n,active:r,instanceClient:i}){let{data:a}=await i.post(`/`,{operation:`alter_user`,username:e,password:t,role:n,active:r});return a}function DT(){return I({mutationFn:ET})}async function OT({username:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_user`,username:e});return n}function kT(){return I({mutationFn:OT})}async function AT({clusterId:e,initialUsername:t,desiredUsername:n,newPassword:r,tempPassword:a,instanceClient:o}){if(!a)throw Error(`You may not have permission to set the password on this cluster.`);let s=o;try{let o=await Yd({username:t,password:a,instanceClient:s,entityId:e});return o.instanceClient&&(s=o.instanceClient),n===`HDB_ADMIN`?await ET({username:n,password:r,instanceClient:s}):(await wT({username:n,password:r,role:`super_user`,active:!0,instanceClient:s}),o=await Yd({username:n,password:r,instanceClient:s,entityId:e}),await OT({username:i,instanceClient:s})),await CT(e),o}catch(t){throw await d({entityId:e,instanceClient:s}),t}}function jT(){return I({mutationFn:AT})}function MT(){let{user:e}=Sr(),{clusterId:t}=z({strict:!1}),{data:n}=L(_f(t,!0)),r=De(),a=Ze(),o=(0,G.useMemo)(()=>c(n),[n]),s=Ql({operationsUrl:o}),{redirect:l}=Oe({strict:!1}),d=Ee(),f=on({resolver:mt(ST),defaultValues:{confirmPassword:``,password:``,role:`super_user`,username:e?.email??``}}),{setFocus:p,control:m,handleSubmit:h}=f;(0,G.useEffect)(()=>{p(`password`)},[p]);let g=n?.instances?.find(e=>e.tempPassword)?.tempPassword,_=lf(n),{mutate:v,isPending:y}=jT(),b=(0,G.useCallback)(async e=>{if(!o){U.error(`Cluster is not yet fully loaded, please wait a moment before trying to sign in.`);return}if(!_){U.error(`Some instances are still starting up. You can create your admin user once they are all running.`);return}v({instanceClient:s,clusterId:t,newPassword:e.password,tempPassword:g,initialUsername:i,desiredUsername:e.username},{onSuccess:async({user:e})=>{U.success(`Admin user created. You're now signed in to your cluster.`),u.setUserForEntity(n,e),await gf(a,t),d.invalidate(),await r({to:l?.startsWith(`/`)?l:`../`})}})},[n,t,s,_,r,o,a,l,d,v,g]);return n&&!n.resetPassword?(0,K.jsx)(qe,{to:`../sign-in`,replace:!0}):n&&!_?(0,K.jsx)(qe,{to:`../starting-up`,replace:!0}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`studio-subnav fixed top-20 w-full h-12 z-39 px-4 md:px-12 bg-violet-50 border-b border-violet-100 dark:bg-grey-700 dark:border-none flex items-center`,children:(0,K.jsx)(Dd,{})}),(0,K.jsx)(`div`,{className:`items-center justify-center flex mt-32 py-4 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsxs)(`div`,{className:`text-foreground w-xs`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light`,children:`Create Admin User`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:`You are ready to create your first user in your new cluster. These credentials belong to you alone, and you can create more users and roles once you create this first one.`}),(0,K.jsx)(Od,{...f,children:(0,K.jsxs)(`form`,{id:`cluster-create-admin-form`,name:`cluster-create-admin-form`,onSubmit:h(b),className:`my-4`,children:[(0,K.jsx)(Y,{control:m,name:`username`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Username`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{autoComplete:`username`,type:`text`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m,name:`password`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,autoComplete:`new-password`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m,name:`confirmPassword`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Confirm Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,autoComplete:`new-password`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(H,{disabled:y,type:`submit`,variant:`submit`,className:`w-full my-2`,children:`Create Admin User`})]})}),(0,K.jsxs)(`p`,{className:`text-muted-foreground flex gap-2 align-middle`,children:[(0,K.jsx)(Ir,{size:36,className:`flex-none`}),(0,K.jsx)(`span`,{children:`These credentials will be used to sign into your cluster directly, providing you a secure connection from your browser to your cluster.`})]})]})})]})}function NT({columns:e,data:t,renderRowWrapper:n}){let r=tt({features:Lb,data:t,columns:e});return(0,K.jsx)(`div`,{className:`bg-card dark:bg-black-dark rounded-md`,children:(0,K.jsxs)(bb,{children:[(0,K.jsx)(xb,{children:r.getHeaderGroups().map(e=>(0,K.jsx)(Cb,{className:`border-none`,children:e.headers.map(e=>(0,K.jsx)(wb,{className:`p-4`,style:{width:`${e.getSize()}%`},children:e.isPlaceholder?null:ot(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,K.jsx)(Sb,{className:`bg-background dark:bg-black`,children:r.getRowModel().rows?.length?r.getRowModel().rows.map(e=>{let t=(0,K.jsx)(Cb,{"data-state":e.getIsSelected()&&`selected`,className:`hover:bg-muted/10 data-[state=selected]:bg-muted`,children:e.getVisibleCells().map(e=>(0,K.jsx)(Eb,{className:`p-4`,style:{width:`${e.column.getSize()}%`},children:ot(e.column.columnDef.cell,e.getContext())},e.id))});return(0,K.jsx)(G.Fragment,{children:n?n(e.original,t):t},e.id)}):(0,K.jsx)(Cb,{children:(0,K.jsx)(Eb,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function PT({instance:e,className:t}){let n=Vm(e);return n?!n.waiting&&(n.lastProgressAt!==void 0||n.startedAt!==void 0)?(0,K.jsx)(FT,{progress:n,className:t}):(0,K.jsx)(IT,{waiting:n.waiting,description:Wm(n,Date.now()),className:t}):null}function FT({progress:e,className:t}){let n=Rl();return(0,K.jsx)(IT,{description:Wm(e,n),className:t})}function IT({description:e,waiting:t,className:n}){let r=t?Hi:Go;return(0,K.jsxs)(`div`,{className:F(`flex items-center gap-1.5 text-xs font-light text-muted-foreground`,n),children:[(0,K.jsx)(r,{"aria-hidden":`true`,className:F(`size-3.5 shrink-0`,t?`text-muted-foreground`:`text-yellow animate-[spin_2.5s_linear_infinite] motion-reduce:animate-none`)}),(0,K.jsx)(`span`,{children:e})]})}function LT({instances:e}){let t=(e??[]).filter(e=>tf(e.status)).sort(E_);return t.length?(0,K.jsx)(`ul`,{className:`flex flex-col gap-3`,"aria-label":`Instances syncing data`,children:t.map(e=>(0,K.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-sm`,children:e.name||e.instanceFqdn}),(0,K.jsx)(PT,{instance:e})]},e.id))}):null}function RT(){return(0,K.jsx)(`div`,{className:`flex-col items-center justify-center px-16 space-y-3 text-center pt-30`,children:(0,K.jsx)(`p`,{children:`No instances found.`})})}var zT={start:!1,restart:!1,stop:!1},BT={start:!1,restart:!0,stop:!0},VT={start:!0,restart:!1,stop:!1},HT={start:!0,restart:!0,stop:!0};function UT(e){switch(e){case`RUNNING`:return BT;case`STOPPED`:return VT;case`ERROR`:case`FAILED`:return HT;default:return zT}}async function WT({instance:e,instanceClient:t}){try{await d({instanceClient:t,entityId:e.id})}catch{}u.signOutLocally(e.id),e.clusterId&&u.signOutLocally(e.clusterId)}async function GT({instanceId:e,action:t,safeMode:n}){let r=n===void 0?{}:{safeMode:n},{data:i}=await P.post(`/HDBInstance/${e}/container/${t}`,r);return i}function KT(){return I({mutationFn:GT})}var qT={stop:`Stopping`,start:`Starting`,restart:`Restarting`};function JT(e){let{clusterId:t}=z({strict:!1}),{mutateAsync:n,isPending:r}=KT(),i=Ze();return{run:(0,G.useCallback)(async(r,a)=>{let o=a?.label??qT[r],s=e.name??e.id,c=U.loading(o,{description:`${o} ${s}. Status will update shortly.`,duration:3e4,action:{label:`Dismiss`,onClick:()=>U.dismiss()}});try{await n({instanceId:e.id,action:r,safeMode:a?.safeMode}),r!==`stop`&&de({instanceIds:[e.id],label:qT[r],allAtOnce:!0}),t&&i.invalidateQueries({queryKey:[t]}),i.invalidateQueries({queryKey:[e.id]}),U.dismiss(c),U.success(`Request accepted`,{description:`${s} is ${o.toLowerCase()}. The status will update automatically.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}catch{U.dismiss(c)}},[t,e.id,e.name,n,i]),isPending:r}}var YT=`4.6.0`;function XT(e){return!!e&&vr(YT,e)}function ZT(e){return!!e&&!XT(e)&&vr(e,YT)}function QT({entityId:e,instanceClient:t},n){return B({queryKey:[`get_status`,e],staleTime:9e3,refetchInterval:Gc(1e4),retry:Kc(),retryDelay:1e4,throwOnError:!1,enabled:n,queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`get_status`});return e}})}function $T(e,t){return e?.systemStatus?.find(e=>e.id===t)?.status}async function eE({instanceClient:e,id:t,status:n}){let{data:r}=await e.post(`/`,{operation:`set_status`,id:t,status:n});return r}function tE(){return I({mutationFn:eE,onSuccess:(e,t)=>hc.invalidateQueries({queryKey:[`get_status`,t.entityId]})})}var nE=[`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`];function rE(e,t,n){let{user:r}=Tr(e.id),{organizationId:i,clusterId:a}=z({strict:!1}),o=qg({organizationId:i,clusterId:a,instanceId:e.id}),s=qg({organizationId:i,clusterId:a,instanceId:e.id},`sign-in`),c=(0,G.useMemo)(()=>p(e),[e]),l=Ql({operationsUrl:c}),{update:d}=bg(),f=_g(),m=u.checkForFabricConnect(e.id),h=q({operationsUrl:c,instanceId:e.id,forceFabricConnect:!0}),g=XT(e.version),{data:_}=L(QT(h,n&&d&&!ef(e.status)&&g)),v=$T(_,`availability`)||`Unknown`,y=v===`Available`,b=v===`Unavailable`,{mutate:x,isPending:S}=tE(),{run:C,isPending:w}=JT(e),[T,E]=(0,G.useState)(null),D=e.instanceFqdn,O=eb({secure:e.operationsApiSecure?`true`:`false`,port:e.operationsApiPort,fqdn:e.instanceFqdn}),[k,A]=Gg(D??``,O),j=(0,G.useCallback)(async()=>{await WT({instance:e,instanceClient:l})},[e,l]),M=!!e.status&&nE.includes(e.status),ee=!!r&&!m,te=M,N=!!D,P=d&&M&&g&&(y||b),F=UT(e.status),ne=f&&!t&&(F.start||F.restart||F.stop),re=[te&&ee&&{key:`direct-connect`,to:o,icon:(0,K.jsx)(ss,{className:`text-green`}),label:`Direct Connect`},te&&ee&&{key:`direct-sign-out`,onClick:j,variant:`destructive`,icon:(0,K.jsx)(uo,{}),label:`Direct Sign Out`},te&&!ee&&d&&!t&&{key:`fabric-connect`,to:o,icon:(0,K.jsx)(ss,{className:`text-green`}),label:`Fabric Connect`},te&&!ee&&{key:`direct-sign-in`,to:s,icon:(0,K.jsx)(co,{}),label:`Direct Sign In`},te&&N&&{type:`separator`,key:`copy-sep`},N&&{key:`copy-fqdn`,onClick:k,icon:(0,K.jsx)(Bi,{}),label:`Copy Instance FQDN`},N&&{key:`copy-api`,onClick:A,icon:(0,K.jsx)(Bi,{}),label:`Copy API URL`},(te||N)&&P&&{type:`separator`,key:`rotation-sep`},P&&y&&{key:`out-of-rotation`,variant:`destructive`,disabled:S,onClick:()=>x({...h,id:`availability`,status:`Unavailable`}),icon:(0,K.jsx)(ps,{}),label:`Bring out of rotation`},P&&b&&{key:`into-rotation`,disabled:S,onClick:()=>x({...h,id:`availability`,status:`Available`}),icon:(0,K.jsx)(ds,{}),label:`Bring back into rotation`},(te||N||P)&&ne&&{type:`separator`,key:`container-sep`},ne&&{type:`label`,key:`container-label`,className:`text-gray-600 text-xs`,label:`Container`},ne&&F.start&&{key:`container-start`,disabled:w,onClick:()=>void C(`start`,{safeMode:!1}),icon:(0,K.jsx)(Vo,{}),label:`Start`},ne&&F.start&&{key:`container-start-safe`,disabled:w,onClick:()=>E(`start`),icon:(0,K.jsx)(Xa,{}),label:`Start in safe mode`},ne&&F.restart&&{key:`container-restart`,disabled:w,onClick:()=>void C(`restart`,{safeMode:!1}),icon:(0,K.jsx)(Zo,{}),label:`Restart`},ne&&F.restart&&{key:`container-restart-safe`,disabled:w,onClick:()=>E(`restart`),icon:(0,K.jsx)(Xa,{}),label:`Restart in safe mode`},ne&&F.stop&&{key:`container-stop`,variant:`destructive`,disabled:w,onClick:()=>void C(`stop`),icon:(0,K.jsx)(Ss,{}),label:`Stop`}].filter(fr),ie=(0,K.jsx)(Ig,{open:T!==null,setOpen:e=>{e||E(null)},action:T??`restart`,targetName:e.name??e.id,scope:`instance`,isPending:w,onConfirm:()=>{let e=T;E(null),e&&C(e,{safeMode:!0,label:e===`start`?`Starting in safe mode`:`Restarting in safe mode`})}});return re.length?{items:[{type:`label`,key:`label`,className:`text-gray-600 text-xs`,label:`Options`},{type:`separator`,key:`label-sep`},...re],dialog:ie}:{items:[],dialog:ie}}function iE({instance:e,isSelfManaged:t}){let[n,r]=(0,G.useState)(!1),{items:i,dialog:a}=rE(e,t,n);return i.length?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(gc,{open:n,onOpenChange:r,children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Instance options`,children:(0,K.jsx)(ua,{})})}),(0,K.jsx)(vc,{align:`end`,className:`min-w-48`,children:Rm(i,`dropdown`)})]}),a]}):null}function aE({isSelfManaged:e,instance:t}){let{user:n,isLoading:r}=Tr(t.id),{organizationId:i,clusterId:a}=z({strict:!1}),o=qg({organizationId:i,clusterId:a,instanceId:t.id}),s=qg({organizationId:i,clusterId:a,instanceId:t.id},`sign-in`),c=Ql({operationsUrl:(0,G.useMemo)(()=>p(t),[t])}),{update:l}=bg(),d=u.checkForFabricConnect(t.id),f=(0,G.useCallback)(async()=>{await WT({instance:t,instanceClient:c})},[t,c]);return $d(t.status)?(0,K.jsx)(`span`,{className:`text-muted-foreground text-sm`,children:`—`}):r||!t.status||![`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`].includes(t.status)?(0,K.jsx)(no,{className:`animate-spin`,color:`gray`}):!n||d?(0,K.jsxs)(`span`,{className:`flex gap-4`,children:[l&&!e&&(0,K.jsx)(V,{to:o,className:`text-sm`,"aria-label":`Connect to ${t.name} instance`,title:`Connect to ${t.name} instance`,children:(0,K.jsx)(H,{variant:`positiveOutline`,children:`Fabric Connect`})}),(0,K.jsx)(V,{to:s,className:`text-sm`,"aria-label":`Sign in to ${t.name} instance`,title:`Sign in to ${t.name} instance`,children:(0,K.jsx)(H,{variant:l?`defaultOutline`:`positiveOutline`,children:`Direct Sign In`})})]}):(0,K.jsxs)(`span`,{className:`flex gap-4`,children:[(0,K.jsx)(V,{to:o,className:`text-sm`,"aria-label":`Go to ${t.name} instance`,title:`Go to ${t.name} instance`,children:(0,K.jsx)(H,{variant:`positiveOutline`,children:`Direct Connect`})}),(0,K.jsx)(H,{variant:`destructiveOutline`,className:`text-sm`,"aria-label":`Sign out from ${t.name} instance`,title:`Sign out from ${t.name} instance`,onClick:f,children:`Direct Sign Out`})]})}function oE({instance:e,isSelfManaged:t,children:n}){let[r,i]=(0,G.useState)(!1),{items:a,dialog:o}=rE(e,t,r);return a.length?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Am,{onOpenChange:i,children:[(0,K.jsx)(jm,{asChild:!0,children:n}),(0,K.jsx)(Mm,{className:`min-w-48`,children:Rm(a,`context`)})]}),o]}):(0,K.jsx)(K.Fragment,{children:n})}function sE(e,t=`0px`){let[n,r]=(0,G.useState)(null);return n!==null&&n.element!==e&&r(null),(0,G.useEffect)(()=>{if(!e||typeof IntersectionObserver>`u`)return;let n=new IntersectionObserver(t=>{let n=t[t.length-1];n&&r({element:e,onScreen:n.isIntersecting})},{rootMargin:t});return n.observe(e),()=>n.disconnect()},[e,t]),typeof IntersectionObserver>`u`||n!==null&&n.element===e&&n.onScreen}function cE({instance:e,index:t}){let{update:n}=bg(),r=q({operationsUrl:(0,G.useMemo)(()=>p(e),[e]),instanceId:e.id,forceFabricConnect:!0}),{mutate:i,isPending:a}=tE(),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(null),u=sE(c,`200px`);(0,G.useEffect)(()=>{let e=setTimeout(()=>s(!0),t*500);return()=>clearTimeout(e)},[t]);let d=ef(e.status),f=XT(e.version),{data:m,isLoading:h,isFetching:g}=L(QT(r,o&&u&&n&&!d&&f)),_=$T(m,`availability`)||`Unknown`,v=_===`Available`,y=_===`Unavailable`;if(!n)return null;if(d||!f){let t=`Status unavailable`;return d&&$d(e.status)?t=`Not running`:!d&&ZT(e.version)&&(t=`Status needs Harper 4.6 or later`),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(`span`,{className:`inline-block size-4 rounded-full bg-muted-foreground/40`,"aria-label":t})}),(0,K.jsx)(Xl,{children:t})]})})}return(0,K.jsxs)(`div`,{ref:l,className:`flex items-center gap-2`,children:[(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(`div`,{className:`flex items-center`,children:h||!o||(g||!u)&&!m?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(no,{className:`animate-spin size-5 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Loading status`})]}):(0,K.jsx)(ol,{variant:v?`success`:y?`destructive`:`default`,className:`size-4 rounded-full p-0`,children:(0,K.jsx)(`span`,{className:`sr-only`,children:v?`Online`:`Offline`})})})}),(0,K.jsxs)(Xl,{children:[g&&m?`Refreshing... `:``,_]})]}),n&&(0,K.jsxs)(`div`,{className:`flex gap-1`,children:[v&&(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(H,{type:`button`,variant:`destructiveGhost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Unavailable`}),disabled:a,children:a?(0,K.jsx)(no,{className:`animate-spin size-4`}):(0,K.jsx)(ps,{className:`size-4`})})}),(0,K.jsx)(Xl,{children:`Bring out of rotation`})]}),y&&(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Available`}),disabled:a,children:a?(0,K.jsx)(no,{className:`animate-spin size-4`}):(0,K.jsx)(ds,{className:`size-4`})})}),(0,K.jsx)(Xl,{children:`Bring back into rotation`})]})]})]})}function lE(){let{clusterId:e}=z({strict:!1}),{data:t,isLoading:n}=L(_f(e,!0)),r=ff(t),i=(0,G.useMemo)(()=>[{id:`instanceActions`,size:1,minSize:1,cell:e=>(0,K.jsx)(`div`,{className:`flex justify-end gap-2 items-center`,children:(0,K.jsx)(aE,{isSelfManaged:r,instance:e.row.original})})},r&&{accessorKey:`instanceFqdn`,size:90,header:`URL`,cell:e=>eb({secure:e.row.original.operationsApiSecure?`true`:`false`,port:e.row.original.operationsApiPort,fqdn:e.row.original.instanceFqdn})},!r&&{accessorKey:`name`,size:90,header:`Name`},!r&&{accessorKey:`status`,header:`Status`,size:1,minSize:1,cell:e=>{let t=e.getValue();return(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(cE,{instance:e.row.original,index:e.row.index}),t?(0,K.jsx)(ol,{variant:Qd(t),children:_d(t)}):null,e.row.original.safeMode&&!$d(e.row.original.status)?(0,K.jsxs)(ol,{variant:`warning`,title:`Running in safe mode — user apps/components are not loaded`,children:[(0,K.jsx)(Xa,{}),`Safe mode`]}):null]}),(0,K.jsx)(PT,{instance:e.row.original,className:`w-64`})]})}},!r&&{accessorKey:`version`,size:1,minSize:1,header:`Version`},!r&&{accessorKey:`storageGb`,size:1,minSize:1,header:`Storage`,cell:e=>`${e.getValue()} GB`},!r&&{accessorKey:`usedStorageGb`,size:1,minSize:1,header:`Used Storage`,cell:e=>{let t=e.getValue();return t===void 0?`-`:`${t} GB`}},!r&&{accessorKey:`cpuCores`,size:1,minSize:1,header:`Cores/Threads`,cell:e=>(0,K.jsxs)(K.Fragment,{children:[e.row.original.cpuCores,` / `,e.row.original.threads]})},!r&&{accessorKey:`memoryMb`,size:1,minSize:1,header:`Memory`,cell:e=>`${e.getValue()/1024} GB`},{id:`instanceMenu`,size:1,minSize:1,cell:e=>(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsx)(iE,{isSelfManaged:r,instance:e.row.original})})}].filter(fr),[r]),a=f_(),o=(0,G.useMemo)(()=>t?.instances?t.instances.filter(e=>e.status&&!Pd.includes(e.status)).map(e=>se(e.id)?.reach===`down`&&!$d(e.status)?{...e,status:`RESTARTING`}:e).sort(E_):[],[t,a]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsx)(h_,{children:(0,K.jsx)(Er,{className:`p-0 min-h-96`,children:(0,K.jsx)(Ar,{className:`p-0 min-h-96`,children:n?(0,K.jsx)(my,{}):o.length?(0,K.jsx)(NT,{data:o,columns:i,renderRowWrapper:(e,t)=>(0,K.jsx)(oE,{instance:e,isSelfManaged:r,children:t})}):(0,K.jsx)(RT,{})})})})]})}function uE(){let{clusterId:e}=z({strict:!1}),{immediate:t}=Oe({strict:!1}),n=t===!0||t===`true`,{data:r,isLoading:i}=L(_f(e,2e3)),a=r?.status,o=(0,G.useMemo)(()=>a&&Nd.includes(a)&&df(r),[a,r]);return i||!r?(0,K.jsx)(hw,{className:`flex justify-center`,children:(0,K.jsx)(my,{})}):af(a)?(0,K.jsx)(hw,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4 items-center`,children:[(0,K.jsx)(Wi,{className:`w-24 h-24`}),(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`Your cluster's update didn't finish`}),(0,K.jsx)(Fg,{cluster:r,forceProgressBarVisible:!0}),(0,K.jsxs)(`p`,{children:[`Some of the changes may already be applied, so check the instances. The cluster can't take another update until it's healthy again, so get in touch and we'll help get it back into a state you can update.`,` `,(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[`We also get notified about these failures. `,(0,K.jsx)(Pf,{}),` if you want more help.`]})]}),(0,K.jsx)(V,{to:`/${r.organizationId}/${r.id}/instances`,children:(0,K.jsx)(H,{type:`button`,variant:`positiveOutline`,children:`View Instances`})})]})}):o?(0,K.jsx)(hw,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`All done!`}),(0,K.jsx)(Fg,{cluster:r,forceProgressBarVisible:!0}),(0,K.jsx)(`p`,{children:`Your cluster finished updating, and is ready for interaction.`}),(0,K.jsx)(`div`,{className:`text-center`,children:(0,K.jsx)(Ag,{cluster:r})})]})}):(0,K.jsx)(hw,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,K.jsx)(Fg,{cluster:r,forceProgressBarVisible:!0}),(0,K.jsx)(LT,{instances:r.instances}),(0,K.jsxs)(`p`,{children:[n?`Your cluster is applying the latest changes immediately, without waiting to take instances out of rotation.`:`Your cluster is updating with the latest changes. This includes waiting several minutes to let traffic drain safely.`,` `,(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[`We will let you know when we are ready for you to connect! In the meantime, join us on`,` `,(0,K.jsx)(`a`,{href:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,children:`Discord`}),`! Get real-time help from our engineers, see feature drops early, and connect with others building on Fabric.`]})]})]})})}function dE({children:e,className:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsx)(`div`,{className:v(`mt-32 px-4 py-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] flex justify-center`,t),children:e})]})}function fE(){let e=Ee(),{clusterId:t}=z({strict:!1}),{data:n,isLoading:r}=L(_f(t,2e3)),i=n?.status,a=(0,G.useMemo)(()=>i&&Nd.includes(i)&&lf(n),[i,n]),o=af(i),[,s]=Zc(_r.SavedClusterState,null),c=(0,G.useCallback)(()=>{s(n),e.navigate({to:`/${n.organizationId}/new-cluster`})},[n,e,s]);return r||!n?(0,K.jsx)(dE,{className:`flex justify-center`,children:(0,K.jsx)(my,{})}):o?(0,K.jsx)(dE,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4 items-center`,children:[(0,K.jsx)(Wi,{className:`w-24 h-24`}),(0,K.jsxs)(`span`,{children:[`Your cluster failed to successfully start. This is usually caused by temporary communication problems. Would you like to try again? We also get notified about these failures. `,(0,K.jsx)(Pf,{}),` if you want more help.`]}),(0,K.jsx)(H,{type:`button`,variant:`positiveOutline`,onClick:c,children:`Try Again`})]})}):Fd(n)?(0,K.jsx)(dE,{className:`flex justify-center`,children:(0,K.jsx)(mf,{cluster:n})}):a?(0,K.jsx)(dE,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`It's ready!`}),(0,K.jsx)(Fg,{cluster:n,forceProgressBarVisible:!0}),(0,K.jsxs)(`p`,{children:[`Let's set up your secure, browser-to-cluster connection now.`,` `,(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Did you know during this step, you connect straight to your cluster, providing a private secure connection? That's `,(0,K.jsx)(`em`,{children:`Direct Connect`}),`! Once you create your user, you will have the option to`,` `,(0,K.jsx)(`em`,{children:`Fabric Connect`}),` from your Fabric account without having to sign in again.`]})]}),(0,K.jsx)(`div`,{className:`text-center`,children:(0,K.jsx)(Ag,{cluster:n})})]})}):(0,K.jsx)(dE,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,K.jsx)(Fg,{cluster:n,forceProgressBarVisible:!0}),(0,K.jsx)(LT,{instances:n.instances}),(0,K.jsxs)(`p`,{children:[`Your cluster is spinning up with the latest changes, including your own DNS records and private connections. Please wait while we get everything going.`,` `,(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[`We will let you know when we are ready for you to connect! In the meantime, join us on`,` `,(0,K.jsx)(`a`,{href:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,children:`Discord`}),`! Get real-time help from our engineers, see feature drops early, and connect with others building on Fabric.`]})]})]})})}function pE(){let{clusterId:e}=z({strict:!1}),{data:t,isLoading:n}=ew(e);if(n)return(0,K.jsxs)(hw,{className:`max-w-4xl pb-20`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:`Usage`}),(0,K.jsx)(`div`,{className:`flex justify-center py-16 text-muted-foreground`,children:(0,K.jsx)(no,{className:`size-6 animate-spin`})})]});let r=t&&!t.selfManaged?yE(t.regions):null;return(0,K.jsxs)(hw,{className:`max-w-4xl pb-20`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:`Usage`}),t?t.selfManaged?(0,K.jsx)(SE,{children:`Usage isn't tracked for self-hosted clusters — they run under their own license.`}):t.regions.length===0?(0,K.jsx)(SE,{children:`No usage has been recorded for the current cycle yet.`}):(0,K.jsxs)(`div`,{className:`mt-5 space-y-3`,children:[t.regions.map(e=>(0,K.jsx)(mE,{region:e,showPlanInfo:r==null},e.region??e.regionIds.join())),r&&(0,K.jsx)(hE,{header:(0,K.jsx)(gE,{title:`Plan limits & resources`}),aside:r.planId??void 0,children:(0,K.jsx)(_E,{rateLimits:r.rateLimits,resourcesPerInstance:r.resourcesPerInstance})})]}):(0,K.jsx)(CE,{})]})}function mE({region:e,showPlanInfo:t}){let n=XC.map(t=>ZC(t,e.metrics[t])),r=[e.planName?`${e.planName} plan`:null,e.status===`exhausted`?`consumed — awaiting renewal`:e.status===`lapsed`?`not renewed`:e.expiresAt?`renews ${vE(e.expiresAt)}`:null].filter(Boolean).join(` · `);return(0,K.jsxs)(hE,{defaultOpen:e.status!==`lapsed`,aside:e.regionIds.length>0?e.regionIds.join(`, `):void 0,header:(0,K.jsxs)(gE,{title:e.region??`Region`,meta:r,children:[e.status===`exhausted`&&(0,K.jsx)(`span`,{className:`rounded-full bg-yellow/10 px-2 py-0.5 text-[11px] text-amber-800 dark:text-yellow`,children:`Cycle exhausted`}),e.status===`lapsed`&&(0,K.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground`,children:`No active license`})]}),children:[(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-x-10 gap-y-4 sm:grid-cols-2`,children:n.map(e=>(0,K.jsx)(QC,{...e},e.label))}),t&&(0,K.jsx)(_E,{rateLimits:e.rateLimits,resourcesPerInstance:e.resourcesPerInstance})]})}function hE({header:e,aside:t,defaultOpen:n=!0,children:r}){let[i,a]=(0,G.useState)(n);return(0,K.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-border`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),"aria-expanded":i,className:`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-accent/40`,children:[(0,K.jsx)(Si,{className:`size-4 shrink-0 text-muted-foreground transition-transform ${i?`rotate-90`:``}`}),(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:e}),t&&(0,K.jsx)(`span`,{className:`shrink-0 self-start pt-0.5 font-mono text-[11px] text-muted-foreground/70`,children:t})]}),i&&(0,K.jsx)(`div`,{className:`border-t border-border px-4 py-4`,children:r})]})}function gE({title:e,meta:t,children:n}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e}),n]}),t&&(0,K.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t})]})}function _E({rateLimits:e,resourcesPerInstance:t}){let n=e,r=n?xE([[`Reads / minute`,n.readsPerMinute,By],[`Read bandwidth / minute`,n.readsPerMinuteBytes,zy],[`Writes / minute`,n.writesPerMinute,By],[`Write bandwidth / minute`,n.writesPerMinuteBytes,zy],[`Real-time deliveries / minute`,n.realTimeDeliveriesPerMinute,By],[`Real-time bandwidth / minute`,n.realTimeDeliveryBytesPerMinute,zy],[`TLS handshakes (cycle)`,n.tlsHandshakes,By]]):[],i=t,a=i?bE([[`Storage`,i.storageGb,e=>`${By(e)} GB`],[`Memory`,i.memoryMb,e=>zy(e*1e3*1e3)],[`vCPU`,i.cpuCores,e=>`${e} ${e===1?`core`:`cores`}`],[`Threads`,i.threads,e=>String(e)]]):[];return(0,K.jsxs)(K.Fragment,{children:[r.length>0&&(0,K.jsx)(wE,{title:`Rate limits`,subtitle:`Throughput ceilings — not part of the cycle allotment, and not metered.`,children:(0,K.jsx)(TE,{rows:r})}),a.length>0&&(0,K.jsx)(wE,{title:`Per-instance resources`,subtitle:`Provisioned capacity on each instance.`,children:(0,K.jsx)(TE,{rows:a})})]})}function vE(e){return new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))}function yE(e){if(e.length===0)return null;let t=e[0];if(t.rateLimits==null&&t.resourcesPerInstance==null)return null;let n=e=>JSON.stringify([e.rateLimits,e.resourcesPerInstance]),r=n(t),i=e.every(e=>e.planId===t.planId);return e.every(e=>n(e)===r)?{rateLimits:t.rateLimits,resourcesPerInstance:t.resourcesPerInstance,planId:i?t.planId:null}:null}function bE(e){return e.filter(e=>typeof e[1]==`number`&&e[1]>0).map(([e,t,n])=>[e,n(t)])}function xE(e){return e.filter(e=>e[1]!=null).map(([e,t,n])=>[e,t.unlimited?`Unlimited`:t.limitKnown&&t.limit!=null?n(t.limit):`—`])}function SE({children:e}){return(0,K.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:e})}function CE(){return(0,K.jsx)(`div`,{role:`alert`,className:`mt-5 rounded-xl border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive`,children:`Couldn't load usage data — refresh to try again.`})}function wE({title:e,subtitle:t,children:n}){return(0,K.jsxs)(`div`,{className:`mt-6 first:mt-0`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:e}),(0,K.jsx)(`p`,{className:`mt-0.5 mb-3 text-xs text-muted-foreground`,children:t}),n]})}function TE({rows:e}){return(0,K.jsx)(`dl`,{className:`grid grid-cols-1 gap-x-10 gap-y-2 sm:grid-cols-2`,children:e.map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 border-b border-border/60 py-1.5 text-sm`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,K.jsx)(`dd`,{className:`text-foreground tabular-nums`,children:t})]},e))})}R({getParentRoute:()=>WC,path:`instances`,head:()=>({meta:[{title:`Instances — Harper Fabric`}]}),beforeLoad:sm,component:lE}),R({getParentRoute:()=>WC,path:`starting-up`,head:()=>({meta:[{title:`Starting Up — Harper Fabric`}]}),component:fE}),R({getParentRoute:()=>WC,path:`scaling`,head:()=>({meta:[{title:`Scaling — Harper Fabric`}]}),beforeLoad:sm,component:uE}),R({getParentRoute:()=>WC,path:`domains`,head:()=>({meta:[{title:`Domains — Harper Fabric`}]}),beforeLoad:sm,component:xT}),R({getParentRoute:()=>WC,path:`usage`,head:()=>({meta:[{title:`Usage — Harper Fabric`}]}),component:pE});function EE({context:e,location:t,params:n}){if(Fd(e?.cluster))return;let r=u.checkForFabricConnect(n.clusterId);if(u.getConnectionById(n.clusterId).user&&!r){let e=t?.search?.redirect;throw Ne({to:e?.startsWith(`/`)?e:`../`})}}function DE({context:e,location:t,params:n}){if(Fd(e?.cluster))return;let r=u.checkForFabricConnect(n.instanceId);if(u.getConnectionById(n.instanceId).user&&!r){let e=t?.search?.redirect;throw Ne({to:e?.startsWith(`/`)?e:`../`})}}R({getParentRoute:()=>WC,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:Of,beforeLoad:EE}),R({getParentRoute:()=>WC,path:`instance/$instanceId/sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:Of,beforeLoad:DE}),R({getParentRoute:()=>WC,path:`finish-setup`,head:()=>({meta:[{title:`Create Admin User — Harper Fabric`}]}),component:MT}),R({getParentRoute:()=>WC,path:`/`,head:()=>({meta:[{title:`Cluster — Harper Fabric`}]}),component:cw});function OE(e){return R({getParentRoute:()=>e,path:`apis`,head:()=>({meta:[{title:`APIs — Harper Fabric`}]})}).lazy(()=>pe(()=>import(`./index.lazy-DgbjUxLo.js`).then(e=>e.route),__vite__mapDeps([21,1,22,7,6,23,4,2,3,24,25,8,9,12,11,26,27,28,29])))}function kE(e,t){return[R({getParentRoute:()=>e,path:t===`cluster`?`apps`:`/`,head:()=>({meta:[{title:`Applications — Harper Fabric`}]}),component:je(()=>pe(()=>import(`./applications-XCds8-ZP.js`),__vite__mapDeps([30,1,22,7,6,23,4,2,3,24,25,8,9,12,11,31,32,15,33,34,26,16,17,28,35,18,19,20,36])),`ApplicationsEditor`)})]}async function AE({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_certificates`});return t}function jE(e){return B({queryKey:[e.entityId,`list_certificates`],queryFn:()=>AE(e)})}var ME=[{header:`Certificate Name`,accessorKey:`name`,enableSorting:!0},{header:`Issuer`,accessorKey:`details.issuer`,enableSorting:!0},Bb().display({header:`Expires At`,enableSorting:!1,id:`details.valid_to`,cell:e=>e.row.original.details.valid_to?new Date(e.row.original.details.valid_to).toLocaleString():`N/A`})];function NE({className:e,...t}){return(0,K.jsx)(`textarea`,{"data-slot":`input`,className:F(`border-input file:text-foreground placeholder:text-muted-foreground selection:bg-purple
19
+ `)}}];function Kb(e){return(0,G.useCallback)(async()=>{U.loading(`Refreshing...`,{id:`refreshing`});let t=Date.now();await e(),Date.now()-t<500&&await h(500),U.success(`Refreshed!`,{id:`refreshing`})},[e])}async function qb(e){let{data:t}=await P.get(`/Invoice/${e}`);return t}function Jb(e,t){return B({queryKey:[e,`invoices`],queryFn:()=>qb(e),retry:!1,enabled:!!e,refetchInterval:t?1e4:void 0})}function Yb(){let{organizationId:e}=z({strict:!1}),{data:t}=L(Yc(e)),{data:n,refetch:r,isLoading:i,isFetching:a,isRefetching:o}=L(Jb(t?.type!==`ENTERPRISE`&&t?.id,!1)),s=Kb(r);return t?.type===`ENTERPRISE`?(0,K.jsxs)(`span`,{children:[`You are part of an enterprise organization! We don’t currently show your invoices on this page. Want to explore your solution with Harper more? `,(0,K.jsx)(Pf,{}),`, we would love to talk!`]}):i?(0,K.jsx)(Lc,{centered:!0}):!n||!n.length?(0,K.jsxs)(`span`,{children:[`Your invoices will be shown here once one is available! Want to explore your solution with Harper more?`,` `,(0,K.jsx)(Pf,{overEmail:!0}),`, we would love to talk!`]}):(0,K.jsx)(Hb,{data:n,columns:Gb,children:(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:s,accessKey:`r`,disabled:a||o,children:[(0,K.jsx)(Go,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]})})}function Xb(e){let t=R({getParentRoute:()=>e,path:`billing`,head:()=>({meta:[{title:`Billing — Harper Fabric`}]}),component:gb}),n=R({getParentRoute:()=>t,path:`/`,head:()=>({meta:[{title:`Payment Methods — Harper Fabric`}]}),component:ay}),r=R({getParentRoute:()=>t,path:`invoices`,head:()=>({meta:[{title:`Invoices — Harper Fabric`}]}),component:Yb}),i=R({getParentRoute:()=>t,path:`confirm`,head:()=>({meta:[{title:`Confirm Payment — Harper Fabric`}]}),component:hb});return t.addChildren([n,r,i])}function Zb({error:e,reset:t}){switch(jr(e)){case 403:return(0,K.jsx)(oc,{error:e,title:`No Access to This Organization`,description:`This organization doesn't exist, or your account isn't a member of it. To join it, ask one of its administrators to invite you.`});case 404:return(0,K.jsx)(oc,{error:e,title:`Organization Not Found`,description:`No organization has this ID. Check that the link is complete and correct.`});default:return(0,K.jsx)(oc,{error:e,reset:t})}}async function Qb(e){let{data:t}=await P.get(`/OrganizationRole/${e}`);return t}function $b(e){return B({queryKey:[e,`roles`],queryFn:()=>Qb(e),retry:!1,refetchInterval:Gc(1e4)})}function ex(e){return e.userIds?.length??0}var tx=[{header:`Role Name`,accessorKey:`roleName`,enableSorting:!0},{header:`ID`,accessorKey:`id`,enableSorting:!0,enableGlobalFilter:!1,cell:e=>(0,K.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,title:e.row.original.id,children:e.row.original.id})},{header:`Users Assigned`,id:`userIds`,accessorFn:ex,enableSorting:!0,enableGlobalFilter:!1,cell:e=>ex(e.row.original)||`No users assigned`}],nx=new Set([`checkbox`,`radio`,`file`,`submit`,`button`,`image`,`reset`]);function rx(e){return t=>{let n=t.target;if(t.key!==`Enter`||t.nativeEvent.isComposing||!(n instanceof HTMLInputElement)||nx.has(n.type)||!n.name)return;let r=n.name,i=e.getValues(r);i!==void 0&&e.setValue(r,i,{shouldTouch:!0,shouldValidate:!0})}}async function ix(e){let{data:t}=await P.post(`/Role/`,e);return t}function ax(){return I({mutationFn:ix})}var ox=b({name:x().nonempty({error:`Please enter a role name.`}).regex(/^[a-zA-Z_]*$/,{error:`Role must contain only letters and underscores.`}).max(30,{error:`Role name cannot be longer than 30 characters.`}),update:A(),delete:A()}).pick({name:!0});b({roles:b({create:A(),delete:A(),update:A(),view:A()}),clusters:b({create:A(),delete:A(),update:A(),view:A(),resources:D(b({id:x(),delete:A(),update:A(),view:A(),instances:b({create:A(),delete:A(),update:A(),view:A()})}))})});function sx({className:e,...t}){return(0,K.jsx)(sn,{"data-slot":`tabs`,className:F(`flex flex-col gap-2`,e),...t})}function cx({className:e,...t}){return(0,K.jsx)(Kt,{"data-slot":`tabs-list`,className:F(`text-muted-foreground inline-flex w-fit items-center justify-center rounded-full bg-muted dark:bg-gray-950 p-1`,e),...t})}function lx({className:e,...t}){return(0,K.jsx)(yt,{"data-slot":`tabs-trigger`,className:F(`data-[state=active]:text-foreground data-[state=active]:bg-card dark:data-[state=active]:bg-gray-600 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring focus-visible:ring-[3px] focus-visible:outline-1 text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 border rounded-full border-transparent px-2 py-1 font-medium whitespace-nowrap transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...t})}function ux({className:e,...t}){return(0,K.jsx)(Yn,{"data-slot":`tabs-content`,className:F(`flex-1 outline-none`,e),...t})}var dx=b({create:A(),view:A(),update:A(),delete:A()}),fx=b({id:x().min(1),view:A(),update:A(),delete:A(),instances:dx}),px=N({update:A(),delete:A(),roles:N(dx.shape),clusters:N({...dx.shape,resources:D(N(fx.shape))})}),mx={create:!0,view:!0,update:!0,delete:!0},hx={update:!1,delete:!1,roles:mx,clusters:{...mx,resources:[]}},gx=e=>({create:e?.create===!0,view:e?.view===!0,update:e?.update===!0,delete:e?.delete===!0});function _x({organization:e}){return{update:e.update===!0,delete:e.delete===!0,roles:gx(e.roles),clusters:{...gx(e.clusters),resources:(e.clusters?.resources??[]).map(e=>({id:e.id,view:e.view===!0,update:e.update===!0,delete:e.delete===!0,instances:gx(e.instances)}))}}}function vx(e,t,n){return{name:e,organizationId:t,...n}}function yx(e){return JSON.stringify(e,null,2)}function bx(e){let t;try{t=JSON.parse(e)}catch{return{ok:!1,error:`This isn’t valid JSON.`}}let n=px.safeParse(t);if(!n.success){let e=n.error.issues[0];return{ok:!1,error:`${e.path.length?e.path.join(`.`):`the permissions`}: ${e.message}`}}return{ok:!0,permissions:n.data}}var xx=(e,t)=>({create:e,view:t.view,update:t.update,delete:t.delete});function Sx({clusters:e}){if(e.resources.length===0)return{scope:`all`};let[t]=e.resources,n=e.resources.every(n=>n.view===t.view&&n.update===t.update&&n.delete===t.delete&&n.instances.create===e.create&&n.instances.view===n.view&&n.instances.update===n.update&&n.instances.delete===n.delete),r=!e.view&&!e.update&&!e.delete;return n&&r?{scope:`selected`,clusterIds:e.resources.map(e=>e.id)}:{scope:`custom`}}function Cx(e,t){let{clusters:n}=e;if(t.scope===`selected`&&n.resources.length>0){let[e]=n.resources;return{create:n.create,view:e.view,update:e.update,delete:e.delete}}return{create:n.create,view:n.view,update:n.update,delete:n.delete}}function wx(e,t,n){if(n.scope===`all`)return{...e,clusters:{...t,resources:[]}};let r={view:t.view,update:t.update,delete:t.delete};return{...e,clusters:{create:t.create,view:!1,update:!1,delete:!1,resources:n.clusterIds.map(e=>({id:e,...r,instances:xx(t.create,r)}))}}}function Tx(){let[e]=tl(),t=Qc();return e===`dark`||e===`system`&&t===`dark`?`vs-dark`:`light`}var Ex=(0,G.lazy)(async()=>(await pe(()=>import(`./setup-Ca4RpPzm.js`),__vite__mapDeps([14,2,1,15,16,17,18,19,20])),{default:(await pe(()=>import(`./dist-9lpzt2Hn.js`).then(e=>e.t),__vite__mapDeps([15,1,2]))).default}));function Dx(e){return(0,K.jsx)(G.Suspense,{fallback:e.loading??null,children:(0,K.jsx)(Ex,{...e})})}var Ox=[`view`,`create`,`update`,`delete`],kx={view:`View`,create:`Create`,update:`Update`,delete:`Delete`};function Ax({checked:e,disabled:t,onChange:n,label:r,id:i,describedBy:a}){return(0,K.jsx)(`input`,{id:i,type:`checkbox`,"aria-label":r,"aria-describedby":a,className:`size-4 shrink-0 accent-primary dark:accent-violet-300 disabled:opacity-60`,checked:e,disabled:t,onChange:e=>n(e.target.checked)})}function jx({label:e,description:t,checked:n,disabled:r,onChange:i}){let a=(0,G.useId)();return(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(`div`,{className:`pt-0.5`,children:(0,K.jsx)(Ax,{id:a,describedBy:`${a}-description`,checked:n,disabled:r,onChange:i})}),(0,K.jsxs)(`div`,{className:`text-sm`,children:[(0,K.jsx)(`label`,{htmlFor:a,className:`text-foreground`,children:e}),(0,K.jsx)(`p`,{id:`${a}-description`,className:`text-xs text-muted-foreground`,children:t})]})]})}function Mx({value:e,onChange:t,clusters:n,disabled:r}){let[i,a]=(0,G.useState)(()=>Sx(e)),[o,s]=(0,G.useState)(()=>Cx(e,Sx(e))),c=i.scope===`custom`,l=r||c,u=i.scope===`selected`?i.clusterIds:[],d=n.filter(e=>!Pd.includes(e.status??``)||u.includes(e.id)),f=(n,r)=>{s(n),a(r),t(wx(e,n,r))};return(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(`section`,{"aria-labelledby":`role-organization-heading`,children:[(0,K.jsx)(`h3`,{id:`role-organization-heading`,className:`mb-3 font-medium text-foreground`,children:`Organization`}),(0,K.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,K.jsx)(jx,{label:`Update organization`,description:`Change the organization’s settings and billing.`,checked:e.update,disabled:r,onChange:n=>t({...e,update:n})}),(0,K.jsx)(jx,{label:`Delete organization`,description:`Permanently delete the organization.`,checked:e.delete,disabled:r,onChange:n=>t({...e,delete:n})})]})]}),(0,K.jsxs)(`section`,{"aria-labelledby":`role-resources-heading`,children:[(0,K.jsx)(`h3`,{id:`role-resources-heading`,className:`mb-3 font-medium text-foreground`,children:`Resource permissions`}),(0,K.jsxs)(bb,{containerClassName:`rounded-md border border-border dark:border-grey-700 bg-card dark:bg-black-dark`,children:[(0,K.jsx)(xb,{children:(0,K.jsxs)(Cb,{className:`border-none`,children:[(0,K.jsx)(wb,{className:`w-1/3 px-2`,children:`Resource`}),Ox.map(e=>(0,K.jsx)(wb,{className:`px-2 text-center`,children:kx[e]},e))]})}),(0,K.jsxs)(Sb,{className:`bg-background dark:bg-black`,children:[(0,K.jsxs)(Cb,{className:`border-border dark:border-grey-700`,children:[(0,K.jsx)(Eb,{className:`px-2 py-2.5 font-medium`,children:`Roles`}),Ox.map(n=>(0,K.jsx)(Eb,{className:`px-2 py-2.5 text-center`,children:(0,K.jsx)(Ax,{label:`Roles: ${kx[n]}`,checked:e.roles[n],disabled:r,onChange:r=>t({...e,roles:{...e.roles,[n]:r}})})},n))]}),(0,K.jsxs)(Cb,{className:`border-border dark:border-grey-700`,children:[(0,K.jsx)(Eb,{className:`px-2 py-2.5 font-medium`,children:`Clusters`}),Ox.map(e=>(0,K.jsx)(Eb,{className:`px-2 py-2.5 text-center`,children:(0,K.jsx)(Ax,{label:`Clusters: ${kx[e]}`,checked:o[e],disabled:l,onChange:t=>f({...o,[e]:t},i)})},e))]})]})]}),(0,K.jsxs)(`ul`,{className:`mt-2 space-y-1 text-xs text-muted-foreground`,children:[(0,K.jsx)(`li`,{children:`Role permissions also control membership: Create allows adding members and inviting people; Delete allows removing members.`}),(0,K.jsx)(`li`,{children:`Cluster Update also allows running operations.`})]})]}),(0,K.jsxs)(`section`,{"aria-labelledby":`role-cluster-access-heading`,className:`space-y-2`,children:[(0,K.jsx)(`h3`,{id:`role-cluster-access-heading`,className:`font-medium text-foreground`,children:`Cluster access`}),c?(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This role sets permissions cluster by cluster in a way this form can’t show. Edit them in Advanced JSON.`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`max-w-xs`,children:(0,K.jsxs)(hy,{value:i.scope,disabled:r,onValueChange:e=>f(o,e===`selected`?{scope:`selected`,clusterIds:[]}:{scope:`all`}),children:[(0,K.jsx)(vy,{className:`w-full`,"aria-labelledby":`role-cluster-access-heading`,children:(0,K.jsx)(_y,{})}),(0,K.jsxs)(yy,{children:[(0,K.jsx)(xy,{value:`all`,children:`All clusters`}),(0,K.jsx)(xy,{value:`selected`,children:`Selected clusters`})]})]})}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i.scope===`selected`?`View, Update and Delete apply only to the clusters chosen here. Create always applies to the whole organization.`:`The Clusters permissions apply to every cluster in the organization.`}),i.scope===`selected`&&(d.length===0?(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This organization has no clusters yet.`}):(0,K.jsx)(`ul`,{className:`grid gap-2 pt-1 sm:grid-cols-2`,children:d.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(Ax,{checked:u.includes(e.id),disabled:r,onChange:t=>f(o,{scope:`selected`,clusterIds:t?[...u,e.id]:u.filter(t=>t!==e.id)})}),e.name??e.id,Pd.includes(e.status??``)&&(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`(deleted)`})]})},e.id))}))]})]})]})}function Nx({value:e,onChange:t,clusters:n,disabled:r=!1,onValidChange:i}){let a=Tx(),[o,s]=(0,G.useState)(`form`),[c,l]=(0,G.useState)(()=>yx(e)),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(0),m=(0,G.useRef)(null),[h,g]=(0,G.useState)();return(0,K.jsxs)(sx,{value:o,onValueChange:t=>{t===`json`?(g(m.current?.offsetHeight),l(yx(e)),d(null),s(`json`)):u||(p(e=>e+1),s(`form`))},children:[(0,K.jsxs)(cx,{className:`p-0.5 text-sm dark:bg-gray-800`,children:[(0,K.jsx)(lx,{value:`form`,className:`px-3 py-0.5`,children:`Permissions`}),(0,K.jsx)(lx,{value:`json`,className:`px-3 py-0.5`,children:`Advanced JSON`})]}),(0,K.jsx)(ux,{value:`form`,ref:m,className:`pt-2`,children:(0,K.jsx)(Mx,{value:e,onChange:t,clusters:n,disabled:r},f)}),(0,K.jsxs)(ux,{value:`json`,style:{height:h},className:`flex min-h-80 flex-none flex-col pt-2`,children:[(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden rounded-lg border`,children:(0,K.jsx)(Dx,{className:`h-full w-full`,theme:a,defaultLanguage:`json`,value:c,onChange:e=>{let n=e??``;l(n);let r=bx(n);d(r.ok?null:r.error),i?.(r.ok),r.ok&&t(r.permissions)},options:{readOnly:r,automaticLayout:!0,minimap:{enabled:!1}}})}),u&&(0,K.jsxs)(`p`,{role:`alert`,className:`mt-2 text-sm text-red-500`,children:[u,` Fix it to save or to go back to Permissions.`]})]})]})}function Px({isModalOpen:e,setIsModalOpen:t}){let n=Ze(),{organizationId:r}=z({strict:!1}),{data:i}=L(Yc(r)),[a,o]=(0,G.useState)(hx),[s,c]=(0,G.useState)(!0),{mutate:l,isPending:u}=ax(),d=on({resolver:mt(ox),mode:`onTouched`,defaultValues:{name:``}}),f=()=>{t(!1),d.reset(),o(hx),c(!0)},p=({name:e})=>l(vx(e,r,a),{onSuccess:()=>{U.success(`Role "${e}" created.`),n.invalidateQueries({queryKey:[r,`roles`],refetchType:`active`}),f()},onError:e=>{pc(e)&&U.error(`Failed to create the role: ${e.message}`)}});return(0,K.jsx)(_m,{onOpenChange:e=>!e&&f(),open:e,children:(0,K.jsxs)(wm,{className:`max-h-[90vh] overflow-y-auto focus:outline-none sm:max-w-[760px]`,onOpenAutoFocus:e=>{e.preventDefault(),e.currentTarget.focus()},children:[(0,K.jsx)(Dm,{children:`Create role`}),(0,K.jsx)(Om,{children:`Choose what this role can access.`}),(0,K.jsx)(Od,{...d,children:(0,K.jsxs)(`form`,{id:`org-add-role-form`,name:`org-add-role-form`,className:`flex flex-col gap-4 my-2`,onSubmit:d.handleSubmit(p),onKeyDown:rx(d),children:[(0,K.jsx)(Y,{control:d.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Role name`}),(0,K.jsx)(cy,{type:`text`,placeholder:`e.g. deployment_operator`,maxLength:ox.shape.name.maxLength,...e}),(0,K.jsx)(ky,{children:`Letters and underscores, up to 30 characters.`}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Nx,{value:a,onChange:o,onValidChange:c,clusters:i?.clusters??[]}),(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(H,{variant:`outline`,type:`button`,onClick:f,disabled:u,children:`Cancel`}),(0,K.jsx)(H,{variant:`submit`,disabled:u||!s||!d.formState.isValid,children:u?`Creating…`:`Create role`})]})})]})})]})})}async function Fx({roleId:e}){let{data:t}=await P.delete(`/Role/${e}`,{id:e,deleted:!0});return t}function Ix(){return I({mutationFn:({roleId:e})=>Fx({roleId:e})})}async function Lx({roleId:e,updatedRoleInfo:t}){let{data:n}=await P.put(`/Role/${e}`,t);return n}function Rx(){return I({mutationFn:({roleId:e,updatedRoleInfo:t})=>Lx({roleId:e,updatedRoleInfo:t})})}function zx({organizationId:e,roleId:t}){return B({queryKey:[e,`roles`,t],queryFn:()=>Bx(t),refetchInterval:Gc(1e4),retry:Kc()})}async function Bx(e){let{data:t}=await P.get(`/Role/${e}`);return t}function Vx({onRoleDeleteClick:e,setIsConfirmingRoleDeletion:t,isRoleDeletionPending:n}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Dm,{children:`Confirm Role Deletion`}),(0,K.jsx)(Om,{children:`Are you sure you want to delete this role? This action cannot be undone.`}),(0,K.jsxs)(Em,{children:[(0,K.jsx)(H,{type:`button`,variant:`defaultOutline`,onClick:()=>t(!1),children:`Cancel`}),(0,K.jsx)(H,{variant:`destructiveOutline`,onClick:e,disabled:n,children:n?`Deleting...`:`Delete Role`})]})]})}function Hx({data:e,isModalOpen:t,closeModal:n}){let r=(0,G.useCallback)(()=>n(!1),[n]);return(0,K.jsx)(_m,{onOpenChange:r,open:t,children:(0,K.jsx)(wm,{className:`max-h-[90vh] overflow-y-auto sm:max-w-[760px]`,children:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(Ux,{roleName:e.roleName}),children:(0,K.jsx)(Wx,{data:e,closeModal:n})})})})}function Ux({roleName:e}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Dm,{children:[`Role "`,e,`"`]}),(0,K.jsx)(Lc,{centered:!0,text:`Loading role…`,className:`flex-1 min-h-0`})]})}function Wx({data:e,closeModal:t}){let n=Ze(),{data:r}=we(zx({roleId:e.id,organizationId:e.organizationId})),{data:i}=L(Yc(e.organizationId)),a=Sr().user?.roles?.[e.organizationId]?.id===e.id,o=e.roleName===`admin`,{update:s,remove:c}=fg(e.organizationId),l=s&&!a&&!o,u=c&&!a&&!o,{mutate:d,isPending:f}=Rx(),{mutate:p,isPending:m}=Ix(),[h,g]=(0,G.useState)(!1),[_]=(0,G.useState)(()=>_x(r)),[v,y]=(0,G.useState)(_),[b,x]=(0,G.useState)(!0),S=JSON.stringify(v)!==JSON.stringify(_),C=(0,G.useCallback)(()=>{p({roleId:e.id},{onSuccess:()=>{U.success(`Role deleted.`),t(!0)},onError:e=>{pc(e)&&U.error(`Failed to delete the role: ${e instanceof Error?e.message:String(e)}`)}})},[e.id,p,t]);return h?(0,K.jsx)(Vx,{onRoleDeleteClick:C,setIsConfirmingRoleDeletion:g,isRoleDeletionPending:m}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Dm,{children:[l?`Edit role`:`Role`,` "`,e.roleName,`"`]}),(0,K.jsx)(Om,{children:o?`The admin role is built in and can’t be edited.`:a?`This is your role. Another member who can update roles can change it.`:l?`Members and service accounts with this role get these permissions from their next request.`:`What members and service accounts with this role can do.`}),(0,K.jsx)(`div`,{className:`my-2`,children:(0,K.jsx)(Nx,{value:v,onChange:y,onValidChange:x,clusters:i?.clusters??[],disabled:!l})}),(l||u)&&(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[u?(0,K.jsx)(H,{type:`button`,variant:`destructiveOutline`,onClick:()=>{x(!0),g(!0)},disabled:f,children:`Delete role`}):(0,K.jsx)(`span`,{}),l&&(0,K.jsx)(H,{variant:`submit`,type:`button`,onClick:()=>d({roleId:e.id,updatedRoleInfo:vx(e.roleName,e.organizationId,v)},{onSuccess:async()=>{U.success(`Role updated. It applies to each member’s next request.`),await n.invalidateQueries({queryKey:[e.organizationId,`roles`,e.id]}),t(!1)},onError:e=>{pc(e)&&U.error(`Failed to update the role: ${e instanceof Error?e.message:String(e)}`)}}),disabled:f||!S||!b,children:f?`Saving…`:`Save changes`})]})})]})}function Gx(){let e=De(),t=Ze(),{organizationId:n,orgRoleId:r}=z({strict:!1}),{create:i}=fg(n),{data:a,refetch:o,isFetching:s,isRefetching:c}=we($b(n)),l=(0,G.useMemo)(()=>a&&a?.find(e=>e.id===r),[a,r]),u=!!r&&!!l,[d,f]=(0,G.useState)(!1),p=(0,G.useCallback)(async(i,a)=>{let o=[r?`..`:``,i].filter(Boolean);await e({to:o.join(`/`)}),a&&await t.invalidateQueries({queryKey:[n,`roles`],refetchType:`active`})},[r,e,t]),m=(0,G.useCallback)(()=>{f(!0)},[f]),h=(0,G.useCallback)(e=>p(e.original.id,!1),[p]),g=(0,G.useCallback)(e=>p(void 0,e),[p]),_=Kb(o);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsxs)(ub,{children:[(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsx)(`h2`,{className:`text-2xl text-foreground font-light`,children:`Roles`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Manage access to this organization and its clusters.`})]}),(0,K.jsxs)(G.Suspense,{fallback:(0,K.jsx)(Lc,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,K.jsxs)(Hb,{data:a,columns:tx,onRowClick:h,filter:{label:`Filter roles`,placeholder:`Filter by role name`},paginated:!0,children:[(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:_,accessKey:`r`,disabled:s||c,children:[(0,K.jsx)(Go,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),i&&(0,K.jsxs)(H,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:d,children:[(0,K.jsx)(Uo,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]}),i&&(0,K.jsx)(Px,{isModalOpen:d,setIsModalOpen:f}),u&&(0,K.jsx)(Hx,{data:l,isModalOpen:u,closeModal:g},l.id)]})]})]})}function Kx({className:e,...t}){return(0,K.jsx)(Gn,{"data-slot":`switch`,className:F(`peer data-[state=checked]:bg-green data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-grey-500 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,K.jsx)(Zn,{"data-slot":`switch-thumb`,className:F(`bg-white dark:data-[state=unchecked]:bg-white dark:data-[state=checked]:bg-white pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0`)})})}async function qx({tokenId:e}){let{data:t}=await P.delete(`/ApiToken/${encodeURIComponent(e)}`);return t}function Jx(e){let t=Ze();return I({mutationFn:qx,onSuccess:(n,{tokenId:r})=>{t.setQueriesData({queryKey:[e,`apiTokens`]},e=>e?.filter(e=>e.id!==r)),t.invalidateQueries({queryKey:[e,`apiTokens`],refetchType:`active`}),t.invalidateQueries({queryKey:[e,`serviceAccounts`],refetchType:`active`})}})}function Yx({token:e}){let[t,n]=(0,G.useState)(!1),{mutate:r,isPending:i}=Jx(e.organizationId),a=(0,G.useRef)(!1);return(0,K.jsx)(km,{typeOfThingBeingDeleted:`API token`,nameOfThingBeingDeleted:e.name,isModalOpen:t,setIsModalOpen:n,deletionConfirmed:()=>{a.current||(a.current=!0,r({tokenId:e.id},{onSuccess:()=>{U.success(`API token "${e.name}" revoked.`),n(!1)},onSettled:()=>{a.current=!1}}))},deletionPending:i,hideDataLossWarning:!0,transitiveVerb:`Revoke`,presentParticiple:`Revoking`,trigger:(0,K.jsxs)(H,{variant:`destructiveGhost`,size:`sm`,className:`text-destructive/75 hover:text-destructive focus-visible:text-destructive`,"aria-label":`Revoke ${e.name}`,children:[(0,K.jsx)(ei,{}),` Revoke`]})})}var Xx=6e4,Zx=60*Xx,Qx=24*Zx;function $x(e){return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function eS(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`long`})}function tS(e,t=Date.now()){let n=new Date(e).getTime()-t,r=Math.abs(n),[i,a]=r<Zx?[n/Xx,`minute`]:r<Qx?[n/Zx,`hour`]:[n/Qx,`day`],o=new Intl.RelativeTimeFormat(void 0,{numeric:`auto`}).format(Math.round(i),a);return o.charAt(0).toUpperCase()+o.slice(1)}function nS({value:e,format:t,className:n}){return(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(`time`,{dateTime:e,tabIndex:0,className:F(`rounded-sm focus-visible:outline-2 focus-visible:outline-ring`,n),children:t===`date`?$x(e):tS(e)})}),(0,K.jsx)(Xl,{children:eS(e)})]})}async function rS(e){let{data:t}=await P.post(`/ApiToken/`,e);return t}function iS(){return I({mutationFn:rS,gcTime:0})}var aS=30,oS=90,sS=b({name:x().trim().nonempty({error:`Please enter a name.`}).max(100,{error:`Name cannot be longer than 100 characters.`}),expiresInDays:C({error:`Enter a whole number of days.`}).int({error:`Enter a whole number of days.`}).min(1,{error:`Must be at least 1 day.`}).max(oS,{error:`Must be at most ${oS} days.`})});function cS({organizationId:e,serviceAccountId:t,onClose:n}){let r=Ze(),i=Kg(),{mutateAsync:a,isPending:o,reset:s}=iS(),[c,l]=(0,G.useState)(null),u=(0,G.useRef)(!1),d=(0,G.useRef)(!1),f=(0,G.useRef)(!1),p=(0,G.useRef)(null);(0,G.useEffect)(()=>(u.current=!0,()=>{u.current=!1,p.current&&_(p.current)}),[]),(0,G.useEffect)(()=>{c&&(p.current=null,d.current=!1,s())},[c,s]);let m=on({resolver:mt(sS),mode:`onTouched`,defaultValues:{name:``,expiresInDays:aS}}),{isValid:h}=m.formState,g=()=>Promise.all([r.invalidateQueries({queryKey:[e,`apiTokens`],refetchType:`active`}),r.invalidateQueries({queryKey:[e,`serviceAccounts`],refetchType:`active`})]),_=async e=>{try{await qx({tokenId:e.id}),U.warning(`An API token created after its dialog closed was revoked.`)}catch(e){console.error(`Failed to revoke an API token that was never shown`,e),U.error(`An API token created after its dialog closed could not be revoked. Revoke it from its service account’s API Tokens.`)}g()},v=async e=>{if(d.current||f.current||!u.current)return;d.current=!0;let n;try{n=await a({serviceAccountId:t,...e})}catch{d.current=!1;return}if(f.current=!0,!u.current){_(n);return}p.current=n,l(n),g()},y=()=>{d.current||n()};return(0,K.jsx)(_m,{open:!0,onOpenChange:e=>{e||y()},children:(0,K.jsx)(wm,{className:`sm:max-w-[600px]`,children:c?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Dm,{children:`Copy your API token`}),(0,K.jsxs)(Om,{children:[`It won't be shown again. Expires `,new Date(c.expiresAt).toLocaleString(),`.`]}),(0,K.jsxs)(`div`,{className:`my-4 flex items-center gap-2`,children:[(0,K.jsx)($,{readOnly:!0,"aria-label":`API token`,value:c.token,className:`font-mono text-xs`,onClick:()=>i(c.token)}),(0,K.jsx)(H,{type:`button`,size:`icon`,variant:`ghost`,className:`shrink-0`,"aria-label":`Copy token`,onClick:()=>i(c.token),children:(0,K.jsx)(ea,{})})]}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Send it as a bearer token:`,` `,(0,K.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 text-xs`,children:`Authorization: Bearer <token>`}),`. It acts as this service account, with its role, on this organization's clusters and their instances.`]}),(0,K.jsx)(Em,{children:(0,K.jsx)(H,{type:`button`,variant:`submit`,onClick:n,children:`Done`})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Dm,{children:`Create API Token`}),(0,K.jsx)(Om,{children:`For CI pipelines and scripts. The token acts as this service account, with its role.`}),(0,K.jsx)(Od,{...m,children:(0,K.jsxs)(`form`,{id:`create-api-token-form`,name:`create-api-token-form`,className:`flex flex-col gap-4 my-4`,onSubmit:m.handleSubmit(v),onKeyDown:rx(m),children:[(0,K.jsx)(Y,{control:m.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,K.jsx)(cy,{type:`text`,placeholder:`e.g. github-actions-deploy`,maxLength:sS.shape.name.maxLength,...e}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`expiresInDays`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Expires in (days)`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`number`,min:1,max:oS,step:1,name:e.name,ref:e.ref,onBlur:e.onBlur,value:Number.isFinite(e.value)?e.value:``,onChange:t=>e.onChange(t.target.valueAsNumber)})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(H,{variant:`destructiveOutline`,type:`button`,onClick:y,disabled:o,children:`Cancel`}),(0,K.jsx)(H,{variant:`submit`,type:`submit`,disabled:o||!h,children:o?`Creating…`:`Create Token`})]})})]})})]})})})}function lS(e){return B({queryKey:[e,`serviceAccounts`],queryFn:async()=>{let{data:t}=await P.get(`/ServiceAccount/`,{params:{organizationId:e}});return t},retry:!1})}function uS(e,t){return B({queryKey:[e,`apiTokens`,t],queryFn:async()=>{let{data:n}=await P.get(`/ApiToken/`,{params:{organizationId:e,serviceAccountId:t}});return n},retry:!1})}var dS=6048e5;function fS({token:e,now:t}){let n=new Date(e.expiresAt).getTime()-t;return n<=0?(0,K.jsxs)(`span`,{className:`text-red-500`,children:[`Expired `,(0,K.jsx)(nS,{value:e.expiresAt,format:`relative`,className:`lowercase`})]}):(0,K.jsx)(nS,{value:e.expiresAt,format:`relative`,className:F(n<dS&&`text-amber-600`)})}function pS({token:e}){return e.createdByUserId?e.createdByEmail?(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(`span`,{tabIndex:0,className:`rounded-sm focus-visible:outline-2 focus-visible:outline-ring`,children:e.createdByEmail})}),(0,K.jsx)(Xl,{children:e.createdByUserId})]}):(0,K.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.createdByUserId}):(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}function mS({organizationId:e,account:t,regionId:n}){let[r,i]=(0,G.useState)(!1),{data:a,isLoading:o,isError:s}=L(uS(e,t.id)),c=t.status===`ACTIVE`,l=Date.now();return(0,K.jsxs)(`section`,{id:n,"aria-label":`API tokens of ${t.name}`,className:`mt-4 rounded-lg border border-primary/30 bg-primary/5 dark:border-white/15 dark:bg-white/5`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 border-b px-4 py-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`h4`,{className:`font-medium text-foreground truncate`,children:t.name}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`API tokens`})]}),(0,K.jsxs)(H,{variant:`positiveOutline`,size:`sm`,onClick:()=>i(!0),disabled:!c,children:[(0,K.jsx)(Uo,{}),`Create token`]})]}),!t.roleName&&(0,K.jsx)(`p`,{className:`px-4 pt-3 text-sm text-red-500`,children:`Its role was deleted; change it from the account’s menu, or its tokens are refused.`}),!c&&(0,K.jsx)(`p`,{className:`px-4 pt-3 text-sm text-muted-foreground`,children:`While the account is disabled its tokens are refused; enabling it restores those not revoked or expired.`}),(0,K.jsx)(`div`,{className:`px-4 pb-2`,children:o?(0,K.jsx)(Lc,{className:`py-6`}):s&&!a?(0,K.jsx)(`p`,{className:`py-4 text-sm text-red-500`,children:`Couldn’t load this account’s tokens.`}):a?.length?(0,K.jsxs)(bb,{children:[(0,K.jsx)(xb,{children:(0,K.jsxs)(Cb,{className:`border-border`,children:[(0,K.jsx)(wb,{children:`Name`}),(0,K.jsx)(wb,{children:`Created by`}),(0,K.jsx)(wb,{children:`Created`}),(0,K.jsx)(wb,{children:`Expires`}),(0,K.jsx)(wb,{children:`Last used`}),(0,K.jsx)(wb,{children:(0,K.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,K.jsx)(Sb,{children:a.map(e=>(0,K.jsxs)(Cb,{className:`border-border`,children:[(0,K.jsx)(Eb,{className:`py-2.5 font-medium`,children:e.name}),(0,K.jsx)(Eb,{className:`py-2.5`,children:(0,K.jsx)(pS,{token:e})}),(0,K.jsx)(Eb,{className:`py-2.5 whitespace-nowrap`,children:(0,K.jsx)(nS,{value:e.createdAt,format:`date`})}),(0,K.jsx)(Eb,{className:`py-2.5 whitespace-nowrap`,children:(0,K.jsx)(fS,{token:e,now:l})}),(0,K.jsx)(Eb,{className:`py-2.5 whitespace-nowrap`,children:e.lastUsedAt?(0,K.jsx)(nS,{value:e.lastUsedAt,format:`relative`}):(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`Not used yet`})}),(0,K.jsx)(Eb,{className:`py-2.5 text-right`,children:(0,K.jsx)(Yx,{token:e})})]},e.id))})]}):(0,K.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No tokens yet.`})}),r&&(0,K.jsx)(cS,{organizationId:e,serviceAccountId:t.id,onClose:()=>i(!1)})]})}function hS({name:e,id:t}){return(0,K.jsxs)(`span`,{className:`flex items-baseline gap-2 truncate`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:e}),(0,K.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:t})]})}async function gS(e){let{data:t}=await P.post(`/ServiceAccount/`,e);return t}async function _S({id:e,...t}){let{data:n}=await P.patch(`/ServiceAccount/${encodeURIComponent(e)}`,t);return n}async function vS({id:e}){let{data:t}=await P.delete(`/ServiceAccount/${encodeURIComponent(e)}`);return t}function yS(e){let t=Ze();return I({mutationFn:gS,onSuccess:n=>{t.setQueryData([e,`serviceAccounts`],e=>e&&[...e.filter(e=>e.id!==n.id),n]),t.invalidateQueries({queryKey:[e,`serviceAccounts`],refetchType:`active`})}})}function bS(e){let t=Ze();return I({mutationFn:_S,onSuccess:n=>{t.setQueryData([e,`serviceAccounts`],e=>e?.map(e=>e.id===n.id?n:e)),t.invalidateQueries({queryKey:[e,`serviceAccounts`],exact:!0})}})}function xS(e){let t=Ze();return I({mutationFn:vS,onSuccess:(n,{id:r})=>{t.setQueryData([e,`serviceAccounts`],e=>e?.filter(e=>e.id!==r)),t.invalidateQueries({queryKey:[e,`serviceAccounts`],exact:!0})}})}function SS({organizationId:e,account:t,onClose:n}){let{data:r}=L($b(e)),{mutate:i,isPending:a}=bS(e),[o,s]=(0,G.useState)(t.roleName?t.roleId:``),c=!!t.roleName&&o===t.roleId;return(0,K.jsx)(_m,{open:!0,onOpenChange:e=>!e&&!a&&n(),children:(0,K.jsxs)(wm,{className:`sm:max-w-[480px]`,children:[(0,K.jsx)(Dm,{children:`Change role`}),(0,K.jsxs)(Om,{children:[t.name,`'s tokens act with this role from their next request.`]}),(0,K.jsxs)(hy,{value:o,onValueChange:s,disabled:a,children:[(0,K.jsx)(vy,{className:`w-full`,"aria-label":`Role`,children:(0,K.jsx)(_y,{placeholder:`Choose a role`})}),(0,K.jsx)(yy,{children:r?.map(e=>(0,K.jsx)(xy,{value:e.id,children:(0,K.jsx)(hS,{name:e.roleName,id:e.id})},e.id))})]}),(0,K.jsxs)(Em,{children:[(0,K.jsx)(H,{variant:`destructiveOutline`,type:`button`,onClick:n,disabled:a,children:`Cancel`}),(0,K.jsx)(H,{variant:`submit`,type:`button`,onClick:()=>i({id:t.id,roleId:o},{onSuccess:()=>{U.success(`Role changed. It applies to the account’s next request.`),n()}}),disabled:!o||c||a,children:a?`Saving…`:`Save`})]})]})})}var CS=b({name:x().trim().nonempty({error:`Please enter a name.`}).max(100,{error:`Name cannot be longer than 100 characters.`}),roleId:x().nonempty({error:`Please choose a role.`})});function wS({organizationId:e,onClose:t,onCreated:n}){let{mutate:r,isPending:i}=yS(e),a=(0,G.useRef)(!1),o=(0,G.useRef)(!1);(0,G.useEffect)(()=>(a.current=!0,()=>{a.current=!1}),[]);let{data:s,isLoading:c}=L($b(e)),l=on({resolver:mt(CS),mode:`onTouched`,defaultValues:{name:``,roleId:``}}),{isValid:u}=l.formState,d=t=>{!o.current&&a.current&&(o.current=!0,r({organizationId:e,...t},{onSuccess:e=>{U.success(`Service account "${e.name}" created.`),n(e)},onError:()=>{o.current=!1}}))},f=()=>{o.current||t()};return(0,K.jsx)(_m,{open:!0,onOpenChange:e=>!e&&f(),children:(0,K.jsxs)(wm,{className:`sm:max-w-[600px]`,children:[(0,K.jsx)(Dm,{children:`Create Service Account`}),(0,K.jsx)(Om,{children:`A non-human member of this organization for CI pipelines and scripts. It acts with the role you give it.`}),(0,K.jsx)(Od,{...l,children:(0,K.jsxs)(`form`,{id:`create-service-account-form`,name:`create-service-account-form`,className:`flex flex-col gap-4 my-4`,onSubmit:l.handleSubmit(d),onKeyDown:rx(l),children:[(0,K.jsx)(Y,{control:l.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,K.jsx)(cy,{type:`text`,placeholder:`e.g. github-actions`,maxLength:CS.shape.name.maxLength,...e}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:l.control,name:`roleId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Role`}),c?(0,K.jsx)(my,{}):(0,K.jsxs)(hy,{value:e.value,onValueChange:t=>e.onChange(t),children:[(0,K.jsx)(J,{children:(0,K.jsx)(vy,{className:`w-full`,"aria-label":`Role`,children:(0,K.jsx)(_y,{placeholder:`Choose a role`})})}),(0,K.jsx)(yy,{children:s?.map(e=>(0,K.jsx)(xy,{value:e.id,children:(0,K.jsx)(hS,{name:e.roleName,id:e.id})},e.id))})]}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(H,{variant:`destructiveOutline`,type:`button`,onClick:f,disabled:i,children:`Cancel`}),(0,K.jsx)(H,{variant:`submit`,type:`submit`,disabled:i||!u,children:i?`Creating…`:`Create Service Account`})]})})]})})]})})}function TS({status:e}){let t=e===`ACTIVE`;return(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:F(`size-2 rounded-full`,t?`bg-green`:`bg-amber-600`)}),(0,K.jsx)(`span`,{className:F(!t&&`text-amber-600`),children:t?`Enabled`:`Disabled`})]})}function ES({organizationId:e,account:t,onDeleted:n}){let[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(!1),{mutate:s,isPending:c}=bS(e),{mutate:l,isPending:u}=xS(e),d=(0,G.useRef)(!1),f=t.status===`ACTIVE`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Options for ${t.name}`,children:(0,K.jsx)(ua,{})})}),(0,K.jsxs)(vc,{align:`end`,className:`min-w-40`,children:[(0,K.jsxs)(yc,{onClick:()=>o(!0),children:[(0,K.jsx)(ds,{}),`Change role…`]}),(0,K.jsxs)(yc,{onClick:()=>s({id:t.id,status:f?`DISABLED`:`ACTIVE`},{onSuccess:()=>U.success(f?`Service account disabled.`:`Service account enabled.`)}),disabled:c,children:[f?(0,K.jsx)(ei,{}):(0,K.jsx)(Ei,{}),f?`Disable`:`Enable`]}),(0,K.jsxs)(yc,{variant:`destructive`,onClick:()=>i(!0),children:[(0,K.jsx)(Is,{}),`Delete`]})]})]}),a&&(0,K.jsx)(SS,{organizationId:e,account:t,onClose:()=>o(!1)}),(0,K.jsx)(km,{typeOfThingBeingDeleted:`service account`,nameOfThingBeingDeleted:t.name,isModalOpen:r,setIsModalOpen:i,deletionConfirmed:()=>{d.current||(d.current=!0,l({id:t.id},{onError:()=>{d.current=!1},onSuccess:()=>{U.success(`Service account "${t.name}" deleted; its tokens no longer work.`),i(!1),n()}}))},deletionPending:u,hideDataLossWarning:!0})]})}function DS({organizationId:e}){let t=(0,G.useId)(),[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(null),{data:o,isLoading:s,isError:c,refetch:l,isFetching:u}=L(lS(e)),d=Kb(l),f=o?.find(e=>e.id===i),p=e=>a(t=>t===e.id?null:e.id);return(0,K.jsxs)(`div`,{className:`px-4 py-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 mb-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`font-medium text-foreground`,children:`Service accounts`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Identities for CI pipelines and scripts, each acting with one of this organization’s roles.`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mr-[17px]`,children:[(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(H,{variant:`ghost`,size:`icon`,"aria-label":`Refresh service accounts`,onClick:d,disabled:u,children:(0,K.jsx)(Go,{})})}),(0,K.jsx)(Xl,{children:`Refresh`})]}),(0,K.jsxs)(H,{variant:`positive`,size:`sm`,onClick:()=>r(!0),disabled:n,children:[(0,K.jsx)(Uo,{}),`Create service account`]})]})]}),s?(0,K.jsx)(Lc,{className:`py-6`}):c&&!o?(0,K.jsx)(`p`,{className:`py-4 text-sm text-red-500`,children:`Couldn’t load service accounts.`}):o?.length?(0,K.jsxs)(bb,{children:[(0,K.jsx)(xb,{children:(0,K.jsxs)(Cb,{className:`border-border`,children:[(0,K.jsx)(wb,{children:`Name`}),(0,K.jsx)(wb,{children:`Role`}),(0,K.jsx)(wb,{children:`Status`}),(0,K.jsx)(wb,{children:`Active tokens`}),(0,K.jsx)(wb,{children:`Created`}),(0,K.jsx)(wb,{children:(0,K.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,K.jsx)(Sb,{children:o.map(n=>{let r=n.id===i;return(0,K.jsxs)(Cb,{"data-state":r?`selected`:void 0,onClick:()=>p(n),className:`cursor-pointer border-border hover:bg-muted/40 data-[state=selected]:bg-primary/10 dark:data-[state=selected]:bg-white/10`,children:[(0,K.jsx)(Eb,{className:`py-2.5`,children:(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":r,"aria-controls":r?t:void 0,onClick:e=>{e.stopPropagation(),p(n)},className:`group flex flex-col items-start text-left rounded-sm focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,K.jsx)(`span`,{className:`font-medium text-foreground group-hover:underline group-focus-visible:underline`,children:n.name}),(0,K.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:n.id})]})}),(0,K.jsx)(Eb,{className:`py-2.5`,children:n.roleName??(0,K.jsx)(`span`,{className:`text-red-500`,children:`Role deleted`})}),(0,K.jsx)(Eb,{className:`py-2.5`,children:(0,K.jsx)(TS,{status:n.status})}),(0,K.jsx)(Eb,{className:`py-2.5`,children:n.activeTokens}),(0,K.jsx)(Eb,{className:`py-2.5 whitespace-nowrap`,children:(0,K.jsx)(nS,{value:n.createdAt,format:`date`})}),(0,K.jsx)(Eb,{className:`py-2.5 text-right`,onClick:e=>e.stopPropagation(),children:(0,K.jsx)(ES,{organizationId:e,account:n,onDeleted:()=>a(e=>e===n.id?null:e)})})]},n.id)})})]}):(0,K.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No service accounts yet.`}),f&&(0,K.jsx)(mS,{organizationId:e,account:f,regionId:t}),n&&(0,K.jsx)(wS,{organizationId:e,onClose:()=>r(!1),onCreated:e=>{r(!1),a(e.id)}})]})}async function OS(e,t){let{data:n}=await P.patch(`/Organization/${e}/settings/apiTokens`,{enabled:t});return n}function kS({organizationId:e,enabled:t}){let n=Ze(),{mutate:r,isPending:i}=I({mutationFn:t=>OS(e,t),onSuccess:({apiTokensEnabled:t})=>{U.success(t?`API tokens are allowed.`:`API tokens are now refused.`),n.setQueryData([e],e=>e&&{...e,settings:{...e.settings,apiTokensEnabled:t}}),n.invalidateQueries({queryKey:[e]})}});return(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-6 border-b px-4 py-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`allow-api-tokens`,className:`font-medium text-foreground`,children:`Allow API tokens`}),(0,K.jsx)(`p`,{id:`allow-api-tokens-help`,className:`text-sm text-muted-foreground`,children:`Service account tokens work only while this is on.`})]}),(0,K.jsx)(Kx,{id:`allow-api-tokens`,"aria-describedby":`allow-api-tokens-help`,checked:t,disabled:i,onCheckedChange:r})]})}function AS({title:e,actions:t,children:n,bodyClassName:r}){let i=(0,G.useId)();return(0,K.jsxs)(`section`,{"aria-labelledby":i,className:`rounded-lg border bg-card text-foreground`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b px-4 py-3`,children:[(0,K.jsx)(`h3`,{id:i,className:`text-lg font-medium`,children:e}),t]}),(0,K.jsx)(`div`,{className:F(`p-4`,r),children:n})]})}function jS({organizationId:e,apiTokensEnabled:t}){return dg(e)?(0,K.jsxs)(AS,{title:`API access`,bodyClassName:`p-0`,children:[(0,K.jsx)(kS,{organizationId:e,enabled:t}),(0,K.jsx)(DS,{organizationId:e})]}):null}async function MS(e,t){let{data:n}=await P.patch(`/Organization/${e}/settings/oauth`,t);return n}var NS=`openid email profile`,PS=b({domain:x().min(1,`Domain is required`),clientId:x().min(1,`Client ID is required`),clientSecret:x().min(1,`Client secret is required`),scope:x().optional()}),FS=b({domain:x().min(1,`Domain is required`),clientId:x().optional(),clientSecret:x().optional(),scope:x().optional()});function IS(){let{organizationId:e}=z({strict:!1}),{user:t}=Sr(),{update:n}=cg(e),{data:r}=we(Yc(e)),i=Ze(),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(null),l=r.settings?.oauthConfigs??[],{mutate:u,isPending:d}=I({mutationFn:t=>MS(e,t),onSuccess:()=>void i.invalidateQueries({queryKey:[e]}),onError:e=>{pc(e)&&U.error(`Failed to update OAuth settings.`)}}),f=on({resolver:mt(PS),defaultValues:{domain:``,clientId:``,clientSecret:``,scope:NS}}),p=e=>{u({provider:`okta`,...e,scope:e.scope?.trim()||NS},{onSuccess:()=>{U.success(`OAuth provider added.`),f.reset(),o(!1)}})},m=on({resolver:mt(FS)}),h=e=>{c(e.id??null),m.reset({domain:e.domain,clientId:``,clientSecret:``,scope:e.scope??``})},g=(e,t)=>{let n={id:e.id,provider:e.provider,domain:t.domain,scope:t.scope?.trim()||NS};t.clientId&&(n.clientId=t.clientId),t.clientSecret&&(n.clientSecret=t.clientSecret),u(n,{onSuccess:()=>{U.success(`OAuth provider updated.`),c(null)}})},_=(e,t)=>{u({id:e.id,provider:e.provider,[t]:!e[t]})},v=e=>`//oauth/${e}/callback`,y=async e=>{await Ug(e)&&U.success(`Sign-in URL copied.`)},b=async e=>{await Ug(e)&&U.success(`Redirect URI copied.`)};return n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsx)(ub,{children:(0,K.jsxs)(`div`,{className:`max-w-5xl space-y-6 pb-12`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-2xl text-foreground font-light`,children:`Authentication`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Manage sign-in methods and API access for your organization.`})]}),(0,K.jsxs)(AS,{title:`OAuth providers`,actions:!a&&(0,K.jsxs)(H,{variant:`positiveOutline`,size:`sm`,onClick:()=>o(!0),children:[(0,K.jsx)(Uo,{}),`Add OAuth provider`]}),children:[l.length===0&&!a&&(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-4 text-center`,children:[(0,K.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-full bg-muted`,children:(0,K.jsx)(Qa,{"aria-hidden":!0,className:`size-5 text-muted-foreground`})}),(0,K.jsx)(`p`,{className:`font-medium`,children:`No OAuth providers configured`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Add your organization’s Okta so members can sign in with single sign-on.`})]}),l.map(e=>{let n=t?.oauthConfigId===e.id;return s===e.id?(0,K.jsxs)(`div`,{className:`border rounded-lg p-4 mb-3 text-foreground`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h4`,{className:`font-medium`,children:`Edit Provider`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(Ks,{className:`size-4`})})]}),(0,K.jsx)(Od,{...m,children:(0,K.jsxs)(`form`,{onSubmit:m.handleSubmit(t=>g(e,t)),className:`space-y-4`,children:[(0,K.jsx)(Y,{control:m.control,name:`domain`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Domain`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`e.g. company.okta.com`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`clientId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client ID`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`Leave blank to keep existing`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`clientSecret`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client Secret`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,placeholder:`Leave blank to keep existing`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`scope`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Scope`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:NS,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,K.jsx)(H,{type:`submit`,variant:`positive`,disabled:d,children:d?`Saving...`:`Save`}),(0,K.jsx)(H,{type:`button`,variant:`outline`,onClick:()=>c(null),children:`Cancel`})]})]})})]},e.id):(0,K.jsx)(`div`,{className:`border rounded-lg p-4 mb-3 text-foreground`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between sm:gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:e.domain}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground uppercase bg-muted px-2 py-0.5 rounded`,children:e.provider}),e.enabled===!1&&(0,K.jsx)(`span`,{className:`text-xs text-destructive bg-destructive/10 px-2 py-0.5 rounded`,children:`Disabled`})]}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground mb-2`,children:[`Client ID: `,(0,K.jsx)(`span`,{className:`text-foreground font-mono`,children:`****`})]}),e.id&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`mt-3 rounded-md bg-muted px-3 py-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Okta redirect URI`}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-1.5`,children:[`Add to `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Login redirect URIs`}),` `,`in your Okta app settings.`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-foreground font-mono truncate`,children:v(e.id)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>void b(v(e.id)),className:`hover:text-foreground shrink-0 text-muted-foreground`,title:`Copy redirect URI`,children:(0,K.jsx)(ea,{className:`size-3.5`})})]})]}),(0,K.jsxs)(`div`,{className:`mt-2 rounded-md bg-muted px-3 py-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`User login link`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`a`,{href:Tp(e.id),target:`_blank`,rel:`noreferrer`,className:`text-sm text-foreground truncate hover:underline`,children:Tp(e.id)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 text-muted-foreground`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>void y(Tp(e.id)),className:`hover:text-foreground`,title:`Copy login link`,children:(0,K.jsx)(ea,{className:`size-3.5`})}),(0,K.jsx)(`a`,{href:Tp(e.id),target:`_blank`,rel:`noreferrer`,className:`hover:text-foreground`,title:`Open login link`,children:(0,K.jsx)(fa,{className:`size-3.5`})})]})]})]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 sm:shrink-0`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-foreground cursor-pointer`,children:[(0,K.jsx)(Kx,{checked:e.enabled!==!1,onCheckedChange:()=>_(e,`enabled`),disabled:d}),`Enabled`]}),(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-sm text-foreground ${n?`cursor-pointer`:`cursor-not-allowed opacity-50`}`,children:[(0,K.jsx)(Kx,{checked:!!e.required,onCheckedChange:()=>_(e,`required`),disabled:d||!n}),`Required`]})}),!n&&(0,K.jsxs)(Xl,{children:[`Sign in via `,e.provider,` first to enable Required`]})]}),(0,K.jsx)(H,{variant:`outline`,size:`sm`,"aria-label":`Edit provider`,onClick:()=>h(e),disabled:d,children:(0,K.jsx)(zo,{className:`size-4`})})]})]})},e.id)}),a&&(0,K.jsxs)(`div`,{className:`border rounded-lg p-4 text-foreground`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h4`,{className:`font-medium`,children:`Add Okta Provider`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),f.reset()},className:`text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(Ks,{className:`size-4`})})]}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-4`,children:[`After saving, copy the `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Okta redirect URI`}),` `,`from the provider card and add it to your Okta app's`,` `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Login redirect URIs`}),`.`]}),(0,K.jsx)(Od,{...f,children:(0,K.jsxs)(`form`,{onSubmit:f.handleSubmit(p),className:`space-y-4`,children:[(0,K.jsx)(Y,{control:f.control,name:`domain`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Domain`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`e.g. company.okta.com`,autoFocus:!0,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:f.control,name:`clientId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client ID`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`Okta Client ID`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:f.control,name:`clientSecret`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client Secret`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,placeholder:`Okta Client Secret`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:f.control,name:`scope`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Scope`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:NS,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,K.jsx)(H,{type:`submit`,variant:`positive`,disabled:d,children:d?`Adding...`:`Add Provider`}),(0,K.jsx)(H,{type:`button`,variant:`outline`,onClick:()=>{o(!1),f.reset()},children:`Cancel`})]})]})})]})]}),(0,K.jsx)(jS,{organizationId:e,apiTokensEnabled:r.settings?.apiTokensEnabled===!0})]})})]}):(0,K.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))] text-foreground`,children:`You don't have permission to manage settings for this organization.`})}b({email:vf.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:x().nonempty({error:`Please select a role.`})});async function LS(e){let{data:t}=await P.post(`/UserInvite/`,e);return t}function RS(){return I({mutationFn:e=>LS(e)})}function zS({user:e}){let{update:t}=fg(),{mutate:n,isPending:r}=RS(),i=e.roles?.[0]?.id,a=(0,G.useCallback)(t=>{if(t.stopPropagation(),!e.email||!i){U.error(`Cannot resend invite: this user has no email or role.`);return}n({email:e.email,roleId:i},{onSuccess:()=>U.success(`Invitation resent to ${e.email}.`)})},[n,i,e.email]);return t?(0,K.jsxs)(H,{variant:`ghost`,size:`sm`,className:`h-auto px-2 py-0 align-middle text-sm`,onClick:a,disabled:r||!i,children:[(0,K.jsx)(_o,{}),` Resend invite`]}):null}var BS=[{header:`User Id`,accessorKey:`id`,enableSorting:!0,enableGlobalFilter:!1},{header:`Email`,accessorKey:`email`,enableSorting:!0},{header:`First Name`,accessorKey:`firstname`,enableSorting:!0},{header:`Last Name`,accessorKey:`lastname`,enableSorting:!0},{header:`Roles`,id:`roles`,accessorFn:e=>(e.roles??[]).map(e=>e.roleName).sort().join(`, `),enableSorting:!0},{header:`Status`,accessorKey:`status`,enableSorting:!0},{header:`Verified`,accessorKey:`isVerified`,enableSorting:!0},Bb().display({header:``,enableSorting:!1,id:`actions`,cell:e=>e.row.original.status===`PENDING`?(0,K.jsx)(zS,{user:e.row.original}):null})],VS=b({email:vf.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:x().nonempty({error:`Please select a role.`})});async function HS(e){let{data:t}=await P.post(`/OrganizationRole/`,e);return t}function US(){return I({mutationFn:e=>HS(e)})}function WS({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let{organizationId:r}=z({strict:!1}),{data:i,isLoading:a}=L({...$b(r),throwOnError:!0}),[o,s]=(0,G.useState)(!1),c=on({resolver:mt(VS),defaultValues:{email:``,roleId:``}}),{mutate:l,isPending:u}=US(),{mutate:d,isPending:f}=RS(),p=(0,G.useCallback)(async e=>{e&&(o?d:l)(e,{onSuccess:()=>{let r=e.roleId;c.reset(),c.setValue(`roleId`,r),t(),U.success(`User invited successfully!`),n(!1),s(!1)},onError:e=>{e?.status===404&&s(!0)}})},[l,c,d,t,n,o]);return(0,K.jsx)(_m,{onOpenChange:()=>{n(!1),s(!1),c.reset()},open:e,children:(0,K.jsx)(wm,{"aria-describedby":void 0,children:(0,K.jsx)(Od,{...c,children:(0,K.jsxs)(`form`,{id:`org-add-user-form`,name:`org-add-user-form`,onSubmit:c.handleSubmit(p),className:`grid gap-4 my-4`,children:[(0,K.jsx)(Tm,{children:(0,K.jsx)(Dm,{children:o?`Invite User`:`Add User`})}),(0,K.jsx)(Y,{control:c.control,name:`email`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Email`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`email`,enterKeyHint:`next`,autoComplete:`email`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:c.control,name:`roleId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Roles`}),a?(0,K.jsx)(my,{}):(0,K.jsx)(J,{children:(0,K.jsxs)(hy,{...e,onValueChange:t=>e.onChange(t),children:[(0,K.jsx)(vy,{className:`w-full`,children:(0,K.jsx)(_y,{placeholder:`Choose Role`})}),(0,K.jsx)(yy,{children:(0,K.jsxs)(gy,{children:[(0,K.jsx)(by,{children:`Role`}),i?.map(e=>(0,K.jsx)(xy,{value:e.id,children:(0,K.jsx)(hS,{name:e.roleName,id:e.id})},e.id))]})})]})}),(0,K.jsx)(Q,{})]})}),o&&(0,K.jsxs)(Om,{className:`p-3 my-5 rounded-md border border-amber-600 dark:border-amber-500 bg-amber-500/10 text-foreground flex`,children:[(0,K.jsx)(ho,{className:`inline-block size-12 pr-2 text-amber-700 dark:text-amber-400`}),(0,K.jsx)(`span`,{children:`This person doesn’t have a Fabric account. Do you want to invite them?`})]}),(0,K.jsx)(Em,{children:(0,K.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,K.jsxs)(H,{type:`submit`,variant:`submit`,disabled:u||f,children:[(0,K.jsx)($o,{}),` `,o?`Invite User`:`Add User`]})})})]})})})})}async function GS({roleId:e,userId:t}){let{data:n}=await P.delete(`/OrganizationRole/role/${e}/user/${t}`);return n}function KS(){return I({mutationFn:({roleId:e,userId:t})=>GS({roleId:e,userId:t})})}function qS(e){let[t,n]=(0,G.useState)(e||!1);return[t,(0,G.useCallback)(e=>{n(typeof e==`boolean`?e:e.target.checked)},[])]}function JS({data:e,readOnly:t,canRemove:n,orgRole:r,selectedRoles:i,setChangesMade:a}){let{mutate:o,isPending:s}=US(),{mutate:c,isPending:l}=KS(),u=!!i[r.id],[d,f]=(0,G.useState)(u),[p,m]=qS(u);return(0,G.useEffect)(()=>{p!==d&&(p?o({email:e.email,roleId:r.id},{onSuccess:()=>{f(p),a(!0),U.success(`Role added successfully`)}}):c({userId:e.id,roleId:r.id},{onSuccess:()=>{f(p),a(!0),U.success(`Role removed successfully`)}}))},[o,e.email,e.id,p,r.id,c,a,d]),(0,K.jsxs)(Md,{className:`flex`,children:[(0,K.jsx)($,{type:`checkbox`,className:`w-6`,disabled:t||s||l||!n&&p,checked:p,onChange:m}),(0,K.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:r.roleName})]},r.id)}function YS({isSelf:e,isPending:t,onConfirm:n}){let[r,i]=(0,G.useState)(!1),a=e?{idle:`Leave organization`,confirm:`Confirm leave`,busy:`Leaving…`,warning:`You’ll lose access to this organization and everything in it. You won’t be able to return unless another member invites you back.`}:{idle:`Remove from organization`,confirm:`Confirm removal`,busy:`Removing…`,warning:`This revokes their access to this organization and everything in it. Their Harper account isn’t deleted, and they can be added back later.`},o=e?uo:Bs;return r?(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`p`,{role:`alert`,className:`flex items-start gap-2 text-sm text-muted-foreground border border-amber-500/50 rounded-md p-3`,children:[(0,K.jsx)(Rs,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,K.jsx)(`span`,{children:a.warning})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(H,{type:`button`,variant:`ghostOutline`,disabled:t,onClick:()=>i(!1),children:`Cancel`}),(0,K.jsxs)(H,{type:`button`,variant:`destructive`,disabled:t,onClick:n,children:[(0,K.jsx)(o,{}),` `,t?a.busy:a.confirm]})]})]}):(0,K.jsx)(`div`,{className:`flex justify-start`,children:(0,K.jsxs)(H,{type:`button`,variant:`destructiveOutline`,disabled:t,onClick:()=>i(!0),children:[(0,K.jsx)(o,{}),` `,a.idle]})})}function XS(e){return e?.trim().toLowerCase()===`admin`}function ZS({canDelete:e,isSelf:t,orgUserCount:n,adminCount:r,isAdmin:i,roleCount:a}){let o=e?t&&n<=1?`sole-member`:t&&i&&r<=1?`last-admin`:null:null,s=e&&o===null;return{canRemoveRoles:s,showRemovalAction:s&&a>0,blockedReason:o}}function QS({closeModal:e,data:t,isModalOpen:n,onUserUpdated:r,orgUserCount:i,orgAdminCount:a}){let{organizationId:o}=z({strict:!1}),s=Sr(),{update:c,remove:l}=fg(o),u=s.user?.email===t.email,[d,f]=(0,G.useState)(!1),{canRemoveRoles:p,showRemovalAction:m,blockedReason:h}=ZS({canDelete:l,isSelf:u,orgUserCount:i,adminCount:a,isAdmin:(t.roles??[]).some(e=>XS(e.roleName)),roleCount:t.roles?.length??0}),{mutateAsync:g}=KS(),[_,v]=(0,G.useState)(!1),y=(0,G.useCallback)(async()=>{let e=t.roles??[];v(!0);let n=(await Promise.allSettled(e.map(e=>g({userId:t.id,roleId:e.id})))).flatMap(e=>e.status===`rejected`&&e.reason?.response?.status!==404?[e.reason]:[]);n.some(pc)?U.error(u?`Something went wrong leaving the organization. Please try again.`:`Couldn’t remove ${t.email} from the organization. Please try again.`):n.length===0&&U.success(u?`You’ve left the organization.`:`${t.email} was removed from the organization.`),v(!1),r()},[t.roles,t.id,t.email,u,g,r]);return(0,K.jsx)(_m,{onOpenChange:d?r:e,open:n,children:(0,K.jsxs)(wm,{resizable:!0,children:[(0,K.jsx)(Tm,{children:(0,K.jsxs)(Dm,{children:[c?`Edit `:`View `,` `,t.email,` `,u?`(yourself)`:``]})}),c&&(0,K.jsxs)(Om,{children:[`Use the checkboxes to change which roles `,u?`you have`:`this user has`,`.`,m&&(u?` To leave the organization entirely, use the button below.`:` To remove this user from the organization entirely, use the button below.`)]}),(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(Lc,{centered:!0,text:`Loading roles…`,className:`flex-1 min-h-0`}),children:(0,K.jsx)($S,{data:t,organizationId:o,update:c,canRemove:p,setChangesMade:f})}),t.status===`PENDING`&&(0,K.jsx)(`div`,{className:`border-t border-border pt-4`,children:(0,K.jsx)(zS,{user:t})}),m&&(0,K.jsx)(`div`,{className:`border-t border-border pt-4`,children:(0,K.jsx)(YS,{isSelf:u,isPending:_,onConfirm:y})}),h&&(0,K.jsxs)(`p`,{className:`flex items-start gap-2 text-sm text-muted-foreground border border-amber-500/50 rounded-md p-3`,children:[(0,K.jsx)(Rs,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,K.jsx)(`span`,{children:h===`sole-member`?`You’re the only member of this organization, so you can’t remove your roles or leave — it would be left with no one to manage it. If you no longer need this organization, terminate its clusters, then delete the organization from the ⋯ menu on the Organizations page.`:`You’re the only admin of this organization, so you can’t remove your roles or leave — it would be left with no one who can manage its members, roles, or clusters. Give another member the admin role first, then you can step back.`})]})]})})}function $S({data:e,organizationId:t,update:n,canRemove:r,setChangesMade:i}){let{data:a}=we($b(t)),o=(0,G.useMemo)(()=>e.roles?O_(e.roles,`id`):{},[e]);return(0,K.jsx)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 overflow-y-auto`,children:a.map(t=>(0,K.jsx)(JS,{readOnly:!n,canRemove:r,data:e,orgRole:t,selectedRoles:o,setChangesMade:i},t.id))})}function eC(e,t){return e.email>t.email?1:-1}function tC(e){return(e.users??[]).filter(e=>e!=null)}function nC(e){let t={};for(let n of e)for(let e of tC(n))t[e.id]||(t[e.id]={...e,roles:[]}),t[e.id].roles.push(n);return Object.values(t).sort(eC)}function rC(e){let t=new Set;for(let n of e)if(XS(n.roleName))for(let e of tC(n))t.add(e.id);return t.size}function iC(){let e=De(),{organizationId:t,orgUserId:n}=z({strict:!1}),{update:r}=fg(t),{data:i,refetch:a,isFetching:o,isRefetching:s}=we($b(t)),c=(0,G.useMemo)(()=>nC(i),[i]),l=(0,G.useMemo)(()=>rC(i),[i]),u=(0,G.useMemo)(()=>c?.find(e=>e.id===n),[c,n]),d=(0,G.useCallback)(t=>{let r=[n?`..`:``,t].filter(Boolean);e({to:r.join(`/`)})},[n,e]),f=!!n&&!!u,[p,m]=(0,G.useState)(!1),[h]=(0,G.useState)({attribute:`email`,descending:!1}),g=(0,G.useMemo)(()=>[{desc:h.descending,id:h.attribute}],[h]),_=(0,G.useCallback)(()=>{m(!0)},[m]),v=(0,G.useCallback)(()=>{a(),m(!1)},[a,m]),y=(0,G.useCallback)(e=>{d(e.original.id)},[d]),b=(0,G.useCallback)(()=>{d(void 0)},[d]),x=(0,G.useCallback)(()=>{a(),d(void 0)},[d,a]),S=Kb(a);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsx)(ub,{children:(0,K.jsxs)(G.Suspense,{fallback:(0,K.jsx)(Lc,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,K.jsxs)(Hb,{data:c,isFetching:o||s,columns:BS,onRowClick:y,sortingState:g,filter:{label:`Filter users`,placeholder:`Filter by email, name, role or status`},paginated:!0,children:[(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:S,accessKey:`r`,disabled:o||s,children:[(0,K.jsx)(Go,{}),` `,(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),r&&(0,K.jsxs)(H,{variant:`positiveOutline`,onClick:_,accessKey:`a`,disabled:p,children:[(0,K.jsx)(Uo,{}),` `,(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]}),r&&(0,K.jsx)(WS,{isModalOpen:p,onChangesSaved:v,setIsModalOpen:m}),f&&(0,K.jsx)(QS,{closeModal:b,data:u,isModalOpen:f,onUserUpdated:x,orgUserCount:c.length,orgAdminCount:l})]})})]})}function aC({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`skeleton`,className:F(`bg-primary/10 animate-pulse rounded-md`,e),...t})}function oC({organizationId:e,organizationName:t,providers:n}){return(0,K.jsxs)(Er,{className:`relative gap-0 py-0 h-full justify-between overflow-hidden border border-amber-500/30`,children:[(0,K.jsxs)(Dr,{className:`gap-4 py-5 border-b border-primary/10 bg-linear-to-br from-primary/5 to-primary/20 dark:from-primary/20 dark:to-primary/5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`rounded-lg border border-primary/20 bg-background/50 p-2 text-primary dark:text-violet-300`,children:(0,K.jsx)(fi,{className:`size-5`,"aria-hidden":`true`})}),(0,K.jsx)(`span`,{className:`rounded-full border border-amber-500/30 bg-amber-500/10 px-2 py-1 text-xs`,children:`Sign-in required`})]}),(0,K.jsx)(Or,{children:(0,K.jsx)(`h2`,{className:`truncate text-xl`,title:t||e,children:t||e})}),t&&t!==e&&(0,K.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,title:e,children:e})]}),(0,K.jsxs)(Ar,{className:`py-4 flex flex-col gap-2`,children:[(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-1.5 mb-1`,children:[(0,K.jsx)(Ha,{className:`size-3 shrink-0`}),`Sign in with an OAuth provider to access this organization.`]}),n.map(e=>(0,K.jsx)(`a`,{href:Tp(e.oauthConfigId),children:(0,K.jsxs)(H,{variant:`outline`,className:`w-full`,children:[`Sign in with `,e.name]})},e.oauthConfigId))]})]})}var sC=b({couponId:x().nonempty({message:`Please enter a coupon ID.`}).trim()});async function cC({organizationId:e,couponId:t}){let n=await P.post(`/Coupon`,{organizationId:e,couponId:t},{validateStatus:e=>e>=200&&e<400||e===400||e===409});if(n.status===400||n.status===409)return fc({response:n}).message}function lC(){return I({mutationFn:cC})}function uC({organizationId:e,organizationName:t,isOpen:n,onClose:r}){let{mutate:i,isPending:a}=lC(),o=on({resolver:mt(sC),defaultValues:{couponId:``}}),{handleSubmit:s,control:c,reset:l}=o;(0,G.useEffect)(()=>{n&&l({couponId:``})},[n,l]);let u=(0,G.useCallback)(n=>{i({organizationId:e,couponId:n.couponId},{onSuccess:i=>{i?U.error(`Error`,{description:i}):(U.success(`Success`,{description:`Coupon "${n.couponId}" added to ${t||e}.`}),r())}})},[i,e,t,r]);return(0,K.jsx)(_m,{open:n,onOpenChange:e=>!e&&r(),children:(0,K.jsxs)(wm,{children:[(0,K.jsxs)(Tm,{children:[(0,K.jsx)(Dm,{children:`Add Coupon`}),(0,K.jsxs)(Om,{children:[`Add a coupon code to`,` `,t||e,`. This coupon will be applied to the next billing cycle.`,(0,K.jsx)(`br`,{}),`Coupons can be created in our`,` `,(0,K.jsx)(`a`,{href:`https://dashboard.stripe.com/`,target:`_blank`,rel:`noreferrer`,className:`text-purple hover:underline`,children:`Stripe Dashboard`}),`.`]})]}),(0,K.jsx)(Od,{...o,children:(0,K.jsxs)(`form`,{onSubmit:s(u),children:[(0,K.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,K.jsx)(Y,{control:c,name:`couponId`,render:({field:e})=>(0,K.jsxs)(X,{className:`grid items-center gap-4`,children:[(0,K.jsx)(Z,{children:`Coupon ID`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{...e,placeholder:`e.g. 100OFF`,disabled:a})}),(0,K.jsx)(Q,{})]})})}),(0,K.jsxs)(Em,{children:[(0,K.jsx)(H,{type:`button`,variant:`ghost`,onClick:r,disabled:a,children:`Cancel`}),(0,K.jsx)(H,{type:`submit`,disabled:a,children:a?`Adding...`:`Add Coupon`})]})]})})]})})}function dC({organizationRole:e,onDeleteOrgModal:t}){let{organizationId:n,organizationName:r,roleName:i}=e,a=r||n,o={organizationId:n},s=qg(o),[c]=Gg(n),{remove:l,update:u}=cg(n),d=u,{view:f}=fg(n),p=wr(`billing:write`),[m,h]=(0,G.useState)(!1),g=(0,G.useCallback)(()=>{t(e)},[t,e]),_=[{type:`label`,key:`label`,className:`text-gray-600 text-xs`,label:`Options`},{type:`separator`,key:`sep-top`},{key:`clusters`,to:s,icon:(0,K.jsx)(ss,{className:`size-4 mr-2 text-blue-500`}),label:`Clusters`},f&&{key:`roles`,to:qg(o,`roles`),icon:(0,K.jsx)(ds,{className:`size-4 mr-2 text-purple`}),label:`Roles`},f&&{key:`users`,to:qg(o,`users`),icon:(0,K.jsx)(Ws,{className:`size-4 mr-2 text-orange-500`}),label:`Users`},d&&{key:`billing`,to:qg(o,`billing`),icon:(0,K.jsx)(na,{className:`size-4 mr-2 text-green-500`}),label:`Billing`},u&&{key:`settings`,to:qg(o,`settings`),icon:(0,K.jsx)(Ha,{className:`size-4 mr-2 text-yellow-500`}),label:`Settings`},p&&{key:`add-coupon`,onClick:()=>h(!0),icon:(0,K.jsx)(Ps,{className:`size-4 mr-2 text-pink-500`}),label:`Add Coupon`},l&&{type:`separator`,key:`sep-bottom`},l&&{key:`delete`,onClick:g,className:`focus:bg-red/70 focus:text-white`,icon:(0,K.jsx)(Is,{className:`size-4 mr-2 text-red-500`}),label:`Delete`}].filter(fr),v=l||p;return(0,K.jsx)(zm,{items:v?_:[],children:(0,K.jsxs)(Er,{className:`group relative gap-0 py-0 h-full cursor-pointer justify-between overflow-hidden border border-primary/15 transition-[border-color,box-shadow] duration-200 hover:border-primary/60 hover:shadow-lg hover:ring-2 hover:ring-primary/40 dark:hover:ring-violet-400/60`,children:[(0,K.jsx)(V,{to:s,"aria-label":`Open ${a}`,className:`absolute inset-0 z-10 cursor-pointer rounded-[inherit] focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring focus-visible:outline-none`}),(0,K.jsxs)(Dr,{className:`gap-4 py-5 border-b border-primary/10 bg-linear-to-br from-primary/5 to-primary/20 dark:from-primary/20 dark:to-primary/5`,children:[(0,K.jsxs)(kr,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,K.jsx)(`span`,{className:`rounded-lg border border-primary/20 bg-background/50 p-2 text-primary dark:text-violet-300`,children:(0,K.jsx)(fi,{className:`size-5`,"aria-hidden":`true`})}),v&&(0,K.jsxs)(gc,{children:[(0,K.jsxs)(_c,{"aria-label":`Options`,onClick:e=>e.stopPropagation(),className:`relative z-20 inline-flex cursor-pointer shrink-0 items-center gap-1.5 rounded-md border border-primary/25 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground shadow-sm transition-colors hover:border-primary/60 hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-ring`,children:[`Options `,(0,K.jsx)(er,{className:`size-3.5`,"aria-hidden":`true`})]}),(0,K.jsx)(vc,{align:`end`,children:Rm(_,`dropdown`)})]})]}),(0,K.jsx)(Or,{children:(0,K.jsx)(`h2`,{className:`truncate text-xl`,title:a,children:a})}),(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs text-muted-foreground`,children:[n!==a&&(0,K.jsx)(`span`,{className:`truncate`,title:n,children:n}),(0,K.jsx)(`button`,{type:`button`,onClick:c,"aria-label":`Copy ID for ${a}`,className:`relative z-20 shrink-0 cursor-pointer rounded p-1 hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-ring`,children:(0,K.jsx)(ea,{className:`size-3.5`,"aria-hidden":`true`})})]})]}),(0,K.jsxs)(Ar,{className:`py-4 flex items-center justify-between gap-2`,children:[(0,K.jsx)(ol,{variant:`outline`,className:`min-w-0 shrink border-primary/25 bg-primary/10 text-foreground`,title:_d(i),children:(0,K.jsx)(`span`,{className:`truncate`,children:_d(i)})}),(0,K.jsxs)(`span`,{className:`text-sm shrink-0 py-2 whitespace-nowrap ml-auto`,children:[`Open `,(0,K.jsx)(Wr,{className:`inline-block`})]})]}),(0,K.jsx)(uC,{organizationId:n,organizationName:r,isOpen:m,onClose:()=>h(!1)})]})})}function fC(e,t){let n=t.toLowerCase();return t=>{for(let r of e){let e=t[r];if(e!=null){if(typeof e==`string`){if(e.toLowerCase().includes(n))return!0}else if(typeof e==`boolean`){if(e&&(n===`yes`||n===`true`||n===`1`)||!e&&(n===`no`||n===`false`||n===`0`))return!0}else throw Error(`curryFilterByFuzzySearch has not implemented support for `+typeof e+` fields yet!`)}}return!1}}function pC(e){let t=e.filter(e=>e.locked).length;return{total:e.length,accessible:e.length-t,locked:t}}function mC(e,t,n,r,i){return e.filter(fC([`id`,`name`],t)).filter(e=>n===`all`||(n===`locked`?e.locked:!e.locked)).filter(e=>!r||!e.locked&&e.roleName===r).sort((e,t)=>(e.name.localeCompare(t.name)||e.id.localeCompare(t.id))*(i?-1:1))}async function hC(e){let{data:t}=await P.delete(`/Organization/${e}`);return t}function gC(){let e=Ze();return I({mutationFn:e=>hC(e),onSuccess:(t,n)=>{e.removeQueries({queryKey:[n]}),e.invalidateQueries({queryKey:[]})}})}async function _C(e){let{data:t}=await P.post(`/Organization/`,{...e});return t}function vC(){return I({mutationFn:e=>_C(e)})}var yC=x().max(62,{error:`Must be at most 62 characters long.`}).regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,{error:`Please only use lowercase letters, digits and dashes (-) in the subdomain. Must not start or end with a dash.`}),bC=b({name:x().max(255,{error:`Name cannot be longer than 255 characters.`}),subdomain:te([O(``),w(),yC]).optional()});function xC(){let{user:e}=Sr(),t=De(),n=on({resolver:mt(bC),defaultValues:{name:``,subdomain:``}}),{setFocus:r,watch:i}=n;(0,G.useEffect)(()=>{r(`name`)},[r]);let a=`${e?.firstname} ${e?.lastname} Org`,o=i(`name`)||a,s=i(`subdomain`),c=(0,G.useMemo)(()=>{let e=L_(z_(o),yC.maxLength);return{suggestedSubdomain:e,fullHostName:`future-cluster-names.${s||e}.harperfabric.com`}},[o,s]),{mutate:l,isPending:d}=vC(),p=Ze(),h=(0,G.useCallback)(async e=>{l({name:e.name||a,subdomain:e.subdomain||c.suggestedSubdomain},{onSuccess:e=>{p.invalidateQueries({queryKey:f,refetchType:`active`}),u.reloadUser(m),t({to:`/${e.id}`})}})},[c.suggestedSubdomain,p,l,a,t]);return(0,K.jsx)(K.Fragment,{children:(0,K.jsx)(Od,{...n,children:(0,K.jsxs)(`form`,{id:`org-add-form`,name:`org-add-form`,onSubmit:n.handleSubmit(h),className:`grid items-start gap-6 text-foreground lg:grid-cols-[1.2fr_1fr]`,children:[(0,K.jsxs)(Er,{className:`min-w-0 gap-0 overflow-hidden py-0`,children:[(0,K.jsxs)(Dr,{className:`border-b border-primary/10 bg-linear-to-br from-primary/5 to-primary/20 py-5 dark:from-primary/20 dark:to-primary/5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-primary dark:text-violet-300`,children:[(0,K.jsx)(fi,{className:`size-4`,"aria-hidden":`true`}),(0,K.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:`Organization details`})]}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Choose a name and an address for your organization.`})]}),(0,K.jsxs)(Ar,{className:`grid gap-6 py-6`,children:[(0,K.jsx)(Y,{control:n.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,K.jsx)(cy,{type:`text`,className:`bg-background/60`,maxLength:bC.shape.name.maxLength,autoCapitalize:`words`,placeholder:a,...e}),(0,K.jsx)(ky,{children:`Use a name your team will recognize.`}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:n.control,name:`subdomain`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Subdomain`}),(0,K.jsx)(cy,{type:`text`,className:`bg-background/60`,maxLength:yC.maxLength,autoCapitalize:`none`,placeholder:c.suggestedSubdomain,...e}),(0,K.jsx)(ky,{children:`Lowercase letters, numbers, and dashes. Leave blank to use the suggested subdomain.`}),(0,K.jsx)(Q,{})]})})]}),(0,K.jsx)(`div`,{className:`border-t border-border/60 bg-muted/20 px-6 py-5`,children:(0,K.jsxs)(H,{type:`submit`,variant:`submit`,disabled:d,className:`w-full sm:w-auto`,children:[d?`Creating organization…`:`Create organization`,` `,(0,K.jsx)(Wr,{"aria-hidden":`true`})]})})]}),(0,K.jsxs)(`aside`,{className:`min-w-0 rounded-2xl border border-primary/15 bg-primary/5 p-6`,"aria-labelledby":`org-address-heading`,children:[(0,K.jsxs)(`div`,{className:`mb-4 flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary dark:text-violet-300`,children:(0,K.jsx)(ca,{className:`size-5`,"aria-hidden":`true`})}),(0,K.jsx)(`h2`,{id:`org-address-heading`,className:`text-base font-semibold`,children:`Your cluster addresses`})]}),(0,K.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-muted-foreground`,children:`Your subdomain is part of the address for Harper-hosted clusters you create in this organization.`}),(0,K.jsxs)(`div`,{className:`my-5`,children:[(0,K.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:`Address preview`}),(0,K.jsx)(sy,{hostname:c.fullHostName,testId:`org-hostname-preview`})]}),(0,K.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`The cluster name here is a placeholder. After creating your organization, you’ll name your first cluster!`}),(0,K.jsxs)(`div`,{className:`mt-5 border-t border-primary/15 pt-5`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium`,children:`Prefer your own domain?`}),(0,K.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-muted-foreground`,children:`You can also bind a domain you own to a Harper-hosted cluster after creating it.`}),(0,K.jsxs)(`a`,{href:`https://docs.harperdb.io/fabric/custom-domains`,target:`_blank`,rel:`noopener noreferrer`,className:`mt-3 inline-flex items-center gap-1.5 rounded-sm text-sm font-medium text-primary underline underline-offset-4 hover:no-underline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring dark:text-violet-300`,children:[`Learn about custom domains`,(0,K.jsx)(fa,{className:`size-3.5`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`(opens in a new tab)`})]})]})]})]})})})}function SC(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsxs)(`section`,{className:`mx-auto mt-32 w-full max-w-6xl px-4 py-8 md:px-12 md:py-10`,children:[(0,K.jsxs)(`header`,{className:`mb-8 flex items-center gap-4`,children:[(0,K.jsx)(`div`,{className:`flex size-14 shrink-0 items-center justify-center rounded-2xl border border-primary/20 bg-primary/10 text-primary dark:text-violet-300`,children:(0,K.jsx)(fi,{className:`size-6`,"aria-hidden":`true`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`mb-1 text-xs font-medium uppercase tracking-widest text-muted-foreground`,children:`Your workspace`}),(0,K.jsx)(`h1`,{className:`text-3xl font-semibold tracking-tight`,children:`Create an organization`}),(0,K.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`A home for your team and clusters in Harper Fabric.`})]})]}),(0,K.jsx)(xC,{})]})]})}var CC={org:`organization`,clu:`cluster`,ins:`instance`},wC=/^(org|clu|ins)-[a-z0-9]+$/;function TC(e){if(typeof e!=`string`)return null;let t=e.trim(),n=wC.exec(t);return n?{kind:CC[n[1]],id:t}:null}function EC(e,t){let n=e*12,r=DC(t);return`/Admin/Organization/?${[...r?[`search=${encodeURIComponent(r)}`]:[],`status=ne=DELETED`,...r?[]:[`sort(name)`],`limit(${n},${n+12+1})`].join(`&`)}`}function DC(e){return typeof e==`string`?e.trim():``}async function OC(e,t){let{data:n}=await P.get(EC(e,t));return{organizations:n.slice(0,12),hasNextPage:n.length>12}}var kC={organizations:[],hasNextPage:!1};function AC(e){return e instanceof E&&(e.response?.status===404||e.status===404)}async function jC(e){try{let{data:t}=await P.get(`/Admin/Organization/${e}`);return t?{organizations:[t],hasNextPage:!1}:kC}catch(e){if(AC(e))return kC;throw e}}async function MC(e){try{let{data:t}=await P.get(`/Cluster/${e}`),n=t?.organizationId;return n?await jC(n):kC}catch(e){if(AC(e))return kC;throw e}}function NC(e,t){let n=DC(t),r=TC(n);return B({queryKey:[`admin-all-organizations`,n,e],queryFn:()=>r?.kind===`organization`?jC(r.id):r?.kind===`cluster`?MC(r.id):OC(e,n),placeholderData:He,retry:!1})}function PC(e,t=300,n){let[r,i]=(0,G.useState)(e),a=n?n(e):e;return(0,G.useEffect)(()=>{let n=setTimeout(()=>i(e),t);return()=>clearTimeout(n)},[a,t]),r}function FC(e,t){let n=(0,G.useRef)({key:e,defaultValue:t});(0,G.useInsertionEffect)(()=>{n.current={key:e,defaultValue:t}});let r=(0,G.useRef)(!0);(0,G.useLayoutEffect)(()=>(r.current=!0,()=>{r.current=!1}),[]);let i=(0,G.useCallback)(t=>uu(e,n.current.defaultValue,t),[e]);return[(0,G.useSyncExternalStore)(i,()=>cu(e,t)),(0,G.useCallback)(e=>{r.current&&lu(n.current.key,n.current.defaultValue,e)},[])]}function IC(){let{data:e}=we(s()),{mutate:t,isPending:n}=gC(),[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(null),[c,l]=(0,G.useState)(``),[u,d]=(0,G.useState)(`all`),[f,p]=(0,G.useState)(``),[m,h]=(0,G.useState)(!1),g=()=>{l(``),d(`all`),p(``),h(!1),x(0)},_=wr(`org:read`),[v,y]=FC(`ShowAllOrganizations`,!1),[b,x]=(0,G.useState)(0),S=_&&v,C=(0,G.useCallback)(e=>{y(e),x(0)},[y]),w=PC(c,300),T=(0,G.useMemo)(()=>{if(!_)return null;let e=TC(w);return e?.kind===`organization`||e?.kind===`cluster`?e:null},[_,w]),E=S||!!T,{data:D,isPending:O,isError:k,isFetching:A,refetch:j}=L({...NC(b,w),enabled:E}),M=(0,G.useMemo)(()=>Nr(e),[e]),ee=(0,G.useMemo)(()=>pC(M),[M]),te=(0,G.useMemo)(()=>[...new Set(M.filter(e=>!e.locked).map(e=>e.roleName))].sort(),[M]),N=te.includes(f)?f:``,P=(0,G.useMemo)(()=>E?[]:mC(M,c,u,N,m),[M,c,u,N,m,E]),F=!!c||u!==`all`||!!N||m,ne=(0,G.useMemo)(()=>{let t=e?.roles||{};return(D?.organizations||[]).map(e=>({organizationId:e.id,organizationName:e.name||e.id,roleName:t[e.id]?.role||`fabric staff`}))},[D?.organizations,e?.roles]),re=(0,G.useCallback)(e=>{l(e.currentTarget.value||``),x(0)},[]),ie=(0,G.useCallback)(e=>{e?.organizationId&&t(e.organizationId,{onSuccess:()=>{U.success(`Success`,{description:`Organization successfully deleted.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),i(!1)},onError:()=>i(!1)})},[t,i]),ae=(0,G.useCallback)(e=>{o(e),i(!0)},[]),{createCluster:oe}=Oe({strict:!1});return!E&&ee.accessible===1&&!F&&oe?(0,K.jsx)(qe,{to:`/${M.find(e=>!e.locked).id}/new-cluster`,replace:!0}):!E&&!M.length&&!F?(0,K.jsx)(SC,{}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsxs)(`section`,{className:`mt-32 px-4 pt-6 pb-10 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:[(0,K.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-4 pb-6`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-bold tracking-normal text-primary sm:text-3xl dark:text-violet-300`,children:`Organizations`}),(0,K.jsx)(H,{asChild:!0,variant:`positive`,accessKey:`n`,children:(0,K.jsxs)(V,{to:`/new-org`,children:[(0,K.jsx)(Uo,{}),`New Organization`]})})]}),!E&&(0,K.jsx)(`div`,{role:`group`,"aria-label":`Organization summary`,className:`mb-5 hidden grid-cols-3 gap-3 sm:grid`,children:[{value:`all`,label:`Total organizations`,count:ee.total},{value:`accessible`,label:`Accessible`,count:ee.accessible},{value:`locked`,label:`Sign-in required`,count:ee.locked}].map(e=>(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":u===e.value,onClick:()=>{d(e.value),p(``)},className:`flex cursor-pointer items-center justify-between rounded-xl border px-4 py-3 text-sm transition-colors hover:border-primary/60 focus-visible:outline-2 focus-visible:outline-ring ${u===e.value?`border-primary/40 bg-primary/10`:`border-border bg-card/60`}`,children:[(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,K.jsx)(`span`,{className:`text-xl font-semibold`,children:e.count})]},e.value))}),(0,K.jsxs)(`div`,{role:`search`,"aria-label":`Find organizations`,className:`mb-4 flex flex-wrap items-center gap-3 rounded-xl border border-border bg-card/60 p-3`,children:[(0,K.jsx)($,{"aria-label":`Search organizations`,placeholder:`Search name or ID…`,className:`min-w-0 flex-1 basis-56 dark:bg-background/60`,value:c,onChange:re}),!E&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`select`,{"aria-label":`Organization access`,value:u,onChange:e=>{d(e.target.value),p(``)},className:`max-w-full rounded-lg border border-border bg-background px-3 py-2 text-sm`,children:[(0,K.jsx)(`option`,{value:`all`,children:`All access`}),(0,K.jsx)(`option`,{value:`accessible`,children:`Accessible`}),(0,K.jsx)(`option`,{value:`locked`,children:`Sign-in required`})]}),u!==`locked`&&(te.length>1||!!N)&&(0,K.jsxs)(`select`,{"aria-label":`Organization role`,value:N,onChange:e=>p(e.target.value),className:`max-w-full rounded-lg border border-border bg-background px-3 py-2 text-sm`,children:[(0,K.jsx)(`option`,{value:``,children:`All roles`}),te.map(e=>(0,K.jsx)(`option`,{value:e,children:_d(e)},e))]}),(0,K.jsxs)(`select`,{"aria-label":`Sort organizations`,value:m?`desc`:`asc`,onChange:e=>h(e.target.value===`desc`),className:`max-w-full rounded-lg border border-border bg-background px-3 py-2 text-sm`,children:[(0,K.jsx)(`option`,{value:`asc`,children:`Name: A–Z`}),(0,K.jsx)(`option`,{value:`desc`,children:`Name: Z–A`})]})]}),_&&(0,K.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm`,children:[(0,K.jsx)(Kx,{checked:v,onCheckedChange:C,"aria-label":`Show all organizations`}),`All organizations`]})]}),(0,K.jsx)(`p`,{role:`status`,className:`mb-4 text-xs text-muted-foreground`,children:E?`Staff directory · Server search and pagination`:`Showing ${P.length} of ${ee.total} organizations`}),E&&k&&(0,K.jsxs)(`div`,{role:`alert`,className:`mb-4 rounded-xl border p-6`,children:[(0,K.jsx)(`p`,{children:D?`Organizations couldn’t be refreshed. Showing the last available results.`:`Organizations couldn’t be loaded.`}),(0,K.jsx)(H,{variant:`outline`,disabled:A,onClick:()=>void j(),children:A?`Retrying…`:`Retry`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-5 md:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4`,children:[E?O?Array.from({length:12},(e,t)=>(0,K.jsx)(aC,{className:`h-48`},t)):ne.map(e=>(0,K.jsx)(dC,{organizationRole:e,onDeleteOrgModal:ae},e.organizationId)):P.map(e=>e.locked?(0,K.jsx)(oC,{organizationId:e.id,organizationName:e.name,providers:e.providers},e.id):(0,K.jsx)(dC,{organizationRole:{organizationId:e.id,organizationName:e.name,roleName:e.roleName},onDeleteOrgModal:ae},e.id)),(E?!O&&!k&&!ne.length:!P.length)&&(0,K.jsxs)(`div`,{className:`col-span-full rounded-xl border border-dashed p-10 text-center`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-medium`,children:`No matching organizations`}),(0,K.jsx)(`p`,{className:`my-3 text-sm text-muted-foreground`,children:`Try another name or clear your filters.`}),(0,K.jsx)(H,{variant:`outline`,onClick:g,children:`Clear filters`})]})]}),E&&(b>0||D?.hasNextPage)&&(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-4 py-6`,children:[(0,K.jsxs)(H,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:b===0,onClick:()=>x(e=>e-1),children:[(0,K.jsx)(Hr,{}),`Previous`]}),(0,K.jsxs)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:[`Page `,b+1]}),(0,K.jsxs)(H,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:!D?.hasNextPage,onClick:()=>x(e=>e+1),children:[`Next`,(0,K.jsx)(Wr,{})]})]})]}),a&&(0,K.jsx)(km,{typeOfThingBeingDeleted:`organization`,nameOfThingBeingDeleted:a.organizationName,isModalOpen:r,setIsModalOpen:()=>i(!1),deletionConfirmed:()=>ie(a),deletionPending:n})]})}var LC=R({getParentRoute:()=>Uu,id:`_orgsLayout`});R({getParentRoute:()=>LC,path:`/`,head:()=>({meta:[{title:`Organizations — Harper Fabric`}]}),component:IC}),R({getParentRoute:()=>LC,path:`/new-org`,head:()=>({meta:[{title:`New Organization — Harper Fabric`}]}),component:SC});async function RC(e,t){let{queryClient:n}=e.context,r=u.getSignOutGeneration(m),i;if(!e.preload){let r=n.getQueryCache().build(n,n.defaultQueryOptions(t));r.state.data===void 0&&(i=uc(r,e.abortController.signal))}try{return await n.ensureQueryData(t)}catch(e){if(Ie(e)&&u.getSignOutGeneration(`OverallAppSignIn`)!==r)return new Promise(()=>void 0);throw e}finally{i?.()}}var zC=R({getParentRoute:()=>LC,path:`$organizationId`,errorComponent:Zb,beforeLoad:async e=>{let{organizationId:t}=e.params;if(!qc(t))throw Ne({to:`/`});return{organization:await RC(e,Yc(t))}}});R({getParentRoute:()=>zC,path:`/roles`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:Gx}),R({getParentRoute:()=>zC,path:`/roles/$orgRoleId`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:Gx}),R({getParentRoute:()=>zC,path:`/users`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:iC}),R({getParentRoute:()=>zC,path:`/users/$orgUserId`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:iC}),R({getParentRoute:()=>zC,path:`/settings`,component:IS}),Xb(zC);var BC=R({getParentRoute:()=>zC,id:`_clusterLayout`});R({getParentRoute:()=>BC,path:`/`,head:()=>({meta:[{title:`Clusters — Harper Fabric`}]}),component:fb}),R({getParentRoute:()=>zC,path:`/new-cluster`,head:()=>({meta:[{title:`New Cluster — Harper Fabric`}]}),component:lb}),R({getParentRoute:()=>WC,path:`/edit`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),beforeLoad:sm,component:lb}),R({getParentRoute:()=>WC,path:`/edit/$mode`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),beforeLoad:sm,component:lb});function VC(){return(0,K.jsx)(st,{})}function HC(){return(0,K.jsxs)(`div`,{className:`text-center py-12`,children:[(0,K.jsx)(ss,{className:`size-12 text-muted-foreground mx-auto mb-4`}),(0,K.jsx)(`h1`,{className:`text-xl font-medium mb-2 text-foreground`,children:`Pending Owner Setup`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-md mx-auto`,children:`This cluster needs an administrator to finish setup before it can be used.`})]})}function UC({error:e,reset:t}){let{organizationId:n}=z({strict:!1});return Rc(e)?(0,K.jsxs)(`div`,{className:`flex flex-col items-center mt-24`,children:[(0,K.jsx)(HC,{}),n&&(0,K.jsx)(V,{to:`/${n}`,children:(0,K.jsxs)(H,{variant:`outline`,children:[(0,K.jsx)(Hr,{}),` Back to clusters`]})})]}):(0,K.jsx)(oc,{error:e,reset:t})}var WC=R({getParentRoute:()=>BC,path:`$clusterId`,component:VC,errorComponent:UC,beforeLoad:async e=>({cluster:await RC(e,_f(e.params.clusterId))})}),GC=e=>new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e),KC=e=>`${new Intl.NumberFormat(void 0,{maximumFractionDigits:1}).format(e)} hr`,qC=e=>zy(e),JC={reads:`Reads`,readBytes:`Read data`,writes:`Writes`,writeBytes:`Write data`,realTimeMessages:`Real-time messages`,realTimeBytes:`Real-time data`,cpuTimeHours:`Compute`,storageBytes:`Storage`},YC={reads:GC,readBytes:qC,writes:GC,writeBytes:qC,realTimeMessages:GC,realTimeBytes:qC,cpuTimeHours:KC,storageBytes:qC},XC=[`reads`,`readBytes`,`writes`,`writeBytes`,`realTimeMessages`,`realTimeBytes`,`cpuTimeHours`,`storageBytes`];function ZC(e,t,n){return{label:n??JC[e],used:t.used,limit:t.limit,unlimited:t.unlimited,limitKnown:t.limitKnown,format:YC[e]}}function QC({label:e,used:t,limit:n,unlimited:r,limitKnown:i,format:a}){let o=r||n!=null&&n<0,s=i&&!o&&n!=null&&n>0,c=s?Math.min(100,Math.round(t/n*100)):0,l=c>=90;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-foreground`,children:e}),(0,K.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[(0,K.jsx)(`span`,{className:`text-foreground`,children:a(t)}),s?(0,K.jsxs)(K.Fragment,{children:[`/ `,a(n)]}):` used`]})]}),(0,K.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`h-2 flex-1 overflow-hidden rounded-full bg-muted`,children:s?(0,K.jsx)(`div`,{className:`h-full rounded-full ${l?`bg-yellow`:`bg-primary dark:bg-violet-400`}`,style:{width:`${c}%`}}):o?(0,K.jsx)(`div`,{className:`h-full w-full bg-[repeating-linear-gradient(-45deg,transparent,transparent_5px,var(--color-border)_5px,var(--color-border)_9px)] dark:bg-[repeating-linear-gradient(-45deg,transparent,transparent_5px,rgba(255,255,255,0.32)_5px,rgba(255,255,255,0.32)_9px)]`}):null}),(0,K.jsx)(`span`,{className:`w-16 shrink-0 text-right text-xs tabular-nums ${l?`text-amber-800 dark:text-yellow`:`text-muted-foreground`}`,children:s?`${c}%`:o?`Unlimited`:`—`})]})]})}function $C(e){return B({queryKey:[`clusterUsage`,e],queryFn:async()=>{let{data:t}=await P.get(`/Cluster/${e}/usage`);return t},enabled:!!e,staleTime:6e4})}function ew(e){return L($C(e))}function tw(e){let{regions:t}=e,n=t.every(e=>e.planName===t[0]?.planName)?t[0]?.planName:null,r=t.length>1?`next renewal`:`renews`;return[n?`${n} plan`:null,e.renewsAt?`${r} ${nw(e.renewsAt)}`:null].filter(Boolean).join(` · `)}function nw(e){return new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))}function rw({clusterId:e,base:t}){let{data:n}=ew(e);return!n||n.selfManaged||n.regions.length===0?null:(0,K.jsxs)(`section`,{className:`mt-6 rounded-2xl border border-border bg-card p-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Plan usage`}),(0,K.jsxs)(V,{to:`${t}/usage`,className:`inline-flex items-center gap-1 text-xs text-primary hover:underline dark:text-violet-300`,children:[`View all usage `,(0,K.jsx)(Wr,{className:`size-3`})]})]}),(0,K.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:tw(n)}),(0,K.jsx)(`div`,{className:`mt-4`,children:n.regions.length===1?(0,K.jsx)(iw,{data:n}):(0,K.jsx)(aw,{data:n})})]})}function iw({data:e}){let t=e.regions[0].metrics,n=[ZC(`reads`,t.reads),ZC(`writes`,t.writes),ZC(`storageBytes`,t.storageBytes),ZC(`cpuTimeHours`,t.cpuTimeHours)];return(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-x-8 gap-y-4 sm:grid-cols-2`,children:n.map(e=>(0,K.jsx)(QC,{...e},e.label))})}function aw({data:e}){let t=e.mostConstrained;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`p`,{className:`mb-1.5 text-xs text-muted-foreground`,children:[`Most constrained of `,e.regions.length,` regions`]}),t?(0,K.jsx)(QC,{...ZC(t.metric,{used:t.used,limit:t.limit,unlimited:!1,limitKnown:!0},`${t.region??`Region`} · ${JC[t.metric]}`)}):(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No metered limits on the current plan — see the breakdown for details.`})]})}function ow({cluster:e}){let t=Ee(),n=Ze(),{update:r,remove:i}=mg(e.organizationId,e.id),a=_g(e.organizationId),{run:o,isPending:s}=Hg(e),{mutate:c,isPending:l}=Rg(),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(null),v=e.status===`RUNNING`,y=e.status===`STOPPED`,b=e.status===`PARTIAL`,x=!a||s,S=(0,G.useCallback)(()=>{c(e.id,{onSuccess:async()=>{await n.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),h(!1),U.success(`Success`,{description:`Cluster successfully terminated.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),t.navigate({to:`/${e.organizationId}`})},onError:()=>{h(!1)}})},[e.id,e.organizationId,c,n,t]),C=(0,G.useCallback)(()=>{let e=g;_(null),e&&o(e,{safeMode:!0,strategy:`parallel`,label:e===`start`?`Starting in safe mode`:`Restarting in safe mode`})},[g,o]);return ff(e)||!r&&!i&&!a?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsxs)(H,{variant:`outline`,size:`sm`,disabled:s,className:`gap-1.5 hover:translate-y-0 data-[state=open]:[&>svg]:rotate-180`,children:[`Cluster actions`,(0,K.jsx)(er,{className:`size-4 transition-transform`})]})}),(0,K.jsxs)(vc,{align:`end`,className:`w-56`,children:[(0,K.jsxs)(Cc,{className:`text-gray-600 text-xs`,children:[`Container`,!a&&(0,K.jsx)(`span`,{className:`block font-normal`,children:`Requires an organization admin`})]}),(0,K.jsxs)(sw,{reason:a?void 0:`Only an organization administrator can start, stop, or restart this cluster.`,children:[(0,K.jsxs)(yc,{disabled:x||!(y||b),onClick:()=>void o(`start`,{safeMode:!1,strategy:`parallel`}),children:[(0,K.jsx)(Vo,{}),` Start`]}),(0,K.jsxs)(yc,{disabled:x||!y,onClick:()=>_(`start`),children:[(0,K.jsx)(Xa,{}),` Start in safe mode`]}),(0,K.jsxs)(yc,{disabled:x||!(v||b),onClick:()=>p(!0),children:[(0,K.jsx)(Zo,{}),` Restart`]}),(0,K.jsxs)(yc,{disabled:x||!v,onClick:()=>_(`restart`),children:[(0,K.jsx)(Xa,{}),` Restart in safe mode`]}),(0,K.jsxs)(yc,{variant:`destructive`,disabled:x||!(v||b),onClick:()=>d(!0),children:[(0,K.jsx)(Ss,{}),` Stop`]})]}),(0,K.jsx)(wc,{}),(0,K.jsxs)(yc,{variant:`destructive`,disabled:!i,onClick:()=>h(!0),children:[(0,K.jsx)(Is,{}),` Terminate`]})]})]}),(0,K.jsx)(Ng,{clusterName:e.name,isPending:s,stopOpen:u,setStopOpen:d,onConfirmStop:()=>{d(!1),o(`stop`,{strategy:`parallel`})},restartOpen:f,setRestartOpen:p,onConfirmRestart:e=>{p(!1),o(`restart`,{safeMode:!1,strategy:e})}}),(0,K.jsx)(Ig,{open:g!==null,setOpen:e=>{e||_(null)},action:g??`restart`,targetName:e.name,scope:`cluster`,isPending:s,onConfirm:C}),(0,K.jsx)(km,{typeOfThingBeingDeleted:`cluster`,transitiveVerb:`Terminate`,presentParticiple:`Terminating`,nameOfThingBeingDeleted:e.name,isModalOpen:m,setIsModalOpen:h,deletionConfirmed:S,deletionPending:l})]})}function sw({reason:e,children:t}){return e?(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(`div`,{role:`none`,children:t})}),(0,K.jsx)(Xl,{side:`left`,className:`max-w-60`,children:e})]}):(0,K.jsx)(K.Fragment,{children:t})}function cw(){let{clusterId:e}=z({strict:!1}),t=Ee(),r=De(),{data:i}=L(_f(e,!0)),{user:a,isLoading:o}=Tr(e),{view:s,update:l}=mg(i?.organizationId,i?.id),[f,p]=(0,G.useState)(!1),m=i?.domains?.[0]?.domain||i?.fqdn||``,[h,g]=Gg(m,m?`https://${m}`:``),_=i?`/${i.organizationId}/${i.id}`:``,v=(0,G.useCallback)(async()=>{if(i){p(!0);try{await u.establishFabricConnectAuth({id:i.id,operationsUrl:c(i)}),await t.invalidate()}catch{U.error(`Could not connect to this cluster through Fabric Connect.`)}finally{p(!1)}}},[i,t]),y=(0,G.useCallback)(()=>{i&&(u.setUserForEntity(i,null),u.flagForFabricConnect(i.id,!1)),r({to:`${_}/sign-in`})},[_,i,r]),b=(0,G.useCallback)(async()=>{if(i){try{await d({instanceClient:n({id:i.id}),entityId:i.id})}catch{}u.setUserForEntity(i,null),u.flagForFabricConnect(i.id,!1),u.flagForBasicAuth(i.id,null),await t.invalidate()}},[i,t]);if(!i)return(0,K.jsx)(uw,{children:(0,K.jsx)(dw,{})});if(!s)return(0,K.jsx)(qe,{to:`/${i.organizationId}`,replace:!0});if(Fd(i))return(0,K.jsx)(uw,{children:(0,K.jsx)(mf,{cluster:i})});if(ff(i))return(0,K.jsx)(lw,{cluster:i});if(!i.fqdn)return(0,K.jsx)(qe,{to:`${_}/instances`,replace:!0});if(i.resetPassword){if(!l)return(0,K.jsx)(uw,{children:(0,K.jsx)(HC,{})});let e=i.status&&Nd.includes(i.status)&&lf(i);return(0,K.jsx)(qe,{to:`${_}/${e?`finish-setup`:`starting-up`}`,replace:!0})}let x=u.checkForFabricConnect(i.id),S=!!a,C=u.getLastConnectMode(i.id),w=(i.instances??[]).filter(e=>e.status&&!Pd.includes(e.status)).length,T=i.instances??[],E=!!i.status&&Nd.includes(i.status)&&T.length>0&&T.every(e=>e.safeMode);return(0,K.jsxs)(uw,{children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-4 mb-6`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center size-12 rounded-xl bg-violet-50 text-primary dark:bg-grey-700 dark:text-violet-300 shrink-0`,children:(0,K.jsx)(ss,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:i.name}),(0,K.jsx)(fw,{status:i.status}),E&&(0,K.jsx)(pw,{})]}),(0,K.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,K.jsxs)(`span`,{children:[w,` `,w===1?`instance`:`instances`]}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsxs)(`a`,{href:`https://${m}`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 hover:text-foreground hover:underline`,children:[m,(0,K.jsx)(fa,{className:`size-3`})]}),(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{"aria-label":`Copy cluster URLs`,className:`rounded-md p-1 -m-1 hover:bg-accent/60 hover:text-foreground`,children:(0,K.jsx)(ea,{className:`size-3.5`})}),(0,K.jsxs)(vc,{align:`start`,children:[(0,K.jsx)(yc,{onClick:h,children:`Copy host name`}),(0,K.jsx)(yc,{onClick:g,children:`Copy API URL`})]})]})]})]}),(0,K.jsx)(ow,{cluster:i})]}),o?(0,K.jsx)(dw,{}):S?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-sm`,children:[(0,K.jsx)(Oi,{className:`size-4 text-green shrink-0`}),(0,K.jsx)(`span`,{className:`font-medium text-green`,children:x?`Connected via Fabric Connect`:`Signed in directly`}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,x?`through your Harper account`:`session cookie`]})]}),(0,K.jsxs)(V,{to:`${_}/apps`,className:`group flex items-center gap-4 rounded-2xl border-2 border-primary/30 bg-primary/5 p-6 transition-all hover:border-primary hover:bg-primary/10 dark:border-violet-400/30 dark:bg-violet-400/5 dark:hover:border-violet-400 dark:hover:bg-violet-400/10`,children:[(0,K.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-primary/10 text-primary shrink-0 dark:bg-violet-400/15 dark:text-violet-300`,children:(0,K.jsx)(qo,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-lg font-medium text-foreground`,children:`Enter cluster`}),(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Open the studio — apps, databases, APIs, logs, and config.`})]}),(0,K.jsx)(Wr,{className:`size-5 text-muted-foreground transition-transform group-hover:translate-x-1`})]}),(0,K.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-4 text-sm`,children:[x&&(0,K.jsx)(`button`,{type:`button`,onClick:y,className:`text-muted-foreground hover:text-foreground transition-colors`,children:`Switch to direct sign-in`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>void b(),className:`text-muted-foreground hover:text-destructive transition-colors`,children:x?`Disconnect`:`Direct sign out`})]})]}):(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-sm font-medium text-foreground mb-3`,children:`Connect to this cluster`}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3.5`,children:[l&&!ff(i)&&(0,K.jsx)(mw,{icon:Js,title:`Fabric Connect`,description:`Connect through your Harper account. No cluster credentials needed.`,pill:C===`fabric`?`last`:C?void 0:`recommended`,children:(0,K.jsx)(H,{className:`w-full`,disabled:f,onClick:()=>void v(),children:f?(0,K.jsx)(no,{className:`animate-spin`}):`Fabric Connect`})}),(0,K.jsx)(mw,{icon:Ha,title:`Direct sign-in`,description:`Sign in with this cluster's Harper username and password.`,pill:C===`direct`?`last`:void 0,children:(0,K.jsx)(H,{className:`w-full`,variant:`outline`,onClick:y,children:`Direct sign-in`})})]})]}),(0,K.jsx)(rw,{clusterId:i.id,base:_})]})}function lw({cluster:e}){let t=Ee(),r=De(),i=`/${e.organizationId}/${e.id}`,a=(0,G.useMemo)(()=>(e.instances??[]).filter(e=>e.status&&!Pd.includes(e.status)).sort(E_),[e.instances]),o=a.at(0),{user:s,isLoading:c}=Tr(o?.id),l=!!o&&!!s,f=(0,G.useCallback)(()=>{o&&r({to:`${i}/instance/${o.id}/sign-in`})},[i,o,r]),m=(0,G.useCallback)(async()=>{if(o){try{await d({instanceClient:n({id:o.id,operationsUrl:p(o)}),entityId:o.id})}catch{}u.setUserForEntity(o,null),u.flagForBasicAuth(o.id,null),await t.invalidate()}},[o,t]);return(0,K.jsxs)(uw,{children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-4 mb-6`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center size-12 rounded-xl bg-violet-50 text-primary dark:bg-grey-700 dark:text-violet-300 shrink-0`,children:(0,K.jsx)(ss,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:e.name}),(0,K.jsx)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full text-muted-foreground bg-muted`,children:`Self-Hosted`})]}),(0,K.jsx)(`div`,{className:`mt-1 text-sm text-muted-foreground`,children:(0,K.jsxs)(V,{to:`${i}/instances`,className:`hover:text-foreground hover:underline`,children:[a.length,` `,a.length===1?`instance`:`instances`]})})]})]}),o?c?(0,K.jsx)(dw,{}):l?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-sm`,children:[(0,K.jsx)(Oi,{className:`size-4 text-green shrink-0`}),(0,K.jsx)(`span`,{className:`font-medium text-green`,children:`Signed in directly`}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,o.name||o.instanceFqdn]})]}),(0,K.jsxs)(V,{to:`${i}/instance/${o.id}/`,className:`group flex items-center gap-4 rounded-2xl border-2 border-primary/30 bg-primary/5 p-6 transition-all hover:border-primary hover:bg-primary/10 dark:border-violet-400/30 dark:bg-violet-400/5 dark:hover:border-violet-400 dark:hover:bg-violet-400/10`,children:[(0,K.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-primary/10 text-primary shrink-0 dark:bg-violet-400/15 dark:text-violet-300`,children:(0,K.jsx)(qo,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-lg font-medium text-foreground`,children:`Enter cluster`}),(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Open the studio — apps, databases, APIs, logs, and config.`})]}),(0,K.jsx)(Wr,{className:`size-5 text-muted-foreground transition-transform group-hover:translate-x-1`})]}),(0,K.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-4 text-sm`,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>void m(),className:`text-muted-foreground hover:text-destructive transition-colors`,children:`Direct sign out`})})]}):(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-sm font-medium text-foreground mb-3`,children:`Connect to this cluster`}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3.5`,children:(0,K.jsx)(mw,{icon:Ha,title:`Direct sign-in`,description:`Sign in with this instance's Harper username and password.`,children:(0,K.jsx)(H,{className:`w-full`,variant:`outline`,onClick:f,children:`Direct sign-in`})})})]}):(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`This cluster has no instances yet. Register one from the`,` `,(0,K.jsx)(V,{to:`${i}/instances`,className:`underline hover:text-foreground`,children:`Instances`}),` page.`]})]})}function uw({children:e}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsx)(h_,{children:(0,K.jsx)(`div`,{className:`max-w-3xl`,children:e})})]})}function dw(){return(0,K.jsx)(`div`,{className:`flex justify-center py-10 text-muted-foreground`,children:(0,K.jsx)(no,{className:`size-6 animate-spin`})})}function fw({status:e}){let t=e&&Nd.includes(e)?`text-green bg-green/10`:e===`STOPPED`?`text-destructive bg-destructive/10`:e===`PARTIAL`?`text-amber-800 dark:text-yellow bg-yellow/10`:`text-muted-foreground bg-muted`;return(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full ${t}`,children:[(0,K.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e?e.charAt(0)+e.slice(1).toLowerCase():`Unknown`]})}function pw(){return(0,K.jsxs)(`span`,{title:`All instances running in safe mode — user apps/components are not loaded`,className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full text-amber-800 dark:text-yellow bg-yellow/10`,children:[(0,K.jsx)(Xa,{className:`size-3`}),`Safe mode`]})}function mw({icon:e,title:t,description:n,pill:r,children:i}){return(0,K.jsxs)(`div`,{className:`relative rounded-xl p-4.5 bg-card border ${r===`last`?`border-2 border-green`:r===`recommended`?`border-2 border-primary dark:border-violet-400`:`border-border`}`,children:[r&&(0,K.jsx)(`span`,{className:`absolute -top-2.5 left-4 rounded-full bg-card`,children:(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full ${r===`last`?`text-green bg-green/15`:`text-primary bg-violet-50 dark:text-violet-300 dark:bg-grey-700`}`,children:[r===`last`&&(0,K.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),r===`last`?`Last used`:`Recommended`]})}),(0,K.jsx)(e,{className:`size-6 text-primary dark:text-violet-300 mb-2`}),(0,K.jsx)(`div`,{className:`text-[15px] font-medium text-foreground mb-1`,children:t}),(0,K.jsx)(`p`,{className:`text-[13px] text-muted-foreground leading-normal mb-4`,children:n}),i]})}function hw({children:e,className:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsx)(h_,{children:(0,K.jsx)(`div`,{className:t,children:e})})]})}function gw(e){let t=jr(e);return t===void 0||t===408||t>=500}var _w=`Not attempted.`;function vw(e){return[...new Set(e.split(/[,\s]+/).map(e=>e.trim().toLowerCase()).filter(Boolean))]}function yw(e){let t=jr(e);return gw(e)||t===401||t===429}async function bw(e,t){let n=[],r=[];for(let i=0;i<e.length;i+=1){let a=e[i];try{await t(a),n.push(a)}catch(t){if(r.push({domain:a,message:fc(t).message,error:t,attempted:!0}),yw(t)){for(let t of e.slice(i+1))r.push({domain:t,message:_w,error:void 0,attempted:!1});break}}}return xw(r),{added:n,failures:r}}function xw(e){let t=new Set;for(let{error:n,attempted:r}of e){if(!r||jr(n)===409)continue;let e=jr(n);t.has(e)||(t.add(e),console.error(n))}}var Sw=4e3;async function Cw(e,t=Sw){let n;try{return await Promise.race([e,new Promise(e=>{n=setTimeout(()=>e(void 0),t)})])}finally{clearTimeout(n)}}function ww(e){let t=new Map;for(let n of e??[]){let e=String(n?.domain??``).toLowerCase();t.set(e,(t.get(e)??0)+1)}return t}function Tw(e,t){return e.filter(({domain:e,error:n,attempted:r})=>!r||!gw(n)||!t.has(e))}function Ew(e,t){if(!e)return new Set;let n=new Set;for(let[r,i]of t)i>(e.get(r)??0)&&n.add(r);return n}function Dw(e){return e.map(({domain:e,message:t})=>`${e} — ${t}`).join(`; `)}function Ow(e,t){return e.status===`ACTIVE`&&!e.clusterId&&!ff(t)}function kw(e,t,n){return e.filter(e=>t?.some(t=>t.id===e&&Ow(t,n)))}var Aw=new Set([`com`,`co`,`org`,`net`,`edu`,`gov`,`mil`,`me`,`biz`,`info`,`ac`,`or`,`ne`,`go`,`lg`,`asn`,`id`,`nom`,`sch`,`ltd`,`plc`]);function jw(e){let t=e.split(`.`);if(t.length<=2)return`@`;let n=t[t.length-1],r=t[t.length-2],i=n.length===2&&Aw.has(r)?3:2;return t.length<=i?`@`:t.slice(0,-i).join(`.`)}function Mw({cluster:{fqdn:e},domain:{domain:t,id:n}}){let r=jw(t),[i,a,o]=Gg(r,e||``,n);return(0,K.jsxs)(`div`,{className:`grid gap-4 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap`,children:`This domain has been verified! Now to associate it with this cluster, add the following to your DNS registrar:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordName`,value:r,onClick:i}),(0,K.jsx)(H,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:i,children:(0,K.jsx)(ea,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordTarget`,value:e,onClick:a}),(0,K.jsx)(H,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:a,children:(0,K.jsx)(ea,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`domainId`,value:n,onClick:o}),(0,K.jsx)(H,{type:`button`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:o,children:(0,K.jsx)(ea,{className:`w-3 h-3`})})]})}),(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap italic text-sm`,children:`Select this domain using the checkbox to the left, then click "Bind" in the top right to finish associating it with this cluster.`})]})}function Nw({certificate:e,domain:t,cluster:n}){let r=jw(t.domain),[i,a,o]=Gg(r,n.fqdn||``,t.id),s=(0,G.useMemo)(()=>e.issueDate&&!e.inProgress?{width:`100%`,color:`bg-green/80`,pulse:!1,text:`Certificate Issued`}:e.inProgress?{width:`100%`,color:`bg-yellow/80`,pulse:!0,text:`Generating Certificate...`}:{width:`100%`,color:`bg-gray-600`,pulse:!1,text:`Pending Certificate Generation...`},[e]);return(0,K.jsxs)(`div`,{className:`w-full max-w-2xl border border-border/50 rounded-md p-4 bg-gray-900/20`,children:[(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsx)(`div`,{className:`w-full h-1.5 rounded-full overflow-clip flex shadow-sm bg-gray-800`,children:(0,K.jsx)(`div`,{style:{width:s.width},className:`grow transition-[width] duration-1000 ease-in-out motion-reduce:transition-none ${s.color} ${s.pulse?`animate-pulse`:``}`})}),(0,K.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-light mt-1 italic`,children:s.text})]}),(0,K.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] text-sm`,children:[(0,K.jsx)(`div`,{className:`col-span-1 text-xs text-muted-foreground`,children:`CNAME:`}),(0,K.jsxs)(`div`,{className:`col-span-1 flex gap-2 items-center flex-wrap`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,K.jsx)(`span`,{className:`truncate max-w-[150px]`,title:r,children:r}),(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:i,title:`Copy Name`,children:(0,K.jsx)(ea,{className:`w-3 h-3`})})]}),(0,K.jsx)(Pw,{}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,K.jsx)(`span`,{className:`truncate max-w-[200px]`,title:n.fqdn||``,children:n.fqdn}),(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:a,title:`Copy Target`,children:(0,K.jsx)(ea,{className:`w-3 h-3`})})]})]}),(0,K.jsx)(`div`,{className:`col-span-1 text-[10px] text-muted-foreground`,children:`Domain ID:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-[10px] text-muted-foreground italic`,children:[(0,K.jsx)(`span`,{className:`truncate max-w-[200px]`,children:t.id}),(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,className:`h-3 w-3 p-0`,onClick:o,title:`Copy ID`,children:(0,K.jsx)(ea,{className:`w-2.5 h-2.5`})})]})})]})]})}function Pw(){return(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`w-3 h-3 text-muted-foreground`,children:[(0,K.jsx)(`path`,{d:`M5 12h14`}),(0,K.jsx)(`path`,{d:`m12 5 7 7-7 7`})]})}function Fw(e){let{enabled:t,entityId:n,databaseName:r,tableName:i,searchAttribute:a,sort:o,pageIndex:s,pageSize:c,onlyIfCached:l,getAttributes:u}=e;return B({enabled:t,queryKey:[n,r,i,`search_by_value`,a,o.attribute||`default`,o.descending||!1,s||0,c||0,l,u??null],retry:!1,staleTime:6e4,gcTime:5e3,queryFn:()=>Iw(e)})}async function Iw({instanceClient:e,databaseName:t,tableName:n,searchAttribute:r,sort:i,pageIndex:a,pageSize:o,onlyIfCached:s,getAttributes:c,responseType:l}){let u=i.attribute.length&&!(i.attribute===r&&!i.descending),d=await e.post(`/`,{operation:`search_by_value`,get_attributes:c??[`*`],database:t,table:n,search_attribute:r,search_value:`*`,sort:u?i:void 0,offset:a*o,limit:o,onlyIfCached:s,noCacheStore:s},{timeout:0,responseType:l,validateStatus:e=>e>=200&&e<400||e===404});return d.status===404?{data:[]}:d}var Lw=5e3,Rw=6e4,zw=18e4,Bw=new Map;function Vw(e){return!e.issueDate||e.inProgress}function Hw(e){return[e,`ChallengeCertificate`]}function Uw(e,t){return Bw.set(t,Date.now()+zw),e.invalidateQueries({queryKey:Hw(t)})}function Ww(e,t){return e&&(Bw.get(e)??0)>Date.now()||t?.some(Vw)?Lw:Rw}function Gw(e){return B({queryKey:Hw(e),queryFn:async()=>{if(!e)return[];let{data:t}=await Iw({searchAttribute:`domain`,entityId:e,databaseName:`data`,tableName:`ChallengeCertificate`,sort:{attribute:`domain`,descending:!0},instanceClient:n({id:e,forceFabricConnect:!0}),onlyIfCached:!1,pageIndex:0,pageSize:100});return t},enabled:!!e,refetchInterval:t=>Gc(Ww(e,t.state.data))(t),retry:Kc()})}function Kw(e){return L(Gw(e))}function qw({domain:{challengeToken:e,challengeTxtRecord:t,domain:n,id:r},cluster:{fqdn:i}}){let a=jw(n),[o,s,c,l,u]=Gg(t,e,a,i||``,r);return(0,K.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap`,children:`Prove that you own this domain by adding the following to your DNS registrar:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TXT`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`challengeName`,value:t,onClick:o}),(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:o,children:(0,K.jsx)(ea,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Content:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`challengeToken`,value:e,onClick:s}),(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:s,children:(0,K.jsx)(ea,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap mt-4`,children:`While you're at it, you should also add the CNAME record to point to this cluster:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordName`,value:a,onClick:c}),(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:c,children:(0,K.jsx)(ea,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordTarget`,value:i,onClick:l}),(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:l,children:(0,K.jsx)(ea,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`domainId`,value:r,onClick:u}),(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:u,children:(0,K.jsx)(ea,{className:`w-3 h-3`})})]})}),(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap mt-2`,children:`Then after your DNS TTL elapses, click the "Validate" button above.`})]})}var Jw=new Set([`PROVISIONING`,`PENDING_UPGRADE`,`DRAINING`,`UPDATING`,`UPDATED`,`CLONE_PENDING`,`CLONE_READY`,`CLONING`,`UPDATING_HDB_NODES`,`GENERATE_TOKEN`,`TOKEN_GENERATED`,`STOPPING`,`STOPPED`,`STARTING`,`RESTARTING`]);function Yw(e){if(e.status!==`RUNNING`)return{message:`This cluster is ${e.status??`not running`}. Its domains can change once it is running again.`,needsSupport:!1};for(let t of e.instances??[]){let e=t.instanceFqdn||t.id;if(t.status===`FAILED`)return{message:`Instance ${e} has failed, and this cluster's domains can't change until it is recovered.`,needsSupport:!0};if(t.status&&Jw.has(t.status))return{message:`Instance ${e} is ${t.status}. This cluster's domains can change once every instance is running.`,needsSupport:!1}}}function Xw(e,t){if(!t)return`isn't one of this organization's domains`;if(t.status!==`ACTIVE`)return`is not verified`;if(t.clusterId&&t.clusterId!==e)return`is bound to cluster ${t.clusterId}`}function Zw(e,{add:t,remove:n},r){if(ff(e))return{message:`Custom domains can't be bound to a self-managed cluster.`,needsSupport:!1};let i=new Map(r.map(e=>[e.id,e])),a=e.domainIds??[];for(let t of a){let n=Xw(e.id,i.get(t));if(n)return{message:`This cluster still lists ${i.get(t)?.domain??t}, which ${n}. Its domains can't change until that is cleared.`,needsSupport:!0}}for(let n of t){let t=a.includes(n)?void 0:Xw(e.id,i.get(n));if(t)return{message:`${i.get(n)?.domain??n} ${t}, so it can't be bound. The list has been refreshed.`,needsSupport:!1}}if(n&&!a.includes(n)){let t=i.get(n);return t?.clusterId===e.id?{message:`${t.domain} is bound to this cluster without the cluster listing it, so it can't be unbound here.`,needsSupport:!0}:{message:`${t?.domain??n} is no longer bound to this cluster. The list has been refreshed.`,needsSupport:!1}}}async function Qw(e){let{data:t}=await P.get(`/Domain/?organizationId=${e}`);return t}function $w(e){return B({queryKey:[e,`domains`],queryFn:()=>Qw(e)})}function eT(e){return[...new Set(e)]}var tT=class extends Error{needsSupport;constructor({message:e,needsSupport:t}){super(e),this.name=`DomainChangeRefusedError`,this.needsSupport=t}};async function nT(e,t,n){await P.put(`/Cluster/${e}`,{domainIds:t,generateDomainCerts:n},{timeout:0})}var rT=[`setDomainIdsOnCluster`];function iT(){let e=Ze(),t=I({mutationKey:rT,mutationFn:async({clusterId:t,organizationId:n,add:r=[],remove:i,generateDomainCerts:a})=>{let[o,s]=await Promise.all([hf(t),Qw(n)]);e.setQueryData(_f(t).queryKey,o),e.setQueryData($w(n).queryKey,s);let c=Yw(o)??Zw(o,{add:r,remove:i},s);if(c)throw new tT(c);await nT(t,eT((o.domainIds??[]).concat(r)).filter(e=>e!==i),a)},meta:{skipGlobalErrorToast:!0},onError:e=>{e instanceof tT||console.error(e)},onSuccess:(t,{clusterId:n})=>{e.invalidateQueries({queryKey:_f(n).queryKey,exact:!0}),Uw(e,n)}}),{mutate:n}=t,r=(0,G.useCallback)((t,r)=>{aT(e)||n(t,r)},[n,e]);return{...t,mutate:r}}function aT(e){return e.isMutating({mutationKey:rT})>0}function oT(){return Me({mutationKey:rT})>0}b({domainId:x(),organizationId:x()});async function sT(e){let{data:t}=await P.delete(`/Domain/${e.domainId}`);return t}var cT=[`deleteDomain`];function lT(){let e=Ze();return I({mutationKey:cT,mutationFn:e=>sT(e),onSuccess:(t,{domainId:n,organizationId:r})=>{e.setQueryData($w(r).queryKey,e=>e?.filter(e=>e.id!==n))}})}function uT(e){return e.isMutating({mutationKey:cT})>0}function dT(){return Me({mutationKey:cT})>0}var fT=Bb();function pT(e,t,n,r){let{data:i}=Kw(e.id),a=(0,G.useMemo)(()=>!!i?.some(Vw),[i]),o=oT(),{mutate:s,isPending:c}=lT(),l=o||c,u=Ze(),d=(0,G.useCallback)(t=>{aT(u)||s({domainId:t,organizationId:e.organizationId},{onSuccess:()=>{u.invalidateQueries({queryKey:[e.organizationId,`domains`],refetchType:`active`}),U.success(`Domain removed!`)}})},[u,s,e.organizationId]);return(0,G.useMemo)(()=>[fT.display({id:`select`,header:`Bind`,size:50,cell:r=>{let i=r.row.original;return Ow(i,e)?(0,K.jsx)(`label`,{className:`p-10 -m-10`,children:(0,K.jsx)(`input`,{type:`checkbox`,checked:t.includes(i.id),onChange:()=>n(i.id),disabled:l||a})}):null}}),fT.display({header:`Domains`,id:`domain`,enableSorting:!1,size:150,cell:e=>{let t=e.row.original,n=(0,K.jsx)(H,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l||!!t.clusterId,onClick:()=>d(t.id),children:`Remove Domain`});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{children:t.domain}),(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:t.clusterId?(0,K.jsx)(`div`,{className:`w-fit`,tabIndex:0,children:n}):n}),(0,K.jsx)(Xl,{side:`bottom`,align:`center`,children:t.clusterId?`To delete this domain, please unbind it from all clusters first.`:`Remember to clean up your DNS records!`})]})]})}}),fT.display({header:`Next Steps`,enableSorting:!1,size:500,id:`nextSteps`,cell:t=>{let n=t.row.original,a=i?.find(e=>e.domain===n.domain);return n.status===`ACTIVE`&&n.clusterId?e.id===n.clusterId?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{children:`Bound to this cluster`}),a&&Vw(a)&&(0,K.jsx)(`div`,{className:`py-2`,children:(0,K.jsx)(Nw,{certificate:a,domain:n,cluster:e})}),(0,K.jsx)(H,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l,onClick:()=>r(n.id),children:`Unbind Domain`})]}):`Bound to cluster ${n.clusterId}`:n.status===`PENDING_VALIDATION`?(0,K.jsx)(qw,{domain:n,cluster:e}):ff(e)?`Cannot be associated with this self-managed cluster.`:n.status===`ACTIVE`&&!n.clusterId?(0,K.jsx)(Mw,{cluster:e,domain:n}):n.status}})],[e,d,r,l,i,a,t,n])}var mT=`Enter a domain name.`,hT=b({domain:x().trim().min(1,mT),organizationId:x()});async function gT(e){let{data:t}=await P.post(`/Domain/`,e);return t}function _T(){return I({mutationFn:e=>gT(e),meta:{skipGlobalErrorToast:!0},networkMode:`always`})}async function vT(e){let{data:t}=await P.post(`/Domain/${e}/validate`);return t}function yT(e){return e instanceof tT?{message:e.message,needsSupport:e.needsSupport}:{message:`The domain change didn't go through: ${fc(e).message}`,needsSupport:!1}}function bT(){let{organizationId:e,clusterId:t}=z({strict:!1}),{data:n}=we(_f(t,!0)),{update:r}=fg(e),{data:i,refetch:a,isFetching:o,isPending:s,isRefetching:c}=L($w(e)),l=(0,G.useMemo)(()=>i?.filter(e=>e.status===`PENDING_VALIDATION`)||[],[i]),[u]=(0,G.useState)({attribute:`domain`,descending:!1}),d=(0,G.useMemo)(()=>[{desc:u.descending,id:u.attribute}],[u]),f=Kb(a),[p,m]=(0,G.useState)([]),h=(0,G.useCallback)(e=>{m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),g=(0,G.useMemo)(()=>kw(p,i,n),[n,i,p]),_=iT(),{mutate:v}=_,y=oT(),b=dT(),x=Ze(),S=(0,G.useCallback)(()=>{if(uT(x))return;let t=kw(p,x.getQueryData($w(e).queryKey),n);t.length!==0&&v({clusterId:n.id,organizationId:e,add:t,generateDomainCerts:!0},{onSuccess:()=>{x.invalidateQueries({queryKey:[n.organizationId],refetchType:`active`}),U.success(`Domain(s) bound! Certificates are being generated in the background now.`),m([])}})},[x,n,e,p,v]),C=(0,G.useCallback)(t=>{v({clusterId:n.id,organizationId:e,remove:t},{onSuccess:()=>{x.invalidateQueries({queryKey:[n.organizationId],refetchType:`active`}),U.success(`Domain unbound!`)}})},[x,n.id,n.organizationId,e,v]),w=_.error&&_.variables?.clusterId===n.id?yT(_.error):void 0,{mutateAsync:T}=_T(),E=on({resolver:mt(hT),defaultValues:{domain:``,organizationId:e}}),D=s||E.formState.isSubmitting,O=(0,G.useCallback)(async e=>{if(e.domain.length>5144){E.setError(`domain`,{type:`server`,message:`That is too much text to be domain names. Paste at most 20.`});return}let t=vw(e.domain);if(t.length===0){E.setError(`domain`,{type:`server`,message:mT});return}if(t.length>20){E.setError(`domain`,{type:`server`,message:`That is ${t.length} domains. Add at most 20 at a time.`});return}let n=i&&ww(i),{added:r,failures:o}=await bw(t,t=>T({...e,domain:t})),s=ke.isOnline()&&(r.length>0||o.some(({error:e,attempted:t})=>t&&gw(e)))?await Cw(a()):void 0,c=Tw(o,s?Ew(n,ww(s.data)):new Set),l=r.length+o.length-c.length;if(l>0&&U.success(`${oe(l,`Domain`,`Domains`)} added! Please add the txt record above to your domain registrar.`),c.length===0){E.reset();return}E.setValue(`domain`,c.map(({domain:e})=>e).join(`, `)),E.setError(`domain`,{type:`server`,message:Dw(c)})},[T,E,i,a]),k=(0,G.useCallback)(async()=>{let e=`Validating ${oe(l.length,`domain`,`domains`)}...`,t=`validatingDomains`,n=0,r=0,i=0;for(let a of l)try{U.loading(e,{description:`${n++} of ${l.length} checked`,id:t}),await vT(a.id)}catch(e){or(e)?i+=1:r+=1}i>0?(await a(),U.error(cr,{description:[ir(i),r>0&&`${oe(r,`other domain`,`other domains`)} failed to validate.`].filter(Boolean).join(` `),id:t})):r>0?U.error(`Validation failed!`,{description:`Please make sure the TXT record has been put in place. You may need to wait a bit for the DNS change to propagate.`,id:t}):(await a(),U.success(`Validation succeeded!`,{description:`Please take a look at the next steps for newly verified domains.`,id:t}))},[l]),A=pT(n,p,h,C),j=E.watch(`domain`),M=(0,G.useMemo)(()=>typeof j==`string`&&j.trim().split(`.`).length===2,[j]),ee=(0,G.useCallback)(()=>{typeof j==`string`&&E.setValue(`domain`,`${j.trim()}, www.${j.trim()}`)},[j,E]);return(0,K.jsx)(Hb,{data:i||[],isFetching:o||c,columns:A,sortingState:d,children:(0,K.jsxs)(`div`,{className:`w-full flex flex-col gap-2`,children:[(0,K.jsxs)(`div`,{className:`w-full flex flex-col md:flex-row items-center md:justify-between md:space-x-2 space-y-2 md:space-y-0`,children:[r&&(0,K.jsx)(Od,{...E,children:(0,K.jsxs)(`form`,{id:`cluster-add-domain-form`,name:`cluster-add-domain-form`,onSubmit:E.handleSubmit(O),className:`flex gap-1 flex-col md:flex-row`,children:[(0,K.jsx)(Y,{control:E.control,name:`domain`,render:({field:e})=>(0,K.jsxs)(X,{className:`flex-1`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`New Domain Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,enterKeyHint:`done`,autoComplete:`off`,disabled:D,...e})}),M&&(0,K.jsxs)(`div`,{className:`mt-1 flex gap-4`,children:[`Adding an apex domain?`,(0,K.jsx)(H,{variant:`positiveOutline`,type:`button`,disabled:D,onClick:ee,children:`Add www as well`})]}),(0,K.jsx)(Q,{children:(0,K.jsx)(`span`,{className:`text-muted-foreground italic`,children:`Type in a domain like example.com or your.example.com, and you'll be guided through validating and binding your cluster to it.`})})]})}),(0,K.jsxs)(`div`,{className:`flex-0 self-start flex gap-1 md:pt-6.5`,children:[(0,K.jsxs)(H,{type:`submit`,variant:`submit`,disabled:D,children:[(0,K.jsx)(Uo,{}),` Add`]}),l.length>0&&(0,K.jsxs)(H,{variant:`positiveOutline`,onClick:k,accessKey:`r`,type:`button`,disabled:o||c,children:[(0,K.jsx)(eo,{}),` `,(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`V`}),`alidate`]})]}),(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:f,accessKey:`r`,type:`button`,disabled:o||c,children:[(0,K.jsx)(Go,{}),` `,(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]})]})]})}),g.length>0&&(0,K.jsx)(`div`,{className:`flex-0 self-start md:pt-6.5`,children:(0,K.jsxs)(H,{variant:`submit`,onClick:S,disabled:y||b,children:[(0,K.jsx)($o,{}),` Bind `,oe(g.length,`Domain`,`Domains`)]})})]}),(0,K.jsx)(Kf,{message:w?.message,suggestSupport:w?.needsSupport})]})})}function xT(){return(0,K.jsx)(hw,{className:`flex flex-col justify-start max-w-4xl`,children:(0,K.jsx)(bT,{})})}var ST=b({username:xf,role:x().nonempty({error:`Please select a role.`}),password:yf.min(8,{error:`Password must be at least 8 characters long.`}),confirmPassword:x()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});async function CT(e){await P.patch(`/ResetPasswordUpdater/${e}`)}async function wT(e){let{instanceClient:t,...n}=e,{data:r}=await t.post(`/`,{operation:`add_user`,...n});return r}function TT(){return I({mutationFn:wT})}async function ET({username:e,password:t,role:n,active:r,instanceClient:i}){let{data:a}=await i.post(`/`,{operation:`alter_user`,username:e,password:t,role:n,active:r});return a}function DT(){return I({mutationFn:ET})}async function OT({username:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_user`,username:e});return n}function kT(){return I({mutationFn:OT})}async function AT({clusterId:e,initialUsername:t,desiredUsername:n,newPassword:r,tempPassword:a,instanceClient:o}){if(!a)throw Error(`You may not have permission to set the password on this cluster.`);let s=o;try{let o=await Yd({username:t,password:a,instanceClient:s,entityId:e});return o.instanceClient&&(s=o.instanceClient),n===`HDB_ADMIN`?await ET({username:n,password:r,instanceClient:s}):(await wT({username:n,password:r,role:`super_user`,active:!0,instanceClient:s}),o=await Yd({username:n,password:r,instanceClient:s,entityId:e}),await OT({username:i,instanceClient:s})),await CT(e),o}catch(t){throw await d({entityId:e,instanceClient:s}),t}}function jT(){return I({mutationFn:AT})}function MT(){let{user:e}=Sr(),{clusterId:t}=z({strict:!1}),{data:n}=L(_f(t,!0)),r=De(),a=Ze(),o=(0,G.useMemo)(()=>c(n),[n]),s=Ql({operationsUrl:o}),{redirect:l}=Oe({strict:!1}),d=Ee(),f=on({resolver:mt(ST),defaultValues:{confirmPassword:``,password:``,role:`super_user`,username:e?.email??``}}),{setFocus:p,control:m,handleSubmit:h}=f;(0,G.useEffect)(()=>{p(`password`)},[p]);let g=n?.instances?.find(e=>e.tempPassword)?.tempPassword,_=lf(n),{mutate:v,isPending:y}=jT(),b=(0,G.useCallback)(async e=>{if(!o){U.error(`Cluster is not yet fully loaded, please wait a moment before trying to sign in.`);return}if(!_){U.error(`Some instances are still starting up. You can create your admin user once they are all running.`);return}v({instanceClient:s,clusterId:t,newPassword:e.password,tempPassword:g,initialUsername:i,desiredUsername:e.username},{onSuccess:async({user:e})=>{U.success(`Admin user created. You're now signed in to your cluster.`),u.setUserForEntity(n,e),await gf(a,t),d.invalidate(),await r({to:l?.startsWith(`/`)?l:`../`})}})},[n,t,s,_,r,o,a,l,d,v,g]);return n&&!n.resetPassword?(0,K.jsx)(qe,{to:`../sign-in`,replace:!0}):n&&!_?(0,K.jsx)(qe,{to:`../starting-up`,replace:!0}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`studio-subnav fixed top-20 w-full h-12 z-39 px-4 md:px-12 bg-violet-50 border-b border-violet-100 dark:bg-grey-700 dark:border-none flex items-center`,children:(0,K.jsx)(Dd,{})}),(0,K.jsx)(`div`,{className:`items-center justify-center flex mt-32 py-4 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsxs)(`div`,{className:`text-foreground w-xs`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light`,children:`Create Admin User`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:`You are ready to create your first user in your new cluster. These credentials belong to you alone, and you can create more users and roles once you create this first one.`}),(0,K.jsx)(Od,{...f,children:(0,K.jsxs)(`form`,{id:`cluster-create-admin-form`,name:`cluster-create-admin-form`,onSubmit:h(b),className:`my-4`,children:[(0,K.jsx)(Y,{control:m,name:`username`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Username`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{autoComplete:`username`,type:`text`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m,name:`password`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,autoComplete:`new-password`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m,name:`confirmPassword`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Confirm Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,autoComplete:`new-password`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(H,{disabled:y,type:`submit`,variant:`submit`,className:`w-full my-2`,children:`Create Admin User`})]})}),(0,K.jsxs)(`p`,{className:`text-muted-foreground flex gap-2 align-middle`,children:[(0,K.jsx)(Ir,{size:36,className:`flex-none`}),(0,K.jsx)(`span`,{children:`These credentials will be used to sign into your cluster directly, providing you a secure connection from your browser to your cluster.`})]})]})})]})}function NT({columns:e,data:t,renderRowWrapper:n}){let r=tt({features:Lb,data:t,columns:e});return(0,K.jsx)(`div`,{className:`bg-card dark:bg-black-dark rounded-md`,children:(0,K.jsxs)(bb,{children:[(0,K.jsx)(xb,{children:r.getHeaderGroups().map(e=>(0,K.jsx)(Cb,{className:`border-none`,children:e.headers.map(e=>(0,K.jsx)(wb,{className:`p-4`,style:{width:`${e.getSize()}%`},children:e.isPlaceholder?null:ot(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,K.jsx)(Sb,{className:`bg-background dark:bg-black`,children:r.getRowModel().rows?.length?r.getRowModel().rows.map(e=>{let t=(0,K.jsx)(Cb,{"data-state":e.getIsSelected()&&`selected`,className:`hover:bg-muted/10 data-[state=selected]:bg-muted`,children:e.getVisibleCells().map(e=>(0,K.jsx)(Eb,{className:`p-4`,style:{width:`${e.column.getSize()}%`},children:ot(e.column.columnDef.cell,e.getContext())},e.id))});return(0,K.jsx)(G.Fragment,{children:n?n(e.original,t):t},e.id)}):(0,K.jsx)(Cb,{children:(0,K.jsx)(Eb,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function PT({instance:e,className:t}){let n=Vm(e);return n?!n.waiting&&(n.lastProgressAt!==void 0||n.startedAt!==void 0)?(0,K.jsx)(FT,{progress:n,className:t}):(0,K.jsx)(IT,{waiting:n.waiting,description:Wm(n,Date.now()),className:t}):null}function FT({progress:e,className:t}){let n=Rl();return(0,K.jsx)(IT,{description:Wm(e,n),className:t})}function IT({description:e,waiting:t,className:n}){let r=t?Hi:Go;return(0,K.jsxs)(`div`,{className:F(`flex items-center gap-1.5 text-xs font-light text-muted-foreground`,n),children:[(0,K.jsx)(r,{"aria-hidden":`true`,className:F(`size-3.5 shrink-0`,t?`text-muted-foreground`:`text-yellow animate-[spin_2.5s_linear_infinite] motion-reduce:animate-none`)}),(0,K.jsx)(`span`,{children:e})]})}function LT({instances:e}){let t=(e??[]).filter(e=>tf(e.status)).sort(E_);return t.length?(0,K.jsx)(`ul`,{className:`flex flex-col gap-3`,"aria-label":`Instances syncing data`,children:t.map(e=>(0,K.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-sm`,children:e.name||e.instanceFqdn}),(0,K.jsx)(PT,{instance:e})]},e.id))}):null}function RT(){return(0,K.jsx)(`div`,{className:`flex-col items-center justify-center px-16 space-y-3 text-center pt-30`,children:(0,K.jsx)(`p`,{children:`No instances found.`})})}var zT={start:!1,restart:!1,stop:!1},BT={start:!1,restart:!0,stop:!0},VT={start:!0,restart:!1,stop:!1},HT={start:!0,restart:!0,stop:!0};function UT(e){switch(e){case`RUNNING`:return BT;case`STOPPED`:return VT;case`ERROR`:case`FAILED`:return HT;default:return zT}}async function WT({instance:e,instanceClient:t}){try{await d({instanceClient:t,entityId:e.id})}catch{}u.signOutLocally(e.id),e.clusterId&&u.signOutLocally(e.clusterId)}async function GT({instanceId:e,action:t,safeMode:n}){let r=n===void 0?{}:{safeMode:n},{data:i}=await P.post(`/HDBInstance/${e}/container/${t}`,r);return i}function KT(){return I({mutationFn:GT})}var qT={stop:`Stopping`,start:`Starting`,restart:`Restarting`};function JT(e){let{clusterId:t}=z({strict:!1}),{mutateAsync:n,isPending:r}=KT(),i=Ze();return{run:(0,G.useCallback)(async(r,a)=>{let o=a?.label??qT[r],s=e.name??e.id,c=U.loading(o,{description:`${o} ${s}. Status will update shortly.`,duration:3e4,action:{label:`Dismiss`,onClick:()=>U.dismiss()}});try{await n({instanceId:e.id,action:r,safeMode:a?.safeMode}),r!==`stop`&&de({instanceIds:[e.id],label:qT[r],allAtOnce:!0}),t&&i.invalidateQueries({queryKey:[t]}),i.invalidateQueries({queryKey:[e.id]}),U.dismiss(c),U.success(`Request accepted`,{description:`${s} is ${o.toLowerCase()}. The status will update automatically.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}catch{U.dismiss(c)}},[t,e.id,e.name,n,i]),isPending:r}}var YT=`4.6.0`;function XT(e){return!!e&&vr(YT,e)}function ZT(e){return!!e&&!XT(e)&&vr(e,YT)}function QT({entityId:e,instanceClient:t},n){return B({queryKey:[`get_status`,e],staleTime:9e3,refetchInterval:Gc(1e4),retry:Kc(),retryDelay:1e4,throwOnError:!1,enabled:n,queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`get_status`});return e}})}function $T(e,t){return e?.systemStatus?.find(e=>e.id===t)?.status}async function eE({instanceClient:e,id:t,status:n}){let{data:r}=await e.post(`/`,{operation:`set_status`,id:t,status:n});return r}function tE(){return I({mutationFn:eE,onSuccess:(e,t)=>hc.invalidateQueries({queryKey:[`get_status`,t.entityId]})})}var nE=[`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`];function rE(e,t,n){let{user:r}=Tr(e.id),{organizationId:i,clusterId:a}=z({strict:!1}),o=qg({organizationId:i,clusterId:a,instanceId:e.id}),s=qg({organizationId:i,clusterId:a,instanceId:e.id},`sign-in`),c=(0,G.useMemo)(()=>p(e),[e]),l=Ql({operationsUrl:c}),{update:d}=bg(),f=_g(),m=u.checkForFabricConnect(e.id),h=q({operationsUrl:c,instanceId:e.id,forceFabricConnect:!0}),g=XT(e.version),{data:_}=L(QT(h,n&&d&&!ef(e.status)&&g)),v=$T(_,`availability`)||`Unknown`,y=v===`Available`,b=v===`Unavailable`,{mutate:x,isPending:S}=tE(),{run:C,isPending:w}=JT(e),[T,E]=(0,G.useState)(null),D=e.instanceFqdn,O=eb({secure:e.operationsApiSecure?`true`:`false`,port:e.operationsApiPort,fqdn:e.instanceFqdn}),[k,A]=Gg(D??``,O),j=(0,G.useCallback)(async()=>{await WT({instance:e,instanceClient:l})},[e,l]),M=!!e.status&&nE.includes(e.status),ee=!!r&&!m,te=M,N=!!D,P=d&&M&&g&&(y||b),F=UT(e.status),ne=f&&!t&&(F.start||F.restart||F.stop),re=[te&&ee&&{key:`direct-connect`,to:o,icon:(0,K.jsx)(ss,{className:`text-green`}),label:`Direct Connect`},te&&ee&&{key:`direct-sign-out`,onClick:j,variant:`destructive`,icon:(0,K.jsx)(uo,{}),label:`Direct Sign Out`},te&&!ee&&d&&!t&&{key:`fabric-connect`,to:o,icon:(0,K.jsx)(ss,{className:`text-green`}),label:`Fabric Connect`},te&&!ee&&{key:`direct-sign-in`,to:s,icon:(0,K.jsx)(co,{}),label:`Direct Sign In`},te&&N&&{type:`separator`,key:`copy-sep`},N&&{key:`copy-fqdn`,onClick:k,icon:(0,K.jsx)(Bi,{}),label:`Copy Instance FQDN`},N&&{key:`copy-api`,onClick:A,icon:(0,K.jsx)(Bi,{}),label:`Copy API URL`},(te||N)&&P&&{type:`separator`,key:`rotation-sep`},P&&y&&{key:`out-of-rotation`,variant:`destructive`,disabled:S,onClick:()=>x({...h,id:`availability`,status:`Unavailable`}),icon:(0,K.jsx)(ps,{}),label:`Bring out of rotation`},P&&b&&{key:`into-rotation`,disabled:S,onClick:()=>x({...h,id:`availability`,status:`Available`}),icon:(0,K.jsx)(ds,{}),label:`Bring back into rotation`},(te||N||P)&&ne&&{type:`separator`,key:`container-sep`},ne&&{type:`label`,key:`container-label`,className:`text-gray-600 text-xs`,label:`Container`},ne&&F.start&&{key:`container-start`,disabled:w,onClick:()=>void C(`start`,{safeMode:!1}),icon:(0,K.jsx)(Vo,{}),label:`Start`},ne&&F.start&&{key:`container-start-safe`,disabled:w,onClick:()=>E(`start`),icon:(0,K.jsx)(Xa,{}),label:`Start in safe mode`},ne&&F.restart&&{key:`container-restart`,disabled:w,onClick:()=>void C(`restart`,{safeMode:!1}),icon:(0,K.jsx)(Zo,{}),label:`Restart`},ne&&F.restart&&{key:`container-restart-safe`,disabled:w,onClick:()=>E(`restart`),icon:(0,K.jsx)(Xa,{}),label:`Restart in safe mode`},ne&&F.stop&&{key:`container-stop`,variant:`destructive`,disabled:w,onClick:()=>void C(`stop`),icon:(0,K.jsx)(Ss,{}),label:`Stop`}].filter(fr),ie=(0,K.jsx)(Ig,{open:T!==null,setOpen:e=>{e||E(null)},action:T??`restart`,targetName:e.name??e.id,scope:`instance`,isPending:w,onConfirm:()=>{let e=T;E(null),e&&C(e,{safeMode:!0,label:e===`start`?`Starting in safe mode`:`Restarting in safe mode`})}});return re.length?{items:[{type:`label`,key:`label`,className:`text-gray-600 text-xs`,label:`Options`},{type:`separator`,key:`label-sep`},...re],dialog:ie}:{items:[],dialog:ie}}function iE({instance:e,isSelfManaged:t}){let[n,r]=(0,G.useState)(!1),{items:i,dialog:a}=rE(e,t,n);return i.length?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(gc,{open:n,onOpenChange:r,children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Instance options`,children:(0,K.jsx)(ua,{})})}),(0,K.jsx)(vc,{align:`end`,className:`min-w-48`,children:Rm(i,`dropdown`)})]}),a]}):null}function aE({isSelfManaged:e,instance:t}){let{user:n,isLoading:r}=Tr(t.id),{organizationId:i,clusterId:a}=z({strict:!1}),o=qg({organizationId:i,clusterId:a,instanceId:t.id}),s=qg({organizationId:i,clusterId:a,instanceId:t.id},`sign-in`),c=Ql({operationsUrl:(0,G.useMemo)(()=>p(t),[t])}),{update:l}=bg(),d=u.checkForFabricConnect(t.id),f=(0,G.useCallback)(async()=>{await WT({instance:t,instanceClient:c})},[t,c]);return $d(t.status)?(0,K.jsx)(`span`,{className:`text-muted-foreground text-sm`,children:`—`}):r||!t.status||![`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`].includes(t.status)?(0,K.jsx)(no,{className:`animate-spin`,color:`gray`}):!n||d?(0,K.jsxs)(`span`,{className:`flex gap-4`,children:[l&&!e&&(0,K.jsx)(V,{to:o,className:`text-sm`,"aria-label":`Connect to ${t.name} instance`,title:`Connect to ${t.name} instance`,children:(0,K.jsx)(H,{variant:`positiveOutline`,children:`Fabric Connect`})}),(0,K.jsx)(V,{to:s,className:`text-sm`,"aria-label":`Sign in to ${t.name} instance`,title:`Sign in to ${t.name} instance`,children:(0,K.jsx)(H,{variant:l?`defaultOutline`:`positiveOutline`,children:`Direct Sign In`})})]}):(0,K.jsxs)(`span`,{className:`flex gap-4`,children:[(0,K.jsx)(V,{to:o,className:`text-sm`,"aria-label":`Go to ${t.name} instance`,title:`Go to ${t.name} instance`,children:(0,K.jsx)(H,{variant:`positiveOutline`,children:`Direct Connect`})}),(0,K.jsx)(H,{variant:`destructiveOutline`,className:`text-sm`,"aria-label":`Sign out from ${t.name} instance`,title:`Sign out from ${t.name} instance`,onClick:f,children:`Direct Sign Out`})]})}function oE({instance:e,isSelfManaged:t,children:n}){let[r,i]=(0,G.useState)(!1),{items:a,dialog:o}=rE(e,t,r);return a.length?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Am,{onOpenChange:i,children:[(0,K.jsx)(jm,{asChild:!0,children:n}),(0,K.jsx)(Mm,{className:`min-w-48`,children:Rm(a,`context`)})]}),o]}):(0,K.jsx)(K.Fragment,{children:n})}function sE(e,t=`0px`){let[n,r]=(0,G.useState)(null);return n!==null&&n.element!==e&&r(null),(0,G.useEffect)(()=>{if(!e||typeof IntersectionObserver>`u`)return;let n=new IntersectionObserver(t=>{let n=t[t.length-1];n&&r({element:e,onScreen:n.isIntersecting})},{rootMargin:t});return n.observe(e),()=>n.disconnect()},[e,t]),typeof IntersectionObserver>`u`||n!==null&&n.element===e&&n.onScreen}function cE({instance:e,index:t}){let{update:n}=bg(),r=q({operationsUrl:(0,G.useMemo)(()=>p(e),[e]),instanceId:e.id,forceFabricConnect:!0}),{mutate:i,isPending:a}=tE(),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(null),u=sE(c,`200px`);(0,G.useEffect)(()=>{let e=setTimeout(()=>s(!0),t*500);return()=>clearTimeout(e)},[t]);let d=ef(e.status),f=XT(e.version),{data:m,isLoading:h,isFetching:g}=L(QT(r,o&&u&&n&&!d&&f)),_=$T(m,`availability`)||`Unknown`,v=_===`Available`,y=_===`Unavailable`;if(!n)return null;if(d||!f){let t=`Status unavailable`;return d&&$d(e.status)?t=`Not running`:!d&&ZT(e.version)&&(t=`Status needs Harper 4.6 or later`),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(`span`,{className:`inline-block size-4 rounded-full bg-muted-foreground/40`,"aria-label":t})}),(0,K.jsx)(Xl,{children:t})]})})}return(0,K.jsxs)(`div`,{ref:l,className:`flex items-center gap-2`,children:[(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(`div`,{className:`flex items-center`,children:h||!o||(g||!u)&&!m?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(no,{className:`animate-spin size-5 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Loading status`})]}):(0,K.jsx)(ol,{variant:v?`success`:y?`destructive`:`default`,className:`size-4 rounded-full p-0`,children:(0,K.jsx)(`span`,{className:`sr-only`,children:v?`Online`:`Offline`})})})}),(0,K.jsxs)(Xl,{children:[g&&m?`Refreshing... `:``,_]})]}),n&&(0,K.jsxs)(`div`,{className:`flex gap-1`,children:[v&&(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(H,{type:`button`,variant:`destructiveGhost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Unavailable`}),disabled:a,children:a?(0,K.jsx)(no,{className:`animate-spin size-4`}):(0,K.jsx)(ps,{className:`size-4`})})}),(0,K.jsx)(Xl,{children:`Bring out of rotation`})]}),y&&(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Available`}),disabled:a,children:a?(0,K.jsx)(no,{className:`animate-spin size-4`}):(0,K.jsx)(ds,{className:`size-4`})})}),(0,K.jsx)(Xl,{children:`Bring back into rotation`})]})]})]})}function lE(){let{clusterId:e}=z({strict:!1}),{data:t,isLoading:n}=L(_f(e,!0)),r=ff(t),i=(0,G.useMemo)(()=>[{id:`instanceActions`,size:1,minSize:1,cell:e=>(0,K.jsx)(`div`,{className:`flex justify-end gap-2 items-center`,children:(0,K.jsx)(aE,{isSelfManaged:r,instance:e.row.original})})},r&&{accessorKey:`instanceFqdn`,size:90,header:`URL`,cell:e=>eb({secure:e.row.original.operationsApiSecure?`true`:`false`,port:e.row.original.operationsApiPort,fqdn:e.row.original.instanceFqdn})},!r&&{accessorKey:`name`,size:90,header:`Name`},!r&&{accessorKey:`status`,header:`Status`,size:1,minSize:1,cell:e=>{let t=e.getValue();return(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(cE,{instance:e.row.original,index:e.row.index}),t?(0,K.jsx)(ol,{variant:Qd(t),children:_d(t)}):null,e.row.original.safeMode&&!$d(e.row.original.status)?(0,K.jsxs)(ol,{variant:`warning`,title:`Running in safe mode — user apps/components are not loaded`,children:[(0,K.jsx)(Xa,{}),`Safe mode`]}):null]}),(0,K.jsx)(PT,{instance:e.row.original,className:`w-64`})]})}},!r&&{accessorKey:`version`,size:1,minSize:1,header:`Version`},!r&&{accessorKey:`storageGb`,size:1,minSize:1,header:`Storage`,cell:e=>`${e.getValue()} GB`},!r&&{accessorKey:`usedStorageGb`,size:1,minSize:1,header:`Used Storage`,cell:e=>{let t=e.getValue();return t===void 0?`-`:`${t} GB`}},!r&&{accessorKey:`cpuCores`,size:1,minSize:1,header:`Cores/Threads`,cell:e=>(0,K.jsxs)(K.Fragment,{children:[e.row.original.cpuCores,` / `,e.row.original.threads]})},!r&&{accessorKey:`memoryMb`,size:1,minSize:1,header:`Memory`,cell:e=>`${e.getValue()/1024} GB`},{id:`instanceMenu`,size:1,minSize:1,cell:e=>(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsx)(iE,{isSelfManaged:r,instance:e.row.original})})}].filter(fr),[r]),a=f_(),o=(0,G.useMemo)(()=>t?.instances?t.instances.filter(e=>e.status&&!Pd.includes(e.status)).map(e=>se(e.id)?.reach===`down`&&!$d(e.status)?{...e,status:`RESTARTING`}:e).sort(E_):[],[t,a]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsx)(h_,{children:(0,K.jsx)(Er,{className:`p-0 min-h-96`,children:(0,K.jsx)(Ar,{className:`p-0 min-h-96`,children:n?(0,K.jsx)(my,{}):o.length?(0,K.jsx)(NT,{data:o,columns:i,renderRowWrapper:(e,t)=>(0,K.jsx)(oE,{instance:e,isSelfManaged:r,children:t})}):(0,K.jsx)(RT,{})})})})]})}function uE(){let{clusterId:e}=z({strict:!1}),{immediate:t}=Oe({strict:!1}),n=t===!0||t===`true`,{data:r,isLoading:i}=L(_f(e,2e3)),a=r?.status,o=(0,G.useMemo)(()=>a&&Nd.includes(a)&&df(r),[a,r]);return i||!r?(0,K.jsx)(hw,{className:`flex justify-center`,children:(0,K.jsx)(my,{})}):af(a)?(0,K.jsx)(hw,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4 items-center`,children:[(0,K.jsx)(Wi,{className:`w-24 h-24`}),(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`Your cluster's update didn't finish`}),(0,K.jsx)(Fg,{cluster:r,forceProgressBarVisible:!0}),(0,K.jsxs)(`p`,{children:[`Some of the changes may already be applied, so check the instances. The cluster can't take another update until it's healthy again, so get in touch and we'll help get it back into a state you can update.`,` `,(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[`We also get notified about these failures. `,(0,K.jsx)(Pf,{}),` if you want more help.`]})]}),(0,K.jsx)(V,{to:`/${r.organizationId}/${r.id}/instances`,children:(0,K.jsx)(H,{type:`button`,variant:`positiveOutline`,children:`View Instances`})})]})}):o?(0,K.jsx)(hw,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`All done!`}),(0,K.jsx)(Fg,{cluster:r,forceProgressBarVisible:!0}),(0,K.jsx)(`p`,{children:`Your cluster finished updating, and is ready for interaction.`}),(0,K.jsx)(`div`,{className:`text-center`,children:(0,K.jsx)(Ag,{cluster:r})})]})}):(0,K.jsx)(hw,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,K.jsx)(Fg,{cluster:r,forceProgressBarVisible:!0}),(0,K.jsx)(LT,{instances:r.instances}),(0,K.jsxs)(`p`,{children:[n?`Your cluster is applying the latest changes immediately, without waiting to take instances out of rotation.`:`Your cluster is updating with the latest changes. This includes waiting several minutes to let traffic drain safely.`,` `,(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[`We will let you know when we are ready for you to connect! In the meantime, join us on`,` `,(0,K.jsx)(`a`,{href:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,children:`Discord`}),`! Get real-time help from our engineers, see feature drops early, and connect with others building on Fabric.`]})]})]})})}function dE({children:e,className:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cm,{}),(0,K.jsx)(`div`,{className:v(`mt-32 px-4 py-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] flex justify-center`,t),children:e})]})}function fE(){let e=Ee(),{clusterId:t}=z({strict:!1}),{data:n,isLoading:r}=L(_f(t,2e3)),i=n?.status,a=(0,G.useMemo)(()=>i&&Nd.includes(i)&&lf(n),[i,n]),o=af(i),[,s]=Zc(_r.SavedClusterState,null),c=(0,G.useCallback)(()=>{s(n),e.navigate({to:`/${n.organizationId}/new-cluster`})},[n,e,s]);return r||!n?(0,K.jsx)(dE,{className:`flex justify-center`,children:(0,K.jsx)(my,{})}):o?(0,K.jsx)(dE,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4 items-center`,children:[(0,K.jsx)(Wi,{className:`w-24 h-24`}),(0,K.jsxs)(`span`,{children:[`Your cluster failed to successfully start. This is usually caused by temporary communication problems. Would you like to try again? We also get notified about these failures. `,(0,K.jsx)(Pf,{}),` if you want more help.`]}),(0,K.jsx)(H,{type:`button`,variant:`positiveOutline`,onClick:c,children:`Try Again`})]})}):Fd(n)?(0,K.jsx)(dE,{className:`flex justify-center`,children:(0,K.jsx)(mf,{cluster:n})}):a?(0,K.jsx)(dE,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`It's ready!`}),(0,K.jsx)(Fg,{cluster:n,forceProgressBarVisible:!0}),(0,K.jsxs)(`p`,{children:[`Let's set up your secure, browser-to-cluster connection now.`,` `,(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Did you know during this step, you connect straight to your cluster, providing a private secure connection? That's `,(0,K.jsx)(`em`,{children:`Direct Connect`}),`! Once you create your user, you will have the option to`,` `,(0,K.jsx)(`em`,{children:`Fabric Connect`}),` from your Fabric account without having to sign in again.`]})]}),(0,K.jsx)(`div`,{className:`text-center`,children:(0,K.jsx)(Ag,{cluster:n})})]})}):(0,K.jsx)(dE,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,K.jsx)(Fg,{cluster:n,forceProgressBarVisible:!0}),(0,K.jsx)(LT,{instances:n.instances}),(0,K.jsxs)(`p`,{children:[`Your cluster is spinning up with the latest changes, including your own DNS records and private connections. Please wait while we get everything going.`,` `,(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[`We will let you know when we are ready for you to connect! In the meantime, join us on`,` `,(0,K.jsx)(`a`,{href:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,children:`Discord`}),`! Get real-time help from our engineers, see feature drops early, and connect with others building on Fabric.`]})]})]})})}function pE(){let{clusterId:e}=z({strict:!1}),{data:t,isLoading:n}=ew(e);if(n)return(0,K.jsxs)(hw,{className:`max-w-4xl pb-20`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:`Usage`}),(0,K.jsx)(`div`,{className:`flex justify-center py-16 text-muted-foreground`,children:(0,K.jsx)(no,{className:`size-6 animate-spin`})})]});let r=t&&!t.selfManaged?yE(t.regions):null;return(0,K.jsxs)(hw,{className:`max-w-4xl pb-20`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:`Usage`}),t?t.selfManaged?(0,K.jsx)(SE,{children:`Usage isn't tracked for self-hosted clusters — they run under their own license.`}):t.regions.length===0?(0,K.jsx)(SE,{children:`No usage has been recorded for the current cycle yet.`}):(0,K.jsxs)(`div`,{className:`mt-5 space-y-3`,children:[t.regions.map(e=>(0,K.jsx)(mE,{region:e,showPlanInfo:r==null},e.region??e.regionIds.join())),r&&(0,K.jsx)(hE,{header:(0,K.jsx)(gE,{title:`Plan limits & resources`}),aside:r.planId??void 0,children:(0,K.jsx)(_E,{rateLimits:r.rateLimits,resourcesPerInstance:r.resourcesPerInstance})})]}):(0,K.jsx)(CE,{})]})}function mE({region:e,showPlanInfo:t}){let n=XC.map(t=>ZC(t,e.metrics[t])),r=[e.planName?`${e.planName} plan`:null,e.status===`exhausted`?`consumed — awaiting renewal`:e.status===`lapsed`?`not renewed`:e.expiresAt?`renews ${vE(e.expiresAt)}`:null].filter(Boolean).join(` · `);return(0,K.jsxs)(hE,{defaultOpen:e.status!==`lapsed`,aside:e.regionIds.length>0?e.regionIds.join(`, `):void 0,header:(0,K.jsxs)(gE,{title:e.region??`Region`,meta:r,children:[e.status===`exhausted`&&(0,K.jsx)(`span`,{className:`rounded-full bg-yellow/10 px-2 py-0.5 text-[11px] text-amber-800 dark:text-yellow`,children:`Cycle exhausted`}),e.status===`lapsed`&&(0,K.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground`,children:`No active license`})]}),children:[(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-x-10 gap-y-4 sm:grid-cols-2`,children:n.map(e=>(0,K.jsx)(QC,{...e},e.label))}),t&&(0,K.jsx)(_E,{rateLimits:e.rateLimits,resourcesPerInstance:e.resourcesPerInstance})]})}function hE({header:e,aside:t,defaultOpen:n=!0,children:r}){let[i,a]=(0,G.useState)(n);return(0,K.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-border`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),"aria-expanded":i,className:`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-accent/40`,children:[(0,K.jsx)(Si,{className:`size-4 shrink-0 text-muted-foreground transition-transform ${i?`rotate-90`:``}`}),(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:e}),t&&(0,K.jsx)(`span`,{className:`shrink-0 self-start pt-0.5 font-mono text-[11px] text-muted-foreground/70`,children:t})]}),i&&(0,K.jsx)(`div`,{className:`border-t border-border px-4 py-4`,children:r})]})}function gE({title:e,meta:t,children:n}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e}),n]}),t&&(0,K.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t})]})}function _E({rateLimits:e,resourcesPerInstance:t}){let n=e,r=n?xE([[`Reads / minute`,n.readsPerMinute,By],[`Read bandwidth / minute`,n.readsPerMinuteBytes,zy],[`Writes / minute`,n.writesPerMinute,By],[`Write bandwidth / minute`,n.writesPerMinuteBytes,zy],[`Real-time deliveries / minute`,n.realTimeDeliveriesPerMinute,By],[`Real-time bandwidth / minute`,n.realTimeDeliveryBytesPerMinute,zy],[`TLS handshakes (cycle)`,n.tlsHandshakes,By]]):[],i=t,a=i?bE([[`Storage`,i.storageGb,e=>`${By(e)} GB`],[`Memory`,i.memoryMb,e=>zy(e*1e3*1e3)],[`vCPU`,i.cpuCores,e=>`${e} ${e===1?`core`:`cores`}`],[`Threads`,i.threads,e=>String(e)]]):[];return(0,K.jsxs)(K.Fragment,{children:[r.length>0&&(0,K.jsx)(wE,{title:`Rate limits`,subtitle:`Throughput ceilings — not part of the cycle allotment, and not metered.`,children:(0,K.jsx)(TE,{rows:r})}),a.length>0&&(0,K.jsx)(wE,{title:`Per-instance resources`,subtitle:`Provisioned capacity on each instance.`,children:(0,K.jsx)(TE,{rows:a})})]})}function vE(e){return new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))}function yE(e){if(e.length===0)return null;let t=e[0];if(t.rateLimits==null&&t.resourcesPerInstance==null)return null;let n=e=>JSON.stringify([e.rateLimits,e.resourcesPerInstance]),r=n(t),i=e.every(e=>e.planId===t.planId);return e.every(e=>n(e)===r)?{rateLimits:t.rateLimits,resourcesPerInstance:t.resourcesPerInstance,planId:i?t.planId:null}:null}function bE(e){return e.filter(e=>typeof e[1]==`number`&&e[1]>0).map(([e,t,n])=>[e,n(t)])}function xE(e){return e.filter(e=>e[1]!=null).map(([e,t,n])=>[e,t.unlimited?`Unlimited`:t.limitKnown&&t.limit!=null?n(t.limit):`—`])}function SE({children:e}){return(0,K.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:e})}function CE(){return(0,K.jsx)(`div`,{role:`alert`,className:`mt-5 rounded-xl border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive`,children:`Couldn't load usage data — refresh to try again.`})}function wE({title:e,subtitle:t,children:n}){return(0,K.jsxs)(`div`,{className:`mt-6 first:mt-0`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:e}),(0,K.jsx)(`p`,{className:`mt-0.5 mb-3 text-xs text-muted-foreground`,children:t}),n]})}function TE({rows:e}){return(0,K.jsx)(`dl`,{className:`grid grid-cols-1 gap-x-10 gap-y-2 sm:grid-cols-2`,children:e.map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 border-b border-border/60 py-1.5 text-sm`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,K.jsx)(`dd`,{className:`text-foreground tabular-nums`,children:t})]},e))})}R({getParentRoute:()=>WC,path:`instances`,head:()=>({meta:[{title:`Instances — Harper Fabric`}]}),beforeLoad:sm,component:lE}),R({getParentRoute:()=>WC,path:`starting-up`,head:()=>({meta:[{title:`Starting Up — Harper Fabric`}]}),component:fE}),R({getParentRoute:()=>WC,path:`scaling`,head:()=>({meta:[{title:`Scaling — Harper Fabric`}]}),beforeLoad:sm,component:uE}),R({getParentRoute:()=>WC,path:`domains`,head:()=>({meta:[{title:`Domains — Harper Fabric`}]}),beforeLoad:sm,component:xT}),R({getParentRoute:()=>WC,path:`usage`,head:()=>({meta:[{title:`Usage — Harper Fabric`}]}),component:pE});function EE({context:e,location:t,params:n}){if(Fd(e?.cluster))return;let r=u.checkForFabricConnect(n.clusterId);if(u.getConnectionById(n.clusterId).user&&!r){let e=t?.search?.redirect;throw Ne({to:e?.startsWith(`/`)?e:`../`})}}function DE({context:e,location:t,params:n}){if(Fd(e?.cluster))return;let r=u.checkForFabricConnect(n.instanceId);if(u.getConnectionById(n.instanceId).user&&!r){let e=t?.search?.redirect;throw Ne({to:e?.startsWith(`/`)?e:`../`})}}R({getParentRoute:()=>WC,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:Of,beforeLoad:EE}),R({getParentRoute:()=>WC,path:`instance/$instanceId/sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:Of,beforeLoad:DE}),R({getParentRoute:()=>WC,path:`finish-setup`,head:()=>({meta:[{title:`Create Admin User — Harper Fabric`}]}),component:MT}),R({getParentRoute:()=>WC,path:`/`,head:()=>({meta:[{title:`Cluster — Harper Fabric`}]}),component:cw});function OE(e){return R({getParentRoute:()=>e,path:`apis`,head:()=>({meta:[{title:`APIs — Harper Fabric`}]})}).lazy(()=>pe(()=>import(`./index.lazy-DQpKL_QQ.js`).then(e=>e.route),__vite__mapDeps([21,1,22,7,6,23,4,2,3,24,25,8,9,12,11,26,27,28,29])))}function kE(e,t){return[R({getParentRoute:()=>e,path:t===`cluster`?`apps`:`/`,head:()=>({meta:[{title:`Applications — Harper Fabric`}]}),component:je(()=>pe(()=>import(`./applications-DgGopKJq.js`),__vite__mapDeps([30,1,22,7,6,23,4,2,3,24,25,8,9,12,11,31,32,15,33,34,26,16,17,28,35,18,19,20,36])),`ApplicationsEditor`)})]}async function AE({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_certificates`});return t}function jE(e){return B({queryKey:[e.entityId,`list_certificates`],queryFn:()=>AE(e)})}var ME=[{header:`Certificate Name`,accessorKey:`name`,enableSorting:!0},{header:`Issuer`,accessorKey:`details.issuer`,enableSorting:!0},Bb().display({header:`Expires At`,enableSorting:!1,id:`details.valid_to`,cell:e=>e.row.original.details.valid_to?new Date(e.row.original.details.valid_to).toLocaleString():`N/A`})];function NE({className:e,...t}){return(0,K.jsx)(`textarea`,{"data-slot":`input`,className:F(`border-input file:text-foreground placeholder:text-muted-foreground selection:bg-purple
20
20
  selection:text-primary-foreground
21
21
  dark:aria-invalid:outline-destructive dark:aria-invalid:ring-destructive/50 ring-ring/10
22
22
  dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 aria-invalid:outline-destructive/60
@@ -675,7 +675,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
675
675
  }
676
676
  ]
677
677
  }
678
- `),_A=`inmemory://harper/config-root.json`,vA=`harper://schemas/config-root.json`;async function yA(){let{json:e}=await pe(async()=>{let{json:e}=await import(`./languageServices-U3mWhpRL.js`).then(e=>e.t);return{json:e}},__vite__mapDeps([35,1,16,2,17])),t=e.jsonDefaults,{schemas:n=[],...r}=t.diagnosticsOptions;n.some(e=>e.uri===vA)||t.setDiagnosticsOptions({...r,validate:!0,enableSchemaRequest:!1,schemas:[...n,{uri:vA,fileMatch:[_A],schema:gA}]})}var bA=({children:e})=>(0,K.jsx)(K.Fragment,{children:e});function xA(){let{clusterId:e,instanceId:t}=z({strict:!1}),{data:n,isLoading:r}=L(eA({clusterId:e,instanceId:t})),i=q(),{version:a}=Ce({strict:!1}),{data:o}=L(uA(i,!1));n?.cluster;let s=n?.instance,{data:c,isLoading:l}=L(HE(i)),{data:u,isLoading:d}=L(lA(i)),f=Cg(),{data:p,isLoading:m}=L(LO({...i,enabled:f})),h=(0,G.useMemo)(()=>{if(!p)return null;let e=0,t=n=>{n.mtime&&(e=Math.max(e,new Date(n.mtime).getTime())),`entries`in n&&n.entries&&n.entries.forEach(t)};return t(p),e||null},[p]),g=(0,G.useMemo)(()=>u?pA(u):null,[u]),_=Tx(),[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(``),[S,C]=(0,G.useState)(null),[w,T]=(0,G.useState)([]),{onConfigUpdate:E,isPending:D}=cA();(0,G.useEffect)(()=>{g&&!v&&(x(JSON.stringify(g,null,4)),C(null),T([]))},[g,v]);let O=(0,G.useCallback)(e=>{if(x(e||``),e)try{let t=JSON.parse(e);C(null);let n=[],r=(e,t,i=``)=>{for(let a in e){let o=i?`${i}.${a}`:a,s=e[a],c=t?.[a];fA(o,s,c)?n.push(o):typeof s==`object`&&s&&!Array.isArray(s)&&r(s,c,o)}for(let r in t){let a=i?`${i}.${r}`:r;r in e||fA(a,void 0,t[r])&&n.push(a)}};g&&r(t,g),T(n)}catch(e){C(e.message),T([])}},[u]),k=(0,G.useCallback)(()=>{yA().catch(e=>{console.error(`Failed to register the Harper config JSON Schema:`,e)})},[]),A=(0,G.useCallback)(()=>{if(!(S||w.length>0))try{let e=JSON.parse(b),t=hA(mA(g,e));E(t),y(!1)}catch(e){C(e.message)}},[b,S,E,g,w.length]);return(0,G.useMemo)(()=>[],[o,s]),(0,K.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,K.jsx)(bA,{children:(0,K.jsxs)(`dl`,{className:`grid grid-cols-1 sm:grid-cols-3`,children:[(0,K.jsx)(`div`,{className:`px-4 pb-4 sm:col-span-1 sm:px-0`,children:(0,K.jsx)(tA,{loadingRegistration:l,registrationInfo:c})}),(0,K.jsx)(`div`,{className:`px-4 pb-4 sm:col-span-1 sm:px-0`,children:(0,K.jsx)(nA,{loading:m,timestamp:h})}),(0,K.jsx)(`div`,{className:`px-4 pb-4 text-right sm:col-span-1 sm:px-0`,children:(0,K.jsx)(Qk,{targetNoun:`Instance`,instanceClient:i.instanceClient,operation:`restart`})})]})}),(0,K.jsxs)(`div`,{className:`flex-none flex items-center justify-between mb-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h3`,{className:`font-bold text-sm/6`,children:[`Instance Config `,v?`(editing)`:`(read only)`]}),!t&&!1]}),(0,K.jsx)(`div`,{className:`flex items-center gap-2 pr-4`,children:v?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(H,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>y(!1),children:[(0,K.jsx)(Ks,{className:`w-4 h-4 mr-1`}),` Cancel`]}),(0,K.jsxs)(H,{size:`sm`,disabled:!!S||w.length>0||D,onClick:A,children:[(0,K.jsx)($o,{className:`w-4 h-4 mr-1`}),` `,D?`Saving...`:`Save & Restart`]})]}):(0,K.jsxs)(H,{size:`sm`,onClick:()=>y(!0),children:[(0,K.jsx)(vs,{className:`w-4 h-4 mr-1`}),` Edit`]})})]}),S&&(0,K.jsxs)(c_,{variant:`destructive`,className:`mb-4`,children:[(0,K.jsx)(wi,{className:`h-4 w-4`}),(0,K.jsx)(l_,{children:`Invalid JSON`}),(0,K.jsx)(u_,{children:S})]}),w.length>0&&(0,K.jsxs)(c_,{variant:`destructive`,className:`mb-4`,children:[(0,K.jsx)(wi,{className:`h-4 w-4`}),(0,K.jsx)(l_,{children:`Restricted Configuration`}),(0,K.jsxs)(u_,{children:[`The following fields cannot be modified via Studio:`,(0,K.jsx)(`ul`,{className:`list-disc ml-4 mt-2`,children:w.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsx)(`code`,{children:e})},e))})]})]}),(0,K.jsx)(`div`,{className:`grow`,children:d?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(my,{className:`w-full`}),(0,K.jsx)(my,{className:`w-full`}),(0,K.jsx)(my,{className:`w-1/2`})]}):(0,K.jsx)(Dx,{className:`w-full min-h-full h-96`,path:_A,language:`json`,theme:_,onMount:k,options:{readOnly:!v,scrollBeyondLastLine:!1},value:v?b:JSON.stringify(g,null,4),onChange:O})})]})}function SA(){let e=q(),{data:t}=L(HE(e)),n=t?.version;return(0,G.useMemo)(()=>t===void 0?void 0:{supported:Th(n),band:Zm(n??``)},[t,n])}function CA(){return SA()?.supported}var wA=(0,G.createContext)(void 0);function TA({children:e}){return(0,K.jsx)(wA,{value:SA(),children:e})}var EA=Bb(),DA=[{header:`Role`,accessorKey:`role`,enableSorting:!1},EA.display({header:`ID`,id:`id`,enableSorting:!1,cell:e=>(0,K.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,title:e.row.original.id,children:e.row.original.id})}),EA.display({header:`Created`,enableSorting:!1,id:`__createdtime__`,cell:e=>Bm((Date.now()-e.row.original.__createdtime__)/1e3,e.row.original.__createdtime__)}),EA.display({header:`Updated`,id:`__updatedtime__`,enableSorting:!1,cell:e=>Bm((Date.now()-e.row.original.__updatedtime__)/1e3,e.row.original.__updatedtime__)}),EA.display({header:`Super User`,id:`super_user`,enableSorting:!1,cell:e=>e.row.original.permission.super_user?`Yes`:`No`}),EA.display({header:`Structure User`,id:`structure_user`,enableSorting:!1,cell:e=>e.row.original.permission.structure_user?`Yes`:`No`}),EA.display({header:`Operations`,id:`operations`,enableSorting:!1,cell:e=>(0,K.jsx)(OA,{permission:e.row.original.permission})})];function OA({permission:e}){let t=(0,G.useContext)(wA);if(t===void 0)return null;let n=Rh(e,t.supported);if(n===`absent`||n===`database`||n===`inert`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{"aria-hidden":!0,children:`—`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`No operation restriction`})]});if(n===`breaks-auth`)return(0,K.jsx)(`span`,{className:`text-destructive`,title:`Harper cannot expand this value; assigning the role breaks authentication instance-wide`,children:`breaks auth`});if(n===`malformed`)return(0,K.jsx)(`span`,{className:`text-destructive`,title:`Not a list of operation names`,children:`invalid`});if(Nh(e))return(0,K.jsx)(`span`,{className:`text-destructive`,title:`Harper rejects an allowlist on a super_user or cluster_user role`,children:`conflicts with role`});let r=Oh(Lh(e)??[],t.band),i=kh(r);return(0,K.jsxs)(`span`,{title:i,children:[r.length,` allowed`,(0,K.jsxs)(`span`,{className:`sr-only`,children:[`: `,i]})]})}var kA=[`read`,`insert`,`update`,`delete`],AA=[`read`,`insert`,`update`],jA=new Set([`__createdtime__`,`__updatedtime__`]),MA=new Set([...kA,`attribute_permissions`]),NA=new Set([`attribute_name`,...AA]);function PA(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function FA(e,t){return Object.hasOwn(e,t)?e[t]:void 0}function IA(e,t,n){let r=!1,i=Object.entries(e).map(([e,i])=>e===t?(r=!0,[e,n]):[e,i]);return r||i.push([t,n]),Object.fromEntries(i)}function LA(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>!t.has(e)))}function RA(e){if(!e)return null;try{let t=JSON.parse(e);return PA(t)?t:null}catch{return null}}function zA(e){return JSON.stringify(zh(e),null,2)}function BA(e,t){let n=Th(t);return Object.keys(e).filter(e=>!jh.has(e)||e===`operations`&&!n)}function VA(e){return e.primary_key??e.hash_attribute??e.attributes?.find(e=>e.is_primary_key)?.attribute}function HA(e){return(e.attributes??[]).map(e=>e.attribute)}function UA(e,t){return Object.keys(e).filter(n=>!jh.has(n)||n===`operations`&&Mh(e,n,t)!==void 0)}function WA(e,t,n){if(KA(n))return[`This Harper version uses the role format from before 2.2, which only the JSON editor supports.`];let r=[],i=Th(n);for(let t of[`super_user`,`cluster_user`])Object.hasOwn(e,t)&&typeof e[t]!=`boolean`&&r.push(`"${t}" must be true or false.`);e.super_user===!0&&e.cluster_user===!0&&r.push(`"super_user" and "cluster_user" cannot both be true.`);let a=e.structure_user;a!==void 0&&typeof a!=`boolean`&&!(Array.isArray(a)&&a.every(e=>typeof e==`string`))&&r.push(`"structure_user" must be true, false, or a list of database names.`);let o=Rh(e,i);(o===`breaks-auth`||o===`malformed`)&&r.push(`"operations" is not a list of operation names.`);for(let i of BA(t,n)){if(!Object.hasOwn(e,i))continue;let n=e[i];if(!PA(n)){r.push(`The entry for database "${i}" is not an object.`);continue}let a=FA(n,`tables`);if(a!==void 0){if(!PA(a)){r.push(`"${i}.tables" is not an object.`);continue}for(let e of Object.keys(t[i])){let t=FA(a,e);t!==void 0&&r.push(...GA(t,`${i}.${e}`))}}}return[...new Set(r)]}function GA(e,t){if(!PA(e))return[`The entry for table "${t}" is not an object.`];if(Object.hasOwn(e,`attribute_restrictions`))return[`"${t}" uses "attribute_restrictions", the role format from before Harper 2.2.`];let n=[],r=kA.filter(t=>typeof e[t]!=`boolean`);r.length&&n.push(`"${t}": ${r.join(`, `)} must each be true or false.`);let i=FA(e,`attribute_permissions`);if(i===null)return n;if(i===void 0)return n.push(`"${t}" needs an "attribute_permissions" list ([] applies the table's access to every attribute).`),n;if(!Array.isArray(i))return n.push(`"${t}.attribute_permissions" must be a list.`),n;let a=new Set;for(let e of i){if(!PA(e)||typeof e.attribute_name!=`string`){n.push(`"${t}.attribute_permissions" has an entry without an attribute_name.`);continue}let r=e.attribute_name;a.has(r)&&n.push(`"${t}.attribute_permissions" lists "${r}" more than once.`),a.add(r),AA.some(t=>typeof e[t]!=`boolean`)&&n.push(`"${t}.attribute_permissions": "${r}" needs read, insert and update set to true or false.`)}return n}function KA(e){return yr(e,`0.0.0`)>=0&&yr(e,`2.2.0`)<0}function qA(e,t,n){let r=Th(n),i=new Set(BA(t,n)),a=[],o=[];if(Array.isArray(e.structure_user))for(let t of e.structure_user)i.has(t)||a.push(`structure_user database "${t}"`);!r&&e.operations!==void 0&&!UA(e,!1).includes(`operations`)&&o.push(`"operations" (has no effect before Harper 5.0)`);for(let n of UA(e,r)){if(!i.has(n)){a.push(`database "${n}"`);continue}let r=e[n];if(!PA(r))continue;for(let e of Object.keys(r))e!==`tables`&&o.push(`"${n}.${e}"`);let s=FA(r,`tables`);if(!PA(s))continue;let c=t[n];for(let e of Object.keys(s)){let t=Object.hasOwn(c,e)?c[e]:void 0;if(!t){a.push(`table "${n}.${e}"`);continue}let r=s[e];if(!PA(r))continue;let i=`${n}.${e}`;for(let e of Object.keys(r))MA.has(e)||o.push(`"${i}.${e}"`);let l=FA(r,`attribute_permissions`);if(!Array.isArray(l))continue;let u=new Set(HA(t));for(let e of l){if(!PA(e))continue;let t=String(e.attribute_name);u.has(t)||o.push(`attribute "${i}.${t}"`);for(let n of Object.keys(e))NA.has(n)||o.push(`"${n}" on attribute "${i}.${t}"`)}}}return{notInSchema:a,notShown:o}}function JA(e,t,n){let r=Th(n),i=new Set(BA(t,n)),a=LA(e,new Set(UA(e,r).filter(e=>!i.has(e))));Array.isArray(a.structure_user)&&(a=IA(a,`structure_user`,a.structure_user.filter(e=>i.has(e))));for(let e of i){let n=FA(a,e),r=PA(n)?FA(n,`tables`):void 0;if(!PA(n)||!PA(r))continue;let i=t[e],o=new Set(Object.keys(r).filter(e=>!Object.hasOwn(i,e)));o.size&&(a=IA(a,e,IA(n,`tables`,LA(r,o))))}return a}function YA(e){return e.super_user===!0?`super_user`:e.cluster_user===!0?`cluster_user`:`standard`}function XA(e,t){let n=e;for(let e of[`super_user`,`cluster_user`])t===e?n=IA(n,e,!0):Object.hasOwn(n,e)&&(n=IA(n,e,!1));return zh(n)}function ZA(e,t){return t===!1&&!Object.hasOwn(e,`structure_user`)?e:zh(IA(e,`structure_user`,t))}function QA(e,t){let n=FA(e,t);return PA(n)?n:void 0}function $A(e,t){let n=e&&FA(e,`tables`),r=PA(n)?FA(n,t):void 0;return PA(r)?r:void 0}function ej(e,t,n){return $A(QA(e,t),n)}function tj(e){let t=e?.attribute_permissions;return Array.isArray(t)&&t.length>0}function nj(){return{read:!1,insert:!1,update:!1,delete:!1,attribute_permissions:[]}}function rj(e,t,n,r){let i=FA(e,t),a=PA(i)?i:{},o=FA(a,`tables`);return IA(e,t,IA(a,`tables`,IA(PA(o)?o:{},n,r)))}function ij(e,t,n){let r={...e,[t]:n};return!n&&t!==`delete`&&Array.isArray(e.attribute_permissions)&&(r.attribute_permissions=e.attribute_permissions.map(e=>e[t]?{...e,[t]:!1}:e)),r}function aj(e,t,n,r,i){let a=ej(e,t,n);return!a&&!i?e:rj(e,t,n,ij(a??nj(),r,i))}function oj(e,t,n,r,i){let a=FA(e,t),o=PA(a)?a:{},s=FA(o,`tables`),c=PA(s)?s:{},l=new Map;for(let a of n){let n=ej(e,t,a);(n||i)&&l.set(a,ij(n??nj(),r,i))}if(!l.size)return e;let u=Object.entries(c).map(([e,t])=>{let n=l.get(e);return l.delete(e),[e,n??t]});return u.push(...l.entries()),IA(e,t,IA(o,`tables`,Object.fromEntries(u)))}function sj(e,t,n){let r=new Map((e.attribute_permissions??[]).map(e=>[e.attribute_name,e])),i=(e,t)=>{let n=jA.has(e);return{read:t?.read===!0,insert:!n&&t?.insert===!0,update:!n&&t?.update===!0}},a={read:!1,insert:!1,update:!1};for(let[e,t]of r)if(e!==n){let n=i(e,t);for(let e of AA)a[e]||=n[e]}return t.map(e=>{let t=r.get(e),o=e===n,s=o&&!t;return{name:e,...s?a:i(e,t),isPrimaryKey:o,isTimestamp:jA.has(e),derived:s}})}function cj(e,t,n,r,i,a){let o=ej(e,t,n)??nj(),s=r?a?.length?a.map(e=>({...e,read:e.read&&o.read,insert:e.insert&&o.insert,update:e.update&&o.update})):i.map(e=>({attribute_name:e,read:o.read,insert:!jA.has(e)&&o.insert,update:!jA.has(e)&&o.update})):[];return rj(e,t,n,{...o,attribute_permissions:s})}function lj(e,t,n,r,i,a,o,s){let c=ej(e,t,n);if(!c||!Array.isArray(c.attribute_permissions))return e;let l=c.attribute_permissions,u=l.findIndex(e=>e.attribute_name===a),d;if(u>=0)d=l.map((e,t)=>t===u?{...e,[o]:s}:e);else{let e=sj(c,r,i).find(e=>e.name===a);d=[...l,{attribute_name:a,read:e?.read??!1,insert:e?.insert??!1,update:e?.update??!1,[o]:s}]}return rj(e,t,n,{...c,attribute_permissions:d,...s&&!c[o]?{[o]:!0}:{}})}function uj({...e}){return(0,K.jsx)(bn,{"data-slot":`accordion`,...e})}function dj({className:e,...t}){return(0,K.jsx)(zn,{"data-slot":`accordion-item`,className:F(`border-b last:border-b-0`,e),...t})}function fj({className:e,children:t,...n}){return(0,K.jsx)(Mn,{className:`flex`,children:(0,K.jsxs)(ln,{"data-slot":`accordion-trigger`,className:F(`focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180`,e),...n,children:[t,(0,K.jsx)(er,{className:`text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200`})]})})}function pj({className:e,children:t,...n}){return(0,K.jsx)(an,{"data-slot":`accordion-content`,className:`data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm`,...n,children:(0,K.jsx)(`div`,{className:F(`pt-0 pb-4`,e),children:t})})}function mj({className:e,...t}){return(0,K.jsx)(Vn,{"data-slot":`radio-group`,className:F(`grid gap-3`,e),...t})}function hj({className:e,...t}){return(0,K.jsx)(Ln,{"data-slot":`radio-group-item`,className:F(`border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,K.jsx)(An,{"data-slot":`radio-group-indicator`,className:`relative flex items-center justify-center`,children:(0,K.jsx)(Ii,{className:`fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2`})})})}function gj({value:e,onChange:t,version:n,allowlistRejected:r,structureUserDdl:i,disabled:a}){let o=e!==void 0,s=Dh(n),c=yh.filter(t=>!s.includes(t)&&e?.includes(t.name)),l=Eh(n),u=Zm(n),d=Qm(u),f=new Set(e??[]),p=(e??[]).filter(e=>!wh(e)),m=e?Oh(e,u):[],h=m.some(e=>Sh(e)?.su),g=(0,G.useRef)([]),_=e=>{let n=new Set(e),r=yh.map(e=>e.name).filter(e=>n.has(e)),i=[...n].filter(e=>!wh(e)).sort();t([...r,...i])},v=t=>{let n=new Set(e??[]);n.has(t)?n.delete(t):n.add(t),_(n)};return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border p-3`,children:[(0,K.jsxs)(Md,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Kx,{checked:o,onCheckedChange:n=>{n?t(g.current):(g.current=e??[],t(void 0))},disabled:a,"aria-label":`Restrict operations`}),(0,K.jsx)(`span`,{className:`font-medium`,children:`Restrict operations`})]}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o?d?`Only the operations below are allowed — anything unlisted is denied, SQL included: SQL statements need sql (or a group with it) listed here, and are then checked against table permissions as well. Listing an operation that normally requires super_user deliberately grants it to this role.`:`Only the operations below are allowed — anything unlisted is denied. Listing an operation that normally requires super_user deliberately grants it to this role. SQL statements are authorized against table permissions instead, so this list does not restrict them.`:`No operation-level restriction. Add one to limit this role to an explicit list of API operations (for example a deploy-only CI role).`}),r&&(0,K.jsx)(`p`,{className:`text-xs text-destructive`,children:`Harper does not accept an operations allowlist on a super_user or cluster_user role — the save is rejected unless the list is dropped. Clear that flag to scope this role by operation; otherwise the allowlist is removed when you save.`}),i&&o&&(d?(0,K.jsx)(_j,{scope:i,effective:m}):(0,K.jsxs)(`p`,{className:`text-xs text-warning`,children:[`This role is a structure user, so it reaches`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:Fh.join(`, `)}),i===!0?` (and create/drop database) on any database regardless of the list below.`:(0,K.jsxs)(K.Fragment,{children:[` `,`on `,(0,K.jsx)(`span`,{className:`font-mono`,children:i.join(`, `)}),` `,`regardless of the list below — and listing them here cannot reach another database.`]}),` Every other operation is still gated by the list.`]})),o&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[s.map(e=>(0,K.jsx)(vj,{group:e,checked:f.has(e.name),onToggle:v,disabled:a},e.name)),c.map(e=>(0,K.jsx)(vj,{group:e,note:`Saved on this role, but not offered for this instance's Harper version.`,checked:!0,onToggle:v,disabled:a},e.name))]}),(0,K.jsx)(xj,{grantable:l,band:u,selectedSet:f,onToggle:v,disabled:a}),p.length>0&&(0,K.jsx)(`div`,{className:`flex max-h-24 flex-wrap gap-1 overflow-y-auto`,children:p.map(e=>(0,K.jsx)(Sj,{name:e,band:u,onRemove:()=>v(e),disabled:a},e))}),m.length===0?(0,K.jsxs)(`p`,{className:`text-xs text-destructive`,children:[e?.length?`Every entry here is inert`:`Nothing selected`,` `,`— this role cannot run any Operations API call`,d?`, not even SQL${i?` or its structure-user DDL`:``}.`:`${i?`, except the DDL noted above`:``} (SQL is gated by table permissions, not this list).`]}):(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,title:kh(m),children:[`Effectively allows `,oe(m.length,`operation`,`operations`),h?`, including some that normally require super_user`:``,`.`,(0,K.jsxs)(`span`,{className:`sr-only`,children:[`: `,kh(m)]})]})]})]})}function _j({scope:e,effective:t}){let n=e===!0?[...Fh,...Ih]:Fh,r=n.filter(e=>!t.includes(e));return(0,K.jsxs)(`p`,{className:F(`text-xs`,r.length>0?`text-warning`:`text-muted-foreground`),children:[`This role is a structure user`,e===!0?``:(0,K.jsxs)(K.Fragment,{children:[` `,`on `,(0,K.jsx)(`span`,{className:`font-mono`,children:e.join(`, `)})]}),`, but on this Harper version the list below gates its DDL too: it can run`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:n.join(`, `)}),e===!0?` only when they are listed.`:` on those databases only when they are listed, and listing them cannot reach another database.`,r.length>0&&(0,K.jsxs)(K.Fragment,{children:[` `,`Not listed, so Harper refuses them: `,(0,K.jsx)(`span`,{className:`font-mono`,children:r.join(`, `)}),`.`]})]})}function vj({group:e,note:t,checked:n,onToggle:r,disabled:i}){return(0,K.jsxs)(Md,{className:`flex items-start gap-2 font-normal`,children:[(0,K.jsx)($,{type:`checkbox`,className:`mt-0.5 size-4`,checked:n,onChange:()=>r(e.name),disabled:i}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,K.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:t??e.description})]})]})}var yj=`This instance's Harper checks this operation under its internal handler name, so listing it has no effect here (HarperFast/harper#2175). Harper 5.3.0 and later grant it, as do prereleases from ${Xm}.`,bj=/^[A-Za-z][A-Za-z0-9_.:-]*$/;function xj({grantable:e,band:t,selectedSet:n,onToggle:r,disabled:i}){let[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(``),l=(0,G.useRef)(null),u=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(!a)return;let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>l.current?.focus())});return()=>{cancelAnimationFrame(t),cancelAnimationFrame(e)}},[a]);let d=s.trim(),f=d.toLowerCase(),p=f?e.filter(e=>e.name.includes(f)):e,m=D_(p,`category`),h=Sh(d),g=!h&&(wh(f)||_h.some(e=>e.name===f)),_=bj.test(d)&&!wh(d)&&!g&&!h?.nonDelegable&&!h?.aliasOf&&eh(d,t)!==`never`&&!e.some(e=>e.name===d)&&!n.has(d)?d:void 0;return(0,K.jsxs)(gc,{open:a,onOpenChange:e=>{o(e),e||c(``)},children:[(0,K.jsx)(_c,{asChild:!0,disabled:i,children:(0,K.jsxs)(H,{type:`button`,variant:`outline`,className:`w-full justify-between font-normal`,children:[(0,K.jsx)(`span`,{className:`truncate text-muted-foreground`,children:`Add operations…`}),(0,K.jsx)(er,{className:`size-4 shrink-0 opacity-60`})]})}),(0,K.jsxs)(vc,{ref:u,className:`w-(--radix-dropdown-menu-trigger-width) max-h-72 overflow-y-auto`,align:`start`,children:[(0,K.jsx)(`input`,{ref:l,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=u.current?.querySelectorAll(`[role="menuitemcheckbox"]:not([data-disabled])`);t?.length&&(e.key===`ArrowDown`?t[0]:t[t.length-1]).focus();return}e.key.length===1&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.stopPropagation()},placeholder:`Filter operations…`,"aria-label":`Filter operations`,className:`mb-1 w-full rounded-md border bg-transparent px-2 py-1 text-sm outline-none`}),gh.filter(e=>m[e]).map(e=>(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Cc,{className:`text-xs text-muted-foreground`,children:e}),m[e].map(e=>(0,K.jsxs)(bc,{checked:n.has(e.name),onCheckedChange:()=>r(e.name),onSelect:e=>e.preventDefault(),children:[(0,K.jsx)(`span`,{className:`flex-1 truncate font-mono text-xs`,children:e.name}),eh(e.name,t)===`needs-5.3`?(0,K.jsx)(ol,{variant:`outline`,title:yj,children:`needs newer Harper`}):e.su&&(0,K.jsx)(ol,{variant:`warning`,title:`Normally requires super_user; listing it grants it to this role`,children:`super_user`})]},e.name))]},e)),_&&(0,K.jsxs)(bc,{checked:!1,onCheckedChange:()=>r(_),onSelect:e=>e.preventDefault(),children:[(0,K.jsx)(Uo,{className:`size-3`}),(0,K.jsxs)(`span`,{className:`flex-1 truncate text-xs`,children:[`Grant "`,(0,K.jsx)(`span`,{className:`font-mono`,children:_}),`" `,h?`(listed for newer Harper versions — this instance may reject it)`:`(component-registered operation)`]})]}),p.length===0&&!_&&(0,K.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-muted-foreground`,children:`No matching operations`})]})]})}function Sj({name:e,band:t,onRemove:n,disabled:r}){let i=Sh(e),a=th(e,t),o=eh(e,t),s=a?`destructive`:i?.su?`warning`:i?`secondary`:`outline`,c=i?.aliasOf?`Legacy alias: Harper authorizes this operation under '${i.aliasOf}', so this entry grants nothing. Grant '${i.aliasOf}' instead.`:o===`needs-5.3`?yj:o===`never`?`This instance's Harper version never lets an operations allowlist grant this operation, so this entry has no effect; only a super_user role can run it.`:i?.nonDelegable?`Always requires an actual super_user role; listing it cannot delegate the operation to a non-super_user role.`:$m(e,t)?i?.caveat:i?.su?`Normally requires super_user; listing it grants it to this role.`:i?void 0:`Not in the built-in catalog — kept as-is (for example a component-registered operation).`;return(0,K.jsxs)(ol,{variant:s,title:c,className:`gap-1 font-mono text-xs`,children:[e,!r&&(0,K.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e}`,onClick:n,className:`ml-0.5 rounded-sm hover:text-destructive`,children:(0,K.jsx)(Ks,{className:`size-3`})})]})}var Cj={read:`Read`,insert:`Insert`,update:`Update`,delete:`Delete`};function wj({permission:e,onChange:t,instanceDatabaseMap:n,version:r,readOnly:i}){let a=YA(e),o=e.structure_user,s=Th(r),c=(0,G.useMemo)(()=>BA(n,r),[n,r]),l=(0,G.useMemo)(()=>qA(e,n,r),[e,n,r]),u=JSON.stringify(Lh(e)??null),d=(0,G.useMemo)(()=>JSON.parse(u)??void 0,[u]);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[l.notInSchema.length>0&&(0,K.jsxs)(c_,{variant:`warning`,children:[(0,K.jsx)(Rs,{}),(0,K.jsx)(l_,{children:`This role names things this instance's schema doesn't have`}),(0,K.jsxs)(u_,{children:[(0,K.jsxs)(`p`,{children:[l.notInSchema.join(`, `),`. Harper refuses to save a role that names a database or table that doesn't exist, so remove them before saving.`]}),!i&&(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`defaultOutline`,className:`mt-2`,onClick:()=>t(JA(e,n,r)),children:`Remove them`})]})]}),(0,K.jsx)(Ej,{permission:e,roleType:a,version:r,readOnly:i,onChange:t}),a===`standard`&&(0,K.jsx)(Oj,{permission:e,databaseNames:c,readOnly:i,onChange:t}),s&&(0,K.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":`Operations`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium`,children:`Operations`}),(0,K.jsx)(gj,{value:d,onChange:n=>t(Bh(e,n)),version:r,allowlistRejected:Nh(e),structureUserDdl:Ph(e),disabled:i})]}),a===`standard`&&o!==!0&&(0,K.jsx)(kj,{permission:e,instanceDatabaseMap:n,databaseNames:c,structureDatabases:Array.isArray(o)?o:[],readOnly:i,onChange:t}),l.notShown.length>0&&(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground italic`,children:[`Also kept as they are, but not shown here:`,` `,l.notShown.join(`, `),`. Use “Edit as JSON” to see or change them.`]})]})}function Tj(e,t){return Object.keys(e).some(n=>n!==t&&e[n]!==!1)}function Ej({permission:e,roleType:t,version:n,readOnly:r,onChange:i}){let a=(0,G.useId)(),o=yr(n,`0.0.0`)>=0&&yr(n,`5.0.0-0`)<0,s=t===`cluster_user`||o,c=t!==`standard`&&Tj(e,t);return(0,K.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-labelledby":`${a}-heading`,children:[(0,K.jsx)(`h3`,{id:`${a}-heading`,className:`text-sm font-medium`,children:`Role type`}),(0,K.jsxs)(mj,{value:t,onValueChange:t=>i(XA(e,t)),disabled:r,"aria-labelledby":`${a}-heading`,children:[(0,K.jsx)(Dj,{id:`${a}-standard`,value:`standard`,label:`Standard`,children:`Access comes from the database and table permissions below.`}),(0,K.jsx)(Dj,{id:`${a}-super`,value:`super_user`,label:`Super user`,children:`Bypasses per-table permissions.`}),s&&(0,K.jsx)(Dj,{id:`${a}-cluster`,value:`cluster_user`,label:`Cluster user`,children:o?`For the user that connects cluster nodes. A user with this role can list every database, table and attribute, and Harper keeps its password in a recoverable form so clustering can use it.`:`Harper 5 doesn't use this role type. Harper 4 used it for the user that connects cluster nodes.`})]}),c&&(0,K.jsxs)(`p`,{className:`text-xs text-warning`,children:[`Saving keeps only the `,(0,K.jsx)(`span`,{className:`font-mono`,children:t}),` flag: Harper rejects a`,` `,t===`super_user`?`super user`:`cluster user`,` `,`role that carries any other permission, so this role's other settings are removed.`]})]})}function Dj({id:e,value:t,label:n,children:r}){return(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(hj,{id:e,value:t,className:`mt-0.5`}),(0,K.jsxs)(Md,{htmlFor:e,className:`flex flex-col items-start gap-1 font-normal`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:n}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r})]})]})}function Oj({permission:e,databaseNames:t,readOnly:n,onChange:r}){let i=(0,G.useId)(),a=e.structure_user,o=a===!0?`all`:Array.isArray(a)?`selected`:`off`,s=Array.isArray(a)?a:[],c=(0,G.useRef)(s),l=[...t,...s.filter(e=>!t.includes(e))],u=Object.keys(e).some(e=>!jh.has(e)),d=t=>{Array.isArray(a)&&(c.current=a),r(ZA(e,t===`all`||t===`selected`&&c.current))},f=t=>{r(ZA(e,s.includes(t)?s.filter(e=>e!==t):[...s,t]))};return(0,K.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-labelledby":`${i}-heading`,children:[(0,K.jsx)(`h3`,{id:`${i}-heading`,className:`text-sm font-medium`,children:`Structure user`}),(0,K.jsxs)(mj,{value:o,onValueChange:d,disabled:n,"aria-labelledby":`${i}-heading`,children:[(0,K.jsx)(Dj,{id:`${i}-off`,value:`off`,label:`No`,children:`Creating and dropping databases, tables and attributes needs super user, or an operations list that grants it.`}),(0,K.jsx)(Dj,{id:`${i}-all`,value:`all`,label:`All databases`,children:`Can create and drop databases, tables and attributes, and can read, insert, update and delete in every table.`}),(0,K.jsx)(Dj,{id:`${i}-selected`,value:`selected`,label:`Selected databases`,children:`Can create and drop tables and attributes in the selected databases, and can read, insert, update and delete in their tables. Creating and dropping databases isn't included.`})]}),o!==`off`&&e.operations!==void 0&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The operations list below can still deny some of these.`}),o===`all`&&u&&(0,K.jsx)(`p`,{className:`text-xs text-warning`,children:`Per-table permissions don't apply to this role, so they are removed when you save.`}),o===`selected`&&(0,K.jsxs)(`div`,{className:`ml-6 flex flex-col gap-1`,children:[l.length===0&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This instance has no databases.`}),l.map(e=>(0,K.jsxs)(Md,{className:`flex items-center gap-2 font-normal`,children:[(0,K.jsx)(Nj,{checked:s.includes(e),onChange:()=>f(e),disabled:n,"aria-label":`Structure user on ${e}`}),(0,K.jsx)(`span`,{className:`font-mono text-xs`,children:e}),!t.includes(e)&&(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(not in this instance's schema)`})]},e))]})]})}function kj({permission:e,instanceDatabaseMap:t,databaseNames:n,structureDatabases:r,readOnly:i,onChange:a}){let[o,s]=(0,G.useState)(()=>[n.find(n=>Object.keys(t[n]).some(t=>{let r=ej(e,n,t);return r&&kA.some(e=>r[e]===!0)}))??n[0]].filter(e=>e!==void 0)),c=(0,G.useRef)(new Map),l=(0,G.useRef)({permission:e,onChange:a});(0,G.useLayoutEffect)(()=>{l.current={permission:e,onChange:a}},[e,a]);let u=(0,G.useCallback)(e=>{l.current.onChange(e(l.current.permission))},[]);return(0,K.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":`Table permissions`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium`,children:`Table permissions`}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`A table without a checked permission has no access. Delete always applies to whole records.`}),n.length===0&&(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This instance has no databases.`}),(0,K.jsx)(uj,{type:`multiple`,value:o,onValueChange:s,className:`rounded-md border`,children:n.map(n=>(0,K.jsx)(Aj,{databaseName:n,tables:t[n],record:QA(e,n),structureScoped:r.includes(n),readOnly:i,update:u,scopingRestore:c},n))})]})}var Aj=(0,G.memo)(function({databaseName:e,tables:t,record:n,structureScoped:r,readOnly:i,update:a,scopingRestore:o}){let s=Object.keys(t),c=s.map(e=>$A(n,e)),l=c.filter(e=>e&&kA.some(t=>e[t]===!0)).length;return(0,K.jsxs)(dj,{value:e,className:`px-3`,children:[(0,K.jsx)(fj,{className:`py-3`,children:(0,K.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,K.jsx)(`span`,{className:`font-mono`,children:e}),(0,K.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:r?`full access (structure user)`:`${l} of ${s.length} ${s.length===1?`table`:`tables`} with access`})]})}),(0,K.jsx)(pj,{children:r?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`As a structure user on this database, the role can read, insert, update and delete in every table here, so per-table permissions don't apply to it.`}):s.length===0?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No tables.`}):(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`border-b text-xs text-muted-foreground`,children:[(0,K.jsx)(`th`,{className:`py-1 pr-2 text-left font-normal`,children:`Table`}),kA.map(e=>(0,K.jsx)(`th`,{className:`px-2 py-1 text-center font-normal`,children:Cj[e]},e)),(0,K.jsx)(`th`,{className:`py-1 pl-2 text-left font-normal`,children:`Attributes`})]})}),(0,K.jsxs)(`tbody`,{children:[(0,K.jsxs)(`tr`,{className:`border-b`,children:[(0,K.jsx)(`td`,{className:`py-1 pr-2 text-xs text-muted-foreground`,children:`All tables`}),kA.map(t=>{let n=c.filter(e=>e?.[t]===!0).length;return(0,K.jsx)(`td`,{className:`px-2 py-1 text-center`,children:(0,K.jsx)(Nj,{checked:n===s.length,indeterminate:n>0&&n<s.length,disabled:i,"aria-label":`${Cj[t]} on every table in ${e}`,onChange:()=>a(r=>oj(r,e,s,t,n<s.length))})},t)}),(0,K.jsx)(`td`,{})]}),s.map((n,r)=>(0,K.jsx)(jj,{databaseName:e,tableName:n,schemaTable:t[n],entry:c[r],readOnly:i,update:a,scopingRestore:o},n))]})]})})})]})}),jj=(0,G.memo)(function({databaseName:e,tableName:t,schemaTable:n,entry:r,readOnly:i,update:a,scopingRestore:o}){let s=(0,G.useMemo)(()=>HA(n),[n]),c=VA(n),l=tj(r),[u,d]=(0,G.useState)(!1),f=`${e}.${t}`,p=l&&r?sj(r,s,c):[],m=p.filter(e=>AA.some(t=>e[t])).length,h=`${e}\u0000${t}`;return(0,K.jsxs)(G.Fragment,{children:[(0,K.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,K.jsx)(`td`,{className:`py-1 pr-2 font-mono text-xs`,children:t}),kA.map(n=>(0,K.jsx)(`td`,{className:`px-2 py-1 text-center`,children:(0,K.jsx)(Nj,{checked:r?.[n]===!0,disabled:i,"aria-label":`${Cj[n]} on ${f}`,onChange:r=>{let{checked:i}=r.target;a(r=>aj(r,e,t,n,i))}})},n)),(0,K.jsx)(`td`,{className:`py-1 pl-2`,children:(0,K.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground`,onClick:()=>d(e=>!e),"aria-expanded":u,"aria-label":`Attribute permissions for ${f}`,children:[u?(0,K.jsx)(er,{className:`size-3`}):(0,K.jsx)(Si,{className:`size-3`}),l?`${m} of ${s.length}`:`All`]})})]}),u&&(0,K.jsx)(`tr`,{className:`border-b bg-muted/30`,children:(0,K.jsx)(`td`,{colSpan:kA.length+2,className:`px-3 py-2`,children:(0,K.jsx)(Mj,{label:f,scoped:l,views:p,disabled:i||s.length===0,onScopingChanged:n=>{!n&&r?.attribute_permissions&&o.current.set(h,r.attribute_permissions),a(r=>cj(r,e,t,n,s,n?o.current.get(h):void 0))},onActionChanged:(n,r,i)=>a(a=>lj(a,e,t,s,c,n,r,i))})})})]})});function Mj({label:e,scoped:t,views:n,disabled:r,onScopingChanged:i,onActionChanged:a}){let o=(0,G.useId)(),s=n.find(e=>e.derived);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Kx,{id:o,checked:t,onCheckedChange:i,disabled:r,"aria-label":`Limit ${e} to specific attributes`}),(0,K.jsx)(Md,{htmlFor:o,className:`font-normal`,children:`Limit to specific attributes`})]}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t?`Only the access checked here applies. An attribute with nothing checked has no access, including attributes added to the table later. Computed and relationship attributes may be missing from this list; grant those in the JSON.`:`The table's read, insert and update apply to every attribute. Limiting lists only the attributes this instance's schema shows, which can leave out computed and relationship attributes, and those then have no access until granted in the JSON.`}),t&&(0,K.jsxs)(`table`,{className:`w-full max-w-md text-xs`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`text-muted-foreground`,children:[(0,K.jsx)(`th`,{className:`py-1 pr-2 text-left font-normal`,children:`Attribute`}),AA.map(e=>(0,K.jsx)(`th`,{className:`px-2 py-1 text-center font-normal`,children:Cj[e]},e))]})}),(0,K.jsx)(`tbody`,{children:n.map(t=>(0,K.jsxs)(`tr`,{children:[(0,K.jsxs)(`td`,{className:`py-0.5 pr-2 font-mono`,children:[t.name,t.isPrimaryKey&&(0,K.jsx)(`span`,{className:`ml-1 font-sans text-muted-foreground`,children:`(primary key)`})]}),AA.map(n=>{let i=t.isTimestamp&&n!==`read`;return(0,K.jsx)(`td`,{className:`px-2 py-0.5 text-center`,children:(0,K.jsx)(Nj,{checked:t[n],disabled:r||i,title:i?`Harper applies only read to this timestamp attribute.`:void 0,"aria-label":`${Cj[n]} on ${e}.${t.name}`,onChange:e=>a(t.name,n,e.target.checked)})},n)})]},t.name))})]}),t&&s&&(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`The primary key `,(0,K.jsx)(`span`,{className:`font-mono`,children:s.name}),` `,`isn't listed, so it gets whatever access any other attribute has. Changing it here sets it explicitly.`]}),t&&n.some(e=>e.isTimestamp)&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Harper applies only read to timestamp attributes.`})]})}function Nj({indeterminate:e=!1,className:t,...n}){let r=(0,G.useRef)(null);return(0,G.useLayoutEffect)(()=>{r.current&&(r.current.indeterminate=e)},[e]),(0,K.jsx)(`input`,{ref:r,type:`checkbox`,className:F(`size-4 cursor-pointer align-middle disabled:cursor-not-allowed disabled:opacity-50`,t),...n})}function Pj({kind:e,assigning:t,databaseCollision:n}){return e===`malformed`?(0,K.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`This role's `,(0,K.jsx)(`span`,{className:`font-mono`,children:`operations`}),` `,`value is not a list of operation names. Harper still gates on it: a string is read one character at a time, so every operation is denied; an array with non-string members enforces whatever it does expand to; and a falsy value makes each of this role's requests fail outright. The role cannot be saved again until it is fixed.`,` `,t?`Correct it in the role editor.`:`Correct it in the JSON below.`]}):(0,K.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`This role's `,(0,K.jsx)(`span`,{className:`font-mono`,children:`operations`}),` `,`value is not a list of operation names — most often table permissions on a database of that name, kept from an older Harper. This version cannot expand it, and `,t?`assigning this role to a user breaks authentication for every user on the instance. Pick a different role, and repair this one in the role editor first.`:(0,K.jsxs)(K.Fragment,{children:[`authentication breaks for every user on the instance as soon as a user holds this role. Remove the`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:`operations`}),` `,`key in the JSON below — that alone restores authentication.`,n&&(0,K.jsxs)(K.Fragment,{children:[` `,`Separately, and only if this instance needs allowlists at all: a database named`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:`operations`}),` `,`stops every role from using one. Retiring it means migrating its data and table grants to a differently-named database and verifying them there first — dropping it destroys whatever it holds, so treat that as a planned migration rather than part of this repair.`]})]})]})}async function Fj({instanceClient:e,skipRecordCount:t,includeComputed:n}){let{data:r}=await e.post(`/`,{operation:`describe_all`,skip_record_count:t||void 0,exact_count:!t&&void 0,include_computed:n||void 0});return r}function Ij(e){return B({queryKey:[e.entityId,`describe_all`,!!e.skipRecordCount,!!e.includeComputed],queryFn:()=>Fj(e),staleTime:6e4,gcTime:5e3,retry:!1})}function Lj(){let e=q(),t=L(Ij({...e,skipRecordCount:!0})),n=L(HE(e));return{instanceDatabaseMap:t.data,version:n.data?.version,isLoading:t.isPending||n.isPending,isError:t.isError&&!t.data||n.isError&&!n.data,retry:()=>{t.refetch(),n.refetch()}}}function Rj(e,t){if(!e)return!1;if(!t)return e.operations!==void 0&&Lh(e)===void 0;let n=Rh(e,Th(t));return n===`breaks-auth`||n===`malformed`}var zj=5;function Bj({draft:e,schema:t,readOnly:n}){let{text:r,permission:i}=e,a=Tx(),{instanceDatabaseMap:o,version:s}=t,c=!!o&&!!s,[l,u]=(0,G.useState)(),d=(0,G.useDeferredValue)(i),f=l===!0?d:i,p=(0,G.useMemo)(()=>!o||!s?[]:f?WA(f,o,s):[`The JSON is not a valid object.`],[f,o,s]),m=c&&!!f&&p.length===0;l===void 0&&c&&u(!m);let h=i&&s?Rh(i,Th(s)):`absent`,g=i?.operations;return t.isLoading&&!t.isError?(0,K.jsx)(my,{}):l===!1&&m&&i&&o&&s?(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2`,children:[(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsxs)(H,{type:`button`,variant:`defaultOutline`,size:`sm`,onClick:()=>u(!0),children:[(0,K.jsx)(Xi,{}),` Edit as JSON`]})}),(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-1`,children:(0,K.jsx)(wj,{permission:i,onChange:e.setPermission,instanceDatabaseMap:o,version:s,readOnly:n})})]}):(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t.isError?(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`The visual editor needs this instance's schema and version, which didn't load.`,(0,K.jsxs)(H,{type:`button`,variant:`defaultOutline`,size:`sm`,onClick:t.retry,children:[(0,K.jsx)(Go,{}),` Retry`]})]}):p.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{children:`The visual editor can't show this role until the JSON is fixed:`}),(0,K.jsxs)(`ul`,{className:`list-disc pl-4`,children:[p.slice(0,zj).map(e=>(0,K.jsx)(`li`,{children:e},e)),p.length>zj&&(0,K.jsxs)(`li`,{children:[`…and `,p.length-zj,` more.`]})]})]})}),c&&(0,K.jsxs)(H,{type:`button`,variant:`defaultOutline`,size:`sm`,className:`shrink-0`,disabled:!m,onClick:()=>u(!1),children:[(0,K.jsx)(Es,{}),` Visual editor`]})]}),(h===`breaks-auth`||h===`malformed`)&&(0,K.jsx)(Pj,{kind:h,databaseCollision:typeof g==`object`&&!!g&&!Array.isArray(g)}),(0,K.jsx)(`div`,{className:`min-h-64 flex-1`,children:(0,K.jsx)(Dx,{className:`h-full w-full`,theme:a,defaultLanguage:`json`,value:r,options:{readOnly:n,automaticLayout:!0},onChange:t=>e.setText(t??``)})})]})}function Vj(e){let[t,n]=(0,G.useState)(()=>Hj(e)),r=(0,G.useCallback)(e=>n({text:e,permission:RA(e)}),[]),i=(0,G.useCallback)(e=>n(Hj(e)),[]);return{...t,setText:r,setPermission:i}}function Hj(e){return{text:zA(e),permission:zh(e)}}function Uj(e){if(e.super_user!==!0&&e.structure_user!==!0&&e.cluster_user!==!0)return Wj(e);let t=Nh(e),n={...e};for(let e in n)(!jh.has(e)||e===`operations`&&(t||!Array.isArray(n.operations))||e===`structure_user`&&t||n[e]===!1)&&delete n[e];return n}function Wj(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Gj(t)]))}function Gj(e){if(typeof e!=`object`||!e||Array.isArray(e))return e;let{tables:t}=e;return typeof t!=`object`||!t||Array.isArray(t)?e:{...e,tables:Object.fromEntries(Object.entries(t).map(([e,t])=>[e,typeof t==`object`&&t&&`attribute_permissions`in t&&t.attribute_permissions===null?{...t,attribute_permissions:[]}:t]))}}async function Kj({role:e,permission:t,instanceClient:n}){let{data:r}=await n.post(`/`,{operation:`add_role`,role:e,permission:t});return r}function qj(){return I({mutationFn:Kj})}var Jj=b({role:x().nonempty({error:`Please enter a role.`}).regex(/^[a-zA-Z_]*$/,{error:`Role must contain only letters and underscores.`}).max(30,{error:`Role cannot be longer than 30 characters.`})}),Yj={super_user:!1,structure_user:!1};function Xj({onChangesSaved:e,closeModal:t}){let n=on({resolver:mt(Jj),defaultValues:{role:``}}),r=q(),i=Lj(),{mutate:a,isPending:o}=qj(),s=Vj(Yj),{permission:c}=s,l=Rj(c,i.version),u=(0,G.useCallback)(t=>{c&&!l&&a({role:t.role,permission:Uj(c),...r},{onSuccess:()=>{U.success(`Role added successfully!`),e()}})},[a,r,e,l,c]);return(0,K.jsx)(_m,{onOpenChange:t,open:!0,children:(0,K.jsx)(wm,{resizable:!0,"aria-describedby":void 0,children:(0,K.jsx)(Od,{...n,children:(0,K.jsxs)(`form`,{id:`instance-add-role-form`,name:`instance-add-role-form`,onSubmit:n.handleSubmit(u),className:`flex min-h-0 flex-1 flex-col gap-4`,children:[(0,K.jsxs)(Tm,{children:[(0,K.jsx)(Dm,{children:`Add New Role`}),(0,K.jsx)(Om,{children:`Name the role and choose what it can access.`})]}),(0,K.jsx)(Y,{control:n.control,name:`role`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,K.jsx)(cy,{type:`text`,maxLength:Jj.shape.role.maxLength,...e}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Bj,{draft:s,schema:i}),(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(H,{variant:`destructiveOutline`,type:`button`,onClick:t,disabled:o,children:`Cancel`}),(0,K.jsxs)(H,{type:`submit`,variant:`submit`,disabled:o||!c||l,children:[(0,K.jsx)($o,{}),` Add Role`]})]})})]})})})})}function Zj({entityId:e,instanceClient:t}){return B({queryKey:[e,`list_roles`],queryFn:()=>Qj({instanceClient:t}),refetchInterval:Gc(1e4),retry:Kc()})}async function Qj({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_roles`});return t}async function $j({id:e,permission:t,instanceClient:n}){let{data:r}=await n.post(`/`,{operation:`alter_role`,id:e,permission:t});return r}function eM(){return I({mutationFn:$j})}async function tM({id:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_role`,id:e});return n}function nM(){return I({mutationFn:tM})}function rM({data:e,instanceId:t,clusterId:n,isModalOpen:r,closeModal:i,onSelectRole:a,onChangesSaved:o}){let{role:s}=e,c=q(),l=Lj(),u=Tr(t??n).user?.role?.id===e.id,d=Vj(e.permission),{permission:f}=d,[p,m]=(0,G.useState)(e.__updatedtime__),h=e.__updatedtime__!==p,{mutate:g,isPending:_}=eM(),{mutate:v,isPending:y}=nM(),[b,x]=(0,G.useState)(!1),S=Rj(f,l.version),C=(0,G.useCallback)(()=>{!f||S||h||g({id:e.id,permission:Uj(f),...c},{onSuccess:()=>{U.success(`Role updated successfully!`),a(void 0),o()}})},[g,h,e.id,c,o,a,S,f]),{setPermission:w}=d,[T,E]=(0,G.useState)(0),D=(0,G.useCallback)(()=>{w(e.permission),E(e=>e+1),m(e.__updatedtime__)},[e.__updatedtime__,e.permission,w]),O=(0,G.useCallback)(()=>m(e.__updatedtime__),[e.__updatedtime__]),k=(0,G.useCallback)(()=>{v({id:e.id,...c},{onSuccess:()=>{U.success(`Role deleted successfully!`),a(void 0),o()}})},[e.id,v,c,o,a]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(_m,{onOpenChange:i,open:r,children:(0,K.jsxs)(wm,{resizable:!0,children:[(0,K.jsxs)(Dm,{children:[u?`View`:`Edit`,` Role "`,s,`"`]}),(0,K.jsx)(Om,{children:u?`You can view your own role, but you cannot edit it. Please assign yourself a different role to edit this role.`:`Choose what this role can access, or remove the role entirely.`}),h&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-warning`,role:`status`,children:[(0,K.jsx)(`span`,{children:`This role was changed somewhere else after you opened it. Load that version, or keep yours to replace it when you save.`}),(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`defaultOutline`,onClick:D,children:`Load the latest version`}),!u&&(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`defaultOutline`,onClick:O,children:`Keep my changes`})]}),(0,K.jsx)(Bj,{draft:d,schema:l,readOnly:u},T),(0,K.jsx)(Em,{children:!u&&(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(H,{type:`button`,variant:`destructiveOutline`,onClick:()=>x(!0),disabled:_,children:`Delete Role`}),(0,K.jsx)(H,{variant:`submit`,onClick:C,disabled:_||!f||S||h,children:`Save Changes`})]})})]})}),(0,K.jsx)(km,{isModalOpen:b,setIsModalOpen:x,deletionConfirmed:k,deletionPending:y,typeOfThingBeingDeleted:`role`,nameOfThingBeingDeleted:s,hideDataLossWarning:!0})]})}function iM(){let e=De(),{clusterId:t,instanceId:n,roleId:r}=z({strict:!1}),i=q(),{data:a,refetch:o,isFetching:s,isRefetching:c}=we(Zj(i)),l=(0,G.useMemo)(()=>a?.find(e=>e.id===r),[a,r]),u=(0,G.useCallback)(t=>{let n=[r?`..`:``,t].filter(Boolean);e({to:n.join(`/`)})},[r,e]),d=!!r&&!!l,[f,p]=(0,G.useState)(!1),m=(0,G.useCallback)(()=>{p(!0)},[p]),h=(0,G.useCallback)(()=>{o(),p(!1)},[o]),g=(0,G.useCallback)(()=>{p(!1)},[]),_=(0,G.useCallback)(e=>{u(e.original.id)},[u]),v=(0,G.useCallback)(()=>{u(void 0)},[u]),y=Kb(o);return(0,K.jsxs)(G.Suspense,{fallback:(0,K.jsx)(Lc,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,K.jsx)(TA,{children:(0,K.jsxs)(Hb,{columns:DA,data:a,isFetching:s,onRowClick:_,children:[(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:y,accessKey:`r`,disabled:s||c,children:[(0,K.jsx)(Go,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),(0,K.jsxs)(H,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:f,children:[(0,K.jsx)(Uo,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]})}),f&&(0,K.jsx)(Xj,{onChangesSaved:h,closeModal:g}),d&&(0,K.jsx)(rM,{instanceId:n,clusterId:t,isModalOpen:d,closeModal:v,data:l,onSelectRole:u,onChangesSaved:()=>o()},l.id)]})}function aM(e){return!!e?.entries}function oM(e){if(!e?.entries)return[];let t=new Set;for(let n of e.entries)aM(n)&&t.add(n.name);return[...t].sort((e,t)=>e.localeCompare(t))}function sM({components:e,granted:t,onAdd:n,disabled:r,actionLabel:i=`Add`,commitOnBlur:a=!1}){let[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(0),[f,p]=(0,G.useState)(!1),m=(0,G.useId)(),h=(0,G.useId)(),g=(0,G.useRef)(!1),_=(0,G.useRef)(!1),v=r||f,y=(0,G.useMemo)(()=>{if(e.length===0)return[];let n=o.trim(),r=n.toLowerCase(),i=new Set(t),a=e.filter(e=>!i.has(e)),s=(n?a.filter(e=>e.toLowerCase().includes(r)):a).map(e=>({value:e,custom:!1})),c=a.some(e=>e.toLowerCase()===r);return n&&!c&&s.push({value:n,custom:!0}),s},[e,t,o]),b=y.length===0?0:Math.min(u,y.length-1),x=(0,G.useCallback)(async e=>{if(_.current)return;let r=e.trim();if(!r||t.includes(r)){s(``);return}_.current=!0,p(!0);try{await n(r),s(``),l(!1)}catch{}finally{_.current=!1,p(!1)}},[t,n]),S=(0,G.useCallback)(()=>{x(y[b]?.value??o)},[x,y,b,o]),C=(0,G.useCallback)(e=>{if(e.key===`ArrowDown`){e.preventDefault(),l(!0),d(Math.min(b+1,Math.max(0,y.length-1)));return}if(e.key===`ArrowUp`){e.preventDefault(),d(Math.max(0,b-1));return}if(e.key===`Escape`){c&&(e.preventDefault(),e.stopPropagation(),l(!1));return}e.key===`Enter`&&(e.preventDefault(),S())},[c,y,b,S]),w=(0,G.useCallback)(()=>{g.current||(l(!1),a&&o.trim()&&S())},[a,o,S]),T=c&&y.length>0;return(0,K.jsxs)(`div`,{className:`relative grid gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{type:`text`,role:`combobox`,"aria-expanded":T,"aria-controls":T?m:void 0,"aria-autocomplete":`list`,"aria-activedescendant":T&&y[b]?`${h}-${b}`:void 0,autoComplete:`off`,autoCapitalize:`off`,placeholder:e.length>0?`Search applications…`:`application name`,value:o,onChange:e=>{s(e.target.value),d(0),l(!0)},onFocus:()=>l(!0),onKeyDown:C,onBlur:w,disabled:v}),(0,K.jsxs)(H,{type:`button`,variant:`positiveOutline`,onMouseDown:e=>e.preventDefault(),onClick:S,disabled:v||!o.trim(),children:[(0,K.jsx)(Uo,{}),` `,i]})]}),T&&(0,K.jsx)(`ul`,{id:m,role:`listbox`,className:`bg-popover text-popover-foreground absolute top-11 z-10 max-h-56 w-full overflow-auto rounded-md border p-1 shadow-md`,children:y.map((e,t)=>{let n=t===b;return(0,K.jsx)(`li`,{id:`${h}-${t}`,role:`option`,"aria-selected":n,onMouseEnter:()=>d(t),onMouseDown:t=>{t.preventDefault(),g.current=!0,x(e.value).finally(()=>{g.current=!1})},className:F(`flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-sm`,n&&`bg-accent text-accent-foreground`),children:e.custom?(0,K.jsxs)(`span`,{className:`truncate`,children:[`Use “`,(0,K.jsx)(`span`,{className:`font-mono`,children:e.value}),`” — not a deployed application`]}):(0,K.jsx)(`span`,{className:`truncate font-mono`,children:e.value})},e.custom?`__custom__${e.value}`:e.value)})})]})}var cM=`enc:v1:`;function lM(e){let t=e.replace(/-----BEGIN [^-]+-----/,``).replace(/-----END [^-]+-----/,``).replace(/\s+/g,``),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}function uM(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function dM(e){return uM(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function fM(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function pM(){if(typeof crypto>`u`||!crypto.subtle)throw Error(`Secret encryption requires a secure context (HTTPS or localhost).`);return crypto.subtle}async function mM(e,t,n){let r=pM(),i=lM(t),a=await r.importKey(`spki`,fM(i),{name:`RSA-OAEP`,hash:`SHA-256`},!1,[`encrypt`]),o=crypto.getRandomValues(new Uint8Array(32)),s=crypto.getRandomValues(new Uint8Array(12)),c=await r.importKey(`raw`,fM(o),{name:`AES-GCM`},!1,[`encrypt`]),l=new Uint8Array(await r.encrypt({name:`AES-GCM`,iv:fM(s),tagLength:128},c,fM(new TextEncoder().encode(e)))),u=l.slice(0,l.length-16),d=l.slice(l.length-16),f={kid:n,k:uM(new Uint8Array(await r.encrypt({name:`RSA-OAEP`},a,fM(o)))),iv:uM(s),ct:uM(u),tag:uM(d)};return cM+dM(new TextEncoder().encode(JSON.stringify(f)))}var hM=class extends Error{constructor(e){super(e),this.name=`SecretsOperationError`}};function gM(e){if(or(e))return e;let t=e?.response?.data,n=typeof t?.error==`string`?t.error:t?.message;return typeof n==`string`?new hM(n):e}var _M=`does not match`;function vM(e){return e.includes(_M)}async function yM({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`get_secrets_public_key`});return{publicKey:t.public_key,fingerprint:t.fingerprint}}var bM=P;async function xM(e){let{data:t}=await bM.post(`/ClusterSecrets`,{operation:`get_secrets_public_key`,clusterId:e});return{publicKey:t.publicKey,fingerprint:t.fingerprint}}function SM(e){return B({queryKey:[e.entityId,`get_secrets_public_key`,e.managedClusterId??`node`],queryFn:()=>e.managedClusterId?xM(e.managedClusterId):yM(e),staleTime:3e5,retry:!1})}async function CM({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_secrets`});return t}function wM(e){return B({queryKey:[e.entityId,`list_secrets`],queryFn:()=>CM(e)})}async function TM(e,t,n){let{publicKey:r,fingerprint:i}=await e.ensureQueryData(SM(t)),a=await mM(t.value,r,i);try{let{data:e}=await t.instanceClient.post(`/`,{operation:`set_secret`,name:t.name,envelope:a,...t.processEnv===void 0?{}:{processEnv:t.processEnv},...t.grants===void 0?{}:{grants:t.grants}});return e}catch(r){let i=gM(r);if(!n&&i instanceof hM&&vM(i.message))return e.removeQueries({queryKey:SM(t).queryKey}),TM(e,t,!0);throw i}}function EM(){let e=Ze();return I({mutationFn:t=>TM(e,t,!1)})}async function DM({instanceClient:e,name:t}){try{let{data:n}=await e.post(`/`,{operation:`delete_secret`,name:t});return n}catch(e){throw gM(e)}}function OM(){return I({mutationFn:DM})}async function kM(e,{instanceClient:t,name:n,component:r}){try{let{data:i}=await t.post(`/`,{operation:e,name:n,component:r});return i}catch(e){throw gM(e)}}function AM(){return I({mutationFn:e=>kM(`grant_secret`,e)})}function jM(){return I({mutationFn:e=>kM(`revoke_secret`,e)})}function MM({name:e,initialGrants:t,components:n,onChanged:r}){let i=q(),{mutateAsync:a,isPending:o}=AM(),{mutateAsync:s,isPending:c}=jM(),l=o||c,[u,d]=(0,G.useState)(t),f=(0,G.useCallback)(async t=>{try{let n=await a({...i,name:e,component:t});d(n.grants),r?.()}catch(e){throw pc(e)&&U.error(fc(e).message),e}},[a,i,e,r]),p=(0,G.useCallback)(async t=>{try{let n=await s({...i,name:e,component:t});d(n.grants),r?.()}catch(e){pc(e)&&U.error(fc(e).message)}},[s,i,e,r]);return(0,K.jsxs)(`div`,{className:`grid gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium`,children:`Granted applications`}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Only granted applications can read this secret through the `,(0,K.jsx)(`code`,{className:`font-mono`,children:`secrets`}),` `,`accessor. Changes apply immediately.`]}),u.length>0&&(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:u.map(e=>(0,K.jsxs)(ol,{variant:`secondary`,children:[e,(0,K.jsxs)(`button`,{type:`button`,onClick:()=>void p(e),disabled:l,title:`Revoke ${e}`,className:`cursor-pointer disabled:cursor-default`,children:[(0,K.jsx)(Ks,{}),(0,K.jsxs)(`span`,{className:`sr-only`,children:[`Revoke `,e]})]})]},e))}),(0,K.jsx)(sM,{components:n,granted:u,onAdd:f,disabled:l,actionLabel:`Grant`})]})}var NM=`********`,PM=/^[\w.-]+$/,FM=/^(\s*(?:export\s+)?)([\w.-]+)\s*=(.*)$/;function IM(e){return e.split(`/`).pop()??``}function LM(e){if(!e)return!1;let t=IM(e).toLowerCase();return t===`.env`||t.startsWith(`.env.`)}var RM=[`.example`,`.sample`,`.template`];function zM(e){if(!LM(e))return!1;let t=IM(e).toLowerCase();return RM.some(e=>t.endsWith(e))}function BM(e){return LM(e)&&!zM(e)}function VM(e){let t={};if(!e)return t;let n=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm,r=e.replace(/\r\n?/g,`
678
+ `),_A=`inmemory://harper/config-root.json`,vA=`harper://schemas/config-root.json`;async function yA(){let{json:e}=await pe(async()=>{let{json:e}=await import(`./languageServices-Ca72n4Ql.js`).then(e=>e.t);return{json:e}},__vite__mapDeps([35,1,16,2,17])),t=e.jsonDefaults,{schemas:n=[],...r}=t.diagnosticsOptions;n.some(e=>e.uri===vA)||t.setDiagnosticsOptions({...r,validate:!0,enableSchemaRequest:!1,schemas:[...n,{uri:vA,fileMatch:[_A],schema:gA}]})}var bA=({children:e})=>(0,K.jsx)(K.Fragment,{children:e});function xA(){let{clusterId:e,instanceId:t}=z({strict:!1}),{data:n,isLoading:r}=L(eA({clusterId:e,instanceId:t})),i=q(),{version:a}=Ce({strict:!1}),{data:o}=L(uA(i,!1));n?.cluster;let s=n?.instance,{data:c,isLoading:l}=L(HE(i)),{data:u,isLoading:d}=L(lA(i)),f=Cg(),{data:p,isLoading:m}=L(LO({...i,enabled:f})),h=(0,G.useMemo)(()=>{if(!p)return null;let e=0,t=n=>{n.mtime&&(e=Math.max(e,new Date(n.mtime).getTime())),`entries`in n&&n.entries&&n.entries.forEach(t)};return t(p),e||null},[p]),g=(0,G.useMemo)(()=>u?pA(u):null,[u]),_=Tx(),[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(``),[S,C]=(0,G.useState)(null),[w,T]=(0,G.useState)([]),{onConfigUpdate:E,isPending:D}=cA();(0,G.useEffect)(()=>{g&&!v&&(x(JSON.stringify(g,null,4)),C(null),T([]))},[g,v]);let O=(0,G.useCallback)(e=>{if(x(e||``),e)try{let t=JSON.parse(e);C(null);let n=[],r=(e,t,i=``)=>{for(let a in e){let o=i?`${i}.${a}`:a,s=e[a],c=t?.[a];fA(o,s,c)?n.push(o):typeof s==`object`&&s&&!Array.isArray(s)&&r(s,c,o)}for(let r in t){let a=i?`${i}.${r}`:r;r in e||fA(a,void 0,t[r])&&n.push(a)}};g&&r(t,g),T(n)}catch(e){C(e.message),T([])}},[u]),k=(0,G.useCallback)(()=>{yA().catch(e=>{console.error(`Failed to register the Harper config JSON Schema:`,e)})},[]),A=(0,G.useCallback)(()=>{if(!(S||w.length>0))try{let e=JSON.parse(b),t=hA(mA(g,e));E(t),y(!1)}catch(e){C(e.message)}},[b,S,E,g,w.length]);return(0,G.useMemo)(()=>[],[o,s]),(0,K.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,K.jsx)(bA,{children:(0,K.jsxs)(`dl`,{className:`grid grid-cols-1 sm:grid-cols-3`,children:[(0,K.jsx)(`div`,{className:`px-4 pb-4 sm:col-span-1 sm:px-0`,children:(0,K.jsx)(tA,{loadingRegistration:l,registrationInfo:c})}),(0,K.jsx)(`div`,{className:`px-4 pb-4 sm:col-span-1 sm:px-0`,children:(0,K.jsx)(nA,{loading:m,timestamp:h})}),(0,K.jsx)(`div`,{className:`px-4 pb-4 text-right sm:col-span-1 sm:px-0`,children:(0,K.jsx)(Qk,{targetNoun:`Instance`,instanceClient:i.instanceClient,operation:`restart`})})]})}),(0,K.jsxs)(`div`,{className:`flex-none flex items-center justify-between mb-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h3`,{className:`font-bold text-sm/6`,children:[`Instance Config `,v?`(editing)`:`(read only)`]}),!t&&!1]}),(0,K.jsx)(`div`,{className:`flex items-center gap-2 pr-4`,children:v?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(H,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>y(!1),children:[(0,K.jsx)(Ks,{className:`w-4 h-4 mr-1`}),` Cancel`]}),(0,K.jsxs)(H,{size:`sm`,disabled:!!S||w.length>0||D,onClick:A,children:[(0,K.jsx)($o,{className:`w-4 h-4 mr-1`}),` `,D?`Saving...`:`Save & Restart`]})]}):(0,K.jsxs)(H,{size:`sm`,onClick:()=>y(!0),children:[(0,K.jsx)(vs,{className:`w-4 h-4 mr-1`}),` Edit`]})})]}),S&&(0,K.jsxs)(c_,{variant:`destructive`,className:`mb-4`,children:[(0,K.jsx)(wi,{className:`h-4 w-4`}),(0,K.jsx)(l_,{children:`Invalid JSON`}),(0,K.jsx)(u_,{children:S})]}),w.length>0&&(0,K.jsxs)(c_,{variant:`destructive`,className:`mb-4`,children:[(0,K.jsx)(wi,{className:`h-4 w-4`}),(0,K.jsx)(l_,{children:`Restricted Configuration`}),(0,K.jsxs)(u_,{children:[`The following fields cannot be modified via Studio:`,(0,K.jsx)(`ul`,{className:`list-disc ml-4 mt-2`,children:w.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsx)(`code`,{children:e})},e))})]})]}),(0,K.jsx)(`div`,{className:`grow`,children:d?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(my,{className:`w-full`}),(0,K.jsx)(my,{className:`w-full`}),(0,K.jsx)(my,{className:`w-1/2`})]}):(0,K.jsx)(Dx,{className:`w-full min-h-full h-96`,path:_A,language:`json`,theme:_,onMount:k,options:{readOnly:!v,scrollBeyondLastLine:!1},value:v?b:JSON.stringify(g,null,4),onChange:O})})]})}function SA(){let e=q(),{data:t}=L(HE(e)),n=t?.version;return(0,G.useMemo)(()=>t===void 0?void 0:{supported:Th(n),band:Zm(n??``)},[t,n])}function CA(){return SA()?.supported}var wA=(0,G.createContext)(void 0);function TA({children:e}){return(0,K.jsx)(wA,{value:SA(),children:e})}var EA=Bb(),DA=[{header:`Role`,accessorKey:`role`,enableSorting:!1},EA.display({header:`ID`,id:`id`,enableSorting:!1,cell:e=>(0,K.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,title:e.row.original.id,children:e.row.original.id})}),EA.display({header:`Created`,enableSorting:!1,id:`__createdtime__`,cell:e=>Bm((Date.now()-e.row.original.__createdtime__)/1e3,e.row.original.__createdtime__)}),EA.display({header:`Updated`,id:`__updatedtime__`,enableSorting:!1,cell:e=>Bm((Date.now()-e.row.original.__updatedtime__)/1e3,e.row.original.__updatedtime__)}),EA.display({header:`Super User`,id:`super_user`,enableSorting:!1,cell:e=>e.row.original.permission.super_user?`Yes`:`No`}),EA.display({header:`Structure User`,id:`structure_user`,enableSorting:!1,cell:e=>e.row.original.permission.structure_user?`Yes`:`No`}),EA.display({header:`Operations`,id:`operations`,enableSorting:!1,cell:e=>(0,K.jsx)(OA,{permission:e.row.original.permission})})];function OA({permission:e}){let t=(0,G.useContext)(wA);if(t===void 0)return null;let n=Rh(e,t.supported);if(n===`absent`||n===`database`||n===`inert`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{"aria-hidden":!0,children:`—`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`No operation restriction`})]});if(n===`breaks-auth`)return(0,K.jsx)(`span`,{className:`text-destructive`,title:`Harper cannot expand this value; assigning the role breaks authentication instance-wide`,children:`breaks auth`});if(n===`malformed`)return(0,K.jsx)(`span`,{className:`text-destructive`,title:`Not a list of operation names`,children:`invalid`});if(Nh(e))return(0,K.jsx)(`span`,{className:`text-destructive`,title:`Harper rejects an allowlist on a super_user or cluster_user role`,children:`conflicts with role`});let r=Oh(Lh(e)??[],t.band),i=kh(r);return(0,K.jsxs)(`span`,{title:i,children:[r.length,` allowed`,(0,K.jsxs)(`span`,{className:`sr-only`,children:[`: `,i]})]})}var kA=[`read`,`insert`,`update`,`delete`],AA=[`read`,`insert`,`update`],jA=new Set([`__createdtime__`,`__updatedtime__`]),MA=new Set([...kA,`attribute_permissions`]),NA=new Set([`attribute_name`,...AA]);function PA(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function FA(e,t){return Object.hasOwn(e,t)?e[t]:void 0}function IA(e,t,n){let r=!1,i=Object.entries(e).map(([e,i])=>e===t?(r=!0,[e,n]):[e,i]);return r||i.push([t,n]),Object.fromEntries(i)}function LA(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>!t.has(e)))}function RA(e){if(!e)return null;try{let t=JSON.parse(e);return PA(t)?t:null}catch{return null}}function zA(e){return JSON.stringify(zh(e),null,2)}function BA(e,t){let n=Th(t);return Object.keys(e).filter(e=>!jh.has(e)||e===`operations`&&!n)}function VA(e){return e.primary_key??e.hash_attribute??e.attributes?.find(e=>e.is_primary_key)?.attribute}function HA(e){return(e.attributes??[]).map(e=>e.attribute)}function UA(e,t){return Object.keys(e).filter(n=>!jh.has(n)||n===`operations`&&Mh(e,n,t)!==void 0)}function WA(e,t,n){if(KA(n))return[`This Harper version uses the role format from before 2.2, which only the JSON editor supports.`];let r=[],i=Th(n);for(let t of[`super_user`,`cluster_user`])Object.hasOwn(e,t)&&typeof e[t]!=`boolean`&&r.push(`"${t}" must be true or false.`);e.super_user===!0&&e.cluster_user===!0&&r.push(`"super_user" and "cluster_user" cannot both be true.`);let a=e.structure_user;a!==void 0&&typeof a!=`boolean`&&!(Array.isArray(a)&&a.every(e=>typeof e==`string`))&&r.push(`"structure_user" must be true, false, or a list of database names.`);let o=Rh(e,i);(o===`breaks-auth`||o===`malformed`)&&r.push(`"operations" is not a list of operation names.`);for(let i of BA(t,n)){if(!Object.hasOwn(e,i))continue;let n=e[i];if(!PA(n)){r.push(`The entry for database "${i}" is not an object.`);continue}let a=FA(n,`tables`);if(a!==void 0){if(!PA(a)){r.push(`"${i}.tables" is not an object.`);continue}for(let e of Object.keys(t[i])){let t=FA(a,e);t!==void 0&&r.push(...GA(t,`${i}.${e}`))}}}return[...new Set(r)]}function GA(e,t){if(!PA(e))return[`The entry for table "${t}" is not an object.`];if(Object.hasOwn(e,`attribute_restrictions`))return[`"${t}" uses "attribute_restrictions", the role format from before Harper 2.2.`];let n=[],r=kA.filter(t=>typeof e[t]!=`boolean`);r.length&&n.push(`"${t}": ${r.join(`, `)} must each be true or false.`);let i=FA(e,`attribute_permissions`);if(i===null)return n;if(i===void 0)return n.push(`"${t}" needs an "attribute_permissions" list ([] applies the table's access to every attribute).`),n;if(!Array.isArray(i))return n.push(`"${t}.attribute_permissions" must be a list.`),n;let a=new Set;for(let e of i){if(!PA(e)||typeof e.attribute_name!=`string`){n.push(`"${t}.attribute_permissions" has an entry without an attribute_name.`);continue}let r=e.attribute_name;a.has(r)&&n.push(`"${t}.attribute_permissions" lists "${r}" more than once.`),a.add(r),AA.some(t=>typeof e[t]!=`boolean`)&&n.push(`"${t}.attribute_permissions": "${r}" needs read, insert and update set to true or false.`)}return n}function KA(e){return yr(e,`0.0.0`)>=0&&yr(e,`2.2.0`)<0}function qA(e,t,n){let r=Th(n),i=new Set(BA(t,n)),a=[],o=[];if(Array.isArray(e.structure_user))for(let t of e.structure_user)i.has(t)||a.push(`structure_user database "${t}"`);!r&&e.operations!==void 0&&!UA(e,!1).includes(`operations`)&&o.push(`"operations" (has no effect before Harper 5.0)`);for(let n of UA(e,r)){if(!i.has(n)){a.push(`database "${n}"`);continue}let r=e[n];if(!PA(r))continue;for(let e of Object.keys(r))e!==`tables`&&o.push(`"${n}.${e}"`);let s=FA(r,`tables`);if(!PA(s))continue;let c=t[n];for(let e of Object.keys(s)){let t=Object.hasOwn(c,e)?c[e]:void 0;if(!t){a.push(`table "${n}.${e}"`);continue}let r=s[e];if(!PA(r))continue;let i=`${n}.${e}`;for(let e of Object.keys(r))MA.has(e)||o.push(`"${i}.${e}"`);let l=FA(r,`attribute_permissions`);if(!Array.isArray(l))continue;let u=new Set(HA(t));for(let e of l){if(!PA(e))continue;let t=String(e.attribute_name);u.has(t)||o.push(`attribute "${i}.${t}"`);for(let n of Object.keys(e))NA.has(n)||o.push(`"${n}" on attribute "${i}.${t}"`)}}}return{notInSchema:a,notShown:o}}function JA(e,t,n){let r=Th(n),i=new Set(BA(t,n)),a=LA(e,new Set(UA(e,r).filter(e=>!i.has(e))));Array.isArray(a.structure_user)&&(a=IA(a,`structure_user`,a.structure_user.filter(e=>i.has(e))));for(let e of i){let n=FA(a,e),r=PA(n)?FA(n,`tables`):void 0;if(!PA(n)||!PA(r))continue;let i=t[e],o=new Set(Object.keys(r).filter(e=>!Object.hasOwn(i,e)));o.size&&(a=IA(a,e,IA(n,`tables`,LA(r,o))))}return a}function YA(e){return e.super_user===!0?`super_user`:e.cluster_user===!0?`cluster_user`:`standard`}function XA(e,t){let n=e;for(let e of[`super_user`,`cluster_user`])t===e?n=IA(n,e,!0):Object.hasOwn(n,e)&&(n=IA(n,e,!1));return zh(n)}function ZA(e,t){return t===!1&&!Object.hasOwn(e,`structure_user`)?e:zh(IA(e,`structure_user`,t))}function QA(e,t){let n=FA(e,t);return PA(n)?n:void 0}function $A(e,t){let n=e&&FA(e,`tables`),r=PA(n)?FA(n,t):void 0;return PA(r)?r:void 0}function ej(e,t,n){return $A(QA(e,t),n)}function tj(e){let t=e?.attribute_permissions;return Array.isArray(t)&&t.length>0}function nj(){return{read:!1,insert:!1,update:!1,delete:!1,attribute_permissions:[]}}function rj(e,t,n,r){let i=FA(e,t),a=PA(i)?i:{},o=FA(a,`tables`);return IA(e,t,IA(a,`tables`,IA(PA(o)?o:{},n,r)))}function ij(e,t,n){let r={...e,[t]:n};return!n&&t!==`delete`&&Array.isArray(e.attribute_permissions)&&(r.attribute_permissions=e.attribute_permissions.map(e=>e[t]?{...e,[t]:!1}:e)),r}function aj(e,t,n,r,i){let a=ej(e,t,n);return!a&&!i?e:rj(e,t,n,ij(a??nj(),r,i))}function oj(e,t,n,r,i){let a=FA(e,t),o=PA(a)?a:{},s=FA(o,`tables`),c=PA(s)?s:{},l=new Map;for(let a of n){let n=ej(e,t,a);(n||i)&&l.set(a,ij(n??nj(),r,i))}if(!l.size)return e;let u=Object.entries(c).map(([e,t])=>{let n=l.get(e);return l.delete(e),[e,n??t]});return u.push(...l.entries()),IA(e,t,IA(o,`tables`,Object.fromEntries(u)))}function sj(e,t,n){let r=new Map((e.attribute_permissions??[]).map(e=>[e.attribute_name,e])),i=(e,t)=>{let n=jA.has(e);return{read:t?.read===!0,insert:!n&&t?.insert===!0,update:!n&&t?.update===!0}},a={read:!1,insert:!1,update:!1};for(let[e,t]of r)if(e!==n){let n=i(e,t);for(let e of AA)a[e]||=n[e]}return t.map(e=>{let t=r.get(e),o=e===n,s=o&&!t;return{name:e,...s?a:i(e,t),isPrimaryKey:o,isTimestamp:jA.has(e),derived:s}})}function cj(e,t,n,r,i,a){let o=ej(e,t,n)??nj(),s=r?a?.length?a.map(e=>({...e,read:e.read&&o.read,insert:e.insert&&o.insert,update:e.update&&o.update})):i.map(e=>({attribute_name:e,read:o.read,insert:!jA.has(e)&&o.insert,update:!jA.has(e)&&o.update})):[];return rj(e,t,n,{...o,attribute_permissions:s})}function lj(e,t,n,r,i,a,o,s){let c=ej(e,t,n);if(!c||!Array.isArray(c.attribute_permissions))return e;let l=c.attribute_permissions,u=l.findIndex(e=>e.attribute_name===a),d;if(u>=0)d=l.map((e,t)=>t===u?{...e,[o]:s}:e);else{let e=sj(c,r,i).find(e=>e.name===a);d=[...l,{attribute_name:a,read:e?.read??!1,insert:e?.insert??!1,update:e?.update??!1,[o]:s}]}return rj(e,t,n,{...c,attribute_permissions:d,...s&&!c[o]?{[o]:!0}:{}})}function uj({...e}){return(0,K.jsx)(bn,{"data-slot":`accordion`,...e})}function dj({className:e,...t}){return(0,K.jsx)(zn,{"data-slot":`accordion-item`,className:F(`border-b last:border-b-0`,e),...t})}function fj({className:e,children:t,...n}){return(0,K.jsx)(Mn,{className:`flex`,children:(0,K.jsxs)(ln,{"data-slot":`accordion-trigger`,className:F(`focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180`,e),...n,children:[t,(0,K.jsx)(er,{className:`text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200`})]})})}function pj({className:e,children:t,...n}){return(0,K.jsx)(an,{"data-slot":`accordion-content`,className:`data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm`,...n,children:(0,K.jsx)(`div`,{className:F(`pt-0 pb-4`,e),children:t})})}function mj({className:e,...t}){return(0,K.jsx)(Vn,{"data-slot":`radio-group`,className:F(`grid gap-3`,e),...t})}function hj({className:e,...t}){return(0,K.jsx)(Ln,{"data-slot":`radio-group-item`,className:F(`border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,K.jsx)(An,{"data-slot":`radio-group-indicator`,className:`relative flex items-center justify-center`,children:(0,K.jsx)(Ii,{className:`fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2`})})})}function gj({value:e,onChange:t,version:n,allowlistRejected:r,structureUserDdl:i,disabled:a}){let o=e!==void 0,s=Dh(n),c=yh.filter(t=>!s.includes(t)&&e?.includes(t.name)),l=Eh(n),u=Zm(n),d=Qm(u),f=new Set(e??[]),p=(e??[]).filter(e=>!wh(e)),m=e?Oh(e,u):[],h=m.some(e=>Sh(e)?.su),g=(0,G.useRef)([]),_=e=>{let n=new Set(e),r=yh.map(e=>e.name).filter(e=>n.has(e)),i=[...n].filter(e=>!wh(e)).sort();t([...r,...i])},v=t=>{let n=new Set(e??[]);n.has(t)?n.delete(t):n.add(t),_(n)};return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border p-3`,children:[(0,K.jsxs)(Md,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Kx,{checked:o,onCheckedChange:n=>{n?t(g.current):(g.current=e??[],t(void 0))},disabled:a,"aria-label":`Restrict operations`}),(0,K.jsx)(`span`,{className:`font-medium`,children:`Restrict operations`})]}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o?d?`Only the operations below are allowed — anything unlisted is denied, SQL included: SQL statements need sql (or a group with it) listed here, and are then checked against table permissions as well. Listing an operation that normally requires super_user deliberately grants it to this role.`:`Only the operations below are allowed — anything unlisted is denied. Listing an operation that normally requires super_user deliberately grants it to this role. SQL statements are authorized against table permissions instead, so this list does not restrict them.`:`No operation-level restriction. Add one to limit this role to an explicit list of API operations (for example a deploy-only CI role).`}),r&&(0,K.jsx)(`p`,{className:`text-xs text-destructive`,children:`Harper does not accept an operations allowlist on a super_user or cluster_user role — the save is rejected unless the list is dropped. Clear that flag to scope this role by operation; otherwise the allowlist is removed when you save.`}),i&&o&&(d?(0,K.jsx)(_j,{scope:i,effective:m}):(0,K.jsxs)(`p`,{className:`text-xs text-warning`,children:[`This role is a structure user, so it reaches`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:Fh.join(`, `)}),i===!0?` (and create/drop database) on any database regardless of the list below.`:(0,K.jsxs)(K.Fragment,{children:[` `,`on `,(0,K.jsx)(`span`,{className:`font-mono`,children:i.join(`, `)}),` `,`regardless of the list below — and listing them here cannot reach another database.`]}),` Every other operation is still gated by the list.`]})),o&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[s.map(e=>(0,K.jsx)(vj,{group:e,checked:f.has(e.name),onToggle:v,disabled:a},e.name)),c.map(e=>(0,K.jsx)(vj,{group:e,note:`Saved on this role, but not offered for this instance's Harper version.`,checked:!0,onToggle:v,disabled:a},e.name))]}),(0,K.jsx)(xj,{grantable:l,band:u,selectedSet:f,onToggle:v,disabled:a}),p.length>0&&(0,K.jsx)(`div`,{className:`flex max-h-24 flex-wrap gap-1 overflow-y-auto`,children:p.map(e=>(0,K.jsx)(Sj,{name:e,band:u,onRemove:()=>v(e),disabled:a},e))}),m.length===0?(0,K.jsxs)(`p`,{className:`text-xs text-destructive`,children:[e?.length?`Every entry here is inert`:`Nothing selected`,` `,`— this role cannot run any Operations API call`,d?`, not even SQL${i?` or its structure-user DDL`:``}.`:`${i?`, except the DDL noted above`:``} (SQL is gated by table permissions, not this list).`]}):(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,title:kh(m),children:[`Effectively allows `,oe(m.length,`operation`,`operations`),h?`, including some that normally require super_user`:``,`.`,(0,K.jsxs)(`span`,{className:`sr-only`,children:[`: `,kh(m)]})]})]})]})}function _j({scope:e,effective:t}){let n=e===!0?[...Fh,...Ih]:Fh,r=n.filter(e=>!t.includes(e));return(0,K.jsxs)(`p`,{className:F(`text-xs`,r.length>0?`text-warning`:`text-muted-foreground`),children:[`This role is a structure user`,e===!0?``:(0,K.jsxs)(K.Fragment,{children:[` `,`on `,(0,K.jsx)(`span`,{className:`font-mono`,children:e.join(`, `)})]}),`, but on this Harper version the list below gates its DDL too: it can run`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:n.join(`, `)}),e===!0?` only when they are listed.`:` on those databases only when they are listed, and listing them cannot reach another database.`,r.length>0&&(0,K.jsxs)(K.Fragment,{children:[` `,`Not listed, so Harper refuses them: `,(0,K.jsx)(`span`,{className:`font-mono`,children:r.join(`, `)}),`.`]})]})}function vj({group:e,note:t,checked:n,onToggle:r,disabled:i}){return(0,K.jsxs)(Md,{className:`flex items-start gap-2 font-normal`,children:[(0,K.jsx)($,{type:`checkbox`,className:`mt-0.5 size-4`,checked:n,onChange:()=>r(e.name),disabled:i}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,K.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:t??e.description})]})]})}var yj=`This instance's Harper checks this operation under its internal handler name, so listing it has no effect here (HarperFast/harper#2175). Harper 5.3.0 and later grant it, as do prereleases from ${Xm}.`,bj=/^[A-Za-z][A-Za-z0-9_.:-]*$/;function xj({grantable:e,band:t,selectedSet:n,onToggle:r,disabled:i}){let[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(``),l=(0,G.useRef)(null),u=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(!a)return;let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>l.current?.focus())});return()=>{cancelAnimationFrame(t),cancelAnimationFrame(e)}},[a]);let d=s.trim(),f=d.toLowerCase(),p=f?e.filter(e=>e.name.includes(f)):e,m=D_(p,`category`),h=Sh(d),g=!h&&(wh(f)||_h.some(e=>e.name===f)),_=bj.test(d)&&!wh(d)&&!g&&!h?.nonDelegable&&!h?.aliasOf&&eh(d,t)!==`never`&&!e.some(e=>e.name===d)&&!n.has(d)?d:void 0;return(0,K.jsxs)(gc,{open:a,onOpenChange:e=>{o(e),e||c(``)},children:[(0,K.jsx)(_c,{asChild:!0,disabled:i,children:(0,K.jsxs)(H,{type:`button`,variant:`outline`,className:`w-full justify-between font-normal`,children:[(0,K.jsx)(`span`,{className:`truncate text-muted-foreground`,children:`Add operations…`}),(0,K.jsx)(er,{className:`size-4 shrink-0 opacity-60`})]})}),(0,K.jsxs)(vc,{ref:u,className:`w-(--radix-dropdown-menu-trigger-width) max-h-72 overflow-y-auto`,align:`start`,children:[(0,K.jsx)(`input`,{ref:l,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=u.current?.querySelectorAll(`[role="menuitemcheckbox"]:not([data-disabled])`);t?.length&&(e.key===`ArrowDown`?t[0]:t[t.length-1]).focus();return}e.key.length===1&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.stopPropagation()},placeholder:`Filter operations…`,"aria-label":`Filter operations`,className:`mb-1 w-full rounded-md border bg-transparent px-2 py-1 text-sm outline-none`}),gh.filter(e=>m[e]).map(e=>(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Cc,{className:`text-xs text-muted-foreground`,children:e}),m[e].map(e=>(0,K.jsxs)(bc,{checked:n.has(e.name),onCheckedChange:()=>r(e.name),onSelect:e=>e.preventDefault(),children:[(0,K.jsx)(`span`,{className:`flex-1 truncate font-mono text-xs`,children:e.name}),eh(e.name,t)===`needs-5.3`?(0,K.jsx)(ol,{variant:`outline`,title:yj,children:`needs newer Harper`}):e.su&&(0,K.jsx)(ol,{variant:`warning`,title:`Normally requires super_user; listing it grants it to this role`,children:`super_user`})]},e.name))]},e)),_&&(0,K.jsxs)(bc,{checked:!1,onCheckedChange:()=>r(_),onSelect:e=>e.preventDefault(),children:[(0,K.jsx)(Uo,{className:`size-3`}),(0,K.jsxs)(`span`,{className:`flex-1 truncate text-xs`,children:[`Grant "`,(0,K.jsx)(`span`,{className:`font-mono`,children:_}),`" `,h?`(listed for newer Harper versions — this instance may reject it)`:`(component-registered operation)`]})]}),p.length===0&&!_&&(0,K.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-muted-foreground`,children:`No matching operations`})]})]})}function Sj({name:e,band:t,onRemove:n,disabled:r}){let i=Sh(e),a=th(e,t),o=eh(e,t),s=a?`destructive`:i?.su?`warning`:i?`secondary`:`outline`,c=i?.aliasOf?`Legacy alias: Harper authorizes this operation under '${i.aliasOf}', so this entry grants nothing. Grant '${i.aliasOf}' instead.`:o===`needs-5.3`?yj:o===`never`?`This instance's Harper version never lets an operations allowlist grant this operation, so this entry has no effect; only a super_user role can run it.`:i?.nonDelegable?`Always requires an actual super_user role; listing it cannot delegate the operation to a non-super_user role.`:$m(e,t)?i?.caveat:i?.su?`Normally requires super_user; listing it grants it to this role.`:i?void 0:`Not in the built-in catalog — kept as-is (for example a component-registered operation).`;return(0,K.jsxs)(ol,{variant:s,title:c,className:`gap-1 font-mono text-xs`,children:[e,!r&&(0,K.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e}`,onClick:n,className:`ml-0.5 rounded-sm hover:text-destructive`,children:(0,K.jsx)(Ks,{className:`size-3`})})]})}var Cj={read:`Read`,insert:`Insert`,update:`Update`,delete:`Delete`};function wj({permission:e,onChange:t,instanceDatabaseMap:n,version:r,readOnly:i}){let a=YA(e),o=e.structure_user,s=Th(r),c=(0,G.useMemo)(()=>BA(n,r),[n,r]),l=(0,G.useMemo)(()=>qA(e,n,r),[e,n,r]),u=JSON.stringify(Lh(e)??null),d=(0,G.useMemo)(()=>JSON.parse(u)??void 0,[u]);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[l.notInSchema.length>0&&(0,K.jsxs)(c_,{variant:`warning`,children:[(0,K.jsx)(Rs,{}),(0,K.jsx)(l_,{children:`This role names things this instance's schema doesn't have`}),(0,K.jsxs)(u_,{children:[(0,K.jsxs)(`p`,{children:[l.notInSchema.join(`, `),`. Harper refuses to save a role that names a database or table that doesn't exist, so remove them before saving.`]}),!i&&(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`defaultOutline`,className:`mt-2`,onClick:()=>t(JA(e,n,r)),children:`Remove them`})]})]}),(0,K.jsx)(Ej,{permission:e,roleType:a,version:r,readOnly:i,onChange:t}),a===`standard`&&(0,K.jsx)(Oj,{permission:e,databaseNames:c,readOnly:i,onChange:t}),s&&(0,K.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":`Operations`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium`,children:`Operations`}),(0,K.jsx)(gj,{value:d,onChange:n=>t(Bh(e,n)),version:r,allowlistRejected:Nh(e),structureUserDdl:Ph(e),disabled:i})]}),a===`standard`&&o!==!0&&(0,K.jsx)(kj,{permission:e,instanceDatabaseMap:n,databaseNames:c,structureDatabases:Array.isArray(o)?o:[],readOnly:i,onChange:t}),l.notShown.length>0&&(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground italic`,children:[`Also kept as they are, but not shown here:`,` `,l.notShown.join(`, `),`. Use “Edit as JSON” to see or change them.`]})]})}function Tj(e,t){return Object.keys(e).some(n=>n!==t&&e[n]!==!1)}function Ej({permission:e,roleType:t,version:n,readOnly:r,onChange:i}){let a=(0,G.useId)(),o=yr(n,`0.0.0`)>=0&&yr(n,`5.0.0-0`)<0,s=t===`cluster_user`||o,c=t!==`standard`&&Tj(e,t);return(0,K.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-labelledby":`${a}-heading`,children:[(0,K.jsx)(`h3`,{id:`${a}-heading`,className:`text-sm font-medium`,children:`Role type`}),(0,K.jsxs)(mj,{value:t,onValueChange:t=>i(XA(e,t)),disabled:r,"aria-labelledby":`${a}-heading`,children:[(0,K.jsx)(Dj,{id:`${a}-standard`,value:`standard`,label:`Standard`,children:`Access comes from the database and table permissions below.`}),(0,K.jsx)(Dj,{id:`${a}-super`,value:`super_user`,label:`Super user`,children:`Bypasses per-table permissions.`}),s&&(0,K.jsx)(Dj,{id:`${a}-cluster`,value:`cluster_user`,label:`Cluster user`,children:o?`For the user that connects cluster nodes. A user with this role can list every database, table and attribute, and Harper keeps its password in a recoverable form so clustering can use it.`:`Harper 5 doesn't use this role type. Harper 4 used it for the user that connects cluster nodes.`})]}),c&&(0,K.jsxs)(`p`,{className:`text-xs text-warning`,children:[`Saving keeps only the `,(0,K.jsx)(`span`,{className:`font-mono`,children:t}),` flag: Harper rejects a`,` `,t===`super_user`?`super user`:`cluster user`,` `,`role that carries any other permission, so this role's other settings are removed.`]})]})}function Dj({id:e,value:t,label:n,children:r}){return(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(hj,{id:e,value:t,className:`mt-0.5`}),(0,K.jsxs)(Md,{htmlFor:e,className:`flex flex-col items-start gap-1 font-normal`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:n}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r})]})]})}function Oj({permission:e,databaseNames:t,readOnly:n,onChange:r}){let i=(0,G.useId)(),a=e.structure_user,o=a===!0?`all`:Array.isArray(a)?`selected`:`off`,s=Array.isArray(a)?a:[],c=(0,G.useRef)(s),l=[...t,...s.filter(e=>!t.includes(e))],u=Object.keys(e).some(e=>!jh.has(e)),d=t=>{Array.isArray(a)&&(c.current=a),r(ZA(e,t===`all`||t===`selected`&&c.current))},f=t=>{r(ZA(e,s.includes(t)?s.filter(e=>e!==t):[...s,t]))};return(0,K.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-labelledby":`${i}-heading`,children:[(0,K.jsx)(`h3`,{id:`${i}-heading`,className:`text-sm font-medium`,children:`Structure user`}),(0,K.jsxs)(mj,{value:o,onValueChange:d,disabled:n,"aria-labelledby":`${i}-heading`,children:[(0,K.jsx)(Dj,{id:`${i}-off`,value:`off`,label:`No`,children:`Creating and dropping databases, tables and attributes needs super user, or an operations list that grants it.`}),(0,K.jsx)(Dj,{id:`${i}-all`,value:`all`,label:`All databases`,children:`Can create and drop databases, tables and attributes, and can read, insert, update and delete in every table.`}),(0,K.jsx)(Dj,{id:`${i}-selected`,value:`selected`,label:`Selected databases`,children:`Can create and drop tables and attributes in the selected databases, and can read, insert, update and delete in their tables. Creating and dropping databases isn't included.`})]}),o!==`off`&&e.operations!==void 0&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The operations list below can still deny some of these.`}),o===`all`&&u&&(0,K.jsx)(`p`,{className:`text-xs text-warning`,children:`Per-table permissions don't apply to this role, so they are removed when you save.`}),o===`selected`&&(0,K.jsxs)(`div`,{className:`ml-6 flex flex-col gap-1`,children:[l.length===0&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This instance has no databases.`}),l.map(e=>(0,K.jsxs)(Md,{className:`flex items-center gap-2 font-normal`,children:[(0,K.jsx)(Nj,{checked:s.includes(e),onChange:()=>f(e),disabled:n,"aria-label":`Structure user on ${e}`}),(0,K.jsx)(`span`,{className:`font-mono text-xs`,children:e}),!t.includes(e)&&(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(not in this instance's schema)`})]},e))]})]})}function kj({permission:e,instanceDatabaseMap:t,databaseNames:n,structureDatabases:r,readOnly:i,onChange:a}){let[o,s]=(0,G.useState)(()=>[n.find(n=>Object.keys(t[n]).some(t=>{let r=ej(e,n,t);return r&&kA.some(e=>r[e]===!0)}))??n[0]].filter(e=>e!==void 0)),c=(0,G.useRef)(new Map),l=(0,G.useRef)({permission:e,onChange:a});(0,G.useLayoutEffect)(()=>{l.current={permission:e,onChange:a}},[e,a]);let u=(0,G.useCallback)(e=>{l.current.onChange(e(l.current.permission))},[]);return(0,K.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":`Table permissions`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium`,children:`Table permissions`}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`A table without a checked permission has no access. Delete always applies to whole records.`}),n.length===0&&(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This instance has no databases.`}),(0,K.jsx)(uj,{type:`multiple`,value:o,onValueChange:s,className:`rounded-md border`,children:n.map(n=>(0,K.jsx)(Aj,{databaseName:n,tables:t[n],record:QA(e,n),structureScoped:r.includes(n),readOnly:i,update:u,scopingRestore:c},n))})]})}var Aj=(0,G.memo)(function({databaseName:e,tables:t,record:n,structureScoped:r,readOnly:i,update:a,scopingRestore:o}){let s=Object.keys(t),c=s.map(e=>$A(n,e)),l=c.filter(e=>e&&kA.some(t=>e[t]===!0)).length;return(0,K.jsxs)(dj,{value:e,className:`px-3`,children:[(0,K.jsx)(fj,{className:`py-3`,children:(0,K.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,K.jsx)(`span`,{className:`font-mono`,children:e}),(0,K.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:r?`full access (structure user)`:`${l} of ${s.length} ${s.length===1?`table`:`tables`} with access`})]})}),(0,K.jsx)(pj,{children:r?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`As a structure user on this database, the role can read, insert, update and delete in every table here, so per-table permissions don't apply to it.`}):s.length===0?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No tables.`}):(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`border-b text-xs text-muted-foreground`,children:[(0,K.jsx)(`th`,{className:`py-1 pr-2 text-left font-normal`,children:`Table`}),kA.map(e=>(0,K.jsx)(`th`,{className:`px-2 py-1 text-center font-normal`,children:Cj[e]},e)),(0,K.jsx)(`th`,{className:`py-1 pl-2 text-left font-normal`,children:`Attributes`})]})}),(0,K.jsxs)(`tbody`,{children:[(0,K.jsxs)(`tr`,{className:`border-b`,children:[(0,K.jsx)(`td`,{className:`py-1 pr-2 text-xs text-muted-foreground`,children:`All tables`}),kA.map(t=>{let n=c.filter(e=>e?.[t]===!0).length;return(0,K.jsx)(`td`,{className:`px-2 py-1 text-center`,children:(0,K.jsx)(Nj,{checked:n===s.length,indeterminate:n>0&&n<s.length,disabled:i,"aria-label":`${Cj[t]} on every table in ${e}`,onChange:()=>a(r=>oj(r,e,s,t,n<s.length))})},t)}),(0,K.jsx)(`td`,{})]}),s.map((n,r)=>(0,K.jsx)(jj,{databaseName:e,tableName:n,schemaTable:t[n],entry:c[r],readOnly:i,update:a,scopingRestore:o},n))]})]})})})]})}),jj=(0,G.memo)(function({databaseName:e,tableName:t,schemaTable:n,entry:r,readOnly:i,update:a,scopingRestore:o}){let s=(0,G.useMemo)(()=>HA(n),[n]),c=VA(n),l=tj(r),[u,d]=(0,G.useState)(!1),f=`${e}.${t}`,p=l&&r?sj(r,s,c):[],m=p.filter(e=>AA.some(t=>e[t])).length,h=`${e}\u0000${t}`;return(0,K.jsxs)(G.Fragment,{children:[(0,K.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,K.jsx)(`td`,{className:`py-1 pr-2 font-mono text-xs`,children:t}),kA.map(n=>(0,K.jsx)(`td`,{className:`px-2 py-1 text-center`,children:(0,K.jsx)(Nj,{checked:r?.[n]===!0,disabled:i,"aria-label":`${Cj[n]} on ${f}`,onChange:r=>{let{checked:i}=r.target;a(r=>aj(r,e,t,n,i))}})},n)),(0,K.jsx)(`td`,{className:`py-1 pl-2`,children:(0,K.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground`,onClick:()=>d(e=>!e),"aria-expanded":u,"aria-label":`Attribute permissions for ${f}`,children:[u?(0,K.jsx)(er,{className:`size-3`}):(0,K.jsx)(Si,{className:`size-3`}),l?`${m} of ${s.length}`:`All`]})})]}),u&&(0,K.jsx)(`tr`,{className:`border-b bg-muted/30`,children:(0,K.jsx)(`td`,{colSpan:kA.length+2,className:`px-3 py-2`,children:(0,K.jsx)(Mj,{label:f,scoped:l,views:p,disabled:i||s.length===0,onScopingChanged:n=>{!n&&r?.attribute_permissions&&o.current.set(h,r.attribute_permissions),a(r=>cj(r,e,t,n,s,n?o.current.get(h):void 0))},onActionChanged:(n,r,i)=>a(a=>lj(a,e,t,s,c,n,r,i))})})})]})});function Mj({label:e,scoped:t,views:n,disabled:r,onScopingChanged:i,onActionChanged:a}){let o=(0,G.useId)(),s=n.find(e=>e.derived);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Kx,{id:o,checked:t,onCheckedChange:i,disabled:r,"aria-label":`Limit ${e} to specific attributes`}),(0,K.jsx)(Md,{htmlFor:o,className:`font-normal`,children:`Limit to specific attributes`})]}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t?`Only the access checked here applies. An attribute with nothing checked has no access, including attributes added to the table later. Computed and relationship attributes may be missing from this list; grant those in the JSON.`:`The table's read, insert and update apply to every attribute. Limiting lists only the attributes this instance's schema shows, which can leave out computed and relationship attributes, and those then have no access until granted in the JSON.`}),t&&(0,K.jsxs)(`table`,{className:`w-full max-w-md text-xs`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`text-muted-foreground`,children:[(0,K.jsx)(`th`,{className:`py-1 pr-2 text-left font-normal`,children:`Attribute`}),AA.map(e=>(0,K.jsx)(`th`,{className:`px-2 py-1 text-center font-normal`,children:Cj[e]},e))]})}),(0,K.jsx)(`tbody`,{children:n.map(t=>(0,K.jsxs)(`tr`,{children:[(0,K.jsxs)(`td`,{className:`py-0.5 pr-2 font-mono`,children:[t.name,t.isPrimaryKey&&(0,K.jsx)(`span`,{className:`ml-1 font-sans text-muted-foreground`,children:`(primary key)`})]}),AA.map(n=>{let i=t.isTimestamp&&n!==`read`;return(0,K.jsx)(`td`,{className:`px-2 py-0.5 text-center`,children:(0,K.jsx)(Nj,{checked:t[n],disabled:r||i,title:i?`Harper applies only read to this timestamp attribute.`:void 0,"aria-label":`${Cj[n]} on ${e}.${t.name}`,onChange:e=>a(t.name,n,e.target.checked)})},n)})]},t.name))})]}),t&&s&&(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`The primary key `,(0,K.jsx)(`span`,{className:`font-mono`,children:s.name}),` `,`isn't listed, so it gets whatever access any other attribute has. Changing it here sets it explicitly.`]}),t&&n.some(e=>e.isTimestamp)&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Harper applies only read to timestamp attributes.`})]})}function Nj({indeterminate:e=!1,className:t,...n}){let r=(0,G.useRef)(null);return(0,G.useLayoutEffect)(()=>{r.current&&(r.current.indeterminate=e)},[e]),(0,K.jsx)(`input`,{ref:r,type:`checkbox`,className:F(`size-4 cursor-pointer align-middle disabled:cursor-not-allowed disabled:opacity-50`,t),...n})}function Pj({kind:e,assigning:t,databaseCollision:n}){return e===`malformed`?(0,K.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`This role's `,(0,K.jsx)(`span`,{className:`font-mono`,children:`operations`}),` `,`value is not a list of operation names. Harper still gates on it: a string is read one character at a time, so every operation is denied; an array with non-string members enforces whatever it does expand to; and a falsy value makes each of this role's requests fail outright. The role cannot be saved again until it is fixed.`,` `,t?`Correct it in the role editor.`:`Correct it in the JSON below.`]}):(0,K.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`This role's `,(0,K.jsx)(`span`,{className:`font-mono`,children:`operations`}),` `,`value is not a list of operation names — most often table permissions on a database of that name, kept from an older Harper. This version cannot expand it, and `,t?`assigning this role to a user breaks authentication for every user on the instance. Pick a different role, and repair this one in the role editor first.`:(0,K.jsxs)(K.Fragment,{children:[`authentication breaks for every user on the instance as soon as a user holds this role. Remove the`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:`operations`}),` `,`key in the JSON below — that alone restores authentication.`,n&&(0,K.jsxs)(K.Fragment,{children:[` `,`Separately, and only if this instance needs allowlists at all: a database named`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:`operations`}),` `,`stops every role from using one. Retiring it means migrating its data and table grants to a differently-named database and verifying them there first — dropping it destroys whatever it holds, so treat that as a planned migration rather than part of this repair.`]})]})]})}async function Fj({instanceClient:e,skipRecordCount:t,includeComputed:n}){let{data:r}=await e.post(`/`,{operation:`describe_all`,skip_record_count:t||void 0,exact_count:!t&&void 0,include_computed:n||void 0});return r}function Ij(e){return B({queryKey:[e.entityId,`describe_all`,!!e.skipRecordCount,!!e.includeComputed],queryFn:()=>Fj(e),staleTime:6e4,gcTime:5e3,retry:!1})}function Lj(){let e=q(),t=L(Ij({...e,skipRecordCount:!0})),n=L(HE(e));return{instanceDatabaseMap:t.data,version:n.data?.version,isLoading:t.isPending||n.isPending,isError:t.isError&&!t.data||n.isError&&!n.data,retry:()=>{t.refetch(),n.refetch()}}}function Rj(e,t){if(!e)return!1;if(!t)return e.operations!==void 0&&Lh(e)===void 0;let n=Rh(e,Th(t));return n===`breaks-auth`||n===`malformed`}var zj=5;function Bj({draft:e,schema:t,readOnly:n}){let{text:r,permission:i}=e,a=Tx(),{instanceDatabaseMap:o,version:s}=t,c=!!o&&!!s,[l,u]=(0,G.useState)(),d=(0,G.useDeferredValue)(i),f=l===!0?d:i,p=(0,G.useMemo)(()=>!o||!s?[]:f?WA(f,o,s):[`The JSON is not a valid object.`],[f,o,s]),m=c&&!!f&&p.length===0;l===void 0&&c&&u(!m);let h=i&&s?Rh(i,Th(s)):`absent`,g=i?.operations;return t.isLoading&&!t.isError?(0,K.jsx)(my,{}):l===!1&&m&&i&&o&&s?(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2`,children:[(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsxs)(H,{type:`button`,variant:`defaultOutline`,size:`sm`,onClick:()=>u(!0),children:[(0,K.jsx)(Xi,{}),` Edit as JSON`]})}),(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-1`,children:(0,K.jsx)(wj,{permission:i,onChange:e.setPermission,instanceDatabaseMap:o,version:s,readOnly:n})})]}):(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t.isError?(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`The visual editor needs this instance's schema and version, which didn't load.`,(0,K.jsxs)(H,{type:`button`,variant:`defaultOutline`,size:`sm`,onClick:t.retry,children:[(0,K.jsx)(Go,{}),` Retry`]})]}):p.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{children:`The visual editor can't show this role until the JSON is fixed:`}),(0,K.jsxs)(`ul`,{className:`list-disc pl-4`,children:[p.slice(0,zj).map(e=>(0,K.jsx)(`li`,{children:e},e)),p.length>zj&&(0,K.jsxs)(`li`,{children:[`…and `,p.length-zj,` more.`]})]})]})}),c&&(0,K.jsxs)(H,{type:`button`,variant:`defaultOutline`,size:`sm`,className:`shrink-0`,disabled:!m,onClick:()=>u(!1),children:[(0,K.jsx)(Es,{}),` Visual editor`]})]}),(h===`breaks-auth`||h===`malformed`)&&(0,K.jsx)(Pj,{kind:h,databaseCollision:typeof g==`object`&&!!g&&!Array.isArray(g)}),(0,K.jsx)(`div`,{className:`min-h-64 flex-1`,children:(0,K.jsx)(Dx,{className:`h-full w-full`,theme:a,defaultLanguage:`json`,value:r,options:{readOnly:n,automaticLayout:!0},onChange:t=>e.setText(t??``)})})]})}function Vj(e){let[t,n]=(0,G.useState)(()=>Hj(e)),r=(0,G.useCallback)(e=>n({text:e,permission:RA(e)}),[]),i=(0,G.useCallback)(e=>n(Hj(e)),[]);return{...t,setText:r,setPermission:i}}function Hj(e){return{text:zA(e),permission:zh(e)}}function Uj(e){if(e.super_user!==!0&&e.structure_user!==!0&&e.cluster_user!==!0)return Wj(e);let t=Nh(e),n={...e};for(let e in n)(!jh.has(e)||e===`operations`&&(t||!Array.isArray(n.operations))||e===`structure_user`&&t||n[e]===!1)&&delete n[e];return n}function Wj(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Gj(t)]))}function Gj(e){if(typeof e!=`object`||!e||Array.isArray(e))return e;let{tables:t}=e;return typeof t!=`object`||!t||Array.isArray(t)?e:{...e,tables:Object.fromEntries(Object.entries(t).map(([e,t])=>[e,typeof t==`object`&&t&&`attribute_permissions`in t&&t.attribute_permissions===null?{...t,attribute_permissions:[]}:t]))}}async function Kj({role:e,permission:t,instanceClient:n}){let{data:r}=await n.post(`/`,{operation:`add_role`,role:e,permission:t});return r}function qj(){return I({mutationFn:Kj})}var Jj=b({role:x().nonempty({error:`Please enter a role.`}).regex(/^[a-zA-Z_]*$/,{error:`Role must contain only letters and underscores.`}).max(30,{error:`Role cannot be longer than 30 characters.`})}),Yj={super_user:!1,structure_user:!1};function Xj({onChangesSaved:e,closeModal:t}){let n=on({resolver:mt(Jj),defaultValues:{role:``}}),r=q(),i=Lj(),{mutate:a,isPending:o}=qj(),s=Vj(Yj),{permission:c}=s,l=Rj(c,i.version),u=(0,G.useCallback)(t=>{c&&!l&&a({role:t.role,permission:Uj(c),...r},{onSuccess:()=>{U.success(`Role added successfully!`),e()}})},[a,r,e,l,c]);return(0,K.jsx)(_m,{onOpenChange:t,open:!0,children:(0,K.jsx)(wm,{resizable:!0,"aria-describedby":void 0,children:(0,K.jsx)(Od,{...n,children:(0,K.jsxs)(`form`,{id:`instance-add-role-form`,name:`instance-add-role-form`,onSubmit:n.handleSubmit(u),className:`flex min-h-0 flex-1 flex-col gap-4`,children:[(0,K.jsxs)(Tm,{children:[(0,K.jsx)(Dm,{children:`Add New Role`}),(0,K.jsx)(Om,{children:`Name the role and choose what it can access.`})]}),(0,K.jsx)(Y,{control:n.control,name:`role`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,K.jsx)(cy,{type:`text`,maxLength:Jj.shape.role.maxLength,...e}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Bj,{draft:s,schema:i}),(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(H,{variant:`destructiveOutline`,type:`button`,onClick:t,disabled:o,children:`Cancel`}),(0,K.jsxs)(H,{type:`submit`,variant:`submit`,disabled:o||!c||l,children:[(0,K.jsx)($o,{}),` Add Role`]})]})})]})})})})}function Zj({entityId:e,instanceClient:t}){return B({queryKey:[e,`list_roles`],queryFn:()=>Qj({instanceClient:t}),refetchInterval:Gc(1e4),retry:Kc()})}async function Qj({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_roles`});return t}async function $j({id:e,permission:t,instanceClient:n}){let{data:r}=await n.post(`/`,{operation:`alter_role`,id:e,permission:t});return r}function eM(){return I({mutationFn:$j})}async function tM({id:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_role`,id:e});return n}function nM(){return I({mutationFn:tM})}function rM({data:e,instanceId:t,clusterId:n,isModalOpen:r,closeModal:i,onSelectRole:a,onChangesSaved:o}){let{role:s}=e,c=q(),l=Lj(),u=Tr(t??n).user?.role?.id===e.id,d=Vj(e.permission),{permission:f}=d,[p,m]=(0,G.useState)(e.__updatedtime__),h=e.__updatedtime__!==p,{mutate:g,isPending:_}=eM(),{mutate:v,isPending:y}=nM(),[b,x]=(0,G.useState)(!1),S=Rj(f,l.version),C=(0,G.useCallback)(()=>{!f||S||h||g({id:e.id,permission:Uj(f),...c},{onSuccess:()=>{U.success(`Role updated successfully!`),a(void 0),o()}})},[g,h,e.id,c,o,a,S,f]),{setPermission:w}=d,[T,E]=(0,G.useState)(0),D=(0,G.useCallback)(()=>{w(e.permission),E(e=>e+1),m(e.__updatedtime__)},[e.__updatedtime__,e.permission,w]),O=(0,G.useCallback)(()=>m(e.__updatedtime__),[e.__updatedtime__]),k=(0,G.useCallback)(()=>{v({id:e.id,...c},{onSuccess:()=>{U.success(`Role deleted successfully!`),a(void 0),o()}})},[e.id,v,c,o,a]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(_m,{onOpenChange:i,open:r,children:(0,K.jsxs)(wm,{resizable:!0,children:[(0,K.jsxs)(Dm,{children:[u?`View`:`Edit`,` Role "`,s,`"`]}),(0,K.jsx)(Om,{children:u?`You can view your own role, but you cannot edit it. Please assign yourself a different role to edit this role.`:`Choose what this role can access, or remove the role entirely.`}),h&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-warning`,role:`status`,children:[(0,K.jsx)(`span`,{children:`This role was changed somewhere else after you opened it. Load that version, or keep yours to replace it when you save.`}),(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`defaultOutline`,onClick:D,children:`Load the latest version`}),!u&&(0,K.jsx)(H,{type:`button`,size:`sm`,variant:`defaultOutline`,onClick:O,children:`Keep my changes`})]}),(0,K.jsx)(Bj,{draft:d,schema:l,readOnly:u},T),(0,K.jsx)(Em,{children:!u&&(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(H,{type:`button`,variant:`destructiveOutline`,onClick:()=>x(!0),disabled:_,children:`Delete Role`}),(0,K.jsx)(H,{variant:`submit`,onClick:C,disabled:_||!f||S||h,children:`Save Changes`})]})})]})}),(0,K.jsx)(km,{isModalOpen:b,setIsModalOpen:x,deletionConfirmed:k,deletionPending:y,typeOfThingBeingDeleted:`role`,nameOfThingBeingDeleted:s,hideDataLossWarning:!0})]})}function iM(){let e=De(),{clusterId:t,instanceId:n,roleId:r}=z({strict:!1}),i=q(),{data:a,refetch:o,isFetching:s,isRefetching:c}=we(Zj(i)),l=(0,G.useMemo)(()=>a?.find(e=>e.id===r),[a,r]),u=(0,G.useCallback)(t=>{let n=[r?`..`:``,t].filter(Boolean);e({to:n.join(`/`)})},[r,e]),d=!!r&&!!l,[f,p]=(0,G.useState)(!1),m=(0,G.useCallback)(()=>{p(!0)},[p]),h=(0,G.useCallback)(()=>{o(),p(!1)},[o]),g=(0,G.useCallback)(()=>{p(!1)},[]),_=(0,G.useCallback)(e=>{u(e.original.id)},[u]),v=(0,G.useCallback)(()=>{u(void 0)},[u]),y=Kb(o);return(0,K.jsxs)(G.Suspense,{fallback:(0,K.jsx)(Lc,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,K.jsx)(TA,{children:(0,K.jsxs)(Hb,{columns:DA,data:a,isFetching:s,onRowClick:_,children:[(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:y,accessKey:`r`,disabled:s||c,children:[(0,K.jsx)(Go,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),(0,K.jsxs)(H,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:f,children:[(0,K.jsx)(Uo,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]})}),f&&(0,K.jsx)(Xj,{onChangesSaved:h,closeModal:g}),d&&(0,K.jsx)(rM,{instanceId:n,clusterId:t,isModalOpen:d,closeModal:v,data:l,onSelectRole:u,onChangesSaved:()=>o()},l.id)]})}function aM(e){return!!e?.entries}function oM(e){if(!e?.entries)return[];let t=new Set;for(let n of e.entries)aM(n)&&t.add(n.name);return[...t].sort((e,t)=>e.localeCompare(t))}function sM({components:e,granted:t,onAdd:n,disabled:r,actionLabel:i=`Add`,commitOnBlur:a=!1}){let[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(0),[f,p]=(0,G.useState)(!1),m=(0,G.useId)(),h=(0,G.useId)(),g=(0,G.useRef)(!1),_=(0,G.useRef)(!1),v=r||f,y=(0,G.useMemo)(()=>{if(e.length===0)return[];let n=o.trim(),r=n.toLowerCase(),i=new Set(t),a=e.filter(e=>!i.has(e)),s=(n?a.filter(e=>e.toLowerCase().includes(r)):a).map(e=>({value:e,custom:!1})),c=a.some(e=>e.toLowerCase()===r);return n&&!c&&s.push({value:n,custom:!0}),s},[e,t,o]),b=y.length===0?0:Math.min(u,y.length-1),x=(0,G.useCallback)(async e=>{if(_.current)return;let r=e.trim();if(!r||t.includes(r)){s(``);return}_.current=!0,p(!0);try{await n(r),s(``),l(!1)}catch{}finally{_.current=!1,p(!1)}},[t,n]),S=(0,G.useCallback)(()=>{x(y[b]?.value??o)},[x,y,b,o]),C=(0,G.useCallback)(e=>{if(e.key===`ArrowDown`){e.preventDefault(),l(!0),d(Math.min(b+1,Math.max(0,y.length-1)));return}if(e.key===`ArrowUp`){e.preventDefault(),d(Math.max(0,b-1));return}if(e.key===`Escape`){c&&(e.preventDefault(),e.stopPropagation(),l(!1));return}e.key===`Enter`&&(e.preventDefault(),S())},[c,y,b,S]),w=(0,G.useCallback)(()=>{g.current||(l(!1),a&&o.trim()&&S())},[a,o,S]),T=c&&y.length>0;return(0,K.jsxs)(`div`,{className:`relative grid gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{type:`text`,role:`combobox`,"aria-expanded":T,"aria-controls":T?m:void 0,"aria-autocomplete":`list`,"aria-activedescendant":T&&y[b]?`${h}-${b}`:void 0,autoComplete:`off`,autoCapitalize:`off`,placeholder:e.length>0?`Search applications…`:`application name`,value:o,onChange:e=>{s(e.target.value),d(0),l(!0)},onFocus:()=>l(!0),onKeyDown:C,onBlur:w,disabled:v}),(0,K.jsxs)(H,{type:`button`,variant:`positiveOutline`,onMouseDown:e=>e.preventDefault(),onClick:S,disabled:v||!o.trim(),children:[(0,K.jsx)(Uo,{}),` `,i]})]}),T&&(0,K.jsx)(`ul`,{id:m,role:`listbox`,className:`bg-popover text-popover-foreground absolute top-11 z-10 max-h-56 w-full overflow-auto rounded-md border p-1 shadow-md`,children:y.map((e,t)=>{let n=t===b;return(0,K.jsx)(`li`,{id:`${h}-${t}`,role:`option`,"aria-selected":n,onMouseEnter:()=>d(t),onMouseDown:t=>{t.preventDefault(),g.current=!0,x(e.value).finally(()=>{g.current=!1})},className:F(`flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-sm`,n&&`bg-accent text-accent-foreground`),children:e.custom?(0,K.jsxs)(`span`,{className:`truncate`,children:[`Use “`,(0,K.jsx)(`span`,{className:`font-mono`,children:e.value}),`” — not a deployed application`]}):(0,K.jsx)(`span`,{className:`truncate font-mono`,children:e.value})},e.custom?`__custom__${e.value}`:e.value)})})]})}var cM=`enc:v1:`;function lM(e){let t=e.replace(/-----BEGIN [^-]+-----/,``).replace(/-----END [^-]+-----/,``).replace(/\s+/g,``),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}function uM(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function dM(e){return uM(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function fM(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function pM(){if(typeof crypto>`u`||!crypto.subtle)throw Error(`Secret encryption requires a secure context (HTTPS or localhost).`);return crypto.subtle}async function mM(e,t,n){let r=pM(),i=lM(t),a=await r.importKey(`spki`,fM(i),{name:`RSA-OAEP`,hash:`SHA-256`},!1,[`encrypt`]),o=crypto.getRandomValues(new Uint8Array(32)),s=crypto.getRandomValues(new Uint8Array(12)),c=await r.importKey(`raw`,fM(o),{name:`AES-GCM`},!1,[`encrypt`]),l=new Uint8Array(await r.encrypt({name:`AES-GCM`,iv:fM(s),tagLength:128},c,fM(new TextEncoder().encode(e)))),u=l.slice(0,l.length-16),d=l.slice(l.length-16),f={kid:n,k:uM(new Uint8Array(await r.encrypt({name:`RSA-OAEP`},a,fM(o)))),iv:uM(s),ct:uM(u),tag:uM(d)};return cM+dM(new TextEncoder().encode(JSON.stringify(f)))}var hM=class extends Error{constructor(e){super(e),this.name=`SecretsOperationError`}};function gM(e){if(or(e))return e;let t=e?.response?.data,n=typeof t?.error==`string`?t.error:t?.message;return typeof n==`string`?new hM(n):e}var _M=`does not match`;function vM(e){return e.includes(_M)}async function yM({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`get_secrets_public_key`});return{publicKey:t.public_key,fingerprint:t.fingerprint}}var bM=P;async function xM(e){let{data:t}=await bM.post(`/ClusterSecrets`,{operation:`get_secrets_public_key`,clusterId:e});return{publicKey:t.publicKey,fingerprint:t.fingerprint}}function SM(e){return B({queryKey:[e.entityId,`get_secrets_public_key`,e.managedClusterId??`node`],queryFn:()=>e.managedClusterId?xM(e.managedClusterId):yM(e),staleTime:3e5,retry:!1})}async function CM({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_secrets`});return t}function wM(e){return B({queryKey:[e.entityId,`list_secrets`],queryFn:()=>CM(e)})}async function TM(e,t,n){let{publicKey:r,fingerprint:i}=await e.ensureQueryData(SM(t)),a=await mM(t.value,r,i);try{let{data:e}=await t.instanceClient.post(`/`,{operation:`set_secret`,name:t.name,envelope:a,...t.processEnv===void 0?{}:{processEnv:t.processEnv},...t.grants===void 0?{}:{grants:t.grants}});return e}catch(r){let i=gM(r);if(!n&&i instanceof hM&&vM(i.message))return e.removeQueries({queryKey:SM(t).queryKey}),TM(e,t,!0);throw i}}function EM(){let e=Ze();return I({mutationFn:t=>TM(e,t,!1)})}async function DM({instanceClient:e,name:t}){try{let{data:n}=await e.post(`/`,{operation:`delete_secret`,name:t});return n}catch(e){throw gM(e)}}function OM(){return I({mutationFn:DM})}async function kM(e,{instanceClient:t,name:n,component:r}){try{let{data:i}=await t.post(`/`,{operation:e,name:n,component:r});return i}catch(e){throw gM(e)}}function AM(){return I({mutationFn:e=>kM(`grant_secret`,e)})}function jM(){return I({mutationFn:e=>kM(`revoke_secret`,e)})}function MM({name:e,initialGrants:t,components:n,onChanged:r}){let i=q(),{mutateAsync:a,isPending:o}=AM(),{mutateAsync:s,isPending:c}=jM(),l=o||c,[u,d]=(0,G.useState)(t),f=(0,G.useCallback)(async t=>{try{let n=await a({...i,name:e,component:t});d(n.grants),r?.()}catch(e){throw pc(e)&&U.error(fc(e).message),e}},[a,i,e,r]),p=(0,G.useCallback)(async t=>{try{let n=await s({...i,name:e,component:t});d(n.grants),r?.()}catch(e){pc(e)&&U.error(fc(e).message)}},[s,i,e,r]);return(0,K.jsxs)(`div`,{className:`grid gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium`,children:`Granted applications`}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Only granted applications can read this secret through the `,(0,K.jsx)(`code`,{className:`font-mono`,children:`secrets`}),` `,`accessor. Changes apply immediately.`]}),u.length>0&&(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:u.map(e=>(0,K.jsxs)(ol,{variant:`secondary`,children:[e,(0,K.jsxs)(`button`,{type:`button`,onClick:()=>void p(e),disabled:l,title:`Revoke ${e}`,className:`cursor-pointer disabled:cursor-default`,children:[(0,K.jsx)(Ks,{}),(0,K.jsxs)(`span`,{className:`sr-only`,children:[`Revoke `,e]})]})]},e))}),(0,K.jsx)(sM,{components:n,granted:u,onAdd:f,disabled:l,actionLabel:`Grant`})]})}var NM=`********`,PM=/^[\w.-]+$/,FM=/^(\s*(?:export\s+)?)([\w.-]+)\s*=(.*)$/;function IM(e){return e.split(`/`).pop()??``}function LM(e){if(!e)return!1;let t=IM(e).toLowerCase();return t===`.env`||t.startsWith(`.env.`)}var RM=[`.example`,`.sample`,`.template`];function zM(e){if(!LM(e))return!1;let t=IM(e).toLowerCase();return RM.some(e=>t.endsWith(e))}function BM(e){return LM(e)&&!zM(e)}function VM(e){let t={};if(!e)return t;let n=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm,r=e.replace(/\r\n?/g,`
679
679
  `),i;for(;(i=n.exec(r))!==null;){let e=i[1],n=(i[2]??``).trim(),r=n[0];n=n.replace(/^(['"`])([\s\S]*)\1$/gm,`$2`),r===`"`&&(n=n.replace(/\\n/g,`
680
680
  `).replace(/\\r/g,`\r`)),t[e]=n}return t}function HM(e){return!e||e.length===0?``:e.map(e=>`${e}=${NM}`).join(`
681
681
  `)+`
@@ -830,4 +830,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
830
830
  <p>Press {keybinding:completeProgrammaticDnd} to drop or {keybinding:abortProgrammaticDnd} to abort.</p>
831
831
  `,programmaticallyDraggingTarget:`
832
832
  <p>Drop target is {dropTarget}.</p>
833
- `},NB=function(e,t,n,r,i){var a=function(e){return t.getItemTitle(t.items[e])};return e.replace(/({[^\s}]+)}/g,function(e){var o=e.slice(1,-1);switch(o){case`treeLabel`:return r.treeLabel??``;case`renamingItem`:return r.renamingItem?a(r.renamingItem):`None`;case`dragItems`:return n.draggingItems?.map(function(e){return t.getItemTitle(e)}).join(`, `)??`None`;case`dropTarget`:if(!n.draggingPosition)return`None`;if(n.draggingPosition.targetType===`item`||n.draggingPosition.targetType===`root`)return`within ${a(n.draggingPosition.targetItem)}`;var s=t.items[n.draggingPosition.parentItem],c=t.getItemTitle(s);return n.draggingPosition.childIndex===0?`within ${c} at the start`:`within ${c} after ${a(s.children[n.draggingPosition.childIndex-1])}`;default:if(o.startsWith(`keybinding:`))return i[o.slice(11)][0];throw Error(`Unknown live descriptor variable {${o}}`)}})},PB=function(e){var t=e.children,n=e.live;return G.createElement(`div`,{"aria-live":n,dangerouslySetInnerHTML:{__html:t}})},FB=function(){var e=lB(),t=KB(),n=Vz(),r=_B(),i=(0,G.useMemo)(function(){return e.liveDescriptors??MB},[e.liveDescriptors]),a=t.renderers.renderLiveDescriptorContainer;return t.treeInformation.isRenaming?G.createElement(a,{tree:t},G.createElement(PB,{live:`polite`},NB(i.renamingItem,e,n,t,r))):t.treeInformation.isSearching?G.createElement(a,{tree:t},G.createElement(PB,{live:`polite`},NB(i.searching,e,n,t,r))):t.treeInformation.isProgrammaticallyDragging?G.createElement(a,{tree:t},G.createElement(PB,{live:`polite`},NB(i.programmaticallyDragging,e,n,t,r)),G.createElement(PB,{live:`assertive`},NB(i.programmaticallyDraggingTarget,e,n,t,r))):G.createElement(a,{tree:t},G.createElement(PB,{live:`off`},NB(i.introduction,e,n,t,r)))},IB=function(){return lB().showLiveDescription??!0?G.createElement(FB,null):null},LB=function(){return LB=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},LB.apply(this,arguments)},RB=function(){var e=KB(),t=e.treeId,n=e.rootItem,r=e.renderers,i=e.treeInformation,a=lB(),o=(0,G.useRef)(),s=Vz();DB(),pB(o.current,function(){a.setActiveTree(t)},function(){a.setActiveTree(function(e){return e===t?void 0:e})});var c=a.items[n].children,l=G.createElement(G.Fragment,null,G.createElement(IB,null),G.createElement(JB,{depth:0,parentId:n},c??[]),G.createElement(dB,{treeId:t}),G.createElement(jB,{containerRef:o.current})),u=LB({onDragOver:function(e){e.preventDefault(),s.onDragOverTreeHandler(e,t,o)},onDragLeave:function(e){s.onDragLeaveContainerHandler(e,o)},onMouseDown:function(){return s.abortProgrammaticDrag()},ref:o,style:{position:`relative`},role:`tree`,"aria-label":i.treeLabelledBy?void 0:i.treeLabel,"aria-labelledby":i.treeLabelledBy},{"data-rct-tree":t});return r.renderTreeContainer({children:l,info:i,containerProps:u})},zB=function(e,t,n){var r=lB(),i=Vz(),a=r.viewState[e.treeId]?.selectedItems;return(0,G.useMemo)(function(){return{isFocused:r.activeTreeId===e.treeId,isRenaming:!!t,areItemsSelected:(a?.length??0)>0,isSearching:n!==null,search:n,isProgrammaticallyDragging:i.isProgrammaticallyDragging??!1,treeId:e.treeId,rootItem:e.rootItem,treeLabel:e.treeLabel,treeLabelledBy:e.treeLabelledBy}},[r.activeTreeId,e.treeId,e.rootItem,e.treeLabel,e.treeLabelledBy,t,a?.length,n,i.isProgrammaticallyDragging])},BB=function(){return BB=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},BB.apply(this,arguments)},VB=function(e,t){var n=lB(),r=KB(),i=Vz();(0,G.useImperativeHandle)(e,function(){return BB(BB(BB({},t),{treeEnvironmentContext:n,dragAndDropContext:i,treeContext:r}),r.treeInformation)})},HB=G.createContext(null),UB=G.forwardRef(function(e,t){lB();var n=KB();Vz();var r=Xz(),i=(0,G.useMemo)(function(){return{abortRenamingItem:function(){n.setRenamingItem(null)},abortSearch:function(){n.setSearch(null)},collapseItem:function(e){r.collapseItem(e,n.treeId)},completeRenamingItem:function(){},expandItem:function(e){r.expandItem(e,n.treeId)},focusItem:function(e,t){t===void 0&&(t=!0),r.focusItem(e,n.treeId,t)},focusTree:function(e){e===void 0&&(e=!0),r.focusTree(n.treeId,e)},invokePrimaryAction:function(e){r.invokePrimaryAction(e,n.treeId)},moveFocusDown:function(){r.moveFocusDown(n.treeId)},moveFocusUp:function(){r.moveFocusUp(n.treeId)},renameItem:function(e,t){r.renameItem(e,t,n.treeId)},selectItems:function(e){r.selectItems(e,n.treeId)},setSearch:function(e){n.setSearch(e)},startRenamingItem:function(e){n.setRenamingItem(e)},stopRenamingItem:function(){n.setRenamingItem(null)},toggleItemExpandedState:function(e){r.toggleItemExpandedState(e,n.treeId)},toggleItemSelectStatus:function(e){r.toggleItemSelectStatus(e,n.treeId)},expandAll:function(){r.expandAll(n.treeId)},collapseAll:function(){r.collapseAll(n.treeId)},expandSubsequently:function(e){return r.expandSubsequently(n.treeId,e)}}},[r,n]);return VB(t,i),G.createElement(HB.Provider,{value:i},e.children)}),WB=function(){return WB=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},WB.apply(this,arguments)},GB=G.createContext(null),KB=function(){return(0,G.useContext)(GB)},qB=G.forwardRef(function(e,t){var n,r=lB(),i=(0,G.useMemo)(function(){return WB(WB({},r),e)},[e,r]),a=(0,G.useState)(null),o=a[0],s=a[1],c=(0,G.useState)(null),l=c[0],u=c[1],d=r.items[e.rootItem],f=r.viewState[e.treeId];(0,G.useEffect)(function(){return r.registerTree({treeId:e.treeId,rootItem:e.rootItem}),function(){return r.unregisterTree(e.treeId)}},[e.treeId,e.rootItem]);var p=zB(e,l,o),m=(0,G.useMemo)(function(){return{treeId:e.treeId,rootItem:e.rootItem,treeLabel:e.treeLabel,treeLabelledBy:e.treeLabelledBy,getItemsLinearly:function(){return iB(e.rootItem,f??{},r.items)},treeInformation:p,search:o,setSearch:s,renamingItem:l,setRenamingItem:u,renderers:i}},[r.items,e.rootItem,e.treeId,e.treeLabel,e.treeLabelledBy,l,i,o,p,f]);return d===void 0?((n=r.onMissingItems)==null||n.call(r,[e.rootItem]),null):G.createElement(GB.Provider,{value:m},G.createElement(UB,{ref:t},G.createElement(RB,null)))}),JB=function(e){for(var t=KB(),n=t.renderers,r=t.treeInformation,i=[],a=0,o=e.children;a<o.length;a++){var s=o[a];i.push(G.createElement($B,{key:s,itemIndex:s,depth:e.depth}))}if(i.length===0)return null;var c={role:e.depth===0?void 0:`group`};return n.renderItemsContainer({children:i,info:r,containerProps:c,depth:e.depth,parentId:e.parentId})},YB=function(){return YB=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},YB.apply(this,arguments)},XB=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},ZB=function(e){var t=KB(),n=t.treeId,r=t.search,i=t.renamingItem,a=t.setRenamingItem,o=lB(),s=Sz(),c=Vz(),l=TB(`last-focus`),u=e&&o.getItemTitle(e),d=Fz(),f=(0,G.useMemo)(function(){return r===null||r.length===0||!e||!u?!1:(o.doesSearchMatchItem??OB)(r,e,u)},[r,e,u,o.doesSearchMatchItem]),p=e&&(o.viewState[n]?.selectedItems)?.includes(e.index),m=e&&(o.viewState[n]?.expandedItems)?.includes(e.index),h=e&&i===e.index;return(0,G.useMemo)(function(){if(e){var t=o.viewState[n],r=((t?.selectedItems)?.map(function(e){return o.items[e]})??(t?.focusedItem?[o.items[t?.focusedItem]]:[])).filter(function(e){return!!e}),i=!!r.find(function(t){return t.index===e.index}),u=r&&(o.canDrag?.call(o,r)??!0)&&r.map(function(e){return e.canMove??!0}).reduce(function(e,t){return e&&t},!0),g=(o.canDrag?.call(o,[e])??!0)&&(e.canMove??!0),_=o.canDragAndDrop&&(i&&u||!i&&g),v=o.canDragAndDrop&&!!(c.viableDragPositions?.[n])?.find(function(t){return t.targetType===`item`&&t.targetItem===e.index}),y={primaryAction:function(){var t;(t=o.onPrimaryAction)==null||t.call(o,o.items[e.index],n)},collapseItem:function(){var t;(t=o.onCollapseItem)==null||t.call(o,e,n)},expandItem:function(){var t;(t=o.onExpandItem)==null||t.call(o,e,n)},toggleExpandedState:function(){var t,r;m?(t=o.onCollapseItem)==null||t.call(o,e,n):(r=o.onExpandItem)==null||r.call(o,e,n)},selectItem:function(){var t;(t=o.onSelectItems)==null||t.call(o,[e.index],n)},addToSelectedItems:function(){var r;(r=o.onSelectItems)==null||r.call(o,XB(XB([],t?.selectedItems??[],!0),[e.index],!1),n)},unselectItem:function(){var r;(r=o.onSelectItems)==null||r.call(o,(t?.selectedItems)?.filter(function(t){return t!==e.index})??[],n)},selectUpTo:function(t){l(e,t)},startRenamingItem:function(){a(e.index)},stopRenamingItem:function(){a(null)},focusItem:function(t){var r;t===void 0&&(t=!0),(r=o.onFocusItem)==null||r.call(o,e,n,t)},startDragging:function(){var r,i=t?.selectedItems??[];if(i.includes(e.index)||(i=[e.index],(r=o.onSelectItems)==null||r.call(o,i,n)),_){var a=d(n,i.map(function(e){return o.items[e]}));c.onStartDraggingItems(a,n)}}},b={isSelected:p,isExpanded:m,isFocused:t?.focusedItem===e.index,isRenaming:h,isDraggingOver:c.draggingPosition&&c.draggingPosition.targetType===`item`&&c.draggingPosition.targetItem===e.index&&c.draggingPosition.treeId===n,isDraggingOverParent:!1,isSearchMatching:f,canDrag:_,canDropOn:v},x=YB(YB({},s.createInteractiveElementProps(e,n,y,b,t)),{"data-rct-item-interactive":!0,"data-rct-item-focus":b.isFocused?`true`:`false`,"data-rct-item-id":e.index}),S=YB({},{"data-rct-item-container":`true`}),C={role:`treeitem`,"aria-selected":b.isSelected,"aria-expanded":e.isFolder?b.isExpanded?`true`:`false`:void 0},w={onClick:function(){e.isFolder&&y.toggleExpandedState(),y.selectItem()},onFocus:function(){y.focusItem()},onDragOver:function(e){e.preventDefault()},"aria-hidden":!0,tabIndex:-1},T=t?Object.entries(t).reduce(function(t,n){var r=n[0],i=n[1];return t[r]=Array.isArray(i)?i.includes(e.index):i===e.index,t},{}):{};return YB(YB(YB({},y),b),{interactiveElementProps:x,itemContainerWithChildrenProps:C,itemContainerWithoutChildrenProps:S,arrowProps:w,viewStateFlags:T})}},[e,o,n,c,p,m,h,f,s,l,a,d])},QB=function(e){var t=KB(),n=t.renderers,r=t.treeInformation,i=t.setRenamingItem,a=t.treeId,o=lB(),s=(0,G.useRef)(null),c=(0,G.useRef)(null),l=o.items[e.itemIndex],u=(0,G.useState)(o.getItemTitle(l)),d=u[0],f=u[1],p=Mz(!0),m=function(){var e;(e=o.onAbortRenamingItem)==null||e.call(o,l,r.treeId),i(null),p(function(){o.setActiveTree(a)})},h=function(){var e;(e=o.onRenameItem)==null||e.call(o,l,d,r.treeId),i(null),p(function(){o.setActiveTree(a)})};Oz(function(){var e,t,n;o.setActiveTree(a),(o.autoFocus??!0)&&((e=s.current)==null||e.select(),(n=(t=s.current)?.focus)==null||n.call(t))},[o,a],[]),yB(`abortRenameItem`,function(){m()},!0,!0);var g={value:d,onChange:function(e){f(e.target.value)},onBlur:function(e){(!e.relatedTarget||e.relatedTarget!==c.current)&&m()},"aria-label":`New item name`,tabIndex:0};return n.renderRenameInput({item:l,inputRef:s,submitButtonProps:{onClick:function(e){e.stopPropagation(),h()}},submitButtonRef:c,formProps:{onSubmit:function(e){e.preventDefault(),h()}},inputProps:g})},$B=function(e){var t,n=(0,G.useState)(!1),r=n[0],i=n[1],a=KB(),o=a.renderers,s=a.treeInformation,c=a.renamingItem,l=lB(),u=bB(),d=l.items[e.itemIndex],f=(0,G.useMemo)(function(){return u.expandedItems?.includes(e.itemIndex)},[e.itemIndex,u.expandedItems]),p=ZB(d);if(d===void 0||p===void 0)return r||(i(!0),(t=l.onMissingItems)==null||t.call(l,[e.itemIndex])),null;var m=l.shouldRenderChildren?.call(l,d,p)??(d.isFolder&&f),h=d.children&&m&&G.createElement(JB,{depth:e.depth+1,parentId:e.itemIndex},d.children),g=l.getItemTitle(d),_=c===e.itemIndex?G.createElement(QB,{itemIndex:e.itemIndex}):o.renderItemTitle({info:s,context:p,title:g,item:d}),v=o.renderItemArrow({info:s,context:p,item:l.items[e.itemIndex]});return o.renderItem({item:l.items[e.itemIndex],depth:e.depth,title:_,arrow:v,context:p,info:s,children:h})??null},eV=`__db_root__`,tV=`__create_table__`;function nV(e,t){return`${e}/${t}`}function rV(e,{canManage:t}){let n={},r=Object.keys(e||{}).sort();for(let t of r){let r=Object.keys(e?.[t]||{}).sort();n[t]={index:t,isFolder:!0,children:r.map(e=>nV(t,e)),data:{kind:`database`,databaseName:t},canMove:!1,canRename:!1};for(let e of r){let r=nV(t,e);n[r]={index:r,isFolder:!1,data:{kind:`table`,databaseName:t,tableName:e},canMove:!1,canRename:!1}}}return n[tV]={index:tV,isFolder:!1,data:{kind:`createTable`},canMove:!1,canRename:!1},n[eV]={index:eV,isFolder:!0,children:[...t?[tV]:[],...r],data:{kind:`root`},canMove:!1,canRename:!1},{items:n,rootId:eV}}function iV({items:e,instanceDatabaseMap:t,children:n}){let r=wg(),[i,a]=(0,G.useState)(void 0),[o,s]=(0,G.useState)(``),c=(0,G.useCallback)(t=>{let n=t.target.closest(`[data-rct-item-id]`)?.getAttribute(`data-rct-item-id`),r=n?e[n]?.data:void 0;if(!r||r.kind===`root`||r.kind===`createTable`){a(void 0),t.preventDefault();return}a(r),s(`${t.clientX},${t.clientY}`)},[e]);return(0,K.jsxs)(Am,{modal:!1,children:[(0,K.jsx)(jm,{asChild:!0,children:(0,K.jsx)(`div`,{onContextMenu:c,className:`min-h-full`,children:n})}),i&&(0,K.jsxs)(Mm,{className:`min-w-44`,onCloseAutoFocus:e=>e.preventDefault(),children:[i.kind===`database`&&r&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Nm,{onSelect:()=>rL(`ShowCreateTable`,{databaseName:i.databaseName}),children:[(0,K.jsx)(Uo,{}),`Create a Table`]}),(0,K.jsx)(Fm,{}),(0,K.jsxs)(Nm,{variant:`destructive`,onSelect:()=>rL(`ShowDeleteDatabase`,{databaseName:i.databaseName}),children:[(0,K.jsx)(Is,{}),`Drop Database`]})]}),i.kind===`table`&&(0,K.jsx)(ez,{databaseName:i.databaseName,tableName:i.tableName,instanceDatabaseMap:t})]},o)]})}function aV(e){switch(e.data.kind){case`createTable`:return`Create a Table`;case`database`:return e.data.databaseName;case`table`:return e.data.tableName;default:return``}}var oV=`mr-1.5 h-4 w-4 shrink-0 pointer-events-none`;function sV({title:e,item:t}){let n=t.data.kind;return(0,K.jsxs)(K.Fragment,{children:[n===`createTable`?(0,K.jsx)(Uo,{className:F(oV,`text-green-500`)}):n===`database`?(0,K.jsx)(ia,{className:F(oV,`text-orange-400`)}):(0,K.jsx)(Es,{className:oV}),(0,K.jsx)(`span`,{className:`text-nowrap pointer-events-none`,children:e})]})}function cV({databaseName:e,tableName:t}){let{entityId:n}=q(),r=(0,G.useMemo)(()=>e&&t?[nV(e,t)]:e?[e]:[],[e,t]),[i,a]=(0,G.useState)(r[0]);(0,G.useEffect)(()=>{r[0]!==void 0&&a(r[0])},[r]);let[o,s]=FC(`DatabaseTreeExpanded/${n}`,e?[e]:[]);return(0,G.useEffect)(()=>{e&&s(t=>t.includes(e)?t:[...t,e])},[e,s]),{focusedItem:i,setFocusedItem:a,expandedItems:o,setExpandedItems:s,selectedItems:r}}var lV={"--rct-drop-target-height":`0px`};function uV({instanceDatabaseMap:e}){let t=z({strict:!1}),n=De(),r=wg(),{items:i,rootId:a}=(0,G.useMemo)(()=>rV(e,{canManage:r}),[e,r]),{focusedItem:o,setFocusedItem:s,expandedItems:c,setExpandedItems:l,selectedItems:u}=cV(t),d=(0,G.useCallback)((e,r)=>{n({to:jP({...t,databaseName:e,tableName:r})})},[n,t]),f=(0,G.useCallback)(e=>{switch(e.kind){case`createTable`:rL(`ShowCreateTable`,{databaseName:t.databaseName});break;case`database`:(t.databaseName!==e.databaseName||t.tableName)&&d(e.databaseName,void 0);break;case`table`:(t.databaseName!==e.databaseName||t.tableName!==e.tableName)&&d(e.databaseName,e.tableName)}},[t.databaseName,t.tableName,d]),p=(0,G.useCallback)(e=>{let t=e[e.length-1],n=t===void 0?void 0:i[t]?.data;n&&f(n)},[i,f]);return(0,K.jsx)(`div`,{className:`app-tree-scroll h-full overflow-auto pr-1.5`,style:lV,children:(0,K.jsx)(iV,{items:i,instanceDatabaseMap:e,children:(0,K.jsx)(uB,{canDragAndDrop:!1,canReorderItems:!1,canSearch:!0,canRename:!1,defaultInteractionMode:pz.DoubleClickItemToExpand,getItemTitle:aV,items:i,renderItemArrow:fz,renderItemTitle:sV,viewState:{databasesTree:{focusedItem:o,expandedItems:c,selectedItems:u}},onFocusItem:e=>s(e.index),onExpandItem:e=>l(t=>t.includes(e.index)?t:[...t,e.index]),onCollapseItem:e=>l(t=>t.filter(t=>t!==e.index)),onSelectItems:p,children:(0,K.jsx)(qB,{treeId:`databasesTree`,rootItem:a,treeLabel:`Databases tree`})})})})}function dV({instanceDatabaseMap:e}){return(0,K.jsxs)(`div`,{className:`pl-3 flex flex-col h-full min-h-0`,children:[(0,K.jsx)(`h1`,{className:`pt-3 pb-3 text-3xl shrink-0`,children:`Databases`}),e?(0,K.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,K.jsx)(uV,{instanceDatabaseMap:e})}):(0,K.jsx)(my,{className:`w-full flex-1 min-h-0 rounded-md`})]})}var fV=new Set([`contains`,`ends_with`,`ne`,`not_equal`]);function pV(e,t,n={}){let r=new Map;for(let{search_attribute:i,search_type:a}of e){let[e,o]=Array.isArray(i)?i:[i],s=o!==void 0&&Object.hasOwn(n,e)?n[e]:void 0,c=s?s.relatedAttributes.find(e=>e.attribute===o):t[e];if((c?.is_primary_key||c?.indexed)&&!fV.has(a))return[];let l=o===void 0?e:`${e}.${o}`;r.set(l,{attribute:l,relatedTableName:s?.relatedTableName})}return[...r.values()]}function mV(e,t){return`No index can answer this filter on ${t.map(({attribute:e})=>`"${e}"`).join(`, `)}, so Harper will read every record in ${[...new Set(t.map(t=>t.relatedTableName??e))].map(e=>`"${e}"`).join(` and `)} to find the matches. On a large table that can take a long time and slow the server down for everyone using it.\n\nRun it anyway?`}function hV(e,t,n){if(!n||!e?.length)return;let r=new Set;for(let t of e){let e=t[n];e!=null&&r.add(e)}let i=new Set;for(let e of t){let t=e[n];t!=null&&i.add(t)}let a=[...r].filter(e=>!i.has(e));if(a.length)return{kind:`lost`,keys:a};let o=[...i].filter(e=>!r.has(e));if(o.length)return{kind:`unknown`,keys:o};let s=e.filter(e=>e[n]==null).length,c=t.filter(e=>e[n]==null).length;if(c!==s)return{kind:`keyless`,added:Math.max(0,c-s),dropped:Math.max(0,s-c)}}function gV(e,t,n){if(!n||!e?.length)return[];let r=new Map(e.map(e=>[e[n],e])),i=[];for(let[e,a]of t.entries()){let t=a[n];if(t==null)continue;let o=r.get(t);if(!o)continue;let s=Object.keys(o).filter(e=>!Object.hasOwn(a,e));s.length&&i.push({index:e,removed:s})}return i}function _V(e){return[...new Set(e.flatMap(e=>e.removed))]}function vV({canEditRecords:e,canDeleteRecords:t,canReplaceRecords:n,replaceBlockedReason:r,setIsModalOpen:i,isModalOpen:a,primaryKey:o,missingPrimaryKey:s,recordUnavailable:c,syntheticAttributes:l,recordNavigation:u,data:d,onSaveChanges:f,onReplaceRecord:p,onDeleteRecord:m,isUpdateTableRecordsPending:h,isDeleteTableRecordsPending:g}){let _=Tx(),v=(0,G.useRef)(null),y=!!s||!!c,b=!e||y,[x,S]=(0,G.useState)(!1),[C,w]=(0,G.useState)(),{onEditorMount:T,showRecordJsonError:E,clearRecordJsonError:D}=II(),O=(0,G.useMemo)(()=>d?.map(({__createdtime__:e,__updatedtime__:t,...n})=>{for(let e of l??[])delete n[e];return n}),[d,l]),k=(0,G.useMemo)(()=>O&&JSON.stringify(O,null,4),[O]),A=k??``,j=(0,G.useRef)(A),M=(0,G.useRef)(null);(0,G.useLayoutEffect)(()=>{j.current!==A&&(j.current=A,M.current=A)},[A]);let ee=(0,G.useMemo)(()=>d&&JSON.stringify(d.map(e=>e[o]??null)),[d,o]),te=a?k:null,N=a?ee:null,[P,F]=(0,G.useState)(te),[ne,re]=(0,G.useState)(N),[ie,ae]=(0,G.useState)(!1),[oe,se]=(0,G.useState)(!1);te!==P&&(ae(a&&N!=null&&N===ne&&x),F(te),re(N),w(void 0),S(!1));let ce=a&&(d!==void 0||oe);oe!==ce&&se(ce);let le=h||g,ue=e=>{(!x||confirm(`Discard your unsaved changes to this record?`))&&(w(void 0),S(!1),ae(!1),e())};return(0,K.jsx)(_m,{onOpenChange:i,open:a,children:(0,K.jsxs)(wm,{"aria-describedby":void 0,resizable:!0,autoFocus:!b,onKeyDown:e=>{if(!u||le||v.current?.contains(e.target))return;let t=e.key===`ArrowLeft`||e.key===`ArrowUp`?u.hasPrevious?u.onPrevious:void 0:(e.key===`ArrowRight`||e.key===`ArrowDown`)&&u.hasNext?u.onNext:void 0;t&&(e.preventDefault(),ue(t))},onEscapeKeyDown:b?void 0:e=>{x&&e.preventDefault()},children:[(0,K.jsx)(Tm,{children:(0,K.jsxs)(Dm,{children:[b?`View`:`Edit`,` Record`]})}),y&&(0,K.jsxs)(c_,{variant:`warning`,children:[(0,K.jsx)(Rs,{}),(0,K.jsx)(l_,{children:s?`This record has no primary key value`:`This record couldn't be loaded`}),(0,K.jsxs)(u_,{children:[(0,K.jsx)(`p`,{children:s?o?(0,K.jsxs)(K.Fragment,{children:[`It has no value for the primary key`,` `,(0,K.jsx)(`code`,{children:o}),`, so it can't be looked up, edited, or deleted individually.`]}):`It has no primary key value, so it can't be looked up, edited, or deleted individually.`:o?(0,K.jsxs)(K.Fragment,{children:[`Nothing is stored under its primary key`,` `,(0,K.jsx)(`code`,{children:o}),`, so it can't be edited or deleted individually.`]}):`Nothing is stored under its primary key, so it can't be edited or deleted individually.`}),(0,K.jsx)(`p`,{children:`This usually means the table's primary key was changed after the record was created, so the value shown here isn't the key the record is actually stored under. To remove it, recreate the table or restore the original primary key attribute.`})]})]}),ie&&(0,K.jsxs)(c_,{variant:`warning`,children:[(0,K.jsx)(Rs,{}),(0,K.jsx)(l_,{children:`This record changed while you were editing it`}),(0,K.jsx)(u_,{children:`The editor was refreshed with the stored record, so the unsaved changes were discarded. Make them again and save.`})]}),d||oe?(0,K.jsx)(`div`,{ref:v,className:`flex-1 min-h-0 w-full`,children:(0,K.jsx)(Dx,{className:`w-full h-full`,language:xI,theme:_,options:{readOnly:b||!d,automaticLayout:!0},value:A,onMount:T,onChange:e=>{let t=M.current!==null&&e===M.current;M.current=null,!t&&(w(e),S(!0),ae(!1),D())}})}):(0,K.jsx)(Lc,{}),(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3 w-full`,children:[(0,K.jsx)(`div`,{className:`flex`,children:t&&!y&&(0,K.jsxs)(H,{variant:`destructive`,type:`button`,autoFocus:!1,onClick:()=>{let e=d?.[0]?.[o];e!=null&&m([e])},disabled:g||h,children:[(0,K.jsx)(Is,{}),` Delete Record`]})}),u&&(0,K.jsx)(yV,{...u,disabled:le,onPrevious:()=>ue(u.onPrevious),onNext:()=>ue(u.onNext)}),(0,K.jsx)(`div`,{className:`flex`,children:e&&!y&&(0,K.jsxs)(H,{variant:`submit`,autoFocus:!0,accessKey:`s`,onClick:()=>{if(C===void 0){i(!1);return}let e=TI(C);if(!e.ok){U.error(`This record isn't valid JSON`,{description:DI(e.error)}),E(e.error);return}let t=Array.isArray(e.value)?e.value:[e.value],a=hV(O,t,o);if(a){U.error(a.kind===`lost`?`This record's ${o} is missing from the save`:a.kind===`unknown`?`This edit names a ${o} the editor didn't load`:`This edit ${a.added?`adds`:`drops`} ${(a.added||a.dropped)===1?`a record`:`${a.added||a.dropped} records`} with no ${o}`,{description:a.kind===`lost`?`${o} identifies the record, so restore ${a.keys.join(`, `)} to save this edit. Changing it doesn't rename a record — the save would do nothing, or overwrite whatever is stored under the new value. To delete the record, use Delete Record.`:a.kind===`unknown`?`Saving would edit the record stored under ${a.keys.join(`, `)}, which isn't the record open here. Remove it from the JSON and edit that record directly.`:a.added?`A record with no ${o} can't be written from here — the save would skip it and still report success. Remove it, and use Add Record to create a record.`:`Removing a record from the JSON doesn't delete it, so the save would report success having left it alone. Put it back, and use Delete Record to delete a record.`});return}let s=gV(O,t,o);if(s.length){if(s.length<t.length){U.error(`Removing an attribute can't be combined with other record edits`,{description:`Removing an attribute replaces the whole record, which would overwrite any concurrent change to the other records in this payload. Remove the same attribute from every record here, or put it back and save the value changes on their own — the records loaded together have to be saved together.`});return}if(!n){let e=_V(s),t=e.length===1?`an attribute`:`attributes`,n=`Removing ${e.join(`, `)}`;U.error(r===`permission`?`You don't have permission to remove ${t}`:`This Harper version can't remove ${t}`,{description:r===`permission`?`${n} rewrites the record through the 'put' operation, which needs both insert and update on this table, and 'put' in the role's allowed operations. Ask an administrator for those grants, or set the value to null instead of removing it.`:`${n} needs the 'put' operation, added in Harper 5.3.0. On this instance the update operation can only merge, so the attribute would silently stay. Upgrade the instance, or set the value to null instead of removing it.`});return}p(t);return}f(t)},disabled:h||g,children:[(0,K.jsx)($o,{}),` `,(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`S`}),`ave Changes`]})]})})]})})]})})}function yV({position:e,total:t,isTotalEstimated:n,hasPrevious:r,hasNext:i,onPrevious:a,onNext:o,disabled:s}){return(0,K.jsxs)(`div`,{className:`flex items-center rounded-lg border border-border text-sm text-muted-foreground`,children:[(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Previous record`,disabled:s||!r,onClick:a,children:(0,K.jsx)(bi,{})}),(0,K.jsxs)(`span`,{className:`whitespace-nowrap px-1 tabular-nums`,"aria-live":`polite`,children:[`Record `,e===void 0?`…`:By(e),t!==void 0&&(0,K.jsxs)(K.Fragment,{children:[` of `,n?`~`:``,By(t)]})]}),(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Next record`,disabled:s||!i,onClick:o,children:(0,K.jsx)(Si,{})})]})}function bV(e,t){if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i of n)if(!r.includes(i)||e[i]!==t[i])return!1;return!0}function xV(e,t){let[n,r]=(0,G.useState)(t),[i,a]=(0,G.useState)(e);return(0,G.useEffect)(()=>{bV(n,t)||(r(t),a(e))},[n,t,e]),bV(n,t)?[i,a]:[e,a]}function SV(e=!1){let[t,n]=(0,G.useState)(e),r=(0,G.useCallback)(e=>{e?.preventDefault?.(),n(e=>!e)},[]),i=(0,G.useCallback)(e=>{e?.preventDefault?.(),n(!0)},[]),a=(0,G.useCallback)(e=>{e?.preventDefault?.(),n(!1)},[]);return(0,G.useMemo)(()=>({toggled:t,setToggled:n,toggle:r,toggleOn:i,toggleOff:a}),[r,n,a,i,t])}async function CV({databaseName:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`cleanup_orphan_blobs`,database:e});return n}function wV(){return I({mutationFn:CV})}function TV(e){return e!==void 0&&!Array.isArray(e)}var EV=`Harper's response didn't report which records it wrote, so the change may not have been saved.`;function DV(e,t){if(!Array.isArray(e?.deleted_hashes)||TV(e?.skipped_hashes))return{message:EV,wroteNothing:!1};let n=e.skipped_hashes?.length??0,r=e.deleted_hashes.length;if(!(n===0&&r>=t))return{message:`Harper deleted ${r} of ${t} records${n>0?` and skipped ${n}`:``}. A record is skipped when nothing is stored under its primary key.`,wroteNothing:r===0}}async function OV({databaseName:e,tableName:t,hashValues:n,instanceClient:r}){let{data:i}=await r.post(`/`,{operation:`delete`,database:e,table:t,hash_values:n});return i}function kV(){return I({mutationFn:OV})}async function AV({databaseName:e,tableName:t,instanceClient:n}){let{data:r}=await n.post(`/`,{operation:`describe_table`,database:e,table:t,exact_count:!0},{timeout:0});return r.record_count}function jV(e){return B({enabled:e.enabled&&!!e.databaseName&&!!e.tableName,queryKey:[e.entityId,e.databaseName,e.tableName,`record_count`,`exact`],queryFn:()=>AV(e),staleTime:6e4,gcTime:5e3,retry:!1})}function MV(e){return!!e&&vr(`5.3.0`,e)}function NV(e,t){if(!t)return`permission`;if(e!==void 0&&!MV(e))return`version`}async function PV({databaseName:e,tableName:t,records:n,instanceClient:r}){let{data:i}=await r.post(`/`,{operation:`put`,database:e,table:t,records:n});return i}function FV(e,t){if(!Array.isArray(e?.put_hashes))return{message:EV,wroteNothing:!1};if(!(e.put_hashes.length>=t))return{message:`Harper reported writing ${e.put_hashes.length} of ${t} records, so the change may not have been saved.`,wroteNothing:e.put_hashes.length===0}}function IV(){return I({mutationFn:PV})}function LV(e,t){if(TV(e?.update_hashes)||TV(e?.skipped_hashes))return{message:EV,wroteNothing:!1};let n=e?.skipped_hashes?.length??0,r=e?.update_hashes?.length??t;if(!(n===0&&r>=t))return{message:`Harper updated ${r} of ${t} records${n>0?` and skipped ${n}`:``}. A record is skipped when nothing is stored under its primary key.`,wroteNothing:Array.isArray(e?.update_hashes)&&r===0}}async function RV(e){let{databaseName:t,tableName:n,records:r,instanceClient:i}=e,{data:a}=await i.post(`/`,{operation:`update`,database:t,table:n,records:r});return a}function zV(){return I({mutationFn:RV})}var BV=ee(x(),x());function VV({applyFilters:e,columnFiltersForm:t,headerGroups:n,selectColumnWidth:r}){let i=(0,G.useCallback)(t=>{if(t.key===`Enter`)return t.preventDefault(),e(),!1},[e]);return(0,K.jsx)(xb,{children:(0,K.jsx)(Od,{...t,children:n.map(e=>(0,K.jsxs)(Cb,{className:`border-none`,children:[r!==void 0&&(0,K.jsx)(Eb,{style:{width:`${r}px`},className:`sticky top-10 left-0 z-20 bg-card dark:bg-black-dark border-b border-border shadow-[inset_-1px_0_0_var(--color-border)]`}),e.headers.map(e=>{let n=e.column.columnDef.meta?.relationshipInfo,r=e.column.columnDef.meta?.unindexed;return(0,K.jsx)(Eb,{style:{width:`${e.column.getSize()}px`},className:`sticky top-10 z-10 bg-card dark:bg-black-dark border-b border-border`,children:e.column.columnDef.enableColumnFilter&&(0,K.jsx)(Y,{control:t.control,name:e.id,render:({field:t})=>(0,K.jsxs)(X,{className:`border-r border-r-black`,children:[(0,K.jsxs)(`div`,{className:`flex items-center`,children:[n&&(0,K.jsx)(HV,{relationshipInfo:n,value:t.value??``,onChange:t.onChange}),(0,K.jsx)(J,{children:(0,K.jsx)($,{...t,type:`text`,autoCapitalize:`none`,autoComplete:`off`,className:`rounded-none`,onKeyDown:i,value:t.value??``,placeholder:n?`.${n.relatedPrimaryKey} value`:r?`not indexed`:void 0,"aria-label":`Filter ${e.column.id}`,title:e.column.columnDef.meta?.filterHint})})]}),(0,K.jsx)(Q,{})]})})},e.id)})]},e.id))})})}function HV({relationshipInfo:e,value:t,onChange:n}){return(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,className:`rounded-none shrink-0`,title:`Filter by a ${e.relatedTableName} property`,children:(0,K.jsx)(er,{})})}),(0,K.jsx)(vc,{side:`bottom`,align:`start`,children:e.relatedAttributes.map(e=>(0,K.jsxs)(yc,{onClick:()=>{let r=t.replace(/^\s*\.\S*\s*/,``);n(`.${e.attribute} ${r}`)},children:[e.attribute,e.type&&(0,K.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.type})]},e.attribute))})]})}function UV({tableName:e,hasPrimaryKey:t,isFiltered:n,isPastFirstPage:r,recordCount:i,canImportFile:a,canImportUrl:o,canSeedSample:s,canSeedRandom:c,canAddRecords:l,onImport:u,onSeed:d,onAddRecords:f,onClearFilters:p}){if(!t)return(0,K.jsxs)(KV,{children:[(0,K.jsxs)(qV,{children:[(0,K.jsx)(`span`,{className:`font-mono`,children:e}),` has no primary key`]}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[i?`It reports ${oe(By(i),`record`,`records`)}, but Studio`:`Studio`,` `,`lists and opens records by their primary key, so it can't browse this table. To browse its records here, copy them into a new table that has a primary key.`]})]});if(r)return(0,K.jsxs)(KV,{children:[(0,K.jsx)(qV,{children:`No records on this page`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`There are fewer records than this page starts at. Try an earlier page.`})]});if(n)return(0,K.jsxs)(KV,{children:[(0,K.jsx)(qV,{children:`No records match these filters`}),(0,K.jsxs)(H,{variant:`ghost`,onClick:p,children:[(0,K.jsx)(Sa,{}),`Clear Filters`]})]});if(i)return(0,K.jsxs)(KV,{children:[(0,K.jsx)(qV,{children:`No records came back`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This table reports records, but the page returned none. Try refreshing, or turn off Only If Cached in the table options menu.`})]});let m=a||o,h=s||c;return(0,K.jsxs)(KV,{children:[(0,K.jsx)(qV,{children:i===0?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`font-mono`,children:e}),` has no records yet`]}):`No records to show`}),m&&h&&(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Two ways to get some in — bring your own, or start from data we provide.`}),(m||h)&&(0,K.jsxs)(`div`,{className:`flex w-full flex-col gap-3 sm:flex-row`,children:[m&&(0,K.jsx)(JV,{Icon:Ji,title:`Import your data`,description:WV(a,o),action:`Import data`,onClick:u}),h&&(0,K.jsx)(JV,{Icon:Fo,title:`Seed some data`,description:GV(s,c),action:`Seed data`,onClick:d})]}),l&&(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[m||h?`Or write one yourself: `:`Write one yourself: `,(0,K.jsxs)(H,{variant:`link`,className:`h-auto p-0 text-sm dark:text-violet-300`,onClick:f,children:[(0,K.jsx)(Uo,{}),`Add New Record(s)`]})]})]})}function WV(e,t){return e?t?`Upload a CSV or JSON file, or load a CSV from a URL the instance can reach.`:`Upload a CSV or JSON file.`:`Load a CSV from a URL the instance can reach.`}function GV(e,t){return e?t?`Fill this table with random records, or load a ready-made sample dataset into a table of its own.`:`Load a ready-made sample dataset. It arrives in a table of its own.`:`Fill this table with random records modelled on its columns.`}function KV({children:e}){return(0,K.jsx)(`div`,{className:`h-full overflow-y-auto p-6`,children:(0,K.jsx)(`div`,{className:`flex min-h-full items-center justify-center`,children:(0,K.jsxs)(`div`,{className:`flex w-full max-w-2xl flex-col items-center gap-4 text-center`,children:[(0,K.jsx)(Os,{"aria-hidden":!0,className:`size-8 text-muted-foreground/50`}),e]})})})}function qV({children:e}){return(0,K.jsx)(`h2`,{className:`text-base font-medium`,children:e})}function JV({Icon:e,title:t,description:n,action:r,onClick:i}){return(0,K.jsxs)(`button`,{type:`button`,onClick:i,className:`group flex flex-1 cursor-pointer flex-col items-start gap-1.5 rounded-lg border border-border p-4 text-left transition-colors hover:border-primary hover:bg-accent/50 focus-visible:ring-1 focus-visible:ring-purple-200 focus-visible:outline-1 dark:border-grey-700 dark:hover:border-violet-300`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[(0,K.jsx)(e,{className:`size-4 text-primary dark:text-violet-300`}),t]}),(0,K.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:n}),(0,K.jsxs)(`span`,{className:`mt-1 text-sm text-primary group-hover:underline dark:text-violet-300`,children:[r,` →`]})]})}var YV={text:`Text`,number:`Numbers`,date:`Dates`,boolean:`Booleans`};function XV({id:e}){return(0,K.jsxs)(`section`,{id:e,"aria-label":`Filter syntax`,className:`mx-4 mb-3 rounded-md border border-border p-3 text-sm [font-variant-ligatures:none]`,children:[(0,K.jsx)(`dl`,{className:`grid gap-x-6 gap-y-2 sm:grid-cols-2 lg:grid-cols-4`,children:Object.keys(ZL).map(e=>(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{className:`font-semibold`,children:YV[e]}),ZL[e].map(e=>(0,K.jsx)(`dd`,{className:`font-mono text-xs`,children:e},e))]},e))}),(0,K.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`A relationship column filters on a property of the related table:`,` `,(0,K.jsx)(`code`,{children:`.name Anvil`}),`. A filter that no index can answer (a column marked “not indexed”, an ends with, a contains or a !=) asks before it runs, unless another filter in it uses an index.`]})]})}function ZV({columns:e,columnVisibility:t,setColumnVisibility:n}){let r=(0,G.useMemo)(()=>e.map(e=>typeof e.header==`string`?e.header:void 0).filter(fr),[e]),i=(0,G.useCallback)((e,r)=>{n({...t,[e]:r})},[t,n]),a=(0,G.useCallback)(e=>{n({...t,...Object.fromEntries(r.map(t=>[t,e]))})},[r,t,n]),o=(0,G.useMemo)(()=>r.every(e=>t[e]??!0),[r,t]),s=(0,G.useMemo)(()=>r.every(e=>!(t[e]??!0)),[r,t]);return(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsxs)(H,{variant:`ghost`,children:[(0,K.jsx)(Qi,{className:`inline-block `}),`Columns`]})}),(0,K.jsxs)(vc,{children:[r.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(yc,{inset:!0,disabled:o,onSelect:e=>{e.preventDefault(),a(!0)},children:`Select all`}),(0,K.jsx)(yc,{inset:!0,disabled:s,onSelect:e=>{e.preventDefault(),a(!1)},children:`Deselect all`}),(0,K.jsx)(wc,{})]}),r.map(e=>(0,K.jsx)(QV,{columnHeader:e,isChecked:t[e]??!0,toggleColumn:i},e))]})]})}function QV({columnHeader:e,isChecked:t,toggleColumn:n}){let r=(0,G.useCallback)(t=>{n(e,t)},[e,n]);return(0,K.jsx)(bc,{checked:t,onCheckedChange:r,onSelect:e=>e.preventDefault(),children:e})}function $V({className:e}){return(0,K.jsx)(no,{className:v(`animate-spin`,e)})}var eH=32,tH=`shadow-[inset_-1px_0_0_var(--color-border)]`;function nH(e,t){return!t||typeof e!=`object`||!e||!Object.hasOwn(e,t)?void 0:e[t]??void 0}function rH({applyFilters:e,columnFiltersForm:t,columns:n,columnVisibility:r,columnSizing:i,setColumnSizing:a,data:o,emptyState:s,isFetching:c,onColumnClick:l,onRowClick:u,pageIndex:d,pageSize:f,primaryKey:p,rowSelection:m,resultSetKey:h,tableIdentity:g,setPageIndex:_,setPageSize:v,filtersToggled:y,totalPages:b,totalRecords:x,uncountedPage:S,isEstimatedCount:C,estimatedRange:w,isExactCountFetching:T,isExactCountError:E,onRequestExactCount:D}){let O=tt({features:Lb,data:o||[],columns:n,manualSorting:!0,enableColumnResizing:!0,columnResizeMode:`onEnd`,onColumnSizingChange:a,defaultColumn:{minSize:80},state:{columnVisibility:r,columnSizing:i}}),k=!!m&&!!p,A=(0,G.useMemo)(()=>k?(o??[]).map(e=>nH(e,p)).filter(e=>e!==void 0):[],[k,o,p]),j=m?A.filter(e=>m.selectedKeys.has(e)).length:0,M=A.length>0&&j===A.length,ee=j>0&&!M,[te,N]=(0,G.useState)(void 0),P=(0,G.useCallback)((e,t)=>{if(!m)return;let n=t?A.indexOf(te):-1,r=A.indexOf(e);if(n===-1||r===-1){m.toggleRow(e),N(e);return}let[i,a]=n<=r?[n,r]:[r,n];m.setRangeSelected(A.slice(i,a+1),!m.selectedKeys.has(e))},[m,A,te]),ne=(0,G.useRef)(null),re=(0,G.useRef)(!1),ie=(0,G.useRef)(!1),ae=(0,G.useCallback)((e,t)=>{!m||e===void 0||t.button!==0||t.shiftKey||t.ctrlKey||t.metaKey||(re.current=!0,ne.current={originKey:e,selected:!m.selectedKeys.has(e),snapshot:new Set(m.selectedKeys),applied:[],lastKey:e})},[m]),oe=(0,G.useCallback)((e,t)=>{let n=ne.current;if(!n)return;if(!(t&1)){ne.current=null;return}if(!m||e===void 0||e===n.lastKey)return;let r=A.indexOf(n.originKey),i=A.indexOf(e);if(r===-1||i===-1)return;n.lastKey=e;let[a,o]=r<=i?[r,i]:[i,r],s=A.slice(a,o+1),c=new Set(s),l=n.applied.filter(e=>!c.has(e)),u=l.filter(e=>n.snapshot.has(e)),d=l.filter(e=>!n.snapshot.has(e));u.length&&m.setRangeSelected(u,!0),d.length&&m.setRangeSelected(d,!1),m.setRangeSelected(s,n.selected),n.applied=s,N(n.originKey),ie.current=!0},[m,A]);(0,G.useEffect)(()=>{let e=()=>{ne.current=null},t=()=>{re.current=!1,ie.current=!1};return window.addEventListener(`mouseup`,e),window.addEventListener(`mousedown`,t,!0),()=>{window.removeEventListener(`mouseup`,e),window.removeEventListener(`mousedown`,t,!0)}},[]),(0,G.useLayoutEffect)(()=>{N(void 0),ne.current=null},[h]);let se=(0,G.useRef)(null),[ce,le]=(0,G.useState)(0);(0,G.useLayoutEffect)(()=>{let e=se.current;e&&(e.scrollTop=0)},[h]),(0,G.useLayoutEffect)(()=>{let e=se.current;e&&(e.scrollTop=0,e.scrollLeft=0)},[g]);let ue=O.state.columnResizing,de=ue.isResizingColumn;(0,G.useLayoutEffect)(()=>{de&&le(se.current?.scrollLeft??0)},[de]);let fe=null;if(de){let e=O.options.defaultColumn?.minSize??20,t=O.getColumn(de)?.getSize()??0,n=k?eH:0;for(let e of O.getVisibleLeafColumns())if(n+=e.getSize(),e.id===de)break;fe=n+Math.max(ue.deltaOffset??0,e-t)-ce}let pe=O.getRowModel().rows.length>0,me=o===void 0,he=!pe&&!me&&!!s;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`relative flex flex-col grow min-h-0`,children:[(0,K.jsxs)(bb,{containerRef:se,containerClassName:F(`rounded-t-md bg-card dark:bg-black-dark min-h-0 overflow-y-auto`,he?`shrink-0`:`rounded-b-md grow`),className:`table-fixed`,children:[(0,K.jsx)(xb,{children:O.getHeaderGroups().map(e=>(0,K.jsxs)(Cb,{className:`border-none`,children:[k&&(0,K.jsx)(wb,{style:{width:`${eH}px`},className:F(`sticky top-0 left-0 z-20 p-0 bg-card dark:bg-black-dark border-b border-border`,tH),children:(0,K.jsx)(iH,{checked:M,indeterminate:ee,disabled:A.length===0,onToggle:()=>{m.toggleAll(A,!M),N(M?void 0:A[0])}})}),e.headers.map(e=>(0,K.jsx)(Tb,{header:e,onColumnClick:l,className:`sticky top-0 z-10 bg-card dark:bg-black-dark border-b border-border font-mono text-[0.8rem] [&_button]:text-[0.8rem]`},e.id)),(0,K.jsx)(wb,{"aria-hidden":!0,className:`w-full p-0 sticky top-0 z-10 bg-card dark:bg-black-dark border-b border-border`})]},e.id))}),y&&(0,K.jsx)(VV,{applyFilters:e,columnFiltersForm:t,headerGroups:O.getHeaderGroups(),selectColumnWidth:k?eH:void 0}),!he&&(0,K.jsx)(Sb,{className:`bg-background dark:bg-black border-y border-border dark:border-grey-700`,children:pe?O.getRowModel().rows.map(e=>(0,K.jsx)(oH,{row:e,onRowClick:u,primaryKey:p,rowSelection:k?m:void 0,onSelectRow:P,onBeginDrag:ae,onDragOver:oe,pressedInGutterRef:re,dragMovedRef:ie},e.id)):(0,K.jsx)(Cb,{children:(0,K.jsx)(Eb,{colSpan:n.length+1+ +!!k,className:`h-24 text-center`,children:c||me?(0,K.jsx)($V,{className:`opacity-50 inline-block`}):(0,K.jsx)(`span`,{children:`No results.`})})})})]}),he&&(0,K.jsx)(`div`,{className:`grow min-h-0 rounded-b-md bg-background dark:bg-black border border-t-0 border-border dark:border-grey-700`,children:s}),fe!==null&&(0,K.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute top-0 bottom-0 z-20 w-0.5 bg-primary`,style:{left:`${fe}px`}})]}),(0,K.jsx)(Ob,{pageIndex:d,pageSize:f,totalPages:b,totalRecords:x,uncountedPage:S,isEstimatedCount:C,estimatedRange:w,isExactCountFetching:T,isExactCountError:E,onRequestExactCount:D,setPageIndex:_,setPageSize:v})]})}function iH({checked:e,indeterminate:t,disabled:n,onToggle:r}){let i=(0,G.useRef)(null);return(0,G.useLayoutEffect)(()=>{i.current&&(i.current.indeterminate=t)},[t]),(0,K.jsx)(aH,{children:(0,K.jsx)(`input`,{ref:i,type:`checkbox`,"aria-label":e?`Deselect all records on this page`:`Select all records on this page`,checked:e,disabled:n,onChange:r})})}function aH({children:e}){return(0,K.jsx)(`label`,{className:`flex h-full w-full items-center justify-center py-2`,children:e})}function oH({row:e,primaryKey:t,onRowClick:n,rowSelection:r,onSelectRow:i,onBeginDrag:a,onDragOver:o,pressedInGutterRef:s,dragMovedRef:c}){let l=e.getVisibleCells(),u=(0,G.useMemo)(()=>{let n=e.original;return n&&n.message===`This entry has expired`?l[0]?.column?.id===t?[(0,K.jsx)(cH,{cell:l[0]},l[0].id),(0,K.jsx)(lH,{colSpan:l.length-1},`expired`)]:[(0,K.jsx)(lH,{colSpan:l.length},`expired`)]:l.map(e=>(0,K.jsx)(cH,{cell:e},e.id))},[e,t,l]),d=r?nH(e.original,t):void 0,f=d!==void 0&&!!r?.selectedKeys.has(d);return(0,K.jsxs)(Cb,{"data-state":f?`selected`:void 0,onMouseOver:e=>o?.(d,e.buttons),onMouseDown:e=>{r&&e.shiftKey&&e.preventDefault()},onClick:t=>{if(!s?.current){if(r&&d!==void 0&&(t.ctrlKey||t.metaKey||t.shiftKey)){t.preventDefault(),i?.(d,t.shiftKey);return}n?.(e)}},className:F(`hover:bg-muted/10 data-[state=selected]:bg-muted`,n&&`cursor-pointer`),children:[r&&(0,K.jsx)(Eb,{className:F(`sticky left-0 z-10 p-0`,tH,f?`bg-muted`:`bg-background dark:bg-black`),onClick:KL,onMouseDown:e=>{e.preventDefault(),e.currentTarget.querySelector(`input`)?.focus(),a?.(d,e)},children:(0,K.jsx)(aH,{children:(0,K.jsx)(`input`,{type:`checkbox`,"aria-label":f?`Deselect record`:`Select record`,checked:f,disabled:d===void 0,onClick:e=>{c?.current&&e.detail!==0||d===void 0||i?.(d,e.shiftKey)},onChange:sH})})}),u,(0,K.jsx)(Eb,{"aria-hidden":!0,className:`p-0`})]})}function sH(){}function cH({cell:e}){let t=e.column.getSize();return(0,K.jsx)(Eb,{"data-col-id":e.column.id,style:{width:`${t}px`,maxWidth:`${t}px`},className:`px-2 py-2 font-mono text-[0.8rem] overflow-hidden text-ellipsis whitespace-nowrap`,children:ot(e.column.columnDef.cell,e.getContext())})}function lH({colSpan:e}){return(0,K.jsx)(Eb,{colSpan:e,className:`px-2 py-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,children:(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`This entry has expired`})})}var uH=new Set,dH=[],fH=[];function pH({instanceDatabaseMap:e,instanceDatabaseMapLoading:t=!1,databaseName:n,tableName:r}){let i=z({strict:!1}),a=q(),{clusterId:o,instanceId:s}=i,{toggled:c,toggle:l}=SV(!0),u=wr(`instance:update`),d=Tg(s??o,n,r,`insert`),f=Dg(s??o,n,r),p=kg(),m=Tg(s??o,n,r,`update`),h=Tg(s??o,n,r,`delete`),g=wg(),{data:_}=L(WL({...a,databaseName:n,tableName:r})),v=e?.[n],y=v?.[r],b=_??y,x=f&&p.methods.file,S=f&&p.methods.url,C=f&&p.allowsSource(`csv-data`),w=(0,G.useMemo)(()=>O_(b?.attributes??[],`attribute`),[b]),{data:T,isLoading:E}=L(PF(a)),{data:D}=L(HE(a)),O=Eg(s??o,n,r),k=NV(D?.version,O),A=k===void 0,j=T?.[n]?.[r],M=(0,G.useMemo)(()=>xL(y?.attributes,v,j),[y,v,j]),ee=f&&p.allowsSource(`json-records`)&&M.length>0,te=(0,G.useMemo)(()=>VF(b,v,j),[b,v,j]),N=(0,G.useMemo)(()=>KF(b,v),[b,v]),P=(0,G.useMemo)(()=>UF(b?.attributes,v,j),[b,v,j]),[F,ne]=xV(null,i),[re,ie]=(0,G.useState)(!1),[ae,se]=xV(null,i),[ce,le]=xV(null,i),[ue,de]=(0,G.useState)(null),fe=ue!==null,pe=(0,G.useMemo)(()=>g&&!!v&&Object.keys(v).length>1,[g,v]),{toggled:me,toggleOn:he,toggleOff:ge}=SV(!1),{toggled:_e,toggle:ve}=SV(!1),ye=on({resolver:mt(BV)}),{reset:be}=ye,xe=ye.watch(),[Se,Ce]=xV(null,[i.clusterId,i.instanceId,n,r]),[we,I]=xV(!1,[i.clusterId,i.instanceId,n,r]),Te=(0,G.useCallback)(e=>{let t=[];for(let n in e){let r=e[n];if(r?.length)try{t.push(...qR(n,r,w[n],Object.hasOwn(te,n)?te[n]:void 0))}catch(e){U.error(String(e))}}return t},[w,te]),Ee=(0,G.useCallback)(e=>{let t=pV(e,w,te);return t.length&&!confirm(mV(r,t))?!1:(I(t.length>0),Ce(e.length?e:null),!0)},[w,te,r,I,Ce]),De=(0,G.useCallback)(()=>{Ee(Te(xe))&&be({...xe})},[Ee,Te,be,xe]),R=(0,G.useCallback)(()=>{be({},{keepValues:!1,keepDirtyValues:!1,keepDefaultValues:!1}),be(),Ce(null),I(!1),ge()},[ge,be,Ce,I]);(0,G.useEffect)(function(){return R()},[i,R]);let{filters:ke}=Oe({strict:!1}),Ae=JSON.stringify([n,r,ke??null]),je=(0,G.useRef)(null);(0,G.useEffect)(function(){if(!b||je.current===Ae||ke&&(E||t))return;let e=je.current===null;je.current=Ae,ke?(Ee(Te(ke))?be({...ke}):be({...ke},{keepDefaultValues:!0}),he()):e||R()},[ke,Ae,b,E,t,be,Te,Ee,he,R]);let Me=cR(b),Ne=!b||!!Me,[B,Pe]=xV(null,i),Fe=(0,G.useMemo)(()=>B??{attribute:Me,descending:!1},[B,Me]),[Ie,Le]=xV(0,[n,r,Se]),[Re,ze]=(0,G.useState)(20),[Be,Ve]=xV(null,[n,r,Se,Re,c]),He=_?.record_count??y?.record_count,Ue=_?.estimated_record_range??y?.estimated_record_range,[We,Ge]=xV(!1,[n,r]),{data:Ke,isFetching:qe,isError:Je,refetch:Ye}=L(jV({...a,enabled:We,databaseName:n,tableName:r})),Xe=(0,G.useCallback)(()=>{We?Ye():Ge(!0)},[We,Ye,Ge]),Qe=Ke??He,$e=Qe&&Ne?Math.ceil(Qe/Re):0,et=Ke===void 0&&Ue!==void 0,tt=me&&!!Se,nt=JSON.stringify([n,r]),rt=JSON.stringify([a.entityId,n,r,Ie,Re,Fe,tt?Se:null,c]),[it,at]=xV(uH,[rt]),ot=(0,G.useCallback)(e=>{at(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})},[at]),st=(0,G.useCallback)((e,t)=>{at(t?new Set(e):uH)},[at]),ct=(0,G.useCallback)((e,t)=>{at(n=>{let r=new Set(n);for(let n of e)t?r.add(n):r.delete(n);return r})},[at]),lt=(0,G.useMemo)(()=>h?{selectedKeys:it,toggleRow:ot,toggleAll:st,setRangeSelected:ct}:void 0,[h,it,ot,st,ct]),ut=Fw({...a,enabled:!tt&&!!Me,databaseName:n,tableName:r,searchAttribute:Me,sort:Fe,pageSize:Re,pageIndex:Ie,onlyIfCached:c,getAttributes:N}),{data:dt,isFetching:ft,isError:pt}=L(ut),ht=WR({...a,enabled:tt&&!!Me,databaseName:n,tableName:r,conditions:Se,sort:Fe,pageSize:Re,pageIndex:Ie,onlyIfCached:c,getAttributes:N,allowFullScan:we}),{data:gt,isFetching:_t,isError:vt}=L(ht),yt=tt?gt:dt,bt=ft||_t,xt=tt?vt:pt,St=yt?.data,Ct=(0,G.useMemo)(()=>new Set([...(b?.attributes??[]).map(({attribute:e})=>e),...Object.keys(te)]),[b,te]),wt=(0,G.useMemo)(()=>St&&fR(St,Ct),[St,Ct]),Tt=JSON.stringify([a.entityId,n,r]),[Et,Dt]=(0,G.useState)({key:Tt,extras:fH});wt&&(Et.key!==Tt||!pR(Et.extras,wt))&&Dt({key:Tt,extras:wt});let{dataTableColumns:Ot}=sR(b,te,wt??(Et.key===Tt?Et.extras:fH)),kt=tt?{rowCount:gt?.data.length,hasNextPage:gt?.hasNextPage}:void 0,At=kt?!!kt.hasNextPage:!!St&&St.length===Re&&Be!==Ie,jt=(0,G.useMemo)(()=>(St??[]).map(e=>nH(e,Me)).filter(e=>e!==void 0&&it.has(e)),[St,Me,it]),{data:Mt,isFetching:Nt,isError:Pt}=L(jL({...a,enabled:re,databaseName:n,tableName:r,ids:F})),Ft=re&&!fe&&!!ae&&(!Me||ae[Me]==null),It=Mt?.data,Lt=!Ft&&!fe&&!!F?.length&&!Nt&&(Pt||Array.isArray(It)&&It.length===0),{mutate:Rt,isPending:zt}=zV(),{mutate:Bt,isPending:Vt}=kV(),{mutate:Ht,isPending:Ut}=IV(),{mutate:Wt,isPending:Gt}=wV(),Kt=Ze(),qt=(0,G.useCallback)(()=>(Ve(null),at(uH),Kt.invalidateQueries({queryKey:[a.entityId,n,r]})),[Kt,a.entityId,n,r,Ve,at]),Jt=(0,G.useCallback)(()=>Kt.invalidateQueries({queryKey:AL(a.entityId,n,r)}),[Kt,a.entityId,n,r]),Yt=(0,G.useCallback)(async()=>{confirm(`Are you sure you want to cleanup orphan blobs for database "${n}"?`)&&Wt({...a,databaseName:n},{onSuccess:e=>{U.success(e.message||`Orphan blobs cleanup started successfully`),qt()},onError:e=>{pc(e)&&U.error(e instanceof Error?e.message:`Failed to cleanup orphan blobs`)}})},[Wt,n,a,qt]),{exportCsv:Xt,isExporting:Zt}=$R(),Qt=(0,G.useCallback)(()=>{Xt({databaseName:n,tableName:r,primaryKey:Me,sort:Fe,conditions:tt?Se:null,allowFullScan:tt&&we,instanceTable:b,databaseTables:v})},[Xt,n,r,Me,Fe,tt,Se,we,b,v]),$t=(0,G.useCallback)(e=>{if(e?.wroteNothing){U.error(`The record wasn't updated`,{description:e.message});return}if(qt(),Jt(),ie(!1),e){U.error(`The record wasn't fully updated`,{description:e.message});return}U.success(`Record updated successfully`)},[qt,Jt]),en=(0,G.useCallback)(e=>{Rt({...a,databaseName:n,tableName:r,records:e},{onSuccess:t=>$t(LV(t,e.length))})},[Rt,a,n,r,$t]),tn=(0,G.useCallback)(e=>{Ht({...a,databaseName:n,tableName:r,records:e},{onSuccess:t=>$t(FV(t,e.length))})},[Ht,a,n,r,$t]),nn=(0,G.useCallback)(e=>{Bt({...a,databaseName:n,tableName:r,hashValues:e},{onSuccess:t=>{let n=DV(t,e.length);if(n?.wroteNothing){U.error(`The record wasn't deleted`,{description:n.message});return}if(qt(),Jt(),ie(!1),n){U.error(`The record wasn't fully deleted`,{description:n.message});return}U.success(`Record deleted successfully`)}})},[Bt,a,n,r,qt,Jt]),rn=(0,G.useCallback)(()=>{let e=jt;e.length&&confirm(`Permanently delete ${oe(e.length,`record`,`records`)} from "${r}"?`)&&Bt({...a,databaseName:n,tableName:r,hashValues:e},{onSuccess:t=>{qt(),Jt();let n=DV(t,e.length);if(n){U.error(`The records weren't all deleted`,{description:n.message});return}U.success(`${oe(e.length,`record`,`records`)} deleted successfully`)}})},[Bt,a,n,r,qt,Jt,jt]),an=(0,G.useCallback)((e,t)=>{let n=Me?t[Me]:void 0;se(t),ne(n==null?null:[n]),le(e)},[Me,se,ne,le]),sn=(0,G.useCallback)(e=>{if(ce===null||!St)return;let t=ce+e,n=St[t];if(n){an(t,n);return}let r=Ie+e;r<0||(Le(r),de({end:e===1?`first`:`last`,fromPage:Ie}))},[ce,St,an,Ie,Le]);(0,G.useEffect)(function(){if(!ue)return;if(!re){de(null);return}let e=ue.end===`first`?0:(St?.length??0)-1,t=e>=0?St?.[e]:void 0;if(t){de(null),an(e,t);return}if(St||xt){if(de(null),Le(ue.fromPage),xt){U.error(`Couldn't load the next page of records`);return}if(ue.end===`first`){Ve(ue.fromPage),U.info(`This is the last record`);return}U.info(`This is the first record`)}},[ue,St,xt,re,an,Le,Ve]);let cn=e=>{an(e.index,e.original),ie(!0)},ln=(e,t)=>{Pe({attribute:e,descending:!t})},un=Kb(qt),dn=(0,G.useCallback)(()=>{rL(`ShowAddTableRecords`,{databaseName:n,tableName:r})},[n,r]),fn=(0,G.useCallback)(()=>{rL(`ShowImportData`,{databaseName:n,tableName:r})},[n,r]),pn=(0,G.useCallback)(()=>{rL(`ShowImportData`,{databaseName:n,tableName:r,method:x?`file`:`url`})},[n,r,x]),mn=(0,G.useCallback)(()=>{rL(`ShowImportData`,{databaseName:n,tableName:r,method:`sample`})},[n,r]),[hn,gn]=FC(`ColumnDisplayed/${n}/${r}`,{}),_n=(0,G.useMemo)(()=>({...Object.fromEntries(GF(te).map(e=>[e,!1])),...hn}),[te,hn]),vn=ce===null?void 0:{position:fe?void 0:Ie*Re+ce+1,total:kt?kb(Ie,Re,kt):Qe,isTotalEstimated:!kt&&et,hasPrevious:!fe&&(ce>0||Ie>0),hasNext:!fe&&!!St&&(ce+1<St.length||At),onPrevious:()=>sn(-1),onNext:()=>sn(1)},[yn,bn]=FC(`ColumnSizing/${n}/${r}`,{});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`shrink-0 flex flex-col md:flex-row md:flex-wrap items-center justify-between gap-3 pt-15 pb-4 px-4`,children:[(0,K.jsxs)(`div`,{className:`flex space-x-2`,children:[d&&Ne&&(0,K.jsxs)(H,{variant:`positiveOutline`,onClick:dn,accessKey:`n`,children:[(0,K.jsx)(Uo,{}),(0,K.jsxs)(`span`,{children:[`Add `,(0,K.jsx)(`u`,{children:`N`}),`ew Record(s)`]})]}),h&&jt.length>0&&(0,K.jsxs)(H,{variant:`destructiveOutline`,onClick:rn,disabled:Vt,children:[(0,K.jsx)(Is,{className:`text-destructive`}),(0,K.jsxs)(`span`,{children:[`Delete Selected (`,jt.length,`)`]})]})]}),(0,K.jsxs)(`div`,{className:`flex space-x-2`,children:[me&&Se&&(0,K.jsxs)(H,{type:`button`,variant:`ghost`,onClick:R,accessKey:`f`,children:[(0,K.jsx)(Sa,{className:`inline-block `}),(0,K.jsxs)(`span`,{children:[`Clear `,(0,K.jsx)(`u`,{children:`F`}),`ilters`]})]}),me&&ye.formState.isDirty&&(0,K.jsxs)(H,{variant:`default`,onClick:De,children:[(0,K.jsx)(ba,{className:`inline-block `}),`Apply Filters`]}),me&&!Se&&(0,K.jsxs)(H,{variant:`ghost`,onClick:ge,accessKey:`f`,children:[(0,K.jsx)(Sa,{className:`inline-block `}),(0,K.jsxs)(`span`,{children:[`Hide `,(0,K.jsx)(`u`,{children:`F`}),`ilters`]})]}),me&&(0,K.jsxs)(H,{variant:`ghost`,onClick:ve,"aria-expanded":_e,"aria-controls":`filter-syntax-help`,children:[(0,K.jsx)(Pi,{className:`inline-block `}),`Filter Syntax`]}),!me&&Ne&&(0,K.jsxs)(H,{variant:`ghost`,onClick:he,accessKey:`f`,children:[(0,K.jsx)(wa,{className:`inline-block `}),(0,K.jsxs)(`span`,{children:[`Show `,(0,K.jsx)(`u`,{children:`F`}),`ilters`]})]}),(0,K.jsx)(H,{variant:`defaultOutline`,onClick:un,disabled:bt,children:(0,K.jsx)(Go,{"aria-label":`Refresh table`,role:`img`})}),(0,K.jsx)(ZV,{columns:Ot,columnVisibility:_n,setColumnVisibility:gn}),(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsx)(H,{variant:`ghost`,size:`icon`,children:(0,K.jsx)(ua,{"aria-label":`Table options`})})}),(0,K.jsxs)(vc,{side:`bottom`,align:`end`,children:[f&&Ne&&(0,K.jsxs)(yc,{onClick:fn,children:[(0,K.jsx)(Ji,{}),`Import Data`]}),(0,K.jsxs)(yc,{onClick:Qt,disabled:Zt||!Ne,children:[(0,K.jsx)(Ki,{}),`Export CSV`]}),(0,K.jsx)(wc,{}),(0,K.jsxs)(yc,{className:`focus:bg-primary/70 focus:text-white`,onClick:l,children:[c?(0,K.jsx)(Ei,{className:`text-green`}):(0,K.jsx)(Ii,{}),`Only If Cached`,(0,K.jsx)(V,{to:`https://docs.harperdb.io/docs/developers/applications/caching#cache-control-header`,target:`_blank`,rel:`noopener noreferrer`,onClick:KL,children:(0,K.jsx)(fa,{})})]}),g&&u&&!!s&&(0,K.jsxs)(yc,{className:`focus:bg-yellow/70 focus:text-white`,onClick:Yt,disabled:Gt,children:[(0,K.jsx)(ci,{className:`text-yellow `}),`Cleanup Orphan Blobs`]}),g&&(0,K.jsx)(wc,{}),pe&&(0,K.jsxs)(yc,{className:`focus:bg-red/70 focus:text-white`,onClick:()=>rL(`ShowDeleteTable`,{databaseName:n,tableName:r}),children:[(0,K.jsx)(Is,{className:`inline-block `}),`Drop Table`]}),g&&(0,K.jsxs)(yc,{className:`focus:bg-red/70 focus:text-white`,onClick:()=>rL(`ShowDeleteDatabase`,{databaseName:n}),children:[(0,K.jsx)(Is,{}),`Drop Database`]})]})]})]})]}),me&&_e&&(0,K.jsx)(XV,{id:`filter-syntax-help`}),(0,K.jsx)(rH,{primaryKey:Me,data:Ne?St:dH,emptyState:(0,K.jsx)(UV,{tableName:r,hasPrimaryKey:Ne,isFiltered:tt,isPastFirstPage:Ie>0,recordCount:Qe,canImportFile:x,canImportUrl:S,canSeedSample:C,canSeedRandom:ee,canAddRecords:d,onImport:pn,onSeed:mn,onAddRecords:dn,onClearFilters:R}),isFetching:bt,filtersToggled:me,columns:Ot,columnVisibility:_n,columnSizing:yn,setColumnSizing:bn,onRowClick:cn,onColumnClick:ln,rowSelection:lt,totalPages:$e,totalRecords:Qe,uncountedPage:kt,isEstimatedCount:et,estimatedRange:Ue,isExactCountFetching:qe,isExactCountError:Je,onRequestExactCount:Xe,pageIndex:Ie,pageSize:Re,resultSetKey:rt,tableIdentity:nt,columnFiltersForm:ye,applyFilters:De,setPageIndex:Le,setPageSize:ze}),(0,K.jsx)(vV,{canEditRecords:m,canDeleteRecords:h,canReplaceRecords:A,replaceBlockedReason:k,setIsModalOpen:ie,isModalOpen:re,primaryKey:Me,missingPrimaryKey:Ft,recordUnavailable:Lt,syntheticAttributes:P,recordNavigation:vn,data:fe?void 0:Ft||Lt?ae?[ae]:void 0:Mt?.data,onSaveChanges:en,onReplaceRecord:tn,onDeleteRecord:nn,isUpdateTableRecordsPending:zt||Ut,isDeleteTableRecordsPending:Vt})]})}function mH(e,t){if(!e)return null;if(!(t.databaseName&&e[t.databaseName])){let n=Object.keys(e).sort()[0];return n&&n!==t.databaseName?{databaseName:n,tableName:void 0}:null}return t.tableName&&!e[t.databaseName][t.tableName]?{databaseName:t.databaseName,tableName:void 0}:null}var hH=10;function gH(e,t){return Math.max(e,Math.floor(t/2))}function _H(e,t,{minWidth:n,defaultWidth:r}){return Math.round(Math.min(Math.max(Number.isFinite(e)?e:r,n),gH(n,t)))}function vH({storageKey:e,defaultWidth:t,minWidth:n,cssVariable:r}){let[i,a]=Zc(e,t),o=(0,G.useRef)(i);(0,G.useLayoutEffect)(()=>{o.current=i},[i]);let s=(0,G.useMemo)(()=>({minWidth:n,defaultWidth:t}),[n,t]),c=(0,G.useCallback)(e=>_H(e,window.innerWidth,s),[s]),[l,u]=(0,G.useState)(()=>c(i)),d=(0,G.useRef)(l),f=(0,G.useCallback)(e=>{d.current=e,u(e)},[]),[p,m]=(0,G.useState)(!1),h=(0,G.useRef)(null),g=(0,G.useRef)(new Set),_=(0,G.useCallback)(e=>{let t=`${e}px`;for(let e of g.current)e.style.setProperty(r,t)},[r]),v=(0,G.useCallback)(e=>{if(e)return g.current.add(e),e.style.setProperty(r,`${h.current?.liveWidth??d.current}px`),()=>{g.current.delete(e)}},[r]);(0,G.useLayoutEffect)(()=>_(l),[_,l]),(0,G.useEffect)(()=>{let e=()=>{let e=h.current;e?(e.liveWidth=c(e.dragWidth??o.current),_(e.liveWidth)):f(c(o.current))};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[c,_,f]);let y=(0,G.useCallback)(e=>{if(e.button!==0||h.current)return;e.preventDefault();let t=e.currentTarget;h.current={pointerId:e.pointerId,target:t,startX:e.clientX,startWidth:d.current,dragWidth:null,liveWidth:d.current};try{t.setPointerCapture?.(e.pointerId)}catch{}m(!0)},[]);(0,G.useEffect)(()=>{if(!p)return;let e=e=>{let t=h.current;if(!t)return;h.current=null,t.target.hasPointerCapture?.(t.pointerId)&&t.target.releasePointerCapture(t.pointerId);let n=e&&t.dragWidth!==null&&t.dragWidth!==t.startWidth?t.dragWidth:null,r=c(n??o.current);_(r),f(r),n!==null&&a(n),m(!1)},t=e=>{let t=h.current;t?.pointerId===e.pointerId&&(t.dragWidth=c(t.startWidth+(e.clientX-t.startX)),t.liveWidth=t.dragWidth,_(t.liveWidth))},n=t=>{h.current?.pointerId===t.pointerId&&e(!0)},r=t=>{h.current?.pointerId===t.pointerId&&e(!1)},i=()=>e(!1),s=document.body.style.userSelect;return document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,t),window.addEventListener(`pointerup`,n),window.addEventListener(`pointercancel`,r),window.addEventListener(`lostpointercapture`,r),window.addEventListener(`blur`,i),()=>{document.body.style.userSelect=s,window.removeEventListener(`pointermove`,t),window.removeEventListener(`pointerup`,n),window.removeEventListener(`pointercancel`,r),window.removeEventListener(`lostpointercapture`,r),window.removeEventListener(`blur`,i)}},[p,c,_,f,a]);let b=(0,G.useCallback)(e=>{let t=e.key===`ArrowLeft`?-10:e.key===`ArrowRight`?hH:0;if(!t)return;e.preventDefault();let n=c(d.current+t);n!==d.current&&(f(n),a(n))},[c,f,a]);return{width:l,minWidth:n,maxWidth:gH(n,window.innerWidth),isResizing:p,sidebarRef:v,startResizing:y,handleKeyDown:b}}var yH={storageKey:_r.DatabasesSidebarWidth,defaultWidth:320,minWidth:200,cssVariable:`--db-sidebar-width`};function bH(){return vH(yH)}function xH(){let e=z({strict:!1}),t=q(),{data:n,isLoading:r}=L(Ij({...t,skipRecordCount:!0,includeComputed:!0})),{width:i,minWidth:a,maxWidth:o,isResizing:s,sidebarRef:c,startResizing:l,handleKeyDown:u}=bH(),d=mH(n,e);return d?(0,K.jsx)(qe,{to:jP({...e,...d}),replace:!0}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`main`,{className:`flex flex-col gap-4 md:gap-0 md:flex-row md:items-start`,children:[(0,K.jsxs)(`section`,{ref:c,className:`relative text-foreground w-full md:w-[var(--db-sidebar-width)] md:shrink-0 md:border-r-2 border-border flex flex-col min-h-0 md:sticky md:top-32 md:h-[calc(100vh-(--spacing(32)))] md:max-h-[calc(100vh-(--spacing(32)))] overflow-y-clip`,children:[(0,K.jsx)(dV,{instanceDatabaseMap:n}),(0,K.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,"aria-valuenow":i,"aria-valuemin":a,"aria-valuemax":o,onPointerDown:l,onKeyDown:u,className:`group hidden md:block absolute top-0 bottom-0 left-full w-2 z-40 cursor-col-resize touch-none outline-none`,children:(0,K.jsx)(`div`,{className:F(`absolute inset-y-0 left-0 w-1 -translate-x-1/2 transition-colors`,`group-hover:bg-violet-400/60 dark:group-hover:bg-violet-500/60 group-focus-visible:bg-violet-500/80`,s&&`bg-violet-400/60 dark:bg-violet-500/60`)})})]}),(0,K.jsx)(`section`,{className:`text-foreground w-full md:flex-1 md:min-w-0 flex flex-col min-h-0 h-[calc(100vh-(--spacing(32)))]`,children:e.databaseName&&e.tableName?(0,K.jsx)(pH,{instanceDatabaseMap:n,instanceDatabaseMapLoading:r,databaseName:e.databaseName,tableName:e.tableName}):e.databaseName?(0,K.jsx)(`div`,{className:`min-h-0 grow overflow-y-auto`,children:(0,K.jsx)(dz,{instanceDatabaseMap:n,databaseName:e.databaseName})}):null})]}),n&&(0,K.jsx)(GL,{instanceDatabaseMap:n})]})}function SH(e){return R({getParentRoute:()=>e,path:`/databases/{-$databaseName}/{-$tableName}`,head:()=>({meta:[{title:`Databases — Harper Fabric`}]}),component:xH})}var CH={className:`text-primary font-semibold bg-primary/10 rounded-md dark:text-white dark:bg-white/10`};function wH(){let e=Cg(),t=z({strict:!1}),{version:n}=Ce({strict:!1}),r=XT(n)&&e,i=vr(`4.7.0-beta.7`,n),a=q(),{data:o}=L(QT(a,r)),s=o?.restartRequired??!1,c=(0,G.useMemo)(()=>[e&&{to:t.clusterId&&!t.instanceId?qg(t,`apps`):qg(t),activeOptions:{exact:!0},name:`Applications`,shortName:`Apps`,icon:(0,K.jsx)(Fo,{className:`inline-block`})},{to:qg(t,`databases`),icon:(0,K.jsx)(ia,{className:`inline-block`}),name:`Databases`},e&&i&&{to:qg(t,`apis`),name:`APIs`,icon:(0,K.jsx)(ss,{className:`inline-block`})},e&&{to:qg(t,`operations`),name:`Operations`,icon:(0,K.jsx)(bs,{className:`inline-block`})},e&&r&&{to:qg(t,`status`),icon:(0,K.jsx)(Ea,{className:`inline-block`}),name:`Status`},e&&{to:qg(t,`logs`),icon:(0,K.jsx)(jo,{className:`inline-block`}),name:`Logs`},e&&{to:qg(t,`config`),icon:(0,K.jsx)(ls,{className:`inline-block`}),name:`Config`}].filter(fr),[e,t,i,r]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(TH,{links:c,restartRequired:s}),(0,K.jsx)(EH,{links:c,restartRequired:s})]})}function TH({links:e,restartRequired:t}){return(0,K.jsxs)(`div`,{className:`hidden md:[@media(hover:hover)]:flex xl:flex items-center justify-between h-full text-sm text-foreground`,children:[(0,K.jsx)(Dd,{restartRequired:t}),(0,K.jsx)(`div`,{className:`flex space-x-2`,children:e.map(({shortName:e,...t})=>{let n=(0,K.jsxs)(V,{"aria-label":t.name,className:`p-2 text-center text-muted-foreground hover:text-foreground`,activeProps:CH,...t,children:[t.icon,(0,K.jsx)(`span`,{className:`hidden xl:inline-block ml-1`,children:t.name}),e&&(0,K.jsx)(`span`,{className:`visible xl:hidden ml-1`,children:e})]},t.to);return e?n:(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:n}),(0,K.jsx)(Xl,{side:`bottom`,className:`xl:hidden`,children:t.name})]},t.to)})})]})}function EH({links:e,restartRequired:t}){return(0,K.jsx)(K.Fragment,{children:(0,K.jsxs)(`div`,{className:`flex md:[@media(hover:hover)]:hidden xl:hidden items-center justify-between h-full px-2 text-foreground`,children:[(0,K.jsx)(Dd,{restartRequired:t}),(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsx)(H,{variant:`ghost`,className:`p-0`,children:(0,K.jsx)(Co,{className:`h-8 w-8`})})}),(0,K.jsxs)(vc,{children:[(0,K.jsx)(Cc,{children:`Instance Menu`}),(0,K.jsx)(wc,{}),e.map(e=>(0,K.jsx)(yc,{asChild:!0,children:(0,K.jsxs)(V,{to:e.to,activeProps:CH,className:`flex items-center gap-2`,children:[e.icon,e.name]})},e.to))]})]})]})})}(0,G.lazy)(()=>pe(()=>import(`./FloatingChat-CFypO7kh.js`).then(e=>({default:e.FloatingChat})),__vite__mapDeps([37,1,2,3,12,26,25])));function DH(){let{instanceId:e,clusterId:t}=z({strict:!1});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`nav`,{className:`studio-subnav fixed top-20 w-full z-39 h-12 md:px-12 bg-violet-50 border-b border-violet-100 dark:bg-grey-700 dark:border-none`,children:(0,K.jsx)(wH,{})}),(0,K.jsxs)(`div`,{className:`mt-32 min-h-[calc(100vh-(--spacing(32)))]`,children:[(0,K.jsx)(m_,{entityId:m,clusterId:t,noun:`instance`,className:`px-4 pt-4 md:px-12`}),(0,K.jsx)(st,{})]}),!1]})}function OH(e){switch(e){case`local`:return R({getParentRoute:()=>Uu,id:`_instanceLayout`,component:DH,loader:kP});case`cluster`:return R({getParentRoute:()=>WC,id:`_instanceLayout`,component:DH,beforeLoad:kH,loader:kP});case`instance`:return R({getParentRoute:()=>WC,path:`instance/$instanceId`,component:DH,beforeLoad:kH,loader:kP})}}async function kH({context:e,params:t}){let n=t.instanceId||t.clusterId,r=!1;if(u.checkForFabricConnect(n)&&!u.hasResolvedFabricConnect(n)&&(r=!0,await AH(n,e.cluster,t.instanceId)))return;u.startSignInCheck(n);let i=u.getConnectionById(n);if(i.isLoading||i.user)return;let a=e.authentication[m];if(!a||a.isLoading)return;let{update:o}=t.instanceId?xg(a.user,t.organizationId,t.clusterId):hg(a.user,t.organizationId,t.clusterId);if(!r&&o&&await AH(n,e.cluster,t.instanceId))return;let s=`/${t.organizationId}/${t.clusterId}/`+(t.instanceId?`instance/${t.instanceId}`:``)+`/sign-in`;throw Ne({to:s,search:Mu()})}async function AH(e,t,n){try{return await u.establishFabricConnectAuth({id:e,operationsUrl:jH(t,n)}),!0}catch(e){return console.debug(`Fabric Connect not established`,e),!1}}function jH(e,t){if(t){let n=e?.instances?.find(e=>e.id===t);return n?p(n):void 0}return c(e)??void 0}function MH(e){switch(e){case`warn`:return`warning`;case`notify`:return`success`;case`info`:case`debug`:case`trace`:case void 0:case`stdout`:return`secondary`;case`stderr`:case`error`:return`destructive`;default:return e}}var NH=[`secondary`,`default`,`warning`,`outline`,`success`,`destructive`],PH=0,FH=new Map,IH=e=>{if(FH.has(e))return FH.get(e);PH++;let t=NH[PH%NH.length];return FH.set(e,t),t};function LH(e){switch(e){case`error`:case`stderr`:return`border-l-destructive`;case`warn`:return`border-l-yellow-500`;case`notify`:return`border-l-green-500`;default:return`border-l-transparent`}}function RH({columns:e,data:t,onRowClick:n,containerRef:r}){let i=tt({features:Lb,data:t,columns:e});return(0,K.jsxs)(bb,{className:`text-xs`,containerRef:r,containerClassName:`rounded-md bg-card dark:bg-black-dark logsTable max-h-[calc(100vh-(--spacing(48)))] overflow-y-auto md:max-h-[calc(100vh-(--spacing(40)))]`,children:[(0,K.jsx)(xb,{children:i.getHeaderGroups().map(e=>(0,K.jsx)(Cb,{className:`border-b border-border`,children:e.headers.map(e=>(0,K.jsx)(wb,{className:`p-4 max-w-96 sticky top-0 z-10 border-b border-border bg-card dark:bg-black-dark`,children:e.isPlaceholder?null:ot(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,K.jsx)(Sb,{className:`bg-background dark:bg-black`,children:i.getRowModel().rows?.length?i.getRowModel().rows.map(e=>(0,K.jsx)(Cb,{"data-state":e.getIsSelected()&&`selected`,className:F(`hover:bg-muted/20 data-[state=selected]:bg-muted max-w-full border-l-2`,LH(e.original.level),n&&`cursor-pointer`),onClick:()=>n?.(e),children:e.getVisibleCells().map(e=>(0,K.jsx)(Eb,{className:`p-2`,children:ot(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,K.jsx)(Cb,{children:(0,K.jsx)(Eb,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})}var zH=524288,BH=class{totalChars=0;spent=!1;get isSpent(){return this.spent}admit(e){return this.spent?{admitted:!1,justExhausted:!1,oversize:!1}:e>524288?{admitted:!1,justExhausted:!1,oversize:!0}:this.totalChars+e>8388608?(this.spent=!0,{admitted:!1,justExhausted:!0,oversize:!1}):(this.totalChars+=e,{admitted:!0,justExhausted:!1,oversize:!1})}};function VH(e){try{JSON.parse(e)}catch{return!1}return!0}function HH(e){return!e||e.length>524288?`plaintext`:VH(e)?`json`:`plaintext`}function UH({label:e,children:t}){return(0,K.jsxs)(`div`,{className:`flex items-start gap-3 py-1.5 border-b border-border/50 last:border-0`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground w-20 shrink-0 pt-0.5`,children:e}),(0,K.jsx)(`span`,{className:`text-xs`,children:t})]})}function WH({setIsModalOpen:e,isModalOpen:t,data:n}){let r=n?IH(n.node):`default`,i=Tx();return(0,K.jsx)(_m,{onOpenChange:e,open:t,children:(0,K.jsxs)(wm,{"aria-describedby":void 0,resizable:!0,children:[(0,K.jsx)(Tm,{children:(0,K.jsx)(Dm,{children:`Log Entry`})}),n?(0,K.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 text-popover-foreground`,children:[(0,K.jsxs)(`div`,{className:`rounded-md border border-border/50 bg-muted/20 px-3 py-1`,children:[(0,K.jsx)(UH,{label:`Level`,children:(0,K.jsx)(ol,{variant:MH(n.level),children:_d(n.level)})}),(0,K.jsx)(UH,{label:`Timestamp`,children:(0,K.jsx)(`span`,{className:`tabular-nums`,children:new Date(n.timestamp).toLocaleString()})}),(0,K.jsx)(UH,{label:`Thread`,children:(0,K.jsx)(`span`,{className:`tabular-nums font-mono`,children:n.thread})}),n.node&&(0,K.jsx)(UH,{label:`Node`,children:(0,K.jsx)(ol,{variant:r,children:n.node})}),n.tags&&n.tags.length>0&&(0,K.jsx)(UH,{label:`Tags`,children:(0,K.jsx)(`span`,{className:`font-mono`,children:n.tags})})]}),(0,K.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`Message`}),(0,K.jsx)(`div`,{className:`rounded-md overflow-hidden border border-border/50 flex-1 min-h-0`,children:(0,K.jsx)(Dx,{className:`w-full h-full`,language:HH(n.message),theme:i,value:n.message,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12,padding:{top:12,bottom:12},automaticLayout:!0}})})]})]}):(0,K.jsx)(Lc,{})]})})}var GH=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d{1,3})?)?$/;function KH(e){let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}`}function qH(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),23,59,59,999)}var JH=KH(new Date(0));function YH(e=new Date){return KH(qH(e))}function XH(e,t){if(!e)return;let n=Date.parse(e);if(!GH.test(e)||Number.isNaN(n))return`Enter a valid date and time with a 4-digit year`;if(n<0)return`Date cannot be before 1970 (UTC)`;if(n>qH(t??new Date).getTime())return`Date cannot be after today`}var ZH=x().or(w()).or(k()).optional().superRefine((e,t)=>{let n=XH(e);n&&t.addIssue({code:`custom`,message:n})}),QH=b({limit:x().or(w()).or(k()).optional(),level:j([`notify`,`error`,`warn`,`info`,`debug`,`trace`,`undefined`]).or(w()).or(k()).optional(),from:ZH,until:ZH,log_name:j([`hdb.log`,`system.log`]).or(w()).or(k()).optional(),filter:x().or(w()).or(k()).optional()});function $H(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),window.setTimeout(()=>URL.revokeObjectURL(n),1e4)}function eU(e){return e.replace(/[^a-z0-9-]+/gi,`-`).replace(/(^-|-$)/g,``).toLowerCase()}function tU(e){return new Date(e).toISOString().replace(/[:.]/g,`-`)}function nU(e){let t=Array.isArray(e.tags)?e.tags:[],n=[e.thread??``,e.level??``,...e.node?[e.node]:[],...t];return`${e.timestamp} ${n.map(e=>`[${e}]`).join(` `)}: ${e.message??``}`}function rU(e,t){return t===`json`?JSON.stringify(e,null,` `):e.map(e=>`${nU(e)}\n`).join(``)}function iU(e,t,n=Date.now()){return`${eU(e)}-${tU(n)}.${t}`}function aU(e,t,n){let r=t===`json`?`application/json`:`text/plain;charset=utf-8`;$H(new Blob([rU(e,t)],{type:r}),iU(n,t))}function oU({logs:e,logName:t,iconOnly:n,className:r}){return(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsxs)(H,{variant:`defaultOutline`,size:n?`icon`:`default`,disabled:e.length===0,"aria-label":`Download logs`,className:F(`shrink-0`,r),children:[(0,K.jsx)(oa,{}),!n&&`Download`]})}),(0,K.jsxs)(vc,{align:`end`,children:[(0,K.jsxs)(Cc,{className:`text-xs font-normal text-muted-foreground`,children:[`Saves the `,oe(e.length,`entry`,`entries`),` shown`]}),(0,K.jsx)(yc,{onSelect:()=>aU(e,`txt`,t),children:`Text (.txt)`}),(0,K.jsx)(yc,{onSelect:()=>aU(e,`json`,t),children:`JSON (.json)`})]})]})}var sU=`dark:bg-grey-600 dark:border-grey-500`,cU=[{name:`from`,label:`Start date`},{name:`until`,label:`End date`}];function lU({form:e,resetFilters:t,submitFilters:n,showLogName:r,showFilter:i,isOpen:a,onOpenChange:o}){let[s,c]=(0,G.useState)(YH),l=()=>c(YH());return(0,K.jsxs)(Er,{className:F(a?`block`:`hidden`,`mt-3 md:mt-0 md:block`),children:[(0,K.jsx)(Dr,{className:`hidden md:block`,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>o(!a),"aria-expanded":a,"aria-controls":`logs-filters-content`,className:`flex w-full items-center justify-between md:pointer-events-none`,children:(0,K.jsxs)(Or,{className:`flex items-center gap-2 text-base`,children:[(0,K.jsx)(gs,{className:`size-4 text-muted-foreground`}),`Filters`]})})}),(0,K.jsx)(Ar,{id:`logs-filters-content`,children:(0,K.jsx)(Od,{...e,children:(0,K.jsxs)(`form`,{id:`instance-edit-log-filters-form`,name:`instance-edit-log-filters-form`,onSubmit:e.handleSubmit(n),className:`flex-col space-y-4`,children:[i&&(0,K.jsx)(Y,{control:e.control,name:`filter`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(J,{children:(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(rs,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,K.jsx)($,{type:`search`,placeholder:`Search logs…`,className:F(`pl-9`,sU),value:e.value??``,onChange:e.onChange})]})}),(0,K.jsx)(Q,{})]})}),r&&(0,K.jsx)(Y,{control:e.control,name:`log_name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Log file`}),(0,K.jsxs)(hy,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,K.jsx)(vy,{className:F(`w-full bg-white`,sU),children:(0,K.jsx)(_y,{placeholder:`Select log file`})}),(0,K.jsx)(yy,{children:(0,K.jsxs)(gy,{children:[(0,K.jsx)(xy,{value:`hdb.log`,children:`Application (hdb.log)`}),(0,K.jsx)(xy,{value:`system.log`,children:`System (system.log)`})]})})]}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsx)(Y,{control:e.control,name:`limit`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Limit`}),(0,K.jsxs)(hy,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,K.jsx)(vy,{className:F(`w-full bg-white`,sU),children:(0,K.jsx)(_y,{placeholder:`Limit`})}),(0,K.jsx)(yy,{children:(0,K.jsxs)(gy,{children:[(0,K.jsx)(xy,{value:`1000`,children:`1000`}),(0,K.jsx)(xy,{value:`500`,children:`500`}),(0,K.jsx)(xy,{value:`250`,children:`250`}),(0,K.jsx)(xy,{value:`100`,children:`100`}),(0,K.jsx)(xy,{value:`10`,children:`10`})]})})]}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:e.control,name:`level`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Level`}),(0,K.jsxs)(hy,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,K.jsx)(vy,{className:F(`w-full bg-white`,sU),children:(0,K.jsx)(_y,{placeholder:`Level`})}),(0,K.jsx)(yy,{children:(0,K.jsxs)(gy,{children:[(0,K.jsx)(xy,{value:`undefined`,children:`All`}),(0,K.jsx)(xy,{value:`notify`,children:`Notify`}),(0,K.jsx)(xy,{value:`error`,children:`Error`}),(0,K.jsx)(xy,{value:`warn`,children:`Warn`}),(0,K.jsx)(xy,{value:`info`,children:`Info`}),(0,K.jsx)(xy,{value:`debug`,children:`Debug`}),(0,K.jsx)(xy,{value:`trace`,children:`Trace`})]})})]}),(0,K.jsx)(Q,{})]})})]}),cU.map(({name:t,label:n})=>(0,K.jsx)(Y,{control:e.control,name:t,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:n}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`datetime-local`,step:1,min:JH,max:s,onFocus:l,className:sU,value:e.value??``,onChange:e.onChange})}),(0,K.jsx)(Q,{})]})},t)),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,K.jsx)(H,{type:`submit`,variant:`positiveOutline`,className:`grow`,children:`Apply Filters`}),(0,K.jsx)(H,{type:`reset`,variant:`destructiveOutline`,onClick:t,children:`Clear`})]})]})})})]})}var uU=1e4;function dU(e){if(!e)return;let t=parseInt(e,10);if(!(!Number.isFinite(t)||t<=0))return Math.min(t,uU)}function fU(e,t){return{operation:`read_log`,start:0,replicated:t,limit:dU(e.limit),level:e.level===`undefined`?void 0:e.level,from:e.from?new Date(e.from).toISOString():void 0,until:e.until?new Date(e.until).toISOString():void 0,log_name:e.log_name??void 0,filter:e.filter?e.filter:void 0,order:`desc`}}async function pU({instanceClient:e,logFilters:t,replicated:n}){let{data:r}=await e.post(`/`,fU(t,n));return r}function mU(e){let t=e.logFilters;return B({queryKey:[`read_log`,e.entityId,t.limit,t.level,t.from,t.until,t.log_name,t.filter,e.replicated],queryFn:()=>pU(e),retry:!1,refetchInterval:e.isAutoRefreshEnabled?Gc(5e3):!1})}async function hU({connection:e,logFilters:t,replicated:n,signal:r,onEntry:i}){let{url:a,headers:o,credentials:s}=OD(e),c;try{c=await fetch(a,{method:`POST`,headers:o,credentials:s,body:JSON.stringify(fU(t,n)),signal:r})}catch(e){throw r?.aborted?e:new TD(`Failed to open the read_log SSE stream.`,{cause:e})}let l=c.headers.get(`content-type`)??``;if(!c.ok||!l.includes(`text/event-stream`)||!c.body)throw await c.body?.cancel().catch(()=>{}),new TD(`read_log did not return an event stream (status ${c.status}, content-type "${l}").`);for await(let e of SD(c.body,r)){if(e.event===`error`){let t=wD(e);if(!t||typeof t!=`object`)throw new DD(typeof t==`string`&&t?t:`The log stream failed.`);let n=t;throw new DD(n.message??`The log stream failed.`,{code:n.code})}if(e.event===`done`||e.event===`end`)return;for(let t of gU(wD(e)))i(t)}}function gU(e){return Array.isArray(e)?e.filter(_U):_U(e)?[e]:[]}function _U(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.timestamp==`string`&&(typeof t.level==`string`||typeof t.message==`string`)}function vU(e){return[e.timestamp,e.node??``,e.thread??``,e.level,e.message].join(`|`)}function yU(e,t,n){let r=new Set,i=[];for(let n of[...t,...e]){let e=vU(n);r.has(e)||(r.add(e),i.push(n))}return i.sort((e,t)=>e.timestamp<t.timestamp?1:e.timestamp>t.timestamp?-1:0),n>0&&i.length>n?i.slice(0,n):i}var bU={entries:[],fellBack:!1};function xU(e,t){switch(t.kind){case`reset`:return bU;case`retry`:return e.fellBack?{...e,fellBack:!1}:e;case`append`:{if(t.entries.length===0)return e;let n=e.entries.concat(t.entries);return n.length<=t.cap?{...e,entries:n}:(n.sort((e,t)=>e.timestamp<t.timestamp?1:e.timestamp>t.timestamp?-1:0),{...e,entries:n.slice(0,t.cap)})}case`fellBack`:return{...e,fellBack:!0}}}function SU(){let e=q();return u.isDirectConnection(e.entityId)}var CU=1e3,wU=2e3,TU=250;function EU(e){return dU(e)??CU}function DU(e,t){return JSON.stringify([e.limit,e.level,e.from,e.until,e.log_name,e.filter,t])}function OU({params:e,logFilters:t,replicated:n,live:r}){let i=SU(),[a,o]=(0,G.useReducer)(xU,bU),s=r&&i&&!a.fellBack,c=DU(t,n),l=EU(t.limit),u=Math.max(wU,l),d=L(mU({...e,logFilters:t,replicated:n,isAutoRefreshEnabled:r&&!s}));(0,G.useEffect)(()=>{o({kind:`reset`})},[e.entityId,c]),(0,G.useEffect)(()=>{r&&o({kind:`retry`})},[r]);let f=(0,G.useRef)({logFilters:t,replicated:n});f.current={logFilters:t,replicated:n},(0,G.useEffect)(()=>{if(!s)return;let t=new AbortController,n=[],r=()=>{if(n.length>0&&!t.signal.aborted){let e=n;n=[],o({kind:`append`,entries:e,cap:u})}},i=setInterval(r,TU);return hU({connection:{id:e.entityId},logFilters:f.current.logFilters,replicated:f.current.replicated,signal:t.signal,onEntry:e=>n.push(e)}).catch(()=>{}).finally(()=>{clearInterval(i),!t.signal.aborted&&(r(),o({kind:`fellBack`}))}),()=>{clearInterval(i),t.abort()}},[s,e.entityId,c]);let p=(0,G.useMemo)(()=>{let e=d.data??[];return a.entries.length===0?e:yU(e,a.entries,l)},[d.data,a.entries,l]),m=s?`streaming`:r?`polling`:`idle`;return{logs:p,isLoading:d.isLoading,isFetching:d.isFetching,refetch:()=>d.refetch(),transport:m}}var kU={log_name:`hdb.log`,limit:`100`,level:`undefined`,from:``,until:``,filter:``},AU={error:(0,K.jsx)(wi,{className:`size-3`}),stderr:(0,K.jsx)(wi,{className:`size-3`}),warn:(0,K.jsx)(Rs,{className:`size-3`}),notify:(0,K.jsx)(ni,{className:`size-3`}),info:(0,K.jsx)(Ba,{className:`size-3`}),debug:(0,K.jsx)(ui,{className:`size-3`}),trace:(0,K.jsx)(Ir,{className:`size-3`}),stdout:(0,K.jsx)(Ms,{className:`size-3`})},jU=[{accessorKey:`level`,header:`Level`,cell:({row:e})=>{let{level:t}=e.original;return(0,K.jsxs)(ol,{variant:MH(t),children:[AU[t],_d(t)]})}},{accessorKey:`timestamp`,header:`Timestamp`,cell:({row:e})=>{let{timestamp:t}=e.original,n=new Date(t),r=n.getFullYear()===new Date().getFullYear()?n.toLocaleDateString(void 0,{month:`numeric`,day:`2-digit`}):n.toLocaleDateString();return(0,K.jsxs)(`span`,{className:`tabular-nums whitespace-nowrap text-muted-foreground`,children:[r,` `,n.toLocaleTimeString()]})}},{accessorKey:`message`,header:`Message`,cell:({row:e})=>{let{message:t}=e.original;return(0,K.jsx)(`span`,{className:`block max-w-xl truncate font-mono text-xs`,children:t})}},{accessorKey:`thread`,header:`Thread`,cell:({row:e})=>(0,K.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:e.original.thread})},{accessorKey:`node`,header:`Node`,cell:({row:e})=>{let{node:t}=e.original,n=IH(t);return(0,K.jsx)(K.Fragment,{children:t?(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsxs)(ol,{variant:n,children:[t.split(`.`)[0],`...`]})}),(0,K.jsx)(Xl,{className:`bg-popover text-popover-foreground border border-border`,arrowClassName:`bg-popover fill-popover`,children:t})]}):null})}},{accessorKey:`tags`,header:`Tags`,cell:({row:e})=>{let{tags:t}=e.original;return t&&t.length>0?(0,K.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null}}],MU=(e,t)=>!e&&!t||!e||!t||new Date(e)<=new Date(t);function NU(){return(0,K.jsxs)(`div`,{className:`rounded-md bg-card dark:bg-black-dark overflow-hidden`,children:[(0,K.jsx)(`div`,{className:`flex gap-4 p-4 border-b border-border`,children:[`w-14`,`w-32`,`w-14`,`w-24`,`w-16`,`flex-1`].map((e,t)=>(0,K.jsx)(aC,{className:`h-4 ${e}`},t))}),Array.from({length:12}).map((e,t)=>(0,K.jsxs)(`div`,{className:`flex gap-4 p-3 border-b border-border/40 border-l-2 border-l-transparent`,children:[(0,K.jsx)(aC,{className:`h-5 w-14`}),(0,K.jsx)(aC,{className:`h-5 w-32`}),(0,K.jsx)(aC,{className:`h-5 w-10`}),(0,K.jsx)(aC,{className:`h-5 w-20`}),(0,K.jsx)(aC,{className:`h-5 w-12`}),(0,K.jsx)(aC,{className:`h-5 flex-1 max-w-xs`})]},t))]})}function PU(){let[e,t]=(0,G.useState)(kU),[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(),[o,s]=(0,G.useState)(!1),[c,l]=Zc(_r.LogsOrderReversed,!1),[u,d]=(0,G.useState)(!1),f=q(),{data:p}=L(HE(f)),m=p?.version,h=!!m&&vr(`4.7.16`,m),{logs:g,isLoading:_,isFetching:v,refetch:y,transport:b}=OU({params:f,logFilters:e,replicated:f.entityType===`cluster`,live:o}),x=(0,G.useMemo)(()=>c?[...g??[]].reverse():g??[],[g,c]),S=e.log_name??`hdb.log`,C=(0,G.useRef)(null);(0,G.useEffect)(()=>{let e=C.current;!_&&e&&e.scrollTo({top:c?e.scrollHeight:0})},[c,_]),(0,G.useEffect)(()=>{let e=C.current;o&&!_&&e&&e.scrollTo({top:c?e.scrollHeight:0})},[x,o,c,_]);let w=on({resolver:mt(QH),defaultValues:kU,mode:`onChange`}),T=e=>{a(e.original),r(!0)},E=async e=>{if(!MU(e.from,e.until)){w.setError(`from`,{type:`onChange`,message:`Start date must be before end date`}),w.setError(`until`,{type:`onChange`,message:`End date must be after start date`});return}t(e)},D=async()=>{w.reset(),t(kU)},O=Kb(y);return(0,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 pt-2 text-foreground md:grid-cols-12 md:gap-4`,children:[(0,K.jsxs)(`section`,{className:`col-span-1 md:col-span-4 lg:col-span-3 px-2 pb-0 md:self-start md:sticky md:top-34 md:max-h-[calc(100vh-(--spacing(34)))] md:overflow-y-auto md:pb-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 md:hidden`,children:[(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:()=>d(e=>!e),"aria-label":`Toggle filters`,"aria-expanded":u,className:`flex-1`,children:[(0,K.jsx)(gs,{}),`Filters`]}),(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:O,disabled:v||_||o,"aria-label":`Refresh logs`,className:`flex-1`,children:[(0,K.jsx)(Go,{className:v?`animate-spin`:``}),`Refresh`]}),(0,K.jsxs)(H,{variant:c?`default`:`defaultOutline`,onClick:()=>l(e=>!e),"aria-label":`Reverse log order`,"aria-pressed":c,className:`flex-1`,children:[(0,K.jsx)(Kr,{}),`Reverse`]}),(0,K.jsx)(oU,{logs:x,logName:S,iconOnly:!0})]}),(0,K.jsx)(lU,{form:w,resetFilters:D,submitFilters:E,showLogName:!1,showFilter:h,isOpen:u,onOpenChange:d}),(0,K.jsxs)(`div`,{className:`mt-3 space-y-3 hidden md:block`,children:[(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:O,disabled:v||_||o,className:`w-full`,children:[(0,K.jsx)(Go,{}),`Refresh`]}),(0,K.jsx)(oU,{logs:x,logName:S,className:`w-full`}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,K.jsx)(Kx,{id:`logs-live-switch`,"aria-label":`Toggle live logs`,checked:o,onCheckedChange:s}),(0,K.jsxs)(`label`,{htmlFor:`logs-live-switch`,className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(Go,{className:`size-4 ${o?`animate-spin [animation-duration:3s]`:``}`}),o?b===`streaming`?`Live (streaming)`:`Live (polling every 5s)`:`Live`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,K.jsx)(Kx,{id:`logs-reverse-order-switch`,"aria-label":`Reverse log order`,checked:c,onCheckedChange:l}),(0,K.jsxs)(`label`,{htmlFor:`logs-reverse-order-switch`,className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(Kr,{className:`size-4`}),c?`Oldest first`:`Newest first`]})]})]})]})]}),(0,K.jsx)(`section`,{className:`col-span-1 md:col-span-8 lg:col-span-9`,children:_?(0,K.jsx)(NU,{}):(0,K.jsx)(RH,{columns:jU,data:x,onRowClick:T,containerRef:C})}),(0,K.jsx)(WH,{isModalOpen:n,setIsModalOpen:r,data:i})]})}function FU(e){return R({getParentRoute:()=>e,path:`logs`,head:()=>({meta:[{title:`Logs — Harper Fabric`}]}),component:PU})}function IU(e){return R({getParentRoute:()=>e,path:`operations`,head:()=>({meta:[{title:`Operations — Harper Fabric`}]}),component:je(async()=>pe(()=>import(`./operations-D8aaKYty.js`),__vite__mapDeps([38,1,7,23,2,3,4,8,6,9,32,34,29])),`OperationsIndex`)})}var LU=6e4,RU=60*LU,zU=24*RU,BU=[{id:`1h`,label:`Last 1 hour`,durationMs:RU,bucketMs:1*LU,expandedBucketMs:1*LU},{id:`6h`,label:`Last 6 hours`,durationMs:6*RU,bucketMs:2*LU,expandedBucketMs:1*LU},{id:`24h`,label:`Last 24 hours`,durationMs:zU,bucketMs:10*LU,expandedBucketMs:5*LU},{id:`7d`,label:`Last 7 days`,durationMs:7*zU,bucketMs:RU,expandedBucketMs:15*LU},{id:`30d`,label:`Last 30 days`,durationMs:30*zU,bucketMs:4*RU,expandedBucketMs:RU}];function VU(e){let t=BU.find(t=>t.id===e);if(!t)throw Error(`Unknown preset: ${e}`);return t}function HU(e){let t=(e,t)=>`${e} ${t}${e===1?``:`s`}`;return e>=RU&&e%RU===0?t(e/RU,`hour`):e>=LU&&e%LU===0?t(e/LU,`minute`):e>=1e3&&e%1e3==0?t(e/1e3,`second`):`${e} ms`}function UU(e,t){let n=e=>t?.expanded?e.expandedBucketMs:e.bucketMs,r=n(BU[0]);if(!Number.isFinite(e)||e<=0)return r;for(let t of BU)if(e<=t.durationMs*1.01)return n(t);let i=BU[BU.length-1];return Math.max(r,Math.ceil(e/(i.durationMs/n(i))))}var WU=[{label:`Off`,value:0},{label:`30s`,value:3e4},{label:`60s`,value:6e4},{label:`5m`,value:3e5}],GU=6e4,KU=[`health`,`traffic`,`requests`,`database`,`replication`,`storage`,`overview`,`jobs`],qU={tab:`health`,range:`1h`,refresh:GU,jobsRefresh:0};function JU(e,t){let n=e===``?NaN:Number(e);return WU.find(e=>e.value===n)?.value??t}function YU(e){return{tab:KU.find(t=>t===e.tab)??qU.tab,range:BU.find(t=>t.id===e.range)?.id??qU.range,refresh:JU(e.refresh,qU.refresh),jobsRefresh:JU(e.jobsRefresh,qU.jobsRefresh)}}function XU(e){return R({getParentRoute:()=>e,path:`status`,validateSearch:YU,search:{middlewares:[ut(qU)]},head:()=>({meta:[{title:`Status — Harper Fabric`}]}),component:je(async()=>pe(()=>import(`./status-CYoonm9V.js`),__vite__mapDeps([39,1,7,6,2,3,4,8,9,12,32,40,41,42,43,44,45,46,47])),`StatusIndex`)})}function ZU(e){let t=OH(e),n=[FU(t),...kE(t,e),OE(t),IU(t),XU(t),AP(t),SH(t)];return t.addChildren(n)}R({getParentRoute:()=>Uu,path:`notifications`,head:()=>({meta:[{title:`Notifications — Harper Fabric`}]}),component:je(async()=>pe(()=>import(`./notifications-D_VqhHnx.js`),__vite__mapDeps([48,1,6,7,2,3,8,9])),`NotificationsCenter`)}),R({getParentRoute:()=>Uu,path:`profile`,head:()=>({meta:[{title:`Profile — Harper Fabric`}]}),component:je(async()=>pe(()=>import(`./profile-DM5E6Xls.js`),__vite__mapDeps([49,1,22,7,6,23,4,2,3,24,25,8,9])),`ProfileIndex`)});var QU=Hu.addChildren([...om,Uu.addChildren([ZU(`local`)])]);function $U({routeTree:e=QU,authentication:t}){let[n]=(0,G.useState)(()=>Ae({routeTree:e,history:be(),defaultNotFoundComponent:sc,defaultErrorComponent:oc,defaultPreload:!cc()&&`intent`,trailingSlash:`never`,defaultPreloadStaleTime:0,scrollRestoration:!0,context:{queryClient:hc,authentication:t||{}}}));return n}function eW(){let e=br(),t=$U({authentication:e}),n=(0,G.useRef)(e);return(0,G.useEffect)(()=>{n.current!==e&&(n.current=e,t.invalidate())},[t,e]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ct,{router:t,context:{authentication:e}}),(0,K.jsx)(Xe,{router:t,position:`bottom-right`})]})}var tW=({...e})=>(0,K.jsx)(Gt,{className:`toaster group`,toastOptions:{classNames:{toast:`group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg`,description:`group-[.toast]:text-muted-foreground`,actionButton:`group-[.toast]:bg-primary group-[.toast]:text-primary-foreground font-medium`,cancelButton:`group-[.toast]:bg-muted group-[.toast]:text-muted-foreground font-medium`}},...e}),nW=!1;function rW(){(0,G.useEffect)(()=>{nW||=!0},[])}function iW(){return Qu(),Bu(),rW(),(0,K.jsxs)(el,{children:[(0,K.jsxs)(it,{client:hc,children:[(0,K.jsx)(eW,{}),(0,K.jsx)(rt,{buttonPosition:`bottom-right`})]}),(0,K.jsx)(tW,{richColors:!0})]})}var aW=1e4,oW=100,sW=new Map;function cW(e){return typeof e==`string`||typeof e==`number`?String(e):e==null?null:typeof e}function lW(e){if(e instanceof Error)return null;try{return JSON.stringify(e)??null}catch{return Object.keys(e).join(`,`)}}function uW(e,t){if(typeof e!=`object`||!e)return JSON.stringify([typeof e,String(e),t??null]);let{name:n,message:r,stack:i,config:a}=e;return JSON.stringify([typeof e,cW(n),cW(r),cW(i),t??null,cW(a?.method),cW(a?.baseURL),cW(a?.url),lW(e)])}function dW(e,t){for(let[e,n]of sW){if(t-n<aW)break;sW.delete(e)}sW.delete(e),sW.set(e,t),sW.size>oW&&sW.delete(sW.keys().next().value)}function fW(e,t){let n;try{n=uW(e,t.componentStack)}catch{n=void 0}let r=performance.now();if(n!==void 0){let e=sW.get(n);if(e!==void 0&&r-e<aW)return}try{me(e,t)}catch{return}n!==void 0&&dW(n,r)}var pW={onUncaughtError:(e,t)=>{fW(e,t),console.warn(`Uncaught error:`,e,t)},onCaughtError:(e,t)=>{fW(e,t),console.warn(`Caught error:`,e,t)},onRecoverableError:(e,t)=>{fW(e,t),console.warn(`Recoverable error:`,e,t)}};function mW(e,t=()=>!1,n=()=>!0){return r=>(r?.response?.status===401&&!t(r.config?.url??``)&&n(r.config)&&e(),Promise.reject(r))}var hW=[`/Login/`,`/ForgotPassword/`,`/ResetPassword/`,`/VerifyEmail/`,`/ResendVerificationEmail/`],gW=`authUserAtSend`;function _W(){let e=u.getConnectionById(m).user;return e&&`id`in e?e.id:null}var vW=!1;function yW(){vW||(vW=!0,P.interceptors.request.use(e=>(e[gW]=_W(),e)),P.interceptors.response.use(e=>e,mW(pu,e=>hW.some(t=>e.startsWith(t)),e=>e?.[gW]===_W())))}var bW=!1;function xW(){bW||=(u.onAppSignedOutElsewhere(mu),!0)}var SW=`Studio:StaleDeployReloadedAt`,CW=6e4,wW=`__harperStaleDeployReloadState__`;function TW(){if(typeof window<`u`)return window[wW]}function EW(){let e=TW();if(e){try{let e=Number(sessionStorage.getItem(SW)??0);if(Date.now()-e<CW)return;sessionStorage.setItem(SW,String(Date.now()))}catch{return}e.reload()}}function DW(e=()=>window.location.reload()){if(typeof window>`u`)return;let t=window,n=t[wW];if(n){n.reload=e;return}t[wW]={reload:e},window.addEventListener(`vite:preloadError`,()=>EW())}var OW=ve();ge(),DW(),yW(),xW(),a(),u.installExplorerCrossTabCleanup(),(0,OW.createRoot)(document.getElementById(`root`),pW).render((0,K.jsx)(G.StrictMode,{children:(0,K.jsx)(iW,{})}));export{iF as $,Ar as $i,Sh as $n,Gc as $r,cO as $t,nL as A,Uo as Ai,pb as An,lu as Ar,Zk as At,oI as B,ia as Bi,A_ as Bn,kl as Br,UO as Bt,KR as C,ds as Ci,rx as Cn,J as Cr,hj as Ct,iL as D,Yo as Di,wb as Dn,gu as Dr,fj as Dt,CL as E,$o as Ei,Eb as En,Au as Er,dj as Et,II as F,no as Fi,xy as Fn,Xl as Fr,XO as Ft,kF as G,Si as Gi,Kg as Gn,wl as Gr,FO as Gt,jF as H,Xi as Hi,u_ as Hn,xl as Hr,LO as Ht,DI as I,Qa as Ii,vy as In,Yl as Ir,WO as It,CF as J,Wr as Ji,wg as Jn,hl as Jr,jO as Jt,EF as K,fi as Ki,Gg as Kn,pl as Kr,kO as Kt,EI as L,Ha as Li,_y as Ln,zl as Lr,qO as Lt,$I as M,zo as Mi,ky as Mn,q as Mr,qk as Mt,tL as N,Fo as Ni,hy as Nn,$l as Nr,Jk as Nt,rL as O,qo as Oi,xb as On,cu as Or,lA as Ot,QI as P,oo as Pi,yy as Pn,Jl as Pr,ak as Pt,rF as Q,Er as Qi,eh as Qn,Rc as Qr,dO as Qt,xI as R,Ba as Ri,cy as Rn,Rl as Rr,JO as Rt,sz as S,Es as Si,lx as Sn,Y as Sr,mj as St,UL as T,rs as Ti,Sb as Tn,Gu as Tr,pj as Tt,OF as U,Oi as Ui,l_ as Un,El as Ur,EO as Ut,qF as V,ea as Vi,c_ as Vn,Sl as Vr,IO as Vt,AF as W,wi as Wi,qg as Wn,Ol as Wr,PO as Wt,qP as X,Br as Xi,Zh as Xn,Zc as Xr,MO as Xt,nF as Y,Hr as Yi,Cg as Yn,ol as Yr,AO as Yt,JP as Z,Nr as Zi,Lh as Zn,Yc as Zr,gO as Zt,SV as _,Hs as _i,Dx as _n,$ as _r,JM as _t,HU as a,wr as aa,yc as ai,KE as an,Fm as ar,eF as at,pz as b,Ms as bi,ux as bn,Md as br,aM as bt,pU as c,Ec as ci,HE as cn,_m as cr,IP as ct,$H as d,_c as di,NT as dn,Em as dr,iP as dt,kr as ea,Kc as ei,WD as en,Zm as er,aF as et,BH as f,fc as fi,eT as fn,Tm as fr,fN as ft,OV as g,Ks as gi,Kx as gn,_f as gr,VM as gt,RV as h,oc as hi,aC as hn,bf as hr,BM as ht,BU as i,Tr as ia,vc as ii,iD as in,Nm as ir,XP as it,eL as j,Vo as ji,zy as jn,Ql as jr,Kk as jt,aL as k,Go as ki,Cb as kn,su as kr,cA as kt,tU as l,Oc as li,NE as ln,wm as lr,BP as lt,vH as m,hc as mi,FC as mn,Sp as mr,LM as mt,YU as n,Or as na,gc as ni,ED as nn,Am as nr,YP as nt,VU as o,wc as oi,GE as on,Im as or,$P as ot,zH as p,mc as pi,Iw as pn,Dm as pr,sN as pt,wF as q,Xr as qi,hg as qn,ml as qr,NO as qt,WU as r,Sr as ra,bc as ri,xD as rn,Mm as rr,tF as rt,UU as s,Tc as si,qE as sn,jm as sr,VP as st,EW as t,Dr as ta,Lc as ti,ID as tn,Bm as tr,ZP as tt,eU as u,Dc as ui,QT as un,Om as ur,zP as ut,qB as v,Rs as vi,Tx as vn,Q as vr,HM as vt,KL as w,ss as wi,bb as wn,Od as wr,uj as wt,fz as x,Os as xi,cx as xn,X as xr,Fj as xt,uB as y,Is as yi,sx as yn,Z as yr,qM as yt,wI as z,oa as zi,z_ as zn,Al as zr,QO as zt};
833
+ `},NB=function(e,t,n,r,i){var a=function(e){return t.getItemTitle(t.items[e])};return e.replace(/({[^\s}]+)}/g,function(e){var o=e.slice(1,-1);switch(o){case`treeLabel`:return r.treeLabel??``;case`renamingItem`:return r.renamingItem?a(r.renamingItem):`None`;case`dragItems`:return n.draggingItems?.map(function(e){return t.getItemTitle(e)}).join(`, `)??`None`;case`dropTarget`:if(!n.draggingPosition)return`None`;if(n.draggingPosition.targetType===`item`||n.draggingPosition.targetType===`root`)return`within ${a(n.draggingPosition.targetItem)}`;var s=t.items[n.draggingPosition.parentItem],c=t.getItemTitle(s);return n.draggingPosition.childIndex===0?`within ${c} at the start`:`within ${c} after ${a(s.children[n.draggingPosition.childIndex-1])}`;default:if(o.startsWith(`keybinding:`))return i[o.slice(11)][0];throw Error(`Unknown live descriptor variable {${o}}`)}})},PB=function(e){var t=e.children,n=e.live;return G.createElement(`div`,{"aria-live":n,dangerouslySetInnerHTML:{__html:t}})},FB=function(){var e=lB(),t=KB(),n=Vz(),r=_B(),i=(0,G.useMemo)(function(){return e.liveDescriptors??MB},[e.liveDescriptors]),a=t.renderers.renderLiveDescriptorContainer;return t.treeInformation.isRenaming?G.createElement(a,{tree:t},G.createElement(PB,{live:`polite`},NB(i.renamingItem,e,n,t,r))):t.treeInformation.isSearching?G.createElement(a,{tree:t},G.createElement(PB,{live:`polite`},NB(i.searching,e,n,t,r))):t.treeInformation.isProgrammaticallyDragging?G.createElement(a,{tree:t},G.createElement(PB,{live:`polite`},NB(i.programmaticallyDragging,e,n,t,r)),G.createElement(PB,{live:`assertive`},NB(i.programmaticallyDraggingTarget,e,n,t,r))):G.createElement(a,{tree:t},G.createElement(PB,{live:`off`},NB(i.introduction,e,n,t,r)))},IB=function(){return lB().showLiveDescription??!0?G.createElement(FB,null):null},LB=function(){return LB=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},LB.apply(this,arguments)},RB=function(){var e=KB(),t=e.treeId,n=e.rootItem,r=e.renderers,i=e.treeInformation,a=lB(),o=(0,G.useRef)(),s=Vz();DB(),pB(o.current,function(){a.setActiveTree(t)},function(){a.setActiveTree(function(e){return e===t?void 0:e})});var c=a.items[n].children,l=G.createElement(G.Fragment,null,G.createElement(IB,null),G.createElement(JB,{depth:0,parentId:n},c??[]),G.createElement(dB,{treeId:t}),G.createElement(jB,{containerRef:o.current})),u=LB({onDragOver:function(e){e.preventDefault(),s.onDragOverTreeHandler(e,t,o)},onDragLeave:function(e){s.onDragLeaveContainerHandler(e,o)},onMouseDown:function(){return s.abortProgrammaticDrag()},ref:o,style:{position:`relative`},role:`tree`,"aria-label":i.treeLabelledBy?void 0:i.treeLabel,"aria-labelledby":i.treeLabelledBy},{"data-rct-tree":t});return r.renderTreeContainer({children:l,info:i,containerProps:u})},zB=function(e,t,n){var r=lB(),i=Vz(),a=r.viewState[e.treeId]?.selectedItems;return(0,G.useMemo)(function(){return{isFocused:r.activeTreeId===e.treeId,isRenaming:!!t,areItemsSelected:(a?.length??0)>0,isSearching:n!==null,search:n,isProgrammaticallyDragging:i.isProgrammaticallyDragging??!1,treeId:e.treeId,rootItem:e.rootItem,treeLabel:e.treeLabel,treeLabelledBy:e.treeLabelledBy}},[r.activeTreeId,e.treeId,e.rootItem,e.treeLabel,e.treeLabelledBy,t,a?.length,n,i.isProgrammaticallyDragging])},BB=function(){return BB=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},BB.apply(this,arguments)},VB=function(e,t){var n=lB(),r=KB(),i=Vz();(0,G.useImperativeHandle)(e,function(){return BB(BB(BB({},t),{treeEnvironmentContext:n,dragAndDropContext:i,treeContext:r}),r.treeInformation)})},HB=G.createContext(null),UB=G.forwardRef(function(e,t){lB();var n=KB();Vz();var r=Xz(),i=(0,G.useMemo)(function(){return{abortRenamingItem:function(){n.setRenamingItem(null)},abortSearch:function(){n.setSearch(null)},collapseItem:function(e){r.collapseItem(e,n.treeId)},completeRenamingItem:function(){},expandItem:function(e){r.expandItem(e,n.treeId)},focusItem:function(e,t){t===void 0&&(t=!0),r.focusItem(e,n.treeId,t)},focusTree:function(e){e===void 0&&(e=!0),r.focusTree(n.treeId,e)},invokePrimaryAction:function(e){r.invokePrimaryAction(e,n.treeId)},moveFocusDown:function(){r.moveFocusDown(n.treeId)},moveFocusUp:function(){r.moveFocusUp(n.treeId)},renameItem:function(e,t){r.renameItem(e,t,n.treeId)},selectItems:function(e){r.selectItems(e,n.treeId)},setSearch:function(e){n.setSearch(e)},startRenamingItem:function(e){n.setRenamingItem(e)},stopRenamingItem:function(){n.setRenamingItem(null)},toggleItemExpandedState:function(e){r.toggleItemExpandedState(e,n.treeId)},toggleItemSelectStatus:function(e){r.toggleItemSelectStatus(e,n.treeId)},expandAll:function(){r.expandAll(n.treeId)},collapseAll:function(){r.collapseAll(n.treeId)},expandSubsequently:function(e){return r.expandSubsequently(n.treeId,e)}}},[r,n]);return VB(t,i),G.createElement(HB.Provider,{value:i},e.children)}),WB=function(){return WB=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},WB.apply(this,arguments)},GB=G.createContext(null),KB=function(){return(0,G.useContext)(GB)},qB=G.forwardRef(function(e,t){var n,r=lB(),i=(0,G.useMemo)(function(){return WB(WB({},r),e)},[e,r]),a=(0,G.useState)(null),o=a[0],s=a[1],c=(0,G.useState)(null),l=c[0],u=c[1],d=r.items[e.rootItem],f=r.viewState[e.treeId];(0,G.useEffect)(function(){return r.registerTree({treeId:e.treeId,rootItem:e.rootItem}),function(){return r.unregisterTree(e.treeId)}},[e.treeId,e.rootItem]);var p=zB(e,l,o),m=(0,G.useMemo)(function(){return{treeId:e.treeId,rootItem:e.rootItem,treeLabel:e.treeLabel,treeLabelledBy:e.treeLabelledBy,getItemsLinearly:function(){return iB(e.rootItem,f??{},r.items)},treeInformation:p,search:o,setSearch:s,renamingItem:l,setRenamingItem:u,renderers:i}},[r.items,e.rootItem,e.treeId,e.treeLabel,e.treeLabelledBy,l,i,o,p,f]);return d===void 0?((n=r.onMissingItems)==null||n.call(r,[e.rootItem]),null):G.createElement(GB.Provider,{value:m},G.createElement(UB,{ref:t},G.createElement(RB,null)))}),JB=function(e){for(var t=KB(),n=t.renderers,r=t.treeInformation,i=[],a=0,o=e.children;a<o.length;a++){var s=o[a];i.push(G.createElement($B,{key:s,itemIndex:s,depth:e.depth}))}if(i.length===0)return null;var c={role:e.depth===0?void 0:`group`};return n.renderItemsContainer({children:i,info:r,containerProps:c,depth:e.depth,parentId:e.parentId})},YB=function(){return YB=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},YB.apply(this,arguments)},XB=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},ZB=function(e){var t=KB(),n=t.treeId,r=t.search,i=t.renamingItem,a=t.setRenamingItem,o=lB(),s=Sz(),c=Vz(),l=TB(`last-focus`),u=e&&o.getItemTitle(e),d=Fz(),f=(0,G.useMemo)(function(){return r===null||r.length===0||!e||!u?!1:(o.doesSearchMatchItem??OB)(r,e,u)},[r,e,u,o.doesSearchMatchItem]),p=e&&(o.viewState[n]?.selectedItems)?.includes(e.index),m=e&&(o.viewState[n]?.expandedItems)?.includes(e.index),h=e&&i===e.index;return(0,G.useMemo)(function(){if(e){var t=o.viewState[n],r=((t?.selectedItems)?.map(function(e){return o.items[e]})??(t?.focusedItem?[o.items[t?.focusedItem]]:[])).filter(function(e){return!!e}),i=!!r.find(function(t){return t.index===e.index}),u=r&&(o.canDrag?.call(o,r)??!0)&&r.map(function(e){return e.canMove??!0}).reduce(function(e,t){return e&&t},!0),g=(o.canDrag?.call(o,[e])??!0)&&(e.canMove??!0),_=o.canDragAndDrop&&(i&&u||!i&&g),v=o.canDragAndDrop&&!!(c.viableDragPositions?.[n])?.find(function(t){return t.targetType===`item`&&t.targetItem===e.index}),y={primaryAction:function(){var t;(t=o.onPrimaryAction)==null||t.call(o,o.items[e.index],n)},collapseItem:function(){var t;(t=o.onCollapseItem)==null||t.call(o,e,n)},expandItem:function(){var t;(t=o.onExpandItem)==null||t.call(o,e,n)},toggleExpandedState:function(){var t,r;m?(t=o.onCollapseItem)==null||t.call(o,e,n):(r=o.onExpandItem)==null||r.call(o,e,n)},selectItem:function(){var t;(t=o.onSelectItems)==null||t.call(o,[e.index],n)},addToSelectedItems:function(){var r;(r=o.onSelectItems)==null||r.call(o,XB(XB([],t?.selectedItems??[],!0),[e.index],!1),n)},unselectItem:function(){var r;(r=o.onSelectItems)==null||r.call(o,(t?.selectedItems)?.filter(function(t){return t!==e.index})??[],n)},selectUpTo:function(t){l(e,t)},startRenamingItem:function(){a(e.index)},stopRenamingItem:function(){a(null)},focusItem:function(t){var r;t===void 0&&(t=!0),(r=o.onFocusItem)==null||r.call(o,e,n,t)},startDragging:function(){var r,i=t?.selectedItems??[];if(i.includes(e.index)||(i=[e.index],(r=o.onSelectItems)==null||r.call(o,i,n)),_){var a=d(n,i.map(function(e){return o.items[e]}));c.onStartDraggingItems(a,n)}}},b={isSelected:p,isExpanded:m,isFocused:t?.focusedItem===e.index,isRenaming:h,isDraggingOver:c.draggingPosition&&c.draggingPosition.targetType===`item`&&c.draggingPosition.targetItem===e.index&&c.draggingPosition.treeId===n,isDraggingOverParent:!1,isSearchMatching:f,canDrag:_,canDropOn:v},x=YB(YB({},s.createInteractiveElementProps(e,n,y,b,t)),{"data-rct-item-interactive":!0,"data-rct-item-focus":b.isFocused?`true`:`false`,"data-rct-item-id":e.index}),S=YB({},{"data-rct-item-container":`true`}),C={role:`treeitem`,"aria-selected":b.isSelected,"aria-expanded":e.isFolder?b.isExpanded?`true`:`false`:void 0},w={onClick:function(){e.isFolder&&y.toggleExpandedState(),y.selectItem()},onFocus:function(){y.focusItem()},onDragOver:function(e){e.preventDefault()},"aria-hidden":!0,tabIndex:-1},T=t?Object.entries(t).reduce(function(t,n){var r=n[0],i=n[1];return t[r]=Array.isArray(i)?i.includes(e.index):i===e.index,t},{}):{};return YB(YB(YB({},y),b),{interactiveElementProps:x,itemContainerWithChildrenProps:C,itemContainerWithoutChildrenProps:S,arrowProps:w,viewStateFlags:T})}},[e,o,n,c,p,m,h,f,s,l,a,d])},QB=function(e){var t=KB(),n=t.renderers,r=t.treeInformation,i=t.setRenamingItem,a=t.treeId,o=lB(),s=(0,G.useRef)(null),c=(0,G.useRef)(null),l=o.items[e.itemIndex],u=(0,G.useState)(o.getItemTitle(l)),d=u[0],f=u[1],p=Mz(!0),m=function(){var e;(e=o.onAbortRenamingItem)==null||e.call(o,l,r.treeId),i(null),p(function(){o.setActiveTree(a)})},h=function(){var e;(e=o.onRenameItem)==null||e.call(o,l,d,r.treeId),i(null),p(function(){o.setActiveTree(a)})};Oz(function(){var e,t,n;o.setActiveTree(a),(o.autoFocus??!0)&&((e=s.current)==null||e.select(),(n=(t=s.current)?.focus)==null||n.call(t))},[o,a],[]),yB(`abortRenameItem`,function(){m()},!0,!0);var g={value:d,onChange:function(e){f(e.target.value)},onBlur:function(e){(!e.relatedTarget||e.relatedTarget!==c.current)&&m()},"aria-label":`New item name`,tabIndex:0};return n.renderRenameInput({item:l,inputRef:s,submitButtonProps:{onClick:function(e){e.stopPropagation(),h()}},submitButtonRef:c,formProps:{onSubmit:function(e){e.preventDefault(),h()}},inputProps:g})},$B=function(e){var t,n=(0,G.useState)(!1),r=n[0],i=n[1],a=KB(),o=a.renderers,s=a.treeInformation,c=a.renamingItem,l=lB(),u=bB(),d=l.items[e.itemIndex],f=(0,G.useMemo)(function(){return u.expandedItems?.includes(e.itemIndex)},[e.itemIndex,u.expandedItems]),p=ZB(d);if(d===void 0||p===void 0)return r||(i(!0),(t=l.onMissingItems)==null||t.call(l,[e.itemIndex])),null;var m=l.shouldRenderChildren?.call(l,d,p)??(d.isFolder&&f),h=d.children&&m&&G.createElement(JB,{depth:e.depth+1,parentId:e.itemIndex},d.children),g=l.getItemTitle(d),_=c===e.itemIndex?G.createElement(QB,{itemIndex:e.itemIndex}):o.renderItemTitle({info:s,context:p,title:g,item:d}),v=o.renderItemArrow({info:s,context:p,item:l.items[e.itemIndex]});return o.renderItem({item:l.items[e.itemIndex],depth:e.depth,title:_,arrow:v,context:p,info:s,children:h})??null},eV=`__db_root__`,tV=`__create_table__`;function nV(e,t){return`${e}/${t}`}function rV(e,{canManage:t}){let n={},r=Object.keys(e||{}).sort();for(let t of r){let r=Object.keys(e?.[t]||{}).sort();n[t]={index:t,isFolder:!0,children:r.map(e=>nV(t,e)),data:{kind:`database`,databaseName:t},canMove:!1,canRename:!1};for(let e of r){let r=nV(t,e);n[r]={index:r,isFolder:!1,data:{kind:`table`,databaseName:t,tableName:e},canMove:!1,canRename:!1}}}return n[tV]={index:tV,isFolder:!1,data:{kind:`createTable`},canMove:!1,canRename:!1},n[eV]={index:eV,isFolder:!0,children:[...t?[tV]:[],...r],data:{kind:`root`},canMove:!1,canRename:!1},{items:n,rootId:eV}}function iV({items:e,instanceDatabaseMap:t,children:n}){let r=wg(),[i,a]=(0,G.useState)(void 0),[o,s]=(0,G.useState)(``),c=(0,G.useCallback)(t=>{let n=t.target.closest(`[data-rct-item-id]`)?.getAttribute(`data-rct-item-id`),r=n?e[n]?.data:void 0;if(!r||r.kind===`root`||r.kind===`createTable`){a(void 0),t.preventDefault();return}a(r),s(`${t.clientX},${t.clientY}`)},[e]);return(0,K.jsxs)(Am,{modal:!1,children:[(0,K.jsx)(jm,{asChild:!0,children:(0,K.jsx)(`div`,{onContextMenu:c,className:`min-h-full`,children:n})}),i&&(0,K.jsxs)(Mm,{className:`min-w-44`,onCloseAutoFocus:e=>e.preventDefault(),children:[i.kind===`database`&&r&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Nm,{onSelect:()=>rL(`ShowCreateTable`,{databaseName:i.databaseName}),children:[(0,K.jsx)(Uo,{}),`Create a Table`]}),(0,K.jsx)(Fm,{}),(0,K.jsxs)(Nm,{variant:`destructive`,onSelect:()=>rL(`ShowDeleteDatabase`,{databaseName:i.databaseName}),children:[(0,K.jsx)(Is,{}),`Drop Database`]})]}),i.kind===`table`&&(0,K.jsx)(ez,{databaseName:i.databaseName,tableName:i.tableName,instanceDatabaseMap:t})]},o)]})}function aV(e){switch(e.data.kind){case`createTable`:return`Create a Table`;case`database`:return e.data.databaseName;case`table`:return e.data.tableName;default:return``}}var oV=`mr-1.5 h-4 w-4 shrink-0 pointer-events-none`;function sV({title:e,item:t}){let n=t.data.kind;return(0,K.jsxs)(K.Fragment,{children:[n===`createTable`?(0,K.jsx)(Uo,{className:F(oV,`text-green-500`)}):n===`database`?(0,K.jsx)(ia,{className:F(oV,`text-orange-400`)}):(0,K.jsx)(Es,{className:oV}),(0,K.jsx)(`span`,{className:`text-nowrap pointer-events-none`,children:e})]})}function cV({databaseName:e,tableName:t}){let{entityId:n}=q(),r=(0,G.useMemo)(()=>e&&t?[nV(e,t)]:e?[e]:[],[e,t]),[i,a]=(0,G.useState)(r[0]);(0,G.useEffect)(()=>{r[0]!==void 0&&a(r[0])},[r]);let[o,s]=FC(`DatabaseTreeExpanded/${n}`,e?[e]:[]);return(0,G.useEffect)(()=>{e&&s(t=>t.includes(e)?t:[...t,e])},[e,s]),{focusedItem:i,setFocusedItem:a,expandedItems:o,setExpandedItems:s,selectedItems:r}}var lV={"--rct-drop-target-height":`0px`};function uV({instanceDatabaseMap:e}){let t=z({strict:!1}),n=De(),r=wg(),{items:i,rootId:a}=(0,G.useMemo)(()=>rV(e,{canManage:r}),[e,r]),{focusedItem:o,setFocusedItem:s,expandedItems:c,setExpandedItems:l,selectedItems:u}=cV(t),d=(0,G.useCallback)((e,r)=>{n({to:jP({...t,databaseName:e,tableName:r})})},[n,t]),f=(0,G.useCallback)(e=>{switch(e.kind){case`createTable`:rL(`ShowCreateTable`,{databaseName:t.databaseName});break;case`database`:(t.databaseName!==e.databaseName||t.tableName)&&d(e.databaseName,void 0);break;case`table`:(t.databaseName!==e.databaseName||t.tableName!==e.tableName)&&d(e.databaseName,e.tableName)}},[t.databaseName,t.tableName,d]),p=(0,G.useCallback)(e=>{let t=e[e.length-1],n=t===void 0?void 0:i[t]?.data;n&&f(n)},[i,f]);return(0,K.jsx)(`div`,{className:`app-tree-scroll h-full overflow-auto pr-1.5`,style:lV,children:(0,K.jsx)(iV,{items:i,instanceDatabaseMap:e,children:(0,K.jsx)(uB,{canDragAndDrop:!1,canReorderItems:!1,canSearch:!0,canRename:!1,defaultInteractionMode:pz.DoubleClickItemToExpand,getItemTitle:aV,items:i,renderItemArrow:fz,renderItemTitle:sV,viewState:{databasesTree:{focusedItem:o,expandedItems:c,selectedItems:u}},onFocusItem:e=>s(e.index),onExpandItem:e=>l(t=>t.includes(e.index)?t:[...t,e.index]),onCollapseItem:e=>l(t=>t.filter(t=>t!==e.index)),onSelectItems:p,children:(0,K.jsx)(qB,{treeId:`databasesTree`,rootItem:a,treeLabel:`Databases tree`})})})})}function dV({instanceDatabaseMap:e}){return(0,K.jsxs)(`div`,{className:`pl-3 flex flex-col h-full min-h-0`,children:[(0,K.jsx)(`h1`,{className:`pt-3 pb-3 text-3xl shrink-0`,children:`Databases`}),e?(0,K.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,K.jsx)(uV,{instanceDatabaseMap:e})}):(0,K.jsx)(my,{className:`w-full flex-1 min-h-0 rounded-md`})]})}var fV=new Set([`contains`,`ends_with`,`ne`,`not_equal`]);function pV(e,t,n={}){let r=new Map;for(let{search_attribute:i,search_type:a}of e){let[e,o]=Array.isArray(i)?i:[i],s=o!==void 0&&Object.hasOwn(n,e)?n[e]:void 0,c=s?s.relatedAttributes.find(e=>e.attribute===o):t[e];if((c?.is_primary_key||c?.indexed)&&!fV.has(a))return[];let l=o===void 0?e:`${e}.${o}`;r.set(l,{attribute:l,relatedTableName:s?.relatedTableName})}return[...r.values()]}function mV(e,t){return`No index can answer this filter on ${t.map(({attribute:e})=>`"${e}"`).join(`, `)}, so Harper will read every record in ${[...new Set(t.map(t=>t.relatedTableName??e))].map(e=>`"${e}"`).join(` and `)} to find the matches. On a large table that can take a long time and slow the server down for everyone using it.\n\nRun it anyway?`}function hV(e,t,n){if(!n||!e?.length)return;let r=new Set;for(let t of e){let e=t[n];e!=null&&r.add(e)}let i=new Set;for(let e of t){let t=e[n];t!=null&&i.add(t)}let a=[...r].filter(e=>!i.has(e));if(a.length)return{kind:`lost`,keys:a};let o=[...i].filter(e=>!r.has(e));if(o.length)return{kind:`unknown`,keys:o};let s=e.filter(e=>e[n]==null).length,c=t.filter(e=>e[n]==null).length;if(c!==s)return{kind:`keyless`,added:Math.max(0,c-s),dropped:Math.max(0,s-c)}}function gV(e,t,n){if(!n||!e?.length)return[];let r=new Map(e.map(e=>[e[n],e])),i=[];for(let[e,a]of t.entries()){let t=a[n];if(t==null)continue;let o=r.get(t);if(!o)continue;let s=Object.keys(o).filter(e=>!Object.hasOwn(a,e));s.length&&i.push({index:e,removed:s})}return i}function _V(e){return[...new Set(e.flatMap(e=>e.removed))]}function vV({canEditRecords:e,canDeleteRecords:t,canReplaceRecords:n,replaceBlockedReason:r,setIsModalOpen:i,isModalOpen:a,primaryKey:o,missingPrimaryKey:s,recordUnavailable:c,syntheticAttributes:l,recordNavigation:u,data:d,onSaveChanges:f,onReplaceRecord:p,onDeleteRecord:m,isUpdateTableRecordsPending:h,isDeleteTableRecordsPending:g}){let _=Tx(),v=(0,G.useRef)(null),y=!!s||!!c,b=!e||y,[x,S]=(0,G.useState)(!1),[C,w]=(0,G.useState)(),{onEditorMount:T,showRecordJsonError:E,clearRecordJsonError:D}=II(),O=(0,G.useMemo)(()=>d?.map(({__createdtime__:e,__updatedtime__:t,...n})=>{for(let e of l??[])delete n[e];return n}),[d,l]),k=(0,G.useMemo)(()=>O&&JSON.stringify(O,null,4),[O]),A=k??``,j=(0,G.useRef)(A),M=(0,G.useRef)(null);(0,G.useLayoutEffect)(()=>{j.current!==A&&(j.current=A,M.current=A)},[A]);let ee=(0,G.useMemo)(()=>d&&JSON.stringify(d.map(e=>e[o]??null)),[d,o]),te=a?k:null,N=a?ee:null,[P,F]=(0,G.useState)(te),[ne,re]=(0,G.useState)(N),[ie,ae]=(0,G.useState)(!1),[oe,se]=(0,G.useState)(!1);te!==P&&(ae(a&&N!=null&&N===ne&&x),F(te),re(N),w(void 0),S(!1));let ce=a&&(d!==void 0||oe);oe!==ce&&se(ce);let le=h||g,ue=e=>{(!x||confirm(`Discard your unsaved changes to this record?`))&&(w(void 0),S(!1),ae(!1),e())};return(0,K.jsx)(_m,{onOpenChange:i,open:a,children:(0,K.jsxs)(wm,{"aria-describedby":void 0,resizable:!0,autoFocus:!b,onKeyDown:e=>{if(!u||le||v.current?.contains(e.target))return;let t=e.key===`ArrowLeft`||e.key===`ArrowUp`?u.hasPrevious?u.onPrevious:void 0:(e.key===`ArrowRight`||e.key===`ArrowDown`)&&u.hasNext?u.onNext:void 0;t&&(e.preventDefault(),ue(t))},onEscapeKeyDown:b?void 0:e=>{x&&e.preventDefault()},children:[(0,K.jsx)(Tm,{children:(0,K.jsxs)(Dm,{children:[b?`View`:`Edit`,` Record`]})}),y&&(0,K.jsxs)(c_,{variant:`warning`,children:[(0,K.jsx)(Rs,{}),(0,K.jsx)(l_,{children:s?`This record has no primary key value`:`This record couldn't be loaded`}),(0,K.jsxs)(u_,{children:[(0,K.jsx)(`p`,{children:s?o?(0,K.jsxs)(K.Fragment,{children:[`It has no value for the primary key`,` `,(0,K.jsx)(`code`,{children:o}),`, so it can't be looked up, edited, or deleted individually.`]}):`It has no primary key value, so it can't be looked up, edited, or deleted individually.`:o?(0,K.jsxs)(K.Fragment,{children:[`Nothing is stored under its primary key`,` `,(0,K.jsx)(`code`,{children:o}),`, so it can't be edited or deleted individually.`]}):`Nothing is stored under its primary key, so it can't be edited or deleted individually.`}),(0,K.jsx)(`p`,{children:`This usually means the table's primary key was changed after the record was created, so the value shown here isn't the key the record is actually stored under. To remove it, recreate the table or restore the original primary key attribute.`})]})]}),ie&&(0,K.jsxs)(c_,{variant:`warning`,children:[(0,K.jsx)(Rs,{}),(0,K.jsx)(l_,{children:`This record changed while you were editing it`}),(0,K.jsx)(u_,{children:`The editor was refreshed with the stored record, so the unsaved changes were discarded. Make them again and save.`})]}),d||oe?(0,K.jsx)(`div`,{ref:v,className:`flex-1 min-h-0 w-full`,children:(0,K.jsx)(Dx,{className:`w-full h-full`,language:xI,theme:_,options:{readOnly:b||!d,automaticLayout:!0},value:A,onMount:T,onChange:e=>{let t=M.current!==null&&e===M.current;M.current=null,!t&&(w(e),S(!0),ae(!1),D())}})}):(0,K.jsx)(Lc,{}),(0,K.jsx)(Em,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3 w-full`,children:[(0,K.jsx)(`div`,{className:`flex`,children:t&&!y&&(0,K.jsxs)(H,{variant:`destructive`,type:`button`,autoFocus:!1,onClick:()=>{let e=d?.[0]?.[o];e!=null&&m([e])},disabled:g||h,children:[(0,K.jsx)(Is,{}),` Delete Record`]})}),u&&(0,K.jsx)(yV,{...u,disabled:le,onPrevious:()=>ue(u.onPrevious),onNext:()=>ue(u.onNext)}),(0,K.jsx)(`div`,{className:`flex`,children:e&&!y&&(0,K.jsxs)(H,{variant:`submit`,autoFocus:!0,accessKey:`s`,onClick:()=>{if(C===void 0){i(!1);return}let e=TI(C);if(!e.ok){U.error(`This record isn't valid JSON`,{description:DI(e.error)}),E(e.error);return}let t=Array.isArray(e.value)?e.value:[e.value],a=hV(O,t,o);if(a){U.error(a.kind===`lost`?`This record's ${o} is missing from the save`:a.kind===`unknown`?`This edit names a ${o} the editor didn't load`:`This edit ${a.added?`adds`:`drops`} ${(a.added||a.dropped)===1?`a record`:`${a.added||a.dropped} records`} with no ${o}`,{description:a.kind===`lost`?`${o} identifies the record, so restore ${a.keys.join(`, `)} to save this edit. Changing it doesn't rename a record — the save would do nothing, or overwrite whatever is stored under the new value. To delete the record, use Delete Record.`:a.kind===`unknown`?`Saving would edit the record stored under ${a.keys.join(`, `)}, which isn't the record open here. Remove it from the JSON and edit that record directly.`:a.added?`A record with no ${o} can't be written from here — the save would skip it and still report success. Remove it, and use Add Record to create a record.`:`Removing a record from the JSON doesn't delete it, so the save would report success having left it alone. Put it back, and use Delete Record to delete a record.`});return}let s=gV(O,t,o);if(s.length){if(s.length<t.length){U.error(`Removing an attribute can't be combined with other record edits`,{description:`Removing an attribute replaces the whole record, which would overwrite any concurrent change to the other records in this payload. Remove the same attribute from every record here, or put it back and save the value changes on their own — the records loaded together have to be saved together.`});return}if(!n){let e=_V(s),t=e.length===1?`an attribute`:`attributes`,n=`Removing ${e.join(`, `)}`;U.error(r===`permission`?`You don't have permission to remove ${t}`:`This Harper version can't remove ${t}`,{description:r===`permission`?`${n} rewrites the record through the 'put' operation, which needs both insert and update on this table, and 'put' in the role's allowed operations. Ask an administrator for those grants, or set the value to null instead of removing it.`:`${n} needs the 'put' operation, added in Harper 5.3.0. On this instance the update operation can only merge, so the attribute would silently stay. Upgrade the instance, or set the value to null instead of removing it.`});return}p(t);return}f(t)},disabled:h||g,children:[(0,K.jsx)($o,{}),` `,(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`S`}),`ave Changes`]})]})})]})})]})})}function yV({position:e,total:t,isTotalEstimated:n,hasPrevious:r,hasNext:i,onPrevious:a,onNext:o,disabled:s}){return(0,K.jsxs)(`div`,{className:`flex items-center rounded-lg border border-border text-sm text-muted-foreground`,children:[(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Previous record`,disabled:s||!r,onClick:a,children:(0,K.jsx)(bi,{})}),(0,K.jsxs)(`span`,{className:`whitespace-nowrap px-1 tabular-nums`,"aria-live":`polite`,children:[`Record `,e===void 0?`…`:By(e),t!==void 0&&(0,K.jsxs)(K.Fragment,{children:[` of `,n?`~`:``,By(t)]})]}),(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Next record`,disabled:s||!i,onClick:o,children:(0,K.jsx)(Si,{})})]})}function bV(e,t){if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i of n)if(!r.includes(i)||e[i]!==t[i])return!1;return!0}function xV(e,t){let[n,r]=(0,G.useState)(t),[i,a]=(0,G.useState)(e);return(0,G.useEffect)(()=>{bV(n,t)||(r(t),a(e))},[n,t,e]),bV(n,t)?[i,a]:[e,a]}function SV(e=!1){let[t,n]=(0,G.useState)(e),r=(0,G.useCallback)(e=>{e?.preventDefault?.(),n(e=>!e)},[]),i=(0,G.useCallback)(e=>{e?.preventDefault?.(),n(!0)},[]),a=(0,G.useCallback)(e=>{e?.preventDefault?.(),n(!1)},[]);return(0,G.useMemo)(()=>({toggled:t,setToggled:n,toggle:r,toggleOn:i,toggleOff:a}),[r,n,a,i,t])}async function CV({databaseName:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`cleanup_orphan_blobs`,database:e});return n}function wV(){return I({mutationFn:CV})}function TV(e){return e!==void 0&&!Array.isArray(e)}var EV=`Harper's response didn't report which records it wrote, so the change may not have been saved.`;function DV(e,t){if(!Array.isArray(e?.deleted_hashes)||TV(e?.skipped_hashes))return{message:EV,wroteNothing:!1};let n=e.skipped_hashes?.length??0,r=e.deleted_hashes.length;if(!(n===0&&r>=t))return{message:`Harper deleted ${r} of ${t} records${n>0?` and skipped ${n}`:``}. A record is skipped when nothing is stored under its primary key.`,wroteNothing:r===0}}async function OV({databaseName:e,tableName:t,hashValues:n,instanceClient:r}){let{data:i}=await r.post(`/`,{operation:`delete`,database:e,table:t,hash_values:n});return i}function kV(){return I({mutationFn:OV})}async function AV({databaseName:e,tableName:t,instanceClient:n}){let{data:r}=await n.post(`/`,{operation:`describe_table`,database:e,table:t,exact_count:!0},{timeout:0});return r.record_count}function jV(e){return B({enabled:e.enabled&&!!e.databaseName&&!!e.tableName,queryKey:[e.entityId,e.databaseName,e.tableName,`record_count`,`exact`],queryFn:()=>AV(e),staleTime:6e4,gcTime:5e3,retry:!1})}function MV(e){return!!e&&vr(`5.3.0`,e)}function NV(e,t){if(!t)return`permission`;if(e!==void 0&&!MV(e))return`version`}async function PV({databaseName:e,tableName:t,records:n,instanceClient:r}){let{data:i}=await r.post(`/`,{operation:`put`,database:e,table:t,records:n});return i}function FV(e,t){if(!Array.isArray(e?.put_hashes))return{message:EV,wroteNothing:!1};if(!(e.put_hashes.length>=t))return{message:`Harper reported writing ${e.put_hashes.length} of ${t} records, so the change may not have been saved.`,wroteNothing:e.put_hashes.length===0}}function IV(){return I({mutationFn:PV})}function LV(e,t){if(TV(e?.update_hashes)||TV(e?.skipped_hashes))return{message:EV,wroteNothing:!1};let n=e?.skipped_hashes?.length??0,r=e?.update_hashes?.length??t;if(!(n===0&&r>=t))return{message:`Harper updated ${r} of ${t} records${n>0?` and skipped ${n}`:``}. A record is skipped when nothing is stored under its primary key.`,wroteNothing:Array.isArray(e?.update_hashes)&&r===0}}async function RV(e){let{databaseName:t,tableName:n,records:r,instanceClient:i}=e,{data:a}=await i.post(`/`,{operation:`update`,database:t,table:n,records:r});return a}function zV(){return I({mutationFn:RV})}var BV=ee(x(),x());function VV({applyFilters:e,columnFiltersForm:t,headerGroups:n,selectColumnWidth:r}){let i=(0,G.useCallback)(t=>{if(t.key===`Enter`)return t.preventDefault(),e(),!1},[e]);return(0,K.jsx)(xb,{children:(0,K.jsx)(Od,{...t,children:n.map(e=>(0,K.jsxs)(Cb,{className:`border-none`,children:[r!==void 0&&(0,K.jsx)(Eb,{style:{width:`${r}px`},className:`sticky top-10 left-0 z-20 bg-card dark:bg-black-dark border-b border-border shadow-[inset_-1px_0_0_var(--color-border)]`}),e.headers.map(e=>{let n=e.column.columnDef.meta?.relationshipInfo,r=e.column.columnDef.meta?.unindexed;return(0,K.jsx)(Eb,{style:{width:`${e.column.getSize()}px`},className:`sticky top-10 z-10 bg-card dark:bg-black-dark border-b border-border`,children:e.column.columnDef.enableColumnFilter&&(0,K.jsx)(Y,{control:t.control,name:e.id,render:({field:t})=>(0,K.jsxs)(X,{className:`border-r border-r-black`,children:[(0,K.jsxs)(`div`,{className:`flex items-center`,children:[n&&(0,K.jsx)(HV,{relationshipInfo:n,value:t.value??``,onChange:t.onChange}),(0,K.jsx)(J,{children:(0,K.jsx)($,{...t,type:`text`,autoCapitalize:`none`,autoComplete:`off`,className:`rounded-none`,onKeyDown:i,value:t.value??``,placeholder:n?`.${n.relatedPrimaryKey} value`:r?`not indexed`:void 0,"aria-label":`Filter ${e.column.id}`,title:e.column.columnDef.meta?.filterHint})})]}),(0,K.jsx)(Q,{})]})})},e.id)})]},e.id))})})}function HV({relationshipInfo:e,value:t,onChange:n}){return(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,className:`rounded-none shrink-0`,title:`Filter by a ${e.relatedTableName} property`,children:(0,K.jsx)(er,{})})}),(0,K.jsx)(vc,{side:`bottom`,align:`start`,children:e.relatedAttributes.map(e=>(0,K.jsxs)(yc,{onClick:()=>{let r=t.replace(/^\s*\.\S*\s*/,``);n(`.${e.attribute} ${r}`)},children:[e.attribute,e.type&&(0,K.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.type})]},e.attribute))})]})}function UV({tableName:e,hasPrimaryKey:t,isFiltered:n,isPastFirstPage:r,recordCount:i,canImportFile:a,canImportUrl:o,canSeedSample:s,canSeedRandom:c,canAddRecords:l,onImport:u,onSeed:d,onAddRecords:f,onClearFilters:p}){if(!t)return(0,K.jsxs)(KV,{children:[(0,K.jsxs)(qV,{children:[(0,K.jsx)(`span`,{className:`font-mono`,children:e}),` has no primary key`]}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[i?`It reports ${oe(By(i),`record`,`records`)}, but Studio`:`Studio`,` `,`lists and opens records by their primary key, so it can't browse this table. To browse its records here, copy them into a new table that has a primary key.`]})]});if(r)return(0,K.jsxs)(KV,{children:[(0,K.jsx)(qV,{children:`No records on this page`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`There are fewer records than this page starts at. Try an earlier page.`})]});if(n)return(0,K.jsxs)(KV,{children:[(0,K.jsx)(qV,{children:`No records match these filters`}),(0,K.jsxs)(H,{variant:`ghost`,onClick:p,children:[(0,K.jsx)(Sa,{}),`Clear Filters`]})]});if(i)return(0,K.jsxs)(KV,{children:[(0,K.jsx)(qV,{children:`No records came back`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This table reports records, but the page returned none. Try refreshing, or turn off Only If Cached in the table options menu.`})]});let m=a||o,h=s||c;return(0,K.jsxs)(KV,{children:[(0,K.jsx)(qV,{children:i===0?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`font-mono`,children:e}),` has no records yet`]}):`No records to show`}),m&&h&&(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Two ways to get some in — bring your own, or start from data we provide.`}),(m||h)&&(0,K.jsxs)(`div`,{className:`flex w-full flex-col gap-3 sm:flex-row`,children:[m&&(0,K.jsx)(JV,{Icon:Ji,title:`Import your data`,description:WV(a,o),action:`Import data`,onClick:u}),h&&(0,K.jsx)(JV,{Icon:Fo,title:`Seed some data`,description:GV(s,c),action:`Seed data`,onClick:d})]}),l&&(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[m||h?`Or write one yourself: `:`Write one yourself: `,(0,K.jsxs)(H,{variant:`link`,className:`h-auto p-0 text-sm dark:text-violet-300`,onClick:f,children:[(0,K.jsx)(Uo,{}),`Add New Record(s)`]})]})]})}function WV(e,t){return e?t?`Upload a CSV or JSON file, or load a CSV from a URL the instance can reach.`:`Upload a CSV or JSON file.`:`Load a CSV from a URL the instance can reach.`}function GV(e,t){return e?t?`Fill this table with random records, or load a ready-made sample dataset into a table of its own.`:`Load a ready-made sample dataset. It arrives in a table of its own.`:`Fill this table with random records modelled on its columns.`}function KV({children:e}){return(0,K.jsx)(`div`,{className:`h-full overflow-y-auto p-6`,children:(0,K.jsx)(`div`,{className:`flex min-h-full items-center justify-center`,children:(0,K.jsxs)(`div`,{className:`flex w-full max-w-2xl flex-col items-center gap-4 text-center`,children:[(0,K.jsx)(Os,{"aria-hidden":!0,className:`size-8 text-muted-foreground/50`}),e]})})})}function qV({children:e}){return(0,K.jsx)(`h2`,{className:`text-base font-medium`,children:e})}function JV({Icon:e,title:t,description:n,action:r,onClick:i}){return(0,K.jsxs)(`button`,{type:`button`,onClick:i,className:`group flex flex-1 cursor-pointer flex-col items-start gap-1.5 rounded-lg border border-border p-4 text-left transition-colors hover:border-primary hover:bg-accent/50 focus-visible:ring-1 focus-visible:ring-purple-200 focus-visible:outline-1 dark:border-grey-700 dark:hover:border-violet-300`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[(0,K.jsx)(e,{className:`size-4 text-primary dark:text-violet-300`}),t]}),(0,K.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:n}),(0,K.jsxs)(`span`,{className:`mt-1 text-sm text-primary group-hover:underline dark:text-violet-300`,children:[r,` →`]})]})}var YV={text:`Text`,number:`Numbers`,date:`Dates`,boolean:`Booleans`};function XV({id:e}){return(0,K.jsxs)(`section`,{id:e,"aria-label":`Filter syntax`,className:`mx-4 mb-3 rounded-md border border-border p-3 text-sm [font-variant-ligatures:none]`,children:[(0,K.jsx)(`dl`,{className:`grid gap-x-6 gap-y-2 sm:grid-cols-2 lg:grid-cols-4`,children:Object.keys(ZL).map(e=>(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{className:`font-semibold`,children:YV[e]}),ZL[e].map(e=>(0,K.jsx)(`dd`,{className:`font-mono text-xs`,children:e},e))]},e))}),(0,K.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`A relationship column filters on a property of the related table:`,` `,(0,K.jsx)(`code`,{children:`.name Anvil`}),`. A filter that no index can answer (a column marked “not indexed”, an ends with, a contains or a !=) asks before it runs, unless another filter in it uses an index.`]})]})}function ZV({columns:e,columnVisibility:t,setColumnVisibility:n}){let r=(0,G.useMemo)(()=>e.map(e=>typeof e.header==`string`?e.header:void 0).filter(fr),[e]),i=(0,G.useCallback)((e,r)=>{n({...t,[e]:r})},[t,n]),a=(0,G.useCallback)(e=>{n({...t,...Object.fromEntries(r.map(t=>[t,e]))})},[r,t,n]),o=(0,G.useMemo)(()=>r.every(e=>t[e]??!0),[r,t]),s=(0,G.useMemo)(()=>r.every(e=>!(t[e]??!0)),[r,t]);return(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsxs)(H,{variant:`ghost`,children:[(0,K.jsx)(Qi,{className:`inline-block `}),`Columns`]})}),(0,K.jsxs)(vc,{children:[r.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(yc,{inset:!0,disabled:o,onSelect:e=>{e.preventDefault(),a(!0)},children:`Select all`}),(0,K.jsx)(yc,{inset:!0,disabled:s,onSelect:e=>{e.preventDefault(),a(!1)},children:`Deselect all`}),(0,K.jsx)(wc,{})]}),r.map(e=>(0,K.jsx)(QV,{columnHeader:e,isChecked:t[e]??!0,toggleColumn:i},e))]})]})}function QV({columnHeader:e,isChecked:t,toggleColumn:n}){let r=(0,G.useCallback)(t=>{n(e,t)},[e,n]);return(0,K.jsx)(bc,{checked:t,onCheckedChange:r,onSelect:e=>e.preventDefault(),children:e})}function $V({className:e}){return(0,K.jsx)(no,{className:v(`animate-spin`,e)})}var eH=32,tH=`shadow-[inset_-1px_0_0_var(--color-border)]`;function nH(e,t){return!t||typeof e!=`object`||!e||!Object.hasOwn(e,t)?void 0:e[t]??void 0}function rH({applyFilters:e,columnFiltersForm:t,columns:n,columnVisibility:r,columnSizing:i,setColumnSizing:a,data:o,emptyState:s,isFetching:c,onColumnClick:l,onRowClick:u,pageIndex:d,pageSize:f,primaryKey:p,rowSelection:m,resultSetKey:h,tableIdentity:g,setPageIndex:_,setPageSize:v,filtersToggled:y,totalPages:b,totalRecords:x,uncountedPage:S,isEstimatedCount:C,estimatedRange:w,isExactCountFetching:T,isExactCountError:E,onRequestExactCount:D}){let O=tt({features:Lb,data:o||[],columns:n,manualSorting:!0,enableColumnResizing:!0,columnResizeMode:`onEnd`,onColumnSizingChange:a,defaultColumn:{minSize:80},state:{columnVisibility:r,columnSizing:i}}),k=!!m&&!!p,A=(0,G.useMemo)(()=>k?(o??[]).map(e=>nH(e,p)).filter(e=>e!==void 0):[],[k,o,p]),j=m?A.filter(e=>m.selectedKeys.has(e)).length:0,M=A.length>0&&j===A.length,ee=j>0&&!M,[te,N]=(0,G.useState)(void 0),P=(0,G.useCallback)((e,t)=>{if(!m)return;let n=t?A.indexOf(te):-1,r=A.indexOf(e);if(n===-1||r===-1){m.toggleRow(e),N(e);return}let[i,a]=n<=r?[n,r]:[r,n];m.setRangeSelected(A.slice(i,a+1),!m.selectedKeys.has(e))},[m,A,te]),ne=(0,G.useRef)(null),re=(0,G.useRef)(!1),ie=(0,G.useRef)(!1),ae=(0,G.useCallback)((e,t)=>{!m||e===void 0||t.button!==0||t.shiftKey||t.ctrlKey||t.metaKey||(re.current=!0,ne.current={originKey:e,selected:!m.selectedKeys.has(e),snapshot:new Set(m.selectedKeys),applied:[],lastKey:e})},[m]),oe=(0,G.useCallback)((e,t)=>{let n=ne.current;if(!n)return;if(!(t&1)){ne.current=null;return}if(!m||e===void 0||e===n.lastKey)return;let r=A.indexOf(n.originKey),i=A.indexOf(e);if(r===-1||i===-1)return;n.lastKey=e;let[a,o]=r<=i?[r,i]:[i,r],s=A.slice(a,o+1),c=new Set(s),l=n.applied.filter(e=>!c.has(e)),u=l.filter(e=>n.snapshot.has(e)),d=l.filter(e=>!n.snapshot.has(e));u.length&&m.setRangeSelected(u,!0),d.length&&m.setRangeSelected(d,!1),m.setRangeSelected(s,n.selected),n.applied=s,N(n.originKey),ie.current=!0},[m,A]);(0,G.useEffect)(()=>{let e=()=>{ne.current=null},t=()=>{re.current=!1,ie.current=!1};return window.addEventListener(`mouseup`,e),window.addEventListener(`mousedown`,t,!0),()=>{window.removeEventListener(`mouseup`,e),window.removeEventListener(`mousedown`,t,!0)}},[]),(0,G.useLayoutEffect)(()=>{N(void 0),ne.current=null},[h]);let se=(0,G.useRef)(null),[ce,le]=(0,G.useState)(0);(0,G.useLayoutEffect)(()=>{let e=se.current;e&&(e.scrollTop=0)},[h]),(0,G.useLayoutEffect)(()=>{let e=se.current;e&&(e.scrollTop=0,e.scrollLeft=0)},[g]);let ue=O.state.columnResizing,de=ue.isResizingColumn;(0,G.useLayoutEffect)(()=>{de&&le(se.current?.scrollLeft??0)},[de]);let fe=null;if(de){let e=O.options.defaultColumn?.minSize??20,t=O.getColumn(de)?.getSize()??0,n=k?eH:0;for(let e of O.getVisibleLeafColumns())if(n+=e.getSize(),e.id===de)break;fe=n+Math.max(ue.deltaOffset??0,e-t)-ce}let pe=O.getRowModel().rows.length>0,me=o===void 0,he=!pe&&!me&&!!s;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`relative flex flex-col grow min-h-0`,children:[(0,K.jsxs)(bb,{containerRef:se,containerClassName:F(`rounded-t-md bg-card dark:bg-black-dark min-h-0 overflow-y-auto`,he?`shrink-0`:`rounded-b-md grow`),className:`table-fixed`,children:[(0,K.jsx)(xb,{children:O.getHeaderGroups().map(e=>(0,K.jsxs)(Cb,{className:`border-none`,children:[k&&(0,K.jsx)(wb,{style:{width:`${eH}px`},className:F(`sticky top-0 left-0 z-20 p-0 bg-card dark:bg-black-dark border-b border-border`,tH),children:(0,K.jsx)(iH,{checked:M,indeterminate:ee,disabled:A.length===0,onToggle:()=>{m.toggleAll(A,!M),N(M?void 0:A[0])}})}),e.headers.map(e=>(0,K.jsx)(Tb,{header:e,onColumnClick:l,className:`sticky top-0 z-10 bg-card dark:bg-black-dark border-b border-border font-mono text-[0.8rem] [&_button]:text-[0.8rem]`},e.id)),(0,K.jsx)(wb,{"aria-hidden":!0,className:`w-full p-0 sticky top-0 z-10 bg-card dark:bg-black-dark border-b border-border`})]},e.id))}),y&&(0,K.jsx)(VV,{applyFilters:e,columnFiltersForm:t,headerGroups:O.getHeaderGroups(),selectColumnWidth:k?eH:void 0}),!he&&(0,K.jsx)(Sb,{className:`bg-background dark:bg-black border-y border-border dark:border-grey-700`,children:pe?O.getRowModel().rows.map(e=>(0,K.jsx)(oH,{row:e,onRowClick:u,primaryKey:p,rowSelection:k?m:void 0,onSelectRow:P,onBeginDrag:ae,onDragOver:oe,pressedInGutterRef:re,dragMovedRef:ie},e.id)):(0,K.jsx)(Cb,{children:(0,K.jsx)(Eb,{colSpan:n.length+1+ +!!k,className:`h-24 text-center`,children:c||me?(0,K.jsx)($V,{className:`opacity-50 inline-block`}):(0,K.jsx)(`span`,{children:`No results.`})})})})]}),he&&(0,K.jsx)(`div`,{className:`grow min-h-0 rounded-b-md bg-background dark:bg-black border border-t-0 border-border dark:border-grey-700`,children:s}),fe!==null&&(0,K.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute top-0 bottom-0 z-20 w-0.5 bg-primary`,style:{left:`${fe}px`}})]}),(0,K.jsx)(Ob,{pageIndex:d,pageSize:f,totalPages:b,totalRecords:x,uncountedPage:S,isEstimatedCount:C,estimatedRange:w,isExactCountFetching:T,isExactCountError:E,onRequestExactCount:D,setPageIndex:_,setPageSize:v})]})}function iH({checked:e,indeterminate:t,disabled:n,onToggle:r}){let i=(0,G.useRef)(null);return(0,G.useLayoutEffect)(()=>{i.current&&(i.current.indeterminate=t)},[t]),(0,K.jsx)(aH,{children:(0,K.jsx)(`input`,{ref:i,type:`checkbox`,"aria-label":e?`Deselect all records on this page`:`Select all records on this page`,checked:e,disabled:n,onChange:r})})}function aH({children:e}){return(0,K.jsx)(`label`,{className:`flex h-full w-full items-center justify-center py-2`,children:e})}function oH({row:e,primaryKey:t,onRowClick:n,rowSelection:r,onSelectRow:i,onBeginDrag:a,onDragOver:o,pressedInGutterRef:s,dragMovedRef:c}){let l=e.getVisibleCells(),u=(0,G.useMemo)(()=>{let n=e.original;return n&&n.message===`This entry has expired`?l[0]?.column?.id===t?[(0,K.jsx)(cH,{cell:l[0]},l[0].id),(0,K.jsx)(lH,{colSpan:l.length-1},`expired`)]:[(0,K.jsx)(lH,{colSpan:l.length},`expired`)]:l.map(e=>(0,K.jsx)(cH,{cell:e},e.id))},[e,t,l]),d=r?nH(e.original,t):void 0,f=d!==void 0&&!!r?.selectedKeys.has(d);return(0,K.jsxs)(Cb,{"data-state":f?`selected`:void 0,onMouseOver:e=>o?.(d,e.buttons),onMouseDown:e=>{r&&e.shiftKey&&e.preventDefault()},onClick:t=>{if(!s?.current){if(r&&d!==void 0&&(t.ctrlKey||t.metaKey||t.shiftKey)){t.preventDefault(),i?.(d,t.shiftKey);return}n?.(e)}},className:F(`hover:bg-muted/10 data-[state=selected]:bg-muted`,n&&`cursor-pointer`),children:[r&&(0,K.jsx)(Eb,{className:F(`sticky left-0 z-10 p-0`,tH,f?`bg-muted`:`bg-background dark:bg-black`),onClick:KL,onMouseDown:e=>{e.preventDefault(),e.currentTarget.querySelector(`input`)?.focus(),a?.(d,e)},children:(0,K.jsx)(aH,{children:(0,K.jsx)(`input`,{type:`checkbox`,"aria-label":f?`Deselect record`:`Select record`,checked:f,disabled:d===void 0,onClick:e=>{c?.current&&e.detail!==0||d===void 0||i?.(d,e.shiftKey)},onChange:sH})})}),u,(0,K.jsx)(Eb,{"aria-hidden":!0,className:`p-0`})]})}function sH(){}function cH({cell:e}){let t=e.column.getSize();return(0,K.jsx)(Eb,{"data-col-id":e.column.id,style:{width:`${t}px`,maxWidth:`${t}px`},className:`px-2 py-2 font-mono text-[0.8rem] overflow-hidden text-ellipsis whitespace-nowrap`,children:ot(e.column.columnDef.cell,e.getContext())})}function lH({colSpan:e}){return(0,K.jsx)(Eb,{colSpan:e,className:`px-2 py-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,children:(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`This entry has expired`})})}var uH=new Set,dH=[],fH=[];function pH({instanceDatabaseMap:e,instanceDatabaseMapLoading:t=!1,databaseName:n,tableName:r}){let i=z({strict:!1}),a=q(),{clusterId:o,instanceId:s}=i,{toggled:c,toggle:l}=SV(!0),u=wr(`instance:update`),d=Tg(s??o,n,r,`insert`),f=Dg(s??o,n,r),p=kg(),m=Tg(s??o,n,r,`update`),h=Tg(s??o,n,r,`delete`),g=wg(),{data:_}=L(WL({...a,databaseName:n,tableName:r})),v=e?.[n],y=v?.[r],b=_??y,x=f&&p.methods.file,S=f&&p.methods.url,C=f&&p.allowsSource(`csv-data`),w=(0,G.useMemo)(()=>O_(b?.attributes??[],`attribute`),[b]),{data:T,isLoading:E}=L(PF(a)),{data:D}=L(HE(a)),O=Eg(s??o,n,r),k=NV(D?.version,O),A=k===void 0,j=T?.[n]?.[r],M=(0,G.useMemo)(()=>xL(y?.attributes,v,j),[y,v,j]),ee=f&&p.allowsSource(`json-records`)&&M.length>0,te=(0,G.useMemo)(()=>VF(b,v,j),[b,v,j]),N=(0,G.useMemo)(()=>KF(b,v),[b,v]),P=(0,G.useMemo)(()=>UF(b?.attributes,v,j),[b,v,j]),[F,ne]=xV(null,i),[re,ie]=(0,G.useState)(!1),[ae,se]=xV(null,i),[ce,le]=xV(null,i),[ue,de]=(0,G.useState)(null),fe=ue!==null,pe=(0,G.useMemo)(()=>g&&!!v&&Object.keys(v).length>1,[g,v]),{toggled:me,toggleOn:he,toggleOff:ge}=SV(!1),{toggled:_e,toggle:ve}=SV(!1),ye=on({resolver:mt(BV)}),{reset:be}=ye,xe=ye.watch(),[Se,Ce]=xV(null,[i.clusterId,i.instanceId,n,r]),[we,I]=xV(!1,[i.clusterId,i.instanceId,n,r]),Te=(0,G.useCallback)(e=>{let t=[];for(let n in e){let r=e[n];if(r?.length)try{t.push(...qR(n,r,w[n],Object.hasOwn(te,n)?te[n]:void 0))}catch(e){U.error(String(e))}}return t},[w,te]),Ee=(0,G.useCallback)(e=>{let t=pV(e,w,te);return t.length&&!confirm(mV(r,t))?!1:(I(t.length>0),Ce(e.length?e:null),!0)},[w,te,r,I,Ce]),De=(0,G.useCallback)(()=>{Ee(Te(xe))&&be({...xe})},[Ee,Te,be,xe]),R=(0,G.useCallback)(()=>{be({},{keepValues:!1,keepDirtyValues:!1,keepDefaultValues:!1}),be(),Ce(null),I(!1),ge()},[ge,be,Ce,I]);(0,G.useEffect)(function(){return R()},[i,R]);let{filters:ke}=Oe({strict:!1}),Ae=JSON.stringify([n,r,ke??null]),je=(0,G.useRef)(null);(0,G.useEffect)(function(){if(!b||je.current===Ae||ke&&(E||t))return;let e=je.current===null;je.current=Ae,ke?(Ee(Te(ke))?be({...ke}):be({...ke},{keepDefaultValues:!0}),he()):e||R()},[ke,Ae,b,E,t,be,Te,Ee,he,R]);let Me=cR(b),Ne=!b||!!Me,[B,Pe]=xV(null,i),Fe=(0,G.useMemo)(()=>B??{attribute:Me,descending:!1},[B,Me]),[Ie,Le]=xV(0,[n,r,Se]),[Re,ze]=(0,G.useState)(20),[Be,Ve]=xV(null,[n,r,Se,Re,c]),He=_?.record_count??y?.record_count,Ue=_?.estimated_record_range??y?.estimated_record_range,[We,Ge]=xV(!1,[n,r]),{data:Ke,isFetching:qe,isError:Je,refetch:Ye}=L(jV({...a,enabled:We,databaseName:n,tableName:r})),Xe=(0,G.useCallback)(()=>{We?Ye():Ge(!0)},[We,Ye,Ge]),Qe=Ke??He,$e=Qe&&Ne?Math.ceil(Qe/Re):0,et=Ke===void 0&&Ue!==void 0,tt=me&&!!Se,nt=JSON.stringify([n,r]),rt=JSON.stringify([a.entityId,n,r,Ie,Re,Fe,tt?Se:null,c]),[it,at]=xV(uH,[rt]),ot=(0,G.useCallback)(e=>{at(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})},[at]),st=(0,G.useCallback)((e,t)=>{at(t?new Set(e):uH)},[at]),ct=(0,G.useCallback)((e,t)=>{at(n=>{let r=new Set(n);for(let n of e)t?r.add(n):r.delete(n);return r})},[at]),lt=(0,G.useMemo)(()=>h?{selectedKeys:it,toggleRow:ot,toggleAll:st,setRangeSelected:ct}:void 0,[h,it,ot,st,ct]),ut=Fw({...a,enabled:!tt&&!!Me,databaseName:n,tableName:r,searchAttribute:Me,sort:Fe,pageSize:Re,pageIndex:Ie,onlyIfCached:c,getAttributes:N}),{data:dt,isFetching:ft,isError:pt}=L(ut),ht=WR({...a,enabled:tt&&!!Me,databaseName:n,tableName:r,conditions:Se,sort:Fe,pageSize:Re,pageIndex:Ie,onlyIfCached:c,getAttributes:N,allowFullScan:we}),{data:gt,isFetching:_t,isError:vt}=L(ht),yt=tt?gt:dt,bt=ft||_t,xt=tt?vt:pt,St=yt?.data,Ct=(0,G.useMemo)(()=>new Set([...(b?.attributes??[]).map(({attribute:e})=>e),...Object.keys(te)]),[b,te]),wt=(0,G.useMemo)(()=>St&&fR(St,Ct),[St,Ct]),Tt=JSON.stringify([a.entityId,n,r]),[Et,Dt]=(0,G.useState)({key:Tt,extras:fH});wt&&(Et.key!==Tt||!pR(Et.extras,wt))&&Dt({key:Tt,extras:wt});let{dataTableColumns:Ot}=sR(b,te,wt??(Et.key===Tt?Et.extras:fH)),kt=tt?{rowCount:gt?.data.length,hasNextPage:gt?.hasNextPage}:void 0,At=kt?!!kt.hasNextPage:!!St&&St.length===Re&&Be!==Ie,jt=(0,G.useMemo)(()=>(St??[]).map(e=>nH(e,Me)).filter(e=>e!==void 0&&it.has(e)),[St,Me,it]),{data:Mt,isFetching:Nt,isError:Pt}=L(jL({...a,enabled:re,databaseName:n,tableName:r,ids:F})),Ft=re&&!fe&&!!ae&&(!Me||ae[Me]==null),It=Mt?.data,Lt=!Ft&&!fe&&!!F?.length&&!Nt&&(Pt||Array.isArray(It)&&It.length===0),{mutate:Rt,isPending:zt}=zV(),{mutate:Bt,isPending:Vt}=kV(),{mutate:Ht,isPending:Ut}=IV(),{mutate:Wt,isPending:Gt}=wV(),Kt=Ze(),qt=(0,G.useCallback)(()=>(Ve(null),at(uH),Kt.invalidateQueries({queryKey:[a.entityId,n,r]})),[Kt,a.entityId,n,r,Ve,at]),Jt=(0,G.useCallback)(()=>Kt.invalidateQueries({queryKey:AL(a.entityId,n,r)}),[Kt,a.entityId,n,r]),Yt=(0,G.useCallback)(async()=>{confirm(`Are you sure you want to cleanup orphan blobs for database "${n}"?`)&&Wt({...a,databaseName:n},{onSuccess:e=>{U.success(e.message||`Orphan blobs cleanup started successfully`),qt()},onError:e=>{pc(e)&&U.error(e instanceof Error?e.message:`Failed to cleanup orphan blobs`)}})},[Wt,n,a,qt]),{exportCsv:Xt,isExporting:Zt}=$R(),Qt=(0,G.useCallback)(()=>{Xt({databaseName:n,tableName:r,primaryKey:Me,sort:Fe,conditions:tt?Se:null,allowFullScan:tt&&we,instanceTable:b,databaseTables:v})},[Xt,n,r,Me,Fe,tt,Se,we,b,v]),$t=(0,G.useCallback)(e=>{if(e?.wroteNothing){U.error(`The record wasn't updated`,{description:e.message});return}if(qt(),Jt(),ie(!1),e){U.error(`The record wasn't fully updated`,{description:e.message});return}U.success(`Record updated successfully`)},[qt,Jt]),en=(0,G.useCallback)(e=>{Rt({...a,databaseName:n,tableName:r,records:e},{onSuccess:t=>$t(LV(t,e.length))})},[Rt,a,n,r,$t]),tn=(0,G.useCallback)(e=>{Ht({...a,databaseName:n,tableName:r,records:e},{onSuccess:t=>$t(FV(t,e.length))})},[Ht,a,n,r,$t]),nn=(0,G.useCallback)(e=>{Bt({...a,databaseName:n,tableName:r,hashValues:e},{onSuccess:t=>{let n=DV(t,e.length);if(n?.wroteNothing){U.error(`The record wasn't deleted`,{description:n.message});return}if(qt(),Jt(),ie(!1),n){U.error(`The record wasn't fully deleted`,{description:n.message});return}U.success(`Record deleted successfully`)}})},[Bt,a,n,r,qt,Jt]),rn=(0,G.useCallback)(()=>{let e=jt;e.length&&confirm(`Permanently delete ${oe(e.length,`record`,`records`)} from "${r}"?`)&&Bt({...a,databaseName:n,tableName:r,hashValues:e},{onSuccess:t=>{qt(),Jt();let n=DV(t,e.length);if(n){U.error(`The records weren't all deleted`,{description:n.message});return}U.success(`${oe(e.length,`record`,`records`)} deleted successfully`)}})},[Bt,a,n,r,qt,Jt,jt]),an=(0,G.useCallback)((e,t)=>{let n=Me?t[Me]:void 0;se(t),ne(n==null?null:[n]),le(e)},[Me,se,ne,le]),sn=(0,G.useCallback)(e=>{if(ce===null||!St)return;let t=ce+e,n=St[t];if(n){an(t,n);return}let r=Ie+e;r<0||(Le(r),de({end:e===1?`first`:`last`,fromPage:Ie}))},[ce,St,an,Ie,Le]);(0,G.useEffect)(function(){if(!ue)return;if(!re){de(null);return}let e=ue.end===`first`?0:(St?.length??0)-1,t=e>=0?St?.[e]:void 0;if(t){de(null),an(e,t);return}if(St||xt){if(de(null),Le(ue.fromPage),xt){U.error(`Couldn't load the next page of records`);return}if(ue.end===`first`){Ve(ue.fromPage),U.info(`This is the last record`);return}U.info(`This is the first record`)}},[ue,St,xt,re,an,Le,Ve]);let cn=e=>{an(e.index,e.original),ie(!0)},ln=(e,t)=>{Pe({attribute:e,descending:!t})},un=Kb(qt),dn=(0,G.useCallback)(()=>{rL(`ShowAddTableRecords`,{databaseName:n,tableName:r})},[n,r]),fn=(0,G.useCallback)(()=>{rL(`ShowImportData`,{databaseName:n,tableName:r})},[n,r]),pn=(0,G.useCallback)(()=>{rL(`ShowImportData`,{databaseName:n,tableName:r,method:x?`file`:`url`})},[n,r,x]),mn=(0,G.useCallback)(()=>{rL(`ShowImportData`,{databaseName:n,tableName:r,method:`sample`})},[n,r]),[hn,gn]=FC(`ColumnDisplayed/${n}/${r}`,{}),_n=(0,G.useMemo)(()=>({...Object.fromEntries(GF(te).map(e=>[e,!1])),...hn}),[te,hn]),vn=ce===null?void 0:{position:fe?void 0:Ie*Re+ce+1,total:kt?kb(Ie,Re,kt):Qe,isTotalEstimated:!kt&&et,hasPrevious:!fe&&(ce>0||Ie>0),hasNext:!fe&&!!St&&(ce+1<St.length||At),onPrevious:()=>sn(-1),onNext:()=>sn(1)},[yn,bn]=FC(`ColumnSizing/${n}/${r}`,{});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`shrink-0 flex flex-col md:flex-row md:flex-wrap items-center justify-between gap-3 pt-15 pb-4 px-4`,children:[(0,K.jsxs)(`div`,{className:`flex space-x-2`,children:[d&&Ne&&(0,K.jsxs)(H,{variant:`positiveOutline`,onClick:dn,accessKey:`n`,children:[(0,K.jsx)(Uo,{}),(0,K.jsxs)(`span`,{children:[`Add `,(0,K.jsx)(`u`,{children:`N`}),`ew Record(s)`]})]}),h&&jt.length>0&&(0,K.jsxs)(H,{variant:`destructiveOutline`,onClick:rn,disabled:Vt,children:[(0,K.jsx)(Is,{className:`text-destructive`}),(0,K.jsxs)(`span`,{children:[`Delete Selected (`,jt.length,`)`]})]})]}),(0,K.jsxs)(`div`,{className:`flex space-x-2`,children:[me&&Se&&(0,K.jsxs)(H,{type:`button`,variant:`ghost`,onClick:R,accessKey:`f`,children:[(0,K.jsx)(Sa,{className:`inline-block `}),(0,K.jsxs)(`span`,{children:[`Clear `,(0,K.jsx)(`u`,{children:`F`}),`ilters`]})]}),me&&ye.formState.isDirty&&(0,K.jsxs)(H,{variant:`default`,onClick:De,children:[(0,K.jsx)(ba,{className:`inline-block `}),`Apply Filters`]}),me&&!Se&&(0,K.jsxs)(H,{variant:`ghost`,onClick:ge,accessKey:`f`,children:[(0,K.jsx)(Sa,{className:`inline-block `}),(0,K.jsxs)(`span`,{children:[`Hide `,(0,K.jsx)(`u`,{children:`F`}),`ilters`]})]}),me&&(0,K.jsxs)(H,{variant:`ghost`,onClick:ve,"aria-expanded":_e,"aria-controls":`filter-syntax-help`,children:[(0,K.jsx)(Pi,{className:`inline-block `}),`Filter Syntax`]}),!me&&Ne&&(0,K.jsxs)(H,{variant:`ghost`,onClick:he,accessKey:`f`,children:[(0,K.jsx)(wa,{className:`inline-block `}),(0,K.jsxs)(`span`,{children:[`Show `,(0,K.jsx)(`u`,{children:`F`}),`ilters`]})]}),(0,K.jsx)(H,{variant:`defaultOutline`,onClick:un,disabled:bt,children:(0,K.jsx)(Go,{"aria-label":`Refresh table`,role:`img`})}),(0,K.jsx)(ZV,{columns:Ot,columnVisibility:_n,setColumnVisibility:gn}),(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsx)(H,{variant:`ghost`,size:`icon`,children:(0,K.jsx)(ua,{"aria-label":`Table options`})})}),(0,K.jsxs)(vc,{side:`bottom`,align:`end`,children:[f&&Ne&&(0,K.jsxs)(yc,{onClick:fn,children:[(0,K.jsx)(Ji,{}),`Import Data`]}),(0,K.jsxs)(yc,{onClick:Qt,disabled:Zt||!Ne,children:[(0,K.jsx)(Ki,{}),`Export CSV`]}),(0,K.jsx)(wc,{}),(0,K.jsxs)(yc,{className:`focus:bg-primary/70 focus:text-white`,onClick:l,children:[c?(0,K.jsx)(Ei,{className:`text-green`}):(0,K.jsx)(Ii,{}),`Only If Cached`,(0,K.jsx)(V,{to:`https://docs.harperdb.io/docs/developers/applications/caching#cache-control-header`,target:`_blank`,rel:`noopener noreferrer`,onClick:KL,children:(0,K.jsx)(fa,{})})]}),g&&u&&!!s&&(0,K.jsxs)(yc,{className:`focus:bg-yellow/70 focus:text-white`,onClick:Yt,disabled:Gt,children:[(0,K.jsx)(ci,{className:`text-yellow `}),`Cleanup Orphan Blobs`]}),g&&(0,K.jsx)(wc,{}),pe&&(0,K.jsxs)(yc,{className:`focus:bg-red/70 focus:text-white`,onClick:()=>rL(`ShowDeleteTable`,{databaseName:n,tableName:r}),children:[(0,K.jsx)(Is,{className:`inline-block `}),`Drop Table`]}),g&&(0,K.jsxs)(yc,{className:`focus:bg-red/70 focus:text-white`,onClick:()=>rL(`ShowDeleteDatabase`,{databaseName:n}),children:[(0,K.jsx)(Is,{}),`Drop Database`]})]})]})]})]}),me&&_e&&(0,K.jsx)(XV,{id:`filter-syntax-help`}),(0,K.jsx)(rH,{primaryKey:Me,data:Ne?St:dH,emptyState:(0,K.jsx)(UV,{tableName:r,hasPrimaryKey:Ne,isFiltered:tt,isPastFirstPage:Ie>0,recordCount:Qe,canImportFile:x,canImportUrl:S,canSeedSample:C,canSeedRandom:ee,canAddRecords:d,onImport:pn,onSeed:mn,onAddRecords:dn,onClearFilters:R}),isFetching:bt,filtersToggled:me,columns:Ot,columnVisibility:_n,columnSizing:yn,setColumnSizing:bn,onRowClick:cn,onColumnClick:ln,rowSelection:lt,totalPages:$e,totalRecords:Qe,uncountedPage:kt,isEstimatedCount:et,estimatedRange:Ue,isExactCountFetching:qe,isExactCountError:Je,onRequestExactCount:Xe,pageIndex:Ie,pageSize:Re,resultSetKey:rt,tableIdentity:nt,columnFiltersForm:ye,applyFilters:De,setPageIndex:Le,setPageSize:ze}),(0,K.jsx)(vV,{canEditRecords:m,canDeleteRecords:h,canReplaceRecords:A,replaceBlockedReason:k,setIsModalOpen:ie,isModalOpen:re,primaryKey:Me,missingPrimaryKey:Ft,recordUnavailable:Lt,syntheticAttributes:P,recordNavigation:vn,data:fe?void 0:Ft||Lt?ae?[ae]:void 0:Mt?.data,onSaveChanges:en,onReplaceRecord:tn,onDeleteRecord:nn,isUpdateTableRecordsPending:zt||Ut,isDeleteTableRecordsPending:Vt})]})}function mH(e,t){if(!e)return null;if(!(t.databaseName&&e[t.databaseName])){let n=Object.keys(e).sort()[0];return n&&n!==t.databaseName?{databaseName:n,tableName:void 0}:null}return t.tableName&&!e[t.databaseName][t.tableName]?{databaseName:t.databaseName,tableName:void 0}:null}var hH=10;function gH(e,t){return Math.max(e,Math.floor(t/2))}function _H(e,t,{minWidth:n,defaultWidth:r}){return Math.round(Math.min(Math.max(Number.isFinite(e)?e:r,n),gH(n,t)))}function vH({storageKey:e,defaultWidth:t,minWidth:n,cssVariable:r}){let[i,a]=Zc(e,t),o=(0,G.useRef)(i);(0,G.useLayoutEffect)(()=>{o.current=i},[i]);let s=(0,G.useMemo)(()=>({minWidth:n,defaultWidth:t}),[n,t]),c=(0,G.useCallback)(e=>_H(e,window.innerWidth,s),[s]),[l,u]=(0,G.useState)(()=>c(i)),d=(0,G.useRef)(l),f=(0,G.useCallback)(e=>{d.current=e,u(e)},[]),[p,m]=(0,G.useState)(!1),h=(0,G.useRef)(null),g=(0,G.useRef)(new Set),_=(0,G.useCallback)(e=>{let t=`${e}px`;for(let e of g.current)e.style.setProperty(r,t)},[r]),v=(0,G.useCallback)(e=>{if(e)return g.current.add(e),e.style.setProperty(r,`${h.current?.liveWidth??d.current}px`),()=>{g.current.delete(e)}},[r]);(0,G.useLayoutEffect)(()=>_(l),[_,l]),(0,G.useEffect)(()=>{let e=()=>{let e=h.current;e?(e.liveWidth=c(e.dragWidth??o.current),_(e.liveWidth)):f(c(o.current))};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[c,_,f]);let y=(0,G.useCallback)(e=>{if(e.button!==0||h.current)return;e.preventDefault();let t=e.currentTarget;h.current={pointerId:e.pointerId,target:t,startX:e.clientX,startWidth:d.current,dragWidth:null,liveWidth:d.current};try{t.setPointerCapture?.(e.pointerId)}catch{}m(!0)},[]);(0,G.useEffect)(()=>{if(!p)return;let e=e=>{let t=h.current;if(!t)return;h.current=null,t.target.hasPointerCapture?.(t.pointerId)&&t.target.releasePointerCapture(t.pointerId);let n=e&&t.dragWidth!==null&&t.dragWidth!==t.startWidth?t.dragWidth:null,r=c(n??o.current);_(r),f(r),n!==null&&a(n),m(!1)},t=e=>{let t=h.current;t?.pointerId===e.pointerId&&(t.dragWidth=c(t.startWidth+(e.clientX-t.startX)),t.liveWidth=t.dragWidth,_(t.liveWidth))},n=t=>{h.current?.pointerId===t.pointerId&&e(!0)},r=t=>{h.current?.pointerId===t.pointerId&&e(!1)},i=()=>e(!1),s=document.body.style.userSelect;return document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,t),window.addEventListener(`pointerup`,n),window.addEventListener(`pointercancel`,r),window.addEventListener(`lostpointercapture`,r),window.addEventListener(`blur`,i),()=>{document.body.style.userSelect=s,window.removeEventListener(`pointermove`,t),window.removeEventListener(`pointerup`,n),window.removeEventListener(`pointercancel`,r),window.removeEventListener(`lostpointercapture`,r),window.removeEventListener(`blur`,i)}},[p,c,_,f,a]);let b=(0,G.useCallback)(e=>{let t=e.key===`ArrowLeft`?-10:e.key===`ArrowRight`?hH:0;if(!t)return;e.preventDefault();let n=c(d.current+t);n!==d.current&&(f(n),a(n))},[c,f,a]);return{width:l,minWidth:n,maxWidth:gH(n,window.innerWidth),isResizing:p,sidebarRef:v,startResizing:y,handleKeyDown:b}}var yH={storageKey:_r.DatabasesSidebarWidth,defaultWidth:320,minWidth:200,cssVariable:`--db-sidebar-width`};function bH(){return vH(yH)}function xH(){let e=z({strict:!1}),t=q(),{data:n,isLoading:r}=L(Ij({...t,skipRecordCount:!0,includeComputed:!0})),{width:i,minWidth:a,maxWidth:o,isResizing:s,sidebarRef:c,startResizing:l,handleKeyDown:u}=bH(),d=mH(n,e);return d?(0,K.jsx)(qe,{to:jP({...e,...d}),replace:!0}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`main`,{className:`flex flex-col gap-4 md:gap-0 md:flex-row md:items-start`,children:[(0,K.jsxs)(`section`,{ref:c,className:`relative text-foreground w-full md:w-[var(--db-sidebar-width)] md:shrink-0 md:border-r-2 border-border flex flex-col min-h-0 md:sticky md:top-32 md:h-[calc(100vh-(--spacing(32)))] md:max-h-[calc(100vh-(--spacing(32)))] overflow-y-clip`,children:[(0,K.jsx)(dV,{instanceDatabaseMap:n}),(0,K.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,"aria-valuenow":i,"aria-valuemin":a,"aria-valuemax":o,onPointerDown:l,onKeyDown:u,className:`group hidden md:block absolute top-0 bottom-0 left-full w-2 z-40 cursor-col-resize touch-none outline-none`,children:(0,K.jsx)(`div`,{className:F(`absolute inset-y-0 left-0 w-1 -translate-x-1/2 transition-colors`,`group-hover:bg-violet-400/60 dark:group-hover:bg-violet-500/60 group-focus-visible:bg-violet-500/80`,s&&`bg-violet-400/60 dark:bg-violet-500/60`)})})]}),(0,K.jsx)(`section`,{className:`text-foreground w-full md:flex-1 md:min-w-0 flex flex-col min-h-0 h-[calc(100vh-(--spacing(32)))]`,children:e.databaseName&&e.tableName?(0,K.jsx)(pH,{instanceDatabaseMap:n,instanceDatabaseMapLoading:r,databaseName:e.databaseName,tableName:e.tableName}):e.databaseName?(0,K.jsx)(`div`,{className:`min-h-0 grow overflow-y-auto`,children:(0,K.jsx)(dz,{instanceDatabaseMap:n,databaseName:e.databaseName})}):null})]}),n&&(0,K.jsx)(GL,{instanceDatabaseMap:n})]})}function SH(e){return R({getParentRoute:()=>e,path:`/databases/{-$databaseName}/{-$tableName}`,head:()=>({meta:[{title:`Databases — Harper Fabric`}]}),component:xH})}var CH={className:`text-primary font-semibold bg-primary/10 rounded-md dark:text-white dark:bg-white/10`};function wH(){let e=Cg(),t=z({strict:!1}),{version:n}=Ce({strict:!1}),r=XT(n)&&e,i=vr(`4.7.0-beta.7`,n),a=q(),{data:o}=L(QT(a,r)),s=o?.restartRequired??!1,c=(0,G.useMemo)(()=>[e&&{to:t.clusterId&&!t.instanceId?qg(t,`apps`):qg(t),activeOptions:{exact:!0},name:`Applications`,shortName:`Apps`,icon:(0,K.jsx)(Fo,{className:`inline-block`})},{to:qg(t,`databases`),icon:(0,K.jsx)(ia,{className:`inline-block`}),name:`Databases`},e&&i&&{to:qg(t,`apis`),name:`APIs`,icon:(0,K.jsx)(ss,{className:`inline-block`})},e&&{to:qg(t,`operations`),name:`Operations`,icon:(0,K.jsx)(bs,{className:`inline-block`})},e&&r&&{to:qg(t,`status`),icon:(0,K.jsx)(Ea,{className:`inline-block`}),name:`Status`},e&&{to:qg(t,`logs`),icon:(0,K.jsx)(jo,{className:`inline-block`}),name:`Logs`},e&&{to:qg(t,`config`),icon:(0,K.jsx)(ls,{className:`inline-block`}),name:`Config`}].filter(fr),[e,t,i,r]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(TH,{links:c,restartRequired:s}),(0,K.jsx)(EH,{links:c,restartRequired:s})]})}function TH({links:e,restartRequired:t}){return(0,K.jsxs)(`div`,{className:`hidden md:[@media(hover:hover)]:flex xl:flex items-center justify-between h-full text-sm text-foreground`,children:[(0,K.jsx)(Dd,{restartRequired:t}),(0,K.jsx)(`div`,{className:`flex space-x-2`,children:e.map(({shortName:e,...t})=>{let n=(0,K.jsxs)(V,{"aria-label":t.name,className:`p-2 text-center text-muted-foreground hover:text-foreground`,activeProps:CH,...t,children:[t.icon,(0,K.jsx)(`span`,{className:`hidden xl:inline-block ml-1`,children:t.name}),e&&(0,K.jsx)(`span`,{className:`visible xl:hidden ml-1`,children:e})]},t.to);return e?n:(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:n}),(0,K.jsx)(Xl,{side:`bottom`,className:`xl:hidden`,children:t.name})]},t.to)})})]})}function EH({links:e,restartRequired:t}){return(0,K.jsx)(K.Fragment,{children:(0,K.jsxs)(`div`,{className:`flex md:[@media(hover:hover)]:hidden xl:hidden items-center justify-between h-full px-2 text-foreground`,children:[(0,K.jsx)(Dd,{restartRequired:t}),(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsx)(H,{variant:`ghost`,className:`p-0`,children:(0,K.jsx)(Co,{className:`h-8 w-8`})})}),(0,K.jsxs)(vc,{children:[(0,K.jsx)(Cc,{children:`Instance Menu`}),(0,K.jsx)(wc,{}),e.map(e=>(0,K.jsx)(yc,{asChild:!0,children:(0,K.jsxs)(V,{to:e.to,activeProps:CH,className:`flex items-center gap-2`,children:[e.icon,e.name]})},e.to))]})]})]})})}(0,G.lazy)(()=>pe(()=>import(`./FloatingChat-BWfKK_RX.js`).then(e=>({default:e.FloatingChat})),__vite__mapDeps([37,1,2,3,12,26,25])));function DH(){let{instanceId:e,clusterId:t}=z({strict:!1});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`nav`,{className:`studio-subnav fixed top-20 w-full z-39 h-12 md:px-12 bg-violet-50 border-b border-violet-100 dark:bg-grey-700 dark:border-none`,children:(0,K.jsx)(wH,{})}),(0,K.jsxs)(`div`,{className:`mt-32 min-h-[calc(100vh-(--spacing(32)))]`,children:[(0,K.jsx)(m_,{entityId:m,clusterId:t,noun:`instance`,className:`px-4 pt-4 md:px-12`}),(0,K.jsx)(st,{})]}),!1]})}function OH(e){switch(e){case`local`:return R({getParentRoute:()=>Uu,id:`_instanceLayout`,component:DH,loader:kP});case`cluster`:return R({getParentRoute:()=>WC,id:`_instanceLayout`,component:DH,beforeLoad:kH,loader:kP});case`instance`:return R({getParentRoute:()=>WC,path:`instance/$instanceId`,component:DH,beforeLoad:kH,loader:kP})}}async function kH({context:e,params:t}){let n=t.instanceId||t.clusterId,r=!1;if(u.checkForFabricConnect(n)&&!u.hasResolvedFabricConnect(n)&&(r=!0,await AH(n,e.cluster,t.instanceId)))return;u.startSignInCheck(n);let i=u.getConnectionById(n);if(i.isLoading||i.user)return;let a=e.authentication[m];if(!a||a.isLoading)return;let{update:o}=t.instanceId?xg(a.user,t.organizationId,t.clusterId):hg(a.user,t.organizationId,t.clusterId);if(!r&&o&&await AH(n,e.cluster,t.instanceId))return;let s=`/${t.organizationId}/${t.clusterId}/`+(t.instanceId?`instance/${t.instanceId}`:``)+`/sign-in`;throw Ne({to:s,search:Mu()})}async function AH(e,t,n){try{return await u.establishFabricConnectAuth({id:e,operationsUrl:jH(t,n)}),!0}catch(e){return console.debug(`Fabric Connect not established`,e),!1}}function jH(e,t){if(t){let n=e?.instances?.find(e=>e.id===t);return n?p(n):void 0}return c(e)??void 0}function MH(e){switch(e){case`warn`:return`warning`;case`notify`:return`success`;case`info`:case`debug`:case`trace`:case void 0:case`stdout`:return`secondary`;case`stderr`:case`error`:return`destructive`;default:return e}}var NH=[`secondary`,`default`,`warning`,`outline`,`success`,`destructive`],PH=0,FH=new Map,IH=e=>{if(FH.has(e))return FH.get(e);PH++;let t=NH[PH%NH.length];return FH.set(e,t),t};function LH(e){switch(e){case`error`:case`stderr`:return`border-l-destructive`;case`warn`:return`border-l-yellow-500`;case`notify`:return`border-l-green-500`;default:return`border-l-transparent`}}function RH({columns:e,data:t,onRowClick:n,containerRef:r}){let i=tt({features:Lb,data:t,columns:e});return(0,K.jsxs)(bb,{className:`text-xs`,containerRef:r,containerClassName:`rounded-md bg-card dark:bg-black-dark logsTable max-h-[calc(100vh-(--spacing(48)))] overflow-y-auto md:max-h-[calc(100vh-(--spacing(40)))]`,children:[(0,K.jsx)(xb,{children:i.getHeaderGroups().map(e=>(0,K.jsx)(Cb,{className:`border-b border-border`,children:e.headers.map(e=>(0,K.jsx)(wb,{className:`p-4 max-w-96 sticky top-0 z-10 border-b border-border bg-card dark:bg-black-dark`,children:e.isPlaceholder?null:ot(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,K.jsx)(Sb,{className:`bg-background dark:bg-black`,children:i.getRowModel().rows?.length?i.getRowModel().rows.map(e=>(0,K.jsx)(Cb,{"data-state":e.getIsSelected()&&`selected`,className:F(`hover:bg-muted/20 data-[state=selected]:bg-muted max-w-full border-l-2`,LH(e.original.level),n&&`cursor-pointer`),onClick:()=>n?.(e),children:e.getVisibleCells().map(e=>(0,K.jsx)(Eb,{className:`p-2`,children:ot(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,K.jsx)(Cb,{children:(0,K.jsx)(Eb,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})}var zH=524288,BH=class{totalChars=0;spent=!1;get isSpent(){return this.spent}admit(e){return this.spent?{admitted:!1,justExhausted:!1,oversize:!1}:e>524288?{admitted:!1,justExhausted:!1,oversize:!0}:this.totalChars+e>8388608?(this.spent=!0,{admitted:!1,justExhausted:!0,oversize:!1}):(this.totalChars+=e,{admitted:!0,justExhausted:!1,oversize:!1})}};function VH(e){try{JSON.parse(e)}catch{return!1}return!0}function HH(e){return!e||e.length>524288?`plaintext`:VH(e)?`json`:`plaintext`}function UH({label:e,children:t}){return(0,K.jsxs)(`div`,{className:`flex items-start gap-3 py-1.5 border-b border-border/50 last:border-0`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground w-20 shrink-0 pt-0.5`,children:e}),(0,K.jsx)(`span`,{className:`text-xs`,children:t})]})}function WH({setIsModalOpen:e,isModalOpen:t,data:n}){let r=n?IH(n.node):`default`,i=Tx();return(0,K.jsx)(_m,{onOpenChange:e,open:t,children:(0,K.jsxs)(wm,{"aria-describedby":void 0,resizable:!0,children:[(0,K.jsx)(Tm,{children:(0,K.jsx)(Dm,{children:`Log Entry`})}),n?(0,K.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 text-popover-foreground`,children:[(0,K.jsxs)(`div`,{className:`rounded-md border border-border/50 bg-muted/20 px-3 py-1`,children:[(0,K.jsx)(UH,{label:`Level`,children:(0,K.jsx)(ol,{variant:MH(n.level),children:_d(n.level)})}),(0,K.jsx)(UH,{label:`Timestamp`,children:(0,K.jsx)(`span`,{className:`tabular-nums`,children:new Date(n.timestamp).toLocaleString()})}),(0,K.jsx)(UH,{label:`Thread`,children:(0,K.jsx)(`span`,{className:`tabular-nums font-mono`,children:n.thread})}),n.node&&(0,K.jsx)(UH,{label:`Node`,children:(0,K.jsx)(ol,{variant:r,children:n.node})}),n.tags&&n.tags.length>0&&(0,K.jsx)(UH,{label:`Tags`,children:(0,K.jsx)(`span`,{className:`font-mono`,children:n.tags})})]}),(0,K.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`Message`}),(0,K.jsx)(`div`,{className:`rounded-md overflow-hidden border border-border/50 flex-1 min-h-0`,children:(0,K.jsx)(Dx,{className:`w-full h-full`,language:HH(n.message),theme:i,value:n.message,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12,padding:{top:12,bottom:12},automaticLayout:!0}})})]})]}):(0,K.jsx)(Lc,{})]})})}var GH=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d{1,3})?)?$/;function KH(e){let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}`}function qH(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),23,59,59,999)}var JH=KH(new Date(0));function YH(e=new Date){return KH(qH(e))}function XH(e,t){if(!e)return;let n=Date.parse(e);if(!GH.test(e)||Number.isNaN(n))return`Enter a valid date and time with a 4-digit year`;if(n<0)return`Date cannot be before 1970 (UTC)`;if(n>qH(t??new Date).getTime())return`Date cannot be after today`}var ZH=x().or(w()).or(k()).optional().superRefine((e,t)=>{let n=XH(e);n&&t.addIssue({code:`custom`,message:n})}),QH=b({limit:x().or(w()).or(k()).optional(),level:j([`notify`,`error`,`warn`,`info`,`debug`,`trace`,`undefined`]).or(w()).or(k()).optional(),from:ZH,until:ZH,log_name:j([`hdb.log`,`system.log`]).or(w()).or(k()).optional(),filter:x().or(w()).or(k()).optional()});function $H(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),window.setTimeout(()=>URL.revokeObjectURL(n),1e4)}function eU(e){return e.replace(/[^a-z0-9-]+/gi,`-`).replace(/(^-|-$)/g,``).toLowerCase()}function tU(e){return new Date(e).toISOString().replace(/[:.]/g,`-`)}function nU(e){let t=Array.isArray(e.tags)?e.tags:[],n=[e.thread??``,e.level??``,...e.node?[e.node]:[],...t];return`${e.timestamp} ${n.map(e=>`[${e}]`).join(` `)}: ${e.message??``}`}function rU(e,t){return t===`json`?JSON.stringify(e,null,` `):e.map(e=>`${nU(e)}\n`).join(``)}function iU(e,t,n=Date.now()){return`${eU(e)}-${tU(n)}.${t}`}function aU(e,t,n){let r=t===`json`?`application/json`:`text/plain;charset=utf-8`;$H(new Blob([rU(e,t)],{type:r}),iU(n,t))}function oU({logs:e,logName:t,iconOnly:n,className:r}){return(0,K.jsxs)(gc,{children:[(0,K.jsx)(_c,{asChild:!0,children:(0,K.jsxs)(H,{variant:`defaultOutline`,size:n?`icon`:`default`,disabled:e.length===0,"aria-label":`Download logs`,className:F(`shrink-0`,r),children:[(0,K.jsx)(oa,{}),!n&&`Download`]})}),(0,K.jsxs)(vc,{align:`end`,children:[(0,K.jsxs)(Cc,{className:`text-xs font-normal text-muted-foreground`,children:[`Saves the `,oe(e.length,`entry`,`entries`),` shown`]}),(0,K.jsx)(yc,{onSelect:()=>aU(e,`txt`,t),children:`Text (.txt)`}),(0,K.jsx)(yc,{onSelect:()=>aU(e,`json`,t),children:`JSON (.json)`})]})]})}var sU=`dark:bg-grey-600 dark:border-grey-500`,cU=[{name:`from`,label:`Start date`},{name:`until`,label:`End date`}];function lU({form:e,resetFilters:t,submitFilters:n,showLogName:r,showFilter:i,isOpen:a,onOpenChange:o}){let[s,c]=(0,G.useState)(YH),l=()=>c(YH());return(0,K.jsxs)(Er,{className:F(a?`block`:`hidden`,`mt-3 md:mt-0 md:block`),children:[(0,K.jsx)(Dr,{className:`hidden md:block`,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>o(!a),"aria-expanded":a,"aria-controls":`logs-filters-content`,className:`flex w-full items-center justify-between md:pointer-events-none`,children:(0,K.jsxs)(Or,{className:`flex items-center gap-2 text-base`,children:[(0,K.jsx)(gs,{className:`size-4 text-muted-foreground`}),`Filters`]})})}),(0,K.jsx)(Ar,{id:`logs-filters-content`,children:(0,K.jsx)(Od,{...e,children:(0,K.jsxs)(`form`,{id:`instance-edit-log-filters-form`,name:`instance-edit-log-filters-form`,onSubmit:e.handleSubmit(n),className:`flex-col space-y-4`,children:[i&&(0,K.jsx)(Y,{control:e.control,name:`filter`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(J,{children:(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(rs,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,K.jsx)($,{type:`search`,placeholder:`Search logs…`,className:F(`pl-9`,sU),value:e.value??``,onChange:e.onChange})]})}),(0,K.jsx)(Q,{})]})}),r&&(0,K.jsx)(Y,{control:e.control,name:`log_name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Log file`}),(0,K.jsxs)(hy,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,K.jsx)(vy,{className:F(`w-full bg-white`,sU),children:(0,K.jsx)(_y,{placeholder:`Select log file`})}),(0,K.jsx)(yy,{children:(0,K.jsxs)(gy,{children:[(0,K.jsx)(xy,{value:`hdb.log`,children:`Application (hdb.log)`}),(0,K.jsx)(xy,{value:`system.log`,children:`System (system.log)`})]})})]}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsx)(Y,{control:e.control,name:`limit`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Limit`}),(0,K.jsxs)(hy,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,K.jsx)(vy,{className:F(`w-full bg-white`,sU),children:(0,K.jsx)(_y,{placeholder:`Limit`})}),(0,K.jsx)(yy,{children:(0,K.jsxs)(gy,{children:[(0,K.jsx)(xy,{value:`1000`,children:`1000`}),(0,K.jsx)(xy,{value:`500`,children:`500`}),(0,K.jsx)(xy,{value:`250`,children:`250`}),(0,K.jsx)(xy,{value:`100`,children:`100`}),(0,K.jsx)(xy,{value:`10`,children:`10`})]})})]}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:e.control,name:`level`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Level`}),(0,K.jsxs)(hy,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,K.jsx)(vy,{className:F(`w-full bg-white`,sU),children:(0,K.jsx)(_y,{placeholder:`Level`})}),(0,K.jsx)(yy,{children:(0,K.jsxs)(gy,{children:[(0,K.jsx)(xy,{value:`undefined`,children:`All`}),(0,K.jsx)(xy,{value:`notify`,children:`Notify`}),(0,K.jsx)(xy,{value:`error`,children:`Error`}),(0,K.jsx)(xy,{value:`warn`,children:`Warn`}),(0,K.jsx)(xy,{value:`info`,children:`Info`}),(0,K.jsx)(xy,{value:`debug`,children:`Debug`}),(0,K.jsx)(xy,{value:`trace`,children:`Trace`})]})})]}),(0,K.jsx)(Q,{})]})})]}),cU.map(({name:t,label:n})=>(0,K.jsx)(Y,{control:e.control,name:t,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:n}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`datetime-local`,step:1,min:JH,max:s,onFocus:l,className:sU,value:e.value??``,onChange:e.onChange})}),(0,K.jsx)(Q,{})]})},t)),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,K.jsx)(H,{type:`submit`,variant:`positiveOutline`,className:`grow`,children:`Apply Filters`}),(0,K.jsx)(H,{type:`reset`,variant:`destructiveOutline`,onClick:t,children:`Clear`})]})]})})})]})}var uU=1e4;function dU(e){if(!e)return;let t=parseInt(e,10);if(!(!Number.isFinite(t)||t<=0))return Math.min(t,uU)}function fU(e,t){return{operation:`read_log`,start:0,replicated:t,limit:dU(e.limit),level:e.level===`undefined`?void 0:e.level,from:e.from?new Date(e.from).toISOString():void 0,until:e.until?new Date(e.until).toISOString():void 0,log_name:e.log_name??void 0,filter:e.filter?e.filter:void 0,order:`desc`}}async function pU({instanceClient:e,logFilters:t,replicated:n}){let{data:r}=await e.post(`/`,fU(t,n));return r}function mU(e){let t=e.logFilters;return B({queryKey:[`read_log`,e.entityId,t.limit,t.level,t.from,t.until,t.log_name,t.filter,e.replicated],queryFn:()=>pU(e),retry:!1,refetchInterval:e.isAutoRefreshEnabled?Gc(5e3):!1})}async function hU({connection:e,logFilters:t,replicated:n,signal:r,onEntry:i}){let{url:a,headers:o,credentials:s}=OD(e),c;try{c=await fetch(a,{method:`POST`,headers:o,credentials:s,body:JSON.stringify(fU(t,n)),signal:r})}catch(e){throw r?.aborted?e:new TD(`Failed to open the read_log SSE stream.`,{cause:e})}let l=c.headers.get(`content-type`)??``;if(!c.ok||!l.includes(`text/event-stream`)||!c.body)throw await c.body?.cancel().catch(()=>{}),new TD(`read_log did not return an event stream (status ${c.status}, content-type "${l}").`);for await(let e of SD(c.body,r)){if(e.event===`error`){let t=wD(e);if(!t||typeof t!=`object`)throw new DD(typeof t==`string`&&t?t:`The log stream failed.`);let n=t;throw new DD(n.message??`The log stream failed.`,{code:n.code})}if(e.event===`done`||e.event===`end`)return;for(let t of gU(wD(e)))i(t)}}function gU(e){return Array.isArray(e)?e.filter(_U):_U(e)?[e]:[]}function _U(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.timestamp==`string`&&(typeof t.level==`string`||typeof t.message==`string`)}function vU(e){return[e.timestamp,e.node??``,e.thread??``,e.level,e.message].join(`|`)}function yU(e,t,n){let r=new Set,i=[];for(let n of[...t,...e]){let e=vU(n);r.has(e)||(r.add(e),i.push(n))}return i.sort((e,t)=>e.timestamp<t.timestamp?1:e.timestamp>t.timestamp?-1:0),n>0&&i.length>n?i.slice(0,n):i}var bU={entries:[],fellBack:!1};function xU(e,t){switch(t.kind){case`reset`:return bU;case`retry`:return e.fellBack?{...e,fellBack:!1}:e;case`append`:{if(t.entries.length===0)return e;let n=e.entries.concat(t.entries);return n.length<=t.cap?{...e,entries:n}:(n.sort((e,t)=>e.timestamp<t.timestamp?1:e.timestamp>t.timestamp?-1:0),{...e,entries:n.slice(0,t.cap)})}case`fellBack`:return{...e,fellBack:!0}}}function SU(){let e=q();return u.isDirectConnection(e.entityId)}var CU=1e3,wU=2e3,TU=250;function EU(e){return dU(e)??CU}function DU(e,t){return JSON.stringify([e.limit,e.level,e.from,e.until,e.log_name,e.filter,t])}function OU({params:e,logFilters:t,replicated:n,live:r}){let i=SU(),[a,o]=(0,G.useReducer)(xU,bU),s=r&&i&&!a.fellBack,c=DU(t,n),l=EU(t.limit),u=Math.max(wU,l),d=L(mU({...e,logFilters:t,replicated:n,isAutoRefreshEnabled:r&&!s}));(0,G.useEffect)(()=>{o({kind:`reset`})},[e.entityId,c]),(0,G.useEffect)(()=>{r&&o({kind:`retry`})},[r]);let f=(0,G.useRef)({logFilters:t,replicated:n});f.current={logFilters:t,replicated:n},(0,G.useEffect)(()=>{if(!s)return;let t=new AbortController,n=[],r=()=>{if(n.length>0&&!t.signal.aborted){let e=n;n=[],o({kind:`append`,entries:e,cap:u})}},i=setInterval(r,TU);return hU({connection:{id:e.entityId},logFilters:f.current.logFilters,replicated:f.current.replicated,signal:t.signal,onEntry:e=>n.push(e)}).catch(()=>{}).finally(()=>{clearInterval(i),!t.signal.aborted&&(r(),o({kind:`fellBack`}))}),()=>{clearInterval(i),t.abort()}},[s,e.entityId,c]);let p=(0,G.useMemo)(()=>{let e=d.data??[];return a.entries.length===0?e:yU(e,a.entries,l)},[d.data,a.entries,l]),m=s?`streaming`:r?`polling`:`idle`;return{logs:p,isLoading:d.isLoading,isFetching:d.isFetching,refetch:()=>d.refetch(),transport:m}}var kU={log_name:`hdb.log`,limit:`100`,level:`undefined`,from:``,until:``,filter:``},AU={error:(0,K.jsx)(wi,{className:`size-3`}),stderr:(0,K.jsx)(wi,{className:`size-3`}),warn:(0,K.jsx)(Rs,{className:`size-3`}),notify:(0,K.jsx)(ni,{className:`size-3`}),info:(0,K.jsx)(Ba,{className:`size-3`}),debug:(0,K.jsx)(ui,{className:`size-3`}),trace:(0,K.jsx)(Ir,{className:`size-3`}),stdout:(0,K.jsx)(Ms,{className:`size-3`})},jU=[{accessorKey:`level`,header:`Level`,cell:({row:e})=>{let{level:t}=e.original;return(0,K.jsxs)(ol,{variant:MH(t),children:[AU[t],_d(t)]})}},{accessorKey:`timestamp`,header:`Timestamp`,cell:({row:e})=>{let{timestamp:t}=e.original,n=new Date(t),r=n.getFullYear()===new Date().getFullYear()?n.toLocaleDateString(void 0,{month:`numeric`,day:`2-digit`}):n.toLocaleDateString();return(0,K.jsxs)(`span`,{className:`tabular-nums whitespace-nowrap text-muted-foreground`,children:[r,` `,n.toLocaleTimeString()]})}},{accessorKey:`message`,header:`Message`,cell:({row:e})=>{let{message:t}=e.original;return(0,K.jsx)(`span`,{className:`block max-w-xl truncate font-mono text-xs`,children:t})}},{accessorKey:`thread`,header:`Thread`,cell:({row:e})=>(0,K.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:e.original.thread})},{accessorKey:`node`,header:`Node`,cell:({row:e})=>{let{node:t}=e.original,n=IH(t);return(0,K.jsx)(K.Fragment,{children:t?(0,K.jsxs)(Jl,{children:[(0,K.jsx)(Yl,{asChild:!0,children:(0,K.jsxs)(ol,{variant:n,children:[t.split(`.`)[0],`...`]})}),(0,K.jsx)(Xl,{className:`bg-popover text-popover-foreground border border-border`,arrowClassName:`bg-popover fill-popover`,children:t})]}):null})}},{accessorKey:`tags`,header:`Tags`,cell:({row:e})=>{let{tags:t}=e.original;return t&&t.length>0?(0,K.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null}}],MU=(e,t)=>!e&&!t||!e||!t||new Date(e)<=new Date(t);function NU(){return(0,K.jsxs)(`div`,{className:`rounded-md bg-card dark:bg-black-dark overflow-hidden`,children:[(0,K.jsx)(`div`,{className:`flex gap-4 p-4 border-b border-border`,children:[`w-14`,`w-32`,`w-14`,`w-24`,`w-16`,`flex-1`].map((e,t)=>(0,K.jsx)(aC,{className:`h-4 ${e}`},t))}),Array.from({length:12}).map((e,t)=>(0,K.jsxs)(`div`,{className:`flex gap-4 p-3 border-b border-border/40 border-l-2 border-l-transparent`,children:[(0,K.jsx)(aC,{className:`h-5 w-14`}),(0,K.jsx)(aC,{className:`h-5 w-32`}),(0,K.jsx)(aC,{className:`h-5 w-10`}),(0,K.jsx)(aC,{className:`h-5 w-20`}),(0,K.jsx)(aC,{className:`h-5 w-12`}),(0,K.jsx)(aC,{className:`h-5 flex-1 max-w-xs`})]},t))]})}function PU(){let[e,t]=(0,G.useState)(kU),[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(),[o,s]=(0,G.useState)(!1),[c,l]=Zc(_r.LogsOrderReversed,!1),[u,d]=(0,G.useState)(!1),f=q(),{data:p}=L(HE(f)),m=p?.version,h=!!m&&vr(`4.7.16`,m),{logs:g,isLoading:_,isFetching:v,refetch:y,transport:b}=OU({params:f,logFilters:e,replicated:f.entityType===`cluster`,live:o}),x=(0,G.useMemo)(()=>c?[...g??[]].reverse():g??[],[g,c]),S=e.log_name??`hdb.log`,C=(0,G.useRef)(null);(0,G.useEffect)(()=>{let e=C.current;!_&&e&&e.scrollTo({top:c?e.scrollHeight:0})},[c,_]),(0,G.useEffect)(()=>{let e=C.current;o&&!_&&e&&e.scrollTo({top:c?e.scrollHeight:0})},[x,o,c,_]);let w=on({resolver:mt(QH),defaultValues:kU,mode:`onChange`}),T=e=>{a(e.original),r(!0)},E=async e=>{if(!MU(e.from,e.until)){w.setError(`from`,{type:`onChange`,message:`Start date must be before end date`}),w.setError(`until`,{type:`onChange`,message:`End date must be after start date`});return}t(e)},D=async()=>{w.reset(),t(kU)},O=Kb(y);return(0,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 pt-2 text-foreground md:grid-cols-12 md:gap-4`,children:[(0,K.jsxs)(`section`,{className:`col-span-1 md:col-span-4 lg:col-span-3 px-2 pb-0 md:self-start md:sticky md:top-34 md:max-h-[calc(100vh-(--spacing(34)))] md:overflow-y-auto md:pb-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 md:hidden`,children:[(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:()=>d(e=>!e),"aria-label":`Toggle filters`,"aria-expanded":u,className:`flex-1`,children:[(0,K.jsx)(gs,{}),`Filters`]}),(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:O,disabled:v||_||o,"aria-label":`Refresh logs`,className:`flex-1`,children:[(0,K.jsx)(Go,{className:v?`animate-spin`:``}),`Refresh`]}),(0,K.jsxs)(H,{variant:c?`default`:`defaultOutline`,onClick:()=>l(e=>!e),"aria-label":`Reverse log order`,"aria-pressed":c,className:`flex-1`,children:[(0,K.jsx)(Kr,{}),`Reverse`]}),(0,K.jsx)(oU,{logs:x,logName:S,iconOnly:!0})]}),(0,K.jsx)(lU,{form:w,resetFilters:D,submitFilters:E,showLogName:!1,showFilter:h,isOpen:u,onOpenChange:d}),(0,K.jsxs)(`div`,{className:`mt-3 space-y-3 hidden md:block`,children:[(0,K.jsxs)(H,{variant:`defaultOutline`,onClick:O,disabled:v||_||o,className:`w-full`,children:[(0,K.jsx)(Go,{}),`Refresh`]}),(0,K.jsx)(oU,{logs:x,logName:S,className:`w-full`}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,K.jsx)(Kx,{id:`logs-live-switch`,"aria-label":`Toggle live logs`,checked:o,onCheckedChange:s}),(0,K.jsxs)(`label`,{htmlFor:`logs-live-switch`,className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(Go,{className:`size-4 ${o?`animate-spin [animation-duration:3s]`:``}`}),o?b===`streaming`?`Live (streaming)`:`Live (polling every 5s)`:`Live`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,K.jsx)(Kx,{id:`logs-reverse-order-switch`,"aria-label":`Reverse log order`,checked:c,onCheckedChange:l}),(0,K.jsxs)(`label`,{htmlFor:`logs-reverse-order-switch`,className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(Kr,{className:`size-4`}),c?`Oldest first`:`Newest first`]})]})]})]})]}),(0,K.jsx)(`section`,{className:`col-span-1 md:col-span-8 lg:col-span-9`,children:_?(0,K.jsx)(NU,{}):(0,K.jsx)(RH,{columns:jU,data:x,onRowClick:T,containerRef:C})}),(0,K.jsx)(WH,{isModalOpen:n,setIsModalOpen:r,data:i})]})}function FU(e){return R({getParentRoute:()=>e,path:`logs`,head:()=>({meta:[{title:`Logs — Harper Fabric`}]}),component:PU})}function IU(e){return R({getParentRoute:()=>e,path:`operations`,head:()=>({meta:[{title:`Operations — Harper Fabric`}]}),component:je(async()=>pe(()=>import(`./operations-Dy69AlTr.js`),__vite__mapDeps([38,1,7,23,2,3,4,8,6,9,32,34,29])),`OperationsIndex`)})}var LU=6e4,RU=60*LU,zU=24*RU,BU=[{id:`1h`,label:`Last 1 hour`,durationMs:RU,bucketMs:1*LU,expandedBucketMs:1*LU},{id:`6h`,label:`Last 6 hours`,durationMs:6*RU,bucketMs:2*LU,expandedBucketMs:1*LU},{id:`24h`,label:`Last 24 hours`,durationMs:zU,bucketMs:10*LU,expandedBucketMs:5*LU},{id:`7d`,label:`Last 7 days`,durationMs:7*zU,bucketMs:RU,expandedBucketMs:15*LU},{id:`30d`,label:`Last 30 days`,durationMs:30*zU,bucketMs:4*RU,expandedBucketMs:RU}];function VU(e){let t=BU.find(t=>t.id===e);if(!t)throw Error(`Unknown preset: ${e}`);return t}function HU(e){let t=(e,t)=>`${e} ${t}${e===1?``:`s`}`;return e>=RU&&e%RU===0?t(e/RU,`hour`):e>=LU&&e%LU===0?t(e/LU,`minute`):e>=1e3&&e%1e3==0?t(e/1e3,`second`):`${e} ms`}function UU(e,t){let n=e=>t?.expanded?e.expandedBucketMs:e.bucketMs,r=n(BU[0]);if(!Number.isFinite(e)||e<=0)return r;for(let t of BU)if(e<=t.durationMs*1.01)return n(t);let i=BU[BU.length-1];return Math.max(r,Math.ceil(e/(i.durationMs/n(i))))}var WU=[{label:`Off`,value:0},{label:`30s`,value:3e4},{label:`60s`,value:6e4},{label:`5m`,value:3e5}],GU=6e4,KU=[`health`,`traffic`,`requests`,`database`,`replication`,`storage`,`overview`,`jobs`],qU={tab:`health`,range:`1h`,refresh:GU,jobsRefresh:0};function JU(e,t){let n=e===``?NaN:Number(e);return WU.find(e=>e.value===n)?.value??t}function YU(e){return{tab:KU.find(t=>t===e.tab)??qU.tab,range:BU.find(t=>t.id===e.range)?.id??qU.range,refresh:JU(e.refresh,qU.refresh),jobsRefresh:JU(e.jobsRefresh,qU.jobsRefresh)}}function XU(e){return R({getParentRoute:()=>e,path:`status`,validateSearch:YU,search:{middlewares:[ut(qU)]},head:()=>({meta:[{title:`Status — Harper Fabric`}]}),component:je(async()=>pe(()=>import(`./status-D05eZ5pQ.js`),__vite__mapDeps([39,1,7,6,2,3,4,8,9,12,32,40,41,42,43,44,45,46,47])),`StatusIndex`)})}function ZU(e){let t=OH(e),n=[FU(t),...kE(t,e),OE(t),IU(t),XU(t),AP(t),SH(t)];return t.addChildren(n)}R({getParentRoute:()=>Uu,path:`notifications`,head:()=>({meta:[{title:`Notifications — Harper Fabric`}]}),component:je(async()=>pe(()=>import(`./notifications-DsGk-TnW.js`),__vite__mapDeps([48,1,6,7,2,3,8,9])),`NotificationsCenter`)}),R({getParentRoute:()=>Uu,path:`profile`,head:()=>({meta:[{title:`Profile — Harper Fabric`}]}),component:je(async()=>pe(()=>import(`./profile-DzQvoYBF.js`),__vite__mapDeps([49,1,22,7,6,23,4,2,3,24,25,8,9])),`ProfileIndex`)});var QU=Hu.addChildren([...om,Uu.addChildren([ZU(`local`)])]);function $U({routeTree:e=QU,authentication:t}){let[n]=(0,G.useState)(()=>Ae({routeTree:e,history:be(),defaultNotFoundComponent:sc,defaultErrorComponent:oc,defaultPreload:!cc()&&`intent`,trailingSlash:`never`,defaultPreloadStaleTime:0,scrollRestoration:!0,context:{queryClient:hc,authentication:t||{}}}));return n}function eW(){let e=br(),t=$U({authentication:e}),n=(0,G.useRef)(e);return(0,G.useEffect)(()=>{n.current!==e&&(n.current=e,t.invalidate())},[t,e]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ct,{router:t,context:{authentication:e}}),(0,K.jsx)(Xe,{router:t,position:`bottom-right`})]})}var tW=({...e})=>(0,K.jsx)(Gt,{className:`toaster group`,toastOptions:{classNames:{toast:`group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg`,description:`group-[.toast]:text-muted-foreground`,actionButton:`group-[.toast]:bg-primary group-[.toast]:text-primary-foreground font-medium`,cancelButton:`group-[.toast]:bg-muted group-[.toast]:text-muted-foreground font-medium`}},...e}),nW=!1;function rW(){(0,G.useEffect)(()=>{nW||=!0},[])}function iW(){return Qu(),Bu(),rW(),(0,K.jsxs)(el,{children:[(0,K.jsxs)(it,{client:hc,children:[(0,K.jsx)(eW,{}),(0,K.jsx)(rt,{buttonPosition:`bottom-right`})]}),(0,K.jsx)(tW,{richColors:!0})]})}var aW=1e4,oW=100,sW=new Map;function cW(e){return typeof e==`string`||typeof e==`number`?String(e):e==null?null:typeof e}function lW(e){if(e instanceof Error)return null;try{return JSON.stringify(e)??null}catch{return Object.keys(e).join(`,`)}}function uW(e,t){if(typeof e!=`object`||!e)return JSON.stringify([typeof e,String(e),t??null]);let{name:n,message:r,stack:i,config:a}=e;return JSON.stringify([typeof e,cW(n),cW(r),cW(i),t??null,cW(a?.method),cW(a?.baseURL),cW(a?.url),lW(e)])}function dW(e,t){for(let[e,n]of sW){if(t-n<aW)break;sW.delete(e)}sW.delete(e),sW.set(e,t),sW.size>oW&&sW.delete(sW.keys().next().value)}function fW(e,t){let n;try{n=uW(e,t.componentStack)}catch{n=void 0}let r=performance.now();if(n!==void 0){let e=sW.get(n);if(e!==void 0&&r-e<aW)return}try{me(e,t)}catch{return}n!==void 0&&dW(n,r)}var pW={onUncaughtError:(e,t)=>{fW(e,t),console.warn(`Uncaught error:`,e,t)},onCaughtError:(e,t)=>{fW(e,t),console.warn(`Caught error:`,e,t)},onRecoverableError:(e,t)=>{fW(e,t),console.warn(`Recoverable error:`,e,t)}};function mW(e,t=()=>!1,n=()=>!0){return r=>(r?.response?.status===401&&!t(r.config?.url??``)&&n(r.config)&&e(),Promise.reject(r))}var hW=[`/Login/`,`/ForgotPassword/`,`/ResetPassword/`,`/VerifyEmail/`,`/ResendVerificationEmail/`],gW=`authUserAtSend`;function _W(){let e=u.getConnectionById(m).user;return e&&`id`in e?e.id:null}var vW=!1;function yW(){vW||(vW=!0,P.interceptors.request.use(e=>(e[gW]=_W(),e)),P.interceptors.response.use(e=>e,mW(pu,e=>hW.some(t=>e.startsWith(t)),e=>e?.[gW]===_W())))}var bW=!1;function xW(){bW||=(u.onAppSignedOutElsewhere(mu),!0)}var SW=`Studio:StaleDeployReloadedAt`,CW=6e4,wW=`__harperStaleDeployReloadState__`;function TW(){if(typeof window<`u`)return window[wW]}function EW(){let e=TW();if(e){try{let e=Number(sessionStorage.getItem(SW)??0);if(Date.now()-e<CW)return;sessionStorage.setItem(SW,String(Date.now()))}catch{return}e.reload()}}function DW(e=()=>window.location.reload()){if(typeof window>`u`)return;let t=window,n=t[wW];if(n){n.reload=e;return}t[wW]={reload:e},window.addEventListener(`vite:preloadError`,()=>EW())}var OW=ve();ge(),DW(),yW(),xW(),a(),u.installExplorerCrossTabCleanup(),(0,OW.createRoot)(document.getElementById(`root`),pW).render((0,K.jsx)(G.StrictMode,{children:(0,K.jsx)(iW,{})}));export{iF as $,Ar as $i,Sh as $n,Gc as $r,cO as $t,nL as A,Uo as Ai,pb as An,lu as Ar,Zk as At,oI as B,ia as Bi,A_ as Bn,kl as Br,UO as Bt,KR as C,ds as Ci,rx as Cn,J as Cr,hj as Ct,iL as D,Yo as Di,wb as Dn,gu as Dr,fj as Dt,CL as E,$o as Ei,Eb as En,Au as Er,dj as Et,II as F,no as Fi,xy as Fn,Xl as Fr,XO as Ft,kF as G,Si as Gi,Kg as Gn,wl as Gr,FO as Gt,jF as H,Xi as Hi,u_ as Hn,xl as Hr,LO as Ht,DI as I,Qa as Ii,vy as In,Yl as Ir,WO as It,CF as J,Wr as Ji,wg as Jn,hl as Jr,jO as Jt,EF as K,fi as Ki,Gg as Kn,pl as Kr,kO as Kt,EI as L,Ha as Li,_y as Ln,zl as Lr,qO as Lt,$I as M,zo as Mi,ky as Mn,q as Mr,qk as Mt,tL as N,Fo as Ni,hy as Nn,$l as Nr,Jk as Nt,rL as O,qo as Oi,xb as On,cu as Or,lA as Ot,QI as P,oo as Pi,yy as Pn,Jl as Pr,ak as Pt,rF as Q,Er as Qi,eh as Qn,Rc as Qr,dO as Qt,xI as R,Ba as Ri,cy as Rn,Rl as Rr,JO as Rt,sz as S,Es as Si,lx as Sn,Y as Sr,mj as St,UL as T,rs as Ti,Sb as Tn,Gu as Tr,pj as Tt,OF as U,Oi as Ui,l_ as Un,El as Ur,EO as Ut,qF as V,ea as Vi,c_ as Vn,Sl as Vr,IO as Vt,AF as W,wi as Wi,qg as Wn,Ol as Wr,PO as Wt,qP as X,Br as Xi,Zh as Xn,Zc as Xr,MO as Xt,nF as Y,Hr as Yi,Cg as Yn,ol as Yr,AO as Yt,JP as Z,Nr as Zi,Lh as Zn,Yc as Zr,gO as Zt,SV as _,Hs as _i,Dx as _n,$ as _r,JM as _t,HU as a,wr as aa,yc as ai,KE as an,Fm as ar,eF as at,pz as b,Ms as bi,ux as bn,Md as br,aM as bt,pU as c,Ec as ci,HE as cn,_m as cr,IP as ct,$H as d,_c as di,NT as dn,Em as dr,iP as dt,kr as ea,Kc as ei,WD as en,Zm as er,aF as et,BH as f,fc as fi,eT as fn,Tm as fr,fN as ft,OV as g,Ks as gi,Kx as gn,_f as gr,VM as gt,RV as h,oc as hi,aC as hn,bf as hr,BM as ht,BU as i,Tr as ia,vc as ii,iD as in,Nm as ir,XP as it,eL as j,Vo as ji,zy as jn,Ql as jr,Kk as jt,aL as k,Go as ki,Cb as kn,su as kr,cA as kt,tU as l,Oc as li,NE as ln,wm as lr,BP as lt,vH as m,hc as mi,FC as mn,Sp as mr,LM as mt,YU as n,Or as na,gc as ni,ED as nn,Am as nr,YP as nt,VU as o,wc as oi,GE as on,Im as or,$P as ot,zH as p,mc as pi,Iw as pn,Dm as pr,sN as pt,wF as q,Xr as qi,hg as qn,ml as qr,NO as qt,WU as r,Sr as ra,bc as ri,xD as rn,Mm as rr,tF as rt,UU as s,Tc as si,qE as sn,jm as sr,VP as st,EW as t,Dr as ta,Lc as ti,ID as tn,Bm as tr,ZP as tt,eU as u,Dc as ui,QT as un,Om as ur,zP as ut,qB as v,Rs as vi,Tx as vn,Q as vr,HM as vt,KL as w,ss as wi,bb as wn,Od as wr,uj as wt,fz as x,Os as xi,cx as xn,X as xr,Fj as xt,uB as y,Is as yi,sx as yn,Z as yr,qM as yt,wI as z,oa as zi,z_ as zn,Al as zr,QO as zt};