@harperfast/harper 5.2.7 → 5.2.8

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 (48) hide show
  1. package/components/mcp/tools/application.ts +8 -4
  2. package/dist/components/mcp/tools/application.js +7 -4
  3. package/dist/components/mcp/tools/application.js.map +1 -1
  4. package/dist/resources/RocksTransactionLogStore.js +11 -1
  5. package/dist/resources/RocksTransactionLogStore.js.map +1 -1
  6. package/dist/resources/Table.js +2 -1
  7. package/dist/resources/Table.js.map +1 -1
  8. package/dist/resources/auditStore.d.ts +1 -0
  9. package/dist/resources/auditStore.js +1 -0
  10. package/dist/resources/auditStore.js.map +1 -1
  11. package/dist/resources/transactionBroadcast.js +5 -5
  12. package/dist/resources/transactionBroadcast.js.map +1 -1
  13. package/npm-shrinkwrap.json +43 -43
  14. package/package.json +3 -3
  15. package/resources/RocksTransactionLogStore.ts +11 -1
  16. package/resources/Table.ts +2 -1
  17. package/resources/auditStore.ts +3 -1
  18. package/resources/transactionBroadcast.ts +5 -5
  19. package/studio/web/assets/{Chat-etJeJv4a.js → Chat-DDlysEi_.js} +1 -1
  20. package/studio/web/assets/{FloatingChat-BvmHsuVo.js → FloatingChat-DdJ3DZJX.js} +3 -3
  21. package/studio/web/assets/{apiToken-Bl5LC8EH.js → apiToken-CrPb_98N.js} +1 -1
  22. package/studio/web/assets/{applications-Dta6Y0Rg.js → applications-C6Y4nL_X.js} +1 -1
  23. package/studio/web/assets/{cssMode-IAbO_2KK.js → cssMode-D8ceA4av.js} +1 -1
  24. package/studio/web/assets/{editor-CeRXEhRl.js → editor-C-jlLd1G.js} +1 -1
  25. package/studio/web/assets/{html-DOV4s_YT.js → html-BnuKFPjv.js} +1 -1
  26. package/studio/web/assets/{htmlMode-CdqjnAh4.js → htmlMode-DXM6YYUw.js} +1 -1
  27. package/studio/web/assets/{index-CTqasm6g.js → index-BtTvoLf8.js} +5 -5
  28. package/studio/web/assets/{index.lazy-VmcKgiEy.js → index.lazy-PVbC6xQh.js} +1 -1
  29. package/studio/web/assets/{javascript-Dj7yXfx5.js → javascript-CAuAkYxc.js} +1 -1
  30. package/studio/web/assets/{jsonMode-khk65qzx.js → jsonMode-Dny8hrU7.js} +1 -1
  31. package/studio/web/assets/{languageServices-D_06p7dw.js → languageServices-D1uNqC6s.js} +1 -1
  32. package/studio/web/assets/{lspLanguageFeatures-DTA6wyQw.js → lspLanguageFeatures-Bh-bvkyK.js} +1 -1
  33. package/studio/web/assets/{notifications-CBZXgxVc.js → notifications-DPTOF-SX.js} +1 -1
  34. package/studio/web/assets/{notifications-Bah46LXX.js → notifications-DsE0S3zT.js} +1 -1
  35. package/studio/web/assets/{profile-QspOun_j.js → profile-BIeCZr-w.js} +1 -1
  36. package/studio/web/assets/{regions-QdUi7bQ9.js → regions-B5lGduv5.js} +1 -1
  37. package/studio/web/assets/{register-Buvoxmb8.js → register-Cvc1TpmQ.js} +2 -2
  38. package/studio/web/assets/{setComponentFile-BI4E_iDe.js → setComponentFile-D8ZLDWhU.js} +1 -1
  39. package/studio/web/assets/{setup-Cop6LBQN.js → setup-D2az-Ue_.js} +2 -2
  40. package/studio/web/assets/{status-DRu3zRgl.js → status-BJegPrWN.js} +1 -1
  41. package/studio/web/assets/{toggleHighContrast-C0dJLmZ0.js → toggleHighContrast-BdIEw2rK.js} +1 -1
  42. package/studio/web/assets/{tsMode-dbDiapTA.js → tsMode-CulNMwI9.js} +1 -1
  43. package/studio/web/assets/{typescript-CT1826cL.js → typescript-BpRqjmvQ.js} +1 -1
  44. package/studio/web/assets/{useEntityRestURL-D1u1X_gE.js → useEntityRestURL-C7x-Yz9r.js} +1 -1
  45. package/studio/web/assets/{workers-FpR9_D2K.js → workers-B2WpJDK9.js} +1 -1
  46. package/studio/web/assets/{xml-ZjKUMjth.js → xml-CZnimVSX.js} +1 -1
  47. package/studio/web/assets/{yaml-B6gXbZU6.js → yaml-BwNuyZS-.js} +1 -1
  48. package/studio/web/index.html +1 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/notifications-CBZXgxVc.js","assets/rolldown-runtime-hePW80VL.js","assets/button-DhiX-njv.js","assets/vendor-core-RCcadM3e.js","assets/vendor-datadog-BRv-mOv1.js","assets/vendor-react-Dyj4O3HE.js","assets/vendor-ui-vhu-UHhF.js","assets/vendor-tanstack-BiFWSB3W.js","assets/dialog-CBf0Mr1d.js","assets/createLucideIcon-BKGPfjm2.js","assets/x-B9o9hsep.js","assets/setLocalStorage-D_kflv4U.js","assets/safeParse-DeaoCCWH.js","assets/useLocalStorage-Dtj1QS8_.js","assets/alertDialog-DIHt7Z0r.js","assets/regions-QdUi7bQ9.js","assets/chevron-up-Df2c8uoU.js","assets/apiToken-Bl5LC8EH.js","assets/setup-Cop6LBQN.js","assets/dist-lkA3O3eM.js","assets/register-Buvoxmb8.js","assets/register-jjEx9u7D.css","assets/editor-CeRXEhRl.js","assets/toggleHighContrast-C0dJLmZ0.js","assets/toggleHighContrast--ixms01u.css","assets/index.lazy-VmcKgiEy.js","assets/authStore-qKmCZcaf.js","assets/setSessionStorage-B0bf71m4.js","assets/useEntityRestURL-D1u1X_gE.js","assets/tabs-B_G5zscN.js","assets/applications-Dta6Y0Rg.js","assets/download-BtTOBem-.js","assets/setComponentFile-BI4E_iDe.js","assets/languageServices-D_06p7dw.js","assets/applications-DNZhsH95.css","assets/FloatingChat-BvmHsuVo.js","assets/status-DRu3zRgl.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-D4LKGeVy.js","assets/notifications-Bah46LXX.js","assets/profile-QspOun_j.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-qKmCZcaf.js";import{E as _,O as v,T as y,_ as b,a as x,b as S,c as C,d as w,g as T,i as E,k as D,n as O,p as k,s as A,t as j,v as ee,y as M}from"./vendor-core-RCcadM3e.js";import{i as N,n as P,t as F}from"./button-DhiX-njv.js";import{A as te,B as ne,C as I,D as L,E as re,F as ie,G as ae,H as oe,I as R,L as z,M as se,N as ce,O as le,P as ue,R as de,S as fe,T as pe,U as me,V as he,W as ge,_ as _e,a as ve,b as ye,c as be,d as xe,f as Se,g as Ce,h as we,i as Te,k as B,l as Ee,m as De,n as Oe,o as ke,p as Ae,q as je,r as Me,s as Ne,t as Pe,u as Fe,v as Ie,w as V,y as Le,z as H}from"./vendor-tanstack-BiFWSB3W.js";import{a as Re,i as ze,t as Be}from"./vendor-datadog-BRv-mOv1.js";import{r as Ve,t as He}from"./vendor-react-Dyj4O3HE.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 U,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-vhu-UHhF.js";import{t as W}from"./createLucideIcon-BKGPfjm2.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-CBf0Mr1d.js";import{n as pn,r as mn,t as hn}from"./chevron-up-Df2c8uoU.js";import{t as gn}from"./x-B9o9hsep.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-Dtj1QS8_.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var G=e(Re(),1);function Sn(){let[e,t]=(0,G.useState)(()=>({...u.getAllConnections()}));return(0,G.useEffect)(()=>u.listenToAllEntities((e,n)=>{t(t=>({...t,[n]:e}))}),[]),e}function Cn(){let e=u.calculateIdFromEntity(m),[t,n]=(0,G.useState)(u.getConnectionById(m));return(0,G.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}=B({strict:!1}),[i,a]=(0,G.useState)(u.getConnectionById(t??r??n));return(0,G.useEffect)(()=>u.listenToEntity(t,a),[t]),i}var K=Ve();function On({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`card`,className:P(`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,K.jsx)(`div`,{"data-slot":`card-header`,className:P(`flex flex-col gap-1.5 px-6`,e),...t})}function An({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`card-title`,className:P(`leading-none text-lg`,e),...t})}function jn({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`card-description`,className:P(`text-muted-foreground text-xs`,e),...t})}function Mn({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`card-content`,className:P(`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=W(`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=W(`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=W(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),Rn=W(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),zn=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Yn=W(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Xn=W(`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=W(`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=W(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),$n=W(`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=W(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),tr=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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`}]]),_r=W(`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`}]]),vr=W(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),yr=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),Dr=W(`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=W(`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=W(`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=W(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),jr=W(`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`}]]),Mr=W(`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`}]]),Nr=W(`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=W(`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=W(`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=W(`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=W(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),Rr=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Kr=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),$r=W(`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=W(`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=W(`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=W(`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`}]]);W(`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=W(`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=W(`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=W(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),oi=W(`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=W(`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=W(`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=W(`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=W(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),di=W(`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=W(`trash`,[[`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=W(`trash-2`,[[`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`}]]),mi=W(`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`}]]),hi=W(`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`}]]),gi=W(`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`}]]),_i=W(`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`}]]),vi=W(`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 yi({className:e,error:t,title:n,showReturnToHome:r,children:i}){let{user:a,isLoading:o}=Cn();return Pn(a),(0,K.jsxs)(On,{className:P(`text-red p-5 border border-red rounded-md m-12 mt-36`,e),children:[(0,K.jsxs)(kn,{children:[(0,K.jsx)(An,{className:`text-2xl`,children:(0,K.jsx)(`h2`,{children:n??`Component Error`})}),(0,K.jsx)(jn,{children:t.message})]}),(0,K.jsxs)(Mn,{children:[i,r!==!1&&(a&&!o?(0,K.jsx)(V,{to:`/`,children:(0,K.jsxs)(F,{children:[` `,(0,K.jsx)(Ln,{}),` Return to Home`]})}):(0,K.jsx)(V,{to:`/sign-in`,children:(0,K.jsxs)(F,{children:[` `,(0,K.jsx)(Ln,{}),` Go to Sign In Page`]})}))]})]})}function bi(){let{user:e,isLoading:t}=Cn();return Pn(e),(0,K.jsx)(`div`,{className:`flex items-center justify-center h-screen px-3`,children:(0,K.jsxs)(On,{className:`text-red p-5 border border-red rounded-md w-full max-w-md`,children:[(0,K.jsx)(kn,{children:(0,K.jsx)(An,{className:`text-2xl`,children:(0,K.jsx)(`h2`,{children:`Sorry, Page Not Found`})})}),(0,K.jsx)(Mn,{children:e&&!t?(0,K.jsx)(V,{to:`/`,children:(0,K.jsxs)(F,{children:[` `,(0,K.jsx)(Ln,{}),` Return to Home`]})}):(0,K.jsx)(V,{to:`/sign-in`,children:(0,K.jsxs)(F,{children:[` `,(0,K.jsx)(Ln,{}),` Go Sign In Page`]})})})]})})}function xi(){return`ontouchstart`in window||navigator.maxTouchPoints>0}function Si(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 Ci(e){console.error(e);let{title:t,description:n}=Si(e),r=e,i=r?.code===`ECONNABORTED`||r?.code===`ETIMEDOUT`,a=r?.response?.status===403;U.error(t,{id:i?`request-timeout`:a?`request-forbidden`:void 0,description:n,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}var wi=new me({queryCache:new ge({onError:Ci}),mutationCache:new ae({onError:(e,t,n,r)=>{r.meta?.skipGlobalErrorToast||Ci(e)}})});function Ti({...e}){return(0,K.jsx)(Rt,{"data-slot":`dropdown-menu`,...e})}function Ei({...e}){return(0,K.jsx)(ht,{"data-slot":`dropdown-menu-trigger`,...e})}function Di({className:e,sideOffset:t=4,...n}){return(0,K.jsx)(pt,{children:(0,K.jsx)(Zt,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:P(`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 Oi({className:e,inset:t,variant:n=`default`,...r}){return(0,K.jsx)(bt,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:P(`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 ki({className:e,children:t,checked:n,...r}){return(0,K.jsxs)(Ze,{"data-slot":`dropdown-menu-checkbox-item`,className:P(`focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm`,`py-1.5 pr-2 pl-8`,`text-sm outline-hidden`,`select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),checked:n,...r,children:[(0,K.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,K.jsx)(tt,{children:(0,K.jsx)(mn,{className:`size-4`})})}),t]})}function Ai({className:e,inset:t,...n}){return(0,K.jsx)($e,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:P(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function ji({className:e,...t}){return(0,K.jsx)(Je,{"data-slot":`dropdown-menu-separator`,className:P(`bg-border -mx-1 my-1 h-px`,e),...t})}function Mi({className:e,...t}){return(0,K.jsx)(`span`,{"data-slot":`dropdown-menu-shortcut`,className:P(`text-muted-foreground ml-auto text-xs tracking-widest`,e),...t})}function Ni({...e}){return(0,K.jsx)(It,{"data-slot":`dropdown-menu-sub`,...e})}function Pi({className:e,inset:t,children:n,...r}){return(0,K.jsxs)(dt,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:P(`focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground`,`flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none`,`data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0`,`[&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,K.jsx)(Jn,{className:`ml-auto size-4`})]})}function Fi({className:e,...t}){return(0,K.jsx)(lt,{"data-slot":`dropdown-menu-sub-content`,className:P(`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 Ii=`flex items-center gap-3 p-2 rounded-lg text-sm transition-colors`,Li=`block p-2 rounded-lg text-sm transition-colors`,Ri={className:`text-foreground hover:bg-accent dark:text-white dark:hover:bg-grey-700`},zi={className:`font-medium text-primary bg-primary/10 dark:text-white dark:bg-white/10`};function Bi({items:e,ariaLabel:t}){let{pathname:n}=Ce(),r=e=>e.exact?n===e.to:n.startsWith(e.to),i=e.find(r)??e[0],a=i.icon;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`nav`,{className:`hidden md:flex flex-col gap-1`,"aria-label":t,children:e.map(e=>{let t=e.icon;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(V,{to:e.to,className:Ii,activeOptions:{exact:!!e.exact},activeProps:zi,inactiveProps:Ri,children:[(0,K.jsx)(t,{className:`size-4 shrink-0`}),e.label]}),e.children&&r(e)&&(0,K.jsx)(`div`,{className:`mt-1 ml-4 flex flex-col gap-1 border-l border-border pl-3`,children:e.children.map(e=>(0,K.jsx)(V,{to:e.to,className:Li,activeOptions:{exact:!!e.exact},activeProps:zi,inactiveProps:Ri,children:e.label},e.to))})]},e.to)})}),(0,K.jsx)(`div`,{className:`md:hidden`,children:(0,K.jsxs)(Ti,{children:[(0,K.jsx)(Ei,{asChild:!0,children:(0,K.jsxs)(F,{variant:`outline`,className:`w-full justify-between`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(a,{className:`size-4`}),i.label]}),(0,K.jsx)(pn,{className:`size-4`})]})}),(0,K.jsx)(Di,{align:`start`,className:`w-(--radix-dropdown-menu-trigger-width)`,children:e.map(e=>{let t=e.icon;return[(0,K.jsx)(Oi,{asChild:!0,children:(0,K.jsxs)(V,{to:e.to,className:`flex items-center gap-2`,children:[(0,K.jsx)(t,{className:`size-4`}),e.label]})},e.to),...e.children&&r(e)?e.children.map(e=>(0,K.jsx)(Oi,{asChild:!0,children:(0,K.jsx)(V,{to:e.to,className:`flex items-center gap-2 pl-8`,children:e.label})},e.to)):[]]})})]})})]})}var Vi=[{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 Hi(e){let t=e!==null&&`fabricRole`in e&&e.fabricRole===`super_user`;return Vi.filter(n=>Tn(e,n.permission)&&!(n.ssoAccountOnly&&t))}function Ui(e){return Hi(e).length>0}function Wi(){let{isLoading:e,user:t}=wn(),{pathname:n}=Ce();if(e)return null;let r=Hi(t);if(!r.length)return(0,K.jsx)(re,{to:`/`,replace:!0});let i=Vi.find(e=>n.startsWith(e.to));return i&&!r.includes(i)?(0,K.jsx)(re,{to:r[0].to,replace:!0}):(0,K.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsxs)(`div`,{className:`md:grid gap-6 md:grid-cols-12`,children:[(0,K.jsx)(`aside`,{className:`md:col-span-3 lg:col-span-2 mb-4 md:mb-0`,children:(0,K.jsx)(Bi,{items:r,ariaLabel:`Admin sections`})}),(0,K.jsx)(`section`,{className:`md:col-span-9 lg:col-span-10 min-w-0`,children:(0,K.jsx)(Le,{})})]})})}function Gi({className:e,text:t,centered:n,...r}){return(0,K.jsxs)(`div`,{className:`text-foreground h-full w-full ${e||``} ${n?`flex flex-col items-center justify-center`:``}`,...r,children:[(0,K.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`100px`,height:`100px`,alt:`HDB Dog Logo Loading`,className:`inline-block`}),(0,K.jsx)(`p`,{className:`pt-4`,children:t||`Loading...`})]})}function Ki(){return(0,K.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 126.644 96`,width:24,height:24,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M81.15,0c-1.2376,2.1973-2.3489,4.4704-3.3591,6.794-9.5975-1.4396-19.3718-1.4396-28.9945,0-.985-2.3236-2.1216-4.5967-3.3591-6.794-9.0166,1.5407-17.8059,4.2431-26.1405,8.0568C2.779,32.5304-1.6914,56.3725.5312,79.8863c9.6732,7.1476,20.5083,12.603,32.0505,16.0884,2.6014-3.4854,4.8998-7.1981,6.8698-11.0623-3.738-1.3891-7.3497-3.1318-10.8098-5.1523.9092-.6567,1.7932-1.3386,2.6519-1.9953,20.281,9.547,43.7696,9.547,64.0758,0,.8587.7072,1.7427,1.3891,2.6519,1.9953-3.4601,2.0457-7.0718,3.7632-10.835,5.1776,1.97,3.8642,4.2683,7.5769,6.8698,11.0623,11.5419-3.4854,22.3769-8.9156,32.0509-16.0631,2.626-27.2771-4.496-50.9172-18.817-71.8548C98.9811,4.2684,90.1918,1.5659,81.1752.0505l-.0252-.0505ZM42.2802,65.4144c-6.2383,0-11.4159-5.6575-11.4159-12.6535s4.9755-12.6788,11.3907-12.6788,11.5169,5.708,11.4159,12.6788c-.101,6.9708-5.026,12.6535-11.3907,12.6535ZM84.3576,65.4144c-6.2637,0-11.3907-5.6575-11.3907-12.6535s4.9755-12.6788,11.3907-12.6788,11.4917,5.708,11.3906,12.6788c-.101,6.9708-5.026,12.6535-11.3906,12.6535Z`})})}function qi(){let e=`studio`,t=`Harper Studio`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`img`,{src:`/harper-${e}_black.png`,alt:t,className:`w-64 hidden md:inline-block dark:hidden`}),(0,K.jsx)(`img`,{src:`/harper-${e}_white.png`,alt:t,className:`w-64 hidden md:dark:inline-block`}),(0,K.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`50px`,height:`44px`,alt:`Harper`,className:`inline-block md:hidden`})]})}var Ji=y(`inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-auto`,{variants:{variant:{default:`border-primary bg-primary/40 text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`border-secondary bg-secondary/40 text-secondary-foreground [a&]:hover:bg-secondary/90`,warning:`border-yellow bg-yellow/40 text-foreground [a&]:hover:bg-yellow/90`,success:`border-green bg-green/40 text-foreground [a&]:hover:bg-green/90`,destructive:`border-transparent bg-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 Yi({className:e,variant:t,asChild:n=!1,...r}){return(0,K.jsx)(n?st:`span`,{"data-slot":`badge`,className:P(Ji({variant:t}),e),...r})}function Xi({className:e,children:t,...n}){return(0,K.jsxs)(tn,{"data-slot":`scroll-area`,className:P(`relative`,e),...n,children:[(0,K.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,K.jsx)(Zi,{}),(0,K.jsx)(Yt,{})]})}function Zi({className:e,orientation:t=`vertical`,...n}){return(0,K.jsx)(Dt,{"data-slot":`scroll-area-scrollbar`,orientation:t,className:P(`flex touch-none p-px transition-colors select-none`,t===`vertical`&&`h-full w-2.5 border-l border-l-transparent`,t===`horizontal`&&`h-2.5 flex-col border-t border-t-transparent`,e),...n,children:(0,K.jsx)($t,{"data-slot":`scroll-area-thumb`,className:`bg-border relative flex-1 rounded-full`})})}var Qi=[`notification-acks`];function $i(){let e=yn(vn.AckedNotificationIds,[]);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function ea(e){wi.setQueryData(Qi,e);try{bn(vn.AckedNotificationIds,e)}catch(e){console.warn(`[notifications] could not persist acknowledgements`,e)}}function ta(){return z({queryKey:Qi,queryFn:$i,staleTime:1/0,gcTime:1/0,initialData:$i})}function na(e){ea(Array.from(new Set([...$i(),e])))}function ra(e){ea($i().filter(t=>t!==e))}function ia(){let{data:e}=H(ta());return(0,G.useMemo)(()=>new Set(e??[]),[e])}var aa={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:mi,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`}},oa=new Set([`critical`,`error`,`outage`,`incident`,`down`,`danger`]),sa=new Set([`warning`,`warn`,`maintenance`,`degraded`,`notice`]),ca=new Set([`info`,`information`,`informational`,`success`,`ok`]);function la(e){let t=(e??``).trim().toLowerCase();return sa.has(t)?`warning`:ca.has(t)?`info`:(oa.has(t),`critical`)}function ua(e){return aa[la(e)]}var da={critical:0,warning:1,info:2};function fa(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 pa(e){let t=fa(e);return t.kind===`valid`?t.ms:null}function ma(e){return new Date(e).toLocaleString()}function ha(e,t){let n=fa(e.startAt),r=fa(e.endAt);return n.kind===`invalid`||r.kind===`invalid`?{state:`expired`,label:`Schedule unavailable`}:n.kind===`valid`&&t<n.ms?{state:`upcoming`,label:`Starts ${ma(n.ms)}`}:r.kind===`valid`&&t>r.ms?{state:`expired`,label:`Ended ${ma(r.ms)}`}:r.kind===`valid`?{state:`active`,label:`Active until ${ma(r.ms)}`}:{state:`active`,label:`Active`}}var ga=new Set([`http`,`https`,`mailto`]);function _a(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?ga.has(n)?{kind:`external`,href:t}:null:{kind:`internal`,href:t.startsWith(`/`)?t:`/${t}`}}function va({url:e,className:t,children:n,onNavigate:r}){let i=_a(e);return i?i.kind===`external`?(0,K.jsxs)(`a`,{href:i.href,target:`_blank`,rel:`noreferrer noopener`,className:t,children:[n??`Learn more`,(0,K.jsx)(dr,{className:`inline size-3 ml-1 align-[-1px]`})]}):(0,K.jsx)(V,{to:i.href,className:t,onClick:r,children:n??`View details`}):null}var ya=[`system-status`];async function ba(){let{data:e}=await N.get(`/SystemStatus/`);return Array.isArray(e)?e:[]}function xa(){return z({queryKey:ya,queryFn:ba,refetchInterval:6e4,staleTime:3e4})}var Sa=3e4,Ca=new Set,wa=Date.now(),Ta=null;function Ea(e){return Ca.add(e),Ta||=(wa=Date.now(),setInterval(()=>{wa=Date.now(),Ca.forEach(e=>e())},Sa)),()=>{Ca.delete(e),Ca.size===0&&Ta&&(clearInterval(Ta),Ta=null)}}function Da(){return(0,G.useSyncExternalStore)(Ea,()=>wa,()=>wa)}function Oa(){return H(xa())}function ka(){let[e,t]=(0,G.useState)(()=>window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`);return(0,G.useEffect)(()=>{let e=window.matchMedia(`(prefers-color-scheme: dark)`),n=e=>t(e.matches?`dark`:`light`);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var Aa=(0,G.createContext)([`system`,()=>{}]);function ja({children:e}){let[t,n]=xn(vn.Theme,`system`),r=ka();return(0,G.useEffect)(()=>{let e=t===`dark`||t===`system`&&r===`dark`;document.documentElement.classList.toggle(`dark`,e)},[t,r]),(0,K.jsx)(Aa.Provider,{value:[t,n],children:e})}function Ma(){return(0,G.useContext)(Aa)}var Na=[{value:`light`,icon:(0,K.jsx)(oi,{className:`size-4`}),label:`Light`},{value:`system`,icon:(0,K.jsx)(Rr,{className:`size-4`}),label:`System`},{value:`dark`,icon:(0,K.jsx)(zr,{className:`size-4`}),label:`Dark`}];function Pa(){let[e,t]=Ma();return(0,K.jsx)(`div`,{className:`flex items-center bg-muted dark:bg-black rounded-xl p-0.5 gap-0.5`,children:Na.map(({value:n,icon:r,label:i})=>(0,K.jsx)(`button`,{type:`button`,title:i,onClick:()=>t(n),className:`p-1.5 rounded-lg transition-colors ${e===n?`bg-background text-foreground shadow-xs`:`text-muted-foreground hover:text-foreground`}`,children:r},n))})}function Fa({className:e,...t}){return(0,K.jsx)(`div`,{className:P(`absolute top-full left-0 isolate z-50 flex justify-center`),children:(0,K.jsx)(wt,{"data-slot":`navigation-menu-viewport`,className:P(`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 Ia({className:e,children:t,viewport:n=!0,...r}){return(0,K.jsxs)(Mt,{"data-slot":`navigation-menu`,"data-viewport":n,className:P(`group/navigation-menu relative flex max-w-max flex-1 items-center justify-center`,e),...r,children:[t,n&&(0,K.jsx)(Fa,{})]})}function La({className:e,...t}){return(0,K.jsx)(Ut,{"data-slot":`navigation-menu-item`,className:P(`relative`,e),...t})}function Ra({className:e,...t}){return(0,K.jsx)(Bt,{"data-slot":`navigation-menu-link`,className:P(`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 za({className:e,...t}){return(0,K.jsx)(Nt,{"data-slot":`navigation-menu-list`,className:P(`group flex flex-1 list-none items-center justify-center gap-1`,e),...t})}function Ba({delayDuration:e=0,...t}){return(0,K.jsx)(qt,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Va({...e}){return(0,K.jsx)(Ba,{children:(0,K.jsx)(kt,{"data-slot":`tooltip`,...e})})}function Ha({...e}){return(0,K.jsx)(jt,{"data-slot":`tooltip-trigger`,...e})}function Ua({className:e,sideOffset:t=0,arrowClassName:n,children:r,...i}){return(0,K.jsx)(zt,{children:(0,K.jsxs)(Ot,{"data-slot":`tooltip-content`,sideOffset:t,className:P(`bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance`,e),...i,children:[r,(0,K.jsx)(Gt,{className:P(`bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`,n)})]})})}function Wa(){let e=`v5.2.7`,t=e.startsWith(`v`)?`https://github.com/HarperFast/studio/releases/tag/${e}`:`https://github.com/HarperFast/studio/releases`;return(0,K.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,children:(0,K.jsxs)(`span`,{className:P(Ji({variant:`default`}),`text-xs inline-block ml-2 align-text-top`),children:[e,` BETA`]})})}function Ga(e={}){let{instanceId:t,clusterId:n}=B({strict:!1});return o({id:m,...e})}function Ka(e={}){let{instanceId:t,clusterId:n}=B({strict:!1});return{instanceClient:o({id:m,...e}),entityType:`instance`}}function q(e={}){let{instanceId:t,clusterId:n}=B({strict:!1});return(0,G.useMemo)(()=>qa({instanceId:t,clusterId:n,...e}),[e.instanceId??t,e.clusterId??n,e.operationsUrl,e.port,e.secure,e.disableFabricConnect,e.forceFabricConnect])}function qa({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 Ja(){localStorage.clear()}function Ya(){sessionStorage.clear()}async function Xa(){u.setUserForEntity(m,null),wi.getQueryCache().clear(),Ja(),Ya(),await wi.invalidateQueries({refetchType:`none`})}async function Za(e){await u.signOutFromPotentiallyAuthenticatedInstances(),await d({...e,entityId:m})}function Qa(){let e=Ga();return R({mutationFn:()=>Za({instanceClient:e}),onSuccess:Xa})}function $a(e){return!!e}var eo={className:`text-foreground dark:text-white font-semibold`};function to(){let{mutate:e}=Qa(),t=L(),{user:n}=Cn(),r=Ui(n),i=se(),a=(0,G.useCallback)(()=>{e(void 0,{onSuccess:async()=>{U.success(`Success`,{description:`You have been signed out successfully.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),t({to:`/sign-in`}),i.invalidate()}})},[e,i,t]),o=(0,G.useMemo)(()=>[!1,!1,{to:`https://docs.harperdb.io/docs`,target:`_blank`,icon:(0,K.jsx)(Hn,{}),text:`Docs`,textBreakpoint:`md`},{to:`https://github.com/HarperFast/studio/issues`,target:`_blank`,icon:(0,K.jsx)(Wn,{}),text:`Report an Issue`,textBreakpoint:`lg`},{to:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,icon:(0,K.jsx)(Ki,{}),text:`Discord`,textBreakpoint:`lg`},{onClick:a,icon:(0,K.jsx)(Nr,{}),text:`Sign Out`,textBreakpoint:`md`}].filter($a),[a,r]);return n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(oo,{menuItems:o}),(0,K.jsx)(io,{menuItems:o})]}):(0,K.jsx)(ro,{})}function no(e){return e.items!==void 0}function ro(){return(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`inline-block`,children:[(0,K.jsx)(V,{to:`/sign-in`,children:(0,K.jsx)(qi,{})}),(0,K.jsx)(Wa,{})]}),(0,K.jsx)(Ia,{children:(0,K.jsxs)(za,{className:`text-muted-foreground dark:text-grey-400`,children:[(0,K.jsx)(La,{children:(0,K.jsx)(Ra,{asChild:!0,children:(0,K.jsxs)(V,{to:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noreferrer noopener`,className:`flex-row items-center`,children:[(0,K.jsx)(Hn,{}),` `,(0,K.jsx)(`span`,{className:`hidden md:inline-block`,children:`Docs`})]})})}),(0,K.jsx)(La,{children:(0,K.jsx)(Pa,{})}),(0,K.jsx)(La,{children:(0,K.jsx)(Ra,{asChild:!0,children:(0,K.jsxs)(V,{to:`/sign-in`,className:`flex-row items-center`,activeProps:eo,children:[(0,K.jsx)(jr,{}),` Sign In`]})})})]})})]})}function io({menuItems:e}){let{user:t}=Cn();return Pn(t),(0,K.jsx)(`div`,{className:`hidden md:[@media(hover:hover)]:block xl:block`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`inline-block`,children:[(0,K.jsx)(V,{to:`/`,children:(0,K.jsx)(qi,{})}),(0,K.jsx)(Wa,{})]}),(0,K.jsx)(Ia,{children:(0,K.jsxs)(za,{className:`text-muted-foreground dark:text-grey-400`,children:[e.map(e=>no(e)?!!e.items.length&&(0,K.jsx)(`div`,{className:`bg-muted dark:bg-black rounded-2xl flex`,children:e.items.map(e=>(0,K.jsx)(ao,{menuItem:e},e.text))},e.text):(0,K.jsx)(ao,{menuItem:e},e.text)),!1,(0,K.jsx)(La,{children:(0,K.jsx)(Pa,{})})]})})]})})}function ao({menuItem:e}){return(0,K.jsx)(La,{className:`text-muted-foreground dark:text-gray-400 hover:text-foreground dark:hover:text-white`,children:(0,K.jsxs)(Va,{children:[(0,K.jsx)(Ha,{asChild:!0,children:(0,K.jsx)(Ra,{asChild:!0,children:(0,K.jsxs)(V,{to:e.to,onClick:e.onClick,"aria-label":e.text,className:`flex-row items-center`,target:e.target,activeProps:e.to?eo:void 0,children:[e.icon,(0,K.jsx)(`span`,{className:`hidden ${e.textBreakpoint}:inline-block`,children:e.text}),(0,K.jsx)(`span`,{className:`${e.textBreakpoint}:hidden`,children:`\xA0`})]})})}),(0,K.jsx)(Ua,{side:`bottom`,className:`${e.textBreakpoint}:hidden`,children:e.text})]})})}function oo({menuItems:e}){let{user:t}=Cn();Pn(t);let[n,r]=(0,G.useState)(!1),i=(0,G.useCallback)(()=>r(e=>!e),[]),a=(0,G.useCallback)(()=>r(!1),[]);return(0,K.jsxs)(`div`,{className:`md:[@media(hover:hover)]:hidden xl:hidden`,id:`mobile-menu`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(V,{to:`/`,children:(0,K.jsx)(qi,{})}),(0,K.jsx)(Wa,{}),(0,K.jsxs)(`div`,{className:`flex items-center`,children:[!1,(0,K.jsxs)(`button`,{type:`button`,className:`shadow-xs text-muted-foreground dark:text-grey-400 hover:text-foreground dark:hover:text-white hover:bg-muted dark:hover:bg-black-dark`,onClick:i,children:[(0,K.jsx)(`span`,{className:`sr-only`,children:n?`Close menu`:`Open menu`}),n?(0,K.jsx)(gn,{}):(0,K.jsx)(Lr,{})]})]})]}),(0,K.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,K.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,K.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,K.jsx)(Pa,{})}),e.map(e=>no(e)?!!e.items.length&&(0,K.jsx)(`div`,{className:`bg-muted dark:bg-black pl-10 pr-2 py-2`,children:e.items.map(e=>(0,K.jsx)(so,{menuItem:e,onClick:a},e.text))},e.text):(0,K.jsx)(so,{menuItem:e,onClick:a},e.text))]})]})}function so({menuItem:e,onClick:t}){let n=(0,G.useCallback)(()=>{e.onClick?.(),t()},[e,t]);return(0,K.jsxs)(V,{to:e.to,onClick:n,target:e.target,className:`flex flex-row px-3 py-2 text-base font-medium rounded-md text-muted-foreground dark:text-gray-400 hover:text-foreground dark:hover:text-white`,activeProps:e.to?eo:void 0,children:[e.icon,(0,K.jsx)(`span`,{className:`ml-4`,children:e.text})]})}function co(){let{isLoading:e}=Cn(),{createCluster:t}=le({strict:!1}),[,n]=xn(vn.SavedClusterState,null);return(0,G.useEffect)(()=>{t&&n(t)},[t,n]),e?(0,K.jsx)(Gi,{className:`fixed z-50 translate-1/2`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.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,K.jsx)(to,{})}),(0,K.jsx)(`main`,{children:(0,K.jsx)(Le,{})})]})}function lo(){let e=location.hash;return e?e.startsWith(`#/`)?e.slice(1):e:`/`}var uo=[`/`,`/forgot-password`,`/reset-password`,`/sign-in`,`/sign-up`,`/verify-email`];function fo(){let e=lo();return!uo.includes(e)&&{redirect:e}}var po=`me|email|token|access_token|id_token|refresh_token|code|secret|password|api[-_]?key`,mo=String.raw`[^&#\s",<>[\]{}|\\]+`,ho=String.raw`[\w.%+!~*'()-]+(?:@|%40)[\w-]+(?:\.[\w-]+)*\.\w{2,}`;new RegExp(String.raw`([?&](?:${po})=)${mo}`,`gi`),new RegExp(String.raw`([?&](?:${po})=)${mo}|${ho}`,`gi`);var go=String.raw`[\w-]+-extension`;new RegExp(String.raw`^${go}://`),new RegExp(String.raw`^\s*at\s.* @ ((?:blob:)?(?:https?|${go})://\S*)\s*$`);var _o=!1;function vo(){(0,G.useEffect)(()=>{_o||=!0},[])}function yo(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(we,{}),(0,K.jsx)(Le,{})]})}var bo=fe()({component:yo}),xo=I({getParentRoute:()=>bo,id:`_dashboardLayout`,component:co,beforeLoad:({context:e})=>{let t=e.authentication[m];if(t&&!t.isLoading&&!t.user)throw ie({to:`/sign-in`,search:fo()})}}),So=I({getParentRoute:()=>xo,path:`admin`,component:Wi});I({getParentRoute:()=>So,path:`/`,beforeLoad:()=>{throw ie({to:`/admin/notifications`})}}),I({getParentRoute:()=>So,path:`notifications`,head:()=>({meta:[{title:`Notifications — Harper Fabric`}]}),component:ye(async()=>ze(()=>import(`./notifications-CBZXgxVc.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])),`NotificationsAdminIndex`)}),I({getParentRoute:()=>So,path:`regions`,head:()=>({meta:[{title:`Regions — Harper Fabric`}]}),component:ye(async()=>ze(()=>import(`./regions-QdUi7bQ9.js`),__vite__mapDeps([15,1,3,2,4,5,6,7,8,9,10,11,12,13,16])),`RegionsIndex`)}),I({getParentRoute:()=>So,path:`api-token`,head:()=>({meta:[{title:`API Token — Harper Fabric`}]}),component:ye(async()=>ze(()=>import(`./apiToken-Bl5LC8EH.js`),__vite__mapDeps([17,1,2,3,4,5,6,7])),`ApiTokenIndex`)});function Co(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.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,K.jsx)(to,{})}),(0,K.jsxs)(`div`,{className:`pt-20 h-screen grid grid-cols-1 md:grid-cols-2`,children:[(0,K.jsx)(`section`,{"aria-label":`Harper Fabric overview`,className:`items-center justify-center hidden text-white md:flex px-6 fabricSignupTextContainer`,children:(0,K.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,K.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,K.jsx)(`div`,{className:`min-h-full flex items-start justify-center py-12`,children:(0,K.jsx)(Le,{})})})]})]})}function wo(){(0,G.useEffect)(()=>{},[])}var To=[`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 Eo(e){if(!e||!e.includes(`@`))return null;let t=e.split(`@`).pop()||``;if(!t)return null;for(let e of To)if(t===e||t.endsWith(`.`+e))return null;return t}var Do=`utm_`;function Oo(e){let t=new URLSearchParams(e),n=Array.from(t.keys()).filter(e=>e.toLowerCase().startsWith(Do));if(n.length===0)return e;for(let e of n)t.delete(e);let r=t.toString();return r?`?${r}`:``}function ko(){if(typeof location>`u`||typeof history>`u`)return;let{search:e,pathname:t,hash:n,origin:r}=location,i=Oo(e);i!==e&&history.replaceState(history.state,``,`${r}${t}${i}${n}`)}var Ao=null;function jo(){let e=L(),t=se(),n=oe(),{redirect:r}=le({strict:!1});return(0,G.useEffect)(()=>{Ao||=(async function(){let i=await l().catch(()=>null);if(!i)U.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),ko();let a=Pn(i);Eo(i.email),await n.invalidateQueries({queryKey:f,refetchType:`none`}),await t.invalidate(),await e({to:r?.startsWith(`/`)?r:a})}Ao=null})()},[]),(0,K.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`text-foreground dark:text-white w-lg flex flex-col gap-4`,children:[(0,K.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Checking...`]}),(0,K.jsx)(`div`,{className:`underline flex gap-4`,children:(0,K.jsx)(V,{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 Mo=new Map;function No(e){if(!e)return``;if(Mo.has(e))return Mo.get(e);let t=e.replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();if(!t)return Mo.set(e,``),``;let n=t.match(/([A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|[0-9]+)/g);if(!n)return Mo.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(Po).join(` `);return Mo.set(e,i),i}function Po(e){return/^[A-Z]{2,3}s?$/.test(e)||/^[0-9]+$/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function Fo({restartRequired:e}){let t=Ce(),{organization:n,instance:r,cluster:i}=pe({strict:!1}),a=(0,G.useMemo)(()=>{let e=t.pathname.split(`/`).filter(e=>e&&e.length>0),a=[(0,K.jsxs)(V,{to:`/`,children:[(0,K.jsx)(Cr,{"aria-hidden":`true`,className:`size-5 shrink-0`}),(0,K.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=No(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,K.jsx)(`svg`,{fill:`currentColor`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`size-5 shrink-0 text-grey`,children:(0,K.jsx)(`path`,{d:`M5.555 17.776l8-16 .894.448-8 16-.894-.448z`})},a.length+`-dash`),(0,K.jsx)(V,{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,K.jsxs)(`div`,{role:`list`,className:`flex items-center space-x-2 xl:space-x-4 sm:max-w-9/10 max-w-[calc(100%-56px)]`,children:[...a,e&&(0,K.jsxs)(Va,{children:[(0,K.jsx)(Ha,{asChild:!0,children:(0,K.jsxs)(`div`,{className:`text-xs italic text-muted-foreground`,children:[`* Restart `,(0,K.jsx)(`span`,{className:`hidden lg:inline-block`,children:`Requested`})]})}),(0,K.jsxs)(Ua,{side:`bottom`,children:[`This `,`Instance`,` is requesting a restart, when convenient, to apply your latest changes.`,(0,K.jsx)(`br`,{}),`You can do this from the Apps or Config pages.`]})]})]})}var Io=Vt,Lo=(0,G.createContext)({}),Ro=(0,G.createContext)({});function zo(){let e=(0,G.useContext)(Lo),t=(0,G.useContext)(Ro),{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}=zo();return(0,K.jsx)(st,{"data-slot":`form-control`,id:n,"aria-describedby":t?`${r} ${i}`:`${r}`,"aria-invalid":!!t,...e})}function Y({...e}){return(0,K.jsx)(Lo,{value:{name:e.name},children:(0,K.jsx)(Kt,{...e})})}function X({className:e,...t}){let n=(0,G.useId)();return(0,K.jsx)(Ro,{value:{id:n},children:(0,K.jsx)(`div`,{"data-slot":`form-item`,className:P(`grid gap-2`,e),...t})})}function Bo({className:e,...t}){return(0,K.jsx)(At,{"data-slot":`label`,className:P(`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}=zo();return(0,K.jsx)(Bo,{"data-slot":`form-label`,"data-error":!!n,className:P(`data-[error=true]:text-destructive`,e),htmlFor:r,...t})}function Q({className:e,...t}){let{error:n,formMessageId:r}=zo(),i=n?String(n?.message):t.children;return i?(0,K.jsx)(`p`,{"data-slot":`form-message`,id:r,className:P(`text-destructive text-sm`,e),...t,children:i}):null}function $({className:e,type:t,...n}){return(0,K.jsx)(`input`,{type:t,"data-slot":`input`,className:P(`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-DPTOF-SX.js","assets/rolldown-runtime-hePW80VL.js","assets/button-DhiX-njv.js","assets/vendor-core-RCcadM3e.js","assets/vendor-datadog-BRv-mOv1.js","assets/vendor-react-Dyj4O3HE.js","assets/vendor-ui-vhu-UHhF.js","assets/vendor-tanstack-BiFWSB3W.js","assets/dialog-CBf0Mr1d.js","assets/createLucideIcon-BKGPfjm2.js","assets/x-B9o9hsep.js","assets/setLocalStorage-D_kflv4U.js","assets/safeParse-DeaoCCWH.js","assets/useLocalStorage-Dtj1QS8_.js","assets/alertDialog-DIHt7Z0r.js","assets/regions-B5lGduv5.js","assets/chevron-up-Df2c8uoU.js","assets/apiToken-CrPb_98N.js","assets/setup-D2az-Ue_.js","assets/dist-lkA3O3eM.js","assets/register-Cvc1TpmQ.js","assets/register-jjEx9u7D.css","assets/editor-C-jlLd1G.js","assets/toggleHighContrast-BdIEw2rK.js","assets/toggleHighContrast--ixms01u.css","assets/index.lazy-PVbC6xQh.js","assets/authStore-qKmCZcaf.js","assets/setSessionStorage-B0bf71m4.js","assets/useEntityRestURL-C7x-Yz9r.js","assets/tabs-B_G5zscN.js","assets/applications-C6Y4nL_X.js","assets/download-BtTOBem-.js","assets/setComponentFile-D8ZLDWhU.js","assets/languageServices-D1uNqC6s.js","assets/applications-DNZhsH95.css","assets/FloatingChat-DdJ3DZJX.js","assets/status-BJegPrWN.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-D4LKGeVy.js","assets/notifications-DsE0S3zT.js","assets/profile-BIeCZr-w.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-qKmCZcaf.js";import{E as _,O as v,T as y,_ as b,a as x,b as S,c as C,d as w,g as T,i as E,k as D,n as O,p as k,s as A,t as j,v as ee,y as M}from"./vendor-core-RCcadM3e.js";import{i as N,n as P,t as F}from"./button-DhiX-njv.js";import{A as te,B as ne,C as I,D as L,E as re,F as ie,G as ae,H as oe,I as R,L as z,M as se,N as ce,O as le,P as ue,R as de,S as fe,T as pe,U as me,V as he,W as ge,_ as _e,a as ve,b as ye,c as be,d as xe,f as Se,g as Ce,h as we,i as Te,k as B,l as Ee,m as De,n as Oe,o as ke,p as Ae,q as je,r as Me,s as Ne,t as Pe,u as Fe,v as Ie,w as V,y as Le,z as H}from"./vendor-tanstack-BiFWSB3W.js";import{a as Re,i as ze,t as Be}from"./vendor-datadog-BRv-mOv1.js";import{r as Ve,t as He}from"./vendor-react-Dyj4O3HE.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 U,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-vhu-UHhF.js";import{t as W}from"./createLucideIcon-BKGPfjm2.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-CBf0Mr1d.js";import{n as pn,r as mn,t as hn}from"./chevron-up-Df2c8uoU.js";import{t as gn}from"./x-B9o9hsep.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-Dtj1QS8_.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var G=e(Re(),1);function Sn(){let[e,t]=(0,G.useState)(()=>({...u.getAllConnections()}));return(0,G.useEffect)(()=>u.listenToAllEntities((e,n)=>{t(t=>({...t,[n]:e}))}),[]),e}function Cn(){let e=u.calculateIdFromEntity(m),[t,n]=(0,G.useState)(u.getConnectionById(m));return(0,G.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}=B({strict:!1}),[i,a]=(0,G.useState)(u.getConnectionById(t??r??n));return(0,G.useEffect)(()=>u.listenToEntity(t,a),[t]),i}var K=Ve();function On({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`card`,className:P(`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,K.jsx)(`div`,{"data-slot":`card-header`,className:P(`flex flex-col gap-1.5 px-6`,e),...t})}function An({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`card-title`,className:P(`leading-none text-lg`,e),...t})}function jn({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`card-description`,className:P(`text-muted-foreground text-xs`,e),...t})}function Mn({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`card-content`,className:P(`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=W(`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=W(`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=W(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),Rn=W(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),zn=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Yn=W(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Xn=W(`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=W(`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=W(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),$n=W(`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=W(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),tr=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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`}]]),_r=W(`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`}]]),vr=W(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),yr=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),Dr=W(`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=W(`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=W(`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=W(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),jr=W(`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`}]]),Mr=W(`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`}]]),Nr=W(`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=W(`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=W(`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=W(`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=W(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),Rr=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Kr=W(`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=W(`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=W(`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=W(`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=W(`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=W(`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=W(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),$r=W(`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=W(`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=W(`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=W(`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`}]]);W(`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=W(`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=W(`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=W(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),oi=W(`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=W(`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=W(`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=W(`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=W(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),di=W(`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=W(`trash`,[[`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=W(`trash-2`,[[`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`}]]),mi=W(`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`}]]),hi=W(`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`}]]),gi=W(`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`}]]),_i=W(`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`}]]),vi=W(`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 yi({className:e,error:t,title:n,showReturnToHome:r,children:i}){let{user:a,isLoading:o}=Cn();return Pn(a),(0,K.jsxs)(On,{className:P(`text-red p-5 border border-red rounded-md m-12 mt-36`,e),children:[(0,K.jsxs)(kn,{children:[(0,K.jsx)(An,{className:`text-2xl`,children:(0,K.jsx)(`h2`,{children:n??`Component Error`})}),(0,K.jsx)(jn,{children:t.message})]}),(0,K.jsxs)(Mn,{children:[i,r!==!1&&(a&&!o?(0,K.jsx)(V,{to:`/`,children:(0,K.jsxs)(F,{children:[` `,(0,K.jsx)(Ln,{}),` Return to Home`]})}):(0,K.jsx)(V,{to:`/sign-in`,children:(0,K.jsxs)(F,{children:[` `,(0,K.jsx)(Ln,{}),` Go to Sign In Page`]})}))]})]})}function bi(){let{user:e,isLoading:t}=Cn();return Pn(e),(0,K.jsx)(`div`,{className:`flex items-center justify-center h-screen px-3`,children:(0,K.jsxs)(On,{className:`text-red p-5 border border-red rounded-md w-full max-w-md`,children:[(0,K.jsx)(kn,{children:(0,K.jsx)(An,{className:`text-2xl`,children:(0,K.jsx)(`h2`,{children:`Sorry, Page Not Found`})})}),(0,K.jsx)(Mn,{children:e&&!t?(0,K.jsx)(V,{to:`/`,children:(0,K.jsxs)(F,{children:[` `,(0,K.jsx)(Ln,{}),` Return to Home`]})}):(0,K.jsx)(V,{to:`/sign-in`,children:(0,K.jsxs)(F,{children:[` `,(0,K.jsx)(Ln,{}),` Go Sign In Page`]})})})]})})}function xi(){return`ontouchstart`in window||navigator.maxTouchPoints>0}function Si(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 Ci(e){console.error(e);let{title:t,description:n}=Si(e),r=e,i=r?.code===`ECONNABORTED`||r?.code===`ETIMEDOUT`,a=r?.response?.status===403;U.error(t,{id:i?`request-timeout`:a?`request-forbidden`:void 0,description:n,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}var wi=new me({queryCache:new ge({onError:Ci}),mutationCache:new ae({onError:(e,t,n,r)=>{r.meta?.skipGlobalErrorToast||Ci(e)}})});function Ti({...e}){return(0,K.jsx)(Rt,{"data-slot":`dropdown-menu`,...e})}function Ei({...e}){return(0,K.jsx)(ht,{"data-slot":`dropdown-menu-trigger`,...e})}function Di({className:e,sideOffset:t=4,...n}){return(0,K.jsx)(pt,{children:(0,K.jsx)(Zt,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:P(`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 Oi({className:e,inset:t,variant:n=`default`,...r}){return(0,K.jsx)(bt,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:P(`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 ki({className:e,children:t,checked:n,...r}){return(0,K.jsxs)(Ze,{"data-slot":`dropdown-menu-checkbox-item`,className:P(`focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm`,`py-1.5 pr-2 pl-8`,`text-sm outline-hidden`,`select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),checked:n,...r,children:[(0,K.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,K.jsx)(tt,{children:(0,K.jsx)(mn,{className:`size-4`})})}),t]})}function Ai({className:e,inset:t,...n}){return(0,K.jsx)($e,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:P(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function ji({className:e,...t}){return(0,K.jsx)(Je,{"data-slot":`dropdown-menu-separator`,className:P(`bg-border -mx-1 my-1 h-px`,e),...t})}function Mi({className:e,...t}){return(0,K.jsx)(`span`,{"data-slot":`dropdown-menu-shortcut`,className:P(`text-muted-foreground ml-auto text-xs tracking-widest`,e),...t})}function Ni({...e}){return(0,K.jsx)(It,{"data-slot":`dropdown-menu-sub`,...e})}function Pi({className:e,inset:t,children:n,...r}){return(0,K.jsxs)(dt,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:P(`focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground`,`flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none`,`data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0`,`[&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,K.jsx)(Jn,{className:`ml-auto size-4`})]})}function Fi({className:e,...t}){return(0,K.jsx)(lt,{"data-slot":`dropdown-menu-sub-content`,className:P(`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 Ii=`flex items-center gap-3 p-2 rounded-lg text-sm transition-colors`,Li=`block p-2 rounded-lg text-sm transition-colors`,Ri={className:`text-foreground hover:bg-accent dark:text-white dark:hover:bg-grey-700`},zi={className:`font-medium text-primary bg-primary/10 dark:text-white dark:bg-white/10`};function Bi({items:e,ariaLabel:t}){let{pathname:n}=Ce(),r=e=>e.exact?n===e.to:n.startsWith(e.to),i=e.find(r)??e[0],a=i.icon;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`nav`,{className:`hidden md:flex flex-col gap-1`,"aria-label":t,children:e.map(e=>{let t=e.icon;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(V,{to:e.to,className:Ii,activeOptions:{exact:!!e.exact},activeProps:zi,inactiveProps:Ri,children:[(0,K.jsx)(t,{className:`size-4 shrink-0`}),e.label]}),e.children&&r(e)&&(0,K.jsx)(`div`,{className:`mt-1 ml-4 flex flex-col gap-1 border-l border-border pl-3`,children:e.children.map(e=>(0,K.jsx)(V,{to:e.to,className:Li,activeOptions:{exact:!!e.exact},activeProps:zi,inactiveProps:Ri,children:e.label},e.to))})]},e.to)})}),(0,K.jsx)(`div`,{className:`md:hidden`,children:(0,K.jsxs)(Ti,{children:[(0,K.jsx)(Ei,{asChild:!0,children:(0,K.jsxs)(F,{variant:`outline`,className:`w-full justify-between`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(a,{className:`size-4`}),i.label]}),(0,K.jsx)(pn,{className:`size-4`})]})}),(0,K.jsx)(Di,{align:`start`,className:`w-(--radix-dropdown-menu-trigger-width)`,children:e.map(e=>{let t=e.icon;return[(0,K.jsx)(Oi,{asChild:!0,children:(0,K.jsxs)(V,{to:e.to,className:`flex items-center gap-2`,children:[(0,K.jsx)(t,{className:`size-4`}),e.label]})},e.to),...e.children&&r(e)?e.children.map(e=>(0,K.jsx)(Oi,{asChild:!0,children:(0,K.jsx)(V,{to:e.to,className:`flex items-center gap-2 pl-8`,children:e.label})},e.to)):[]]})})]})})]})}var Vi=[{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 Hi(e){let t=e!==null&&`fabricRole`in e&&e.fabricRole===`super_user`;return Vi.filter(n=>Tn(e,n.permission)&&!(n.ssoAccountOnly&&t))}function Ui(e){return Hi(e).length>0}function Wi(){let{isLoading:e,user:t}=wn(),{pathname:n}=Ce();if(e)return null;let r=Hi(t);if(!r.length)return(0,K.jsx)(re,{to:`/`,replace:!0});let i=Vi.find(e=>n.startsWith(e.to));return i&&!r.includes(i)?(0,K.jsx)(re,{to:r[0].to,replace:!0}):(0,K.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsxs)(`div`,{className:`md:grid gap-6 md:grid-cols-12`,children:[(0,K.jsx)(`aside`,{className:`md:col-span-3 lg:col-span-2 mb-4 md:mb-0`,children:(0,K.jsx)(Bi,{items:r,ariaLabel:`Admin sections`})}),(0,K.jsx)(`section`,{className:`md:col-span-9 lg:col-span-10 min-w-0`,children:(0,K.jsx)(Le,{})})]})})}function Gi({className:e,text:t,centered:n,...r}){return(0,K.jsxs)(`div`,{className:`text-foreground h-full w-full ${e||``} ${n?`flex flex-col items-center justify-center`:``}`,...r,children:[(0,K.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`100px`,height:`100px`,alt:`HDB Dog Logo Loading`,className:`inline-block`}),(0,K.jsx)(`p`,{className:`pt-4`,children:t||`Loading...`})]})}function Ki(){return(0,K.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 126.644 96`,width:24,height:24,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M81.15,0c-1.2376,2.1973-2.3489,4.4704-3.3591,6.794-9.5975-1.4396-19.3718-1.4396-28.9945,0-.985-2.3236-2.1216-4.5967-3.3591-6.794-9.0166,1.5407-17.8059,4.2431-26.1405,8.0568C2.779,32.5304-1.6914,56.3725.5312,79.8863c9.6732,7.1476,20.5083,12.603,32.0505,16.0884,2.6014-3.4854,4.8998-7.1981,6.8698-11.0623-3.738-1.3891-7.3497-3.1318-10.8098-5.1523.9092-.6567,1.7932-1.3386,2.6519-1.9953,20.281,9.547,43.7696,9.547,64.0758,0,.8587.7072,1.7427,1.3891,2.6519,1.9953-3.4601,2.0457-7.0718,3.7632-10.835,5.1776,1.97,3.8642,4.2683,7.5769,6.8698,11.0623,11.5419-3.4854,22.3769-8.9156,32.0509-16.0631,2.626-27.2771-4.496-50.9172-18.817-71.8548C98.9811,4.2684,90.1918,1.5659,81.1752.0505l-.0252-.0505ZM42.2802,65.4144c-6.2383,0-11.4159-5.6575-11.4159-12.6535s4.9755-12.6788,11.3907-12.6788,11.5169,5.708,11.4159,12.6788c-.101,6.9708-5.026,12.6535-11.3907,12.6535ZM84.3576,65.4144c-6.2637,0-11.3907-5.6575-11.3907-12.6535s4.9755-12.6788,11.3907-12.6788,11.4917,5.708,11.3906,12.6788c-.101,6.9708-5.026,12.6535-11.3906,12.6535Z`})})}function qi(){let e=`studio`,t=`Harper Studio`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`img`,{src:`/harper-${e}_black.png`,alt:t,className:`w-64 hidden md:inline-block dark:hidden`}),(0,K.jsx)(`img`,{src:`/harper-${e}_white.png`,alt:t,className:`w-64 hidden md:dark:inline-block`}),(0,K.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`50px`,height:`44px`,alt:`Harper`,className:`inline-block md:hidden`})]})}var Ji=y(`inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-auto`,{variants:{variant:{default:`border-primary bg-primary/40 text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`border-secondary bg-secondary/40 text-secondary-foreground [a&]:hover:bg-secondary/90`,warning:`border-yellow bg-yellow/40 text-foreground [a&]:hover:bg-yellow/90`,success:`border-green bg-green/40 text-foreground [a&]:hover:bg-green/90`,destructive:`border-transparent bg-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 Yi({className:e,variant:t,asChild:n=!1,...r}){return(0,K.jsx)(n?st:`span`,{"data-slot":`badge`,className:P(Ji({variant:t}),e),...r})}function Xi({className:e,children:t,...n}){return(0,K.jsxs)(tn,{"data-slot":`scroll-area`,className:P(`relative`,e),...n,children:[(0,K.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,K.jsx)(Zi,{}),(0,K.jsx)(Yt,{})]})}function Zi({className:e,orientation:t=`vertical`,...n}){return(0,K.jsx)(Dt,{"data-slot":`scroll-area-scrollbar`,orientation:t,className:P(`flex touch-none p-px transition-colors select-none`,t===`vertical`&&`h-full w-2.5 border-l border-l-transparent`,t===`horizontal`&&`h-2.5 flex-col border-t border-t-transparent`,e),...n,children:(0,K.jsx)($t,{"data-slot":`scroll-area-thumb`,className:`bg-border relative flex-1 rounded-full`})})}var Qi=[`notification-acks`];function $i(){let e=yn(vn.AckedNotificationIds,[]);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function ea(e){wi.setQueryData(Qi,e);try{bn(vn.AckedNotificationIds,e)}catch(e){console.warn(`[notifications] could not persist acknowledgements`,e)}}function ta(){return z({queryKey:Qi,queryFn:$i,staleTime:1/0,gcTime:1/0,initialData:$i})}function na(e){ea(Array.from(new Set([...$i(),e])))}function ra(e){ea($i().filter(t=>t!==e))}function ia(){let{data:e}=H(ta());return(0,G.useMemo)(()=>new Set(e??[]),[e])}var aa={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:mi,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`}},oa=new Set([`critical`,`error`,`outage`,`incident`,`down`,`danger`]),sa=new Set([`warning`,`warn`,`maintenance`,`degraded`,`notice`]),ca=new Set([`info`,`information`,`informational`,`success`,`ok`]);function la(e){let t=(e??``).trim().toLowerCase();return sa.has(t)?`warning`:ca.has(t)?`info`:(oa.has(t),`critical`)}function ua(e){return aa[la(e)]}var da={critical:0,warning:1,info:2};function fa(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 pa(e){let t=fa(e);return t.kind===`valid`?t.ms:null}function ma(e){return new Date(e).toLocaleString()}function ha(e,t){let n=fa(e.startAt),r=fa(e.endAt);return n.kind===`invalid`||r.kind===`invalid`?{state:`expired`,label:`Schedule unavailable`}:n.kind===`valid`&&t<n.ms?{state:`upcoming`,label:`Starts ${ma(n.ms)}`}:r.kind===`valid`&&t>r.ms?{state:`expired`,label:`Ended ${ma(r.ms)}`}:r.kind===`valid`?{state:`active`,label:`Active until ${ma(r.ms)}`}:{state:`active`,label:`Active`}}var ga=new Set([`http`,`https`,`mailto`]);function _a(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?ga.has(n)?{kind:`external`,href:t}:null:{kind:`internal`,href:t.startsWith(`/`)?t:`/${t}`}}function va({url:e,className:t,children:n,onNavigate:r}){let i=_a(e);return i?i.kind===`external`?(0,K.jsxs)(`a`,{href:i.href,target:`_blank`,rel:`noreferrer noopener`,className:t,children:[n??`Learn more`,(0,K.jsx)(dr,{className:`inline size-3 ml-1 align-[-1px]`})]}):(0,K.jsx)(V,{to:i.href,className:t,onClick:r,children:n??`View details`}):null}var ya=[`system-status`];async function ba(){let{data:e}=await N.get(`/SystemStatus/`);return Array.isArray(e)?e:[]}function xa(){return z({queryKey:ya,queryFn:ba,refetchInterval:6e4,staleTime:3e4})}var Sa=3e4,Ca=new Set,wa=Date.now(),Ta=null;function Ea(e){return Ca.add(e),Ta||=(wa=Date.now(),setInterval(()=>{wa=Date.now(),Ca.forEach(e=>e())},Sa)),()=>{Ca.delete(e),Ca.size===0&&Ta&&(clearInterval(Ta),Ta=null)}}function Da(){return(0,G.useSyncExternalStore)(Ea,()=>wa,()=>wa)}function Oa(){return H(xa())}function ka(){let[e,t]=(0,G.useState)(()=>window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`);return(0,G.useEffect)(()=>{let e=window.matchMedia(`(prefers-color-scheme: dark)`),n=e=>t(e.matches?`dark`:`light`);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var Aa=(0,G.createContext)([`system`,()=>{}]);function ja({children:e}){let[t,n]=xn(vn.Theme,`system`),r=ka();return(0,G.useEffect)(()=>{let e=t===`dark`||t===`system`&&r===`dark`;document.documentElement.classList.toggle(`dark`,e)},[t,r]),(0,K.jsx)(Aa.Provider,{value:[t,n],children:e})}function Ma(){return(0,G.useContext)(Aa)}var Na=[{value:`light`,icon:(0,K.jsx)(oi,{className:`size-4`}),label:`Light`},{value:`system`,icon:(0,K.jsx)(Rr,{className:`size-4`}),label:`System`},{value:`dark`,icon:(0,K.jsx)(zr,{className:`size-4`}),label:`Dark`}];function Pa(){let[e,t]=Ma();return(0,K.jsx)(`div`,{className:`flex items-center bg-muted dark:bg-black rounded-xl p-0.5 gap-0.5`,children:Na.map(({value:n,icon:r,label:i})=>(0,K.jsx)(`button`,{type:`button`,title:i,onClick:()=>t(n),className:`p-1.5 rounded-lg transition-colors ${e===n?`bg-background text-foreground shadow-xs`:`text-muted-foreground hover:text-foreground`}`,children:r},n))})}function Fa({className:e,...t}){return(0,K.jsx)(`div`,{className:P(`absolute top-full left-0 isolate z-50 flex justify-center`),children:(0,K.jsx)(wt,{"data-slot":`navigation-menu-viewport`,className:P(`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 Ia({className:e,children:t,viewport:n=!0,...r}){return(0,K.jsxs)(Mt,{"data-slot":`navigation-menu`,"data-viewport":n,className:P(`group/navigation-menu relative flex max-w-max flex-1 items-center justify-center`,e),...r,children:[t,n&&(0,K.jsx)(Fa,{})]})}function La({className:e,...t}){return(0,K.jsx)(Ut,{"data-slot":`navigation-menu-item`,className:P(`relative`,e),...t})}function Ra({className:e,...t}){return(0,K.jsx)(Bt,{"data-slot":`navigation-menu-link`,className:P(`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 za({className:e,...t}){return(0,K.jsx)(Nt,{"data-slot":`navigation-menu-list`,className:P(`group flex flex-1 list-none items-center justify-center gap-1`,e),...t})}function Ba({delayDuration:e=0,...t}){return(0,K.jsx)(qt,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Va({...e}){return(0,K.jsx)(Ba,{children:(0,K.jsx)(kt,{"data-slot":`tooltip`,...e})})}function Ha({...e}){return(0,K.jsx)(jt,{"data-slot":`tooltip-trigger`,...e})}function Ua({className:e,sideOffset:t=0,arrowClassName:n,children:r,...i}){return(0,K.jsx)(zt,{children:(0,K.jsxs)(Ot,{"data-slot":`tooltip-content`,sideOffset:t,className:P(`bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance`,e),...i,children:[r,(0,K.jsx)(Gt,{className:P(`bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`,n)})]})})}function Wa(){let e=`v5.2.8`,t=e.startsWith(`v`)?`https://github.com/HarperFast/studio/releases/tag/${e}`:`https://github.com/HarperFast/studio/releases`;return(0,K.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,children:(0,K.jsxs)(`span`,{className:P(Ji({variant:`default`}),`text-xs inline-block ml-2 align-text-top`),children:[e,` BETA`]})})}function Ga(e={}){let{instanceId:t,clusterId:n}=B({strict:!1});return o({id:m,...e})}function Ka(e={}){let{instanceId:t,clusterId:n}=B({strict:!1});return{instanceClient:o({id:m,...e}),entityType:`instance`}}function q(e={}){let{instanceId:t,clusterId:n}=B({strict:!1});return(0,G.useMemo)(()=>qa({instanceId:t,clusterId:n,...e}),[e.instanceId??t,e.clusterId??n,e.operationsUrl,e.port,e.secure,e.disableFabricConnect,e.forceFabricConnect])}function qa({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 Ja(){localStorage.clear()}function Ya(){sessionStorage.clear()}async function Xa(){u.setUserForEntity(m,null),wi.getQueryCache().clear(),Ja(),Ya(),await wi.invalidateQueries({refetchType:`none`})}async function Za(e){await u.signOutFromPotentiallyAuthenticatedInstances(),await d({...e,entityId:m})}function Qa(){let e=Ga();return R({mutationFn:()=>Za({instanceClient:e}),onSuccess:Xa})}function $a(e){return!!e}var eo={className:`text-foreground dark:text-white font-semibold`};function to(){let{mutate:e}=Qa(),t=L(),{user:n}=Cn(),r=Ui(n),i=se(),a=(0,G.useCallback)(()=>{e(void 0,{onSuccess:async()=>{U.success(`Success`,{description:`You have been signed out successfully.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),t({to:`/sign-in`}),i.invalidate()}})},[e,i,t]),o=(0,G.useMemo)(()=>[!1,!1,{to:`https://docs.harperdb.io/docs`,target:`_blank`,icon:(0,K.jsx)(Hn,{}),text:`Docs`,textBreakpoint:`md`},{to:`https://github.com/HarperFast/studio/issues`,target:`_blank`,icon:(0,K.jsx)(Wn,{}),text:`Report an Issue`,textBreakpoint:`lg`},{to:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,icon:(0,K.jsx)(Ki,{}),text:`Discord`,textBreakpoint:`lg`},{onClick:a,icon:(0,K.jsx)(Nr,{}),text:`Sign Out`,textBreakpoint:`md`}].filter($a),[a,r]);return n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(oo,{menuItems:o}),(0,K.jsx)(io,{menuItems:o})]}):(0,K.jsx)(ro,{})}function no(e){return e.items!==void 0}function ro(){return(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`inline-block`,children:[(0,K.jsx)(V,{to:`/sign-in`,children:(0,K.jsx)(qi,{})}),(0,K.jsx)(Wa,{})]}),(0,K.jsx)(Ia,{children:(0,K.jsxs)(za,{className:`text-muted-foreground dark:text-grey-400`,children:[(0,K.jsx)(La,{children:(0,K.jsx)(Ra,{asChild:!0,children:(0,K.jsxs)(V,{to:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noreferrer noopener`,className:`flex-row items-center`,children:[(0,K.jsx)(Hn,{}),` `,(0,K.jsx)(`span`,{className:`hidden md:inline-block`,children:`Docs`})]})})}),(0,K.jsx)(La,{children:(0,K.jsx)(Pa,{})}),(0,K.jsx)(La,{children:(0,K.jsx)(Ra,{asChild:!0,children:(0,K.jsxs)(V,{to:`/sign-in`,className:`flex-row items-center`,activeProps:eo,children:[(0,K.jsx)(jr,{}),` Sign In`]})})})]})})]})}function io({menuItems:e}){let{user:t}=Cn();return Pn(t),(0,K.jsx)(`div`,{className:`hidden md:[@media(hover:hover)]:block xl:block`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`inline-block`,children:[(0,K.jsx)(V,{to:`/`,children:(0,K.jsx)(qi,{})}),(0,K.jsx)(Wa,{})]}),(0,K.jsx)(Ia,{children:(0,K.jsxs)(za,{className:`text-muted-foreground dark:text-grey-400`,children:[e.map(e=>no(e)?!!e.items.length&&(0,K.jsx)(`div`,{className:`bg-muted dark:bg-black rounded-2xl flex`,children:e.items.map(e=>(0,K.jsx)(ao,{menuItem:e},e.text))},e.text):(0,K.jsx)(ao,{menuItem:e},e.text)),!1,(0,K.jsx)(La,{children:(0,K.jsx)(Pa,{})})]})})]})})}function ao({menuItem:e}){return(0,K.jsx)(La,{className:`text-muted-foreground dark:text-gray-400 hover:text-foreground dark:hover:text-white`,children:(0,K.jsxs)(Va,{children:[(0,K.jsx)(Ha,{asChild:!0,children:(0,K.jsx)(Ra,{asChild:!0,children:(0,K.jsxs)(V,{to:e.to,onClick:e.onClick,"aria-label":e.text,className:`flex-row items-center`,target:e.target,activeProps:e.to?eo:void 0,children:[e.icon,(0,K.jsx)(`span`,{className:`hidden ${e.textBreakpoint}:inline-block`,children:e.text}),(0,K.jsx)(`span`,{className:`${e.textBreakpoint}:hidden`,children:`\xA0`})]})})}),(0,K.jsx)(Ua,{side:`bottom`,className:`${e.textBreakpoint}:hidden`,children:e.text})]})})}function oo({menuItems:e}){let{user:t}=Cn();Pn(t);let[n,r]=(0,G.useState)(!1),i=(0,G.useCallback)(()=>r(e=>!e),[]),a=(0,G.useCallback)(()=>r(!1),[]);return(0,K.jsxs)(`div`,{className:`md:[@media(hover:hover)]:hidden xl:hidden`,id:`mobile-menu`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(V,{to:`/`,children:(0,K.jsx)(qi,{})}),(0,K.jsx)(Wa,{}),(0,K.jsxs)(`div`,{className:`flex items-center`,children:[!1,(0,K.jsxs)(`button`,{type:`button`,className:`shadow-xs text-muted-foreground dark:text-grey-400 hover:text-foreground dark:hover:text-white hover:bg-muted dark:hover:bg-black-dark`,onClick:i,children:[(0,K.jsx)(`span`,{className:`sr-only`,children:n?`Close menu`:`Open menu`}),n?(0,K.jsx)(gn,{}):(0,K.jsx)(Lr,{})]})]})]}),(0,K.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,K.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,K.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,K.jsx)(Pa,{})}),e.map(e=>no(e)?!!e.items.length&&(0,K.jsx)(`div`,{className:`bg-muted dark:bg-black pl-10 pr-2 py-2`,children:e.items.map(e=>(0,K.jsx)(so,{menuItem:e,onClick:a},e.text))},e.text):(0,K.jsx)(so,{menuItem:e,onClick:a},e.text))]})]})}function so({menuItem:e,onClick:t}){let n=(0,G.useCallback)(()=>{e.onClick?.(),t()},[e,t]);return(0,K.jsxs)(V,{to:e.to,onClick:n,target:e.target,className:`flex flex-row px-3 py-2 text-base font-medium rounded-md text-muted-foreground dark:text-gray-400 hover:text-foreground dark:hover:text-white`,activeProps:e.to?eo:void 0,children:[e.icon,(0,K.jsx)(`span`,{className:`ml-4`,children:e.text})]})}function co(){let{isLoading:e}=Cn(),{createCluster:t}=le({strict:!1}),[,n]=xn(vn.SavedClusterState,null);return(0,G.useEffect)(()=>{t&&n(t)},[t,n]),e?(0,K.jsx)(Gi,{className:`fixed z-50 translate-1/2`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.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,K.jsx)(to,{})}),(0,K.jsx)(`main`,{children:(0,K.jsx)(Le,{})})]})}function lo(){let e=location.hash;return e?e.startsWith(`#/`)?e.slice(1):e:`/`}var uo=[`/`,`/forgot-password`,`/reset-password`,`/sign-in`,`/sign-up`,`/verify-email`];function fo(){let e=lo();return!uo.includes(e)&&{redirect:e}}var po=`me|email|token|access_token|id_token|refresh_token|code|secret|password|api[-_]?key`,mo=String.raw`[^&#\s",<>[\]{}|\\]+`,ho=String.raw`[\w.%+!~*'()-]+(?:@|%40)[\w-]+(?:\.[\w-]+)*\.\w{2,}`;new RegExp(String.raw`([?&](?:${po})=)${mo}`,`gi`),new RegExp(String.raw`([?&](?:${po})=)${mo}|${ho}`,`gi`);var go=String.raw`[\w-]+-extension`;new RegExp(String.raw`^${go}://`),new RegExp(String.raw`^\s*at\s.* @ ((?:blob:)?(?:https?|${go})://\S*)\s*$`);var _o=!1;function vo(){(0,G.useEffect)(()=>{_o||=!0},[])}function yo(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(we,{}),(0,K.jsx)(Le,{})]})}var bo=fe()({component:yo}),xo=I({getParentRoute:()=>bo,id:`_dashboardLayout`,component:co,beforeLoad:({context:e})=>{let t=e.authentication[m];if(t&&!t.isLoading&&!t.user)throw ie({to:`/sign-in`,search:fo()})}}),So=I({getParentRoute:()=>xo,path:`admin`,component:Wi});I({getParentRoute:()=>So,path:`/`,beforeLoad:()=>{throw ie({to:`/admin/notifications`})}}),I({getParentRoute:()=>So,path:`notifications`,head:()=>({meta:[{title:`Notifications — Harper Fabric`}]}),component:ye(async()=>ze(()=>import(`./notifications-DPTOF-SX.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])),`NotificationsAdminIndex`)}),I({getParentRoute:()=>So,path:`regions`,head:()=>({meta:[{title:`Regions — Harper Fabric`}]}),component:ye(async()=>ze(()=>import(`./regions-B5lGduv5.js`),__vite__mapDeps([15,1,3,2,4,5,6,7,8,9,10,11,12,13,16])),`RegionsIndex`)}),I({getParentRoute:()=>So,path:`api-token`,head:()=>({meta:[{title:`API Token — Harper Fabric`}]}),component:ye(async()=>ze(()=>import(`./apiToken-CrPb_98N.js`),__vite__mapDeps([17,1,2,3,4,5,6,7])),`ApiTokenIndex`)});function Co(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.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,K.jsx)(to,{})}),(0,K.jsxs)(`div`,{className:`pt-20 h-screen grid grid-cols-1 md:grid-cols-2`,children:[(0,K.jsx)(`section`,{"aria-label":`Harper Fabric overview`,className:`items-center justify-center hidden text-white md:flex px-6 fabricSignupTextContainer`,children:(0,K.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,K.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,K.jsx)(`div`,{className:`min-h-full flex items-start justify-center py-12`,children:(0,K.jsx)(Le,{})})})]})]})}function wo(){(0,G.useEffect)(()=>{},[])}var To=[`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 Eo(e){if(!e||!e.includes(`@`))return null;let t=e.split(`@`).pop()||``;if(!t)return null;for(let e of To)if(t===e||t.endsWith(`.`+e))return null;return t}var Do=`utm_`;function Oo(e){let t=new URLSearchParams(e),n=Array.from(t.keys()).filter(e=>e.toLowerCase().startsWith(Do));if(n.length===0)return e;for(let e of n)t.delete(e);let r=t.toString();return r?`?${r}`:``}function ko(){if(typeof location>`u`||typeof history>`u`)return;let{search:e,pathname:t,hash:n,origin:r}=location,i=Oo(e);i!==e&&history.replaceState(history.state,``,`${r}${t}${i}${n}`)}var Ao=null;function jo(){let e=L(),t=se(),n=oe(),{redirect:r}=le({strict:!1});return(0,G.useEffect)(()=>{Ao||=(async function(){let i=await l().catch(()=>null);if(!i)U.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),ko();let a=Pn(i);Eo(i.email),await n.invalidateQueries({queryKey:f,refetchType:`none`}),await t.invalidate(),await e({to:r?.startsWith(`/`)?r:a})}Ao=null})()},[]),(0,K.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`text-foreground dark:text-white w-lg flex flex-col gap-4`,children:[(0,K.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Checking...`]}),(0,K.jsx)(`div`,{className:`underline flex gap-4`,children:(0,K.jsx)(V,{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 Mo=new Map;function No(e){if(!e)return``;if(Mo.has(e))return Mo.get(e);let t=e.replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();if(!t)return Mo.set(e,``),``;let n=t.match(/([A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|[0-9]+)/g);if(!n)return Mo.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(Po).join(` `);return Mo.set(e,i),i}function Po(e){return/^[A-Z]{2,3}s?$/.test(e)||/^[0-9]+$/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function Fo({restartRequired:e}){let t=Ce(),{organization:n,instance:r,cluster:i}=pe({strict:!1}),a=(0,G.useMemo)(()=>{let e=t.pathname.split(`/`).filter(e=>e&&e.length>0),a=[(0,K.jsxs)(V,{to:`/`,children:[(0,K.jsx)(Cr,{"aria-hidden":`true`,className:`size-5 shrink-0`}),(0,K.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=No(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,K.jsx)(`svg`,{fill:`currentColor`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`size-5 shrink-0 text-grey`,children:(0,K.jsx)(`path`,{d:`M5.555 17.776l8-16 .894.448-8 16-.894-.448z`})},a.length+`-dash`),(0,K.jsx)(V,{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,K.jsxs)(`div`,{role:`list`,className:`flex items-center space-x-2 xl:space-x-4 sm:max-w-9/10 max-w-[calc(100%-56px)]`,children:[...a,e&&(0,K.jsxs)(Va,{children:[(0,K.jsx)(Ha,{asChild:!0,children:(0,K.jsxs)(`div`,{className:`text-xs italic text-muted-foreground`,children:[`* Restart `,(0,K.jsx)(`span`,{className:`hidden lg:inline-block`,children:`Requested`})]})}),(0,K.jsxs)(Ua,{side:`bottom`,children:[`This `,`Instance`,` is requesting a restart, when convenient, to apply your latest changes.`,(0,K.jsx)(`br`,{}),`You can do this from the Apps or Config pages.`]})]})]})}var Io=Vt,Lo=(0,G.createContext)({}),Ro=(0,G.createContext)({});function zo(){let e=(0,G.useContext)(Lo),t=(0,G.useContext)(Ro),{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}=zo();return(0,K.jsx)(st,{"data-slot":`form-control`,id:n,"aria-describedby":t?`${r} ${i}`:`${r}`,"aria-invalid":!!t,...e})}function Y({...e}){return(0,K.jsx)(Lo,{value:{name:e.name},children:(0,K.jsx)(Kt,{...e})})}function X({className:e,...t}){let n=(0,G.useId)();return(0,K.jsx)(Ro,{value:{id:n},children:(0,K.jsx)(`div`,{"data-slot":`form-item`,className:P(`grid gap-2`,e),...t})})}function Bo({className:e,...t}){return(0,K.jsx)(At,{"data-slot":`label`,className:P(`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}=zo();return(0,K.jsx)(Bo,{"data-slot":`form-label`,"data-error":!!n,className:P(`data-[error=true]:text-destructive`,e),htmlFor:r,...t})}function Q({className:e,...t}){let{error:n,formMessageId:r}=zo(),i=n?String(n?.message):t.children;return i?(0,K.jsx)(`p`,{"data-slot":`form-message`,id:r,className:P(`text-destructive text-sm`,e),...t,children:i}):null}function $({className:e,type:t,...n}){return(0,K.jsx)(`input`,{type:t,"data-slot":`input`,className:P(`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 Vo=[`RUNNING`],Ho=[`TERMINATING`,`TERMINATED`,`REMOVED`];function Uo(){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 Wo({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 Go(){return R({mutationFn:Wo})}function Ko({cluster:e,instance:t,instanceParams:n}){let r=L(),i=se(),{redirect:a}=le({strict:!1}),{mutate:o,isPending:s}=Go();return{isPending:s,submitForm:(0,G.useCallback)(async s=>{o({...s,...n},{onSuccess:async({message:n,user:o})=>{if(U.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 qo(e){if(Qo(e)||$o(e))return`warning`;if(Yo(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 Jo(e){switch(e){case`STOPPED`:case`STOPPING`:case`STARTING`:case`RESTARTING`:return!0;default:return!1}}function Yo(e){switch(e){case`RUNNING`:case`UPDATED`:return!0;default:return!1}}function Xo(e){switch(e){case`FAILED`:return!0;default:return!1}}function Zo(e){switch(e){case`TERMINATED`:return!0;default:return!1}}function Qo(e){switch(e){case`CLONE_PENDING`:case`PENDING_UPGRADE`:return!0;default:return!1}}function $o(e){switch(e){case`PROVISIONING`:case`CLONING`:case`CLONE_READY`:case`UPDATING_HDB_NODES`:case`DRAINING`:case`UPDATING`:return!0;default:return!1}}function es(e){let t=(e?.instances??[]).filter(e=>!(e.status&&Ho.includes(e.status)));return t.length>0&&t.every(e=>Yo(e.status))}function ts(e){return e?.response?.status??e?.status}function ns(e){return ts(e)===403}function rs(e){let t=ts(e);return t===400||t===403}function is(e){return t=>ns(t.state.error)?!1:e??!1}function as(e=3){return(t,n)=>!rs(n)&&t<e}async function os(e){let{data:t}=await N.get(`/Cluster/${e}`);return t}async function ss(e,t){let{queryKey:n}=cs(t);await e.cancelQueries({queryKey:n,exact:!0}),e.setQueryData(n,e=>e&&{...e,resetPassword:!1})}function cs(e,t){return z({queryKey:[e],queryFn:()=>os(e),retry:!1,staleTime:1900,enabled:!!e,refetchInterval:is(t?t===!0?1e4:t:void 0)})}var ls=w({error:`Please enter a valid email address.`}).toLowerCase().trim(),us=M().nonempty({error:`Please enter your password.`}),ds=M().nonempty({error:`Please enter a username.`}),fs=b({username:ds,password:us}),ps=b({email:ls,password:us});function ms({entityId:e,instanceClient:t}){return z({queryKey:[`health`,e],queryFn:async()=>{try{return await t.get(`/health`),!0}catch{return!1}},retry:2,refetchInterval:5e3})}var hs=[`localhost`,`127.0.0.1`],gs=function(e){return e.MixedLoopback=`MixedLoopback`,e.InsecureCookieOutsideChromeAndFirefox=`InsecureCookieOutsideChromeAndFirefox`,e}({});function _s(e,t,n){if(!n||!t||!e)return null;let r=new URL(n).hostname,i=hs.includes(t),a=hs.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 vs(){let{clusterId:e,instanceId:t}=B({strict:!1}),{data:n}=H(cs(e,!0)),r=(0,G.useMemo)(()=>t&&n&&n?.instances?.find(e=>e.id===t)||void 0,[n,t]),i=(0,G.useMemo)(()=>n?.status&&Vo.includes(n.status),[n?.status]),a=`instance`,o=(0,G.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,G.useEffect)(()=>{r?u.setUserForEntity(r,null):n&&u.setUserForEntity(n,null)},[s]);let l=q({operationsUrl:o}),d=(0,G.useMemo)(()=>o?.includes(`localhost`)||o?.includes(`127.0.0.1`),[o]),f=(0,G.useMemo)(()=>_s(navigator.userAgent,location.hostname,o),[o]),{data:m}=H(ms(l)),h=Pt({resolver:Ke(fs),defaultValues:{username:``,password:``}}),{control:g,handleSubmit:v}=h,{submitForm:y,isPending:b}=Ko({cluster:n,instance:r,instanceParams:l});if(!t&&n&&!n?.fqdn)return(0,K.jsx)(re,{to:`../instances`,replace:!0});if(n?.resetPassword){let e=i&&es(n);return(0,K.jsx)(re,{to:`/${n.organizationId}/${n.id}/${e?`finish-setup`:`starting-up`}`,replace:!0})}return(0,K.jsxs)(K.Fragment,{children:[!1,(0,K.jsx)(`div`,{className:_(`min-h-screen`,`items-center justify-center flex`),children:(0,K.jsxs)(`div`,{className:`text-foreground w-xs py-8`,children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-light`,children:[`Sign in to Harper `,`Local`]}),(0,K.jsx)(Io,{...h,children:(0,K.jsxs)(`form`,{id:`auth-${a}-signin-form`,name:`auth-${a}-signin-form`,onSubmit:v(y),className:`my-4`,children:[(0,K.jsx)(Y,{control:g,name:`username`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Username`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{autoComplete:`username`,autoFocus:!0,type:`text`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:g,name:`password`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(F,{disabled:b,type:`submit`,variant:`submit`,className:`w-full my-2`,children:`Sign In`}),m===!1&&(0,K.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,K.jsx)(`span`,{className:`font-medium`,children:`Warning!`}),` This `,a,` is not responding to GET`,` `,(0,K.jsxs)(`a`,{href:`${o}health`,className:`underline`,target:`_blank`,children:[o,`health`]}),` `,`checks.`,(0,K.jsxs)(`ol`,{className:`list-decimal ml-8 mt-2`,children:[(0,K.jsx)(`li`,{children:`Is the server running?`}),(0,K.jsxs)(`li`,{children:[`Have you`,` `,(0,K.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,K.jsxs)(`li`,{children:[`Have you allowed`,` `,(0,K.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===gs.MixedLoopback&&(0,K.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,K.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===gs.InsecureCookieOutsideChromeAndFirefox&&(0,K.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,K.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,K.jsxs)(`div`,{className:`p-4 mt-4 text-sm rounded-lg bg-purple-950`,role:`alert`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:`Did you know?`}),` `,`You can add this instance to your Harper account to manage it remotely.`,(0,K.jsx)(`div`,{className:`text-center pt-2`,children:(0,K.jsx)(V,{to:Uo(),target:`_blank`,children:(0,K.jsx)(F,{type:`button`,variant:`positive`,children:`Connect to Harper Fabric`})})})]})]})})]})})]})}function ys({overEmail:e}){return(0,K.jsx)(`a`,{href:e?`mailto:support@harperdb.io`:`https://discord.com/channels/1415002037439041710/1415002038286286994`,target:`_blank`,rel:`noreferrer`,className:`underline`,children:`Contact us`})}function bs(){return!1}var xs;function Ss(){return xs??=Es().catch(e=>{throw xs=void 0,e}),xs}function Cs(){bs()&&Ss().catch(()=>{})}async function ws(e){}var Ts=8e3;function Es(){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`),Ts);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 Ds=`verification failed`,Os=[`error`,`message`,`title`,`detail`];function ks(e){let t=e?.response;if(t?.status!==403)return!1;let n=t.data;return typeof n==`string`?As(n):Os.some(e=>As(n?.[e]))}function As(e){return typeof e==`string`&&e.toLowerCase().includes(Ds)}var js=`Verification failed. Please try again.`,Ms=`We could not run the verification check. Disable any ad blocker for this page, then reload and try again.`,Ns=2;function Ps(e){(0,G.useEffect)(()=>{Cs()},[]);let t=(0,G.useRef)(!1),[n,r]=(0,G.useState)(!1),i=(0,G.useCallback)(async()=>{r(!0);try{let n=await ws(e);return t.current=bs()&&!n,n}finally{r(!1)}},[e]),a=(0,G.useRef)(0),[o,s]=(0,G.useState)(!1);return{getToken:i,describeCaptchaError:(0,G.useCallback)(e=>{if(!ks(e)){a.current=0,s(!1);return}return a.current+=1,s(a.current>=Ns),t.current?Ms:js},[]),minting:n,supportSuggested:o}}async function Fs({email:e,captchaToken:t}){let{data:n}=await N.post(`/ForgotPassword/`,{email:e,...t?{captchaToken:t}:{}});if(n)return n;throw Error(`Something went wrong`)}function Is(){return R({mutationFn:e=>Fs(e),meta:{skipGlobalErrorToast:!0}})}var Ls=b({email:ls});function Rs(){let e=L(),{me:t}=le({strict:!1}),n=Pt({resolver:Ke(Ls),defaultValues:{email:t||``}}),r=n.watch(`email`),{setFocus:i,setError:a,clearErrors:o,control:s,handleSubmit:c,formState:l}=n,u=l.errors.root?.message;(0,G.useEffect)(()=>{i(`email`)},[i]);let{mutate:d,isPending:f}=Is(),p=Ps(`forgot_password`),m=async t=>{o(`root`);let n=await p.getToken();d({...t,captchaToken:n},{onSuccess:t=>{U.success(`Success`,{description:`${t}`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),e({to:`/sign-in`,search:{me:r}})},onError:e=>{let t=p.describeCaptchaError(e);if(t){a(`root`,{type:`server`,message:t});return}Ci(e)}})};return(0,K.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light`,children:`Enter your account email`}),(0,K.jsx)(`p`,{className:`text-sm pt-1`,children:`If a matching account exists, we'll send you a password reset link.`}),(0,K.jsx)(Io,{...n,children:(0,K.jsxs)(`form`,{id:`auth-forgot-password-form`,name:`auth-forgot-password-form`,onSubmit:c(m),className:`my-4`,children:[(0,K.jsx)(Y,{control:s,name:`email`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-2`,children:[(0,K.jsx)(Z,{children:`Email`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{disabled:f,type:`email`,className:`dark:bg-black dark:border-black`,...e})}),(0,K.jsx)(Q,{})]})}),u&&(0,K.jsxs)(`p`,{role:`alert`,"data-slot":`form-message`,className:`text-destructive text-sm`,children:[u,p.supportSuggested&&(0,K.jsxs)(K.Fragment,{children:[` `,(0,K.jsx)(ys,{overEmail:!0}),` if this keeps happening.`]})]}),(0,K.jsx)(F,{type:`submit`,variant:`submit`,disabled:f||p.minting,className:`w-full my-2`,children:`Send Password Reset Email`})]})}),(0,K.jsxs)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:[(0,K.jsx)(V,{className:`text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:r},children:`Sign in to your account`}),(0,K.jsx)(V,{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 N.put(`/ResetPassword/`,{token:e,newPassword:t});return n};function Bs(){return R({mutationFn:e=>zs(e)})}var Vs=b({password:us.min(8,{error:`Password must be at least 8 characters long.`}).max(50,{error:`Password cannot be longer than 50 characters.`}),confirmPassword:M()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});function Hs(){let{token:e}=le({strict:!1}),t=L();(0,G.useEffect)(()=>{e||t({to:`/sign-in`})},[e,t]);let n=Pt({resolver:Ke(Vs),defaultValues:{password:``,confirmPassword:``}}),{setFocus:r,control:i,handleSubmit:a}=n;(0,G.useEffect)(()=>{r(`password`)},[r]);let{mutate:o,isPending:s}=Bs(),c=(0,G.useCallback)(async n=>{o({token:e,password:n.password},{onSuccess:()=>{U.success(`Success`,{description:`Your password has been reset successfully.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),t({to:`/sign-in`})}})},[t,o,e]);return(0,K.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light`,children:`Reset Password`}),(0,K.jsx)(Io,{...n,children:(0,K.jsxs)(`form`,{id:`auth-reset-password-form`,name:`auth-reset-password-form`,className:`my-4`,onSubmit:a(c),children:[(0,K.jsx)(Y,{control:i,name:`password`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-2`,children:[(0,K.jsx)(Z,{children:`New Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{disabled:s,type:`password`,autoComplete:`new-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:i,name:`confirmPassword`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-2`,children:[(0,K.jsx)(Z,{children:`Confirm Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{disabled:s,type:`password`,autoComplete:`new-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(F,{variant:`submit`,type:`submit`,disabled:s,className:`w-full my-2`,children:`Submit New Password`})]})})]})}function Us(){return(0,K.jsx)(Yi,{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 Ws({text:e,disabled:t,onClick:n,lastUsed:r=!1}){let i=(0,K.jsxs)(`a`,{href:`/oauth/github/login?redirect=%2F%23%2Fcheck-oauth`,onClick:n,"aria-disabled":t||void 0,className:_(`github-signin-btn`,t&&`opacity-50 cursor-default`),children:[(0,K.jsx)(`img`,{src:`/github/GitHub_Invertocat_White.svg`,alt:``,className:`github-icon`}),e]});return r?(0,K.jsxs)(`div`,{className:`relative flex flex-col`,children:[i,(0,K.jsx)(Us,{})]}):i}function Gs({text:e,disabled:t,onClick:n,lastUsed:r=!1}){let i=(0,K.jsxs)(`a`,{href:`/oauth/google/login?redirect=%2F%23%2Fcheck-oauth`,onClick:n,"aria-disabled":t||void 0,className:_(`gsi-material-button`,t&&`opacity-50 cursor-default`),children:[(0,K.jsx)(`div`,{"aria-hidden":`true`,className:`gsi-material-button-state`}),(0,K.jsxs)(`div`,{className:`gsi-material-button-content-wrapper`,children:[(0,K.jsx)(`div`,{"aria-hidden":`true`,className:`gsi-material-button-icon`,children:(0,K.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,K.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,K.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,K.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,K.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,K.jsx)(`path`,{fill:`none`,d:`M0 0h48v48H0z`})]})}),(0,K.jsx)(`span`,{className:`gsi-material-button-contents`,children:e}),(0,K.jsx)(`span`,{className:`hidden`,children:e})]})]});return r?(0,K.jsxs)(`div`,{className:`relative flex flex-col`,children:[i,(0,K.jsx)(Us,{})]}):i}function Ks(e){if(!D(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 qs=async({email:e})=>{let{data:t}=await N.post(`/ResendVerificationEmail/`,{email:e});return t};function Js(){return R({mutationFn:e=>qs(e)})}function Ys(){let e=L(),t=oe(),n=se(),{redirect:r}=le({strict:!1}),{mutate:i,isPending:a}=Xs(),{mutate:o}=Js();return{isPending:a,submitForm:(0,G.useCallback)(a=>{i(a,{onSuccess:async i=>{u.setUserForEntity(m,i),ko();let a=Pn(i);Eo(i.email),await t.invalidateQueries({queryKey:f,refetchType:`none`}),n.invalidate(),await e({to:r?.startsWith(`/`)?r:a})},onError:t=>{if(Ks(t)){o({email:a.email},{onSuccess:()=>U.info(`Verify your email to finish signing in`,{description:`We sent a new verification link to ${a.email}.`})}),e({to:`/verifying?email=`+encodeURIComponent(a.email)});return}Ci(t)}})},[e,t,r,o,n,i])}}function Xs(){return R({mutationFn:e=>Zs(e),meta:{skipGlobalErrorToast:!0}})}async function Zs({email:e,password:t}){let{data:n}=await N.post(`/Login/`,{email:e,password:t});if(n)return n;throw Error(`Something went wrong`)}function Qs(){let[e,t]=xn(vn.RememberSignInMethod,!0),[n,r]=xn(vn.LastUsedSignInMethod,null),i=(0,G.useCallback)(t=>{e&&(bn(vn.LastUsedSignInMethod,t),r(t))},[e,r]),a=(0,G.useCallback)(()=>{r(null),t(!1)},[r,t]),o=(0,G.useCallback)(()=>{t(!0)},[t]);return{lastUsed:e?n:null,remember:e,recordMethod:i,disable:a,enable:o}}var $s=`mx-auto mt-3 block text-xs text-muted-foreground underline hover:text-foreground dark:text-inherit dark:hover:text-blue-300`;function ec(){let{me:e}=le({strict:!1}),t=Pt({resolver:Ke(ps),defaultValues:{email:e||``,password:``}}),{handleSubmit:n,control:r}=t,i=t.watch(`email`),{submitForm:a,isPending:o}=Ys(),{lastUsed:s,remember:c,recordMethod:l,disable:u,enable:d}=Qs();return(0,K.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-center`,children:`Sign in to Harper Fabric`}),(0,K.jsx)(Io,{...t,children:(0,K.jsxs)(`form`,{id:`auth-signin-form`,name:`auth-signin-form`,onSubmit:n(a),className:`my-4`,children:[(0,K.jsx)(Y,{control:r,name:`email`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Email`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`email`,autoFocus:!0,autoComplete:`email`,className:`dark:bg-black dark:border-black`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:r,name:`password`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,autoComplete:`current-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(F,{type:`submit`,variant:`submit`,className:`w-full my-2`,disabled:o,children:`Sign In`}),(0,K.jsxs)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:[(0,K.jsx)(V,{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,K.jsx)(V,{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,K.jsx)(`hr`,{"aria-hidden":`true`,className:`border-border dark:border-gray-600 my-6`}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(Gs,{text:`Sign in with Google`,lastUsed:s===`google`,onClick:()=>l(`google`)}),(0,K.jsx)(Ws,{text:`Sign in with GitHub`,lastUsed:s===`github`,onClick:()=>l(`github`)})]}),c?s&&(0,K.jsx)(`button`,{type:`button`,onClick:u,className:$s,children:`On a shared device? Forget my sign-in method.`}):(0,K.jsx)(`button`,{type:`button`,onClick:d,className:$s,children:`Remember my last sign-in method on this device.`})]})}var tc=/^[a-zA-ZàáâäãåąčćęèéêëėįìíîïłńòóôöõøùúûüųūÿýżźñçčšžæÀÁÂÄÃÅĄĆČĖĘÈÉÊËÌÍÎÏĮŁŃÒÓÔÖÕØÙÚÛÜŲŪŸÝŻŹÑßÇŒÆČŠŽ∂ð ,'-]+$/u;async function nc({captchaToken:e,...t}){let{data:n}=await N.post(`/User/`,{...t,...e?{captchaToken:e}:{}});if(n)return n;throw Error(`Something went wrong`)}function rc(){return R({mutationFn:e=>nc(e),meta:{skipGlobalErrorToast:!0}})}var ic=b({email:ls.max(80,{error:`Email cannot be longer than 80 characters.`}),firstname:M().trim().min(2,{error:`Please enter your first name.`}).regex(tc,{error:`First name can only contain letters, spaces, and hyphens.`}).max(40,{error:`First name cannot be longer than 40 characters.`}),lastname:M().trim().min(2,{error:`Please enter your last name.`}).regex(tc,{error:`Last name can only contain letters, spaces, and hyphens.`}).max(80,{error:`Last name cannot be longer than 80 characters.`}),password:us.min(8,{error:`Password must be at least 8 characters long.`}),confirmPassword:M(),acceptTerms:C().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 ac(){let e=L(),{email:t,me:n}=le({strict:!1}),[r,i]=(0,G.useState)(!1),a=Pt({resolver:Ke(ic),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,G.useEffect)(()=>{c(`firstname`)},[c]);let{mutate:h,isPending:g}=rc(),_=Ps(`signup`),v=(0,G.useCallback)(async t=>{let{confirmPassword:n,acceptTerms:r,...i}=t;u(`root`);let a=await _.getToken();h({...i,captchaToken:a},{onSuccess:()=>{Eo(i.email),ko(),e({to:`/verifying?email=`+encodeURIComponent(i.email)})},onError:e=>{console.error(e),l(`root`,{type:`server`,message:_.describeCaptchaError(e)??Si(e).message})}})},[u,e,l,h,_]),y=(0,G.useCallback)(e=>{if(!s)return i(!0),setTimeout(()=>i(!1),1e3),e.preventDefault(),!1},[s]),b=(0,K.jsx)(Y,{control:d,name:`acceptTerms`,render:({field:e})=>(0,K.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,K.jsx)(J,{children:(0,K.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,K.jsxs)(`div`,{className:`space-y-1 leading-none`,children:[(0,K.jsxs)(Z,{className:`text-xs font-normal`,children:[`I accept the`,` `,(0,K.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,K.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,K.jsx)(Q,{})]})]})});return(0,K.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-center`,children:`Sign up for Harper Fabric`}),(0,K.jsxs)(Io,{...a,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 my-6`,children:[b,(0,K.jsx)(Gs,{text:`Sign up with Google`,disabled:!s,onClick:y}),(0,K.jsx)(Ws,{text:`Sign up with GitHub`,disabled:!s,onClick:y})]}),(0,K.jsx)(`hr`,{className:`border-gray-600`}),(0,K.jsxs)(`form`,{id:`auth-signup-form`,name:`auth-signup-form`,onSubmit:f(v),className:`grid gap-4 my-4`,children:[(0,K.jsx)(Y,{control:d,name:`firstname`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`First Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,className:`dark:bg-black dark:border-black`,autoCapitalize:`words`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:d,name:`lastname`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Last Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,className:`dark:bg-black dark:border-black`,autoCapitalize:`words`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:d,name:`email`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Email`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`email`,readOnly:!!t,disabled:!!t,className:`dark:bg-black dark:border-black`,autoComplete:`email`,autoCapitalize:`none`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:d,name:`password`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,autoComplete:`new-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:d,name:`confirmPassword`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Confirm Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,autoComplete:`new-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,K.jsx)(Q,{})]})}),b,m&&(0,K.jsxs)(`p`,{role:`alert`,"data-slot":`form-message`,className:`text-destructive text-sm`,children:[m,_.supportSuggested&&(0,K.jsxs)(K.Fragment,{children:[` `,(0,K.jsx)(ys,{overEmail:!0}),` if this keeps happening.`]})]}),(0,K.jsx)(F,{type:`submit`,variant:`submit`,disabled:g||_.minting,className:`w-full my-4`,children:`Sign Up For Free`})]})]}),(0,K.jsx)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:(0,K.jsx)(V,{className:`m-auto text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:o},children:`Already have an account? Sign in instead.`})})]})}var oc=async e=>{let{data:t}=await N.put(`/VerifyEmail/`,{token:e.toString()});return t};function sc(){return R({mutationFn:e=>oc(e)})}var cc=b({email:ls});function lc(){let e=L(),{mutate:t,isPending:n}=Js(),r=Pt({resolver:Ke(cc),defaultValues:{email:``}}),i=r.watch(`email`),{setFocus:a,control:o,handleSubmit:s}=r;(0,G.useEffect)(()=>{a(`email`)},[a]);let c=(0,G.useCallback)(async n=>{t(n,{onSuccess:t=>{U.success(`Success`,{description:`${t}`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),e({to:`/sign-in`,search:{me:i}})}})},[i,e,t]);return(0,K.jsxs)(Io,{...r,children:[(0,K.jsx)(`p`,{className:`text-sm py-2`,children:`Please Enter an Email`}),(0,K.jsxs)(`form`,{id:`auth-verify-email-form`,name:`auth-verify-email-form`,onSubmit:s(c),className:`my-4`,children:[(0,K.jsx)(Y,{control:o,name:`email`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-2`,children:[(0,K.jsx)(Z,{children:`Email`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{disabled:n,type:`email`,className:`dark:bg-black dark:border-black`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(F,{type:`submit`,variant:`submit`,disabled:n,className:`w-full my-2`,children:`Send Verification Email`})]})]})}function uc(){let{token:e}=le({strict:!1}),t=L(),{mutate:n,isPending:r}=sc(),i=(0,G.useCallback)(e=>{n(e,{onSuccess:()=>{U.success(`Success`,{description:`Email verified successfully`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),t({to:`/sign-in`})}})},[n,t]);return(0,G.useEffect)(()=>{e&&i(e)},[i,e]),(0,K.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,K.jsx)(`h1`,{className:`text-3xl font-light`,children:`Verify Email`}),r?(0,K.jsx)(`p`,{className:`text-sm pt-1`,children:`Verifying email...`}):(0,K.jsx)(lc,{})]})}function dc(){let{email:e}=le({strict:!1}),{mutate:t,isPending:n}=Js(),r=(0,G.useCallback)(n=>(n.preventDefault(),e&&t({email:e},{onSuccess:e=>{U.success(`Code Sent`,{description:`${e}`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}}),!1),[e,t]);return(0,K.jsxs)(`div`,{className:`text-foreground dark:text-white w-lg flex flex-col gap-4`,children:[(0,K.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Check your email!`]}),(0,K.jsxs)(`p`,{children:[`Your account has been created! You should receive an email with a link to `,(0,K.jsx)(`strong`,{children:`[Verify My Email]`}),`!`]}),(0,K.jsxs)(`p`,{children:[`From: `,(0,K.jsx)(`strong`,{children:`harper@notifications.harperfabric.com`})]}),(0,K.jsxs)(`p`,{children:[`To: `,(0,K.jsx)(`strong`,{children:e||`your email`})]}),(0,K.jsx)(`p`,{children:`Can you click it? Then we can carry on to more fun things!`}),(0,K.jsxs)(`div`,{className:`underline flex gap-4`,children:[(0,K.jsx)(V,{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,K.jsx)(V,{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 fc=I({getParentRoute:()=>bo,id:`_authLayout`,component:Co}),pc=I({getParentRoute:()=>fc,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:ec,beforeLoad:({context:e,location:t})=>{let n=e.authentication[m]?.user;if(n){let e=t?.search,r=Pn(n);throw ie({to:e?.redirect?.startsWith(`/`)?e.redirect:r})}}}),mc=I({getParentRoute:()=>bo,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:vs,beforeLoad:({context:e,location:t})=>{if(e.authentication.OverallAppSignIn?.user){let e=t?.search;throw ie({to:e?.redirect?.startsWith(`/`)?e.redirect:`/`})}}}),hc=I({getParentRoute:()=>fc,path:`sign-up`,head:()=>({meta:[{title:`Sign Up — Harper Fabric`}]}),component:ac}),gc=I({getParentRoute:()=>fc,path:`forgot-password`,head:()=>({meta:[{title:`Forgot Password — Harper Fabric`}]}),component:Rs}),_c=I({getParentRoute:()=>fc,path:`verify-email`,head:()=>({meta:[{title:`Verify Email — Harper Fabric`}]}),component:uc}),vc=I({getParentRoute:()=>fc,path:`verifying`,head:()=>({meta:[{title:`Check Your Email — Harper Fabric`}]}),component:dc}),yc=I({getParentRoute:()=>fc,path:`check-oauth`,head:()=>({meta:[{title:`Signing In — Harper Fabric`}]}),component:jo}),bc=I({getParentRoute:()=>fc,path:`reset-password`,head:()=>({meta:[{title:`Reset Password — Harper Fabric`}]}),component:Hs});fc.addChildren([pc,hc,yc,gc,_c,vc,bc]);var xc=[mc];function Sc({children:e}){return(0,K.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,K.jsxs)(`div`,{className:`flex items-center h-full space-x-2`,children:[(0,K.jsx)(Fo,{}),e]})})}function Cc({typeOfThingBeingDeleted:e,nameOfThingBeingDeleted:t,isModalOpen:n,hideDataLossWarning:r,setIsModalOpen:i,deletionConfirmed:a,deletionPending:o,trigger:s,presentParticiple:c=`Deleting`,transitiveVerb:l=`Delete`}){return(0,K.jsxs)(fn,{open:n,onOpenChange:i,children:[s&&(0,K.jsx)(dn,{asChild:!0,children:s}),(0,K.jsxs)(cn,{className:`sm:max-w-[750px]`,children:[(0,K.jsxs)(rn,{children:[(0,K.jsxs)(ln,{children:[`Are you sure you want to `,l.toLowerCase(),` this `,e,`?`]}),(0,K.jsx)(un,{children:`This action cannot be undone.`})]}),!r&&(0,K.jsxs)(`div`,{className:`p-3 my-5 text-white rounded-md bg-amber-600`,children:[(0,K.jsxs)(`p`,{className:`flex space-x-1 font-semibold align-baseline`,children:[(0,K.jsx)(mi,{className:`inline-block size-5`}),` `,(0,K.jsx)(`span`,{children:`Warning`})]}),(0,K.jsxs)(`p`,{className:`pt-2 text-base`,children:[`By `,c.toLowerCase(),` `,e,` `,(0,K.jsx)(`span`,{className:`font-semibold`,children:t}),` `,`you will lose the data stored in it permanently.`]})]}),(0,K.jsx)(on,{children:(0,K.jsxs)(`div`,{className:`flex justify-center space-x-5`,children:[(0,K.jsxs)(F,{type:`button`,onClick:()=>i(!1),children:[(0,K.jsx)(Ln,{}),` Cancel`]}),(0,K.jsxs)(F,{variant:`destructive`,onClick:a,disabled:o,children:[(0,K.jsx)(fi,{}),` `,l]})]})})]})]})}function wc({...e}){return(0,K.jsx)(it,{"data-slot":`context-menu`,...e})}function Tc({...e}){return(0,K.jsx)(Ct,{"data-slot":`context-menu-trigger`,...e})}function Ec({className:e,...t}){return(0,K.jsx)(St,{children:(0,K.jsx)(gt,{"data-slot":`context-menu-content`,className:P(`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 Dc({className:e,inset:t,variant:n=`default`,...r}){return(0,K.jsx)(nn,{"data-slot":`context-menu-item`,"data-inset":t,"data-variant":n,className:P(`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 Oc({className:e,inset:t,...n}){return(0,K.jsx)(Ye,{"data-slot":`context-menu-label`,"data-inset":t,className:P(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function kc({className:e,...t}){return(0,K.jsx)(xt,{"data-slot":`context-menu-separator`,className:P(`bg-border -mx-1 my-1 h-px`,e),...t})}function Ac({className:e,...t}){return(0,K.jsx)(`span`,{"data-slot":`context-menu-shortcut`,className:P(`text-muted-foreground ml-auto text-xs tracking-widest`,e),...t})}var jc={dropdown:{Item:Oi,Label:Ai,Separator:ji},context:{Item:Dc,Label:Oc,Separator:kc}};function Mc(e,t){let{Item:n,Label:r,Separator:i}=jc[t];return e.map(e=>{if(e.type===`separator`)return(0,K.jsx)(i,{},e.key);if(e.type===`label`)return(0,K.jsx)(r,{className:e.className,children:e.label},e.key);let t=(0,K.jsxs)(n,{className:e.className,onClick:e.onClick,disabled:e.disabled,variant:e.variant,children:[e.icon,e.label]});return e.to?(0,K.jsx)(V,{to:e.to,disabled:e.disabled,children:t},e.key):(0,K.jsx)(G.Fragment,{children:t},e.key)})}function Nc({items:e,children:t}){return e.length?(0,K.jsxs)(wc,{children:[(0,K.jsx)(Tc,{asChild:!0,children:t}),(0,K.jsx)(Ec,{children:Mc(e,`context`)})]}):(0,K.jsx)(K.Fragment,{children:t})}function Pc(e,t){let n=Ic(e),r=Ic(t);return!n||!r?!1:zc(r,n)>=0}function Fc(e,t){let n=Ic(e),r=Ic(t);return!n&&!r?0:n?r?zc(n,r):1:-1}function Ic(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=Lc(a[0]),s=Lc(a[1]??`0`),c=Lc(a[2]??`0`);return o==null||s==null||c==null?null:{major:o,minor:s,patch:c,pre:i?i.split(`.`).map(e=>Rc(e)?Number(e):e):[]}}function Lc(e){return e==null||e===``||!/^\d+$/.test(e)?null:Number(e)}function Rc(e){return/^\d+$/.test(e)}function zc(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 Bc=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 Vc(e){return Bc.has(e)}function Hc(e){let t=ol.get(e);return!!t?.aliasOf||!!t?.nonDelegable||!!t?.outOfGate||Vc(e)}var Uc=`5.1.0-alpha.1`,Wc=`5.2.0-alpha.1`,Gc=`Data`,Kc=`Schema`,qc=`Users & Roles`,Jc=`Components & Deployments`,Yc=`Clustering & Replication`,Xc=`Jobs`,Zc=`Logs & Analytics`,Qc=`System`,$c=`Managed Backups`,el=`Secrets & Environment`,tl=`Agent`,nl=[Gc,Kc,qc,Jc,Yc,Xc,Zc,Qc,$c,el,tl],rl=[{name:`search`,su:!1,category:Gc},{name:`search_by_conditions`,su:!1,category:Gc},{name:`search_by_hash`,su:!1,category:Gc},{name:`search_by_id`,su:!1,category:Gc,aliasOf:`search_by_hash`},{name:`search_by_value`,su:!1,category:Gc},{name:`sql`,su:!1,category:Gc,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:Gc},{name:`update`,su:!1,category:Gc},{name:`upsert`,su:!1,category:Gc},{name:`delete`,su:!1,category:Gc},{name:`delete_records_before`,su:!0,category:Gc},{name:`csv_data_load`,su:!1,category:Gc},{name:`csv_file_load`,su:!1,category:Gc},{name:`csv_url_load`,su:!1,category:Gc},{name:`import_from_s3`,su:!1,category:Gc},{name:`export_local`,su:!0,category:Gc},{name:`export_to_s3`,su:!0,category:Gc},{name:`describe_all`,su:!1,category:Kc},{name:`describe_database`,su:!1,category:Kc,aliasOf:`describe_schema`},{name:`describe_schema`,su:!1,category:Kc},{name:`describe_table`,su:!1,category:Kc},{name:`create_database`,su:!0,category:Kc},{name:`create_schema`,su:!0,category:Kc,aliasOf:`create_database`},{name:`drop_database`,su:!0,category:Kc},{name:`drop_schema`,su:!0,category:Kc,aliasOf:`drop_database`},{name:`create_table`,su:!0,category:Kc},{name:`drop_table`,su:!0,category:Kc},{name:`create_attribute`,su:!1,category:Kc},{name:`drop_attribute`,su:!0,category:Kc},{name:`cleanup_orphan_blobs`,su:!0,category:Kc},{name:`user_info`,su:!1,category:qc},{name:`list_users`,su:!0,category:qc},{name:`add_user`,su:!0,category:qc},{name:`alter_user`,su:!0,category:qc},{name:`drop_user`,su:!0,category:qc},{name:`list_roles`,su:!0,category:qc},{name:`add_role`,su:!0,category:qc},{name:`alter_role`,su:!0,category:qc},{name:`drop_role`,su:!0,category:qc},{name:`refresh_operation_token`,su:!1,category:qc},{name:`get_components`,su:!0,category:Jc},{name:`get_component_file`,su:!0,category:Jc},{name:`set_component_file`,su:!0,category:Jc},{name:`add_component`,su:!0,category:Jc},{name:`drop_component`,su:!0,category:Jc},{name:`deploy_component`,su:!0,category:Jc},{name:`package_component`,su:!0,category:Jc},{name:`install_node_modules`,su:!0,category:Jc},{name:`audit_node_modules`,su:!0,category:Jc},{name:`custom_functions_status`,su:!0,category:Jc},{name:`get_custom_functions`,su:!0,category:Jc},{name:`get_custom_function`,su:!0,category:Jc},{name:`set_custom_function`,su:!0,category:Jc},{name:`drop_custom_function`,su:!0,category:Jc},{name:`add_custom_function_project`,su:!0,category:Jc,aliasOf:`add_component`},{name:`deploy_custom_function_project`,su:!0,category:Jc,aliasOf:`deploy_component`},{name:`package_custom_function_project`,su:!0,category:Jc,aliasOf:`package_component`},{name:`drop_custom_function_project`,su:!0,category:Jc,aliasOf:`drop_component`},{name:`list_deployments`,su:!0,category:Jc,addedIn:Uc},{name:`get_deployment`,su:!0,category:Jc,addedIn:Uc},{name:`get_deployment_payload`,su:!0,category:Jc,addedIn:Uc,nonDelegable:!0},{name:`delete_deployment_payload`,su:!0,category:Jc,addedIn:Uc},{name:`add_node`,su:!0,category:Yc},{name:`update_node`,su:!0,category:Yc},{name:`set_node_replication`,su:!0,category:Yc},{name:`purge_stream`,su:!0,category:Yc},{name:`catchup`,su:!0,category:Yc},{name:`get_job`,su:!1,category:Xc},{name:`search_jobs_by_start_date`,su:!0,category:Xc},{name:`update_job`,su:!0,category:Xc},{name:`delete_job`,su:!0,category:Xc},{name:`read_log`,su:!0,category:Zc},{name:`read_audit_log`,su:!0,category:Zc},{name:`read_transaction_log`,su:!0,category:Zc},{name:`delete_files_before`,su:!0,category:Zc},{name:`delete_audit_logs_before`,su:!0,category:Zc},{name:`delete_transaction_logs_before`,su:!0,category:Zc},{name:`get_analytics`,su:!1,category:Zc},{name:`list_metrics`,su:!1,category:Zc},{name:`describe_metric`,su:!1,category:Zc},{name:`get_configuration`,su:!0,category:Qc},{name:`set_configuration`,su:!0,category:Qc},{name:`restart`,su:!0,category:Qc},{name:`restart_service`,su:!0,category:Qc},{name:`system_information`,su:!0,category:Qc},{name:`get_status`,su:!0,category:Qc},{name:`set_status`,su:!0,category:Qc},{name:`clear_status`,su:!0,category:Qc},{name:`registration_info`,su:!1,category:Qc},{name:`get_backup`,su:!0,category:Qc},{name:`create_backup`,su:!0,category:$c,addedIn:Wc,nonDelegable:!0},{name:`verify_backup`,su:!0,category:$c,addedIn:Wc,nonDelegable:!0},{name:`restore_backup`,su:!0,category:$c,addedIn:Wc,nonDelegable:!0},{name:`list_backups`,su:!0,category:$c,addedIn:Wc,nonDelegable:!0},{name:`delete_backup`,su:!0,category:$c,addedIn:Wc,nonDelegable:!0},{name:`purge_backups`,su:!0,category:$c,addedIn:Wc,nonDelegable:!0},{name:`set_secret`,su:!0,category:el,addedIn:Wc,nonDelegable:!0},{name:`grant_secret`,su:!0,category:el,addedIn:Wc,nonDelegable:!0},{name:`revoke_secret`,su:!0,category:el,addedIn:Wc,nonDelegable:!0},{name:`list_secrets`,su:!0,category:el,addedIn:Wc,nonDelegable:!0},{name:`delete_secret`,su:!0,category:el,addedIn:Wc,nonDelegable:!0},{name:`get_secrets_public_key`,su:!0,category:el,addedIn:Wc,nonDelegable:!0},{name:`set_env_value`,su:!0,category:el,addedIn:Wc},{name:`delete_env_value`,su:!0,category:el,addedIn:Wc},{name:`get_env_keys`,su:!0,category:el,addedIn:Wc},{name:`agent_prompt`,su:!0,category:tl,addedIn:Uc},{name:`get_agent_session`,su:!0,category:tl,addedIn:Uc},{name:`list_agent_sessions`,su:!0,category:tl,addedIn:Uc},{name:`cancel_agent_run`,su:!0,category:tl,addedIn:Uc},{name:`approve_agent_action`,su:!0,category:tl,addedIn:Uc},{name:`set_agent_config`,su:!0,category:tl,addedIn:Uc}],il=[`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`],al=[{name:`read_only`,description:`Read-only data access: searches, SQL, schema describes, and user/analytics reads.`,members:il},{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:[...il,`insert`,`update`,`upsert`,`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:Wc}],ol=new Map(rl.map(e=>[e.name,e])),sl=new Map(al.map(e=>[e.name,e]));function cl(e){return ol.get(e)}function ll(e){return ol.get(e)?.aliasOf??e}function ul(e){return sl.has(e)}function dl(e){return!!e&&Pc(`5.0.0-alpha.8`,e)}function fl(e){return rl.filter(t=>!t.nonDelegable&&!t.aliasOf&&(!t.addedIn||Pc(t.addedIn,e)))}function pl(e){return al.filter(t=>!t.addedIn||Pc(t.addedIn,e))}function ml(e){let t=new Set;for(let n of e){let e=sl.get(n);if(e){for(let n of e.members){let e=ol.get(n)?.aliasOf??n;Hc(e)||t.add(e)}continue}Hc(n)||t.add(n)}return[...t].sort()}function hl(e,t=40){return e.length>t?`${e.slice(0,t).join(`, `)}, +${e.length-t} more`:e.join(`, `)}var gl=[`super_user`,`structure_user`,`cluster_user`,`operations`],_l=new Set(gl);function vl(e,t,n){if((t===`operations`?n:_l.has(t))||!Object.hasOwn(e,t))return;let r=e[t];return typeof r==`object`&&r&&!Array.isArray(r)?r:void 0}function yl(e){return e?.super_user===!0||e?.cluster_user===!0}function bl(e){let t=e?.structure_user;return t===!0?!0:Array.isArray(t)&&t.length>0?t:!1}var xl=[`create_table`,`create_attribute`,`drop_table`,`drop_attribute`];function Sl(e){let t=e?.operations;return Array.isArray(t)&&t.every(e=>typeof e==`string`)?t:void 0}function Cl(e,t){let n=e?.operations;return e===void 0||n===void 0?`absent`:t?Sl(e)===void 0?n&&typeof n!=`string`&&!Array.isArray(n)?`breaks-auth`:`malformed`:`allowlist`:vl(e,`operations`,!1)===void 0?`inert`:`database`}function wl(e){let t=gl.filter(t=>t in e),n=Object.keys(e).filter(e=>!_l.has(e));return Object.fromEntries([...t,...n].map(t=>[t,e[t]]))}function Tl(e,t){let n={...e};return t===void 0?delete n.operations:n.operations=t,wl(n)}var El={read:[`search`,`search_by_conditions`,`search_by_hash`,`search_by_value`,`sql`],insert:[`insert`],update:[`update`],delete:[`delete`]},Dl=[`insert`],Ol=[`csv_data_load`,`get_job`],kl=[`csv_url_load`,`get_job`],Al={"json-records":Dl,"csv-data":Ol,"csv-url":kl},jl={sample:[Dl,Ol],file:[Dl,Ol],url:[kl]},Ml=Object.keys(jl),Nl=new WeakMap,Pl=new Map(al.map(e=>[e.name,e.members]));function Fl(e){let t=new Set;for(let n of e){let e=Pl.get(n);if(e)for(let n of e)t.add(n);else t.add(n)}return t}function Il(e,t){let n=Sl(e);if(!n)return!0;let r=Nl.get(n);return r||(r=Fl(n),Nl.set(n,r)),t.some(e=>r.has(ll(e)))}function Ll(e,t){return e?.super_user===!0||Il(e,t)}function Rl(e,t){return Ll(e,El[t]??[])}function zl(e,t){return t.every(t=>Il(e,[t]))}function Bl(e,t){return e?.super_user===!0||zl(e,Al[t])}function Vl(e,t){return e?.super_user===!0||jl[t].some(t=>zl(e,t))}function Hl(e){return Ml.some(t=>Vl(e,t))}function Ul(e,t,n,r){return Rl(e,r)&&Gl(e,t,n,r)}function Wl(e,t,n){return Hl(e)&&Gl(e,t,n,`insert`)}function Gl(e,t,n,r){return e?e.super_user===!0||e.structure_user===!0||vl(e,t,!1)?.tables?.[n]?.[r]===!0:!1}function Kl(e){let{user:t}=wn(),{organizationId:n}=B({strict:!1}),r=ql(t,e??n);return{update:Tn(t,`org:update`)||r.update,remove:Tn(t,`org:delete`)||r.remove}}function ql(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 Jl(e){let{user:t}=wn(),{organizationId:n}=B({strict:!1}),r=Yl(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 Yl(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 Xl(e,t){let{user:n}=wn(),{organizationId:r,clusterId:i}=B({strict:!1});return Zl(n,e??r,t??i)}function Zl(e,t,n){let r=Ql(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 Ql(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 $l(e,t){let{user:n}=wn(),{organizationId:r,clusterId:i}=B({strict:!1});return eu(n,e??r,t??i)}function eu(e,t,n){let r=tu(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 tu(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 nu(e){let{clusterId:t,instanceId:n}=B({strict:!1}),{user:r}=Dn(e??n??t),i=r?.role?.permission;return i?i.super_user===!0:!1}function ru(e){let{clusterId:t,instanceId:n}=B({strict:!1}),{user:r}=Dn(e??n??t),i=r?.role?.permission;return i?i.super_user===!0||i.structure_user===!0:!1}function iu(e,t,n,r){let{clusterId:i,instanceId:a}=B({strict:!1}),{user:o}=Dn(e??a??i);return Ul(o?.role?.permission,t,n,r)}function au(e,t,n){let{clusterId:r,instanceId:i}=B({strict:!1}),{user:a}=Dn(e??i??r);return Wl(a?.role?.permission,t,n)}function ou(e){let{clusterId:t,instanceId:n}=B({strict:!1}),{user:r}=Dn(e??n??t);return Hl(r?.role?.permission)}function su(e){let{clusterId:t,instanceId:n}=B({strict:!1}),{user:r}=Dn(e??n??t),i=r?.role?.permission;return(0,G.useMemo)(()=>({methods:Object.fromEntries(Ml.map(e=>[e,Vl(i,e)])),allowsSource:e=>Bl(i,e),allowsDestination:(e,t)=>Wl(i,e,t)}),[i])}function cu(e){return!!e?.plans?.[0]?.planId?.startsWith(`self-hosted`)}function lu({cluster:e,hasCardLink:t=!1}){let{view:n,update:r}=Xl(e.organizationId,e.id),i=`/${e.organizationId}/${e.id}`;if(n)return cu(e)?(0,K.jsx)(uu,{cluster:e,hasCardLink:t}):e.fqdn?e.resetPassword?r?(0,K.jsx)(V,{to:`${i}/finish-setup`,className:`text-sm text-nowrap`,"aria-label":`Set Password on ${e.name}`,title:`Set Password on ${e.name}`,children:(0,K.jsxs)(F,{variant:`positive`,className:`py-2 hover:border-b-2 animate-glow-pulse`,children:[`Finish Setup `,(0,K.jsx)(Rn,{className:`inline-block`})]})}):(0,K.jsx)(`span`,{className:`py-2 text-nowrap`,children:`Pending Owner Setup`}):(0,K.jsx)(uu,{cluster:e,hasCardLink:t}):t?(0,K.jsxs)(`span`,{className:`text-sm text-nowrap py-2 ml-auto`,children:[`Instances `,(0,K.jsx)(Rn,{className:`inline-block`})]}):(0,K.jsx)(V,{to:`${i}/instances`,className:`text-sm text-nowrap`,"aria-label":`View ${e.name}`,title:`View ${e.name}`,children:(0,K.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Instances `,(0,K.jsx)(Rn,{className:`inline-block`})]})})}function uu({cluster:e,hasCardLink:t}){return t?(0,K.jsxs)(`span`,{className:`text-sm text-nowrap py-2 ml-auto`,children:[`Open `,(0,K.jsx)(Rn,{className:`inline-block`})]}):(0,K.jsx)(V,{to:`/${e.organizationId}/${e.id}`,className:`text-sm text-nowrap`,"aria-label":`Open ${e.name}`,title:`Open ${e.name}`,children:(0,K.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Open `,(0,K.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,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(fn,{open:n,onOpenChange:r,children:(0,K.jsxs)(cn,{className:`sm:max-w-[560px]`,children:[(0,K.jsxs)(rn,{children:[(0,K.jsxs)(ln,{children:[`Stop cluster `,e,`?`]}),(0,K.jsx)(un,{children:`This stops every instance in the cluster. It will be offline and stop serving traffic until you start it again.`})]}),(0,K.jsx)(on,{children:(0,K.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,K.jsx)(F,{type:`button`,variant:`defaultOutline`,onClick:()=>r(!1),children:`Cancel`}),(0,K.jsx)(F,{type:`button`,variant:`destructive`,onClick:i,disabled:t,children:`Stop cluster`})]})})]})}),(0,K.jsx)(fn,{open:a,onOpenChange:o,children:(0,K.jsxs)(cn,{className:`sm:max-w-[560px]`,children:[(0,K.jsxs)(rn,{children:[(0,K.jsxs)(ln,{children:[`Restart cluster `,e]}),(0,K.jsx)(un,{children:`Choose how to restart the cluster's instances.`})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 py-2`,children:[(0,K.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,K.jsxs)(`div`,{className:`font-medium`,children:[`Rolling `,(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(recommended)`})]}),(0,K.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,K.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,K.jsx)(`div`,{className:`font-medium`,children:`Parallel`}),(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`All instances at once. Faster, but the whole cluster is briefly offline.`})]})]}),(0,K.jsx)(on,{children:(0,K.jsx)(F,{type:`button`,variant:`defaultOutline`,onClick:()=>o(!1),children:`Cancel`})})]})})]})}function fu(e,t){let n=[];if(e)for(let r of e)n.push(r[t]);return n}function pu({cluster:e,forceProgressBarVisible:t}){let[n,r]=(0,G.useState)(t||!1),{data:i}=H(cs(n&&e.id,2e3));(0,G.useEffect)(function(){(Qo(e.status)||$o(e.status))&&r(!0)},[n,e.status,i?.instances]);let a=(0,G.useMemo)(()=>{let e=fu(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||Zo(t)||(Qo(t)?(n+=1,r[t]=`${n} ${No(t)}`):$o(t)?(a+=1,o[t]=`${a} ${No(t)}`):Xo(t)?(l+=1,u[t]=`${l} ${No(t)}`):!i.planId||!e.includes(i.planId)?(a+=1,o.DRAINING_TRAFFIC=`${a} ${No(`Draining Traffic`)}`):Yo(t)&&(s+=1,c[t]=`${s} ${No(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,K.jsxs)(`div`,{className:`w-full text-center`,children:[(0,K.jsxs)(`div`,{className:`w-full h-2.5 rounded-full overflow-clip flex shadow`,children:[(0,K.jsx)(`div`,{style:{width:a.runningWidth},className:`grow bg-green/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,K.jsx)(`div`,{style:{width:a.failedWidth},className:`grow bg-red/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,K.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,K.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,K.jsx)(`div`,{className:`text-xs text-muted-foreground font-light mt-2`,children:a.text})]}):null}function mu({open:e,setOpen:t,action:n,targetName:r,scope:i,isPending:a,onConfirm:o}){let s=n===`start`?`Start`:`Restart`;return(0,K.jsx)(fn,{open:e,onOpenChange:t,children:(0,K.jsxs)(cn,{className:`sm:max-w-[560px]`,children:[(0,K.jsxs)(rn,{children:[(0,K.jsxs)(ln,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Or,{className:`size-5 text-yellow`}),s,` `,r,` in safe mode?`]}),(0,K.jsxs)(un,{children:[`Safe mode boots Harper`,` `,(0,K.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,K.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,K.jsx)(on,{children:(0,K.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,K.jsx)(F,{type:`button`,variant:`defaultOutline`,onClick:()=>t(!1),children:`Cancel`}),(0,K.jsxs)(F,{type:`button`,variant:`warning`,onClick:o,disabled:a,children:[(0,K.jsx)(Or,{}),` `,s,` in safe mode`]})]})})]})})}async function hu(e){let{data:t}=await N.delete(`/Cluster/${e}`,{timeout:0});return t}function gu(){return R({mutationFn:e=>hu(e)})}async function _u({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 N.post(`/Cluster/${e}/container/${t}`,i);return a}function vu(){return R({mutationFn:_u})}var yu={stop:`Stopping`,start:`Starting`,restart:`Restarting`};function bu(e){let{mutateAsync:t,isPending:n}=vu(),r=oe();return{run:(0,G.useCallback)(async(n,i)=>{let a=i?.label??yu[n],o=U.loading(a,{description:`${a} cluster ${e.name}. Status will update automatically.`,duration:3e4,action:{label:`Dismiss`,onClick:()=>U.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]}),U.dismiss(o),U.success(`Request accepted`,{description:`${e.name} is ${a.toLowerCase()}. The status will update automatically.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}catch{U.dismiss(o)}},[e.id,e.name,e.organizationId,t,r]),isPending:n}}async function xu(e){if(!navigator.clipboard)return U.error(`Clipboard access is not available in this environment.`),!1;try{return await navigator.clipboard.writeText(e),!0}catch{return U.error(`Failed to copy to clipboard.`),!1}}function Su(e){xu(e).then(e=>{e&&U.info(`Copied to clipboard!`,{icon:(0,K.jsx)(tr,{}),duration:1e3})})}function Cu(...e){return(0,G.useMemo)(()=>e.map(e=>()=>Su(e)),e)}function wu(){return Su}function Tu({cluster:e}){let t=se(),n=oe(),r=(0,G.useMemo)(()=>c(e),[e]),i=Ga({operationsUrl:r}),a=Dn(e.id),[,o]=xn(vn.SavedClusterState,null),{view:s,update:l,remove:f,create:p}=Xl(e.organizationId,e.id),{mutate:m,isPending:h}=gu(),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(!1),[S,C]=(0,G.useState)(!1),[w,T]=(0,G.useState)(null),{run:E,isPending:D}=bu(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,G.useMemo)(()=>!!(e.status&&Vo.includes(e.status)),[e.status]),N=cu(e),P=l&&!N,F=u.checkForFabricConnect(e.id),te=!F&&!!a.user,ne=(0,G.useMemo)(()=>!!(e.status&&Ho.includes(e.status)),[e.status]),I=(0,G.useMemo)(()=>!!(e.status&&Xo(e.status)),[e.status]),L=l&&!N&&!ne&&!$o(e.status)&&!Qo(e.status),re=(0,G.useCallback)(async()=>{_(!0);let t=await os(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]),ie=(0,G.useCallback)(()=>{o(e),t.navigate({to:`/${e.organizationId}/new-cluster`})},[e,t,o]),ae=(0,G.useCallback)(()=>y(!0),[]),R=(0,G.useCallback)(()=>{let r=e.organizationId;m(e.id,{onSuccess:async()=>{await n.invalidateQueries({queryKey:[r],refetchType:`active`}),await t.invalidate(),U.success(`Success`,{description:N?`Cluster successfully removed.`:`Cluster successfully terminated.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),y(!1)},onError:()=>{U.error(`Error`,{description:N?`Failed to remove cluster: ${e.name}`:`Failed to terminate cluster: ${e.name}.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),y(!1)}})},[t,e.organizationId,e.id,e.name,m,N,n]),z=!s||ne?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,ce=e.domains?.[0]?.domain||e.fqdn,[le,ue]=Cu(`${ce}`,`https://${ce}`),de=[{type:`label`,key:`label`,className:`text-gray-600 text-xs`,label:`Options`},{type:`separator`,key:`label-separator`},M&&l&&!a.isLoading&&(!te||F)&&{key:`sign-in`,to:`${e.id}/sign-in`,disabled:g,icon:(0,K.jsx)(Er,{className:`text-green`}),label:`Direct Sign In`},M&&s&&!!r&&!a.isLoading&&te&&{key:`direct-sign-out`,onClick:re,disabled:g,label:`Direct Sign Out`},M&&l&&{key:`edit`,to:`${e.id}/edit`,disabled:g,icon:(0,K.jsx)(Zr,{className:`text-purple-600`}),label:N?`Edit`:`Edit Scaling`},L&&{key:`edit-version`,to:`${e.id}/edit/version`,disabled:g,icon:(0,K.jsx)(yr,{className:`text-fuchsia-300`}),label:`Edit Version`},M&&l&&!1,M&&s&&{key:`instances`,to:`${e.id}/instances`,disabled:g,icon:(0,K.jsx)($r,{className:`text-orange-300`}),label:`Instances`},M&&s&&!!a.user&&{key:`deployments`,to:`${e.id}/config/deployments`,disabled:g,icon:(0,K.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,K.jsx)(Wr,{}),label:`Start`},P&&k&&{key:`container-start-safe`,disabled:D,onClick:()=>T(`start`),icon:(0,K.jsx)(Or,{}),label:`Start in safe mode`},P&&(O||A)&&{key:`container-restart`,disabled:D,onClick:()=>C(!0),icon:(0,K.jsx)(Yr,{}),label:`Restart`},P&&O&&{key:`container-restart-safe`,disabled:D,onClick:()=>T(`restart`),icon:(0,K.jsx)(Or,{}),label:`Restart in safe mode`},P&&(O||A)&&{key:`container-stop`,variant:`destructive`,disabled:D,onClick:()=>x(!0),icon:(0,K.jsx)(ai,{}),label:`Stop`},M&&s&&!!e.fqdn&&{type:`separator`,key:`copy-separator`},M&&s&&!!e.fqdn&&{key:`copy-host-name`,onClick:le,disabled:g,icon:(0,K.jsx)(nr,{}),label:`Copy Host Name`},M&&s&&!!e.fqdn&&{key:`copy-api-url`,onClick:ue,disabled:g,icon:(0,K.jsx)(nr,{}),label:`Copy API URL`},I&&p&&{key:`try-again`,onClick:ie,className:`focus:bg-green/70 focus:text-white`,label:`Try Again`},!ne&&f&&M&&{type:`separator`,key:`remove-separator`},!ne&&f&&{key:`remove`,onClick:ae,className:`focus:bg-red/70 focus:text-white`,icon:(0,K.jsx)(fi,{className:`text-red-300`}),label:N?`Remove`:`Terminate`}].filter($a);return(0,K.jsx)(Nc,{items:ne?[]:de,children:(0,K.jsxs)(On,{className:`relative h-full justify-between transition-[transform,box-shadow] duration-200 ${z?`hover:scale-[1.02] hover:shadow-lg hover:ring-2 hover:ring-primary/60 dark:hover:ring-violet-400/70`:`hover:shadow-lg`}`,children:[z&&(0,K.jsx)(V,{to:z,"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,K.jsxs)(kn,{children:[(0,K.jsxs)(jn,{className:`flex items-center justify-between`,children:[ce?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`truncate max-w-48`,children:ce}),(0,K.jsx)(`button`,{type:`button`,"aria-label":`Copy host name`,onClick:e=>{e.stopPropagation(),le()},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,K.jsx)(sr,{size:16})}),(0,K.jsx)(`span`,{className:`grow`})]}):(0,K.jsx)(`span`,{children:`Self-Hosted`}),!ne&&(0,K.jsxs)(Ti,{children:[(0,K.jsx)(Ei,{"aria-label":`Cluster options`,onClick:e=>e.stopPropagation(),className:`relative z-10 -m-2 p-2 rounded-md hover:bg-accent/60`,children:(0,K.jsx)(ur,{})}),(0,K.jsx)(Di,{children:Mc(de,`dropdown`)})]})]}),(0,K.jsx)(An,{children:(0,K.jsx)(`h2`,{children:e.name})})]}),(0,K.jsxs)(Mn,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(pu,{cluster:e}),M&&s&&(0,K.jsx)(lu,{cluster:e,hasCardLink:!!z}),ee&&e.status&&(0,K.jsxs)(Yi,{variant:k?`destructive`:`warning`,children:[j&&(0,K.jsx)(Ar,{className:`animate-spin`}),No(e.status)]}),I&&e.status&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Yi,{variant:qo(e.status),children:No(e.status)}),(0,K.jsx)(`span`,{className:`text-xs`,children:`Click "..." to choose how to proceed.`})]})]}),(0,K.jsx)(Cc,{typeOfThingBeingDeleted:`cluster`,transitiveVerb:N?`Remove`:`Terminate`,presentParticiple:N?`Removing`:`Terminating`,nameOfThingBeingDeleted:e.name,isModalOpen:v,hideDataLossWarning:N,setIsModalOpen:e=>y(e),deletionConfirmed:R,deletionPending:h}),(0,K.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,K.jsx)(mu,{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 Eu({children:e,className:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sc,{}),(0,K.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] relative ${t??``}`,children:e})]})}function Du({children:e}){let{organizationId:t,clusterId:n}=B({strict:!1}),{view:r,update:i}=Xl(t,n),{data:a}=H(cs(n,!1)),o=a?cu(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,K.jsx)(`div`,{className:`relative mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsxs)(`div`,{className:`md:grid gap-6 md:grid-cols-12`,children:[(0,K.jsx)(`aside`,{className:`md:col-span-3 lg:col-span-2 mb-4 md:mb-0`,children:(0,K.jsx)(Bi,{items:c,ariaLabel:`Cluster sections`})}),(0,K.jsx)(`section`,{className:`md:col-span-9 lg:col-span-10 min-w-0`,children:e})]})})}async function Ou(e){let{data:t}=await N.get(`/Plan/`,{params:{organizationId:e}});return t}function ku(e){return z({queryKey:[e,`instancePlan`],queryFn:()=>Ou(e),retry:!1})}var Au=[`stable`,`next`,`beta`,`alpha`];function ju(e){let t=Au.indexOf(e);return t===-1?Au.length:t}function Mu(e){let t=new Map;for(let n of e){let e=t.get(n.version);(!e||ju(n.name)<ju(e.name))&&t.set(n.version,n)}return[...t.values()]}async function Nu(e){let{data:t}=await N.get(`/HarperVersions/`,{params:{organizationId:e}}),n=t;return{...n,value:Mu(n.value)}}function Pu(e){return z({queryKey:[e,`HarperVersions`],queryFn:()=>Nu(e),staleTime:6e4,retry:!1})}async function Fu({organizationId:e,availableHosts:t}={}){let{data:n}=await N.get(`/Region/`,{params:{availableHosts:t,organizationId:e}});return n}function Iu({organizationId:e,availableHosts:t}={}){return z({queryKey:[e,`regionLocations`,t],queryFn:()=>Fu({organizationId:e,availableHosts:t}),retry:!1})}function Lu(e){return(t,n)=>t[e]===n[e]?0:t[e]>n[e]?1:-1}function Ru(e){let t=e.split(`.`).map(Number);return(t[0]<<24|t[1]<<16|t[2]<<8|t[3])>>>0}function zu(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 Bu(e,t){return e.instanceFqdn===t.instanceFqdn?e.operationsApiPort-t.operationsApiPort:zu(e.instanceFqdn)&&zu(t.instanceFqdn)?Ru(e.instanceFqdn)-Ru(t.instanceFqdn):e.instanceFqdn>t.instanceFqdn?1:-1}function Vu(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 Hu(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 Uu(e,t,n){let r=Vu(e,t),i={};for(let e in r)i[e]=Hu(r[e],n);return i}function Wu({width:e,className:t,animated:n,placeholder:r}){return(0,K.jsxs)(`div`,{className:_(`w-full bg-gray-200 rounded-full relative`,r?`h-6`:`h-2.5`),children:[r&&(0,K.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,K.jsx)(`div`,{className:_(`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 Gu({duration:e,message:t,lateMessage:n}){let r=(0,G.useRef)(0),i=(0,G.useRef)(0),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(`5%`),l=(0,G.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,G.useEffect)(()=>(r.current=requestAnimationFrame(l),()=>cancelAnimationFrame(r.current)),[l]),(0,K.jsxs)(K.Fragment,{children:[a?n:t,(0,K.jsx)(Wu,{width:s,animated:!1})]})}async function Ku(e){let{data:t}=await N.post(`/Cluster/`,e,{timeout:0});return t}function qu(){return R({mutationFn:e=>Ku(e)})}async function Ju(e){let{id:t,...n}=e,{data:r}=await N.put(`/Cluster/${t}`,n,{timeout:0});return r}function Yu(){return R({mutationFn:e=>Ju(e)})}function Xu(e){return!!e&&e!==`undefined`&&e!==`null`}async function Zu(e){if(!Xu(e))throw Error(`getOrganization called without a valid organization id (got: ${e})`);let{data:t}=await N.get(`/Organization/${e}`);return t}function Qu(e){return z({queryKey:[e],queryFn:()=>Zu(e),retry:!1,enabled:Xu(e),refetchInterval:is(1e4)})}var $u=`ENTERPRISE`;function ed(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 td(e,t,n=`-`){let r=t.split(n)[0];return e.findIndex(e=>e.startsWith(r))!==-1}function nd(e){return e.replace(/[^a-zA-Z0-9]/g,`-`).replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase().replace(/-+/g,`-`).replace(/^-+|-+$/g,``)}function rd(e){return e!==void 0&&e>0}function id(e,t,n){return t===void 0?Promise.resolve():e.invalidateQueries({predicate:e=>e.queryKey[0]===t||e.queryKey[1]===t,...n})}async function ad(e){await N.put(`/Payment/`,e)}function od(){return R({mutationFn:e=>ad(e)})}function sd(e){let{mutate:t}=od();return(0,G.useCallback)((n,r)=>{t({paymentMethodId:typeof n==`string`?n:n.id,organizationId:e},{onSuccess:()=>{U.success(`Success! Your payment method has been saved.`),r(!0)},onError:()=>{U.error(`Failed to process payment method details. Please try another payment method.`),r(!1)}})},[t,e])}var cd=(0,G.createContext)(null);function ld(){return(0,G.useContext)(cd)}var ud=t(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),dd=t(((e,t)=>{var n=ud();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}})),fd=e(t(((e,t)=>{t.exports=dd()()}))(),1);function pd(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 md(e){if(Array.isArray(e))return e}function hd(e,t,n){return(t=wd(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gd(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 _d(){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 vd(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 yd(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?vd(Object(n),!0).forEach(function(t){hd(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vd(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function bd(e,t){if(e==null)return{};var n,r,i=xd(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 xd(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 Sd(e,t){return md(e)||gd(e,t)||Ed(e,t)||_d()}function Cd(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 wd(e){var t=Cd(e,`string`);return typeof t==`symbol`?t:t+``}function Td(e){"@babel/helpers - typeof";return Td=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},Td(e)}function Ed(e,t){if(e){if(typeof e==`string`)return pd(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)?pd(e,t):void 0}}var Dd=function(e,t,n){var r=!!n,i=G.useRef(n);G.useEffect(function(){i.current=n},[n]),G.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])},Od=function(e){var t=G.useRef(e);return G.useEffect(function(){t.current=e},[e]),t.current},kd=function(e){return e!==null&&Td(e)===`object`},Ad=`[object Object]`,jd=function e(t,n){if(!kd(t)||!kd(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var i=Object.prototype.toString.call(t)===Ad;if(i!==(Object.prototype.toString.call(n)===Ad))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])})},Md=function(e,t,n){return kd(e)?Object.keys(e).reduce(function(r,i){var a=!kd(t)||!jd(e[i],t[i]);return n.includes(i)?(a&&console.warn(`Unsupported prop change: options.${i} is not a mutable property.`),r):a?yd(yd({},r||{}),{},hd({},i,e[i])):r},null):null},Nd=G.createContext(null);Nd.displayName=`ElementsContext`;var Pd=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};fd.default.any,fd.default.object;var Fd=function(e){return Pd(G.useContext(Nd),e)},Id=function(){return Fd(`calls useElements()`).elements};fd.default.func.isRequired;var Ld=G.createContext(null);Ld.displayName=`CheckoutContext`;var Rd=function(e){var t=G.useContext(Ld),n=G.useContext(Nd);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 Pd(n,e)},zd=[`mode`],Bd=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},Vd=function(e,t,n){var r=`${Bd(e)}Element`,i=t?function(e){Rd(`mounts <${r}>`);var t=e.id,n=e.className;return G.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=Rd(`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=Sd(G.useState(null),2),O=D[0],k=D[1],A=G.useRef(null),j=G.useRef(null);Dd(O,`blur`,s),Dd(O,`focus`,c),Dd(O,`escape`,d),Dd(O,`click`,f),Dd(O,`loaderror`,p),Dd(O,`loaderstart`,m),Dd(O,`networkschange`,h),Dd(O,`confirm`,g),Dd(O,`cancel`,_),Dd(O,`shippingaddresschange`,v),Dd(O,`shippingratechange`,y),Dd(O,`savedpaymentmethodremove`,b),Dd(O,`savedpaymentmethodupdate`,x),Dd(O,`availablepaymentmethodschange`,S),Dd(O,`change`,u);var ee;l&&(ee=e===`expressCheckout`?l:function(){l(O)}),Dd(O,`ready`,ee),G.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=bd(o,zd);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=Od(o);return G.useEffect(function(){if(A.current){var e=Md(o,M,[`paymentRequest`]);e&&`update`in A.current&&A.current.update(e)}},[o,M]),G.useLayoutEffect(function(){return function(){if(A.current&&typeof A.current.destroy==`function`)try{A.current.destroy(),A.current=null}catch{}}},[]),G.createElement(`div`,{id:n,className:i,ref:j})};return i.propTypes={id:fd.default.string,className:fd.default.string,onChange:fd.default.func,onBlur:fd.default.func,onFocus:fd.default.func,onReady:fd.default.func,onEscape:fd.default.func,onClick:fd.default.func,onLoadError:fd.default.func,onLoaderStart:fd.default.func,onNetworksChange:fd.default.func,onConfirm:fd.default.func,onCancel:fd.default.func,onShippingAddressChange:fd.default.func,onShippingRateChange:fd.default.func,onSavedPaymentMethodRemove:fd.default.func,onSavedPaymentMethodUpdate:fd.default.func,onAvailablePaymentMethodsChange:fd.default.func,options:fd.default.object},i.displayName=r,i.__elementType=e,i},Hd=typeof window>`u`,Ud=G.createContext(null);Ud.displayName=`EmbeddedCheckoutProviderContext`;var Wd=function(){return Rd(`calls useStripe()`).stripe};Vd(`auBankAccount`,Hd),Vd(`card`,Hd),Vd(`cardNumber`,Hd),Vd(`cardExpiry`,Hd),Vd(`cardCvc`,Hd),Vd(`currencySelector`,Hd),Vd(`iban`,Hd);var Gd=Vd(`payment`,Hd);Vd(`expressCheckout`,Hd),Vd(`paymentRequestButton`,Hd),Vd(`linkAuthentication`,Hd),Vd(`contactDetails`,Hd);var Kd=Vd(`address`,Hd);Vd(`shippingAddress`,Hd),Vd(`paymentMethodMessaging`,Hd),Vd(`taxId`,Hd),Vd(`issuingCardNumberDisplay`,Hd),Vd(`issuingCardCvcDisplay`,Hd),Vd(`issuingCardExpiryDisplay`,Hd),Vd(`issuingCardPinDisplay`,Hd),Vd(`issuingCardCopyButton`,Hd),Vd(`terms`,Hd);function qd({hasExistingBilling:e,onPaymentAdded:t,onSaveStateForBillingRedirect:n}){let{organizationId:r}=B({strict:!1}),i=Wd(),a=ld(),o=Id(),[s,c]=(0,G.useState)(!1),l=sd(r),u=(0,G.useCallback)(()=>{t(!1)},[t]),d=(0,G.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),U.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,K.jsxs)(`form`,{id:`billing-add-payment-method-form`,name:`billing-add-payment-method-form`,onSubmit:d,className:`max-w-xl`,children:[(0,K.jsx)(Gd,{}),(0,K.jsx)(Kd,{options:{mode:`billing`}}),(0,K.jsxs)(`div`,{className:`mt-4 flex gap-8 items-center`,children:[(0,K.jsxs)(F,{disabled:!i||!o||s,variant:`submit`,children:[(0,K.jsx)(Xr,{}),` Add Payment Method`]}),e&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`text-xs text-gray-600`,children:`Your existing payment method will be overwritten.`}),(0,K.jsx)(F,{variant:`defaultOutline`,type:`button`,onClick:u,children:`Cancel`})]})]})]})}var Jd=`dahlia`,Yd=`https://js.stripe.com`,Xd=`${Yd}/${Jd}/stripe.js`,Zd=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,Qd=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/,$d=`loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used`,ef=function(e){return Zd.test(e)||Qd.test(e)},tf=function(){for(var e=document.querySelectorAll(`script[src^="${Yd}"]`),t=0;t<e.length;t++){var n=e[t];if(ef(n.src))return n}return null},nf=function(e){var t=e&&!e.advancedFraudSignals?`?advancedFraudSignals=false`:``,n=document.createElement(`script`);n.src=`${Xd}${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},rf=null,af=null,of=null,sf=function(e){return function(t){e(Error(`Failed to load Stripe.js`,{cause:t}))}},cf=function(e,t){return function(){window.Stripe?e(window.Stripe):t(Error(`Stripe.js not available`))}},lf=function(e){return rf===null?(rf=new Promise(function(t,n){if(typeof window>`u`||typeof document>`u`){t(null);return}if(window.Stripe&&e&&console.warn($d),window.Stripe){t(window.Stripe);return}try{var r=tf();if(r&&e)console.warn($d);else if(!r)r=nf(e);else if(r&&of!==null&&af!==null){var i;r.removeEventListener(`load`,of),r.removeEventListener(`error`,af),(i=r.parentNode)==null||i.removeChild(r),r=nf(e)}of=cf(t,n),af=sf(n),r.addEventListener(`load`,of),r.addEventListener(`error`,af)}catch(e){n(e);return}}),rf.catch(function(e){return rf=null,Promise.reject(e)})):rf},uf,df=function(){return uf||(uf=lf(null).catch(function(e){return uf=null,Promise.reject(e)}),uf)};Promise.resolve().then(function(){return df()}).catch(function(e){console.warn(e)});async function ff(e){let{data:t}=await N.post(`/StripeAccount/`,e);return t}function pf(){return R({mutationFn:e=>ff(e)})}async function mf(e){let{data:t}=await N.post(`/Payment/`,{organizationId:e.organizationId});return t}function hf(){return R({mutationFn:e=>mf(e)})}function gf(e){let{enabled:t,existingStripeId:n,organizationId:r}=e,{mutate:i}=pf(),{mutate:a}=hf(),[o,s]=(0,G.useState)(void 0),c=(0,G.useCallback)(e=>{s(e.clientSecret)},[]);return(0,G.useEffect)(()=>{},[i,t,n,a,c,r]),o}function _f({children:e}){let{organizationId:t}=B({strict:!1}),{data:n}=H(Qu(t)),r=gf({organizationId:t,enabled:!!n,existingStripeId:n?.stripeId}),i=ka();return(0,G.useMemo)(()=>({clientSecret:r||``,appearance:{theme:i===`dark`?`night`:`stripe`}}),[r,i]),console.error(`No VITE_PUBLIC_STRIPE_KEY is configured for this environment.`),(0,K.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 vf({onPaymentAdded:e,onSaveStateForBillingRedirect:t}){let{organizationId:n}=B({strict:!1}),{data:r}=H(Qu(n)),i=r?.billing,a=i?.paymentMethod;return(0,K.jsxs)(_f,{children:[(0,K.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,K.jsx)(qd,{hasExistingBilling:!!i,onSaveStateForBillingRedirect:t,onPaymentAdded:e})]})}var yf=function(e){return e.PASS=`pass`,e.FAIL=`fail`,e.PENDING=`pending`,e.ERROR=`error`,e}({});function bf(e){switch(e){case yf.PASS:return`success`;case yf.FAIL:case yf.ERROR:return`destructive`;case yf.PENDING:default:return`default`}}function xf(e){switch(e){case yf.PASS:return`READY`;case yf.FAIL:case yf.ERROR:case yf.PENDING:default:return e.toUpperCase()}}function Sf(e,t){return`${String(e).padStart(2,`0`)}/${String(t%100).padStart(2,`0`)}`}function Cf(e){let{onSaveStateForBillingRedirect:t,onReplacingPaymentMethod:n}=e??{},{organizationId:r}=B({strict:!1}),{update:i}=Kl(r),{data:a,refetch:o}=H(Qu(r)),s=a?.billing?.paymentMethod,[c,l]=(0,G.useState)(!1),u=(0,G.useCallback)(()=>{l(!c),n?.(!c)},[n,c]),d=(0,G.useCallback)(e=>{l(!1),n?.(!1),e&&o()},[n,o]);return a?.type===`ENTERPRISE`?(0,K.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,K.jsx)(ys,{}),`, we would love to talk!`]}):s&&!c?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`mt-2`,children:[s.brand?.toUpperCase()??`Card`,` ending in `,s.last4??`••••`,s.expMonth&&s.expYear?(0,K.jsxs)(K.Fragment,{children:[`(exp `,Sf(s.expMonth,s.expYear),`)`]}):null,s.status?(0,K.jsxs)(K.Fragment,{children:[`—`,` `,(0,K.jsx)(Yi,{variant:bf(s.status),children:xf(s.status)})]}):null]}),i&&(0,K.jsx)(`div`,{className:`mt-2 mb-6`,children:(0,K.jsx)(F,{variant:`defaultOutline`,type:`button`,onClick:u,children:`Replace Payment Method`})})]}):i?(0,K.jsx)(vf,{onSaveStateForBillingRedirect:t,onPaymentAdded:d}):(0,K.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 wf({clusterId:e,isPending:t,onGoBackToDetails:n,onSaveStateForBillingRedirect:r,onSubmit:i,organizationId:a,selectedPlan:o}){let{data:s}=H(Qu(a)),c=s?.billing,l=s?.type===$u,u=l||c?.paymentMethod?.status===yf.PASS,[d,f]=(0,G.useState)(!1),p=rd(o?.planLimits?.expirationMonths)&&o.planLimits.expirationMonths<1e3&&o.planLimits.expirationMonths,m=(0,K.jsx)(K.Fragment,{children:(0,K.jsxs)(`div`,{className:`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end mt-3 max-w-xl`,children:[(0,K.jsxs)(F,{type:`button`,variant:`defaultOutline`,disabled:t,onClick:n,children:[(0,K.jsx)(Ln,{}),` Back to Details`]}),(0,K.jsxs)(F,{disabled:t||!u||d,type:`submit`,variant:`submit`,onClick:i,children:[e?`Edit Cluster`:`Create New Cluster`,` `,(0,K.jsx)(Rn,{})]})]})});if(l)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`ul`,{className:`list-disc ml-6 max-w-lg`,children:[(0,K.jsx)(`li`,{children:`Reminder: you will be billed at your contracted rate for any additional infrastructure.`}),(0,K.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,K.jsx)(ys,{overEmail:!0}),`, we are here to help.`]})]}),m]});let g=p&&`, or ${h(p,`month`,`months`)} elapse`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`ul`,{className:`list-disc ml-6 mb-6`,children:[(0,K.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,K.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,K.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,K.jsxs)(`li`,{children:[`When that block is used up`,g,`, you will be automatically renewed.`]}),(0,K.jsx)(`li`,{children:`While refunds are not available, we’d be happy to assist you with troubleshooting.`}),(0,K.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,K.jsx)(ys,{overEmail:!0}),`, we are here to help.`]})]}),(0,K.jsx)(`p`,{className:`text-muted-foreground text-sm mb-6`,children:`Payment method:`}),(0,K.jsx)(Cf,{onSaveStateForBillingRedirect:r,onReplacingPaymentMethod:f}),m]})}var Tf=/(^$|^(?: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,Ef=65535,Df=M().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.`),Of=b({clusterName:M().nonempty(`Please enter a cluster name.`).max(255,`Cluster name cannot be longer than 255 characters long.`),abbreviatedName:S([k(``),x(),Df]).optional(),fqdn:M().regex(Tf,`Please enter a valid host name without the port or any path.`).optional(),version:M().optional(),deploymentDescription:M().nonempty(`Please select a deployment tier.`),performanceDescription:M().nonempty(`Please select a performance tier.`),regionPlans:A(b({regionName:M().nonempty(`Please select a region.`),latencyDescription:M().nonempty(`Please select a latency tier.`)})).max(50,{error:`A maximum of 50 regions can be selected for each cluster. `}),instances:A(b({secure:O([`true`,`false`]),fqdn:M().nonempty(`Please enter the host name of your instance.`).regex(Tf,`Please enter a valid host name without the port or any path.`),port:T().min(0,`Positive thinking only, please.`).max(Ef,`That port number is too high.`).optional()})).max(100,{error:`A maximum of 100 instances can be added to each cluster.`}),skipToBilling:C().optional(),skipGtmWait:C().optional(),sourceClusterId:M().optional()});function kf({calculatedNames:e,disabled:t,form:n}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Y,{control:n.control,name:`abbreviatedName`,render:({field:n})=>(0,K.jsxs)(X,{className:`col-span-3`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Host Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{...n,type:`text`,maxLength:Df.maxLength,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:e.suggestedAbbreviatedName,disabled:t})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(X,{className:`col-span-3 `,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Full Host Name`}),(0,K.jsx)(J,{children:(0,K.jsx)(`span`,{children:e.fullHostName})}),(0,K.jsx)(Q,{})]})]})}function Af({className:e}={}){let t=(0,G.useMemo)(()=>_(`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,K.jsx)(`div`,{className:t})}function jf({...e}){return(0,K.jsx)(Xt,{"data-slot":`select`,...e})}function Mf({...e}){return(0,K.jsx)(et,{"data-slot":`select-group`,...e})}function Nf({...e}){return(0,K.jsx)(at,{"data-slot":`select-value`,...e})}function Pf({className:e,children:t,...n}){return(0,K.jsxs)(nt,{"data-slot":`select-trigger`,className:P(`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,K.jsx)(Qe,{asChild:!0,children:(0,K.jsx)(pn,{className:`size-4 text-foreground dark:text-white`})})]})}function Ff({className:e,children:t,position:n=`popper`,...r}){return(0,K.jsx)(ct,{children:(0,K.jsxs)(yt,{"data-slot":`select-content`,className:P(`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,K.jsx)(Rf,{}),(0,K.jsx)(ot,{className:P(`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,K.jsx)(zf,{})]})})}function If({className:e,...t}){return(0,K.jsx)(Ft,{"data-slot":`select-label`,className:P(`px-2 py-1.5 text-sm font-medium`,e),...t})}function Lf({className:e,children:t,...n}){return(0,K.jsxs)(ft,{"data-slot":`select-item`,className:P(`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,K.jsx)(qe,{children:t}),(0,K.jsx)(`span`,{className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,K.jsx)(Lt,{children:(0,K.jsx)(mn,{className:`size-4`})})})]})}function Rf({className:e,...t}){return(0,K.jsx)(mt,{"data-slot":`select-scroll-up-button`,className:P(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,K.jsx)(hn,{className:`size-4`})})}function zf({className:e,...t}){return(0,K.jsx)(ut,{"data-slot":`select-scroll-down-button`,className:P(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,K.jsx)(pn,{className:`size-4`})})}var Bf={Colocated:`Shared infrastructure for optimized value`,Dedicated:`Dedicated infrastructure for consistent performance`,"Self-Hosted":`Your own infrastructure`};function Vf({availableDeploymentTypes:e,disabled:t,form:n}){return(0,K.jsx)(Y,{control:n.control,name:`deploymentDescription`,render:({field:r})=>(0,K.jsxs)(X,{className:`col-span-3`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Harper Deployment`}),(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(Af,{}),children:(0,K.jsx)(J,{children:(0,K.jsxs)(jf,{...r,disabled:t,onValueChange:e=>{r.onChange(e),n.trigger()},children:[(0,K.jsx)(Pf,{className:`w-full h-auto`,children:(0,K.jsx)(Nf,{placeholder:`Choose Tier`})}),(0,K.jsx)(Ff,{children:(0,K.jsx)(Mf,{children:e.map(e=>(0,K.jsxs)(Lf,{value:e,children:[(0,K.jsx)(`dt`,{className:`text-left font-bold text-sm/6`,children:e}),Bf[e]&&(0,K.jsx)(`dd`,{className:`font-light`,children:Bf[e]})]},e))})})]})})}),(0,K.jsx)(Q,{})]})})}function Hf({disabled:e,form:t}){return(0,K.jsx)(Y,{control:t.control,name:`fqdn`,render:({field:t})=>(0,K.jsxs)(X,{className:`md:col-span-6 col-span-3`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Optional Cluster Load Balancer Host Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{...t,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:`example.your-company.com`,disabled:e})}),(0,K.jsx)(Q,{})]})})}function Uf({className:e,disabled:t,form:n}){return(0,K.jsx)(Y,{control:n.control,name:`clusterName`,render:({field:n})=>(0,K.jsxs)(X,{className:e,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Cluster Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{autoFocus:!0,type:`text`,maxLength:Of.shape.clusterName.maxLength,autoCapitalize:`words`,disabled:t,...n})}),(0,K.jsx)(Q,{})]})})}function Wf({availablePerformanceDescriptions:e,form:t,selectedDeployment:n}){return(0,K.jsx)(Y,{control:t.control,name:`performanceDescription`,render:({field:r})=>(0,K.jsxs)(X,{className:`col-span-3`,children:[(0,K.jsxs)(Z,{className:`pb-1`,children:[n.startsWith(`Self`)?`Support`:`Performance`,` & Usage`]}),(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(Af,{}),children:(0,K.jsx)(J,{children:(0,K.jsxs)(jf,{...r,onValueChange:e=>{r.onChange(e),t.trigger()},disabled:!e?.length,children:[(0,K.jsx)(Pf,{className:`w-full h-auto`,children:(0,K.jsx)(Nf,{placeholder:`Choose Tier`})}),(0,K.jsx)(Ff,{children:(0,K.jsx)(Mf,{children:e.map(e=>(0,K.jsxs)(Lf,{value:e.performanceTier,children:[(0,K.jsxs)(`dt`,{className:`text-left font-bold text-sm/6 flex items-center gap-2`,children:[e.name,e.isPremium&&(0,K.jsx)(Yi,{children:`Premium`})]}),e.description&&(0,K.jsx)(`dd`,{className:`text-left font-light`,children:e.description})]},e.name))})})]})})}),(0,K.jsx)(Q,{})]})})}function Gf({className:e,...t}){let{formDescriptionId:n}=zo();return(0,K.jsx)(`p`,{"data-slot":`form-description`,id:n,className:P(`text-muted-foreground text-sm`,e),...t})}function Kf({className:e,form:t}){return(0,K.jsx)(Y,{control:t.control,name:`skipGtmWait`,render:({field:t})=>(0,K.jsxs)(X,{className:e,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(J,{children:(0,K.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,K.jsx)(Z,{className:`cursor-pointer`,children:`Immediate upgrade and restart`})]}),(0,K.jsx)(Gf,{children:`Apply changes immediately without waiting for each instance to be taken out of the load balancer (faster, but potentially less safe).`})]})})}function qf({className:e,disabled:t,form:n,harperVersions:r}){return r?.value?.length?(0,K.jsx)(Y,{control:n.control,name:`version`,render:({field:i})=>(0,K.jsxs)(X,{className:e,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Harper Version`}),(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(Af,{}),children:(0,K.jsx)(J,{children:(0,K.jsxs)(jf,{...i,disabled:t,onValueChange:e=>{i.onChange(e),n.trigger()},children:[(0,K.jsx)(Pf,{className:`w-full h-auto`,children:(0,K.jsx)(Nf,{placeholder:`Choose Version`})}),(0,K.jsx)(Ff,{children:(0,K.jsx)(Mf,{children:r?.value.map(e=>(0,K.jsxs)(Lf,{value:e.version,children:[e.version,` `,(0,K.jsx)(`span`,{className:`font-light opacity-50`,children:e.name})]},e.version))})})]})})}),(0,K.jsx)(Q,{})]})}):null}var Jf=new RegExp(/^\d+/);function Yf(e,t){let n=parseInt(e.match(Jf)?.[0]||`0`,10),r=parseInt(t.match(Jf)?.[0]||`0`,10);return n===r?0:n>r?1:-1}var Xf=[`B`,`KB`,`MB`,`GB`,`TB`,`PB`,`EB`,`ZB`,`YB`],Zf=[`secs`,`mins`,`hrs`],Qf={bytes:1e3,secs:60};function $f(e,t,n){let r,i;switch(t){case`bytes`:r=Xf,i=Qf.bytes;break;case`secs`:r=Zf,i=Qf.secs;break;default:return e}let a=r.indexOf(n);return a===-1?e:e/i**a}function ep(e,t){let n,r;switch(e){case`bytes`:n=Xf,r=Qf.bytes;break;case`secs`:n=Zf,r=Qf.secs;break;default:return e}let i=0;for(;t>=r&&i<n.length-1;)t/=r,i++;return n[i]}function tp(e,t=1){let n=e*t,r=ep(`bytes`,n),i=$f(n,`bytes`,r);return`${new Intl.NumberFormat().format(Math.round(i))} ${r}`}function np(e){return new Intl.NumberFormat().format(e)}var rp=[`K`,`M`,`B`,`T`,`Qa`,`Qi`,`Sx`,`Sp`,`Oc`,`No`,`Dc`];function ip(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<rp.length-1);return`${np(Math.round(n))} ${rp[r]}`}function ap(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 op(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 sp({selectedPlan:e,selectedRegion:t,usageScale:n,isEnterprise:r,cloudProvider:i}){let[a,o]=(0,G.useState)(!1),s=(0,G.useCallback)(()=>{o(!a)},[a,o]),c=e?.planLimits,l=e?.resourcesPerInstance,u=i&&e?.cloudInstanceTypes?.[i],d=rd(c?.expirationMonths)&&c.expirationMonths<1e3&&c.expirationMonths,f=t?.purchasedBlockMultiplier??1,p=(0,G.useMemo)(()=>c?[rd(c.totalReadCount)&&{label:`Total Reads`,value:ip(c.totalReadCount*f)},rd(c.totalReadsBytes)&&{label:`Total Read Transfer`,value:`${tp(c.totalReadsBytes*f)}`},rd(c.readsPerMinuteCount)&&{label:`Read Rate`,value:`${ip(c.readsPerMinuteCount*60*f)}/hr`},rd(c.readsPerMinuteBytes)&&{label:`Read Bandwidth`,value:`${tp(c.readsPerMinuteBytes*60*f)}/hr`},rd(c.totalWriteCount)&&{label:`Total Writes`,value:ip(c.totalWriteCount)},rd(c.totalWritesBytes)&&{label:`Total Write Transfer`,value:`${tp(c.totalWritesBytes)}`},rd(c.writesPerMinuteCount)&&{label:`Write Rate`,value:`${ip(c.writesPerMinuteCount*60)}/hr`},rd(c.writesPerMinuteBytes)&&{label:`Write Bandwidth`,value:`${tp(c.writesPerMinuteBytes*60)}/hr`},rd(c.totalRealTimeMessageDeliveries)&&{label:`Total Real-Time Messages`,value:`${ip(c.totalRealTimeMessageDeliveries*f)} messages`},rd(c.totalRealTimeMessageDeliveryBytes)&&{label:`Total Real-Time Message Transfer`,value:`${tp(c.totalRealTimeMessageDeliveryBytes*f)}`},rd(c.realTimeMessageDeliveriesPerMinute)&&{label:`Real-Time Message Rate`,value:`${ip(c.realTimeMessageDeliveriesPerMinute*60*f)}/hr`},rd(c.realTimeMessageDeliveryBytesPerMinute)&&{label:`Real-Time Message Bandwidth`,value:`${tp(c.realTimeMessageDeliveryBytesPerMinute*60*f)}/hr`},rd(c.tlsHandshakes)&&{label:`TLS Handshakes`,value:`${ip(c.tlsHandshakes*60*f)}`},rd(c.applicationComputeHours)&&{label:`Application Compute Hours`,value:`${ip(c.applicationComputeHours*f)}`},!!l&&rd(l.storageGb)&&{label:`Storage`,value:`${tp(l.storageGb*1e9)}`},!!l&&rd(l.cpuCores)&&{label:`Maximum CPU Cores`,value:`${ip(l.cpuCores)}`},!!l&&rd(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($a):[],[d,t,e,f]);if(!c)return``;if(!rd(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`:``,_=rd(c.readsPerMinuteCount)?c.readsPerMinuteCount*f:0,v=rd(c.writesPerMinuteCount)?c.writesPerMinuteCount:0,y=c.totalReadCount*f,b=rd(c.totalWriteCount)?c.totalWriteCount:0,x=[_>0&&{icon:vr,label:`Read Rate`,value:`${ip(_)}/min`,fill:op(_,n.readRate)},y>0&&{icon:Bn,label:`Total Reads`,value:ip(y),fill:op(y,n.totalReads)},v>0&&{icon:vr,label:`Write Rate`,value:`${ip(v)}/min`,fill:op(v,n.writeRate)},b>0&&{icon:In,label:`Total Writes`,value:ip(b),fill:op(b,n.totalWrites)},!!d&&{icon:Gn,label:`License Term`,value:h(d,`month`,`months`)}].filter($a);return(0,K.jsxs)(X,{className:`basis-full`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-2`,children:[(0,K.jsx)(Z,{onClick:s,className:`cursor-pointer`,children:`Usage block included with this plan`}),(0,K.jsxs)(F,{type:`button`,variant:`link`,className:`text-foreground`,onClick:s,children:[`Learn More `,a?(0,K.jsx)(sn,{}):(0,K.jsx)(Rn,{})]})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-5`,children:x.map(e=>(0,K.jsx)(cp,{icon:e.icon,label:e.label,value:e.value,fill:e.fill},e.label))}),(0,K.jsx)(J,{children:(0,K.jsxs)(`dl`,{className:P(`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,K.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,K.jsxs)(`div`,{className:P(`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,K.jsx)(`dt`,{className:`text-sm/6 font-medium text-foreground`,children:e.label}),(0,K.jsx)(`dd`,{className:`mt-1 text-sm/6 text-muted-foreground sm:col-span-2 sm:mt-0`,children:e.value})]},e.label))]})}),(0,K.jsx)(Q,{})]})}function cp({icon:e,label:t,value:n,fill:r}){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-background/50 p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,K.jsx)(e,{className:`size-4 shrink-0`}),(0,K.jsx)(`span`,{className:`text-xs font-medium`,children:t})]}),(0,K.jsx)(`span`,{className:`text-lg font-bold text-foreground tabular-nums`,children:n}),r!==void 0&&(0,K.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-sky-500/15`,children:(0,K.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 lp({control:e,fieldArray:t,form:n,index:r,regionNameToLatencyToRegion:i,premiumOnlyRegions:a,usageScale:o,selectedPlan:s,isEnterprise:c,cloudProvider:l}){let u=(0,G.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,G.useMemo)(()=>Object.keys(i[f]||{}).sort(Yf).reverse(),[i,f]),h=s?.allowedRegionIds,g=(0,G.useCallback)(e=>!h?.length||Object.values(i[e]||{}).some(e=>h.includes(e.id)),[h,i]),_=(0,G.useCallback)(e=>{if(!h?.length)return!0;let t=i[f]?.[e]?.id;return!t||h.includes(t)},[h,i,f]);(0,G.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,G.useCallback)(()=>{t?.remove(r),n.trigger()},[t,n,r]);return(0,K.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,K.jsx)(Y,{control:e,name:`regionPlans.${r}.regionName`,render:({field:e})=>(0,K.jsxs)(X,{className:`flex-1`,children:[(0,K.jsxs)(Z,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(Ir,{className:`size-4 shrink-0`}),`Region `,t.fields.length>1?r+1:``]}),(0,K.jsx)(J,{children:(0,K.jsxs)(jf,{onValueChange:t=>{e.onChange(t),n.trigger()},...e,children:[(0,K.jsx)(Pf,{className:`w-full`,children:(0,K.jsx)(Nf,{placeholder:`Choose Region`})}),(0,K.jsx)(Ff,{children:(0,K.jsx)(Mf,{children:u.map(e=>(0,K.jsx)(Lf,{value:e,disabled:!g(e),children:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e,a.regionNames.has(e)&&(0,K.jsx)(Yi,{children:`Premium`})]})},e))})})]})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:e,name:`regionPlans.${r}.latencyDescription`,render:({field:e})=>(0,K.jsxs)(X,{className:`flex-1`,children:[(0,K.jsxs)(Z,{children:[`Estimated `,d?`P95`:`P90`,` Latency, Distribution`]}),(0,K.jsx)(J,{children:(0,K.jsxs)(jf,{onValueChange:t=>{e.onChange(t),n.trigger()},...e,disabled:!m?.length,children:[(0,K.jsx)(Pf,{className:`w-full`,children:(0,K.jsx)(Nf,{placeholder:`Choose Latency Tier`})}),(0,K.jsx)(Ff,{children:(0,K.jsx)(Mf,{children:m.map(e=>(0,K.jsx)(Lf,{value:e,disabled:!_(e),children:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e,(()=>{let t=i[f]?.[e]?.id;return t&&a.regionIds.has(t)&&(0,K.jsx)(Yi,{children:`Premium`})})()]})},e))})})]})}),(0,K.jsx)(Q,{})]})}),t?.fields?.length&&t?.fields?.length>1&&(0,K.jsx)(`div`,{className:`flex-none mt-6`,children:(0,K.jsxs)(F,{type:`button`,variant:`destructiveOutline`,size:`sm`,onClick:v,children:[(0,K.jsx)(fi,{}),` `,(0,K.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})}),(0,K.jsx)(sp,{selectedPlan:s,selectedRegion:i[f]?.[p],usageScale:o,isEnterprise:c,cloudProvider:l})]})}function up({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,G.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,G.useCallback)(()=>{d&&(u.append({regionName:d.region,latencyDescription:d.latencyDescription}),e.trigger())},[e,d,u]);return t?.length?(0,K.jsxs)(K.Fragment,{children:[u.fields.map((t,o)=>(0,K.jsx)(lp,{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,K.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,K.jsxs)(F,{type:`button`,variant:`positiveOutline`,onClick:f,children:[(0,K.jsx)(Gr,{}),`Add Additional Region Usage`]})})]}):(0,K.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,K.jsx)(yi,{className:`mt-0 m-0`,title:`No Regions Available`,showReturnToHome:!1,error:{message:(0,K.jsxs)(K.Fragment,{children:[`The deployment type you selected currently has no available regions. Please try a different deployment type, try again later, or `,(0,K.jsx)(ys,{}),`.`]})}})})}function dp({control:e,fieldArray:t,form:n,index:r}){let a=(0,G.useCallback)(()=>{t?.remove(r)},[t,r]);return(0,K.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,K.jsx)(Y,{control:e,name:`instances.${r}.secure`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsxs)(Z,{children:[`Instance `,t.fields.length>1?r+1:``]}),(0,K.jsx)(J,{children:(0,K.jsxs)(jf,{...e,onValueChange:t=>{e.onChange(t),n.trigger()},children:[(0,K.jsx)(Pf,{className:`w-full`,children:(0,K.jsx)(Nf,{placeholder:`https://`})}),(0,K.jsx)(Ff,{children:(0,K.jsxs)(Mf,{children:[(0,K.jsx)(Lf,{value:`true`,children:`https://`}),(0,K.jsx)(Lf,{value:`false`,children:`http://`})]})})]})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:e,name:`instances.${r}.fqdn`,render:({field:e})=>(0,K.jsxs)(X,{className:`flex-3`,children:[(0,K.jsx)(Z,{children:`Host Name`}),(0,K.jsx)(J,{children:(0,K.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,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:e,name:`instances.${r}.port`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Operations API Port`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{...e,type:`number`,min:0,max:Ef,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,K.jsx)(Q,{})]})}),t?.fields?.length&&t?.fields?.length>1&&(0,K.jsx)(`div`,{className:`flex-none mt-6`,children:(0,K.jsxs)(F,{type:`button`,variant:`destructiveOutline`,size:`sm`,onClick:a,children:[(0,K.jsx)(fi,{}),` `,(0,K.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})})]})}function fp({form:e}){let t=Wt({control:e.control,name:`instances`}),n=(0,G.useCallback)(()=>{t.append({secure:`true`,fqdn:``,port:i})},[t]);return(0,K.jsxs)(K.Fragment,{children:[t.fields.map((n,r)=>(0,K.jsx)(dp,{control:e.control,fieldArray:t,form:e,index:r},n.id)),(0,K.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,K.jsxs)(F,{type:`button`,variant:`positiveOutline`,onClick:n,children:[(0,K.jsx)(Gr,{}),`Add Instance`]})})]})}function pp(e,t){return!e.allowedRegionIds?.length||e.allowedRegionIds.includes(t)}function mp(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=>pp(t,e.id)),i=o.some(t=>pp(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 hp({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,G.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,G.useMemo)(()=>Object.keys(n).sort(),[n]),b=(0,G.useMemo)(()=>mp(Object.values(n[f]||{}),d),[n,d,f]),x=(0,G.useMemo)(()=>ap(Object.values(n).flatMap(e=>Object.values(e)),d),[n,d]);(0,G.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,K.jsx)(on,{className:`mt-3 mb-12`,children:(0,K.jsxs)(F,{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,K.jsx)(Rn,{})]})});return c===`version`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-3 items-start gap-6 text-foreground md:grid-cols-6`,children:[(0,K.jsx)(Uf,{className:i?.value?.length?`col-span-3`:`md:col-span-6 col-span-3`,disabled:!0,form:r}),(0,K.jsx)(qf,{className:`col-span-3`,form:r,harperVersions:i}),(0,K.jsx)(Kf,{className:`col-span-3 md:col-span-6`,form:r}),l&&(0,K.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,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-3 items-start gap-6 text-foreground md:grid-cols-6`,children:[(0,K.jsx)(Uf,{className:i?.value?.length?`col-span-3`:`md:col-span-6 col-span-3`,disabled:!!t,form:r}),(0,K.jsx)(qf,{className:`col-span-3`,disabled:!!t,form:r,harperVersions:i}),S?(0,K.jsx)(Hf,{form:r,disabled:!!t}):(0,K.jsx)(kf,{form:r,calculatedNames:e,disabled:!!t}),(0,K.jsx)(Vf,{form:r,availableDeploymentTypes:y}),(0,K.jsx)(Wf,{availablePerformanceDescriptions:v,form:r,selectedDeployment:f}),S?(0,K.jsx)(fp,{form:r}):(0,K.jsx)(up,{form:r,regionLocations:u,regionNameToLatencyToRegion:d,premiumOnlyRegions:b,usageScale:x,selectedPlan:m,totalPrice:h,isEnterprise:a,cloudProvider:o}),t&&!S&&(0,K.jsx)(Kf,{className:`col-span-3 md:col-span-6`,form:r})]}),C]})}function gp(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 _p(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 vp(e,t,n){if(t&&n){let r=e.getValues();if(!r.deploymentDescription||!r.performanceDescription||!r.regionPlans.length){let i=_p(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 yp({price:e}){let t=new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).formatToParts(e||0);return(0,K.jsx)(`span`,{className:`text-4xl`,children:t.map((e,t)=>(0,K.jsx)(bp,{type:e.type,value:e.value},t))})}function bp({type:e,value:t}){switch(e){case`currency`:case`decimal`:case`fraction`:return(0,K.jsx)(`sup`,{className:`font-light text-xl`,children:t});default:return t}}function xp({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=L(),v=se(),y=s?.type===$u,b=s?.channel===`Akamai`?`linode`:void 0,x=oe(),{mutate:S,isPending:C}=qu(),{mutate:w,isPending:T}=Yu(),[E,D]=(0,G.useState)(m),O=(0,G.useMemo)(()=>Uu(d?.sort(Lu(`latencyDescription`))||[],`region`,`latencyDescription`),[d]),k=(0,G.useMemo)(()=>Uu(f?.sort(Lu(`latencyDescription`))||[],`region`,`latencyDescription`),[f]),A=(0,G.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=gp(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!`}):td(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(Of.superRefine(A)),defaultValues:n}),[ee,M]=(0,G.useState)(!0);(0,G.useEffect)(()=>{ee&&n&&(p(null),M(!1))},[n,ee,p]);let N=j.watch(`clusterName`),P=j.watch(`abbreviatedName`),F=j.watch(`deploymentDescription`),te=j.watch(`performanceDescription`),ne=j.watch(`regionPlans`),I=j.watch(`instances`),re=F===`Dedicated`?k:O,ie=F===`Dedicated`?f:d;(0,G.useEffect)(function(){let e=j.getValues();F&&(F===`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||vp(j,u,ie)))},[j,u,ie,F]);let ae=(0,G.useMemo)(()=>{let e=ed(nd(N),Df.maxLength);return{suggestedAbbreviatedName:e,fullHostName:`${P||e}.${s.subdomain||`your-org`}.harperfabric.com`}},[N,P,s]),R=(0,G.useMemo)(()=>r?.[F]?.[te],[r,F,te]);(0,G.useEffect)(function(){let e=R?.allowedRegionIds;if(e?.length&&ne?.length===1){let t=ne[0],n=re?.[t.regionName]?.[t.latencyDescription];if(!e.includes(n?.id)){let t=ie?.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())}}},[R,ne,j,re,ie]),(0,G.useEffect)(function(){if(F!==`Self-Hosted`&&Object.keys(re).length&&ne.length)for(let e=0;e<ne.length;e++){let t=ne[e];re[t.regionName]||j.setValue(`regionPlans.${e}.regionName`,``)}},[j,re,F,ne]);let z=R?.priceUsd?F===`Self-Hosted`?I.length*R.priceUsd:ne.reduce((e,t)=>{let n=re?.[t.regionName]?.[t.latencyDescription];return e+(n?R.priceUsd*n.instanceCount/2:0)},0):0,ce=R?.planLimits?.expirationMonths,le=rd(ce)&&ce<1e3?ce:void 0,ue=le?z/le:z,de=(0,G.useCallback)(({creating:e,deploymentDescription:t})=>U.message(e?`Creating Cluster`:`Updating Cluster`,{description:(0,K.jsx)(Gu,{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,G.useCallback)(async({clusterId:e,sourceClusterId:t,creating:n,toastId:r,isSelfManaged:i,skipGtmWait:a})=>{if(t){let e=(await Zu(c)).clusters?.find(e=>e.id===t);Xo(e?.status)&&await hu(t)}x.invalidateQueries({queryKey:[c],refetchType:`active`}),n||id(x,e,{refetchType:`active`}),v.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(),U.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,v,g,c,j]),pe=(0,G.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=re[t.regionName][t.latencyDescription];n.push({autoRenew:!0,planId:i.id,regionId:e.id})}p(null);let s=de({creating:!t,deploymentDescription:e.deploymentDescription}),l=()=>U.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||ae.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})},[ae.suggestedAbbreviatedName,t,r,j,fe,de,c,re,p,w,S]),me=(0,G.useCallback)(()=>{if(o!==`version`&&z>0){D(!0);return}return pe()},[o,pe,z]),he=(0,G.useCallback)(e=>{p(e?{clusterId:t,...j.getValues(),skipToBilling:!0}:null)},[t,j,p]),ge=(0,G.useCallback)(()=>{D(!1)},[]),_e=!y&&`mr-37.5`;return(0,K.jsxs)(K.Fragment,{children:[!y&&o!==`version`&&(0,K.jsxs)(`div`,{className:`absolute top-3 right-4 md:right-12 flex flex-col items-end text-right`,children:[(0,K.jsx)(`dt`,{className:`font-light`,children:le?`Monthly Price`:`Total Price`}),(0,K.jsx)(`dd`,{className:`font-bold`,children:z>0?(0,K.jsxs)(`span`,{className:`inline-flex items-baseline`,children:[(0,K.jsx)(yp,{price:ue}),!!le&&(0,K.jsxs)(`span`,{className:`font-light text-base text-muted-foreground`,children:[`/mo`,le>1&&(0,K.jsx)(`sup`,{children:`*`})]})]}):(0,K.jsx)(`span`,{className:`text-4xl text-green`,children:`Free`})})]}),(0,K.jsx)(Io,{...j,children:E?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h1`,{className:_(`text-lg leading-none text-foreground font-semibold mb-4`,_e),children:`Cluster Billing`}),(0,K.jsx)(`p`,{className:_(`text-muted-foreground text-sm mb-2`,_e),children:`Please confirm the following billing details:`}),(0,K.jsx)(wf,{clusterId:t,isPending:C||T,onGoBackToDetails:ge,onSaveStateForBillingRedirect:he,onSubmit:pe,organizationId:c,selectedPlan:R})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h1`,{className:_(`text-lg leading-none text-foreground font-semibold mb-4`,_e),children:`Cluster Configuration`}),(0,K.jsxs)(`div`,{className:_(`mb-6 flex flex-col items-start gap-2`,_e),children:[(0,K.jsx)(`p`,{className:`sr-only`,children:`Configure your Harper cluster and define deployment plans.`}),!y&&o!==`version`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Yi,{variant:`warning`,children:`Beta pricing subject to change.`}),!!le&&le>1&&z>0&&(0,K.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(z),` `,`every`,` `,h(le,`month`,`months`),`, or sooner if you reach a usage limit — then a new license is issued.`]})]})]}),(0,K.jsx)(`form`,{id:`cluster-upsert-form`,name:`cluster-upsert-form`,onSubmit:j.handleSubmit(me),children:(0,K.jsx)(hp,{calculatedNames:ae,clusterId:t,deploymentToPerformanceToPlan:r,form:j,isPending:C||T,harperVersions:a,mode:o,partialUpgrade:l,regionLocations:ie,regionNameToLatencyToRegion:re,selectedDeployment:F,selectedPerformance:te,selectedPlan:R,totalPrice:z,isEnterprise:y,cloudProvider:b})})]})})]})}function Sp(e){return e?.clusterName!==void 0}function Cp(e){let t=e.filter(e=>!!e&&!(e.status!=null&&Ho.includes(e.status))).map(e=>e.version).filter(e=>!!e);if(t.length<2)return null;let n=t.reduce((e,t)=>Fc(t,e)>0?t:e),r=t.filter(e=>e!==n).length;return r>0?{latest:n,behindCount:r,total:t.length}:null}function wp({isEdit:e,className:t,children:n}){return e?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sc,{}),(0,K.jsx)(Du,{children:(0,K.jsx)(`div`,{className:t,children:n})})]}):(0,K.jsx)(Eu,{className:t,children:n})}function Tp(){let{organizationId:e,clusterId:t,mode:n}=B({strict:!1}),{create:r,update:i}=Xl(e),{organization:a,cluster:o}=pe({strict:!1}),[s,c]=xn(vn.SavedClusterState,null),{data:l}=H(ku(e)),{data:u}=H(Iu({availableHosts:!0,organizationId:e})),{data:d}=H(Iu({organizationId:e})),{data:f}=H(Pu(e)),p=(0,G.useMemo)(()=>{if(o){let e=o.instances?.map(e=>e.version).filter($a);if(f&&e){let t=[...e].sort(Fc).pop(),n=new Set(e);return{...f,value:[!!t&&{name:`current`,version:t},...(f?.value||[]).filter(e=>!n.has(e.version)&&(!t||Pc(t,e.version)))].filter($a)}}}return f},[f,o]),m=(0,G.useMemo)(()=>Cp(o?.instances??[]),[o]),h=(0,G.useMemo)(()=>{for(let e of a?.clusters??[])if(e.id!==o?.id&&l&&!Zo(e.status)&&!Xo(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,G.useMemo)(()=>Uu(l?.sort(Lu(`priceUsd`))||[],`deploymentDescription`,`performanceDescription`),[l]),_=(0,G.useMemo)(()=>{if(!l||!p||!u||!d||t&&!o)return null;let e=o;if(s){if(Sp(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=_p(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&&!Ho.includes(e.status)).sort(Bu);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,K.jsx)(wp,{isEdit:!!t,children:(0,K.jsx)(Gi,{centered:!0,text:`Loading...`})}):(o?.id?!i:!r)?(0,K.jsx)(wp,{isEdit:!!t,children:(0,K.jsx)(yi,{title:`Not Allowed`,error:{message:(0,K.jsxs)(K.Fragment,{children:[`You do not have permission to `,o?.id?`update`:`create`,` clusters in this org.`]})}})}):l.length===0?(0,K.jsx)(wp,{isEdit:!!t,children:(0,K.jsx)(yi,{title:`Cluster ${t?`Modification`:`Creation`} Not Currently Allowed`,error:{message:(0,K.jsxs)(K.Fragment,{children:[`There are no available deployment types right now! Please try again later, or `,(0,K.jsx)(ys,{}),`.`]})}})}):(0,K.jsx)(wp,{isEdit:!!t,className:`max-w-4xl mx-auto`,children:(0,K.jsx)(xp,{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:Sp(s)&&s.skipToBilling===!0})})}function Ep({children:e}){let{organizationId:t}=B({strict:!1}),{view:n}=Jl(t),{update:r}=Kl(t),i=`/${t}`,a=[{to:i,label:`Clusters`,icon:$r,exact:!0},n&&{to:`${i}/users`,label:`Users`,icon:_i},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,K.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsxs)(`div`,{className:`md:grid gap-6 md:grid-cols-12`,children:[(0,K.jsx)(`aside`,{className:`md:col-span-3 lg:col-span-2 mb-4 md:mb-0`,children:(0,K.jsx)(Bi,{items:a,ariaLabel:`Organization sections`})}),(0,K.jsx)(`section`,{className:`md:col-span-9 lg:col-span-10 min-w-0`,children:e})]})})}var Dp={FAILED:0,UPDATING:1,PROVISIONING:2,RUNNING:3,TERMINATED:4},Op=Dp.RUNNING;function kp(e,t){return e.status===t.status?e.name.localeCompare(t.name):(e.status?Dp[e.status]??Op:Op)-(t.status?Dp[t.status]??Op:Op)}function Ap(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 jp(){let{organizationId:e}=B({strict:!1}),{create:t}=Xl(e),{data:n,isSuccess:r}=de(Qu(e)),[i]=xn(vn.SavedClusterState,null),[a,o]=(0,G.useState)(``),s=(0,G.useCallback)(()=>o(``),[]),c=(0,G.useCallback)(e=>{o(e.currentTarget.value?.toLowerCase()||``)},[]),l=(0,G.useMemo)(()=>n?.clusters?.slice().filter(e=>!Zo(e.status)).sort(kp)||[],[n?.clusters]),u=(0,G.useMemo)(()=>l.filter(Ap([`id`,`name`],a))||[],[a,l]);return n&&l.length===0&&t?(0,K.jsx)(Tp,{}):i?(0,K.jsx)(re,{to:`/${e}/new-cluster`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sc,{children:r&&t&&(0,K.jsx)(`div`,{className:`flex w-full justify-end`,children:(0,K.jsx)(V,{to:`new-cluster`,children:(0,K.jsxs)(F,{variant:`positive`,accessKey:`n`,children:[(0,K.jsx)(Gr,{}),` `,(0,K.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,K.jsx)(`u`,{children:`N`}),`ew `,(0,K.jsx)(`span`,{className:`hidden md:inline-block`,children:`Cluster`})]})]})})})}),(0,K.jsxs)(Ep,{children:[(0,K.jsxs)(`div`,{className:`relative mb-6 w-full`,children:[(0,K.jsx)(Qr,{className:`pointer-events-none absolute left-0 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,K.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,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-9 mb-4`,children:[u.map(e=>(0,K.jsx)(`div`,{className:`col-span-1 md:col-span-3 xl:col-span-3 2xl:col-span-2`,children:(0,K.jsx)(Tu,{cluster:e})},e.id)),!u.length&&(0,K.jsxs)(`div`,{className:`col-span-1 md:col-span-9 text-center`,children:[(0,K.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,K.jsx)(F,{type:`button`,variant:`outline`,onClick:s,children:`Clear Filters`})]})]})]})]})}function Mp(){return`/#`+lo()}function Np(){let{organizationId:e}=B({strict:!1}),t=L(),n=new URLSearchParams(window.location.search).get(`setup_intent_client_secret`),{setup_intent_client_secret:r}=le({strict:!1}),[i]=xn(vn.SavedClusterState,null),a=n||r,o=Wd(),s=sd(e),c=(0,G.useCallback)(()=>{let e=i?i.clusterId?`../../${i.clusterId}/edit`:`../../new-cluster`:`../`;window.history.replaceState(null,``,Mp()),t({search:void 0,to:e})},[t,i]);return(0,G.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?(U.error(`Failed to process payment method details. Please try another payment method.`),c()):s(e.payment_method,c);break;case`processing`:U.warning(`Processing payment method. Please check back later.`),c();break;case`requires_payment_method`:U.error(`Failed to process payment method details. Please try another payment method.`),c();break;default:U.error(`Failed to process payment method details. Please try another payment method.`),c()}}catch(e){console.error(e),U.error(`Failed to process payment method details. Please try another payment method.`),c()}})()},[a,c,e,s,o]),(0,K.jsx)(Gi,{centered:!0})}function Pp(){return(0,K.jsx)(_f,{children:(0,K.jsx)(Np,{})})}function Fp(){let{organizationId:e}=B({strict:!1}),{update:t}=Kl(e);return t?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sc,{}),(0,K.jsx)(Ep,{children:(0,K.jsx)(Le,{})})]}):(0,K.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 Ip=500,Lp=16,Rp=16;function zp({className:e,containerClassName:t,containerRef:n,...r}){return(0,K.jsx)(`div`,{ref:n,"data-slot":`table-container`,className:P(`relative w-full overflow-x-auto`,t),children:(0,K.jsx)(`table`,{"data-slot":`table`,className:P(`w-full caption-bottom text-sm`,e),...r})})}function Bp({className:e,...t}){return(0,K.jsx)(`thead`,{"data-slot":`table-header`,className:P(`[&_tr]:border-b`,e),...t})}function Vp({className:e,...t}){return(0,K.jsx)(`tbody`,{"data-slot":`table-body`,className:P(`[&_tr:last-child]:border-0`,e),...t})}function Hp({className:e,...t}){return(0,K.jsx)(`tr`,{"data-slot":`table-row`,className:P(`border-b border-grey-700 transition-colors`,e),...t})}function Up({className:e,...t}){return(0,K.jsx)(`th`,{"data-slot":`table-head`,className:P(`h-10 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function Wp({header:e,onColumnClick:t,className:n,...r}){let i=(0,G.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:De(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,G.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+Rp)}let d=Math.min(Math.max(Math.ceil(o)+Lp,u),Ip);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,K.jsxs)(Up,{...r,"data-col-id":e.column.id,style:{width:`${l}px`,maxWidth:`${l}px`},className:P(`relative`,o&&`select-none`,a?`px-0`:`px-2`,n),children:[(0,K.jsx)(`div`,{className:P(`flex items-center min-w-0 overflow-hidden`,o&&`pr-4`),children:a?(0,K.jsxs)(F,{type:`button`,variant:`ghost`,className:P(`rounded-none min-w-0`,!e.column.getIsSorted()||e.column.getIsSorted()===`asc`?`cursor-n-resize`:`cursor-s-resize`),onClick:i,children:[(0,K.jsx)(`span`,{className:`truncate`,children:s}),e.column.getIsSorted()===`asc`?(0,K.jsx)(an,{className:`shrink-0`}):e.column.getIsSorted()===`desc`?(0,K.jsx)(sn,{className:`shrink-0`}):(0,K.jsx)(zn,{className:`shrink-0 text-gray-600`})]}):(0,K.jsx)(`span`,{className:`truncate`,children:s})}),o&&(0,K.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,K.jsx)(xr,{className:`size-3.5`})})]})}function Gp({className:e,...t}){return(0,K.jsx)(`td`,{"data-slot":`table-cell`,className:P(`align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}var Kp=xe({columnSizingFeature:be,columnResizingFeature:Ee,columnVisibilityFeature:Ne,columnFilteringFeature:Fe,rowSelectionFeature:ke,rowSortingFeature:ve,sortedRowModel:Te(),sortFns:Ae});function qp(){return Se()}function Jp({columns:e,data:t,isFetching:n,onRowClick:r,onColumnClick:i,sortingState:a,children:o}){let s=Me({features:Kp,data:t,columns:e,initialState:{sorting:a??[]}});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-end space-x-2 pb-4`,children:[(0,K.jsx)(`div`,{className:`grow lg:hidden`}),o,(0,K.jsx)(`div`,{className:`grow hidden lg:visible`})]}),(0,K.jsxs)(zp,{containerClassName:`rounded-md bg-card dark:bg-black-dark`,children:[(0,K.jsx)(Bp,{children:s.getHeaderGroups().map(e=>(0,K.jsx)(Hp,{className:`border-none`,children:e.headers.map(e=>(0,K.jsx)(Wp,{header:e,onColumnClick:i},e.id))},e.id))}),(0,K.jsx)(Vp,{className:`bg-background dark:bg-black border border-border dark:border-grey-700`,children:s.getRowModel().rows?.length?s.getRowModel().rows.map(e=>(0,K.jsx)(Hp,{"data-state":e.getIsSelected()&&`selected`,onClick:()=>r?.(e),className:P(`hover:bg-muted/10 data-[state=selected]:bg-muted`,r&&`cursor-pointer`),children:e.getVisibleCells().map(e=>(0,K.jsx)(Gp,{className:`py-2 px-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,style:{width:`${e.column.getSize()}px`},children:De(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,K.jsx)(Hp,{children:(0,K.jsx)(Gp,{colSpan:e.length,className:`h-24 text-center`,children:n?(0,K.jsx)(`div`,{children:(0,K.jsx)(Gi,{className:`p-12`})}):(0,K.jsx)(`span`,{children:`No results.`})})})})]})]})}function Yp(e){switch(e){case`paid`:return`success`;case`void`:case`uncollectible`:return`destructive`;default:return`default`}}function Xp(e){return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).format(e)}function Zp(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 Qp=[{header:`Invoice Id`,accessorKey:`id`,enableSorting:!1},{header:`Status`,accessorKey:`status`,enableSorting:!1,cell:({cell:e})=>(0,K.jsx)(Yi,{variant:Yp(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?Zp(r,t):[t?Zp(r,t):`-`,n?Zp(i,n):`-`].join(` to `)}},{header:`Amount Due`,accessorKey:`amountDue`,enableSorting:!1,cell:({cell:e})=>Xp(e.getValue()?e.getValue()/100:0)},{header:`Amount Paid`,accessorKey:`amountPaid`,enableSorting:!1,cell:({cell:e})=>Xp(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} @ ${Xp(e.amount/100)}`);return n.join(`
12
- `)}}];function $p(e){return(0,G.useCallback)(async()=>{U.loading(`Refreshing...`,{id:`refreshing`});let t=Date.now();await e(),Date.now()-t<500&&await n(500),U.success(`Refreshed!`,{id:`refreshing`})},[e])}async function em(e){let{data:t}=await N.get(`/Invoice/${e}`);return t}function tm(e,t){return z({queryKey:[e,`invoices`],queryFn:()=>em(e),retry:!1,enabled:!!e,refetchInterval:t?1e4:void 0})}function nm(){let{organizationId:e}=B({strict:!1}),{data:t}=H(Qu(e)),{data:n,refetch:r,isLoading:i,isFetching:a,isRefetching:o}=H(tm(t?.type!==`ENTERPRISE`&&t?.id,!1)),s=$p(r);return t?.type===`ENTERPRISE`?(0,K.jsxs)(`span`,{children:[`You are part of an enterprise organization! We don’t currently show your invoices on this page. Want to explore your solution with Harper more? `,(0,K.jsx)(ys,{}),`, we would love to talk!`]}):i?(0,K.jsx)(Gi,{centered:!0}):!n||!n.length?(0,K.jsxs)(`span`,{children:[`Your invoices will be shown here once one is available! Want to explore your solution with Harper more?`,` `,(0,K.jsx)(ys,{overEmail:!0}),`, we would love to talk!`]}):(0,K.jsx)(Jp,{data:n,columns:Qp,children:(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:s,accessKey:`r`,disabled:a||o,children:[(0,K.jsx)(Kr,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]})})}function rm(e){let t=I({getParentRoute:()=>e,path:`billing`,head:()=>({meta:[{title:`Billing — Harper Fabric`}]}),component:Fp}),n=I({getParentRoute:()=>t,path:`/`,head:()=>({meta:[{title:`Payment Methods — Harper Fabric`}]}),component:Cf}),r=I({getParentRoute:()=>t,path:`invoices`,head:()=>({meta:[{title:`Invoices — Harper Fabric`}]}),component:nm}),i=I({getParentRoute:()=>t,path:`confirm`,head:()=>({meta:[{title:`Confirm Payment — Harper Fabric`}]}),component:Pp});return t.addChildren([n,r,i])}async function im(e){let{data:t}=await N.get(`/OrganizationRole/${e}`);return t}function am(e){return z({queryKey:[e,`roles`],queryFn:()=>im(e),retry:!1,refetchInterval:is(1e4)})}var om=qp(),sm=[{header:`Role Name`,accessorKey:`roleName`,enableSorting:!1},om.display({header:`ID`,id:`id`,enableSorting:!1,cell:e=>(0,K.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,title:e.row.original.id,children:e.row.original.id})}),om.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 cm(e){let{data:t}=await N.post(`/Role/`,e);return t}function lm(){return R({mutationFn:cm})}var um=b({name:M().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:C(),delete:C()});b({roles:b({create:C(),delete:C(),update:C(),view:C()}),clusters:b({create:C(),delete:C(),update:C(),view:C(),resources:A(b({id:M(),delete:C(),update:C(),view:C(),instances:b({create:C(),delete:C(),update:C(),view:C()})}))})});function dm(){let[e]=Ma(),t=ka();return e===`dark`||e===`system`&&t===`dark`?`vs-dark`:`light`}var fm=(0,G.lazy)(async()=>(await ze(()=>import(`./setup-Cop6LBQN.js`),__vite__mapDeps([18,4,1,19,20,21,22,23,24])),{default:(await ze(()=>import(`./dist-lkA3O3eM.js`),__vite__mapDeps([19,1,4]))).default}));function pm(e){return(0,K.jsx)(G.Suspense,{fallback:e.loading??null,children:(0,K.jsx)(fm,{...e})})}var mm={roles:{create:!0,view:!0,update:!0,delete:!0},clusters:{create:!0,view:!0,update:!0,delete:!0,resources:[]}};function hm({isModalOpen:e,setIsModalOpen:t}){let n=dm(),r=oe(),{organizationId:i}=B({strict:!1}),[a,o]=(0,G.useState)(!0),[s,c]=(0,G.useState)(JSON.stringify(mm,null,2)),{mutate:l,isPending:u}=lm(),d=Pt({resolver:Ke(um),defaultValues:{name:``,update:!1,delete:!1}}),f=(0,G.useCallback)(e=>{o(e.length===0)},[o]),p=(0,G.useCallback)(async e=>{let n=Ue(s);if(!n)return;let o={...e,...n,organizationId:i};e&&a&&l(o,{onSuccess:()=>{U.success(`Organization role added successfully!`),t(!1),r.invalidateQueries({queryKey:[i,`roles`],refetchType:`active`}),d.reset()},onError:e=>{U.error(`Failed to add organization role: ${e.message}`)}})},[a,s,l,d,r,t,i]);return(0,K.jsx)(fn,{onOpenChange:t,open:e,children:(0,K.jsxs)(cn,{resizable:!0,children:[(0,K.jsx)(ln,{children:`Add New Organization Role`}),(0,K.jsx)(un,{children:`Set the new organization role permissions.`}),(0,K.jsx)(Io,{...d,children:(0,K.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,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsx)(Y,{control:d.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{className:`col-span-2`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Role Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,className:``,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:d.control,name:`update`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Can Update Organization`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:d.control,name:`delete`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Can Delete Organization`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,K.jsx)(Q,{})]})})]}),(0,K.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,K.jsx)(pm,{className:`w-full h-full`,theme:n,defaultLanguage:`json`,onValidate:f,onChange:e=>{e&&c(e)},options:{automaticLayout:!0},defaultValue:JSON.stringify(mm,null,2)})}),(0,K.jsx)(on,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(F,{variant:`destructiveOutline`,type:`button`,onClick:()=>t(!1),disabled:u,children:`Cancel`}),(0,K.jsx)(F,{variant:`submit`,disabled:u||!a||!d.formState.isValid,children:`Save Changes`})]})})]})})]})})}async function gm({roleId:e}){let{data:t}=await N.delete(`/Role/${e}`,{id:e,deleted:!0});return t}function _m(){return R({mutationFn:({roleId:e})=>gm({roleId:e})})}async function vm({roleId:e,updatedRoleInfo:t}){let{data:n}=await N.put(`/Role/${e}`,t);return n}function ym(){return R({mutationFn:({roleId:e,updatedRoleInfo:t})=>vm({roleId:e,updatedRoleInfo:t})})}function bm({organizationId:e,roleId:t}){return z({queryKey:[e,`roles`,t],queryFn:()=>xm(t),refetchInterval:is(1e4),retry:as()})}async function xm(e){let{data:t}=await N.get(`/Role/${e}`);return t}function Sm({onRoleDeleteClick:e,setIsConfirmingRoleDeletion:t,isRoleDeletionPending:n}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ln,{children:`Confirm Role Deletion`}),(0,K.jsx)(un,{children:`Are you sure you want to delete this role? This action cannot be undone.`}),(0,K.jsxs)(on,{children:[(0,K.jsx)(F,{type:`button`,variant:`defaultOutline`,onClick:()=>t(!1),children:`Cancel`}),(0,K.jsx)(F,{variant:`destructiveOutline`,onClick:e,disabled:n,children:n?`Deleting...`:`Delete Role`})]})]})}function Cm({data:e,isModalOpen:t,closeModal:n}){let r=(0,G.useCallback)(()=>n(!1),[n]);return(0,K.jsx)(fn,{onOpenChange:r,open:t,children:(0,K.jsx)(cn,{resizable:!0,children:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(wm,{roleName:e.roleName}),children:(0,K.jsx)(Tm,{data:e,closeModal:n})})})})}function wm({roleName:e}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(ln,{children:[`Organization Role "`,e,`"`]}),(0,K.jsx)(Gi,{centered:!0,text:`Loading role…`,className:`flex-1 min-h-0`})]})}function Tm({data:e,closeModal:t}){let n=oe(),{data:r}=de(bm({roleId:e.id,organizationId:e.organizationId})),i=wn().user?.roles?.[e.organizationId]?.id===e.id,{update:a,remove:o}=Jl(e.organizationId),{mutate:s,isPending:c}=ym(),{mutate:l,isPending:u}=_m(),d=dm(),[f,p]=(0,G.useState)(!1),m=Pt({resolver:Ke(um),defaultValues:{name:e.roleName,update:r.organization.update||!1,delete:r.organization.delete||!1}}),h=(0,G.useCallback)(()=>{l({roleId:e.id},{onSuccess:()=>{U.success(`Role deleted successfully!`),t(!0),m.reset()},onError:e=>{U.error(`Error`,{description:`Failed to delete role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}})},[e.id,l,m,t]),[g,_]=(0,G.useState)(!0),v=(0,G.useMemo)(()=>JSON.stringify({roles:{...r.organization.roles},clusters:{...r.organization.clusters}},null,2),[r]),[y,b]=(0,G.useState)(v),x=y!==v,S=(0,G.useCallback)(e=>{_(e.length===0)},[_]),C=(0,G.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()=>{U.success(`Role updated successfully!`),await n.invalidateQueries({queryKey:[e.organizationId,`roles`,e.id]}),t(!1),m.reset()},onError:e=>{U.error(`Error`,{description:`Failed to update role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}})},[t,e.id,e.organizationId,m,g,n,r,a,y,s]);return f?(0,K.jsx)(Sm,{onRoleDeleteClick:h,setIsConfirmingRoleDeletion:p,isRoleDeletionPending:u}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(ln,{children:[i||!a?`View`:`Edit`,` Organization Role "`,e.roleName,`"`]}),(0,K.jsx)(Io,{...m,children:(0,K.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,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsx)(Y,{control:m.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{className:`col-span-2`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Role Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,className:``,...e,disabled:!0,readOnly:!0})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`update`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Can Update Organization`}),(0,K.jsx)(J,{children:(0,K.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,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`delete`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Can Delete Organization`}),(0,K.jsx)(J,{children:(0,K.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,K.jsx)(Q,{})]})})]}),(0,K.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,K.jsx)(pm,{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,K.jsx)(on,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[o&&(0,K.jsx)(F,{type:`button`,variant:`destructiveOutline`,onClick:()=>p(!0),disabled:c,children:`Delete Role`}),a&&(0,K.jsx)(F,{variant:`submit`,disabled:!g||c||!m.formState.isValid||!m.formState.isDirty&&!x,children:`Save Changes`})]})})]})})]})}function Em(){let e=L(),t=oe(),{organizationId:n,orgRoleId:r}=B({strict:!1}),{create:i}=Jl(n),{data:a,refetch:o,isFetching:s,isRefetching:c}=de(am(n)),l=(0,G.useMemo)(()=>a&&a?.find(e=>e.id===r),[a,r]),u=!!r&&!!l,[d,f]=(0,G.useState)(!1),p=(0,G.useCallback)(async(i,a)=>{let o=[r?`..`:``,i].filter(Boolean);await e({to:o.join(`/`)}),a&&await t.invalidateQueries({queryKey:[n,`roles`],refetchType:`active`})},[r,e,t]),m=(0,G.useCallback)(()=>{f(!0)},[f]),h=(0,G.useCallback)(e=>p(e.original.id,!1),[p]),g=(0,G.useCallback)(e=>p(void 0,e),[p]),_=$p(o);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sc,{}),(0,K.jsx)(Ep,{children:(0,K.jsxs)(G.Suspense,{fallback:(0,K.jsx)(Gi,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,K.jsxs)(Jp,{data:a,columns:sm,onRowClick:h,children:[(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:_,accessKey:`r`,disabled:s||c,children:[(0,K.jsx)(Kr,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),i&&(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:d,children:[(0,K.jsx)(Gr,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]}),i&&(0,K.jsx)(hm,{isModalOpen:d,setIsModalOpen:f}),u&&(0,K.jsx)(Cm,{data:l,isModalOpen:u,closeModal:g},l.id)]})})]})}function Dm({className:e,...t}){return(0,K.jsx)(_t,{"data-slot":`switch`,className:P(`peer data-[state=checked]:bg-green data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-grey-500 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,K.jsx)(Xe,{"data-slot":`switch-thumb`,className:P(`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 Om(e){return`//oauth/${e}/login`}async function km(e,t){let{data:n}=await N.patch(`/Organization/${e}/settings/oauth`,t);return n}var Am=b({domain:M().min(1,`Domain is required`),clientId:M().min(1,`Client ID is required`),clientSecret:M().min(1,`Client secret is required`),scope:M().optional()}),jm=b({domain:M().min(1,`Domain is required`),clientId:M().optional(),clientSecret:M().optional(),scope:M().optional()});function Mm(){let{organizationId:e}=B({strict:!1}),{user:t}=wn(),{update:n}=Kl(e),{data:r}=de(Qu(e)),i=oe(),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(null),l=r.settings?.oauthConfigs??[],{mutate:u,isPending:d}=R({mutationFn:t=>km(e,t),onSuccess:()=>void i.invalidateQueries({queryKey:[e]}),onError:()=>U.error(`Failed to update OAuth settings.`)}),f=Pt({resolver:Ke(Am),defaultValues:{domain:``,clientId:``,clientSecret:``,scope:`openid email profile`}}),p=e=>{u({provider:`okta`,...e},{onSuccess:()=>{U.success(`OAuth provider added.`),f.reset(),o(!1)}})},m=Pt({resolver:Ke(jm)}),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:()=>{U.success(`OAuth provider updated.`),c(null)}})},_=(e,t)=>{u({id:e.id,provider:e.provider,[t]:!e[t]})},v=e=>`//oauth/${e}/callback`,y=async e=>{await xu(e)&&U.success(`Sign-in URL copied.`)},b=async e=>{await xu(e)&&U.success(`Redirect URI copied.`)};return n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sc,{}),(0,K.jsx)(Ep,{children:(0,K.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,K.jsx)(`h2`,{className:`text-2xl text-foreground font-light mb-6`,children:`Authentication`}),(0,K.jsxs)(`section`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h3`,{className:`text-lg text-foreground font-medium`,children:`OAuth Providers`}),!a&&(0,K.jsxs)(F,{variant:`positiveOutline`,size:`sm`,onClick:()=>o(!0),children:[(0,K.jsx)(Gr,{}),`Add Provider`]})]}),l.length===0&&!a&&(0,K.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,K.jsxs)(`div`,{className:`border rounded-lg p-4 mb-3 text-foreground`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h4`,{className:`font-medium`,children:`Edit Provider`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(gn,{className:`size-4`})})]}),(0,K.jsx)(Io,{...m,children:(0,K.jsxs)(`form`,{onSubmit:m.handleSubmit(t=>g(e,t)),className:`space-y-4`,children:[(0,K.jsx)(Y,{control:m.control,name:`domain`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Domain`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`company.okta.com`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`clientId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client ID`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`Leave blank to keep existing`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`clientSecret`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client Secret`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,placeholder:`Leave blank to keep existing`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`scope`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Scope`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`openid email profile`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,K.jsx)(F,{type:`submit`,variant:`positive`,disabled:d,children:d?`Saving...`:`Save`}),(0,K.jsx)(F,{type:`button`,variant:`outline`,onClick:()=>c(null),children:`Cancel`})]})]})})]},e.id):(0,K.jsx)(`div`,{className:`border rounded-lg p-4 mb-3 text-foreground`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between sm:gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:e.domain}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground uppercase bg-muted px-2 py-0.5 rounded`,children:e.provider}),e.enabled===!1&&(0,K.jsx)(`span`,{className:`text-xs text-destructive bg-destructive/10 px-2 py-0.5 rounded`,children:`Disabled`})]}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground mb-2`,children:[`Client ID: `,(0,K.jsx)(`span`,{className:`text-foreground font-mono`,children:`****`})]}),e.id&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`mt-3 rounded-md bg-muted px-3 py-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Okta redirect URI`}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-1.5`,children:[`Add to `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Login redirect URIs`}),` `,`in your Okta app settings.`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-foreground font-mono truncate`,children:v(e.id)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>void b(v(e.id)),className:`hover:text-foreground shrink-0 text-muted-foreground`,title:`Copy redirect URI`,children:(0,K.jsx)(sr,{className:`size-3.5`})})]})]}),(0,K.jsxs)(`div`,{className:`mt-2 rounded-md bg-muted px-3 py-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`User login link`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`a`,{href:Om(e.id),target:`_blank`,rel:`noreferrer`,className:`text-sm text-foreground truncate hover:underline`,children:Om(e.id)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 text-muted-foreground`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>void y(Om(e.id)),className:`hover:text-foreground`,title:`Copy login link`,children:(0,K.jsx)(sr,{className:`size-3.5`})}),(0,K.jsx)(`a`,{href:Om(e.id),target:`_blank`,rel:`noreferrer`,className:`hover:text-foreground`,title:`Open login link`,children:(0,K.jsx)(dr,{className:`size-3.5`})})]})]})]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 sm:shrink-0`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-foreground cursor-pointer`,children:[(0,K.jsx)(Dm,{checked:e.enabled!==!1,onCheckedChange:()=>_(e,`enabled`),disabled:d}),`Enabled`]}),(0,K.jsxs)(Va,{children:[(0,K.jsx)(Ha,{asChild:!0,children:(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-sm text-foreground ${n?`cursor-pointer`:`cursor-not-allowed opacity-50`}`,children:[(0,K.jsx)(Dm,{checked:!!e.required,onCheckedChange:()=>_(e,`required`),disabled:d||!n}),`Required`]})}),!n&&(0,K.jsxs)(Ua,{children:[`Sign in via `,e.provider,` first to enable Required`]})]}),(0,K.jsx)(F,{variant:`outline`,size:`sm`,onClick:()=>h(e),disabled:d,children:(0,K.jsx)(Ur,{className:`size-4`})})]})]})},e.id)}),a&&(0,K.jsxs)(`div`,{className:`border rounded-lg p-4 text-foreground`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h4`,{className:`font-medium`,children:`Add Okta Provider`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),f.reset()},className:`text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(gn,{className:`size-4`})})]}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-4`,children:[`After saving, copy the `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Okta redirect URI`}),` `,`from the provider card and add it to your Okta app's`,` `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Login redirect URIs`}),`.`]}),(0,K.jsx)(Io,{...f,children:(0,K.jsxs)(`form`,{onSubmit:f.handleSubmit(p),className:`space-y-4`,children:[(0,K.jsx)(Y,{control:f.control,name:`domain`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Domain`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`company.okta.com`,autoFocus:!0,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:f.control,name:`clientId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client ID`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`Okta Client ID`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:f.control,name:`clientSecret`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client Secret`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,placeholder:`Okta Client Secret`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:f.control,name:`scope`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Scope`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`openid email profile`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,K.jsx)(F,{type:`submit`,variant:`positive`,disabled:d,children:d?`Adding...`:`Add Provider`}),(0,K.jsx)(F,{type:`button`,variant:`outline`,onClick:()=>{o(!1),f.reset()},children:`Cancel`})]})]})})]})]})]})})]}):(0,K.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))] text-foreground`,children:`You don't have permission to manage settings for this organization.`})}j.object({email:ls.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:j.string().nonempty({error:`Please select a role.`})});async function Nm(e){let{data:t}=await N.post(`/UserInvite/`,e);return t}function Pm(){return R({mutationFn:e=>Nm(e)})}function Fm({user:e}){let{update:t}=Jl(),{mutate:n,isPending:r}=Pm(),i=e.roles?.[0]?.id,a=(0,G.useCallback)(t=>{if(t.stopPropagation(),!e.email||!i){U.error(`Cannot resend invite: this user has no email or role.`);return}n({email:e.email,roleId:i},{onSuccess:()=>U.success(`Invitation resent to ${e.email}.`)})},[n,i,e.email]);return t?(0,K.jsxs)(F,{variant:`ghost`,size:`sm`,className:`h-auto px-2 py-0 align-middle text-sm`,onClick:a,disabled:r||!i,children:[(0,K.jsx)(Fr,{}),` Resend invite`]}):null}var Im=qp(),Lm=[{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},Im.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},Im.display({header:``,enableSorting:!1,id:`actions`,cell:e=>e.row.original.status===`PENDING`?(0,K.jsx)(Fm,{user:e.row.original}):null})];function Rm({name:e,id:t}){return(0,K.jsxs)(`span`,{className:`flex items-baseline gap-2 truncate`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:e}),(0,K.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:t})]})}var zm=j.object({email:ls.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:j.string().nonempty({error:`Please select a role.`})});async function Bm(e){let{data:t}=await N.post(`/OrganizationRole/`,e);return t}function Vm(){return R({mutationFn:e=>Bm(e)})}function Hm({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let{organizationId:r}=B({strict:!1}),{data:i,isLoading:a}=H({...am(r),throwOnError:!0}),[o,s]=(0,G.useState)(!1),c=Pt({resolver:Ke(zm),defaultValues:{email:``,roleId:``}}),{mutate:l,isPending:u}=Vm(),{mutate:d,isPending:f}=Pm(),p=(0,G.useCallback)(async e=>{e&&(o?d:l)(e,{onSuccess:()=>{let r=e.roleId;c.reset(),c.setValue(`roleId`,r),t(),U.success(`User invited successfully!`),n(!1),s(!1)},onError:e=>{e?.status===404&&s(!0)}})},[l,c,d,t,n,o]);return(0,K.jsx)(fn,{onOpenChange:()=>{n(!1),s(!1),c.reset()},open:e,children:(0,K.jsx)(cn,{"aria-describedby":void 0,children:(0,K.jsx)(Io,{...c,children:(0,K.jsxs)(`form`,{id:`org-add-user-form`,name:`org-add-user-form`,onSubmit:c.handleSubmit(p),className:`grid gap-4 my-4`,children:[(0,K.jsx)(rn,{children:(0,K.jsx)(ln,{children:o?`Invite User`:`Add User`})}),(0,K.jsx)(Y,{control:c.control,name:`email`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Email`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`email`,enterKeyHint:`next`,autoComplete:`email`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:c.control,name:`roleId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Roles`}),a?(0,K.jsx)(Af,{}):(0,K.jsx)(J,{children:(0,K.jsxs)(jf,{...e,onValueChange:t=>e.onChange(t),children:[(0,K.jsx)(Pf,{className:`w-full`,children:(0,K.jsx)(Nf,{placeholder:`Choose Role`})}),(0,K.jsx)(Ff,{children:(0,K.jsxs)(Mf,{children:[(0,K.jsx)(If,{children:`Role`}),i?.map(e=>(0,K.jsx)(Lf,{value:e.id,children:(0,K.jsx)(Rm,{name:e.roleName,id:e.id})},e.id))]})})]})}),(0,K.jsx)(Q,{})]})}),o&&(0,K.jsxs)(un,{className:`p-3 my-5 text-white rounded-md bg-amber-600 flex`,children:[(0,K.jsx)(Pr,{className:`inline-block size-12 pr-2`}),(0,K.jsx)(`span`,{children:`This person doesn’t have a Fabric account. Do you want to invite them?`})]}),(0,K.jsx)(on,{children:(0,K.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,K.jsxs)(F,{type:`submit`,variant:`submit`,disabled:u||f,children:[(0,K.jsx)(Xr,{}),` `,o?`Invite User`:`Add User`]})})})]})})})})}async function Um({roleId:e,userId:t}){let{data:n}=await N.delete(`/OrganizationRole/role/${e}/user/${t}`);return n}function Wm(){return R({mutationFn:({roleId:e,userId:t})=>Um({roleId:e,userId:t})})}function Gm(e){let[t,n]=(0,G.useState)(e||!1);return[t,(0,G.useCallback)(e=>{n(typeof e==`boolean`?e:e.target.checked)},[])]}function Km({data:e,readOnly:t,canRemove:n,orgRole:r,selectedRoles:i,setChangesMade:a}){let{mutate:o,isPending:s}=Vm(),{mutate:c,isPending:l}=Wm(),u=!!i[r.id],[d,f]=(0,G.useState)(u),[p,m]=Gm(u);return(0,G.useEffect)(()=>{p!==d&&(p?o({email:e.email,roleId:r.id},{onSuccess:()=>{f(p),a(!0),U.success(`Role added successfully`)}}):c({userId:e.id,roleId:r.id},{onSuccess:()=>{f(p),a(!0),U.success(`Role removed successfully`)}}))},[o,e.email,e.id,p,r.id,c,a,d]),(0,K.jsxs)(Bo,{className:`flex`,children:[(0,K.jsx)($,{type:`checkbox`,className:`w-6`,disabled:t||s||l||!n&&p,checked:p,onChange:m}),(0,K.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:r.roleName})]},r.id)}function qm({isSelf:e,isPending:t,onConfirm:n}){let[r,i]=(0,G.useState)(!1),a=e?{idle:`Leave organization`,confirm:`Confirm leave`,busy:`Leaving…`,warning:`You’ll lose access to this organization and everything in it. You won’t be able to return unless another member invites you back.`}:{idle:`Remove from organization`,confirm:`Confirm removal`,busy:`Removing…`,warning:`This revokes their access to this organization and everything in it. Their Harper account isn’t deleted, and they can be added back later.`},o=e?Nr:hi;return r?(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`p`,{role:`alert`,className:`flex items-start gap-2 text-sm text-muted-foreground border border-amber-500/50 rounded-md p-3`,children:[(0,K.jsx)(mi,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,K.jsx)(`span`,{children:a.warning})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(F,{type:`button`,variant:`ghostOutline`,disabled:t,onClick:()=>i(!1),children:`Cancel`}),(0,K.jsxs)(F,{type:`button`,variant:`destructive`,disabled:t,onClick:n,children:[(0,K.jsx)(o,{}),` `,t?a.busy:a.confirm]})]})]}):(0,K.jsx)(`div`,{className:`flex justify-start`,children:(0,K.jsxs)(F,{type:`button`,variant:`destructiveOutline`,disabled:t,onClick:()=>i(!0),children:[(0,K.jsx)(o,{}),` `,a.idle]})})}function Jm(e){return e?.trim().toLowerCase()===`admin`}function Ym({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 Xm({closeModal:e,data:t,isModalOpen:n,onUserUpdated:r,orgUserCount:i,orgAdminCount:a}){let{organizationId:o}=B({strict:!1}),s=wn(),{update:c,remove:l}=Jl(o),u=s.user?.email===t.email,[d,f]=(0,G.useState)(!1),{canRemoveRoles:p,showRemovalAction:m,blockedReason:h}=Ym({canDelete:l,isSelf:u,orgUserCount:i,adminCount:a,isAdmin:(t.roles??[]).some(e=>Jm(e.roleName)),roleCount:t.roles?.length??0}),{mutateAsync:g}=Wm(),[_,v]=(0,G.useState)(!1),y=(0,G.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)?U.error(u?`Something went wrong leaving the organization. Please try again.`:`Couldn’t remove ${t.email} from the organization. Please try again.`):U.success(u?`You’ve left the organization.`:`${t.email} was removed from the organization.`),v(!1),r()},[t.roles,t.id,t.email,u,g,r]);return(0,K.jsx)(fn,{onOpenChange:d?r:e,open:n,children:(0,K.jsxs)(cn,{resizable:!0,children:[(0,K.jsx)(rn,{children:(0,K.jsxs)(ln,{children:[c?`Edit `:`View `,` `,t.email,` `,u?`(yourself)`:``]})}),c&&(0,K.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,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(Gi,{centered:!0,text:`Loading roles…`,className:`flex-1 min-h-0`}),children:(0,K.jsx)(Zm,{data:t,organizationId:o,update:c,canRemove:p,setChangesMade:f})}),t.status===`PENDING`&&(0,K.jsx)(`div`,{className:`border-t border-border pt-4`,children:(0,K.jsx)(Fm,{user:t})}),m&&(0,K.jsx)(`div`,{className:`border-t border-border pt-4`,children:(0,K.jsx)(qm,{isSelf:u,isPending:_,onConfirm:y})}),h&&(0,K.jsxs)(`p`,{className:`flex items-start gap-2 text-sm text-muted-foreground border border-amber-500/50 rounded-md p-3`,children:[(0,K.jsx)(mi,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,K.jsx)(`span`,{children:h===`sole-member`?`You’re the only member of this organization, so you can’t remove your roles or leave — it would be left with no one to manage it. If you no longer need this organization, terminate its clusters, then delete the organization from the ⋯ menu on the Organizations page.`:`You’re the only admin of this organization, so you can’t remove your roles or leave — it would be left with no one who can manage its members, roles, or clusters. Give another member the admin role first, then you can step back.`})]})]})})}function Zm({data:e,organizationId:t,update:n,canRemove:r,setChangesMade:i}){let{data:a}=de(am(t)),o=(0,G.useMemo)(()=>e.roles?Hu(e.roles,`id`):{},[e]);return(0,K.jsx)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 overflow-y-auto`,children:a.map(t=>(0,K.jsx)(Km,{readOnly:!n,canRemove:r,data:e,orgRole:t,selectedRoles:o,setChangesMade:i},t.id))})}function Qm(e,t){return e.email>t.email?1:-1}function $m(e){return(e.users??[]).filter(e=>e!=null)}function eh(e){let t={};for(let n of e)for(let e of $m(n))t[e.id]||(t[e.id]={...e,roles:[]}),t[e.id].roles.push(n);return Object.values(t).sort(Qm)}function th(e){let t=new Set;for(let n of e)if(Jm(n.roleName))for(let e of $m(n))t.add(e.id);return t.size}function nh(){let e=L(),{organizationId:t,orgUserId:n}=B({strict:!1}),{update:r}=Jl(t),{data:i,refetch:a,isFetching:o,isRefetching:s}=de(am(t)),c=(0,G.useMemo)(()=>eh(i),[i]),l=(0,G.useMemo)(()=>th(i),[i]),u=(0,G.useMemo)(()=>c?.find(e=>e.id===n),[c,n]),d=(0,G.useCallback)(t=>{let r=[n?`..`:``,t].filter(Boolean);e({to:r.join(`/`)})},[n,e]),f=!!n&&!!u,[p,m]=(0,G.useState)(!1),[h]=(0,G.useState)({attribute:`email`,descending:!1}),g=(0,G.useMemo)(()=>[{desc:h.descending,id:h.attribute}],[h]),_=(0,G.useCallback)(()=>{m(!0)},[m]),v=(0,G.useCallback)(()=>{a(),m(!1)},[a,m]),y=(0,G.useCallback)(e=>{d(e.original.id)},[d]),b=(0,G.useCallback)(()=>{d(void 0)},[d]),x=(0,G.useCallback)(()=>{a(),d(void 0)},[d,a]),S=$p(a);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sc,{}),(0,K.jsx)(Ep,{children:(0,K.jsxs)(G.Suspense,{fallback:(0,K.jsx)(Gi,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,K.jsxs)(Jp,{data:c,isFetching:o||s,columns:Lm,onRowClick:y,sortingState:g,children:[(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:S,accessKey:`r`,disabled:o||s,children:[(0,K.jsx)(Kr,{}),` `,(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),r&&(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:_,accessKey:`a`,disabled:p,children:[(0,K.jsx)(Gr,{}),` `,(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]}),r&&(0,K.jsx)(Hm,{isModalOpen:p,onChangesSaved:v,setIsModalOpen:m}),f&&(0,K.jsx)(Xm,{closeModal:b,data:u,isModalOpen:f,onUserUpdated:x,orgUserCount:c.length,orgAdminCount:l})]})})]})}function rh({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`skeleton`,className:P(`bg-primary/10 animate-pulse rounded-md`,e),...t})}function ih({organizationId:e,organizationName:t,providers:n}){return(0,K.jsxs)(On,{className:`relative h-full justify-between opacity-90`,children:[(0,K.jsxs)(kn,{children:[(0,K.jsx)(jn,{className:`truncate`,children:e}),(0,K.jsx)(An,{children:(0,K.jsx)(`h2`,{children:t})})]}),(0,K.jsxs)(Mn,{className:`flex flex-col gap-2`,children:[(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-1.5 mb-1`,children:[(0,K.jsx)(Tr,{className:`size-3 shrink-0`}),`Sign in with an OAuth provider to access this organization.`]}),n.map(e=>(0,K.jsx)(`a`,{href:Om(e.oauthConfigId),children:(0,K.jsxs)(F,{variant:`outline`,className:`w-full`,children:[`Sign in with `,e.name]})},e.oauthConfigId))]})]})}var ah=b({couponId:M().nonempty({message:`Please enter a coupon ID.`}).trim()});async function oh({organizationId:e,couponId:t}){let{data:n}=await N.post(`/Coupon`,{organizationId:e,couponId:t},{validateStatus:e=>e>=200&&e<400||e===400||e===409});return n}function sh(){return R({mutationFn:oh})}function ch({organizationId:e,organizationName:t,isOpen:n,onClose:r}){let{mutate:i,isPending:a}=sh(),o=Pt({resolver:Ke(ah),defaultValues:{couponId:``}}),{handleSubmit:s,control:c,reset:l}=o;(0,G.useEffect)(()=>{n&&l({couponId:``})},[n,l]);let u=(0,G.useCallback)(n=>{i({organizationId:e,couponId:n.couponId},{onSuccess:i=>{i?U.error(`Error`,{description:i||`Failed to add coupon.`}):(U.success(`Success`,{description:`Coupon "${n.couponId}" added to ${t||e}.`}),r())}})},[i,e,t,r]);return(0,K.jsx)(fn,{open:n,onOpenChange:e=>!e&&r(),children:(0,K.jsxs)(cn,{children:[(0,K.jsxs)(rn,{children:[(0,K.jsx)(ln,{children:`Add Coupon`}),(0,K.jsxs)(un,{children:[`Add a coupon code to`,` `,t||e,`. This coupon will be applied to the next billing cycle.`,(0,K.jsx)(`br`,{}),`Coupons can be created in our`,` `,(0,K.jsx)(`a`,{href:`https://dashboard.stripe.com/`,target:`_blank`,rel:`noreferrer`,className:`text-purple hover:underline`,children:`Stripe Dashboard`}),`.`]})]}),(0,K.jsx)(Io,{...o,children:(0,K.jsxs)(`form`,{onSubmit:s(u),children:[(0,K.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,K.jsx)(Y,{control:c,name:`couponId`,render:({field:e})=>(0,K.jsxs)(X,{className:`grid items-center gap-4`,children:[(0,K.jsx)(Z,{children:`Coupon ID`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{...e,placeholder:`e.g. 100OFF`,disabled:a})}),(0,K.jsx)(Q,{})]})})}),(0,K.jsxs)(on,{children:[(0,K.jsx)(F,{type:`button`,variant:`ghost`,onClick:r,disabled:a,children:`Cancel`}),(0,K.jsx)(F,{type:`submit`,disabled:a,children:a?`Adding...`:`Add Coupon`})]})]})})]})})}function lh({organizationRole:e,onDeleteOrgModal:t}){let{organizationId:n,organizationName:r,roleName:i}=e,{remove:a,update:o}=Kl(n),s=o,{view:c}=Jl(n),l=En(`billing:write`),[u,d]=(0,G.useState)(!1),f=(0,G.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,K.jsx)($r,{className:`size-4 mr-2 text-blue-500`}),label:`Clusters`},c&&{key:`roles`,to:`${n}/roles`,icon:(0,K.jsx)(ti,{className:`size-4 mr-2 text-purple`}),label:`Roles`},c&&{key:`users`,to:`${n}/users`,icon:(0,K.jsx)(_i,{className:`size-4 mr-2 text-orange-500`}),label:`Users`},s&&{key:`billing`,to:`${n}/billing`,icon:(0,K.jsx)(cr,{className:`size-4 mr-2 text-green-500`}),label:`Billing`},o&&{key:`settings`,to:`${n}/settings`,icon:(0,K.jsx)(Tr,{className:`size-4 mr-2 text-yellow-500`}),label:`Settings`},l&&{key:`add-coupon`,onClick:()=>d(!0),icon:(0,K.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,K.jsx)(pi,{className:`size-4 mr-2 text-red-500`}),label:`Delete`}].filter($a),m=a||l;return(0,K.jsx)(Nc,{items:m?p:[],children:(0,K.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,K.jsx)(V,{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,K.jsxs)(kn,{children:[(0,K.jsxs)(jn,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:n}),m&&(0,K.jsxs)(Ti,{children:[(0,K.jsx)(Ei,{"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,K.jsx)(ur,{})}),(0,K.jsx)(Di,{children:Mc(p,`dropdown`)})]})]}),(0,K.jsx)(An,{children:(0,K.jsx)(`h2`,{children:r})})]}),(0,K.jsxs)(Mn,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(Yi,{className:`min-w-0 shrink`,title:No(i),children:(0,K.jsx)(`span`,{className:`truncate`,children:No(i)})}),(0,K.jsxs)(`span`,{className:`text-sm shrink-0 py-2 whitespace-nowrap ml-auto`,children:[`View `,(0,K.jsx)(Rn,{className:`inline-block`})]})]}),(0,K.jsx)(ch,{organizationId:n,organizationName:r,isOpen:u,onClose:()=>d(!1)})]})})}async function uh(e){let{data:t}=await N.delete(`/Organization/${e}`);return t}function dh(){return R({mutationFn:e=>uh(e)})}async function fh(e){let{data:t}=await N.post(`/Organization/`,{...e});return t}function ph(){return R({mutationFn:e=>fh(e)})}var mh=M().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.`}),hh=b({name:M().max(255,{error:`Name cannot be longer than 255 characters.`}),subdomain:S([k(``),x(),mh]).optional()});function gh(){let{user:e}=wn(),t=L(),n=Pt({resolver:Ke(hh),defaultValues:{name:``,subdomain:``}}),{setFocus:r,watch:i}=n;(0,G.useEffect)(()=>{r(`name`)},[r]);let a=`${e?.firstname} ${e?.lastname} Org`,o=i(`name`)||a,s=i(`subdomain`),c=(0,G.useMemo)(()=>{let e=ed(nd(o),mh.maxLength);return{suggestedSubdomain:e,fullHostName:`future-cluster-names.${s||e}.harperfabric.com`}},[o,s]),{mutate:l,isPending:d}=ph(),p=oe(),h=(0,G.useCallback)(async e=>{l({name:e.name||a,subdomain:e.subdomain||c.suggestedSubdomain},{onSuccess:e=>{p.invalidateQueries({queryKey:f,refetchType:`active`}),u.reloadUser(m),t({to:`/${e.id}`})}})},[c.suggestedSubdomain,p,l,a,t]);return(0,K.jsx)(K.Fragment,{children:(0,K.jsx)(Io,{...n,children:(0,K.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,K.jsx)(Y,{control:n.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,maxLength:hh.shape.name.maxLength,autoCapitalize:`words`,placeholder:a,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:n.control,name:`subdomain`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Subdomain`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,maxLength:mh.maxLength,autoCapitalize:`none`,placeholder:c.suggestedSubdomain,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Full Host Name`}),(0,K.jsx)(J,{children:(0,K.jsx)(`span`,{children:c.fullHostName})}),(0,K.jsx)(Q,{})]}),(0,K.jsx)(on,{children:(0,K.jsxs)(F,{type:`submit`,variant:`submit`,disabled:d,children:[`Create New Organization `,(0,K.jsx)(Rn,{})]})})]})})})}function _h(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sc,{}),(0,K.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,K.jsx)(gh,{})})]})}var vh={org:`organization`,clu:`cluster`,ins:`instance`},yh=/^(org|clu|ins)-[a-z0-9]+$/;function bh(e){if(typeof e!=`string`)return null;let t=e.trim(),n=yh.exec(t);return n?{kind:vh[n[1]],id:t}:null}function xh(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 Sh(e,t){let{data:n}=await N.get(xh(e,t));return{organizations:n.slice(0,12),hasNextPage:n.length>12}}var Ch={organizations:[],hasNextPage:!1};function wh(e){return e instanceof v&&(e.response?.status===404||e.status===404)}async function Th(e){try{let{data:t}=await N.get(`/Admin/Organization/${e}`);return t?{organizations:[t],hasNextPage:!1}:Ch}catch(e){if(wh(e))return Ch;throw e}}async function Eh(e){try{let{data:t}=await N.get(`/Cluster/${e}`),n=t?.organizationId;return n?await Th(n):Ch}catch(e){if(wh(e))return Ch;throw e}}function Dh(e,t){let n=bh(t);return z({queryKey:[`admin-all-organizations`,t,e],queryFn:()=>n?.kind===`organization`?Th(n.id):n?.kind===`cluster`?Eh(n.id):Sh(e,t),placeholderData:je,retry:!1})}function Oh(e,t=300,n){let[r,i]=(0,G.useState)(e),a=n?n(e):e;return(0,G.useEffect)(()=>{let n=setTimeout(()=>i(e),t);return()=>clearTimeout(n)},[a,t]),r}function kh(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 Ah(e,t){let[n,r]=(0,G.useState)(t),[i,a]=(0,G.useState)(e);return(0,G.useEffect)(()=>{kh(n,t)||(r(t),a(e))},[n,t,e]),kh(n,t)?[i,a]:[e,a]}var jh={};function Mh(e,t,n){let r=(0,G.useCallback)((e,n)=>t(e,n),[n]);(0,G.useEffect)(()=>(jh[e]||(jh[e]=[]),jh[e].push(r),function(){let t=jh[e].indexOf(r);t>=0&&jh[e].splice(t,1)}),[e,t,r])}function Nh(e,t,n){let r=jh[e];if(r)for(let e of r)e(t,n)}function Ph(e,t,n){return r=>Nh(e,t,n??r)}function Fh(e,t,n){return(0,G.useCallback)(r=>Nh(e,t,n??r),[e,t,n])}function Ih(e,t){let n=Ah(We(e,t),[e]),[r,i]=n;return(0,G.useEffect)(()=>{Ge(e,r),Nh(`Session:${e}`,r)},[e,r]),Mh(`Session:${e}`,function(e){r!==e&&i(e)},[r,e,t]),(0,G.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 Lh(){let e=oe(),{data:t}=de(s()),{mutate:n,isPending:r}=dh(),[i,a]=(0,G.useState)(!1),[o,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(``),d=(0,G.useCallback)(()=>u(``),[]),f=En(`org:read`),[p,m]=Ih(`ShowAllOrganizations`,!1),[h,g]=(0,G.useState)(0),_=f&&p,v=(0,G.useCallback)(e=>{m(e),g(0)},[m]),y=Oh(l,300),b=(0,G.useMemo)(()=>{if(!f)return null;let e=bh(y);return e?.kind===`organization`||e?.kind===`cluster`?e:null},[f,y]),x=_||!!b,{data:S,isPending:C}=H({...Dh(h,y),enabled:x}),{organizationRoles:w,oauthLockedOrgs:T}=(0,G.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(Ap([`organizationId`,`organizationName`],l)).sort((e,t)=>(e.organizationName||``)>(t.organizationName||``)?1:-1),oauthLockedOrgs:r}},[l,t?.roles,f]),E=(0,G.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,G.useCallback)(e=>{u(e.currentTarget.value||``),g(0)},[]),k=(0,G.useCallback)(t=>{t?.organizationId&&n(t.organizationId,{onSuccess:()=>{U.success(`Success`,{description:`Organization successfully deleted.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),e.invalidateQueries({queryKey:[]}),a(!1)},onError:()=>a(!1)})},[n,e,a]),A=(0,G.useCallback)(e=>{c(e),a(!0)},[]),{createCluster:j}=le({strict:!1});return!_&&w.length===1&&!l.length&&j?(0,K.jsx)(re,{to:`/${w[0].organizationId}/new-cluster`,replace:!0}):!_&&!w.length&&!T.length&&!l.length?(0,K.jsx)(_h,{}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sc,{children:(0,K.jsxs)(`div`,{className:`flex w-full items-center justify-end gap-2`,children:[f&&(0,K.jsxs)(`label`,{className:`flex shrink-0 cursor-pointer items-center gap-2 text-xs`,children:[(0,K.jsx)(Dm,{checked:p,onCheckedChange:v,"aria-label":`Show all organizations`}),(0,K.jsx)(`span`,{className:`hidden sm:inline-block`,children:`All Orgs`})]}),(0,K.jsx)($,{placeholder:`Filter by name`,className:`inline-block w-full text-xs`,value:l,onChange:O}),(0,K.jsx)(V,{to:`/new-org`,children:(0,K.jsxs)(F,{variant:`positive`,accessKey:`n`,children:[(0,K.jsx)(Gr,{}),(0,K.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,K.jsx)(`u`,{children:`N`}),`ew `,(0,K.jsx)(`span`,{className:`hidden md:inline-block`,children:`Organization`})]})]})})]})}),(0,K.jsxs)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-12`,children:[!x&&T.map(e=>(0,K.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,K.jsx)(ih,{organizationId:e.organizationId,organizationName:e.organizationName,providers:e.providers})},e.organizationId)),x&&C?Array.from({length:12},(e,t)=>(0,K.jsx)(rh,{className:`col-span-1 h-40 md:col-span-4 lg:col-span-3 2xl:col-span-2`},t)):D.map(e=>(0,K.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,K.jsx)(lh,{organizationRole:e,onDeleteOrgModal:A})},e.organizationId)),!D.length&&!(x&&C)&&(x||!T.length)&&(0,K.jsxs)(`div`,{className:`col-span-1 md:col-span-12 text-center`,children:[(0,K.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,K.jsx)(F,{variant:`outline`,onClick:d,children:`Clear Filters`})]})]}),x&&(h>0||S?.hasNextPage)&&(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-4 py-6`,children:[(0,K.jsxs)(F,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:h===0,onClick:()=>g(e=>e-1),children:[(0,K.jsx)(Ln,{}),`Previous`]}),(0,K.jsxs)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:[`Page `,h+1]}),(0,K.jsxs)(F,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:!S?.hasNextPage,onClick:()=>g(e=>e+1),children:[`Next`,(0,K.jsx)(Rn,{})]})]})]}),o&&(0,K.jsx)(Cc,{typeOfThingBeingDeleted:`organization`,nameOfThingBeingDeleted:o.organizationName,isModalOpen:i,setIsModalOpen:()=>a(!1),deletionConfirmed:()=>k(o),deletionPending:r})]})}var Rh=I({getParentRoute:()=>xo,id:`_orgsLayout`});I({getParentRoute:()=>Rh,path:`/`,head:()=>({meta:[{title:`Organizations — Harper Fabric`}]}),component:Lh}),I({getParentRoute:()=>Rh,path:`/new-org`,head:()=>({meta:[{title:`New Organization — Harper Fabric`}]}),component:_h});var zh=I({getParentRoute:()=>Rh,path:`$organizationId`,beforeLoad:async e=>{let{organizationId:t}=e.params;if(!Xu(t))throw ie({to:`/`});return{organization:await e.context.queryClient.ensureQueryData(Qu(t))}}});I({getParentRoute:()=>zh,path:`/roles`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:Em}),I({getParentRoute:()=>zh,path:`/roles/$orgRoleId`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:Em}),I({getParentRoute:()=>zh,path:`/users`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:nh}),I({getParentRoute:()=>zh,path:`/users/$orgUserId`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:nh}),I({getParentRoute:()=>zh,path:`/settings`,component:Mm}),rm(zh);var Bh=I({getParentRoute:()=>zh,id:`_clusterLayout`});I({getParentRoute:()=>Bh,path:`/`,head:()=>({meta:[{title:`Clusters — Harper Fabric`}]}),component:jp}),I({getParentRoute:()=>zh,path:`/new-cluster`,head:()=>({meta:[{title:`New Cluster — Harper Fabric`}]}),component:Tp}),I({getParentRoute:()=>Hh,path:`/edit`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),component:Tp}),I({getParentRoute:()=>Hh,path:`/edit/$mode`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),component:Tp});function Vh(){return(0,K.jsx)(Le,{})}var Hh=I({getParentRoute:()=>Bh,path:`$clusterId`,component:Vh,beforeLoad:async({context:e,params:t})=>({cluster:await e.queryClient.ensureQueryData(cs(t.clusterId))})}),Uh=e=>new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e),Wh=e=>`${new Intl.NumberFormat(void 0,{maximumFractionDigits:1}).format(e)} hr`,Gh=e=>tp(e),Kh={reads:`Reads`,readBytes:`Read data`,writes:`Writes`,writeBytes:`Write data`,realTimeMessages:`Real-time messages`,realTimeBytes:`Real-time data`,cpuTimeHours:`Compute`,storageBytes:`Storage`},qh={reads:Uh,readBytes:Gh,writes:Uh,writeBytes:Gh,realTimeMessages:Uh,realTimeBytes:Gh,cpuTimeHours:Wh,storageBytes:Gh},Jh=[`reads`,`readBytes`,`writes`,`writeBytes`,`realTimeMessages`,`realTimeBytes`,`cpuTimeHours`,`storageBytes`];function Yh(e,t,n){return{label:n??Kh[e],used:t.used,limit:t.limit,unlimited:t.unlimited,limitKnown:t.limitKnown,format:qh[e]}}function Xh({label:e,used:t,limit:n,unlimited:r,limitKnown:i,format:a}){let o=r||n!=null&&n<0,s=i&&!o&&n!=null&&n>0,c=s?Math.min(100,Math.round(t/n*100)):0,l=c>=90;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-foreground`,children:e}),(0,K.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[(0,K.jsx)(`span`,{className:`text-foreground`,children:a(t)}),s?(0,K.jsxs)(K.Fragment,{children:[`/ `,a(n)]}):` used`]})]}),(0,K.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`h-2 flex-1 overflow-hidden rounded-full bg-muted`,children:s?(0,K.jsx)(`div`,{className:`h-full rounded-full ${l?`bg-yellow`:`bg-primary dark:bg-violet-400`}`,style:{width:`${c}%`}}):o?(0,K.jsx)(`div`,{className:`h-full w-full bg-[repeating-linear-gradient(-45deg,transparent,transparent_5px,var(--color-border)_5px,var(--color-border)_9px)] dark:bg-[repeating-linear-gradient(-45deg,transparent,transparent_5px,rgba(255,255,255,0.32)_5px,rgba(255,255,255,0.32)_9px)]`}):null}),(0,K.jsx)(`span`,{className:`w-16 shrink-0 text-right text-xs tabular-nums ${l?`text-yellow`:`text-muted-foreground`}`,children:s?`${c}%`:o?`Unlimited`:`—`})]})]})}function Zh(e){return z({queryKey:[`clusterUsage`,e],queryFn:async()=>{let{data:t}=await N.get(`/Cluster/${e}/usage`);return t},enabled:!!e,staleTime:6e4})}function Qh(e){return H(Zh(e))}function $h(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} ${eg(e.renewsAt)}`:null].filter(Boolean).join(` · `)}function eg(e){return new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))}function tg({clusterId:e,base:t}){let{data:n}=Qh(e);return!n||n.selfManaged||n.regions.length===0?null:(0,K.jsxs)(`section`,{className:`mt-6 rounded-2xl border border-border bg-card p-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Plan usage`}),(0,K.jsxs)(V,{to:`${t}/usage`,className:`inline-flex items-center gap-1 text-xs text-primary hover:underline dark:text-violet-300`,children:[`View all usage `,(0,K.jsx)(Rn,{className:`size-3`})]})]}),(0,K.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:$h(n)}),(0,K.jsx)(`div`,{className:`mt-4`,children:n.regions.length===1?(0,K.jsx)(ng,{data:n}):(0,K.jsx)(rg,{data:n})})]})}function ng({data:e}){let t=e.regions[0].metrics,n=[Yh(`reads`,t.reads),Yh(`writes`,t.writes),Yh(`storageBytes`,t.storageBytes),Yh(`cpuTimeHours`,t.cpuTimeHours)];return(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-x-8 gap-y-4 sm:grid-cols-2`,children:n.map(e=>(0,K.jsx)(Xh,{...e},e.label))})}function rg({data:e}){let t=e.mostConstrained;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`p`,{className:`mb-1.5 text-xs text-muted-foreground`,children:[`Most constrained of `,e.regions.length,` regions`]}),t?(0,K.jsx)(Xh,{...Yh(t.metric,{used:t.used,limit:t.limit,unlimited:!1,limitKnown:!0},`${t.region??`Region`} · ${Kh[t.metric]}`)}):(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No metered limits on the current plan — see the breakdown for details.`})]})}function ig({cluster:e}){let t=se(),n=oe(),{update:r,remove:i}=Xl(e.organizationId,e.id),{run:a,isPending:o}=bu(e),{mutate:s,isPending:c}=gu(),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(!1),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(null),_=e.status===`RUNNING`,v=e.status===`STOPPED`,y=e.status===`PARTIAL`,b=!r||o,x=(0,G.useCallback)(()=>{s(e.id,{onSuccess:async()=>{await n.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),m(!1),U.success(`Success`,{description:`Cluster successfully terminated.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),t.navigate({to:`/${e.organizationId}`})},onError:()=>{m(!1)}})},[e.id,e.organizationId,s,n,t]),S=(0,G.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 cu(e)||!r&&!i?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Ti,{children:[(0,K.jsx)(Ei,{asChild:!0,children:(0,K.jsxs)(F,{variant:`outline`,size:`sm`,disabled:o,className:`gap-1.5 hover:translate-y-0 data-[state=open]:[&>svg]:rotate-180`,children:[`Cluster actions`,(0,K.jsx)(pn,{className:`size-4 transition-transform`})]})}),(0,K.jsxs)(Di,{align:`end`,className:`w-56`,children:[(0,K.jsx)(Ai,{className:`text-gray-600 text-xs`,children:`Container`}),(0,K.jsxs)(Oi,{disabled:b||!(v||y),onClick:()=>void a(`start`,{safeMode:!1,strategy:`parallel`}),children:[(0,K.jsx)(Wr,{}),` Start`]}),(0,K.jsxs)(Oi,{disabled:b||!v,onClick:()=>g(`start`),children:[(0,K.jsx)(Or,{}),` Start in safe mode`]}),(0,K.jsxs)(Oi,{disabled:b||!(_||y),onClick:()=>f(!0),children:[(0,K.jsx)(Yr,{}),` Restart`]}),(0,K.jsxs)(Oi,{disabled:b||!_,onClick:()=>g(`restart`),children:[(0,K.jsx)(Or,{}),` Restart in safe mode`]}),(0,K.jsxs)(Oi,{variant:`destructive`,disabled:b||!(_||y),onClick:()=>u(!0),children:[(0,K.jsx)(ai,{}),` Stop`]}),(0,K.jsx)(ji,{}),(0,K.jsxs)(Oi,{variant:`destructive`,disabled:!i,onClick:()=>m(!0),children:[(0,K.jsx)(fi,{}),` Terminate`]})]})]}),(0,K.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,K.jsx)(mu,{open:h!==null,setOpen:e=>{e||g(null)},action:h??`restart`,targetName:e.name,scope:`cluster`,isPending:o,onConfirm:S}),(0,K.jsx)(Cc,{typeOfThingBeingDeleted:`cluster`,transitiveVerb:`Terminate`,presentParticiple:`Terminating`,nameOfThingBeingDeleted:e.name,isModalOpen:p,setIsModalOpen:m,deletionConfirmed:x,deletionPending:c})]})}function ag(){let{clusterId:e}=B({strict:!1}),t=se(),n=L(),{data:r}=H(cs(e,!0)),{user:i,isLoading:a}=Dn(e),{view:s,update:l}=Xl(r?.organizationId,r?.id),[f,p]=(0,G.useState)(!1),m=r?.domains?.[0]?.domain||r?.fqdn||``,[h,g]=Cu(m,m?`https://${m}`:``),_=r?`/${r.organizationId}/${r.id}`:``,v=(0,G.useCallback)(async()=>{if(r){p(!0);try{await u.establishFabricConnectAuth({id:r.id,operationsUrl:c(r)}),await t.invalidate()}catch{U.error(`Could not connect to this cluster through Fabric Connect.`)}finally{p(!1)}}},[r,t]),y=(0,G.useCallback)(()=>{r&&(u.setUserForEntity(r,null),u.flagForFabricConnect(r.id,!1)),n({to:`${_}/sign-in`})},[_,r,n]),b=(0,G.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,K.jsx)(sg,{children:(0,K.jsx)(cg,{})});if(!s)return(0,K.jsx)(re,{to:`/${r.organizationId}`,replace:!0});if(cu(r))return(0,K.jsx)(og,{cluster:r});if(!r.fqdn)return(0,K.jsx)(re,{to:`${_}/instances`,replace:!0});if(r.resetPassword){if(!l)return(0,K.jsx)(sg,{children:(0,K.jsxs)(`div`,{className:`text-center py-12`,children:[(0,K.jsx)($r,{className:`size-12 text-muted-foreground mx-auto mb-4`}),(0,K.jsx)(`h1`,{className:`text-xl font-medium mb-2 text-foreground`,children:`Pending Owner Setup`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-md mx-auto`,children:`This cluster needs an administrator to finish setup before it can be used.`})]})});let e=r.status&&Vo.includes(r.status)&&es(r);return(0,K.jsx)(re,{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&&!Ho.includes(e.status)).length,T=r.instances??[],E=!!r.status&&Vo.includes(r.status)&&T.length>0&&T.every(e=>e.safeMode);return(0,K.jsxs)(sg,{children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-4 mb-6`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center size-12 rounded-xl bg-violet-50 text-primary dark:bg-grey-700 dark:text-violet-300 shrink-0`,children:(0,K.jsx)($r,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:r.name}),(0,K.jsx)(lg,{status:r.status}),E&&(0,K.jsx)(ug,{})]}),(0,K.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,K.jsxs)(`span`,{children:[w,` `,w===1?`instance`:`instances`]}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsxs)(`a`,{href:`https://${m}`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 hover:text-foreground hover:underline`,children:[m,(0,K.jsx)(dr,{className:`size-3`})]}),(0,K.jsxs)(Ti,{children:[(0,K.jsx)(Ei,{"aria-label":`Copy cluster URLs`,className:`rounded-md p-1 -m-1 hover:bg-accent/60 hover:text-foreground`,children:(0,K.jsx)(sr,{className:`size-3.5`})}),(0,K.jsxs)(Di,{align:`start`,children:[(0,K.jsx)(Oi,{onClick:h,children:`Copy host name`}),(0,K.jsx)(Oi,{onClick:g,children:`Copy API URL`})]})]})]})]}),(0,K.jsx)(ig,{cluster:r})]}),a?(0,K.jsx)(cg,{}):S?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-sm`,children:[(0,K.jsx)(Qn,{className:`size-4 text-green shrink-0`}),(0,K.jsx)(`span`,{className:`font-medium text-green`,children:x?`Connected via Fabric Connect`:`Signed in directly`}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,x?`through your Harper account`:`session cookie`]})]}),(0,K.jsxs)(V,{to:`${_}/apps`,className:`group flex items-center gap-4 rounded-2xl border-2 border-primary/30 bg-primary/5 p-6 transition-all hover:border-primary hover:bg-primary/10 dark:border-violet-400/30 dark:bg-violet-400/5 dark:hover:border-violet-400 dark:hover:bg-violet-400/10`,children:[(0,K.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-primary/10 text-primary shrink-0 dark:bg-violet-400/15 dark:text-violet-300`,children:(0,K.jsx)(qr,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-lg font-medium text-foreground`,children:`Enter cluster`}),(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Open the studio — apps, databases, APIs, logs, and config.`})]}),(0,K.jsx)(Rn,{className:`size-5 text-muted-foreground transition-transform group-hover:translate-x-1`})]}),(0,K.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-4 text-sm`,children:[x&&(0,K.jsx)(`button`,{type:`button`,onClick:y,className:`text-muted-foreground hover:text-foreground transition-colors`,children:`Switch to direct sign-in`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>void b(),className:`text-muted-foreground hover:text-destructive transition-colors`,children:x?`Disconnect`:`Direct sign out`})]})]}):(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-sm font-medium text-foreground mb-3`,children:`Connect to this cluster`}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3.5`,children:[l&&!cu(r)&&(0,K.jsx)(dg,{icon:vi,title:`Fabric Connect`,description:`Connect through your Harper account. No cluster credentials needed.`,pill:C===`fabric`?`last`:C?void 0:`recommended`,children:(0,K.jsx)(F,{className:`w-full`,disabled:f,onClick:()=>void v(),children:f?(0,K.jsx)(Ar,{className:`animate-spin`}):`Fabric Connect`})}),(0,K.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,K.jsx)(F,{className:`w-full`,variant:`outline`,onClick:y,children:`Direct sign-in`})})]})]}),(0,K.jsx)(tg,{clusterId:r.id,base:_})]})}function og({cluster:e}){let t=se(),n=L(),r=`/${e.organizationId}/${e.id}`,i=(0,G.useMemo)(()=>(e.instances??[]).filter(e=>e.status&&!Ho.includes(e.status)).sort(Bu),[e.instances]),a=i.at(0),{user:s,isLoading:c}=Dn(a?.id),l=!!a&&!!s,f=(0,G.useCallback)(()=>{a&&n({to:`${r}/instance/${a.id}/sign-in`})},[r,a,n]),m=(0,G.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,K.jsxs)(sg,{children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-4 mb-6`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center size-12 rounded-xl bg-violet-50 text-primary dark:bg-grey-700 dark:text-violet-300 shrink-0`,children:(0,K.jsx)($r,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:e.name}),(0,K.jsx)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full text-muted-foreground bg-muted`,children:`Self-Hosted`})]}),(0,K.jsx)(`div`,{className:`mt-1 text-sm text-muted-foreground`,children:(0,K.jsxs)(V,{to:`${r}/instances`,className:`hover:text-foreground hover:underline`,children:[i.length,` `,i.length===1?`instance`:`instances`]})})]})]}),a?c?(0,K.jsx)(cg,{}):l?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-sm`,children:[(0,K.jsx)(Qn,{className:`size-4 text-green shrink-0`}),(0,K.jsx)(`span`,{className:`font-medium text-green`,children:`Signed in directly`}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,a.name||a.instanceFqdn]})]}),(0,K.jsxs)(V,{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,K.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-primary/10 text-primary shrink-0 dark:bg-violet-400/15 dark:text-violet-300`,children:(0,K.jsx)(qr,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-lg font-medium text-foreground`,children:`Enter cluster`}),(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Open the studio — apps, databases, APIs, logs, and config.`})]}),(0,K.jsx)(Rn,{className:`size-5 text-muted-foreground transition-transform group-hover:translate-x-1`})]}),(0,K.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-4 text-sm`,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>void m(),className:`text-muted-foreground hover:text-destructive transition-colors`,children:`Direct sign out`})})]}):(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-sm font-medium text-foreground mb-3`,children:`Connect to this cluster`}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3.5`,children:(0,K.jsx)(dg,{icon:Tr,title:`Direct sign-in`,description:`Sign in with this instance's Harper username and password.`,children:(0,K.jsx)(F,{className:`w-full`,variant:`outline`,onClick:f,children:`Direct sign-in`})})})]}):(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`This cluster has no instances yet. Register one from the`,` `,(0,K.jsx)(V,{to:`${r}/instances`,className:`underline hover:text-foreground`,children:`Instances`}),` page.`]})]})}function sg({children:e}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sc,{}),(0,K.jsx)(Du,{children:(0,K.jsx)(`div`,{className:`max-w-3xl`,children:e})})]})}function cg(){return(0,K.jsx)(`div`,{className:`flex justify-center py-10 text-muted-foreground`,children:(0,K.jsx)(Ar,{className:`size-6 animate-spin`})})}function lg({status:e}){let t=e&&Vo.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,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full ${t}`,children:[(0,K.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e?e.charAt(0)+e.slice(1).toLowerCase():`Unknown`]})}function ug(){return(0,K.jsxs)(`span`,{title:`All instances running in safe mode — user apps/components are not loaded`,className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full text-yellow bg-yellow/10`,children:[(0,K.jsx)(Or,{className:`size-3`}),`Safe mode`]})}function dg({icon:e,title:t,description:n,pill:r,children:i}){return(0,K.jsxs)(`div`,{className:`relative rounded-xl p-4.5 bg-card border ${r===`last`?`border-2 border-green`:r===`recommended`?`border-2 border-primary dark:border-violet-400`:`border-border`}`,children:[r&&(0,K.jsx)(`span`,{className:`absolute -top-2.5 left-4 rounded-full bg-card`,children:(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full ${r===`last`?`text-green bg-green/15`:`text-primary bg-violet-50 dark:text-violet-300 dark:bg-grey-700`}`,children:[r===`last`&&(0,K.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),r===`last`?`Last used`:`Recommended`]})}),(0,K.jsx)(e,{className:`size-6 text-primary dark:text-violet-300 mb-2`}),(0,K.jsx)(`div`,{className:`text-[15px] font-medium text-foreground mb-1`,children:t}),(0,K.jsx)(`p`,{className:`text-[13px] text-muted-foreground leading-normal mb-4`,children:n}),i]})}function fg({children:e,className:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sc,{}),(0,K.jsx)(Du,{children:(0,K.jsx)(`div`,{className:t,children:e})})]})}var pg=new Set([`com`,`co`,`org`,`net`,`edu`,`gov`,`mil`,`me`,`biz`,`info`,`ac`,`or`,`ne`,`go`,`lg`,`asn`,`id`,`nom`,`sch`,`ltd`,`plc`]);function mg(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&&pg.has(r)?3:2;return t.length<=i?`@`:t.slice(0,-i).join(`.`)}function hg({cluster:{fqdn:e},domain:{domain:t,id:n}}){let r=mg(t),[i,a,o]=Cu(r,e||``,n);return(0,K.jsxs)(`div`,{className:`grid gap-4 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap`,children:`This domain has been verified! Now to associate it with this cluster, add the following to your DNS registrar:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordName`,value:r,onClick:i}),(0,K.jsx)(F,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:i,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordTarget`,value:e,onClick:a}),(0,K.jsx)(F,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:a,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`domainId`,value:n,onClick:o}),(0,K.jsx)(F,{type:`button`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:o,children:(0,K.jsx)(sr,{className:`w-3 h-3`})})]})}),(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap italic text-sm`,children:`Select this domain using the checkbox to the left, then click "Bind" in the top right to finish associating it with this cluster.`})]})}function gg({certificate:e,domain:t,cluster:n}){let r=mg(t.domain),[i,a,o]=Cu(r,n.fqdn||``,t.id),s=(0,G.useMemo)(()=>e.issueDate&&!e.inProgress?{width:`100%`,color:`bg-green/80`,pulse:!1,text:`Certificate Issued`}:e.inProgress?{width:`100%`,color:`bg-yellow/80`,pulse:!0,text:`Generating Certificate...`}:{width:`100%`,color:`bg-gray-600`,pulse:!1,text:`Pending Certificate Generation...`},[e]);return(0,K.jsxs)(`div`,{className:`w-full max-w-2xl border border-border/50 rounded-md p-4 bg-gray-900/20`,children:[(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsx)(`div`,{className:`w-full h-1.5 rounded-full overflow-clip flex shadow-sm bg-gray-800`,children:(0,K.jsx)(`div`,{style:{width:s.width},className:`grow transition-[width] duration-1000 ease-in-out motion-reduce:transition-none ${s.color} ${s.pulse?`animate-pulse`:``}`})}),(0,K.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-light mt-1 italic`,children:s.text})]}),(0,K.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] text-sm`,children:[(0,K.jsx)(`div`,{className:`col-span-1 text-xs text-muted-foreground`,children:`CNAME:`}),(0,K.jsxs)(`div`,{className:`col-span-1 flex gap-2 items-center flex-wrap`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,K.jsx)(`span`,{className:`truncate max-w-[150px]`,title:r,children:r}),(0,K.jsx)(F,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:i,title:`Copy Name`,children:(0,K.jsx)(sr,{className:`w-3 h-3`})})]}),(0,K.jsx)(_g,{}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,K.jsx)(`span`,{className:`truncate max-w-[200px]`,title:n.fqdn||``,children:n.fqdn}),(0,K.jsx)(F,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:a,title:`Copy Target`,children:(0,K.jsx)(sr,{className:`w-3 h-3`})})]})]}),(0,K.jsx)(`div`,{className:`col-span-1 text-[10px] text-muted-foreground`,children:`Domain ID:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-[10px] text-muted-foreground italic`,children:[(0,K.jsx)(`span`,{className:`truncate max-w-[200px]`,children:t.id}),(0,K.jsx)(F,{type:`button`,variant:`ghost`,size:`sm`,className:`h-3 w-3 p-0`,onClick:o,title:`Copy ID`,children:(0,K.jsx)(sr,{className:`w-2.5 h-2.5`})})]})})]})]})}function _g(){return(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`w-3 h-3 text-muted-foreground`,children:[(0,K.jsx)(`path`,{d:`M5 12h14`}),(0,K.jsx)(`path`,{d:`m12 5 7 7-7 7`})]})}function vg(e){let{enabled:t,entityId:n,databaseName:r,tableName:i,searchAttribute:a,sort:o,pageIndex:s,pageSize:c,onlyIfCached:l,getAttributes:u}=e;return z({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:()=>yg(e)})}async function yg({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 bg(e){return z({queryKey:[e,`ChallengeCertificate`],queryFn:async()=>{if(!e)return[];let{data:t}=await yg({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:is(5e3),retry:as()})}function xg(e){return H(bg(e))}function Sg({domain:{challengeToken:e,challengeTxtRecord:t,domain:n,id:r},cluster:{fqdn:i}}){let a=mg(n),[o,s,c,l,u]=Cu(t,e,a,i||``,r);return(0,K.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap`,children:`Prove that you own this domain by adding the following to your DNS registrar:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TXT`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`challengeName`,value:t,onClick:o}),(0,K.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:o,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Content:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`challengeToken`,value:e,onClick:s}),(0,K.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:s,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap mt-4`,children:`While you're at it, you should also add the CNAME record to point to this cluster:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordName`,value:a,onClick:c}),(0,K.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:c,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordTarget`,value:i,onClick:l}),(0,K.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:l,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`domainId`,value:r,onClick:u}),(0,K.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:u,children:(0,K.jsx)(sr,{className:`w-3 h-3`})})]})}),(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap mt-2`,children:`Then after your DNS TTL elapses, click the "Validate" button above.`})]})}async function Cg({clusterId:e,domainIds:t,generateDomainCerts:n}){let{data:r}=await N.put(`/Cluster/${e}`,{domainIds:t,generateDomainCerts:n},{timeout:0});return r}function wg(){return R({mutationFn:e=>Cg(e)})}j.object({domainId:j.string()});async function Tg(e){let{data:t}=await N.delete(`/Domain/${e.domainId}`);return t}function Eg(){return R({mutationFn:e=>Tg(e)})}function Dg(e){return[...new Set(e)]}var Og=qp();function kg(e,t,n){let{data:r}=xg(e.id),i=(0,G.useMemo)(()=>!!r?.some(e=>!e.issueDate||e.inProgress),[r]),{mutate:a,isPending:o}=wg(),{mutate:s,isPending:c}=Eg(),l=o||c,u=(0,G.useCallback)((t,n)=>{if(!Yo(e.status)){U.error(`Cluster is currently `+e.status,{description:`To bind a domain, it must be running.`});return}a({clusterId:e.id,domainIds:Dg((e.domainIds?.slice()||[]).concat([t])),generateDomainCerts:n},{onSuccess:()=>{wi.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),U.success(`Domain bound!`+(n?` Certificates are being generated in the background now.`:``))}})},[a,e]),d=(0,G.useCallback)(t=>{s({domainId:t},{onSuccess:()=>{wi.invalidateQueries({queryKey:[e.organizationId,`domains`],refetchType:`active`}),U.success(`Domain removed!`)}})},[s]),f=(0,G.useCallback)(t=>{a({clusterId:e.id,domainIds:(e.domainIds?.slice()||[]).filter(e=>e!==t),generateDomainCerts:!1},{onSuccess:()=>{wi.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),U.success(`Domain unbound!`)}})},[s]);return(0,G.useMemo)(()=>[Og.display({id:`select`,header:`Bind`,size:50,cell:r=>{let a=r.row.original;return a.status===`ACTIVE`&&!a.clusterId&&!cu(e)?(0,K.jsx)(`label`,{className:`p-10 -m-10`,children:(0,K.jsx)(`input`,{type:`checkbox`,checked:t.includes(a.id),onChange:()=>n(a.id),disabled:l||i})}):null}}),Og.display({header:`Domains`,id:`domain`,enableSorting:!1,size:150,cell:e=>{let t=e.row.original;return(0,K.jsxs)(Va,{children:[(0,K.jsx)(Ha,{asChild:!0,children:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{children:t.domain}),(0,K.jsx)(F,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l||!!t.clusterId,onClick:()=>d(t.id),children:`Remove Domain`})]})}),(0,K.jsx)(Ua,{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!`})]})}}),Og.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,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{children:`Bound to this cluster`}),i&&(!i.issueDate||i.inProgress)&&(0,K.jsx)(`div`,{className:`py-2`,children:(0,K.jsx)(gg,{certificate:i,domain:n,cluster:e})}),(0,K.jsx)(F,{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,K.jsx)(Sg,{domain:n,cluster:e}):cu(e)?`Cannot be associated with this self-managed cluster.`:n.status===`ACTIVE`&&!n.clusterId?(0,K.jsx)(hg,{cluster:e,domain:n}):n.status}})],[e,u,l,r,i,t,n])}var Ag=j.object({domain:j.string(),organizationId:j.string()});async function jg(e){let{data:t}=await N.post(`/Domain/`,e);return t}function Mg(){return R({mutationFn:e=>jg(e)})}async function Ng(e){let{data:t}=await N.post(`/Domain/${e}/validate`);return t}async function Pg(e){let{data:t}=await N.get(`/Domain/?organizationId=${e}`);return t}function Fg(e){return z({queryKey:[e,`domains`],queryFn:()=>Pg(e)})}function Ig(){let{organizationId:e,clusterId:t}=B({strict:!1}),{data:n}=de(cs(t,!0)),{update:r}=Jl(e),{data:i,refetch:a,isFetching:o,isRefetching:s}=H(Fg(e)),c=(0,G.useMemo)(()=>i?.filter(e=>e.status===`PENDING_VALIDATION`)||[],[i]),[l]=(0,G.useState)({attribute:`domain`,descending:!1}),u=(0,G.useMemo)(()=>[{desc:l.descending,id:l.attribute}],[l]),d=$p(a),[f,p]=(0,G.useState)([]),m=(0,G.useCallback)(e=>{p(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),{mutate:g,isPending:_}=wg(),v=(0,G.useCallback)(()=>{if(!Yo(n.status)){U.error(`Cluster is currently `+n.status,{description:`To bind a domain, it must be running.`});return}g({clusterId:n.id,domainIds:Dg((n.domainIds?.slice()||[]).concat(f)),generateDomainCerts:!0},{onSuccess:()=>{wi.invalidateQueries({queryKey:[n.organizationId],refetchType:`active`}),U.success(`Domain(s) bound! Certificates are being generated in the background now.`),p([])}})},[n,f,g]),{mutateAsync:y,isPending:b}=Mg(),x=Pt({resolver:Ke(Ag),defaultValues:{domain:``,organizationId:e}}),S=(0,G.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(),U.success(`${h(t.length,`Domain`,`Domains`)} added! Please add the txt record above to your domain registrar.`)}},[y,x,a]),C=(0,G.useCallback)(async()=>{let e=`Validating ${h(c.length,`domain`,`domains`)}...`,t=`validatingDomains`,n=0,r=0;for(let i of c)try{U.loading(e,{description:`${n++} of ${c.length} checked`,id:t}),await Ng(i.id)}catch{r+=1}r>0?U.error(`Validation failed!`,{description:`Please make sure the TXT record has been put in place. You may need to wait a bit for the DNS change to propagate.`,id:t}):(await a(),U.success(`Validation succeeded!`,{description:`Please take a look at the next steps for newly verified domains.`,id:t}))},[c]),w=kg(n,f,m),T=x.watch(`domain`),E=(0,G.useMemo)(()=>typeof T==`string`&&T.trim().split(`.`).length===2,[T]),D=(0,G.useCallback)(()=>{typeof T==`string`&&x.setValue(`domain`,`${T.trim()}, www.${T.trim()}`)},[T,x]);return(0,K.jsx)(Jp,{data:i||[],isFetching:o||s,columns:w,sortingState:u,children:(0,K.jsxs)(`div`,{className:`w-full flex flex-col md:flex-row items-center md:justify-between md:space-x-2 space-y-2 md:space-y-0`,children:[r&&(0,K.jsx)(Io,{...x,children:(0,K.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,K.jsx)(Y,{control:x.control,name:`domain`,render:({field:e})=>(0,K.jsxs)(X,{className:`flex-1`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`New Domain Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,enterKeyHint:`done`,autoComplete:`off`,...e})}),E&&(0,K.jsxs)(`div`,{className:`mt-1 flex gap-4`,children:[`Adding an apex domain?`,(0,K.jsx)(F,{variant:`positiveOutline`,type:`button`,onClick:D,children:`Add www as well`})]}),(0,K.jsx)(Q,{children:(0,K.jsx)(`span`,{className:`text-muted-foreground italic`,children:`Type in a domain like example.com or your.example.com, and you'll be guided through validating and binding your cluster to it.`})})]})}),(0,K.jsxs)(`div`,{className:`flex-0 self-start flex gap-1 md:pt-6.5`,children:[(0,K.jsxs)(F,{type:`submit`,variant:`submit`,disabled:b,children:[(0,K.jsx)(Gr,{}),` Add`]}),c.length>0&&(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:C,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,K.jsx)(kr,{}),` `,(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`V`}),`alidate`]})]}),(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:d,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,K.jsx)(Kr,{}),` `,(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]})]})]})}),f.length>0&&(0,K.jsx)(`div`,{className:`flex-0 self-start md:pt-6.5`,children:(0,K.jsxs)(F,{variant:`submit`,onClick:v,disabled:_,children:[(0,K.jsx)(Xr,{}),` Bind `,h(f.length,`Domain`,`Domains`)]})})]})})}function Lg(){return(0,K.jsx)(fg,{className:`flex flex-col justify-start max-w-4xl`,children:(0,K.jsx)(Ig,{})})}var Rg=b({username:ds,role:M().nonempty({error:`Please select a role.`}),password:us.min(8,{error:`Password must be at least 8 characters long.`}),confirmPassword:M()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});async function zg(e){await N.patch(`/ResetPasswordUpdater/${e}`)}async function Bg(e){let{instanceClient:t,...n}=e,{data:r}=await t.post(`/`,{operation:`add_user`,...n});return r}function Vg(){return R({mutationFn:Bg})}async function Hg({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 Ug(){return R({mutationFn:Hg})}async function Wg({username:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_user`,username:e});return n}function Gg(){return R({mutationFn:Wg})}async function Kg({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 Wo({username:t,password:i,instanceClient:o,entityId:e});return a.instanceClient&&(o=a.instanceClient),n===`HDB_ADMIN`?await Hg({username:n,password:r,instanceClient:o}):(await Bg({username:n,password:r,role:`super_user`,active:!0,instanceClient:o}),await Wo({username:n,password:r,instanceClient:o,entityId:e}),await Wg({username:g,instanceClient:o})),await zg(e),a}catch(t){throw await d({entityId:e,instanceClient:o}),t}}function qg(){return R({mutationFn:Kg})}function Jg(){let{user:e}=wn(),{clusterId:t}=B({strict:!1}),{data:n}=H(cs(t,!0)),r=L(),i=oe(),a=(0,G.useMemo)(()=>c(n),[n]),o=Ga({operationsUrl:a}),{redirect:s}=le({strict:!1}),l=se(),d=Pt({resolver:Ke(Rg),defaultValues:{confirmPassword:``,password:``,role:`super_user`,username:e?.email??``}}),{setFocus:f,control:p,handleSubmit:m}=d;(0,G.useEffect)(()=>{f(`password`)},[f]);let h=n?.instances?.find(e=>e.tempPassword)?.tempPassword,_=es(n),{mutate:v,isPending:y}=qg(),b=(0,G.useCallback)(async e=>{if(!a){U.error(`Cluster is not yet fully loaded, please wait a moment before trying to sign in.`);return}if(!_){U.error(`Some instances are still starting up. You can create your admin user once they are all running.`);return}v({instanceClient:o,clusterId:t,newPassword:e.password,tempPassword:h,initialUsername:g,desiredUsername:e.username},{onSuccess:async({message:e,user:a})=>{U.success(e),u.setUserForEntity(n,a),await ss(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,K.jsx)(re,{to:`../sign-in`,replace:!0}):n&&!_?(0,K.jsx)(re,{to:`../starting-up`,replace:!0}):(0,K.jsxs)(K.Fragment,{children:[(0,K.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,K.jsx)(Fo,{})}),(0,K.jsx)(`div`,{className:`items-center justify-center flex mt-32 py-4 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsxs)(`div`,{className:`text-foreground w-xs`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light`,children:`Create Admin User`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:`You are ready to create your first user in your new cluster. These credentials belong to you alone, and you can create more users and roles once you create this first one.`}),(0,K.jsx)(Io,{...d,children:(0,K.jsxs)(`form`,{id:`cluster-create-admin-form`,name:`cluster-create-admin-form`,onSubmit:m(b),className:`my-4`,children:[(0,K.jsx)(Y,{control:p,name:`username`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Username`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{autoComplete:`username`,type:`text`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:p,name:`password`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,autoComplete:`new-password`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:p,name:`confirmPassword`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Confirm Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,autoComplete:`new-password`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(F,{disabled:y,type:`submit`,variant:`submit`,className:`w-full my-2`,children:`Create Admin User`})]})}),(0,K.jsxs)(`p`,{className:`text-muted-foreground flex gap-2 align-middle`,children:[(0,K.jsx)(Fn,{size:36,className:`flex-none`}),(0,K.jsx)(`span`,{children:`These credentials will be used to sign into your cluster directly, providing you a secure connection from your browser to your cluster.`})]})]})})]})}function Yg({columns:e,data:t,renderRowWrapper:n}){let r=Me({features:Kp,data:t,columns:e});return(0,K.jsx)(`div`,{className:`bg-card dark:bg-black-dark rounded-md`,children:(0,K.jsxs)(zp,{children:[(0,K.jsx)(Bp,{children:r.getHeaderGroups().map(e=>(0,K.jsx)(Hp,{className:`border-none`,children:e.headers.map(e=>(0,K.jsx)(Up,{className:`p-4`,style:{width:`${e.getSize()}%`},children:e.isPlaceholder?null:De(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,K.jsx)(Vp,{className:`bg-background dark:bg-black`,children:r.getRowModel().rows?.length?r.getRowModel().rows.map(e=>{let t=(0,K.jsx)(Hp,{"data-state":e.getIsSelected()&&`selected`,className:`hover:bg-muted/10 data-[state=selected]:bg-muted`,children:e.getVisibleCells().map(e=>(0,K.jsx)(Gp,{className:`p-4`,style:{width:`${e.column.getSize()}%`},children:De(e.column.columnDef.cell,e.getContext())},e.id))});return(0,K.jsx)(G.Fragment,{children:n?n(e.original,t):t},e.id)}):(0,K.jsx)(Hp,{children:(0,K.jsx)(Gp,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function Xg(){return(0,K.jsx)(`div`,{className:`flex-col items-center justify-center px-16 space-y-3 text-center pt-30`,children:(0,K.jsx)(`p`,{children:`No instances found.`})})}async function Zg({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 Qg({instanceId:e,action:t,safeMode:n}){let r=n===void 0?{}:{safeMode:n},{data:i}=await N.post(`/HDBInstance/${e}/container/${t}`,r);return i}function $g(){return R({mutationFn:Qg})}var e_={stop:`Stopping`,start:`Starting`,restart:`Restarting`};function t_(e){let{clusterId:t}=B({strict:!1}),{mutateAsync:n,isPending:r}=$g(),i=oe();return{run:(0,G.useCallback)(async(r,a)=>{let o=a?.label??e_[r],s=e.name??e.id,c=U.loading(o,{description:`${o} ${s}. Status will update shortly.`,duration:3e4,action:{label:`Dismiss`,onClick:()=>U.dismiss()}});try{await n({instanceId:e.id,action:r,safeMode:a?.safeMode}),t&&i.invalidateQueries({queryKey:[t]}),i.invalidateQueries({queryKey:[e.id]}),U.dismiss(c),U.success(`Request accepted`,{description:`${s} is ${o.toLowerCase()}. The status will update automatically.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}catch{U.dismiss(c)}},[t,e.id,e.name,n,i]),isPending:r}}function n_({entityId:e,instanceClient:t},n){return z({queryKey:[`get_status`,e],staleTime:9e3,refetchInterval:is(1e4),retry:as(),retryDelay:1e4,throwOnError:!1,enabled:n,queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`get_status`});return e}})}function r_(e,t){return e?.systemStatus?.find(e=>e.id===t)?.status}async function i_({instanceClient:e,id:t,status:n}){let{data:r}=await e.post(`/`,{operation:`set_status`,id:t,status:n});return r}function a_(){return R({mutationFn:i_,onSuccess:(e,t)=>wi.invalidateQueries({queryKey:[`get_status`,t.entityId]})})}var o_=[`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`];function s_(e,t,n){let{user:r}=Dn(e.id),i=(0,G.useMemo)(()=>p(e),[e]),a=Ga({operationsUrl:i}),{update:o}=$l(),s=u.checkForFabricConnect(e.id),c=q({operationsUrl:i,instanceId:e.id,forceFabricConnect:!0}),{data:l}=H(n_(c,n&&o&&!Jo(e.status))),d=r_(l,`availability`)||`Unknown`,f=d===`Available`,m=d===`Unavailable`,{mutate:h,isPending:g}=a_(),{run:_,isPending:v}=t_(e),[y,b]=(0,G.useState)(null),x=e.instanceFqdn,S=gp({secure:e.operationsApiSecure?`true`:`false`,port:e.operationsApiPort,fqdn:e.instanceFqdn}),[C,w]=Cu(x??``,S),T=(0,G.useCallback)(async()=>{await Zg({instance:e,instanceClient:a})},[e,a]),E=!!e.status&&o_.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,K.jsx)($r,{className:`text-green`}),label:`Direct Connect`},O&&D&&{key:`direct-sign-out`,onClick:T,variant:`destructive`,icon:(0,K.jsx)(Nr,{}),label:`Direct Sign Out`},O&&!D&&o&&!t&&{key:`fabric-connect`,to:`../instance/${e.id}/`,icon:(0,K.jsx)($r,{className:`text-green`}),label:`Fabric Connect`},O&&!D&&{key:`direct-sign-in`,to:`../instance/${e.id}/sign-in`,icon:(0,K.jsx)(jr,{}),label:`Direct Sign In`},O&&k&&{type:`separator`,key:`copy-sep`},k&&{key:`copy-fqdn`,onClick:C,icon:(0,K.jsx)(nr,{}),label:`Copy Instance FQDN`},k&&{key:`copy-api`,onClick:w,icon:(0,K.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,K.jsx)(ni,{}),label:`Bring out of rotation`},A&&m&&{key:`into-rotation`,disabled:g,onClick:()=>h({...c,id:`availability`,status:`Available`}),icon:(0,K.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,K.jsx)(Wr,{}),label:`Start`},M&&ee&&{key:`container-start-safe`,disabled:v,onClick:()=>b(`start`),icon:(0,K.jsx)(Or,{}),label:`Start in safe mode`},M&&j&&{key:`container-restart`,disabled:v,onClick:()=>void _(`restart`,{safeMode:!1}),icon:(0,K.jsx)(Yr,{}),label:`Restart`},M&&j&&{key:`container-restart-safe`,disabled:v,onClick:()=>b(`restart`),icon:(0,K.jsx)(Or,{}),label:`Restart in safe mode`},M&&j&&{key:`container-stop`,variant:`destructive`,disabled:v,onClick:()=>void _(`stop`),icon:(0,K.jsx)(ai,{}),label:`Stop`}].filter($a),P=(0,K.jsx)(mu,{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 c_({instance:e,isSelfManaged:t}){let[n,r]=(0,G.useState)(!1),{items:i,dialog:a}=s_(e,t,n);return i.length?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Ti,{open:n,onOpenChange:r,children:[(0,K.jsx)(Ei,{asChild:!0,children:(0,K.jsx)(F,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Instance options`,children:(0,K.jsx)(ur,{})})}),(0,K.jsx)(Di,{align:`end`,className:`min-w-48`,children:Mc(i,`dropdown`)})]}),a]}):null}function l_({isSelfManaged:e,instance:t}){let{user:n,isLoading:r}=Dn(t.id),i=Ga({operationsUrl:(0,G.useMemo)(()=>p(t),[t])}),{update:a}=$l(),o=u.checkForFabricConnect(t.id),s=(0,G.useCallback)(async()=>{await Zg({instance:t,instanceClient:i})},[t,i]);return Jo(t.status)?(0,K.jsx)(`span`,{className:`text-muted-foreground text-sm`,children:`—`}):r||!t.status||![`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`].includes(t.status)?(0,K.jsx)(Ar,{className:`animate-spin`,color:`gray`}):!n||o?(0,K.jsxs)(`span`,{className:`flex gap-4`,children:[a&&!e&&(0,K.jsx)(V,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Connect to ${t.name} instance`,title:`Connect to ${t.name} instance`,children:(0,K.jsx)(F,{variant:`positiveOutline`,children:`Fabric Connect`})}),(0,K.jsx)(V,{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,K.jsx)(F,{variant:a?`defaultOutline`:`positiveOutline`,children:`Direct Sign In`})})]}):(0,K.jsxs)(`span`,{className:`flex gap-4`,children:[(0,K.jsx)(V,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Go to ${t.name} instance`,title:`Go to ${t.name} instance`,children:(0,K.jsx)(F,{variant:`positiveOutline`,children:`Direct Connect`})}),(0,K.jsx)(F,{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 u_({instance:e,isSelfManaged:t,children:n}){let[r,i]=(0,G.useState)(!1),{items:a,dialog:o}=s_(e,t,r);return a.length?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(wc,{onOpenChange:i,children:[(0,K.jsx)(Tc,{asChild:!0,children:n}),(0,K.jsx)(Ec,{className:`min-w-48`,children:Mc(a,`context`)})]}),o]}):(0,K.jsx)(K.Fragment,{children:n})}function d_({instance:e,index:t}){let{update:n}=$l(),r=q({operationsUrl:(0,G.useMemo)(()=>p(e),[e]),instanceId:e.id,forceFabricConnect:!0}),{mutate:i,isPending:a}=a_(),[o,s]=(0,G.useState)(!1);(0,G.useEffect)(()=>{let e=setTimeout(()=>s(!0),t*500);return()=>clearTimeout(e)},[t]);let c=Jo(e.status),{data:l,isLoading:u,isFetching:d}=H(n_(r,o&&n&&!c)),f=r_(l,`availability`)||`Unknown`,m=f===`Available`,h=f===`Unavailable`;return n?c?(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(Va,{children:[(0,K.jsx)(Ha,{asChild:!0,children:(0,K.jsx)(`span`,{className:`inline-block size-4 rounded-full bg-muted-foreground/40`,"aria-label":`Not running`})}),(0,K.jsx)(Ua,{children:`Not running`})]})}):(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(Va,{children:[(0,K.jsx)(Ha,{asChild:!0,children:(0,K.jsx)(`div`,{className:`flex items-center`,children:u||!o||d&&!l?(0,K.jsx)(Ar,{className:`animate-spin size-5 text-muted-foreground`}):(0,K.jsx)(Yi,{variant:m?`success`:h?`destructive`:`default`,className:`size-4 rounded-full p-0`,children:(0,K.jsx)(`span`,{className:`sr-only`,children:m?`Online`:`Offline`})})})}),(0,K.jsxs)(Ua,{children:[d&&l?`Refreshing... `:``,f]})]}),n&&(0,K.jsxs)(`div`,{className:`flex gap-1`,children:[m&&(0,K.jsxs)(Va,{children:[(0,K.jsx)(Ha,{asChild:!0,children:(0,K.jsx)(F,{type:`button`,variant:`destructiveGhost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Unavailable`}),disabled:a,children:a?(0,K.jsx)(Ar,{className:`animate-spin size-4`}):(0,K.jsx)(ni,{className:`size-4`})})}),(0,K.jsx)(Ua,{children:`Bring out of rotation`})]}),h&&(0,K.jsxs)(Va,{children:[(0,K.jsx)(Ha,{asChild:!0,children:(0,K.jsx)(F,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Available`}),disabled:a,children:a?(0,K.jsx)(Ar,{className:`animate-spin size-4`}):(0,K.jsx)(ti,{className:`size-4`})})}),(0,K.jsx)(Ua,{children:`Bring back into rotation`})]})]})]}):null}function f_(){let{clusterId:e}=B({strict:!1}),{data:t,isLoading:n}=H(cs(e,!0)),r=cu(t),i=(0,G.useMemo)(()=>[{id:`instanceActions`,size:1,minSize:1,cell:e=>(0,K.jsx)(`div`,{className:`flex justify-end gap-2 items-center`,children:(0,K.jsx)(l_,{isSelfManaged:r,instance:e.row.original})})},r&&{accessorKey:`instanceFqdn`,size:90,header:`URL`,cell:e=>gp({secure:e.row.original.operationsApiSecure?`true`:`false`,port:e.row.original.operationsApiPort,fqdn:e.row.original.instanceFqdn})},!r&&{accessorKey:`name`,size:90,header:`Name`},!r&&{accessorKey:`status`,header:`Status`,size:1,minSize:1,cell:e=>{let t=e.getValue();return(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(d_,{instance:e.row.original,index:e.row.index}),t?(0,K.jsx)(Yi,{variant:qo(t),children:No(t)}):null,e.row.original.safeMode&&!Jo(e.row.original.status)?(0,K.jsxs)(Yi,{variant:`warning`,title:`Running in safe mode — user apps/components are not loaded`,children:[(0,K.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,K.jsxs)(K.Fragment,{children:[e.row.original.cpuCores,` / `,e.row.original.threads]})},!r&&{accessorKey:`memoryMb`,size:1,minSize:1,header:`Memory`,cell:e=>`${e.getValue()/1024} GB`},{id:`instanceMenu`,size:1,minSize:1,cell:e=>(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsx)(c_,{isSelfManaged:r,instance:e.row.original})})}].filter($a),[r]),a=(0,G.useMemo)(()=>t?.instances?t.instances.filter(e=>e.status&&!Ho.includes(e.status)).sort(Bu):[],[t]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sc,{}),(0,K.jsx)(Du,{children:(0,K.jsx)(On,{className:`p-0 min-h-96`,children:(0,K.jsx)(Mn,{className:`p-0 min-h-96`,children:n?(0,K.jsx)(Af,{}):a.length?(0,K.jsx)(Yg,{data:a,columns:i,renderRowWrapper:(e,t)=>(0,K.jsx)(u_,{instance:e,isSelfManaged:r,children:t})}):(0,K.jsx)(Xg,{})})})})]})}function p_(){let{clusterId:e}=B({strict:!1}),{immediate:t}=le({strict:!1}),n=t===!0||t===`true`,{data:r,isLoading:i}=H(cs(e,2e3)),a=r?.status,o=(0,G.useMemo)(()=>a&&Vo.includes(a),[a]);return i||!r?(0,K.jsx)(fg,{className:`flex justify-center`,children:(0,K.jsx)(Af,{})}):o?(0,K.jsx)(fg,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`All done!`}),(0,K.jsx)(pu,{cluster:r,forceProgressBarVisible:!0}),(0,K.jsx)(`p`,{children:`Your cluster finished updating, and is ready for interaction.`}),(0,K.jsx)(`div`,{className:`text-center`,children:(0,K.jsx)(lu,{cluster:r})})]})}):(0,K.jsx)(fg,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,K.jsx)(pu,{cluster:r,forceProgressBarVisible:!0}),(0,K.jsxs)(`p`,{children:[n?`Your cluster is applying the latest changes immediately, without waiting to take instances out of rotation.`:`Your cluster is updating with the latest changes. This includes waiting several minutes to let traffic drain safely.`,` `,(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[`We will let you know when we are ready for you to connect! In the meantime, join us on`,` `,(0,K.jsx)(`a`,{href:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,children:`Discord`}),`! Get real-time help from our engineers, see feature drops early, and connect with others building on Fabric.`]})]})]})})}function m_({children:e,className:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sc,{}),(0,K.jsx)(`div`,{className:_(`mt-32 px-4 py-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] flex justify-center`,t),children:e})]})}function h_(){let e=se(),{clusterId:t}=B({strict:!1}),{data:n,isLoading:r}=H(cs(t,2e3)),i=n?.status,a=(0,G.useMemo)(()=>i&&Vo.includes(i)&&es(n),[i,n]),o=Xo(i),[,s]=xn(vn.SavedClusterState,null),c=(0,G.useCallback)(()=>{s(n),e.navigate({to:`/${n.organizationId}/new-cluster`})},[n,e,s]);return r||!n?(0,K.jsx)(m_,{className:`flex justify-center`,children:(0,K.jsx)(Af,{})}):o?(0,K.jsx)(m_,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4 items-center`,children:[(0,K.jsx)(rr,{className:`w-24 h-24`}),(0,K.jsxs)(`span`,{children:[`Your cluster failed to successfully start. This is usually caused by temporary communication problems. Would you like to try again? We also get notified about these failures. `,(0,K.jsx)(ys,{}),` if you want more help.`]}),(0,K.jsx)(F,{type:`button`,variant:`positiveOutline`,onClick:c,children:`Try Again`})]})}):a?(0,K.jsx)(m_,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`It's ready!`}),(0,K.jsx)(pu,{cluster:n,forceProgressBarVisible:!0}),(0,K.jsxs)(`p`,{children:[`Let's set up your secure, browser-to-cluster connection now.`,` `,(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Did you know during this step, you connect straight to your cluster, providing a private secure connection? That's `,(0,K.jsx)(`em`,{children:`Direct Connect`}),`! Once you create your user, you will have the option to`,` `,(0,K.jsx)(`em`,{children:`Fabric Connect`}),` from your Fabric account without having to sign in again.`]})]}),(0,K.jsx)(`div`,{className:`text-center`,children:(0,K.jsx)(lu,{cluster:n})})]})}):(0,K.jsx)(m_,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,K.jsx)(pu,{cluster:n,forceProgressBarVisible:!0}),(0,K.jsxs)(`p`,{children:[`Your cluster is spinning up with the latest changes, including your own DNS records and private connections. Please wait while we get everything going.`,` `,(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[`We will let you know when we are ready for you to connect! In the meantime, join us on`,` `,(0,K.jsx)(`a`,{href:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,children:`Discord`}),`! Get real-time help from our engineers, see feature drops early, and connect with others building on Fabric.`]})]})]})})}function g_(){let{clusterId:e}=B({strict:!1}),{data:t,isLoading:n}=Qh(e);if(n)return(0,K.jsxs)(fg,{className:`max-w-4xl pb-20`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:`Usage`}),(0,K.jsx)(`div`,{className:`flex justify-center py-16 text-muted-foreground`,children:(0,K.jsx)(Ar,{className:`size-6 animate-spin`})})]});let r=t&&!t.selfManaged?S_(t.regions):null;return(0,K.jsxs)(fg,{className:`max-w-4xl pb-20`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:`Usage`}),t?t.selfManaged?(0,K.jsx)(T_,{children:`Usage isn't tracked for self-hosted clusters — they run under their own license.`}):t.regions.length===0?(0,K.jsx)(T_,{children:`No usage has been recorded for the current cycle yet.`}):(0,K.jsxs)(`div`,{className:`mt-5 space-y-3`,children:[t.regions.map(e=>(0,K.jsx)(__,{region:e,showPlanInfo:r==null},e.region??e.regionIds.join())),r&&(0,K.jsx)(v_,{header:(0,K.jsx)(y_,{title:`Plan limits & resources`}),aside:r.planId??void 0,children:(0,K.jsx)(b_,{rateLimits:r.rateLimits,resourcesPerInstance:r.resourcesPerInstance})})]}):(0,K.jsx)(E_,{})]})}function __({region:e,showPlanInfo:t}){let n=Jh.map(t=>Yh(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 ${x_(e.expiresAt)}`:null].filter(Boolean).join(` · `);return(0,K.jsxs)(v_,{defaultOpen:e.status!==`lapsed`,aside:e.regionIds.length>0?e.regionIds.join(`, `):void 0,header:(0,K.jsxs)(y_,{title:e.region??`Region`,meta:r,children:[e.status===`exhausted`&&(0,K.jsx)(`span`,{className:`rounded-full bg-yellow/10 px-2 py-0.5 text-[11px] text-yellow`,children:`Cycle exhausted`}),e.status===`lapsed`&&(0,K.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground`,children:`No active license`})]}),children:[(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-x-10 gap-y-4 sm:grid-cols-2`,children:n.map(e=>(0,K.jsx)(Xh,{...e},e.label))}),t&&(0,K.jsx)(b_,{rateLimits:e.rateLimits,resourcesPerInstance:e.resourcesPerInstance})]})}function v_({header:e,aside:t,defaultOpen:n=!0,children:r}){let[i,a]=(0,G.useState)(n);return(0,K.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-border`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),"aria-expanded":i,className:`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-accent/40`,children:[(0,K.jsx)(Jn,{className:`size-4 shrink-0 text-muted-foreground transition-transform ${i?`rotate-90`:``}`}),(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:e}),t&&(0,K.jsx)(`span`,{className:`shrink-0 self-start pt-0.5 font-mono text-[11px] text-muted-foreground/70`,children:t})]}),i&&(0,K.jsx)(`div`,{className:`border-t border-border px-4 py-4`,children:r})]})}function y_({title:e,meta:t,children:n}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e}),n]}),t&&(0,K.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t})]})}function b_({rateLimits:e,resourcesPerInstance:t}){let n=e,r=n?w_([[`Reads / minute`,n.readsPerMinute,np],[`Read bandwidth / minute`,n.readsPerMinuteBytes,tp],[`Writes / minute`,n.writesPerMinute,np],[`Write bandwidth / minute`,n.writesPerMinuteBytes,tp],[`Real-time deliveries / minute`,n.realTimeDeliveriesPerMinute,np],[`Real-time bandwidth / minute`,n.realTimeDeliveryBytesPerMinute,tp],[`TLS handshakes (cycle)`,n.tlsHandshakes,np]]):[],i=t,a=i?C_([[`Storage`,i.storageGb,e=>`${np(e)} GB`],[`Memory`,i.memoryMb,e=>tp(e*1e3*1e3)],[`vCPU`,i.cpuCores,e=>`${e} ${e===1?`core`:`cores`}`],[`Threads`,i.threads,e=>String(e)]]):[];return(0,K.jsxs)(K.Fragment,{children:[r.length>0&&(0,K.jsx)(D_,{title:`Rate limits`,subtitle:`Throughput ceilings — not part of the cycle allotment, and not metered.`,children:(0,K.jsx)(O_,{rows:r})}),a.length>0&&(0,K.jsx)(D_,{title:`Per-instance resources`,subtitle:`Provisioned capacity on each instance.`,children:(0,K.jsx)(O_,{rows:a})})]})}function x_(e){return new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))}function S_(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 C_(e){return e.filter(e=>typeof e[1]==`number`&&e[1]>0).map(([e,t,n])=>[e,n(t)])}function w_(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 T_({children:e}){return(0,K.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:e})}function E_(){return(0,K.jsx)(`div`,{role:`alert`,className:`mt-5 rounded-xl border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive`,children:`Couldn't load usage data — refresh to try again.`})}function D_({title:e,subtitle:t,children:n}){return(0,K.jsxs)(`div`,{className:`mt-6 first:mt-0`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:e}),(0,K.jsx)(`p`,{className:`mt-0.5 mb-3 text-xs text-muted-foreground`,children:t}),n]})}function O_({rows:e}){return(0,K.jsx)(`dl`,{className:`grid grid-cols-1 gap-x-10 gap-y-2 sm:grid-cols-2`,children:e.map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 border-b border-border/60 py-1.5 text-sm`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,K.jsx)(`dd`,{className:`text-foreground tabular-nums`,children:t})]},e))})}I({getParentRoute:()=>Hh,path:`instances`,head:()=>({meta:[{title:`Instances — Harper Fabric`}]}),component:f_}),I({getParentRoute:()=>Hh,path:`starting-up`,head:()=>({meta:[{title:`Starting Up — Harper Fabric`}]}),component:h_}),I({getParentRoute:()=>Hh,path:`scaling`,head:()=>({meta:[{title:`Scaling — Harper Fabric`}]}),component:p_}),I({getParentRoute:()=>Hh,path:`domains`,head:()=>({meta:[{title:`Domains — Harper Fabric`}]}),component:Lg}),I({getParentRoute:()=>Hh,path:`usage`,head:()=>({meta:[{title:`Usage — Harper Fabric`}]}),component:g_});function k_({location:e,params:t}){let n=u.checkForFabricConnect(t.clusterId);if(u.getConnectionById(t.clusterId).user&&!n){let t=e?.search?.redirect;throw ie({to:t?.startsWith(`/`)?t:`../`})}}function A_({location:e,params:t}){let n=u.checkForFabricConnect(t.instanceId);if(u.getConnectionById(t.instanceId).user&&!n){let t=e?.search?.redirect;throw ie({to:t?.startsWith(`/`)?t:`../`})}}I({getParentRoute:()=>Hh,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:vs,beforeLoad:k_}),I({getParentRoute:()=>Hh,path:`instance/$instanceId/sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:vs,beforeLoad:A_}),I({getParentRoute:()=>Hh,path:`finish-setup`,head:()=>({meta:[{title:`Create Admin User — Harper Fabric`}]}),component:Jg}),I({getParentRoute:()=>Hh,path:`/`,head:()=>({meta:[{title:`Cluster — Harper Fabric`}]}),component:ag});function j_(e){return I({getParentRoute:()=>e,path:`apis`,head:()=>({meta:[{title:`APIs — Harper Fabric`}]})}).lazy(()=>ze(()=>import(`./index.lazy-VmcKgiEy.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 M_(e,t){return[I({getParentRoute:()=>e,path:t===`cluster`?`apps`:`/`,head:()=>({meta:[{title:`Applications — Harper Fabric`}]}),component:ye(()=>ze(()=>import(`./applications-Dta6Y0Rg.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 N_({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_certificates`});return t}function P_(e){return z({queryKey:[e.entityId,`list_certificates`],queryFn:()=>N_(e)})}var F_=[{header:`Certificate Name`,accessorKey:`name`,enableSorting:!0},{header:`Issuer`,accessorKey:`details.issuer`,enableSorting:!0},qp().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 I_({className:e,...t}){return(0,K.jsx)(`textarea`,{"data-slot":`input`,className:P(`border-input file:text-foreground placeholder:text-muted-foreground selection:bg-purple
12
+ `)}}];function $p(e){return(0,G.useCallback)(async()=>{U.loading(`Refreshing...`,{id:`refreshing`});let t=Date.now();await e(),Date.now()-t<500&&await n(500),U.success(`Refreshed!`,{id:`refreshing`})},[e])}async function em(e){let{data:t}=await N.get(`/Invoice/${e}`);return t}function tm(e,t){return z({queryKey:[e,`invoices`],queryFn:()=>em(e),retry:!1,enabled:!!e,refetchInterval:t?1e4:void 0})}function nm(){let{organizationId:e}=B({strict:!1}),{data:t}=H(Qu(e)),{data:n,refetch:r,isLoading:i,isFetching:a,isRefetching:o}=H(tm(t?.type!==`ENTERPRISE`&&t?.id,!1)),s=$p(r);return t?.type===`ENTERPRISE`?(0,K.jsxs)(`span`,{children:[`You are part of an enterprise organization! We don’t currently show your invoices on this page. Want to explore your solution with Harper more? `,(0,K.jsx)(ys,{}),`, we would love to talk!`]}):i?(0,K.jsx)(Gi,{centered:!0}):!n||!n.length?(0,K.jsxs)(`span`,{children:[`Your invoices will be shown here once one is available! Want to explore your solution with Harper more?`,` `,(0,K.jsx)(ys,{overEmail:!0}),`, we would love to talk!`]}):(0,K.jsx)(Jp,{data:n,columns:Qp,children:(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:s,accessKey:`r`,disabled:a||o,children:[(0,K.jsx)(Kr,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]})})}function rm(e){let t=I({getParentRoute:()=>e,path:`billing`,head:()=>({meta:[{title:`Billing — Harper Fabric`}]}),component:Fp}),n=I({getParentRoute:()=>t,path:`/`,head:()=>({meta:[{title:`Payment Methods — Harper Fabric`}]}),component:Cf}),r=I({getParentRoute:()=>t,path:`invoices`,head:()=>({meta:[{title:`Invoices — Harper Fabric`}]}),component:nm}),i=I({getParentRoute:()=>t,path:`confirm`,head:()=>({meta:[{title:`Confirm Payment — Harper Fabric`}]}),component:Pp});return t.addChildren([n,r,i])}async function im(e){let{data:t}=await N.get(`/OrganizationRole/${e}`);return t}function am(e){return z({queryKey:[e,`roles`],queryFn:()=>im(e),retry:!1,refetchInterval:is(1e4)})}var om=qp(),sm=[{header:`Role Name`,accessorKey:`roleName`,enableSorting:!1},om.display({header:`ID`,id:`id`,enableSorting:!1,cell:e=>(0,K.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,title:e.row.original.id,children:e.row.original.id})}),om.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 cm(e){let{data:t}=await N.post(`/Role/`,e);return t}function lm(){return R({mutationFn:cm})}var um=b({name:M().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:C(),delete:C()});b({roles:b({create:C(),delete:C(),update:C(),view:C()}),clusters:b({create:C(),delete:C(),update:C(),view:C(),resources:A(b({id:M(),delete:C(),update:C(),view:C(),instances:b({create:C(),delete:C(),update:C(),view:C()})}))})});function dm(){let[e]=Ma(),t=ka();return e===`dark`||e===`system`&&t===`dark`?`vs-dark`:`light`}var fm=(0,G.lazy)(async()=>(await ze(()=>import(`./setup-D2az-Ue_.js`),__vite__mapDeps([18,4,1,19,20,21,22,23,24])),{default:(await ze(()=>import(`./dist-lkA3O3eM.js`),__vite__mapDeps([19,1,4]))).default}));function pm(e){return(0,K.jsx)(G.Suspense,{fallback:e.loading??null,children:(0,K.jsx)(fm,{...e})})}var mm={roles:{create:!0,view:!0,update:!0,delete:!0},clusters:{create:!0,view:!0,update:!0,delete:!0,resources:[]}};function hm({isModalOpen:e,setIsModalOpen:t}){let n=dm(),r=oe(),{organizationId:i}=B({strict:!1}),[a,o]=(0,G.useState)(!0),[s,c]=(0,G.useState)(JSON.stringify(mm,null,2)),{mutate:l,isPending:u}=lm(),d=Pt({resolver:Ke(um),defaultValues:{name:``,update:!1,delete:!1}}),f=(0,G.useCallback)(e=>{o(e.length===0)},[o]),p=(0,G.useCallback)(async e=>{let n=Ue(s);if(!n)return;let o={...e,...n,organizationId:i};e&&a&&l(o,{onSuccess:()=>{U.success(`Organization role added successfully!`),t(!1),r.invalidateQueries({queryKey:[i,`roles`],refetchType:`active`}),d.reset()},onError:e=>{U.error(`Failed to add organization role: ${e.message}`)}})},[a,s,l,d,r,t,i]);return(0,K.jsx)(fn,{onOpenChange:t,open:e,children:(0,K.jsxs)(cn,{resizable:!0,children:[(0,K.jsx)(ln,{children:`Add New Organization Role`}),(0,K.jsx)(un,{children:`Set the new organization role permissions.`}),(0,K.jsx)(Io,{...d,children:(0,K.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,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsx)(Y,{control:d.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{className:`col-span-2`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Role Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,className:``,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:d.control,name:`update`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Can Update Organization`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:d.control,name:`delete`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Can Delete Organization`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,K.jsx)(Q,{})]})})]}),(0,K.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,K.jsx)(pm,{className:`w-full h-full`,theme:n,defaultLanguage:`json`,onValidate:f,onChange:e=>{e&&c(e)},options:{automaticLayout:!0},defaultValue:JSON.stringify(mm,null,2)})}),(0,K.jsx)(on,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(F,{variant:`destructiveOutline`,type:`button`,onClick:()=>t(!1),disabled:u,children:`Cancel`}),(0,K.jsx)(F,{variant:`submit`,disabled:u||!a||!d.formState.isValid,children:`Save Changes`})]})})]})})]})})}async function gm({roleId:e}){let{data:t}=await N.delete(`/Role/${e}`,{id:e,deleted:!0});return t}function _m(){return R({mutationFn:({roleId:e})=>gm({roleId:e})})}async function vm({roleId:e,updatedRoleInfo:t}){let{data:n}=await N.put(`/Role/${e}`,t);return n}function ym(){return R({mutationFn:({roleId:e,updatedRoleInfo:t})=>vm({roleId:e,updatedRoleInfo:t})})}function bm({organizationId:e,roleId:t}){return z({queryKey:[e,`roles`,t],queryFn:()=>xm(t),refetchInterval:is(1e4),retry:as()})}async function xm(e){let{data:t}=await N.get(`/Role/${e}`);return t}function Sm({onRoleDeleteClick:e,setIsConfirmingRoleDeletion:t,isRoleDeletionPending:n}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ln,{children:`Confirm Role Deletion`}),(0,K.jsx)(un,{children:`Are you sure you want to delete this role? This action cannot be undone.`}),(0,K.jsxs)(on,{children:[(0,K.jsx)(F,{type:`button`,variant:`defaultOutline`,onClick:()=>t(!1),children:`Cancel`}),(0,K.jsx)(F,{variant:`destructiveOutline`,onClick:e,disabled:n,children:n?`Deleting...`:`Delete Role`})]})]})}function Cm({data:e,isModalOpen:t,closeModal:n}){let r=(0,G.useCallback)(()=>n(!1),[n]);return(0,K.jsx)(fn,{onOpenChange:r,open:t,children:(0,K.jsx)(cn,{resizable:!0,children:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(wm,{roleName:e.roleName}),children:(0,K.jsx)(Tm,{data:e,closeModal:n})})})})}function wm({roleName:e}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(ln,{children:[`Organization Role "`,e,`"`]}),(0,K.jsx)(Gi,{centered:!0,text:`Loading role…`,className:`flex-1 min-h-0`})]})}function Tm({data:e,closeModal:t}){let n=oe(),{data:r}=de(bm({roleId:e.id,organizationId:e.organizationId})),i=wn().user?.roles?.[e.organizationId]?.id===e.id,{update:a,remove:o}=Jl(e.organizationId),{mutate:s,isPending:c}=ym(),{mutate:l,isPending:u}=_m(),d=dm(),[f,p]=(0,G.useState)(!1),m=Pt({resolver:Ke(um),defaultValues:{name:e.roleName,update:r.organization.update||!1,delete:r.organization.delete||!1}}),h=(0,G.useCallback)(()=>{l({roleId:e.id},{onSuccess:()=>{U.success(`Role deleted successfully!`),t(!0),m.reset()},onError:e=>{U.error(`Error`,{description:`Failed to delete role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}})},[e.id,l,m,t]),[g,_]=(0,G.useState)(!0),v=(0,G.useMemo)(()=>JSON.stringify({roles:{...r.organization.roles},clusters:{...r.organization.clusters}},null,2),[r]),[y,b]=(0,G.useState)(v),x=y!==v,S=(0,G.useCallback)(e=>{_(e.length===0)},[_]),C=(0,G.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()=>{U.success(`Role updated successfully!`),await n.invalidateQueries({queryKey:[e.organizationId,`roles`,e.id]}),t(!1),m.reset()},onError:e=>{U.error(`Error`,{description:`Failed to update role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}})},[t,e.id,e.organizationId,m,g,n,r,a,y,s]);return f?(0,K.jsx)(Sm,{onRoleDeleteClick:h,setIsConfirmingRoleDeletion:p,isRoleDeletionPending:u}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(ln,{children:[i||!a?`View`:`Edit`,` Organization Role "`,e.roleName,`"`]}),(0,K.jsx)(Io,{...m,children:(0,K.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,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsx)(Y,{control:m.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{className:`col-span-2`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Role Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,className:``,...e,disabled:!0,readOnly:!0})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`update`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Can Update Organization`}),(0,K.jsx)(J,{children:(0,K.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,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`delete`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Can Delete Organization`}),(0,K.jsx)(J,{children:(0,K.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,K.jsx)(Q,{})]})})]}),(0,K.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,K.jsx)(pm,{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,K.jsx)(on,{children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[o&&(0,K.jsx)(F,{type:`button`,variant:`destructiveOutline`,onClick:()=>p(!0),disabled:c,children:`Delete Role`}),a&&(0,K.jsx)(F,{variant:`submit`,disabled:!g||c||!m.formState.isValid||!m.formState.isDirty&&!x,children:`Save Changes`})]})})]})})]})}function Em(){let e=L(),t=oe(),{organizationId:n,orgRoleId:r}=B({strict:!1}),{create:i}=Jl(n),{data:a,refetch:o,isFetching:s,isRefetching:c}=de(am(n)),l=(0,G.useMemo)(()=>a&&a?.find(e=>e.id===r),[a,r]),u=!!r&&!!l,[d,f]=(0,G.useState)(!1),p=(0,G.useCallback)(async(i,a)=>{let o=[r?`..`:``,i].filter(Boolean);await e({to:o.join(`/`)}),a&&await t.invalidateQueries({queryKey:[n,`roles`],refetchType:`active`})},[r,e,t]),m=(0,G.useCallback)(()=>{f(!0)},[f]),h=(0,G.useCallback)(e=>p(e.original.id,!1),[p]),g=(0,G.useCallback)(e=>p(void 0,e),[p]),_=$p(o);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sc,{}),(0,K.jsx)(Ep,{children:(0,K.jsxs)(G.Suspense,{fallback:(0,K.jsx)(Gi,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,K.jsxs)(Jp,{data:a,columns:sm,onRowClick:h,children:[(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:_,accessKey:`r`,disabled:s||c,children:[(0,K.jsx)(Kr,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),i&&(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:d,children:[(0,K.jsx)(Gr,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]}),i&&(0,K.jsx)(hm,{isModalOpen:d,setIsModalOpen:f}),u&&(0,K.jsx)(Cm,{data:l,isModalOpen:u,closeModal:g},l.id)]})})]})}function Dm({className:e,...t}){return(0,K.jsx)(_t,{"data-slot":`switch`,className:P(`peer data-[state=checked]:bg-green data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-grey-500 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,K.jsx)(Xe,{"data-slot":`switch-thumb`,className:P(`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 Om(e){return`//oauth/${e}/login`}async function km(e,t){let{data:n}=await N.patch(`/Organization/${e}/settings/oauth`,t);return n}var Am=b({domain:M().min(1,`Domain is required`),clientId:M().min(1,`Client ID is required`),clientSecret:M().min(1,`Client secret is required`),scope:M().optional()}),jm=b({domain:M().min(1,`Domain is required`),clientId:M().optional(),clientSecret:M().optional(),scope:M().optional()});function Mm(){let{organizationId:e}=B({strict:!1}),{user:t}=wn(),{update:n}=Kl(e),{data:r}=de(Qu(e)),i=oe(),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(null),l=r.settings?.oauthConfigs??[],{mutate:u,isPending:d}=R({mutationFn:t=>km(e,t),onSuccess:()=>void i.invalidateQueries({queryKey:[e]}),onError:()=>U.error(`Failed to update OAuth settings.`)}),f=Pt({resolver:Ke(Am),defaultValues:{domain:``,clientId:``,clientSecret:``,scope:`openid email profile`}}),p=e=>{u({provider:`okta`,...e},{onSuccess:()=>{U.success(`OAuth provider added.`),f.reset(),o(!1)}})},m=Pt({resolver:Ke(jm)}),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:()=>{U.success(`OAuth provider updated.`),c(null)}})},_=(e,t)=>{u({id:e.id,provider:e.provider,[t]:!e[t]})},v=e=>`//oauth/${e}/callback`,y=async e=>{await xu(e)&&U.success(`Sign-in URL copied.`)},b=async e=>{await xu(e)&&U.success(`Redirect URI copied.`)};return n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sc,{}),(0,K.jsx)(Ep,{children:(0,K.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,K.jsx)(`h2`,{className:`text-2xl text-foreground font-light mb-6`,children:`Authentication`}),(0,K.jsxs)(`section`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h3`,{className:`text-lg text-foreground font-medium`,children:`OAuth Providers`}),!a&&(0,K.jsxs)(F,{variant:`positiveOutline`,size:`sm`,onClick:()=>o(!0),children:[(0,K.jsx)(Gr,{}),`Add Provider`]})]}),l.length===0&&!a&&(0,K.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,K.jsxs)(`div`,{className:`border rounded-lg p-4 mb-3 text-foreground`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h4`,{className:`font-medium`,children:`Edit Provider`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(gn,{className:`size-4`})})]}),(0,K.jsx)(Io,{...m,children:(0,K.jsxs)(`form`,{onSubmit:m.handleSubmit(t=>g(e,t)),className:`space-y-4`,children:[(0,K.jsx)(Y,{control:m.control,name:`domain`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Domain`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`company.okta.com`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`clientId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client ID`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`Leave blank to keep existing`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`clientSecret`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client Secret`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,placeholder:`Leave blank to keep existing`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:m.control,name:`scope`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Scope`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`openid email profile`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,K.jsx)(F,{type:`submit`,variant:`positive`,disabled:d,children:d?`Saving...`:`Save`}),(0,K.jsx)(F,{type:`button`,variant:`outline`,onClick:()=>c(null),children:`Cancel`})]})]})})]},e.id):(0,K.jsx)(`div`,{className:`border rounded-lg p-4 mb-3 text-foreground`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between sm:gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:e.domain}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground uppercase bg-muted px-2 py-0.5 rounded`,children:e.provider}),e.enabled===!1&&(0,K.jsx)(`span`,{className:`text-xs text-destructive bg-destructive/10 px-2 py-0.5 rounded`,children:`Disabled`})]}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground mb-2`,children:[`Client ID: `,(0,K.jsx)(`span`,{className:`text-foreground font-mono`,children:`****`})]}),e.id&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`mt-3 rounded-md bg-muted px-3 py-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Okta redirect URI`}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-1.5`,children:[`Add to `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Login redirect URIs`}),` `,`in your Okta app settings.`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-foreground font-mono truncate`,children:v(e.id)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>void b(v(e.id)),className:`hover:text-foreground shrink-0 text-muted-foreground`,title:`Copy redirect URI`,children:(0,K.jsx)(sr,{className:`size-3.5`})})]})]}),(0,K.jsxs)(`div`,{className:`mt-2 rounded-md bg-muted px-3 py-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`User login link`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`a`,{href:Om(e.id),target:`_blank`,rel:`noreferrer`,className:`text-sm text-foreground truncate hover:underline`,children:Om(e.id)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 text-muted-foreground`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>void y(Om(e.id)),className:`hover:text-foreground`,title:`Copy login link`,children:(0,K.jsx)(sr,{className:`size-3.5`})}),(0,K.jsx)(`a`,{href:Om(e.id),target:`_blank`,rel:`noreferrer`,className:`hover:text-foreground`,title:`Open login link`,children:(0,K.jsx)(dr,{className:`size-3.5`})})]})]})]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 sm:shrink-0`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-foreground cursor-pointer`,children:[(0,K.jsx)(Dm,{checked:e.enabled!==!1,onCheckedChange:()=>_(e,`enabled`),disabled:d}),`Enabled`]}),(0,K.jsxs)(Va,{children:[(0,K.jsx)(Ha,{asChild:!0,children:(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-sm text-foreground ${n?`cursor-pointer`:`cursor-not-allowed opacity-50`}`,children:[(0,K.jsx)(Dm,{checked:!!e.required,onCheckedChange:()=>_(e,`required`),disabled:d||!n}),`Required`]})}),!n&&(0,K.jsxs)(Ua,{children:[`Sign in via `,e.provider,` first to enable Required`]})]}),(0,K.jsx)(F,{variant:`outline`,size:`sm`,onClick:()=>h(e),disabled:d,children:(0,K.jsx)(Ur,{className:`size-4`})})]})]})},e.id)}),a&&(0,K.jsxs)(`div`,{className:`border rounded-lg p-4 text-foreground`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h4`,{className:`font-medium`,children:`Add Okta Provider`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),f.reset()},className:`text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(gn,{className:`size-4`})})]}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-4`,children:[`After saving, copy the `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Okta redirect URI`}),` `,`from the provider card and add it to your Okta app's`,` `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Login redirect URIs`}),`.`]}),(0,K.jsx)(Io,{...f,children:(0,K.jsxs)(`form`,{onSubmit:f.handleSubmit(p),className:`space-y-4`,children:[(0,K.jsx)(Y,{control:f.control,name:`domain`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Domain`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`company.okta.com`,autoFocus:!0,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:f.control,name:`clientId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client ID`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`Okta Client ID`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:f.control,name:`clientSecret`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Client Secret`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,placeholder:`Okta Client Secret`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:f.control,name:`scope`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Scope`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{placeholder:`openid email profile`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,K.jsx)(F,{type:`submit`,variant:`positive`,disabled:d,children:d?`Adding...`:`Add Provider`}),(0,K.jsx)(F,{type:`button`,variant:`outline`,onClick:()=>{o(!1),f.reset()},children:`Cancel`})]})]})})]})]})]})})]}):(0,K.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))] text-foreground`,children:`You don't have permission to manage settings for this organization.`})}j.object({email:ls.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:j.string().nonempty({error:`Please select a role.`})});async function Nm(e){let{data:t}=await N.post(`/UserInvite/`,e);return t}function Pm(){return R({mutationFn:e=>Nm(e)})}function Fm({user:e}){let{update:t}=Jl(),{mutate:n,isPending:r}=Pm(),i=e.roles?.[0]?.id,a=(0,G.useCallback)(t=>{if(t.stopPropagation(),!e.email||!i){U.error(`Cannot resend invite: this user has no email or role.`);return}n({email:e.email,roleId:i},{onSuccess:()=>U.success(`Invitation resent to ${e.email}.`)})},[n,i,e.email]);return t?(0,K.jsxs)(F,{variant:`ghost`,size:`sm`,className:`h-auto px-2 py-0 align-middle text-sm`,onClick:a,disabled:r||!i,children:[(0,K.jsx)(Fr,{}),` Resend invite`]}):null}var Im=qp(),Lm=[{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},Im.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},Im.display({header:``,enableSorting:!1,id:`actions`,cell:e=>e.row.original.status===`PENDING`?(0,K.jsx)(Fm,{user:e.row.original}):null})];function Rm({name:e,id:t}){return(0,K.jsxs)(`span`,{className:`flex items-baseline gap-2 truncate`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:e}),(0,K.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:t})]})}var zm=j.object({email:ls.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:j.string().nonempty({error:`Please select a role.`})});async function Bm(e){let{data:t}=await N.post(`/OrganizationRole/`,e);return t}function Vm(){return R({mutationFn:e=>Bm(e)})}function Hm({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let{organizationId:r}=B({strict:!1}),{data:i,isLoading:a}=H({...am(r),throwOnError:!0}),[o,s]=(0,G.useState)(!1),c=Pt({resolver:Ke(zm),defaultValues:{email:``,roleId:``}}),{mutate:l,isPending:u}=Vm(),{mutate:d,isPending:f}=Pm(),p=(0,G.useCallback)(async e=>{e&&(o?d:l)(e,{onSuccess:()=>{let r=e.roleId;c.reset(),c.setValue(`roleId`,r),t(),U.success(`User invited successfully!`),n(!1),s(!1)},onError:e=>{e?.status===404&&s(!0)}})},[l,c,d,t,n,o]);return(0,K.jsx)(fn,{onOpenChange:()=>{n(!1),s(!1),c.reset()},open:e,children:(0,K.jsx)(cn,{"aria-describedby":void 0,children:(0,K.jsx)(Io,{...c,children:(0,K.jsxs)(`form`,{id:`org-add-user-form`,name:`org-add-user-form`,onSubmit:c.handleSubmit(p),className:`grid gap-4 my-4`,children:[(0,K.jsx)(rn,{children:(0,K.jsx)(ln,{children:o?`Invite User`:`Add User`})}),(0,K.jsx)(Y,{control:c.control,name:`email`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Email`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`email`,enterKeyHint:`next`,autoComplete:`email`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:c.control,name:`roleId`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Roles`}),a?(0,K.jsx)(Af,{}):(0,K.jsx)(J,{children:(0,K.jsxs)(jf,{...e,onValueChange:t=>e.onChange(t),children:[(0,K.jsx)(Pf,{className:`w-full`,children:(0,K.jsx)(Nf,{placeholder:`Choose Role`})}),(0,K.jsx)(Ff,{children:(0,K.jsxs)(Mf,{children:[(0,K.jsx)(If,{children:`Role`}),i?.map(e=>(0,K.jsx)(Lf,{value:e.id,children:(0,K.jsx)(Rm,{name:e.roleName,id:e.id})},e.id))]})})]})}),(0,K.jsx)(Q,{})]})}),o&&(0,K.jsxs)(un,{className:`p-3 my-5 text-white rounded-md bg-amber-600 flex`,children:[(0,K.jsx)(Pr,{className:`inline-block size-12 pr-2`}),(0,K.jsx)(`span`,{children:`This person doesn’t have a Fabric account. Do you want to invite them?`})]}),(0,K.jsx)(on,{children:(0,K.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,K.jsxs)(F,{type:`submit`,variant:`submit`,disabled:u||f,children:[(0,K.jsx)(Xr,{}),` `,o?`Invite User`:`Add User`]})})})]})})})})}async function Um({roleId:e,userId:t}){let{data:n}=await N.delete(`/OrganizationRole/role/${e}/user/${t}`);return n}function Wm(){return R({mutationFn:({roleId:e,userId:t})=>Um({roleId:e,userId:t})})}function Gm(e){let[t,n]=(0,G.useState)(e||!1);return[t,(0,G.useCallback)(e=>{n(typeof e==`boolean`?e:e.target.checked)},[])]}function Km({data:e,readOnly:t,canRemove:n,orgRole:r,selectedRoles:i,setChangesMade:a}){let{mutate:o,isPending:s}=Vm(),{mutate:c,isPending:l}=Wm(),u=!!i[r.id],[d,f]=(0,G.useState)(u),[p,m]=Gm(u);return(0,G.useEffect)(()=>{p!==d&&(p?o({email:e.email,roleId:r.id},{onSuccess:()=>{f(p),a(!0),U.success(`Role added successfully`)}}):c({userId:e.id,roleId:r.id},{onSuccess:()=>{f(p),a(!0),U.success(`Role removed successfully`)}}))},[o,e.email,e.id,p,r.id,c,a,d]),(0,K.jsxs)(Bo,{className:`flex`,children:[(0,K.jsx)($,{type:`checkbox`,className:`w-6`,disabled:t||s||l||!n&&p,checked:p,onChange:m}),(0,K.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:r.roleName})]},r.id)}function qm({isSelf:e,isPending:t,onConfirm:n}){let[r,i]=(0,G.useState)(!1),a=e?{idle:`Leave organization`,confirm:`Confirm leave`,busy:`Leaving…`,warning:`You’ll lose access to this organization and everything in it. You won’t be able to return unless another member invites you back.`}:{idle:`Remove from organization`,confirm:`Confirm removal`,busy:`Removing…`,warning:`This revokes their access to this organization and everything in it. Their Harper account isn’t deleted, and they can be added back later.`},o=e?Nr:hi;return r?(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`p`,{role:`alert`,className:`flex items-start gap-2 text-sm text-muted-foreground border border-amber-500/50 rounded-md p-3`,children:[(0,K.jsx)(mi,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,K.jsx)(`span`,{children:a.warning})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(F,{type:`button`,variant:`ghostOutline`,disabled:t,onClick:()=>i(!1),children:`Cancel`}),(0,K.jsxs)(F,{type:`button`,variant:`destructive`,disabled:t,onClick:n,children:[(0,K.jsx)(o,{}),` `,t?a.busy:a.confirm]})]})]}):(0,K.jsx)(`div`,{className:`flex justify-start`,children:(0,K.jsxs)(F,{type:`button`,variant:`destructiveOutline`,disabled:t,onClick:()=>i(!0),children:[(0,K.jsx)(o,{}),` `,a.idle]})})}function Jm(e){return e?.trim().toLowerCase()===`admin`}function Ym({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 Xm({closeModal:e,data:t,isModalOpen:n,onUserUpdated:r,orgUserCount:i,orgAdminCount:a}){let{organizationId:o}=B({strict:!1}),s=wn(),{update:c,remove:l}=Jl(o),u=s.user?.email===t.email,[d,f]=(0,G.useState)(!1),{canRemoveRoles:p,showRemovalAction:m,blockedReason:h}=Ym({canDelete:l,isSelf:u,orgUserCount:i,adminCount:a,isAdmin:(t.roles??[]).some(e=>Jm(e.roleName)),roleCount:t.roles?.length??0}),{mutateAsync:g}=Wm(),[_,v]=(0,G.useState)(!1),y=(0,G.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)?U.error(u?`Something went wrong leaving the organization. Please try again.`:`Couldn’t remove ${t.email} from the organization. Please try again.`):U.success(u?`You’ve left the organization.`:`${t.email} was removed from the organization.`),v(!1),r()},[t.roles,t.id,t.email,u,g,r]);return(0,K.jsx)(fn,{onOpenChange:d?r:e,open:n,children:(0,K.jsxs)(cn,{resizable:!0,children:[(0,K.jsx)(rn,{children:(0,K.jsxs)(ln,{children:[c?`Edit `:`View `,` `,t.email,` `,u?`(yourself)`:``]})}),c&&(0,K.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,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(Gi,{centered:!0,text:`Loading roles…`,className:`flex-1 min-h-0`}),children:(0,K.jsx)(Zm,{data:t,organizationId:o,update:c,canRemove:p,setChangesMade:f})}),t.status===`PENDING`&&(0,K.jsx)(`div`,{className:`border-t border-border pt-4`,children:(0,K.jsx)(Fm,{user:t})}),m&&(0,K.jsx)(`div`,{className:`border-t border-border pt-4`,children:(0,K.jsx)(qm,{isSelf:u,isPending:_,onConfirm:y})}),h&&(0,K.jsxs)(`p`,{className:`flex items-start gap-2 text-sm text-muted-foreground border border-amber-500/50 rounded-md p-3`,children:[(0,K.jsx)(mi,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,K.jsx)(`span`,{children:h===`sole-member`?`You’re the only member of this organization, so you can’t remove your roles or leave — it would be left with no one to manage it. If you no longer need this organization, terminate its clusters, then delete the organization from the ⋯ menu on the Organizations page.`:`You’re the only admin of this organization, so you can’t remove your roles or leave — it would be left with no one who can manage its members, roles, or clusters. Give another member the admin role first, then you can step back.`})]})]})})}function Zm({data:e,organizationId:t,update:n,canRemove:r,setChangesMade:i}){let{data:a}=de(am(t)),o=(0,G.useMemo)(()=>e.roles?Hu(e.roles,`id`):{},[e]);return(0,K.jsx)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 overflow-y-auto`,children:a.map(t=>(0,K.jsx)(Km,{readOnly:!n,canRemove:r,data:e,orgRole:t,selectedRoles:o,setChangesMade:i},t.id))})}function Qm(e,t){return e.email>t.email?1:-1}function $m(e){return(e.users??[]).filter(e=>e!=null)}function eh(e){let t={};for(let n of e)for(let e of $m(n))t[e.id]||(t[e.id]={...e,roles:[]}),t[e.id].roles.push(n);return Object.values(t).sort(Qm)}function th(e){let t=new Set;for(let n of e)if(Jm(n.roleName))for(let e of $m(n))t.add(e.id);return t.size}function nh(){let e=L(),{organizationId:t,orgUserId:n}=B({strict:!1}),{update:r}=Jl(t),{data:i,refetch:a,isFetching:o,isRefetching:s}=de(am(t)),c=(0,G.useMemo)(()=>eh(i),[i]),l=(0,G.useMemo)(()=>th(i),[i]),u=(0,G.useMemo)(()=>c?.find(e=>e.id===n),[c,n]),d=(0,G.useCallback)(t=>{let r=[n?`..`:``,t].filter(Boolean);e({to:r.join(`/`)})},[n,e]),f=!!n&&!!u,[p,m]=(0,G.useState)(!1),[h]=(0,G.useState)({attribute:`email`,descending:!1}),g=(0,G.useMemo)(()=>[{desc:h.descending,id:h.attribute}],[h]),_=(0,G.useCallback)(()=>{m(!0)},[m]),v=(0,G.useCallback)(()=>{a(),m(!1)},[a,m]),y=(0,G.useCallback)(e=>{d(e.original.id)},[d]),b=(0,G.useCallback)(()=>{d(void 0)},[d]),x=(0,G.useCallback)(()=>{a(),d(void 0)},[d,a]),S=$p(a);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sc,{}),(0,K.jsx)(Ep,{children:(0,K.jsxs)(G.Suspense,{fallback:(0,K.jsx)(Gi,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,K.jsxs)(Jp,{data:c,isFetching:o||s,columns:Lm,onRowClick:y,sortingState:g,children:[(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:S,accessKey:`r`,disabled:o||s,children:[(0,K.jsx)(Kr,{}),` `,(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),r&&(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:_,accessKey:`a`,disabled:p,children:[(0,K.jsx)(Gr,{}),` `,(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]}),r&&(0,K.jsx)(Hm,{isModalOpen:p,onChangesSaved:v,setIsModalOpen:m}),f&&(0,K.jsx)(Xm,{closeModal:b,data:u,isModalOpen:f,onUserUpdated:x,orgUserCount:c.length,orgAdminCount:l})]})})]})}function rh({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`skeleton`,className:P(`bg-primary/10 animate-pulse rounded-md`,e),...t})}function ih({organizationId:e,organizationName:t,providers:n}){return(0,K.jsxs)(On,{className:`relative h-full justify-between opacity-90`,children:[(0,K.jsxs)(kn,{children:[(0,K.jsx)(jn,{className:`truncate`,children:e}),(0,K.jsx)(An,{children:(0,K.jsx)(`h2`,{children:t})})]}),(0,K.jsxs)(Mn,{className:`flex flex-col gap-2`,children:[(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-1.5 mb-1`,children:[(0,K.jsx)(Tr,{className:`size-3 shrink-0`}),`Sign in with an OAuth provider to access this organization.`]}),n.map(e=>(0,K.jsx)(`a`,{href:Om(e.oauthConfigId),children:(0,K.jsxs)(F,{variant:`outline`,className:`w-full`,children:[`Sign in with `,e.name]})},e.oauthConfigId))]})]})}var ah=b({couponId:M().nonempty({message:`Please enter a coupon ID.`}).trim()});async function oh({organizationId:e,couponId:t}){let{data:n}=await N.post(`/Coupon`,{organizationId:e,couponId:t},{validateStatus:e=>e>=200&&e<400||e===400||e===409});return n}function sh(){return R({mutationFn:oh})}function ch({organizationId:e,organizationName:t,isOpen:n,onClose:r}){let{mutate:i,isPending:a}=sh(),o=Pt({resolver:Ke(ah),defaultValues:{couponId:``}}),{handleSubmit:s,control:c,reset:l}=o;(0,G.useEffect)(()=>{n&&l({couponId:``})},[n,l]);let u=(0,G.useCallback)(n=>{i({organizationId:e,couponId:n.couponId},{onSuccess:i=>{i?U.error(`Error`,{description:i||`Failed to add coupon.`}):(U.success(`Success`,{description:`Coupon "${n.couponId}" added to ${t||e}.`}),r())}})},[i,e,t,r]);return(0,K.jsx)(fn,{open:n,onOpenChange:e=>!e&&r(),children:(0,K.jsxs)(cn,{children:[(0,K.jsxs)(rn,{children:[(0,K.jsx)(ln,{children:`Add Coupon`}),(0,K.jsxs)(un,{children:[`Add a coupon code to`,` `,t||e,`. This coupon will be applied to the next billing cycle.`,(0,K.jsx)(`br`,{}),`Coupons can be created in our`,` `,(0,K.jsx)(`a`,{href:`https://dashboard.stripe.com/`,target:`_blank`,rel:`noreferrer`,className:`text-purple hover:underline`,children:`Stripe Dashboard`}),`.`]})]}),(0,K.jsx)(Io,{...o,children:(0,K.jsxs)(`form`,{onSubmit:s(u),children:[(0,K.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,K.jsx)(Y,{control:c,name:`couponId`,render:({field:e})=>(0,K.jsxs)(X,{className:`grid items-center gap-4`,children:[(0,K.jsx)(Z,{children:`Coupon ID`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{...e,placeholder:`e.g. 100OFF`,disabled:a})}),(0,K.jsx)(Q,{})]})})}),(0,K.jsxs)(on,{children:[(0,K.jsx)(F,{type:`button`,variant:`ghost`,onClick:r,disabled:a,children:`Cancel`}),(0,K.jsx)(F,{type:`submit`,disabled:a,children:a?`Adding...`:`Add Coupon`})]})]})})]})})}function lh({organizationRole:e,onDeleteOrgModal:t}){let{organizationId:n,organizationName:r,roleName:i}=e,{remove:a,update:o}=Kl(n),s=o,{view:c}=Jl(n),l=En(`billing:write`),[u,d]=(0,G.useState)(!1),f=(0,G.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,K.jsx)($r,{className:`size-4 mr-2 text-blue-500`}),label:`Clusters`},c&&{key:`roles`,to:`${n}/roles`,icon:(0,K.jsx)(ti,{className:`size-4 mr-2 text-purple`}),label:`Roles`},c&&{key:`users`,to:`${n}/users`,icon:(0,K.jsx)(_i,{className:`size-4 mr-2 text-orange-500`}),label:`Users`},s&&{key:`billing`,to:`${n}/billing`,icon:(0,K.jsx)(cr,{className:`size-4 mr-2 text-green-500`}),label:`Billing`},o&&{key:`settings`,to:`${n}/settings`,icon:(0,K.jsx)(Tr,{className:`size-4 mr-2 text-yellow-500`}),label:`Settings`},l&&{key:`add-coupon`,onClick:()=>d(!0),icon:(0,K.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,K.jsx)(pi,{className:`size-4 mr-2 text-red-500`}),label:`Delete`}].filter($a),m=a||l;return(0,K.jsx)(Nc,{items:m?p:[],children:(0,K.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,K.jsx)(V,{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,K.jsxs)(kn,{children:[(0,K.jsxs)(jn,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:n}),m&&(0,K.jsxs)(Ti,{children:[(0,K.jsx)(Ei,{"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,K.jsx)(ur,{})}),(0,K.jsx)(Di,{children:Mc(p,`dropdown`)})]})]}),(0,K.jsx)(An,{children:(0,K.jsx)(`h2`,{children:r})})]}),(0,K.jsxs)(Mn,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(Yi,{className:`min-w-0 shrink`,title:No(i),children:(0,K.jsx)(`span`,{className:`truncate`,children:No(i)})}),(0,K.jsxs)(`span`,{className:`text-sm shrink-0 py-2 whitespace-nowrap ml-auto`,children:[`View `,(0,K.jsx)(Rn,{className:`inline-block`})]})]}),(0,K.jsx)(ch,{organizationId:n,organizationName:r,isOpen:u,onClose:()=>d(!1)})]})})}async function uh(e){let{data:t}=await N.delete(`/Organization/${e}`);return t}function dh(){return R({mutationFn:e=>uh(e)})}async function fh(e){let{data:t}=await N.post(`/Organization/`,{...e});return t}function ph(){return R({mutationFn:e=>fh(e)})}var mh=M().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.`}),hh=b({name:M().max(255,{error:`Name cannot be longer than 255 characters.`}),subdomain:S([k(``),x(),mh]).optional()});function gh(){let{user:e}=wn(),t=L(),n=Pt({resolver:Ke(hh),defaultValues:{name:``,subdomain:``}}),{setFocus:r,watch:i}=n;(0,G.useEffect)(()=>{r(`name`)},[r]);let a=`${e?.firstname} ${e?.lastname} Org`,o=i(`name`)||a,s=i(`subdomain`),c=(0,G.useMemo)(()=>{let e=ed(nd(o),mh.maxLength);return{suggestedSubdomain:e,fullHostName:`future-cluster-names.${s||e}.harperfabric.com`}},[o,s]),{mutate:l,isPending:d}=ph(),p=oe(),h=(0,G.useCallback)(async e=>{l({name:e.name||a,subdomain:e.subdomain||c.suggestedSubdomain},{onSuccess:e=>{p.invalidateQueries({queryKey:f,refetchType:`active`}),u.reloadUser(m),t({to:`/${e.id}`})}})},[c.suggestedSubdomain,p,l,a,t]);return(0,K.jsx)(K.Fragment,{children:(0,K.jsx)(Io,{...n,children:(0,K.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,K.jsx)(Y,{control:n.control,name:`name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,maxLength:hh.shape.name.maxLength,autoCapitalize:`words`,placeholder:a,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:n.control,name:`subdomain`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Subdomain`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,maxLength:mh.maxLength,autoCapitalize:`none`,placeholder:c.suggestedSubdomain,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Full Host Name`}),(0,K.jsx)(J,{children:(0,K.jsx)(`span`,{children:c.fullHostName})}),(0,K.jsx)(Q,{})]}),(0,K.jsx)(on,{children:(0,K.jsxs)(F,{type:`submit`,variant:`submit`,disabled:d,children:[`Create New Organization `,(0,K.jsx)(Rn,{})]})})]})})})}function _h(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sc,{}),(0,K.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,K.jsx)(gh,{})})]})}var vh={org:`organization`,clu:`cluster`,ins:`instance`},yh=/^(org|clu|ins)-[a-z0-9]+$/;function bh(e){if(typeof e!=`string`)return null;let t=e.trim(),n=yh.exec(t);return n?{kind:vh[n[1]],id:t}:null}function xh(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 Sh(e,t){let{data:n}=await N.get(xh(e,t));return{organizations:n.slice(0,12),hasNextPage:n.length>12}}var Ch={organizations:[],hasNextPage:!1};function wh(e){return e instanceof v&&(e.response?.status===404||e.status===404)}async function Th(e){try{let{data:t}=await N.get(`/Admin/Organization/${e}`);return t?{organizations:[t],hasNextPage:!1}:Ch}catch(e){if(wh(e))return Ch;throw e}}async function Eh(e){try{let{data:t}=await N.get(`/Cluster/${e}`),n=t?.organizationId;return n?await Th(n):Ch}catch(e){if(wh(e))return Ch;throw e}}function Dh(e,t){let n=bh(t);return z({queryKey:[`admin-all-organizations`,t,e],queryFn:()=>n?.kind===`organization`?Th(n.id):n?.kind===`cluster`?Eh(n.id):Sh(e,t),placeholderData:je,retry:!1})}function Oh(e,t=300,n){let[r,i]=(0,G.useState)(e),a=n?n(e):e;return(0,G.useEffect)(()=>{let n=setTimeout(()=>i(e),t);return()=>clearTimeout(n)},[a,t]),r}function kh(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 Ah(e,t){let[n,r]=(0,G.useState)(t),[i,a]=(0,G.useState)(e);return(0,G.useEffect)(()=>{kh(n,t)||(r(t),a(e))},[n,t,e]),kh(n,t)?[i,a]:[e,a]}var jh={};function Mh(e,t,n){let r=(0,G.useCallback)((e,n)=>t(e,n),[n]);(0,G.useEffect)(()=>(jh[e]||(jh[e]=[]),jh[e].push(r),function(){let t=jh[e].indexOf(r);t>=0&&jh[e].splice(t,1)}),[e,t,r])}function Nh(e,t,n){let r=jh[e];if(r)for(let e of r)e(t,n)}function Ph(e,t,n){return r=>Nh(e,t,n??r)}function Fh(e,t,n){return(0,G.useCallback)(r=>Nh(e,t,n??r),[e,t,n])}function Ih(e,t){let n=Ah(We(e,t),[e]),[r,i]=n;return(0,G.useEffect)(()=>{Ge(e,r),Nh(`Session:${e}`,r)},[e,r]),Mh(`Session:${e}`,function(e){r!==e&&i(e)},[r,e,t]),(0,G.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 Lh(){let e=oe(),{data:t}=de(s()),{mutate:n,isPending:r}=dh(),[i,a]=(0,G.useState)(!1),[o,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(``),d=(0,G.useCallback)(()=>u(``),[]),f=En(`org:read`),[p,m]=Ih(`ShowAllOrganizations`,!1),[h,g]=(0,G.useState)(0),_=f&&p,v=(0,G.useCallback)(e=>{m(e),g(0)},[m]),y=Oh(l,300),b=(0,G.useMemo)(()=>{if(!f)return null;let e=bh(y);return e?.kind===`organization`||e?.kind===`cluster`?e:null},[f,y]),x=_||!!b,{data:S,isPending:C}=H({...Dh(h,y),enabled:x}),{organizationRoles:w,oauthLockedOrgs:T}=(0,G.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(Ap([`organizationId`,`organizationName`],l)).sort((e,t)=>(e.organizationName||``)>(t.organizationName||``)?1:-1),oauthLockedOrgs:r}},[l,t?.roles,f]),E=(0,G.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,G.useCallback)(e=>{u(e.currentTarget.value||``),g(0)},[]),k=(0,G.useCallback)(t=>{t?.organizationId&&n(t.organizationId,{onSuccess:()=>{U.success(`Success`,{description:`Organization successfully deleted.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),e.invalidateQueries({queryKey:[]}),a(!1)},onError:()=>a(!1)})},[n,e,a]),A=(0,G.useCallback)(e=>{c(e),a(!0)},[]),{createCluster:j}=le({strict:!1});return!_&&w.length===1&&!l.length&&j?(0,K.jsx)(re,{to:`/${w[0].organizationId}/new-cluster`,replace:!0}):!_&&!w.length&&!T.length&&!l.length?(0,K.jsx)(_h,{}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sc,{children:(0,K.jsxs)(`div`,{className:`flex w-full items-center justify-end gap-2`,children:[f&&(0,K.jsxs)(`label`,{className:`flex shrink-0 cursor-pointer items-center gap-2 text-xs`,children:[(0,K.jsx)(Dm,{checked:p,onCheckedChange:v,"aria-label":`Show all organizations`}),(0,K.jsx)(`span`,{className:`hidden sm:inline-block`,children:`All Orgs`})]}),(0,K.jsx)($,{placeholder:`Filter by name`,className:`inline-block w-full text-xs`,value:l,onChange:O}),(0,K.jsx)(V,{to:`/new-org`,children:(0,K.jsxs)(F,{variant:`positive`,accessKey:`n`,children:[(0,K.jsx)(Gr,{}),(0,K.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,K.jsx)(`u`,{children:`N`}),`ew `,(0,K.jsx)(`span`,{className:`hidden md:inline-block`,children:`Organization`})]})]})})]})}),(0,K.jsxs)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-12`,children:[!x&&T.map(e=>(0,K.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,K.jsx)(ih,{organizationId:e.organizationId,organizationName:e.organizationName,providers:e.providers})},e.organizationId)),x&&C?Array.from({length:12},(e,t)=>(0,K.jsx)(rh,{className:`col-span-1 h-40 md:col-span-4 lg:col-span-3 2xl:col-span-2`},t)):D.map(e=>(0,K.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,K.jsx)(lh,{organizationRole:e,onDeleteOrgModal:A})},e.organizationId)),!D.length&&!(x&&C)&&(x||!T.length)&&(0,K.jsxs)(`div`,{className:`col-span-1 md:col-span-12 text-center`,children:[(0,K.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,K.jsx)(F,{variant:`outline`,onClick:d,children:`Clear Filters`})]})]}),x&&(h>0||S?.hasNextPage)&&(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-4 py-6`,children:[(0,K.jsxs)(F,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:h===0,onClick:()=>g(e=>e-1),children:[(0,K.jsx)(Ln,{}),`Previous`]}),(0,K.jsxs)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:[`Page `,h+1]}),(0,K.jsxs)(F,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:!S?.hasNextPage,onClick:()=>g(e=>e+1),children:[`Next`,(0,K.jsx)(Rn,{})]})]})]}),o&&(0,K.jsx)(Cc,{typeOfThingBeingDeleted:`organization`,nameOfThingBeingDeleted:o.organizationName,isModalOpen:i,setIsModalOpen:()=>a(!1),deletionConfirmed:()=>k(o),deletionPending:r})]})}var Rh=I({getParentRoute:()=>xo,id:`_orgsLayout`});I({getParentRoute:()=>Rh,path:`/`,head:()=>({meta:[{title:`Organizations — Harper Fabric`}]}),component:Lh}),I({getParentRoute:()=>Rh,path:`/new-org`,head:()=>({meta:[{title:`New Organization — Harper Fabric`}]}),component:_h});var zh=I({getParentRoute:()=>Rh,path:`$organizationId`,beforeLoad:async e=>{let{organizationId:t}=e.params;if(!Xu(t))throw ie({to:`/`});return{organization:await e.context.queryClient.ensureQueryData(Qu(t))}}});I({getParentRoute:()=>zh,path:`/roles`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:Em}),I({getParentRoute:()=>zh,path:`/roles/$orgRoleId`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:Em}),I({getParentRoute:()=>zh,path:`/users`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:nh}),I({getParentRoute:()=>zh,path:`/users/$orgUserId`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:nh}),I({getParentRoute:()=>zh,path:`/settings`,component:Mm}),rm(zh);var Bh=I({getParentRoute:()=>zh,id:`_clusterLayout`});I({getParentRoute:()=>Bh,path:`/`,head:()=>({meta:[{title:`Clusters — Harper Fabric`}]}),component:jp}),I({getParentRoute:()=>zh,path:`/new-cluster`,head:()=>({meta:[{title:`New Cluster — Harper Fabric`}]}),component:Tp}),I({getParentRoute:()=>Hh,path:`/edit`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),component:Tp}),I({getParentRoute:()=>Hh,path:`/edit/$mode`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),component:Tp});function Vh(){return(0,K.jsx)(Le,{})}var Hh=I({getParentRoute:()=>Bh,path:`$clusterId`,component:Vh,beforeLoad:async({context:e,params:t})=>({cluster:await e.queryClient.ensureQueryData(cs(t.clusterId))})}),Uh=e=>new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e),Wh=e=>`${new Intl.NumberFormat(void 0,{maximumFractionDigits:1}).format(e)} hr`,Gh=e=>tp(e),Kh={reads:`Reads`,readBytes:`Read data`,writes:`Writes`,writeBytes:`Write data`,realTimeMessages:`Real-time messages`,realTimeBytes:`Real-time data`,cpuTimeHours:`Compute`,storageBytes:`Storage`},qh={reads:Uh,readBytes:Gh,writes:Uh,writeBytes:Gh,realTimeMessages:Uh,realTimeBytes:Gh,cpuTimeHours:Wh,storageBytes:Gh},Jh=[`reads`,`readBytes`,`writes`,`writeBytes`,`realTimeMessages`,`realTimeBytes`,`cpuTimeHours`,`storageBytes`];function Yh(e,t,n){return{label:n??Kh[e],used:t.used,limit:t.limit,unlimited:t.unlimited,limitKnown:t.limitKnown,format:qh[e]}}function Xh({label:e,used:t,limit:n,unlimited:r,limitKnown:i,format:a}){let o=r||n!=null&&n<0,s=i&&!o&&n!=null&&n>0,c=s?Math.min(100,Math.round(t/n*100)):0,l=c>=90;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-foreground`,children:e}),(0,K.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[(0,K.jsx)(`span`,{className:`text-foreground`,children:a(t)}),s?(0,K.jsxs)(K.Fragment,{children:[`/ `,a(n)]}):` used`]})]}),(0,K.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`h-2 flex-1 overflow-hidden rounded-full bg-muted`,children:s?(0,K.jsx)(`div`,{className:`h-full rounded-full ${l?`bg-yellow`:`bg-primary dark:bg-violet-400`}`,style:{width:`${c}%`}}):o?(0,K.jsx)(`div`,{className:`h-full w-full bg-[repeating-linear-gradient(-45deg,transparent,transparent_5px,var(--color-border)_5px,var(--color-border)_9px)] dark:bg-[repeating-linear-gradient(-45deg,transparent,transparent_5px,rgba(255,255,255,0.32)_5px,rgba(255,255,255,0.32)_9px)]`}):null}),(0,K.jsx)(`span`,{className:`w-16 shrink-0 text-right text-xs tabular-nums ${l?`text-yellow`:`text-muted-foreground`}`,children:s?`${c}%`:o?`Unlimited`:`—`})]})]})}function Zh(e){return z({queryKey:[`clusterUsage`,e],queryFn:async()=>{let{data:t}=await N.get(`/Cluster/${e}/usage`);return t},enabled:!!e,staleTime:6e4})}function Qh(e){return H(Zh(e))}function $h(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} ${eg(e.renewsAt)}`:null].filter(Boolean).join(` · `)}function eg(e){return new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))}function tg({clusterId:e,base:t}){let{data:n}=Qh(e);return!n||n.selfManaged||n.regions.length===0?null:(0,K.jsxs)(`section`,{className:`mt-6 rounded-2xl border border-border bg-card p-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Plan usage`}),(0,K.jsxs)(V,{to:`${t}/usage`,className:`inline-flex items-center gap-1 text-xs text-primary hover:underline dark:text-violet-300`,children:[`View all usage `,(0,K.jsx)(Rn,{className:`size-3`})]})]}),(0,K.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:$h(n)}),(0,K.jsx)(`div`,{className:`mt-4`,children:n.regions.length===1?(0,K.jsx)(ng,{data:n}):(0,K.jsx)(rg,{data:n})})]})}function ng({data:e}){let t=e.regions[0].metrics,n=[Yh(`reads`,t.reads),Yh(`writes`,t.writes),Yh(`storageBytes`,t.storageBytes),Yh(`cpuTimeHours`,t.cpuTimeHours)];return(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-x-8 gap-y-4 sm:grid-cols-2`,children:n.map(e=>(0,K.jsx)(Xh,{...e},e.label))})}function rg({data:e}){let t=e.mostConstrained;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`p`,{className:`mb-1.5 text-xs text-muted-foreground`,children:[`Most constrained of `,e.regions.length,` regions`]}),t?(0,K.jsx)(Xh,{...Yh(t.metric,{used:t.used,limit:t.limit,unlimited:!1,limitKnown:!0},`${t.region??`Region`} · ${Kh[t.metric]}`)}):(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No metered limits on the current plan — see the breakdown for details.`})]})}function ig({cluster:e}){let t=se(),n=oe(),{update:r,remove:i}=Xl(e.organizationId,e.id),{run:a,isPending:o}=bu(e),{mutate:s,isPending:c}=gu(),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(!1),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(null),_=e.status===`RUNNING`,v=e.status===`STOPPED`,y=e.status===`PARTIAL`,b=!r||o,x=(0,G.useCallback)(()=>{s(e.id,{onSuccess:async()=>{await n.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),m(!1),U.success(`Success`,{description:`Cluster successfully terminated.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}}),t.navigate({to:`/${e.organizationId}`})},onError:()=>{m(!1)}})},[e.id,e.organizationId,s,n,t]),S=(0,G.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 cu(e)||!r&&!i?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Ti,{children:[(0,K.jsx)(Ei,{asChild:!0,children:(0,K.jsxs)(F,{variant:`outline`,size:`sm`,disabled:o,className:`gap-1.5 hover:translate-y-0 data-[state=open]:[&>svg]:rotate-180`,children:[`Cluster actions`,(0,K.jsx)(pn,{className:`size-4 transition-transform`})]})}),(0,K.jsxs)(Di,{align:`end`,className:`w-56`,children:[(0,K.jsx)(Ai,{className:`text-gray-600 text-xs`,children:`Container`}),(0,K.jsxs)(Oi,{disabled:b||!(v||y),onClick:()=>void a(`start`,{safeMode:!1,strategy:`parallel`}),children:[(0,K.jsx)(Wr,{}),` Start`]}),(0,K.jsxs)(Oi,{disabled:b||!v,onClick:()=>g(`start`),children:[(0,K.jsx)(Or,{}),` Start in safe mode`]}),(0,K.jsxs)(Oi,{disabled:b||!(_||y),onClick:()=>f(!0),children:[(0,K.jsx)(Yr,{}),` Restart`]}),(0,K.jsxs)(Oi,{disabled:b||!_,onClick:()=>g(`restart`),children:[(0,K.jsx)(Or,{}),` Restart in safe mode`]}),(0,K.jsxs)(Oi,{variant:`destructive`,disabled:b||!(_||y),onClick:()=>u(!0),children:[(0,K.jsx)(ai,{}),` Stop`]}),(0,K.jsx)(ji,{}),(0,K.jsxs)(Oi,{variant:`destructive`,disabled:!i,onClick:()=>m(!0),children:[(0,K.jsx)(fi,{}),` Terminate`]})]})]}),(0,K.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,K.jsx)(mu,{open:h!==null,setOpen:e=>{e||g(null)},action:h??`restart`,targetName:e.name,scope:`cluster`,isPending:o,onConfirm:S}),(0,K.jsx)(Cc,{typeOfThingBeingDeleted:`cluster`,transitiveVerb:`Terminate`,presentParticiple:`Terminating`,nameOfThingBeingDeleted:e.name,isModalOpen:p,setIsModalOpen:m,deletionConfirmed:x,deletionPending:c})]})}function ag(){let{clusterId:e}=B({strict:!1}),t=se(),n=L(),{data:r}=H(cs(e,!0)),{user:i,isLoading:a}=Dn(e),{view:s,update:l}=Xl(r?.organizationId,r?.id),[f,p]=(0,G.useState)(!1),m=r?.domains?.[0]?.domain||r?.fqdn||``,[h,g]=Cu(m,m?`https://${m}`:``),_=r?`/${r.organizationId}/${r.id}`:``,v=(0,G.useCallback)(async()=>{if(r){p(!0);try{await u.establishFabricConnectAuth({id:r.id,operationsUrl:c(r)}),await t.invalidate()}catch{U.error(`Could not connect to this cluster through Fabric Connect.`)}finally{p(!1)}}},[r,t]),y=(0,G.useCallback)(()=>{r&&(u.setUserForEntity(r,null),u.flagForFabricConnect(r.id,!1)),n({to:`${_}/sign-in`})},[_,r,n]),b=(0,G.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,K.jsx)(sg,{children:(0,K.jsx)(cg,{})});if(!s)return(0,K.jsx)(re,{to:`/${r.organizationId}`,replace:!0});if(cu(r))return(0,K.jsx)(og,{cluster:r});if(!r.fqdn)return(0,K.jsx)(re,{to:`${_}/instances`,replace:!0});if(r.resetPassword){if(!l)return(0,K.jsx)(sg,{children:(0,K.jsxs)(`div`,{className:`text-center py-12`,children:[(0,K.jsx)($r,{className:`size-12 text-muted-foreground mx-auto mb-4`}),(0,K.jsx)(`h1`,{className:`text-xl font-medium mb-2 text-foreground`,children:`Pending Owner Setup`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-md mx-auto`,children:`This cluster needs an administrator to finish setup before it can be used.`})]})});let e=r.status&&Vo.includes(r.status)&&es(r);return(0,K.jsx)(re,{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&&!Ho.includes(e.status)).length,T=r.instances??[],E=!!r.status&&Vo.includes(r.status)&&T.length>0&&T.every(e=>e.safeMode);return(0,K.jsxs)(sg,{children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-4 mb-6`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center size-12 rounded-xl bg-violet-50 text-primary dark:bg-grey-700 dark:text-violet-300 shrink-0`,children:(0,K.jsx)($r,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:r.name}),(0,K.jsx)(lg,{status:r.status}),E&&(0,K.jsx)(ug,{})]}),(0,K.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,K.jsxs)(`span`,{children:[w,` `,w===1?`instance`:`instances`]}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsxs)(`a`,{href:`https://${m}`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 hover:text-foreground hover:underline`,children:[m,(0,K.jsx)(dr,{className:`size-3`})]}),(0,K.jsxs)(Ti,{children:[(0,K.jsx)(Ei,{"aria-label":`Copy cluster URLs`,className:`rounded-md p-1 -m-1 hover:bg-accent/60 hover:text-foreground`,children:(0,K.jsx)(sr,{className:`size-3.5`})}),(0,K.jsxs)(Di,{align:`start`,children:[(0,K.jsx)(Oi,{onClick:h,children:`Copy host name`}),(0,K.jsx)(Oi,{onClick:g,children:`Copy API URL`})]})]})]})]}),(0,K.jsx)(ig,{cluster:r})]}),a?(0,K.jsx)(cg,{}):S?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-sm`,children:[(0,K.jsx)(Qn,{className:`size-4 text-green shrink-0`}),(0,K.jsx)(`span`,{className:`font-medium text-green`,children:x?`Connected via Fabric Connect`:`Signed in directly`}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,x?`through your Harper account`:`session cookie`]})]}),(0,K.jsxs)(V,{to:`${_}/apps`,className:`group flex items-center gap-4 rounded-2xl border-2 border-primary/30 bg-primary/5 p-6 transition-all hover:border-primary hover:bg-primary/10 dark:border-violet-400/30 dark:bg-violet-400/5 dark:hover:border-violet-400 dark:hover:bg-violet-400/10`,children:[(0,K.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-primary/10 text-primary shrink-0 dark:bg-violet-400/15 dark:text-violet-300`,children:(0,K.jsx)(qr,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-lg font-medium text-foreground`,children:`Enter cluster`}),(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Open the studio — apps, databases, APIs, logs, and config.`})]}),(0,K.jsx)(Rn,{className:`size-5 text-muted-foreground transition-transform group-hover:translate-x-1`})]}),(0,K.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-4 text-sm`,children:[x&&(0,K.jsx)(`button`,{type:`button`,onClick:y,className:`text-muted-foreground hover:text-foreground transition-colors`,children:`Switch to direct sign-in`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>void b(),className:`text-muted-foreground hover:text-destructive transition-colors`,children:x?`Disconnect`:`Direct sign out`})]})]}):(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-sm font-medium text-foreground mb-3`,children:`Connect to this cluster`}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3.5`,children:[l&&!cu(r)&&(0,K.jsx)(dg,{icon:vi,title:`Fabric Connect`,description:`Connect through your Harper account. No cluster credentials needed.`,pill:C===`fabric`?`last`:C?void 0:`recommended`,children:(0,K.jsx)(F,{className:`w-full`,disabled:f,onClick:()=>void v(),children:f?(0,K.jsx)(Ar,{className:`animate-spin`}):`Fabric Connect`})}),(0,K.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,K.jsx)(F,{className:`w-full`,variant:`outline`,onClick:y,children:`Direct sign-in`})})]})]}),(0,K.jsx)(tg,{clusterId:r.id,base:_})]})}function og({cluster:e}){let t=se(),n=L(),r=`/${e.organizationId}/${e.id}`,i=(0,G.useMemo)(()=>(e.instances??[]).filter(e=>e.status&&!Ho.includes(e.status)).sort(Bu),[e.instances]),a=i.at(0),{user:s,isLoading:c}=Dn(a?.id),l=!!a&&!!s,f=(0,G.useCallback)(()=>{a&&n({to:`${r}/instance/${a.id}/sign-in`})},[r,a,n]),m=(0,G.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,K.jsxs)(sg,{children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-4 mb-6`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center size-12 rounded-xl bg-violet-50 text-primary dark:bg-grey-700 dark:text-violet-300 shrink-0`,children:(0,K.jsx)($r,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:e.name}),(0,K.jsx)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full text-muted-foreground bg-muted`,children:`Self-Hosted`})]}),(0,K.jsx)(`div`,{className:`mt-1 text-sm text-muted-foreground`,children:(0,K.jsxs)(V,{to:`${r}/instances`,className:`hover:text-foreground hover:underline`,children:[i.length,` `,i.length===1?`instance`:`instances`]})})]})]}),a?c?(0,K.jsx)(cg,{}):l?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-sm`,children:[(0,K.jsx)(Qn,{className:`size-4 text-green shrink-0`}),(0,K.jsx)(`span`,{className:`font-medium text-green`,children:`Signed in directly`}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,a.name||a.instanceFqdn]})]}),(0,K.jsxs)(V,{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,K.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-primary/10 text-primary shrink-0 dark:bg-violet-400/15 dark:text-violet-300`,children:(0,K.jsx)(qr,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-lg font-medium text-foreground`,children:`Enter cluster`}),(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Open the studio — apps, databases, APIs, logs, and config.`})]}),(0,K.jsx)(Rn,{className:`size-5 text-muted-foreground transition-transform group-hover:translate-x-1`})]}),(0,K.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-4 text-sm`,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>void m(),className:`text-muted-foreground hover:text-destructive transition-colors`,children:`Direct sign out`})})]}):(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-sm font-medium text-foreground mb-3`,children:`Connect to this cluster`}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3.5`,children:(0,K.jsx)(dg,{icon:Tr,title:`Direct sign-in`,description:`Sign in with this instance's Harper username and password.`,children:(0,K.jsx)(F,{className:`w-full`,variant:`outline`,onClick:f,children:`Direct sign-in`})})})]}):(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`This cluster has no instances yet. Register one from the`,` `,(0,K.jsx)(V,{to:`${r}/instances`,className:`underline hover:text-foreground`,children:`Instances`}),` page.`]})]})}function sg({children:e}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sc,{}),(0,K.jsx)(Du,{children:(0,K.jsx)(`div`,{className:`max-w-3xl`,children:e})})]})}function cg(){return(0,K.jsx)(`div`,{className:`flex justify-center py-10 text-muted-foreground`,children:(0,K.jsx)(Ar,{className:`size-6 animate-spin`})})}function lg({status:e}){let t=e&&Vo.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,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full ${t}`,children:[(0,K.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e?e.charAt(0)+e.slice(1).toLowerCase():`Unknown`]})}function ug(){return(0,K.jsxs)(`span`,{title:`All instances running in safe mode — user apps/components are not loaded`,className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full text-yellow bg-yellow/10`,children:[(0,K.jsx)(Or,{className:`size-3`}),`Safe mode`]})}function dg({icon:e,title:t,description:n,pill:r,children:i}){return(0,K.jsxs)(`div`,{className:`relative rounded-xl p-4.5 bg-card border ${r===`last`?`border-2 border-green`:r===`recommended`?`border-2 border-primary dark:border-violet-400`:`border-border`}`,children:[r&&(0,K.jsx)(`span`,{className:`absolute -top-2.5 left-4 rounded-full bg-card`,children:(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full ${r===`last`?`text-green bg-green/15`:`text-primary bg-violet-50 dark:text-violet-300 dark:bg-grey-700`}`,children:[r===`last`&&(0,K.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),r===`last`?`Last used`:`Recommended`]})}),(0,K.jsx)(e,{className:`size-6 text-primary dark:text-violet-300 mb-2`}),(0,K.jsx)(`div`,{className:`text-[15px] font-medium text-foreground mb-1`,children:t}),(0,K.jsx)(`p`,{className:`text-[13px] text-muted-foreground leading-normal mb-4`,children:n}),i]})}function fg({children:e,className:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sc,{}),(0,K.jsx)(Du,{children:(0,K.jsx)(`div`,{className:t,children:e})})]})}var pg=new Set([`com`,`co`,`org`,`net`,`edu`,`gov`,`mil`,`me`,`biz`,`info`,`ac`,`or`,`ne`,`go`,`lg`,`asn`,`id`,`nom`,`sch`,`ltd`,`plc`]);function mg(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&&pg.has(r)?3:2;return t.length<=i?`@`:t.slice(0,-i).join(`.`)}function hg({cluster:{fqdn:e},domain:{domain:t,id:n}}){let r=mg(t),[i,a,o]=Cu(r,e||``,n);return(0,K.jsxs)(`div`,{className:`grid gap-4 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap`,children:`This domain has been verified! Now to associate it with this cluster, add the following to your DNS registrar:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordName`,value:r,onClick:i}),(0,K.jsx)(F,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:i,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordTarget`,value:e,onClick:a}),(0,K.jsx)(F,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:a,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`domainId`,value:n,onClick:o}),(0,K.jsx)(F,{type:`button`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:o,children:(0,K.jsx)(sr,{className:`w-3 h-3`})})]})}),(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap italic text-sm`,children:`Select this domain using the checkbox to the left, then click "Bind" in the top right to finish associating it with this cluster.`})]})}function gg({certificate:e,domain:t,cluster:n}){let r=mg(t.domain),[i,a,o]=Cu(r,n.fqdn||``,t.id),s=(0,G.useMemo)(()=>e.issueDate&&!e.inProgress?{width:`100%`,color:`bg-green/80`,pulse:!1,text:`Certificate Issued`}:e.inProgress?{width:`100%`,color:`bg-yellow/80`,pulse:!0,text:`Generating Certificate...`}:{width:`100%`,color:`bg-gray-600`,pulse:!1,text:`Pending Certificate Generation...`},[e]);return(0,K.jsxs)(`div`,{className:`w-full max-w-2xl border border-border/50 rounded-md p-4 bg-gray-900/20`,children:[(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsx)(`div`,{className:`w-full h-1.5 rounded-full overflow-clip flex shadow-sm bg-gray-800`,children:(0,K.jsx)(`div`,{style:{width:s.width},className:`grow transition-[width] duration-1000 ease-in-out motion-reduce:transition-none ${s.color} ${s.pulse?`animate-pulse`:``}`})}),(0,K.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-light mt-1 italic`,children:s.text})]}),(0,K.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] text-sm`,children:[(0,K.jsx)(`div`,{className:`col-span-1 text-xs text-muted-foreground`,children:`CNAME:`}),(0,K.jsxs)(`div`,{className:`col-span-1 flex gap-2 items-center flex-wrap`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,K.jsx)(`span`,{className:`truncate max-w-[150px]`,title:r,children:r}),(0,K.jsx)(F,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:i,title:`Copy Name`,children:(0,K.jsx)(sr,{className:`w-3 h-3`})})]}),(0,K.jsx)(_g,{}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,K.jsx)(`span`,{className:`truncate max-w-[200px]`,title:n.fqdn||``,children:n.fqdn}),(0,K.jsx)(F,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:a,title:`Copy Target`,children:(0,K.jsx)(sr,{className:`w-3 h-3`})})]})]}),(0,K.jsx)(`div`,{className:`col-span-1 text-[10px] text-muted-foreground`,children:`Domain ID:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-[10px] text-muted-foreground italic`,children:[(0,K.jsx)(`span`,{className:`truncate max-w-[200px]`,children:t.id}),(0,K.jsx)(F,{type:`button`,variant:`ghost`,size:`sm`,className:`h-3 w-3 p-0`,onClick:o,title:`Copy ID`,children:(0,K.jsx)(sr,{className:`w-2.5 h-2.5`})})]})})]})]})}function _g(){return(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`w-3 h-3 text-muted-foreground`,children:[(0,K.jsx)(`path`,{d:`M5 12h14`}),(0,K.jsx)(`path`,{d:`m12 5 7 7-7 7`})]})}function vg(e){let{enabled:t,entityId:n,databaseName:r,tableName:i,searchAttribute:a,sort:o,pageIndex:s,pageSize:c,onlyIfCached:l,getAttributes:u}=e;return z({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:()=>yg(e)})}async function yg({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 bg(e){return z({queryKey:[e,`ChallengeCertificate`],queryFn:async()=>{if(!e)return[];let{data:t}=await yg({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:is(5e3),retry:as()})}function xg(e){return H(bg(e))}function Sg({domain:{challengeToken:e,challengeTxtRecord:t,domain:n,id:r},cluster:{fqdn:i}}){let a=mg(n),[o,s,c,l,u]=Cu(t,e,a,i||``,r);return(0,K.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap`,children:`Prove that you own this domain by adding the following to your DNS registrar:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TXT`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`challengeName`,value:t,onClick:o}),(0,K.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:o,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Content:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`challengeToken`,value:e,onClick:s}),(0,K.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:s,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap mt-4`,children:`While you're at it, you should also add the CNAME record to point to this cluster:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordName`,value:a,onClick:c}),(0,K.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:c,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`recordTarget`,value:i,onClick:l}),(0,K.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:l,children:(0,K.jsx)(sr,{className:`w-3.5 h-3.5`})})]})}),(0,K.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,K.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,K.jsx)(`input`,{className:`bg-transparent border-none outline-none w-full cursor-text truncate`,type:`text`,readOnly:!0,name:`domainId`,value:r,onClick:u}),(0,K.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:u,children:(0,K.jsx)(sr,{className:`w-3 h-3`})})]})}),(0,K.jsx)(`div`,{className:`text-muted-foreground md:col-span-2 text-wrap mt-2`,children:`Then after your DNS TTL elapses, click the "Validate" button above.`})]})}async function Cg({clusterId:e,domainIds:t,generateDomainCerts:n}){let{data:r}=await N.put(`/Cluster/${e}`,{domainIds:t,generateDomainCerts:n},{timeout:0});return r}function wg(){return R({mutationFn:e=>Cg(e)})}j.object({domainId:j.string()});async function Tg(e){let{data:t}=await N.delete(`/Domain/${e.domainId}`);return t}function Eg(){return R({mutationFn:e=>Tg(e)})}function Dg(e){return[...new Set(e)]}var Og=qp();function kg(e,t,n){let{data:r}=xg(e.id),i=(0,G.useMemo)(()=>!!r?.some(e=>!e.issueDate||e.inProgress),[r]),{mutate:a,isPending:o}=wg(),{mutate:s,isPending:c}=Eg(),l=o||c,u=(0,G.useCallback)((t,n)=>{if(!Yo(e.status)){U.error(`Cluster is currently `+e.status,{description:`To bind a domain, it must be running.`});return}a({clusterId:e.id,domainIds:Dg((e.domainIds?.slice()||[]).concat([t])),generateDomainCerts:n},{onSuccess:()=>{wi.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),U.success(`Domain bound!`+(n?` Certificates are being generated in the background now.`:``))}})},[a,e]),d=(0,G.useCallback)(t=>{s({domainId:t},{onSuccess:()=>{wi.invalidateQueries({queryKey:[e.organizationId,`domains`],refetchType:`active`}),U.success(`Domain removed!`)}})},[s]),f=(0,G.useCallback)(t=>{a({clusterId:e.id,domainIds:(e.domainIds?.slice()||[]).filter(e=>e!==t),generateDomainCerts:!1},{onSuccess:()=>{wi.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),U.success(`Domain unbound!`)}})},[s]);return(0,G.useMemo)(()=>[Og.display({id:`select`,header:`Bind`,size:50,cell:r=>{let a=r.row.original;return a.status===`ACTIVE`&&!a.clusterId&&!cu(e)?(0,K.jsx)(`label`,{className:`p-10 -m-10`,children:(0,K.jsx)(`input`,{type:`checkbox`,checked:t.includes(a.id),onChange:()=>n(a.id),disabled:l||i})}):null}}),Og.display({header:`Domains`,id:`domain`,enableSorting:!1,size:150,cell:e=>{let t=e.row.original;return(0,K.jsxs)(Va,{children:[(0,K.jsx)(Ha,{asChild:!0,children:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{children:t.domain}),(0,K.jsx)(F,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l||!!t.clusterId,onClick:()=>d(t.id),children:`Remove Domain`})]})}),(0,K.jsx)(Ua,{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!`})]})}}),Og.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,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{children:`Bound to this cluster`}),i&&(!i.issueDate||i.inProgress)&&(0,K.jsx)(`div`,{className:`py-2`,children:(0,K.jsx)(gg,{certificate:i,domain:n,cluster:e})}),(0,K.jsx)(F,{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,K.jsx)(Sg,{domain:n,cluster:e}):cu(e)?`Cannot be associated with this self-managed cluster.`:n.status===`ACTIVE`&&!n.clusterId?(0,K.jsx)(hg,{cluster:e,domain:n}):n.status}})],[e,u,l,r,i,t,n])}var Ag=j.object({domain:j.string(),organizationId:j.string()});async function jg(e){let{data:t}=await N.post(`/Domain/`,e);return t}function Mg(){return R({mutationFn:e=>jg(e)})}async function Ng(e){let{data:t}=await N.post(`/Domain/${e}/validate`);return t}async function Pg(e){let{data:t}=await N.get(`/Domain/?organizationId=${e}`);return t}function Fg(e){return z({queryKey:[e,`domains`],queryFn:()=>Pg(e)})}function Ig(){let{organizationId:e,clusterId:t}=B({strict:!1}),{data:n}=de(cs(t,!0)),{update:r}=Jl(e),{data:i,refetch:a,isFetching:o,isRefetching:s}=H(Fg(e)),c=(0,G.useMemo)(()=>i?.filter(e=>e.status===`PENDING_VALIDATION`)||[],[i]),[l]=(0,G.useState)({attribute:`domain`,descending:!1}),u=(0,G.useMemo)(()=>[{desc:l.descending,id:l.attribute}],[l]),d=$p(a),[f,p]=(0,G.useState)([]),m=(0,G.useCallback)(e=>{p(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),{mutate:g,isPending:_}=wg(),v=(0,G.useCallback)(()=>{if(!Yo(n.status)){U.error(`Cluster is currently `+n.status,{description:`To bind a domain, it must be running.`});return}g({clusterId:n.id,domainIds:Dg((n.domainIds?.slice()||[]).concat(f)),generateDomainCerts:!0},{onSuccess:()=>{wi.invalidateQueries({queryKey:[n.organizationId],refetchType:`active`}),U.success(`Domain(s) bound! Certificates are being generated in the background now.`),p([])}})},[n,f,g]),{mutateAsync:y,isPending:b}=Mg(),x=Pt({resolver:Ke(Ag),defaultValues:{domain:``,organizationId:e}}),S=(0,G.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(),U.success(`${h(t.length,`Domain`,`Domains`)} added! Please add the txt record above to your domain registrar.`)}},[y,x,a]),C=(0,G.useCallback)(async()=>{let e=`Validating ${h(c.length,`domain`,`domains`)}...`,t=`validatingDomains`,n=0,r=0;for(let i of c)try{U.loading(e,{description:`${n++} of ${c.length} checked`,id:t}),await Ng(i.id)}catch{r+=1}r>0?U.error(`Validation failed!`,{description:`Please make sure the TXT record has been put in place. You may need to wait a bit for the DNS change to propagate.`,id:t}):(await a(),U.success(`Validation succeeded!`,{description:`Please take a look at the next steps for newly verified domains.`,id:t}))},[c]),w=kg(n,f,m),T=x.watch(`domain`),E=(0,G.useMemo)(()=>typeof T==`string`&&T.trim().split(`.`).length===2,[T]),D=(0,G.useCallback)(()=>{typeof T==`string`&&x.setValue(`domain`,`${T.trim()}, www.${T.trim()}`)},[T,x]);return(0,K.jsx)(Jp,{data:i||[],isFetching:o||s,columns:w,sortingState:u,children:(0,K.jsxs)(`div`,{className:`w-full flex flex-col md:flex-row items-center md:justify-between md:space-x-2 space-y-2 md:space-y-0`,children:[r&&(0,K.jsx)(Io,{...x,children:(0,K.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,K.jsx)(Y,{control:x.control,name:`domain`,render:({field:e})=>(0,K.jsxs)(X,{className:`flex-1`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`New Domain Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,enterKeyHint:`done`,autoComplete:`off`,...e})}),E&&(0,K.jsxs)(`div`,{className:`mt-1 flex gap-4`,children:[`Adding an apex domain?`,(0,K.jsx)(F,{variant:`positiveOutline`,type:`button`,onClick:D,children:`Add www as well`})]}),(0,K.jsx)(Q,{children:(0,K.jsx)(`span`,{className:`text-muted-foreground italic`,children:`Type in a domain like example.com or your.example.com, and you'll be guided through validating and binding your cluster to it.`})})]})}),(0,K.jsxs)(`div`,{className:`flex-0 self-start flex gap-1 md:pt-6.5`,children:[(0,K.jsxs)(F,{type:`submit`,variant:`submit`,disabled:b,children:[(0,K.jsx)(Gr,{}),` Add`]}),c.length>0&&(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:C,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,K.jsx)(kr,{}),` `,(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`V`}),`alidate`]})]}),(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:d,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,K.jsx)(Kr,{}),` `,(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]})]})]})}),f.length>0&&(0,K.jsx)(`div`,{className:`flex-0 self-start md:pt-6.5`,children:(0,K.jsxs)(F,{variant:`submit`,onClick:v,disabled:_,children:[(0,K.jsx)(Xr,{}),` Bind `,h(f.length,`Domain`,`Domains`)]})})]})})}function Lg(){return(0,K.jsx)(fg,{className:`flex flex-col justify-start max-w-4xl`,children:(0,K.jsx)(Ig,{})})}var Rg=b({username:ds,role:M().nonempty({error:`Please select a role.`}),password:us.min(8,{error:`Password must be at least 8 characters long.`}),confirmPassword:M()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});async function zg(e){await N.patch(`/ResetPasswordUpdater/${e}`)}async function Bg(e){let{instanceClient:t,...n}=e,{data:r}=await t.post(`/`,{operation:`add_user`,...n});return r}function Vg(){return R({mutationFn:Bg})}async function Hg({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 Ug(){return R({mutationFn:Hg})}async function Wg({username:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_user`,username:e});return n}function Gg(){return R({mutationFn:Wg})}async function Kg({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 Wo({username:t,password:i,instanceClient:o,entityId:e});return a.instanceClient&&(o=a.instanceClient),n===`HDB_ADMIN`?await Hg({username:n,password:r,instanceClient:o}):(await Bg({username:n,password:r,role:`super_user`,active:!0,instanceClient:o}),await Wo({username:n,password:r,instanceClient:o,entityId:e}),await Wg({username:g,instanceClient:o})),await zg(e),a}catch(t){throw await d({entityId:e,instanceClient:o}),t}}function qg(){return R({mutationFn:Kg})}function Jg(){let{user:e}=wn(),{clusterId:t}=B({strict:!1}),{data:n}=H(cs(t,!0)),r=L(),i=oe(),a=(0,G.useMemo)(()=>c(n),[n]),o=Ga({operationsUrl:a}),{redirect:s}=le({strict:!1}),l=se(),d=Pt({resolver:Ke(Rg),defaultValues:{confirmPassword:``,password:``,role:`super_user`,username:e?.email??``}}),{setFocus:f,control:p,handleSubmit:m}=d;(0,G.useEffect)(()=>{f(`password`)},[f]);let h=n?.instances?.find(e=>e.tempPassword)?.tempPassword,_=es(n),{mutate:v,isPending:y}=qg(),b=(0,G.useCallback)(async e=>{if(!a){U.error(`Cluster is not yet fully loaded, please wait a moment before trying to sign in.`);return}if(!_){U.error(`Some instances are still starting up. You can create your admin user once they are all running.`);return}v({instanceClient:o,clusterId:t,newPassword:e.password,tempPassword:h,initialUsername:g,desiredUsername:e.username},{onSuccess:async({message:e,user:a})=>{U.success(e),u.setUserForEntity(n,a),await ss(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,K.jsx)(re,{to:`../sign-in`,replace:!0}):n&&!_?(0,K.jsx)(re,{to:`../starting-up`,replace:!0}):(0,K.jsxs)(K.Fragment,{children:[(0,K.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,K.jsx)(Fo,{})}),(0,K.jsx)(`div`,{className:`items-center justify-center flex mt-32 py-4 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsxs)(`div`,{className:`text-foreground w-xs`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light`,children:`Create Admin User`}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:`You are ready to create your first user in your new cluster. These credentials belong to you alone, and you can create more users and roles once you create this first one.`}),(0,K.jsx)(Io,{...d,children:(0,K.jsxs)(`form`,{id:`cluster-create-admin-form`,name:`cluster-create-admin-form`,onSubmit:m(b),className:`my-4`,children:[(0,K.jsx)(Y,{control:p,name:`username`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Username`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{autoComplete:`username`,type:`text`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:p,name:`password`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,autoComplete:`new-password`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:p,name:`confirmPassword`,render:({field:e})=>(0,K.jsxs)(X,{className:`my-4`,children:[(0,K.jsx)(Z,{children:`Confirm Password`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`password`,autoComplete:`new-password`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(F,{disabled:y,type:`submit`,variant:`submit`,className:`w-full my-2`,children:`Create Admin User`})]})}),(0,K.jsxs)(`p`,{className:`text-muted-foreground flex gap-2 align-middle`,children:[(0,K.jsx)(Fn,{size:36,className:`flex-none`}),(0,K.jsx)(`span`,{children:`These credentials will be used to sign into your cluster directly, providing you a secure connection from your browser to your cluster.`})]})]})})]})}function Yg({columns:e,data:t,renderRowWrapper:n}){let r=Me({features:Kp,data:t,columns:e});return(0,K.jsx)(`div`,{className:`bg-card dark:bg-black-dark rounded-md`,children:(0,K.jsxs)(zp,{children:[(0,K.jsx)(Bp,{children:r.getHeaderGroups().map(e=>(0,K.jsx)(Hp,{className:`border-none`,children:e.headers.map(e=>(0,K.jsx)(Up,{className:`p-4`,style:{width:`${e.getSize()}%`},children:e.isPlaceholder?null:De(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,K.jsx)(Vp,{className:`bg-background dark:bg-black`,children:r.getRowModel().rows?.length?r.getRowModel().rows.map(e=>{let t=(0,K.jsx)(Hp,{"data-state":e.getIsSelected()&&`selected`,className:`hover:bg-muted/10 data-[state=selected]:bg-muted`,children:e.getVisibleCells().map(e=>(0,K.jsx)(Gp,{className:`p-4`,style:{width:`${e.column.getSize()}%`},children:De(e.column.columnDef.cell,e.getContext())},e.id))});return(0,K.jsx)(G.Fragment,{children:n?n(e.original,t):t},e.id)}):(0,K.jsx)(Hp,{children:(0,K.jsx)(Gp,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function Xg(){return(0,K.jsx)(`div`,{className:`flex-col items-center justify-center px-16 space-y-3 text-center pt-30`,children:(0,K.jsx)(`p`,{children:`No instances found.`})})}async function Zg({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 Qg({instanceId:e,action:t,safeMode:n}){let r=n===void 0?{}:{safeMode:n},{data:i}=await N.post(`/HDBInstance/${e}/container/${t}`,r);return i}function $g(){return R({mutationFn:Qg})}var e_={stop:`Stopping`,start:`Starting`,restart:`Restarting`};function t_(e){let{clusterId:t}=B({strict:!1}),{mutateAsync:n,isPending:r}=$g(),i=oe();return{run:(0,G.useCallback)(async(r,a)=>{let o=a?.label??e_[r],s=e.name??e.id,c=U.loading(o,{description:`${o} ${s}. Status will update shortly.`,duration:3e4,action:{label:`Dismiss`,onClick:()=>U.dismiss()}});try{await n({instanceId:e.id,action:r,safeMode:a?.safeMode}),t&&i.invalidateQueries({queryKey:[t]}),i.invalidateQueries({queryKey:[e.id]}),U.dismiss(c),U.success(`Request accepted`,{description:`${s} is ${o.toLowerCase()}. The status will update automatically.`,action:{label:`Dismiss`,onClick:()=>U.dismiss()}})}catch{U.dismiss(c)}},[t,e.id,e.name,n,i]),isPending:r}}function n_({entityId:e,instanceClient:t},n){return z({queryKey:[`get_status`,e],staleTime:9e3,refetchInterval:is(1e4),retry:as(),retryDelay:1e4,throwOnError:!1,enabled:n,queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`get_status`});return e}})}function r_(e,t){return e?.systemStatus?.find(e=>e.id===t)?.status}async function i_({instanceClient:e,id:t,status:n}){let{data:r}=await e.post(`/`,{operation:`set_status`,id:t,status:n});return r}function a_(){return R({mutationFn:i_,onSuccess:(e,t)=>wi.invalidateQueries({queryKey:[`get_status`,t.entityId]})})}var o_=[`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`];function s_(e,t,n){let{user:r}=Dn(e.id),i=(0,G.useMemo)(()=>p(e),[e]),a=Ga({operationsUrl:i}),{update:o}=$l(),s=u.checkForFabricConnect(e.id),c=q({operationsUrl:i,instanceId:e.id,forceFabricConnect:!0}),{data:l}=H(n_(c,n&&o&&!Jo(e.status))),d=r_(l,`availability`)||`Unknown`,f=d===`Available`,m=d===`Unavailable`,{mutate:h,isPending:g}=a_(),{run:_,isPending:v}=t_(e),[y,b]=(0,G.useState)(null),x=e.instanceFqdn,S=gp({secure:e.operationsApiSecure?`true`:`false`,port:e.operationsApiPort,fqdn:e.instanceFqdn}),[C,w]=Cu(x??``,S),T=(0,G.useCallback)(async()=>{await Zg({instance:e,instanceClient:a})},[e,a]),E=!!e.status&&o_.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,K.jsx)($r,{className:`text-green`}),label:`Direct Connect`},O&&D&&{key:`direct-sign-out`,onClick:T,variant:`destructive`,icon:(0,K.jsx)(Nr,{}),label:`Direct Sign Out`},O&&!D&&o&&!t&&{key:`fabric-connect`,to:`../instance/${e.id}/`,icon:(0,K.jsx)($r,{className:`text-green`}),label:`Fabric Connect`},O&&!D&&{key:`direct-sign-in`,to:`../instance/${e.id}/sign-in`,icon:(0,K.jsx)(jr,{}),label:`Direct Sign In`},O&&k&&{type:`separator`,key:`copy-sep`},k&&{key:`copy-fqdn`,onClick:C,icon:(0,K.jsx)(nr,{}),label:`Copy Instance FQDN`},k&&{key:`copy-api`,onClick:w,icon:(0,K.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,K.jsx)(ni,{}),label:`Bring out of rotation`},A&&m&&{key:`into-rotation`,disabled:g,onClick:()=>h({...c,id:`availability`,status:`Available`}),icon:(0,K.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,K.jsx)(Wr,{}),label:`Start`},M&&ee&&{key:`container-start-safe`,disabled:v,onClick:()=>b(`start`),icon:(0,K.jsx)(Or,{}),label:`Start in safe mode`},M&&j&&{key:`container-restart`,disabled:v,onClick:()=>void _(`restart`,{safeMode:!1}),icon:(0,K.jsx)(Yr,{}),label:`Restart`},M&&j&&{key:`container-restart-safe`,disabled:v,onClick:()=>b(`restart`),icon:(0,K.jsx)(Or,{}),label:`Restart in safe mode`},M&&j&&{key:`container-stop`,variant:`destructive`,disabled:v,onClick:()=>void _(`stop`),icon:(0,K.jsx)(ai,{}),label:`Stop`}].filter($a),P=(0,K.jsx)(mu,{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 c_({instance:e,isSelfManaged:t}){let[n,r]=(0,G.useState)(!1),{items:i,dialog:a}=s_(e,t,n);return i.length?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Ti,{open:n,onOpenChange:r,children:[(0,K.jsx)(Ei,{asChild:!0,children:(0,K.jsx)(F,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Instance options`,children:(0,K.jsx)(ur,{})})}),(0,K.jsx)(Di,{align:`end`,className:`min-w-48`,children:Mc(i,`dropdown`)})]}),a]}):null}function l_({isSelfManaged:e,instance:t}){let{user:n,isLoading:r}=Dn(t.id),i=Ga({operationsUrl:(0,G.useMemo)(()=>p(t),[t])}),{update:a}=$l(),o=u.checkForFabricConnect(t.id),s=(0,G.useCallback)(async()=>{await Zg({instance:t,instanceClient:i})},[t,i]);return Jo(t.status)?(0,K.jsx)(`span`,{className:`text-muted-foreground text-sm`,children:`—`}):r||!t.status||![`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`].includes(t.status)?(0,K.jsx)(Ar,{className:`animate-spin`,color:`gray`}):!n||o?(0,K.jsxs)(`span`,{className:`flex gap-4`,children:[a&&!e&&(0,K.jsx)(V,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Connect to ${t.name} instance`,title:`Connect to ${t.name} instance`,children:(0,K.jsx)(F,{variant:`positiveOutline`,children:`Fabric Connect`})}),(0,K.jsx)(V,{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,K.jsx)(F,{variant:a?`defaultOutline`:`positiveOutline`,children:`Direct Sign In`})})]}):(0,K.jsxs)(`span`,{className:`flex gap-4`,children:[(0,K.jsx)(V,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Go to ${t.name} instance`,title:`Go to ${t.name} instance`,children:(0,K.jsx)(F,{variant:`positiveOutline`,children:`Direct Connect`})}),(0,K.jsx)(F,{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 u_({instance:e,isSelfManaged:t,children:n}){let[r,i]=(0,G.useState)(!1),{items:a,dialog:o}=s_(e,t,r);return a.length?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(wc,{onOpenChange:i,children:[(0,K.jsx)(Tc,{asChild:!0,children:n}),(0,K.jsx)(Ec,{className:`min-w-48`,children:Mc(a,`context`)})]}),o]}):(0,K.jsx)(K.Fragment,{children:n})}function d_({instance:e,index:t}){let{update:n}=$l(),r=q({operationsUrl:(0,G.useMemo)(()=>p(e),[e]),instanceId:e.id,forceFabricConnect:!0}),{mutate:i,isPending:a}=a_(),[o,s]=(0,G.useState)(!1);(0,G.useEffect)(()=>{let e=setTimeout(()=>s(!0),t*500);return()=>clearTimeout(e)},[t]);let c=Jo(e.status),{data:l,isLoading:u,isFetching:d}=H(n_(r,o&&n&&!c)),f=r_(l,`availability`)||`Unknown`,m=f===`Available`,h=f===`Unavailable`;return n?c?(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(Va,{children:[(0,K.jsx)(Ha,{asChild:!0,children:(0,K.jsx)(`span`,{className:`inline-block size-4 rounded-full bg-muted-foreground/40`,"aria-label":`Not running`})}),(0,K.jsx)(Ua,{children:`Not running`})]})}):(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(Va,{children:[(0,K.jsx)(Ha,{asChild:!0,children:(0,K.jsx)(`div`,{className:`flex items-center`,children:u||!o||d&&!l?(0,K.jsx)(Ar,{className:`animate-spin size-5 text-muted-foreground`}):(0,K.jsx)(Yi,{variant:m?`success`:h?`destructive`:`default`,className:`size-4 rounded-full p-0`,children:(0,K.jsx)(`span`,{className:`sr-only`,children:m?`Online`:`Offline`})})})}),(0,K.jsxs)(Ua,{children:[d&&l?`Refreshing... `:``,f]})]}),n&&(0,K.jsxs)(`div`,{className:`flex gap-1`,children:[m&&(0,K.jsxs)(Va,{children:[(0,K.jsx)(Ha,{asChild:!0,children:(0,K.jsx)(F,{type:`button`,variant:`destructiveGhost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Unavailable`}),disabled:a,children:a?(0,K.jsx)(Ar,{className:`animate-spin size-4`}):(0,K.jsx)(ni,{className:`size-4`})})}),(0,K.jsx)(Ua,{children:`Bring out of rotation`})]}),h&&(0,K.jsxs)(Va,{children:[(0,K.jsx)(Ha,{asChild:!0,children:(0,K.jsx)(F,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Available`}),disabled:a,children:a?(0,K.jsx)(Ar,{className:`animate-spin size-4`}):(0,K.jsx)(ti,{className:`size-4`})})}),(0,K.jsx)(Ua,{children:`Bring back into rotation`})]})]})]}):null}function f_(){let{clusterId:e}=B({strict:!1}),{data:t,isLoading:n}=H(cs(e,!0)),r=cu(t),i=(0,G.useMemo)(()=>[{id:`instanceActions`,size:1,minSize:1,cell:e=>(0,K.jsx)(`div`,{className:`flex justify-end gap-2 items-center`,children:(0,K.jsx)(l_,{isSelfManaged:r,instance:e.row.original})})},r&&{accessorKey:`instanceFqdn`,size:90,header:`URL`,cell:e=>gp({secure:e.row.original.operationsApiSecure?`true`:`false`,port:e.row.original.operationsApiPort,fqdn:e.row.original.instanceFqdn})},!r&&{accessorKey:`name`,size:90,header:`Name`},!r&&{accessorKey:`status`,header:`Status`,size:1,minSize:1,cell:e=>{let t=e.getValue();return(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(d_,{instance:e.row.original,index:e.row.index}),t?(0,K.jsx)(Yi,{variant:qo(t),children:No(t)}):null,e.row.original.safeMode&&!Jo(e.row.original.status)?(0,K.jsxs)(Yi,{variant:`warning`,title:`Running in safe mode — user apps/components are not loaded`,children:[(0,K.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,K.jsxs)(K.Fragment,{children:[e.row.original.cpuCores,` / `,e.row.original.threads]})},!r&&{accessorKey:`memoryMb`,size:1,minSize:1,header:`Memory`,cell:e=>`${e.getValue()/1024} GB`},{id:`instanceMenu`,size:1,minSize:1,cell:e=>(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsx)(c_,{isSelfManaged:r,instance:e.row.original})})}].filter($a),[r]),a=(0,G.useMemo)(()=>t?.instances?t.instances.filter(e=>e.status&&!Ho.includes(e.status)).sort(Bu):[],[t]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sc,{}),(0,K.jsx)(Du,{children:(0,K.jsx)(On,{className:`p-0 min-h-96`,children:(0,K.jsx)(Mn,{className:`p-0 min-h-96`,children:n?(0,K.jsx)(Af,{}):a.length?(0,K.jsx)(Yg,{data:a,columns:i,renderRowWrapper:(e,t)=>(0,K.jsx)(u_,{instance:e,isSelfManaged:r,children:t})}):(0,K.jsx)(Xg,{})})})})]})}function p_(){let{clusterId:e}=B({strict:!1}),{immediate:t}=le({strict:!1}),n=t===!0||t===`true`,{data:r,isLoading:i}=H(cs(e,2e3)),a=r?.status,o=(0,G.useMemo)(()=>a&&Vo.includes(a),[a]);return i||!r?(0,K.jsx)(fg,{className:`flex justify-center`,children:(0,K.jsx)(Af,{})}):o?(0,K.jsx)(fg,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`All done!`}),(0,K.jsx)(pu,{cluster:r,forceProgressBarVisible:!0}),(0,K.jsx)(`p`,{children:`Your cluster finished updating, and is ready for interaction.`}),(0,K.jsx)(`div`,{className:`text-center`,children:(0,K.jsx)(lu,{cluster:r})})]})}):(0,K.jsx)(fg,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,K.jsx)(pu,{cluster:r,forceProgressBarVisible:!0}),(0,K.jsxs)(`p`,{children:[n?`Your cluster is applying the latest changes immediately, without waiting to take instances out of rotation.`:`Your cluster is updating with the latest changes. This includes waiting several minutes to let traffic drain safely.`,` `,(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[`We will let you know when we are ready for you to connect! In the meantime, join us on`,` `,(0,K.jsx)(`a`,{href:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,children:`Discord`}),`! Get real-time help from our engineers, see feature drops early, and connect with others building on Fabric.`]})]})]})})}function m_({children:e,className:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sc,{}),(0,K.jsx)(`div`,{className:_(`mt-32 px-4 py-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] flex justify-center`,t),children:e})]})}function h_(){let e=se(),{clusterId:t}=B({strict:!1}),{data:n,isLoading:r}=H(cs(t,2e3)),i=n?.status,a=(0,G.useMemo)(()=>i&&Vo.includes(i)&&es(n),[i,n]),o=Xo(i),[,s]=xn(vn.SavedClusterState,null),c=(0,G.useCallback)(()=>{s(n),e.navigate({to:`/${n.organizationId}/new-cluster`})},[n,e,s]);return r||!n?(0,K.jsx)(m_,{className:`flex justify-center`,children:(0,K.jsx)(Af,{})}):o?(0,K.jsx)(m_,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4 items-center`,children:[(0,K.jsx)(rr,{className:`w-24 h-24`}),(0,K.jsxs)(`span`,{children:[`Your cluster failed to successfully start. This is usually caused by temporary communication problems. Would you like to try again? We also get notified about these failures. `,(0,K.jsx)(ys,{}),` if you want more help.`]}),(0,K.jsx)(F,{type:`button`,variant:`positiveOutline`,onClick:c,children:`Try Again`})]})}):a?(0,K.jsx)(m_,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`It's ready!`}),(0,K.jsx)(pu,{cluster:n,forceProgressBarVisible:!0}),(0,K.jsxs)(`p`,{children:[`Let's set up your secure, browser-to-cluster connection now.`,` `,(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Did you know during this step, you connect straight to your cluster, providing a private secure connection? That's `,(0,K.jsx)(`em`,{children:`Direct Connect`}),`! Once you create your user, you will have the option to`,` `,(0,K.jsx)(`em`,{children:`Fabric Connect`}),` from your Fabric account without having to sign in again.`]})]}),(0,K.jsx)(`div`,{className:`text-center`,children:(0,K.jsx)(lu,{cluster:n})})]})}):(0,K.jsx)(m_,{className:`flex justify-center`,children:(0,K.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,K.jsx)(pu,{cluster:n,forceProgressBarVisible:!0}),(0,K.jsxs)(`p`,{children:[`Your cluster is spinning up with the latest changes, including your own DNS records and private connections. Please wait while we get everything going.`,` `,(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[`We will let you know when we are ready for you to connect! In the meantime, join us on`,` `,(0,K.jsx)(`a`,{href:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,children:`Discord`}),`! Get real-time help from our engineers, see feature drops early, and connect with others building on Fabric.`]})]})]})})}function g_(){let{clusterId:e}=B({strict:!1}),{data:t,isLoading:n}=Qh(e);if(n)return(0,K.jsxs)(fg,{className:`max-w-4xl pb-20`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:`Usage`}),(0,K.jsx)(`div`,{className:`flex justify-center py-16 text-muted-foreground`,children:(0,K.jsx)(Ar,{className:`size-6 animate-spin`})})]});let r=t&&!t.selfManaged?S_(t.regions):null;return(0,K.jsxs)(fg,{className:`max-w-4xl pb-20`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:`Usage`}),t?t.selfManaged?(0,K.jsx)(T_,{children:`Usage isn't tracked for self-hosted clusters — they run under their own license.`}):t.regions.length===0?(0,K.jsx)(T_,{children:`No usage has been recorded for the current cycle yet.`}):(0,K.jsxs)(`div`,{className:`mt-5 space-y-3`,children:[t.regions.map(e=>(0,K.jsx)(__,{region:e,showPlanInfo:r==null},e.region??e.regionIds.join())),r&&(0,K.jsx)(v_,{header:(0,K.jsx)(y_,{title:`Plan limits & resources`}),aside:r.planId??void 0,children:(0,K.jsx)(b_,{rateLimits:r.rateLimits,resourcesPerInstance:r.resourcesPerInstance})})]}):(0,K.jsx)(E_,{})]})}function __({region:e,showPlanInfo:t}){let n=Jh.map(t=>Yh(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 ${x_(e.expiresAt)}`:null].filter(Boolean).join(` · `);return(0,K.jsxs)(v_,{defaultOpen:e.status!==`lapsed`,aside:e.regionIds.length>0?e.regionIds.join(`, `):void 0,header:(0,K.jsxs)(y_,{title:e.region??`Region`,meta:r,children:[e.status===`exhausted`&&(0,K.jsx)(`span`,{className:`rounded-full bg-yellow/10 px-2 py-0.5 text-[11px] text-yellow`,children:`Cycle exhausted`}),e.status===`lapsed`&&(0,K.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground`,children:`No active license`})]}),children:[(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-x-10 gap-y-4 sm:grid-cols-2`,children:n.map(e=>(0,K.jsx)(Xh,{...e},e.label))}),t&&(0,K.jsx)(b_,{rateLimits:e.rateLimits,resourcesPerInstance:e.resourcesPerInstance})]})}function v_({header:e,aside:t,defaultOpen:n=!0,children:r}){let[i,a]=(0,G.useState)(n);return(0,K.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-border`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),"aria-expanded":i,className:`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-accent/40`,children:[(0,K.jsx)(Jn,{className:`size-4 shrink-0 text-muted-foreground transition-transform ${i?`rotate-90`:``}`}),(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:e}),t&&(0,K.jsx)(`span`,{className:`shrink-0 self-start pt-0.5 font-mono text-[11px] text-muted-foreground/70`,children:t})]}),i&&(0,K.jsx)(`div`,{className:`border-t border-border px-4 py-4`,children:r})]})}function y_({title:e,meta:t,children:n}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e}),n]}),t&&(0,K.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t})]})}function b_({rateLimits:e,resourcesPerInstance:t}){let n=e,r=n?w_([[`Reads / minute`,n.readsPerMinute,np],[`Read bandwidth / minute`,n.readsPerMinuteBytes,tp],[`Writes / minute`,n.writesPerMinute,np],[`Write bandwidth / minute`,n.writesPerMinuteBytes,tp],[`Real-time deliveries / minute`,n.realTimeDeliveriesPerMinute,np],[`Real-time bandwidth / minute`,n.realTimeDeliveryBytesPerMinute,tp],[`TLS handshakes (cycle)`,n.tlsHandshakes,np]]):[],i=t,a=i?C_([[`Storage`,i.storageGb,e=>`${np(e)} GB`],[`Memory`,i.memoryMb,e=>tp(e*1e3*1e3)],[`vCPU`,i.cpuCores,e=>`${e} ${e===1?`core`:`cores`}`],[`Threads`,i.threads,e=>String(e)]]):[];return(0,K.jsxs)(K.Fragment,{children:[r.length>0&&(0,K.jsx)(D_,{title:`Rate limits`,subtitle:`Throughput ceilings — not part of the cycle allotment, and not metered.`,children:(0,K.jsx)(O_,{rows:r})}),a.length>0&&(0,K.jsx)(D_,{title:`Per-instance resources`,subtitle:`Provisioned capacity on each instance.`,children:(0,K.jsx)(O_,{rows:a})})]})}function x_(e){return new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))}function S_(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 C_(e){return e.filter(e=>typeof e[1]==`number`&&e[1]>0).map(([e,t,n])=>[e,n(t)])}function w_(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 T_({children:e}){return(0,K.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:e})}function E_(){return(0,K.jsx)(`div`,{role:`alert`,className:`mt-5 rounded-xl border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive`,children:`Couldn't load usage data — refresh to try again.`})}function D_({title:e,subtitle:t,children:n}){return(0,K.jsxs)(`div`,{className:`mt-6 first:mt-0`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:e}),(0,K.jsx)(`p`,{className:`mt-0.5 mb-3 text-xs text-muted-foreground`,children:t}),n]})}function O_({rows:e}){return(0,K.jsx)(`dl`,{className:`grid grid-cols-1 gap-x-10 gap-y-2 sm:grid-cols-2`,children:e.map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 border-b border-border/60 py-1.5 text-sm`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,K.jsx)(`dd`,{className:`text-foreground tabular-nums`,children:t})]},e))})}I({getParentRoute:()=>Hh,path:`instances`,head:()=>({meta:[{title:`Instances — Harper Fabric`}]}),component:f_}),I({getParentRoute:()=>Hh,path:`starting-up`,head:()=>({meta:[{title:`Starting Up — Harper Fabric`}]}),component:h_}),I({getParentRoute:()=>Hh,path:`scaling`,head:()=>({meta:[{title:`Scaling — Harper Fabric`}]}),component:p_}),I({getParentRoute:()=>Hh,path:`domains`,head:()=>({meta:[{title:`Domains — Harper Fabric`}]}),component:Lg}),I({getParentRoute:()=>Hh,path:`usage`,head:()=>({meta:[{title:`Usage — Harper Fabric`}]}),component:g_});function k_({location:e,params:t}){let n=u.checkForFabricConnect(t.clusterId);if(u.getConnectionById(t.clusterId).user&&!n){let t=e?.search?.redirect;throw ie({to:t?.startsWith(`/`)?t:`../`})}}function A_({location:e,params:t}){let n=u.checkForFabricConnect(t.instanceId);if(u.getConnectionById(t.instanceId).user&&!n){let t=e?.search?.redirect;throw ie({to:t?.startsWith(`/`)?t:`../`})}}I({getParentRoute:()=>Hh,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:vs,beforeLoad:k_}),I({getParentRoute:()=>Hh,path:`instance/$instanceId/sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:vs,beforeLoad:A_}),I({getParentRoute:()=>Hh,path:`finish-setup`,head:()=>({meta:[{title:`Create Admin User — Harper Fabric`}]}),component:Jg}),I({getParentRoute:()=>Hh,path:`/`,head:()=>({meta:[{title:`Cluster — Harper Fabric`}]}),component:ag});function j_(e){return I({getParentRoute:()=>e,path:`apis`,head:()=>({meta:[{title:`APIs — Harper Fabric`}]})}).lazy(()=>ze(()=>import(`./index.lazy-PVbC6xQh.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 M_(e,t){return[I({getParentRoute:()=>e,path:t===`cluster`?`apps`:`/`,head:()=>({meta:[{title:`Applications — Harper Fabric`}]}),component:ye(()=>ze(()=>import(`./applications-C6Y4nL_X.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 N_({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_certificates`});return t}function P_(e){return z({queryKey:[e.entityId,`list_certificates`],queryFn:()=>N_(e)})}var F_=[{header:`Certificate Name`,accessorKey:`name`,enableSorting:!0},{header:`Issuer`,accessorKey:`details.issuer`,enableSorting:!0},qp().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 I_({className:e,...t}){return(0,K.jsx)(`textarea`,{"data-slot":`input`,className:P(`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
- `),hy=`inmemory://harper/config-root.json`,gy=`harper://schemas/config-root.json`;async function _y(){let{json:e}=await ze(async()=>{let{json:e}=await import(`./languageServices-D_06p7dw.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===gy)||t.setDiagnosticsOptions({...r,validate:!0,enableSchemaRequest:!1,schemas:[...n,{uri:gy,fileMatch:[hy],schema:my}]})}var vy=({children:e})=>(0,K.jsx)(K.Fragment,{children:e});function yy(){let{clusterId:e,instanceId:t}=B({strict:!1}),{data:n,isLoading:r}=H(ey({clusterId:e,instanceId:t})),i=q(),{version:a}=te({strict:!1}),{data:o}=H(cy(i,!1));n?.cluster;let s=n?.instance,{data:c,isLoading:l}=H(wv(i)),{data:u,isLoading:d}=H(sy(i)),f=nu(),{data:p,isLoading:m}=H(oy({...i,enabled:f})),h=(0,G.useMemo)(()=>{if(!p)return null;let e=0,t=n=>{n.mtime&&(e=Math.max(e,new Date(n.mtime).getTime())),`entries`in n&&n.entries&&n.entries.forEach(t)};return t(p),e||null},[p]),g=(0,G.useMemo)(()=>u?dy(u):null,[u]),_=dm(),[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(``),[S,C]=(0,G.useState)(null),[w,T]=(0,G.useState)([]),{onConfigUpdate:E,isPending:D}=iy();(0,G.useEffect)(()=>{g&&!v&&(x(JSON.stringify(g,null,4)),C(null),T([]))},[g,v]);let O=(0,G.useCallback)(e=>{if(x(e||``),e)try{let t=JSON.parse(e);C(null);let n=[],r=(e,t,i=``)=>{for(let a in e){let o=i?`${i}.${a}`:a,s=e[a],c=t?.[a];uy(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||uy(a,void 0,t[r])&&n.push(a)}};g&&r(t,g),T(n)}catch(e){C(e.message),T([])}},[u]),k=(0,G.useCallback)(()=>{_y().catch(e=>{console.error(`Failed to register the Harper config JSON Schema:`,e)})},[]),A=(0,G.useCallback)(()=>{if(!(S||w.length>0))try{let e=JSON.parse(b),t=py(fy(g,e));E(t),y(!1)}catch(e){C(e.message)}},[b,S,E,g,w.length]);return(0,G.useMemo)(()=>[],[o,s]),(0,K.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,K.jsx)(vy,{children:(0,K.jsxs)(`dl`,{className:`grid grid-cols-1 sm:grid-cols-3`,children:[(0,K.jsx)(`div`,{className:`px-4 pb-4 sm:col-span-1 sm:px-0`,children:(0,K.jsx)(ty,{loadingRegistration:l,registrationInfo:c})}),(0,K.jsx)(`div`,{className:`px-4 pb-4 sm:col-span-1 sm:px-0`,children:(0,K.jsx)(ny,{loading:m,timestamp:h})}),(0,K.jsx)(`div`,{className:`px-4 pb-4 text-right sm:col-span-1 sm:px-0`,children:(0,K.jsx)(Jv,{targetNoun:`Instance`,instanceClient:i.instanceClient,operation:`restart`})})]})}),(0,K.jsxs)(`div`,{className:`flex-none flex items-center justify-between mb-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h3`,{className:`font-bold text-sm/6`,children:[`Instance Config `,v?`(editing)`:`(read only)`]}),!t&&!1]}),(0,K.jsx)(`div`,{className:`flex items-center gap-2 pr-4`,children:v?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(F,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>y(!1),children:[(0,K.jsx)(gn,{className:`w-4 h-4 mr-1`}),` Cancel`]}),(0,K.jsxs)(F,{size:`sm`,disabled:!!S||w.length>0||D,onClick:A,children:[(0,K.jsx)(Xr,{className:`w-4 h-4 mr-1`}),` `,D?`Saving...`:`Save & Restart`]})]}):(0,K.jsxs)(F,{size:`sm`,onClick:()=>y(!0),children:[(0,K.jsx)(ii,{className:`w-4 h-4 mr-1`}),` Edit`]})})]}),S&&(0,K.jsxs)(Xv,{variant:`destructive`,className:`mb-4`,children:[(0,K.jsx)(Xn,{className:`h-4 w-4`}),(0,K.jsx)(Zv,{children:`Invalid JSON`}),(0,K.jsx)(Qv,{children:S})]}),w.length>0&&(0,K.jsxs)(Xv,{variant:`destructive`,className:`mb-4`,children:[(0,K.jsx)(Xn,{className:`h-4 w-4`}),(0,K.jsx)(Zv,{children:`Restricted Configuration`}),(0,K.jsxs)(Qv,{children:[`The following fields cannot be modified via Studio:`,(0,K.jsx)(`ul`,{className:`list-disc ml-4 mt-2`,children:w.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsx)(`code`,{children:e})},e))})]})]}),(0,K.jsx)(`div`,{className:`grow`,children:d?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Af,{className:`w-full`}),(0,K.jsx)(Af,{className:`w-full`}),(0,K.jsx)(Af,{className:`w-1/2`})]}):(0,K.jsx)(pm,{className:`w-full min-h-full h-96`,path:hy,language:`json`,theme:_,onMount:k,options:{readOnly:!v,scrollBeyondLastLine:!1},value:v?b:JSON.stringify(g,null,4),onChange:O})})]})}function by(){let e=q(),{data:t}=H(wv(e));return t===void 0?void 0:dl(t.version)}var xy=(0,G.createContext)(void 0);function Sy({children:e}){return(0,K.jsx)(xy,{value:by(),children:e})}var Cy=qp(),wy=[{header:`Role`,accessorKey:`role`,enableSorting:!1},Cy.display({header:`ID`,id:`id`,enableSorting:!1,cell:e=>(0,K.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,title:e.row.original.id,children:e.row.original.id})}),Cy.display({header:`Created`,enableSorting:!1,id:`__createdtime__`,cell:e=>Zp((Date.now()-e.row.original.__createdtime__)/1e3,e.row.original.__createdtime__)}),Cy.display({header:`Updated`,id:`__updatedtime__`,enableSorting:!1,cell:e=>Zp((Date.now()-e.row.original.__updatedtime__)/1e3,e.row.original.__updatedtime__)}),Cy.display({header:`Super User`,id:`super_user`,enableSorting:!1,cell:e=>e.row.original.permission.super_user?`Yes`:`No`}),Cy.display({header:`Structure User`,id:`structure_user`,enableSorting:!1,cell:e=>e.row.original.permission.structure_user?`Yes`:`No`}),Cy.display({header:`Operations`,id:`operations`,enableSorting:!1,cell:e=>(0,K.jsx)(Ty,{permission:e.row.original.permission})})];function Ty({permission:e}){let t=(0,G.useContext)(xy);if(t===void 0)return null;let n=Cl(e,t);if(n===`absent`||n===`database`||n===`inert`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{"aria-hidden":!0,children:`—`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`No operation restriction`})]});if(n===`breaks-auth`)return(0,K.jsx)(`span`,{className:`text-destructive`,title:`Harper cannot expand this value; assigning the role breaks authentication instance-wide`,children:`breaks auth`});if(n===`malformed`)return(0,K.jsx)(`span`,{className:`text-destructive`,title:`Not a list of operation names`,children:`invalid`});if(yl(e))return(0,K.jsx)(`span`,{className:`text-destructive`,title:`Harper rejects an allowlist on a super_user or cluster_user role`,children:`conflicts with role`});let r=ml(Sl(e)??[]),i=hl(r);return(0,K.jsxs)(`span`,{title:i,children:[r.length,` allowed`,(0,K.jsxs)(`span`,{className:`sr-only`,children:[`: `,i]})]})}async function Ey(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 Dy(){return R({mutationFn:Ey})}var Oy=b({role:M().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:C(),structure_user:C()});function ky({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let r=Pt({resolver:Ke(Oy),defaultValues:{role:``,super_user:!1,structure_user:!1}}),i=q(),{mutate:a,isPending:o}=Dy(),s=(0,G.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),U.success(`Role added successfully!`),n(!1)}})},[a,r,i,t,n]),c=(0,G.useCallback)(()=>{r.reset(),n(!1)},[r,n]);return(0,K.jsx)(fn,{onOpenChange:n,open:e,children:(0,K.jsx)(cn,{"aria-describedby":void 0,children:(0,K.jsx)(Io,{...r,children:(0,K.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,K.jsxs)(rn,{className:`md:col-span-2`,children:[(0,K.jsx)(ln,{children:`Add New Role`}),(0,K.jsx)(un,{children:`After adding the role, you will be able to edit the per-table permissions.`})]}),(0,K.jsx)(Y,{control:r.control,name:`role`,render:({field:e})=>(0,K.jsxs)(X,{className:`md:col-span-2`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:r.control,name:`super_user`,render:({field:e})=>(0,K.jsxs)(X,{className:`flex`,children:[(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`checkbox`,className:`w-6`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,K.jsx)(Z,{className:`pl-4 pr-8 flex-1 py-2.5`,children:`Super User`}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:r.control,name:`structure_user`,render:({field:e})=>(0,K.jsxs)(X,{className:`flex`,children:[(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`checkbox`,className:`w-6`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,K.jsx)(Z,{className:`pl-4 pr-8 flex-1 py-2.5`,children:`Structure User`}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(on,{className:`md:col-span-2`,children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(F,{variant:`destructiveOutline`,type:`button`,onClick:c,disabled:o,children:`Cancel`}),(0,K.jsxs)(F,{type:`submit`,variant:`submit`,disabled:o,children:[(0,K.jsx)(Xr,{}),` Add Role`]})]})})]})})})})}function Ay({entityId:e,instanceClient:t}){return z({queryKey:[e,`list_roles`],queryFn:()=>jy({instanceClient:t}),refetchInterval:is(1e4),retry:as()})}async function jy({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_roles`});return t}function My({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=dl(n);for(let n in e){if(_l.has(n)&&(n!==`operations`||u))continue;let i=l(n,{tables:{}}),a=t&&vl(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]=Ny(s,o,r):i.tables[t]=Py(s,o,r)}}return i}function Ny(e,t,n){let r=e&&Hu(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 Py(e,t,n){let r=e&&Hu(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 Fy({value:e,onChange:t,version:n,allowlistRejected:r,structureUserDdl:i,disabled:a}){let o=e!==void 0,s=pl(n),c=al.filter(t=>!s.includes(t)&&e?.includes(t.name)),l=fl(n),u=new Set(e??[]),d=(e??[]).filter(e=>!ul(e)),f=e?ml(e):[],p=f.some(e=>cl(e)?.su),m=(0,G.useRef)([]),g=e=>{let n=new Set(e),r=al.map(e=>e.name).filter(e=>n.has(e)),i=[...n].filter(e=>!ul(e)).sort();t([...r,...i])},_=t=>{let n=new Set(e??[]);n.has(t)?n.delete(t):n.add(t),g(n)};return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border p-3`,children:[(0,K.jsxs)(Bo,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Dm,{checked:o,onCheckedChange:n=>{n?t(m.current):(m.current=e??[],t(void 0))},disabled:a,"aria-label":`Restrict operations`}),(0,K.jsx)(`span`,{className:`font-medium`,children:`Restrict operations`})]}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o?`Only the operations below are allowed — anything unlisted is denied. Listing an operation that normally requires super_user deliberately grants it to this role. SQL statements are authorized against table permissions instead, so this list does not restrict them.`:`No operation-level restriction. Add one to limit this role to an explicit list of API operations (for example a deploy-only CI role).`}),r&&(0,K.jsx)(`p`,{className:`text-xs text-destructive`,children:`Harper does not accept an operations allowlist on a super_user or cluster_user role — the save is rejected unless the list is dropped. Clear that flag to scope this role by operation; otherwise the allowlist is removed when you save.`}),i&&o&&(0,K.jsxs)(`p`,{className:`text-xs text-warning`,children:[`This role is a structure user, so it reaches`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:xl.join(`, `)}),i===!0?` (and create/drop database) on any database regardless of the list below.`:(0,K.jsxs)(K.Fragment,{children:[` `,`on `,(0,K.jsx)(`span`,{className:`font-mono`,children:i.join(`, `)}),` `,`regardless of the list below — and listing them here cannot reach another database.`]}),` Every other operation is still gated by the list.`]}),o&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[s.map(e=>(0,K.jsx)(Iy,{group:e,checked:u.has(e.name),onToggle:_,disabled:a},e.name)),c.map(e=>(0,K.jsx)(Iy,{group:e,note:`Saved on this role, but not offered for this instance's Harper version.`,checked:!0,onToggle:_,disabled:a},e.name))]}),(0,K.jsx)(Ry,{grantable:l,selectedSet:u,onToggle:_,disabled:a}),d.length>0&&(0,K.jsx)(`div`,{className:`flex max-h-24 flex-wrap gap-1 overflow-y-auto`,children:d.map(e=>(0,K.jsx)(zy,{name:e,onRemove:()=>_(e),disabled:a},e))}),f.length===0?(0,K.jsxs)(`p`,{className:`text-xs text-destructive`,children:[e?.length?`Every entry here is inert`:`Nothing selected`,` `,`— this role cannot run any Operations API call`,i?`, except the DDL noted above`:``,` `,`(SQL is gated by table permissions, not this list).`]}):(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,title:hl(f),children:[`Effectively allows `,h(f.length,`operation`,`operations`),p?`, including some that normally require super_user`:``,`.`,(0,K.jsxs)(`span`,{className:`sr-only`,children:[`: `,hl(f)]})]})]})]})}function Iy({group:e,note:t,checked:n,onToggle:r,disabled:i}){return(0,K.jsxs)(Bo,{className:`flex items-start gap-2 font-normal`,children:[(0,K.jsx)($,{type:`checkbox`,className:`mt-0.5 size-4`,checked:n,onChange:()=>r(e.name),disabled:i}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,K.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:t??e.description})]})]})}var Ly=/^[A-Za-z][A-Za-z0-9_.:-]*$/;function Ry({grantable:e,selectedSet:t,onToggle:n,disabled:r}){let[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(``),c=(0,G.useRef)(null),l=(0,G.useRef)(null);(0,G.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=Vu(f,`category`),m=cl(u),h=!m&&(ul(d)||rl.some(e=>e.name===d)),g=Ly.test(u)&&!ul(u)&&!h&&!m?.nonDelegable&&!m?.aliasOf&&!e.some(e=>e.name===u)&&!t.has(u)?u:void 0;return(0,K.jsxs)(Ti,{open:i,onOpenChange:e=>{a(e),e||s(``)},children:[(0,K.jsx)(Ei,{asChild:!0,disabled:r,children:(0,K.jsxs)(F,{type:`button`,variant:`outline`,className:`w-full justify-between font-normal`,children:[(0,K.jsx)(`span`,{className:`truncate text-muted-foreground`,children:`Add operations…`}),(0,K.jsx)(pn,{className:`size-4 shrink-0 opacity-60`})]})}),(0,K.jsxs)(Di,{ref:l,className:`w-(--radix-dropdown-menu-trigger-width) max-h-72 overflow-y-auto`,align:`start`,children:[(0,K.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`}),nl.filter(e=>p[e]).map(e=>(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Ai,{className:`text-xs text-muted-foreground`,children:e}),p[e].map(e=>(0,K.jsxs)(ki,{checked:t.has(e.name),onCheckedChange:()=>n(e.name),onSelect:e=>e.preventDefault(),children:[(0,K.jsx)(`span`,{className:`flex-1 truncate font-mono text-xs`,children:e.name}),Vc(e.name)?(0,K.jsx)(Yi,{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,K.jsx)(Yi,{variant:`warning`,title:`Normally requires super_user; listing it grants it to this role`,children:`super_user`})]},e.name))]},e)),g&&(0,K.jsxs)(ki,{checked:!1,onCheckedChange:()=>n(g),onSelect:e=>e.preventDefault(),children:[(0,K.jsx)(Gr,{className:`size-3`}),(0,K.jsxs)(`span`,{className:`flex-1 truncate text-xs`,children:[`Grant "`,(0,K.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,K.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-muted-foreground`,children:`No matching operations`})]})]})}function zy({name:e,onRemove:t,disabled:n}){let r=cl(e),i=Hc(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.`:Vc(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,K.jsxs)(Yi,{variant:i,title:a,className:`gap-1 font-mono text-xs`,children:[e,!n&&(0,K.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e}`,onClick:t,className:`ml-0.5 rounded-sm hover:text-destructive`,children:(0,K.jsx)(gn,{className:`size-3`})})]})}function By({kind:e,assigning:t,databaseCollision:n}){return e===`malformed`?(0,K.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`This role's `,(0,K.jsx)(`span`,{className:`font-mono`,children:`operations`}),` `,`value is not a list of operation names. Harper still gates on it: a string is read one character at a time, so every operation is denied; an array with non-string members enforces whatever it does expand to; and a falsy value makes each of this role's requests fail outright. The role cannot be saved again until it is fixed.`,` `,t?`Correct it in the role editor.`:`Correct it in the JSON below.`]}):(0,K.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`This role's `,(0,K.jsx)(`span`,{className:`font-mono`,children:`operations`}),` `,`value is not a list of operation names — most often table permissions on a database of that name, kept from an older Harper. This version cannot expand it, and `,t?`assigning this role to a user breaks authentication for every user on the instance. Pick a different role, and repair this one in the role editor first.`:(0,K.jsxs)(K.Fragment,{children:[`authentication breaks for every user on the instance as soon as a user holds this role. Remove the`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:`operations`}),` `,`key in the JSON below — that alone restores authentication.`,n&&(0,K.jsxs)(K.Fragment,{children:[` `,`Separately, and only if this instance needs allowlists at all: a database named`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:`operations`}),` `,`stops every role from using one. Retiring it means migrating its data and table grants to a differently-named database and verifying them there first — dropping it destroys whatever it holds, so treat that as a planned migration rather than part of this repair.`]})]})]})}function Vy(e){if(e.super_user!==!0&&e.structure_user!==!0&&e.cluster_user!==!0)return e;let t=yl(e),n={...e};for(let e in n)(!_l.has(e)||e===`operations`&&(t||!Array.isArray(n.operations))||n[e]===!1)&&delete n[e];return n}async function Hy({id:e,permission:t,instanceClient:n}){let{data:r}=await n.post(`/`,{operation:`alter_role`,id:e,permission:t});return r}function Uy(){return R({mutationFn:Hy})}async function Wy({id:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_role`,id:e});return n}function Gy(){return R({mutationFn:Wy})}async function Ky({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 qy(e){return z({queryKey:[e.entityId,`describe_all`,!!e.skipRecordCount],queryFn:()=>Ky(e),staleTime:6e4,gcTime:5e3,retry:!1})}function Jy(e){try{return JSON.parse(e)}catch{return null}}function Yy({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,G.useState)(JSON.stringify(l,null,2)),f=q(),[p,m]=(0,G.useState)(!0),{data:h}=H(qy({...f,skipRecordCount:!0})),{data:g}=H(wv(f)),_=Dn(t??n).user?.role?.id===e.id,[v,y]=Gm(u?.includes(`attribute_name`)),{mutate:b,isPending:x}=Uy(),{mutate:S,isPending:C}=Gy(),[w,T]=(0,G.useState)(!1),E=(0,G.useCallback)(e=>{m(e.length===0)},[m]),D=(0,G.useMemo)(()=>JSON.stringify(h&&g&&wl(My({instanceDatabaseMap:h,currentRolePermissions:u&&Ue(u)||l,version:g.version,showAttributes:v})),null,2),[l,h,g,v]);(0,G.useEffect)(()=>{d(D)},[D]);let O=dl(g?.version),k=(0,G.useRef)(null),{operationsRaw:A,operationsJson:j,operationsKind:ee,allowlistRejected:M,structureUserDdl:N}=(0,G.useMemo)(()=>{let e=O&&u?Jy(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=Sl(t);return{operationsRaw:t.operations,operationsJson:n&&JSON.stringify(n),operationsKind:Cl(t,O),allowlistRejected:yl(t),structureUserDdl:bl(t)}},[O,p,u]),P=(0,G.useMemo)(()=>j===void 0?void 0:JSON.parse(j),[j]),te=(0,G.useCallback)(e=>{d(t=>{let n=t?Ue(t):null;return!n||typeof n!=`object`||Array.isArray(n)?t:JSON.stringify(Tl(n,e),null,2)})},[]),ne=(0,G.useCallback)(t=>{let n=Ue(t);if(n&&typeof n==`object`&&!Array.isArray(n)){let t=Vy(n);b({id:e.id,permission:t,...f},{onSuccess:()=>{U.success(`Role updated successfully!`),a(void 0),o()}})}},[b,e.id,f,o,a]),I=(0,G.useCallback)(()=>{S({id:e.id,...f},{onSuccess:()=>{U.success(`Role deleted successfully!`),a(void 0),o()}})},[e.id,S,f,o,a]),L=ee===`breaks-auth`||ee===`malformed`,re=typeof A==`object`&&!!A&&!Array.isArray(A),ie=(0,G.useCallback)(()=>{u&&p&&ne(u)},[u,ne,p]),ae=(0,G.useCallback)(()=>{T(!0)},[]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(fn,{onOpenChange:i,open:r,children:(0,K.jsxs)(cn,{resizable:!0,children:[(0,K.jsxs)(ln,{children:[_?`View`:`Edit`,` Role "`,c,`"`]}),(0,K.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&&(L?(0,K.jsx)(By,{kind:ee,databaseCollision:re}):(0,K.jsx)(Fy,{allowlistRejected:M,structureUserDdl:N,value:P,onChange:te,version:g.version,disabled:_||!p})),(0,K.jsx)(`div`,{className:`flex-1 min-h-0`,children:D?(0,K.jsx)(pm,{className:`w-full h-full`,theme:s,defaultLanguage:`json`,value:u,options:{readOnly:_,automaticLayout:!0},onValidate:E,onChange:d,defaultValue:D}):(0,K.jsx)(Af,{})}),(0,K.jsx)(on,{children:!_&&(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(F,{type:`button`,variant:`destructiveOutline`,onClick:ae,disabled:x,children:`Delete Role`}),(0,K.jsx)(`div`,{className:`grow`}),(0,K.jsxs)(Bo,{className:`flex`,children:[(0,K.jsx)($,{type:`checkbox`,className:`w-6`,checked:v,onChange:y}),(0,K.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:`Pick Attributes`})]}),(0,K.jsx)(F,{variant:`submit`,onClick:ie,disabled:x||!p||L,children:`Save Changes`})]})})]})}),(0,K.jsx)(Cc,{isModalOpen:w,setIsModalOpen:T,deletionConfirmed:I,deletionPending:C,typeOfThingBeingDeleted:`role`,nameOfThingBeingDeleted:c,hideDataLossWarning:!0})]})}function Xy(){let e=L(),{clusterId:t,instanceId:n,roleId:r}=B({strict:!1}),i=q(),{data:a,refetch:o,isFetching:s,isRefetching:c}=de(Ay(i)),l=(0,G.useMemo)(()=>a?.find(e=>e.id===r),[a,r]),u=(0,G.useCallback)(t=>{let n=[r?`..`:``,t].filter(Boolean);e({to:n.join(`/`)})},[r,e]),d=!!r&&!!l,[f,p]=(0,G.useState)(!1),m=(0,G.useCallback)(()=>{p(!0)},[p]),h=(0,G.useCallback)(e=>{o(),p(!1),u(e)},[u,o]),g=(0,G.useCallback)(e=>{u(e.original.id)},[u]),_=(0,G.useCallback)(()=>{u(void 0)},[u]),v=$p(o);return(0,K.jsxs)(G.Suspense,{fallback:(0,K.jsx)(Gi,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,K.jsx)(Sy,{children:(0,K.jsxs)(Jp,{columns:wy,data:a,isFetching:s,onRowClick:g,children:[(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:v,accessKey:`r`,disabled:s||c,children:[(0,K.jsx)(Kr,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:f,children:[(0,K.jsx)(Gr,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]})}),(0,K.jsx)(ky,{isModalOpen:f,onChangesSaved:h,setIsModalOpen:p}),d&&(0,K.jsx)(Yy,{instanceId:n,clusterId:t,isModalOpen:d,closeModal:_,data:l,onSelectRole:u,onChangesSaved:()=>o()})]})}function Zy(e){return!!e?.entries}function Qy(e){if(!e?.entries)return[];let t=new Set;for(let n of e.entries)Zy(n)&&t.add(n.name);return[...t].sort((e,t)=>e.localeCompare(t))}function $y({components:e,granted:t,onAdd:n,disabled:r,actionLabel:i=`Add`,commitOnBlur:a=!1}){let[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(0),[f,p]=(0,G.useState)(!1),m=(0,G.useId)(),h=(0,G.useId)(),g=(0,G.useRef)(!1),_=(0,G.useRef)(!1),v=r||f,y=(0,G.useMemo)(()=>{if(e.length===0)return[];let n=o.trim(),r=n.toLowerCase(),i=new Set(t),a=e.filter(e=>!i.has(e)),s=(n?a.filter(e=>e.toLowerCase().includes(r)):a).map(e=>({value:e,custom:!1})),c=a.some(e=>e.toLowerCase()===r);return n&&!c&&s.push({value:n,custom:!0}),s},[e,t,o]),b=y.length===0?0:Math.min(u,y.length-1),x=(0,G.useCallback)(async e=>{if(_.current)return;let r=e.trim();if(!r||t.includes(r)){s(``);return}_.current=!0,p(!0);try{await n(r),s(``),l(!1)}catch{}finally{_.current=!1,p(!1)}},[t,n]),S=(0,G.useCallback)(()=>{x(y[b]?.value??o)},[x,y,b,o]),C=(0,G.useCallback)(e=>{if(e.key===`ArrowDown`){e.preventDefault(),l(!0),d(Math.min(b+1,Math.max(0,y.length-1)));return}if(e.key===`ArrowUp`){e.preventDefault(),d(Math.max(0,b-1));return}if(e.key===`Escape`){c&&(e.preventDefault(),e.stopPropagation(),l(!1));return}e.key===`Enter`&&(e.preventDefault(),S())},[c,y,b,S]),w=(0,G.useCallback)(()=>{g.current||(l(!1),a&&o.trim()&&S())},[a,o,S]),T=c&&y.length>0;return(0,K.jsxs)(`div`,{className:`relative grid gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{type:`text`,role:`combobox`,"aria-expanded":T,"aria-controls":T?m:void 0,"aria-autocomplete":`list`,"aria-activedescendant":T&&y[b]?`${h}-${b}`:void 0,autoComplete:`off`,autoCapitalize:`off`,placeholder:e.length>0?`Search applications…`:`application name`,value:o,onChange:e=>{s(e.target.value),d(0),l(!0)},onFocus:()=>l(!0),onKeyDown:C,onBlur:w,disabled:v}),(0,K.jsxs)(F,{type:`button`,variant:`positiveOutline`,onMouseDown:e=>e.preventDefault(),onClick:S,disabled:v||!o.trim(),children:[(0,K.jsx)(Gr,{}),` `,i]})]}),T&&(0,K.jsx)(`ul`,{id:m,role:`listbox`,className:`bg-popover text-popover-foreground absolute top-11 z-10 max-h-56 w-full overflow-auto rounded-md border p-1 shadow-md`,children:y.map((e,t)=>{let n=t===b;return(0,K.jsx)(`li`,{id:`${h}-${t}`,role:`option`,"aria-selected":n,onMouseEnter:()=>d(t),onMouseDown:t=>{t.preventDefault(),g.current=!0,x(e.value).finally(()=>{g.current=!1})},className:P(`flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-sm`,n&&`bg-accent text-accent-foreground`),children:e.custom?(0,K.jsxs)(`span`,{className:`truncate`,children:[`Use “`,(0,K.jsx)(`span`,{className:`font-mono`,children:e.value}),`” — not a deployed application`]}):(0,K.jsx)(`span`,{className:`truncate font-mono`,children:e.value})},e.custom?`__custom__${e.value}`:e.value)})})]})}var eb=`enc:v1:`;function tb(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 nb(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function rb(e){return nb(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function ib(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function ab(){if(typeof crypto>`u`||!crypto.subtle)throw Error(`Secret encryption requires a secure context (HTTPS or localhost).`);return crypto.subtle}async function ob(e,t,n){let r=ab(),i=tb(t),a=await r.importKey(`spki`,ib(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`,ib(o),{name:`AES-GCM`},!1,[`encrypt`]),l=new Uint8Array(await r.encrypt({name:`AES-GCM`,iv:ib(s),tagLength:128},c,ib(new TextEncoder().encode(e)))),u=l.slice(0,l.length-16),d=l.slice(l.length-16),f={kid:n,k:nb(new Uint8Array(await r.encrypt({name:`RSA-OAEP`},a,ib(o)))),iv:nb(s),ct:nb(u),tag:nb(d)};return eb+rb(new TextEncoder().encode(JSON.stringify(f)))}function sb(e){let t=e?.response?.data;return t?.error??t?.message??String(e)}var cb=`does not match`;function lb(e){return e.includes(cb)}async function ub({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`get_secrets_public_key`});return{publicKey:t.public_key,fingerprint:t.fingerprint}}var db=N;async function fb(e){let{data:t}=await db.post(`/ClusterSecrets`,{operation:`get_secrets_public_key`,clusterId:e});return{publicKey:t.publicKey,fingerprint:t.fingerprint}}function pb(e){return z({queryKey:[e.entityId,`get_secrets_public_key`,e.managedClusterId??`node`],queryFn:()=>e.managedClusterId?fb(e.managedClusterId):ub(e),staleTime:3e5,retry:!1})}async function mb({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_secrets`});return t}function hb(e){return z({queryKey:[e.entityId,`list_secrets`],queryFn:()=>mb(e)})}async function gb(e,t,n){let{publicKey:r,fingerprint:i}=await e.ensureQueryData(pb(t)),a=await ob(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=sb(r);if(!n&&lb(i))return e.removeQueries({queryKey:pb(t).queryKey}),gb(e,t,!0);throw Error(i)}}function _b(){let e=oe();return R({mutationFn:t=>gb(e,t,!1)})}async function vb({instanceClient:e,name:t}){try{let{data:n}=await e.post(`/`,{operation:`delete_secret`,name:t});return n}catch(e){throw Error(sb(e))}}function yb(){return R({mutationFn:vb})}async function bb(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(sb(e))}}function xb(){return R({mutationFn:e=>bb(`grant_secret`,e)})}function Sb(){return R({mutationFn:e=>bb(`revoke_secret`,e)})}function Cb({name:e,initialGrants:t,components:n,onChanged:r}){let i=q(),{mutateAsync:a,isPending:o}=xb(),{mutateAsync:s,isPending:c}=Sb(),l=o||c,[u,d]=(0,G.useState)(t),f=(0,G.useCallback)(async t=>{try{let n=await a({...i,name:e,component:t});d(n.grants),r?.()}catch(e){throw U.error(String(e)),e}},[a,i,e,r]),p=(0,G.useCallback)(async t=>{try{let n=await s({...i,name:e,component:t});d(n.grants),r?.()}catch(e){U.error(String(e))}},[s,i,e,r]);return(0,K.jsxs)(`div`,{className:`grid gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium`,children:`Granted applications`}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Only granted applications can read this secret through the `,(0,K.jsx)(`code`,{className:`font-mono`,children:`secrets`}),` `,`accessor. Changes apply immediately.`]}),u.length>0&&(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:u.map(e=>(0,K.jsxs)(Yi,{variant:`secondary`,children:[e,(0,K.jsxs)(`button`,{type:`button`,onClick:()=>void p(e),disabled:l,title:`Revoke ${e}`,className:`cursor-pointer disabled:cursor-default`,children:[(0,K.jsx)(gn,{}),(0,K.jsxs)(`span`,{className:`sr-only`,children:[`Revoke `,e]})]})]},e))}),(0,K.jsx)($y,{components:n,granted:u,onAdd:f,disabled:l,actionLabel:`Grant`})]})}var wb=`********`,Tb=/^[\w.-]+$/,Eb=/^(\s*(?:export\s+)?)([\w.-]+)\s*=(.*)$/;function Db(e){return e.split(`/`).pop()??``}function Ob(e){if(!e)return!1;let t=Db(e).toLowerCase();return t===`.env`||t.startsWith(`.env.`)}var kb=[`.example`,`.sample`,`.template`];function Ab(e){if(!Ob(e))return!1;let t=Db(e).toLowerCase();return kb.some(e=>t.endsWith(e))}function jb(e){return Ob(e)&&!Ab(e)}function Mb(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
+ `),hy=`inmemory://harper/config-root.json`,gy=`harper://schemas/config-root.json`;async function _y(){let{json:e}=await ze(async()=>{let{json:e}=await import(`./languageServices-D1uNqC6s.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===gy)||t.setDiagnosticsOptions({...r,validate:!0,enableSchemaRequest:!1,schemas:[...n,{uri:gy,fileMatch:[hy],schema:my}]})}var vy=({children:e})=>(0,K.jsx)(K.Fragment,{children:e});function yy(){let{clusterId:e,instanceId:t}=B({strict:!1}),{data:n,isLoading:r}=H(ey({clusterId:e,instanceId:t})),i=q(),{version:a}=te({strict:!1}),{data:o}=H(cy(i,!1));n?.cluster;let s=n?.instance,{data:c,isLoading:l}=H(wv(i)),{data:u,isLoading:d}=H(sy(i)),f=nu(),{data:p,isLoading:m}=H(oy({...i,enabled:f})),h=(0,G.useMemo)(()=>{if(!p)return null;let e=0,t=n=>{n.mtime&&(e=Math.max(e,new Date(n.mtime).getTime())),`entries`in n&&n.entries&&n.entries.forEach(t)};return t(p),e||null},[p]),g=(0,G.useMemo)(()=>u?dy(u):null,[u]),_=dm(),[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(``),[S,C]=(0,G.useState)(null),[w,T]=(0,G.useState)([]),{onConfigUpdate:E,isPending:D}=iy();(0,G.useEffect)(()=>{g&&!v&&(x(JSON.stringify(g,null,4)),C(null),T([]))},[g,v]);let O=(0,G.useCallback)(e=>{if(x(e||``),e)try{let t=JSON.parse(e);C(null);let n=[],r=(e,t,i=``)=>{for(let a in e){let o=i?`${i}.${a}`:a,s=e[a],c=t?.[a];uy(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||uy(a,void 0,t[r])&&n.push(a)}};g&&r(t,g),T(n)}catch(e){C(e.message),T([])}},[u]),k=(0,G.useCallback)(()=>{_y().catch(e=>{console.error(`Failed to register the Harper config JSON Schema:`,e)})},[]),A=(0,G.useCallback)(()=>{if(!(S||w.length>0))try{let e=JSON.parse(b),t=py(fy(g,e));E(t),y(!1)}catch(e){C(e.message)}},[b,S,E,g,w.length]);return(0,G.useMemo)(()=>[],[o,s]),(0,K.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,K.jsx)(vy,{children:(0,K.jsxs)(`dl`,{className:`grid grid-cols-1 sm:grid-cols-3`,children:[(0,K.jsx)(`div`,{className:`px-4 pb-4 sm:col-span-1 sm:px-0`,children:(0,K.jsx)(ty,{loadingRegistration:l,registrationInfo:c})}),(0,K.jsx)(`div`,{className:`px-4 pb-4 sm:col-span-1 sm:px-0`,children:(0,K.jsx)(ny,{loading:m,timestamp:h})}),(0,K.jsx)(`div`,{className:`px-4 pb-4 text-right sm:col-span-1 sm:px-0`,children:(0,K.jsx)(Jv,{targetNoun:`Instance`,instanceClient:i.instanceClient,operation:`restart`})})]})}),(0,K.jsxs)(`div`,{className:`flex-none flex items-center justify-between mb-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h3`,{className:`font-bold text-sm/6`,children:[`Instance Config `,v?`(editing)`:`(read only)`]}),!t&&!1]}),(0,K.jsx)(`div`,{className:`flex items-center gap-2 pr-4`,children:v?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(F,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>y(!1),children:[(0,K.jsx)(gn,{className:`w-4 h-4 mr-1`}),` Cancel`]}),(0,K.jsxs)(F,{size:`sm`,disabled:!!S||w.length>0||D,onClick:A,children:[(0,K.jsx)(Xr,{className:`w-4 h-4 mr-1`}),` `,D?`Saving...`:`Save & Restart`]})]}):(0,K.jsxs)(F,{size:`sm`,onClick:()=>y(!0),children:[(0,K.jsx)(ii,{className:`w-4 h-4 mr-1`}),` Edit`]})})]}),S&&(0,K.jsxs)(Xv,{variant:`destructive`,className:`mb-4`,children:[(0,K.jsx)(Xn,{className:`h-4 w-4`}),(0,K.jsx)(Zv,{children:`Invalid JSON`}),(0,K.jsx)(Qv,{children:S})]}),w.length>0&&(0,K.jsxs)(Xv,{variant:`destructive`,className:`mb-4`,children:[(0,K.jsx)(Xn,{className:`h-4 w-4`}),(0,K.jsx)(Zv,{children:`Restricted Configuration`}),(0,K.jsxs)(Qv,{children:[`The following fields cannot be modified via Studio:`,(0,K.jsx)(`ul`,{className:`list-disc ml-4 mt-2`,children:w.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsx)(`code`,{children:e})},e))})]})]}),(0,K.jsx)(`div`,{className:`grow`,children:d?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Af,{className:`w-full`}),(0,K.jsx)(Af,{className:`w-full`}),(0,K.jsx)(Af,{className:`w-1/2`})]}):(0,K.jsx)(pm,{className:`w-full min-h-full h-96`,path:hy,language:`json`,theme:_,onMount:k,options:{readOnly:!v,scrollBeyondLastLine:!1},value:v?b:JSON.stringify(g,null,4),onChange:O})})]})}function by(){let e=q(),{data:t}=H(wv(e));return t===void 0?void 0:dl(t.version)}var xy=(0,G.createContext)(void 0);function Sy({children:e}){return(0,K.jsx)(xy,{value:by(),children:e})}var Cy=qp(),wy=[{header:`Role`,accessorKey:`role`,enableSorting:!1},Cy.display({header:`ID`,id:`id`,enableSorting:!1,cell:e=>(0,K.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,title:e.row.original.id,children:e.row.original.id})}),Cy.display({header:`Created`,enableSorting:!1,id:`__createdtime__`,cell:e=>Zp((Date.now()-e.row.original.__createdtime__)/1e3,e.row.original.__createdtime__)}),Cy.display({header:`Updated`,id:`__updatedtime__`,enableSorting:!1,cell:e=>Zp((Date.now()-e.row.original.__updatedtime__)/1e3,e.row.original.__updatedtime__)}),Cy.display({header:`Super User`,id:`super_user`,enableSorting:!1,cell:e=>e.row.original.permission.super_user?`Yes`:`No`}),Cy.display({header:`Structure User`,id:`structure_user`,enableSorting:!1,cell:e=>e.row.original.permission.structure_user?`Yes`:`No`}),Cy.display({header:`Operations`,id:`operations`,enableSorting:!1,cell:e=>(0,K.jsx)(Ty,{permission:e.row.original.permission})})];function Ty({permission:e}){let t=(0,G.useContext)(xy);if(t===void 0)return null;let n=Cl(e,t);if(n===`absent`||n===`database`||n===`inert`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{"aria-hidden":!0,children:`—`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`No operation restriction`})]});if(n===`breaks-auth`)return(0,K.jsx)(`span`,{className:`text-destructive`,title:`Harper cannot expand this value; assigning the role breaks authentication instance-wide`,children:`breaks auth`});if(n===`malformed`)return(0,K.jsx)(`span`,{className:`text-destructive`,title:`Not a list of operation names`,children:`invalid`});if(yl(e))return(0,K.jsx)(`span`,{className:`text-destructive`,title:`Harper rejects an allowlist on a super_user or cluster_user role`,children:`conflicts with role`});let r=ml(Sl(e)??[]),i=hl(r);return(0,K.jsxs)(`span`,{title:i,children:[r.length,` allowed`,(0,K.jsxs)(`span`,{className:`sr-only`,children:[`: `,i]})]})}async function Ey(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 Dy(){return R({mutationFn:Ey})}var Oy=b({role:M().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:C(),structure_user:C()});function ky({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let r=Pt({resolver:Ke(Oy),defaultValues:{role:``,super_user:!1,structure_user:!1}}),i=q(),{mutate:a,isPending:o}=Dy(),s=(0,G.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),U.success(`Role added successfully!`),n(!1)}})},[a,r,i,t,n]),c=(0,G.useCallback)(()=>{r.reset(),n(!1)},[r,n]);return(0,K.jsx)(fn,{onOpenChange:n,open:e,children:(0,K.jsx)(cn,{"aria-describedby":void 0,children:(0,K.jsx)(Io,{...r,children:(0,K.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,K.jsxs)(rn,{className:`md:col-span-2`,children:[(0,K.jsx)(ln,{children:`Add New Role`}),(0,K.jsx)(un,{children:`After adding the role, you will be able to edit the per-table permissions.`})]}),(0,K.jsx)(Y,{control:r.control,name:`role`,render:({field:e})=>(0,K.jsxs)(X,{className:`md:col-span-2`,children:[(0,K.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`text`,...e})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:r.control,name:`super_user`,render:({field:e})=>(0,K.jsxs)(X,{className:`flex`,children:[(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`checkbox`,className:`w-6`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,K.jsx)(Z,{className:`pl-4 pr-8 flex-1 py-2.5`,children:`Super User`}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:r.control,name:`structure_user`,render:({field:e})=>(0,K.jsxs)(X,{className:`flex`,children:[(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`checkbox`,className:`w-6`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,K.jsx)(Z,{className:`pl-4 pr-8 flex-1 py-2.5`,children:`Structure User`}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(on,{className:`md:col-span-2`,children:(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(F,{variant:`destructiveOutline`,type:`button`,onClick:c,disabled:o,children:`Cancel`}),(0,K.jsxs)(F,{type:`submit`,variant:`submit`,disabled:o,children:[(0,K.jsx)(Xr,{}),` Add Role`]})]})})]})})})})}function Ay({entityId:e,instanceClient:t}){return z({queryKey:[e,`list_roles`],queryFn:()=>jy({instanceClient:t}),refetchInterval:is(1e4),retry:as()})}async function jy({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_roles`});return t}function My({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=dl(n);for(let n in e){if(_l.has(n)&&(n!==`operations`||u))continue;let i=l(n,{tables:{}}),a=t&&vl(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]=Ny(s,o,r):i.tables[t]=Py(s,o,r)}}return i}function Ny(e,t,n){let r=e&&Hu(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 Py(e,t,n){let r=e&&Hu(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 Fy({value:e,onChange:t,version:n,allowlistRejected:r,structureUserDdl:i,disabled:a}){let o=e!==void 0,s=pl(n),c=al.filter(t=>!s.includes(t)&&e?.includes(t.name)),l=fl(n),u=new Set(e??[]),d=(e??[]).filter(e=>!ul(e)),f=e?ml(e):[],p=f.some(e=>cl(e)?.su),m=(0,G.useRef)([]),g=e=>{let n=new Set(e),r=al.map(e=>e.name).filter(e=>n.has(e)),i=[...n].filter(e=>!ul(e)).sort();t([...r,...i])},_=t=>{let n=new Set(e??[]);n.has(t)?n.delete(t):n.add(t),g(n)};return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border p-3`,children:[(0,K.jsxs)(Bo,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Dm,{checked:o,onCheckedChange:n=>{n?t(m.current):(m.current=e??[],t(void 0))},disabled:a,"aria-label":`Restrict operations`}),(0,K.jsx)(`span`,{className:`font-medium`,children:`Restrict operations`})]}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o?`Only the operations below are allowed — anything unlisted is denied. Listing an operation that normally requires super_user deliberately grants it to this role. SQL statements are authorized against table permissions instead, so this list does not restrict them.`:`No operation-level restriction. Add one to limit this role to an explicit list of API operations (for example a deploy-only CI role).`}),r&&(0,K.jsx)(`p`,{className:`text-xs text-destructive`,children:`Harper does not accept an operations allowlist on a super_user or cluster_user role — the save is rejected unless the list is dropped. Clear that flag to scope this role by operation; otherwise the allowlist is removed when you save.`}),i&&o&&(0,K.jsxs)(`p`,{className:`text-xs text-warning`,children:[`This role is a structure user, so it reaches`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:xl.join(`, `)}),i===!0?` (and create/drop database) on any database regardless of the list below.`:(0,K.jsxs)(K.Fragment,{children:[` `,`on `,(0,K.jsx)(`span`,{className:`font-mono`,children:i.join(`, `)}),` `,`regardless of the list below — and listing them here cannot reach another database.`]}),` Every other operation is still gated by the list.`]}),o&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[s.map(e=>(0,K.jsx)(Iy,{group:e,checked:u.has(e.name),onToggle:_,disabled:a},e.name)),c.map(e=>(0,K.jsx)(Iy,{group:e,note:`Saved on this role, but not offered for this instance's Harper version.`,checked:!0,onToggle:_,disabled:a},e.name))]}),(0,K.jsx)(Ry,{grantable:l,selectedSet:u,onToggle:_,disabled:a}),d.length>0&&(0,K.jsx)(`div`,{className:`flex max-h-24 flex-wrap gap-1 overflow-y-auto`,children:d.map(e=>(0,K.jsx)(zy,{name:e,onRemove:()=>_(e),disabled:a},e))}),f.length===0?(0,K.jsxs)(`p`,{className:`text-xs text-destructive`,children:[e?.length?`Every entry here is inert`:`Nothing selected`,` `,`— this role cannot run any Operations API call`,i?`, except the DDL noted above`:``,` `,`(SQL is gated by table permissions, not this list).`]}):(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,title:hl(f),children:[`Effectively allows `,h(f.length,`operation`,`operations`),p?`, including some that normally require super_user`:``,`.`,(0,K.jsxs)(`span`,{className:`sr-only`,children:[`: `,hl(f)]})]})]})]})}function Iy({group:e,note:t,checked:n,onToggle:r,disabled:i}){return(0,K.jsxs)(Bo,{className:`flex items-start gap-2 font-normal`,children:[(0,K.jsx)($,{type:`checkbox`,className:`mt-0.5 size-4`,checked:n,onChange:()=>r(e.name),disabled:i}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,K.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:t??e.description})]})]})}var Ly=/^[A-Za-z][A-Za-z0-9_.:-]*$/;function Ry({grantable:e,selectedSet:t,onToggle:n,disabled:r}){let[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(``),c=(0,G.useRef)(null),l=(0,G.useRef)(null);(0,G.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=Vu(f,`category`),m=cl(u),h=!m&&(ul(d)||rl.some(e=>e.name===d)),g=Ly.test(u)&&!ul(u)&&!h&&!m?.nonDelegable&&!m?.aliasOf&&!e.some(e=>e.name===u)&&!t.has(u)?u:void 0;return(0,K.jsxs)(Ti,{open:i,onOpenChange:e=>{a(e),e||s(``)},children:[(0,K.jsx)(Ei,{asChild:!0,disabled:r,children:(0,K.jsxs)(F,{type:`button`,variant:`outline`,className:`w-full justify-between font-normal`,children:[(0,K.jsx)(`span`,{className:`truncate text-muted-foreground`,children:`Add operations…`}),(0,K.jsx)(pn,{className:`size-4 shrink-0 opacity-60`})]})}),(0,K.jsxs)(Di,{ref:l,className:`w-(--radix-dropdown-menu-trigger-width) max-h-72 overflow-y-auto`,align:`start`,children:[(0,K.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`}),nl.filter(e=>p[e]).map(e=>(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Ai,{className:`text-xs text-muted-foreground`,children:e}),p[e].map(e=>(0,K.jsxs)(ki,{checked:t.has(e.name),onCheckedChange:()=>n(e.name),onSelect:e=>e.preventDefault(),children:[(0,K.jsx)(`span`,{className:`flex-1 truncate font-mono text-xs`,children:e.name}),Vc(e.name)?(0,K.jsx)(Yi,{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,K.jsx)(Yi,{variant:`warning`,title:`Normally requires super_user; listing it grants it to this role`,children:`super_user`})]},e.name))]},e)),g&&(0,K.jsxs)(ki,{checked:!1,onCheckedChange:()=>n(g),onSelect:e=>e.preventDefault(),children:[(0,K.jsx)(Gr,{className:`size-3`}),(0,K.jsxs)(`span`,{className:`flex-1 truncate text-xs`,children:[`Grant "`,(0,K.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,K.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-muted-foreground`,children:`No matching operations`})]})]})}function zy({name:e,onRemove:t,disabled:n}){let r=cl(e),i=Hc(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.`:Vc(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,K.jsxs)(Yi,{variant:i,title:a,className:`gap-1 font-mono text-xs`,children:[e,!n&&(0,K.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e}`,onClick:t,className:`ml-0.5 rounded-sm hover:text-destructive`,children:(0,K.jsx)(gn,{className:`size-3`})})]})}function By({kind:e,assigning:t,databaseCollision:n}){return e===`malformed`?(0,K.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`This role's `,(0,K.jsx)(`span`,{className:`font-mono`,children:`operations`}),` `,`value is not a list of operation names. Harper still gates on it: a string is read one character at a time, so every operation is denied; an array with non-string members enforces whatever it does expand to; and a falsy value makes each of this role's requests fail outright. The role cannot be saved again until it is fixed.`,` `,t?`Correct it in the role editor.`:`Correct it in the JSON below.`]}):(0,K.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`This role's `,(0,K.jsx)(`span`,{className:`font-mono`,children:`operations`}),` `,`value is not a list of operation names — most often table permissions on a database of that name, kept from an older Harper. This version cannot expand it, and `,t?`assigning this role to a user breaks authentication for every user on the instance. Pick a different role, and repair this one in the role editor first.`:(0,K.jsxs)(K.Fragment,{children:[`authentication breaks for every user on the instance as soon as a user holds this role. Remove the`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:`operations`}),` `,`key in the JSON below — that alone restores authentication.`,n&&(0,K.jsxs)(K.Fragment,{children:[` `,`Separately, and only if this instance needs allowlists at all: a database named`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:`operations`}),` `,`stops every role from using one. Retiring it means migrating its data and table grants to a differently-named database and verifying them there first — dropping it destroys whatever it holds, so treat that as a planned migration rather than part of this repair.`]})]})]})}function Vy(e){if(e.super_user!==!0&&e.structure_user!==!0&&e.cluster_user!==!0)return e;let t=yl(e),n={...e};for(let e in n)(!_l.has(e)||e===`operations`&&(t||!Array.isArray(n.operations))||n[e]===!1)&&delete n[e];return n}async function Hy({id:e,permission:t,instanceClient:n}){let{data:r}=await n.post(`/`,{operation:`alter_role`,id:e,permission:t});return r}function Uy(){return R({mutationFn:Hy})}async function Wy({id:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_role`,id:e});return n}function Gy(){return R({mutationFn:Wy})}async function Ky({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 qy(e){return z({queryKey:[e.entityId,`describe_all`,!!e.skipRecordCount],queryFn:()=>Ky(e),staleTime:6e4,gcTime:5e3,retry:!1})}function Jy(e){try{return JSON.parse(e)}catch{return null}}function Yy({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,G.useState)(JSON.stringify(l,null,2)),f=q(),[p,m]=(0,G.useState)(!0),{data:h}=H(qy({...f,skipRecordCount:!0})),{data:g}=H(wv(f)),_=Dn(t??n).user?.role?.id===e.id,[v,y]=Gm(u?.includes(`attribute_name`)),{mutate:b,isPending:x}=Uy(),{mutate:S,isPending:C}=Gy(),[w,T]=(0,G.useState)(!1),E=(0,G.useCallback)(e=>{m(e.length===0)},[m]),D=(0,G.useMemo)(()=>JSON.stringify(h&&g&&wl(My({instanceDatabaseMap:h,currentRolePermissions:u&&Ue(u)||l,version:g.version,showAttributes:v})),null,2),[l,h,g,v]);(0,G.useEffect)(()=>{d(D)},[D]);let O=dl(g?.version),k=(0,G.useRef)(null),{operationsRaw:A,operationsJson:j,operationsKind:ee,allowlistRejected:M,structureUserDdl:N}=(0,G.useMemo)(()=>{let e=O&&u?Jy(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=Sl(t);return{operationsRaw:t.operations,operationsJson:n&&JSON.stringify(n),operationsKind:Cl(t,O),allowlistRejected:yl(t),structureUserDdl:bl(t)}},[O,p,u]),P=(0,G.useMemo)(()=>j===void 0?void 0:JSON.parse(j),[j]),te=(0,G.useCallback)(e=>{d(t=>{let n=t?Ue(t):null;return!n||typeof n!=`object`||Array.isArray(n)?t:JSON.stringify(Tl(n,e),null,2)})},[]),ne=(0,G.useCallback)(t=>{let n=Ue(t);if(n&&typeof n==`object`&&!Array.isArray(n)){let t=Vy(n);b({id:e.id,permission:t,...f},{onSuccess:()=>{U.success(`Role updated successfully!`),a(void 0),o()}})}},[b,e.id,f,o,a]),I=(0,G.useCallback)(()=>{S({id:e.id,...f},{onSuccess:()=>{U.success(`Role deleted successfully!`),a(void 0),o()}})},[e.id,S,f,o,a]),L=ee===`breaks-auth`||ee===`malformed`,re=typeof A==`object`&&!!A&&!Array.isArray(A),ie=(0,G.useCallback)(()=>{u&&p&&ne(u)},[u,ne,p]),ae=(0,G.useCallback)(()=>{T(!0)},[]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(fn,{onOpenChange:i,open:r,children:(0,K.jsxs)(cn,{resizable:!0,children:[(0,K.jsxs)(ln,{children:[_?`View`:`Edit`,` Role "`,c,`"`]}),(0,K.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&&(L?(0,K.jsx)(By,{kind:ee,databaseCollision:re}):(0,K.jsx)(Fy,{allowlistRejected:M,structureUserDdl:N,value:P,onChange:te,version:g.version,disabled:_||!p})),(0,K.jsx)(`div`,{className:`flex-1 min-h-0`,children:D?(0,K.jsx)(pm,{className:`w-full h-full`,theme:s,defaultLanguage:`json`,value:u,options:{readOnly:_,automaticLayout:!0},onValidate:E,onChange:d,defaultValue:D}):(0,K.jsx)(Af,{})}),(0,K.jsx)(on,{children:!_&&(0,K.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,K.jsx)(F,{type:`button`,variant:`destructiveOutline`,onClick:ae,disabled:x,children:`Delete Role`}),(0,K.jsx)(`div`,{className:`grow`}),(0,K.jsxs)(Bo,{className:`flex`,children:[(0,K.jsx)($,{type:`checkbox`,className:`w-6`,checked:v,onChange:y}),(0,K.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:`Pick Attributes`})]}),(0,K.jsx)(F,{variant:`submit`,onClick:ie,disabled:x||!p||L,children:`Save Changes`})]})})]})}),(0,K.jsx)(Cc,{isModalOpen:w,setIsModalOpen:T,deletionConfirmed:I,deletionPending:C,typeOfThingBeingDeleted:`role`,nameOfThingBeingDeleted:c,hideDataLossWarning:!0})]})}function Xy(){let e=L(),{clusterId:t,instanceId:n,roleId:r}=B({strict:!1}),i=q(),{data:a,refetch:o,isFetching:s,isRefetching:c}=de(Ay(i)),l=(0,G.useMemo)(()=>a?.find(e=>e.id===r),[a,r]),u=(0,G.useCallback)(t=>{let n=[r?`..`:``,t].filter(Boolean);e({to:n.join(`/`)})},[r,e]),d=!!r&&!!l,[f,p]=(0,G.useState)(!1),m=(0,G.useCallback)(()=>{p(!0)},[p]),h=(0,G.useCallback)(e=>{o(),p(!1),u(e)},[u,o]),g=(0,G.useCallback)(e=>{u(e.original.id)},[u]),_=(0,G.useCallback)(()=>{u(void 0)},[u]),v=$p(o);return(0,K.jsxs)(G.Suspense,{fallback:(0,K.jsx)(Gi,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,K.jsx)(Sy,{children:(0,K.jsxs)(Jp,{columns:wy,data:a,isFetching:s,onRowClick:g,children:[(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:v,accessKey:`r`,disabled:s||c,children:[(0,K.jsx)(Kr,{}),(0,K.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,K.jsx)(`u`,{children:`R`}),`efresh`]})]}),(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:f,children:[(0,K.jsx)(Gr,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`A`}),`dd`]})]})]})}),(0,K.jsx)(ky,{isModalOpen:f,onChangesSaved:h,setIsModalOpen:p}),d&&(0,K.jsx)(Yy,{instanceId:n,clusterId:t,isModalOpen:d,closeModal:_,data:l,onSelectRole:u,onChangesSaved:()=>o()})]})}function Zy(e){return!!e?.entries}function Qy(e){if(!e?.entries)return[];let t=new Set;for(let n of e.entries)Zy(n)&&t.add(n.name);return[...t].sort((e,t)=>e.localeCompare(t))}function $y({components:e,granted:t,onAdd:n,disabled:r,actionLabel:i=`Add`,commitOnBlur:a=!1}){let[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(0),[f,p]=(0,G.useState)(!1),m=(0,G.useId)(),h=(0,G.useId)(),g=(0,G.useRef)(!1),_=(0,G.useRef)(!1),v=r||f,y=(0,G.useMemo)(()=>{if(e.length===0)return[];let n=o.trim(),r=n.toLowerCase(),i=new Set(t),a=e.filter(e=>!i.has(e)),s=(n?a.filter(e=>e.toLowerCase().includes(r)):a).map(e=>({value:e,custom:!1})),c=a.some(e=>e.toLowerCase()===r);return n&&!c&&s.push({value:n,custom:!0}),s},[e,t,o]),b=y.length===0?0:Math.min(u,y.length-1),x=(0,G.useCallback)(async e=>{if(_.current)return;let r=e.trim();if(!r||t.includes(r)){s(``);return}_.current=!0,p(!0);try{await n(r),s(``),l(!1)}catch{}finally{_.current=!1,p(!1)}},[t,n]),S=(0,G.useCallback)(()=>{x(y[b]?.value??o)},[x,y,b,o]),C=(0,G.useCallback)(e=>{if(e.key===`ArrowDown`){e.preventDefault(),l(!0),d(Math.min(b+1,Math.max(0,y.length-1)));return}if(e.key===`ArrowUp`){e.preventDefault(),d(Math.max(0,b-1));return}if(e.key===`Escape`){c&&(e.preventDefault(),e.stopPropagation(),l(!1));return}e.key===`Enter`&&(e.preventDefault(),S())},[c,y,b,S]),w=(0,G.useCallback)(()=>{g.current||(l(!1),a&&o.trim()&&S())},[a,o,S]),T=c&&y.length>0;return(0,K.jsxs)(`div`,{className:`relative grid gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{type:`text`,role:`combobox`,"aria-expanded":T,"aria-controls":T?m:void 0,"aria-autocomplete":`list`,"aria-activedescendant":T&&y[b]?`${h}-${b}`:void 0,autoComplete:`off`,autoCapitalize:`off`,placeholder:e.length>0?`Search applications…`:`application name`,value:o,onChange:e=>{s(e.target.value),d(0),l(!0)},onFocus:()=>l(!0),onKeyDown:C,onBlur:w,disabled:v}),(0,K.jsxs)(F,{type:`button`,variant:`positiveOutline`,onMouseDown:e=>e.preventDefault(),onClick:S,disabled:v||!o.trim(),children:[(0,K.jsx)(Gr,{}),` `,i]})]}),T&&(0,K.jsx)(`ul`,{id:m,role:`listbox`,className:`bg-popover text-popover-foreground absolute top-11 z-10 max-h-56 w-full overflow-auto rounded-md border p-1 shadow-md`,children:y.map((e,t)=>{let n=t===b;return(0,K.jsx)(`li`,{id:`${h}-${t}`,role:`option`,"aria-selected":n,onMouseEnter:()=>d(t),onMouseDown:t=>{t.preventDefault(),g.current=!0,x(e.value).finally(()=>{g.current=!1})},className:P(`flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-sm`,n&&`bg-accent text-accent-foreground`),children:e.custom?(0,K.jsxs)(`span`,{className:`truncate`,children:[`Use “`,(0,K.jsx)(`span`,{className:`font-mono`,children:e.value}),`” — not a deployed application`]}):(0,K.jsx)(`span`,{className:`truncate font-mono`,children:e.value})},e.custom?`__custom__${e.value}`:e.value)})})]})}var eb=`enc:v1:`;function tb(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 nb(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function rb(e){return nb(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function ib(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function ab(){if(typeof crypto>`u`||!crypto.subtle)throw Error(`Secret encryption requires a secure context (HTTPS or localhost).`);return crypto.subtle}async function ob(e,t,n){let r=ab(),i=tb(t),a=await r.importKey(`spki`,ib(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`,ib(o),{name:`AES-GCM`},!1,[`encrypt`]),l=new Uint8Array(await r.encrypt({name:`AES-GCM`,iv:ib(s),tagLength:128},c,ib(new TextEncoder().encode(e)))),u=l.slice(0,l.length-16),d=l.slice(l.length-16),f={kid:n,k:nb(new Uint8Array(await r.encrypt({name:`RSA-OAEP`},a,ib(o)))),iv:nb(s),ct:nb(u),tag:nb(d)};return eb+rb(new TextEncoder().encode(JSON.stringify(f)))}function sb(e){let t=e?.response?.data;return t?.error??t?.message??String(e)}var cb=`does not match`;function lb(e){return e.includes(cb)}async function ub({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`get_secrets_public_key`});return{publicKey:t.public_key,fingerprint:t.fingerprint}}var db=N;async function fb(e){let{data:t}=await db.post(`/ClusterSecrets`,{operation:`get_secrets_public_key`,clusterId:e});return{publicKey:t.publicKey,fingerprint:t.fingerprint}}function pb(e){return z({queryKey:[e.entityId,`get_secrets_public_key`,e.managedClusterId??`node`],queryFn:()=>e.managedClusterId?fb(e.managedClusterId):ub(e),staleTime:3e5,retry:!1})}async function mb({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_secrets`});return t}function hb(e){return z({queryKey:[e.entityId,`list_secrets`],queryFn:()=>mb(e)})}async function gb(e,t,n){let{publicKey:r,fingerprint:i}=await e.ensureQueryData(pb(t)),a=await ob(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=sb(r);if(!n&&lb(i))return e.removeQueries({queryKey:pb(t).queryKey}),gb(e,t,!0);throw Error(i)}}function _b(){let e=oe();return R({mutationFn:t=>gb(e,t,!1)})}async function vb({instanceClient:e,name:t}){try{let{data:n}=await e.post(`/`,{operation:`delete_secret`,name:t});return n}catch(e){throw Error(sb(e))}}function yb(){return R({mutationFn:vb})}async function bb(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(sb(e))}}function xb(){return R({mutationFn:e=>bb(`grant_secret`,e)})}function Sb(){return R({mutationFn:e=>bb(`revoke_secret`,e)})}function Cb({name:e,initialGrants:t,components:n,onChanged:r}){let i=q(),{mutateAsync:a,isPending:o}=xb(),{mutateAsync:s,isPending:c}=Sb(),l=o||c,[u,d]=(0,G.useState)(t),f=(0,G.useCallback)(async t=>{try{let n=await a({...i,name:e,component:t});d(n.grants),r?.()}catch(e){throw U.error(String(e)),e}},[a,i,e,r]),p=(0,G.useCallback)(async t=>{try{let n=await s({...i,name:e,component:t});d(n.grants),r?.()}catch(e){U.error(String(e))}},[s,i,e,r]);return(0,K.jsxs)(`div`,{className:`grid gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium`,children:`Granted applications`}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Only granted applications can read this secret through the `,(0,K.jsx)(`code`,{className:`font-mono`,children:`secrets`}),` `,`accessor. Changes apply immediately.`]}),u.length>0&&(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:u.map(e=>(0,K.jsxs)(Yi,{variant:`secondary`,children:[e,(0,K.jsxs)(`button`,{type:`button`,onClick:()=>void p(e),disabled:l,title:`Revoke ${e}`,className:`cursor-pointer disabled:cursor-default`,children:[(0,K.jsx)(gn,{}),(0,K.jsxs)(`span`,{className:`sr-only`,children:[`Revoke `,e]})]})]},e))}),(0,K.jsx)($y,{components:n,granted:u,onAdd:f,disabled:l,actionLabel:`Grant`})]})}var wb=`********`,Tb=/^[\w.-]+$/,Eb=/^(\s*(?:export\s+)?)([\w.-]+)\s*=(.*)$/;function Db(e){return e.split(`/`).pop()??``}function Ob(e){if(!e)return!1;let t=Db(e).toLowerCase();return t===`.env`||t.startsWith(`.env.`)}var kb=[`.example`,`.sample`,`.template`];function Ab(e){if(!Ob(e))return!1;let t=Db(e).toLowerCase();return kb.some(e=>t.endsWith(e))}function jb(e){return Ob(e)&&!Ab(e)}function Mb(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 Nb(e){return!e||e.length===0?``:e.map(e=>`${e}=${wb}`).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 WD({pageCount:e,disabled:t,onGo:n}){let[r,i]=(0,G.useState)(``);return(0,K.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let a=Number(r);Number.isFinite(a)&&a>=1&&n(Math.min(a,e)),i(``)},className:`hidden items-center gap-2 @min-[840px]:flex`,children:[(0,K.jsx)(`label`,{htmlFor:`pagination-go-to`,className:`text-sm whitespace-nowrap text-muted-foreground`,children:`Go to`}),(0,K.jsx)(`input`,{id:`pagination-go-to`,type:`number`,min:1,max:e,inputMode:`numeric`,placeholder:`Page`,disabled:t,value:r,onChange:e=>i(e.target.value),className:`h-9 w-20 rounded-md border border-input bg-white px-3 text-sm text-foreground
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 GD({pageSize:e,onChange:t}){return(0,K.jsxs)(`div`,{className:`hidden items-center gap-2 @min-[960px]:flex`,children:[(0,K.jsx)(`span`,{className:`text-sm whitespace-nowrap text-muted-foreground`,children:`Rows`}),(0,K.jsxs)(jf,{value:String(e),onValueChange:e=>t(Number(e)),children:[(0,K.jsx)(Pf,{"aria-label":`Rows per page`,className:`h-9 w-20`,children:(0,K.jsx)(Nf,{})}),(0,K.jsx)(Ff,{side:`top`,children:BD.map(e=>(0,K.jsx)(Lf,{value:String(e),children:np(e)},e))})]})]})}function KD(e,t,n=1){if(t<=n*2+5)return qD(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?[...qD(1,s),`ellipsis`,t]:a&&!o?[1,`ellipsis`,...qD(t-s+1,t)]:[1,`ellipsis`,...qD(r,i),`ellipsis`,t]}function qD(e,t){return Array.from({length:t-e+1},(t,n)=>e+n)}function JD({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,setPageIndex:p,setPageSize:m,filtersToggled:h,totalPages:g,totalRecords:_,isEstimatedCount:v,estimatedRange:y,isExactCountFetching:b,isExactCountError:x,onRequestExactCount:S}){let C=Me({features:Kp,data:o||[],columns:n,manualSorting:!0,enableColumnResizing:!0,columnResizeMode:`onEnd`,onColumnSizingChange:a,defaultColumn:{minSize:80},state:{columnVisibility:r,columnSizing:i}}),w=C.state.columnResizing,T=w.isResizingColumn,E=null;if(T){let e=C.options.defaultColumn?.minSize??20,t=C.getColumn(T)?.getSize()??0,n=0;for(let e of C.getVisibleLeafColumns())if(n+=e.getSize(),e.id===T)break;E=n+Math.max(w.deltaOffset??0,e-t)}return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`relative flex flex-col grow`,children:[(0,K.jsxs)(zp,{containerClassName:`rounded-md bg-card dark:bg-black-dark grow overflow-visible`,className:`table-fixed`,children:[(0,K.jsx)(Bp,{children:C.getHeaderGroups().map(e=>(0,K.jsxs)(Hp,{className:`border-none`,children:[e.headers.map(e=>(0,K.jsx)(Wp,{header:e,onColumnClick:c,className:`sticky top-32 z-10 bg-card dark:bg-black-dark border-b border-border`},e.id)),(0,K.jsx)(Up,{"aria-hidden":!0,className:`w-full p-0 sticky top-32 z-10 bg-card dark:bg-black-dark border-b border-border`})]},e.id))}),h&&(0,K.jsx)(FD,{applyFilters:e,columnFiltersForm:t,headerGroups:C.getHeaderGroups()}),(0,K.jsx)(Vp,{className:`bg-background dark:bg-black border border-border dark:border-grey-700`,children:C.getRowModel().rows?.length?C.getRowModel().rows.map(e=>(0,K.jsx)(YD,{row:e,onRowClick:l,primaryKey:f},e.id)):(0,K.jsx)(Hp,{children:(0,K.jsx)(Gp,{colSpan:n.length+1,className:`h-24 text-center`,children:s||o===void 0?(0,K.jsx)(zD,{className:`opacity-50 inline-block`}):(0,K.jsx)(`span`,{children:`No results.`})})})})]}),E!==null&&(0,K.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute top-0 bottom-0 z-20 w-0.5 bg-primary`,style:{left:`${E}px`}})]}),(0,K.jsx)(VD,{pageIndex:u,pageSize:d,totalPages:g,totalRecords:_,isEstimatedCount:v,estimatedRange:y,isExactCountFetching:b,isExactCountError:x,onRequestExactCount:S,setPageIndex:p,setPageSize:m})]})}function YD({row:e,primaryKey:t,onRowClick:n}){let r=e.getVisibleCells(),i=(0,G.useMemo)(()=>{let n=e.original;return n&&n.message===`This entry has expired`?r[0]?.column?.id===t?[(0,K.jsx)(XD,{cell:r[0]},r[0].id),(0,K.jsx)(ZD,{colSpan:r.length-1},`expired`)]:[(0,K.jsx)(ZD,{colSpan:r.length},`expired`)]:r.map(e=>(0,K.jsx)(XD,{cell:e},e.id))},[e,t,r]);return(0,K.jsxs)(Hp,{"data-state":e.getIsSelected()&&`selected`,onClick:()=>n?.(e),className:P(`hover:bg-muted/10 data-[state=selected]:bg-muted`,n&&`cursor-pointer`),children:[i,(0,K.jsx)(Gp,{"aria-hidden":!0,className:`p-0`})]})}function XD({cell:e}){let t=e.column.getSize();return(0,K.jsx)(Gp,{"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:De(e.column.columnDef.cell,e.getContext())})}function ZD({colSpan:e}){return(0,K.jsx)(Gp,{colSpan:e,className:`px-2 py-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,children:(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`This entry has expired`})})}function QD({instanceDatabaseMap:e,databaseName:t,tableName:n}){let r=B({strict:!1}),i=q(),{clusterId:a,instanceId:o}=r,{toggled:s,toggle:c}=wD(!0),l=En(`instance:update`),u=iu(o??a,t,n,`insert`),d=au(o??a,t,n),f=iu(o??a,t,n,`update`),p=iu(o??a,t,n,`delete`),m=ru(),{data:h}=H(pw({...i,databaseName:t,tableName:n})),g=e?.[t],_=g?.[n],v=h??_,y=(0,G.useMemo)(()=>Hu(v?.attributes??[],`attribute`),[v]),{data:b}=H(bD(i)),x=b?.[t]?.[n],S=(0,G.useMemo)(()=>Yx(v,g,x),[v,g,x]),C=(0,G.useMemo)(()=>eS(v,g),[v,g]),w=(0,G.useMemo)(()=>Zx(v?.attributes,g),[v,g]),[T,E]=Ah(null,r),[D,O]=(0,G.useState)(!1),[k,A]=Ah(null,r),j=(0,G.useMemo)(()=>(t?Object.keys(e?.[t]||[]).sort():[]).length===1,[e,t]),{toggled:ee,toggleOn:M,toggleOff:N}=wD(!1),P=Pt({resolver:Ke(PD)}),{reset:te}=P,ne=P.watch(),[I,L]=Ah(null,[r.clusterId,r.instanceId,t,n]),re=(0,G.useCallback)(e=>{let t=[];for(let n in e){let r=e[n];if(r?.length)try{t.push(...rw(n,r,y[n],S[n]))}catch(e){U.error(String(e))}}return t},[y,S]),ie=(0,G.useCallback)(()=>{let e=re(ne);L(e.length?e:null),te({...ne})},[re,te,ne]),ae=(0,G.useCallback)(()=>{te({},{keepValues:!1,keepDirtyValues:!1,keepDefaultValues:!1}),te(),L(null),N()},[N,te]);(0,G.useEffect)(function(){return ae()},[r,ae]);let{filters:R}=le({strict:!1}),z=JSON.stringify([t,n,R??null]),se=(0,G.useRef)(null);(0,G.useEffect)(function(){if(!v||se.current===z)return;let e=se.current===null;if(se.current=z,R){te({...R});let e=re(R);L(e.length?e:null),M()}else e||ae()},[R,z,v,te,re,L,M,ae]);let{dataTableColumns:ce,primaryKey:ue}=GC(v,S),[de,fe]=Ah({attribute:ue,descending:!1},r),[pe,me]=Ah(0,[t,n,I]),[he,ge]=(0,G.useState)(20),_e=h?.record_count??_?.record_count,ve=h?.estimated_record_range??_?.estimated_record_range,[ye,be]=Ah(!1,[t,n]),{data:xe,isFetching:Se,isError:Ce,refetch:we}=H(jD({...i,enabled:ye,databaseName:t,tableName:n})),Te=(0,G.useCallback)(()=>{ye?we():be(!0)},[ye,we,be]),Ee=xe??_e,De=Ee?Math.ceil(Ee/he):0,Oe=xe===void 0&&ve!==void 0,ke=ee&&!!I,Ae=vg({...i,enabled:!ke&&!!ue,databaseName:t,tableName:n,searchAttribute:ue,sort:de,pageSize:he,pageIndex:pe,onlyIfCached:s,getAttributes:C}),{data:je,isFetching:Me}=H(Ae),Ne=tw({...i,enabled:ke&&!!ue,databaseName:t,tableName:n,conditions:I,sort:de,pageSize:he,pageIndex:pe,onlyIfCached:s,getAttributes:C}),{data:Pe,isFetching:Fe}=H(Ne),Ie=ke?Pe:je,Le=Me||Fe,{data:Re,isFetching:ze,isError:Be}=H(kD({...i,enabled:D,databaseName:t,tableName:n,ids:T})),Ve=D&&!!k&&(!ue||k[ue]==null),He=Re?.data,Ue=!Ve&&!!T?.length&&!ze&&(Be||Array.isArray(He)&&He.length===0),{mutate:We,isPending:Ge}=ND(),{mutate:qe,isPending:Je}=OD(),{mutate:Ye,isPending:Xe}=ED(),Ze=oe(),Qe=(0,G.useCallback)(()=>Ze.invalidateQueries({queryKey:[i.entityId,t,n]}),[Ze,i.entityId,t,n]),$e=(0,G.useCallback)(async()=>{confirm(`Are you sure you want to cleanup orphan blobs for database "${t}"?`)&&Ye({...i,databaseName:t},{onSuccess:e=>{U.success(e.message||`Orphan blobs cleanup started successfully`),Qe()},onError:e=>{U.error(e instanceof Error?e.message:`Failed to cleanup orphan blobs`)}})},[Ye,t,i,Qe]),{exportCsv:et,isExporting:tt}=lw(),nt=(0,G.useCallback)(()=>{et({databaseName:t,tableName:n,primaryKey:ue,sort:de,conditions:ke?I:null})},[et,t,n,ue,de,ke,I]),rt=(0,G.useCallback)(e=>{We({...i,databaseName:t,tableName:n,records:e},{onSuccess:()=>{Qe(),O(!1),U.success(`Record updated successfully`)}})},[We,i,t,n,Qe]),it=(0,G.useCallback)(e=>{qe({...i,databaseName:t,tableName:n,hashValues:e},{onSuccess:()=>{Qe(),O(!1),U.success(`Record deleted successfully`)}})},[qe,i,t,n,Qe]),at=e=>{let t=ue?e.original[ue]:void 0;A(e.original),E(t==null?null:[t]),O(!0)},ot=(e,t)=>{fe({attribute:e,descending:!t})},st=$p(Qe),ct=(0,G.useCallback)(()=>{aC(`ShowAddTableRecords`,{databaseName:t,tableName:n})},[t,n]),lt=(0,G.useCallback)(()=>{aC(`ShowImportData`,{databaseName:t,tableName:n})},[t,n]),[ut,dt]=Ih(`ColumnDisplayed/${t}/${n}`,{}),ft=(0,G.useMemo)(()=>({...Object.fromEntries($x(S).map(e=>[e,!1])),...ut}),[S,ut]),[pt,mt]=Ih(`ColumnSizing/${t}/${n}`,{});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex flex-col md:flex-row items-center justify-between space-y-3 md:space-y-0 md:space-x-3 pt-15 pb-4 pr-4`,children:[(0,K.jsxs)(`div`,{className:`flex space-x-2`,children:[u&&(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:ct,accessKey:`n`,children:[(0,K.jsx)(Gr,{}),(0,K.jsxs)(`span`,{children:[`Add `,(0,K.jsx)(`u`,{children:`N`}),`ew Record(s)`]})]}),d&&(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:lt,accessKey:`i`,children:[(0,K.jsx)(ar,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`I`}),`mport Data`]})]}),(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:nt,disabled:tt,accessKey:`e`,children:[(0,K.jsx)(ir,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`E`}),`xport CSV`]})]})]}),(0,K.jsxs)(`div`,{className:`flex space-x-2`,children:[ee&&I&&(0,K.jsxs)(F,{type:`button`,variant:`ghost`,onClick:ae,accessKey:`f`,children:[(0,K.jsx)(gr,{className:`inline-block `}),(0,K.jsxs)(`span`,{children:[`Clear `,(0,K.jsx)(`u`,{children:`F`}),`ilters`]})]}),ee&&P.formState.isDirty&&(0,K.jsxs)(F,{variant:`default`,onClick:ie,children:[(0,K.jsx)(hr,{className:`inline-block `}),`Apply Filters`]}),ee&&!I&&(0,K.jsxs)(F,{variant:`ghost`,onClick:N,accessKey:`f`,children:[(0,K.jsx)(gr,{className:`inline-block `}),(0,K.jsxs)(`span`,{children:[`Hide `,(0,K.jsx)(`u`,{children:`F`}),`ilters`]})]}),!ee&&(0,K.jsxs)(F,{variant:`ghost`,onClick:M,accessKey:`f`,children:[(0,K.jsx)(_r,{className:`inline-block `}),(0,K.jsxs)(`span`,{children:[`Show `,(0,K.jsx)(`u`,{children:`F`}),`ilters`]})]}),(0,K.jsx)(F,{variant:`defaultOutline`,onClick:st,disabled:Le,children:(0,K.jsx)(Kr,{})}),(0,K.jsx)(LD,{columns:ce,columnVisibility:ft,setColumnVisibility:dt}),(0,K.jsxs)(Ti,{children:[(0,K.jsx)(Ei,{asChild:!0,disabled:!e,children:(0,K.jsx)(F,{variant:`ghost`,size:`icon`,disabled:!e,children:(0,K.jsx)(ur,{"aria-label":`Table options`})})}),(0,K.jsxs)(Di,{side:`bottom`,align:`end`,children:[(0,K.jsxs)(Oi,{className:`focus:bg-primary/70 focus:text-white`,onClick:c,children:[s?(0,K.jsx)(Zn,{className:`text-green`}):(0,K.jsx)(er,{}),`Only If Cached`,(0,K.jsx)(V,{to:`https://docs.harperdb.io/docs/developers/applications/caching#cache-control-header`,target:`_blank`,rel:`noopener noreferrer`,onClick:BC,children:(0,K.jsx)(dr,{})})]}),m&&l&&!!o&&(0,K.jsxs)(Oi,{className:`focus:bg-yellow/70 focus:text-white`,onClick:$e,disabled:Xe,children:[(0,K.jsx)(Un,{className:`text-yellow `}),`Cleanup Orphan Blobs`]}),m&&!j&&(0,K.jsxs)(Oi,{className:`focus:bg-red/70 focus:text-white`,onClick:()=>aC(`ShowDeleteTable`,{databaseName:t,tableName:n}),children:[(0,K.jsx)(fi,{className:`inline-block `}),`Drop Table`]}),m&&(0,K.jsxs)(Oi,{className:`focus:bg-red/70 focus:text-white`,onClick:()=>aC(`ShowDeleteDatabase`,{databaseName:t}),children:[(0,K.jsx)(pi,{}),`Drop Database`]})]})]})]})]}),(0,K.jsx)(JD,{primaryKey:ue,data:Ie?.data,isFetching:Le,filtersToggled:ee,columns:ce,columnVisibility:ft,columnSizing:pt,setColumnSizing:mt,onRowClick:at,onColumnClick:ot,totalPages:De,totalRecords:Ee,isEstimatedCount:Oe,estimatedRange:ve,isExactCountFetching:Se,isExactCountError:Ce,onRequestExactCount:Te,pageIndex:pe,pageSize:he,columnFiltersForm:P,applyFilters:ie,setPageIndex:me,setPageSize:ge}),(0,K.jsx)(CD,{canEditRecords:f,canDeleteRecords:p,setIsModalOpen:O,isModalOpen:D,primaryKey:ue,missingPrimaryKey:Ve,recordUnavailable:Ue,syntheticAttributes:w,data:Ve||Ue?k?[k]:void 0:Re?.data,onSaveChanges:rt,onDeleteRecord:it,isUpdateTableRecordsPending:Ge,isDeleteTableRecordsPending:Je})]})}function $D(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 eO=10;function tO(e){return Math.max(200,Math.floor(e/2))}function nO(e,t){return Math.round(Math.min(Math.max(e,200),tO(t)))}function rO(){let[e,t]=xn(vn.DatabasesSidebarWidth,320),[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(()=>nO(e,window.innerWidth)),o=(0,G.useRef)(i);o.current=i;let s=(0,G.useRef)(null);(0,G.useEffect)(()=>{n||a(nO(e,window.innerWidth))},[e,n]),(0,G.useEffect)(()=>{let t=()=>{n||a(nO(e,window.innerWidth))};return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e,n]);let c=(0,G.useCallback)(e=>{e.preventDefault(),s.current={startX:e.clientX,startWidth:o.current},r(!0)},[]);return(0,G.useEffect)(()=>{if(!n)return;let e=e=>{let t=s.current;t&&a(nO(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,G.useCallback)(e=>{e.key===`ArrowLeft`?(e.preventDefault(),t(e=>nO(e-eO,window.innerWidth))):e.key===`ArrowRight`&&(e.preventDefault(),t(e=>nO(e+eO,window.innerWidth)))},[t])}}function iO(){let e=B({strict:!1}),t=q(),{data:n}=H(qy({...t,skipRecordCount:!0})),{width:r,isResizing:i,startResizing:a,handleKeyDown:o}=rO(),s={"--db-sidebar-width":`${r}px`},c=$D(n,e);return c?(0,K.jsx)(re,{to:Ux({...e,...c}),replace:!0}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`main`,{className:`flex flex-col gap-4 md:flex-row md:items-start`,children:[(0,K.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,K.jsx)(vE,{instanceDatabaseMap:n}),(0,K.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,"aria-valuenow":r,"aria-valuemin":200,"aria-valuemax":tO(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,K.jsx)(`div`,{className:P(`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,K.jsx)(`section`,{className:`text-foreground w-full md:flex-1 md:min-w-0 flex flex-col min-h-0`,children:e.databaseName&&e.tableName?(0,K.jsx)(QD,{instanceDatabaseMap:n,databaseName:e.databaseName,tableName:e.tableName}):e.databaseName?(0,K.jsx)(vw,{instanceDatabaseMap:n,databaseName:e.databaseName}):null})]}),n&&(0,K.jsx)(zC,{instanceDatabaseMap:n})]})}function aO(e){return I({getParentRoute:()=>e,path:`/databases/{-$databaseName}/{-$tableName}`,head:()=>({meta:[{title:`Databases — Harper Fabric`}]}),component:iO})}var oO={className:`text-primary font-semibold bg-primary/10 rounded-md dark:text-white dark:bg-white/10`};function sO(){let e=nu(),t=B({strict:!1}),{version:n}=te({strict:!1}),r=Pc(`4.6.0`,n)&&e,i=Pc(`4.7.0-beta.7`,n),a=q(),{data:o}=H(n_(a,r)),s=o?.restartRequired??!1,c=(0,G.useMemo)(()=>[e&&{to:t.clusterId&&!t.instanceId?hv(t,`apps`):hv(t),activeOptions:{exact:!0},name:`Applications`,shortName:`Apps`,icon:(0,K.jsx)(Hr,{className:`inline-block`})},{to:hv(t,`databases`),icon:(0,K.jsx)(lr,{className:`inline-block`}),name:`Databases`},e&&i&&{to:hv(t,`apis`),name:`APIs`,icon:(0,K.jsx)($r,{className:`inline-block`})},e&&r&&{to:hv(t,`status`),icon:(0,K.jsx)(vr,{className:`inline-block`}),name:`Status`},e&&{to:hv(t,`logs`),icon:(0,K.jsx)(Br,{className:`inline-block`}),name:`Logs`},e&&{to:hv(t,`config`),icon:(0,K.jsx)(ei,{className:`inline-block`}),name:`Config`}].filter($a),[e,t,i,r]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cO,{links:c,restartRequired:s}),(0,K.jsx)(lO,{links:c,restartRequired:s})]})}function cO({links:e,restartRequired:t}){return(0,K.jsxs)(`div`,{className:`hidden md:[@media(hover:hover)]:flex xl:flex items-center justify-between h-full text-sm text-foreground`,children:[(0,K.jsx)(Fo,{restartRequired:t}),(0,K.jsx)(`div`,{className:`flex space-x-2`,children:e.map(({shortName:e,...t})=>{let n=(0,K.jsxs)(V,{"aria-label":t.name,className:`p-2 text-center text-muted-foreground hover:text-foreground`,activeProps:oO,...t,children:[t.icon,(0,K.jsx)(`span`,{className:`hidden xl:inline-block ml-1`,children:t.name}),e&&(0,K.jsx)(`span`,{className:`visible xl:hidden ml-1`,children:e})]},t.to);return e?n:(0,K.jsxs)(Va,{children:[(0,K.jsx)(Ha,{asChild:!0,children:n}),(0,K.jsx)(Ua,{side:`bottom`,className:`xl:hidden`,children:t.name})]},t.to)})})]})}function lO({links:e,restartRequired:t}){return(0,K.jsx)(K.Fragment,{children:(0,K.jsxs)(`div`,{className:`flex md:[@media(hover:hover)]:hidden xl:hidden items-center justify-between h-full px-2 text-foreground`,children:[(0,K.jsx)(Fo,{restartRequired:t}),(0,K.jsxs)(Ti,{children:[(0,K.jsx)(Ei,{asChild:!0,children:(0,K.jsx)(F,{variant:`ghost`,className:`p-0`,children:(0,K.jsx)(Lr,{className:`h-8 w-8`})})}),(0,K.jsxs)(Di,{children:[(0,K.jsx)(Ai,{children:`Instance Menu`}),(0,K.jsx)(ji,{}),e.map(e=>(0,K.jsx)(Oi,{asChild:!0,children:(0,K.jsxs)(V,{to:e.to,activeProps:oO,className:`flex items-center gap-2`,children:[e.icon,e.name]})},e.to))]})]})]})})}(0,G.lazy)(()=>ze(()=>import(`./FloatingChat-BvmHsuVo.js`).then(e=>({default:e.FloatingChat})),__vite__mapDeps([35,1,4,5,9,11,12,13])));function uO(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.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,K.jsx)(sO,{})}),(0,K.jsx)(`div`,{className:`mt-32 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsx)(Le,{})}),!1]})}function dO(e){switch(e){case`local`:return I({getParentRoute:()=>xo,id:`_instanceLayout`,component:uO,loader:Vx});case`cluster`:return I({getParentRoute:()=>Hh,id:`_instanceLayout`,component:uO,beforeLoad:fO,loader:Vx});case`instance`:return I({getParentRoute:()=>Hh,path:`instance/$instanceId`,component:uO,beforeLoad:fO,loader:Vx})}}async function fO({context:e,params:t}){let n=t.instanceId||t.clusterId,r=!1;if(u.checkForFabricConnect(n)&&!u.hasResolvedFabricConnect(n)&&(r=!0,await pO(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?eu(a.user,t.organizationId,t.clusterId):Zl(a.user,t.organizationId,t.clusterId);if(!r&&o&&await pO(n,e.cluster,t.instanceId))return;let s=`/${t.organizationId}/${t.clusterId}/`+(t.instanceId?`instance/${t.instanceId}`:``)+`/sign-in`;throw ie({to:s,search:fo()})}async function pO(e,t,n){try{return await u.establishFabricConnectAuth({id:e,operationsUrl:mO(t,n)}),!0}catch(e){return console.debug(`Fabric Connect not established`,e),!1}}function mO(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 hO(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 gO=[`secondary`,`default`,`warning`,`outline`,`success`,`destructive`],_O=0,vO=new Map,yO=e=>{if(vO.has(e))return vO.get(e);_O++;let t=gO[_O%gO.length];return vO.set(e,t),t};function bO(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 xO({columns:e,data:t,onRowClick:n,containerRef:r}){let i=Me({features:Kp,data:t,columns:e});return(0,K.jsxs)(zp,{className:`text-xs`,containerRef:r,containerClassName:`rounded-md bg-card dark:bg-black-dark logsTable max-h-[calc(100vh-(--spacing(48)))] overflow-y-auto md:max-h-[calc(100vh-(--spacing(40)))]`,children:[(0,K.jsx)(Bp,{children:i.getHeaderGroups().map(e=>(0,K.jsx)(Hp,{className:`border-b border-border`,children:e.headers.map(e=>(0,K.jsx)(Up,{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:De(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,K.jsx)(Vp,{className:`bg-background dark:bg-black`,children:i.getRowModel().rows?.length?i.getRowModel().rows.map(e=>(0,K.jsx)(Hp,{"data-state":e.getIsSelected()&&`selected`,className:P(`hover:bg-muted/20 data-[state=selected]:bg-muted max-w-full border-l-2`,bO(e.original.level),n&&`cursor-pointer`),onClick:()=>n?.(e),children:e.getVisibleCells().map(e=>(0,K.jsx)(Gp,{className:`p-2`,children:De(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,K.jsx)(Hp,{children:(0,K.jsx)(Gp,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})}var SO=524288,CO=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 wO(e){try{JSON.parse(e)}catch{return!1}return!0}function TO(e){return!e||e.length>524288?`plaintext`:wO(e)?`json`:`plaintext`}function EO({label:e,children:t}){return(0,K.jsxs)(`div`,{className:`flex items-start gap-3 py-1.5 border-b border-border/50 last:border-0`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground w-20 shrink-0 pt-0.5`,children:e}),(0,K.jsx)(`span`,{className:`text-xs`,children:t})]})}function DO({setIsModalOpen:e,isModalOpen:t,data:n}){let r=n?yO(n.node):`default`,i=dm();return(0,K.jsx)(fn,{onOpenChange:e,open:t,children:(0,K.jsxs)(cn,{"aria-describedby":void 0,resizable:!0,children:[(0,K.jsx)(rn,{children:(0,K.jsx)(ln,{children:`Log Entry`})}),n?(0,K.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 text-popover-foreground`,children:[(0,K.jsxs)(`div`,{className:`rounded-md border border-border/50 bg-muted/20 px-3 py-1`,children:[(0,K.jsx)(EO,{label:`Level`,children:(0,K.jsx)(Yi,{variant:hO(n.level),children:No(n.level)})}),(0,K.jsx)(EO,{label:`Timestamp`,children:(0,K.jsx)(`span`,{className:`tabular-nums`,children:new Date(n.timestamp).toLocaleString()})}),(0,K.jsx)(EO,{label:`Thread`,children:(0,K.jsx)(`span`,{className:`tabular-nums font-mono`,children:n.thread})}),n.node&&(0,K.jsx)(EO,{label:`Node`,children:(0,K.jsx)(Yi,{variant:r,children:n.node})}),n.tags&&n.tags.length>0&&(0,K.jsx)(EO,{label:`Tags`,children:(0,K.jsx)(`span`,{className:`font-mono`,children:n.tags})})]}),(0,K.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`Message`}),(0,K.jsx)(`div`,{className:`rounded-md overflow-hidden border border-border/50 flex-1 min-h-0`,children:(0,K.jsx)(pm,{className:`w-full h-full`,language:TO(n.message),theme:i,value:n.message,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12,padding:{top:12,bottom:12},automaticLayout:!0}})})]})]}):(0,K.jsx)(Gi,{})]})})}var OO=b({limit:M().or(x()).or(E()).optional(),level:O([`notify`,`error`,`warn`,`info`,`debug`,`trace`,`undefined`]).or(x()).or(E()).optional(),from:M().or(x()).or(E()).optional(),until:M().or(x()).or(E()).optional(),log_name:O([`hdb.log`,`system.log`]).or(x()).or(E()).optional(),filter:M().or(x()).or(E()).optional()}),kO=`dark:bg-grey-600 dark:border-grey-500`;function AO({form:e,resetFilters:t,submitFilters:n,showLogName:r,showFilter:i,isOpen:a,onOpenChange:o}){return(0,K.jsxs)(On,{className:P(a?`block`:`hidden`,`mt-3 md:mt-0 md:block`),children:[(0,K.jsx)(kn,{className:`hidden md:block`,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>o(!a),"aria-expanded":a,"aria-controls":`logs-filters-content`,className:`flex w-full items-center justify-between md:pointer-events-none`,children:(0,K.jsxs)(An,{className:`flex items-center gap-2 text-base`,children:[(0,K.jsx)(ri,{className:`size-4 text-muted-foreground`}),`Filters`]})})}),(0,K.jsx)(Mn,{id:`logs-filters-content`,children:(0,K.jsx)(Io,{...e,children:(0,K.jsxs)(`form`,{id:`instance-edit-log-filters-form`,name:`instance-edit-log-filters-form`,onSubmit:e.handleSubmit(n),className:`flex-col space-y-4`,children:[i&&(0,K.jsx)(Y,{control:e.control,name:`filter`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(J,{children:(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Qr,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,K.jsx)($,{type:`search`,placeholder:`Search logs…`,className:P(`pl-9`,kO),value:e.value??``,onChange:e.onChange})]})}),(0,K.jsx)(Q,{})]})}),r&&(0,K.jsx)(Y,{control:e.control,name:`log_name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Log file`}),(0,K.jsxs)(jf,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,K.jsx)(Pf,{className:P(`w-full bg-white`,kO),children:(0,K.jsx)(Nf,{placeholder:`Select log file`})}),(0,K.jsx)(Ff,{children:(0,K.jsxs)(Mf,{children:[(0,K.jsx)(Lf,{value:`hdb.log`,children:`Application (hdb.log)`}),(0,K.jsx)(Lf,{value:`system.log`,children:`System (system.log)`})]})})]}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsx)(Y,{control:e.control,name:`limit`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Limit`}),(0,K.jsxs)(jf,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,K.jsx)(Pf,{className:P(`w-full bg-white`,kO),children:(0,K.jsx)(Nf,{placeholder:`Limit`})}),(0,K.jsx)(Ff,{children:(0,K.jsxs)(Mf,{children:[(0,K.jsx)(Lf,{value:`1000`,children:`1000`}),(0,K.jsx)(Lf,{value:`500`,children:`500`}),(0,K.jsx)(Lf,{value:`250`,children:`250`}),(0,K.jsx)(Lf,{value:`100`,children:`100`}),(0,K.jsx)(Lf,{value:`10`,children:`10`})]})})]}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:e.control,name:`level`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Level`}),(0,K.jsxs)(jf,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,K.jsx)(Pf,{className:P(`w-full bg-white`,kO),children:(0,K.jsx)(Nf,{placeholder:`Level`})}),(0,K.jsx)(Ff,{children:(0,K.jsxs)(Mf,{children:[(0,K.jsx)(Lf,{value:`undefined`,children:`All`}),(0,K.jsx)(Lf,{value:`notify`,children:`Notify`}),(0,K.jsx)(Lf,{value:`error`,children:`Error`}),(0,K.jsx)(Lf,{value:`warn`,children:`Warn`}),(0,K.jsx)(Lf,{value:`info`,children:`Info`}),(0,K.jsx)(Lf,{value:`debug`,children:`Debug`}),(0,K.jsx)(Lf,{value:`trace`,children:`Trace`})]})})]}),(0,K.jsx)(Q,{})]})})]}),(0,K.jsx)(Y,{control:e.control,name:`from`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Start date`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`datetime-local`,className:kO,value:e.value??void 0,onChange:e.onChange})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:e.control,name:`until`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`End date`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`datetime-local`,className:kO,value:e.value??void 0,onChange:e.onChange})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,K.jsx)(F,{type:`submit`,variant:`positiveOutline`,className:`grow`,children:`Apply Filters`}),(0,K.jsx)(F,{type:`reset`,variant:`destructiveOutline`,onClick:t,children:`Clear`})]})]})})})]})}var jO=1e4;function MO(e){if(!e)return;let t=parseInt(e,10);if(!(!Number.isFinite(t)||t<=0))return Math.min(t,jO)}function NO(e,t){return{operation:`read_log`,start:0,replicated:t,limit:MO(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 PO({instanceClient:e,logFilters:t,replicated:n}){let{data:r}=await e.post(`/`,NO(t,n));return r}function FO(e){let t=e.logFilters;return z({queryKey:[`read_log`,e.entityId,t.limit,t.level,t.from,t.until,t.log_name,t.filter,e.replicated],queryFn:()=>PO(e),retry:!1,refetchInterval:e.isAutoRefreshEnabled?5e3:!1})}async function IO({connection:e,logFilters:t,replicated:n,signal:r,onEntry:i}){let{url:a,headers:o,credentials:s}=uv(e),c;try{c=await fetch(a,{method:`POST`,headers:o,credentials:s,body:JSON.stringify(NO(t,n)),signal:r})}catch(e){throw r?.aborted?e:new sv(`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 sv(`read_log did not return an event stream (status ${c.status}, content-type "${l}").`);for await(let e of iv(c.body,r)){if(e.event===`error`){let t=ov(e);if(!t||typeof t!=`object`)throw new lv(typeof t==`string`&&t?t:`The log stream failed.`);let n=t;throw new lv(n.message??`The log stream failed.`,{code:n.code})}if(e.event===`done`||e.event===`end`)return;for(let t of LO(ov(e)))i(t)}}function LO(e){return Array.isArray(e)?e.filter(RO):RO(e)?[e]:[]}function RO(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 zO(e){return[e.timestamp,e.node??``,e.thread??``,e.level,e.message].join(`|`)}function BO(e,t,n){let r=new Set,i=[];for(let n of[...t,...e]){let e=zO(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 VO={entries:[],fellBack:!1};function HO(e,t){switch(t.kind){case`reset`:return VO;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 UO(){let e=q();return u.isDirectConnection(e.entityId)}var WO=1e3,GO=2e3,KO=250;function qO(e){return MO(e)??WO}function JO(e,t){return JSON.stringify([e.limit,e.level,e.from,e.until,e.log_name,e.filter,t])}function YO({params:e,logFilters:t,replicated:n,live:r}){let i=UO(),[a,o]=(0,G.useReducer)(HO,VO),s=r&&i&&!a.fellBack,c=JO(t,n),l=qO(t.limit),u=Math.max(GO,l),d=H(FO({...e,logFilters:t,replicated:n,isAutoRefreshEnabled:r&&!s}));(0,G.useEffect)(()=>{o({kind:`reset`})},[e.entityId,c]),(0,G.useEffect)(()=>{r&&o({kind:`retry`})},[r]);let f=(0,G.useRef)({logFilters:t,replicated:n});f.current={logFilters:t,replicated:n},(0,G.useEffect)(()=>{if(!s)return;let t=new AbortController,n=[],r=()=>{if(n.length>0&&!t.signal.aborted){let e=n;n=[],o({kind:`append`,entries:e,cap:u})}},i=setInterval(r,KO);return IO({connection:{id:e.entityId},logFilters:f.current.logFilters,replicated:f.current.replicated,signal:t.signal,onEntry:e=>n.push(e)}).catch(()=>{}).finally(()=>{clearInterval(i),!t.signal.aborted&&(r(),o({kind:`fellBack`}))}),()=>{clearInterval(i),t.abort()}},[s,e.entityId,c]);let p=(0,G.useMemo)(()=>{let e=d.data??[];return a.entries.length===0?e:BO(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 XO={log_name:`hdb.log`,limit:`100`,level:`undefined`,from:``,until:``,filter:``},ZO={error:(0,K.jsx)(Xn,{className:`size-3`}),stderr:(0,K.jsx)(Xn,{className:`size-3`}),warn:(0,K.jsx)(mi,{className:`size-3`}),notify:(0,K.jsx)(Vn,{className:`size-3`}),info:(0,K.jsx)(wr,{className:`size-3`}),debug:(0,K.jsx)(Wn,{className:`size-3`}),trace:(0,K.jsx)(Fn,{className:`size-3`}),stdout:(0,K.jsx)(ui,{className:`size-3`})},QO=[{accessorKey:`level`,header:`Level`,cell:({row:e})=>{let{level:t}=e.original;return(0,K.jsxs)(Yi,{variant:hO(t),children:[ZO[t],No(t)]})}},{accessorKey:`timestamp`,header:`Timestamp`,cell:({row:e})=>{let{timestamp:t}=e.original,n=new Date(t),r=n.getFullYear()===new Date().getFullYear()?n.toLocaleDateString(void 0,{month:`numeric`,day:`2-digit`}):n.toLocaleDateString();return(0,K.jsxs)(`span`,{className:`tabular-nums whitespace-nowrap text-muted-foreground`,children:[r,` `,n.toLocaleTimeString()]})}},{accessorKey:`message`,header:`Message`,cell:({row:e})=>{let{message:t}=e.original;return(0,K.jsx)(`span`,{className:`block max-w-xl truncate font-mono text-xs`,children:t})}},{accessorKey:`thread`,header:`Thread`,cell:({row:e})=>(0,K.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:e.original.thread})},{accessorKey:`node`,header:`Node`,cell:({row:e})=>{let{node:t}=e.original,n=yO(t);return(0,K.jsx)(K.Fragment,{children:t?(0,K.jsxs)(Va,{children:[(0,K.jsx)(Ha,{asChild:!0,children:(0,K.jsxs)(Yi,{variant:n,children:[t.split(`.`)[0],`...`]})}),(0,K.jsx)(Ua,{className:`bg-popover text-popover-foreground border border-border`,arrowClassName:`bg-popover fill-popover`,children:t})]}):null})}},{accessorKey:`tags`,header:`Tags`,cell:({row:e})=>{let{tags:t}=e.original;return t&&t.length>0?(0,K.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null}}],$O=(e,t)=>!e&&!t||!e||!t||new Date(e)<=new Date(t);function ek(){return(0,K.jsxs)(`div`,{className:`rounded-md bg-card dark:bg-black-dark overflow-hidden`,children:[(0,K.jsx)(`div`,{className:`flex gap-4 p-4 border-b border-border`,children:[`w-14`,`w-32`,`w-14`,`w-24`,`w-16`,`flex-1`].map((e,t)=>(0,K.jsx)(rh,{className:`h-4 ${e}`},t))}),Array.from({length:12}).map((e,t)=>(0,K.jsxs)(`div`,{className:`flex gap-4 p-3 border-b border-border/40 border-l-2 border-l-transparent`,children:[(0,K.jsx)(rh,{className:`h-5 w-14`}),(0,K.jsx)(rh,{className:`h-5 w-32`}),(0,K.jsx)(rh,{className:`h-5 w-10`}),(0,K.jsx)(rh,{className:`h-5 w-20`}),(0,K.jsx)(rh,{className:`h-5 w-12`}),(0,K.jsx)(rh,{className:`h-5 flex-1 max-w-xs`})]},t))]})}function tk(){let[e,t]=(0,G.useState)(XO),[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(),[o,s]=(0,G.useState)(!1),[c,l]=xn(vn.LogsOrderReversed,!1),[u,d]=(0,G.useState)(!1),f=q(),{data:p}=H(wv(f)),m=p?.version,h=!!m&&Pc(`4.7.16`,m),{logs:g,isLoading:_,isFetching:v,refetch:y,transport:b}=YO({params:f,logFilters:e,replicated:f.entityType===`cluster`,live:o}),x=(0,G.useMemo)(()=>c?[...g??[]].reverse():g??[],[g,c]),S=(0,G.useRef)(null);(0,G.useEffect)(()=>{let e=S.current;_||!e||e.scrollTo({top:c?e.scrollHeight:0})},[c,_]),(0,G.useEffect)(()=>{let e=S.current;!o||_||!e||e.scrollTo({top:c?e.scrollHeight:0})},[x,o,c,_]);let C=Pt({resolver:Ke(OO),defaultValues:XO,mode:`onChange`}),w=e=>{a(e.original),r(!0)},T=async e=>{if(!$O(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(XO)},D=$p(y);return(0,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 pt-2 text-foreground md:grid-cols-12 md:gap-4`,children:[(0,K.jsxs)(`section`,{className:`col-span-1 md:col-span-4 lg:col-span-3 px-2 pb-0 md:self-start md:sticky md:top-34 md:max-h-[calc(100vh-(--spacing(34)))] md:overflow-y-auto md:pb-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 md:hidden`,children:[(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:()=>d(e=>!e),"aria-label":`Toggle filters`,"aria-expanded":u,className:`flex-1`,children:[(0,K.jsx)(ri,{}),`Filters`]}),(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:D,disabled:v||_||o,"aria-label":`Refresh logs`,className:`flex-1`,children:[(0,K.jsx)(Kr,{className:v?`animate-spin`:``}),`Refresh`]}),(0,K.jsxs)(F,{variant:c?`default`:`defaultOutline`,onClick:()=>l(e=>!e),"aria-label":`Reverse log order`,"aria-pressed":c,className:`flex-1`,children:[(0,K.jsx)(zn,{}),`Reverse`]})]}),(0,K.jsx)(AO,{form:C,resetFilters:E,submitFilters:T,showLogName:!1,showFilter:h,isOpen:u,onOpenChange:d}),(0,K.jsxs)(`div`,{className:`mt-3 space-y-3 hidden md:block`,children:[(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:D,disabled:v||_||o,className:`w-full`,children:[(0,K.jsx)(Kr,{}),`Refresh`]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,K.jsx)(Dm,{id:`logs-live-switch`,"aria-label":`Toggle live logs`,checked:o,onCheckedChange:s}),(0,K.jsxs)(`label`,{htmlFor:`logs-live-switch`,className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(Kr,{className:`size-4 ${o?`animate-spin [animation-duration:3s]`:``}`}),o?b===`streaming`?`Live (streaming)`:`Live (polling every 5s)`:`Live`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,K.jsx)(Dm,{id:`logs-reverse-order-switch`,"aria-label":`Reverse log order`,checked:c,onCheckedChange:l}),(0,K.jsxs)(`label`,{htmlFor:`logs-reverse-order-switch`,className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(zn,{className:`size-4`}),c?`Oldest first`:`Newest first`]})]})]})]})]}),(0,K.jsx)(`section`,{className:`col-span-1 md:col-span-8 lg:col-span-9`,children:_?(0,K.jsx)(ek,{}):(0,K.jsx)(xO,{columns:QO,data:x,onRowClick:w,containerRef:S})}),(0,K.jsx)(DO,{isModalOpen:n,setIsModalOpen:r,data:i})]})}function nk(e){return I({getParentRoute:()=>e,path:`logs`,head:()=>({meta:[{title:`Logs — Harper Fabric`}]}),component:tk})}var rk=6e4,ik=60*rk,ak=24*ik,ok=[{id:`1h`,label:`Last 1 hour`,durationMs:ik,bucketMs:1*rk,expandedBucketMs:1*rk},{id:`6h`,label:`Last 6 hours`,durationMs:6*ik,bucketMs:2*rk,expandedBucketMs:1*rk},{id:`24h`,label:`Last 24 hours`,durationMs:ak,bucketMs:10*rk,expandedBucketMs:5*rk},{id:`7d`,label:`Last 7 days`,durationMs:7*ak,bucketMs:ik,expandedBucketMs:15*rk},{id:`30d`,label:`Last 30 days`,durationMs:30*ak,bucketMs:4*ik,expandedBucketMs:ik}];function sk(e){let t=ok.find(t=>t.id===e);if(!t)throw Error(`Unknown preset: ${e}`);return t}function ck(e){let t=(e,t)=>`${e} ${t}${e===1?``:`s`}`;return e>=ik&&e%ik===0?t(e/ik,`hour`):e>=rk&&e%rk===0?t(e/rk,`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(ok[0]);if(!Number.isFinite(e)||e<=0)return r;for(let t of ok)if(e<=t.durationMs*1.01)return n(t);let i=ok[ok.length-1];return Math.max(r,Math.ceil(e/(i.durationMs/n(i))))}var uk=[{label:`Off`,value:0},{label:`30s`,value:3e4},{label:`60s`,value:6e4},{label:`5m`,value:3e5}],dk=6e4,fk=[`health`,`traffic`,`requests`,`database`,`replication`,`storage`,`overview`],pk={tab:`health`,range:`1h`,refresh:dk};function mk(e){let t=e.refresh===``?NaN:Number(e.refresh);return{tab:fk.find(t=>t===e.tab)??pk.tab,range:ok.find(t=>t.id===e.range)?.id??pk.range,refresh:uk.find(e=>e.value===t)?.value??pk.refresh}}function hk(e){return I({getParentRoute:()=>e,path:`status`,validateSearch:mk,search:{middlewares:[ce(pk)]},head:()=>({meta:[{title:`Status — Harper Fabric`}]}),component:ye(async()=>ze(()=>import(`./status-DRu3zRgl.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 gk(e){let t=dO(e),n=[nk(t),...M_(t,e),j_(t),hk(t),Hx(t),aO(t)];return t.addChildren(n)}I({getParentRoute:()=>xo,path:`notifications`,head:()=>({meta:[{title:`Notifications — Harper Fabric`}]}),component:ye(async()=>ze(()=>import(`./notifications-Bah46LXX.js`),__vite__mapDeps([46,1,2,3,4,5,6])),`NotificationsCenter`)}),I({getParentRoute:()=>xo,path:`profile`,head:()=>({meta:[{title:`Profile — Harper Fabric`}]}),component:ye(async()=>ze(()=>import(`./profile-QspOun_j.js`),__vite__mapDeps([47,1,26,3,2,4,5,6,7,27,12])),`ProfileIndex`)});var _k=bo.addChildren([...xc,xo.addChildren([gk(`local`)])]);function vk({routeTree:e=_k,authentication:t}){let[n]=(0,G.useState)(()=>Ie({routeTree:e,history:ue(),defaultNotFoundComponent:bi,defaultErrorComponent:yi,defaultPreload:!xi()&&`intent`,trailingSlash:`never`,defaultPreloadStaleTime:0,scrollRestoration:!0,context:{queryClient:wi,authentication:t||{}}}));return n}function yk(){let e=Sn(),t=vk({authentication:e}),n=(0,G.useRef)(e);return(0,G.useEffect)(()=>{n.current!==e&&(n.current=e,t.invalidate())},[t,e]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(_e,{router:t,context:{authentication:e}}),(0,K.jsx)(Oe,{router:t,position:`bottom-right`})]})}var bk=({...e})=>(0,K.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}),xk=!1;function Sk(){(0,G.useEffect)(()=>{xk||=!0},[])}function Ck(){return wo(),vo(),Sk(),(0,K.jsxs)(ja,{children:[(0,K.jsxs)(he,{client:wi,children:[(0,K.jsx)(yk,{}),(0,K.jsx)(Pe,{buttonPosition:`bottom-right`})]}),(0,K.jsx)(bk,{richColors:!0})]})}function wk(){u.signOutAllLocally(),wi.getMutationCache().clear(),wi.getQueryCache().clear(),Ja(),Ya()}function Tk(e,t=()=>!1,n=()=>!0){return r=>(r?.response?.status===401&&!t(r.config?.url??``)&&n(r.config)&&e(),Promise.reject(r))}var Ek=[`/Login/`,`/ForgotPassword/`,`/ResetPassword/`,`/VerifyEmail/`,`/ResendVerificationEmail/`],Dk=`authUserAtSend`;function Ok(){let e=u.getConnectionById(m).user;return e&&`id`in e?e.id:null}var kk=!1;function Ak(){kk||(kk=!0,N.interceptors.request.use(e=>(e[Dk]=Ok(),e)),N.interceptors.response.use(e=>e,Tk(wk,e=>Ek.some(t=>e.startsWith(t)),e=>e?.[Dk]===Ok())))}function jk(){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 Mk=`Studio:StaleDeployReloadedAt`,Nk=6e4,Pk=`__harperStaleDeployReloadState__`;function Fk(){if(!(typeof window>`u`))return window[Pk]}function Ik(){let e=Fk();if(e){try{let e=Number(sessionStorage.getItem(Mk)??0);if(Date.now()-e<Nk)return;sessionStorage.setItem(Mk,String(Date.now()))}catch{return}e.reload()}}function Lk(e=()=>window.location.reload()){if(typeof window>`u`)return;let t=window,n=t[Pk];if(n){n.reload=e;return}t[Pk]={reload:e},window.addEventListener(`vite:preloadError`,()=>Ik())}var Rk=He();jk(),Lk(),Ak(),a(),u.installExplorerCrossTabCleanup(),(0,Rk.createRoot)(document.getElementById(`root`),{onUncaughtError:(e,t)=>{Be(e,t),console.error(`Uncaught error:`,e,t)},onCaughtError:(e,t)=>{Be(e,t),console.error(`Caught error:`,e,t)},onRecoverableError:(e,t)=>{Be(e,t),console.warn(`Recoverable error:`,e,t)}}).render((0,K.jsx)(G.StrictMode,{children:(0,K.jsx)(Ck,{})}));export{ix as $,ji as $n,Ff as $t,VE as A,q as An,sr as Ar,n_ as At,mw as B,ua as Bn,An as Br,Dm as Bt,WE as C,Y as Cn,Ur as Cr,yv as Ct,IE as D,$a as Dn,Tr as Dr,sv as Dt,RE as E,lo as En,Ar as Er,cv as Et,EE as F,Oa as Fn,Ln as Fr,Ph as Ft,aC as G,ra as Gn,Vp as Gt,nw as H,_a as Hn,Dn as Hr,dm as Ht,eE as I,Da as In,On as Ir,Nh as It,kS as J,Gi as Jn,Bp as Jt,sC as K,ia as Kn,Gp as Kt,_T as L,ya as Ln,Mn as Lr,Fh as Lt,OE as M,Va as Mn,Xn as Mr,Dg as Mt,CE as N,Ua as Nn,Jn as Nr,yg as Nt,HE as O,Xa as On,wr as Or,rv as Ot,DE as P,Ha as Pn,Rn as Pr,Ih as Pt,xx as Q,Oi as Qn,jf as Qt,bw as R,va as Rn,jn as Rr,Mh as Rt,FE as S,X as Sn,Wr as Sr,Cv as St,KE as T,Io as Tn,Mr as Tr,mv as Tt,BC as U,pa as Un,En as Ur,Zp as Ut,fw as V,ha as Vn,wn as Vr,pm as Vt,oC as W,na as Wn,zp as Wt,mS as X,ki as Xn,Mp as Xt,MS as Y,Ti as Yn,Hp as Yt,tS as Z,Di as Zn,tp as Zt,pD as _,cs as _n,Xr as _r,Zv as _t,ck as a,Wu as an,Ci as ar,Mb as at,UE as b,Z as bn,Kr as br,Ev as bt,PO as c,ru as cn,gi as cr,Rb as ct,MD as d,wc as dn,fi as dr,sy as dt,Lf as en,Mi as er,$b as et,DD as f,Ec as fn,ui as fr,ay as ft,gD as g,Tc as gn,Qr as gr,Qv as gt,_D as h,Ac as hn,ti as hr,Xv as ht,ok as i,nd as in,Ei as ir,jb as it,BE as j,Ka as jn,Qn as jr,Yg as jt,LE as k,Ga as kn,lr as kr,I_ as kt,CO as l,nu as ln,mi as lr,Zy as lt,hD as m,kc as mn,si as mr,iy as mt,mk as n,Nf as nn,Fi as nr,Hb as nt,sk as o,wu as on,wi as or,zb as ot,wD as p,Dc as pn,ci as pr,oy as pt,iC as q,Yi as qn,Up as qt,uk as r,id as rn,Pi as rr,Ob as rt,lk as s,Cu as sn,yi as sr,Nb as st,Ik as t,Pf as tn,Ni as tr,Vb as tt,SO as u,Pc as un,pi as ur,Ky as ut,dD as v,$ as vn,Jr as vr,qv as vt,GE as w,J as wn,Hr as wr,hv as wt,PE as x,Bo as xn,Gr as xr,wv as xt,uD as y,Q as yn,qr as yr,Wv as yt,yw as z,da as zn,kn as zr,rh as zt};
824
+ disabled:pointer-events-none disabled:opacity-50 dark:bg-grey-700 dark:text-white`})]})}function GD({pageSize:e,onChange:t}){return(0,K.jsxs)(`div`,{className:`hidden items-center gap-2 @min-[960px]:flex`,children:[(0,K.jsx)(`span`,{className:`text-sm whitespace-nowrap text-muted-foreground`,children:`Rows`}),(0,K.jsxs)(jf,{value:String(e),onValueChange:e=>t(Number(e)),children:[(0,K.jsx)(Pf,{"aria-label":`Rows per page`,className:`h-9 w-20`,children:(0,K.jsx)(Nf,{})}),(0,K.jsx)(Ff,{side:`top`,children:BD.map(e=>(0,K.jsx)(Lf,{value:String(e),children:np(e)},e))})]})]})}function KD(e,t,n=1){if(t<=n*2+5)return qD(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?[...qD(1,s),`ellipsis`,t]:a&&!o?[1,`ellipsis`,...qD(t-s+1,t)]:[1,`ellipsis`,...qD(r,i),`ellipsis`,t]}function qD(e,t){return Array.from({length:t-e+1},(t,n)=>e+n)}function JD({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,setPageIndex:p,setPageSize:m,filtersToggled:h,totalPages:g,totalRecords:_,isEstimatedCount:v,estimatedRange:y,isExactCountFetching:b,isExactCountError:x,onRequestExactCount:S}){let C=Me({features:Kp,data:o||[],columns:n,manualSorting:!0,enableColumnResizing:!0,columnResizeMode:`onEnd`,onColumnSizingChange:a,defaultColumn:{minSize:80},state:{columnVisibility:r,columnSizing:i}}),w=C.state.columnResizing,T=w.isResizingColumn,E=null;if(T){let e=C.options.defaultColumn?.minSize??20,t=C.getColumn(T)?.getSize()??0,n=0;for(let e of C.getVisibleLeafColumns())if(n+=e.getSize(),e.id===T)break;E=n+Math.max(w.deltaOffset??0,e-t)}return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`relative flex flex-col grow`,children:[(0,K.jsxs)(zp,{containerClassName:`rounded-md bg-card dark:bg-black-dark grow overflow-visible`,className:`table-fixed`,children:[(0,K.jsx)(Bp,{children:C.getHeaderGroups().map(e=>(0,K.jsxs)(Hp,{className:`border-none`,children:[e.headers.map(e=>(0,K.jsx)(Wp,{header:e,onColumnClick:c,className:`sticky top-32 z-10 bg-card dark:bg-black-dark border-b border-border`},e.id)),(0,K.jsx)(Up,{"aria-hidden":!0,className:`w-full p-0 sticky top-32 z-10 bg-card dark:bg-black-dark border-b border-border`})]},e.id))}),h&&(0,K.jsx)(FD,{applyFilters:e,columnFiltersForm:t,headerGroups:C.getHeaderGroups()}),(0,K.jsx)(Vp,{className:`bg-background dark:bg-black border border-border dark:border-grey-700`,children:C.getRowModel().rows?.length?C.getRowModel().rows.map(e=>(0,K.jsx)(YD,{row:e,onRowClick:l,primaryKey:f},e.id)):(0,K.jsx)(Hp,{children:(0,K.jsx)(Gp,{colSpan:n.length+1,className:`h-24 text-center`,children:s||o===void 0?(0,K.jsx)(zD,{className:`opacity-50 inline-block`}):(0,K.jsx)(`span`,{children:`No results.`})})})})]}),E!==null&&(0,K.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute top-0 bottom-0 z-20 w-0.5 bg-primary`,style:{left:`${E}px`}})]}),(0,K.jsx)(VD,{pageIndex:u,pageSize:d,totalPages:g,totalRecords:_,isEstimatedCount:v,estimatedRange:y,isExactCountFetching:b,isExactCountError:x,onRequestExactCount:S,setPageIndex:p,setPageSize:m})]})}function YD({row:e,primaryKey:t,onRowClick:n}){let r=e.getVisibleCells(),i=(0,G.useMemo)(()=>{let n=e.original;return n&&n.message===`This entry has expired`?r[0]?.column?.id===t?[(0,K.jsx)(XD,{cell:r[0]},r[0].id),(0,K.jsx)(ZD,{colSpan:r.length-1},`expired`)]:[(0,K.jsx)(ZD,{colSpan:r.length},`expired`)]:r.map(e=>(0,K.jsx)(XD,{cell:e},e.id))},[e,t,r]);return(0,K.jsxs)(Hp,{"data-state":e.getIsSelected()&&`selected`,onClick:()=>n?.(e),className:P(`hover:bg-muted/10 data-[state=selected]:bg-muted`,n&&`cursor-pointer`),children:[i,(0,K.jsx)(Gp,{"aria-hidden":!0,className:`p-0`})]})}function XD({cell:e}){let t=e.column.getSize();return(0,K.jsx)(Gp,{"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:De(e.column.columnDef.cell,e.getContext())})}function ZD({colSpan:e}){return(0,K.jsx)(Gp,{colSpan:e,className:`px-2 py-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,children:(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`This entry has expired`})})}function QD({instanceDatabaseMap:e,databaseName:t,tableName:n}){let r=B({strict:!1}),i=q(),{clusterId:a,instanceId:o}=r,{toggled:s,toggle:c}=wD(!0),l=En(`instance:update`),u=iu(o??a,t,n,`insert`),d=au(o??a,t,n),f=iu(o??a,t,n,`update`),p=iu(o??a,t,n,`delete`),m=ru(),{data:h}=H(pw({...i,databaseName:t,tableName:n})),g=e?.[t],_=g?.[n],v=h??_,y=(0,G.useMemo)(()=>Hu(v?.attributes??[],`attribute`),[v]),{data:b}=H(bD(i)),x=b?.[t]?.[n],S=(0,G.useMemo)(()=>Yx(v,g,x),[v,g,x]),C=(0,G.useMemo)(()=>eS(v,g),[v,g]),w=(0,G.useMemo)(()=>Zx(v?.attributes,g),[v,g]),[T,E]=Ah(null,r),[D,O]=(0,G.useState)(!1),[k,A]=Ah(null,r),j=(0,G.useMemo)(()=>(t?Object.keys(e?.[t]||[]).sort():[]).length===1,[e,t]),{toggled:ee,toggleOn:M,toggleOff:N}=wD(!1),P=Pt({resolver:Ke(PD)}),{reset:te}=P,ne=P.watch(),[I,L]=Ah(null,[r.clusterId,r.instanceId,t,n]),re=(0,G.useCallback)(e=>{let t=[];for(let n in e){let r=e[n];if(r?.length)try{t.push(...rw(n,r,y[n],S[n]))}catch(e){U.error(String(e))}}return t},[y,S]),ie=(0,G.useCallback)(()=>{let e=re(ne);L(e.length?e:null),te({...ne})},[re,te,ne]),ae=(0,G.useCallback)(()=>{te({},{keepValues:!1,keepDirtyValues:!1,keepDefaultValues:!1}),te(),L(null),N()},[N,te]);(0,G.useEffect)(function(){return ae()},[r,ae]);let{filters:R}=le({strict:!1}),z=JSON.stringify([t,n,R??null]),se=(0,G.useRef)(null);(0,G.useEffect)(function(){if(!v||se.current===z)return;let e=se.current===null;if(se.current=z,R){te({...R});let e=re(R);L(e.length?e:null),M()}else e||ae()},[R,z,v,te,re,L,M,ae]);let{dataTableColumns:ce,primaryKey:ue}=GC(v,S),[de,fe]=Ah({attribute:ue,descending:!1},r),[pe,me]=Ah(0,[t,n,I]),[he,ge]=(0,G.useState)(20),_e=h?.record_count??_?.record_count,ve=h?.estimated_record_range??_?.estimated_record_range,[ye,be]=Ah(!1,[t,n]),{data:xe,isFetching:Se,isError:Ce,refetch:we}=H(jD({...i,enabled:ye,databaseName:t,tableName:n})),Te=(0,G.useCallback)(()=>{ye?we():be(!0)},[ye,we,be]),Ee=xe??_e,De=Ee?Math.ceil(Ee/he):0,Oe=xe===void 0&&ve!==void 0,ke=ee&&!!I,Ae=vg({...i,enabled:!ke&&!!ue,databaseName:t,tableName:n,searchAttribute:ue,sort:de,pageSize:he,pageIndex:pe,onlyIfCached:s,getAttributes:C}),{data:je,isFetching:Me}=H(Ae),Ne=tw({...i,enabled:ke&&!!ue,databaseName:t,tableName:n,conditions:I,sort:de,pageSize:he,pageIndex:pe,onlyIfCached:s,getAttributes:C}),{data:Pe,isFetching:Fe}=H(Ne),Ie=ke?Pe:je,Le=Me||Fe,{data:Re,isFetching:ze,isError:Be}=H(kD({...i,enabled:D,databaseName:t,tableName:n,ids:T})),Ve=D&&!!k&&(!ue||k[ue]==null),He=Re?.data,Ue=!Ve&&!!T?.length&&!ze&&(Be||Array.isArray(He)&&He.length===0),{mutate:We,isPending:Ge}=ND(),{mutate:qe,isPending:Je}=OD(),{mutate:Ye,isPending:Xe}=ED(),Ze=oe(),Qe=(0,G.useCallback)(()=>Ze.invalidateQueries({queryKey:[i.entityId,t,n]}),[Ze,i.entityId,t,n]),$e=(0,G.useCallback)(async()=>{confirm(`Are you sure you want to cleanup orphan blobs for database "${t}"?`)&&Ye({...i,databaseName:t},{onSuccess:e=>{U.success(e.message||`Orphan blobs cleanup started successfully`),Qe()},onError:e=>{U.error(e instanceof Error?e.message:`Failed to cleanup orphan blobs`)}})},[Ye,t,i,Qe]),{exportCsv:et,isExporting:tt}=lw(),nt=(0,G.useCallback)(()=>{et({databaseName:t,tableName:n,primaryKey:ue,sort:de,conditions:ke?I:null})},[et,t,n,ue,de,ke,I]),rt=(0,G.useCallback)(e=>{We({...i,databaseName:t,tableName:n,records:e},{onSuccess:()=>{Qe(),O(!1),U.success(`Record updated successfully`)}})},[We,i,t,n,Qe]),it=(0,G.useCallback)(e=>{qe({...i,databaseName:t,tableName:n,hashValues:e},{onSuccess:()=>{Qe(),O(!1),U.success(`Record deleted successfully`)}})},[qe,i,t,n,Qe]),at=e=>{let t=ue?e.original[ue]:void 0;A(e.original),E(t==null?null:[t]),O(!0)},ot=(e,t)=>{fe({attribute:e,descending:!t})},st=$p(Qe),ct=(0,G.useCallback)(()=>{aC(`ShowAddTableRecords`,{databaseName:t,tableName:n})},[t,n]),lt=(0,G.useCallback)(()=>{aC(`ShowImportData`,{databaseName:t,tableName:n})},[t,n]),[ut,dt]=Ih(`ColumnDisplayed/${t}/${n}`,{}),ft=(0,G.useMemo)(()=>({...Object.fromEntries($x(S).map(e=>[e,!1])),...ut}),[S,ut]),[pt,mt]=Ih(`ColumnSizing/${t}/${n}`,{});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex flex-col md:flex-row items-center justify-between space-y-3 md:space-y-0 md:space-x-3 pt-15 pb-4 pr-4`,children:[(0,K.jsxs)(`div`,{className:`flex space-x-2`,children:[u&&(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:ct,accessKey:`n`,children:[(0,K.jsx)(Gr,{}),(0,K.jsxs)(`span`,{children:[`Add `,(0,K.jsx)(`u`,{children:`N`}),`ew Record(s)`]})]}),d&&(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:lt,accessKey:`i`,children:[(0,K.jsx)(ar,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`I`}),`mport Data`]})]}),(0,K.jsxs)(F,{variant:`positiveOutline`,onClick:nt,disabled:tt,accessKey:`e`,children:[(0,K.jsx)(ir,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`u`,{children:`E`}),`xport CSV`]})]})]}),(0,K.jsxs)(`div`,{className:`flex space-x-2`,children:[ee&&I&&(0,K.jsxs)(F,{type:`button`,variant:`ghost`,onClick:ae,accessKey:`f`,children:[(0,K.jsx)(gr,{className:`inline-block `}),(0,K.jsxs)(`span`,{children:[`Clear `,(0,K.jsx)(`u`,{children:`F`}),`ilters`]})]}),ee&&P.formState.isDirty&&(0,K.jsxs)(F,{variant:`default`,onClick:ie,children:[(0,K.jsx)(hr,{className:`inline-block `}),`Apply Filters`]}),ee&&!I&&(0,K.jsxs)(F,{variant:`ghost`,onClick:N,accessKey:`f`,children:[(0,K.jsx)(gr,{className:`inline-block `}),(0,K.jsxs)(`span`,{children:[`Hide `,(0,K.jsx)(`u`,{children:`F`}),`ilters`]})]}),!ee&&(0,K.jsxs)(F,{variant:`ghost`,onClick:M,accessKey:`f`,children:[(0,K.jsx)(_r,{className:`inline-block `}),(0,K.jsxs)(`span`,{children:[`Show `,(0,K.jsx)(`u`,{children:`F`}),`ilters`]})]}),(0,K.jsx)(F,{variant:`defaultOutline`,onClick:st,disabled:Le,children:(0,K.jsx)(Kr,{})}),(0,K.jsx)(LD,{columns:ce,columnVisibility:ft,setColumnVisibility:dt}),(0,K.jsxs)(Ti,{children:[(0,K.jsx)(Ei,{asChild:!0,disabled:!e,children:(0,K.jsx)(F,{variant:`ghost`,size:`icon`,disabled:!e,children:(0,K.jsx)(ur,{"aria-label":`Table options`})})}),(0,K.jsxs)(Di,{side:`bottom`,align:`end`,children:[(0,K.jsxs)(Oi,{className:`focus:bg-primary/70 focus:text-white`,onClick:c,children:[s?(0,K.jsx)(Zn,{className:`text-green`}):(0,K.jsx)(er,{}),`Only If Cached`,(0,K.jsx)(V,{to:`https://docs.harperdb.io/docs/developers/applications/caching#cache-control-header`,target:`_blank`,rel:`noopener noreferrer`,onClick:BC,children:(0,K.jsx)(dr,{})})]}),m&&l&&!!o&&(0,K.jsxs)(Oi,{className:`focus:bg-yellow/70 focus:text-white`,onClick:$e,disabled:Xe,children:[(0,K.jsx)(Un,{className:`text-yellow `}),`Cleanup Orphan Blobs`]}),m&&!j&&(0,K.jsxs)(Oi,{className:`focus:bg-red/70 focus:text-white`,onClick:()=>aC(`ShowDeleteTable`,{databaseName:t,tableName:n}),children:[(0,K.jsx)(fi,{className:`inline-block `}),`Drop Table`]}),m&&(0,K.jsxs)(Oi,{className:`focus:bg-red/70 focus:text-white`,onClick:()=>aC(`ShowDeleteDatabase`,{databaseName:t}),children:[(0,K.jsx)(pi,{}),`Drop Database`]})]})]})]})]}),(0,K.jsx)(JD,{primaryKey:ue,data:Ie?.data,isFetching:Le,filtersToggled:ee,columns:ce,columnVisibility:ft,columnSizing:pt,setColumnSizing:mt,onRowClick:at,onColumnClick:ot,totalPages:De,totalRecords:Ee,isEstimatedCount:Oe,estimatedRange:ve,isExactCountFetching:Se,isExactCountError:Ce,onRequestExactCount:Te,pageIndex:pe,pageSize:he,columnFiltersForm:P,applyFilters:ie,setPageIndex:me,setPageSize:ge}),(0,K.jsx)(CD,{canEditRecords:f,canDeleteRecords:p,setIsModalOpen:O,isModalOpen:D,primaryKey:ue,missingPrimaryKey:Ve,recordUnavailable:Ue,syntheticAttributes:w,data:Ve||Ue?k?[k]:void 0:Re?.data,onSaveChanges:rt,onDeleteRecord:it,isUpdateTableRecordsPending:Ge,isDeleteTableRecordsPending:Je})]})}function $D(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 eO=10;function tO(e){return Math.max(200,Math.floor(e/2))}function nO(e,t){return Math.round(Math.min(Math.max(e,200),tO(t)))}function rO(){let[e,t]=xn(vn.DatabasesSidebarWidth,320),[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(()=>nO(e,window.innerWidth)),o=(0,G.useRef)(i);o.current=i;let s=(0,G.useRef)(null);(0,G.useEffect)(()=>{n||a(nO(e,window.innerWidth))},[e,n]),(0,G.useEffect)(()=>{let t=()=>{n||a(nO(e,window.innerWidth))};return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e,n]);let c=(0,G.useCallback)(e=>{e.preventDefault(),s.current={startX:e.clientX,startWidth:o.current},r(!0)},[]);return(0,G.useEffect)(()=>{if(!n)return;let e=e=>{let t=s.current;t&&a(nO(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,G.useCallback)(e=>{e.key===`ArrowLeft`?(e.preventDefault(),t(e=>nO(e-eO,window.innerWidth))):e.key===`ArrowRight`&&(e.preventDefault(),t(e=>nO(e+eO,window.innerWidth)))},[t])}}function iO(){let e=B({strict:!1}),t=q(),{data:n}=H(qy({...t,skipRecordCount:!0})),{width:r,isResizing:i,startResizing:a,handleKeyDown:o}=rO(),s={"--db-sidebar-width":`${r}px`},c=$D(n,e);return c?(0,K.jsx)(re,{to:Ux({...e,...c}),replace:!0}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`main`,{className:`flex flex-col gap-4 md:flex-row md:items-start`,children:[(0,K.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,K.jsx)(vE,{instanceDatabaseMap:n}),(0,K.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,"aria-valuenow":r,"aria-valuemin":200,"aria-valuemax":tO(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,K.jsx)(`div`,{className:P(`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,K.jsx)(`section`,{className:`text-foreground w-full md:flex-1 md:min-w-0 flex flex-col min-h-0`,children:e.databaseName&&e.tableName?(0,K.jsx)(QD,{instanceDatabaseMap:n,databaseName:e.databaseName,tableName:e.tableName}):e.databaseName?(0,K.jsx)(vw,{instanceDatabaseMap:n,databaseName:e.databaseName}):null})]}),n&&(0,K.jsx)(zC,{instanceDatabaseMap:n})]})}function aO(e){return I({getParentRoute:()=>e,path:`/databases/{-$databaseName}/{-$tableName}`,head:()=>({meta:[{title:`Databases — Harper Fabric`}]}),component:iO})}var oO={className:`text-primary font-semibold bg-primary/10 rounded-md dark:text-white dark:bg-white/10`};function sO(){let e=nu(),t=B({strict:!1}),{version:n}=te({strict:!1}),r=Pc(`4.6.0`,n)&&e,i=Pc(`4.7.0-beta.7`,n),a=q(),{data:o}=H(n_(a,r)),s=o?.restartRequired??!1,c=(0,G.useMemo)(()=>[e&&{to:t.clusterId&&!t.instanceId?hv(t,`apps`):hv(t),activeOptions:{exact:!0},name:`Applications`,shortName:`Apps`,icon:(0,K.jsx)(Hr,{className:`inline-block`})},{to:hv(t,`databases`),icon:(0,K.jsx)(lr,{className:`inline-block`}),name:`Databases`},e&&i&&{to:hv(t,`apis`),name:`APIs`,icon:(0,K.jsx)($r,{className:`inline-block`})},e&&r&&{to:hv(t,`status`),icon:(0,K.jsx)(vr,{className:`inline-block`}),name:`Status`},e&&{to:hv(t,`logs`),icon:(0,K.jsx)(Br,{className:`inline-block`}),name:`Logs`},e&&{to:hv(t,`config`),icon:(0,K.jsx)(ei,{className:`inline-block`}),name:`Config`}].filter($a),[e,t,i,r]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cO,{links:c,restartRequired:s}),(0,K.jsx)(lO,{links:c,restartRequired:s})]})}function cO({links:e,restartRequired:t}){return(0,K.jsxs)(`div`,{className:`hidden md:[@media(hover:hover)]:flex xl:flex items-center justify-between h-full text-sm text-foreground`,children:[(0,K.jsx)(Fo,{restartRequired:t}),(0,K.jsx)(`div`,{className:`flex space-x-2`,children:e.map(({shortName:e,...t})=>{let n=(0,K.jsxs)(V,{"aria-label":t.name,className:`p-2 text-center text-muted-foreground hover:text-foreground`,activeProps:oO,...t,children:[t.icon,(0,K.jsx)(`span`,{className:`hidden xl:inline-block ml-1`,children:t.name}),e&&(0,K.jsx)(`span`,{className:`visible xl:hidden ml-1`,children:e})]},t.to);return e?n:(0,K.jsxs)(Va,{children:[(0,K.jsx)(Ha,{asChild:!0,children:n}),(0,K.jsx)(Ua,{side:`bottom`,className:`xl:hidden`,children:t.name})]},t.to)})})]})}function lO({links:e,restartRequired:t}){return(0,K.jsx)(K.Fragment,{children:(0,K.jsxs)(`div`,{className:`flex md:[@media(hover:hover)]:hidden xl:hidden items-center justify-between h-full px-2 text-foreground`,children:[(0,K.jsx)(Fo,{restartRequired:t}),(0,K.jsxs)(Ti,{children:[(0,K.jsx)(Ei,{asChild:!0,children:(0,K.jsx)(F,{variant:`ghost`,className:`p-0`,children:(0,K.jsx)(Lr,{className:`h-8 w-8`})})}),(0,K.jsxs)(Di,{children:[(0,K.jsx)(Ai,{children:`Instance Menu`}),(0,K.jsx)(ji,{}),e.map(e=>(0,K.jsx)(Oi,{asChild:!0,children:(0,K.jsxs)(V,{to:e.to,activeProps:oO,className:`flex items-center gap-2`,children:[e.icon,e.name]})},e.to))]})]})]})})}(0,G.lazy)(()=>ze(()=>import(`./FloatingChat-DdJ3DZJX.js`).then(e=>({default:e.FloatingChat})),__vite__mapDeps([35,1,4,5,9,11,12,13])));function uO(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.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,K.jsx)(sO,{})}),(0,K.jsx)(`div`,{className:`mt-32 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,K.jsx)(Le,{})}),!1]})}function dO(e){switch(e){case`local`:return I({getParentRoute:()=>xo,id:`_instanceLayout`,component:uO,loader:Vx});case`cluster`:return I({getParentRoute:()=>Hh,id:`_instanceLayout`,component:uO,beforeLoad:fO,loader:Vx});case`instance`:return I({getParentRoute:()=>Hh,path:`instance/$instanceId`,component:uO,beforeLoad:fO,loader:Vx})}}async function fO({context:e,params:t}){let n=t.instanceId||t.clusterId,r=!1;if(u.checkForFabricConnect(n)&&!u.hasResolvedFabricConnect(n)&&(r=!0,await pO(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?eu(a.user,t.organizationId,t.clusterId):Zl(a.user,t.organizationId,t.clusterId);if(!r&&o&&await pO(n,e.cluster,t.instanceId))return;let s=`/${t.organizationId}/${t.clusterId}/`+(t.instanceId?`instance/${t.instanceId}`:``)+`/sign-in`;throw ie({to:s,search:fo()})}async function pO(e,t,n){try{return await u.establishFabricConnectAuth({id:e,operationsUrl:mO(t,n)}),!0}catch(e){return console.debug(`Fabric Connect not established`,e),!1}}function mO(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 hO(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 gO=[`secondary`,`default`,`warning`,`outline`,`success`,`destructive`],_O=0,vO=new Map,yO=e=>{if(vO.has(e))return vO.get(e);_O++;let t=gO[_O%gO.length];return vO.set(e,t),t};function bO(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 xO({columns:e,data:t,onRowClick:n,containerRef:r}){let i=Me({features:Kp,data:t,columns:e});return(0,K.jsxs)(zp,{className:`text-xs`,containerRef:r,containerClassName:`rounded-md bg-card dark:bg-black-dark logsTable max-h-[calc(100vh-(--spacing(48)))] overflow-y-auto md:max-h-[calc(100vh-(--spacing(40)))]`,children:[(0,K.jsx)(Bp,{children:i.getHeaderGroups().map(e=>(0,K.jsx)(Hp,{className:`border-b border-border`,children:e.headers.map(e=>(0,K.jsx)(Up,{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:De(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,K.jsx)(Vp,{className:`bg-background dark:bg-black`,children:i.getRowModel().rows?.length?i.getRowModel().rows.map(e=>(0,K.jsx)(Hp,{"data-state":e.getIsSelected()&&`selected`,className:P(`hover:bg-muted/20 data-[state=selected]:bg-muted max-w-full border-l-2`,bO(e.original.level),n&&`cursor-pointer`),onClick:()=>n?.(e),children:e.getVisibleCells().map(e=>(0,K.jsx)(Gp,{className:`p-2`,children:De(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,K.jsx)(Hp,{children:(0,K.jsx)(Gp,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})}var SO=524288,CO=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 wO(e){try{JSON.parse(e)}catch{return!1}return!0}function TO(e){return!e||e.length>524288?`plaintext`:wO(e)?`json`:`plaintext`}function EO({label:e,children:t}){return(0,K.jsxs)(`div`,{className:`flex items-start gap-3 py-1.5 border-b border-border/50 last:border-0`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground w-20 shrink-0 pt-0.5`,children:e}),(0,K.jsx)(`span`,{className:`text-xs`,children:t})]})}function DO({setIsModalOpen:e,isModalOpen:t,data:n}){let r=n?yO(n.node):`default`,i=dm();return(0,K.jsx)(fn,{onOpenChange:e,open:t,children:(0,K.jsxs)(cn,{"aria-describedby":void 0,resizable:!0,children:[(0,K.jsx)(rn,{children:(0,K.jsx)(ln,{children:`Log Entry`})}),n?(0,K.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 text-popover-foreground`,children:[(0,K.jsxs)(`div`,{className:`rounded-md border border-border/50 bg-muted/20 px-3 py-1`,children:[(0,K.jsx)(EO,{label:`Level`,children:(0,K.jsx)(Yi,{variant:hO(n.level),children:No(n.level)})}),(0,K.jsx)(EO,{label:`Timestamp`,children:(0,K.jsx)(`span`,{className:`tabular-nums`,children:new Date(n.timestamp).toLocaleString()})}),(0,K.jsx)(EO,{label:`Thread`,children:(0,K.jsx)(`span`,{className:`tabular-nums font-mono`,children:n.thread})}),n.node&&(0,K.jsx)(EO,{label:`Node`,children:(0,K.jsx)(Yi,{variant:r,children:n.node})}),n.tags&&n.tags.length>0&&(0,K.jsx)(EO,{label:`Tags`,children:(0,K.jsx)(`span`,{className:`font-mono`,children:n.tags})})]}),(0,K.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`Message`}),(0,K.jsx)(`div`,{className:`rounded-md overflow-hidden border border-border/50 flex-1 min-h-0`,children:(0,K.jsx)(pm,{className:`w-full h-full`,language:TO(n.message),theme:i,value:n.message,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12,padding:{top:12,bottom:12},automaticLayout:!0}})})]})]}):(0,K.jsx)(Gi,{})]})})}var OO=b({limit:M().or(x()).or(E()).optional(),level:O([`notify`,`error`,`warn`,`info`,`debug`,`trace`,`undefined`]).or(x()).or(E()).optional(),from:M().or(x()).or(E()).optional(),until:M().or(x()).or(E()).optional(),log_name:O([`hdb.log`,`system.log`]).or(x()).or(E()).optional(),filter:M().or(x()).or(E()).optional()}),kO=`dark:bg-grey-600 dark:border-grey-500`;function AO({form:e,resetFilters:t,submitFilters:n,showLogName:r,showFilter:i,isOpen:a,onOpenChange:o}){return(0,K.jsxs)(On,{className:P(a?`block`:`hidden`,`mt-3 md:mt-0 md:block`),children:[(0,K.jsx)(kn,{className:`hidden md:block`,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>o(!a),"aria-expanded":a,"aria-controls":`logs-filters-content`,className:`flex w-full items-center justify-between md:pointer-events-none`,children:(0,K.jsxs)(An,{className:`flex items-center gap-2 text-base`,children:[(0,K.jsx)(ri,{className:`size-4 text-muted-foreground`}),`Filters`]})})}),(0,K.jsx)(Mn,{id:`logs-filters-content`,children:(0,K.jsx)(Io,{...e,children:(0,K.jsxs)(`form`,{id:`instance-edit-log-filters-form`,name:`instance-edit-log-filters-form`,onSubmit:e.handleSubmit(n),className:`flex-col space-y-4`,children:[i&&(0,K.jsx)(Y,{control:e.control,name:`filter`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(J,{children:(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Qr,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,K.jsx)($,{type:`search`,placeholder:`Search logs…`,className:P(`pl-9`,kO),value:e.value??``,onChange:e.onChange})]})}),(0,K.jsx)(Q,{})]})}),r&&(0,K.jsx)(Y,{control:e.control,name:`log_name`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Log file`}),(0,K.jsxs)(jf,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,K.jsx)(Pf,{className:P(`w-full bg-white`,kO),children:(0,K.jsx)(Nf,{placeholder:`Select log file`})}),(0,K.jsx)(Ff,{children:(0,K.jsxs)(Mf,{children:[(0,K.jsx)(Lf,{value:`hdb.log`,children:`Application (hdb.log)`}),(0,K.jsx)(Lf,{value:`system.log`,children:`System (system.log)`})]})})]}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsx)(Y,{control:e.control,name:`limit`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Limit`}),(0,K.jsxs)(jf,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,K.jsx)(Pf,{className:P(`w-full bg-white`,kO),children:(0,K.jsx)(Nf,{placeholder:`Limit`})}),(0,K.jsx)(Ff,{children:(0,K.jsxs)(Mf,{children:[(0,K.jsx)(Lf,{value:`1000`,children:`1000`}),(0,K.jsx)(Lf,{value:`500`,children:`500`}),(0,K.jsx)(Lf,{value:`250`,children:`250`}),(0,K.jsx)(Lf,{value:`100`,children:`100`}),(0,K.jsx)(Lf,{value:`10`,children:`10`})]})})]}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:e.control,name:`level`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Level`}),(0,K.jsxs)(jf,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,K.jsx)(Pf,{className:P(`w-full bg-white`,kO),children:(0,K.jsx)(Nf,{placeholder:`Level`})}),(0,K.jsx)(Ff,{children:(0,K.jsxs)(Mf,{children:[(0,K.jsx)(Lf,{value:`undefined`,children:`All`}),(0,K.jsx)(Lf,{value:`notify`,children:`Notify`}),(0,K.jsx)(Lf,{value:`error`,children:`Error`}),(0,K.jsx)(Lf,{value:`warn`,children:`Warn`}),(0,K.jsx)(Lf,{value:`info`,children:`Info`}),(0,K.jsx)(Lf,{value:`debug`,children:`Debug`}),(0,K.jsx)(Lf,{value:`trace`,children:`Trace`})]})})]}),(0,K.jsx)(Q,{})]})})]}),(0,K.jsx)(Y,{control:e.control,name:`from`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`Start date`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`datetime-local`,className:kO,value:e.value??void 0,onChange:e.onChange})}),(0,K.jsx)(Q,{})]})}),(0,K.jsx)(Y,{control:e.control,name:`until`,render:({field:e})=>(0,K.jsxs)(X,{children:[(0,K.jsx)(Z,{children:`End date`}),(0,K.jsx)(J,{children:(0,K.jsx)($,{type:`datetime-local`,className:kO,value:e.value??void 0,onChange:e.onChange})}),(0,K.jsx)(Q,{})]})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,K.jsx)(F,{type:`submit`,variant:`positiveOutline`,className:`grow`,children:`Apply Filters`}),(0,K.jsx)(F,{type:`reset`,variant:`destructiveOutline`,onClick:t,children:`Clear`})]})]})})})]})}var jO=1e4;function MO(e){if(!e)return;let t=parseInt(e,10);if(!(!Number.isFinite(t)||t<=0))return Math.min(t,jO)}function NO(e,t){return{operation:`read_log`,start:0,replicated:t,limit:MO(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 PO({instanceClient:e,logFilters:t,replicated:n}){let{data:r}=await e.post(`/`,NO(t,n));return r}function FO(e){let t=e.logFilters;return z({queryKey:[`read_log`,e.entityId,t.limit,t.level,t.from,t.until,t.log_name,t.filter,e.replicated],queryFn:()=>PO(e),retry:!1,refetchInterval:e.isAutoRefreshEnabled?5e3:!1})}async function IO({connection:e,logFilters:t,replicated:n,signal:r,onEntry:i}){let{url:a,headers:o,credentials:s}=uv(e),c;try{c=await fetch(a,{method:`POST`,headers:o,credentials:s,body:JSON.stringify(NO(t,n)),signal:r})}catch(e){throw r?.aborted?e:new sv(`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 sv(`read_log did not return an event stream (status ${c.status}, content-type "${l}").`);for await(let e of iv(c.body,r)){if(e.event===`error`){let t=ov(e);if(!t||typeof t!=`object`)throw new lv(typeof t==`string`&&t?t:`The log stream failed.`);let n=t;throw new lv(n.message??`The log stream failed.`,{code:n.code})}if(e.event===`done`||e.event===`end`)return;for(let t of LO(ov(e)))i(t)}}function LO(e){return Array.isArray(e)?e.filter(RO):RO(e)?[e]:[]}function RO(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 zO(e){return[e.timestamp,e.node??``,e.thread??``,e.level,e.message].join(`|`)}function BO(e,t,n){let r=new Set,i=[];for(let n of[...t,...e]){let e=zO(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 VO={entries:[],fellBack:!1};function HO(e,t){switch(t.kind){case`reset`:return VO;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 UO(){let e=q();return u.isDirectConnection(e.entityId)}var WO=1e3,GO=2e3,KO=250;function qO(e){return MO(e)??WO}function JO(e,t){return JSON.stringify([e.limit,e.level,e.from,e.until,e.log_name,e.filter,t])}function YO({params:e,logFilters:t,replicated:n,live:r}){let i=UO(),[a,o]=(0,G.useReducer)(HO,VO),s=r&&i&&!a.fellBack,c=JO(t,n),l=qO(t.limit),u=Math.max(GO,l),d=H(FO({...e,logFilters:t,replicated:n,isAutoRefreshEnabled:r&&!s}));(0,G.useEffect)(()=>{o({kind:`reset`})},[e.entityId,c]),(0,G.useEffect)(()=>{r&&o({kind:`retry`})},[r]);let f=(0,G.useRef)({logFilters:t,replicated:n});f.current={logFilters:t,replicated:n},(0,G.useEffect)(()=>{if(!s)return;let t=new AbortController,n=[],r=()=>{if(n.length>0&&!t.signal.aborted){let e=n;n=[],o({kind:`append`,entries:e,cap:u})}},i=setInterval(r,KO);return IO({connection:{id:e.entityId},logFilters:f.current.logFilters,replicated:f.current.replicated,signal:t.signal,onEntry:e=>n.push(e)}).catch(()=>{}).finally(()=>{clearInterval(i),!t.signal.aborted&&(r(),o({kind:`fellBack`}))}),()=>{clearInterval(i),t.abort()}},[s,e.entityId,c]);let p=(0,G.useMemo)(()=>{let e=d.data??[];return a.entries.length===0?e:BO(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 XO={log_name:`hdb.log`,limit:`100`,level:`undefined`,from:``,until:``,filter:``},ZO={error:(0,K.jsx)(Xn,{className:`size-3`}),stderr:(0,K.jsx)(Xn,{className:`size-3`}),warn:(0,K.jsx)(mi,{className:`size-3`}),notify:(0,K.jsx)(Vn,{className:`size-3`}),info:(0,K.jsx)(wr,{className:`size-3`}),debug:(0,K.jsx)(Wn,{className:`size-3`}),trace:(0,K.jsx)(Fn,{className:`size-3`}),stdout:(0,K.jsx)(ui,{className:`size-3`})},QO=[{accessorKey:`level`,header:`Level`,cell:({row:e})=>{let{level:t}=e.original;return(0,K.jsxs)(Yi,{variant:hO(t),children:[ZO[t],No(t)]})}},{accessorKey:`timestamp`,header:`Timestamp`,cell:({row:e})=>{let{timestamp:t}=e.original,n=new Date(t),r=n.getFullYear()===new Date().getFullYear()?n.toLocaleDateString(void 0,{month:`numeric`,day:`2-digit`}):n.toLocaleDateString();return(0,K.jsxs)(`span`,{className:`tabular-nums whitespace-nowrap text-muted-foreground`,children:[r,` `,n.toLocaleTimeString()]})}},{accessorKey:`message`,header:`Message`,cell:({row:e})=>{let{message:t}=e.original;return(0,K.jsx)(`span`,{className:`block max-w-xl truncate font-mono text-xs`,children:t})}},{accessorKey:`thread`,header:`Thread`,cell:({row:e})=>(0,K.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:e.original.thread})},{accessorKey:`node`,header:`Node`,cell:({row:e})=>{let{node:t}=e.original,n=yO(t);return(0,K.jsx)(K.Fragment,{children:t?(0,K.jsxs)(Va,{children:[(0,K.jsx)(Ha,{asChild:!0,children:(0,K.jsxs)(Yi,{variant:n,children:[t.split(`.`)[0],`...`]})}),(0,K.jsx)(Ua,{className:`bg-popover text-popover-foreground border border-border`,arrowClassName:`bg-popover fill-popover`,children:t})]}):null})}},{accessorKey:`tags`,header:`Tags`,cell:({row:e})=>{let{tags:t}=e.original;return t&&t.length>0?(0,K.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null}}],$O=(e,t)=>!e&&!t||!e||!t||new Date(e)<=new Date(t);function ek(){return(0,K.jsxs)(`div`,{className:`rounded-md bg-card dark:bg-black-dark overflow-hidden`,children:[(0,K.jsx)(`div`,{className:`flex gap-4 p-4 border-b border-border`,children:[`w-14`,`w-32`,`w-14`,`w-24`,`w-16`,`flex-1`].map((e,t)=>(0,K.jsx)(rh,{className:`h-4 ${e}`},t))}),Array.from({length:12}).map((e,t)=>(0,K.jsxs)(`div`,{className:`flex gap-4 p-3 border-b border-border/40 border-l-2 border-l-transparent`,children:[(0,K.jsx)(rh,{className:`h-5 w-14`}),(0,K.jsx)(rh,{className:`h-5 w-32`}),(0,K.jsx)(rh,{className:`h-5 w-10`}),(0,K.jsx)(rh,{className:`h-5 w-20`}),(0,K.jsx)(rh,{className:`h-5 w-12`}),(0,K.jsx)(rh,{className:`h-5 flex-1 max-w-xs`})]},t))]})}function tk(){let[e,t]=(0,G.useState)(XO),[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(),[o,s]=(0,G.useState)(!1),[c,l]=xn(vn.LogsOrderReversed,!1),[u,d]=(0,G.useState)(!1),f=q(),{data:p}=H(wv(f)),m=p?.version,h=!!m&&Pc(`4.7.16`,m),{logs:g,isLoading:_,isFetching:v,refetch:y,transport:b}=YO({params:f,logFilters:e,replicated:f.entityType===`cluster`,live:o}),x=(0,G.useMemo)(()=>c?[...g??[]].reverse():g??[],[g,c]),S=(0,G.useRef)(null);(0,G.useEffect)(()=>{let e=S.current;_||!e||e.scrollTo({top:c?e.scrollHeight:0})},[c,_]),(0,G.useEffect)(()=>{let e=S.current;!o||_||!e||e.scrollTo({top:c?e.scrollHeight:0})},[x,o,c,_]);let C=Pt({resolver:Ke(OO),defaultValues:XO,mode:`onChange`}),w=e=>{a(e.original),r(!0)},T=async e=>{if(!$O(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(XO)},D=$p(y);return(0,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 pt-2 text-foreground md:grid-cols-12 md:gap-4`,children:[(0,K.jsxs)(`section`,{className:`col-span-1 md:col-span-4 lg:col-span-3 px-2 pb-0 md:self-start md:sticky md:top-34 md:max-h-[calc(100vh-(--spacing(34)))] md:overflow-y-auto md:pb-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 md:hidden`,children:[(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:()=>d(e=>!e),"aria-label":`Toggle filters`,"aria-expanded":u,className:`flex-1`,children:[(0,K.jsx)(ri,{}),`Filters`]}),(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:D,disabled:v||_||o,"aria-label":`Refresh logs`,className:`flex-1`,children:[(0,K.jsx)(Kr,{className:v?`animate-spin`:``}),`Refresh`]}),(0,K.jsxs)(F,{variant:c?`default`:`defaultOutline`,onClick:()=>l(e=>!e),"aria-label":`Reverse log order`,"aria-pressed":c,className:`flex-1`,children:[(0,K.jsx)(zn,{}),`Reverse`]})]}),(0,K.jsx)(AO,{form:C,resetFilters:E,submitFilters:T,showLogName:!1,showFilter:h,isOpen:u,onOpenChange:d}),(0,K.jsxs)(`div`,{className:`mt-3 space-y-3 hidden md:block`,children:[(0,K.jsxs)(F,{variant:`defaultOutline`,onClick:D,disabled:v||_||o,className:`w-full`,children:[(0,K.jsx)(Kr,{}),`Refresh`]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,K.jsx)(Dm,{id:`logs-live-switch`,"aria-label":`Toggle live logs`,checked:o,onCheckedChange:s}),(0,K.jsxs)(`label`,{htmlFor:`logs-live-switch`,className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(Kr,{className:`size-4 ${o?`animate-spin [animation-duration:3s]`:``}`}),o?b===`streaming`?`Live (streaming)`:`Live (polling every 5s)`:`Live`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,K.jsx)(Dm,{id:`logs-reverse-order-switch`,"aria-label":`Reverse log order`,checked:c,onCheckedChange:l}),(0,K.jsxs)(`label`,{htmlFor:`logs-reverse-order-switch`,className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(zn,{className:`size-4`}),c?`Oldest first`:`Newest first`]})]})]})]})]}),(0,K.jsx)(`section`,{className:`col-span-1 md:col-span-8 lg:col-span-9`,children:_?(0,K.jsx)(ek,{}):(0,K.jsx)(xO,{columns:QO,data:x,onRowClick:w,containerRef:S})}),(0,K.jsx)(DO,{isModalOpen:n,setIsModalOpen:r,data:i})]})}function nk(e){return I({getParentRoute:()=>e,path:`logs`,head:()=>({meta:[{title:`Logs — Harper Fabric`}]}),component:tk})}var rk=6e4,ik=60*rk,ak=24*ik,ok=[{id:`1h`,label:`Last 1 hour`,durationMs:ik,bucketMs:1*rk,expandedBucketMs:1*rk},{id:`6h`,label:`Last 6 hours`,durationMs:6*ik,bucketMs:2*rk,expandedBucketMs:1*rk},{id:`24h`,label:`Last 24 hours`,durationMs:ak,bucketMs:10*rk,expandedBucketMs:5*rk},{id:`7d`,label:`Last 7 days`,durationMs:7*ak,bucketMs:ik,expandedBucketMs:15*rk},{id:`30d`,label:`Last 30 days`,durationMs:30*ak,bucketMs:4*ik,expandedBucketMs:ik}];function sk(e){let t=ok.find(t=>t.id===e);if(!t)throw Error(`Unknown preset: ${e}`);return t}function ck(e){let t=(e,t)=>`${e} ${t}${e===1?``:`s`}`;return e>=ik&&e%ik===0?t(e/ik,`hour`):e>=rk&&e%rk===0?t(e/rk,`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(ok[0]);if(!Number.isFinite(e)||e<=0)return r;for(let t of ok)if(e<=t.durationMs*1.01)return n(t);let i=ok[ok.length-1];return Math.max(r,Math.ceil(e/(i.durationMs/n(i))))}var uk=[{label:`Off`,value:0},{label:`30s`,value:3e4},{label:`60s`,value:6e4},{label:`5m`,value:3e5}],dk=6e4,fk=[`health`,`traffic`,`requests`,`database`,`replication`,`storage`,`overview`],pk={tab:`health`,range:`1h`,refresh:dk};function mk(e){let t=e.refresh===``?NaN:Number(e.refresh);return{tab:fk.find(t=>t===e.tab)??pk.tab,range:ok.find(t=>t.id===e.range)?.id??pk.range,refresh:uk.find(e=>e.value===t)?.value??pk.refresh}}function hk(e){return I({getParentRoute:()=>e,path:`status`,validateSearch:mk,search:{middlewares:[ce(pk)]},head:()=>({meta:[{title:`Status — Harper Fabric`}]}),component:ye(async()=>ze(()=>import(`./status-BJegPrWN.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 gk(e){let t=dO(e),n=[nk(t),...M_(t,e),j_(t),hk(t),Hx(t),aO(t)];return t.addChildren(n)}I({getParentRoute:()=>xo,path:`notifications`,head:()=>({meta:[{title:`Notifications — Harper Fabric`}]}),component:ye(async()=>ze(()=>import(`./notifications-DsE0S3zT.js`),__vite__mapDeps([46,1,2,3,4,5,6])),`NotificationsCenter`)}),I({getParentRoute:()=>xo,path:`profile`,head:()=>({meta:[{title:`Profile — Harper Fabric`}]}),component:ye(async()=>ze(()=>import(`./profile-BIeCZr-w.js`),__vite__mapDeps([47,1,26,3,2,4,5,6,7,27,12])),`ProfileIndex`)});var _k=bo.addChildren([...xc,xo.addChildren([gk(`local`)])]);function vk({routeTree:e=_k,authentication:t}){let[n]=(0,G.useState)(()=>Ie({routeTree:e,history:ue(),defaultNotFoundComponent:bi,defaultErrorComponent:yi,defaultPreload:!xi()&&`intent`,trailingSlash:`never`,defaultPreloadStaleTime:0,scrollRestoration:!0,context:{queryClient:wi,authentication:t||{}}}));return n}function yk(){let e=Sn(),t=vk({authentication:e}),n=(0,G.useRef)(e);return(0,G.useEffect)(()=>{n.current!==e&&(n.current=e,t.invalidate())},[t,e]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(_e,{router:t,context:{authentication:e}}),(0,K.jsx)(Oe,{router:t,position:`bottom-right`})]})}var bk=({...e})=>(0,K.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}),xk=!1;function Sk(){(0,G.useEffect)(()=>{xk||=!0},[])}function Ck(){return wo(),vo(),Sk(),(0,K.jsxs)(ja,{children:[(0,K.jsxs)(he,{client:wi,children:[(0,K.jsx)(yk,{}),(0,K.jsx)(Pe,{buttonPosition:`bottom-right`})]}),(0,K.jsx)(bk,{richColors:!0})]})}function wk(){u.signOutAllLocally(),wi.getMutationCache().clear(),wi.getQueryCache().clear(),Ja(),Ya()}function Tk(e,t=()=>!1,n=()=>!0){return r=>(r?.response?.status===401&&!t(r.config?.url??``)&&n(r.config)&&e(),Promise.reject(r))}var Ek=[`/Login/`,`/ForgotPassword/`,`/ResetPassword/`,`/VerifyEmail/`,`/ResendVerificationEmail/`],Dk=`authUserAtSend`;function Ok(){let e=u.getConnectionById(m).user;return e&&`id`in e?e.id:null}var kk=!1;function Ak(){kk||(kk=!0,N.interceptors.request.use(e=>(e[Dk]=Ok(),e)),N.interceptors.response.use(e=>e,Tk(wk,e=>Ek.some(t=>e.startsWith(t)),e=>e?.[Dk]===Ok())))}function jk(){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 Mk=`Studio:StaleDeployReloadedAt`,Nk=6e4,Pk=`__harperStaleDeployReloadState__`;function Fk(){if(!(typeof window>`u`))return window[Pk]}function Ik(){let e=Fk();if(e){try{let e=Number(sessionStorage.getItem(Mk)??0);if(Date.now()-e<Nk)return;sessionStorage.setItem(Mk,String(Date.now()))}catch{return}e.reload()}}function Lk(e=()=>window.location.reload()){if(typeof window>`u`)return;let t=window,n=t[Pk];if(n){n.reload=e;return}t[Pk]={reload:e},window.addEventListener(`vite:preloadError`,()=>Ik())}var Rk=He();jk(),Lk(),Ak(),a(),u.installExplorerCrossTabCleanup(),(0,Rk.createRoot)(document.getElementById(`root`),{onUncaughtError:(e,t)=>{Be(e,t),console.error(`Uncaught error:`,e,t)},onCaughtError:(e,t)=>{Be(e,t),console.error(`Caught error:`,e,t)},onRecoverableError:(e,t)=>{Be(e,t),console.warn(`Recoverable error:`,e,t)}}).render((0,K.jsx)(G.StrictMode,{children:(0,K.jsx)(Ck,{})}));export{ix as $,ji as $n,Ff as $t,VE as A,q as An,sr as Ar,n_ as At,mw as B,ua as Bn,An as Br,Dm as Bt,WE as C,Y as Cn,Ur as Cr,yv as Ct,IE as D,$a as Dn,Tr as Dr,sv as Dt,RE as E,lo as En,Ar as Er,cv as Et,EE as F,Oa as Fn,Ln as Fr,Ph as Ft,aC as G,ra as Gn,Vp as Gt,nw as H,_a as Hn,Dn as Hr,dm as Ht,eE as I,Da as In,On as Ir,Nh as It,kS as J,Gi as Jn,Bp as Jt,sC as K,ia as Kn,Gp as Kt,_T as L,ya as Ln,Mn as Lr,Fh as Lt,OE as M,Va as Mn,Xn as Mr,Dg as Mt,CE as N,Ua as Nn,Jn as Nr,yg as Nt,HE as O,Xa as On,wr as Or,rv as Ot,DE as P,Ha as Pn,Rn as Pr,Ih as Pt,xx as Q,Oi as Qn,jf as Qt,bw as R,va as Rn,jn as Rr,Mh as Rt,FE as S,X as Sn,Wr as Sr,Cv as St,KE as T,Io as Tn,Mr as Tr,mv as Tt,BC as U,pa as Un,En as Ur,Zp as Ut,fw as V,ha as Vn,wn as Vr,pm as Vt,oC as W,na as Wn,zp as Wt,mS as X,ki as Xn,Mp as Xt,MS as Y,Ti as Yn,Hp as Yt,tS as Z,Di as Zn,tp as Zt,pD as _,cs as _n,Xr as _r,Zv as _t,ck as a,Wu as an,Ci as ar,Mb as at,UE as b,Z as bn,Kr as br,Ev as bt,PO as c,ru as cn,gi as cr,Rb as ct,MD as d,wc as dn,fi as dr,sy as dt,Lf as en,Mi as er,$b as et,DD as f,Ec as fn,ui as fr,ay as ft,gD as g,Tc as gn,Qr as gr,Qv as gt,_D as h,Ac as hn,ti as hr,Xv as ht,ok as i,nd as in,Ei as ir,jb as it,BE as j,Ka as jn,Qn as jr,Yg as jt,LE as k,Ga as kn,lr as kr,I_ as kt,CO as l,nu as ln,mi as lr,Zy as lt,hD as m,kc as mn,si as mr,iy as mt,mk as n,Nf as nn,Fi as nr,Hb as nt,sk as o,wu as on,wi as or,zb as ot,wD as p,Dc as pn,ci as pr,oy as pt,iC as q,Yi as qn,Up as qt,uk as r,id as rn,Pi as rr,Ob as rt,lk as s,Cu as sn,yi as sr,Nb as st,Ik as t,Pf as tn,Ni as tr,Vb as tt,SO as u,Pc as un,pi as ur,Ky as ut,dD as v,$ as vn,Jr as vr,qv as vt,GE as w,J as wn,Hr as wr,hv as wt,PE as x,Bo as xn,Gr as xr,wv as xt,uD as y,Q as yn,qr as yr,Wv as yt,yw as z,da as zn,kn as zr,rh as zt};