@harperfast/harper 5.2.10 → 5.2.13

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 (44) hide show
  1. package/dist/resources/Table.d.ts +2 -2
  2. package/dist/resources/Table.js +182 -61
  3. package/dist/resources/Table.js.map +1 -1
  4. package/dist/resources/databases.d.ts +1 -0
  5. package/dist/resources/databases.js +73 -40
  6. package/dist/resources/databases.js.map +1 -1
  7. package/dist/utility/errors/hdbError.d.ts +8 -0
  8. package/dist/utility/errors/hdbError.js +29 -0
  9. package/dist/utility/errors/hdbError.js.map +1 -1
  10. package/npm-shrinkwrap.json +38 -38
  11. package/package.json +2 -2
  12. package/resources/Table.ts +177 -62
  13. package/resources/databases.ts +74 -42
  14. package/studio/web/assets/{Chat-Br06zdMA.js → Chat-4RrB5134.js} +1 -1
  15. package/studio/web/assets/{FloatingChat-BWImX5fA.js → FloatingChat-omlNMDcJ.js} +3 -3
  16. package/studio/web/assets/{apiToken-DN0nmDsq.js → apiToken-Bke3wvfZ.js} +1 -1
  17. package/studio/web/assets/{applications-kSxVoyeU.js → applications-DvFDYJgK.js} +1 -1
  18. package/studio/web/assets/{cssMode-C1JeufH5.js → cssMode-C1vRa7zh.js} +1 -1
  19. package/studio/web/assets/{editor-qoo9CrGO.js → editor-3XRWEDWX.js} +1 -1
  20. package/studio/web/assets/{html-Dt4IIy04.js → html-CTY5tdMr.js} +1 -1
  21. package/studio/web/assets/{htmlMode-DXgKKr4C.js → htmlMode-CG1vSD9t.js} +1 -1
  22. package/studio/web/assets/{index-6onkYFOG.js → index-Dfpeofdu.js} +5 -5
  23. package/studio/web/assets/{index.lazy-BrCFnpNJ.js → index.lazy-B1VOIv-t.js} +1 -1
  24. package/studio/web/assets/{javascript-DNCQGUBc.js → javascript-CJeJzGnI.js} +1 -1
  25. package/studio/web/assets/{jsonMode-CR6HWruP.js → jsonMode-CYPBwM82.js} +1 -1
  26. package/studio/web/assets/{languageServices-BM4fI4rS.js → languageServices-IKH4GUHl.js} +1 -1
  27. package/studio/web/assets/{lspLanguageFeatures-DSa1ttcD.js → lspLanguageFeatures-BC8_gxKG.js} +1 -1
  28. package/studio/web/assets/{notifications-BHXLnh6x.js → notifications-BfKBpYcq.js} +1 -1
  29. package/studio/web/assets/{notifications-CUmtIA6z.js → notifications-DFbArTfC.js} +1 -1
  30. package/studio/web/assets/{profile-8BeFSF3j.js → profile-Q4-T6c-S.js} +1 -1
  31. package/studio/web/assets/{regions-C8qR0HhD.js → regions-CtkV0xje.js} +1 -1
  32. package/studio/web/assets/{register-B4n5i0SD.js → register-1ZZuMsiA.js} +2 -2
  33. package/studio/web/assets/{setComponentFile-g0_B0lgX.js → setComponentFile-ZWLcWv5X.js} +1 -1
  34. package/studio/web/assets/{setup-B0CTj_Q5.js → setup-DWprJyJy.js} +2 -2
  35. package/studio/web/assets/{status-C6Yib7-K.js → status--aNm8isn.js} +1 -1
  36. package/studio/web/assets/{toggleHighContrast-Dgta7bVi.js → toggleHighContrast-Cq_lt3XD.js} +1 -1
  37. package/studio/web/assets/{tsMode-CH_jHvU-.js → tsMode-pjgytARx.js} +1 -1
  38. package/studio/web/assets/{typescript-Co9LCXd5.js → typescript-Cdg0mqUh.js} +1 -1
  39. package/studio/web/assets/{useEntityRestURL-wKC8NsC_.js → useEntityRestURL-RZhaY8Rn.js} +1 -1
  40. package/studio/web/assets/{workers-CWeLxCXA.js → workers-BgoXIqQe.js} +1 -1
  41. package/studio/web/assets/{xml-BadC-0Rk.js → xml-BwSeDMiP.js} +1 -1
  42. package/studio/web/assets/{yaml-BiUfxPbC.js → yaml-DotCUG5l.js} +1 -1
  43. package/studio/web/index.html +1 -1
  44. package/utility/errors/hdbError.ts +26 -0
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/notifications-CUmtIA6z.js","assets/rolldown-runtime-hePW80VL.js","assets/button-BIsUKRZq.js","assets/vendor-core-c2JRRJpV.js","assets/vendor-datadog-CLUcJXOo.js","assets/vendor-react-CJV_K1u4.js","assets/vendor-ui-BUjK0h8a.js","assets/vendor-tanstack-DxzraizX.js","assets/dialog-Cn2uWgD4.js","assets/createLucideIcon-CzW9508A.js","assets/x-DIzaLEdK.js","assets/setLocalStorage-D_kflv4U.js","assets/safeParse-DeaoCCWH.js","assets/useLocalStorage-BqMR3D8_.js","assets/alertDialog-CQyAJJhl.js","assets/regions-C8qR0HhD.js","assets/chevron-up-DtKGqDn3.js","assets/apiToken-DN0nmDsq.js","assets/setup-B0CTj_Q5.js","assets/dist-DP8UjMB_.js","assets/register-B4n5i0SD.js","assets/register-jjEx9u7D.css","assets/editor-qoo9CrGO.js","assets/toggleHighContrast-Dgta7bVi.js","assets/toggleHighContrast--ixms01u.css","assets/index.lazy-BrCFnpNJ.js","assets/authStore-C3Nfubqr.js","assets/setSessionStorage-B0bf71m4.js","assets/useEntityRestURL-wKC8NsC_.js","assets/tabs-BrHu7gJi.js","assets/applications-kSxVoyeU.js","assets/download-B5T5r7ss.js","assets/setComponentFile-g0_B0lgX.js","assets/languageServices-BM4fI4rS.js","assets/applications-DNZhsH95.css","assets/FloatingChat-BWImX5fA.js","assets/status-C6Yib7-K.js","assets/errorText-NpBmvk9I.js","assets/linear-Cnt8506Q.js","assets/step-vX8bovaY.js","assets/defaultLocale-BFoDCU3G.js","assets/init-ZlXS9mIS.js","assets/ordinal-CPleeUAT.js","assets/time-Cclkb7kQ.js","assets/band-DZ4Jagyz.js","assets/getAnalytics-GHK8ORfM.js","assets/notifications-BHXLnh6x.js","assets/profile-8BeFSF3j.js"])))=>i.map(i=>d[i]);
2
- import{r as e,t}from"./rolldown-runtime-hePW80VL.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,y as g}from"./authStore-C3Nfubqr.js";import{D as _,O as v,T as y,_ as b,f as x,g as S,h as C,i as w,o as T,r as E,s as D,t as O,u as k,v as A,w as j,y as ee}from"./vendor-core-c2JRRJpV.js";import{i as M,n as N,t as P}from"./button-BIsUKRZq.js";import{a as te,i as ne,t as re}from"./vendor-datadog-CLUcJXOo.js";import{r as ie,t as ae}from"./vendor-react-CJV_K1u4.js";import{A as oe,B as se,C as F,D as I,E as ce,F as le,G as ue,H as de,I as L,K as fe,L as R,M as pe,N as me,O as he,P as ge,R as _e,S as ve,T as ye,U as be,V as xe,_ as Se,a as Ce,b as we,c as Te,d as Ee,f as De,g as Oe,h as ke,i as Ae,k as z,l as je,m as Me,n as Ne,o as Pe,p as Fe,q as Ie,r as Le,s as Re,t as ze,u as Be,v as Ve,w as B,y as He,z as V}from"./vendor-tanstack-DxzraizX.js";import{t as Ue}from"./safeParse-DeaoCCWH.js";import{n as We,t as Ge}from"./setSessionStorage-B0bf71m4.js";import{$ as Ke,A as qe,At as Je,B as Ye,C as Xe,Ct as Ze,D as Qe,Dt as $e,E as et,Et as tt,F as nt,Ft as rt,H as it,I as at,It as H,L as ot,Lt as st,M as ct,Mt as lt,N as ut,Nt as dt,O as ft,Ot as pt,P as mt,Pt as ht,R as gt,S as _t,St as vt,T as yt,Tt as bt,U as xt,V as St,W as Ct,_t as wt,at as Tt,b as Et,bt as Dt,ct as Ot,dt as kt,et as At,ft as jt,gt as Mt,ht as Nt,it as Pt,j as Ft,jt as It,k as Lt,kt as Rt,lt as zt,mt as Bt,nt as Vt,ot as Ht,pt as Ut,rt as Wt,st as Gt,tt as Kt,ut as qt,v as Jt,vt as Yt,w as Xt,wt as Zt,x as Qt,xt as $t,y as en,yt as tn,z as nn}from"./vendor-ui-BUjK0h8a.js";import{t as U}from"./createLucideIcon-CzW9508A.js";import{a as rn,c as an,i as on,l as sn,n as cn,o as ln,r as un,s as dn,t as fn}from"./dialog-Cn2uWgD4.js";import{n as pn,r as mn,t as hn}from"./chevron-up-DtKGqDn3.js";import{t as gn}from"./x-DIzaLEdK.js";import{t as _n}from"./errorText-NpBmvk9I.js";import{n as vn,r as yn,t as bn}from"./setLocalStorage-D_kflv4U.js";import{t as xn}from"./useLocalStorage-BqMR3D8_.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 W=e(te(),1);function Sn(){let[e,t]=(0,W.useState)(()=>({...u.getAllConnections()}));return(0,W.useEffect)(()=>u.listenToAllEntities((e,n)=>{t(t=>({...t,[n]:e}))}),[]),e}function Cn(){let e=u.calculateIdFromEntity(m),[t,n]=(0,W.useState)(u.getConnectionById(m));return(0,W.useEffect)(()=>u.listenToEntity(e,n),[e]),t}function wn(){return Cn()}function Tn(e,t){return!e||!(`fabricRole`in e)?!1:e.staffPermissions?e.staffPermissions.includes(t):e.fabricRole===`fabric_admin`||e.fabricRole===`super_user`}function En(e){let{user:t}=wn();return Tn(t,e)}function Dn(e){let t=m,{clusterId:n,instanceId:r}=z({strict:!1}),[i,a]=(0,W.useState)(u.getConnectionById(t??r??n));return(0,W.useEffect)(()=>u.listenToEntity(t,a),[t]),i}var G=ie();function On({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`card`,className:N(`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 kn({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`card-header`,className:N(`flex flex-col gap-1.5 px-6`,e),...t})}function An({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`card-title`,className:N(`leading-none text-lg`,e),...t})}function jn({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`card-description`,className:N(`text-muted-foreground text-xs`,e),...t})}function Mn({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`card-content`,className:N(`px-6`,e),...t})}function Nn(e){return e!==null&&!!e.username}function Pn(e){if(e&&!Nn(e)){let t=Object.keys(e.roles);if(t.length===1)return`/${t[0]}`}return`/`}var Fn=U(`activity`,[[`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`}]]),In=U(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),Ln=U(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),Rn=U(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),zn=U(`arrow-up-down`,[[`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`}]]),Bn=U(`arrow-up-from-line`,[[`path`,{d:`m18 9-6-6-6 6`,key:`kcunyi`}],[`path`,{d:`M12 3v14`,key:`7cf3v8`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]),Vn=U(`bell`,[[`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`}]]),Hn=U(`book-open-text`,[[`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`}]]),Un=U(`brush-cleaning`,[[`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`}]]),Wn=U(`bug`,[[`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`}]]),Gn=U(`calendar-clock`,[[`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`}]]),Kn=U(`chart-column-increasing`,[[`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`}]]),qn=U(`chart-pie`,[[`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`}]]),Jn=U(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Yn=U(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Xn=U(`circle-alert`,[[`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`}]]),Zn=U(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),Qn=U(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]]),$n=U(`circle-dashed`,[[`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`}]]),er=U(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),tr=U(`clipboard-check`,[[`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`}]]),nr=U(`clipboard`,[[`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`}]]),rr=U(`cloud-alert`,[[`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`}]]),ir=U(`cloud-download`,[[`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`}]]),ar=U(`cloud-upload`,[[`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`}]]),or=U(`columns-3-cog`,[[`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`}]]),sr=U(`copy`,[[`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`}]]),cr=U(`credit-card`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}]]),lr=U(`database`,[[`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`}]]),ur=U(`ellipsis`,[[`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`}]]),dr=U(`external-link`,[[`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`}]]),fr=U(`eye-off`,[[`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`}]]),pr=U(`eye`,[[`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`}]]),mr=U(`file-up`,[[`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`}]]),hr=U(`funnel-plus`,[[`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`}]]),gr=U(`funnel`,[[`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`}]]),_r=U(`funnel-x`,[[`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`}]]),vr=U(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),yr=U(`git-graph`,[[`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`}]]),br=U(`globe`,[[`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`}]]),xr=U(`grip-vertical`,[[`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`}]]),Sr=U(`handshake`,[[`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`}]]),Cr=U(`house`,[[`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`}]]),wr=U(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),Tr=U(`key-round`,[[`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`}]]),Er=U(`key`,[[`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`}]]),Dr=U(`layout-dashboard`,[[`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`}]]),Or=U(`life-buoy`,[[`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`}]]),kr=U(`list-todo`,[[`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`}]]),Ar=U(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),jr=U(`lock`,[[`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`}]]),Mr=U(`log-in`,[[`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`}]]),Nr=U(`log-out`,[[`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`}]]),Pr=U(`mail-warning`,[[`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`}]]),Fr=U(`mail`,[[`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`}]]),Ir=U(`map-pin`,[[`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`}]]),Lr=U(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),Rr=U(`monitor`,[[`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`}]]),zr=U(`moon`,[[`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`}]]),Br=U(`notepad-text`,[[`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`}]]),Vr=U(`octagon-alert`,[[`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`}]]),Hr=U(`package`,[[`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`}]]),Ur=U(`pencil`,[[`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`}]]),Wr=U(`play`,[[`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`}]]),Gr=U(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Kr=U(`refresh-cw`,[[`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`}]]),qr=U(`rocket`,[[`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`}]]),Jr=U(`rotate-ccw`,[[`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`}]]),Yr=U(`rotate-cw`,[[`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`}]]),Xr=U(`save`,[[`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`}]]),Zr=U(`scale`,[[`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`}]]),Qr=U(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),$r=U(`server`,[[`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`}]]),ei=U(`settings`,[[`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`}]]),ti=U(`shield-check`,[[`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`}]]),ni=U(`shield-x`,[[`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`}]]);U(`shield`,[[`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`}]]);var ri=U(`sliders-horizontal`,[[`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`}]]),ii=U(`square-pen`,[[`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`}]]),ai=U(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),oi=U(`sun`,[[`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`}]]),si=U(`table-2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]),ci=U(`table`,[[`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`}]]),li=U(`tag`,[[`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`}]]),ui=U(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),di=U(`ticket`,[[`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`}]]),fi=U(`trash`,[[`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`}]]),pi=U(`triangle-alert`,[[`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`}]]),mi=U(`user-minus`,[[`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`}]]),hi=U(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),gi=U(`users`,[[`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`}]]),_i=U(`zap`,[[`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`}]]);function vi({className:e,error:t,title:n,showReturnToHome:r,children:i}){let{user:a,isLoading:o}=Cn();return Pn(a),(0,G.jsxs)(On,{className:N(`text-red p-5 border border-red rounded-md m-12 mt-36`,e),children:[(0,G.jsxs)(kn,{children:[(0,G.jsx)(An,{className:`text-2xl`,children:(0,G.jsx)(`h2`,{children:n??`Component Error`})}),(0,G.jsx)(jn,{children:t.message})]}),(0,G.jsxs)(Mn,{children:[i,r!==!1&&(a&&!o?(0,G.jsx)(B,{to:`/`,children:(0,G.jsxs)(P,{children:[` `,(0,G.jsx)(Ln,{}),` Return to Home`]})}):(0,G.jsx)(B,{to:`/sign-in`,children:(0,G.jsxs)(P,{children:[` `,(0,G.jsx)(Ln,{}),` Go to Sign In Page`]})}))]})]})}function yi(){let{user:e,isLoading:t}=Cn();return Pn(e),(0,G.jsx)(`div`,{className:`flex items-center justify-center h-screen px-3`,children:(0,G.jsxs)(On,{className:`text-red p-5 border border-red rounded-md w-full max-w-md`,children:[(0,G.jsx)(kn,{children:(0,G.jsx)(An,{className:`text-2xl`,children:(0,G.jsx)(`h2`,{children:`Sorry, Page Not Found`})})}),(0,G.jsx)(Mn,{children:e&&!t?(0,G.jsx)(B,{to:`/`,children:(0,G.jsxs)(P,{children:[` `,(0,G.jsx)(Ln,{}),` Return to Home`]})}):(0,G.jsx)(B,{to:`/sign-in`,children:(0,G.jsxs)(P,{children:[` `,(0,G.jsx)(Ln,{}),` Go Sign In Page`]})})})]})})}function bi(){return`ontouchstart`in window||navigator.maxTouchPoints>0}function xi(e){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=_n(e.detail);n=i?`${e.title}: ${i}`:e.title,r=!1}else n=_n(e.error)??_n(e.message)??n}else n=_n(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 Si(e){console.error(e);let{title:t,description:n}=xi(e),r=e,i=r?.code===`ECONNABORTED`||r?.code===`ETIMEDOUT`,a=r?.response?.status===403;H.error(t,{id:i?`request-timeout`:a?`request-forbidden`:void 0,description:n,action:{label:`Dismiss`,onClick:()=>H.dismiss()}})}var Ci=new xe({queryCache:new de({onError:Si}),mutationCache:new be({onError:(e,t,n,r)=>{r.meta?.skipGlobalErrorToast||Si(e)}})});function wi({...e}){return(0,G.jsx)(Rt,{"data-slot":`dropdown-menu`,...e})}function Ti({...e}){return(0,G.jsx)(ht,{"data-slot":`dropdown-menu-trigger`,...e})}function Ei({className:e,sideOffset:t=4,...n}){return(0,G.jsx)(pt,{children:(0,G.jsx)(Zt,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:N(`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 Di({className:e,inset:t,variant:n=`default`,...r}){return(0,G.jsx)(bt,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:N(`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 Oi({className:e,children:t,checked:n,...r}){return(0,G.jsxs)(Ze,{"data-slot":`dropdown-menu-checkbox-item`,className:N(`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,G.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,G.jsx)(tt,{children:(0,G.jsx)(mn,{className:`size-4`})})}),t]})}function ki({className:e,inset:t,...n}){return(0,G.jsx)($e,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:N(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function Ai({className:e,...t}){return(0,G.jsx)(Je,{"data-slot":`dropdown-menu-separator`,className:N(`bg-border -mx-1 my-1 h-px`,e),...t})}function ji({className:e,...t}){return(0,G.jsx)(`span`,{"data-slot":`dropdown-menu-shortcut`,className:N(`text-muted-foreground ml-auto text-xs tracking-widest`,e),...t})}function Mi({...e}){return(0,G.jsx)(It,{"data-slot":`dropdown-menu-sub`,...e})}function Ni({className:e,inset:t,children:n,...r}){return(0,G.jsxs)(dt,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:N(`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,G.jsx)(Yn,{className:`ml-auto size-4`})]})}function Pi({className:e,...t}){return(0,G.jsx)(lt,{"data-slot":`dropdown-menu-sub-content`,className:N(`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 Fi=`flex items-center gap-3 p-2 rounded-lg text-sm transition-colors`,Ii=`block p-2 rounded-lg text-sm transition-colors`,Li={className:`text-foreground hover:bg-accent dark:text-white dark:hover:bg-grey-700`},Ri={className:`font-medium text-primary bg-primary/10 dark:text-white dark:bg-white/10`};function zi({items:e,ariaLabel:t}){let{pathname:n}=Oe(),r=e=>e.exact?n===e.to:n.startsWith(e.to),i=e.find(r)??e[0],a=i.icon;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`nav`,{className:`hidden md:flex flex-col gap-1`,"aria-label":t,children:e.map(e=>{let t=e.icon;return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(B,{to:e.to,className:Fi,activeOptions:{exact:!!e.exact},activeProps:Ri,inactiveProps:Li,children:[(0,G.jsx)(t,{className:`size-4 shrink-0`}),e.label]}),e.children&&r(e)&&(0,G.jsx)(`div`,{className:`mt-1 ml-4 flex flex-col gap-1 border-l border-border pl-3`,children:e.children.map(e=>(0,G.jsx)(B,{to:e.to,className:Ii,activeOptions:{exact:!!e.exact},activeProps:Ri,inactiveProps:Li,children:e.label},e.to))})]},e.to)})}),(0,G.jsx)(`div`,{className:`md:hidden`,children:(0,G.jsxs)(wi,{children:[(0,G.jsx)(Ti,{asChild:!0,children:(0,G.jsxs)(P,{variant:`outline`,className:`w-full justify-between`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(a,{className:`size-4`}),i.label]}),(0,G.jsx)(pn,{className:`size-4`})]})}),(0,G.jsx)(Ei,{align:`start`,className:`w-(--radix-dropdown-menu-trigger-width)`,children:e.map(e=>{let t=e.icon;return[(0,G.jsx)(Di,{asChild:!0,children:(0,G.jsxs)(B,{to:e.to,className:`flex items-center gap-2`,children:[(0,G.jsx)(t,{className:`size-4`}),e.label]})},e.to),...e.children&&r(e)?e.children.map(e=>(0,G.jsx)(Di,{asChild:!0,children:(0,G.jsx)(B,{to:e.to,className:`flex items-center gap-2 pl-8`,children:e.label})},e.to)):[]]})})]})})]})}var Bi=[{to:`/admin/notifications`,label:`Notifications`,icon:Vn,permission:`systemStatus:write`},{to:`/admin/regions`,label:`Regions`,icon:br,permission:`region:read`},{to:`/admin/api-token`,label:`API Token`,icon:Tr,permission:`apiToken:create`,ssoAccountOnly:!0}];function Vi(e){let t=e!==null&&`fabricRole`in e&&e.fabricRole===`super_user`;return Bi.filter(n=>Tn(e,n.permission)&&!(n.ssoAccountOnly&&t))}function Hi(e){return Vi(e).length>0}function Ui(){let{isLoading:e,user:t}=wn(),{pathname:n}=Oe();if(e)return null;let r=Vi(t);if(!r.length)return(0,G.jsx)(ce,{to:`/`,replace:!0});let i=Bi.find(e=>n.startsWith(e.to));return i&&!r.includes(i)?(0,G.jsx)(ce,{to:r[0].to,replace:!0}):(0,G.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,G.jsxs)(`div`,{className:`md:grid gap-6 md:grid-cols-12`,children:[(0,G.jsx)(`aside`,{className:`md:col-span-3 lg:col-span-2 mb-4 md:mb-0`,children:(0,G.jsx)(zi,{items:r,ariaLabel:`Admin sections`})}),(0,G.jsx)(`section`,{className:`md:col-span-9 lg:col-span-10 min-w-0`,children:(0,G.jsx)(He,{})})]})})}function Wi({className:e,text:t,centered:n,...r}){return(0,G.jsxs)(`div`,{className:`text-foreground h-full w-full ${e||``} ${n?`flex flex-col items-center justify-center`:``}`,...r,children:[(0,G.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`100px`,height:`100px`,alt:`HDB Dog Logo Loading`,className:`inline-block`}),(0,G.jsx)(`p`,{className:`pt-4`,children:t||`Loading...`})]})}function Gi(){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 126.644 96`,width:24,height:24,children:(0,G.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 Ki(){let e=`studio`,t=`Harper Studio`;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`img`,{src:`/harper-${e}_black.png`,alt:t,className:`w-64 hidden md:inline-block dark:hidden`}),(0,G.jsx)(`img`,{src:`/harper-${e}_white.png`,alt:t,className:`w-64 hidden md:dark:inline-block`}),(0,G.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`50px`,height:`44px`,alt:`Harper`,className:`inline-block md:hidden`})]})}var qi=j(`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-destructive text-white [a&]:hover:bg-destructive/90 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 Ji({className:e,variant:t,asChild:n=!1,...r}){return(0,G.jsx)(n?st:`span`,{"data-slot":`badge`,className:N(qi({variant:t}),e),...r})}function Yi({className:e,children:t,...n}){return(0,G.jsxs)(tn,{"data-slot":`scroll-area`,className:N(`relative`,e),...n,children:[(0,G.jsx)(vt,{"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,G.jsx)(Xi,{}),(0,G.jsx)(Yt,{})]})}function Xi({className:e,orientation:t=`vertical`,...n}){return(0,G.jsx)(Dt,{"data-slot":`scroll-area-scrollbar`,orientation:t,className:N(`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,G.jsx)($t,{"data-slot":`scroll-area-thumb`,className:`bg-border relative flex-1 rounded-full`})})}var Zi=[`notification-acks`];function Qi(){let e=yn(vn.AckedNotificationIds,[]);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function $i(e){Ci.setQueryData(Zi,e);try{bn(vn.AckedNotificationIds,e)}catch(e){console.warn(`[notifications] could not persist acknowledgements`,e)}}function ea(){return R({queryKey:Zi,queryFn:Qi,staleTime:1/0,gcTime:1/0,initialData:Qi})}function ta(e){$i(Array.from(new Set([...Qi(),e])))}function na(e){$i(Qi().filter(t=>t!==e))}function ra(){let{data:e}=V(ea());return(0,W.useMemo)(()=>new Set(e??[]),[e])}var ia={critical:{severity:`critical`,label:`Critical`,Icon:Vr,badgeVariant:`destructive`,bannerClass:`bg-destructive/10 border-destructive/40 text-foreground`,iconClass:`text-destructive`},warning:{severity:`warning`,label:`Warning`,Icon:pi,badgeVariant:`warning`,bannerClass:`bg-yellow/10 border-yellow/40 text-foreground`,iconClass:`text-yellow`},info:{severity:`info`,label:`Info`,Icon:wr,badgeVariant:`secondary`,bannerClass:`bg-secondary/20 border-secondary/50 text-foreground`,iconClass:`text-secondary-foreground`}},aa=new Set([`critical`,`error`,`outage`,`incident`,`down`,`danger`]),oa=new Set([`warning`,`warn`,`maintenance`,`degraded`,`notice`]),sa=new Set([`info`,`information`,`informational`,`success`,`ok`]);function ca(e){let t=(e??``).trim().toLowerCase();return oa.has(t)?`warning`:sa.has(t)?`info`:(aa.has(t),`critical`)}function la(e){return ia[ca(e)]}var ua={critical:0,warning:1,info:2};function da(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 fa(e){let t=da(e);return t.kind===`valid`?t.ms:null}function pa(e){return new Date(e).toLocaleString()}function ma(e,t){let n=da(e.startAt),r=da(e.endAt);return n.kind===`invalid`||r.kind===`invalid`?{state:`expired`,label:`Schedule unavailable`}:n.kind===`valid`&&t<n.ms?{state:`upcoming`,label:`Starts ${pa(n.ms)}`}:r.kind===`valid`&&t>r.ms?{state:`expired`,label:`Ended ${pa(r.ms)}`}:r.kind===`valid`?{state:`active`,label:`Active until ${pa(r.ms)}`}:{state:`active`,label:`Active`}}var ha=new Set([`http`,`https`,`mailto`]);function ga(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?ha.has(n)?{kind:`external`,href:t}:null:{kind:`internal`,href:t.startsWith(`/`)?t:`/${t}`}}function _a({url:e,className:t,children:n,onNavigate:r}){let i=ga(e);return i?i.kind===`external`?(0,G.jsxs)(`a`,{href:i.href,target:`_blank`,rel:`noreferrer noopener`,className:t,children:[n??`Learn more`,(0,G.jsx)(dr,{className:`inline size-3 ml-1 align-[-1px]`})]}):(0,G.jsx)(B,{to:i.href,className:t,onClick:r,children:n??`View details`}):null}var va=[`system-status`];async function ya(){let{data:e}=await M.get(`/SystemStatus/`);return Array.isArray(e)?e:[]}function ba(){return R({queryKey:va,queryFn:ya,refetchInterval:6e4,staleTime:3e4})}var xa=3e4,Sa=new Set,Ca=Date.now(),wa=null;function Ta(e){return Sa.add(e),wa||=(Ca=Date.now(),setInterval(()=>{Ca=Date.now(),Sa.forEach(e=>e())},xa)),()=>{Sa.delete(e),Sa.size===0&&wa&&(clearInterval(wa),wa=null)}}function Ea(){return(0,W.useSyncExternalStore)(Ta,()=>Ca,()=>Ca)}function Da(){return V(ba())}function Oa(){let[e,t]=(0,W.useState)(()=>window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`);return(0,W.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 ka=(0,W.createContext)([`system`,()=>{}]);function Aa({children:e}){let[t,n]=xn(vn.Theme,`system`),r=Oa();return(0,W.useEffect)(()=>{let e=t===`dark`||t===`system`&&r===`dark`;document.documentElement.classList.toggle(`dark`,e)},[t,r]),(0,G.jsx)(ka.Provider,{value:[t,n],children:e})}function ja(){return(0,W.useContext)(ka)}var Ma=[{value:`light`,icon:(0,G.jsx)(oi,{className:`size-4`}),label:`Light`},{value:`system`,icon:(0,G.jsx)(Rr,{className:`size-4`}),label:`System`},{value:`dark`,icon:(0,G.jsx)(zr,{className:`size-4`}),label:`Dark`}];function Na(){let[e,t]=ja();return(0,G.jsx)(`div`,{className:`flex items-center bg-muted dark:bg-black rounded-xl p-0.5 gap-0.5`,children:Ma.map(({value:n,icon:r,label:i})=>(0,G.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 Pa({className:e,...t}){return(0,G.jsx)(`div`,{className:N(`absolute top-full left-0 isolate z-50 flex justify-center`),children:(0,G.jsx)(wt,{"data-slot":`navigation-menu-viewport`,className:N(`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 Fa({className:e,children:t,viewport:n=!0,...r}){return(0,G.jsxs)(Mt,{"data-slot":`navigation-menu`,"data-viewport":n,className:N(`group/navigation-menu relative flex max-w-max flex-1 items-center justify-center`,e),...r,children:[t,n&&(0,G.jsx)(Pa,{})]})}function Ia({className:e,...t}){return(0,G.jsx)(Ut,{"data-slot":`navigation-menu-item`,className:N(`relative`,e),...t})}function La({className:e,...t}){return(0,G.jsx)(Bt,{"data-slot":`navigation-menu-link`,className:N(`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 Ra({className:e,...t}){return(0,G.jsx)(Nt,{"data-slot":`navigation-menu-list`,className:N(`group flex flex-1 list-none items-center justify-center gap-1`,e),...t})}function za({delayDuration:e=0,...t}){return(0,G.jsx)(qt,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Ba({...e}){return(0,G.jsx)(za,{children:(0,G.jsx)(kt,{"data-slot":`tooltip`,...e})})}function Va({...e}){return(0,G.jsx)(jt,{"data-slot":`tooltip-trigger`,...e})}function Ha({className:e,sideOffset:t=0,arrowClassName:n,children:r,...i}){return(0,G.jsx)(zt,{children:(0,G.jsxs)(Ot,{"data-slot":`tooltip-content`,sideOffset:t,className:N(`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,G.jsx)(Gt,{className:N(`bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`,n)})]})})}function Ua(){let e=`v5.2.10`,t=e.startsWith(`v`)?`https://github.com/HarperFast/studio/releases/tag/${e}`:`https://github.com/HarperFast/studio/releases`;return(0,G.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,children:(0,G.jsxs)(`span`,{className:N(qi({variant:`default`}),`text-xs inline-block ml-2 align-text-top`),children:[e,` BETA`]})})}function Wa(e={}){let{instanceId:t,clusterId:n}=z({strict:!1});return o({id:m,...e})}function Ga(e={}){let{instanceId:t,clusterId:n}=z({strict:!1});return{instanceClient:o({id:m,...e}),entityType:`instance`}}function K(e={}){let{instanceId:t,clusterId:n}=z({strict:!1});return(0,W.useMemo)(()=>Ka({instanceId:t,clusterId:n,...e}),[e.instanceId??t,e.clusterId??n,e.operationsUrl,e.port,e.secure,e.disableFabricConnect,e.forceFabricConnect])}function Ka({instanceId:e,clusterId:t,...n}){let r=m;if(!r)throw Error(`id could not be automatically calculated in useInstanceClientIdParams`);return{instanceClient:o({id:r,...n}),entityId:r,entityType:`instance`}}function qa(){localStorage.clear()}function Ja(){sessionStorage.clear()}async function Ya(){u.setUserForEntity(m,null),Ci.getQueryCache().clear(),qa(),Ja(),await Ci.invalidateQueries({refetchType:`none`})}async function Xa(e){await u.signOutFromPotentiallyAuthenticatedInstances(),await d({...e,entityId:m})}function Za(){let e=Wa();return L({mutationFn:()=>Xa({instanceClient:e}),onSuccess:Ya})}function Qa(e){return!!e}var $a={className:`text-foreground dark:text-white font-semibold`};function eo(){let{mutate:e}=Za(),t=I(),{user:n}=Cn(),r=Hi(n),i=pe(),a=(0,W.useCallback)(()=>{e(void 0,{onSuccess:async()=>{H.success(`Success`,{description:`You have been signed out successfully.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),t({to:`/sign-in`}),i.invalidate()}})},[e,i,t]),o=(0,W.useMemo)(()=>[!1,!1,{to:`https://docs.harperdb.io/docs`,target:`_blank`,icon:(0,G.jsx)(Hn,{}),text:`Docs`,textBreakpoint:`md`},{to:`https://github.com/HarperFast/studio/issues`,target:`_blank`,icon:(0,G.jsx)(Wn,{}),text:`Report an Issue`,textBreakpoint:`lg`},{to:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,icon:(0,G.jsx)(Gi,{}),text:`Discord`,textBreakpoint:`lg`},{onClick:a,icon:(0,G.jsx)(Nr,{}),text:`Sign Out`,textBreakpoint:`md`}].filter(Qa),[a,r]);return n?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ao,{menuItems:o}),(0,G.jsx)(ro,{menuItems:o})]}):(0,G.jsx)(no,{})}function to(e){return e.items!==void 0}function no(){return(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`inline-block`,children:[(0,G.jsx)(B,{to:`/sign-in`,children:(0,G.jsx)(Ki,{})}),(0,G.jsx)(Ua,{})]}),(0,G.jsx)(Fa,{children:(0,G.jsxs)(Ra,{className:`text-muted-foreground dark:text-grey-400`,children:[(0,G.jsx)(Ia,{children:(0,G.jsx)(La,{asChild:!0,children:(0,G.jsxs)(B,{to:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noreferrer noopener`,className:`flex-row items-center`,children:[(0,G.jsx)(Hn,{}),` `,(0,G.jsx)(`span`,{className:`hidden md:inline-block`,children:`Docs`})]})})}),(0,G.jsx)(Ia,{children:(0,G.jsx)(Na,{})}),(0,G.jsx)(Ia,{children:(0,G.jsx)(La,{asChild:!0,children:(0,G.jsxs)(B,{to:`/sign-in`,className:`flex-row items-center`,activeProps:$a,children:[(0,G.jsx)(Mr,{}),` Sign In`]})})})]})})]})}function ro({menuItems:e}){let{user:t}=Cn();return Pn(t),(0,G.jsx)(`div`,{className:`hidden md:[@media(hover:hover)]:block xl:block`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`inline-block`,children:[(0,G.jsx)(B,{to:`/`,children:(0,G.jsx)(Ki,{})}),(0,G.jsx)(Ua,{})]}),(0,G.jsx)(Fa,{children:(0,G.jsxs)(Ra,{className:`text-muted-foreground dark:text-grey-400`,children:[e.map(e=>to(e)?!!e.items.length&&(0,G.jsx)(`div`,{className:`bg-muted dark:bg-black rounded-2xl flex`,children:e.items.map(e=>(0,G.jsx)(io,{menuItem:e},e.text))},e.text):(0,G.jsx)(io,{menuItem:e},e.text)),!1,(0,G.jsx)(Ia,{children:(0,G.jsx)(Na,{})})]})})]})})}function io({menuItem:e}){return(0,G.jsx)(Ia,{className:`text-muted-foreground dark:text-gray-400 hover:text-foreground dark:hover:text-white`,children:(0,G.jsxs)(Ba,{children:[(0,G.jsx)(Va,{asChild:!0,children:(0,G.jsx)(La,{asChild:!0,children:(0,G.jsxs)(B,{to:e.to,onClick:e.onClick,"aria-label":e.text,className:`flex-row items-center`,target:e.target,activeProps:e.to?$a:void 0,children:[e.icon,(0,G.jsx)(`span`,{className:`hidden ${e.textBreakpoint}:inline-block`,children:e.text}),(0,G.jsx)(`span`,{className:`${e.textBreakpoint}:hidden`,children:`\xA0`})]})})}),(0,G.jsx)(Ha,{side:`bottom`,className:`${e.textBreakpoint}:hidden`,children:e.text})]})})}function ao({menuItems:e}){let{user:t}=Cn();Pn(t);let[n,r]=(0,W.useState)(!1),i=(0,W.useCallback)(()=>r(e=>!e),[]),a=(0,W.useCallback)(()=>r(!1),[]);return(0,G.jsxs)(`div`,{className:`md:[@media(hover:hover)]:hidden xl:hidden`,id:`mobile-menu`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(B,{to:`/`,children:(0,G.jsx)(Ki,{})}),(0,G.jsx)(Ua,{}),(0,G.jsxs)(`div`,{className:`flex items-center`,children:[!1,(0,G.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:i,children:[(0,G.jsx)(`span`,{className:`sr-only`,children:n?`Close menu`:`Open menu`}),n?(0,G.jsx)(gn,{}):(0,G.jsx)(Lr,{})]})]})]}),(0,G.jsx)(`div`,{className:`${n?`fixed`:`hidden`} top-40 bottom-0 left-0 right-0 bg-foreground/20 dark:bg-black-dark dark:opacity-70`,onClick:a}),(0,G.jsxs)(`div`,{className:`${n?`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:[(0,G.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,G.jsx)(Na,{})}),e.map(e=>to(e)?!!e.items.length&&(0,G.jsx)(`div`,{className:`bg-muted dark:bg-black pl-10 pr-2 py-2`,children:e.items.map(e=>(0,G.jsx)(oo,{menuItem:e,onClick:a},e.text))},e.text):(0,G.jsx)(oo,{menuItem:e,onClick:a},e.text))]})]})}function oo({menuItem:e,onClick:t}){let n=(0,W.useCallback)(()=>{e.onClick?.(),t()},[e,t]);return(0,G.jsxs)(B,{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?$a:void 0,children:[e.icon,(0,G.jsx)(`span`,{className:`ml-4`,children:e.text})]})}function so(){let{isLoading:e}=Cn(),{createCluster:t}=he({strict:!1}),[,n]=xn(vn.SavedClusterState,null);return(0,W.useEffect)(()=>{t&&n(t)},[t,n]),e?(0,G.jsx)(Wi,{className:`fixed z-50 translate-1/2`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`header`,{className:`fixed top-0 z-40 w-full h-20 p-4 bg-gradient-to-r from-violet-100 to-white border-b border-violet-200 dark:from-purple-950 dark:to-zinc-900 dark:border-purple-950 md:px-12`,children:(0,G.jsx)(eo,{})}),(0,G.jsx)(`main`,{children:(0,G.jsx)(He,{})})]})}function co(){let e=location.hash;return e?e.startsWith(`#/`)?e.slice(1):e:`/`}var lo=[`/`,`/forgot-password`,`/reset-password`,`/sign-in`,`/sign-up`,`/verify-email`];function uo(){let e=co();return!lo.includes(e)&&{redirect:e}}var fo=`me|email|token|access_token|id_token|refresh_token|code|secret|password|api[-_]?key`,po=String.raw`[^&#\s",<>[\]{}|\\]+`,mo=String.raw`[\w.%+!~*'()-]+(?:@|%40)[\w-]+(?:\.[\w-]+)*\.\w{2,}`;new RegExp(String.raw`([?&](?:${fo})=)${po}`,`gi`),new RegExp(String.raw`([?&](?:${fo})=)${po}|${mo}`,`gi`);var ho=String.raw`[\w-]+-extension`;new RegExp(String.raw`^${ho}://`),new RegExp(String.raw`^\s*at\s.* @ ((?:blob:)?(?:https?|${ho})://\S*)\s*$`);var go=!1;function _o(){(0,W.useEffect)(()=>{go||=!0},[])}function vo(){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ke,{}),(0,G.jsx)(He,{})]})}var yo=ve()({component:vo}),bo=F({getParentRoute:()=>yo,id:`_dashboardLayout`,component:so,beforeLoad:({context:e})=>{let t=e.authentication[m];if(t&&!t.isLoading&&!t.user)throw le({to:`/sign-in`,search:uo()})}}),xo=F({getParentRoute:()=>bo,path:`admin`,component:Ui});F({getParentRoute:()=>xo,path:`/`,beforeLoad:()=>{throw le({to:`/admin/notifications`})}}),F({getParentRoute:()=>xo,path:`notifications`,head:()=>({meta:[{title:`Notifications — Harper Fabric`}]}),component:we(async()=>ne(()=>import(`./notifications-CUmtIA6z.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])),`NotificationsAdminIndex`)}),F({getParentRoute:()=>xo,path:`regions`,head:()=>({meta:[{title:`Regions — Harper Fabric`}]}),component:we(async()=>ne(()=>import(`./regions-C8qR0HhD.js`),__vite__mapDeps([15,1,3,2,4,5,6,7,8,9,10,11,12,13,16])),`RegionsIndex`)}),F({getParentRoute:()=>xo,path:`api-token`,head:()=>({meta:[{title:`API Token — Harper Fabric`}]}),component:we(async()=>ne(()=>import(`./apiToken-DN0nmDsq.js`),__vite__mapDeps([17,1,2,3,4,5,6,7])),`ApiTokenIndex`)});function So(){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`header`,{className:`fixed top-0 z-40 w-full h-20 p-4 bg-gradient-to-r from-violet-100 to-white border-b border-violet-200 dark:from-purple-950 dark:to-zinc-900 dark:border-purple-950 md:px-12`,children:(0,G.jsx)(eo,{})}),(0,G.jsxs)(`div`,{className:`pt-20 h-screen grid grid-cols-1 md:grid-cols-2`,children:[(0,G.jsx)(`section`,{"aria-label":`Harper Fabric overview`,className:`items-center justify-center hidden text-white md:flex px-6 fabricSignupTextContainer`,children:(0,G.jsx)(`img`,{className:`object-scale-down max-h-[calc(100vh-80px-40px)] min-h-115`,src:`/fabric-signup-text.png`,alt:`One Runtime: App, database, Cache and Messaging. Distributed by design, free to deploy, and live in minutes. Deploy!`})}),(0,G.jsx)(`main`,{className:`overflow-y-auto px-6 bg-white dark:bg-linear-(--black-dark-gradient) border-l border-border dark:border-none`,children:(0,G.jsx)(`div`,{className:`min-h-full flex items-start justify-center py-12`,children:(0,G.jsx)(He,{})})})]})]})}function Co(){(0,W.useEffect)(()=>{},[])}var wo=[`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 To(e){if(!e||!e.includes(`@`))return null;let t=e.split(`@`).pop()||``;if(!t)return null;for(let e of wo)if(t===e||t.endsWith(`.`+e))return null;return t}var Eo=`utm_`;function Do(e){let t=new URLSearchParams(e),n=Array.from(t.keys()).filter(e=>e.toLowerCase().startsWith(Eo));if(n.length===0)return e;for(let e of n)t.delete(e);let r=t.toString();return r?`?${r}`:``}function Oo(){if(typeof location>`u`||typeof history>`u`)return;let{search:e,pathname:t,hash:n,origin:r}=location,i=Do(e);i!==e&&history.replaceState(history.state,``,`${r}${t}${i}${n}`)}var ko=null;function Ao(){let e=I(),t=pe(),n=Ie(),{redirect:r}=he({strict:!1});return(0,W.useEffect)(()=>{ko||=(async function(){let i=await l().catch(()=>null);if(!i)H.error(`We were not able to verify your sign-in. Please try signing in again.`,{duration:1e4}),await e({to:`/sign-in`});else{u.setUserForEntity(m,i),Oo();let a=Pn(i);To(i.email),await n.invalidateQueries({queryKey:f,refetchType:`none`}),await t.invalidate(),await e({to:r?.startsWith(`/`)?r:a})}ko=null})()},[]),(0,G.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`text-foreground dark:text-white w-lg flex flex-col gap-4`,children:[(0,G.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Checking...`]}),(0,G.jsx)(`div`,{className:`underline flex gap-4`,children:(0,G.jsx)(B,{className:`text-sm opacity-50 text-muted-foreground hover:text-foreground dark:text-inherit dark:hover:text-blue-300`,to:`/sign-in`,children:`Try signing in again`})})]})}var jo=new Map;function Mo(e){if(!e)return``;if(jo.has(e))return jo.get(e);let t=e.replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();if(!t)return jo.set(e,``),``;let n=t.match(/([A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|[0-9]+)/g);if(!n)return jo.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(No).join(` `);return jo.set(e,i),i}function No(e){return/^[A-Z]{2,3}s?$/.test(e)||/^[0-9]+$/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function Po({restartRequired:e}){let t=Oe(),{organization:n,instance:r,cluster:i}=ye({strict:!1}),a=(0,W.useMemo)(()=>{let e=t.pathname.split(`/`).filter(e=>e&&e.length>0),a=[(0,G.jsxs)(B,{to:`/`,children:[(0,G.jsx)(Cr,{"aria-hidden":`true`,className:`size-5 shrink-0`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Home`})]},`home`)];for(let t=0;t<e.length;t++){let o=e[t];if(o===`instance`)continue;let s=`/${e.slice(0,t+1).join(`/`)}`,c=Mo(o);o===`databases`&&e.length===t+3?(c=e[t+2],t+=2):c.startsWith(`Org `)?c=n?.name||`Org`:c.startsWith(`Clu `)?(c=i?.name||`Cluster`,e[t+1]===`instance`&&(s+=`/instances`)):c.startsWith(`Ins `)?c=r?.name?.split(`.`)?.shift()||`Instance`:c===`Apis`&&(c=`APIs`),a.push((0,G.jsx)(`svg`,{fill:`currentColor`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`size-5 shrink-0 text-grey`,children:(0,G.jsx)(`path`,{d:`M5.555 17.776l8-16 .894.448-8 16-.894-.448z`})},a.length+`-dash`),(0,G.jsx)(B,{to:s,className:`text-xs md:text-sm font-medium hover:text-grey truncate max-w-48`,children:c},s))}return a},[t.pathname,i?.name,r?.name,n?.name]);return(0,G.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:[...a,e&&(0,G.jsxs)(Ba,{children:[(0,G.jsx)(Va,{asChild:!0,children:(0,G.jsxs)(`div`,{className:`text-xs italic text-muted-foreground`,children:[`* Restart `,(0,G.jsx)(`span`,{className:`hidden lg:inline-block`,children:`Requested`})]})}),(0,G.jsxs)(Ha,{side:`bottom`,children:[`This `,`Instance`,` is requesting a restart, when convenient, to apply your latest changes.`,(0,G.jsx)(`br`,{}),`You can do this from the Apps or Config pages.`]})]})]})}var q=Vt,Fo=(0,W.createContext)({}),Io=(0,W.createContext)({});function Lo(){let e=(0,W.useContext)(Fo),t=(0,W.useContext)(Io),{getFieldState:n}=Tt(),r=Ht({name:e.name}),i=n(e.name,r);if(!e)throw Error(`useFormField should be used within <FormField>`);let{id:a}=t;return{id:a,name:e.name,formItemId:`${a}-form-item`,formDescriptionId:`${a}-form-item-description`,formMessageId:`${a}-form-item-message`,...i}}function J({...e}){let{error:t,formItemId:n,formDescriptionId:r,formMessageId:i}=Lo();return(0,G.jsx)(st,{"data-slot":`form-control`,id:n,"aria-describedby":t?`${r} ${i}`:`${r}`,"aria-invalid":!!t,...e})}function Y({...e}){return(0,G.jsx)(Fo,{value:{name:e.name},children:(0,G.jsx)(Kt,{...e})})}function X({className:e,...t}){let n=(0,W.useId)();return(0,G.jsx)(Io,{value:{id:n},children:(0,G.jsx)(`div`,{"data-slot":`form-item`,className:N(`grid gap-2`,e),...t})})}function Ro({className:e,...t}){return(0,G.jsx)(At,{"data-slot":`label`,className:N(`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}=Lo();return(0,G.jsx)(Ro,{"data-slot":`form-label`,"data-error":!!n,className:N(`data-[error=true]:text-destructive`,e),htmlFor:r,...t})}function Q({className:e,...t}){let{error:n,formMessageId:r}=Lo(),i=n?String(n?.message):t.children;return i?(0,G.jsx)(`p`,{"data-slot":`form-message`,id:r,className:N(`text-destructive text-sm`,e),...t,children:i}):null}function $({className:e,type:t,...n}){return(0,G.jsx)(`input`,{type:t,"data-slot":`input`,className:N(`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/notifications-DFbArTfC.js","assets/rolldown-runtime-hePW80VL.js","assets/button-BIsUKRZq.js","assets/vendor-core-c2JRRJpV.js","assets/vendor-datadog-CLUcJXOo.js","assets/vendor-react-CJV_K1u4.js","assets/vendor-ui-BUjK0h8a.js","assets/vendor-tanstack-DxzraizX.js","assets/dialog-Cn2uWgD4.js","assets/createLucideIcon-CzW9508A.js","assets/x-DIzaLEdK.js","assets/setLocalStorage-D_kflv4U.js","assets/safeParse-DeaoCCWH.js","assets/useLocalStorage-BqMR3D8_.js","assets/alertDialog-CQyAJJhl.js","assets/regions-CtkV0xje.js","assets/chevron-up-DtKGqDn3.js","assets/apiToken-Bke3wvfZ.js","assets/setup-DWprJyJy.js","assets/dist-DP8UjMB_.js","assets/register-1ZZuMsiA.js","assets/register-jjEx9u7D.css","assets/editor-3XRWEDWX.js","assets/toggleHighContrast-Cq_lt3XD.js","assets/toggleHighContrast--ixms01u.css","assets/index.lazy-B1VOIv-t.js","assets/authStore-C3Nfubqr.js","assets/setSessionStorage-B0bf71m4.js","assets/useEntityRestURL-RZhaY8Rn.js","assets/tabs-BrHu7gJi.js","assets/applications-DvFDYJgK.js","assets/download-B5T5r7ss.js","assets/setComponentFile-ZWLcWv5X.js","assets/languageServices-IKH4GUHl.js","assets/applications-DNZhsH95.css","assets/FloatingChat-omlNMDcJ.js","assets/status--aNm8isn.js","assets/errorText-NpBmvk9I.js","assets/linear-Cnt8506Q.js","assets/step-vX8bovaY.js","assets/defaultLocale-BFoDCU3G.js","assets/init-ZlXS9mIS.js","assets/ordinal-CPleeUAT.js","assets/time-Cclkb7kQ.js","assets/band-DZ4Jagyz.js","assets/getAnalytics-GHK8ORfM.js","assets/notifications-BfKBpYcq.js","assets/profile-Q4-T6c-S.js"])))=>i.map(i=>d[i]);
2
+ import{r as e,t}from"./rolldown-runtime-hePW80VL.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,y as g}from"./authStore-C3Nfubqr.js";import{D as _,O as v,T as y,_ as b,f as x,g as S,h as C,i as w,o as T,r as E,s as D,t as O,u as k,v as A,w as j,y as ee}from"./vendor-core-c2JRRJpV.js";import{i as M,n as N,t as P}from"./button-BIsUKRZq.js";import{a as te,i as ne,t as re}from"./vendor-datadog-CLUcJXOo.js";import{r as ie,t as ae}from"./vendor-react-CJV_K1u4.js";import{A as oe,B as se,C as F,D as I,E as ce,F as le,G as ue,H as de,I as L,K as fe,L as R,M as pe,N as me,O as he,P as ge,R as _e,S as ve,T as ye,U as be,V as xe,_ as Se,a as Ce,b as we,c as Te,d as Ee,f as De,g as Oe,h as ke,i as Ae,k as z,l as je,m as Me,n as Ne,o as Pe,p as Fe,q as Ie,r as Le,s as Re,t as ze,u as Be,v as Ve,w as B,y as He,z as V}from"./vendor-tanstack-DxzraizX.js";import{t as Ue}from"./safeParse-DeaoCCWH.js";import{n as We,t as Ge}from"./setSessionStorage-B0bf71m4.js";import{$ as Ke,A as qe,At as Je,B as Ye,C as Xe,Ct as Ze,D as Qe,Dt as $e,E as et,Et as tt,F as nt,Ft as rt,H as it,I as at,It as H,L as ot,Lt as st,M as ct,Mt as lt,N as ut,Nt as dt,O as ft,Ot as pt,P as mt,Pt as ht,R as gt,S as _t,St as vt,T as yt,Tt as bt,U as xt,V as St,W as Ct,_t as wt,at as Tt,b as Et,bt as Dt,ct as Ot,dt as kt,et as At,ft as jt,gt as Mt,ht as Nt,it as Pt,j as Ft,jt as It,k as Lt,kt as Rt,lt as zt,mt as Bt,nt as Vt,ot as Ht,pt as Ut,rt as Wt,st as Gt,tt as Kt,ut as qt,v as Jt,vt as Yt,w as Xt,wt as Zt,x as Qt,xt as $t,y as en,yt as tn,z as nn}from"./vendor-ui-BUjK0h8a.js";import{t as U}from"./createLucideIcon-CzW9508A.js";import{a as rn,c as an,i as on,l as sn,n as cn,o as ln,r as un,s as dn,t as fn}from"./dialog-Cn2uWgD4.js";import{n as pn,r as mn,t as hn}from"./chevron-up-DtKGqDn3.js";import{t as gn}from"./x-DIzaLEdK.js";import{t as _n}from"./errorText-NpBmvk9I.js";import{n as vn,r as yn,t as bn}from"./setLocalStorage-D_kflv4U.js";import{t as xn}from"./useLocalStorage-BqMR3D8_.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 W=e(te(),1);function Sn(){let[e,t]=(0,W.useState)(()=>({...u.getAllConnections()}));return(0,W.useEffect)(()=>u.listenToAllEntities((e,n)=>{t(t=>({...t,[n]:e}))}),[]),e}function Cn(){let e=u.calculateIdFromEntity(m),[t,n]=(0,W.useState)(u.getConnectionById(m));return(0,W.useEffect)(()=>u.listenToEntity(e,n),[e]),t}function wn(){return Cn()}function Tn(e,t){return!e||!(`fabricRole`in e)?!1:e.staffPermissions?e.staffPermissions.includes(t):e.fabricRole===`fabric_admin`||e.fabricRole===`super_user`}function En(e){let{user:t}=wn();return Tn(t,e)}function Dn(e){let t=m,{clusterId:n,instanceId:r}=z({strict:!1}),[i,a]=(0,W.useState)(u.getConnectionById(t??r??n));return(0,W.useEffect)(()=>u.listenToEntity(t,a),[t]),i}var G=ie();function On({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`card`,className:N(`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 kn({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`card-header`,className:N(`flex flex-col gap-1.5 px-6`,e),...t})}function An({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`card-title`,className:N(`leading-none text-lg`,e),...t})}function jn({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`card-description`,className:N(`text-muted-foreground text-xs`,e),...t})}function Mn({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`card-content`,className:N(`px-6`,e),...t})}function Nn(e){return e!==null&&!!e.username}function Pn(e){if(e&&!Nn(e)){let t=Object.keys(e.roles);if(t.length===1)return`/${t[0]}`}return`/`}var Fn=U(`activity`,[[`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`}]]),In=U(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),Ln=U(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),Rn=U(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),zn=U(`arrow-up-down`,[[`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`}]]),Bn=U(`arrow-up-from-line`,[[`path`,{d:`m18 9-6-6-6 6`,key:`kcunyi`}],[`path`,{d:`M12 3v14`,key:`7cf3v8`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]),Vn=U(`bell`,[[`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`}]]),Hn=U(`book-open-text`,[[`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`}]]),Un=U(`brush-cleaning`,[[`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`}]]),Wn=U(`bug`,[[`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`}]]),Gn=U(`calendar-clock`,[[`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`}]]),Kn=U(`chart-column-increasing`,[[`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`}]]),qn=U(`chart-pie`,[[`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`}]]),Jn=U(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Yn=U(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Xn=U(`circle-alert`,[[`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`}]]),Zn=U(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),Qn=U(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]]),$n=U(`circle-dashed`,[[`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`}]]),er=U(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),tr=U(`clipboard-check`,[[`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`}]]),nr=U(`clipboard`,[[`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`}]]),rr=U(`cloud-alert`,[[`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`}]]),ir=U(`cloud-download`,[[`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`}]]),ar=U(`cloud-upload`,[[`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`}]]),or=U(`columns-3-cog`,[[`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`}]]),sr=U(`copy`,[[`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`}]]),cr=U(`credit-card`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}]]),lr=U(`database`,[[`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`}]]),ur=U(`ellipsis`,[[`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`}]]),dr=U(`external-link`,[[`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`}]]),fr=U(`eye-off`,[[`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`}]]),pr=U(`eye`,[[`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`}]]),mr=U(`file-up`,[[`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`}]]),hr=U(`funnel-plus`,[[`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`}]]),gr=U(`funnel`,[[`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`}]]),_r=U(`funnel-x`,[[`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`}]]),vr=U(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),yr=U(`git-graph`,[[`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`}]]),br=U(`globe`,[[`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`}]]),xr=U(`grip-vertical`,[[`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`}]]),Sr=U(`handshake`,[[`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`}]]),Cr=U(`house`,[[`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`}]]),wr=U(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),Tr=U(`key-round`,[[`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`}]]),Er=U(`key`,[[`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`}]]),Dr=U(`layout-dashboard`,[[`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`}]]),Or=U(`life-buoy`,[[`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`}]]),kr=U(`list-todo`,[[`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`}]]),Ar=U(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),jr=U(`lock`,[[`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`}]]),Mr=U(`log-in`,[[`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`}]]),Nr=U(`log-out`,[[`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`}]]),Pr=U(`mail-warning`,[[`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`}]]),Fr=U(`mail`,[[`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`}]]),Ir=U(`map-pin`,[[`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`}]]),Lr=U(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),Rr=U(`monitor`,[[`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`}]]),zr=U(`moon`,[[`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`}]]),Br=U(`notepad-text`,[[`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`}]]),Vr=U(`octagon-alert`,[[`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`}]]),Hr=U(`package`,[[`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`}]]),Ur=U(`pencil`,[[`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`}]]),Wr=U(`play`,[[`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`}]]),Gr=U(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Kr=U(`refresh-cw`,[[`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`}]]),qr=U(`rocket`,[[`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`}]]),Jr=U(`rotate-ccw`,[[`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`}]]),Yr=U(`rotate-cw`,[[`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`}]]),Xr=U(`save`,[[`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`}]]),Zr=U(`scale`,[[`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`}]]),Qr=U(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),$r=U(`server`,[[`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`}]]),ei=U(`settings`,[[`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`}]]),ti=U(`shield-check`,[[`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`}]]),ni=U(`shield-x`,[[`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`}]]);U(`shield`,[[`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`}]]);var ri=U(`sliders-horizontal`,[[`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`}]]),ii=U(`square-pen`,[[`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`}]]),ai=U(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),oi=U(`sun`,[[`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`}]]),si=U(`table-2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]),ci=U(`table`,[[`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`}]]),li=U(`tag`,[[`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`}]]),ui=U(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),di=U(`ticket`,[[`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`}]]),fi=U(`trash`,[[`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`}]]),pi=U(`triangle-alert`,[[`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`}]]),mi=U(`user-minus`,[[`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`}]]),hi=U(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),gi=U(`users`,[[`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`}]]),_i=U(`zap`,[[`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`}]]);function vi({className:e,error:t,title:n,showReturnToHome:r,children:i}){let{user:a,isLoading:o}=Cn();return Pn(a),(0,G.jsxs)(On,{className:N(`text-red p-5 border border-red rounded-md m-12 mt-36`,e),children:[(0,G.jsxs)(kn,{children:[(0,G.jsx)(An,{className:`text-2xl`,children:(0,G.jsx)(`h2`,{children:n??`Component Error`})}),(0,G.jsx)(jn,{children:t.message})]}),(0,G.jsxs)(Mn,{children:[i,r!==!1&&(a&&!o?(0,G.jsx)(B,{to:`/`,children:(0,G.jsxs)(P,{children:[` `,(0,G.jsx)(Ln,{}),` Return to Home`]})}):(0,G.jsx)(B,{to:`/sign-in`,children:(0,G.jsxs)(P,{children:[` `,(0,G.jsx)(Ln,{}),` Go to Sign In Page`]})}))]})]})}function yi(){let{user:e,isLoading:t}=Cn();return Pn(e),(0,G.jsx)(`div`,{className:`flex items-center justify-center h-screen px-3`,children:(0,G.jsxs)(On,{className:`text-red p-5 border border-red rounded-md w-full max-w-md`,children:[(0,G.jsx)(kn,{children:(0,G.jsx)(An,{className:`text-2xl`,children:(0,G.jsx)(`h2`,{children:`Sorry, Page Not Found`})})}),(0,G.jsx)(Mn,{children:e&&!t?(0,G.jsx)(B,{to:`/`,children:(0,G.jsxs)(P,{children:[` `,(0,G.jsx)(Ln,{}),` Return to Home`]})}):(0,G.jsx)(B,{to:`/sign-in`,children:(0,G.jsxs)(P,{children:[` `,(0,G.jsx)(Ln,{}),` Go Sign In Page`]})})})]})})}function bi(){return`ontouchstart`in window||navigator.maxTouchPoints>0}function xi(e){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=_n(e.detail);n=i?`${e.title}: ${i}`:e.title,r=!1}else n=_n(e.error)??_n(e.message)??n}else n=_n(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 Si(e){console.error(e);let{title:t,description:n}=xi(e),r=e,i=r?.code===`ECONNABORTED`||r?.code===`ETIMEDOUT`,a=r?.response?.status===403;H.error(t,{id:i?`request-timeout`:a?`request-forbidden`:void 0,description:n,action:{label:`Dismiss`,onClick:()=>H.dismiss()}})}var Ci=new xe({queryCache:new de({onError:Si}),mutationCache:new be({onError:(e,t,n,r)=>{r.meta?.skipGlobalErrorToast||Si(e)}})});function wi({...e}){return(0,G.jsx)(Rt,{"data-slot":`dropdown-menu`,...e})}function Ti({...e}){return(0,G.jsx)(ht,{"data-slot":`dropdown-menu-trigger`,...e})}function Ei({className:e,sideOffset:t=4,...n}){return(0,G.jsx)(pt,{children:(0,G.jsx)(Zt,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:N(`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 Di({className:e,inset:t,variant:n=`default`,...r}){return(0,G.jsx)(bt,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:N(`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 Oi({className:e,children:t,checked:n,...r}){return(0,G.jsxs)(Ze,{"data-slot":`dropdown-menu-checkbox-item`,className:N(`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,G.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,G.jsx)(tt,{children:(0,G.jsx)(mn,{className:`size-4`})})}),t]})}function ki({className:e,inset:t,...n}){return(0,G.jsx)($e,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:N(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function Ai({className:e,...t}){return(0,G.jsx)(Je,{"data-slot":`dropdown-menu-separator`,className:N(`bg-border -mx-1 my-1 h-px`,e),...t})}function ji({className:e,...t}){return(0,G.jsx)(`span`,{"data-slot":`dropdown-menu-shortcut`,className:N(`text-muted-foreground ml-auto text-xs tracking-widest`,e),...t})}function Mi({...e}){return(0,G.jsx)(It,{"data-slot":`dropdown-menu-sub`,...e})}function Ni({className:e,inset:t,children:n,...r}){return(0,G.jsxs)(dt,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:N(`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,G.jsx)(Yn,{className:`ml-auto size-4`})]})}function Pi({className:e,...t}){return(0,G.jsx)(lt,{"data-slot":`dropdown-menu-sub-content`,className:N(`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 Fi=`flex items-center gap-3 p-2 rounded-lg text-sm transition-colors`,Ii=`block p-2 rounded-lg text-sm transition-colors`,Li={className:`text-foreground hover:bg-accent dark:text-white dark:hover:bg-grey-700`},Ri={className:`font-medium text-primary bg-primary/10 dark:text-white dark:bg-white/10`};function zi({items:e,ariaLabel:t}){let{pathname:n}=Oe(),r=e=>e.exact?n===e.to:n.startsWith(e.to),i=e.find(r)??e[0],a=i.icon;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`nav`,{className:`hidden md:flex flex-col gap-1`,"aria-label":t,children:e.map(e=>{let t=e.icon;return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(B,{to:e.to,className:Fi,activeOptions:{exact:!!e.exact},activeProps:Ri,inactiveProps:Li,children:[(0,G.jsx)(t,{className:`size-4 shrink-0`}),e.label]}),e.children&&r(e)&&(0,G.jsx)(`div`,{className:`mt-1 ml-4 flex flex-col gap-1 border-l border-border pl-3`,children:e.children.map(e=>(0,G.jsx)(B,{to:e.to,className:Ii,activeOptions:{exact:!!e.exact},activeProps:Ri,inactiveProps:Li,children:e.label},e.to))})]},e.to)})}),(0,G.jsx)(`div`,{className:`md:hidden`,children:(0,G.jsxs)(wi,{children:[(0,G.jsx)(Ti,{asChild:!0,children:(0,G.jsxs)(P,{variant:`outline`,className:`w-full justify-between`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(a,{className:`size-4`}),i.label]}),(0,G.jsx)(pn,{className:`size-4`})]})}),(0,G.jsx)(Ei,{align:`start`,className:`w-(--radix-dropdown-menu-trigger-width)`,children:e.map(e=>{let t=e.icon;return[(0,G.jsx)(Di,{asChild:!0,children:(0,G.jsxs)(B,{to:e.to,className:`flex items-center gap-2`,children:[(0,G.jsx)(t,{className:`size-4`}),e.label]})},e.to),...e.children&&r(e)?e.children.map(e=>(0,G.jsx)(Di,{asChild:!0,children:(0,G.jsx)(B,{to:e.to,className:`flex items-center gap-2 pl-8`,children:e.label})},e.to)):[]]})})]})})]})}var Bi=[{to:`/admin/notifications`,label:`Notifications`,icon:Vn,permission:`systemStatus:write`},{to:`/admin/regions`,label:`Regions`,icon:br,permission:`region:read`},{to:`/admin/api-token`,label:`API Token`,icon:Tr,permission:`apiToken:create`,ssoAccountOnly:!0}];function Vi(e){let t=e!==null&&`fabricRole`in e&&e.fabricRole===`super_user`;return Bi.filter(n=>Tn(e,n.permission)&&!(n.ssoAccountOnly&&t))}function Hi(e){return Vi(e).length>0}function Ui(){let{isLoading:e,user:t}=wn(),{pathname:n}=Oe();if(e)return null;let r=Vi(t);if(!r.length)return(0,G.jsx)(ce,{to:`/`,replace:!0});let i=Bi.find(e=>n.startsWith(e.to));return i&&!r.includes(i)?(0,G.jsx)(ce,{to:r[0].to,replace:!0}):(0,G.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,G.jsxs)(`div`,{className:`md:grid gap-6 md:grid-cols-12`,children:[(0,G.jsx)(`aside`,{className:`md:col-span-3 lg:col-span-2 mb-4 md:mb-0`,children:(0,G.jsx)(zi,{items:r,ariaLabel:`Admin sections`})}),(0,G.jsx)(`section`,{className:`md:col-span-9 lg:col-span-10 min-w-0`,children:(0,G.jsx)(He,{})})]})})}function Wi({className:e,text:t,centered:n,...r}){return(0,G.jsxs)(`div`,{className:`text-foreground h-full w-full ${e||``} ${n?`flex flex-col items-center justify-center`:``}`,...r,children:[(0,G.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`100px`,height:`100px`,alt:`HDB Dog Logo Loading`,className:`inline-block`}),(0,G.jsx)(`p`,{className:`pt-4`,children:t||`Loading...`})]})}function Gi(){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 126.644 96`,width:24,height:24,children:(0,G.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 Ki(){let e=`studio`,t=`Harper Studio`;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`img`,{src:`/harper-${e}_black.png`,alt:t,className:`w-64 hidden md:inline-block dark:hidden`}),(0,G.jsx)(`img`,{src:`/harper-${e}_white.png`,alt:t,className:`w-64 hidden md:dark:inline-block`}),(0,G.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`50px`,height:`44px`,alt:`Harper`,className:`inline-block md:hidden`})]})}var qi=j(`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-destructive text-white [a&]:hover:bg-destructive/90 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 Ji({className:e,variant:t,asChild:n=!1,...r}){return(0,G.jsx)(n?st:`span`,{"data-slot":`badge`,className:N(qi({variant:t}),e),...r})}function Yi({className:e,children:t,...n}){return(0,G.jsxs)(tn,{"data-slot":`scroll-area`,className:N(`relative`,e),...n,children:[(0,G.jsx)(vt,{"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,G.jsx)(Xi,{}),(0,G.jsx)(Yt,{})]})}function Xi({className:e,orientation:t=`vertical`,...n}){return(0,G.jsx)(Dt,{"data-slot":`scroll-area-scrollbar`,orientation:t,className:N(`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,G.jsx)($t,{"data-slot":`scroll-area-thumb`,className:`bg-border relative flex-1 rounded-full`})})}var Zi=[`notification-acks`];function Qi(){let e=yn(vn.AckedNotificationIds,[]);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function $i(e){Ci.setQueryData(Zi,e);try{bn(vn.AckedNotificationIds,e)}catch(e){console.warn(`[notifications] could not persist acknowledgements`,e)}}function ea(){return R({queryKey:Zi,queryFn:Qi,staleTime:1/0,gcTime:1/0,initialData:Qi})}function ta(e){$i(Array.from(new Set([...Qi(),e])))}function na(e){$i(Qi().filter(t=>t!==e))}function ra(){let{data:e}=V(ea());return(0,W.useMemo)(()=>new Set(e??[]),[e])}var ia={critical:{severity:`critical`,label:`Critical`,Icon:Vr,badgeVariant:`destructive`,bannerClass:`bg-destructive/10 border-destructive/40 text-foreground`,iconClass:`text-destructive`},warning:{severity:`warning`,label:`Warning`,Icon:pi,badgeVariant:`warning`,bannerClass:`bg-yellow/10 border-yellow/40 text-foreground`,iconClass:`text-yellow`},info:{severity:`info`,label:`Info`,Icon:wr,badgeVariant:`secondary`,bannerClass:`bg-secondary/20 border-secondary/50 text-foreground`,iconClass:`text-secondary-foreground`}},aa=new Set([`critical`,`error`,`outage`,`incident`,`down`,`danger`]),oa=new Set([`warning`,`warn`,`maintenance`,`degraded`,`notice`]),sa=new Set([`info`,`information`,`informational`,`success`,`ok`]);function ca(e){let t=(e??``).trim().toLowerCase();return oa.has(t)?`warning`:sa.has(t)?`info`:(aa.has(t),`critical`)}function la(e){return ia[ca(e)]}var ua={critical:0,warning:1,info:2};function da(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 fa(e){let t=da(e);return t.kind===`valid`?t.ms:null}function pa(e){return new Date(e).toLocaleString()}function ma(e,t){let n=da(e.startAt),r=da(e.endAt);return n.kind===`invalid`||r.kind===`invalid`?{state:`expired`,label:`Schedule unavailable`}:n.kind===`valid`&&t<n.ms?{state:`upcoming`,label:`Starts ${pa(n.ms)}`}:r.kind===`valid`&&t>r.ms?{state:`expired`,label:`Ended ${pa(r.ms)}`}:r.kind===`valid`?{state:`active`,label:`Active until ${pa(r.ms)}`}:{state:`active`,label:`Active`}}var ha=new Set([`http`,`https`,`mailto`]);function ga(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?ha.has(n)?{kind:`external`,href:t}:null:{kind:`internal`,href:t.startsWith(`/`)?t:`/${t}`}}function _a({url:e,className:t,children:n,onNavigate:r}){let i=ga(e);return i?i.kind===`external`?(0,G.jsxs)(`a`,{href:i.href,target:`_blank`,rel:`noreferrer noopener`,className:t,children:[n??`Learn more`,(0,G.jsx)(dr,{className:`inline size-3 ml-1 align-[-1px]`})]}):(0,G.jsx)(B,{to:i.href,className:t,onClick:r,children:n??`View details`}):null}var va=[`system-status`];async function ya(){let{data:e}=await M.get(`/SystemStatus/`);return Array.isArray(e)?e:[]}function ba(){return R({queryKey:va,queryFn:ya,refetchInterval:6e4,staleTime:3e4})}var xa=3e4,Sa=new Set,Ca=Date.now(),wa=null;function Ta(e){return Sa.add(e),wa||=(Ca=Date.now(),setInterval(()=>{Ca=Date.now(),Sa.forEach(e=>e())},xa)),()=>{Sa.delete(e),Sa.size===0&&wa&&(clearInterval(wa),wa=null)}}function Ea(){return(0,W.useSyncExternalStore)(Ta,()=>Ca,()=>Ca)}function Da(){return V(ba())}function Oa(){let[e,t]=(0,W.useState)(()=>window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`);return(0,W.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 ka=(0,W.createContext)([`system`,()=>{}]);function Aa({children:e}){let[t,n]=xn(vn.Theme,`system`),r=Oa();return(0,W.useEffect)(()=>{let e=t===`dark`||t===`system`&&r===`dark`;document.documentElement.classList.toggle(`dark`,e)},[t,r]),(0,G.jsx)(ka.Provider,{value:[t,n],children:e})}function ja(){return(0,W.useContext)(ka)}var Ma=[{value:`light`,icon:(0,G.jsx)(oi,{className:`size-4`}),label:`Light`},{value:`system`,icon:(0,G.jsx)(Rr,{className:`size-4`}),label:`System`},{value:`dark`,icon:(0,G.jsx)(zr,{className:`size-4`}),label:`Dark`}];function Na(){let[e,t]=ja();return(0,G.jsx)(`div`,{className:`flex items-center bg-muted dark:bg-black rounded-xl p-0.5 gap-0.5`,children:Ma.map(({value:n,icon:r,label:i})=>(0,G.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 Pa({className:e,...t}){return(0,G.jsx)(`div`,{className:N(`absolute top-full left-0 isolate z-50 flex justify-center`),children:(0,G.jsx)(wt,{"data-slot":`navigation-menu-viewport`,className:N(`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 Fa({className:e,children:t,viewport:n=!0,...r}){return(0,G.jsxs)(Mt,{"data-slot":`navigation-menu`,"data-viewport":n,className:N(`group/navigation-menu relative flex max-w-max flex-1 items-center justify-center`,e),...r,children:[t,n&&(0,G.jsx)(Pa,{})]})}function Ia({className:e,...t}){return(0,G.jsx)(Ut,{"data-slot":`navigation-menu-item`,className:N(`relative`,e),...t})}function La({className:e,...t}){return(0,G.jsx)(Bt,{"data-slot":`navigation-menu-link`,className:N(`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 Ra({className:e,...t}){return(0,G.jsx)(Nt,{"data-slot":`navigation-menu-list`,className:N(`group flex flex-1 list-none items-center justify-center gap-1`,e),...t})}function za({delayDuration:e=0,...t}){return(0,G.jsx)(qt,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Ba({...e}){return(0,G.jsx)(za,{children:(0,G.jsx)(kt,{"data-slot":`tooltip`,...e})})}function Va({...e}){return(0,G.jsx)(jt,{"data-slot":`tooltip-trigger`,...e})}function Ha({className:e,sideOffset:t=0,arrowClassName:n,children:r,...i}){return(0,G.jsx)(zt,{children:(0,G.jsxs)(Ot,{"data-slot":`tooltip-content`,sideOffset:t,className:N(`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,G.jsx)(Gt,{className:N(`bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`,n)})]})})}function Ua(){let e=`v5.2.13`,t=e.startsWith(`v`)?`https://github.com/HarperFast/studio/releases/tag/${e}`:`https://github.com/HarperFast/studio/releases`;return(0,G.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,children:(0,G.jsxs)(`span`,{className:N(qi({variant:`default`}),`text-xs inline-block ml-2 align-text-top`),children:[e,` BETA`]})})}function Wa(e={}){let{instanceId:t,clusterId:n}=z({strict:!1});return o({id:m,...e})}function Ga(e={}){let{instanceId:t,clusterId:n}=z({strict:!1});return{instanceClient:o({id:m,...e}),entityType:`instance`}}function K(e={}){let{instanceId:t,clusterId:n}=z({strict:!1});return(0,W.useMemo)(()=>Ka({instanceId:t,clusterId:n,...e}),[e.instanceId??t,e.clusterId??n,e.operationsUrl,e.port,e.secure,e.disableFabricConnect,e.forceFabricConnect])}function Ka({instanceId:e,clusterId:t,...n}){let r=m;if(!r)throw Error(`id could not be automatically calculated in useInstanceClientIdParams`);return{instanceClient:o({id:r,...n}),entityId:r,entityType:`instance`}}function qa(){localStorage.clear()}function Ja(){sessionStorage.clear()}async function Ya(){u.setUserForEntity(m,null),Ci.getQueryCache().clear(),qa(),Ja(),await Ci.invalidateQueries({refetchType:`none`})}async function Xa(e){await u.signOutFromPotentiallyAuthenticatedInstances(),await d({...e,entityId:m})}function Za(){let e=Wa();return L({mutationFn:()=>Xa({instanceClient:e}),onSuccess:Ya})}function Qa(e){return!!e}var $a={className:`text-foreground dark:text-white font-semibold`};function eo(){let{mutate:e}=Za(),t=I(),{user:n}=Cn(),r=Hi(n),i=pe(),a=(0,W.useCallback)(()=>{e(void 0,{onSuccess:async()=>{H.success(`Success`,{description:`You have been signed out successfully.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),t({to:`/sign-in`}),i.invalidate()}})},[e,i,t]),o=(0,W.useMemo)(()=>[!1,!1,{to:`https://docs.harperdb.io/docs`,target:`_blank`,icon:(0,G.jsx)(Hn,{}),text:`Docs`,textBreakpoint:`md`},{to:`https://github.com/HarperFast/studio/issues`,target:`_blank`,icon:(0,G.jsx)(Wn,{}),text:`Report an Issue`,textBreakpoint:`lg`},{to:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,icon:(0,G.jsx)(Gi,{}),text:`Discord`,textBreakpoint:`lg`},{onClick:a,icon:(0,G.jsx)(Nr,{}),text:`Sign Out`,textBreakpoint:`md`}].filter(Qa),[a,r]);return n?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ao,{menuItems:o}),(0,G.jsx)(ro,{menuItems:o})]}):(0,G.jsx)(no,{})}function to(e){return e.items!==void 0}function no(){return(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`inline-block`,children:[(0,G.jsx)(B,{to:`/sign-in`,children:(0,G.jsx)(Ki,{})}),(0,G.jsx)(Ua,{})]}),(0,G.jsx)(Fa,{children:(0,G.jsxs)(Ra,{className:`text-muted-foreground dark:text-grey-400`,children:[(0,G.jsx)(Ia,{children:(0,G.jsx)(La,{asChild:!0,children:(0,G.jsxs)(B,{to:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noreferrer noopener`,className:`flex-row items-center`,children:[(0,G.jsx)(Hn,{}),` `,(0,G.jsx)(`span`,{className:`hidden md:inline-block`,children:`Docs`})]})})}),(0,G.jsx)(Ia,{children:(0,G.jsx)(Na,{})}),(0,G.jsx)(Ia,{children:(0,G.jsx)(La,{asChild:!0,children:(0,G.jsxs)(B,{to:`/sign-in`,className:`flex-row items-center`,activeProps:$a,children:[(0,G.jsx)(Mr,{}),` Sign In`]})})})]})})]})}function ro({menuItems:e}){let{user:t}=Cn();return Pn(t),(0,G.jsx)(`div`,{className:`hidden md:[@media(hover:hover)]:block xl:block`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`inline-block`,children:[(0,G.jsx)(B,{to:`/`,children:(0,G.jsx)(Ki,{})}),(0,G.jsx)(Ua,{})]}),(0,G.jsx)(Fa,{children:(0,G.jsxs)(Ra,{className:`text-muted-foreground dark:text-grey-400`,children:[e.map(e=>to(e)?!!e.items.length&&(0,G.jsx)(`div`,{className:`bg-muted dark:bg-black rounded-2xl flex`,children:e.items.map(e=>(0,G.jsx)(io,{menuItem:e},e.text))},e.text):(0,G.jsx)(io,{menuItem:e},e.text)),!1,(0,G.jsx)(Ia,{children:(0,G.jsx)(Na,{})})]})})]})})}function io({menuItem:e}){return(0,G.jsx)(Ia,{className:`text-muted-foreground dark:text-gray-400 hover:text-foreground dark:hover:text-white`,children:(0,G.jsxs)(Ba,{children:[(0,G.jsx)(Va,{asChild:!0,children:(0,G.jsx)(La,{asChild:!0,children:(0,G.jsxs)(B,{to:e.to,onClick:e.onClick,"aria-label":e.text,className:`flex-row items-center`,target:e.target,activeProps:e.to?$a:void 0,children:[e.icon,(0,G.jsx)(`span`,{className:`hidden ${e.textBreakpoint}:inline-block`,children:e.text}),(0,G.jsx)(`span`,{className:`${e.textBreakpoint}:hidden`,children:`\xA0`})]})})}),(0,G.jsx)(Ha,{side:`bottom`,className:`${e.textBreakpoint}:hidden`,children:e.text})]})})}function ao({menuItems:e}){let{user:t}=Cn();Pn(t);let[n,r]=(0,W.useState)(!1),i=(0,W.useCallback)(()=>r(e=>!e),[]),a=(0,W.useCallback)(()=>r(!1),[]);return(0,G.jsxs)(`div`,{className:`md:[@media(hover:hover)]:hidden xl:hidden`,id:`mobile-menu`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(B,{to:`/`,children:(0,G.jsx)(Ki,{})}),(0,G.jsx)(Ua,{}),(0,G.jsxs)(`div`,{className:`flex items-center`,children:[!1,(0,G.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:i,children:[(0,G.jsx)(`span`,{className:`sr-only`,children:n?`Close menu`:`Open menu`}),n?(0,G.jsx)(gn,{}):(0,G.jsx)(Lr,{})]})]})]}),(0,G.jsx)(`div`,{className:`${n?`fixed`:`hidden`} top-40 bottom-0 left-0 right-0 bg-foreground/20 dark:bg-black-dark dark:opacity-70`,onClick:a}),(0,G.jsxs)(`div`,{className:`${n?`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:[(0,G.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,G.jsx)(Na,{})}),e.map(e=>to(e)?!!e.items.length&&(0,G.jsx)(`div`,{className:`bg-muted dark:bg-black pl-10 pr-2 py-2`,children:e.items.map(e=>(0,G.jsx)(oo,{menuItem:e,onClick:a},e.text))},e.text):(0,G.jsx)(oo,{menuItem:e,onClick:a},e.text))]})]})}function oo({menuItem:e,onClick:t}){let n=(0,W.useCallback)(()=>{e.onClick?.(),t()},[e,t]);return(0,G.jsxs)(B,{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?$a:void 0,children:[e.icon,(0,G.jsx)(`span`,{className:`ml-4`,children:e.text})]})}function so(){let{isLoading:e}=Cn(),{createCluster:t}=he({strict:!1}),[,n]=xn(vn.SavedClusterState,null);return(0,W.useEffect)(()=>{t&&n(t)},[t,n]),e?(0,G.jsx)(Wi,{className:`fixed z-50 translate-1/2`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`header`,{className:`fixed top-0 z-40 w-full h-20 p-4 bg-gradient-to-r from-violet-100 to-white border-b border-violet-200 dark:from-purple-950 dark:to-zinc-900 dark:border-purple-950 md:px-12`,children:(0,G.jsx)(eo,{})}),(0,G.jsx)(`main`,{children:(0,G.jsx)(He,{})})]})}function co(){let e=location.hash;return e?e.startsWith(`#/`)?e.slice(1):e:`/`}var lo=[`/`,`/forgot-password`,`/reset-password`,`/sign-in`,`/sign-up`,`/verify-email`];function uo(){let e=co();return!lo.includes(e)&&{redirect:e}}var fo=`me|email|token|access_token|id_token|refresh_token|code|secret|password|api[-_]?key`,po=String.raw`[^&#\s",<>[\]{}|\\]+`,mo=String.raw`[\w.%+!~*'()-]+(?:@|%40)[\w-]+(?:\.[\w-]+)*\.\w{2,}`;new RegExp(String.raw`([?&](?:${fo})=)${po}`,`gi`),new RegExp(String.raw`([?&](?:${fo})=)${po}|${mo}`,`gi`);var ho=String.raw`[\w-]+-extension`;new RegExp(String.raw`^${ho}://`),new RegExp(String.raw`^\s*at\s.* @ ((?:blob:)?(?:https?|${ho})://\S*)\s*$`);var go=!1;function _o(){(0,W.useEffect)(()=>{go||=!0},[])}function vo(){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ke,{}),(0,G.jsx)(He,{})]})}var yo=ve()({component:vo}),bo=F({getParentRoute:()=>yo,id:`_dashboardLayout`,component:so,beforeLoad:({context:e})=>{let t=e.authentication[m];if(t&&!t.isLoading&&!t.user)throw le({to:`/sign-in`,search:uo()})}}),xo=F({getParentRoute:()=>bo,path:`admin`,component:Ui});F({getParentRoute:()=>xo,path:`/`,beforeLoad:()=>{throw le({to:`/admin/notifications`})}}),F({getParentRoute:()=>xo,path:`notifications`,head:()=>({meta:[{title:`Notifications — Harper Fabric`}]}),component:we(async()=>ne(()=>import(`./notifications-DFbArTfC.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])),`NotificationsAdminIndex`)}),F({getParentRoute:()=>xo,path:`regions`,head:()=>({meta:[{title:`Regions — Harper Fabric`}]}),component:we(async()=>ne(()=>import(`./regions-CtkV0xje.js`),__vite__mapDeps([15,1,3,2,4,5,6,7,8,9,10,11,12,13,16])),`RegionsIndex`)}),F({getParentRoute:()=>xo,path:`api-token`,head:()=>({meta:[{title:`API Token — Harper Fabric`}]}),component:we(async()=>ne(()=>import(`./apiToken-Bke3wvfZ.js`),__vite__mapDeps([17,1,2,3,4,5,6,7])),`ApiTokenIndex`)});function So(){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`header`,{className:`fixed top-0 z-40 w-full h-20 p-4 bg-gradient-to-r from-violet-100 to-white border-b border-violet-200 dark:from-purple-950 dark:to-zinc-900 dark:border-purple-950 md:px-12`,children:(0,G.jsx)(eo,{})}),(0,G.jsxs)(`div`,{className:`pt-20 h-screen grid grid-cols-1 md:grid-cols-2`,children:[(0,G.jsx)(`section`,{"aria-label":`Harper Fabric overview`,className:`items-center justify-center hidden text-white md:flex px-6 fabricSignupTextContainer`,children:(0,G.jsx)(`img`,{className:`object-scale-down max-h-[calc(100vh-80px-40px)] min-h-115`,src:`/fabric-signup-text.png`,alt:`One Runtime: App, database, Cache and Messaging. Distributed by design, free to deploy, and live in minutes. Deploy!`})}),(0,G.jsx)(`main`,{className:`overflow-y-auto px-6 bg-white dark:bg-linear-(--black-dark-gradient) border-l border-border dark:border-none`,children:(0,G.jsx)(`div`,{className:`min-h-full flex items-start justify-center py-12`,children:(0,G.jsx)(He,{})})})]})]})}function Co(){(0,W.useEffect)(()=>{},[])}var wo=[`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 To(e){if(!e||!e.includes(`@`))return null;let t=e.split(`@`).pop()||``;if(!t)return null;for(let e of wo)if(t===e||t.endsWith(`.`+e))return null;return t}var Eo=`utm_`;function Do(e){let t=new URLSearchParams(e),n=Array.from(t.keys()).filter(e=>e.toLowerCase().startsWith(Eo));if(n.length===0)return e;for(let e of n)t.delete(e);let r=t.toString();return r?`?${r}`:``}function Oo(){if(typeof location>`u`||typeof history>`u`)return;let{search:e,pathname:t,hash:n,origin:r}=location,i=Do(e);i!==e&&history.replaceState(history.state,``,`${r}${t}${i}${n}`)}var ko=null;function Ao(){let e=I(),t=pe(),n=Ie(),{redirect:r}=he({strict:!1});return(0,W.useEffect)(()=>{ko||=(async function(){let i=await l().catch(()=>null);if(!i)H.error(`We were not able to verify your sign-in. Please try signing in again.`,{duration:1e4}),await e({to:`/sign-in`});else{u.setUserForEntity(m,i),Oo();let a=Pn(i);To(i.email),await n.invalidateQueries({queryKey:f,refetchType:`none`}),await t.invalidate(),await e({to:r?.startsWith(`/`)?r:a})}ko=null})()},[]),(0,G.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`text-foreground dark:text-white w-lg flex flex-col gap-4`,children:[(0,G.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Checking...`]}),(0,G.jsx)(`div`,{className:`underline flex gap-4`,children:(0,G.jsx)(B,{className:`text-sm opacity-50 text-muted-foreground hover:text-foreground dark:text-inherit dark:hover:text-blue-300`,to:`/sign-in`,children:`Try signing in again`})})]})}var jo=new Map;function Mo(e){if(!e)return``;if(jo.has(e))return jo.get(e);let t=e.replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();if(!t)return jo.set(e,``),``;let n=t.match(/([A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|[0-9]+)/g);if(!n)return jo.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(No).join(` `);return jo.set(e,i),i}function No(e){return/^[A-Z]{2,3}s?$/.test(e)||/^[0-9]+$/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function Po({restartRequired:e}){let t=Oe(),{organization:n,instance:r,cluster:i}=ye({strict:!1}),a=(0,W.useMemo)(()=>{let e=t.pathname.split(`/`).filter(e=>e&&e.length>0),a=[(0,G.jsxs)(B,{to:`/`,children:[(0,G.jsx)(Cr,{"aria-hidden":`true`,className:`size-5 shrink-0`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Home`})]},`home`)];for(let t=0;t<e.length;t++){let o=e[t];if(o===`instance`)continue;let s=`/${e.slice(0,t+1).join(`/`)}`,c=Mo(o);o===`databases`&&e.length===t+3?(c=e[t+2],t+=2):c.startsWith(`Org `)?c=n?.name||`Org`:c.startsWith(`Clu `)?(c=i?.name||`Cluster`,e[t+1]===`instance`&&(s+=`/instances`)):c.startsWith(`Ins `)?c=r?.name?.split(`.`)?.shift()||`Instance`:c===`Apis`&&(c=`APIs`),a.push((0,G.jsx)(`svg`,{fill:`currentColor`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`size-5 shrink-0 text-grey`,children:(0,G.jsx)(`path`,{d:`M5.555 17.776l8-16 .894.448-8 16-.894-.448z`})},a.length+`-dash`),(0,G.jsx)(B,{to:s,className:`text-xs md:text-sm font-medium hover:text-grey truncate max-w-48`,children:c},s))}return a},[t.pathname,i?.name,r?.name,n?.name]);return(0,G.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:[...a,e&&(0,G.jsxs)(Ba,{children:[(0,G.jsx)(Va,{asChild:!0,children:(0,G.jsxs)(`div`,{className:`text-xs italic text-muted-foreground`,children:[`* Restart `,(0,G.jsx)(`span`,{className:`hidden lg:inline-block`,children:`Requested`})]})}),(0,G.jsxs)(Ha,{side:`bottom`,children:[`This `,`Instance`,` is requesting a restart, when convenient, to apply your latest changes.`,(0,G.jsx)(`br`,{}),`You can do this from the Apps or Config pages.`]})]})]})}var q=Vt,Fo=(0,W.createContext)({}),Io=(0,W.createContext)({});function Lo(){let e=(0,W.useContext)(Fo),t=(0,W.useContext)(Io),{getFieldState:n}=Tt(),r=Ht({name:e.name}),i=n(e.name,r);if(!e)throw Error(`useFormField should be used within <FormField>`);let{id:a}=t;return{id:a,name:e.name,formItemId:`${a}-form-item`,formDescriptionId:`${a}-form-item-description`,formMessageId:`${a}-form-item-message`,...i}}function J({...e}){let{error:t,formItemId:n,formDescriptionId:r,formMessageId:i}=Lo();return(0,G.jsx)(st,{"data-slot":`form-control`,id:n,"aria-describedby":t?`${r} ${i}`:`${r}`,"aria-invalid":!!t,...e})}function Y({...e}){return(0,G.jsx)(Fo,{value:{name:e.name},children:(0,G.jsx)(Kt,{...e})})}function X({className:e,...t}){let n=(0,W.useId)();return(0,G.jsx)(Io,{value:{id:n},children:(0,G.jsx)(`div`,{"data-slot":`form-item`,className:N(`grid gap-2`,e),...t})})}function Ro({className:e,...t}){return(0,G.jsx)(At,{"data-slot":`label`,className:N(`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}=Lo();return(0,G.jsx)(Ro,{"data-slot":`form-label`,"data-error":!!n,className:N(`data-[error=true]:text-destructive`,e),htmlFor:r,...t})}function Q({className:e,...t}){let{error:n,formMessageId:r}=Lo(),i=n?String(n?.message):t.children;return i?(0,G.jsx)(`p`,{"data-slot":`form-message`,id:r,className:N(`text-destructive text-sm`,e),...t,children:i}):null}function $({className:e,type:t,...n}){return(0,G.jsx)(`input`,{type:t,"data-slot":`input`,className:N(`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
@@ -9,7 +9,7 @@ import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{_ as n,a as r,b as i
9
9
  focus-visible:ring-1 focus-visible:outline-none focus-visible:ring-purple disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50
10
10
  aria-invalid:focus-visible:ring-[1px] aria-invalid:focus-visible:outline-none md:text-sm dark:aria-invalid:focus-visible:ring-1`,e),...n})}var zo=[`RUNNING`],Bo=[`TERMINATING`,`TERMINATED`,`REMOVED`];function Vo(){return`https://fabric.harper.fast/#/?createCluster=`+encodeURIComponent(JSON.stringify({deploymentDescription:`Self-Hosted`,performanceDescription:`Self Supported and Managed`,instances:[{secure:String(location.protocol===`https:`),fqdn:location.hostname,port:parseInt(location.port,10)}]}))}async function Ho({username:e,password:t,instanceClient:n,entityId:i}){let a={username:e,password:t};u.checkForBasicAuth(i)&&(n.defaults.auth=a,n.defaults.withCredentials=!1);let{data:{message:o}}=await n.post(`/`,{operation:`login`,username:e,password:t});if(!u.checkForBasicAuth(i))try{let e=await r({instanceClient:n});return u.setLastConnectMode(i,`direct`),{message:o,user:e}}catch(e){console.error(`Failed to get user after login, trying basic auth`,e)}try{n.defaults.auth=a,n.defaults.withCredentials=!1;let e=await r({instanceClient:n,auth:a});return u.flagForBasicAuth(i,a),u.setLastConnectMode(i,`direct`),{message:o,user:e}}catch(e){throw n.defaults.auth=void 0,n.defaults.withCredentials=!0,e}}function Uo(){return L({mutationFn:Ho})}function Wo({cluster:e,instance:t,instanceParams:n}){let r=I(),i=pe(),{redirect:a}=he({strict:!1}),{mutate:o,isPending:s}=Uo();return{isPending:s,submitForm:(0,W.useCallback)(async s=>{o({...s,...n},{onSuccess:async({message:n,user:o})=>{if(H.success(n),e?.instances?.length&&!t)for(let t of e.instances)u.setUserForEntity(t,o);let s=m;if(!s)throw Error(`Sign in failed due to missing cluster or instance.`);u.setUserForEntity(s,o),i.invalidate(),await r({to:a?.startsWith(`/`)?a:`/`})}})},[e,t,n,r,a,i,o])}}function Go(e){if(Xo(e)||Zo(e))return`warning`;if(qo(e))return`success`;switch(e){case`STOPPED`:return`destructive`;case`TERMINATING`:case`TERMINATED`:case`FAILED`:case`REMOVED`:case`ERROR`:return`destructive`;default:return`default`}}function Ko(e){switch(e){case`STOPPED`:case`STOPPING`:case`STARTING`:case`RESTARTING`:return!0;default:return!1}}function qo(e){switch(e){case`RUNNING`:case`UPDATED`:return!0;default:return!1}}function Jo(e){switch(e){case`FAILED`:return!0;default:return!1}}function Yo(e){switch(e){case`TERMINATED`:return!0;default:return!1}}function Xo(e){switch(e){case`CLONE_PENDING`:case`PENDING_UPGRADE`:return!0;default:return!1}}function Zo(e){switch(e){case`PROVISIONING`:case`CLONING`:case`CLONE_READY`:case`UPDATING_HDB_NODES`:case`DRAINING`:case`UPDATING`:return!0;default:return!1}}function Qo(e){let t=(e?.instances??[]).filter(e=>!(e.status&&Bo.includes(e.status)));return t.length>0&&t.every(e=>qo(e.status))}function $o(e){return e?.response?.status??e?.status}function es(e){return $o(e)===403}function ts(e){let t=$o(e);return t===400||t===403}function ns(e){return t=>es(t.state.error)?!1:e??!1}function rs(e=3){return(t,n)=>!ts(n)&&t<e}async function is(e){let{data:t}=await M.get(`/Cluster/${e}`);return t}async function as(e,t){let{queryKey:n}=os(t);await e.cancelQueries({queryKey:n,exact:!0}),e.setQueryData(n,e=>e&&{...e,resetPassword:!1})}function os(e,t){return R({queryKey:[e],queryFn:()=>is(e),retry:!1,staleTime:1900,enabled:!!e,refetchInterval:ns(t?t===!0?1e4:t:void 0)})}var ss=k({error:`Please enter a valid email address.`}).toLowerCase().trim(),cs=A().nonempty({error:`Please enter your password.`}),ls=A().nonempty({error:`Please enter a username.`}),us=S({username:ls,password:cs}),ds=S({email:ss,password:cs});function fs({entityId:e,instanceClient:t}){return R({queryKey:[`health`,e],queryFn:async()=>{try{return await t.get(`/health`),!0}catch{return!1}},retry:2,refetchInterval:5e3})}var ps=[`localhost`,`127.0.0.1`],ms=function(e){return e.MixedLoopback=`MixedLoopback`,e.InsecureCookieOutsideChromeAndFirefox=`InsecureCookieOutsideChromeAndFirefox`,e}({});function hs(e,t,n){if(!n||!t||!e)return null;let r=new URL(n).hostname,i=ps.includes(t),a=ps.includes(r);if(i&&a&&r!==t)return`MixedLoopback`;if(!i&&a){let t=e.indexOf(`Chrome`)>=0,n=e.indexOf(`Firefox`)>=0;if(!t&&!n)return`InsecureCookieOutsideChromeAndFirefox`}return null}function gs(){let{clusterId:e,instanceId:t}=z({strict:!1}),{data:n}=V(os(e,!0)),r=(0,W.useMemo)(()=>t&&n&&n?.instances?.find(e=>e.id===t)||void 0,[n,t]),i=(0,W.useMemo)(()=>n?.status&&zo.includes(n.status),[n?.status]),a=`instance`,o=(0,W.useMemo)(()=>n?r?(u.flagForFabricConnect(r.id,!1),p(r)):(u.flagForFabricConnect(n.id,!1),c(n)):null,[n,r]),s=r?.id??n?.id;(0,W.useEffect)(()=>{r?u.setUserForEntity(r,null):n&&u.setUserForEntity(n,null)},[s]);let l=K({operationsUrl:o}),d=(0,W.useMemo)(()=>o?.includes(`localhost`)||o?.includes(`127.0.0.1`),[o]),f=(0,W.useMemo)(()=>hs(navigator.userAgent,location.hostname,o),[o]),{data:m}=V(fs(l)),h=Pt({resolver:Ke(us),defaultValues:{username:``,password:``}}),{control:g,handleSubmit:_}=h,{submitForm:v,isPending:b}=Wo({cluster:n,instance:r,instanceParams:l});if(!t&&n&&!n?.fqdn)return(0,G.jsx)(ce,{to:`../instances`,replace:!0});if(n?.resetPassword){let e=i&&Qo(n);return(0,G.jsx)(ce,{to:`/${n.organizationId}/${n.id}/${e?`finish-setup`:`starting-up`}`,replace:!0})}return(0,G.jsxs)(G.Fragment,{children:[!1,(0,G.jsx)(`div`,{className:y(`min-h-screen`,`items-center justify-center flex`),children:(0,G.jsxs)(`div`,{className:`text-foreground w-xs py-8`,children:[(0,G.jsxs)(`h1`,{className:`text-2xl font-light`,children:[`Sign in to Harper `,`Local`]}),(0,G.jsx)(q,{...h,children:(0,G.jsxs)(`form`,{id:`auth-${a}-signin-form`,name:`auth-${a}-signin-form`,onSubmit:_(v),className:`my-4`,children:[(0,G.jsx)(Y,{control:g,name:`username`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-4`,children:[(0,G.jsx)(Z,{children:`Username`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{autoComplete:`username`,autoFocus:!0,type:`text`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:g,name:`password`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-4`,children:[(0,G.jsx)(Z,{children:`Password`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(P,{disabled:b,type:`submit`,variant:`submit`,className:`w-full my-2`,children:`Sign In`}),m===!1&&(0,G.jsxs)(`div`,{className:`p-4 mt-4 text-sm text-yellow-800 rounded-lg bg-yellow-50 dark:bg-gray-800 dark:text-yellow-300`,role:`alert`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:`Warning!`}),` This `,a,` is not responding to GET`,` `,(0,G.jsxs)(`a`,{href:`${o}health`,className:`underline`,target:`_blank`,children:[o,`health`]}),` `,`checks.`,(0,G.jsxs)(`ol`,{className:`list-decimal ml-8 mt-2`,children:[(0,G.jsx)(`li`,{children:`Is the server running?`}),(0,G.jsxs)(`li`,{children:[`Have you`,` `,(0,G.jsx)(`a`,{href:`https://docs.harperdb.io/docs/developers/security/configuration#cors`,target:`_blank`,rel:`noreferrer`,className:`underline`,children:`enabled CORS`}),` `,`for the operations API?`]}),d&&(0,G.jsxs)(`li`,{children:[`Have you allowed`,` `,(0,G.jsx)(`a`,{href:`https://www.google.com/search?q=How+do+I+enable+local+network+access+in+my+browser%3F`,className:`underline`,target:`_blank`,rel:`noreferrer`,children:`local network access`}),` `,`in your browser?`]})]})]}),f===ms.MixedLoopback&&(0,G.jsxs)(`div`,{className:`p-4 mt-4 text-sm text-yellow-800 rounded-lg bg-yellow-50 dark:bg-gray-800 dark:text-yellow-300`,role:`alert`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:`Warning!`}),` `,`Your login might not work because you're mixing 127.0.0.1 and localhost. Pick one or the other.`]}),f===ms.InsecureCookieOutsideChromeAndFirefox&&(0,G.jsxs)(`div`,{className:`p-4 mt-4 text-sm text-yellow-800 rounded-lg bg-yellow-50 dark:bg-gray-800 dark:text-yellow-300`,role:`alert`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:`Warning!`}),` `,`Your login might not work because your browser doesn't consider localhost to be secure, so it doesn't pass the cookies along. Firefox or Chromium based browsers should pass the cookies properly.`]}),(0,G.jsxs)(`div`,{className:`p-4 mt-4 text-sm rounded-lg bg-purple-950`,role:`alert`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:`Did you know?`}),` `,`You can add this instance to your Harper account to manage it remotely.`,(0,G.jsx)(`div`,{className:`text-center pt-2`,children:(0,G.jsx)(B,{to:Vo(),target:`_blank`,children:(0,G.jsx)(P,{type:`button`,variant:`positive`,children:`Connect to Harper Fabric`})})})]})]})})]})})]})}function _s({overEmail:e}){return(0,G.jsx)(`a`,{href:e?`mailto:support@harperdb.io`:`https://discord.com/channels/1415002037439041710/1415002038286286994`,target:`_blank`,rel:`noreferrer`,className:`underline`,children:`Contact us`})}var vs=`The server is temporarily unavailable. It isn't a problem with the details you entered — please try again in a moment.`,ys=`Something went wrong on our end. It isn't a problem with the details you entered, and trying again may not help.`,bs=`Too many attempts. Please wait a short while before trying again.`,xs=`We didn't get an answer from the server, so we can't tell whether that went through.`,Ss=new Set([503]),Cs=new Set([502,504]),ws=new Set([_.ERR_NETWORK,_.ETIMEDOUT,_.ECONNABORTED]);function Ts(e,t){let n=`${xs} ${t}`,r=e,i=r?.response?.status;if(typeof i==`number`)return i===429?bs:i<500?void 0:Cs.has(i)?n:Ss.has(i)?vs:ys;let a=r?.code;return typeof a==`string`&&ws.has(a)?n:void 0}function Es(e,t){return Ts(e,t)??xi(e).message}var Ds=240,Os=/[\uD800-\uDBFF]$/;function ks(e){return`${e.slice(0,Ds).replace(Os,``).trimEnd()}…`}function As({message:e,suggestSupport:t}){if(!e)return null;let n=e.length>Ds?ks(e):e;return(0,G.jsxs)(`p`,{role:`alert`,"data-slot":`form-message`,className:`text-destructive text-sm break-words`,children:[n,(t||e===`Something went wrong on our end. It isn't a problem with the details you entered, and trying again may not help.`)&&(0,G.jsxs)(G.Fragment,{children:[` `,(0,G.jsx)(_s,{overEmail:!0}),` if this keeps happening.`]})]})}function js(){return!1}var Ms;function Ns(){return Ms??=Ls().catch(e=>{throw Ms=void 0,e}),Ms}function Ps(){js()&&Ns().catch(()=>{})}async function Fs(e){}var Is=8e3;function Ls(){return new Promise((e,t)=>{if(window.grecaptcha?.enterprise){e(window.grecaptcha.enterprise);return}let n=document.createElement(`script`);n.src=`https://www.google.com/recaptcha/enterprise.js?render=undefined`,n.async=!0,n.defer=!0;let r=e=>{clearTimeout(i),n.remove(),t(Error(e))},i=setTimeout(()=>r(`reCAPTCHA script load timed out`),Is);n.addEventListener(`load`,()=>{clearTimeout(i),window.grecaptcha?.enterprise?e(window.grecaptcha.enterprise):r(`reCAPTCHA script loaded without exposing its API`)}),n.addEventListener(`error`,()=>r(`reCAPTCHA script failed to load`)),document.head.appendChild(n)})}var Rs=`verification failed`,zs=[`error`,`message`,`title`,`detail`];function Bs(e){let t=e?.response;if(t?.status!==403)return!1;let n=t.data;return typeof n==`string`?Vs(n):zs.some(e=>Vs(n?.[e]))}function Vs(e){return typeof e==`string`&&e.toLowerCase().includes(Rs)}var Hs=`Verification failed. Please try again.`,Us=`We could not run the verification check. Disable any ad blocker for this page, then reload and try again.`,Ws=2;function Gs(e){(0,W.useEffect)(()=>{Ps()},[]);let t=(0,W.useRef)(!1),[n,r]=(0,W.useState)(!1),i=(0,W.useCallback)(async()=>{r(!0);try{let n=await Fs(e);return t.current=js()&&!n,n}finally{r(!1)}},[e]),a=(0,W.useRef)(0),[o,s]=(0,W.useState)(!1);return{getToken:i,describeCaptchaError:(0,W.useCallback)(e=>{if(!Bs(e)){a.current=0,s(!1);return}return a.current+=1,s(a.current>=Ws),t.current?Us:Hs},[]),minting:n,supportSuggested:o}}async function Ks({email:e,captchaToken:t}){let{data:n}=await M.post(`/ForgotPassword/`,{email:e,...t?{captchaToken:t}:{}});if(n)return n;throw Error(`Something went wrong`)}function qs(){return L({mutationFn:e=>Ks(e),meta:{skipGlobalErrorToast:!0}})}var Js=`Check your inbox before requesting another link.`,Ys=S({email:ss});function Xs(){let e=I(),{me:t}=he({strict:!1}),n=Pt({resolver:Ke(Ys),defaultValues:{email:t||``}}),r=n.watch(`email`),{setFocus:i,control:a,handleSubmit:o}=n,[s,c]=(0,W.useState)(),l=(0,W.useCallback)(()=>c(void 0),[]);(0,W.useEffect)(()=>{i(`email`)},[i]);let{mutate:u,isPending:d}=qs(),f=Gs(`forgot_password`),p=async t=>{c(void 0);let n=await f.getToken();u({...t,captchaToken:n},{onSuccess:t=>{H.success(`Success`,{description:`${t}`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),e({to:`/sign-in`,search:{me:r}})},onError:e=>{let t=f.describeCaptchaError(e);if(t){c(t);return}let n=Ts(e,Js);if(n){console.error(e),c(n);return}Si(e)}})};return(0,G.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light`,children:`Enter your account email`}),(0,G.jsx)(`p`,{className:`text-sm pt-1`,children:`If a matching account exists, we'll send you a password reset link.`}),(0,G.jsx)(q,{...n,children:(0,G.jsxs)(`form`,{id:`auth-forgot-password-form`,name:`auth-forgot-password-form`,onSubmit:o(p,l),className:`my-4`,children:[(0,G.jsx)(Y,{control:a,name:`email`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-2`,children:[(0,G.jsx)(Z,{children:`Email`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{disabled:d,type:`email`,className:`dark:bg-black dark:border-black`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(As,{message:s,suggestSupport:f.supportSuggested}),(0,G.jsx)(P,{type:`submit`,variant:`submit`,disabled:d||f.minting,className:`w-full my-2`,children:`Send Password Reset Email`})]})}),(0,G.jsxs)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:[(0,G.jsx)(B,{className:`text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:r},children:`Sign in to your account`}),(0,G.jsx)(B,{className:`text-sm hover:text-blue-300`,to:`/sign-up`,search:{me:r},children:`Sign up for free`})]})]})}var Zs=async({token:e,password:t})=>{let{data:n}=await M.put(`/ResetPassword/`,{token:e,newPassword:t});return n};function Qs(){return L({mutationFn:e=>Zs(e)})}var $s=S({password:cs.min(8,{error:`Password must be at least 8 characters long.`}).max(50,{error:`Password cannot be longer than 50 characters.`}),confirmPassword:A()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});function ec(){let{token:e}=he({strict:!1}),t=I();(0,W.useEffect)(()=>{e||t({to:`/sign-in`})},[e,t]);let n=Pt({resolver:Ke($s),defaultValues:{password:``,confirmPassword:``}}),{setFocus:r,control:i,handleSubmit:a}=n;(0,W.useEffect)(()=>{r(`password`)},[r]);let{mutate:o,isPending:s}=Qs(),c=(0,W.useCallback)(async n=>{o({token:e,password:n.password},{onSuccess:()=>{H.success(`Success`,{description:`Your password has been reset successfully.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),t({to:`/sign-in`})}})},[t,o,e]);return(0,G.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light`,children:`Reset Password`}),(0,G.jsx)(q,{...n,children:(0,G.jsxs)(`form`,{id:`auth-reset-password-form`,name:`auth-reset-password-form`,className:`my-4`,onSubmit:a(c),children:[(0,G.jsx)(Y,{control:i,name:`password`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-2`,children:[(0,G.jsx)(Z,{children:`New Password`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{disabled:s,type:`password`,autoComplete:`new-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:i,name:`confirmPassword`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-2`,children:[(0,G.jsx)(Z,{children:`Confirm Password`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{disabled:s,type:`password`,autoComplete:`new-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(P,{variant:`submit`,type:`submit`,disabled:s,className:`w-full my-2`,children:`Submit New Password`})]})})]})}function tc(){return(0,G.jsx)(Ji,{className:`pointer-events-none absolute -top-2 right-3 z-10 rounded-full border-primary bg-primary px-1.5 py-0 text-[10px] font-medium text-white shadow-sm`,children:`Last used`})}function nc({text:e,disabled:t,onClick:n,lastUsed:r=!1}){let i=(0,G.jsxs)(`a`,{href:`/oauth/github/login?redirect=%2F%23%2Fcheck-oauth`,onClick:n,"aria-disabled":t||void 0,className:y(`github-signin-btn`,t&&`opacity-50 cursor-default`),children:[(0,G.jsx)(`img`,{src:`/github/GitHub_Invertocat_White.svg`,alt:``,className:`github-icon`}),e]});return r?(0,G.jsxs)(`div`,{className:`relative flex flex-col`,children:[i,(0,G.jsx)(tc,{})]}):i}function rc({text:e,disabled:t,onClick:n,lastUsed:r=!1}){let i=(0,G.jsxs)(`a`,{href:`/oauth/google/login?redirect=%2F%23%2Fcheck-oauth`,onClick:n,"aria-disabled":t||void 0,className:y(`gsi-material-button`,t&&`opacity-50 cursor-default`),children:[(0,G.jsx)(`div`,{"aria-hidden":`true`,className:`gsi-material-button-state`}),(0,G.jsxs)(`div`,{className:`gsi-material-button-content-wrapper`,children:[(0,G.jsx)(`div`,{"aria-hidden":`true`,className:`gsi-material-button-icon`,children:(0,G.jsxs)(`svg`,{version:`1.1`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 48 48`,xmlnsXlink:`http://www.w3.org/1999/xlink`,className:`block`,children:[(0,G.jsx)(`path`,{fill:`#EA4335`,d:`M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z`}),(0,G.jsx)(`path`,{fill:`#4285F4`,d:`M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z`}),(0,G.jsx)(`path`,{fill:`#FBBC05`,d:`M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z`}),(0,G.jsx)(`path`,{fill:`#34A853`,d:`M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z`}),(0,G.jsx)(`path`,{fill:`none`,d:`M0 0h48v48H0z`})]})}),(0,G.jsx)(`span`,{className:`gsi-material-button-contents`,children:e}),(0,G.jsx)(`span`,{className:`hidden`,children:e})]})]});return r?(0,G.jsxs)(`div`,{className:`relative flex flex-col`,children:[i,(0,G.jsx)(tc,{})]}):i}function ic(e){if(!v(e)||e.response?.status!==403)return!1;let t=e.response.data,n=typeof t==`string`?t:_n(t?.error)??_n(t?.message)??_n(t?.title)??``;return/verif/i.test(n)}var ac=async({email:e})=>{let{data:t}=await M.post(`/ResendVerificationEmail/`,{email:e});return t};function oc(){return L({mutationFn:e=>ac(e)})}function sc(){let e=I(),t=Ie(),n=pe(),{redirect:r}=he({strict:!1}),[i,a]=(0,W.useState)(),{mutate:o,isPending:s}=cc(),{mutate:c}=oc();return{clearSubmitError:(0,W.useCallback)(()=>a(void 0),[]),isPending:s,submitError:i,submitForm:(0,W.useCallback)(i=>{a(void 0),o(i,{onSuccess:async i=>{u.setUserForEntity(m,i),Oo();let a=Pn(i);To(i.email),await t.invalidateQueries({queryKey:f,refetchType:`none`}),n.invalidate(),await e({to:r?.startsWith(`/`)?r:a})},onError:t=>{if(ic(t)){c({email:i.email},{onSuccess:()=>H.info(`Verify your email to finish signing in`,{description:`We sent a new verification link to ${i.email}.`})}),e({to:`/verifying?email=`+encodeURIComponent(i.email)});return}a(Es(t,`Try signing in again.`))}})},[e,t,r,c,n,o])}}function cc(){return L({mutationFn:e=>lc(e),meta:{skipGlobalErrorToast:!0},onError:e=>{ic(e)||console.error(e)}})}async function lc({email:e,password:t}){let{data:n}=await M.post(`/Login/`,{email:e,password:t});if(n)return n;throw Error(`Something went wrong`)}function uc(){let[e,t]=xn(vn.RememberSignInMethod,!0),[n,r]=xn(vn.LastUsedSignInMethod,null),i=(0,W.useCallback)(t=>{e&&(bn(vn.LastUsedSignInMethod,t),r(t))},[e,r]),a=(0,W.useCallback)(()=>{r(null),t(!1)},[r,t]),o=(0,W.useCallback)(()=>{t(!0)},[t]);return{lastUsed:e?n:null,remember:e,recordMethod:i,disable:a,enable:o}}var dc=`mx-auto mt-3 block text-xs text-muted-foreground underline hover:text-foreground dark:text-inherit dark:hover:text-blue-300`;function fc(){let{me:e}=he({strict:!1}),t=Pt({resolver:Ke(ds),defaultValues:{email:e||``,password:``}}),{handleSubmit:n,control:r}=t,i=t.watch(`email`),{submitForm:a,isPending:o,submitError:s,clearSubmitError:c}=sc(),{lastUsed:l,remember:u,recordMethod:d,disable:f,enable:p}=uc();return(0,G.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light text-center`,children:`Sign in to Harper Fabric`}),(0,G.jsx)(q,{...t,children:(0,G.jsxs)(`form`,{id:`auth-signin-form`,name:`auth-signin-form`,onSubmit:n(a,c),className:`my-4`,children:[(0,G.jsx)(Y,{control:r,name:`email`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-4`,children:[(0,G.jsx)(Z,{children:`Email`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`email`,autoFocus:!0,autoComplete:`email`,className:`dark:bg-black dark:border-black`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:r,name:`password`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-4`,children:[(0,G.jsx)(Z,{children:`Password`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,autoComplete:`current-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(As,{message:s}),(0,G.jsx)(P,{type:`submit`,variant:`submit`,className:`w-full my-2`,disabled:o,children:`Sign In`}),(0,G.jsxs)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:[(0,G.jsx)(B,{className:`text-sm text-muted-foreground hover:text-foreground dark:text-inherit dark:hover:text-blue-300`,to:`/sign-up`,search:{me:i},children:`Sign up for free`}),(0,G.jsx)(B,{className:`text-sm text-muted-foreground hover:text-foreground dark:text-inherit dark:hover:text-blue-300`,to:`/forgot-password`,search:{me:i},children:`Forgot password?`})]})]})}),(0,G.jsx)(`hr`,{"aria-hidden":`true`,className:`border-border dark:border-gray-600 my-6`}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(rc,{text:`Sign in with Google`,lastUsed:l===`google`,onClick:()=>d(`google`)}),(0,G.jsx)(nc,{text:`Sign in with GitHub`,lastUsed:l===`github`,onClick:()=>d(`github`)})]}),u?l&&(0,G.jsx)(`button`,{type:`button`,onClick:f,className:dc,children:`On a shared device? Forget my sign-in method.`}):(0,G.jsx)(`button`,{type:`button`,onClick:p,className:dc,children:`Remember my last sign-in method on this device.`})]})}var pc=/^[a-zA-ZàáâäãåąčćęèéêëėįìíîïłńòóôöõøùúûüųūÿýżźñçčšžæÀÁÂÄÃÅĄĆČĖĘÈÉÊËÌÍÎÏĮŁŃÒÓÔÖÕØÙÚÛÜŲŪŸÝŻŹÑßÇŒÆČŠŽ∂ð ,'-]+$/u;async function mc({captchaToken:e,...t}){let{data:n}=await M.post(`/User/`,{...t,...e?{captchaToken:e}:{}});if(n)return n;throw Error(`Something went wrong`)}function hc(){return L({mutationFn:e=>mc(e),meta:{skipGlobalErrorToast:!0},onError:e=>console.error(e)})}var gc=`Check your email for a verification link before signing up again.`,_c=S({email:ss.max(80,{error:`Email cannot be longer than 80 characters.`}),firstname:A().trim().min(2,{error:`Please enter your first name.`}).regex(pc,{error:`First name can only contain letters, spaces, and hyphens.`}).max(40,{error:`First name cannot be longer than 40 characters.`}),lastname:A().trim().min(2,{error:`Please enter your last name.`}).regex(pc,{error:`Last name can only contain letters, spaces, and hyphens.`}).max(80,{error:`Last name cannot be longer than 80 characters.`}),password:cs.min(8,{error:`Password must be at least 8 characters long.`}),confirmPassword:A(),acceptTerms:D().refine(e=>e===!0,{message:`You must accept the Privacy Policy and Terms of Service.`})}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});function vc(){let e=I(),{email:t,me:n}=he({strict:!1}),[r,i]=(0,W.useState)(!1),a=Pt({resolver:Ke(_c),defaultValues:{firstname:``,lastname:``,email:n||t||``,password:``,confirmPassword:``,acceptTerms:!1}}),o=a.watch(`email`),s=a.watch(`acceptTerms`),{setFocus:c,setError:l,clearErrors:u,control:d,handleSubmit:f,formState:p}=a,m=p.errors.root?.message;(0,W.useEffect)(()=>{c(`firstname`)},[c]);let{mutate:h,isPending:g}=hc(),_=Gs(`signup`),v=(0,W.useCallback)(async t=>{let{confirmPassword:n,acceptTerms:r,...i}=t;u(`root`);let a=await _.getToken();h({...i,captchaToken:a},{onSuccess:()=>{To(i.email),Oo(),e({to:`/verifying?email=`+encodeURIComponent(i.email)})},onError:e=>{l(`root`,{type:`server`,message:_.describeCaptchaError(e)??Es(e,gc)})}})},[u,e,l,h,_]),y=(0,W.useCallback)(e=>{if(!s)return i(!0),setTimeout(()=>i(!1),1e3),e.preventDefault(),!1},[s]),b=(0,G.jsx)(Y,{control:d,name:`acceptTerms`,render:({field:e})=>(0,G.jsxs)(X,{className:`flex flex-row items-start space-x-3 space-y-0 p-1 transition-colors duration-300 ${r?`bg-red-500/20 animate-pulse rounded`:``}`,children:[(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`checkbox`,className:`size-4 rounded border-gray-300 bg-white text-purple-600 focus:ring-purple-500`,checked:e.value,onChange:e.onChange})}),(0,G.jsxs)(`div`,{className:`space-y-1 leading-none`,children:[(0,G.jsxs)(Z,{className:`text-xs font-normal`,children:[`I accept the`,` `,(0,G.jsx)(`a`,{href:`https://www.harper.fast/resources/privacy-policy`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,"aria-label":`Privacy Policy (opens in new tab)`,children:`Privacy Policy`}),` `,`and`,` `,(0,G.jsx)(`a`,{href:`https://www.harper.fast/resources/paas-terms-of-service`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,"aria-label":`Terms of Service (opens in new tab)`,children:`Terms of Service`})]}),(0,G.jsx)(Q,{})]})]})});return(0,G.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light text-center`,children:`Sign up for Harper Fabric`}),(0,G.jsxs)(q,{...a,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 my-6`,children:[b,(0,G.jsx)(rc,{text:`Sign up with Google`,disabled:!s,onClick:y}),(0,G.jsx)(nc,{text:`Sign up with GitHub`,disabled:!s,onClick:y})]}),(0,G.jsx)(`hr`,{className:`border-gray-600`}),(0,G.jsxs)(`form`,{id:`auth-signup-form`,name:`auth-signup-form`,onSubmit:f(v),className:`grid gap-4 my-4`,children:[(0,G.jsx)(Y,{control:d,name:`firstname`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`First Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,className:`dark:bg-black dark:border-black`,autoCapitalize:`words`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:d,name:`lastname`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Last Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,className:`dark:bg-black dark:border-black`,autoCapitalize:`words`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:d,name:`email`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Email`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`email`,readOnly:!!t,disabled:!!t,className:`dark:bg-black dark:border-black`,autoComplete:`email`,autoCapitalize:`none`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:d,name:`password`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Password`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,autoComplete:`new-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:d,name:`confirmPassword`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Confirm Password`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,autoComplete:`new-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,G.jsx)(Q,{})]})}),b,(0,G.jsx)(As,{message:m,suggestSupport:_.supportSuggested}),(0,G.jsx)(P,{type:`submit`,variant:`submit`,disabled:g||_.minting,className:`w-full my-4`,children:`Sign Up For Free`})]})]}),(0,G.jsx)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:(0,G.jsx)(B,{className:`m-auto text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:o},children:`Already have an account? Sign in instead.`})})]})}var yc=async e=>{let{data:t}=await M.put(`/VerifyEmail/`,{token:e.toString()});return t};function bc(){return L({mutationFn:e=>yc(e)})}var xc=S({email:ss});function Sc(){let e=I(),{mutate:t,isPending:n}=oc(),r=Pt({resolver:Ke(xc),defaultValues:{email:``}}),i=r.watch(`email`),{setFocus:a,control:o,handleSubmit:s}=r;(0,W.useEffect)(()=>{a(`email`)},[a]);let c=(0,W.useCallback)(async n=>{t(n,{onSuccess:t=>{H.success(`Success`,{description:`${t}`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),e({to:`/sign-in`,search:{me:i}})}})},[i,e,t]);return(0,G.jsxs)(q,{...r,children:[(0,G.jsx)(`p`,{className:`text-sm py-2`,children:`Please Enter an Email`}),(0,G.jsxs)(`form`,{id:`auth-verify-email-form`,name:`auth-verify-email-form`,onSubmit:s(c),className:`my-4`,children:[(0,G.jsx)(Y,{control:o,name:`email`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-2`,children:[(0,G.jsx)(Z,{children:`Email`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{disabled:n,type:`email`,className:`dark:bg-black dark:border-black`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(P,{type:`submit`,variant:`submit`,disabled:n,className:`w-full my-2`,children:`Send Verification Email`})]})]})}function Cc(){let{token:e}=he({strict:!1}),t=I(),{mutate:n,isPending:r}=bc(),i=(0,W.useCallback)(e=>{n(e,{onSuccess:()=>{H.success(`Success`,{description:`Email verified successfully`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),t({to:`/sign-in`})}})},[n,t]);return(0,W.useEffect)(()=>{e&&i(e)},[i,e]),(0,G.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,G.jsx)(`h1`,{className:`text-3xl font-light`,children:`Verify Email`}),r?(0,G.jsx)(`p`,{className:`text-sm pt-1`,children:`Verifying email...`}):(0,G.jsx)(Sc,{})]})}function wc(){let{email:e}=he({strict:!1}),{mutate:t,isPending:n}=oc(),r=(0,W.useCallback)(n=>(n.preventDefault(),e&&t({email:e},{onSuccess:e=>{H.success(`Code Sent`,{description:`${e}`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}})}}),!1),[e,t]);return(0,G.jsxs)(`div`,{className:`text-foreground dark:text-white w-lg flex flex-col gap-4`,children:[(0,G.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Check your email!`]}),(0,G.jsxs)(`p`,{children:[`Your account has been created! You should receive an email with a link to `,(0,G.jsx)(`strong`,{children:`[Verify My Email]`}),`!`]}),(0,G.jsxs)(`p`,{children:[`From: `,(0,G.jsx)(`strong`,{children:`harper@notifications.harperfabric.com`})]}),(0,G.jsxs)(`p`,{children:[`To: `,(0,G.jsx)(`strong`,{children:e||`your email`})]}),(0,G.jsx)(`p`,{children:`Can you click it? Then we can carry on to more fun things!`}),(0,G.jsxs)(`div`,{className:`underline flex gap-4`,children:[(0,G.jsx)(B,{className:`text-sm text-muted-foreground hover:text-foreground dark:text-inherit dark:hover:text-blue-300`,to:`/sign-in`,search:{me:e},children:`I did it, let me sign in!`}),(0,G.jsx)(B,{className:`text-sm opacity-50 text-muted-foreground hover:text-foreground dark:text-inherit dark:hover:text-blue-300`,to:void 0,onClick:r,disabled:n,children:`Send me another code, please.`})]})]})}var Tc=F({getParentRoute:()=>yo,id:`_authLayout`,component:So}),Ec=F({getParentRoute:()=>Tc,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:fc,beforeLoad:({context:e,location:t})=>{let n=e.authentication[m]?.user;if(n){let e=t?.search,r=Pn(n);throw le({to:e?.redirect?.startsWith(`/`)?e.redirect:r})}}}),Dc=F({getParentRoute:()=>yo,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:gs,beforeLoad:({context:e,location:t})=>{if(e.authentication.OverallAppSignIn?.user){let e=t?.search;throw le({to:e?.redirect?.startsWith(`/`)?e.redirect:`/`})}}}),Oc=F({getParentRoute:()=>Tc,path:`sign-up`,head:()=>({meta:[{title:`Sign Up — Harper Fabric`}]}),component:vc}),kc=F({getParentRoute:()=>Tc,path:`forgot-password`,head:()=>({meta:[{title:`Forgot Password — Harper Fabric`}]}),component:Xs}),Ac=F({getParentRoute:()=>Tc,path:`verify-email`,head:()=>({meta:[{title:`Verify Email — Harper Fabric`}]}),component:Cc}),jc=F({getParentRoute:()=>Tc,path:`verifying`,head:()=>({meta:[{title:`Check Your Email — Harper Fabric`}]}),component:wc}),Mc=F({getParentRoute:()=>Tc,path:`check-oauth`,head:()=>({meta:[{title:`Signing In — Harper Fabric`}]}),component:Ao}),Nc=F({getParentRoute:()=>Tc,path:`reset-password`,head:()=>({meta:[{title:`Reset Password — Harper Fabric`}]}),component:ec});Tc.addChildren([Ec,Oc,Mc,kc,Ac,jc,Nc]);var Pc=[Dc];function Fc({children:e}){return(0,G.jsx)(`nav`,{className:`fixed top-20 w-full h-12 z-39 py-2 px-4 md:px-12 bg-violet-50 border-b border-violet-100 dark:bg-grey-700 dark:border-none`,children:(0,G.jsxs)(`div`,{className:`flex items-center h-full space-x-2`,children:[(0,G.jsx)(Po,{}),e]})})}function Ic({typeOfThingBeingDeleted:e,nameOfThingBeingDeleted:t,isModalOpen:n,hideDataLossWarning:r,setIsModalOpen:i,deletionConfirmed:a,deletionPending:o,trigger:s,presentParticiple:c=`Deleting`,transitiveVerb:l=`Delete`}){return(0,G.jsxs)(fn,{open:n,onOpenChange:i,children:[s&&(0,G.jsx)(dn,{asChild:!0,children:s}),(0,G.jsxs)(cn,{className:`sm:max-w-[750px]`,children:[(0,G.jsxs)(rn,{children:[(0,G.jsxs)(ln,{children:[`Are you sure you want to `,l.toLowerCase(),` this `,e,`?`]}),(0,G.jsx)(un,{children:`This action cannot be undone.`})]}),!r&&(0,G.jsxs)(`div`,{className:`p-3 my-5 text-white rounded-md bg-amber-600`,children:[(0,G.jsxs)(`p`,{className:`flex space-x-1 font-semibold align-baseline`,children:[(0,G.jsx)(pi,{className:`inline-block size-5`}),` `,(0,G.jsx)(`span`,{children:`Warning`})]}),(0,G.jsxs)(`p`,{className:`pt-2 text-base`,children:[`By `,c.toLowerCase(),` `,e,` `,(0,G.jsx)(`span`,{className:`font-semibold`,children:t}),` `,`you will lose the data stored in it permanently.`]})]}),(0,G.jsx)(on,{children:(0,G.jsxs)(`div`,{className:`flex justify-center space-x-5`,children:[(0,G.jsxs)(P,{type:`button`,onClick:()=>i(!1),children:[(0,G.jsx)(Ln,{}),` Cancel`]}),(0,G.jsxs)(P,{variant:`destructive`,onClick:a,disabled:o,children:[(0,G.jsx)(fi,{}),` `,l]})]})})]})]})}function Lc({...e}){return(0,G.jsx)(it,{"data-slot":`context-menu`,...e})}function Rc({...e}){return(0,G.jsx)(Ct,{"data-slot":`context-menu-trigger`,...e})}function zc({className:e,...t}){return(0,G.jsx)(St,{children:(0,G.jsx)(gt,{"data-slot":`context-menu-content`,className:N(`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-context-menu-content-available-height) min-w-[8rem] origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border p-1 shadow-md`,e),...t})})}function Bc({className:e,inset:t,variant:n=`default`,...r}){return(0,G.jsx)(nn,{"data-slot":`context-menu-item`,"data-inset":t,"data-variant":n,className:N(`focus:bg-accent focus:text-grey dark:focus:bg-white/15 dark:focus:text-white`,`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 Vc({className:e,inset:t,...n}){return(0,G.jsx)(Ye,{"data-slot":`context-menu-label`,"data-inset":t,className:N(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function Hc({className:e,...t}){return(0,G.jsx)(xt,{"data-slot":`context-menu-separator`,className:N(`bg-border -mx-1 my-1 h-px`,e),...t})}function Uc({className:e,...t}){return(0,G.jsx)(`span`,{"data-slot":`context-menu-shortcut`,className:N(`text-muted-foreground ml-auto text-xs tracking-widest`,e),...t})}var Wc={dropdown:{Item:Di,Label:ki,Separator:Ai},context:{Item:Bc,Label:Vc,Separator:Hc}};function Gc(e,t){let{Item:n,Label:r,Separator:i}=Wc[t];return e.map(e=>{if(e.type===`separator`)return(0,G.jsx)(i,{},e.key);if(e.type===`label`)return(0,G.jsx)(r,{className:e.className,children:e.label},e.key);let t=(0,G.jsxs)(n,{className:e.className,onClick:e.onClick,disabled:e.disabled,variant:e.variant,children:[e.icon,e.label]});return e.to?(0,G.jsx)(B,{to:e.to,disabled:e.disabled,children:t},e.key):(0,G.jsx)(W.Fragment,{children:t},e.key)})}function Kc({items:e,children:t}){return e.length?(0,G.jsxs)(Lc,{children:[(0,G.jsx)(Rc,{asChild:!0,children:t}),(0,G.jsx)(zc,{children:Gc(e,`context`)})]}):(0,G.jsx)(G.Fragment,{children:t})}function qc(e,t){let n=Yc(e),r=Yc(t);return!n||!r?!1:Qc(r,n)>=0}function Jc(e,t){let n=Yc(e),r=Yc(t);return!n&&!r?0:n?r?Qc(n,r):1:-1}function Yc(e){if(typeof e!=`string`)return null;let[t]=e.split(`+`,1).concat(``),n=t.indexOf(`-`),r=n===-1?t:t.slice(0,n),i=n===-1?``:t.slice(n+1),a=r.split(`.`);if(a.length===0)return null;let o=Xc(a[0]),s=Xc(a[1]??`0`),c=Xc(a[2]??`0`);return o==null||s==null||c==null?null:{major:o,minor:s,patch:c,pre:i?i.split(`.`).map(e=>Zc(e)?Number(e):e):[]}}function Xc(e){return e==null||e===``||!/^\d+$/.test(e)?null:Number(e)}function Zc(e){return/^\d+$/.test(e)}function Qc(e,t){if(e.major!==t.major)return e.major<t.major?-1:1;if(e.minor!==t.minor)return e.minor<t.minor?-1:1;if(e.patch!==t.patch)return e.patch<t.patch?-1:1;let n=e.pre.length>0,r=t.pre.length>0;if(!n&&!r)return 0;if(!n&&r)return 1;if(n&&!r)return-1;let i=Math.min(e.pre.length,t.pre.length);for(let n=0;n<i;n++){let r=e.pre[n],i=t.pre[n],a=typeof r==`number`,o=typeof i==`number`;if(a&&o){if(r!==i)return r<i?-1:1;continue}if(a&&!o)return-1;if(!a&&o)return 1;if(r!==i)return String(r)<String(i)?-1:1}return e.pre.length===t.pre.length?0:e.pre.length<t.pre.length?-1:1}var $c=new Set([`add_component`,`cleanup_orphan_blobs`,`clear_status`,`delete_audit_logs_before`,`delete_files_before`,`delete_transaction_logs_before`,`deploy_component`,`drop_component`,`drop_custom_function`,`drop_custom_function_project`,`get_backup`,`get_status`,`install_node_modules`,`package_component`,`read_transaction_log`,`restart_service`,`search_jobs_by_start_date`,`set_component_file`,`set_configuration`,`set_custom_function`,`set_status`,`delete_records_before`,`registration_info`]);function el(e){return $c.has(e)}function tl(e){let t=bl.get(e);return!!t?.aliasOf||!!t?.nonDelegable||!!t?.outOfGate||el(e)}var nl=`5.1.0-alpha.1`,rl=`5.2.0-alpha.1`,il=`5.3.0-alpha.1`,al=`Data`,ol=`Schema`,sl=`Users & Roles`,cl=`Components & Deployments`,ll=`Clustering & Replication`,ul=`Jobs`,dl=`Logs & Analytics`,fl=`System`,pl=`Managed Backups`,ml=`Secrets & Environment`,hl=`Agent`,gl=[al,ol,sl,cl,ll,ul,dl,fl,pl,ml,hl],_l=[{name:`search`,su:!1,category:al},{name:`search_by_conditions`,su:!1,category:al},{name:`search_by_hash`,su:!1,category:al},{name:`search_by_id`,su:!1,category:al,aliasOf:`search_by_hash`},{name:`search_by_value`,su:!1,category:al},{name:`sql`,su:!1,category:al,outOfGate:!0,caveat:`SQL is authorized against table permissions, not this list — listing or omitting it does not restrict SQL statements.`},{name:`insert`,su:!1,category:al},{name:`update`,su:!1,category:al},{name:`upsert`,su:!1,category:al},{name:`put`,su:!1,category:al,addedIn:il},{name:`delete`,su:!1,category:al},{name:`delete_records_before`,su:!0,category:al},{name:`csv_data_load`,su:!1,category:al},{name:`csv_file_load`,su:!1,category:al},{name:`csv_url_load`,su:!1,category:al},{name:`import_from_s3`,su:!1,category:al},{name:`export_local`,su:!0,category:al},{name:`export_to_s3`,su:!0,category:al},{name:`describe_all`,su:!1,category:ol},{name:`describe_database`,su:!1,category:ol,aliasOf:`describe_schema`},{name:`describe_schema`,su:!1,category:ol},{name:`describe_table`,su:!1,category:ol},{name:`create_database`,su:!0,category:ol},{name:`create_schema`,su:!0,category:ol,aliasOf:`create_database`},{name:`drop_database`,su:!0,category:ol},{name:`drop_schema`,su:!0,category:ol,aliasOf:`drop_database`},{name:`create_table`,su:!0,category:ol},{name:`drop_table`,su:!0,category:ol},{name:`create_attribute`,su:!1,category:ol},{name:`drop_attribute`,su:!0,category:ol},{name:`cleanup_orphan_blobs`,su:!0,category:ol},{name:`user_info`,su:!1,category:sl},{name:`list_users`,su:!0,category:sl},{name:`add_user`,su:!0,category:sl},{name:`alter_user`,su:!0,category:sl},{name:`drop_user`,su:!0,category:sl},{name:`list_roles`,su:!0,category:sl},{name:`add_role`,su:!0,category:sl},{name:`alter_role`,su:!0,category:sl},{name:`drop_role`,su:!0,category:sl},{name:`refresh_operation_token`,su:!1,category:sl},{name:`get_components`,su:!0,category:cl},{name:`get_component_file`,su:!0,category:cl},{name:`set_component_file`,su:!0,category:cl},{name:`add_component`,su:!0,category:cl},{name:`drop_component`,su:!0,category:cl},{name:`deploy_component`,su:!0,category:cl},{name:`package_component`,su:!0,category:cl},{name:`install_node_modules`,su:!0,category:cl},{name:`audit_node_modules`,su:!0,category:cl},{name:`custom_functions_status`,su:!0,category:cl},{name:`get_custom_functions`,su:!0,category:cl},{name:`get_custom_function`,su:!0,category:cl},{name:`set_custom_function`,su:!0,category:cl},{name:`drop_custom_function`,su:!0,category:cl},{name:`add_custom_function_project`,su:!0,category:cl,aliasOf:`add_component`},{name:`deploy_custom_function_project`,su:!0,category:cl,aliasOf:`deploy_component`},{name:`package_custom_function_project`,su:!0,category:cl,aliasOf:`package_component`},{name:`drop_custom_function_project`,su:!0,category:cl,aliasOf:`drop_component`},{name:`list_deployments`,su:!0,category:cl,addedIn:nl},{name:`get_deployment`,su:!0,category:cl,addedIn:nl},{name:`get_deployment_payload`,su:!0,category:cl,addedIn:nl,nonDelegable:!0},{name:`delete_deployment_payload`,su:!0,category:cl,addedIn:nl},{name:`add_node`,su:!0,category:ll},{name:`update_node`,su:!0,category:ll},{name:`set_node_replication`,su:!0,category:ll},{name:`purge_stream`,su:!0,category:ll},{name:`catchup`,su:!0,category:ll},{name:`get_job`,su:!1,category:ul},{name:`search_jobs_by_start_date`,su:!0,category:ul},{name:`update_job`,su:!0,category:ul},{name:`delete_job`,su:!0,category:ul},{name:`read_log`,su:!0,category:dl},{name:`read_audit_log`,su:!0,category:dl},{name:`read_transaction_log`,su:!0,category:dl},{name:`delete_files_before`,su:!0,category:dl},{name:`delete_audit_logs_before`,su:!0,category:dl},{name:`delete_transaction_logs_before`,su:!0,category:dl},{name:`get_analytics`,su:!1,category:dl},{name:`list_metrics`,su:!1,category:dl},{name:`describe_metric`,su:!1,category:dl},{name:`get_configuration`,su:!0,category:fl},{name:`set_configuration`,su:!0,category:fl},{name:`restart`,su:!0,category:fl},{name:`restart_service`,su:!0,category:fl},{name:`system_information`,su:!0,category:fl},{name:`get_status`,su:!0,category:fl},{name:`set_status`,su:!0,category:fl},{name:`clear_status`,su:!0,category:fl},{name:`registration_info`,su:!1,category:fl},{name:`get_backup`,su:!0,category:fl},{name:`create_backup`,su:!0,category:pl,addedIn:rl,nonDelegable:!0},{name:`verify_backup`,su:!0,category:pl,addedIn:rl,nonDelegable:!0},{name:`restore_backup`,su:!0,category:pl,addedIn:rl,nonDelegable:!0},{name:`list_backups`,su:!0,category:pl,addedIn:rl,nonDelegable:!0},{name:`delete_backup`,su:!0,category:pl,addedIn:rl,nonDelegable:!0},{name:`purge_backups`,su:!0,category:pl,addedIn:rl,nonDelegable:!0},{name:`set_secret`,su:!0,category:ml,addedIn:rl,nonDelegable:!0},{name:`grant_secret`,su:!0,category:ml,addedIn:rl,nonDelegable:!0},{name:`revoke_secret`,su:!0,category:ml,addedIn:rl,nonDelegable:!0},{name:`list_secrets`,su:!0,category:ml,addedIn:rl,nonDelegable:!0},{name:`delete_secret`,su:!0,category:ml,addedIn:rl,nonDelegable:!0},{name:`get_secrets_public_key`,su:!0,category:ml,addedIn:rl,nonDelegable:!0},{name:`set_env_value`,su:!0,category:ml,addedIn:rl},{name:`delete_env_value`,su:!0,category:ml,addedIn:rl},{name:`get_env_keys`,su:!0,category:ml,addedIn:rl},{name:`agent_prompt`,su:!0,category:hl,addedIn:nl},{name:`get_agent_session`,su:!0,category:hl,addedIn:nl},{name:`list_agent_sessions`,su:!0,category:hl,addedIn:nl},{name:`cancel_agent_run`,su:!0,category:hl,addedIn:nl},{name:`approve_agent_action`,su:!0,category:hl,addedIn:nl},{name:`set_agent_config`,su:!0,category:hl,addedIn:nl}],vl=[`search`,`search_by_conditions`,`search_by_hash`,`search_by_id`,`search_by_value`,`sql`,`describe_all`,`describe_schema`,`describe_database`,`describe_table`,`user_info`,`get_job`,`get_analytics`,`list_metrics`,`describe_metric`],yl=[{name:`read_only`,description:`Read-only data access: searches, SQL, schema describes, and user/analytics reads.`,members:vl},{name:`admin_read`,description:`Read-only access to configuration, logs, and component views (normally super_user-only).`,members:[`get_configuration`,`read_log`,`read_audit_log`,`get_custom_functions`,`get_custom_function`,`get_components`,`get_component_file`]},{name:`standard_user`,description:`Everything in read_only plus data writes and bulk loads. No DDL, user management, or admin reads.`,members:[...vl,`insert`,`update`,`upsert`,`put`,`delete`,`csv_data_load`,`csv_file_load`,`csv_url_load`,`import_from_s3`]},{name:`agent`,description:`Drive the built-in agent: prompts, sessions, and run approvals. Excludes agent configuration.`,members:[`agent_prompt`,`get_agent_session`,`list_agent_sessions`,`cancel_agent_run`,`approve_agent_action`],addedIn:rl}],bl=new Map(_l.map(e=>[e.name,e])),xl=new Map(yl.map(e=>[e.name,e]));function Sl(e){return bl.get(e)}function Cl(e){return bl.get(e)?.aliasOf??e}function wl(e){return xl.has(e)}function Tl(e){return!!e&&qc(`5.0.0-alpha.8`,e)}function El(e){return _l.filter(t=>!t.nonDelegable&&!t.aliasOf&&(!t.addedIn||qc(t.addedIn,e)))}function Dl(e){return yl.filter(t=>!t.addedIn||qc(t.addedIn,e))}function Ol(e){let t=new Set;for(let n of e){let e=xl.get(n);if(e){for(let n of e.members){let e=bl.get(n)?.aliasOf??n;tl(e)||t.add(e)}continue}tl(n)||t.add(n)}return[...t].sort()}function kl(e,t=40){return e.length>t?`${e.slice(0,t).join(`, `)}, +${e.length-t} more`:e.join(`, `)}var Al=[`super_user`,`structure_user`,`cluster_user`,`operations`],jl=new Set(Al);function Ml(e,t,n){if((t===`operations`?n:jl.has(t))||!Object.hasOwn(e,t))return;let r=e[t];return typeof r==`object`&&r&&!Array.isArray(r)?r:void 0}function Nl(e){return e?.super_user===!0||e?.cluster_user===!0}function Pl(e){let t=e?.structure_user;return t===!0?!0:Array.isArray(t)&&t.length>0?t:!1}var Fl=[`create_table`,`create_attribute`,`drop_table`,`drop_attribute`];function Il(e){let t=e?.operations;return Array.isArray(t)&&t.every(e=>typeof e==`string`)?t:void 0}function Ll(e,t){let n=e?.operations;return e===void 0||n===void 0?`absent`:t?Il(e)===void 0?n&&typeof n!=`string`&&!Array.isArray(n)?`breaks-auth`:`malformed`:`allowlist`:Ml(e,`operations`,!1)===void 0?`inert`:`database`}function Rl(e){let t=Al.filter(t=>t in e),n=Object.keys(e).filter(e=>!jl.has(e));return Object.fromEntries([...t,...n].map(t=>[t,e[t]]))}function zl(e,t){let n={...e};return t===void 0?delete n.operations:n.operations=t,Rl(n)}var Bl={read:[`search`,`search_by_conditions`,`search_by_hash`,`search_by_value`,`sql`],insert:[`insert`],update:[`update`],delete:[`delete`]},Vl=[`insert`],Hl=[`csv_data_load`,`get_job`],Ul=[`csv_url_load`,`get_job`],Wl={"json-records":Vl,"csv-data":Hl,"csv-url":Ul},Gl={sample:[Vl,Hl],file:[Vl,Hl],url:[Ul]},Kl=Object.keys(Gl),ql=new WeakMap,Jl=new Map(yl.map(e=>[e.name,e.members]));function Yl(e){let t=new Set;for(let n of e){let e=Jl.get(n);if(e)for(let n of e)t.add(n);else t.add(n)}return t}function Xl(e,t){let n=Il(e);if(!n)return!0;let r=ql.get(n);return r||(r=Yl(n),ql.set(n,r)),t.some(e=>r.has(Cl(e)))}function Zl(e,t){return e?.super_user===!0||Xl(e,t)}function Ql(e,t){return Zl(e,Bl[t]??[])}function $l(e,t){return t.every(t=>Xl(e,[t]))}function eu(e,t){return e?.super_user===!0||$l(e,Wl[t])}function tu(e,t){return e?.super_user===!0||Gl[t].some(t=>$l(e,t))}function nu(e){return Kl.some(t=>tu(e,t))}function ru(e,t,n,r){return Ql(e,r)&&ou(e,t,n,r)}function iu(e,t,n){if(!e)return!1;if(e.super_user===!0)return!0;if(!Xl(e,[`put`]))return!1;let r=Ml(e,t,!1)?.tables?.[n];return r?.insert!==!0||r.update!==!0?!1:!(`attribute_permissions`in r&&r.attribute_permissions?.length||`attribute_restrictions`in r&&r.attribute_restrictions?.length)}function au(e,t,n){return nu(e)&&ou(e,t,n,`insert`)}function ou(e,t,n,r){return e?e.super_user===!0||e.structure_user===!0||Ml(e,t,!1)?.tables?.[n]?.[r]===!0:!1}function su(e){let{user:t}=wn(),{organizationId:n}=z({strict:!1}),r=cu(t,e??n);return{update:Tn(t,`org:update`)||r.update,remove:Tn(t,`org:delete`)||r.remove}}function cu(e,t){let n=e?.roles?.[t];return!n||`oauthProviders`in n||!n.permission&&!n.organization?{update:!1,remove:!1}:n.permission?.super_user?{update:!0,remove:!0}:{update:n.organization.update,remove:n.organization.delete}}function lu(e){let{user:t}=wn(),{organizationId:n}=z({strict:!1}),r=uu(t,e??n);return{create:Tn(t,`role:create`)||r.create,remove:Tn(t,`role:delete`)||r.remove,update:Tn(t,`role:update`)||r.update,view:Tn(t,`role:read`)||r.view}}function uu(e,t){let n=e?.roles?.[t];if(!n||`oauthProviders`in n||!n.permission&&!n.organization?.roles)return{create:!1,remove:!1,update:!1,view:!1};if(n.permission?.super_user)return{create:!0,remove:!0,update:!0,view:!0};let r=n.organization.roles;return{create:r.create,remove:r.delete,update:r.update,view:r.view}}function du(e,t){let{user:n}=wn(),{organizationId:r,clusterId:i}=z({strict:!1});return fu(n,e??r,t??i)}function fu(e,t,n){let r=pu(e,t,n);return{create:Tn(e,`cluster:create`)||r.create,remove:Tn(e,`cluster:delete`)||r.remove,update:Tn(e,`cluster:update`)||r.update,view:Tn(e,`cluster:read`)||r.view}}function pu(e,t,n){let r=e?.roles?.[t];if(!r||`oauthProviders`in r||!r.permission&&!r.organization?.clusters)return{create:!1,remove:!1,update:!1,view:!1};if(r.permission?.super_user)return{create:!0,remove:!0,update:!0,view:!0};let i=r.organization.clusters.resources?.find(e=>e.id===n),a=r.organization.clusters;return{create:a.create,remove:i?i.delete:a.delete,update:i?i.update:a.update,view:i?i.view:a.view}}function mu(e,t){let{user:n}=wn(),{organizationId:r,clusterId:i}=z({strict:!1});return hu(n,e??r,t??i)}function hu(e,t,n){let r=gu(e,t,n);return{create:Tn(e,`cluster:update`)||r.create,remove:Tn(e,`cluster:delete`)||r.remove,update:Tn(e,`instance:update`)||r.update,view:Tn(e,`instance:read`)||r.view}}function gu(e,t,n){let r=e?.roles?.[t];if(!r||`oauthProviders`in r||!r.permission&&!r.organization?.clusters)return{create:!1,remove:!1,update:!1,view:!1};if(r.permission?.super_user)return{create:!0,remove:!0,update:!0,view:!0};let i=r.organization.clusters.resources?.find(e=>e.id===n)?.instances,a=r.organization.clusters;return{create:i?i.create:a.create,remove:i?i.delete:a.delete,update:i?i.update:a.update,view:i?i.view:a.view}}function _u(e){let{clusterId:t,instanceId:n}=z({strict:!1}),{user:r}=Dn(e??n??t),i=r?.role?.permission;return i?i.super_user===!0:!1}function vu(e){let{clusterId:t,instanceId:n}=z({strict:!1}),{user:r}=Dn(e??n??t),i=r?.role?.permission;return i?i.super_user===!0||i.structure_user===!0:!1}function yu(e,t,n,r){let{clusterId:i,instanceId:a}=z({strict:!1}),{user:o}=Dn(e??a??i);return ru(o?.role?.permission,t,n,r)}function bu(e,t,n){let{clusterId:r,instanceId:i}=z({strict:!1}),{user:a}=Dn(e??i??r);return iu(a?.role?.permission,t,n)}function xu(e,t,n){let{clusterId:r,instanceId:i}=z({strict:!1}),{user:a}=Dn(e??i??r);return au(a?.role?.permission,t,n)}function Su(e){let{clusterId:t,instanceId:n}=z({strict:!1}),{user:r}=Dn(e??n??t);return nu(r?.role?.permission)}function Cu(e){let{clusterId:t,instanceId:n}=z({strict:!1}),{user:r}=Dn(e??n??t),i=r?.role?.permission;return(0,W.useMemo)(()=>({methods:Object.fromEntries(Kl.map(e=>[e,tu(i,e)])),allowsSource:e=>eu(i,e),allowsDestination:(e,t)=>au(i,e,t)}),[i])}function wu(e){return!!e?.plans?.[0]?.planId?.startsWith(`self-hosted`)}function Tu({cluster:e,hasCardLink:t=!1}){let{view:n,update:r}=du(e.organizationId,e.id),i=`/${e.organizationId}/${e.id}`;if(n)return wu(e)?(0,G.jsx)(Eu,{cluster:e,hasCardLink:t}):e.fqdn?e.resetPassword?r?(0,G.jsx)(B,{to:`${i}/finish-setup`,className:`text-sm text-nowrap`,"aria-label":`Set Password on ${e.name}`,title:`Set Password on ${e.name}`,children:(0,G.jsxs)(P,{variant:`positive`,className:`py-2 hover:border-b-2 animate-glow-pulse`,children:[`Finish Setup `,(0,G.jsx)(Rn,{className:`inline-block`})]})}):(0,G.jsx)(`span`,{className:`py-2 text-nowrap`,children:`Pending Owner Setup`}):(0,G.jsx)(Eu,{cluster:e,hasCardLink:t}):t?(0,G.jsxs)(`span`,{className:`text-sm text-nowrap py-2 ml-auto`,children:[`Instances `,(0,G.jsx)(Rn,{className:`inline-block`})]}):(0,G.jsx)(B,{to:`${i}/instances`,className:`text-sm text-nowrap`,"aria-label":`View ${e.name}`,title:`View ${e.name}`,children:(0,G.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Instances `,(0,G.jsx)(Rn,{className:`inline-block`})]})})}function Eu({cluster:e,hasCardLink:t}){return t?(0,G.jsxs)(`span`,{className:`text-sm text-nowrap py-2 ml-auto`,children:[`Open `,(0,G.jsx)(Rn,{className:`inline-block`})]}):(0,G.jsx)(B,{to:`/${e.organizationId}/${e.id}`,className:`text-sm text-nowrap`,"aria-label":`Open ${e.name}`,title:`Open ${e.name}`,children:(0,G.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Open `,(0,G.jsx)(Rn,{className:`inline-block`})]})})}function Du({clusterName:e,isPending:t,stopOpen:n,setStopOpen:r,onConfirmStop:i,restartOpen:a,setRestartOpen:o,onConfirmRestart:s}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(fn,{open:n,onOpenChange:r,children:(0,G.jsxs)(cn,{className:`sm:max-w-[560px]`,children:[(0,G.jsxs)(rn,{children:[(0,G.jsxs)(ln,{children:[`Stop cluster `,e,`?`]}),(0,G.jsx)(un,{children:`This stops every instance in the cluster. It will be offline and stop serving traffic until you start it again.`})]}),(0,G.jsx)(on,{children:(0,G.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,G.jsx)(P,{type:`button`,variant:`defaultOutline`,onClick:()=>r(!1),children:`Cancel`}),(0,G.jsx)(P,{type:`button`,variant:`destructive`,onClick:i,disabled:t,children:`Stop cluster`})]})})]})}),(0,G.jsx)(fn,{open:a,onOpenChange:o,children:(0,G.jsxs)(cn,{className:`sm:max-w-[560px]`,children:[(0,G.jsxs)(rn,{children:[(0,G.jsxs)(ln,{children:[`Restart cluster `,e]}),(0,G.jsx)(un,{children:`Choose how to restart the cluster's instances.`})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 py-2`,children:[(0,G.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>s(`rolling`),className:`rounded-lg border border-border p-4 text-left transition-colors hover:border-primary hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:opacity-60`,children:[(0,G.jsxs)(`div`,{className:`font-medium`,children:[`Rolling `,(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(recommended)`})]}),(0,G.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`One instance at a time, waiting for each to rejoin before moving on. No downtime.`})]}),(0,G.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>s(`parallel`),className:`rounded-lg border border-border p-4 text-left transition-colors hover:border-primary hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:opacity-60`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:`Parallel`}),(0,G.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`All instances at once. Faster, but the whole cluster is briefly offline.`})]})]}),(0,G.jsx)(on,{children:(0,G.jsx)(P,{type:`button`,variant:`defaultOutline`,onClick:()=>o(!1),children:`Cancel`})})]})})]})}function Ou(e,t){let n=[];if(e)for(let r of e)n.push(r[t]);return n}function ku({cluster:e,forceProgressBarVisible:t}){let[n,r]=(0,W.useState)(t||!1),{data:i}=V(os(n&&e.id,2e3));(0,W.useEffect)(function(){(Xo(e.status)||Zo(e.status))&&r(!0)},[n,e.status,i?.instances]);let a=(0,W.useMemo)(()=>{let e=Ou(i?.plans??[],`planId`),t=i?.instances??[],n=0,r={},a=0,o={},s=0,c={},l=0,u={};for(let i of t){let t=i.status;!t||Yo(t)||(Xo(t)?(n+=1,r[t]=`${n} ${Mo(t)}`):Zo(t)?(a+=1,o[t]=`${a} ${Mo(t)}`):Jo(t)?(l+=1,u[t]=`${l} ${Mo(t)}`):!i.planId||!e.includes(i.planId)?(a+=1,o.DRAINING_TRAFFIC=`${a} ${Mo(`Draining Traffic`)}`):qo(t)&&(s+=1,c[t]=`${s} ${Mo(t)}`))}let d=n+a+s;return{pendingWidth:`${d===0?100:n===0?0:n/d*100}%`,updatingWidth:`${a===0?0:a/d*100}%`,failedWidth:`${l===0?0:l/d*100}%`,runningWidth:`${s===0?0:s/d*100}%`,text:[...Object.values(c).sort(),...Object.values(u).sort(),...Object.values(o).sort(),...Object.values(r).sort()].join(` · `)}},[i]);return n?(0,G.jsxs)(`div`,{className:`w-full text-center`,children:[(0,G.jsxs)(`div`,{className:`w-full h-2.5 rounded-full overflow-clip flex shadow`,children:[(0,G.jsx)(`div`,{style:{width:a.runningWidth},className:`grow bg-green/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,G.jsx)(`div`,{style:{width:a.failedWidth},className:`grow bg-red/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,G.jsx)(`div`,{style:{width:a.updatingWidth},className:`grow animate-pulse bg-yellow/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,G.jsx)(`div`,{style:{width:a.pendingWidth},className:`grow bg-gray-600 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`})]}),a.text&&(0,G.jsx)(`div`,{className:`text-xs text-muted-foreground font-light mt-2`,children:a.text})]}):null}function Au({open:e,setOpen:t,action:n,targetName:r,scope:i,isPending:a,onConfirm:o}){let s=n===`start`?`Start`:`Restart`;return(0,G.jsx)(fn,{open:e,onOpenChange:t,children:(0,G.jsxs)(cn,{className:`sm:max-w-[560px]`,children:[(0,G.jsxs)(rn,{children:[(0,G.jsxs)(ln,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Or,{className:`size-5 text-yellow`}),s,` `,r,` in safe mode?`]}),(0,G.jsxs)(un,{children:[`Safe mode boots Harper`,` `,(0,G.jsx)(`strong`,{className:`text-foreground`,children:`without loading your applications or components`}),`. Use it to recover `,i===`cluster`?`a cluster`:`an instance`,` `,`that a bad app, component, or config is keeping from starting. Then fix or remove what's broken and`,` `,n===`start`?`start`:`restart`,` normally to bring everything back.`]})]}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i===`cluster`?`All instances are ${n===`start`?`started`:`restarted`} at once (parallel)${n===`restart`?`, so expect a brief interruption while they come back.`:`.`}`:`The instance ${n===`start`?`starts`:`restarts`} in safe mode${n===`restart`?`, so expect a brief interruption while it comes back.`:`.`}`}),(0,G.jsx)(on,{children:(0,G.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,G.jsx)(P,{type:`button`,variant:`defaultOutline`,onClick:()=>t(!1),children:`Cancel`}),(0,G.jsxs)(P,{type:`button`,variant:`warning`,onClick:o,disabled:a,children:[(0,G.jsx)(Or,{}),` `,s,` in safe mode`]})]})})]})})}async function ju(e){let{data:t}=await M.delete(`/Cluster/${e}`,{timeout:0});return t}function Mu(){return L({mutationFn:e=>ju(e)})}async function Nu({clusterId:e,action:t,safeMode:n,strategy:r}){let i={};n!==void 0&&(i.safeMode=n),r!==void 0&&(i.strategy=r);let{data:a}=await M.post(`/Cluster/${e}/container/${t}`,i);return a}function Pu(){return L({mutationFn:Nu})}var Fu={stop:`Stopping`,start:`Starting`,restart:`Restarting`};function Iu(e){let{mutateAsync:t,isPending:n}=Pu(),r=Ie();return{run:(0,W.useCallback)(async(n,i)=>{let a=i?.label??Fu[n],o=H.loading(a,{description:`${a} cluster ${e.name}. Status will update automatically.`,duration:3e4,action:{label:`Dismiss`,onClick:()=>H.dismiss()}});try{await t({clusterId:e.id,action:n,safeMode:i?.safeMode,strategy:i?.strategy}),r.invalidateQueries({queryKey:[e.organizationId]}),r.invalidateQueries({queryKey:[e.id]}),H.dismiss(o),H.success(`Request accepted`,{description:`${e.name} is ${a.toLowerCase()}. The status will update automatically.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}})}catch{H.dismiss(o)}},[e.id,e.name,e.organizationId,t,r]),isPending:n}}async function Lu(e){if(!navigator.clipboard)return H.error(`Clipboard access is not available in this environment.`),!1;try{return await navigator.clipboard.writeText(e),!0}catch{return H.error(`Failed to copy to clipboard.`),!1}}function Ru(e){Lu(e).then(e=>{e&&H.info(`Copied to clipboard!`,{icon:(0,G.jsx)(tr,{}),duration:1e3})})}function zu(...e){return(0,W.useMemo)(()=>e.map(e=>()=>Ru(e)),e)}function Bu(){return Ru}function Vu({cluster:e}){let t=pe(),n=Ie(),r=(0,W.useMemo)(()=>c(e),[e]),i=Wa({operationsUrl:r}),a=Dn(e.id),[,o]=xn(vn.SavedClusterState,null),{view:s,update:l,remove:f,create:p}=du(e.organizationId,e.id),{mutate:m,isPending:h}=Mu(),[g,_]=(0,W.useState)(!1),[v,y]=(0,W.useState)(!1),[b,x]=(0,W.useState)(!1),[S,C]=(0,W.useState)(!1),[w,T]=(0,W.useState)(null),{run:E,isPending:D}=Iu(e),O=e.status===`RUNNING`,k=e.status===`STOPPED`,A=e.status===`PARTIAL`,j=e.status===`STOPPING`||e.status===`STARTING`||e.status===`RESTARTING`,ee=j||k||A,M=(0,W.useMemo)(()=>!!(e.status&&zo.includes(e.status)),[e.status]),N=wu(e),P=l&&!N,te=u.checkForFabricConnect(e.id),ne=!te&&!!a.user,re=(0,W.useMemo)(()=>!!(e.status&&Bo.includes(e.status)),[e.status]),ie=(0,W.useMemo)(()=>!!(e.status&&Jo(e.status)),[e.status]),ae=l&&!N&&!re&&!Zo(e.status)&&!Xo(e.status),oe=(0,W.useCallback)(async()=>{_(!0);let t=await is(e.id).catch(e=>(console.error(`Failed to lookup cluster details, proceeding without checking instances.`,e),null));if(await d({entityId:e.id,instanceClient:i}),t?.instances?.length)for(let e of t.instances)u.setUserForEntity(e,null);u.setUserForEntity(e,null)},[e,i]),se=(0,W.useCallback)(()=>{o(e),t.navigate({to:`/${e.organizationId}/new-cluster`})},[e,t,o]),F=(0,W.useCallback)(()=>y(!0),[]),I=(0,W.useCallback)(()=>{let r=e.organizationId;m(e.id,{onSuccess:async()=>{await n.invalidateQueries({queryKey:[r],refetchType:`active`}),await t.invalidate(),H.success(`Success`,{description:N?`Cluster successfully removed.`:`Cluster successfully terminated.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),y(!1)},onError:()=>{H.error(`Error`,{description:N?`Failed to remove cluster: ${e.name}`:`Failed to terminate cluster: ${e.name}.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),y(!1)}})},[t,e.organizationId,e.id,e.name,m,N,n]),ce=!s||re?void 0:e.status===`STOPPED`?`/${e.organizationId}/${e.id}/instances`:e.status===`PARTIAL`?`/${e.organizationId}/${e.id}`:M?N?`/${e.organizationId}/${e.id}`:e.fqdn?e.resetPassword?void 0:`/${e.organizationId}/${e.id}`:`/${e.organizationId}/${e.id}/instances`:void 0,le=e.domains?.[0]?.domain||e.fqdn,[ue,de]=zu(`${le}`,`https://${le}`),L=[{type:`label`,key:`label`,className:`text-gray-600 text-xs`,label:`Options`},{type:`separator`,key:`label-separator`},M&&l&&!a.isLoading&&(!ne||te)&&{key:`sign-in`,to:`${e.id}/sign-in`,disabled:g,icon:(0,G.jsx)(Er,{className:`text-green`}),label:`Direct Sign In`},M&&s&&!!r&&!a.isLoading&&ne&&{key:`direct-sign-out`,onClick:oe,disabled:g,label:`Direct Sign Out`},M&&l&&{key:`edit`,to:`${e.id}/edit`,disabled:g,icon:(0,G.jsx)(Zr,{className:`text-purple-600`}),label:N?`Edit`:`Edit Scaling`},ae&&{key:`edit-version`,to:`${e.id}/edit/version`,disabled:g,icon:(0,G.jsx)(yr,{className:`text-fuchsia-300`}),label:`Edit Version`},M&&l&&!1,M&&s&&{key:`instances`,to:`${e.id}/instances`,disabled:g,icon:(0,G.jsx)($r,{className:`text-orange-300`}),label:`Instances`},M&&s&&!!a.user&&{key:`deployments`,to:`${e.id}/config/deployments`,disabled:g,icon:(0,G.jsx)(qr,{className:`text-sky-400`}),label:`Deployments`},P&&(O||k||A)&&{type:`separator`,key:`container-separator`},P&&(O||k||A)&&{type:`label`,key:`container-label`,className:`text-gray-600 text-xs`,label:`Container`},P&&(k||A)&&{key:`container-start`,disabled:D,onClick:()=>void E(`start`,{safeMode:!1,strategy:`parallel`}),icon:(0,G.jsx)(Wr,{}),label:`Start`},P&&k&&{key:`container-start-safe`,disabled:D,onClick:()=>T(`start`),icon:(0,G.jsx)(Or,{}),label:`Start in safe mode`},P&&(O||A)&&{key:`container-restart`,disabled:D,onClick:()=>C(!0),icon:(0,G.jsx)(Yr,{}),label:`Restart`},P&&O&&{key:`container-restart-safe`,disabled:D,onClick:()=>T(`restart`),icon:(0,G.jsx)(Or,{}),label:`Restart in safe mode`},P&&(O||A)&&{key:`container-stop`,variant:`destructive`,disabled:D,onClick:()=>x(!0),icon:(0,G.jsx)(ai,{}),label:`Stop`},M&&s&&!!e.fqdn&&{type:`separator`,key:`copy-separator`},M&&s&&!!e.fqdn&&{key:`copy-host-name`,onClick:ue,disabled:g,icon:(0,G.jsx)(nr,{}),label:`Copy Host Name`},M&&s&&!!e.fqdn&&{key:`copy-api-url`,onClick:de,disabled:g,icon:(0,G.jsx)(nr,{}),label:`Copy API URL`},ie&&p&&{key:`try-again`,onClick:se,className:`focus:bg-green/70 focus:text-white`,label:`Try Again`},!re&&f&&M&&{type:`separator`,key:`remove-separator`},!re&&f&&{key:`remove`,onClick:F,className:`focus:bg-red/70 focus:text-white`,icon:(0,G.jsx)(fi,{className:`text-red-300`}),label:N?`Remove`:`Terminate`}].filter(Qa);return(0,G.jsx)(Kc,{items:re?[]:L,children:(0,G.jsxs)(On,{className:`relative h-full justify-between transition-[transform,box-shadow] duration-200 ${ce?`hover:scale-[1.02] hover:shadow-lg hover:ring-2 hover:ring-primary/60 dark:hover:ring-violet-400/70`:`hover:shadow-lg`}`,children:[ce&&(0,G.jsx)(B,{to:ce,"aria-label":`${N||e.fqdn?`Open`:`View`} ${e.name}`,className:`absolute inset-0 rounded-[inherit] focus-visible:ring-2 focus-visible:ring-purple-200 focus-visible:outline-none`}),(0,G.jsxs)(kn,{children:[(0,G.jsxs)(jn,{className:`flex items-center justify-between`,children:[le?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`truncate max-w-48`,children:le}),(0,G.jsx)(`button`,{type:`button`,"aria-label":`Copy host name`,onClick:e=>{e.stopPropagation(),ue()},className:`relative z-10 -m-1.5 p-1.5 rounded-md text-muted-foreground cursor-pointer hover:bg-accent/60 hover:text-foreground`,children:(0,G.jsx)(sr,{size:16})}),(0,G.jsx)(`span`,{className:`grow`})]}):(0,G.jsx)(`span`,{children:`Self-Hosted`}),!re&&(0,G.jsxs)(wi,{children:[(0,G.jsx)(Ti,{"aria-label":`Cluster options`,onClick:e=>e.stopPropagation(),className:`relative z-10 -m-2 p-2 rounded-md hover:bg-accent/60`,children:(0,G.jsx)(ur,{})}),(0,G.jsx)(Ei,{children:Gc(L,`dropdown`)})]})]}),(0,G.jsx)(An,{children:(0,G.jsx)(`h2`,{children:e.name})})]}),(0,G.jsxs)(Mn,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(ku,{cluster:e}),M&&s&&(0,G.jsx)(Tu,{cluster:e,hasCardLink:!!ce}),ee&&e.status&&(0,G.jsxs)(Ji,{variant:k?`destructive`:`warning`,children:[j&&(0,G.jsx)(Ar,{className:`animate-spin`}),Mo(e.status)]}),ie&&e.status&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ji,{variant:Go(e.status),children:Mo(e.status)}),(0,G.jsx)(`span`,{className:`text-xs`,children:`Click "..." to choose how to proceed.`})]})]}),(0,G.jsx)(Ic,{typeOfThingBeingDeleted:`cluster`,transitiveVerb:N?`Remove`:`Terminate`,presentParticiple:N?`Removing`:`Terminating`,nameOfThingBeingDeleted:e.name,isModalOpen:v,hideDataLossWarning:N,setIsModalOpen:e=>y(e),deletionConfirmed:I,deletionPending:h}),(0,G.jsx)(Du,{clusterName:e.name,isPending:D,stopOpen:b,setStopOpen:x,onConfirmStop:()=>{x(!1),E(`stop`,{strategy:`parallel`})},restartOpen:S,setRestartOpen:C,onConfirmRestart:e=>{C(!1),E(`restart`,{safeMode:!1,strategy:e})}}),(0,G.jsx)(Au,{open:w!==null,setOpen:e=>{e||T(null)},action:w??`restart`,targetName:e.name,scope:`cluster`,isPending:D,onConfirm:()=>{let e=w;T(null),e&&E(e,{safeMode:!0,strategy:`parallel`,label:e===`start`?`Starting in safe mode`:`Restarting in safe mode`})}})]})})}function Hu({children:e,className:t}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Fc,{}),(0,G.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] relative ${t??``}`,children:e})]})}function Uu({children:e}){let{organizationId:t,clusterId:n}=z({strict:!1}),{view:r,update:i}=du(t,n),{data:a}=V(os(n,!1)),o=a?wu(a):!1,s=`/${t}/${n}`,c=[{to:s,label:`Overview`,icon:Dr,exact:!0},r&&!o&&{to:`${s}/usage`,label:`Usage`,icon:Kn},i&&{to:`${s}/edit`,label:o?`Configuration`:`Scaling`,icon:vr,exact:!0},i&&!o&&{to:`${s}/edit/version`,label:`Version`,icon:li,exact:!0},i&&!o&&{to:`${s}/domains`,label:`Domains`,icon:br},r&&{to:`${s}/instances`,label:`Instances`,icon:$r}].filter(Boolean);return(0,G.jsx)(`div`,{className:`relative mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,G.jsxs)(`div`,{className:`md:grid gap-6 md:grid-cols-12`,children:[(0,G.jsx)(`aside`,{className:`md:col-span-3 lg:col-span-2 mb-4 md:mb-0`,children:(0,G.jsx)(zi,{items:c,ariaLabel:`Cluster sections`})}),(0,G.jsx)(`section`,{className:`md:col-span-9 lg:col-span-10 min-w-0`,children:e})]})})}async function Wu(e){let{data:t}=await M.get(`/Plan/`,{params:{organizationId:e}});return t}function Gu(e){return R({queryKey:[e,`instancePlan`],queryFn:()=>Wu(e),retry:!1})}var Ku=[`stable`,`next`,`beta`,`alpha`];function qu(e){let t=Ku.indexOf(e);return t===-1?Ku.length:t}function Ju(e){let t=new Map;for(let n of e){let e=t.get(n.version);(!e||qu(n.name)<qu(e.name))&&t.set(n.version,n)}return[...t.values()]}async function Yu(e){let{data:t}=await M.get(`/HarperVersions/`,{params:{organizationId:e}}),n=t;return{...n,value:Ju(n.value)}}function Xu(e){return R({queryKey:[e,`HarperVersions`],queryFn:()=>Yu(e),staleTime:6e4,retry:!1})}async function Zu({organizationId:e,availableHosts:t}={}){let{data:n}=await M.get(`/Region/`,{params:{availableHosts:t,organizationId:e}});return n}function Qu({organizationId:e,availableHosts:t}={}){return R({queryKey:[e,`regionLocations`,t],queryFn:()=>Zu({organizationId:e,availableHosts:t}),retry:!1})}function $u(e){return(t,n)=>t[e]===n[e]?0:t[e]>n[e]?1:-1}function ed(e){let t=e.split(`.`).map(Number);return(t[0]<<24|t[1]<<16|t[2]<<8|t[3])>>>0}function td(e){return typeof e==`string`&&/^(?:25[0-5]|2[0-4]\d|1?\d?\d)(?:\.(?:25[0-5]|2[0-4]\d|1?\d?\d)){3}$/.test(e)}function nd(e,t){return e.instanceFqdn===t.instanceFqdn?e.operationsApiPort-t.operationsApiPort:td(e.instanceFqdn)&&td(t.instanceFqdn)?ed(e.instanceFqdn)-ed(t.instanceFqdn):e.instanceFqdn>t.instanceFqdn?1:-1}function rd(e,t){let n={};for(let r of e){let e=r[t];if(e!==void 0){if(Array.isArray(e))for(let t of e)n[t]||(n[t]=[]),n[t].push(r);else n[e]||(n[e]=[]),n[e].push(r)}}return n}function id(e,t){let n={};for(let r of e){let e=r[t];if(e!==void 0){if(Array.isArray(e))for(let t of e)n[t]=r;else n[e]=r}}return n}function ad(e,t,n){let r=rd(e,t),i={};for(let e in r)i[e]=id(r[e],n);return i}function od({width:e,className:t,animated:n,placeholder:r}){return(0,G.jsxs)(`div`,{className:y(`w-full bg-gray-200 rounded-full relative`,r?`h-6`:`h-2.5`),children:[r&&(0,G.jsx)(`div`,{className:`absolute top-0 h-full w-full font-bold text-xs flex flex-col items-center justify-center text-black/60 text-shadow-2xs`,children:r}),(0,G.jsx)(`div`,{className:y(`rounded-full`,r?`h-6`:`h-2.5`,!t?.includes(`bg-`)&&`bg-purple/40`,n&&`transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`,t),style:{width:e}})]})}function sd({duration:e,message:t,lateMessage:n}){let r=(0,W.useRef)(0),i=(0,W.useRef)(0),[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(`5%`),l=(0,W.useCallback)(function t(n){i.current||=n;let a=n-i.current,s=Math.min(a/e,1);c(Math.max(5,s*100)+`%`),s<1?r.current=requestAnimationFrame(t):o(!0)},[e]);return(0,W.useEffect)(()=>(r.current=requestAnimationFrame(l),()=>cancelAnimationFrame(r.current)),[l]),(0,G.jsxs)(G.Fragment,{children:[a?n:t,(0,G.jsx)(od,{width:s,animated:!1})]})}async function cd(e){let{data:t}=await M.post(`/Cluster/`,e,{timeout:0});return t}function ld(){return L({mutationFn:e=>cd(e)})}async function ud(e){let{id:t,...n}=e,{data:r}=await M.put(`/Cluster/${t}`,n,{timeout:0});return r}function dd(){return L({mutationFn:e=>ud(e)})}function fd(e){return!!e&&e!==`undefined`&&e!==`null`}async function pd(e){if(!fd(e))throw Error(`getOrganization called without a valid organization id (got: ${e})`);let{data:t}=await M.get(`/Organization/${e}`);return t}function md(e){return R({queryKey:[e],queryFn:()=>pd(e),retry:!1,enabled:fd(e),refetchInterval:ns(1e4)})}var hd=`ENTERPRISE`;function gd(e,t){if(t<=0)return``;if(e.length<=t)return e;let n=e.split(`-`);if(n.length===1)return n[0].slice(0,t);let r=[n[0],...n.slice(1).map(e=>e.charAt(0))],i=r.join(`-`);if(i.length<=t)return i;let a=r.slice(1).join(``).length,o=r.length-1,s=t-a-o;if(s>0)return r[0]=r[0].slice(0,s),r.join(`-`);{let e=[],i=0;t>0&&(e.push(n[0].charAt(0)),i=1);for(let n=1;n<r.length&&i+2<=t;n++)e.push(r[n]),i+=2;return e.join(`-`)}}function _d(e,t,n=`-`){let r=t.split(n)[0];return e.findIndex(e=>e.startsWith(r))!==-1}function vd(e){return e.replace(/[^a-zA-Z0-9]/g,`-`).replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase().replace(/-+/g,`-`).replace(/^-+|-+$/g,``)}function yd(e){return e!==void 0&&e>0}function bd(e,t,n){return t===void 0?Promise.resolve():e.invalidateQueries({predicate:e=>e.queryKey[0]===t||e.queryKey[1]===t,...n})}async function xd(e){await M.put(`/Payment/`,e)}function Sd(){return L({mutationFn:e=>xd(e)})}function Cd(e){let{mutate:t}=Sd();return(0,W.useCallback)((n,r)=>{t({paymentMethodId:typeof n==`string`?n:n.id,organizationId:e},{onSuccess:()=>{H.success(`Success! Your payment method has been saved.`),r(!0)},onError:()=>{H.error(`Failed to process payment method details. Please try another payment method.`),r(!1)}})},[t,e])}var wd=(0,W.createContext)(null);function Td(){return(0,W.useContext)(wd)}var Ed=t(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),Dd=t(((e,t)=>{var n=Ed();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),Od=e(t(((e,t)=>{t.exports=Dd()()}))(),1);function kd(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Ad(e){if(Array.isArray(e))return e}function jd(e,t,n){return(t=Bd(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Md(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Nd(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
11
11
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Pd(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Fd(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Pd(Object(n),!0).forEach(function(t){jd(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Pd(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Id(e,t){if(e==null)return{};var n,r,i=Ld(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Ld(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Rd(e,t){return Ad(e)||Md(e,t)||Hd(e,t)||Nd()}function zd(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Bd(e){var t=zd(e,`string`);return typeof t==`symbol`?t:t+``}function Vd(e){"@babel/helpers - typeof";return Vd=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Vd(e)}function Hd(e,t){if(e){if(typeof e==`string`)return kd(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?kd(e,t):void 0}}var Ud=function(e,t,n){var r=!!n,i=W.useRef(n);W.useEffect(function(){i.current=n},[n]),W.useEffect(function(){if(!r||!e)return function(){};var n=function(){if(i.current)return i.current.apply(i,arguments)};return e.on(t,n),function(){e.off(t,n)}},[r,t,e,i])},Wd=function(e){var t=W.useRef(e);return W.useEffect(function(){t.current=e},[e]),t.current},Gd=function(e){return e!==null&&Vd(e)===`object`},Kd=`[object Object]`,qd=function e(t,n){if(!Gd(t)||!Gd(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var i=Object.prototype.toString.call(t)===Kd;if(i!==(Object.prototype.toString.call(n)===Kd))return!1;if(!i&&!r)return t===n;var a=Object.keys(t),o=Object.keys(n);if(a.length!==o.length)return!1;for(var s={},c=0;c<a.length;c+=1)s[a[c]]=!0;for(var l=0;l<o.length;l+=1)s[o[l]]=!0;var u=Object.keys(s);if(u.length!==a.length)return!1;var d=t,f=n;return u.every(function(t){return e(d[t],f[t])})},Jd=function(e,t,n){return Gd(e)?Object.keys(e).reduce(function(r,i){var a=!Gd(t)||!qd(e[i],t[i]);return n.includes(i)?(a&&console.warn(`Unsupported prop change: options.${i} is not a mutable property.`),r):a?Fd(Fd({},r||{}),{},jd({},i,e[i])):r},null):null},Yd=W.createContext(null);Yd.displayName=`ElementsContext`;var Xd=function(e,t){if(!e)throw Error(`Could not find Elements context; You need to wrap the part of your app that ${t} in an <Elements> provider.`);return e};Od.default.any,Od.default.object;var Zd=function(e){return Xd(W.useContext(Yd),e)},Qd=function(){return Zd(`calls useElements()`).elements};Od.default.func.isRequired;var $d=W.createContext(null);$d.displayName=`CheckoutContext`;var ef=function(e){var t=W.useContext($d),n=W.useContext(Yd);if(t){if(n)throw Error(`You cannot wrap the part of your app that ${e} in both a checkout provider and <Elements> provider.`);return t}return Xd(n,e)},tf=[`mode`],nf=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},rf=function(e,t,n){var r=`${nf(e)}Element`,i=t?function(e){ef(`mounts <${r}>`);var t=e.id,n=e.className;return W.createElement(`div`,{id:t,className:n})}:function(t){var n=t.id,i=t.className,a=t.options,o=a===void 0?{}:a,s=t.onBlur,c=t.onFocus,l=t.onReady,u=t.onChange,d=t.onEscape,f=t.onClick,p=t.onLoadError,m=t.onLoaderStart,h=t.onNetworksChange,g=t.onConfirm,_=t.onCancel,v=t.onShippingAddressChange,y=t.onShippingRateChange,b=t.onSavedPaymentMethodRemove,x=t.onSavedPaymentMethodUpdate,S=t.onAvailablePaymentMethodsChange,C=ef(`mounts <${r}>`),w=`elements`in C?C.elements:null,T=`checkoutState`in C?C.checkoutState:null,E=T?.type===`success`||T?.type===`loading`?T.sdk:null,D=Rd(W.useState(null),2),O=D[0],k=D[1],A=W.useRef(null),j=W.useRef(null);Ud(O,`blur`,s),Ud(O,`focus`,c),Ud(O,`escape`,d),Ud(O,`click`,f),Ud(O,`loaderror`,p),Ud(O,`loaderstart`,m),Ud(O,`networkschange`,h),Ud(O,`confirm`,g),Ud(O,`cancel`,_),Ud(O,`shippingaddresschange`,v),Ud(O,`shippingratechange`,y),Ud(O,`savedpaymentmethodremove`,b),Ud(O,`savedpaymentmethodupdate`,x),Ud(O,`availablepaymentmethodschange`,S),Ud(O,`change`,u);var ee;l&&(ee=e===`expressCheckout`?l:function(){l(O)}),Ud(O,`ready`,ee),W.useLayoutEffect(function(){if(A.current===null&&j.current!==null&&(w||E)){var t=null;if(E){var n=E,i=E;switch(e){case`paymentForm`:t=i.createForm(o);break;case`payment`:t=n.createPaymentElement(o);break;case`address`:if(`mode`in o){var a=o.mode,s=Id(o,tf);if(a===`shipping`)t=n.createShippingAddressElement(s);else if(a===`billing`)t=n.createBillingAddressElement(s);else throw Error(`Invalid options.mode. mode must be 'billing' or 'shipping'.`)}else throw Error(`You must supply options.mode. mode must be 'billing' or 'shipping'.`);break;case`expressCheckout`:t=n.createExpressCheckoutElement(o);break;case`currencySelector`:t=E.createCurrencySelectorElement();break;case`taxId`:t=n.createTaxIdElement(o);break;case`contactDetails`:t=n.createContactDetailsElement();break;case`terms`:t=n.createTermsElement(o);break;default:throw Error(`<${r}> is not supported inside a checkout provider. Use an <Elements> provider instead.`)}}else w&&(t=w.create(e,o));A.current=t,k(t),t&&t.mount(j.current)}},[w,E,o]);var M=Wd(o);return W.useEffect(function(){if(A.current){var e=Jd(o,M,[`paymentRequest`]);e&&`update`in A.current&&A.current.update(e)}},[o,M]),W.useLayoutEffect(function(){return function(){if(A.current&&typeof A.current.destroy==`function`)try{A.current.destroy(),A.current=null}catch{}}},[]),W.createElement(`div`,{id:n,className:i,ref:j})};return i.propTypes={id:Od.default.string,className:Od.default.string,onChange:Od.default.func,onBlur:Od.default.func,onFocus:Od.default.func,onReady:Od.default.func,onEscape:Od.default.func,onClick:Od.default.func,onLoadError:Od.default.func,onLoaderStart:Od.default.func,onNetworksChange:Od.default.func,onConfirm:Od.default.func,onCancel:Od.default.func,onShippingAddressChange:Od.default.func,onShippingRateChange:Od.default.func,onSavedPaymentMethodRemove:Od.default.func,onSavedPaymentMethodUpdate:Od.default.func,onAvailablePaymentMethodsChange:Od.default.func,options:Od.default.object},i.displayName=r,i.__elementType=e,i},af=typeof window>`u`,of=W.createContext(null);of.displayName=`EmbeddedCheckoutProviderContext`;var sf=function(){return ef(`calls useStripe()`).stripe};rf(`auBankAccount`,af),rf(`card`,af),rf(`cardNumber`,af),rf(`cardExpiry`,af),rf(`cardCvc`,af),rf(`currencySelector`,af),rf(`iban`,af);var cf=rf(`payment`,af);rf(`expressCheckout`,af),rf(`paymentRequestButton`,af),rf(`linkAuthentication`,af),rf(`contactDetails`,af);var lf=rf(`address`,af);rf(`shippingAddress`,af),rf(`paymentMethodMessaging`,af),rf(`taxId`,af),rf(`issuingCardNumberDisplay`,af),rf(`issuingCardCvcDisplay`,af),rf(`issuingCardExpiryDisplay`,af),rf(`issuingCardPinDisplay`,af),rf(`issuingCardCopyButton`,af),rf(`terms`,af);function uf({hasExistingBilling:e,onPaymentAdded:t,onSaveStateForBillingRedirect:n}){let{organizationId:r}=z({strict:!1}),i=sf(),a=Td(),o=Qd(),[s,c]=(0,W.useState)(!1),l=Cd(r),u=(0,W.useCallback)(()=>{t(!1)},[t]),d=(0,W.useCallback)(async e=>{if(e.preventDefault(),!i||!o)return;c(!0),await o.submit(),n?.(!0);let s=await i.confirmSetup({clientSecret:a.clientSecret,elements:o,redirect:`if_required`,confirmParams:{return_url:`${window.location.origin}/#/${r}/billing/confirm`}});s.error?(console.error(s.error.message),H.error(s.error.message),c(!1),n?.(!1)):s.setupIntent.payment_method&&(l(s.setupIntent.payment_method,t),n?.(!1))},[o,t,n,r,l,i,a.clientSecret]);return(0,G.jsxs)(`form`,{id:`billing-add-payment-method-form`,name:`billing-add-payment-method-form`,onSubmit:d,className:`max-w-xl`,children:[(0,G.jsx)(cf,{}),(0,G.jsx)(lf,{options:{mode:`billing`}}),(0,G.jsxs)(`div`,{className:`mt-4 flex gap-8 items-center`,children:[(0,G.jsxs)(P,{disabled:!i||!o||s,variant:`submit`,children:[(0,G.jsx)(Xr,{}),` Add Payment Method`]}),e&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`text-xs text-gray-600`,children:`Your existing payment method will be overwritten.`}),(0,G.jsx)(P,{variant:`defaultOutline`,type:`button`,onClick:u,children:`Cancel`})]})]})]})}var df=`dahlia`,ff=`https://js.stripe.com`,pf=`${ff}/${df}/stripe.js`,mf=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,hf=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/,gf=`loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used`,_f=function(e){return mf.test(e)||hf.test(e)},vf=function(){for(var e=document.querySelectorAll(`script[src^="${ff}"]`),t=0;t<e.length;t++){var n=e[t];if(_f(n.src))return n}return null},yf=function(e){var t=e&&!e.advancedFraudSignals?`?advancedFraudSignals=false`:``,n=document.createElement(`script`);n.src=`${pf}${t}`;var r=document.head||document.body;if(!r)throw Error(`Expected document.body not to be null. Stripe.js requires a <body> element.`);return r.appendChild(n),n},bf=null,xf=null,Sf=null,Cf=function(e){return function(t){e(Error(`Failed to load Stripe.js`,{cause:t}))}},wf=function(e,t){return function(){window.Stripe?e(window.Stripe):t(Error(`Stripe.js not available`))}},Tf=function(e){return bf===null?(bf=new Promise(function(t,n){if(typeof window>`u`||typeof document>`u`){t(null);return}if(window.Stripe&&e&&console.warn(gf),window.Stripe){t(window.Stripe);return}try{var r=vf();if(r&&e)console.warn(gf);else if(!r)r=yf(e);else if(r&&Sf!==null&&xf!==null){var i;r.removeEventListener(`load`,Sf),r.removeEventListener(`error`,xf),(i=r.parentNode)==null||i.removeChild(r),r=yf(e)}Sf=wf(t,n),xf=Cf(n),r.addEventListener(`load`,Sf),r.addEventListener(`error`,xf)}catch(e){n(e);return}}),bf.catch(function(e){return bf=null,Promise.reject(e)})):bf},Ef,Df=function(){return Ef||(Ef=Tf(null).catch(function(e){return Ef=null,Promise.reject(e)}),Ef)};Promise.resolve().then(function(){return Df()}).catch(function(e){console.warn(e)});async function Of(e){let{data:t}=await M.post(`/StripeAccount/`,e);return t}function kf(){return L({mutationFn:e=>Of(e)})}async function Af(e){let{data:t}=await M.post(`/Payment/`,{organizationId:e.organizationId});return t}function jf(){return L({mutationFn:e=>Af(e)})}function Mf(e){let{enabled:t,existingStripeId:n,organizationId:r}=e,{mutate:i}=kf(),{mutate:a}=jf(),[o,s]=(0,W.useState)(void 0),c=(0,W.useCallback)(e=>{s(e.clientSecret)},[]);return(0,W.useEffect)(()=>{},[i,t,n,a,c,r]),o}function Nf({children:e}){let{organizationId:t}=z({strict:!1}),{data:n}=V(md(t)),r=Mf({organizationId:t,enabled:!!n,existingStripeId:n?.stripeId}),i=Oa();return(0,W.useMemo)(()=>({clientSecret:r||``,appearance:{theme:i===`dark`?`night`:`stripe`}}),[r,i]),console.error(`No VITE_PUBLIC_STRIPE_KEY is configured for this environment.`),(0,G.jsx)(`div`,{className:`mt-20 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:`Setting up your billing is currently disabled. Please check back again later.`})}function Pf({onPaymentAdded:e,onSaveStateForBillingRedirect:t}){let{organizationId:n}=z({strict:!1}),{data:r}=V(md(n)),i=r?.billing,a=i?.paymentMethod;return(0,G.jsxs)(Nf,{children:[(0,G.jsx)(`div`,{className:`mt-2 mb-6`,children:!a&&`You currently have no payment method on file. Please fill out the secure form below.`}),(0,G.jsx)(uf,{hasExistingBilling:!!i,onSaveStateForBillingRedirect:t,onPaymentAdded:e})]})}var Ff=function(e){return e.PASS=`pass`,e.FAIL=`fail`,e.PENDING=`pending`,e.ERROR=`error`,e}({});function If(e){switch(e){case Ff.PASS:return`success`;case Ff.FAIL:case Ff.ERROR:return`destructive`;case Ff.PENDING:default:return`default`}}function Lf(e){switch(e){case Ff.PASS:return`READY`;case Ff.FAIL:case Ff.ERROR:case Ff.PENDING:default:return e.toUpperCase()}}function Rf(e,t){return`${String(e).padStart(2,`0`)}/${String(t%100).padStart(2,`0`)}`}function zf(e){let{onSaveStateForBillingRedirect:t,onReplacingPaymentMethod:n}=e??{},{organizationId:r}=z({strict:!1}),{update:i}=su(r),{data:a,refetch:o}=V(md(r)),s=a?.billing?.paymentMethod,[c,l]=(0,W.useState)(!1),u=(0,W.useCallback)(()=>{l(!c),n?.(!c)},[n,c]),d=(0,W.useCallback)(e=>{l(!1),n?.(!1),e&&o()},[n,o]);return a?.type===`ENTERPRISE`?(0,G.jsxs)(`span`,{children:[`You are part of an enterprise organization! We don’t currently show your payment methods on this page. Want to explore your solution with Harper more? `,(0,G.jsx)(_s,{}),`, we would love to talk!`]}):s&&!c?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mt-2`,children:[s.brand?.toUpperCase()??`Card`,` ending in `,s.last4??`••••`,s.expMonth&&s.expYear?(0,G.jsxs)(G.Fragment,{children:[`(exp `,Rf(s.expMonth,s.expYear),`)`]}):null,s.status?(0,G.jsxs)(G.Fragment,{children:[`—`,` `,(0,G.jsx)(Ji,{variant:If(s.status),children:Lf(s.status)})]}):null]}),i&&(0,G.jsx)(`div`,{className:`mt-2 mb-6`,children:(0,G.jsx)(P,{variant:`defaultOutline`,type:`button`,onClick:u,children:`Replace Payment Method`})})]}):i?(0,G.jsx)(Pf,{onSaveStateForBillingRedirect:t,onPaymentAdded:d}):(0,G.jsx)(`div`,{children:`This org doesn't have a payment method, and you don't have access to add one. Please contact your administrator.`})}function Bf({clusterId:e,isPending:t,onGoBackToDetails:n,onSaveStateForBillingRedirect:r,onSubmit:i,organizationId:a,selectedPlan:o}){let{data:s}=V(md(a)),c=s?.billing,l=s?.type===hd,u=l||c?.paymentMethod?.status===Ff.PASS,[d,f]=(0,W.useState)(!1),p=yd(o?.planLimits?.expirationMonths)&&o.planLimits.expirationMonths<1e3&&o.planLimits.expirationMonths,m=(0,G.jsx)(G.Fragment,{children:(0,G.jsxs)(`div`,{className:`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end mt-3 max-w-xl`,children:[(0,G.jsxs)(P,{type:`button`,variant:`defaultOutline`,disabled:t,onClick:n,children:[(0,G.jsx)(Ln,{}),` Back to Details`]}),(0,G.jsxs)(P,{disabled:t||!u||d,type:`submit`,variant:`submit`,onClick:i,children:[e?`Edit Cluster`:`Create New Cluster`,` `,(0,G.jsx)(Rn,{})]})]})});if(l)return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`ul`,{className:`list-disc ml-6 max-w-lg`,children:[(0,G.jsx)(`li`,{children:`Reminder: you will be billed at your contracted rate for any additional infrastructure.`}),(0,G.jsxs)(`li`,{children:[`Your account representative can work with you to sort out more precise details, and to help accomplish your objectives with this cluster. `,(0,G.jsx)(_s,{overEmail:!0}),`, we are here to help.`]})]}),m]});let g=p&&`, or ${h(p,`month`,`months`)} elapse`;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`ul`,{className:`list-disc ml-6 mb-6`,children:[(0,G.jsx)(`li`,{children:`You will be billed for this cluster today, and will receive a license for the block of usage you've requested.`}),e&&(0,G.jsx)(`li`,{children:`If you scale up, you'll be charged for the additional blocks you've purchased now, and your next auto renewal will be for all purchased blocks.`}),e&&(0,G.jsx)(`li`,{children:`If you remove a region, that region's usage block will not be used anymore (because it is specific to that region).`}),(0,G.jsxs)(`li`,{children:[`When that block is used up`,g,`, you will be automatically renewed.`]}),(0,G.jsx)(`li`,{children:`While refunds are not available, we’d be happy to assist you with troubleshooting.`}),(0,G.jsxs)(`li`,{children:[`We would love to work with you to sort out more precise details, and to help accomplish your objectives with this cluster. `,(0,G.jsx)(_s,{overEmail:!0}),`, we are here to help.`]})]}),(0,G.jsx)(`p`,{className:`text-muted-foreground text-sm mb-6`,children:`Payment method:`}),(0,G.jsx)(zf,{onSaveStateForBillingRedirect:r,onReplacingPaymentMethod:f}),m]})}var Vf=/(^$|^(?:localhost|(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}|(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,})$)/i,Hf=65535,Uf=A().max(20,`Must be at most 20 characters long.`).regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,`Can only contain lowercase letters, numbers and dashes. Must not start or end with a dash.`),Wf=S({clusterName:A().nonempty(`Please enter a cluster name.`).max(255,`Cluster name cannot be longer than 255 characters long.`),abbreviatedName:ee([x(``),w(),Uf]).optional(),fqdn:A().regex(Vf,`Please enter a valid host name without the port or any path.`).optional(),version:A().optional(),deploymentDescription:A().nonempty(`Please select a deployment tier.`),performanceDescription:A().nonempty(`Please select a performance tier.`),regionPlans:T(S({regionName:A().nonempty(`Please select a region.`),latencyDescription:A().nonempty(`Please select a latency tier.`)})).max(50,{error:`A maximum of 50 regions can be selected for each cluster. `}),instances:T(S({secure:O([`true`,`false`]),fqdn:A().nonempty(`Please enter the host name of your instance.`).regex(Vf,`Please enter a valid host name without the port or any path.`),port:C().min(0,`Positive thinking only, please.`).max(Hf,`That port number is too high.`).optional()})).max(100,{error:`A maximum of 100 instances can be added to each cluster.`}),skipToBilling:D().optional(),skipGtmWait:D().optional(),sourceClusterId:A().optional()});function Gf({calculatedNames:e,disabled:t,form:n}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{control:n.control,name:`abbreviatedName`,render:({field:n})=>(0,G.jsxs)(X,{className:`col-span-3`,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Host Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{...n,type:`text`,maxLength:Uf.maxLength,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:e.suggestedAbbreviatedName,disabled:t})}),(0,G.jsx)(Q,{})]})}),(0,G.jsxs)(X,{className:`col-span-3 `,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Full Host Name`}),(0,G.jsx)(J,{children:(0,G.jsx)(`span`,{children:e.fullHostName})}),(0,G.jsx)(Q,{})]})]})}function Kf({className:e}={}){let t=(0,W.useMemo)(()=>y(`animate-pulse h-2.5 bg-gray-200 rounded-full dark:bg-gray-700`,!e?.includes(`mb-`)&&`mb-4 `,!e?.includes(`w-`)&&`w-48 `,e),[e]);return(0,G.jsx)(`div`,{className:t})}function qf({...e}){return(0,G.jsx)(Xt,{"data-slot":`select`,...e})}function Jf({...e}){return(0,G.jsx)(et,{"data-slot":`select-group`,...e})}function Yf({...e}){return(0,G.jsx)(at,{"data-slot":`select-value`,...e})}function Xf({className:e,children:t,...n}){return(0,G.jsxs)(nt,{"data-slot":`select-trigger`,className:N(`border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive flex h-9 w-fit items-center justify-between gap-2 rounded-md border bg-white text-foreground dark:bg-grey-700 dark:text-white px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 *:data-[slot=select-value]:truncate *:data-[slot=select-value]:block *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[t,(0,G.jsx)(Qe,{asChild:!0,children:(0,G.jsx)(pn,{className:`size-4 text-foreground dark:text-white`})})]})}function Zf({className:e,children:t,position:n=`popper`,...r}){return(0,G.jsx)(ct,{children:(0,G.jsxs)(yt,{"data-slot":`select-content`,className:N(`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 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border shadow-md`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,G.jsx)(ep,{}),(0,G.jsx)(ot,{className:N(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,G.jsx)(tp,{})]})})}function Qf({className:e,...t}){return(0,G.jsx)(Ft,{"data-slot":`select-label`,className:N(`px-2 py-1.5 text-sm font-medium`,e),...t})}function $f({className:e,children:t,...n}){return(0,G.jsxs)(ft,{"data-slot":`select-item`,className:N(`focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 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 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,G.jsx)(qe,{children:t}),(0,G.jsx)(`span`,{className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,G.jsx)(Lt,{children:(0,G.jsx)(mn,{className:`size-4`})})})]})}function ep({className:e,...t}){return(0,G.jsx)(mt,{"data-slot":`select-scroll-up-button`,className:N(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,G.jsx)(hn,{className:`size-4`})})}function tp({className:e,...t}){return(0,G.jsx)(ut,{"data-slot":`select-scroll-down-button`,className:N(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,G.jsx)(pn,{className:`size-4`})})}var np={Colocated:`Shared infrastructure for optimized value`,Dedicated:`Dedicated infrastructure for consistent performance`,"Self-Hosted":`Your own infrastructure`};function rp({availableDeploymentTypes:e,disabled:t,form:n}){return(0,G.jsx)(Y,{control:n.control,name:`deploymentDescription`,render:({field:r})=>(0,G.jsxs)(X,{className:`col-span-3`,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Harper Deployment`}),(0,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(Kf,{}),children:(0,G.jsx)(J,{children:(0,G.jsxs)(qf,{...r,disabled:t,onValueChange:e=>{r.onChange(e),n.trigger()},children:[(0,G.jsx)(Xf,{className:`w-full h-auto`,children:(0,G.jsx)(Yf,{placeholder:`Choose Tier`})}),(0,G.jsx)(Zf,{children:(0,G.jsx)(Jf,{children:e.map(e=>(0,G.jsxs)($f,{value:e,children:[(0,G.jsx)(`dt`,{className:`text-left font-bold text-sm/6`,children:e}),np[e]&&(0,G.jsx)(`dd`,{className:`font-light`,children:np[e]})]},e))})})]})})}),(0,G.jsx)(Q,{})]})})}function ip({disabled:e,form:t}){return(0,G.jsx)(Y,{control:t.control,name:`fqdn`,render:({field:t})=>(0,G.jsxs)(X,{className:`md:col-span-6 col-span-3`,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Optional Cluster Load Balancer Host Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{...t,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:`example.your-company.com`,disabled:e})}),(0,G.jsx)(Q,{})]})})}function ap({className:e,disabled:t,form:n}){return(0,G.jsx)(Y,{control:n.control,name:`clusterName`,render:({field:n})=>(0,G.jsxs)(X,{className:e,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Cluster Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{autoFocus:!0,type:`text`,maxLength:Wf.shape.clusterName.maxLength,autoCapitalize:`words`,disabled:t,...n})}),(0,G.jsx)(Q,{})]})})}function op({availablePerformanceDescriptions:e,form:t,selectedDeployment:n}){return(0,G.jsx)(Y,{control:t.control,name:`performanceDescription`,render:({field:r})=>(0,G.jsxs)(X,{className:`col-span-3`,children:[(0,G.jsxs)(Z,{className:`pb-1`,children:[n.startsWith(`Self`)?`Support`:`Performance`,` & Usage`]}),(0,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(Kf,{}),children:(0,G.jsx)(J,{children:(0,G.jsxs)(qf,{...r,onValueChange:e=>{r.onChange(e),t.trigger()},disabled:!e?.length,children:[(0,G.jsx)(Xf,{className:`w-full h-auto`,children:(0,G.jsx)(Yf,{placeholder:`Choose Tier`})}),(0,G.jsx)(Zf,{children:(0,G.jsx)(Jf,{children:e.map(e=>(0,G.jsxs)($f,{value:e.performanceTier,children:[(0,G.jsxs)(`dt`,{className:`text-left font-bold text-sm/6 flex items-center gap-2`,children:[e.name,e.isPremium&&(0,G.jsx)(Ji,{children:`Premium`})]}),e.description&&(0,G.jsx)(`dd`,{className:`text-left font-light`,children:e.description})]},e.name))})})]})})}),(0,G.jsx)(Q,{})]})})}function sp({className:e,...t}){let{formDescriptionId:n}=Lo();return(0,G.jsx)(`p`,{"data-slot":`form-description`,id:n,className:N(`text-muted-foreground text-sm`,e),...t})}function cp({className:e,form:t}){return(0,G.jsx)(Y,{control:t.control,name:`skipGtmWait`,render:({field:t})=>(0,G.jsxs)(X,{className:e,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`checkbox`,className:`w-4 h-4 cursor-pointer`,checked:t.value||!1,onChange:t.onChange,onBlur:t.onBlur,name:t.name,ref:t.ref})}),(0,G.jsx)(Z,{className:`cursor-pointer`,children:`Immediate upgrade and restart`})]}),(0,G.jsx)(sp,{children:`Apply changes immediately without waiting for each instance to be taken out of the load balancer (faster, but potentially less safe).`})]})})}function lp({className:e,disabled:t,form:n,harperVersions:r}){return r?.value?.length?(0,G.jsx)(Y,{control:n.control,name:`version`,render:({field:i})=>(0,G.jsxs)(X,{className:e,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Harper Version`}),(0,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(Kf,{}),children:(0,G.jsx)(J,{children:(0,G.jsxs)(qf,{...i,disabled:t,onValueChange:e=>{i.onChange(e),n.trigger()},children:[(0,G.jsx)(Xf,{className:`w-full h-auto`,children:(0,G.jsx)(Yf,{placeholder:`Choose Version`})}),(0,G.jsx)(Zf,{children:(0,G.jsx)(Jf,{children:r?.value.map(e=>(0,G.jsxs)($f,{value:e.version,children:[e.version,` `,(0,G.jsx)(`span`,{className:`font-light opacity-50`,children:e.name})]},e.version))})})]})})}),(0,G.jsx)(Q,{})]})}):null}var up=new RegExp(/^\d+/);function dp(e,t){let n=parseInt(e.match(up)?.[0]||`0`,10),r=parseInt(t.match(up)?.[0]||`0`,10);return n===r?0:n>r?1:-1}var fp=[`B`,`KB`,`MB`,`GB`,`TB`,`PB`,`EB`,`ZB`,`YB`],pp=[`secs`,`mins`,`hrs`],mp={bytes:1e3,secs:60};function hp(e,t,n){let r,i;switch(t){case`bytes`:r=fp,i=mp.bytes;break;case`secs`:r=pp,i=mp.secs;break;default:return e}let a=r.indexOf(n);return a===-1?e:e/i**a}function gp(e,t){let n,r;switch(e){case`bytes`:n=fp,r=mp.bytes;break;case`secs`:n=pp,r=mp.secs;break;default:return e}let i=0;for(;t>=r&&i<n.length-1;)t/=r,i++;return n[i]}function _p(e,t=1){let n=e*t,r=gp(`bytes`,n),i=hp(n,`bytes`,r);return`${new Intl.NumberFormat().format(Math.round(i))} ${r}`}function vp(e){return new Intl.NumberFormat().format(e)}var yp=[`K`,`M`,`B`,`T`,`Qa`,`Qi`,`Sx`,`Sp`,`Oc`,`No`,`Dc`];function bp(e){let t=1e3,n=e;if(Math.abs(n)<t)return String(Math.round(n));let r=-1;do n/=t,++r;while(Math.round(Math.abs(n)*10)/10>=t&&r<yp.length-1);return`${vp(Math.round(n))} ${yp[r]}`}function xp(e,t){let n=Object.values(t).flatMap(e=>Object.values(e)).map(e=>e.purchasedBlockMultiplier??1),r=Math.max(...n,1),i=Math.min(...n,r),a=t=>{let n=e.map(t).filter(e=>typeof e==`number`&&e>0);return n.length?{min:Math.min(...n),max:Math.max(...n)}:{min:0,max:0}},o=a(e=>e.planLimits?.readsPerMinuteCount),s=a(e=>e.planLimits?.totalReadCount);return{readRate:{min:o.min*i,max:o.max*r},totalReads:{min:s.min*i,max:s.max*r},writeRate:a(e=>e.planLimits?.writesPerMinuteCount),totalWrites:a(e=>e.planLimits?.totalWriteCount)}}function Sp(e,{min:t,max:n}){if(e<=0)return 0;let r=Math.max(Math.min(t,e),1),i=Math.max(n,e);if(i<=r)return 1;let a=(Math.log(e)-Math.log(r))/(Math.log(i)-Math.log(r));return Math.min(Math.max(a,0),1)}function Cp({selectedPlan:e,selectedRegion:t,usageScale:n,isEnterprise:r,cloudProvider:i}){let[a,o]=(0,W.useState)(!1),s=(0,W.useCallback)(()=>{o(!a)},[a,o]),c=e?.planLimits,l=e?.resourcesPerInstance,u=i&&e?.cloudInstanceTypes?.[i],d=yd(c?.expirationMonths)&&c.expirationMonths<1e3&&c.expirationMonths,f=t?.purchasedBlockMultiplier??1,p=(0,W.useMemo)(()=>c?[yd(c.totalReadCount)&&{label:`Total Reads`,value:bp(c.totalReadCount*f)},yd(c.totalReadsBytes)&&{label:`Total Read Transfer`,value:`${_p(c.totalReadsBytes*f)}`},yd(c.readsPerMinuteCount)&&{label:`Read Rate`,value:`${bp(c.readsPerMinuteCount*60*f)}/hr`},yd(c.readsPerMinuteBytes)&&{label:`Read Bandwidth`,value:`${_p(c.readsPerMinuteBytes*60*f)}/hr`},yd(c.totalWriteCount)&&{label:`Total Writes`,value:bp(c.totalWriteCount)},yd(c.totalWritesBytes)&&{label:`Total Write Transfer`,value:`${_p(c.totalWritesBytes)}`},yd(c.writesPerMinuteCount)&&{label:`Write Rate`,value:`${bp(c.writesPerMinuteCount*60)}/hr`},yd(c.writesPerMinuteBytes)&&{label:`Write Bandwidth`,value:`${_p(c.writesPerMinuteBytes*60)}/hr`},yd(c.totalRealTimeMessageDeliveries)&&{label:`Total Real-Time Messages`,value:`${bp(c.totalRealTimeMessageDeliveries*f)} messages`},yd(c.totalRealTimeMessageDeliveryBytes)&&{label:`Total Real-Time Message Transfer`,value:`${_p(c.totalRealTimeMessageDeliveryBytes*f)}`},yd(c.realTimeMessageDeliveriesPerMinute)&&{label:`Real-Time Message Rate`,value:`${bp(c.realTimeMessageDeliveriesPerMinute*60*f)}/hr`},yd(c.realTimeMessageDeliveryBytesPerMinute)&&{label:`Real-Time Message Bandwidth`,value:`${_p(c.realTimeMessageDeliveryBytesPerMinute*60*f)}/hr`},yd(c.tlsHandshakes)&&{label:`TLS Handshakes`,value:`${bp(c.tlsHandshakes*60*f)}`},yd(c.applicationComputeHours)&&{label:`Application Compute Hours`,value:`${bp(c.applicationComputeHours*f)}`},!!l&&yd(l.storageGb)&&{label:`Storage`,value:`${_p(l.storageGb*1e9)}`},!!l&&yd(l.cpuCores)&&{label:`Maximum CPU Cores`,value:`${bp(l.cpuCores)}`},!!l&&yd(l.memoryMb)&&{label:`Memory`,value:`${l.memoryMb/1024} GB`},!!u&&{label:`Cloud Instance Type`,value:u},!!d&&{label:`Expiration`,value:h(d,`month`,`months`)},!!t?.id&&{label:`Region ID`,value:t.id},!!e?.id&&{label:`Plan ID`,value:e.id}].filter(Qa):[],[d,t,e,f]);if(!c)return``;if(!yd(c.totalReadCount))return`This plan has no usage limits.`;let m=r?`for the contracted rate`:`for the price listed above`,g=d?` in ${h(d,`month`,`months`)} or`:``,_=yd(c.readsPerMinuteCount)?c.readsPerMinuteCount*f:0,v=yd(c.writesPerMinuteCount)?c.writesPerMinuteCount:0,y=c.totalReadCount*f,b=yd(c.totalWriteCount)?c.totalWriteCount:0,x=[_>0&&{icon:vr,label:`Read Rate`,value:`${bp(_)}/min`,fill:Sp(_,n.readRate)},y>0&&{icon:Bn,label:`Total Reads`,value:bp(y),fill:Sp(y,n.totalReads)},v>0&&{icon:vr,label:`Write Rate`,value:`${bp(v)}/min`,fill:Sp(v,n.writeRate)},b>0&&{icon:In,label:`Total Writes`,value:bp(b),fill:Sp(b,n.totalWrites)},!!d&&{icon:Gn,label:`License Term`,value:h(d,`month`,`months`)}].filter(Qa);return(0,G.jsxs)(X,{className:`basis-full`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-2`,children:[(0,G.jsx)(Z,{onClick:s,className:`cursor-pointer`,children:`Usage block included with this plan`}),(0,G.jsxs)(P,{type:`button`,variant:`link`,className:`text-foreground`,onClick:s,children:[`Learn More `,a?(0,G.jsx)(sn,{}):(0,G.jsx)(Rn,{})]})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-5`,children:x.map(e=>(0,G.jsx)(wp,{icon:e.icon,label:e.label,value:e.value,fill:e.fill},e.label))}),(0,G.jsx)(J,{children:(0,G.jsxs)(`dl`,{className:N(`divide-y divide-border rounded-md overflow-hidden transition-[max-height] duration-200 ease-in`,a?`max-h-fit border border-border`:`max-h-0`),children:[(0,G.jsxs)(`div`,{className:`text-sm px-4 py-5 leading-relaxed text-muted-foreground`,children:[`This plan licenses Harper for the usage limits below, `,m,`. The usage license expires`,g,` `,`when any usage limit is reached. New usage blocks are automatically purchased/billed as blocks are consumed.`]}),p.map((e,t)=>(0,G.jsxs)(`div`,{className:N(`px-4 py-1 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-3`,t%2==0&&`bg-muted dark:bg-grey-700`),children:[(0,G.jsx)(`dt`,{className:`text-sm/6 font-medium text-foreground`,children:e.label}),(0,G.jsx)(`dd`,{className:`mt-1 text-sm/6 text-muted-foreground sm:col-span-2 sm:mt-0`,children:e.value})]},e.label))]})}),(0,G.jsx)(Q,{})]})}function wp({icon:e,label:t,value:n,fill:r}){return(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-background/50 p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,G.jsx)(e,{className:`size-4 shrink-0`}),(0,G.jsx)(`span`,{className:`text-xs font-medium`,children:t})]}),(0,G.jsx)(`span`,{className:`text-lg font-bold text-foreground tabular-nums`,children:n}),r!==void 0&&(0,G.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-sky-500/15`,children:(0,G.jsx)(`div`,{className:`h-full rounded-full bg-sky-500 transition-[width] duration-300`,style:{width:`${Math.max(Math.min(r,1)*100,4)}%`}})})]})}function Tp({control:e,fieldArray:t,form:n,index:r,regionNameToLatencyToRegion:i,premiumOnlyRegions:a,usageScale:o,selectedPlan:s,isEnterprise:c,cloudProvider:l}){let u=(0,W.useMemo)(()=>Object.keys(i).sort(),[i]),d=n.watch(`deploymentDescription`)?.startsWith(`Dedicated`),f=n.watch(`regionPlans.${r}.regionName`),p=n.watch(`regionPlans.${r}.latencyDescription`),m=(0,W.useMemo)(()=>Object.keys(i[f]||{}).sort(dp).reverse(),[i,f]),h=s?.allowedRegionIds,g=(0,W.useCallback)(e=>!h?.length||Object.values(i[e]||{}).some(e=>h.includes(e.id)),[h,i]),_=(0,W.useCallback)(e=>{if(!h?.length)return!0;let t=i[f]?.[e]?.id;return!t||h.includes(t)},[h,i,f]);(0,W.useEffect)(function(){if(f&&m?.length&&!m?.includes(p)){let e=p?.split(` `)[0].toLowerCase(),t=m.find(t=>!e||t.split(` `)[0].toLowerCase()===e)||m[0];n.setValue(`regionPlans.${r}.latencyDescription`,t),n.trigger()}},[m,n,r,p,f]);let v=(0,W.useCallback)(()=>{t?.remove(r),n.trigger()},[t,n,r]);return(0,G.jsxs)(`div`,{className:`md:col-span-6 col-span-3 py-2 pl-4 border-l-4 border-border gap-6 flex flex-wrap items-start`,children:[(0,G.jsx)(Y,{control:e,name:`regionPlans.${r}.regionName`,render:({field:e})=>(0,G.jsxs)(X,{className:`flex-1`,children:[(0,G.jsxs)(Z,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(Ir,{className:`size-4 shrink-0`}),`Region `,t.fields.length>1?r+1:``]}),(0,G.jsx)(J,{children:(0,G.jsxs)(qf,{onValueChange:t=>{e.onChange(t),n.trigger()},...e,children:[(0,G.jsx)(Xf,{className:`w-full`,children:(0,G.jsx)(Yf,{placeholder:`Choose Region`})}),(0,G.jsx)(Zf,{children:(0,G.jsx)(Jf,{children:u.map(e=>(0,G.jsx)($f,{value:e,disabled:!g(e),children:(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e,a.regionNames.has(e)&&(0,G.jsx)(Ji,{children:`Premium`})]})},e))})})]})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:e,name:`regionPlans.${r}.latencyDescription`,render:({field:e})=>(0,G.jsxs)(X,{className:`flex-1`,children:[(0,G.jsxs)(Z,{children:[`Estimated `,d?`P95`:`P90`,` Latency, Distribution`]}),(0,G.jsx)(J,{children:(0,G.jsxs)(qf,{onValueChange:t=>{e.onChange(t),n.trigger()},...e,disabled:!m?.length,children:[(0,G.jsx)(Xf,{className:`w-full`,children:(0,G.jsx)(Yf,{placeholder:`Choose Latency Tier`})}),(0,G.jsx)(Zf,{children:(0,G.jsx)(Jf,{children:m.map(e=>(0,G.jsx)($f,{value:e,disabled:!_(e),children:(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e,(()=>{let t=i[f]?.[e]?.id;return t&&a.regionIds.has(t)&&(0,G.jsx)(Ji,{children:`Premium`})})()]})},e))})})]})}),(0,G.jsx)(Q,{})]})}),t?.fields?.length&&t?.fields?.length>1&&(0,G.jsx)(`div`,{className:`flex-none mt-6`,children:(0,G.jsxs)(P,{type:`button`,variant:`destructiveOutline`,size:`sm`,onClick:v,children:[(0,G.jsx)(fi,{}),` `,(0,G.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})}),(0,G.jsx)(Cp,{selectedPlan:s,selectedRegion:i[f]?.[p],usageScale:o,isEnterprise:c,cloudProvider:l})]})}function Ep({form:e,regionLocations:t,regionNameToLatencyToRegion:n,premiumOnlyRegions:r,usageScale:i,selectedPlan:a,totalPrice:o,isEnterprise:s,cloudProvider:c}){let l=e.watch(`regionPlans`),u=Wt({control:e.control,name:`regionPlans`}),d=(0,W.useMemo)(()=>{let e=l.map(e=>n?.[e.regionName]?.[e.latencyDescription]?.region);return o?t?.find(t=>!e.includes(t.region)):null},[t,n,l,o]),f=(0,W.useCallback)(()=>{d&&(u.append({regionName:d.region,latencyDescription:d.latencyDescription}),e.trigger())},[e,d,u]);return t?.length?(0,G.jsxs)(G.Fragment,{children:[u.fields.map((t,o)=>(0,G.jsx)(Tp,{control:e.control,fieldArray:u,form:e,index:o,regionNameToLatencyToRegion:n,premiumOnlyRegions:r,usageScale:i,selectedPlan:a,isEnterprise:s,cloudProvider:c},t.id)),d&&(0,G.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,G.jsxs)(P,{type:`button`,variant:`positiveOutline`,onClick:f,children:[(0,G.jsx)(Gr,{}),`Add Additional Region Usage`]})})]}):(0,G.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,G.jsx)(vi,{className:`mt-0 m-0`,title:`No Regions Available`,showReturnToHome:!1,error:{message:(0,G.jsxs)(G.Fragment,{children:[`The deployment type you selected currently has no available regions. Please try a different deployment type, try again later, or `,(0,G.jsx)(_s,{}),`.`]})}})})}function Dp({control:e,fieldArray:t,form:n,index:r}){let a=(0,W.useCallback)(()=>{t?.remove(r)},[t,r]);return(0,G.jsxs)(`div`,{className:`md:col-span-6 col-span-3 p-4 rounded-md bg-accent gap-6 flex flex-wrap items-start`,children:[(0,G.jsx)(Y,{control:e,name:`instances.${r}.secure`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsxs)(Z,{children:[`Instance `,t.fields.length>1?r+1:``]}),(0,G.jsx)(J,{children:(0,G.jsxs)(qf,{...e,onValueChange:t=>{e.onChange(t),n.trigger()},children:[(0,G.jsx)(Xf,{className:`w-full`,children:(0,G.jsx)(Yf,{placeholder:`https://`})}),(0,G.jsx)(Zf,{children:(0,G.jsxs)(Jf,{children:[(0,G.jsx)($f,{value:`true`,children:`https://`}),(0,G.jsx)($f,{value:`false`,children:`http://`})]})})]})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:e,name:`instances.${r}.fqdn`,render:({field:e})=>(0,G.jsxs)(X,{className:`flex-3`,children:[(0,G.jsx)(Z,{children:`Host Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{...e,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,onChange:t=>{e.onChange(t);let i=t.target.value,a=i===`localhost`||i===`127.0.0.1`,o=n.getFieldState(`instances.${r}.secure`);a&&!o.isDirty&&n.setValue(`instances.${r}.secure`,`false`)}})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:e,name:`instances.${r}.port`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Operations API Port`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{...e,type:`number`,min:0,max:Hf,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:String(i),onChange:t=>{e.onChange(t.target.value?parseInt(t.target.value,10):void 0),n.trigger()}})}),(0,G.jsx)(Q,{})]})}),t?.fields?.length&&t?.fields?.length>1&&(0,G.jsx)(`div`,{className:`flex-none mt-6`,children:(0,G.jsxs)(P,{type:`button`,variant:`destructiveOutline`,size:`sm`,onClick:a,children:[(0,G.jsx)(fi,{}),` `,(0,G.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})})]})}function Op({form:e}){let t=Wt({control:e.control,name:`instances`}),n=(0,W.useCallback)(()=>{t.append({secure:`true`,fqdn:``,port:i})},[t]);return(0,G.jsxs)(G.Fragment,{children:[t.fields.map((n,r)=>(0,G.jsx)(Dp,{control:e.control,fieldArray:t,form:e,index:r},n.id)),(0,G.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,G.jsxs)(P,{type:`button`,variant:`positiveOutline`,onClick:n,children:[(0,G.jsx)(Gr,{}),`Add Instance`]})})]})}function kp(e,t){return!e.allowedRegionIds?.length||e.allowedRegionIds.includes(t)}function Ap(e,t){let n=new Set,r=new Set;if(!e.length)return{regionNames:n,regionIds:r};let i=Math.min(...e.map(e=>e.planLevel??0)),a=e.filter(e=>(e.planLevel??0)===i),o=e.filter(e=>(e.planLevel??0)>i);if(!o.length)return{regionNames:n,regionIds:r};for(let[e,i]of Object.entries(t)){let t=!1,s=!0;for(let e of Object.values(i)){let n=a.some(t=>kp(t,e.id)),i=o.some(t=>kp(t,e.id));!n&&!i||(t=!0,n?s=!1:r.add(e.id))}t&&s&&n.add(e)}return{regionNames:n,regionIds:r}}function jp({calculatedNames:e,clusterId:t,deploymentToPerformanceToPlan:n,form:r,harperVersions:i,isEnterprise:a,cloudProvider:o,isPending:s,mode:c,partialUpgrade:l,regionLocations:u,regionNameToLatencyToRegion:d,selectedDeployment:f,selectedPerformance:p,selectedPlan:m,totalPrice:h}){let{isDirty:g,isValid:_}=Ht(),v=(0,W.useMemo)(()=>{let e=n[f]||{},t=Object.values(e).map(e=>e.planLevel??0),r=t.length?Math.min(...t):0;return Object.keys(e).map(t=>{let n=(e[t].planLevel??0)>r,i=t.slice(0,-1).split(`(`);if(i.length>1)return{performanceTier:t,name:i[0],description:i[1],isPremium:n};let a=t.split(` for `);return a.length>1?{performanceTier:t,name:a[0],description:`For `+a[1],isPremium:n}:{performanceTier:t,name:t,description:``,isPremium:n}})},[n,f]),y=(0,W.useMemo)(()=>Object.keys(n).sort(),[n]),b=(0,W.useMemo)(()=>Ap(Object.values(n[f]||{}),d),[n,d,f]),x=(0,W.useMemo)(()=>xp(Object.values(n).flatMap(e=>Object.values(e)),d),[n,d]);(0,W.useEffect)(function(){v?.length&&!v.find(e=>e.performanceTier===p)&&(r.setValue(`performanceDescription`,v[0].performanceTier),r.trigger())},[f,p,v,r]);let S=f===`Self-Hosted`,C=(0,G.jsx)(on,{className:`mt-3 mb-12`,children:(0,G.jsxs)(P,{type:`submit`,variant:`submit`,disabled:s||t&&!g&&!(c===`version`&&l)||!_,children:[c!==`version`&&h>0?`Confirm Payment Details`:t?`Edit Cluster`:`Create New Cluster`,(0,G.jsx)(Rn,{})]})});return c===`version`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-3 items-start gap-6 text-foreground md:grid-cols-6`,children:[(0,G.jsx)(ap,{className:i?.value?.length?`col-span-3`:`md:col-span-6 col-span-3`,disabled:!0,form:r}),(0,G.jsx)(lp,{className:`col-span-3`,form:r,harperVersions:i}),(0,G.jsx)(cp,{className:`col-span-3 md:col-span-6`,form:r}),l&&(0,G.jsxs)(`p`,{className:`col-span-3 md:col-span-6 max-w-prose text-xs font-light text-amber-600 dark:text-amber-400`,children:[l.behindCount,` of `,l.total,` instances`,` `,l.behindCount===1?`is`:`are`,` still on an older version. Re-run the upgrade to bring`,` `,l.behindCount===1?`it`:`them`,` up to `,l.latest,`.`]})]}),C]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-3 items-start gap-6 text-foreground md:grid-cols-6`,children:[(0,G.jsx)(ap,{className:i?.value?.length?`col-span-3`:`md:col-span-6 col-span-3`,disabled:!!t,form:r}),(0,G.jsx)(lp,{className:`col-span-3`,disabled:!!t,form:r,harperVersions:i}),S?(0,G.jsx)(ip,{form:r,disabled:!!t}):(0,G.jsx)(Gf,{form:r,calculatedNames:e,disabled:!!t}),(0,G.jsx)(rp,{form:r,availableDeploymentTypes:y}),(0,G.jsx)(op,{availablePerformanceDescriptions:v,form:r,selectedDeployment:f}),S?(0,G.jsx)(Op,{form:r}):(0,G.jsx)(Ep,{form:r,regionLocations:u,regionNameToLatencyToRegion:d,premiumOnlyRegions:b,usageScale:x,selectedPlan:m,totalPrice:h,isEnterprise:a,cloudProvider:o}),t&&!S&&(0,G.jsx)(cp,{className:`col-span-3 md:col-span-6`,form:r})]}),C]})}function Mp(e){let{fqdn:t}=e,{secure:n,port:r}=e;return r||=i,r===443&&n===`false`&&(n=`true`),r===80&&n===`true`&&(n=`false`),`${n===`true`?`https`:`http`}://${t}${r===443||r===80?``:`:`+r}`.toLowerCase()}function Np(e,t,n){let r=e.find(e=>(n?!!e.priceUsd:!e.priceUsd)&&e.deploymentType===`colocated`)||e.find(e=>e.deploymentType===`colocated`)||e[0],i=r?.allowedRegionIds;if(r){let e=i?t.filter(e=>i.includes(e.id)):t,n=e.find(e=>e.region===`US`)||e[0];if(n)return{deploymentDescription:r.deploymentDescription,performanceDescription:r.performanceDescription,regionPlans:[{regionName:n.region,latencyDescription:n.latencyDescription}]}}return null}function Pp(e,t,n){if(t&&n){let r=e.getValues();if(!r.deploymentDescription||!r.performanceDescription||!r.regionPlans.length){let i=Np(t,n);i&&(!r.deploymentDescription&&!r.performanceDescription&&(e.setValue(`deploymentDescription`,i.deploymentDescription),e.setValue(`performanceDescription`,i.performanceDescription)),r.regionPlans.length||e.setValue(`regionPlans`,i.regionPlans))}}}function Fp({price:e}){let t=new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).formatToParts(e||0);return(0,G.jsx)(`span`,{className:`text-4xl`,children:t.map((e,t)=>(0,G.jsx)(Ip,{type:e.type,value:e.value},t))})}function Ip({type:e,value:t}){switch(e){case`currency`:case`decimal`:case`fraction`:return(0,G.jsx)(`sup`,{className:`font-light text-xl`,children:t});default:return t}}function Lp({alreadyUsingFree:e,clusterId:t,defaultValues:n,deploymentToPerformanceToPlan:r,harperVersions:a,mode:o,organization:s,organizationId:c,partialUpgrade:l,planTypes:u,regionLocationsColocated:d,regionLocationsDedicated:f,setSavedClusterState:p,startOffOnBilling:m}){let g=I(),_=pe(),v=s?.type===hd,b=s?.channel===`Akamai`?`linode`:void 0,x=Ie(),{mutate:S,isPending:C}=ld(),{mutate:w,isPending:T}=dd(),[E,D]=(0,W.useState)(m),O=(0,W.useMemo)(()=>ad(d?.sort($u(`latencyDescription`))||[],`region`,`latencyDescription`),[d]),k=(0,W.useMemo)(()=>ad(f?.sort($u(`latencyDescription`))||[],`region`,`latencyDescription`),[f]),A=(0,W.useCallback)((t,n)=>{let i=new Set,a=r?.[t.deploymentDescription]?.[t.performanceDescription];if(t.deploymentDescription===`Self-Hosted`)for(let e=0;e<t.instances.length;e++){let r=Mp(t.instances[e]);i.has(r)?n.addIssue({code:`custom`,path:[`instances.${e}.fqdn`],message:`Every instance url must be unique!`}):i.add(r)}else{a?.priceUsd===0&&e&&n.addIssue({code:`custom`,path:[`performanceDescription`],message:`Only one free cluster is allowed per organization.`});let r=a?.deploymentDescription===`Dedicated`?k:O;for(let e=0;e<t.regionPlans.length;e++){let o=t.regionPlans[e],s=r[o.regionName]?.[o.latencyDescription];i.has(o.regionName)?n.addIssue({code:`custom`,path:[`regionPlans.${e}.regionName`],message:`You can only select a region once!`}):i.add(o.regionName),a?.allowedRegionIds?.length&&s?.id&&(a.allowedRegionIds.includes(s.id)?e>=1&&n.addIssue({code:`custom`,path:[`regionPlans.${e}.regionName`],message:`You can only select one region with this performance tier!`}):_d(a.allowedRegionIds,s.id)?n.addIssue({code:`custom`,path:[`regionPlans.${e}.latencyDescription`],message:`This latency is not available with the selected performance tier!`}):n.addIssue({code:`custom`,path:[`regionPlans.${e}.regionName`],message:`This region is not available with the selected performance tier!`}))}}},[e,O,k,r]),j=Pt({mode:`onChange`,resolver:Ke(Wf.superRefine(A)),defaultValues:n}),[ee,M]=(0,W.useState)(!0);(0,W.useEffect)(()=>{ee&&n&&(p(null),M(!1))},[n,ee,p]);let N=j.watch(`clusterName`),P=j.watch(`abbreviatedName`),te=j.watch(`deploymentDescription`),ne=j.watch(`performanceDescription`),re=j.watch(`regionPlans`),ie=j.watch(`instances`),ae=te===`Dedicated`?k:O,oe=te===`Dedicated`?f:d;(0,W.useEffect)(function(){let e=j.getValues();te&&(te===`Self-Hosted`?(e.abbreviatedName&&j.setValue(`abbreviatedName`,``),e.regionPlans.length&&j.setValue(`regionPlans`,[]),e.instances.length||j.setValue(`instances`,[{secure:`true`,fqdn:``,port:i}])):(e.fqdn&&j.setValue(`fqdn`,``),e.instances.length&&j.setValue(`instances`,[]),e.regionPlans.length||Pp(j,u,oe)))},[j,u,oe,te]);let se=(0,W.useMemo)(()=>{let e=gd(vd(N),Uf.maxLength);return{suggestedAbbreviatedName:e,fullHostName:`${P||e}.${s.subdomain||`your-org`}.harperfabric.com`}},[N,P,s]),F=(0,W.useMemo)(()=>r?.[te]?.[ne],[r,te,ne]);(0,W.useEffect)(function(){let e=F?.allowedRegionIds;if(e?.length&&re?.length===1){let t=re[0],n=ae?.[t.regionName]?.[t.latencyDescription];if(!e.includes(n?.id)){let t=oe?.filter(t=>e.includes(t.id)),n=t?.find(e=>e.region===`US`)||t?.[0];n&&(j.setValue(`regionPlans.0.regionName`,n.region),j.setValue(`regionPlans.0.latencyDescription`,n.latencyDescription),j.trigger())}}},[F,re,j,ae,oe]),(0,W.useEffect)(function(){if(te!==`Self-Hosted`&&Object.keys(ae).length&&re.length)for(let e=0;e<re.length;e++){let t=re[e];ae[t.regionName]||j.setValue(`regionPlans.${e}.regionName`,``)}},[j,ae,te,re]);let ce=F?.priceUsd?te===`Self-Hosted`?ie.length*F.priceUsd:re.reduce((e,t)=>{let n=ae?.[t.regionName]?.[t.latencyDescription];return e+(n?F.priceUsd*n.instanceCount/2:0)},0):0,le=F?.planLimits?.expirationMonths,ue=yd(le)&&le<1e3?le:void 0,de=ue?ce/ue:ce,L=(0,W.useCallback)(({creating:e,deploymentDescription:t})=>H.message(e?`Creating Cluster`:`Updating Cluster`,{description:(0,G.jsx)(sd,{message:`This may take a little bit, hold tight!`,lateMessage:`Still working on it... why don't you grab a coffee, and I'll let you know when it's done?`,duration:t===`Dedicated`?6e4:5e3}),duration:0}),[]),fe=(0,W.useCallback)(async({clusterId:e,sourceClusterId:t,creating:n,toastId:r,isSelfManaged:i,skipGtmWait:a})=>{if(t){let e=(await pd(c)).clusters?.find(e=>e.id===t);Jo(e?.status)&&await ju(t)}x.invalidateQueries({queryKey:[c],refetchType:`active`}),n||bd(x,e,{refetchType:`active`}),_.invalidate(),g(i?{to:`/${c}/${e}/instances`}:n?{to:`/${c}/${e}/starting-up`}:{to:`/${c}/${e}/scaling`,search:a?{immediate:!0}:void 0}),j.reset(),H.success(n?`Cluster Created`:`Cluster Updated`,{id:r,description:i?void 0:n?`It is being provisioned now.`:`The updates are being provisioned now.`,duration:5e3})},[x,_,g,c,j]),R=(0,W.useCallback)(async()=>{let e=j.getValues(),n=[],i=r[e.deploymentDescription][e.performanceDescription],a=e.deploymentDescription===`Self-Hosted`;if(a)for(let t of e.instances)n.push({autoRenew:!0,instanceFqdn:t.fqdn,operationsApiPort:t.port||9925,operationsApiSecure:t.secure===`true`,planId:i.id});else for(let t of e.regionPlans){let e=ae[t.regionName][t.latencyDescription];n.push({autoRenew:!0,planId:i.id,regionId:e.id})}p(null);let s=L({creating:!t,deploymentDescription:e.deploymentDescription}),l=()=>H.dismiss(s);t?w(o===`version`?{id:t,version:e.version,skipGtmWait:e.skipGtmWait}:{id:t,regionPlans:n,skipGtmWait:e.skipGtmWait},{onSuccess:t=>fe({clusterId:t.id,sourceClusterId:e.sourceClusterId,isSelfManaged:a,creating:!1,toastId:s,skipGtmWait:e.skipGtmWait}),onError:l}):S({abbreviatedName:a?void 0:e.abbreviatedName||se.suggestedAbbreviatedName,autoRenew:!0,fqdn:a&&e.fqdn||void 0,name:e.clusterName,version:e.version,organizationId:c,regionPlans:n},{onSuccess:t=>fe({clusterId:t.id,sourceClusterId:e.sourceClusterId,isSelfManaged:a,creating:!0,toastId:s}),onError:l})},[se.suggestedAbbreviatedName,t,r,j,fe,L,c,ae,p,w,S]),me=(0,W.useCallback)(()=>{if(o!==`version`&&ce>0){D(!0);return}return R()},[o,R,ce]),he=(0,W.useCallback)(e=>{p(e?{clusterId:t,...j.getValues(),skipToBilling:!0}:null)},[t,j,p]),ge=(0,W.useCallback)(()=>{D(!1)},[]),_e=!v&&`mr-37.5`;return(0,G.jsxs)(G.Fragment,{children:[!v&&o!==`version`&&(0,G.jsxs)(`div`,{className:`absolute top-3 right-4 md:right-12 flex flex-col items-end text-right`,children:[(0,G.jsx)(`dt`,{className:`font-light`,children:ue?`Monthly Price`:`Total Price`}),(0,G.jsx)(`dd`,{className:`font-bold`,children:ce>0?(0,G.jsxs)(`span`,{className:`inline-flex items-baseline`,children:[(0,G.jsx)(Fp,{price:de}),!!ue&&(0,G.jsxs)(`span`,{className:`font-light text-base text-muted-foreground`,children:[`/mo`,ue>1&&(0,G.jsx)(`sup`,{children:`*`})]})]}):(0,G.jsx)(`span`,{className:`text-4xl text-green`,children:`Free`})})]}),(0,G.jsx)(q,{...j,children:E?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h1`,{className:y(`text-lg leading-none text-foreground font-semibold mb-4`,_e),children:`Cluster Billing`}),(0,G.jsx)(`p`,{className:y(`text-muted-foreground text-sm mb-2`,_e),children:`Please confirm the following billing details:`}),(0,G.jsx)(Bf,{clusterId:t,isPending:C||T,onGoBackToDetails:ge,onSaveStateForBillingRedirect:he,onSubmit:R,organizationId:c,selectedPlan:F})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h1`,{className:y(`text-lg leading-none text-foreground font-semibold mb-4`,_e),children:`Cluster Configuration`}),(0,G.jsxs)(`div`,{className:y(`mb-6 flex flex-col items-start gap-2`,_e),children:[(0,G.jsx)(`p`,{className:`sr-only`,children:`Configure your Harper cluster and define deployment plans.`}),!v&&o!==`version`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ji,{variant:`warning`,children:`Beta pricing subject to change.`}),!!ue&&ue>1&&ce>0&&(0,G.jsxs)(`p`,{className:`max-w-prose text-xs font-light text-muted-foreground`,children:[`* Billed as`,` `,new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).format(ce),` `,`every`,` `,h(ue,`month`,`months`),`, or sooner if you reach a usage limit — then a new license is issued.`]})]})]}),(0,G.jsx)(`form`,{id:`cluster-upsert-form`,name:`cluster-upsert-form`,onSubmit:j.handleSubmit(me),children:(0,G.jsx)(jp,{calculatedNames:se,clusterId:t,deploymentToPerformanceToPlan:r,form:j,isPending:C||T,harperVersions:a,mode:o,partialUpgrade:l,regionLocations:oe,regionNameToLatencyToRegion:ae,selectedDeployment:te,selectedPerformance:ne,selectedPlan:F,totalPrice:ce,isEnterprise:v,cloudProvider:b})})]})})]})}function Rp(e){return e?.clusterName!==void 0}function zp(e){let t=e.filter(e=>!!e&&!(e.status!=null&&Bo.includes(e.status))).map(e=>e.version).filter(e=>!!e);if(t.length<2)return null;let n=t.reduce((e,t)=>Jc(t,e)>0?t:e),r=t.filter(e=>e!==n).length;return r>0?{latest:n,behindCount:r,total:t.length}:null}function Bp({isEdit:e,className:t,children:n}){return e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Fc,{}),(0,G.jsx)(Uu,{children:(0,G.jsx)(`div`,{className:t,children:n})})]}):(0,G.jsx)(Hu,{className:t,children:n})}function Vp(){let{organizationId:e,clusterId:t,mode:n}=z({strict:!1}),{create:r,update:i}=du(e),{organization:a,cluster:o}=ye({strict:!1}),[s,c]=xn(vn.SavedClusterState,null),{data:l}=V(Gu(e)),{data:u}=V(Qu({availableHosts:!0,organizationId:e})),{data:d}=V(Qu({organizationId:e})),{data:f}=V(Xu(e)),p=(0,W.useMemo)(()=>{if(o){let e=o.instances?.map(e=>e.version).filter(Qa);if(f&&e){let t=[...e].sort(Jc).pop(),n=new Set(e);return{...f,value:[!!t&&{name:`current`,version:t},...(f?.value||[]).filter(e=>!n.has(e.version)&&(!t||qc(t,e.version)))].filter(Qa)}}}return f},[f,o]),m=(0,W.useMemo)(()=>zp(o?.instances??[]),[o]),h=(0,W.useMemo)(()=>{for(let e of a?.clusters??[])if(e.id!==o?.id&&l&&!Yo(e.status)&&!Jo(e.status)&&e.plans)for(let t of e.plans){let e=l.find(e=>e.id===t.planId);if(e?.priceUsd===0&&!e.id.startsWith(`self-hosted`))return!0}return!1},[o?.id,a?.clusters,l]),g=(0,W.useMemo)(()=>ad(l?.sort($u(`priceUsd`))||[],`deploymentDescription`,`performanceDescription`),[l]),_=(0,W.useMemo)(()=>{if(!l||!p||!u||!d||t&&!o)return null;let e=o;if(s){if(Rp(s))return{...s,clusterName:s.clusterName||``,abbreviatedName:s.abbreviatedName||``,version:s.version,deploymentDescription:s.deploymentDescription||``,performanceDescription:s.performanceDescription||``,fqdn:s.fqdn||``,regionPlans:s.regionPlans||[],instances:s.instances||[]};e=s}let n=l?.find(e=>e.id===o?.plans?.[0].planId),r=[],i=[],a=n?.deploymentDescription===`Dedicated`?d:u,c=Np(l,a,h),f=!1;if(e){if(e.plans){for(let t of e.plans)if(t.regionId){let e=a.find(e=>e.id===t.regionId);e&&r.push({regionName:e.region,latencyDescription:e.latencyDescription})}}if(!r.length&&e.instances){let t=e.instances.filter(e=>e.status&&!Bo.includes(e.status)).sort(nd);for(let e of t)f=!0,i.push({fqdn:e.instanceFqdn,port:e.operationsApiPort,secure:e.operationsApiSecure?`true`:`false`})}}else c&&r.push(...c.regionPlans);!f&&!r.length&&r.push({regionName:``,latencyDescription:``});let m=p.value?.find(e=>e.name===`current`)?.version??p.value?.find(e=>e.name===`stable`)?.version;return{sourceClusterId:e?.id,autoRenew:e?.plans?.[0]?.autoRenew??!0,clusterName:e?.name??``,abbreviatedName:e?.abbreviatedName??``,version:m,deploymentDescription:n?.deploymentDescription??c?.deploymentDescription??``,performanceDescription:n?.performanceDescription??c?.performanceDescription??``,fqdn:f?e?.fqdn??``:``,instances:i,regionPlans:r}},[h,o,t,l,p,u,d,s]);return!_||!a||!l||!u||!d?(0,G.jsx)(Bp,{isEdit:!!t,children:(0,G.jsx)(Wi,{centered:!0,text:`Loading...`})}):(o?.id?!i:!r)?(0,G.jsx)(Bp,{isEdit:!!t,children:(0,G.jsx)(vi,{title:`Not Allowed`,error:{message:(0,G.jsxs)(G.Fragment,{children:[`You do not have permission to `,o?.id?`update`:`create`,` clusters in this org.`]})}})}):l.length===0?(0,G.jsx)(Bp,{isEdit:!!t,children:(0,G.jsx)(vi,{title:`Cluster ${t?`Modification`:`Creation`} Not Currently Allowed`,error:{message:(0,G.jsxs)(G.Fragment,{children:[`There are no available deployment types right now! Please try again later, or `,(0,G.jsx)(_s,{}),`.`]})}})}):(0,G.jsx)(Bp,{isEdit:!!t,className:`max-w-4xl mx-auto`,children:(0,G.jsx)(Lp,{alreadyUsingFree:h,clusterId:t,defaultValues:_,deploymentToPerformanceToPlan:g,harperVersions:p,mode:n,organization:a,organizationId:e,partialUpgrade:m,planTypes:l,regionLocationsColocated:u,regionLocationsDedicated:d,setSavedClusterState:c,startOffOnBilling:Rp(s)&&s.skipToBilling===!0})})}function Hp({children:e}){let{organizationId:t}=z({strict:!1}),{view:n}=lu(t),{update:r}=su(t),i=`/${t}`,a=[{to:i,label:`Clusters`,icon:$r,exact:!0},n&&{to:`${i}/users`,label:`Users`,icon:gi},n&&{to:`${i}/roles`,label:`Roles`,icon:ti},r&&{to:`${i}/billing`,label:`Billing`,icon:cr,children:[{to:`${i}/billing`,label:`Payment Method`,exact:!0},{to:`${i}/billing/invoices`,label:`Invoices`}]},r&&{to:`${i}/settings`,label:`Settings`,icon:ei}].filter(Boolean);return(0,G.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,G.jsxs)(`div`,{className:`md:grid gap-6 md:grid-cols-12`,children:[(0,G.jsx)(`aside`,{className:`md:col-span-3 lg:col-span-2 mb-4 md:mb-0`,children:(0,G.jsx)(zi,{items:a,ariaLabel:`Organization sections`})}),(0,G.jsx)(`section`,{className:`md:col-span-9 lg:col-span-10 min-w-0`,children:e})]})})}var Up={FAILED:0,UPDATING:1,PROVISIONING:2,RUNNING:3,TERMINATED:4},Wp=Up.RUNNING;function Gp(e,t){return e.status===t.status?e.name.localeCompare(t.name):(e.status?Up[e.status]??Wp:Wp)-(t.status?Up[t.status]??Wp:Wp)}function Kp(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 qp(){let{organizationId:e}=z({strict:!1}),{create:t}=du(e),{data:n,isSuccess:r}=_e(md(e)),[i]=xn(vn.SavedClusterState,null),[a,o]=(0,W.useState)(``),s=(0,W.useCallback)(()=>o(``),[]),c=(0,W.useCallback)(e=>{o(e.currentTarget.value?.toLowerCase()||``)},[]),l=(0,W.useMemo)(()=>n?.clusters?.slice().filter(e=>!Yo(e.status)).sort(Gp)||[],[n?.clusters]),u=(0,W.useMemo)(()=>l.filter(Kp([`id`,`name`],a))||[],[a,l]);return n&&l.length===0&&t?(0,G.jsx)(Vp,{}):i?(0,G.jsx)(ce,{to:`/${e}/new-cluster`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Fc,{children:r&&t&&(0,G.jsx)(`div`,{className:`flex w-full justify-end`,children:(0,G.jsx)(B,{to:`new-cluster`,children:(0,G.jsxs)(P,{variant:`positive`,accessKey:`n`,children:[(0,G.jsx)(Gr,{}),` `,(0,G.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,G.jsx)(`u`,{children:`N`}),`ew `,(0,G.jsx)(`span`,{className:`hidden md:inline-block`,children:`Cluster`})]})]})})})}),(0,G.jsxs)(Hp,{children:[(0,G.jsxs)(`div`,{className:`relative mb-6 w-full`,children:[(0,G.jsx)(Qr,{className:`pointer-events-none absolute left-0 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,G.jsx)($,{placeholder:`Filter by name`,className:`w-full rounded-none border-0 border-b border-border bg-transparent dark:bg-transparent pl-6 shadow-none focus-visible:border-primary focus-visible:ring-0`,value:a,onChange:c})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-9 mb-4`,children:[u.map(e=>(0,G.jsx)(`div`,{className:`col-span-1 md:col-span-3 xl:col-span-3 2xl:col-span-2`,children:(0,G.jsx)(Vu,{cluster:e})},e.id)),!u.length&&(0,G.jsxs)(`div`,{className:`col-span-1 md:col-span-9 text-center`,children:[(0,G.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,G.jsx)(P,{type:`button`,variant:`outline`,onClick:s,children:`Clear Filters`})]})]})]})]})}function Jp(){return`/#`+co()}function Yp(){let{organizationId:e}=z({strict:!1}),t=I(),n=new URLSearchParams(window.location.search).get(`setup_intent_client_secret`),{setup_intent_client_secret:r}=he({strict:!1}),[i]=xn(vn.SavedClusterState,null),a=n||r,o=sf(),s=Cd(e),c=(0,W.useCallback)(()=>{let e=i?i.clusterId?`../../${i.clusterId}/edit`:`../../new-cluster`:`../`;window.history.replaceState(null,``,Jp()),t({search:void 0,to:e})},[t,i]);return(0,W.useEffect)(()=>{!o||!a||!s||!e||!c||(async function(){try{let{setupIntent:e}=await o.retrieveSetupIntent(a);switch(e?.status){case`succeeded`:e.payment_method===null?(H.error(`Failed to process payment method details. Please try another payment method.`),c()):s(e.payment_method,c);break;case`processing`:H.warning(`Processing payment method. Please check back later.`),c();break;case`requires_payment_method`:H.error(`Failed to process payment method details. Please try another payment method.`),c();break;default:H.error(`Failed to process payment method details. Please try another payment method.`),c()}}catch(e){console.error(e),H.error(`Failed to process payment method details. Please try another payment method.`),c()}})()},[a,c,e,s,o]),(0,G.jsx)(Wi,{centered:!0})}function Xp(){return(0,G.jsx)(Nf,{children:(0,G.jsx)(Yp,{})})}function Zp(){let{organizationId:e}=z({strict:!1}),{update:t}=su(e);return t?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Fc,{}),(0,G.jsx)(Hp,{children:(0,G.jsx)(He,{})})]}):(0,G.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:`You don't have access to manage payments for this organization. Please contact your administrator.`})}var Qp=500,$p=16,em=16;function tm({className:e,containerClassName:t,containerRef:n,...r}){return(0,G.jsx)(`div`,{ref:n,"data-slot":`table-container`,className:N(`relative w-full overflow-x-auto`,t),children:(0,G.jsx)(`table`,{"data-slot":`table`,className:N(`w-full caption-bottom text-sm`,e),...r})})}function nm({className:e,...t}){return(0,G.jsx)(`thead`,{"data-slot":`table-header`,className:N(`[&_tr]:border-b`,e),...t})}function rm({className:e,...t}){return(0,G.jsx)(`tbody`,{"data-slot":`table-body`,className:N(`[&_tr:last-child]:border-0`,e),...t})}function im({className:e,...t}){return(0,G.jsx)(`tr`,{"data-slot":`table-row`,className:N(`border-b border-grey-700 transition-colors`,e),...t})}function am({className:e,...t}){return(0,G.jsx)(`th`,{"data-slot":`table-head`,className:N(`h-10 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function om({header:e,onColumnClick:t,className:n,...r}){let i=(0,W.useCallback)(()=>{e.column.toggleSorting(e.column.getIsSorted()===`asc`);let n=e.column.getIsSorted()===!1||e.column.getIsSorted()!==`asc`;t?.(e.column.columnDef.accessorKey,n)},[e,t]),a=e.column.columnDef.enableSorting,o=e.getContext().table.options.enableColumnResizing===!0&&e.column.getCanResize(),s=e.isPlaceholder?null:Me(e.column.columnDef.header,e.getContext()),c=e.getContext().table,l=e.getSize(),u=e.column.columnDef.minSize??c.options.defaultColumn?.minSize??20,d=(0,W.useCallback)(t=>{let n=t.currentTarget.closest(`table`);if(!n){e.column.resetSize();return}let r=`[data-col-id="${CSS.escape(e.column.id)}"]`,i=document.createRange(),a=e=>(i.selectNodeContents(e),i.getBoundingClientRect().width),o=0;n.querySelectorAll(`tbody ${r}`).forEach(e=>{o=Math.max(o,a(e))});let s=n.querySelector(`thead ${r} > div`),l=s?.querySelector(`.truncate`);if(s&&l){let e=Array.from(s.children).reduce((e,t)=>e+t.getBoundingClientRect().width,0)-l.getBoundingClientRect().width;o=Math.max(o,a(l)+e+em)}let d=Math.min(Math.max(Math.ceil(o)+$p,u),Qp);c.setColumnSizing(t=>({...t,[e.column.id]:d}))},[e,c,u]),f=e.column.getIsResizing()?Math.max(c.store.state.columnResizing.deltaOffset??0,u-l):0;return(0,G.jsxs)(am,{...r,"data-col-id":e.column.id,style:{width:`${l}px`,maxWidth:`${l}px`},className:N(`relative`,o&&`select-none`,a?`px-0`:`px-2`,n),children:[(0,G.jsx)(`div`,{className:N(`flex items-center min-w-0 overflow-hidden`,o&&`pr-4`),children:a?(0,G.jsxs)(P,{type:`button`,variant:`ghost`,className:N(`rounded-none min-w-0`,!e.column.getIsSorted()||e.column.getIsSorted()===`asc`?`cursor-n-resize`:`cursor-s-resize`),onClick:i,children:[(0,G.jsx)(`span`,{className:`truncate`,children:s}),e.column.getIsSorted()===`asc`?(0,G.jsx)(an,{className:`shrink-0`}):e.column.getIsSorted()===`desc`?(0,G.jsx)(sn,{className:`shrink-0`}):(0,G.jsx)(zn,{className:`shrink-0 text-gray-600`})]}):(0,G.jsx)(`span`,{className:`truncate`,children:s})}),o&&(0,G.jsx)(`div`,{"aria-hidden":!0,className:`absolute top-0 right-0 z-10 flex h-full w-4 cursor-col-resize items-center justify-center text-muted-foreground hover:text-foreground`,onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),onDoubleClick:d,style:{transform:e.column.getIsResizing()?`translateX(${f}px)`:``},children:(0,G.jsx)(xr,{className:`size-3.5`})})]})}function sm({className:e,...t}){return(0,G.jsx)(`td`,{"data-slot":`table-cell`,className:N(`align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}var cm=Ee({columnSizingFeature:Te,columnResizingFeature:je,columnVisibilityFeature:Re,columnFilteringFeature:Be,rowSelectionFeature:Pe,rowSortingFeature:Ce,sortedRowModel:Ae(),sortFns:Fe});function lm(){return De()}function um({columns:e,data:t,isFetching:n,onRowClick:r,onColumnClick:i,sortingState:a,children:o}){let s=Le({features:cm,data:t,columns:e,initialState:{sorting:a??[]}});return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-end space-x-2 pb-4`,children:[(0,G.jsx)(`div`,{className:`grow lg:hidden`}),o,(0,G.jsx)(`div`,{className:`grow hidden lg:visible`})]}),(0,G.jsxs)(tm,{containerClassName:`rounded-md bg-card dark:bg-black-dark`,children:[(0,G.jsx)(nm,{children:s.getHeaderGroups().map(e=>(0,G.jsx)(im,{className:`border-none`,children:e.headers.map(e=>(0,G.jsx)(om,{header:e,onColumnClick:i},e.id))},e.id))}),(0,G.jsx)(rm,{className:`bg-background dark:bg-black border border-border dark:border-grey-700`,children:s.getRowModel().rows?.length?s.getRowModel().rows.map(e=>(0,G.jsx)(im,{"data-state":e.getIsSelected()&&`selected`,onClick:()=>r?.(e),className:N(`hover:bg-muted/10 data-[state=selected]:bg-muted`,r&&`cursor-pointer`),children:e.getVisibleCells().map(e=>(0,G.jsx)(sm,{className:`py-2 px-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,style:{width:`${e.column.getSize()}px`},children:Me(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,G.jsx)(im,{children:(0,G.jsx)(sm,{colSpan:e.length,className:`h-24 text-center`,children:n?(0,G.jsx)(`div`,{children:(0,G.jsx)(Wi,{className:`p-12`})}):(0,G.jsx)(`span`,{children:`No results.`})})})})]})]})}function dm(e){switch(e){case`paid`:return`success`;case`void`:case`uncollectible`:return`destructive`;default:return`default`}}function fm(e){return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).format(e)}function pm(e,t){if(e<45)return`a few seconds ago`;if(e<120)return`a minute ago`;let n=Math.floor(e/60);if(n<60)return`${n} minutes ago`;if(n<120)return`an hour ago`;let r=Math.floor(e/3600);return r>48?new Date(t).toLocaleString():`${r} hours ago`}var mm=[{header:`Invoice Id`,accessorKey:`id`,enableSorting:!1},{header:`Status`,accessorKey:`status`,enableSorting:!1,cell:({cell:e})=>(0,G.jsx)(Ji,{variant:dm(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?pm(r,t):[t?pm(r,t):`-`,n?pm(i,n):`-`].join(` to `)}},{header:`Amount Due`,accessorKey:`amountDue`,enableSorting:!1,cell:({cell:e})=>fm(e.getValue()?e.getValue()/100:0)},{header:`Amount Paid`,accessorKey:`amountPaid`,enableSorting:!1,cell:({cell:e})=>fm(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} @ ${fm(e.amount/100)}`);return n.join(`
12
- `)}}];function hm(e){return(0,W.useCallback)(async()=>{H.loading(`Refreshing...`,{id:`refreshing`});let t=Date.now();await e(),Date.now()-t<500&&await n(500),H.success(`Refreshed!`,{id:`refreshing`})},[e])}async function gm(e){let{data:t}=await M.get(`/Invoice/${e}`);return t}function _m(e,t){return R({queryKey:[e,`invoices`],queryFn:()=>gm(e),retry:!1,enabled:!!e,refetchInterval:t?1e4:void 0})}function vm(){let{organizationId:e}=z({strict:!1}),{data:t}=V(md(e)),{data:n,refetch:r,isLoading:i,isFetching:a,isRefetching:o}=V(_m(t?.type!==`ENTERPRISE`&&t?.id,!1)),s=hm(r);return t?.type===`ENTERPRISE`?(0,G.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,G.jsx)(_s,{}),`, we would love to talk!`]}):i?(0,G.jsx)(Wi,{centered:!0}):!n||!n.length?(0,G.jsxs)(`span`,{children:[`Your invoices will be shown here once one is available! Want to explore your solution with Harper more?`,` `,(0,G.jsx)(_s,{overEmail:!0}),`, we would love to talk!`]}):(0,G.jsx)(um,{data:n,columns:mm,children:(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:s,accessKey:`r`,disabled:a||o,children:[(0,G.jsx)(Kr,{}),(0,G.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,G.jsx)(`u`,{children:`R`}),`efresh`]})]})})}function ym(e){let t=F({getParentRoute:()=>e,path:`billing`,head:()=>({meta:[{title:`Billing — Harper Fabric`}]}),component:Zp}),n=F({getParentRoute:()=>t,path:`/`,head:()=>({meta:[{title:`Payment Methods — Harper Fabric`}]}),component:zf}),r=F({getParentRoute:()=>t,path:`invoices`,head:()=>({meta:[{title:`Invoices — Harper Fabric`}]}),component:vm}),i=F({getParentRoute:()=>t,path:`confirm`,head:()=>({meta:[{title:`Confirm Payment — Harper Fabric`}]}),component:Xp});return t.addChildren([n,r,i])}async function bm(e){let{data:t}=await M.get(`/OrganizationRole/${e}`);return t}function xm(e){return R({queryKey:[e,`roles`],queryFn:()=>bm(e),retry:!1,refetchInterval:ns(1e4)})}var Sm=lm(),Cm=[{header:`Role Name`,accessorKey:`roleName`,enableSorting:!1},Sm.display({header:`ID`,id:`id`,enableSorting:!1,cell:e=>(0,G.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,title:e.row.original.id,children:e.row.original.id})}),Sm.display({header:`Users Assigned`,enableSorting:!1,id:`userIds`,cell:e=>!e.row.original.userIds||e.row.original.userIds.length===0?`No users assigned`:e.row.original.userIds.length})];async function wm(e){let{data:t}=await M.post(`/Role/`,e);return t}function Tm(){return L({mutationFn:wm})}var Em=S({name:A().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:D(),delete:D()});S({roles:S({create:D(),delete:D(),update:D(),view:D()}),clusters:S({create:D(),delete:D(),update:D(),view:D(),resources:T(S({id:A(),delete:D(),update:D(),view:D(),instances:S({create:D(),delete:D(),update:D(),view:D()})}))})});function Dm(){let[e]=ja(),t=Oa();return e===`dark`||e===`system`&&t===`dark`?`vs-dark`:`light`}var Om=(0,W.lazy)(async()=>(await ne(()=>import(`./setup-B0CTj_Q5.js`),__vite__mapDeps([18,4,1,19,20,21,22,23,24])),{default:(await ne(()=>import(`./dist-DP8UjMB_.js`),__vite__mapDeps([19,1,4]))).default}));function km(e){return(0,G.jsx)(W.Suspense,{fallback:e.loading??null,children:(0,G.jsx)(Om,{...e})})}var Am={roles:{create:!0,view:!0,update:!0,delete:!0},clusters:{create:!0,view:!0,update:!0,delete:!0,resources:[]}};function jm({isModalOpen:e,setIsModalOpen:t}){let n=Dm(),r=Ie(),{organizationId:i}=z({strict:!1}),[a,o]=(0,W.useState)(!0),[s,c]=(0,W.useState)(JSON.stringify(Am,null,2)),{mutate:l,isPending:u}=Tm(),d=Pt({resolver:Ke(Em),defaultValues:{name:``,update:!1,delete:!1}}),f=(0,W.useCallback)(e=>{o(e.length===0)},[o]),p=(0,W.useCallback)(async e=>{let n=Ue(s);if(!n)return;let o={...e,...n,organizationId:i};e&&a&&l(o,{onSuccess:()=>{H.success(`Organization role added successfully!`),t(!1),r.invalidateQueries({queryKey:[i,`roles`],refetchType:`active`}),d.reset()},onError:e=>{H.error(`Failed to add organization role: ${e.message}`)}})},[a,s,l,d,r,t,i]);return(0,G.jsx)(fn,{onOpenChange:t,open:e,children:(0,G.jsxs)(cn,{resizable:!0,children:[(0,G.jsx)(ln,{children:`Add New Organization Role`}),(0,G.jsx)(un,{children:`Set the new organization role permissions.`}),(0,G.jsx)(q,{...d,children:(0,G.jsxs)(`form`,{id:`org-add-role-form`,name:`org-add-role-form`,className:`flex flex-1 min-h-0 flex-col gap-4 my-4`,onSubmit:d.handleSubmit(p),children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsx)(Y,{control:d.control,name:`name`,render:({field:e})=>(0,G.jsxs)(X,{className:`col-span-2`,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Role Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,className:``,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:d.control,name:`update`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Can Update Organization`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:d.control,name:`delete`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Can Delete Organization`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,G.jsx)(Q,{})]})})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,G.jsx)(km,{className:`w-full h-full`,theme:n,defaultLanguage:`json`,onValidate:f,onChange:e=>{e&&c(e)},options:{automaticLayout:!0},defaultValue:JSON.stringify(Am,null,2)})}),(0,G.jsx)(on,{children:(0,G.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,G.jsx)(P,{variant:`destructiveOutline`,type:`button`,onClick:()=>t(!1),disabled:u,children:`Cancel`}),(0,G.jsx)(P,{variant:`submit`,disabled:u||!a||!d.formState.isValid,children:`Save Changes`})]})})]})})]})})}async function Mm({roleId:e}){let{data:t}=await M.delete(`/Role/${e}`,{id:e,deleted:!0});return t}function Nm(){return L({mutationFn:({roleId:e})=>Mm({roleId:e})})}async function Pm({roleId:e,updatedRoleInfo:t}){let{data:n}=await M.put(`/Role/${e}`,t);return n}function Fm(){return L({mutationFn:({roleId:e,updatedRoleInfo:t})=>Pm({roleId:e,updatedRoleInfo:t})})}function Im({organizationId:e,roleId:t}){return R({queryKey:[e,`roles`,t],queryFn:()=>Lm(t),refetchInterval:ns(1e4),retry:rs()})}async function Lm(e){let{data:t}=await M.get(`/Role/${e}`);return t}function Rm({onRoleDeleteClick:e,setIsConfirmingRoleDeletion:t,isRoleDeletionPending:n}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ln,{children:`Confirm Role Deletion`}),(0,G.jsx)(un,{children:`Are you sure you want to delete this role? This action cannot be undone.`}),(0,G.jsxs)(on,{children:[(0,G.jsx)(P,{type:`button`,variant:`defaultOutline`,onClick:()=>t(!1),children:`Cancel`}),(0,G.jsx)(P,{variant:`destructiveOutline`,onClick:e,disabled:n,children:n?`Deleting...`:`Delete Role`})]})]})}function zm({data:e,isModalOpen:t,closeModal:n}){let r=(0,W.useCallback)(()=>n(!1),[n]);return(0,G.jsx)(fn,{onOpenChange:r,open:t,children:(0,G.jsx)(cn,{resizable:!0,children:(0,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(Bm,{roleName:e.roleName}),children:(0,G.jsx)(Vm,{data:e,closeModal:n})})})})}function Bm({roleName:e}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(ln,{children:[`Organization Role "`,e,`"`]}),(0,G.jsx)(Wi,{centered:!0,text:`Loading role…`,className:`flex-1 min-h-0`})]})}function Vm({data:e,closeModal:t}){let n=Ie(),{data:r}=_e(Im({roleId:e.id,organizationId:e.organizationId})),i=wn().user?.roles?.[e.organizationId]?.id===e.id,{update:a,remove:o}=lu(e.organizationId),{mutate:s,isPending:c}=Fm(),{mutate:l,isPending:u}=Nm(),d=Dm(),[f,p]=(0,W.useState)(!1),m=Pt({resolver:Ke(Em),defaultValues:{name:e.roleName,update:r.organization.update||!1,delete:r.organization.delete||!1}}),h=(0,W.useCallback)(()=>{l({roleId:e.id},{onSuccess:()=>{H.success(`Role deleted successfully!`),t(!0),m.reset()},onError:e=>{H.error(`Error`,{description:`Failed to delete role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}})}})},[e.id,l,m,t]),[g,_]=(0,W.useState)(!0),v=(0,W.useMemo)(()=>JSON.stringify({roles:{...r.organization.roles},clusters:{...r.organization.clusters}},null,2),[r]),[y,b]=(0,W.useState)(v),x=y!==v,S=(0,W.useCallback)(e=>{_(e.length===0)},[_]),C=(0,W.useCallback)(async r=>{if(!a)return;let i=Ue(y);if(!i)return;let o={...r,...i,organizationId:e.organizationId};y&&g&&s({roleId:e.id,updatedRoleInfo:o},{onSuccess:async()=>{H.success(`Role updated successfully!`),await n.invalidateQueries({queryKey:[e.organizationId,`roles`,e.id]}),t(!1),m.reset()},onError:e=>{H.error(`Error`,{description:`Failed to update role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}})}})},[t,e.id,e.organizationId,m,g,n,r,a,y,s]);return f?(0,G.jsx)(Rm,{onRoleDeleteClick:h,setIsConfirmingRoleDeletion:p,isRoleDeletionPending:u}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(ln,{children:[i||!a?`View`:`Edit`,` Organization Role "`,e.roleName,`"`]}),(0,G.jsx)(q,{...m,children:(0,G.jsxs)(`form`,{id:`org-edit-role-form`,name:`org-edit-role-form`,className:`flex flex-1 min-h-0 flex-col gap-4 my-4`,onSubmit:m.handleSubmit(C),children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsx)(Y,{control:m.control,name:`name`,render:({field:e})=>(0,G.jsxs)(X,{className:`col-span-2`,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Role Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,className:``,...e,disabled:!0,readOnly:!0})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:m.control,name:`update`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Can Update Organization`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,disabled:i||!a,readOnly:i||!a,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:m.control,name:`delete`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Can Delete Organization`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,disabled:i||!a,readOnly:i||!a,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,G.jsx)(Q,{})]})})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,G.jsx)(km,{className:`w-full h-full`,theme:d,defaultLanguage:`json`,onValidate:S,onChange:e=>{e&&b(e)},options:{readOnly:i||!a,automaticLayout:!0},defaultValue:y})}),!i&&(o||a)&&(0,G.jsx)(on,{children:(0,G.jsxs)(`div`,{className:`flex justify-between w-full`,children:[o&&(0,G.jsx)(P,{type:`button`,variant:`destructiveOutline`,onClick:()=>p(!0),disabled:c,children:`Delete Role`}),a&&(0,G.jsx)(P,{variant:`submit`,disabled:!g||c||!m.formState.isValid||!m.formState.isDirty&&!x,children:`Save Changes`})]})})]})})]})}function Hm(){let e=I(),t=Ie(),{organizationId:n,orgRoleId:r}=z({strict:!1}),{create:i}=lu(n),{data:a,refetch:o,isFetching:s,isRefetching:c}=_e(xm(n)),l=(0,W.useMemo)(()=>a&&a?.find(e=>e.id===r),[a,r]),u=!!r&&!!l,[d,f]=(0,W.useState)(!1),p=(0,W.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,W.useCallback)(()=>{f(!0)},[f]),h=(0,W.useCallback)(e=>p(e.original.id,!1),[p]),g=(0,W.useCallback)(e=>p(void 0,e),[p]),_=hm(o);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Fc,{}),(0,G.jsx)(Hp,{children:(0,G.jsxs)(W.Suspense,{fallback:(0,G.jsx)(Wi,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,G.jsxs)(um,{data:a,columns:Cm,onRowClick:h,children:[(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:_,accessKey:`r`,disabled:s||c,children:[(0,G.jsx)(Kr,{}),(0,G.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,G.jsx)(`u`,{children:`R`}),`efresh`]})]}),i&&(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:d,children:[(0,G.jsx)(Gr,{}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`A`}),`dd`]})]})]}),i&&(0,G.jsx)(jm,{isModalOpen:d,setIsModalOpen:f}),u&&(0,G.jsx)(zm,{data:l,isModalOpen:u,closeModal:g},l.id)]})})]})}function Um({className:e,...t}){return(0,G.jsx)(_t,{"data-slot":`switch`,className:N(`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,G.jsx)(Xe,{"data-slot":`switch-thumb`,className:N(`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`)})})}function Wm(e){return`//oauth/${e}/login`}async function Gm(e,t){let{data:n}=await M.patch(`/Organization/${e}/settings/oauth`,t);return n}var Km=S({domain:A().min(1,`Domain is required`),clientId:A().min(1,`Client ID is required`),clientSecret:A().min(1,`Client secret is required`),scope:A().optional()}),qm=S({domain:A().min(1,`Domain is required`),clientId:A().optional(),clientSecret:A().optional(),scope:A().optional()});function Jm(){let{organizationId:e}=z({strict:!1}),{user:t}=wn(),{update:n}=su(e),{data:r}=_e(md(e)),i=Ie(),[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(null),l=r.settings?.oauthConfigs??[],{mutate:u,isPending:d}=L({mutationFn:t=>Gm(e,t),onSuccess:()=>void i.invalidateQueries({queryKey:[e]}),onError:()=>H.error(`Failed to update OAuth settings.`)}),f=Pt({resolver:Ke(Km),defaultValues:{domain:``,clientId:``,clientSecret:``,scope:`openid email profile`}}),p=e=>{u({provider:`okta`,...e},{onSuccess:()=>{H.success(`OAuth provider added.`),f.reset(),o(!1)}})},m=Pt({resolver:Ke(qm)}),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};t.clientId&&(n.clientId=t.clientId),t.clientSecret&&(n.clientSecret=t.clientSecret),u(n,{onSuccess:()=>{H.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 Lu(e)&&H.success(`Sign-in URL copied.`)},b=async e=>{await Lu(e)&&H.success(`Redirect URI copied.`)};return n?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Fc,{}),(0,G.jsx)(Hp,{children:(0,G.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,G.jsx)(`h2`,{className:`text-2xl text-foreground font-light mb-6`,children:`Authentication`}),(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsx)(`h3`,{className:`text-lg text-foreground font-medium`,children:`OAuth Providers`}),!a&&(0,G.jsxs)(P,{variant:`positiveOutline`,size:`sm`,onClick:()=>o(!0),children:[(0,G.jsx)(Gr,{}),`Add Provider`]})]}),l.length===0&&!a&&(0,G.jsx)(`p`,{className:`text-muted-foreground text-sm mb-4`,children:`No OAuth providers configured.`}),l.map(e=>{let n=t?.oauthConfigId===e.id;return s===e.id?(0,G.jsxs)(`div`,{className:`border rounded-lg p-4 mb-3 text-foreground`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsx)(`h4`,{className:`font-medium`,children:`Edit Provider`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`text-muted-foreground hover:text-foreground`,children:(0,G.jsx)(gn,{className:`size-4`})})]}),(0,G.jsx)(q,{...m,children:(0,G.jsxs)(`form`,{onSubmit:m.handleSubmit(t=>g(e,t)),className:`space-y-4`,children:[(0,G.jsx)(Y,{control:m.control,name:`domain`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Domain`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`company.okta.com`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:m.control,name:`clientId`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Client ID`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`Leave blank to keep existing`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:m.control,name:`clientSecret`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Client Secret`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,placeholder:`Leave blank to keep existing`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:m.control,name:`scope`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Scope`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`openid email profile`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,G.jsx)(P,{type:`submit`,variant:`positive`,disabled:d,children:d?`Saving...`:`Save`}),(0,G.jsx)(P,{type:`button`,variant:`outline`,onClick:()=>c(null),children:`Cancel`})]})]})})]},e.id):(0,G.jsx)(`div`,{className:`border rounded-lg p-4 mb-3 text-foreground`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between sm:gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:e.domain}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground uppercase bg-muted px-2 py-0.5 rounded`,children:e.provider}),e.enabled===!1&&(0,G.jsx)(`span`,{className:`text-xs text-destructive bg-destructive/10 px-2 py-0.5 rounded`,children:`Disabled`})]}),(0,G.jsxs)(`p`,{className:`text-sm text-muted-foreground mb-2`,children:[`Client ID: `,(0,G.jsx)(`span`,{className:`text-foreground font-mono`,children:`****`})]}),e.id&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mt-3 rounded-md bg-muted px-3 py-2`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Okta redirect URI`}),(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-1.5`,children:[`Add to `,(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:`Login redirect URIs`}),` `,`in your Okta app settings.`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-sm text-foreground font-mono truncate`,children:v(e.id)}),(0,G.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,G.jsx)(sr,{className:`size-3.5`})})]})]}),(0,G.jsxs)(`div`,{className:`mt-2 rounded-md bg-muted px-3 py-2`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`User login link`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`a`,{href:Wm(e.id),target:`_blank`,rel:`noreferrer`,className:`text-sm text-foreground truncate hover:underline`,children:Wm(e.id)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 text-muted-foreground`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>void y(Wm(e.id)),className:`hover:text-foreground`,title:`Copy login link`,children:(0,G.jsx)(sr,{className:`size-3.5`})}),(0,G.jsx)(`a`,{href:Wm(e.id),target:`_blank`,rel:`noreferrer`,className:`hover:text-foreground`,title:`Open login link`,children:(0,G.jsx)(dr,{className:`size-3.5`})})]})]})]})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 sm:shrink-0`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-foreground cursor-pointer`,children:[(0,G.jsx)(Um,{checked:e.enabled!==!1,onCheckedChange:()=>_(e,`enabled`),disabled:d}),`Enabled`]}),(0,G.jsxs)(Ba,{children:[(0,G.jsx)(Va,{asChild:!0,children:(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-sm text-foreground ${n?`cursor-pointer`:`cursor-not-allowed opacity-50`}`,children:[(0,G.jsx)(Um,{checked:!!e.required,onCheckedChange:()=>_(e,`required`),disabled:d||!n}),`Required`]})}),!n&&(0,G.jsxs)(Ha,{children:[`Sign in via `,e.provider,` first to enable Required`]})]}),(0,G.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>h(e),disabled:d,children:(0,G.jsx)(Ur,{className:`size-4`})})]})]})},e.id)}),a&&(0,G.jsxs)(`div`,{className:`border rounded-lg p-4 text-foreground`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsx)(`h4`,{className:`font-medium`,children:`Add Okta Provider`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),f.reset()},className:`text-muted-foreground hover:text-foreground`,children:(0,G.jsx)(gn,{className:`size-4`})})]}),(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-4`,children:[`After saving, copy the `,(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:`Okta redirect URI`}),` `,`from the provider card and add it to your Okta app's`,` `,(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:`Login redirect URIs`}),`.`]}),(0,G.jsx)(q,{...f,children:(0,G.jsxs)(`form`,{onSubmit:f.handleSubmit(p),className:`space-y-4`,children:[(0,G.jsx)(Y,{control:f.control,name:`domain`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Domain`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`company.okta.com`,autoFocus:!0,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:f.control,name:`clientId`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Client ID`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`Okta Client ID`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:f.control,name:`clientSecret`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Client Secret`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,placeholder:`Okta Client Secret`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:f.control,name:`scope`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Scope`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`openid email profile`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,G.jsx)(P,{type:`submit`,variant:`positive`,disabled:d,children:d?`Adding...`:`Add Provider`}),(0,G.jsx)(P,{type:`button`,variant:`outline`,onClick:()=>{o(!1),f.reset()},children:`Cancel`})]})]})})]})]})]})})]}):(0,G.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.`})}S({email:ss.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:A().nonempty({error:`Please select a role.`})});async function Ym(e){let{data:t}=await M.post(`/UserInvite/`,e);return t}function Xm(){return L({mutationFn:e=>Ym(e)})}function Zm({user:e}){let{update:t}=lu(),{mutate:n,isPending:r}=Xm(),i=e.roles?.[0]?.id,a=(0,W.useCallback)(t=>{if(t.stopPropagation(),!e.email||!i){H.error(`Cannot resend invite: this user has no email or role.`);return}n({email:e.email,roleId:i},{onSuccess:()=>H.success(`Invitation resent to ${e.email}.`)})},[n,i,e.email]);return t?(0,G.jsxs)(P,{variant:`ghost`,size:`sm`,className:`h-auto px-2 py-0 align-middle text-sm`,onClick:a,disabled:r||!i,children:[(0,G.jsx)(Fr,{}),` Resend invite`]}):null}var Qm=lm(),$m=[{header:`User Id`,accessorKey:`id`,enableSorting:!1},{header:`Email`,accessorKey:`email`,enableSorting:!1},{header:`First Name`,accessorKey:`firstname`,enableSorting:!1},{header:`Last Name`,accessorKey:`lastname`,enableSorting:!1},Qm.display({header:`Roles`,enableSorting:!1,id:`roles`,cell:e=>e.row.original.roles?.map(e=>e.roleName)?.sort()?.join(`, `)}),{header:`Status`,accessorKey:`status`,enableSorting:!1},{header:`Verified`,accessorKey:`isVerified`,enableSorting:!1},Qm.display({header:``,enableSorting:!1,id:`actions`,cell:e=>e.row.original.status===`PENDING`?(0,G.jsx)(Zm,{user:e.row.original}):null})];function eh({name:e,id:t}){return(0,G.jsxs)(`span`,{className:`flex items-baseline gap-2 truncate`,children:[(0,G.jsx)(`span`,{className:`truncate`,children:e}),(0,G.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:t})]})}var th=S({email:ss.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:A().nonempty({error:`Please select a role.`})});async function nh(e){let{data:t}=await M.post(`/OrganizationRole/`,e);return t}function rh(){return L({mutationFn:e=>nh(e)})}function ih({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let{organizationId:r}=z({strict:!1}),{data:i,isLoading:a}=V({...xm(r),throwOnError:!0}),[o,s]=(0,W.useState)(!1),c=Pt({resolver:Ke(th),defaultValues:{email:``,roleId:``}}),{mutate:l,isPending:u}=rh(),{mutate:d,isPending:f}=Xm(),p=(0,W.useCallback)(async e=>{e&&(o?d:l)(e,{onSuccess:()=>{let r=e.roleId;c.reset(),c.setValue(`roleId`,r),t(),H.success(`User invited successfully!`),n(!1),s(!1)},onError:e=>{e?.status===404&&s(!0)}})},[l,c,d,t,n,o]);return(0,G.jsx)(fn,{onOpenChange:()=>{n(!1),s(!1),c.reset()},open:e,children:(0,G.jsx)(cn,{"aria-describedby":void 0,children:(0,G.jsx)(q,{...c,children:(0,G.jsxs)(`form`,{id:`org-add-user-form`,name:`org-add-user-form`,onSubmit:c.handleSubmit(p),className:`grid gap-4 my-4`,children:[(0,G.jsx)(rn,{children:(0,G.jsx)(ln,{children:o?`Invite User`:`Add User`})}),(0,G.jsx)(Y,{control:c.control,name:`email`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Email`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`email`,enterKeyHint:`next`,autoComplete:`email`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:c.control,name:`roleId`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Roles`}),a?(0,G.jsx)(Kf,{}):(0,G.jsx)(J,{children:(0,G.jsxs)(qf,{...e,onValueChange:t=>e.onChange(t),children:[(0,G.jsx)(Xf,{className:`w-full`,children:(0,G.jsx)(Yf,{placeholder:`Choose Role`})}),(0,G.jsx)(Zf,{children:(0,G.jsxs)(Jf,{children:[(0,G.jsx)(Qf,{children:`Role`}),i?.map(e=>(0,G.jsx)($f,{value:e.id,children:(0,G.jsx)(eh,{name:e.roleName,id:e.id})},e.id))]})})]})}),(0,G.jsx)(Q,{})]})}),o&&(0,G.jsxs)(un,{className:`p-3 my-5 text-white rounded-md bg-amber-600 flex`,children:[(0,G.jsx)(Pr,{className:`inline-block size-12 pr-2`}),(0,G.jsx)(`span`,{children:`This person doesn’t have a Fabric account. Do you want to invite them?`})]}),(0,G.jsx)(on,{children:(0,G.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,G.jsxs)(P,{type:`submit`,variant:`submit`,disabled:u||f,children:[(0,G.jsx)(Xr,{}),` `,o?`Invite User`:`Add User`]})})})]})})})})}async function ah({roleId:e,userId:t}){let{data:n}=await M.delete(`/OrganizationRole/role/${e}/user/${t}`);return n}function oh(){return L({mutationFn:({roleId:e,userId:t})=>ah({roleId:e,userId:t})})}function sh(e){let[t,n]=(0,W.useState)(e||!1);return[t,(0,W.useCallback)(e=>{n(typeof e==`boolean`?e:e.target.checked)},[])]}function ch({data:e,readOnly:t,canRemove:n,orgRole:r,selectedRoles:i,setChangesMade:a}){let{mutate:o,isPending:s}=rh(),{mutate:c,isPending:l}=oh(),u=!!i[r.id],[d,f]=(0,W.useState)(u),[p,m]=sh(u);return(0,W.useEffect)(()=>{p!==d&&(p?o({email:e.email,roleId:r.id},{onSuccess:()=>{f(p),a(!0),H.success(`Role added successfully`)}}):c({userId:e.id,roleId:r.id},{onSuccess:()=>{f(p),a(!0),H.success(`Role removed successfully`)}}))},[o,e.email,e.id,p,r.id,c,a,d]),(0,G.jsxs)(Ro,{className:`flex`,children:[(0,G.jsx)($,{type:`checkbox`,className:`w-6`,disabled:t||s||l||!n&&p,checked:p,onChange:m}),(0,G.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:r.roleName})]},r.id)}function lh({isSelf:e,isPending:t,onConfirm:n}){let[r,i]=(0,W.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?Nr:mi;return r?(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.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,G.jsx)(pi,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,G.jsx)(`span`,{children:a.warning})]}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(P,{type:`button`,variant:`ghostOutline`,disabled:t,onClick:()=>i(!1),children:`Cancel`}),(0,G.jsxs)(P,{type:`button`,variant:`destructive`,disabled:t,onClick:n,children:[(0,G.jsx)(o,{}),` `,t?a.busy:a.confirm]})]})]}):(0,G.jsx)(`div`,{className:`flex justify-start`,children:(0,G.jsxs)(P,{type:`button`,variant:`destructiveOutline`,disabled:t,onClick:()=>i(!0),children:[(0,G.jsx)(o,{}),` `,a.idle]})})}function uh(e){return e?.trim().toLowerCase()===`admin`}function dh({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 fh({closeModal:e,data:t,isModalOpen:n,onUserUpdated:r,orgUserCount:i,orgAdminCount:a}){let{organizationId:o}=z({strict:!1}),s=wn(),{update:c,remove:l}=lu(o),u=s.user?.email===t.email,[d,f]=(0,W.useState)(!1),{canRemoveRoles:p,showRemovalAction:m,blockedReason:h}=dh({canDelete:l,isSelf:u,orgUserCount:i,adminCount:a,isAdmin:(t.roles??[]).some(e=>uh(e.roleName)),roleCount:t.roles?.length??0}),{mutateAsync:g}=oh(),[_,v]=(0,W.useState)(!1),y=(0,W.useCallback)(async()=>{let e=t.roles??[];v(!0),(await Promise.allSettled(e.map(e=>g({userId:t.id,roleId:e.id})))).some(e=>e.status===`rejected`&&e.reason?.response?.status!==404)?H.error(u?`Something went wrong leaving the organization. Please try again.`:`Couldn’t remove ${t.email} from the organization. Please try again.`):H.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,G.jsx)(fn,{onOpenChange:d?r:e,open:n,children:(0,G.jsxs)(cn,{resizable:!0,children:[(0,G.jsx)(rn,{children:(0,G.jsxs)(ln,{children:[c?`Edit `:`View `,` `,t.email,` `,u?`(yourself)`:``]})}),c&&(0,G.jsxs)(un,{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,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(Wi,{centered:!0,text:`Loading roles…`,className:`flex-1 min-h-0`}),children:(0,G.jsx)(ph,{data:t,organizationId:o,update:c,canRemove:p,setChangesMade:f})}),t.status===`PENDING`&&(0,G.jsx)(`div`,{className:`border-t border-border pt-4`,children:(0,G.jsx)(Zm,{user:t})}),m&&(0,G.jsx)(`div`,{className:`border-t border-border pt-4`,children:(0,G.jsx)(lh,{isSelf:u,isPending:_,onConfirm:y})}),h&&(0,G.jsxs)(`p`,{className:`flex items-start gap-2 text-sm text-muted-foreground border border-amber-500/50 rounded-md p-3`,children:[(0,G.jsx)(pi,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,G.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 ph({data:e,organizationId:t,update:n,canRemove:r,setChangesMade:i}){let{data:a}=_e(xm(t)),o=(0,W.useMemo)(()=>e.roles?id(e.roles,`id`):{},[e]);return(0,G.jsx)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 overflow-y-auto`,children:a.map(t=>(0,G.jsx)(ch,{readOnly:!n,canRemove:r,data:e,orgRole:t,selectedRoles:o,setChangesMade:i},t.id))})}function mh(e,t){return e.email>t.email?1:-1}function hh(e){return(e.users??[]).filter(e=>e!=null)}function gh(e){let t={};for(let n of e)for(let e of hh(n))t[e.id]||(t[e.id]={...e,roles:[]}),t[e.id].roles.push(n);return Object.values(t).sort(mh)}function _h(e){let t=new Set;for(let n of e)if(uh(n.roleName))for(let e of hh(n))t.add(e.id);return t.size}function vh(){let e=I(),{organizationId:t,orgUserId:n}=z({strict:!1}),{update:r}=lu(t),{data:i,refetch:a,isFetching:o,isRefetching:s}=_e(xm(t)),c=(0,W.useMemo)(()=>gh(i),[i]),l=(0,W.useMemo)(()=>_h(i),[i]),u=(0,W.useMemo)(()=>c?.find(e=>e.id===n),[c,n]),d=(0,W.useCallback)(t=>{let r=[n?`..`:``,t].filter(Boolean);e({to:r.join(`/`)})},[n,e]),f=!!n&&!!u,[p,m]=(0,W.useState)(!1),[h]=(0,W.useState)({attribute:`email`,descending:!1}),g=(0,W.useMemo)(()=>[{desc:h.descending,id:h.attribute}],[h]),_=(0,W.useCallback)(()=>{m(!0)},[m]),v=(0,W.useCallback)(()=>{a(),m(!1)},[a,m]),y=(0,W.useCallback)(e=>{d(e.original.id)},[d]),b=(0,W.useCallback)(()=>{d(void 0)},[d]),x=(0,W.useCallback)(()=>{a(),d(void 0)},[d,a]),S=hm(a);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Fc,{}),(0,G.jsx)(Hp,{children:(0,G.jsxs)(W.Suspense,{fallback:(0,G.jsx)(Wi,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,G.jsxs)(um,{data:c,isFetching:o||s,columns:$m,onRowClick:y,sortingState:g,children:[(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:S,accessKey:`r`,disabled:o||s,children:[(0,G.jsx)(Kr,{}),` `,(0,G.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,G.jsx)(`u`,{children:`R`}),`efresh`]})]}),r&&(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:_,accessKey:`a`,disabled:p,children:[(0,G.jsx)(Gr,{}),` `,(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`A`}),`dd`]})]})]}),r&&(0,G.jsx)(ih,{isModalOpen:p,onChangesSaved:v,setIsModalOpen:m}),f&&(0,G.jsx)(fh,{closeModal:b,data:u,isModalOpen:f,onUserUpdated:x,orgUserCount:c.length,orgAdminCount:l})]})})]})}function yh({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`skeleton`,className:N(`bg-primary/10 animate-pulse rounded-md`,e),...t})}function bh({organizationId:e,organizationName:t,providers:n}){return(0,G.jsxs)(On,{className:`relative h-full justify-between opacity-90`,children:[(0,G.jsxs)(kn,{children:[(0,G.jsx)(jn,{className:`truncate`,children:e}),(0,G.jsx)(An,{children:(0,G.jsx)(`h2`,{children:t})})]}),(0,G.jsxs)(Mn,{className:`flex flex-col gap-2`,children:[(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-1.5 mb-1`,children:[(0,G.jsx)(Tr,{className:`size-3 shrink-0`}),`Sign in with an OAuth provider to access this organization.`]}),n.map(e=>(0,G.jsx)(`a`,{href:Wm(e.oauthConfigId),children:(0,G.jsxs)(P,{variant:`outline`,className:`w-full`,children:[`Sign in with `,e.name]})},e.oauthConfigId))]})]})}var xh=S({couponId:A().nonempty({message:`Please enter a coupon ID.`}).trim()});async function Sh({organizationId:e,couponId:t}){let{data:n}=await M.post(`/Coupon`,{organizationId:e,couponId:t},{validateStatus:e=>e>=200&&e<400||e===400||e===409});return n}function Ch(){return L({mutationFn:Sh})}function wh({organizationId:e,organizationName:t,isOpen:n,onClose:r}){let{mutate:i,isPending:a}=Ch(),o=Pt({resolver:Ke(xh),defaultValues:{couponId:``}}),{handleSubmit:s,control:c,reset:l}=o;(0,W.useEffect)(()=>{n&&l({couponId:``})},[n,l]);let u=(0,W.useCallback)(n=>{i({organizationId:e,couponId:n.couponId},{onSuccess:i=>{i?H.error(`Error`,{description:i||`Failed to add coupon.`}):(H.success(`Success`,{description:`Coupon "${n.couponId}" added to ${t||e}.`}),r())}})},[i,e,t,r]);return(0,G.jsx)(fn,{open:n,onOpenChange:e=>!e&&r(),children:(0,G.jsxs)(cn,{children:[(0,G.jsxs)(rn,{children:[(0,G.jsx)(ln,{children:`Add Coupon`}),(0,G.jsxs)(un,{children:[`Add a coupon code to`,` `,t||e,`. This coupon will be applied to the next billing cycle.`,(0,G.jsx)(`br`,{}),`Coupons can be created in our`,` `,(0,G.jsx)(`a`,{href:`https://dashboard.stripe.com/`,target:`_blank`,rel:`noreferrer`,className:`text-purple hover:underline`,children:`Stripe Dashboard`}),`.`]})]}),(0,G.jsx)(q,{...o,children:(0,G.jsxs)(`form`,{onSubmit:s(u),children:[(0,G.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,G.jsx)(Y,{control:c,name:`couponId`,render:({field:e})=>(0,G.jsxs)(X,{className:`grid items-center gap-4`,children:[(0,G.jsx)(Z,{children:`Coupon ID`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{...e,placeholder:`e.g. 100OFF`,disabled:a})}),(0,G.jsx)(Q,{})]})})}),(0,G.jsxs)(on,{children:[(0,G.jsx)(P,{type:`button`,variant:`ghost`,onClick:r,disabled:a,children:`Cancel`}),(0,G.jsx)(P,{type:`submit`,disabled:a,children:a?`Adding...`:`Add Coupon`})]})]})})]})})}function Th({organizationRole:e,onDeleteOrgModal:t}){let{organizationId:n,organizationName:r,roleName:i}=e,{remove:a,update:o}=su(n),s=o,{view:c}=lu(n),l=En(`billing:write`),[u,d]=(0,W.useState)(!1),f=(0,W.useCallback)(()=>{t(e)},[t,e]),p=[{type:`label`,key:`label`,className:`text-gray-600 text-xs`,label:`Options`},{type:`separator`,key:`sep-top`},{key:`clusters`,to:`${n}`,icon:(0,G.jsx)($r,{className:`size-4 mr-2 text-blue-500`}),label:`Clusters`},c&&{key:`roles`,to:`${n}/roles`,icon:(0,G.jsx)(ti,{className:`size-4 mr-2 text-purple`}),label:`Roles`},c&&{key:`users`,to:`${n}/users`,icon:(0,G.jsx)(gi,{className:`size-4 mr-2 text-orange-500`}),label:`Users`},s&&{key:`billing`,to:`${n}/billing`,icon:(0,G.jsx)(cr,{className:`size-4 mr-2 text-green-500`}),label:`Billing`},o&&{key:`settings`,to:`${n}/settings`,icon:(0,G.jsx)(Tr,{className:`size-4 mr-2 text-yellow-500`}),label:`Settings`},l&&{key:`add-coupon`,onClick:()=>d(!0),icon:(0,G.jsx)(di,{className:`size-4 mr-2 text-pink-500`}),label:`Add Coupon`},a&&{type:`separator`,key:`sep-bottom`},a&&{key:`delete`,onClick:f,className:`focus:bg-red/70 focus:text-white`,icon:(0,G.jsx)(fi,{className:`size-4 mr-2 text-red-500`}),label:`Delete`}].filter(Qa),m=a||l;return(0,G.jsx)(Kc,{items:m?p:[],children:(0,G.jsxs)(On,{className:`relative h-full justify-between transition-[transform,box-shadow] duration-200 hover:scale-[1.02] hover:shadow-lg hover:ring-2 hover:ring-primary/60 dark:hover:ring-violet-400/70`,children:[(0,G.jsx)(B,{to:n,"aria-label":`View ${r??n}`,className:`absolute inset-0 rounded-[inherit] focus-visible:ring-2 focus-visible:ring-purple-200 focus-visible:outline-none`}),(0,G.jsxs)(kn,{children:[(0,G.jsxs)(jn,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`truncate`,children:n}),m&&(0,G.jsxs)(wi,{children:[(0,G.jsx)(Ti,{"aria-label":`Options`,onClick:e=>e.stopPropagation(),className:`relative z-10 -m-2 p-2 rounded-md hover:bg-accent/60 hover:text-foreground`,children:(0,G.jsx)(ur,{})}),(0,G.jsx)(Ei,{children:Gc(p,`dropdown`)})]})]}),(0,G.jsx)(An,{children:(0,G.jsx)(`h2`,{children:r})})]}),(0,G.jsxs)(Mn,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(Ji,{className:`min-w-0 shrink`,title:Mo(i),children:(0,G.jsx)(`span`,{className:`truncate`,children:Mo(i)})}),(0,G.jsxs)(`span`,{className:`text-sm shrink-0 py-2 whitespace-nowrap ml-auto`,children:[`View `,(0,G.jsx)(Rn,{className:`inline-block`})]})]}),(0,G.jsx)(wh,{organizationId:n,organizationName:r,isOpen:u,onClose:()=>d(!1)})]})})}async function Eh(e){let{data:t}=await M.delete(`/Organization/${e}`);return t}function Dh(){return L({mutationFn:e=>Eh(e)})}async function Oh(e){let{data:t}=await M.post(`/Organization/`,{...e});return t}function kh(){return L({mutationFn:e=>Oh(e)})}var Ah=A().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.`}),jh=S({name:A().max(255,{error:`Name cannot be longer than 255 characters.`}),subdomain:ee([x(``),w(),Ah]).optional()});function Mh(){let{user:e}=wn(),t=I(),n=Pt({resolver:Ke(jh),defaultValues:{name:``,subdomain:``}}),{setFocus:r,watch:i}=n;(0,W.useEffect)(()=>{r(`name`)},[r]);let a=`${e?.firstname} ${e?.lastname} Org`,o=i(`name`)||a,s=i(`subdomain`),c=(0,W.useMemo)(()=>{let e=gd(vd(o),Ah.maxLength);return{suggestedSubdomain:e,fullHostName:`future-cluster-names.${s||e}.harperfabric.com`}},[o,s]),{mutate:l,isPending:d}=kh(),p=Ie(),h=(0,W.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,G.jsx)(G.Fragment,{children:(0,G.jsx)(q,{...n,children:(0,G.jsxs)(`form`,{id:`org-add-form`,name:`org-add-form`,onSubmit:n.handleSubmit(h),className:`grid gap-6 text-foreground max-w-xl`,children:[(0,G.jsx)(Y,{control:n.control,name:`name`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,maxLength:jh.shape.name.maxLength,autoCapitalize:`words`,placeholder:a,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:n.control,name:`subdomain`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Subdomain`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,maxLength:Ah.maxLength,autoCapitalize:`none`,placeholder:c.suggestedSubdomain,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Full Host Name`}),(0,G.jsx)(J,{children:(0,G.jsx)(`span`,{children:c.fullHostName})}),(0,G.jsx)(Q,{})]}),(0,G.jsx)(on,{children:(0,G.jsxs)(P,{type:`submit`,variant:`submit`,disabled:d,children:[`Create New Organization `,(0,G.jsx)(Rn,{})]})})]})})})}function Nh(){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Fc,{}),(0,G.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,G.jsx)(Mh,{})})]})}var Ph={org:`organization`,clu:`cluster`,ins:`instance`},Fh=/^(org|clu|ins)-[a-z0-9]+$/;function Ih(e){if(typeof e!=`string`)return null;let t=e.trim(),n=Fh.exec(t);return n?{kind:Ph[n[1]],id:t}:null}function Lh(e,t){let n=e*12;return`/Admin/Organization/?${[...t?[`name=ct=${encodeURIComponent(t)}`]:[],`status=ne=DELETED`,`sort(name)`,`limit(${n},${n+12+1})`].join(`&`)}`}async function Rh(e,t){let{data:n}=await M.get(Lh(e,t));return{organizations:n.slice(0,12),hasNextPage:n.length>12}}var zh={organizations:[],hasNextPage:!1};function Bh(e){return e instanceof _&&(e.response?.status===404||e.status===404)}async function Vh(e){try{let{data:t}=await M.get(`/Admin/Organization/${e}`);return t?{organizations:[t],hasNextPage:!1}:zh}catch(e){if(Bh(e))return zh;throw e}}async function Hh(e){try{let{data:t}=await M.get(`/Cluster/${e}`),n=t?.organizationId;return n?await Vh(n):zh}catch(e){if(Bh(e))return zh;throw e}}function Uh(e,t){let n=Ih(t);return R({queryKey:[`admin-all-organizations`,t,e],queryFn:()=>n?.kind===`organization`?Vh(n.id):n?.kind===`cluster`?Hh(n.id):Rh(e,t),placeholderData:ue,retry:!1})}function Wh(e,t=300,n){let[r,i]=(0,W.useState)(e),a=n?n(e):e;return(0,W.useEffect)(()=>{let n=setTimeout(()=>i(e),t);return()=>clearTimeout(n)},[a,t]),r}function Gh(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 Kh(e,t){let[n,r]=(0,W.useState)(t),[i,a]=(0,W.useState)(e);return(0,W.useEffect)(()=>{Gh(n,t)||(r(t),a(e))},[n,t,e]),Gh(n,t)?[i,a]:[e,a]}var qh={};function Jh(e,t,n){let r=(0,W.useCallback)((e,n)=>t(e,n),[n]);(0,W.useEffect)(()=>(qh[e]||(qh[e]=[]),qh[e].push(r),function(){let t=qh[e].indexOf(r);t>=0&&qh[e].splice(t,1)}),[e,t,r])}function Yh(e,t,n){let r=qh[e];if(r)for(let e of r)e(t,n)}function Xh(e,t,n){return r=>Yh(e,t,n??r)}function Zh(e,t,n){return(0,W.useCallback)(r=>Yh(e,t,n??r),[e,t,n])}function Qh(e,t){let n=Kh(We(e,t),[e]),[r,i]=n;return(0,W.useEffect)(()=>{Ge(e,r),Yh(`Session:${e}`,r)},[e,r]),Jh(`Session:${e}`,function(e){r!==e&&i(e)},[r,e,t]),(0,W.useEffect)(function(){let n=n=>{n.key===e&&i(We(e,t))};return window.addEventListener(`storage`,n),()=>{window.removeEventListener(`storage`,n)}},[e,i,t]),n}function $h(){let e=Ie(),{data:t}=_e(s()),{mutate:n,isPending:r}=Dh(),[i,a]=(0,W.useState)(!1),[o,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(``),d=(0,W.useCallback)(()=>u(``),[]),f=En(`org:read`),[p,m]=Qh(`ShowAllOrganizations`,!1),[h,g]=(0,W.useState)(0),_=f&&p,v=(0,W.useCallback)(e=>{m(e),g(0)},[m]),y=Wh(l,300),b=(0,W.useMemo)(()=>{if(!f)return null;let e=Ih(y);return e?.kind===`organization`||e?.kind===`cluster`?e:null},[f,y]),x=_||!!b,{data:S,isPending:C}=V({...Uh(h,y),enabled:x}),{organizationRoles:w,oauthLockedOrgs:T}=(0,W.useMemo)(()=>{let e=t?.roles||{},n=[],r=[];for(let[t,i]of Object.entries(e))`oauthProviders`in i&&!f?r.push({organizationId:t,organizationName:i.organizationName,providers:i.oauthProviders}):n.push({organizationId:t,organizationName:i.organizationName,roleName:i.role??`fabric staff`});return{organizationRoles:n.filter(Kp([`organizationId`,`organizationName`],l)).sort((e,t)=>(e.organizationName||``)>(t.organizationName||``)?1:-1),oauthLockedOrgs:r}},[l,t?.roles,f]),E=(0,W.useMemo)(()=>{let e=t?.roles||{};return(S?.organizations||[]).map(t=>({organizationId:t.id,organizationName:t.name,roleName:e[t.id]?.role||`fabric staff`}))},[S?.organizations,t?.roles]),D=x?E:w,O=(0,W.useCallback)(e=>{u(e.currentTarget.value||``),g(0)},[]),k=(0,W.useCallback)(t=>{t?.organizationId&&n(t.organizationId,{onSuccess:()=>{H.success(`Success`,{description:`Organization successfully deleted.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),e.invalidateQueries({queryKey:[]}),a(!1)},onError:()=>a(!1)})},[n,e,a]),A=(0,W.useCallback)(e=>{c(e),a(!0)},[]),{createCluster:j}=he({strict:!1});return!_&&w.length===1&&!l.length&&j?(0,G.jsx)(ce,{to:`/${w[0].organizationId}/new-cluster`,replace:!0}):!_&&!w.length&&!T.length&&!l.length?(0,G.jsx)(Nh,{}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Fc,{children:(0,G.jsxs)(`div`,{className:`flex w-full items-center justify-end gap-2`,children:[f&&(0,G.jsxs)(`label`,{className:`flex shrink-0 cursor-pointer items-center gap-2 text-xs`,children:[(0,G.jsx)(Um,{checked:p,onCheckedChange:v,"aria-label":`Show all organizations`}),(0,G.jsx)(`span`,{className:`hidden sm:inline-block`,children:`All Orgs`})]}),(0,G.jsx)($,{placeholder:`Filter by name`,className:`inline-block w-full text-xs`,value:l,onChange:O}),(0,G.jsx)(B,{to:`/new-org`,children:(0,G.jsxs)(P,{variant:`positive`,accessKey:`n`,children:[(0,G.jsx)(Gr,{}),(0,G.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,G.jsx)(`u`,{children:`N`}),`ew `,(0,G.jsx)(`span`,{className:`hidden md:inline-block`,children:`Organization`})]})]})})]})}),(0,G.jsxs)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-12`,children:[!x&&T.map(e=>(0,G.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,G.jsx)(bh,{organizationId:e.organizationId,organizationName:e.organizationName,providers:e.providers})},e.organizationId)),x&&C?Array.from({length:12},(e,t)=>(0,G.jsx)(yh,{className:`col-span-1 h-40 md:col-span-4 lg:col-span-3 2xl:col-span-2`},t)):D.map(e=>(0,G.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,G.jsx)(Th,{organizationRole:e,onDeleteOrgModal:A})},e.organizationId)),!D.length&&!(x&&C)&&(x||!T.length)&&(0,G.jsxs)(`div`,{className:`col-span-1 md:col-span-12 text-center`,children:[(0,G.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,G.jsx)(P,{variant:`outline`,onClick:d,children:`Clear Filters`})]})]}),x&&(h>0||S?.hasNextPage)&&(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-4 py-6`,children:[(0,G.jsxs)(P,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:h===0,onClick:()=>g(e=>e-1),children:[(0,G.jsx)(Ln,{}),`Previous`]}),(0,G.jsxs)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:[`Page `,h+1]}),(0,G.jsxs)(P,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:!S?.hasNextPage,onClick:()=>g(e=>e+1),children:[`Next`,(0,G.jsx)(Rn,{})]})]})]}),o&&(0,G.jsx)(Ic,{typeOfThingBeingDeleted:`organization`,nameOfThingBeingDeleted:o.organizationName,isModalOpen:i,setIsModalOpen:()=>a(!1),deletionConfirmed:()=>k(o),deletionPending:r})]})}var eg=F({getParentRoute:()=>bo,id:`_orgsLayout`});F({getParentRoute:()=>eg,path:`/`,head:()=>({meta:[{title:`Organizations — Harper Fabric`}]}),component:$h}),F({getParentRoute:()=>eg,path:`/new-org`,head:()=>({meta:[{title:`New Organization — Harper Fabric`}]}),component:Nh});var tg=F({getParentRoute:()=>eg,path:`$organizationId`,beforeLoad:async e=>{let{organizationId:t}=e.params;if(!fd(t))throw le({to:`/`});return{organization:await e.context.queryClient.ensureQueryData(md(t))}}});F({getParentRoute:()=>tg,path:`/roles`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:Hm}),F({getParentRoute:()=>tg,path:`/roles/$orgRoleId`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:Hm}),F({getParentRoute:()=>tg,path:`/users`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:vh}),F({getParentRoute:()=>tg,path:`/users/$orgUserId`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:vh}),F({getParentRoute:()=>tg,path:`/settings`,component:Jm}),ym(tg);var ng=F({getParentRoute:()=>tg,id:`_clusterLayout`});F({getParentRoute:()=>ng,path:`/`,head:()=>({meta:[{title:`Clusters — Harper Fabric`}]}),component:qp}),F({getParentRoute:()=>tg,path:`/new-cluster`,head:()=>({meta:[{title:`New Cluster — Harper Fabric`}]}),component:Vp}),F({getParentRoute:()=>ig,path:`/edit`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),component:Vp}),F({getParentRoute:()=>ig,path:`/edit/$mode`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),component:Vp});function rg(){return(0,G.jsx)(He,{})}var ig=F({getParentRoute:()=>ng,path:`$clusterId`,component:rg,beforeLoad:async({context:e,params:t})=>({cluster:await e.queryClient.ensureQueryData(os(t.clusterId))})}),ag=e=>new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e),og=e=>`${new Intl.NumberFormat(void 0,{maximumFractionDigits:1}).format(e)} hr`,sg=e=>_p(e),cg={reads:`Reads`,readBytes:`Read data`,writes:`Writes`,writeBytes:`Write data`,realTimeMessages:`Real-time messages`,realTimeBytes:`Real-time data`,cpuTimeHours:`Compute`,storageBytes:`Storage`},lg={reads:ag,readBytes:sg,writes:ag,writeBytes:sg,realTimeMessages:ag,realTimeBytes:sg,cpuTimeHours:og,storageBytes:sg},ug=[`reads`,`readBytes`,`writes`,`writeBytes`,`realTimeMessages`,`realTimeBytes`,`cpuTimeHours`,`storageBytes`];function dg(e,t,n){return{label:n??cg[e],used:t.used,limit:t.limit,unlimited:t.unlimited,limitKnown:t.limitKnown,format:lg[e]}}function fg({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,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-sm`,children:[(0,G.jsx)(`span`,{className:`text-foreground`,children:e}),(0,G.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[(0,G.jsx)(`span`,{className:`text-foreground`,children:a(t)}),s?(0,G.jsxs)(G.Fragment,{children:[`/ `,a(n)]}):` used`]})]}),(0,G.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`h-2 flex-1 overflow-hidden rounded-full bg-muted`,children:s?(0,G.jsx)(`div`,{className:`h-full rounded-full ${l?`bg-yellow`:`bg-primary dark:bg-violet-400`}`,style:{width:`${c}%`}}):o?(0,G.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,G.jsx)(`span`,{className:`w-16 shrink-0 text-right text-xs tabular-nums ${l?`text-yellow`:`text-muted-foreground`}`,children:s?`${c}%`:o?`Unlimited`:`—`})]})]})}function pg(e){return R({queryKey:[`clusterUsage`,e],queryFn:async()=>{let{data:t}=await M.get(`/Cluster/${e}/usage`);return t},enabled:!!e,staleTime:6e4})}function mg(e){return V(pg(e))}function hg(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} ${gg(e.renewsAt)}`:null].filter(Boolean).join(` · `)}function gg(e){return new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))}function _g({clusterId:e,base:t}){let{data:n}=mg(e);return!n||n.selfManaged||n.regions.length===0?null:(0,G.jsxs)(`section`,{className:`mt-6 rounded-2xl border border-border bg-card p-5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Plan usage`}),(0,G.jsxs)(B,{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,G.jsx)(Rn,{className:`size-3`})]})]}),(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:hg(n)}),(0,G.jsx)(`div`,{className:`mt-4`,children:n.regions.length===1?(0,G.jsx)(vg,{data:n}):(0,G.jsx)(yg,{data:n})})]})}function vg({data:e}){let t=e.regions[0].metrics,n=[dg(`reads`,t.reads),dg(`writes`,t.writes),dg(`storageBytes`,t.storageBytes),dg(`cpuTimeHours`,t.cpuTimeHours)];return(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-x-8 gap-y-4 sm:grid-cols-2`,children:n.map(e=>(0,G.jsx)(fg,{...e},e.label))})}function yg({data:e}){let t=e.mostConstrained;return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`p`,{className:`mb-1.5 text-xs text-muted-foreground`,children:[`Most constrained of `,e.regions.length,` regions`]}),t?(0,G.jsx)(fg,{...dg(t.metric,{used:t.used,limit:t.limit,unlimited:!1,limitKnown:!0},`${t.region??`Region`} · ${cg[t.metric]}`)}):(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No metered limits on the current plan — see the breakdown for details.`})]})}function bg({cluster:e}){let t=pe(),n=Ie(),{update:r,remove:i}=du(e.organizationId,e.id),{run:a,isPending:o}=Iu(e),{mutate:s,isPending:c}=Mu(),[l,u]=(0,W.useState)(!1),[d,f]=(0,W.useState)(!1),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(null),_=e.status===`RUNNING`,v=e.status===`STOPPED`,y=e.status===`PARTIAL`,b=!r||o,x=(0,W.useCallback)(()=>{s(e.id,{onSuccess:async()=>{await n.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),m(!1),H.success(`Success`,{description:`Cluster successfully terminated.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),t.navigate({to:`/${e.organizationId}`})},onError:()=>{m(!1)}})},[e.id,e.organizationId,s,n,t]),S=(0,W.useCallback)(()=>{let e=h;g(null),e&&a(e,{safeMode:!0,strategy:`parallel`,label:e===`start`?`Starting in safe mode`:`Restarting in safe mode`})},[h,a]);return wu(e)||!r&&!i?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(wi,{children:[(0,G.jsx)(Ti,{asChild:!0,children:(0,G.jsxs)(P,{variant:`outline`,size:`sm`,disabled:o,className:`gap-1.5 hover:translate-y-0 data-[state=open]:[&>svg]:rotate-180`,children:[`Cluster actions`,(0,G.jsx)(pn,{className:`size-4 transition-transform`})]})}),(0,G.jsxs)(Ei,{align:`end`,className:`w-56`,children:[(0,G.jsx)(ki,{className:`text-gray-600 text-xs`,children:`Container`}),(0,G.jsxs)(Di,{disabled:b||!(v||y),onClick:()=>void a(`start`,{safeMode:!1,strategy:`parallel`}),children:[(0,G.jsx)(Wr,{}),` Start`]}),(0,G.jsxs)(Di,{disabled:b||!v,onClick:()=>g(`start`),children:[(0,G.jsx)(Or,{}),` Start in safe mode`]}),(0,G.jsxs)(Di,{disabled:b||!(_||y),onClick:()=>f(!0),children:[(0,G.jsx)(Yr,{}),` Restart`]}),(0,G.jsxs)(Di,{disabled:b||!_,onClick:()=>g(`restart`),children:[(0,G.jsx)(Or,{}),` Restart in safe mode`]}),(0,G.jsxs)(Di,{variant:`destructive`,disabled:b||!(_||y),onClick:()=>u(!0),children:[(0,G.jsx)(ai,{}),` Stop`]}),(0,G.jsx)(Ai,{}),(0,G.jsxs)(Di,{variant:`destructive`,disabled:!i,onClick:()=>m(!0),children:[(0,G.jsx)(fi,{}),` Terminate`]})]})]}),(0,G.jsx)(Du,{clusterName:e.name,isPending:o,stopOpen:l,setStopOpen:u,onConfirmStop:()=>{u(!1),a(`stop`,{strategy:`parallel`})},restartOpen:d,setRestartOpen:f,onConfirmRestart:e=>{f(!1),a(`restart`,{safeMode:!1,strategy:e})}}),(0,G.jsx)(Au,{open:h!==null,setOpen:e=>{e||g(null)},action:h??`restart`,targetName:e.name,scope:`cluster`,isPending:o,onConfirm:S}),(0,G.jsx)(Ic,{typeOfThingBeingDeleted:`cluster`,transitiveVerb:`Terminate`,presentParticiple:`Terminating`,nameOfThingBeingDeleted:e.name,isModalOpen:p,setIsModalOpen:m,deletionConfirmed:x,deletionPending:c})]})}function xg(){let{clusterId:e}=z({strict:!1}),t=pe(),n=I(),{data:r}=V(os(e,!0)),{user:i,isLoading:a}=Dn(e),{view:s,update:l}=du(r?.organizationId,r?.id),[f,p]=(0,W.useState)(!1),m=r?.domains?.[0]?.domain||r?.fqdn||``,[h,g]=zu(m,m?`https://${m}`:``),_=r?`/${r.organizationId}/${r.id}`:``,v=(0,W.useCallback)(async()=>{if(r){p(!0);try{await u.establishFabricConnectAuth({id:r.id,operationsUrl:c(r)}),await t.invalidate()}catch{H.error(`Could not connect to this cluster through Fabric Connect.`)}finally{p(!1)}}},[r,t]),y=(0,W.useCallback)(()=>{r&&(u.setUserForEntity(r,null),u.flagForFabricConnect(r.id,!1)),n({to:`${_}/sign-in`})},[_,r,n]),b=(0,W.useCallback)(async()=>{if(r){try{await d({instanceClient:o({id:r.id}),entityId:r.id})}catch{}u.setUserForEntity(r,null),u.flagForFabricConnect(r.id,!1),u.flagForBasicAuth(r.id,null),await t.invalidate()}},[r,t]);if(!r)return(0,G.jsx)(Cg,{children:(0,G.jsx)(wg,{})});if(!s)return(0,G.jsx)(ce,{to:`/${r.organizationId}`,replace:!0});if(wu(r))return(0,G.jsx)(Sg,{cluster:r});if(!r.fqdn)return(0,G.jsx)(ce,{to:`${_}/instances`,replace:!0});if(r.resetPassword){if(!l)return(0,G.jsx)(Cg,{children:(0,G.jsxs)(`div`,{className:`text-center py-12`,children:[(0,G.jsx)($r,{className:`size-12 text-muted-foreground mx-auto mb-4`}),(0,G.jsx)(`h1`,{className:`text-xl font-medium mb-2 text-foreground`,children:`Pending Owner Setup`}),(0,G.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.`})]})});let e=r.status&&zo.includes(r.status)&&Qo(r);return(0,G.jsx)(ce,{to:`${_}/${e?`finish-setup`:`starting-up`}`,replace:!0})}let x=u.checkForFabricConnect(r.id),S=!!i,C=u.getLastConnectMode(r.id),w=(r.instances??[]).filter(e=>e.status&&!Bo.includes(e.status)).length,T=r.instances??[],E=!!r.status&&zo.includes(r.status)&&T.length>0&&T.every(e=>e.safeMode);return(0,G.jsxs)(Cg,{children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-4 mb-6`,children:[(0,G.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,G.jsx)($r,{className:`size-6`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:r.name}),(0,G.jsx)(Tg,{status:r.status}),E&&(0,G.jsx)(Eg,{})]}),(0,G.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,G.jsxs)(`span`,{children:[w,` `,w===1?`instance`:`instances`]}),(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,G.jsxs)(`a`,{href:`https://${m}`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 hover:text-foreground hover:underline`,children:[m,(0,G.jsx)(dr,{className:`size-3`})]}),(0,G.jsxs)(wi,{children:[(0,G.jsx)(Ti,{"aria-label":`Copy cluster URLs`,className:`rounded-md p-1 -m-1 hover:bg-accent/60 hover:text-foreground`,children:(0,G.jsx)(sr,{className:`size-3.5`})}),(0,G.jsxs)(Ei,{align:`start`,children:[(0,G.jsx)(Di,{onClick:h,children:`Copy host name`}),(0,G.jsx)(Di,{onClick:g,children:`Copy API URL`})]})]})]})]}),(0,G.jsx)(bg,{cluster:r})]}),a?(0,G.jsx)(wg,{}):S?(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-sm`,children:[(0,G.jsx)(Qn,{className:`size-4 text-green shrink-0`}),(0,G.jsx)(`span`,{className:`font-medium text-green`,children:x?`Connected via Fabric Connect`:`Signed in directly`}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,x?`through your Harper account`:`session cookie`]})]}),(0,G.jsxs)(B,{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,G.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,G.jsx)(qr,{className:`size-6`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-lg font-medium text-foreground`,children:`Enter cluster`}),(0,G.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Open the studio — apps, databases, APIs, logs, and config.`})]}),(0,G.jsx)(Rn,{className:`size-5 text-muted-foreground transition-transform group-hover:translate-x-1`})]}),(0,G.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-4 text-sm`,children:[x&&(0,G.jsx)(`button`,{type:`button`,onClick:y,className:`text-muted-foreground hover:text-foreground transition-colors`,children:`Switch to direct sign-in`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void b(),className:`text-muted-foreground hover:text-destructive transition-colors`,children:x?`Disconnect`:`Direct sign out`})]})]}):(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-medium text-foreground mb-3`,children:`Connect to this cluster`}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3.5`,children:[l&&!wu(r)&&(0,G.jsx)(Dg,{icon:_i,title:`Fabric Connect`,description:`Connect through your Harper account. No cluster credentials needed.`,pill:C===`fabric`?`last`:C?void 0:`recommended`,children:(0,G.jsx)(P,{className:`w-full`,disabled:f,onClick:()=>void v(),children:f?(0,G.jsx)(Ar,{className:`animate-spin`}):`Fabric Connect`})}),(0,G.jsx)(Dg,{icon:Tr,title:`Direct sign-in`,description:`Sign in with this cluster's Harper username and password.`,pill:C===`direct`?`last`:void 0,children:(0,G.jsx)(P,{className:`w-full`,variant:`outline`,onClick:y,children:`Direct sign-in`})})]})]}),(0,G.jsx)(_g,{clusterId:r.id,base:_})]})}function Sg({cluster:e}){let t=pe(),n=I(),r=`/${e.organizationId}/${e.id}`,i=(0,W.useMemo)(()=>(e.instances??[]).filter(e=>e.status&&!Bo.includes(e.status)).sort(nd),[e.instances]),a=i.at(0),{user:s,isLoading:c}=Dn(a?.id),l=!!a&&!!s,f=(0,W.useCallback)(()=>{a&&n({to:`${r}/instance/${a.id}/sign-in`})},[r,a,n]),m=(0,W.useCallback)(async()=>{if(a){try{await d({instanceClient:o({id:a.id,operationsUrl:p(a)}),entityId:a.id})}catch{}u.setUserForEntity(a,null),u.flagForBasicAuth(a.id,null),await t.invalidate()}},[a,t]);return(0,G.jsxs)(Cg,{children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-4 mb-6`,children:[(0,G.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,G.jsx)($r,{className:`size-6`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:e.name}),(0,G.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,G.jsx)(`div`,{className:`mt-1 text-sm text-muted-foreground`,children:(0,G.jsxs)(B,{to:`${r}/instances`,className:`hover:text-foreground hover:underline`,children:[i.length,` `,i.length===1?`instance`:`instances`]})})]})]}),a?c?(0,G.jsx)(wg,{}):l?(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-sm`,children:[(0,G.jsx)(Qn,{className:`size-4 text-green shrink-0`}),(0,G.jsx)(`span`,{className:`font-medium text-green`,children:`Signed in directly`}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,a.name||a.instanceFqdn]})]}),(0,G.jsxs)(B,{to:`${r}/instance/${a.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,G.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,G.jsx)(qr,{className:`size-6`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-lg font-medium text-foreground`,children:`Enter cluster`}),(0,G.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Open the studio — apps, databases, APIs, logs, and config.`})]}),(0,G.jsx)(Rn,{className:`size-5 text-muted-foreground transition-transform group-hover:translate-x-1`})]}),(0,G.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-4 text-sm`,children:(0,G.jsx)(`button`,{type:`button`,onClick:()=>void m(),className:`text-muted-foreground hover:text-destructive transition-colors`,children:`Direct sign out`})})]}):(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-medium text-foreground mb-3`,children:`Connect to this cluster`}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3.5`,children:(0,G.jsx)(Dg,{icon:Tr,title:`Direct sign-in`,description:`Sign in with this instance's Harper username and password.`,children:(0,G.jsx)(P,{className:`w-full`,variant:`outline`,onClick:f,children:`Direct sign-in`})})})]}):(0,G.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`This cluster has no instances yet. Register one from the`,` `,(0,G.jsx)(B,{to:`${r}/instances`,className:`underline hover:text-foreground`,children:`Instances`}),` page.`]})]})}function Cg({children:e}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Fc,{}),(0,G.jsx)(Uu,{children:(0,G.jsx)(`div`,{className:`max-w-3xl`,children:e})})]})}function wg(){return(0,G.jsx)(`div`,{className:`flex justify-center py-10 text-muted-foreground`,children:(0,G.jsx)(Ar,{className:`size-6 animate-spin`})})}function Tg({status:e}){let t=e&&zo.includes(e)?`text-green bg-green/10`:e===`STOPPED`?`text-destructive bg-destructive/10`:e===`PARTIAL`?`text-yellow bg-yellow/10`:`text-muted-foreground bg-muted`;return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full ${t}`,children:[(0,G.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e?e.charAt(0)+e.slice(1).toLowerCase():`Unknown`]})}function Eg(){return(0,G.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-yellow bg-yellow/10`,children:[(0,G.jsx)(Or,{className:`size-3`}),`Safe mode`]})}function Dg({icon:e,title:t,description:n,pill:r,children:i}){return(0,G.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,G.jsx)(`span`,{className:`absolute -top-2.5 left-4 rounded-full bg-card`,children:(0,G.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,G.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),r===`last`?`Last used`:`Recommended`]})}),(0,G.jsx)(e,{className:`size-6 text-primary dark:text-violet-300 mb-2`}),(0,G.jsx)(`div`,{className:`text-[15px] font-medium text-foreground mb-1`,children:t}),(0,G.jsx)(`p`,{className:`text-[13px] text-muted-foreground leading-normal mb-4`,children:n}),i]})}function Og({children:e,className:t}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Fc,{}),(0,G.jsx)(Uu,{children:(0,G.jsx)(`div`,{className:t,children:e})})]})}var kg=new Set([`com`,`co`,`org`,`net`,`edu`,`gov`,`mil`,`me`,`biz`,`info`,`ac`,`or`,`ne`,`go`,`lg`,`asn`,`id`,`nom`,`sch`,`ltd`,`plc`]);function Ag(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&&kg.has(r)?3:2;return t.length<=i?`@`:t.slice(0,-i).join(`.`)}function jg({cluster:{fqdn:e},domain:{domain:t,id:n}}){let r=Ag(t),[i,a,o]=zu(r,e||``,n);return(0,G.jsxs)(`div`,{className:`grid gap-4 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,G.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,G.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:i,children:(0,G.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:a,children:(0,G.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,G.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.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,G.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,G.jsx)(P,{type:`button`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:o,children:(0,G.jsx)(sr,{className:`w-3 h-3`})})]})}),(0,G.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 Mg({certificate:e,domain:t,cluster:n}){let r=Ag(t.domain),[i,a,o]=zu(r,n.fqdn||``,t.id),s=(0,W.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,G.jsxs)(`div`,{className:`w-full max-w-2xl border border-border/50 rounded-md p-4 bg-gray-900/20`,children:[(0,G.jsxs)(`div`,{className:`mb-4`,children:[(0,G.jsx)(`div`,{className:`w-full h-1.5 rounded-full overflow-clip flex shadow-sm bg-gray-800`,children:(0,G.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,G.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-light mt-1 italic`,children:s.text})]}),(0,G.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] text-sm`,children:[(0,G.jsx)(`div`,{className:`col-span-1 text-xs text-muted-foreground`,children:`CNAME:`}),(0,G.jsxs)(`div`,{className:`col-span-1 flex gap-2 items-center flex-wrap`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,G.jsx)(`span`,{className:`truncate max-w-[150px]`,title:r,children:r}),(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:i,title:`Copy Name`,children:(0,G.jsx)(sr,{className:`w-3 h-3`})})]}),(0,G.jsx)(Ng,{}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,G.jsx)(`span`,{className:`truncate max-w-[200px]`,title:n.fqdn||``,children:n.fqdn}),(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:a,title:`Copy Target`,children:(0,G.jsx)(sr,{className:`w-3 h-3`})})]})]}),(0,G.jsx)(`div`,{className:`col-span-1 text-[10px] text-muted-foreground`,children:`Domain ID:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-[10px] text-muted-foreground italic`,children:[(0,G.jsx)(`span`,{className:`truncate max-w-[200px]`,children:t.id}),(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`sm`,className:`h-3 w-3 p-0`,onClick:o,title:`Copy ID`,children:(0,G.jsx)(sr,{className:`w-2.5 h-2.5`})})]})})]})]})}function Ng(){return(0,G.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,G.jsx)(`path`,{d:`M5 12h14`}),(0,G.jsx)(`path`,{d:`m12 5 7 7-7 7`})]})}function Pg(e){let{enabled:t,entityId:n,databaseName:r,tableName:i,searchAttribute:a,sort:o,pageIndex:s,pageSize:c,onlyIfCached:l,getAttributes:u}=e;return R({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:()=>Fg(e)})}async function Fg({instanceClient:e,databaseName:t,tableName:n,searchAttribute:r,sort:i,pageIndex:a,pageSize:o,onlyIfCached:s,getAttributes:c,headers: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,headers:l,validateStatus:e=>e>=200&&e<400||e===404});return d.status===404?{data:[]}:d}function Ig(e){return R({queryKey:[e,`ChallengeCertificate`],queryFn:async()=>{if(!e)return[];let{data:t}=await Fg({searchAttribute:`domain`,entityId:e,databaseName:`data`,tableName:`ChallengeCertificate`,sort:{attribute:`domain`,descending:!0},instanceClient:o({id:e,forceFabricConnect:!0}),onlyIfCached:!1,pageIndex:0,pageSize:100});return t},enabled:!!e,refetchInterval:ns(5e3),retry:rs()})}function Lg(e){return V(Ig(e))}function Rg({domain:{challengeToken:e,challengeTxtRecord:t,domain:n,id:r},cluster:{fqdn:i}}){let a=Ag(n),[o,s,c,l,u]=zu(t,e,a,i||``,r);return(0,G.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,G.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,G.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`TXT`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:o,children:(0,G.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Content:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:s,children:(0,G.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,G.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,G.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:c,children:(0,G.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:l,children:(0,G.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,G.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.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,G.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,G.jsx)(P,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:u,children:(0,G.jsx)(sr,{className:`w-3 h-3`})})]})}),(0,G.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.`})]})}async function zg({clusterId:e,domainIds:t,generateDomainCerts:n}){let{data:r}=await M.put(`/Cluster/${e}`,{domainIds:t,generateDomainCerts:n},{timeout:0});return r}function Bg(){return L({mutationFn:e=>zg(e)})}S({domainId:A()});async function Vg(e){let{data:t}=await M.delete(`/Domain/${e.domainId}`);return t}function Hg(){return L({mutationFn:e=>Vg(e)})}function Ug(e){return[...new Set(e)]}var Wg=lm();function Gg(e,t,n){let{data:r}=Lg(e.id),i=(0,W.useMemo)(()=>!!r?.some(e=>!e.issueDate||e.inProgress),[r]),{mutate:a,isPending:o}=Bg(),{mutate:s,isPending:c}=Hg(),l=o||c,u=(0,W.useCallback)((t,n)=>{if(!qo(e.status)){H.error(`Cluster is currently `+e.status,{description:`To bind a domain, it must be running.`});return}a({clusterId:e.id,domainIds:Ug((e.domainIds?.slice()||[]).concat([t])),generateDomainCerts:n},{onSuccess:()=>{Ci.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),H.success(`Domain bound!`+(n?` Certificates are being generated in the background now.`:``))}})},[a,e]),d=(0,W.useCallback)(t=>{s({domainId:t},{onSuccess:()=>{Ci.invalidateQueries({queryKey:[e.organizationId,`domains`],refetchType:`active`}),H.success(`Domain removed!`)}})},[s]),f=(0,W.useCallback)(t=>{a({clusterId:e.id,domainIds:(e.domainIds?.slice()||[]).filter(e=>e!==t),generateDomainCerts:!1},{onSuccess:()=>{Ci.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),H.success(`Domain unbound!`)}})},[s]);return(0,W.useMemo)(()=>[Wg.display({id:`select`,header:`Bind`,size:50,cell:r=>{let a=r.row.original;return a.status===`ACTIVE`&&!a.clusterId&&!wu(e)?(0,G.jsx)(`label`,{className:`p-10 -m-10`,children:(0,G.jsx)(`input`,{type:`checkbox`,checked:t.includes(a.id),onChange:()=>n(a.id),disabled:l||i})}):null}}),Wg.display({header:`Domains`,id:`domain`,enableSorting:!1,size:150,cell:e=>{let t=e.row.original;return(0,G.jsxs)(Ba,{children:[(0,G.jsx)(Va,{asChild:!0,children:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{children:t.domain}),(0,G.jsx)(P,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l||!!t.clusterId,onClick:()=>d(t.id),children:`Remove Domain`})]})}),(0,G.jsx)(Ha,{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!`})]})}}),Wg.display({header:`Next Steps`,enableSorting:!1,size:500,id:`nextSteps`,cell:t=>{let n=t.row.original,i=r?.find(e=>e.domain===n.domain);return n.status===`ACTIVE`&&n.clusterId?e.id===n.clusterId?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{children:`Bound to this cluster`}),i&&(!i.issueDate||i.inProgress)&&(0,G.jsx)(`div`,{className:`py-2`,children:(0,G.jsx)(Mg,{certificate:i,domain:n,cluster:e})}),(0,G.jsx)(P,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l,onClick:()=>f(n.id),children:`Unbind Domain`})]}):`Bound to cluster ${n.clusterId}`:n.status===`PENDING_VALIDATION`?(0,G.jsx)(Rg,{domain:n,cluster:e}):wu(e)?`Cannot be associated with this self-managed cluster.`:n.status===`ACTIVE`&&!n.clusterId?(0,G.jsx)(jg,{cluster:e,domain:n}):n.status}})],[e,u,l,r,i,t,n])}var Kg=S({domain:A(),organizationId:A()});async function qg(e){let{data:t}=await M.post(`/Domain/`,e);return t}function Jg(){return L({mutationFn:e=>qg(e)})}async function Yg(e){let{data:t}=await M.post(`/Domain/${e}/validate`);return t}async function Xg(e){let{data:t}=await M.get(`/Domain/?organizationId=${e}`);return t}function Zg(e){return R({queryKey:[e,`domains`],queryFn:()=>Xg(e)})}function Qg(){let{organizationId:e,clusterId:t}=z({strict:!1}),{data:n}=_e(os(t,!0)),{update:r}=lu(e),{data:i,refetch:a,isFetching:o,isRefetching:s}=V(Zg(e)),c=(0,W.useMemo)(()=>i?.filter(e=>e.status===`PENDING_VALIDATION`)||[],[i]),[l]=(0,W.useState)({attribute:`domain`,descending:!1}),u=(0,W.useMemo)(()=>[{desc:l.descending,id:l.attribute}],[l]),d=hm(a),[f,p]=(0,W.useState)([]),m=(0,W.useCallback)(e=>{p(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),{mutate:g,isPending:_}=Bg(),v=(0,W.useCallback)(()=>{if(!qo(n.status)){H.error(`Cluster is currently `+n.status,{description:`To bind a domain, it must be running.`});return}g({clusterId:n.id,domainIds:Ug((n.domainIds?.slice()||[]).concat(f)),generateDomainCerts:!0},{onSuccess:()=>{Ci.invalidateQueries({queryKey:[n.organizationId],refetchType:`active`}),H.success(`Domain(s) bound! Certificates are being generated in the background now.`),p([])}})},[n,f,g]),{mutateAsync:y,isPending:b}=Jg(),x=Pt({resolver:Ke(Kg),defaultValues:{domain:``,organizationId:e}}),S=(0,W.useCallback)(async e=>{if(e){let t=e.domain.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean);for(let n of t)await y({...e,domain:n});x.reset(),await a(),H.success(`${h(t.length,`Domain`,`Domains`)} added! Please add the txt record above to your domain registrar.`)}},[y,x,a]),C=(0,W.useCallback)(async()=>{let e=`Validating ${h(c.length,`domain`,`domains`)}...`,t=`validatingDomains`,n=0,r=0;for(let i of c)try{H.loading(e,{description:`${n++} of ${c.length} checked`,id:t}),await Yg(i.id)}catch{r+=1}r>0?H.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(),H.success(`Validation succeeded!`,{description:`Please take a look at the next steps for newly verified domains.`,id:t}))},[c]),w=Gg(n,f,m),T=x.watch(`domain`),E=(0,W.useMemo)(()=>typeof T==`string`&&T.trim().split(`.`).length===2,[T]),D=(0,W.useCallback)(()=>{typeof T==`string`&&x.setValue(`domain`,`${T.trim()}, www.${T.trim()}`)},[T,x]);return(0,G.jsx)(um,{data:i||[],isFetching:o||s,columns:w,sortingState:u,children:(0,G.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,G.jsx)(q,{...x,children:(0,G.jsxs)(`form`,{id:`cluster-add-domain-form`,name:`cluster-add-domain-form`,onSubmit:x.handleSubmit(S),className:`flex gap-1 flex-col md:flex-row`,children:[(0,G.jsx)(Y,{control:x.control,name:`domain`,render:({field:e})=>(0,G.jsxs)(X,{className:`flex-1`,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`New Domain Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,enterKeyHint:`done`,autoComplete:`off`,...e})}),E&&(0,G.jsxs)(`div`,{className:`mt-1 flex gap-4`,children:[`Adding an apex domain?`,(0,G.jsx)(P,{variant:`positiveOutline`,type:`button`,onClick:D,children:`Add www as well`})]}),(0,G.jsx)(Q,{children:(0,G.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,G.jsxs)(`div`,{className:`flex-0 self-start flex gap-1 md:pt-6.5`,children:[(0,G.jsxs)(P,{type:`submit`,variant:`submit`,disabled:b,children:[(0,G.jsx)(Gr,{}),` Add`]}),c.length>0&&(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:C,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,G.jsx)(kr,{}),` `,(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`V`}),`alidate`]})]}),(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:d,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,G.jsx)(Kr,{}),` `,(0,G.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,G.jsx)(`u`,{children:`R`}),`efresh`]})]})]})]})}),f.length>0&&(0,G.jsx)(`div`,{className:`flex-0 self-start md:pt-6.5`,children:(0,G.jsxs)(P,{variant:`submit`,onClick:v,disabled:_,children:[(0,G.jsx)(Xr,{}),` Bind `,h(f.length,`Domain`,`Domains`)]})})]})})}function $g(){return(0,G.jsx)(Og,{className:`flex flex-col justify-start max-w-4xl`,children:(0,G.jsx)(Qg,{})})}var e_=S({username:ls,role:A().nonempty({error:`Please select a role.`}),password:cs.min(8,{error:`Password must be at least 8 characters long.`}),confirmPassword:A()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});async function t_(e){await M.patch(`/ResetPasswordUpdater/${e}`)}async function n_(e){let{instanceClient:t,...n}=e,{data:r}=await t.post(`/`,{operation:`add_user`,...n});return r}function r_(){return L({mutationFn:n_})}async function i_({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 a_(){return L({mutationFn:i_})}async function o_({username:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_user`,username:e});return n}function s_(){return L({mutationFn:o_})}async function c_({clusterId:e,initialUsername:t,desiredUsername:n,newPassword:r,tempPassword:i,instanceClient:a}){if(!i)throw Error(`You may not have permission to set the password on this cluster.`);let o=a;try{let a=await Ho({username:t,password:i,instanceClient:o,entityId:e});return a.instanceClient&&(o=a.instanceClient),n===`HDB_ADMIN`?await i_({username:n,password:r,instanceClient:o}):(await n_({username:n,password:r,role:`super_user`,active:!0,instanceClient:o}),await Ho({username:n,password:r,instanceClient:o,entityId:e}),await o_({username:g,instanceClient:o})),await t_(e),a}catch(t){throw await d({entityId:e,instanceClient:o}),t}}function l_(){return L({mutationFn:c_})}function u_(){let{user:e}=wn(),{clusterId:t}=z({strict:!1}),{data:n}=V(os(t,!0)),r=I(),i=Ie(),a=(0,W.useMemo)(()=>c(n),[n]),o=Wa({operationsUrl:a}),{redirect:s}=he({strict:!1}),l=pe(),d=Pt({resolver:Ke(e_),defaultValues:{confirmPassword:``,password:``,role:`super_user`,username:e?.email??``}}),{setFocus:f,control:p,handleSubmit:m}=d;(0,W.useEffect)(()=>{f(`password`)},[f]);let h=n?.instances?.find(e=>e.tempPassword)?.tempPassword,_=Qo(n),{mutate:v,isPending:y}=l_(),b=(0,W.useCallback)(async e=>{if(!a){H.error(`Cluster is not yet fully loaded, please wait a moment before trying to sign in.`);return}if(!_){H.error(`Some instances are still starting up. You can create your admin user once they are all running.`);return}v({instanceClient:o,clusterId:t,newPassword:e.password,tempPassword:h,initialUsername:g,desiredUsername:e.username},{onSuccess:async({message:e,user:a})=>{H.success(e),u.setUserForEntity(n,a),await as(i,t),l.invalidate(),await r({to:s?.startsWith(`/`)?s:`../`})}})},[n,t,o,_,r,a,i,s,l,v,h]);return n&&!n.resetPassword?(0,G.jsx)(ce,{to:`../sign-in`,replace:!0}):n&&!_?(0,G.jsx)(ce,{to:`../starting-up`,replace:!0}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`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,G.jsx)(Po,{})}),(0,G.jsx)(`div`,{className:`items-center justify-center flex mt-32 py-4 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,G.jsxs)(`div`,{className:`text-foreground w-xs`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light`,children:`Create Admin User`}),(0,G.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,G.jsx)(q,{...d,children:(0,G.jsxs)(`form`,{id:`cluster-create-admin-form`,name:`cluster-create-admin-form`,onSubmit:m(b),className:`my-4`,children:[(0,G.jsx)(Y,{control:p,name:`username`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-4`,children:[(0,G.jsx)(Z,{children:`Username`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{autoComplete:`username`,type:`text`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:p,name:`password`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-4`,children:[(0,G.jsx)(Z,{children:`Password`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,autoComplete:`new-password`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:p,name:`confirmPassword`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-4`,children:[(0,G.jsx)(Z,{children:`Confirm Password`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,autoComplete:`new-password`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(P,{disabled:y,type:`submit`,variant:`submit`,className:`w-full my-2`,children:`Create Admin User`})]})}),(0,G.jsxs)(`p`,{className:`text-muted-foreground flex gap-2 align-middle`,children:[(0,G.jsx)(Fn,{size:36,className:`flex-none`}),(0,G.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 d_({columns:e,data:t,renderRowWrapper:n}){let r=Le({features:cm,data:t,columns:e});return(0,G.jsx)(`div`,{className:`bg-card dark:bg-black-dark rounded-md`,children:(0,G.jsxs)(tm,{children:[(0,G.jsx)(nm,{children:r.getHeaderGroups().map(e=>(0,G.jsx)(im,{className:`border-none`,children:e.headers.map(e=>(0,G.jsx)(am,{className:`p-4`,style:{width:`${e.getSize()}%`},children:e.isPlaceholder?null:Me(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,G.jsx)(rm,{className:`bg-background dark:bg-black`,children:r.getRowModel().rows?.length?r.getRowModel().rows.map(e=>{let t=(0,G.jsx)(im,{"data-state":e.getIsSelected()&&`selected`,className:`hover:bg-muted/10 data-[state=selected]:bg-muted`,children:e.getVisibleCells().map(e=>(0,G.jsx)(sm,{className:`p-4`,style:{width:`${e.column.getSize()}%`},children:Me(e.column.columnDef.cell,e.getContext())},e.id))});return(0,G.jsx)(W.Fragment,{children:n?n(e.original,t):t},e.id)}):(0,G.jsx)(im,{children:(0,G.jsx)(sm,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function f_(){return(0,G.jsx)(`div`,{className:`flex-col items-center justify-center px-16 space-y-3 text-center pt-30`,children:(0,G.jsx)(`p`,{children:`No instances found.`})})}async function p_({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 m_({instanceId:e,action:t,safeMode:n}){let r=n===void 0?{}:{safeMode:n},{data:i}=await M.post(`/HDBInstance/${e}/container/${t}`,r);return i}function h_(){return L({mutationFn:m_})}var g_={stop:`Stopping`,start:`Starting`,restart:`Restarting`};function __(e){let{clusterId:t}=z({strict:!1}),{mutateAsync:n,isPending:r}=h_(),i=Ie();return{run:(0,W.useCallback)(async(r,a)=>{let o=a?.label??g_[r],s=e.name??e.id,c=H.loading(o,{description:`${o} ${s}. Status will update shortly.`,duration:3e4,action:{label:`Dismiss`,onClick:()=>H.dismiss()}});try{await n({instanceId:e.id,action:r,safeMode:a?.safeMode}),t&&i.invalidateQueries({queryKey:[t]}),i.invalidateQueries({queryKey:[e.id]}),H.dismiss(c),H.success(`Request accepted`,{description:`${s} is ${o.toLowerCase()}. The status will update automatically.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}})}catch{H.dismiss(c)}},[t,e.id,e.name,n,i]),isPending:r}}function v_({entityId:e,instanceClient:t},n){return R({queryKey:[`get_status`,e],staleTime:9e3,refetchInterval:ns(1e4),retry:rs(),retryDelay:1e4,throwOnError:!1,enabled:n,queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`get_status`});return e}})}function y_(e,t){return e?.systemStatus?.find(e=>e.id===t)?.status}async function b_({instanceClient:e,id:t,status:n}){let{data:r}=await e.post(`/`,{operation:`set_status`,id:t,status:n});return r}function x_(){return L({mutationFn:b_,onSuccess:(e,t)=>Ci.invalidateQueries({queryKey:[`get_status`,t.entityId]})})}var S_=[`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`];function C_(e,t,n){let{user:r}=Dn(e.id),i=(0,W.useMemo)(()=>p(e),[e]),a=Wa({operationsUrl:i}),{update:o}=mu(),s=u.checkForFabricConnect(e.id),c=K({operationsUrl:i,instanceId:e.id,forceFabricConnect:!0}),{data:l}=V(v_(c,n&&o&&!Ko(e.status))),d=y_(l,`availability`)||`Unknown`,f=d===`Available`,m=d===`Unavailable`,{mutate:h,isPending:g}=x_(),{run:_,isPending:v}=__(e),[y,b]=(0,W.useState)(null),x=e.instanceFqdn,S=Mp({secure:e.operationsApiSecure?`true`:`false`,port:e.operationsApiPort,fqdn:e.instanceFqdn}),[C,w]=zu(x??``,S),T=(0,W.useCallback)(async()=>{await p_({instance:e,instanceClient:a})},[e,a]),E=!!e.status&&S_.includes(e.status),D=!!r&&!s,O=E,k=!!x,A=o&&E&&(f||m),j=e.status===`RUNNING`,ee=e.status===`STOPPED`,M=o&&!t&&(j||ee),N=[O&&D&&{key:`direct-connect`,to:`../instance/${e.id}/`,icon:(0,G.jsx)($r,{className:`text-green`}),label:`Direct Connect`},O&&D&&{key:`direct-sign-out`,onClick:T,variant:`destructive`,icon:(0,G.jsx)(Nr,{}),label:`Direct Sign Out`},O&&!D&&o&&!t&&{key:`fabric-connect`,to:`../instance/${e.id}/`,icon:(0,G.jsx)($r,{className:`text-green`}),label:`Fabric Connect`},O&&!D&&{key:`direct-sign-in`,to:`../instance/${e.id}/sign-in`,icon:(0,G.jsx)(Mr,{}),label:`Direct Sign In`},O&&k&&{type:`separator`,key:`copy-sep`},k&&{key:`copy-fqdn`,onClick:C,icon:(0,G.jsx)(nr,{}),label:`Copy Instance FQDN`},k&&{key:`copy-api`,onClick:w,icon:(0,G.jsx)(nr,{}),label:`Copy API URL`},(O||k)&&A&&{type:`separator`,key:`rotation-sep`},A&&f&&{key:`out-of-rotation`,variant:`destructive`,disabled:g,onClick:()=>h({...c,id:`availability`,status:`Unavailable`}),icon:(0,G.jsx)(ni,{}),label:`Bring out of rotation`},A&&m&&{key:`into-rotation`,disabled:g,onClick:()=>h({...c,id:`availability`,status:`Available`}),icon:(0,G.jsx)(ti,{}),label:`Bring back into rotation`},(O||k||A)&&M&&{type:`separator`,key:`container-sep`},M&&{type:`label`,key:`container-label`,className:`text-gray-600 text-xs`,label:`Container`},M&&ee&&{key:`container-start`,disabled:v,onClick:()=>void _(`start`,{safeMode:!1}),icon:(0,G.jsx)(Wr,{}),label:`Start`},M&&ee&&{key:`container-start-safe`,disabled:v,onClick:()=>b(`start`),icon:(0,G.jsx)(Or,{}),label:`Start in safe mode`},M&&j&&{key:`container-restart`,disabled:v,onClick:()=>void _(`restart`,{safeMode:!1}),icon:(0,G.jsx)(Yr,{}),label:`Restart`},M&&j&&{key:`container-restart-safe`,disabled:v,onClick:()=>b(`restart`),icon:(0,G.jsx)(Or,{}),label:`Restart in safe mode`},M&&j&&{key:`container-stop`,variant:`destructive`,disabled:v,onClick:()=>void _(`stop`),icon:(0,G.jsx)(ai,{}),label:`Stop`}].filter(Qa),P=(0,G.jsx)(Au,{open:y!==null,setOpen:e=>{e||b(null)},action:y??`restart`,targetName:e.name??e.id,scope:`instance`,isPending:v,onConfirm:()=>{let e=y;b(null),e&&_(e,{safeMode:!0,label:e===`start`?`Starting in safe mode`:`Restarting in safe mode`})}});return N.length?{items:[{type:`label`,key:`label`,className:`text-gray-600 text-xs`,label:`Options`},{type:`separator`,key:`label-sep`},...N],dialog:P}:{items:[],dialog:P}}function w_({instance:e,isSelfManaged:t}){let[n,r]=(0,W.useState)(!1),{items:i,dialog:a}=C_(e,t,n);return i.length?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(wi,{open:n,onOpenChange:r,children:[(0,G.jsx)(Ti,{asChild:!0,children:(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Instance options`,children:(0,G.jsx)(ur,{})})}),(0,G.jsx)(Ei,{align:`end`,className:`min-w-48`,children:Gc(i,`dropdown`)})]}),a]}):null}function T_({isSelfManaged:e,instance:t}){let{user:n,isLoading:r}=Dn(t.id),i=Wa({operationsUrl:(0,W.useMemo)(()=>p(t),[t])}),{update:a}=mu(),o=u.checkForFabricConnect(t.id),s=(0,W.useCallback)(async()=>{await p_({instance:t,instanceClient:i})},[t,i]);return Ko(t.status)?(0,G.jsx)(`span`,{className:`text-muted-foreground text-sm`,children:`—`}):r||!t.status||![`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`].includes(t.status)?(0,G.jsx)(Ar,{className:`animate-spin`,color:`gray`}):!n||o?(0,G.jsxs)(`span`,{className:`flex gap-4`,children:[a&&!e&&(0,G.jsx)(B,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Connect to ${t.name} instance`,title:`Connect to ${t.name} instance`,children:(0,G.jsx)(P,{variant:`positiveOutline`,children:`Fabric Connect`})}),(0,G.jsx)(B,{to:`../instance/${t.id}/sign-in`,className:`text-sm`,"aria-label":`Sign in to ${t.name} instance`,title:`Sign in to ${t.name} instance`,children:(0,G.jsx)(P,{variant:a?`defaultOutline`:`positiveOutline`,children:`Direct Sign In`})})]}):(0,G.jsxs)(`span`,{className:`flex gap-4`,children:[(0,G.jsx)(B,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Go to ${t.name} instance`,title:`Go to ${t.name} instance`,children:(0,G.jsx)(P,{variant:`positiveOutline`,children:`Direct Connect`})}),(0,G.jsx)(P,{variant:`destructiveOutline`,className:`text-sm`,"aria-label":`Sign out from ${t.name} instance`,title:`Sign out from ${t.name} instance`,onClick:s,children:`Direct Sign Out`})]})}function E_({instance:e,isSelfManaged:t,children:n}){let[r,i]=(0,W.useState)(!1),{items:a,dialog:o}=C_(e,t,r);return a.length?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Lc,{onOpenChange:i,children:[(0,G.jsx)(Rc,{asChild:!0,children:n}),(0,G.jsx)(zc,{className:`min-w-48`,children:Gc(a,`context`)})]}),o]}):(0,G.jsx)(G.Fragment,{children:n})}function D_({instance:e,index:t}){let{update:n}=mu(),r=K({operationsUrl:(0,W.useMemo)(()=>p(e),[e]),instanceId:e.id,forceFabricConnect:!0}),{mutate:i,isPending:a}=x_(),[o,s]=(0,W.useState)(!1);(0,W.useEffect)(()=>{let e=setTimeout(()=>s(!0),t*500);return()=>clearTimeout(e)},[t]);let c=Ko(e.status),{data:l,isLoading:u,isFetching:d}=V(v_(r,o&&n&&!c)),f=y_(l,`availability`)||`Unknown`,m=f===`Available`,h=f===`Unavailable`;return n?c?(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,G.jsxs)(Ba,{children:[(0,G.jsx)(Va,{asChild:!0,children:(0,G.jsx)(`span`,{className:`inline-block size-4 rounded-full bg-muted-foreground/40`,"aria-label":`Not running`})}),(0,G.jsx)(Ha,{children:`Not running`})]})}):(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(Ba,{children:[(0,G.jsx)(Va,{asChild:!0,children:(0,G.jsx)(`div`,{className:`flex items-center`,children:u||!o||d&&!l?(0,G.jsx)(Ar,{className:`animate-spin size-5 text-muted-foreground`}):(0,G.jsx)(Ji,{variant:m?`success`:h?`destructive`:`default`,className:`size-4 rounded-full p-0`,children:(0,G.jsx)(`span`,{className:`sr-only`,children:m?`Online`:`Offline`})})})}),(0,G.jsxs)(Ha,{children:[d&&l?`Refreshing... `:``,f]})]}),n&&(0,G.jsxs)(`div`,{className:`flex gap-1`,children:[m&&(0,G.jsxs)(Ba,{children:[(0,G.jsx)(Va,{asChild:!0,children:(0,G.jsx)(P,{type:`button`,variant:`destructiveGhost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Unavailable`}),disabled:a,children:a?(0,G.jsx)(Ar,{className:`animate-spin size-4`}):(0,G.jsx)(ni,{className:`size-4`})})}),(0,G.jsx)(Ha,{children:`Bring out of rotation`})]}),h&&(0,G.jsxs)(Ba,{children:[(0,G.jsx)(Va,{asChild:!0,children:(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Available`}),disabled:a,children:a?(0,G.jsx)(Ar,{className:`animate-spin size-4`}):(0,G.jsx)(ti,{className:`size-4`})})}),(0,G.jsx)(Ha,{children:`Bring back into rotation`})]})]})]}):null}function O_(){let{clusterId:e}=z({strict:!1}),{data:t,isLoading:n}=V(os(e,!0)),r=wu(t),i=(0,W.useMemo)(()=>[{id:`instanceActions`,size:1,minSize:1,cell:e=>(0,G.jsx)(`div`,{className:`flex justify-end gap-2 items-center`,children:(0,G.jsx)(T_,{isSelfManaged:r,instance:e.row.original})})},r&&{accessorKey:`instanceFqdn`,size:90,header:`URL`,cell:e=>Mp({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,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(D_,{instance:e.row.original,index:e.row.index}),t?(0,G.jsx)(Ji,{variant:Go(t),children:Mo(t)}):null,e.row.original.safeMode&&!Ko(e.row.original.status)?(0,G.jsxs)(Ji,{variant:`warning`,title:`Running in safe mode — user apps/components are not loaded`,children:[(0,G.jsx)(Or,{}),`Safe mode`]}):null]})}},!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,G.jsxs)(G.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,G.jsx)(`div`,{className:`flex justify-end`,children:(0,G.jsx)(w_,{isSelfManaged:r,instance:e.row.original})})}].filter(Qa),[r]),a=(0,W.useMemo)(()=>t?.instances?t.instances.filter(e=>e.status&&!Bo.includes(e.status)).sort(nd):[],[t]);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Fc,{}),(0,G.jsx)(Uu,{children:(0,G.jsx)(On,{className:`p-0 min-h-96`,children:(0,G.jsx)(Mn,{className:`p-0 min-h-96`,children:n?(0,G.jsx)(Kf,{}):a.length?(0,G.jsx)(d_,{data:a,columns:i,renderRowWrapper:(e,t)=>(0,G.jsx)(E_,{instance:e,isSelfManaged:r,children:t})}):(0,G.jsx)(f_,{})})})})]})}function k_(){let{clusterId:e}=z({strict:!1}),{immediate:t}=he({strict:!1}),n=t===!0||t===`true`,{data:r,isLoading:i}=V(os(e,2e3)),a=r?.status,o=(0,W.useMemo)(()=>a&&zo.includes(a),[a]);return i||!r?(0,G.jsx)(Og,{className:`flex justify-center`,children:(0,G.jsx)(Kf,{})}):o?(0,G.jsx)(Og,{className:`flex justify-center`,children:(0,G.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,G.jsx)(`h1`,{className:`text-xl text-center`,children:`All done!`}),(0,G.jsx)(ku,{cluster:r,forceProgressBarVisible:!0}),(0,G.jsx)(`p`,{children:`Your cluster finished updating, and is ready for interaction.`}),(0,G.jsx)(`div`,{className:`text-center`,children:(0,G.jsx)(Tu,{cluster:r})})]})}):(0,G.jsx)(Og,{className:`flex justify-center`,children:(0,G.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,G.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,G.jsx)(ku,{cluster:r,forceProgressBarVisible:!0}),(0,G.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,G.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,G.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 A_({children:e,className:t}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Fc,{}),(0,G.jsx)(`div`,{className:y(`mt-32 px-4 py-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] flex justify-center`,t),children:e})]})}function j_(){let e=pe(),{clusterId:t}=z({strict:!1}),{data:n,isLoading:r}=V(os(t,2e3)),i=n?.status,a=(0,W.useMemo)(()=>i&&zo.includes(i)&&Qo(n),[i,n]),o=Jo(i),[,s]=xn(vn.SavedClusterState,null),c=(0,W.useCallback)(()=>{s(n),e.navigate({to:`/${n.organizationId}/new-cluster`})},[n,e,s]);return r||!n?(0,G.jsx)(A_,{className:`flex justify-center`,children:(0,G.jsx)(Kf,{})}):o?(0,G.jsx)(A_,{className:`flex justify-center`,children:(0,G.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4 items-center`,children:[(0,G.jsx)(rr,{className:`w-24 h-24`}),(0,G.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,G.jsx)(_s,{}),` if you want more help.`]}),(0,G.jsx)(P,{type:`button`,variant:`positiveOutline`,onClick:c,children:`Try Again`})]})}):a?(0,G.jsx)(A_,{className:`flex justify-center`,children:(0,G.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,G.jsx)(`h1`,{className:`text-xl text-center`,children:`It's ready!`}),(0,G.jsx)(ku,{cluster:n,forceProgressBarVisible:!0}),(0,G.jsxs)(`p`,{children:[`Let's set up your secure, browser-to-cluster connection now.`,` `,(0,G.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,G.jsx)(`em`,{children:`Direct Connect`}),`! Once you create your user, you will have the option to`,` `,(0,G.jsx)(`em`,{children:`Fabric Connect`}),` from your Fabric account without having to sign in again.`]})]}),(0,G.jsx)(`div`,{className:`text-center`,children:(0,G.jsx)(Tu,{cluster:n})})]})}):(0,G.jsx)(A_,{className:`flex justify-center`,children:(0,G.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,G.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,G.jsx)(ku,{cluster:n,forceProgressBarVisible:!0}),(0,G.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,G.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,G.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 M_(){let{clusterId:e}=z({strict:!1}),{data:t,isLoading:n}=mg(e);if(n)return(0,G.jsxs)(Og,{className:`max-w-4xl pb-20`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:`Usage`}),(0,G.jsx)(`div`,{className:`flex justify-center py-16 text-muted-foreground`,children:(0,G.jsx)(Ar,{className:`size-6 animate-spin`})})]});let r=t&&!t.selfManaged?R_(t.regions):null;return(0,G.jsxs)(Og,{className:`max-w-4xl pb-20`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:`Usage`}),t?t.selfManaged?(0,G.jsx)(V_,{children:`Usage isn't tracked for self-hosted clusters — they run under their own license.`}):t.regions.length===0?(0,G.jsx)(V_,{children:`No usage has been recorded for the current cycle yet.`}):(0,G.jsxs)(`div`,{className:`mt-5 space-y-3`,children:[t.regions.map(e=>(0,G.jsx)(N_,{region:e,showPlanInfo:r==null},e.region??e.regionIds.join())),r&&(0,G.jsx)(P_,{header:(0,G.jsx)(F_,{title:`Plan limits & resources`}),aside:r.planId??void 0,children:(0,G.jsx)(I_,{rateLimits:r.rateLimits,resourcesPerInstance:r.resourcesPerInstance})})]}):(0,G.jsx)(H_,{})]})}function N_({region:e,showPlanInfo:t}){let n=ug.map(t=>dg(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 ${L_(e.expiresAt)}`:null].filter(Boolean).join(` · `);return(0,G.jsxs)(P_,{defaultOpen:e.status!==`lapsed`,aside:e.regionIds.length>0?e.regionIds.join(`, `):void 0,header:(0,G.jsxs)(F_,{title:e.region??`Region`,meta:r,children:[e.status===`exhausted`&&(0,G.jsx)(`span`,{className:`rounded-full bg-yellow/10 px-2 py-0.5 text-[11px] text-yellow`,children:`Cycle exhausted`}),e.status===`lapsed`&&(0,G.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground`,children:`No active license`})]}),children:[(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-x-10 gap-y-4 sm:grid-cols-2`,children:n.map(e=>(0,G.jsx)(fg,{...e},e.label))}),t&&(0,G.jsx)(I_,{rateLimits:e.rateLimits,resourcesPerInstance:e.resourcesPerInstance})]})}function P_({header:e,aside:t,defaultOpen:n=!0,children:r}){let[i,a]=(0,W.useState)(n);return(0,G.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-border`,children:[(0,G.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,G.jsx)(Yn,{className:`size-4 shrink-0 text-muted-foreground transition-transform ${i?`rotate-90`:``}`}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:e}),t&&(0,G.jsx)(`span`,{className:`shrink-0 self-start pt-0.5 font-mono text-[11px] text-muted-foreground/70`,children:t})]}),i&&(0,G.jsx)(`div`,{className:`border-t border-border px-4 py-4`,children:r})]})}function F_({title:e,meta:t,children:n}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e}),n]}),t&&(0,G.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t})]})}function I_({rateLimits:e,resourcesPerInstance:t}){let n=e,r=n?B_([[`Reads / minute`,n.readsPerMinute,vp],[`Read bandwidth / minute`,n.readsPerMinuteBytes,_p],[`Writes / minute`,n.writesPerMinute,vp],[`Write bandwidth / minute`,n.writesPerMinuteBytes,_p],[`Real-time deliveries / minute`,n.realTimeDeliveriesPerMinute,vp],[`Real-time bandwidth / minute`,n.realTimeDeliveryBytesPerMinute,_p],[`TLS handshakes (cycle)`,n.tlsHandshakes,vp]]):[],i=t,a=i?z_([[`Storage`,i.storageGb,e=>`${vp(e)} GB`],[`Memory`,i.memoryMb,e=>_p(e*1e3*1e3)],[`vCPU`,i.cpuCores,e=>`${e} ${e===1?`core`:`cores`}`],[`Threads`,i.threads,e=>String(e)]]):[];return(0,G.jsxs)(G.Fragment,{children:[r.length>0&&(0,G.jsx)(U_,{title:`Rate limits`,subtitle:`Throughput ceilings — not part of the cycle allotment, and not metered.`,children:(0,G.jsx)(W_,{rows:r})}),a.length>0&&(0,G.jsx)(U_,{title:`Per-instance resources`,subtitle:`Provisioned capacity on each instance.`,children:(0,G.jsx)(W_,{rows:a})})]})}function L_(e){return new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))}function R_(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 z_(e){return e.filter(e=>typeof e[1]==`number`&&e[1]>0).map(([e,t,n])=>[e,n(t)])}function B_(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 V_({children:e}){return(0,G.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:e})}function H_(){return(0,G.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 U_({title:e,subtitle:t,children:n}){return(0,G.jsxs)(`div`,{className:`mt-6 first:mt-0`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:e}),(0,G.jsx)(`p`,{className:`mt-0.5 mb-3 text-xs text-muted-foreground`,children:t}),n]})}function W_({rows:e}){return(0,G.jsx)(`dl`,{className:`grid grid-cols-1 gap-x-10 gap-y-2 sm:grid-cols-2`,children:e.map(([e,t])=>(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 border-b border-border/60 py-1.5 text-sm`,children:[(0,G.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,G.jsx)(`dd`,{className:`text-foreground tabular-nums`,children:t})]},e))})}F({getParentRoute:()=>ig,path:`instances`,head:()=>({meta:[{title:`Instances — Harper Fabric`}]}),component:O_}),F({getParentRoute:()=>ig,path:`starting-up`,head:()=>({meta:[{title:`Starting Up — Harper Fabric`}]}),component:j_}),F({getParentRoute:()=>ig,path:`scaling`,head:()=>({meta:[{title:`Scaling — Harper Fabric`}]}),component:k_}),F({getParentRoute:()=>ig,path:`domains`,head:()=>({meta:[{title:`Domains — Harper Fabric`}]}),component:$g}),F({getParentRoute:()=>ig,path:`usage`,head:()=>({meta:[{title:`Usage — Harper Fabric`}]}),component:M_});function G_({location:e,params:t}){let n=u.checkForFabricConnect(t.clusterId);if(u.getConnectionById(t.clusterId).user&&!n){let t=e?.search?.redirect;throw le({to:t?.startsWith(`/`)?t:`../`})}}function K_({location:e,params:t}){let n=u.checkForFabricConnect(t.instanceId);if(u.getConnectionById(t.instanceId).user&&!n){let t=e?.search?.redirect;throw le({to:t?.startsWith(`/`)?t:`../`})}}F({getParentRoute:()=>ig,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:gs,beforeLoad:G_}),F({getParentRoute:()=>ig,path:`instance/$instanceId/sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:gs,beforeLoad:K_}),F({getParentRoute:()=>ig,path:`finish-setup`,head:()=>({meta:[{title:`Create Admin User — Harper Fabric`}]}),component:u_}),F({getParentRoute:()=>ig,path:`/`,head:()=>({meta:[{title:`Cluster — Harper Fabric`}]}),component:xg});function q_(e){return F({getParentRoute:()=>e,path:`apis`,head:()=>({meta:[{title:`APIs — Harper Fabric`}]})}).lazy(()=>ne(()=>import(`./index.lazy-BrCFnpNJ.js`).then(e=>e.route),__vite__mapDeps([25,1,26,3,2,4,5,6,7,27,12,9,16,11,13,28,29])))}function J_(e,t){return[F({getParentRoute:()=>e,path:t===`cluster`?`apps`:`/`,head:()=>({meta:[{title:`Applications — Harper Fabric`}]}),component:we(()=>ne(()=>import(`./applications-kSxVoyeU.js`),__vite__mapDeps([30,1,26,3,2,4,5,6,7,27,12,9,8,10,11,13,16,31,32,20,21,14,28,29,33,22,23,24,34])),`ApplicationsEditor`)})]}async function Y_({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_certificates`});return t}function X_(e){return R({queryKey:[e.entityId,`list_certificates`],queryFn:()=>Y_(e)})}var Z_=[{header:`Certificate Name`,accessorKey:`name`,enableSorting:!0},{header:`Issuer`,accessorKey:`details.issuer`,enableSorting:!0},lm().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 Q_({className:e,...t}){return(0,G.jsx)(`textarea`,{"data-slot":`input`,className:N(`border-input file:text-foreground placeholder:text-muted-foreground selection:bg-purple
12
+ `)}}];function hm(e){return(0,W.useCallback)(async()=>{H.loading(`Refreshing...`,{id:`refreshing`});let t=Date.now();await e(),Date.now()-t<500&&await n(500),H.success(`Refreshed!`,{id:`refreshing`})},[e])}async function gm(e){let{data:t}=await M.get(`/Invoice/${e}`);return t}function _m(e,t){return R({queryKey:[e,`invoices`],queryFn:()=>gm(e),retry:!1,enabled:!!e,refetchInterval:t?1e4:void 0})}function vm(){let{organizationId:e}=z({strict:!1}),{data:t}=V(md(e)),{data:n,refetch:r,isLoading:i,isFetching:a,isRefetching:o}=V(_m(t?.type!==`ENTERPRISE`&&t?.id,!1)),s=hm(r);return t?.type===`ENTERPRISE`?(0,G.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,G.jsx)(_s,{}),`, we would love to talk!`]}):i?(0,G.jsx)(Wi,{centered:!0}):!n||!n.length?(0,G.jsxs)(`span`,{children:[`Your invoices will be shown here once one is available! Want to explore your solution with Harper more?`,` `,(0,G.jsx)(_s,{overEmail:!0}),`, we would love to talk!`]}):(0,G.jsx)(um,{data:n,columns:mm,children:(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:s,accessKey:`r`,disabled:a||o,children:[(0,G.jsx)(Kr,{}),(0,G.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,G.jsx)(`u`,{children:`R`}),`efresh`]})]})})}function ym(e){let t=F({getParentRoute:()=>e,path:`billing`,head:()=>({meta:[{title:`Billing — Harper Fabric`}]}),component:Zp}),n=F({getParentRoute:()=>t,path:`/`,head:()=>({meta:[{title:`Payment Methods — Harper Fabric`}]}),component:zf}),r=F({getParentRoute:()=>t,path:`invoices`,head:()=>({meta:[{title:`Invoices — Harper Fabric`}]}),component:vm}),i=F({getParentRoute:()=>t,path:`confirm`,head:()=>({meta:[{title:`Confirm Payment — Harper Fabric`}]}),component:Xp});return t.addChildren([n,r,i])}async function bm(e){let{data:t}=await M.get(`/OrganizationRole/${e}`);return t}function xm(e){return R({queryKey:[e,`roles`],queryFn:()=>bm(e),retry:!1,refetchInterval:ns(1e4)})}var Sm=lm(),Cm=[{header:`Role Name`,accessorKey:`roleName`,enableSorting:!1},Sm.display({header:`ID`,id:`id`,enableSorting:!1,cell:e=>(0,G.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,title:e.row.original.id,children:e.row.original.id})}),Sm.display({header:`Users Assigned`,enableSorting:!1,id:`userIds`,cell:e=>!e.row.original.userIds||e.row.original.userIds.length===0?`No users assigned`:e.row.original.userIds.length})];async function wm(e){let{data:t}=await M.post(`/Role/`,e);return t}function Tm(){return L({mutationFn:wm})}var Em=S({name:A().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:D(),delete:D()});S({roles:S({create:D(),delete:D(),update:D(),view:D()}),clusters:S({create:D(),delete:D(),update:D(),view:D(),resources:T(S({id:A(),delete:D(),update:D(),view:D(),instances:S({create:D(),delete:D(),update:D(),view:D()})}))})});function Dm(){let[e]=ja(),t=Oa();return e===`dark`||e===`system`&&t===`dark`?`vs-dark`:`light`}var Om=(0,W.lazy)(async()=>(await ne(()=>import(`./setup-DWprJyJy.js`),__vite__mapDeps([18,4,1,19,20,21,22,23,24])),{default:(await ne(()=>import(`./dist-DP8UjMB_.js`),__vite__mapDeps([19,1,4]))).default}));function km(e){return(0,G.jsx)(W.Suspense,{fallback:e.loading??null,children:(0,G.jsx)(Om,{...e})})}var Am={roles:{create:!0,view:!0,update:!0,delete:!0},clusters:{create:!0,view:!0,update:!0,delete:!0,resources:[]}};function jm({isModalOpen:e,setIsModalOpen:t}){let n=Dm(),r=Ie(),{organizationId:i}=z({strict:!1}),[a,o]=(0,W.useState)(!0),[s,c]=(0,W.useState)(JSON.stringify(Am,null,2)),{mutate:l,isPending:u}=Tm(),d=Pt({resolver:Ke(Em),defaultValues:{name:``,update:!1,delete:!1}}),f=(0,W.useCallback)(e=>{o(e.length===0)},[o]),p=(0,W.useCallback)(async e=>{let n=Ue(s);if(!n)return;let o={...e,...n,organizationId:i};e&&a&&l(o,{onSuccess:()=>{H.success(`Organization role added successfully!`),t(!1),r.invalidateQueries({queryKey:[i,`roles`],refetchType:`active`}),d.reset()},onError:e=>{H.error(`Failed to add organization role: ${e.message}`)}})},[a,s,l,d,r,t,i]);return(0,G.jsx)(fn,{onOpenChange:t,open:e,children:(0,G.jsxs)(cn,{resizable:!0,children:[(0,G.jsx)(ln,{children:`Add New Organization Role`}),(0,G.jsx)(un,{children:`Set the new organization role permissions.`}),(0,G.jsx)(q,{...d,children:(0,G.jsxs)(`form`,{id:`org-add-role-form`,name:`org-add-role-form`,className:`flex flex-1 min-h-0 flex-col gap-4 my-4`,onSubmit:d.handleSubmit(p),children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsx)(Y,{control:d.control,name:`name`,render:({field:e})=>(0,G.jsxs)(X,{className:`col-span-2`,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Role Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,className:``,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:d.control,name:`update`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Can Update Organization`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:d.control,name:`delete`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Can Delete Organization`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,G.jsx)(Q,{})]})})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,G.jsx)(km,{className:`w-full h-full`,theme:n,defaultLanguage:`json`,onValidate:f,onChange:e=>{e&&c(e)},options:{automaticLayout:!0},defaultValue:JSON.stringify(Am,null,2)})}),(0,G.jsx)(on,{children:(0,G.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,G.jsx)(P,{variant:`destructiveOutline`,type:`button`,onClick:()=>t(!1),disabled:u,children:`Cancel`}),(0,G.jsx)(P,{variant:`submit`,disabled:u||!a||!d.formState.isValid,children:`Save Changes`})]})})]})})]})})}async function Mm({roleId:e}){let{data:t}=await M.delete(`/Role/${e}`,{id:e,deleted:!0});return t}function Nm(){return L({mutationFn:({roleId:e})=>Mm({roleId:e})})}async function Pm({roleId:e,updatedRoleInfo:t}){let{data:n}=await M.put(`/Role/${e}`,t);return n}function Fm(){return L({mutationFn:({roleId:e,updatedRoleInfo:t})=>Pm({roleId:e,updatedRoleInfo:t})})}function Im({organizationId:e,roleId:t}){return R({queryKey:[e,`roles`,t],queryFn:()=>Lm(t),refetchInterval:ns(1e4),retry:rs()})}async function Lm(e){let{data:t}=await M.get(`/Role/${e}`);return t}function Rm({onRoleDeleteClick:e,setIsConfirmingRoleDeletion:t,isRoleDeletionPending:n}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ln,{children:`Confirm Role Deletion`}),(0,G.jsx)(un,{children:`Are you sure you want to delete this role? This action cannot be undone.`}),(0,G.jsxs)(on,{children:[(0,G.jsx)(P,{type:`button`,variant:`defaultOutline`,onClick:()=>t(!1),children:`Cancel`}),(0,G.jsx)(P,{variant:`destructiveOutline`,onClick:e,disabled:n,children:n?`Deleting...`:`Delete Role`})]})]})}function zm({data:e,isModalOpen:t,closeModal:n}){let r=(0,W.useCallback)(()=>n(!1),[n]);return(0,G.jsx)(fn,{onOpenChange:r,open:t,children:(0,G.jsx)(cn,{resizable:!0,children:(0,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(Bm,{roleName:e.roleName}),children:(0,G.jsx)(Vm,{data:e,closeModal:n})})})})}function Bm({roleName:e}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(ln,{children:[`Organization Role "`,e,`"`]}),(0,G.jsx)(Wi,{centered:!0,text:`Loading role…`,className:`flex-1 min-h-0`})]})}function Vm({data:e,closeModal:t}){let n=Ie(),{data:r}=_e(Im({roleId:e.id,organizationId:e.organizationId})),i=wn().user?.roles?.[e.organizationId]?.id===e.id,{update:a,remove:o}=lu(e.organizationId),{mutate:s,isPending:c}=Fm(),{mutate:l,isPending:u}=Nm(),d=Dm(),[f,p]=(0,W.useState)(!1),m=Pt({resolver:Ke(Em),defaultValues:{name:e.roleName,update:r.organization.update||!1,delete:r.organization.delete||!1}}),h=(0,W.useCallback)(()=>{l({roleId:e.id},{onSuccess:()=>{H.success(`Role deleted successfully!`),t(!0),m.reset()},onError:e=>{H.error(`Error`,{description:`Failed to delete role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}})}})},[e.id,l,m,t]),[g,_]=(0,W.useState)(!0),v=(0,W.useMemo)(()=>JSON.stringify({roles:{...r.organization.roles},clusters:{...r.organization.clusters}},null,2),[r]),[y,b]=(0,W.useState)(v),x=y!==v,S=(0,W.useCallback)(e=>{_(e.length===0)},[_]),C=(0,W.useCallback)(async r=>{if(!a)return;let i=Ue(y);if(!i)return;let o={...r,...i,organizationId:e.organizationId};y&&g&&s({roleId:e.id,updatedRoleInfo:o},{onSuccess:async()=>{H.success(`Role updated successfully!`),await n.invalidateQueries({queryKey:[e.organizationId,`roles`,e.id]}),t(!1),m.reset()},onError:e=>{H.error(`Error`,{description:`Failed to update role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}})}})},[t,e.id,e.organizationId,m,g,n,r,a,y,s]);return f?(0,G.jsx)(Rm,{onRoleDeleteClick:h,setIsConfirmingRoleDeletion:p,isRoleDeletionPending:u}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(ln,{children:[i||!a?`View`:`Edit`,` Organization Role "`,e.roleName,`"`]}),(0,G.jsx)(q,{...m,children:(0,G.jsxs)(`form`,{id:`org-edit-role-form`,name:`org-edit-role-form`,className:`flex flex-1 min-h-0 flex-col gap-4 my-4`,onSubmit:m.handleSubmit(C),children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsx)(Y,{control:m.control,name:`name`,render:({field:e})=>(0,G.jsxs)(X,{className:`col-span-2`,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Role Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,className:``,...e,disabled:!0,readOnly:!0})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:m.control,name:`update`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Can Update Organization`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,disabled:i||!a,readOnly:i||!a,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:m.control,name:`delete`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Can Delete Organization`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,disabled:i||!a,readOnly:i||!a,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,G.jsx)(Q,{})]})})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,G.jsx)(km,{className:`w-full h-full`,theme:d,defaultLanguage:`json`,onValidate:S,onChange:e=>{e&&b(e)},options:{readOnly:i||!a,automaticLayout:!0},defaultValue:y})}),!i&&(o||a)&&(0,G.jsx)(on,{children:(0,G.jsxs)(`div`,{className:`flex justify-between w-full`,children:[o&&(0,G.jsx)(P,{type:`button`,variant:`destructiveOutline`,onClick:()=>p(!0),disabled:c,children:`Delete Role`}),a&&(0,G.jsx)(P,{variant:`submit`,disabled:!g||c||!m.formState.isValid||!m.formState.isDirty&&!x,children:`Save Changes`})]})})]})})]})}function Hm(){let e=I(),t=Ie(),{organizationId:n,orgRoleId:r}=z({strict:!1}),{create:i}=lu(n),{data:a,refetch:o,isFetching:s,isRefetching:c}=_e(xm(n)),l=(0,W.useMemo)(()=>a&&a?.find(e=>e.id===r),[a,r]),u=!!r&&!!l,[d,f]=(0,W.useState)(!1),p=(0,W.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,W.useCallback)(()=>{f(!0)},[f]),h=(0,W.useCallback)(e=>p(e.original.id,!1),[p]),g=(0,W.useCallback)(e=>p(void 0,e),[p]),_=hm(o);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Fc,{}),(0,G.jsx)(Hp,{children:(0,G.jsxs)(W.Suspense,{fallback:(0,G.jsx)(Wi,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,G.jsxs)(um,{data:a,columns:Cm,onRowClick:h,children:[(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:_,accessKey:`r`,disabled:s||c,children:[(0,G.jsx)(Kr,{}),(0,G.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,G.jsx)(`u`,{children:`R`}),`efresh`]})]}),i&&(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:d,children:[(0,G.jsx)(Gr,{}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`A`}),`dd`]})]})]}),i&&(0,G.jsx)(jm,{isModalOpen:d,setIsModalOpen:f}),u&&(0,G.jsx)(zm,{data:l,isModalOpen:u,closeModal:g},l.id)]})})]})}function Um({className:e,...t}){return(0,G.jsx)(_t,{"data-slot":`switch`,className:N(`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,G.jsx)(Xe,{"data-slot":`switch-thumb`,className:N(`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`)})})}function Wm(e){return`//oauth/${e}/login`}async function Gm(e,t){let{data:n}=await M.patch(`/Organization/${e}/settings/oauth`,t);return n}var Km=S({domain:A().min(1,`Domain is required`),clientId:A().min(1,`Client ID is required`),clientSecret:A().min(1,`Client secret is required`),scope:A().optional()}),qm=S({domain:A().min(1,`Domain is required`),clientId:A().optional(),clientSecret:A().optional(),scope:A().optional()});function Jm(){let{organizationId:e}=z({strict:!1}),{user:t}=wn(),{update:n}=su(e),{data:r}=_e(md(e)),i=Ie(),[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(null),l=r.settings?.oauthConfigs??[],{mutate:u,isPending:d}=L({mutationFn:t=>Gm(e,t),onSuccess:()=>void i.invalidateQueries({queryKey:[e]}),onError:()=>H.error(`Failed to update OAuth settings.`)}),f=Pt({resolver:Ke(Km),defaultValues:{domain:``,clientId:``,clientSecret:``,scope:`openid email profile`}}),p=e=>{u({provider:`okta`,...e},{onSuccess:()=>{H.success(`OAuth provider added.`),f.reset(),o(!1)}})},m=Pt({resolver:Ke(qm)}),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};t.clientId&&(n.clientId=t.clientId),t.clientSecret&&(n.clientSecret=t.clientSecret),u(n,{onSuccess:()=>{H.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 Lu(e)&&H.success(`Sign-in URL copied.`)},b=async e=>{await Lu(e)&&H.success(`Redirect URI copied.`)};return n?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Fc,{}),(0,G.jsx)(Hp,{children:(0,G.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,G.jsx)(`h2`,{className:`text-2xl text-foreground font-light mb-6`,children:`Authentication`}),(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsx)(`h3`,{className:`text-lg text-foreground font-medium`,children:`OAuth Providers`}),!a&&(0,G.jsxs)(P,{variant:`positiveOutline`,size:`sm`,onClick:()=>o(!0),children:[(0,G.jsx)(Gr,{}),`Add Provider`]})]}),l.length===0&&!a&&(0,G.jsx)(`p`,{className:`text-muted-foreground text-sm mb-4`,children:`No OAuth providers configured.`}),l.map(e=>{let n=t?.oauthConfigId===e.id;return s===e.id?(0,G.jsxs)(`div`,{className:`border rounded-lg p-4 mb-3 text-foreground`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsx)(`h4`,{className:`font-medium`,children:`Edit Provider`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`text-muted-foreground hover:text-foreground`,children:(0,G.jsx)(gn,{className:`size-4`})})]}),(0,G.jsx)(q,{...m,children:(0,G.jsxs)(`form`,{onSubmit:m.handleSubmit(t=>g(e,t)),className:`space-y-4`,children:[(0,G.jsx)(Y,{control:m.control,name:`domain`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Domain`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`company.okta.com`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:m.control,name:`clientId`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Client ID`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`Leave blank to keep existing`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:m.control,name:`clientSecret`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Client Secret`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,placeholder:`Leave blank to keep existing`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:m.control,name:`scope`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Scope`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`openid email profile`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,G.jsx)(P,{type:`submit`,variant:`positive`,disabled:d,children:d?`Saving...`:`Save`}),(0,G.jsx)(P,{type:`button`,variant:`outline`,onClick:()=>c(null),children:`Cancel`})]})]})})]},e.id):(0,G.jsx)(`div`,{className:`border rounded-lg p-4 mb-3 text-foreground`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between sm:gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:e.domain}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground uppercase bg-muted px-2 py-0.5 rounded`,children:e.provider}),e.enabled===!1&&(0,G.jsx)(`span`,{className:`text-xs text-destructive bg-destructive/10 px-2 py-0.5 rounded`,children:`Disabled`})]}),(0,G.jsxs)(`p`,{className:`text-sm text-muted-foreground mb-2`,children:[`Client ID: `,(0,G.jsx)(`span`,{className:`text-foreground font-mono`,children:`****`})]}),e.id&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mt-3 rounded-md bg-muted px-3 py-2`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Okta redirect URI`}),(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-1.5`,children:[`Add to `,(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:`Login redirect URIs`}),` `,`in your Okta app settings.`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-sm text-foreground font-mono truncate`,children:v(e.id)}),(0,G.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,G.jsx)(sr,{className:`size-3.5`})})]})]}),(0,G.jsxs)(`div`,{className:`mt-2 rounded-md bg-muted px-3 py-2`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`User login link`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`a`,{href:Wm(e.id),target:`_blank`,rel:`noreferrer`,className:`text-sm text-foreground truncate hover:underline`,children:Wm(e.id)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 text-muted-foreground`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>void y(Wm(e.id)),className:`hover:text-foreground`,title:`Copy login link`,children:(0,G.jsx)(sr,{className:`size-3.5`})}),(0,G.jsx)(`a`,{href:Wm(e.id),target:`_blank`,rel:`noreferrer`,className:`hover:text-foreground`,title:`Open login link`,children:(0,G.jsx)(dr,{className:`size-3.5`})})]})]})]})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 sm:shrink-0`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-foreground cursor-pointer`,children:[(0,G.jsx)(Um,{checked:e.enabled!==!1,onCheckedChange:()=>_(e,`enabled`),disabled:d}),`Enabled`]}),(0,G.jsxs)(Ba,{children:[(0,G.jsx)(Va,{asChild:!0,children:(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-sm text-foreground ${n?`cursor-pointer`:`cursor-not-allowed opacity-50`}`,children:[(0,G.jsx)(Um,{checked:!!e.required,onCheckedChange:()=>_(e,`required`),disabled:d||!n}),`Required`]})}),!n&&(0,G.jsxs)(Ha,{children:[`Sign in via `,e.provider,` first to enable Required`]})]}),(0,G.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>h(e),disabled:d,children:(0,G.jsx)(Ur,{className:`size-4`})})]})]})},e.id)}),a&&(0,G.jsxs)(`div`,{className:`border rounded-lg p-4 text-foreground`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsx)(`h4`,{className:`font-medium`,children:`Add Okta Provider`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),f.reset()},className:`text-muted-foreground hover:text-foreground`,children:(0,G.jsx)(gn,{className:`size-4`})})]}),(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-4`,children:[`After saving, copy the `,(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:`Okta redirect URI`}),` `,`from the provider card and add it to your Okta app's`,` `,(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:`Login redirect URIs`}),`.`]}),(0,G.jsx)(q,{...f,children:(0,G.jsxs)(`form`,{onSubmit:f.handleSubmit(p),className:`space-y-4`,children:[(0,G.jsx)(Y,{control:f.control,name:`domain`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Domain`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`company.okta.com`,autoFocus:!0,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:f.control,name:`clientId`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Client ID`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`Okta Client ID`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:f.control,name:`clientSecret`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Client Secret`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,placeholder:`Okta Client Secret`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:f.control,name:`scope`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Scope`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`openid email profile`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,G.jsx)(P,{type:`submit`,variant:`positive`,disabled:d,children:d?`Adding...`:`Add Provider`}),(0,G.jsx)(P,{type:`button`,variant:`outline`,onClick:()=>{o(!1),f.reset()},children:`Cancel`})]})]})})]})]})]})})]}):(0,G.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.`})}S({email:ss.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:A().nonempty({error:`Please select a role.`})});async function Ym(e){let{data:t}=await M.post(`/UserInvite/`,e);return t}function Xm(){return L({mutationFn:e=>Ym(e)})}function Zm({user:e}){let{update:t}=lu(),{mutate:n,isPending:r}=Xm(),i=e.roles?.[0]?.id,a=(0,W.useCallback)(t=>{if(t.stopPropagation(),!e.email||!i){H.error(`Cannot resend invite: this user has no email or role.`);return}n({email:e.email,roleId:i},{onSuccess:()=>H.success(`Invitation resent to ${e.email}.`)})},[n,i,e.email]);return t?(0,G.jsxs)(P,{variant:`ghost`,size:`sm`,className:`h-auto px-2 py-0 align-middle text-sm`,onClick:a,disabled:r||!i,children:[(0,G.jsx)(Fr,{}),` Resend invite`]}):null}var Qm=lm(),$m=[{header:`User Id`,accessorKey:`id`,enableSorting:!1},{header:`Email`,accessorKey:`email`,enableSorting:!1},{header:`First Name`,accessorKey:`firstname`,enableSorting:!1},{header:`Last Name`,accessorKey:`lastname`,enableSorting:!1},Qm.display({header:`Roles`,enableSorting:!1,id:`roles`,cell:e=>e.row.original.roles?.map(e=>e.roleName)?.sort()?.join(`, `)}),{header:`Status`,accessorKey:`status`,enableSorting:!1},{header:`Verified`,accessorKey:`isVerified`,enableSorting:!1},Qm.display({header:``,enableSorting:!1,id:`actions`,cell:e=>e.row.original.status===`PENDING`?(0,G.jsx)(Zm,{user:e.row.original}):null})];function eh({name:e,id:t}){return(0,G.jsxs)(`span`,{className:`flex items-baseline gap-2 truncate`,children:[(0,G.jsx)(`span`,{className:`truncate`,children:e}),(0,G.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:t})]})}var th=S({email:ss.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:A().nonempty({error:`Please select a role.`})});async function nh(e){let{data:t}=await M.post(`/OrganizationRole/`,e);return t}function rh(){return L({mutationFn:e=>nh(e)})}function ih({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let{organizationId:r}=z({strict:!1}),{data:i,isLoading:a}=V({...xm(r),throwOnError:!0}),[o,s]=(0,W.useState)(!1),c=Pt({resolver:Ke(th),defaultValues:{email:``,roleId:``}}),{mutate:l,isPending:u}=rh(),{mutate:d,isPending:f}=Xm(),p=(0,W.useCallback)(async e=>{e&&(o?d:l)(e,{onSuccess:()=>{let r=e.roleId;c.reset(),c.setValue(`roleId`,r),t(),H.success(`User invited successfully!`),n(!1),s(!1)},onError:e=>{e?.status===404&&s(!0)}})},[l,c,d,t,n,o]);return(0,G.jsx)(fn,{onOpenChange:()=>{n(!1),s(!1),c.reset()},open:e,children:(0,G.jsx)(cn,{"aria-describedby":void 0,children:(0,G.jsx)(q,{...c,children:(0,G.jsxs)(`form`,{id:`org-add-user-form`,name:`org-add-user-form`,onSubmit:c.handleSubmit(p),className:`grid gap-4 my-4`,children:[(0,G.jsx)(rn,{children:(0,G.jsx)(ln,{children:o?`Invite User`:`Add User`})}),(0,G.jsx)(Y,{control:c.control,name:`email`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Email`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`email`,enterKeyHint:`next`,autoComplete:`email`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:c.control,name:`roleId`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Roles`}),a?(0,G.jsx)(Kf,{}):(0,G.jsx)(J,{children:(0,G.jsxs)(qf,{...e,onValueChange:t=>e.onChange(t),children:[(0,G.jsx)(Xf,{className:`w-full`,children:(0,G.jsx)(Yf,{placeholder:`Choose Role`})}),(0,G.jsx)(Zf,{children:(0,G.jsxs)(Jf,{children:[(0,G.jsx)(Qf,{children:`Role`}),i?.map(e=>(0,G.jsx)($f,{value:e.id,children:(0,G.jsx)(eh,{name:e.roleName,id:e.id})},e.id))]})})]})}),(0,G.jsx)(Q,{})]})}),o&&(0,G.jsxs)(un,{className:`p-3 my-5 text-white rounded-md bg-amber-600 flex`,children:[(0,G.jsx)(Pr,{className:`inline-block size-12 pr-2`}),(0,G.jsx)(`span`,{children:`This person doesn’t have a Fabric account. Do you want to invite them?`})]}),(0,G.jsx)(on,{children:(0,G.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,G.jsxs)(P,{type:`submit`,variant:`submit`,disabled:u||f,children:[(0,G.jsx)(Xr,{}),` `,o?`Invite User`:`Add User`]})})})]})})})})}async function ah({roleId:e,userId:t}){let{data:n}=await M.delete(`/OrganizationRole/role/${e}/user/${t}`);return n}function oh(){return L({mutationFn:({roleId:e,userId:t})=>ah({roleId:e,userId:t})})}function sh(e){let[t,n]=(0,W.useState)(e||!1);return[t,(0,W.useCallback)(e=>{n(typeof e==`boolean`?e:e.target.checked)},[])]}function ch({data:e,readOnly:t,canRemove:n,orgRole:r,selectedRoles:i,setChangesMade:a}){let{mutate:o,isPending:s}=rh(),{mutate:c,isPending:l}=oh(),u=!!i[r.id],[d,f]=(0,W.useState)(u),[p,m]=sh(u);return(0,W.useEffect)(()=>{p!==d&&(p?o({email:e.email,roleId:r.id},{onSuccess:()=>{f(p),a(!0),H.success(`Role added successfully`)}}):c({userId:e.id,roleId:r.id},{onSuccess:()=>{f(p),a(!0),H.success(`Role removed successfully`)}}))},[o,e.email,e.id,p,r.id,c,a,d]),(0,G.jsxs)(Ro,{className:`flex`,children:[(0,G.jsx)($,{type:`checkbox`,className:`w-6`,disabled:t||s||l||!n&&p,checked:p,onChange:m}),(0,G.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:r.roleName})]},r.id)}function lh({isSelf:e,isPending:t,onConfirm:n}){let[r,i]=(0,W.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?Nr:mi;return r?(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.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,G.jsx)(pi,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,G.jsx)(`span`,{children:a.warning})]}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(P,{type:`button`,variant:`ghostOutline`,disabled:t,onClick:()=>i(!1),children:`Cancel`}),(0,G.jsxs)(P,{type:`button`,variant:`destructive`,disabled:t,onClick:n,children:[(0,G.jsx)(o,{}),` `,t?a.busy:a.confirm]})]})]}):(0,G.jsx)(`div`,{className:`flex justify-start`,children:(0,G.jsxs)(P,{type:`button`,variant:`destructiveOutline`,disabled:t,onClick:()=>i(!0),children:[(0,G.jsx)(o,{}),` `,a.idle]})})}function uh(e){return e?.trim().toLowerCase()===`admin`}function dh({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 fh({closeModal:e,data:t,isModalOpen:n,onUserUpdated:r,orgUserCount:i,orgAdminCount:a}){let{organizationId:o}=z({strict:!1}),s=wn(),{update:c,remove:l}=lu(o),u=s.user?.email===t.email,[d,f]=(0,W.useState)(!1),{canRemoveRoles:p,showRemovalAction:m,blockedReason:h}=dh({canDelete:l,isSelf:u,orgUserCount:i,adminCount:a,isAdmin:(t.roles??[]).some(e=>uh(e.roleName)),roleCount:t.roles?.length??0}),{mutateAsync:g}=oh(),[_,v]=(0,W.useState)(!1),y=(0,W.useCallback)(async()=>{let e=t.roles??[];v(!0),(await Promise.allSettled(e.map(e=>g({userId:t.id,roleId:e.id})))).some(e=>e.status===`rejected`&&e.reason?.response?.status!==404)?H.error(u?`Something went wrong leaving the organization. Please try again.`:`Couldn’t remove ${t.email} from the organization. Please try again.`):H.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,G.jsx)(fn,{onOpenChange:d?r:e,open:n,children:(0,G.jsxs)(cn,{resizable:!0,children:[(0,G.jsx)(rn,{children:(0,G.jsxs)(ln,{children:[c?`Edit `:`View `,` `,t.email,` `,u?`(yourself)`:``]})}),c&&(0,G.jsxs)(un,{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,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(Wi,{centered:!0,text:`Loading roles…`,className:`flex-1 min-h-0`}),children:(0,G.jsx)(ph,{data:t,organizationId:o,update:c,canRemove:p,setChangesMade:f})}),t.status===`PENDING`&&(0,G.jsx)(`div`,{className:`border-t border-border pt-4`,children:(0,G.jsx)(Zm,{user:t})}),m&&(0,G.jsx)(`div`,{className:`border-t border-border pt-4`,children:(0,G.jsx)(lh,{isSelf:u,isPending:_,onConfirm:y})}),h&&(0,G.jsxs)(`p`,{className:`flex items-start gap-2 text-sm text-muted-foreground border border-amber-500/50 rounded-md p-3`,children:[(0,G.jsx)(pi,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,G.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 ph({data:e,organizationId:t,update:n,canRemove:r,setChangesMade:i}){let{data:a}=_e(xm(t)),o=(0,W.useMemo)(()=>e.roles?id(e.roles,`id`):{},[e]);return(0,G.jsx)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 overflow-y-auto`,children:a.map(t=>(0,G.jsx)(ch,{readOnly:!n,canRemove:r,data:e,orgRole:t,selectedRoles:o,setChangesMade:i},t.id))})}function mh(e,t){return e.email>t.email?1:-1}function hh(e){return(e.users??[]).filter(e=>e!=null)}function gh(e){let t={};for(let n of e)for(let e of hh(n))t[e.id]||(t[e.id]={...e,roles:[]}),t[e.id].roles.push(n);return Object.values(t).sort(mh)}function _h(e){let t=new Set;for(let n of e)if(uh(n.roleName))for(let e of hh(n))t.add(e.id);return t.size}function vh(){let e=I(),{organizationId:t,orgUserId:n}=z({strict:!1}),{update:r}=lu(t),{data:i,refetch:a,isFetching:o,isRefetching:s}=_e(xm(t)),c=(0,W.useMemo)(()=>gh(i),[i]),l=(0,W.useMemo)(()=>_h(i),[i]),u=(0,W.useMemo)(()=>c?.find(e=>e.id===n),[c,n]),d=(0,W.useCallback)(t=>{let r=[n?`..`:``,t].filter(Boolean);e({to:r.join(`/`)})},[n,e]),f=!!n&&!!u,[p,m]=(0,W.useState)(!1),[h]=(0,W.useState)({attribute:`email`,descending:!1}),g=(0,W.useMemo)(()=>[{desc:h.descending,id:h.attribute}],[h]),_=(0,W.useCallback)(()=>{m(!0)},[m]),v=(0,W.useCallback)(()=>{a(),m(!1)},[a,m]),y=(0,W.useCallback)(e=>{d(e.original.id)},[d]),b=(0,W.useCallback)(()=>{d(void 0)},[d]),x=(0,W.useCallback)(()=>{a(),d(void 0)},[d,a]),S=hm(a);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Fc,{}),(0,G.jsx)(Hp,{children:(0,G.jsxs)(W.Suspense,{fallback:(0,G.jsx)(Wi,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,G.jsxs)(um,{data:c,isFetching:o||s,columns:$m,onRowClick:y,sortingState:g,children:[(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:S,accessKey:`r`,disabled:o||s,children:[(0,G.jsx)(Kr,{}),` `,(0,G.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,G.jsx)(`u`,{children:`R`}),`efresh`]})]}),r&&(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:_,accessKey:`a`,disabled:p,children:[(0,G.jsx)(Gr,{}),` `,(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`A`}),`dd`]})]})]}),r&&(0,G.jsx)(ih,{isModalOpen:p,onChangesSaved:v,setIsModalOpen:m}),f&&(0,G.jsx)(fh,{closeModal:b,data:u,isModalOpen:f,onUserUpdated:x,orgUserCount:c.length,orgAdminCount:l})]})})]})}function yh({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`skeleton`,className:N(`bg-primary/10 animate-pulse rounded-md`,e),...t})}function bh({organizationId:e,organizationName:t,providers:n}){return(0,G.jsxs)(On,{className:`relative h-full justify-between opacity-90`,children:[(0,G.jsxs)(kn,{children:[(0,G.jsx)(jn,{className:`truncate`,children:e}),(0,G.jsx)(An,{children:(0,G.jsx)(`h2`,{children:t})})]}),(0,G.jsxs)(Mn,{className:`flex flex-col gap-2`,children:[(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-1.5 mb-1`,children:[(0,G.jsx)(Tr,{className:`size-3 shrink-0`}),`Sign in with an OAuth provider to access this organization.`]}),n.map(e=>(0,G.jsx)(`a`,{href:Wm(e.oauthConfigId),children:(0,G.jsxs)(P,{variant:`outline`,className:`w-full`,children:[`Sign in with `,e.name]})},e.oauthConfigId))]})]})}var xh=S({couponId:A().nonempty({message:`Please enter a coupon ID.`}).trim()});async function Sh({organizationId:e,couponId:t}){let{data:n}=await M.post(`/Coupon`,{organizationId:e,couponId:t},{validateStatus:e=>e>=200&&e<400||e===400||e===409});return n}function Ch(){return L({mutationFn:Sh})}function wh({organizationId:e,organizationName:t,isOpen:n,onClose:r}){let{mutate:i,isPending:a}=Ch(),o=Pt({resolver:Ke(xh),defaultValues:{couponId:``}}),{handleSubmit:s,control:c,reset:l}=o;(0,W.useEffect)(()=>{n&&l({couponId:``})},[n,l]);let u=(0,W.useCallback)(n=>{i({organizationId:e,couponId:n.couponId},{onSuccess:i=>{i?H.error(`Error`,{description:i||`Failed to add coupon.`}):(H.success(`Success`,{description:`Coupon "${n.couponId}" added to ${t||e}.`}),r())}})},[i,e,t,r]);return(0,G.jsx)(fn,{open:n,onOpenChange:e=>!e&&r(),children:(0,G.jsxs)(cn,{children:[(0,G.jsxs)(rn,{children:[(0,G.jsx)(ln,{children:`Add Coupon`}),(0,G.jsxs)(un,{children:[`Add a coupon code to`,` `,t||e,`. This coupon will be applied to the next billing cycle.`,(0,G.jsx)(`br`,{}),`Coupons can be created in our`,` `,(0,G.jsx)(`a`,{href:`https://dashboard.stripe.com/`,target:`_blank`,rel:`noreferrer`,className:`text-purple hover:underline`,children:`Stripe Dashboard`}),`.`]})]}),(0,G.jsx)(q,{...o,children:(0,G.jsxs)(`form`,{onSubmit:s(u),children:[(0,G.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,G.jsx)(Y,{control:c,name:`couponId`,render:({field:e})=>(0,G.jsxs)(X,{className:`grid items-center gap-4`,children:[(0,G.jsx)(Z,{children:`Coupon ID`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{...e,placeholder:`e.g. 100OFF`,disabled:a})}),(0,G.jsx)(Q,{})]})})}),(0,G.jsxs)(on,{children:[(0,G.jsx)(P,{type:`button`,variant:`ghost`,onClick:r,disabled:a,children:`Cancel`}),(0,G.jsx)(P,{type:`submit`,disabled:a,children:a?`Adding...`:`Add Coupon`})]})]})})]})})}function Th({organizationRole:e,onDeleteOrgModal:t}){let{organizationId:n,organizationName:r,roleName:i}=e,{remove:a,update:o}=su(n),s=o,{view:c}=lu(n),l=En(`billing:write`),[u,d]=(0,W.useState)(!1),f=(0,W.useCallback)(()=>{t(e)},[t,e]),p=[{type:`label`,key:`label`,className:`text-gray-600 text-xs`,label:`Options`},{type:`separator`,key:`sep-top`},{key:`clusters`,to:`${n}`,icon:(0,G.jsx)($r,{className:`size-4 mr-2 text-blue-500`}),label:`Clusters`},c&&{key:`roles`,to:`${n}/roles`,icon:(0,G.jsx)(ti,{className:`size-4 mr-2 text-purple`}),label:`Roles`},c&&{key:`users`,to:`${n}/users`,icon:(0,G.jsx)(gi,{className:`size-4 mr-2 text-orange-500`}),label:`Users`},s&&{key:`billing`,to:`${n}/billing`,icon:(0,G.jsx)(cr,{className:`size-4 mr-2 text-green-500`}),label:`Billing`},o&&{key:`settings`,to:`${n}/settings`,icon:(0,G.jsx)(Tr,{className:`size-4 mr-2 text-yellow-500`}),label:`Settings`},l&&{key:`add-coupon`,onClick:()=>d(!0),icon:(0,G.jsx)(di,{className:`size-4 mr-2 text-pink-500`}),label:`Add Coupon`},a&&{type:`separator`,key:`sep-bottom`},a&&{key:`delete`,onClick:f,className:`focus:bg-red/70 focus:text-white`,icon:(0,G.jsx)(fi,{className:`size-4 mr-2 text-red-500`}),label:`Delete`}].filter(Qa),m=a||l;return(0,G.jsx)(Kc,{items:m?p:[],children:(0,G.jsxs)(On,{className:`relative h-full justify-between transition-[transform,box-shadow] duration-200 hover:scale-[1.02] hover:shadow-lg hover:ring-2 hover:ring-primary/60 dark:hover:ring-violet-400/70`,children:[(0,G.jsx)(B,{to:n,"aria-label":`View ${r??n}`,className:`absolute inset-0 rounded-[inherit] focus-visible:ring-2 focus-visible:ring-purple-200 focus-visible:outline-none`}),(0,G.jsxs)(kn,{children:[(0,G.jsxs)(jn,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`truncate`,children:n}),m&&(0,G.jsxs)(wi,{children:[(0,G.jsx)(Ti,{"aria-label":`Options`,onClick:e=>e.stopPropagation(),className:`relative z-10 -m-2 p-2 rounded-md hover:bg-accent/60 hover:text-foreground`,children:(0,G.jsx)(ur,{})}),(0,G.jsx)(Ei,{children:Gc(p,`dropdown`)})]})]}),(0,G.jsx)(An,{children:(0,G.jsx)(`h2`,{children:r})})]}),(0,G.jsxs)(Mn,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(Ji,{className:`min-w-0 shrink`,title:Mo(i),children:(0,G.jsx)(`span`,{className:`truncate`,children:Mo(i)})}),(0,G.jsxs)(`span`,{className:`text-sm shrink-0 py-2 whitespace-nowrap ml-auto`,children:[`View `,(0,G.jsx)(Rn,{className:`inline-block`})]})]}),(0,G.jsx)(wh,{organizationId:n,organizationName:r,isOpen:u,onClose:()=>d(!1)})]})})}async function Eh(e){let{data:t}=await M.delete(`/Organization/${e}`);return t}function Dh(){return L({mutationFn:e=>Eh(e)})}async function Oh(e){let{data:t}=await M.post(`/Organization/`,{...e});return t}function kh(){return L({mutationFn:e=>Oh(e)})}var Ah=A().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.`}),jh=S({name:A().max(255,{error:`Name cannot be longer than 255 characters.`}),subdomain:ee([x(``),w(),Ah]).optional()});function Mh(){let{user:e}=wn(),t=I(),n=Pt({resolver:Ke(jh),defaultValues:{name:``,subdomain:``}}),{setFocus:r,watch:i}=n;(0,W.useEffect)(()=>{r(`name`)},[r]);let a=`${e?.firstname} ${e?.lastname} Org`,o=i(`name`)||a,s=i(`subdomain`),c=(0,W.useMemo)(()=>{let e=gd(vd(o),Ah.maxLength);return{suggestedSubdomain:e,fullHostName:`future-cluster-names.${s||e}.harperfabric.com`}},[o,s]),{mutate:l,isPending:d}=kh(),p=Ie(),h=(0,W.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,G.jsx)(G.Fragment,{children:(0,G.jsx)(q,{...n,children:(0,G.jsxs)(`form`,{id:`org-add-form`,name:`org-add-form`,onSubmit:n.handleSubmit(h),className:`grid gap-6 text-foreground max-w-xl`,children:[(0,G.jsx)(Y,{control:n.control,name:`name`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,maxLength:jh.shape.name.maxLength,autoCapitalize:`words`,placeholder:a,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:n.control,name:`subdomain`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Subdomain`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,maxLength:Ah.maxLength,autoCapitalize:`none`,placeholder:c.suggestedSubdomain,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Full Host Name`}),(0,G.jsx)(J,{children:(0,G.jsx)(`span`,{children:c.fullHostName})}),(0,G.jsx)(Q,{})]}),(0,G.jsx)(on,{children:(0,G.jsxs)(P,{type:`submit`,variant:`submit`,disabled:d,children:[`Create New Organization `,(0,G.jsx)(Rn,{})]})})]})})})}function Nh(){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Fc,{}),(0,G.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,G.jsx)(Mh,{})})]})}var Ph={org:`organization`,clu:`cluster`,ins:`instance`},Fh=/^(org|clu|ins)-[a-z0-9]+$/;function Ih(e){if(typeof e!=`string`)return null;let t=e.trim(),n=Fh.exec(t);return n?{kind:Ph[n[1]],id:t}:null}function Lh(e,t){let n=e*12;return`/Admin/Organization/?${[...t?[`name=ct=${encodeURIComponent(t)}`]:[],`status=ne=DELETED`,`sort(name)`,`limit(${n},${n+12+1})`].join(`&`)}`}async function Rh(e,t){let{data:n}=await M.get(Lh(e,t));return{organizations:n.slice(0,12),hasNextPage:n.length>12}}var zh={organizations:[],hasNextPage:!1};function Bh(e){return e instanceof _&&(e.response?.status===404||e.status===404)}async function Vh(e){try{let{data:t}=await M.get(`/Admin/Organization/${e}`);return t?{organizations:[t],hasNextPage:!1}:zh}catch(e){if(Bh(e))return zh;throw e}}async function Hh(e){try{let{data:t}=await M.get(`/Cluster/${e}`),n=t?.organizationId;return n?await Vh(n):zh}catch(e){if(Bh(e))return zh;throw e}}function Uh(e,t){let n=Ih(t);return R({queryKey:[`admin-all-organizations`,t,e],queryFn:()=>n?.kind===`organization`?Vh(n.id):n?.kind===`cluster`?Hh(n.id):Rh(e,t),placeholderData:ue,retry:!1})}function Wh(e,t=300,n){let[r,i]=(0,W.useState)(e),a=n?n(e):e;return(0,W.useEffect)(()=>{let n=setTimeout(()=>i(e),t);return()=>clearTimeout(n)},[a,t]),r}function Gh(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 Kh(e,t){let[n,r]=(0,W.useState)(t),[i,a]=(0,W.useState)(e);return(0,W.useEffect)(()=>{Gh(n,t)||(r(t),a(e))},[n,t,e]),Gh(n,t)?[i,a]:[e,a]}var qh={};function Jh(e,t,n){let r=(0,W.useCallback)((e,n)=>t(e,n),[n]);(0,W.useEffect)(()=>(qh[e]||(qh[e]=[]),qh[e].push(r),function(){let t=qh[e].indexOf(r);t>=0&&qh[e].splice(t,1)}),[e,t,r])}function Yh(e,t,n){let r=qh[e];if(r)for(let e of r)e(t,n)}function Xh(e,t,n){return r=>Yh(e,t,n??r)}function Zh(e,t,n){return(0,W.useCallback)(r=>Yh(e,t,n??r),[e,t,n])}function Qh(e,t){let n=Kh(We(e,t),[e]),[r,i]=n;return(0,W.useEffect)(()=>{Ge(e,r),Yh(`Session:${e}`,r)},[e,r]),Jh(`Session:${e}`,function(e){r!==e&&i(e)},[r,e,t]),(0,W.useEffect)(function(){let n=n=>{n.key===e&&i(We(e,t))};return window.addEventListener(`storage`,n),()=>{window.removeEventListener(`storage`,n)}},[e,i,t]),n}function $h(){let e=Ie(),{data:t}=_e(s()),{mutate:n,isPending:r}=Dh(),[i,a]=(0,W.useState)(!1),[o,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(``),d=(0,W.useCallback)(()=>u(``),[]),f=En(`org:read`),[p,m]=Qh(`ShowAllOrganizations`,!1),[h,g]=(0,W.useState)(0),_=f&&p,v=(0,W.useCallback)(e=>{m(e),g(0)},[m]),y=Wh(l,300),b=(0,W.useMemo)(()=>{if(!f)return null;let e=Ih(y);return e?.kind===`organization`||e?.kind===`cluster`?e:null},[f,y]),x=_||!!b,{data:S,isPending:C}=V({...Uh(h,y),enabled:x}),{organizationRoles:w,oauthLockedOrgs:T}=(0,W.useMemo)(()=>{let e=t?.roles||{},n=[],r=[];for(let[t,i]of Object.entries(e))`oauthProviders`in i&&!f?r.push({organizationId:t,organizationName:i.organizationName,providers:i.oauthProviders}):n.push({organizationId:t,organizationName:i.organizationName,roleName:i.role??`fabric staff`});return{organizationRoles:n.filter(Kp([`organizationId`,`organizationName`],l)).sort((e,t)=>(e.organizationName||``)>(t.organizationName||``)?1:-1),oauthLockedOrgs:r}},[l,t?.roles,f]),E=(0,W.useMemo)(()=>{let e=t?.roles||{};return(S?.organizations||[]).map(t=>({organizationId:t.id,organizationName:t.name,roleName:e[t.id]?.role||`fabric staff`}))},[S?.organizations,t?.roles]),D=x?E:w,O=(0,W.useCallback)(e=>{u(e.currentTarget.value||``),g(0)},[]),k=(0,W.useCallback)(t=>{t?.organizationId&&n(t.organizationId,{onSuccess:()=>{H.success(`Success`,{description:`Organization successfully deleted.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),e.invalidateQueries({queryKey:[]}),a(!1)},onError:()=>a(!1)})},[n,e,a]),A=(0,W.useCallback)(e=>{c(e),a(!0)},[]),{createCluster:j}=he({strict:!1});return!_&&w.length===1&&!l.length&&j?(0,G.jsx)(ce,{to:`/${w[0].organizationId}/new-cluster`,replace:!0}):!_&&!w.length&&!T.length&&!l.length?(0,G.jsx)(Nh,{}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Fc,{children:(0,G.jsxs)(`div`,{className:`flex w-full items-center justify-end gap-2`,children:[f&&(0,G.jsxs)(`label`,{className:`flex shrink-0 cursor-pointer items-center gap-2 text-xs`,children:[(0,G.jsx)(Um,{checked:p,onCheckedChange:v,"aria-label":`Show all organizations`}),(0,G.jsx)(`span`,{className:`hidden sm:inline-block`,children:`All Orgs`})]}),(0,G.jsx)($,{placeholder:`Filter by name`,className:`inline-block w-full text-xs`,value:l,onChange:O}),(0,G.jsx)(B,{to:`/new-org`,children:(0,G.jsxs)(P,{variant:`positive`,accessKey:`n`,children:[(0,G.jsx)(Gr,{}),(0,G.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,G.jsx)(`u`,{children:`N`}),`ew `,(0,G.jsx)(`span`,{className:`hidden md:inline-block`,children:`Organization`})]})]})})]})}),(0,G.jsxs)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-12`,children:[!x&&T.map(e=>(0,G.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,G.jsx)(bh,{organizationId:e.organizationId,organizationName:e.organizationName,providers:e.providers})},e.organizationId)),x&&C?Array.from({length:12},(e,t)=>(0,G.jsx)(yh,{className:`col-span-1 h-40 md:col-span-4 lg:col-span-3 2xl:col-span-2`},t)):D.map(e=>(0,G.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,G.jsx)(Th,{organizationRole:e,onDeleteOrgModal:A})},e.organizationId)),!D.length&&!(x&&C)&&(x||!T.length)&&(0,G.jsxs)(`div`,{className:`col-span-1 md:col-span-12 text-center`,children:[(0,G.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,G.jsx)(P,{variant:`outline`,onClick:d,children:`Clear Filters`})]})]}),x&&(h>0||S?.hasNextPage)&&(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-4 py-6`,children:[(0,G.jsxs)(P,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:h===0,onClick:()=>g(e=>e-1),children:[(0,G.jsx)(Ln,{}),`Previous`]}),(0,G.jsxs)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:[`Page `,h+1]}),(0,G.jsxs)(P,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:!S?.hasNextPage,onClick:()=>g(e=>e+1),children:[`Next`,(0,G.jsx)(Rn,{})]})]})]}),o&&(0,G.jsx)(Ic,{typeOfThingBeingDeleted:`organization`,nameOfThingBeingDeleted:o.organizationName,isModalOpen:i,setIsModalOpen:()=>a(!1),deletionConfirmed:()=>k(o),deletionPending:r})]})}var eg=F({getParentRoute:()=>bo,id:`_orgsLayout`});F({getParentRoute:()=>eg,path:`/`,head:()=>({meta:[{title:`Organizations — Harper Fabric`}]}),component:$h}),F({getParentRoute:()=>eg,path:`/new-org`,head:()=>({meta:[{title:`New Organization — Harper Fabric`}]}),component:Nh});var tg=F({getParentRoute:()=>eg,path:`$organizationId`,beforeLoad:async e=>{let{organizationId:t}=e.params;if(!fd(t))throw le({to:`/`});return{organization:await e.context.queryClient.ensureQueryData(md(t))}}});F({getParentRoute:()=>tg,path:`/roles`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:Hm}),F({getParentRoute:()=>tg,path:`/roles/$orgRoleId`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:Hm}),F({getParentRoute:()=>tg,path:`/users`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:vh}),F({getParentRoute:()=>tg,path:`/users/$orgUserId`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:vh}),F({getParentRoute:()=>tg,path:`/settings`,component:Jm}),ym(tg);var ng=F({getParentRoute:()=>tg,id:`_clusterLayout`});F({getParentRoute:()=>ng,path:`/`,head:()=>({meta:[{title:`Clusters — Harper Fabric`}]}),component:qp}),F({getParentRoute:()=>tg,path:`/new-cluster`,head:()=>({meta:[{title:`New Cluster — Harper Fabric`}]}),component:Vp}),F({getParentRoute:()=>ig,path:`/edit`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),component:Vp}),F({getParentRoute:()=>ig,path:`/edit/$mode`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),component:Vp});function rg(){return(0,G.jsx)(He,{})}var ig=F({getParentRoute:()=>ng,path:`$clusterId`,component:rg,beforeLoad:async({context:e,params:t})=>({cluster:await e.queryClient.ensureQueryData(os(t.clusterId))})}),ag=e=>new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e),og=e=>`${new Intl.NumberFormat(void 0,{maximumFractionDigits:1}).format(e)} hr`,sg=e=>_p(e),cg={reads:`Reads`,readBytes:`Read data`,writes:`Writes`,writeBytes:`Write data`,realTimeMessages:`Real-time messages`,realTimeBytes:`Real-time data`,cpuTimeHours:`Compute`,storageBytes:`Storage`},lg={reads:ag,readBytes:sg,writes:ag,writeBytes:sg,realTimeMessages:ag,realTimeBytes:sg,cpuTimeHours:og,storageBytes:sg},ug=[`reads`,`readBytes`,`writes`,`writeBytes`,`realTimeMessages`,`realTimeBytes`,`cpuTimeHours`,`storageBytes`];function dg(e,t,n){return{label:n??cg[e],used:t.used,limit:t.limit,unlimited:t.unlimited,limitKnown:t.limitKnown,format:lg[e]}}function fg({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,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-sm`,children:[(0,G.jsx)(`span`,{className:`text-foreground`,children:e}),(0,G.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[(0,G.jsx)(`span`,{className:`text-foreground`,children:a(t)}),s?(0,G.jsxs)(G.Fragment,{children:[`/ `,a(n)]}):` used`]})]}),(0,G.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`h-2 flex-1 overflow-hidden rounded-full bg-muted`,children:s?(0,G.jsx)(`div`,{className:`h-full rounded-full ${l?`bg-yellow`:`bg-primary dark:bg-violet-400`}`,style:{width:`${c}%`}}):o?(0,G.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,G.jsx)(`span`,{className:`w-16 shrink-0 text-right text-xs tabular-nums ${l?`text-yellow`:`text-muted-foreground`}`,children:s?`${c}%`:o?`Unlimited`:`—`})]})]})}function pg(e){return R({queryKey:[`clusterUsage`,e],queryFn:async()=>{let{data:t}=await M.get(`/Cluster/${e}/usage`);return t},enabled:!!e,staleTime:6e4})}function mg(e){return V(pg(e))}function hg(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} ${gg(e.renewsAt)}`:null].filter(Boolean).join(` · `)}function gg(e){return new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))}function _g({clusterId:e,base:t}){let{data:n}=mg(e);return!n||n.selfManaged||n.regions.length===0?null:(0,G.jsxs)(`section`,{className:`mt-6 rounded-2xl border border-border bg-card p-5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Plan usage`}),(0,G.jsxs)(B,{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,G.jsx)(Rn,{className:`size-3`})]})]}),(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:hg(n)}),(0,G.jsx)(`div`,{className:`mt-4`,children:n.regions.length===1?(0,G.jsx)(vg,{data:n}):(0,G.jsx)(yg,{data:n})})]})}function vg({data:e}){let t=e.regions[0].metrics,n=[dg(`reads`,t.reads),dg(`writes`,t.writes),dg(`storageBytes`,t.storageBytes),dg(`cpuTimeHours`,t.cpuTimeHours)];return(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-x-8 gap-y-4 sm:grid-cols-2`,children:n.map(e=>(0,G.jsx)(fg,{...e},e.label))})}function yg({data:e}){let t=e.mostConstrained;return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`p`,{className:`mb-1.5 text-xs text-muted-foreground`,children:[`Most constrained of `,e.regions.length,` regions`]}),t?(0,G.jsx)(fg,{...dg(t.metric,{used:t.used,limit:t.limit,unlimited:!1,limitKnown:!0},`${t.region??`Region`} · ${cg[t.metric]}`)}):(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No metered limits on the current plan — see the breakdown for details.`})]})}function bg({cluster:e}){let t=pe(),n=Ie(),{update:r,remove:i}=du(e.organizationId,e.id),{run:a,isPending:o}=Iu(e),{mutate:s,isPending:c}=Mu(),[l,u]=(0,W.useState)(!1),[d,f]=(0,W.useState)(!1),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(null),_=e.status===`RUNNING`,v=e.status===`STOPPED`,y=e.status===`PARTIAL`,b=!r||o,x=(0,W.useCallback)(()=>{s(e.id,{onSuccess:async()=>{await n.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),m(!1),H.success(`Success`,{description:`Cluster successfully terminated.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),t.navigate({to:`/${e.organizationId}`})},onError:()=>{m(!1)}})},[e.id,e.organizationId,s,n,t]),S=(0,W.useCallback)(()=>{let e=h;g(null),e&&a(e,{safeMode:!0,strategy:`parallel`,label:e===`start`?`Starting in safe mode`:`Restarting in safe mode`})},[h,a]);return wu(e)||!r&&!i?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(wi,{children:[(0,G.jsx)(Ti,{asChild:!0,children:(0,G.jsxs)(P,{variant:`outline`,size:`sm`,disabled:o,className:`gap-1.5 hover:translate-y-0 data-[state=open]:[&>svg]:rotate-180`,children:[`Cluster actions`,(0,G.jsx)(pn,{className:`size-4 transition-transform`})]})}),(0,G.jsxs)(Ei,{align:`end`,className:`w-56`,children:[(0,G.jsx)(ki,{className:`text-gray-600 text-xs`,children:`Container`}),(0,G.jsxs)(Di,{disabled:b||!(v||y),onClick:()=>void a(`start`,{safeMode:!1,strategy:`parallel`}),children:[(0,G.jsx)(Wr,{}),` Start`]}),(0,G.jsxs)(Di,{disabled:b||!v,onClick:()=>g(`start`),children:[(0,G.jsx)(Or,{}),` Start in safe mode`]}),(0,G.jsxs)(Di,{disabled:b||!(_||y),onClick:()=>f(!0),children:[(0,G.jsx)(Yr,{}),` Restart`]}),(0,G.jsxs)(Di,{disabled:b||!_,onClick:()=>g(`restart`),children:[(0,G.jsx)(Or,{}),` Restart in safe mode`]}),(0,G.jsxs)(Di,{variant:`destructive`,disabled:b||!(_||y),onClick:()=>u(!0),children:[(0,G.jsx)(ai,{}),` Stop`]}),(0,G.jsx)(Ai,{}),(0,G.jsxs)(Di,{variant:`destructive`,disabled:!i,onClick:()=>m(!0),children:[(0,G.jsx)(fi,{}),` Terminate`]})]})]}),(0,G.jsx)(Du,{clusterName:e.name,isPending:o,stopOpen:l,setStopOpen:u,onConfirmStop:()=>{u(!1),a(`stop`,{strategy:`parallel`})},restartOpen:d,setRestartOpen:f,onConfirmRestart:e=>{f(!1),a(`restart`,{safeMode:!1,strategy:e})}}),(0,G.jsx)(Au,{open:h!==null,setOpen:e=>{e||g(null)},action:h??`restart`,targetName:e.name,scope:`cluster`,isPending:o,onConfirm:S}),(0,G.jsx)(Ic,{typeOfThingBeingDeleted:`cluster`,transitiveVerb:`Terminate`,presentParticiple:`Terminating`,nameOfThingBeingDeleted:e.name,isModalOpen:p,setIsModalOpen:m,deletionConfirmed:x,deletionPending:c})]})}function xg(){let{clusterId:e}=z({strict:!1}),t=pe(),n=I(),{data:r}=V(os(e,!0)),{user:i,isLoading:a}=Dn(e),{view:s,update:l}=du(r?.organizationId,r?.id),[f,p]=(0,W.useState)(!1),m=r?.domains?.[0]?.domain||r?.fqdn||``,[h,g]=zu(m,m?`https://${m}`:``),_=r?`/${r.organizationId}/${r.id}`:``,v=(0,W.useCallback)(async()=>{if(r){p(!0);try{await u.establishFabricConnectAuth({id:r.id,operationsUrl:c(r)}),await t.invalidate()}catch{H.error(`Could not connect to this cluster through Fabric Connect.`)}finally{p(!1)}}},[r,t]),y=(0,W.useCallback)(()=>{r&&(u.setUserForEntity(r,null),u.flagForFabricConnect(r.id,!1)),n({to:`${_}/sign-in`})},[_,r,n]),b=(0,W.useCallback)(async()=>{if(r){try{await d({instanceClient:o({id:r.id}),entityId:r.id})}catch{}u.setUserForEntity(r,null),u.flagForFabricConnect(r.id,!1),u.flagForBasicAuth(r.id,null),await t.invalidate()}},[r,t]);if(!r)return(0,G.jsx)(Cg,{children:(0,G.jsx)(wg,{})});if(!s)return(0,G.jsx)(ce,{to:`/${r.organizationId}`,replace:!0});if(wu(r))return(0,G.jsx)(Sg,{cluster:r});if(!r.fqdn)return(0,G.jsx)(ce,{to:`${_}/instances`,replace:!0});if(r.resetPassword){if(!l)return(0,G.jsx)(Cg,{children:(0,G.jsxs)(`div`,{className:`text-center py-12`,children:[(0,G.jsx)($r,{className:`size-12 text-muted-foreground mx-auto mb-4`}),(0,G.jsx)(`h1`,{className:`text-xl font-medium mb-2 text-foreground`,children:`Pending Owner Setup`}),(0,G.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.`})]})});let e=r.status&&zo.includes(r.status)&&Qo(r);return(0,G.jsx)(ce,{to:`${_}/${e?`finish-setup`:`starting-up`}`,replace:!0})}let x=u.checkForFabricConnect(r.id),S=!!i,C=u.getLastConnectMode(r.id),w=(r.instances??[]).filter(e=>e.status&&!Bo.includes(e.status)).length,T=r.instances??[],E=!!r.status&&zo.includes(r.status)&&T.length>0&&T.every(e=>e.safeMode);return(0,G.jsxs)(Cg,{children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-4 mb-6`,children:[(0,G.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,G.jsx)($r,{className:`size-6`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:r.name}),(0,G.jsx)(Tg,{status:r.status}),E&&(0,G.jsx)(Eg,{})]}),(0,G.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,G.jsxs)(`span`,{children:[w,` `,w===1?`instance`:`instances`]}),(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,G.jsxs)(`a`,{href:`https://${m}`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 hover:text-foreground hover:underline`,children:[m,(0,G.jsx)(dr,{className:`size-3`})]}),(0,G.jsxs)(wi,{children:[(0,G.jsx)(Ti,{"aria-label":`Copy cluster URLs`,className:`rounded-md p-1 -m-1 hover:bg-accent/60 hover:text-foreground`,children:(0,G.jsx)(sr,{className:`size-3.5`})}),(0,G.jsxs)(Ei,{align:`start`,children:[(0,G.jsx)(Di,{onClick:h,children:`Copy host name`}),(0,G.jsx)(Di,{onClick:g,children:`Copy API URL`})]})]})]})]}),(0,G.jsx)(bg,{cluster:r})]}),a?(0,G.jsx)(wg,{}):S?(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-sm`,children:[(0,G.jsx)(Qn,{className:`size-4 text-green shrink-0`}),(0,G.jsx)(`span`,{className:`font-medium text-green`,children:x?`Connected via Fabric Connect`:`Signed in directly`}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,x?`through your Harper account`:`session cookie`]})]}),(0,G.jsxs)(B,{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,G.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,G.jsx)(qr,{className:`size-6`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-lg font-medium text-foreground`,children:`Enter cluster`}),(0,G.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Open the studio — apps, databases, APIs, logs, and config.`})]}),(0,G.jsx)(Rn,{className:`size-5 text-muted-foreground transition-transform group-hover:translate-x-1`})]}),(0,G.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-4 text-sm`,children:[x&&(0,G.jsx)(`button`,{type:`button`,onClick:y,className:`text-muted-foreground hover:text-foreground transition-colors`,children:`Switch to direct sign-in`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void b(),className:`text-muted-foreground hover:text-destructive transition-colors`,children:x?`Disconnect`:`Direct sign out`})]})]}):(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-medium text-foreground mb-3`,children:`Connect to this cluster`}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3.5`,children:[l&&!wu(r)&&(0,G.jsx)(Dg,{icon:_i,title:`Fabric Connect`,description:`Connect through your Harper account. No cluster credentials needed.`,pill:C===`fabric`?`last`:C?void 0:`recommended`,children:(0,G.jsx)(P,{className:`w-full`,disabled:f,onClick:()=>void v(),children:f?(0,G.jsx)(Ar,{className:`animate-spin`}):`Fabric Connect`})}),(0,G.jsx)(Dg,{icon:Tr,title:`Direct sign-in`,description:`Sign in with this cluster's Harper username and password.`,pill:C===`direct`?`last`:void 0,children:(0,G.jsx)(P,{className:`w-full`,variant:`outline`,onClick:y,children:`Direct sign-in`})})]})]}),(0,G.jsx)(_g,{clusterId:r.id,base:_})]})}function Sg({cluster:e}){let t=pe(),n=I(),r=`/${e.organizationId}/${e.id}`,i=(0,W.useMemo)(()=>(e.instances??[]).filter(e=>e.status&&!Bo.includes(e.status)).sort(nd),[e.instances]),a=i.at(0),{user:s,isLoading:c}=Dn(a?.id),l=!!a&&!!s,f=(0,W.useCallback)(()=>{a&&n({to:`${r}/instance/${a.id}/sign-in`})},[r,a,n]),m=(0,W.useCallback)(async()=>{if(a){try{await d({instanceClient:o({id:a.id,operationsUrl:p(a)}),entityId:a.id})}catch{}u.setUserForEntity(a,null),u.flagForBasicAuth(a.id,null),await t.invalidate()}},[a,t]);return(0,G.jsxs)(Cg,{children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-4 mb-6`,children:[(0,G.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,G.jsx)($r,{className:`size-6`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:e.name}),(0,G.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,G.jsx)(`div`,{className:`mt-1 text-sm text-muted-foreground`,children:(0,G.jsxs)(B,{to:`${r}/instances`,className:`hover:text-foreground hover:underline`,children:[i.length,` `,i.length===1?`instance`:`instances`]})})]})]}),a?c?(0,G.jsx)(wg,{}):l?(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-sm`,children:[(0,G.jsx)(Qn,{className:`size-4 text-green shrink-0`}),(0,G.jsx)(`span`,{className:`font-medium text-green`,children:`Signed in directly`}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,a.name||a.instanceFqdn]})]}),(0,G.jsxs)(B,{to:`${r}/instance/${a.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,G.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,G.jsx)(qr,{className:`size-6`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-lg font-medium text-foreground`,children:`Enter cluster`}),(0,G.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Open the studio — apps, databases, APIs, logs, and config.`})]}),(0,G.jsx)(Rn,{className:`size-5 text-muted-foreground transition-transform group-hover:translate-x-1`})]}),(0,G.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-4 text-sm`,children:(0,G.jsx)(`button`,{type:`button`,onClick:()=>void m(),className:`text-muted-foreground hover:text-destructive transition-colors`,children:`Direct sign out`})})]}):(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-medium text-foreground mb-3`,children:`Connect to this cluster`}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3.5`,children:(0,G.jsx)(Dg,{icon:Tr,title:`Direct sign-in`,description:`Sign in with this instance's Harper username and password.`,children:(0,G.jsx)(P,{className:`w-full`,variant:`outline`,onClick:f,children:`Direct sign-in`})})})]}):(0,G.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`This cluster has no instances yet. Register one from the`,` `,(0,G.jsx)(B,{to:`${r}/instances`,className:`underline hover:text-foreground`,children:`Instances`}),` page.`]})]})}function Cg({children:e}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Fc,{}),(0,G.jsx)(Uu,{children:(0,G.jsx)(`div`,{className:`max-w-3xl`,children:e})})]})}function wg(){return(0,G.jsx)(`div`,{className:`flex justify-center py-10 text-muted-foreground`,children:(0,G.jsx)(Ar,{className:`size-6 animate-spin`})})}function Tg({status:e}){let t=e&&zo.includes(e)?`text-green bg-green/10`:e===`STOPPED`?`text-destructive bg-destructive/10`:e===`PARTIAL`?`text-yellow bg-yellow/10`:`text-muted-foreground bg-muted`;return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full ${t}`,children:[(0,G.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e?e.charAt(0)+e.slice(1).toLowerCase():`Unknown`]})}function Eg(){return(0,G.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-yellow bg-yellow/10`,children:[(0,G.jsx)(Or,{className:`size-3`}),`Safe mode`]})}function Dg({icon:e,title:t,description:n,pill:r,children:i}){return(0,G.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,G.jsx)(`span`,{className:`absolute -top-2.5 left-4 rounded-full bg-card`,children:(0,G.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,G.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),r===`last`?`Last used`:`Recommended`]})}),(0,G.jsx)(e,{className:`size-6 text-primary dark:text-violet-300 mb-2`}),(0,G.jsx)(`div`,{className:`text-[15px] font-medium text-foreground mb-1`,children:t}),(0,G.jsx)(`p`,{className:`text-[13px] text-muted-foreground leading-normal mb-4`,children:n}),i]})}function Og({children:e,className:t}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Fc,{}),(0,G.jsx)(Uu,{children:(0,G.jsx)(`div`,{className:t,children:e})})]})}var kg=new Set([`com`,`co`,`org`,`net`,`edu`,`gov`,`mil`,`me`,`biz`,`info`,`ac`,`or`,`ne`,`go`,`lg`,`asn`,`id`,`nom`,`sch`,`ltd`,`plc`]);function Ag(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&&kg.has(r)?3:2;return t.length<=i?`@`:t.slice(0,-i).join(`.`)}function jg({cluster:{fqdn:e},domain:{domain:t,id:n}}){let r=Ag(t),[i,a,o]=zu(r,e||``,n);return(0,G.jsxs)(`div`,{className:`grid gap-4 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,G.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,G.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:i,children:(0,G.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:a,children:(0,G.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,G.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.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,G.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,G.jsx)(P,{type:`button`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:o,children:(0,G.jsx)(sr,{className:`w-3 h-3`})})]})}),(0,G.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 Mg({certificate:e,domain:t,cluster:n}){let r=Ag(t.domain),[i,a,o]=zu(r,n.fqdn||``,t.id),s=(0,W.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,G.jsxs)(`div`,{className:`w-full max-w-2xl border border-border/50 rounded-md p-4 bg-gray-900/20`,children:[(0,G.jsxs)(`div`,{className:`mb-4`,children:[(0,G.jsx)(`div`,{className:`w-full h-1.5 rounded-full overflow-clip flex shadow-sm bg-gray-800`,children:(0,G.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,G.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-light mt-1 italic`,children:s.text})]}),(0,G.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] text-sm`,children:[(0,G.jsx)(`div`,{className:`col-span-1 text-xs text-muted-foreground`,children:`CNAME:`}),(0,G.jsxs)(`div`,{className:`col-span-1 flex gap-2 items-center flex-wrap`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,G.jsx)(`span`,{className:`truncate max-w-[150px]`,title:r,children:r}),(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:i,title:`Copy Name`,children:(0,G.jsx)(sr,{className:`w-3 h-3`})})]}),(0,G.jsx)(Ng,{}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,G.jsx)(`span`,{className:`truncate max-w-[200px]`,title:n.fqdn||``,children:n.fqdn}),(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:a,title:`Copy Target`,children:(0,G.jsx)(sr,{className:`w-3 h-3`})})]})]}),(0,G.jsx)(`div`,{className:`col-span-1 text-[10px] text-muted-foreground`,children:`Domain ID:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-[10px] text-muted-foreground italic`,children:[(0,G.jsx)(`span`,{className:`truncate max-w-[200px]`,children:t.id}),(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`sm`,className:`h-3 w-3 p-0`,onClick:o,title:`Copy ID`,children:(0,G.jsx)(sr,{className:`w-2.5 h-2.5`})})]})})]})]})}function Ng(){return(0,G.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,G.jsx)(`path`,{d:`M5 12h14`}),(0,G.jsx)(`path`,{d:`m12 5 7 7-7 7`})]})}function Pg(e){let{enabled:t,entityId:n,databaseName:r,tableName:i,searchAttribute:a,sort:o,pageIndex:s,pageSize:c,onlyIfCached:l,getAttributes:u}=e;return R({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:()=>Fg(e)})}async function Fg({instanceClient:e,databaseName:t,tableName:n,searchAttribute:r,sort:i,pageIndex:a,pageSize:o,onlyIfCached:s,getAttributes:c,headers: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,headers:l,validateStatus:e=>e>=200&&e<400||e===404});return d.status===404?{data:[]}:d}function Ig(e){return R({queryKey:[e,`ChallengeCertificate`],queryFn:async()=>{if(!e)return[];let{data:t}=await Fg({searchAttribute:`domain`,entityId:e,databaseName:`data`,tableName:`ChallengeCertificate`,sort:{attribute:`domain`,descending:!0},instanceClient:o({id:e,forceFabricConnect:!0}),onlyIfCached:!1,pageIndex:0,pageSize:100});return t},enabled:!!e,refetchInterval:ns(5e3),retry:rs()})}function Lg(e){return V(Ig(e))}function Rg({domain:{challengeToken:e,challengeTxtRecord:t,domain:n,id:r},cluster:{fqdn:i}}){let a=Ag(n),[o,s,c,l,u]=zu(t,e,a,i||``,r);return(0,G.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,G.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,G.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`TXT`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:o,children:(0,G.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Content:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:s,children:(0,G.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,G.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,G.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:c,children:(0,G.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:l,children:(0,G.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,G.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.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,G.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,G.jsx)(P,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:u,children:(0,G.jsx)(sr,{className:`w-3 h-3`})})]})}),(0,G.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.`})]})}async function zg({clusterId:e,domainIds:t,generateDomainCerts:n}){let{data:r}=await M.put(`/Cluster/${e}`,{domainIds:t,generateDomainCerts:n},{timeout:0});return r}function Bg(){return L({mutationFn:e=>zg(e)})}S({domainId:A()});async function Vg(e){let{data:t}=await M.delete(`/Domain/${e.domainId}`);return t}function Hg(){return L({mutationFn:e=>Vg(e)})}function Ug(e){return[...new Set(e)]}var Wg=lm();function Gg(e,t,n){let{data:r}=Lg(e.id),i=(0,W.useMemo)(()=>!!r?.some(e=>!e.issueDate||e.inProgress),[r]),{mutate:a,isPending:o}=Bg(),{mutate:s,isPending:c}=Hg(),l=o||c,u=(0,W.useCallback)((t,n)=>{if(!qo(e.status)){H.error(`Cluster is currently `+e.status,{description:`To bind a domain, it must be running.`});return}a({clusterId:e.id,domainIds:Ug((e.domainIds?.slice()||[]).concat([t])),generateDomainCerts:n},{onSuccess:()=>{Ci.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),H.success(`Domain bound!`+(n?` Certificates are being generated in the background now.`:``))}})},[a,e]),d=(0,W.useCallback)(t=>{s({domainId:t},{onSuccess:()=>{Ci.invalidateQueries({queryKey:[e.organizationId,`domains`],refetchType:`active`}),H.success(`Domain removed!`)}})},[s]),f=(0,W.useCallback)(t=>{a({clusterId:e.id,domainIds:(e.domainIds?.slice()||[]).filter(e=>e!==t),generateDomainCerts:!1},{onSuccess:()=>{Ci.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),H.success(`Domain unbound!`)}})},[s]);return(0,W.useMemo)(()=>[Wg.display({id:`select`,header:`Bind`,size:50,cell:r=>{let a=r.row.original;return a.status===`ACTIVE`&&!a.clusterId&&!wu(e)?(0,G.jsx)(`label`,{className:`p-10 -m-10`,children:(0,G.jsx)(`input`,{type:`checkbox`,checked:t.includes(a.id),onChange:()=>n(a.id),disabled:l||i})}):null}}),Wg.display({header:`Domains`,id:`domain`,enableSorting:!1,size:150,cell:e=>{let t=e.row.original;return(0,G.jsxs)(Ba,{children:[(0,G.jsx)(Va,{asChild:!0,children:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{children:t.domain}),(0,G.jsx)(P,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l||!!t.clusterId,onClick:()=>d(t.id),children:`Remove Domain`})]})}),(0,G.jsx)(Ha,{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!`})]})}}),Wg.display({header:`Next Steps`,enableSorting:!1,size:500,id:`nextSteps`,cell:t=>{let n=t.row.original,i=r?.find(e=>e.domain===n.domain);return n.status===`ACTIVE`&&n.clusterId?e.id===n.clusterId?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{children:`Bound to this cluster`}),i&&(!i.issueDate||i.inProgress)&&(0,G.jsx)(`div`,{className:`py-2`,children:(0,G.jsx)(Mg,{certificate:i,domain:n,cluster:e})}),(0,G.jsx)(P,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l,onClick:()=>f(n.id),children:`Unbind Domain`})]}):`Bound to cluster ${n.clusterId}`:n.status===`PENDING_VALIDATION`?(0,G.jsx)(Rg,{domain:n,cluster:e}):wu(e)?`Cannot be associated with this self-managed cluster.`:n.status===`ACTIVE`&&!n.clusterId?(0,G.jsx)(jg,{cluster:e,domain:n}):n.status}})],[e,u,l,r,i,t,n])}var Kg=S({domain:A(),organizationId:A()});async function qg(e){let{data:t}=await M.post(`/Domain/`,e);return t}function Jg(){return L({mutationFn:e=>qg(e)})}async function Yg(e){let{data:t}=await M.post(`/Domain/${e}/validate`);return t}async function Xg(e){let{data:t}=await M.get(`/Domain/?organizationId=${e}`);return t}function Zg(e){return R({queryKey:[e,`domains`],queryFn:()=>Xg(e)})}function Qg(){let{organizationId:e,clusterId:t}=z({strict:!1}),{data:n}=_e(os(t,!0)),{update:r}=lu(e),{data:i,refetch:a,isFetching:o,isRefetching:s}=V(Zg(e)),c=(0,W.useMemo)(()=>i?.filter(e=>e.status===`PENDING_VALIDATION`)||[],[i]),[l]=(0,W.useState)({attribute:`domain`,descending:!1}),u=(0,W.useMemo)(()=>[{desc:l.descending,id:l.attribute}],[l]),d=hm(a),[f,p]=(0,W.useState)([]),m=(0,W.useCallback)(e=>{p(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),{mutate:g,isPending:_}=Bg(),v=(0,W.useCallback)(()=>{if(!qo(n.status)){H.error(`Cluster is currently `+n.status,{description:`To bind a domain, it must be running.`});return}g({clusterId:n.id,domainIds:Ug((n.domainIds?.slice()||[]).concat(f)),generateDomainCerts:!0},{onSuccess:()=>{Ci.invalidateQueries({queryKey:[n.organizationId],refetchType:`active`}),H.success(`Domain(s) bound! Certificates are being generated in the background now.`),p([])}})},[n,f,g]),{mutateAsync:y,isPending:b}=Jg(),x=Pt({resolver:Ke(Kg),defaultValues:{domain:``,organizationId:e}}),S=(0,W.useCallback)(async e=>{if(e){let t=e.domain.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean);for(let n of t)await y({...e,domain:n});x.reset(),await a(),H.success(`${h(t.length,`Domain`,`Domains`)} added! Please add the txt record above to your domain registrar.`)}},[y,x,a]),C=(0,W.useCallback)(async()=>{let e=`Validating ${h(c.length,`domain`,`domains`)}...`,t=`validatingDomains`,n=0,r=0;for(let i of c)try{H.loading(e,{description:`${n++} of ${c.length} checked`,id:t}),await Yg(i.id)}catch{r+=1}r>0?H.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(),H.success(`Validation succeeded!`,{description:`Please take a look at the next steps for newly verified domains.`,id:t}))},[c]),w=Gg(n,f,m),T=x.watch(`domain`),E=(0,W.useMemo)(()=>typeof T==`string`&&T.trim().split(`.`).length===2,[T]),D=(0,W.useCallback)(()=>{typeof T==`string`&&x.setValue(`domain`,`${T.trim()}, www.${T.trim()}`)},[T,x]);return(0,G.jsx)(um,{data:i||[],isFetching:o||s,columns:w,sortingState:u,children:(0,G.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,G.jsx)(q,{...x,children:(0,G.jsxs)(`form`,{id:`cluster-add-domain-form`,name:`cluster-add-domain-form`,onSubmit:x.handleSubmit(S),className:`flex gap-1 flex-col md:flex-row`,children:[(0,G.jsx)(Y,{control:x.control,name:`domain`,render:({field:e})=>(0,G.jsxs)(X,{className:`flex-1`,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`New Domain Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,enterKeyHint:`done`,autoComplete:`off`,...e})}),E&&(0,G.jsxs)(`div`,{className:`mt-1 flex gap-4`,children:[`Adding an apex domain?`,(0,G.jsx)(P,{variant:`positiveOutline`,type:`button`,onClick:D,children:`Add www as well`})]}),(0,G.jsx)(Q,{children:(0,G.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,G.jsxs)(`div`,{className:`flex-0 self-start flex gap-1 md:pt-6.5`,children:[(0,G.jsxs)(P,{type:`submit`,variant:`submit`,disabled:b,children:[(0,G.jsx)(Gr,{}),` Add`]}),c.length>0&&(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:C,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,G.jsx)(kr,{}),` `,(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`V`}),`alidate`]})]}),(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:d,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,G.jsx)(Kr,{}),` `,(0,G.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,G.jsx)(`u`,{children:`R`}),`efresh`]})]})]})]})}),f.length>0&&(0,G.jsx)(`div`,{className:`flex-0 self-start md:pt-6.5`,children:(0,G.jsxs)(P,{variant:`submit`,onClick:v,disabled:_,children:[(0,G.jsx)(Xr,{}),` Bind `,h(f.length,`Domain`,`Domains`)]})})]})})}function $g(){return(0,G.jsx)(Og,{className:`flex flex-col justify-start max-w-4xl`,children:(0,G.jsx)(Qg,{})})}var e_=S({username:ls,role:A().nonempty({error:`Please select a role.`}),password:cs.min(8,{error:`Password must be at least 8 characters long.`}),confirmPassword:A()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});async function t_(e){await M.patch(`/ResetPasswordUpdater/${e}`)}async function n_(e){let{instanceClient:t,...n}=e,{data:r}=await t.post(`/`,{operation:`add_user`,...n});return r}function r_(){return L({mutationFn:n_})}async function i_({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 a_(){return L({mutationFn:i_})}async function o_({username:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_user`,username:e});return n}function s_(){return L({mutationFn:o_})}async function c_({clusterId:e,initialUsername:t,desiredUsername:n,newPassword:r,tempPassword:i,instanceClient:a}){if(!i)throw Error(`You may not have permission to set the password on this cluster.`);let o=a;try{let a=await Ho({username:t,password:i,instanceClient:o,entityId:e});return a.instanceClient&&(o=a.instanceClient),n===`HDB_ADMIN`?await i_({username:n,password:r,instanceClient:o}):(await n_({username:n,password:r,role:`super_user`,active:!0,instanceClient:o}),await Ho({username:n,password:r,instanceClient:o,entityId:e}),await o_({username:g,instanceClient:o})),await t_(e),a}catch(t){throw await d({entityId:e,instanceClient:o}),t}}function l_(){return L({mutationFn:c_})}function u_(){let{user:e}=wn(),{clusterId:t}=z({strict:!1}),{data:n}=V(os(t,!0)),r=I(),i=Ie(),a=(0,W.useMemo)(()=>c(n),[n]),o=Wa({operationsUrl:a}),{redirect:s}=he({strict:!1}),l=pe(),d=Pt({resolver:Ke(e_),defaultValues:{confirmPassword:``,password:``,role:`super_user`,username:e?.email??``}}),{setFocus:f,control:p,handleSubmit:m}=d;(0,W.useEffect)(()=>{f(`password`)},[f]);let h=n?.instances?.find(e=>e.tempPassword)?.tempPassword,_=Qo(n),{mutate:v,isPending:y}=l_(),b=(0,W.useCallback)(async e=>{if(!a){H.error(`Cluster is not yet fully loaded, please wait a moment before trying to sign in.`);return}if(!_){H.error(`Some instances are still starting up. You can create your admin user once they are all running.`);return}v({instanceClient:o,clusterId:t,newPassword:e.password,tempPassword:h,initialUsername:g,desiredUsername:e.username},{onSuccess:async({message:e,user:a})=>{H.success(e),u.setUserForEntity(n,a),await as(i,t),l.invalidate(),await r({to:s?.startsWith(`/`)?s:`../`})}})},[n,t,o,_,r,a,i,s,l,v,h]);return n&&!n.resetPassword?(0,G.jsx)(ce,{to:`../sign-in`,replace:!0}):n&&!_?(0,G.jsx)(ce,{to:`../starting-up`,replace:!0}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`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,G.jsx)(Po,{})}),(0,G.jsx)(`div`,{className:`items-center justify-center flex mt-32 py-4 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,G.jsxs)(`div`,{className:`text-foreground w-xs`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light`,children:`Create Admin User`}),(0,G.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,G.jsx)(q,{...d,children:(0,G.jsxs)(`form`,{id:`cluster-create-admin-form`,name:`cluster-create-admin-form`,onSubmit:m(b),className:`my-4`,children:[(0,G.jsx)(Y,{control:p,name:`username`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-4`,children:[(0,G.jsx)(Z,{children:`Username`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{autoComplete:`username`,type:`text`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:p,name:`password`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-4`,children:[(0,G.jsx)(Z,{children:`Password`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,autoComplete:`new-password`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:p,name:`confirmPassword`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-4`,children:[(0,G.jsx)(Z,{children:`Confirm Password`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,autoComplete:`new-password`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(P,{disabled:y,type:`submit`,variant:`submit`,className:`w-full my-2`,children:`Create Admin User`})]})}),(0,G.jsxs)(`p`,{className:`text-muted-foreground flex gap-2 align-middle`,children:[(0,G.jsx)(Fn,{size:36,className:`flex-none`}),(0,G.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 d_({columns:e,data:t,renderRowWrapper:n}){let r=Le({features:cm,data:t,columns:e});return(0,G.jsx)(`div`,{className:`bg-card dark:bg-black-dark rounded-md`,children:(0,G.jsxs)(tm,{children:[(0,G.jsx)(nm,{children:r.getHeaderGroups().map(e=>(0,G.jsx)(im,{className:`border-none`,children:e.headers.map(e=>(0,G.jsx)(am,{className:`p-4`,style:{width:`${e.getSize()}%`},children:e.isPlaceholder?null:Me(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,G.jsx)(rm,{className:`bg-background dark:bg-black`,children:r.getRowModel().rows?.length?r.getRowModel().rows.map(e=>{let t=(0,G.jsx)(im,{"data-state":e.getIsSelected()&&`selected`,className:`hover:bg-muted/10 data-[state=selected]:bg-muted`,children:e.getVisibleCells().map(e=>(0,G.jsx)(sm,{className:`p-4`,style:{width:`${e.column.getSize()}%`},children:Me(e.column.columnDef.cell,e.getContext())},e.id))});return(0,G.jsx)(W.Fragment,{children:n?n(e.original,t):t},e.id)}):(0,G.jsx)(im,{children:(0,G.jsx)(sm,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function f_(){return(0,G.jsx)(`div`,{className:`flex-col items-center justify-center px-16 space-y-3 text-center pt-30`,children:(0,G.jsx)(`p`,{children:`No instances found.`})})}async function p_({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 m_({instanceId:e,action:t,safeMode:n}){let r=n===void 0?{}:{safeMode:n},{data:i}=await M.post(`/HDBInstance/${e}/container/${t}`,r);return i}function h_(){return L({mutationFn:m_})}var g_={stop:`Stopping`,start:`Starting`,restart:`Restarting`};function __(e){let{clusterId:t}=z({strict:!1}),{mutateAsync:n,isPending:r}=h_(),i=Ie();return{run:(0,W.useCallback)(async(r,a)=>{let o=a?.label??g_[r],s=e.name??e.id,c=H.loading(o,{description:`${o} ${s}. Status will update shortly.`,duration:3e4,action:{label:`Dismiss`,onClick:()=>H.dismiss()}});try{await n({instanceId:e.id,action:r,safeMode:a?.safeMode}),t&&i.invalidateQueries({queryKey:[t]}),i.invalidateQueries({queryKey:[e.id]}),H.dismiss(c),H.success(`Request accepted`,{description:`${s} is ${o.toLowerCase()}. The status will update automatically.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}})}catch{H.dismiss(c)}},[t,e.id,e.name,n,i]),isPending:r}}function v_({entityId:e,instanceClient:t},n){return R({queryKey:[`get_status`,e],staleTime:9e3,refetchInterval:ns(1e4),retry:rs(),retryDelay:1e4,throwOnError:!1,enabled:n,queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`get_status`});return e}})}function y_(e,t){return e?.systemStatus?.find(e=>e.id===t)?.status}async function b_({instanceClient:e,id:t,status:n}){let{data:r}=await e.post(`/`,{operation:`set_status`,id:t,status:n});return r}function x_(){return L({mutationFn:b_,onSuccess:(e,t)=>Ci.invalidateQueries({queryKey:[`get_status`,t.entityId]})})}var S_=[`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`];function C_(e,t,n){let{user:r}=Dn(e.id),i=(0,W.useMemo)(()=>p(e),[e]),a=Wa({operationsUrl:i}),{update:o}=mu(),s=u.checkForFabricConnect(e.id),c=K({operationsUrl:i,instanceId:e.id,forceFabricConnect:!0}),{data:l}=V(v_(c,n&&o&&!Ko(e.status))),d=y_(l,`availability`)||`Unknown`,f=d===`Available`,m=d===`Unavailable`,{mutate:h,isPending:g}=x_(),{run:_,isPending:v}=__(e),[y,b]=(0,W.useState)(null),x=e.instanceFqdn,S=Mp({secure:e.operationsApiSecure?`true`:`false`,port:e.operationsApiPort,fqdn:e.instanceFqdn}),[C,w]=zu(x??``,S),T=(0,W.useCallback)(async()=>{await p_({instance:e,instanceClient:a})},[e,a]),E=!!e.status&&S_.includes(e.status),D=!!r&&!s,O=E,k=!!x,A=o&&E&&(f||m),j=e.status===`RUNNING`,ee=e.status===`STOPPED`,M=o&&!t&&(j||ee),N=[O&&D&&{key:`direct-connect`,to:`../instance/${e.id}/`,icon:(0,G.jsx)($r,{className:`text-green`}),label:`Direct Connect`},O&&D&&{key:`direct-sign-out`,onClick:T,variant:`destructive`,icon:(0,G.jsx)(Nr,{}),label:`Direct Sign Out`},O&&!D&&o&&!t&&{key:`fabric-connect`,to:`../instance/${e.id}/`,icon:(0,G.jsx)($r,{className:`text-green`}),label:`Fabric Connect`},O&&!D&&{key:`direct-sign-in`,to:`../instance/${e.id}/sign-in`,icon:(0,G.jsx)(Mr,{}),label:`Direct Sign In`},O&&k&&{type:`separator`,key:`copy-sep`},k&&{key:`copy-fqdn`,onClick:C,icon:(0,G.jsx)(nr,{}),label:`Copy Instance FQDN`},k&&{key:`copy-api`,onClick:w,icon:(0,G.jsx)(nr,{}),label:`Copy API URL`},(O||k)&&A&&{type:`separator`,key:`rotation-sep`},A&&f&&{key:`out-of-rotation`,variant:`destructive`,disabled:g,onClick:()=>h({...c,id:`availability`,status:`Unavailable`}),icon:(0,G.jsx)(ni,{}),label:`Bring out of rotation`},A&&m&&{key:`into-rotation`,disabled:g,onClick:()=>h({...c,id:`availability`,status:`Available`}),icon:(0,G.jsx)(ti,{}),label:`Bring back into rotation`},(O||k||A)&&M&&{type:`separator`,key:`container-sep`},M&&{type:`label`,key:`container-label`,className:`text-gray-600 text-xs`,label:`Container`},M&&ee&&{key:`container-start`,disabled:v,onClick:()=>void _(`start`,{safeMode:!1}),icon:(0,G.jsx)(Wr,{}),label:`Start`},M&&ee&&{key:`container-start-safe`,disabled:v,onClick:()=>b(`start`),icon:(0,G.jsx)(Or,{}),label:`Start in safe mode`},M&&j&&{key:`container-restart`,disabled:v,onClick:()=>void _(`restart`,{safeMode:!1}),icon:(0,G.jsx)(Yr,{}),label:`Restart`},M&&j&&{key:`container-restart-safe`,disabled:v,onClick:()=>b(`restart`),icon:(0,G.jsx)(Or,{}),label:`Restart in safe mode`},M&&j&&{key:`container-stop`,variant:`destructive`,disabled:v,onClick:()=>void _(`stop`),icon:(0,G.jsx)(ai,{}),label:`Stop`}].filter(Qa),P=(0,G.jsx)(Au,{open:y!==null,setOpen:e=>{e||b(null)},action:y??`restart`,targetName:e.name??e.id,scope:`instance`,isPending:v,onConfirm:()=>{let e=y;b(null),e&&_(e,{safeMode:!0,label:e===`start`?`Starting in safe mode`:`Restarting in safe mode`})}});return N.length?{items:[{type:`label`,key:`label`,className:`text-gray-600 text-xs`,label:`Options`},{type:`separator`,key:`label-sep`},...N],dialog:P}:{items:[],dialog:P}}function w_({instance:e,isSelfManaged:t}){let[n,r]=(0,W.useState)(!1),{items:i,dialog:a}=C_(e,t,n);return i.length?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(wi,{open:n,onOpenChange:r,children:[(0,G.jsx)(Ti,{asChild:!0,children:(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Instance options`,children:(0,G.jsx)(ur,{})})}),(0,G.jsx)(Ei,{align:`end`,className:`min-w-48`,children:Gc(i,`dropdown`)})]}),a]}):null}function T_({isSelfManaged:e,instance:t}){let{user:n,isLoading:r}=Dn(t.id),i=Wa({operationsUrl:(0,W.useMemo)(()=>p(t),[t])}),{update:a}=mu(),o=u.checkForFabricConnect(t.id),s=(0,W.useCallback)(async()=>{await p_({instance:t,instanceClient:i})},[t,i]);return Ko(t.status)?(0,G.jsx)(`span`,{className:`text-muted-foreground text-sm`,children:`—`}):r||!t.status||![`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`].includes(t.status)?(0,G.jsx)(Ar,{className:`animate-spin`,color:`gray`}):!n||o?(0,G.jsxs)(`span`,{className:`flex gap-4`,children:[a&&!e&&(0,G.jsx)(B,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Connect to ${t.name} instance`,title:`Connect to ${t.name} instance`,children:(0,G.jsx)(P,{variant:`positiveOutline`,children:`Fabric Connect`})}),(0,G.jsx)(B,{to:`../instance/${t.id}/sign-in`,className:`text-sm`,"aria-label":`Sign in to ${t.name} instance`,title:`Sign in to ${t.name} instance`,children:(0,G.jsx)(P,{variant:a?`defaultOutline`:`positiveOutline`,children:`Direct Sign In`})})]}):(0,G.jsxs)(`span`,{className:`flex gap-4`,children:[(0,G.jsx)(B,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Go to ${t.name} instance`,title:`Go to ${t.name} instance`,children:(0,G.jsx)(P,{variant:`positiveOutline`,children:`Direct Connect`})}),(0,G.jsx)(P,{variant:`destructiveOutline`,className:`text-sm`,"aria-label":`Sign out from ${t.name} instance`,title:`Sign out from ${t.name} instance`,onClick:s,children:`Direct Sign Out`})]})}function E_({instance:e,isSelfManaged:t,children:n}){let[r,i]=(0,W.useState)(!1),{items:a,dialog:o}=C_(e,t,r);return a.length?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Lc,{onOpenChange:i,children:[(0,G.jsx)(Rc,{asChild:!0,children:n}),(0,G.jsx)(zc,{className:`min-w-48`,children:Gc(a,`context`)})]}),o]}):(0,G.jsx)(G.Fragment,{children:n})}function D_({instance:e,index:t}){let{update:n}=mu(),r=K({operationsUrl:(0,W.useMemo)(()=>p(e),[e]),instanceId:e.id,forceFabricConnect:!0}),{mutate:i,isPending:a}=x_(),[o,s]=(0,W.useState)(!1);(0,W.useEffect)(()=>{let e=setTimeout(()=>s(!0),t*500);return()=>clearTimeout(e)},[t]);let c=Ko(e.status),{data:l,isLoading:u,isFetching:d}=V(v_(r,o&&n&&!c)),f=y_(l,`availability`)||`Unknown`,m=f===`Available`,h=f===`Unavailable`;return n?c?(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,G.jsxs)(Ba,{children:[(0,G.jsx)(Va,{asChild:!0,children:(0,G.jsx)(`span`,{className:`inline-block size-4 rounded-full bg-muted-foreground/40`,"aria-label":`Not running`})}),(0,G.jsx)(Ha,{children:`Not running`})]})}):(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(Ba,{children:[(0,G.jsx)(Va,{asChild:!0,children:(0,G.jsx)(`div`,{className:`flex items-center`,children:u||!o||d&&!l?(0,G.jsx)(Ar,{className:`animate-spin size-5 text-muted-foreground`}):(0,G.jsx)(Ji,{variant:m?`success`:h?`destructive`:`default`,className:`size-4 rounded-full p-0`,children:(0,G.jsx)(`span`,{className:`sr-only`,children:m?`Online`:`Offline`})})})}),(0,G.jsxs)(Ha,{children:[d&&l?`Refreshing... `:``,f]})]}),n&&(0,G.jsxs)(`div`,{className:`flex gap-1`,children:[m&&(0,G.jsxs)(Ba,{children:[(0,G.jsx)(Va,{asChild:!0,children:(0,G.jsx)(P,{type:`button`,variant:`destructiveGhost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Unavailable`}),disabled:a,children:a?(0,G.jsx)(Ar,{className:`animate-spin size-4`}):(0,G.jsx)(ni,{className:`size-4`})})}),(0,G.jsx)(Ha,{children:`Bring out of rotation`})]}),h&&(0,G.jsxs)(Ba,{children:[(0,G.jsx)(Va,{asChild:!0,children:(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Available`}),disabled:a,children:a?(0,G.jsx)(Ar,{className:`animate-spin size-4`}):(0,G.jsx)(ti,{className:`size-4`})})}),(0,G.jsx)(Ha,{children:`Bring back into rotation`})]})]})]}):null}function O_(){let{clusterId:e}=z({strict:!1}),{data:t,isLoading:n}=V(os(e,!0)),r=wu(t),i=(0,W.useMemo)(()=>[{id:`instanceActions`,size:1,minSize:1,cell:e=>(0,G.jsx)(`div`,{className:`flex justify-end gap-2 items-center`,children:(0,G.jsx)(T_,{isSelfManaged:r,instance:e.row.original})})},r&&{accessorKey:`instanceFqdn`,size:90,header:`URL`,cell:e=>Mp({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,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(D_,{instance:e.row.original,index:e.row.index}),t?(0,G.jsx)(Ji,{variant:Go(t),children:Mo(t)}):null,e.row.original.safeMode&&!Ko(e.row.original.status)?(0,G.jsxs)(Ji,{variant:`warning`,title:`Running in safe mode — user apps/components are not loaded`,children:[(0,G.jsx)(Or,{}),`Safe mode`]}):null]})}},!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,G.jsxs)(G.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,G.jsx)(`div`,{className:`flex justify-end`,children:(0,G.jsx)(w_,{isSelfManaged:r,instance:e.row.original})})}].filter(Qa),[r]),a=(0,W.useMemo)(()=>t?.instances?t.instances.filter(e=>e.status&&!Bo.includes(e.status)).sort(nd):[],[t]);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Fc,{}),(0,G.jsx)(Uu,{children:(0,G.jsx)(On,{className:`p-0 min-h-96`,children:(0,G.jsx)(Mn,{className:`p-0 min-h-96`,children:n?(0,G.jsx)(Kf,{}):a.length?(0,G.jsx)(d_,{data:a,columns:i,renderRowWrapper:(e,t)=>(0,G.jsx)(E_,{instance:e,isSelfManaged:r,children:t})}):(0,G.jsx)(f_,{})})})})]})}function k_(){let{clusterId:e}=z({strict:!1}),{immediate:t}=he({strict:!1}),n=t===!0||t===`true`,{data:r,isLoading:i}=V(os(e,2e3)),a=r?.status,o=(0,W.useMemo)(()=>a&&zo.includes(a),[a]);return i||!r?(0,G.jsx)(Og,{className:`flex justify-center`,children:(0,G.jsx)(Kf,{})}):o?(0,G.jsx)(Og,{className:`flex justify-center`,children:(0,G.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,G.jsx)(`h1`,{className:`text-xl text-center`,children:`All done!`}),(0,G.jsx)(ku,{cluster:r,forceProgressBarVisible:!0}),(0,G.jsx)(`p`,{children:`Your cluster finished updating, and is ready for interaction.`}),(0,G.jsx)(`div`,{className:`text-center`,children:(0,G.jsx)(Tu,{cluster:r})})]})}):(0,G.jsx)(Og,{className:`flex justify-center`,children:(0,G.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,G.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,G.jsx)(ku,{cluster:r,forceProgressBarVisible:!0}),(0,G.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,G.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,G.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 A_({children:e,className:t}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Fc,{}),(0,G.jsx)(`div`,{className:y(`mt-32 px-4 py-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] flex justify-center`,t),children:e})]})}function j_(){let e=pe(),{clusterId:t}=z({strict:!1}),{data:n,isLoading:r}=V(os(t,2e3)),i=n?.status,a=(0,W.useMemo)(()=>i&&zo.includes(i)&&Qo(n),[i,n]),o=Jo(i),[,s]=xn(vn.SavedClusterState,null),c=(0,W.useCallback)(()=>{s(n),e.navigate({to:`/${n.organizationId}/new-cluster`})},[n,e,s]);return r||!n?(0,G.jsx)(A_,{className:`flex justify-center`,children:(0,G.jsx)(Kf,{})}):o?(0,G.jsx)(A_,{className:`flex justify-center`,children:(0,G.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4 items-center`,children:[(0,G.jsx)(rr,{className:`w-24 h-24`}),(0,G.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,G.jsx)(_s,{}),` if you want more help.`]}),(0,G.jsx)(P,{type:`button`,variant:`positiveOutline`,onClick:c,children:`Try Again`})]})}):a?(0,G.jsx)(A_,{className:`flex justify-center`,children:(0,G.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,G.jsx)(`h1`,{className:`text-xl text-center`,children:`It's ready!`}),(0,G.jsx)(ku,{cluster:n,forceProgressBarVisible:!0}),(0,G.jsxs)(`p`,{children:[`Let's set up your secure, browser-to-cluster connection now.`,` `,(0,G.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,G.jsx)(`em`,{children:`Direct Connect`}),`! Once you create your user, you will have the option to`,` `,(0,G.jsx)(`em`,{children:`Fabric Connect`}),` from your Fabric account without having to sign in again.`]})]}),(0,G.jsx)(`div`,{className:`text-center`,children:(0,G.jsx)(Tu,{cluster:n})})]})}):(0,G.jsx)(A_,{className:`flex justify-center`,children:(0,G.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,G.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,G.jsx)(ku,{cluster:n,forceProgressBarVisible:!0}),(0,G.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,G.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,G.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 M_(){let{clusterId:e}=z({strict:!1}),{data:t,isLoading:n}=mg(e);if(n)return(0,G.jsxs)(Og,{className:`max-w-4xl pb-20`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:`Usage`}),(0,G.jsx)(`div`,{className:`flex justify-center py-16 text-muted-foreground`,children:(0,G.jsx)(Ar,{className:`size-6 animate-spin`})})]});let r=t&&!t.selfManaged?R_(t.regions):null;return(0,G.jsxs)(Og,{className:`max-w-4xl pb-20`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:`Usage`}),t?t.selfManaged?(0,G.jsx)(V_,{children:`Usage isn't tracked for self-hosted clusters — they run under their own license.`}):t.regions.length===0?(0,G.jsx)(V_,{children:`No usage has been recorded for the current cycle yet.`}):(0,G.jsxs)(`div`,{className:`mt-5 space-y-3`,children:[t.regions.map(e=>(0,G.jsx)(N_,{region:e,showPlanInfo:r==null},e.region??e.regionIds.join())),r&&(0,G.jsx)(P_,{header:(0,G.jsx)(F_,{title:`Plan limits & resources`}),aside:r.planId??void 0,children:(0,G.jsx)(I_,{rateLimits:r.rateLimits,resourcesPerInstance:r.resourcesPerInstance})})]}):(0,G.jsx)(H_,{})]})}function N_({region:e,showPlanInfo:t}){let n=ug.map(t=>dg(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 ${L_(e.expiresAt)}`:null].filter(Boolean).join(` · `);return(0,G.jsxs)(P_,{defaultOpen:e.status!==`lapsed`,aside:e.regionIds.length>0?e.regionIds.join(`, `):void 0,header:(0,G.jsxs)(F_,{title:e.region??`Region`,meta:r,children:[e.status===`exhausted`&&(0,G.jsx)(`span`,{className:`rounded-full bg-yellow/10 px-2 py-0.5 text-[11px] text-yellow`,children:`Cycle exhausted`}),e.status===`lapsed`&&(0,G.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground`,children:`No active license`})]}),children:[(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-x-10 gap-y-4 sm:grid-cols-2`,children:n.map(e=>(0,G.jsx)(fg,{...e},e.label))}),t&&(0,G.jsx)(I_,{rateLimits:e.rateLimits,resourcesPerInstance:e.resourcesPerInstance})]})}function P_({header:e,aside:t,defaultOpen:n=!0,children:r}){let[i,a]=(0,W.useState)(n);return(0,G.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-border`,children:[(0,G.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,G.jsx)(Yn,{className:`size-4 shrink-0 text-muted-foreground transition-transform ${i?`rotate-90`:``}`}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:e}),t&&(0,G.jsx)(`span`,{className:`shrink-0 self-start pt-0.5 font-mono text-[11px] text-muted-foreground/70`,children:t})]}),i&&(0,G.jsx)(`div`,{className:`border-t border-border px-4 py-4`,children:r})]})}function F_({title:e,meta:t,children:n}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e}),n]}),t&&(0,G.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t})]})}function I_({rateLimits:e,resourcesPerInstance:t}){let n=e,r=n?B_([[`Reads / minute`,n.readsPerMinute,vp],[`Read bandwidth / minute`,n.readsPerMinuteBytes,_p],[`Writes / minute`,n.writesPerMinute,vp],[`Write bandwidth / minute`,n.writesPerMinuteBytes,_p],[`Real-time deliveries / minute`,n.realTimeDeliveriesPerMinute,vp],[`Real-time bandwidth / minute`,n.realTimeDeliveryBytesPerMinute,_p],[`TLS handshakes (cycle)`,n.tlsHandshakes,vp]]):[],i=t,a=i?z_([[`Storage`,i.storageGb,e=>`${vp(e)} GB`],[`Memory`,i.memoryMb,e=>_p(e*1e3*1e3)],[`vCPU`,i.cpuCores,e=>`${e} ${e===1?`core`:`cores`}`],[`Threads`,i.threads,e=>String(e)]]):[];return(0,G.jsxs)(G.Fragment,{children:[r.length>0&&(0,G.jsx)(U_,{title:`Rate limits`,subtitle:`Throughput ceilings — not part of the cycle allotment, and not metered.`,children:(0,G.jsx)(W_,{rows:r})}),a.length>0&&(0,G.jsx)(U_,{title:`Per-instance resources`,subtitle:`Provisioned capacity on each instance.`,children:(0,G.jsx)(W_,{rows:a})})]})}function L_(e){return new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))}function R_(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 z_(e){return e.filter(e=>typeof e[1]==`number`&&e[1]>0).map(([e,t,n])=>[e,n(t)])}function B_(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 V_({children:e}){return(0,G.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:e})}function H_(){return(0,G.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 U_({title:e,subtitle:t,children:n}){return(0,G.jsxs)(`div`,{className:`mt-6 first:mt-0`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:e}),(0,G.jsx)(`p`,{className:`mt-0.5 mb-3 text-xs text-muted-foreground`,children:t}),n]})}function W_({rows:e}){return(0,G.jsx)(`dl`,{className:`grid grid-cols-1 gap-x-10 gap-y-2 sm:grid-cols-2`,children:e.map(([e,t])=>(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 border-b border-border/60 py-1.5 text-sm`,children:[(0,G.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,G.jsx)(`dd`,{className:`text-foreground tabular-nums`,children:t})]},e))})}F({getParentRoute:()=>ig,path:`instances`,head:()=>({meta:[{title:`Instances — Harper Fabric`}]}),component:O_}),F({getParentRoute:()=>ig,path:`starting-up`,head:()=>({meta:[{title:`Starting Up — Harper Fabric`}]}),component:j_}),F({getParentRoute:()=>ig,path:`scaling`,head:()=>({meta:[{title:`Scaling — Harper Fabric`}]}),component:k_}),F({getParentRoute:()=>ig,path:`domains`,head:()=>({meta:[{title:`Domains — Harper Fabric`}]}),component:$g}),F({getParentRoute:()=>ig,path:`usage`,head:()=>({meta:[{title:`Usage — Harper Fabric`}]}),component:M_});function G_({location:e,params:t}){let n=u.checkForFabricConnect(t.clusterId);if(u.getConnectionById(t.clusterId).user&&!n){let t=e?.search?.redirect;throw le({to:t?.startsWith(`/`)?t:`../`})}}function K_({location:e,params:t}){let n=u.checkForFabricConnect(t.instanceId);if(u.getConnectionById(t.instanceId).user&&!n){let t=e?.search?.redirect;throw le({to:t?.startsWith(`/`)?t:`../`})}}F({getParentRoute:()=>ig,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:gs,beforeLoad:G_}),F({getParentRoute:()=>ig,path:`instance/$instanceId/sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:gs,beforeLoad:K_}),F({getParentRoute:()=>ig,path:`finish-setup`,head:()=>({meta:[{title:`Create Admin User — Harper Fabric`}]}),component:u_}),F({getParentRoute:()=>ig,path:`/`,head:()=>({meta:[{title:`Cluster — Harper Fabric`}]}),component:xg});function q_(e){return F({getParentRoute:()=>e,path:`apis`,head:()=>({meta:[{title:`APIs — Harper Fabric`}]})}).lazy(()=>ne(()=>import(`./index.lazy-B1VOIv-t.js`).then(e=>e.route),__vite__mapDeps([25,1,26,3,2,4,5,6,7,27,12,9,16,11,13,28,29])))}function J_(e,t){return[F({getParentRoute:()=>e,path:t===`cluster`?`apps`:`/`,head:()=>({meta:[{title:`Applications — Harper Fabric`}]}),component:we(()=>ne(()=>import(`./applications-DvFDYJgK.js`),__vite__mapDeps([30,1,26,3,2,4,5,6,7,27,12,9,8,10,11,13,16,31,32,20,21,14,28,29,33,22,23,24,34])),`ApplicationsEditor`)})]}async function Y_({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_certificates`});return t}function X_(e){return R({queryKey:[e.entityId,`list_certificates`],queryFn:()=>Y_(e)})}var Z_=[{header:`Certificate Name`,accessorKey:`name`,enableSorting:!0},{header:`Issuer`,accessorKey:`details.issuer`,enableSorting:!0},lm().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 Q_({className:e,...t}){return(0,G.jsx)(`textarea`,{"data-slot":`input`,className:N(`border-input file:text-foreground placeholder:text-muted-foreground selection:bg-purple
13
13
  selection:text-primary-foreground
14
14
  dark:aria-invalid:outline-destructive dark:aria-invalid:ring-destructive/50 ring-ring/10
15
15
  dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 aria-invalid:outline-destructive/60
@@ -667,7 +667,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
667
667
  }
668
668
  ]
669
669
  }
670
- `),jy=`inmemory://harper/config-root.json`,My=`harper://schemas/config-root.json`;async function Ny(){let{json:e}=await ne(async()=>{let{json:e}=await import(`./languageServices-BM4fI4rS.js`).then(e=>e.t);return{json:e}},__vite__mapDeps([33,1,20,4,21])),t=e.jsonDefaults,{schemas:n=[],...r}=t.diagnosticsOptions;n.some(e=>e.uri===My)||t.setDiagnosticsOptions({...r,validate:!0,enableSchemaRequest:!1,schemas:[...n,{uri:My,fileMatch:[jy],schema:Ay}]})}var Py=({children:e})=>(0,G.jsx)(G.Fragment,{children:e});function Fy(){let{clusterId:e,instanceId:t}=z({strict:!1}),{data:n,isLoading:r}=V(gy({clusterId:e,instanceId:t})),i=K(),{version:a}=oe({strict:!1}),{data:o}=V(wy(i,!1));n?.cluster;let s=n?.instance,{data:c,isLoading:l}=V(Bv(i)),{data:u,isLoading:d}=V(Cy(i)),f=_u(),{data:p,isLoading:m}=V(Sy({...i,enabled:f})),h=(0,W.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,W.useMemo)(()=>u?Dy(u):null,[u]),_=Dm(),[v,y]=(0,W.useState)(!1),[b,x]=(0,W.useState)(``),[S,C]=(0,W.useState)(null),[w,T]=(0,W.useState)([]),{onConfigUpdate:E,isPending:D}=by();(0,W.useEffect)(()=>{g&&!v&&(x(JSON.stringify(g,null,4)),C(null),T([]))},[g,v]);let O=(0,W.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];Ey(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||Ey(a,void 0,t[r])&&n.push(a)}};g&&r(t,g),T(n)}catch(e){C(e.message),T([])}},[u]),k=(0,W.useCallback)(()=>{Ny().catch(e=>{console.error(`Failed to register the Harper config JSON Schema:`,e)})},[]),A=(0,W.useCallback)(()=>{if(!(S||w.length>0))try{let e=JSON.parse(b),t=ky(Oy(g,e));E(t),y(!1)}catch(e){C(e.message)}},[b,S,E,g,w.length]);return(0,W.useMemo)(()=>[],[o,s]),(0,G.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,G.jsx)(Py,{children:(0,G.jsxs)(`dl`,{className:`grid grid-cols-1 sm:grid-cols-3`,children:[(0,G.jsx)(`div`,{className:`px-4 pb-4 sm:col-span-1 sm:px-0`,children:(0,G.jsx)(_y,{loadingRegistration:l,registrationInfo:c})}),(0,G.jsx)(`div`,{className:`px-4 pb-4 sm:col-span-1 sm:px-0`,children:(0,G.jsx)(vy,{loading:m,timestamp:h})}),(0,G.jsx)(`div`,{className:`px-4 pb-4 text-right sm:col-span-1 sm:px-0`,children:(0,G.jsx)(uy,{targetNoun:`Instance`,instanceClient:i.instanceClient,operation:`restart`})})]})}),(0,G.jsxs)(`div`,{className:`flex-none flex items-center justify-between mb-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h3`,{className:`font-bold text-sm/6`,children:[`Instance Config `,v?`(editing)`:`(read only)`]}),!t&&!1]}),(0,G.jsx)(`div`,{className:`flex items-center gap-2 pr-4`,children:v?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(P,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>y(!1),children:[(0,G.jsx)(gn,{className:`w-4 h-4 mr-1`}),` Cancel`]}),(0,G.jsxs)(P,{size:`sm`,disabled:!!S||w.length>0||D,onClick:A,children:[(0,G.jsx)(Xr,{className:`w-4 h-4 mr-1`}),` `,D?`Saving...`:`Save & Restart`]})]}):(0,G.jsxs)(P,{size:`sm`,onClick:()=>y(!0),children:[(0,G.jsx)(ii,{className:`w-4 h-4 mr-1`}),` Edit`]})})]}),S&&(0,G.jsxs)(fy,{variant:`destructive`,className:`mb-4`,children:[(0,G.jsx)(Xn,{className:`h-4 w-4`}),(0,G.jsx)(py,{children:`Invalid JSON`}),(0,G.jsx)(my,{children:S})]}),w.length>0&&(0,G.jsxs)(fy,{variant:`destructive`,className:`mb-4`,children:[(0,G.jsx)(Xn,{className:`h-4 w-4`}),(0,G.jsx)(py,{children:`Restricted Configuration`}),(0,G.jsxs)(my,{children:[`The following fields cannot be modified via Studio:`,(0,G.jsx)(`ul`,{className:`list-disc ml-4 mt-2`,children:w.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsx)(`code`,{children:e})},e))})]})]}),(0,G.jsx)(`div`,{className:`grow`,children:d?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Kf,{className:`w-full`}),(0,G.jsx)(Kf,{className:`w-full`}),(0,G.jsx)(Kf,{className:`w-1/2`})]}):(0,G.jsx)(km,{className:`w-full min-h-full h-96`,path:jy,language:`json`,theme:_,onMount:k,options:{readOnly:!v,scrollBeyondLastLine:!1},value:v?b:JSON.stringify(g,null,4),onChange:O})})]})}function Iy(){let e=K(),{data:t}=V(Bv(e));return t===void 0?void 0:Tl(t.version)}var Ly=(0,W.createContext)(void 0);function Ry({children:e}){return(0,G.jsx)(Ly,{value:Iy(),children:e})}var zy=lm(),By=[{header:`Role`,accessorKey:`role`,enableSorting:!1},zy.display({header:`ID`,id:`id`,enableSorting:!1,cell:e=>(0,G.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,title:e.row.original.id,children:e.row.original.id})}),zy.display({header:`Created`,enableSorting:!1,id:`__createdtime__`,cell:e=>pm((Date.now()-e.row.original.__createdtime__)/1e3,e.row.original.__createdtime__)}),zy.display({header:`Updated`,id:`__updatedtime__`,enableSorting:!1,cell:e=>pm((Date.now()-e.row.original.__updatedtime__)/1e3,e.row.original.__updatedtime__)}),zy.display({header:`Super User`,id:`super_user`,enableSorting:!1,cell:e=>e.row.original.permission.super_user?`Yes`:`No`}),zy.display({header:`Structure User`,id:`structure_user`,enableSorting:!1,cell:e=>e.row.original.permission.structure_user?`Yes`:`No`}),zy.display({header:`Operations`,id:`operations`,enableSorting:!1,cell:e=>(0,G.jsx)(Vy,{permission:e.row.original.permission})})];function Vy({permission:e}){let t=(0,W.useContext)(Ly);if(t===void 0)return null;let n=Ll(e,t);if(n===`absent`||n===`database`||n===`inert`)return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{"aria-hidden":!0,children:`—`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`No operation restriction`})]});if(n===`breaks-auth`)return(0,G.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,G.jsx)(`span`,{className:`text-destructive`,title:`Not a list of operation names`,children:`invalid`});if(Nl(e))return(0,G.jsx)(`span`,{className:`text-destructive`,title:`Harper rejects an allowlist on a super_user or cluster_user role`,children:`conflicts with role`});let r=Ol(Il(e)??[]),i=kl(r);return(0,G.jsxs)(`span`,{title:i,children:[r.length,` allowed`,(0,G.jsxs)(`span`,{className:`sr-only`,children:[`: `,i]})]})}async function Hy(e){let{role:t,super_user:n,structure_user:r,instanceClient:i}=e,{data:a}=await i.post(`/`,{operation:`add_role`,role:t,permission:{super_user:n,structure_user:r}});return a}function Uy(){return L({mutationFn:Hy})}var Wy=S({role:A().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.`}),super_user:D(),structure_user:D()});function Gy({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let r=Pt({resolver:Ke(Wy),defaultValues:{role:``,super_user:!1,structure_user:!1}}),i=K(),{mutate:a,isPending:o}=Uy(),s=(0,W.useCallback)(async e=>{e&&a({role:e.role,super_user:e.super_user,structure_user:e.structure_user,...i},{onSuccess:e=>{r.reset(),t(e.id),H.success(`Role added successfully!`),n(!1)}})},[a,r,i,t,n]),c=(0,W.useCallback)(()=>{r.reset(),n(!1)},[r,n]);return(0,G.jsx)(fn,{onOpenChange:n,open:e,children:(0,G.jsx)(cn,{"aria-describedby":void 0,children:(0,G.jsx)(q,{...r,children:(0,G.jsxs)(`form`,{id:`instance-add-role-form`,name:`instance-add-role-form`,onSubmit:r.handleSubmit(s),className:`grid gap-4 my-4 md:grid-cols-2`,children:[(0,G.jsxs)(rn,{className:`md:col-span-2`,children:[(0,G.jsx)(ln,{children:`Add New Role`}),(0,G.jsx)(un,{children:`After adding the role, you will be able to edit the per-table permissions.`})]}),(0,G.jsx)(Y,{control:r.control,name:`role`,render:({field:e})=>(0,G.jsxs)(X,{className:`md:col-span-2`,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:r.control,name:`super_user`,render:({field:e})=>(0,G.jsxs)(X,{className:`flex`,children:[(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`checkbox`,className:`w-6`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,G.jsx)(Z,{className:`pl-4 pr-8 flex-1 py-2.5`,children:`Super User`}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:r.control,name:`structure_user`,render:({field:e})=>(0,G.jsxs)(X,{className:`flex`,children:[(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`checkbox`,className:`w-6`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,G.jsx)(Z,{className:`pl-4 pr-8 flex-1 py-2.5`,children:`Structure User`}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(on,{className:`md:col-span-2`,children:(0,G.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,G.jsx)(P,{variant:`destructiveOutline`,type:`button`,onClick:c,disabled:o,children:`Cancel`}),(0,G.jsxs)(P,{type:`submit`,variant:`submit`,disabled:o,children:[(0,G.jsx)(Xr,{}),` Add Role`]})]})})]})})})})}function Ky({entityId:e,instanceClient:t}){return R({queryKey:[e,`list_roles`],queryFn:()=>qy({instanceClient:t}),refetchInterval:ns(1e4),retry:rs()})}async function qy({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_roles`});return t}function Jy({instanceDatabaseMap:e,currentRolePermissions:t,version:n,showAttributes:r}){let i={...t};if(t.super_user||t.structure_user||t.cluster_user)return t;let[a,o,s]=n.split(`.`).map(e=>parseInt(e,10)),c=n!==`2.0.000`&&a<=2&&o<=1&&s<=2,l=(e,t)=>(Object.defineProperty(i,e,{value:t,writable:!0,enumerable:!0,configurable:!0}),t),u=Tl(n);for(let n in e){if(jl.has(n)&&(n!==`operations`||u))continue;let i=l(n,{tables:{}}),a=t&&Ml(t,n,u);for(let t in e[n]){let o=e[n][t].attributes.map(e=>e.attribute).sort(),s=a&&a.tables?.[t];c?i.tables[t]=Yy(s,o,r):i.tables[t]=Xy(s,o,r)}}return i}function Yy(e,t,n){let r=e&&id(e.attribute_restrictions,`attribute_name`);return{read:!e||e.read,insert:!e||e.insert,update:!e||e.update,delete:!e||e.delete,attribute_restrictions:t.filter(()=>n).map(t=>{let n=r?.[t];return{attribute_name:t,read:n?n.read:!e||e.read,insert:n?n.insert:!e||e.insert,update:n?n.update:!e||e.update,delete:n?n.delete:!e||e.delete}})}}function Xy(e,t,n){let r=e&&id(e.attribute_permissions||[],`attribute_name`);return{read:e?e.read:!1,insert:e?e.insert:!1,update:e?e.update:!1,delete:e?e.delete:!1,attribute_permissions:n?t.map(t=>{let n=r?.[t];return{attribute_name:t,read:n?n.read:e?.attribute_permissions?.length?!1:e?.read||!1,insert:n?n.insert:e?.attribute_permissions?.length?!1:e?.insert||!1,update:n?n.update:e?.attribute_permissions?.length?!1:e?.update||!1}}):null}}function Zy({value:e,onChange:t,version:n,allowlistRejected:r,structureUserDdl:i,disabled:a}){let o=e!==void 0,s=Dl(n),c=yl.filter(t=>!s.includes(t)&&e?.includes(t.name)),l=El(n),u=new Set(e??[]),d=(e??[]).filter(e=>!wl(e)),f=e?Ol(e):[],p=f.some(e=>Sl(e)?.su),m=(0,W.useRef)([]),g=e=>{let n=new Set(e),r=yl.map(e=>e.name).filter(e=>n.has(e)),i=[...n].filter(e=>!wl(e)).sort();t([...r,...i])},_=t=>{let n=new Set(e??[]);n.has(t)?n.delete(t):n.add(t),g(n)};return(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border p-3`,children:[(0,G.jsxs)(Ro,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Um,{checked:o,onCheckedChange:n=>{n?t(m.current):(m.current=e??[],t(void 0))},disabled:a,"aria-label":`Restrict operations`}),(0,G.jsx)(`span`,{className:`font-medium`,children:`Restrict operations`})]}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o?`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,G.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&&(0,G.jsxs)(`p`,{className:`text-xs text-warning`,children:[`This role is a structure user, so it reaches`,` `,(0,G.jsx)(`span`,{className:`font-mono`,children:Fl.join(`, `)}),i===!0?` (and create/drop database) on any database regardless of the list below.`:(0,G.jsxs)(G.Fragment,{children:[` `,`on `,(0,G.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,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[s.map(e=>(0,G.jsx)(Qy,{group:e,checked:u.has(e.name),onToggle:_,disabled:a},e.name)),c.map(e=>(0,G.jsx)(Qy,{group:e,note:`Saved on this role, but not offered for this instance's Harper version.`,checked:!0,onToggle:_,disabled:a},e.name))]}),(0,G.jsx)(eb,{grantable:l,selectedSet:u,onToggle:_,disabled:a}),d.length>0&&(0,G.jsx)(`div`,{className:`flex max-h-24 flex-wrap gap-1 overflow-y-auto`,children:d.map(e=>(0,G.jsx)(tb,{name:e,onRemove:()=>_(e),disabled:a},e))}),f.length===0?(0,G.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`,i?`, except the DDL noted above`:``,` `,`(SQL is gated by table permissions, not this list).`]}):(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground`,title:kl(f),children:[`Effectively allows `,h(f.length,`operation`,`operations`),p?`, including some that normally require super_user`:``,`.`,(0,G.jsxs)(`span`,{className:`sr-only`,children:[`: `,kl(f)]})]})]})]})}function Qy({group:e,note:t,checked:n,onToggle:r,disabled:i}){return(0,G.jsxs)(Ro,{className:`flex items-start gap-2 font-normal`,children:[(0,G.jsx)($,{type:`checkbox`,className:`mt-0.5 size-4`,checked:n,onChange:()=>r(e.name),disabled:i}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,G.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:t??e.description})]})]})}var $y=/^[A-Za-z][A-Za-z0-9_.:-]*$/;function eb({grantable:e,selectedSet:t,onToggle:n,disabled:r}){let[i,a]=(0,W.useState)(!1),[o,s]=(0,W.useState)(``),c=(0,W.useRef)(null),l=(0,W.useRef)(null);(0,W.useEffect)(()=>{if(!i)return;let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>c.current?.focus())});return()=>{cancelAnimationFrame(t),cancelAnimationFrame(e)}},[i]);let u=o.trim(),d=u.toLowerCase(),f=d?e.filter(e=>e.name.includes(d)):e,p=rd(f,`category`),m=Sl(u),h=!m&&(wl(d)||_l.some(e=>e.name===d)),g=$y.test(u)&&!wl(u)&&!h&&!m?.nonDelegable&&!m?.aliasOf&&!e.some(e=>e.name===u)&&!t.has(u)?u:void 0;return(0,G.jsxs)(wi,{open:i,onOpenChange:e=>{a(e),e||s(``)},children:[(0,G.jsx)(Ti,{asChild:!0,disabled:r,children:(0,G.jsxs)(P,{type:`button`,variant:`outline`,className:`w-full justify-between font-normal`,children:[(0,G.jsx)(`span`,{className:`truncate text-muted-foreground`,children:`Add operations…`}),(0,G.jsx)(pn,{className:`size-4 shrink-0 opacity-60`})]})}),(0,G.jsxs)(Ei,{ref:l,className:`w-(--radix-dropdown-menu-trigger-width) max-h-72 overflow-y-auto`,align:`start`,children:[(0,G.jsx)(`input`,{ref:c,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=l.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`}),gl.filter(e=>p[e]).map(e=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(ki,{className:`text-xs text-muted-foreground`,children:e}),p[e].map(e=>(0,G.jsxs)(Oi,{checked:t.has(e.name),onCheckedChange:()=>n(e.name),onSelect:e=>e.preventDefault(),children:[(0,G.jsx)(`span`,{className:`flex-1 truncate font-mono text-xs`,children:e.name}),el(e.name)?(0,G.jsx)(Ji,{variant:`outline`,title:`Harper authorizes this operation under its internal handler name, so listing it has no effect on current 5.x releases (HarperFast/harper#2175). Kept available so the role is ready once that lands.`,children:`not yet enforced`}):e.su&&(0,G.jsx)(Ji,{variant:`warning`,title:`Normally requires super_user; listing it grants it to this role`,children:`super_user`})]},e.name))]},e)),g&&(0,G.jsxs)(Oi,{checked:!1,onCheckedChange:()=>n(g),onSelect:e=>e.preventDefault(),children:[(0,G.jsx)(Gr,{className:`size-3`}),(0,G.jsxs)(`span`,{className:`flex-1 truncate text-xs`,children:[`Grant "`,(0,G.jsx)(`span`,{className:`font-mono`,children:g}),`" `,m?`(listed for newer Harper versions — this instance may reject it)`:`(component-registered operation)`]})]}),f.length===0&&!g&&(0,G.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-muted-foreground`,children:`No matching operations`})]})]})}function tb({name:e,onRemove:t,disabled:n}){let r=Sl(e),i=tl(e)?`destructive`:r?.su?`warning`:r?`secondary`:`outline`,a=r?.aliasOf?`Legacy alias: Harper authorizes this operation under '${r.aliasOf}', so this entry grants nothing. Grant '${r.aliasOf}' instead.`:el(e)?`Harper authorizes this operation under its internal handler name, so this grant has no effect on current 5.x releases (HarperFast/harper#2175).`:r?.nonDelegable?`Always requires an actual super_user role; listing it cannot delegate the operation to a non-super_user role.`:r?.outOfGate||r?.caveat?r.caveat:r?.su?`Normally requires super_user; listing it grants it to this role.`:r?void 0:`Not in the built-in catalog — kept as-is (for example a component-registered operation).`;return(0,G.jsxs)(Ji,{variant:i,title:a,className:`gap-1 font-mono text-xs`,children:[e,!n&&(0,G.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e}`,onClick:t,className:`ml-0.5 rounded-sm hover:text-destructive`,children:(0,G.jsx)(gn,{className:`size-3`})})]})}function nb({kind:e,assigning:t,databaseCollision:n}){return e===`malformed`?(0,G.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`This role's `,(0,G.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,G.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`This role's `,(0,G.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,G.jsxs)(G.Fragment,{children:[`authentication breaks for every user on the instance as soon as a user holds this role. Remove the`,` `,(0,G.jsx)(`span`,{className:`font-mono`,children:`operations`}),` `,`key in the JSON below — that alone restores authentication.`,n&&(0,G.jsxs)(G.Fragment,{children:[` `,`Separately, and only if this instance needs allowlists at all: a database named`,` `,(0,G.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.`]})]})]})}function rb(e){if(e.super_user!==!0&&e.structure_user!==!0&&e.cluster_user!==!0)return e;let t=Nl(e),n={...e};for(let e in n)(!jl.has(e)||e===`operations`&&(t||!Array.isArray(n.operations))||n[e]===!1)&&delete n[e];return n}async function ib({id:e,permission:t,instanceClient:n}){let{data:r}=await n.post(`/`,{operation:`alter_role`,id:e,permission:t});return r}function ab(){return L({mutationFn:ib})}async function ob({id:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_role`,id:e});return n}function sb(){return L({mutationFn:ob})}async function cb({instanceClient:e,skipRecordCount:t}){let{data:n}=await e.post(`/`,{operation:`describe_all`,skip_record_count:t||void 0,exact_count:!t&&void 0});return n}function lb(e){return R({queryKey:[e.entityId,`describe_all`,!!e.skipRecordCount],queryFn:()=>cb(e),staleTime:6e4,gcTime:5e3,retry:!1})}function ub(e){try{return JSON.parse(e)}catch{return null}}function db({data:e,instanceId:t,clusterId:n,isModalOpen:r,closeModal:i,onSelectRole:a,onChangesSaved:o}){let s=Dm(),{role:c,permission:l}=e,[u,d]=(0,W.useState)(JSON.stringify(l,null,2)),f=K(),[p,m]=(0,W.useState)(!0),{data:h}=V(lb({...f,skipRecordCount:!0})),{data:g}=V(Bv(f)),_=Dn(t??n).user?.role?.id===e.id,[v,y]=sh(u?.includes(`attribute_name`)),{mutate:b,isPending:x}=ab(),{mutate:S,isPending:C}=sb(),[w,T]=(0,W.useState)(!1),E=(0,W.useCallback)(e=>{m(e.length===0)},[m]),D=(0,W.useMemo)(()=>JSON.stringify(h&&g&&Rl(Jy({instanceDatabaseMap:h,currentRolePermissions:u&&Ue(u)||l,version:g.version,showAttributes:v})),null,2),[l,h,g,v]);(0,W.useEffect)(()=>{d(D)},[D]);let O=Tl(g?.version),k=(0,W.useRef)(null),{operationsRaw:A,operationsJson:j,operationsKind:ee,allowlistRejected:M,structureUserDdl:N}=(0,W.useMemo)(()=>{let e=O&&u?ub(u):null,t=p&&typeof e==`object`&&e&&!Array.isArray(e)?e:k.current;if(t===null)return{operationsRaw:void 0,operationsJson:void 0,operationsKind:`absent`,allowlistRejected:!1,structureUserDdl:!1};k.current=t;let n=Il(t);return{operationsRaw:t.operations,operationsJson:n&&JSON.stringify(n),operationsKind:Ll(t,O),allowlistRejected:Nl(t),structureUserDdl:Pl(t)}},[O,p,u]),te=(0,W.useMemo)(()=>j===void 0?void 0:JSON.parse(j),[j]),ne=(0,W.useCallback)(e=>{d(t=>{let n=t?Ue(t):null;return!n||typeof n!=`object`||Array.isArray(n)?t:JSON.stringify(zl(n,e),null,2)})},[]),re=(0,W.useCallback)(t=>{let n=Ue(t);if(n&&typeof n==`object`&&!Array.isArray(n)){let t=rb(n);b({id:e.id,permission:t,...f},{onSuccess:()=>{H.success(`Role updated successfully!`),a(void 0),o()}})}},[b,e.id,f,o,a]),ie=(0,W.useCallback)(()=>{S({id:e.id,...f},{onSuccess:()=>{H.success(`Role deleted successfully!`),a(void 0),o()}})},[e.id,S,f,o,a]),ae=ee===`breaks-auth`||ee===`malformed`,oe=typeof A==`object`&&!!A&&!Array.isArray(A),se=(0,W.useCallback)(()=>{u&&p&&re(u)},[u,re,p]),F=(0,W.useCallback)(()=>{T(!0)},[]);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(fn,{onOpenChange:i,open:r,children:(0,G.jsxs)(cn,{resizable:!0,children:[(0,G.jsxs)(ln,{children:[_?`View`:`Edit`,` Role "`,c,`"`]}),(0,G.jsx)(un,{children:_?`You can view your own role, but you cannot edit it. Please assign yourself a different role to edit this role.`:`Edit the role's permissions in JSON format or remove the role entirely.`}),O&&g&&(ae?(0,G.jsx)(nb,{kind:ee,databaseCollision:oe}):(0,G.jsx)(Zy,{allowlistRejected:M,structureUserDdl:N,value:te,onChange:ne,version:g.version,disabled:_||!p})),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:D?(0,G.jsx)(km,{className:`w-full h-full`,theme:s,defaultLanguage:`json`,value:u,options:{readOnly:_,automaticLayout:!0},onValidate:E,onChange:d,defaultValue:D}):(0,G.jsx)(Kf,{})}),(0,G.jsx)(on,{children:!_&&(0,G.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,G.jsx)(P,{type:`button`,variant:`destructiveOutline`,onClick:F,disabled:x,children:`Delete Role`}),(0,G.jsx)(`div`,{className:`grow`}),(0,G.jsxs)(Ro,{className:`flex`,children:[(0,G.jsx)($,{type:`checkbox`,className:`w-6`,checked:v,onChange:y}),(0,G.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:`Pick Attributes`})]}),(0,G.jsx)(P,{variant:`submit`,onClick:se,disabled:x||!p||ae,children:`Save Changes`})]})})]})}),(0,G.jsx)(Ic,{isModalOpen:w,setIsModalOpen:T,deletionConfirmed:ie,deletionPending:C,typeOfThingBeingDeleted:`role`,nameOfThingBeingDeleted:c,hideDataLossWarning:!0})]})}function fb(){let e=I(),{clusterId:t,instanceId:n,roleId:r}=z({strict:!1}),i=K(),{data:a,refetch:o,isFetching:s,isRefetching:c}=_e(Ky(i)),l=(0,W.useMemo)(()=>a?.find(e=>e.id===r),[a,r]),u=(0,W.useCallback)(t=>{let n=[r?`..`:``,t].filter(Boolean);e({to:n.join(`/`)})},[r,e]),d=!!r&&!!l,[f,p]=(0,W.useState)(!1),m=(0,W.useCallback)(()=>{p(!0)},[p]),h=(0,W.useCallback)(e=>{o(),p(!1),u(e)},[u,o]),g=(0,W.useCallback)(e=>{u(e.original.id)},[u]),_=(0,W.useCallback)(()=>{u(void 0)},[u]),v=hm(o);return(0,G.jsxs)(W.Suspense,{fallback:(0,G.jsx)(Wi,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,G.jsx)(Ry,{children:(0,G.jsxs)(um,{columns:By,data:a,isFetching:s,onRowClick:g,children:[(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:v,accessKey:`r`,disabled:s||c,children:[(0,G.jsx)(Kr,{}),(0,G.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,G.jsx)(`u`,{children:`R`}),`efresh`]})]}),(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:f,children:[(0,G.jsx)(Gr,{}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`A`}),`dd`]})]})]})}),(0,G.jsx)(Gy,{isModalOpen:f,onChangesSaved:h,setIsModalOpen:p}),d&&(0,G.jsx)(db,{instanceId:n,clusterId:t,isModalOpen:d,closeModal:_,data:l,onSelectRole:u,onChangesSaved:()=>o()})]})}function pb(e){return!!e?.entries}function mb(e){if(!e?.entries)return[];let t=new Set;for(let n of e.entries)pb(n)&&t.add(n.name);return[...t].sort((e,t)=>e.localeCompare(t))}function hb({components:e,granted:t,onAdd:n,disabled:r,actionLabel:i=`Add`,commitOnBlur:a=!1}){let[o,s]=(0,W.useState)(``),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(0),[f,p]=(0,W.useState)(!1),m=(0,W.useId)(),h=(0,W.useId)(),g=(0,W.useRef)(!1),_=(0,W.useRef)(!1),v=r||f,y=(0,W.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,W.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,W.useCallback)(()=>{x(y[b]?.value??o)},[x,y,b,o]),C=(0,W.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,W.useCallback)(()=>{g.current||(l(!1),a&&o.trim()&&S())},[a,o,S]),T=c&&y.length>0;return(0,G.jsxs)(`div`,{className:`relative grid gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.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,G.jsxs)(P,{type:`button`,variant:`positiveOutline`,onMouseDown:e=>e.preventDefault(),onClick:S,disabled:v||!o.trim(),children:[(0,G.jsx)(Gr,{}),` `,i]})]}),T&&(0,G.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,G.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:N(`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,G.jsxs)(`span`,{className:`truncate`,children:[`Use “`,(0,G.jsx)(`span`,{className:`font-mono`,children:e.value}),`” — not a deployed application`]}):(0,G.jsx)(`span`,{className:`truncate font-mono`,children:e.value})},e.custom?`__custom__${e.value}`:e.value)})})]})}var gb=`enc:v1:`;function _b(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 vb(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function yb(e){return vb(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function bb(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function xb(){if(typeof crypto>`u`||!crypto.subtle)throw Error(`Secret encryption requires a secure context (HTTPS or localhost).`);return crypto.subtle}async function Sb(e,t,n){let r=xb(),i=_b(t),a=await r.importKey(`spki`,bb(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`,bb(o),{name:`AES-GCM`},!1,[`encrypt`]),l=new Uint8Array(await r.encrypt({name:`AES-GCM`,iv:bb(s),tagLength:128},c,bb(new TextEncoder().encode(e)))),u=l.slice(0,l.length-16),d=l.slice(l.length-16),f={kid:n,k:vb(new Uint8Array(await r.encrypt({name:`RSA-OAEP`},a,bb(o)))),iv:vb(s),ct:vb(u),tag:vb(d)};return gb+yb(new TextEncoder().encode(JSON.stringify(f)))}function Cb(e){let t=e?.response?.data;return t?.error??t?.message??String(e)}var wb=`does not match`;function Tb(e){return e.includes(wb)}async function Eb({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`get_secrets_public_key`});return{publicKey:t.public_key,fingerprint:t.fingerprint}}var Db=M;async function Ob(e){let{data:t}=await Db.post(`/ClusterSecrets`,{operation:`get_secrets_public_key`,clusterId:e});return{publicKey:t.publicKey,fingerprint:t.fingerprint}}function kb(e){return R({queryKey:[e.entityId,`get_secrets_public_key`,e.managedClusterId??`node`],queryFn:()=>e.managedClusterId?Ob(e.managedClusterId):Eb(e),staleTime:3e5,retry:!1})}async function Ab({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_secrets`});return t}function jb(e){return R({queryKey:[e.entityId,`list_secrets`],queryFn:()=>Ab(e)})}async function Mb(e,t,n){let{publicKey:r,fingerprint:i}=await e.ensureQueryData(kb(t)),a=await Sb(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=Cb(r);if(!n&&Tb(i))return e.removeQueries({queryKey:kb(t).queryKey}),Mb(e,t,!0);throw Error(i)}}function Nb(){let e=Ie();return L({mutationFn:t=>Mb(e,t,!1)})}async function Pb({instanceClient:e,name:t}){try{let{data:n}=await e.post(`/`,{operation:`delete_secret`,name:t});return n}catch(e){throw Error(Cb(e))}}function Fb(){return L({mutationFn:Pb})}async function Ib(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 Error(Cb(e))}}function Lb(){return L({mutationFn:e=>Ib(`grant_secret`,e)})}function Rb(){return L({mutationFn:e=>Ib(`revoke_secret`,e)})}function zb({name:e,initialGrants:t,components:n,onChanged:r}){let i=K(),{mutateAsync:a,isPending:o}=Lb(),{mutateAsync:s,isPending:c}=Rb(),l=o||c,[u,d]=(0,W.useState)(t),f=(0,W.useCallback)(async t=>{try{let n=await a({...i,name:e,component:t});d(n.grants),r?.()}catch(e){throw H.error(String(e)),e}},[a,i,e,r]),p=(0,W.useCallback)(async t=>{try{let n=await s({...i,name:e,component:t});d(n.grants),r?.()}catch(e){H.error(String(e))}},[s,i,e,r]);return(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`Granted applications`}),(0,G.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Only granted applications can read this secret through the `,(0,G.jsx)(`code`,{className:`font-mono`,children:`secrets`}),` `,`accessor. Changes apply immediately.`]}),u.length>0&&(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:u.map(e=>(0,G.jsxs)(Ji,{variant:`secondary`,children:[e,(0,G.jsxs)(`button`,{type:`button`,onClick:()=>void p(e),disabled:l,title:`Revoke ${e}`,className:`cursor-pointer disabled:cursor-default`,children:[(0,G.jsx)(gn,{}),(0,G.jsxs)(`span`,{className:`sr-only`,children:[`Revoke `,e]})]})]},e))}),(0,G.jsx)(hb,{components:n,granted:u,onAdd:f,disabled:l,actionLabel:`Grant`})]})}var Bb=`********`,Vb=/^[\w.-]+$/,Hb=/^(\s*(?:export\s+)?)([\w.-]+)\s*=(.*)$/;function Ub(e){return e.split(`/`).pop()??``}function Wb(e){if(!e)return!1;let t=Ub(e).toLowerCase();return t===`.env`||t.startsWith(`.env.`)}var Gb=[`.example`,`.sample`,`.template`];function Kb(e){if(!Wb(e))return!1;let t=Ub(e).toLowerCase();return Gb.some(e=>t.endsWith(e))}function qb(e){return Wb(e)&&!Kb(e)}function Jb(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,`
670
+ `),jy=`inmemory://harper/config-root.json`,My=`harper://schemas/config-root.json`;async function Ny(){let{json:e}=await ne(async()=>{let{json:e}=await import(`./languageServices-IKH4GUHl.js`).then(e=>e.t);return{json:e}},__vite__mapDeps([33,1,20,4,21])),t=e.jsonDefaults,{schemas:n=[],...r}=t.diagnosticsOptions;n.some(e=>e.uri===My)||t.setDiagnosticsOptions({...r,validate:!0,enableSchemaRequest:!1,schemas:[...n,{uri:My,fileMatch:[jy],schema:Ay}]})}var Py=({children:e})=>(0,G.jsx)(G.Fragment,{children:e});function Fy(){let{clusterId:e,instanceId:t}=z({strict:!1}),{data:n,isLoading:r}=V(gy({clusterId:e,instanceId:t})),i=K(),{version:a}=oe({strict:!1}),{data:o}=V(wy(i,!1));n?.cluster;let s=n?.instance,{data:c,isLoading:l}=V(Bv(i)),{data:u,isLoading:d}=V(Cy(i)),f=_u(),{data:p,isLoading:m}=V(Sy({...i,enabled:f})),h=(0,W.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,W.useMemo)(()=>u?Dy(u):null,[u]),_=Dm(),[v,y]=(0,W.useState)(!1),[b,x]=(0,W.useState)(``),[S,C]=(0,W.useState)(null),[w,T]=(0,W.useState)([]),{onConfigUpdate:E,isPending:D}=by();(0,W.useEffect)(()=>{g&&!v&&(x(JSON.stringify(g,null,4)),C(null),T([]))},[g,v]);let O=(0,W.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];Ey(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||Ey(a,void 0,t[r])&&n.push(a)}};g&&r(t,g),T(n)}catch(e){C(e.message),T([])}},[u]),k=(0,W.useCallback)(()=>{Ny().catch(e=>{console.error(`Failed to register the Harper config JSON Schema:`,e)})},[]),A=(0,W.useCallback)(()=>{if(!(S||w.length>0))try{let e=JSON.parse(b),t=ky(Oy(g,e));E(t),y(!1)}catch(e){C(e.message)}},[b,S,E,g,w.length]);return(0,W.useMemo)(()=>[],[o,s]),(0,G.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,G.jsx)(Py,{children:(0,G.jsxs)(`dl`,{className:`grid grid-cols-1 sm:grid-cols-3`,children:[(0,G.jsx)(`div`,{className:`px-4 pb-4 sm:col-span-1 sm:px-0`,children:(0,G.jsx)(_y,{loadingRegistration:l,registrationInfo:c})}),(0,G.jsx)(`div`,{className:`px-4 pb-4 sm:col-span-1 sm:px-0`,children:(0,G.jsx)(vy,{loading:m,timestamp:h})}),(0,G.jsx)(`div`,{className:`px-4 pb-4 text-right sm:col-span-1 sm:px-0`,children:(0,G.jsx)(uy,{targetNoun:`Instance`,instanceClient:i.instanceClient,operation:`restart`})})]})}),(0,G.jsxs)(`div`,{className:`flex-none flex items-center justify-between mb-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h3`,{className:`font-bold text-sm/6`,children:[`Instance Config `,v?`(editing)`:`(read only)`]}),!t&&!1]}),(0,G.jsx)(`div`,{className:`flex items-center gap-2 pr-4`,children:v?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(P,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>y(!1),children:[(0,G.jsx)(gn,{className:`w-4 h-4 mr-1`}),` Cancel`]}),(0,G.jsxs)(P,{size:`sm`,disabled:!!S||w.length>0||D,onClick:A,children:[(0,G.jsx)(Xr,{className:`w-4 h-4 mr-1`}),` `,D?`Saving...`:`Save & Restart`]})]}):(0,G.jsxs)(P,{size:`sm`,onClick:()=>y(!0),children:[(0,G.jsx)(ii,{className:`w-4 h-4 mr-1`}),` Edit`]})})]}),S&&(0,G.jsxs)(fy,{variant:`destructive`,className:`mb-4`,children:[(0,G.jsx)(Xn,{className:`h-4 w-4`}),(0,G.jsx)(py,{children:`Invalid JSON`}),(0,G.jsx)(my,{children:S})]}),w.length>0&&(0,G.jsxs)(fy,{variant:`destructive`,className:`mb-4`,children:[(0,G.jsx)(Xn,{className:`h-4 w-4`}),(0,G.jsx)(py,{children:`Restricted Configuration`}),(0,G.jsxs)(my,{children:[`The following fields cannot be modified via Studio:`,(0,G.jsx)(`ul`,{className:`list-disc ml-4 mt-2`,children:w.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsx)(`code`,{children:e})},e))})]})]}),(0,G.jsx)(`div`,{className:`grow`,children:d?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Kf,{className:`w-full`}),(0,G.jsx)(Kf,{className:`w-full`}),(0,G.jsx)(Kf,{className:`w-1/2`})]}):(0,G.jsx)(km,{className:`w-full min-h-full h-96`,path:jy,language:`json`,theme:_,onMount:k,options:{readOnly:!v,scrollBeyondLastLine:!1},value:v?b:JSON.stringify(g,null,4),onChange:O})})]})}function Iy(){let e=K(),{data:t}=V(Bv(e));return t===void 0?void 0:Tl(t.version)}var Ly=(0,W.createContext)(void 0);function Ry({children:e}){return(0,G.jsx)(Ly,{value:Iy(),children:e})}var zy=lm(),By=[{header:`Role`,accessorKey:`role`,enableSorting:!1},zy.display({header:`ID`,id:`id`,enableSorting:!1,cell:e=>(0,G.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,title:e.row.original.id,children:e.row.original.id})}),zy.display({header:`Created`,enableSorting:!1,id:`__createdtime__`,cell:e=>pm((Date.now()-e.row.original.__createdtime__)/1e3,e.row.original.__createdtime__)}),zy.display({header:`Updated`,id:`__updatedtime__`,enableSorting:!1,cell:e=>pm((Date.now()-e.row.original.__updatedtime__)/1e3,e.row.original.__updatedtime__)}),zy.display({header:`Super User`,id:`super_user`,enableSorting:!1,cell:e=>e.row.original.permission.super_user?`Yes`:`No`}),zy.display({header:`Structure User`,id:`structure_user`,enableSorting:!1,cell:e=>e.row.original.permission.structure_user?`Yes`:`No`}),zy.display({header:`Operations`,id:`operations`,enableSorting:!1,cell:e=>(0,G.jsx)(Vy,{permission:e.row.original.permission})})];function Vy({permission:e}){let t=(0,W.useContext)(Ly);if(t===void 0)return null;let n=Ll(e,t);if(n===`absent`||n===`database`||n===`inert`)return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{"aria-hidden":!0,children:`—`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`No operation restriction`})]});if(n===`breaks-auth`)return(0,G.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,G.jsx)(`span`,{className:`text-destructive`,title:`Not a list of operation names`,children:`invalid`});if(Nl(e))return(0,G.jsx)(`span`,{className:`text-destructive`,title:`Harper rejects an allowlist on a super_user or cluster_user role`,children:`conflicts with role`});let r=Ol(Il(e)??[]),i=kl(r);return(0,G.jsxs)(`span`,{title:i,children:[r.length,` allowed`,(0,G.jsxs)(`span`,{className:`sr-only`,children:[`: `,i]})]})}async function Hy(e){let{role:t,super_user:n,structure_user:r,instanceClient:i}=e,{data:a}=await i.post(`/`,{operation:`add_role`,role:t,permission:{super_user:n,structure_user:r}});return a}function Uy(){return L({mutationFn:Hy})}var Wy=S({role:A().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.`}),super_user:D(),structure_user:D()});function Gy({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let r=Pt({resolver:Ke(Wy),defaultValues:{role:``,super_user:!1,structure_user:!1}}),i=K(),{mutate:a,isPending:o}=Uy(),s=(0,W.useCallback)(async e=>{e&&a({role:e.role,super_user:e.super_user,structure_user:e.structure_user,...i},{onSuccess:e=>{r.reset(),t(e.id),H.success(`Role added successfully!`),n(!1)}})},[a,r,i,t,n]),c=(0,W.useCallback)(()=>{r.reset(),n(!1)},[r,n]);return(0,G.jsx)(fn,{onOpenChange:n,open:e,children:(0,G.jsx)(cn,{"aria-describedby":void 0,children:(0,G.jsx)(q,{...r,children:(0,G.jsxs)(`form`,{id:`instance-add-role-form`,name:`instance-add-role-form`,onSubmit:r.handleSubmit(s),className:`grid gap-4 my-4 md:grid-cols-2`,children:[(0,G.jsxs)(rn,{className:`md:col-span-2`,children:[(0,G.jsx)(ln,{children:`Add New Role`}),(0,G.jsx)(un,{children:`After adding the role, you will be able to edit the per-table permissions.`})]}),(0,G.jsx)(Y,{control:r.control,name:`role`,render:({field:e})=>(0,G.jsxs)(X,{className:`md:col-span-2`,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:r.control,name:`super_user`,render:({field:e})=>(0,G.jsxs)(X,{className:`flex`,children:[(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`checkbox`,className:`w-6`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,G.jsx)(Z,{className:`pl-4 pr-8 flex-1 py-2.5`,children:`Super User`}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:r.control,name:`structure_user`,render:({field:e})=>(0,G.jsxs)(X,{className:`flex`,children:[(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`checkbox`,className:`w-6`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,G.jsx)(Z,{className:`pl-4 pr-8 flex-1 py-2.5`,children:`Structure User`}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(on,{className:`md:col-span-2`,children:(0,G.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,G.jsx)(P,{variant:`destructiveOutline`,type:`button`,onClick:c,disabled:o,children:`Cancel`}),(0,G.jsxs)(P,{type:`submit`,variant:`submit`,disabled:o,children:[(0,G.jsx)(Xr,{}),` Add Role`]})]})})]})})})})}function Ky({entityId:e,instanceClient:t}){return R({queryKey:[e,`list_roles`],queryFn:()=>qy({instanceClient:t}),refetchInterval:ns(1e4),retry:rs()})}async function qy({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_roles`});return t}function Jy({instanceDatabaseMap:e,currentRolePermissions:t,version:n,showAttributes:r}){let i={...t};if(t.super_user||t.structure_user||t.cluster_user)return t;let[a,o,s]=n.split(`.`).map(e=>parseInt(e,10)),c=n!==`2.0.000`&&a<=2&&o<=1&&s<=2,l=(e,t)=>(Object.defineProperty(i,e,{value:t,writable:!0,enumerable:!0,configurable:!0}),t),u=Tl(n);for(let n in e){if(jl.has(n)&&(n!==`operations`||u))continue;let i=l(n,{tables:{}}),a=t&&Ml(t,n,u);for(let t in e[n]){let o=e[n][t].attributes.map(e=>e.attribute).sort(),s=a&&a.tables?.[t];c?i.tables[t]=Yy(s,o,r):i.tables[t]=Xy(s,o,r)}}return i}function Yy(e,t,n){let r=e&&id(e.attribute_restrictions,`attribute_name`);return{read:!e||e.read,insert:!e||e.insert,update:!e||e.update,delete:!e||e.delete,attribute_restrictions:t.filter(()=>n).map(t=>{let n=r?.[t];return{attribute_name:t,read:n?n.read:!e||e.read,insert:n?n.insert:!e||e.insert,update:n?n.update:!e||e.update,delete:n?n.delete:!e||e.delete}})}}function Xy(e,t,n){let r=e&&id(e.attribute_permissions||[],`attribute_name`);return{read:e?e.read:!1,insert:e?e.insert:!1,update:e?e.update:!1,delete:e?e.delete:!1,attribute_permissions:n?t.map(t=>{let n=r?.[t];return{attribute_name:t,read:n?n.read:e?.attribute_permissions?.length?!1:e?.read||!1,insert:n?n.insert:e?.attribute_permissions?.length?!1:e?.insert||!1,update:n?n.update:e?.attribute_permissions?.length?!1:e?.update||!1}}):null}}function Zy({value:e,onChange:t,version:n,allowlistRejected:r,structureUserDdl:i,disabled:a}){let o=e!==void 0,s=Dl(n),c=yl.filter(t=>!s.includes(t)&&e?.includes(t.name)),l=El(n),u=new Set(e??[]),d=(e??[]).filter(e=>!wl(e)),f=e?Ol(e):[],p=f.some(e=>Sl(e)?.su),m=(0,W.useRef)([]),g=e=>{let n=new Set(e),r=yl.map(e=>e.name).filter(e=>n.has(e)),i=[...n].filter(e=>!wl(e)).sort();t([...r,...i])},_=t=>{let n=new Set(e??[]);n.has(t)?n.delete(t):n.add(t),g(n)};return(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border p-3`,children:[(0,G.jsxs)(Ro,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Um,{checked:o,onCheckedChange:n=>{n?t(m.current):(m.current=e??[],t(void 0))},disabled:a,"aria-label":`Restrict operations`}),(0,G.jsx)(`span`,{className:`font-medium`,children:`Restrict operations`})]}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o?`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,G.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&&(0,G.jsxs)(`p`,{className:`text-xs text-warning`,children:[`This role is a structure user, so it reaches`,` `,(0,G.jsx)(`span`,{className:`font-mono`,children:Fl.join(`, `)}),i===!0?` (and create/drop database) on any database regardless of the list below.`:(0,G.jsxs)(G.Fragment,{children:[` `,`on `,(0,G.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,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[s.map(e=>(0,G.jsx)(Qy,{group:e,checked:u.has(e.name),onToggle:_,disabled:a},e.name)),c.map(e=>(0,G.jsx)(Qy,{group:e,note:`Saved on this role, but not offered for this instance's Harper version.`,checked:!0,onToggle:_,disabled:a},e.name))]}),(0,G.jsx)(eb,{grantable:l,selectedSet:u,onToggle:_,disabled:a}),d.length>0&&(0,G.jsx)(`div`,{className:`flex max-h-24 flex-wrap gap-1 overflow-y-auto`,children:d.map(e=>(0,G.jsx)(tb,{name:e,onRemove:()=>_(e),disabled:a},e))}),f.length===0?(0,G.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`,i?`, except the DDL noted above`:``,` `,`(SQL is gated by table permissions, not this list).`]}):(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground`,title:kl(f),children:[`Effectively allows `,h(f.length,`operation`,`operations`),p?`, including some that normally require super_user`:``,`.`,(0,G.jsxs)(`span`,{className:`sr-only`,children:[`: `,kl(f)]})]})]})]})}function Qy({group:e,note:t,checked:n,onToggle:r,disabled:i}){return(0,G.jsxs)(Ro,{className:`flex items-start gap-2 font-normal`,children:[(0,G.jsx)($,{type:`checkbox`,className:`mt-0.5 size-4`,checked:n,onChange:()=>r(e.name),disabled:i}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,G.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:t??e.description})]})]})}var $y=/^[A-Za-z][A-Za-z0-9_.:-]*$/;function eb({grantable:e,selectedSet:t,onToggle:n,disabled:r}){let[i,a]=(0,W.useState)(!1),[o,s]=(0,W.useState)(``),c=(0,W.useRef)(null),l=(0,W.useRef)(null);(0,W.useEffect)(()=>{if(!i)return;let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>c.current?.focus())});return()=>{cancelAnimationFrame(t),cancelAnimationFrame(e)}},[i]);let u=o.trim(),d=u.toLowerCase(),f=d?e.filter(e=>e.name.includes(d)):e,p=rd(f,`category`),m=Sl(u),h=!m&&(wl(d)||_l.some(e=>e.name===d)),g=$y.test(u)&&!wl(u)&&!h&&!m?.nonDelegable&&!m?.aliasOf&&!e.some(e=>e.name===u)&&!t.has(u)?u:void 0;return(0,G.jsxs)(wi,{open:i,onOpenChange:e=>{a(e),e||s(``)},children:[(0,G.jsx)(Ti,{asChild:!0,disabled:r,children:(0,G.jsxs)(P,{type:`button`,variant:`outline`,className:`w-full justify-between font-normal`,children:[(0,G.jsx)(`span`,{className:`truncate text-muted-foreground`,children:`Add operations…`}),(0,G.jsx)(pn,{className:`size-4 shrink-0 opacity-60`})]})}),(0,G.jsxs)(Ei,{ref:l,className:`w-(--radix-dropdown-menu-trigger-width) max-h-72 overflow-y-auto`,align:`start`,children:[(0,G.jsx)(`input`,{ref:c,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=l.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`}),gl.filter(e=>p[e]).map(e=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(ki,{className:`text-xs text-muted-foreground`,children:e}),p[e].map(e=>(0,G.jsxs)(Oi,{checked:t.has(e.name),onCheckedChange:()=>n(e.name),onSelect:e=>e.preventDefault(),children:[(0,G.jsx)(`span`,{className:`flex-1 truncate font-mono text-xs`,children:e.name}),el(e.name)?(0,G.jsx)(Ji,{variant:`outline`,title:`Harper authorizes this operation under its internal handler name, so listing it has no effect on current 5.x releases (HarperFast/harper#2175). Kept available so the role is ready once that lands.`,children:`not yet enforced`}):e.su&&(0,G.jsx)(Ji,{variant:`warning`,title:`Normally requires super_user; listing it grants it to this role`,children:`super_user`})]},e.name))]},e)),g&&(0,G.jsxs)(Oi,{checked:!1,onCheckedChange:()=>n(g),onSelect:e=>e.preventDefault(),children:[(0,G.jsx)(Gr,{className:`size-3`}),(0,G.jsxs)(`span`,{className:`flex-1 truncate text-xs`,children:[`Grant "`,(0,G.jsx)(`span`,{className:`font-mono`,children:g}),`" `,m?`(listed for newer Harper versions — this instance may reject it)`:`(component-registered operation)`]})]}),f.length===0&&!g&&(0,G.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-muted-foreground`,children:`No matching operations`})]})]})}function tb({name:e,onRemove:t,disabled:n}){let r=Sl(e),i=tl(e)?`destructive`:r?.su?`warning`:r?`secondary`:`outline`,a=r?.aliasOf?`Legacy alias: Harper authorizes this operation under '${r.aliasOf}', so this entry grants nothing. Grant '${r.aliasOf}' instead.`:el(e)?`Harper authorizes this operation under its internal handler name, so this grant has no effect on current 5.x releases (HarperFast/harper#2175).`:r?.nonDelegable?`Always requires an actual super_user role; listing it cannot delegate the operation to a non-super_user role.`:r?.outOfGate||r?.caveat?r.caveat:r?.su?`Normally requires super_user; listing it grants it to this role.`:r?void 0:`Not in the built-in catalog — kept as-is (for example a component-registered operation).`;return(0,G.jsxs)(Ji,{variant:i,title:a,className:`gap-1 font-mono text-xs`,children:[e,!n&&(0,G.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e}`,onClick:t,className:`ml-0.5 rounded-sm hover:text-destructive`,children:(0,G.jsx)(gn,{className:`size-3`})})]})}function nb({kind:e,assigning:t,databaseCollision:n}){return e===`malformed`?(0,G.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`This role's `,(0,G.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,G.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`This role's `,(0,G.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,G.jsxs)(G.Fragment,{children:[`authentication breaks for every user on the instance as soon as a user holds this role. Remove the`,` `,(0,G.jsx)(`span`,{className:`font-mono`,children:`operations`}),` `,`key in the JSON below — that alone restores authentication.`,n&&(0,G.jsxs)(G.Fragment,{children:[` `,`Separately, and only if this instance needs allowlists at all: a database named`,` `,(0,G.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.`]})]})]})}function rb(e){if(e.super_user!==!0&&e.structure_user!==!0&&e.cluster_user!==!0)return e;let t=Nl(e),n={...e};for(let e in n)(!jl.has(e)||e===`operations`&&(t||!Array.isArray(n.operations))||n[e]===!1)&&delete n[e];return n}async function ib({id:e,permission:t,instanceClient:n}){let{data:r}=await n.post(`/`,{operation:`alter_role`,id:e,permission:t});return r}function ab(){return L({mutationFn:ib})}async function ob({id:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_role`,id:e});return n}function sb(){return L({mutationFn:ob})}async function cb({instanceClient:e,skipRecordCount:t}){let{data:n}=await e.post(`/`,{operation:`describe_all`,skip_record_count:t||void 0,exact_count:!t&&void 0});return n}function lb(e){return R({queryKey:[e.entityId,`describe_all`,!!e.skipRecordCount],queryFn:()=>cb(e),staleTime:6e4,gcTime:5e3,retry:!1})}function ub(e){try{return JSON.parse(e)}catch{return null}}function db({data:e,instanceId:t,clusterId:n,isModalOpen:r,closeModal:i,onSelectRole:a,onChangesSaved:o}){let s=Dm(),{role:c,permission:l}=e,[u,d]=(0,W.useState)(JSON.stringify(l,null,2)),f=K(),[p,m]=(0,W.useState)(!0),{data:h}=V(lb({...f,skipRecordCount:!0})),{data:g}=V(Bv(f)),_=Dn(t??n).user?.role?.id===e.id,[v,y]=sh(u?.includes(`attribute_name`)),{mutate:b,isPending:x}=ab(),{mutate:S,isPending:C}=sb(),[w,T]=(0,W.useState)(!1),E=(0,W.useCallback)(e=>{m(e.length===0)},[m]),D=(0,W.useMemo)(()=>JSON.stringify(h&&g&&Rl(Jy({instanceDatabaseMap:h,currentRolePermissions:u&&Ue(u)||l,version:g.version,showAttributes:v})),null,2),[l,h,g,v]);(0,W.useEffect)(()=>{d(D)},[D]);let O=Tl(g?.version),k=(0,W.useRef)(null),{operationsRaw:A,operationsJson:j,operationsKind:ee,allowlistRejected:M,structureUserDdl:N}=(0,W.useMemo)(()=>{let e=O&&u?ub(u):null,t=p&&typeof e==`object`&&e&&!Array.isArray(e)?e:k.current;if(t===null)return{operationsRaw:void 0,operationsJson:void 0,operationsKind:`absent`,allowlistRejected:!1,structureUserDdl:!1};k.current=t;let n=Il(t);return{operationsRaw:t.operations,operationsJson:n&&JSON.stringify(n),operationsKind:Ll(t,O),allowlistRejected:Nl(t),structureUserDdl:Pl(t)}},[O,p,u]),te=(0,W.useMemo)(()=>j===void 0?void 0:JSON.parse(j),[j]),ne=(0,W.useCallback)(e=>{d(t=>{let n=t?Ue(t):null;return!n||typeof n!=`object`||Array.isArray(n)?t:JSON.stringify(zl(n,e),null,2)})},[]),re=(0,W.useCallback)(t=>{let n=Ue(t);if(n&&typeof n==`object`&&!Array.isArray(n)){let t=rb(n);b({id:e.id,permission:t,...f},{onSuccess:()=>{H.success(`Role updated successfully!`),a(void 0),o()}})}},[b,e.id,f,o,a]),ie=(0,W.useCallback)(()=>{S({id:e.id,...f},{onSuccess:()=>{H.success(`Role deleted successfully!`),a(void 0),o()}})},[e.id,S,f,o,a]),ae=ee===`breaks-auth`||ee===`malformed`,oe=typeof A==`object`&&!!A&&!Array.isArray(A),se=(0,W.useCallback)(()=>{u&&p&&re(u)},[u,re,p]),F=(0,W.useCallback)(()=>{T(!0)},[]);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(fn,{onOpenChange:i,open:r,children:(0,G.jsxs)(cn,{resizable:!0,children:[(0,G.jsxs)(ln,{children:[_?`View`:`Edit`,` Role "`,c,`"`]}),(0,G.jsx)(un,{children:_?`You can view your own role, but you cannot edit it. Please assign yourself a different role to edit this role.`:`Edit the role's permissions in JSON format or remove the role entirely.`}),O&&g&&(ae?(0,G.jsx)(nb,{kind:ee,databaseCollision:oe}):(0,G.jsx)(Zy,{allowlistRejected:M,structureUserDdl:N,value:te,onChange:ne,version:g.version,disabled:_||!p})),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:D?(0,G.jsx)(km,{className:`w-full h-full`,theme:s,defaultLanguage:`json`,value:u,options:{readOnly:_,automaticLayout:!0},onValidate:E,onChange:d,defaultValue:D}):(0,G.jsx)(Kf,{})}),(0,G.jsx)(on,{children:!_&&(0,G.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,G.jsx)(P,{type:`button`,variant:`destructiveOutline`,onClick:F,disabled:x,children:`Delete Role`}),(0,G.jsx)(`div`,{className:`grow`}),(0,G.jsxs)(Ro,{className:`flex`,children:[(0,G.jsx)($,{type:`checkbox`,className:`w-6`,checked:v,onChange:y}),(0,G.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:`Pick Attributes`})]}),(0,G.jsx)(P,{variant:`submit`,onClick:se,disabled:x||!p||ae,children:`Save Changes`})]})})]})}),(0,G.jsx)(Ic,{isModalOpen:w,setIsModalOpen:T,deletionConfirmed:ie,deletionPending:C,typeOfThingBeingDeleted:`role`,nameOfThingBeingDeleted:c,hideDataLossWarning:!0})]})}function fb(){let e=I(),{clusterId:t,instanceId:n,roleId:r}=z({strict:!1}),i=K(),{data:a,refetch:o,isFetching:s,isRefetching:c}=_e(Ky(i)),l=(0,W.useMemo)(()=>a?.find(e=>e.id===r),[a,r]),u=(0,W.useCallback)(t=>{let n=[r?`..`:``,t].filter(Boolean);e({to:n.join(`/`)})},[r,e]),d=!!r&&!!l,[f,p]=(0,W.useState)(!1),m=(0,W.useCallback)(()=>{p(!0)},[p]),h=(0,W.useCallback)(e=>{o(),p(!1),u(e)},[u,o]),g=(0,W.useCallback)(e=>{u(e.original.id)},[u]),_=(0,W.useCallback)(()=>{u(void 0)},[u]),v=hm(o);return(0,G.jsxs)(W.Suspense,{fallback:(0,G.jsx)(Wi,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,G.jsx)(Ry,{children:(0,G.jsxs)(um,{columns:By,data:a,isFetching:s,onRowClick:g,children:[(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:v,accessKey:`r`,disabled:s||c,children:[(0,G.jsx)(Kr,{}),(0,G.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,G.jsx)(`u`,{children:`R`}),`efresh`]})]}),(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:f,children:[(0,G.jsx)(Gr,{}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`A`}),`dd`]})]})]})}),(0,G.jsx)(Gy,{isModalOpen:f,onChangesSaved:h,setIsModalOpen:p}),d&&(0,G.jsx)(db,{instanceId:n,clusterId:t,isModalOpen:d,closeModal:_,data:l,onSelectRole:u,onChangesSaved:()=>o()})]})}function pb(e){return!!e?.entries}function mb(e){if(!e?.entries)return[];let t=new Set;for(let n of e.entries)pb(n)&&t.add(n.name);return[...t].sort((e,t)=>e.localeCompare(t))}function hb({components:e,granted:t,onAdd:n,disabled:r,actionLabel:i=`Add`,commitOnBlur:a=!1}){let[o,s]=(0,W.useState)(``),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(0),[f,p]=(0,W.useState)(!1),m=(0,W.useId)(),h=(0,W.useId)(),g=(0,W.useRef)(!1),_=(0,W.useRef)(!1),v=r||f,y=(0,W.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,W.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,W.useCallback)(()=>{x(y[b]?.value??o)},[x,y,b,o]),C=(0,W.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,W.useCallback)(()=>{g.current||(l(!1),a&&o.trim()&&S())},[a,o,S]),T=c&&y.length>0;return(0,G.jsxs)(`div`,{className:`relative grid gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.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,G.jsxs)(P,{type:`button`,variant:`positiveOutline`,onMouseDown:e=>e.preventDefault(),onClick:S,disabled:v||!o.trim(),children:[(0,G.jsx)(Gr,{}),` `,i]})]}),T&&(0,G.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,G.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:N(`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,G.jsxs)(`span`,{className:`truncate`,children:[`Use “`,(0,G.jsx)(`span`,{className:`font-mono`,children:e.value}),`” — not a deployed application`]}):(0,G.jsx)(`span`,{className:`truncate font-mono`,children:e.value})},e.custom?`__custom__${e.value}`:e.value)})})]})}var gb=`enc:v1:`;function _b(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 vb(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function yb(e){return vb(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function bb(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function xb(){if(typeof crypto>`u`||!crypto.subtle)throw Error(`Secret encryption requires a secure context (HTTPS or localhost).`);return crypto.subtle}async function Sb(e,t,n){let r=xb(),i=_b(t),a=await r.importKey(`spki`,bb(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`,bb(o),{name:`AES-GCM`},!1,[`encrypt`]),l=new Uint8Array(await r.encrypt({name:`AES-GCM`,iv:bb(s),tagLength:128},c,bb(new TextEncoder().encode(e)))),u=l.slice(0,l.length-16),d=l.slice(l.length-16),f={kid:n,k:vb(new Uint8Array(await r.encrypt({name:`RSA-OAEP`},a,bb(o)))),iv:vb(s),ct:vb(u),tag:vb(d)};return gb+yb(new TextEncoder().encode(JSON.stringify(f)))}function Cb(e){let t=e?.response?.data;return t?.error??t?.message??String(e)}var wb=`does not match`;function Tb(e){return e.includes(wb)}async function Eb({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`get_secrets_public_key`});return{publicKey:t.public_key,fingerprint:t.fingerprint}}var Db=M;async function Ob(e){let{data:t}=await Db.post(`/ClusterSecrets`,{operation:`get_secrets_public_key`,clusterId:e});return{publicKey:t.publicKey,fingerprint:t.fingerprint}}function kb(e){return R({queryKey:[e.entityId,`get_secrets_public_key`,e.managedClusterId??`node`],queryFn:()=>e.managedClusterId?Ob(e.managedClusterId):Eb(e),staleTime:3e5,retry:!1})}async function Ab({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_secrets`});return t}function jb(e){return R({queryKey:[e.entityId,`list_secrets`],queryFn:()=>Ab(e)})}async function Mb(e,t,n){let{publicKey:r,fingerprint:i}=await e.ensureQueryData(kb(t)),a=await Sb(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=Cb(r);if(!n&&Tb(i))return e.removeQueries({queryKey:kb(t).queryKey}),Mb(e,t,!0);throw Error(i)}}function Nb(){let e=Ie();return L({mutationFn:t=>Mb(e,t,!1)})}async function Pb({instanceClient:e,name:t}){try{let{data:n}=await e.post(`/`,{operation:`delete_secret`,name:t});return n}catch(e){throw Error(Cb(e))}}function Fb(){return L({mutationFn:Pb})}async function Ib(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 Error(Cb(e))}}function Lb(){return L({mutationFn:e=>Ib(`grant_secret`,e)})}function Rb(){return L({mutationFn:e=>Ib(`revoke_secret`,e)})}function zb({name:e,initialGrants:t,components:n,onChanged:r}){let i=K(),{mutateAsync:a,isPending:o}=Lb(),{mutateAsync:s,isPending:c}=Rb(),l=o||c,[u,d]=(0,W.useState)(t),f=(0,W.useCallback)(async t=>{try{let n=await a({...i,name:e,component:t});d(n.grants),r?.()}catch(e){throw H.error(String(e)),e}},[a,i,e,r]),p=(0,W.useCallback)(async t=>{try{let n=await s({...i,name:e,component:t});d(n.grants),r?.()}catch(e){H.error(String(e))}},[s,i,e,r]);return(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`Granted applications`}),(0,G.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Only granted applications can read this secret through the `,(0,G.jsx)(`code`,{className:`font-mono`,children:`secrets`}),` `,`accessor. Changes apply immediately.`]}),u.length>0&&(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:u.map(e=>(0,G.jsxs)(Ji,{variant:`secondary`,children:[e,(0,G.jsxs)(`button`,{type:`button`,onClick:()=>void p(e),disabled:l,title:`Revoke ${e}`,className:`cursor-pointer disabled:cursor-default`,children:[(0,G.jsx)(gn,{}),(0,G.jsxs)(`span`,{className:`sr-only`,children:[`Revoke `,e]})]})]},e))}),(0,G.jsx)(hb,{components:n,granted:u,onAdd:f,disabled:l,actionLabel:`Grant`})]})}var Bb=`********`,Vb=/^[\w.-]+$/,Hb=/^(\s*(?:export\s+)?)([\w.-]+)\s*=(.*)$/;function Ub(e){return e.split(`/`).pop()??``}function Wb(e){if(!e)return!1;let t=Ub(e).toLowerCase();return t===`.env`||t.startsWith(`.env.`)}var Gb=[`.example`,`.sample`,`.template`];function Kb(e){if(!Wb(e))return!1;let t=Ub(e).toLowerCase();return Gb.some(e=>t.endsWith(e))}function qb(e){return Wb(e)&&!Kb(e)}function Jb(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,`
671
671
  `),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,`
672
672
  `).replace(/\\r/g,`\r`)),t[e]=n}return t}function Yb(e){return!e||e.length===0?``:e.map(e=>`${e}=${Bb}`).join(`
673
673
  `)+`
@@ -821,4 +821,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
821
821
  disabled:pointer-events-none disabled:opacity-40
822
822
  [&_svg]:size-4 [&_svg]:shrink-0`,e&&`bg-muted font-semibold text-foreground`,t),...n})}function vO({pageCount:e,disabled:t,onGo:n}){let[r,i]=(0,W.useState)(``);return(0,G.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,G.jsx)(`label`,{htmlFor:`pagination-go-to`,className:`text-sm whitespace-nowrap text-muted-foreground`,children:`Go to`}),(0,G.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
823
823
  placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-purple focus-visible:outline-none
824
- disabled:pointer-events-none disabled:opacity-50 dark:bg-grey-700 dark:text-white`})]})}function yO({pageSize:e,onChange:t}){return(0,G.jsxs)(`div`,{className:`hidden items-center gap-2 @min-[960px]:flex`,children:[(0,G.jsx)(`span`,{className:`text-sm whitespace-nowrap text-muted-foreground`,children:`Rows`}),(0,G.jsxs)(qf,{value:String(e),onValueChange:e=>t(Number(e)),children:[(0,G.jsx)(Xf,{"aria-label":`Rows per page`,className:`h-9 w-20`,children:(0,G.jsx)(Yf,{})}),(0,G.jsx)(Zf,{side:`top`,children:mO.map(e=>(0,G.jsx)($f,{value:String(e),children:vp(e)},e))})]})]})}function bO(e,t,n=1){if(t<=n*2+5)return xO(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?[...xO(1,s),`ellipsis`,t]:a&&!o?[1,`ellipsis`,...xO(t-s+1,t)]:[1,`ellipsis`,...xO(r,i),`ellipsis`,t]}function xO(e,t){return Array.from({length:t-e+1},(t,n)=>e+n)}function SO({applyFilters:e,columnFiltersForm:t,columns:n,columnVisibility:r,columnSizing:i,setColumnSizing:a,data:o,isFetching:s,onColumnClick:c,onRowClick:l,pageIndex:u,pageSize:d,primaryKey:f,resultSetKey:p,tableIdentity:m,setPageIndex:h,setPageSize:g,filtersToggled:_,totalPages:v,totalRecords:y,isEstimatedCount:b,estimatedRange:x,isExactCountFetching:S,isExactCountError:C,onRequestExactCount:w}){let T=Le({features:cm,data:o||[],columns:n,manualSorting:!0,enableColumnResizing:!0,columnResizeMode:`onEnd`,onColumnSizingChange:a,defaultColumn:{minSize:80},state:{columnVisibility:r,columnSizing:i}}),E=(0,W.useRef)(null),[D,O]=(0,W.useState)(0);(0,W.useLayoutEffect)(()=>{let e=E.current;e&&(e.scrollTop=0)},[p]),(0,W.useLayoutEffect)(()=>{let e=E.current;e&&(e.scrollTop=0,e.scrollLeft=0)},[m]);let k=T.state.columnResizing,A=k.isResizingColumn;(0,W.useLayoutEffect)(()=>{A&&O(E.current?.scrollLeft??0)},[A]);let j=null;if(A){let e=T.options.defaultColumn?.minSize??20,t=T.getColumn(A)?.getSize()??0,n=0;for(let e of T.getVisibleLeafColumns())if(n+=e.getSize(),e.id===A)break;j=n+Math.max(k.deltaOffset??0,e-t)-D}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`relative flex flex-col grow min-h-0`,children:[(0,G.jsxs)(tm,{containerRef:E,containerClassName:`rounded-md bg-card dark:bg-black-dark grow min-h-0 overflow-y-auto`,className:`table-fixed`,children:[(0,G.jsx)(nm,{children:T.getHeaderGroups().map(e=>(0,G.jsxs)(im,{className:`border-none`,children:[e.headers.map(e=>(0,G.jsx)(om,{header:e,onColumnClick:c,className:`sticky top-0 z-10 bg-card dark:bg-black-dark border-b border-border`},e.id)),(0,G.jsx)(am,{"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))}),_&&(0,G.jsx)(lO,{applyFilters:e,columnFiltersForm:t,headerGroups:T.getHeaderGroups()}),(0,G.jsx)(rm,{className:`bg-background dark:bg-black border border-border dark:border-grey-700`,children:T.getRowModel().rows?.length?T.getRowModel().rows.map(e=>(0,G.jsx)(CO,{row:e,onRowClick:l,primaryKey:f},e.id)):(0,G.jsx)(im,{children:(0,G.jsx)(sm,{colSpan:n.length+1,className:`h-24 text-center`,children:s||o===void 0?(0,G.jsx)(pO,{className:`opacity-50 inline-block`}):(0,G.jsx)(`span`,{children:`No results.`})})})})]}),j!==null&&(0,G.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute top-0 bottom-0 z-20 w-0.5 bg-primary`,style:{left:`${j}px`}})]}),(0,G.jsx)(hO,{pageIndex:u,pageSize:d,totalPages:v,totalRecords:y,isEstimatedCount:b,estimatedRange:x,isExactCountFetching:S,isExactCountError:C,onRequestExactCount:w,setPageIndex:h,setPageSize:g})]})}function CO({row:e,primaryKey:t,onRowClick:n}){let r=e.getVisibleCells(),i=(0,W.useMemo)(()=>{let n=e.original;return n&&n.message===`This entry has expired`?r[0]?.column?.id===t?[(0,G.jsx)(wO,{cell:r[0]},r[0].id),(0,G.jsx)(TO,{colSpan:r.length-1},`expired`)]:[(0,G.jsx)(TO,{colSpan:r.length},`expired`)]:r.map(e=>(0,G.jsx)(wO,{cell:e},e.id))},[e,t,r]);return(0,G.jsxs)(im,{"data-state":e.getIsSelected()&&`selected`,onClick:()=>n?.(e),className:N(`hover:bg-muted/10 data-[state=selected]:bg-muted`,n&&`cursor-pointer`),children:[i,(0,G.jsx)(sm,{"aria-hidden":!0,className:`p-0`})]})}function wO({cell:e}){let t=e.column.getSize();return(0,G.jsx)(sm,{"data-col-id":e.column.id,style:{width:`${t}px`,maxWidth:`${t}px`},className:`px-2 py-2 overflow-hidden text-ellipsis whitespace-nowrap`,children:Me(e.column.columnDef.cell,e.getContext())})}function TO({colSpan:e}){return(0,G.jsx)(sm,{colSpan:e,className:`px-2 py-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,children:(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`This entry has expired`})})}function EO({instanceDatabaseMap:e,databaseName:t,tableName:n}){let r=z({strict:!1}),i=K(),{clusterId:a,instanceId:o}=r,{toggled:s,toggle:c}=UD(!0),l=En(`instance:update`),u=yu(o??a,t,n,`insert`),d=xu(o??a,t,n),f=yu(o??a,t,n,`update`),p=yu(o??a,t,n,`delete`),m=vu(),{data:h}=V(kw({...i,databaseName:t,tableName:n})),g=e?.[t],_=g?.[n],v=h??_,y=(0,W.useMemo)(()=>id(v?.attributes??[],`attribute`),[v]),{data:b}=V(ID(i)),{data:x}=V(Bv(i)),S=bu(o??a,t,n),C=tO(x?.version,S),w=C===void 0,T=b?.[t]?.[n],E=(0,W.useMemo)(()=>dS(v,g,T),[v,g,T]),D=(0,W.useMemo)(()=>gS(v,g),[v,g]),O=(0,W.useMemo)(()=>pS(v?.attributes,g),[v,g]),[k,A]=Kh(null,r),[j,ee]=(0,W.useState)(!1),[M,N]=Kh(null,r),te=(0,W.useMemo)(()=>(t?Object.keys(e?.[t]||[]).sort():[]).length===1,[e,t]),{toggled:ne,toggleOn:re,toggleOff:ie}=UD(!1),ae=Pt({resolver:Ke(cO)}),{reset:oe}=ae,se=ae.watch(),[F,I]=Kh(null,[r.clusterId,r.instanceId,t,n]),ce=(0,W.useCallback)(e=>{let t=[];for(let n in e){let r=e[n];if(r?.length)try{t.push(...yw(n,r,y[n],E[n]))}catch(e){H.error(String(e))}}return t},[y,E]),le=(0,W.useCallback)(()=>{let e=ce(se);I(e.length?e:null),oe({...se})},[ce,oe,se]),ue=(0,W.useCallback)(()=>{oe({},{keepValues:!1,keepDirtyValues:!1,keepDefaultValues:!1}),oe(),I(null),ie()},[ie,oe]);(0,W.useEffect)(function(){return ue()},[r,ue]);let{filters:de}=he({strict:!1}),L=JSON.stringify([t,n,de??null]),fe=(0,W.useRef)(null);(0,W.useEffect)(function(){if(!v||fe.current===L)return;let e=fe.current===null;if(fe.current=L,de){oe({...de});let e=ce(de);I(e.length?e:null),re()}else e||ue()},[de,L,v,oe,ce,I,re,ue]);let{dataTableColumns:R,primaryKey:pe}=sw(v,E),[me,ge]=Kh({attribute:pe,descending:!1},r),[_e,ve]=Kh(0,[t,n,F]),[ye,be]=(0,W.useState)(20),xe=h?.record_count??_?.record_count,Se=h?.estimated_record_range??_?.estimated_record_range,[Ce,we]=Kh(!1,[t,n]),{data:Te,isFetching:Ee,isError:De,refetch:Oe}=V(ZD({...i,enabled:Ce,databaseName:t,tableName:n})),ke=(0,W.useCallback)(()=>{Ce?Oe():we(!0)},[Ce,Oe,we]),Ae=Te??xe,je=Ae?Math.ceil(Ae/ye):0,Me=Te===void 0&&Se!==void 0,Ne=ne&&!!F,Pe=`${t}.${n}`,Fe=JSON.stringify([Pe,_e,ye,me,Ne?F:null]),Le=Pg({...i,enabled:!Ne&&!!pe,databaseName:t,tableName:n,searchAttribute:pe,sort:me,pageSize:ye,pageIndex:_e,onlyIfCached:s,getAttributes:D}),{data:Re,isFetching:ze}=V(Le),Be=_w({...i,enabled:Ne&&!!pe,databaseName:t,tableName:n,conditions:F,sort:me,pageSize:ye,pageIndex:_e,onlyIfCached:s,getAttributes:D}),{data:Ve,isFetching:He}=V(Be),Ue=Ne?Ve:Re,We=ze||He,{data:Ge,isFetching:qe,isError:Je}=V(YD({...i,enabled:j,databaseName:t,tableName:n,ids:k})),Ye=j&&!!M&&(!pe||M[pe]==null),Xe=Ge?.data,Ze=!Ye&&!!k?.length&&!qe&&(Je||Array.isArray(Xe)&&Xe.length===0),{mutate:Qe,isPending:$e}=sO(),{mutate:et,isPending:tt}=qD(),{mutate:nt,isPending:rt}=iO(),{mutate:it,isPending:at}=GD(),ot=Ie(),st=(0,W.useCallback)(()=>ot.invalidateQueries({queryKey:[i.entityId,t,n]}),[ot,i.entityId,t,n]),ct=(0,W.useCallback)(()=>ot.invalidateQueries({queryKey:JD(i.entityId,t,n)}),[ot,i.entityId,t,n]),lt=(0,W.useCallback)(async()=>{confirm(`Are you sure you want to cleanup orphan blobs for database "${t}"?`)&&it({...i,databaseName:t},{onSuccess:e=>{H.success(e.message||`Orphan blobs cleanup started successfully`),st()},onError:e=>{H.error(e instanceof Error?e.message:`Failed to cleanup orphan blobs`)}})},[it,t,i,st]),{exportCsv:ut,isExporting:dt}=Tw(),ft=(0,W.useCallback)(()=>{ut({databaseName:t,tableName:n,primaryKey:pe,sort:me,conditions:Ne?F:null})},[ut,t,n,pe,me,Ne,F]),pt=(0,W.useCallback)(e=>{if(e?.wroteNothing){H.error(`The record wasn't updated`,{description:e.message});return}if(st(),ct(),ee(!1),e){H.error(`The record wasn't fully updated`,{description:e.message});return}H.success(`Record updated successfully`)},[st,ct]),mt=(0,W.useCallback)(e=>{Qe({...i,databaseName:t,tableName:n,records:e},{onSuccess:t=>pt(aO(t,e.length))})},[Qe,i,t,n,pt]),ht=(0,W.useCallback)(e=>{nt({...i,databaseName:t,tableName:n,records:e},{onSuccess:t=>pt(rO(t,e.length))})},[nt,i,t,n,pt]),gt=(0,W.useCallback)(e=>{et({...i,databaseName:t,tableName:n,hashValues:e},{onSuccess:()=>{st(),ee(!1),H.success(`Record deleted successfully`)}})},[et,i,t,n,st]),_t=e=>{let t=pe?e.original[pe]:void 0;N(e.original),A(t==null?null:[t]),ee(!0)},vt=(e,t)=>{ge({attribute:e,descending:!t})},yt=hm(st),bt=(0,W.useCallback)(()=>{xC(`ShowAddTableRecords`,{databaseName:t,tableName:n})},[t,n]),xt=(0,W.useCallback)(()=>{xC(`ShowImportData`,{databaseName:t,tableName:n})},[t,n]),[St,Ct]=Qh(`ColumnDisplayed/${t}/${n}`,{}),wt=(0,W.useMemo)(()=>({...Object.fromEntries(hS(E).map(e=>[e,!1])),...St}),[E,St]),[Tt,Et]=Qh(`ColumnSizing/${t}/${n}`,{});return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`shrink-0 flex flex-col md:flex-row md:flex-wrap items-center justify-between gap-3 pt-15 pb-4 pr-4`,children:[(0,G.jsxs)(`div`,{className:`flex space-x-2`,children:[u&&(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:bt,accessKey:`n`,children:[(0,G.jsx)(Gr,{}),(0,G.jsxs)(`span`,{children:[`Add `,(0,G.jsx)(`u`,{children:`N`}),`ew Record(s)`]})]}),d&&(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:xt,accessKey:`i`,children:[(0,G.jsx)(ar,{}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`I`}),`mport Data`]})]}),(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:ft,disabled:dt,accessKey:`e`,children:[(0,G.jsx)(ir,{}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`E`}),`xport CSV`]})]})]}),(0,G.jsxs)(`div`,{className:`flex space-x-2`,children:[ne&&F&&(0,G.jsxs)(P,{type:`button`,variant:`ghost`,onClick:ue,accessKey:`f`,children:[(0,G.jsx)(_r,{className:`inline-block `}),(0,G.jsxs)(`span`,{children:[`Clear `,(0,G.jsx)(`u`,{children:`F`}),`ilters`]})]}),ne&&ae.formState.isDirty&&(0,G.jsxs)(P,{variant:`default`,onClick:le,children:[(0,G.jsx)(hr,{className:`inline-block `}),`Apply Filters`]}),ne&&!F&&(0,G.jsxs)(P,{variant:`ghost`,onClick:ie,accessKey:`f`,children:[(0,G.jsx)(_r,{className:`inline-block `}),(0,G.jsxs)(`span`,{children:[`Hide `,(0,G.jsx)(`u`,{children:`F`}),`ilters`]})]}),!ne&&(0,G.jsxs)(P,{variant:`ghost`,onClick:re,accessKey:`f`,children:[(0,G.jsx)(gr,{className:`inline-block `}),(0,G.jsxs)(`span`,{children:[`Show `,(0,G.jsx)(`u`,{children:`F`}),`ilters`]})]}),(0,G.jsx)(P,{variant:`defaultOutline`,onClick:yt,disabled:We,children:(0,G.jsx)(Kr,{})}),(0,G.jsx)(dO,{columns:R,columnVisibility:wt,setColumnVisibility:Ct}),(0,G.jsxs)(wi,{children:[(0,G.jsx)(Ti,{asChild:!0,disabled:!e,children:(0,G.jsx)(P,{variant:`ghost`,size:`icon`,disabled:!e,children:(0,G.jsx)(ur,{"aria-label":`Table options`})})}),(0,G.jsxs)(Ei,{side:`bottom`,align:`end`,children:[(0,G.jsxs)(Di,{className:`focus:bg-primary/70 focus:text-white`,onClick:c,children:[s?(0,G.jsx)(Zn,{className:`text-green`}):(0,G.jsx)(er,{}),`Only If Cached`,(0,G.jsx)(B,{to:`https://docs.harperdb.io/docs/developers/applications/caching#cache-control-header`,target:`_blank`,rel:`noopener noreferrer`,onClick:nw,children:(0,G.jsx)(dr,{})})]}),m&&l&&!!o&&(0,G.jsxs)(Di,{className:`focus:bg-yellow/70 focus:text-white`,onClick:lt,disabled:at,children:[(0,G.jsx)(Un,{className:`text-yellow `}),`Cleanup Orphan Blobs`]}),m&&!te&&(0,G.jsxs)(Di,{className:`focus:bg-red/70 focus:text-white`,onClick:()=>xC(`ShowDeleteTable`,{databaseName:t,tableName:n}),children:[(0,G.jsx)(fi,{className:`inline-block `}),`Drop Table`]}),m&&(0,G.jsxs)(Di,{className:`focus:bg-red/70 focus:text-white`,onClick:()=>xC(`ShowDeleteDatabase`,{databaseName:t}),children:[(0,G.jsx)(fi,{}),`Drop Database`]})]})]})]})]}),(0,G.jsx)(SO,{primaryKey:pe,data:Ue?.data,isFetching:We,filtersToggled:ne,columns:R,columnVisibility:wt,columnSizing:Tt,setColumnSizing:Et,onRowClick:_t,onColumnClick:vt,totalPages:je,totalRecords:Ae,isEstimatedCount:Me,estimatedRange:Se,isExactCountFetching:Ee,isExactCountError:De,onRequestExactCount:ke,pageIndex:_e,pageSize:ye,resultSetKey:Fe,tableIdentity:Pe,columnFiltersForm:ae,applyFilters:le,setPageIndex:ve,setPageSize:be}),(0,G.jsx)(HD,{canEditRecords:f,canDeleteRecords:p,canReplaceRecords:w,replaceBlockedReason:C,setIsModalOpen:ee,isModalOpen:j,primaryKey:pe,missingPrimaryKey:Ye,recordUnavailable:Ze,syntheticAttributes:O,data:Ye||Ze?M?[M]:void 0:Ge?.data,onSaveChanges:mt,onReplaceRecord:ht,onDeleteRecord:gt,isUpdateTableRecordsPending:$e||rt,isDeleteTableRecordsPending:tt})]})}function DO(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 OO=10;function kO(e){return Math.max(200,Math.floor(e/2))}function AO(e,t){return Math.round(Math.min(Math.max(e,200),kO(t)))}function jO(){let[e,t]=xn(vn.DatabasesSidebarWidth,320),[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(()=>AO(e,window.innerWidth)),o=(0,W.useRef)(i);o.current=i;let s=(0,W.useRef)(null);(0,W.useEffect)(()=>{n||a(AO(e,window.innerWidth))},[e,n]),(0,W.useEffect)(()=>{let t=()=>{n||a(AO(e,window.innerWidth))};return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e,n]);let c=(0,W.useCallback)(e=>{e.preventDefault(),s.current={startX:e.clientX,startWidth:o.current},r(!0)},[]);return(0,W.useEffect)(()=>{if(!n)return;let e=e=>{let t=s.current;t&&a(AO(t.startWidth+(e.clientX-t.startX),window.innerWidth))},i=()=>{r(!1),t(o.current)},c=document.body.style.userSelect;return document.body.style.userSelect=`none`,window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,i),()=>{document.body.style.userSelect=c,window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,i)}},[n,t]),{width:i,isResizing:n,startResizing:c,handleKeyDown:(0,W.useCallback)(e=>{e.key===`ArrowLeft`?(e.preventDefault(),t(e=>AO(e-OO,window.innerWidth))):e.key===`ArrowRight`&&(e.preventDefault(),t(e=>AO(e+OO,window.innerWidth)))},[t])}}function MO(){let e=z({strict:!1}),t=K(),{data:n}=V(lb({...t,skipRecordCount:!0})),{width:r,isResizing:i,startResizing:a,handleKeyDown:o}=jO(),s={"--db-sidebar-width":`${r}px`},c=DO(n,e);return c?(0,G.jsx)(ce,{to:aS({...e,...c}),replace:!0}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`main`,{className:`flex flex-col gap-4 md:flex-row md:items-start`,children:[(0,G.jsxs)(`section`,{style:s,className:`relative text-foreground w-full md:w-[var(--db-sidebar-width)] md:shrink-0 md:border-r 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,G.jsx)(PE,{instanceDatabaseMap:n}),(0,G.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,"aria-valuenow":r,"aria-valuemin":200,"aria-valuemax":kO(window.innerWidth),onMouseDown:a,onKeyDown:o,className:`group hidden md:block absolute top-0 bottom-0 right-0 w-4 translate-x-1/2 z-40 cursor-col-resize outline-none`,children:(0,G.jsx)(`div`,{className:N(`absolute inset-y-0 left-1/2 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`,i&&`bg-violet-400/60 dark:bg-violet-500/60`)})})]}),(0,G.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,G.jsx)(EO,{instanceDatabaseMap:n,databaseName:e.databaseName,tableName:e.tableName}):e.databaseName?(0,G.jsx)(`div`,{className:`min-h-0 grow overflow-y-auto`,children:(0,G.jsx)(Pw,{instanceDatabaseMap:n,databaseName:e.databaseName})}):null})]}),n&&(0,G.jsx)(tw,{instanceDatabaseMap:n})]})}function NO(e){return F({getParentRoute:()=>e,path:`/databases/{-$databaseName}/{-$tableName}`,head:()=>({meta:[{title:`Databases — Harper Fabric`}]}),component:MO})}var PO={className:`text-primary font-semibold bg-primary/10 rounded-md dark:text-white dark:bg-white/10`};function FO(){let e=_u(),t=z({strict:!1}),{version:n}=oe({strict:!1}),r=qc(`4.6.0`,n)&&e,i=qc(`4.7.0-beta.7`,n),a=K(),{data:o}=V(v_(a,r)),s=o?.restartRequired??!1,c=(0,W.useMemo)(()=>[e&&{to:t.clusterId&&!t.instanceId?jv(t,`apps`):jv(t),activeOptions:{exact:!0},name:`Applications`,shortName:`Apps`,icon:(0,G.jsx)(Hr,{className:`inline-block`})},{to:jv(t,`databases`),icon:(0,G.jsx)(lr,{className:`inline-block`}),name:`Databases`},e&&i&&{to:jv(t,`apis`),name:`APIs`,icon:(0,G.jsx)($r,{className:`inline-block`})},e&&r&&{to:jv(t,`status`),icon:(0,G.jsx)(vr,{className:`inline-block`}),name:`Status`},e&&{to:jv(t,`logs`),icon:(0,G.jsx)(Br,{className:`inline-block`}),name:`Logs`},e&&{to:jv(t,`config`),icon:(0,G.jsx)(ei,{className:`inline-block`}),name:`Config`}].filter(Qa),[e,t,i,r]);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(IO,{links:c,restartRequired:s}),(0,G.jsx)(LO,{links:c,restartRequired:s})]})}function IO({links:e,restartRequired:t}){return(0,G.jsxs)(`div`,{className:`hidden md:[@media(hover:hover)]:flex xl:flex items-center justify-between h-full text-sm text-foreground`,children:[(0,G.jsx)(Po,{restartRequired:t}),(0,G.jsx)(`div`,{className:`flex space-x-2`,children:e.map(({shortName:e,...t})=>{let n=(0,G.jsxs)(B,{"aria-label":t.name,className:`p-2 text-center text-muted-foreground hover:text-foreground`,activeProps:PO,...t,children:[t.icon,(0,G.jsx)(`span`,{className:`hidden xl:inline-block ml-1`,children:t.name}),e&&(0,G.jsx)(`span`,{className:`visible xl:hidden ml-1`,children:e})]},t.to);return e?n:(0,G.jsxs)(Ba,{children:[(0,G.jsx)(Va,{asChild:!0,children:n}),(0,G.jsx)(Ha,{side:`bottom`,className:`xl:hidden`,children:t.name})]},t.to)})})]})}function LO({links:e,restartRequired:t}){return(0,G.jsx)(G.Fragment,{children:(0,G.jsxs)(`div`,{className:`flex md:[@media(hover:hover)]:hidden xl:hidden items-center justify-between h-full px-2 text-foreground`,children:[(0,G.jsx)(Po,{restartRequired:t}),(0,G.jsxs)(wi,{children:[(0,G.jsx)(Ti,{asChild:!0,children:(0,G.jsx)(P,{variant:`ghost`,className:`p-0`,children:(0,G.jsx)(Lr,{className:`h-8 w-8`})})}),(0,G.jsxs)(Ei,{children:[(0,G.jsx)(ki,{children:`Instance Menu`}),(0,G.jsx)(Ai,{}),e.map(e=>(0,G.jsx)(Di,{asChild:!0,children:(0,G.jsxs)(B,{to:e.to,activeProps:PO,className:`flex items-center gap-2`,children:[e.icon,e.name]})},e.to))]})]})]})})}(0,W.lazy)(()=>ne(()=>import(`./FloatingChat-BWImX5fA.js`).then(e=>({default:e.FloatingChat})),__vite__mapDeps([35,1,4,5,9,11,12,13])));function RO(){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`nav`,{className:`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,G.jsx)(FO,{})}),(0,G.jsx)(`div`,{className:`mt-32 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,G.jsx)(He,{})}),!1]})}function zO(e){switch(e){case`local`:return F({getParentRoute:()=>bo,id:`_instanceLayout`,component:RO,loader:rS});case`cluster`:return F({getParentRoute:()=>ig,id:`_instanceLayout`,component:RO,beforeLoad:BO,loader:rS});case`instance`:return F({getParentRoute:()=>ig,path:`instance/$instanceId`,component:RO,beforeLoad:BO,loader:rS})}}async function BO({context:e,params:t}){let n=t.instanceId||t.clusterId,r=!1;if(u.checkForFabricConnect(n)&&!u.hasResolvedFabricConnect(n)&&(r=!0,await VO(n,e.cluster,t.instanceId)))return;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?hu(a.user,t.organizationId,t.clusterId):fu(a.user,t.organizationId,t.clusterId);if(!r&&o&&await VO(n,e.cluster,t.instanceId))return;let s=`/${t.organizationId}/${t.clusterId}/`+(t.instanceId?`instance/${t.instanceId}`:``)+`/sign-in`;throw le({to:s,search:uo()})}async function VO(e,t,n){try{return await u.establishFabricConnectAuth({id:e,operationsUrl:HO(t,n)}),!0}catch(e){return console.debug(`Fabric Connect not established`,e),!1}}function HO(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 UO(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 WO=[`secondary`,`default`,`warning`,`outline`,`success`,`destructive`],GO=0,KO=new Map,qO=e=>{if(KO.has(e))return KO.get(e);GO++;let t=WO[GO%WO.length];return KO.set(e,t),t};function JO(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 YO({columns:e,data:t,onRowClick:n,containerRef:r}){let i=Le({features:cm,data:t,columns:e});return(0,G.jsxs)(tm,{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,G.jsx)(nm,{children:i.getHeaderGroups().map(e=>(0,G.jsx)(im,{className:`border-b border-border`,children:e.headers.map(e=>(0,G.jsx)(am,{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:Me(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,G.jsx)(rm,{className:`bg-background dark:bg-black`,children:i.getRowModel().rows?.length?i.getRowModel().rows.map(e=>(0,G.jsx)(im,{"data-state":e.getIsSelected()&&`selected`,className:N(`hover:bg-muted/20 data-[state=selected]:bg-muted max-w-full border-l-2`,JO(e.original.level),n&&`cursor-pointer`),onClick:()=>n?.(e),children:e.getVisibleCells().map(e=>(0,G.jsx)(sm,{className:`p-2`,children:Me(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,G.jsx)(im,{children:(0,G.jsx)(sm,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})}var XO=524288,ZO=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 QO(e){try{JSON.parse(e)}catch{return!1}return!0}function $O(e){return!e||e.length>524288?`plaintext`:QO(e)?`json`:`plaintext`}function ek({label:e,children:t}){return(0,G.jsxs)(`div`,{className:`flex items-start gap-3 py-1.5 border-b border-border/50 last:border-0`,children:[(0,G.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground w-20 shrink-0 pt-0.5`,children:e}),(0,G.jsx)(`span`,{className:`text-xs`,children:t})]})}function tk({setIsModalOpen:e,isModalOpen:t,data:n}){let r=n?qO(n.node):`default`,i=Dm();return(0,G.jsx)(fn,{onOpenChange:e,open:t,children:(0,G.jsxs)(cn,{"aria-describedby":void 0,resizable:!0,children:[(0,G.jsx)(rn,{children:(0,G.jsx)(ln,{children:`Log Entry`})}),n?(0,G.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 text-popover-foreground`,children:[(0,G.jsxs)(`div`,{className:`rounded-md border border-border/50 bg-muted/20 px-3 py-1`,children:[(0,G.jsx)(ek,{label:`Level`,children:(0,G.jsx)(Ji,{variant:UO(n.level),children:Mo(n.level)})}),(0,G.jsx)(ek,{label:`Timestamp`,children:(0,G.jsx)(`span`,{className:`tabular-nums`,children:new Date(n.timestamp).toLocaleString()})}),(0,G.jsx)(ek,{label:`Thread`,children:(0,G.jsx)(`span`,{className:`tabular-nums font-mono`,children:n.thread})}),n.node&&(0,G.jsx)(ek,{label:`Node`,children:(0,G.jsx)(Ji,{variant:r,children:n.node})}),n.tags&&n.tags.length>0&&(0,G.jsx)(ek,{label:`Tags`,children:(0,G.jsx)(`span`,{className:`font-mono`,children:n.tags})})]}),(0,G.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`Message`}),(0,G.jsx)(`div`,{className:`rounded-md overflow-hidden border border-border/50 flex-1 min-h-0`,children:(0,G.jsx)(km,{className:`w-full h-full`,language:$O(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,G.jsx)(Wi,{})]})})}var nk=S({limit:A().or(w()).or(E()).optional(),level:O([`notify`,`error`,`warn`,`info`,`debug`,`trace`,`undefined`]).or(w()).or(E()).optional(),from:A().or(w()).or(E()).optional(),until:A().or(w()).or(E()).optional(),log_name:O([`hdb.log`,`system.log`]).or(w()).or(E()).optional(),filter:A().or(w()).or(E()).optional()}),rk=`dark:bg-grey-600 dark:border-grey-500`;function ik({form:e,resetFilters:t,submitFilters:n,showLogName:r,showFilter:i,isOpen:a,onOpenChange:o}){return(0,G.jsxs)(On,{className:N(a?`block`:`hidden`,`mt-3 md:mt-0 md:block`),children:[(0,G.jsx)(kn,{className:`hidden md:block`,children:(0,G.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,G.jsxs)(An,{className:`flex items-center gap-2 text-base`,children:[(0,G.jsx)(ri,{className:`size-4 text-muted-foreground`}),`Filters`]})})}),(0,G.jsx)(Mn,{id:`logs-filters-content`,children:(0,G.jsx)(q,{...e,children:(0,G.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,G.jsx)(Y,{control:e.control,name:`filter`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(J,{children:(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(Qr,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,G.jsx)($,{type:`search`,placeholder:`Search logs…`,className:N(`pl-9`,rk),value:e.value??``,onChange:e.onChange})]})}),(0,G.jsx)(Q,{})]})}),r&&(0,G.jsx)(Y,{control:e.control,name:`log_name`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Log file`}),(0,G.jsxs)(qf,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,G.jsx)(Xf,{className:N(`w-full bg-white`,rk),children:(0,G.jsx)(Yf,{placeholder:`Select log file`})}),(0,G.jsx)(Zf,{children:(0,G.jsxs)(Jf,{children:[(0,G.jsx)($f,{value:`hdb.log`,children:`Application (hdb.log)`}),(0,G.jsx)($f,{value:`system.log`,children:`System (system.log)`})]})})]}),(0,G.jsx)(Q,{})]})}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,G.jsx)(Y,{control:e.control,name:`limit`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Limit`}),(0,G.jsxs)(qf,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,G.jsx)(Xf,{className:N(`w-full bg-white`,rk),children:(0,G.jsx)(Yf,{placeholder:`Limit`})}),(0,G.jsx)(Zf,{children:(0,G.jsxs)(Jf,{children:[(0,G.jsx)($f,{value:`1000`,children:`1000`}),(0,G.jsx)($f,{value:`500`,children:`500`}),(0,G.jsx)($f,{value:`250`,children:`250`}),(0,G.jsx)($f,{value:`100`,children:`100`}),(0,G.jsx)($f,{value:`10`,children:`10`})]})})]}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:e.control,name:`level`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Level`}),(0,G.jsxs)(qf,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,G.jsx)(Xf,{className:N(`w-full bg-white`,rk),children:(0,G.jsx)(Yf,{placeholder:`Level`})}),(0,G.jsx)(Zf,{children:(0,G.jsxs)(Jf,{children:[(0,G.jsx)($f,{value:`undefined`,children:`All`}),(0,G.jsx)($f,{value:`notify`,children:`Notify`}),(0,G.jsx)($f,{value:`error`,children:`Error`}),(0,G.jsx)($f,{value:`warn`,children:`Warn`}),(0,G.jsx)($f,{value:`info`,children:`Info`}),(0,G.jsx)($f,{value:`debug`,children:`Debug`}),(0,G.jsx)($f,{value:`trace`,children:`Trace`})]})})]}),(0,G.jsx)(Q,{})]})})]}),(0,G.jsx)(Y,{control:e.control,name:`from`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Start date`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`datetime-local`,className:rk,value:e.value??void 0,onChange:e.onChange})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:e.control,name:`until`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`End date`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`datetime-local`,className:rk,value:e.value??void 0,onChange:e.onChange})}),(0,G.jsx)(Q,{})]})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,G.jsx)(P,{type:`submit`,variant:`positiveOutline`,className:`grow`,children:`Apply Filters`}),(0,G.jsx)(P,{type:`reset`,variant:`destructiveOutline`,onClick:t,children:`Clear`})]})]})})})]})}var ak=1e4;function ok(e){if(!e)return;let t=parseInt(e,10);if(!(!Number.isFinite(t)||t<=0))return Math.min(t,ak)}function sk(e,t){return{operation:`read_log`,start:0,replicated:t,limit:ok(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 ck({instanceClient:e,logFilters:t,replicated:n}){let{data:r}=await e.post(`/`,sk(t,n));return r}function lk(e){let t=e.logFilters;return R({queryKey:[`read_log`,e.entityId,t.limit,t.level,t.from,t.until,t.log_name,t.filter,e.replicated],queryFn:()=>ck(e),retry:!1,refetchInterval:e.isAutoRefreshEnabled?5e3:!1})}async function uk({connection:e,logFilters:t,replicated:n,signal:r,onEntry:i}){let{url:a,headers:o,credentials:s}=Ev(e),c;try{c=await fetch(a,{method:`POST`,headers:o,credentials:s,body:JSON.stringify(sk(t,n)),signal:r})}catch(e){throw r?.aborted?e:new Cv(`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 Cv(`read_log did not return an event stream (status ${c.status}, content-type "${l}").`);for await(let e of bv(c.body,r)){if(e.event===`error`){let t=Sv(e);if(!t||typeof t!=`object`)throw new Tv(typeof t==`string`&&t?t:`The log stream failed.`);let n=t;throw new Tv(n.message??`The log stream failed.`,{code:n.code})}if(e.event===`done`||e.event===`end`)return;for(let t of dk(Sv(e)))i(t)}}function dk(e){return Array.isArray(e)?e.filter(fk):fk(e)?[e]:[]}function fk(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 pk(e){return[e.timestamp,e.node??``,e.thread??``,e.level,e.message].join(`|`)}function mk(e,t,n){let r=new Set,i=[];for(let n of[...t,...e]){let e=pk(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 hk={entries:[],fellBack:!1};function gk(e,t){switch(t.kind){case`reset`:return hk;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 _k(){let e=K();return u.isDirectConnection(e.entityId)}var vk=1e3,yk=2e3,bk=250;function xk(e){return ok(e)??vk}function Sk(e,t){return JSON.stringify([e.limit,e.level,e.from,e.until,e.log_name,e.filter,t])}function Ck({params:e,logFilters:t,replicated:n,live:r}){let i=_k(),[a,o]=(0,W.useReducer)(gk,hk),s=r&&i&&!a.fellBack,c=Sk(t,n),l=xk(t.limit),u=Math.max(yk,l),d=V(lk({...e,logFilters:t,replicated:n,isAutoRefreshEnabled:r&&!s}));(0,W.useEffect)(()=>{o({kind:`reset`})},[e.entityId,c]),(0,W.useEffect)(()=>{r&&o({kind:`retry`})},[r]);let f=(0,W.useRef)({logFilters:t,replicated:n});f.current={logFilters:t,replicated:n},(0,W.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,bk);return uk({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,W.useMemo)(()=>{let e=d.data??[];return a.entries.length===0?e:mk(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 wk={log_name:`hdb.log`,limit:`100`,level:`undefined`,from:``,until:``,filter:``},Tk={error:(0,G.jsx)(Xn,{className:`size-3`}),stderr:(0,G.jsx)(Xn,{className:`size-3`}),warn:(0,G.jsx)(pi,{className:`size-3`}),notify:(0,G.jsx)(Vn,{className:`size-3`}),info:(0,G.jsx)(wr,{className:`size-3`}),debug:(0,G.jsx)(Wn,{className:`size-3`}),trace:(0,G.jsx)(Fn,{className:`size-3`}),stdout:(0,G.jsx)(ui,{className:`size-3`})},Ek=[{accessorKey:`level`,header:`Level`,cell:({row:e})=>{let{level:t}=e.original;return(0,G.jsxs)(Ji,{variant:UO(t),children:[Tk[t],Mo(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,G.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,G.jsx)(`span`,{className:`block max-w-xl truncate font-mono text-xs`,children:t})}},{accessorKey:`thread`,header:`Thread`,cell:({row:e})=>(0,G.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=qO(t);return(0,G.jsx)(G.Fragment,{children:t?(0,G.jsxs)(Ba,{children:[(0,G.jsx)(Va,{asChild:!0,children:(0,G.jsxs)(Ji,{variant:n,children:[t.split(`.`)[0],`...`]})}),(0,G.jsx)(Ha,{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,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null}}],Dk=(e,t)=>!e&&!t||!e||!t||new Date(e)<=new Date(t);function Ok(){return(0,G.jsxs)(`div`,{className:`rounded-md bg-card dark:bg-black-dark overflow-hidden`,children:[(0,G.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,G.jsx)(yh,{className:`h-4 ${e}`},t))}),Array.from({length:12}).map((e,t)=>(0,G.jsxs)(`div`,{className:`flex gap-4 p-3 border-b border-border/40 border-l-2 border-l-transparent`,children:[(0,G.jsx)(yh,{className:`h-5 w-14`}),(0,G.jsx)(yh,{className:`h-5 w-32`}),(0,G.jsx)(yh,{className:`h-5 w-10`}),(0,G.jsx)(yh,{className:`h-5 w-20`}),(0,G.jsx)(yh,{className:`h-5 w-12`}),(0,G.jsx)(yh,{className:`h-5 flex-1 max-w-xs`})]},t))]})}function kk(){let[e,t]=(0,W.useState)(wk),[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(),[o,s]=(0,W.useState)(!1),[c,l]=xn(vn.LogsOrderReversed,!1),[u,d]=(0,W.useState)(!1),f=K(),{data:p}=V(Bv(f)),m=p?.version,h=!!m&&qc(`4.7.16`,m),{logs:g,isLoading:_,isFetching:v,refetch:y,transport:b}=Ck({params:f,logFilters:e,replicated:f.entityType===`cluster`,live:o}),x=(0,W.useMemo)(()=>c?[...g??[]].reverse():g??[],[g,c]),S=(0,W.useRef)(null);(0,W.useEffect)(()=>{let e=S.current;_||!e||e.scrollTo({top:c?e.scrollHeight:0})},[c,_]),(0,W.useEffect)(()=>{let e=S.current;!o||_||!e||e.scrollTo({top:c?e.scrollHeight:0})},[x,o,c,_]);let C=Pt({resolver:Ke(nk),defaultValues:wk,mode:`onChange`}),w=e=>{a(e.original),r(!0)},T=async e=>{if(!Dk(e.from,e.until)){C.setError(`from`,{type:`onChange`,message:`Start date must be before end date`}),C.setError(`until`,{type:`onChange`,message:`End date must be after start date`});return}t(e)},E=async()=>{C.reset(),t(wk)},D=hm(y);return(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 pt-2 text-foreground md:grid-cols-12 md:gap-4`,children:[(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2 md:hidden`,children:[(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:()=>d(e=>!e),"aria-label":`Toggle filters`,"aria-expanded":u,className:`flex-1`,children:[(0,G.jsx)(ri,{}),`Filters`]}),(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:D,disabled:v||_||o,"aria-label":`Refresh logs`,className:`flex-1`,children:[(0,G.jsx)(Kr,{className:v?`animate-spin`:``}),`Refresh`]}),(0,G.jsxs)(P,{variant:c?`default`:`defaultOutline`,onClick:()=>l(e=>!e),"aria-label":`Reverse log order`,"aria-pressed":c,className:`flex-1`,children:[(0,G.jsx)(zn,{}),`Reverse`]})]}),(0,G.jsx)(ik,{form:C,resetFilters:E,submitFilters:T,showLogName:!1,showFilter:h,isOpen:u,onOpenChange:d}),(0,G.jsxs)(`div`,{className:`mt-3 space-y-3 hidden md:block`,children:[(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:D,disabled:v||_||o,className:`w-full`,children:[(0,G.jsx)(Kr,{}),`Refresh`]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,G.jsx)(Um,{id:`logs-live-switch`,"aria-label":`Toggle live logs`,checked:o,onCheckedChange:s}),(0,G.jsxs)(`label`,{htmlFor:`logs-live-switch`,className:`flex items-center gap-2 cursor-pointer`,children:[(0,G.jsx)(Kr,{className:`size-4 ${o?`animate-spin [animation-duration:3s]`:``}`}),o?b===`streaming`?`Live (streaming)`:`Live (polling every 5s)`:`Live`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,G.jsx)(Um,{id:`logs-reverse-order-switch`,"aria-label":`Reverse log order`,checked:c,onCheckedChange:l}),(0,G.jsxs)(`label`,{htmlFor:`logs-reverse-order-switch`,className:`flex items-center gap-2 cursor-pointer`,children:[(0,G.jsx)(zn,{className:`size-4`}),c?`Oldest first`:`Newest first`]})]})]})]})]}),(0,G.jsx)(`section`,{className:`col-span-1 md:col-span-8 lg:col-span-9`,children:_?(0,G.jsx)(Ok,{}):(0,G.jsx)(YO,{columns:Ek,data:x,onRowClick:w,containerRef:S})}),(0,G.jsx)(tk,{isModalOpen:n,setIsModalOpen:r,data:i})]})}function Ak(e){return F({getParentRoute:()=>e,path:`logs`,head:()=>({meta:[{title:`Logs — Harper Fabric`}]}),component:kk})}var jk=6e4,Mk=60*jk,Nk=24*Mk,Pk=[{id:`1h`,label:`Last 1 hour`,durationMs:Mk,bucketMs:1*jk,expandedBucketMs:1*jk},{id:`6h`,label:`Last 6 hours`,durationMs:6*Mk,bucketMs:2*jk,expandedBucketMs:1*jk},{id:`24h`,label:`Last 24 hours`,durationMs:Nk,bucketMs:10*jk,expandedBucketMs:5*jk},{id:`7d`,label:`Last 7 days`,durationMs:7*Nk,bucketMs:Mk,expandedBucketMs:15*jk},{id:`30d`,label:`Last 30 days`,durationMs:30*Nk,bucketMs:4*Mk,expandedBucketMs:Mk}];function Fk(e){let t=Pk.find(t=>t.id===e);if(!t)throw Error(`Unknown preset: ${e}`);return t}function Ik(e){let t=(e,t)=>`${e} ${t}${e===1?``:`s`}`;return e>=Mk&&e%Mk===0?t(e/Mk,`hour`):e>=jk&&e%jk===0?t(e/jk,`minute`):e>=1e3&&e%1e3==0?t(e/1e3,`second`):`${e} ms`}function Lk(e,t){let n=e=>t?.expanded?e.expandedBucketMs:e.bucketMs,r=n(Pk[0]);if(!Number.isFinite(e)||e<=0)return r;for(let t of Pk)if(e<=t.durationMs*1.01)return n(t);let i=Pk[Pk.length-1];return Math.max(r,Math.ceil(e/(i.durationMs/n(i))))}var Rk=[{label:`Off`,value:0},{label:`30s`,value:3e4},{label:`60s`,value:6e4},{label:`5m`,value:3e5}],zk=6e4,Bk=[`health`,`traffic`,`requests`,`database`,`replication`,`storage`,`overview`],Vk={tab:`health`,range:`1h`,refresh:zk};function Hk(e){let t=e.refresh===``?NaN:Number(e.refresh);return{tab:Bk.find(t=>t===e.tab)??Vk.tab,range:Pk.find(t=>t.id===e.range)?.id??Vk.range,refresh:Rk.find(e=>e.value===t)?.value??Vk.refresh}}function Uk(e){return F({getParentRoute:()=>e,path:`status`,validateSearch:Hk,search:{middlewares:[me(Vk)]},head:()=>({meta:[{title:`Status — Harper Fabric`}]}),component:we(async()=>ne(()=>import(`./status-C6Yib7-K.js`),__vite__mapDeps([36,1,3,2,4,5,6,7,9,8,10,11,12,13,16,31,37,38,39,40,41,42,43,44,29,45])),`StatusIndex`)})}function Wk(e){let t=zO(e),n=[Ak(t),...J_(t,e),q_(t),Uk(t),iS(t),NO(t)];return t.addChildren(n)}F({getParentRoute:()=>bo,path:`notifications`,head:()=>({meta:[{title:`Notifications — Harper Fabric`}]}),component:we(async()=>ne(()=>import(`./notifications-BHXLnh6x.js`),__vite__mapDeps([46,1,2,3,4,5,6])),`NotificationsCenter`)}),F({getParentRoute:()=>bo,path:`profile`,head:()=>({meta:[{title:`Profile — Harper Fabric`}]}),component:we(async()=>ne(()=>import(`./profile-8BeFSF3j.js`),__vite__mapDeps([47,1,26,3,2,4,5,6,7,27,12])),`ProfileIndex`)});var Gk=yo.addChildren([...Pc,bo.addChildren([Wk(`local`)])]);function Kk({routeTree:e=Gk,authentication:t}){let[n]=(0,W.useState)(()=>Ve({routeTree:e,history:ge(),defaultNotFoundComponent:yi,defaultErrorComponent:vi,defaultPreload:!bi()&&`intent`,trailingSlash:`never`,defaultPreloadStaleTime:0,scrollRestoration:!0,context:{queryClient:Ci,authentication:t||{}}}));return n}function qk(){let e=Sn(),t=Kk({authentication:e}),n=(0,W.useRef)(e);return(0,W.useEffect)(()=>{n.current!==e&&(n.current=e,t.invalidate())},[t,e]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Se,{router:t,context:{authentication:e}}),(0,G.jsx)(Ne,{router:t,position:`bottom-right`})]})}var Jk=({...e})=>(0,G.jsx)(rt,{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}),Yk=!1;function Xk(){(0,W.useEffect)(()=>{Yk||=!0},[])}function Zk(){return Co(),_o(),Xk(),(0,G.jsxs)(Aa,{children:[(0,G.jsxs)(fe,{client:Ci,children:[(0,G.jsx)(qk,{}),(0,G.jsx)(ze,{buttonPosition:`bottom-right`})]}),(0,G.jsx)(Jk,{richColors:!0})]})}function Qk(){u.signOutAllLocally(),Ci.getMutationCache().clear(),Ci.getQueryCache().clear(),qa(),Ja()}function $k(e,t=()=>!1,n=()=>!0){return r=>(r?.response?.status===401&&!t(r.config?.url??``)&&n(r.config)&&e(),Promise.reject(r))}var eA=[`/Login/`,`/ForgotPassword/`,`/ResetPassword/`,`/VerifyEmail/`,`/ResendVerificationEmail/`],tA=`authUserAtSend`;function nA(){let e=u.getConnectionById(m).user;return e&&`id`in e?e.id:null}var rA=!1;function iA(){rA||(rA=!0,M.interceptors.request.use(e=>(e[tA]=nA(),e)),M.interceptors.response.use(e=>e,$k(Qk,e=>eA.some(t=>e.startsWith(t)),e=>e?.[tA]===nA())))}function aA(){if(typeof Node!=`function`||!Node.prototype)return;let e=`__harperTranslationGuarded__`,t=Node.prototype;if(t[e])return;Object.defineProperty(t,e,{value:!0,configurable:!0,writable:!0,enumerable:!1});let n=Node.prototype.removeChild;Node.prototype.removeChild=function(e){return e instanceof Node&&e.parentNode!==this?e:n.call(this,e)};let r=Node.prototype.insertBefore;Node.prototype.insertBefore=function(e,t){return t instanceof Node&&t.parentNode!==this?r.call(this,e,null):r.call(this,e,t)}}var oA=`Studio:StaleDeployReloadedAt`,sA=6e4,cA=`__harperStaleDeployReloadState__`;function lA(){if(!(typeof window>`u`))return window[cA]}function uA(){let e=lA();if(e){try{let e=Number(sessionStorage.getItem(oA)??0);if(Date.now()-e<sA)return;sessionStorage.setItem(oA,String(Date.now()))}catch{return}e.reload()}}function dA(e=()=>window.location.reload()){if(typeof window>`u`)return;let t=window,n=t[cA];if(n){n.reload=e;return}t[cA]={reload:e},window.addEventListener(`vite:preloadError`,()=>uA())}var fA=ae();aA(),dA(),iA(),a(),u.installExplorerCrossTabCleanup(),(0,fA.createRoot)(document.getElementById(`root`),{onUncaughtError:(e,t)=>{re(e,t),console.error(`Uncaught error:`,e,t)},onCaughtError:(e,t)=>{re(e,t),console.error(`Caught error:`,e,t)},onRecoverableError:(e,t)=>{re(e,t),console.warn(`Recoverable error:`,e,t)}}).render((0,G.jsx)(W.StrictMode,{children:(0,G.jsx)(Zk,{})}));export{bx as $,Ai as $n,Zf as $t,rD as A,K as An,Qn as Ar,v_ as At,Aw as B,la as Bn,wn as Br,Um as Bt,oD as C,Y as Cn,Hr as Cr,Fv as Ct,QE as D,Qa as Dn,wr as Dr,Cv as Dt,eD as E,co as En,Tr as Er,wv as Et,HE as F,Da as Fn,On as Fr,Xh as Ft,xC as G,na as Gn,rm as Gt,vw as H,ga as Hn,En as Hr,Dm as Ht,gE as I,Ea as In,Mn as Ir,Yh as It,GS as J,Wi as Jn,nm as Jt,CC as K,ra as Kn,sm as Kt,NT as L,va as Ln,jn as Lr,Zh as Lt,WE as M,Ba as Mn,Yn as Mr,Ug as Mt,zE as N,Ha as Nn,Rn as Nr,Fg as Nt,iD as O,Ya as On,lr as Or,yv as Ot,UE as P,Va as Pn,Ln as Pr,Qh as Pt,Lx as Q,Di as Qn,qf as Qt,Iw as R,_a as Rn,kn as Rr,Jh as Rt,ZE as S,X as Sn,Ur as Sr,zv as St,cD as T,q as Tn,Ar as Tr,Av as Tt,nw as U,fa as Un,pm as Ut,Ow as V,ma as Vn,Dn as Vr,km as Vt,SC as W,ta as Wn,tm as Wt,AS as X,Oi as Xn,Jp as Xt,JS as Y,wi as Yn,im as Yt,_S as Z,Ei as Zn,_p as Zt,kD as _,os as _n,Jr as _r,py as _t,Ik as a,od as an,Si as ar,Jb as at,aD as b,Z as bn,Gr as br,Hv as bt,ck as c,vu as cn,hi as cr,ex as ct,oO as d,Lc as dn,ui as dr,Cy as dt,$f as en,ji as er,hx as et,KD as f,zc as fn,ci as fr,xy as ft,MD as g,Rc as gn,Xr as gr,my as gt,ND as h,Uc as hn,Qr as hr,fy as ht,Pk as i,vd as in,Ti as ir,qb as it,nD as j,Ga as jn,Xn as jr,d_ as jt,$E as k,Wa as kn,sr as kr,Q_ as kt,ZO as l,_u as ln,pi as lr,pb as lt,jD as m,Hc as mn,ti as mr,by as mt,Hk as n,Yf as nn,Pi as nr,ix as nt,Fk as o,Bu as on,Ci as or,tx as ot,UD as p,Bc as pn,si as pr,Sy as pt,bC as q,Ji as qn,am as qt,Rk as r,bd as rn,Ni as rr,Wb as rt,Lk as s,zu as sn,vi as sr,Yb as st,uA as t,Xf as tn,Mi as tr,rx as tt,XO as u,qc as un,fi as ur,cb as ut,DD as v,$ as vn,qr as vr,ly as vt,sD as w,J as wn,jr as wr,jv as wt,XE as x,Ro as xn,Wr as xr,Bv as xt,ED as y,Q as yn,Kr as yr,oy as yt,Fw as z,ua as zn,An as zr,yh as zt};
824
+ disabled:pointer-events-none disabled:opacity-50 dark:bg-grey-700 dark:text-white`})]})}function yO({pageSize:e,onChange:t}){return(0,G.jsxs)(`div`,{className:`hidden items-center gap-2 @min-[960px]:flex`,children:[(0,G.jsx)(`span`,{className:`text-sm whitespace-nowrap text-muted-foreground`,children:`Rows`}),(0,G.jsxs)(qf,{value:String(e),onValueChange:e=>t(Number(e)),children:[(0,G.jsx)(Xf,{"aria-label":`Rows per page`,className:`h-9 w-20`,children:(0,G.jsx)(Yf,{})}),(0,G.jsx)(Zf,{side:`top`,children:mO.map(e=>(0,G.jsx)($f,{value:String(e),children:vp(e)},e))})]})]})}function bO(e,t,n=1){if(t<=n*2+5)return xO(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?[...xO(1,s),`ellipsis`,t]:a&&!o?[1,`ellipsis`,...xO(t-s+1,t)]:[1,`ellipsis`,...xO(r,i),`ellipsis`,t]}function xO(e,t){return Array.from({length:t-e+1},(t,n)=>e+n)}function SO({applyFilters:e,columnFiltersForm:t,columns:n,columnVisibility:r,columnSizing:i,setColumnSizing:a,data:o,isFetching:s,onColumnClick:c,onRowClick:l,pageIndex:u,pageSize:d,primaryKey:f,resultSetKey:p,tableIdentity:m,setPageIndex:h,setPageSize:g,filtersToggled:_,totalPages:v,totalRecords:y,isEstimatedCount:b,estimatedRange:x,isExactCountFetching:S,isExactCountError:C,onRequestExactCount:w}){let T=Le({features:cm,data:o||[],columns:n,manualSorting:!0,enableColumnResizing:!0,columnResizeMode:`onEnd`,onColumnSizingChange:a,defaultColumn:{minSize:80},state:{columnVisibility:r,columnSizing:i}}),E=(0,W.useRef)(null),[D,O]=(0,W.useState)(0);(0,W.useLayoutEffect)(()=>{let e=E.current;e&&(e.scrollTop=0)},[p]),(0,W.useLayoutEffect)(()=>{let e=E.current;e&&(e.scrollTop=0,e.scrollLeft=0)},[m]);let k=T.state.columnResizing,A=k.isResizingColumn;(0,W.useLayoutEffect)(()=>{A&&O(E.current?.scrollLeft??0)},[A]);let j=null;if(A){let e=T.options.defaultColumn?.minSize??20,t=T.getColumn(A)?.getSize()??0,n=0;for(let e of T.getVisibleLeafColumns())if(n+=e.getSize(),e.id===A)break;j=n+Math.max(k.deltaOffset??0,e-t)-D}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`relative flex flex-col grow min-h-0`,children:[(0,G.jsxs)(tm,{containerRef:E,containerClassName:`rounded-md bg-card dark:bg-black-dark grow min-h-0 overflow-y-auto`,className:`table-fixed`,children:[(0,G.jsx)(nm,{children:T.getHeaderGroups().map(e=>(0,G.jsxs)(im,{className:`border-none`,children:[e.headers.map(e=>(0,G.jsx)(om,{header:e,onColumnClick:c,className:`sticky top-0 z-10 bg-card dark:bg-black-dark border-b border-border`},e.id)),(0,G.jsx)(am,{"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))}),_&&(0,G.jsx)(lO,{applyFilters:e,columnFiltersForm:t,headerGroups:T.getHeaderGroups()}),(0,G.jsx)(rm,{className:`bg-background dark:bg-black border border-border dark:border-grey-700`,children:T.getRowModel().rows?.length?T.getRowModel().rows.map(e=>(0,G.jsx)(CO,{row:e,onRowClick:l,primaryKey:f},e.id)):(0,G.jsx)(im,{children:(0,G.jsx)(sm,{colSpan:n.length+1,className:`h-24 text-center`,children:s||o===void 0?(0,G.jsx)(pO,{className:`opacity-50 inline-block`}):(0,G.jsx)(`span`,{children:`No results.`})})})})]}),j!==null&&(0,G.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute top-0 bottom-0 z-20 w-0.5 bg-primary`,style:{left:`${j}px`}})]}),(0,G.jsx)(hO,{pageIndex:u,pageSize:d,totalPages:v,totalRecords:y,isEstimatedCount:b,estimatedRange:x,isExactCountFetching:S,isExactCountError:C,onRequestExactCount:w,setPageIndex:h,setPageSize:g})]})}function CO({row:e,primaryKey:t,onRowClick:n}){let r=e.getVisibleCells(),i=(0,W.useMemo)(()=>{let n=e.original;return n&&n.message===`This entry has expired`?r[0]?.column?.id===t?[(0,G.jsx)(wO,{cell:r[0]},r[0].id),(0,G.jsx)(TO,{colSpan:r.length-1},`expired`)]:[(0,G.jsx)(TO,{colSpan:r.length},`expired`)]:r.map(e=>(0,G.jsx)(wO,{cell:e},e.id))},[e,t,r]);return(0,G.jsxs)(im,{"data-state":e.getIsSelected()&&`selected`,onClick:()=>n?.(e),className:N(`hover:bg-muted/10 data-[state=selected]:bg-muted`,n&&`cursor-pointer`),children:[i,(0,G.jsx)(sm,{"aria-hidden":!0,className:`p-0`})]})}function wO({cell:e}){let t=e.column.getSize();return(0,G.jsx)(sm,{"data-col-id":e.column.id,style:{width:`${t}px`,maxWidth:`${t}px`},className:`px-2 py-2 overflow-hidden text-ellipsis whitespace-nowrap`,children:Me(e.column.columnDef.cell,e.getContext())})}function TO({colSpan:e}){return(0,G.jsx)(sm,{colSpan:e,className:`px-2 py-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,children:(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`This entry has expired`})})}function EO({instanceDatabaseMap:e,databaseName:t,tableName:n}){let r=z({strict:!1}),i=K(),{clusterId:a,instanceId:o}=r,{toggled:s,toggle:c}=UD(!0),l=En(`instance:update`),u=yu(o??a,t,n,`insert`),d=xu(o??a,t,n),f=yu(o??a,t,n,`update`),p=yu(o??a,t,n,`delete`),m=vu(),{data:h}=V(kw({...i,databaseName:t,tableName:n})),g=e?.[t],_=g?.[n],v=h??_,y=(0,W.useMemo)(()=>id(v?.attributes??[],`attribute`),[v]),{data:b}=V(ID(i)),{data:x}=V(Bv(i)),S=bu(o??a,t,n),C=tO(x?.version,S),w=C===void 0,T=b?.[t]?.[n],E=(0,W.useMemo)(()=>dS(v,g,T),[v,g,T]),D=(0,W.useMemo)(()=>gS(v,g),[v,g]),O=(0,W.useMemo)(()=>pS(v?.attributes,g),[v,g]),[k,A]=Kh(null,r),[j,ee]=(0,W.useState)(!1),[M,N]=Kh(null,r),te=(0,W.useMemo)(()=>(t?Object.keys(e?.[t]||[]).sort():[]).length===1,[e,t]),{toggled:ne,toggleOn:re,toggleOff:ie}=UD(!1),ae=Pt({resolver:Ke(cO)}),{reset:oe}=ae,se=ae.watch(),[F,I]=Kh(null,[r.clusterId,r.instanceId,t,n]),ce=(0,W.useCallback)(e=>{let t=[];for(let n in e){let r=e[n];if(r?.length)try{t.push(...yw(n,r,y[n],E[n]))}catch(e){H.error(String(e))}}return t},[y,E]),le=(0,W.useCallback)(()=>{let e=ce(se);I(e.length?e:null),oe({...se})},[ce,oe,se]),ue=(0,W.useCallback)(()=>{oe({},{keepValues:!1,keepDirtyValues:!1,keepDefaultValues:!1}),oe(),I(null),ie()},[ie,oe]);(0,W.useEffect)(function(){return ue()},[r,ue]);let{filters:de}=he({strict:!1}),L=JSON.stringify([t,n,de??null]),fe=(0,W.useRef)(null);(0,W.useEffect)(function(){if(!v||fe.current===L)return;let e=fe.current===null;if(fe.current=L,de){oe({...de});let e=ce(de);I(e.length?e:null),re()}else e||ue()},[de,L,v,oe,ce,I,re,ue]);let{dataTableColumns:R,primaryKey:pe}=sw(v,E),[me,ge]=Kh({attribute:pe,descending:!1},r),[_e,ve]=Kh(0,[t,n,F]),[ye,be]=(0,W.useState)(20),xe=h?.record_count??_?.record_count,Se=h?.estimated_record_range??_?.estimated_record_range,[Ce,we]=Kh(!1,[t,n]),{data:Te,isFetching:Ee,isError:De,refetch:Oe}=V(ZD({...i,enabled:Ce,databaseName:t,tableName:n})),ke=(0,W.useCallback)(()=>{Ce?Oe():we(!0)},[Ce,Oe,we]),Ae=Te??xe,je=Ae?Math.ceil(Ae/ye):0,Me=Te===void 0&&Se!==void 0,Ne=ne&&!!F,Pe=`${t}.${n}`,Fe=JSON.stringify([Pe,_e,ye,me,Ne?F:null]),Le=Pg({...i,enabled:!Ne&&!!pe,databaseName:t,tableName:n,searchAttribute:pe,sort:me,pageSize:ye,pageIndex:_e,onlyIfCached:s,getAttributes:D}),{data:Re,isFetching:ze}=V(Le),Be=_w({...i,enabled:Ne&&!!pe,databaseName:t,tableName:n,conditions:F,sort:me,pageSize:ye,pageIndex:_e,onlyIfCached:s,getAttributes:D}),{data:Ve,isFetching:He}=V(Be),Ue=Ne?Ve:Re,We=ze||He,{data:Ge,isFetching:qe,isError:Je}=V(YD({...i,enabled:j,databaseName:t,tableName:n,ids:k})),Ye=j&&!!M&&(!pe||M[pe]==null),Xe=Ge?.data,Ze=!Ye&&!!k?.length&&!qe&&(Je||Array.isArray(Xe)&&Xe.length===0),{mutate:Qe,isPending:$e}=sO(),{mutate:et,isPending:tt}=qD(),{mutate:nt,isPending:rt}=iO(),{mutate:it,isPending:at}=GD(),ot=Ie(),st=(0,W.useCallback)(()=>ot.invalidateQueries({queryKey:[i.entityId,t,n]}),[ot,i.entityId,t,n]),ct=(0,W.useCallback)(()=>ot.invalidateQueries({queryKey:JD(i.entityId,t,n)}),[ot,i.entityId,t,n]),lt=(0,W.useCallback)(async()=>{confirm(`Are you sure you want to cleanup orphan blobs for database "${t}"?`)&&it({...i,databaseName:t},{onSuccess:e=>{H.success(e.message||`Orphan blobs cleanup started successfully`),st()},onError:e=>{H.error(e instanceof Error?e.message:`Failed to cleanup orphan blobs`)}})},[it,t,i,st]),{exportCsv:ut,isExporting:dt}=Tw(),ft=(0,W.useCallback)(()=>{ut({databaseName:t,tableName:n,primaryKey:pe,sort:me,conditions:Ne?F:null})},[ut,t,n,pe,me,Ne,F]),pt=(0,W.useCallback)(e=>{if(e?.wroteNothing){H.error(`The record wasn't updated`,{description:e.message});return}if(st(),ct(),ee(!1),e){H.error(`The record wasn't fully updated`,{description:e.message});return}H.success(`Record updated successfully`)},[st,ct]),mt=(0,W.useCallback)(e=>{Qe({...i,databaseName:t,tableName:n,records:e},{onSuccess:t=>pt(aO(t,e.length))})},[Qe,i,t,n,pt]),ht=(0,W.useCallback)(e=>{nt({...i,databaseName:t,tableName:n,records:e},{onSuccess:t=>pt(rO(t,e.length))})},[nt,i,t,n,pt]),gt=(0,W.useCallback)(e=>{et({...i,databaseName:t,tableName:n,hashValues:e},{onSuccess:()=>{st(),ee(!1),H.success(`Record deleted successfully`)}})},[et,i,t,n,st]),_t=e=>{let t=pe?e.original[pe]:void 0;N(e.original),A(t==null?null:[t]),ee(!0)},vt=(e,t)=>{ge({attribute:e,descending:!t})},yt=hm(st),bt=(0,W.useCallback)(()=>{xC(`ShowAddTableRecords`,{databaseName:t,tableName:n})},[t,n]),xt=(0,W.useCallback)(()=>{xC(`ShowImportData`,{databaseName:t,tableName:n})},[t,n]),[St,Ct]=Qh(`ColumnDisplayed/${t}/${n}`,{}),wt=(0,W.useMemo)(()=>({...Object.fromEntries(hS(E).map(e=>[e,!1])),...St}),[E,St]),[Tt,Et]=Qh(`ColumnSizing/${t}/${n}`,{});return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`shrink-0 flex flex-col md:flex-row md:flex-wrap items-center justify-between gap-3 pt-15 pb-4 pr-4`,children:[(0,G.jsxs)(`div`,{className:`flex space-x-2`,children:[u&&(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:bt,accessKey:`n`,children:[(0,G.jsx)(Gr,{}),(0,G.jsxs)(`span`,{children:[`Add `,(0,G.jsx)(`u`,{children:`N`}),`ew Record(s)`]})]}),d&&(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:xt,accessKey:`i`,children:[(0,G.jsx)(ar,{}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`I`}),`mport Data`]})]}),(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:ft,disabled:dt,accessKey:`e`,children:[(0,G.jsx)(ir,{}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`E`}),`xport CSV`]})]})]}),(0,G.jsxs)(`div`,{className:`flex space-x-2`,children:[ne&&F&&(0,G.jsxs)(P,{type:`button`,variant:`ghost`,onClick:ue,accessKey:`f`,children:[(0,G.jsx)(_r,{className:`inline-block `}),(0,G.jsxs)(`span`,{children:[`Clear `,(0,G.jsx)(`u`,{children:`F`}),`ilters`]})]}),ne&&ae.formState.isDirty&&(0,G.jsxs)(P,{variant:`default`,onClick:le,children:[(0,G.jsx)(hr,{className:`inline-block `}),`Apply Filters`]}),ne&&!F&&(0,G.jsxs)(P,{variant:`ghost`,onClick:ie,accessKey:`f`,children:[(0,G.jsx)(_r,{className:`inline-block `}),(0,G.jsxs)(`span`,{children:[`Hide `,(0,G.jsx)(`u`,{children:`F`}),`ilters`]})]}),!ne&&(0,G.jsxs)(P,{variant:`ghost`,onClick:re,accessKey:`f`,children:[(0,G.jsx)(gr,{className:`inline-block `}),(0,G.jsxs)(`span`,{children:[`Show `,(0,G.jsx)(`u`,{children:`F`}),`ilters`]})]}),(0,G.jsx)(P,{variant:`defaultOutline`,onClick:yt,disabled:We,children:(0,G.jsx)(Kr,{})}),(0,G.jsx)(dO,{columns:R,columnVisibility:wt,setColumnVisibility:Ct}),(0,G.jsxs)(wi,{children:[(0,G.jsx)(Ti,{asChild:!0,disabled:!e,children:(0,G.jsx)(P,{variant:`ghost`,size:`icon`,disabled:!e,children:(0,G.jsx)(ur,{"aria-label":`Table options`})})}),(0,G.jsxs)(Ei,{side:`bottom`,align:`end`,children:[(0,G.jsxs)(Di,{className:`focus:bg-primary/70 focus:text-white`,onClick:c,children:[s?(0,G.jsx)(Zn,{className:`text-green`}):(0,G.jsx)(er,{}),`Only If Cached`,(0,G.jsx)(B,{to:`https://docs.harperdb.io/docs/developers/applications/caching#cache-control-header`,target:`_blank`,rel:`noopener noreferrer`,onClick:nw,children:(0,G.jsx)(dr,{})})]}),m&&l&&!!o&&(0,G.jsxs)(Di,{className:`focus:bg-yellow/70 focus:text-white`,onClick:lt,disabled:at,children:[(0,G.jsx)(Un,{className:`text-yellow `}),`Cleanup Orphan Blobs`]}),m&&!te&&(0,G.jsxs)(Di,{className:`focus:bg-red/70 focus:text-white`,onClick:()=>xC(`ShowDeleteTable`,{databaseName:t,tableName:n}),children:[(0,G.jsx)(fi,{className:`inline-block `}),`Drop Table`]}),m&&(0,G.jsxs)(Di,{className:`focus:bg-red/70 focus:text-white`,onClick:()=>xC(`ShowDeleteDatabase`,{databaseName:t}),children:[(0,G.jsx)(fi,{}),`Drop Database`]})]})]})]})]}),(0,G.jsx)(SO,{primaryKey:pe,data:Ue?.data,isFetching:We,filtersToggled:ne,columns:R,columnVisibility:wt,columnSizing:Tt,setColumnSizing:Et,onRowClick:_t,onColumnClick:vt,totalPages:je,totalRecords:Ae,isEstimatedCount:Me,estimatedRange:Se,isExactCountFetching:Ee,isExactCountError:De,onRequestExactCount:ke,pageIndex:_e,pageSize:ye,resultSetKey:Fe,tableIdentity:Pe,columnFiltersForm:ae,applyFilters:le,setPageIndex:ve,setPageSize:be}),(0,G.jsx)(HD,{canEditRecords:f,canDeleteRecords:p,canReplaceRecords:w,replaceBlockedReason:C,setIsModalOpen:ee,isModalOpen:j,primaryKey:pe,missingPrimaryKey:Ye,recordUnavailable:Ze,syntheticAttributes:O,data:Ye||Ze?M?[M]:void 0:Ge?.data,onSaveChanges:mt,onReplaceRecord:ht,onDeleteRecord:gt,isUpdateTableRecordsPending:$e||rt,isDeleteTableRecordsPending:tt})]})}function DO(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 OO=10;function kO(e){return Math.max(200,Math.floor(e/2))}function AO(e,t){return Math.round(Math.min(Math.max(e,200),kO(t)))}function jO(){let[e,t]=xn(vn.DatabasesSidebarWidth,320),[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(()=>AO(e,window.innerWidth)),o=(0,W.useRef)(i);o.current=i;let s=(0,W.useRef)(null);(0,W.useEffect)(()=>{n||a(AO(e,window.innerWidth))},[e,n]),(0,W.useEffect)(()=>{let t=()=>{n||a(AO(e,window.innerWidth))};return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e,n]);let c=(0,W.useCallback)(e=>{e.preventDefault(),s.current={startX:e.clientX,startWidth:o.current},r(!0)},[]);return(0,W.useEffect)(()=>{if(!n)return;let e=e=>{let t=s.current;t&&a(AO(t.startWidth+(e.clientX-t.startX),window.innerWidth))},i=()=>{r(!1),t(o.current)},c=document.body.style.userSelect;return document.body.style.userSelect=`none`,window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,i),()=>{document.body.style.userSelect=c,window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,i)}},[n,t]),{width:i,isResizing:n,startResizing:c,handleKeyDown:(0,W.useCallback)(e=>{e.key===`ArrowLeft`?(e.preventDefault(),t(e=>AO(e-OO,window.innerWidth))):e.key===`ArrowRight`&&(e.preventDefault(),t(e=>AO(e+OO,window.innerWidth)))},[t])}}function MO(){let e=z({strict:!1}),t=K(),{data:n}=V(lb({...t,skipRecordCount:!0})),{width:r,isResizing:i,startResizing:a,handleKeyDown:o}=jO(),s={"--db-sidebar-width":`${r}px`},c=DO(n,e);return c?(0,G.jsx)(ce,{to:aS({...e,...c}),replace:!0}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`main`,{className:`flex flex-col gap-4 md:flex-row md:items-start`,children:[(0,G.jsxs)(`section`,{style:s,className:`relative text-foreground w-full md:w-[var(--db-sidebar-width)] md:shrink-0 md:border-r 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,G.jsx)(PE,{instanceDatabaseMap:n}),(0,G.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,"aria-valuenow":r,"aria-valuemin":200,"aria-valuemax":kO(window.innerWidth),onMouseDown:a,onKeyDown:o,className:`group hidden md:block absolute top-0 bottom-0 right-0 w-4 translate-x-1/2 z-40 cursor-col-resize outline-none`,children:(0,G.jsx)(`div`,{className:N(`absolute inset-y-0 left-1/2 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`,i&&`bg-violet-400/60 dark:bg-violet-500/60`)})})]}),(0,G.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,G.jsx)(EO,{instanceDatabaseMap:n,databaseName:e.databaseName,tableName:e.tableName}):e.databaseName?(0,G.jsx)(`div`,{className:`min-h-0 grow overflow-y-auto`,children:(0,G.jsx)(Pw,{instanceDatabaseMap:n,databaseName:e.databaseName})}):null})]}),n&&(0,G.jsx)(tw,{instanceDatabaseMap:n})]})}function NO(e){return F({getParentRoute:()=>e,path:`/databases/{-$databaseName}/{-$tableName}`,head:()=>({meta:[{title:`Databases — Harper Fabric`}]}),component:MO})}var PO={className:`text-primary font-semibold bg-primary/10 rounded-md dark:text-white dark:bg-white/10`};function FO(){let e=_u(),t=z({strict:!1}),{version:n}=oe({strict:!1}),r=qc(`4.6.0`,n)&&e,i=qc(`4.7.0-beta.7`,n),a=K(),{data:o}=V(v_(a,r)),s=o?.restartRequired??!1,c=(0,W.useMemo)(()=>[e&&{to:t.clusterId&&!t.instanceId?jv(t,`apps`):jv(t),activeOptions:{exact:!0},name:`Applications`,shortName:`Apps`,icon:(0,G.jsx)(Hr,{className:`inline-block`})},{to:jv(t,`databases`),icon:(0,G.jsx)(lr,{className:`inline-block`}),name:`Databases`},e&&i&&{to:jv(t,`apis`),name:`APIs`,icon:(0,G.jsx)($r,{className:`inline-block`})},e&&r&&{to:jv(t,`status`),icon:(0,G.jsx)(vr,{className:`inline-block`}),name:`Status`},e&&{to:jv(t,`logs`),icon:(0,G.jsx)(Br,{className:`inline-block`}),name:`Logs`},e&&{to:jv(t,`config`),icon:(0,G.jsx)(ei,{className:`inline-block`}),name:`Config`}].filter(Qa),[e,t,i,r]);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(IO,{links:c,restartRequired:s}),(0,G.jsx)(LO,{links:c,restartRequired:s})]})}function IO({links:e,restartRequired:t}){return(0,G.jsxs)(`div`,{className:`hidden md:[@media(hover:hover)]:flex xl:flex items-center justify-between h-full text-sm text-foreground`,children:[(0,G.jsx)(Po,{restartRequired:t}),(0,G.jsx)(`div`,{className:`flex space-x-2`,children:e.map(({shortName:e,...t})=>{let n=(0,G.jsxs)(B,{"aria-label":t.name,className:`p-2 text-center text-muted-foreground hover:text-foreground`,activeProps:PO,...t,children:[t.icon,(0,G.jsx)(`span`,{className:`hidden xl:inline-block ml-1`,children:t.name}),e&&(0,G.jsx)(`span`,{className:`visible xl:hidden ml-1`,children:e})]},t.to);return e?n:(0,G.jsxs)(Ba,{children:[(0,G.jsx)(Va,{asChild:!0,children:n}),(0,G.jsx)(Ha,{side:`bottom`,className:`xl:hidden`,children:t.name})]},t.to)})})]})}function LO({links:e,restartRequired:t}){return(0,G.jsx)(G.Fragment,{children:(0,G.jsxs)(`div`,{className:`flex md:[@media(hover:hover)]:hidden xl:hidden items-center justify-between h-full px-2 text-foreground`,children:[(0,G.jsx)(Po,{restartRequired:t}),(0,G.jsxs)(wi,{children:[(0,G.jsx)(Ti,{asChild:!0,children:(0,G.jsx)(P,{variant:`ghost`,className:`p-0`,children:(0,G.jsx)(Lr,{className:`h-8 w-8`})})}),(0,G.jsxs)(Ei,{children:[(0,G.jsx)(ki,{children:`Instance Menu`}),(0,G.jsx)(Ai,{}),e.map(e=>(0,G.jsx)(Di,{asChild:!0,children:(0,G.jsxs)(B,{to:e.to,activeProps:PO,className:`flex items-center gap-2`,children:[e.icon,e.name]})},e.to))]})]})]})})}(0,W.lazy)(()=>ne(()=>import(`./FloatingChat-omlNMDcJ.js`).then(e=>({default:e.FloatingChat})),__vite__mapDeps([35,1,4,5,9,11,12,13])));function RO(){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`nav`,{className:`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,G.jsx)(FO,{})}),(0,G.jsx)(`div`,{className:`mt-32 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,G.jsx)(He,{})}),!1]})}function zO(e){switch(e){case`local`:return F({getParentRoute:()=>bo,id:`_instanceLayout`,component:RO,loader:rS});case`cluster`:return F({getParentRoute:()=>ig,id:`_instanceLayout`,component:RO,beforeLoad:BO,loader:rS});case`instance`:return F({getParentRoute:()=>ig,path:`instance/$instanceId`,component:RO,beforeLoad:BO,loader:rS})}}async function BO({context:e,params:t}){let n=t.instanceId||t.clusterId,r=!1;if(u.checkForFabricConnect(n)&&!u.hasResolvedFabricConnect(n)&&(r=!0,await VO(n,e.cluster,t.instanceId)))return;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?hu(a.user,t.organizationId,t.clusterId):fu(a.user,t.organizationId,t.clusterId);if(!r&&o&&await VO(n,e.cluster,t.instanceId))return;let s=`/${t.organizationId}/${t.clusterId}/`+(t.instanceId?`instance/${t.instanceId}`:``)+`/sign-in`;throw le({to:s,search:uo()})}async function VO(e,t,n){try{return await u.establishFabricConnectAuth({id:e,operationsUrl:HO(t,n)}),!0}catch(e){return console.debug(`Fabric Connect not established`,e),!1}}function HO(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 UO(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 WO=[`secondary`,`default`,`warning`,`outline`,`success`,`destructive`],GO=0,KO=new Map,qO=e=>{if(KO.has(e))return KO.get(e);GO++;let t=WO[GO%WO.length];return KO.set(e,t),t};function JO(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 YO({columns:e,data:t,onRowClick:n,containerRef:r}){let i=Le({features:cm,data:t,columns:e});return(0,G.jsxs)(tm,{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,G.jsx)(nm,{children:i.getHeaderGroups().map(e=>(0,G.jsx)(im,{className:`border-b border-border`,children:e.headers.map(e=>(0,G.jsx)(am,{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:Me(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,G.jsx)(rm,{className:`bg-background dark:bg-black`,children:i.getRowModel().rows?.length?i.getRowModel().rows.map(e=>(0,G.jsx)(im,{"data-state":e.getIsSelected()&&`selected`,className:N(`hover:bg-muted/20 data-[state=selected]:bg-muted max-w-full border-l-2`,JO(e.original.level),n&&`cursor-pointer`),onClick:()=>n?.(e),children:e.getVisibleCells().map(e=>(0,G.jsx)(sm,{className:`p-2`,children:Me(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,G.jsx)(im,{children:(0,G.jsx)(sm,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})}var XO=524288,ZO=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 QO(e){try{JSON.parse(e)}catch{return!1}return!0}function $O(e){return!e||e.length>524288?`plaintext`:QO(e)?`json`:`plaintext`}function ek({label:e,children:t}){return(0,G.jsxs)(`div`,{className:`flex items-start gap-3 py-1.5 border-b border-border/50 last:border-0`,children:[(0,G.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground w-20 shrink-0 pt-0.5`,children:e}),(0,G.jsx)(`span`,{className:`text-xs`,children:t})]})}function tk({setIsModalOpen:e,isModalOpen:t,data:n}){let r=n?qO(n.node):`default`,i=Dm();return(0,G.jsx)(fn,{onOpenChange:e,open:t,children:(0,G.jsxs)(cn,{"aria-describedby":void 0,resizable:!0,children:[(0,G.jsx)(rn,{children:(0,G.jsx)(ln,{children:`Log Entry`})}),n?(0,G.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 text-popover-foreground`,children:[(0,G.jsxs)(`div`,{className:`rounded-md border border-border/50 bg-muted/20 px-3 py-1`,children:[(0,G.jsx)(ek,{label:`Level`,children:(0,G.jsx)(Ji,{variant:UO(n.level),children:Mo(n.level)})}),(0,G.jsx)(ek,{label:`Timestamp`,children:(0,G.jsx)(`span`,{className:`tabular-nums`,children:new Date(n.timestamp).toLocaleString()})}),(0,G.jsx)(ek,{label:`Thread`,children:(0,G.jsx)(`span`,{className:`tabular-nums font-mono`,children:n.thread})}),n.node&&(0,G.jsx)(ek,{label:`Node`,children:(0,G.jsx)(Ji,{variant:r,children:n.node})}),n.tags&&n.tags.length>0&&(0,G.jsx)(ek,{label:`Tags`,children:(0,G.jsx)(`span`,{className:`font-mono`,children:n.tags})})]}),(0,G.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`Message`}),(0,G.jsx)(`div`,{className:`rounded-md overflow-hidden border border-border/50 flex-1 min-h-0`,children:(0,G.jsx)(km,{className:`w-full h-full`,language:$O(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,G.jsx)(Wi,{})]})})}var nk=S({limit:A().or(w()).or(E()).optional(),level:O([`notify`,`error`,`warn`,`info`,`debug`,`trace`,`undefined`]).or(w()).or(E()).optional(),from:A().or(w()).or(E()).optional(),until:A().or(w()).or(E()).optional(),log_name:O([`hdb.log`,`system.log`]).or(w()).or(E()).optional(),filter:A().or(w()).or(E()).optional()}),rk=`dark:bg-grey-600 dark:border-grey-500`;function ik({form:e,resetFilters:t,submitFilters:n,showLogName:r,showFilter:i,isOpen:a,onOpenChange:o}){return(0,G.jsxs)(On,{className:N(a?`block`:`hidden`,`mt-3 md:mt-0 md:block`),children:[(0,G.jsx)(kn,{className:`hidden md:block`,children:(0,G.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,G.jsxs)(An,{className:`flex items-center gap-2 text-base`,children:[(0,G.jsx)(ri,{className:`size-4 text-muted-foreground`}),`Filters`]})})}),(0,G.jsx)(Mn,{id:`logs-filters-content`,children:(0,G.jsx)(q,{...e,children:(0,G.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,G.jsx)(Y,{control:e.control,name:`filter`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(J,{children:(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(Qr,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,G.jsx)($,{type:`search`,placeholder:`Search logs…`,className:N(`pl-9`,rk),value:e.value??``,onChange:e.onChange})]})}),(0,G.jsx)(Q,{})]})}),r&&(0,G.jsx)(Y,{control:e.control,name:`log_name`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Log file`}),(0,G.jsxs)(qf,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,G.jsx)(Xf,{className:N(`w-full bg-white`,rk),children:(0,G.jsx)(Yf,{placeholder:`Select log file`})}),(0,G.jsx)(Zf,{children:(0,G.jsxs)(Jf,{children:[(0,G.jsx)($f,{value:`hdb.log`,children:`Application (hdb.log)`}),(0,G.jsx)($f,{value:`system.log`,children:`System (system.log)`})]})})]}),(0,G.jsx)(Q,{})]})}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,G.jsx)(Y,{control:e.control,name:`limit`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Limit`}),(0,G.jsxs)(qf,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,G.jsx)(Xf,{className:N(`w-full bg-white`,rk),children:(0,G.jsx)(Yf,{placeholder:`Limit`})}),(0,G.jsx)(Zf,{children:(0,G.jsxs)(Jf,{children:[(0,G.jsx)($f,{value:`1000`,children:`1000`}),(0,G.jsx)($f,{value:`500`,children:`500`}),(0,G.jsx)($f,{value:`250`,children:`250`}),(0,G.jsx)($f,{value:`100`,children:`100`}),(0,G.jsx)($f,{value:`10`,children:`10`})]})})]}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:e.control,name:`level`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Level`}),(0,G.jsxs)(qf,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,G.jsx)(Xf,{className:N(`w-full bg-white`,rk),children:(0,G.jsx)(Yf,{placeholder:`Level`})}),(0,G.jsx)(Zf,{children:(0,G.jsxs)(Jf,{children:[(0,G.jsx)($f,{value:`undefined`,children:`All`}),(0,G.jsx)($f,{value:`notify`,children:`Notify`}),(0,G.jsx)($f,{value:`error`,children:`Error`}),(0,G.jsx)($f,{value:`warn`,children:`Warn`}),(0,G.jsx)($f,{value:`info`,children:`Info`}),(0,G.jsx)($f,{value:`debug`,children:`Debug`}),(0,G.jsx)($f,{value:`trace`,children:`Trace`})]})})]}),(0,G.jsx)(Q,{})]})})]}),(0,G.jsx)(Y,{control:e.control,name:`from`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Start date`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`datetime-local`,className:rk,value:e.value??void 0,onChange:e.onChange})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:e.control,name:`until`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`End date`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`datetime-local`,className:rk,value:e.value??void 0,onChange:e.onChange})}),(0,G.jsx)(Q,{})]})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,G.jsx)(P,{type:`submit`,variant:`positiveOutline`,className:`grow`,children:`Apply Filters`}),(0,G.jsx)(P,{type:`reset`,variant:`destructiveOutline`,onClick:t,children:`Clear`})]})]})})})]})}var ak=1e4;function ok(e){if(!e)return;let t=parseInt(e,10);if(!(!Number.isFinite(t)||t<=0))return Math.min(t,ak)}function sk(e,t){return{operation:`read_log`,start:0,replicated:t,limit:ok(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 ck({instanceClient:e,logFilters:t,replicated:n}){let{data:r}=await e.post(`/`,sk(t,n));return r}function lk(e){let t=e.logFilters;return R({queryKey:[`read_log`,e.entityId,t.limit,t.level,t.from,t.until,t.log_name,t.filter,e.replicated],queryFn:()=>ck(e),retry:!1,refetchInterval:e.isAutoRefreshEnabled?5e3:!1})}async function uk({connection:e,logFilters:t,replicated:n,signal:r,onEntry:i}){let{url:a,headers:o,credentials:s}=Ev(e),c;try{c=await fetch(a,{method:`POST`,headers:o,credentials:s,body:JSON.stringify(sk(t,n)),signal:r})}catch(e){throw r?.aborted?e:new Cv(`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 Cv(`read_log did not return an event stream (status ${c.status}, content-type "${l}").`);for await(let e of bv(c.body,r)){if(e.event===`error`){let t=Sv(e);if(!t||typeof t!=`object`)throw new Tv(typeof t==`string`&&t?t:`The log stream failed.`);let n=t;throw new Tv(n.message??`The log stream failed.`,{code:n.code})}if(e.event===`done`||e.event===`end`)return;for(let t of dk(Sv(e)))i(t)}}function dk(e){return Array.isArray(e)?e.filter(fk):fk(e)?[e]:[]}function fk(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 pk(e){return[e.timestamp,e.node??``,e.thread??``,e.level,e.message].join(`|`)}function mk(e,t,n){let r=new Set,i=[];for(let n of[...t,...e]){let e=pk(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 hk={entries:[],fellBack:!1};function gk(e,t){switch(t.kind){case`reset`:return hk;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 _k(){let e=K();return u.isDirectConnection(e.entityId)}var vk=1e3,yk=2e3,bk=250;function xk(e){return ok(e)??vk}function Sk(e,t){return JSON.stringify([e.limit,e.level,e.from,e.until,e.log_name,e.filter,t])}function Ck({params:e,logFilters:t,replicated:n,live:r}){let i=_k(),[a,o]=(0,W.useReducer)(gk,hk),s=r&&i&&!a.fellBack,c=Sk(t,n),l=xk(t.limit),u=Math.max(yk,l),d=V(lk({...e,logFilters:t,replicated:n,isAutoRefreshEnabled:r&&!s}));(0,W.useEffect)(()=>{o({kind:`reset`})},[e.entityId,c]),(0,W.useEffect)(()=>{r&&o({kind:`retry`})},[r]);let f=(0,W.useRef)({logFilters:t,replicated:n});f.current={logFilters:t,replicated:n},(0,W.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,bk);return uk({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,W.useMemo)(()=>{let e=d.data??[];return a.entries.length===0?e:mk(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 wk={log_name:`hdb.log`,limit:`100`,level:`undefined`,from:``,until:``,filter:``},Tk={error:(0,G.jsx)(Xn,{className:`size-3`}),stderr:(0,G.jsx)(Xn,{className:`size-3`}),warn:(0,G.jsx)(pi,{className:`size-3`}),notify:(0,G.jsx)(Vn,{className:`size-3`}),info:(0,G.jsx)(wr,{className:`size-3`}),debug:(0,G.jsx)(Wn,{className:`size-3`}),trace:(0,G.jsx)(Fn,{className:`size-3`}),stdout:(0,G.jsx)(ui,{className:`size-3`})},Ek=[{accessorKey:`level`,header:`Level`,cell:({row:e})=>{let{level:t}=e.original;return(0,G.jsxs)(Ji,{variant:UO(t),children:[Tk[t],Mo(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,G.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,G.jsx)(`span`,{className:`block max-w-xl truncate font-mono text-xs`,children:t})}},{accessorKey:`thread`,header:`Thread`,cell:({row:e})=>(0,G.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=qO(t);return(0,G.jsx)(G.Fragment,{children:t?(0,G.jsxs)(Ba,{children:[(0,G.jsx)(Va,{asChild:!0,children:(0,G.jsxs)(Ji,{variant:n,children:[t.split(`.`)[0],`...`]})}),(0,G.jsx)(Ha,{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,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null}}],Dk=(e,t)=>!e&&!t||!e||!t||new Date(e)<=new Date(t);function Ok(){return(0,G.jsxs)(`div`,{className:`rounded-md bg-card dark:bg-black-dark overflow-hidden`,children:[(0,G.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,G.jsx)(yh,{className:`h-4 ${e}`},t))}),Array.from({length:12}).map((e,t)=>(0,G.jsxs)(`div`,{className:`flex gap-4 p-3 border-b border-border/40 border-l-2 border-l-transparent`,children:[(0,G.jsx)(yh,{className:`h-5 w-14`}),(0,G.jsx)(yh,{className:`h-5 w-32`}),(0,G.jsx)(yh,{className:`h-5 w-10`}),(0,G.jsx)(yh,{className:`h-5 w-20`}),(0,G.jsx)(yh,{className:`h-5 w-12`}),(0,G.jsx)(yh,{className:`h-5 flex-1 max-w-xs`})]},t))]})}function kk(){let[e,t]=(0,W.useState)(wk),[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(),[o,s]=(0,W.useState)(!1),[c,l]=xn(vn.LogsOrderReversed,!1),[u,d]=(0,W.useState)(!1),f=K(),{data:p}=V(Bv(f)),m=p?.version,h=!!m&&qc(`4.7.16`,m),{logs:g,isLoading:_,isFetching:v,refetch:y,transport:b}=Ck({params:f,logFilters:e,replicated:f.entityType===`cluster`,live:o}),x=(0,W.useMemo)(()=>c?[...g??[]].reverse():g??[],[g,c]),S=(0,W.useRef)(null);(0,W.useEffect)(()=>{let e=S.current;_||!e||e.scrollTo({top:c?e.scrollHeight:0})},[c,_]),(0,W.useEffect)(()=>{let e=S.current;!o||_||!e||e.scrollTo({top:c?e.scrollHeight:0})},[x,o,c,_]);let C=Pt({resolver:Ke(nk),defaultValues:wk,mode:`onChange`}),w=e=>{a(e.original),r(!0)},T=async e=>{if(!Dk(e.from,e.until)){C.setError(`from`,{type:`onChange`,message:`Start date must be before end date`}),C.setError(`until`,{type:`onChange`,message:`End date must be after start date`});return}t(e)},E=async()=>{C.reset(),t(wk)},D=hm(y);return(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 pt-2 text-foreground md:grid-cols-12 md:gap-4`,children:[(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2 md:hidden`,children:[(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:()=>d(e=>!e),"aria-label":`Toggle filters`,"aria-expanded":u,className:`flex-1`,children:[(0,G.jsx)(ri,{}),`Filters`]}),(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:D,disabled:v||_||o,"aria-label":`Refresh logs`,className:`flex-1`,children:[(0,G.jsx)(Kr,{className:v?`animate-spin`:``}),`Refresh`]}),(0,G.jsxs)(P,{variant:c?`default`:`defaultOutline`,onClick:()=>l(e=>!e),"aria-label":`Reverse log order`,"aria-pressed":c,className:`flex-1`,children:[(0,G.jsx)(zn,{}),`Reverse`]})]}),(0,G.jsx)(ik,{form:C,resetFilters:E,submitFilters:T,showLogName:!1,showFilter:h,isOpen:u,onOpenChange:d}),(0,G.jsxs)(`div`,{className:`mt-3 space-y-3 hidden md:block`,children:[(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:D,disabled:v||_||o,className:`w-full`,children:[(0,G.jsx)(Kr,{}),`Refresh`]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,G.jsx)(Um,{id:`logs-live-switch`,"aria-label":`Toggle live logs`,checked:o,onCheckedChange:s}),(0,G.jsxs)(`label`,{htmlFor:`logs-live-switch`,className:`flex items-center gap-2 cursor-pointer`,children:[(0,G.jsx)(Kr,{className:`size-4 ${o?`animate-spin [animation-duration:3s]`:``}`}),o?b===`streaming`?`Live (streaming)`:`Live (polling every 5s)`:`Live`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,G.jsx)(Um,{id:`logs-reverse-order-switch`,"aria-label":`Reverse log order`,checked:c,onCheckedChange:l}),(0,G.jsxs)(`label`,{htmlFor:`logs-reverse-order-switch`,className:`flex items-center gap-2 cursor-pointer`,children:[(0,G.jsx)(zn,{className:`size-4`}),c?`Oldest first`:`Newest first`]})]})]})]})]}),(0,G.jsx)(`section`,{className:`col-span-1 md:col-span-8 lg:col-span-9`,children:_?(0,G.jsx)(Ok,{}):(0,G.jsx)(YO,{columns:Ek,data:x,onRowClick:w,containerRef:S})}),(0,G.jsx)(tk,{isModalOpen:n,setIsModalOpen:r,data:i})]})}function Ak(e){return F({getParentRoute:()=>e,path:`logs`,head:()=>({meta:[{title:`Logs — Harper Fabric`}]}),component:kk})}var jk=6e4,Mk=60*jk,Nk=24*Mk,Pk=[{id:`1h`,label:`Last 1 hour`,durationMs:Mk,bucketMs:1*jk,expandedBucketMs:1*jk},{id:`6h`,label:`Last 6 hours`,durationMs:6*Mk,bucketMs:2*jk,expandedBucketMs:1*jk},{id:`24h`,label:`Last 24 hours`,durationMs:Nk,bucketMs:10*jk,expandedBucketMs:5*jk},{id:`7d`,label:`Last 7 days`,durationMs:7*Nk,bucketMs:Mk,expandedBucketMs:15*jk},{id:`30d`,label:`Last 30 days`,durationMs:30*Nk,bucketMs:4*Mk,expandedBucketMs:Mk}];function Fk(e){let t=Pk.find(t=>t.id===e);if(!t)throw Error(`Unknown preset: ${e}`);return t}function Ik(e){let t=(e,t)=>`${e} ${t}${e===1?``:`s`}`;return e>=Mk&&e%Mk===0?t(e/Mk,`hour`):e>=jk&&e%jk===0?t(e/jk,`minute`):e>=1e3&&e%1e3==0?t(e/1e3,`second`):`${e} ms`}function Lk(e,t){let n=e=>t?.expanded?e.expandedBucketMs:e.bucketMs,r=n(Pk[0]);if(!Number.isFinite(e)||e<=0)return r;for(let t of Pk)if(e<=t.durationMs*1.01)return n(t);let i=Pk[Pk.length-1];return Math.max(r,Math.ceil(e/(i.durationMs/n(i))))}var Rk=[{label:`Off`,value:0},{label:`30s`,value:3e4},{label:`60s`,value:6e4},{label:`5m`,value:3e5}],zk=6e4,Bk=[`health`,`traffic`,`requests`,`database`,`replication`,`storage`,`overview`],Vk={tab:`health`,range:`1h`,refresh:zk};function Hk(e){let t=e.refresh===``?NaN:Number(e.refresh);return{tab:Bk.find(t=>t===e.tab)??Vk.tab,range:Pk.find(t=>t.id===e.range)?.id??Vk.range,refresh:Rk.find(e=>e.value===t)?.value??Vk.refresh}}function Uk(e){return F({getParentRoute:()=>e,path:`status`,validateSearch:Hk,search:{middlewares:[me(Vk)]},head:()=>({meta:[{title:`Status — Harper Fabric`}]}),component:we(async()=>ne(()=>import(`./status--aNm8isn.js`),__vite__mapDeps([36,1,3,2,4,5,6,7,9,8,10,11,12,13,16,31,37,38,39,40,41,42,43,44,29,45])),`StatusIndex`)})}function Wk(e){let t=zO(e),n=[Ak(t),...J_(t,e),q_(t),Uk(t),iS(t),NO(t)];return t.addChildren(n)}F({getParentRoute:()=>bo,path:`notifications`,head:()=>({meta:[{title:`Notifications — Harper Fabric`}]}),component:we(async()=>ne(()=>import(`./notifications-BfKBpYcq.js`),__vite__mapDeps([46,1,2,3,4,5,6])),`NotificationsCenter`)}),F({getParentRoute:()=>bo,path:`profile`,head:()=>({meta:[{title:`Profile — Harper Fabric`}]}),component:we(async()=>ne(()=>import(`./profile-Q4-T6c-S.js`),__vite__mapDeps([47,1,26,3,2,4,5,6,7,27,12])),`ProfileIndex`)});var Gk=yo.addChildren([...Pc,bo.addChildren([Wk(`local`)])]);function Kk({routeTree:e=Gk,authentication:t}){let[n]=(0,W.useState)(()=>Ve({routeTree:e,history:ge(),defaultNotFoundComponent:yi,defaultErrorComponent:vi,defaultPreload:!bi()&&`intent`,trailingSlash:`never`,defaultPreloadStaleTime:0,scrollRestoration:!0,context:{queryClient:Ci,authentication:t||{}}}));return n}function qk(){let e=Sn(),t=Kk({authentication:e}),n=(0,W.useRef)(e);return(0,W.useEffect)(()=>{n.current!==e&&(n.current=e,t.invalidate())},[t,e]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Se,{router:t,context:{authentication:e}}),(0,G.jsx)(Ne,{router:t,position:`bottom-right`})]})}var Jk=({...e})=>(0,G.jsx)(rt,{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}),Yk=!1;function Xk(){(0,W.useEffect)(()=>{Yk||=!0},[])}function Zk(){return Co(),_o(),Xk(),(0,G.jsxs)(Aa,{children:[(0,G.jsxs)(fe,{client:Ci,children:[(0,G.jsx)(qk,{}),(0,G.jsx)(ze,{buttonPosition:`bottom-right`})]}),(0,G.jsx)(Jk,{richColors:!0})]})}function Qk(){u.signOutAllLocally(),Ci.getMutationCache().clear(),Ci.getQueryCache().clear(),qa(),Ja()}function $k(e,t=()=>!1,n=()=>!0){return r=>(r?.response?.status===401&&!t(r.config?.url??``)&&n(r.config)&&e(),Promise.reject(r))}var eA=[`/Login/`,`/ForgotPassword/`,`/ResetPassword/`,`/VerifyEmail/`,`/ResendVerificationEmail/`],tA=`authUserAtSend`;function nA(){let e=u.getConnectionById(m).user;return e&&`id`in e?e.id:null}var rA=!1;function iA(){rA||(rA=!0,M.interceptors.request.use(e=>(e[tA]=nA(),e)),M.interceptors.response.use(e=>e,$k(Qk,e=>eA.some(t=>e.startsWith(t)),e=>e?.[tA]===nA())))}function aA(){if(typeof Node!=`function`||!Node.prototype)return;let e=`__harperTranslationGuarded__`,t=Node.prototype;if(t[e])return;Object.defineProperty(t,e,{value:!0,configurable:!0,writable:!0,enumerable:!1});let n=Node.prototype.removeChild;Node.prototype.removeChild=function(e){return e instanceof Node&&e.parentNode!==this?e:n.call(this,e)};let r=Node.prototype.insertBefore;Node.prototype.insertBefore=function(e,t){return t instanceof Node&&t.parentNode!==this?r.call(this,e,null):r.call(this,e,t)}}var oA=`Studio:StaleDeployReloadedAt`,sA=6e4,cA=`__harperStaleDeployReloadState__`;function lA(){if(!(typeof window>`u`))return window[cA]}function uA(){let e=lA();if(e){try{let e=Number(sessionStorage.getItem(oA)??0);if(Date.now()-e<sA)return;sessionStorage.setItem(oA,String(Date.now()))}catch{return}e.reload()}}function dA(e=()=>window.location.reload()){if(typeof window>`u`)return;let t=window,n=t[cA];if(n){n.reload=e;return}t[cA]={reload:e},window.addEventListener(`vite:preloadError`,()=>uA())}var fA=ae();aA(),dA(),iA(),a(),u.installExplorerCrossTabCleanup(),(0,fA.createRoot)(document.getElementById(`root`),{onUncaughtError:(e,t)=>{re(e,t),console.error(`Uncaught error:`,e,t)},onCaughtError:(e,t)=>{re(e,t),console.error(`Caught error:`,e,t)},onRecoverableError:(e,t)=>{re(e,t),console.warn(`Recoverable error:`,e,t)}}).render((0,G.jsx)(W.StrictMode,{children:(0,G.jsx)(Zk,{})}));export{bx as $,Ai as $n,Zf as $t,rD as A,K as An,Qn as Ar,v_ as At,Aw as B,la as Bn,wn as Br,Um as Bt,oD as C,Y as Cn,Hr as Cr,Fv as Ct,QE as D,Qa as Dn,wr as Dr,Cv as Dt,eD as E,co as En,Tr as Er,wv as Et,HE as F,Da as Fn,On as Fr,Xh as Ft,xC as G,na as Gn,rm as Gt,vw as H,ga as Hn,En as Hr,Dm as Ht,gE as I,Ea as In,Mn as Ir,Yh as It,GS as J,Wi as Jn,nm as Jt,CC as K,ra as Kn,sm as Kt,NT as L,va as Ln,jn as Lr,Zh as Lt,WE as M,Ba as Mn,Yn as Mr,Ug as Mt,zE as N,Ha as Nn,Rn as Nr,Fg as Nt,iD as O,Ya as On,lr as Or,yv as Ot,UE as P,Va as Pn,Ln as Pr,Qh as Pt,Lx as Q,Di as Qn,qf as Qt,Iw as R,_a as Rn,kn as Rr,Jh as Rt,ZE as S,X as Sn,Ur as Sr,zv as St,cD as T,q as Tn,Ar as Tr,Av as Tt,nw as U,fa as Un,pm as Ut,Ow as V,ma as Vn,Dn as Vr,km as Vt,SC as W,ta as Wn,tm as Wt,AS as X,Oi as Xn,Jp as Xt,JS as Y,wi as Yn,im as Yt,_S as Z,Ei as Zn,_p as Zt,kD as _,os as _n,Jr as _r,py as _t,Ik as a,od as an,Si as ar,Jb as at,aD as b,Z as bn,Gr as br,Hv as bt,ck as c,vu as cn,hi as cr,ex as ct,oO as d,Lc as dn,ui as dr,Cy as dt,$f as en,ji as er,hx as et,KD as f,zc as fn,ci as fr,xy as ft,MD as g,Rc as gn,Xr as gr,my as gt,ND as h,Uc as hn,Qr as hr,fy as ht,Pk as i,vd as in,Ti as ir,qb as it,nD as j,Ga as jn,Xn as jr,d_ as jt,$E as k,Wa as kn,sr as kr,Q_ as kt,ZO as l,_u as ln,pi as lr,pb as lt,jD as m,Hc as mn,ti as mr,by as mt,Hk as n,Yf as nn,Pi as nr,ix as nt,Fk as o,Bu as on,Ci as or,tx as ot,UD as p,Bc as pn,si as pr,Sy as pt,bC as q,Ji as qn,am as qt,Rk as r,bd as rn,Ni as rr,Wb as rt,Lk as s,zu as sn,vi as sr,Yb as st,uA as t,Xf as tn,Mi as tr,rx as tt,XO as u,qc as un,fi as ur,cb as ut,DD as v,$ as vn,qr as vr,ly as vt,sD as w,J as wn,jr as wr,jv as wt,XE as x,Ro as xn,Wr as xr,Bv as xt,ED as y,Q as yn,Kr as yr,oy as yt,Fw as z,ua as zn,An as zr,yh as zt};