@harperfast/harper-pro 5.0.18 → 5.0.19

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.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index.lazy-De4JGuec.js","assets/rolldown-runtime-BYbx6iT9.js","assets/vendor-datadog-D28PhZSI.js","assets/vendor-react-Dj1rnUQ4.js","assets/vendor-core-f32UXcS5.js","assets/vendor-misc-DKMU5hOJ.js","assets/vendor-markdown-E78pex-p.js","assets/vendor-html-Bv6KjEJU.js","assets/vendor-monaco-B6UzVkIC.js","assets/vendor-charts-FM0f3SSx.js","assets/vendor-react-CrIa5r46.css","assets/button-V4IQ8FFq.js","assets/useInstanceClient-CdXj_Str.js","assets/index-DZem5S77.css","assets/vendor-viz-Db_2kM67.js","assets/status-110CCE-v.js","assets/profile-voeNsl4C.js","assets/useAuth-DqzxNJHV.js"])))=>i.map(i=>d[i]);
2
- import{a as e}from"./rolldown-runtime-BYbx6iT9.js";import{_ as t,a as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as u,n as d,o as f,p,r as m,s as h,t as g,u as _,v,y}from"./button-V4IQ8FFq.js";import{At as b,Bt as x,Dt as S,Et as ee,Mt as te,Nt as C,Ot as ne,Pt as re,St as w,Tt as T,bt as ie,jt as E,kt as ae,wt as oe,xt as D,yt as se,zt as ce}from"./vendor-core-f32UXcS5.js";import{$n as le,$r as ue,$t as de,Aa as fe,Ai as O,An as pe,Ar as me,Bn as he,Br as ge,Bt as _e,Ca as k,Ci as ve,Cn as ye,Cr as be,Da as xe,Di as Se,Dn as Ce,Dr as we,Ea as Te,Ei as Ee,En as De,Er as Oe,Fa as ke,Fi as Ae,Fn as je,Fr as Me,Ft as Ne,Gi as Pe,Gn as Fe,Gr as Ie,Gt as Le,Hi as Re,Hn as ze,Hr as Be,Ht as Ve,Ii as He,In as Ue,Ir as We,Jn as Ge,Jr as Ke,Jt as qe,Ki as Je,Kn as Ye,Kr as Xe,Kt as Ze,Ln as Qe,Lr as $e,Ma as et,Mi as tt,Mn as nt,Mt as rt,Na as it,Ni as at,Nn as ot,Nr as st,Nt as ct,Oa as A,Oi as lt,On as ut,Or as dt,Pa as ft,Pi as pt,Pn as mt,Pr as ht,Pt as gt,Qn as j,Qr as _t,Qt as vt,Ri as yt,Rn as bt,Rr as xt,Sa as St,Si as Ct,Sn as wt,Sr as Tt,Ta as Et,Ti as Dt,Tn as Ot,Tr as kt,Ui as At,Un as jt,Ur as Mt,Ut as Nt,Vi as Pt,Vn as Ft,Vr as It,Vt as Lt,Wi as Rt,Wn as zt,Wr as Bt,Wt as Vt,Xi as Ht,Xn as Ut,Xr as Wt,Xt as Gt,Yi as Kt,Yn as qt,Yt as Jt,Zi as Yt,Zn as Xt,Zt,_a as Qt,_i as $t,_n as en,_r as tn,aa as nn,an as rn,ar as an,ba as on,bi as sn,bn as cn,br as ln,ca as un,ci as dn,cn as fn,cr as pn,da as mn,di as hn,dn as gn,dr as _n,ea as vn,ei as yn,en as bn,er as xn,fa as Sn,fi as Cn,fn as wn,fr as Tn,gi as En,gn as Dn,gr as On,ha as kn,hi as An,hn as jn,hr as M,ia as Mn,ii as Nn,in as Pn,ir as Fn,ja as N,ji as In,jn as Ln,ka as P,ki as Rn,kn as zn,kr as Bn,la as Vn,ln as Hn,lr as Un,ma as Wn,mi as Gn,mn as Kn,mr as qn,na as Jn,ni as Yn,nn as Xn,nr as Zn,oa as Qn,oi as $n,on as er,or as tr,pa as nr,pi as rr,pn as ir,pr as ar,qn as F,qt as or,ra as sr,ri as cr,rn as lr,rr as ur,sa as dr,si as fr,sn as pr,sr as mr,ti as hr,tn as gr,tr as _r,ua as vr,ui as yr,un as br,ur as xr,va as I,vi as Sr,vn as Cr,wa as wr,wi as Tr,wn as Er,wr as Dr,xa as Or,xn as kr,xr as Ar,ya as L,yi as jr,yn as Mr,yr as Nr,zi as Pr,zn as Fr,zr as Ir,zt as Lr}from"./vendor-react-Dj1rnUQ4.js";import{a as Rr,i as zr,r as Br}from"./vendor-tanstack-CuVnguzk.js";import{Ar as Vr,Br as Hr,Gr as Ur,Hr as Wr,Ir as Gr,Kr,Lr as qr,Mr as Jr,Nr as Yr,Pr as Xr,Rr as Zr,Ur as Qr,Vr as $r,Wr as ei,jr as ti,kr as ni,qr as ri,zr as ii}from"./vendor-misc-DKMU5hOJ.js";import{a as ai,i as oi,n as si,r as ci,t as li}from"./useAuth-DqzxNJHV.js";import{a as ui,c as di,i as fi,l as pi,n as mi,o as hi,r as R,s as gi,t as _i,u as vi}from"./useInstanceClient-CdXj_Str.js";import{i as yi,r as bi}from"./vendor-datadog-D28PhZSI.js";import"./vendor-stripe-jcNDVsoU.js";import{t as xi}from"./vendor-markdown-E78pex-p.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),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function Si(e){return e!==null&&!!e.username}function Ci(e){if(e&&!Si(e)){let t=Object.keys(e.roles);if(t.length===1)return`/${t[0]}`}return`/`}var z=ft();function wi({className:e,error:t,title:n,showReturnToHome:r,children:i}){let{user:a,isLoading:o}=oi();return Ci(a),(0,z.jsxs)(hi,{className:d(`text-red p-5 border border-red rounded-md m-12 mt-36`,e),children:[(0,z.jsxs)(pi,{children:[(0,z.jsx)(vi,{className:`text-2xl`,children:(0,z.jsx)(`h2`,{children:n??`Component Error`})}),(0,z.jsx)(di,{children:t.message})]}),(0,z.jsxs)(gi,{children:[i,r!==!1&&(a&&!o?(0,z.jsx)(L,{to:`/`,children:(0,z.jsxs)(g,{children:[` `,(0,z.jsx)(Qn,{}),` Return to Home`]})}):(0,z.jsx)(L,{to:`/sign-in`,children:(0,z.jsxs)(g,{children:[` `,(0,z.jsx)(Qn,{}),` Go to Sign In Page`]})}))]})]})}function Ti(){let{user:e,isLoading:t}=oi();return Ci(e),(0,z.jsx)(`div`,{className:`flex items-center justify-center h-screen px-3`,children:(0,z.jsxs)(hi,{className:`text-red p-5 border border-red rounded-md w-full max-w-md`,children:[(0,z.jsx)(pi,{children:(0,z.jsx)(vi,{className:`text-2xl`,children:(0,z.jsx)(`h2`,{children:`Sorry, Page Not Found`})})}),(0,z.jsx)(gi,{children:e&&!t?(0,z.jsx)(L,{to:`/`,children:(0,z.jsxs)(g,{children:[` `,(0,z.jsx)(Qn,{}),` Return to Home`]})}):(0,z.jsx)(L,{to:`/sign-in`,children:(0,z.jsxs)(g,{children:[` `,(0,z.jsx)(Qn,{}),` Go Sign In Page`]})})})]})})}function Ei(){return`ontouchstart`in window||navigator.maxTouchPoints>0}function Di(e){let t=`Error`,n=`We had some trouble!`;console.error(e);let r=e,i=e;if(typeof e==`string`?n=e:r?.response?.data?typeof r.response.data==`string`?n=r.response.data:r.response.data.error?n=r.response.data.error:r.response.data.message&&(n=r.response.data.message):i?.message&&(n=i.message),n.includes(`:`)){let e=n.split(`:`);t=e.shift(),n=e.join(`:`)}M.error(t,{description:n,action:{label:`Dismiss`,onClick:()=>M.dismiss()}})}var Oi=new Br({queryCache:new zr({onError:Di}),mutationCache:new Rr({onError:Di})}),B=e(ke(),1),ki=!1,Ai=!1;function ji(){(0,B.useEffect)(()=>{ki||(ki=!0,Ai&&(bi.init({applicationId:`f590deee-4bac-49b4-a202-3b6963d9721d`,clientToken:`pub27aa29cea521492f4fef73032f86a023`,site:`datadoghq.com`,service:`studio`,env:void 0,version:`v5.0.18`,trackViewsManually:!0,trackUserInteractions:!0,sessionSampleRate:100,sessionReplaySampleRate:0,defaultPrivacyLevel:`mask`,plugins:[ar()]}),bi.onReady(()=>{bi.startView({service:`studio`,version:`v5.0.18`,name:window.location.pathname||`initial`})})))},[])}function Mi(e){if(!Ai)return;bi.setUser({id:e.id,email:e.email,name:[e.firstname,e.lastname].filter(Boolean).join(` `)||void 0});let t=`hasLoggedInBefore:${e.id}`;localStorage.getItem(t)?bi.addAction(`return_login`):(bi.addAction(`first_time_login`),localStorage.setItem(t,`true`));let n=`lastLoginTimestamp:${e.id}`,r=localStorage.getItem(n),i=Date.now();if(r){let e=Math.floor((i-Number(r))/1e3);!Number.isNaN(e)&&e>=0&&bi.addAction(`login_time_gap`,{value:e})}localStorage.setItem(n,String(i)),bi.addAction(`login_success`,{userId:e.id})}function Ni(){return(0,z.jsx)(z.Fragment,{children:(0,z.jsx)(Wn,{})})}var Pi=Qt()({component:Ni});function Fi(){return(0,z.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 126.644 96`,width:24,height:24,children:(0,z.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 Ii(){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`img`,{src:`/harper-studio_white.png`,alt:`Harper Studio`,className:`w-64 hidden md:inline-block`}),(0,z.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`50px`,height:`44px`,alt:`Harper`,className:`inline-block md:hidden`})]})}function Li({className:e,...t}){return(0,z.jsx)(`div`,{className:d(`absolute top-full left-0 isolate z-50 flex justify-center`),children:(0,z.jsx)(_n,{"data-slot":`navigation-menu-viewport`,className:d(`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 Ri({className:e,children:t,viewport:n=!0,...r}){return(0,z.jsxs)(xr,{"data-slot":`navigation-menu`,"data-viewport":n,className:d(`group/navigation-menu relative flex max-w-max flex-1 items-center justify-center`,e),...r,children:[t,n&&(0,z.jsx)(Li,{})]})}function zi({className:e,...t}){return(0,z.jsx)(mr,{"data-slot":`navigation-menu-item`,className:d(`relative`,e),...t})}function Bi({className:e,...t}){return(0,z.jsx)(pn,{"data-slot":`navigation-menu-link`,className:d(`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 Vi({className:e,...t}){return(0,z.jsx)(Un,{"data-slot":`navigation-menu-list`,className:d(`group flex flex-1 list-none items-center justify-center gap-1`,e),...t})}var Hi=ce(`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-white [a&]:hover:bg-yellow/90`,success:`border-green bg-green/40 text-white [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-white [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`}},defaultVariants:{variant:`default`}});function Ui(){let e=`v5.0.18`;return(0,z.jsx)(`a`,{href:e?.startsWith(`v`)?`https://github.com/HarperFast/studio/releases/tag/${e}`:`https://github.com/HarperFast/studio/releases`,target:`_blank`,rel:`noopener noreferrer`,children:(0,z.jsxs)(`span`,{className:d(Hi({variant:`default`}),`text-xs inline-block ml-2 align-text-top`),children:[e,` BETA`]})})}function Wi(){localStorage.clear()}function Gi(){sessionStorage.clear()}async function Ki(){c.setUserForEntity(m,null),Oi.getQueryCache().clear(),Wi(),Gi(),await Oi.invalidateQueries({refetchType:`none`})}async function qi(e){await c.signOutFromPotentiallyAuthenticatedInstances(),await r({...e,entityId:m})}function Ji(){let e=mi();return A({mutationFn:()=>qi({instanceClient:e}),onSuccess:Ki})}function Yi(e){let{user:t}=si(),{organizationId:n}=k({strict:!1}),r=t?.roles?.[e??n];return!r?.permission&&!r?.organization?{update:!1,remove:!1}:r.permission?.super_user?{update:!0,remove:!0}:{update:r.organization.update,remove:r.organization.delete}}function Xi(e){let{user:t}=si(),{organizationId:n}=k({strict:!1}),r=t?.roles?.[e??n];if(!r?.permission&&!r?.organization?.roles)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.roles;return{create:i.create,remove:i.delete,update:i.update,view:i.view}}function Zi(e,t){let{user:n}=si(),{organizationId:r,clusterId:i}=k({strict:!1});return Qi(n,e??r,t??i)}function Qi(e,t,n){let r=e?.roles?.[t];if(!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 $i(e,t){let{user:n}=si(),{organizationId:r,clusterId:i}=k({strict:!1});return ea(n,e??r,t??i)}function ea(e,t,n){let r=e?.roles?.[t];if(!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 ta(e){let{clusterId:t,instanceId:n}=k({strict:!1}),{user:r}=ci(e??n??t),i=r?.role?.permission;return i?i.super_user===!0:!1}function na(e){let{clusterId:t,instanceId:n}=k({strict:!1}),{user:r}=ci(e??n??t),i=r?.role?.permission;return i?i.super_user===!0||i.structure_user===!0:!1}function ra(e,t,n,r){let{clusterId:i,instanceId:a}=k({strict:!1}),{user:o}=ci(e??a??i),s=o?.role?.permission;return s?s.super_user===!0||s.structure_user===!0?!0:s[t]?.tables?.[n][r]===!0:!1}var ia={className:`text-white`};function aa(){let{mutate:e}=Ji(),t=Or(),{user:n}=oi(),r=Et(),{organizationId:i}=k({strict:!1}),{update:a}=Yi(i),{view:o}=Xi(i),s=a,c=(0,B.useCallback)(()=>{e(void 0,{onSuccess:async()=>{M.success(`Success`,{description:`You have been signed out successfully.`,action:{label:`Dismiss`,onClick:()=>M.dismiss()}}),t({to:`/sign-in`}),r.invalidate()}})},[e,r,t]),l=(0,B.useMemo)(()=>[!1,!1,!1,{to:`https://docs.harperdb.io/docs`,target:`_blank`,icon:(0,z.jsx)(vn,{}),text:`Docs`,textBreakpoint:`md`},{to:`https://github.com/HarperFast/studio/issues`,target:`_blank`,icon:(0,z.jsx)(Kt,{}),text:`Report an Issue`,textBreakpoint:`lg`},{to:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,icon:(0,z.jsx)(Fi,{}),text:`Discord`,textBreakpoint:`lg`},{onClick:c,icon:(0,z.jsx)(_t,{}),text:`Sign Out`,textBreakpoint:`md`}].filter(ui),[i,s,o,c]);return n?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ua,{menuItems:l}),(0,z.jsx)(ca,{menuItems:l})]}):(0,z.jsx)(sa,{})}function oa(e){return e.items!==void 0}function sa(){return(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsxs)(`div`,{className:`inline-block`,children:[(0,z.jsx)(L,{to:`/sign-in`,children:(0,z.jsx)(Ii,{})}),(0,z.jsx)(Ui,{})]}),(0,z.jsx)(Ri,{children:(0,z.jsxs)(Vi,{className:`text-grey-400`,children:[(0,z.jsx)(zi,{children:(0,z.jsx)(Bi,{asChild:!0,children:(0,z.jsxs)(L,{to:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noreferrer noopener`,className:`flex-row items-center`,children:[(0,z.jsx)(vn,{}),` `,(0,z.jsx)(`span`,{className:`hidden md:inline-block`,children:`Docs`})]})})}),(0,z.jsx)(zi,{children:(0,z.jsx)(Bi,{asChild:!0,children:(0,z.jsxs)(L,{to:`/sign-in`,className:`flex-row items-center`,activeProps:ia,children:[(0,z.jsx)(ue,{}),` Sign In`]})})})]})})]})}function ca({menuItems:e}){let{user:t}=oi();return Ci(t),(0,z.jsx)(`div`,{className:`hidden md:block`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsxs)(`div`,{className:`inline-block`,children:[(0,z.jsx)(L,{to:`/`,children:(0,z.jsx)(Ii,{})}),(0,z.jsx)(Ui,{})]}),(0,z.jsx)(Ri,{children:(0,z.jsx)(Vi,{className:`text-grey-400`,children:e.map(e=>oa(e)?!!e.items.length&&(0,z.jsx)(`div`,{className:`bg-black rounded-2xl flex`,children:e.items.map(e=>(0,z.jsx)(la,{menuItem:e},e.text))},e.text):(0,z.jsx)(la,{menuItem:e},e.text))})})]})})}function la({menuItem:e}){return(0,z.jsx)(zi,{className:`text-gray-400 hover:text-white`,children:(0,z.jsx)(Bi,{asChild:!0,children:(0,z.jsxs)(L,{to:e.to,onClick:e.onClick,className:`flex-row items-center`,target:e.target,activeProps:e.to?ia:void 0,children:[e.icon,(0,z.jsx)(`span`,{className:`hidden ${e.textBreakpoint}:inline-block`,children:e.text}),(0,z.jsx)(`span`,{className:`${e.textBreakpoint}:hidden`,children:`\xA0`})]})})})}function ua({menuItems:e}){let{user:t}=oi();Ci(t);let[n,r]=(0,B.useState)(!1),i=(0,B.useCallback)(()=>r(e=>!e),[]),a=(0,B.useCallback)(()=>r(!1),[]);return(0,z.jsxs)(`div`,{className:`md:hidden`,id:`mobile-menu`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsx)(L,{to:`/`,children:(0,z.jsx)(Ii,{})}),(0,z.jsx)(Ui,{}),(0,z.jsxs)(`button`,{type:`button`,className:`shadow-xs text-grey-400 hover:text-white hover:bg-black-dark`,onClick:i,children:[(0,z.jsx)(`span`,{className:`sr-only`,children:n?`Close menu`:`Open menu`}),n?(0,z.jsx)(On,{}):(0,z.jsx)(Ke,{})]})]}),(0,z.jsx)(`div`,{className:`${n?`fixed`:`hidden`} top-40 bottom-0 left-0 right-0 bg-black-dark opacity-70`,onClick:a}),(0,z.jsx)(`div`,{className:`${n?`block`:`hidden`} md:hidden z-50 space-y-1 pb-3 bg-black-dark absolute left-0 top-full w-full rounded-b-md`,children:e.map(e=>oa(e)?!!e.items.length&&(0,z.jsx)(`div`,{className:`bg-black pl-10 pr-2 py-2`,children:e.items.map(e=>(0,z.jsx)(da,{menuItem:e,onClick:a},e.text))},e.text):(0,z.jsx)(da,{menuItem:e,onClick:a},e.text))})]})}function da({menuItem:e,onClick:t}){let n=(0,B.useCallback)(()=>{e.onClick?.(),t()},[e,t]);return(0,z.jsxs)(L,{to:e.to,onClick:n,target:e.target,className:`flex flex-row px-3 py-2 text-base font-medium rounded-md text-gray-400 hover:text-white`,activeProps:e.to?ia:void 0,children:[e.icon,(0,z.jsx)(`span`,{className:`ml-4`,children:e.text})]})}function fa(){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`header`,{className:`fixed top-0 z-40 w-full h-20 p-4 bg-black-dark dark:bg-black-dark dark:border-b dark:border-black md:px-12`,children:(0,z.jsx)(aa,{})}),(0,z.jsxs)(`div`,{className:`pt-20 grid h-screen grid-cols-1 md:grid-cols-2`,children:[(0,z.jsx)(`section`,{className:`items-center justify-center hidden text-white md:flex px-6 fabricSignupTextContainer`,children:(0,z.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,z.jsx)(`section`,{className:`flex items-center justify-center px-6 bg-linear-(--purple-gradient) dark:bg-linear-(--black-dark-gradient)`,children:(0,z.jsx)(Wn,{})})]})]})}var pa;function ma(){(0,B.useEffect)(()=>{},[])}var ha=[`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 ga(e){if(!e||!e.includes(`@`))return null;let t=e.split(`@`).pop()||``;if(!t)return null;for(let e of ha)if(t===e||t.endsWith(`.`+e))return null;return t}var _a=null;function va(){let e=Or(),t=Et(),n=it(),{redirect:r}=St({strict:!1});return(0,B.useEffect)(()=>{_a||=(async function(){let i=await _().catch(()=>null);if(!i)M.error(`We were not able to verify your sign-in. Please try signing in again.`,{duration:1e4}),await e({to:`/sign-in`});else{c.setUserForEntity(m,i);let a=Ci(i);Mi(i);let o=ga(i.email);pa?.identify?.({username:i.email,type:`email`,...o?{company:o}:{}}),await n.invalidateQueries({queryKey:l,refetchType:`none`}),await t.invalidate(),await e({to:r?.startsWith(`/`)?r:a})}_a=null})()},[]),(0,z.jsxs)(`div`,{className:`text-white w-lg flex flex-col gap-4`,children:[(0,z.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Checking...`]}),(0,z.jsx)(`div`,{className:`underline flex gap-4`,children:(0,z.jsx)(L,{className:`text-sm opacity-50 hover:text-blue-300`,to:`/sign-in`,children:`Try signing in again`})})]})}function ya({delayDuration:e=0,...t}){return(0,z.jsx)(Fn,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function ba({...e}){return(0,z.jsx)(ya,{children:(0,z.jsx)(an,{"data-slot":`tooltip`,...e})})}function xa({...e}){return(0,z.jsx)(tr,{"data-slot":`tooltip-trigger`,...e})}function Sa({className:e,sideOffset:t=0,arrowClassName:n,children:r,...i}){return(0,z.jsx)(ur,{children:(0,z.jsxs)(Zn,{"data-slot":`tooltip-content`,sideOffset:t,className:d(`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,z.jsx)(_r,{className:d(`bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`,n)})]})})}var Ca=new Map;function wa(e){if(!e)return``;if(Ca.has(e))return Ca.get(e);let t=e.replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();if(!t)return Ca.set(e,``),``;let n=t.match(/([A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|[0-9]+)/g);if(!n)return Ca.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(Ta).join(` `);return Ca.set(e,i),i}function Ta(e){return/^[A-Z]{2,3}s?$/.test(e)||/^[0-9]+$/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function Ea({restartRequired:e}){let t=vr(),{organization:n,instance:r,cluster:i}=mn({strict:!1});return(0,z.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:[...(0,B.useMemo)(()=>{let e=t.pathname.split(`/`).filter(e=>e&&e.length>0),a=[(0,z.jsxs)(L,{to:`/`,children:[(0,z.jsx)($n,{"aria-hidden":`true`,className:`size-5 shrink-0`}),(0,z.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=wa(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,z.jsx)(`svg`,{fill:`currentColor`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`size-5 shrink-0 text-grey`,children:(0,z.jsx)(`path`,{d:`M5.555 17.776l8-16 .894.448-8 16-.894-.448z`})},a.length+`-dash`),(0,z.jsx)(L,{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]),e&&(0,z.jsxs)(ba,{children:[(0,z.jsx)(xa,{asChild:!0,children:(0,z.jsxs)(`div`,{className:`text-xs italic text-muted-foreground`,children:[`* Restart `,(0,z.jsx)(`span`,{className:`hidden lg:inline-block`,children:`Requested`})]})}),(0,z.jsxs)(Sa,{side:`bottom`,children:[`This `,`Instance`,` is requesting a restart, when convenient, to apply your latest changes.`,(0,z.jsx)(`br`,{}),`You can do this from the Apps or Config pages.`]})]})]})}var V=Ut,Da=(0,B.createContext)({}),Oa=(0,B.createContext)({});function ka(){let e=(0,B.useContext)(Da),t=(0,B.useContext)(Oa),{getFieldState:n}=le(),r=xn({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 H({...e}){let{error:t,formItemId:n,formDescriptionId:r,formMessageId:i}=ka();return(0,z.jsx)(Vn,{"data-slot":`form-control`,id:n,"aria-describedby":t?`${r} ${i}`:`${r}`,"aria-invalid":!!t,...e})}function U({...e}){return(0,z.jsx)(Da,{value:{name:e.name},children:(0,z.jsx)(qt,{...e})})}function W({className:e,...t}){return(0,z.jsx)(Oa,{value:{id:(0,B.useId)()},children:(0,z.jsx)(`div`,{"data-slot":`form-item`,className:d(`grid gap-2`,e),...t})})}function Aa({className:e,...t}){return(0,z.jsx)(Ge,{"data-slot":`label`,className:d(`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 G({className:e,...t}){let{error:n,formItemId:r}=ka();return(0,z.jsx)(Aa,{"data-slot":`form-label`,"data-error":!!n,className:d(`data-[error=true]:text-destructive`,e),htmlFor:r,...t})}function K({className:e,...t}){let{error:n,formMessageId:r}=ka(),i=n?String(n?.message):t.children;return i?(0,z.jsx)(`p`,{"data-slot":`form-message`,id:r,className:d(`text-destructive text-sm`,e),...t,children:i}):null}function q({className:e,type:t,...n}){return(0,z.jsx)(`input`,{type:t,"data-slot":`input`,className:d(`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/index.lazy-DN6bSQzR.js","assets/rolldown-runtime-BYbx6iT9.js","assets/vendor-datadog-D28PhZSI.js","assets/vendor-react-Dj1rnUQ4.js","assets/vendor-core-f32UXcS5.js","assets/vendor-misc-DKMU5hOJ.js","assets/vendor-markdown-E78pex-p.js","assets/vendor-html-Bv6KjEJU.js","assets/vendor-monaco-B6UzVkIC.js","assets/vendor-charts-FM0f3SSx.js","assets/vendor-react-CrIa5r46.css","assets/button-V4IQ8FFq.js","assets/useInstanceClient-CdXj_Str.js","assets/index-DZem5S77.css","assets/vendor-viz-Db_2kM67.js","assets/status-BrfTnnpt.js","assets/profile-Dyrp-ZIJ.js","assets/useAuth-DqzxNJHV.js"])))=>i.map(i=>d[i]);
2
+ import{a as e}from"./rolldown-runtime-BYbx6iT9.js";import{_ as t,a as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as u,n as d,o as f,p,r as m,s as h,t as g,u as _,v,y}from"./button-V4IQ8FFq.js";import{At as b,Bt as x,Dt as S,Et as ee,Mt as te,Nt as C,Ot as ne,Pt as re,St as w,Tt as T,bt as ie,jt as E,kt as ae,wt as oe,xt as D,yt as se,zt as ce}from"./vendor-core-f32UXcS5.js";import{$n as le,$r as ue,$t as de,Aa as fe,Ai as O,An as pe,Ar as me,Bn as he,Br as ge,Bt as _e,Ca as k,Ci as ve,Cn as ye,Cr as be,Da as xe,Di as Se,Dn as Ce,Dr as we,Ea as Te,Ei as Ee,En as De,Er as Oe,Fa as ke,Fi as Ae,Fn as je,Fr as Me,Ft as Ne,Gi as Pe,Gn as Fe,Gr as Ie,Gt as Le,Hi as Re,Hn as ze,Hr as Be,Ht as Ve,Ii as He,In as Ue,Ir as We,Jn as Ge,Jr as Ke,Jt as qe,Ki as Je,Kn as Ye,Kr as Xe,Kt as Ze,Ln as Qe,Lr as $e,Ma as et,Mi as tt,Mn as nt,Mt as rt,Na as it,Ni as at,Nn as ot,Nr as st,Nt as ct,Oa as A,Oi as lt,On as ut,Or as dt,Pa as ft,Pi as pt,Pn as mt,Pr as ht,Pt as gt,Qn as j,Qr as _t,Qt as vt,Ri as yt,Rn as bt,Rr as xt,Sa as St,Si as Ct,Sn as wt,Sr as Tt,Ta as Et,Ti as Dt,Tn as Ot,Tr as kt,Ui as At,Un as jt,Ur as Mt,Ut as Nt,Vi as Pt,Vn as Ft,Vr as It,Vt as Lt,Wi as Rt,Wn as zt,Wr as Bt,Wt as Vt,Xi as Ht,Xn as Ut,Xr as Wt,Xt as Gt,Yi as Kt,Yn as qt,Yt as Jt,Zi as Yt,Zn as Xt,Zt,_a as Qt,_i as $t,_n as en,_r as tn,aa as nn,an as rn,ar as an,ba as on,bi as sn,bn as cn,br as ln,ca as un,ci as dn,cn as fn,cr as pn,da as mn,di as hn,dn as gn,dr as _n,ea as vn,ei as yn,en as bn,er as xn,fa as Sn,fi as Cn,fn as wn,fr as Tn,gi as En,gn as Dn,gr as On,ha as kn,hi as An,hn as jn,hr as M,ia as Mn,ii as Nn,in as Pn,ir as Fn,ja as N,ji as In,jn as Ln,ka as P,ki as Rn,kn as zn,kr as Bn,la as Vn,ln as Hn,lr as Un,ma as Wn,mi as Gn,mn as Kn,mr as qn,na as Jn,ni as Yn,nn as Xn,nr as Zn,oa as Qn,oi as $n,on as er,or as tr,pa as nr,pi as rr,pn as ir,pr as ar,qn as F,qt as or,ra as sr,ri as cr,rn as lr,rr as ur,sa as dr,si as fr,sn as pr,sr as mr,ti as hr,tn as gr,tr as _r,ua as vr,ui as yr,un as br,ur as xr,va as I,vi as Sr,vn as Cr,wa as wr,wi as Tr,wn as Er,wr as Dr,xa as Or,xn as kr,xr as Ar,ya as L,yi as jr,yn as Mr,yr as Nr,zi as Pr,zn as Fr,zr as Ir,zt as Lr}from"./vendor-react-Dj1rnUQ4.js";import{a as Rr,i as zr,r as Br}from"./vendor-tanstack-CuVnguzk.js";import{Ar as Vr,Br as Hr,Gr as Ur,Hr as Wr,Ir as Gr,Kr,Lr as qr,Mr as Jr,Nr as Yr,Pr as Xr,Rr as Zr,Ur as Qr,Vr as $r,Wr as ei,jr as ti,kr as ni,qr as ri,zr as ii}from"./vendor-misc-DKMU5hOJ.js";import{a as ai,i as oi,n as si,r as ci,t as li}from"./useAuth-DqzxNJHV.js";import{a as ui,c as di,i as fi,l as pi,n as mi,o as hi,r as R,s as gi,t as _i,u as vi}from"./useInstanceClient-CdXj_Str.js";import{i as yi,r as bi}from"./vendor-datadog-D28PhZSI.js";import"./vendor-stripe-jcNDVsoU.js";import{t as xi}from"./vendor-markdown-E78pex-p.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),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function Si(e){return e!==null&&!!e.username}function Ci(e){if(e&&!Si(e)){let t=Object.keys(e.roles);if(t.length===1)return`/${t[0]}`}return`/`}var z=ft();function wi({className:e,error:t,title:n,showReturnToHome:r,children:i}){let{user:a,isLoading:o}=oi();return Ci(a),(0,z.jsxs)(hi,{className:d(`text-red p-5 border border-red rounded-md m-12 mt-36`,e),children:[(0,z.jsxs)(pi,{children:[(0,z.jsx)(vi,{className:`text-2xl`,children:(0,z.jsx)(`h2`,{children:n??`Component Error`})}),(0,z.jsx)(di,{children:t.message})]}),(0,z.jsxs)(gi,{children:[i,r!==!1&&(a&&!o?(0,z.jsx)(L,{to:`/`,children:(0,z.jsxs)(g,{children:[` `,(0,z.jsx)(Qn,{}),` Return to Home`]})}):(0,z.jsx)(L,{to:`/sign-in`,children:(0,z.jsxs)(g,{children:[` `,(0,z.jsx)(Qn,{}),` Go to Sign In Page`]})}))]})]})}function Ti(){let{user:e,isLoading:t}=oi();return Ci(e),(0,z.jsx)(`div`,{className:`flex items-center justify-center h-screen px-3`,children:(0,z.jsxs)(hi,{className:`text-red p-5 border border-red rounded-md w-full max-w-md`,children:[(0,z.jsx)(pi,{children:(0,z.jsx)(vi,{className:`text-2xl`,children:(0,z.jsx)(`h2`,{children:`Sorry, Page Not Found`})})}),(0,z.jsx)(gi,{children:e&&!t?(0,z.jsx)(L,{to:`/`,children:(0,z.jsxs)(g,{children:[` `,(0,z.jsx)(Qn,{}),` Return to Home`]})}):(0,z.jsx)(L,{to:`/sign-in`,children:(0,z.jsxs)(g,{children:[` `,(0,z.jsx)(Qn,{}),` Go Sign In Page`]})})})]})})}function Ei(){return`ontouchstart`in window||navigator.maxTouchPoints>0}function Di(e){let t=`Error`,n=`We had some trouble!`;console.error(e);let r=e,i=e;if(typeof e==`string`?n=e:r?.response?.data?typeof r.response.data==`string`?n=r.response.data:r.response.data.error?n=r.response.data.error:r.response.data.message&&(n=r.response.data.message):i?.message&&(n=i.message),n.includes(`:`)){let e=n.split(`:`);t=e.shift(),n=e.join(`:`)}M.error(t,{description:n,action:{label:`Dismiss`,onClick:()=>M.dismiss()}})}var Oi=new Br({queryCache:new zr({onError:Di}),mutationCache:new Rr({onError:Di})}),B=e(ke(),1),ki=!1,Ai=!1;function ji(){(0,B.useEffect)(()=>{ki||(ki=!0,Ai&&(bi.init({applicationId:`f590deee-4bac-49b4-a202-3b6963d9721d`,clientToken:`pub27aa29cea521492f4fef73032f86a023`,site:`datadoghq.com`,service:`studio`,env:void 0,version:`v5.0.19`,trackViewsManually:!0,trackUserInteractions:!0,sessionSampleRate:100,sessionReplaySampleRate:0,defaultPrivacyLevel:`mask`,plugins:[ar()]}),bi.onReady(()=>{bi.startView({service:`studio`,version:`v5.0.19`,name:window.location.pathname||`initial`})})))},[])}function Mi(e){if(!Ai)return;bi.setUser({id:e.id,email:e.email,name:[e.firstname,e.lastname].filter(Boolean).join(` `)||void 0});let t=`hasLoggedInBefore:${e.id}`;localStorage.getItem(t)?bi.addAction(`return_login`):(bi.addAction(`first_time_login`),localStorage.setItem(t,`true`));let n=`lastLoginTimestamp:${e.id}`,r=localStorage.getItem(n),i=Date.now();if(r){let e=Math.floor((i-Number(r))/1e3);!Number.isNaN(e)&&e>=0&&bi.addAction(`login_time_gap`,{value:e})}localStorage.setItem(n,String(i)),bi.addAction(`login_success`,{userId:e.id})}function Ni(){return(0,z.jsx)(z.Fragment,{children:(0,z.jsx)(Wn,{})})}var Pi=Qt()({component:Ni});function Fi(){return(0,z.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 126.644 96`,width:24,height:24,children:(0,z.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 Ii(){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`img`,{src:`/harper-studio_white.png`,alt:`Harper Studio`,className:`w-64 hidden md:inline-block`}),(0,z.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`50px`,height:`44px`,alt:`Harper`,className:`inline-block md:hidden`})]})}function Li({className:e,...t}){return(0,z.jsx)(`div`,{className:d(`absolute top-full left-0 isolate z-50 flex justify-center`),children:(0,z.jsx)(_n,{"data-slot":`navigation-menu-viewport`,className:d(`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 Ri({className:e,children:t,viewport:n=!0,...r}){return(0,z.jsxs)(xr,{"data-slot":`navigation-menu`,"data-viewport":n,className:d(`group/navigation-menu relative flex max-w-max flex-1 items-center justify-center`,e),...r,children:[t,n&&(0,z.jsx)(Li,{})]})}function zi({className:e,...t}){return(0,z.jsx)(mr,{"data-slot":`navigation-menu-item`,className:d(`relative`,e),...t})}function Bi({className:e,...t}){return(0,z.jsx)(pn,{"data-slot":`navigation-menu-link`,className:d(`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 Vi({className:e,...t}){return(0,z.jsx)(Un,{"data-slot":`navigation-menu-list`,className:d(`group flex flex-1 list-none items-center justify-center gap-1`,e),...t})}var Hi=ce(`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-white [a&]:hover:bg-yellow/90`,success:`border-green bg-green/40 text-white [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-white [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`}},defaultVariants:{variant:`default`}});function Ui(){let e=`v5.0.19`;return(0,z.jsx)(`a`,{href:e?.startsWith(`v`)?`https://github.com/HarperFast/studio/releases/tag/${e}`:`https://github.com/HarperFast/studio/releases`,target:`_blank`,rel:`noopener noreferrer`,children:(0,z.jsxs)(`span`,{className:d(Hi({variant:`default`}),`text-xs inline-block ml-2 align-text-top`),children:[e,` BETA`]})})}function Wi(){localStorage.clear()}function Gi(){sessionStorage.clear()}async function Ki(){c.setUserForEntity(m,null),Oi.getQueryCache().clear(),Wi(),Gi(),await Oi.invalidateQueries({refetchType:`none`})}async function qi(e){await c.signOutFromPotentiallyAuthenticatedInstances(),await r({...e,entityId:m})}function Ji(){let e=mi();return A({mutationFn:()=>qi({instanceClient:e}),onSuccess:Ki})}function Yi(e){let{user:t}=si(),{organizationId:n}=k({strict:!1}),r=t?.roles?.[e??n];return!r?.permission&&!r?.organization?{update:!1,remove:!1}:r.permission?.super_user?{update:!0,remove:!0}:{update:r.organization.update,remove:r.organization.delete}}function Xi(e){let{user:t}=si(),{organizationId:n}=k({strict:!1}),r=t?.roles?.[e??n];if(!r?.permission&&!r?.organization?.roles)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.roles;return{create:i.create,remove:i.delete,update:i.update,view:i.view}}function Zi(e,t){let{user:n}=si(),{organizationId:r,clusterId:i}=k({strict:!1});return Qi(n,e??r,t??i)}function Qi(e,t,n){let r=e?.roles?.[t];if(!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 $i(e,t){let{user:n}=si(),{organizationId:r,clusterId:i}=k({strict:!1});return ea(n,e??r,t??i)}function ea(e,t,n){let r=e?.roles?.[t];if(!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 ta(e){let{clusterId:t,instanceId:n}=k({strict:!1}),{user:r}=ci(e??n??t),i=r?.role?.permission;return i?i.super_user===!0:!1}function na(e){let{clusterId:t,instanceId:n}=k({strict:!1}),{user:r}=ci(e??n??t),i=r?.role?.permission;return i?i.super_user===!0||i.structure_user===!0:!1}function ra(e,t,n,r){let{clusterId:i,instanceId:a}=k({strict:!1}),{user:o}=ci(e??a??i),s=o?.role?.permission;return s?s.super_user===!0||s.structure_user===!0?!0:s[t]?.tables?.[n][r]===!0:!1}var ia={className:`text-white`};function aa(){let{mutate:e}=Ji(),t=Or(),{user:n}=oi(),r=Et(),{organizationId:i}=k({strict:!1}),{update:a}=Yi(i),{view:o}=Xi(i),s=a,c=(0,B.useCallback)(()=>{e(void 0,{onSuccess:async()=>{M.success(`Success`,{description:`You have been signed out successfully.`,action:{label:`Dismiss`,onClick:()=>M.dismiss()}}),t({to:`/sign-in`}),r.invalidate()}})},[e,r,t]),l=(0,B.useMemo)(()=>[!1,!1,!1,{to:`https://docs.harperdb.io/docs`,target:`_blank`,icon:(0,z.jsx)(vn,{}),text:`Docs`,textBreakpoint:`md`},{to:`https://github.com/HarperFast/studio/issues`,target:`_blank`,icon:(0,z.jsx)(Kt,{}),text:`Report an Issue`,textBreakpoint:`lg`},{to:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,icon:(0,z.jsx)(Fi,{}),text:`Discord`,textBreakpoint:`lg`},{onClick:c,icon:(0,z.jsx)(_t,{}),text:`Sign Out`,textBreakpoint:`md`}].filter(ui),[i,s,o,c]);return n?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ua,{menuItems:l}),(0,z.jsx)(ca,{menuItems:l})]}):(0,z.jsx)(sa,{})}function oa(e){return e.items!==void 0}function sa(){return(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsxs)(`div`,{className:`inline-block`,children:[(0,z.jsx)(L,{to:`/sign-in`,children:(0,z.jsx)(Ii,{})}),(0,z.jsx)(Ui,{})]}),(0,z.jsx)(Ri,{children:(0,z.jsxs)(Vi,{className:`text-grey-400`,children:[(0,z.jsx)(zi,{children:(0,z.jsx)(Bi,{asChild:!0,children:(0,z.jsxs)(L,{to:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noreferrer noopener`,className:`flex-row items-center`,children:[(0,z.jsx)(vn,{}),` `,(0,z.jsx)(`span`,{className:`hidden md:inline-block`,children:`Docs`})]})})}),(0,z.jsx)(zi,{children:(0,z.jsx)(Bi,{asChild:!0,children:(0,z.jsxs)(L,{to:`/sign-in`,className:`flex-row items-center`,activeProps:ia,children:[(0,z.jsx)(ue,{}),` Sign In`]})})})]})})]})}function ca({menuItems:e}){let{user:t}=oi();return Ci(t),(0,z.jsx)(`div`,{className:`hidden md:block`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsxs)(`div`,{className:`inline-block`,children:[(0,z.jsx)(L,{to:`/`,children:(0,z.jsx)(Ii,{})}),(0,z.jsx)(Ui,{})]}),(0,z.jsx)(Ri,{children:(0,z.jsx)(Vi,{className:`text-grey-400`,children:e.map(e=>oa(e)?!!e.items.length&&(0,z.jsx)(`div`,{className:`bg-black rounded-2xl flex`,children:e.items.map(e=>(0,z.jsx)(la,{menuItem:e},e.text))},e.text):(0,z.jsx)(la,{menuItem:e},e.text))})})]})})}function la({menuItem:e}){return(0,z.jsx)(zi,{className:`text-gray-400 hover:text-white`,children:(0,z.jsx)(Bi,{asChild:!0,children:(0,z.jsxs)(L,{to:e.to,onClick:e.onClick,className:`flex-row items-center`,target:e.target,activeProps:e.to?ia:void 0,children:[e.icon,(0,z.jsx)(`span`,{className:`hidden ${e.textBreakpoint}:inline-block`,children:e.text}),(0,z.jsx)(`span`,{className:`${e.textBreakpoint}:hidden`,children:`\xA0`})]})})})}function ua({menuItems:e}){let{user:t}=oi();Ci(t);let[n,r]=(0,B.useState)(!1),i=(0,B.useCallback)(()=>r(e=>!e),[]),a=(0,B.useCallback)(()=>r(!1),[]);return(0,z.jsxs)(`div`,{className:`md:hidden`,id:`mobile-menu`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsx)(L,{to:`/`,children:(0,z.jsx)(Ii,{})}),(0,z.jsx)(Ui,{}),(0,z.jsxs)(`button`,{type:`button`,className:`shadow-xs text-grey-400 hover:text-white hover:bg-black-dark`,onClick:i,children:[(0,z.jsx)(`span`,{className:`sr-only`,children:n?`Close menu`:`Open menu`}),n?(0,z.jsx)(On,{}):(0,z.jsx)(Ke,{})]})]}),(0,z.jsx)(`div`,{className:`${n?`fixed`:`hidden`} top-40 bottom-0 left-0 right-0 bg-black-dark opacity-70`,onClick:a}),(0,z.jsx)(`div`,{className:`${n?`block`:`hidden`} md:hidden z-50 space-y-1 pb-3 bg-black-dark absolute left-0 top-full w-full rounded-b-md`,children:e.map(e=>oa(e)?!!e.items.length&&(0,z.jsx)(`div`,{className:`bg-black pl-10 pr-2 py-2`,children:e.items.map(e=>(0,z.jsx)(da,{menuItem:e,onClick:a},e.text))},e.text):(0,z.jsx)(da,{menuItem:e,onClick:a},e.text))})]})}function da({menuItem:e,onClick:t}){let n=(0,B.useCallback)(()=>{e.onClick?.(),t()},[e,t]);return(0,z.jsxs)(L,{to:e.to,onClick:n,target:e.target,className:`flex flex-row px-3 py-2 text-base font-medium rounded-md text-gray-400 hover:text-white`,activeProps:e.to?ia:void 0,children:[e.icon,(0,z.jsx)(`span`,{className:`ml-4`,children:e.text})]})}function fa(){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`header`,{className:`fixed top-0 z-40 w-full h-20 p-4 bg-black-dark dark:bg-black-dark dark:border-b dark:border-black md:px-12`,children:(0,z.jsx)(aa,{})}),(0,z.jsxs)(`div`,{className:`pt-20 grid h-screen grid-cols-1 md:grid-cols-2`,children:[(0,z.jsx)(`section`,{className:`items-center justify-center hidden text-white md:flex px-6 fabricSignupTextContainer`,children:(0,z.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,z.jsx)(`section`,{className:`flex items-center justify-center px-6 bg-linear-(--purple-gradient) dark:bg-linear-(--black-dark-gradient)`,children:(0,z.jsx)(Wn,{})})]})]})}var pa;function ma(){(0,B.useEffect)(()=>{},[])}var ha=[`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 ga(e){if(!e||!e.includes(`@`))return null;let t=e.split(`@`).pop()||``;if(!t)return null;for(let e of ha)if(t===e||t.endsWith(`.`+e))return null;return t}var _a=null;function va(){let e=Or(),t=Et(),n=it(),{redirect:r}=St({strict:!1});return(0,B.useEffect)(()=>{_a||=(async function(){let i=await _().catch(()=>null);if(!i)M.error(`We were not able to verify your sign-in. Please try signing in again.`,{duration:1e4}),await e({to:`/sign-in`});else{c.setUserForEntity(m,i);let a=Ci(i);Mi(i);let o=ga(i.email);pa?.identify?.({username:i.email,type:`email`,...o?{company:o}:{}}),await n.invalidateQueries({queryKey:l,refetchType:`none`}),await t.invalidate(),await e({to:r?.startsWith(`/`)?r:a})}_a=null})()},[]),(0,z.jsxs)(`div`,{className:`text-white w-lg flex flex-col gap-4`,children:[(0,z.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Checking...`]}),(0,z.jsx)(`div`,{className:`underline flex gap-4`,children:(0,z.jsx)(L,{className:`text-sm opacity-50 hover:text-blue-300`,to:`/sign-in`,children:`Try signing in again`})})]})}function ya({delayDuration:e=0,...t}){return(0,z.jsx)(Fn,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function ba({...e}){return(0,z.jsx)(ya,{children:(0,z.jsx)(an,{"data-slot":`tooltip`,...e})})}function xa({...e}){return(0,z.jsx)(tr,{"data-slot":`tooltip-trigger`,...e})}function Sa({className:e,sideOffset:t=0,arrowClassName:n,children:r,...i}){return(0,z.jsx)(ur,{children:(0,z.jsxs)(Zn,{"data-slot":`tooltip-content`,sideOffset:t,className:d(`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,z.jsx)(_r,{className:d(`bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`,n)})]})})}var Ca=new Map;function wa(e){if(!e)return``;if(Ca.has(e))return Ca.get(e);let t=e.replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();if(!t)return Ca.set(e,``),``;let n=t.match(/([A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|[0-9]+)/g);if(!n)return Ca.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(Ta).join(` `);return Ca.set(e,i),i}function Ta(e){return/^[A-Z]{2,3}s?$/.test(e)||/^[0-9]+$/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function Ea({restartRequired:e}){let t=vr(),{organization:n,instance:r,cluster:i}=mn({strict:!1});return(0,z.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:[...(0,B.useMemo)(()=>{let e=t.pathname.split(`/`).filter(e=>e&&e.length>0),a=[(0,z.jsxs)(L,{to:`/`,children:[(0,z.jsx)($n,{"aria-hidden":`true`,className:`size-5 shrink-0`}),(0,z.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=wa(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,z.jsx)(`svg`,{fill:`currentColor`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`size-5 shrink-0 text-grey`,children:(0,z.jsx)(`path`,{d:`M5.555 17.776l8-16 .894.448-8 16-.894-.448z`})},a.length+`-dash`),(0,z.jsx)(L,{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]),e&&(0,z.jsxs)(ba,{children:[(0,z.jsx)(xa,{asChild:!0,children:(0,z.jsxs)(`div`,{className:`text-xs italic text-muted-foreground`,children:[`* Restart `,(0,z.jsx)(`span`,{className:`hidden lg:inline-block`,children:`Requested`})]})}),(0,z.jsxs)(Sa,{side:`bottom`,children:[`This `,`Instance`,` is requesting a restart, when convenient, to apply your latest changes.`,(0,z.jsx)(`br`,{}),`You can do this from the Apps or Config pages.`]})]})]})}var V=Ut,Da=(0,B.createContext)({}),Oa=(0,B.createContext)({});function ka(){let e=(0,B.useContext)(Da),t=(0,B.useContext)(Oa),{getFieldState:n}=le(),r=xn({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 H({...e}){let{error:t,formItemId:n,formDescriptionId:r,formMessageId:i}=ka();return(0,z.jsx)(Vn,{"data-slot":`form-control`,id:n,"aria-describedby":t?`${r} ${i}`:`${r}`,"aria-invalid":!!t,...e})}function U({...e}){return(0,z.jsx)(Da,{value:{name:e.name},children:(0,z.jsx)(qt,{...e})})}function W({className:e,...t}){return(0,z.jsx)(Oa,{value:{id:(0,B.useId)()},children:(0,z.jsx)(`div`,{"data-slot":`form-item`,className:d(`grid gap-2`,e),...t})})}function Aa({className:e,...t}){return(0,z.jsx)(Ge,{"data-slot":`label`,className:d(`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 G({className:e,...t}){let{error:n,formItemId:r}=ka();return(0,z.jsx)(Aa,{"data-slot":`form-label`,"data-error":!!n,className:d(`data-[error=true]:text-destructive`,e),htmlFor:r,...t})}function K({className:e,...t}){let{error:n,formMessageId:r}=ka(),i=n?String(n?.message):t.children;return i?(0,z.jsx)(`p`,{"data-slot":`form-message`,id:r,className:d(`text-destructive text-sm`,e),...t,children:i}):null}function q({className:e,type:t,...n}){return(0,z.jsx)(`input`,{type:t,"data-slot":`input`,className:d(`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
@@ -8,7 +8,7 @@ import{a as e}from"./rolldown-runtime-BYbx6iT9.js";import{_ as t,a as n,c as r,d
8
8
  file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium
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 ja=[`RUNNING`],Ma=[`TERMINATING`,`TERMINATED`,`REMOVED`];function Na(){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 Pa({username:e,password:t,instanceClient:n,entityId:r}){let i={username:e,password:t};c.checkForBasicAuth(r)&&(n.defaults.auth=i,n.defaults.withCredentials=!1);let{data:{message:o}}=await n.post(`/`,{operation:`login`,username:e,password:t});if(!c.checkForBasicAuth(r))try{return{message:o,user:await h({instanceClient:n})}}catch(e){console.error(`Failed to get user after login, trying basic auth`,e)}try{n.defaults.auth=i,n.defaults.withCredentials=!1;let e=await h({instanceClient:n,auth:i});return c.flagForBasicAuth(r,i),{message:o,user:e}}catch(e){throw n.defaults.auth=void 0,n.defaults.withCredentials=!0,e}let s=a({id:r,forceFabricConnect:!0}),l=await h({instanceClient:s});return c.flagForFabricConnect(r,!0),{message:o,user:l,instanceClient:s}}function Fa(){return A({mutationFn:Pa})}function Ia({cluster:e,instance:t,instanceParams:n}){let r=Or(),i=Et(),{redirect:a}=St({strict:!1}),{mutate:o,isPending:s}=Fa();return{isPending:s,submitForm:(0,B.useCallback)(async s=>{o({...s,...n},{onSuccess:async({message:n,user:o})=>{if(M.success(n),e?.instances?.length&&!t)for(let t of e.instances)c.setUserForEntity(t,o);let s=m;if(!s)throw Error(`Sign in failed due to missing cluster or instance.`);c.setUserForEntity(s,o),i.invalidate(),await r({to:a?.startsWith(`/`)?a:`/`})}})},[e,t,n,r,a,i,o])}}async function La(e){let{data:t}=await s.get(`/Cluster/${e}`);return t}function Ra(e,t){return P({queryKey:[e],queryFn:()=>La(e),retry:!1,staleTime:1900,enabled:!!e,refetchInterval:t?t===!0?1e4:t:void 0})}var za=S({error:`Please enter a valid email address.`}).toLowerCase().trim(),Ba=C().nonempty({error:`Please enter your password.`}),Va=C().nonempty({error:`Please enter a username.`}),Ha=E({username:Va,password:Ba}),Ua=E({email:za,password:Ba});function Wa({entityId:e,instanceClient:t}){return P({queryKey:[e,`health`],queryFn:async()=>{try{return await t.get(`/health`),!0}catch{return!1}},retry:2,refetchInterval:5e3})}var Ga=[`localhost`,`127.0.0.1`],Ka=function(e){return e.MixedLoopback=`MixedLoopback`,e.InsecureCookieOutsideChromeAndFirefox=`InsecureCookieOutsideChromeAndFirefox`,e}({});function qa(e,t,n){if(!n||!t||!e)return null;let r=new URL(n).hostname,i=Ga.includes(t),a=Ga.includes(r);if(i&&a&&r!==t)return Ka.MixedLoopback;if(!i&&a){let t=e.indexOf(`Chrome`)>=0,n=e.indexOf(`Firefox`)>=0;if(!t&&!n)return Ka.InsecureCookieOutsideChromeAndFirefox}return null}function Ja(){let{clusterId:e,instanceId:t}=k({strict:!1}),{data:r}=N(Ra(e,!0)),i=(0,B.useMemo)(()=>t&&r&&r?.instances?.find(e=>e.id===t)||void 0,[r,t]),a=(0,B.useMemo)(()=>r?.status&&ja.includes(r.status),[r?.status]),o=`instance`,s=(0,B.useMemo)(()=>r?i?(c.flagForFabricConnect(i.id,!1),n(i)):(c.flagForFabricConnect(r.id,!1),f(r)):null,[r,i]),l=R({operationsUrl:s}),u=(0,B.useMemo)(()=>s?.includes(`localhost`)||s?.includes(`127.0.0.1`),[s]),d=(0,B.useMemo)(()=>qa(navigator.userAgent,location.hostname,s),[s]),{data:p}=N(Wa(l)),m=j({resolver:F(Ha),defaultValues:{username:``,password:``}}),{control:h,handleSubmit:_}=m,{submitForm:v,isPending:y}=Ia({cluster:r,instance:i,instanceParams:l});return!t&&r&&!r?.fqdn?(0,z.jsx)(on,{to:`../instances`,replace:!0}):a&&r?.resetPassword?(0,z.jsx)(on,{to:`/${r.organizationId}/${r.id}/finish-setup`,replace:!0}):!a&&r?.resetPassword?(0,z.jsx)(on,{to:`/${r.organizationId}/${r.id}/starting-up`,replace:!0}):(0,z.jsxs)(z.Fragment,{children:[!1,(0,z.jsx)(`div`,{className:`h-screen items-center justify-center flex`,children:(0,z.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,z.jsxs)(`h2`,{className:`text-2xl font-light`,children:[`Sign in to Harper `,`Local`]}),(0,z.jsx)(V,{...m,children:(0,z.jsxs)(`form`,{id:`auth-${o}-signin-form`,name:`auth-${o}-signin-form`,onSubmit:_(v),className:`my-4`,children:[(0,z.jsx)(U,{control:h,name:`username`,render:({field:e})=>(0,z.jsxs)(W,{className:`my-4`,children:[(0,z.jsx)(G,{children:`Username`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{autoComplete:`username`,autoFocus:!0,type:`text`,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:h,name:`password`,render:({field:e})=>(0,z.jsxs)(W,{className:`my-4`,children:[(0,z.jsx)(G,{children:`Password`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`password`,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(g,{disabled:y,type:`submit`,variant:`submit`,className:`w-full my-2 rounded-full`,children:`Sign In`}),p===!1&&(0,z.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,z.jsx)(`span`,{className:`font-medium`,children:`Warning!`}),` This `,o,` is not responding to GET`,` `,(0,z.jsxs)(`a`,{href:`${s}health`,className:`underline`,target:`_blank`,children:[s,`health`]}),` `,`checks.`,(0,z.jsxs)(`ol`,{className:`list-decimal ml-8 mt-2`,children:[(0,z.jsx)(`li`,{children:`Is the server running?`}),(0,z.jsxs)(`li`,{children:[`Have you`,` `,(0,z.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?`]}),u&&(0,z.jsxs)(`li`,{children:[`Have you allowed`,` `,(0,z.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?`]})]})]}),d===Ka.MixedLoopback&&(0,z.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,z.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.`]}),d===Ka.InsecureCookieOutsideChromeAndFirefox&&(0,z.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,z.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,z.jsxs)(`div`,{className:`p-4 mt-4 text-sm rounded-lg bg-purple-950`,role:`alert`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:`Did you know?`}),` `,`You can add this instance to your Harper account to manage it remotely.`,(0,z.jsx)(`div`,{className:`text-center pt-2`,children:(0,z.jsx)(L,{to:Na(),target:`_blank`,children:(0,z.jsx)(g,{type:`button`,variant:`positive`,children:`Connect to Harper Fabric`})})})]})]})})]})})]})}async function Ya({email:e}){let{data:t}=await s.post(`/ForgotPassword/`,{email:e});if(t)return t;throw Error(`Something went wrong`)}function Xa(){return A({mutationFn:e=>Ya(e)})}var Za=E({email:za});function Qa(){let e=Or(),{me:t}=St({strict:!1}),n=j({resolver:F(Za),defaultValues:{email:t||``}}),r=n.watch(`email`),{setFocus:i,control:a,handleSubmit:o}=n;(0,B.useEffect)(()=>{i(`email`)},[i]);let{mutate:s,isPending:c}=Xa(),l=async t=>{s(t,{onSuccess:t=>{M.success(`Success`,{description:`${t}`,action:{label:`Dismiss`,onClick:()=>M.dismiss()}}),e({to:`/sign-in`,search:{me:r}})}})};return(0,z.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,z.jsx)(`h2`,{className:`text-2xl font-light`,children:`Enter your account email`}),(0,z.jsx)(`p`,{className:`text-sm pt-1`,children:`If a matching account exists, we'll send you a password reset link.`}),(0,z.jsx)(V,{...n,children:(0,z.jsxs)(`form`,{id:`auth-forgot-password-form`,name:`auth-forgot-password-form`,onSubmit:o(l),className:`my-4`,children:[(0,z.jsx)(U,{control:a,name:`email`,render:({field:e})=>(0,z.jsxs)(W,{className:`my-2`,children:[(0,z.jsx)(G,{children:`Email`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{disabled:c,type:`email`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(g,{type:`submit`,variant:`submit`,disabled:c,className:`w-full my-2 rounded-full`,children:`Send Password Reset Email`})]})}),(0,z.jsxs)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:[(0,z.jsx)(L,{className:`text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:r},children:`Sign in to your account`}),(0,z.jsx)(L,{className:`text-sm hover:text-blue-300`,to:`/sign-up`,search:{me:r},children:`Sign up for free`})]})]})}var $a=async({token:e,password:t})=>{let{data:n}=await s.put(`/ResetPassword/`,{token:e,newPassword:t});return n};function eo(){return A({mutationFn:e=>$a(e)})}var to=E({password:Ba.min(8,{error:`Password must be at least 8 characters long.`}).max(50,{error:`Password cannot be longer than 50 characters.`}),confirmPassword:C()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});function no(){let{token:e}=St({strict:!1}),t=Or();(0,B.useEffect)(()=>{e||t({to:`/sign-in`})},[e,t]);let n=j({resolver:F(to),defaultValues:{password:``,confirmPassword:``}}),{setFocus:r,control:i,handleSubmit:a}=n;(0,B.useEffect)(()=>{r(`password`)},[r]);let{mutate:o,isPending:s}=eo(),c=(0,B.useCallback)(async n=>{o({token:e,password:n.password},{onSuccess:()=>{M.success(`Success`,{description:`Your password has been reset successfully.`,action:{label:`Dismiss`,onClick:()=>M.dismiss()}}),t({to:`/sign-in`})}})},[t,o,e]);return(0,z.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,z.jsx)(`h2`,{className:`text-2xl font-light`,children:`Reset Password`}),(0,z.jsx)(V,{...n,children:(0,z.jsxs)(`form`,{id:`auth-reset-password-form`,name:`auth-reset-password-form`,className:`my-4`,onSubmit:a(c),children:[(0,z.jsx)(U,{control:i,name:`password`,render:({field:e})=>(0,z.jsxs)(W,{className:`my-2`,children:[(0,z.jsx)(G,{children:`New Password`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{disabled:s,type:`password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:i,name:`confirmPassword`,render:({field:e})=>(0,z.jsxs)(W,{className:`my-2`,children:[(0,z.jsx)(G,{children:`Confirm Password`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{disabled:s,type:`password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(g,{variant:`submit`,type:`submit`,disabled:s,className:`w-full my-2 rounded-full`,children:`Submit New Password`})]})})]})}function ro({text:e,disabled:t,onClick:n}){return(0,z.jsx)(`a`,{href:`/oauth/github/login?redirect=%2F%23%2Fcheck-oauth`,onClick:n,children:(0,z.jsxs)(`button`,{className:x(`github-signin-btn`,t&&`opacity-50`),type:`button`,children:[(0,z.jsx)(`img`,{src:`/github/GitHub_Invertocat_White.svg`,alt:`GitHub Logo`,className:`github-icon`}),e]})})}function io({text:e,disabled:t,onClick:n}){return(0,z.jsx)(`a`,{href:`/oauth/google/login?redirect=%2F%23%2Fcheck-oauth`,onClick:n,children:(0,z.jsxs)(`button`,{className:x(`gsi-material-button`,t&&`opacity-50`),type:`button`,children:[(0,z.jsx)(`div`,{className:`gsi-material-button-state`}),(0,z.jsxs)(`div`,{className:`gsi-material-button-content-wrapper`,children:[(0,z.jsx)(`div`,{className:`gsi-material-button-icon`,children:(0,z.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,z.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,z.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,z.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,z.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,z.jsx)(`path`,{fill:`none`,d:`M0 0h48v48H0z`})]})}),(0,z.jsx)(`span`,{className:`gsi-material-button-contents`,children:e}),(0,z.jsx)(`span`,{className:`hidden`,children:e})]})]})})}function ao(){let e=Or(),t=it(),n=Et(),{redirect:r}=St({strict:!1}),{mutate:i,isPending:a}=oo();return{isPending:a,submitForm:(0,B.useCallback)(a=>{i(a,{onSuccess:async i=>{c.setUserForEntity(m,i);let a=Ci(i);Mi(i);let o=ga(i.email);pa?.identify?.({username:i.email,type:`email`,...o?{company:o}:{}}),await t.invalidateQueries({queryKey:l,refetchType:`none`}),n.invalidate(),await e({to:r?.startsWith(`/`)?r:a})}})},[e,t,r,n,i])}}function oo(){return A({mutationFn:e=>so(e)})}async function so({email:e,password:t}){let{data:n}=await s.post(`/Login/`,{email:e,password:t});if(n)return n;throw Error(`Something went wrong`)}function co(){let{me:e}=St({strict:!1}),t=j({resolver:F(Ua),defaultValues:{email:e||``,password:``}}),{handleSubmit:n,control:r}=t,i=t.watch(`email`),{submitForm:a,isPending:o}=ao();return(0,z.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,z.jsx)(`h2`,{className:`text-2xl font-light`,children:`Sign in to Harper Fabric`}),(0,z.jsx)(V,{...t,children:(0,z.jsxs)(`form`,{id:`auth-signin-form`,name:`auth-signin-form`,onSubmit:n(a),className:`my-4`,children:[(0,z.jsx)(U,{control:r,name:`email`,render:({field:e})=>(0,z.jsxs)(W,{className:`my-4`,children:[(0,z.jsx)(G,{children:`Email`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`email`,autoFocus:!0,autoComplete:`email`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:r,name:`password`,render:({field:e})=>(0,z.jsxs)(W,{className:`my-4`,children:[(0,z.jsx)(G,{children:`Password`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`password`,autoComplete:`current-password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(g,{type:`submit`,variant:`submit`,className:`w-full my-2 rounded-full`,disabled:o,children:`Sign In`}),(0,z.jsxs)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:[(0,z.jsx)(L,{className:`text-sm hover:text-blue-300`,to:`/sign-up`,search:{me:i},children:`Sign up for free`}),(0,z.jsx)(L,{className:`text-sm hover:text-blue-300`,to:`/forgot-password`,search:{me:i},children:`Forgot password?`})]})]})}),(0,z.jsx)(`hr`,{className:`border-gray-600 my-6`}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(io,{text:`Sign in with Google`}),(0,z.jsx)(ro,{text:`Sign in with GitHub`})]})]})}var lo=/^[a-zA-ZàáâäãåąčćęèéêëėįìíîïłńòóôöõøùúûüųūÿýżźñçčšžæÀÁÂÄÃÅĄĆČĖĘÈÉÊËÌÍÎÏĮŁŃÒÓÔÖÕØÙÚÛÜŲŪŸÝŻŹÑßÇŒÆČŠŽ∂ð ,'-]+$/u;async function uo(e){let{data:t}=await s.post(`/User/`,e);if(t)return t;throw Error(`Something went wrong`)}function fo(){return A({mutationFn:e=>uo(e)})}var po=E({email:za.max(80,{error:`Email cannot be longer than 80 characters.`}),firstname:C().trim().min(2,{error:`Please enter your first name.`}).regex(lo,{error:`First name can only contain letters, spaces, and hyphens.`}).max(40,{error:`First name cannot be longer than 40 characters.`}),lastname:C().trim().min(2,{error:`Please enter your last name.`}).regex(lo,{error:`Last name can only contain letters, spaces, and hyphens.`}).max(80,{error:`Last name cannot be longer than 80 characters.`}),password:Ba.min(8,{error:`Password must be at least 8 characters long.`}),confirmPassword:C(),acceptTerms:T().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 mo(){let e=Or(),{email:t,me:n}=St({strict:!1}),[r,i]=(0,B.useState)(!1),a=j({resolver:F(po),defaultValues:{firstname:``,lastname:``,email:n||t||``,password:``,confirmPassword:``,acceptTerms:!1}}),o=a.watch(`email`),s=a.watch(`acceptTerms`),{setFocus:c,control:l,handleSubmit:u}=a;(0,B.useEffect)(()=>{c(`firstname`)},[c]);let{mutate:d}=fo(),f=(0,B.useCallback)(async t=>{let{confirmPassword:n,acceptTerms:r,...i}=t;d(i,{onSuccess:()=>{let t=ga(i.email);pa?.identify?.({username:i.email,type:`email`,firstname:i.firstname,lastname:i.lastname,...t?{company:t}:{}}),e({to:`/verifying?email=`+encodeURIComponent(i.email)})}})},[e,d]),p=(0,B.useCallback)(e=>{if(!s)return i(!0),setTimeout(()=>i(!1),1e3),e.preventDefault(),!1},[s]),m=(0,z.jsx)(U,{control:l,name:`acceptTerms`,render:({field:e})=>(0,z.jsxs)(W,{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,z.jsx)(H,{children:(0,z.jsx)(q,{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,z.jsxs)(`div`,{className:`space-y-1 leading-none`,children:[(0,z.jsxs)(G,{className:`text-xs font-normal`,children:[`I accept the`,` `,(0,z.jsx)(`a`,{href:`https://www.harper.fast/resources/privacy-policy`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,children:`Privacy Policy`}),` `,`and`,` `,(0,z.jsx)(`a`,{href:`https://www.harper.fast/resources/paas-terms-of-service`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-blue-300`,children:`Terms of Service`})]}),(0,z.jsx)(K,{})]})]})});return(0,z.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,z.jsx)(`h2`,{className:`text-2xl font-light`,children:`Sign up for Harper Fabric`}),(0,z.jsxs)(V,{...a,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 my-6`,children:[m,(0,z.jsx)(io,{text:`Sign up with Google`,disabled:!s,onClick:p}),(0,z.jsx)(ro,{text:`Sign up with GitHub`,disabled:!s,onClick:p})]}),(0,z.jsx)(`hr`,{className:`border-gray-600`}),(0,z.jsxs)(`form`,{id:`auth-signup-form`,name:`auth-signup-form`,onSubmit:u(f),className:`grid gap-4 my-4`,children:[(0,z.jsx)(U,{control:l,name:`firstname`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{className:`pb-1`,children:`First Name`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`text`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,autoCapitalize:`words`,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:l,name:`lastname`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{className:`pb-1`,children:`Last Name`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`text`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,autoCapitalize:`words`,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:l,name:`email`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{className:`pb-1`,children:`Email`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`email`,readOnly:!!t,disabled:!!t,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,autoComplete:`email`,autoCapitalize:`none`,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:l,name:`password`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{className:`pb-1`,children:`Password`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`password`,autoComplete:`new-password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:l,name:`confirmPassword`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{className:`pb-1`,children:`Confirm Password`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`password`,autoComplete:`new-password`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,z.jsx)(K,{})]})}),m,(0,z.jsx)(g,{type:`submit`,variant:`submit`,className:`w-full rounded-full my-4`,children:`Sign Up For Free`})]})]}),(0,z.jsx)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:(0,z.jsx)(L,{className:`m-auto text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:o},children:`Already have an account? Sign in instead.`})})]})}var ho=async({email:e})=>{let{data:t}=await s.post(`/ResendVerificationEmail/`,{email:e});return t};function go(){return A({mutationFn:e=>ho(e)})}var _o=async e=>{let{data:t}=await s.put(`/VerifyEmail/`,{token:e.toString()});return t};function vo(){return A({mutationFn:e=>_o(e)})}var yo=E({email:za});function bo(){let e=Or(),{mutate:t,isPending:n}=go(),r=j({resolver:F(yo),defaultValues:{email:``}}),i=r.watch(`email`),{setFocus:a,control:o,handleSubmit:s}=r;(0,B.useEffect)(()=>{a(`email`)},[a]);let c=(0,B.useCallback)(async n=>{t(n,{onSuccess:t=>{M.success(`Success`,{description:`${t}`,action:{label:`Dismiss`,onClick:()=>M.dismiss()}}),e({to:`/sign-in`,search:{me:i}})}})},[i,e,t]);return(0,z.jsxs)(V,{...r,children:[(0,z.jsx)(`p`,{className:`text-sm py-2`,children:`Please Enter an Email`}),(0,z.jsxs)(`form`,{id:`auth-verify-email-form`,name:`auth-verify-email-form`,onSubmit:s(c),className:`my-4`,children:[(0,z.jsx)(U,{control:o,name:`email`,render:({field:e})=>(0,z.jsxs)(W,{className:`my-2`,children:[(0,z.jsx)(G,{children:`Email`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{disabled:n,type:`email`,className:`bg-purple-400 border-purple-400 dark:bg-black dark:border-black`,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(g,{type:`submit`,variant:`submit`,disabled:n,className:`w-full my-2 rounded-full`,children:`Send Verification Email`})]})]})}function xo(){let{token:e}=St({strict:!1}),t=Or(),{mutate:n,isPending:r}=vo(),i=(0,B.useCallback)(e=>{n(e,{onSuccess:()=>{M.success(`Success`,{description:`Email verified successfully`,action:{label:`Dismiss`,onClick:()=>M.dismiss()}}),t({to:`/sign-in`})}})},[n,t]);return(0,B.useEffect)(()=>{e&&i(e)},[i,e]),(0,z.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,z.jsx)(`h1`,{className:`text-3xl font-light`,children:`Verify Email`}),r?(0,z.jsx)(`p`,{className:`text-sm pt-1`,children:`Verifying email...`}):(0,z.jsx)(bo,{})]})}function So(){let{email:e}=St({strict:!1}),{mutate:t,isPending:n}=go(),r=(0,B.useCallback)(n=>(n.preventDefault(),e&&t({email:e},{onSuccess:e=>{M.success(`Code Sent`,{description:`${e}`,action:{label:`Dismiss`,onClick:()=>M.dismiss()}})}}),!1),[e,t]);return(0,z.jsxs)(`div`,{className:`text-white w-lg flex flex-col gap-4`,children:[(0,z.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Check your email!`]}),(0,z.jsxs)(`p`,{children:[`Your account has been created! You should receive an email with a link to `,(0,z.jsx)(`strong`,{children:`[Verify My Email]`}),`!`]}),(0,z.jsxs)(`p`,{children:[`From: `,(0,z.jsx)(`strong`,{children:`harper@notifications.harperfabric.com`})]}),(0,z.jsxs)(`p`,{children:[`To: `,(0,z.jsx)(`strong`,{children:e||`your email`})]}),(0,z.jsx)(`p`,{children:`Can you click it? Then we can carry on to more fun things!`}),(0,z.jsxs)(`div`,{className:`underline flex gap-4`,children:[(0,z.jsx)(L,{className:`text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:e},children:`I did it, let me sign in!`}),(0,z.jsx)(L,{className:`text-sm opacity-50 hover:text-blue-300`,to:void 0,onClick:r,disabled:n,children:`Send me another code, please.`})]})]})}var Co=I({getParentRoute:()=>Pi,id:`_authLayout`,component:fa}),wo=I({getParentRoute:()=>Co,path:`sign-in`,component:co,beforeLoad:({context:e,location:t})=>{let n=e.authentication[m]?.user;if(n){let e=t?.search,r=Ci(n);throw Te({to:e?.redirect?.startsWith(`/`)?e.redirect:r})}}}),To=I({getParentRoute:()=>Pi,path:`sign-in`,component:Ja,beforeLoad:({context:e,location:t})=>{if(e.authentication.OverallAppSignIn?.user){let e=t?.search;throw Te({to:e?.redirect?.startsWith(`/`)?e.redirect:`/`})}}}),Eo=I({getParentRoute:()=>Co,path:`sign-up`,component:mo}),Do=I({getParentRoute:()=>Co,path:`forgot-password`,component:Qa}),Oo=I({getParentRoute:()=>Co,path:`verify-email`,component:xo}),ko=I({getParentRoute:()=>Co,path:`verifying`,component:So}),Ao=I({getParentRoute:()=>Co,path:`check-oauth`,component:va}),jo=I({getParentRoute:()=>Co,path:`reset-password`,component:no});Co.addChildren([wo,Eo,Ao,Do,Oo,ko,jo]);var Mo=[To];function No({children:e}){return(0,z.jsx)(`nav`,{className:`fixed top-20 w-full h-12 z-39 py-2 px-4 md:px-12 bg-grey-700`,children:(0,z.jsxs)(`div`,{className:`flex items-center h-full space-x-2`,children:[(0,z.jsx)(Ea,{}),e]})})}function Po(e){if(Ro(e)||zo(e))return`warning`;if(Fo(e))return`success`;switch(e){case`STOPPED`:return`secondary`;case`TERMINATING`:case`TERMINATED`:case`FAILED`:case`REMOVED`:case`ERROR`:return`destructive`;default:return`default`}}function Fo(e){switch(e){case`RUNNING`:case`UPDATED`:return!0;default:return!1}}function Io(e){switch(e){case`FAILED`:return!0;default:return!1}}function Lo(e){switch(e){case`TERMINATED`:return!0;default:return!1}}function Ro(e){switch(e){case`CLONE_PENDING`:return!0;default:return!1}}function zo(e){switch(e){case`PROVISIONING`:case`CLONING`:case`CLONE_READY`:case`UPDATING_HDB_NODES`:case`UPDATING`:return!0;default:return!1}}function J({...e}){return(0,z.jsx)(zt,{"data-slot":`dialog`,...e})}function Bo({...e}){return(0,z.jsx)(Ye,{"data-slot":`dialog-trigger`,...e})}function Vo({...e}){return(0,z.jsx)(jt,{"data-slot":`dialog-portal`,...e})}function Ho({className:e,...t}){return(0,z.jsx)(ze,{"data-slot":`dialog-overlay`,className:d(`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black-dark/90`,e),...t})}function Y({className:e,children:t,...n}){return(0,z.jsxs)(Vo,{"data-slot":`dialog-portal`,children:[(0,z.jsx)(Ho,{}),(0,z.jsxs)(he,{"data-slot":`dialog-content`,className:d(`bg-black 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 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] lg:max-w-2xl max-h-screen overflow-y-auto translate-x-[-50%] translate-y-[-50%] gap-4 rounded-md p-6 shadow-lg duration-200`,e),...n,children:[t,(0,z.jsxs)(Fr,{className:`ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,z.jsx)(On,{className:`text-white`}),(0,z.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function Uo({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`dialog-header`,className:d(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function X({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`dialog-footer`,className:d(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...t})}function Z({className:e,...t}){return(0,z.jsx)(Fe,{"data-slot":`dialog-title`,className:d(`text-lg leading-none text-white font-semibold`,e),...t})}function Wo({className:e,...t}){return(0,z.jsx)(Ft,{"data-slot":`dialog-description`,className:d(`text-muted-foreground text-sm`,e),...t})}function Go({typeOfThingBeingDeleted:e,nameOfThingBeingDeleted:t,isModalOpen:n,hideDataLossWarning:r,setIsModalOpen:i,deletionConfirmed:a,deletionPending:o,trigger:s,presentParticiple:c=`Deleting`,transitiveVerb:l=`Delete`}){return(0,z.jsxs)(J,{open:n,onOpenChange:i,children:[s&&(0,z.jsx)(Bo,{asChild:!0,children:s}),(0,z.jsxs)(Y,{className:`sm:max-w-[750px]`,children:[(0,z.jsxs)(Uo,{children:[(0,z.jsxs)(Z,{children:[`Are you sure you want to `,l.toLowerCase(),` this `,e,`?`]}),(0,z.jsx)(Wo,{children:`This action cannot be undone.`})]}),!r&&(0,z.jsxs)(`div`,{className:`p-3 my-5 text-white rounded-md bg-amber-600`,children:[(0,z.jsxs)(`p`,{className:`flex space-x-1 font-semibold align-baseline`,children:[(0,z.jsx)(ln,{className:`inline-block size-5`}),` `,(0,z.jsx)(`span`,{children:`Warning`})]}),(0,z.jsxs)(`p`,{className:`pt-2 text-base`,children:[`By `,c.toLowerCase(),` `,e,` `,(0,z.jsx)(`span`,{className:`font-semibold`,children:t}),` `,`you will lose the data stored in it permanently.`]})]}),(0,z.jsx)(X,{children:(0,z.jsxs)(`div`,{className:`flex justify-center space-x-5`,children:[(0,z.jsxs)(g,{type:`button`,className:`rounded-full`,onClick:()=>i(!1),children:[(0,z.jsx)(Qn,{}),` Cancel`]}),(0,z.jsxs)(g,{variant:`destructive`,className:`rounded-full`,onClick:a,disabled:o,children:[(0,z.jsx)(Ar,{}),` `,l]})]})})]})]})}function Ko({className:e,variant:t,asChild:n=!1,...r}){return(0,z.jsx)(n?Vn:`span`,{"data-slot":`badge`,className:d(Hi({variant:t}),e),...r})}function qo({...e}){return(0,z.jsx)(Ue,{"data-slot":`dropdown-menu`,...e})}function Jo({...e}){return(0,z.jsx)(bt,{"data-slot":`dropdown-menu-trigger`,...e})}function Yo({className:e,sideOffset:t=4,...n}){return(0,z.jsx)(je,{children:(0,z.jsx)(Ln,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:d(`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-grey-700 p-1 shadow-md`,e),...n})})}function Xo({className:e,inset:t,variant:n=`default`,...r}){return(0,z.jsx)(nt,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:d(`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 Zo({className:e,children:t,checked:n,...r}){return(0,z.jsxs)(pe,{"data-slot":`dropdown-menu-checkbox-item`,className:d(`focus:bg-primary 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,z.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,z.jsx)(ot,{children:(0,z.jsx)(Pe,{className:`size-4`})})}),t]})}function Qo({className:e,inset:t,...n}){return(0,z.jsx)(mt,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:d(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function $o({className:e,...t}){return(0,z.jsx)(Qe,{"data-slot":`dropdown-menu-separator`,className:d(`bg-grey-700 -mx-1 my-1 h-px`,e),...t})}function es(e){return!!e?.plans?.[0]?.planId?.startsWith(`self-hosted`)}function ts({cluster:e}){let t=ci(e.id),{view:n,update:r}=Zi(e.organizationId,e.id),i=!c.checkForFabricConnect(e.id)&&!!t.user;if(n){if(!e.fqdn)return(0,z.jsx)(L,{to:`/${e.organizationId}/${e.id}/instances`,className:`text-sm text-nowrap`,"aria-label":`View ${e.name}`,title:`View ${e.name}`,children:(0,z.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Instances `,(0,z.jsx)(nn,{className:`inline-block`})]})});if(e.resetPassword)return r?(0,z.jsx)(L,{to:`/${e.organizationId}/${e.id}/finish-setup`,className:`text-sm text-nowrap`,"aria-label":`Set Password on ${e.name}`,title:`Set Password on ${e.name}`,children:(0,z.jsxs)(g,{variant:`positive`,className:`py-2 hover:border-b-2 animate-glow-pulse`,children:[`Finish Setup `,(0,z.jsx)(nn,{className:`inline-block`})]})}):(0,z.jsx)(`span`,{className:`py-2 text-nowrap`,children:`Pending Owner Setup`});if(!t.isLoading)return i?(0,z.jsx)(L,{to:`/${e.organizationId}/${e.id}/`,className:`text-sm text-nowrap`,"aria-label":`View ${e.name}`,title:`View ${e.name}`,children:(0,z.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Direct Connect `,(0,z.jsx)(nn,{className:`inline-block`})]})}):r&&!es(e)?(0,z.jsx)(L,{to:`/${e.organizationId}/${e.id}/`,className:`text-sm text-nowrap`,"aria-label":`Connect to ${e.name}`,title:`Connect to ${e.name}`,children:(0,z.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Fabric Connect `,(0,z.jsx)(nn,{className:`inline-block`})]})}):(0,z.jsx)(L,{to:`/${e.organizationId}/${e.id}/sign-in`,className:`text-sm text-nowrap`,"aria-label":`Sign In to ${e.name}`,title:`Sign In to ${e.name}`,children:(0,z.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Direct Sign In `,(0,z.jsx)(nn,{className:`inline-block`})]})})}}function ns(e,t){let n=[];if(e)for(let r of e)n.push(r[t]);return n}function rs({cluster:e,forceProgressBarVisible:t}){let[n,r]=(0,B.useState)(t||!1),{data:i}=N(Ra(n&&e.id,2e3));(0,B.useEffect)(function(){(Ro(e.status)||zo(e.status))&&r(!0)},[n,e.status,i?.instances]);let a=(0,B.useMemo)(()=>{let e=ns(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||Lo(t)||(Ro(t)?(n+=1,r[t]=`${n} ${wa(t)}`):zo(t)?(a+=1,o[t]=`${a} ${wa(t)}`):Io(t)?(l+=1,u[t]=`${l} ${wa(t)}`):!i.planId||!e.includes(i.planId)?(a+=1,o.DRAINING_TRAFFIC=`${a} ${wa(`Draining Traffic`)}`):Fo(t)&&(s+=1,c[t]=`${s} ${wa(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,z.jsxs)(`div`,{className:`w-full text-center`,children:[(0,z.jsxs)(`div`,{className:`w-full h-2.5 rounded-full overflow-clip flex shadow`,children:[(0,z.jsx)(`div`,{style:{width:a.runningWidth},className:`grow bg-green/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,z.jsx)(`div`,{style:{width:a.failedWidth},className:`grow bg-red/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,z.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,z.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,z.jsx)(`div`,{className:`text-xs text-muted-foreground font-light mt-2`,children:a.text})]}):null}async function is(e){let{data:t}=await s.delete(`/Cluster/${e}`,{timeout:0});return t}function as(){return A({mutationFn:e=>is(e)})}function os(...e){return(0,B.useMemo)(()=>e.map(e=>(()=>{navigator.clipboard.writeText(e),M.info(`Copied to clipboard!`,{icon:(0,z.jsx)(yt,{}),duration:1e3})})),e)}function ss(e){try{return e===`null`||e===`undefined`||e==null?null:JSON.parse(e)}catch(e){return console.error(`safeParse failed to parse value, returning null instead`,e),null}}function cs(e,t){return ss(localStorage.getItem(e))??t}function ls(e,t){t==null?localStorage.removeItem(e):localStorage.setItem(e,JSON.stringify(t))}function us(e,t){let n=(0,B.useState)(cs(e,t)),[r]=n;return(0,B.useEffect)(()=>ls(e,r),[e,r]),n}var ds=function(e){return e.ApplicationChatPosition=`ApplicationChatPosition`,e.ApplicationChatWidth=`ApplicationChatWidth`,e.ChatAlwaysApprovedTools=`ChatAlwaysApprovedTools`,e.SavedClusterState=`SavedClusterState`,e}({});function fs({cluster:e}){let t=Et(),n=it(),i=(0,B.useMemo)(()=>f(e),[e]),a=mi({operationsUrl:i}),o=ci(e.id),[,s]=us(ds.SavedClusterState,null),{view:l,update:u,remove:d,create:p}=Zi(e.organizationId,e.id),{mutate:m,isPending:h}=as(),[g,_]=(0,B.useState)(!1),[v,y]=(0,B.useState)(!1),b=(0,B.useMemo)(()=>e.status&&ja.includes(e.status),[e.status]),x=es(e),S=c.checkForFabricConnect(e.id),ee=!S&&!!o.user,te=(0,B.useMemo)(()=>e.status&&Ma.includes(e.status),[e.status]),C=(0,B.useMemo)(()=>e.status&&Io(e.status),[e.status]),ne=(0,B.useCallback)(async()=>{_(!0);let t=await La(e.id).catch(e=>(console.error(`Failed to lookup cluster details, proceeding without checking instances.`,e),null));if(await r({entityId:e.id,instanceClient:a}),t?.instances?.length)for(let e of t.instances)c.setUserForEntity(e,null);c.setUserForEntity(e,null)},[e,a]),re=(0,B.useCallback)(()=>{s(e),t.navigate({to:`/${e.organizationId}/new-cluster`})},[e,t,s]),w=(0,B.useCallback)(()=>y(!0),[]),T=(0,B.useCallback)(()=>{let r=e.organizationId;m(e.id,{onSuccess:async()=>{await n.invalidateQueries({queryKey:[r],refetchType:`active`}),await t.invalidate(),M.success(`Success`,{description:x?`Cluster successfully removed.`:`Cluster successfully terminated.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>M.dismiss()}}),y(!1)},onError:()=>{M.error(`Error`,{description:x?`Failed to remove cluster: ${e.name}`:`Failed to terminate cluster: ${e.name}.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>M.dismiss()}}),y(!1)}})},[t,e.organizationId,e.id,e.name,m,x,n]),ie=e.domains?.[0]?.domain||e.fqdn,[E,ae]=os(`${ie}`,`https://${ie}`),oe=[b&&u&&!o.isLoading&&(!ee||S)&&(0,z.jsx)(L,{to:`${e.id}/sign-in`,disabled:g,children:(0,z.jsxs)(Xo,{children:[(0,z.jsx)(Nn,{className:`text-green`}),` Direct Sign In`]})},`sign-in`),b&&u&&(0,z.jsx)(L,{to:`${e.id}/edit`,disabled:g,children:(0,z.jsxs)(Xo,{children:[(0,z.jsx)(st,{className:`text-purple-600`}),` `,x?`Edit`:`Edit Scaling`]})},`edit`),b&&u&&!x&&(0,z.jsx)(L,{to:`${e.id}/edit/version`,disabled:g,children:(0,z.jsxs)(Xo,{children:[(0,z.jsx)(hn,{className:`text-fuchsia-300`}),` Edit Version`]})},`edit-version`),b&&u&&!1,b&&l&&(0,z.jsx)(L,{to:`${e.id}/instances`,disabled:g,children:(0,z.jsxs)(Xo,{children:[(0,z.jsx)(me,{className:`text-orange-300`}),` Instances`]})},`instances`),b&&l&&e.fqdn&&(0,z.jsx)($o,{},`copy-separator`),b&&l&&e.fqdn&&(0,z.jsxs)(Xo,{onClick:E,disabled:g,children:[(0,z.jsx)(He,{}),` Copy Host Name`]},`copy-host-name`),b&&l&&e.fqdn&&(0,z.jsxs)(Xo,{onClick:ae,disabled:g,children:[(0,z.jsx)(He,{}),` Copy API URL`]},`copy-api-url`),b&&l&&!!i&&!o.isLoading&&ee&&(0,z.jsx)(Xo,{onClick:ne,disabled:g,children:`Direct Sign Out`},`direct-sign-out`),C&&p&&(0,z.jsx)(Xo,{className:`focus:bg-green/70 focus:text-white`,onClick:re,children:`Try Again`},`try-again`),!te&&d&&b&&(0,z.jsx)($o,{},`remove-separator`),!te&&d&&(0,z.jsxs)(Xo,{className:`focus:bg-red/70 focus:text-white`,onClick:w,children:[(0,z.jsx)(Ar,{className:`text-red-300`}),` `,x?`Remove`:`Terminate`]},`remove`)].filter(ui);return(0,z.jsxs)(hi,{className:`relative h-full justify-between`,children:[(0,z.jsxs)(pi,{children:[(0,z.jsxs)(di,{className:`flex items-center justify-between`,children:[ie?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`truncate max-w-48`,children:ie}),(0,z.jsx)(O,{onClick:E,size:16,className:`cursor-pointer`}),(0,z.jsx)(`span`,{className:`grow`})]}):(0,z.jsx)(`span`,{children:`Self-Hosted`}),!te&&(0,z.jsxs)(qo,{children:[(0,z.jsx)(Jo,{children:(0,z.jsx)(Ee,{"aria-label":`Cluster options`})}),(0,z.jsx)(Yo,{children:[...oe]})]})]}),(0,z.jsx)(vi,{children:(0,z.jsx)(`h2`,{children:e.name})})]}),(0,z.jsxs)(gi,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsx)(rs,{cluster:e}),b&&l&&(0,z.jsx)(ts,{cluster:e}),C&&e.status&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Ko,{variant:Po(e.status),children:wa(e.status)}),(0,z.jsx)(`span`,{className:`text-xs`,children:`Click "..." to choose how to proceed.`})]})]}),(0,z.jsx)(Go,{typeOfThingBeingDeleted:`cluster`,transitiveVerb:x?`Remove`:`Terminate`,presentParticiple:x?`Removing`:`Terminating`,nameOfThingBeingDeleted:e.name,isModalOpen:v,hideDataLossWarning:x,setIsModalOpen:e=>y(e),deletionConfirmed:T,deletionPending:h})]})}function ps({overEmail:e}){return(0,z.jsx)(`a`,{href:e?`mailto:support@harperdb.io`:`https://discord.com/channels/1415002037439041710/1415002038286286994`,target:`_blank`,rel:`noreferrer`,className:`underline`,children:`Contact us`})}function ms({className:e,text:t,centered:n,...r}){return(0,z.jsxs)(`div`,{className:`text-white h-full w-full ${e||``} ${n?`flex flex-col items-center justify-center`:``}`,...r,children:[(0,z.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`100px`,height:`100px`,alt:`HDB Dog Logo Loading`,className:`inline-block`}),(0,z.jsx)(`p`,{className:`pt-4`,children:t||`Loading...`})]})}function hs({children:e,className:t}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(No,{}),(0,z.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] relative ${t??``}`,children:e})]})}async function gs(e){let{data:t}=await s.get(`/Plan/`,{params:{organizationId:e}});return t}function _s(e){return P({queryKey:[e,`instancePlan`],queryFn:()=>gs(e),retry:!1})}async function vs(){let{data:e}=await s.get(`/HarperVersions/`);return e}function ys(){return P({queryKey:[`HarperVersions`],queryFn:vs,staleTime:6e4,retry:!1})}async function bs({organizationId:e,availableHosts:t}={}){let{data:n}=await s.get(`/Region/`,{params:{availableHosts:t,organizationId:e}});return n}function xs({organizationId:e,availableHosts:t}={}){return P({queryKey:[e,`regionLocations`,t],queryFn:()=>bs({organizationId:e,availableHosts:t}),retry:!1})}function Ss(e){return(t,n)=>t[e]===n[e]?0:t[e]>n[e]?1:-1}function Cs(e){let t=e.split(`.`).map(Number);return(t[0]<<24|t[1]<<16|t[2]<<8|t[3])>>>0}function ws(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):!1}function Ts(e,t){return e.instanceFqdn===t.instanceFqdn?e.operationsApiPort-t.operationsApiPort:ws(e.instanceFqdn)&&ws(t.instanceFqdn)?Cs(e.instanceFqdn)-Cs(t.instanceFqdn):e.instanceFqdn>t.instanceFqdn?1:-1}function Es(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 Ds(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 Os(e,t,n){let r=Es(e,t),i={};for(let e in r)i[e]=Ds(r[e],n);return i}function ks(e,t){let n=js(e),r=js(t);return!n||!r?!1:Ps(r,n)>=0}function As(e,t){let n=js(e),r=js(t);return!n&&!r?0:n?r?Ps(n,r):1:-1}function js(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=Ms(a[0]),s=Ms(a[1]??`0`),c=Ms(a[2]??`0`);return o==null||s==null||c==null?null:{major:o,minor:s,patch:c,pre:i?i.split(`.`).map(e=>Ns(e)?Number(e):e):[]}}function Ms(e){return e==null||e===``||!/^\d+$/.test(e)?null:Number(e)}function Ns(e){return/^\d+$/.test(e)}function Ps(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}function Fs({width:e,className:t,animated:n,placeholder:r}){return(0,z.jsxs)(`div`,{className:x(`w-full bg-gray-200 rounded-full relative`,r?`h-6`:`h-2.5`),children:[r&&(0,z.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,z.jsx)(`div`,{className:x(`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 Is({duration:e,message:t,lateMessage:n}){let r=(0,B.useRef)(0),i=(0,B.useRef)(0),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(`5%`),l=(0,B.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,B.useEffect)(()=>(r.current=requestAnimationFrame(l),()=>cancelAnimationFrame(r.current)),[l]),(0,z.jsxs)(z.Fragment,{children:[a?n:t,(0,z.jsx)(Fs,{width:s,animated:!1})]})}async function Ls(e){let{data:t}=await s.post(`/Cluster/`,e,{timeout:0});return t}function Rs(){return A({mutationFn:e=>Ls(e)})}async function zs(e){let{id:t,...n}=e,{data:r}=await s.put(`/Cluster/${t}`,n,{timeout:0});return r}function Bs(){return A({mutationFn:e=>zs(e)})}async function Vs(e){let{data:t}=await s.get(`/Organization/${e}`);return t}function Hs(e){return P({queryKey:[e],queryFn:()=>Vs(e),retry:!1,refetchInterval:1e4})}var Us=`ENTERPRISE`;function Ws(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 Gs(e,t,n=`-`){let r=t.split(n)[0];return e.findIndex(e=>e.startsWith(r))!==-1}function Ks(e){return e.replace(/[^a-zA-Z0-9]/g,`-`).replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase().replace(/-+/g,`-`).replace(/^-+|-+$/g,``)}async function qs(e){await s.put(`/Payment/`,e)}function Js(){return A({mutationFn:e=>qs(e)})}function Ys(e){let{mutate:t}=Js();return(0,B.useCallback)((n,r)=>{t({paymentMethodId:typeof n==`string`?n:n.id,organizationId:e},{onSuccess:()=>{M.success(`Success! Your payment method has been saved.`),r(!0)},onError:()=>{M.error(`Failed to process payment method details. Please try another payment method.`),r(!1)}})},[t,e])}var Xs=(0,B.createContext)(null);function Zs(){return(0,B.useContext)(Xs)}function Qs({hasExistingBilling:e,onPaymentAdded:t,onSaveStateForBillingRedirect:n}){let{organizationId:r}=k({strict:!1}),i=zn(),a=Zs(),o=ut(),[s,c]=(0,B.useState)(!1),l=Ys(r),u=(0,B.useCallback)(()=>{t(!1)},[t]);return(0,z.jsxs)(`form`,{id:`billing-add-payment-method-form`,name:`billing-add-payment-method-form`,onSubmit:(0,B.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),M.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]),className:`max-w-xl`,children:[(0,z.jsx)(Ce,{}),(0,z.jsx)(De,{options:{mode:`billing`}}),(0,z.jsxs)(`div`,{className:`mt-4 flex gap-8 items-center`,children:[(0,z.jsxs)(g,{disabled:!i||!o||s,variant:`submit`,className:`rounded-full`,children:[(0,z.jsx)(ht,{}),` Add Payment Method`]}),e&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`text-xs text-gray-600`,children:`Your existing payment method will be overwritten.`}),(0,z.jsx)(g,{variant:`defaultOutline`,type:`button`,onClick:u,children:`Cancel`})]})]})]})}async function $s(e){let{data:t}=await s.post(`/StripeAccount/`,e);return t}function ec(){return A({mutationFn:e=>$s(e)})}async function tc(e){let{data:t}=await s.post(`/Payment/`,{organizationId:e.organizationId});return t}function nc(){return A({mutationFn:e=>tc(e)})}function rc(e){let{enabled:t,existingStripeId:n,organizationId:r}=e,{mutate:i}=ec(),{mutate:a}=nc(),[o,s]=(0,B.useState)(void 0);return(0,B.useEffect)(()=>{},[i,t,n,a,(0,B.useCallback)(e=>{s(e.clientSecret)},[]),r]),o}function ic({children:e}){let{organizationId:t}=k({strict:!1}),{data:n}=N(Hs(t)),r=rc({organizationId:t,enabled:!!n,existingStripeId:n?.stripeId});return(0,B.useMemo)(()=>({clientSecret:r||``,appearance:{theme:`night`}}),[r]),console.error(`No VITE_PUBLIC_STRIPE_KEY is configured for this environment.`),(0,z.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 ac({onPaymentAdded:e,onSaveStateForBillingRedirect:t}){let{organizationId:n}=k({strict:!1}),{data:r}=N(Hs(n)),i=r?.billing,a=i?.paymentMethod;return(0,z.jsxs)(ic,{children:[(0,z.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,z.jsx)(Qs,{hasExistingBilling:!!i,onSaveStateForBillingRedirect:t,onPaymentAdded:e})]})}var oc=function(e){return e.PASS=`pass`,e.FAIL=`fail`,e.PENDING=`pending`,e.ERROR=`error`,e}({});function sc(e){switch(e){case oc.PASS:return`success`;case oc.FAIL:case oc.ERROR:return`destructive`;case oc.PENDING:default:return`default`}}function cc(e){switch(e){case oc.PASS:return`READY`;case oc.FAIL:case oc.ERROR:case oc.PENDING:default:return e.toUpperCase()}}function lc(e,t){return`${String(e).padStart(2,`0`)}/${String(t%100).padStart(2,`0`)}`}function uc(e){let{onSaveStateForBillingRedirect:t,onReplacingPaymentMethod:n}=e??{},{organizationId:r}=k({strict:!1}),{update:i}=Yi(r),{data:a,refetch:o}=N(Hs(r)),s=a?.billing?.paymentMethod,[c,l]=(0,B.useState)(!1),u=(0,B.useCallback)(()=>{l(!c),n?.(!c)},[n,c]),d=(0,B.useCallback)(e=>{l(!1),n?.(!1),e&&o()},[n,o]);return a?.type===`ENTERPRISE`?(0,z.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,z.jsx)(ps,{}),`, we would love to talk!`]}):s&&!c?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`mt-2`,children:[s.brand?.toUpperCase()??`Card`,` ending in `,s.last4??`••••`,s.expMonth&&s.expYear?(0,z.jsxs)(z.Fragment,{children:[`(exp `,lc(s.expMonth,s.expYear),`)`]}):null,s.status?(0,z.jsxs)(z.Fragment,{children:[`—`,` `,(0,z.jsx)(Ko,{variant:sc(s.status),children:cc(s.status)})]}):null]}),i&&(0,z.jsx)(`div`,{className:`mt-2 mb-6`,children:(0,z.jsx)(g,{variant:`defaultOutline`,type:`button`,onClick:u,children:`Replace Payment Method`})})]}):i?(0,z.jsx)(ac,{onSaveStateForBillingRedirect:t,onPaymentAdded:d}):(0,z.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 Q(e){return e!==void 0&&e>0}function dc({clusterId:e,isPending:t,onGoBackToDetails:n,onSaveStateForBillingRedirect:r,onSubmit:i,organizationId:a,selectedPlan:o}){let{data:s}=N(Hs(a)),c=s?.billing,l=s?.type===Us,d=l||c?.paymentMethod?.status===oc.PASS,[f,p]=(0,B.useState)(!1),m=Q(o?.planLimits?.expirationMonths)&&o.planLimits.expirationMonths<1e3&&o.planLimits.expirationMonths,h=(0,z.jsx)(z.Fragment,{children:(0,z.jsxs)(`div`,{className:`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end mt-3 max-w-xl`,children:[(0,z.jsxs)(g,{type:`button`,variant:`defaultOutline`,className:`rounded-full`,disabled:t,onClick:n,children:[(0,z.jsx)(Qn,{}),` Back to Details`]}),(0,z.jsxs)(g,{disabled:t||!d||f,type:`submit`,variant:`submit`,className:`rounded-full`,onClick:i,children:[e?`Edit Cluster`:`Create New Cluster`,` `,(0,z.jsx)(nn,{})]})]})});if(l)return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`ul`,{className:`list-disc ml-6 max-w-lg`,children:[(0,z.jsx)(`li`,{children:`Reminder: you will be billed at your contracted rate for any additional infrastructure.`}),(0,z.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,z.jsx)(ps,{overEmail:!0}),`, we are here to help.`]})]}),h]});let _=m&&`, or ${u(m,`month`,`months`)} elapse`;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`ul`,{className:`list-disc ml-6 mb-6`,children:[(0,z.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,z.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,z.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,z.jsxs)(`li`,{children:[`When that block is used up`,_,`, you will be automatically renewed.`]}),(0,z.jsx)(`li`,{children:`While refunds are not available, we’d be happy to assist you with troubleshooting.`}),(0,z.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,z.jsx)(ps,{overEmail:!0}),`, we are here to help.`]})]}),(0,z.jsx)(`p`,{className:`text-muted-foreground text-sm mb-6`,children:`Payment method:`}),(0,z.jsx)(uc,{onSaveStateForBillingRedirect:r,onReplacingPaymentMethod:p}),h]})}var fc=/(^$|^(?: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,pc=65535,mc=C().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.`),hc=E({clusterName:C().nonempty(`Please enter a cluster name.`).max(255,`Cluster name cannot be longer than 255 characters long.`),abbreviatedName:re([ae(``),w(),mc]).optional(),fqdn:C().regex(fc,`Please enter a valid host name without the port or any path.`).optional(),version:C().optional(),deploymentDescription:C().nonempty(`Please select a deployment tier.`),performanceDescription:C().nonempty(`Please select a performance tier.`),regionPlans:oe(E({regionName:C().nonempty(`Please select a region.`),latencyDescription:C().nonempty(`Please select a latency tier.`)})).max(50,{error:`A maximum of 50 regions can be selected for each cluster. `}),instances:oe(E({secure:ie([`true`,`false`]),fqdn:C().nonempty(`Please enter the host name of your instance.`).regex(fc,`Please enter a valid host name without the port or any path.`),port:b().min(0,`Positive thinking only, please.`).max(pc,`That port number is too high.`).optional()})).max(100,{error:`A maximum of 100 instances can be added to each cluster.`}),skipToBilling:T().optional(),skipGtmWait:T().optional(),sourceClusterId:C().optional()});function gc({calculatedNames:e,disabled:t,form:n}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(U,{control:n.control,name:`abbreviatedName`,render:({field:n})=>(0,z.jsxs)(W,{className:`col-span-3`,children:[(0,z.jsx)(G,{className:`pb-1`,children:`Host Name`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{...n,type:`text`,maxLength:mc.maxLength,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:e.suggestedAbbreviatedName,disabled:t})}),(0,z.jsx)(K,{})]})}),(0,z.jsxs)(W,{className:`col-span-3 `,children:[(0,z.jsx)(G,{className:`pb-1`,children:`Full Host Name`}),(0,z.jsx)(H,{children:(0,z.jsx)(`span`,{children:e.fullHostName})}),(0,z.jsx)(K,{})]})]})}function _c({className:e}={}){return(0,z.jsx)(`div`,{className:(0,B.useMemo)(()=>x(`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])})}function vc({...e}){return(0,z.jsx)(cn,{"data-slot":`select`,...e})}function yc({...e}){return(0,z.jsx)(ir,{"data-slot":`select-group`,...e})}function bc({...e}){return(0,z.jsx)(Er,{"data-slot":`select-value`,...e})}function xc({className:e,children:t,...n}){return(0,z.jsxs)(ye,{"data-slot":`select-trigger`,className:d(`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-grey-700 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,z.jsx)(Kn,{asChild:!0,children:(0,z.jsx)(Rt,{className:`opacity-50 size-4`})})]})}function Sc({className:e,children:t,position:n=`popper`,...r}){return(0,z.jsx)(Mr,{children:(0,z.jsxs)(wn,{"data-slot":`select-content`,className:d(`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,z.jsx)(wc,{}),(0,z.jsx)(Ot,{className:d(`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,z.jsx)(Tc,{})]})})}function Cc({className:e,...t}){return(0,z.jsx)(Cr,{"data-slot":`select-label`,className:d(`px-2 py-1.5 text-sm font-medium`,e),...t})}function $({className:e,children:t,...n}){return(0,z.jsxs)(jn,{"data-slot":`select-item`,className:d(`focus:bg-grey-200 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,z.jsx)(en,{children:t}),(0,z.jsx)(`span`,{className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,z.jsx)(Dn,{children:(0,z.jsx)(Pe,{className:`size-4`})})})]})}function wc({className:e,...t}){return(0,z.jsx)(wt,{"data-slot":`select-scroll-up-button`,className:d(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,z.jsx)(At,{className:`size-4`})})}function Tc({className:e,...t}){return(0,z.jsx)(kr,{"data-slot":`select-scroll-down-button`,className:d(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,z.jsx)(Rt,{className:`size-4`})})}var Ec={Colocated:`Shared infrastructure for optimized value`,Dedicated:`Dedicated infrastructure for consistent performance`,"Self-Hosted":`Your own infrastructure`};function Dc({availableDeploymentTypes:e,disabled:t,form:n}){return(0,z.jsx)(U,{control:n.control,name:`deploymentDescription`,render:({field:r})=>(0,z.jsxs)(W,{className:`col-span-3`,children:[(0,z.jsx)(G,{className:`pb-1`,children:`Harper Deployment`}),(0,z.jsx)(B.Suspense,{fallback:(0,z.jsx)(_c,{}),children:(0,z.jsx)(H,{children:(0,z.jsxs)(vc,{...r,disabled:t,onValueChange:e=>{r.onChange(e),n.trigger()},children:[(0,z.jsx)(xc,{className:`w-full h-auto`,children:(0,z.jsx)(bc,{placeholder:`Choose Tier`})}),(0,z.jsx)(Sc,{children:(0,z.jsx)(yc,{children:e.map(e=>(0,z.jsxs)($,{value:e,children:[(0,z.jsx)(`dt`,{className:`text-left font-bold text-sm/6`,children:e}),Ec[e]&&(0,z.jsx)(`dd`,{className:`font-light`,children:Ec[e]})]},e))})})]})})}),(0,z.jsx)(K,{})]})})}function Oc({disabled:e,form:t}){return(0,z.jsx)(U,{control:t.control,name:`fqdn`,render:({field:t})=>(0,z.jsxs)(W,{className:`md:col-span-6 col-span-3`,children:[(0,z.jsx)(G,{className:`pb-1`,children:`Optional Cluster Load Balancer Host Name`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{...t,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:`example.your-company.com`,disabled:e})}),(0,z.jsx)(K,{})]})})}function kc({className:e,disabled:t,form:n}){return(0,z.jsx)(U,{control:n.control,name:`clusterName`,render:({field:n})=>(0,z.jsxs)(W,{className:e,children:[(0,z.jsx)(G,{className:`pb-1`,children:`Cluster Name`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{autoFocus:!0,type:`text`,maxLength:hc.shape.clusterName.maxLength,autoCapitalize:`words`,disabled:t,...n})}),(0,z.jsx)(K,{})]})})}function Ac({availablePerformanceDescriptions:e,form:t,selectedDeployment:n}){return(0,z.jsx)(U,{control:t.control,name:`performanceDescription`,render:({field:r})=>(0,z.jsxs)(W,{className:`col-span-3`,children:[(0,z.jsxs)(G,{className:`pb-1`,children:[n.startsWith(`Self`)?`Support`:`Performance`,` & Usage`]}),(0,z.jsx)(B.Suspense,{fallback:(0,z.jsx)(_c,{}),children:(0,z.jsx)(H,{children:(0,z.jsxs)(vc,{...r,onValueChange:e=>{r.onChange(e),t.trigger()},disabled:!e?.length,children:[(0,z.jsx)(xc,{className:`w-full h-auto`,children:(0,z.jsx)(bc,{placeholder:`Choose Tier`})}),(0,z.jsx)(Sc,{children:(0,z.jsx)(yc,{children:e.map(e=>(0,z.jsxs)($,{value:e.performanceTier,children:[(0,z.jsx)(`dt`,{className:`text-left font-bold text-sm/6`,children:e.name}),e.description&&(0,z.jsx)(`dd`,{className:`font-light`,children:e.description})]},e.name))})})]})})}),(0,z.jsx)(K,{})]})})}function jc({className:e,...t}){let{formDescriptionId:n}=ka();return(0,z.jsx)(`p`,{"data-slot":`form-description`,id:n,className:d(`text-muted-foreground text-sm`,e),...t})}function Mc({className:e,form:t}){return(0,z.jsx)(U,{control:t.control,name:`skipGtmWait`,render:({field:t})=>(0,z.jsxs)(W,{className:e,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(H,{children:(0,z.jsx)(q,{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,z.jsx)(G,{className:`cursor-pointer`,children:`Immediate upgrade and restart`})]}),(0,z.jsx)(jc,{children:`Apply changes immediately without waiting for each instance to be taken out of the load balancer (faster, but potentially less safe).`})]})})}function Nc({className:e,disabled:t,form:n,harperVersions:r}){return r?.value?.length?(0,z.jsx)(U,{control:n.control,name:`version`,render:({field:i})=>(0,z.jsxs)(W,{className:e,children:[(0,z.jsx)(G,{className:`pb-1`,children:`Harper Version`}),(0,z.jsx)(B.Suspense,{fallback:(0,z.jsx)(_c,{}),children:(0,z.jsx)(H,{children:(0,z.jsxs)(vc,{...i,disabled:t,onValueChange:e=>{i.onChange(e),n.trigger()},children:[(0,z.jsx)(xc,{className:`w-full h-auto`,children:(0,z.jsx)(bc,{placeholder:`Choose Version`})}),(0,z.jsx)(Sc,{children:(0,z.jsx)(yc,{children:r?.value.map(e=>(0,z.jsxs)($,{value:e.version,children:[e.version,` `,(0,z.jsx)(`span`,{className:`font-light opacity-50`,children:e.name})]},e.version))})})]})})}),(0,z.jsx)(K,{})]})}):null}var Pc=new RegExp(/^\d+/);function Fc(e,t){let n=parseInt(e.match(Pc)?.[0]||`0`,10),r=parseInt(t.match(Pc)?.[0]||`0`,10);return n===r?0:n>r?1:-1}var Ic=[`B`,`KB`,`MB`,`GB`,`TB`,`PB`,`EB`,`ZB`,`YB`],Lc=[`secs`,`mins`,`hrs`],Rc={bytes:1e3,secs:60};function zc(e,t,n){let r,i;switch(t){case`bytes`:r=Ic,i=Rc.bytes;break;case`secs`:r=Lc,i=Rc.secs;break;default:return e}let a=r.indexOf(n);return a===-1?e:e/i**a}function Bc(e,t){let n,r;switch(e){case`bytes`:n=Ic,r=Rc.bytes;break;case`secs`:n=Lc,r=Rc.secs;break;default:return e}let i=0;for(;t>=r&&i<n.length-1;)t/=r,i++;return n[i]}function Vc(e,t=1){let n=e*t,r=Bc(`bytes`,n),i=zc(n,`bytes`,r);return`${new Intl.NumberFormat().format(Math.round(i))} ${r}`}function Hc(e){return new Intl.NumberFormat().format(e)}var Uc=[`K`,`M`,`B`,`T`,`Qa`,`Qi`,`Sx`,`Sp`,`Oc`,`No`,`Dc`];function Wc(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<Uc.length-1);return`${Hc(Math.round(n))} ${Uc[r]}`}function Gc({selectedPlan:e,selectedRegion:t,isEnterprise:n,cloudProvider:r}){let[i,a]=(0,B.useState)(!1),o=(0,B.useCallback)(()=>{a(!i)},[i,a]),s=e?.planLimits,c=e?.resourcesPerInstance,l=r&&e?.cloudInstanceTypes?.[r],f=Q(s?.expirationMonths)&&s.expirationMonths<1e3&&s.expirationMonths,p=t?.purchasedBlockMultiplier??1,m=(0,B.useMemo)(()=>s?[Q(s.totalReadCount)&&{label:`Total Reads`,value:`${Wc(s.totalReadCount*p)} reads`},Q(s.totalReadsBytes)&&{label:`Total Read Transfer`,value:`${Vc(s.totalReadsBytes*p)}`},Q(s.readsPerMinuteCount)&&{label:`Read Rate`,value:`${Wc(s.readsPerMinuteCount*60*p)}/min`},Q(s.readsPerMinuteBytes)&&{label:`Read Bandwidth`,value:`${Vc(s.readsPerMinuteBytes*60*p)}/min`},Q(s.totalWriteCount)&&{label:`Total Writes`,value:`${Wc(s.totalWriteCount)} reads`},Q(s.totalWritesBytes)&&{label:`Total Write Transfer`,value:`${Vc(s.totalWritesBytes)}`},Q(s.writesPerMinuteCount)&&{label:`Write Rate`,value:`${Wc(s.writesPerMinuteCount*60)}/min`},Q(s.writesPerMinuteBytes)&&{label:`Write Bandwidth`,value:`${Vc(s.writesPerMinuteBytes*60)}/min`},Q(s.totalRealTimeMessageDeliveries)&&{label:`Total Real-Time Messages`,value:`${Wc(s.totalRealTimeMessageDeliveries*p)} messages`},Q(s.totalRealTimeMessageDeliveryBytes)&&{label:`Total Real-Time Message Transfer`,value:`${Vc(s.totalRealTimeMessageDeliveryBytes*p)}`},Q(s.realTimeMessageDeliveriesPerMinute)&&{label:`Real-Time Message Rate`,value:`${Wc(s.realTimeMessageDeliveriesPerMinute*60*p)}/min`},Q(s.realTimeMessageDeliveryBytesPerMinute)&&{label:`Real-Time Message Bandwidth`,value:`${Vc(s.realTimeMessageDeliveryBytesPerMinute*60*p)}/min`},Q(s.tlsHandshakes)&&{label:`TLS Handshakes`,value:`${Wc(s.tlsHandshakes*60*p)}`},Q(s.applicationComputeHours)&&{label:`Application Compute Hours`,value:`${Wc(s.applicationComputeHours*p)}`},!!c&&Q(c.storageGb)&&{label:`Storage`,value:`${Vc(c.storageGb*1e9)}`},!!c&&Q(c.cpuCores)&&{label:`Maximum CPU Cores`,value:`${Wc(c.cpuCores)}`},!!c&&Q(c.memoryMb)&&{label:`Memory`,value:`${c.memoryMb/1024} GB`},!!l&&{label:`Cloud Instance Type`,value:l},!!f&&{label:`Expiration`,value:u(f,`month`,`months`)},!!t?.id&&{label:`Region ID`,value:t.id},!!e?.id&&{label:`Plan ID`,value:e.id}].filter(ui):[],[f,t,e,p]);if(!s)return``;if(!Q(s.totalReadCount))return`This plan has no usage limits.`;let h=n?` Pricing subject to contracted rate.`:` Beta pricing subject to change.`,_=Q(s.readsPerMinuteCount)?`${Wc(s.readsPerMinuteCount*p)} reads/min & `:``,v=Q(s.writesPerMinuteCount)?` ${Wc(s.writesPerMinuteCount)} writes/min & `:` `,y=Q(s.readsPerMinuteCount)?`in ${t?.region??``} region${t?` (${t?.id})`:``}`:`per server`,b=f?`, for ${u(f,`month`,`months`)}`:``,x=n?`for the contracted rate`:`for the price listed above`,S=f?` in ${u(f,`month`,`months`)} or`:``;return(0,z.jsxs)(W,{className:`basis-full`,children:[(0,z.jsxs)(G,{onClick:o,children:[(0,z.jsx)(`em`,{className:`text-muted-foreground`,children:e?.id}),` Purchasing usage block for `,_,Wc(s.totalReadCount*p),` total reads `,y,`,`,(0,z.jsx)(`br`,{className:`hidden sm:block`}),v,` `,Wc(s.totalWriteCount),` total writes`,b,`.`,h,(0,z.jsx)(`br`,{className:`block sm:hidden`}),(0,z.jsxs)(g,{type:`button`,variant:`link`,className:`text-white`,children:[`Learn More `,i?(0,z.jsx)(dr,{}):(0,z.jsx)(nn,{})]})]}),(0,z.jsx)(H,{children:(0,z.jsxs)(`dl`,{className:d(`divide-y divide-black overflow-hidden transition-[max-height] duration-200 ease-in`,i?`max-h-fit`:`max-h-0`),children:[(0,z.jsxs)(`div`,{className:`text-sm mb-3 max-w-lg`,children:[`This plan licenses Harper for the usage limits below, `,x,`. The usage license expires`,S,` `,`when any usage limit is reached. New usage blocks are automatically purchased/billed as blocks are consumed.`]}),m.map((e,t)=>(0,z.jsxs)(`div`,{className:d(`px-4 py-1 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-3`,t%2==0&&`bg-gray-700`),children:[(0,z.jsx)(`dt`,{className:`text-sm/6 font-medium text-gray-300`,children:e.label}),(0,z.jsx)(`dd`,{className:`mt-1 text-sm/6 sm:col-span-2 sm:mt-0`,children:e.value})]},e.label))]})}),(0,z.jsx)(K,{})]})}function Kc({control:e,fieldArray:t,form:n,index:r,regionNameToLatencyToRegion:i,selectedPlan:a,isEnterprise:o,cloudProvider:s}){let c=(0,B.useMemo)(()=>Object.keys(i).sort(),[i]),l=n.watch(`deploymentDescription`)?.startsWith(`Dedicated`),u=n.watch(`regionPlans.${r}.regionName`),d=n.watch(`regionPlans.${r}.latencyDescription`),f=(0,B.useMemo)(()=>Object.keys(i[u]||{}).sort(Fc).reverse(),[i,u]);(0,B.useEffect)(function(){if(u&&f?.length&&!f?.includes(d)){let e=d?.split(` `)[0].toLowerCase(),t=f.find(t=>e?t.split(` `)[0].toLowerCase()===e:!0)||f[0];n.setValue(`regionPlans.${r}.latencyDescription`,t),n.trigger()}},[f,n,r,d,u]);let p=(0,B.useCallback)(()=>{t?.remove(r),n.trigger()},[t,n,r]);return(0,z.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,z.jsx)(U,{control:e,name:`regionPlans.${r}.regionName`,render:({field:e})=>(0,z.jsxs)(W,{className:`flex-1`,children:[(0,z.jsxs)(G,{children:[`Region `,t.fields.length>1?r+1:``]}),(0,z.jsx)(H,{children:(0,z.jsxs)(vc,{onValueChange:t=>{e.onChange(t),n.trigger()},...e,children:[(0,z.jsx)(xc,{className:`w-full`,children:(0,z.jsx)(bc,{placeholder:`Choose Region`})}),(0,z.jsx)(Sc,{children:(0,z.jsx)(yc,{children:c.map(e=>(0,z.jsx)($,{value:e,children:e},e))})})]})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:e,name:`regionPlans.${r}.latencyDescription`,render:({field:e})=>(0,z.jsxs)(W,{className:`flex-1`,children:[(0,z.jsxs)(G,{children:[`Estimated `,l?`P95`:`P90`,` Latency, Distribution`]}),(0,z.jsx)(H,{children:(0,z.jsxs)(vc,{onValueChange:t=>{e.onChange(t),n.trigger()},...e,disabled:!f?.length,children:[(0,z.jsx)(xc,{className:`w-full`,children:(0,z.jsx)(bc,{placeholder:`Choose Latency Tier`})}),(0,z.jsx)(Sc,{children:(0,z.jsx)(yc,{children:f.map(e=>(0,z.jsx)($,{value:e,children:e},e))})})]})}),(0,z.jsx)(K,{})]})}),t?.fields?.length&&t?.fields?.length>1&&(0,z.jsx)(`div`,{className:`flex-none mt-6`,children:(0,z.jsxs)(g,{type:`button`,variant:`destructiveOutline`,size:`sm`,onClick:p,children:[(0,z.jsx)(Ar,{}),` `,(0,z.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})}),(0,z.jsx)(Gc,{selectedPlan:a,selectedRegion:i[u]?.[d],isEnterprise:o,cloudProvider:s})]})}function qc({form:e,regionLocations:t,regionNameToLatencyToRegion:n,selectedPlan:r,totalPrice:i,isEnterprise:a,cloudProvider:o}){let s=e.watch(`regionPlans`),c=Xt({control:e.control,name:`regionPlans`}),l=(0,B.useMemo)(()=>{let e=s.map(e=>n?.[e.regionName]?.[e.latencyDescription]?.region);return i?t?.find(t=>!e.includes(t.region)):null},[t,n,s,i]),u=(0,B.useCallback)(()=>{l&&(c.append({regionName:l.region,latencyDescription:l.latencyDescription}),e.trigger())},[e,l,c]);return t?.length?(0,z.jsxs)(z.Fragment,{children:[c.fields.map((t,i)=>(0,z.jsx)(Kc,{control:e.control,fieldArray:c,form:e,index:i,regionNameToLatencyToRegion:n,selectedPlan:r,isEnterprise:a,cloudProvider:o},t.id)),l&&(0,z.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,z.jsxs)(g,{type:`button`,variant:`positiveOutline`,className:`rounded-full`,onClick:u,children:[(0,z.jsx)(ge,{}),`Add Additional Region Usage`]})})]}):(0,z.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,z.jsx)(wi,{className:`mt-0 m-0`,title:`No Regions Available`,showReturnToHome:!1,error:{message:(0,z.jsxs)(z.Fragment,{children:[`The deployment type you selected currently has no available regions. Please try a different deployment type, try again later, or `,(0,z.jsx)(ps,{}),`.`]})}})})}function Jc({control:e,fieldArray:n,form:r,index:i}){let a=(0,B.useCallback)(()=>{n?.remove(i)},[n,i]);return(0,z.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,z.jsx)(U,{control:e,name:`instances.${i}.secure`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsxs)(G,{children:[`Instance `,n.fields.length>1?i+1:``]}),(0,z.jsx)(H,{children:(0,z.jsxs)(vc,{...e,onValueChange:t=>{e.onChange(t),r.trigger()},children:[(0,z.jsx)(xc,{className:`w-full`,children:(0,z.jsx)(bc,{placeholder:`https://`})}),(0,z.jsx)(Sc,{children:(0,z.jsxs)(yc,{children:[(0,z.jsx)($,{value:`true`,children:`https://`}),(0,z.jsx)($,{value:`false`,children:`http://`})]})})]})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:e,name:`instances.${i}.fqdn`,render:({field:e})=>(0,z.jsxs)(W,{className:`flex-3`,children:[(0,z.jsx)(G,{children:`Host Name`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{...e,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:e,name:`instances.${i}.port`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{children:`Operations API Port`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{...e,type:`number`,min:0,max:pc,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:String(t),onChange:t=>{e.onChange(t.target.value?parseInt(t.target.value,10):void 0),r.trigger()}})}),(0,z.jsx)(K,{})]})}),n?.fields?.length&&n?.fields?.length>1&&(0,z.jsx)(`div`,{className:`flex-none mt-6`,children:(0,z.jsxs)(g,{type:`button`,variant:`destructiveOutline`,size:`sm`,onClick:a,children:[(0,z.jsx)(Ar,{}),` `,(0,z.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})})]})}function Yc({form:e}){let n=Xt({control:e.control,name:`instances`}),r=(0,B.useCallback)(()=>{n.append({secure:`true`,fqdn:``,port:t})},[n]);return(0,z.jsxs)(z.Fragment,{children:[n.fields.map((t,r)=>(0,z.jsx)(Jc,{control:e.control,fieldArray:n,form:e,index:r},t.id)),(0,z.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,z.jsxs)(g,{type:`button`,variant:`positiveOutline`,className:`rounded-full`,onClick:r,children:[(0,z.jsx)(ge,{}),`Add Instance`]})})]})}function Xc({calculatedNames:e,clusterId:t,deploymentToPerformanceToPlan:n,form:r,harperVersions:i,isEnterprise:a,cloudProvider:o,isPending:s,mode:c,regionLocations:l,regionNameToLatencyToRegion:u,selectedDeployment:d,selectedPerformance:f,selectedPlan:p,totalPrice:m}){let{isDirty:h,isValid:_}=xn(),v=(0,B.useMemo)(()=>Object.keys(n[d]||{}).map(e=>{let t=e.slice(0,-1).split(`(`);if(t.length>1)return{performanceTier:e,name:t[0],description:t[1]};let n=e.split(` for `);return n.length>1?{performanceTier:e,name:n[0],description:`For `+n[1]}:{performanceTier:e,name:e,description:``}}),[n,d]),y=(0,B.useMemo)(()=>Object.keys(n).sort(),[n]);(0,B.useEffect)(function(){v?.length&&!v.find(e=>e.performanceTier===f)&&(r.setValue(`performanceDescription`,v[0].performanceTier),r.trigger())},[d,f,v,r]);let b=d===`Self-Hosted`,x=(0,z.jsx)(X,{className:`mt-3 mb-12`,children:(0,z.jsxs)(g,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:s||t&&!h||!_,children:[c!==`version`&&m>0?`Confirm Payment Details`:t?`Edit Cluster`:`Create New Cluster`,(0,z.jsx)(nn,{})]})});return c===`version`?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-3 gap-6 text-white md:grid-cols-6`,children:[(0,z.jsx)(kc,{className:i?.value?.length?`col-span-3`:`md:col-span-6 col-span-3`,disabled:!0,form:r}),(0,z.jsx)(Nc,{className:`col-span-3`,form:r,harperVersions:i}),(0,z.jsx)(Mc,{className:`col-span-3 md:col-span-6`,form:r})]}),x]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-3 gap-6 text-white md:grid-cols-6`,children:[(0,z.jsx)(kc,{className:i?.value?.length?`col-span-3`:`md:col-span-6 col-span-3`,disabled:!!t,form:r}),(0,z.jsx)(Nc,{className:`col-span-3`,disabled:!!t,form:r,harperVersions:i}),b?(0,z.jsx)(Oc,{form:r,disabled:!!t}):(0,z.jsx)(gc,{form:r,calculatedNames:e,disabled:!!t}),(0,z.jsx)(Dc,{form:r,availableDeploymentTypes:y}),(0,z.jsx)(Ac,{availablePerformanceDescriptions:v,form:r,selectedDeployment:d}),b?(0,z.jsx)(Yc,{form:r}):(0,z.jsx)(qc,{form:r,regionLocations:l,regionNameToLatencyToRegion:u,selectedPlan:p,totalPrice:m,isEnterprise:a,cloudProvider:o}),t&&!b&&(0,z.jsx)(Mc,{className:`col-span-3 md:col-span-6`,form:r})]}),x]})}function Zc(e){let{fqdn:n}=e,{secure:r,port:i}=e;return i||=t,i===443&&r===`false`&&(r=`true`),i===80&&r===`true`&&(r=`false`),`${r===`true`?`https`:`http`}://${n}${i===443||i===80?``:`:`+i}`.toLowerCase()}function Qc(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 $c(e,t,n){if(t&&n){let r=e.getValues();if(!r.deploymentDescription||!r.performanceDescription||!r.regionPlans.length){let i=Qc(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 el({price:e}){return(0,z.jsx)(`span`,{className:`text-4xl`,children:new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).formatToParts(e||0).map((e,t)=>(0,z.jsx)(tl,{type:e.type,value:e.value},t))})}function tl({type:e,value:t}){switch(e){case`currency`:case`decimal`:case`fraction`:return(0,z.jsx)(`sup`,{className:`font-light text-xl`,children:t});default:return t}}function nl({alreadyUsingFree:e,clusterId:n,defaultValues:r,deploymentToPerformanceToPlan:i,harperVersions:a,mode:o,organization:s,organizationId:c,planTypes:l,regionLocationsColocated:u,regionLocationsDedicated:d,setSavedClusterState:f,startOffOnBilling:p}){let m=Or(),h=Et(),g=s?.type===Us,_=s?.channel===`Akamai`?`linode`:void 0,v=it(),{mutate:y,isPending:b}=Rs(),{mutate:S,isPending:ee}=Bs(),[te,C]=(0,B.useState)(p),ne=(0,B.useMemo)(()=>Os(u?.sort(Ss(`latencyDescription`))||[],`region`,`latencyDescription`),[u]),re=(0,B.useMemo)(()=>Os(d?.sort(Ss(`latencyDescription`))||[],`region`,`latencyDescription`),[d]),w=(0,B.useCallback)((t,n)=>{let r=new Set,a=i?.[t.deploymentDescription]?.[t.performanceDescription];if(t.deploymentDescription===`Self-Hosted`)for(let e=0;e<t.instances.length;e++){let i=Zc(t.instances[e]);r.has(i)?n.addIssue({code:`custom`,path:[`instances.${e}.fqdn`],message:`Every instance url must be unique!`}):r.add(i)}else{a?.priceUsd===0&&e&&n.addIssue({code:`custom`,path:[`performanceDescription`],message:`Only one free cluster is allowed per organization.`});let i=a?.deploymentDescription===`Dedicated`?re:ne;for(let e=0;e<t.regionPlans.length;e++){let o=t.regionPlans[e],s=i[o.regionName]?.[o.latencyDescription];r.has(o.regionName)?n.addIssue({code:`custom`,path:[`regionPlans.${e}.regionName`],message:`You can only select a region once!`}):r.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!`}):Gs(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,ne,re,i]),T=j({mode:`onChange`,resolver:F(hc.superRefine(w)),defaultValues:r}),[ie,E]=(0,B.useState)(!0);(0,B.useEffect)(()=>{ie&&r&&(f(null),E(!1))},[r,ie,f]);let ae=T.watch(`clusterName`),oe=T.watch(`abbreviatedName`),D=T.watch(`deploymentDescription`),se=T.watch(`performanceDescription`),ce=T.watch(`regionPlans`),le=T.watch(`instances`),ue=D===`Dedicated`?re:ne,de=D===`Dedicated`?d:u;(0,B.useEffect)(function(){let e=T.getValues();D&&(D===`Self-Hosted`?(e.abbreviatedName&&T.setValue(`abbreviatedName`,``),e.regionPlans.length&&T.setValue(`regionPlans`,[]),e.instances.length||T.setValue(`instances`,[{secure:`true`,fqdn:``,port:t}])):(e.fqdn&&T.setValue(`fqdn`,``),e.instances.length&&T.setValue(`instances`,[]),e.regionPlans.length||$c(T,l,de)))},[T,l,de,D]);let fe=(0,B.useMemo)(()=>{let e=Ws(Ks(ae),mc.maxLength);return{suggestedAbbreviatedName:e,fullHostName:`${oe||e}.${s.subdomain||`your-org`}.harperfabric.com`}},[ae,oe,s]),O=(0,B.useMemo)(()=>i?.[D]?.[se],[i,D,se]);(0,B.useEffect)(function(){let e=O?.allowedRegionIds;if(e?.length&&ce?.length===1){let t=ce[0],n=ue?.[t.regionName]?.[t.latencyDescription];if(!e.includes(n?.id)){let t=de?.filter(t=>e.includes(t.id)),n=t?.find(e=>e.region===`US`)||t?.[0];n&&(T.setValue(`regionPlans.0.regionName`,n.region),T.setValue(`regionPlans.0.latencyDescription`,n.latencyDescription),T.trigger())}}},[O,ce,T,ue,de]),(0,B.useEffect)(function(){if(D!==`Self-Hosted`&&Object.keys(ue).length&&ce.length)for(let e=0;e<ce.length;e++)ue[ce[e].regionName]||T.setValue(`regionPlans.${e}.regionName`,``)},[T,ue,D,ce]);let pe=O?.priceUsd?D===`Self-Hosted`?le.length*O.priceUsd:ce.reduce((e,t)=>{let n=ue?.[t.regionName]?.[t.latencyDescription];return e+(n?O.priceUsd*n.instanceCount/2:0)},0):0,me=(0,B.useCallback)(({creating:e,deploymentDescription:t})=>M.message(e?`Creating Cluster`:`Updating Cluster`,{description:(0,z.jsx)(Is,{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:12e4}),[]),he=(0,B.useCallback)(async({clusterId:e,sourceClusterId:t,creating:n,toastId:r,isSelfManaged:i})=>{if(t){let e=(await Vs(c)).clusters?.find(e=>e.id===t);Io(e?.status)&&await is(t)}v.invalidateQueries({queryKey:[c],refetchType:`active`}),n||v.invalidateQueries({queryKey:[e],refetchType:`active`}),h.invalidate(),m(i?{to:`/${c}/${e}/instances`}:n?{to:`/${c}/${e}/starting-up`}:{to:`/${c}/${e}/scaling`}),T.reset(),M.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})},[v,h,m,c,T]),ge=(0,B.useCallback)(async()=>{let e=T.getValues(),t=[],r=i[e.deploymentDescription][e.performanceDescription],a=e.deploymentDescription===`Self-Hosted`;if(a)for(let n of e.instances)t.push({autoRenew:!0,instanceFqdn:n.fqdn,operationsApiPort:n.port||9925,operationsApiSecure:n.secure===`true`,planId:r.id});else for(let n of e.regionPlans){let e=ue[n.regionName][n.latencyDescription];t.push({autoRenew:!0,planId:r.id,regionId:e.id})}f(null);let s=me({creating:!n,deploymentDescription:e.deploymentDescription}),l=()=>M.dismiss(s);n?S(o===`version`?{id:n,version:e.version,skipGtmWait:e.skipGtmWait}:{id:n,regionPlans:t,skipGtmWait:e.skipGtmWait},{onSuccess:t=>he({clusterId:t.id,sourceClusterId:e.sourceClusterId,isSelfManaged:a,creating:!1,toastId:s}),onError:l}):y({abbreviatedName:a?void 0:e.abbreviatedName||fe.suggestedAbbreviatedName,autoRenew:!0,fqdn:a&&e.fqdn||void 0,name:e.clusterName,version:e.version,organizationId:c,regionPlans:t},{onSuccess:t=>he({clusterId:t.id,sourceClusterId:e.sourceClusterId,isSelfManaged:a,creating:!0,toastId:s}),onError:l})},[fe.suggestedAbbreviatedName,n,i,T,he,me,c,ue,f,S,y]),_e=(0,B.useCallback)(()=>{if(o!==`version`&&pe>0){C(!0);return}return ge()},[o,ge,pe]),k=(0,B.useCallback)(e=>{f(e?{clusterId:n,...T.getValues(),skipToBilling:!0}:null)},[n,T,f]),ve=(0,B.useCallback)(()=>{C(!1)},[]),ye=!g&&`mr-37.5`;return(0,z.jsxs)(z.Fragment,{children:[!g&&o!==`version`&&(0,z.jsxs)(`div`,{className:`absolute top-3 right-4 md:right-12 text-right`,children:[(0,z.jsx)(`dt`,{className:`font-light`,children:`Total Price`}),(0,z.jsx)(`dd`,{className:`font-bold`,children:(0,z.jsx)(el,{price:pe})})]}),(0,z.jsx)(V,{...T,children:te?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`h1`,{className:x(`text-lg leading-none text-white font-semibold mb-4`,ye),children:`Cluster Billing`}),(0,z.jsx)(`p`,{className:x(`text-muted-foreground text-sm mb-2`,ye),children:`Please confirm the following billing details:`}),(0,z.jsx)(dc,{clusterId:n,isPending:b||ee,onGoBackToDetails:ve,onSaveStateForBillingRedirect:k,onSubmit:ge,organizationId:c,selectedPlan:O})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`h1`,{className:x(`text-lg leading-none text-white font-semibold mb-4`,ye),children:`Cluster Configuration`}),(0,z.jsx)(`p`,{className:x(`text-muted-foreground text-sm mb-6`,ye),children:`Configure your Harper cluster and define deployment plans.`}),(0,z.jsx)(`form`,{id:`cluster-upsert-form`,name:`cluster-upsert-form`,onSubmit:T.handleSubmit(_e),children:(0,z.jsx)(Xc,{calculatedNames:fe,clusterId:n,deploymentToPerformanceToPlan:i,form:T,isPending:b||ee,harperVersions:a,mode:o,regionLocations:de,regionNameToLatencyToRegion:ue,selectedDeployment:D,selectedPerformance:se,selectedPlan:O,totalPrice:pe,isEnterprise:g,cloudProvider:_})})]})})]})}function rl(e){return e?.clusterName!==void 0}function il(){let{organizationId:e,clusterId:t,mode:n}=k({strict:!1}),{create:r,update:i}=Zi(e),{organization:a,cluster:o}=mn({strict:!1}),[s,c]=us(ds.SavedClusterState,null),{data:l}=N(_s(e)),{data:u}=N(xs({availableHosts:!0,organizationId:e})),{data:d}=N(xs({organizationId:e})),{data:f}=N(ys()),p=(0,B.useMemo)(()=>{if(o){let e=o.instances?.map(e=>e.version).filter(ui);if(f&&e){let t=e.sort(As).pop();return{...f,value:[!!t&&{name:`current`,version:t},...(f?.value||[]).filter(e=>t!==e.version&&(!t||ks(t,e.version)))].filter(ui)}}}return f},[f,o]),m=(0,B.useMemo)(()=>{for(let e of a?.clusters??[])if(e.id!==o?.id&&l&&!Lo(e.status)&&!Io(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]),h=(0,B.useMemo)(()=>Os(l?.sort(Ss(`priceUsd`))||[],`deploymentDescription`,`performanceDescription`),[l]),g=(0,B.useMemo)(()=>{if(!l||!p||!u||!d||t&&!o)return null;let e=o;if(s){if(rl(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=Qc(l,a,m),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&&!Ma.includes(e.status)).sort(Ts);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 h=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:h,deploymentDescription:n?.deploymentDescription??c?.deploymentDescription??``,performanceDescription:n?.performanceDescription??c?.performanceDescription??``,fqdn:f?e?.fqdn??``:``,instances:i,regionPlans:r}},[m,o,t,l,p,u,d,s]);return!g||!a||!l||!u||!d?(0,z.jsx)(hs,{children:(0,z.jsx)(ms,{centered:!0,text:`Loading...`})}):(o?.id?!i:!r)?(0,z.jsx)(hs,{children:(0,z.jsx)(wi,{title:`Not Allowed`,error:{message:(0,z.jsxs)(z.Fragment,{children:[`You do not have permission to `,o?.id?`update`:`create`,` clusters in this org.`]})}})}):l.length===0?(0,z.jsx)(hs,{children:(0,z.jsx)(wi,{title:`Cluster ${t?`Modification`:`Creation`} Not Currently Allowed`,error:{message:(0,z.jsxs)(z.Fragment,{children:[`There are no available deployment types right now! Please try again later, or `,(0,z.jsx)(ps,{}),`.`]})}})}):(0,z.jsx)(hs,{className:`max-w-4xl mx-auto`,children:(0,z.jsx)(nl,{alreadyUsingFree:m,clusterId:t,defaultValues:g,deploymentToPerformanceToPlan:h,harperVersions:p,mode:n,organization:a,organizationId:e,planTypes:l,regionLocationsColocated:u,regionLocationsDedicated:d,setSavedClusterState:c,startOffOnBilling:rl(s)&&s.skipToBilling===!0})})}var al={FAILED:0,UPDATING:1,PROVISIONING:2,RUNNING:3,TERMINATED:4},ol=al.RUNNING;function sl(e,t){return e.status===t.status?e.name.localeCompare(t.name):(e.status?al[e.status]??ol:ol)-(t.status?al[t.status]??ol:ol)}function cl(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 ll(){let{organizationId:e}=k({strict:!1}),{create:t}=Zi(e),{data:n,isSuccess:r}=fe(Hs(e)),[i]=us(ds.SavedClusterState,null),[a,o]=(0,B.useState)(``),s=(0,B.useCallback)(()=>o(``),[]),c=(0,B.useCallback)(e=>{o(e.currentTarget.value?.toLowerCase()||``)},[]),l=(0,B.useMemo)(()=>n?.clusters?.slice().filter(e=>!Lo(e.status)).sort(sl)||[],[n?.clusters]),u=(0,B.useMemo)(()=>l.filter(cl([`id`,`name`],a))||[],[a,l]);return n&&l.length===0&&t?(0,z.jsx)(il,{}):i?(0,z.jsx)(on,{to:`/${e}/new-cluster`}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(No,{children:r?(0,z.jsxs)(`div`,{className:`flex w-full justify-end gap-2`,children:[(0,z.jsx)(q,{placeholder:`Filter by name`,className:`inline-block w-full text-xs`,value:a,onChange:c}),t&&(0,z.jsx)(L,{to:`new-cluster`,children:(0,z.jsxs)(g,{variant:`positive`,accessKey:`n`,children:[(0,z.jsx)(ge,{}),` `,(0,z.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,z.jsx)(`u`,{children:`N`}),`ew `,(0,z.jsx)(`span`,{className:`hidden md:inline-block`,children:`Cluster`})]})]})})]}):null}),(0,z.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-12 mb-4`,children:[u.map(e=>(0,z.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,z.jsx)(fs,{cluster:e})},e.id)),!u.length&&(0,z.jsxs)(`div`,{className:`col-span-1 md:col-span-12 text-center`,children:[(0,z.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,z.jsx)(g,{type:`button`,variant:`outline`,onClick:s,children:`Clear Filters`})]})]})})]})}function ul(){let e=URL.parse(location.href);return e?.hash?e.hash.startsWith(`#/`)?e.hash.slice(1):e.hash:`/`}function dl(){return`/#`+ul()}function fl(){let{organizationId:e}=k({strict:!1}),t=Or(),n=new URLSearchParams(window.location.search).get(`setup_intent_client_secret`),{setup_intent_client_secret:r}=St({strict:!1}),[i]=us(ds.SavedClusterState,null),a=n||r,o=zn(),s=Ys(e),c=(0,B.useCallback)(()=>{let e=i?i.clusterId?`../../${i.clusterId}/edit`:`../../new-cluster`:`../`;window.history.replaceState(null,``,dl()),t({search:void 0,to:e})},[t,i]);return(0,B.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?(M.error(`Failed to process payment method details. Please try another payment method.`),c()):s(e.payment_method,c);break;case`processing`:M.warning(`Processing payment method. Please check back later.`),c();break;case`requires_payment_method`:M.error(`Failed to process payment method details. Please try another payment method.`),c();break;default:M.error(`Failed to process payment method details. Please try another payment method.`),c();break}}catch(e){console.error(e),M.error(`Failed to process payment method details. Please try another payment method.`),c()}})()},[a,c,e,s,o]),(0,z.jsx)(ms,{centered:!0})}function pl(){return(0,z.jsx)(ic,{children:(0,z.jsx)(fl,{})})}function ml({clusterId:e,instanceId:t,organizationId:n},r){return`/`+[n,e,t&&`instance`,t,r].filter(ui).join(`/`)}var hl=`flex items-center p-2 rounded-lg group`,gl={className:`text-white hover:bg-gray-700`},_l={className:`text-black bg-white pointer-events-none cursor-default`};function vl(){let{organizationId:e}=k({strict:!1}),{update:t}=Yi(e);return t?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(No,{}),(0,z.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,z.jsxs)(`div`,{className:`md:grid gap-4 md:grid-cols-12 min-h-[calc(100vh-theme(spacing.36))] mb-12`,children:[(0,z.jsxs)(`section`,{className:`col-span-1 text-white md:col-span-4 lg:col-span-3 md:border-r-1 border-b md:border-b-0 md:pr-4 border-gray-700`,children:[(0,z.jsx)(yl,{}),(0,z.jsx)(bl,{})]}),(0,z.jsx)(`section`,{className:`col-span-1 text-white md:col-span-8 lg:col-span-9`,children:(0,z.jsx)(Wn,{})})]})})]}):(0,z.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.`})}function yl(){let e=k({strict:!1});return(0,z.jsxs)(`div`,{className:`hidden md:block`,children:[(0,z.jsxs)(`span`,{className:hl,children:[(0,z.jsx)(xt,{className:`inline-block`}),(0,z.jsx)(`h3`,{className:`ms-3 text-2xl font-extrabold dark:text-white`,children:`Billing`})]}),(0,z.jsxs)(`ul`,{className:`border-t border-gray-700 pt-4 mt-4 space-y-2`,children:[(0,z.jsx)(`li`,{children:(0,z.jsxs)(L,{to:ml(e,`billing`),className:hl,activeOptions:{exact:!0},inactiveProps:gl,activeProps:_l,children:[(0,z.jsx)(Rn,{className:`inline-block`}),` `,(0,z.jsx)(`span`,{className:`ms-3`,children:`Payment Method`})]})}),(0,z.jsx)(`li`,{children:(0,z.jsxs)(L,{to:ml(e,`billing/invoices`),className:hl,inactiveProps:gl,activeProps:_l,children:[(0,z.jsx)(Ir,{className:`inline-block`}),(0,z.jsx)(`span`,{className:`ms-3`,children:`Invoices & Payments`})]})})]})]})}function bl(){let e=k({strict:!1});return(0,z.jsxs)(`ul`,{className:`flex space-x-4 md:hidden py-2`,children:[(0,z.jsx)(`li`,{children:(0,z.jsxs)(L,{to:ml(e,`billing`),className:hl,activeOptions:{exact:!0},inactiveProps:gl,activeProps:_l,children:[(0,z.jsx)(Rn,{className:`inline-block`}),` `,(0,z.jsx)(`span`,{className:`ms-3`,children:`Payment Method`})]})}),(0,z.jsx)(`li`,{children:(0,z.jsxs)(L,{to:ml(e,`billing/invoices`),className:hl,inactiveProps:gl,activeProps:_l,children:[(0,z.jsx)(Ir,{className:`inline-block`}),` `,(0,z.jsx)(`span`,{className:`ms-3`,children:`Invoices & Payments`})]})})]})}function xl({className:e,containerClassName:t,...n}){return(0,z.jsx)(`div`,{"data-slot":`table-container`,className:d(`relative w-full overflow-x-auto`,t),children:(0,z.jsx)(`table`,{"data-slot":`table`,className:d(`w-full caption-bottom text-sm`,e),...n})})}function Sl({className:e,...t}){return(0,z.jsx)(`thead`,{"data-slot":`table-header`,className:d(`[&_tr]:border-b`,e),...t})}function Cl({className:e,...t}){return(0,z.jsx)(`tbody`,{"data-slot":`table-body`,className:d(`[&_tr:last-child]:border-0`,e),...t})}function wl({className:e,...t}){return(0,z.jsx)(`tr`,{"data-slot":`table-row`,className:d(`border-b border-grey-700 transition-colors`,e),...t})}function Tl({className:e,...t}){return(0,z.jsx)(`th`,{"data-slot":`table-head`,className:d(`h-10 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function El({header:e,onColumnClick:t,...n}){let r=(0,B.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]),i=e.column.columnDef.enableSorting,a=e.column.columnDef.enableResizing,o=e.isPlaceholder?null:er(e.column.columnDef.header,e.getContext()),s=(0,B.useCallback)(()=>{e.column.resetSize()},[e]);return(0,z.jsx)(Tl,{...n,style:{width:`${e.getSize()}px`},className:i?`px-0`:`px-2`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[i?(0,z.jsxs)(g,{type:`button`,variant:`ghost`,className:d(`rounded-none`,!e.column.getIsSorted()||e.column.getIsSorted()===`asc`?`cursor-n-resize`:`cursor-s-resize`),onClick:r,children:[o,e.column.getIsSorted()===`asc`?(0,z.jsx)(sr,{}):e.column.getIsSorted()===`desc`?(0,z.jsx)(dr,{}):(0,z.jsx)(Mn,{className:`text-gray-600`})]}):o,a&&(0,z.jsx)(g,{type:`button`,variant:`ghost`,className:`cursor-col-resize`,onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),onDoubleClick:s,style:{transform:e.column.getIsResizing()?`translateX(${e.getContext().table.getState().columnSizingInfo.deltaOffset}px)`:``},children:(0,z.jsx)(dn,{})})]})})}function Dl({className:e,...t}){return(0,z.jsx)(`td`,{"data-slot":`table-cell`,className:d(`align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function Ol({columns:e,data:t,isFetching:n,onRowClick:r,onColumnClick:i,sortingState:a,children:o}){let s=pr({data:t,columns:e,getCoreRowModel:Hn(),getSortedRowModel:gn(),initialState:{sorting:a}});return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-end space-x-2 pb-4`,children:[(0,z.jsx)(`div`,{className:`grow lg:hidden`}),o,(0,z.jsx)(`div`,{className:`grow hidden lg:visible`})]}),(0,z.jsxs)(xl,{containerClassName:`rounded-md bg-black-dark`,children:[(0,z.jsx)(Sl,{children:s.getHeaderGroups().map(e=>(0,z.jsx)(wl,{className:`border-none`,children:e.headers.map(e=>(0,z.jsx)(El,{header:e,onColumnClick:i},e.id))},e.id))}),(0,z.jsx)(Cl,{className:`bg-black border border-grey-700`,children:s.getRowModel().rows?.length?s.getRowModel().rows.map(e=>(0,z.jsx)(wl,{"data-state":e.getIsSelected()&&`selected`,onClick:()=>r?.(e),className:d(`hover:bg-muted/10 data-[state=selected]:bg-muted`,r&&`cursor-pointer`),children:e.getVisibleCells().map(e=>(0,z.jsx)(Dl,{className:`py-2 px-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,style:{width:`${e.column.getSize()}px`},children:er(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,z.jsx)(wl,{children:(0,z.jsx)(Dl,{colSpan:e.length,className:`h-24 text-center`,children:n?(0,z.jsx)(`div`,{children:(0,z.jsx)(ms,{className:`p-12`})}):(0,z.jsx)(`span`,{children:`No results.`})})})})]})]})}function kl(e){switch(e){case`paid`:return`success`;case`void`:case`uncollectible`:return`destructive`;default:return`default`}}function Al(e){return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).format(e)}function jl(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 Ml=[{header:`Invoice Id`,accessorKey:`id`,enableSorting:!1},{header:`Status`,accessorKey:`status`,enableSorting:!1,cell:({cell:e})=>(0,z.jsx)(Ko,{variant:kl(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?jl(r,t):[t?jl(r,t):`-`,n?jl(i,n):`-`].join(` to `)}},{header:`Amount Due`,accessorKey:`amountDue`,enableSorting:!1,cell:({cell:e})=>Al(e.getValue()?e.getValue()/100:0)},{header:`Amount Paid`,accessorKey:`amountPaid`,enableSorting:!1,cell:({cell:e})=>Al(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} @ ${Al(e.amount/100)}`);return n.join(`
11
- `)}}];function Nl(e){return(0,B.useCallback)(async()=>{M.loading(`Refreshing...`,{id:`refreshing`});let t=Date.now();await e(),Date.now()-t<500&&await p(500),M.success(`Refreshed!`,{id:`refreshing`})},[e])}async function Pl(e){let{data:t}=await s.get(`/Invoice/${e}`);return t}function Fl(e,t){return P({queryKey:[e,`invoices`],queryFn:()=>Pl(e),retry:!1,enabled:!!e,refetchInterval:t?1e4:void 0})}function Il(){let{organizationId:e}=k({strict:!1}),{data:t}=N(Hs(e)),{data:n,refetch:r,isLoading:i,isFetching:a,isRefetching:o}=N(Fl(t?.type!==`ENTERPRISE`&&t?.id,!1)),s=Nl(r);return t?.type===`ENTERPRISE`?(0,z.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,z.jsx)(ps,{}),`, we would love to talk!`]}):i?(0,z.jsx)(ms,{centered:!0}):!n||!n.length?(0,z.jsxs)(`span`,{children:[`Your invoices will be shown here once one is available! Want to explore your solution with Harper more?`,` `,(0,z.jsx)(ps,{overEmail:!0}),`, we would love to talk!`]}):(0,z.jsx)(Ol,{data:n,columns:Ml,children:(0,z.jsxs)(g,{variant:`defaultOutline`,onClick:s,accessKey:`r`,disabled:a||o,children:[(0,z.jsx)($e,{}),(0,z.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,z.jsx)(`u`,{children:`R`}),`efresh`]})]})})}function Ll(e){let t=I({getParentRoute:()=>e,path:`billing`,component:vl}),n=I({getParentRoute:()=>t,path:`/`,component:uc}),r=I({getParentRoute:()=>t,path:`invoices`,component:Il}),i=I({getParentRoute:()=>t,path:`confirm`,component:pl});return t.addChildren([n,r,i])}async function Rl(e){let{data:t}=await s.get(`/OrganizationRole/${e}`);return t}function zl(e){return P({queryKey:[e,`roles`],queryFn:()=>Rl(e),retry:!1,refetchInterval:10*1e3})}var Bl=[{header:`Role Name`,accessorKey:`roleName`,enableSorting:!1},fn().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 Vl(e){let{data:t}=await s.post(`/Role/`,e);return t}function Hl(){return A({mutationFn:Vl})}var Ul=E({name:C().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:T(),delete:T()});E({roles:E({create:T(),delete:T(),update:T(),view:T()}),clusters:E({create:T(),delete:T(),update:T(),view:T(),resources:oe(E({id:C(),delete:T(),update:T(),view:T(),instances:E({create:T(),delete:T(),update:T(),view:T()})}))})});var Wl={roles:{create:!0,view:!0,update:!0,delete:!0},clusters:{create:!0,view:!0,update:!0,delete:!0,resources:[]}};function Gl({isModalOpen:e,setIsModalOpen:t}){let n=it(),{organizationId:r}=k({strict:!1}),[i,a]=(0,B.useState)(!0),[o,s]=(0,B.useState)(JSON.stringify(Wl,null,2)),{mutate:c,isPending:l}=Hl(),u=j({resolver:F(Ul),defaultValues:{name:``,update:!1,delete:!1}}),d=(0,B.useCallback)(e=>{a(e.length===0)},[a]),f=(0,B.useCallback)(async e=>{let a=ss(o);if(!a)return;let s={...e,...a,organizationId:r};e&&i&&c(s,{onSuccess:()=>{M.success(`Organization role added successfully!`),t(!1),n.invalidateQueries({queryKey:[r,`roles`],refetchType:`active`}),u.reset()},onError:e=>{M.error(`Failed to add organization role: ${e.message}`)}})},[i,o,c,u,n,t,r]);return(0,z.jsx)(J,{onOpenChange:t,open:e,children:(0,z.jsxs)(Y,{children:[(0,z.jsx)(Z,{children:`Add New Organization Role`}),(0,z.jsx)(Wo,{children:`Set the new organization role permissions.`}),(0,z.jsx)(V,{...u,children:(0,z.jsxs)(`form`,{id:`org-add-role-form`,name:`org-add-role-form`,className:`grid grid-cols-2 gap-4 my-4`,onSubmit:u.handleSubmit(f),children:[(0,z.jsx)(U,{control:u.control,name:`name`,render:({field:e})=>(0,z.jsxs)(W,{className:`col-span-2`,children:[(0,z.jsx)(G,{className:`pb-1`,children:`Role Name`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`text`,className:``,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:u.control,name:`update`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{className:`pb-1`,children:`Can Update Organization`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:u.control,name:`delete`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{className:`pb-1`,children:`Can Delete Organization`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(`div`,{className:`col-span-2`,children:(0,z.jsx)(rn,{theme:`vs-dark`,height:`300px`,defaultLanguage:`json`,onValidate:d,onChange:e=>{e&&s(e)},defaultValue:JSON.stringify(Wl,null,2)})}),(0,z.jsx)(X,{className:`col-span-2`,children:(0,z.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,z.jsx)(g,{variant:`destructiveOutline`,className:`rounded-full`,type:`button`,onClick:()=>t(!1),disabled:l,children:`Cancel`}),(0,z.jsx)(g,{variant:`submit`,className:`rounded-full`,disabled:l||!i||!u.formState.isValid,children:`Save Changes`})]})})]})})]})})}async function Kl({roleId:e}){let{data:t}=await s.delete(`/Role/${e}`,{id:e,deleted:!0});return t}function ql(){return A({mutationFn:({roleId:e})=>Kl({roleId:e})})}async function Jl({roleId:e,updatedRoleInfo:t}){let{data:n}=await s.put(`/Role/${e}`,t);return n}function Yl(){return A({mutationFn:({roleId:e,updatedRoleInfo:t})=>Jl({roleId:e,updatedRoleInfo:t})})}function Xl({organizationId:e,roleId:t}){return P({queryKey:[e,`roles`,t],queryFn:()=>Zl(t),refetchInterval:10*1e3})}async function Zl(e){let{data:t}=await s.get(`/Role/${e}`);return t}function Ql({onRoleDeleteClick:e,setIsConfirmingRoleDeletion:t,isRoleDeletionPending:n}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Z,{children:`Confirm Role Deletion`}),(0,z.jsx)(Wo,{children:`Are you sure you want to delete this role? This action cannot be undone.`}),(0,z.jsxs)(X,{children:[(0,z.jsx)(g,{type:`button`,variant:`defaultOutline`,className:`rounded-full`,onClick:()=>t(!1),children:`Cancel`}),(0,z.jsx)(g,{variant:`destructiveOutline`,className:`rounded-full`,onClick:e,disabled:n,children:n?`Deleting...`:`Delete Role`})]})]})}function $l({data:e,isModalOpen:t,closeModal:n}){let r=it(),{data:i}=fe(Xl({roleId:e.id,organizationId:e.organizationId})),a=si(),o=a.user&&a.user?.roles?.[e.organizationId]?.role===e.roleName,{update:s,remove:c}=Xi(e.organizationId),{mutate:l,isPending:u}=Yl(),{mutate:d,isPending:f}=ql(),[p,m]=(0,B.useState)(!1),h=j({resolver:F(Ul),defaultValues:{name:e.roleName,update:i.organization.update||!1,delete:i.organization.delete||!1}}),_=(0,B.useCallback)(()=>{d({roleId:e.id},{onSuccess:()=>{M.success(`Role deleted successfully!`),n(!0),h.reset()},onError:e=>{M.error(`Error`,{description:`Failed to delete role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>M.dismiss()}})}})},[e.id,d,h,n]),[v,y]=(0,B.useState)(!0),[b,x]=(0,B.useState)(JSON.stringify({roles:{...i.organization.roles},clusters:{...i.organization.clusters}},null,2)),S=(0,B.useCallback)(e=>{y(e.length===0)},[y]),ee=(0,B.useCallback)(async t=>{if(!s)return;let i=ss(b);if(!i)return;let a={...t,...i,organizationId:e.organizationId};b&&v&&l({roleId:e.id,updatedRoleInfo:a},{onSuccess:async()=>{M.success(`Role updated successfully!`),await r.invalidateQueries({queryKey:[e.organizationId,`roles`,e.id]}),n(!1),h.reset()},onError:e=>{M.error(`Error`,{description:`Failed to update role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>M.dismiss()}})}})},[n,e.id,e.organizationId,h,v,r,i,s,b,l]);return(0,z.jsx)(J,{onOpenChange:(0,B.useCallback)(()=>n(!1),[n]),open:t,children:(0,z.jsx)(Y,{children:p?(0,z.jsx)(Ql,{onRoleDeleteClick:_,setIsConfirmingRoleDeletion:m,isRoleDeletionPending:f}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Z,{children:[o||!s?`View`:`Edit`,` Organization Role "`,e.roleName,`"`]}),(0,z.jsx)(V,{...h,children:(0,z.jsxs)(`form`,{id:`org-edit-role-form`,name:`org-edit-role-form`,className:`grid grid-cols-2 gap-4 my-4`,onSubmit:h.handleSubmit(ee),children:[(0,z.jsx)(U,{control:h.control,name:`name`,render:({field:e})=>(0,z.jsxs)(W,{className:`col-span-2`,children:[(0,z.jsx)(G,{className:`pb-1`,children:`Role Name`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`text`,className:``,...e,disabled:!0,readOnly:!0})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:h.control,name:`update`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{className:`pb-1`,children:`Can Update Organization`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`checkbox`,className:`w-6 ml-2`,disabled:o||!s,readOnly:o||!s,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:h.control,name:`delete`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{className:`pb-1`,children:`Can Delete Organization`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`checkbox`,className:`w-6 ml-2`,disabled:o||!s,readOnly:o||!s,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(`div`,{className:`col-span-2`,children:(0,z.jsx)(rn,{theme:`vs-dark`,height:`300px`,defaultLanguage:`json`,onValidate:S,onChange:e=>{e&&x(e)},options:o||!s?{readOnly:!0}:void 0,defaultValue:b})}),!o&&(c||s)&&(0,z.jsx)(X,{className:`col-span-2`,children:(0,z.jsxs)(`div`,{className:`flex justify-between w-full`,children:[c&&(0,z.jsx)(g,{type:`button`,variant:`destructiveOutline`,className:`rounded-full`,onClick:()=>m(!0),disabled:u,children:`Delete Role`}),s&&(0,z.jsx)(g,{variant:`submit`,className:`rounded-full`,disabled:!v||u||!h.formState.isValid||!h.formState.isDirty,children:`Save Changes`})]})})]})})]})})})}function eu(){let e=Or(),t=it(),{organizationId:n,orgRoleId:r}=k({strict:!1}),{create:i}=Xi(n),{data:a,refetch:o,isFetching:s,isRefetching:c}=fe(zl(n)),l=(0,B.useMemo)(()=>a&&a?.find(e=>e.id===r),[a,r]),u=!!r&&!!l,[d,f]=(0,B.useState)(!1),p=(0,B.useCallback)(async(i,a)=>{await e({to:[r?`..`:``,i].filter(Boolean).join(`/`)}),a&&await t.invalidateQueries({queryKey:[n,`roles`],refetchType:`active`})},[r,e,t]),m=(0,B.useCallback)(()=>{f(!0)},[f]),h=(0,B.useCallback)(e=>p(e.original.id,!1),[p]),_=(0,B.useCallback)(e=>p(void 0,e),[p]),v=Nl(o);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(No,{}),(0,z.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,z.jsxs)(B.Suspense,{fallback:(0,z.jsx)(ms,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,z.jsxs)(Ol,{data:a,columns:Bl,onRowClick:h,children:[(0,z.jsxs)(g,{variant:`defaultOutline`,onClick:v,accessKey:`r`,disabled:s||c,children:[(0,z.jsx)($e,{}),(0,z.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,z.jsx)(`u`,{children:`R`}),`efresh`]})]}),i&&(0,z.jsxs)(g,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:d,children:[(0,z.jsx)(ge,{}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`u`,{children:`A`}),`dd`]})]})]}),i&&(0,z.jsx)(Gl,{isModalOpen:d,setIsModalOpen:f}),u&&(0,z.jsx)($l,{data:l,isModalOpen:u,closeModal:_})]})})]})}var tu=[{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},fn().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}],nu=se.object({email:za.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:se.string().nonempty({error:`Please select a role.`})});async function ru(e){let{data:t}=await s.post(`/OrganizationRole/`,e);return t}function iu(){return A({mutationFn:e=>ru(e)})}se.object({email:za.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:se.string().nonempty({error:`Please select a role.`})});async function au(e){let{data:t}=await s.post(`/UserInvite/`,e);return t}function ou(){return A({mutationFn:e=>au(e)})}function su({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let{organizationId:r}=k({strict:!1}),{data:i}=fe(zl(r)),[a,o]=(0,B.useState)(!1),s=j({resolver:F(nu),defaultValues:{email:``,roleId:``}}),{mutate:c,isPending:l}=iu(),{mutate:u,isPending:d}=ou(),f=(0,B.useCallback)(async e=>{e&&(a?u:c)(e,{onSuccess:()=>{let r=e.roleId;s.reset(),s.setValue(`roleId`,r),t(),M.success(`User invited successfully!`),n(!1),o(!1)},onError:e=>{e?.status===404&&o(!0)}})},[c,s,u,t,n,a]);return(0,z.jsx)(J,{onOpenChange:()=>{n(!1),o(!1),s.reset()},open:e,children:(0,z.jsx)(Y,{"aria-describedby":void 0,children:(0,z.jsx)(V,{...s,children:(0,z.jsxs)(`form`,{id:`org-add-user-form`,name:`org-add-user-form`,onSubmit:s.handleSubmit(f),className:`grid gap-4 my-4`,children:[(0,z.jsx)(Uo,{children:(0,z.jsx)(Z,{children:a?`Invite User`:`Add User`})}),(0,z.jsx)(U,{control:s.control,name:`email`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{className:`pb-1`,children:`Email`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`email`,enterKeyHint:`next`,autoComplete:`email`,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:s.control,name:`roleId`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{className:`pb-1`,children:`Roles`}),(0,z.jsx)(B.Suspense,{fallback:(0,z.jsx)(_c,{}),children:(0,z.jsx)(H,{children:(0,z.jsxs)(vc,{...e,onValueChange:t=>e.onChange(t),children:[(0,z.jsx)(xc,{className:`w-full`,children:(0,z.jsx)(bc,{placeholder:`Choose Role`})}),(0,z.jsx)(Sc,{children:(0,z.jsxs)(yc,{children:[(0,z.jsx)(Cc,{children:`Role`}),i?.map(e=>(0,z.jsx)($,{value:e.id,children:e.roleName},e.id))]})})]})})}),(0,z.jsx)(K,{})]})}),a&&(0,z.jsxs)(Wo,{className:`p-3 my-5 text-white rounded-md bg-amber-600 flex`,children:[(0,z.jsx)(Wt,{className:`inline-block size-12 pr-2`}),(0,z.jsx)(`span`,{children:`This person doesn’t have a Fabric account. Do you want to invite them?`})]}),(0,z.jsx)(X,{children:(0,z.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,z.jsxs)(g,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:l||d,children:[(0,z.jsx)(ht,{}),` `,a?`Invite User`:`Add User`]})})})]})})})})}async function cu({roleId:e,userId:t}){let{data:n}=await s.delete(`/OrganizationRole/role/${e}/user/${t}`);return n}function lu(){return A({mutationFn:({roleId:e,userId:t})=>cu({roleId:e,userId:t})})}function uu(e){let[t,n]=(0,B.useState)(e||!1);return[t,(0,B.useCallback)(e=>{n(typeof e==`boolean`?e:e.target.checked)},[])]}function du({data:e,readOnly:t,canRemove:n,orgRole:r,selectedRoles:i,setChangesMade:a}){let{mutate:o,isPending:s}=iu(),{mutate:c,isPending:l}=lu(),u=!!i[r.roleName],[d,f]=(0,B.useState)(u),[p,m]=uu(u);return(0,B.useEffect)(()=>{p!==d&&(p?o({email:e.email,roleId:r.id},{onSuccess:()=>{f(p),a(!0),M.success(`Role added successfully`)}}):c({userId:e.id,roleId:r.id},{onSuccess:()=>{f(p),a(!0),M.success(`Role removed successfully`)}}))},[o,e.email,e.id,p,r.id,c,a,d]),(0,z.jsxs)(Aa,{className:`flex`,children:[(0,z.jsx)(q,{type:`checkbox`,className:`w-6`,disabled:t||s||l||!n&&p,checked:p,onChange:m}),(0,z.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:r.roleName})]},r.id)}function fu({closeModal:e,data:t,isModalOpen:n,onUserUpdated:r}){let{organizationId:i}=k({strict:!1}),a=si(),{update:o,remove:s}=Xi(i),c=a.user?.email===t.email,{data:l}=fe(zl(i)),u=(0,B.useMemo)(()=>t.roles?Ds(t.roles,`roleName`):{},[t]),[d,f]=(0,B.useState)(!1);return(0,z.jsx)(J,{onOpenChange:d?r:e,open:n,children:(0,z.jsxs)(Y,{className:`sm:max-w-[750px]`,children:[(0,z.jsx)(Uo,{children:(0,z.jsxs)(Z,{children:[o?`Edit `:`View `,` `,t.email,` `,c?`(yourself)`:``]})}),o&&(0,z.jsxs)(Wo,{children:[`To remove `,c?`your self`:`this user`,` from the organization, uncheck all of the boxes below.`]}),l.map(e=>(0,z.jsx)(du,{readOnly:!o,canRemove:s,data:t,orgRole:e,selectedRoles:u,setChangesMade:f},e.id))]})})}function pu(e,t){return e.email>t.email?1:-1}function mu(){let e=Or(),{organizationId:t,orgUserId:n}=k({strict:!1}),{update:r}=Xi(t),{data:i,refetch:a,isFetching:o,isRefetching:s}=fe(zl(t)),c=(0,B.useMemo)(()=>{let e={};for(let t of i)if(t.users)for(let n of t.users)e[n.id]||(e[n.id]={...n,roles:[]}),e[n.id].roles.push(t);return Object.values(e).sort(pu)},[i]),l=(0,B.useMemo)(()=>c?.find(e=>e.id===n),[c,n]),u=(0,B.useCallback)(t=>{e({to:[n?`..`:``,t].filter(Boolean).join(`/`)})},[n,e]),d=!!n&&!!l,[f,p]=(0,B.useState)(!1),[m]=(0,B.useState)({attribute:`email`,descending:!1}),h=(0,B.useMemo)(()=>[{desc:m.descending,id:m.attribute}],[m]),_=(0,B.useCallback)(()=>{p(!0)},[p]),v=(0,B.useCallback)(()=>{a(),p(!1)},[a,p]),y=(0,B.useCallback)(e=>{u(e.original.id)},[u]),b=(0,B.useCallback)(()=>{u(void 0)},[u]),x=(0,B.useCallback)(()=>{a(),u(void 0)},[u,a]),S=Nl(a);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(No,{}),(0,z.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,z.jsxs)(B.Suspense,{fallback:(0,z.jsx)(ms,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,z.jsxs)(Ol,{data:c,isFetching:o||s,columns:tu,onRowClick:y,sortingState:h,children:[(0,z.jsxs)(g,{variant:`defaultOutline`,onClick:S,accessKey:`r`,disabled:o||s,children:[(0,z.jsx)($e,{}),` `,(0,z.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,z.jsx)(`u`,{children:`R`}),`efresh`]})]}),r&&(0,z.jsxs)(g,{variant:`positiveOutline`,onClick:_,accessKey:`a`,disabled:f,children:[(0,z.jsx)(ge,{}),` `,(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`u`,{children:`A`}),`dd`]})]})]}),r&&(0,z.jsx)(su,{isModalOpen:f,onChangesSaved:v,setIsModalOpen:p}),d&&(0,z.jsx)(fu,{closeModal:b,data:l,isModalOpen:d,onUserUpdated:x})]})})]})}var hu=E({couponId:C().nonempty({message:`Please enter a coupon ID.`}).trim()});async function gu({organizationId:e,couponId:t}){let{data:n}=await s.post(`/Coupon`,{organizationId:e,couponId:t},{validateStatus:e=>e>=200&&e<400||e===400||e===409});return n}function _u(){return A({mutationFn:gu})}function vu({organizationId:e,organizationName:t,isOpen:n,onClose:r}){let{mutate:i,isPending:a}=_u(),o=j({resolver:F(hu),defaultValues:{couponId:``}}),{handleSubmit:s,control:c,reset:l}=o;(0,B.useEffect)(()=>{n&&l({couponId:``})},[n,l]);let u=(0,B.useCallback)(n=>{i({organizationId:e,couponId:n.couponId},{onSuccess:i=>{i?M.error(`Error`,{description:i||`Failed to add coupon.`}):(M.success(`Success`,{description:`Coupon "${n.couponId}" added to ${t||e}.`}),r())}})},[i,e,t,r]);return(0,z.jsx)(J,{open:n,onOpenChange:e=>!e&&r(),children:(0,z.jsxs)(Y,{children:[(0,z.jsxs)(Uo,{children:[(0,z.jsx)(Z,{children:`Add Coupon`}),(0,z.jsxs)(Wo,{children:[`Add a coupon code to`,` `,t||e,`. This coupon will be applied to the next billing cycle.`,(0,z.jsx)(`br`,{}),`Coupons can be created in our`,` `,(0,z.jsx)(`a`,{href:`https://dashboard.stripe.com/`,target:`_blank`,rel:`noreferrer`,className:`text-purple hover:underline`,children:`Stripe Dashboard`}),`.`]})]}),(0,z.jsx)(V,{...o,children:(0,z.jsxs)(`form`,{onSubmit:s(u),children:[(0,z.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,z.jsx)(U,{control:c,name:`couponId`,render:({field:e})=>(0,z.jsxs)(W,{className:`grid items-center gap-4`,children:[(0,z.jsx)(G,{children:`Coupon ID`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{...e,placeholder:`e.g. 100OFF`,disabled:a})}),(0,z.jsx)(K,{})]})})}),(0,z.jsxs)(X,{children:[(0,z.jsx)(g,{type:`button`,variant:`ghost`,onClick:r,disabled:a,children:`Cancel`}),(0,z.jsx)(g,{type:`submit`,disabled:a,children:a?`Adding...`:`Add Coupon`})]})]})})]})})}function yu({organizationRole:e,onDeleteOrgModal:t}){let{organizationId:n,organizationName:r,roleName:i}=e,{remove:a,update:o}=Yi(n),s=o,{view:c}=Xi(n),l=li(),[u,d]=(0,B.useState)(!1),f=(0,B.useCallback)(()=>{t(e)},[t,e]);return(0,z.jsxs)(hi,{className:`relative h-full justify-between`,children:[(0,z.jsxs)(pi,{children:[(0,z.jsxs)(di,{className:`flex items-center justify-between`,children:[(0,z.jsx)(`span`,{className:`truncate`,children:n}),a&&(0,z.jsxs)(qo,{children:[(0,z.jsx)(Jo,{className:`p-4 -m-4 -mr-6 hover:text-white`,children:(0,z.jsx)(Ee,{"aria-label":`Options`})}),(0,z.jsxs)(Yo,{children:[(0,z.jsx)(Qo,{className:`text-gray-600 text-xs`,children:`Options`}),(0,z.jsx)($o,{}),(0,z.jsx)(L,{to:`${n}`,children:(0,z.jsxs)(Xo,{children:[(0,z.jsx)(me,{className:`size-4 mr-2 text-blue-500`}),`Clusters`]})}),c&&(0,z.jsx)(L,{to:`${n}/roles`,children:(0,z.jsxs)(Xo,{children:[(0,z.jsx)(dt,{className:`size-4 mr-2 text-purple`}),`Roles`]})}),c&&(0,z.jsx)(L,{to:`${n}/users`,children:(0,z.jsxs)(Xo,{children:[(0,z.jsx)(tn,{className:`size-4 mr-2 text-orange-500`}),`Users`]})}),s&&(0,z.jsx)(L,{to:`${n}/billing`,children:(0,z.jsxs)(Xo,{children:[(0,z.jsx)(Rn,{className:`size-4 mr-2 text-green-500`}),`Billing`]})}),l&&(0,z.jsxs)(Xo,{onClick:()=>d(!0),children:[(0,z.jsx)(be,{className:`size-4 mr-2 text-pink-500`}),`Add Coupon`]}),(0,z.jsx)($o,{}),a&&(0,z.jsxs)(Xo,{className:`focus:bg-red/70 focus:text-white`,onClick:f,children:[(0,z.jsx)(Tt,{className:`size-4 mr-2 text-red-500`}),`Delete`]})]})]})]}),(0,z.jsx)(vi,{children:(0,z.jsx)(`h2`,{children:r})})]}),(0,z.jsxs)(gi,{className:`flex justify-between`,children:[(0,z.jsx)(Ko,{children:wa(i)}),(0,z.jsx)(L,{to:n,className:`text-sm`,"aria-label":`View ${r}`,title:`View ${r}`,children:(0,z.jsxs)(`span`,{className:`py-2 transition-all duration-100 ease-in-out border-0 hover:border-b-2`,children:[`View `,(0,z.jsx)(nn,{className:`inline-block`})]})})]}),(0,z.jsx)(vu,{organizationId:n,organizationName:r,isOpen:u,onClose:()=>d(!1)})]})}async function bu(e){let{data:t}=await s.delete(`/Organization/${e}`);return t}function xu(){return A({mutationFn:e=>bu(e)})}async function Su(e){let{data:t}=await s.post(`/Organization/`,{...e});return t}function Cu(){return A({mutationFn:e=>Su(e)})}var wu=C().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.`}),Tu=E({name:C().max(255,{error:`Name cannot be longer than 255 characters.`}),subdomain:re([ae(``),w(),wu]).optional()});function Eu(){let{user:e}=si(),t=Or(),n=j({resolver:F(Tu),defaultValues:{name:``,subdomain:``}}),{setFocus:r,watch:i}=n;(0,B.useEffect)(()=>{r(`name`)},[r]);let a=`${e?.firstname} ${e?.lastname} Org`,o=i(`name`)||a,s=i(`subdomain`),u=(0,B.useMemo)(()=>{let e=Ws(Ks(o),wu.maxLength);return{suggestedSubdomain:e,fullHostName:`future-cluster-names.${s||e}.harperfabric.com`}},[o,s]),{mutate:d,isPending:f}=Cu(),p=it(),h=(0,B.useCallback)(async e=>{d({name:e.name||a,subdomain:e.subdomain||u.suggestedSubdomain},{onSuccess:e=>{p.invalidateQueries({queryKey:l,refetchType:`active`}),c.reloadUser(m),t({to:`/${e.id}`})}})},[u.suggestedSubdomain,p,d,a,t]);return(0,z.jsx)(z.Fragment,{children:(0,z.jsx)(V,{...n,children:(0,z.jsxs)(`form`,{id:`org-add-form`,name:`org-add-form`,onSubmit:n.handleSubmit(h),className:`grid gap-6 text-white max-w-xl`,children:[(0,z.jsx)(U,{control:n.control,name:`name`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{className:`pb-1`,children:`Name`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`text`,maxLength:Tu.shape.name.maxLength,autoCapitalize:`words`,placeholder:a,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:n.control,name:`subdomain`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{className:`pb-1`,children:`Subdomain`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`text`,maxLength:wu.maxLength,autoCapitalize:`none`,placeholder:u.suggestedSubdomain,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{className:`pb-1`,children:`Full Host Name`}),(0,z.jsx)(H,{children:(0,z.jsx)(`span`,{children:u.fullHostName})}),(0,z.jsx)(K,{})]}),(0,z.jsx)(X,{children:(0,z.jsxs)(g,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:f,children:[`Create New Organization `,(0,z.jsx)(nn,{})]})})]})})})}function Du(){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(No,{}),(0,z.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,z.jsx)(Eu,{})})]})}function Ou(){let e=it(),{data:t}=fe(i()),{mutate:n,isPending:r}=xu(),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(``),d=(0,B.useCallback)(()=>u(``),[]),f=(0,B.useMemo)(()=>{let e=t?.roles||{},n=Object.values(e);return Object.keys(e).map((e,t)=>({organizationId:e,organizationName:n[t].organizationName,roleName:n[t].role})).filter(cl([`organizationId`,`organizationName`],l)).sort((e,t)=>(e.organizationName||``)>(t.organizationName||``)?1:-1)||[]},[l,t?.roles]),p=(0,B.useCallback)(e=>{u(e.currentTarget.value?.toLowerCase()||``)},[]),m=(0,B.useCallback)(t=>{t?.organizationId&&n(t.organizationId,{onSuccess:()=>{M.success(`Success`,{description:`Organization successfully deleted.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>M.dismiss()}}),e.invalidateQueries({queryKey:[]}),o(!1)},onError:()=>o(!1)})},[n,e,o]),h=(0,B.useCallback)(e=>{c(e),o(!0)},[]),{createCluster:_}=St({strict:!1});return f.length===1&&!l.length&&_?(0,z.jsx)(on,{to:`/${f[0].organizationId}/new-cluster`,replace:!0}):!f.length&&!l.length?(0,z.jsx)(Du,{}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(No,{children:(0,z.jsxs)(`div`,{className:`flex w-full justify-end gap-2`,children:[(0,z.jsx)(q,{placeholder:`Filter by name`,className:`inline-block w-full text-xs`,value:l,onChange:p}),(0,z.jsx)(L,{to:`/new-org`,children:(0,z.jsxs)(g,{variant:`positive`,accessKey:`n`,children:[(0,z.jsx)(ge,{}),(0,z.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,z.jsx)(`u`,{children:`N`}),`ew `,(0,z.jsx)(`span`,{className:`hidden md:inline-block`,children:`Organization`})]})]})})]})}),(0,z.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-12`,children:[f.map(e=>(0,z.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,z.jsx)(yu,{organizationRole:e,onDeleteOrgModal:h})},e.organizationId)),!f.length&&(0,z.jsxs)(`div`,{className:`col-span-1 md:col-span-12 text-center`,children:[(0,z.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,z.jsx)(g,{variant:`outline`,onClick:d,children:`Clear Filters`})]})]})}),s&&(0,z.jsx)(Go,{typeOfThingBeingDeleted:`organization`,nameOfThingBeingDeleted:s.organizationName,isModalOpen:a,setIsModalOpen:()=>o(!1),deletionConfirmed:()=>m(s),deletionPending:r})]})}function ku(){let{isLoading:e}=oi(),{createCluster:t}=St({strict:!1}),[,n]=us(ds.SavedClusterState,null);return(0,B.useEffect)(()=>{t&&n(t)},[t,n]),e?(0,z.jsx)(ms,{className:`fixed z-50 translate-1/2`}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`header`,{className:`fixed top-0 z-40 w-full h-20 p-4 bg-black-dark dark:bg-black-dark dark:border-b dark:border-black md:px-12`,children:(0,z.jsx)(aa,{})}),(0,z.jsx)(`main`,{children:(0,z.jsx)(Wn,{})})]})}var Au=[`/`,`/forgot-password`,`/reset-password`,`/sign-in`,`/sign-up`,`/verify-email`];function ju(){let e=ul();return!Au.includes(e)&&{redirect:e}}var Mu=I({getParentRoute:()=>Pi,id:`_dashboardLayout`,component:ku,beforeLoad:({context:e})=>{let t=e.authentication[m];if(t&&!t.isLoading&&!t.user)throw Te({to:`/sign-in`,search:ju()})}}),Nu=I({getParentRoute:()=>Mu,id:`_orgsLayout`});I({getParentRoute:()=>Nu,path:`/`,component:Ou}),I({getParentRoute:()=>Nu,path:`/new-org`,component:Du});var Pu=I({getParentRoute:()=>Nu,path:`$organizationId`,beforeLoad:async e=>({organization:await e.context.queryClient.ensureQueryData(Hs(e.params.organizationId))})});I({getParentRoute:()=>Pu,path:`/roles`,component:eu}),I({getParentRoute:()=>Pu,path:`/roles/$orgRoleId`,component:eu}),I({getParentRoute:()=>Pu,path:`/users`,component:mu}),I({getParentRoute:()=>Pu,path:`/users/$orgUserId`,component:mu}),Ll(Pu);var Fu=I({getParentRoute:()=>Pu,id:`_clusterLayout`});I({getParentRoute:()=>Fu,path:`/`,component:ll}),I({getParentRoute:()=>Pu,path:`/new-cluster`,component:il}),I({getParentRoute:()=>Lu,path:`/edit`,component:il}),I({getParentRoute:()=>Lu,path:`/edit/$mode`,component:il});function Iu(){return(0,z.jsx)(Wn,{})}var Lu=I({getParentRoute:()=>Fu,path:`$clusterId`,component:Iu,beforeLoad:async({context:e,params:t})=>({cluster:await e.queryClient.ensureQueryData(Ra(t.clusterId))})});function Ru({children:e,className:t}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(No,{}),(0,z.jsx)(`div`,{className:x(`mt-32 px-4 py-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] flex justify-center`,t),children:e})]})}var zu=new Set([`com`,`co`,`org`,`net`,`edu`,`gov`,`mil`,`me`,`biz`,`info`,`ac`,`or`,`ne`,`go`,`lg`,`asn`,`id`,`nom`,`sch`,`ltd`,`plc`]);function Bu(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&&zu.has(r)?3:2;return t.length<=i?`@`:t.slice(0,-i).join(`.`)}function Vu({cluster:{fqdn:e},domain:{domain:t,id:n}}){let r=Bu(t),[i,a,o]=os(r,e||``,n);return(0,z.jsxs)(`div`,{className:`grid gap-4 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,z.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,z.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,z.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,z.jsx)(g,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:i,children:(0,z.jsx)(O,{className:`w-3.5 h-3.5`})})]})}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,z.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,z.jsx)(g,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:a,children:(0,z.jsx)(O,{className:`w-3.5 h-3.5`})})]})}),(0,z.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-800 rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,z.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,z.jsx)(g,{type:`button`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:o,children:(0,z.jsx)(O,{className:`w-3 h-3`})})]})}),(0,z.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 Hu({certificate:e,domain:t,cluster:n}){let r=Bu(t.domain),[i,a,o]=os(r,n.fqdn||``,t.id),s=(0,B.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,z.jsxs)(`div`,{className:`w-full max-w-2xl border border-border/50 rounded-md p-4 bg-gray-900/20`,children:[(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`div`,{className:`w-full h-1.5 rounded-full overflow-clip flex shadow-sm bg-gray-800`,children:(0,z.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,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-light mt-1 italic`,children:s.text})]}),(0,z.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] text-sm`,children:[(0,z.jsx)(`div`,{className:`col-span-1 text-xs text-muted-foreground`,children:`CNAME:`}),(0,z.jsxs)(`div`,{className:`col-span-1 flex gap-2 items-center flex-wrap`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-800 px-2 py-0.5 rounded text-xs`,children:[(0,z.jsx)(`span`,{className:`truncate max-w-[150px]`,title:r,children:r}),(0,z.jsx)(g,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:i,title:`Copy Name`,children:(0,z.jsx)(O,{className:`w-3 h-3`})})]}),(0,z.jsx)(Uu,{}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-800 px-2 py-0.5 rounded text-xs`,children:[(0,z.jsx)(`span`,{className:`truncate max-w-[200px]`,title:n.fqdn||``,children:n.fqdn}),(0,z.jsx)(g,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:a,title:`Copy Target`,children:(0,z.jsx)(O,{className:`w-3 h-3`})})]})]}),(0,z.jsx)(`div`,{className:`col-span-1 text-[10px] text-muted-foreground`,children:`Domain ID:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-800/50 px-2 py-0.5 rounded text-[10px] text-muted-foreground italic`,children:[(0,z.jsx)(`span`,{className:`truncate max-w-[200px]`,children:t.id}),(0,z.jsx)(g,{type:`button`,variant:`ghost`,size:`sm`,className:`h-3 w-3 p-0`,onClick:o,title:`Copy ID`,children:(0,z.jsx)(O,{className:`w-2.5 h-2.5`})})]})})]})]})}function Uu(){return(0,z.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,z.jsx)(`path`,{d:`M5 12h14`}),(0,z.jsx)(`path`,{d:`m12 5 7 7-7 7`})]})}function Wu(e){let{enabled:t,entityId:n,databaseName:r,tableName:i,searchAttribute:a,sort:o,pageIndex:s,pageSize:c,onlyIfCached:l}=e;return P({enabled:t,queryKey:[n,r,i,`search_by_value`,a,o.attribute||`default`,o.descending||!1,s||0,c||0,l],retry:!1,staleTime:6e4,gcTime:5e3,queryFn:()=>Gu(e)})}async function Gu({instanceClient:e,databaseName:t,tableName:n,searchAttribute:r,sort:i,pageIndex:a,pageSize:o,onlyIfCached:s,headers:c}){let l=i.attribute.length&&!(i.attribute===r&&!i.descending),u=await e.post(`/`,{operation:`search_by_value`,get_attributes:[`*`],database:t,table:n,search_attribute:r,search_value:`*`,sort:l?i:void 0,offset:a*o,limit:o,onlyIfCached:s,noCacheStore:s},{timeout:0,headers:c,validateStatus:e=>e>=200&&e<400||e===404});return u.status===404?{data:[]}:u}function Ku(e){return P({queryKey:[e,`ChallengeCertificate`],queryFn:async()=>{if(!e)return[];let{data:t}=await Gu({searchAttribute:`domain`,entityId:e,databaseName:`data`,tableName:`ChallengeCertificate`,sort:{attribute:`domain`,descending:!0},instanceClient:a({id:e,forceFabricConnect:!0}),onlyIfCached:!1,pageIndex:0,pageSize:100});return t},enabled:!!e,refetchInterval:5e3})}function qu(e){return N(Ku(e))}function Ju({domain:{challengeToken:e,challengeTxtRecord:t,domain:n,id:r},cluster:{fqdn:i}}){let a=Bu(n),[o,s,c,l,u]=os(t,e,a,i||``,r);return(0,z.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,z.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,z.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`TXT`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,z.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,z.jsx)(g,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:o,children:(0,z.jsx)(O,{className:`w-3.5 h-3.5`})})]})}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Content:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,z.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,z.jsx)(g,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:s,children:(0,z.jsx)(O,{className:`w-3.5 h-3.5`})})]})}),(0,z.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,z.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,z.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,z.jsx)(g,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:c,children:(0,z.jsx)(O,{className:`w-3.5 h-3.5`})})]})}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,z.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,z.jsx)(g,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:l,children:(0,z.jsx)(O,{className:`w-3.5 h-3.5`})})]})}),(0,z.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-800 rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,z.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,z.jsx)(g,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:u,children:(0,z.jsx)(O,{className:`w-3 h-3`})})]})}),(0,z.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 Yu({clusterId:e,domainIds:t,generateDomainCerts:n}){let{data:r}=await s.put(`/Cluster/${e}`,{domainIds:t,generateDomainCerts:n},{timeout:0});return r}function Xu(){return A({mutationFn:e=>Yu(e)})}se.object({domainId:se.string()});async function Zu(e){let{data:t}=await s.delete(`/Domain/${e.domainId}`);return t}function Qu(){return A({mutationFn:e=>Zu(e)})}function $u(e){return[...new Set(e)]}var ed=fn();function td(e,t,n){let{data:r}=qu(e.id),i=(0,B.useMemo)(()=>!!r?.some(e=>!e.issueDate||e.inProgress),[r]),{mutate:a,isPending:o}=Xu(),{mutate:s,isPending:c}=Qu(),l=o||c,u=(0,B.useCallback)((t,n)=>{if(!Fo(e.status)){M.error(`Cluster is currently `+e.status,{description:`To bind a domain, it must be running.`});return}a({clusterId:e.id,domainIds:$u((e.domainIds?.slice()||[]).concat([t])),generateDomainCerts:n},{onSuccess:()=>{Oi.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),M.success(`Domain bound!`+(n?` Certificates are being generated in the background now.`:``))}})},[a,e]),d=(0,B.useCallback)(t=>{s({domainId:t},{onSuccess:()=>{Oi.invalidateQueries({queryKey:[e.organizationId,`domains`],refetchType:`active`}),M.success(`Domain removed!`)}})},[s]),f=(0,B.useCallback)(t=>{a({clusterId:e.id,domainIds:(e.domainIds?.slice()||[]).filter(e=>e!==t),generateDomainCerts:!1},{onSuccess:()=>{Oi.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),M.success(`Domain unbound!`)}})},[s]);return(0,B.useMemo)(()=>[ed.display({id:`select`,header:`Bind`,size:50,cell:r=>{let a=r.row.original;return a.status===`ACTIVE`&&!a.clusterId&&!es(e)?(0,z.jsx)(`label`,{className:`p-10 -m-10`,children:(0,z.jsx)(`input`,{type:`checkbox`,checked:t.includes(a.id),onChange:()=>n(a.id),disabled:l||i})}):null}}),ed.display({header:`Domains`,id:`domain`,enableSorting:!1,size:150,cell:e=>{let t=e.row.original;return(0,z.jsxs)(ba,{children:[(0,z.jsx)(xa,{asChild:!0,children:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{children:t.domain}),(0,z.jsx)(g,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l||!!t.clusterId,onClick:()=>d(t.id),children:`Remove Domain`})]})}),(0,z.jsx)(Sa,{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!`})]})}}),ed.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,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{children:`Bound to this cluster`}),i&&(!i.issueDate||i.inProgress)&&(0,z.jsx)(`div`,{className:`py-2`,children:(0,z.jsx)(Hu,{certificate:i,domain:n,cluster:e})}),(0,z.jsx)(g,{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,z.jsx)(Ju,{domain:n,cluster:e}):es(e)?`Cannot be associated with this self-managed cluster.`:n.status===`ACTIVE`&&!n.clusterId?(0,z.jsx)(Vu,{cluster:e,domain:n}):n.status}})],[e,u,l,r,i,t,n])}var nd=se.object({domain:se.string(),organizationId:se.string()});async function rd(e){let{data:t}=await s.post(`/Domain/`,e);return t}function id(){return A({mutationFn:e=>rd(e)})}async function ad(e){let{data:t}=await s.post(`/Domain/${e}/validate`);return t}async function od(e){let{data:t}=await s.get(`/Domain/?organizationId=${e}`);return t}function sd(e){return P({queryKey:[e,`domains`],queryFn:()=>od(e)})}function cd(){let{organizationId:e,clusterId:t}=k({strict:!1}),{data:n}=fe(Ra(t,!0)),{update:r}=Xi(e),{data:i,refetch:a,isFetching:o,isRefetching:s}=N(sd(e)),c=(0,B.useMemo)(()=>i?.filter(e=>e.status===`PENDING_VALIDATION`)||[],[i]),[l]=(0,B.useState)({attribute:`domain`,descending:!1}),d=(0,B.useMemo)(()=>[{desc:l.descending,id:l.attribute}],[l]),f=Nl(a),[p,m]=(0,B.useState)([]),h=(0,B.useCallback)(e=>{m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),{mutate:_,isPending:v}=Xu(),y=(0,B.useCallback)(()=>{if(!Fo(n.status)){M.error(`Cluster is currently `+n.status,{description:`To bind a domain, it must be running.`});return}_({clusterId:n.id,domainIds:$u((n.domainIds?.slice()||[]).concat(p)),generateDomainCerts:!0},{onSuccess:()=>{Oi.invalidateQueries({queryKey:[n.organizationId],refetchType:`active`}),M.success(`Domain(s) bound! Certificates are being generated in the background now.`),m([])}})},[n,p,_]),{mutateAsync:b,isPending:x}=id(),S=j({resolver:F(nd),defaultValues:{domain:``,organizationId:e}}),ee=(0,B.useCallback)(async e=>{if(e){let t=e.domain.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean);for(let n of t)await b({...e,domain:n});S.reset(),await a(),M.success(`${u(t.length,`Domain`,`Domains`)} added! Please add the txt record above to your domain registrar.`)}},[b,S,a]),te=(0,B.useCallback)(async()=>{let e=`Validating ${u(c.length,`domain`,`domains`)}...`,t=`validatingDomains`,n=0,r=0;for(let i of c)try{M.loading(e,{description:`${n++} of ${c.length} checked`,id:t}),await ad(i.id)}catch{r+=1}r>0?M.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(),M.success(`Validation succeeded!`,{description:`Please take a look at the next steps for newly verified domains.`,id:t}))},[c]),C=td(n,p,h),ne=S.watch(`domain`),re=(0,B.useMemo)(()=>typeof ne==`string`?ne.trim().split(`.`).length===2:!1,[ne]),w=(0,B.useCallback)(()=>{typeof ne==`string`&&S.setValue(`domain`,`${ne.trim()}, www.${ne.trim()}`)},[ne,S]);return(0,z.jsx)(Ol,{data:i||[],isFetching:o||s,columns:C,sortingState:d,children:(0,z.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,z.jsx)(V,{...S,children:(0,z.jsxs)(`form`,{id:`cluster-add-domain-form`,name:`cluster-add-domain-form`,onSubmit:S.handleSubmit(ee),className:`flex gap-1 flex-col md:flex-row`,children:[(0,z.jsx)(U,{control:S.control,name:`domain`,render:({field:e})=>(0,z.jsxs)(W,{className:`flex-1`,children:[(0,z.jsx)(G,{className:`pb-1`,children:`New Domain Name`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`text`,enterKeyHint:`done`,autoComplete:`off`,...e})}),re&&(0,z.jsxs)(`div`,{className:`mt-1 flex gap-4`,children:[`Adding an apex domain?`,(0,z.jsx)(g,{variant:`positiveOutline`,type:`button`,onClick:w,children:`Add www as well`})]}),(0,z.jsx)(K,{children:(0,z.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,z.jsxs)(`div`,{className:`flex-0 self-start flex gap-1 md:pt-6.5`,children:[(0,z.jsxs)(g,{type:`submit`,variant:`submit`,disabled:x,children:[(0,z.jsx)(ge,{}),` Add`]}),c.length>0&&(0,z.jsxs)(g,{variant:`positiveOutline`,onClick:te,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,z.jsx)(Yn,{}),` `,(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`u`,{children:`V`}),`alidate`]})]}),(0,z.jsxs)(g,{variant:`defaultOutline`,onClick:f,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,z.jsx)($e,{}),` `,(0,z.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,z.jsx)(`u`,{children:`R`}),`efresh`]})]})]})]})}),p.length>0&&(0,z.jsx)(`div`,{className:`flex-0 self-start md:pt-6.5`,children:(0,z.jsxs)(g,{variant:`submit`,onClick:y,disabled:v,children:[(0,z.jsx)(ht,{}),` Bind `,u(p.length,`Domain`,`Domains`)]})})]})})}function ld(){return(0,z.jsx)(Ru,{className:`flex flex-col justify-start max-w-4xl`,children:(0,z.jsx)(cd,{})})}var ud=E({username:Va,role:C().nonempty({error:`Please select a role.`}),password:Ba.min(8,{error:`Password must be at least 8 characters long.`}),confirmPassword:C()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});async function dd(e){await s.patch(`/ResetPasswordUpdater/${e}`)}async function fd(e){let{instanceClient:t,...n}=e,{data:r}=await t.post(`/`,{operation:`add_user`,...n});return r}function pd(){return A({mutationFn:fd})}async function md({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 hd(){return A({mutationFn:md})}async function gd({username:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_user`,username:e});return n}function _d(){return A({mutationFn:gd})}async function vd({clusterId:e,initialUsername:t,desiredUsername:n,newPassword:i,tempPassword:a,instanceClient:s}){if(!a)throw Error(`You may not have permission to set the password on this cluster.`);let c=s;try{let r=await Pa({username:t,password:a,instanceClient:c,entityId:e});return r.instanceClient&&(c=r.instanceClient),n===`HDB_ADMIN`?await md({username:n,password:i,instanceClient:c}):(await fd({username:n,password:i,role:`super_user`,active:!0,instanceClient:c}),await Pa({username:n,password:i,instanceClient:c,entityId:e}),await gd({username:o,instanceClient:c})),await dd(e),r}catch(t){throw await r({entityId:e,instanceClient:c}),t}}function yd(){return A({mutationFn:vd})}function bd(){let{user:e}=si(),{clusterId:t}=k({strict:!1}),{data:n}=N(Ra(t,!0)),r=Or(),i=(0,B.useMemo)(()=>f(n),[n]),a=mi({operationsUrl:i}),{redirect:s}=St({strict:!1}),l=Et(),u=j({resolver:F(ud),defaultValues:{confirmPassword:``,password:``,role:`super_user`,username:e?.email??``}}),{setFocus:d,control:p,handleSubmit:m}=u;(0,B.useEffect)(()=>{d(`password`)},[d]);let h=n?.instances?.find(e=>e.tempPassword)?.tempPassword,{mutate:_,isPending:v}=yd(),y=(0,B.useCallback)(async e=>{if(!i){M.error(`Cluster is not yet fully loaded, please wait a moment before trying to sign in.`);return}_({instanceClient:a,clusterId:t,newPassword:e.password,tempPassword:h,initialUsername:o,desiredUsername:e.username},{onSuccess:async({message:e,user:t})=>{M.success(e),c.setUserForEntity(n,t),l.invalidate(),await r({to:s?.startsWith(`/`)?s:`../`})}})},[n,t,a,r,i,s,l,_,h]);return n&&!n.resetPassword?(0,z.jsx)(on,{to:`../sign-in`,replace:!0}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`nav`,{className:`fixed top-20 w-full h-12 z-39 px-4 md:px-12 bg-grey-700 flex items-center`,children:(0,z.jsx)(Ea,{})}),(0,z.jsx)(`div`,{className:`items-center justify-center flex mt-32 py-4 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,z.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,z.jsx)(`h2`,{className:`text-2xl font-light`,children:`Create Admin User`}),(0,z.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,z.jsx)(V,{...u,children:(0,z.jsxs)(`form`,{id:`cluster-create-admin-form`,name:`cluster-create-admin-form`,onSubmit:m(y),className:`my-4`,children:[(0,z.jsx)(U,{control:p,name:`username`,render:({field:e})=>(0,z.jsxs)(W,{className:`my-4`,children:[(0,z.jsx)(G,{children:`Username`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{autoComplete:`username`,type:`text`,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:p,name:`password`,render:({field:e})=>(0,z.jsxs)(W,{className:`my-4`,children:[(0,z.jsx)(G,{children:`Password`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`password`,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:p,name:`confirmPassword`,render:({field:e})=>(0,z.jsxs)(W,{className:`my-4`,children:[(0,z.jsx)(G,{children:`Confirm Password`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`password`,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(g,{disabled:v,type:`submit`,variant:`submit`,className:`w-full my-2 rounded-full`,children:`Create Admin User`})]})}),(0,z.jsxs)(`p`,{className:`text-muted-foreground flex gap-2 align-middle`,children:[(0,z.jsx)(un,{size:36,className:`flex-none`}),(0,z.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 xd({columns:e,data:t}){let n=pr({data:t,columns:e,getCoreRowModel:Hn()});return(0,z.jsx)(`div`,{className:`bg-black-dark rounded-md`,children:(0,z.jsxs)(xl,{children:[(0,z.jsx)(Sl,{children:n.getHeaderGroups().map(e=>(0,z.jsx)(wl,{className:`border-none`,children:e.headers.map(e=>(0,z.jsx)(Tl,{className:`p-4`,style:{width:`${e.getSize()}%`},children:e.isPlaceholder?null:er(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,z.jsx)(Cl,{className:`bg-black`,children:n.getRowModel().rows?.length?n.getRowModel().rows.map(e=>(0,z.jsx)(wl,{"data-state":e.getIsSelected()&&`selected`,className:`hover:bg-muted/10 data-[state=selected]:bg-muted`,children:e.getVisibleCells().map(e=>(0,z.jsx)(Dl,{className:`p-4`,style:{width:`${e.column.getSize()}%`},children:er(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,z.jsx)(wl,{children:(0,z.jsx)(Dl,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function Sd(){return(0,z.jsx)(`div`,{className:`flex-col items-center justify-center px-16 space-y-3 text-center pt-30`,children:(0,z.jsx)(`p`,{children:`No instances found.`})})}function Cd({isSelfManaged:e,instance:t}){let{user:i,isLoading:a}=ci(t.id),o=mi({operationsUrl:(0,B.useMemo)(()=>n(t),[t])}),{update:s}=$i(),l=c.checkForFabricConnect(t.id),u=(0,B.useCallback)(async()=>{await r({instanceClient:o,entityId:t.id}),c.setUserForEntity(t,null)},[t,o]);return a||![`CLONE_READY`,`RUNNING`,`UPDATED`].includes(t.status)?(0,z.jsx)(hr,{className:`animate-spin`,color:`gray`}):!i||l?(0,z.jsxs)(`span`,{className:`flex gap-4`,children:[s&&!e&&(0,z.jsx)(L,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Connect to ${t.name} instance`,title:`Connect to ${t.name} instance`,children:(0,z.jsx)(g,{variant:`positiveOutline`,children:`Fabric Connect`})}),(0,z.jsx)(L,{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,z.jsx)(g,{variant:s?`defaultOutline`:`positiveOutline`,children:`Direct Sign In`})})]}):(0,z.jsxs)(`span`,{className:`flex gap-4`,children:[(0,z.jsx)(L,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Go to ${t.name} instance`,title:`Go to ${t.name} instance`,children:(0,z.jsx)(g,{variant:`positiveOutline`,children:`Direct Connect`})}),(0,z.jsx)(g,{variant:`destructiveOutline`,className:`text-sm`,"aria-label":`Sign out from ${t.name} instance`,title:`Sign out from ${t.name} instance`,onClick:u,children:`Direct Sign Out`})]})}function wd({entityId:e,instanceClient:t},n){return P({queryKey:[e,`get_status`],staleTime:9e3,refetchInterval:1e4,retryDelay:1e4,throwOnError:!1,enabled:n,queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`get_status`});return e}})}function Td(e,t){return e?.systemStatus?.find(e=>e.id===t)?.status}async function Ed({instanceClient:e,id:t,status:n}){let{data:r}=await e.post(`/`,{operation:`set_status`,id:t,status:n});return r}function Dd(){return A({mutationFn:Ed,onSuccess:(e,t)=>Oi.invalidateQueries({queryKey:[t.entityId,`get_status`]})})}function Od({instance:e,index:t}){let{update:r}=$i(),i=R({operationsUrl:(0,B.useMemo)(()=>n(e),[e]),instanceId:e.id,forceFabricConnect:!0}),{mutate:a,isPending:o}=Dd(),[s,c]=(0,B.useState)(!1);(0,B.useEffect)(()=>{let e=setTimeout(()=>c(!0),t*500);return()=>clearTimeout(e)},[t]);let{data:l,isLoading:u,isFetching:d}=N(wd(i,s&&r)),f=Td(l,`availability`)||`Unknown`,p=f===`Available`,m=f===`Unavailable`;return r?(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsxs)(ba,{children:[(0,z.jsx)(xa,{asChild:!0,children:(0,z.jsx)(`div`,{className:`flex items-center`,children:u||!s||d&&!l?(0,z.jsx)(hr,{className:`animate-spin size-5 text-muted-foreground`}):(0,z.jsx)(Ko,{variant:p?`success`:m?`destructive`:`default`,className:`size-4 rounded-full p-0`,children:(0,z.jsx)(`span`,{className:`sr-only`,children:p?`Online`:`Offline`})})})}),(0,z.jsxs)(Sa,{children:[d&&l?`Refreshing... `:``,f]})]}),r&&(0,z.jsxs)(`div`,{className:`flex gap-1`,children:[p&&(0,z.jsxs)(ba,{children:[(0,z.jsx)(xa,{asChild:!0,children:(0,z.jsx)(g,{type:`button`,variant:`destructiveGhost`,size:`icon`,onClick:()=>a({...i,id:`availability`,status:`Unavailable`}),disabled:o,children:o?(0,z.jsx)(hr,{className:`animate-spin size-4`}):(0,z.jsx)(we,{className:`size-4`})})}),(0,z.jsx)(Sa,{children:`Bring out of rotation`})]}),m&&(0,z.jsxs)(ba,{children:[(0,z.jsx)(xa,{asChild:!0,children:(0,z.jsx)(g,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>a({...i,id:`availability`,status:`Available`}),disabled:o,children:o?(0,z.jsx)(hr,{className:`animate-spin size-4`}):(0,z.jsx)(dt,{className:`size-4`})})}),(0,z.jsx)(Sa,{children:`Bring back into rotation`})]})]})]}):null}function kd(){let{clusterId:e}=k({strict:!1}),{data:t,isLoading:n}=N(Ra(e,!0)),r=es(t),i=(0,B.useMemo)(()=>[{id:`instanceActions`,size:1,minSize:1,cell:e=>(0,z.jsx)(`div`,{className:`flex justify-end gap-2 items-center`,children:(0,z.jsx)(Cd,{isSelfManaged:r,instance:e.row.original})})},r&&{accessorKey:`instanceFqdn`,size:90,header:`URL`,cell:e=>Zc({secure:e.row.original.operationsApiSecure?`true`:`false`,port:e.row.original.operationsApiPort,fqdn:e.row.original.instanceFqdn})},!r&&{accessorKey:`name`,size:90,header:`Name`},{accessorKey:`status`,header:`Status`,size:1,minSize:1,cell:e=>{let t=e.getValue();return(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(Od,{instance:e.row.original,index:e.row.index}),t?(0,z.jsx)(Ko,{variant:Po(t),children:wa(t)}):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,z.jsxs)(z.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`}].filter(ui),[r]),a=(0,B.useMemo)(()=>t?.instances?t.instances.filter(e=>e.status&&!Ma.includes(e.status)).sort(Ts):[],[t]);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(No,{}),(0,z.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,z.jsx)(hi,{className:`p-0 mt-4 min-h-96`,children:(0,z.jsx)(gi,{className:`p-0 min-h-96`,children:n?(0,z.jsx)(_c,{}):a.length?(0,z.jsx)(xd,{data:a,columns:i}):(0,z.jsx)(Sd,{})})})})]})}function Ad(){let{clusterId:e}=k({strict:!1}),{data:t,isLoading:n}=N(Ra(e,2e3)),r=t?.status,i=(0,B.useMemo)(()=>r&&ja.includes(r),[r]);return n||!t?(0,z.jsx)(Ru,{className:`flex justify-center`,children:(0,z.jsx)(_c,{})}):i?(0,z.jsx)(Ru,{className:`flex justify-center`,children:(0,z.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,z.jsx)(`h1`,{className:`text-xl text-center`,children:`All done!`}),(0,z.jsx)(rs,{cluster:t,forceProgressBarVisible:!0}),(0,z.jsx)(`p`,{children:`Your cluster finished updating, and is ready for interaction.`}),(0,z.jsx)(`div`,{className:`text-center`,children:(0,z.jsx)(ts,{cluster:t})})]})}):(0,z.jsx)(Ru,{className:`flex justify-center`,children:(0,z.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,z.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,z.jsx)(rs,{cluster:t,forceProgressBarVisible:!0}),(0,z.jsxs)(`p`,{children:[`Your cluster is updating with the latest changes. This includes waiting several minutes to let traffic drain safely.`,` `,(0,z.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,z.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 jd(){let e=Et(),{clusterId:t}=k({strict:!1}),{data:n,isLoading:r}=N(Ra(t,2e3)),i=n?.status,a=(0,B.useMemo)(()=>i&&ja.includes(i),[i]),o=Io(i),[,s]=us(ds.SavedClusterState,null),c=(0,B.useCallback)(()=>{s(n),e.navigate({to:`/${n.organizationId}/new-cluster`})},[n,e,s]);return r||!n?(0,z.jsx)(Ru,{className:`flex justify-center`,children:(0,z.jsx)(_c,{})}):o?(0,z.jsx)(Ru,{className:`flex justify-center`,children:(0,z.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4 items-center`,children:[(0,z.jsx)(Ae,{className:`w-24 h-24`}),(0,z.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,z.jsx)(ps,{}),` if you want more help.`]}),(0,z.jsx)(g,{type:`button`,variant:`positiveOutline`,onClick:c,children:`Try Again`})]})}):a?(0,z.jsx)(Ru,{className:`flex justify-center`,children:(0,z.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,z.jsx)(`h1`,{className:`text-xl text-center`,children:`It's ready!`}),(0,z.jsx)(rs,{cluster:n,forceProgressBarVisible:!0}),(0,z.jsxs)(`p`,{children:[`Let's set up your secure, browser-to-cluster connection now.`,` `,(0,z.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,z.jsx)(`em`,{children:`Direct Connect`}),`! Once you create your user, you will have the option to`,` `,(0,z.jsx)(`em`,{children:`Fabric Connect`}),` from your Fabric account without having to sign in again.`]})]}),(0,z.jsx)(`div`,{className:`text-center`,children:(0,z.jsx)(ts,{cluster:n})})]})}):(0,z.jsx)(Ru,{className:`flex justify-center`,children:(0,z.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,z.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,z.jsx)(rs,{cluster:n,forceProgressBarVisible:!0}),(0,z.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,z.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,z.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.`]})]})]})})}I({getParentRoute:()=>Lu,path:`instances`,component:kd}),I({getParentRoute:()=>Lu,path:`starting-up`,component:jd}),I({getParentRoute:()=>Lu,path:`scaling`,component:Ad}),I({getParentRoute:()=>Lu,path:`domains`,component:ld}),I({getParentRoute:()=>Lu,path:`sign-in`,component:Ja,beforeLoad:({context:e,location:t,params:n})=>{let r=c.checkForFabricConnect(n.clusterId);if(e.authentication[n.clusterId]?.user&&!r){let e=t?.search;throw Te({to:e?.redirect?.startsWith(`/`)?e.redirect:`../`})}}}),I({getParentRoute:()=>Lu,path:`instance/$instanceId/sign-in`,component:Ja,beforeLoad:({context:e,location:t,params:n})=>{if(!(c.checkForFabricConnect(n.clusterId)||c.checkForFabricConnect(n.instanceId))&&e.authentication[n.instanceId]?.user){let e=t?.search;throw Te({to:e?.redirect?.startsWith(`/`)?e.redirect:`../`})}}}),I({getParentRoute:()=>Lu,path:`finish-setup`,component:bd});function Md(e){return I({getParentRoute:()=>e,path:`apis`}).lazy(()=>yi(()=>import(`./index.lazy-De4JGuec.js`).then(e=>e.route),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])))}function Nd(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 Pd(e,t){let[n,r]=(0,B.useState)(t),[i,a]=(0,B.useState)(e);return(0,B.useEffect)(()=>{Nd(n,t)||(r(t),a(e))},[n,t,e]),Nd(n,t)?[i,a]:[e,a]}var Fd={};function Id(e,t,n){let r=(0,B.useCallback)((e,n)=>t(e,n),[n]);(0,B.useEffect)(()=>(Fd[e]||(Fd[e]=[]),Fd[e].push(r),function(){let t=Fd[e].indexOf(r);t>=0&&Fd[e].splice(t,1)}),[e,t,r])}function Ld(e,t,n){let r=Fd[e];if(r)for(let e of r)e(t,n)}function Rd(e,t,n){return r=>Ld(e,t,n??r)}function zd(e,t,n){return(0,B.useCallback)(r=>Ld(e,t,n??r),[e,t,n])}function Bd(e,t){return ss(sessionStorage.getItem(String(e)))??t}function Vd(e,t){t==null?sessionStorage.removeItem(String(e)):sessionStorage.setItem(String(e),JSON.stringify(t))}function Hd(e,t){let n=Pd(Bd(e,t),[e]),[r,i]=n;return(0,B.useEffect)(()=>{Vd(e,r),Ld(`Session:${e}`,r)},[e,r]),Id(`Session:${e}`,function(e){r!==e&&i(e)},[r,e,t]),(0,B.useEffect)(function(){let n=n=>{n.key===e&&i(Bd(e,t))};return window.addEventListener(`storage`,n),()=>{window.removeEventListener(`storage`,n)}},[e,i,t]),n}function Ud(e,t=!1){let[n,r]=Hd(e,t),i=(0,B.useCallback)(e=>{e?.preventDefault?.(),r(e=>!e)},[r]),a=(0,B.useCallback)(e=>{e?.preventDefault?.(),r(!0)},[r]),o=(0,B.useCallback)(e=>{e?.preventDefault?.(),r(!1)},[r]);return(0,B.useMemo)(()=>({toggled:n,setToggled:r,toggle:i,toggleOn:a,toggleOff:o}),[i,r,o,a,n])}var Wd=(0,B.createContext)(null);function Gd(){return(0,B.useContext)(Wd)}async function Kd({file:e,project:t,entityType:n,instanceClient:r}){let{data:i}=await r.post(`/`,{operation:`drop_component`,file:e||void 0,project:t,replicated:n===`cluster`});return i}function qd(e){let t=(e||``)?.split(`.`);return t.length>1?t.slice(-1)[0]:``}function Jd(e){switch(qd(e).toLowerCase()){case`jpg`:case`jpeg`:case`gif`:case`png`:case`pneg`:case`webp`:return!0;default:return!1}}async function Yd({instanceClient:e,file:t,project:n,encoding:r}){let{data:i}=await e.post(`/`,{operation:`get_component_file`,project:n,file:t,encoding:r??(Jd(t)?`base64`:`utf8`)});return{project:n,file:t,...i}}function Xd(e){return P({queryKey:Zd(e),queryFn:()=>Yd(e),enabled:!!e.file&&!!e.project,retry:!1})}function Zd(e){return[e.entityId,`get_component_file`,e.project,e.file,e.encoding]}async function Qd({file:e,payload:t,project:n,entityType:r,instanceClient:i,encoding:a}){let{data:o}=await i.post(`/`,{operation:`set_component_file`,file:e,payload:t,project:n,encoding:a,replicated:r===`cluster`},{timeout:3e5});return o}function $d(){return A({mutationFn:Qd})}function ef(){let{reloadRootEntries:e,setFocusedItem:t,setSelectedItems:n}=Gd(),r=R();return(0,B.useCallback)(async i=>{let a=!1,o=i.filter(e=>e.from!==e.to);if(o.length===0)return;let s=`Renaming ${u(o.length,`File`,`Files`)}`,c={duration:6e4,action:{label:`Cancel`,onClick:()=>{a=!0}}};c.id=M.loading(s,{...c,description:(0,z.jsx)(Fs,{animated:!0,width:`0%`})});let l=o.length*3,d=0;function f(){d+=1,M.loading(s,{...c,description:(0,z.jsx)(Fs,{animated:!0,width:(d===0?0:d/l*100)+`%`})})}for(let e of o){let t=e.from.split(`/`),n=t.shift(),i=t.join(`/`),o=e.to.split(`/`),s=o.shift(),c=o.join(`/`),l=await Yd({...r,file:i,project:n,encoding:`base64`});if(a||(f(),await Qd({...r,file:c,project:s,encoding:`base64`,payload:l.message}),a)||(f(),await Kd({...r,file:i,project:n}),a))break;f()}d>=l?M.success(`Renamed ${u(o.length,`File`,`Files`)}`,{id:c.id,description:`All done!`,duration:3e3,action:{label:`OK`,onClick:()=>{}}}):M.warning(`Rename Cancelled`,{id:c.id,description:`${d} of ${l} steps completed.`,duration:1e4,action:{label:`OK`,onClick:()=>{}}}),e(),n(e=>{let t=e.slice();for(let e of o){let n=t.indexOf(e.from);n>=0?t.splice(n,1,e.to):t.push(e.to)}return t}),t(e=>{for(let t of o)if(e===t.from)return t.to;return e})},[r,e,t,n])}function tf(e,t){return e[t]!==void 0}function nf(e){return t=>tf(t,e)}function rf(e,t){let[n,r]=(0,B.useState)({value:t});return Id(e,(e,t)=>r({value:e,trigger:t}),[r]),n}function af(e,t,n){Ld(e,t,n)}function of(e,t,n){return r=>af(e,t,n??r)}function sf(e,t,n){return(0,B.useCallback)(r=>{af(e,t,n??r)},[e,t,n])}var cf=[{handleGlobal(e,t){if((t.cmd||t.ctrl)&&e===`Delete`)return af(`ShowDeleteDirectoryOrFileModal`,!0),!0},addEditorAction(e){return{id:`delete-file`,label:`Delete File`,keybindings:[e.KeyMod.CtrlCmd|e.KeyCode.Delete],run:of(`ShowDeleteDirectoryOrFileModal`,!0)}}},{handleGlobal(e,t){if(t.ctrl&&t.alt&&t.shift&&e===`˜`)return af(`ShowAddDirectoryOrFileModalType`,`directory`),!0},addEditorAction(e){return{id:`new-directory`,label:`New Directory`,keybindings:[e.KeyMod.WinCtrl|e.KeyMod.Alt|e.KeyMod.Shift|e.KeyCode.KeyN],run:of(`ShowAddDirectoryOrFileModalType`,`directory`)}}},{handleGlobal(e,t){if(t.ctrl&&e===`n`)return af(`ShowAddDirectoryOrFileModalType`,`file`),!0},addEditorAction(e){return{id:`new-file`,label:`New File`,keybindings:[e.KeyMod.WinCtrl|e.KeyCode.KeyN],run:of(`ShowAddDirectoryOrFileModalType`,`file`)}}},{handleGlobal(e){if(e===`F2`)return af(`ShowRenameFileModal`,`file`),!0},addEditorAction(e){return{id:`rename-file`,label:`Rename File`,keybindings:[e.KeyMod.WinCtrl|e.KeyMod.Alt|e.KeyCode.KeyR,e.KeyCode.F2],run:of(`ShowRenameFileModal`,!0)}}},{addEditorAction(){return{id:`revert-file`,label:`Revert File`,run:Rd(`RevertChanges`,!0)}}},{handleGlobal(e,t){if(t.cmd&&e===`s`)return Ld(`SaveFile`,!0),!0},addEditorAction(e){return{id:`save-file`,label:`Save Changes`,keybindings:[e.KeyMod.CtrlCmd|e.KeyCode.KeyS],run:Rd(`SaveFile`,!0)}}}],lf=cf.filter(nf(`addEditorAction`)),uf=cf.filter(nf(`handleGlobal`));function df(e){let[t,n]=e,r=lf.map(e=>t.addAction(e.addEditorAction(n)));return()=>{for(let e of r)e?.dispose()}}function ff(){(0,B.useEffect)(()=>(document.addEventListener(`keydown`,pf),()=>{document.removeEventListener(`keydown`,pf)}),[])}function pf(e){let t={cmd:e.getModifierState(`Meta`),alt:e.getModifierState(`Alt`),shift:e.getModifierState(`Shift`),ctrl:e.getModifierState(`Control`)};for(let n of uf)if(n.handleGlobal(e.key,t)){e.preventDefault();return}}function mf(e){return e.split(`/`).pop()}function hf(...e){let t=e.flat(1);return t.map((e,n)=>typeof e==`string`?gf(e,n!==0,n!==t.length-1):e).join(`/`)}function gf(e,t=!0,n=!0){let r=t&&e[0]===`/`,i=n&&e[e.length-1]===`/`;return r&&i?e.slice(1,-1):r?e.slice(1):i?e.slice(0,-1):e}function _f(e){return!!e?.entries}var vf=`__root__`,yf=`importedApplications`,bf=`newApplication`;function xf(e){let t={},n=[],r=[],i=[];for(let a of e)_f(a)?a.package?r.push(a.path):n.push(a.path):i.push(a.path),Sf(t,a);return t[vf]={index:vf,isFolder:!0,children:[bf,yf,...n,...i].filter(ui),data:void 0,canMove:!1,canRename:!1},t[yf]={index:yf,isFolder:!0,children:r,data:{name:`Imported Applications`,path:yf,package:yf,project:``,entries:[]},canMove:!1,canRename:!1},t[bf]={index:bf,isFolder:!1,data:{name:`New Application`,path:bf,project:``},canMove:!1,canRename:!1},{items:t,rootId:vf}}function Sf(e,t){let n=t.path;if(_f(t)){let r=t,i=[],a=[];for(let e of r.entries)_f(e)?i.push(e.path):a.push(e.path);e[n]={index:n,isFolder:!0,children:[...i,...a],data:t,canMove:!1,canRename:!1};for(let t of r.entries)Sf(e,t)}else e[n]={index:n,isFolder:!1,data:t,canMove:!t.package,canRename:!t.package}}function Cf(){let[e,t]=(0,B.useState)(!1),[n,r]=(0,B.useState)(void 0),i=(0,B.useCallback)(e=>{if(!e.dataTransfer?.types?.includes(`Files`))return;let n=e.target;if(n instanceof Element&&n.classList.contains(`rct-tree-item-button-isFolder`)){let e=n.getAttribute(`data-rct-item-id`);!n.querySelector(`.packageIsLocked`)&&e&&e!==`importedApplications`&&e!==`newApplication`&&r(e=>e===n?e:(e?.classList?.remove?.(`rct-tree-item-title-container-dragging-over`),n.classList.add(`rct-tree-item-title-container-dragging-over`),n))}t(!0)},[]),a=(0,B.useCallback)(()=>{t(!1),r(e=>{e&&e.classList.remove(`rct-tree-item-title-container-dragging-over`)})},[]),o=(0,B.useCallback)(e=>{if(!e.dataTransfer?.types?.includes(`Files`)||e.detail===1337)return;t(!1),n&&(n.classList.remove(`rct-tree-item-title-container-dragging-over`),r(void 0));let i=document.getElementById(`dropTarget`);return i?i.dispatchEvent(new DragEvent(`drop`,{bubbles:!0,detail:1337,cancelable:!0,dataTransfer:e.dataTransfer})):!1},[n]);return(0,B.useEffect)(()=>(document.addEventListener(`dragenter`,i),document.addEventListener(`dragover`,i),document.addEventListener(`dragleave`,a),document.addEventListener(`drop`,o),()=>{document.removeEventListener(`dragenter`,i),document.removeEventListener(`dragover`,i),document.removeEventListener(`dragleave`,a),document.removeEventListener(`drop`,o)}),[i,o,a]),(0,B.useMemo)(()=>({dragging:e,dragTarget:n}),[e,n])}function wf(e){return new Promise((t,n)=>{let r=new FileReader;r.onabort=n,r.onerror=n,r.onload=t,r.readAsDataURL(e)})}function Tf(){let[e,t]=(0,B.useState)(``),{clusterId:n}=k({strict:!1}),{openedEntry:r,restrictPackageModification:i,reloadRootEntries:a,entryExists:o}=Gd(),s=!!r&&!r.package&&!i,l=R(),{dragging:d,dragTarget:f}=Cf(),p=(f?.getAttribute?.(`data-rct-item-id`))?.split?.(`/`)?.pop?.(),m=r?.project,h=!1,g;if(r?.path){let e=r.path.split(`/`),t=_f(r);h=s&&(t?e.slice(1):e.slice(1,-1)).join(`/`),g=e[e.length-(t?1:2)]}let _=(0,B.useCallback)(async(e,n)=>{let r=f?.getAttribute?.(`data-rct-item-id`)?.split?.(`/`),i=r?.length?r[0]:s?m:!1,c=r?.length?r.slice(1).join(`/`):s?h:!1;if(i===!1||i===void 0||c===!1||c===void 0)return;let d=[],p=n.slice();for(let t of e){let e=Ef(c,t);t.name.startsWith(`.`)||t.relativePath?.includes(`/.`)?p.push({file:t,errors:[{message:`Sensitive files and folders starting with . are skipped.`,code:`dot-ignored`}]}):o(`${i}/${e}`)?p.push({file:t,errors:[{message:`${e} already exists`,code:`duplicate`}]}):d.push(t)}let g=!1,_=`uploading-files`,v={label:`Cancel`,onClick:()=>{g=!0}},y={label:`OK`,onClick:()=>void 0};t(`Uploading ${u(d.length,`file`,`files`)}...`);let b=d.reduce((e,t)=>e+t.size,0),x=0,S=0;for(let e of d){S+=1,M.loading(`Upload in progress...`,{id:_,descriptionClassName:`whitespace-pre`,description:`${S} of ${u(d.length,`file`,`files`)}
11
+ `)}}];function Nl(e){return(0,B.useCallback)(async()=>{M.loading(`Refreshing...`,{id:`refreshing`});let t=Date.now();await e(),Date.now()-t<500&&await p(500),M.success(`Refreshed!`,{id:`refreshing`})},[e])}async function Pl(e){let{data:t}=await s.get(`/Invoice/${e}`);return t}function Fl(e,t){return P({queryKey:[e,`invoices`],queryFn:()=>Pl(e),retry:!1,enabled:!!e,refetchInterval:t?1e4:void 0})}function Il(){let{organizationId:e}=k({strict:!1}),{data:t}=N(Hs(e)),{data:n,refetch:r,isLoading:i,isFetching:a,isRefetching:o}=N(Fl(t?.type!==`ENTERPRISE`&&t?.id,!1)),s=Nl(r);return t?.type===`ENTERPRISE`?(0,z.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,z.jsx)(ps,{}),`, we would love to talk!`]}):i?(0,z.jsx)(ms,{centered:!0}):!n||!n.length?(0,z.jsxs)(`span`,{children:[`Your invoices will be shown here once one is available! Want to explore your solution with Harper more?`,` `,(0,z.jsx)(ps,{overEmail:!0}),`, we would love to talk!`]}):(0,z.jsx)(Ol,{data:n,columns:Ml,children:(0,z.jsxs)(g,{variant:`defaultOutline`,onClick:s,accessKey:`r`,disabled:a||o,children:[(0,z.jsx)($e,{}),(0,z.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,z.jsx)(`u`,{children:`R`}),`efresh`]})]})})}function Ll(e){let t=I({getParentRoute:()=>e,path:`billing`,component:vl}),n=I({getParentRoute:()=>t,path:`/`,component:uc}),r=I({getParentRoute:()=>t,path:`invoices`,component:Il}),i=I({getParentRoute:()=>t,path:`confirm`,component:pl});return t.addChildren([n,r,i])}async function Rl(e){let{data:t}=await s.get(`/OrganizationRole/${e}`);return t}function zl(e){return P({queryKey:[e,`roles`],queryFn:()=>Rl(e),retry:!1,refetchInterval:10*1e3})}var Bl=[{header:`Role Name`,accessorKey:`roleName`,enableSorting:!1},fn().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 Vl(e){let{data:t}=await s.post(`/Role/`,e);return t}function Hl(){return A({mutationFn:Vl})}var Ul=E({name:C().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:T(),delete:T()});E({roles:E({create:T(),delete:T(),update:T(),view:T()}),clusters:E({create:T(),delete:T(),update:T(),view:T(),resources:oe(E({id:C(),delete:T(),update:T(),view:T(),instances:E({create:T(),delete:T(),update:T(),view:T()})}))})});var Wl={roles:{create:!0,view:!0,update:!0,delete:!0},clusters:{create:!0,view:!0,update:!0,delete:!0,resources:[]}};function Gl({isModalOpen:e,setIsModalOpen:t}){let n=it(),{organizationId:r}=k({strict:!1}),[i,a]=(0,B.useState)(!0),[o,s]=(0,B.useState)(JSON.stringify(Wl,null,2)),{mutate:c,isPending:l}=Hl(),u=j({resolver:F(Ul),defaultValues:{name:``,update:!1,delete:!1}}),d=(0,B.useCallback)(e=>{a(e.length===0)},[a]),f=(0,B.useCallback)(async e=>{let a=ss(o);if(!a)return;let s={...e,...a,organizationId:r};e&&i&&c(s,{onSuccess:()=>{M.success(`Organization role added successfully!`),t(!1),n.invalidateQueries({queryKey:[r,`roles`],refetchType:`active`}),u.reset()},onError:e=>{M.error(`Failed to add organization role: ${e.message}`)}})},[i,o,c,u,n,t,r]);return(0,z.jsx)(J,{onOpenChange:t,open:e,children:(0,z.jsxs)(Y,{children:[(0,z.jsx)(Z,{children:`Add New Organization Role`}),(0,z.jsx)(Wo,{children:`Set the new organization role permissions.`}),(0,z.jsx)(V,{...u,children:(0,z.jsxs)(`form`,{id:`org-add-role-form`,name:`org-add-role-form`,className:`grid grid-cols-2 gap-4 my-4`,onSubmit:u.handleSubmit(f),children:[(0,z.jsx)(U,{control:u.control,name:`name`,render:({field:e})=>(0,z.jsxs)(W,{className:`col-span-2`,children:[(0,z.jsx)(G,{className:`pb-1`,children:`Role Name`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`text`,className:``,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:u.control,name:`update`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{className:`pb-1`,children:`Can Update Organization`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:u.control,name:`delete`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{className:`pb-1`,children:`Can Delete Organization`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(`div`,{className:`col-span-2`,children:(0,z.jsx)(rn,{theme:`vs-dark`,height:`300px`,defaultLanguage:`json`,onValidate:d,onChange:e=>{e&&s(e)},defaultValue:JSON.stringify(Wl,null,2)})}),(0,z.jsx)(X,{className:`col-span-2`,children:(0,z.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,z.jsx)(g,{variant:`destructiveOutline`,className:`rounded-full`,type:`button`,onClick:()=>t(!1),disabled:l,children:`Cancel`}),(0,z.jsx)(g,{variant:`submit`,className:`rounded-full`,disabled:l||!i||!u.formState.isValid,children:`Save Changes`})]})})]})})]})})}async function Kl({roleId:e}){let{data:t}=await s.delete(`/Role/${e}`,{id:e,deleted:!0});return t}function ql(){return A({mutationFn:({roleId:e})=>Kl({roleId:e})})}async function Jl({roleId:e,updatedRoleInfo:t}){let{data:n}=await s.put(`/Role/${e}`,t);return n}function Yl(){return A({mutationFn:({roleId:e,updatedRoleInfo:t})=>Jl({roleId:e,updatedRoleInfo:t})})}function Xl({organizationId:e,roleId:t}){return P({queryKey:[e,`roles`,t],queryFn:()=>Zl(t),refetchInterval:10*1e3})}async function Zl(e){let{data:t}=await s.get(`/Role/${e}`);return t}function Ql({onRoleDeleteClick:e,setIsConfirmingRoleDeletion:t,isRoleDeletionPending:n}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Z,{children:`Confirm Role Deletion`}),(0,z.jsx)(Wo,{children:`Are you sure you want to delete this role? This action cannot be undone.`}),(0,z.jsxs)(X,{children:[(0,z.jsx)(g,{type:`button`,variant:`defaultOutline`,className:`rounded-full`,onClick:()=>t(!1),children:`Cancel`}),(0,z.jsx)(g,{variant:`destructiveOutline`,className:`rounded-full`,onClick:e,disabled:n,children:n?`Deleting...`:`Delete Role`})]})]})}function $l({data:e,isModalOpen:t,closeModal:n}){let r=it(),{data:i}=fe(Xl({roleId:e.id,organizationId:e.organizationId})),a=si(),o=a.user&&a.user?.roles?.[e.organizationId]?.role===e.roleName,{update:s,remove:c}=Xi(e.organizationId),{mutate:l,isPending:u}=Yl(),{mutate:d,isPending:f}=ql(),[p,m]=(0,B.useState)(!1),h=j({resolver:F(Ul),defaultValues:{name:e.roleName,update:i.organization.update||!1,delete:i.organization.delete||!1}}),_=(0,B.useCallback)(()=>{d({roleId:e.id},{onSuccess:()=>{M.success(`Role deleted successfully!`),n(!0),h.reset()},onError:e=>{M.error(`Error`,{description:`Failed to delete role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>M.dismiss()}})}})},[e.id,d,h,n]),[v,y]=(0,B.useState)(!0),[b,x]=(0,B.useState)(JSON.stringify({roles:{...i.organization.roles},clusters:{...i.organization.clusters}},null,2)),S=(0,B.useCallback)(e=>{y(e.length===0)},[y]),ee=(0,B.useCallback)(async t=>{if(!s)return;let i=ss(b);if(!i)return;let a={...t,...i,organizationId:e.organizationId};b&&v&&l({roleId:e.id,updatedRoleInfo:a},{onSuccess:async()=>{M.success(`Role updated successfully!`),await r.invalidateQueries({queryKey:[e.organizationId,`roles`,e.id]}),n(!1),h.reset()},onError:e=>{M.error(`Error`,{description:`Failed to update role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>M.dismiss()}})}})},[n,e.id,e.organizationId,h,v,r,i,s,b,l]);return(0,z.jsx)(J,{onOpenChange:(0,B.useCallback)(()=>n(!1),[n]),open:t,children:(0,z.jsx)(Y,{children:p?(0,z.jsx)(Ql,{onRoleDeleteClick:_,setIsConfirmingRoleDeletion:m,isRoleDeletionPending:f}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Z,{children:[o||!s?`View`:`Edit`,` Organization Role "`,e.roleName,`"`]}),(0,z.jsx)(V,{...h,children:(0,z.jsxs)(`form`,{id:`org-edit-role-form`,name:`org-edit-role-form`,className:`grid grid-cols-2 gap-4 my-4`,onSubmit:h.handleSubmit(ee),children:[(0,z.jsx)(U,{control:h.control,name:`name`,render:({field:e})=>(0,z.jsxs)(W,{className:`col-span-2`,children:[(0,z.jsx)(G,{className:`pb-1`,children:`Role Name`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`text`,className:``,...e,disabled:!0,readOnly:!0})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:h.control,name:`update`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{className:`pb-1`,children:`Can Update Organization`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`checkbox`,className:`w-6 ml-2`,disabled:o||!s,readOnly:o||!s,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:h.control,name:`delete`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{className:`pb-1`,children:`Can Delete Organization`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`checkbox`,className:`w-6 ml-2`,disabled:o||!s,readOnly:o||!s,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(`div`,{className:`col-span-2`,children:(0,z.jsx)(rn,{theme:`vs-dark`,height:`300px`,defaultLanguage:`json`,onValidate:S,onChange:e=>{e&&x(e)},options:o||!s?{readOnly:!0}:void 0,defaultValue:b})}),!o&&(c||s)&&(0,z.jsx)(X,{className:`col-span-2`,children:(0,z.jsxs)(`div`,{className:`flex justify-between w-full`,children:[c&&(0,z.jsx)(g,{type:`button`,variant:`destructiveOutline`,className:`rounded-full`,onClick:()=>m(!0),disabled:u,children:`Delete Role`}),s&&(0,z.jsx)(g,{variant:`submit`,className:`rounded-full`,disabled:!v||u||!h.formState.isValid||!h.formState.isDirty,children:`Save Changes`})]})})]})})]})})})}function eu(){let e=Or(),t=it(),{organizationId:n,orgRoleId:r}=k({strict:!1}),{create:i}=Xi(n),{data:a,refetch:o,isFetching:s,isRefetching:c}=fe(zl(n)),l=(0,B.useMemo)(()=>a&&a?.find(e=>e.id===r),[a,r]),u=!!r&&!!l,[d,f]=(0,B.useState)(!1),p=(0,B.useCallback)(async(i,a)=>{await e({to:[r?`..`:``,i].filter(Boolean).join(`/`)}),a&&await t.invalidateQueries({queryKey:[n,`roles`],refetchType:`active`})},[r,e,t]),m=(0,B.useCallback)(()=>{f(!0)},[f]),h=(0,B.useCallback)(e=>p(e.original.id,!1),[p]),_=(0,B.useCallback)(e=>p(void 0,e),[p]),v=Nl(o);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(No,{}),(0,z.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,z.jsxs)(B.Suspense,{fallback:(0,z.jsx)(ms,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,z.jsxs)(Ol,{data:a,columns:Bl,onRowClick:h,children:[(0,z.jsxs)(g,{variant:`defaultOutline`,onClick:v,accessKey:`r`,disabled:s||c,children:[(0,z.jsx)($e,{}),(0,z.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,z.jsx)(`u`,{children:`R`}),`efresh`]})]}),i&&(0,z.jsxs)(g,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:d,children:[(0,z.jsx)(ge,{}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`u`,{children:`A`}),`dd`]})]})]}),i&&(0,z.jsx)(Gl,{isModalOpen:d,setIsModalOpen:f}),u&&(0,z.jsx)($l,{data:l,isModalOpen:u,closeModal:_})]})})]})}var tu=[{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},fn().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}],nu=se.object({email:za.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:se.string().nonempty({error:`Please select a role.`})});async function ru(e){let{data:t}=await s.post(`/OrganizationRole/`,e);return t}function iu(){return A({mutationFn:e=>ru(e)})}se.object({email:za.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:se.string().nonempty({error:`Please select a role.`})});async function au(e){let{data:t}=await s.post(`/UserInvite/`,e);return t}function ou(){return A({mutationFn:e=>au(e)})}function su({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let{organizationId:r}=k({strict:!1}),{data:i}=fe(zl(r)),[a,o]=(0,B.useState)(!1),s=j({resolver:F(nu),defaultValues:{email:``,roleId:``}}),{mutate:c,isPending:l}=iu(),{mutate:u,isPending:d}=ou(),f=(0,B.useCallback)(async e=>{e&&(a?u:c)(e,{onSuccess:()=>{let r=e.roleId;s.reset(),s.setValue(`roleId`,r),t(),M.success(`User invited successfully!`),n(!1),o(!1)},onError:e=>{e?.status===404&&o(!0)}})},[c,s,u,t,n,a]);return(0,z.jsx)(J,{onOpenChange:()=>{n(!1),o(!1),s.reset()},open:e,children:(0,z.jsx)(Y,{"aria-describedby":void 0,children:(0,z.jsx)(V,{...s,children:(0,z.jsxs)(`form`,{id:`org-add-user-form`,name:`org-add-user-form`,onSubmit:s.handleSubmit(f),className:`grid gap-4 my-4`,children:[(0,z.jsx)(Uo,{children:(0,z.jsx)(Z,{children:a?`Invite User`:`Add User`})}),(0,z.jsx)(U,{control:s.control,name:`email`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{className:`pb-1`,children:`Email`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`email`,enterKeyHint:`next`,autoComplete:`email`,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:s.control,name:`roleId`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{className:`pb-1`,children:`Roles`}),(0,z.jsx)(B.Suspense,{fallback:(0,z.jsx)(_c,{}),children:(0,z.jsx)(H,{children:(0,z.jsxs)(vc,{...e,onValueChange:t=>e.onChange(t),children:[(0,z.jsx)(xc,{className:`w-full`,children:(0,z.jsx)(bc,{placeholder:`Choose Role`})}),(0,z.jsx)(Sc,{children:(0,z.jsxs)(yc,{children:[(0,z.jsx)(Cc,{children:`Role`}),i?.map(e=>(0,z.jsx)($,{value:e.id,children:e.roleName},e.id))]})})]})})}),(0,z.jsx)(K,{})]})}),a&&(0,z.jsxs)(Wo,{className:`p-3 my-5 text-white rounded-md bg-amber-600 flex`,children:[(0,z.jsx)(Wt,{className:`inline-block size-12 pr-2`}),(0,z.jsx)(`span`,{children:`This person doesn’t have a Fabric account. Do you want to invite them?`})]}),(0,z.jsx)(X,{children:(0,z.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,z.jsxs)(g,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:l||d,children:[(0,z.jsx)(ht,{}),` `,a?`Invite User`:`Add User`]})})})]})})})})}async function cu({roleId:e,userId:t}){let{data:n}=await s.delete(`/OrganizationRole/role/${e}/user/${t}`);return n}function lu(){return A({mutationFn:({roleId:e,userId:t})=>cu({roleId:e,userId:t})})}function uu(e){let[t,n]=(0,B.useState)(e||!1);return[t,(0,B.useCallback)(e=>{n(typeof e==`boolean`?e:e.target.checked)},[])]}function du({data:e,readOnly:t,canRemove:n,orgRole:r,selectedRoles:i,setChangesMade:a}){let{mutate:o,isPending:s}=iu(),{mutate:c,isPending:l}=lu(),u=!!i[r.roleName],[d,f]=(0,B.useState)(u),[p,m]=uu(u);return(0,B.useEffect)(()=>{p!==d&&(p?o({email:e.email,roleId:r.id},{onSuccess:()=>{f(p),a(!0),M.success(`Role added successfully`)}}):c({userId:e.id,roleId:r.id},{onSuccess:()=>{f(p),a(!0),M.success(`Role removed successfully`)}}))},[o,e.email,e.id,p,r.id,c,a,d]),(0,z.jsxs)(Aa,{className:`flex`,children:[(0,z.jsx)(q,{type:`checkbox`,className:`w-6`,disabled:t||s||l||!n&&p,checked:p,onChange:m}),(0,z.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:r.roleName})]},r.id)}function fu({closeModal:e,data:t,isModalOpen:n,onUserUpdated:r}){let{organizationId:i}=k({strict:!1}),a=si(),{update:o,remove:s}=Xi(i),c=a.user?.email===t.email,{data:l}=fe(zl(i)),u=(0,B.useMemo)(()=>t.roles?Ds(t.roles,`roleName`):{},[t]),[d,f]=(0,B.useState)(!1);return(0,z.jsx)(J,{onOpenChange:d?r:e,open:n,children:(0,z.jsxs)(Y,{className:`sm:max-w-[750px]`,children:[(0,z.jsx)(Uo,{children:(0,z.jsxs)(Z,{children:[o?`Edit `:`View `,` `,t.email,` `,c?`(yourself)`:``]})}),o&&(0,z.jsxs)(Wo,{children:[`To remove `,c?`your self`:`this user`,` from the organization, uncheck all of the boxes below.`]}),l.map(e=>(0,z.jsx)(du,{readOnly:!o,canRemove:s,data:t,orgRole:e,selectedRoles:u,setChangesMade:f},e.id))]})})}function pu(e,t){return e.email>t.email?1:-1}function mu(){let e=Or(),{organizationId:t,orgUserId:n}=k({strict:!1}),{update:r}=Xi(t),{data:i,refetch:a,isFetching:o,isRefetching:s}=fe(zl(t)),c=(0,B.useMemo)(()=>{let e={};for(let t of i)if(t.users)for(let n of t.users)e[n.id]||(e[n.id]={...n,roles:[]}),e[n.id].roles.push(t);return Object.values(e).sort(pu)},[i]),l=(0,B.useMemo)(()=>c?.find(e=>e.id===n),[c,n]),u=(0,B.useCallback)(t=>{e({to:[n?`..`:``,t].filter(Boolean).join(`/`)})},[n,e]),d=!!n&&!!l,[f,p]=(0,B.useState)(!1),[m]=(0,B.useState)({attribute:`email`,descending:!1}),h=(0,B.useMemo)(()=>[{desc:m.descending,id:m.attribute}],[m]),_=(0,B.useCallback)(()=>{p(!0)},[p]),v=(0,B.useCallback)(()=>{a(),p(!1)},[a,p]),y=(0,B.useCallback)(e=>{u(e.original.id)},[u]),b=(0,B.useCallback)(()=>{u(void 0)},[u]),x=(0,B.useCallback)(()=>{a(),u(void 0)},[u,a]),S=Nl(a);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(No,{}),(0,z.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,z.jsxs)(B.Suspense,{fallback:(0,z.jsx)(ms,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,z.jsxs)(Ol,{data:c,isFetching:o||s,columns:tu,onRowClick:y,sortingState:h,children:[(0,z.jsxs)(g,{variant:`defaultOutline`,onClick:S,accessKey:`r`,disabled:o||s,children:[(0,z.jsx)($e,{}),` `,(0,z.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,z.jsx)(`u`,{children:`R`}),`efresh`]})]}),r&&(0,z.jsxs)(g,{variant:`positiveOutline`,onClick:_,accessKey:`a`,disabled:f,children:[(0,z.jsx)(ge,{}),` `,(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`u`,{children:`A`}),`dd`]})]})]}),r&&(0,z.jsx)(su,{isModalOpen:f,onChangesSaved:v,setIsModalOpen:p}),d&&(0,z.jsx)(fu,{closeModal:b,data:l,isModalOpen:d,onUserUpdated:x})]})})]})}var hu=E({couponId:C().nonempty({message:`Please enter a coupon ID.`}).trim()});async function gu({organizationId:e,couponId:t}){let{data:n}=await s.post(`/Coupon`,{organizationId:e,couponId:t},{validateStatus:e=>e>=200&&e<400||e===400||e===409});return n}function _u(){return A({mutationFn:gu})}function vu({organizationId:e,organizationName:t,isOpen:n,onClose:r}){let{mutate:i,isPending:a}=_u(),o=j({resolver:F(hu),defaultValues:{couponId:``}}),{handleSubmit:s,control:c,reset:l}=o;(0,B.useEffect)(()=>{n&&l({couponId:``})},[n,l]);let u=(0,B.useCallback)(n=>{i({organizationId:e,couponId:n.couponId},{onSuccess:i=>{i?M.error(`Error`,{description:i||`Failed to add coupon.`}):(M.success(`Success`,{description:`Coupon "${n.couponId}" added to ${t||e}.`}),r())}})},[i,e,t,r]);return(0,z.jsx)(J,{open:n,onOpenChange:e=>!e&&r(),children:(0,z.jsxs)(Y,{children:[(0,z.jsxs)(Uo,{children:[(0,z.jsx)(Z,{children:`Add Coupon`}),(0,z.jsxs)(Wo,{children:[`Add a coupon code to`,` `,t||e,`. This coupon will be applied to the next billing cycle.`,(0,z.jsx)(`br`,{}),`Coupons can be created in our`,` `,(0,z.jsx)(`a`,{href:`https://dashboard.stripe.com/`,target:`_blank`,rel:`noreferrer`,className:`text-purple hover:underline`,children:`Stripe Dashboard`}),`.`]})]}),(0,z.jsx)(V,{...o,children:(0,z.jsxs)(`form`,{onSubmit:s(u),children:[(0,z.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,z.jsx)(U,{control:c,name:`couponId`,render:({field:e})=>(0,z.jsxs)(W,{className:`grid items-center gap-4`,children:[(0,z.jsx)(G,{children:`Coupon ID`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{...e,placeholder:`e.g. 100OFF`,disabled:a})}),(0,z.jsx)(K,{})]})})}),(0,z.jsxs)(X,{children:[(0,z.jsx)(g,{type:`button`,variant:`ghost`,onClick:r,disabled:a,children:`Cancel`}),(0,z.jsx)(g,{type:`submit`,disabled:a,children:a?`Adding...`:`Add Coupon`})]})]})})]})})}function yu({organizationRole:e,onDeleteOrgModal:t}){let{organizationId:n,organizationName:r,roleName:i}=e,{remove:a,update:o}=Yi(n),s=o,{view:c}=Xi(n),l=li(),[u,d]=(0,B.useState)(!1),f=(0,B.useCallback)(()=>{t(e)},[t,e]);return(0,z.jsxs)(hi,{className:`relative h-full justify-between`,children:[(0,z.jsxs)(pi,{children:[(0,z.jsxs)(di,{className:`flex items-center justify-between`,children:[(0,z.jsx)(`span`,{className:`truncate`,children:n}),a&&(0,z.jsxs)(qo,{children:[(0,z.jsx)(Jo,{className:`p-4 -m-4 -mr-6 hover:text-white`,children:(0,z.jsx)(Ee,{"aria-label":`Options`})}),(0,z.jsxs)(Yo,{children:[(0,z.jsx)(Qo,{className:`text-gray-600 text-xs`,children:`Options`}),(0,z.jsx)($o,{}),(0,z.jsx)(L,{to:`${n}`,children:(0,z.jsxs)(Xo,{children:[(0,z.jsx)(me,{className:`size-4 mr-2 text-blue-500`}),`Clusters`]})}),c&&(0,z.jsx)(L,{to:`${n}/roles`,children:(0,z.jsxs)(Xo,{children:[(0,z.jsx)(dt,{className:`size-4 mr-2 text-purple`}),`Roles`]})}),c&&(0,z.jsx)(L,{to:`${n}/users`,children:(0,z.jsxs)(Xo,{children:[(0,z.jsx)(tn,{className:`size-4 mr-2 text-orange-500`}),`Users`]})}),s&&(0,z.jsx)(L,{to:`${n}/billing`,children:(0,z.jsxs)(Xo,{children:[(0,z.jsx)(Rn,{className:`size-4 mr-2 text-green-500`}),`Billing`]})}),l&&(0,z.jsxs)(Xo,{onClick:()=>d(!0),children:[(0,z.jsx)(be,{className:`size-4 mr-2 text-pink-500`}),`Add Coupon`]}),(0,z.jsx)($o,{}),a&&(0,z.jsxs)(Xo,{className:`focus:bg-red/70 focus:text-white`,onClick:f,children:[(0,z.jsx)(Tt,{className:`size-4 mr-2 text-red-500`}),`Delete`]})]})]})]}),(0,z.jsx)(vi,{children:(0,z.jsx)(`h2`,{children:r})})]}),(0,z.jsxs)(gi,{className:`flex justify-between`,children:[(0,z.jsx)(Ko,{children:wa(i)}),(0,z.jsx)(L,{to:n,className:`text-sm`,"aria-label":`View ${r}`,title:`View ${r}`,children:(0,z.jsxs)(`span`,{className:`py-2 transition-all duration-100 ease-in-out border-0 hover:border-b-2`,children:[`View `,(0,z.jsx)(nn,{className:`inline-block`})]})})]}),(0,z.jsx)(vu,{organizationId:n,organizationName:r,isOpen:u,onClose:()=>d(!1)})]})}async function bu(e){let{data:t}=await s.delete(`/Organization/${e}`);return t}function xu(){return A({mutationFn:e=>bu(e)})}async function Su(e){let{data:t}=await s.post(`/Organization/`,{...e});return t}function Cu(){return A({mutationFn:e=>Su(e)})}var wu=C().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.`}),Tu=E({name:C().max(255,{error:`Name cannot be longer than 255 characters.`}),subdomain:re([ae(``),w(),wu]).optional()});function Eu(){let{user:e}=si(),t=Or(),n=j({resolver:F(Tu),defaultValues:{name:``,subdomain:``}}),{setFocus:r,watch:i}=n;(0,B.useEffect)(()=>{r(`name`)},[r]);let a=`${e?.firstname} ${e?.lastname} Org`,o=i(`name`)||a,s=i(`subdomain`),u=(0,B.useMemo)(()=>{let e=Ws(Ks(o),wu.maxLength);return{suggestedSubdomain:e,fullHostName:`future-cluster-names.${s||e}.harperfabric.com`}},[o,s]),{mutate:d,isPending:f}=Cu(),p=it(),h=(0,B.useCallback)(async e=>{d({name:e.name||a,subdomain:e.subdomain||u.suggestedSubdomain},{onSuccess:e=>{p.invalidateQueries({queryKey:l,refetchType:`active`}),c.reloadUser(m),t({to:`/${e.id}`})}})},[u.suggestedSubdomain,p,d,a,t]);return(0,z.jsx)(z.Fragment,{children:(0,z.jsx)(V,{...n,children:(0,z.jsxs)(`form`,{id:`org-add-form`,name:`org-add-form`,onSubmit:n.handleSubmit(h),className:`grid gap-6 text-white max-w-xl`,children:[(0,z.jsx)(U,{control:n.control,name:`name`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{className:`pb-1`,children:`Name`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`text`,maxLength:Tu.shape.name.maxLength,autoCapitalize:`words`,placeholder:a,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:n.control,name:`subdomain`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{className:`pb-1`,children:`Subdomain`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`text`,maxLength:wu.maxLength,autoCapitalize:`none`,placeholder:u.suggestedSubdomain,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{className:`pb-1`,children:`Full Host Name`}),(0,z.jsx)(H,{children:(0,z.jsx)(`span`,{children:u.fullHostName})}),(0,z.jsx)(K,{})]}),(0,z.jsx)(X,{children:(0,z.jsxs)(g,{type:`submit`,variant:`submit`,className:`rounded-full`,disabled:f,children:[`Create New Organization `,(0,z.jsx)(nn,{})]})})]})})})}function Du(){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(No,{}),(0,z.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,z.jsx)(Eu,{})})]})}function Ou(){let e=it(),{data:t}=fe(i()),{mutate:n,isPending:r}=xu(),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(``),d=(0,B.useCallback)(()=>u(``),[]),f=(0,B.useMemo)(()=>{let e=t?.roles||{},n=Object.values(e);return Object.keys(e).map((e,t)=>({organizationId:e,organizationName:n[t].organizationName,roleName:n[t].role})).filter(cl([`organizationId`,`organizationName`],l)).sort((e,t)=>(e.organizationName||``)>(t.organizationName||``)?1:-1)||[]},[l,t?.roles]),p=(0,B.useCallback)(e=>{u(e.currentTarget.value?.toLowerCase()||``)},[]),m=(0,B.useCallback)(t=>{t?.organizationId&&n(t.organizationId,{onSuccess:()=>{M.success(`Success`,{description:`Organization successfully deleted.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>M.dismiss()}}),e.invalidateQueries({queryKey:[]}),o(!1)},onError:()=>o(!1)})},[n,e,o]),h=(0,B.useCallback)(e=>{c(e),o(!0)},[]),{createCluster:_}=St({strict:!1});return f.length===1&&!l.length&&_?(0,z.jsx)(on,{to:`/${f[0].organizationId}/new-cluster`,replace:!0}):!f.length&&!l.length?(0,z.jsx)(Du,{}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(No,{children:(0,z.jsxs)(`div`,{className:`flex w-full justify-end gap-2`,children:[(0,z.jsx)(q,{placeholder:`Filter by name`,className:`inline-block w-full text-xs`,value:l,onChange:p}),(0,z.jsx)(L,{to:`/new-org`,children:(0,z.jsxs)(g,{variant:`positive`,accessKey:`n`,children:[(0,z.jsx)(ge,{}),(0,z.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,z.jsx)(`u`,{children:`N`}),`ew `,(0,z.jsx)(`span`,{className:`hidden md:inline-block`,children:`Organization`})]})]})})]})}),(0,z.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-12`,children:[f.map(e=>(0,z.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,z.jsx)(yu,{organizationRole:e,onDeleteOrgModal:h})},e.organizationId)),!f.length&&(0,z.jsxs)(`div`,{className:`col-span-1 md:col-span-12 text-center`,children:[(0,z.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,z.jsx)(g,{variant:`outline`,onClick:d,children:`Clear Filters`})]})]})}),s&&(0,z.jsx)(Go,{typeOfThingBeingDeleted:`organization`,nameOfThingBeingDeleted:s.organizationName,isModalOpen:a,setIsModalOpen:()=>o(!1),deletionConfirmed:()=>m(s),deletionPending:r})]})}function ku(){let{isLoading:e}=oi(),{createCluster:t}=St({strict:!1}),[,n]=us(ds.SavedClusterState,null);return(0,B.useEffect)(()=>{t&&n(t)},[t,n]),e?(0,z.jsx)(ms,{className:`fixed z-50 translate-1/2`}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`header`,{className:`fixed top-0 z-40 w-full h-20 p-4 bg-black-dark dark:bg-black-dark dark:border-b dark:border-black md:px-12`,children:(0,z.jsx)(aa,{})}),(0,z.jsx)(`main`,{children:(0,z.jsx)(Wn,{})})]})}var Au=[`/`,`/forgot-password`,`/reset-password`,`/sign-in`,`/sign-up`,`/verify-email`];function ju(){let e=ul();return!Au.includes(e)&&{redirect:e}}var Mu=I({getParentRoute:()=>Pi,id:`_dashboardLayout`,component:ku,beforeLoad:({context:e})=>{let t=e.authentication[m];if(t&&!t.isLoading&&!t.user)throw Te({to:`/sign-in`,search:ju()})}}),Nu=I({getParentRoute:()=>Mu,id:`_orgsLayout`});I({getParentRoute:()=>Nu,path:`/`,component:Ou}),I({getParentRoute:()=>Nu,path:`/new-org`,component:Du});var Pu=I({getParentRoute:()=>Nu,path:`$organizationId`,beforeLoad:async e=>({organization:await e.context.queryClient.ensureQueryData(Hs(e.params.organizationId))})});I({getParentRoute:()=>Pu,path:`/roles`,component:eu}),I({getParentRoute:()=>Pu,path:`/roles/$orgRoleId`,component:eu}),I({getParentRoute:()=>Pu,path:`/users`,component:mu}),I({getParentRoute:()=>Pu,path:`/users/$orgUserId`,component:mu}),Ll(Pu);var Fu=I({getParentRoute:()=>Pu,id:`_clusterLayout`});I({getParentRoute:()=>Fu,path:`/`,component:ll}),I({getParentRoute:()=>Pu,path:`/new-cluster`,component:il}),I({getParentRoute:()=>Lu,path:`/edit`,component:il}),I({getParentRoute:()=>Lu,path:`/edit/$mode`,component:il});function Iu(){return(0,z.jsx)(Wn,{})}var Lu=I({getParentRoute:()=>Fu,path:`$clusterId`,component:Iu,beforeLoad:async({context:e,params:t})=>({cluster:await e.queryClient.ensureQueryData(Ra(t.clusterId))})});function Ru({children:e,className:t}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(No,{}),(0,z.jsx)(`div`,{className:x(`mt-32 px-4 py-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] flex justify-center`,t),children:e})]})}var zu=new Set([`com`,`co`,`org`,`net`,`edu`,`gov`,`mil`,`me`,`biz`,`info`,`ac`,`or`,`ne`,`go`,`lg`,`asn`,`id`,`nom`,`sch`,`ltd`,`plc`]);function Bu(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&&zu.has(r)?3:2;return t.length<=i?`@`:t.slice(0,-i).join(`.`)}function Vu({cluster:{fqdn:e},domain:{domain:t,id:n}}){let r=Bu(t),[i,a,o]=os(r,e||``,n);return(0,z.jsxs)(`div`,{className:`grid gap-4 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,z.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,z.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,z.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,z.jsx)(g,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:i,children:(0,z.jsx)(O,{className:`w-3.5 h-3.5`})})]})}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,z.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,z.jsx)(g,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:a,children:(0,z.jsx)(O,{className:`w-3.5 h-3.5`})})]})}),(0,z.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-800 rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,z.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,z.jsx)(g,{type:`button`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:o,children:(0,z.jsx)(O,{className:`w-3 h-3`})})]})}),(0,z.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 Hu({certificate:e,domain:t,cluster:n}){let r=Bu(t.domain),[i,a,o]=os(r,n.fqdn||``,t.id),s=(0,B.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,z.jsxs)(`div`,{className:`w-full max-w-2xl border border-border/50 rounded-md p-4 bg-gray-900/20`,children:[(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`div`,{className:`w-full h-1.5 rounded-full overflow-clip flex shadow-sm bg-gray-800`,children:(0,z.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,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-light mt-1 italic`,children:s.text})]}),(0,z.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] text-sm`,children:[(0,z.jsx)(`div`,{className:`col-span-1 text-xs text-muted-foreground`,children:`CNAME:`}),(0,z.jsxs)(`div`,{className:`col-span-1 flex gap-2 items-center flex-wrap`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-800 px-2 py-0.5 rounded text-xs`,children:[(0,z.jsx)(`span`,{className:`truncate max-w-[150px]`,title:r,children:r}),(0,z.jsx)(g,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:i,title:`Copy Name`,children:(0,z.jsx)(O,{className:`w-3 h-3`})})]}),(0,z.jsx)(Uu,{}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-800 px-2 py-0.5 rounded text-xs`,children:[(0,z.jsx)(`span`,{className:`truncate max-w-[200px]`,title:n.fqdn||``,children:n.fqdn}),(0,z.jsx)(g,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:a,title:`Copy Target`,children:(0,z.jsx)(O,{className:`w-3 h-3`})})]})]}),(0,z.jsx)(`div`,{className:`col-span-1 text-[10px] text-muted-foreground`,children:`Domain ID:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-800/50 px-2 py-0.5 rounded text-[10px] text-muted-foreground italic`,children:[(0,z.jsx)(`span`,{className:`truncate max-w-[200px]`,children:t.id}),(0,z.jsx)(g,{type:`button`,variant:`ghost`,size:`sm`,className:`h-3 w-3 p-0`,onClick:o,title:`Copy ID`,children:(0,z.jsx)(O,{className:`w-2.5 h-2.5`})})]})})]})]})}function Uu(){return(0,z.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,z.jsx)(`path`,{d:`M5 12h14`}),(0,z.jsx)(`path`,{d:`m12 5 7 7-7 7`})]})}function Wu(e){let{enabled:t,entityId:n,databaseName:r,tableName:i,searchAttribute:a,sort:o,pageIndex:s,pageSize:c,onlyIfCached:l}=e;return P({enabled:t,queryKey:[n,r,i,`search_by_value`,a,o.attribute||`default`,o.descending||!1,s||0,c||0,l],retry:!1,staleTime:6e4,gcTime:5e3,queryFn:()=>Gu(e)})}async function Gu({instanceClient:e,databaseName:t,tableName:n,searchAttribute:r,sort:i,pageIndex:a,pageSize:o,onlyIfCached:s,headers:c}){let l=i.attribute.length&&!(i.attribute===r&&!i.descending),u=await e.post(`/`,{operation:`search_by_value`,get_attributes:[`*`],database:t,table:n,search_attribute:r,search_value:`*`,sort:l?i:void 0,offset:a*o,limit:o,onlyIfCached:s,noCacheStore:s},{timeout:0,headers:c,validateStatus:e=>e>=200&&e<400||e===404});return u.status===404?{data:[]}:u}function Ku(e){return P({queryKey:[e,`ChallengeCertificate`],queryFn:async()=>{if(!e)return[];let{data:t}=await Gu({searchAttribute:`domain`,entityId:e,databaseName:`data`,tableName:`ChallengeCertificate`,sort:{attribute:`domain`,descending:!0},instanceClient:a({id:e,forceFabricConnect:!0}),onlyIfCached:!1,pageIndex:0,pageSize:100});return t},enabled:!!e,refetchInterval:5e3})}function qu(e){return N(Ku(e))}function Ju({domain:{challengeToken:e,challengeTxtRecord:t,domain:n,id:r},cluster:{fqdn:i}}){let a=Bu(n),[o,s,c,l,u]=os(t,e,a,i||``,r);return(0,z.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,z.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,z.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`TXT`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,z.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,z.jsx)(g,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:o,children:(0,z.jsx)(O,{className:`w-3.5 h-3.5`})})]})}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Content:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,z.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,z.jsx)(g,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:s,children:(0,z.jsx)(O,{className:`w-3.5 h-3.5`})})]})}),(0,z.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,z.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,z.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,z.jsx)(g,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:c,children:(0,z.jsx)(O,{className:`w-3.5 h-3.5`})})]})}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,z.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-700 rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,z.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,z.jsx)(g,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:l,children:(0,z.jsx)(O,{className:`w-3.5 h-3.5`})})]})}),(0,z.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,z.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1 bg-gray-800 rounded-md px-3 py-0.5 text-xs text-muted-foreground italic flex-1 overflow-hidden`,children:[(0,z.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,z.jsx)(g,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:u,children:(0,z.jsx)(O,{className:`w-3 h-3`})})]})}),(0,z.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 Yu({clusterId:e,domainIds:t,generateDomainCerts:n}){let{data:r}=await s.put(`/Cluster/${e}`,{domainIds:t,generateDomainCerts:n},{timeout:0});return r}function Xu(){return A({mutationFn:e=>Yu(e)})}se.object({domainId:se.string()});async function Zu(e){let{data:t}=await s.delete(`/Domain/${e.domainId}`);return t}function Qu(){return A({mutationFn:e=>Zu(e)})}function $u(e){return[...new Set(e)]}var ed=fn();function td(e,t,n){let{data:r}=qu(e.id),i=(0,B.useMemo)(()=>!!r?.some(e=>!e.issueDate||e.inProgress),[r]),{mutate:a,isPending:o}=Xu(),{mutate:s,isPending:c}=Qu(),l=o||c,u=(0,B.useCallback)((t,n)=>{if(!Fo(e.status)){M.error(`Cluster is currently `+e.status,{description:`To bind a domain, it must be running.`});return}a({clusterId:e.id,domainIds:$u((e.domainIds?.slice()||[]).concat([t])),generateDomainCerts:n},{onSuccess:()=>{Oi.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),M.success(`Domain bound!`+(n?` Certificates are being generated in the background now.`:``))}})},[a,e]),d=(0,B.useCallback)(t=>{s({domainId:t},{onSuccess:()=>{Oi.invalidateQueries({queryKey:[e.organizationId,`domains`],refetchType:`active`}),M.success(`Domain removed!`)}})},[s]),f=(0,B.useCallback)(t=>{a({clusterId:e.id,domainIds:(e.domainIds?.slice()||[]).filter(e=>e!==t),generateDomainCerts:!1},{onSuccess:()=>{Oi.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),M.success(`Domain unbound!`)}})},[s]);return(0,B.useMemo)(()=>[ed.display({id:`select`,header:`Bind`,size:50,cell:r=>{let a=r.row.original;return a.status===`ACTIVE`&&!a.clusterId&&!es(e)?(0,z.jsx)(`label`,{className:`p-10 -m-10`,children:(0,z.jsx)(`input`,{type:`checkbox`,checked:t.includes(a.id),onChange:()=>n(a.id),disabled:l||i})}):null}}),ed.display({header:`Domains`,id:`domain`,enableSorting:!1,size:150,cell:e=>{let t=e.row.original;return(0,z.jsxs)(ba,{children:[(0,z.jsx)(xa,{asChild:!0,children:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{children:t.domain}),(0,z.jsx)(g,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l||!!t.clusterId,onClick:()=>d(t.id),children:`Remove Domain`})]})}),(0,z.jsx)(Sa,{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!`})]})}}),ed.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,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{children:`Bound to this cluster`}),i&&(!i.issueDate||i.inProgress)&&(0,z.jsx)(`div`,{className:`py-2`,children:(0,z.jsx)(Hu,{certificate:i,domain:n,cluster:e})}),(0,z.jsx)(g,{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,z.jsx)(Ju,{domain:n,cluster:e}):es(e)?`Cannot be associated with this self-managed cluster.`:n.status===`ACTIVE`&&!n.clusterId?(0,z.jsx)(Vu,{cluster:e,domain:n}):n.status}})],[e,u,l,r,i,t,n])}var nd=se.object({domain:se.string(),organizationId:se.string()});async function rd(e){let{data:t}=await s.post(`/Domain/`,e);return t}function id(){return A({mutationFn:e=>rd(e)})}async function ad(e){let{data:t}=await s.post(`/Domain/${e}/validate`);return t}async function od(e){let{data:t}=await s.get(`/Domain/?organizationId=${e}`);return t}function sd(e){return P({queryKey:[e,`domains`],queryFn:()=>od(e)})}function cd(){let{organizationId:e,clusterId:t}=k({strict:!1}),{data:n}=fe(Ra(t,!0)),{update:r}=Xi(e),{data:i,refetch:a,isFetching:o,isRefetching:s}=N(sd(e)),c=(0,B.useMemo)(()=>i?.filter(e=>e.status===`PENDING_VALIDATION`)||[],[i]),[l]=(0,B.useState)({attribute:`domain`,descending:!1}),d=(0,B.useMemo)(()=>[{desc:l.descending,id:l.attribute}],[l]),f=Nl(a),[p,m]=(0,B.useState)([]),h=(0,B.useCallback)(e=>{m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),{mutate:_,isPending:v}=Xu(),y=(0,B.useCallback)(()=>{if(!Fo(n.status)){M.error(`Cluster is currently `+n.status,{description:`To bind a domain, it must be running.`});return}_({clusterId:n.id,domainIds:$u((n.domainIds?.slice()||[]).concat(p)),generateDomainCerts:!0},{onSuccess:()=>{Oi.invalidateQueries({queryKey:[n.organizationId],refetchType:`active`}),M.success(`Domain(s) bound! Certificates are being generated in the background now.`),m([])}})},[n,p,_]),{mutateAsync:b,isPending:x}=id(),S=j({resolver:F(nd),defaultValues:{domain:``,organizationId:e}}),ee=(0,B.useCallback)(async e=>{if(e){let t=e.domain.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean);for(let n of t)await b({...e,domain:n});S.reset(),await a(),M.success(`${u(t.length,`Domain`,`Domains`)} added! Please add the txt record above to your domain registrar.`)}},[b,S,a]),te=(0,B.useCallback)(async()=>{let e=`Validating ${u(c.length,`domain`,`domains`)}...`,t=`validatingDomains`,n=0,r=0;for(let i of c)try{M.loading(e,{description:`${n++} of ${c.length} checked`,id:t}),await ad(i.id)}catch{r+=1}r>0?M.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(),M.success(`Validation succeeded!`,{description:`Please take a look at the next steps for newly verified domains.`,id:t}))},[c]),C=td(n,p,h),ne=S.watch(`domain`),re=(0,B.useMemo)(()=>typeof ne==`string`?ne.trim().split(`.`).length===2:!1,[ne]),w=(0,B.useCallback)(()=>{typeof ne==`string`&&S.setValue(`domain`,`${ne.trim()}, www.${ne.trim()}`)},[ne,S]);return(0,z.jsx)(Ol,{data:i||[],isFetching:o||s,columns:C,sortingState:d,children:(0,z.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,z.jsx)(V,{...S,children:(0,z.jsxs)(`form`,{id:`cluster-add-domain-form`,name:`cluster-add-domain-form`,onSubmit:S.handleSubmit(ee),className:`flex gap-1 flex-col md:flex-row`,children:[(0,z.jsx)(U,{control:S.control,name:`domain`,render:({field:e})=>(0,z.jsxs)(W,{className:`flex-1`,children:[(0,z.jsx)(G,{className:`pb-1`,children:`New Domain Name`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`text`,enterKeyHint:`done`,autoComplete:`off`,...e})}),re&&(0,z.jsxs)(`div`,{className:`mt-1 flex gap-4`,children:[`Adding an apex domain?`,(0,z.jsx)(g,{variant:`positiveOutline`,type:`button`,onClick:w,children:`Add www as well`})]}),(0,z.jsx)(K,{children:(0,z.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,z.jsxs)(`div`,{className:`flex-0 self-start flex gap-1 md:pt-6.5`,children:[(0,z.jsxs)(g,{type:`submit`,variant:`submit`,disabled:x,children:[(0,z.jsx)(ge,{}),` Add`]}),c.length>0&&(0,z.jsxs)(g,{variant:`positiveOutline`,onClick:te,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,z.jsx)(Yn,{}),` `,(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`u`,{children:`V`}),`alidate`]})]}),(0,z.jsxs)(g,{variant:`defaultOutline`,onClick:f,accessKey:`r`,type:`button`,disabled:o||s,children:[(0,z.jsx)($e,{}),` `,(0,z.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,z.jsx)(`u`,{children:`R`}),`efresh`]})]})]})]})}),p.length>0&&(0,z.jsx)(`div`,{className:`flex-0 self-start md:pt-6.5`,children:(0,z.jsxs)(g,{variant:`submit`,onClick:y,disabled:v,children:[(0,z.jsx)(ht,{}),` Bind `,u(p.length,`Domain`,`Domains`)]})})]})})}function ld(){return(0,z.jsx)(Ru,{className:`flex flex-col justify-start max-w-4xl`,children:(0,z.jsx)(cd,{})})}var ud=E({username:Va,role:C().nonempty({error:`Please select a role.`}),password:Ba.min(8,{error:`Password must be at least 8 characters long.`}),confirmPassword:C()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});async function dd(e){await s.patch(`/ResetPasswordUpdater/${e}`)}async function fd(e){let{instanceClient:t,...n}=e,{data:r}=await t.post(`/`,{operation:`add_user`,...n});return r}function pd(){return A({mutationFn:fd})}async function md({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 hd(){return A({mutationFn:md})}async function gd({username:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_user`,username:e});return n}function _d(){return A({mutationFn:gd})}async function vd({clusterId:e,initialUsername:t,desiredUsername:n,newPassword:i,tempPassword:a,instanceClient:s}){if(!a)throw Error(`You may not have permission to set the password on this cluster.`);let c=s;try{let r=await Pa({username:t,password:a,instanceClient:c,entityId:e});return r.instanceClient&&(c=r.instanceClient),n===`HDB_ADMIN`?await md({username:n,password:i,instanceClient:c}):(await fd({username:n,password:i,role:`super_user`,active:!0,instanceClient:c}),await Pa({username:n,password:i,instanceClient:c,entityId:e}),await gd({username:o,instanceClient:c})),await dd(e),r}catch(t){throw await r({entityId:e,instanceClient:c}),t}}function yd(){return A({mutationFn:vd})}function bd(){let{user:e}=si(),{clusterId:t}=k({strict:!1}),{data:n}=N(Ra(t,!0)),r=Or(),i=(0,B.useMemo)(()=>f(n),[n]),a=mi({operationsUrl:i}),{redirect:s}=St({strict:!1}),l=Et(),u=j({resolver:F(ud),defaultValues:{confirmPassword:``,password:``,role:`super_user`,username:e?.email??``}}),{setFocus:d,control:p,handleSubmit:m}=u;(0,B.useEffect)(()=>{d(`password`)},[d]);let h=n?.instances?.find(e=>e.tempPassword)?.tempPassword,{mutate:_,isPending:v}=yd(),y=(0,B.useCallback)(async e=>{if(!i){M.error(`Cluster is not yet fully loaded, please wait a moment before trying to sign in.`);return}_({instanceClient:a,clusterId:t,newPassword:e.password,tempPassword:h,initialUsername:o,desiredUsername:e.username},{onSuccess:async({message:e,user:t})=>{M.success(e),c.setUserForEntity(n,t),l.invalidate(),await r({to:s?.startsWith(`/`)?s:`../`})}})},[n,t,a,r,i,s,l,_,h]);return n&&!n.resetPassword?(0,z.jsx)(on,{to:`../sign-in`,replace:!0}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`nav`,{className:`fixed top-20 w-full h-12 z-39 px-4 md:px-12 bg-grey-700 flex items-center`,children:(0,z.jsx)(Ea,{})}),(0,z.jsx)(`div`,{className:`items-center justify-center flex mt-32 py-4 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,z.jsxs)(`div`,{className:`text-white w-xs`,children:[(0,z.jsx)(`h2`,{className:`text-2xl font-light`,children:`Create Admin User`}),(0,z.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,z.jsx)(V,{...u,children:(0,z.jsxs)(`form`,{id:`cluster-create-admin-form`,name:`cluster-create-admin-form`,onSubmit:m(y),className:`my-4`,children:[(0,z.jsx)(U,{control:p,name:`username`,render:({field:e})=>(0,z.jsxs)(W,{className:`my-4`,children:[(0,z.jsx)(G,{children:`Username`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{autoComplete:`username`,type:`text`,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:p,name:`password`,render:({field:e})=>(0,z.jsxs)(W,{className:`my-4`,children:[(0,z.jsx)(G,{children:`Password`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`password`,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:p,name:`confirmPassword`,render:({field:e})=>(0,z.jsxs)(W,{className:`my-4`,children:[(0,z.jsx)(G,{children:`Confirm Password`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`password`,...e})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(g,{disabled:v,type:`submit`,variant:`submit`,className:`w-full my-2 rounded-full`,children:`Create Admin User`})]})}),(0,z.jsxs)(`p`,{className:`text-muted-foreground flex gap-2 align-middle`,children:[(0,z.jsx)(un,{size:36,className:`flex-none`}),(0,z.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 xd({columns:e,data:t}){let n=pr({data:t,columns:e,getCoreRowModel:Hn()});return(0,z.jsx)(`div`,{className:`bg-black-dark rounded-md`,children:(0,z.jsxs)(xl,{children:[(0,z.jsx)(Sl,{children:n.getHeaderGroups().map(e=>(0,z.jsx)(wl,{className:`border-none`,children:e.headers.map(e=>(0,z.jsx)(Tl,{className:`p-4`,style:{width:`${e.getSize()}%`},children:e.isPlaceholder?null:er(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,z.jsx)(Cl,{className:`bg-black`,children:n.getRowModel().rows?.length?n.getRowModel().rows.map(e=>(0,z.jsx)(wl,{"data-state":e.getIsSelected()&&`selected`,className:`hover:bg-muted/10 data-[state=selected]:bg-muted`,children:e.getVisibleCells().map(e=>(0,z.jsx)(Dl,{className:`p-4`,style:{width:`${e.column.getSize()}%`},children:er(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,z.jsx)(wl,{children:(0,z.jsx)(Dl,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function Sd(){return(0,z.jsx)(`div`,{className:`flex-col items-center justify-center px-16 space-y-3 text-center pt-30`,children:(0,z.jsx)(`p`,{children:`No instances found.`})})}function Cd({isSelfManaged:e,instance:t}){let{user:i,isLoading:a}=ci(t.id),o=mi({operationsUrl:(0,B.useMemo)(()=>n(t),[t])}),{update:s}=$i(),l=c.checkForFabricConnect(t.id),u=(0,B.useCallback)(async()=>{await r({instanceClient:o,entityId:t.id}),c.setUserForEntity(t,null)},[t,o]);return a||![`CLONE_READY`,`RUNNING`,`UPDATED`].includes(t.status)?(0,z.jsx)(hr,{className:`animate-spin`,color:`gray`}):!i||l?(0,z.jsxs)(`span`,{className:`flex gap-4`,children:[s&&!e&&(0,z.jsx)(L,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Connect to ${t.name} instance`,title:`Connect to ${t.name} instance`,children:(0,z.jsx)(g,{variant:`positiveOutline`,children:`Fabric Connect`})}),(0,z.jsx)(L,{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,z.jsx)(g,{variant:s?`defaultOutline`:`positiveOutline`,children:`Direct Sign In`})})]}):(0,z.jsxs)(`span`,{className:`flex gap-4`,children:[(0,z.jsx)(L,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Go to ${t.name} instance`,title:`Go to ${t.name} instance`,children:(0,z.jsx)(g,{variant:`positiveOutline`,children:`Direct Connect`})}),(0,z.jsx)(g,{variant:`destructiveOutline`,className:`text-sm`,"aria-label":`Sign out from ${t.name} instance`,title:`Sign out from ${t.name} instance`,onClick:u,children:`Direct Sign Out`})]})}function wd({entityId:e,instanceClient:t},n){return P({queryKey:[e,`get_status`],staleTime:9e3,refetchInterval:1e4,retryDelay:1e4,throwOnError:!1,enabled:n,queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`get_status`});return e}})}function Td(e,t){return e?.systemStatus?.find(e=>e.id===t)?.status}async function Ed({instanceClient:e,id:t,status:n}){let{data:r}=await e.post(`/`,{operation:`set_status`,id:t,status:n});return r}function Dd(){return A({mutationFn:Ed,onSuccess:(e,t)=>Oi.invalidateQueries({queryKey:[t.entityId,`get_status`]})})}function Od({instance:e,index:t}){let{update:r}=$i(),i=R({operationsUrl:(0,B.useMemo)(()=>n(e),[e]),instanceId:e.id,forceFabricConnect:!0}),{mutate:a,isPending:o}=Dd(),[s,c]=(0,B.useState)(!1);(0,B.useEffect)(()=>{let e=setTimeout(()=>c(!0),t*500);return()=>clearTimeout(e)},[t]);let{data:l,isLoading:u,isFetching:d}=N(wd(i,s&&r)),f=Td(l,`availability`)||`Unknown`,p=f===`Available`,m=f===`Unavailable`;return r?(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsxs)(ba,{children:[(0,z.jsx)(xa,{asChild:!0,children:(0,z.jsx)(`div`,{className:`flex items-center`,children:u||!s||d&&!l?(0,z.jsx)(hr,{className:`animate-spin size-5 text-muted-foreground`}):(0,z.jsx)(Ko,{variant:p?`success`:m?`destructive`:`default`,className:`size-4 rounded-full p-0`,children:(0,z.jsx)(`span`,{className:`sr-only`,children:p?`Online`:`Offline`})})})}),(0,z.jsxs)(Sa,{children:[d&&l?`Refreshing... `:``,f]})]}),r&&(0,z.jsxs)(`div`,{className:`flex gap-1`,children:[p&&(0,z.jsxs)(ba,{children:[(0,z.jsx)(xa,{asChild:!0,children:(0,z.jsx)(g,{type:`button`,variant:`destructiveGhost`,size:`icon`,onClick:()=>a({...i,id:`availability`,status:`Unavailable`}),disabled:o,children:o?(0,z.jsx)(hr,{className:`animate-spin size-4`}):(0,z.jsx)(we,{className:`size-4`})})}),(0,z.jsx)(Sa,{children:`Bring out of rotation`})]}),m&&(0,z.jsxs)(ba,{children:[(0,z.jsx)(xa,{asChild:!0,children:(0,z.jsx)(g,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>a({...i,id:`availability`,status:`Available`}),disabled:o,children:o?(0,z.jsx)(hr,{className:`animate-spin size-4`}):(0,z.jsx)(dt,{className:`size-4`})})}),(0,z.jsx)(Sa,{children:`Bring back into rotation`})]})]})]}):null}function kd(){let{clusterId:e}=k({strict:!1}),{data:t,isLoading:n}=N(Ra(e,!0)),r=es(t),i=(0,B.useMemo)(()=>[{id:`instanceActions`,size:1,minSize:1,cell:e=>(0,z.jsx)(`div`,{className:`flex justify-end gap-2 items-center`,children:(0,z.jsx)(Cd,{isSelfManaged:r,instance:e.row.original})})},r&&{accessorKey:`instanceFqdn`,size:90,header:`URL`,cell:e=>Zc({secure:e.row.original.operationsApiSecure?`true`:`false`,port:e.row.original.operationsApiPort,fqdn:e.row.original.instanceFqdn})},!r&&{accessorKey:`name`,size:90,header:`Name`},{accessorKey:`status`,header:`Status`,size:1,minSize:1,cell:e=>{let t=e.getValue();return(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(Od,{instance:e.row.original,index:e.row.index}),t?(0,z.jsx)(Ko,{variant:Po(t),children:wa(t)}):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,z.jsxs)(z.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`}].filter(ui),[r]),a=(0,B.useMemo)(()=>t?.instances?t.instances.filter(e=>e.status&&!Ma.includes(e.status)).sort(Ts):[],[t]);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(No,{}),(0,z.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,z.jsx)(hi,{className:`p-0 mt-4 min-h-96`,children:(0,z.jsx)(gi,{className:`p-0 min-h-96`,children:n?(0,z.jsx)(_c,{}):a.length?(0,z.jsx)(xd,{data:a,columns:i}):(0,z.jsx)(Sd,{})})})})]})}function Ad(){let{clusterId:e}=k({strict:!1}),{data:t,isLoading:n}=N(Ra(e,2e3)),r=t?.status,i=(0,B.useMemo)(()=>r&&ja.includes(r),[r]);return n||!t?(0,z.jsx)(Ru,{className:`flex justify-center`,children:(0,z.jsx)(_c,{})}):i?(0,z.jsx)(Ru,{className:`flex justify-center`,children:(0,z.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,z.jsx)(`h1`,{className:`text-xl text-center`,children:`All done!`}),(0,z.jsx)(rs,{cluster:t,forceProgressBarVisible:!0}),(0,z.jsx)(`p`,{children:`Your cluster finished updating, and is ready for interaction.`}),(0,z.jsx)(`div`,{className:`text-center`,children:(0,z.jsx)(ts,{cluster:t})})]})}):(0,z.jsx)(Ru,{className:`flex justify-center`,children:(0,z.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,z.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,z.jsx)(rs,{cluster:t,forceProgressBarVisible:!0}),(0,z.jsxs)(`p`,{children:[`Your cluster is updating with the latest changes. This includes waiting several minutes to let traffic drain safely.`,` `,(0,z.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,z.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 jd(){let e=Et(),{clusterId:t}=k({strict:!1}),{data:n,isLoading:r}=N(Ra(t,2e3)),i=n?.status,a=(0,B.useMemo)(()=>i&&ja.includes(i),[i]),o=Io(i),[,s]=us(ds.SavedClusterState,null),c=(0,B.useCallback)(()=>{s(n),e.navigate({to:`/${n.organizationId}/new-cluster`})},[n,e,s]);return r||!n?(0,z.jsx)(Ru,{className:`flex justify-center`,children:(0,z.jsx)(_c,{})}):o?(0,z.jsx)(Ru,{className:`flex justify-center`,children:(0,z.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4 items-center`,children:[(0,z.jsx)(Ae,{className:`w-24 h-24`}),(0,z.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,z.jsx)(ps,{}),` if you want more help.`]}),(0,z.jsx)(g,{type:`button`,variant:`positiveOutline`,onClick:c,children:`Try Again`})]})}):a?(0,z.jsx)(Ru,{className:`flex justify-center`,children:(0,z.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,z.jsx)(`h1`,{className:`text-xl text-center`,children:`It's ready!`}),(0,z.jsx)(rs,{cluster:n,forceProgressBarVisible:!0}),(0,z.jsxs)(`p`,{children:[`Let's set up your secure, browser-to-cluster connection now.`,` `,(0,z.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,z.jsx)(`em`,{children:`Direct Connect`}),`! Once you create your user, you will have the option to`,` `,(0,z.jsx)(`em`,{children:`Fabric Connect`}),` from your Fabric account without having to sign in again.`]})]}),(0,z.jsx)(`div`,{className:`text-center`,children:(0,z.jsx)(ts,{cluster:n})})]})}):(0,z.jsx)(Ru,{className:`flex justify-center`,children:(0,z.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,z.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,z.jsx)(rs,{cluster:n,forceProgressBarVisible:!0}),(0,z.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,z.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,z.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.`]})]})]})})}I({getParentRoute:()=>Lu,path:`instances`,component:kd}),I({getParentRoute:()=>Lu,path:`starting-up`,component:jd}),I({getParentRoute:()=>Lu,path:`scaling`,component:Ad}),I({getParentRoute:()=>Lu,path:`domains`,component:ld}),I({getParentRoute:()=>Lu,path:`sign-in`,component:Ja,beforeLoad:({context:e,location:t,params:n})=>{let r=c.checkForFabricConnect(n.clusterId);if(e.authentication[n.clusterId]?.user&&!r){let e=t?.search;throw Te({to:e?.redirect?.startsWith(`/`)?e.redirect:`../`})}}}),I({getParentRoute:()=>Lu,path:`instance/$instanceId/sign-in`,component:Ja,beforeLoad:({context:e,location:t,params:n})=>{if(!(c.checkForFabricConnect(n.clusterId)||c.checkForFabricConnect(n.instanceId))&&e.authentication[n.instanceId]?.user){let e=t?.search;throw Te({to:e?.redirect?.startsWith(`/`)?e.redirect:`../`})}}}),I({getParentRoute:()=>Lu,path:`finish-setup`,component:bd});function Md(e){return I({getParentRoute:()=>e,path:`apis`}).lazy(()=>yi(()=>import(`./index.lazy-DN6bSQzR.js`).then(e=>e.route),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])))}function Nd(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 Pd(e,t){let[n,r]=(0,B.useState)(t),[i,a]=(0,B.useState)(e);return(0,B.useEffect)(()=>{Nd(n,t)||(r(t),a(e))},[n,t,e]),Nd(n,t)?[i,a]:[e,a]}var Fd={};function Id(e,t,n){let r=(0,B.useCallback)((e,n)=>t(e,n),[n]);(0,B.useEffect)(()=>(Fd[e]||(Fd[e]=[]),Fd[e].push(r),function(){let t=Fd[e].indexOf(r);t>=0&&Fd[e].splice(t,1)}),[e,t,r])}function Ld(e,t,n){let r=Fd[e];if(r)for(let e of r)e(t,n)}function Rd(e,t,n){return r=>Ld(e,t,n??r)}function zd(e,t,n){return(0,B.useCallback)(r=>Ld(e,t,n??r),[e,t,n])}function Bd(e,t){return ss(sessionStorage.getItem(String(e)))??t}function Vd(e,t){t==null?sessionStorage.removeItem(String(e)):sessionStorage.setItem(String(e),JSON.stringify(t))}function Hd(e,t){let n=Pd(Bd(e,t),[e]),[r,i]=n;return(0,B.useEffect)(()=>{Vd(e,r),Ld(`Session:${e}`,r)},[e,r]),Id(`Session:${e}`,function(e){r!==e&&i(e)},[r,e,t]),(0,B.useEffect)(function(){let n=n=>{n.key===e&&i(Bd(e,t))};return window.addEventListener(`storage`,n),()=>{window.removeEventListener(`storage`,n)}},[e,i,t]),n}function Ud(e,t=!1){let[n,r]=Hd(e,t),i=(0,B.useCallback)(e=>{e?.preventDefault?.(),r(e=>!e)},[r]),a=(0,B.useCallback)(e=>{e?.preventDefault?.(),r(!0)},[r]),o=(0,B.useCallback)(e=>{e?.preventDefault?.(),r(!1)},[r]);return(0,B.useMemo)(()=>({toggled:n,setToggled:r,toggle:i,toggleOn:a,toggleOff:o}),[i,r,o,a,n])}var Wd=(0,B.createContext)(null);function Gd(){return(0,B.useContext)(Wd)}async function Kd({file:e,project:t,entityType:n,instanceClient:r}){let{data:i}=await r.post(`/`,{operation:`drop_component`,file:e||void 0,project:t,replicated:n===`cluster`});return i}function qd(e){let t=(e||``)?.split(`.`);return t.length>1?t.slice(-1)[0]:``}function Jd(e){switch(qd(e).toLowerCase()){case`jpg`:case`jpeg`:case`gif`:case`png`:case`pneg`:case`webp`:return!0;default:return!1}}async function Yd({instanceClient:e,file:t,project:n,encoding:r}){let{data:i}=await e.post(`/`,{operation:`get_component_file`,project:n,file:t,encoding:r??(Jd(t)?`base64`:`utf8`)});return{project:n,file:t,...i}}function Xd(e){return P({queryKey:Zd(e),queryFn:()=>Yd(e),enabled:!!e.file&&!!e.project,retry:!1})}function Zd(e){return[e.entityId,`get_component_file`,e.project,e.file,e.encoding]}async function Qd({file:e,payload:t,project:n,entityType:r,instanceClient:i,encoding:a}){let{data:o}=await i.post(`/`,{operation:`set_component_file`,file:e,payload:t,project:n,encoding:a,replicated:r===`cluster`},{timeout:3e5});return o}function $d(){return A({mutationFn:Qd})}function ef(){let{reloadRootEntries:e,setFocusedItem:t,setSelectedItems:n}=Gd(),r=R();return(0,B.useCallback)(async i=>{let a=!1,o=i.filter(e=>e.from!==e.to);if(o.length===0)return;let s=`Renaming ${u(o.length,`File`,`Files`)}`,c={duration:6e4,action:{label:`Cancel`,onClick:()=>{a=!0}}};c.id=M.loading(s,{...c,description:(0,z.jsx)(Fs,{animated:!0,width:`0%`})});let l=o.length*3,d=0;function f(){d+=1,M.loading(s,{...c,description:(0,z.jsx)(Fs,{animated:!0,width:(d===0?0:d/l*100)+`%`})})}for(let e of o){let t=e.from.split(`/`),n=t.shift(),i=t.join(`/`),o=e.to.split(`/`),s=o.shift(),c=o.join(`/`),l=await Yd({...r,file:i,project:n,encoding:`base64`});if(a||(f(),await Qd({...r,file:c,project:s,encoding:`base64`,payload:l.message}),a)||(f(),await Kd({...r,file:i,project:n}),a))break;f()}d>=l?M.success(`Renamed ${u(o.length,`File`,`Files`)}`,{id:c.id,description:`All done!`,duration:3e3,action:{label:`OK`,onClick:()=>{}}}):M.warning(`Rename Cancelled`,{id:c.id,description:`${d} of ${l} steps completed.`,duration:1e4,action:{label:`OK`,onClick:()=>{}}}),e(),n(e=>{let t=e.slice();for(let e of o){let n=t.indexOf(e.from);n>=0?t.splice(n,1,e.to):t.push(e.to)}return t}),t(e=>{for(let t of o)if(e===t.from)return t.to;return e})},[r,e,t,n])}function tf(e,t){return e[t]!==void 0}function nf(e){return t=>tf(t,e)}function rf(e,t){let[n,r]=(0,B.useState)({value:t});return Id(e,(e,t)=>r({value:e,trigger:t}),[r]),n}function af(e,t,n){Ld(e,t,n)}function of(e,t,n){return r=>af(e,t,n??r)}function sf(e,t,n){return(0,B.useCallback)(r=>{af(e,t,n??r)},[e,t,n])}var cf=[{handleGlobal(e,t){if((t.cmd||t.ctrl)&&e===`Delete`)return af(`ShowDeleteDirectoryOrFileModal`,!0),!0},addEditorAction(e){return{id:`delete-file`,label:`Delete File`,keybindings:[e.KeyMod.CtrlCmd|e.KeyCode.Delete],run:of(`ShowDeleteDirectoryOrFileModal`,!0)}}},{handleGlobal(e,t){if(t.ctrl&&t.alt&&t.shift&&e===`˜`)return af(`ShowAddDirectoryOrFileModalType`,`directory`),!0},addEditorAction(e){return{id:`new-directory`,label:`New Directory`,keybindings:[e.KeyMod.WinCtrl|e.KeyMod.Alt|e.KeyMod.Shift|e.KeyCode.KeyN],run:of(`ShowAddDirectoryOrFileModalType`,`directory`)}}},{handleGlobal(e,t){if(t.ctrl&&e===`n`)return af(`ShowAddDirectoryOrFileModalType`,`file`),!0},addEditorAction(e){return{id:`new-file`,label:`New File`,keybindings:[e.KeyMod.WinCtrl|e.KeyCode.KeyN],run:of(`ShowAddDirectoryOrFileModalType`,`file`)}}},{handleGlobal(e){if(e===`F2`)return af(`ShowRenameFileModal`,`file`),!0},addEditorAction(e){return{id:`rename-file`,label:`Rename File`,keybindings:[e.KeyMod.WinCtrl|e.KeyMod.Alt|e.KeyCode.KeyR,e.KeyCode.F2],run:of(`ShowRenameFileModal`,!0)}}},{addEditorAction(){return{id:`revert-file`,label:`Revert File`,run:Rd(`RevertChanges`,!0)}}},{handleGlobal(e,t){if(t.cmd&&e===`s`)return Ld(`SaveFile`,!0),!0},addEditorAction(e){return{id:`save-file`,label:`Save Changes`,keybindings:[e.KeyMod.CtrlCmd|e.KeyCode.KeyS],run:Rd(`SaveFile`,!0)}}}],lf=cf.filter(nf(`addEditorAction`)),uf=cf.filter(nf(`handleGlobal`));function df(e){let[t,n]=e,r=lf.map(e=>t.addAction(e.addEditorAction(n)));return()=>{for(let e of r)e?.dispose()}}function ff(){(0,B.useEffect)(()=>(document.addEventListener(`keydown`,pf),()=>{document.removeEventListener(`keydown`,pf)}),[])}function pf(e){let t={cmd:e.getModifierState(`Meta`),alt:e.getModifierState(`Alt`),shift:e.getModifierState(`Shift`),ctrl:e.getModifierState(`Control`)};for(let n of uf)if(n.handleGlobal(e.key,t)){e.preventDefault();return}}function mf(e){return e.split(`/`).pop()}function hf(...e){let t=e.flat(1);return t.map((e,n)=>typeof e==`string`?gf(e,n!==0,n!==t.length-1):e).join(`/`)}function gf(e,t=!0,n=!0){let r=t&&e[0]===`/`,i=n&&e[e.length-1]===`/`;return r&&i?e.slice(1,-1):r?e.slice(1):i?e.slice(0,-1):e}function _f(e){return!!e?.entries}var vf=`__root__`,yf=`importedApplications`,bf=`newApplication`;function xf(e){let t={},n=[],r=[],i=[];for(let a of e)_f(a)?a.package?r.push(a.path):n.push(a.path):i.push(a.path),Sf(t,a);return t[vf]={index:vf,isFolder:!0,children:[bf,yf,...n,...i].filter(ui),data:void 0,canMove:!1,canRename:!1},t[yf]={index:yf,isFolder:!0,children:r,data:{name:`Imported Applications`,path:yf,package:yf,project:``,entries:[]},canMove:!1,canRename:!1},t[bf]={index:bf,isFolder:!1,data:{name:`New Application`,path:bf,project:``},canMove:!1,canRename:!1},{items:t,rootId:vf}}function Sf(e,t){let n=t.path;if(_f(t)){let r=t,i=[],a=[];for(let e of r.entries)_f(e)?i.push(e.path):a.push(e.path);e[n]={index:n,isFolder:!0,children:[...i,...a],data:t,canMove:!1,canRename:!1};for(let t of r.entries)Sf(e,t)}else e[n]={index:n,isFolder:!1,data:t,canMove:!t.package,canRename:!t.package}}function Cf(){let[e,t]=(0,B.useState)(!1),[n,r]=(0,B.useState)(void 0),i=(0,B.useCallback)(e=>{if(!e.dataTransfer?.types?.includes(`Files`))return;let n=e.target;if(n instanceof Element&&n.classList.contains(`rct-tree-item-button-isFolder`)){let e=n.getAttribute(`data-rct-item-id`);!n.querySelector(`.packageIsLocked`)&&e&&e!==`importedApplications`&&e!==`newApplication`&&r(e=>e===n?e:(e?.classList?.remove?.(`rct-tree-item-title-container-dragging-over`),n.classList.add(`rct-tree-item-title-container-dragging-over`),n))}t(!0)},[]),a=(0,B.useCallback)(()=>{t(!1),r(e=>{e&&e.classList.remove(`rct-tree-item-title-container-dragging-over`)})},[]),o=(0,B.useCallback)(e=>{if(!e.dataTransfer?.types?.includes(`Files`)||e.detail===1337)return;t(!1),n&&(n.classList.remove(`rct-tree-item-title-container-dragging-over`),r(void 0));let i=document.getElementById(`dropTarget`);return i?i.dispatchEvent(new DragEvent(`drop`,{bubbles:!0,detail:1337,cancelable:!0,dataTransfer:e.dataTransfer})):!1},[n]);return(0,B.useEffect)(()=>(document.addEventListener(`dragenter`,i),document.addEventListener(`dragover`,i),document.addEventListener(`dragleave`,a),document.addEventListener(`drop`,o),()=>{document.removeEventListener(`dragenter`,i),document.removeEventListener(`dragover`,i),document.removeEventListener(`dragleave`,a),document.removeEventListener(`drop`,o)}),[i,o,a]),(0,B.useMemo)(()=>({dragging:e,dragTarget:n}),[e,n])}function wf(e){return new Promise((t,n)=>{let r=new FileReader;r.onabort=n,r.onerror=n,r.onload=t,r.readAsDataURL(e)})}function Tf(){let[e,t]=(0,B.useState)(``),{clusterId:n}=k({strict:!1}),{openedEntry:r,restrictPackageModification:i,reloadRootEntries:a,entryExists:o}=Gd(),s=!!r&&!r.package&&!i,l=R(),{dragging:d,dragTarget:f}=Cf(),p=(f?.getAttribute?.(`data-rct-item-id`))?.split?.(`/`)?.pop?.(),m=r?.project,h=!1,g;if(r?.path){let e=r.path.split(`/`),t=_f(r);h=s&&(t?e.slice(1):e.slice(1,-1)).join(`/`),g=e[e.length-(t?1:2)]}let _=(0,B.useCallback)(async(e,n)=>{let r=f?.getAttribute?.(`data-rct-item-id`)?.split?.(`/`),i=r?.length?r[0]:s?m:!1,c=r?.length?r.slice(1).join(`/`):s?h:!1;if(i===!1||i===void 0||c===!1||c===void 0)return;let d=[],p=n.slice();for(let t of e){let e=Ef(c,t);t.name.startsWith(`.`)||t.relativePath?.includes(`/.`)?p.push({file:t,errors:[{message:`Sensitive files and folders starting with . are skipped.`,code:`dot-ignored`}]}):o(`${i}/${e}`)?p.push({file:t,errors:[{message:`${e} already exists`,code:`duplicate`}]}):d.push(t)}let g=!1,_=`uploading-files`,v={label:`Cancel`,onClick:()=>{g=!0}},y={label:`OK`,onClick:()=>void 0};t(`Uploading ${u(d.length,`file`,`files`)}...`);let b=d.reduce((e,t)=>e+t.size,0),x=0,S=0;for(let e of d){S+=1,M.loading(`Upload in progress...`,{id:_,descriptionClassName:`whitespace-pre`,description:`${S} of ${u(d.length,`file`,`files`)}
12
12
  ${e.name}
13
13
  ${Vc(x)} of ${Vc(b)}`,action:v});let t=Ef(c,e),n=(await wf(e)).target.result,r=n.indexOf(`base64,`);g?p.push({file:e,errors:[{message:`${t} cancelled`,code:`cancelled`}]}):(await Qd({...l,file:t,project:i,encoding:`base64`,payload:n.slice(r+7)}),x+=e.size)}M.loading(`Reloading sidebar...`,{id:g?void 0:_,action:y,description:``}),await a(),p.length===0?e.length>0&&M.success(`Uploaded ${u(d.length,`file`,`files`)}!`,{id:_,action:y,description:``}):(console.log(p),M.error(g?`Cancelled uploads`:`Rejected uploads`,{id:g?void 0:_,action:y,descriptionClassName:`whitespace-pre overflow-y-auto`,description:p.slice(0,5).map(e=>e.errors.map(e=>e.message).join(`
14
14
  `)).join(`
@@ -48,5 +48,5 @@ Check the console for the full list.`:``)})),t(``)},[f,s,m,h,o,l,a]),{getRootPro
48
48
  focus-visible:ring-1
49
49
  focus-visible:outline-1
50
50
  focus-visible:ring-purple-200
51
- aria-invalid:focus-visible:ring-0`,{variants:{variant:{default:`bg-primary text-primary-foreground shadow-sm hover:bg-primary/90`,outline:`border bg-default border-primary border-2 text-white shadow-xs hover:-translate-y-1 transition duration-200 hover:bg-grey-700/40`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,sm:`h-8 px-1.5 min-w-8`,lg:`h-10 px-2.5 min-w-10`}},defaultVariants:{variant:`default`,size:`default`}});function u_({className:e,variant:t,size:n,...r}){return(0,z.jsx)(Ne,{"data-slot":`toggle`,className:d(l_({variant:t,size:n,className:e})),...r})}function d_(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 f_=[`secondary`,`default`,`warning`,`outline`,`success`,`destructive`],p_=0,m_=new Map,h_=e=>{if(m_.has(e))return m_.get(e);p_++;let t=f_[p_%f_.length];return m_.set(e,t),t};function g_({columns:e,data:t,onRowClick:n}){let r=pr({data:t,columns:e,getCoreRowModel:Hn()});return(0,z.jsx)(`div`,{className:`rounded-md bg-black-dark logsTable`,children:(0,z.jsxs)(xl,{className:`text-xs`,children:[(0,z.jsx)(Sl,{children:r.getHeaderGroups().map(e=>(0,z.jsx)(wl,{className:`border-none`,children:e.headers.map(e=>(0,z.jsx)(Tl,{className:`p-4 max-w-96`,children:e.isPlaceholder?null:er(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,z.jsx)(Cl,{className:`bg-black`,children:r.getRowModel().rows?.length?r.getRowModel().rows.map(e=>(0,z.jsx)(wl,{"data-state":e.getIsSelected()&&`selected`,className:d(`hover:bg-muted/10 data-[state=selected]:bg-muted max-w-full`,n&&`cursor-pointer`),onClick:()=>n?.(e),children:e.getVisibleCells().map(e=>(0,z.jsx)(Dl,{className:`p-1`,children:er(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,z.jsx)(wl,{children:(0,z.jsx)(Dl,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function __(e){try{JSON.parse(e)}catch{return!1}return!0}function v_({setIsModalOpen:e,isModalOpen:t,data:n}){let r=n?h_(n.node):`default`;return(0,z.jsx)(J,{onOpenChange:e,open:t,children:(0,z.jsxs)(Y,{"aria-describedby":void 0,children:[(0,z.jsx)(Uo,{children:(0,z.jsx)(Z,{children:`Edit Row`})}),n?(0,z.jsxs)(`div`,{className:`flex flex-col gap-3 text-white`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`inline-block pr-2`,children:`Level:`}),(0,z.jsx)(Ko,{variant:d_(n.level),children:wa(n.level)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{children:`Timestamp:`}),(0,z.jsx)(`p`,{className:`text-sm`,children:n.timestamp})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{children:`Thread:`}),(0,z.jsx)(`p`,{className:`text-sm`,children:n.thread})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{children:`Node:`}),(0,z.jsx)(Ko,{variant:r,children:n.node})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{children:`Tags:`}),(0,z.jsx)(`p`,{className:`text-sm`,children:n.tags&&n.tags.length>0?(0,z.jsx)(`span`,{children:n.tags}):`N/A`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-lg font-bold`,children:`Message`}),(0,z.jsx)(Pn,{className:`w-full h-72`,language:__(n.message)?`json`:`text`,theme:`vs-dark`,value:n.message,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1}})]})]}):(0,z.jsx)(ms,{}),(0,z.jsx)(X,{children:(0,z.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,z.jsxs)(g,{type:`button`,variant:`destructive`,className:`rounded-full`,children:[(0,z.jsx)(Ar,{}),` Delete Row`]}),(0,z.jsxs)(g,{variant:`submit`,className:`rounded-full`,children:[(0,z.jsx)(ht,{}),` Save Changes`]})]})})]})})}var y_=E({limit:C().or(w()).or(D()).optional(),level:ie([`notify`,`error`,`warn`,`info`,`debug`,`trace`,`undefined`]).or(w()).or(D()).optional(),from:C().or(w()).or(D()).optional(),until:C().or(w()).or(D()).optional(),log_name:ie([`hdb.log`,`system.log`]).or(w()).or(D()).optional()});function b_({form:e,resetFilters:t,submitFilters:n,showLogName:r}){return(0,z.jsx)(`div`,{children:(0,z.jsx)(V,{...e,children:(0,z.jsxs)(`form`,{id:`instance-edit-log-filters-form`,name:`instance-edit-log-filters-form`,onSubmit:e.handleSubmit(n),className:`flex-col space-y-5`,children:[r&&(0,z.jsx)(U,{control:e.control,name:`log_name`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{children:`Log File:`}),(0,z.jsxs)(vc,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,z.jsx)(xc,{className:`w-full`,children:(0,z.jsx)(bc,{placeholder:`Select log file`})}),(0,z.jsx)(Sc,{children:(0,z.jsxs)(yc,{children:[(0,z.jsx)($,{value:`hdb.log`,children:`Application (hdb.log)`}),(0,z.jsx)($,{value:`system.log`,children:`System (system.log)`})]})})]}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:e.control,name:`limit`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{children:`Log Limit:`}),(0,z.jsxs)(vc,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,z.jsx)(xc,{className:`w-full`,children:(0,z.jsx)(bc,{placeholder:`Select log limit`})}),(0,z.jsx)(Sc,{children:(0,z.jsxs)(yc,{children:[(0,z.jsx)($,{value:`1000`,children:`1000`}),(0,z.jsx)($,{value:`500`,children:`500`}),(0,z.jsx)($,{value:`250`,children:`250`}),(0,z.jsx)($,{value:`100`,children:`100`}),(0,z.jsx)($,{value:`10`,children:`10`})]})})]}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:e.control,name:`level`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{children:`Log Level:`}),(0,z.jsxs)(vc,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,z.jsx)(xc,{className:`w-full`,children:(0,z.jsx)(bc,{placeholder:`Select log level`})}),(0,z.jsx)(Sc,{children:(0,z.jsxs)(yc,{children:[(0,z.jsx)($,{value:`undefined`,children:`All`}),(0,z.jsx)($,{value:`notify`,children:`Notify`}),(0,z.jsx)($,{value:`error`,children:`Error`}),(0,z.jsx)($,{value:`warn`,children:`Warn`}),(0,z.jsx)($,{value:`info`,children:`Info`}),(0,z.jsx)($,{value:`debug`,children:`Debug`}),(0,z.jsx)($,{value:`trace`,children:`Trace`})]})})]}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:e.control,name:`from`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{children:`Start Date:`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`datetime-local`,value:e.value??void 0,onChange:e.onChange})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:e.control,name:`until`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{children:`End Date:`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`datetime-local`,value:e.value??void 0,onChange:e.onChange})}),(0,z.jsx)(K,{})]})}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between space-x-2 mt-2`,children:[(0,z.jsx)(g,{type:`submit`,variant:`positiveOutline`,className:`grow`,children:`Apply Filters`}),(0,z.jsx)(g,{type:`reset`,variant:`destructiveOutline`,onClick:t,children:`Clear Filters`})]})]})})})}var x_={log_name:`hdb.log`,limit:`100`,level:`undefined`,from:``,until:``},S_=[{accessorKey:`level`,header:`Status`,cell:({row:e})=>{let{level:t}=e.original;return(0,z.jsx)(Ko,{variant:d_(t),children:wa(t)})}},{accessorKey:`timestamp`,header:`Date`,cell:({row:e})=>{let{timestamp:t}=e.original;return(0,z.jsx)(`span`,{children:new Date(t).toLocaleDateString()})}},{accessorKey:`time`,header:`Time`,cell:({row:e})=>{let{timestamp:t}=e.original;return(0,z.jsx)(`span`,{children:new Date(t).toLocaleTimeString()})}},{accessorKey:`thread`,header:`Thread`},{accessorKey:`node`,header:`Node`,cell:({row:e})=>{let{node:t}=e.original,n=h_(t);return(0,z.jsx)(z.Fragment,{children:t?(0,z.jsxs)(ba,{children:[(0,z.jsx)(xa,{asChild:!0,children:(0,z.jsxs)(Ko,{variant:n,children:[t.split(`.`)[0],`...`]})}),(0,z.jsx)(Sa,{className:`bg-grey-700`,arrowClassName:`bg-grey-700 fill-grey-700`,children:t})]}):null})}},{accessorKey:`tags`,header:`Tags`},{accessorKey:`message`,header:`Message`,cell:({row:e})=>{let{message:t}=e.original;return e.getIsSelected(),(0,z.jsx)(`pre`,{children:(0,z.jsx)(`code`,{children:t})})}}],C_=(e,t)=>!e&&!t||!e||!t?!0:new Date(e)<=new Date(t);function w_(){let[e,t]=(0,B.useState)(x_),[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(),[o,s]=(0,B.useState)(!1),c=R(),{data:l}=N(Fm(c));l?.version;let{data:u,isLoading:d,refetch:f,isFetching:p}=N(a_({logFilters:e,...c,replicated:c.entityType===`cluster`,isAutoRefreshEnabled:o})),m=j({resolver:F(y_),defaultValues:x_,mode:`onChange`}),h=e=>{a(e.original),r(!0)},_=async e=>{if(!C_(e.from,e.until)){m.setError(`from`,{type:`onChange`,message:`Start date must be before end date`}),m.setError(`until`,{type:`onChange`,message:`End date must be after start date`});return}t(e)},v=async()=>{m.reset(),t(x_)},y=Nl(f);return(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 text-white md:grid-cols-12`,children:[(0,z.jsxs)(`section`,{className:`col-span-1 md:col-span-4 lg:col-span-3 px-2 pt-4 md:pt-12`,children:[(0,z.jsx)(b_,{form:m,resetFilters:v,submitFilters:_,showLogName:!1}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between space-x-2 mt-2`,children:[(0,z.jsxs)(g,{variant:`defaultOutline`,onClick:y,disabled:p||d||o,className:`grow`,children:[(0,z.jsx)($e,{}),`Refresh`]}),(0,z.jsxs)(u_,{variant:`outline`,"aria-label":`Toggle Auto Refresh`,onPressedChange:s,children:[(0,z.jsx)($e,{}),`Auto Refresh `,o?`On`:`Off`]})]})]}),(0,z.jsx)(`section`,{className:`col-span-1 md:col-span-8 lg:col-span-9`,children:d?(0,z.jsx)(`div`,{children:`Loading...`}):(0,z.jsx)(`div`,{children:(0,z.jsx)(g_,{columns:S_,data:u||[],onRowClick:h})})}),(0,z.jsx)(v_,{isModalOpen:n,setIsModalOpen:r,data:i})]})}function T_(e){return I({getParentRoute:()=>e,path:`logs`,component:w_})}function E_(e){return I({getParentRoute:()=>e,path:`status`,component:kn(async()=>yi(()=>import(`./status-110CCE-v.js`),__vite__mapDeps([15,1,3,2,4,5,6,7,8,9,10,11,12])),`StatusIndex`)})}function D_(e){let t=s_(e),n=[T_(t),...sm(t),Md(t),E_(t),Uh(t),Yg(t)];return t.addChildren(n)}I({getParentRoute:()=>Mu,path:`profile`,component:kn(async()=>yi(()=>import(`./profile-voeNsl4C.js`),__vite__mapDeps([16,1,4,3,2,5,6,7,8,9,10,11,17])),`ProfileIndex`)});var O_=Pi.addChildren([...Mo,Mu.addChildren([D_(`local`)])]);function k_({routeTree:e=O_,authentication:t}){return nr({routeTree:e,history:xe(),defaultNotFoundComponent:Ti,defaultErrorComponent:wi,defaultPreload:Ei()?!1:`intent`,trailingSlash:`never`,defaultPreloadStaleTime:0,scrollRestoration:!0,context:{queryClient:Oi,authentication:t||{}}})}function A_(){let e=ai(),t=k_({authentication:e});return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Sn,{router:t,context:{authentication:e}}),(0,z.jsx)(gt,{router:t,position:`bottom-right`})]})}var j_=({...e})=>(0,z.jsx)(qn,{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}),M_=!1,N_=!1;function P_(){(0,B.useEffect)(()=>{M_||(M_=!0,N_&&(function(e,t,n,r,i){e[r]=e[r]||[],e[r].push({"gtm.start":new Date().getTime(),event:`gtm.js`});let a=t.getElementsByTagName(n)[0],o=t.createElement(n),s=r===`dataLayer`?``:`&l=${r}`;o.async=!0,o.src=`https://www.googletagmanager.com/gtm.js?id=`+i+s,a.parentNode.insertBefore(o,a)})(window,document,`script`,`dataLayer`,`GTM-5QQX432`))},[])}function F_(){return ma(),ji(),P_(),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(et,{client:Oi,children:[(0,z.jsx)(A_,{}),(0,z.jsx)(ct,{buttonPosition:`bottom-right`})]}),(0,z.jsx)(j_,{richColors:!0})]})}(0,rt().createRoot)(document.getElementById(`root`),{onUncaughtError:(e,t)=>{Tn(e,t),console.error(`Uncaught error:`,e,t)},onCaughtError:(e,t)=>{Tn(e,t),console.error(`Caught error:`,e,t)},onRecoverableError:(e,t)=>{Tn(e,t),console.warn(`Recoverable error:`,e,t)}}).render((0,z.jsx)(B.StrictMode,{children:(0,z.jsx)(F_,{})}));export{U as A,Wo as C,K as D,q as E,xa as F,Ki as I,wi as L,V as M,ba as N,G as O,Sa as P,Y as S,Z as T,xc as _,Nm as a,ms as b,Jf as c,wd as d,jl as f,$ as g,Sc as h,Pm as i,H as j,W as k,Kf as l,vc as m,n_ as n,jp as o,Vc as p,Fm as r,Gf as s,t_ as t,qf as u,bc as v,Uo as w,J as x,ks as y};
52
- //# sourceMappingURL=index-Tv7e9k8K.js.map
51
+ aria-invalid:focus-visible:ring-0`,{variants:{variant:{default:`bg-primary text-primary-foreground shadow-sm hover:bg-primary/90`,outline:`border bg-default border-primary border-2 text-white shadow-xs hover:-translate-y-1 transition duration-200 hover:bg-grey-700/40`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,sm:`h-8 px-1.5 min-w-8`,lg:`h-10 px-2.5 min-w-10`}},defaultVariants:{variant:`default`,size:`default`}});function u_({className:e,variant:t,size:n,...r}){return(0,z.jsx)(Ne,{"data-slot":`toggle`,className:d(l_({variant:t,size:n,className:e})),...r})}function d_(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 f_=[`secondary`,`default`,`warning`,`outline`,`success`,`destructive`],p_=0,m_=new Map,h_=e=>{if(m_.has(e))return m_.get(e);p_++;let t=f_[p_%f_.length];return m_.set(e,t),t};function g_({columns:e,data:t,onRowClick:n}){let r=pr({data:t,columns:e,getCoreRowModel:Hn()});return(0,z.jsx)(`div`,{className:`rounded-md bg-black-dark logsTable`,children:(0,z.jsxs)(xl,{className:`text-xs`,children:[(0,z.jsx)(Sl,{children:r.getHeaderGroups().map(e=>(0,z.jsx)(wl,{className:`border-none`,children:e.headers.map(e=>(0,z.jsx)(Tl,{className:`p-4 max-w-96`,children:e.isPlaceholder?null:er(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,z.jsx)(Cl,{className:`bg-black`,children:r.getRowModel().rows?.length?r.getRowModel().rows.map(e=>(0,z.jsx)(wl,{"data-state":e.getIsSelected()&&`selected`,className:d(`hover:bg-muted/10 data-[state=selected]:bg-muted max-w-full`,n&&`cursor-pointer`),onClick:()=>n?.(e),children:e.getVisibleCells().map(e=>(0,z.jsx)(Dl,{className:`p-1`,children:er(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,z.jsx)(wl,{children:(0,z.jsx)(Dl,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function __(e){try{JSON.parse(e)}catch{return!1}return!0}function v_({setIsModalOpen:e,isModalOpen:t,data:n}){let r=n?h_(n.node):`default`;return(0,z.jsx)(J,{onOpenChange:e,open:t,children:(0,z.jsxs)(Y,{"aria-describedby":void 0,children:[(0,z.jsx)(Uo,{children:(0,z.jsx)(Z,{children:`Edit Row`})}),n?(0,z.jsxs)(`div`,{className:`flex flex-col gap-3 text-white`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`inline-block pr-2`,children:`Level:`}),(0,z.jsx)(Ko,{variant:d_(n.level),children:wa(n.level)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{children:`Timestamp:`}),(0,z.jsx)(`p`,{className:`text-sm`,children:n.timestamp})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{children:`Thread:`}),(0,z.jsx)(`p`,{className:`text-sm`,children:n.thread})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{children:`Node:`}),(0,z.jsx)(Ko,{variant:r,children:n.node})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{children:`Tags:`}),(0,z.jsx)(`p`,{className:`text-sm`,children:n.tags&&n.tags.length>0?(0,z.jsx)(`span`,{children:n.tags}):`N/A`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-lg font-bold`,children:`Message`}),(0,z.jsx)(Pn,{className:`w-full h-72`,language:__(n.message)?`json`:`text`,theme:`vs-dark`,value:n.message,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1}})]})]}):(0,z.jsx)(ms,{}),(0,z.jsx)(X,{children:(0,z.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,z.jsxs)(g,{type:`button`,variant:`destructive`,className:`rounded-full`,children:[(0,z.jsx)(Ar,{}),` Delete Row`]}),(0,z.jsxs)(g,{variant:`submit`,className:`rounded-full`,children:[(0,z.jsx)(ht,{}),` Save Changes`]})]})})]})})}var y_=E({limit:C().or(w()).or(D()).optional(),level:ie([`notify`,`error`,`warn`,`info`,`debug`,`trace`,`undefined`]).or(w()).or(D()).optional(),from:C().or(w()).or(D()).optional(),until:C().or(w()).or(D()).optional(),log_name:ie([`hdb.log`,`system.log`]).or(w()).or(D()).optional()});function b_({form:e,resetFilters:t,submitFilters:n,showLogName:r}){return(0,z.jsx)(`div`,{children:(0,z.jsx)(V,{...e,children:(0,z.jsxs)(`form`,{id:`instance-edit-log-filters-form`,name:`instance-edit-log-filters-form`,onSubmit:e.handleSubmit(n),className:`flex-col space-y-5`,children:[r&&(0,z.jsx)(U,{control:e.control,name:`log_name`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{children:`Log File:`}),(0,z.jsxs)(vc,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,z.jsx)(xc,{className:`w-full`,children:(0,z.jsx)(bc,{placeholder:`Select log file`})}),(0,z.jsx)(Sc,{children:(0,z.jsxs)(yc,{children:[(0,z.jsx)($,{value:`hdb.log`,children:`Application (hdb.log)`}),(0,z.jsx)($,{value:`system.log`,children:`System (system.log)`})]})})]}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:e.control,name:`limit`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{children:`Log Limit:`}),(0,z.jsxs)(vc,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,z.jsx)(xc,{className:`w-full`,children:(0,z.jsx)(bc,{placeholder:`Select log limit`})}),(0,z.jsx)(Sc,{children:(0,z.jsxs)(yc,{children:[(0,z.jsx)($,{value:`1000`,children:`1000`}),(0,z.jsx)($,{value:`500`,children:`500`}),(0,z.jsx)($,{value:`250`,children:`250`}),(0,z.jsx)($,{value:`100`,children:`100`}),(0,z.jsx)($,{value:`10`,children:`10`})]})})]}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:e.control,name:`level`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{children:`Log Level:`}),(0,z.jsxs)(vc,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,z.jsx)(xc,{className:`w-full`,children:(0,z.jsx)(bc,{placeholder:`Select log level`})}),(0,z.jsx)(Sc,{children:(0,z.jsxs)(yc,{children:[(0,z.jsx)($,{value:`undefined`,children:`All`}),(0,z.jsx)($,{value:`notify`,children:`Notify`}),(0,z.jsx)($,{value:`error`,children:`Error`}),(0,z.jsx)($,{value:`warn`,children:`Warn`}),(0,z.jsx)($,{value:`info`,children:`Info`}),(0,z.jsx)($,{value:`debug`,children:`Debug`}),(0,z.jsx)($,{value:`trace`,children:`Trace`})]})})]}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:e.control,name:`from`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{children:`Start Date:`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`datetime-local`,value:e.value??void 0,onChange:e.onChange})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(U,{control:e.control,name:`until`,render:({field:e})=>(0,z.jsxs)(W,{children:[(0,z.jsx)(G,{children:`End Date:`}),(0,z.jsx)(H,{children:(0,z.jsx)(q,{type:`datetime-local`,value:e.value??void 0,onChange:e.onChange})}),(0,z.jsx)(K,{})]})}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between space-x-2 mt-2`,children:[(0,z.jsx)(g,{type:`submit`,variant:`positiveOutline`,className:`grow`,children:`Apply Filters`}),(0,z.jsx)(g,{type:`reset`,variant:`destructiveOutline`,onClick:t,children:`Clear Filters`})]})]})})})}var x_={log_name:`hdb.log`,limit:`100`,level:`undefined`,from:``,until:``},S_=[{accessorKey:`level`,header:`Status`,cell:({row:e})=>{let{level:t}=e.original;return(0,z.jsx)(Ko,{variant:d_(t),children:wa(t)})}},{accessorKey:`timestamp`,header:`Date`,cell:({row:e})=>{let{timestamp:t}=e.original;return(0,z.jsx)(`span`,{children:new Date(t).toLocaleDateString()})}},{accessorKey:`time`,header:`Time`,cell:({row:e})=>{let{timestamp:t}=e.original;return(0,z.jsx)(`span`,{children:new Date(t).toLocaleTimeString()})}},{accessorKey:`thread`,header:`Thread`},{accessorKey:`node`,header:`Node`,cell:({row:e})=>{let{node:t}=e.original,n=h_(t);return(0,z.jsx)(z.Fragment,{children:t?(0,z.jsxs)(ba,{children:[(0,z.jsx)(xa,{asChild:!0,children:(0,z.jsxs)(Ko,{variant:n,children:[t.split(`.`)[0],`...`]})}),(0,z.jsx)(Sa,{className:`bg-grey-700`,arrowClassName:`bg-grey-700 fill-grey-700`,children:t})]}):null})}},{accessorKey:`tags`,header:`Tags`},{accessorKey:`message`,header:`Message`,cell:({row:e})=>{let{message:t}=e.original;return e.getIsSelected(),(0,z.jsx)(`pre`,{children:(0,z.jsx)(`code`,{children:t})})}}],C_=(e,t)=>!e&&!t||!e||!t?!0:new Date(e)<=new Date(t);function w_(){let[e,t]=(0,B.useState)(x_),[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(),[o,s]=(0,B.useState)(!1),c=R(),{data:l}=N(Fm(c));l?.version;let{data:u,isLoading:d,refetch:f,isFetching:p}=N(a_({logFilters:e,...c,replicated:c.entityType===`cluster`,isAutoRefreshEnabled:o})),m=j({resolver:F(y_),defaultValues:x_,mode:`onChange`}),h=e=>{a(e.original),r(!0)},_=async e=>{if(!C_(e.from,e.until)){m.setError(`from`,{type:`onChange`,message:`Start date must be before end date`}),m.setError(`until`,{type:`onChange`,message:`End date must be after start date`});return}t(e)},v=async()=>{m.reset(),t(x_)},y=Nl(f);return(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 text-white md:grid-cols-12`,children:[(0,z.jsxs)(`section`,{className:`col-span-1 md:col-span-4 lg:col-span-3 px-2 pt-4 md:pt-12`,children:[(0,z.jsx)(b_,{form:m,resetFilters:v,submitFilters:_,showLogName:!1}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between space-x-2 mt-2`,children:[(0,z.jsxs)(g,{variant:`defaultOutline`,onClick:y,disabled:p||d||o,className:`grow`,children:[(0,z.jsx)($e,{}),`Refresh`]}),(0,z.jsxs)(u_,{variant:`outline`,"aria-label":`Toggle Auto Refresh`,onPressedChange:s,children:[(0,z.jsx)($e,{}),`Auto Refresh `,o?`On`:`Off`]})]})]}),(0,z.jsx)(`section`,{className:`col-span-1 md:col-span-8 lg:col-span-9`,children:d?(0,z.jsx)(`div`,{children:`Loading...`}):(0,z.jsx)(`div`,{children:(0,z.jsx)(g_,{columns:S_,data:u||[],onRowClick:h})})}),(0,z.jsx)(v_,{isModalOpen:n,setIsModalOpen:r,data:i})]})}function T_(e){return I({getParentRoute:()=>e,path:`logs`,component:w_})}function E_(e){return I({getParentRoute:()=>e,path:`status`,component:kn(async()=>yi(()=>import(`./status-BrfTnnpt.js`),__vite__mapDeps([15,1,3,2,4,5,6,7,8,9,10,11,12])),`StatusIndex`)})}function D_(e){let t=s_(e),n=[T_(t),...sm(t),Md(t),E_(t),Uh(t),Yg(t)];return t.addChildren(n)}I({getParentRoute:()=>Mu,path:`profile`,component:kn(async()=>yi(()=>import(`./profile-Dyrp-ZIJ.js`),__vite__mapDeps([16,1,4,3,2,5,6,7,8,9,10,11,17])),`ProfileIndex`)});var O_=Pi.addChildren([...Mo,Mu.addChildren([D_(`local`)])]);function k_({routeTree:e=O_,authentication:t}){return nr({routeTree:e,history:xe(),defaultNotFoundComponent:Ti,defaultErrorComponent:wi,defaultPreload:Ei()?!1:`intent`,trailingSlash:`never`,defaultPreloadStaleTime:0,scrollRestoration:!0,context:{queryClient:Oi,authentication:t||{}}})}function A_(){let e=ai(),t=k_({authentication:e});return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Sn,{router:t,context:{authentication:e}}),(0,z.jsx)(gt,{router:t,position:`bottom-right`})]})}var j_=({...e})=>(0,z.jsx)(qn,{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}),M_=!1,N_=!1;function P_(){(0,B.useEffect)(()=>{M_||(M_=!0,N_&&(function(e,t,n,r,i){e[r]=e[r]||[],e[r].push({"gtm.start":new Date().getTime(),event:`gtm.js`});let a=t.getElementsByTagName(n)[0],o=t.createElement(n),s=r===`dataLayer`?``:`&l=${r}`;o.async=!0,o.src=`https://www.googletagmanager.com/gtm.js?id=`+i+s,a.parentNode.insertBefore(o,a)})(window,document,`script`,`dataLayer`,`GTM-5QQX432`))},[])}function F_(){return ma(),ji(),P_(),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(et,{client:Oi,children:[(0,z.jsx)(A_,{}),(0,z.jsx)(ct,{buttonPosition:`bottom-right`})]}),(0,z.jsx)(j_,{richColors:!0})]})}(0,rt().createRoot)(document.getElementById(`root`),{onUncaughtError:(e,t)=>{Tn(e,t),console.error(`Uncaught error:`,e,t)},onCaughtError:(e,t)=>{Tn(e,t),console.error(`Caught error:`,e,t)},onRecoverableError:(e,t)=>{Tn(e,t),console.warn(`Recoverable error:`,e,t)}}).render((0,z.jsx)(B.StrictMode,{children:(0,z.jsx)(F_,{})}));export{U as A,Wo as C,K as D,q as E,xa as F,Ki as I,wi as L,V as M,ba as N,G as O,Sa as P,Y as S,Z as T,xc as _,Nm as a,ms as b,Jf as c,wd as d,jl as f,$ as g,Sc as h,Pm as i,H as j,W as k,Kf as l,vc as m,n_ as n,jp as o,Vc as p,Fm as r,Gf as s,t_ as t,qf as u,bc as v,Uo as w,J as x,ks as y};
52
+ //# sourceMappingURL=index-BIjBsaWw.js.map